Skip to content

Commit

Permalink
feat: add enabled props for web
Browse files Browse the repository at this point in the history
  • Loading branch information
Naturalclar committed Sep 11, 2021
1 parent b4ac9a3 commit 04f0179
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ If set to false, the picker will be disabled, i.e. the user will not be able to

| Type | Required | Platform |
| ---- | -------- | -------- |
| bool | No | Android, Windows |
| bool | No | Android, Web, Windows |

---

Expand Down
13 changes: 12 additions & 1 deletion js/PickerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
color?: ColorValue,
label: string,
testID?: string,
enabled?: Boolean,
value?: number | string,
};

Expand All @@ -22,14 +23,24 @@ const createElement =

const Option = (props: any) => createElement('option', props);

/**
* PickerItem Component for React Native Web
* @returns
*/
export default function PickerItem({
color,
label,
testID,
value,
enabled = true,
}: Props): React.Node {
return (
<Option style={{color}} testID={testID} value={value} label={label}>
<Option
disabled={enabled === false ? true : undefined}
style={{color}}
testID={testID}
value={value}
label={label}>
{label}
</Option>
);
Expand Down
2 changes: 1 addition & 1 deletion typings/Picker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface PickerItemProps<T = ItemValue> {
* If set to false, the specific item will be disabled, i.e. the user will not be able to make a
* selection.
* @default true
* @platform android
* @platform android | web
*/
enabled?: boolean;
}
Expand Down

0 comments on commit 04f0179

Please sign in to comment.