intl-tel-input 25.10.5 → 25.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # International Telephone Input [![Build Status](https://app.travis-ci.com/jackocnr/intl-tel-input.svg?branch=master)](https://app.travis-ci.com/jackocnr/intl-tel-input) <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
1
+ # International Telephone Input [![CI](https://github.com/jackocnr/intl-tel-input/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/jackocnr/intl-tel-input/actions/workflows/ci.yml) <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
2
2
 
3
3
  <img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vue-icon.png" alt="Vue logo" width="16px" /> NEWS: we now have our own <a href="https://github.com/jackocnr/intl-tel-input/tree/master/vue">Vue component</a>!
4
4
 
@@ -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.10.5/build/css/intlTelInput.css">
80
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.7/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.10.5/build/js/intlTelInput.min.js"></script>
85
+ <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.7/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.10.5/build/js/utils.js"),
89
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.7/build/js/utils.js"),
90
90
  });
91
91
  </script>
92
92
  ```
@@ -327,7 +327,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
327
327
  ```js
328
328
  // (A) import utils module from a CDN
329
329
  intlTelInput(htmlInputElement, {
330
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.5/build/js/utils.js"),
330
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.7/build/js/utils.js"),
331
331
  });
332
332
 
333
333
  // (B) import utils module from your own hosted version of utils.js
