-
Notifications
You must be signed in to change notification settings - Fork 131
/
index.d.ts
261 lines (225 loc) · 6.11 KB
/
index.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
// Type definitions for react-country-region-selector 3.0.1 by
// Project: https://github.com/country-regions/react-country-region-selector
// Definitions by: Kyle Davis <https://github.com/kyledavisdev>, Ben Keen <https://github.com/benkeen>
import * as React from "react";
export type ValueType = "full" | "short";
export interface CountryDropdownProps<T = Element> {
/**
* The currently selected country. This should either
* be the shortcode, or the full country name depending
* on what you're using for your value attribute
* (see the valueType option). By default it's the full country name.
*
* Default value: ""
*/
value: string;
/**
* Callback that gets called when the user selects a country. Use
* this to store the value in whatever store you're
* using (or just the parent component state).
*
* The original event is also provided optionally.
*
* Default value: undefined
*/
onChange: (val: string, e: React.ChangeEvent<T>) => void;
/**
* Callback that gets called when the user blurs off the country field.
*
* The original event is also provided optionally.
*
* Default value: undefined
*/
onBlur?: (val: string, e: React.ChangeEvent<T>) => void;
/**
* The name attribute of the generated select box.
*
* Default value: "rcrs-country"
*/
name?: string;
/**
* The ID of the generated select box. Not added by default.
*
* Default value: ""
*/
id?: string;
/**
* Any additional space-separated classes you want to add.
*
* Default value: ""
*/
classes?: string;
/**
* Whether you want to show a default option.
*
* Default value: true
*/
showDefaultOption?: boolean;
/**
* Lets you target countries that should appear at the top
* of the dropdown. Should also be an array of country shortcodes.
*
* Default value: array
*/
priorityOptions?: string[];
/**
* The default option label.
*
* Default value: "Select Country"
*/
defaultOptionLabel?: string;
/**
* Either "full" or "short". This governs whether you see
* country names or country short codes in the dropdown.
*
* Default value: "full"
*/
labelType?: ValueType;
/**
* Either "full" or "short". This controls the actual value
* attribute of each <option> in the dropdown. Please note,
* if you set this to "short" you will need to let the
* corresponding <RegionDropdown /> component know as well,
* by passing a countryValueType="short" attribute.
*
* Default value: "full"
*/
valueType?: ValueType;
/**
* This setting lets you target specific countries to appear
* in the dropdown. Only those specified here will appear.
* This should be an array of country shortcodes. See the
* country-region-data repo for the data and the shortcodes.
*
* Default value: []
*/
whitelist?: string[];
/**
* Lets you target countries that should not appear in the
* dropdown. Should also be an array of country shortcodes.
*
* Default value: []
*/
blacklist?: string[];
/**
* Disables the country field.
*
* Default value: false
*/
disabled?: boolean;
}
export class CountryDropdown extends React.Component<CountryDropdownProps> {}
export interface RegionDropdownProps<T = Element> {
/**
* The currently selected country.
*
* Default value: ""
*/
country: string;
/**
* The currently selected region.
*
* Default value: ""
*/
value: string;
/**
* Callback that gets called when the user selects a region.
* Use this to store the value in whatever store you're
* using (or just the parent component state).
*
* The original event is also provided optionally.
*
* Default value: undefined
*/
onChange: (val: string, e: React.ChangeEvent<T>) => void;
/**
* Callback that gets called when the user blurs off the region field.
*
* The original event is also provided optionally.
*
* Default value: undefined
*/
onBlur?: (val: string, e: React.ChangeEvent<T>) => void;
/**
* The name attribute of the generated select box.
*
* Default value: "rcrs-region"
*/
name?: string;
/**
* The ID of the generated select box. Not added by default.
*
* Default value: ""
*/
id?: string;
/**
* Any additional space-separated classes you want to add.
*
* Default value: ""
*/
classes?: string;
/**
* The label that appears in the region dropdown when the user
* hasn't selected a country yet.
*
* Default value: undefined
*/
blankOptionLabel?: string;
/**
* Whether you want to show a default option. This is what the
* user sees in the region dropdown after selecting a country.
* It defaults to the defaultOptionLabel setting (see next).
*
* Default value: true
*/
showDefaultOption?: boolean;
/**
* string The default region option.
*
* Default value: "Select Region"
*/
defaultOptionLabel?: string;
/**
* If you've changed the country dropdown valueType to short you
* will need to set this value to short as well, so the component
* knows what's being passed in the country property.
*
* Default value: "full"
*/
countryValueType?: ValueType;
/**
* Either "full" or "short". This governs whether you see
* region names or region short codes in the dropdown.
*
* Default value: "full"
*/
labelType?: ValueType;
/**
* Either "full" or "short". This controls the actual value
* attribute of each <option> in the dropdown.
*
* Default value: "full"
*/
valueType?: ValueType;
/**
* Disables the region field when the user hasn't selected a country.
*
* Default value: false
*/
disableWhenEmpty?: boolean;
/**
* Disables the region field. If set to true, it overrides disableWhenEmpty
*
* Default value: false
*/
disabled?: boolean;
/**
* Appends a list of string to the every region dropdown,
* regardless of the country selected.
*
* Default value: []
*/
customOptions?: string[];
}
export class RegionDropdown extends React.Component<RegionDropdownProps> {}
export const CountryRegionData: [string[]];