react-country-kit-core 1.1.2 → 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.
Files changed (2) hide show
  1. package/README.md +55 -36
  2. package/package.json +1 -1
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-country-kit-core",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Core datasets, utilities, and hooks for react-country-kit. Comprehensive data for countries, currencies, timezones, languages, and divisions.",
5
5
  "author": "Kishor Mainali",
6
6
  "license": "MIT",