react-country-kit-core 1.1.2 → 1.2.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/README.md CHANGED
@@ -1,54 +1,83 @@
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
23
 
24
- Manages country selection and searching.
24
+ Get labels and placeholders for billing/registration forms:
25
25
 
26
- ### `usePhoneInput(initialValue?, onChange?, defaultCountryIso2?)`
26
+ ```tsx
27
+ import {
28
+ getTaxLabelByCountry,
29
+ getTaxPlaceholderByCountry,
30
+ getPostalLabelByCountry,
31
+ } from "react-country-kit-core";
27
32
 
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.
33
+ const label = getTaxLabelByCountry("US"); // "EIN / SSN"
34
+ const placeholder = getTaxPlaceholderByCountry("US"); // "00-0000000"
35
+ const postalLabel = getPostalLabelByCountry("JP"); // "Postal Code (〒)"
36
+ ```
37
37
 
38
- ### `useTimezonePicker(initialValue?, onChange?, countryIso2?)`
38
+ ### Data Retrieval
39
39
 
40
- Manages timezone selection, optionally filtered by country.
40
+ ```tsx
41
+ import {
42
+ getAllCountries,
43
+ getCountryByIso2,
44
+ searchCountries,
45
+ } from "react-country-kit-core";
41
46
 
42
- ## Utility Functions
47
+ const usa = getCountryByIso2("US");
48
+ const results = searchCountries("united");
49
+ ```
43
50
 
44
- - `getAllCountries()`
45
- - `getCountryByIso2(iso2)`
46
- - `getDivisionsByCountry(iso2)`
47
- - `getTimezonesByCountry(iso2)`
48
- - `searchCountries(query)`
49
- - ...and many more.
51
+ ## 🧠 Headless Hooks
52
+
53
+ Our hooks handle state, filtering, and interaction logic so you can focus on the UI:
54
+
55
+ ```tsx
56
+ import { useCountryPicker } from "react-country-kit-core";
57
+
58
+ function CustomPicker() {
59
+ const { filteredItems, searchQuery, setSearchQuery, selectItem } =
60
+ useCountryPicker();
61
+
62
+ return (
63
+ <div>
64
+ <input
65
+ value={searchQuery}
66
+ onChange={(e) => setSearchQuery(e.target.value)}
67
+ />
68
+ <ul>
69
+ {filteredItems.map((c) => (
70
+ <li key={c.iso2} onClick={() => selectItem(c)}>
71
+ {c.name}
72
+ </li>
73
+ ))}
74
+ </ul>
75
+ </div>
76
+ );
77
+ }
78
+ ```
50
79
 
51
- ## Data Structure
80
+ ## 📄 Data Structure
52
81
 
53
82
  ```typescript
54
83
  export interface Country {
@@ -56,14 +85,17 @@ export interface Country {
56
85
  iso2: string;
57
86
  iso3: string;
58
87
  phone_code: string;
88
+ division_type: string;
59
89
  flag: string;
60
90
  flag_url: string;
61
91
  currency_code: string;
62
92
  language_code: string;
63
- division_type: string;
93
+ tax_id_label: string;
94
+ tax_id_placeholder: string;
95
+ postal_code_label: string;
64
96
  }
65
97
  ```
66
98
 
67
- ## License
99
+ ## 📄 License
68
100
 
69
101
  MIT
package/dist/index.d.ts CHANGED
@@ -5,11 +5,7 @@ export declare interface Country {
5
5
  iso2: string;
6
6
  iso3: string;
7
7
  phone_code: string;
8
- phone_format?: PhoneFormat;
9
- currency?: Currency;
10
8
  division_type: string;
11
- divisions?: Division[];
12
- timezones?: Timezone[];
13
9
  /** Emoji flag computed from iso2 */
14
10
  flag: string;
15
11
  /** SVG/Image URL for the country flag */
@@ -19,11 +15,11 @@ export declare interface Country {
19
15
  /** Default currency code for the country */
20
16
  currency_code: string;
21
17
  /** Label for tax identification number (e.g. "VAT", "SSN", "ABN") */
22
- tax_id_label?: string;
18
+ tax_id_label: string;
23
19
  /** Placeholder for tax identification number */
24
- tax_id_placeholder?: string;
20
+ tax_id_placeholder: string;
25
21
  /** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
26
- postal_code_label?: string;
22
+ postal_code_label: string;
27
23
  }
28
24
 
29
25
  export declare interface CountryMultiSelectProps {
@@ -243,7 +239,6 @@ export declare interface LanguagePickerProps {
243
239
  export declare const PHONE_FORMATS: PhoneFormat[];
244
240
 
245
241
  export declare interface PhoneFormat {
246
- countryCode?: string;
247
242
  iso2: string;
248
243
  dialCode: string;
249
244
  patterns: string;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "react-country-kit-core",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
+ "type": "module",
4
5
  "description": "Core datasets, utilities, and hooks for react-country-kit. Comprehensive data for countries, currencies, timezones, languages, and divisions.",
5
6
  "author": "Kishor Mainali",
6
7
  "license": "MIT",