intl-tel-input 25.5.1 → 25.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
1
  See the Github Releases page for changelog: https://github.com/jackocnr/intl-tel-input/releases
2
2
 
3
- Or to lookup a specific version, e.g. v20.0.0, update the URL accordingly: https://github.com/jackocnr/intl-tel-input/releases/tag/v20.0.0
3
+ Or to view a specific version, e.g. v20.0.0, update the URL accordingly, e.g. https://github.com/jackocnr/intl-tel-input/releases/tag/v20.0.0
4
+
5
+ ## Breaking changes
6
+
7
+ - v25.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v25.0.0
8
+ - v24.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v24.0.0
9
+ - v23.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v23.0.0
10
+ - v22.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v22.0.0
11
+ - v21.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v21.0.0
12
+ - v20.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v20.0.0
13
+ - v19.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v19.0.0
14
+ - v18.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v18.0.0
15
+ - v17.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v17.0.0
16
+ - v16.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v16.0.0
17
+ - v15.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v15.0.0
18
+ - v14.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v14.0.0
19
+ - v13.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v13.0.0
20
+ - v12.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v12.0.0
21
+ - v11.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v11.0.0
22
+ - v10.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v10.0.0
23
+ - v9.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v9.0.0
24
+ - v8.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v8.0.0
25
+ - v7.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v7.0.0
26
+ - v6.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v6.0.0
27
+ - v5.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v5.0.0
28
+ - v4.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v4.0.0
29
+ - v3.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v3.0.0
30
+ - v2.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v2.0.0
31
+ - v1.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v1.0.0
package/README.md CHANGED
@@ -77,16 +77,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
77
77
  ## Getting Started (Using a CDN)
78
78
  1. Add the CSS
79
79
  ```html
80
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.1/build/css/intlTelInput.css">
80
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/css/intlTelInput.css">
81
81
  ```
82
82
 
83
83
  2. Add the plugin script and initialise it on your input element
84
84
  ```html
85
- <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.1/build/js/intlTelInput.min.js"></script>
85
+ <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/intlTelInput.min.js"></script>
86
86
  <script>
87
87
  const input = document.querySelector("#phone");
88
88
  window.intlTelInput(input, {
89
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.1/build/js/utils.js"),
89
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
90
90
  });
91
91
  </script>
92
92
  ```
@@ -229,9 +229,9 @@ _Note that the `failure` callback must be called in the event of an error, hence
229
229
 
230
230
  **hiddenInput**
231
231
  Type: `Function` Default: `null`
232
- Allows the creation of hidden input fields within a form to store the full international telephone number and the selected country code. It accepts a function that receives the name of the main telephone input as an argument. This function should return an object with `phone` and (optionally) `country` properties to specify the names of the hidden inputs for the phone number and country code, respectively. This is useful for non-Ajax form submissions to ensure the full international number and country code are captured, especially when `nationalMode` is enabled.
232
+ Allows the creation of hidden input fields within a form, which, on submit, get populated with the (1) full international telephone number and (2) the selected country code. It accepts a function that receives the name of the main telephone input as an argument. This function should return an object with `phone` and (optionally) `country` properties to specify the names of the hidden inputs for the phone number and country code, respectively. This is useful for non-Ajax form submissions to ensure the full international number and country code are captured, especially when `nationalMode` is enabled.
233
233
 
