|
1 |
| -import * as React from "react" |
2 |
| -import { TextStyle, StyleProp, ViewProps } from 'react-native' |
| 1 | +import * as React from 'react'; |
| 2 | +import { |
| 3 | + TextStyle, |
| 4 | + StyleProp, |
| 5 | + ViewProps, |
| 6 | + NativeSyntheticEvent, |
| 7 | + TargetedEvent, |
| 8 | +} from 'react-native'; |
3 | 9 |
|
4 |
| -export type ItemValue = number | string |
| 10 | +export type ItemValue = number | string; |
5 | 11 |
|
6 | 12 | export interface PickerItemProps<T = ItemValue> {
|
7 |
| - label?: string; |
8 |
| - value?: T; |
9 |
| - color?: string; |
10 |
| - fontFamily?: string, |
11 |
| - testID?: string; |
12 |
| - /** |
13 |
| - * Style to apply to individual item labels. |
14 |
| - * Only following values take effect: |
15 |
| - * - 'color' |
16 |
| - * - 'backgroundColor' |
17 |
| - * - 'fontSize' |
18 |
| - * - 'fontFamily' |
19 |
| - * |
20 |
| - * @platform android |
21 |
| - */ |
22 |
| - style?: StyleProp<TextStyle> |
23 |
| - /** |
24 |
| - * If set to false, the specific item will be disabled, i.e. the user will not be able to make a |
25 |
| - * selection. |
26 |
| - * @default true |
27 |
| - * @platform android |
28 |
| - */ |
29 |
| - enabled?:boolean |
| 13 | + label?: string; |
| 14 | + value?: T; |
| 15 | + color?: string; |
| 16 | + fontFamily?: string; |
| 17 | + testID?: string; |
| 18 | + /** |
| 19 | + * Style to apply to individual item labels. |
| 20 | + * Only following values take effect: |
| 21 | + * - 'color' |
| 22 | + * - 'backgroundColor' |
| 23 | + * - 'fontSize' |
| 24 | + * - 'fontFamily' |
| 25 | + * |
| 26 | + * @platform android |
| 27 | + */ |
| 28 | + style?: StyleProp<TextStyle>; |
| 29 | + /** |
| 30 | + * If set to false, the specific item will be disabled, i.e. the user will not be able to make a |
| 31 | + * selection. |
| 32 | + * @default true |
| 33 | + * @platform android |
| 34 | + */ |
| 35 | + enabled?: boolean; |
30 | 36 | }
|
31 | 37 |
|
32 | 38 | export interface PickerProps<T = ItemValue> extends ViewProps {
|
33 |
| - style?: StyleProp<TextStyle>; |
34 |
| - /** |
| 39 | + style?: StyleProp<TextStyle>; |
| 40 | + /** |
35 | 41 | * Value matching value of one of the items. Can be a string or an integer.
|
36 | 42 | */
|
37 |
| - selectedValue?: T; |
38 |
| - /** |
| 43 | + selectedValue?: T; |
| 44 | + /** |
39 | 45 | * Callback for when an item is selected. This is called with the following parameters:
|
40 | 46 | * - `itemValue`: the `value` prop of the item that was selected
|
41 | 47 | * - `itemIndex`: the index of the selected item in this picker
|
42 | 48 | */
|
43 |
| - onValueChange?: (itemValue: T, itemIndex: number) => void; |
44 |
| - /** |
| 49 | + onValueChange?: (itemValue: T, itemIndex: number) => void; |
| 50 | + /** |
45 | 51 | * If set to false, the picker will be disabled, i.e. the user will not be able to make a
|
46 | 52 | * selection.
|
47 | 53 | * @platform android
|
48 | 54 | */
|
49 |
| - enabled?: boolean; |
50 |
| - /** |
| 55 | + enabled?: boolean; |
| 56 | + /** |
51 | 57 | * On Android, specifies how to display the selection items when the user taps on the picker:
|
52 | 58 | *
|
53 | 59 | * - 'dialog': Show a modal dialog. This is the default.
|
54 | 60 | * - 'dropdown': Shows a dropdown anchored to the picker view
|
55 | 61 | *
|
56 | 62 | * @platform android
|
57 | 63 | */
|
58 |
| - mode?: 'dialog' | 'dropdown'; |
59 |
| - /** |
| 64 | + mode?: 'dialog' | 'dropdown'; |
| 65 | + /** |
60 | 66 | * Style to apply to each of the item labels.
|
61 | 67 | * @platform ios
|
62 | 68 | */
|
63 |
| - itemStyle?: StyleProp<TextStyle>; |
64 |
| - /** |
| 69 | + itemStyle?: StyleProp<TextStyle>; |
| 70 | + /** |
65 | 71 | * Prompt string for this picker, used on Android in dialog mode as the title of the dialog.
|
66 | 72 | * @platform android
|
67 | 73 | */
|
68 |
| - prompt?: string; |
69 |
| - /** |
| 74 | + prompt?: string; |
| 75 | + /** |
70 | 76 | * Used to locate this view in end-to-end tests.
|
71 | 77 | */
|
72 |
| - testID?: string; |
73 |
| - /** |
74 |
| - * Color of arrow for spinner dropdown in hexadecimal format |
75 |
| - * @platform android |
76 |
| - */ |
77 |
| - dropdownIconColor?: string; |
78 |
| - /** |
| 78 | + testID?: string; |
| 79 | + /** |
| 80 | + * Color of arrow for spinner dropdown in hexadecimal format |
| 81 | + * @platform android |
| 82 | + */ |
| 83 | + dropdownIconColor?: string; |
| 84 | + /** |
79 | 85 | * On Android, used to truncate the text with an ellipsis after computing the text layout, including line wrapping,
|
80 | 86 | * such that the total number of lines does not exceed this number. Default is '1'
|
81 | 87 | * @platform android
|
82 | 88 | */
|
83 |
| - numberOfLines?: number; |
84 |
| - /** |
85 |
| - * The string used for the accessibility label. Will be read once focused on the picker but not on change. |
86 |
| - */ |
87 |
| - accessibilityLabel?: string; |
88 |
| - /** |
89 |
| - * Called when picker is focused |
90 |
| - * @platform android |
91 |
| - */ |
92 |
| - onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void |
93 |
| - /** |
94 |
| - * Called when picker is blurred |
95 |
| - * @platform android |
96 |
| - */ |
97 |
| - onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void |
| 89 | + numberOfLines?: number; |
| 90 | + /** |
| 91 | + * The string used for the accessibility label. Will be read once focused on the picker but not on change. |
| 92 | + */ |
| 93 | + accessibilityLabel?: string; |
| 94 | + /** |
| 95 | + * Called when picker is focused |
| 96 | + * @platform android |
| 97 | + */ |
| 98 | + onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void; |
| 99 | + /** |
| 100 | + * Called when picker is blurred |
| 101 | + * @platform android |
| 102 | + */ |
| 103 | + onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void; |
98 | 104 | }
|
99 | 105 |
|
100 | 106 | declare class Picker<T> extends React.Component<PickerProps<T>, {}> {
|
101 |
| - /** |
102 |
| - * On Android, display the options in a dialog (this is the default). |
103 |
| - */ |
104 |
| - static readonly MODE_DIALOG: 'dialog'; |
105 |
| - /** |
106 |
| - * On Android, display the options in a dropdown. |
107 |
| - */ |
108 |
| - static readonly MODE_DROPDOWN: 'dropdown'; |
| 107 | + /** |
| 108 | + * On Android, display the options in a dialog (this is the default). |
| 109 | + */ |
| 110 | + static readonly MODE_DIALOG: 'dialog'; |
| 111 | + /** |
| 112 | + * On Android, display the options in a dropdown. |
| 113 | + */ |
| 114 | + static readonly MODE_DROPDOWN: 'dropdown'; |
109 | 115 |
|
110 |
| - static Item: React.ComponentType<PickerItemProps<ItemValue>>; |
| 116 | + static Item: React.ComponentType<PickerItemProps<ItemValue>>; |
111 | 117 |
|
112 |
| - /** |
113 |
| - * @platform android |
114 |
| - */ |
115 |
| - focus: () => void |
116 |
| - /** |
117 |
| - * @platform android |
118 |
| - */ |
119 |
| - blur: () => void |
| 118 | + /** |
| 119 | + * @platform android |
| 120 | + */ |
| 121 | + focus: () => void; |
| 122 | + /** |
| 123 | + * @platform android |
| 124 | + */ |
| 125 | + blur: () => void; |
120 | 126 | }
|
121 | 127 |
|
122 | 128 | export { Picker };
|
0 commit comments