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 = Object.assign(Object.assign({}, countries_default), interf
1606
1607
  var en_default = allTranslations;
1607
1608
 
1608
1609
  // angular/build/temp/intl-tel-input.js
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,11 +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(navigator.userAgent) || window.innerWidth <= 500
1663
- ) : false,
1673
+ useFullscreenPopup: computeDefaultUseFullscreenPopup(),
1664
1674
  //* The number type to enforce during validation.
1665
1675
  validationNumberTypes: ["MOBILE"]
1666
1676
  };
@@ -1688,7 +1698,7 @@ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g,
1688
1698
  var isRegionlessNanp = (number) => {
1689
1699
  const numeric = getNumeric(number);
1690
1700
  if (numeric.charAt(0) === "1") {
1691
- const areaCode = numeric.substr(1, 3);
1701
+ const areaCode = numeric.substring(1, 4);
1692
1702
  return regionlessNanpNumbers.includes(areaCode);
1693
1703
  }
1694
1704
  return false;
@@ -1711,8 +1721,8 @@ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDe
1711
1721
  }
1712
1722
  return formattedValue.length;
1713
1723
  };
1714
- var createEl = (name, attrs, container) => {
1715
- const el = document.createElement(name);
1724
+ var createEl = (tagName, attrs, container) => {
1725
+ const el = document.createElement(tagName);
1716
1726
  if (attrs) {
1717
1727
  Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
1718
1728
  }
@@ -1725,7 +1735,14 @@ var forEachInstance = (method, ...args) => {
1725
1735
  const { instances } = intlTelInput;
1726
1736
  Object.values(instances).forEach((instance) => instance[method](...args));
1727
1737
  };
1728
- 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
+ }
1729
1746
  constructor(input, customOptions = {}) {
1730
1747
  this.id = id++;
1731
1748
  this.telInput = input;
@@ -1788,6 +1805,16 @@ var Iti = class {
1788
1805
  this._processDialCodes();
1789
1806
  this._translateCountryNames();
1790
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
+ }
1791
1818
  }
1792
1819
  //* Sort countries by countryOrder option (if present), then name.
1793
1820
  _sortCountries() {
@@ -1819,13 +1846,12 @@ var Iti = class {
1819
1846
  if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
1820
1847
  this.dialCodeToIso2Map[dialCode] = [];
1821
1848
  }
1822
- for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
1823
- if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
1824
- return;
1825
- }
1849
+ const iso2List = this.dialCodeToIso2Map[dialCode];
1850
+ if (iso2List.includes(iso2)) {
1851
+ return;
1826
1852
  }
1827
- const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1828
- this.dialCodeToIso2Map[dialCode][index] = iso2;
1853
+ const index = priority !== void 0 ? priority : iso2List.length;
1854
+ iso2List[index] = iso2;
1829
1855
  }
1830
1856
  //* Process onlyCountries or excludeCountries array if present.
