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.
@@ -1,5 +1,5 @@
1
- import { mergeModels as N, useModel as x, ref as L, onMounted as E, watch as M, onUnmounted as B, withDirectives as F, createElementBlock as V, openBlock as z, mergeProps as R, vModelText as O } from "vue";
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 j = {
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
- }, U = {
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
- }, k = { ...j, ...U };
1593
+ }, T = { ...U, ...H };
1593
1594
  for (const d of w)
1594
- d.name = k[d.iso2];
1595
- let H = 0;
1596
- const D = (d) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(d).matches, K = () => {
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 = D("(max-width: 500px)"), e = D("(max-height: 600px)"), i = D("(pointer: coarse)");
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
- }, P = {
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: K(),
1649
+ useFullscreenPopup: W(),
1649
1650
  //* The number type to enforce during validation.
1650
1651
  validationNumberTypes: ["MOBILE"]
1651
- }, W = [
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
- ], v = (d) => d.replace(/\D/g, ""), S = (d = "") => d.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), A = (d) => {
1670
- const t = v(d);
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 W.includes(e);
1674
+ return q.includes(e);
1674
1675
  }
1675
1676
  return !1;
1676
- }, q = (d, t, e, i) => {
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
- }, m = (d, t, e) => {
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 G {
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 = H++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, P, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
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 = { ...k, ...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 = S(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
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, b;
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: p,
1801
- i18n: C
1802
- } = this.options;
1803
- let c = "iti";
1804
- t && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), r || (c += " iti--inline-dropdown");
1805
- const y = m("div", { class: c });
1806
- if ((a = this.telInput.parentNode) == null || a.insertBefore(y, this.telInput), t || i || e) {
1807
- this.countryContainer = m(
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
- y
1811
- ), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = m(
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": "true",
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 = m(
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 _ = m("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1829
- if (this.selectedCountryInner = m("div", { class: "iti__flag" }, _), this.selectedCountryA11yText = m(
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 = m(
1843
+ ), t && (this.dropdownArrow = C(
1834
1844
  "div",
1835
1845
  { class: "iti__arrow", "aria-hidden": "true" },
1836
- _
1837
- )), e && (this.selectedDialCode = m(
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 = m("div", {
1853
+ if (this.dropdownContent = C("div", {
1844
1854
  id: `iti-${this.id}__dropdown-content`,
1845
- class: `iti__dropdown-content iti__hide ${f}`
1846
- }), p && (this.searchInput = m(
1847
- "input",
1848
- {
1849
- type: "text",
1850
- class: "iti__search-input",
1851
- placeholder: C.searchPlaceholder,
1852
- role: "combobox",
1853
- "aria-expanded": "true",
1854
- "aria-label": C.searchPlaceholder,
1855
- "aria-controls": `iti-${this.id}__country-listbox`,
1856
- "aria-autocomplete": "list",
1857
- autocomplete: "off"
1858
- },
1859
- this.dropdownContent
1860
- ), this.searchResultsA11yText = m(
1861
- "span",
1862
- { class: "iti__a11y-text" },
1863
- this.dropdownContent
1864
- )), this.countryList = m(
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": C.countryListAriaLabel
1930
+ "aria-label": p.countryListAriaLabel
1871
1931
  },
1872
1932
  this.dropdownContent
1873
- ), this._appendListItems(), p && this._updateSearchResultsText(), o) {
1874
- let g = "iti iti--container";
1875
- s && (g += ` ${s}`), r ? g += " iti--fullscreen-popup" : g += " iti--inline-dropdown", this.dropdown = m("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
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 (y.appendChild(this.telInput), this._updateInputPadding(), n) {
1881
- const _ = this.telInput.getAttribute("name") || "", f = n(_);
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 = m("input", {
1950
+ g ? this.hiddenInput = g : (this.hiddenInput = C("input", {
1885
1951
  type: "hidden",
1886
1952
  name: f.phone
1887
- }), y.appendChild(this.hiddenInput));
1953
+ }), m.appendChild(this.hiddenInput));
1888
1954
  }
1889
1955
  if (f.country) {
1890
- const g = (b = this.telInput.form) == null ? void 0 : b.querySelector(`input[name="${f.country}"]`);
1891
- g ? this.hiddenInputCountry = g : (this.hiddenInputCountry = m("input", {
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
- }), y.appendChild(this.hiddenInputCountry));
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 = m(
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 = A(n), { initialCountry: r, geoIpLookup: p } = this.options, C = r === "auto" && p;
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 (!C || t) {
1927
- const c = r ? r.toLowerCase() : "";
1928
- c && this._getCountryData(c, !0) ? this._setCountry(c) : o && l ? this._setCountry("us") : this._setCountry();
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 y = this.telInput.selectionStart || 0, a = this.telInput.value.substring(0, y - 1), h = this.telInput.value.substring(y);
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 p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), C = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
1997
- p || C && !t ? l = !0 : /[^+0-9]/.test(this.telInput.value) || (l = !1);
1998
- const c = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
1999
- if (e && !l && !c) {
2000
- const y = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, y).replace(/[^+0-9]/g, "").length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", _ = this._formatNumberAsYouType(), f = q(h, _, y, b);
2001
- this.telInput.value = _, this.telInput.setSelectionRange(f, f);
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 p = this.telInput.value, c = !(p.charAt(0) === "+") && this.telInput.selectionStart === 0 && r.key === "+", y = /^[0-9]$/.test(r.key), a = i ? y : c || y, h = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), b = this._getFullNumber(h), _ = u.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength, T = this._getNewCountryFromNumber(b) !== null;
2011
- (!a || f && !T && !c) && r.preventDefault();
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.searchInput.addEventListener("click", (o) => o.stopPropagation());
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 = S(t), n = s.length, o = [], l = [], r = [], p = [], C = [], c = [];
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 ? p.push(a) : a.dialCodePlus.includes(s) ? C.push(a) : a.initials.includes(s) && c.push(a);
2101
- const y = [
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
- ...C.sort((a, h) => a.priority - h.priority),
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 y) {
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 && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
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
- _updateSearchResultsText() {
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 = v(i);
2234
+ const o = this._getDialCode(i, !0), l = L(i);
2167
2235
  if (o) {
2168
- const r = v(o), p = this.dialCodeToIso2Map[r];
2169
- if (!s && this.defaultCountry && p.includes(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 C = this.selectedCountryData.areaCodes && l.length > r.length, c = s && p.includes(s) && !C;
2172
- if (!(n === "1" && A(l)) && !c) {
2173
- for (const a of p)
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.selectedCountry.setAttribute("aria-activedescendant", s), this.options.countrySearch && this.searchInput.setAttribute("aria-activedescendant", s);
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.selectedCountry.removeAttribute("aria-activedescendant"), this.highlightedItem && this.highlightedItem.setAttribute("aria-selected", "false"), this.options.countrySearch && this.searchInput.removeAttribute("aria-activedescendant"), this.dropdownArrow.classList.remove("iti__arrow--up"), document.removeEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch && this.searchInput.removeEventListener("input", this._handleSearchChange), document.documentElement.removeEventListener(
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, p = r + l, C = r - n + e.scrollTop;
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 = C;
2308
- else if (p > o) {
2309
- const c = s - l;
2310
- e.scrollTop = C - c;
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 = v(e);
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 G(d, t);
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: P,
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.7.0"
2599
+ version: "25.8.0"
2533
2600
  }
2534
2601
  ), Z = {
2535
2602
  __name: "IntlTelInput",
2536
- props: /* @__PURE__ */ N({
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__ */ N([
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 = x(d, "modelValue"), s = d, n = e, o = L(), l = L(), r = L(!1), p = () => l.value ? s.options.strictMode ? l.value.isValidNumberPrecise() : l.value.isValidNumber() : null, C = () => {
2568
- let a = p();
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("changeCountry", ((a = l.value) == null ? void 0 : a.getSelectedCountryData().iso2) ?? ""), c(), C();
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 E(() => {
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 = p());
2582
- }), M(
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
- ), B(() => {
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((z(), V("input", R({
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] = (b) => i.value = b),
2661
+ "onUpdate:modelValue": h[0] || (h[0] = (_) => i.value = _),
2595
2662
  type: "tel",
2596
- onCountrychange: y,
2597
- onInput: c
2663
+ onCountrychange: m,
2664
+ onInput: y
2598
2665
  }, d.inputProps), null, 16)), [
2599
2666
  [
2600
- O,
2667
+ $,
2601
2668
  i.value,
2602
2669
  void 0,
2603
2670
  { lazy: !0 }