react-country-kit-core 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/countries.d.ts +10 -0
- package/dist/data/currencies.d.ts +3 -0
- package/dist/data/divisions.d.ts +3 -0
- package/dist/data/languages.d.ts +3 -0
- package/dist/data/phoneFormats.d.ts +3 -0
- package/dist/data/timezones.d.ts +3 -0
- package/dist/hooks/useBasePicker.d.ts +6 -0
- package/dist/hooks/useCountryPicker.d.ts +2 -0
- package/dist/hooks/useCurrencyPicker.d.ts +2 -0
- package/dist/hooks/useDivisionPicker.d.ts +2 -0
- package/dist/hooks/useLanguagePicker.d.ts +2 -0
- package/dist/hooks/useMultiSelect.d.ts +6 -0
- package/dist/hooks/usePhoneInput.d.ts +17 -0
- package/dist/hooks/useTimezonePicker.d.ts +2 -0
- package/dist/index.d.ts +19 -388
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +639 -393
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +197 -0
- package/dist/utils/countries.d.ts +65 -0
- package/dist/utils/currencies.d.ts +13 -0
- package/dist/utils/languages.d.ts +13 -0
- package/dist/utils/timezones.d.ts +14 -0
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Country } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-generated country dataset — DO NOT EDIT MANUALLY.
|
|
4
|
+
* Source: https://raw.githubusercontent.com/kishormainali/country_division_database/refs/heads/main/countries.json
|
|
5
|
+
* Generated: 2026-05-18T08:54:17.574Z
|
|
6
|
+
* Countries: 250
|
|
7
|
+
*/
|
|
8
|
+
export declare function iso2ToFlag(iso2: string): string;
|
|
9
|
+
export declare const COUNTRIES: Country[];
|
|
10
|
+
export default COUNTRIES;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UsePickerReturn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generic base hook for all pickers.
|
|
4
|
+
* Handles open/close state, search query, and item selection.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBasePicker<T>(allItems: T[], filterFn: (items: T[], query: string) => T[], initialValue?: T | null, onChange?: (item: T) => void): UsePickerReturn<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseMultiSelectReturn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generic multi-selection hook.
|
|
4
|
+
* Handles open/close, search, and toggle-selection of multiple items.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useMultiSelect<T>(allItems: T[], filterFn: (items: T[], query: string) => T[], keyFn: (item: T) => string, initialValue?: T[], onChange?: (items: T[]) => void, maxItems?: number): UseMultiSelectReturn<T>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Country, PhoneValue } from '../types';
|
|
2
|
+
export interface UsePhoneInputReturn {
|
|
3
|
+
country: Country | null;
|
|
4
|
+
number: string;
|
|
5
|
+
value: PhoneValue | null;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
searchQuery: string;
|
|
8
|
+
filteredCountries: Country[];
|
|
9
|
+
minLength?: number;
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
setSearchQuery: (q: string) => void;
|
|
12
|
+
selectCountry: (country: Country) => void;
|
|
13
|
+
setNumber: (num: string) => void;
|
|
14
|
+
toggle: () => void;
|
|
15
|
+
close: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function usePhoneInput(initialValue?: PhoneValue | null, onChange?: (value: PhoneValue) => void, defaultCountryIso2?: string): UsePhoneInputReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,388 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
tax_id_placeholder: string;
|
|
21
|
-
/** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
|
|
22
|
-
postal_code_label: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export declare interface CountryMultiSelectProps {
|
|
26
|
-
value: Country[];
|
|
27
|
-
onChange: (countries: Country[]) => void;
|
|
28
|
-
placeholder?: string;
|
|
29
|
-
/** Maximum number of selections (undefined = unlimited) */
|
|
30
|
-
maxItems?: number;
|
|
31
|
-
showFlags?: boolean;
|
|
32
|
-
searchable?: boolean;
|
|
33
|
-
disabled?: boolean;
|
|
34
|
-
className?: string;
|
|
35
|
-
label?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export declare interface CountryPickerProps {
|
|
39
|
-
/** Currently selected country */
|
|
40
|
-
value?: Country | null;
|
|
41
|
-
/** Callback when user selects a country */
|
|
42
|
-
onChange: (country: Country) => void;
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
/** Enable search input */
|
|
45
|
-
searchable?: boolean;
|
|
46
|
-
/** Show emoji flag next to country name */
|
|
47
|
-
showFlag?: boolean;
|
|
48
|
-
/** Show phone dial code */
|
|
49
|
-
showPhoneCode?: boolean;
|
|
50
|
-
/** Disable the picker */
|
|
51
|
-
disabled?: boolean;
|
|
52
|
-
/** Additional wrapper class */
|
|
53
|
-
className?: string;
|
|
54
|
-
/** aria-label */
|
|
55
|
-
label?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export declare const CURRENCIES: Currency[];
|
|
59
|
-
|
|
60
|
-
export declare interface Currency {
|
|
61
|
-
code: string;
|
|
62
|
-
name: string;
|
|
63
|
-
symbol: string;
|
|
64
|
-
countryCode: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export declare interface CurrencyMultiSelectProps {
|
|
68
|
-
value: Currency[];
|
|
69
|
-
onChange: (currencies: Currency[]) => void;
|
|
70
|
-
placeholder?: string;
|
|
71
|
-
maxItems?: number;
|
|
72
|
-
showSymbol?: boolean;
|
|
73
|
-
searchable?: boolean;
|
|
74
|
-
disabled?: boolean;
|
|
75
|
-
className?: string;
|
|
76
|
-
label?: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export declare interface CurrencyPickerProps {
|
|
80
|
-
value?: Currency | null;
|
|
81
|
-
onChange: (currency: Currency) => void;
|
|
82
|
-
placeholder?: string;
|
|
83
|
-
searchable?: boolean;
|
|
84
|
-
/** Filter currencies to a specific country (iso2) and enable auto-selection */
|
|
85
|
-
countryIso2?: string;
|
|
86
|
-
/** Auto-select the first currency if countryIso2 is provided. Defaults to true if countryIso2 is present and value is empty. */
|
|
87
|
-
autoSelect?: boolean;
|
|
88
|
-
/** Show currency symbol alongside code */
|
|
89
|
-
showSymbol?: boolean;
|
|
90
|
-
disabled?: boolean;
|
|
91
|
-
className?: string;
|
|
92
|
-
label?: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export declare interface Division {
|
|
96
|
-
name: string;
|
|
97
|
-
iso2: string;
|
|
98
|
-
timezone: string;
|
|
99
|
-
countryCode: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export declare interface DivisionPickerProps {
|
|
103
|
-
/** ISO2 code of the parent country (required) */
|
|
104
|
-
countryIso2: string;
|
|
105
|
-
value?: Division | null;
|
|
106
|
-
onChange: (division: Division) => void;
|
|
107
|
-
placeholder?: string;
|
|
108
|
-
searchable?: boolean;
|
|
109
|
-
disabled?: boolean;
|
|
110
|
-
className?: string;
|
|
111
|
-
label?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export declare const DIVISIONS: Division[];
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Returns all countries
|
|
118
|
-
*/
|
|
119
|
-
export declare function getAllCountries(): Country[];
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Returns all unique currencies across all countries
|
|
123
|
-
*/
|
|
124
|
-
export declare function getAllCurrencies(): Currency[];
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Returns all languages
|
|
128
|
-
*/
|
|
129
|
-
export declare function getAllLanguages(): Language[];
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns all unique timezones across all countries
|
|
133
|
-
*/
|
|
134
|
-
export declare function getAllTimezones(): Timezone[];
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Find a country by its ISO2 code (case-insensitive)
|
|
138
|
-
*/
|
|
139
|
-
export declare function getCountryByIso2(iso2: string): Country | undefined;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Find a country by its ISO3 code (case-insensitive)
|
|
143
|
-
*/
|
|
144
|
-
export declare function getCountryByIso3(iso3: string): Country | undefined;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Find a country by its name (partial, case-insensitive)
|
|
148
|
-
*/
|
|
149
|
-
export declare function getCountryByName(name: string): Country | undefined;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Find a currency by its code (e.g. "USD")
|
|
153
|
-
*/
|
|
154
|
-
export declare function getCurrencyByCode(code: string): Currency | undefined;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Get the currency of a country
|
|
158
|
-
*/
|
|
159
|
-
/**
|
|
160
|
-
* Get the currency for a country
|
|
161
|
-
*/
|
|
162
|
-
export declare function getCurrencyByCountry(iso2: string): Currency | undefined;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Get all divisions for a country
|
|
166
|
-
*/
|
|
167
|
-
export declare function getDivisionsByCountry(iso2: string): Division[];
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Find a language by its BCP-47 code
|
|
171
|
-
*/
|
|
172
|
-
export declare function getLanguageByCode(code: string): Language | undefined;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get the phone format for a country
|
|
176
|
-
*/
|
|
177
|
-
export declare function getPhoneFormatByCountry(iso2: string): PhoneFormat | undefined;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Get the min and max phone number lengths for a country
|
|
181
|
-
*/
|
|
182
|
-
export declare function getPhoneLengths(iso2: string): {
|
|
183
|
-
min?: number;
|
|
184
|
-
max?: number;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Get the localized Postal Code label for a country
|
|
189
|
-
*/
|
|
190
|
-
export declare function getPostalLabelByCountry(iso2: string): string;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Get the localized Tax ID label for a country
|
|
194
|
-
*/
|
|
195
|
-
export declare function getTaxLabelByCountry(iso2: string): string;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Get the localized Tax ID placeholder for a country
|
|
199
|
-
*/
|
|
200
|
-
export declare function getTaxPlaceholderByCountry(iso2: string): string;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Find a timezone by its IANA name (e.g. "America/New_York")
|
|
204
|
-
* Supports modern names and common deprecated aliases.
|
|
205
|
-
*/
|
|
206
|
-
export declare function getTimezoneByName(name: string): Timezone | undefined;
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Get all timezones for a country
|
|
210
|
-
*/
|
|
211
|
-
export declare function getTimezonesByCountry(iso2: string): Timezone[];
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Auto-generated country dataset — DO NOT EDIT MANUALLY.
|
|
215
|
-
* Source: https://raw.githubusercontent.com/kishormainali/country_division_database/refs/heads/main/countries.json
|
|
216
|
-
* Generated: 2026-05-15T08:46:14.513Z
|
|
217
|
-
* Countries: 250
|
|
218
|
-
*/
|
|
219
|
-
export declare function iso2ToFlag(iso2: string): string;
|
|
220
|
-
|
|
221
|
-
export declare interface Language {
|
|
222
|
-
code: string;
|
|
223
|
-
english_name: string;
|
|
224
|
-
native_name: string;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export declare interface LanguagePickerProps {
|
|
228
|
-
value?: Language | null;
|
|
229
|
-
onChange: (language: Language) => void;
|
|
230
|
-
placeholder?: string;
|
|
231
|
-
searchable?: boolean;
|
|
232
|
-
/** Show native language name alongside english name */
|
|
233
|
-
showNativeName?: boolean;
|
|
234
|
-
disabled?: boolean;
|
|
235
|
-
className?: string;
|
|
236
|
-
label?: string;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export declare const PHONE_FORMATS: PhoneFormat[];
|
|
240
|
-
|
|
241
|
-
export declare interface PhoneFormat {
|
|
242
|
-
iso2: string;
|
|
243
|
-
dialCode: string;
|
|
244
|
-
patterns: string;
|
|
245
|
-
possibleLengths: string;
|
|
246
|
-
example: string | number;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export declare interface PhoneInputProps {
|
|
250
|
-
value?: PhoneValue | null;
|
|
251
|
-
onChange: (value: PhoneValue) => void;
|
|
252
|
-
/** Pre-select a country by ISO2 on first render */
|
|
253
|
-
defaultCountryIso2?: string;
|
|
254
|
-
placeholder?: string;
|
|
255
|
-
showFlag?: boolean;
|
|
256
|
-
disabled?: boolean;
|
|
257
|
-
className?: string;
|
|
258
|
-
label?: string;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Value object returned by PhoneInput.
|
|
263
|
-
*/
|
|
264
|
-
export declare interface PhoneValue {
|
|
265
|
-
/** Full Country object of the selected country */
|
|
266
|
-
country: Country;
|
|
267
|
-
/** Dial code with + prefix, e.g. "+1" */
|
|
268
|
-
dialCode: string;
|
|
269
|
-
/** Raw phone number without dial code, e.g. "4155551234" */
|
|
270
|
-
number: string;
|
|
271
|
-
/** Full number with dial code, e.g. "+14155551234" */
|
|
272
|
-
full: string;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Search countries by name, iso2, iso3 or phone code
|
|
277
|
-
*/
|
|
278
|
-
export declare function searchCountries(query: string): Country[];
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Search currencies by code, name, or symbol
|
|
282
|
-
*/
|
|
283
|
-
export declare function searchCurrencies(query: string, countryIso2?: string): Currency[];
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Search languages by english name, native name, or code
|
|
287
|
-
*/
|
|
288
|
-
export declare function searchLanguages(query: string): Language[];
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Search timezones by name, abbreviation, or offset string
|
|
292
|
-
*/
|
|
293
|
-
export declare function searchTimezones(query: string, countryIso2?: string): Timezone[];
|
|
294
|
-
|
|
295
|
-
export declare interface Timezone {
|
|
296
|
-
name: string;
|
|
297
|
-
offset: number;
|
|
298
|
-
offset_name: string;
|
|
299
|
-
abbreviation: string;
|
|
300
|
-
tzName: string;
|
|
301
|
-
countryCode: string;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
export declare interface TimezonePickerProps {
|
|
305
|
-
value?: Timezone | null;
|
|
306
|
-
onChange: (timezone: Timezone) => void;
|
|
307
|
-
placeholder?: string;
|
|
308
|
-
searchable?: boolean;
|
|
309
|
-
/** Filter timezones to a specific country (iso2) and enable auto-selection */
|
|
310
|
-
countryIso2?: string;
|
|
311
|
-
/** Auto-select the first timezone if countryIso2 is provided. Defaults to true if countryIso2 is present and value is empty. */
|
|
312
|
-
autoSelect?: boolean;
|
|
313
|
-
disabled?: boolean;
|
|
314
|
-
className?: string;
|
|
315
|
-
label?: string;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export declare const TIMEZONES: Timezone[];
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Generic base hook for all pickers.
|
|
322
|
-
* Handles open/close state, search query, and item selection.
|
|
323
|
-
*/
|
|
324
|
-
export declare function useBasePicker<T>(allItems: T[], filterFn: (items: T[], query: string) => T[], initialValue?: T | null, onChange?: (item: T) => void): UsePickerReturn<T>;
|
|
325
|
-
|
|
326
|
-
export declare function useCountryPicker(initialValue?: Country | null, onChange?: (country: Country) => void): UsePickerReturn<Country>;
|
|
327
|
-
|
|
328
|
-
export declare function useCurrencyPicker(initialValue?: Currency | null, onChange?: (currency: Currency) => void): UsePickerReturn<Currency>;
|
|
329
|
-
|
|
330
|
-
export declare function useDivisionPicker(countryIso2: string, initialValue?: Division | null, onChange?: (division: Division) => void): UsePickerReturn<Division>;
|
|
331
|
-
|
|
332
|
-
export declare function useLanguagePicker(initialValue?: Language | null, onChange?: (language: Language) => void): UsePickerReturn<Language>;
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Generic multi-selection hook.
|
|
336
|
-
* Handles open/close, search, and toggle-selection of multiple items.
|
|
337
|
-
*/
|
|
338
|
-
export declare function useMultiSelect<T>(allItems: T[], filterFn: (items: T[], query: string) => T[], keyFn: (item: T) => string, initialValue?: T[], onChange?: (items: T[]) => void, maxItems?: number): UseMultiSelectReturn<T>;
|
|
339
|
-
|
|
340
|
-
export declare interface UseMultiSelectReturn<T> {
|
|
341
|
-
isOpen: boolean;
|
|
342
|
-
searchQuery: string;
|
|
343
|
-
filteredItems: T[];
|
|
344
|
-
selectedItems: T[];
|
|
345
|
-
open: () => void;
|
|
346
|
-
close: () => void;
|
|
347
|
-
toggle: () => void;
|
|
348
|
-
setSearchQuery: (query: string) => void;
|
|
349
|
-
toggleItem: (item: T) => void;
|
|
350
|
-
isSelected: (item: T) => boolean;
|
|
351
|
-
removeItem: (item: T) => void;
|
|
352
|
-
clearAll: () => void;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
export declare function usePhoneInput(initialValue?: PhoneValue | null, onChange?: (value: PhoneValue) => void, defaultCountryIso2?: string): UsePhoneInputReturn;
|
|
356
|
-
|
|
357
|
-
export declare interface UsePhoneInputReturn {
|
|
358
|
-
country: Country | null;
|
|
359
|
-
number: string;
|
|
360
|
-
value: PhoneValue | null;
|
|
361
|
-
isOpen: boolean;
|
|
362
|
-
searchQuery: string;
|
|
363
|
-
filteredCountries: Country[];
|
|
364
|
-
minLength?: number;
|
|
365
|
-
maxLength?: number;
|
|
366
|
-
setSearchQuery: (q: string) => void;
|
|
367
|
-
selectCountry: (country: Country) => void;
|
|
368
|
-
setNumber: (num: string) => void;
|
|
369
|
-
toggle: () => void;
|
|
370
|
-
close: () => void;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
export declare interface UsePickerReturn<T> {
|
|
374
|
-
isOpen: boolean;
|
|
375
|
-
searchQuery: string;
|
|
376
|
-
filteredItems: T[];
|
|
377
|
-
selectedItem: T | null;
|
|
378
|
-
open: () => void;
|
|
379
|
-
close: () => void;
|
|
380
|
-
toggle: () => void;
|
|
381
|
-
setSearchQuery: (query: string) => void;
|
|
382
|
-
selectItem: (item: T) => void;
|
|
383
|
-
clearSelection: () => void;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
export declare function useTimezonePicker(initialValue?: Timezone | null, onChange?: (timezone: Timezone) => void, countryIso2?: string): UsePickerReturn<Timezone>;
|
|
387
|
-
|
|
388
|
-
export { }
|
|
1
|
+
export * from './data/countries';
|
|
2
|
+
export * from './data/divisions';
|
|
3
|
+
export * from './data/languages';
|
|
4
|
+
export * from './data/timezones';
|
|
5
|
+
export * from './data/phoneFormats';
|
|
6
|
+
export * from './data/currencies';
|
|
7
|
+
export * from './hooks/useCountryPicker';
|
|
8
|
+
export * from './hooks/useCurrencyPicker';
|
|
9
|
+
export * from './hooks/useDivisionPicker';
|
|
10
|
+
export * from './hooks/useLanguagePicker';
|
|
11
|
+
export * from './hooks/useTimezonePicker';
|
|
12
|
+
export * from './hooks/usePhoneInput';
|
|
13
|
+
export * from './hooks/useMultiSelect';
|
|
14
|
+
export * from './hooks/useBasePicker';
|
|
15
|
+
export * from './utils/countries';
|
|
16
|
+
export * from './utils/currencies';
|
|
17
|
+
export * from './utils/languages';
|
|
18
|
+
export * from './utils/timezones';
|
|
19
|
+
export * from './types';
|