intl-tel-input 25.10.5 → 25.10.6
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 +6 -6
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +64 -53
- package/angular/build/IntlTelInputWithUtils.js +64 -53
- package/build/js/data.js +8 -8
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.js +65 -54
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +65 -54
- package/build/js/intlTelInputWithUtils.min.js +4 -4
- package/package.json +11 -6
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +64 -53
- package/react/build/IntlTelInput.js +64 -53
- package/react/build/IntlTelInputWithUtils.cjs +64 -53
- package/react/build/IntlTelInputWithUtils.js +64 -53
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +142 -130
- package/vue/build/IntlTelInputWithUtils.mjs +203 -191
|
@@ -1226,6 +1226,13 @@ const j = [
|
|
|
1226
1226
|
// Tuvalu
|
|
1227
1227
|
"688"
|
|
1228
1228
|
],
|
|
1229
|
+
[
|
|
1230
|
+
"vi",
|
|
1231
|
+
// U.S. Virgin Islands
|
|
1232
|
+
"1",
|
|
1233
|
+
24,
|
|
1234
|
+
["340"]
|
|
1235
|
+
],
|
|
1229
1236
|
[
|
|
1230
1237
|
"ug",
|
|
1231
1238
|
// Uganda
|
|
@@ -1260,13 +1267,6 @@ const j = [
|
|
|
1260
1267
|
// Uruguay
|
|
1261
1268
|
"598"
|
|
1262
1269
|
],
|
|
1263
|
-
[
|
|
1264
|
-
"vi",
|
|
1265
|
-
// U.S. Virgin Islands
|
|
1266
|
-
"1",
|
|
1267
|
-
24,
|
|
1268
|
-
["340"]
|
|
1269
|
-
],
|
|
1270
1270
|
[
|
|
1271
1271
|
"uz",
|
|
1272
1272
|
// Uzbekistan
|
|
@@ -1651,7 +1651,7 @@ const N = (u) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1651
1651
|
useFullscreenPopup: W(),
|
|
1652
1652
|
//* The number type to enforce during validation.
|
|
1653
1653
|
validationNumberTypes: ["MOBILE"]
|
|
1654
|
-
},
|
|
1654
|
+
}, G = [
|
|
1655
1655
|
"800",
|
|
1656
1656
|
"822",
|
|
1657
1657
|
"833",
|
|
@@ -1673,10 +1673,10 @@ const N = (u) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1673
1673
|
const t = v(u);
|
|
1674
1674
|
if (t.charAt(0) === "1") {
|
|
1675
1675
|
const e = t.substring(1, 4);
|
|
1676
|
-
return
|
|
1676
|
+
return G.includes(e);
|
|
1677
1677
|
}
|
|
1678
1678
|
return !1;
|
|
1679
|
-
},
|
|
1679
|
+
}, q = (u, t, e, i) => {
|
|
1680
1680
|
if (e === 0 && !i)
|
|
1681
1681
|
return 0;
|
|
1682
1682
|
let s = 0;
|
|
@@ -1734,15 +1734,17 @@ class L {
|
|
|
1734
1734
|
this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((t) => t.toLowerCase())), this.countries.sort((t, e) => {
|
|
1735
1735
|
const { countryOrder: i } = this.options;
|
|
1736
1736
|
if (i) {
|
|
1737
|
-
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2),
|
|
1738
|
-
if (
|
|
1739
|
-
return
|
|
1737
|
+
const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), a = s > -1, o = n > -1;
|
|
1738
|
+
if (a || o)
|
|
1739
|
+
return a && o ? s - n : a ? -1 : 1;
|
|
1740
1740
|
}
|
|
1741
1741
|
return t.name.localeCompare(e.name);
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
1744
|
//* Add a dial code to this.dialCodeToIso2Map.
|
|
1745
1745
|
_addToDialCodeMap(t, e, i) {
|
|
1746
|
+
if (!t || !e)
|
|
1747
|
+
return;
|
|
1746
1748
|
e.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = e.length), this.dialCodeToIso2Map.hasOwnProperty(e) || (this.dialCodeToIso2Map[e] = []);
|
|
1747
1749
|
const s = this.dialCodeToIso2Map[e];
|
|
1748
1750
|
if (s.includes(t))
|
|
@@ -1782,13 +1784,16 @@ class L {
|
|
|
1782
1784
|
this.dialCodes = /* @__PURE__ */ new Set(), this.dialCodeMaxLen = 0, this.dialCodeToIso2Map = {};
|
|
1783
1785
|
for (const t of this.countries)
|
|
1784
1786
|
this.dialCodes.has(t.dialCode) || this.dialCodes.add(t.dialCode), this._addToDialCodeMap(t.iso2, t.dialCode, t.priority);
|
|
1787
|
+
(this.options.onlyCountries.length || this.options.excludeCountries.length) && this.dialCodes.forEach((t) => {
|
|
1788
|
+
this.dialCodeToIso2Map[t] = this.dialCodeToIso2Map[t].filter(Boolean);
|
|
1789
|
+
});
|
|
1785
1790
|
for (const t of this.countries)
|
|
1786
1791
|
if (t.areaCodes) {
|
|
1787
1792
|
const e = this.dialCodeToIso2Map[t.dialCode][0];
|
|
1788
1793
|
for (const i of t.areaCodes) {
|
|
1789
1794
|
for (let s = 1; s < i.length; s++) {
|
|
1790
|
-
const n = i.substring(0, s),
|
|
1791
|
-
this._addToDialCodeMap(e,
|
|
1795
|
+
const n = i.substring(0, s), a = t.dialCode + n;
|
|
1796
|
+
this._addToDialCodeMap(e, a), this._addToDialCodeMap(t.iso2, a);
|
|
1792
1797
|
}
|
|
1793
1798
|
this._addToDialCodeMap(t.iso2, t.dialCode + i);
|
|
1794
1799
|
}
|
|
@@ -1796,7 +1801,7 @@ class L {
|
|
|
1796
1801
|
}
|
|
1797
1802
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1798
1803
|
_generateMarkup() {
|
|
1799
|
-
var
|
|
1804
|
+
var p, m, g;
|
|
1800
1805
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
1801
1806
|
const {
|
|
1802
1807
|
allowDropdown: t,
|
|
@@ -1804,24 +1809,24 @@ class L {
|
|
|
1804
1809
|
showFlags: i,
|
|
1805
1810
|
containerClass: s,
|
|
1806
1811
|
hiddenInput: n,
|
|
1807
|
-
dropdownContainer:
|
|
1812
|
+
dropdownContainer: a,
|
|
1808
1813
|
fixDropdownWidth: o,
|
|
1809
1814
|
useFullscreenPopup: d,
|
|
1810
|
-
countrySearch:
|
|
1811
|
-
i18n:
|
|
1812
|
-
} = this.options,
|
|
1815
|
+
countrySearch: c,
|
|
1816
|
+
i18n: C
|
|
1817
|
+
} = this.options, r = L._buildClassNames({
|
|
1813
1818
|
iti: !0,
|
|
1814
1819
|
"iti--allow-dropdown": t,
|
|
1815
1820
|
"iti--show-flags": i,
|
|
1816
1821
|
"iti--inline-dropdown": !d,
|
|
1817
1822
|
[s]: !!s
|
|
1818
|
-
}),
|
|
1819
|
-
if ((
|
|
1823
|
+
}), h = y("div", { class: r });
|
|
1824
|
+
if ((p = this.telInput.parentNode) == null || p.insertBefore(h, this.telInput), t || i || e) {
|
|
1820
1825
|
this.countryContainer = y(
|
|
1821
1826
|
"div",
|
|
1822
1827
|
// visibly hidden until we measure it's width to set the input padding correctly
|
|
1823
1828
|
{ class: "iti__country-container iti__v-hide" },
|
|
1824
|
-
|
|
1829
|
+
h
|
|
1825
1830
|
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = y(
|
|
1826
1831
|
"button",
|
|
1827
1832
|
{
|
|
@@ -1862,7 +1867,7 @@ class L {
|
|
|
1862
1867
|
class: `iti__dropdown-content iti__hide ${b}`,
|
|
1863
1868
|
role: "dialog",
|
|
1864
1869
|
"aria-modal": "true"
|
|
1865
|
-
}),
|
|
1870
|
+
}), c) {
|
|
1866
1871
|
const f = y(
|
|
1867
1872
|
"div",
|
|
1868
1873
|
{ class: "iti__search-input-wrapper" },
|
|
@@ -1886,11 +1891,11 @@ class L {
|
|
|
1886
1891
|
// Chrome says inputs need either a name or an id
|
|
1887
1892
|
type: "search",
|
|
1888
1893
|
class: "iti__search-input",
|
|
1889
|
-
placeholder:
|
|
1894
|
+
placeholder: C.searchPlaceholder,
|
|
1890
1895
|
// role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
|
|
1891
1896
|
role: "combobox",
|
|
1892
1897
|
"aria-expanded": "true",
|
|
1893
|
-
"aria-label":
|
|
1898
|
+
"aria-label": C.searchPlaceholder,
|
|
1894
1899
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1895
1900
|
"aria-autocomplete": "list",
|
|
1896
1901
|
autocomplete: "off"
|
|
@@ -1901,7 +1906,7 @@ class L {
|
|
|
1901
1906
|
{
|
|
1902
1907
|
type: "button",
|
|
1903
1908
|
class: "iti__search-clear iti__hide",
|
|
1904
|
-
"aria-label":
|
|
1909
|
+
"aria-label": C.clearSearchAriaLabel,
|
|
1905
1910
|
tabindex: "-1"
|
|
1906
1911
|
},
|
|
1907
1912
|
f
|
|
@@ -1926,7 +1931,7 @@ class L {
|
|
|
1926
1931
|
// all a11y messaging happens in this.searchResultsA11yText
|
|
1927
1932
|
},
|
|
1928
1933
|
this.dropdownContent
|
|
1929
|
-
), this.searchNoResults.textContent =
|
|
1934
|
+
), this.searchNoResults.textContent = C.zeroSearchResults;
|
|
1930
1935
|
}
|
|
1931
1936
|
if (this.countryList = y(
|
|
1932
1937
|
"ul",
|
|
@@ -1934,10 +1939,10 @@ class L {
|
|
|
1934
1939
|
class: "iti__country-list",
|
|
1935
1940
|
id: `iti-${this.id}__country-listbox`,
|
|
1936
1941
|
role: "listbox",
|
|
1937
|
-
"aria-label":
|
|
1942
|
+
"aria-label": C.countryListAriaLabel
|
|
1938
1943
|
},
|
|
1939
1944
|
this.dropdownContent
|
|
1940
|
-
), this._appendListItems(),
|
|
1945
|
+
), this._appendListItems(), c && this._updateSearchResultsA11yText(), a) {
|
|
1941
1946
|
const f = L._buildClassNames({
|
|
1942
1947
|
iti: !0,
|
|
1943
1948
|
"iti--container": !0,
|
|
@@ -1950,21 +1955,21 @@ class L {
|
|
|
1950
1955
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1951
1956
|
}
|
|
1952
1957
|
}
|
|
1953
|
-
if (
|
|
1958
|
+
if (h.appendChild(this.telInput), this.countryContainer && (this._updateInputPadding(), this.countryContainer.classList.remove("iti__v-hide")), n) {
|
|
1954
1959
|
const _ = this.telInput.getAttribute("name") || "", b = n(_);
|
|
1955
1960
|
if (b.phone) {
|
|
1956
|
-
const f = (
|
|
1961
|
+
const f = (m = this.telInput.form) == null ? void 0 : m.querySelector(`input[name="${b.phone}"]`);
|
|
1957
1962
|
f ? this.hiddenInput = f : (this.hiddenInput = y("input", {
|
|
1958
1963
|
type: "hidden",
|
|
1959
1964
|
name: b.phone
|
|
1960
|
-
}),
|
|
1965
|
+
}), h.appendChild(this.hiddenInput));
|
|
1961
1966
|
}
|
|
1962
1967
|
if (b.country) {
|
|
1963
1968
|
const f = (g = this.telInput.form) == null ? void 0 : g.querySelector(`input[name="${b.country}"]`);
|
|
1964
1969
|
f ? this.hiddenInputCountry = f : (this.hiddenInputCountry = y("input", {
|
|
1965
1970
|
type: "hidden",
|
|
1966
1971
|
name: b.country
|
|
1967
|
-
}),
|
|
1972
|
+
}), h.appendChild(this.hiddenInputCountry));
|
|
1968
1973
|
}
|
|
1969
1974
|
}
|
|
1970
1975
|
}
|
|
@@ -1993,12 +1998,12 @@ class L {
|
|
|
1993
1998
|
//* 1. Extracting a dial code from the given number
|
|
1994
1999
|
//* 2. Using explicit initialCountry
|
|
1995
2000
|
_setInitialState(t = !1) {
|
|
1996
|
-
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i,
|
|
1997
|
-
if (
|
|
2001
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, a = this._getDialCode(n), o = P(n), { initialCountry: d, geoIpLookup: c } = this.options, C = d === "auto" && c;
|
|
2002
|
+
if (a && !o)
|
|
1998
2003
|
this._updateCountryFromNumber(n);
|
|
1999
|
-
else if (!
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2004
|
+
else if (!C || t) {
|
|
2005
|
+
const r = d ? d.toLowerCase() : "";
|
|
2006
|
+
r && this._getCountryData(r, !0) ? this._setCountry(r) : a && o ? this._setCountry("us") : this._setCountry();
|
|
2002
2007
|
}
|
|
2003
2008
|
n && this._updateValFromNumber(n);
|
|
2004
2009
|
}
|
|
@@ -2053,24 +2058,24 @@ class L {
|
|
|
2053
2058
|
));
|
|
2054
2059
|
}
|
|
2055
2060
|
_openDropdownWithPlus() {
|
|
2056
|
-
this._openDropdown(), this.searchInput.value = "+", this._filterCountries(""
|
|
2061
|
+
this._openDropdown(), this.searchInput.value = "+", this._filterCountries("");
|
|
2057
2062
|
}
|
|
2058
2063
|
//* Initialize the tel input listeners.
|
|
2059
2064
|
_initTelInputListeners() {
|
|
2060
2065
|
const { strictMode: t, formatAsYouType: e, separateDialCode: i, allowDropdown: s, countrySearch: n } = this.options;
|
|
2061
|
-
let
|
|
2062
|
-
new RegExp("\\p{L}", "u").test(this.telInput.value) && (
|
|
2066
|
+
let a = !1;
|
|
2067
|
+
new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (o) => {
|
|
2063
2068
|
if (this.isAndroid && (o == null ? void 0 : o.data) === "+" && i && s && n) {
|
|
2064
|
-
const
|
|
2065
|
-
this.telInput.value =
|
|
2069
|
+
const r = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, r - 1), p = this.telInput.value.substring(r);
|
|
2070
|
+
this.telInput.value = h + p, this._openDropdownWithPlus();
|
|
2066
2071
|
return;
|
|
2067
2072
|
}
|
|
2068
2073
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
2069
|
-
const d = (o == null ? void 0 : o.data) && /[^+0-9]/.test(o.data),
|
|
2070
|
-
d ||
|
|
2071
|
-
const
|
|
2072
|
-
if (e && !
|
|
2073
|
-
const
|
|
2074
|
+
const d = (o == null ? void 0 : o.data) && /[^+0-9]/.test(o.data), c = (o == null ? void 0 : o.inputType) === "insertFromPaste" && this.telInput.value;
|
|
2075
|
+
d || c && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
|
|
2076
|
+
const C = (o == null ? void 0 : o.detail) && o.detail.isSetNumber;
|
|
2077
|
+
if (e && !a && !C) {
|
|
2078
|
+
const r = this.telInput.selectionStart || 0, p = this.telInput.value.substring(0, r).replace(/[^+0-9]/g, "").length, m = (o == null ? void 0 : o.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(), _ = q(p, g, r, m);
|
|
2074
2079
|
this.telInput.value = g, this.telInput.setSelectionRange(_, _);
|
|
2075
2080
|
}
|
|
2076
2081
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (o) => {
|
|
@@ -2080,8 +2085,8 @@ class L {
|
|
|
2080
2085
|
return;
|
|
2081
2086
|
}
|
|
2082
2087
|
if (t) {
|
|
2083
|
-
const d = this.telInput.value,
|
|
2084
|
-
(!
|
|
2088
|
+
const d = this.telInput.value, C = !(d.charAt(0) === "+") && this.telInput.selectionStart === 0 && o.key === "+", r = /^[0-9]$/.test(o.key), h = i ? r : C || r, p = d.slice(0, this.telInput.selectionStart) + o.key + d.slice(this.telInput.selectionEnd), m = this._getFullNumber(p), g = l.utils.getCoreNumber(m, this.selectedCountryData.iso2), _ = this.maxCoreNumberLength && g.length > this.maxCoreNumberLength, f = this._getNewCountryFromNumber(m) !== null;
|
|
2089
|
+
(!h || _ && !f && !C) && o.preventDefault();
|
|
2085
2090
|
}
|
|
2086
2091
|
}
|
|
2087
2092
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2145,7 +2150,7 @@ class L {
|
|
|
2145
2150
|
}, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
|
|
2146
2151
|
const i = () => {
|
|
2147
2152
|
const n = this.searchInput.value.trim();
|
|
2148
|
-
|
|
2153
|
+
this._filterCountries(n), this.searchInput.value ? this.searchClearButton.classList.remove("iti__hide") : this.searchClearButton.classList.add("iti__hide");
|
|
2149
2154
|
};
|
|
2150
2155
|
let s = null;
|
|
2151
2156
|
this._handleSearchChange = () => {
|
|
@@ -2167,25 +2172,31 @@ class L {
|
|
|
2167
2172
|
}
|
|
2168
2173
|
}
|
|
2169
2174
|
//* Country search enabled: Filter the countries according to the search query.
|
|
2170
|
-
_filterCountries(t
|
|
2171
|
-
let
|
|
2175
|
+
_filterCountries(t) {
|
|
2176
|
+
let e = !0;
|
|
2172
2177
|
this.countryList.innerHTML = "";
|
|
2173
|
-
const
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2178
|
+
const i = k(t);
|
|
2179
|
+
let s;
|
|
2180
|
+
if (t === "")
|
|
2181
|
+
s = this.countries;
|
|
2182
|
+
else {
|
|
2183
|
+
const n = [], a = [], o = [], d = [], c = [], C = [];
|
|
2184
|
+
for (const r of this.countries)
|
|
2185
|
+
r.iso2 === i ? n.push(r) : r.normalisedName.startsWith(i) ? a.push(r) : r.normalisedName.includes(i) ? o.push(r) : i === r.dialCode || i === r.dialCodePlus ? d.push(r) : r.dialCodePlus.includes(i) ? c.push(r) : r.initials.includes(i) && C.push(r);
|
|
2186
|
+
s = [
|
|
2187
|
+
...n.sort((r, h) => r.priority - h.priority),
|
|
2188
|
+
...a.sort((r, h) => r.priority - h.priority),
|
|
2189
|
+
...o.sort((r, h) => r.priority - h.priority),
|
|
2190
|
+
...d.sort((r, h) => r.priority - h.priority),
|
|
2191
|
+
...c.sort((r, h) => r.priority - h.priority),
|
|
2192
|
+
...C.sort((r, h) => r.priority - h.priority)
|
|
2193
|
+
];
|
|
2187
2194
|
}
|
|
2188
|
-
|
|
2195
|
+
for (const n of s) {
|
|
2196
|
+
const a = n.nodeById[this.id];
|
|
2197
|
+
a && (this.countryList.appendChild(a), e && (this._highlightListItem(a, !1), e = !1));
|
|
2198
|
+
}
|
|
2199
|
+
e ? (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();
|
|
2189
2200
|
}
|
|
2190
2201
|
//* Update search results text (for a11y).
|
|
2191
2202
|
_updateSearchResultsA11yText() {
|
|
@@ -2208,11 +2219,11 @@ class L {
|
|
|
2208
2219
|
_updateValFromNumber(t) {
|
|
2209
2220
|
let e = t;
|
|
2210
2221
|
if (this.options.formatOnDisplay && l.utils && this.selectedCountryData) {
|
|
2211
|
-
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat,
|
|
2222
|
+
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, a = i ? s : n;
|
|
2212
2223
|
e = l.utils.formatNumber(
|
|
2213
2224
|
e,
|
|
2214
2225
|
this.selectedCountryData.iso2,
|
|
2215
|
-
|
|
2226
|
+
a
|
|
2216
2227
|
);
|
|
2217
2228
|
}
|
|
2218
2229
|
e = this._beforeSetNumber(e), this.telInput.value = e;
|
|
@@ -2227,8 +2238,8 @@ class L {
|
|
|
2227
2238
|
const { dialCode: e, nationalPrefix: i } = this.selectedCountryData;
|
|
2228
2239
|
if (t.charAt(0) === "+" || !e)
|
|
2229
2240
|
return t;
|
|
2230
|
-
const
|
|
2231
|
-
return `+${e}${
|
|
2241
|
+
const a = i && t.charAt(0) === i && !this.options.separateDialCode ? t.substring(1) : t;
|
|
2242
|
+
return `+${e}${a}`;
|
|
2232
2243
|
}
|
|
2233
2244
|
// Get the country ISO2 code from the given number
|
|
2234
2245
|
// BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
|
|
@@ -2238,21 +2249,22 @@ class L {
|
|
|
2238
2249
|
let i = e ? t.substring(e) : t;
|
|
2239
2250
|
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2240
2251
|
i = this._ensureHasDialCode(i);
|
|
2241
|
-
const
|
|
2242
|
-
if (
|
|
2243
|
-
const d = v(
|
|
2244
|
-
if (
|
|
2252
|
+
const a = this._getDialCode(i, !0), o = v(i);
|
|
2253
|
+
if (a) {
|
|
2254
|
+
const d = v(a), c = this.dialCodeToIso2Map[d];
|
|
2255
|
+
if (c.length === 1)
|
|
2256
|
+
return c[0] === s ? null : c[0];
|
|
2257
|
+
if (!s && this.defaultCountry && c.includes(this.defaultCountry))
|
|
2245
2258
|
return this.defaultCountry;
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
}
|
|
2259
|
+
if (n === "1" && P(o))
|
|
2260
|
+
return null;
|
|
2261
|
+
const r = this.selectedCountryData.areaCodes && o.length > d.length;
|
|
2262
|
+
if (!(s && c.includes(s) && !r))
|
|
2263
|
+
return c[0];
|
|
2252
2264
|
} else {
|
|
2253
2265
|
if (i.charAt(0) === "+" && o.length)
|
|
2254
2266
|
return "";
|
|
2255
|
-
if ((!i || i === "+") && !
|
|
2267
|
+
if ((!i || i === "+") && !s)
|
|
2256
2268
|
return this.defaultCountry;
|
|
2257
2269
|
}
|
|
2258
2270
|
return null;
|
|
@@ -2281,18 +2293,18 @@ class L {
|
|
|
2281
2293
|
_setCountry(t) {
|
|
2282
2294
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 || "";
|
|
2283
2295
|
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountry) {
|
|
2284
|
-
const
|
|
2296
|
+
const a = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
|
|
2285
2297
|
let o, d;
|
|
2286
2298
|
if (t) {
|
|
2287
|
-
const { name:
|
|
2288
|
-
d =
|
|
2299
|
+
const { name: c, dialCode: C } = this.selectedCountryData;
|
|
2300
|
+
d = c, o = s.selectedCountryAriaLabel.replace("${countryName}", c).replace("${dialCode}", `+${C}`);
|
|
2289
2301
|
} else
|
|
2290
2302
|
d = s.noCountrySelected, o = s.noCountrySelected;
|
|
2291
|
-
this.selectedCountryInner.className =
|
|
2303
|
+
this.selectedCountryInner.className = a, this.selectedCountry.setAttribute("title", d), this.selectedCountry.setAttribute("aria-label", o);
|
|
2292
2304
|
}
|
|
2293
2305
|
if (e) {
|
|
2294
|
-
const
|
|
2295
|
-
this.selectedDialCode.innerHTML =
|
|
2306
|
+
const a = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
2307
|
+
this.selectedDialCode.innerHTML = a, this._updateInputPadding();
|
|
2296
2308
|
}
|
|
2297
2309
|
return this._updatePlaceholder(), this._updateMaxLength(), n !== t;
|
|
2298
2310
|
}
|
|
@@ -2309,14 +2321,14 @@ class L {
|
|
|
2309
2321
|
if (t && l.utils)
|
|
2310
2322
|
if (s) {
|
|
2311
2323
|
const n = l.utils.numberType[e];
|
|
2312
|
-
let
|
|
2324
|
+
let a = l.utils.getExampleNumber(
|
|
2313
2325
|
s,
|
|
2314
2326
|
!1,
|
|
2315
2327
|
n,
|
|
2316
2328
|
!0
|
|
2317
|
-
), o =
|
|
2318
|
-
for (; l.utils.isPossibleNumber(
|
|
2319
|
-
o =
|
|
2329
|
+
), o = a;
|
|
2330
|
+
for (; l.utils.isPossibleNumber(a, s, i); )
|
|
2331
|
+
o = a, a += "0";
|
|
2320
2332
|
const d = l.utils.getCoreNumber(o, s);
|
|
2321
2333
|
this.maxCoreNumberLength = d.length, s === "by" && (this.maxCoreNumberLength = d.length + 1);
|
|
2322
2334
|
} else
|
|
@@ -2354,11 +2366,11 @@ class L {
|
|
|
2354
2366
|
customPlaceholder: s
|
|
2355
2367
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2356
2368
|
if (l.utils && n) {
|
|
2357
|
-
const
|
|
2369
|
+
const a = l.utils.numberType[e];
|
|
2358
2370
|
let o = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
|
|
2359
2371
|
this.selectedCountryData.iso2,
|
|
2360
2372
|
i,
|
|
2361
|
-
|
|
2373
|
+
a
|
|
2362
2374
|
) : "";
|
|
2363
2375
|
o = this._beforeSetNumber(o), typeof s == "function" && (o = s(o, this.selectedCountryData)), this.telInput.setAttribute("placeholder", o);
|
|
2364
2376
|
}
|
|
@@ -2382,12 +2394,12 @@ class L {
|
|
|
2382
2394
|
}
|
|
2383
2395
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2384
2396
|
_scrollTo(t) {
|
|
2385
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i,
|
|
2397
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, a = n + s, o = t.offsetHeight, d = t.getBoundingClientRect().top + i, c = d + o, C = d - n + e.scrollTop;
|
|
2386
2398
|
if (d < n)
|
|
2387
|
-
e.scrollTop =
|
|
2388
|
-
else if (
|
|
2389
|
-
const
|
|
2390
|
-
e.scrollTop =
|
|
2399
|
+
e.scrollTop = C;
|
|
2400
|
+
else if (c > a) {
|
|
2401
|
+
const r = s - o;
|
|
2402
|
+
e.scrollTop = C - r;
|
|
2391
2403
|
}
|
|
2392
2404
|
}
|
|
2393
2405
|
//* Replace any existing dial code with the new one
|
|
@@ -2407,9 +2419,9 @@ class L {
|
|
|
2407
2419
|
if (t.charAt(0) === "+") {
|
|
2408
2420
|
let s = "";
|
|
2409
2421
|
for (let n = 0; n < t.length; n++) {
|
|
2410
|
-
const
|
|
2411
|
-
if (!isNaN(parseInt(
|
|
2412
|
-
if (s +=
|
|
2422
|
+
const a = t.charAt(n);
|
|
2423
|
+
if (!isNaN(parseInt(a, 10))) {
|
|
2424
|
+
if (s += a, e)
|
|
2413
2425
|
this.dialCodeToIso2Map[s] && (i = t.substring(0, n + 1));
|
|
2414
2426
|
else if (this.dialCodes.has(s)) {
|
|
2415
2427
|
i = t.substring(0, n + 1);
|
|
@@ -2467,7 +2479,7 @@ class L {
|
|
|
2467
2479
|
//********************
|
|
2468
2480
|
//* Remove plugin.
|
|
2469
2481
|
destroy() {
|
|
2470
|
-
var n,
|
|
2482
|
+
var n, a;
|
|
2471
2483
|
this.telInput.iti = void 0;
|
|
2472
2484
|
const { allowDropdown: t, separateDialCode: e } = this.options;
|
|
2473
2485
|
if (t) {
|
|
@@ -2484,7 +2496,7 @@ class L {
|
|
|
2484
2496
|
const { form: i } = this.telInput;
|
|
2485
2497
|
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);
|
|
2486
2498
|
const s = this.telInput.parentNode;
|
|
2487
|
-
(n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (
|
|
2499
|
+
(n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (a = s == null ? void 0 : s.parentNode) == null || a.removeChild(s), delete l.instances[this.id];
|
|
2488
2500
|
}
|
|
2489
2501
|
//* Get the extension from the current number.
|
|
2490
2502
|
getExtension() {
|
|
@@ -2539,9 +2551,9 @@ class L {
|
|
|
2539
2551
|
_validateNumber(t) {
|
|
2540
2552
|
if (!this.selectedCountryData.iso2)
|
|
2541
2553
|
return !1;
|
|
2542
|
-
const e = (
|
|
2554
|
+
const e = (a) => t ? this._utilsIsValidNumber(a) : this._utilsIsPossibleNumber(a), i = this._getFullNumber(), s = i.search(new RegExp("\\p{L}", "u"));
|
|
2543
2555
|
if (s > -1 && !this.options.allowPhonewords) {
|
|
2544
|
-
const
|
|
2556
|
+
const a = i.substring(0, s), o = e(a), d = e(i);
|
|
2545
2557
|
return o && d;
|
|
2546
2558
|
}
|
|
2547
2559
|
return e(i);
|
|
@@ -2609,7 +2621,7 @@ const Y = (u) => {
|
|
|
2609
2621
|
attachUtils: Y,
|
|
2610
2622
|
startedLoadingUtilsScript: !1,
|
|
2611
2623
|
startedLoadingAutoCountry: !1,
|
|
2612
|
-
version: "25.10.
|
|
2624
|
+
version: "25.10.6"
|
|
2613
2625
|
}
|
|
2614
2626
|
), Z = {
|
|
2615
2627
|
__name: "IntlTelInput",
|
|
@@ -2644,37 +2656,37 @@ const Y = (u) => {
|
|
|
2644
2656
|
"changeErrorCode"
|
|
2645
2657
|
], ["update:modelValue"]),
|
|
2646
2658
|
setup(u, { expose: t, emit: e }) {
|
|
2647
|
-
const i = M(u, "modelValue"), s = u, n = e,
|
|
2648
|
-
let
|
|
2649
|
-
d.value !==
|
|
2659
|
+
const i = M(u, "modelValue"), s = u, n = e, a = D(), o = D(), d = D(!1), c = () => o.value ? s.options.strictMode ? o.value.isValidNumberPrecise() : o.value.isValidNumber() : null, C = () => {
|
|
2660
|
+
let p = c();
|
|
2661
|
+
d.value !== p && (d.value = p, n("changeValidity", !!p), n(
|
|
2650
2662
|
"changeErrorCode",
|
|
2651
|
-
|
|
2663
|
+
p ? null : o.value.getValidationError()
|
|
2652
2664
|
));
|
|
2653
|
-
},
|
|
2654
|
-
var
|
|
2655
|
-
n("changeNumber", ((
|
|
2656
|
-
},
|
|
2657
|
-
var
|
|
2658
|
-
n("changeCountry", ((
|
|
2665
|
+
}, r = () => {
|
|
2666
|
+
var p;
|
|
2667
|
+
n("changeNumber", ((p = o.value) == null ? void 0 : p.getNumber()) ?? ""), C();
|
|
2668
|
+
}, h = () => {
|
|
2669
|
+
var p;
|
|
2670
|
+
n("changeCountry", ((p = o.value) == null ? void 0 : p.getSelectedCountryData().iso2) ?? ""), r(), C();
|
|
2659
2671
|
};
|
|
2660
2672
|
return E(() => {
|
|
2661
|
-
|
|
2673
|
+
a.value && (o.value = l(a.value, s.options), s.value && o.value.setNumber(s.value), s.disabled && o.value.setDisabled(s.disabled), d.value = c());
|
|
2662
2674
|
}), B(
|
|
2663
2675
|
() => s.disabled,
|
|
2664
|
-
(
|
|
2665
|
-
var
|
|
2666
|
-
return (
|
|
2676
|
+
(p) => {
|
|
2677
|
+
var m;
|
|
2678
|
+
return (m = o.value) == null ? void 0 : m.setDisabled(p);
|
|
2667
2679
|
}
|
|
2668
2680
|
), R(() => {
|
|
2669
|
-
var
|
|
2670
|
-
return (
|
|
2671
|
-
}), t({ instance: o, input:
|
|
2681
|
+
var p;
|
|
2682
|
+
return (p = o.value) == null ? void 0 : p.destroy();
|
|
2683
|
+
}), t({ instance: o, input: a }), (p, m) => F((z(), V("input", O({
|
|
2672
2684
|
ref_key: "input",
|
|
2673
|
-
ref:
|
|
2674
|
-
"onUpdate:modelValue":
|
|
2685
|
+
ref: a,
|
|
2686
|
+
"onUpdate:modelValue": m[0] || (m[0] = (g) => i.value = g),
|
|
2675
2687
|
type: "tel",
|
|
2676
|
-
onCountrychange:
|
|
2677
|
-
onInput:
|
|
2688
|
+
onCountrychange: h,
|
|
2689
|
+
onInput: r
|
|
2678
2690
|
}, u.inputProps), null, 16)), [
|
|
2679
2691
|
[
|
|
2680
2692
|
$,
|