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