lite-phone-input 0.3.0 → 0.5.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 +30 -0
- package/dist/core/index.cjs +27 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +27 -2
- package/dist/core/index.js.map +1 -1
- package/dist/preact/index.cjs +54 -10
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.cts +1 -0
- package/dist/preact/index.d.ts +1 -0
- package/dist/preact/index.js +54 -10
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +54 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +54 -10
- package/dist/react/index.js.map +1 -1
- package/dist/vanilla/index.cjs +52 -10
- package/dist/vanilla/index.cjs.map +1 -1
- package/dist/vanilla/index.d.cts +3 -0
- package/dist/vanilla/index.d.ts +3 -0
- package/dist/vanilla/index.global.js +52 -10
- package/dist/vanilla/index.global.js.map +1 -1
- package/dist/vanilla/index.js +52 -10
- package/dist/vanilla/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -65,6 +65,7 @@ interface PhoneInputOptions {
|
|
|
65
65
|
initialValue?: string;
|
|
66
66
|
containerClass?: string;
|
|
67
67
|
dropdownContainer?: HTMLElement;
|
|
68
|
+
geoIpLookup?: (callback: (countryCode: string | null) => void) => void;
|
|
68
69
|
onChange?: (e164: string, country: Country, validation: ValidationResult) => void;
|
|
69
70
|
onCountryChange?: (country: Country) => void;
|
|
70
71
|
onValidationChange?: (validation: ValidationResult) => void;
|
|
@@ -99,7 +100,8 @@ declare function formatPhone(digits: string, pattern: string | null): string;
|
|
|
99
100
|
declare function getCursorPosition(oldValue: string, oldCursor: number, newValue: string): number;
|
|
100
101
|
declare function extractDigits(value: string): string;
|
|
101
102
|
/**
|
|
102
|
-
* Normalize Arabic-Indic
|
|
103
|
+
* Normalize non-ASCII numerals (Arabic-Indic, Persian, Devanagari, Bengali,
|
|
104
|
+
* Thai, Lao, Myanmar, Khmer, Fullwidth) to ASCII 0-9.
|
|
103
105
|
*/
|
|
104
106
|
declare function normalizeNumerals(value: string): string;
|
|
105
107
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ interface PhoneInputOptions {
|
|
|
65
65
|
initialValue?: string;
|
|
66
66
|
containerClass?: string;
|
|
67
67
|
dropdownContainer?: HTMLElement;
|
|
68
|
+
geoIpLookup?: (callback: (countryCode: string | null) => void) => void;
|
|
68
69
|
onChange?: (e164: string, country: Country, validation: ValidationResult) => void;
|
|
69
70
|
onCountryChange?: (country: Country) => void;
|
|
70
71
|
onValidationChange?: (validation: ValidationResult) => void;
|
|
@@ -99,7 +100,8 @@ declare function formatPhone(digits: string, pattern: string | null): string;
|
|
|
99
100
|
declare function getCursorPosition(oldValue: string, oldCursor: number, newValue: string): number;
|
|
100
101
|
declare function extractDigits(value: string): string;
|
|
101
102
|
/**
|
|
102
|
-
* Normalize Arabic-Indic
|
|
103
|
+
* Normalize non-ASCII numerals (Arabic-Indic, Persian, Devanagari, Bengali,
|
|
104
|
+
* Thai, Lao, Myanmar, Khmer, Fullwidth) to ASCII 0-9.
|
|
103
105
|
*/
|
|
104
106
|
declare function normalizeNumerals(value: string): string;
|
|
105
107
|
|
package/dist/core/index.js
CHANGED
|
@@ -2805,7 +2805,27 @@ var phone_countries_default = [
|
|
|
2805
2805
|
// src/core/format.ts
|
|
2806
2806
|
var TRAILING_SEP = /[\s\-]+$/;
|
|
2807
2807
|
var FALLBACK_GROUP = /(.{4})(?=.)/g;
|
|
2808
|
-
var
|
|
2808
|
+
var NUMERAL_BASES = [
|
|
2809
|
+
1632,
|
|
2810
|
+
// Arabic-Indic ٠-٩
|
|
2811
|
+
1776,
|
|
2812
|
+
// Persian ۰-۹
|
|
2813
|
+
2406,
|
|
2814
|
+
// Devanagari ०-९
|
|
2815
|
+
2534,
|
|
2816
|
+
// Bengali ০-৯
|
|
2817
|
+
3664,
|
|
2818
|
+
// Thai ๐-๙
|
|
2819
|
+
3792,
|
|
2820
|
+
// Lao ໐-໙
|
|
2821
|
+
4160,
|
|
2822
|
+
// Myanmar ၀-၉
|
|
2823
|
+
6112,
|
|
2824
|
+
// Khmer ០-៩
|
|
2825
|
+
65296
|
|
2826
|
+
// Fullwidth 0-9
|
|
2827
|
+
];
|
|
2828
|
+
var NON_ASCII_DIGITS = /[\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0E50-\u0E59\u0ED0-\u0ED9\u1040-\u1049\u17E0-\u17E9\uFF10-\uFF19]/g;
|
|
2809
2829
|
function isRelevantChar(ch) {
|
|
2810
2830
|
const c = ch.charCodeAt(0);
|
|
2811
2831
|
return c >= 48 && c <= 57 || c === 43;
|
|
@@ -2855,7 +2875,12 @@ function extractDigits(value) {
|
|
|
2855
2875
|
function normalizeNumerals(value) {
|
|
2856
2876
|
return value.replace(NON_ASCII_DIGITS, (c) => {
|
|
2857
2877
|
const code = c.charCodeAt(0);
|
|
2858
|
-
|
|
2878
|
+
for (const base of NUMERAL_BASES) {
|
|
2879
|
+
if (code >= base && code <= base + 9) {
|
|
2880
|
+
return String(code - base);
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
return c;
|
|
2859
2884
|
});
|
|
2860
2885
|
}
|
|
2861
2886
|
|