@@ -611,7 +611,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
611
611
  ```js
612
612
  // (A) import utils module from a CDN
613
613
  intlTelInput(htmlInputElement, {
614
- loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.5/build/js/utils.js"),
614
+ loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.7/build/js/utils.js"),
615
615
  });
616
616
 
617
617
  // (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.10.5/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.10.7/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.
@@ -1226,6 +1226,13 @@ var rawCountryData = [
1226
1226
  // Tuvalu
1227
1227
  "688"
1228
1228
  ],
1229
+ [
1230
+ "vi",
1231
+ // U.S. Virgin Islands
1232
+ "1",
1233
+ 24,
1234
+ ["340"]
1235
+ ],
1229
1236
  [
1230
1237
  "ug",
1231
1238
  // Uganda
@@ -1260,13 +1267,6 @@ var rawCountryData = [
1260
1267
  // Uruguay
1261
1268
  "598"
1262
1269
  ],
1263
- [
1264
- "vi",
1265
- // U.S. Virgin Islands
1266
- "1",
1267
- 24,
1268
- ["340"]
1269
- ],
1270
1270
  [
1271
1271
  "uz",
1272
1272
  // Uzbekistan
@@ -1842,6 +1842,9 @@ var Iti = class _Iti {
1842
1842
  }
1843
1843
  //* Add a dial code to this.dialCodeToIso2Map.
1844
1844
  _addToDialCodeMap(iso2, dialCode, priority) {
1845
+ if (!iso2 || !dialCode) {
1846
+ return;
1847
+ }
1845
1848
  if (dialCode.length > this.dialCodeMaxLen) {
1846
1849
  this.dialCodeMaxLen = dialCode.length;
1847
1850
  }
@@ -1888,6 +1891,11 @@ var Iti = class _Iti {
1888
1891
  }
1889
1892
  this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1890
1893
  }
1894
+ if (this.options.onlyCountries.length || this.options.excludeCountries.length) {
1895
+ this.dialCodes.forEach((dialCode) => {
1896
+ this.dialCodeToIso2Map[dialCode] = this.dialCodeToIso2Map[dialCode].filter(Boolean);
1897
+ });
1898
+ }
1891
1899
  for (const c of this.countries) {
1892
1900
  if (c.areaCodes) {
1893
1901
  const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
@@ -2233,7 +2241,7 @@ var Iti = class _Iti {
2233
2241
  _openDropdownWithPlus() {
2234
2242
  this._openDropdown();
2235
2243
  this.searchInput.value = "+";
2236
- this._filterCountries("", true);
2244
+ this._filterCountries("");
2237
2245
  }
2238
2246
  //* Initialize the tel input listeners.
2239
2247
  _initTelInputListeners() {
@@ -2302,6 +2310,36 @@ var Iti = class _Iti {
2302
2310
  };
2303
2311
  this.telInput.addEventListener("keydown", this._handleKeydownEvent);
2304
2312
  }
2313
+ if (strictMode) {
2314
+ this._handlePasteEvent = (e) => {
2315
+ e.preventDefault();
2316
+ const input = this.telInput;
2317
+ const selStart = input.selectionStart;
2318
+ const selEnd = input.selectionEnd;
2319
+ const pasted = e.clipboardData.getData("text");
2320
+ const initialCharSelected = selStart === 0 && selEnd > 0;
2321
+ const allowLeadingPlus = !input.value.startsWith("+") || initialCharSelected;
2322
+ const allowedChars = pasted.replace(/[^0-9+]/g, "");
2323
+ const hasLeadingPlus = allowedChars.startsWith("+");
2324
+ const numerics = allowedChars.replace(/\+/g, "");
2325
+ const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
2326
+ let newVal = input.value.slice(0, selStart) + sanitised + input.value.slice(selEnd);
2327
+ const coreNumber = intlTelInput.utils.getCoreNumber(newVal, this.selectedCountryData.iso2);
2328
+ if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
2329
+ if (input.selectionEnd === input.value.length) {
2330
+ const trimLength = coreNumber.length - this.maxCoreNumberLength;
2331
+ newVal = newVal.slice(0, newVal.length - trimLength);
2332
+ } else {
2333
+ return;
2334
+ }
2335
+ }
2336
+ input.value = newVal;
2337
+ const caretPos = selStart + sanitised.length;
2338
+ input.setSelectionRange(caretPos, caretPos);
2339
+ input.dispatchEvent(new InputEvent("input", { bubbles: true }));
2340
+ };
2341
+ this.telInput.addEventListener("paste", this._handlePasteEvent);
2342
+ }
2305
2343
  }
2306
2344
  //* Adhere to the input's maxlength attr.
2307
2345
  _cap(number) {
@@ -2412,11 +2450,7 @@ var Iti = class _Iti {
2412
2450
  if (this.options.countrySearch) {
2413
2451
  const doFilter = () => {
2414
2452
  const inputQuery = this.searchInput.value.trim();
2415
- if (inputQuery) {
2416
- this._filterCountries(inputQuery);
2417
- } else {
2418
- this._filterCountries("", true);
2419
- }
2453
+ this._filterCountries(inputQuery);
2420
2454
  if (this.searchInput.value) {
2421
2455
  this.searchClearButton.classList.remove("iti__hide");
2422
2456
  } else {
@@ -2455,42 +2489,44 @@ var Iti = class _Iti {
2455
2489
  }
2456
2490
  }
2457
2491
  //* Country search enabled: Filter the countries according to the search query.
2458
- _filterCountries(query, isReset = false) {
2492
+ _filterCountries(query) {
2459
2493
  let noCountriesAddedYet = true;
2460
2494
  this.countryList.innerHTML = "";
2461
2495
  const normalisedQuery = normaliseString(query);
2462
- const queryLength = normalisedQuery.length;
2463
- const iso2Matches = [];
2464
- const nameStartWith = [];
2465
- const nameContains = [];
2466
- const dialCodeMatches = [];
2467
- const dialCodeContains = [];
2468
- const initialsMatches = [];
2469
- for (const c of this.countries) {
2470
- if (isReset || queryLength === 0) {
2471
- nameContains.push(c);
2472
- } else if (c.iso2 === normalisedQuery) {
2473
- iso2Matches.push(c);
2474
- } else if (c.normalisedName.startsWith(normalisedQuery)) {
2475
- nameStartWith.push(c);
2476
- } else if (c.normalisedName.includes(normalisedQuery)) {
2477
- nameContains.push(c);
2478
- } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2479
- dialCodeMatches.push(c);
2480
- } else if (c.dialCodePlus.includes(normalisedQuery)) {
2481
- dialCodeContains.push(c);
2482
- } else if (c.initials.includes(normalisedQuery)) {
2483
- initialsMatches.push(c);
2496
+ let matchedCountries;
2497
+ if (query === "") {
2498
+ matchedCountries = this.countries;
2499
+ } else {
2500
+ const iso2Matches = [];
2501
+ const nameStartWith = [];
2502
+ const nameContains = [];
2503
+ const dialCodeMatches = [];
2504
+ const dialCodeContains = [];
2505
+ const initialsMatches = [];
2506
+ for (const c of this.countries) {
2507
+ if (c.iso2 === normalisedQuery) {
2508
+ iso2Matches.push(c);
2509
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2510
+ nameStartWith.push(c);
2511
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2512
+ nameContains.push(c);
2513
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2514
+ dialCodeMatches.push(c);
2515
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2516
+ dialCodeContains.push(c);
2517
+ } else if (c.initials.includes(normalisedQuery)) {
2518
+ initialsMatches.push(c);
2519
+ }
2484
2520
  }
2521
+ matchedCountries = [
2522
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2523
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2524
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2525
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2526
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2527
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2528
+ ];
2485
2529
  }
2486
- const matchedCountries = [
2487
- ...iso2Matches.sort((a, b) => a.priority - b.priority),
2488
- ...nameStartWith.sort((a, b) => a.priority - b.priority),
2489
- ...nameContains.sort((a, b) => a.priority - b.priority),
2490
- ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2491
- ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2492
- ...initialsMatches.sort((a, b) => a.priority - b.priority)
2493
- ];
2494
2530
  for (const c of matchedCountries) {
2495
2531
  const listItem = c.nodeById[this.id];
2496
2532
  if (listItem) {
@@ -2594,22 +2630,27 @@ var Iti = class _Iti {
2594
2630
  if (dialCodeMatch) {
2595
2631
  const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2596
2632
  const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2633
+ if (iso2Codes.length === 1) {
2634
+ if (iso2Codes[0] === selectedIso2) {
2635
+ return null;
2636
+ }
2637
+ return iso2Codes[0];
2638
+ }
2597
2639
  if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2598
2640
  return this.defaultCountry;
2599
2641
  }
2642
+ const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2643
+ if (isRegionlessNanpNumber) {
2644
+ return null;
2645
+ }
2600
2646
  const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
2601
2647
  const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2602
- const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2603
- if (!isRegionlessNanpNumber && !alreadySelected) {
2604
- for (const iso2 of iso2Codes) {
2605
- if (iso2) {
2606
- return iso2;
2607
- }
2608
- }
2648
+ if (!alreadySelected) {
2649
+ return iso2Codes[0];
2609
2650
  }
2610
2651
  } else if (number.charAt(0) === "+" && numeric.length) {
2611
2652
  return "";
2612
- } else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
2653
+ } else if ((!number || number === "+") && !selectedIso2) {
2613
2654
  return this.defaultCountry;
2614
2655
  }
2615
2656
  return null;
@@ -2953,6 +2994,9 @@ var Iti = class _Iti {
2953
2994
  if (this._handleKeydownEvent) {
2954
2995
  this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
2955
2996
  }
2997
+ if (this._handlePasteEvent) {
2998
+ this.telInput.removeEventListener("paste", this._handlePasteEvent);
2999
+ }
2956
3000
  this.telInput.removeAttribute("data-intl-tel-input-id");
2957
3001
  if (separateDialCode) {
2958
3002
  if (this.isRTL) {
@@ -3119,7 +3163,7 @@ var intlTelInput = Object.assign((input, options) => {
3119
3163
  attachUtils,
3120
3164
  startedLoadingUtilsScript: false,
3121
3165
  startedLoadingAutoCountry: false,
3122
- version: "25.10.5"
3166
+ version: "25.10.7"
3123
3167
  });
3124
3168
  var intl_tel_input_default = intlTelInput;
3125
3169
 
@@ -1226,6 +1226,13 @@ var rawCountryData = [
1226
1226
  // Tuvalu
1227
1227
  "688"
1228
1228
  ],
1229
+ [
1230
+ "vi",
1231
+ // U.S. Virgin Islands
1232
+ "1",
1233
+ 24,
1234
+ ["340"]
1235
+ ],
1229
1236
  [
1230
1237
  "ug",
1231
1238
  // Uganda
@@ -1260,13 +1267,6 @@ var rawCountryData = [
1260
1267
  // Uruguay
1261
1268
  "598"
1262
1269
  ],
1263
- [
1264
- "vi",
1265
- // U.S. Virgin Islands
1266
- "1",
1267
- 24,
1268
- ["340"]
1269
- ],
1270
1270
  [
1271
1271
  "uz",
1272
1272
  // Uzbekistan
@@ -1842,6 +1842,9 @@ var Iti = class _Iti {
1842
1842
  }
1843
1843
  //* Add a dial code to this.dialCodeToIso2Map.
1844
1844
  _addToDialCodeMap(iso2, dialCode, priority) {
1845
+ if (!iso2 || !dialCode) {
1846
+ return;
1847
+ }
1845
1848
  if (dialCode.length > this.dialCodeMaxLen) {
1846
1849
  this.dialCodeMaxLen = dialCode.length;
1847
1850
  }
@@ -1888,6 +1891,11 @@ var Iti = class _Iti {
1888
1891
  }
1889
1892
  this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1890
1893
  }
1894
+ if (this.options.onlyCountries.length || this.options.excludeCountries.length) {
1895
+ this.dialCodes.forEach((dialCode) => {
1896
+ this.dialCodeToIso2Map[dialCode] = this.dialCodeToIso2Map[dialCode].filter(Boolean);
1897
+ });
1898
+ }
1891
1899
  for (const c of this.countries) {
1892
1900
  if (c.areaCodes) {
1893
1901
  const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
@@ -2233,7 +2241,7 @@ var Iti = class _Iti {
2233
2241
  _openDropdownWithPlus() {
2234
2242
  this._openDropdown();
2235
2243
  this.searchInput.value = "+";
2236
- this._filterCountries("", true);
2244
+ this._filterCountries("");
2237
2245
  }
2238
2246
  //* Initialize the tel input listeners.
2239
2247
  _initTelInputListeners() {
@@ -2302,6 +2310,36 @@ var Iti = class _Iti {
2302
2310
  };
2303
2311
  this.telInput.addEventListener("keydown", this._handleKeydownEvent);
2304
2312
  }
2313
+ if (strictMode) {
2314
+ this._handlePasteEvent = (e) => {
2315
+ e.preventDefault();
2316
+ const input = this.telInput;
2317
+ const selStart = input.selectionStart;
2318
+ const selEnd = input.selectionEnd;
2319
+ const pasted = e.clipboardData.getData("text");
2320
+ const initialCharSelected = selStart === 0 && selEnd > 0;
2321
+ const allowLeadingPlus = !input.value.startsWith("+") || initialCharSelected;
2322
+ const allowedChars = pasted.replace(/[^0-9+]/g, "");
2323
+ const hasLeadingPlus = allowedChars.startsWith("+");
2324
+ const numerics = allowedChars.replace(/\+/g, "");
2325
+ const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
2326
+ let newVal = input.value.slice(0, selStart) + sanitised + input.value.slice(selEnd);
2327
+ const coreNumber = intlTelInput.utils.getCoreNumber(newVal, this.selectedCountryData.iso2);
2328
+ if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
2329
+ if (input.selectionEnd === input.value.length) {
2330
+ const trimLength = coreNumber.length - this.maxCoreNumberLength;
2331
+ newVal = newVal.slice(0, newVal.length - trimLength);
2332
+ } else {
2333
+ return;
2334
+ }
2335
+ }
2336
+ input.value = newVal;
2337
+ const caretPos = selStart + sanitised.length;
2338
+ input.setSelectionRange(caretPos, caretPos);
2339
+ input.dispatchEvent(new InputEvent("input", { bubbles: true }));
2340
+ };
2341
+ this.telInput.addEventListener("paste", this._handlePasteEvent);
2342
+ }
2305
2343
  }
2306
2344
  //* Adhere to the input's maxlength attr.
2307
2345
  _cap(number) {
@@ -2412,11 +2450,7 @@ var Iti = class _Iti {
2412
2450
  if (this.options.countrySearch) {
2413
2451
  const doFilter = () => {
2414
2452
  const inputQuery = this.searchInput.value.trim();
2415
- if (inputQuery) {
2416
- this._filterCountries(inputQuery);
2417
- } else {
2418
- this._filterCountries("", true);
2419
- }
2453
+ this._filterCountries(inputQuery);
2420
2454
  if (this.searchInput.value) {
2421
2455
  this.searchClearButton.classList.remove("iti__hide");
2422
2456
  } else {
@@ -2455,42 +2489,44 @@ var Iti = class _Iti {
2455
2489
  }
2456
2490
  }
2457
2491
  //* Country search enabled: Filter the countries according to the search query.
2458
- _filterCountries(query, isReset = false) {
2492
+ _filterCountries(query) {
2459
2493
  let noCountriesAddedYet = true;
2460
2494
  this.countryList.innerHTML = "";
2461
2495
  const normalisedQuery = normaliseString(query);
2462
- const queryLength = normalisedQuery.length;
2463
- const iso2Matches = [];
2464
- const nameStartWith = [];
2465
- const nameContains = [];
2466
- const dialCodeMatches = [];
2467
- const dialCodeContains = [];
2468
- const initialsMatches = [];
2469
- for (const c of this.countries) {
2470
- if (isReset || queryLength === 0) {
2471
- nameContains.push(c);
2472
- } else if (c.iso2 === normalisedQuery) {
2473
- iso2Matches.push(c);
2474
- } else if (c.normalisedName.startsWith(normalisedQuery)) {
2475
- nameStartWith.push(c);
2476
- } else if (c.normalisedName.includes(normalisedQuery)) {
2477
- nameContains.push(c);
2478
- } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2479
- dialCodeMatches.push(c);
2480
- } else if (c.dialCodePlus.includes(normalisedQuery)) {
2481
- dialCodeContains.push(c);
2482
- } else if (c.initials.includes(normalisedQuery)) {
2483
- initialsMatches.push(c);
2496
+ let matchedCountries;
2497
+ if (query === "") {
2498
+ matchedCountries = this.countries;
2499
+ } else {
2500
+ const iso2Matches = [];
2501
+ const nameStartWith = [];
2502
+ const nameContains = [];
2503
+ const dialCodeMatches = [];
2504
+ const dialCodeContains = [];
2505
+ const initialsMatches = [];
2506
+ for (const c of this.countries) {
2507
+ if (c.iso2 === normalisedQuery) {
2508
+ iso2Matches.push(c);
2509
+ } else if (c.normalisedName.startsWith(normalisedQuery)) {
2510
+ nameStartWith.push(c);
2511
+ } else if (c.normalisedName.includes(normalisedQuery)) {
2512
+ nameContains.push(c);
2513
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
2514
+ dialCodeMatches.push(c);
2515
+ } else if (c.dialCodePlus.includes(normalisedQuery)) {
2516
+ dialCodeContains.push(c);
2517
+ } else if (c.initials.includes(normalisedQuery)) {
2518
+ initialsMatches.push(c);
2519
+ }
2484
2520
  }
2521
+ matchedCountries = [
2522
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2523
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2524
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2525
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2526
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2527
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2528
+ ];
2485
2529
  }
2486
- const matchedCountries = [
2487
- ...iso2Matches.sort((a, b) => a.priority - b.priority),
2488
- ...nameStartWith.sort((a, b) => a.priority - b.priority),
2489
- ...nameContains.sort((a, b) => a.priority - b.priority),
2490
- ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2491
- ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2492
- ...initialsMatches.sort((a, b) => a.priority - b.priority)
2493
- ];
2494
2530
  for (const c of matchedCountries) {
2495
2531
  const listItem = c.nodeById[this.id];
2496
2532
  if (listItem) {
@@ -2594,22 +2630,27 @@ var Iti = class _Iti {
2594
2630
  if (dialCodeMatch) {
2595
2631
  const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2596
2632
  const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2633
+ if (iso2Codes.length === 1) {
2634
+ if (iso2Codes[0] === selectedIso2) {
2635
+ return null;
2636
+ }
2637
+ return iso2Codes[0];
2638
+ }
2597
2639
  if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2598
2640
  return this.defaultCountry;
2599
2641
  }
2642
+ const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2643
+ if (isRegionlessNanpNumber) {
2644
+ return null;
2645
+ }
2600
2646
  const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
2601
2647
  const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
2602
- const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2603
- if (!isRegionlessNanpNumber && !alreadySelected) {
2604
- for (const iso2 of iso2Codes) {
2605
- if (iso2) {
2606
- return iso2;
2607
- }
2608
- }
2648
+ if (!alreadySelected) {
2649
+ return iso2Codes[0];
2609
2650
  }
2610
2651
  } else if (number.charAt(0) === "+" && numeric.length) {
2611
2652
  return "";
2612
- } else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
2653
+ } else if ((!number || number === "+") && !selectedIso2) {
2613
2654
  return this.defaultCountry;
2614
2655
  }
2615
2656
  return null;
@@ -2953,6 +2994,9 @@ var Iti = class _Iti {
2953
2994
  if (this._handleKeydownEvent) {
2954
2995
  this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
2955
2996
  }
2997
+ if (this._handlePasteEvent) {
2998
+ this.telInput.removeEventListener("paste", this._handlePasteEvent);
2999
+ }
2956
3000
  this.telInput.removeAttribute("data-intl-tel-input-id");
2957
3001
  if (separateDialCode) {
2958
3002
  if (this.isRTL) {
@@ -3119,7 +3163,7 @@ var intlTelInput = Object.assign((input, options) => {
3119
3163
  attachUtils,
3120
3164
  startedLoadingUtilsScript: false,
3121
3165
  startedLoadingAutoCountry: false,
3122
- version: "25.10.5"
3166
+ version: "25.10.7"
3123
3167
  });
3124
3168
  var intl_tel_input_default = intlTelInput;
3125
3169
 
@@ -122,6 +122,7 @@ export declare class Iti {
122
122
  private _handleCountryContainerKeydown;
123
123
  private _handleInputEvent;
124
124
  private _handleKeydownEvent;
125
+ private _handlePasteEvent;
125
126
  private _handleWindowScroll;
126
127
  private _handleMouseoverCountryList;
127
128
  private _handleClickCountryList;
package/build/js/data.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v25.10.5
2
+ * International Telephone Input v25.10.7
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -1264,6 +1264,13 @@ var factoryOutput = (() => {
1264
1264
  // Tuvalu
1265
1265
  "688"
1266
1266
  ],
1267
+ [
1268
+ "vi",
1269
+ // U.S. Virgin Islands
1270
+ "1",
1271
+ 24,
1272
+ ["340"]
1273
+ ],
1267
1274
  [
1268
1275
  "ug",
1269
1276
  // Uganda
@@ -1298,13 +1305,6 @@ var factoryOutput = (() => {
1298
1305
  // Uruguay
1299
1306
  "598"
1300
1307
  ],
1301
- [
1302
- "vi",
1303
- // U.S. Virgin Islands
1304
- "1",
1305
- 24,
1306
- ["340"]
1307
- ],
1308
1308
  [
1309
1309
  "uz",
1310
1310
  // Uzbekistan
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v25.10.5
2
+ * International Telephone Input v25.10.7
3
3
  * https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -13,7 +13,7 @@
13
13
  }
14
14
  }(() => {
15
15
 
16
- var factoryOutput=(()=>{var a=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var o=(n,t)=>{for(var r in t)a(n,r,{get:t[r],enumerable:!0})},u=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of m(t))!g.call(n,s)&&s!==r&&a(n,s,{get:()=>t[s],enumerable:!(i=e(t,s))||i.enumerable});return n};var c=n=>u(a({},"__esModule",{value:!0}),n);var p={};o(p,{default:()=>b});var d=[["af","93"],["ax","358",1],["al","355"],["dz","213"],["as","1",5,["684"]],["ad","376"],["ao","244"],["ai","1",6,["264"]],["ag","1",7,["268"]],["ar","54"],["am","374"],["aw","297"],["ac","247"],["au","61",0,null,"0"],["at","43"],["az","994"],["bs","1",8,["242"]],["bh","973"],["bd","880"],["bb","1",9,["246"]],["by","375"],["be","32"],["bz","501"],["bj","229"],["bm","1",10,["441"]],["bt","975"],["bo","591"],["ba","387"],["bw","267"],["br","55"],["io","246"],["vg","1",11,["284"]],["bn","673"],["bg","359"],["bf","226"],["bi","257"],["kh","855"],["cm","237"],["ca","1",1,["204","226","236","249","250","263","289","306","343","354","365","367","368","382","387","403","416","418","428","431","437","438","450","584","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","879","902","905"]],["cv","238"],["bq","599",1,["3","4","7"]],["ky","1",12,["345"]],["cf","236"],["td","235"],["cl","56"],["cn","86"],["cx","61",2,["89164"],"0"],["cc","61",1,["89162"],"0"],["co","57"],["km","269"],["cg","242"],["cd","243"],["ck","682"],["cr","506"],["ci","225"],["hr","385"],["cu","53"],["cw","599",0],["cy","357"],["cz","420"],["dk","45"],["dj","253"],["dm","1",13,["767"]],["do","1",2,["809","829","849"]],["ec","593"],["eg","20"],["sv","503"],["gq","240"],["er","291"],["ee","372"],["sz","268"],["et","251"],["fk","500"],["fo","298"],["fj","679"],["fi","358",0],["fr","33"],["gf","594"],["pf","689"],["ga","241"],["gm","220"],["ge","995"],["de","49"],["gh","233"],["gi","350"],["gr","30"],["gl","299"],["gd","1",14,["473"]],["gp","590",0],["gu","1",15,["671"]],["gt","502"],["gg","44",1,["1481","7781","7839","7911"],"0"],["gn","224"],["gw","245"],["gy","592"],["ht","509"],["hn","504"],["hk","852"],["hu","36"],["is","354"],["in","91"],["id","62"],["ir","98"],["iq","964"],["ie","353"],["im","44",2,["1624","74576","7524","7924","7624"],"0"],["il","972"],["it","39",0],["jm","1",4,["876","658"]],["jp","81"],["je","44",3,["1534","7509","7700","7797","7829","7937"],"0"],["jo","962"],["kz","7",1,["33","7"],"8"],["ke","254"],["ki","686"],["xk","383"],["kw","965"],["kg","996"],["la","856"],["lv","371"],["lb","961"],["ls","266"],["lr","231"],["ly","218"],["li","423"],["lt","370"],["lu","352"],["mo","853"],["mg","261"],["mw","265"],["my","60"],["mv","960"],["ml","223"],["mt","356"],["mh","692"],["mq","596"],["mr","222"],["mu","230"],["yt","262",1,["269","639"],"0"],["mx","52"],["fm","691"],["md","373"],["mc","377"],["mn","976"],["me","382"],["ms","1",16,["664"]],["ma","212",0,null,"0"],["mz","258"],["mm","95"],["na","264"],["nr","674"],["np","977"],["nl","31"],["nc","687"],["nz","64"],["ni","505"],["ne","227"],["ng","234"],["nu","683"],["nf","672"],["kp","850"],["mk","389"],["mp","1",17,["670"]],["no","47",0],["om","968"],["pk","92"],["pw","680"],["ps","970"],["pa","507"],["pg","675"],["py","595"],["pe","51"],["ph","63"],["pl","48"],["pt","351"],["pr","1",3,["787","939"]],["qa","974"],["re","262",0,null,"0"],["ro","40"],["ru","7",0,null,"8"],["rw","250"],["ws","685"],["sm","378"],["st","239"],["sa","966"],["sn","221"],["rs","381"],["sc","248"],["sl","232"],["sg","65"],["sx","1",21,["721"]],["sk","421"],["si","386"],["sb","677"],["so","252"],["za","27"],["kr","82"],["ss","211"],["es","34"],["lk","94"],["bl","590",1],["sh","290"],["kn","1",18,["869"]],["lc","1",19,["758"]],["mf","590",2],["pm","508"],["vc","1",20,["784"]],["sd","249"],["sr","597"],["sj","47",1,["79"]],["se","46"],["ch","41"],["sy","963"],["tw","886"],["tj","992"],["tz","255"],["th","66"],["tl","670"],["tg","228"],["tk","690"],["to","676"],["tt","1",22,["868"]],["tn","216"],["tr","90"],["tm","993"],["tc","1",23,["649"]],["tv","688"],["ug","256"],["ua","380"],["ae","971"],["gb","44",0,null,"0"],["us","1",0],["uy","598"],["vi","1",24,["340"]],["uz","998"],["vu","678"],["va","39",1,["06698"]],["ve","58"],["vn","84"],["wf","681"],["eh","212",1,["5288","5289"],"0"],["ye","967"],["zm","260"],["zw","263"]],l=[];for(let n of d)l.push({name:"",iso2:n[0],dialCode:n[1],priority:n[2]||0,areaCodes:n[3]||null,nodeById:{},nationalPrefix:n[4]||null});var b=l;return c(p);})();
16
+ var factoryOutput=(()=>{var a=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var o=(n,t)=>{for(var r in t)a(n,r,{get:t[r],enumerable:!0})},u=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of m(t))!g.call(n,s)&&s!==r&&a(n,s,{get:()=>t[s],enumerable:!(i=e(t,s))||i.enumerable});return n};var c=n=>u(a({},"__esModule",{value:!0}),n);var p={};o(p,{default:()=>b});var d=[["af","93"],["ax","358",1],["al","355"],["dz","213"],["as","1",5,["684"]],["ad","376"],["ao","244"],["ai","1",6,["264"]],["ag","1",7,["268"]],["ar","54"],["am","374"],["aw","297"],["ac","247"],["au","61",0,null,"0"],["at","43"],["az","994"],["bs","1",8,["242"]],["bh","973"],["bd","880"],["bb","1",9,["246"]],["by","375"],["be","32"],["bz","501"],["bj","229"],["bm","1",10,["441"]],["bt","975"],["bo","591"],["ba","387"],["bw","267"],["br","55"],["io","246"],["vg","1",11,["284"]],["bn","673"],["bg","359"],["bf","226"],["bi","257"],["kh","855"],["cm","237"],["ca","1",1,["204","226","236","249","250","263","289","306","343","354","365","367","368","382","387","403","416","418","428","431","437","438","450","584","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","879","902","905"]],["cv","238"],["bq","599",1,["3","4","7"]],["ky","1",12,["345"]],["cf","236"],["td","235"],["cl","56"],["cn","86"],["cx","61",2,["89164"],"0"],["cc","61",1,["89162"],"0"],["co","57"],["km","269"],["cg","242"],["cd","243"],["ck","682"],["cr","506"],["ci","225"],["hr","385"],["cu","53"],["cw","599",0],["cy","357"],["cz","420"],["dk","45"],["dj","253"],["dm","1",13,["767"]],["do","1",2,["809","829","849"]],["ec","593"],["eg","20"],["sv","503"],["gq","240"],["er","291"],["ee","372"],["sz","268"],["et","251"],["fk","500"],["fo","298"],["fj","679"],["fi","358",0],["fr","33"],["gf","594"],["pf","689"],["ga","241"],["gm","220"],["ge","995"],["de","49"],["gh","233"],["gi","350"],["gr","30"],["gl","299"],["gd","1",14,["473"]],["gp","590",0],["gu","1",15,["671"]],["gt","502"],["gg","44",1,["1481","7781","7839","7911"],"0"],["gn","224"],["gw","245"],["gy","592"],["ht","509"],["hn","504"],["hk","852"],["hu","36"],["is","354"],["in","91"],["id","62"],["ir","98"],["iq","964"],["ie","353"],["im","44",2,["1624","74576","7524","7924","7624"],"0"],["il","972"],["it","39",0],["jm","1",4,["876","658"]],["jp","81"],["je","44",3,["1534","7509","7700","7797","7829","7937"],"0"],["jo","962"],["kz","7",1,["33","7"],"8"],["ke","254"],["ki","686"],["xk","383"],["kw","965"],["kg","996"],["la","856"],["lv","371"],["lb","961"],["ls","266"],["lr","231"],["ly","218"],["li","423"],["lt","370"],["lu","352"],["mo","853"],["mg","261"],["mw","265"],["my","60"],["mv","960"],["ml","223"],["mt","356"],["mh","692"],["mq","596"],["mr","222"],["mu","230"],["yt","262",1,["269","639"],"0"],["mx","52"],["fm","691"],["md","373"],["mc","377"],["mn","976"],["me","382"],["ms","1",16,["664"]],["ma","212",0,null,"0"],["mz","258"],["mm","95"],["na","264"],["nr","674"],["np","977"],["nl","31"],["nc","687"],["nz","64"],["ni","505"],["ne","227"],["ng","234"],["nu","683"],["nf","672"],["kp","850"],["mk","389"],["mp","1",17,["670"]],["no","47",0],["om","968"],["pk","92"],["pw","680"],["ps","970"],["pa","507"],["pg","675"],["py","595"],["pe","51"],["ph","63"],["pl","48"],["pt","351"],["pr","1",3,["787","939"]],["qa","974"],["re","262",0,null,"0"],["ro","40"],["ru","7",0,null,"8"],["rw","250"],["ws","685"],["sm","378"],["st","239"],["sa","966"],["sn","221"],["rs","381"],["sc","248"],["sl","232"],["sg","65"],["sx","1",21,["721"]],["sk","421"],["si","386"],["sb","677"],["so","252"],["za","27"],["kr","82"],["ss","211"],["es","34"],["lk","94"],["bl","590",1],["sh","290"],["kn","1",18,["869"]],["lc","1",19,["758"]],["mf","590",2],["pm","508"],["vc","1",20,["784"]],["sd","249"],["sr","597"],["sj","47",1,["79"]],["se","46"],["ch","41"],["sy","963"],["tw","886"],["tj","992"],["tz","255"],["th","66"],["tl","670"],["tg","228"],["tk","690"],["to","676"],["tt","1",22,["868"]],["tn","216"],["tr","90"],["tm","993"],["tc","1",23,["649"]],["tv","688"],["vi","1",24,["340"]],["ug","256"],["ua","380"],["ae","971"],["gb","44",0,null,"0"],["us","1",0],["uy","598"],["uz","998"],["vu","678"],["va","39",1,["06698"]],["ve","58"],["vn","84"],["wf","681"],["eh","212",1,["5288","5289"],"0"],["ye","967"],["zm","260"],["zw","263"]],l=[];for(let n of d)l.push({name:"",iso2:n[0],dialCode:n[1],priority:n[2]||0,areaCodes:n[3]||null,nodeById:{},nationalPrefix:n[4]||null});var b=l;return c(p);})();
17
17
 
18
18
  // UMD
19
19
  return factoryOutput.default;
@@ -416,6 +416,7 @@ declare module "intl-tel-input" {
416
416
  private _handleCountryContainerKeydown;
417
417
  private _handleInputEvent;
418
418
  private _handleKeydownEvent;
419
+ private _handlePasteEvent;
419
420
  private _handleWindowScroll;
420
421
  private _handleMouseoverCountryList;
421
422
  private _handleClickCountryList;