intl-tel-input 25.10.5 → 25.10.7
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 +6 -6
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +97 -53
- package/angular/build/IntlTelInputWithUtils.js +97 -53
- package/angular/build/types/intl-tel-input.d.ts +1 -0
- package/build/js/data.js +8 -8
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +1 -0
- package/build/js/intlTelInput.js +98 -54
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +98 -54
- package/build/js/intlTelInputWithUtils.min.js +6 -6
- package/package.json +11 -6
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +97 -53
- package/react/build/IntlTelInput.d.ts +1 -0
- package/react/build/IntlTelInput.js +97 -53
- package/react/build/IntlTelInputWithUtils.cjs +97 -53
- package/react/build/IntlTelInputWithUtils.js +97 -53
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +286 -260
- package/vue/build/IntlTelInputWithUtils.mjs +539 -513
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v25.10.
|
|
2
|
+
* International Telephone Input v25.10.7
|
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -1266,6 +1266,13 @@ var factoryOutput = (() => {
|
|
|
1266
1266
|
// Tuvalu
|
|
1267
1267
|
"688"
|
|
1268
1268
|
],
|
|
1269
|
+
[
|
|
1270
|
+
"vi",
|
|
1271
|
+
// U.S. Virgin Islands
|
|
1272
|
+
"1",
|
|
1273
|
+
24,
|
|
1274
|
+
["340"]
|
|
1275
|
+
],
|
|
1269
1276
|
[
|
|
1270
1277
|
"ug",
|
|
1271
1278
|
// Uganda
|
|
@@ -1300,13 +1307,6 @@ var factoryOutput = (() => {
|
|
|
1300
1307
|
// Uruguay
|
|
1301
1308
|
"598"
|
|
1302
1309
|
],
|
|
1303
|
-
[
|
|
1304
|
-
"vi",
|
|
1305
|
-
// U.S. Virgin Islands
|
|
1306
|
-
"1",
|
|
1307
|
-
24,
|
|
1308
|
-
["340"]
|
|
1309
|
-
],
|
|
1310
1310
|
[
|
|
1311
1311
|
"uz",
|
|
1312
1312
|
// Uzbekistan
|
|
@@ -1882,6 +1882,9 @@ var factoryOutput = (() => {
|
|
|
1882
1882
|
}
|
|
1883
1883
|
//* Add a dial code to this.dialCodeToIso2Map.
|
|
1884
1884
|
_addToDialCodeMap(iso2, dialCode, priority) {
|
|
1885
|
+
if (!iso2 || !dialCode) {
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1885
1888
|
if (dialCode.length > this.dialCodeMaxLen) {
|
|
1886
1889
|
this.dialCodeMaxLen = dialCode.length;
|
|
1887
1890
|
}
|
|
@@ -1936,6 +1939,11 @@ var factoryOutput = (() => {
|
|
|
1936
1939
|
}
|
|
1937
1940
|
this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
|
|
1938
1941
|
}
|
|
1942
|
+
if (this.options.onlyCountries.length || this.options.excludeCountries.length) {
|
|
1943
|
+
this.dialCodes.forEach((dialCode) => {
|
|
1944
|
+
this.dialCodeToIso2Map[dialCode] = this.dialCodeToIso2Map[dialCode].filter(Boolean);
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1939
1947
|
for (const c of this.countries) {
|
|
1940
1948
|
if (c.areaCodes) {
|
|
1941
1949
|
const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
|
|
@@ -2354,7 +2362,7 @@ var factoryOutput = (() => {
|
|
|
2354
2362
|
_openDropdownWithPlus() {
|
|
2355
2363
|
this._openDropdown();
|
|
2356
2364
|
this.searchInput.value = "+";
|
|
2357
|
-
this._filterCountries(""
|
|
2365
|
+
this._filterCountries("");
|
|
2358
2366
|
}
|
|
2359
2367
|
//* Initialize the tel input listeners.
|
|
2360
2368
|
_initTelInputListeners() {
|
|
@@ -2423,6 +2431,36 @@ var factoryOutput = (() => {
|
|
|
2423
2431
|
};
|
|
2424
2432
|
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2425
2433
|
}
|
|
2434
|
+
if (strictMode) {
|
|
2435
|
+
this._handlePasteEvent = (e) => {
|
|
2436
|
+
e.preventDefault();
|
|
2437
|
+
const input = this.telInput;
|
|
2438
|
+
const selStart = input.selectionStart;
|
|
2439
|
+
const selEnd = input.selectionEnd;
|
|
2440
|
+
const pasted = e.clipboardData.getData("text");
|
|
2441
|
+
const initialCharSelected = selStart === 0 && selEnd > 0;
|
|
2442
|
+
const allowLeadingPlus = !input.value.startsWith("+") || initialCharSelected;
|
|
2443
|
+
const allowedChars = pasted.replace(/[^0-9+]/g, "");
|
|
2444
|
+
const hasLeadingPlus = allowedChars.startsWith("+");
|
|
2445
|
+
const numerics = allowedChars.replace(/\+/g, "");
|
|
2446
|
+
const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
|
|
2447
|
+
let newVal = input.value.slice(0, selStart) + sanitised + input.value.slice(selEnd);
|
|
2448
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newVal, this.selectedCountryData.iso2);
|
|
2449
|
+
if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
|
|
2450
|
+
if (input.selectionEnd === input.value.length) {
|
|
2451
|
+
const trimLength = coreNumber.length - this.maxCoreNumberLength;
|
|
2452
|
+
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
2453
|
+
} else {
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
input.value = newVal;
|
|
2458
|
+
const caretPos = selStart + sanitised.length;
|
|
2459
|
+
input.setSelectionRange(caretPos, caretPos);
|
|
2460
|
+
input.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
2461
|
+
};
|
|
2462
|
+
this.telInput.addEventListener("paste", this._handlePasteEvent);
|
|
2463
|
+
}
|
|
2426
2464
|
}
|
|
2427
2465
|
//* Adhere to the input's maxlength attr.
|
|
2428
2466
|
_cap(number) {
|
|
@@ -2537,11 +2575,7 @@ var factoryOutput = (() => {
|
|
|
2537
2575
|
if (this.options.countrySearch) {
|
|
2538
2576
|
const doFilter = () => {
|
|
2539
2577
|
const inputQuery = this.searchInput.value.trim();
|
|
2540
|
-
|
|
2541
|
-
this._filterCountries(inputQuery);
|
|
2542
|
-
} else {
|
|
2543
|
-
this._filterCountries("", true);
|
|
2544
|
-
}
|
|
2578
|
+
this._filterCountries(inputQuery);
|
|
2545
2579
|
if (this.searchInput.value) {
|
|
2546
2580
|
this.searchClearButton.classList.remove("iti__hide");
|
|
2547
2581
|
} else {
|
|
@@ -2580,42 +2614,44 @@ var factoryOutput = (() => {
|
|
|
2580
2614
|
}
|
|
2581
2615
|
}
|
|
2582
2616
|
//* Country search enabled: Filter the countries according to the search query.
|
|
2583
|
-
_filterCountries(query
|
|
2617
|
+
_filterCountries(query) {
|
|
2584
2618
|
let noCountriesAddedYet = true;
|
|
2585
2619
|
this.countryList.innerHTML = "";
|
|
2586
2620
|
const normalisedQuery = normaliseString(query);
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2621
|
+
let matchedCountries;
|
|
2622
|
+
if (query === "") {
|
|
2623
|
+
matchedCountries = this.countries;
|
|
2624
|
+
} else {
|
|
2625
|
+
const iso2Matches = [];
|
|
2626
|
+
const nameStartWith = [];
|
|
2627
|
+
const nameContains = [];
|
|
2628
|
+
const dialCodeMatches = [];
|
|
2629
|
+
const dialCodeContains = [];
|
|
2630
|
+
const initialsMatches = [];
|
|
2631
|
+
for (const c of this.countries) {
|
|
2632
|
+
if (c.iso2 === normalisedQuery) {
|
|
2633
|
+
iso2Matches.push(c);
|
|
2634
|
+
} else if (c.normalisedName.startsWith(normalisedQuery)) {
|
|
2635
|
+
nameStartWith.push(c);
|
|
2636
|
+
} else if (c.normalisedName.includes(normalisedQuery)) {
|
|
2637
|
+
nameContains.push(c);
|
|
2638
|
+
} else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
|
|
2639
|
+
dialCodeMatches.push(c);
|
|
2640
|
+
} else if (c.dialCodePlus.includes(normalisedQuery)) {
|
|
2641
|
+
dialCodeContains.push(c);
|
|
2642
|
+
} else if (c.initials.includes(normalisedQuery)) {
|
|
2643
|
+
initialsMatches.push(c);
|
|
2644
|
+
}
|
|
2609
2645
|
}
|
|
2646
|
+
matchedCountries = [
|
|
2647
|
+
...iso2Matches.sort((a, b) => a.priority - b.priority),
|
|
2648
|
+
...nameStartWith.sort((a, b) => a.priority - b.priority),
|
|
2649
|
+
...nameContains.sort((a, b) => a.priority - b.priority),
|
|
2650
|
+
...dialCodeMatches.sort((a, b) => a.priority - b.priority),
|
|
2651
|
+
...dialCodeContains.sort((a, b) => a.priority - b.priority),
|
|
2652
|
+
...initialsMatches.sort((a, b) => a.priority - b.priority)
|
|
2653
|
+
];
|
|
2610
2654
|
}
|
|
2611
|
-
const matchedCountries = [
|
|
2612
|
-
...iso2Matches.sort((a, b) => a.priority - b.priority),
|
|
2613
|
-
...nameStartWith.sort((a, b) => a.priority - b.priority),
|
|
2614
|
-
...nameContains.sort((a, b) => a.priority - b.priority),
|
|
2615
|
-
...dialCodeMatches.sort((a, b) => a.priority - b.priority),
|
|
2616
|
-
...dialCodeContains.sort((a, b) => a.priority - b.priority),
|
|
2617
|
-
...initialsMatches.sort((a, b) => a.priority - b.priority)
|
|
2618
|
-
];
|
|
2619
2655
|
for (const c of matchedCountries) {
|
|
2620
2656
|
const listItem = c.nodeById[this.id];
|
|
2621
2657
|
if (listItem) {
|
|
@@ -2722,22 +2758,27 @@ var factoryOutput = (() => {
|
|
|
2722
2758
|
if (dialCodeMatch) {
|
|
2723
2759
|
const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
|
|
2724
2760
|
const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
|
|
2761
|
+
if (iso2Codes.length === 1) {
|
|
2762
|
+
if (iso2Codes[0] === selectedIso2) {
|
|
2763
|
+
return null;
|
|
2764
|
+
}
|
|
2765
|
+
return iso2Codes[0];
|
|
2766
|
+
}
|
|
2725
2767
|
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2726
2768
|
return this.defaultCountry;
|
|
2727
2769
|
}
|
|
2770
|
+
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2771
|
+
if (isRegionlessNanpNumber) {
|
|
2772
|
+
return null;
|
|
2773
|
+
}
|
|
2728
2774
|
const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
|
|
2729
2775
|
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
for (const iso2 of iso2Codes) {
|
|
2733
|
-
if (iso2) {
|
|
2734
|
-
return iso2;
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2776
|
+
if (!alreadySelected) {
|
|
2777
|
+
return iso2Codes[0];
|
|
2737
2778
|
}
|
|
2738
2779
|
} else if (number.charAt(0) === "+" && numeric.length) {
|
|
2739
2780
|
return "";
|
|
2740
|
-
} else if ((!number || number === "+") && !
|
|
2781
|
+
} else if ((!number || number === "+") && !selectedIso2) {
|
|
2741
2782
|
return this.defaultCountry;
|
|
2742
2783
|
}
|
|
2743
2784
|
return null;
|
|
@@ -3108,6 +3149,9 @@ var factoryOutput = (() => {
|
|
|
3108
3149
|
if (this._handleKeydownEvent) {
|
|
3109
3150
|
this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
|
|
3110
3151
|
}
|
|
3152
|
+
if (this._handlePasteEvent) {
|
|
3153
|
+
this.telInput.removeEventListener("paste", this._handlePasteEvent);
|
|
3154
|
+
}
|
|
3111
3155
|
this.telInput.removeAttribute("data-intl-tel-input-id");
|
|
3112
3156
|
if (separateDialCode) {
|
|
3113
3157
|
if (this.isRTL) {
|
|
@@ -3286,7 +3330,7 @@ var factoryOutput = (() => {
|
|
|
3286
3330
|
attachUtils,
|
|
3287
3331
|
startedLoadingUtilsScript: false,
|
|
3288
3332
|
startedLoadingAutoCountry: false,
|
|
3289
|
-
version: "25.10.
|
|
3333
|
+
version: "25.10.7"
|
|
3290
3334
|
}
|
|
3291
3335
|
);
|
|
3292
3336
|
var intl_tel_input_default = intlTelInput;
|