intl-tel-input 25.0.0 → 25.0.2
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 +9 -9
- package/build/js/data.js +3 -3
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +5 -1
- package/build/js/intlTelInput.js +58 -19
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +58 -19
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +57 -18
- package/react/build/IntlTelInput.d.ts +5 -1
- package/react/build/IntlTelInput.js +57 -18
- package/react/build/IntlTelInputWithUtils.cjs +57 -18
- package/react/build/IntlTelInputWithUtils.js +57 -18
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +327 -314
- package/vue/build/IntlTelInputWithUtils.mjs +450 -437
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as D, useModel as x, ref as
|
|
2
|
-
const
|
|
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 A = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -9,8 +9,7 @@ const N = [
|
|
|
9
9
|
"ax",
|
|
10
10
|
// Åland Islands
|
|
11
11
|
"358",
|
|
12
|
-
1
|
|
13
|
-
["18"]
|
|
12
|
+
1
|
|
14
13
|
],
|
|
15
14
|
[
|
|
16
15
|
"al",
|
|
@@ -1305,16 +1304,17 @@ const N = [
|
|
|
1305
1304
|
// Zimbabwe
|
|
1306
1305
|
"263"
|
|
1307
1306
|
]
|
|
1308
|
-
],
|
|
1309
|
-
for (let u = 0; u <
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1307
|
+
], I = [];
|
|
1308
|
+
for (let u = 0; u < A.length; u++) {
|
|
1309
|
+
const e = A[u];
|
|
1310
|
+
I[u] = {
|
|
1312
1311
|
name: "",
|
|
1313
1312
|
// this is now populated in the plugin
|
|
1314
|
-
iso2:
|
|
1315
|
-
dialCode:
|
|
1316
|
-
priority:
|
|
1317
|
-
areaCodes:
|
|
1313
|
+
iso2: e[0],
|
|
1314
|
+
dialCode: e[1],
|
|
1315
|
+
priority: e[2] || 0,
|
|
1316
|
+
areaCodes: e[3] || null,
|
|
1317
|
+
partialAreaCodes: null,
|
|
1318
1318
|
nodeById: {}
|
|
1319
1319
|
};
|
|
1320
1320
|
}
|
|
@@ -1573,8 +1573,8 @@ const j = {
|
|
|
1573
1573
|
ac: "Ascension Island",
|
|
1574
1574
|
xk: "Kosovo"
|
|
1575
1575
|
}, k = { ...j, ...$ };
|
|
1576
|
-
for (let u = 0; u <
|
|
1577
|
-
|
|
1576
|
+
for (let u = 0; u < I.length; u++)
|
|
1577
|
+
I[u].name = k[I[u].iso2];
|
|
1578
1578
|
let U = 0;
|
|
1579
1579
|
const T = {
|
|
1580
1580
|
//* Whether or not to allow the dropdown.
|
|
@@ -1649,46 +1649,46 @@ const T = {
|
|
|
1649
1649
|
"887",
|
|
1650
1650
|
"888",
|
|
1651
1651
|
"889"
|
|
1652
|
-
],
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1655
|
-
const
|
|
1656
|
-
return K.indexOf(
|
|
1652
|
+
], v = (u) => u.replace(/\D/g, ""), N = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
|
|
1653
|
+
const e = v(u);
|
|
1654
|
+
if (e.charAt(0) === "1") {
|
|
1655
|
+
const t = e.substr(1, 3);
|
|
1656
|
+
return K.indexOf(t) !== -1;
|
|
1657
1657
|
}
|
|
1658
1658
|
return !1;
|
|
1659
|
-
}, H = (u,
|
|
1660
|
-
if (
|
|
1659
|
+
}, H = (u, e, t, i) => {
|
|
1660
|
+
if (t === 0 && !i)
|
|
1661
1661
|
return 0;
|
|
1662
1662
|
let s = 0;
|
|
1663
|
-
for (let n = 0; n <
|
|
1664
|
-
if (/[+0-9]/.test(
|
|
1663
|
+
for (let n = 0; n < e.length; n++) {
|
|
1664
|
+
if (/[+0-9]/.test(e[n]) && s++, s === u && !i)
|
|
1665
1665
|
return n + 1;
|
|
1666
1666
|
if (i && s === u + 1)
|
|
1667
1667
|
return n;
|
|
1668
1668
|
}
|
|
1669
|
-
return
|
|
1670
|
-
}, y = (u,
|
|
1669
|
+
return e.length;
|
|
1670
|
+
}, y = (u, e, t) => {
|
|
1671
1671
|
const i = document.createElement(u);
|
|
1672
|
-
return
|
|
1673
|
-
},
|
|
1674
|
-
const { instances:
|
|
1675
|
-
Object.values(
|
|
1672
|
+
return e && Object.entries(e).forEach(([s, n]) => i.setAttribute(s, n)), t && t.appendChild(i), i;
|
|
1673
|
+
}, w = (u, ...e) => {
|
|
1674
|
+
const { instances: t } = l;
|
|
1675
|
+
Object.values(t).forEach((i) => i[u](...e));
|
|
1676
1676
|
};
|
|
1677
1677
|
class G {
|
|
1678
|
-
constructor(
|
|
1679
|
-
this.id = U++, this.telInput =
|
|
1678
|
+
constructor(e, t = {}) {
|
|
1679
|
+
this.id = U++, this.telInput = e, this.highlightedItem = null, this.options = Object.assign({}, T, t), this.hadInitialPlaceholder = !!e.getAttribute("placeholder");
|
|
1680
1680
|
}
|
|
1681
1681
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1682
1682
|
_init() {
|
|
1683
1683
|
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
|
|
1684
|
+
const e = this.options.allowDropdown || this.options.separateDialCode;
|
|
1685
|
+
this.showSelectedCountryOnLeft = this.isRTL ? !e : e, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...k, ...this.options.i18n };
|
|
1686
|
+
const t = new Promise((s, n) => {
|
|
1687
1687
|
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
|
|
1688
1688
|
}), i = new Promise((s, n) => {
|
|
1689
1689
|
this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = n;
|
|
1690
1690
|
});
|
|
1691
|
-
this.promise = Promise.all([
|
|
1691
|
+
this.promise = Promise.all([t, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests();
|
|
1692
1692
|
}
|
|
1693
1693
|
//********************
|
|
1694
1694
|
//* PRIVATE METHODS
|
|
@@ -1699,81 +1699,81 @@ class G {
|
|
|
1699
1699
|
}
|
|
1700
1700
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1701
1701
|
_sortCountries() {
|
|
1702
|
-
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((
|
|
1702
|
+
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((e) => e.toLowerCase())), this.countries.sort((e, t) => {
|
|
1703
1703
|
const { countryOrder: i } = this.options;
|
|
1704
1704
|
if (i) {
|
|
1705
|
-
const s = i.indexOf(
|
|
1705
|
+
const s = i.indexOf(e.iso2), n = i.indexOf(t.iso2), o = s > -1, a = n > -1;
|
|
1706
1706
|
if (o || a)
|
|
1707
1707
|
return o && a ? s - n : o ? -1 : 1;
|
|
1708
1708
|
}
|
|
1709
|
-
return
|
|
1709
|
+
return e.name.localeCompare(t.name);
|
|
1710
1710
|
});
|
|
1711
1711
|
}
|
|
1712
1712
|
//* Add a dial code to this.dialCodeToIso2Map.
|
|
1713
|
-
_addToDialCodeMap(
|
|
1714
|
-
|
|
1715
|
-
for (let n = 0; n < this.dialCodeToIso2Map[
|
|
1716
|
-
if (this.dialCodeToIso2Map[
|
|
1713
|
+
_addToDialCodeMap(e, t, i) {
|
|
1714
|
+
t.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = t.length), this.dialCodeToIso2Map.hasOwnProperty(t) || (this.dialCodeToIso2Map[t] = []);
|
|
1715
|
+
for (let n = 0; n < this.dialCodeToIso2Map[t].length; n++)
|
|
1716
|
+
if (this.dialCodeToIso2Map[t][n] === e)
|
|
1717
1717
|
return;
|
|
1718
|
-
const s = i !== void 0 ? i : this.dialCodeToIso2Map[
|
|
1719
|
-
this.dialCodeToIso2Map[
|
|
1718
|
+
const s = i !== void 0 ? i : this.dialCodeToIso2Map[t].length;
|
|
1719
|
+
this.dialCodeToIso2Map[t][s] = e;
|
|
1720
1720
|
}
|
|
1721
1721
|
//* Process onlyCountries or excludeCountries array if present.
|
|
1722
1722
|
_processAllCountries() {
|
|
1723
|
-
const { onlyCountries:
|
|
1724
|
-
if (
|
|
1725
|
-
const i =
|
|
1723
|
+
const { onlyCountries: e, excludeCountries: t } = this.options;
|
|
1724
|
+
if (e.length) {
|
|
1725
|
+
const i = e.map(
|
|
1726
1726
|
(s) => s.toLowerCase()
|
|
1727
1727
|
);
|
|
1728
|
-
this.countries =
|
|
1728
|
+
this.countries = I.filter(
|
|
1729
1729
|
(s) => i.indexOf(s.iso2) > -1
|
|
1730
1730
|
);
|
|
1731
|
-
} else if (
|
|
1732
|
-
const i =
|
|
1731
|
+
} else if (t.length) {
|
|
1732
|
+
const i = t.map(
|
|
1733
1733
|
(s) => s.toLowerCase()
|
|
1734
1734
|
);
|
|
1735
|
-
this.countries =
|
|
1735
|
+
this.countries = I.filter(
|
|
1736
1736
|
(s) => i.indexOf(s.iso2) === -1
|
|
1737
1737
|
);
|
|
1738
1738
|
} else
|
|
1739
|
-
this.countries =
|
|
1739
|
+
this.countries = I;
|
|
1740
1740
|
}
|
|
1741
1741
|
//* Translate Countries by object literal provided on config.
|
|
1742
1742
|
_translateCountryNames() {
|
|
1743
|
-
for (let
|
|
1744
|
-
const
|
|
1745
|
-
this.options.i18n.hasOwnProperty(
|
|
1743
|
+
for (let e = 0; e < this.countries.length; e++) {
|
|
1744
|
+
const t = this.countries[e].iso2.toLowerCase();
|
|
1745
|
+
this.options.i18n.hasOwnProperty(t) && (this.countries[e].name = this.options.i18n[t]);
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
|
-
//* Generate this.dialCodes and this.dialCodeToIso2Map.
|
|
1748
|
+
//* Generate this.dialCodes and this.dialCodeToIso2Map and country.partialAreaCodes.
|
|
1749
1749
|
_processDialCodes() {
|
|
1750
1750
|
this.dialCodes = {}, this.dialCodeMaxLen = 0, this.dialCodeToIso2Map = {};
|
|
1751
|
-
for (let
|
|
1752
|
-
const
|
|
1753
|
-
this.dialCodes[
|
|
1751
|
+
for (let e = 0; e < this.countries.length; e++) {
|
|
1752
|
+
const t = this.countries[e];
|
|
1753
|
+
this.dialCodes[t.dialCode] || (this.dialCodes[t.dialCode] = !0), this._addToDialCodeMap(t.iso2, t.dialCode, t.priority);
|
|
1754
1754
|
}
|
|
1755
|
-
for (let
|
|
1756
|
-
const
|
|
1757
|
-
if (
|
|
1758
|
-
const i = this.dialCodeToIso2Map[
|
|
1759
|
-
for (let s = 0; s <
|
|
1760
|
-
const n =
|
|
1755
|
+
for (let e = 0; e < this.countries.length; e++) {
|
|
1756
|
+
const t = this.countries[e];
|
|
1757
|
+
if (t.areaCodes) {
|
|
1758
|
+
const i = this.dialCodeToIso2Map[t.dialCode][0];
|
|
1759
|
+
for (let s = 0; s < t.areaCodes.length; s++) {
|
|
1760
|
+
const n = t.areaCodes[s];
|
|
1761
1761
|
for (let o = 1; o < n.length; o++) {
|
|
1762
|
-
const a =
|
|
1763
|
-
this._addToDialCodeMap(i,
|
|
1762
|
+
const a = n.substr(0, o), r = t.dialCode + a;
|
|
1763
|
+
this._addToDialCodeMap(i, r), this._addToDialCodeMap(t.iso2, r), t.partialAreaCodes || (t.partialAreaCodes = []), t.partialAreaCodes.includes(a) || t.partialAreaCodes.push(a);
|
|
1764
1764
|
}
|
|
1765
|
-
this._addToDialCodeMap(
|
|
1765
|
+
this._addToDialCodeMap(t.iso2, t.dialCode + n);
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
1769
|
}
|
|
1770
1770
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1771
1771
|
_generateMarkup() {
|
|
1772
|
-
var
|
|
1772
|
+
var d, m, b;
|
|
1773
1773
|
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
1774
|
const {
|
|
1775
|
-
allowDropdown:
|
|
1776
|
-
separateDialCode:
|
|
1775
|
+
allowDropdown: e,
|
|
1776
|
+
separateDialCode: t,
|
|
1777
1777
|
showFlags: i,
|
|
1778
1778
|
containerClass: s,
|
|
1779
1779
|
hiddenInput: n,
|
|
@@ -1781,17 +1781,17 @@ class G {
|
|
|
1781
1781
|
fixDropdownWidth: a,
|
|
1782
1782
|
useFullscreenPopup: r,
|
|
1783
1783
|
countrySearch: p,
|
|
1784
|
-
i18n:
|
|
1784
|
+
i18n: h
|
|
1785
1785
|
} = this.options;
|
|
1786
|
-
let
|
|
1787
|
-
|
|
1788
|
-
const C = y("div", { class:
|
|
1789
|
-
if ((
|
|
1786
|
+
let c = "iti";
|
|
1787
|
+
e && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), r || (c += " iti--inline-dropdown");
|
|
1788
|
+
const C = y("div", { class: c });
|
|
1789
|
+
if ((d = this.telInput.parentNode) == null || d.insertBefore(C, this.telInput), e || i || t) {
|
|
1790
1790
|
this.countryContainer = y(
|
|
1791
1791
|
"div",
|
|
1792
1792
|
{ class: "iti__country-container" },
|
|
1793
1793
|
C
|
|
1794
|
-
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px",
|
|
1794
|
+
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", e ? (this.selectedCountry = y(
|
|
1795
1795
|
"button",
|
|
1796
1796
|
{
|
|
1797
1797
|
type: "button",
|
|
@@ -1808,20 +1808,20 @@ class G {
|
|
|
1808
1808
|
{ class: "iti__selected-country" },
|
|
1809
1809
|
this.countryContainer
|
|
1810
1810
|
);
|
|
1811
|
-
const
|
|
1812
|
-
if (this.selectedCountryInner = y("div", { class: "iti__flag" },
|
|
1811
|
+
const _ = y("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
|
|
1812
|
+
if (this.selectedCountryInner = y("div", { class: "iti__flag" }, _), this.selectedCountryA11yText = y(
|
|
1813
1813
|
"span",
|
|
1814
1814
|
{ class: "iti__a11y-text" },
|
|
1815
1815
|
this.selectedCountryInner
|
|
1816
|
-
),
|
|
1816
|
+
), e && (this.dropdownArrow = y(
|
|
1817
1817
|
"div",
|
|
1818
1818
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1819
|
-
|
|
1820
|
-
)),
|
|
1819
|
+
_
|
|
1820
|
+
)), t && (this.selectedDialCode = y(
|
|
1821
1821
|
"div",
|
|
1822
1822
|
{ class: "iti__selected-dial-code" },
|
|
1823
1823
|
this.selectedCountry
|
|
1824
|
-
)),
|
|
1824
|
+
)), e) {
|
|
1825
1825
|
const f = a ? "" : "iti--flexible-dropdown-width";
|
|
1826
1826
|
if (this.dropdownContent = y("div", {
|
|
1827
1827
|
id: `iti-${this.id}__dropdown-content`,
|
|
@@ -1831,10 +1831,10 @@ class G {
|
|
|
1831
1831
|
{
|
|
1832
1832
|
type: "text",
|
|
1833
1833
|
class: "iti__search-input",
|
|
1834
|
-
placeholder:
|
|
1834
|
+
placeholder: h.searchPlaceholder,
|
|
1835
1835
|
role: "combobox",
|
|
1836
1836
|
"aria-expanded": "true",
|
|
1837
|
-
"aria-label":
|
|
1837
|
+
"aria-label": h.searchPlaceholder,
|
|
1838
1838
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1839
1839
|
"aria-autocomplete": "list",
|
|
1840
1840
|
autocomplete: "off"
|
|
@@ -1850,7 +1850,7 @@ class G {
|
|
|
1850
1850
|
class: "iti__country-list",
|
|
1851
1851
|
id: `iti-${this.id}__country-listbox`,
|
|
1852
1852
|
role: "listbox",
|
|
1853
|
-
"aria-label":
|
|
1853
|
+
"aria-label": h.countryListAriaLabel
|
|
1854
1854
|
},
|
|
1855
1855
|
this.dropdownContent
|
|
1856
1856
|
), this._appendListItems(), p && this._updateSearchResultsText(), o) {
|
|
@@ -1861,47 +1861,54 @@ class G {
|
|
|
1861
1861
|
}
|
|
1862
1862
|
}
|
|
1863
1863
|
if (C.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1864
|
-
const
|
|
1865
|
-
f.phone
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1864
|
+
const _ = this.telInput.getAttribute("name") || "", f = n(_);
|
|
1865
|
+
if (f.phone) {
|
|
1866
|
+
const g = (m = this.telInput.form) == null ? void 0 : m.querySelector(`input[name="${f.phone}"]`);
|
|
1867
|
+
g ? this.hiddenInput = g : (this.hiddenInput = y("input", {
|
|
1868
|
+
type: "hidden",
|
|
1869
|
+
name: f.phone
|
|
1870
|
+
}), C.appendChild(this.hiddenInput));
|
|
1871
|
+
}
|
|
1872
|
+
if (f.country) {
|
|
1873
|
+
const g = (b = this.telInput.form) == null ? void 0 : b.querySelector(`input[name="${f.country}"]`);
|
|
1874
|
+
g ? this.hiddenInputCountry = g : (this.hiddenInputCountry = y("input", {
|
|
1875
|
+
type: "hidden",
|
|
1876
|
+
name: f.country
|
|
1877
|
+
}), C.appendChild(this.hiddenInputCountry));
|
|
1878
|
+
}
|
|
1872
1879
|
}
|
|
1873
1880
|
}
|
|
1874
1881
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1875
1882
|
_appendListItems() {
|
|
1876
|
-
for (let
|
|
1877
|
-
const
|
|
1883
|
+
for (let e = 0; e < this.countries.length; e++) {
|
|
1884
|
+
const t = this.countries[e], i = e === 0 ? "iti__highlight" : "", s = y(
|
|
1878
1885
|
"li",
|
|
1879
1886
|
{
|
|
1880
|
-
id: `iti-${this.id}__item-${
|
|
1887
|
+
id: `iti-${this.id}__item-${t.iso2}`,
|
|
1881
1888
|
class: `iti__country ${i}`,
|
|
1882
1889
|
tabindex: "-1",
|
|
1883
1890
|
role: "option",
|
|
1884
|
-
"data-dial-code":
|
|
1885
|
-
"data-country-code":
|
|
1891
|
+
"data-dial-code": t.dialCode,
|
|
1892
|
+
"data-country-code": t.iso2,
|
|
1886
1893
|
"aria-selected": "false"
|
|
1887
1894
|
},
|
|
1888
1895
|
this.countryList
|
|
1889
1896
|
);
|
|
1890
|
-
|
|
1897
|
+
t.nodeById[this.id] = s;
|
|
1891
1898
|
let n = "";
|
|
1892
|
-
this.options.showFlags && (n += `<div class='iti__flag iti__${
|
|
1899
|
+
this.options.showFlags && (n += `<div class='iti__flag iti__${t.iso2}'></div>`), n += `<span class='iti__country-name'>${t.name}</span>`, n += `<span class='iti__dial-code'>+${t.dialCode}</span>`, s.insertAdjacentHTML("beforeend", n);
|
|
1893
1900
|
}
|
|
1894
1901
|
}
|
|
1895
1902
|
//* Set the initial state of the input value and the selected country by:
|
|
1896
1903
|
//* 1. Extracting a dial code from the given number
|
|
1897
1904
|
//* 2. Using explicit initialCountry
|
|
1898
|
-
_setInitialState(
|
|
1899
|
-
const
|
|
1905
|
+
_setInitialState(e = !1) {
|
|
1906
|
+
const t = this.telInput.getAttribute("value"), i = this.telInput.value, n = t && t.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? t : i, o = this._getDialCode(n), a = S(n), { initialCountry: r, geoIpLookup: p } = this.options, h = r === "auto" && p;
|
|
1900
1907
|
if (o && !a)
|
|
1901
1908
|
this._updateCountryFromNumber(n);
|
|
1902
|
-
else if (!
|
|
1903
|
-
const
|
|
1904
|
-
|
|
1909
|
+
else if (!h || e) {
|
|
1910
|
+
const c = r ? r.toLowerCase() : "";
|
|
1911
|
+
c && this._getCountryData(c, !0) ? this._setCountry(c) : o && a ? this._setCountry("us") : this._setCountry();
|
|
1905
1912
|
}
|
|
1906
1913
|
n && this._updateValFromNumber(n);
|
|
1907
1914
|
}
|
|
@@ -1911,24 +1918,24 @@ class G {
|
|
|
1911
1918
|
}
|
|
1912
1919
|
//* Update hidden input on form submit.
|
|
1913
1920
|
_initHiddenInputListener() {
|
|
1914
|
-
var
|
|
1921
|
+
var e;
|
|
1915
1922
|
this._handleHiddenInputSubmit = () => {
|
|
1916
1923
|
this.hiddenInput && (this.hiddenInput.value = this.getNumber()), this.hiddenInputCountry && (this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "");
|
|
1917
|
-
}, (
|
|
1924
|
+
}, (e = this.telInput.form) == null || e.addEventListener(
|
|
1918
1925
|
"submit",
|
|
1919
1926
|
this._handleHiddenInputSubmit
|
|
1920
1927
|
);
|
|
1921
1928
|
}
|
|
1922
1929
|
//* initialise the dropdown listeners.
|
|
1923
1930
|
_initDropdownListeners() {
|
|
1924
|
-
this._handleLabelClick = (
|
|
1925
|
-
this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() :
|
|
1931
|
+
this._handleLabelClick = (t) => {
|
|
1932
|
+
this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() : t.preventDefault();
|
|
1926
1933
|
};
|
|
1927
|
-
const
|
|
1928
|
-
|
|
1934
|
+
const e = this.telInput.closest("label");
|
|
1935
|
+
e && e.addEventListener("click", this._handleLabelClick), this._handleClickSelectedCountry = () => {
|
|
1929
1936
|
this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly && this._openDropdown();
|
|
1930
|
-
}, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (
|
|
1931
|
-
this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(
|
|
1937
|
+
}, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (t) => {
|
|
1938
|
+
this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(t.key) && (t.preventDefault(), t.stopPropagation(), this._openDropdown()), t.key === "Tab" && this._closeDropdown();
|
|
1932
1939
|
}, this.countryContainer.addEventListener(
|
|
1933
1940
|
"keydown",
|
|
1934
1941
|
this._handleCountryContainerKeydown
|
|
@@ -1936,22 +1943,22 @@ class G {
|
|
|
1936
1943
|
}
|
|
1937
1944
|
//* Init many requests: utils script / geo ip lookup.
|
|
1938
1945
|
_initRequests() {
|
|
1939
|
-
let { loadUtils:
|
|
1940
|
-
|
|
1946
|
+
let { loadUtils: e, initialCountry: t, geoIpLookup: i } = this.options;
|
|
1947
|
+
e && !l.utils ? (this._handlePageLoad = () => {
|
|
1941
1948
|
var n;
|
|
1942
|
-
window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(
|
|
1949
|
+
window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(e)) == null || n.catch(() => {
|
|
1943
1950
|
});
|
|
1944
|
-
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(),
|
|
1951
|
+
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), t === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
1945
1952
|
}
|
|
1946
1953
|
//* Perform the geo ip lookup.
|
|
1947
1954
|
_loadAutoCountry() {
|
|
1948
1955
|
l.autoCountry ? this.handleAutoCountry() : l.startedLoadingAutoCountry || (l.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
1949
|
-
(
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1956
|
+
(e = "") => {
|
|
1957
|
+
const t = e.toLowerCase();
|
|
1958
|
+
t && this._getCountryData(t, !0) ? (l.autoCountry = t, setTimeout(() => w("handleAutoCountry"))) : (this._setInitialState(!0), w("rejectAutoCountryPromise"));
|
|
1952
1959
|
},
|
|
1953
1960
|
() => {
|
|
1954
|
-
this._setInitialState(!0),
|
|
1961
|
+
this._setInitialState(!0), w("rejectAutoCountryPromise");
|
|
1955
1962
|
}
|
|
1956
1963
|
));
|
|
1957
1964
|
}
|
|
@@ -1960,58 +1967,58 @@ class G {
|
|
|
1960
1967
|
}
|
|
1961
1968
|
//* Initialize the tel input listeners.
|
|
1962
1969
|
_initTelInputListeners() {
|
|
1963
|
-
const { strictMode:
|
|
1970
|
+
const { strictMode: e, formatAsYouType: t, separateDialCode: i, formatOnDisplay: s, allowDropdown: n, countrySearch: o } = this.options;
|
|
1964
1971
|
let a = !1;
|
|
1965
1972
|
new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (r) => {
|
|
1966
1973
|
if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && n && o) {
|
|
1967
|
-
const C = this.telInput.selectionStart || 0,
|
|
1968
|
-
this.telInput.value =
|
|
1974
|
+
const C = this.telInput.selectionStart || 0, d = this.telInput.value.substring(0, C - 1), m = this.telInput.value.substring(C);
|
|
1975
|
+
this.telInput.value = d + m, this._openDropdownWithPlus();
|
|
1969
1976
|
return;
|
|
1970
1977
|
}
|
|
1971
1978
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
1972
|
-
const p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data),
|
|
1973
|
-
p ||
|
|
1974
|
-
const
|
|
1975
|
-
if (
|
|
1976
|
-
const C = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length,
|
|
1977
|
-
this.telInput.value =
|
|
1979
|
+
const p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), h = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
|
|
1980
|
+
p || h && !e ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
|
|
1981
|
+
const c = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
|
|
1982
|
+
if (t && !a && !c) {
|
|
1983
|
+
const C = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", _ = this._formatNumberAsYouType(), f = H(m, _, C, b);
|
|
1984
|
+
this.telInput.value = _, this.telInput.setSelectionRange(f, f);
|
|
1978
1985
|
}
|
|
1979
|
-
}, this.telInput.addEventListener("input", this._handleInputEvent), (
|
|
1986
|
+
}, this.telInput.addEventListener("input", this._handleInputEvent), (e || i) && (this._handleKeydownEvent = (r) => {
|
|
1980
1987
|
if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
|
|
1981
1988
|
if (i && n && o && r.key === "+") {
|
|
1982
1989
|
r.preventDefault(), this._openDropdownWithPlus();
|
|
1983
1990
|
return;
|
|
1984
1991
|
}
|
|
1985
|
-
if (
|
|
1986
|
-
const p = this.telInput.value,
|
|
1987
|
-
let
|
|
1988
|
-
if (
|
|
1992
|
+
if (e) {
|
|
1993
|
+
const p = this.telInput.value, h = p.charAt(0) === "+", c = !h && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), d = i ? C : c || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), b = this._getFullNumber(m), _ = l.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength;
|
|
1994
|
+
let g = !1;
|
|
1995
|
+
if (h) {
|
|
1989
1996
|
const P = this.selectedCountryData.iso2;
|
|
1990
|
-
|
|
1997
|
+
g = this._getCountryFromNumber(b) !== P;
|
|
1991
1998
|
}
|
|
1992
|
-
(!
|
|
1999
|
+
(!d || f && !g && !c) && r.preventDefault();
|
|
1993
2000
|
}
|
|
1994
2001
|
}
|
|
1995
2002
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
1996
2003
|
}
|
|
1997
2004
|
//* Adhere to the input's maxlength attr.
|
|
1998
|
-
_cap(
|
|
1999
|
-
const
|
|
2000
|
-
return
|
|
2005
|
+
_cap(e) {
|
|
2006
|
+
const t = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
2007
|
+
return t && e.length > t ? e.substr(0, t) : e;
|
|
2001
2008
|
}
|
|
2002
2009
|
//* Trigger a custom event on the input.
|
|
2003
|
-
_trigger(
|
|
2004
|
-
const i = new CustomEvent(
|
|
2010
|
+
_trigger(e, t = {}) {
|
|
2011
|
+
const i = new CustomEvent(e, {
|
|
2005
2012
|
bubbles: !0,
|
|
2006
2013
|
cancelable: !0,
|
|
2007
|
-
detail:
|
|
2014
|
+
detail: t
|
|
2008
2015
|
});
|
|
2009
2016
|
this.telInput.dispatchEvent(i);
|
|
2010
2017
|
}
|
|
2011
2018
|
//* Open the dropdown.
|
|
2012
2019
|
_openDropdown() {
|
|
2013
|
-
const { fixDropdownWidth:
|
|
2014
|
-
if (
|
|
2020
|
+
const { fixDropdownWidth: e, countrySearch: t } = this.options;
|
|
2021
|
+
if (e && (this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`), this.dropdownContent.classList.remove("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), t) {
|
|
2015
2022
|
const i = this.countryList.firstElementChild;
|
|
2016
2023
|
i && (this._highlightListItem(i, !1), this.countryList.scrollTop = 0), this.searchInput.focus();
|
|
2017
2024
|
}
|
|
@@ -2020,8 +2027,8 @@ class G {
|
|
|
2020
2027
|
//* Set the dropdown position
|
|
2021
2028
|
_setDropdownPosition() {
|
|
2022
2029
|
if (this.options.dropdownContainer && this.options.dropdownContainer.appendChild(this.dropdown), !this.options.useFullscreenPopup) {
|
|
2023
|
-
const
|
|
2024
|
-
this.options.dropdownContainer && (this.dropdown.style.top = `${
|
|
2030
|
+
const e = this.telInput.getBoundingClientRect(), t = this.telInput.offsetHeight;
|
|
2031
|
+
this.options.dropdownContainer && (this.dropdown.style.top = `${e.top + t}px`, this.dropdown.style.left = `${e.left}px`, this._handleWindowScroll = () => this._closeDropdown(), window.addEventListener("scroll", this._handleWindowScroll));
|
|
2025
2032
|
}
|
|
2026
2033
|
}
|
|
2027
2034
|
//* We only bind dropdown listeners when the dropdown is open.
|
|
@@ -2038,17 +2045,17 @@ class G {
|
|
|
2038
2045
|
const n = (o = s.target) == null ? void 0 : o.closest(".iti__country");
|
|
2039
2046
|
n && this._selectListItem(n);
|
|
2040
2047
|
}, this.countryList.addEventListener("click", this._handleClickCountryList);
|
|
2041
|
-
let
|
|
2048
|
+
let e = !0;
|
|
2042
2049
|
this._handleClickOffToClose = () => {
|
|
2043
|
-
|
|
2050
|
+
e || this._closeDropdown(), e = !1;
|
|
2044
2051
|
}, document.documentElement.addEventListener(
|
|
2045
2052
|
"click",
|
|
2046
2053
|
this._handleClickOffToClose
|
|
2047
2054
|
);
|
|
2048
|
-
let
|
|
2055
|
+
let t = "", i = null;
|
|
2049
2056
|
if (this._handleKeydownOnDropdown = (s) => {
|
|
2050
|
-
["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),
|
|
2051
|
-
|
|
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), t += s.key.toLowerCase(), this._searchForCountry(t), i = setTimeout(() => {
|
|
2058
|
+
t = "";
|
|
2052
2059
|
}, 1e3));
|
|
2053
2060
|
}, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
|
|
2054
2061
|
const s = () => {
|
|
@@ -2064,10 +2071,10 @@ class G {
|
|
|
2064
2071
|
}
|
|
2065
2072
|
}
|
|
2066
2073
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2067
|
-
_searchForCountry(
|
|
2068
|
-
for (let
|
|
2069
|
-
const i = this.countries[
|
|
2070
|
-
if (i.name.substr(0,
|
|
2074
|
+
_searchForCountry(e) {
|
|
2075
|
+
for (let t = 0; t < this.countries.length; t++) {
|
|
2076
|
+
const i = this.countries[t];
|
|
2077
|
+
if (i.name.substr(0, e.length).toLowerCase() === e) {
|
|
2071
2078
|
const n = i.nodeById[this.id];
|
|
2072
2079
|
this._highlightListItem(n, !1), this._scrollTo(n);
|
|
2073
2080
|
break;
|
|
@@ -2075,30 +2082,30 @@ class G {
|
|
|
2075
2082
|
}
|
|
2076
2083
|
}
|
|
2077
2084
|
//* Country search enabled: Filter the countries according to the search query.
|
|
2078
|
-
_filterCountries(
|
|
2085
|
+
_filterCountries(e, t = !1) {
|
|
2079
2086
|
let i = !0;
|
|
2080
2087
|
this.countryList.innerHTML = "";
|
|
2081
|
-
const s =
|
|
2088
|
+
const s = N(e);
|
|
2082
2089
|
for (let n = 0; n < this.countries.length; n++) {
|
|
2083
|
-
const o = this.countries[n], a =
|
|
2084
|
-
if (
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2090
|
+
const o = this.countries[n], a = N(o.name), r = o.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((h) => h[0]).join("").toLowerCase(), p = `+${o.dialCode}`;
|
|
2091
|
+
if (t || a.includes(s) || p.includes(s) || o.iso2.includes(s) || r.includes(s)) {
|
|
2092
|
+
const h = o.nodeById[this.id];
|
|
2093
|
+
h && this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1);
|
|
2087
2094
|
}
|
|
2088
2095
|
}
|
|
2089
2096
|
i && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
|
|
2090
2097
|
}
|
|
2091
2098
|
//* Update search results text (for a11y).
|
|
2092
2099
|
_updateSearchResultsText() {
|
|
2093
|
-
const { i18n:
|
|
2100
|
+
const { i18n: e } = this.options, t = this.countryList.childElementCount;
|
|
2094
2101
|
let i;
|
|
2095
|
-
|
|
2102
|
+
t === 0 ? i = e.zeroSearchResults : t === 1 ? i = e.oneSearchResult : i = e.multipleSearchResults.replace("${count}", t.toString()), this.searchResultsA11yText.textContent = i;
|
|
2096
2103
|
}
|
|
2097
2104
|
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2098
|
-
_handleUpDownKey(
|
|
2105
|
+
_handleUpDownKey(e) {
|
|
2099
2106
|
var i, s;
|
|
2100
|
-
let
|
|
2101
|
-
!
|
|
2107
|
+
let t = e === "ArrowUp" ? (i = this.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.highlightedItem) == null ? void 0 : s.nextElementSibling;
|
|
2108
|
+
!t && this.countryList.childElementCount > 1 && (t = e === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild), t && (this._scrollTo(t), this._highlightListItem(t, !1));
|
|
2102
2109
|
}
|
|
2103
2110
|
//* Select the currently highlighted item.
|
|
2104
2111
|
_handleEnterKey() {
|
|
@@ -2106,36 +2113,42 @@ class G {
|
|
|
2106
2113
|
}
|
|
2107
2114
|
//* Update the input's value to the given val (format first if possible)
|
|
2108
2115
|
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2109
|
-
_updateValFromNumber(
|
|
2110
|
-
let
|
|
2116
|
+
_updateValFromNumber(e) {
|
|
2117
|
+
let t = e;
|
|
2111
2118
|
if (this.options.formatOnDisplay && l.utils && this.selectedCountryData) {
|
|
2112
|
-
const i = this.options.nationalMode ||
|
|
2113
|
-
|
|
2114
|
-
|
|
2119
|
+
const i = this.options.nationalMode || t.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, o = i ? s : n;
|
|
2120
|
+
t = l.utils.formatNumber(
|
|
2121
|
+
t,
|
|
2115
2122
|
this.selectedCountryData.iso2,
|
|
2116
2123
|
o
|
|
2117
2124
|
);
|
|
2118
2125
|
}
|
|
2119
|
-
|
|
2126
|
+
t = this._beforeSetNumber(t), this.telInput.value = t;
|
|
2120
2127
|
}
|
|
2121
2128
|
//* Check if need to select a new country based on the given number
|
|
2122
2129
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2123
|
-
_updateCountryFromNumber(
|
|
2124
|
-
const
|
|
2125
|
-
return
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
+
_updateCountryFromNumber(e) {
|
|
2131
|
+
const t = this._getCountryFromNumber(e);
|
|
2132
|
+
return t !== null ? this._setCountry(t) : !1;
|
|
2133
|
+
}
|
|
2134
|
+
//* Check if the given number matches an area code from the selected country.
|
|
2135
|
+
_isAreaCodeMatch(e, t) {
|
|
2136
|
+
const { areaCodes: i, partialAreaCodes: s, dialCode: n } = this.selectedCountryData, o = e.substring(n.length), a = t.substring(n.length);
|
|
2137
|
+
return !!(i.includes(a) || s.includes(o));
|
|
2138
|
+
}
|
|
2139
|
+
_getCountryFromNumber(e) {
|
|
2140
|
+
const t = e.indexOf("+");
|
|
2141
|
+
let i = t ? e.substring(t) : e;
|
|
2130
2142
|
const s = this.selectedCountryData.dialCode;
|
|
2131
2143
|
i && s === "1" && i.charAt(0) !== "+" && (i.charAt(0) !== "1" && (i = `1${i}`), i = `+${i}`), this.options.separateDialCode && s && i.charAt(0) !== "+" && (i = `+${s}${i}`);
|
|
2132
|
-
const o = this._getDialCode(i, !0), a =
|
|
2144
|
+
const o = this._getDialCode(i, !0), a = v(i);
|
|
2133
2145
|
if (o) {
|
|
2134
|
-
const r = this.dialCodeToIso2Map[
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2146
|
+
const r = v(o), p = this.dialCodeToIso2Map[r], h = this.selectedCountryData.iso2 && p.includes(this.selectedCountryData.iso2);
|
|
2147
|
+
let c = !1;
|
|
2148
|
+
if (h && (this.selectedCountryData.areaCodes && a.length > s.length ? c = this._isAreaCodeMatch(a, r) : c = !0), !(s === "1" && S(a)) && (!h || !c)) {
|
|
2149
|
+
for (let d = 0; d < p.length; d++)
|
|
2150
|
+
if (p[d])
|
|
2151
|
+
return p[d];
|
|
2139
2152
|
}
|
|
2140
2153
|
} else {
|
|
2141
2154
|
if (i.charAt(0) === "+" && a.length)
|
|
@@ -2146,52 +2159,52 @@ class G {
|
|
|
2146
2159
|
return null;
|
|
2147
2160
|
}
|
|
2148
2161
|
//* Remove highlighting from other list items and highlight the given item.
|
|
2149
|
-
_highlightListItem(
|
|
2162
|
+
_highlightListItem(e, t) {
|
|
2150
2163
|
const i = this.highlightedItem;
|
|
2151
|
-
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem =
|
|
2164
|
+
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = e, this.highlightedItem) {
|
|
2152
2165
|
this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2153
2166
|
const s = this.highlightedItem.getAttribute("id") || "";
|
|
2154
2167
|
this.selectedCountry.setAttribute("aria-activedescendant", s), this.options.countrySearch && this.searchInput.setAttribute("aria-activedescendant", s);
|
|
2155
2168
|
}
|
|
2156
|
-
|
|
2169
|
+
t && this.highlightedItem.focus();
|
|
2157
2170
|
}
|
|
2158
2171
|
//* Find the country data for the given iso2 code
|
|
2159
2172
|
//* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
|
|
2160
|
-
_getCountryData(
|
|
2173
|
+
_getCountryData(e, t) {
|
|
2161
2174
|
for (let i = 0; i < this.countries.length; i++)
|
|
2162
|
-
if (this.countries[i].iso2 ===
|
|
2175
|
+
if (this.countries[i].iso2 === e)
|
|
2163
2176
|
return this.countries[i];
|
|
2164
|
-
if (
|
|
2177
|
+
if (t)
|
|
2165
2178
|
return null;
|
|
2166
|
-
throw new Error(`No country data for '${
|
|
2179
|
+
throw new Error(`No country data for '${e}'`);
|
|
2167
2180
|
}
|
|
2168
2181
|
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
|
|
2169
2182
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
2170
|
-
_setCountry(
|
|
2171
|
-
const { separateDialCode:
|
|
2172
|
-
if (this.selectedCountryData =
|
|
2183
|
+
_setCountry(e) {
|
|
2184
|
+
const { separateDialCode: t, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2185
|
+
if (this.selectedCountryData = e ? this._getCountryData(e, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountryInner) {
|
|
2173
2186
|
let o = "", a = "";
|
|
2174
|
-
|
|
2187
|
+
e && i ? (o = `iti__flag iti__${e}`, a = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`) : (o = "iti__flag iti__globe", a = s.noCountrySelected), this.selectedCountryInner.className = o, this.selectedCountryA11yText.textContent = a;
|
|
2175
2188
|
}
|
|
2176
|
-
if (this._setSelectedCountryTitleAttribute(
|
|
2189
|
+
if (this._setSelectedCountryTitleAttribute(e, t), t) {
|
|
2177
2190
|
const o = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2178
2191
|
this.selectedDialCode.innerHTML = o, this._updateInputPadding();
|
|
2179
2192
|
}
|
|
2180
|
-
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !==
|
|
2193
|
+
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== e;
|
|
2181
2194
|
}
|
|
2182
2195
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2183
2196
|
_updateInputPadding() {
|
|
2184
2197
|
if (this.selectedCountry) {
|
|
2185
|
-
const
|
|
2186
|
-
this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${
|
|
2198
|
+
const t = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 6;
|
|
2199
|
+
this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${t}px` : this.telInput.style.paddingRight = `${t}px`;
|
|
2187
2200
|
}
|
|
2188
2201
|
}
|
|
2189
2202
|
//* Update the maximum valid number length for the currently selected country.
|
|
2190
2203
|
_updateMaxLength() {
|
|
2191
|
-
const { strictMode:
|
|
2192
|
-
if (
|
|
2204
|
+
const { strictMode: e, placeholderNumberType: t, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2205
|
+
if (e && l.utils)
|
|
2193
2206
|
if (s) {
|
|
2194
|
-
const n = l.utils.numberType[
|
|
2207
|
+
const n = l.utils.numberType[t];
|
|
2195
2208
|
let o = l.utils.getExampleNumber(
|
|
2196
2209
|
s,
|
|
2197
2210
|
!1,
|
|
@@ -2205,11 +2218,11 @@ class G {
|
|
|
2205
2218
|
} else
|
|
2206
2219
|
this.maxCoreNumberLength = null;
|
|
2207
2220
|
}
|
|
2208
|
-
_setSelectedCountryTitleAttribute(
|
|
2221
|
+
_setSelectedCountryTitleAttribute(e = null, t) {
|
|
2209
2222
|
if (!this.selectedCountry)
|
|
2210
2223
|
return;
|
|
2211
2224
|
let i;
|
|
2212
|
-
|
|
2225
|
+
e && !t ? i = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : e ? i = this.selectedCountryData.name : i = "Unknown", this.selectedCountry.setAttribute("title", i);
|
|
2213
2226
|
}
|
|
2214
2227
|
//* When the input is in a hidden container during initialisation, we must inject some markup
|
|
2215
2228
|
//* into the end of the DOM to calculate the correct offsetWidth.
|
|
@@ -2217,27 +2230,27 @@ class G {
|
|
|
2217
2230
|
//* will definitely exist.
|
|
2218
2231
|
_getHiddenSelectedCountryWidth() {
|
|
2219
2232
|
if (this.telInput.parentNode) {
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2233
|
+
const e = this.telInput.parentNode.cloneNode(!1);
|
|
2234
|
+
e.style.visibility = "hidden", document.body.appendChild(e);
|
|
2235
|
+
const t = this.countryContainer.cloneNode();
|
|
2236
|
+
e.appendChild(t);
|
|
2224
2237
|
const i = this.selectedCountry.cloneNode(!0);
|
|
2225
|
-
|
|
2238
|
+
t.appendChild(i);
|
|
2226
2239
|
const s = i.offsetWidth;
|
|
2227
|
-
return document.body.removeChild(
|
|
2240
|
+
return document.body.removeChild(e), s;
|
|
2228
2241
|
}
|
|
2229
2242
|
return 0;
|
|
2230
2243
|
}
|
|
2231
2244
|
//* Update the input placeholder to an example number from the currently selected country.
|
|
2232
2245
|
_updatePlaceholder() {
|
|
2233
2246
|
const {
|
|
2234
|
-
autoPlaceholder:
|
|
2235
|
-
placeholderNumberType:
|
|
2247
|
+
autoPlaceholder: e,
|
|
2248
|
+
placeholderNumberType: t,
|
|
2236
2249
|
nationalMode: i,
|
|
2237
2250
|
customPlaceholder: s
|
|
2238
|
-
} = this.options, n =
|
|
2251
|
+
} = this.options, n = e === "aggressive" || !this.hadInitialPlaceholder && e === "polite";
|
|
2239
2252
|
if (l.utils && n) {
|
|
2240
|
-
const o = l.utils.numberType[
|
|
2253
|
+
const o = l.utils.numberType[t];
|
|
2241
2254
|
let a = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
|
|
2242
2255
|
this.selectedCountryData.iso2,
|
|
2243
2256
|
i,
|
|
@@ -2247,11 +2260,11 @@ class G {
|
|
|
2247
2260
|
}
|
|
2248
2261
|
}
|
|
2249
2262
|
//* Called when the user selects a list item from the dropdown.
|
|
2250
|
-
_selectListItem(
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2263
|
+
_selectListItem(e) {
|
|
2264
|
+
const t = this._setCountry(
|
|
2265
|
+
e.getAttribute("data-country-code")
|
|
2253
2266
|
);
|
|
2254
|
-
this._closeDropdown(), this._updateDialCode(
|
|
2267
|
+
this._closeDropdown(), this._updateDialCode(e.getAttribute("data-dial-code")), this.telInput.focus(), t && this._triggerCountryChange();
|
|
2255
2268
|
}
|
|
2256
2269
|
//* Close the dropdown and unbind any listeners.
|
|
2257
2270
|
_closeDropdown() {
|
|
@@ -2264,38 +2277,38 @@ class G {
|
|
|
2264
2277
|
), 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");
|
|
2265
2278
|
}
|
|
2266
2279
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2267
|
-
_scrollTo(
|
|
2268
|
-
const
|
|
2280
|
+
_scrollTo(e) {
|
|
2281
|
+
const t = this.countryList, i = document.documentElement.scrollTop, s = t.offsetHeight, n = t.getBoundingClientRect().top + i, o = n + s, a = e.offsetHeight, r = e.getBoundingClientRect().top + i, p = r + a, h = r - n + t.scrollTop;
|
|
2269
2282
|
if (r < n)
|
|
2270
|
-
|
|
2283
|
+
t.scrollTop = h;
|
|
2271
2284
|
else if (p > o) {
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2285
|
+
const c = s - a;
|
|
2286
|
+
t.scrollTop = h - c;
|
|
2274
2287
|
}
|
|
2275
2288
|
}
|
|
2276
2289
|
//* Replace any existing dial code with the new one
|
|
2277
2290
|
//* Note: called from _selectListItem and setCountry
|
|
2278
|
-
_updateDialCode(
|
|
2279
|
-
const
|
|
2291
|
+
_updateDialCode(e) {
|
|
2292
|
+
const t = this.telInput.value, i = `+${e}`;
|
|
2280
2293
|
let s;
|
|
2281
|
-
if (
|
|
2282
|
-
const n = this._getDialCode(
|
|
2283
|
-
n ? s =
|
|
2294
|
+
if (t.charAt(0) === "+") {
|
|
2295
|
+
const n = this._getDialCode(t);
|
|
2296
|
+
n ? s = t.replace(n, i) : s = i, this.telInput.value = s;
|
|
2284
2297
|
}
|
|
2285
2298
|
}
|
|
2286
2299
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
2287
2300
|
//* Note: returns the raw string inc plus character and any whitespace/dots etc.
|
|
2288
|
-
_getDialCode(
|
|
2301
|
+
_getDialCode(e, t) {
|
|
2289
2302
|
let i = "";
|
|
2290
|
-
if (
|
|
2303
|
+
if (e.charAt(0) === "+") {
|
|
2291
2304
|
let s = "";
|
|
2292
|
-
for (let n = 0; n <
|
|
2293
|
-
const o =
|
|
2305
|
+
for (let n = 0; n < e.length; n++) {
|
|
2306
|
+
const o = e.charAt(n);
|
|
2294
2307
|
if (!isNaN(parseInt(o, 10))) {
|
|
2295
|
-
if (s += o,
|
|
2296
|
-
this.dialCodeToIso2Map[s] && (i =
|
|
2308
|
+
if (s += o, t)
|
|
2309
|
+
this.dialCodeToIso2Map[s] && (i = e.substr(0, n + 1));
|
|
2297
2310
|
else if (this.dialCodes[s]) {
|
|
2298
|
-
i =
|
|
2311
|
+
i = e.substr(0, n + 1);
|
|
2299
2312
|
break;
|
|
2300
2313
|
}
|
|
2301
2314
|
if (s.length === this.dialCodeMaxLen)
|
|
@@ -2306,24 +2319,24 @@ class G {
|
|
|
2306
2319
|
return i;
|
|
2307
2320
|
}
|
|
2308
2321
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
2309
|
-
_getFullNumber(
|
|
2310
|
-
const
|
|
2322
|
+
_getFullNumber(e) {
|
|
2323
|
+
const t = e || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2311
2324
|
let s;
|
|
2312
|
-
const n =
|
|
2313
|
-
return this.options.separateDialCode &&
|
|
2325
|
+
const n = v(t);
|
|
2326
|
+
return this.options.separateDialCode && t.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + t;
|
|
2314
2327
|
}
|
|
2315
2328
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
2316
|
-
_beforeSetNumber(
|
|
2317
|
-
let
|
|
2329
|
+
_beforeSetNumber(e) {
|
|
2330
|
+
let t = e;
|
|
2318
2331
|
if (this.options.separateDialCode) {
|
|
2319
|
-
let i = this._getDialCode(
|
|
2332
|
+
let i = this._getDialCode(t);
|
|
2320
2333
|
if (i) {
|
|
2321
2334
|
i = `+${this.selectedCountryData.dialCode}`;
|
|
2322
|
-
const s =
|
|
2323
|
-
|
|
2335
|
+
const s = t[i.length] === " " || t[i.length] === "-" ? i.length + 1 : i.length;
|
|
2336
|
+
t = t.substr(s);
|
|
2324
2337
|
}
|
|
2325
2338
|
}
|
|
2326
|
-
return this._cap(
|
|
2339
|
+
return this._cap(t);
|
|
2327
2340
|
}
|
|
2328
2341
|
//* Trigger the 'countrychange' event.
|
|
2329
2342
|
_triggerCountryChange() {
|
|
@@ -2331,8 +2344,8 @@ class G {
|
|
|
2331
2344
|
}
|
|
2332
2345
|
//* Format the number as the user types.
|
|
2333
2346
|
_formatNumberAsYouType() {
|
|
2334
|
-
const
|
|
2335
|
-
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" &&
|
|
2347
|
+
const e = this._getFullNumber(), t = l.utils ? l.utils.formatNumberAsYouType(e, this.selectedCountryData.iso2) : e, { dialCode: i } = this.selectedCountryData;
|
|
2348
|
+
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && t.includes(`+${i}`) ? (t.split(`+${i}`)[1] || "").trim() : t;
|
|
2336
2349
|
}
|
|
2337
2350
|
//**************************
|
|
2338
2351
|
//* SECRET PUBLIC METHODS
|
|
@@ -2351,8 +2364,8 @@ class G {
|
|
|
2351
2364
|
//* Remove plugin.
|
|
2352
2365
|
destroy() {
|
|
2353
2366
|
var n, o;
|
|
2354
|
-
const { allowDropdown:
|
|
2355
|
-
if (
|
|
2367
|
+
const { allowDropdown: e, separateDialCode: t } = this.options;
|
|
2368
|
+
if (e) {
|
|
2356
2369
|
this._closeDropdown(), this.selectedCountry.removeEventListener(
|
|
2357
2370
|
"click",
|
|
2358
2371
|
this._handleClickSelectedCountry
|
|
@@ -2364,7 +2377,7 @@ class G {
|
|
|
2364
2377
|
a && a.removeEventListener("click", this._handleLabelClick);
|
|
2365
2378
|
}
|
|
2366
2379
|
const { form: i } = this.telInput;
|
|
2367
|
-
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"),
|
|
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"), t && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
|
|
2368
2381
|
const s = this.telInput.parentNode;
|
|
2369
2382
|
(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];
|
|
2370
2383
|
}
|
|
@@ -2376,13 +2389,13 @@ class G {
|
|
|
2376
2389
|
) : "";
|
|
2377
2390
|
}
|
|
2378
2391
|
//* Format the number to the given format.
|
|
2379
|
-
getNumber(
|
|
2392
|
+
getNumber(e) {
|
|
2380
2393
|
if (l.utils) {
|
|
2381
|
-
const { iso2:
|
|
2394
|
+
const { iso2: t } = this.selectedCountryData;
|
|
2382
2395
|
return l.utils.formatNumber(
|
|
2383
2396
|
this._getFullNumber(),
|
|
2384
|
-
|
|
2385
|
-
|
|
2397
|
+
t,
|
|
2398
|
+
e
|
|
2386
2399
|
);
|
|
2387
2400
|
}
|
|
2388
2401
|
return "";
|
|
@@ -2401,8 +2414,8 @@ class G {
|
|
|
2401
2414
|
//* Get the validation error.
|
|
2402
2415
|
getValidationError() {
|
|
2403
2416
|
if (l.utils) {
|
|
2404
|
-
const { iso2:
|
|
2405
|
-
return l.utils.getValidationError(this._getFullNumber(),
|
|
2417
|
+
const { iso2: e } = this.selectedCountryData;
|
|
2418
|
+
return l.utils.getValidationError(this._getFullNumber(), e);
|
|
2406
2419
|
}
|
|
2407
2420
|
return -99;
|
|
2408
2421
|
}
|
|
@@ -2410,91 +2423,91 @@ class G {
|
|
|
2410
2423
|
isValidNumber() {
|
|
2411
2424
|
if (!this.selectedCountryData.iso2)
|
|
2412
2425
|
return !1;
|
|
2413
|
-
const
|
|
2414
|
-
if (
|
|
2415
|
-
const i =
|
|
2426
|
+
const e = this._getFullNumber(), t = e.search(new RegExp("\\p{L}", "u"));
|
|
2427
|
+
if (t > -1) {
|
|
2428
|
+
const i = e.substring(0, t), s = this._utilsIsPossibleNumber(i), n = this._utilsIsPossibleNumber(e);
|
|
2416
2429
|
return s && n;
|
|
2417
2430
|
}
|
|
2418
|
-
return this._utilsIsPossibleNumber(
|
|
2431
|
+
return this._utilsIsPossibleNumber(e);
|
|
2419
2432
|
}
|
|
2420
|
-
_utilsIsPossibleNumber(
|
|
2421
|
-
return l.utils ? l.utils.isPossibleNumber(
|
|
2433
|
+
_utilsIsPossibleNumber(e) {
|
|
2434
|
+
return l.utils ? l.utils.isPossibleNumber(e, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2422
2435
|
}
|
|
2423
2436
|
//* Validate the input val (precise)
|
|
2424
2437
|
isValidNumberPrecise() {
|
|
2425
2438
|
if (!this.selectedCountryData.iso2)
|
|
2426
2439
|
return !1;
|
|
2427
|
-
const
|
|
2428
|
-
if (
|
|
2429
|
-
const i =
|
|
2440
|
+
const e = this._getFullNumber(), t = e.search(new RegExp("\\p{L}", "u"));
|
|
2441
|
+
if (t > -1) {
|
|
2442
|
+
const i = e.substring(0, t), s = this._utilsIsValidNumber(i), n = this._utilsIsValidNumber(e);
|
|
2430
2443
|
return s && n;
|
|
2431
2444
|
}
|
|
2432
|
-
return this._utilsIsValidNumber(
|
|
2445
|
+
return this._utilsIsValidNumber(e);
|
|
2433
2446
|
}
|
|
2434
|
-
_utilsIsValidNumber(
|
|
2435
|
-
return l.utils ? l.utils.isValidNumber(
|
|
2447
|
+
_utilsIsValidNumber(e) {
|
|
2448
|
+
return l.utils ? l.utils.isValidNumber(e, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2436
2449
|
}
|
|
2437
2450
|
//* Update the selected country, and update the input val accordingly.
|
|
2438
|
-
setCountry(
|
|
2439
|
-
const
|
|
2440
|
-
(
|
|
2451
|
+
setCountry(e) {
|
|
2452
|
+
const t = e == null ? void 0 : e.toLowerCase(), i = this.selectedCountryData.iso2;
|
|
2453
|
+
(e && t !== i || !e && i) && (this._setCountry(t), this._updateDialCode(this.selectedCountryData.dialCode), this._triggerCountryChange());
|
|
2441
2454
|
}
|
|
2442
2455
|
//* Set the input value and update the country.
|
|
2443
|
-
setNumber(
|
|
2444
|
-
const
|
|
2445
|
-
this._updateValFromNumber(
|
|
2456
|
+
setNumber(e) {
|
|
2457
|
+
const t = this._updateCountryFromNumber(e);
|
|
2458
|
+
this._updateValFromNumber(e), t && this._triggerCountryChange(), this._trigger("input", { isSetNumber: !0 });
|
|
2446
2459
|
}
|
|
2447
2460
|
//* Set the placeholder number typ
|
|
2448
|
-
setPlaceholderNumberType(
|
|
2449
|
-
this.options.placeholderNumberType =
|
|
2461
|
+
setPlaceholderNumberType(e) {
|
|
2462
|
+
this.options.placeholderNumberType = e, this._updatePlaceholder();
|
|
2450
2463
|
}
|
|
2451
|
-
setDisabled(
|
|
2452
|
-
this.telInput.disabled =
|
|
2464
|
+
setDisabled(e) {
|
|
2465
|
+
this.telInput.disabled = e, e ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2453
2466
|
}
|
|
2454
2467
|
}
|
|
2455
2468
|
const W = (u) => {
|
|
2456
2469
|
if (!l.utils && !l.startedLoadingUtilsScript) {
|
|
2457
|
-
let
|
|
2470
|
+
let e;
|
|
2458
2471
|
if (typeof u == "function")
|
|
2459
2472
|
try {
|
|
2460
|
-
|
|
2461
|
-
} catch (
|
|
2462
|
-
return Promise.reject(
|
|
2473
|
+
e = Promise.resolve(u());
|
|
2474
|
+
} catch (t) {
|
|
2475
|
+
return Promise.reject(t);
|
|
2463
2476
|
}
|
|
2464
2477
|
else
|
|
2465
2478
|
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}`));
|
|
2466
|
-
return l.startedLoadingUtilsScript = !0,
|
|
2467
|
-
const i =
|
|
2479
|
+
return l.startedLoadingUtilsScript = !0, e.then((t) => {
|
|
2480
|
+
const i = t == null ? void 0 : t.default;
|
|
2468
2481
|
if (!i || typeof i != "object")
|
|
2469
2482
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2470
|
-
return l.utils = i,
|
|
2471
|
-
}).catch((
|
|
2472
|
-
throw
|
|
2483
|
+
return l.utils = i, w("handleUtils"), !0;
|
|
2484
|
+
}).catch((t) => {
|
|
2485
|
+
throw w("rejectUtilsScriptPromise", t), t;
|
|
2473
2486
|
});
|
|
2474
2487
|
}
|
|
2475
2488
|
return null;
|
|
2476
2489
|
}, l = Object.assign(
|
|
2477
|
-
(u,
|
|
2478
|
-
const
|
|
2479
|
-
return
|
|
2490
|
+
(u, e) => {
|
|
2491
|
+
const t = new G(u, e);
|
|
2492
|
+
return t._init(), u.setAttribute("data-intl-tel-input-id", t.id.toString()), l.instances[t.id] = t, t;
|
|
2480
2493
|
},
|
|
2481
2494
|
{
|
|
2482
2495
|
defaults: T,
|
|
2483
2496
|
//* Using a static var like this allows us to mock it in the tests.
|
|
2484
2497
|
documentReady: () => document.readyState === "complete",
|
|
2485
2498
|
//* Get the country data object.
|
|
2486
|
-
getCountryData: () =>
|
|
2499
|
+
getCountryData: () => I,
|
|
2487
2500
|
//* A getter for the plugin instance.
|
|
2488
2501
|
getInstance: (u) => {
|
|
2489
|
-
const
|
|
2490
|
-
return
|
|
2502
|
+
const e = u.getAttribute("data-intl-tel-input-id");
|
|
2503
|
+
return e ? l.instances[e] : null;
|
|
2491
2504
|
},
|
|
2492
2505
|
//* A map from instance ID to instance object.
|
|
2493
2506
|
instances: {},
|
|
2494
2507
|
attachUtils: W,
|
|
2495
2508
|
startedLoadingUtilsScript: !1,
|
|
2496
2509
|
startedLoadingAutoCountry: !1,
|
|
2497
|
-
version: "25.0.
|
|
2510
|
+
version: "25.0.2"
|
|
2498
2511
|
}
|
|
2499
2512
|
), J = {
|
|
2500
2513
|
__name: "IntlTelInput",
|
|
@@ -2528,38 +2541,38 @@ const W = (u) => {
|
|
|
2528
2541
|
"changeValidity",
|
|
2529
2542
|
"changeErrorCode"
|
|
2530
2543
|
], ["update:modelValue"]),
|
|
2531
|
-
setup(u, { expose:
|
|
2532
|
-
const i = x(u, "modelValue"), s = u, n =
|
|
2533
|
-
let
|
|
2534
|
-
r.value !==
|
|
2544
|
+
setup(u, { expose: e, emit: t }) {
|
|
2545
|
+
const i = x(u, "modelValue"), s = u, n = t, o = L(), a = L(), r = L(!1), p = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, h = () => {
|
|
2546
|
+
let d = p();
|
|
2547
|
+
r.value !== d && (r.value = d, n("changeValidity", !!d), n(
|
|
2535
2548
|
"changeErrorCode",
|
|
2536
|
-
|
|
2549
|
+
d ? null : a.value.getValidationError()
|
|
2537
2550
|
));
|
|
2538
|
-
},
|
|
2539
|
-
var
|
|
2540
|
-
n("changeNumber", ((
|
|
2551
|
+
}, c = () => {
|
|
2552
|
+
var d;
|
|
2553
|
+
n("changeNumber", ((d = a.value) == null ? void 0 : d.getNumber()) ?? ""), h();
|
|
2541
2554
|
}, C = () => {
|
|
2542
|
-
var
|
|
2543
|
-
n("changeCountry", ((
|
|
2555
|
+
var d;
|
|
2556
|
+
n("changeCountry", ((d = a.value) == null ? void 0 : d.getSelectedCountryData().iso2) ?? ""), c(), h();
|
|
2544
2557
|
};
|
|
2545
2558
|
return E(() => {
|
|
2546
2559
|
o.value && (a.value = l(o.value, s.options), s.value && a.value.setNumber(s.value), s.disabled && a.value.setDisabled(s.disabled));
|
|
2547
2560
|
}), M(
|
|
2548
2561
|
() => s.disabled,
|
|
2549
|
-
(
|
|
2562
|
+
(d) => {
|
|
2550
2563
|
var m;
|
|
2551
|
-
return (m = a.value) == null ? void 0 : m.setDisabled(
|
|
2564
|
+
return (m = a.value) == null ? void 0 : m.setDisabled(d);
|
|
2552
2565
|
}
|
|
2553
2566
|
), F(() => {
|
|
2554
|
-
var
|
|
2555
|
-
return (
|
|
2556
|
-
}),
|
|
2567
|
+
var d;
|
|
2568
|
+
return (d = a.value) == null ? void 0 : d.destroy();
|
|
2569
|
+
}), e({ instance: a, input: o }), (d, m) => B((V(), O("input", z({
|
|
2557
2570
|
ref_key: "input",
|
|
2558
2571
|
ref: o,
|
|
2559
|
-
"onUpdate:modelValue": m[0] || (m[0] = (
|
|
2572
|
+
"onUpdate:modelValue": m[0] || (m[0] = (b) => i.value = b),
|
|
2560
2573
|
type: "tel",
|
|
2561
2574
|
onCountrychange: C,
|
|
2562
|
-
onInput:
|
|
2575
|
+
onInput: c
|
|
2563
2576
|
}, u.inputProps), null, 16)), [
|
|
2564
2577
|
[R, i.value]
|
|
2565
2578
|
]);
|