Skip to content

Commit

Permalink
Merge pull request #445 from hossein-zare/dev-5.x
Browse files Browse the repository at this point in the history
Bugfix: schemaless item props.
  • Loading branch information
hossein-zare authored Oct 25, 2021
2 parents 81f9708 + 7967ffe commit de81392
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
9 changes: 2 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ declare module "react-native-dropdown-picker" {
selectedItemLabelStyle: StyleProp<TextStyle>;
disabledItemContainerStyle: StyleProp<ViewStyle>;
disabledItemLabelStyle: StyleProp<TextStyle>;
containerStyle: StyleProp<ViewStyle>;
labelStyle: StyleProp<TextStyle>;
categorySelectable: boolean;
onPress: () => void;
setPosition: (value: ValueType, y: number) => void;
Expand Down Expand Up @@ -238,20 +240,13 @@ declare module "react-native-dropdown-picker" {
rtl?: boolean;
};

type GetSelectedItemOutputType = ItemType | undefined | null;
type GetSelectedItemsOutputType = ItemType[] | undefined;

interface DropDownPickerInterface {
MODE: ModeInterface;
LIST_MODE: ListModeInterface;
DROPDOWN_DIRECTION: DropDownDirectionType;
SCHEMA: SchemaInterface;
LANGUAGE: LanguageType;
THEMES: ThemeNameType;
HELPER: {
GET_SELECTED_ITEM: (items: ItemType[], value: string | number | null, key?: string) => GetSelectedItemOutputType;
GET_SELECTED_ITEMS: (items: ItemType[], values: string[] | number[] | null, key?: string) => GetSelectedItemsOutputType;
};
setMode: (mode: string) => void;
setListMode: (mode: string) => void;
setDropDownDirection: (direction: DropDownDirectionType) => void;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-dropdown-picker",
"version": "5.2.2",
"version": "5.2.3",
"description": "A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.",
"keywords": [
"picker",
Expand Down
8 changes: 5 additions & 3 deletions src/components/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,9 @@ function Picker({
item={item}
label={item[_schema.label]}
value={item[_schema.value]}
parent={item[_schema.parent] ?? null}
selectable={item[_schema.selectable] ?? null}
disabled={item[_schema.disabled] ?? false}
parent={item?.[_schema.parent] ?? null}
selectable={item?.[_schema.selectable] ?? null}
disabled={item?.[_schema.disabled] ?? false}
custom={item.custom ?? false}
props={itemProps}
isSelected={isSelected}
Expand All @@ -1349,6 +1349,8 @@ function Picker({
selectedItemLabelStyle={_selectedItemLabelStyle}
disabledItemContainerStyle={_disabledItemContainerStyle}
disabledItemLabelStyle={_disabledItemLabelStyle}
labelStyle={item?.[_schema.labelStyle] ?? {}}
containerStyle={item?.[_schema.containerStyle] ?? {}}
categorySelectable={categorySelectable}
onPress={onPressItem}
setPosition={setItemPosition}
Expand Down
10 changes: 6 additions & 4 deletions src/components/RenderListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function RenderListItem({
selectedItemLabelStyle,
disabledItemContainerStyle,
disabledItemLabelStyle,
containerStyle,
labelStyle,
categorySelectable,
onPress,
setPosition,
Expand Down Expand Up @@ -89,11 +91,11 @@ function RenderListItem({
const _listItemContainerStyle = useMemo(() => ([
...[listItemContainerStyle].flat(),
...[_listParentChildContainerStyle].flat(),
...[item?.containerStyle ?? {}].flat(),
...[containerStyle].flat(),
...[_selectedItemContainerStyle].flat(),
...[_customItemContainerStyle].flat(),
...[_disabledItemContainerStyle].flat(),
]), [listItemContainerStyle, _listParentChildContainerStyle, _selectedItemContainerStyle, _customItemContainerStyle, _disabledItemContainerStyle]);
]), [listItemContainerStyle, _listParentChildContainerStyle, _selectedItemContainerStyle, _customItemContainerStyle, _disabledItemContainerStyle, containerStyle]);

/**
* The list category label style.
Expand Down Expand Up @@ -135,11 +137,11 @@ function RenderListItem({
const _listItemLabelStyle = useMemo(() => ([
...[listItemLabelStyle].flat(),
...[_listParentChildLabelStyle].flat(),
...[item?.labelStyle ?? {}].flat(),
...[labelStyle].flat(),
...[_selectedItemLabelStyle].flat(),
...[_customItemLabelStyle].flat(),
...[_disabledItemLabelStyle].flat(),
]), [listItemLabelStyle, _listParentChildLabelStyle, _selectedItemLabelStyle, _customItemLabelStyle, _disabledItemLabelStyle]);
]), [listItemLabelStyle, _listParentChildLabelStyle, _selectedItemLabelStyle, _customItemLabelStyle, _disabledItemLabelStyle, labelStyle]);

/**
* onPress.
Expand Down

0 comments on commit de81392

Please sign in to comment.