react-country-kit-core 1.1.0 → 1.1.2
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/README.md +56 -7
- package/dist/index.d.ts +23 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1264 -443
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,18 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-country-kit-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The engine behind `react-country-kit`. This package provides all the data, hooks, and utilities needed to build your own custom country-related UI components.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
7
|
+
- **250+ Countries**: Comprehensive dataset with ISO codes (2 & 3), flags, and phone codes.
|
|
8
|
+
- **Administrative Divisions**: State/Province data for major countries.
|
|
9
|
+
- **Currencies & Timezones**: Linked data for every country.
|
|
10
|
+
- **Native Language Support**: English and Native names for languages.
|
|
11
|
+
- **Headless Hooks**: Logic-only hooks (`useCountryPicker`, `usePhoneInput`, etc.) for building custom UI.
|
|
12
|
+
- **Phone Formatting**: Integrated `libphonenumber-js` for accurate phone number handling.
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
14
16
|
```bash
|
|
15
|
-
npm install
|
|
17
|
+
npm install react-country-kit-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Available Hooks
|
|
21
|
+
|
|
22
|
+
### `useCountryPicker(initialValue?, onChange?)`
|
|
23
|
+
|
|
24
|
+
Manages country selection and searching.
|
|
25
|
+
|
|
26
|
+
### `usePhoneInput(initialValue?, onChange?, defaultCountryIso2?)`
|
|
27
|
+
|
|
28
|
+
Handles complex phone number input logic, including country switching and validation.
|
|
29
|
+
|
|
30
|
+
### `useDivisionPicker(countryIso2, initialValue?, onChange?)`
|
|
31
|
+
|
|
32
|
+
Manages state/province selection for a specific country.
|
|
33
|
+
|
|
34
|
+
### `useCurrencyPicker(initialValue?, onChange?)`
|
|
35
|
+
|
|
36
|
+
Manages currency selection.
|
|
37
|
+
|
|
38
|
+
### `useTimezonePicker(initialValue?, onChange?, countryIso2?)`
|
|
39
|
+
|
|
40
|
+
Manages timezone selection, optionally filtered by country.
|
|
41
|
+
|
|
42
|
+
## Utility Functions
|
|
43
|
+
|
|
44
|
+
- `getAllCountries()`
|
|
45
|
+
- `getCountryByIso2(iso2)`
|
|
46
|
+
- `getDivisionsByCountry(iso2)`
|
|
47
|
+
- `getTimezonesByCountry(iso2)`
|
|
48
|
+
- `searchCountries(query)`
|
|
49
|
+
- ...and many more.
|
|
50
|
+
|
|
51
|
+
## Data Structure
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
export interface Country {
|
|
55
|
+
name: string;
|
|
56
|
+
iso2: string;
|
|
57
|
+
iso3: string;
|
|
58
|
+
phone_code: string;
|
|
59
|
+
flag: string;
|
|
60
|
+
flag_url: string;
|
|
61
|
+
currency_code: string;
|
|
62
|
+
language_code: string;
|
|
63
|
+
division_type: string;
|
|
64
|
+
}
|
|
16
65
|
```
|
|
17
66
|
|
|
18
67
|
## License
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export declare interface Country {
|
|
|
18
18
|
language_code: string;
|
|
19
19
|
/** Default currency code for the country */
|
|
20
20
|
currency_code: string;
|
|
21
|
+
/** Label for tax identification number (e.g. "VAT", "SSN", "ABN") */
|
|
22
|
+
tax_id_label?: string;
|
|
23
|
+
/** Placeholder for tax identification number */
|
|
24
|
+
tax_id_placeholder?: string;
|
|
25
|
+
/** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
|
|
26
|
+
postal_code_label?: string;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export declare interface CountryMultiSelectProps {
|
|
@@ -182,8 +188,24 @@ export declare function getPhoneLengths(iso2: string): {
|
|
|
182
188
|
max?: number;
|
|
183
189
|
};
|
|
184
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Get the localized Postal Code label for a country
|
|
193
|
+
*/
|
|
194
|
+
export declare function getPostalLabelByCountry(iso2: string): string;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Get the localized Tax ID label for a country
|
|
198
|
+
*/
|
|
199
|
+
export declare function getTaxLabelByCountry(iso2: string): string;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get the localized Tax ID placeholder for a country
|
|
203
|
+
*/
|
|
204
|
+
export declare function getTaxPlaceholderByCountry(iso2: string): string;
|
|
205
|
+
|
|
185
206
|
/**
|
|
186
207
|
* Find a timezone by its IANA name (e.g. "America/New_York")
|
|
208
|
+
* Supports modern names and common deprecated aliases.
|
|
187
209
|
*/
|
|
188
210
|
export declare function getTimezoneByName(name: string): Timezone | undefined;
|
|
189
211
|
|
|
@@ -195,7 +217,7 @@ export declare function getTimezonesByCountry(iso2: string): Timezone[];
|
|
|
195
217
|
/**
|
|
196
218
|
* Auto-generated country dataset — DO NOT EDIT MANUALLY.
|
|
197
219
|
* Source: https://raw.githubusercontent.com/kishormainali/country_division_database/refs/heads/main/countries.json
|
|
198
|
-
* Generated: 2026-05-
|
|
220
|
+
* Generated: 2026-05-15T08:46:14.513Z
|
|
199
221
|
* Countries: 250
|
|
200
222
|
*/
|
|
201
223
|
export declare function iso2ToFlag(iso2: string): string;
|