intl-tel-input 25.10.6 → 25.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +34 -1
- package/angular/build/IntlTelInputWithUtils.js +34 -1
- package/angular/build/types/intl-tel-input.d.ts +1 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +1 -0
- package/build/js/intlTelInput.js +35 -2
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +35 -2
- package/build/js/intlTelInputWithUtils.min.js +6 -6
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +34 -1
- package/react/build/IntlTelInput.d.ts +1 -0
- package/react/build/IntlTelInput.js +34 -1
- package/react/build/IntlTelInputWithUtils.cjs +34 -1
- package/react/build/IntlTelInputWithUtils.js +34 -1
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +227 -213
- package/vue/build/IntlTelInputWithUtils.mjs +473 -459
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as k, useModel as B, ref as D, onMounted as R, watch as F, onUnmounted as V, withDirectives as z, createElementBlock as $, openBlock as O, mergeProps as j, vModelText as U } from "vue";
|
|
2
|
+
const H = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1323,19 +1323,19 @@ const j = [
|
|
|
1323
1323
|
"263"
|
|
1324
1324
|
]
|
|
1325
1325
|
], w = [];
|
|
1326
|
-
for (const
|
|
1326
|
+
for (const d of H)
|
|
1327
1327
|
w.push({
|
|
1328
1328
|
name: "",
|
|
1329
1329
|
// populated in the plugin
|
|
1330
|
-
iso2:
|
|
1331
|
-
dialCode:
|
|
1332
|
-
priority:
|
|
1333
|
-
areaCodes:
|
|
1330
|
+
iso2: d[0],
|
|
1331
|
+
dialCode: d[1],
|
|
1332
|
+
priority: d[2] || 0,
|
|
1333
|
+
areaCodes: d[3] || null,
|
|
1334
1334
|
nodeById: {},
|
|
1335
1335
|
// populated by the plugin
|
|
1336
|
-
nationalPrefix:
|
|
1336
|
+
nationalPrefix: d[4] || null
|
|
1337
1337
|
});
|
|
1338
|
-
const
|
|
1338
|
+
const K = {
|
|
1339
1339
|
ad: "Andorra",
|
|
1340
1340
|
ae: "United Arab Emirates",
|
|
1341
1341
|
af: "Afghanistan",
|
|
@@ -1578,7 +1578,7 @@ const U = {
|
|
|
1578
1578
|
za: "South Africa",
|
|
1579
1579
|
zm: "Zambia",
|
|
1580
1580
|
zw: "Zimbabwe"
|
|
1581
|
-
},
|
|
1581
|
+
}, W = {
|
|
1582
1582
|
selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
|
|
1583
1583
|
noCountrySelected: "Select country",
|
|
1584
1584
|
countryListAriaLabel: "List of countries",
|
|
@@ -1590,17 +1590,17 @@ const U = {
|
|
|
1590
1590
|
// additional countries (not supported by country-list library)
|
|
1591
1591
|
ac: "Ascension Island",
|
|
1592
1592
|
xk: "Kosovo"
|
|
1593
|
-
},
|
|
1594
|
-
for (const
|
|
1595
|
-
|
|
1596
|
-
let
|
|
1597
|
-
const
|
|
1593
|
+
}, x = { ...K, ...W };
|
|
1594
|
+
for (const d of w)
|
|
1595
|
+
d.name = x[d.iso2];
|
|
1596
|
+
let G = 0;
|
|
1597
|
+
const S = (d) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(d).matches, q = () => {
|
|
1598
1598
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
1599
|
-
const
|
|
1600
|
-
return
|
|
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)");
|
|
1600
|
+
return d || t || i && e;
|
|
1601
1601
|
}
|
|
1602
1602
|
return !1;
|
|
1603
|
-
},
|
|
1603
|
+
}, E = {
|
|
1604
1604
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1605
1605
|
allowPhonewords: !1,
|
|
1606
1606
|
//* Whether or not to allow the dropdown.
|
|
@@ -1648,10 +1648,10 @@ const N = (u) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1648
1648
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1649
1649
|
strictMode: !1,
|
|
1650
1650
|
//* Use full screen popup instead of dropdown for country list.
|
|
1651
|
-
useFullscreenPopup:
|
|
1651
|
+
useFullscreenPopup: q(),
|
|
1652
1652
|
//* The number type to enforce during validation.
|
|
1653
1653
|
validationNumberTypes: ["MOBILE"]
|
|
1654
|
-
},
|
|
1654
|
+
}, Y = [
|
|
1655
1655
|
"800",
|
|
1656
1656
|
"822",
|
|
1657
1657
|
"833",
|
|
@@ -1669,32 +1669,32 @@ const N = (u) => typeof window < "u" && typeof window.matchMedia == "function" &
|
|
|
1669
1669
|
"887",
|
|
1670
1670
|
"888",
|
|
1671
1671
|
"889"
|
|
1672
|
-
],
|
|
1673
|
-
const t =
|
|
1672
|
+
], L = (d) => d.replace(/\D/g, ""), P = (d = "") => d.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), T = (d) => {
|
|
1673
|
+
const t = L(d);
|
|
1674
1674
|
if (t.charAt(0) === "1") {
|
|
1675
1675
|
const e = t.substring(1, 4);
|
|
1676
|
-
return
|
|
1676
|
+
return Y.includes(e);
|
|
1677
1677
|
}
|
|
1678
1678
|
return !1;
|
|
1679
|
-
},
|
|
1679
|
+
}, J = (d, t, e, i) => {
|
|
1680
1680
|
if (e === 0 && !i)
|
|
1681
1681
|
return 0;
|
|
1682
1682
|
let s = 0;
|
|
1683
1683
|
for (let n = 0; n < t.length; n++) {
|
|
1684
|
-
if (/[+0-9]/.test(t[n]) && s++, s ===
|
|
1684
|
+
if (/[+0-9]/.test(t[n]) && s++, s === d && !i)
|
|
1685
1685
|
return n + 1;
|
|
1686
|
-
if (i && s ===
|
|
1686
|
+
if (i && s === d + 1)
|
|
1687
1687
|
return n;
|
|
1688
1688
|
}
|
|
1689
1689
|
return t.length;
|
|
1690
|
-
},
|
|
1691
|
-
const i = document.createElement(
|
|
1690
|
+
}, m = (d, t, e) => {
|
|
1691
|
+
const i = document.createElement(d);
|
|
1692
1692
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1693
|
-
}, I = (
|
|
1694
|
-
const { instances: e } =
|
|
1695
|
-
Object.values(e).forEach((i) => i[
|
|
1693
|
+
}, I = (d, ...t) => {
|
|
1694
|
+
const { instances: e } = u;
|
|
1695
|
+
Object.values(e).forEach((i) => i[d](...t));
|
|
1696
1696
|
};
|
|
1697
|
-
class
|
|
1697
|
+
class N {
|
|
1698
1698
|
/**
|
|
1699
1699
|
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
1700
1700
|
* Only keys with truthy values are included.
|
|
@@ -1703,13 +1703,13 @@ class L {
|
|
|
1703
1703
|
return Object.keys(t).filter((e) => !!t[e]).join(" ");
|
|
1704
1704
|
}
|
|
1705
1705
|
constructor(t, e = {}) {
|
|
1706
|
-
this.id =
|
|
1706
|
+
this.id = G++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, E, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1707
1707
|
}
|
|
1708
1708
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1709
1709
|
_init() {
|
|
1710
1710
|
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";
|
|
1711
1711
|
const t = this.options.allowDropdown || this.options.separateDialCode;
|
|
1712
|
-
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 = { ...
|
|
1712
|
+
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 = { ...x, ...this.options.i18n };
|
|
1713
1713
|
const e = new Promise((s, n) => {
|
|
1714
1714
|
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
|
|
1715
1715
|
}), i = new Promise((s, n) => {
|
|
@@ -1727,7 +1727,7 @@ class L {
|
|
|
1727
1727
|
//* Precompute and cache country search tokens to speed up filtering
|
|
1728
1728
|
_cacheSearchTokens() {
|
|
1729
1729
|
for (const t of this.countries)
|
|
1730
|
-
t.normalisedName =
|
|
1730
|
+
t.normalisedName = P(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
|
|
1731
1731
|
}
|
|
1732
1732
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1733
1733
|
_sortCountries() {
|
|
@@ -1801,7 +1801,7 @@ class L {
|
|
|
1801
1801
|
}
|
|
1802
1802
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
1803
1803
|
_generateMarkup() {
|
|
1804
|
-
var
|
|
1804
|
+
var C, f, b;
|
|
1805
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");
|
|
1806
1806
|
const {
|
|
1807
1807
|
allowDropdown: t,
|
|
@@ -1811,23 +1811,23 @@ class L {
|
|
|
1811
1811
|
hiddenInput: n,
|
|
1812
1812
|
dropdownContainer: a,
|
|
1813
1813
|
fixDropdownWidth: o,
|
|
1814
|
-
useFullscreenPopup:
|
|
1815
|
-
countrySearch:
|
|
1816
|
-
i18n:
|
|
1817
|
-
} = this.options, r =
|
|
1814
|
+
useFullscreenPopup: l,
|
|
1815
|
+
countrySearch: h,
|
|
1816
|
+
i18n: p
|
|
1817
|
+
} = this.options, r = N._buildClassNames({
|
|
1818
1818
|
iti: !0,
|
|
1819
1819
|
"iti--allow-dropdown": t,
|
|
1820
1820
|
"iti--show-flags": i,
|
|
1821
|
-
"iti--inline-dropdown": !
|
|
1821
|
+
"iti--inline-dropdown": !l,
|
|
1822
1822
|
[s]: !!s
|
|
1823
|
-
}),
|
|
1824
|
-
if ((
|
|
1825
|
-
this.countryContainer =
|
|
1823
|
+
}), c = m("div", { class: r });
|
|
1824
|
+
if ((C = this.telInput.parentNode) == null || C.insertBefore(c, this.telInput), t || i || e) {
|
|
1825
|
+
this.countryContainer = m(
|
|
1826
1826
|
"div",
|
|
1827
1827
|
// visibly hidden until we measure it's width to set the input padding correctly
|
|
1828
1828
|
{ class: "iti__country-container iti__v-hide" },
|
|
1829
|
-
|
|
1830
|
-
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry =
|
|
1829
|
+
c
|
|
1830
|
+
), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = m(
|
|
1831
1831
|
"button",
|
|
1832
1832
|
{
|
|
1833
1833
|
type: "button",
|
|
@@ -1838,92 +1838,92 @@ class L {
|
|
|
1838
1838
|
"aria-controls": `iti-${this.id}__dropdown-content`
|
|
1839
1839
|
},
|
|
1840
1840
|
this.countryContainer
|
|
1841
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
1841
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
|
|
1842
1842
|
"div",
|
|
1843
1843
|
{ class: "iti__selected-country" },
|
|
1844
1844
|
this.countryContainer
|
|
1845
1845
|
);
|
|
1846
|
-
const
|
|
1846
|
+
const g = m(
|
|
1847
1847
|
"div",
|
|
1848
1848
|
{ class: "iti__selected-country-primary" },
|
|
1849
1849
|
this.selectedCountry
|
|
1850
1850
|
);
|
|
1851
|
-
if (this.selectedCountryInner =
|
|
1851
|
+
if (this.selectedCountryInner = m(
|
|
1852
1852
|
"div",
|
|
1853
1853
|
{ class: "iti__flag" },
|
|
1854
|
-
|
|
1855
|
-
), t && (this.dropdownArrow =
|
|
1854
|
+
g
|
|
1855
|
+
), t && (this.dropdownArrow = m(
|
|
1856
1856
|
"div",
|
|
1857
1857
|
{ class: "iti__arrow", "aria-hidden": "true" },
|
|
1858
|
-
|
|
1859
|
-
)), e && (this.selectedDialCode =
|
|
1858
|
+
g
|
|
1859
|
+
)), e && (this.selectedDialCode = m(
|
|
1860
1860
|
"div",
|
|
1861
1861
|
{ class: "iti__selected-dial-code", dir: "ltr" },
|
|
1862
1862
|
this.selectedCountry
|
|
1863
1863
|
)), t) {
|
|
1864
|
-
const
|
|
1865
|
-
if (this.dropdownContent =
|
|
1864
|
+
const _ = o ? "" : "iti--flexible-dropdown-width";
|
|
1865
|
+
if (this.dropdownContent = m("div", {
|
|
1866
1866
|
id: `iti-${this.id}__dropdown-content`,
|
|
1867
|
-
class: `iti__dropdown-content iti__hide ${
|
|
1867
|
+
class: `iti__dropdown-content iti__hide ${_}`,
|
|
1868
1868
|
role: "dialog",
|
|
1869
1869
|
"aria-modal": "true"
|
|
1870
|
-
}),
|
|
1871
|
-
const
|
|
1870
|
+
}), h) {
|
|
1871
|
+
const y = m(
|
|
1872
1872
|
"div",
|
|
1873
1873
|
{ class: "iti__search-input-wrapper" },
|
|
1874
1874
|
this.dropdownContent
|
|
1875
1875
|
);
|
|
1876
|
-
this.searchIcon =
|
|
1876
|
+
this.searchIcon = m(
|
|
1877
1877
|
"span",
|
|
1878
1878
|
{
|
|
1879
1879
|
class: "iti__search-icon",
|
|
1880
1880
|
"aria-hidden": "true"
|
|
1881
1881
|
},
|
|
1882
|
-
|
|
1882
|
+
y
|
|
1883
1883
|
), this.searchIcon.innerHTML = `
|
|
1884
1884
|
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
|
|
1885
1885
|
<circle cx="11" cy="11" r="7" />
|
|
1886
1886
|
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
1887
|
-
</svg>`, this.searchInput =
|
|
1887
|
+
</svg>`, this.searchInput = m(
|
|
1888
1888
|
"input",
|
|
1889
1889
|
{
|
|
1890
1890
|
id: `iti-${this.id}__search-input`,
|
|
1891
1891
|
// Chrome says inputs need either a name or an id
|
|
1892
1892
|
type: "search",
|
|
1893
1893
|
class: "iti__search-input",
|
|
1894
|
-
placeholder:
|
|
1894
|
+
placeholder: p.searchPlaceholder,
|
|
1895
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
|
|
1896
1896
|
role: "combobox",
|
|
1897
1897
|
"aria-expanded": "true",
|
|
1898
|
-
"aria-label":
|
|
1898
|
+
"aria-label": p.searchPlaceholder,
|
|
1899
1899
|
"aria-controls": `iti-${this.id}__country-listbox`,
|
|
1900
1900
|
"aria-autocomplete": "list",
|
|
1901
1901
|
autocomplete: "off"
|
|
1902
1902
|
},
|
|
1903
|
-
|
|
1904
|
-
), this.searchClearButton =
|
|
1903
|
+
y
|
|
1904
|
+
), this.searchClearButton = m(
|
|
1905
1905
|
"button",
|
|
1906
1906
|
{
|
|
1907
1907
|
type: "button",
|
|
1908
1908
|
class: "iti__search-clear iti__hide",
|
|
1909
|
-
"aria-label":
|
|
1909
|
+
"aria-label": p.clearSearchAriaLabel,
|
|
1910
1910
|
tabindex: "-1"
|
|
1911
1911
|
},
|
|
1912
|
-
|
|
1912
|
+
y
|
|
1913
1913
|
);
|
|
1914
|
-
const
|
|
1914
|
+
const v = `iti-${this.id}-clear-mask`;
|
|
1915
1915
|
this.searchClearButton.innerHTML = `
|
|
1916
1916
|
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
1917
|
-
<mask id="${
|
|
1917
|
+
<mask id="${v}" maskUnits="userSpaceOnUse">
|
|
1918
1918
|
<rect width="16" height="16" fill="white" />
|
|
1919
1919
|
<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" />
|
|
1920
1920
|
</mask>
|
|
1921
|
-
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${
|
|
1922
|
-
</svg>`, this.searchResultsA11yText =
|
|
1921
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${v})" />
|
|
1922
|
+
</svg>`, this.searchResultsA11yText = m(
|
|
1923
1923
|
"span",
|
|
1924
1924
|
{ class: "iti__a11y-text" },
|
|
1925
1925
|
this.dropdownContent
|
|
1926
|
-
), this.searchNoResults =
|
|
1926
|
+
), this.searchNoResults = m(
|
|
1927
1927
|
"div",
|
|
1928
1928
|
{
|
|
1929
1929
|
class: "iti__no-results iti__hide",
|
|
@@ -1931,52 +1931,52 @@ class L {
|
|
|
1931
1931
|
// all a11y messaging happens in this.searchResultsA11yText
|
|
1932
1932
|
},
|
|
1933
1933
|
this.dropdownContent
|
|
1934
|
-
), this.searchNoResults.textContent =
|
|
1934
|
+
), this.searchNoResults.textContent = p.zeroSearchResults;
|
|
1935
1935
|
}
|
|
1936
|
-
if (this.countryList =
|
|
1936
|
+
if (this.countryList = m(
|
|
1937
1937
|
"ul",
|
|
1938
1938
|
{
|
|
1939
1939
|
class: "iti__country-list",
|
|
1940
1940
|
id: `iti-${this.id}__country-listbox`,
|
|
1941
1941
|
role: "listbox",
|
|
1942
|
-
"aria-label":
|
|
1942
|
+
"aria-label": p.countryListAriaLabel
|
|
1943
1943
|
},
|
|
1944
1944
|
this.dropdownContent
|
|
1945
|
-
), this._appendListItems(),
|
|
1946
|
-
const
|
|
1945
|
+
), this._appendListItems(), h && this._updateSearchResultsA11yText(), a) {
|
|
1946
|
+
const y = N._buildClassNames({
|
|
1947
1947
|
iti: !0,
|
|
1948
1948
|
"iti--container": !0,
|
|
1949
|
-
"iti--fullscreen-popup":
|
|
1950
|
-
"iti--inline-dropdown": !
|
|
1949
|
+
"iti--fullscreen-popup": l,
|
|
1950
|
+
"iti--inline-dropdown": !l,
|
|
1951
1951
|
[s]: !!s
|
|
1952
1952
|
});
|
|
1953
|
-
this.dropdown =
|
|
1953
|
+
this.dropdown = m("div", { class: y }), this.dropdown.appendChild(this.dropdownContent);
|
|
1954
1954
|
} else
|
|
1955
1955
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
|
-
if (
|
|
1959
|
-
const
|
|
1960
|
-
if (
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1958
|
+
if (c.appendChild(this.telInput), this.countryContainer && (this._updateInputPadding(), this.countryContainer.classList.remove("iti__v-hide")), n) {
|
|
1959
|
+
const g = this.telInput.getAttribute("name") || "", _ = n(g);
|
|
1960
|
+
if (_.phone) {
|
|
1961
|
+
const y = (f = this.telInput.form) == null ? void 0 : f.querySelector(`input[name="${_.phone}"]`);
|
|
1962
|
+
y ? this.hiddenInput = y : (this.hiddenInput = m("input", {
|
|
1963
1963
|
type: "hidden",
|
|
1964
|
-
name:
|
|
1965
|
-
}),
|
|
1964
|
+
name: _.phone
|
|
1965
|
+
}), c.appendChild(this.hiddenInput));
|
|
1966
1966
|
}
|
|
1967
|
-
if (
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1967
|
+
if (_.country) {
|
|
1968
|
+
const y = (b = this.telInput.form) == null ? void 0 : b.querySelector(`input[name="${_.country}"]`);
|
|
1969
|
+
y ? this.hiddenInputCountry = y : (this.hiddenInputCountry = m("input", {
|
|
1970
1970
|
type: "hidden",
|
|
1971
|
-
name:
|
|
1972
|
-
}),
|
|
1971
|
+
name: _.country
|
|
1972
|
+
}), c.appendChild(this.hiddenInputCountry));
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
1975
|
}
|
|
1976
1976
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
1977
1977
|
_appendListItems() {
|
|
1978
1978
|
for (let t = 0; t < this.countries.length; t++) {
|
|
1979
|
-
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s =
|
|
1979
|
+
const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = m(
|
|
1980
1980
|
"li",
|
|
1981
1981
|
{
|
|
1982
1982
|
id: `iti-${this.id}__item-${e.iso2}`,
|
|
@@ -1998,11 +1998,11 @@ class L {
|
|
|
1998
1998
|
//* 1. Extracting a dial code from the given number
|
|
1999
1999
|
//* 2. Using explicit initialCountry
|
|
2000
2000
|
_setInitialState(t = !1) {
|
|
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 =
|
|
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 = T(n), { initialCountry: l, geoIpLookup: h } = this.options, p = l === "auto" && h;
|
|
2002
2002
|
if (a && !o)
|
|
2003
2003
|
this._updateCountryFromNumber(n);
|
|
2004
|
-
else if (!
|
|
2005
|
-
const r =
|
|
2004
|
+
else if (!p || t) {
|
|
2005
|
+
const r = l ? l.toLowerCase() : "";
|
|
2006
2006
|
r && this._getCountryData(r, !0) ? this._setCountry(r) : a && o ? this._setCountry("us") : this._setCountry();
|
|
2007
2007
|
}
|
|
2008
2008
|
n && this._updateValFromNumber(n);
|
|
@@ -2039,18 +2039,18 @@ class L {
|
|
|
2039
2039
|
//* Init many requests: utils script / geo ip lookup.
|
|
2040
2040
|
_initRequests() {
|
|
2041
2041
|
let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
|
|
2042
|
-
t && !
|
|
2042
|
+
t && !u.utils ? (this._handlePageLoad = () => {
|
|
2043
2043
|
var n;
|
|
2044
|
-
window.removeEventListener("load", this._handlePageLoad), (n =
|
|
2044
|
+
window.removeEventListener("load", this._handlePageLoad), (n = u.attachUtils(t)) == null || n.catch(() => {
|
|
2045
2045
|
});
|
|
2046
|
-
},
|
|
2046
|
+
}, u.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
2047
2047
|
}
|
|
2048
2048
|
//* Perform the geo ip lookup.
|
|
2049
2049
|
_loadAutoCountry() {
|
|
2050
|
-
|
|
2050
|
+
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
2051
2051
|
(t = "") => {
|
|
2052
2052
|
const e = t.toLowerCase();
|
|
2053
|
-
e && this._getCountryData(e, !0) ? (
|
|
2053
|
+
e && this._getCountryData(e, !0) ? (u.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
|
|
2054
2054
|
},
|
|
2055
2055
|
() => {
|
|
2056
2056
|
this._setInitialState(!0), I("rejectAutoCountryPromise");
|
|
@@ -2066,17 +2066,17 @@ class L {
|
|
|
2066
2066
|
let a = !1;
|
|
2067
2067
|
new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (o) => {
|
|
2068
2068
|
if (this.isAndroid && (o == null ? void 0 : o.data) === "+" && i && s && n) {
|
|
2069
|
-
const r = this.telInput.selectionStart || 0,
|
|
2070
|
-
this.telInput.value =
|
|
2069
|
+
const r = this.telInput.selectionStart || 0, c = this.telInput.value.substring(0, r - 1), C = this.telInput.value.substring(r);
|
|
2070
|
+
this.telInput.value = c + C, this._openDropdownWithPlus();
|
|
2071
2071
|
return;
|
|
2072
2072
|
}
|
|
2073
2073
|
this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
|
|
2074
|
-
const
|
|
2075
|
-
|
|
2076
|
-
const
|
|
2077
|
-
if (e && !a && !
|
|
2078
|
-
const r = this.telInput.selectionStart || 0,
|
|
2079
|
-
this.telInput.value =
|
|
2074
|
+
const l = (o == null ? void 0 : o.data) && /[^+0-9]/.test(o.data), h = (o == null ? void 0 : o.inputType) === "insertFromPaste" && this.telInput.value;
|
|
2075
|
+
l || h && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
|
|
2076
|
+
const p = (o == null ? void 0 : o.detail) && o.detail.isSetNumber;
|
|
2077
|
+
if (e && !a && !p) {
|
|
2078
|
+
const r = this.telInput.selectionStart || 0, C = this.telInput.value.substring(0, r).replace(/[^+0-9]/g, "").length, f = (o == null ? void 0 : o.inputType) === "deleteContentForward", b = this._formatNumberAsYouType(), g = J(C, b, r, f);
|
|
2079
|
+
this.telInput.value = b, this.telInput.setSelectionRange(g, g);
|
|
2080
2080
|
}
|
|
2081
2081
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (o) => {
|
|
2082
2082
|
if (o.key && o.key.length === 1 && !o.altKey && !o.ctrlKey && !o.metaKey) {
|
|
@@ -2085,11 +2085,25 @@ class L {
|
|
|
2085
2085
|
return;
|
|
2086
2086
|
}
|
|
2087
2087
|
if (t) {
|
|
2088
|
-
const
|
|
2089
|
-
(!
|
|
2088
|
+
const l = this.telInput.value, p = !(l.charAt(0) === "+") && this.telInput.selectionStart === 0 && o.key === "+", r = /^[0-9]$/.test(o.key), c = i ? r : p || r, C = l.slice(0, this.telInput.selectionStart) + o.key + l.slice(this.telInput.selectionEnd), f = this._getFullNumber(C), b = u.utils.getCoreNumber(f, this.selectedCountryData.iso2), g = this.maxCoreNumberLength && b.length > this.maxCoreNumberLength, y = this._getNewCountryFromNumber(f) !== null;
|
|
2089
|
+
(!c || g && !y && !p) && o.preventDefault();
|
|
2090
2090
|
}
|
|
2091
2091
|
}
|
|
2092
|
-
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent))
|
|
2092
|
+
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent)), t && (this._handlePasteEvent = (o) => {
|
|
2093
|
+
o.preventDefault();
|
|
2094
|
+
const l = this.telInput, h = l.selectionStart, p = l.selectionEnd, r = o.clipboardData.getData("text"), c = h === 0 && p > 0, C = !l.value.startsWith("+") || c, f = r.replace(/[^0-9+]/g, ""), b = f.startsWith("+"), g = f.replace(/\+/g, ""), _ = b && C ? `+${g}` : g;
|
|
2095
|
+
let y = l.value.slice(0, h) + _ + l.value.slice(p);
|
|
2096
|
+
const v = u.utils.getCoreNumber(y, this.selectedCountryData.iso2);
|
|
2097
|
+
if (this.maxCoreNumberLength && v.length > this.maxCoreNumberLength)
|
|
2098
|
+
if (l.selectionEnd === l.value.length) {
|
|
2099
|
+
const M = v.length - this.maxCoreNumberLength;
|
|
2100
|
+
y = y.slice(0, y.length - M);
|
|
2101
|
+
} else
|
|
2102
|
+
return;
|
|
2103
|
+
l.value = y;
|
|
2104
|
+
const A = h + _.length;
|
|
2105
|
+
l.setSelectionRange(A, A), l.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
|
|
2106
|
+
}, this.telInput.addEventListener("paste", this._handlePasteEvent));
|
|
2093
2107
|
}
|
|
2094
2108
|
//* Adhere to the input's maxlength attr.
|
|
2095
2109
|
_cap(t) {
|
|
@@ -2175,21 +2189,21 @@ class L {
|
|
|
2175
2189
|
_filterCountries(t) {
|
|
2176
2190
|
let e = !0;
|
|
2177
2191
|
this.countryList.innerHTML = "";
|
|
2178
|
-
const i =
|
|
2192
|
+
const i = P(t);
|
|
2179
2193
|
let s;
|
|
2180
2194
|
if (t === "")
|
|
2181
2195
|
s = this.countries;
|
|
2182
2196
|
else {
|
|
2183
|
-
const n = [], a = [], o = [],
|
|
2197
|
+
const n = [], a = [], o = [], l = [], h = [], p = [];
|
|
2184
2198
|
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 ?
|
|
2199
|
+
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 ? l.push(r) : r.dialCodePlus.includes(i) ? h.push(r) : r.initials.includes(i) && p.push(r);
|
|
2186
2200
|
s = [
|
|
2187
|
-
...n.sort((r,
|
|
2188
|
-
...a.sort((r,
|
|
2189
|
-
...o.sort((r,
|
|
2190
|
-
...
|
|
2191
|
-
...
|
|
2192
|
-
...
|
|
2201
|
+
...n.sort((r, c) => r.priority - c.priority),
|
|
2202
|
+
...a.sort((r, c) => r.priority - c.priority),
|
|
2203
|
+
...o.sort((r, c) => r.priority - c.priority),
|
|
2204
|
+
...l.sort((r, c) => r.priority - c.priority),
|
|
2205
|
+
...h.sort((r, c) => r.priority - c.priority),
|
|
2206
|
+
...p.sort((r, c) => r.priority - c.priority)
|
|
2193
2207
|
];
|
|
2194
2208
|
}
|
|
2195
2209
|
for (const n of s) {
|
|
@@ -2218,9 +2232,9 @@ class L {
|
|
|
2218
2232
|
//* NOTE: this is called from _setInitialState, handleUtils and setNumber.
|
|
2219
2233
|
_updateValFromNumber(t) {
|
|
2220
2234
|
let e = t;
|
|
2221
|
-
if (this.options.formatOnDisplay &&
|
|
2222
|
-
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } =
|
|
2223
|
-
e =
|
|
2235
|
+
if (this.options.formatOnDisplay && u.utils && this.selectedCountryData) {
|
|
2236
|
+
const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = u.utils.numberFormat, a = i ? s : n;
|
|
2237
|
+
e = u.utils.formatNumber(
|
|
2224
2238
|
e,
|
|
2225
2239
|
this.selectedCountryData.iso2,
|
|
2226
2240
|
a
|
|
@@ -2249,18 +2263,18 @@ class L {
|
|
|
2249
2263
|
let i = e ? t.substring(e) : t;
|
|
2250
2264
|
const s = this.selectedCountryData.iso2, n = this.selectedCountryData.dialCode;
|
|
2251
2265
|
i = this._ensureHasDialCode(i);
|
|
2252
|
-
const a = this._getDialCode(i, !0), o =
|
|
2266
|
+
const a = this._getDialCode(i, !0), o = L(i);
|
|
2253
2267
|
if (a) {
|
|
2254
|
-
const
|
|
2255
|
-
if (
|
|
2256
|
-
return
|
|
2257
|
-
if (!s && this.defaultCountry &&
|
|
2268
|
+
const l = L(a), h = this.dialCodeToIso2Map[l];
|
|
2269
|
+
if (h.length === 1)
|
|
2270
|
+
return h[0] === s ? null : h[0];
|
|
2271
|
+
if (!s && this.defaultCountry && h.includes(this.defaultCountry))
|
|
2258
2272
|
return this.defaultCountry;
|
|
2259
|
-
if (n === "1" &&
|
|
2273
|
+
if (n === "1" && T(o))
|
|
2260
2274
|
return null;
|
|
2261
|
-
const r = this.selectedCountryData.areaCodes && o.length >
|
|
2262
|
-
if (!(s &&
|
|
2263
|
-
return
|
|
2275
|
+
const r = this.selectedCountryData.areaCodes && o.length > l.length;
|
|
2276
|
+
if (!(s && h.includes(s) && !r))
|
|
2277
|
+
return h[0];
|
|
2264
2278
|
} else {
|
|
2265
2279
|
if (i.charAt(0) === "+" && o.length)
|
|
2266
2280
|
return "";
|
|
@@ -2294,13 +2308,13 @@ class L {
|
|
|
2294
2308
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 || "";
|
|
2295
2309
|
if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountry) {
|
|
2296
2310
|
const a = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
|
|
2297
|
-
let o,
|
|
2311
|
+
let o, l;
|
|
2298
2312
|
if (t) {
|
|
2299
|
-
const { name:
|
|
2300
|
-
|
|
2313
|
+
const { name: h, dialCode: p } = this.selectedCountryData;
|
|
2314
|
+
l = h, o = s.selectedCountryAriaLabel.replace("${countryName}", h).replace("${dialCode}", `+${p}`);
|
|
2301
2315
|
} else
|
|
2302
|
-
|
|
2303
|
-
this.selectedCountryInner.className = a, this.selectedCountry.setAttribute("title",
|
|
2316
|
+
l = s.noCountrySelected, o = s.noCountrySelected;
|
|
2317
|
+
this.selectedCountryInner.className = a, this.selectedCountry.setAttribute("title", l), this.selectedCountry.setAttribute("aria-label", o);
|
|
2304
2318
|
}
|
|
2305
2319
|
if (e) {
|
|
2306
2320
|
const a = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
@@ -2318,19 +2332,19 @@ class L {
|
|
|
2318
2332
|
//* Update the maximum valid number length for the currently selected country.
|
|
2319
2333
|
_updateMaxLength() {
|
|
2320
2334
|
const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2321
|
-
if (t &&
|
|
2335
|
+
if (t && u.utils)
|
|
2322
2336
|
if (s) {
|
|
2323
|
-
const n =
|
|
2324
|
-
let a =
|
|
2337
|
+
const n = u.utils.numberType[e];
|
|
2338
|
+
let a = u.utils.getExampleNumber(
|
|
2325
2339
|
s,
|
|
2326
2340
|
!1,
|
|
2327
2341
|
n,
|
|
2328
2342
|
!0
|
|
2329
2343
|
), o = a;
|
|
2330
|
-
for (;
|
|
2344
|
+
for (; u.utils.isPossibleNumber(a, s, i); )
|
|
2331
2345
|
o = a, a += "0";
|
|
2332
|
-
const
|
|
2333
|
-
this.maxCoreNumberLength =
|
|
2346
|
+
const l = u.utils.getCoreNumber(o, s);
|
|
2347
|
+
this.maxCoreNumberLength = l.length, s === "by" && (this.maxCoreNumberLength = l.length + 1);
|
|
2334
2348
|
} else
|
|
2335
2349
|
this.maxCoreNumberLength = null;
|
|
2336
2350
|
}
|
|
@@ -2365,9 +2379,9 @@ class L {
|
|
|
2365
2379
|
nationalMode: i,
|
|
2366
2380
|
customPlaceholder: s
|
|
2367
2381
|
} = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
|
|
2368
|
-
if (
|
|
2369
|
-
const a =
|
|
2370
|
-
let o = this.selectedCountryData.iso2 ?
|
|
2382
|
+
if (u.utils && n) {
|
|
2383
|
+
const a = u.utils.numberType[e];
|
|
2384
|
+
let o = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
2371
2385
|
this.selectedCountryData.iso2,
|
|
2372
2386
|
i,
|
|
2373
2387
|
a
|
|
@@ -2394,12 +2408,12 @@ class L {
|
|
|
2394
2408
|
}
|
|
2395
2409
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2396
2410
|
_scrollTo(t) {
|
|
2397
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, a = n + s, o = t.offsetHeight,
|
|
2398
|
-
if (
|
|
2399
|
-
e.scrollTop =
|
|
2400
|
-
else if (
|
|
2411
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, a = n + s, o = t.offsetHeight, l = t.getBoundingClientRect().top + i, h = l + o, p = l - n + e.scrollTop;
|
|
2412
|
+
if (l < n)
|
|
2413
|
+
e.scrollTop = p;
|
|
2414
|
+
else if (h > a) {
|
|
2401
2415
|
const r = s - o;
|
|
2402
|
-
e.scrollTop =
|
|
2416
|
+
e.scrollTop = p - r;
|
|
2403
2417
|
}
|
|
2404
2418
|
}
|
|
2405
2419
|
//* Replace any existing dial code with the new one
|
|
@@ -2438,7 +2452,7 @@ class L {
|
|
|
2438
2452
|
_getFullNumber(t) {
|
|
2439
2453
|
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2440
2454
|
let s;
|
|
2441
|
-
const n =
|
|
2455
|
+
const n = L(e);
|
|
2442
2456
|
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2443
2457
|
}
|
|
2444
2458
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
@@ -2460,7 +2474,7 @@ class L {
|
|
|
2460
2474
|
}
|
|
2461
2475
|
//* Format the number as the user types.
|
|
2462
2476
|
_formatNumberAsYouType() {
|
|
2463
|
-
const t = this._getFullNumber(), e =
|
|
2477
|
+
const t = this._getFullNumber(), e = u.utils ? u.utils.formatNumberAsYouType(t, this.selectedCountryData.iso2) : t, { dialCode: i } = this.selectedCountryData;
|
|
2464
2478
|
return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
|
|
2465
2479
|
}
|
|
2466
2480
|
//**************************
|
|
@@ -2468,11 +2482,11 @@ class L {
|
|
|
2468
2482
|
//**************************
|
|
2469
2483
|
//* This is called when the geoip call returns.
|
|
2470
2484
|
handleAutoCountry() {
|
|
2471
|
-
this.options.initialCountry === "auto" &&
|
|
2485
|
+
this.options.initialCountry === "auto" && u.autoCountry && (this.defaultCountry = u.autoCountry, this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
|
|
2472
2486
|
}
|
|
2473
2487
|
//* This is called when the utils request completes.
|
|
2474
2488
|
handleUtils() {
|
|
2475
|
-
|
|
2489
|
+
u.utils && (this.telInput.value && this._updateValFromNumber(this.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
|
|
2476
2490
|
}
|
|
2477
2491
|
//********************
|
|
2478
2492
|
//* PUBLIC METHODS
|
|
@@ -2494,22 +2508,22 @@ class L {
|
|
|
2494
2508
|
o && o.removeEventListener("click", this._handleLabelClick);
|
|
2495
2509
|
}
|
|
2496
2510
|
const { form: i } = this.telInput;
|
|
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);
|
|
2511
|
+
this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this._handlePasteEvent && this.telInput.removeEventListener("paste", this._handlePasteEvent), this.telInput.removeAttribute("data-intl-tel-input-id"), e && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
|
|
2498
2512
|
const s = this.telInput.parentNode;
|
|
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
|
|
2513
|
+
(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 u.instances[this.id];
|
|
2500
2514
|
}
|
|
2501
2515
|
//* Get the extension from the current number.
|
|
2502
2516
|
getExtension() {
|
|
2503
|
-
return
|
|
2517
|
+
return u.utils ? u.utils.getExtension(
|
|
2504
2518
|
this._getFullNumber(),
|
|
2505
2519
|
this.selectedCountryData.iso2
|
|
2506
2520
|
) : "";
|
|
2507
2521
|
}
|
|
2508
2522
|
//* Format the number to the given format.
|
|
2509
2523
|
getNumber(t) {
|
|
2510
|
-
if (
|
|
2524
|
+
if (u.utils) {
|
|
2511
2525
|
const { iso2: e } = this.selectedCountryData;
|
|
2512
|
-
return
|
|
2526
|
+
return u.utils.formatNumber(
|
|
2513
2527
|
this._getFullNumber(),
|
|
2514
2528
|
e,
|
|
2515
2529
|
t
|
|
@@ -2519,7 +2533,7 @@ class L {
|
|
|
2519
2533
|
}
|
|
2520
2534
|
//* Get the type of the entered number e.g. landline/mobile.
|
|
2521
2535
|
getNumberType() {
|
|
2522
|
-
return
|
|
2536
|
+
return u.utils ? u.utils.getNumberType(
|
|
2523
2537
|
this._getFullNumber(),
|
|
2524
2538
|
this.selectedCountryData.iso2
|
|
2525
2539
|
) : -99;
|
|
@@ -2530,9 +2544,9 @@ class L {
|
|
|
2530
2544
|
}
|
|
2531
2545
|
//* Get the validation error.
|
|
2532
2546
|
getValidationError() {
|
|
2533
|
-
if (
|
|
2547
|
+
if (u.utils) {
|
|
2534
2548
|
const { iso2: t } = this.selectedCountryData;
|
|
2535
|
-
return
|
|
2549
|
+
return u.utils.getValidationError(this._getFullNumber(), t);
|
|
2536
2550
|
}
|
|
2537
2551
|
return -99;
|
|
2538
2552
|
}
|
|
@@ -2545,7 +2559,7 @@ class L {
|
|
|
2545
2559
|
return this._validateNumber(!0);
|
|
2546
2560
|
}
|
|
2547
2561
|
_utilsIsPossibleNumber(t) {
|
|
2548
|
-
return
|
|
2562
|
+
return u.utils ? u.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2549
2563
|
}
|
|
2550
2564
|
//* Shared internal validation logic to handle alpha character extension rules.
|
|
2551
2565
|
_validateNumber(t) {
|
|
@@ -2553,13 +2567,13 @@ class L {
|
|
|
2553
2567
|
return !1;
|
|
2554
2568
|
const e = (a) => t ? this._utilsIsValidNumber(a) : this._utilsIsPossibleNumber(a), i = this._getFullNumber(), s = i.search(new RegExp("\\p{L}", "u"));
|
|
2555
2569
|
if (s > -1 && !this.options.allowPhonewords) {
|
|
2556
|
-
const a = i.substring(0, s), o = e(a),
|
|
2557
|
-
return o &&
|
|
2570
|
+
const a = i.substring(0, s), o = e(a), l = e(i);
|
|
2571
|
+
return o && l;
|
|
2558
2572
|
}
|
|
2559
2573
|
return e(i);
|
|
2560
2574
|
}
|
|
2561
2575
|
_utilsIsValidNumber(t) {
|
|
2562
|
-
return
|
|
2576
|
+
return u.utils ? u.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2563
2577
|
}
|
|
2564
2578
|
//* Update the selected country, and update the input val accordingly.
|
|
2565
2579
|
setCountry(t) {
|
|
@@ -2579,53 +2593,53 @@ class L {
|
|
|
2579
2593
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2580
2594
|
}
|
|
2581
2595
|
}
|
|
2582
|
-
const
|
|
2583
|
-
if (!
|
|
2596
|
+
const Z = (d) => {
|
|
2597
|
+
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
2584
2598
|
let t;
|
|
2585
|
-
if (typeof
|
|
2599
|
+
if (typeof d == "function")
|
|
2586
2600
|
try {
|
|
2587
|
-
t = Promise.resolve(
|
|
2601
|
+
t = Promise.resolve(d());
|
|
2588
2602
|
} catch (e) {
|
|
2589
2603
|
return Promise.reject(e);
|
|
2590
2604
|
}
|
|
2591
2605
|
else
|
|
2592
|
-
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof
|
|
2593
|
-
return
|
|
2606
|
+
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof d}`));
|
|
2607
|
+
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2594
2608
|
const i = e == null ? void 0 : e.default;
|
|
2595
2609
|
if (!i || typeof i != "object")
|
|
2596
2610
|
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
2597
|
-
return
|
|
2611
|
+
return u.utils = i, I("handleUtils"), !0;
|
|
2598
2612
|
}).catch((e) => {
|
|
2599
2613
|
throw I("rejectUtilsScriptPromise", e), e;
|
|
2600
2614
|
});
|
|
2601
2615
|
}
|
|
2602
2616
|
return null;
|
|
2603
|
-
},
|
|
2604
|
-
(
|
|
2605
|
-
const e = new
|
|
2606
|
-
return e._init(),
|
|
2617
|
+
}, u = Object.assign(
|
|
2618
|
+
(d, t) => {
|
|
2619
|
+
const e = new N(d, t);
|
|
2620
|
+
return e._init(), d.setAttribute("data-intl-tel-input-id", e.id.toString()), u.instances[e.id] = e, d.iti = e, e;
|
|
2607
2621
|
},
|
|
2608
2622
|
{
|
|
2609
|
-
defaults:
|
|
2623
|
+
defaults: E,
|
|
2610
2624
|
//* Using a static var like this allows us to mock it in the tests.
|
|
2611
2625
|
documentReady: () => document.readyState === "complete",
|
|
2612
2626
|
//* Get the country data object.
|
|
2613
2627
|
getCountryData: () => w,
|
|
2614
2628
|
//* A getter for the plugin instance.
|
|
2615
|
-
getInstance: (
|
|
2616
|
-
const t =
|
|
2617
|
-
return t ?
|
|
2629
|
+
getInstance: (d) => {
|
|
2630
|
+
const t = d.getAttribute("data-intl-tel-input-id");
|
|
2631
|
+
return t ? u.instances[t] : null;
|
|
2618
2632
|
},
|
|
2619
2633
|
//* A map from instance ID to instance object.
|
|
2620
2634
|
instances: {},
|
|
2621
|
-
attachUtils:
|
|
2635
|
+
attachUtils: Z,
|
|
2622
2636
|
startedLoadingUtilsScript: !1,
|
|
2623
2637
|
startedLoadingAutoCountry: !1,
|
|
2624
|
-
version: "25.10.
|
|
2638
|
+
version: "25.10.7"
|
|
2625
2639
|
}
|
|
2626
|
-
),
|
|
2640
|
+
), X = {
|
|
2627
2641
|
__name: "IntlTelInput",
|
|
2628
|
-
props: /* @__PURE__ */
|
|
2642
|
+
props: /* @__PURE__ */ k({
|
|
2629
2643
|
disabled: {
|
|
2630
2644
|
type: Boolean,
|
|
2631
2645
|
default: !1
|
|
@@ -2649,47 +2663,47 @@ const Y = (u) => {
|
|
|
2649
2663
|
},
|
|
2650
2664
|
modelModifiers: {}
|
|
2651
2665
|
}),
|
|
2652
|
-
emits: /* @__PURE__ */
|
|
2666
|
+
emits: /* @__PURE__ */ k([
|
|
2653
2667
|
"changeNumber",
|
|
2654
2668
|
"changeCountry",
|
|
2655
2669
|
"changeValidity",
|
|
2656
2670
|
"changeErrorCode"
|
|
2657
2671
|
], ["update:modelValue"]),
|
|
2658
|
-
setup(
|
|
2659
|
-
const i =
|
|
2660
|
-
let
|
|
2661
|
-
|
|
2672
|
+
setup(d, { expose: t, emit: e }) {
|
|
2673
|
+
const i = B(d, "modelValue"), s = d, n = e, a = D(), o = D(), l = D(!1), h = () => o.value ? s.options.strictMode ? o.value.isValidNumberPrecise() : o.value.isValidNumber() : null, p = () => {
|
|
2674
|
+
let C = h();
|
|
2675
|
+
l.value !== C && (l.value = C, n("changeValidity", !!C), n(
|
|
2662
2676
|
"changeErrorCode",
|
|
2663
|
-
|
|
2677
|
+
C ? null : o.value.getValidationError()
|
|
2664
2678
|
));
|
|
2665
2679
|
}, r = () => {
|
|
2666
|
-
var
|
|
2667
|
-
n("changeNumber", ((
|
|
2668
|
-
},
|
|
2669
|
-
var
|
|
2670
|
-
n("changeCountry", ((
|
|
2680
|
+
var C;
|
|
2681
|
+
n("changeNumber", ((C = o.value) == null ? void 0 : C.getNumber()) ?? ""), p();
|
|
2682
|
+
}, c = () => {
|
|
2683
|
+
var C;
|
|
2684
|
+
n("changeCountry", ((C = o.value) == null ? void 0 : C.getSelectedCountryData().iso2) ?? ""), r(), p();
|
|
2671
2685
|
};
|
|
2672
|
-
return
|
|
2673
|
-
a.value && (o.value =
|
|
2674
|
-
}),
|
|
2686
|
+
return R(() => {
|
|
2687
|
+
a.value && (o.value = u(a.value, s.options), s.value && o.value.setNumber(s.value), s.disabled && o.value.setDisabled(s.disabled), l.value = h());
|
|
2688
|
+
}), F(
|
|
2675
2689
|
() => s.disabled,
|
|
2676
|
-
(
|
|
2677
|
-
var
|
|
2678
|
-
return (
|
|
2690
|
+
(C) => {
|
|
2691
|
+
var f;
|
|
2692
|
+
return (f = o.value) == null ? void 0 : f.setDisabled(C);
|
|
2679
2693
|
}
|
|
2680
|
-
),
|
|
2681
|
-
var
|
|
2682
|
-
return (
|
|
2683
|
-
}), t({ instance: o, input: a }), (
|
|
2694
|
+
), V(() => {
|
|
2695
|
+
var C;
|
|
2696
|
+
return (C = o.value) == null ? void 0 : C.destroy();
|
|
2697
|
+
}), t({ instance: o, input: a }), (C, f) => z((O(), $("input", j({
|
|
2684
2698
|
ref_key: "input",
|
|
2685
2699
|
ref: a,
|
|
2686
|
-
"onUpdate:modelValue":
|
|
2700
|
+
"onUpdate:modelValue": f[0] || (f[0] = (b) => i.value = b),
|
|
2687
2701
|
type: "tel",
|
|
2688
|
-
onCountrychange:
|
|
2702
|
+
onCountrychange: c,
|
|
2689
2703
|
onInput: r
|
|
2690
|
-
},
|
|
2704
|
+
}, d.inputProps), null, 16)), [
|
|
2691
2705
|
[
|
|
2692
|
-
|
|
2706
|
+
U,
|
|
2693
2707
|
i.value,
|
|
2694
2708
|
void 0,
|
|
2695
2709
|
{ lazy: !0 }
|
|
@@ -2698,5 +2712,5 @@ const Y = (u) => {
|
|
|
2698
2712
|
}
|
|
2699
2713
|
};
|
|
2700
2714
|
export {
|
|
2701
|
-
|
|
2715
|
+
X as default
|
|
2702
2716
|
};
|