intl-tel-input 25.0.2 → 25.1.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/README.md +5 -5
- package/build/js/data.js +34 -16
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +4 -3
- package/build/js/intlTelInput.js +57 -57
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +57 -57
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +56 -56
- package/react/build/IntlTelInput.d.ts +4 -3
- package/react/build/IntlTelInput.js +56 -56
- package/react/build/IntlTelInputWithUtils.cjs +56 -56
- package/react/build/IntlTelInputWithUtils.js +56 -56
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +370 -344
- package/vue/build/IntlTelInputWithUtils.mjs +678 -652
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeModels as D, useModel as x, ref as L, onMounted as E, watch as M, onUnmounted as F, withDirectives as B, openBlock as V, createElementBlock as O, mergeProps as z, vModelText as R } from "vue";
|
|
2
|
-
const
|
|
2
|
+
const N = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -76,7 +76,9 @@ const A = [
|
|
|
76
76
|
"au",
|
|
77
77
|
// Australia
|
|
78
78
|
"61",
|
|
79
|
-
0
|
|
79
|
+
0,
|
|
80
|
+
null,
|
|
81
|
+
"0"
|
|
80
82
|
],
|
|
81
83
|
[
|
|
82
84
|
"at",
|
|
@@ -257,14 +259,16 @@ const A = [
|
|
|
257
259
|
// Christmas Island
|
|
258
260
|
"61",
|
|
259
261
|
2,
|
|
260
|
-
["89164"]
|
|
262
|
+
["89164"],
|
|
263
|
+
"0"
|
|
261
264
|
],
|
|
262
265
|
[
|
|
263
266
|
"cc",
|
|
264
267
|
// Cocos (Keeling) Islands
|
|
265
268
|
"61",
|
|
266
269
|
1,
|
|
267
|
-
["89162"]
|
|
270
|
+
["89162"],
|
|
271
|
+
"0"
|
|
268
272
|
],
|
|
269
273
|
[
|
|
270
274
|
"co",
|
|
@@ -497,7 +501,8 @@ const A = [
|
|
|
497
501
|
// Guernsey
|
|
498
502
|
"44",
|
|
499
503
|
1,
|
|
500
|
-
["1481", "7781", "7839", "7911"]
|
|
504
|
+
["1481", "7781", "7839", "7911"],
|
|
505
|
+
"0"
|
|
501
506
|
],
|
|
502
507
|
[
|
|
503
508
|
"gn",
|
|
@@ -569,7 +574,8 @@ const A = [
|
|
|
569
574
|
// Isle of Man
|
|
570
575
|
"44",
|
|
571
576
|
2,
|
|
572
|
-
["1624", "74576", "7524", "7924", "7624"]
|
|
577
|
+
["1624", "74576", "7524", "7924", "7624"],
|
|
578
|
+
"0"
|
|
573
579
|
],
|
|
574
580
|
[
|
|
575
581
|
"il",
|
|
@@ -599,7 +605,8 @@ const A = [
|
|
|
599
605
|
// Jersey
|
|
600
606
|
"44",
|
|
601
607
|
3,
|
|
602
|
-
["1534", "7509", "7700", "7797", "7829", "7937"]
|
|
608
|
+
["1534", "7509", "7700", "7797", "7829", "7937"],
|
|
609
|
+
"0"
|
|
603
610
|
],
|
|
604
611
|
[
|
|
605
612
|
"jo",
|
|
@@ -611,7 +618,8 @@ const A = [
|
|
|
611
618
|
// Kazakhstan
|
|
612
619
|
"7",
|
|
613
620
|
1,
|
|
614
|
-
["33", "7"]
|
|
621
|
+
["33", "7"],
|
|
622
|
+
"8"
|
|
615
623
|
],
|
|
616
624
|
[
|
|
617
625
|
"ke",
|
|
@@ -743,7 +751,8 @@ const A = [
|
|
|
743
751
|
// Mayotte
|
|
744
752
|
"262",
|
|
745
753
|
1,
|
|
746
|
-
["269", "639"]
|
|
754
|
+
["269", "639"],
|
|
755
|
+
"0"
|
|
747
756
|
],
|
|
748
757
|
[
|
|
749
758
|
"mx",
|
|
@@ -786,7 +795,9 @@ const A = [
|
|
|
786
795
|
"ma",
|
|
787
796
|
// Morocco
|
|
788
797
|
"212",
|
|
789
|
-
0
|
|
798
|
+
0,
|
|
799
|
+
null,
|
|
800
|
+
"0"
|
|
790
801
|
],
|
|
791
802
|
[
|
|
792
803
|
"mz",
|
|
@@ -947,7 +958,9 @@ const A = [
|
|
|
947
958
|
"re",
|
|
948
959
|
// Réunion
|
|
949
960
|
"262",
|
|
950
|
-
0
|
|
961
|
+
0,
|
|
962
|
+
null,
|
|
963
|
+
"0"
|
|
951
964
|
],
|
|
952
965
|
[
|
|
953
966
|
"ro",
|
|
@@ -958,7 +971,9 @@ const A = [
|
|
|
958
971
|
"ru",
|
|
959
972
|
// Russia
|
|
960
973
|
"7",
|
|
961
|
-
0
|
|
974
|
+
0,
|
|
975
|
+
null,
|
|
976
|
+
"8"
|
|
962
977
|
],
|
|
963
978
|
[
|
|
964
979
|
"rw",
|
|
@@ -1230,7 +1245,9 @@ const A = [
|
|
|
1230
1245
|
"gb",
|
|
1231
1246
|
// United Kingdom
|
|
1232
1247
|
"44",
|
|
1233
|
-
0
|
|
1248
|
+
0,
|
|
1249
|
+
null,
|
|
1250
|
+
"0"
|
|
1234
1251
|
],
|
|
1235
1252
|
[
|
|
1236
1253
|
"us",
|
|
@@ -1287,7 +1304,8 @@ const A = [
|
|
|
1287
1304
|
// Western Sahara
|
|
1288
1305
|
"212",
|
|
1289
1306
|
1,
|
|
1290
|
-
["5288", "5289"]
|
|
1307
|
+
["5288", "5289"],
|
|
1308
|
+
"0"
|
|
1291
1309
|
],
|
|
1292
1310
|
[
|
|
1293
1311
|
"ye",
|
|
@@ -1305,17 +1323,17 @@ const A = [
|
|
|
1305
1323
|
"263"
|
|
1306
1324
|
]
|
|
1307
1325
|
], I = [];
|
|
1308
|
-
for (let u = 0; u <
|
|
1309
|
-
const
|
|
1326
|
+
for (let u = 0; u < N.length; u++) {
|
|
1327
|
+
const t = N[u];
|
|
1310
1328
|
I[u] = {
|
|
1311
1329
|
name: "",
|
|
1312
1330
|
// this is now populated in the plugin
|
|
1313
|
-
iso2:
|
|
1314
|
-
dialCode:
|
|
1315
|
-
priority:
|
|
1316
|
-
areaCodes:
|
|
1317
|
-
|
|
1318
|
-
|
|
1331
|
+
iso2: t[0],
|
|
1332
|
+
dialCode: t[1],
|
|
1333
|
+
priority: t[2] || 0,
|
|
1334
|
+
areaCodes: t[3] || null,
|
|
1335
|
+
nodeById: {},
|
|
1336
|
+
nationalPrefix: t[4] || null
|
|
1319
1337
|
};
|
|
1320
1338
|
}
|
|
1321
1339
|
const j = {
|
|
@@ -1631,7 +1649,7 @@ const T = {
|
|
|
1631
1649
|
) : !1,
|
|
1632
1650
|
//* The number type to enforce during validation.
|
|
1633
1651
|
validationNumberTypes: ["MOBILE"]
|
|
1634
|
-
},
|
|
1652
|
+
}, H = [
|
|
1635
1653
|
"800",
|
|
1636
1654
|
"822",
|
|
1637
1655
|
"833",
|
|
@@ -1649,46 +1667,46 @@ const T = {
|
|
|
1649
1667
|
"887",
|
|
1650
1668
|
"888",
|
|
1651
1669
|
"889"
|
|
1652
|
-
], v = (u) => u.replace(/\D/g, ""),
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1655
|
-
const
|
|
1656
|
-
return
|
|
1670
|
+
], v = (u) => u.replace(/\D/g, ""), A = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
|
|
1671
|
+
const t = v(u);
|
|
1672
|
+
if (t.charAt(0) === "1") {
|
|
1673
|
+
const e = t.substr(1, 3);
|
|
1674
|
+
return H.indexOf(e) !== -1;
|
|
1657
1675
|
}
|
|
1658
1676
|
return !1;
|
|
1659
|
-
},
|
|
1660
|
-
if (
|
|
1677
|
+
}, K = (u, t, e, i) => {
|
|
1678
|
+
if (e === 0 && !i)
|
|
1661
1679
|
return 0;
|
|
1662
1680
|
let s = 0;
|
|
1663
|
-
for (let n = 0; n <
|
|
1664
|
-
if (/[+0-9]/.test(
|
|
1681
|
+
for (let n = 0; n < t.length; n++) {
|
|
1682
|
+
if (/[+0-9]/.test(t[n]) && s++, s === u && !i)
|
|
1665
1683
|
return n + 1;
|
|
1666
1684
|
if (i && s === u + 1)
|
|
1667
1685
|
return n;
|
|
1668
1686
|
}
|
|
1669
|
-
return
|
|
1670
|
-
}, y = (u,
|
|
1687
|
+
return t.length;
|
|
1688
|
+
}, y = (u, t, e) => {
|
|
1671
1689
|
const i = document.createElement(u);
|
|
1672
|
-
return
|
|
1673
|
-
}, w = (u, ...
|
|
1674
|
-
const { instances:
|
|
1675
|
-
Object.values(
|
|
1690
|
+
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1691
|
+
}, w = (u, ...t) => {
|
|
1692
|
+
const { instances: e } = l;
|
|
1693
|
+
Object.values(e).forEach((i) => i[u](...t));
|
|
1676
1694
|
};
|
|
1677
1695
|
class G {
|
|
1678
|
-
constructor(
|
|
1679
|
-
this.id = U++, this.telInput =
|
|
1696
|
+
constructor(t, e = {}) {
|
|
1697
|
+
this.id = U++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, T, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1680
1698
|
}
|
|
1681
1699
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1682
1700
|
_init() {
|
|
1683
1701
|
this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]");
|
|
1684
|
-
const
|
|
1685
|
-
this.showSelectedCountryOnLeft = this.isRTL ? !
|
|
1686
|
-
const
|
|
1702
|
+
const t = this.options.allowDropdown || this.options.separateDialCode;
|
|
1703
|
+
this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...k, ...this.options.i18n };
|
|
1704
|
+
const e = new Promise((s, n) => {
|
|
1687
1705
|
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
|
|
1688
1706
|
}), i = new Promise((s, n) => {
|
|
1689
1707
|
this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = n;
|
|
1690
1708
|
});
|
|
1691
|
-
this.promise = Promise.all([
|
|
1709
|
+
this.promise = Promise.all([e, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests();
|
|
1692
1710
|
}
|
|
1693
1711
|
//********************
|
|
1694
1712
|
//* PRIVATE METHODS
|
|
@@ -1699,37 +1717,37 @@ class G {
|
|
|
1699
1717
|
}
|
|
1700
1718
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1701
1719
|
_sortCountries() {
|
|
1702
|
-
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((
|
|
1720
|
+
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((t) => t.toLowerCase())), this.countries.sort((t, e) => {
|
|
1703
1721
|
const { countryOrder: i } = this.options;
|
|
1704
1722
|
if (i) {
|
|
1705
|
-
const s = i.indexOf(
|
|
1706
|
-
if (o ||
|
|
1707
|
-
return o &&
|
|
1723
|
+
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), o = s > -1, r = n > -1;
|
|
1724
|
+
if (o || r)
|
|
1725
|
+
return o && r ? s - n : o ? -1 : 1;
|
|
1708
1726
|
}
|
|
1709
|
-
return
|
|
1727
|
+
return t.name.localeCompare(e.name);
|
|
1710
1728
|
});
|
|
1711
1729
|
}
|
|
1712
1730
|
//* Add a dial code to this.dialCodeToIso2Map.
|
|
1713
|
-
_addToDialCodeMap(
|
|
1714
|
-
|
|
1715
|
-
for (let n = 0; n < this.dialCodeToIso2Map[
|
|
1716
|
-
if (this.dialCodeToIso2Map[
|
|
1731
|
+
_addToDialCodeMap(t, e, i) {
|
|
1732
|
+
e.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = e.length), this.dialCodeToIso2Map.hasOwnProperty(e) || (this.dialCodeToIso2Map[e] = []);
|
|
1733
|
+
for (let n = 0; n < this.dialCodeToIso2Map[e].length; n++)
|
|
1734
|
+
if (this.dialCodeToIso2Map[e][n] === t)
|
|
1717
1735
|
return;
|
|
1718
|
-
const s = i !== void 0 ? i : this.dialCodeToIso2Map[
|
|
1719
|
-
this.dialCodeToIso2Map[
|
|
1736
|
+
const s = i !== void 0 ? i : this.dialCodeToIso2Map[e].length;
|
|
1737
|
+
this.dialCodeToIso2Map[e][s] = t;
|
|
1720
1738
|
}
|
|
1721
1739
|
//* Process onlyCountries or excludeCountries array if present.
|
|
1722
1740
|
_processAllCountries() {
|
|
1723
|
-
const { onlyCountries:
|
|
1724
|
-
if (
|
|
1725
|
-
const i =
|
|
1741
|
+
const { onlyCountries: t, excludeCountries: e } = this.options;
|
|
1742
|
+
if (t.length) {
|
|
1743
|
+
const i = t.map(
|
|
1726
1744
|
(s) => s.toLowerCase()
|
|
1727
1745
|
);
|
|
1728
1746
|
this.countries = I.filter(
|
|
1729
1747
|
(s) => i.indexOf(s.iso2) > -1
|
|
1730
1748
|
);
|
|
1731
|
-
} else if (
|
|
1732
|
-
const i =
|
|
1749
|
+
} else if (e.length) {
|
|
1750
|
+
const i = e.map(
|
|
1733
1751
|
(s) => s.toLowerCase()
|
|
1734
1752
|
);
|
|
1735
1753
|
this.countries = I.filter(
|
|
@@ -1740,58 +1758,58 @@ class G {
|
|
|
1740
1758
|
}
|
|
1741
1759
|
//* Translate Countries by object literal provided on config.
|
|
1742
1760
|
_translateCountryNames() {
|
|
1743
|
-
for (let
|
|
1744
|
-
const
|
|
1745
|
-
this.options.i18n.hasOwnProperty(
|
|
1761
|
+
for (let t = 0; t < this.countries.length; t++) {
|
|
1762
|
+
const e = this.countries[t].iso2.toLowerCase();
|
|
1763
|
+
this.options.i18n.hasOwnProperty(e) && (this.countries[t].name = this.options.i18n[e]);
|
|
1746
1764
|
}
|
|
1747
1765
|
}
|
|
1748
|
-
//* Generate this.dialCodes and this.dialCodeToIso2Map
|
|
1766
|
+
//* Generate this.dialCodes and this.dialCodeToIso2Map.
|
|
1749
1767
|
_processDialCodes() {
|
|
1750
1768
|
this.dialCodes = {}, this.dialCodeMaxLen = 0, this.dialCodeToIso2Map = {};
|
|
1751
|
-
for (let
|
|
1752
|
-
const
|
|
1753
|
-
this.dialCodes[
|
|
1769
|
+
for (let t = 0; t < this.countries.length; t++) {
|
|
1770
|
+
const e = this.countries[t];
|
|
1771
|
+
this.dialCodes[e.dialCode] || (this.dialCodes[e.dialCode] = !0), this._addToDialCodeMap(e.iso2, e.dialCode, e.priority);
|
|
1754
1772
|
}
|
|
1755
|
-
for (let
|
|
1756
|
-
const
|
|
1757
|
-
if (
|
|
1758
|
-
const i = this.dialCodeToIso2Map[
|
|
1759
|
-
for (let s = 0; s <
|
|
1760
|
-
const n =
|
|
1773
|
+
for (let t = 0; t < this.countries.length; t++) {
|
|
1774
|
+
const e = this.countries[t];
|
|
1775
|
+
if (e.areaCodes) {
|
|
1776
|
+
const i = this.dialCodeToIso2Map[e.dialCode][0];
|
|
1777
|
+
for (let s = 0; s < e.areaCodes.length; s++) {
|
|
1778
|
+
const n = e.areaCodes[s];
|
|
1761
1779
|
for (let o = 1; o < n.length; o++) {
|
|
1762
|
-
const
|
|
1763
|
-
this._addToDialCodeMap(i,
|
|
1780
|
+
const r = n.substr(0, o), a = e.dialCode + r;
|
|
1781
|
+
this._addToDialCodeMap(i, a), this._addToDialCodeMap(e.iso2, a);
|
|
1764
1782
|
}
|
|
1765
|
-
this._addToDialCodeMap(
|
|
1783
|
+
this._addToDialCodeMap(e.iso2, e.dialCode + n);
|
|
1766
1784
|
}
|
|
1767
1785
|
}
|
|
1768
1786
|
}
|
|
1769
1787
|
}
|
|
1770
1788
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1771
1789
|
_generateMarkup() {
|
|
1772
|
-
var
|
|
1790
|
+
var h, m, b;
|
|
1773
1791
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
1774
1792
|
const {
|
|
1775
|
-
allowDropdown:
|
|
1776
|
-
separateDialCode:
|
|
1793
|
+
allowDropdown: t,
|
|
1794
|
+
separateDialCode: e,
|
|
1777
1795
|
showFlags: i,
|
|
1778
1796
|
containerClass: s,
|
|
1779
1797
|
hiddenInput: n,
|
|
1780
1798
|
dropdownContainer: o,
|
|
1781
|
-
fixDropdownWidth:
|
|
1782
|
-
useFullscreenPopup:
|
|
1783
|
-
countrySearch:
|
|
1784
|
-
i18n:
|
|
1799
|
+
fixDropdownWidth: r,
|
|
1800
|
+
useFullscreenPopup: a,
|
|
1801
|
+
countrySearch: c,
|
|
1802
|
+
i18n: d
|
|
1785
1803
|
} = this.options;
|
|
1786
|
-
let
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
if ((
|
|
1804
|
+
let C = "iti";
|
|
1805
|
+
t && (C += " iti--allow-dropdown"), i && (C += " iti--show-flags"), s && (C += ` ${s}`), a || (C += " iti--inline-dropdown");
|
|
1806
|
+
const p = y("div", { class: C });
|
|
1807
|
+
if ((h = this.telInput.parentNode) == null || h.insertBefore(p, this.telInput), t || i || e) {
|
|
1790
1808
|
this.countryContainer = y(
|
|
1791
1809
|
"div",
|
|
1792
1810
|
{ class: "iti__country-container" },
|
|
1793
|
-
|
|
1794
|
-
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px",
|
|
1811
|
+
p
|
|
1812
|
+
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = y(
|
|
1795
1813
|
"button",
|
|
1796
1814
|
{
|
|
1797
1815
|
type: "button",
|
|
@@ -1813,28 +1831,28 @@ class G {
|
|
|
1813
1831
|
"span",
|
|
1814
1832
|
{ class: "iti__a11y-text" },
|
|
1815
1833
|
this.selectedCountryInner
|
|
1816
|
-
),
|
|
1834
|
+
), t && (this.dropdownArrow = y(
|
|
1817
1835
|
"div",
|
|
1818
1836
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1819
1837
|
_
|
|
1820
|
-
)),
|
|
1838
|
+
)), e && (this.selectedDialCode = y(
|
|
1821
1839
|
"div",
|
|
1822
1840
|
{ class: "iti__selected-dial-code" },
|
|
1823
1841
|
this.selectedCountry
|
|
1824
|
-
)),
|
|
1825
|
-
const f =
|
|
1842
|
+
)), t) {
|
|
1843
|
+
const f = r ? "" : "iti--flexible-dropdown-width";
|
|
1826
1844
|
if (this.dropdownContent = y("div", {
|
|
1827
1845
|
id: `iti-${this.id}__dropdown-content`,
|
|
1828
1846
|
class: `iti__dropdown-content iti__hide ${f}`
|
|
1829
|
-
}),
|
|
1847
|
+
}), c && (this.searchInput = y(
|
|
1830
1848
|
"input",
|
|
1831
1849
|
{
|
|
1832
1850
|
type: "text",
|
|
1833
1851
|
class: "iti__search-input",
|
|
1834
|
-
placeholder:
|
|
1852
|
+
placeholder: d.searchPlaceholder,
|
|
1835
1853
|
role: "combobox",
|
|
1836
1854
|
"aria-expanded": "true",
|
|
1837
|
-
"aria-label":
|
|
1855
|
+
"aria-label": d.searchPlaceholder,
|
|
1838
1856
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1839
1857
|
"aria-autocomplete": "list",
|
|
1840
1858
|
autocomplete: "off"
|
|
@@ -1850,65 +1868,65 @@ class G {
|
|
|
1850
1868
|
class: "iti__country-list",
|
|
1851
1869
|
id: `iti-${this.id}__country-listbox`,
|
|
1852
1870
|
role: "listbox",
|
|
1853
|
-
"aria-label":
|
|
1871
|
+
"aria-label": d.countryListAriaLabel
|
|
1854
1872
|
},
|
|
1855
1873
|
this.dropdownContent
|
|
1856
|
-
), this._appendListItems(),
|
|
1874
|
+
), this._appendListItems(), c && this._updateSearchResultsText(), o) {
|
|
1857
1875
|
let g = "iti iti--container";
|
|
1858
|
-
|
|
1876
|
+
a ? g += " iti--fullscreen-popup" : g += " iti--inline-dropdown", this.dropdown = y("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
|
|
1859
1877
|
} else
|
|
1860
1878
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1861
1879
|
}
|
|
1862
1880
|
}
|
|
1863
|
-
if (
|
|
1881
|
+
if (p.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1864
1882
|
const _ = this.telInput.getAttribute("name") || "", f = n(_);
|
|
1865
1883
|
if (f.phone) {
|
|
1866
1884
|
const g = (m = this.telInput.form) == null ? void 0 : m.querySelector(`input[name="${f.phone}"]`);
|
|
1867
1885
|
g ? this.hiddenInput = g : (this.hiddenInput = y("input", {
|
|
1868
1886
|
type: "hidden",
|
|
1869
1887
|
name: f.phone
|
|
1870
|
-
}),
|
|
1888
|
+
}), p.appendChild(this.hiddenInput));
|
|
1871
1889
|
}
|
|
1872
1890
|
if (f.country) {
|
|
1873
1891
|
const g = (b = this.telInput.form) == null ? void 0 : b.querySelector(`input[name="${f.country}"]`);
|
|
1874
1892
|
g ? this.hiddenInputCountry = g : (this.hiddenInputCountry = y("input", {
|
|
1875
1893
|
type: "hidden",
|
|
1876
1894
|
name: f.country
|
|
1877
|
-
}),
|
|
1895
|
+
}), p.appendChild(this.hiddenInputCountry));
|
|
1878
1896
|
}
|
|
1879
1897
|
}
|
|
1880
1898
|
}
|
|
1881
1899
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1882
1900
|
_appendListItems() {
|
|
1883
|
-
for (let
|
|
1884
|
-
const
|
|
1901
|
+
for (let t = 0; t < this.countries.length; t++) {
|
|
1902
|
+
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = y(
|
|
1885
1903
|
"li",
|
|
1886
1904
|
{
|
|
1887
|
-
id: `iti-${this.id}__item-${
|
|
1905
|
+
id: `iti-${this.id}__item-${e.iso2}`,
|
|
1888
1906
|
class: `iti__country ${i}`,
|
|
1889
1907
|
tabindex: "-1",
|
|
1890
1908
|
role: "option",
|
|
1891
|
-
"data-dial-code":
|
|
1892
|
-
"data-country-code":
|
|
1909
|
+
"data-dial-code": e.dialCode,
|
|
1910
|
+
"data-country-code": e.iso2,
|
|
1893
1911
|
"aria-selected": "false"
|
|
1894
1912
|
},
|
|
1895
1913
|
this.countryList
|
|
1896
1914
|
);
|
|
1897
|
-
|
|
1915
|
+
e.nodeById[this.id] = s;
|
|
1898
1916
|
let n = "";
|
|
1899
|
-
this.options.showFlags && (n += `<div class='iti__flag iti__${
|
|
1917
|
+
this.options.showFlags && (n += `<div class='iti__flag iti__${e.iso2}'></div>`), n += `<span class='iti__country-name'>${e.name}</span>`, n += `<span class='iti__dial-code'>+${e.dialCode}</span>`, s.insertAdjacentHTML("beforeend", n);
|
|
1900
1918
|
}
|
|
1901
1919
|
}
|
|
1902
1920
|
//* Set the initial state of the input value and the selected country by:
|
|
1903
1921
|
//* 1. Extracting a dial code from the given number
|
|
1904
1922
|
//* 2. Using explicit initialCountry
|
|
1905
|
-
_setInitialState(
|
|
1906
|
-
const
|
|
1907
|
-
if (o && !
|
|
1923
|
+
_setInitialState(t = !1) {
|
|
1924
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), r = S(n), { initialCountry: a, geoIpLookup: c } = this.options, d = a === "auto" && c;
|
|
1925
|
+
if (o && !r)
|
|
1908
1926
|
this._updateCountryFromNumber(n);
|
|
1909
|
-
else if (!
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1927
|
+
else if (!d || t) {
|
|
1928
|
+
const C = a ? a.toLowerCase() : "";
|
|
1929
|
+
C && this._getCountryData(C, !0) ? this._setCountry(C) : o && r ? this._setCountry("us") : this._setCountry();
|
|
1912
1930
|
}
|
|
1913
1931
|
n && this._updateValFromNumber(n);
|
|
1914
1932
|
}
|
|
@@ -1918,24 +1936,24 @@ class G {
|
|
|
1918
1936
|
}
|
|
1919
1937
|
//* Update hidden input on form submit.
|
|
1920
1938
|
_initHiddenInputListener() {
|
|
1921
|
-
var
|
|
1939
|
+
var t;
|
|
1922
1940
|
this._handleHiddenInputSubmit = () => {
|
|
1923
1941
|
this.hiddenInput && (this.hiddenInput.value = this.getNumber()), this.hiddenInputCountry && (this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "");
|
|
1924
|
-
}, (
|
|
1942
|
+
}, (t = this.telInput.form) == null || t.addEventListener(
|
|
1925
1943
|
"submit",
|
|
1926
1944
|
this._handleHiddenInputSubmit
|
|
1927
1945
|
);
|
|
1928
1946
|
}
|
|
1929
1947
|
//* initialise the dropdown listeners.
|
|
1930
1948
|
_initDropdownListeners() {
|
|
1931
|
-
this._handleLabelClick = (
|
|
1932
|
-
this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() :
|
|
1949
|
+
this._handleLabelClick = (e) => {
|
|
1950
|
+
this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() : e.preventDefault();
|
|
1933
1951
|
};
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1952
|
+
const t = this.telInput.closest("label");
|
|
1953
|
+
t && t.addEventListener("click", this._handleLabelClick), this._handleClickSelectedCountry = () => {
|
|
1936
1954
|
this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly && this._openDropdown();
|
|
1937
|
-
}, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (
|
|
1938
|
-
this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(
|
|
1955
|
+
}, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (e) => {
|
|
1956
|
+
this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key) && (e.preventDefault(), e.stopPropagation(), this._openDropdown()), e.key === "Tab" && this._closeDropdown();
|
|
1939
1957
|
}, this.countryContainer.addEventListener(
|
|
1940
1958
|
"keydown",
|
|
1941
1959
|
this._handleCountryContainerKeydown
|
|
@@ -1943,19 +1961,19 @@ class G {
|
|
|
1943
1961
|
}
|
|
1944
1962
|
//* Init many requests: utils script / geo ip lookup.
|
|
1945
1963
|
_initRequests() {
|
|
1946
|
-
let { loadUtils:
|
|
1947
|
-
|
|
1964
|
+
let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
|
|
1965
|
+
t && !l.utils ? (this._handlePageLoad = () => {
|
|
1948
1966
|
var n;
|
|
1949
|
-
window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(
|
|
1967
|
+
window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(t)) == null || n.catch(() => {
|
|
1950
1968
|
});
|
|
1951
|
-
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(),
|
|
1969
|
+
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
1952
1970
|
}
|
|
1953
1971
|
//* Perform the geo ip lookup.
|
|
1954
1972
|
_loadAutoCountry() {
|
|
1955
1973
|
l.autoCountry ? this.handleAutoCountry() : l.startedLoadingAutoCountry || (l.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
1956
|
-
(
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1974
|
+
(t = "") => {
|
|
1975
|
+
const e = t.toLowerCase();
|
|
1976
|
+
e && this._getCountryData(e, !0) ? (l.autoCountry = e, setTimeout(() => w("handleAutoCountry"))) : (this._setInitialState(!0), w("rejectAutoCountryPromise"));
|
|
1959
1977
|
},
|
|
1960
1978
|
() => {
|
|
1961
1979
|
this._setInitialState(!0), w("rejectAutoCountryPromise");
|
|
@@ -1967,58 +1985,58 @@ class G {
|
|
|
1967
1985
|
}
|
|
1968
1986
|
//* Initialize the tel input listeners.
|
|
1969
1987
|
_initTelInputListeners() {
|
|
1970
|
-
const { strictMode:
|
|
1971
|
-
let
|
|
1972
|
-
new RegExp("\\p{L}", "u").test(this.telInput.value) && (
|
|
1973
|
-
if (this.isAndroid && (
|
|
1974
|
-
const
|
|
1975
|
-
this.telInput.value =
|
|
1988
|
+
const { strictMode: t, formatAsYouType: e, separateDialCode: i, formatOnDisplay: s, allowDropdown: n, countrySearch: o } = this.options;
|
|
1989
|
+
let r = !1;
|
|
1990
|
+
new RegExp("\\p{L}", "u").test(this.telInput.value) && (r = !0), this._handleInputEvent = (a) => {
|
|
1991
|
+
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && n && o) {
|
|
1992
|
+
const p = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, p - 1), m = this.telInput.value.substring(p);
|
|
1993
|
+
this.telInput.value = h + m, this._openDropdownWithPlus();
|
|
1976
1994
|
return;
|
|
1977
1995
|
}
|
|
1978
1996
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1981
|
-
const
|
|
1982
|
-
if (
|
|
1983
|
-
const
|
|
1997
|
+
const c = (a == null ? void 0 : a.data) && /[^+0-9]/.test(a.data), d = (a == null ? void 0 : a.inputType) === "insertFromPaste" && this.telInput.value;
|
|
1998
|
+
c || d && !t ? r = !0 : /[^+0-9]/.test(this.telInput.value) || (r = !1);
|
|
1999
|
+
const C = (a == null ? void 0 : a.detail) && a.detail.isSetNumber && !s;
|
|
2000
|
+
if (e && !r && !C) {
|
|
2001
|
+
const p = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, p).replace(/[^+0-9]/g, "").length, b = (a == null ? void 0 : a.inputType) === "deleteContentForward", _ = this._formatNumberAsYouType(), f = K(m, _, p, b);
|
|
1984
2002
|
this.telInput.value = _, this.telInput.setSelectionRange(f, f);
|
|
1985
2003
|
}
|
|
1986
|
-
}, this.telInput.addEventListener("input", this._handleInputEvent), (
|
|
1987
|
-
if (
|
|
1988
|
-
if (i && n && o &&
|
|
1989
|
-
|
|
2004
|
+
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (a) => {
|
|
2005
|
+
if (a.key && a.key.length === 1 && !a.altKey && !a.ctrlKey && !a.metaKey) {
|
|
2006
|
+
if (i && n && o && a.key === "+") {
|
|
2007
|
+
a.preventDefault(), this._openDropdownWithPlus();
|
|
1990
2008
|
return;
|
|
1991
2009
|
}
|
|
1992
|
-
if (
|
|
1993
|
-
const
|
|
2010
|
+
if (t) {
|
|
2011
|
+
const c = this.telInput.value, d = c.charAt(0) === "+", C = !d && this.telInput.selectionStart === 0 && a.key === "+", p = /^[0-9]$/.test(a.key), h = i ? p : C || p, m = c.slice(0, this.telInput.selectionStart) + a.key + c.slice(this.telInput.selectionEnd), b = this._getFullNumber(m), _ = l.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength;
|
|
1994
2012
|
let g = !1;
|
|
1995
|
-
if (
|
|
2013
|
+
if (d) {
|
|
1996
2014
|
const P = this.selectedCountryData.iso2;
|
|
1997
2015
|
g = this._getCountryFromNumber(b) !== P;
|
|
1998
2016
|
}
|
|
1999
|
-
(!
|
|
2017
|
+
(!h || f && !g && !C) && a.preventDefault();
|
|
2000
2018
|
}
|
|
2001
2019
|
}
|
|
2002
2020
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
2003
2021
|
}
|
|
2004
2022
|
//* Adhere to the input's maxlength attr.
|
|
2005
|
-
_cap(
|
|
2006
|
-
const
|
|
2007
|
-
return
|
|
2023
|
+
_cap(t) {
|
|
2024
|
+
const e = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
2025
|
+
return e && t.length > e ? t.substr(0, e) : t;
|
|
2008
2026
|
}
|
|
2009
2027
|
//* Trigger a custom event on the input.
|
|
2010
|
-
_trigger(
|
|
2011
|
-
const i = new CustomEvent(
|
|
2028
|
+
_trigger(t, e = {}) {
|
|
2029
|
+
const i = new CustomEvent(t, {
|
|
2012
2030
|
bubbles: !0,
|
|
2013
2031
|
cancelable: !0,
|
|
2014
|
-
detail:
|
|
2032
|
+
detail: e
|
|
2015
2033
|
});
|
|
2016
2034
|
this.telInput.dispatchEvent(i);
|
|
2017
2035
|
}
|
|
2018
2036
|
//* Open the dropdown.
|
|
2019
2037
|
_openDropdown() {
|
|
2020
|
-
const { fixDropdownWidth:
|
|
2021
|
-
if (
|
|
2038
|
+
const { fixDropdownWidth: t, countrySearch: e } = this.options;
|
|
2039
|
+
if (t && (this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`), this.dropdownContent.classList.remove("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), e) {
|
|
2022
2040
|
const i = this.countryList.firstElementChild;
|
|
2023
2041
|
i && (this._highlightListItem(i, !1), this.countryList.scrollTop = 0), this.searchInput.focus();
|
|
2024
2042
|
}
|
|
@@ -2027,8 +2045,8 @@ class G {
|
|
|
2027
2045
|
//* Set the dropdown position
|
|
2028
2046
|
_setDropdownPosition() {
|
|
2029
2047
|
if (this.options.dropdownContainer && this.options.dropdownContainer.appendChild(this.dropdown), !this.options.useFullscreenPopup) {
|
|
2030
|
-
const
|
|
2031
|
-
this.options.dropdownContainer && (this.dropdown.style.top = `${
|
|
2048
|
+
const t = this.telInput.getBoundingClientRect(), e = this.telInput.offsetHeight;
|
|
2049
|
+
this.options.dropdownContainer && (this.dropdown.style.top = `${t.top + e}px`, this.dropdown.style.left = `${t.left}px`, this._handleWindowScroll = () => this._closeDropdown(), window.addEventListener("scroll", this._handleWindowScroll));
|
|
2032
2050
|
}
|
|
2033
2051
|
}
|
|
2034
2052
|
//* We only bind dropdown listeners when the dropdown is open.
|
|
@@ -2045,17 +2063,17 @@ class G {
|
|
|
2045
2063
|
const n = (o = s.target) == null ? void 0 : o.closest(".iti__country");
|
|
2046
2064
|
n && this._selectListItem(n);
|
|
2047
2065
|
}, this.countryList.addEventListener("click", this._handleClickCountryList);
|
|
2048
|
-
let
|
|
2066
|
+
let t = !0;
|
|
2049
2067
|
this._handleClickOffToClose = () => {
|
|
2050
|
-
|
|
2068
|
+
t || this._closeDropdown(), t = !1;
|
|
2051
2069
|
}, document.documentElement.addEventListener(
|
|
2052
2070
|
"click",
|
|
2053
2071
|
this._handleClickOffToClose
|
|
2054
2072
|
);
|
|
2055
|
-
let
|
|
2073
|
+
let e = "", i = null;
|
|
2056
2074
|
if (this._handleKeydownOnDropdown = (s) => {
|
|
2057
|
-
["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(s.key) && (s.preventDefault(), s.stopPropagation(), s.key === "ArrowUp" || s.key === "ArrowDown" ? this._handleUpDownKey(s.key) : s.key === "Enter" ? this._handleEnterKey() : s.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(s.key) && (s.stopPropagation(), i && clearTimeout(i),
|
|
2058
|
-
|
|
2075
|
+
["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(s.key) && (s.preventDefault(), s.stopPropagation(), s.key === "ArrowUp" || s.key === "ArrowDown" ? this._handleUpDownKey(s.key) : s.key === "Enter" ? this._handleEnterKey() : s.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(s.key) && (s.stopPropagation(), i && clearTimeout(i), e += s.key.toLowerCase(), this._searchForCountry(e), i = setTimeout(() => {
|
|
2076
|
+
e = "";
|
|
2059
2077
|
}, 1e3));
|
|
2060
2078
|
}, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
|
|
2061
2079
|
const s = () => {
|
|
@@ -2071,10 +2089,10 @@ class G {
|
|
|
2071
2089
|
}
|
|
2072
2090
|
}
|
|
2073
2091
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2074
|
-
_searchForCountry(
|
|
2075
|
-
for (let
|
|
2076
|
-
const i = this.countries[
|
|
2077
|
-
if (i.name.substr(0,
|
|
2092
|
+
_searchForCountry(t) {
|
|
2093
|
+
for (let e = 0; e < this.countries.length; e++) {
|
|
2094
|
+
const i = this.countries[e];
|
|
2095
|
+
if (i.name.substr(0, t.length).toLowerCase() === t) {
|
|
2078
2096
|
const n = i.nodeById[this.id];
|
|
2079
2097
|
this._highlightListItem(n, !1), this._scrollTo(n);
|
|
2080
2098
|
break;
|
|
@@ -2082,30 +2100,30 @@ class G {
|
|
|
2082
2100
|
}
|
|
2083
2101
|
}
|
|
2084
2102
|
//* Country search enabled: Filter the countries according to the search query.
|
|
2085
|
-
_filterCountries(
|
|
2103
|
+
_filterCountries(t, e = !1) {
|
|
2086
2104
|
let i = !0;
|
|
2087
2105
|
this.countryList.innerHTML = "";
|
|
2088
|
-
const s =
|
|
2106
|
+
const s = A(t);
|
|
2089
2107
|
for (let n = 0; n < this.countries.length; n++) {
|
|
2090
|
-
const o = this.countries[n],
|
|
2091
|
-
if (
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2108
|
+
const o = this.countries[n], r = A(o.name), a = o.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((d) => d[0]).join("").toLowerCase(), c = `+${o.dialCode}`;
|
|
2109
|
+
if (e || r.includes(s) || c.includes(s) || o.iso2.includes(s) || a.includes(s)) {
|
|
2110
|
+
const d = o.nodeById[this.id];
|
|
2111
|
+
d && this.countryList.appendChild(d), i && (this._highlightListItem(d, !1), i = !1);
|
|
2094
2112
|
}
|
|
2095
2113
|
}
|
|
2096
2114
|
i && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
|
|
2097
2115
|
}
|
|
2098
2116
|
//* Update search results text (for a11y).
|
|
2099
2117
|
_updateSearchResultsText() {
|
|
2100
|
-
const { i18n:
|
|
2118
|
+
const { i18n: t } = this.options, e = this.countryList.childElementCount;
|
|
2101
2119
|
let i;
|
|
2102
|
-
|
|
2120
|
+
e === 0 ? i = t.zeroSearchResults : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace("${count}", e.toString()), this.searchResultsA11yText.textContent = i;
|
|
2103
2121
|
}
|
|
2104
2122
|
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2105
|
-
_handleUpDownKey(
|
|
2123
|
+
_handleUpDownKey(t) {
|
|
2106
2124
|
var i, s;
|
|
2107
|
-
let
|
|
2108
|
-
!
|
|
2125
|
+
let e = t === "ArrowUp" ? (i = this.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.highlightedItem) == null ? void 0 : s.nextElementSibling;
|
|
2126
|
+
!e && this.countryList.childElementCount > 1 && (e = t === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild), e && (this._scrollTo(e), this._highlightListItem(e, !1));
|
|
2109
2127
|
}
|
|
2110
2128
|
//* Select the currently highlighted item.
|
|
2111
2129
|
_handleEnterKey() {
|
|
@@ -2113,45 +2131,53 @@ class G {
|
|
|
2113
2131
|
}
|
|
2114
2132
|
//* Update the input's value to the given val (format first if possible)
|
|
2115
2133
|
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2116
|
-
_updateValFromNumber(
|
|
2117
|
-
let
|
|
2134
|
+
_updateValFromNumber(t) {
|
|
2135
|
+
let e = t;
|
|
2118
2136
|
if (this.options.formatOnDisplay && l.utils && this.selectedCountryData) {
|
|
2119
|
-
const i = this.options.nationalMode ||
|
|
2120
|
-
|
|
2121
|
-
|
|
2137
|
+
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, o = i ? s : n;
|
|
2138
|
+
e = l.utils.formatNumber(
|
|
2139
|
+
e,
|
|
2122
2140
|
this.selectedCountryData.iso2,
|
|
2123
2141
|
o
|
|
2124
2142
|
);
|
|
2125
2143
|
}
|
|
2126
|
-
|
|
2144
|
+
e = this._beforeSetNumber(e), this.telInput.value = e;
|
|
2127
2145
|
}
|
|
2128
2146
|
//* Check if need to select a new country based on the given number
|
|
2129
2147
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2130
|
-
_updateCountryFromNumber(
|
|
2131
|
-
const
|
|
2132
|
-
return
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
const
|
|
2148
|
+
_updateCountryFromNumber(t) {
|
|
2149
|
+
const e = this._getCountryFromNumber(t);
|
|
2150
|
+
return e !== null ? this._setCountry(e) : !1;
|
|
2151
|
+
}
|
|
2152
|
+
_ensureHasDialCode(t) {
|
|
2153
|
+
const { dialCode: e, nationalPrefix: i } = this.selectedCountryData;
|
|
2154
|
+
if (t.charAt(0) === "+" || !e)
|
|
2155
|
+
return t;
|
|
2156
|
+
const o = i && t.charAt(0) === i && !this.options.separateDialCode ? t.substring(1) : t;
|
|
2157
|
+
return `+${e}${o}`;
|
|
2158
|
+
}
|
|
2159
|
+
_getCountryFromNumber(t) {
|
|
2160
|
+
const e = t.indexOf("+");
|
|
2161
|
+
let i = e ? t.substring(e) : t;
|
|
2162
|
+
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2163
|
+
i = this._ensureHasDialCode(i);
|
|
2164
|
+
const o = this._getDialCode(i, !0);
|
|
2165
|
+
if (o && o === this.prevDialCodeMatch)
|
|
2166
|
+
return null;
|
|
2167
|
+
this.prevDialCodeMatch = o;
|
|
2168
|
+
const r = v(i);
|
|
2145
2169
|
if (o) {
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2170
|
+
const a = v(o), c = this.dialCodeToIso2Map[a];
|
|
2171
|
+
if (!s && this.defaultCountry && c.includes(this.defaultCountry))
|
|
2172
|
+
return this.defaultCountry;
|
|
2173
|
+
const d = s && c.includes(s) && r.length === a.length;
|
|
2174
|
+
if (!(n === "1" && S(r)) && !d) {
|
|
2175
|
+
for (let p = 0; p < c.length; p++)
|
|
2176
|
+
if (c[p])
|
|
2177
|
+
return c[p];
|
|
2152
2178
|
}
|
|
2153
2179
|
} else {
|
|
2154
|
-
if (i.charAt(0) === "+" &&
|
|
2180
|
+
if (i.charAt(0) === "+" && r.length)
|
|
2155
2181
|
return "";
|
|
2156
2182
|
if ((!i || i === "+") && !this.selectedCountryData.iso2)
|
|
2157
2183
|
return this.defaultCountry;
|
|
@@ -2159,70 +2185,70 @@ class G {
|
|
|
2159
2185
|
return null;
|
|
2160
2186
|
}
|
|
2161
2187
|
//* Remove highlighting from other list items and highlight the given item.
|
|
2162
|
-
_highlightListItem(
|
|
2188
|
+
_highlightListItem(t, e) {
|
|
2163
2189
|
const i = this.highlightedItem;
|
|
2164
|
-
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem =
|
|
2190
|
+
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem) {
|
|
2165
2191
|
this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2166
2192
|
const s = this.highlightedItem.getAttribute("id") || "";
|
|
2167
2193
|
this.selectedCountry.setAttribute("aria-activedescendant", s), this.options.countrySearch && this.searchInput.setAttribute("aria-activedescendant", s);
|
|
2168
2194
|
}
|
|
2169
|
-
|
|
2195
|
+
e && this.highlightedItem.focus();
|
|
2170
2196
|
}
|
|
2171
2197
|
//* Find the country data for the given iso2 code
|
|
2172
2198
|
//* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
|
|
2173
|
-
_getCountryData(
|
|
2199
|
+
_getCountryData(t, e) {
|
|
2174
2200
|
for (let i = 0; i < this.countries.length; i++)
|
|
2175
|
-
if (this.countries[i].iso2 ===
|
|
2201
|
+
if (this.countries[i].iso2 === t)
|
|
2176
2202
|
return this.countries[i];
|
|
2177
|
-
if (
|
|
2203
|
+
if (e)
|
|
2178
2204
|
return null;
|
|
2179
|
-
throw new Error(`No country data for '${
|
|
2205
|
+
throw new Error(`No country data for '${t}'`);
|
|
2180
2206
|
}
|
|
2181
2207
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
|
|
2182
2208
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
2183
|
-
_setCountry(
|
|
2184
|
-
const { separateDialCode:
|
|
2185
|
-
if (this.selectedCountryData =
|
|
2186
|
-
let o = "",
|
|
2187
|
-
|
|
2209
|
+
_setCountry(t) {
|
|
2210
|
+
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2211
|
+
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountryInner) {
|
|
2212
|
+
let o = "", r = "";
|
|
2213
|
+
t && i ? (o = `iti__flag iti__${t}`, r = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`) : (o = "iti__flag iti__globe", r = s.noCountrySelected), this.selectedCountryInner.className = o, this.selectedCountryA11yText.textContent = r;
|
|
2188
2214
|
}
|
|
2189
|
-
if (this._setSelectedCountryTitleAttribute(
|
|
2215
|
+
if (this._setSelectedCountryTitleAttribute(t, e), e) {
|
|
2190
2216
|
const o = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2191
2217
|
this.selectedDialCode.innerHTML = o, this._updateInputPadding();
|
|
2192
2218
|
}
|
|
2193
|
-
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !==
|
|
2219
|
+
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== t;
|
|
2194
2220
|
}
|
|
2195
2221
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2196
2222
|
_updateInputPadding() {
|
|
2197
2223
|
if (this.selectedCountry) {
|
|
2198
|
-
const
|
|
2199
|
-
this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${
|
|
2224
|
+
const e = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 6;
|
|
2225
|
+
this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${e}px` : this.telInput.style.paddingRight = `${e}px`;
|
|
2200
2226
|
}
|
|
2201
2227
|
}
|
|
2202
2228
|
//* Update the maximum valid number length for the currently selected country.
|
|
2203
2229
|
_updateMaxLength() {
|
|
2204
|
-
const { strictMode:
|
|
2205
|
-
if (
|
|
2230
|
+
const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2231
|
+
if (t && l.utils)
|
|
2206
2232
|
if (s) {
|
|
2207
|
-
const n = l.utils.numberType[
|
|
2233
|
+
const n = l.utils.numberType[e];
|
|
2208
2234
|
let o = l.utils.getExampleNumber(
|
|
2209
2235
|
s,
|
|
2210
2236
|
!1,
|
|
2211
2237
|
n,
|
|
2212
2238
|
!0
|
|
2213
|
-
),
|
|
2239
|
+
), r = o;
|
|
2214
2240
|
for (; l.utils.isPossibleNumber(o, s, i); )
|
|
2215
|
-
|
|
2216
|
-
const
|
|
2217
|
-
this.maxCoreNumberLength =
|
|
2241
|
+
r = o, o += "0";
|
|
2242
|
+
const a = l.utils.getCoreNumber(r, s);
|
|
2243
|
+
this.maxCoreNumberLength = a.length, s === "by" && (this.maxCoreNumberLength = a.length + 1);
|
|
2218
2244
|
} else
|
|
2219
2245
|
this.maxCoreNumberLength = null;
|
|
2220
2246
|
}
|
|
2221
|
-
_setSelectedCountryTitleAttribute(
|
|
2247
|
+
_setSelectedCountryTitleAttribute(t = null, e) {
|
|
2222
2248
|
if (!this.selectedCountry)
|
|
2223
2249
|
return;
|
|
2224
2250
|
let i;
|
|
2225
|
-
|
|
2251
|
+
t && !e ? i = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : t ? i = this.selectedCountryData.name : i = "Unknown", this.selectedCountry.setAttribute("title", i);
|
|
2226
2252
|
}
|
|
2227
2253
|
//* When the input is in a hidden container during initialisation, we must inject some markup
|
|
2228
2254
|
//* into the end of the DOM to calculate the correct offsetWidth.
|
|
@@ -2230,41 +2256,41 @@ class G {
|
|
|
2230
2256
|
//* will definitely exist.
|
|
2231
2257
|
_getHiddenSelectedCountryWidth() {
|
|
2232
2258
|
if (this.telInput.parentNode) {
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2259
|
+
const t = this.telInput.parentNode.cloneNode(!1);
|
|
2260
|
+
t.style.visibility = "hidden", document.body.appendChild(t);
|
|
2261
|
+
const e = this.countryContainer.cloneNode();
|
|
2262
|
+
t.appendChild(e);
|
|
2237
2263
|
const i = this.selectedCountry.cloneNode(!0);
|
|
2238
|
-
|
|
2264
|
+
e.appendChild(i);
|
|
2239
2265
|
const s = i.offsetWidth;
|
|
2240
|
-
return document.body.removeChild(
|
|
2266
|
+
return document.body.removeChild(t), s;
|
|
2241
2267
|
}
|
|
2242
2268
|
return 0;
|
|
2243
2269
|
}
|
|
2244
2270
|
//* Update the input placeholder to an example number from the currently selected country.
|
|
2245
2271
|
_updatePlaceholder() {
|
|
2246
2272
|
const {
|
|
2247
|
-
autoPlaceholder:
|
|
2248
|
-
placeholderNumberType:
|
|
2273
|
+
autoPlaceholder: t,
|
|
2274
|
+
placeholderNumberType: e,
|
|
2249
2275
|
nationalMode: i,
|
|
2250
2276
|
customPlaceholder: s
|
|
2251
|
-
} = this.options, n =
|
|
2277
|
+
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2252
2278
|
if (l.utils && n) {
|
|
2253
|
-
const o = l.utils.numberType[
|
|
2254
|
-
let
|
|
2279
|
+
const o = l.utils.numberType[e];
|
|
2280
|
+
let r = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
|
|
2255
2281
|
this.selectedCountryData.iso2,
|
|
2256
2282
|
i,
|
|
2257
2283
|
o
|
|
2258
2284
|
) : "";
|
|
2259
|
-
|
|
2285
|
+
r = this._beforeSetNumber(r), typeof s == "function" && (r = s(r, this.selectedCountryData)), this.telInput.setAttribute("placeholder", r);
|
|
2260
2286
|
}
|
|
2261
2287
|
}
|
|
2262
2288
|
//* Called when the user selects a list item from the dropdown.
|
|
2263
|
-
_selectListItem(
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2289
|
+
_selectListItem(t) {
|
|
2290
|
+
const e = this._setCountry(
|
|
2291
|
+
t.getAttribute("data-country-code")
|
|
2266
2292
|
);
|
|
2267
|
-
this._closeDropdown(), this._updateDialCode(
|
|
2293
|
+
this._closeDropdown(), this._updateDialCode(t.getAttribute("data-dial-code")), this.telInput.focus(), e && this._triggerCountryChange();
|
|
2268
2294
|
}
|
|
2269
2295
|
//* Close the dropdown and unbind any listeners.
|
|
2270
2296
|
_closeDropdown() {
|
|
@@ -2277,38 +2303,38 @@ class G {
|
|
|
2277
2303
|
), this.countryList.removeEventListener("click", this._handleClickCountryList), this.options.dropdownContainer && (this.options.useFullscreenPopup || window.removeEventListener("scroll", this._handleWindowScroll), this.dropdown.parentNode && this.dropdown.parentNode.removeChild(this.dropdown)), this._handlePageLoad && window.removeEventListener("load", this._handlePageLoad), this._trigger("close:countrydropdown");
|
|
2278
2304
|
}
|
|
2279
2305
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2280
|
-
_scrollTo(
|
|
2281
|
-
const
|
|
2282
|
-
if (
|
|
2283
|
-
|
|
2284
|
-
else if (
|
|
2285
|
-
const
|
|
2286
|
-
|
|
2306
|
+
_scrollTo(t) {
|
|
2307
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, r = t.offsetHeight, a = t.getBoundingClientRect().top + i, c = a + r, d = a - n + e.scrollTop;
|
|
2308
|
+
if (a < n)
|
|
2309
|
+
e.scrollTop = d;
|
|
2310
|
+
else if (c > o) {
|
|
2311
|
+
const C = s - r;
|
|
2312
|
+
e.scrollTop = d - C;
|
|
2287
2313
|
}
|
|
2288
2314
|
}
|
|
2289
2315
|
//* Replace any existing dial code with the new one
|
|
2290
2316
|
//* Note: called from _selectListItem and setCountry
|
|
2291
|
-
_updateDialCode(
|
|
2292
|
-
const
|
|
2317
|
+
_updateDialCode(t) {
|
|
2318
|
+
const e = this.telInput.value, i = `+${t}`;
|
|
2293
2319
|
let s;
|
|
2294
|
-
if (
|
|
2295
|
-
const n = this._getDialCode(
|
|
2296
|
-
n ? s =
|
|
2320
|
+
if (e.charAt(0) === "+") {
|
|
2321
|
+
const n = this._getDialCode(e);
|
|
2322
|
+
n ? s = e.replace(n, i) : s = i, this.telInput.value = s;
|
|
2297
2323
|
}
|
|
2298
2324
|
}
|
|
2299
2325
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
2300
2326
|
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
2301
|
-
_getDialCode(
|
|
2327
|
+
_getDialCode(t, e) {
|
|
2302
2328
|
let i = "";
|
|
2303
|
-
if (
|
|
2329
|
+
if (t.charAt(0) === "+") {
|
|
2304
2330
|
let s = "";
|
|
2305
|
-
for (let n = 0; n <
|
|
2306
|
-
const o =
|
|
2331
|
+
for (let n = 0; n < t.length; n++) {
|
|
2332
|
+
const o = t.charAt(n);
|
|
2307
2333
|
if (!isNaN(parseInt(o, 10))) {
|
|
2308
|
-
if (s += o,
|
|
2309
|
-
this.dialCodeToIso2Map[s] && (i =
|
|
2334
|
+
if (s += o, e)
|
|
2335
|
+
this.dialCodeToIso2Map[s] && (i = t.substr(0, n + 1));
|
|
2310
2336
|
else if (this.dialCodes[s]) {
|
|
2311
|
-
i =
|
|
2337
|
+
i = t.substr(0, n + 1);
|
|
2312
2338
|
break;
|
|
2313
2339
|
}
|
|
2314
2340
|
if (s.length === this.dialCodeMaxLen)
|
|
@@ -2319,24 +2345,24 @@ class G {
|
|
|
2319
2345
|
return i;
|
|
2320
2346
|
}
|
|
2321
2347
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
2322
|
-
_getFullNumber(
|
|
2323
|
-
const
|
|
2348
|
+
_getFullNumber(t) {
|
|
2349
|
+
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2324
2350
|
let s;
|
|
2325
|
-
const n = v(
|
|
2326
|
-
return this.options.separateDialCode &&
|
|
2351
|
+
const n = v(e);
|
|
2352
|
+
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2327
2353
|
}
|
|
2328
2354
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
2329
|
-
_beforeSetNumber(
|
|
2330
|
-
let
|
|
2355
|
+
_beforeSetNumber(t) {
|
|
2356
|
+
let e = t;
|
|
2331
2357
|
if (this.options.separateDialCode) {
|
|
2332
|
-
let i = this._getDialCode(
|
|
2358
|
+
let i = this._getDialCode(e);
|
|
2333
2359
|
if (i) {
|
|
2334
2360
|
i = `+${this.selectedCountryData.dialCode}`;
|
|
2335
|
-
const s =
|
|
2336
|
-
|
|
2361
|
+
const s = e[i.length] === " " || e[i.length] === "-" ? i.length + 1 : i.length;
|
|
2362
|
+
e = e.substr(s);
|
|
2337
2363
|
}
|
|
2338
2364
|
}
|
|
2339
|
-
return this._cap(
|
|
2365
|
+
return this._cap(e);
|
|
2340
2366
|
}
|
|
2341
2367
|
//* Trigger the 'countrychange' event.
|
|
2342
2368
|
_triggerCountryChange() {
|
|
@@ -2344,8 +2370,8 @@ class G {
|
|
|
2344
2370
|
}
|
|
2345
2371
|
//* Format the number as the user types.
|
|
2346
2372
|
_formatNumberAsYouType() {
|
|
2347
|
-
const
|
|
2348
|
-
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" &&
|
|
2373
|
+
const t = this._getFullNumber(), e = l.utils ? l.utils.formatNumberAsYouType(t, this.selectedCountryData.iso2) : t, { dialCode: i } = this.selectedCountryData;
|
|
2374
|
+
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
|
|
2349
2375
|
}
|
|
2350
2376
|
//**************************
|
|
2351
2377
|
//* SECRET PUBLIC METHODS
|
|
@@ -2364,8 +2390,8 @@ class G {
|
|
|
2364
2390
|
//* Remove plugin.
|
|
2365
2391
|
destroy() {
|
|
2366
2392
|
var n, o;
|
|
2367
|
-
const { allowDropdown:
|
|
2368
|
-
if (
|
|
2393
|
+
const { allowDropdown: t, separateDialCode: e } = this.options;
|
|
2394
|
+
if (t) {
|
|
2369
2395
|
this._closeDropdown(), this.selectedCountry.removeEventListener(
|
|
2370
2396
|
"click",
|
|
2371
2397
|
this._handleClickSelectedCountry
|
|
@@ -2373,11 +2399,11 @@ class G {
|
|
|
2373
2399
|
"keydown",
|
|
2374
2400
|
this._handleCountryContainerKeydown
|
|
2375
2401
|
);
|
|
2376
|
-
const
|
|
2377
|
-
|
|
2402
|
+
const r = this.telInput.closest("label");
|
|
2403
|
+
r && r.removeEventListener("click", this._handleLabelClick);
|
|
2378
2404
|
}
|
|
2379
2405
|
const { form: i } = this.telInput;
|
|
2380
|
-
this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this.telInput.removeAttribute("data-intl-tel-input-id"),
|
|
2406
|
+
this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this.telInput.removeAttribute("data-intl-tel-input-id"), e && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
|
|
2381
2407
|
const s = this.telInput.parentNode;
|
|
2382
2408
|
(n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (o = s == null ? void 0 : s.parentNode) == null || o.removeChild(s), delete l.instances[this.id];
|
|
2383
2409
|
}
|
|
@@ -2389,13 +2415,13 @@ class G {
|
|
|
2389
2415
|
) : "";
|
|
2390
2416
|
}
|
|
2391
2417
|
//* Format the number to the given format.
|
|
2392
|
-
getNumber(
|
|
2418
|
+
getNumber(t) {
|
|
2393
2419
|
if (l.utils) {
|
|
2394
|
-
const { iso2:
|
|
2420
|
+
const { iso2: e } = this.selectedCountryData;
|
|
2395
2421
|
return l.utils.formatNumber(
|
|
2396
2422
|
this._getFullNumber(),
|
|
2397
|
-
|
|
2398
|
-
|
|
2423
|
+
e,
|
|
2424
|
+
t
|
|
2399
2425
|
);
|
|
2400
2426
|
}
|
|
2401
2427
|
return "";
|
|
@@ -2414,8 +2440,8 @@ class G {
|
|
|
2414
2440
|
//* Get the validation error.
|
|
2415
2441
|
getValidationError() {
|
|
2416
2442
|
if (l.utils) {
|
|
2417
|
-
const { iso2:
|
|
2418
|
-
return l.utils.getValidationError(this._getFullNumber(),
|
|
2443
|
+
const { iso2: t } = this.selectedCountryData;
|
|
2444
|
+
return l.utils.getValidationError(this._getFullNumber(), t);
|
|
2419
2445
|
}
|
|
2420
2446
|
return -99;
|
|
2421
2447
|
}
|
|
@@ -2423,73 +2449,73 @@ class G {
|
|
|
2423
2449
|
isValidNumber() {
|
|
2424
2450
|
if (!this.selectedCountryData.iso2)
|
|
2425
2451
|
return !1;
|
|
2426
|
-
const
|
|
2427
|
-
if (
|
|
2428
|
-
const i =
|
|
2452
|
+
const t = this._getFullNumber(), e = t.search(new RegExp("\\p{L}", "u"));
|
|
2453
|
+
if (e > -1) {
|
|
2454
|
+
const i = t.substring(0, e), s = this._utilsIsPossibleNumber(i), n = this._utilsIsPossibleNumber(t);
|
|
2429
2455
|
return s && n;
|
|
2430
2456
|
}
|
|
2431
|
-
return this._utilsIsPossibleNumber(
|
|
2457
|
+
return this._utilsIsPossibleNumber(t);
|
|
2432
2458
|
}
|
|
2433
|
-
_utilsIsPossibleNumber(
|
|
2434
|
-
return l.utils ? l.utils.isPossibleNumber(
|
|
2459
|
+
_utilsIsPossibleNumber(t) {
|
|
2460
|
+
return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2435
2461
|
}
|
|
2436
2462
|
//* Validate the input val (precise)
|
|
2437
2463
|
isValidNumberPrecise() {
|
|
2438
2464
|
if (!this.selectedCountryData.iso2)
|
|
2439
2465
|
return !1;
|
|
2440
|
-
const
|
|
2441
|
-
if (
|
|
2442
|
-
const i =
|
|
2466
|
+
const t = this._getFullNumber(), e = t.search(new RegExp("\\p{L}", "u"));
|
|
2467
|
+
if (e > -1) {
|
|
2468
|
+
const i = t.substring(0, e), s = this._utilsIsValidNumber(i), n = this._utilsIsValidNumber(t);
|
|
2443
2469
|
return s && n;
|
|
2444
2470
|
}
|
|
2445
|
-
return this._utilsIsValidNumber(
|
|
2471
|
+
return this._utilsIsValidNumber(t);
|
|
2446
2472
|
}
|
|
2447
|
-
_utilsIsValidNumber(
|
|
2448
|
-
return l.utils ? l.utils.isValidNumber(
|
|
2473
|
+
_utilsIsValidNumber(t) {
|
|
2474
|
+
return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2449
2475
|
}
|
|
2450
2476
|
//* Update the selected country, and update the input val accordingly.
|
|
2451
|
-
setCountry(
|
|
2452
|
-
const
|
|
2453
|
-
(
|
|
2477
|
+
setCountry(t) {
|
|
2478
|
+
const e = t == null ? void 0 : t.toLowerCase(), i = this.selectedCountryData.iso2;
|
|
2479
|
+
(t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this._triggerCountryChange());
|
|
2454
2480
|
}
|
|
2455
2481
|
//* Set the input value and update the country.
|
|
2456
|
-
setNumber(
|
|
2457
|
-
const
|
|
2458
|
-
this._updateValFromNumber(
|
|
2482
|
+
setNumber(t) {
|
|
2483
|
+
const e = this._updateCountryFromNumber(t);
|
|
2484
|
+
this._updateValFromNumber(t), e && this._triggerCountryChange(), this._trigger("input", { isSetNumber: !0 });
|
|
2459
2485
|
}
|
|
2460
2486
|
//* Set the placeholder number typ
|
|
2461
|
-
setPlaceholderNumberType(
|
|
2462
|
-
this.options.placeholderNumberType =
|
|
2487
|
+
setPlaceholderNumberType(t) {
|
|
2488
|
+
this.options.placeholderNumberType = t, this._updatePlaceholder();
|
|
2463
2489
|
}
|
|
2464
|
-
setDisabled(
|
|
2465
|
-
this.telInput.disabled =
|
|
2490
|
+
setDisabled(t) {
|
|
2491
|
+
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2466
2492
|
}
|
|
2467
2493
|
}
|
|
2468
2494
|
const W = (u) => {
|
|
2469
2495
|
if (!l.utils && !l.startedLoadingUtilsScript) {
|
|
2470
|
-
let
|
|
2496
|
+
let t;
|
|
2471
2497
|
if (typeof u == "function")
|
|
2472
2498
|
try {
|
|
2473
|
-
|
|
2474
|
-
} catch (
|
|
2475
|
-
return Promise.reject(
|
|
2499
|
+
t = Promise.resolve(u());
|
|
2500
|
+
} catch (e) {
|
|
2501
|
+
return Promise.reject(e);
|
|
2476
2502
|
}
|
|
2477
2503
|
else
|
|
2478
2504
|
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof u}`));
|
|
2479
|
-
return l.startedLoadingUtilsScript = !0,
|
|
2480
|
-
const i =
|
|
2505
|
+
return l.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2506
|
+
const i = e == null ? void 0 : e.default;
|
|
2481
2507
|
if (!i || typeof i != "object")
|
|
2482
2508
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2483
2509
|
return l.utils = i, w("handleUtils"), !0;
|
|
2484
|
-
}).catch((
|
|
2485
|
-
throw w("rejectUtilsScriptPromise",
|
|
2510
|
+
}).catch((e) => {
|
|
2511
|
+
throw w("rejectUtilsScriptPromise", e), e;
|
|
2486
2512
|
});
|
|
2487
2513
|
}
|
|
2488
2514
|
return null;
|
|
2489
2515
|
}, l = Object.assign(
|
|
2490
|
-
(u,
|
|
2491
|
-
const
|
|
2492
|
-
return
|
|
2516
|
+
(u, t) => {
|
|
2517
|
+
const e = new G(u, t);
|
|
2518
|
+
return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, e;
|
|
2493
2519
|
},
|
|
2494
2520
|
{
|
|
2495
2521
|
defaults: T,
|
|
@@ -2499,15 +2525,15 @@ const W = (u) => {
|
|
|
2499
2525
|
getCountryData: () => I,
|
|
2500
2526
|
//* A getter for the plugin instance.
|
|
2501
2527
|
getInstance: (u) => {
|
|
2502
|
-
const
|
|
2503
|
-
return
|
|
2528
|
+
const t = u.getAttribute("data-intl-tel-input-id");
|
|
2529
|
+
return t ? l.instances[t] : null;
|
|
2504
2530
|
},
|
|
2505
2531
|
//* A map from instance ID to instance object.
|
|
2506
2532
|
instances: {},
|
|
2507
2533
|
attachUtils: W,
|
|
2508
2534
|
startedLoadingUtilsScript: !1,
|
|
2509
2535
|
startedLoadingAutoCountry: !1,
|
|
2510
|
-
version: "25.0
|
|
2536
|
+
version: "25.1.0"
|
|
2511
2537
|
}
|
|
2512
2538
|
), J = {
|
|
2513
2539
|
__name: "IntlTelInput",
|
|
@@ -2541,38 +2567,38 @@ const W = (u) => {
|
|
|
2541
2567
|
"changeValidity",
|
|
2542
2568
|
"changeErrorCode"
|
|
2543
2569
|
], ["update:modelValue"]),
|
|
2544
|
-
setup(u, { expose:
|
|
2545
|
-
const i = x(u, "modelValue"), s = u, n =
|
|
2546
|
-
let
|
|
2547
|
-
|
|
2570
|
+
setup(u, { expose: t, emit: e }) {
|
|
2571
|
+
const i = x(u, "modelValue"), s = u, n = e, o = L(), r = L(), a = L(!1), c = () => r.value ? s.options.strictMode ? r.value.isValidNumberPrecise() : r.value.isValidNumber() : null, d = () => {
|
|
2572
|
+
let h = c();
|
|
2573
|
+
a.value !== h && (a.value = h, n("changeValidity", !!h), n(
|
|
2548
2574
|
"changeErrorCode",
|
|
2549
|
-
|
|
2575
|
+
h ? null : r.value.getValidationError()
|
|
2550
2576
|
));
|
|
2551
|
-
}, c = () => {
|
|
2552
|
-
var d;
|
|
2553
|
-
n("changeNumber", ((d = a.value) == null ? void 0 : d.getNumber()) ?? ""), h();
|
|
2554
2577
|
}, C = () => {
|
|
2555
|
-
var
|
|
2556
|
-
n("
|
|
2578
|
+
var h;
|
|
2579
|
+
n("changeNumber", ((h = r.value) == null ? void 0 : h.getNumber()) ?? ""), d();
|
|
2580
|
+
}, p = () => {
|
|
2581
|
+
var h;
|
|
2582
|
+
n("changeCountry", ((h = r.value) == null ? void 0 : h.getSelectedCountryData().iso2) ?? ""), C(), d();
|
|
2557
2583
|
};
|
|
2558
2584
|
return E(() => {
|
|
2559
|
-
o.value && (
|
|
2585
|
+
o.value && (r.value = l(o.value, s.options), s.value && r.value.setNumber(s.value), s.disabled && r.value.setDisabled(s.disabled));
|
|
2560
2586
|
}), M(
|
|
2561
2587
|
() => s.disabled,
|
|
2562
|
-
(
|
|
2588
|
+
(h) => {
|
|
2563
2589
|
var m;
|
|
2564
|
-
return (m =
|
|
2590
|
+
return (m = r.value) == null ? void 0 : m.setDisabled(h);
|
|
2565
2591
|
}
|
|
2566
2592
|
), F(() => {
|
|
2567
|
-
var
|
|
2568
|
-
return (
|
|
2569
|
-
}),
|
|
2593
|
+
var h;
|
|
2594
|
+
return (h = r.value) == null ? void 0 : h.destroy();
|
|
2595
|
+
}), t({ instance: r, input: o }), (h, m) => B((V(), O("input", z({
|
|
2570
2596
|
ref_key: "input",
|
|
2571
2597
|
ref: o,
|
|
2572
2598
|
"onUpdate:modelValue": m[0] || (m[0] = (b) => i.value = b),
|
|
2573
2599
|
type: "tel",
|
|
2574
|
-
onCountrychange:
|
|
2575
|
-
onInput:
|
|
2600
|
+
onCountrychange: p,
|
|
2601
|
+
onInput: C
|
|
2576
2602
|
}, u.inputProps), null, 16)), [
|
|
2577
2603
|
[R, i.value]
|
|
2578
2604
|
]);
|