intl-tel-input 25.5.2 → 25.7.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/CHANGELOG.md +29 -1
- package/README.md +9 -9
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +81 -77
- package/angular/build/IntlTelInputWithUtils.js +146 -163
- package/angular/build/types/intl-tel-input/data.d.ts +7 -2
- package/angular/build/types/intl-tel-input.d.ts +4 -1
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +6 -6
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +11 -3
- package/build/js/intlTelInput.js +82 -80
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +146 -165
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/build/js/utils.js +22 -21
- package/package.json +3 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +81 -79
- package/react/build/IntlTelInput.d.ts +11 -3
- package/react/build/IntlTelInput.js +81 -79
- package/react/build/IntlTelInputWithUtils.cjs +145 -164
- package/react/build/IntlTelInputWithUtils.js +145 -164
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +230 -238
- package/vue/build/IntlTelInputWithUtils.mjs +813 -843
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as N, useModel as x, ref as L, onMounted as E, watch as M, onUnmounted as B, withDirectives as F, createElementBlock as V, openBlock as z, mergeProps as R, vModelText as O } from "vue";
|
|
2
|
+
const $ = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1322,20 +1322,19 @@ const N = [
|
|
|
1322
1322
|
// Zimbabwe
|
|
1323
1323
|
"263"
|
|
1324
1324
|
]
|
|
1325
|
-
],
|
|
1326
|
-
for (
|
|
1327
|
-
|
|
1328
|
-
I[h] = {
|
|
1325
|
+
], w = [];
|
|
1326
|
+
for (const d of $)
|
|
1327
|
+
w.push({
|
|
1329
1328
|
name: "",
|
|
1330
|
-
//
|
|
1331
|
-
iso2:
|
|
1332
|
-
dialCode:
|
|
1333
|
-
priority:
|
|
1334
|
-
areaCodes:
|
|
1329
|
+
// populated in the plugin
|
|
1330
|
+
iso2: d[0],
|
|
1331
|
+
dialCode: d[1],
|
|
1332
|
+
priority: d[2] || 0,
|
|
1333
|
+
areaCodes: d[3] || null,
|
|
1335
1334
|
nodeById: {},
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}
|
|
1335
|
+
// populated by the plugin
|
|
1336
|
+
nationalPrefix: d[4] || null
|
|
1337
|
+
});
|
|
1339
1338
|
const j = {
|
|
1340
1339
|
ad: "Andorra",
|
|
1341
1340
|
ae: "United Arab Emirates",
|
|
@@ -1579,7 +1578,7 @@ const j = {
|
|
|
1579
1578
|
za: "South Africa",
|
|
1580
1579
|
zm: "Zambia",
|
|
1581
1580
|
zw: "Zimbabwe"
|
|
1582
|
-
},
|
|
1581
|
+
}, U = {
|
|
1583
1582
|
selectedCountryAriaLabel: "Selected country",
|
|
1584
1583
|
noCountrySelected: "No country selected",
|
|
1585
1584
|
countryListAriaLabel: "List of countries",
|
|
@@ -1590,11 +1589,17 @@ const j = {
|
|
|
1590
1589
|
// additional countries (not supported by country-list library)
|
|
1591
1590
|
ac: "Ascension Island",
|
|
1592
1591
|
xk: "Kosovo"
|
|
1593
|
-
}, k = { ...j,
|
|
1594
|
-
for (
|
|
1595
|
-
|
|
1596
|
-
let
|
|
1597
|
-
const
|
|
1592
|
+
}, k = { ...j, ...U };
|
|
1593
|
+
for (const d of w)
|
|
1594
|
+
d.name = k[d.iso2];
|
|
1595
|
+
let H = 0;
|
|
1596
|
+
const D = (d) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(d).matches, K = () => {
|
|
1597
|
+
if (typeof navigator < "u" && typeof window < "u") {
|
|
1598
|
+
const d = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = D("(max-width: 500px)"), e = D("(max-height: 600px)"), i = D("(pointer: coarse)");
|
|
1599
|
+
return d || t || i && e;
|
|
1600
|
+
}
|
|
1601
|
+
return !1;
|
|
1602
|
+
}, P = {
|
|
1598
1603
|
//* Whether or not to allow the dropdown.
|
|
1599
1604
|
allowDropdown: !0,
|
|
1600
1605
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1640,16 +1645,10 @@ const T = {
|
|
|
1640
1645
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1641
1646
|
strictMode: !1,
|
|
1642
1647
|
//* Use full screen popup instead of dropdown for country list.
|
|
1643
|
-
useFullscreenPopup:
|
|
1644
|
-
//* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
|
|
1645
|
-
//* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
|
|
1646
|
-
/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
1647
|
-
navigator.userAgent
|
|
1648
|
-
) || window.innerWidth <= 500
|
|
1649
|
-
) : !1,
|
|
1648
|
+
useFullscreenPopup: K(),
|
|
1650
1649
|
//* The number type to enforce during validation.
|
|
1651
1650
|
validationNumberTypes: ["MOBILE"]
|
|
1652
|
-
},
|
|
1651
|
+
}, W = [
|
|
1653
1652
|
"800",
|
|
1654
1653
|
"822",
|
|
1655
1654
|
"833",
|
|
@@ -1667,34 +1666,34 @@ const T = {
|
|
|
1667
1666
|
"887",
|
|
1668
1667
|
"888",
|
|
1669
1668
|
"889"
|
|
1670
|
-
], v = (
|
|
1671
|
-
const t = v(
|
|
1669
|
+
], v = (d) => d.replace(/\D/g, ""), S = (d = "") => d.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), A = (d) => {
|
|
1670
|
+
const t = v(d);
|
|
1672
1671
|
if (t.charAt(0) === "1") {
|
|
1673
|
-
const e = t.
|
|
1674
|
-
return
|
|
1672
|
+
const e = t.substring(1, 4);
|
|
1673
|
+
return W.includes(e);
|
|
1675
1674
|
}
|
|
1676
1675
|
return !1;
|
|
1677
|
-
},
|
|
1676
|
+
}, q = (d, t, e, i) => {
|
|
1678
1677
|
if (e === 0 && !i)
|
|
1679
1678
|
return 0;
|
|
1680
1679
|
let s = 0;
|
|
1681
1680
|
for (let n = 0; n < t.length; n++) {
|
|
1682
|
-
if (/[+0-9]/.test(t[n]) && s++, s ===
|
|
1681
|
+
if (/[+0-9]/.test(t[n]) && s++, s === d && !i)
|
|
1683
1682
|
return n + 1;
|
|
1684
|
-
if (i && s ===
|
|
1683
|
+
if (i && s === d + 1)
|
|
1685
1684
|
return n;
|
|
1686
1685
|
}
|
|
1687
1686
|
return t.length;
|
|
1688
|
-
}, m = (
|
|
1689
|
-
const i = document.createElement(
|
|
1687
|
+
}, m = (d, t, e) => {
|
|
1688
|
+
const i = document.createElement(d);
|
|
1690
1689
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1691
|
-
},
|
|
1690
|
+
}, I = (d, ...t) => {
|
|
1692
1691
|
const { instances: e } = u;
|
|
1693
|
-
Object.values(e).forEach((i) => i[
|
|
1692
|
+
Object.values(e).forEach((i) => i[d](...t));
|
|
1694
1693
|
};
|
|
1695
|
-
class
|
|
1694
|
+
class G {
|
|
1696
1695
|
constructor(t, e = {}) {
|
|
1697
|
-
this.id =
|
|
1696
|
+
this.id = H++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, P, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1698
1697
|
}
|
|
1699
1698
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1700
1699
|
_init() {
|
|
@@ -1713,16 +1712,21 @@ class W {
|
|
|
1713
1712
|
//********************
|
|
1714
1713
|
//* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
|
|
1715
1714
|
_processCountryData() {
|
|
1716
|
-
this._processAllCountries(), this._processDialCodes(), this._translateCountryNames(), this._sortCountries();
|
|
1715
|
+
this._processAllCountries(), this._processDialCodes(), this._translateCountryNames(), this._sortCountries(), this.countryByIso2 = new Map(this.countries.map((t) => [t.iso2, t])), this._cacheSearchTokens();
|
|
1716
|
+
}
|
|
1717
|
+
//* Precompute and cache country search tokens to speed up filtering
|
|
1718
|
+
_cacheSearchTokens() {
|
|
1719
|
+
for (const t of this.countries)
|
|
1720
|
+
t.normalisedName = S(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
|
|
1717
1721
|
}
|
|
1718
1722
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1719
1723
|
_sortCountries() {
|
|
1720
1724
|
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((t) => t.toLowerCase())), this.countries.sort((t, e) => {
|
|
1721
1725
|
const { countryOrder: i } = this.options;
|
|
1722
1726
|
if (i) {
|
|
1723
|
-
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), o = s > -1,
|
|
1724
|
-
if (o ||
|
|
1725
|
-
return o &&
|
|
1727
|
+
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), o = s > -1, l = n > -1;
|
|
1728
|
+
if (o || l)
|
|
1729
|
+
return o && l ? s - n : o ? -1 : 1;
|
|
1726
1730
|
}
|
|
1727
1731
|
return t.name.localeCompare(e.name);
|
|
1728
1732
|
});
|
|
@@ -1730,11 +1734,11 @@ class W {
|
|
|
1730
1734
|
//* Add a dial code to this.dialCodeToIso2Map.
|
|
1731
1735
|
_addToDialCodeMap(t, e, i) {
|
|
1732
1736
|
e.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = e.length), this.dialCodeToIso2Map.hasOwnProperty(e) || (this.dialCodeToIso2Map[e] = []);
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
const
|
|
1737
|
-
|
|
1737
|
+
const s = this.dialCodeToIso2Map[e];
|
|
1738
|
+
if (s.includes(t))
|
|
1739
|
+
return;
|
|
1740
|
+
const n = i !== void 0 ? i : s.length;
|
|
1741
|
+
s[n] = t;
|
|
1738
1742
|
}
|
|
1739
1743
|
//* Process onlyCountries or excludeCountries array if present.
|
|
1740
1744
|
_processAllCountries() {
|
|
@@ -1743,51 +1747,46 @@ class W {
|
|
|
1743
1747
|
const i = t.map(
|
|
1744
1748
|
(s) => s.toLowerCase()
|
|
1745
1749
|
);
|
|
1746
|
-
this.countries =
|
|
1750
|
+
this.countries = w.filter(
|
|
1747
1751
|
(s) => i.includes(s.iso2)
|
|
1748
1752
|
);
|
|
1749
1753
|
} else if (e.length) {
|
|
1750
1754
|
const i = e.map(
|
|
1751
1755
|
(s) => s.toLowerCase()
|
|
1752
1756
|
);
|
|
1753
|
-
this.countries =
|
|
1757
|
+
this.countries = w.filter(
|
|
1754
1758
|
(s) => !i.includes(s.iso2)
|
|
1755
1759
|
);
|
|
1756
1760
|
} else
|
|
1757
|
-
this.countries =
|
|
1761
|
+
this.countries = w;
|
|
1758
1762
|
}
|
|
1759
1763
|
//* Translate Countries by object literal provided on config.
|
|
1760
1764
|
_translateCountryNames() {
|
|
1761
|
-
for (
|
|
1762
|
-
const e =
|
|
1763
|
-
this.options.i18n.hasOwnProperty(e) && (
|
|
1765
|
+
for (const t of this.countries) {
|
|
1766
|
+
const e = t.iso2.toLowerCase();
|
|
1767
|
+
this.options.i18n.hasOwnProperty(e) && (t.name = this.options.i18n[e]);
|
|
1764
1768
|
}
|
|
1765
1769
|
}
|
|
1766
1770
|
//* Generate this.dialCodes and this.dialCodeToIso2Map.
|
|
1767
1771
|
_processDialCodes() {
|
|
1768
|
-
this.dialCodes =
|
|
1769
|
-
for (
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
const n = e.areaCodes[s];
|
|
1779
|
-
for (let o = 1; o < n.length; o++) {
|
|
1780
|
-
const r = n.substr(0, o), a = e.dialCode + r;
|
|
1781
|
-
this._addToDialCodeMap(i, a), this._addToDialCodeMap(e.iso2, a);
|
|
1772
|
+
this.dialCodes = /* @__PURE__ */ new Set(), this.dialCodeMaxLen = 0, this.dialCodeToIso2Map = {};
|
|
1773
|
+
for (const t of this.countries)
|
|
1774
|
+
this.dialCodes.has(t.dialCode) || this.dialCodes.add(t.dialCode), this._addToDialCodeMap(t.iso2, t.dialCode, t.priority);
|
|
1775
|
+
for (const t of this.countries)
|
|
1776
|
+
if (t.areaCodes) {
|
|
1777
|
+
const e = this.dialCodeToIso2Map[t.dialCode][0];
|
|
1778
|
+
for (const i of t.areaCodes) {
|
|
1779
|
+
for (let s = 1; s < i.length; s++) {
|
|
1780
|
+
const n = i.substring(0, s), o = t.dialCode + n;
|
|
1781
|
+
this._addToDialCodeMap(e, o), this._addToDialCodeMap(t.iso2, o);
|
|
1782
1782
|
}
|
|
1783
|
-
this._addToDialCodeMap(
|
|
1783
|
+
this._addToDialCodeMap(t.iso2, t.dialCode + i);
|
|
1784
1784
|
}
|
|
1785
1785
|
}
|
|
1786
|
-
}
|
|
1787
1786
|
}
|
|
1788
1787
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1789
1788
|
_generateMarkup() {
|
|
1790
|
-
var
|
|
1789
|
+
var a, h, b;
|
|
1791
1790
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
1792
1791
|
const {
|
|
1793
1792
|
allowDropdown: t,
|
|
@@ -1796,19 +1795,19 @@ class W {
|
|
|
1796
1795
|
containerClass: s,
|
|
1797
1796
|
hiddenInput: n,
|
|
1798
1797
|
dropdownContainer: o,
|
|
1799
|
-
fixDropdownWidth:
|
|
1800
|
-
useFullscreenPopup:
|
|
1801
|
-
countrySearch:
|
|
1802
|
-
i18n:
|
|
1798
|
+
fixDropdownWidth: l,
|
|
1799
|
+
useFullscreenPopup: r,
|
|
1800
|
+
countrySearch: p,
|
|
1801
|
+
i18n: C
|
|
1803
1802
|
} = this.options;
|
|
1804
|
-
let
|
|
1805
|
-
t && (
|
|
1806
|
-
const
|
|
1807
|
-
if ((
|
|
1803
|
+
let c = "iti";
|
|
1804
|
+
t && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), r || (c += " iti--inline-dropdown");
|
|
1805
|
+
const y = m("div", { class: c });
|
|
1806
|
+
if ((a = this.telInput.parentNode) == null || a.insertBefore(y, this.telInput), t || i || e) {
|
|
1808
1807
|
this.countryContainer = m(
|
|
1809
1808
|
"div",
|
|
1810
1809
|
{ class: "iti__country-container" },
|
|
1811
|
-
|
|
1810
|
+
y
|
|
1812
1811
|
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = m(
|
|
1813
1812
|
"button",
|
|
1814
1813
|
{
|
|
@@ -1826,33 +1825,33 @@ class W {
|
|
|
1826
1825
|
{ class: "iti__selected-country" },
|
|
1827
1826
|
this.countryContainer
|
|
1828
1827
|
);
|
|
1829
|
-
const
|
|
1830
|
-
if (this.selectedCountryInner = m("div", { class: "iti__flag" },
|
|
1828
|
+
const _ = m("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
|
|
1829
|
+
if (this.selectedCountryInner = m("div", { class: "iti__flag" }, _), this.selectedCountryA11yText = m(
|
|
1831
1830
|
"span",
|
|
1832
1831
|
{ class: "iti__a11y-text" },
|
|
1833
1832
|
this.selectedCountryInner
|
|
1834
1833
|
), t && (this.dropdownArrow = m(
|
|
1835
1834
|
"div",
|
|
1836
1835
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1837
|
-
|
|
1836
|
+
_
|
|
1838
1837
|
)), e && (this.selectedDialCode = m(
|
|
1839
1838
|
"div",
|
|
1840
1839
|
{ class: "iti__selected-dial-code", "aria-hidden": "true", dir: "ltr" },
|
|
1841
1840
|
this.selectedCountry
|
|
1842
1841
|
)), t) {
|
|
1843
|
-
const f =
|
|
1842
|
+
const f = l ? "" : "iti--flexible-dropdown-width";
|
|
1844
1843
|
if (this.dropdownContent = m("div", {
|
|
1845
1844
|
id: `iti-${this.id}__dropdown-content`,
|
|
1846
1845
|
class: `iti__dropdown-content iti__hide ${f}`
|
|
1847
|
-
}),
|
|
1846
|
+
}), p && (this.searchInput = m(
|
|
1848
1847
|
"input",
|
|
1849
1848
|
{
|
|
1850
1849
|
type: "text",
|
|
1851
1850
|
class: "iti__search-input",
|
|
1852
|
-
placeholder:
|
|
1851
|
+
placeholder: C.searchPlaceholder,
|
|
1853
1852
|
role: "combobox",
|
|
1854
1853
|
"aria-expanded": "true",
|
|
1855
|
-
"aria-label":
|
|
1854
|
+
"aria-label": C.searchPlaceholder,
|
|
1856
1855
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1857
1856
|
"aria-autocomplete": "list",
|
|
1858
1857
|
autocomplete: "off"
|
|
@@ -1868,31 +1867,31 @@ class W {
|
|
|
1868
1867
|
class: "iti__country-list",
|
|
1869
1868
|
id: `iti-${this.id}__country-listbox`,
|
|
1870
1869
|
role: "listbox",
|
|
1871
|
-
"aria-label":
|
|
1870
|
+
"aria-label": C.countryListAriaLabel
|
|
1872
1871
|
},
|
|
1873
1872
|
this.dropdownContent
|
|
1874
|
-
), this._appendListItems(),
|
|
1875
|
-
let
|
|
1876
|
-
s && (
|
|
1873
|
+
), this._appendListItems(), p && this._updateSearchResultsText(), o) {
|
|
1874
|
+
let g = "iti iti--container";
|
|
1875
|
+
s && (g += ` ${s}`), r ? g += " iti--fullscreen-popup" : g += " iti--inline-dropdown", this.dropdown = m("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
|
|
1877
1876
|
} else
|
|
1878
1877
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1879
1878
|
}
|
|
1880
1879
|
}
|
|
1881
|
-
if (
|
|
1882
|
-
const
|
|
1880
|
+
if (y.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1881
|
+
const _ = this.telInput.getAttribute("name") || "", f = n(_);
|
|
1883
1882
|
if (f.phone) {
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1883
|
+
const g = (h = this.telInput.form) == null ? void 0 : h.querySelector(`input[name="${f.phone}"]`);
|
|
1884
|
+
g ? this.hiddenInput = g : (this.hiddenInput = m("input", {
|
|
1886
1885
|
type: "hidden",
|
|
1887
1886
|
name: f.phone
|
|
1888
|
-
}),
|
|
1887
|
+
}), y.appendChild(this.hiddenInput));
|
|
1889
1888
|
}
|
|
1890
1889
|
if (f.country) {
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1890
|
+
const g = (b = this.telInput.form) == null ? void 0 : b.querySelector(`input[name="${f.country}"]`);
|
|
1891
|
+
g ? this.hiddenInputCountry = g : (this.hiddenInputCountry = m("input", {
|
|
1893
1892
|
type: "hidden",
|
|
1894
1893
|
name: f.country
|
|
1895
|
-
}),
|
|
1894
|
+
}), y.appendChild(this.hiddenInputCountry));
|
|
1896
1895
|
}
|
|
1897
1896
|
}
|
|
1898
1897
|
}
|
|
@@ -1921,12 +1920,12 @@ class W {
|
|
|
1921
1920
|
//* 1. Extracting a dial code from the given number
|
|
1922
1921
|
//* 2. Using explicit initialCountry
|
|
1923
1922
|
_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),
|
|
1925
|
-
if (o && !
|
|
1923
|
+
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), l = A(n), { initialCountry: r, geoIpLookup: p } = this.options, C = r === "auto" && p;
|
|
1924
|
+
if (o && !l)
|
|
1926
1925
|
this._updateCountryFromNumber(n);
|
|
1927
|
-
else if (!
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1926
|
+
else if (!C || t) {
|
|
1927
|
+
const c = r ? r.toLowerCase() : "";
|
|
1928
|
+
c && this._getCountryData(c, !0) ? this._setCountry(c) : o && l ? this._setCountry("us") : this._setCountry();
|
|
1930
1929
|
}
|
|
1931
1930
|
n && this._updateValFromNumber(n);
|
|
1932
1931
|
}
|
|
@@ -1973,10 +1972,10 @@ class W {
|
|
|
1973
1972
|
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
1974
1973
|
(t = "") => {
|
|
1975
1974
|
const e = t.toLowerCase();
|
|
1976
|
-
e && this._getCountryData(e, !0) ? (u.autoCountry = e, setTimeout(() =>
|
|
1975
|
+
e && this._getCountryData(e, !0) ? (u.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
|
|
1977
1976
|
},
|
|
1978
1977
|
() => {
|
|
1979
|
-
this._setInitialState(!0),
|
|
1978
|
+
this._setInitialState(!0), I("rejectAutoCountryPromise");
|
|
1980
1979
|
}
|
|
1981
1980
|
));
|
|
1982
1981
|
}
|
|
@@ -1986,30 +1985,30 @@ class W {
|
|
|
1986
1985
|
//* Initialize the tel input listeners.
|
|
1987
1986
|
_initTelInputListeners() {
|
|
1988
1987
|
const { strictMode: t, formatAsYouType: e, separateDialCode: i, formatOnDisplay: s, allowDropdown: n, countrySearch: o } = this.options;
|
|
1989
|
-
let
|
|
1990
|
-
new RegExp("\\p{L}", "u").test(this.telInput.value) && (
|
|
1991
|
-
if (this.isAndroid && (
|
|
1992
|
-
const
|
|
1993
|
-
this.telInput.value =
|
|
1988
|
+
let l = !1;
|
|
1989
|
+
new RegExp("\\p{L}", "u").test(this.telInput.value) && (l = !0), this._handleInputEvent = (r) => {
|
|
1990
|
+
if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && n && o) {
|
|
1991
|
+
const y = this.telInput.selectionStart || 0, a = this.telInput.value.substring(0, y - 1), h = this.telInput.value.substring(y);
|
|
1992
|
+
this.telInput.value = a + h, this._openDropdownWithPlus();
|
|
1994
1993
|
return;
|
|
1995
1994
|
}
|
|
1996
1995
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
1997
|
-
const
|
|
1998
|
-
|
|
1999
|
-
const
|
|
2000
|
-
if (e && !
|
|
2001
|
-
const
|
|
2002
|
-
this.telInput.value =
|
|
1996
|
+
const p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), C = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
|
|
1997
|
+
p || C && !t ? l = !0 : /[^+0-9]/.test(this.telInput.value) || (l = !1);
|
|
1998
|
+
const c = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
|
|
1999
|
+
if (e && !l && !c) {
|
|
2000
|
+
const y = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, y).replace(/[^+0-9]/g, "").length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", _ = this._formatNumberAsYouType(), f = q(h, _, y, b);
|
|
2001
|
+
this.telInput.value = _, this.telInput.setSelectionRange(f, f);
|
|
2003
2002
|
}
|
|
2004
|
-
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (
|
|
2005
|
-
if (
|
|
2006
|
-
if (i && n && o &&
|
|
2007
|
-
|
|
2003
|
+
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (r) => {
|
|
2004
|
+
if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
|
|
2005
|
+
if (i && n && o && r.key === "+") {
|
|
2006
|
+
r.preventDefault(), this._openDropdownWithPlus();
|
|
2008
2007
|
return;
|
|
2009
2008
|
}
|
|
2010
2009
|
if (t) {
|
|
2011
|
-
const
|
|
2012
|
-
(!
|
|
2010
|
+
const p = this.telInput.value, c = !(p.charAt(0) === "+") && this.telInput.selectionStart === 0 && r.key === "+", y = /^[0-9]$/.test(r.key), a = i ? y : c || y, h = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), b = this._getFullNumber(h), _ = u.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength, T = this._getNewCountryFromNumber(b) !== null;
|
|
2011
|
+
(!a || f && !T && !c) && r.preventDefault();
|
|
2013
2012
|
}
|
|
2014
2013
|
}
|
|
2015
2014
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2017,7 +2016,7 @@ class W {
|
|
|
2017
2016
|
//* Adhere to the input's maxlength attr.
|
|
2018
2017
|
_cap(t) {
|
|
2019
2018
|
const e = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
2020
|
-
return e && t.length > e ? t.
|
|
2019
|
+
return e && t.length > e ? t.substring(0, e) : t;
|
|
2021
2020
|
}
|
|
2022
2021
|
//* Trigger a custom event on the input.
|
|
2023
2022
|
_trigger(t, e = {}) {
|
|
@@ -2085,35 +2084,31 @@ class W {
|
|
|
2085
2084
|
}
|
|
2086
2085
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2087
2086
|
_searchForCountry(t) {
|
|
2088
|
-
for (
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
this._highlightListItem(n, !1), this._scrollTo(n);
|
|
2087
|
+
for (const e of this.countries)
|
|
2088
|
+
if (e.name.substring(0, t.length).toLowerCase() === t) {
|
|
2089
|
+
const s = e.nodeById[this.id];
|
|
2090
|
+
this._highlightListItem(s, !1), this._scrollTo(s);
|
|
2093
2091
|
break;
|
|
2094
2092
|
}
|
|
2095
|
-
}
|
|
2096
2093
|
}
|
|
2097
2094
|
//* Country search enabled: Filter the countries according to the search query.
|
|
2098
2095
|
_filterCountries(t, e = !1) {
|
|
2099
2096
|
let i = !0;
|
|
2100
2097
|
this.countryList.innerHTML = "";
|
|
2101
|
-
const s =
|
|
2102
|
-
for (
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
...
|
|
2108
|
-
...
|
|
2109
|
-
...
|
|
2110
|
-
...c.sort((
|
|
2111
|
-
...y.sort((l, d) => l.priority - d.priority),
|
|
2112
|
-
...p.sort((l, d) => l.priority - d.priority)
|
|
2098
|
+
const s = S(t), n = s.length, o = [], l = [], r = [], p = [], C = [], c = [];
|
|
2099
|
+
for (const a of this.countries)
|
|
2100
|
+
e || n === 0 ? r.push(a) : a.iso2 === s ? o.push(a) : a.normalisedName.startsWith(s) ? l.push(a) : a.normalisedName.includes(s) ? r.push(a) : s === a.dialCode || s === a.dialCodePlus ? p.push(a) : a.dialCodePlus.includes(s) ? C.push(a) : a.initials.includes(s) && c.push(a);
|
|
2101
|
+
const y = [
|
|
2102
|
+
...o.sort((a, h) => a.priority - h.priority),
|
|
2103
|
+
...l.sort((a, h) => a.priority - h.priority),
|
|
2104
|
+
...r.sort((a, h) => a.priority - h.priority),
|
|
2105
|
+
...p.sort((a, h) => a.priority - h.priority),
|
|
2106
|
+
...C.sort((a, h) => a.priority - h.priority),
|
|
2107
|
+
...c.sort((a, h) => a.priority - h.priority)
|
|
2113
2108
|
];
|
|
2114
|
-
for (const
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2109
|
+
for (const a of y) {
|
|
2110
|
+
const h = a.nodeById[this.id];
|
|
2111
|
+
h && (this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1));
|
|
2117
2112
|
}
|
|
2118
2113
|
i && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
|
|
2119
2114
|
}
|
|
@@ -2168,19 +2163,19 @@ class W {
|
|
|
2168
2163
|
let i = e ? t.substring(e) : t;
|
|
2169
2164
|
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2170
2165
|
i = this._ensureHasDialCode(i);
|
|
2171
|
-
const o = this._getDialCode(i, !0),
|
|
2166
|
+
const o = this._getDialCode(i, !0), l = v(i);
|
|
2172
2167
|
if (o) {
|
|
2173
|
-
const
|
|
2174
|
-
if (!s && this.defaultCountry &&
|
|
2168
|
+
const r = v(o), p = this.dialCodeToIso2Map[r];
|
|
2169
|
+
if (!s && this.defaultCountry && p.includes(this.defaultCountry))
|
|
2175
2170
|
return this.defaultCountry;
|
|
2176
|
-
const
|
|
2177
|
-
if (!(n === "1" &&
|
|
2178
|
-
for (
|
|
2179
|
-
if (
|
|
2180
|
-
return
|
|
2171
|
+
const C = this.selectedCountryData.areaCodes && l.length > r.length, c = s && p.includes(s) && !C;
|
|
2172
|
+
if (!(n === "1" && A(l)) && !c) {
|
|
2173
|
+
for (const a of p)
|
|
2174
|
+
if (a)
|
|
2175
|
+
return a;
|
|
2181
2176
|
}
|
|
2182
2177
|
} else {
|
|
2183
|
-
if (i.charAt(0) === "+" &&
|
|
2178
|
+
if (i.charAt(0) === "+" && l.length)
|
|
2184
2179
|
return "";
|
|
2185
2180
|
if ((!i || i === "+") && !this.selectedCountryData.iso2)
|
|
2186
2181
|
return this.defaultCountry;
|
|
@@ -2198,11 +2193,11 @@ class W {
|
|
|
2198
2193
|
e && this.highlightedItem.focus();
|
|
2199
2194
|
}
|
|
2200
2195
|
//* Find the country data for the given iso2 code
|
|
2201
|
-
//* the
|
|
2196
|
+
//* the allowFail option is only used during init() for the initialCountry option, and for the iso2 returned from geoIpLookup - in these 2 cases we don't want to error out
|
|
2202
2197
|
_getCountryData(t, e) {
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2198
|
+
const i = this.countryByIso2.get(t);
|
|
2199
|
+
if (i)
|
|
2200
|
+
return i;
|
|
2206
2201
|
if (e)
|
|
2207
2202
|
return null;
|
|
2208
2203
|
throw new Error(`No country data for '${t}'`);
|
|
@@ -2212,8 +2207,8 @@ class W {
|
|
|
2212
2207
|
_setCountry(t) {
|
|
2213
2208
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2214
2209
|
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountryInner) {
|
|
2215
|
-
let o = "",
|
|
2216
|
-
t && i ? (o = `iti__flag iti__${t}`,
|
|
2210
|
+
let o = "", l = "";
|
|
2211
|
+
t && i ? (o = `iti__flag iti__${t}`, l = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`) : (o = "iti__flag iti__globe", l = s.noCountrySelected), this.selectedCountryInner.className = o, this.selectedCountryA11yText.textContent = l;
|
|
2217
2212
|
}
|
|
2218
2213
|
if (this._setSelectedCountryTitleAttribute(t, e), e) {
|
|
2219
2214
|
const o = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
@@ -2239,11 +2234,11 @@ class W {
|
|
|
2239
2234
|
!1,
|
|
2240
2235
|
n,
|
|
2241
2236
|
!0
|
|
2242
|
-
),
|
|
2237
|
+
), l = o;
|
|
2243
2238
|
for (; u.utils.isPossibleNumber(o, s, i); )
|
|
2244
|
-
|
|
2245
|
-
const
|
|
2246
|
-
this.maxCoreNumberLength =
|
|
2239
|
+
l = o, o += "0";
|
|
2240
|
+
const r = u.utils.getCoreNumber(l, s);
|
|
2241
|
+
this.maxCoreNumberLength = r.length, s === "by" && (this.maxCoreNumberLength = r.length + 1);
|
|
2247
2242
|
} else
|
|
2248
2243
|
this.maxCoreNumberLength = null;
|
|
2249
2244
|
}
|
|
@@ -2280,12 +2275,12 @@ class W {
|
|
|
2280
2275
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2281
2276
|
if (u.utils && n) {
|
|
2282
2277
|
const o = u.utils.numberType[e];
|
|
2283
|
-
let
|
|
2278
|
+
let l = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
2284
2279
|
this.selectedCountryData.iso2,
|
|
2285
2280
|
i,
|
|
2286
2281
|
o
|
|
2287
2282
|
) : "";
|
|
2288
|
-
|
|
2283
|
+
l = this._beforeSetNumber(l), typeof s == "function" && (l = s(l, this.selectedCountryData)), this.telInput.setAttribute("placeholder", l);
|
|
2289
2284
|
}
|
|
2290
2285
|
}
|
|
2291
2286
|
//* Called when the user selects a list item from the dropdown.
|
|
@@ -2307,12 +2302,12 @@ class W {
|
|
|
2307
2302
|
}
|
|
2308
2303
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2309
2304
|
_scrollTo(t) {
|
|
2310
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s,
|
|
2311
|
-
if (
|
|
2312
|
-
e.scrollTop =
|
|
2313
|
-
else if (
|
|
2314
|
-
const
|
|
2315
|
-
e.scrollTop =
|
|
2305
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, l = t.offsetHeight, r = t.getBoundingClientRect().top + i, p = r + l, C = r - n + e.scrollTop;
|
|
2306
|
+
if (r < n)
|
|
2307
|
+
e.scrollTop = C;
|
|
2308
|
+
else if (p > o) {
|
|
2309
|
+
const c = s - l;
|
|
2310
|
+
e.scrollTop = C - c;
|
|
2316
2311
|
}
|
|
2317
2312
|
}
|
|
2318
2313
|
//* Replace any existing dial code with the new one
|
|
@@ -2335,9 +2330,9 @@ class W {
|
|
|
2335
2330
|
const o = t.charAt(n);
|
|
2336
2331
|
if (!isNaN(parseInt(o, 10))) {
|
|
2337
2332
|
if (s += o, e)
|
|
2338
|
-
this.dialCodeToIso2Map[s] && (i = t.
|
|
2339
|
-
else if (this.dialCodes
|
|
2340
|
-
i = t.
|
|
2333
|
+
this.dialCodeToIso2Map[s] && (i = t.substring(0, n + 1));
|
|
2334
|
+
else if (this.dialCodes.has(s)) {
|
|
2335
|
+
i = t.substring(0, n + 1);
|
|
2341
2336
|
break;
|
|
2342
2337
|
}
|
|
2343
2338
|
if (s.length === this.dialCodeMaxLen)
|
|
@@ -2362,7 +2357,7 @@ class W {
|
|
|
2362
2357
|
if (i) {
|
|
2363
2358
|
i = `+${this.selectedCountryData.dialCode}`;
|
|
2364
2359
|
const s = e[i.length] === " " || e[i.length] === "-" ? i.length + 1 : i.length;
|
|
2365
|
-
e = e.
|
|
2360
|
+
e = e.substring(s);
|
|
2366
2361
|
}
|
|
2367
2362
|
}
|
|
2368
2363
|
return this._cap(e);
|
|
@@ -2403,8 +2398,8 @@ class W {
|
|
|
2403
2398
|
"keydown",
|
|
2404
2399
|
this._handleCountryContainerKeydown
|
|
2405
2400
|
);
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2401
|
+
const l = this.telInput.closest("label");
|
|
2402
|
+
l && l.removeEventListener("click", this._handleLabelClick);
|
|
2408
2403
|
}
|
|
2409
2404
|
const { form: i } = this.telInput;
|
|
2410
2405
|
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);
|
|
@@ -2449,30 +2444,27 @@ class W {
|
|
|
2449
2444
|
}
|
|
2450
2445
|
return -99;
|
|
2451
2446
|
}
|
|
2452
|
-
//* Validate the input val
|
|
2447
|
+
//* Validate the input val (with precise=false)
|
|
2453
2448
|
isValidNumber() {
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
return s && n;
|
|
2460
|
-
}
|
|
2461
|
-
return this._utilsIsPossibleNumber(t);
|
|
2449
|
+
return this._validateNumber(!1);
|
|
2450
|
+
}
|
|
2451
|
+
//* Validate the input val (with precise=true)
|
|
2452
|
+
isValidNumberPrecise() {
|
|
2453
|
+
return this._validateNumber(!0);
|
|
2462
2454
|
}
|
|
2463
2455
|
_utilsIsPossibleNumber(t) {
|
|
2464
2456
|
return u.utils ? u.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2465
2457
|
}
|
|
2466
|
-
//*
|
|
2467
|
-
|
|
2458
|
+
//* Shared internal validation logic to handle alpha character extension rules.
|
|
2459
|
+
_validateNumber(t) {
|
|
2468
2460
|
if (!this.selectedCountryData.iso2)
|
|
2469
2461
|
return !1;
|
|
2470
|
-
const
|
|
2471
|
-
if (
|
|
2472
|
-
const
|
|
2473
|
-
return
|
|
2462
|
+
const e = this._getFullNumber(), i = e.search(new RegExp("\\p{L}", "u")), s = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n);
|
|
2463
|
+
if (i > -1) {
|
|
2464
|
+
const n = e.substring(0, i), o = s(n), l = s(e);
|
|
2465
|
+
return o && l;
|
|
2474
2466
|
}
|
|
2475
|
-
return
|
|
2467
|
+
return s(e);
|
|
2476
2468
|
}
|
|
2477
2469
|
_utilsIsValidNumber(t) {
|
|
2478
2470
|
return u.utils ? u.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
@@ -2495,53 +2487,53 @@ class W {
|
|
|
2495
2487
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2496
2488
|
}
|
|
2497
2489
|
}
|
|
2498
|
-
const
|
|
2490
|
+
const Y = (d) => {
|
|
2499
2491
|
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
2500
2492
|
let t;
|
|
2501
|
-
if (typeof
|
|
2493
|
+
if (typeof d == "function")
|
|
2502
2494
|
try {
|
|
2503
|
-
t = Promise.resolve(
|
|
2495
|
+
t = Promise.resolve(d());
|
|
2504
2496
|
} catch (e) {
|
|
2505
2497
|
return Promise.reject(e);
|
|
2506
2498
|
}
|
|
2507
2499
|
else
|
|
2508
|
-
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof
|
|
2500
|
+
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof d}`));
|
|
2509
2501
|
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2510
2502
|
const i = e == null ? void 0 : e.default;
|
|
2511
2503
|
if (!i || typeof i != "object")
|
|
2512
2504
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2513
|
-
return u.utils = i,
|
|
2505
|
+
return u.utils = i, I("handleUtils"), !0;
|
|
2514
2506
|
}).catch((e) => {
|
|
2515
|
-
throw
|
|
2507
|
+
throw I("rejectUtilsScriptPromise", e), e;
|
|
2516
2508
|
});
|
|
2517
2509
|
}
|
|
2518
2510
|
return null;
|
|
2519
2511
|
}, u = Object.assign(
|
|
2520
|
-
(
|
|
2521
|
-
const e = new
|
|
2522
|
-
return e._init(),
|
|
2512
|
+
(d, t) => {
|
|
2513
|
+
const e = new G(d, t);
|
|
2514
|
+
return e._init(), d.setAttribute("data-intl-tel-input-id", e.id.toString()), u.instances[e.id] = e, d.iti = e, e;
|
|
2523
2515
|
},
|
|
2524
2516
|
{
|
|
2525
|
-
defaults:
|
|
2517
|
+
defaults: P,
|
|
2526
2518
|
//* Using a static var like this allows us to mock it in the tests.
|
|
2527
2519
|
documentReady: () => document.readyState === "complete",
|
|
2528
2520
|
//* Get the country data object.
|
|
2529
|
-
getCountryData: () =>
|
|
2521
|
+
getCountryData: () => w,
|
|
2530
2522
|
//* A getter for the plugin instance.
|
|
2531
|
-
getInstance: (
|
|
2532
|
-
const t =
|
|
2523
|
+
getInstance: (d) => {
|
|
2524
|
+
const t = d.getAttribute("data-intl-tel-input-id");
|
|
2533
2525
|
return t ? u.instances[t] : null;
|
|
2534
2526
|
},
|
|
2535
2527
|
//* A map from instance ID to instance object.
|
|
2536
2528
|
instances: {},
|
|
2537
|
-
attachUtils:
|
|
2529
|
+
attachUtils: Y,
|
|
2538
2530
|
startedLoadingUtilsScript: !1,
|
|
2539
2531
|
startedLoadingAutoCountry: !1,
|
|
2540
|
-
version: "25.
|
|
2532
|
+
version: "25.7.0"
|
|
2541
2533
|
}
|
|
2542
|
-
),
|
|
2534
|
+
), Z = {
|
|
2543
2535
|
__name: "IntlTelInput",
|
|
2544
|
-
props: /* @__PURE__ */
|
|
2536
|
+
props: /* @__PURE__ */ N({
|
|
2545
2537
|
disabled: {
|
|
2546
2538
|
type: Boolean,
|
|
2547
2539
|
default: !1
|
|
@@ -2565,45 +2557,45 @@ const G = (h) => {
|
|
|
2565
2557
|
},
|
|
2566
2558
|
modelModifiers: {}
|
|
2567
2559
|
}),
|
|
2568
|
-
emits: /* @__PURE__ */
|
|
2560
|
+
emits: /* @__PURE__ */ N([
|
|
2569
2561
|
"changeNumber",
|
|
2570
2562
|
"changeCountry",
|
|
2571
2563
|
"changeValidity",
|
|
2572
2564
|
"changeErrorCode"
|
|
2573
2565
|
], ["update:modelValue"]),
|
|
2574
|
-
setup(
|
|
2575
|
-
const i = x(
|
|
2576
|
-
let
|
|
2577
|
-
|
|
2566
|
+
setup(d, { expose: t, emit: e }) {
|
|
2567
|
+
const i = x(d, "modelValue"), s = d, n = e, o = L(), l = L(), r = L(!1), p = () => l.value ? s.options.strictMode ? l.value.isValidNumberPrecise() : l.value.isValidNumber() : null, C = () => {
|
|
2568
|
+
let a = p();
|
|
2569
|
+
r.value !== a && (r.value = a, n("changeValidity", !!a), n(
|
|
2578
2570
|
"changeErrorCode",
|
|
2579
|
-
|
|
2571
|
+
a ? null : l.value.getValidationError()
|
|
2580
2572
|
));
|
|
2581
|
-
},
|
|
2582
|
-
var
|
|
2583
|
-
n("changeNumber", ((
|
|
2584
|
-
},
|
|
2585
|
-
var
|
|
2586
|
-
n("changeCountry", ((
|
|
2573
|
+
}, c = () => {
|
|
2574
|
+
var a;
|
|
2575
|
+
n("changeNumber", ((a = l.value) == null ? void 0 : a.getNumber()) ?? ""), C();
|
|
2576
|
+
}, y = () => {
|
|
2577
|
+
var a;
|
|
2578
|
+
n("changeCountry", ((a = l.value) == null ? void 0 : a.getSelectedCountryData().iso2) ?? ""), c(), C();
|
|
2587
2579
|
};
|
|
2588
2580
|
return E(() => {
|
|
2589
|
-
o.value && (
|
|
2581
|
+
o.value && (l.value = u(o.value, s.options), s.value && l.value.setNumber(s.value), s.disabled && l.value.setDisabled(s.disabled), r.value = p());
|
|
2590
2582
|
}), M(
|
|
2591
2583
|
() => s.disabled,
|
|
2592
|
-
(
|
|
2593
|
-
var
|
|
2594
|
-
return (
|
|
2584
|
+
(a) => {
|
|
2585
|
+
var h;
|
|
2586
|
+
return (h = l.value) == null ? void 0 : h.setDisabled(a);
|
|
2595
2587
|
}
|
|
2596
|
-
),
|
|
2597
|
-
var
|
|
2598
|
-
return (
|
|
2599
|
-
}), t({ instance:
|
|
2588
|
+
), B(() => {
|
|
2589
|
+
var a;
|
|
2590
|
+
return (a = l.value) == null ? void 0 : a.destroy();
|
|
2591
|
+
}), t({ instance: l, input: o }), (a, h) => F((z(), V("input", R({
|
|
2600
2592
|
ref_key: "input",
|
|
2601
2593
|
ref: o,
|
|
2602
|
-
"onUpdate:modelValue":
|
|
2594
|
+
"onUpdate:modelValue": h[0] || (h[0] = (b) => i.value = b),
|
|
2603
2595
|
type: "tel",
|
|
2604
|
-
onCountrychange:
|
|
2605
|
-
onInput:
|
|
2606
|
-
},
|
|
2596
|
+
onCountrychange: y,
|
|
2597
|
+
onInput: c
|
|
2598
|
+
}, d.inputProps), null, 16)), [
|
|
2607
2599
|
[
|
|
2608
2600
|
O,
|
|
2609
2601
|
i.value,
|
|
@@ -2614,5 +2606,5 @@ const G = (h) => {
|
|
|
2614
2606
|
}
|
|
2615
2607
|
};
|
|
2616
2608
|
export {
|
|
2617
|
-
|
|
2609
|
+
Z as default
|
|
2618
2610
|
};
|