Skip to content

Commit de81392

Browse files
authored
Merge pull request #445 from hossein-zare/dev-5.x
Bugfix: schemaless item props.
2 parents 81f9708 + 7967ffe commit de81392

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

index.d.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ declare module "react-native-dropdown-picker" {
107107
selectedItemLabelStyle: StyleProp<TextStyle>;
108108
disabledItemContainerStyle: StyleProp<ViewStyle>;
109109
disabledItemLabelStyle: StyleProp<TextStyle>;
110+
containerStyle: StyleProp<ViewStyle>;
111+
labelStyle: StyleProp<TextStyle>;
110112
categorySelectable: boolean;
111113
onPress: () => void;
112114
setPosition: (value: ValueType, y: number) => void;
@@ -238,20 +240,13 @@ declare module "react-native-dropdown-picker" {
238240
rtl?: boolean;
239241
};
240242

241-
type GetSelectedItemOutputType = ItemType | undefined | null;
242-
type GetSelectedItemsOutputType = ItemType[] | undefined;
243-
244243
interface DropDownPickerInterface {
245244
MODE: ModeInterface;
246245
LIST_MODE: ListModeInterface;
247246
DROPDOWN_DIRECTION: DropDownDirectionType;
248247
SCHEMA: SchemaInterface;
249248
LANGUAGE: LanguageType;
250249
THEMES: ThemeNameType;
251-
HELPER: {
252-
GET_SELECTED_ITEM: (items: ItemType[], value: string | number | null, key?: string) => GetSelectedItemOutputType;
253-
GET_SELECTED_ITEMS: (items: ItemType[], values: string[] | number[] | null, key?: string) => GetSelectedItemsOutputType;
254-
};
255250
setMode: (mode: string) => void;
256251
setListMode: (mode: string) => void;
257252
setDropDownDirection: (direction: DropDownDirectionType) => void;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-dropdown-picker",
3-
"version": "5.2.2",
3+
"version": "5.2.3",
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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,9 @@ function Picker({
13291329
item={item}
13301330
label={item[_schema.label]}
13311331
value={item[_schema.value]}
1332-
parent={item[_schema.parent] ?? null}
1333-
selectable={item[_schema.selectable] ?? null}
1334-
disabled={item[_schema.disabled] ?? false}
1332+
parent={item?.[_schema.parent] ?? null}
1333+
selectable={item?.[_schema.selectable] ?? null}
1334+
disabled={item?.[_schema.disabled] ?? false}
13351335
custom={item.custom ?? false}
13361336
props={itemProps}
13371337
isSelected={isSelected}
@@ -1349,6 +1349,8 @@ function Picker({
13491349
selectedItemLabelStyle={_selectedItemLabelStyle}
13501350
disabledItemContainerStyle={_disabledItemContainerStyle}
13511351
disabledItemLabelStyle={_disabledItemLabelStyle}
1352+
labelStyle={item?.[_schema.labelStyle] ?? {}}
1353+
containerStyle={item?.[_schema.containerStyle] ?? {}}
13521354
categorySelectable={categorySelectable}
13531355
onPress={onPressItem}
13541356
setPosition={setItemPosition}

src/components/RenderListItem.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ function RenderListItem({
3636
selectedItemLabelStyle,
3737
disabledItemContainerStyle,
3838
disabledItemLabelStyle,
39+
containerStyle,
40+
labelStyle,
3941
categorySelectable,
4042
onPress,
4143
setPosition,
@@ -89,11 +91,11 @@ function RenderListItem({
8991
const _listItemContainerStyle = useMemo(() => ([
9092
...[listItemContainerStyle].flat(),
9193
...[_listParentChildContainerStyle].flat(),
92-
...[item?.containerStyle ?? {}].flat(),
94+
...[containerStyle].flat(),
9395
...[_selectedItemContainerStyle].flat(),
9496
...[_customItemContainerStyle].flat(),
9597
...[_disabledItemContainerStyle].flat(),
96-
]), [listItemContainerStyle, _listParentChildContainerStyle, _selectedItemContainerStyle, _customItemContainerStyle, _disabledItemContainerStyle]);
98+
]), [listItemContainerStyle, _listParentChildContainerStyle, _selectedItemContainerStyle, _customItemContainerStyle, _disabledItemContainerStyle, containerStyle]);
9799

98100
/**
99101
* The list category label style.
@@ -135,11 +137,11 @@ function RenderListItem({
135137
const _listItemLabelStyle = useMemo(() => ([
136138
...[listItemLabelStyle].flat(),
137139
...[_listParentChildLabelStyle].flat(),
138-
...[item?.labelStyle ?? {}].flat(),
140+
...[labelStyle].flat(),
139141
...[_selectedItemLabelStyle].flat(),
140142
...[_customItemLabelStyle].flat(),
141143
...[_disabledItemLabelStyle].flat(),
142-
]), [listItemLabelStyle, _listParentChildLabelStyle, _selectedItemLabelStyle, _customItemLabelStyle, _disabledItemLabelStyle]);
144+
]), [listItemLabelStyle, _listParentChildLabelStyle, _selectedItemLabelStyle, _customItemLabelStyle, _disabledItemLabelStyle, labelStyle]);
143145

144146
/**
145147
* onPress.

0 commit comments

Comments
 (0)