1831
1857
  _processAllCountries() {
@@ -1842,33 +1868,30 @@ var Iti = class {
1842
1868
  }
1843
1869
  //* Translate Countries by object literal provided on config.
1844
1870
  _translateCountryNames() {
1845
- for (let i = 0; i < this.countries.length; i++) {
1846
- const iso2 = this.countries[i].iso2.toLowerCase();
1871
+ for (const c of this.countries) {
1872
+ const iso2 = c.iso2.toLowerCase();
1847
1873
  if (this.options.i18n.hasOwnProperty(iso2)) {
1848
- this.countries[i].name = this.options.i18n[iso2];
1874
+ c.name = this.options.i18n[iso2];
1849
1875
  }
1850
1876
  }
1851
1877
  }
1852
1878
  //* Generate this.dialCodes and this.dialCodeToIso2Map.
1853
1879
  _processDialCodes() {
1854
- this.dialCodes = {};
1880
+ this.dialCodes = /* @__PURE__ */ new Set();
1855
1881
  this.dialCodeMaxLen = 0;
1856
1882
  this.dialCodeToIso2Map = {};
1857
- for (let i = 0; i < this.countries.length; i++) {
1858
- const c = this.countries[i];
1859
- if (!this.dialCodes[c.dialCode]) {
1860
- this.dialCodes[c.dialCode] = true;
1883
+ for (const c of this.countries) {
1884
+ if (!this.dialCodes.has(c.dialCode)) {
1885
+ this.dialCodes.add(c.dialCode);
1861
1886
  }
1862
1887
  this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1863
1888
  }
1864
- for (let i = 0; i < this.countries.length; i++) {
1865
- const c = this.countries[i];
1889
+ for (const c of this.countries) {
1866
1890
  if (c.areaCodes) {
1867
1891
  const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
1868
- for (let j = 0; j < c.areaCodes.length; j++) {
1869
- const areaCode = c.areaCodes[j];
1892
+ for (const areaCode of c.areaCodes) {
1870
1893
  for (let k = 1; k < areaCode.length; k++) {
1871
- const partialAreaCode = areaCode.substr(0, k);
1894
+ const partialAreaCode = areaCode.substring(0, k);
1872
1895
  const partialDialCode = c.dialCode + partialAreaCode;
1873
1896
  this._addToDialCodeMap(rootIso2Code, partialDialCode);
1874
1897
  this._addToDialCodeMap(c.iso2, partialDialCode);
@@ -1886,20 +1909,14 @@ var Iti = class {
1886
1909
  this.telInput.setAttribute("autocomplete", "off");
1887
1910
  }
1888
1911
  const { allowDropdown, separateDialCode, showFlags, containerClass, hiddenInput, dropdownContainer, fixDropdownWidth, useFullscreenPopup, countrySearch, i18n } = this.options;
1889
- let parentClass = "iti";
1890
- if (allowDropdown) {
1891
- parentClass += " iti--allow-dropdown";
1892
- }
1893
- if (showFlags) {
1894
- parentClass += " iti--show-flags";
1895
- }
1896
- if (containerClass) {
1897
- parentClass += ` ${containerClass}`;
1898
- }
1899
- if (!useFullscreenPopup) {
1900
- parentClass += " iti--inline-dropdown";
1901
- }
1902
- const wrapper = createEl("div", { class: parentClass });
1912
+ const parentClasses = _Iti._buildClassNames({
1913
+ "iti": true,
1914
+ "iti--allow-dropdown": allowDropdown,
1915
+ "iti--show-flags": showFlags,
1916
+ "iti--inline-dropdown": !useFullscreenPopup,
1917
+ [containerClass]: Boolean(containerClass)
1918
+ });
1919
+ const wrapper = createEl("div", { class: parentClasses });
1903
1920
  (_a = this.telInput.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(wrapper, this.telInput);
1904
1921
  if (allowDropdown || showFlags || separateDialCode) {
1905
1922
  this.countryContainer = createEl("div", { class: "iti__country-container" }, wrapper);
@@ -1914,9 +1931,8 @@ var Iti = class {
1914
1931
  class: "iti__selected-country",
1915
1932
  "aria-expanded": "false",
1916
1933
  "aria-label": this.options.i18n.selectedCountryAriaLabel,
1917
- "aria-haspopup": "true",
1918
- "aria-controls": `iti-${this.id}__dropdown-content`,
1919
- "role": "combobox"
1934
+ "aria-haspopup": "dialog",
1935
+ "aria-controls": `iti-${this.id}__dropdown-content`
1920
1936
  }, this.countryContainer);
1921
1937
  if (this.telInput.disabled) {
1922
1938
  this.selectedCountry.setAttribute("disabled", "true");
@@ -1937,21 +1953,57 @@ var Iti = class {
1937
1953
  const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
1938
1954
  this.dropdownContent = createEl("div", {
1939
1955
  id: `iti-${this.id}__dropdown-content`,
1940
- class: `iti__dropdown-content iti__hide ${extraClasses}`
1956
+ class: `iti__dropdown-content iti__hide ${extraClasses}`,
1957
+ role: "dialog",
1958
+ "aria-modal": "true"
1941
1959
  });
1942
1960
  if (countrySearch) {
1961
+ const searchWrapper = createEl("div", { class: "iti__search-input-wrapper" }, this.dropdownContent);
1962
+ this.searchIcon = createEl("span", {
1963
+ class: "iti__search-icon",
1964
+ "aria-hidden": "true"
1965
+ }, searchWrapper);
1966
+ this.searchIcon.innerHTML = `
1967
+ <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
1968
+ <circle cx="11" cy="11" r="7" />
1969
+ <line x1="21" y1="21" x2="16.65" y2="16.65" />
1970
+ </svg>`;
1943
1971
  this.searchInput = createEl("input", {
1944
- type: "text",
1972
+ id: `iti-${this.id}__search-input`,
1973
+ // Chrome says inputs need either a name or an id
1974
+ type: "search",
1945
1975
  class: "iti__search-input",
1946
1976
  placeholder: i18n.searchPlaceholder,
1977
+ // 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
1947
1978
  role: "combobox",
1948
1979
  "aria-expanded": "true",
1949
1980
  "aria-label": i18n.searchPlaceholder,
1950
1981
  "aria-controls": `iti-${this.id}__country-listbox`,
1951
1982
  "aria-autocomplete": "list",
1952
1983
  "autocomplete": "off"
1953
- }, this.dropdownContent);
1984
+ }, searchWrapper);
1985
+ this.searchClearButton = createEl("button", {
1986
+ type: "button",
1987
+ class: "iti__search-clear iti__hide",
1988
+ "aria-label": i18n.clearSearchAriaLabel,
1989
+ tabindex: "-1"
1990
+ }, searchWrapper);
1991
+ const maskId = `iti-${this.id}-clear-mask`;
1992
+ this.searchClearButton.innerHTML = `
1993
+ <svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
1994
+ <mask id="${maskId}" maskUnits="userSpaceOnUse">
1995
+ <rect width="16" height="16" fill="white" />
1996
+ <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" />
1997
+ </mask>
1998
+ <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
1999
+ </svg>`;
1954
2000
  this.searchResultsA11yText = createEl("span", { class: "iti__a11y-text" }, this.dropdownContent);
2001
+ this.searchNoResults = createEl("div", {
2002
+ class: "iti__no-results iti__hide",
2003
+ "aria-hidden": "true"
2004
+ // all a11y messaging happens in this.searchResultsA11yText
2005
+ }, this.dropdownContent);
2006
+ this.searchNoResults.textContent = i18n.zeroSearchResults;
1955
2007
  }
1956
2008
  this.countryList = createEl("ul", {
1957
2009
  class: "iti__country-list",
@@ -1961,18 +2013,16 @@ var Iti = class {
1961
2013
  }, this.dropdownContent);
1962
2014
  this._appendListItems();
1963
2015
  if (countrySearch) {
1964
- this._updateSearchResultsText();
2016
+ this._updateSearchResultsA11yText();
1965
2017
  }
1966
2018
  if (dropdownContainer) {
1967
- let dropdownClasses = "iti iti--container";
1968
- if (containerClass) {
1969
- dropdownClasses += ` ${containerClass}`;
1970
- }
1971
- if (useFullscreenPopup) {
1972
- dropdownClasses += " iti--fullscreen-popup";
1973
- } else {
1974
- dropdownClasses += " iti--inline-dropdown";
1975
- }
2019
+ const dropdownClasses = _Iti._buildClassNames({
2020
+ "iti": true,
2021
+ "iti--container": true,
2022
+ "iti--fullscreen-popup": useFullscreenPopup,
2023
+ "iti--inline-dropdown": !useFullscreenPopup,
2024
+ [containerClass]: Boolean(containerClass)
2025
+ });
1976
2026
  this.dropdown = createEl("div", { class: dropdownClasses });
1977
2027
  this.dropdown.appendChild(this.dropdownContent);
1978
2028
  } else {
@@ -2246,7 +2296,7 @@ var Iti = class {
2246
2296
  //* Adhere to the input's maxlength attr.
2247
2297
  _cap(number) {
2248
2298
  const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2249
- return max && number.length > max ? number.substr(0, max) : number;
2299
+ return max && number.length > max ? number.substring(0, max) : number;
2250
2300
  }
2251
2301
  //* Trigger a custom event on the input.
2252
2302
  _trigger(name, detailProps = {}) {
@@ -2355,6 +2405,11 @@ var Iti = class {
2355
2405
  } else {
2356
2406
  this._filterCountries("", true);
2357
2407
  }
2408
+ if (this.searchInput.value) {
2409
+ this.searchClearButton.classList.remove("iti__hide");
2410
+ } else {
2411
+ this.searchClearButton.classList.add("iti__hide");
2412
+ }
2358
2413
  };
2359
2414
  let keyupTimer = null;
2360
2415
  this._handleSearchChange = () => {
@@ -2367,14 +2422,20 @@ var Iti = class {
2367
2422
  }, 100);
2368
2423
  };
2369
2424
  this.searchInput.addEventListener("input", this._handleSearchChange);
2425
+ this._handleSearchClear = (e) => {
2426
+ e.stopPropagation();
2427
+ this.searchInput.value = "";
2428
+ this.searchInput.focus();
2429
+ doFilter();
2430
+ };
2431
+ this.searchClearButton.addEventListener("click", this._handleSearchClear);
2370
2432
  this.searchInput.addEventListener("click", (e) => e.stopPropagation());
2371
2433
  }
2372
2434
  }
2373
2435
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2374
2436
  _searchForCountry(query) {
2375
- for (let i = 0; i < this.countries.length; i++) {
2376
- const c = this.countries[i];
2377
- const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
2437
+ for (const c of this.countries) {
2438
+ const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
2378
2439
  if (startsWith) {
2379
2440
  const listItem = c.nodeById[this.id];
2380
2441
  this._highlightListItem(listItem, false);
@@ -2395,23 +2456,20 @@ var Iti = class {
2395
2456
  const dialCodeMatches = [];
2396
2457
  const dialCodeContains = [];
2397
2458
  const initialsMatches = [];
2398
- for (let i = 0; i < this.countries.length; i++) {
2399
- const c = this.countries[i];
2400
- const normalisedCountryName = normaliseString(c.name);
2401
- const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2459
+ for (const c of this.countries) {
2402
2460
  if (isReset || queryLength === 0) {
2403
2461
  nameContains.push(c);
2404
- } else if (c.iso2.toLowerCase() === normalisedQuery) {
2462
+ } else if (c.iso2 === normalisedQuery) {
2405
2463
  iso2Matches.push(c);
2406
- } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2464
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2407
2465
  nameStartWith.push(c);
2408
- } else if (normalisedCountryName.includes(normalisedQuery)) {
2466
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2409
2467
  nameContains.push(c);
2410
- } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2468
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2411
2469
  dialCodeMatches.push(c);
2412
- } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2470
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2413
2471
  dialCodeContains.push(c);
2414
- } else if (countryInitials.includes(normalisedQuery)) {
2472
+ } else if (c.initials.includes(normalisedQuery)) {
2415
2473
  initialsMatches.push(c);
2416
2474
  }
2417
2475
  }
@@ -2435,12 +2493,17 @@ var Iti = class {
2435
2493
  }
2436
2494
  if (noCountriesAddedYet) {
2437
2495
  this._highlightListItem(null, false);
2496
+ if (this.searchNoResults) {
2497
+ this.searchNoResults.classList.remove("iti__hide");
2498
+ }
2499
+ } else if (this.searchNoResults) {
2500
+ this.searchNoResults.classList.add("iti__hide");
2438
2501
  }
2439
2502
  this.countryList.scrollTop = 0;
2440
- this._updateSearchResultsText();
2503
+ this._updateSearchResultsA11yText();
2441
2504
  }
2442
2505
  //* Update search results text (for a11y).
2443
- _updateSearchResultsText() {
2506
+ _updateSearchResultsA11yText() {
2444
2507
  const { i18n } = this.options;
2445
2508
  const count = this.countryList.childElementCount;
2446
2509
  let searchText;
@@ -2528,9 +2591,9 @@ var Iti = class {
2528
2591
  const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2529
2592
  const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2530
2593
  if (!isRegionlessNanpNumber && !alreadySelected) {
2531
- for (let j = 0; j < iso2Codes.length; j++) {
2532
- if (iso2Codes[j]) {
2533
- return iso2Codes[j];
2594
+ for (const iso2 of iso2Codes) {
2595
+ if (iso2) {
2596
+ return iso2;
2534
2597
  }
2535
2598
  }
2536
2599
  }
@@ -2552,9 +2615,8 @@ var Iti = class {
2552
2615
  if (this.highlightedItem) {
2553
2616
  this.highlightedItem.classList.add("iti__highlight");
2554
2617
  this.highlightedItem.setAttribute("aria-selected", "true");
2555
- const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2556
- this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
2557
2618
  if (this.options.countrySearch) {
2619
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2558
2620
  this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
2559
2621
  }
2560
2622
  }
@@ -2563,12 +2625,11 @@ var Iti = class {
2563
2625
  }
2564
2626
  }
2565
2627
  //* Find the country data for the given iso2 code
2566
- //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2628
+ //* 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
2567
2629
  _getCountryData(iso2, allowFail) {
2568
- for (let i = 0; i < this.countries.length; i++) {
2569
- if (this.countries[i].iso2 === iso2) {
2570
- return this.countries[i];
2571
- }
2630
+ const country = this.countryByIso2.get(iso2);
2631
+ if (country) {
2632
+ return country;
2572
2633
  }
2573
2634
  if (allowFail) {
2574
2635
  return null;
@@ -2703,7 +2764,6 @@ var Iti = class {
2703
2764
  _closeDropdown() {
2704
2765
  this.dropdownContent.classList.add("iti__hide");
2705
2766
  this.selectedCountry.setAttribute("aria-expanded", "false");
2706
- this.selectedCountry.removeAttribute("aria-activedescendant");
2707
2767
  if (this.highlightedItem) {
2708
2768
  this.highlightedItem.setAttribute("aria-selected", "false");
2709
2769
  }
@@ -2711,9 +2771,9 @@ var Iti = class {
2711
2771
  this.searchInput.removeAttribute("aria-activedescendant");
2712
2772
  }
2713
2773
  this.dropdownArrow.classList.remove("iti__arrow--up");
2714
- document.removeEventListener("keydown", this._handleKeydownOnDropdown);
2715
2774
  if (this.options.countrySearch) {
2716
2775
  this.searchInput.removeEventListener("input", this._handleSearchChange);
2776
+ this.searchClearButton.removeEventListener("click", this._handleSearchClear);
2717
2777
  }
2718
2778
  document.documentElement.removeEventListener("click", this._handleClickOffToClose);
2719
2779
  this.countryList.removeEventListener("mouseover", this._handleMouseoverCountryList);
@@ -2777,11 +2837,11 @@ var Iti = class {
2777
2837
  numericChars += c;
2778
2838
  if (includeAreaCode) {
2779
2839
  if (this.dialCodeToIso2Map[numericChars]) {
2780
- dialCode = number.substr(0, i + 1);
2840
+ dialCode = number.substring(0, i + 1);
2781
2841
  }
2782
2842
  } else {
2783
- if (this.dialCodes[numericChars]) {
2784
- dialCode = number.substr(0, i + 1);
2843
+ if (this.dialCodes.has(numericChars)) {
2844
+ dialCode = number.substring(0, i + 1);
2785
2845
  break;
2786
2846
  }
2787
2847
  }
@@ -2814,7 +2874,7 @@ var Iti = class {
2814
2874
  if (dialCode) {
2815
2875
  dialCode = `+${this.selectedCountryData.dialCode}`;
2816
2876
  const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2817
- number = number.substr(start);
2877
+ number = number.substring(start);
2818
2878
  }
2819
2879
  }
2820
2880
  return this._cap(number);
@@ -2933,38 +2993,32 @@ var Iti = class {
2933
2993
  }
2934
2994
  return -99;
2935
2995
  }
2936
- //* Validate the input val
2996
+ //* Validate the input val (with precise=false)
2937
2997
  isValidNumber() {
2938
- if (!this.selectedCountryData.iso2) {
2939
- return false;
2940
- }
2941
- const val = this._getFullNumber();
2942
- const alphaCharPosition = val.search(/\p{L}/u);
2943
- if (alphaCharPosition > -1) {
2944
- const beforeAlphaChar = val.substring(0, alphaCharPosition);
2945
- const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
2946
- const isValid = this._utilsIsPossibleNumber(val);
2947
- return beforeAlphaIsValid && isValid;
2948
- }
2949
- return this._utilsIsPossibleNumber(val);
2998
+ return this._validateNumber(false);
2999
+ }
3000
+ //* Validate the input val (with precise=true)
3001
+ isValidNumberPrecise() {
3002
+ return this._validateNumber(true);
2950
3003
  }
2951
3004
  _utilsIsPossibleNumber(val) {
2952
3005
  return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2953
3006
  }
2954
- //* Validate the input val (precise)
2955
- isValidNumberPrecise() {
3007
+ //* Shared internal validation logic to handle alpha character extension rules.
3008
+ _validateNumber(precise) {
2956
3009
  if (!this.selectedCountryData.iso2) {
2957
3010
  return false;
2958
3011
  }
2959
3012
  const val = this._getFullNumber();
2960
3013
  const alphaCharPosition = val.search(/\p{L}/u);
3014
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
2961
3015
  if (alphaCharPosition > -1) {
2962
3016
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
2963
- const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
2964
- const isValid = this._utilsIsValidNumber(val);
3017
+ const beforeAlphaIsValid = testValidity(beforeAlphaChar);
3018
+ const isValid = testValidity(val);
2965
3019
  return beforeAlphaIsValid && isValid;
2966
3020
  }
2967
- return this._utilsIsValidNumber(val);
3021
+ return testValidity(val);
2968
3022
  }
2969
3023
  _utilsIsValidNumber(val) {
2970
3024
  return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
@@ -3054,7 +3108,7 @@ var intlTelInput = Object.assign((input, options) => {
3054
3108
  attachUtils,
3055
3109
  startedLoadingUtilsScript: false,
3056
3110
  startedLoadingAutoCountry: false,
3057
- version: "25.5.2"
3111
+ version: "25.8.0"
3058
3112
  });
3059
3113
  var intl_tel_input_default = intlTelInput;
3060
3114