Skip to content

Commit 1b3b586

Browse files
authored
Merge pull request #355 from hossein-zare/dev-5.x
v5.1.20
2 parents e3df0fd + cc0b038 commit 1b3b586

File tree

5 files changed

+29
-46
lines changed

5 files changed

+29
-46
lines changed

index.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import {ComponentType, SetStateAction, Dispatch} from "react";
2-
import {
3-
FlatListProps,
4-
LayoutChangeEvent,
5-
ModalProps,
6-
ScrollViewProps,
7-
StyleProp,
8-
TextInputProps,
9-
TextProps,
10-
TextStyle,
11-
ViewProps,
12-
ViewStyle
13-
} from "react-native";
14-
151
declare module "react-native-dropdown-picker" {
2+
import type {ComponentType, SetStateAction, Dispatch} from "react";
3+
import type {
4+
FlatListProps,
5+
LayoutChangeEvent,
6+
ModalProps,
7+
ScrollViewProps,
8+
StyleProp,
9+
TextInputProps,
10+
TextProps,
11+
TextStyle,
12+
ViewProps,
13+
ViewStyle
14+
} from "react-native";
15+
1616
export type ValueType = string | number | boolean;
1717

1818
export type ItemType = {
@@ -205,9 +205,9 @@ declare module "react-native-dropdown-picker" {
205205
min?: number;
206206
max?: number;
207207
addCustomItem?: boolean;
208-
setOpen: (open: boolean) => void;
208+
setOpen: Dispatch<SetStateAction<boolean>>;
209209
setItems?: Dispatch<SetStateAction<any[]>>;
210-
setValue: (callback: (state: ValueType | ValueType[] | null) => ValueType | ValueType[] | null) => void;
210+
setValue: Dispatch<any>;
211211
disableBorderRadius?: boolean;
212212
containerProps?: ViewProps;
213213
onLayout?: (e: LayoutChangeEvent) => void;
@@ -251,5 +251,5 @@ declare module "react-native-dropdown-picker" {
251251
const DropDownPicker: ComponentType<DropDownPickerProps> & DropDownPickerInterface;
252252
export default DropDownPicker;
253253
}
254-
254+
255255
//TODO: remove uses of the ambiguous "any" and "object" types

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-dropdown-picker",
3-
"version": "5.1.19",
3+
"version": "5.1.20",
44
"description": "A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.",
55
"keywords": [
66
"picker",

src/components/Picker.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import React, {
1010

1111
import {
1212
View,
13+
SafeAreaView,
1314
TouchableOpacity,
1415
Text,
1516
Image,
@@ -525,8 +526,6 @@ function Picker({
525526
open,
526527
onPressToggle,
527528
onPress,
528-
onOpen,
529-
onClose,
530529
pickerRef,
531530
maxHeight,
532531
pickerHeight,
@@ -632,7 +631,7 @@ function Picker({
632631
...[textStyle].flat(),
633632
...[! isNull && labelStyle].flat(),
634633
...[_placeholderStyle].flat(),
635-
]), [textStyle, _placeholderStyle, labelStyle, THEME]);
634+
]), [textStyle, _placeholderStyle, labelStyle, isNull, THEME]);
636635

637636
/**
638637
* The arrow icon style.
@@ -904,7 +903,7 @@ function Picker({
904903
*/
905904
const BadgeSeparatorComponent = useCallback(() => (
906905
<View style={_badgeSeparatorStyle} />
907-
), [badgeSeparatorStyle]);
906+
), [_badgeSeparatorStyle]);
908907

909908
/**
910909
* The label container.
@@ -1262,7 +1261,6 @@ function Picker({
12621261
disabledItemContainerStyle={_disabledItemContainerStyle}
12631262
disabledItemLabelStyle={_disabledItemLabelStyle}
12641263
categorySelectable={categorySelectable}
1265-
listMode={listMode}
12661264
onPress={onPressItem}
12671265
theme={theme}
12681266
THEME={THEME}
@@ -1290,7 +1288,6 @@ function Picker({
12901288
_value,
12911289
multiple,
12921290
categorySelectable,
1293-
listMode,
12941291
onPressItem,
12951292
theme,
12961293
THEME
@@ -1498,20 +1495,20 @@ function Picker({
14981495
{_items.length === 0 && _ListEmptyComponent()}
14991496
</ScrollView>
15001497
);
1501-
}, [renderListItem, __renderListItem, _itemKey, scrollViewProps, _ListEmptyComponent]);
1498+
}, [__renderListItem, _itemKey, scrollViewProps, _ListEmptyComponent]);
15021499

15031500
/**
15041501
* The dropdown modal component.
15051502
* @returns {JSX.Element}
15061503
*/
15071504
const DropDownModalComponent = useMemo(() => (
15081505
<Modal visible={open} presentationStyle="fullScreen" {...modalProps}>
1509-
<View style={_modalContentContainerStyle}>
1506+
<SafeAreaView style={_modalContentContainerStyle}>
15101507
{SearchComponent}
15111508
{DropDownFlatListComponent}
1512-
</View>
1509+
</SafeAreaView>
15131510
</Modal>
1514-
), [open, SearchComponent, DropDownComponentWrapper, _modalContentContainerStyle, modalProps]);
1511+
), [open, SearchComponent, _modalContentContainerStyle, modalProps]);
15151512

