forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-select.d.ts
221 lines (215 loc) · 6.85 KB
/
react-select.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Type definitions for react-select v1.0.0
// Project: https://github.com/JedWatson/react-select
// Definitions by: ESQUIBET Hugo <https://github.com/Hesquibet/>, Gilad Gray <https://github.com/giladgray/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts"/>
declare namespace ReactSelect {
interface Option {
/** Text for rendering */
label: string;
/** Value for searching */
value: string | number;
/**
* Allow this option to be cleared
* @default true
*/
clearableValue?: boolean;
}
interface ReactSelectProps extends __React.Props<ReactSelect> {
/**
* text to display when `allowCreate` is true.
* @default 'Add "{label}"?'
*/
addLabelText?: string;
/**
* blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices.
* @default false
*/
autoBlur?: boolean;
/**
* allow new options to be created in multi mode (displays an "Add <option> ?" item
* when a value not already in the options array is entered)
* @default false
*/
allowCreate?: boolean;
/**
* whether to auto-load the default async options set
* @default true
*/
autoload?: boolean;
/**
* whether pressing backspace removes the last item when there is no input value
* @default true
*/
backspaceRemoves?: boolean;
/**
* enables the options cache for `asyncOptions`
* @default true
*/
cacheAsyncResults?: boolean;
/**
* CSS className for the outer element
*/
className?: string;
/**
* whether it is possible to reset value. if enabled, an X button will appear at the right side.
* @default true
*/
clearable?: boolean;
/**
* title for the "clear" control when `multi` is true
* @default "Clear all"
*/
clearAllText?: string;
/**
* title for the "clear" control
* @default "Clear value"
*/
clearValueText?: string;
/**
* delimiter to use to join multiple values
* @default ","
*/
delimiter?: string;
/**
* whether the Select is disabled or not
* @default false
*/
disabled?: boolean;
/**
* method to filter a single option
*/
filterOption?: (option: Option, filter: string) => Option;
/**
* method to filter the options array
*/
filterOptions?: (options: Array<Option>, filter: string, currentValues: (string | number)[]) => Array<Option>;
/**
* whether to perform case-insensitive filtering
* @default true
*/
ignoreCase?: boolean;
/**
* custom attributes for the Input (in the Select-control) e.g: {'data-foo': 'bar'}
* @default {}
*/
inputProps?: Object;
/**
* whether the Select is loading externally or not (such as options being loaded).
* if true, a loading spinner will be shown at the right side.
* @default false
*/
isLoading?: boolean;
/**
* the option property to use for the label
* @default "label"
*/
labelKey?: string;
/**
* function that calls a callback with the options
*/
loadOptions?: (input: string, callback: (options: Option[]) => any) => any;
/**
* (any, start) match the start or entire string when filtering
* @default "any"
*/
matchPos?: string;
/**
* (any, label, value) which option property to filter on
* @default "any"
*/
matchProp?: string;
/**
* buffer of px between the base of the dropdown and the viewport to shift if menu doesnt fit in viewport
* @default 0
*/
menuBuffer?: number;
/**
* multi-value input
* @default false
*/
multi?: boolean;
/**
* field name, for hidden `<input>` tag
*/
name?: string;
/**
* factory to create new options when `allowCreate` is true
* @default false
*/
newOptionCreator?: (input: string) => Option;
/**
* placeholder displayed when there are no matching search results or a falsy value to hide it
* @default "No results found"
*/
noResultsText?: string;
onBlur?: __React.FocusEventHandler;
/**
* whether to clear input on blur or not
* @default true
*/
onBlurResetsInput?: boolean;
onChange?: (newValue: Option | Option[]) => void;
onFocus?: __React.FocusEventHandler;
onInputChange?: (inputValue: string) => void;
onOptionLabelClick?: (value: string, event: Event) => void;
/**
* function which returns a custom way to render the options in the menu
*/
optionRenderer?: () => void;
/**
* array of Select options
* @default false
*/
options?: Array<Option>;
/**
* field placeholder, displayed when there's no value
* @default "Select..."
*/
placeholder?: string;
/**
* whether to enable searching feature or not
* @default true;
*/
searchable?: boolean;
/**
* message to display whilst options are loading via asyncOptions, or when `isLoading` is true
* @default "Searching..."
*/
searchingText?: string;
/**
* label to prompt for search input
* @default "Type to search"
*/
searchPromptText?: string;
/**
* initial field value
*/
value?: Option | Option[];
/**
* the option property to use for the value
* @default "value"
*/
valueKey?: string;
/**
* function which returns a custom way to render the value selected
* @default false
*/
valueRenderer?: () => void;
}
interface ReactAsyncSelectProps extends __React.Props<ReactSelect> {
cache?: any;
loadOptions?: () => void;
ignoreAccents?: boolean;
isLoading?: boolean;
loadingPlaceholder?: string;
}
interface ReactSelect extends __React.ReactElement<ReactSelectProps> { }
interface ReactSelectClass extends __React.ComponentClass<ReactSelectProps> {
Async: __React.ComponentClass<ReactAsyncSelectProps>;
}
}
declare module "react-select" {
var select: ReactSelect.ReactSelectClass;
export = select;
}