1/* 2 * International Telephone Input v25.3.0 3 * https://github.com/jackocnr/intl-tel-input.git 4 * Licensed under the MIT license 5 */ 6 7// UMD 8(function(factory) { 9 if (typeof module === 'object' && module.exports) { 10 module.exports = factory(); 11 } else { 12 window.intlTelInput = factory(); 13 } 14}(() => { 15 16var factoryOutput = (() => { 17 var __defProp = Object.defineProperty; 18 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 19 var __getOwnPropNames = Object.getOwnPropertyNames; 20 var __hasOwnProp = Object.prototype.hasOwnProperty; 21 var __export = (target, all) => { 22 for (var name in all) 23 __defProp(target, name, { get: all[name], enumerable: true }); 24 }; 25 var __copyProps = (to, from, except, desc) => { 26 if (from && typeof from === "object" || typeof from === "function") { 27 for (let key of __getOwnPropNames(from)) 28 if (!__hasOwnProp.call(to, key) && key !== except) 29 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 30 } 31 return to; 32 }; 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35
35// src/js/intl-tel-input.ts 36 var intl_tel_input_exports = {}; 37 __export(intl_tel_input_exports, { 38 Iti: () => Iti, 39 default: () => intl_tel_input_default 40 }); 41 42
42// src/js/intl-tel-input/data.ts 43 var rawCountryData = [ 44 [ 45 "af", 46 // Afghanistan 47 "93" 48 ], 49 [ 50 "ax", 51 // à land Islands 52 "358", 53 1 54 ], 55 [ 56 "al", 57 // Albania 58 "355" 59 ], 60 [ 61 "dz", 62 // Algeria 63 "213" 64 ], 65 [ 66 "as", 67 // American Samoa 68 "1", 69 5, 70 ["684"] 71 ], 72 [ 73 "ad", 74 // Andorra 75 "376" 76 ], 77 [ 78 "ao", 79 // Angola 80 "244" 81 ], 82 [ 83 "ai", 84 // Anguilla 85 "1", 86 6, 87 ["264"] 88 ], 89 [ 90 "ag", 91 // Antigua and Barbuda 92 "1", 93 7, 94 ["268"] 95 ], 96 [ 97 "ar", 98 // Argentina 99 "54" 100 ], 101 [ 102 "am", 103 // Armenia 104 "374" 105 ], 106 [ 107 "aw", 108 // Aruba 109 "297" 110 ], 111 [ 112 "ac", 113 // Ascension Island 114 "247" 115 ], 116 [ 117 "au", 118 // Australia 119 "61", 120 0, 121 null, 122 "0" 123 ], 124 [ 125 "at", 126 // Austria 127 "43" 128 ], 129 [ 130 "az", 131 // Azerbaijan 132 "994" 133 ], 134 [ 135 "bs", 136 // Bahamas 137 "1", 138 8, 139 ["242"] 140 ], 141 [ 142 "bh", 143 // Bahrain 144 "973" 145 ], 146 [ 147 "bd", 148 // Bangladesh 149 "880" 150 ], 151 [ 152 "bb", 153 // Barbados 154 "1", 155 9, 156 ["246"] 157 ], 158 [ 159 "by", 160 // Belarus 161 "375" 162 ], 163 [ 164 "be", 165 // Belgium 166 "32" 167 ], 168 [ 169 "bz", 170 // Belize 171 "501" 172 ], 173 [ 174 "bj", 175 // Benin 176 "229" 177 ], 178 [ 179 "bm", 180 // Bermuda 181 "1", 182 10, 183 ["441"] 184 ], 185 [ 186 "bt", 187 // Bhutan 188 "975" 189 ], 190 [ 191 "bo", 192 // Bolivia 193 "591" 194 ], 195 [ 196 "ba", 197 // Bosnia and Herzegovina 198 "387" 199 ], 200 [ 201 "bw", 202 // Botswana 203 "267" 204 ], 205 [ 206 "br", 207 // Brazil 208 "55" 209 ], 210 [ 211 "io", 212 // British Indian Ocean Territory 213 "246" 214 ], 215 [ 216 "vg", 217 // British Virgin Islands 218 "1", 219 11, 220 ["284"] 221 ], 222 [ 223 "bn", 224 // Brunei 225 "673" 226 ], 227 [ 228 "bg", 229 // Bulgaria 230 "359" 231 ], 232 [ 233 "bf", 234 // Burkina Faso 235 "226" 236 ], 237 [ 238 "bi", 239 // Burundi 240 "257" 241 ], 242 [ 243 "kh", 244 // Cambodia 245 "855" 246 ], 247 [ 248 "cm", 249 // Cameroon 250 "237" 251 ], 252 [ 253 "ca", 254 // Canada 255 "1", 256 1, 257 ["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"] 258 ], 259 [ 260 "cv", 261 // Cape Verde 262 "238" 263 ], 264 [ 265 "bq", 266 // Caribbean Netherlands 267 "599", 268 1, 269 ["3", "4", "7"] 270 ], 271 [ 272 "ky", 273 // Cayman Islands 274 "1", 275 12, 276 ["345"] 277 ], 278 [ 279 "cf", 280 // Central African Republic 281 "236" 282 ], 283 [ 284 "td", 285 // Chad 286 "235" 287 ], 288 [ 289 "cl", 290 // Chile 291 "56" 292 ], 293 [ 294 "cn", 295 // China 296 "86" 297 ], 298 [ 299 "cx", 300 // Christmas Island 301 "61", 302 2, 303 ["89164"], 304 "0" 305 ], 306 [ 307 "cc", 308 // Cocos (Keeling) Islands 309 "61", 310 1, 311 ["89162"], 312 "0" 313 ], 314 [ 315 "co", 316 // Colombia 317 "57" 318 ], 319 [ 320 "km", 321 // Comoros 322 "269" 323 ], 324 [ 325 "cg", 326 // Congo (Brazzaville) 327 "242" 328 ], 329 [ 330 "cd", 331 // Congo (Kinshasa) 332 "243" 333 ], 334 [ 335 "ck", 336 // Cook Islands 337 "682" 338 ], 339 [ 340 "cr", 341 // Costa Rica 342 "506" 343 ], 344 [ 345 "ci", 346 // Côte d'Ivoire 347 "225" 348 ], 349 [ 350 "hr", 351 // Croatia 352 "385" 353 ], 354 [ 355 "cu", 356 // Cuba 357 "53" 358 ], 359 [ 360 "cw", 361 // Curaçao 362 "599", 363 0 364 ], 365 [ 366 "cy", 367 // Cyprus 368 "357" 369 ], 370 [ 371 "cz", 372 // Czech Republic 373 "420" 374 ], 375 [ 376 "dk",
377 // Denmark 378 "45" 379 ], 380 [ 381 "dj", 382 // Djibouti 383 "253" 384 ], 385 [ 386 "dm", 387 // Dominica 388 "1", 389 13, 390 ["767"] 391 ], 392 [ 393 "do", 394 // Dominican Republic 395 "1", 396 2, 397 ["809", "829", "849"] 398 ], 399 [ 400 "ec", 401 // Ecuador 402 "593" 403 ], 404 [ 405 "eg", 406 // Egypt 407 "20" 408 ], 409 [ 410 "sv", 411 // El Salvador 412 "503" 413 ], 414 [ 415 "gq", 416 // Equatorial Guinea 417 "240" 418 ], 419 [ 420 "er", 421 // Eritrea 422 "291" 423 ], 424 [ 425 "ee", 426 // Estonia 427 "372" 428 ], 429 [ 430 "sz", 431 // Eswatini 432 "268" 433 ], 434 [ 435 "et", 436 // Ethiopia 437 "251" 438 ], 439 [ 440 "fk", 441 // Falkland Islands (Malvinas) 442 "500" 443 ], 444 [ 445 "fo", 446 // Faroe Islands 447 "298" 448 ], 449 [ 450 "fj", 451 // Fiji 452 "679" 453 ], 454 [ 455 "fi", 456 // Finland 457 "358", 458 0 459 ], 460 [ 461 "fr", 462 // France 463 "33" 464 ], 465 [ 466 "gf", 467 // French Guiana 468 "594" 469 ], 470 [ 471 "pf", 472 // French Polynesia 473 "689" 474 ], 475 [ 476 "ga", 477 // Gabon 478 "241" 479 ], 480 [ 481 "gm", 482 // Gambia 483 "220" 484 ], 485 [ 486 "ge", 487 // Georgia 488 "995" 489 ], 490 [ 491 "de", 492 // Germany 493 "49" 494 ], 495 [ 496 "gh", 497 // Ghana 498 "233" 499 ], 500 [ 501 "gi", 502 // Gibraltar 503 "350" 504 ], 505 [ 506 "gr", 507 // Greece 508 "30" 509 ], 510 [ 511 "gl", 512 // Greenland 513 "299" 514 ], 515 [ 516 "gd", 517 // Grenada 518 "1", 519 14, 520 ["473"] 521 ], 522 [ 523 "gp", 524 // Guadeloupe 525 "590", 526 0 527 ], 528 [ 529 "gu", 530 // Guam 531 "1", 532 15, 533 ["671"] 534 ], 535 [ 536 "gt", 537 // Guatemala 538 "502" 539 ], 540 [ 541 "gg", 542 // Guernsey 543 "44", 544 1, 545 ["1481", "7781", "7839", "7911"], 546 "0" 547 ], 548 [ 549 "gn", 550 // Guinea 551 "224" 552 ], 553 [ 554 "gw", 555 // Guinea-Bissau 556 "245" 557 ], 558 [ 559 "gy", 560 // Guyana 561 "592" 562 ], 563 [ 564 "ht", 565 // Haiti 566 "509" 567 ], 568 [ 569 "hn", 570 // Honduras 571 "504" 572 ], 573 [ 574 "hk", 575 // Hong Kong SAR China 576 "852" 577 ], 578 [ 579 "hu", 580 // Hungary 581 "36" 582 ], 583 [ 584 "is", 585 // Iceland 586 "354" 587 ], 588 [ 589 "in", 590 // India 591 "91" 592 ], 593 [ 594 "id", 595 // Indonesia 596 "62" 597 ], 598 [ 599 "ir", 600 // Iran 601 "98" 602 ], 603 [ 604 "iq", 605 // Iraq 606 "964" 607 ], 608 [ 609 "ie", 610 // Ireland 611 "353" 612 ], 613 [ 614 "im", 615 // Isle of Man 616 "44", 617 2, 618 ["1624", "74576", "7524", "7924", "7624"], 619 "0" 620 ], 621 [ 622 "il", 623 // Israel 624 "972" 625 ], 626 [ 627 "it", 628 // Italy 629 "39", 630 0 631 ], 632 [ 633 "jm", 634 // Jamaica 635 "1", 636 4, 637 ["876", "658"] 638 ], 639 [ 640 "jp", 641 // Japan 642 "81" 643 ], 644 [ 645 "je", 646 // Jersey 647 "44", 648 3, 649 ["1534", "7509", "7700", "7797", "7829", "7937"], 650 "0" 651 ], 652 [ 653 "jo", 654 // Jordan 655 "962" 656 ], 657 [ 658 "kz", 659 // Kazakhstan 660 "7", 661 1, 662 ["33", "7"], 663 "8" 664 ], 665 [ 666 "ke", 667 // Kenya 668 "254" 669 ], 670 [ 671 "ki", 672 // Kiribati 673 "686" 674 ], 675 [ 676 "xk", 677 // Kosovo 678 "383" 679 ], 680 [ 681 "kw", 682 // Kuwait 683 "965" 684 ], 685 [ 686 "kg", 687 // Kyrgyzstan 688 "996" 689 ], 690 [ 691 "la", 692 // Laos 693 "856" 694 ], 695 [ 696 "lv", 697 // Latvia 698 "371" 699 ], 700 [ 701 "lb", 702 // Lebanon 703 "961" 704 ], 705 [ 706 "ls", 707 // Lesotho 708 "266" 709 ], 710 [ 711 "lr", 712 // Liberia 713 "231" 714 ], 715 [ 716 "ly", 717 // Libya 718 "218" 719 ], 720 [ 721 "li", 722 // Liechtenstein 723 "423" 724 ], 725 [ 726 "lt", 727 // Lithuania 728 "370" 729 ], 730 [ 731 "lu", 732 // Luxembourg 733 "352" 734 ], 735 [ 736 "mo", 737 // Macao SAR China 738 "853" 739 ], 740 [ 741 "mg", 742 // Madagascar 743 "261" 744 ], 745 [ 746 "mw", 747 // Malawi 748 "265" 749 ], 750 [ 751 "my", 752 // Malaysia 753 "60" 754 ], 755 [ 756 "mv", 757 // Maldives 758 "960" 759 ], 760 [ 761 "ml", 762 // Mali 763 "223" 764 ], 765 [ 766 "mt", 767 // Malta 768 "356" 769 ], 770 [ 771 "mh", 772 // Marshall Islands 773 "692" 774 ], 775 [ 776 "mq", 777 // Martinique 778 "596" 779 ], 780 [ 781 "mr", 782 // Mauritania 783 "222" 784 ], 785 [ 786 "mu", 787 // Mauritius 788 "230" 789 ], 790 [ 791 "yt", 792 // Mayotte 793 "262", 794 1, 795 ["269", "639"], 796 "0" 797 ], 798 [ 799 "mx", 800 // Mexico 801 "52" 802 ], 803 [ 804 "fm", 805 // Micronesia 806 "691" 807 ], 808 [ 809 "md", 810 // Moldova 811 "373" 812 ], 813 [ 814 "mc", 815 // Monaco 816 "377" 817 ], 818 [ 819 "mn", 820 // Mongolia 821 "976" 822 ], 823 [ 824 "me", 825 // Montenegro 826 "382" 827 ], 828 [ 829 "ms", 830 // Montserrat 831 "1", 832 16, 833 ["664"] 834 ], 835 [ 836 "ma", 837 // Morocco 838 "212", 839 0, 840 null, 841 "0" 842 ], 843 [ 844 "mz", 845 // Mozambique 846 "258" 847 ], 848 [ 849 "mm", 850 // Myanmar (Burma) 851 "95" 852 ], 853 [ 854 "na", 855 // Namibia 856 "264" 857 ], 858 [ 859 "nr", 860 // Nauru 861 "674" 862 ], 863 [ 864 "np", 865 // Nepal 866 "977" 867 ], 868 [ 869 "nl", 870 // Netherlands 871 "31" 872 ], 873 [ 874 "nc", 875 // New Caledonia 876 "687" 877 ], 878 [ 879 "nz", 880 // New Zealand 881 "64" 882 ], 883 [ 884 "ni", 885 // Nicaragua 886 "505" 887 ], 888 [ 889 "ne", 890 // Niger 891 "227" 892 ], 893 [ 894 "ng", 895 // Nigeria 896 "234" 897 ], 898 [ 899 "nu", 900 // Niue 901 "683" 902 ], 903 [ 904 "nf", 905 // Norfolk Island 906 "672" 907 ], 908 [ 909 "kp", 910 // North Korea 911 "850" 912 ], 913 [ 914 "mk", 915 // North Macedonia 916 "389" 917 ], 918 [ 919 "mp", 920 // Northern Mariana Islands 921 "1", 922 17, 923 ["670"] 924 ], 925 [ 926 "no", 927 // Norway 928 "47", 929 0 930 ], 931 [ 932 "om", 933 // Oman 934 "968" 935 ], 936 [ 937 "pk", 938 // Pakistan 939 "92" 940 ], 941 [ 942 "pw", 943 // Palau 944 "680"
945 ], 946 [ 947 "ps", 948 // Palestinian Territories 949 "970" 950 ], 951 [ 952 "pa", 953 // Panama 954 "507" 955 ], 956 [ 957 "pg", 958 // Papua New Guinea 959 "675" 960 ], 961 [ 962 "py", 963 // Paraguay 964 "595" 965 ], 966 [ 967 "pe", 968 // Peru 969 "51" 970 ], 971 [ 972 "ph", 973 // Philippines 974 "63" 975 ], 976 [ 977 "pl", 978 // Poland 979 "48" 980 ], 981 [ 982 "pt", 983 // Portugal 984 "351" 985 ], 986 [ 987 "pr", 988 // Puerto Rico 989 "1", 990 3, 991 ["787", "939"] 992 ], 993 [ 994 "qa", 995 // Qatar 996 "974" 997 ], 998 [ 999 "re", 1000 // Réunion 1001 "262", 1002 0, 1003 null, 1004 "0" 1005 ], 1006 [ 1007 "ro", 1008 // Romania 1009 "40" 1010 ], 1011 [ 1012 "ru", 1013 // Russia 1014 "7", 1015 0, 1016 null, 1017 "8" 1018 ], 1019 [ 1020 "rw", 1021 // Rwanda 1022 "250" 1023 ], 1024 [ 1025 "ws", 1026 // Samoa 1027 "685" 1028 ], 1029 [ 1030 "sm", 1031 // San Marino 1032 "378" 1033 ], 1034 [ 1035 "st", 1036 // São Tomé & PrÃncipe 1037 "239" 1038 ], 1039 [ 1040 "sa", 1041 // Saudi Arabia 1042 "966" 1043 ], 1044 [ 1045 "sn", 1046 // Senegal 1047 "221" 1048 ], 1049 [ 1050 "rs", 1051 // Serbia 1052 "381" 1053 ], 1054 [ 1055 "sc", 1056 // Seychelles 1057 "248" 1058 ], 1059 [ 1060 "sl", 1061 // Sierra Leone 1062 "232" 1063 ], 1064 [ 1065 "sg", 1066 // Singapore 1067 "65" 1068 ], 1069 [ 1070 "sx", 1071 // Sint Maarten 1072 "1", 1073 21, 1074 ["721"] 1075 ], 1076 [ 1077 "sk", 1078 // Slovakia 1079 "421" 1080 ], 1081 [ 1082 "si", 1083 // Slovenia 1084 "386" 1085 ], 1086 [ 1087 "sb", 1088 // Solomon Islands 1089 "677" 1090 ], 1091 [ 1092 "so", 1093 // Somalia 1094 "252" 1095 ], 1096 [ 1097 "za", 1098 // South Africa 1099 "27" 1100 ], 1101 [ 1102 "kr", 1103 // South Korea 1104 "82" 1105 ], 1106 [ 1107 "ss", 1108 // South Sudan 1109 "211" 1110 ], 1111 [ 1112 "es", 1113 // Spain 1114 "34" 1115 ], 1116 [ 1117 "lk", 1118 // Sri Lanka 1119 "94" 1120 ], 1121 [ 1122 "bl", 1123 // St. Barthélemy 1124 "590", 1125 1 1126 ], 1127 [ 1128 "sh", 1129 // St. Helena 1130 "290" 1131 ], 1132 [ 1133 "kn", 1134 // St. Kitts & Nevis 1135 "1", 1136 18, 1137 ["869"] 1138 ], 1139 [ 1140 "lc", 1141 // St. Lucia 1142 "1", 1143 19, 1144 ["758"] 1145 ], 1146 [ 1147 "mf", 1148 // St. Martin 1149 "590", 1150 2 1151 ], 1152 [ 1153 "pm", 1154 // St. Pierre & Miquelon 1155 "508" 1156 ], 1157 [ 1158 "vc", 1159 // St. Vincent & Grenadines 1160 "1", 1161 20, 1162 ["784"] 1163 ], 1164 [ 1165 "sd", 1166 // Sudan 1167 "249" 1168 ], 1169 [ 1170 "sr", 1171 // Suriname 1172 "597" 1173 ], 1174 [ 1175 "sj", 1176 // Svalbard & Jan Mayen 1177 "47", 1178 1, 1179 ["79"] 1180 ], 1181 [ 1182 "se", 1183 // Sweden 1184 "46" 1185 ], 1186 [ 1187 "ch", 1188 // Switzerland 1189 "41" 1190 ], 1191 [ 1192 "sy", 1193 // Syria 1194 "963" 1195 ], 1196 [ 1197 "tw", 1198 // Taiwan 1199 "886" 1200 ], 1201 [ 1202 "tj", 1203 // Tajikistan 1204 "992" 1205 ], 1206 [ 1207 "tz", 1208 // Tanzania 1209 "255" 1210 ], 1211 [ 1212 "th", 1213 // Thailand 1214 "66" 1215 ], 1216 [ 1217 "tl", 1218 // Timor-Leste 1219 "670" 1220 ], 1221 [ 1222 "tg", 1223 // Togo 1224 "228" 1225 ], 1226 [ 1227 "tk", 1228 // Tokelau 1229 "690" 1230 ], 1231 [ 1232 "to", 1233 // Tonga 1234 "676" 1235 ], 1236 [ 1237 "tt", 1238 // Trinidad & Tobago 1239 "1", 1240 22, 1241 ["868"] 1242 ], 1243 [ 1244 "tn", 1245 // Tunisia 1246 "216" 1247 ], 1248 [ 1249 "tr", 1250 // Turkey 1251 "90" 1252 ], 1253 [ 1254 "tm", 1255 // Turkmenistan 1256 "993" 1257 ], 1258 [ 1259 "tc", 1260 // Turks & Caicos Islands 1261 "1", 1262 23, 1263 ["649"] 1264 ], 1265 [ 1266 "tv", 1267 // Tuvalu 1268 "688" 1269 ], 1270 [ 1271 "ug", 1272 // Uganda 1273 "256" 1274 ], 1275 [ 1276 "ua", 1277 // Ukraine 1278 "380" 1279 ], 1280 [ 1281 "ae", 1282 // United Arab Emirates 1283 "971" 1284 ], 1285 [ 1286 "gb", 1287 // United Kingdom 1288 "44", 1289 0, 1290 null, 1291 "0" 1292 ], 1293 [ 1294 "us", 1295 // United States 1296 "1", 1297 0 1298 ], 1299 [ 1300 "uy", 1301 // Uruguay 1302 "598" 1303 ], 1304 [ 1305 "vi", 1306 // U.S. Virgin Islands 1307 "1", 1308 24, 1309 ["340"] 1310 ], 1311 [ 1312 "uz", 1313 // Uzbekistan 1314 "998" 1315 ], 1316 [ 1317 "vu", 1318 // Vanuatu 1319 "678" 1320 ], 1321 [ 1322 "va", 1323 // Vatican City 1324 "39", 1325 1, 1326 ["06698"] 1327 ], 1328 [ 1329 "ve", 1330 // Venezuela 1331 "58" 1332 ], 1333 [ 1334 "vn", 1335 // Vietnam 1336 "84" 1337 ], 1338 [ 1339 "wf", 1340 // Wallis & Futuna 1341 "681" 1342 ], 1343 [ 1344 "eh", 1345 // Western Sahara 1346 "212", 1347 1, 1348 ["5288", "5289"], 1349 "0" 1350 ], 1351 [ 1352 "ye", 1353 // Yemen 1354 "967" 1355 ], 1356 [ 1357 "zm", 1358 // Zambia 1359 "260" 1360 ], 1361 [ 1362 "zw", 1363 // Zimbabwe 1364 "263" 1365 ] 1366 ]; 1367 var allCountries = []; 1368 for (let i = 0; i < rawCountryData.length; i++) { 1369 const c = rawCountryData[i]; 1370 allCountries[i] = { 1371 name: "", 1372 // this is now populated in the plugin 1373 iso2: c[0], 1374 dialCode: c[1], 1375 priority: c[2] || 0, 1376 areaCodes: c[3] || null, 1377 nodeById: {}, 1378 nationalPrefix: c[4] || null 1379 }; 1380 } 1381 var data_default = allCountries; 1382 1383
1383// src/js/intl-tel-input/i18n/en/countries.ts 1384 var countryTranslations = { 1385 ad: "Andorra", 1386 ae: "United Arab Emirates", 1387 af: "Afghanistan", 1388 ag: "Antigua & Barbuda", 1389 ai: "Anguilla", 1390 al: "Albania", 1391 am: "Armenia", 1392 ao: "Angola", 1393 ar: "Argentina", 1394 as: "American Samoa", 1395 at: "Austria", 1396 au: "Australia", 1397 aw: "Aruba", 1398 ax: "\xC5land Islands", 1399 az: "Azerbaijan", 1400 ba: "Bosnia & Herzegovina", 1401 bb: "Barbados", 1402 bd: "Bangladesh", 1403 be: "Belgium", 1404 bf: "Burkina Faso", 1405 bg: "Bulgaria", 1406 bh: "Bahrain", 1407 bi: "Burundi", 1408 bj: "Benin", 1409 bl: "St. Barth\xE9lemy", 1410 bm: "Bermuda", 1411 bn: "Brunei", 1412 bo: "Bolivia", 1413 bq: "Caribbean Netherlands", 1414 br: "Brazil", 1415 bs: "Bahamas", 1416 bt: "Bhutan", 1417 bw: "Botswana", 1418 by: "Belarus", 1419 bz: "Belize", 1420 ca: "Canada", 1421 cc: "Cocos (Keeling) Islands", 1422 cd: "Congo - Kinshasa", 1423 cf: "Central African Republic", 1424 cg: "Congo - Brazzaville", 1425 ch: "Switzerland", 1426 ci: "C\xF4te d\u2019Ivoire", 1427 ck: "Cook Islands", 1428 cl: "Chile", 1429 cm: "Cameroon", 1430 cn: "China", 1431 co: "Colombia", 1432 cr: "Costa Rica", 1433 cu: "Cuba", 1434 cv: "Cape Verde", 1435 cw: "Cura\xE7ao", 1436 cx: "Christmas Island", 1437 cy: "Cyprus", 1438 cz: "Czechia", 1439 de: "Germany", 1440 dj: "Djibouti", 1441 dk: "Denmark", 1442 dm: "Dominica", 1443 do: "Dominican Republic", 1444 dz: "Algeria", 1445 ec: "Ecuador", 1446 ee: "Estonia", 1447 eg: "Egypt", 1448 eh: "Western Sahara", 1449 er: "Eritrea", 1450 es: "Spain", 1451 et: "Ethiopia", 1452 fi: "Finland", 1453 fj: "Fiji", 1454 fk: "Falkland Islands", 1455 fm: "Micronesia", 1456 fo: "Faroe Islands", 1457 fr: "France", 1458 ga: "Gabon", 1459 gb: "United Kingdom", 1460 gd: "Grenada", 1461 ge: "Georgia", 1462 gf: "French Guiana", 1463 gg: "Guernsey", 1464 gh: "Ghana", 1465 gi: "Gibraltar", 1466 gl: "Greenland", 1467 gm: "Gambia", 1468 gn: "Guinea", 1469 gp: "Guadeloupe", 1470 gq: "Equatorial Guinea", 1471 gr: "Greece", 1472 gt: "Guatemala", 1473 gu: "Guam", 1474 gw: "Guinea-Bissau", 1475 gy: "Guyana", 1476 hk: "Hong Kong SAR China", 1477 hn: "Honduras", 1478 hr: "Croatia", 1479 ht: "Haiti", 1480 hu: "Hungary", 1481 id: "Indonesia", 1482 ie: "Ireland", 1483 il: "Israel", 1484 im: "Isle of Man", 1485 in: "India", 1486 io: "British Indian Ocean Territory", 1487 iq: "Iraq", 1488 ir: "Iran", 1489 is: "Iceland", 1490 it: "Italy", 1491 je: "Jersey", 1492 jm: "Jamaica", 1493 jo: "Jordan", 1494 jp: "Japan", 1495 ke: "Kenya", 1496 kg: "Kyrgyzstan", 1497 kh: "Cambodia", 1498 ki: "Kiribati", 1499 km: "Comoros", 1500 kn: "St. Kitts & Nevis", 1501 kp: "North Korea", 1502 kr: "South Korea", 1503 kw: "Kuwait", 1504 ky: "Cayman Islands", 1505 kz: "Kazakhstan", 1506 la: "Laos", 1507 lb: "Lebanon", 1508 lc: "St. Lucia", 1509 li: "Liechtenstein", 1510 lk: "Sri Lanka", 1511 lr: "Liberia", 1512 ls: "Lesotho", 1513 lt: "Lithuania", 1514 lu: "Luxembourg", 1515 lv: "Latvia", 1516 ly: "Libya", 1517 ma: "Morocco", 1518 mc: "Monaco", 1519 md: "Moldova", 1520 me: "Montenegro", 1521 mf: "St. Martin", 1522 mg: "Madagascar", 1523 mh: "Marshall Islands", 1524 mk: "North Macedonia", 1525 ml: "Mali", 1526 mm: "Myanmar (Burma)", 1527 mn: "Mongolia", 1528 mo: "Macao SAR China", 1529 mp: "Northern Mariana Islands", 1530 mq: "Martinique", 1531 mr: "Mauritania", 1532 ms: "Montserrat", 1533 mt: "Malta", 1534 mu: "Mauritius", 1535 mv: "Maldives", 1536 mw: "Malawi", 1537 mx: "Mexico", 1538 my: "Malaysia", 1539 mz: "Mozambique", 1540 na: "Namibia", 1541 nc: "New Caledonia", 1542 ne: "Niger", 1543 nf: "Norfolk Island", 1544 ng: "Nigeria", 1545 ni: "Nicaragua", 1546 nl: "Netherlands", 1547 no: "Norway", 1548 np: "Nepal", 1549 nr: "Nauru", 1550 nu: "Niue", 1551 nz: "New Zealand", 1552 om: "Oman", 1553 pa: "Panama", 1554 pe: "Peru", 1555 pf: "French Polynesia", 1556 pg: "Papua New Guinea", 1557 ph: "Philippines", 1558 pk: "Pakistan", 1559 pl: "Poland", 1560 pm: "St. Pierre & Miquelon", 1561 pr: "Puerto Rico", 1562 ps: "Palestinian Territories", 1563 pt: "Portugal", 1564 pw: "Palau", 1565 py: "Paraguay", 1566 qa: "Qatar", 1567 re: "R\xE9union", 1568 ro: "Romania", 1569 rs: "Serbia", 1570 ru: "Russia", 1571 rw: "Rwanda", 1572 sa: "Saudi Arabia", 1573 sb: "Solomon Islands", 1574 sc: "Seychelles", 1575 sd: "Sudan",
1576 se: "Sweden", 1577 sg: "Singapore", 1578 sh: "St. Helena", 1579 si: "Slovenia", 1580 sj: "Svalbard & Jan Mayen", 1581 sk: "Slovakia", 1582 sl: "Sierra Leone", 1583 sm: "San Marino", 1584 sn: "Senegal", 1585 so: "Somalia", 1586 sr: "Suriname", 1587 ss: "South Sudan", 1588 st: "S\xE3o Tom\xE9 & Pr\xEDncipe", 1589 sv: "El Salvador", 1590 sx: "Sint Maarten", 1591 sy: "Syria", 1592 sz: "Eswatini", 1593 tc: "Turks & Caicos Islands", 1594 td: "Chad", 1595 tg: "Togo", 1596 th: "Thailand", 1597 tj: "Tajikistan", 1598 tk: "Tokelau", 1599 tl: "Timor-Leste", 1600 tm: "Turkmenistan", 1601 tn: "Tunisia", 1602 to: "Tonga", 1603 tr: "Turkey", 1604 tt: "Trinidad & Tobago", 1605 tv: "Tuvalu", 1606 tw: "Taiwan", 1607 tz: "Tanzania", 1608 ua: "Ukraine", 1609 ug: "Uganda", 1610 us: "United States", 1611 uy: "Uruguay", 1612 uz: "Uzbekistan", 1613 va: "Vatican City", 1614 vc: "St. Vincent & Grenadines", 1615 ve: "Venezuela", 1616 vg: "British Virgin Islands", 1617 vi: "U.S. Virgin Islands", 1618 vn: "Vietnam", 1619 vu: "Vanuatu", 1620 wf: "Wallis & Futuna", 1621 ws: "Samoa", 1622 ye: "Yemen", 1623 yt: "Mayotte", 1624 za: "South Africa", 1625 zm: "Zambia", 1626 zw: "Zimbabwe" 1627 }; 1628 var countries_default = countryTranslations; 1629 1630
1630// src/js/intl-tel-input/i18n/en/interface.ts 1631 var interfaceTranslations = { 1632 selectedCountryAriaLabel: "Selected country", 1633 noCountrySelected: "No country selected", 1634 countryListAriaLabel: "List of countries", 1635 searchPlaceholder: "Search", 1636 zeroSearchResults: "No results found", 1637 oneSearchResult: "1 result found", 1638 multipleSearchResults: "${count} results found", 1639 // additional countries (not supported by country-list library) 1640 ac: "Ascension Island", 1641 xk: "Kosovo" 1642 }; 1643 var interface_default = interfaceTranslations; 1644 1645
1645// src/js/intl-tel-input/i18n/en/index.ts 1646 var allTranslations = { ...countries_default, ...interface_default }; 1647 var en_default = allTranslations; 1648 1649
1649// src/js/intl-tel-input.ts 1650 for (let i = 0; i < data_default.length; i++) { 1651 data_default[i].name = en_default[data_default[i].iso2]; 1652 } 1653 var id = 0; 1654 var defaults = { 1655 //* Whether or not to allow the dropdown. 1656 allowDropdown: true, 1657 //* Add a placeholder in the input with an example number for the selected country. 1658 autoPlaceholder: "polite", 1659 //* Modify the parentClass. 1660 containerClass: "", 1661 //* The order of the countries in the dropdown. Defaults to alphabetical. 1662 countryOrder: null, 1663 //* Add a country search input at the top of the dropdown. 1664 countrySearch: true, 1665 //* Modify the auto placeholder. 1666 customPlaceholder: null, 1667 //* Append menu to specified element. 1668 dropdownContainer: null, 1669 //* Don't display these countries. 1670 excludeCountries: [], 1671 //* Fix the dropdown width to the input width (rather than being as wide as the longest country name). 1672 fixDropdownWidth: true, 1673 //* Format the number as the user types 1674 formatAsYouType: true, 1675 //* Format the input value during initialisation and on setNumber. 1676 formatOnDisplay: true, 1677 //* geoIp lookup function. 1678 geoIpLookup: null, 1679 //* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber. 1680 hiddenInput: null, 1681 //* Internationalise the plugin text e.g. search input placeholder, country names. 1682 i18n: {}, 1683 //* Initial country. 1684 initialCountry: "", 1685 //* A function to load the utils script. 1686 loadUtils: null, 1687 //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers. 1688 nationalMode: true, 1689 //* Display only these countries. 1690 onlyCountries: [], 1691 //* Number type to use for placeholders. 1692 placeholderNumberType: "MOBILE", 1693 //* Show flags - for both the selected country, and in the country dropdown 1694 showFlags: true, 1695 //* Display the international dial code next to the selected flag. 1696 separateDialCode: false, 1697 //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length. 1698 strictMode: false, 1699 //* Use full screen popup instead of dropdown for country list. 1700 useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? ( 1701 //* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions. 1702 //* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile' 1703 /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test( 1704 navigator.userAgent 1705 ) || window.innerWidth <= 500 1706 ) : false, 1707 //* The number type to enforce during validation. 1708 validationNumberTypes: ["MOBILE"] 1709 }; 1710 var regionlessNanpNumbers = [ 1711 "800", 1712 "822", 1713 "833", 1714 "844", 1715 "855", 1716 "866", 1717 "877", 1718 "880", 1719 "881", 1720 "882", 1721 "883", 1722 "884", 1723 "885", 1724 "886", 1725 "887", 1726 "888", 1727 "889" 1728 ]; 1729 var getNumeric = (s) => s.replace(/\D/g, ""); 1730 var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(); 1731 var isRegionlessNanp = (number) => { 1732 const numeric = getNumeric(number); 1733 if (numeric.charAt(0) === "1") { 1734 const areaCode = numeric.substr(1, 3); 1735 return regionlessNanpNumbers.includes(areaCode); 1736 } 1737 return false; 1738 }; 1739 var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => { 1740 if (prevCaretPos === 0 && !isDeleteForwards) { 1741 return 0; 1742 } 1743 let count = 0; 1744 for (let i = 0; i < formattedValue.length; i++) { 1745 if (/[+0-9]/.test(formattedValue[i])) { 1746 count++; 1747 } 1748 if (count === relevantChars && !isDeleteForwards) { 1749 return i + 1; 1750 } 1751 if (isDeleteForwards && count === relevantChars + 1) { 1752 return i; 1753 } 1754 } 1755 return formattedValue.length; 1756 }; 1757 var createEl = (name, attrs, container) => { 1758 const el = document.createElement(name); 1759 if (attrs) { 1760 Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value)); 1761 } 1762 if (container) { 1763 container.appendChild(el); 1764 } 1765 return el; 1766 };
1767 var forEachInstance = (method, ...args) => { 1768 const { instances } = intlTelInput; 1769 Object.values(instances).forEach((instance) => instance[method](...args)); 1770 }; 1771 var Iti = class { 1772 constructor(input, customOptions = {}) { 1773 this.id = id++; 1774 this.telInput = input; 1775 this.highlightedItem = null; 1776 this.options = Object.assign({}, defaults, customOptions); 1777 this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder")); 1778 } 1779 //* Can't be private as it's called from intlTelInput convenience wrapper. 1780 _init() { 1781 if (this.options.useFullscreenPopup) { 1782 this.options.fixDropdownWidth = false; 1783 } 1784 if (this.options.onlyCountries.length === 1) { 1785 this.options.initialCountry = this.options.onlyCountries[0]; 1786 } 1787 if (this.options.separateDialCode) { 1788 this.options.nationalMode = false; 1789 } 1790 if (this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode) { 1791 this.options.nationalMode = false; 1792 } 1793 if (this.options.useFullscreenPopup && !this.options.dropdownContainer) { 1794 this.options.dropdownContainer = document.body; 1795 } 1796 this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; 1797 this.isRTL = !!this.telInput.closest("[dir=rtl]"); 1798 const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; 1799 this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; 1800 if (this.options.separateDialCode) { 1801 if (this.isRTL) { 1802 this.originalPaddingRight = this.telInput.style.paddingRight; 1803 } else { 1804 this.originalPaddingLeft = this.telInput.style.paddingLeft; 1805 } 1806 } 1807 this.options.i18n = { ...en_default, ...this.options.i18n }; 1808 const autoCountryPromise = new Promise((resolve, reject) => { 1809 this.resolveAutoCountryPromise = resolve; 1810 this.rejectAutoCountryPromise = reject; 1811 }); 1812 const utilsScriptPromise = new Promise((resolve, reject) => { 1813 this.resolveUtilsScriptPromise = resolve; 1814 this.rejectUtilsScriptPromise = reject; 1815 }); 1816 this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]); 1817 this.selectedCountryData = {}; 1818 this._processCountryData(); 1819 this._generateMarkup(); 1820 this._setInitialState(); 1821 this._initListeners(); 1822 this._initRequests(); 1823 } 1824 //******************** 1825 //* PRIVATE METHODS 1826 //******************** 1827 //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options. 1828 _processCountryData() { 1829 this._processAllCountries(); 1830 this._processDialCodes(); 1831 this._translateCountryNames(); 1832 this._sortCountries(); 1833 } 1834 //* Sort countries by countryOrder option (if present), then name. 1835 _sortCountries() { 1836 if (this.options.countryOrder) { 1837 this.options.countryOrder = this.options.countryOrder.map((country) => country.toLowerCase()); 1838 } 1839 this.countries.sort((a, b) => { 1840 const { countryOrder } = this.options; 1841 if (countryOrder) { 1842 const aIndex = countryOrder.indexOf(a.iso2); 1843 const bIndex = countryOrder.indexOf(b.iso2); 1844 const aIndexExists = aIndex > -1; 1845 const bIndexExists = bIndex > -1; 1846 if (aIndexExists || bIndexExists) { 1847 if (aIndexExists && bIndexExists) { 1848 return aIndex - bIndex; 1849 } 1850 return aIndexExists ? -1 : 1; 1851 } 1852 } 1853 return a.name.localeCompare(b.name); 1854 }); 1855 } 1856 //* Add a dial code to this.dialCodeToIso2Map. 1857 _addToDialCodeMap(iso2, dialCode, priority) { 1858 if (dialCode.length > this.dialCodeMaxLen) { 1859 this.dialCodeMaxLen = dialCode.length; 1860 } 1861 if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) { 1862 this.dialCodeToIso2Map[dialCode] = []; 1863 } 1864 for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) { 1865 if (this.dialCodeToIso2Map[dialCode][i] === iso2) { 1866 return; 1867 } 1868 } 1869 const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length; 1870 this.dialCodeToIso2Map[dialCode][index] = iso2; 1871 } 1872 //* Process onlyCountries or excludeCountries array if present. 1873 _processAllCountries() { 1874 const { onlyCountries, excludeCountries } = this.options; 1875 if (onlyCountries.length) { 1876 const lowerCaseOnlyCountries = onlyCountries.map( 1877 (country) => country.toLowerCase() 1878 ); 1879 this.countries = data_default.filter( 1880 (country) => lowerCaseOnlyCountries.includes(country.iso2) 1881 ); 1882 } else if (excludeCountries.length) { 1883 const lowerCaseExcludeCountries = excludeCountries.map( 1884 (country) => country.toLowerCase() 1885 ); 1886 this.countries = data_default.filter( 1887 (country) => !lowerCaseExcludeCountries.includes(country.iso2) 1888 ); 1889 } else { 1890 this.countries = data_default; 1891 } 1892 } 1893 //* Translate Countries by object literal provided on config. 1894 _translateCountryNames() { 1895 for (let i = 0; i < this.countries.length; i++) { 1896 const iso2 = this.countries[i].iso2.toLowerCase(); 1897 if (this.options.i18n.hasOwnProperty(iso2)) { 1898 this.countries[i].name = this.options.i18n[iso2]; 1899 } 1900 } 1901 } 1902 //* Generate this.dialCodes and this.dialCodeToIso2Map. 1903 _processDialCodes() { 1904 this.dialCodes = {}; 1905 this.dialCodeMaxLen = 0; 1906 this.dialCodeToIso2Map = {}; 1907 for (let i = 0; i < this.countries.length; i++) { 1908 const c = this.countries[i]; 1909 if (!this.dialCodes[c.dialCode]) { 1910 this.dialCodes[c.dialCode] = true; 1911 } 1912 this._addToDialCodeMap(c.iso2, c.dialCode, c.priority); 1913 } 1914 for (let i = 0; i < this.countries.length; i++) { 1915 const c = this.countries[i]; 1916 if (c.areaCodes) { 1917 const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0]; 1918 for (let j = 0; j < c.areaCodes.length; j++) { 1919 const areaCode = c.areaCodes[j]; 1920 for (let k = 1; k < areaCode.length; k++) { 1921 const partialAreaCode = areaCode.substr(0, k); 1922 const partialDialCode = c.dialCode + partialAreaCode; 1923 this._addToDialCodeMap(rootIso2Code, partialDialCode); 1924 this._addToDialCodeMap(c.iso2, partialDialCode); 1925 } 1926 this._addToDialCodeMap(c.iso2, c.dialCode + areaCode); 1927 } 1928 } 1929 } 1930 } 1931 //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown. 1932 _generateMarkup() { 1933 this.telInput.classList.add("iti__tel-input"); 1934 if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) { 1935 this.telInput.setAttribute("autocomplete", "off"); 1936 } 1937 const { 1938 allowDropdown, 1939 separateDialCode, 1940 showFlags, 1941 containerClass, 1942 hiddenInput, 1943 dropdownContainer, 1944 fixDropdownWidth, 1945 useFullscreenPopup, 1946 countrySearch, 1947 i18n 1948 } = this.options; 1949 let parentClass = "iti"; 1950 if (allowDropdown) { 1951 parentClass += " iti--allow-dropdown"; 1952 } 1953 if (showFlags) { 1954 parentClass += " iti--show-flags"; 1955 } 1956 if (containerClass) { 1957 parentClass += ` ${containerClass}`; 1958 } 1959 if (!useFullscreenPopup) { 1960 parentClass += " iti--inline-dropdown"; 1961 } 1962 const wrapper = createEl("div", { class: parentClass }); 1963 this.telInput.parentNode?.insertBefore(wrapper, this.telInput); 1964 if (allowDropdown || showFlags || separateDialCode) { 1965 this.countryContainer = createEl( 1966 "div", 1967 { class: "iti__country-container" }, 1968 wrapper 1969 ); 1970 if (this.showSelectedCountryOnLeft) {
1971 this.countryContainer.style.left = "0px"; 1972 } else { 1973 this.countryContainer.style.right = "0px"; 1974 } 1975 if (allowDropdown) { 1976 this.selectedCountry = createEl( 1977 "button", 1978 { 1979 type: "button", 1980 class: "iti__selected-country", 1981 "aria-expanded": "false", 1982 "aria-label": this.options.i18n.selectedCountryAriaLabel, 1983 "aria-haspopup": "true", 1984 "aria-controls": `iti-${this.id}__dropdown-content`, 1985 "role": "combobox" 1986 }, 1987 this.countryContainer 1988 ); 1989 if (this.telInput.disabled) { 1990 this.selectedCountry.setAttribute("disabled", "true"); 1991 } 1992 } else { 1993 this.selectedCountry = createEl( 1994 "div", 1995 { class: "iti__selected-country" }, 1996 this.countryContainer 1997 ); 1998 } 1999 const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry); 2000 this.selectedCountryInner = createEl("div", { class: "iti__flag" }, selectedCountryPrimary); 2001 this.selectedCountryA11yText = createEl( 2002 "span", 2003 { class: "iti__a11y-text" }, 2004 this.selectedCountryInner 2005 ); 2006 if (allowDropdown) { 2007 this.dropdownArrow = createEl( 2008 "div", 2009 { class: "iti__arrow", "aria-hidden": "true" }, 2010 selectedCountryPrimary 2011 ); 2012 } 2013 if (separateDialCode) { 2014 this.selectedDialCode = createEl( 2015 "div", 2016 { class: "iti__selected-dial-code" }, 2017 this.selectedCountry 2018 ); 2019 } 2020 if (allowDropdown) { 2021 const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width"; 2022 this.dropdownContent = createEl("div", { 2023 id: `iti-${this.id}__dropdown-content`, 2024 class: `iti__dropdown-content iti__hide ${extraClasses}` 2025 }); 2026 if (countrySearch) { 2027 this.searchInput = createEl( 2028 "input", 2029 { 2030 type: "text", 2031 class: "iti__search-input", 2032 placeholder: i18n.searchPlaceholder, 2033 role: "combobox", 2034 "aria-expanded": "true", 2035 "aria-label": i18n.searchPlaceholder, 2036 "aria-controls": `iti-${this.id}__country-listbox`, 2037 "aria-autocomplete": "list", 2038 "autocomplete": "off" 2039 }, 2040 this.dropdownContent 2041 ); 2042 this.searchResultsA11yText = createEl( 2043 "span", 2044 { class: "iti__a11y-text" }, 2045 this.dropdownContent 2046 ); 2047 } 2048 this.countryList = createEl( 2049 "ul", 2050 { 2051 class: "iti__country-list", 2052 id: `iti-${this.id}__country-listbox`, 2053 role: "listbox", 2054 "aria-label": i18n.countryListAriaLabel 2055 }, 2056 this.dropdownContent 2057 ); 2058 this._appendListItems(); 2059 if (countrySearch) { 2060 this._updateSearchResultsText(); 2061 } 2062 if (dropdownContainer) { 2063 let dropdownClasses = "iti iti--container"; 2064 if (useFullscreenPopup) { 2065 dropdownClasses += " iti--fullscreen-popup"; 2066 } else { 2067 dropdownClasses += " iti--inline-dropdown"; 2068 } 2069 this.dropdown = createEl("div", { class: dropdownClasses }); 2070 this.dropdown.appendChild(this.dropdownContent); 2071 } else { 2072 this.countryContainer.appendChild(this.dropdownContent); 2073 } 2074 } 2075 } 2076 wrapper.appendChild(this.telInput); 2077 this._updateInputPadding(); 2078 if (hiddenInput) { 2079 const telInputName = this.telInput.getAttribute("name") || ""; 2080 const names = hiddenInput(telInputName); 2081 if (names.phone) { 2082 const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`); 2083 if (existingInput) { 2084 this.hiddenInput = existingInput; 2085 } else { 2086 this.hiddenInput = createEl("input", { 2087 type: "hidden", 2088 name: names.phone 2089 }); 2090 wrapper.appendChild(this.hiddenInput); 2091 } 2092 } 2093 if (names.country) { 2094 const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`); 2095 if (existingInput) { 2096 this.hiddenInputCountry = existingInput; 2097 } else { 2098 this.hiddenInputCountry = createEl("input", { 2099 type: "hidden", 2100 name: names.country 2101 }); 2102 wrapper.appendChild(this.hiddenInputCountry); 2103 } 2104 } 2105 } 2106 } 2107 //* For each country: add a country list item <li> to the countryList <ul> container. 2108 _appendListItems() { 2109 for (let i = 0; i < this.countries.length; i++) { 2110 const c = this.countries[i]; 2111 const extraClass = i === 0 ? "iti__highlight" : ""; 2112 const listItem = createEl( 2113 "li", 2114 { 2115 id: `iti-${this.id}__item-${c.iso2}`, 2116 class: `iti__country ${extraClass}`, 2117 tabindex: "-1", 2118 role: "option", 2119 "data-dial-code": c.dialCode, 2120 "data-country-code": c.iso2, 2121 "aria-selected": "false" 2122 }, 2123 this.countryList 2124 ); 2125 c.nodeById[this.id] = listItem; 2126 let content = ""; 2127 if (this.options.showFlags) { 2128 content += `<div class='iti__flag iti__${c.iso2}'></div>`; 2129 } 2130 content += `<span class='iti__country-name'>${c.name}</span>`;
2131 content += `<span class='iti__dial-code'>+${c.dialCode}</span>`; 2132 listItem.insertAdjacentHTML("beforeend", content); 2133 } 2134 } 2135 //* Set the initial state of the input value and the selected country by: 2136 //* 1. Extracting a dial code from the given number 2137 //* 2. Using explicit initialCountry 2138 _setInitialState(overrideAutoCountry = false) { 2139 const attributeValue = this.telInput.getAttribute("value"); 2140 const inputValue = this.telInput.value; 2141 const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+"); 2142 const val = useAttribute ? attributeValue : inputValue; 2143 const dialCode = this._getDialCode(val); 2144 const isRegionlessNanpNumber = isRegionlessNanp(val); 2145 const { initialCountry, geoIpLookup } = this.options; 2146 const isAutoCountry = initialCountry === "auto" && geoIpLookup; 2147 if (dialCode && !isRegionlessNanpNumber) { 2148 this._updateCountryFromNumber(val); 2149 } else if (!isAutoCountry || overrideAutoCountry) { 2150 const lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : ""; 2151 const isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true); 2152 if (isValidInitialCountry) { 2153 this._setCountry(lowerInitialCountry); 2154 } else { 2155 if (dialCode && isRegionlessNanpNumber) { 2156 this._setCountry("us"); 2157 } else { 2158 this._setCountry(); 2159 } 2160 } 2161 } 2162 if (val) { 2163 this._updateValFromNumber(val); 2164 } 2165 } 2166 //* Initialise the main event listeners: input keyup, and click selected country. 2167 _initListeners() { 2168 this._initTelInputListeners(); 2169 if (this.options.allowDropdown) { 2170 this._initDropdownListeners(); 2171 } 2172 if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) { 2173 this._initHiddenInputListener(); 2174 } 2175 } 2176 //* Update hidden input on form submit. 2177 _initHiddenInputListener() { 2178 this._handleHiddenInputSubmit = () => { 2179 if (this.hiddenInput) { 2180 this.hiddenInput.value = this.getNumber(); 2181 } 2182 if (this.hiddenInputCountry) { 2183 this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || ""; 2184 } 2185 }; 2186 this.telInput.form?.addEventListener( 2187 "submit", 2188 this._handleHiddenInputSubmit 2189 ); 2190 } 2191 //* initialise the dropdown listeners. 2192 _initDropdownListeners() { 2193 this._handleLabelClick = (e) => { 2194 if (this.dropdownContent.classList.contains("iti__hide")) { 2195 this.telInput.focus(); 2196 } else { 2197 e.preventDefault(); 2198 } 2199 }; 2200 const label = this.telInput.closest("label"); 2201 if (label) { 2202 label.addEventListener("click", this._handleLabelClick); 2203 } 2204 this._handleClickSelectedCountry = () => { 2205 if (this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly) { 2206 this._openDropdown(); 2207 } 2208 }; 2209 this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry); 2210 this._handleCountryContainerKeydown = (e) => { 2211 const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide"); 2212 if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) { 2213 e.preventDefault(); 2214 e.stopPropagation(); 2215 this._openDropdown(); 2216 } 2217 if (e.key === "Tab") { 2218 this._closeDropdown(); 2219 } 2220 }; 2221 this.countryContainer.addEventListener( 2222 "keydown", 2223 this._handleCountryContainerKeydown 2224 ); 2225 } 2226 //* Init many requests: utils script / geo ip lookup. 2227 _initRequests() { 2228 let { loadUtils, initialCountry, geoIpLookup } = this.options; 2229 if (loadUtils && !intlTelInput.utils) { 2230 this._handlePageLoad = () => { 2231 window.removeEventListener("load", this._handlePageLoad); 2232 intlTelInput.attachUtils(loadUtils)?.catch(() => { 2233 }); 2234 }; 2235 if (intlTelInput.documentReady()) { 2236 this._handlePageLoad(); 2237 } else { 2238 window.addEventListener("load", this._handlePageLoad); 2239 } 2240 } else { 2241 this.resolveUtilsScriptPromise(); 2242 } 2243 const isAutoCountry = initialCountry === "auto" && geoIpLookup; 2244 if (isAutoCountry && !this.selectedCountryData.iso2) { 2245 this._loadAutoCountry(); 2246 } else { 2247 this.resolveAutoCountryPromise(); 2248 } 2249 } 2250 //* Perform the geo ip lookup. 2251 _loadAutoCountry() { 2252 if (intlTelInput.autoCountry) { 2253 this.handleAutoCountry(); 2254 } else if (!intlTelInput.startedLoadingAutoCountry) { 2255 intlTelInput.startedLoadingAutoCountry = true; 2256 if (typeof this.options.geoIpLookup === "function") { 2257 this.options.geoIpLookup( 2258 (iso2 = "") => { 2259 const iso2Lower = iso2.toLowerCase(); 2260 const isValidIso2 = iso2Lower && this._getCountryData(iso2Lower, true); 2261 if (isValidIso2) { 2262 intlTelInput.autoCountry = iso2Lower; 2263 setTimeout(() => forEachInstance("handleAutoCountry")); 2264 } else { 2265 this._setInitialState(true);
2266 forEachInstance("rejectAutoCountryPromise"); 2267 } 2268 }, 2269 () => { 2270 this._setInitialState(true); 2271 forEachInstance("rejectAutoCountryPromise"); 2272 } 2273 ); 2274 } 2275 } 2276 } 2277 _openDropdownWithPlus() { 2278 this._openDropdown(); 2279 this.searchInput.value = "+"; 2280 this._filterCountries("", true); 2281 } 2282 //* Initialize the tel input listeners. 2283 _initTelInputListeners() { 2284 const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown, countrySearch } = this.options; 2285 let userOverrideFormatting = false; 2286 if (/\p{L}/u.test(this.telInput.value)) { 2287 userOverrideFormatting = true; 2288 } 2289 this._handleInputEvent = (e) => { 2290 if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) { 2291 const currentCaretPos = this.telInput.selectionStart || 0; 2292 const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); 2293 const valueAfterCaret = this.telInput.value.substring(currentCaretPos); 2294 this.telInput.value = valueBeforeCaret + valueAfterCaret; 2295 this._openDropdownWithPlus(); 2296 return; 2297 } 2298 if (this._updateCountryFromNumber(this.telInput.value)) { 2299 this._triggerCountryChange(); 2300 } 2301 const isFormattingChar = e?.data && /[^+0-9]/.test(e.data); 2302 const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value; 2303 if (isFormattingChar || isPaste && !strictMode) { 2304 userOverrideFormatting = true; 2305 } else if (!/[^+0-9]/.test(this.telInput.value)) { 2306 userOverrideFormatting = false; 2307 } 2308 const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay; 2309 if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) { 2310 const currentCaretPos = this.telInput.selectionStart || 0; 2311 const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos); 2312 const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length; 2313 const isDeleteForwards = e?.inputType === "deleteContentForward"; 2314 const formattedValue = this._formatNumberAsYouType(); 2315 const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards); 2316 this.telInput.value = formattedValue; 2317 this.telInput.setSelectionRange(newCaretPos, newCaretPos); 2318 } 2319 }; 2320 this.telInput.addEventListener("input", this._handleInputEvent); 2321 if (strictMode || separateDialCode) { 2322 this._handleKeydownEvent = (e) => { 2323 if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { 2324 if (separateDialCode && allowDropdown && countrySearch && e.key === "+") { 2325 e.preventDefault(); 2326 this._openDropdownWithPlus(); 2327 return; 2328 } 2329 if (strictMode) { 2330 const value = this.telInput.value; 2331 const alreadyHasPlus = value.charAt(0) === "+"; 2332 const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+"; 2333 const isNumeric = /^[0-9]$/.test(e.key); 2334 const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; 2335 const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd); 2336 const newFullNumber = this._getFullNumber(newValue); 2337 const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2); 2338 const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength; 2339 let isChangingDialCode = false; 2340 if (alreadyHasPlus) { 2341 const currentCountry = this.selectedCountryData.iso2; 2342 const newCountry = this._getCountryFromNumber(newFullNumber); 2343 isChangingDialCode = newCountry !== currentCountry; 2344 } 2345 if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) { 2346 e.preventDefault(); 2347 } 2348 } 2349 } 2350 }; 2351 this.telInput.addEventListener("keydown", this._handleKeydownEvent); 2352 } 2353 } 2354 //* Adhere to the input's maxlength attr. 2355 _cap(number) { 2356 const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10); 2357 return max && number.length > max ? number.substr(0, max) : number; 2358 } 2359 //* Trigger a custom event on the input. 2360 _trigger(name, detailProps = {}) { 2361 const e = new CustomEvent(name, { 2362 bubbles: true, 2363 cancelable: true, 2364 detail: detailProps 2365 }); 2366 this.telInput.dispatchEvent(e); 2367 } 2368 //* Open the dropdown. 2369 _openDropdown() { 2370 const { fixDropdownWidth, countrySearch } = this.options; 2371 if (fixDropdownWidth) { 2372 this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`; 2373 } 2374 this.dropdownContent.classList.remove("iti__hide"); 2375 this.selectedCountry.setAttribute("aria-expanded", "true"); 2376 this._setDropdownPosition(); 2377 if (countrySearch) { 2378 const firstCountryItem = this.countryList.firstElementChild; 2379 if (firstCountryItem) { 2380 this._highlightListItem(firstCountryItem, false); 2381 this.countryList.scrollTop = 0; 2382 } 2383 this.searchInput.focus(); 2384 } 2385 this._bindDropdownListeners(); 2386 this.dropdownArrow.classList.add("iti__arrow--up"); 2387 this._trigger("open:countrydropdown"); 2388 } 2389 //* Set the dropdown position 2390 _setDropdownPosition() { 2391 if (this.options.dropdownContainer) { 2392 this.options.dropdownContainer.appendChild(this.dropdown); 2393 } 2394 if (!this.options.useFullscreenPopup) { 2395 const inputPosRelativeToVP = this.telInput.getBoundingClientRect(); 2396 const inputHeight = this.telInput.offsetHeight; 2397 if (this.options.dropdownContainer) { 2398 this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`; 2399 this.dropdown.style.left = `${inputPosRelativeToVP.left}px`; 2400 this._handleWindowScroll = () => this._closeDropdown(); 2401 window.addEventListener("scroll", this._handleWindowScroll); 2402 } 2403 } 2404 } 2405 //* We only bind dropdown listeners when the dropdown is open. 2406 _bindDropdownListeners() { 2407 this._handleMouseoverCountryList = (e) => { 2408 const listItem = e.target?.closest(".iti__country"); 2409 if (listItem) { 2410 this._highlightListItem(listItem, false); 2411 } 2412 }; 2413 this.countryList.addEventListener( 2414 "mouseover", 2415 this._handleMouseoverCountryList 2416 ); 2417 this._handleClickCountryList = (e) => { 2418 const listItem = e.target?.closest(".iti__country"); 2419 if (listItem) { 2420 this._selectListItem(listItem); 2421 } 2422 }; 2423 this.countryList.addEventListener("click", this._handleClickCountryList); 2424 let isOpening = true; 2425 this._handleClickOffToClose = () => { 2426 if (!isOpening) { 2427 this._closeDropdown(); 2428 } 2429 isOpening = false;
2430 }; 2431 document.documentElement.addEventListener( 2432 "click", 2433 this._handleClickOffToClose 2434 ); 2435 let query = ""; 2436 let queryTimer = null; 2437 this._handleKeydownOnDropdown = (e) => { 2438 if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) { 2439 e.preventDefault(); 2440 e.stopPropagation(); 2441 if (e.key === "ArrowUp" || e.key === "ArrowDown") { 2442 this._handleUpDownKey(e.key); 2443 } else if (e.key === "Enter") { 2444 this._handleEnterKey(); 2445 } else if (e.key === "Escape") { 2446 this._closeDropdown(); 2447 } 2448 } 2449 if (!this.options.countrySearch && /^[a-zA-ZÃ-ÿа-ÑÐ-Я ]$/.test(e.key)) { 2450 e.stopPropagation(); 2451 if (queryTimer) { 2452 clearTimeout(queryTimer); 2453 } 2454 query += e.key.toLowerCase(); 2455 this._searchForCountry(query); 2456 queryTimer = setTimeout(() => { 2457 query = ""; 2458 }, 1e3); 2459 } 2460 }; 2461 document.addEventListener("keydown", this._handleKeydownOnDropdown); 2462 if (this.options.countrySearch) { 2463 const doFilter = () => { 2464 const inputQuery = this.searchInput.value.trim(); 2465 if (inputQuery) { 2466 this._filterCountries(inputQuery); 2467 } else { 2468 this._filterCountries("", true); 2469 } 2470 }; 2471 let keyupTimer = null; 2472 this._handleSearchChange = () => { 2473 if (keyupTimer) { 2474 clearTimeout(keyupTimer); 2475 } 2476 keyupTimer = setTimeout(() => { 2477 doFilter(); 2478 keyupTimer = null; 2479 }, 100); 2480 }; 2481 this.searchInput.addEventListener("input", this._handleSearchChange); 2482 this.searchInput.addEventListener("click", (e) => e.stopPropagation()); 2483 } 2484 } 2485 //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string. 2486 _searchForCountry(query) { 2487 for (let i = 0; i < this.countries.length; i++) { 2488 const c = this.countries[i]; 2489 const startsWith = c.name.substr(0, query.length).toLowerCase() === query; 2490 if (startsWith) { 2491 const listItem = c.nodeById[this.id]; 2492 this._highlightListItem(listItem, false); 2493 this._scrollTo(listItem); 2494 break; 2495 } 2496 } 2497 } 2498 //* Country search enabled: Filter the countries according to the search query. 2499 _filterCountries(query, isReset = false) { 2500 let noCountriesAddedYet = true; 2501 this.countryList.innerHTML = ""; 2502 const normalisedQuery = normaliseString(query); 2503 for (let i = 0; i < this.countries.length; i++) { 2504 const c = this.countries[i]; 2505 const normalisedCountryName = normaliseString(c.name); 2506 const countryInitials = c.name.split(/[^a-zA-ZÃ-ÿа-ÑÐ-Я]/).map((word) => word[0]).join("").toLowerCase(); 2507 const fullDialCode = `+${c.dialCode}`; 2508 if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) { 2509 const listItem = c.nodeById[this.id]; 2510 if (listItem) { 2511 this.countryList.appendChild(listItem); 2512 } 2513 if (noCountriesAddedYet) { 2514 this._highlightListItem(listItem, false); 2515 noCountriesAddedYet = false;
2516 } 2517 } 2518 } 2519 if (noCountriesAddedYet) { 2520 this._highlightListItem(null, false); 2521 } 2522 this.countryList.scrollTop = 0; 2523 this._updateSearchResultsText(); 2524 } 2525 //* Update search results text (for a11y). 2526 _updateSearchResultsText() { 2527 const { i18n } = this.options; 2528 const count = this.countryList.childElementCount; 2529 let searchText; 2530 if (count === 0) { 2531 searchText = i18n.zeroSearchResults; 2532 } else if (count === 1) { 2533 searchText = i18n.oneSearchResult; 2534 } else { 2535 searchText = i18n.multipleSearchResults.replace("${count}", count.toString()); 2536 } 2537 this.searchResultsA11yText.textContent = searchText; 2538 } 2539 //* Highlight the next/prev item in the list (and ensure it is visible). 2540 _handleUpDownKey(key) { 2541 let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling; 2542 if (!next && this.countryList.childElementCount > 1) { 2543 next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild; 2544 } 2545 if (next) { 2546 this._scrollTo(next); 2547 this._highlightListItem(next, false); 2548 } 2549 } 2550 //* Select the currently highlighted item. 2551 _handleEnterKey() { 2552 if (this.highlightedItem) { 2553 this._selectListItem(this.highlightedItem); 2554 } 2555 } 2556 //* Update the input's value to the given val (format first if possible) 2557 //* NOTE: this is called from _setInitialState, handleUtils and setNumber. 2558 _updateValFromNumber(fullNumber) { 2559 let number = fullNumber; 2560 if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) { 2561 const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode; 2562 const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat; 2563 const format = useNational ? NATIONAL : INTERNATIONAL; 2564 number = intlTelInput.utils.formatNumber( 2565 number, 2566 this.selectedCountryData.iso2, 2567 format 2568 ); 2569 } 2570 number = this._beforeSetNumber(number); 2571 this.telInput.value = number; 2572 } 2573 //* Check if need to select a new country based on the given number 2574 //* Note: called from _setInitialState, keyup handler, setNumber. 2575 _updateCountryFromNumber(fullNumber) { 2576 const iso2 = this._getCountryFromNumber(fullNumber); 2577 if (iso2 !== null) { 2578 return this._setCountry(iso2); 2579 } 2580 return false; 2581 } 2582 _ensureHasDialCode(number) { 2583 const { dialCode, nationalPrefix } = this.selectedCountryData; 2584 const alreadyHasPlus = number.charAt(0) === "+"; 2585 if (alreadyHasPlus || !dialCode) { 2586 return number; 2587 } 2588 const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode; 2589 const cleanNumber = hasPrefix ? number.substring(1) : number; 2590 return `+${dialCode}${cleanNumber}`; 2591 } 2592 _getCountryFromNumber(fullNumber) { 2593 const plusIndex = fullNumber.indexOf("+"); 2594 let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber; 2595 const selectedIso2 = this.selectedCountryData.iso2; 2596 const selectedDialCode = this.selectedCountryData.dialCode; 2597 number = this._ensureHasDialCode(number); 2598 const dialCodeMatch = this._getDialCode(number, true); 2599 const numeric = getNumeric(number); 2600 if (dialCodeMatch) { 2601 const dialCodeMatchNumeric = getNumeric(dialCodeMatch); 2602 const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric]; 2603 if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) { 2604 return this.defaultCountry; 2605 } 2606 const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes); 2607 const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric); 2608 if (!isRegionlessNanpNumber && !alreadySelected) { 2609 for (let j = 0; j < iso2Codes.length; j++) { 2610 if (iso2Codes[j]) { 2611 return iso2Codes[j]; 2612 } 2613 } 2614 } 2615 } else if (number.charAt(0) === "+" && numeric.length) { 2616 return ""; 2617 } else if ((!number || number === "+") && !this.selectedCountryData.iso2) { 2618 return this.defaultCountry; 2619 } 2620 return null; 2621 } 2622 //* Remove highlighting from other list items and highlight the given item. 2623 _highlightListItem(listItem, shouldFocus) { 2624 const prevItem = this.highlightedItem; 2625 if (prevItem) { 2626 prevItem.classList.remove("iti__highlight"); 2627 prevItem.setAttribute("aria-selected", "false"); 2628 } 2629 this.highlightedItem = listItem; 2630 if (this.highlightedItem) { 2631 this.highlightedItem.classList.add("iti__highlight"); 2632 this.highlightedItem.setAttribute("aria-selected", "true"); 2633 const activeDescendant = this.highlightedItem.getAttribute("id") || ""; 2634 this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant); 2635 if (this.options.countrySearch) { 2636 this.searchInput.setAttribute("aria-activedescendant", activeDescendant); 2637 } 2638 } 2639 if (shouldFocus) { 2640 this.highlightedItem.focus(); 2641 } 2642 } 2643 //* Find the country data for the given iso2 code 2644 //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2645 _getCountryData(iso2, allowFail) { 2646 for (let i = 0; i < this.countries.length; i++) { 2647 if (this.countries[i].iso2 === iso2) { 2648 return this.countries[i]; 2649 } 2650 } 2651 if (allowFail) { 2652 return null; 2653 } 2654 throw new Error(`No country data for '${iso2}'`); 2655 } 2656 //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item. 2657 //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry. 2658 _setCountry(iso2) { 2659 const { separateDialCode, showFlags, i18n } = this.options; 2660 const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {}; 2661 this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {}; 2662 if (this.selectedCountryData.iso2) { 2663 this.defaultCountry = this.selectedCountryData.iso2; 2664 } 2665 if (this.selectedCountryInner) { 2666 let flagClass = ""; 2667 let a11yText = ""; 2668 if (iso2 && showFlags) { 2669 flagClass = `iti__flag iti__${iso2}`; 2670 a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`; 2671 } else { 2672 flagClass = "iti__flag iti__globe"; 2673 a11yText = i18n.noCountrySelected; 2674 } 2675 this.selectedCountryInner.className = flagClass; 2676 this.selectedCountryA11yText.textContent = a11yText; 2677 } 2678 this._setSelectedCountryTitleAttribute(iso2, separateDialCode); 2679 if (separateDialCode) { 2680 const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : ""; 2681 this.selectedDialCode.innerHTML = dialCode; 2682 this._updateInputPadding(); 2683 } 2684 this._updatePlaceholder(); 2685 this._updateMaxLength(); 2686 return prevCountry.iso2 !== iso2; 2687 } 2688 //* Update the input padding to make space for the selected country/dial code. 2689 _updateInputPadding() { 2690 if (this.selectedCountry) { 2691 const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth(); 2692 const inputPadding = selectedCountryWidth + 6; 2693 if (this.showSelectedCountryOnLeft) { 2694 this.telInput.style.paddingLeft = `${inputPadding}px`; 2695 } else { 2696 this.telInput.style.paddingRight = `${inputPadding}px`; 2697 } 2698 } 2699 } 2700 //* Update the maximum valid number length for the currently selected country. 2701 _updateMaxLength() { 2702 const { strictMode, placeholderNumberType, validationNumberTypes } = this.options; 2703 const { iso2 } = this.selectedCountryData; 2704 if (strictMode && intlTelInput.utils) { 2705 if (iso2) { 2706 const numberType = intlTelInput.utils.numberType[placeholderNumberType]; 2707 let exampleNumber = intlTelInput.utils.getExampleNumber( 2708 iso2, 2709 false, 2710 numberType, 2711 true 2712 ); 2713 let validNumber = exampleNumber; 2714 while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) { 2715 validNumber = exampleNumber; 2716 exampleNumber += "0"; 2717 } 2718 const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2); 2719 this.maxCoreNumberLength = coreNumber.length; 2720 if (iso2 === "by") { 2721 this.maxCoreNumberLength = coreNumber.length + 1; 2722 } 2723 } else { 2724 this.maxCoreNumberLength = null; 2725 } 2726 } 2727 } 2728 _setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) { 2729 if (!this.selectedCountry) { 2730 return; 2731 } 2732 let title; 2733 if (iso2 && !separateDialCode) { 2734 title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`; 2735 } else if (iso2) { 2736 title = this.selectedCountryData.name; 2737 } else { 2738 title = "Unknown"; 2739 } 2740 this.selectedCountry.setAttribute("title", title); 2741 } 2742 //* When the input is in a hidden container during initialisation, we must inject some markup 2743 //* into the end of the DOM to calculate the correct offsetWidth. 2744 //* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry 2745 //* will definitely exist. 2746 _getHiddenSelectedCountryWidth() { 2747 if (this.telInput.parentNode) { 2748 const containerClone = this.telInput.parentNode.cloneNode(false); 2749 containerClone.style.visibility = "hidden"; 2750 document.body.appendChild(containerClone); 2751 const countryContainerClone = this.countryContainer.cloneNode(); 2752 containerClone.appendChild(countryContainerClone); 2753 const selectedCountryClone = this.selectedCountry.cloneNode(true); 2754 countryContainerClone.appendChild(selectedCountryClone); 2755 const width = selectedCountryClone.offsetWidth; 2756 document.body.removeChild(containerClone); 2757 return width; 2758 } 2759 return 0; 2760 } 2761 //* Update the input placeholder to an example number from the currently selected country. 2762 _updatePlaceholder() { 2763 const { 2764 autoPlaceholder, 2765 placeholderNumberType, 2766 nationalMode, 2767 customPlaceholder 2768 } = this.options; 2769 const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite"; 2770 if (intlTelInput.utils && shouldSetPlaceholder) { 2771 const numberType = intlTelInput.utils.numberType[placeholderNumberType]; 2772 let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber( 2773 this.selectedCountryData.iso2, 2774 nationalMode, 2775 numberType 2776 ) : ""; 2777 placeholder = this._beforeSetNumber(placeholder); 2778 if (typeof customPlaceholder === "function") { 2779 placeholder = customPlaceholder(placeholder, this.selectedCountryData); 2780 } 2781 this.telInput.setAttribute("placeholder", placeholder); 2782 } 2783 } 2784 //* Called when the user selects a list item from the dropdown. 2785 _selectListItem(listItem) { 2786 const countryChanged = this._setCountry( 2787 listItem.getAttribute("data-country-code") 2788 ); 2789 this._closeDropdown(); 2790 this._updateDialCode(listItem.getAttribute("data-dial-code")); 2791 this.telInput.focus(); 2792 if (countryChanged) { 2793 this._triggerCountryChange(); 2794 } 2795 } 2796 //* Close the dropdown and unbind any listeners. 2797 _closeDropdown() { 2798 this.dropdownContent.classList.add("iti__hide"); 2799 this.selectedCountry.setAttribute("aria-expanded", "false"); 2800 this.selectedCountry.removeAttribute("aria-activedescendant"); 2801 if (this.highlightedItem) { 2802 this.highlightedItem.setAttribute("aria-selected", "false"); 2803 } 2804 if (this.options.countrySearch) { 2805 this.searchInput.removeAttribute("aria-activedescendant"); 2806 } 2807 this.dropdownArrow.classList.remove("iti__arrow--up"); 2808 document.removeEventListener("keydown", this._handleKeydownOnDropdown); 2809 if (this.options.countrySearch) { 2810 this.searchInput.removeEventListener("input", this._handleSearchChange); 2811 } 2812 document.documentElement.removeEventListener( 2813 "click", 2814 this._handleClickOffToClose 2815 ); 2816 this.countryList.removeEventListener( 2817 "mouseover", 2818 this._handleMouseoverCountryList 2819 ); 2820 this.countryList.removeEventListener("click", this._handleClickCountryList); 2821 if (this.options.dropdownContainer) { 2822 if (!this.options.useFullscreenPopup) { 2823 window.removeEventListener("scroll", this._handleWindowScroll); 2824 } 2825 if (this.dropdown.parentNode) { 2826 this.dropdown.parentNode.removeChild(this.dropdown); 2827 } 2828 } 2829 if (this._handlePageLoad) { 2830 window.removeEventListener("load", this._handlePageLoad); 2831 } 2832 this._trigger("close:countrydropdown"); 2833 } 2834 //* Check if an element is visible within it's container, else scroll until it is. 2835 _scrollTo(element) { 2836 const container = this.countryList; 2837 const scrollTop = document.documentElement.scrollTop; 2838 const containerHeight = container.offsetHeight; 2839 const containerTop = container.getBoundingClientRect().top + scrollTop; 2840 const containerBottom = containerTop + containerHeight; 2841 const elementHeight = element.offsetHeight; 2842 const elementTop = element.getBoundingClientRect().top + scrollTop; 2843 const elementBottom = elementTop + elementHeight; 2844 const newScrollTop = elementTop - containerTop + container.scrollTop;
2845 if (elementTop < containerTop) { 2846 container.scrollTop = newScrollTop; 2847 } else if (elementBottom > containerBottom) { 2848 const heightDifference = containerHeight - elementHeight; 2849 container.scrollTop = newScrollTop - heightDifference; 2850 } 2851 } 2852 //* Replace any existing dial code with the new one 2853 //* Note: called from _selectListItem and setCountry 2854 _updateDialCode(newDialCodeBare) { 2855 const inputVal = this.telInput.value; 2856 const newDialCode = `+${newDialCodeBare}`; 2857 let newNumber; 2858 if (inputVal.charAt(0) === "+") { 2859 const prevDialCode = this._getDialCode(inputVal); 2860 if (prevDialCode) { 2861 newNumber = inputVal.replace(prevDialCode, newDialCode); 2862 } else { 2863 newNumber = newDialCode; 2864 } 2865 this.telInput.value = newNumber; 2866 } 2867 } 2868 //* Try and extract a valid international dial code from a full telephone number. 2869 //* Note: returns the raw string inc plus character and any whitespace/dots etc. 2870 _getDialCode(number, includeAreaCode) { 2871 let dialCode = ""; 2872 if (number.charAt(0) === "+") { 2873 let numericChars = ""; 2874 for (let i = 0; i < number.length; i++) { 2875 const c = number.charAt(i); 2876 if (!isNaN(parseInt(c, 10))) { 2877 numericChars += c; 2878 if (includeAreaCode) { 2879 if (this.dialCodeToIso2Map[numericChars]) { 2880 dialCode = number.substr(0, i + 1); 2881 } 2882 } else { 2883 if (this.dialCodes[numericChars]) { 2884 dialCode = number.substr(0, i + 1); 2885 break; 2886 } 2887 } 2888 if (numericChars.length === this.dialCodeMaxLen) { 2889 break; 2890 } 2891 } 2892 } 2893 } 2894 return dialCode; 2895 } 2896 //* Get the input val, adding the dial code if separateDialCode is enabled. 2897 _getFullNumber(overrideVal) { 2898 const val = overrideVal || this.telInput.value.trim(); 2899 const { dialCode } = this.selectedCountryData; 2900 let prefix; 2901 const numericVal = getNumeric(val); 2902 if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) { 2903 prefix = `+${dialCode}`; 2904 } else { 2905 prefix = ""; 2906 } 2907 return prefix + val; 2908 } 2909 //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute 2910 _beforeSetNumber(fullNumber) { 2911 let number = fullNumber; 2912 if (this.options.separateDialCode) { 2913 let dialCode = this._getDialCode(number); 2914 if (dialCode) { 2915 dialCode = `+${this.selectedCountryData.dialCode}`; 2916 const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length; 2917 number = number.substr(start); 2918 } 2919 } 2920 return this._cap(number); 2921 } 2922 //* Trigger the 'countrychange' event. 2923 _triggerCountryChange() { 2924 this._trigger("countrychange"); 2925 } 2926 //* Format the number as the user types. 2927 _formatNumberAsYouType() { 2928 const val = this._getFullNumber(); 2929 const result = intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val; 2930 const { dialCode } = this.selectedCountryData; 2931 if (this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && result.includes(`+${dialCode}`)) { 2932 const afterDialCode = result.split(`+${dialCode}`)[1] || ""; 2933 return afterDialCode.trim(); 2934 } 2935 return result; 2936 } 2937 //************************** 2938 //* SECRET PUBLIC METHODS 2939 //************************** 2940 //* This is called when the geoip call returns. 2941 handleAutoCountry() { 2942 if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) { 2943 this.defaultCountry = intlTelInput.autoCountry; 2944 const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe"); 2945 if (!hasSelectedCountryOrGlobe) { 2946 this.setCountry(this.defaultCountry); 2947 } 2948 this.resolveAutoCountryPromise(); 2949 } 2950 } 2951 //* This is called when the utils request completes. 2952 handleUtils() { 2953 if (intlTelInput.utils) { 2954 if (this.telInput.value) {
2955 this._updateValFromNumber(this.telInput.value); 2956 } 2957 if (this.selectedCountryData.iso2) { 2958 this._updatePlaceholder(); 2959 this._updateMaxLength(); 2960 } 2961 } 2962 this.resolveUtilsScriptPromise(); 2963 } 2964 //******************** 2965 //* PUBLIC METHODS 2966 //******************** 2967 //* Remove plugin. 2968 destroy() { 2969 const { allowDropdown, separateDialCode } = this.options; 2970 if (allowDropdown) { 2971 this._closeDropdown(); 2972 this.selectedCountry.removeEventListener( 2973 "click", 2974 this._handleClickSelectedCountry 2975 ); 2976 this.countryContainer.removeEventListener( 2977 "keydown", 2978 this._handleCountryContainerKeydown 2979 ); 2980 const label = this.telInput.closest("label"); 2981 if (label) { 2982 label.removeEventListener("click", this._handleLabelClick); 2983 } 2984 } 2985 const { form } = this.telInput; 2986 if (this._handleHiddenInputSubmit && form) { 2987 form.removeEventListener("submit", this._handleHiddenInputSubmit); 2988 } 2989 this.telInput.removeEventListener("input", this._handleInputEvent); 2990 if (this._handleKeydownEvent) { 2991 this.telInput.removeEventListener("keydown", this._handleKeydownEvent); 2992 } 2993 this.telInput.removeAttribute("data-intl-tel-input-id"); 2994 if (separateDialCode) { 2995 if (this.isRTL) { 2996 this.telInput.style.paddingRight = this.originalPaddingRight; 2997 } else { 2998 this.telInput.style.paddingLeft = this.originalPaddingLeft; 2999 } 3000 } 3001 const wrapper = this.telInput.parentNode; 3002 wrapper?.parentNode?.insertBefore(this.telInput, wrapper); 3003 wrapper?.parentNode?.removeChild(wrapper); 3004 delete intlTelInput.instances[this.id]; 3005 } 3006 //* Get the extension from the current number. 3007 getExtension() { 3008 if (intlTelInput.utils) { 3009 return intlTelInput.utils.getExtension( 3010 this._getFullNumber(), 3011 this.selectedCountryData.iso2 3012 ); 3013 } 3014 return ""; 3015 } 3016 //* Format the number to the given format. 3017 getNumber(format) { 3018 if (intlTelInput.utils) { 3019 const { iso2 } = this.selectedCountryData; 3020 return intlTelInput.utils.formatNumber( 3021 this._getFullNumber(), 3022 iso2, 3023 format 3024 ); 3025 } 3026 return ""; 3027 } 3028 //* Get the type of the entered number e.g. landline/mobile. 3029 getNumberType() { 3030 if (intlTelInput.utils) { 3031 return intlTelInput.utils.getNumberType( 3032 this._getFullNumber(), 3033 this.selectedCountryData.iso2 3034 ); 3035 } 3036 return -99; 3037 } 3038 //* Get the country data for the currently selected country. 3039 getSelectedCountryData() { 3040 return this.selectedCountryData; 3041 } 3042 //* Get the validation error. 3043 getValidationError() { 3044 if (intlTelInput.utils) { 3045 const { iso2 } = this.selectedCountryData; 3046 return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2); 3047 } 3048 return -99; 3049 } 3050 //* Validate the input val 3051 isValidNumber() { 3052 if (!this.selectedCountryData.iso2) { 3053 return false; 3054 } 3055 const val = this._getFullNumber(); 3056 const alphaCharPosition = val.search(/\p{L}/u); 3057 if (alphaCharPosition > -1) { 3058 const beforeAlphaChar = val.substring(0, alphaCharPosition); 3059 const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar); 3060 const isValid = this._utilsIsPossibleNumber(val); 3061 return beforeAlphaIsValid && isValid; 3062 } 3063 return this._utilsIsPossibleNumber(val); 3064 } 3065 _utilsIsPossibleNumber(val) { 3066 return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null; 3067 } 3068 //* Validate the input val (precise) 3069 isValidNumberPrecise() { 3070 if (!this.selectedCountryData.iso2) { 3071 return false; 3072 } 3073 const val = this._getFullNumber(); 3074 const alphaCharPosition = val.search(/\p{L}/u); 3075 if (alphaCharPosition > -1) { 3076 const beforeAlphaChar = val.substring(0, alphaCharPosition); 3077 const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar); 3078 const isValid = this._utilsIsValidNumber(val); 3079 return beforeAlphaIsValid && isValid; 3080 } 3081 return this._utilsIsValidNumber(val); 3082 } 3083 _utilsIsValidNumber(val) { 3084 return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null; 3085 } 3086 //* Update the selected country, and update the input val accordingly. 3087 setCountry(iso2) { 3088 const iso2Lower = iso2?.toLowerCase(); 3089 const currentCountry = this.selectedCountryData.iso2; 3090 const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry; 3091 if (isCountryChange) { 3092 this._setCountry(iso2Lower); 3093 this._updateDialCode(this.selectedCountryData.dialCode); 3094 this._triggerCountryChange(); 3095 } 3096 } 3097 //* Set the input value and update the country. 3098 setNumber(number) { 3099 const countryChanged = this._updateCountryFromNumber(number);
3100 this._updateValFromNumber(number); 3101 if (countryChanged) { 3102 this._triggerCountryChange(); 3103 } 3104 this._trigger("input", { isSetNumber: true }); 3105 } 3106 //* Set the placeholder number typ 3107 setPlaceholderNumberType(type) { 3108 this.options.placeholderNumberType = type; 3109 this._updatePlaceholder(); 3110 } 3111 setDisabled(disabled) { 3112 this.telInput.disabled = disabled; 3113 if (disabled) { 3114 this.selectedCountry.setAttribute("disabled", "true"); 3115 } else { 3116 this.selectedCountry.removeAttribute("disabled"); 3117 } 3118 } 3119 }; 3120 var attachUtils = (source) => { 3121 if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) { 3122 let loadCall; 3123 if (typeof source === "function") { 3124 try { 3125 loadCall = Promise.resolve(source()); 3126 } catch (error) { 3127 return Promise.reject(error); 3128 } 3129 } else { 3130 return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`)); 3131 } 3132 intlTelInput.startedLoadingUtilsScript = true; 3133 return loadCall.then((module) => { 3134 const utils = module?.default; 3135 if (!utils || typeof utils !== "object") { 3136 throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export."); 3137 } 3138 intlTelInput.utils = utils; 3139 forEachInstance("handleUtils"); 3140 return true; 3141 }).catch((error) => { 3142 forEachInstance("rejectUtilsScriptPromise", error); 3143 throw error; 3144 }); 3145 } 3146 return null; 3147 }; 3148 var intlTelInput = Object.assign( 3149 (input, options) => { 3150 const iti = new Iti(input, options); 3151 iti._init(); 3152 input.setAttribute("data-intl-tel-input-id", iti.id.toString()); 3153 intlTelInput.instances[iti.id] = iti; 3154 return iti; 3155 }, 3156 { 3157 defaults,
3158 //* Using a static var like this allows us to mock it in the tests. 3159 documentReady: () => document.readyState === "complete", 3160 //* Get the country data object. 3161 getCountryData: () => data_default, 3162 //* A getter for the plugin instance. 3163 getInstance: (input) => { 3164 const id2 = input.getAttribute("data-intl-tel-input-id"); 3165 return id2 ? intlTelInput.instances[id2] : null; 3166 }, 3167 //* A map from instance ID to instance object. 3168 instances: {}, 3169 attachUtils, 3170 startedLoadingUtilsScript: false, 3171 startedLoadingAutoCountry: false, 3172 version: "25.3.0" 3173 } 3174 ); 3175 var intl_tel_input_default = intlTelInput; 3176 return __toCommonJS(intl_tel_input_exports); 3177})(); 3178 3179// UMD 3180 return factoryOutput.default; 3181}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.