intl-tel-input 25.8.3 → 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 +10 -4
- package/angular/build/IntlTelInputWithUtils.js +10 -4
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.js +11 -5
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +11 -5
- package/build/js/intlTelInputWithUtils.min.js +4 -4
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +10 -4
- package/react/build/IntlTelInput.js +10 -4
- package/react/build/IntlTelInputWithUtils.cjs +10 -4
- package/react/build/IntlTelInputWithUtils.js +10 -4
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +204 -204
- package/vue/build/IntlTelInputWithUtils.mjs +390 -390
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as k, useModel as M, ref as
|
|
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
2
|
const $ = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
@@ -1323,17 +1323,17 @@ const $ = [
|
|
|
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.
|
|
@@ -1732,9 +1732,9 @@ class D {
|
|
|
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 a, h,
|
|
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 ((a = this.telInput.parentNode) == null || a.insertBefore(
|
|
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
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
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 &&
|
|
2061
|
-
const
|
|
2062
|
-
this.telInput.value =
|
|
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
2073
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (o) => {
|
|
2074
2074
|
if (o.key && o.key.length === 1 && !o.altKey && !o.ctrlKey && !o.metaKey) {
|
|
2075
|
-
if (i &&
|
|
2075
|
+
if (i && s && n && o.key === "+") {
|
|
2076
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,18 +2167,18 @@ class D {
|
|
|
2167
2167
|
_filterCountries(t, e = !1) {
|
|
2168
2168
|
let i = !0;
|
|
2169
2169
|
this.countryList.innerHTML = "";
|
|
2170
|
-
const s = A(t), n = s.length,
|
|
2170
|
+
const s = A(t), n = s.length, r = [], o = [], d = [], y = [], p = [], c = [];
|
|
2171
2171
|
for (const a of this.countries)
|
|
2172
|
-
e || n === 0 ?
|
|
2173
|
-
const
|
|
2174
|
-
...l.sort((a, h) => a.priority - h.priority),
|
|
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 = [
|
|
2175
2174
|
...r.sort((a, h) => a.priority - h.priority),
|
|
2176
2175
|
...o.sort((a, h) => a.priority - h.priority),
|
|
2177
|
-
...
|
|
2176
|
+
...d.sort((a, h) => a.priority - h.priority),
|
|
2177
|
+
...y.sort((a, h) => a.priority - h.priority),
|
|
2178
2178
|
...p.sort((a, h) => a.priority - h.priority),
|
|
2179
|
-
...
|
|
2179
|
+
...c.sort((a, h) => a.priority - h.priority)
|
|
2180
2180
|
];
|
|
2181
|
-
for (const a of
|
|
2181
|
+
for (const a of m) {
|
|
2182
2182
|
const h = a.nodeById[this.id];
|
|
2183
2183
|
h && (this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1));
|
|
2184
2184
|
}
|
|
@@ -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 a of
|
|
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
2246
|
if (a)
|
|
2247
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;
|
|
@@ -2278,13 +2278,13 @@ class D {
|
|
|
2278
2278
|
_setCountry(t) {
|
|
2279
2279
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
|
|
2280
2280
|
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountry) {
|
|
2281
|
-
const
|
|
2282
|
-
let
|
|
2283
|
-
t ? (
|
|
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);
|
|
2284
2284
|
}
|
|
2285
2285
|
if (e) {
|
|
2286
|
-
const
|
|
2287
|
-
this.selectedDialCode.innerHTML =
|
|
2286
|
+
const r = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2287
|
+
this.selectedDialCode.innerHTML = r, this._updateInputPadding();
|
|
2288
2288
|
}
|
|
2289
2289
|
return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== t;
|
|
2290
2290
|
}
|
|
@@ -2298,19 +2298,19 @@ class D {
|
|
|
2298
2298
|
//* Update the maximum valid number length for the currently selected country.
|
|
2299
2299
|
_updateMaxLength() {
|
|
2300
2300
|
const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2301
|
-
if (t &&
|
|
2301
|
+
if (t && l.utils)
|
|
2302
2302
|
if (s) {
|
|
2303
|
-
const n =
|
|
2304
|
-
let
|
|
2303
|
+
const n = l.utils.numberType[e];
|
|
2304
|
+
let r = l.utils.getExampleNumber(
|
|
2305
2305
|
s,
|
|
2306
2306
|
!1,
|
|
2307
2307
|
n,
|
|
2308
2308
|
!0
|
|
2309
|
-
),
|
|
2310
|
-
for (;
|
|
2311
|
-
|
|
2312
|
-
const
|
|
2313
|
-
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);
|
|
2314
2314
|
} else
|
|
2315
2315
|
this.maxCoreNumberLength = null;
|
|
2316
2316
|
}
|
|
@@ -2339,14 +2339,14 @@ class D {
|
|
|
2339
2339
|
nationalMode: i,
|
|
2340
2340
|
customPlaceholder: s
|
|
2341
2341
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2342
|
-
if (
|
|
2343
|
-
const
|
|
2344
|
-
let
|
|
2342
|
+
if (l.utils && n) {
|
|
2343
|
+
const r = l.utils.numberType[e];
|
|
2344
|
+
let o = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
|
|
2345
2345
|
this.selectedCountryData.iso2,
|
|
2346
2346
|
i,
|
|
2347
|
-
|
|
2347
|
+
r
|
|
2348
2348
|
) : "";
|
|
2349
|
-
|
|
2349
|
+
o = this._beforeSetNumber(o), typeof s == "function" && (o = s(o, this.selectedCountryData)), this.telInput.setAttribute("placeholder", o);
|
|
2350
2350
|
}
|
|
2351
2351
|
}
|
|
2352
2352
|
//* Called when the user selects a list item from the dropdown.
|
|
@@ -2354,7 +2354,7 @@ class D {
|
|
|
2354
2354
|
const e = this._setCountry(
|
|
2355
2355
|
t.getAttribute("data-country-code")
|
|
2356
2356
|
);
|
|
2357
|
-
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();
|
|
2358
2358
|
}
|
|
2359
2359
|
//* Close the dropdown and unbind any listeners.
|
|
2360
2360
|
_closeDropdown() {
|
|
@@ -2368,12 +2368,12 @@ class D {
|
|
|
2368
2368
|
}
|
|
2369
2369
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2370
2370
|
_scrollTo(t) {
|
|
2371
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i,
|
|
2372
|
-
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)
|
|
2373
2373
|
e.scrollTop = p;
|
|
2374
|
-
else if (
|
|
2375
|
-
const
|
|
2376
|
-
e.scrollTop = p -
|
|
2374
|
+
else if (y > r) {
|
|
2375
|
+
const c = s - o;
|
|
2376
|
+
e.scrollTop = p - c;
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
2379
|
//* Replace any existing dial code with the new one
|
|
@@ -2393,9 +2393,9 @@ class D {
|
|
|
2393
2393
|
if (t.charAt(0) === "+") {
|
|
2394
2394
|
let s = "";
|
|
2395
2395
|
for (let n = 0; n < t.length; n++) {
|
|
2396
|
-
const
|
|
2397
|
-
if (!isNaN(parseInt(
|
|
2398
|
-
if (s +=
|
|
2396
|
+
const r = t.charAt(n);
|
|
2397
|
+
if (!isNaN(parseInt(r, 10))) {
|
|
2398
|
+
if (s += r, e)
|
|
2399
2399
|
this.dialCodeToIso2Map[s] && (i = t.substring(0, n + 1));
|
|
2400
2400
|
else if (this.dialCodes.has(s)) {
|
|
2401
2401
|
i = t.substring(0, n + 1);
|
|
@@ -2412,7 +2412,7 @@ class D {
|
|
|
2412
2412
|
_getFullNumber(t) {
|
|
2413
2413
|
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2414
2414
|
let s;
|
|
2415
|
-
const n =
|
|
2415
|
+
const n = v(e);
|
|
2416
2416
|
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2417
2417
|
}
|
|
2418
2418
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
@@ -2434,7 +2434,7 @@ class D {
|
|
|
2434
2434
|
}
|
|
2435
2435
|
//* Format the number as the user types.
|
|
2436
2436
|
_formatNumberAsYouType() {
|
|
2437
|
-
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;
|
|
2438
2438
|
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
|
|
2439
2439
|
}
|
|
2440
2440
|
//**************************
|
|
@@ -2442,18 +2442,18 @@ class D {
|
|
|
2442
2442
|
//**************************
|
|
2443
2443
|
//* This is called when the geoip call returns.
|
|
2444
2444
|
handleAutoCountry() {
|
|
2445
|
-
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());
|
|
2446
2446
|
}
|
|
2447
2447
|
//* This is called when the utils request completes.
|
|
2448
2448
|
handleUtils() {
|
|
2449
|
-
|
|
2449
|
+
l.utils && (this.telInput.value && this._updateValFromNumber(this.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
|
|
2450
2450
|
}
|
|
2451
2451
|
//********************
|
|
2452
2452
|
//* PUBLIC METHODS
|
|
2453
2453
|
//********************
|
|
2454
2454
|
//* Remove plugin.
|
|
2455
2455
|
destroy() {
|
|
2456
|
-
var n,
|
|
2456
|
+
var n, r;
|
|
2457
2457
|
this.telInput.iti = void 0;
|
|
2458
2458
|
const { allowDropdown: t, separateDialCode: e } = this.options;
|
|
2459
2459
|
if (t) {
|
|
@@ -2464,26 +2464,26 @@ class D {
|
|
|
2464
2464
|
"keydown",
|
|
2465
2465
|
this._handleCountryContainerKeydown
|
|
2466
2466
|
);
|
|
2467
|
-
const
|
|
2468
|
-
|
|
2467
|
+
const o = this.telInput.closest("label");
|
|
2468
|
+
o && o.removeEventListener("click", this._handleLabelClick);
|
|
2469
2469
|
}
|
|
2470
2470
|
const { form: i } = this.telInput;
|
|
2471
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);
|
|
2472
2472
|
const s = this.telInput.parentNode;
|
|
2473
|
-
(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];
|
|
2474
2474
|
}
|
|
2475
2475
|
//* Get the extension from the current number.
|
|
2476
2476
|
getExtension() {
|
|
2477
|
-
return
|
|
2477
|
+
return l.utils ? l.utils.getExtension(
|
|
2478
2478
|
this._getFullNumber(),
|
|
2479
2479
|
this.selectedCountryData.iso2
|
|
2480
2480
|
) : "";
|
|
2481
2481
|
}
|
|
2482
2482
|
//* Format the number to the given format.
|
|
2483
2483
|
getNumber(t) {
|
|
2484
|
-
if (
|
|
2484
|
+
if (l.utils) {
|
|
2485
2485
|
const { iso2: e } = this.selectedCountryData;
|
|
2486
|
-
return
|
|
2486
|
+
return l.utils.formatNumber(
|
|
2487
2487
|
this._getFullNumber(),
|
|
2488
2488
|
e,
|
|
2489
2489
|
t
|
|
@@ -2493,7 +2493,7 @@ class D {
|
|
|
2493
2493
|
}
|
|
2494
2494
|
//* Get the type of the entered number e.g. landline/mobile.
|
|
2495
2495
|
getNumberType() {
|
|
2496
|
-
return
|
|
2496
|
+
return l.utils ? l.utils.getNumberType(
|
|
2497
2497
|
this._getFullNumber(),
|
|
2498
2498
|
this.selectedCountryData.iso2
|
|
2499
2499
|
) : -99;
|
|
@@ -2504,9 +2504,9 @@ class D {
|
|
|
2504
2504
|
}
|
|
2505
2505
|
//* Get the validation error.
|
|
2506
2506
|
getValidationError() {
|
|
2507
|
-
if (
|
|
2507
|
+
if (l.utils) {
|
|
2508
2508
|
const { iso2: t } = this.selectedCountryData;
|
|
2509
|
-
return
|
|
2509
|
+
return l.utils.getValidationError(this._getFullNumber(), t);
|
|
2510
2510
|
}
|
|
2511
2511
|
return -99;
|
|
2512
2512
|
}
|
|
@@ -2519,7 +2519,7 @@ class D {
|
|
|
2519
2519
|
return this._validateNumber(!0);
|
|
2520
2520
|
}
|
|
2521
2521
|
_utilsIsPossibleNumber(t) {
|
|
2522
|
-
return
|
|
2522
|
+
return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2523
2523
|
}
|
|
2524
2524
|
//* Shared internal validation logic to handle alpha character extension rules.
|
|
2525
2525
|
_validateNumber(t) {
|
|
@@ -2527,18 +2527,18 @@ class D {
|
|
|
2527
2527
|
return !1;
|
|
2528
2528
|
const e = this._getFullNumber(), i = e.search(new RegExp("\\p{L}", "u")), s = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n);
|
|
2529
2529
|
if (i > -1) {
|
|
2530
|
-
const n = e.substring(0, i),
|
|
2531
|
-
return
|
|
2530
|
+
const n = e.substring(0, i), r = s(n), o = s(e);
|
|
2531
|
+
return r && o;
|
|
2532
2532
|
}
|
|
2533
2533
|
return s(e);
|
|
2534
2534
|
}
|
|
2535
2535
|
_utilsIsValidNumber(t) {
|
|
2536
|
-
return
|
|
2536
|
+
return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2537
2537
|
}
|
|
2538
2538
|
//* Update the selected country, and update the input val accordingly.
|
|
2539
2539
|
setCountry(t) {
|
|
2540
2540
|
const e = t == null ? void 0 : t.toLowerCase(), i = this.selectedCountryData.iso2;
|
|
2541
|
-
(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());
|
|
2542
2542
|
}
|
|
2543
2543
|
//* Set the input value and update the country.
|
|
2544
2544
|
setNumber(t) {
|
|
@@ -2553,31 +2553,31 @@ class D {
|
|
|
2553
2553
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2554
2554
|
}
|
|
2555
2555
|
}
|
|
2556
|
-
const Y = (
|
|
2557
|
-
if (!
|
|
2556
|
+
const Y = (u) => {
|
|
2557
|
+
if (!l.utils && !l.startedLoadingUtilsScript) {
|
|
2558
2558
|
let t;
|
|
2559
|
-
if (typeof
|
|
2559
|
+
if (typeof u == "function")
|
|
2560
2560
|
try {
|
|
2561
|
-
t = Promise.resolve(
|
|
2561
|
+
t = Promise.resolve(u());
|
|
2562
2562
|
} catch (e) {
|
|
2563
2563
|
return Promise.reject(e);
|
|
2564
2564
|
}
|
|
2565
2565
|
else
|
|
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
|
|
2567
|
-
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) => {
|
|
2568
2568
|
const i = e == null ? void 0 : e.default;
|
|
2569
2569
|
if (!i || typeof i != "object")
|
|
2570
2570
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2571
|
-
return
|
|
2571
|
+
return l.utils = i, I("handleUtils"), !0;
|
|
2572
2572
|
}).catch((e) => {
|
|
2573
2573
|
throw I("rejectUtilsScriptPromise", e), e;
|
|
2574
2574
|
});
|
|
2575
2575
|
}
|
|
2576
2576
|
return null;
|
|
2577
|
-
},
|
|
2578
|
-
(
|
|
2579
|
-
const e = new
|
|
2580
|
-
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;
|
|
2581
2581
|
},
|
|
2582
2582
|
{
|
|
2583
2583
|
defaults: x,
|
|
@@ -2586,16 +2586,16 @@ const Y = (d) => {
|
|
|
2586
2586
|
//* Get the country data object.
|
|
2587
2587
|
getCountryData: () => w,
|
|
2588
2588
|
//* A getter for the plugin instance.
|
|
2589
|
-
getInstance: (
|
|
2590
|
-
const t =
|
|
2591
|
-
return t ?
|
|
2589
|
+
getInstance: (u) => {
|
|
2590
|
+
const t = u.getAttribute("data-intl-tel-input-id");
|
|
2591
|
+
return t ? l.instances[t] : null;
|
|
2592
2592
|
},
|
|
2593
2593
|
//* A map from instance ID to instance object.
|
|
2594
2594
|
instances: {},
|
|
2595
2595
|
attachUtils: Y,
|
|
2596
2596
|
startedLoadingUtilsScript: !1,
|
|
2597
2597
|
startedLoadingAutoCountry: !1,
|
|
2598
|
-
version: "25.8.
|
|
2598
|
+
version: "25.8.4"
|
|
2599
2599
|
}
|
|
2600
2600
|
), Z = {
|
|
2601
2601
|
__name: "IntlTelInput",
|
|
@@ -2629,39 +2629,39 @@ const Y = (d) => {
|
|
|
2629
2629
|
"changeValidity",
|
|
2630
2630
|
"changeErrorCode"
|
|
2631
2631
|
], ["update:modelValue"]),
|
|
2632
|
-
setup(
|
|
2633
|
-
const i = M(
|
|
2634
|
-
let a =
|
|
2635
|
-
|
|
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(
|
|
2636
2636
|
"changeErrorCode",
|
|
2637
|
-
a ? null :
|
|
2637
|
+
a ? null : o.value.getValidationError()
|
|
2638
2638
|
));
|
|
2639
|
-
},
|
|
2639
|
+
}, c = () => {
|
|
2640
2640
|
var a;
|
|
2641
|
-
n("changeNumber", ((a =
|
|
2642
|
-
},
|
|
2641
|
+
n("changeNumber", ((a = o.value) == null ? void 0 : a.getNumber()) ?? ""), p();
|
|
2642
|
+
}, m = () => {
|
|
2643
2643
|
var a;
|
|
2644
|
-
n("changeCountry", ((a =
|
|
2644
|
+
n("changeCountry", ((a = o.value) == null ? void 0 : a.getSelectedCountryData().iso2) ?? ""), c(), p();
|
|
2645
2645
|
};
|
|
2646
2646
|
return E(() => {
|
|
2647
|
-
|
|
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());
|
|
2648
2648
|
}), B(
|
|
2649
2649
|
() => s.disabled,
|
|
2650
2650
|
(a) => {
|
|
2651
2651
|
var h;
|
|
2652
|
-
return (h =
|
|
2652
|
+
return (h = o.value) == null ? void 0 : h.setDisabled(a);
|
|
2653
2653
|
}
|
|
2654
2654
|
), R(() => {
|
|
2655
2655
|
var a;
|
|
2656
|
-
return (a =
|
|
2657
|
-
}), t({ instance:
|
|
2656
|
+
return (a = o.value) == null ? void 0 : a.destroy();
|
|
2657
|
+
}), t({ instance: o, input: r }), (a, h) => F((z(), V("input", O({
|
|
2658
2658
|
ref_key: "input",
|
|
2659
|
-
ref:
|
|
2660
|
-
"onUpdate:modelValue": h[0] || (h[0] = (
|
|
2659
|
+
ref: r,
|
|
2660
|
+
"onUpdate:modelValue": h[0] || (h[0] = (g) => i.value = g),
|
|
2661
2661
|
type: "tel",
|
|
2662
|
-
onCountrychange:
|
|
2663
|
-
onInput:
|
|
2664
|
-
},
|
|
2662
|
+
onCountrychange: m,
|
|
2663
|
+
onInput: c
|
|
2664
|
+
}, u.inputProps), null, 16)), [
|
|
2665
2665
|
[
|
|
2666
2666
|
j,
|
|
2667
2667
|
i.value,
|