|
1 |
| -/// <reference types="react" /> |
| 1 | +import { ViewStyle, TextStyle, ModalProps, TextInputProperties, PickerProps } from 'react-native'; |
| 2 | +import React from 'react'; |
2 | 3 |
|
3 |
| -declare module 'react-native-picker-select' { |
4 |
| - export interface Item { |
5 |
| - label: string; |
6 |
| - value: any; |
7 |
| - key?: string | number; |
8 |
| - color?: string; |
9 |
| - } |
10 |
| - export interface PickerProps { |
11 |
| - onValueChange: (value: any, index: number) => void; |
12 |
| - items: Item[]; |
13 |
| - value?: any; |
14 |
| - placeholder?: Item | {}; |
15 |
| - disabled?: boolean; |
16 |
| - itemKey?: string | number; |
17 |
| - style?: object; |
18 |
| - children?: any; |
19 |
| - placeholderTextColor?: string; |
20 |
| - useNativeAndroidPickerStyle?: boolean; |
21 |
| - hideDoneBar?: boolean; |
22 |
| - doneText?: string; |
23 |
| - onDonePress?: () => void; |
24 |
| - onUpArrow?: () => void; |
25 |
| - onDownArrow?: () => void; |
26 |
| - onOpen?: () => void; |
27 |
| - onClose?: () => void; |
28 |
| - modalProps?: object; |
29 |
| - textInputProps?: object; |
30 |
| - pickerProps?: object; |
31 |
| - Icon?: React.ReactNode; |
32 |
| - renderModalContentIOS?: (modalContent: React.ReactElement) => void |
33 |
| - } |
34 |
| - class Picker extends React.Component<PickerProps> {} |
35 |
| - export default Picker; |
| 4 | +export interface Item { |
| 5 | + label: string; |
| 6 | + value: any; |
| 7 | + key?: string | number; |
| 8 | + color?: string; |
36 | 9 | }
|
| 10 | +export interface PickerStyle { |
| 11 | + chevron?: ViewStyle; |
| 12 | + chevronActive?: ViewStyle; |
| 13 | + chevronContainer?: ViewStyle; |
| 14 | + chevronDown?: ViewStyle; |
| 15 | + chevronUp?: ViewStyle; |
| 16 | + done?: TextStyle; |
| 17 | + headlessAndroidContainer?: ViewStyle; |
| 18 | + headlessAndroidPicker?: ViewStyle; |
| 19 | + iconContainer?: ViewStyle; |
| 20 | + inputAndroid?: TextStyle; |
| 21 | + inputAndroidContainer?: ViewStyle; |
| 22 | + inputIOS?: TextStyle; |
| 23 | + inputIOSContainer?: ViewStyle; |
| 24 | + modalViewBottom?: ViewStyle; |
| 25 | + modalViewMiddle?: ViewStyle; |
| 26 | + modalViewTop?: ViewStyle; |
| 27 | + placeholder?: TextStyle; |
| 28 | + viewContainer?: ViewStyle; |
| 29 | +} |
| 30 | + |
| 31 | +// Omit props needed by the library |
| 32 | +type PickerModalProps = Omit< |
| 33 | + ModalProps, |
| 34 | + | 'testID' |
| 35 | + | 'visible' |
| 36 | + | 'transparent' |
| 37 | + | 'animationType' |
| 38 | + | 'supportedOrientations' |
| 39 | + | 'onDismiss' |
| 40 | + | 'onOrientationChange' |
| 41 | + >; |
| 42 | + |
| 43 | +export interface PickerSelectProps { |
| 44 | + onValueChange: (value: any, index: number) => void; |
| 45 | + items: Item[]; |
| 46 | + value?: any; |
| 47 | + placeholder?: Item | {}; |
| 48 | + disabled?: boolean; |
| 49 | + itemKey?: string | number; |
| 50 | + style?: PickerStyle; |
| 51 | + children?: React.ReactNode; |
| 52 | + placeholderTextColor?: string; // deprecated |
| 53 | + useNativeAndroidPickerStyle?: boolean; |
| 54 | + hideDoneBar?: boolean; // deprecated |
| 55 | + doneText?: string; |
| 56 | + onDonePress?: () => void; |
| 57 | + onUpArrow?: () => void; |
| 58 | + onDownArrow?: () => void; |
| 59 | + onOpen?: () => void; |
| 60 | + onClose?: () => void; |
| 61 | + modalProps?: PickerModalProps; |
| 62 | + textInputProps?: TextInputProperties; |
| 63 | + pickerProps?: PickerProps; |
| 64 | + Icon?: React.ReactNode; |
| 65 | + InputAccessoryView?: React.ReactNode; |
| 66 | +} |
| 67 | + |
| 68 | +declare class Picker extends React.Component<PickerSelectProps> {} |
| 69 | +export default Picker; |
0 commit comments