234
- ***Note**: This feature requires the input to be inside a `<form>` element, as it listens for the `submit` event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the [utils script to be loaded](#loading-the-utilities-script), and secondly it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through.
234
+ ***Note**: This feature requires the input to be inside a `<form>` element, as it listens for the `submit` event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the [utils script to be loaded](#loading-the-utilities-script), and secondly, it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through.
235
235
 
236
236
  ```js
237
237
  intlTelInput(input, {
@@ -251,7 +251,7 @@ This will generate the following (hidden) elements, which will be automatically
251
251
 
252
252
  **i18n**
253
253
  Type: `Object` Default: `{}`
254
- Allow localisation/customisation of the 200+ country names, as well as other user interface text (e.g. the placeholder text for the country search input). The easiest way to do this is to simply import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) and set `i18n` to that value (see option 1 below). You can also override one or more individual keys this way (see option 1 below). Alternatively, you can provide your own custom translations (see option 2 below). If providing your own, you will need to specify all the country names (which can be copied from the country-list project e.g. here are the [country names in French](https://github.com/umpirsky/country-list/blob/master/data/fr/country.json)), as well as a few UI strings (listed below). [See example](https://intl-tel-input.com/examples/localise-countries.html).
254
+ Allows you to specify translation strings for the 200+ country names, as well as other user interface text (e.g. the placeholder text for the country search input). The easiest way to do this is to import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) and set `i18n` to that value (see option 1 below). You can also override one or more individual keys this way (see option 1 below). Alternatively, you can provide your own custom translations (see option 2 below). If providing your own, you will need to specify all the country names (which can be copied from the country-list project, e.g. here are the [country names in French](https://github.com/umpirsky/country-list/blob/master/data/fr/country.json)), as well as a few UI strings (listed below). [See example](https://intl-tel-input.com/examples/localise-countries.html).
255
255
 
256
256
  If we don't currently support a language you need, it's easy to [contribute this](https://github.com/jackocnr/intl-tel-input/blob/master/.github/CONTRIBUTING.md#adding-a-new-translation) yourself - you only need to provide a handful of UI translation strings, as we automatically pull in the country names from the country-list project.
257
257
 
@@ -297,7 +297,7 @@ intlTelInput(input, {
297
297
  oneSearchResult: "1 result found",
298
298
  // Screen reader text for when the search produces multiple results
299
299
  multipleSearchResults: "${count} results found",
300
- // For more complex pluralisation cases e.g. Polish or Arabic, you can implement your own logic
300
+ // For more complex pluralisation cases, e.g. Polish or Arabic, you can implement your own logic
301
301
  // Note that if this function is defined, the plugin will ignore the "zero", "one" and "multiple" keys listed above
302
302
  searchResultsText(count) {
303
303
  if (count === 0) return "No results found";
@@ -322,7 +322,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
322
322
  ```js
323
323
  // (A) import utils module from a CDN
324
324
  intlTelInput(htmlInputElement, {
325
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.1/build/js/utils.js"),
325
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
326
326
  });
327
327
 
328
328
  // (B) import utils module from your own hosted version of utils.js
@@ -606,7 +606,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
606
606
  ```js
607
607
  // (A) import utils module from a CDN
608
608
  intlTelInput(htmlInputElement, {
609
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.1/build/js/utils.js"),
609
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
610
610
  });
611
611
 
612
612
  // (B) import utils module from your own hosted version of utils.js
package/angular/README.md CHANGED
@@ -29,7 +29,7 @@ import "intl-tel-input/styles";
29
29
 
30
30
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/validation/validation.component.ts) for a more fleshed-out example of how to handle validation.
31
31
 
32
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.2.1/build/js/utils.js"`.
32
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"`.
33
33
 
34
34
  ## Props
35
35
  Here's a list of all of the current props you can pass to the IntlTelInput Angular component.
@@ -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
 
@@ -1606,10 +1606,23 @@ var allTranslations = Object.assign(Object.assign({}, countries_default), interf
1606
1606
  var en_default = allTranslations;
1607
1607
 
1608
1608
  // 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];
1609
+ for (const c of data_default) {
1610
+ c.name = en_default[c.iso2];
1611
1611
  }
1612
1612
  var id = 0;
1613
+ var mq = (q) => {
1614
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
1615
+ };
1616
+ var computeDefaultUseFullscreenPopup = () => {
1617
+ if (typeof navigator !== "undefined" && typeof window !== "undefined") {
1618
+ const isMobileUserAgent = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1619
+ const isNarrowViewport = mq("(max-width: 500px)");
1620
+ const isShortViewport = mq("(max-height: 600px)");
1621
+ const isCoarsePointer = mq("(pointer: coarse)");
1622
+ return isMobileUserAgent || isNarrowViewport || isCoarsePointer && isShortViewport;
1623
+ }
1624
+ return false;
1625
+ };
1613
1626
  var defaults = {
1614
1627
  //* Whether or not to allow the dropdown.
1615
1628
  allowDropdown: true,
@@ -1656,11 +1669,7 @@ var defaults = {
1656
1669
  //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1657
1670
  strictMode: false,
1658
1671
  //* 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,
1672
+ useFullscreenPopup: computeDefaultUseFullscreenPopup(),
1664
1673
  //* The number type to enforce during validation.
1665
1674
  validationNumberTypes: ["MOBILE"]
1666
1675
  };
@@ -1688,7 +1697,7 @@ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g,
1688
1697
  var isRegionlessNanp = (number) => {
1689
1698
  const numeric = getNumeric(number);
1690
1699
  if (numeric.charAt(0) === "1") {
1691
- const areaCode = numeric.substr(1, 3);
1700
+ const areaCode = numeric.substring(1, 4);
1692
1701
  return regionlessNanpNumbers.includes(areaCode);
1693
1702
  }
1694
1703
  return false;
@@ -1752,6 +1761,7 @@ var Iti = class {
1752
1761
  }
1753
1762
  this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
1754
1763
  this.isRTL = !!this.telInput.closest("[dir=rtl]");
1764
+ this.telInput.dir = "ltr";
1755
1765
  const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode;
1756
1766
  this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide;
1757
1767
  if (this.options.separateDialCode) {
@@ -1787,6 +1797,16 @@ var Iti = class {
1787
1797
  this._processDialCodes();
1788
1798
  this._translateCountryNames();
1789
1799
  this._sortCountries();
1800
+ this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
1801
+ this._cacheSearchTokens();
1802
+ }
1803
+ //* Precompute and cache country search tokens to speed up filtering
1804
+ _cacheSearchTokens() {
1805
+ for (const c of this.countries) {
1806
+ c.normalisedName = normaliseString(c.name);
1807
+ c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
1808
+ c.dialCodePlus = `+${c.dialCode}`;
1809
+ }
1790
1810
  }
1791
1811
  //* Sort countries by countryOrder option (if present), then name.
1792
1812
  _sortCountries() {
@@ -1818,13 +1838,12 @@ var Iti = class {
1818
1838
  if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
1819
1839
  this.dialCodeToIso2Map[dialCode] = [];
1820
1840
  }
1821
- for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
1822
- if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
1823
- return;
1824
- }
1841
+ const iso2List = this.dialCodeToIso2Map[dialCode];
1842
+ if (iso2List.includes(iso2)) {
1843
+ return;
1825
1844
  }
1826
- const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1827
- this.dialCodeToIso2Map[dialCode][index] = iso2;
1845
+ const index = priority !== void 0 ? priority : iso2List.length;
1846
+ iso2List[index] = iso2;
1828
1847
  }
1829
1848
  //* Process onlyCountries or excludeCountries array if present.
1830
1849
  _processAllCountries() {
@@ -1841,33 +1860,30 @@ var Iti = class {
1841
1860
  }
1842
1861
  //* Translate Countries by object literal provided on config.
1843
1862
  _translateCountryNames() {
1844
- for (let i = 0; i < this.countries.length; i++) {
1845
- const iso2 = this.countries[i].iso2.toLowerCase();
1863
+ for (const c of this.countries) {
1864
+ const iso2 = c.iso2.toLowerCase();
1846
1865
  if (this.options.i18n.hasOwnProperty(iso2)) {
1847
- this.countries[i].name = this.options.i18n[iso2];
1866
+ c.name = this.options.i18n[iso2];
1848
1867
  }
1849
1868
  }
1850
1869
  }
1851
1870
  //* Generate this.dialCodes and this.dialCodeToIso2Map.
1852
1871
  _processDialCodes() {
1853
- this.dialCodes = {};
1872
+ this.dialCodes = /* @__PURE__ */ new Set();
1854
1873
  this.dialCodeMaxLen = 0;
1855
1874
  this.dialCodeToIso2Map = {};
1856
- for (let i = 0; i < this.countries.length; i++) {
1857
- const c = this.countries[i];
1858
- if (!this.dialCodes[c.dialCode]) {
1859
- this.dialCodes[c.dialCode] = true;
1875
+ for (const c of this.countries) {
1876
+ if (!this.dialCodes.has(c.dialCode)) {
1877
+ this.dialCodes.add(c.dialCode);
1860
1878
  }
1861
1879
  this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1862
1880
  }
1863
- for (let i = 0; i < this.countries.length; i++) {
1864
- const c = this.countries[i];
1881
+ for (const c of this.countries) {
1865
1882
  if (c.areaCodes) {
1866
1883
  const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
1867
- for (let j = 0; j < c.areaCodes.length; j++) {
1868
- const areaCode = c.areaCodes[j];
1884
+ for (const areaCode of c.areaCodes) {
1869
1885
  for (let k = 1; k < areaCode.length; k++) {
1870
- const partialAreaCode = areaCode.substr(0, k);
1886
+ const partialAreaCode = areaCode.substring(0, k);
1871
1887
  const partialDialCode = c.dialCode + partialAreaCode;
1872
1888
  this._addToDialCodeMap(rootIso2Code, partialDialCode);
1873
1889
  this._addToDialCodeMap(c.iso2, partialDialCode);
@@ -1930,7 +1946,7 @@ var Iti = class {
1930
1946
  this.dropdownArrow = createEl("div", { class: "iti__arrow", "aria-hidden": "true" }, selectedCountryPrimary);
1931
1947
  }
1932
1948
  if (separateDialCode) {
1933
- this.selectedDialCode = createEl("div", { class: "iti__selected-dial-code", "aria-hidden": "true" }, this.selectedCountry);
1949
+ this.selectedDialCode = createEl("div", { class: "iti__selected-dial-code", "aria-hidden": "true", dir: "ltr" }, this.selectedCountry);
1934
1950
  }
1935
1951
  if (allowDropdown) {
1936
1952
  const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
@@ -2030,7 +2046,7 @@ var Iti = class {
2030
2046
  content += `<div class='iti__flag iti__${c.iso2}'></div>`;
2031
2047
  }
2032
2048
  content += `<span class='iti__country-name'>${c.name}</span>`;
2033
- content += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
2049
+ content += `<span class='iti__dial-code' dir='ltr'>+${c.dialCode}</span>`;
2034
2050
  listItem.insertAdjacentHTML("beforeend", content);
2035
2051
  }
2036
2052
  }
@@ -2245,7 +2261,7 @@ var Iti = class {
2245
2261
  //* Adhere to the input's maxlength attr.
2246
2262
  _cap(number) {
2247
2263
  const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2248
- return max && number.length > max ? number.substr(0, max) : number;
2264
+ return max && number.length > max ? number.substring(0, max) : number;
2249
2265
  }
2250
2266
  //* Trigger a custom event on the input.
2251
2267
  _trigger(name, detailProps = {}) {
@@ -2371,9 +2387,8 @@ var Iti = class {
2371
2387
  }
2372
2388
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2373
2389
  _searchForCountry(query) {
2374
- for (let i = 0; i < this.countries.length; i++) {
2375
- const c = this.countries[i];
2376
- const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
2390
+ for (const c of this.countries) {
2391
+ const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
2377
2392
  if (startsWith) {
2378
2393
  const listItem = c.nodeById[this.id];
2379
2394
  this._highlightListItem(listItem, false);
@@ -2394,23 +2409,20 @@ var Iti = class {
2394
2409
  const dialCodeMatches = [];
2395
2410
  const dialCodeContains = [];
2396
2411
  const initialsMatches = [];
2397
- for (let i = 0; i < this.countries.length; i++) {
2398
- const c = this.countries[i];
2399
- const normalisedCountryName = normaliseString(c.name);
2400
- const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2412
+ for (const c of this.countries) {
2401
2413
  if (isReset || queryLength === 0) {
2402
2414
  nameContains.push(c);
2403
- } else if (c.iso2.toLowerCase() === normalisedQuery) {
2415
+ } else if (c.iso2 === normalisedQuery) {
2404
2416
  iso2Matches.push(c);
2405
- } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2417
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2406
2418
  nameStartWith.push(c);
2407
- } else if (normalisedCountryName.includes(normalisedQuery)) {
2419
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2408
2420
  nameContains.push(c);
2409
- } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2421
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2410
2422
  dialCodeMatches.push(c);
2411
- } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2423
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2412
2424
  dialCodeContains.push(c);
2413
- } else if (countryInitials.includes(normalisedQuery)) {
2425
+ } else if (c.initials.includes(normalisedQuery)) {
2414
2426
  initialsMatches.push(c);
2415
2427
  }
2416
2428
  }
@@ -2527,9 +2539,9 @@ var Iti = class {
2527
2539
  const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2528
2540
  const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2529
2541
  if (!isRegionlessNanpNumber && !alreadySelected) {
2530
- for (let j = 0; j < iso2Codes.length; j++) {
2531
- if (iso2Codes[j]) {
2532
- return iso2Codes[j];
2542
+ for (const iso2 of iso2Codes) {
2543
+ if (iso2) {
2544
+ return iso2;
2533
2545
  }
2534
2546
  }
2535
2547
  }
@@ -2562,12 +2574,11 @@ var Iti = class {
2562
2574
  }
2563
2575
  }
2564
2576
  //* Find the country data for the given iso2 code
2565
- //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2577
+ //* 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
2566
2578
  _getCountryData(iso2, allowFail) {
2567
- for (let i = 0; i < this.countries.length; i++) {
2568
- if (this.countries[i].iso2 === iso2) {
2569
- return this.countries[i];
2570
- }
2579
+ const country = this.countryByIso2.get(iso2);
2580
+ if (country) {
2581
+ return country;
2571
2582
  }
2572
2583
  if (allowFail) {
2573
2584
  return null;
@@ -2776,11 +2787,11 @@ var Iti = class {
2776
2787
  numericChars += c;
2777
2788
  if (includeAreaCode) {
2778
2789
  if (this.dialCodeToIso2Map[numericChars]) {
2779
- dialCode = number.substr(0, i + 1);
2790
+ dialCode = number.substring(0, i + 1);
2780
2791
  }
2781
2792
  } else {
2782
- if (this.dialCodes[numericChars]) {
2783
- dialCode = number.substr(0, i + 1);
2793
+ if (this.dialCodes.has(numericChars)) {
2794
+ dialCode = number.substring(0, i + 1);
2784
2795
  break;
2785
2796
  }
2786
2797
  }
@@ -2813,7 +2824,7 @@ var Iti = class {
2813
2824
  if (dialCode) {
2814
2825
  dialCode = `+${this.selectedCountryData.dialCode}`;
2815
2826
  const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2816
- number = number.substr(start);
2827
+ number = number.substring(start);
2817
2828
  }
2818
2829
  }
2819
2830
  return this._cap(number);
@@ -2932,38 +2943,32 @@ var Iti = class {
2932
2943
  }
2933
2944
  return -99;
2934
2945
  }
2935
- //* Validate the input val
2946
+ //* Validate the input val (with precise=false)
2936
2947
  isValidNumber() {
2937
- if (!this.selectedCountryData.iso2) {
2938
- return false;
2939
- }
2940
- const val = this._getFullNumber();
2941
- const alphaCharPosition = val.search(/\p{L}/u);
2942
- if (alphaCharPosition > -1) {
2943
- const beforeAlphaChar = val.substring(0, alphaCharPosition);
2944
- const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
2945
- const isValid = this._utilsIsPossibleNumber(val);
2946
- return beforeAlphaIsValid && isValid;
2947
- }
2948
- return this._utilsIsPossibleNumber(val);
2948
+ return this._validateNumber(false);
2949
+ }
2950
+ //* Validate the input val (with precise=true)
2951
+ isValidNumberPrecise() {
2952
+ return this._validateNumber(true);
2949
2953
  }
2950
2954
  _utilsIsPossibleNumber(val) {
2951
2955
  return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2952
2956
  }
2953
- //* Validate the input val (precise)
2954
- isValidNumberPrecise() {
2957
+ //* Shared internal validation logic to handle alpha character extension rules.
2958
+ _validateNumber(precise) {
2955
2959
  if (!this.selectedCountryData.iso2) {
2956
2960
  return false;
2957
2961
  }
2958
2962
  const val = this._getFullNumber();
2959
2963
  const alphaCharPosition = val.search(/\p{L}/u);
2964
+ const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
2960
2965
  if (alphaCharPosition > -1) {
2961
2966
  const beforeAlphaChar = val.substring(0, alphaCharPosition);
2962
- const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
2963
- const isValid = this._utilsIsValidNumber(val);
2967
+ const beforeAlphaIsValid = testValidity(beforeAlphaChar);
2968
+ const isValid = testValidity(val);
2964
2969
  return beforeAlphaIsValid && isValid;
2965
2970
  }
2966
- return this._utilsIsValidNumber(val);
2971
+ return testValidity(val);
2967
2972
  }
2968
2973
  _utilsIsValidNumber(val) {
2969
2974
  return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
@@ -3053,7 +3058,7 @@ var intlTelInput = Object.assign((input, options) => {
3053
3058
  attachUtils,
3054
3059
  startedLoadingUtilsScript: false,
3055
3060
  startedLoadingAutoCountry: false,
3056
- version: "25.5.1"
3061
+ version: "25.7.0"
3057
3062
  });
3058
3063
  var intl_tel_input_default = intlTelInput;
3059
3064