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