intl-tel-input 25.8.2 → 25.8.4
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 +7 -7
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +18 -26
- package/angular/build/IntlTelInputWithUtils.js +18 -26
- package/angular/build/types/intl-tel-input.d.ts +0 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +0 -1
- package/build/js/intlTelInput.js +19 -27
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +19 -27
- package/build/js/intlTelInputWithUtils.min.js +4 -4
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +18 -26
- package/react/build/IntlTelInput.d.ts +0 -1
- package/react/build/IntlTelInput.js +18 -26
- package/react/build/IntlTelInputWithUtils.cjs +18 -26
- package/react/build/IntlTelInputWithUtils.js +18 -26
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +227 -232
- package/vue/build/IntlTelInputWithUtils.mjs +377 -382
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as k, useModel as M, ref as D, onMounted as E, watch as B, onUnmounted as R, withDirectives as F, createElementBlock as V, openBlock as z, mergeProps as O, vModelText as j } from "vue";
|
|
2
|
+
const $ = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1323,17 +1323,17 @@ const j = [
|
|
|
1323
1323
|
"263"
|
|
1324
1324
|
]
|
|
1325
1325
|
], w = [];
|
|
1326
|
-
for (const
|
|
1326
|
+
for (const u of $)
|
|
1327
1327
|
w.push({
|
|
1328
1328
|
name: "",
|
|
1329
1329
|
// populated in the plugin
|
|
1330
|
-
iso2:
|
|
1331
|
-
dialCode:
|
|
1332
|
-
priority:
|
|
1333
|
-
areaCodes:
|
|
1330
|
+
iso2: u[0],
|
|
1331
|
+
dialCode: u[1],
|
|
1332
|
+
priority: u[2] || 0,
|
|
1333
|
+
areaCodes: u[3] || null,
|
|
1334
1334
|
nodeById: {},
|
|
1335
1335
|
// populated by the plugin
|
|
1336
|
-
nationalPrefix:
|
|
1336
|
+
nationalPrefix: u[4] || null
|
|
1337
1337
|
});
|
|
1338
1338
|
const U = {
|
|
1339
1339
|
ad: "Andorra",
|
|
@@ -1591,13 +1591,13 @@ const U = {
|
|
|
1591
1591
|
ac: "Ascension Island",
|
|
1592
1592
|
xk: "Kosovo"
|
|
1593
1593
|
}, T = { ...U, ...H };
|
|
1594
|
-
for (const
|
|
1595
|
-
|
|
1594
|
+
for (const u of w)
|
|
1595
|
+
u.name = T[u.iso2];
|
|
1596
1596
|
let K = 0;
|
|
1597
|
-
const
|
|
1597
|
+
const N = (u) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(u).matches, W = () => {
|
|
1598
1598
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
1599
|
-
const
|
|
1600
|
-
return
|
|
1599
|
+
const u = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = N("(max-width: 500px)"), e = N("(max-height: 600px)"), i = N("(pointer: coarse)");
|
|
1600
|
+
return u || t || i && e;
|
|
1601
1601
|
}
|
|
1602
1602
|
return !1;
|
|
1603
1603
|
}, x = {
|
|
@@ -1667,32 +1667,32 @@ const S = (d) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1667
1667
|
"887",
|
|
1668
1668
|
"888",
|
|
1669
1669
|
"889"
|
|
1670
|
-
],
|
|
1671
|
-
const t =
|
|
1670
|
+
], v = (u) => u.replace(/\D/g, ""), A = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), P = (u) => {
|
|
1671
|
+
const t = v(u);
|
|
1672
1672
|
if (t.charAt(0) === "1") {
|
|
1673
1673
|
const e = t.substring(1, 4);
|
|
1674
1674
|
return q.includes(e);
|
|
1675
1675
|
}
|
|
1676
1676
|
return !1;
|
|
1677
|
-
}, G = (
|
|
1677
|
+
}, G = (u, 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 === u && !i)
|
|
1683
1683
|
return n + 1;
|
|
1684
|
-
if (i && s ===
|
|
1684
|
+
if (i && s === u + 1)
|
|
1685
1685
|
return n;
|
|
1686
1686
|
}
|
|
1687
1687
|
return t.length;
|
|
1688
|
-
},
|
|
1689
|
-
const i = document.createElement(
|
|
1688
|
+
}, C = (u, t, e) => {
|
|
1689
|
+
const i = document.createElement(u);
|
|
1690
1690
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1691
|
-
}, I = (
|
|
1692
|
-
const { instances: e } =
|
|
1693
|
-
Object.values(e).forEach((i) => i[
|
|
1691
|
+
}, I = (u, ...t) => {
|
|
1692
|
+
const { instances: e } = l;
|
|
1693
|
+
Object.values(e).forEach((i) => i[u](...t));
|
|
1694
1694
|
};
|
|
1695
|
-
class
|
|
1695
|
+
class L {
|
|
1696
1696
|
/**
|
|
1697
1697
|
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
1698
1698
|
* Only keys with truthy values are included.
|
|
@@ -1725,16 +1725,16 @@ class D {
|
|
|
1725
1725
|
//* Precompute and cache country search tokens to speed up filtering
|
|
1726
1726
|
_cacheSearchTokens() {
|
|
1727
1727
|
for (const t of this.countries)
|
|
1728
|
-
t.normalisedName =
|
|
1728
|
+
t.normalisedName = A(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
|
|
1729
1729
|
}
|
|
1730
1730
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1731
1731
|
_sortCountries() {
|
|
1732
1732
|
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((t) => t.toLowerCase())), this.countries.sort((t, e) => {
|
|
1733
1733
|
const { countryOrder: i } = this.options;
|
|
1734
1734
|
if (i) {
|
|
1735
|
-
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2),
|
|
1736
|
-
if (
|
|
1737
|
-
return
|
|
1735
|
+
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), r = s > -1, o = n > -1;
|
|
1736
|
+
if (r || o)
|
|
1737
|
+
return r && o ? s - n : r ? -1 : 1;
|
|
1738
1738
|
}
|
|
1739
1739
|
return t.name.localeCompare(e.name);
|
|
1740
1740
|
});
|
|
@@ -1785,8 +1785,8 @@ class D {
|
|
|
1785
1785
|
const e = this.dialCodeToIso2Map[t.dialCode][0];
|
|
1786
1786
|
for (const i of t.areaCodes) {
|
|
1787
1787
|
for (let s = 1; s < i.length; s++) {
|
|
1788
|
-
const n = i.substring(0, s),
|
|
1789
|
-
this._addToDialCodeMap(e,
|
|
1788
|
+
const n = i.substring(0, s), r = t.dialCode + n;
|
|
1789
|
+
this._addToDialCodeMap(e, r), this._addToDialCodeMap(t.iso2, r);
|
|
1790
1790
|
}
|
|
1791
1791
|
this._addToDialCodeMap(t.iso2, t.dialCode + i);
|
|
1792
1792
|
}
|
|
@@ -1794,7 +1794,7 @@ class D {
|
|
|
1794
1794
|
}
|
|
1795
1795
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1796
1796
|
_generateMarkup() {
|
|
1797
|
-
var
|
|
1797
|
+
var a, h, g;
|
|
1798
1798
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
1799
1799
|
const {
|
|
1800
1800
|
allowDropdown: t,
|
|
@@ -1802,24 +1802,24 @@ class D {
|
|
|
1802
1802
|
showFlags: i,
|
|
1803
1803
|
containerClass: s,
|
|
1804
1804
|
hiddenInput: n,
|
|
1805
|
-
dropdownContainer:
|
|
1806
|
-
fixDropdownWidth:
|
|
1807
|
-
useFullscreenPopup:
|
|
1808
|
-
countrySearch:
|
|
1805
|
+
dropdownContainer: r,
|
|
1806
|
+
fixDropdownWidth: o,
|
|
1807
|
+
useFullscreenPopup: d,
|
|
1808
|
+
countrySearch: y,
|
|
1809
1809
|
i18n: p
|
|
1810
|
-
} = this.options,
|
|
1810
|
+
} = this.options, c = L._buildClassNames({
|
|
1811
1811
|
iti: !0,
|
|
1812
1812
|
"iti--allow-dropdown": t,
|
|
1813
1813
|
"iti--show-flags": i,
|
|
1814
|
-
"iti--inline-dropdown": !
|
|
1814
|
+
"iti--inline-dropdown": !d,
|
|
1815
1815
|
[s]: !!s
|
|
1816
|
-
}),
|
|
1817
|
-
if ((
|
|
1818
|
-
this.countryContainer =
|
|
1816
|
+
}), m = C("div", { class: c });
|
|
1817
|
+
if ((a = this.telInput.parentNode) == null || a.insertBefore(m, this.telInput), t || i || e) {
|
|
1818
|
+
this.countryContainer = C(
|
|
1819
1819
|
"div",
|
|
1820
1820
|
{ class: "iti__country-container" },
|
|
1821
|
-
|
|
1822
|
-
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry =
|
|
1821
|
+
m
|
|
1822
|
+
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = C(
|
|
1823
1823
|
"button",
|
|
1824
1824
|
{
|
|
1825
1825
|
type: "button",
|
|
@@ -1830,53 +1830,53 @@ class D {
|
|
|
1830
1830
|
"aria-controls": `iti-${this.id}__dropdown-content`
|
|
1831
1831
|
},
|
|
1832
1832
|
this.countryContainer
|
|
1833
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
1833
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = C(
|
|
1834
1834
|
"div",
|
|
1835
1835
|
{ class: "iti__selected-country" },
|
|
1836
1836
|
this.countryContainer
|
|
1837
1837
|
);
|
|
1838
|
-
const
|
|
1838
|
+
const _ = C(
|
|
1839
1839
|
"div",
|
|
1840
1840
|
{ class: "iti__selected-country-primary" },
|
|
1841
1841
|
this.selectedCountry
|
|
1842
1842
|
);
|
|
1843
|
-
if (this.selectedCountryInner =
|
|
1843
|
+
if (this.selectedCountryInner = C(
|
|
1844
1844
|
"div",
|
|
1845
1845
|
{ class: "iti__flag" },
|
|
1846
|
-
|
|
1847
|
-
), t && (this.dropdownArrow =
|
|
1846
|
+
_
|
|
1847
|
+
), t && (this.dropdownArrow = C(
|
|
1848
1848
|
"div",
|
|
1849
1849
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1850
|
-
|
|
1851
|
-
)), e && (this.selectedDialCode =
|
|
1850
|
+
_
|
|
1851
|
+
)), e && (this.selectedDialCode = C(
|
|
1852
1852
|
"div",
|
|
1853
|
-
{ class: "iti__selected-dial-code",
|
|
1853
|
+
{ class: "iti__selected-dial-code", dir: "ltr" },
|
|
1854
1854
|
this.selectedCountry
|
|
1855
1855
|
)), t) {
|
|
1856
|
-
const
|
|
1857
|
-
if (this.dropdownContent =
|
|
1856
|
+
const b = o ? "" : "iti--flexible-dropdown-width";
|
|
1857
|
+
if (this.dropdownContent = C("div", {
|
|
1858
1858
|
id: `iti-${this.id}__dropdown-content`,
|
|
1859
|
-
class: `iti__dropdown-content iti__hide ${
|
|
1859
|
+
class: `iti__dropdown-content iti__hide ${b}`,
|
|
1860
1860
|
role: "dialog",
|
|
1861
1861
|
"aria-modal": "true"
|
|
1862
|
-
}),
|
|
1863
|
-
const
|
|
1862
|
+
}), y) {
|
|
1863
|
+
const f = C(
|
|
1864
1864
|
"div",
|
|
1865
1865
|
{ class: "iti__search-input-wrapper" },
|
|
1866
1866
|
this.dropdownContent
|
|
1867
1867
|
);
|
|
1868
|
-
this.searchIcon =
|
|
1868
|
+
this.searchIcon = C(
|
|
1869
1869
|
"span",
|
|
1870
1870
|
{
|
|
1871
1871
|
class: "iti__search-icon",
|
|
1872
1872
|
"aria-hidden": "true"
|
|
1873
1873
|
},
|
|
1874
|
-
|
|
1874
|
+
f
|
|
1875
1875
|
), this.searchIcon.innerHTML = `
|
|
1876
1876
|
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
|
|
1877
1877
|
<circle cx="11" cy="11" r="7" />
|
|
1878
1878
|
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
1879
|
-
</svg>`, this.searchInput =
|
|
1879
|
+
</svg>`, this.searchInput = C(
|
|
1880
1880
|
"input",
|
|
1881
1881
|
{
|
|
1882
1882
|
id: `iti-${this.id}__search-input`,
|
|
@@ -1892,8 +1892,8 @@ class D {
|
|
|
1892
1892
|
"aria-autocomplete": "list",
|
|
1893
1893
|
autocomplete: "off"
|
|
1894
1894
|
},
|
|
1895
|
-
|
|
1896
|
-
), this.searchClearButton =
|
|
1895
|
+
f
|
|
1896
|
+
), this.searchClearButton = C(
|
|
1897
1897
|
"button",
|
|
1898
1898
|
{
|
|
1899
1899
|
type: "button",
|
|
@@ -1901,21 +1901,21 @@ class D {
|
|
|
1901
1901
|
"aria-label": p.clearSearchAriaLabel,
|
|
1902
1902
|
tabindex: "-1"
|
|
1903
1903
|
},
|
|
1904
|
-
|
|
1904
|
+
f
|
|
1905
1905
|
);
|
|
1906
|
-
const
|
|
1906
|
+
const S = `iti-${this.id}-clear-mask`;
|
|
1907
1907
|
this.searchClearButton.innerHTML = `
|
|
1908
1908
|
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
1909
|
-
<mask id="${
|
|
1909
|
+
<mask id="${S}" maskUnits="userSpaceOnUse">
|
|
1910
1910
|
<rect width="16" height="16" fill="white" />
|
|
1911
1911
|
<path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
|
|
1912
1912
|
</mask>
|
|
1913
|
-
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${
|
|
1914
|
-
</svg>`, this.searchResultsA11yText =
|
|
1913
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${S})" />
|
|
1914
|
+
</svg>`, this.searchResultsA11yText = C(
|
|
1915
1915
|
"span",
|
|
1916
1916
|
{ class: "iti__a11y-text" },
|
|
1917
1917
|
this.dropdownContent
|
|
1918
|
-
), this.searchNoResults =
|
|
1918
|
+
), this.searchNoResults = C(
|
|
1919
1919
|
"div",
|
|
1920
1920
|
{
|
|
1921
1921
|
class: "iti__no-results iti__hide",
|
|
@@ -1925,7 +1925,7 @@ class D {
|
|
|
1925
1925
|
this.dropdownContent
|
|
1926
1926
|
), this.searchNoResults.textContent = p.zeroSearchResults;
|
|
1927
1927
|
}
|
|
1928
|
-
if (this.countryList =
|
|
1928
|
+
if (this.countryList = C(
|
|
1929
1929
|
"ul",
|
|
1930
1930
|
{
|
|
1931
1931
|
class: "iti__country-list",
|
|
@@ -1934,41 +1934,41 @@ class D {
|
|
|
1934
1934
|
"aria-label": p.countryListAriaLabel
|
|
1935
1935
|
},
|
|
1936
1936
|
this.dropdownContent
|
|
1937
|
-
), this._appendListItems(),
|
|
1938
|
-
const
|
|
1937
|
+
), this._appendListItems(), y && this._updateSearchResultsA11yText(), r) {
|
|
1938
|
+
const f = L._buildClassNames({
|
|
1939
1939
|
iti: !0,
|
|
1940
1940
|
"iti--container": !0,
|
|
1941
|
-
"iti--fullscreen-popup":
|
|
1942
|
-
"iti--inline-dropdown": !
|
|
1941
|
+
"iti--fullscreen-popup": d,
|
|
1942
|
+
"iti--inline-dropdown": !d,
|
|
1943
1943
|
[s]: !!s
|
|
1944
1944
|
});
|
|
1945
|
-
this.dropdown =
|
|
1945
|
+
this.dropdown = C("div", { class: f }), this.dropdown.appendChild(this.dropdownContent);
|
|
1946
1946
|
} else
|
|
1947
1947
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1948
1948
|
}
|
|
1949
1949
|
}
|
|
1950
|
-
if (
|
|
1951
|
-
const
|
|
1952
|
-
if (
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1950
|
+
if (m.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1951
|
+
const _ = this.telInput.getAttribute("name") || "", b = n(_);
|
|
1952
|
+
if (b.phone) {
|
|
1953
|
+
const f = (h = this.telInput.form) == null ? void 0 : h.querySelector(`input[name="${b.phone}"]`);
|
|
1954
|
+
f ? this.hiddenInput = f : (this.hiddenInput = C("input", {
|
|
1955
1955
|
type: "hidden",
|
|
1956
|
-
name:
|
|
1957
|
-
}),
|
|
1956
|
+
name: b.phone
|
|
1957
|
+
}), m.appendChild(this.hiddenInput));
|
|
1958
1958
|
}
|
|
1959
|
-
if (
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1959
|
+
if (b.country) {
|
|
1960
|
+
const f = (g = this.telInput.form) == null ? void 0 : g.querySelector(`input[name="${b.country}"]`);
|
|
1961
|
+
f ? this.hiddenInputCountry = f : (this.hiddenInputCountry = C("input", {
|
|
1962
1962
|
type: "hidden",
|
|
1963
|
-
name:
|
|
1964
|
-
}),
|
|
1963
|
+
name: b.country
|
|
1964
|
+
}), m.appendChild(this.hiddenInputCountry));
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
1967
|
}
|
|
1968
1968
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1969
1969
|
_appendListItems() {
|
|
1970
1970
|
for (let t = 0; t < this.countries.length; t++) {
|
|
1971
|
-
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s =
|
|
1971
|
+
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = C(
|
|
1972
1972
|
"li",
|
|
1973
1973
|
{
|
|
1974
1974
|
id: `iti-${this.id}__item-${e.iso2}`,
|
|
@@ -1990,12 +1990,12 @@ class D {
|
|
|
1990
1990
|
//* 1. Extracting a dial code from the given number
|
|
1991
1991
|
//* 2. Using explicit initialCountry
|
|
1992
1992
|
_setInitialState(t = !1) {
|
|
1993
|
-
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i,
|
|
1994
|
-
if (
|
|
1993
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, r = this._getDialCode(n), o = P(n), { initialCountry: d, geoIpLookup: y } = this.options, p = d === "auto" && y;
|
|
1994
|
+
if (r && !o)
|
|
1995
1995
|
this._updateCountryFromNumber(n);
|
|
1996
1996
|
else if (!p || t) {
|
|
1997
|
-
const
|
|
1998
|
-
|
|
1997
|
+
const c = d ? d.toLowerCase() : "";
|
|
1998
|
+
c && this._getCountryData(c, !0) ? this._setCountry(c) : r && o ? this._setCountry("us") : this._setCountry();
|
|
1999
1999
|
}
|
|
2000
2000
|
n && this._updateValFromNumber(n);
|
|
2001
2001
|
}
|
|
@@ -2031,18 +2031,18 @@ class D {
|
|
|
2031
2031
|
//* Init many requests: utils script / geo ip lookup.
|
|
2032
2032
|
_initRequests() {
|
|
2033
2033
|
let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
|
|
2034
|
-
t && !
|
|
2034
|
+
t && !l.utils ? (this._handlePageLoad = () => {
|
|
2035
2035
|
var n;
|
|
2036
|
-
window.removeEventListener("load", this._handlePageLoad), (n =
|
|
2036
|
+
window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(t)) == null || n.catch(() => {
|
|
2037
2037
|
});
|
|
2038
|
-
},
|
|
2038
|
+
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
2039
2039
|
}
|
|
2040
2040
|
//* Perform the geo ip lookup.
|
|
2041
2041
|
_loadAutoCountry() {
|
|
2042
|
-
|
|
2042
|
+
l.autoCountry ? this.handleAutoCountry() : l.startedLoadingAutoCountry || (l.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
2043
2043
|
(t = "") => {
|
|
2044
2044
|
const e = t.toLowerCase();
|
|
2045
|
-
e && this._getCountryData(e, !0) ? (
|
|
2045
|
+
e && this._getCountryData(e, !0) ? (l.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
|
|
2046
2046
|
},
|
|
2047
2047
|
() => {
|
|
2048
2048
|
this._setInitialState(!0), I("rejectAutoCountryPromise");
|
|
@@ -2054,31 +2054,31 @@ class D {
|
|
|
2054
2054
|
}
|
|
2055
2055
|
//* Initialize the tel input listeners.
|
|
2056
2056
|
_initTelInputListeners() {
|
|
2057
|
-
const { strictMode: t, formatAsYouType: e, separateDialCode: i,
|
|
2057
|
+
const { strictMode: t, formatAsYouType: e, separateDialCode: i, allowDropdown: s, countrySearch: n } = this.options;
|
|
2058
2058
|
let r = !1;
|
|
2059
|
-
new RegExp("\\p{L}", "u").test(this.telInput.value) && (r = !0), this._handleInputEvent = (
|
|
2060
|
-
if (this.isAndroid && (
|
|
2061
|
-
const
|
|
2062
|
-
this.telInput.value =
|
|
2059
|
+
new RegExp("\\p{L}", "u").test(this.telInput.value) && (r = !0), this._handleInputEvent = (o) => {
|
|
2060
|
+
if (this.isAndroid && (o == null ? void 0 : o.data) === "+" && i && s && n) {
|
|
2061
|
+
const c = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, c - 1), a = this.telInput.value.substring(c);
|
|
2062
|
+
this.telInput.value = m + a, this._openDropdownWithPlus();
|
|
2063
2063
|
return;
|
|
2064
2064
|
}
|
|
2065
2065
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2068
|
-
const
|
|
2069
|
-
if (e && !r && !
|
|
2070
|
-
const
|
|
2071
|
-
this.telInput.value =
|
|
2066
|
+
const d = (o == null ? void 0 : o.data) && /[^+0-9]/.test(o.data), y = (o == null ? void 0 : o.inputType) === "insertFromPaste" && this.telInput.value;
|
|
2067
|
+
d || y && !t ? r = !0 : /[^+0-9]/.test(this.telInput.value) || (r = !1);
|
|
2068
|
+
const p = (o == null ? void 0 : o.detail) && o.detail.isSetNumber;
|
|
2069
|
+
if (e && !r && !p) {
|
|
2070
|
+
const c = this.telInput.selectionStart || 0, a = this.telInput.value.substring(0, c).replace(/[^+0-9]/g, "").length, h = (o == null ? void 0 : o.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(), _ = G(a, g, c, h);
|
|
2071
|
+
this.telInput.value = g, this.telInput.setSelectionRange(_, _);
|
|
2072
2072
|
}
|
|
2073
|
-
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (
|
|
2074
|
-
if (
|
|
2075
|
-
if (i &&
|
|
2076
|
-
|
|
2073
|
+
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (o) => {
|
|
2074
|
+
if (o.key && o.key.length === 1 && !o.altKey && !o.ctrlKey && !o.metaKey) {
|
|
2075
|
+
if (i && s && n && o.key === "+") {
|
|
2076
|
+
o.preventDefault(), this._openDropdownWithPlus();
|
|
2077
2077
|
return;
|
|
2078
2078
|
}
|
|
2079
2079
|
if (t) {
|
|
2080
|
-
const
|
|
2081
|
-
(!
|
|
2080
|
+
const d = this.telInput.value, p = !(d.charAt(0) === "+") && this.telInput.selectionStart === 0 && o.key === "+", c = /^[0-9]$/.test(o.key), m = i ? c : p || c, a = d.slice(0, this.telInput.selectionStart) + o.key + d.slice(this.telInput.selectionEnd), h = this._getFullNumber(a), g = l.utils.getCoreNumber(h, this.selectedCountryData.iso2), _ = this.maxCoreNumberLength && g.length > this.maxCoreNumberLength, f = this._getNewCountryFromNumber(h) !== null;
|
|
2081
|
+
(!m || _ && !f && !p) && o.preventDefault();
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
2084
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2167,19 +2167,19 @@ class D {
|
|
|
2167
2167
|
_filterCountries(t, e = !1) {
|
|
2168
2168
|
let i = !0;
|
|
2169
2169
|
this.countryList.innerHTML = "";
|
|
2170
|
-
const s =
|
|
2171
|
-
for (const
|
|
2172
|
-
e || n === 0 ?
|
|
2173
|
-
const
|
|
2174
|
-
...
|
|
2175
|
-
...
|
|
2176
|
-
...
|
|
2177
|
-
...
|
|
2178
|
-
...p.sort((
|
|
2179
|
-
...
|
|
2170
|
+
const s = A(t), n = s.length, r = [], o = [], d = [], y = [], p = [], c = [];
|
|
2171
|
+
for (const a of this.countries)
|
|
2172
|
+
e || n === 0 ? d.push(a) : a.iso2 === s ? r.push(a) : a.normalisedName.startsWith(s) ? o.push(a) : a.normalisedName.includes(s) ? d.push(a) : s === a.dialCode || s === a.dialCodePlus ? y.push(a) : a.dialCodePlus.includes(s) ? p.push(a) : a.initials.includes(s) && c.push(a);
|
|
2173
|
+
const m = [
|
|
2174
|
+
...r.sort((a, h) => a.priority - h.priority),
|
|
2175
|
+
...o.sort((a, h) => a.priority - h.priority),
|
|
2176
|
+
...d.sort((a, h) => a.priority - h.priority),
|
|
2177
|
+
...y.sort((a, h) => a.priority - h.priority),
|
|
2178
|
+
...p.sort((a, h) => a.priority - h.priority),
|
|
2179
|
+
...c.sort((a, h) => a.priority - h.priority)
|
|
2180
2180
|
];
|
|
2181
|
-
for (const
|
|
2182
|
-
const h =
|
|
2181
|
+
for (const a of m) {
|
|
2182
|
+
const h = a.nodeById[this.id];
|
|
2183
2183
|
h && (this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1));
|
|
2184
2184
|
}
|
|
2185
2185
|
i ? (this._highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove("iti__hide")) : this.searchNoResults && this.searchNoResults.classList.add("iti__hide"), this.countryList.scrollTop = 0, this._updateSearchResultsA11yText();
|
|
@@ -2204,12 +2204,12 @@ class D {
|
|
|
2204
2204
|
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2205
2205
|
_updateValFromNumber(t) {
|
|
2206
2206
|
let e = t;
|
|
2207
|
-
if (this.options.formatOnDisplay &&
|
|
2208
|
-
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } =
|
|
2209
|
-
e =
|
|
2207
|
+
if (this.options.formatOnDisplay && l.utils && this.selectedCountryData) {
|
|
2208
|
+
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, r = i ? s : n;
|
|
2209
|
+
e = l.utils.formatNumber(
|
|
2210
2210
|
e,
|
|
2211
2211
|
this.selectedCountryData.iso2,
|
|
2212
|
-
|
|
2212
|
+
r
|
|
2213
2213
|
);
|
|
2214
2214
|
}
|
|
2215
2215
|
e = this._beforeSetNumber(e), this.telInput.value = e;
|
|
@@ -2224,8 +2224,8 @@ class D {
|
|
|
2224
2224
|
const { dialCode: e, nationalPrefix: i } = this.selectedCountryData;
|
|
2225
2225
|
if (t.charAt(0) === "+" || !e)
|
|
2226
2226
|
return t;
|
|
2227
|
-
const
|
|
2228
|
-
return `+${e}${
|
|
2227
|
+
const r = i && t.charAt(0) === i && !this.options.separateDialCode ? t.substring(1) : t;
|
|
2228
|
+
return `+${e}${r}`;
|
|
2229
2229
|
}
|
|
2230
2230
|
// Get the country ISO2 code from the given number
|
|
2231
2231
|
// BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
|
|
@@ -2235,19 +2235,19 @@ class D {
|
|
|
2235
2235
|
let i = e ? t.substring(e) : t;
|
|
2236
2236
|
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2237
2237
|
i = this._ensureHasDialCode(i);
|
|
2238
|
-
const
|
|
2239
|
-
if (
|
|
2240
|
-
const
|
|
2241
|
-
if (!s && this.defaultCountry &&
|
|
2238
|
+
const r = this._getDialCode(i, !0), o = v(i);
|
|
2239
|
+
if (r) {
|
|
2240
|
+
const d = v(r), y = this.dialCodeToIso2Map[d];
|
|
2241
|
+
if (!s && this.defaultCountry && y.includes(this.defaultCountry))
|
|
2242
2242
|
return this.defaultCountry;
|
|
2243
|
-
const p = this.selectedCountryData.areaCodes &&
|
|
2244
|
-
if (!(n === "1" && P(
|
|
2245
|
-
for (const
|
|
2246
|
-
if (
|
|
2247
|
-
return
|
|
2243
|
+
const p = this.selectedCountryData.areaCodes && o.length > d.length, c = s && y.includes(s) && !p;
|
|
2244
|
+
if (!(n === "1" && P(o)) && !c) {
|
|
2245
|
+
for (const a of y)
|
|
2246
|
+
if (a)
|
|
2247
|
+
return a;
|
|
2248
2248
|
}
|
|
2249
2249
|
} else {
|
|
2250
|
-
if (i.charAt(0) === "+" &&
|
|
2250
|
+
if (i.charAt(0) === "+" && o.length)
|
|
2251
2251
|
return "";
|
|
2252
2252
|
if ((!i || i === "+") && !this.selectedCountryData.iso2)
|
|
2253
2253
|
return this.defaultCountry;
|
|
@@ -2277,13 +2277,14 @@ class D {
|
|
|
2277
2277
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
2278
2278
|
_setCountry(t) {
|
|
2279
2279
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2280
|
-
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.
|
|
2281
|
-
|
|
2282
|
-
|
|
2280
|
+
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountry) {
|
|
2281
|
+
const r = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
|
|
2282
|
+
let o, d;
|
|
2283
|
+
t ? (d = this.selectedCountryData.name, o = s.selectedCountryAriaLabel.replace("${country}", this.selectedCountryData.name)) : (d = s.noCountrySelected, o = s.noCountrySelected), this.selectedCountryInner.className = r, this.selectedCountry.setAttribute("title", d), this.selectedCountry.setAttribute("aria-label", o);
|
|
2283
2284
|
}
|
|
2284
|
-
if (
|
|
2285
|
-
const
|
|
2286
|
-
this.selectedDialCode.innerHTML =
|
|
2285
|
+
if (e) {
|
|
2286
|
+
const r = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2287
|
+
this.selectedDialCode.innerHTML = r, this._updateInputPadding();
|
|
2287
2288
|
}
|
|
2288
2289
|
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== t;
|
|
2289
2290
|
}
|
|
@@ -2297,28 +2298,22 @@ class D {
|
|
|
2297
2298
|
//* Update the maximum valid number length for the currently selected country.
|
|
2298
2299
|
_updateMaxLength() {
|
|
2299
2300
|
const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2300
|
-
if (t &&
|
|
2301
|
+
if (t && l.utils)
|
|
2301
2302
|
if (s) {
|
|
2302
|
-
const n =
|
|
2303
|
-
let
|
|
2303
|
+
const n = l.utils.numberType[e];
|
|
2304
|
+
let r = l.utils.getExampleNumber(
|
|
2304
2305
|
s,
|
|
2305
2306
|
!1,
|
|
2306
2307
|
n,
|
|
2307
2308
|
!0
|
|
2308
|
-
),
|
|
2309
|
-
for (;
|
|
2310
|
-
|
|
2311
|
-
const
|
|
2312
|
-
this.maxCoreNumberLength =
|
|
2309
|
+
), o = r;
|
|
2310
|
+
for (; l.utils.isPossibleNumber(r, s, i); )
|
|
2311
|
+
o = r, r += "0";
|
|
2312
|
+
const d = l.utils.getCoreNumber(o, s);
|
|
2313
|
+
this.maxCoreNumberLength = d.length, s === "by" && (this.maxCoreNumberLength = d.length + 1);
|
|
2313
2314
|
} else
|
|
2314
2315
|
this.maxCoreNumberLength = null;
|
|
2315
2316
|
}
|
|
2316
|
-
_setSelectedCountryTitleAttribute(t = null, e) {
|
|
2317
|
-
if (!this.selectedCountry)
|
|
2318
|
-
return;
|
|
2319
|
-
let i;
|
|
2320
|
-
t && !e ? i = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : t ? i = this.selectedCountryData.name : i = this.options.i18n.noCountrySelected, this.selectedCountry.setAttribute("title", i);
|
|
2321
|
-
}
|
|
2322
2317
|
//* When the input is in a hidden container during initialisation, we must inject some markup
|
|
2323
2318
|
//* into the end of the DOM to calculate the correct offsetWidth.
|
|
2324
2319
|
//* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry
|
|
@@ -2344,14 +2339,14 @@ class D {
|
|
|
2344
2339
|
nationalMode: i,
|
|
2345
2340
|
customPlaceholder: s
|
|
2346
2341
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2347
|
-
if (
|
|
2348
|
-
const
|
|
2349
|
-
let
|
|
2342
|
+
if (l.utils && n) {
|
|
2343
|
+
const r = l.utils.numberType[e];
|
|
2344
|
+
let o = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
|
|
2350
2345
|
this.selectedCountryData.iso2,
|
|
2351
2346
|
i,
|
|
2352
|
-
|
|
2347
|
+
r
|
|
2353
2348
|
) : "";
|
|
2354
|
-
|
|
2349
|
+
o = this._beforeSetNumber(o), typeof s == "function" && (o = s(o, this.selectedCountryData)), this.telInput.setAttribute("placeholder", o);
|
|
2355
2350
|
}
|
|
2356
2351
|
}
|
|
2357
2352
|
//* Called when the user selects a list item from the dropdown.
|
|
@@ -2359,7 +2354,7 @@ class D {
|
|
|
2359
2354
|
const e = this._setCountry(
|
|
2360
2355
|
t.getAttribute("data-country-code")
|
|
2361
2356
|
);
|
|
2362
|
-
this._closeDropdown(), this._updateDialCode(t.getAttribute("data-dial-code")), this.telInput.focus(), e && this._triggerCountryChange();
|
|
2357
|
+
this._closeDropdown(), this._updateDialCode(t.getAttribute("data-dial-code")), this.options.formatOnDisplay && this._updateValFromNumber(this.telInput.value), this.telInput.focus(), e && this._triggerCountryChange();
|
|
2363
2358
|
}
|
|
2364
2359
|
//* Close the dropdown and unbind any listeners.
|
|
2365
2360
|
_closeDropdown() {
|
|
@@ -2373,12 +2368,12 @@ class D {
|
|
|
2373
2368
|
}
|
|
2374
2369
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2375
2370
|
_scrollTo(t) {
|
|
2376
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i,
|
|
2377
|
-
if (
|
|
2371
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, r = n + s, o = t.offsetHeight, d = t.getBoundingClientRect().top + i, y = d + o, p = d - n + e.scrollTop;
|
|
2372
|
+
if (d < n)
|
|
2378
2373
|
e.scrollTop = p;
|
|
2379
|
-
else if (
|
|
2380
|
-
const
|
|
2381
|
-
e.scrollTop = p -
|
|
2374
|
+
else if (y > r) {
|
|
2375
|
+
const c = s - o;
|
|
2376
|
+
e.scrollTop = p - c;
|
|
2382
2377
|
}
|
|
2383
2378
|
}
|
|
2384
2379
|
//* Replace any existing dial code with the new one
|
|
@@ -2398,9 +2393,9 @@ class D {
|
|
|
2398
2393
|
if (t.charAt(0) === "+") {
|
|
2399
2394
|
let s = "";
|
|
2400
2395
|
for (let n = 0; n < t.length; n++) {
|
|
2401
|
-
const
|
|
2402
|
-
if (!isNaN(parseInt(
|
|
2403
|
-
if (s +=
|
|
2396
|
+
const r = t.charAt(n);
|
|
2397
|
+
if (!isNaN(parseInt(r, 10))) {
|
|
2398
|
+
if (s += r, e)
|
|
2404
2399
|
this.dialCodeToIso2Map[s] && (i = t.substring(0, n + 1));
|
|
2405
2400
|
else if (this.dialCodes.has(s)) {
|
|
2406
2401
|
i = t.substring(0, n + 1);
|
|
@@ -2417,7 +2412,7 @@ class D {
|
|
|
2417
2412
|
_getFullNumber(t) {
|
|
2418
2413
|
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2419
2414
|
let s;
|
|
2420
|
-
const n =
|
|
2415
|
+
const n = v(e);
|
|
2421
2416
|
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2422
2417
|
}
|
|
2423
2418
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
@@ -2439,7 +2434,7 @@ class D {
|
|
|
2439
2434
|
}
|
|
2440
2435
|
//* Format the number as the user types.
|
|
2441
2436
|
_formatNumberAsYouType() {
|
|
2442
|
-
const t = this._getFullNumber(), e =
|
|
2437
|
+
const t = this._getFullNumber(), e = l.utils ? l.utils.formatNumberAsYouType(t, this.selectedCountryData.iso2) : t, { dialCode: i } = this.selectedCountryData;
|
|
2443
2438
|
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
|
|
2444
2439
|
}
|
|
2445
2440
|
//**************************
|
|
@@ -2447,18 +2442,18 @@ class D {
|
|
|
2447
2442
|
//**************************
|
|
2448
2443
|
//* This is called when the geoip call returns.
|
|
2449
2444
|
handleAutoCountry() {
|
|
2450
|
-
this.options.initialCountry === "auto" &&
|
|
2445
|
+
this.options.initialCountry === "auto" && l.autoCountry && (this.defaultCountry = l.autoCountry, this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
|
|
2451
2446
|
}
|
|
2452
2447
|
//* This is called when the utils request completes.
|
|
2453
2448
|
handleUtils() {
|
|
2454
|
-
|
|
2449
|
+
l.utils && (this.telInput.value && this._updateValFromNumber(this.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
|
|
2455
2450
|
}
|
|
2456
2451
|
//********************
|
|
2457
2452
|
//* PUBLIC METHODS
|
|
2458
2453
|
//********************
|
|
2459
2454
|
//* Remove plugin.
|
|
2460
2455
|
destroy() {
|
|
2461
|
-
var n,
|
|
2456
|
+
var n, r;
|
|
2462
2457
|
this.telInput.iti = void 0;
|
|
2463
2458
|
const { allowDropdown: t, separateDialCode: e } = this.options;
|
|
2464
2459
|
if (t) {
|
|
@@ -2469,26 +2464,26 @@ class D {
|
|
|
2469
2464
|
"keydown",
|
|
2470
2465
|
this._handleCountryContainerKeydown
|
|
2471
2466
|
);
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2467
|
+
const o = this.telInput.closest("label");
|
|
2468
|
+
o && o.removeEventListener("click", this._handleLabelClick);
|
|
2474
2469
|
}
|
|
2475
2470
|
const { form: i } = this.telInput;
|
|
2476
2471
|
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);
|
|
2477
2472
|
const s = this.telInput.parentNode;
|
|
2478
|
-
(n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (
|
|
2473
|
+
(n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (r = s == null ? void 0 : s.parentNode) == null || r.removeChild(s), delete l.instances[this.id];
|
|
2479
2474
|
}
|
|
2480
2475
|
//* Get the extension from the current number.
|
|
2481
2476
|
getExtension() {
|
|
2482
|
-
return
|
|
2477
|
+
return l.utils ? l.utils.getExtension(
|
|
2483
2478
|
this._getFullNumber(),
|
|
2484
2479
|
this.selectedCountryData.iso2
|
|
2485
2480
|
) : "";
|
|
2486
2481
|
}
|
|
2487
2482
|
//* Format the number to the given format.
|
|
2488
2483
|
getNumber(t) {
|
|
2489
|
-
if (
|
|
2484
|
+
if (l.utils) {
|
|
2490
2485
|
const { iso2: e } = this.selectedCountryData;
|
|
2491
|
-
return
|
|
2486
|
+
return l.utils.formatNumber(
|
|
2492
2487
|
this._getFullNumber(),
|
|
2493
2488
|
e,
|
|
2494
2489
|
t
|
|
@@ -2498,7 +2493,7 @@ class D {
|
|
|
2498
2493
|
}
|
|
2499
2494
|
//* Get the type of the entered number e.g. landline/mobile.
|
|
2500
2495
|
getNumberType() {
|
|
2501
|
-
return
|
|
2496
|
+
return l.utils ? l.utils.getNumberType(
|
|
2502
2497
|
this._getFullNumber(),
|
|
2503
2498
|
this.selectedCountryData.iso2
|
|
2504
2499
|
) : -99;
|
|
@@ -2509,9 +2504,9 @@ class D {
|
|
|
2509
2504
|
}
|
|
2510
2505
|
//* Get the validation error.
|
|
2511
2506
|
getValidationError() {
|
|
2512
|
-
if (
|
|
2507
|
+
if (l.utils) {
|
|
2513
2508
|
const { iso2: t } = this.selectedCountryData;
|
|
2514
|
-
return
|
|
2509
|
+
return l.utils.getValidationError(this._getFullNumber(), t);
|
|
2515
2510
|
}
|
|
2516
2511
|
return -99;
|
|
2517
2512
|
}
|
|
@@ -2524,7 +2519,7 @@ class D {
|
|
|
2524
2519
|
return this._validateNumber(!0);
|
|
2525
2520
|
}
|
|
2526
2521
|
_utilsIsPossibleNumber(t) {
|
|
2527
|
-
return
|
|
2522
|
+
return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2528
2523
|
}
|
|
2529
2524
|
//* Shared internal validation logic to handle alpha character extension rules.
|
|
2530
2525
|
_validateNumber(t) {
|
|
@@ -2532,18 +2527,18 @@ class D {
|
|
|
2532
2527
|
return !1;
|
|
2533
2528
|
const e = this._getFullNumber(), i = e.search(new RegExp("\\p{L}", "u")), s = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n);
|
|
2534
2529
|
if (i > -1) {
|
|
2535
|
-
const n = e.substring(0, i),
|
|
2536
|
-
return
|
|
2530
|
+
const n = e.substring(0, i), r = s(n), o = s(e);
|
|
2531
|
+
return r && o;
|
|
2537
2532
|
}
|
|
2538
2533
|
return s(e);
|
|
2539
2534
|
}
|
|
2540
2535
|
_utilsIsValidNumber(t) {
|
|
2541
|
-
return
|
|
2536
|
+
return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2542
2537
|
}
|
|
2543
2538
|
//* Update the selected country, and update the input val accordingly.
|
|
2544
2539
|
setCountry(t) {
|
|
2545
2540
|
const e = t == null ? void 0 : t.toLowerCase(), i = this.selectedCountryData.iso2;
|
|
2546
|
-
(t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this._triggerCountryChange());
|
|
2541
|
+
(t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay && this._updateValFromNumber(this.telInput.value), this._triggerCountryChange());
|
|
2547
2542
|
}
|
|
2548
2543
|
//* Set the input value and update the country.
|
|
2549
2544
|
setNumber(t) {
|
|
@@ -2558,31 +2553,31 @@ class D {
|
|
|
2558
2553
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2559
2554
|
}
|
|
2560
2555
|
}
|
|
2561
|
-
const Y = (
|
|
2562
|
-
if (!
|
|
2556
|
+
const Y = (u) => {
|
|
2557
|
+
if (!l.utils && !l.startedLoadingUtilsScript) {
|
|
2563
2558
|
let t;
|
|
2564
|
-
if (typeof
|
|
2559
|
+
if (typeof u == "function")
|
|
2565
2560
|
try {
|
|
2566
|
-
t = Promise.resolve(
|
|
2561
|
+
t = Promise.resolve(u());
|
|
2567
2562
|
} catch (e) {
|
|
2568
2563
|
return Promise.reject(e);
|
|
2569
2564
|
}
|
|
2570
2565
|
else
|
|
2571
|
-
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof
|
|
2572
|
-
return
|
|
2566
|
+
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}`));
|
|
2567
|
+
return l.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2573
2568
|
const i = e == null ? void 0 : e.default;
|
|
2574
2569
|
if (!i || typeof i != "object")
|
|
2575
2570
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2576
|
-
return
|
|
2571
|
+
return l.utils = i, I("handleUtils"), !0;
|
|
2577
2572
|
}).catch((e) => {
|
|
2578
2573
|
throw I("rejectUtilsScriptPromise", e), e;
|
|
2579
2574
|
});
|
|
2580
2575
|
}
|
|
2581
2576
|
return null;
|
|
2582
|
-
},
|
|
2583
|
-
(
|
|
2584
|
-
const e = new
|
|
2585
|
-
return e._init(),
|
|
2577
|
+
}, l = Object.assign(
|
|
2578
|
+
(u, t) => {
|
|
2579
|
+
const e = new L(u, t);
|
|
2580
|
+
return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, u.iti = e, e;
|
|
2586
2581
|
},
|
|
2587
2582
|
{
|
|
2588
2583
|
defaults: x,
|
|
@@ -2591,20 +2586,20 @@ const Y = (d) => {
|
|
|
2591
2586
|
//* Get the country data object.
|
|
2592
2587
|
getCountryData: () => w,
|
|
2593
2588
|
//* A getter for the plugin instance.
|
|
2594
|
-
getInstance: (
|
|
2595
|
-
const t =
|
|
2596
|
-
return t ?
|
|
2589
|
+
getInstance: (u) => {
|
|
2590
|
+
const t = u.getAttribute("data-intl-tel-input-id");
|
|
2591
|
+
return t ? l.instances[t] : null;
|
|
2597
2592
|
},
|
|
2598
2593
|
//* A map from instance ID to instance object.
|
|
2599
2594
|
instances: {},
|
|
2600
2595
|
attachUtils: Y,
|
|
2601
2596
|
startedLoadingUtilsScript: !1,
|
|
2602
2597
|
startedLoadingAutoCountry: !1,
|
|
2603
|
-
version: "25.8.
|
|
2598
|
+
version: "25.8.4"
|
|
2604
2599
|
}
|
|
2605
2600
|
), Z = {
|
|
2606
2601
|
__name: "IntlTelInput",
|
|
2607
|
-
props: /* @__PURE__ */
|
|
2602
|
+
props: /* @__PURE__ */ k({
|
|
2608
2603
|
disabled: {
|
|
2609
2604
|
type: Boolean,
|
|
2610
2605
|
default: !1
|
|
@@ -2628,47 +2623,47 @@ const Y = (d) => {
|
|
|
2628
2623
|
},
|
|
2629
2624
|
modelModifiers: {}
|
|
2630
2625
|
}),
|
|
2631
|
-
emits: /* @__PURE__ */
|
|
2626
|
+
emits: /* @__PURE__ */ k([
|
|
2632
2627
|
"changeNumber",
|
|
2633
2628
|
"changeCountry",
|
|
2634
2629
|
"changeValidity",
|
|
2635
2630
|
"changeErrorCode"
|
|
2636
2631
|
], ["update:modelValue"]),
|
|
2637
|
-
setup(
|
|
2638
|
-
const i = M(
|
|
2639
|
-
let
|
|
2640
|
-
|
|
2632
|
+
setup(u, { expose: t, emit: e }) {
|
|
2633
|
+
const i = M(u, "modelValue"), s = u, n = e, r = D(), o = D(), d = D(!1), y = () => o.value ? s.options.strictMode ? o.value.isValidNumberPrecise() : o.value.isValidNumber() : null, p = () => {
|
|
2634
|
+
let a = y();
|
|
2635
|
+
d.value !== a && (d.value = a, n("changeValidity", !!a), n(
|
|
2641
2636
|
"changeErrorCode",
|
|
2642
|
-
|
|
2637
|
+
a ? null : o.value.getValidationError()
|
|
2643
2638
|
));
|
|
2644
|
-
},
|
|
2645
|
-
var
|
|
2646
|
-
n("changeNumber", ((
|
|
2647
|
-
},
|
|
2648
|
-
var
|
|
2649
|
-
n("changeCountry", ((
|
|
2639
|
+
}, c = () => {
|
|
2640
|
+
var a;
|
|
2641
|
+
n("changeNumber", ((a = o.value) == null ? void 0 : a.getNumber()) ?? ""), p();
|
|
2642
|
+
}, m = () => {
|
|
2643
|
+
var a;
|
|
2644
|
+
n("changeCountry", ((a = o.value) == null ? void 0 : a.getSelectedCountryData().iso2) ?? ""), c(), p();
|
|
2650
2645
|
};
|
|
2651
2646
|
return E(() => {
|
|
2652
|
-
|
|
2647
|
+
r.value && (o.value = l(r.value, s.options), s.value && o.value.setNumber(s.value), s.disabled && o.value.setDisabled(s.disabled), d.value = y());
|
|
2653
2648
|
}), B(
|
|
2654
2649
|
() => s.disabled,
|
|
2655
|
-
(
|
|
2650
|
+
(a) => {
|
|
2656
2651
|
var h;
|
|
2657
|
-
return (h =
|
|
2652
|
+
return (h = o.value) == null ? void 0 : h.setDisabled(a);
|
|
2658
2653
|
}
|
|
2659
2654
|
), R(() => {
|
|
2660
|
-
var
|
|
2661
|
-
return (
|
|
2662
|
-
}), t({ instance:
|
|
2655
|
+
var a;
|
|
2656
|
+
return (a = o.value) == null ? void 0 : a.destroy();
|
|
2657
|
+
}), t({ instance: o, input: r }), (a, h) => F((z(), V("input", O({
|
|
2663
2658
|
ref_key: "input",
|
|
2664
|
-
ref:
|
|
2665
|
-
"onUpdate:modelValue": h[0] || (h[0] = (
|
|
2659
|
+
ref: r,
|
|
2660
|
+
"onUpdate:modelValue": h[0] || (h[0] = (g) => i.value = g),
|
|
2666
2661
|
type: "tel",
|
|
2667
|
-
onCountrychange:
|
|
2668
|
-
onInput:
|
|
2669
|
-
},
|
|
2662
|
+
onCountrychange: m,
|
|
2663
|
+
onInput: c
|
|
2664
|
+
}, u.inputProps), null, 16)), [
|
|
2670
2665
|
[
|
|
2671
|
-
|
|
2666
|
+
j,
|
|
2672
2667
|
i.value,
|
|
2673
2668
|
void 0,
|
|
2674
2669
|
{ lazy: !0 }
|