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 // ææºç«¯èå¨å½å®¶ä¸æ 2420 if($(window).width() < 1199){ 2421 var wordf = $(listItem).data('country-code'); 2422 if($('.ys-select-li[data-code='+wordf+']').length>0){ 2423 var namek = $('.ys-select-li[data-code='+wordf+']').attr('data-value'); 2424 $('.ys-form-inof-country').find('.ys-select-show').val(namek); 2425 } 2426 } 2427 // 2428 if (listItem) { 2429 this._selectListItem(listItem); 2430 } 2431 }; 2432 this.countryList.addEventListener("click", this._handleClickCountryList); 2433 let isOpening = true; 2434 this._handleClickOffToClose = () => { 2435 if (!isOpening) { 2436 this._closeDropdown(); 2437 } 2438 isOpening = false;
2439 }; 2440 document.documentElement.addEventListener( 2441 "click", 2442 this._handleClickOffToClose 2443 ); 2444 let query = ""; 2445 let queryTimer = null; 2446 this._handleKeydownOnDropdown = (e) => { 2447 if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) { 2448 e.preventDefault(); 2449 e.stopPropagation(); 2450 if (e.key === "ArrowUp" || e.key === "ArrowDown") { 2451 this._handleUpDownKey(e.key); 2452 } else if (e.key === "Enter") { 2453 this._handleEnterKey(); 2454 } else if (e.key === "Escape") { 2455 this._closeDropdown(); 2456 } 2457 } 2458 if (!this.options.countrySearch && /^[a-zA-ZÃ-ÿа-ÑÐ-Я ]$/.test(e.key)) { 2459 e.stopPropagation(); 2460 if (queryTimer) { 2461 clearTimeout(queryTimer); 2462 } 2463 query += e.key.toLowerCase(); 2464 this._searchForCountry(query); 2465 queryTimer = setTimeout(() => { 2466 query = ""; 2467 }, 1e3); 2468 } 2469 }; 2470 document.addEventListener("keydown", this._handleKeydownOnDropdown); 2471 if (this.options.countrySearch) { 2472 const doFilter = () => { 2473 const inputQuery = this.searchInput.value.trim(); 2474 if (inputQuery) { 2475 this._filterCountries(inputQuery); 2476 } else { 2477 this._filterCountries("", true); 2478 } 2479 }; 2480 let keyupTimer = null; 2481 this._handleSearchChange = () => { 2482 if (keyupTimer) { 2483 clearTimeout(keyupTimer); 2484 } 2485 keyupTimer = setTimeout(() => { 2486 doFilter(); 2487 keyupTimer = null; 2488 }, 100); 2489 }; 2490 this.searchInput.addEventListener("input", this._handleSearchChange); 2491 this.searchInput.addEventListener("click", (e) => e.stopPropagation()); 2492 } 2493 } 2494 //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string. 2495 _searchForCountry(query) { 2496 for (let i = 0; i < this.countries.length; i++) { 2497 const c = this.countries[i]; 2498 const startsWith = c.name.substr(0, query.length).toLowerCase() === query; 2499 if (startsWith) { 2500 const listItem = c.nodeById[this.id]; 2501 this._highlightListItem(listItem, false); 2502 this._scrollTo(listItem); 2503 break; 2504 } 2505 } 2506 } 2507 //* Country search enabled: Filter the countries according to the search query. 2508 _filterCountries(query, isReset = false) { 2509 let noCountriesAddedYet = true; 2510 this.countryList.innerHTML = ""; 2511 const normalisedQuery = normaliseString(query); 2512 for (let i = 0; i < this.countries.length; i++) { 2513 const c = this.countries[i]; 2514 const normalisedCountryName = normaliseString(c.name); 2515 const countryInitials = c.name.split(/[^a-zA-ZÃ-ÿа-ÑÐ-Я]/).map((word) => word[0]).join("").toLowerCase(); 2516 const fullDialCode = `+${c.dialCode}`; 2517 if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) { 2518 const listItem = c.nodeById[this.id]; 2519 if (listItem) { 2520 this.countryList.appendChild(listItem); 2521 } 2522 if (noCountriesAddedYet) { 2523 this._highlightListItem(listItem, false); 2524 noCountriesAddedYet = false;
2525 } 2526 } 2527 } 2528 if (noCountriesAddedYet) { 2529 this._highlightListItem(null, false); 2530 } 2531 this.countryList.scrollTop = 0; 2532 this._updateSearchResultsText(); 2533 } 2534 //* Update search results text (for a11y). 2535 _updateSearchResultsText() { 2536 const { i18n } = this.options; 2537 const count = this.countryList.childElementCount; 2538 let searchText; 2539 if (count === 0) { 2540 searchText = i18n.zeroSearchResults; 2541 } else if (count === 1) { 2542 searchText = i18n.oneSearchResult; 2543 } else { 2544 searchText = i18n.multipleSearchResults.replace("${count}", count.toString()); 2545 } 2546 this.searchResultsA11yText.textContent = searchText; 2547 } 2548 //* Highlight the next/prev item in the list (and ensure it is visible). 2549 _handleUpDownKey(key) { 2550 let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling; 2551 if (!next && this.countryList.childElementCount > 1) { 2552 next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild; 2553 } 2554 if (next) { 2555 this._scrollTo(next); 2556 this._highlightListItem(next, false); 2557 } 2558 } 2559 //* Select the currently highlighted item. 2560 _handleEnterKey() { 2561 if (this.highlightedItem) { 2562 this._selectListItem(this.highlightedItem); 2563 } 2564 } 2565 //* Update the input's value to the given val (format first if possible) 2566 //* NOTE: this is called from _setInitialState, handleUtils and setNumber. 2567 _updateValFromNumber(fullNumber) { 2568 let number = fullNumber; 2569 if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) { 2570 const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode; 2571 const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat; 2572 const format = useNational ? NATIONAL : INTERNATIONAL; 2573 number = intlTelInput.utils.formatNumber( 2574 number, 2575 this.selectedCountryData.iso2, 2576 format 2577 ); 2578 } 2579 number = this._beforeSetNumber(number); 2580 this.telInput.value = number; 2581 } 2582 //* Check if need to select a new country based on the given number 2583 //* Note: called from _setInitialState, keyup handler, setNumber. 2584 _updateCountryFromNumber(fullNumber) { 2585 const iso2 = this._getCountryFromNumber(fullNumber); 2586 if (iso2 !== null) { 2587 return this._setCountry(iso2); 2588 } 2589 return false; 2590 } 2591 _ensureHasDialCode(number) { 2592 const { dialCode, nationalPrefix } = this.selectedCountryData; 2593 const alreadyHasPlus = number.charAt(0) === "+"; 2594 if (alreadyHasPlus || !dialCode) { 2595 return number; 2596 } 2597 const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode; 2598 const cleanNumber = hasPrefix ? number.substring(1) : number; 2599 return `+${dialCode}${cleanNumber}`; 2600 } 2601 _getCountryFromNumber(fullNumber) { 2602 const plusIndex = fullNumber.indexOf("+"); 2603 let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber; 2604 const selectedIso2 = this.selectedCountryData.iso2; 2605 const selectedDialCode = this.selectedCountryData.dialCode; 2606 number = this._ensureHasDialCode(number); 2607 const dialCodeMatch = this._getDialCode(number, true); 2608 const numeric = getNumeric(number); 2609 if (dialCodeMatch) { 2610 const dialCodeMatchNumeric = getNumeric(dialCodeMatch); 2611 const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric]; 2612 if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) { 2613 return this.defaultCountry; 2614 } 2615 const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes); 2616 const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric); 2617 if (!isRegionlessNanpNumber && !alreadySelected) { 2618 for (let j = 0; j < iso2Codes.length; j++) { 2619 if (iso2Codes[j]) { 2620 return iso2Codes[j]; 2621 } 2622 } 2623 } 2624 } else if (number.charAt(0) === "+" && numeric.length) { 2625 return ""; 2626 } else if ((!number || number === "+") && !this.selectedCountryData.iso2) { 2627 return this.defaultCountry; 2628 } 2629 return null; 2630 } 2631 //* Remove highlighting from other list items and highlight the given item. 2632 _highlightListItem(listItem, shouldFocus) { 2633 const prevItem = this.highlightedItem; 2634 if (prevItem) { 2635 prevItem.classList.remove("iti__highlight"); 2636 prevItem.setAttribute("aria-selected", "false"); 2637 } 2638 this.highlightedItem = listItem; 2639 if (this.highlightedItem) { 2640 this.highlightedItem.classList.add("iti__highlight"); 2641 this.highlightedItem.setAttribute("aria-selected", "true"); 2642 const activeDescendant = this.highlightedItem.getAttribute("id") || ""; 2643 this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant); 2644 if (this.options.countrySearch) { 2645 this.searchInput.setAttribute("aria-activedescendant", activeDescendant); 2646 } 2647 } 2648 if (shouldFocus) { 2649 this.highlightedItem.focus(); 2650 } 2651 } 2652 //* Find the country data for the given iso2 code 2653 //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2654 _getCountryData(iso2, allowFail) { 2655 for (let i = 0; i < this.countries.length; i++) { 2656 if (this.countries[i].iso2 === iso2) { 2657 return this.countries[i]; 2658 } 2659 } 2660 if (allowFail) { 2661 return null; 2662 } 2663 throw new Error(`No country data for '${iso2}'`); 2664 } 2665 //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item. 2666 //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry. 2667 _setCountry(iso2) { 2668 const { separateDialCode, showFlags, i18n } = this.options; 2669 const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {}; 2670 this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {}; 2671 if (this.selectedCountryData.iso2) { 2672 this.defaultCountry = this.selectedCountryData.iso2; 2673 } 2674 if (this.selectedCountryInner) { 2675 let flagClass = ""; 2676 let a11yText = ""; 2677 if (iso2 && showFlags) { 2678 flagClass = `iti__flag iti__${iso2}`; 2679 a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`; 2680 } else { 2681 flagClass = "iti__flag iti__globe"; 2682 a11yText = i18n.noCountrySelected; 2683 } 2684 this.selectedCountryInner.className = flagClass; 2685 this.selectedCountryA11yText.textContent = a11yText; 2686 } 2687 this._setSelectedCountryTitleAttribute(iso2, separateDialCode); 2688 if (separateDialCode) { 2689 const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : ""; 2690 this.selectedDialCode.innerHTML = dialCode; 2691 this._updateInputPadding(); 2692 } 2693 this._updatePlaceholder(); 2694 this._updateMaxLength(); 2695 return prevCountry.iso2 !== iso2; 2696 } 2697 //* Update the input padding to make space for the selected country/dial code. 2698 _updateInputPadding() { 2699 if (this.selectedCountry) { 2700 const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth(); 2701 const inputPadding = selectedCountryWidth + 6; 2702 if (this.showSelectedCountryOnLeft) { 2703 this.telInput.style.paddingLeft = `${inputPadding}px`; 2704 } else { 2705 this.telInput.style.paddingRight = `${inputPadding}px`; 2706 } 2707 } 2708 } 2709 //* Update the maximum valid number length for the currently selected country. 2710 _updateMaxLength() { 2711 const { strictMode, placeholderNumberType, validationNumberTypes } = this.options; 2712 const { iso2 } = this.selectedCountryData; 2713 if (strictMode && intlTelInput.utils) { 2714 if (iso2) { 2715 const numberType = intlTelInput.utils.numberType[placeholderNumberType]; 2716 let exampleNumber = intlTelInput.utils.getExampleNumber( 2717 iso2, 2718 false, 2719 numberType, 2720 true 2721 ); 2722 let validNumber = exampleNumber; 2723 while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) { 2724 validNumber = exampleNumber; 2725 exampleNumber += "0"; 2726 } 2727 const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2); 2728 this.maxCoreNumberLength = coreNumber.length; 2729 if (iso2 === "by") { 2730 this.maxCoreNumberLength = coreNumber.length + 1; 2731 } 2732 } else { 2733 this.maxCoreNumberLength = null; 2734 } 2735 } 2736 } 2737 _setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) { 2738 if (!this.selectedCountry) { 2739 return; 2740 } 2741 let title; 2742 if (iso2 && !separateDialCode) { 2743 title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`; 2744 } else if (iso2) { 2745 title = this.selectedCountryData.name; 2746 } else { 2747 title = "Unknown"; 2748 } 2749 this.selectedCountry.setAttribute("title", title); 2750 } 2751 //* When the input is in a hidden container during initialisation, we must inject some markup 2752 //* into the end of the DOM to calculate the correct offsetWidth. 2753 //* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry 2754 //* will definitely exist. 2755 _getHiddenSelectedCountryWidth() { 2756 if (this.telInput.parentNode) { 2757 const containerClone = this.telInput.parentNode.cloneNode(false); 2758 containerClone.style.visibility = "hidden"; 2759 document.body.appendChild(containerClone); 2760 const countryContainerClone = this.countryContainer.cloneNode(); 2761 containerClone.appendChild(countryContainerClone); 2762 const selectedCountryClone = this.selectedCountry.cloneNode(true); 2763 countryContainerClone.appendChild(selectedCountryClone); 2764 const width = selectedCountryClone.offsetWidth; 2765 document.body.removeChild(containerClone); 2766 return width; 2767 } 2768 return 0; 2769 } 2770 //* Update the input placeholder to an example number from the currently selected country. 2771 _updatePlaceholder() { 2772 const { 2773 autoPlaceholder, 2774 placeholderNumberType, 2775 nationalMode, 2776 customPlaceholder 2777 } = this.options; 2778 const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite"; 2779 if (intlTelInput.utils && shouldSetPlaceholder) { 2780 const numberType = intlTelInput.utils.numberType[placeholderNumberType]; 2781 let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber( 2782 this.selectedCountryData.iso2, 2783 nationalMode, 2784 numberType 2785 ) : ""; 2786 placeholder = this._beforeSetNumber(placeholder); 2787 if (typeof customPlaceholder === "function") { 2788 placeholder = customPlaceholder(placeholder, this.selectedCountryData); 2789 } 2790 this.telInput.setAttribute("placeholder", placeholder); 2791 } 2792 } 2793 //* Called when the user selects a list item from the dropdown. 2794 _selectListItem(listItem) { 2795 const countryChanged = this._setCountry( 2796 listItem.getAttribute("data-country-code") 2797 ); 2798 this._closeDropdown(); 2799 this._updateDialCode(listItem.getAttribute("data-dial-code")); 2800 this.telInput.focus(); 2801 if (countryChanged) { 2802 this._triggerCountryChange(); 2803 } 2804 } 2805 //* Close the dropdown and unbind any listeners. 2806 _closeDropdown() { 2807 this.dropdownContent.classList.add("iti__hide"); 2808 this.selectedCountry.setAttribute("aria-expanded", "false"); 2809 this.selectedCountry.removeAttribute("aria-activedescendant"); 2810 if (this.highlightedItem) { 2811 this.highlightedItem.setAttribute("aria-selected", "false"); 2812 } 2813 if (this.options.countrySearch) { 2814 this.searchInput.removeAttribute("aria-activedescendant"); 2815 } 2816 this.dropdownArrow.classList.remove("iti__arrow--up"); 2817 document.removeEventListener("keydown", this._handleKeydownOnDropdown); 2818 if (this.options.countrySearch) { 2819 this.searchInput.removeEventListener("input", this._handleSearchChange); 2820 } 2821 document.documentElement.removeEventListener( 2822 "click", 2823 this._handleClickOffToClose 2824 ); 2825 this.countryList.removeEventListener( 2826 "mouseover", 2827 this._handleMouseoverCountryList 2828 ); 2829 this.countryList.removeEventListener("click", this._handleClickCountryList); 2830 if (this.options.dropdownContainer) { 2831 if (!this.options.useFullscreenPopup) { 2832 window.removeEventListener("scroll", this._handleWindowScroll); 2833 } 2834 if (this.dropdown.parentNode) { 2835 this.dropdown.parentNode.removeChild(this.dropdown); 2836 } 2837 } 2838 if (this._handlePageLoad) { 2839 window.removeEventListener("load", this._handlePageLoad); 2840 } 2841 this._trigger("close:countrydropdown"); 2842 } 2843 //* Check if an element is visible within it's container, else scroll until it is. 2844 _scrollTo(element) { 2845 const container = this.countryList; 2846 const scrollTop = document.documentElement.scrollTop; 2847 const containerHeight = container.offsetHeight; 2848 const containerTop = container.getBoundingClientRect().top + scrollTop; 2849 const containerBottom = containerTop + containerHeight; 2850 const elementHeight = element.offsetHeight; 2851 const elementTop = element.getBoundingClientRect().top + scrollTop; 2852 const elementBottom = elementTop + elementHeight; 2853 const newScrollTop = elementTop - containerTop + container.scrollTop;
2854 if (elementTop < containerTop) { 2855 container.scrollTop = newScrollTop; 2856 } else if (elementBottom > containerBottom) { 2857 const heightDifference = containerHeight - elementHeight; 2858 container.scrollTop = newScrollTop - heightDifference; 2859 } 2860 } 2861 //* Replace any existing dial code with the new one 2862 //* Note: called from _selectListItem and setCountry 2863 _updateDialCode(newDialCodeBare) { 2864 const inputVal = this.telInput.value; 2865 const newDialCode = `+${newDialCodeBare}`; 2866 let newNumber; 2867 if (inputVal.charAt(0) === "+") { 2868 const prevDialCode = this._getDialCode(inputVal); 2869 if (prevDialCode) { 2870 newNumber = inputVal.replace(prevDialCode, newDialCode); 2871 } else { 2872 newNumber = newDialCode; 2873 } 2874 this.telInput.value = newNumber; 2875 } 2876 } 2877 //* Try and extract a valid international dial code from a full telephone number. 2878 //* Note: returns the raw string inc plus character and any whitespace/dots etc. 2879 _getDialCode(number, includeAreaCode) { 2880 let dialCode = ""; 2881 if (number.charAt(0) === "+") { 2882 let numericChars = ""; 2883 for (let i = 0; i < number.length; i++) { 2884 const c = number.charAt(i); 2885 if (!isNaN(parseInt(c, 10))) { 2886 numericChars += c; 2887 if (includeAreaCode) { 2888 if (this.dialCodeToIso2Map[numericChars]) { 2889 dialCode = number.substr(0, i + 1); 2890 } 2891 } else { 2892 if (this.dialCodes[numericChars]) { 2893 dialCode = number.substr(0, i + 1); 2894 break; 2895 } 2896 } 2897 if (numericChars.length === this.dialCodeMaxLen) { 2898 break; 2899 } 2900 } 2901 } 2902 } 2903 return dialCode; 2904 } 2905 //* Get the input val, adding the dial code if separateDialCode is enabled. 2906 _getFullNumber(overrideVal) { 2907 const val = overrideVal || this.telInput.value.trim(); 2908 const { dialCode } = this.selectedCountryData; 2909 let prefix; 2910 const numericVal = getNumeric(val); 2911 if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) { 2912 prefix = `+${dialCode}`; 2913 } else { 2914 prefix = ""; 2915 } 2916 return prefix + val; 2917 } 2918 //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute 2919 _beforeSetNumber(fullNumber) { 2920 let number = fullNumber; 2921 if (this.options.separateDialCode) { 2922 let dialCode = this._getDialCode(number); 2923 if (dialCode) { 2924 dialCode = `+${this.selectedCountryData.dialCode}`; 2925 const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length; 2926 number = number.substr(start); 2927 } 2928 } 2929 return this._cap(number); 2930 } 2931 //* Trigger the 'countrychange' event. 2932 _triggerCountryChange() { 2933 this._trigger("countrychange"); 2934 } 2935 //* Format the number as the user types. 2936 _formatNumberAsYouType() { 2937 const val = this._getFullNumber(); 2938 const result = intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val; 2939 const { dialCode } = this.selectedCountryData; 2940 if (this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && result.includes(`+${dialCode}`)) { 2941 const afterDialCode = result.split(`+${dialCode}`)[1] || ""; 2942 return afterDialCode.trim(); 2943 } 2944 return result; 2945 } 2946 //************************** 2947 //* SECRET PUBLIC METHODS 2948 //************************** 2949 //* This is called when the geoip call returns. 2950 handleAutoCountry() { 2951 if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) { 2952 this.defaultCountry = intlTelInput.autoCountry; 2953 const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe"); 2954 if (!hasSelectedCountryOrGlobe) { 2955 this.setCountry(this.defaultCountry); 2956 } 2957 this.resolveAutoCountryPromise(); 2958 } 2959 } 2960 //* This is called when the utils request completes. 2961 handleUtils() { 2962 if (intlTelInput.utils) { 2963 if (this.telInput.value) {
2964 this._updateValFromNumber(this.telInput.value); 2965 } 2966 if (this.selectedCountryData.iso2) { 2967 this._updatePlaceholder(); 2968 this._updateMaxLength(); 2969 } 2970 } 2971 this.resolveUtilsScriptPromise(); 2972 } 2973 //******************** 2974 //* PUBLIC METHODS 2975 //******************** 2976 //* Remove plugin. 2977 destroy() { 2978 const { allowDropdown, separateDialCode } = this.options; 2979 if (allowDropdown) { 2980 this._closeDropdown(); 2981 this.selectedCountry.removeEventListener( 2982 "click", 2983 this._handleClickSelectedCountry 2984 ); 2985 this.countryContainer.removeEventListener( 2986 "keydown", 2987 this._handleCountryContainerKeydown 2988 ); 2989 const label = this.telInput.closest("label"); 2990 if (label) { 2991 label.removeEventListener("click", this._handleLabelClick); 2992 } 2993 } 2994 const { form } = this.telInput; 2995 if (this._handleHiddenInputSubmit && form) { 2996 form.removeEventListener("submit", this._handleHiddenInputSubmit); 2997 } 2998 this.telInput.removeEventListener("input", this._handleInputEvent); 2999 if (this._handleKeydownEvent) { 3000 this.telInput.removeEventListener("keydown", this._handleKeydownEvent); 3001 } 3002 this.telInput.removeAttribute("data-intl-tel-input-id"); 3003 if (separateDialCode) { 3004 if (this.isRTL) { 3005 this.telInput.style.paddingRight = this.originalPaddingRight; 3006 } else { 3007 this.telInput.style.paddingLeft = this.originalPaddingLeft; 3008 } 3009 } 3010 const wrapper = this.telInput.parentNode; 3011 wrapper?.parentNode?.insertBefore(this.telInput, wrapper); 3012 wrapper?.parentNode?.removeChild(wrapper); 3013 delete intlTelInput.instances[this.id]; 3014 } 3015 //* Get the extension from the current number. 3016 getExtension() { 3017 if (intlTelInput.utils) { 3018 return intlTelInput.utils.getExtension( 3019 this._getFullNumber(), 3020 this.selectedCountryData.iso2 3021 ); 3022 } 3023 return ""; 3024 } 3025 //* Format the number to the given format. 3026 getNumber(format) { 3027 if (intlTelInput.utils) { 3028 const { iso2 } = this.selectedCountryData; 3029 return intlTelInput.utils.formatNumber( 3030 this._getFullNumber(), 3031 iso2, 3032 format 3033 ); 3034 } 3035 return ""; 3036 } 3037 //* Get the type of the entered number e.g. landline/mobile. 3038 getNumberType() { 3039 if (intlTelInput.utils) { 3040 return intlTelInput.utils.getNumberType( 3041 this._getFullNumber(), 3042 this.selectedCountryData.iso2 3043 ); 3044 } 3045 return -99; 3046 } 3047 //* Get the country data for the currently selected country. 3048 getSelectedCountryData() { 3049 return this.selectedCountryData; 3050 } 3051 //* Get the validation error. 3052 getValidationError() { 3053 if (intlTelInput.utils) { 3054 const { iso2 } = this.selectedCountryData; 3055 return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2); 3056 } 3057 return -99; 3058 } 3059 //* Validate the input val 3060 isValidNumber() { 3061 if (!this.selectedCountryData.iso2) { 3062 return false; 3063 } 3064 const val = this._getFullNumber(); 3065 const alphaCharPosition = val.search(/\p{L}/u); 3066 if (alphaCharPosition > -1) { 3067 const beforeAlphaChar = val.substring(0, alphaCharPosition); 3068 const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar); 3069 const isValid = this._utilsIsPossibleNumber(val); 3070 return beforeAlphaIsValid && isValid; 3071 } 3072 return this._utilsIsPossibleNumber(val); 3073 } 3074 _utilsIsPossibleNumber(val) { 3075 return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null; 3076 } 3077 //* Validate the input val (precise) 3078 isValidNumberPrecise() { 3079 if (!this.selectedCountryData.iso2) { 3080 return false; 3081 } 3082 const val = this._getFullNumber(); 3083 const alphaCharPosition = val.search(/\p{L}/u); 3084 if (alphaCharPosition > -1) { 3085 const beforeAlphaChar = val.substring(0, alphaCharPosition); 3086 const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar); 3087 const isValid = this._utilsIsValidNumber(val); 3088 return beforeAlphaIsValid && isValid; 3089 } 3090 return this._utilsIsValidNumber(val); 3091 } 3092 _utilsIsValidNumber(val) { 3093 return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null; 3094 } 3095 //* Update the selected country, and update the input val accordingly. 3096 setCountry(iso2) { 3097 const iso2Lower = iso2?.toLowerCase(); 3098 const currentCountry = this.selectedCountryData.iso2; 3099 const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry; 3100 if (isCountryChange) { 3101 this._setCountry(iso2Lower); 3102 this._updateDialCode(this.selectedCountryData.dialCode); 3103 this._triggerCountryChange(); 3104 } 3105 } 3106 //* Set the input value and update the country. 3107 setNumber(number) { 3108 const countryChanged = this._updateCountryFromNumber(number);
3109 this._updateValFromNumber(number); 3110 if (countryChanged) { 3111 this._triggerCountryChange(); 3112 } 3113 this._trigger("input", { isSetNumber: true }); 3114 } 3115 //* Set the placeholder number typ 3116 setPlaceholderNumberType(type) { 3117 this.options.placeholderNumberType = type; 3118 this._updatePlaceholder(); 3119 } 3120 setDisabled(disabled) { 3121 this.telInput.disabled = disabled; 3122 if (disabled) { 3123 this.selectedCountry.setAttribute("disabled", "true"); 3124 } else { 3125 this.selectedCountry.removeAttribute("disabled"); 3126 } 3127 } 3128 }; 3129 var attachUtils = (source) => { 3130 if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) { 3131 let loadCall; 3132 if (typeof source === "function") { 3133 try { 3134 loadCall = Promise.resolve(source()); 3135 } catch (error) { 3136 return Promise.reject(error); 3137 } 3138 } else { 3139 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}`)); 3140 } 3141 intlTelInput.startedLoadingUtilsScript = true; 3142 return loadCall.then((module) => { 3143 const utils = module?.default; 3144 if (!utils || typeof utils !== "object") { 3145 throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export."); 3146 } 3147 intlTelInput.utils = utils; 3148 forEachInstance("handleUtils"); 3149 return true; 3150 }).catch((error) => { 3151 forEachInstance("rejectUtilsScriptPromise", error); 3152 throw error; 3153 }); 3154 } 3155 return null; 3156 }; 3157 var intlTelInput = Object.assign( 3158 (input, options) => { 3159 const iti = new Iti(input, options); 3160 iti._init(); 3161 input.setAttribute("data-intl-tel-input-id", iti.id.toString()); 3162 intlTelInput.instances[iti.id] = iti; 3163 return iti; 3164 }, 3165 { 3166 defaults,
3167 //* Using a static var like this allows us to mock it in the tests. 3168 documentReady: () => document.readyState === "complete", 3169 //* Get the country data object. 3170 getCountryData: () => data_default, 3171 //* A getter for the plugin instance. 3172 getInstance: (input) => { 3173 const id2 = input.getAttribute("data-intl-tel-input-id"); 3174 return id2 ? intlTelInput.instances[id2] : null; 3175 }, 3176 //* A map from instance ID to instance object. 3177 instances: {}, 3178 attachUtils, 3179 startedLoadingUtilsScript: false, 3180 startedLoadingAutoCountry: false, 3181 version: "25.3.0" 3182 } 3183 ); 3184 var intl_tel_input_default = intlTelInput; 3185 return __toCommonJS(intl_tel_input_exports); 3186})(); 3187 3188// UMD 3189 return factoryOutput.default; 3190}));
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.