intl-tel-input 25.0.2 → 25.1.1
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 +5 -5
- package/build/js/data.js +34 -16
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +3 -3
- package/build/js/intlTelInput.js +54 -58
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +54 -58
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +53 -57
- package/react/build/IntlTelInput.d.ts +3 -3
- package/react/build/IntlTelInput.js +53 -57
- package/react/build/IntlTelInputWithUtils.cjs +53 -57
- package/react/build/IntlTelInputWithUtils.js +53 -57
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +366 -344
- package/vue/build/IntlTelInputWithUtils.mjs +674 -652
package/package.json
CHANGED
package/react/README.md
CHANGED
|
@@ -28,7 +28,7 @@ import "intl-tel-input/styles";
|
|
|
28
28
|
|
|
29
29
|
See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
|
|
30
30
|
|
|
31
|
-
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.
|
|
31
|
+
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.1/build/js/utils.js"`.
|
|
32
32
|
|
|
33
33
|
## Props
|
|
34
34
|
Here's a list of all of the current props you can pass to the IntlTelInput React component.
|
|
@@ -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
|
-
|
|
1355
|
-
|
|
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
|
|
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,33 @@ var Iti = class {
|
|
|
2562
2574
|
}
|
|
2563
2575
|
return false;
|
|
2564
2576
|
}
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2569
|
-
|
|
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
|
-
|
|
2574
|
-
|
|
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
|
-
|
|
2583
|
-
|
|
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}`;
|
|
2591
|
-
}
|
|
2592
|
-
const dialCode = this._getDialCode(number, true);
|
|
2592
|
+
number = this._ensureHasDialCode(number);
|
|
2593
|
+
const dialCodeMatch = this._getDialCode(number, true);
|
|
2593
2594
|
const numeric = getNumeric(number);
|
|
2594
|
-
if (
|
|
2595
|
-
const
|
|
2596
|
-
const iso2Codes = this.dialCodeToIso2Map[
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
if (alreadySelected) {
|
|
2600
|
-
if (this.selectedCountryData.areaCodes && numeric.length > selectedDialCode.length) {
|
|
2601
|
-
areaCodeMatch = this._isAreaCodeMatch(numeric, dialCodeNumerics);
|
|
2602
|
-
} else {
|
|
2603
|
-
areaCodeMatch = true;
|
|
2604
|
-
}
|
|
2595
|
+
if (dialCodeMatch) {
|
|
2596
|
+
const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
|
|
2597
|
+
const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
|
|
2598
|
+
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2599
|
+
return this.defaultCountry;
|
|
2605
2600
|
}
|
|
2601
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes);
|
|
2606
2602
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2607
|
-
if (!isRegionlessNanpNumber &&
|
|
2603
|
+
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2608
2604
|
for (let j = 0; j < iso2Codes.length; j++) {
|
|
2609
2605
|
if (iso2Codes[j]) {
|
|
2610
2606
|
return iso2Codes[j];
|
|
@@ -3168,7 +3164,7 @@ var intlTelInput = Object.assign(
|
|
|
3168
3164
|
attachUtils,
|
|
3169
3165
|
startedLoadingUtilsScript: false,
|
|
3170
3166
|
startedLoadingAutoCountry: false,
|
|
3171
|
-
version: "25.
|
|
3167
|
+
version: "25.1.1"
|
|
3172
3168
|
}
|
|
3173
3169
|
);
|
|
3174
3170
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -5,8 +5,8 @@ declare module "intl-tel-input/data" {
|
|
|
5
5
|
dialCode: string;
|
|
6
6
|
priority: number;
|
|
7
7
|
areaCodes: string[] | null;
|
|
8
|
-
partialAreaCodes: string[] | null;
|
|
9
8
|
nodeById: object;
|
|
9
|
+
nationalPrefix: string | null;
|
|
10
10
|
};
|
|
11
11
|
const allCountries: Country[];
|
|
12
12
|
export default allCountries;
|
|
@@ -330,7 +330,7 @@ declare module "intl-tel-input" {
|
|
|
330
330
|
iso2?: string;
|
|
331
331
|
dialCode?: string;
|
|
332
332
|
areaCodes?: string[];
|
|
333
|
-
|
|
333
|
+
nationalPrefix?: string;
|
|
334
334
|
};
|
|
335
335
|
interface AllOptions {
|
|
336
336
|
allowDropdown: boolean;
|
|
@@ -441,7 +441,7 @@ declare module "intl-tel-input" {
|
|
|
441
441
|
private _handleEnterKey;
|
|
442
442
|
private _updateValFromNumber;
|
|
443
443
|
private _updateCountryFromNumber;
|
|
444
|
-
private
|
|
444
|
+
private _ensureHasDialCode;
|
|
445
445
|
private _getCountryFromNumber;
|
|
446
446
|
private _highlightListItem;
|
|
447
447
|
private _getCountryData;
|
|
@@ -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
|
-
|
|
1319
|
-
|
|
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
|
|
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,33 @@ var Iti = class {
|
|
|
2526
2538
|
}
|
|
2527
2539
|
return false;
|
|
2528
2540
|
}
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
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
|
-
|
|
2538
|
-
|
|
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
|
-
|
|
2547
|
-
|
|
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}`;
|
|
2555
|
-
}
|
|
2556
|
-
const dialCode = this._getDialCode(number, true);
|
|
2556
|
+
number = this._ensureHasDialCode(number);
|
|
2557
|
+
const dialCodeMatch = this._getDialCode(number, true);
|
|
2557
2558
|
const numeric = getNumeric(number);
|
|
2558
|
-
if (
|
|
2559
|
-
const
|
|
2560
|
-
const iso2Codes = this.dialCodeToIso2Map[
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
if (alreadySelected) {
|
|
2564
|
-
if (this.selectedCountryData.areaCodes && numeric.length > selectedDialCode.length) {
|
|
2565
|
-
areaCodeMatch = this._isAreaCodeMatch(numeric, dialCodeNumerics);
|
|
2566
|
-
} else {
|
|
2567
|
-
areaCodeMatch = true;
|
|
2568
|
-
}
|
|
2559
|
+
if (dialCodeMatch) {
|
|
2560
|
+
const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
|
|
2561
|
+
const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
|
|
2562
|
+
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2563
|
+
return this.defaultCountry;
|
|
2569
2564
|
}
|
|
2565
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes);
|
|
2570
2566
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2571
|
-
if (!isRegionlessNanpNumber &&
|
|
2567
|
+
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2572
2568
|
for (let j = 0; j < iso2Codes.length; j++) {
|
|
2573
2569
|
if (iso2Codes[j]) {
|
|
2574
2570
|
return iso2Codes[j];
|
|
@@ -3132,7 +3128,7 @@ var intlTelInput = Object.assign(
|
|
|
3132
3128
|
attachUtils,
|
|
3133
3129
|
startedLoadingUtilsScript: false,
|
|
3134
3130
|
startedLoadingAutoCountry: false,
|
|
3135
|
-
version: "25.
|
|
3131
|
+
version: "25.1.1"
|
|
3136
3132
|
}
|
|
3137
3133
|
);
|
|
3138
3134
|
var intl_tel_input_default = intlTelInput;
|