intl-tel-input 25.0.2 → 25.1.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.
@@ -112,7 +112,9 @@ var rawCountryData = [
112
112
  "au",
113
113
  // Australia
114
114
  "61",
115
- 0
115
+ 0,
116
+ null,
117
+ "0"
116
118
  ],
117
119
  [
118
120
  "at",
@@ -293,14 +295,16 @@ var rawCountryData = [
293
295
  // Christmas Island
294
296
  "61",
295
297
  2,
296
- ["89164"]
298
+ ["89164"],
299
+ "0"
297
300
  ],
298
301
  [
299
302
  "cc",
300
303
  // Cocos (Keeling) Islands
301
304
  "61",
302
305
  1,
303
- ["89162"]
306
+ ["89162"],
307
+ "0"
304
308
  ],
305
309
  [
306
310
  "co",
@@ -533,7 +537,8 @@ var rawCountryData = [
533
537
  // Guernsey
534
538
  "44",
535
539
  1,
536
- ["1481", "7781", "7839", "7911"]
540
+ ["1481", "7781", "7839", "7911"],
541
+ "0"
537
542
  ],
538
543
  [
539
544
  "gn",
@@ -605,7 +610,8 @@ var rawCountryData = [
605
610
  // Isle of Man
606
611
  "44",
607
612
  2,
608
- ["1624", "74576", "7524", "7924", "7624"]
613
+ ["1624", "74576", "7524", "7924", "7624"],
614
+ "0"
609
615
  ],
610
616
  [
611
617
  "il",
@@ -635,7 +641,8 @@ var rawCountryData = [
635
641
  // Jersey
636
642
  "44",
637
643
  3,
638
- ["1534", "7509", "7700", "7797", "7829", "7937"]
644
+ ["1534", "7509", "7700", "7797", "7829", "7937"],
645
+ "0"
639
646
  ],
640
647
  [
641
648
  "jo",
@@ -647,7 +654,8 @@ var rawCountryData = [
647
654
  // Kazakhstan
648
655
  "7",
649
656
  1,
650
- ["33", "7"]
657
+ ["33", "7"],
658
+ "8"
651
659
  ],
652
660
  [
653
661
  "ke",
@@ -779,7 +787,8 @@ var rawCountryData = [
779
787
  // Mayotte
780
788
  "262",
781
789
  1,
782
- ["269", "639"]
790
+ ["269", "639"],
791
+ "0"
783
792
  ],
784
793
  [
785
794
  "mx",
@@ -822,7 +831,9 @@ var rawCountryData = [
822
831
  "ma",
823
832
  // Morocco
824
833
  "212",
825
- 0
834
+ 0,
835
+ null,
836
+ "0"
826
837
  ],
827
838
  [
828
839
  "mz",
@@ -983,7 +994,9 @@ var rawCountryData = [
983
994
  "re",
984
995
  // Réunion
985
996
  "262",
986
- 0
997
+ 0,
998
+ null,
999
+ "0"
987
1000
  ],
988
1001
  [
989
1002
  "ro",
@@ -994,7 +1007,9 @@ var rawCountryData = [
994
1007
  "ru",
995
1008
  // Russia
996
1009
  "7",
997
- 0
1010
+ 0,
1011
+ null,
1012
+ "8"
998
1013
  ],
999
1014
  [
1000
1015
  "rw",
@@ -1266,7 +1281,9 @@ var rawCountryData = [
1266
1281
  "gb",
1267
1282
  // United Kingdom
1268
1283
  "44",
1269
- 0
1284
+ 0,
1285
+ null,
1286
+ "0"
1270
1287
  ],
1271
1288
  [
1272
1289
  "us",
@@ -1323,7 +1340,8 @@ var rawCountryData = [
1323
1340
  // Western Sahara
1324
1341
  "212",
1325
1342
  1,
1326
- ["5288", "5289"]
1343
+ ["5288", "5289"],
1344
+ "0"
1327
1345
  ],
1328
1346
  [
1329
1347
  "ye",
@@ -1351,8 +1369,8 @@ for (let i = 0; i < rawCountryData.length; i++) {
1351
1369
  dialCode: c[1],
1352
1370
  priority: c[2] || 0,
1353
1371
  areaCodes: c[3] || null,
1354
- partialAreaCodes: null,
1355
- nodeById: {}
1372
+ nodeById: {},
1373
+ nationalPrefix: c[4] || null
1356
1374
  };
1357
1375
  }
1358
1376
  var data_default = allCountries;
@@ -1876,7 +1894,7 @@ var Iti = class {
1876
1894
  }
1877
1895
  }
1878
1896
  }
1879
- //* Generate this.dialCodes and this.dialCodeToIso2Map and country.partialAreaCodes.
1897
+ //* Generate this.dialCodes and this.dialCodeToIso2Map.
1880
1898
  _processDialCodes() {
1881
1899
  this.dialCodes = {};
1882
1900
  this.dialCodeMaxLen = 0;
@@ -1899,12 +1917,6 @@ var Iti = class {
1899
1917
  const partialDialCode = c.dialCode + partialAreaCode;
1900
1918
  this._addToDialCodeMap(rootIso2Code, partialDialCode);
1901
1919
  this._addToDialCodeMap(c.iso2, partialDialCode);
1902
- if (!c.partialAreaCodes) {
1903
- c.partialAreaCodes = [];
1904
- }
1905
- if (!c.partialAreaCodes.includes(partialAreaCode)) {
1906
- c.partialAreaCodes.push(partialAreaCode);
1907
- }
1908
1920
  }
1909
1921
  this._addToDialCodeMap(c.iso2, c.dialCode + areaCode);
1910
1922
  }
@@ -2562,49 +2574,37 @@ var Iti = class {
2562
2574
  }
2563
2575
  return false;
2564
2576
  }
2565
- //* Check if the given number matches an area code from the selected country.
2566
- _isAreaCodeMatch(numeric, dialCodeNumerics) {
2567
- const { areaCodes, partialAreaCodes, dialCode } = this.selectedCountryData;
2568
- const typedNumber = numeric.substring(dialCode.length);
2569
- const typedAreaCode = dialCodeNumerics.substring(dialCode.length);
2570
- if (areaCodes.includes(typedAreaCode)) {
2571
- return true;
2577
+ _ensureHasDialCode(number) {
2578
+ const { dialCode, nationalPrefix } = this.selectedCountryData;
2579
+ const alreadyHasPlus = number.charAt(0) === "+";
2580
+ if (alreadyHasPlus || !dialCode) {
2581
+ return number;
2572
2582
  }
2573
- if (partialAreaCodes.includes(typedNumber)) {
2574
- return true;
2575
- }
2576
- return false;
2583
+ const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
2584
+ const cleanNumber = hasPrefix ? number.substring(1) : number;
2585
+ return `+${dialCode}${cleanNumber}`;
2577
2586
  }
2578
2587
  _getCountryFromNumber(fullNumber) {
2579
2588
  const plusIndex = fullNumber.indexOf("+");
2580
2589
  let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
2590
+ const selectedIso2 = this.selectedCountryData.iso2;
2581
2591
  const selectedDialCode = this.selectedCountryData.dialCode;
2582
- const isNanp = selectedDialCode === "1";
2583
- if (number && isNanp && number.charAt(0) !== "+") {
2584
- if (number.charAt(0) !== "1") {
2585
- number = `1${number}`;
2586
- }
2587
- number = `+${number}`;
2588
- }
2589
- if (this.options.separateDialCode && selectedDialCode && number.charAt(0) !== "+") {
2590
- number = `+${selectedDialCode}${number}`;
2592
+ number = this._ensureHasDialCode(number);
2593
+ const dialCodeMatch = this._getDialCode(number, true);
2594
+ if (dialCodeMatch && dialCodeMatch === this.prevDialCodeMatch) {
2595
+ return null;
2591
2596
  }
2592
- const dialCode = this._getDialCode(number, true);
2597
+ this.prevDialCodeMatch = dialCodeMatch;
2593
2598
  const numeric = getNumeric(number);
2594
- if (dialCode) {
2595
- const dialCodeNumerics = getNumeric(dialCode);
2596
- const iso2Codes = this.dialCodeToIso2Map[dialCodeNumerics];
2597
- const alreadySelected = this.selectedCountryData.iso2 && iso2Codes.includes(this.selectedCountryData.iso2);
2598
- let areaCodeMatch = false;
2599
- if (alreadySelected) {
2600
- if (this.selectedCountryData.areaCodes && numeric.length > selectedDialCode.length) {
2601
- areaCodeMatch = this._isAreaCodeMatch(numeric, dialCodeNumerics);
2602
- } else {
2603
- areaCodeMatch = true;
2604
- }
2599
+ if (dialCodeMatch) {
2600
+ const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2601
+ const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2602
+ if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2603
+ return this.defaultCountry;
2605
2604
  }
2605
+ const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && numeric.length === dialCodeMatchNumeric.length;
2606
2606
  const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2607
- if (!isRegionlessNanpNumber && (!alreadySelected || !areaCodeMatch)) {
2607
+ if (!isRegionlessNanpNumber && !alreadySelected) {
2608
2608
  for (let j = 0; j < iso2Codes.length; j++) {
2609
2609
  if (iso2Codes[j]) {
2610
2610
  return iso2Codes[j];
@@ -3168,7 +3168,7 @@ var intlTelInput = Object.assign(
3168
3168
  attachUtils,
3169
3169
  startedLoadingUtilsScript: false,
3170
3170
  startedLoadingAutoCountry: false,
3171
- version: "25.0.2"
3171
+ version: "25.1.0"
3172
3172
  }
3173
3173
  );
3174
3174
  var intl_tel_input_default = intlTelInput;
@@ -76,7 +76,9 @@ var rawCountryData = [
76
76
  "au",
77
77
  // Australia
78
78
  "61",
79
- 0
79
+ 0,
80
+ null,
81
+ "0"
80
82
  ],
81
83
  [
82
84
  "at",
@@ -257,14 +259,16 @@ var rawCountryData = [
257
259
  // Christmas Island
258
260
  "61",
259
261
  2,
260
- ["89164"]
262
+ ["89164"],
263
+ "0"
261
264
  ],
262
265
  [
263
266
  "cc",
264
267
  // Cocos (Keeling) Islands
265
268
  "61",
266
269
  1,
267
- ["89162"]
270
+ ["89162"],
271
+ "0"
268
272
  ],
269
273
  [
270
274
  "co",
@@ -497,7 +501,8 @@ var rawCountryData = [
497
501
  // Guernsey
498
502
  "44",
499
503
  1,
500
- ["1481", "7781", "7839", "7911"]
504
+ ["1481", "7781", "7839", "7911"],
505
+ "0"
501
506
  ],
502
507
  [
503
508
  "gn",
@@ -569,7 +574,8 @@ var rawCountryData = [
569
574
  // Isle of Man
570
575
  "44",
571
576
  2,
572
- ["1624", "74576", "7524", "7924", "7624"]
577
+ ["1624", "74576", "7524", "7924", "7624"],
578
+ "0"
573
579
  ],
574
580
  [
575
581
  "il",
@@ -599,7 +605,8 @@ var rawCountryData = [
599
605
  // Jersey
600
606
  "44",
601
607
  3,
602
- ["1534", "7509", "7700", "7797", "7829", "7937"]
608
+ ["1534", "7509", "7700", "7797", "7829", "7937"],
609
+ "0"
603
610
  ],
604
611
  [
605
612
  "jo",
@@ -611,7 +618,8 @@ var rawCountryData = [
611
618
  // Kazakhstan
612
619
  "7",
613
620
  1,
614
- ["33", "7"]
621
+ ["33", "7"],
622
+ "8"
615
623
  ],
616
624
  [
617
625
  "ke",
@@ -743,7 +751,8 @@ var rawCountryData = [
743
751
  // Mayotte
744
752
  "262",
745
753
  1,
746
- ["269", "639"]
754
+ ["269", "639"],
755
+ "0"
747
756
  ],
748
757
  [
749
758
  "mx",
@@ -786,7 +795,9 @@ var rawCountryData = [
786
795
  "ma",
787
796
  // Morocco
788
797
  "212",
789
- 0
798
+ 0,
799
+ null,
800
+ "0"
790
801
  ],
791
802
  [
792
803
  "mz",
@@ -947,7 +958,9 @@ var rawCountryData = [
947
958
  "re",
948
959
  // Réunion
949
960
  "262",
950
- 0
961
+ 0,
962
+ null,
963
+ "0"
951
964
  ],
952
965
  [
953
966
  "ro",
@@ -958,7 +971,9 @@ var rawCountryData = [
958
971
  "ru",
959
972
  // Russia
960
973
  "7",
961
- 0
974
+ 0,
975
+ null,
976
+ "8"
962
977
  ],
963
978
  [
964
979
  "rw",
@@ -1230,7 +1245,9 @@ var rawCountryData = [
1230
1245
  "gb",
1231
1246
  // United Kingdom
1232
1247
  "44",
1233
- 0
1248
+ 0,
1249
+ null,
1250
+ "0"
1234
1251
  ],
1235
1252
  [
1236
1253
  "us",
@@ -1287,7 +1304,8 @@ var rawCountryData = [
1287
1304
  // Western Sahara
1288
1305
  "212",
1289
1306
  1,
1290
- ["5288", "5289"]
1307
+ ["5288", "5289"],
1308
+ "0"
1291
1309
  ],
1292
1310
  [
1293
1311
  "ye",
@@ -1315,8 +1333,8 @@ for (let i = 0; i < rawCountryData.length; i++) {
1315
1333
  dialCode: c[1],
1316
1334
  priority: c[2] || 0,
1317
1335
  areaCodes: c[3] || null,
1318
- partialAreaCodes: null,
1319
- nodeById: {}
1336
+ nodeById: {},
1337
+ nationalPrefix: c[4] || null
1320
1338
  };
1321
1339
  }
1322
1340
  var data_default = allCountries;
@@ -1840,7 +1858,7 @@ var Iti = class {
1840
1858
  }
1841
1859
  }
1842
1860
  }
1843
- //* Generate this.dialCodes and this.dialCodeToIso2Map and country.partialAreaCodes.
1861
+ //* Generate this.dialCodes and this.dialCodeToIso2Map.
1844
1862
  _processDialCodes() {
1845
1863
  this.dialCodes = {};
1846
1864
  this.dialCodeMaxLen = 0;
@@ -1863,12 +1881,6 @@ var Iti = class {
1863
1881
  const partialDialCode = c.dialCode + partialAreaCode;
1864
1882
  this._addToDialCodeMap(rootIso2Code, partialDialCode);
1865
1883
  this._addToDialCodeMap(c.iso2, partialDialCode);
1866
- if (!c.partialAreaCodes) {
1867
- c.partialAreaCodes = [];
1868
- }
1869
- if (!c.partialAreaCodes.includes(partialAreaCode)) {
1870
- c.partialAreaCodes.push(partialAreaCode);
1871
- }
1872
1884
  }
1873
1885
  this._addToDialCodeMap(c.iso2, c.dialCode + areaCode);
1874
1886
  }
@@ -2526,49 +2538,37 @@ var Iti = class {
2526
2538
  }
2527
2539
  return false;
2528
2540
  }
2529
- //* Check if the given number matches an area code from the selected country.
2530
- _isAreaCodeMatch(numeric, dialCodeNumerics) {
2531
- const { areaCodes, partialAreaCodes, dialCode } = this.selectedCountryData;
2532
- const typedNumber = numeric.substring(dialCode.length);
2533
- const typedAreaCode = dialCodeNumerics.substring(dialCode.length);
2534
- if (areaCodes.includes(typedAreaCode)) {
2535
- return true;
2541
+ _ensureHasDialCode(number) {
2542
+ const { dialCode, nationalPrefix } = this.selectedCountryData;
2543
+ const alreadyHasPlus = number.charAt(0) === "+";
2544
+ if (alreadyHasPlus || !dialCode) {
2545
+ return number;
2536
2546
  }
2537
- if (partialAreaCodes.includes(typedNumber)) {
2538
- return true;
2539
- }
2540
- return false;
2547
+ const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
2548
+ const cleanNumber = hasPrefix ? number.substring(1) : number;
2549
+ return `+${dialCode}${cleanNumber}`;
2541
2550
  }
2542
2551
  _getCountryFromNumber(fullNumber) {
2543
2552
  const plusIndex = fullNumber.indexOf("+");
2544
2553
  let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
2554
+ const selectedIso2 = this.selectedCountryData.iso2;
2545
2555
  const selectedDialCode = this.selectedCountryData.dialCode;
2546
- const isNanp = selectedDialCode === "1";
2547
- if (number && isNanp && number.charAt(0) !== "+") {
2548
- if (number.charAt(0) !== "1") {
2549
- number = `1${number}`;
2550
- }
2551
- number = `+${number}`;
2552
- }
2553
- if (this.options.separateDialCode && selectedDialCode && number.charAt(0) !== "+") {
2554
- number = `+${selectedDialCode}${number}`;
2556
+ number = this._ensureHasDialCode(number);
2557
+ const dialCodeMatch = this._getDialCode(number, true);
2558
+ if (dialCodeMatch && dialCodeMatch === this.prevDialCodeMatch) {
2559
+ return null;
2555
2560
  }
2556
- const dialCode = this._getDialCode(number, true);
2561
+ this.prevDialCodeMatch = dialCodeMatch;
2557
2562
  const numeric = getNumeric(number);
2558
- if (dialCode) {
2559
- const dialCodeNumerics = getNumeric(dialCode);
2560
- const iso2Codes = this.dialCodeToIso2Map[dialCodeNumerics];
2561
- const alreadySelected = this.selectedCountryData.iso2 && iso2Codes.includes(this.selectedCountryData.iso2);
2562
- let areaCodeMatch = false;
2563
- if (alreadySelected) {
2564
- if (this.selectedCountryData.areaCodes && numeric.length > selectedDialCode.length) {
2565
- areaCodeMatch = this._isAreaCodeMatch(numeric, dialCodeNumerics);
2566
- } else {
2567
- areaCodeMatch = true;
2568
- }
2563
+ if (dialCodeMatch) {
2564
+ const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2565
+ const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2566
+ if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2567
+ return this.defaultCountry;
2569
2568
  }
2569
+ const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && numeric.length === dialCodeMatchNumeric.length;
2570
2570
  const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2571
- if (!isRegionlessNanpNumber && (!alreadySelected || !areaCodeMatch)) {
2571
+ if (!isRegionlessNanpNumber && !alreadySelected) {
2572
2572
  for (let j = 0; j < iso2Codes.length; j++) {
2573
2573
  if (iso2Codes[j]) {
2574
2574
  return iso2Codes[j];
@@ -3132,7 +3132,7 @@ var intlTelInput = Object.assign(
3132
3132
  attachUtils,
3133
3133
  startedLoadingUtilsScript: false,
3134
3134
  startedLoadingAutoCountry: false,
3135
- version: "25.0.2"
3135
+ version: "25.1.0"
3136
3136
  }
3137
3137
  );
3138
3138
  var intl_tel_input_default = intlTelInput;
package/vue/README.md CHANGED
@@ -34,7 +34,7 @@ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master
34
34
  "vue:demo": "vite --config vue/demo/[demo variant]/vite.config.js"
35
35
  ```
36
36
 
37
- 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/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` 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.0.2/build/js/utils.js"`.
37
+ 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/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` 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.1.0/build/js/utils.js"`.
38
38
 
39
39
  ## Props
40
40
  Here's a list of all of the current props you can pass to the IntlTelInput Vue component.