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/vanilla/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,9 +2875,18 @@ 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
|
}
|
|
2886
|
+
function isNonAsciiDigit(ch) {
|
|
2887
|
+
const code = ch.charCodeAt(0);
|
|
2888
|
+
return NUMERAL_BASES.some((base) => code >= base && code <= base + 9);
|
|
2889
|
+
}
|
|
2861
2890
|
|
|
2862
2891
|
// src/core/countries.ts
|
|
2863
2892
|
function getFlag(code) {
|
|
@@ -3495,7 +3524,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3495
3524
|
const formatted = this.formatNationalValue(digits);
|
|
3496
3525
|
const np = this.shouldPrependPrefix ? this.selectedCountry.nationalPrefix : "";
|
|
3497
3526
|
const display = !digits && np && extractDigits(raw).length > 0 ? np : digits && np ? np + formatted : formatted;
|
|
3498
|
-
const newCursor = this.getNationalCursor(
|
|
3527
|
+
const newCursor = this.getNationalCursor(raw, oldCursor, formatted);
|
|
3499
3528
|
this.inputEl.value = display;
|
|
3500
3529
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3501
3530
|
} else {
|
|
@@ -3522,7 +3551,7 @@ var PhoneInput = class _PhoneInput {
|
|
|
3522
3551
|
} else {
|
|
3523
3552
|
formatted = this.formatNationalValue(national);
|
|
3524
3553
|
}
|
|
3525
|
-
const newCursor = getCursorPosition(
|
|
3554
|
+
const newCursor = getCursorPosition(raw, oldCursor, formatted);
|
|
3526
3555
|
this.inputEl.value = formatted;
|
|
3527
3556
|
this.inputEl.setSelectionRange(newCursor, newCursor);
|
|
3528
3557
|
}
|
|
@@ -3537,11 +3566,8 @@ var PhoneInput = class _PhoneInput {
|
|
|
3537
3566
|
if (!this.isNationalInput && e.key === "+" && this.inputEl.selectionStart === 0) {
|
|
3538
3567
|
return;
|
|
3539
3568
|
}
|
|
3540
|
-
if (e.key.length === 1 && !/\d/.test(e.key)) {
|
|
3541
|
-
|
|
3542
|
-
if (!(code >= 1632 && code <= 1641 || code >= 1776 && code <= 1785)) {
|
|
3543
|
-
e.preventDefault();
|
|
3544
|
-
}
|
|
3569
|
+
if (e.key.length === 1 && !/\d/.test(e.key) && !isNonAsciiDigit(e.key)) {
|
|
3570
|
+
e.preventDefault();
|
|
3545
3571
|
}
|
|
3546
3572
|
}
|
|
3547
3573
|
handlePaste(e) {
|