intl-tel-input 25.5.2 → 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.
@@ -1324,18 +1324,18 @@ var rawCountryData = [
1324
1324
  ]
1325
1325
  ];
1326
1326
  var allCountries = [];
1327
- for (let i = 0; i < rawCountryData.length; i++) {
1328
- const c = rawCountryData[i];
1329
- allCountries[i] = {
1327
+ for (const c of rawCountryData) {
1328
+ allCountries.push({
1330
1329
  name: "",
1331
- // this is now populated in the plugin
1330
+ // populated in the plugin
1332
1331
  iso2: c[0],
1333
1332
  dialCode: c[1],
1334
1333
  priority: c[2] || 0,
1335
1334
  areaCodes: c[3] || null,
1336
1335
  nodeById: {},
1336
+ // populated by the plugin
1337
1337
  nationalPrefix: c[4] || null
1338
- };
1338
+ });
1339
1339
  }
1340
1340
  var data_default = allCountries;
1341
1341
 
@@ -1592,6 +1592,7 @@ var interfaceTranslations = {
1592
1592
  noCountrySelected: "No country selected",
1593
1593
  countryListAriaLabel: "List of countries",
1594
1594
  searchPlaceholder: "Search",
1595
+ clearSearchAriaLabel: "Clear search",
1595
1596
  zeroSearchResults: "No results found",
1596
1597
  oneSearchResult: "1 result found",
1597
1598
  multipleSearchResults: "${count} results found",
@@ -1606,10 +1607,23 @@ var allTranslations = { ...countries_default, ...interface_default };
1606
1607
  var en_default = allTranslations;
1607
1608
 
1608
1609
  // src/js/intl-tel-input.ts
1609
- for (let i = 0; i < data_default.length; i++) {
1610
- data_default[i].name = en_default[data_default[i].iso2];
1610
+ for (const c of data_default) {
1611
+ c.name = en_default[c.iso2];
1611
1612
  }
1612
1613
  var id = 0;
1614
+ var mq = (q) => {
1615
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
1616
+ };
1617
+ var computeDefaultUseFullscreenPopup = () => {
1618
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
1619
+ const isMobileUserAgent = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1620
+ const isNarrowViewport = mq("(max-width: 500px)");
1621
+ const isShortViewport = mq("(max-height: 600px)");
1622
+ const isCoarsePointer = mq("(pointer: coarse)");
1623
+ return isMobileUserAgent || isNarrowViewport || isCoarsePointer && isShortViewport;
1624
+ }
1625
+ return false;
1626
+ };
1613
1627
  var defaults = {
1614
1628
  //* Whether or not to allow the dropdown.
1615
1629
  allowDropdown: true,
@@ -1656,13 +1670,7 @@ var defaults = {
1656
1670
  //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1657
1671
  strictMode: false,
1658
1672
  //* Use full screen popup instead of dropdown for country list.
1659
- useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? (
1660
- //* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
1661
- //* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
1662
- /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1663
- navigator.userAgent
1664
- ) || window.innerWidth <= 500
1665
- ) : false,
1673
+ useFullscreenPopup: computeDefaultUseFullscreenPopup(),
1666
1674
  //* The number type to enforce during validation.
1667
1675
  validationNumberTypes: ["MOBILE"]
1668
1676
  };
@@ -1690,7 +1698,7 @@ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g,
1690
1698
  var isRegionlessNanp = (number) => {
1691
1699
  const numeric = getNumeric(number);
1692
1700
  if (numeric.charAt(0) === "1") {
1693
- const areaCode = numeric.substr(1, 3);
1701
+ const areaCode = numeric.substring(1, 4);
1694
1702
  return regionlessNanpNumbers.includes(areaCode);
1695
1703
  }
1696
1704
  return false;
@@ -1713,8 +1721,8 @@ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDe
1713
1721
  }
1714
1722
  return formattedValue.length;
1715
1723
  };
1716
- var createEl = (name, attrs, container) => {
1717
- const el = document.createElement(name);
1724
+ var createEl = (tagName, attrs, container) => {
1725
+ const el = document.createElement(tagName);
1718
1726
  if (attrs) {
1719
1727
  Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
1720
1728
  }
@@ -1727,7 +1735,14 @@ var forEachInstance = (method, ...args) => {
1727
1735
  const { instances } = intlTelInput;
1728
1736
  Object.values(instances).forEach((instance) => instance[method](...args));
1729
1737
  };
1730
- var Iti = class {
1738
+ var Iti = class _Iti {
1739
+ /**
1740
+ * Build a space-delimited class string from an object map of className -> truthy/falsey.
1741
+ * Only keys with truthy values are included.
1742
+ */
1743
+ static _buildClassNames(flags) {
1744
+ return Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
1745
+ }
1731
1746
  constructor(input, customOptions = {}) {
1732
1747
  this.id = id++;
1733
1748
  this.telInput = input;
@@ -1790,6 +1805,16 @@ var Iti = class {
1790
1805
  this._processDialCodes();
1791
1806
  this._translateCountryNames();
1792
1807
  this._sortCountries();
1808
+ this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
1809
+ this._cacheSearchTokens();
1810
+ }
1811
+ //* Precompute and cache country search tokens to speed up filtering
1812
+ _cacheSearchTokens() {
1813
+ for (const c of this.countries) {
1814
+ c.normalisedName = normaliseString(c.name);
1815
+ c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
1816
+ c.dialCodePlus = `+${c.dialCode}`;
1817
+ }
1793
1818
  }
1794
1819
  //* Sort countries by countryOrder option (if present), then name.
1795
1820
  _sortCountries() {
@@ -1821,13 +1846,12 @@ var Iti = class {
1821
1846
  if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
1822
1847
  this.dialCodeToIso2Map[dialCode] = [];
1823
1848
  }
1824
- for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
1825
- if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
1826
- return;
1827
- }
1849
+ const iso2List = this.dialCodeToIso2Map[dialCode];
1850
+ if (iso2List.includes(iso2)) {
1851
+ return;
1828
1852
  }
1829
- const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1830
- this.dialCodeToIso2Map[dialCode][index] = iso2;
1853
+ const index = priority !== void 0 ? priority : iso2List.length;
1854
+ iso2List[index] = iso2;
1831
1855
  }
1832
1856
  //* Process onlyCountries or excludeCountries array if present.
1833
1857
  _processAllCountries() {
@@ -1852,33 +1876,30 @@ var Iti = class {
1852
1876
  }
1853
1877
  //* Translate Countries by object literal provided on config.
1854
1878
  _translateCountryNames() {
1855
- for (let i = 0; i < this.countries.length; i++) {
1856
- const iso2 = this.countries[i].iso2.toLowerCase();
1879
+ for (const c of this.countries) {
1880
+ const iso2 = c.iso2.toLowerCase();
1857
1881
  if (this.options.i18n.hasOwnProperty(iso2)) {
1858
- this.countries[i].name = this.options.i18n[iso2];
1882
+ c.name = this.options.i18n[iso2];
1859
1883
  }
1860
1884
  }
1861
1885
  }
1862
1886
  //* Generate this.dialCodes and this.dialCodeToIso2Map.
1863
1887
  _processDialCodes() {
1864
- this.dialCodes = {};
1888
+ this.dialCodes = /* @__PURE__ */ new Set();
1865
1889
  this.dialCodeMaxLen = 0;
1866
1890
  this.dialCodeToIso2Map = {};
1867
- for (let i = 0; i < this.countries.length; i++) {
1868
- const c = this.countries[i];
1869
- if (!this.dialCodes[c.dialCode]) {
1870
- this.dialCodes[c.dialCode] = true;
1891
+ for (const c of this.countries) {
1892
+ if (!this.dialCodes.has(c.dialCode)) {
1893
+ this.dialCodes.add(c.dialCode);
1871
1894
  }
1872
1895
  this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1873
1896
  }
1874
- for (let i = 0; i < this.countries.length; i++) {
1875
- const c = this.countries[i];
1897
+ for (const c of this.countries) {
1876
1898
  if (c.areaCodes) {
1877
1899
  const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
1878
- for (let j = 0; j < c.areaCodes.length; j++) {
1879
- const areaCode = c.areaCodes[j];
1900
+ for (const areaCode of c.areaCodes) {
1880
1901
  for (let k = 1; k < areaCode.length; k++) {
1881
- const partialAreaCode = areaCode.substr(0, k);
1902
+ const partialAreaCode = areaCode.substring(0, k);
1882
1903
  const partialDialCode = c.dialCode + partialAreaCode;
1883
1904
  this._addToDialCodeMap(rootIso2Code, partialDialCode);
1884
1905
  this._addToDialCodeMap(c.iso2, partialDialCode);
@@ -1906,20 +1927,14 @@ var Iti = class {
1906
1927
  countrySearch,
1907
1928
  i18n
1908
1929
  } = this.options;
1909
- let parentClass = "iti";
1910
- if (allowDropdown) {
1911
- parentClass += " iti--allow-dropdown";
1912
- }
1913
- if (showFlags) {
1914
- parentClass += " iti--show-flags";
1915
- }
1916
- if (containerClass) {
1917
- parentClass += ` ${containerClass}`;
1918
- }
1919
- if (!useFullscreenPopup) {
1920
- parentClass += " iti--inline-dropdown";
1921
- }
1922
- const wrapper = createEl("div", { class: parentClass });
1930
+ const parentClasses = _Iti._buildClassNames({
1931
+ "iti": true,
1932
+ "iti--allow-dropdown": allowDropdown,
1933
+ "iti--show-flags": showFlags,
1934
+ "iti--inline-dropdown": !useFullscreenPopup,
1935
+ [containerClass]: Boolean(containerClass)
1936
+ });
1937
+ const wrapper = createEl("div", { class: parentClasses });
1923
1938
  this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
1924
1939
  if (allowDropdown || showFlags || separateDialCode) {
1925
1940
  this.countryContainer = createEl(
@@ -1940,9 +1955,8 @@ var Iti = class {
1940
1955
  class: "iti__selected-country",
1941
1956
  "aria-expanded": "false",
1942
1957
  "aria-label": this.options.i18n.selectedCountryAriaLabel,
1943
- "aria-haspopup": "true",
1944
- "aria-controls": `iti-${this.id}__dropdown-content`,
1945
- "role": "combobox"
1958
+ "aria-haspopup": "dialog",
1959
+ "aria-controls": `iti-${this.id}__dropdown-content`
1946
1960
  },
1947
1961
  this.countryContainer
1948
1962
  );
@@ -1981,15 +1995,38 @@ var Iti = class {
1981
1995
  const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
1982
1996
  this.dropdownContent = createEl("div", {
1983
1997
  id: `iti-${this.id}__dropdown-content`,
1984
- class: `iti__dropdown-content iti__hide ${extraClasses}`
1998
+ class: `iti__dropdown-content iti__hide ${extraClasses}`,
1999
+ role: "dialog",
2000
+ "aria-modal": "true"
1985
2001
  });
1986
2002
  if (countrySearch) {
2003
+ const searchWrapper = createEl(
2004
+ "div",
2005
+ { class: "iti__search-input-wrapper" },
2006
+ this.dropdownContent
2007
+ );
2008
+ this.searchIcon = createEl(
2009
+ "span",
2010
+ {
2011
+ class: "iti__search-icon",
2012
+ "aria-hidden": "true"
2013
+ },
2014
+ searchWrapper
2015
+ );
2016
+ this.searchIcon.innerHTML = `
2017
+ <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
2018
+ <circle cx="11" cy="11" r="7" />
2019
+ <line x1="21" y1="21" x2="16.65" y2="16.65" />
2020
+ </svg>`;
1987
2021
  this.searchInput = createEl(
1988
2022
  "input",
1989
2023
  {
1990
- type: "text",
2024
+ id: `iti-${this.id}__search-input`,
2025
+ // Chrome says inputs need either a name or an id
2026
+ type: "search",
1991
2027
  class: "iti__search-input",
1992
2028
  placeholder: i18n.searchPlaceholder,
2029
+ // 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
1993
2030
  role: "combobox",
1994
2031
  "aria-expanded": "true",
1995
2032
  "aria-label": i18n.searchPlaceholder,
@@ -1997,13 +2034,42 @@ var Iti = class {
1997
2034
  "aria-autocomplete": "list",
1998
2035
  "autocomplete": "off"
1999
2036
  },
2000
- this.dropdownContent
2037
+ searchWrapper
2038
+ );
2039
+ this.searchClearButton = createEl(
2040
+ "button",
2041
+ {
2042
+ type: "button",
2043
+ class: "iti__search-clear iti__hide",
2044
+ "aria-label": i18n.clearSearchAriaLabel,
2045
+ tabindex: "-1"
2046
+ },
2047
+ searchWrapper
2001
2048
  );
2049
+ const maskId = `iti-${this.id}-clear-mask`;
2050
+ this.searchClearButton.innerHTML = `
2051
+ <svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
2052
+ <mask id="${maskId}" maskUnits="userSpaceOnUse">
2053
+ <rect width="16" height="16" fill="white" />
2054
+ <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" />
2055
+ </mask>
2056
+ <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
2057
+ </svg>`;
2002
2058
  this.searchResultsA11yText = createEl(
2003
2059
  "span",
2004
2060
  { class: "iti__a11y-text" },
2005
2061
  this.dropdownContent
2006
2062
  );
2063
+ this.searchNoResults = createEl(
2064
+ "div",
2065
+ {
2066
+ class: "iti__no-results iti__hide",
2067
+ "aria-hidden": "true"
2068
+ // all a11y messaging happens in this.searchResultsA11yText
2069
+ },
2070
+ this.dropdownContent
2071
+ );
2072
+ this.searchNoResults.textContent = i18n.zeroSearchResults;
2007
2073
  }
2008
2074
  this.countryList = createEl(
2009
2075
  "ul",
@@ -2017,18 +2083,16 @@ var Iti = class {
2017
2083
  );
2018
2084
  this._appendListItems();
2019
2085
  if (countrySearch) {
2020
- this._updateSearchResultsText();
2086
+ this._updateSearchResultsA11yText();
2021
2087
  }
2022
2088
  if (dropdownContainer) {
2023
- let dropdownClasses = "iti iti--container";
2024
- if (containerClass) {
2025
- dropdownClasses += ` ${containerClass}`;
2026
- }
2027
- if (useFullscreenPopup) {
2028
- dropdownClasses += " iti--fullscreen-popup";
2029
- } else {
2030
- dropdownClasses += " iti--inline-dropdown";
2031
- }
2089
+ const dropdownClasses = _Iti._buildClassNames({
2090
+ "iti": true,
2091
+ "iti--container": true,
2092
+ "iti--fullscreen-popup": useFullscreenPopup,
2093
+ "iti--inline-dropdown": !useFullscreenPopup,
2094
+ [containerClass]: Boolean(containerClass)
2095
+ });
2032
2096
  this.dropdown = createEl("div", { class: dropdownClasses });
2033
2097
  this.dropdown.appendChild(this.dropdownContent);
2034
2098
  } else {
@@ -2313,7 +2377,7 @@ var Iti = class {
2313
2377
  //* Adhere to the input's maxlength attr.
2314
2378
  _cap(number) {
2315
2379
  const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2316
- return max && number.length > max ? number.substr(0, max) : number;
2380
+ return max && number.length > max ? number.substring(0, max) : number;
2317
2381
  }
2318
2382
  //* Trigger a custom event on the input.
2319
2383
  _trigger(name, detailProps = {}) {
@@ -2426,6 +2490,11 @@ var Iti = class {
2426
2490
  } else {
2427
2491
  this._filterCountries("", true);
2428
2492
  }
2493
+ if (this.searchInput.value) {
2494
+ this.searchClearButton.classList.remove("iti__hide");
2495
+ } else {
2496
+ this.searchClearButton.classList.add("iti__hide");
2497
+ }
2429
2498
  };
2430
2499
  let keyupTimer = null;
2431
2500
  this._handleSearchChange = () => {
@@ -2438,14 +2507,20 @@ var Iti = class {
2438
2507
  }, 100);
2439
2508
  };
2440
2509
  this.searchInput.addEventListener("input", this._handleSearchChange);
2510
+ this._handleSearchClear = (e) => {
2511
+ e.stopPropagation();
2512
+ this.searchInput.value = "";
2513
+ this.searchInput.focus();
2514
+ doFilter();
2515
+ };
2516
+ this.searchClearButton.addEventListener("click", this._handleSearchClear);
2441
2517
  this.searchInput.addEventListener("click", (e) => e.stopPropagation());
2442
2518
  }
2443
2519
  }
2444
2520
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2445
2521
  _searchForCountry(query) {
2446
- for (let i = 0; i < this.countries.length; i++) {
2447
- const c = this.countries[i];
2448
- const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
2522
+ for (const c of this.countries) {
2523
+ const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
2449
2524
  if (startsWith) {
2450
2525
  const listItem = c.nodeById[this.id];
2451
2526
  this._highlightListItem(listItem, false);
@@ -2466,23 +2541,20 @@ var Iti = class {
2466
2541
  const dialCodeMatches = [];
2467
2542
  const dialCodeContains = [];
2468
2543
  const initialsMatches = [];
2469
- for (let i = 0; i < this.countries.length; i++) {
2470
- const c = this.countries[i];
2471
- const normalisedCountryName = normaliseString(c.name);
2472
- const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2544
+ for (const c of this.countries) {
2473
2545
  if (isReset || queryLength === 0) {
2474
2546
  nameContains.push(c);
2475
- } else if (c.iso2.toLowerCase() === normalisedQuery) {
2547
+ } else if (c.iso2 === normalisedQuery) {
2476
2548
  iso2Matches.push(c);
2477
- } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2549
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2478
2550
  nameStartWith.push(c);
2479
- } else if (normalisedCountryName.includes(normalisedQuery)) {
2551
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2480
2552
  nameContains.push(c);
2481
- } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2553
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2482
2554
  dialCodeMatches.push(c);
2483
- } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2555
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2484
2556
  dialCodeContains.push(c);
2485
- } else if (countryInitials.includes(normalisedQuery)) {
2557
+ } else if (c.initials.includes(normalisedQuery)) {
2486
2558
  initialsMatches.push(c);
2487
2559
  }
2488
2560
  }
@@ -2506,12 +2578,17 @@ var Iti = class {
2506
2578
  }
2507
2579
  if (noCountriesAddedYet) {
2508
2580
  this._highlightListItem(null, false);
2581
+ if (this.searchNoResults) {
2582
+ this.searchNoResults.classList.remove("iti__hide");
2583
+ }
2584
+ } else if (this.searchNoResults) {
2585
+ this.searchNoResults.classList.add("iti__hide");
2509
2586
  }
2510
2587
  this.countryList.scrollTop = 0;
2511
- this._updateSearchResultsText();
2588
+ this._updateSearchResultsA11yText();
2512
2589
  }
2513
2590
  //* Update search results text (for a11y).
2514
- _updateSearchResultsText() {
2591
+ _updateSearchResultsA11yText() {
2515
2592
  const { i18n } = this.options;
2516
2593
  const count = this.countryList.childElementCount;
2517
2594
  let searchText;
@@ -2602,9 +2679,9 @@ var Iti = class {
2602
2679
  const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2603
2680
  const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2604
2681
  if (!isRegionlessNanpNumber && !alreadySelected) {
2605
- for (let j = 0; j < iso2Codes.length; j++) {
2606
- if (iso2Codes[j]) {
2607
- return iso2Codes[j];
2682
+ for (const iso2 of iso2Codes) {
2683
+ if (iso2) {
2684
+ return iso2;
2608
2685
  }
2609
2686
  }
2610
2687
  }
@@ -2626,9 +2703,8 @@ var Iti = class {
2626
2703
  if (this.highlightedItem) {
2627
2704
  this.highlightedItem.classList.add("iti__highlight");
2628
2705
  this.highlightedItem.setAttribute("aria-selected", "true");
2629
- const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2630
- this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
2631
2706
  if (this.options.countrySearch) {
2707
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2632
2708
  this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
2633
2709
  }
2634
2710
  }
@@ -2637,12 +2713,11 @@ var Iti = class {
2637
2713
  }
2638
2714
  }
2639
2715
  //* Find the country data for the given iso2 code
2640
- //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2716
+ //* the allowFail option is only used during init() for the initialCountry option, and for the iso2 returned from geoIpLookup - in these 2 cases we don't want to error out
2641
2717
  _getCountryData(iso2, allowFail) {
2642
- for (let i = 0; i < this.countries.length; i++) {
2643
- if (this.countries[i].iso2 === iso2) {
2644
- return this.countries[i];
2645
- }
2718
+ const country = this.countryByIso2.get(iso2);
2719
+ if (country) {
2720
+ return country;
2646
2721
  }
2647
2722
  if (allowFail) {
2648
2723
  return null;
@@ -2793,7 +2868,6 @@ var Iti = class {
2793
2868
  _closeDropdown() {
2794
2869
  this.dropdownContent.classList.add("iti__hide");
2795
2870
  this.selectedCountry.setAttribute("aria-expanded", "false");
2796
- this.selectedCountry.removeAttribute("aria-activedescendant");
2797
2871
  if (this.highlightedItem) {
2798
2872
  this.highlightedItem.setAttribute("aria-selected", "false");
2799
2873
  }
@@ -2801,9 +2875,9 @@ var Iti = class {
2801
2875
  this.searchInput.removeAttribute("aria-activedescendant");
2802
2876
  }
2803
2877
  this.dropdownArrow.classList.remove("iti__arrow--up");
2804
- document.removeEventListener("keydown", this._handleKeydownOnDropdown);
2805
2878
  if (this.options.countrySearch) {
2806
2879
  this.searchInput.removeEventListener("input", this._handleSearchChange);
2880
+ this.searchClearButton.removeEventListener("click", this._handleSearchClear);
2807
2881
  }
2808
2882
  document.documentElement.removeEventListener(
2809
2883
  "click",
@@ -2873,11 +2947,11 @@ var Iti = class {
2873
2947
  numericChars += c;
2874
2948
  if (includeAreaCode) {
2875
2949
  if (this.dialCodeToIso2Map[numericChars]) {
2876
- dialCode = number.substr(0, i + 1);
2950
+ dialCode = number.substring(0, i + 1);
2877
2951
  }
2878
2952
  } else {
2879
- if (this.dialCodes[numericChars]) {
2880
- dialCode = number.substr(0, i + 1);
2953
+ if (this.dialCodes.has(numericChars)) {
2954
+ dialCode = number.substring(0, i + 1);
2881
2955
  break;
2882
2956
  }
2883
2957
  }
@@ -2910,7 +2984,7 @@ var Iti = class {
2910
2984
  if (dialCode) {
2911
2985
  dialCode = `+${this.selectedCountryData.dialCode}`;
2912
2986
  const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2913
- number = number.substr(start);
2987
+ number = number.substring(start);
2914
2988
  }
2915
2989
  }
2916
2990
  return this._cap(number);
@@ -3044,38 +3118,32 @@ var Iti = class {
3044
3118
  }
3045
3119
  return -99;
3046
3120
  }
3047
- //* Validate the input val
3121
+ //* Validate the input val (with precise=false)
3048
3122
  isValidNumber() {
3049
- if (!this.selectedCountryData.iso2) {
3050
- return false;
3051
- }
3052
- const val = this._getFullNumber();
3053
- const alphaCharPosition = val.search(/\p{L}/u);
3054
- if (alphaCharPosition > -1) {
3055
- const beforeAlphaChar = val.substring(0, alphaCharPosition);
3056
- const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
3057
- const isValid = this._utilsIsPossibleNumber(val);
3058
- return beforeAlphaIsValid && isValid;
3059
- }
3060
- return this._utilsIsPossibleNumber(val);
3123
+ return this._validateNumber(false);
3124
+ }
3125
+ //* Validate the input val (with precise=true)
3126
+ isValidNumberPrecise() {
3127
+ return this._validateNumber(true);
3061
3128
  }
3062
3129
  _utilsIsPossibleNumber(val) {
3063
3130
  return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3064
3131
  }
3065
- //* Validate the input val (precise)
3066
- isValidNumberPrecise() {
3132
+ //* Shared internal validation logic to handle alpha character extension rules.
3133
+ _validateNumber(precise) {
3067
3134
  if (!this.selectedCountryData.iso2) {
3068
3135
  return false;
3069
3136
  }
3070
3137
  const val = this._getFullNumber();
3071
3138
  const alphaCharPosition = val.search(/\p{L}/u);
3139
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3072
3140
  if (alphaCharPosition > -1) {
3073
3141
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
3074
- const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
3075
- const isValid = this._utilsIsValidNumber(val);
3142
+ const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3143
+ const isValid = testValidity(val);
3076
3144
  return beforeAlphaIsValid && isValid;
3077
3145
  }
3078
- return this._utilsIsValidNumber(val);
3146
+ return testValidity(val);
3079
3147
  }
3080
3148
  _utilsIsValidNumber(val) {
3081
3149
  return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
@@ -3167,7 +3235,7 @@ var intlTelInput = Object.assign(
3167
3235
  attachUtils,
3168
3236
  startedLoadingUtilsScript: false,
3169
3237
  startedLoadingAutoCountry: false,
3170
- version: "25.5.2"
3238
+ version: "25.8.0"
3171
3239
  }
3172
3240
  );
3173
3241
  var intl_tel_input_default = intlTelInput;