react-country-kit-core 2.0.0 → 2.1.1
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/dist/data/dateFormats.d.ts +3 -0
- package/dist/hooks/useDateFormat.d.ts +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3125 -662
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +16 -0
- package/dist/utils/date.d.ts +27 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface IPhoneFormat {
|
|
|
5
5
|
possibleLengths: string;
|
|
6
6
|
example: string | number;
|
|
7
7
|
countryCode: string;
|
|
8
|
+
nationalPrefix?: string;
|
|
8
9
|
}
|
|
9
10
|
export interface ICurrency {
|
|
10
11
|
code: string;
|
|
@@ -47,6 +48,12 @@ export interface ICountry {
|
|
|
47
48
|
tax_id_placeholder: string;
|
|
48
49
|
/** Label for postal/zip code (e.g. "ZIP Code", "Postcode", "PIN Code") */
|
|
49
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;
|
|
50
57
|
}
|
|
51
58
|
export interface ILanguage {
|
|
52
59
|
code: string;
|
|
@@ -148,6 +155,8 @@ export interface IPhoneValidation {
|
|
|
148
155
|
example?: string;
|
|
149
156
|
/** Placeholder text for the phone input */
|
|
150
157
|
placeholder?: string;
|
|
158
|
+
/** National prefix that can optionally be typed in front, e.g. "0" */
|
|
159
|
+
nationalPrefix?: string;
|
|
151
160
|
}
|
|
152
161
|
/**
|
|
153
162
|
* Value object returned by PhoneInput.
|
|
@@ -212,6 +221,12 @@ export interface IUseMultiSelectReturn<T> {
|
|
|
212
221
|
removeItem: (item: T) => void;
|
|
213
222
|
clearAll: () => void;
|
|
214
223
|
}
|
|
224
|
+
export interface IDateFormat {
|
|
225
|
+
countryCode: string;
|
|
226
|
+
format: string;
|
|
227
|
+
separator: string;
|
|
228
|
+
weekStart: number;
|
|
229
|
+
}
|
|
215
230
|
export interface IUseCountryReturn {
|
|
216
231
|
country: ICountry | null;
|
|
217
232
|
divisions: IDivision[];
|
|
@@ -230,4 +245,5 @@ export interface IUseCountryReturn {
|
|
|
230
245
|
postalCode: {
|
|
231
246
|
label: string;
|
|
232
247
|
};
|
|
248
|
+
dateFormat: IDateFormat | null;
|
|
233
249
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-country-kit-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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",
|