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,197 @@
|
|
|
1
|
+
export interface PhoneFormat {
|
|
2
|
+
iso2: string;
|
|
3
|
+
dialCode: string;
|
|
4
|
+
patterns: string;
|
|
5
|
+
possibleLengths: string;
|
|
6
|
+
example: string | number;
|
|
7
|
+
countryCode: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Currency {
|
|
10
|
+
code: string;
|
|
11
|
+
name: string;
|
|
12
|
+
symbol: string;
|
|
13
|
+
countryCode: string;
|
|
14
|
+
precision: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Timezone {
|
|
17
|
+
name: string;
|
|
18
|
+
offset: number;
|
|
19
|
+
offset_name: string;
|
|
20
|
+
abbreviation: string;
|
|
21
|
+
tzName: string;
|
|
22
|
+
countryCode: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Division {
|
|
25
|
+
name: string;
|
|
26
|
+
iso2: string;
|
|
27
|
+
timezone: string;
|
|
28
|
+
countryCode: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Country {
|
|
31
|
+
name: string;
|
|
32
|
+
iso2: string;
|
|
33
|
+
iso3: string;
|
|
34
|
+
phone_code: string;
|
|
35
|
+
division_type: string;
|
|
36
|
+
/** Emoji flag computed from iso2 */
|
|
37
|
+
flag: string;
|
|
38
|
+
/** SVG/Image URL for the country flag */
|
|
39
|
+
flag_url: string;
|
|
40
|
+
/** Default language code for the country */
|
|
41
|
+
language_code: string;
|
|
42
|
+
/** Default currency code for the country */
|
|
43
|
+
currency_code: string;
|
|
44
|
+
/** Label for tax identification number (e.g. "VAT", "SSN", "ABN") */
|
|
45
|
+
tax_id_label: string;
|
|
46
|
+
/** Placeholder for tax identification number */
|
|
47
|
+
tax_id_placeholder: string;
|
|
48
|
+
/** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
|
|
49
|
+
postal_code_label: string;
|
|
50
|
+
}
|
|
51
|
+
export interface Language {
|
|
52
|
+
code: string;
|
|
53
|
+
english_name: string;
|
|
54
|
+
native_name: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CountryPickerProps {
|
|
57
|
+
/** Currently selected country */
|
|
58
|
+
value?: Country | null;
|
|
59
|
+
/** Callback when user selects a country */
|
|
60
|
+
onChange: (country: Country) => void;
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
/** Enable search input */
|
|
63
|
+
searchable?: boolean;
|
|
64
|
+
/** Show emoji flag next to country name */
|
|
65
|
+
showFlag?: boolean;
|
|
66
|
+
/** Show phone dial code */
|
|
67
|
+
showPhoneCode?: boolean;
|
|
68
|
+
/** Disable the picker */
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
/** Additional wrapper class */
|
|
71
|
+
className?: string;
|
|
72
|
+
/** aria-label */
|
|
73
|
+
label?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface CurrencyPickerProps {
|
|
76
|
+
value?: Currency | null;
|
|
77
|
+
onChange: (currency: Currency) => void;
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
searchable?: boolean;
|
|
80
|
+
/** Filter currencies to a specific country (iso2) and enable auto-selection */
|
|
81
|
+
countryIso2?: string;
|
|
82
|
+
/** Auto-select the first currency if countryIso2 is provided. Defaults to true if countryIso2 is present and value is empty. */
|
|
83
|
+
autoSelect?: boolean;
|
|
84
|
+
/** Show currency symbol alongside code */
|
|
85
|
+
showSymbol?: boolean;
|
|
86
|
+
disabled?: boolean;
|
|
87
|
+
className?: string;
|
|
88
|
+
label?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface TimezonePickerProps {
|
|
91
|
+
value?: Timezone | null;
|
|
92
|
+
onChange: (timezone: Timezone) => void;
|
|
93
|
+
placeholder?: string;
|
|
94
|
+
searchable?: boolean;
|
|
95
|
+
/** Filter timezones to a specific country (iso2) and enable auto-selection */
|
|
96
|
+
countryIso2?: string;
|
|
97
|
+
/** Auto-select the first timezone if countryIso2 is provided. Defaults to true if countryIso2 is present and value is empty. */
|
|
98
|
+
autoSelect?: boolean;
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
className?: string;
|
|
101
|
+
label?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface LanguagePickerProps {
|
|
104
|
+
value?: Language | null;
|
|
105
|
+
onChange: (language: Language) => void;
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
searchable?: boolean;
|
|
108
|
+
/** Show native language name alongside english name */
|
|
109
|
+
showNativeName?: boolean;
|
|
110
|
+
disabled?: boolean;
|
|
111
|
+
className?: string;
|
|
112
|
+
label?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface DivisionPickerProps {
|
|
115
|
+
/** ISO2 code of the parent country (required) */
|
|
116
|
+
countryIso2: string;
|
|
117
|
+
value?: Division | null;
|
|
118
|
+
onChange: (division: Division) => void;
|
|
119
|
+
placeholder?: string;
|
|
120
|
+
searchable?: boolean;
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
className?: string;
|
|
123
|
+
label?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface UsePickerReturn<T> {
|
|
126
|
+
isOpen: boolean;
|
|
127
|
+
searchQuery: string;
|
|
128
|
+
filteredItems: T[];
|
|
129
|
+
selectedItem: T | null;
|
|
130
|
+
open: () => void;
|
|
131
|
+
close: () => void;
|
|
132
|
+
toggle: () => void;
|
|
133
|
+
setSearchQuery: (query: string) => void;
|
|
134
|
+
selectItem: (item: T) => void;
|
|
135
|
+
clearSelection: () => void;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Value object returned by PhoneInput.
|
|
139
|
+
*/
|
|
140
|
+
export interface PhoneValue {
|
|
141
|
+
/** Full Country object of the selected country */
|
|
142
|
+
country: Country;
|
|
143
|
+
/** Dial code with + prefix, e.g. "+1" */
|
|
144
|
+
dialCode: string;
|
|
145
|
+
/** Raw phone number without dial code, e.g. "4155551234" */
|
|
146
|
+
number: string;
|
|
147
|
+
/** Full number with dial code, e.g. "+14155551234" */
|
|
148
|
+
full: string;
|
|
149
|
+
}
|
|
150
|
+
export interface PhoneInputProps {
|
|
151
|
+
value?: PhoneValue | null;
|
|
152
|
+
onChange: (value: PhoneValue) => void;
|
|
153
|
+
/** Pre-select a country by ISO2 on first render */
|
|
154
|
+
defaultCountryIso2?: string;
|
|
155
|
+
placeholder?: string;
|
|
156
|
+
showFlag?: boolean;
|
|
157
|
+
disabled?: boolean;
|
|
158
|
+
className?: string;
|
|
159
|
+
label?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface CountryMultiSelectProps {
|
|
162
|
+
value: Country[];
|
|
163
|
+
onChange: (countries: Country[]) => void;
|
|
164
|
+
placeholder?: string;
|
|
165
|
+
/** Maximum number of selections (undefined = unlimited) */
|
|
166
|
+
maxItems?: number;
|
|
167
|
+
showFlags?: boolean;
|
|
168
|
+
searchable?: boolean;
|
|
169
|
+
disabled?: boolean;
|
|
170
|
+
className?: string;
|
|
171
|
+
label?: string;
|
|
172
|
+
}
|
|
173
|
+
export interface CurrencyMultiSelectProps {
|
|
174
|
+
value: Currency[];
|
|
175
|
+
onChange: (currencies: Currency[]) => void;
|
|
176
|
+
placeholder?: string;
|
|
177
|
+
maxItems?: number;
|
|
178
|
+
showSymbol?: boolean;
|
|
179
|
+
searchable?: boolean;
|
|
180
|
+
disabled?: boolean;
|
|
181
|
+
className?: string;
|
|
182
|
+
label?: string;
|
|
183
|
+
}
|
|
184
|
+
export interface UseMultiSelectReturn<T> {
|
|
185
|
+
isOpen: boolean;
|
|
186
|
+
searchQuery: string;
|
|
187
|
+
filteredItems: T[];
|
|
188
|
+
selectedItems: T[];
|
|
189
|
+
open: () => void;
|
|
190
|
+
close: () => void;
|
|
191
|
+
toggle: () => void;
|
|
192
|
+
setSearchQuery: (query: string) => void;
|
|
193
|
+
toggleItem: (item: T) => void;
|
|
194
|
+
isSelected: (item: T) => boolean;
|
|
195
|
+
removeItem: (item: T) => void;
|
|
196
|
+
clearAll: () => void;
|
|
197
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { iso2ToFlag as _iso2ToFlag } from '../data/countries';
|
|
2
|
+
import { Country, Currency, Division, PhoneFormat, Timezone } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert ISO2 code to emoji flag
|
|
5
|
+
* Re-exported from the generated data module.
|
|
6
|
+
*/
|
|
7
|
+
export { _iso2ToFlag as iso2ToFlag };
|
|
8
|
+
/**
|
|
9
|
+
* Returns all countries
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAllCountries(): Country[];
|
|
12
|
+
/**
|
|
13
|
+
* Find a country by its ISO2 code (case-insensitive)
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCountryByIso2(iso2: string): Country | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Find a country by its ISO3 code (case-insensitive)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCountryByIso3(iso3: string): Country | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Find a country by its name (partial, case-insensitive)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCountryByName(name: string): Country | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Search countries by name, iso2, iso3 or phone code
|
|
26
|
+
*/
|
|
27
|
+
export declare function searchCountries(query: string): Country[];
|
|
28
|
+
/**
|
|
29
|
+
* Get all divisions for a country
|
|
30
|
+
*/
|
|
31
|
+
export declare function getDivisionsByCountry(iso2: string): Division[];
|
|
32
|
+
/**
|
|
33
|
+
* Get all timezones for a country
|
|
34
|
+
*/
|
|
35
|
+
export declare function getTimezonesByCountry(iso2: string): Timezone[];
|
|
36
|
+
/**
|
|
37
|
+
* Get the currency of a country
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Get the currency for a country
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCurrencyByCountry(iso2: string): Currency | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Get the phone format for a country
|
|
45
|
+
*/
|
|
46
|
+
export declare function getPhoneFormatByCountry(iso2: string): PhoneFormat | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Get the min and max phone number lengths for a country
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPhoneLengths(iso2: string): {
|
|
51
|
+
min?: number;
|
|
52
|
+
max?: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get the localized Tax ID label for a country
|
|
56
|
+
*/
|
|
57
|
+
export declare function getTaxLabelByCountry(iso2: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Get the localized Tax ID placeholder for a country
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTaxPlaceholderByCountry(iso2: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Get the localized Postal Code label for a country
|
|
64
|
+
*/
|
|
65
|
+
export declare function getPostalLabelByCountry(iso2: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Currency } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns all unique currencies across all countries
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAllCurrencies(): Currency[];
|
|
6
|
+
/**
|
|
7
|
+
* Find a currency by its code (e.g. "USD")
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCurrencyByCode(code: string): Currency | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Search currencies by code, name, or symbol
|
|
12
|
+
*/
|
|
13
|
+
export declare function searchCurrencies(query: string, countryIso2?: string): Currency[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Language } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns all languages
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAllLanguages(): Language[];
|
|
6
|
+
/**
|
|
7
|
+
* Find a language by its BCP-47 code
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLanguageByCode(code: string): Language | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Search languages by english name, native name, or code
|
|
12
|
+
*/
|
|
13
|
+
export declare function searchLanguages(query: string): Language[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Timezone } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns all unique timezones across all countries
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAllTimezones(): Timezone[];
|
|
6
|
+
/**
|
|
7
|
+
* Find a timezone by its IANA name (e.g. "America/New_York")
|
|
8
|
+
* Supports modern names and common deprecated aliases.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTimezoneByName(name: string): Timezone | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Search timezones by name, abbreviation, or offset string
|
|
13
|
+
*/
|
|
14
|
+
export declare function searchTimezones(query: string, countryIso2?: string): Timezone[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-country-kit-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core datasets, utilities, and hooks for react-country-kit. Comprehensive data for countries, currencies, timezones, languages, and divisions.",
|
|
6
6
|
"author": "Kishor Mainali",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
23
24
|
"import": "./dist/index.mjs",
|
|
24
|
-
"require": "./dist/index.js"
|
|
25
|
-
"types": "./dist/index.d.ts"
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"files": [
|