15161513
/**
15171514
* The dropdown component.

src/components/RenderBadgeItem.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import React, {
55
import {
66
View,
77
Text,
8+
TouchableOpacity
89
} from 'react-native';
910

10-
import { TouchableOpacity } from 'react-native-gesture-handler';
11-
1211
import { RTL_DIRECTION, RTL_STYLE } from '../constants';
1312

1413
function RenderBadge({

src/components/RenderListItem.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import {
99
TouchableOpacity
1010
} from 'react-native';
1111

12-
import {
13-
TouchableOpacity as TouchableOpacityGestureHandler
14-
} from 'react-native-gesture-handler';
15-
1612
import { LIST_MODE } from '../constants';
1713

1814
function RenderListItem({
@@ -40,7 +36,6 @@ function RenderListItem({
4036
disabledItemContainerStyle,
4137
disabledItemLabelStyle,
4238
categorySelectable,
43-
listMode,
4439
onPress,
4540
THEME
4641
}) {
@@ -151,22 +146,16 @@ function RenderListItem({
151146
}
152147

153148
onPress(item, custom);
154-
}, [onPress, parent, categorySelectable, label, value, custom]);
155-
156-
const _TouchableOpacity = useMemo(() => {
157-
if (listMode === LIST_MODE.MODAL)
158-
return TouchableOpacity;
159-
return TouchableOpacityGestureHandler;
160-
}, [listMode]);
149+
}, [onPress, parent, categorySelectable, custom]);
161150

162151
return (
163-
<_TouchableOpacity style={_listItemContainerStyle} onPress={__onPress} disabled={selectable === false || disabled}>
152+
<TouchableOpacity style={_listItemContainerStyle} onPress={__onPress} disabled={selectable === false || disabled}>
164153
{IconComponent}
165154
<Text style={_listItemLabelStyle}>
166155
{label}
167156
</Text>
168157
{_TickIconComponent}
169-
</_TouchableOpacity>
158+
</TouchableOpacity>
170159
);
171160
}
172161

@@ -187,8 +176,6 @@ const areEqual = (nextProps, prevProps) => {
187176
return false;
188177
if (nextProps.categorySelectable !== prevProps.categorySelectable)
189178
return false;
190-
if (nextProps.listMode !== prevProps.listMode)
191-
return false;
192179
if (nextProps.rtl !== prevProps.rtl)
193180
return false;
194181
if (nextProps.theme !== prevProps.theme)

0 commit comments

Comments
 (0)