lite-phone-input 0.4.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/dist/core/index.cjs +27 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +27 -2
- package/dist/core/index.js.map +1 -1
- package/dist/preact/index.cjs +35 -9
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +35 -9
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +35 -9
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +35 -9
- package/dist/react/index.js.map +1 -1
- package/dist/vanilla/index.cjs +35 -9
- package/dist/vanilla/index.cjs.map +1 -1
- package/dist/vanilla/index.global.js +35 -9
- package/dist/vanilla/index.global.js.map +1 -1
- package/dist/vanilla/index.js +35 -9
- package/dist/vanilla/index.js.map +1 -1
- package/package.json +1 -1
package/dist/preact/index.cjs
CHANGED
|
@@ -2836,7 +2836,27 @@ var phone_countries_default = [
|
|
|
2836
2836
|
// src/core/format.ts
|
|
2837
2837
|
var TRAILING_SEP = /[\s\-]+$/;
|
|
2838
2838
|
var FALLBACK_GROUP = /(.{4})(?=.)/g;
|
|
2839
|
-
var
|
|
2839
|
+
var NUMERAL_BASES = [
|
|
2840
|
+
1632,
|
|
2841
|
+
// Arabic-Indic ٠-٩
|
|
2842
|
+
1776,
|
|
2843
|
+
// Persian ۰-۹
|
|
2844
|
+
2406,
|
|
2845
|
+
// Devanagari ०-९
|
|
2846
|
+
2534,
|
|
2847
|
+
// Bengali ০-৯
|
|
2848
|
+
3664,
|
|
2849
|
+
// Thai ๐-๙
|
|
2850
|
+
3792,
|
|
2851
|
+
// Lao ໐-໙
|
|
2852
|
+
4160,
|
|
2853
|
+
// Myanmar ၀-၉
|
|
2854
|
+
6112,
|
|
2855
|
+
// Khmer ០-៩
|
|
2856
|
+
65296
|
|
2857
|
+
// Fullwidth 0-9
|
|
2858
|
+
];
|
|
2859
|
+
var NON_ASCII_DIGITS = /[\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0E50-\u0E59\u0ED0-\u0ED9\u1040-\u1049\u17E0-\u17E9\uFF10-\uFF19]/g;
|
|
2840
2860
|
function isRelevantChar(ch) {
|
|
2841
2861
|
const c = ch.charCodeAt(0);
|
|
2842
2862
|
return c >= 48 && c <= 57 || c === 43;
|
|
@@ -2886,9 +2906,18 @@ function extractDigits(value) {
|
|
|
2886
2906
|
function normalizeNumerals(value) {
|
|
2887
2907
|
return value.replace(NON_ASCII_DIGITS, (c) => {
|
|
2888
2908
|
const code = c.charCodeAt(0);
|
|
2889
|
-
|
|
2909
|
+
for (const base of NUMERAL_BASES) {
|
|
2910
|
+
if (code >= base && code <= base + 9) {
|
|
2911
|
+
return String(code - base);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
return c;
|
|
2890
2915
|
});
|
|
2891
2916
|
}
|
|
2917
|
+
function isNonAsciiDigit(ch) {
|
|
2918
|
+
const code = ch.charCodeAt(0);
|
|
2919
|
+
return NUMERAL_BASES.some((base) => code >= base && code <= base + 9);
|
|
2920
|
+
}
|
|
2892
2921
|
|
|
2893
2922
|
// src/core/countries.ts
|
|
2894
2923
|
function getFlag(code) {
|
|
@@ -3526,7 +3555,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3526
3555
|
const formatted = this.formatNationalValue(digits);
|
|
3527
3556
|
const np = this.shouldPrependPrefix ? this.selectedCountry.nationalPrefix : "";
|
|
3528
3557
|
const display = !digits && np && extractDigits(raw).length > 0 ? np : digits && np ? np + formatted : formatted;
|
|
3529
|
-
const newCursor = this.getNationalCursor(
|
|
3558
|
+
const newCursor = this.getNationalCursor(raw, oldCursor, formatted);
|
|
3530
3559
|
this.inputEl.value = display;
|
|
3531
3560
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3532
3561
|
} else {
|
|
@@ -3553,7 +3582,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3553
3582
|
} else {
|
|
3554
3583
|
formatted = this.formatNationalValue(national);
|
|
3555
3584
|
}
|
|
3556
|
-
const newCursor = getCursorPosition(
|
|
3585
|
+
const newCursor = getCursorPosition(raw, oldCursor, formatted);
|
|
3557
3586
|
this.inputEl.value = formatted;
|
|
3558
3587
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3559
3588
|
}
|
|
@@ -3568,11 +3597,8 @@ var PhoneInput = class _PhoneInput {
|
|
|
3568
3597
|
if (!this.isNationalInput && e.key === "+" && this.inputEl.selectionStart === 0) {
|
|
3569
3598
|
return;
|
|
3570
3599
|
}
|
|
3571
|
-
if (e.key.length === 1 && !/\d/.test(e.key)) {
|
|
3572
|
-
|
|
3573
|
-
if (!(code >= 1632 && code <= 1641 || code >= 1776 && code <= 1785)) {
|
|
3574
|
-
e.preventDefault();
|
|
3575
|
-
}
|
|
3600
|
+
if (e.key.length === 1 && !/\d/.test(e.key) && !isNonAsciiDigit(e.key)) {
|
|
3601
|
+
e.preventDefault();
|
|
3576
3602
|
}
|
|
3577
3603
|
}
|
|
3578
3604
|
handlePaste(e) {
|