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.js
CHANGED
|
@@ -2808,7 +2808,27 @@ var phone_countries_default = [
|
|
|
2808
2808
|
// src/core/format.ts
|
|
2809
2809
|
var TRAILING_SEP = /[\s\-]+$/;
|
|
2810
2810
|
var FALLBACK_GROUP = /(.{4})(?=.)/g;
|
|
2811
|
-
var
|
|
2811
|
+
var NUMERAL_BASES = [
|
|
2812
|
+
1632,
|
|
2813
|
+
// Arabic-Indic ٠-٩
|
|
2814
|
+
1776,
|
|
2815
|
+
// Persian ۰-۹
|
|
2816
|
+
2406,
|
|
2817
|
+
// Devanagari ०-९
|
|
2818
|
+
2534,
|
|
2819
|
+
// Bengali ০-৯
|
|
2820
|
+
3664,
|
|
2821
|
+
// Thai ๐-๙
|
|
2822
|
+
3792,
|
|
2823
|
+
// Lao ໐-໙
|
|
2824
|
+
4160,
|
|
2825
|
+
// Myanmar ၀-၉
|
|
2826
|
+
6112,
|
|
2827
|
+
// Khmer ០-៩
|
|
2828
|
+
65296
|
|
2829
|
+
// Fullwidth 0-9
|
|
2830
|
+
];
|
|
2831
|
+
var NON_ASCII_DIGITS = /[\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0E50-\u0E59\u0ED0-\u0ED9\u1040-\u1049\u17E0-\u17E9\uFF10-\uFF19]/g;
|
|
2812
2832
|
function isRelevantChar(ch) {
|
|
2813
2833
|
const c = ch.charCodeAt(0);
|
|
2814
2834
|
return c >= 48 && c <= 57 || c === 43;
|
|
@@ -2858,9 +2878,18 @@ function extractDigits(value) {
|
|
|
2858
2878
|
function normalizeNumerals(value) {
|
|
2859
2879
|
return value.replace(NON_ASCII_DIGITS, (c) => {
|
|
2860
2880
|
const code = c.charCodeAt(0);
|
|
2861
|
-
|
|
2881
|
+
for (const base of NUMERAL_BASES) {
|
|
2882
|
+
if (code >= base && code <= base + 9) {
|
|
2883
|
+
return String(code - base);
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
return c;
|
|
2862
2887
|
});
|
|
2863
2888
|
}
|
|
2889
|
+
function isNonAsciiDigit(ch) {
|
|
2890
|
+
const code = ch.charCodeAt(0);
|
|
2891
|
+
return NUMERAL_BASES.some((base) => code >= base && code <= base + 9);
|
|
2892
|
+
}
|
|
2864
2893
|
|
|
2865
2894
|
// src/core/countries.ts
|
|
2866
2895
|
function getFlag(code) {
|
|
@@ -3498,7 +3527,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3498
3527
|
const formatted = this.formatNationalValue(digits);
|
|
3499
3528
|
const np = this.shouldPrependPrefix ? this.selectedCountry.nationalPrefix : "";
|
|
3500
3529
|
const display = !digits && np && extractDigits(raw).length > 0 ? np : digits && np ? np + formatted : formatted;
|
|
3501
|
-
const newCursor = this.getNationalCursor(
|
|
3530
|
+
const newCursor = this.getNationalCursor(raw, oldCursor, formatted);
|
|
3502
3531
|
this.inputEl.value = display;
|
|
3503
3532
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3504
3533
|
} else {
|
|
@@ -3525,7 +3554,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3525
3554
|
} else {
|
|
3526
3555
|
formatted = this.formatNationalValue(national);
|
|
3527
3556
|
}
|
|
3528
|
-
const newCursor = getCursorPosition(
|
|
3557
|
+
const newCursor = getCursorPosition(raw, oldCursor, formatted);
|
|
3529
3558
|
this.inputEl.value = formatted;
|
|
3530
3559
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3531
3560
|
}
|
|
@@ -3540,11 +3569,8 @@ var PhoneInput = class _PhoneInput {
|
|
|
3540
3569
|
if (!this.isNationalInput && e.key === "+" && this.inputEl.selectionStart === 0) {
|
|
3541
3570
|
return;
|
|
3542
3571
|
}
|
|
3543
|
-
if (e.key.length === 1 && !/\d/.test(e.key)) {
|
|
3544
|
-
|
|
3545
|
-
if (!(code >= 1632 && code <= 1641 || code >= 1776 && code <= 1785)) {
|
|
3546
|
-
e.preventDefault();
|
|
3547
|
-
}
|
|
3572
|
+
if (e.key.length === 1 && !/\d/.test(e.key) && !isNonAsciiDigit(e.key)) {
|
|
3573
|
+
e.preventDefault();
|
|
3548
3574
|
}
|
|
3549
3575
|
}
|
|
3550
3576
|
handlePaste(e) {
|