react-country-kit-core 2.1.4 → 2.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.
@@ -1,65 +1,5 @@
1
- export interface IPhoneFormat {
2
- iso2: string;
3
- dialCode: string;
4
- patterns: string;
5
- possibleLengths: string;
6
- example: string | number;
7
- countryCode: string;
8
- nationalPrefix?: string;
9
- }
10
- export interface ICurrency {
11
- code: string;
12
- name: string;
13
- symbol: string;
14
- countryCode: string;
15
- precision: number;
16
- }
17
- export interface ITimezone {
18
- name: string;
19
- offset: number;
20
- offset_name: string;
21
- abbreviation: string;
22
- tzName: string;
23
- countryCode: string;
24
- }
25
- export interface IDivision {
26
- name: string;
27
- iso2: string;
28
- timezone: string;
29
- countryCode: string;
30
- }
31
- export interface ICountry {
32
- name: string;
33
- iso2: string;
34
- iso3: string;
35
- phone_code: string;
36
- division_type: string;
37
- /** Emoji flag computed from iso2 */
38
- flag: string;
39
- /** SVG/Image URL for the country flag */
40
- flag_url: string;
41
- /** Default language code for the country */
42
- language_code: string;
43
- /** Default currency code for the country */
44
- currency_code: string;
45
- /** Label for tax identification number (e.g. "VAT", "SSN", "ABN") */
46
- tax_id_label: string;
47
- /** Placeholder for tax identification number */
48
- tax_id_placeholder: string;
49
- /** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
50
- postal_code_label: string;
51
- /** Preferred date format, e.g. "DD/MM/YYYY", "MM/DD/YYYY", "YYYY-MM-DD" */
52
- date_format: string;
53
- /** Preferred date separator, e.g. "/", "-", "." */
54
- date_separator: string;
55
- /** First day of the week (0 = Sunday, 1 = Monday, 6 = Saturday) */
56
- week_start: number;
57
- }
58
- export interface ILanguage {
59
- code: string;
60
- english_name: string;
61
- native_name: string;
62
- }
1
+ import { ICountry, ICurrency, ITimezone, IDivision, ILanguage, IPhoneFormat, IPhoneValidation, IDateFormat } from 'react-country-kit-data';
2
+ export * from 'react-country-kit-data';
63
3
  export interface ICountryPickerProps {
64
4
  /** Currently selected country */
65
5
  value?: ICountry | null;
@@ -141,23 +81,6 @@ export interface IUsePickerReturn<T> {
141
81
  selectItem: (item: T) => void;
142
82
  clearSelection: () => void;
143
83
  }
144
- /**
145
- * Phone number validation rules and metadata for a country
146
- */
147
- export interface IPhoneValidation {
148
- /** Min phone number length (without dial code) */
149
- minLength?: number;
150
- /** Max phone number length (without dial code) */
151
- maxLength?: number;
152
- /** Regex pattern for validation */
153
- pattern?: string;
154
- /** Example phone number without dial code */
155
- example?: string;
156
- /** Placeholder text for the phone input */
157
- placeholder?: string;
158
- /** National prefix that can optionally be typed in front, e.g. "0" */
159
- nationalPrefix?: string;
160
- }
161
84
  /**
162
85
  * Value object returned by PhoneInput.
163
86
  */
@@ -221,12 +144,6 @@ export interface IUseMultiSelectReturn<T> {
221
144
  removeItem: (item: T) => void;
222
145
  clearAll: () => void;
223
146
  }
224
- export interface IDateFormat {
225
- countryCode: string;
226
- format: string;
227
- separator: string;
228
- weekStart: number;
229
- }
230
147
  export interface IUseCountryReturn {
231
148
  country: ICountry | null;
232
149
  divisions: IDivision[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-country-kit-core",
3
- "version": "2.1.4",
3
+ "version": "2.2.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",
@@ -35,7 +35,8 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
- "libphonenumber-js": "^1.13.8"
38
+ "libphonenumber-js": "^1.13.8",
39
+ "react-country-kit-data": "^2.2.0"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@types/react": "^19.2.17",
@@ -1,10 +0,0 @@
1
- import { ICountry } from '../types';
2
- /**
3
- * Auto-generated country dataset — DO NOT EDIT MANUALLY.
4
- * Source: https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/countries.json
5
- * Generated: 2026-06-19T15:29:10.745Z
6
- * Countries: 250
7
- */
8
- export declare function iso2ToFlag(iso2: string): string;
9
- export declare const COUNTRIES: ICountry[];
10
- export default COUNTRIES;
@@ -1,3 +0,0 @@
1
- import { ICurrency } from '../types';
2
- export declare const CURRENCIES: ICurrency[];
3
- export default CURRENCIES;
@@ -1,3 +0,0 @@
1
- import { IDateFormat } from '../types';
2
- declare const DATE_FORMATS: IDateFormat[];
3
- export default DATE_FORMATS;
@@ -1,3 +0,0 @@
1
- import { IDivision } from '../types';
2
- export declare const DIVISIONS: IDivision[];
3
- export default DIVISIONS;
@@ -1,3 +0,0 @@
1
- import { ILanguage } from '../types';
2
- declare const languages: ILanguage[];
3
- export default languages;
@@ -1,3 +0,0 @@
1
- import { IPhoneFormat } from '../types';
2
- export declare const PHONE_FORMATS: IPhoneFormat[];
3
- export default PHONE_FORMATS;
@@ -1,3 +0,0 @@
1
- import { ITimezone } from '../types';
2
- export declare const TIMEZONES: ITimezone[];
3
- export default TIMEZONES;
@@ -1,62 +0,0 @@
1
- import { iso2ToFlag as _iso2ToFlag } from '../data/countries';
2
- import { ICountry, ICurrency, IDivision, IPhoneFormat, ITimezone } 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(): ICountry[];
12
- /**
13
- * Find a country by its ISO2 code (case-insensitive)
14
- */
15
- export declare function getCountryByIso2(iso2: string): ICountry | undefined;
16
- /**
17
- * Find a country by its ISO3 code (case-insensitive)
18
- */
19
- export declare function getCountryByIso3(iso3: string): ICountry | undefined;
20
- /**
21
- * Find a country by its name (partial, case-insensitive)
22
- */
23
- export declare function getCountryByName(name: string): ICountry | undefined;
24
- /**
25
- * Search countries by name, iso2, iso3 or phone code
26
- */
27
- export declare function searchCountries(query: string): ICountry[];
28
- /**
29
- * Get all divisions for a country
30
- */
31
- export declare function getDivisionsByCountry(iso2: string): IDivision[];
32
- /**
33
- * Get all timezones for a country
34
- */
35
- export declare function getTimezonesByCountry(iso2: string): ITimezone[];
36
- /**
37
- * Get the currency for a country
38
- */
39
- export declare function getCurrencyByCountry(iso2: string): ICurrency | undefined;
40
- /**
41
- * Get the phone format for a country
42
- */
43
- export declare function getPhoneFormatByCountry(iso2: string): IPhoneFormat | undefined;
44
- /**
45
- * Get the min and max phone number lengths for a country
46
- */
47
- export declare function getPhoneLengths(iso2: string): {
48
- min?: number;
49
- max?: number;
50
- };
51
- /**
52
- * Get the localized Tax ID label for a country
53
- */
54
- export declare function getTaxLabelByCountry(iso2: string): string;
55
- /**
56
- * Get the localized Tax ID placeholder for a country
57
- */
58
- export declare function getTaxPlaceholderByCountry(iso2: string): string;
59
- /**
60
- * Get the localized Postal Code label for a country
61
- */
62
- export declare function getPostalLabelByCountry(iso2: string): string;
@@ -1,13 +0,0 @@
1
- import { ICurrency } from '../types';
2
- /**
3
- * Returns all unique currencies across all countries
4
- */
5
- export declare function getAllCurrencies(): ICurrency[];
6
- /**
7
- * Find a currency by its code (e.g. "USD")
8
- */
9
- export declare function getCurrencyByCode(code: string): ICurrency | undefined;
10
- /**
11
- * Search currencies by code, name, or symbol
12
- */
13
- export declare function searchCurrencies(query: string, countryIso2?: string): ICurrency[];
@@ -1,27 +0,0 @@
1
- import { IDateFormat } from '../types';
2
- /**
3
- * Returns all country date format mappings.
4
- */
5
- export declare function getAllDateFormats(): IDateFormat[];
6
- /**
7
- * Finds the date format configurations for a country by its ISO2 code (case-insensitive).
8
- */
9
- export declare function getDateFormatByCountry(iso2: string): IDateFormat;
10
- /**
11
- * Formats a Date object using a specified pattern (e.g. 'YYYY-MM-DD', 'DD/MM/YYYY').
12
- * Only supports standard YYYY, MM, DD placeholders.
13
- */
14
- export declare function formatDateWithPattern(date: Date, pattern: string): string;
15
- /**
16
- * Formats a Date object based on the country's default date format.
17
- */
18
- export declare function formatDateByCountry(date: Date, iso2: string): string;
19
- /**
20
- * Parses a date string matching a specific pattern (e.g. 'YYYY-MM-DD', 'DD/MM/YYYY') and returns a Date object.
21
- * Returns null if the string is invalid or does not match the pattern.
22
- */
23
- export declare function parseDateWithPattern(dateString: string, pattern: string): Date | null;
24
- /**
25
- * Parses a date string based on the country's default date format.
26
- */
27
- export declare function parseDateByCountry(dateString: string, iso2: string): Date | null;
@@ -1,13 +0,0 @@
1
- import { ILanguage } from '../types';
2
- /**
3
- * Returns all languages
4
- */
5
- export declare function getAllLanguages(): ILanguage[];
6
- /**
7
- * Find a language by its BCP-47 code
8
- */
9
- export declare function getLanguageByCode(code: string): ILanguage | undefined;
10
- /**
11
- * Search languages by english name, native name, or code
12
- */
13
- export declare function searchLanguages(query: string): ILanguage[];
@@ -1,21 +0,0 @@
1
- import { IPhoneValidation } from '../types';
2
- /**
3
- * Get phone number validation rules for a country
4
- * Combines libphonenumber-js data with custom formatting rules
5
- */
6
- export declare function getPhoneValidation(countryIso2: string): IPhoneValidation;
7
- /**
8
- * Format phone example as a user-friendly placeholder
9
- */
10
- export declare function formatPhoneExample(example: string, countryIso2: string): string;
11
- /**
12
- * Validate phone number against country-specific rules
13
- */
14
- export declare function validatePhoneNumber(dialCode: string, number: string, countryIso2: string): {
15
- isValid: boolean;
16
- errors: string[];
17
- };
18
- /**
19
- * Format phone number for display based on country conventions
20
- */
21
- export declare function formatPhoneNumber(number: string, countryIso2: string): string;
@@ -1,14 +0,0 @@
1
- import { ITimezone } from '../types';
2
- /**
3
- * Returns all unique timezones across all countries
4
- */
5
- export declare function getAllTimezones(): ITimezone[];
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): ITimezone | undefined;
11
- /**
12
- * Search timezones by name, abbreviation, or offset string
13
- */
14
- export declare function searchTimezones(query: string, countryIso2?: string): ITimezone[];