react-country-kit-core 1.1.1 → 1.1.3

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 CHANGED
@@ -1,54 +1,71 @@
1
1
  # react-country-kit-core
2
2
 
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.
3
+ The high-performance logic and data engine behind `react-country-kit`. This package provides all the comprehensive datasets, headless hooks, and utilities needed to build custom country-related UI components.
4
4
 
5
- ## Features
5
+ ## 🚀 Features
6
6
 
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.
7
+ - **250+ Countries**: Full dataset with ISO codes, flags, and phone codes.
8
+ - **📑 Localized Metadata**: Built-in support for localized **Tax ID labels** (SSN, VAT, ABN) and **Postal Code labels** (ZIP, PIN, Postcode).
9
+ - **🌍 Global Data**: Timezones (with legacy alias support), Currencies, and Native Language names.
10
+ - **🏙 Administrative Divisions**: State/Province data for all countries.
11
+ - **🧠 Headless Hooks**: Logic-only hooks (`useCountryPicker`, `usePhoneInput`, etc.) for building custom UI with any styling library.
12
+ - **📞 Phone Validation**: Powered by `libphonenumber-js` for accurate formatting and validation.
13
13
 
14
- ## Installation
14
+ ## 📦 Installation
15
15
 
16
16
  ```bash
17
17
  npm install react-country-kit-core
18
18
  ```
19
19
 
20
- ## Available Hooks
20
+ ## 🛠 Utility Functions
21
21
 
22
- ### `useCountryPicker(initialValue?, onChange?)`
22
+ ### Localized Metadata
23
+ Get labels and placeholders for billing/registration forms:
23
24
 
24
- Manages country selection and searching.
25
+ ```tsx
26
+ import {
27
+ getTaxLabelByCountry,
28
+ getTaxPlaceholderByCountry,
29
+ getPostalLabelByCountry
30
+ } from 'react-country-kit-core';
25
31
 
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?)`
32
+ const label = getTaxLabelByCountry('US'); // "EIN / SSN"
33
+ const placeholder = getTaxPlaceholderByCountry('US'); // "00-0000000"
34
+ const postalLabel = getPostalLabelByCountry('JP'); // "Postal Code (〒)"
35
+ ```
39
36
 
40
- Manages timezone selection, optionally filtered by country.
37
+ ### Data Retrieval
38
+ ```tsx
39
+ import { getAllCountries, getCountryByIso2, searchCountries } from 'react-country-kit-core';
41
40
 
42
- ## Utility Functions
41
+ const usa = getCountryByIso2('US');
42
+ const results = searchCountries('united');
43
+ ```
43
44
 
44
- - `getAllCountries()`
45
- - `getCountryByIso2(iso2)`
46
- - `getDivisionsByCountry(iso2)`
47
- - `getTimezonesByCountry(iso2)`
48
- - `searchCountries(query)`
49
- - ...and many more.
45
+ ## 🧠 Headless Hooks
46
+
47
+ Our hooks handle state, filtering, and interaction logic so you can focus on the UI:
48
+
49
+ ```tsx
50
+ import { useCountryPicker } from 'react-country-kit-core';
51
+
52
+ function CustomPicker() {
53
+ const { filteredItems, searchQuery, setSearchQuery, selectItem } = useCountryPicker();
54
+
55
+ return (
56
+ <div>
57
+ <input value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} />
58
+ <ul>
59
+ {filteredItems.map(c => (
60
+ <li key={c.iso2} onClick={() => selectItem(c)}>{c.name}</li>
61
+ ))}
62
+ </ul>
63
+ </div>
64
+ );
65
+ }
66
+ ```
50
67
 
51
- ## Data Structure
68
+ ## 📄 Data Structure
52
69
 
53
70
  ```typescript
54
71
  export interface Country {
@@ -60,10 +77,12 @@ export interface Country {
60
77
  flag_url: string;
61
78
  currency_code: string;
62
79
  language_code: string;
63
- division_type: string;
80
+ tax_id_label: string;
81
+ tax_id_placeholder: string;
82
+ postal_code_label: string;
64
83
  }
65
84
  ```
66
85
 
67
- ## License
86
+ ## 📄 License
68
87
 
69
88
  MIT
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-15T06:35:47.156Z
220
+ * Generated: 2026-05-15T08:46:14.513Z
199
221
  * Countries: 250
200
222
  */
201
223
  export declare function iso2ToFlag(iso2: string): string;