intl-tel-input 25.7.0 → 25.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +90 -40
- package/angular/build/IntlTelInputWithUtils.js +90 -40
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +1 -0
- package/angular/build/types/intl-tel-input.d.ts +10 -1
- package/build/css/intlTelInput.css +67 -6
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/i18n/en/interface.js +1 -0
- package/build/js/intlTelInput.d.ts +11 -1
- package/build/js/intlTelInput.js +107 -41
- package/build/js/intlTelInput.min.js +13 -2
- package/build/js/intlTelInputWithUtils.js +107 -41
- package/build/js/intlTelInputWithUtils.min.js +13 -2
- package/package.json +7 -12
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +106 -40
- package/react/build/IntlTelInput.d.ts +11 -1
- package/react/build/IntlTelInput.js +106 -40
- package/react/build/IntlTelInputWithUtils.cjs +106 -40
- package/react/build/IntlTelInputWithUtils.js +106 -40
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +201 -134
- package/vue/build/IntlTelInputWithUtils.mjs +737 -670
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as A, useModel as E, ref as N, onMounted as M, watch as B, onUnmounted as R, withDirectives as F, createElementBlock as z, openBlock as V, mergeProps as O, vModelText as $ } from "vue";
|
|
2
|
+
const j = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1323,7 +1323,7 @@ const $ = [
|
|
|
1323
1323
|
"263"
|
|
1324
1324
|
]
|
|
1325
1325
|
], w = [];
|
|
1326
|
-
for (const d of
|
|
1326
|
+
for (const d of j)
|
|
1327
1327
|
w.push({
|
|
1328
1328
|
name: "",
|
|
1329
1329
|
// populated in the plugin
|
|
@@ -1335,7 +1335,7 @@ for (const d of $)
|
|
|
1335
1335
|
// populated by the plugin
|
|
1336
1336
|
nationalPrefix: d[4] || null
|
|
1337
1337
|
});
|
|
1338
|
-
const
|
|
1338
|
+
const U = {
|
|
1339
1339
|
ad: "Andorra",
|
|
1340
1340
|
ae: "United Arab Emirates",
|
|
1341
1341
|
af: "Afghanistan",
|
|
@@ -1578,28 +1578,29 @@ const j = {
|
|
|
1578
1578
|
za: "South Africa",
|
|
1579
1579
|
zm: "Zambia",
|
|
1580
1580
|
zw: "Zimbabwe"
|
|
1581
|
-
},
|
|
1581
|
+
}, H = {
|
|
1582
1582
|
selectedCountryAriaLabel: "Selected country",
|
|
1583
1583
|
noCountrySelected: "No country selected",
|
|
1584
1584
|
countryListAriaLabel: "List of countries",
|
|
1585
1585
|
searchPlaceholder: "Search",
|
|
1586
|
+
clearSearchAriaLabel: "Clear search",
|
|
1586
1587
|
zeroSearchResults: "No results found",
|
|
1587
1588
|
oneSearchResult: "1 result found",
|
|
1588
1589
|
multipleSearchResults: "${count} results found",
|
|
1589
1590
|
// additional countries (not supported by country-list library)
|
|
1590
1591
|
ac: "Ascension Island",
|
|
1591
1592
|
xk: "Kosovo"
|
|
1592
|
-
},
|
|
1593
|
+
}, T = { ...U, ...H };
|
|
1593
1594
|
for (const d of w)
|
|
1594
|
-
d.name =
|
|
1595
|
-
let
|
|
1596
|
-
const
|
|
1595
|
+
d.name = T[d.iso2];
|
|
1596
|
+
let K = 0;
|
|
1597
|
+
const S = (d) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(d).matches, W = () => {
|
|
1597
1598
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
1598
|
-
const d = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t =
|
|
1599
|
+
const d = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = S("(max-width: 500px)"), e = S("(max-height: 600px)"), i = S("(pointer: coarse)");
|
|
1599
1600
|
return d || t || i && e;
|
|
1600
1601
|
}
|
|
1601
1602
|
return !1;
|
|
1602
|
-
},
|
|
1603
|
+
}, x = {
|
|
1603
1604
|
//* Whether or not to allow the dropdown.
|
|
1604
1605
|
allowDropdown: !0,
|
|
1605
1606
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1645,10 +1646,10 @@ const D = (d) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1645
1646
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1646
1647
|
strictMode: !1,
|
|
1647
1648
|
//* Use full screen popup instead of dropdown for country list.
|
|
1648
|
-
useFullscreenPopup:
|
|
1649
|
+
useFullscreenPopup: W(),
|
|
1649
1650
|
//* The number type to enforce during validation.
|
|
1650
1651
|
validationNumberTypes: ["MOBILE"]
|
|
1651
|
-
},
|
|
1652
|
+
}, q = [
|
|
1652
1653
|
"800",
|
|
1653
1654
|
"822",
|
|
1654
1655
|
"833",
|
|
@@ -1666,14 +1667,14 @@ const D = (d) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1666
1667
|
"887",
|
|
1667
1668
|
"888",
|
|
1668
1669
|
"889"
|
|
1669
|
-
],
|
|
1670
|
-
const t =
|
|
1670
|
+
], L = (d) => d.replace(/\D/g, ""), k = (d = "") => d.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), P = (d) => {
|
|
1671
|
+
const t = L(d);
|
|
1671
1672
|
if (t.charAt(0) === "1") {
|
|
1672
1673
|
const e = t.substring(1, 4);
|
|
1673
|
-
return
|
|
1674
|
+
return q.includes(e);
|
|
1674
1675
|
}
|
|
1675
1676
|
return !1;
|
|
1676
|
-
},
|
|
1677
|
+
}, G = (d, t, e, i) => {
|
|
1677
1678
|
if (e === 0 && !i)
|
|
1678
1679
|
return 0;
|
|
1679
1680
|
let s = 0;
|
|
@@ -1684,22 +1685,29 @@ const D = (d) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1684
1685
|
return n;
|
|
1685
1686
|
}
|
|
1686
1687
|
return t.length;
|
|
1687
|
-
},
|
|
1688
|
+
}, C = (d, t, e) => {
|
|
1688
1689
|
const i = document.createElement(d);
|
|
1689
1690
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1690
1691
|
}, I = (d, ...t) => {
|
|
1691
1692
|
const { instances: e } = u;
|
|
1692
1693
|
Object.values(e).forEach((i) => i[d](...t));
|
|
1693
1694
|
};
|
|
1694
|
-
class
|
|
1695
|
+
class D {
|
|
1696
|
+
/**
|
|
1697
|
+
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
1698
|
+
* Only keys with truthy values are included.
|
|
1699
|
+
*/
|
|
1700
|
+
static _buildClassNames(t) {
|
|
1701
|
+
return Object.keys(t).filter((e) => !!t[e]).join(" ");
|
|
1702
|
+
}
|
|
1695
1703
|
constructor(t, e = {}) {
|
|
1696
|
-
this.id =
|
|
1704
|
+
this.id = K++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, x, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1697
1705
|
}
|
|
1698
1706
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1699
1707
|
_init() {
|
|
1700
1708
|
this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.telInput.dir = "ltr";
|
|
1701
1709
|
const t = this.options.allowDropdown || this.options.separateDialCode;
|
|
1702
|
-
this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...
|
|
1710
|
+
this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...T, ...this.options.i18n };
|
|
1703
1711
|
const e = new Promise((s, n) => {
|
|
1704
1712
|
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
|
|
1705
1713
|
}), i = new Promise((s, n) => {
|
|
@@ -1717,7 +1725,7 @@ class G {
|
|
|
1717
1725
|
//* Precompute and cache country search tokens to speed up filtering
|
|
1718
1726
|
_cacheSearchTokens() {
|
|
1719
1727
|
for (const t of this.countries)
|
|
1720
|
-
t.normalisedName =
|
|
1728
|
+
t.normalisedName = k(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
|
|
1721
1729
|
}
|
|
1722
1730
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1723
1731
|
_sortCountries() {
|
|
@@ -1786,7 +1794,7 @@ class G {
|
|
|
1786
1794
|
}
|
|
1787
1795
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1788
1796
|
_generateMarkup() {
|
|
1789
|
-
var a, h,
|
|
1797
|
+
var a, h, _;
|
|
1790
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");
|
|
1791
1799
|
const {
|
|
1792
1800
|
allowDropdown: t,
|
|
@@ -1797,108 +1805,166 @@ class G {
|
|
|
1797
1805
|
dropdownContainer: o,
|
|
1798
1806
|
fixDropdownWidth: l,
|
|
1799
1807
|
useFullscreenPopup: r,
|
|
1800
|
-
countrySearch:
|
|
1801
|
-
i18n:
|
|
1802
|
-
} = this.options
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
+
countrySearch: c,
|
|
1809
|
+
i18n: p
|
|
1810
|
+
} = this.options, y = D._buildClassNames({
|
|
1811
|
+
iti: !0,
|
|
1812
|
+
"iti--allow-dropdown": t,
|
|
1813
|
+
"iti--show-flags": i,
|
|
1814
|
+
"iti--inline-dropdown": !r,
|
|
1815
|
+
[s]: !!s
|
|
1816
|
+
}), m = C("div", { class: y });
|
|
1817
|
+
if ((a = this.telInput.parentNode) == null || a.insertBefore(m, this.telInput), t || i || e) {
|
|
1818
|
+
this.countryContainer = C(
|
|
1808
1819
|
"div",
|
|
1809
1820
|
{ class: "iti__country-container" },
|
|
1810
|
-
|
|
1811
|
-
), 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(
|
|
1812
1823
|
"button",
|
|
1813
1824
|
{
|
|
1814
1825
|
type: "button",
|
|
1815
1826
|
class: "iti__selected-country",
|
|
1816
1827
|
"aria-expanded": "false",
|
|
1817
1828
|
"aria-label": this.options.i18n.selectedCountryAriaLabel,
|
|
1818
|
-
"aria-haspopup": "
|
|
1819
|
-
"aria-controls": `iti-${this.id}__dropdown-content
|
|
1820
|
-
role: "combobox"
|
|
1829
|
+
"aria-haspopup": "dialog",
|
|
1830
|
+
"aria-controls": `iti-${this.id}__dropdown-content`
|
|
1821
1831
|
},
|
|
1822
1832
|
this.countryContainer
|
|
1823
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
1833
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = C(
|
|
1824
1834
|
"div",
|
|
1825
1835
|
{ class: "iti__selected-country" },
|
|
1826
1836
|
this.countryContainer
|
|
1827
1837
|
);
|
|
1828
|
-
const
|
|
1829
|
-
if (this.selectedCountryInner =
|
|
1838
|
+
const b = C("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
|
|
1839
|
+
if (this.selectedCountryInner = C("div", { class: "iti__flag" }, b), this.selectedCountryA11yText = C(
|
|
1830
1840
|
"span",
|
|
1831
1841
|
{ class: "iti__a11y-text" },
|
|
1832
1842
|
this.selectedCountryInner
|
|
1833
|
-
), t && (this.dropdownArrow =
|
|
1843
|
+
), t && (this.dropdownArrow = C(
|
|
1834
1844
|
"div",
|
|
1835
1845
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1836
|
-
|
|
1837
|
-
)), e && (this.selectedDialCode =
|
|
1846
|
+
b
|
|
1847
|
+
)), e && (this.selectedDialCode = C(
|
|
1838
1848
|
"div",
|
|
1839
1849
|
{ class: "iti__selected-dial-code", "aria-hidden": "true", dir: "ltr" },
|
|
1840
1850
|
this.selectedCountry
|
|
1841
1851
|
)), t) {
|
|
1842
1852
|
const f = l ? "" : "iti--flexible-dropdown-width";
|
|
1843
|
-
if (this.dropdownContent =
|
|
1853
|
+
if (this.dropdownContent = C("div", {
|
|
1844
1854
|
id: `iti-${this.id}__dropdown-content`,
|
|
1845
|
-
class: `iti__dropdown-content iti__hide ${f}
|
|
1846
|
-
|
|
1847
|
-
"
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
"
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1855
|
+
class: `iti__dropdown-content iti__hide ${f}`,
|
|
1856
|
+
role: "dialog",
|
|
1857
|
+
"aria-modal": "true"
|
|
1858
|
+
}), c) {
|
|
1859
|
+
const g = C(
|
|
1860
|
+
"div",
|
|
1861
|
+
{ class: "iti__search-input-wrapper" },
|
|
1862
|
+
this.dropdownContent
|
|
1863
|
+
);
|
|
1864
|
+
this.searchIcon = C(
|
|
1865
|
+
"span",
|
|
1866
|
+
{
|
|
1867
|
+
class: "iti__search-icon",
|
|
1868
|
+
"aria-hidden": "true"
|
|
1869
|
+
},
|
|
1870
|
+
g
|
|
1871
|
+
), this.searchIcon.innerHTML = `
|
|
1872
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
|
|
1873
|
+
<circle cx="11" cy="11" r="7" />
|
|
1874
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
1875
|
+
</svg>`, this.searchInput = C(
|
|
1876
|
+
"input",
|
|
1877
|
+
{
|
|
1878
|
+
id: `iti-${this.id}__search-input`,
|
|
1879
|
+
// Chrome says inputs need either a name or an id
|
|
1880
|
+
type: "search",
|
|
1881
|
+
class: "iti__search-input",
|
|
1882
|
+
placeholder: p.searchPlaceholder,
|
|
1883
|
+
// 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
|
|
1884
|
+
role: "combobox",
|
|
1885
|
+
"aria-expanded": "true",
|
|
1886
|
+
"aria-label": p.searchPlaceholder,
|
|
1887
|
+
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1888
|
+
"aria-autocomplete": "list",
|
|
1889
|
+
autocomplete: "off"
|
|
1890
|
+
},
|
|
1891
|
+
g
|
|
1892
|
+
), this.searchClearButton = C(
|
|
1893
|
+
"button",
|
|
1894
|
+
{
|
|
1895
|
+
type: "button",
|
|
1896
|
+
class: "iti__search-clear iti__hide",
|
|
1897
|
+
"aria-label": p.clearSearchAriaLabel,
|
|
1898
|
+
tabindex: "-1"
|
|
1899
|
+
},
|
|
1900
|
+
g
|
|
1901
|
+
);
|
|
1902
|
+
const v = `iti-${this.id}-clear-mask`;
|
|
1903
|
+
this.searchClearButton.innerHTML = `
|
|
1904
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
1905
|
+
<mask id="${v}" maskUnits="userSpaceOnUse">
|
|
1906
|
+
<rect width="16" height="16" fill="white" />
|
|
1907
|
+
<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" />
|
|
1908
|
+
</mask>
|
|
1909
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${v})" />
|
|
1910
|
+
</svg>`, this.searchResultsA11yText = C(
|
|
1911
|
+
"span",
|
|
1912
|
+
{ class: "iti__a11y-text" },
|
|
1913
|
+
this.dropdownContent
|
|
1914
|
+
), this.searchNoResults = C(
|
|
1915
|
+
"div",
|
|
1916
|
+
{
|
|
1917
|
+
class: "iti__no-results iti__hide",
|
|
1918
|
+
"aria-hidden": "true"
|
|
1919
|
+
// all a11y messaging happens in this.searchResultsA11yText
|
|
1920
|
+
},
|
|
1921
|
+
this.dropdownContent
|
|
1922
|
+
), this.searchNoResults.textContent = p.zeroSearchResults;
|
|
1923
|
+
}
|
|
1924
|
+
if (this.countryList = C(
|
|
1865
1925
|
"ul",
|
|
1866
1926
|
{
|
|
1867
1927
|
class: "iti__country-list",
|
|
1868
1928
|
id: `iti-${this.id}__country-listbox`,
|
|
1869
1929
|
role: "listbox",
|
|
1870
|
-
"aria-label":
|
|
1930
|
+
"aria-label": p.countryListAriaLabel
|
|
1871
1931
|
},
|
|
1872
1932
|
this.dropdownContent
|
|
1873
|
-
), this._appendListItems(),
|
|
1874
|
-
|
|
1875
|
-
|
|
1933
|
+
), this._appendListItems(), c && this._updateSearchResultsA11yText(), o) {
|
|
1934
|
+
const g = D._buildClassNames({
|
|
1935
|
+
iti: !0,
|
|
1936
|
+
"iti--container": !0,
|
|
1937
|
+
"iti--fullscreen-popup": r,
|
|
1938
|
+
"iti--inline-dropdown": !r,
|
|
1939
|
+
[s]: !!s
|
|
1940
|
+
});
|
|
1941
|
+
this.dropdown = C("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
|
|
1876
1942
|
} else
|
|
1877
1943
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1878
1944
|
}
|
|
1879
1945
|
}
|
|
1880
|
-
if (
|
|
1881
|
-
const
|
|
1946
|
+
if (m.appendChild(this.telInput), this._updateInputPadding(), n) {
|
|
1947
|
+
const b = this.telInput.getAttribute("name") || "", f = n(b);
|
|
1882
1948
|
if (f.phone) {
|
|
1883
1949
|
const g = (h = this.telInput.form) == null ? void 0 : h.querySelector(`input[name="${f.phone}"]`);
|
|
1884
|
-
g ? this.hiddenInput = g : (this.hiddenInput =
|
|
1950
|
+
g ? this.hiddenInput = g : (this.hiddenInput = C("input", {
|
|
1885
1951
|
type: "hidden",
|
|
1886
1952
|
name: f.phone
|
|
1887
|
-
}),
|
|
1953
|
+
}), m.appendChild(this.hiddenInput));
|
|
1888
1954
|
}
|
|
1889
1955
|
if (f.country) {
|
|
1890
|
-
const g = (
|
|
1891
|
-
g ? this.hiddenInputCountry = g : (this.hiddenInputCountry =
|
|
1956
|
+
const g = (_ = this.telInput.form) == null ? void 0 : _.querySelector(`input[name="${f.country}"]`);
|
|
1957
|
+
g ? this.hiddenInputCountry = g : (this.hiddenInputCountry = C("input", {
|
|
1892
1958
|
type: "hidden",
|
|
1893
1959
|
name: f.country
|
|
1894
|
-
}),
|
|
1960
|
+
}), m.appendChild(this.hiddenInputCountry));
|
|
1895
1961
|
}
|
|
1896
1962
|
}
|
|
1897
1963
|
}
|
|
1898
1964
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1899
1965
|
_appendListItems() {
|
|
1900
1966
|
for (let t = 0; t < this.countries.length; t++) {
|
|
1901
|
-
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s =
|
|
1967
|
+
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = C(
|
|
1902
1968
|
"li",
|
|
1903
1969
|
{
|
|
1904
1970
|
id: `iti-${this.id}__item-${e.iso2}`,
|
|
@@ -1920,12 +1986,12 @@ class G {
|
|
|
1920
1986
|
//* 1. Extracting a dial code from the given number
|
|
1921
1987
|
//* 2. Using explicit initialCountry
|
|
1922
1988
|
_setInitialState(t = !1) {
|
|
1923
|
-
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), l =
|
|
1989
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), l = P(n), { initialCountry: r, geoIpLookup: c } = this.options, p = r === "auto" && c;
|
|
1924
1990
|
if (o && !l)
|
|
1925
1991
|
this._updateCountryFromNumber(n);
|
|
1926
|
-
else if (!
|
|
1927
|
-
const
|
|
1928
|
-
|
|
1992
|
+
else if (!p || t) {
|
|
1993
|
+
const y = r ? r.toLowerCase() : "";
|
|
1994
|
+
y && this._getCountryData(y, !0) ? this._setCountry(y) : o && l ? this._setCountry("us") : this._setCountry();
|
|
1929
1995
|
}
|
|
1930
1996
|
n && this._updateValFromNumber(n);
|
|
1931
1997
|
}
|
|
@@ -1988,17 +2054,17 @@ class G {
|
|
|
1988
2054
|
let l = !1;
|
|
1989
2055
|
new RegExp("\\p{L}", "u").test(this.telInput.value) && (l = !0), this._handleInputEvent = (r) => {
|
|
1990
2056
|
if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && n && o) {
|
|
1991
|
-
const
|
|
2057
|
+
const m = this.telInput.selectionStart || 0, a = this.telInput.value.substring(0, m - 1), h = this.telInput.value.substring(m);
|
|
1992
2058
|
this.telInput.value = a + h, this._openDropdownWithPlus();
|
|
1993
2059
|
return;
|
|
1994
2060
|
}
|
|
1995
2061
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
const
|
|
1999
|
-
if (e && !l && !
|
|
2000
|
-
const
|
|
2001
|
-
this.telInput.value =
|
|
2062
|
+
const c = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), p = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
|
|
2063
|
+
c || p && !t ? l = !0 : /[^+0-9]/.test(this.telInput.value) || (l = !1);
|
|
2064
|
+
const y = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
|
|
2065
|
+
if (e && !l && !y) {
|
|
2066
|
+
const m = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, m).replace(/[^+0-9]/g, "").length, _ = (r == null ? void 0 : r.inputType) === "deleteContentForward", b = this._formatNumberAsYouType(), f = G(h, b, m, _);
|
|
2067
|
+
this.telInput.value = b, this.telInput.setSelectionRange(f, f);
|
|
2002
2068
|
}
|
|
2003
2069
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (r) => {
|
|
2004
2070
|
if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
|
|
@@ -2007,8 +2073,8 @@ class G {
|
|
|
2007
2073
|
return;
|
|
2008
2074
|
}
|
|
2009
2075
|
if (t) {
|
|
2010
|
-
const
|
|
2011
|
-
(!a || f && !
|
|
2076
|
+
const c = this.telInput.value, y = !(c.charAt(0) === "+") && this.telInput.selectionStart === 0 && r.key === "+", m = /^[0-9]$/.test(r.key), a = i ? m : y || m, h = c.slice(0, this.telInput.selectionStart) + r.key + c.slice(this.telInput.selectionEnd), _ = this._getFullNumber(h), b = u.utils.getCoreNumber(_, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && b.length > this.maxCoreNumberLength, v = this._getNewCountryFromNumber(_) !== null;
|
|
2077
|
+
(!a || f && !v && !y) && r.preventDefault();
|
|
2012
2078
|
}
|
|
2013
2079
|
}
|
|
2014
2080
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2072,14 +2138,16 @@ class G {
|
|
|
2072
2138
|
}, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
|
|
2073
2139
|
const s = () => {
|
|
2074
2140
|
const o = this.searchInput.value.trim();
|
|
2075
|
-
o ? this._filterCountries(o) : this._filterCountries("", !0);
|
|
2141
|
+
o ? this._filterCountries(o) : this._filterCountries("", !0), this.searchInput.value ? this.searchClearButton.classList.remove("iti__hide") : this.searchClearButton.classList.add("iti__hide");
|
|
2076
2142
|
};
|
|
2077
2143
|
let n = null;
|
|
2078
2144
|
this._handleSearchChange = () => {
|
|
2079
2145
|
n && clearTimeout(n), n = setTimeout(() => {
|
|
2080
2146
|
s(), n = null;
|
|
2081
2147
|
}, 100);
|
|
2082
|
-
}, this.searchInput.addEventListener("input", this._handleSearchChange), this.
|
|
2148
|
+
}, this.searchInput.addEventListener("input", this._handleSearchChange), this._handleSearchClear = (o) => {
|
|
2149
|
+
o.stopPropagation(), this.searchInput.value = "", this.searchInput.focus(), s();
|
|
2150
|
+
}, this.searchClearButton.addEventListener("click", this._handleSearchClear), this.searchInput.addEventListener("click", (o) => o.stopPropagation());
|
|
2083
2151
|
}
|
|
2084
2152
|
}
|
|
2085
2153
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
@@ -2095,25 +2163,25 @@ class G {
|
|
|
2095
2163
|
_filterCountries(t, e = !1) {
|
|
2096
2164
|
let i = !0;
|
|
2097
2165
|
this.countryList.innerHTML = "";
|
|
2098
|
-
const s =
|
|
2166
|
+
const s = k(t), n = s.length, o = [], l = [], r = [], c = [], p = [], y = [];
|
|
2099
2167
|
for (const a of this.countries)
|
|
2100
|
-
e || n === 0 ? r.push(a) : a.iso2 === s ? o.push(a) : a.normalisedName.startsWith(s) ? l.push(a) : a.normalisedName.includes(s) ? r.push(a) : s === a.dialCode || s === a.dialCodePlus ?
|
|
2101
|
-
const
|
|
2168
|
+
e || n === 0 ? r.push(a) : a.iso2 === s ? o.push(a) : a.normalisedName.startsWith(s) ? l.push(a) : a.normalisedName.includes(s) ? r.push(a) : s === a.dialCode || s === a.dialCodePlus ? c.push(a) : a.dialCodePlus.includes(s) ? p.push(a) : a.initials.includes(s) && y.push(a);
|
|
2169
|
+
const m = [
|
|
2102
2170
|
...o.sort((a, h) => a.priority - h.priority),
|
|
2103
2171
|
...l.sort((a, h) => a.priority - h.priority),
|
|
2104
2172
|
...r.sort((a, h) => a.priority - h.priority),
|
|
2173
|
+
...c.sort((a, h) => a.priority - h.priority),
|
|
2105
2174
|
...p.sort((a, h) => a.priority - h.priority),
|
|
2106
|
-
...
|
|
2107
|
-
...c.sort((a, h) => a.priority - h.priority)
|
|
2175
|
+
...y.sort((a, h) => a.priority - h.priority)
|
|
2108
2176
|
];
|
|
2109
|
-
for (const a of
|
|
2177
|
+
for (const a of m) {
|
|
2110
2178
|
const h = a.nodeById[this.id];
|
|
2111
2179
|
h && (this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1));
|
|
2112
2180
|
}
|
|
2113
|
-
i
|
|
2181
|
+
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();
|
|
2114
2182
|
}
|
|
2115
2183
|
//* Update search results text (for a11y).
|
|
2116
|
-
|
|
2184
|
+
_updateSearchResultsA11yText() {
|
|
2117
2185
|
const { i18n: t } = this.options, e = this.countryList.childElementCount;
|
|
2118
2186
|
let i;
|
|
2119
2187
|
"searchResultsText" in t ? i = t.searchResultsText(e) : e === 0 ? i = t.zeroSearchResults : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace("${count}", e.toString()), this.searchResultsA11yText.textContent = i;
|
|
@@ -2163,14 +2231,14 @@ class G {
|
|
|
2163
2231
|
let i = e ? t.substring(e) : t;
|
|
2164
2232
|
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2165
2233
|
i = this._ensureHasDialCode(i);
|
|
2166
|
-
const o = this._getDialCode(i, !0), l =
|
|
2234
|
+
const o = this._getDialCode(i, !0), l = L(i);
|
|
2167
2235
|
if (o) {
|
|
2168
|
-
const r =
|
|
2169
|
-
if (!s && this.defaultCountry &&
|
|
2236
|
+
const r = L(o), c = this.dialCodeToIso2Map[r];
|
|
2237
|
+
if (!s && this.defaultCountry && c.includes(this.defaultCountry))
|
|
2170
2238
|
return this.defaultCountry;
|
|
2171
|
-
const
|
|
2172
|
-
if (!(n === "1" &&
|
|
2173
|
-
for (const a of
|
|
2239
|
+
const p = this.selectedCountryData.areaCodes && l.length > r.length, y = s && c.includes(s) && !p;
|
|
2240
|
+
if (!(n === "1" && P(l)) && !y) {
|
|
2241
|
+
for (const a of c)
|
|
2174
2242
|
if (a)
|
|
2175
2243
|
return a;
|
|
2176
2244
|
}
|
|
@@ -2185,10 +2253,9 @@ class G {
|
|
|
2185
2253
|
//* Remove highlighting from other list items and highlight the given item.
|
|
2186
2254
|
_highlightListItem(t, e) {
|
|
2187
2255
|
const i = this.highlightedItem;
|
|
2188
|
-
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem) {
|
|
2189
|
-
this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2256
|
+
if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true"), this.options.countrySearch)) {
|
|
2190
2257
|
const s = this.highlightedItem.getAttribute("id") || "";
|
|
2191
|
-
this.
|
|
2258
|
+
this.searchInput.setAttribute("aria-activedescendant", s);
|
|
2192
2259
|
}
|
|
2193
2260
|
e && this.highlightedItem.focus();
|
|
2194
2261
|
}
|
|
@@ -2292,7 +2359,7 @@ class G {
|
|
|
2292
2359
|
}
|
|
2293
2360
|
//* Close the dropdown and unbind any listeners.
|
|
2294
2361
|
_closeDropdown() {
|
|
2295
|
-
this.dropdownContent.classList.add("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "false"), this.
|
|
2362
|
+
this.dropdownContent.classList.add("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "false"), this.highlightedItem && this.highlightedItem.setAttribute("aria-selected", "false"), this.options.countrySearch && this.searchInput.removeAttribute("aria-activedescendant"), this.dropdownArrow.classList.remove("iti__arrow--up"), this.options.countrySearch && (this.searchInput.removeEventListener("input", this._handleSearchChange), this.searchClearButton.removeEventListener("click", this._handleSearchClear)), document.documentElement.removeEventListener(
|
|
2296
2363
|
"click",
|
|
2297
2364
|
this._handleClickOffToClose
|
|
2298
2365
|
), this.countryList.removeEventListener(
|
|
@@ -2302,12 +2369,12 @@ class G {
|
|
|
2302
2369
|
}
|
|
2303
2370
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2304
2371
|
_scrollTo(t) {
|
|
2305
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, l = t.offsetHeight, r = t.getBoundingClientRect().top + i,
|
|
2372
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, l = t.offsetHeight, r = t.getBoundingClientRect().top + i, c = r + l, p = r - n + e.scrollTop;
|
|
2306
2373
|
if (r < n)
|
|
2307
|
-
e.scrollTop =
|
|
2308
|
-
else if (
|
|
2309
|
-
const
|
|
2310
|
-
e.scrollTop =
|
|
2374
|
+
e.scrollTop = p;
|
|
2375
|
+
else if (c > o) {
|
|
2376
|
+
const y = s - l;
|
|
2377
|
+
e.scrollTop = p - y;
|
|
2311
2378
|
}
|
|
2312
2379
|
}
|
|
2313
2380
|
//* Replace any existing dial code with the new one
|
|
@@ -2346,7 +2413,7 @@ class G {
|
|
|
2346
2413
|
_getFullNumber(t) {
|
|
2347
2414
|
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2348
2415
|
let s;
|
|
2349
|
-
const n =
|
|
2416
|
+
const n = L(e);
|
|
2350
2417
|
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2351
2418
|
}
|
|
2352
2419
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
@@ -2510,11 +2577,11 @@ const Y = (d) => {
|
|
|
2510
2577
|
return null;
|
|
2511
2578
|
}, u = Object.assign(
|
|
2512
2579
|
(d, t) => {
|
|
2513
|
-
const e = new
|
|
2580
|
+
const e = new D(d, t);
|
|
2514
2581
|
return e._init(), d.setAttribute("data-intl-tel-input-id", e.id.toString()), u.instances[e.id] = e, d.iti = e, e;
|
|
2515
2582
|
},
|
|
2516
2583
|
{
|
|
2517
|
-
defaults:
|
|
2584
|
+
defaults: x,
|
|
2518
2585
|
//* Using a static var like this allows us to mock it in the tests.
|
|
2519
2586
|
documentReady: () => document.readyState === "complete",
|
|
2520
2587
|
//* Get the country data object.
|
|
@@ -2529,11 +2596,11 @@ const Y = (d) => {
|
|
|
2529
2596
|
attachUtils: Y,
|
|
2530
2597
|
startedLoadingUtilsScript: !1,
|
|
2531
2598
|
startedLoadingAutoCountry: !1,
|
|
2532
|
-
version: "25.
|
|
2599
|
+
version: "25.8.0"
|
|
2533
2600
|
}
|
|
2534
2601
|
), Z = {
|
|
2535
2602
|
__name: "IntlTelInput",
|
|
2536
|
-
props: /* @__PURE__ */
|
|
2603
|
+
props: /* @__PURE__ */ A({
|
|
2537
2604
|
disabled: {
|
|
2538
2605
|
type: Boolean,
|
|
2539
2606
|
default: !1
|
|
@@ -2557,47 +2624,47 @@ const Y = (d) => {
|
|
|
2557
2624
|
},
|
|
2558
2625
|
modelModifiers: {}
|
|
2559
2626
|
}),
|
|
2560
|
-
emits: /* @__PURE__ */
|
|
2627
|
+
emits: /* @__PURE__ */ A([
|
|
2561
2628
|
"changeNumber",
|
|
2562
2629
|
"changeCountry",
|
|
2563
2630
|
"changeValidity",
|
|
2564
2631
|
"changeErrorCode"
|
|
2565
2632
|
], ["update:modelValue"]),
|
|
2566
2633
|
setup(d, { expose: t, emit: e }) {
|
|
2567
|
-
const i =
|
|
2568
|
-
let a =
|
|
2634
|
+
const i = E(d, "modelValue"), s = d, n = e, o = N(), l = N(), r = N(!1), c = () => l.value ? s.options.strictMode ? l.value.isValidNumberPrecise() : l.value.isValidNumber() : null, p = () => {
|
|
2635
|
+
let a = c();
|
|
2569
2636
|
r.value !== a && (r.value = a, n("changeValidity", !!a), n(
|
|
2570
2637
|
"changeErrorCode",
|
|
2571
2638
|
a ? null : l.value.getValidationError()
|
|
2572
2639
|
));
|
|
2573
|
-
}, c = () => {
|
|
2574
|
-
var a;
|
|
2575
|
-
n("changeNumber", ((a = l.value) == null ? void 0 : a.getNumber()) ?? ""), C();
|
|
2576
2640
|
}, y = () => {
|
|
2577
2641
|
var a;
|
|
2578
|
-
n("
|
|
2642
|
+
n("changeNumber", ((a = l.value) == null ? void 0 : a.getNumber()) ?? ""), p();
|
|
2643
|
+
}, m = () => {
|
|
2644
|
+
var a;
|
|
2645
|
+
n("changeCountry", ((a = l.value) == null ? void 0 : a.getSelectedCountryData().iso2) ?? ""), y(), p();
|
|
2579
2646
|
};
|
|
2580
|
-
return
|
|
2581
|
-
o.value && (l.value = u(o.value, s.options), s.value && l.value.setNumber(s.value), s.disabled && l.value.setDisabled(s.disabled), r.value =
|
|
2582
|
-
}),
|
|
2647
|
+
return M(() => {
|
|
2648
|
+
o.value && (l.value = u(o.value, s.options), s.value && l.value.setNumber(s.value), s.disabled && l.value.setDisabled(s.disabled), r.value = c());
|
|
2649
|
+
}), B(
|
|
2583
2650
|
() => s.disabled,
|
|
2584
2651
|
(a) => {
|
|
2585
2652
|
var h;
|
|
2586
2653
|
return (h = l.value) == null ? void 0 : h.setDisabled(a);
|
|
2587
2654
|
}
|
|
2588
|
-
),
|
|
2655
|
+
), R(() => {
|
|
2589
2656
|
var a;
|
|
2590
2657
|
return (a = l.value) == null ? void 0 : a.destroy();
|
|
2591
|
-
}), t({ instance: l, input: o }), (a, h) => F((
|
|
2658
|
+
}), t({ instance: l, input: o }), (a, h) => F((V(), z("input", O({
|
|
2592
2659
|
ref_key: "input",
|
|
2593
2660
|
ref: o,
|
|
2594
|
-
"onUpdate:modelValue": h[0] || (h[0] = (
|
|
2661
|
+
"onUpdate:modelValue": h[0] || (h[0] = (_) => i.value = _),
|
|
2595
2662
|
type: "tel",
|
|
2596
|
-
onCountrychange:
|
|
2597
|
-
onInput:
|
|
2663
|
+
onCountrychange: m,
|
|
2664
|
+
onInput: y
|
|
2598
2665
|
}, d.inputProps), null, 16)), [
|
|
2599
2666
|
[
|
|
2600
|
-
|
|
2667
|
+
$,
|
|
2601
2668
|
i.value,
|
|
2602
2669
|
void 0,
|
|
2603
2670
|
{ lazy: !0 }
|