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