intl-tel-input 25.4.8 → 25.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/angular/build/intl-tel-input.js +43 -11
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.js +37 -8
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +37 -8
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +36 -7
- package/react/build/IntlTelInput.js +36 -7
- package/react/build/IntlTelInputWithUtils.cjs +36 -7
- package/react/build/IntlTelInputWithUtils.js +36 -7
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +143 -134
- package/vue/build/IntlTelInputWithUtils.mjs +487 -478
|
@@ -1323,9 +1323,9 @@ const N = [
|
|
|
1323
1323
|
"263"
|
|
1324
1324
|
]
|
|
1325
1325
|
], I = [];
|
|
1326
|
-
for (let
|
|
1327
|
-
const t = N[
|
|
1328
|
-
I[
|
|
1326
|
+
for (let h = 0; h < N.length; h++) {
|
|
1327
|
+
const t = N[h];
|
|
1328
|
+
I[h] = {
|
|
1329
1329
|
name: "",
|
|
1330
1330
|
// this is now populated in the plugin
|
|
1331
1331
|
iso2: t[0],
|
|
@@ -1591,8 +1591,8 @@ const j = {
|
|
|
1591
1591
|
ac: "Ascension Island",
|
|
1592
1592
|
xk: "Kosovo"
|
|
1593
1593
|
}, k = { ...j, ...$ };
|
|
1594
|
-
for (let
|
|
1595
|
-
I[
|
|
1594
|
+
for (let h = 0; h < I.length; h++)
|
|
1595
|
+
I[h].name = k[I[h].iso2];
|
|
1596
1596
|
let U = 0;
|
|
1597
1597
|
const T = {
|
|
1598
1598
|
//* Whether or not to allow the dropdown.
|
|
@@ -1667,32 +1667,32 @@ const T = {
|
|
|
1667
1667
|
"887",
|
|
1668
1668
|
"888",
|
|
1669
1669
|
"889"
|
|
1670
|
-
], v = (
|
|
1671
|
-
const t = v(
|
|
1670
|
+
], v = (h) => h.replace(/\D/g, ""), A = (h = "") => h.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (h) => {
|
|
1671
|
+
const t = v(h);
|
|
1672
1672
|
if (t.charAt(0) === "1") {
|
|
1673
1673
|
const e = t.substr(1, 3);
|
|
1674
1674
|
return H.includes(e);
|
|
1675
1675
|
}
|
|
1676
1676
|
return !1;
|
|
1677
|
-
}, K = (
|
|
1677
|
+
}, K = (h, t, e, i) => {
|
|
1678
1678
|
if (e === 0 && !i)
|
|
1679
1679
|
return 0;
|
|
1680
1680
|
let s = 0;
|
|
1681
1681
|
for (let n = 0; n < t.length; n++) {
|
|
1682
|
-
if (/[+0-9]/.test(t[n]) && s++, s ===
|
|
1682
|
+
if (/[+0-9]/.test(t[n]) && s++, s === h && !i)
|
|
1683
1683
|
return n + 1;
|
|
1684
|
-
if (i && s ===
|
|
1684
|
+
if (i && s === h + 1)
|
|
1685
1685
|
return n;
|
|
1686
1686
|
}
|
|
1687
1687
|
return t.length;
|
|
1688
|
-
},
|
|
1689
|
-
const i = document.createElement(
|
|
1688
|
+
}, m = (h, t, e) => {
|
|
1689
|
+
const i = document.createElement(h);
|
|
1690
1690
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1691
|
-
}, w = (
|
|
1692
|
-
const { instances: e } =
|
|
1693
|
-
Object.values(e).forEach((i) => i[
|
|
1691
|
+
}, w = (h, ...t) => {
|
|
1692
|
+
const { instances: e } = u;
|
|
1693
|
+
Object.values(e).forEach((i) => i[h](...t));
|
|
1694
1694
|
};
|
|
1695
|
-
class
|
|
1695
|
+
class W {
|
|
1696
1696
|
constructor(t, e = {}) {
|
|
1697
1697
|
this.id = U++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, T, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1698
1698
|
}
|
|
@@ -1787,7 +1787,7 @@ class G {
|
|
|
1787
1787
|
}
|
|
1788
1788
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1789
1789
|
_generateMarkup() {
|
|
1790
|
-
var
|
|
1790
|
+
var l, d, g;
|
|
1791
1791
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
1792
1792
|
const {
|
|
1793
1793
|
allowDropdown: t,
|
|
@@ -1798,18 +1798,18 @@ class G {
|
|
|
1798
1798
|
dropdownContainer: o,
|
|
1799
1799
|
fixDropdownWidth: r,
|
|
1800
1800
|
useFullscreenPopup: a,
|
|
1801
|
-
countrySearch:
|
|
1802
|
-
i18n:
|
|
1801
|
+
countrySearch: c,
|
|
1802
|
+
i18n: y
|
|
1803
1803
|
} = this.options;
|
|
1804
1804
|
let p = "iti";
|
|
1805
1805
|
t && (p += " iti--allow-dropdown"), i && (p += " iti--show-flags"), s && (p += ` ${s}`), a || (p += " iti--inline-dropdown");
|
|
1806
|
-
const C =
|
|
1807
|
-
if ((
|
|
1808
|
-
this.countryContainer =
|
|
1806
|
+
const C = m("div", { class: p });
|
|
1807
|
+
if ((l = this.telInput.parentNode) == null || l.insertBefore(C, this.telInput), t || i || e) {
|
|
1808
|
+
this.countryContainer = m(
|
|
1809
1809
|
"div",
|
|
1810
1810
|
{ class: "iti__country-container" },
|
|
1811
1811
|
C
|
|
1812
|
-
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry =
|
|
1812
|
+
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = m(
|
|
1813
1813
|
"button",
|
|
1814
1814
|
{
|
|
1815
1815
|
type: "button",
|
|
@@ -1821,75 +1821,75 @@ class G {
|
|
|
1821
1821
|
role: "combobox"
|
|
1822
1822
|
},
|
|
1823
1823
|
this.countryContainer
|
|
1824
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
1824
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
|
|
1825
1825
|
"div",
|
|
1826
1826
|
{ class: "iti__selected-country" },
|
|
1827
1827
|
this.countryContainer
|
|
1828
1828
|
);
|
|
1829
|
-
const
|
|
1830
|
-
if (this.selectedCountryInner =
|
|
1829
|
+
const b = m("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
|
|
1830
|
+
if (this.selectedCountryInner = m("div", { class: "iti__flag" }, b), this.selectedCountryA11yText = m(
|
|
1831
1831
|
"span",
|
|
1832
1832
|
{ class: "iti__a11y-text" },
|
|
1833
1833
|
this.selectedCountryInner
|
|
1834
|
-
), t && (this.dropdownArrow =
|
|
1834
|
+
), t && (this.dropdownArrow = m(
|
|
1835
1835
|
"div",
|
|
1836
1836
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1837
|
-
|
|
1838
|
-
)), e && (this.selectedDialCode =
|
|
1837
|
+
b
|
|
1838
|
+
)), e && (this.selectedDialCode = m(
|
|
1839
1839
|
"div",
|
|
1840
1840
|
{ class: "iti__selected-dial-code" },
|
|
1841
1841
|
this.selectedCountry
|
|
1842
1842
|
)), t) {
|
|
1843
1843
|
const f = r ? "" : "iti--flexible-dropdown-width";
|
|
1844
|
-
if (this.dropdownContent =
|
|
1844
|
+
if (this.dropdownContent = m("div", {
|
|
1845
1845
|
id: `iti-${this.id}__dropdown-content`,
|
|
1846
1846
|
class: `iti__dropdown-content iti__hide ${f}`
|
|
1847
|
-
}),
|
|
1847
|
+
}), c && (this.searchInput = m(
|
|
1848
1848
|
"input",
|
|
1849
1849
|
{
|
|
1850
1850
|
type: "text",
|
|
1851
1851
|
class: "iti__search-input",
|
|
1852
|
-
placeholder:
|
|
1852
|
+
placeholder: y.searchPlaceholder,
|
|
1853
1853
|
role: "combobox",
|
|
1854
1854
|
"aria-expanded": "true",
|
|
1855
|
-
"aria-label":
|
|
1855
|
+
"aria-label": y.searchPlaceholder,
|
|
1856
1856
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1857
1857
|
"aria-autocomplete": "list",
|
|
1858
1858
|
autocomplete: "off"
|
|
1859
1859
|
},
|
|
1860
1860
|
this.dropdownContent
|
|
1861
|
-
), this.searchResultsA11yText =
|
|
1861
|
+
), this.searchResultsA11yText = m(
|
|
1862
1862
|
"span",
|
|
1863
1863
|
{ class: "iti__a11y-text" },
|
|
1864
1864
|
this.dropdownContent
|
|
1865
|
-
)), this.countryList =
|
|
1865
|
+
)), this.countryList = m(
|
|
1866
1866
|
"ul",
|
|
1867
1867
|
{
|
|
1868
1868
|
class: "iti__country-list",
|
|
1869
1869
|
id: `iti-${this.id}__country-listbox`,
|
|
1870
1870
|
role: "listbox",
|
|
1871
|
-
"aria-label":
|
|
1871
|
+
"aria-label": y.countryListAriaLabel
|
|
1872
1872
|
},
|
|
1873
1873
|
this.dropdownContent
|
|
1874
|
-
), this._appendListItems(),
|
|
1875
|
-
let
|
|
1876
|
-
s && (
|
|
1874
|
+
), this._appendListItems(), c && this._updateSearchResultsText(), o) {
|
|
1875
|
+
let _ = "iti iti--container";
|
|
1876
|
+
s && (_ += ` ${s}`), a ? _ += " iti--fullscreen-popup" : _ += " iti--inline-dropdown", this.dropdown = m("div", { class: _ }), this.dropdown.appendChild(this.dropdownContent);
|
|
1877
1877
|
} else
|
|
1878
1878
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1879
1879
|
}
|
|
1880
1880
|
}
|
|
1881
1881
|
if (C.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1882
|
-
const
|
|
1882
|
+
const b = this.telInput.getAttribute("name") || "", f = n(b);
|
|
1883
1883
|
if (f.phone) {
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1884
|
+
const _ = (d = this.telInput.form) == null ? void 0 : d.querySelector(`input[name="${f.phone}"]`);
|
|
1885
|
+
_ ? this.hiddenInput = _ : (this.hiddenInput = m("input", {
|
|
1886
1886
|
type: "hidden",
|
|
1887
1887
|
name: f.phone
|
|
1888
1888
|
}), C.appendChild(this.hiddenInput));
|
|
1889
1889
|
}
|
|
1890
1890
|
if (f.country) {
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1891
|
+
const _ = (g = this.telInput.form) == null ? void 0 : g.querySelector(`input[name="${f.country}"]`);
|
|
1892
|
+
_ ? this.hiddenInputCountry = _ : (this.hiddenInputCountry = m("input", {
|
|
1893
1893
|
type: "hidden",
|
|
1894
1894
|
name: f.country
|
|
1895
1895
|
}), C.appendChild(this.hiddenInputCountry));
|
|
@@ -1899,7 +1899,7 @@ class G {
|
|
|
1899
1899
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1900
1900
|
_appendListItems() {
|
|
1901
1901
|
for (let t = 0; t < this.countries.length; t++) {
|
|
1902
|
-
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s =
|
|
1902
|
+
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = m(
|
|
1903
1903
|
"li",
|
|
1904
1904
|
{
|
|
1905
1905
|
id: `iti-${this.id}__item-${e.iso2}`,
|
|
@@ -1921,10 +1921,10 @@ class G {
|
|
|
1921
1921
|
//* 1. Extracting a dial code from the given number
|
|
1922
1922
|
//* 2. Using explicit initialCountry
|
|
1923
1923
|
_setInitialState(t = !1) {
|
|
1924
|
-
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), r = S(n), { initialCountry: a, geoIpLookup:
|
|
1924
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), r = S(n), { initialCountry: a, geoIpLookup: c } = this.options, y = a === "auto" && c;
|
|
1925
1925
|
if (o && !r)
|
|
1926
1926
|
this._updateCountryFromNumber(n);
|
|
1927
|
-
else if (!
|
|
1927
|
+
else if (!y || t) {
|
|
1928
1928
|
const p = a ? a.toLowerCase() : "";
|
|
1929
1929
|
p && this._getCountryData(p, !0) ? this._setCountry(p) : o && r ? this._setCountry("us") : this._setCountry();
|
|
1930
1930
|
}
|
|
@@ -1962,18 +1962,18 @@ class G {
|
|
|
1962
1962
|
//* Init many requests: utils script / geo ip lookup.
|
|
1963
1963
|
_initRequests() {
|
|
1964
1964
|
let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
|
|
1965
|
-
t && !
|
|
1965
|
+
t && !u.utils ? (this._handlePageLoad = () => {
|
|
1966
1966
|
var n;
|
|
1967
|
-
window.removeEventListener("load", this._handlePageLoad), (n =
|
|
1967
|
+
window.removeEventListener("load", this._handlePageLoad), (n = u.attachUtils(t)) == null || n.catch(() => {
|
|
1968
1968
|
});
|
|
1969
|
-
},
|
|
1969
|
+
}, u.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
1970
1970
|
}
|
|
1971
1971
|
//* Perform the geo ip lookup.
|
|
1972
1972
|
_loadAutoCountry() {
|
|
1973
|
-
|
|
1973
|
+
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
1974
1974
|
(t = "") => {
|
|
1975
1975
|
const e = t.toLowerCase();
|
|
1976
|
-
e && this._getCountryData(e, !0) ? (
|
|
1976
|
+
e && this._getCountryData(e, !0) ? (u.autoCountry = e, setTimeout(() => w("handleAutoCountry"))) : (this._setInitialState(!0), w("rejectAutoCountryPromise"));
|
|
1977
1977
|
},
|
|
1978
1978
|
() => {
|
|
1979
1979
|
this._setInitialState(!0), w("rejectAutoCountryPromise");
|
|
@@ -1989,17 +1989,17 @@ class G {
|
|
|
1989
1989
|
let r = !1;
|
|
1990
1990
|
new RegExp("\\p{L}", "u").test(this.telInput.value) && (r = !0), this._handleInputEvent = (a) => {
|
|
1991
1991
|
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && n && o) {
|
|
1992
|
-
const C = this.telInput.selectionStart || 0,
|
|
1993
|
-
this.telInput.value =
|
|
1992
|
+
const C = this.telInput.selectionStart || 0, l = this.telInput.value.substring(0, C - 1), d = this.telInput.value.substring(C);
|
|
1993
|
+
this.telInput.value = l + d, this._openDropdownWithPlus();
|
|
1994
1994
|
return;
|
|
1995
1995
|
}
|
|
1996
1996
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
1997
|
-
const
|
|
1998
|
-
|
|
1997
|
+
const c = (a == null ? void 0 : a.data) && /[^+0-9]/.test(a.data), y = (a == null ? void 0 : a.inputType) === "insertFromPaste" && this.telInput.value;
|
|
1998
|
+
c || y && !t ? r = !0 : /[^+0-9]/.test(this.telInput.value) || (r = !1);
|
|
1999
1999
|
const p = (a == null ? void 0 : a.detail) && a.detail.isSetNumber && !s;
|
|
2000
2000
|
if (e && !r && !p) {
|
|
2001
|
-
const C = this.telInput.selectionStart || 0,
|
|
2002
|
-
this.telInput.value =
|
|
2001
|
+
const C = this.telInput.selectionStart || 0, d = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length, g = (a == null ? void 0 : a.inputType) === "deleteContentForward", b = this._formatNumberAsYouType(), f = K(d, b, C, g);
|
|
2002
|
+
this.telInput.value = b, this.telInput.setSelectionRange(f, f);
|
|
2003
2003
|
}
|
|
2004
2004
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (a) => {
|
|
2005
2005
|
if (a.key && a.key.length === 1 && !a.altKey && !a.ctrlKey && !a.metaKey) {
|
|
@@ -2008,8 +2008,8 @@ class G {
|
|
|
2008
2008
|
return;
|
|
2009
2009
|
}
|
|
2010
2010
|
if (t) {
|
|
2011
|
-
const
|
|
2012
|
-
(!
|
|
2011
|
+
const c = this.telInput.value, p = !(c.charAt(0) === "+") && this.telInput.selectionStart === 0 && a.key === "+", C = /^[0-9]$/.test(a.key), l = i ? C : p || C, d = c.slice(0, this.telInput.selectionStart) + a.key + c.slice(this.telInput.selectionEnd), g = this._getFullNumber(d), b = u.utils.getCoreNumber(g, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && b.length > this.maxCoreNumberLength, P = this._getNewCountryFromNumber(g) !== null;
|
|
2012
|
+
(!l || f && !P && !p) && a.preventDefault();
|
|
2013
2013
|
}
|
|
2014
2014
|
}
|
|
2015
2015
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2098,13 +2098,22 @@ class G {
|
|
|
2098
2098
|
_filterCountries(t, e = !1) {
|
|
2099
2099
|
let i = !0;
|
|
2100
2100
|
this.countryList.innerHTML = "";
|
|
2101
|
-
const s = A(t);
|
|
2102
|
-
for (let
|
|
2103
|
-
const
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2101
|
+
const s = A(t), n = s.length, o = [], r = [], a = [], c = [], y = [], p = [];
|
|
2102
|
+
for (let l = 0; l < this.countries.length; l++) {
|
|
2103
|
+
const d = this.countries[l], g = A(d.name), b = d.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((f) => f[0]).join("").toLowerCase();
|
|
2104
|
+
e || n === 0 ? a.push(d) : d.iso2.toLowerCase() === s ? o.push(d) : g.startsWith(s) ? r.push(d) : g.includes(s) ? a.push(d) : s === d.dialCode || s === `+${d.dialCode}` ? c.push(d) : `+${d.dialCode}`.includes(s) ? y.push(d) : b.includes(s) && p.push(d);
|
|
2105
|
+
}
|
|
2106
|
+
const C = [
|
|
2107
|
+
...o.sort((l, d) => l.priority - d.priority),
|
|
2108
|
+
...r.sort((l, d) => l.priority - d.priority),
|
|
2109
|
+
...a.sort((l, d) => l.priority - d.priority),
|
|
2110
|
+
...c.sort((l, d) => l.priority - d.priority),
|
|
2111
|
+
...y.sort((l, d) => l.priority - d.priority),
|
|
2112
|
+
...p.sort((l, d) => l.priority - d.priority)
|
|
2113
|
+
];
|
|
2114
|
+
for (const l of C) {
|
|
2115
|
+
const d = l.nodeById[this.id];
|
|
2116
|
+
d && (this.countryList.appendChild(d), i && (this._highlightListItem(d, !1), i = !1));
|
|
2108
2117
|
}
|
|
2109
2118
|
i && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
|
|
2110
2119
|
}
|
|
@@ -2128,9 +2137,9 @@ class G {
|
|
|
2128
2137
|
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2129
2138
|
_updateValFromNumber(t) {
|
|
2130
2139
|
let e = t;
|
|
2131
|
-
if (this.options.formatOnDisplay &&
|
|
2132
|
-
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } =
|
|
2133
|
-
e =
|
|
2140
|
+
if (this.options.formatOnDisplay && u.utils && this.selectedCountryData) {
|
|
2141
|
+
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = u.utils.numberFormat, o = i ? s : n;
|
|
2142
|
+
e = u.utils.formatNumber(
|
|
2134
2143
|
e,
|
|
2135
2144
|
this.selectedCountryData.iso2,
|
|
2136
2145
|
o
|
|
@@ -2161,14 +2170,14 @@ class G {
|
|
|
2161
2170
|
i = this._ensureHasDialCode(i);
|
|
2162
2171
|
const o = this._getDialCode(i, !0), r = v(i);
|
|
2163
2172
|
if (o) {
|
|
2164
|
-
const a = v(o),
|
|
2165
|
-
if (!s && this.defaultCountry &&
|
|
2173
|
+
const a = v(o), c = this.dialCodeToIso2Map[a];
|
|
2174
|
+
if (!s && this.defaultCountry && c.includes(this.defaultCountry))
|
|
2166
2175
|
return this.defaultCountry;
|
|
2167
|
-
const
|
|
2176
|
+
const y = this.selectedCountryData.areaCodes && r.length > a.length, p = s && c.includes(s) && !y;
|
|
2168
2177
|
if (!(n === "1" && S(r)) && !p) {
|
|
2169
|
-
for (let
|
|
2170
|
-
if (
|
|
2171
|
-
return
|
|
2178
|
+
for (let l = 0; l < c.length; l++)
|
|
2179
|
+
if (c[l])
|
|
2180
|
+
return c[l];
|
|
2172
2181
|
}
|
|
2173
2182
|
} else {
|
|
2174
2183
|
if (i.charAt(0) === "+" && r.length)
|
|
@@ -2222,18 +2231,18 @@ class G {
|
|
|
2222
2231
|
//* Update the maximum valid number length for the currently selected country.
|
|
2223
2232
|
_updateMaxLength() {
|
|
2224
2233
|
const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2225
|
-
if (t &&
|
|
2234
|
+
if (t && u.utils)
|
|
2226
2235
|
if (s) {
|
|
2227
|
-
const n =
|
|
2228
|
-
let o =
|
|
2236
|
+
const n = u.utils.numberType[e];
|
|
2237
|
+
let o = u.utils.getExampleNumber(
|
|
2229
2238
|
s,
|
|
2230
2239
|
!1,
|
|
2231
2240
|
n,
|
|
2232
2241
|
!0
|
|
2233
2242
|
), r = o;
|
|
2234
|
-
for (;
|
|
2243
|
+
for (; u.utils.isPossibleNumber(o, s, i); )
|
|
2235
2244
|
r = o, o += "0";
|
|
2236
|
-
const a =
|
|
2245
|
+
const a = u.utils.getCoreNumber(r, s);
|
|
2237
2246
|
this.maxCoreNumberLength = a.length, s === "by" && (this.maxCoreNumberLength = a.length + 1);
|
|
2238
2247
|
} else
|
|
2239
2248
|
this.maxCoreNumberLength = null;
|
|
@@ -2269,9 +2278,9 @@ class G {
|
|
|
2269
2278
|
nationalMode: i,
|
|
2270
2279
|
customPlaceholder: s
|
|
2271
2280
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2272
|
-
if (
|
|
2273
|
-
const o =
|
|
2274
|
-
let r = this.selectedCountryData.iso2 ?
|
|
2281
|
+
if (u.utils && n) {
|
|
2282
|
+
const o = u.utils.numberType[e];
|
|
2283
|
+
let r = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
2275
2284
|
this.selectedCountryData.iso2,
|
|
2276
2285
|
i,
|
|
2277
2286
|
o
|
|
@@ -2298,12 +2307,12 @@ class G {
|
|
|
2298
2307
|
}
|
|
2299
2308
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2300
2309
|
_scrollTo(t) {
|
|
2301
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, r = t.offsetHeight, a = t.getBoundingClientRect().top + i,
|
|
2310
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, r = t.offsetHeight, a = t.getBoundingClientRect().top + i, c = a + r, y = a - n + e.scrollTop;
|
|
2302
2311
|
if (a < n)
|
|
2303
|
-
e.scrollTop =
|
|
2304
|
-
else if (
|
|
2312
|
+
e.scrollTop = y;
|
|
2313
|
+
else if (c > o) {
|
|
2305
2314
|
const p = s - r;
|
|
2306
|
-
e.scrollTop =
|
|
2315
|
+
e.scrollTop = y - p;
|
|
2307
2316
|
}
|
|
2308
2317
|
}
|
|
2309
2318
|
//* Replace any existing dial code with the new one
|
|
@@ -2364,7 +2373,7 @@ class G {
|
|
|
2364
2373
|
}
|
|
2365
2374
|
//* Format the number as the user types.
|
|
2366
2375
|
_formatNumberAsYouType() {
|
|
2367
|
-
const t = this._getFullNumber(), e =
|
|
2376
|
+
const t = this._getFullNumber(), e = u.utils ? u.utils.formatNumberAsYouType(t, this.selectedCountryData.iso2) : t, { dialCode: i } = this.selectedCountryData;
|
|
2368
2377
|
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
|
|
2369
2378
|
}
|
|
2370
2379
|
//**************************
|
|
@@ -2372,11 +2381,11 @@ class G {
|
|
|
2372
2381
|
//**************************
|
|
2373
2382
|
//* This is called when the geoip call returns.
|
|
2374
2383
|
handleAutoCountry() {
|
|
2375
|
-
this.options.initialCountry === "auto" &&
|
|
2384
|
+
this.options.initialCountry === "auto" && u.autoCountry && (this.defaultCountry = u.autoCountry, this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
|
|
2376
2385
|
}
|
|
2377
2386
|
//* This is called when the utils request completes.
|
|
2378
2387
|
handleUtils() {
|
|
2379
|
-
|
|
2388
|
+
u.utils && (this.telInput.value && this._updateValFromNumber(this.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
|
|
2380
2389
|
}
|
|
2381
2390
|
//********************
|
|
2382
2391
|
//* PUBLIC METHODS
|
|
@@ -2400,20 +2409,20 @@ class G {
|
|
|
2400
2409
|
const { form: i } = this.telInput;
|
|
2401
2410
|
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);
|
|
2402
2411
|
const s = this.telInput.parentNode;
|
|
2403
|
-
(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
|
|
2412
|
+
(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 u.instances[this.id];
|
|
2404
2413
|
}
|
|
2405
2414
|
//* Get the extension from the current number.
|
|
2406
2415
|
getExtension() {
|
|
2407
|
-
return
|
|
2416
|
+
return u.utils ? u.utils.getExtension(
|
|
2408
2417
|
this._getFullNumber(),
|
|
2409
2418
|
this.selectedCountryData.iso2
|
|
2410
2419
|
) : "";
|
|
2411
2420
|
}
|
|
2412
2421
|
//* Format the number to the given format.
|
|
2413
2422
|
getNumber(t) {
|
|
2414
|
-
if (
|
|
2423
|
+
if (u.utils) {
|
|
2415
2424
|
const { iso2: e } = this.selectedCountryData;
|
|
2416
|
-
return
|
|
2425
|
+
return u.utils.formatNumber(
|
|
2417
2426
|
this._getFullNumber(),
|
|
2418
2427
|
e,
|
|
2419
2428
|
t
|
|
@@ -2423,7 +2432,7 @@ class G {
|
|
|
2423
2432
|
}
|
|
2424
2433
|
//* Get the type of the entered number e.g. landline/mobile.
|
|
2425
2434
|
getNumberType() {
|
|
2426
|
-
return
|
|
2435
|
+
return u.utils ? u.utils.getNumberType(
|
|
2427
2436
|
this._getFullNumber(),
|
|
2428
2437
|
this.selectedCountryData.iso2
|
|
2429
2438
|
) : -99;
|
|
@@ -2434,9 +2443,9 @@ class G {
|
|
|
2434
2443
|
}
|
|
2435
2444
|
//* Get the validation error.
|
|
2436
2445
|
getValidationError() {
|
|
2437
|
-
if (
|
|
2446
|
+
if (u.utils) {
|
|
2438
2447
|
const { iso2: t } = this.selectedCountryData;
|
|
2439
|
-
return
|
|
2448
|
+
return u.utils.getValidationError(this._getFullNumber(), t);
|
|
2440
2449
|
}
|
|
2441
2450
|
return -99;
|
|
2442
2451
|
}
|
|
@@ -2452,7 +2461,7 @@ class G {
|
|
|
2452
2461
|
return this._utilsIsPossibleNumber(t);
|
|
2453
2462
|
}
|
|
2454
2463
|
_utilsIsPossibleNumber(t) {
|
|
2455
|
-
return
|
|
2464
|
+
return u.utils ? u.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2456
2465
|
}
|
|
2457
2466
|
//* Validate the input val (precise)
|
|
2458
2467
|
isValidNumberPrecise() {
|
|
@@ -2466,7 +2475,7 @@ class G {
|
|
|
2466
2475
|
return this._utilsIsValidNumber(t);
|
|
2467
2476
|
}
|
|
2468
2477
|
_utilsIsValidNumber(t) {
|
|
2469
|
-
return
|
|
2478
|
+
return u.utils ? u.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2470
2479
|
}
|
|
2471
2480
|
//* Update the selected country, and update the input val accordingly.
|
|
2472
2481
|
setCountry(t) {
|
|
@@ -2486,31 +2495,31 @@ class G {
|
|
|
2486
2495
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2487
2496
|
}
|
|
2488
2497
|
}
|
|
2489
|
-
const
|
|
2490
|
-
if (!
|
|
2498
|
+
const G = (h) => {
|
|
2499
|
+
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
2491
2500
|
let t;
|
|
2492
|
-
if (typeof
|
|
2501
|
+
if (typeof h == "function")
|
|
2493
2502
|
try {
|
|
2494
|
-
t = Promise.resolve(
|
|
2503
|
+
t = Promise.resolve(h());
|
|
2495
2504
|
} catch (e) {
|
|
2496
2505
|
return Promise.reject(e);
|
|
2497
2506
|
}
|
|
2498
2507
|
else
|
|
2499
|
-
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
|
|
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 h}`));
|
|
2509
|
+
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2501
2510
|
const i = e == null ? void 0 : e.default;
|
|
2502
2511
|
if (!i || typeof i != "object")
|
|
2503
2512
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2504
|
-
return
|
|
2513
|
+
return u.utils = i, w("handleUtils"), !0;
|
|
2505
2514
|
}).catch((e) => {
|
|
2506
2515
|
throw w("rejectUtilsScriptPromise", e), e;
|
|
2507
2516
|
});
|
|
2508
2517
|
}
|
|
2509
2518
|
return null;
|
|
2510
|
-
},
|
|
2511
|
-
(
|
|
2512
|
-
const e = new
|
|
2513
|
-
return e._init(),
|
|
2519
|
+
}, u = Object.assign(
|
|
2520
|
+
(h, t) => {
|
|
2521
|
+
const e = new W(h, t);
|
|
2522
|
+
return e._init(), h.setAttribute("data-intl-tel-input-id", e.id.toString()), u.instances[e.id] = e, h.iti = e, e;
|
|
2514
2523
|
},
|
|
2515
2524
|
{
|
|
2516
2525
|
defaults: T,
|
|
@@ -2519,16 +2528,16 @@ const W = (u) => {
|
|
|
2519
2528
|
//* Get the country data object.
|
|
2520
2529
|
getCountryData: () => I,
|
|
2521
2530
|
//* A getter for the plugin instance.
|
|
2522
|
-
getInstance: (
|
|
2523
|
-
const t =
|
|
2524
|
-
return t ?
|
|
2531
|
+
getInstance: (h) => {
|
|
2532
|
+
const t = h.getAttribute("data-intl-tel-input-id");
|
|
2533
|
+
return t ? u.instances[t] : null;
|
|
2525
2534
|
},
|
|
2526
2535
|
//* A map from instance ID to instance object.
|
|
2527
2536
|
instances: {},
|
|
2528
|
-
attachUtils:
|
|
2537
|
+
attachUtils: G,
|
|
2529
2538
|
startedLoadingUtilsScript: !1,
|
|
2530
2539
|
startedLoadingAutoCountry: !1,
|
|
2531
|
-
version: "25.
|
|
2540
|
+
version: "25.5.0"
|
|
2532
2541
|
}
|
|
2533
2542
|
), Y = {
|
|
2534
2543
|
__name: "IntlTelInput",
|
|
@@ -2562,39 +2571,39 @@ const W = (u) => {
|
|
|
2562
2571
|
"changeValidity",
|
|
2563
2572
|
"changeErrorCode"
|
|
2564
2573
|
], ["update:modelValue"]),
|
|
2565
|
-
setup(
|
|
2566
|
-
const i = x(
|
|
2567
|
-
let
|
|
2568
|
-
a.value !==
|
|
2574
|
+
setup(h, { expose: t, emit: e }) {
|
|
2575
|
+
const i = x(h, "modelValue"), s = h, n = e, o = L(), r = L(), a = L(!1), c = () => r.value ? s.options.strictMode ? r.value.isValidNumberPrecise() : r.value.isValidNumber() : null, y = () => {
|
|
2576
|
+
let l = c();
|
|
2577
|
+
a.value !== l && (a.value = l, n("changeValidity", !!l), n(
|
|
2569
2578
|
"changeErrorCode",
|
|
2570
|
-
|
|
2579
|
+
l ? null : r.value.getValidationError()
|
|
2571
2580
|
));
|
|
2572
2581
|
}, p = () => {
|
|
2573
|
-
var
|
|
2574
|
-
n("changeNumber", ((
|
|
2582
|
+
var l;
|
|
2583
|
+
n("changeNumber", ((l = r.value) == null ? void 0 : l.getNumber()) ?? ""), y();
|
|
2575
2584
|
}, C = () => {
|
|
2576
|
-
var
|
|
2577
|
-
n("changeCountry", ((
|
|
2585
|
+
var l;
|
|
2586
|
+
n("changeCountry", ((l = r.value) == null ? void 0 : l.getSelectedCountryData().iso2) ?? ""), p(), y();
|
|
2578
2587
|
};
|
|
2579
2588
|
return E(() => {
|
|
2580
|
-
o.value && (r.value =
|
|
2589
|
+
o.value && (r.value = u(o.value, s.options), s.value && r.value.setNumber(s.value), s.disabled && r.value.setDisabled(s.disabled), a.value = c());
|
|
2581
2590
|
}), M(
|
|
2582
2591
|
() => s.disabled,
|
|
2583
|
-
(
|
|
2584
|
-
var
|
|
2585
|
-
return (
|
|
2592
|
+
(l) => {
|
|
2593
|
+
var d;
|
|
2594
|
+
return (d = r.value) == null ? void 0 : d.setDisabled(l);
|
|
2586
2595
|
}
|
|
2587
2596
|
), F(() => {
|
|
2588
|
-
var
|
|
2589
|
-
return (
|
|
2590
|
-
}), t({ instance: r, input: o }), (
|
|
2597
|
+
var l;
|
|
2598
|
+
return (l = r.value) == null ? void 0 : l.destroy();
|
|
2599
|
+
}), t({ instance: r, input: o }), (l, d) => B((z(), V("input", R({
|
|
2591
2600
|
ref_key: "input",
|
|
2592
2601
|
ref: o,
|
|
2593
|
-
"onUpdate:modelValue":
|
|
2602
|
+
"onUpdate:modelValue": d[0] || (d[0] = (g) => i.value = g),
|
|
2594
2603
|
type: "tel",
|
|
2595
2604
|
onCountrychange: C,
|
|
2596
2605
|
onInput: p
|
|
2597
|
-
},
|
|
2606
|
+
}, h.inputProps), null, 16)), [
|
|
2598
2607
|
[
|
|
2599
2608
|
O,
|
|
2600
2609
|
i.value,
|