intl-tel-input 18.1.0 → 18.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +2 -8
- package/.github/CONTRIBUTING.md +1 -1
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +3 -0
- package/Gruntfile.js +0 -2
- package/README.md +46 -35
- package/build/css/demo.css +16 -27
- package/build/css/intlTelInput.css +19 -9
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +2 -2
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput-jquery.js +161 -60
- package/build/js/intlTelInput-jquery.min.js +3 -3
- package/build/js/intlTelInput.js +161 -60
- package/build/js/intlTelInput.min.js +3 -3
- package/composer.json +1 -1
- package/demo.html +42 -44
- package/demo_rtl.html +21 -23
- package/grunt/template.js +2 -265
- package/package.json +5 -2
- package/src/css/demo.scss +13 -29
- package/src/css/intlTelInput.scss +21 -21
- package/src/js/data.js +1 -1
- package/src/js/intlTelInput.js +563 -333
- package/examples/css/countrySync.css +0 -10
- package/examples/css/isValidNumber.css +0 -12
- package/examples/css/prism.css +0 -126
- package/examples/gen/country-sync.html +0 -98
- package/examples/gen/default-country-ip.html +0 -62
- package/examples/gen/display-number.html +0 -47
- package/examples/gen/hidden-input.html +0 -54
- package/examples/gen/init-promise.html +0 -66
- package/examples/gen/is-valid-number.html +0 -86
- package/examples/gen/js/countrySync.js +0 -31
- package/examples/gen/js/defaultCountryIp.js +0 -11
- package/examples/gen/js/displayNumber.js +0 -4
- package/examples/gen/js/hiddenInput.js +0 -5
- package/examples/gen/js/initPromise.js +0 -9
- package/examples/gen/js/isValidNumber.js +0 -37
- package/examples/gen/js/modifyCountryData.js +0 -11
- package/examples/gen/js/multipleInstances.js +0 -13
- package/examples/gen/js/nationalMode.js +0 -18
- package/examples/gen/js/onlyCountriesEurope.js +0 -8
- package/examples/gen/modify-country-data.html +0 -52
- package/examples/gen/multiple-instances.html +0 -60
- package/examples/gen/national-mode.html +0 -63
- package/examples/gen/only-countries-europe.html +0 -49
- package/examples/js/countrySync.js.ejs +0 -31
- package/examples/js/defaultCountryIp.js.ejs +0 -11
- package/examples/js/displayNumber.js.ejs +0 -4
- package/examples/js/hiddenInput.js.ejs +0 -5
- package/examples/js/initPromise.js.ejs +0 -9
- package/examples/js/isValidNumber.js.ejs +0 -37
- package/examples/js/modifyCountryData.js.ejs +0 -11
- package/examples/js/multipleInstances.js.ejs +0 -13
- package/examples/js/nationalMode.js.ejs +0 -18
- package/examples/js/onlyCountriesEurope.js.ejs +0 -8
- package/examples/js/prism.js +0 -11
- package/examples/partials/countrySync.html +0 -13
- package/examples/partials/defaultCountryIp.html +0 -5
- package/examples/partials/displayNumber.html +0 -1
- package/examples/partials/hiddenInput.html +0 -4
- package/examples/partials/initPromise.html +0 -8
- package/examples/partials/isValidNumber.html +0 -3
- package/examples/partials/multipleInstances.html +0 -3
- package/examples/partials/nationalMode.html +0 -2
- package/examples/partials/simpleInput.html +0 -1
- package/examples/template.html.ejs +0 -43
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v18.1.
|
|
2
|
+
* International Telephone Input v18.1.2
|
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
// Order (if >1 country with same dial code),
|
|
30
30
|
// Area codes
|
|
31
31
|
// ]
|
|
32
|
-
var allCountries = [ [ "Afghanistan (افغانستان)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (الجزائر)", "dz", "213" ], [ "American Samoa", "as", "1", 5, [ "684" ] ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1", 6, [ "264" ] ], [ "Antigua and Barbuda", "ag", "1", 7, [ "268" ] ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Ascension Island", "ac", "247" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1", 8, [ "242" ] ], [ "Bahrain (البحرين)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1", 9, [ "246" ] ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1", 10, [ "441" ] ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1", 11, [ "284" ] ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "367", "368", "387", "403", "416", "418", "431", "437", "438", "450", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1, [ "3", "4", "7" ] ], [ "Cayman Islands", "ky", "1", 12, [ "345" ] ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2, [ "89164" ] ], [ "Cocos (Keeling) Islands", "cc", "61", 1, [ "89162" ] ], [ "Colombia", "co", "57" ], [ "Comoros (جزر القمر)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1", 13, [ "767" ] ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (مصر)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Eswatini", "sz", "268" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1", 14, [ "473" ] ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1", 15, [ "671" ] ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1, [ "1481", "7781", "7839", "7911" ] ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (ایران)", "ir", "98" ], [ "Iraq (العراق)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2, [ "1624", "74576", "7524", "7924", "7624" ] ], [ "Israel (ישראל)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1", 4, [ "876", "658" ] ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3, [ "1534", "7509", "7700", "7797", "7829", "7937" ] ], [ "Jordan (الأردن)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1, [ "33", "7" ] ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kosovo", "xk", "383" ], [ "Kuwait (الكويت)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (لبنان)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (ليبيا)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (موريتانيا)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1, [ "269", "639" ] ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1", 16, [ "664" ] ], [ "Morocco (المغرب)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "North Macedonia (Северна Македонија)", "mk", "389" ], [ "Northern Mariana Islands", "mp", "1", 17, [ "670" ] ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (عُمان)", "om", "968" ], [ "Pakistan (پاکستان)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (فلسطين)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (قطر)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1", 18, [ "869" ] ], [ "Saint Lucia", "lc", "1", 19, [ "758" ] ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1", 20, [ "784" ] ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (المملكة العربية السعودية)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1", 21, [ "721" ] ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (جنوب السودان)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්රී ලංකාව)", "lk", "94" ], [ "Sudan (السودان)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1, [ "79" ] ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (سوريا)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1", 22, [ "868" ] ], [ "Tunisia (تونس)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1", 23, [ "649" ] ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1", 24, [ "340" ] ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (الإمارات العربية المتحدة)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1, [ "06698" ] ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna (Wallis-et-Futuna)", "wf", "681" ], [ "Western Sahara (الصحراء الغربية)", "eh", "212", 1, [ "5288", "5289" ] ], [ "Yemen (اليمن)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1, [ "18" ] ] ];
|
|
32
|
+
var allCountries = [ [ "Afghanistan (افغانستان)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (الجزائر)", "dz", "213" ], [ "American Samoa", "as", "1", 5, [ "684" ] ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1", 6, [ "264" ] ], [ "Antigua and Barbuda", "ag", "1", 7, [ "268" ] ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Ascension Island", "ac", "247" ], [ "Australia", "au", "61", 0 ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1", 8, [ "242" ] ], [ "Bahrain (البحرين)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1", 9, [ "246" ] ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1", 10, [ "441" ] ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1", 11, [ "284" ] ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "263", "289", "306", "343", "354", "365", "367", "368", "382", "387", "403", "416", "418", "428", "431", "437", "438", "450", "584", "468", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "683", "705", "709", "742", "753", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1, [ "3", "4", "7" ] ], [ "Cayman Islands", "ky", "1", 12, [ "345" ] ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Christmas Island", "cx", "61", 2, [ "89164" ] ], [ "Cocos (Keeling) Islands", "cc", "61", 1, [ "89162" ] ], [ "Colombia", "co", "57" ], [ "Comoros (جزر القمر)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1", 13, [ "767" ] ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (مصر)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Eswatini", "sz", "268" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358", 0 ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1", 14, [ "473" ] ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1", 15, [ "671" ] ], [ "Guatemala", "gt", "502" ], [ "Guernsey", "gg", "44", 1, [ "1481", "7781", "7839", "7911" ] ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (ایران)", "ir", "98" ], [ "Iraq (العراق)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Isle of Man", "im", "44", 2, [ "1624", "74576", "7524", "7924", "7624" ] ], [ "Israel (ישראל)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1", 4, [ "876", "658" ] ], [ "Japan (日本)", "jp", "81" ], [ "Jersey", "je", "44", 3, [ "1534", "7509", "7700", "7797", "7829", "7937" ] ], [ "Jordan (الأردن)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1, [ "33", "7" ] ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kosovo", "xk", "383" ], [ "Kuwait (الكويت)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (لبنان)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (ليبيا)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (موريتانيا)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mayotte", "yt", "262", 1, [ "269", "639" ] ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1", 16, [ "664" ] ], [ "Morocco (المغرب)", "ma", "212", 0 ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "North Macedonia (Северна Македонија)", "mk", "389" ], [ "Northern Mariana Islands", "mp", "1", 17, [ "670" ] ], [ "Norway (Norge)", "no", "47", 0 ], [ "Oman (عُمان)", "om", "968" ], [ "Pakistan (پاکستان)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (فلسطين)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (قطر)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262", 0 ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1", 18, [ "869" ] ], [ "Saint Lucia", "lc", "1", 19, [ "758" ] ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1", 20, [ "784" ] ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (المملكة العربية السعودية)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1", 21, [ "721" ] ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (جنوب السودان)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්රී ලංකාව)", "lk", "94" ], [ "Sudan (السودان)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Svalbard and Jan Mayen", "sj", "47", 1, [ "79" ] ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (سوريا)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1", 22, [ "868" ] ], [ "Tunisia (تونس)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1", 23, [ "649" ] ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1", 24, [ "340" ] ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (الإمارات العربية المتحدة)", "ae", "971" ], [ "United Kingdom", "gb", "44", 0 ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1, [ "06698" ] ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna (Wallis-et-Futuna)", "wf", "681" ], [ "Western Sahara (الصحراء الغربية)", "eh", "212", 1, [ "5288", "5289" ] ], [ "Yemen (اليمن)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ], [ "Åland Islands", "ax", "358", 1, [ "18" ] ] ];
|
|
33
33
|
// loop over all of the countries above, restructuring the data to be objects with named keys
|
|
34
34
|
for (var i = 0; i < allCountries.length; i++) {
|
|
35
35
|
var c = allCountries[i];
|
|
@@ -118,7 +118,9 @@
|
|
|
118
118
|
return document.readyState === "complete";
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
|
-
if (typeof window === "object")
|
|
121
|
+
if (typeof window === "object") {
|
|
122
|
+
window.intlTelInputGlobals = intlTelInputGlobals;
|
|
123
|
+
}
|
|
122
124
|
// these vars persist through all instances of the plugin
|
|
123
125
|
var id = 0;
|
|
124
126
|
var defaults = {
|
|
@@ -147,7 +149,7 @@
|
|
|
147
149
|
initialCountry: "",
|
|
148
150
|
// localized country names e.g. { 'de': 'Deutschland' }
|
|
149
151
|
localizedCountries: null,
|
|
150
|
-
//
|
|
152
|
+
// national vs international formatting for numbers e.g. placeholders and displaying existing numbers
|
|
151
153
|
nationalMode: true,
|
|
152
154
|
// display only these countries
|
|
153
155
|
onlyCountries: [],
|
|
@@ -202,9 +204,13 @@
|
|
|
202
204
|
value: function _init() {
|
|
203
205
|
var _this2 = this;
|
|
204
206
|
// if in nationalMode, do not insert dial codes
|
|
205
|
-
if (this.options.nationalMode)
|
|
207
|
+
if (this.options.nationalMode) {
|
|
208
|
+
this.options.autoInsertDialCode = false;
|
|
209
|
+
}
|
|
206
210
|
// if separateDialCode enabled, do not insert dial codes
|
|
207
|
-
if (this.options.separateDialCode)
|
|
211
|
+
if (this.options.separateDialCode) {
|
|
212
|
+
this.options.autoInsertDialCode = false;
|
|
213
|
+
}
|
|
208
214
|
// force showFlags=true if there's a dropdown and we're not displaying the dial code,
|
|
209
215
|
// as otherwise you just have a down arrow on it's own which doesn't make sense
|
|
210
216
|
var forceShowFlags = this.options.allowDropdown && !this.options.separateDialCode;
|
|
@@ -221,7 +227,9 @@
|
|
|
221
227
|
// trigger the mobile dropdown css
|
|
222
228
|
document.body.classList.add("iti-mobile");
|
|
223
229
|
// on mobile, we want a full screen dropdown, so we must append it to the body
|
|
224
|
-
if (!this.options.dropdownContainer)
|
|
230
|
+
if (!this.options.dropdownContainer) {
|
|
231
|
+
this.options.dropdownContainer = document.body;
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
// these promises get resolved when their individual requests complete
|
|
227
235
|
// this way the dev can do something like iti.promise.then(...) to know when all requests are
|
|
@@ -265,7 +273,9 @@
|
|
|
265
273
|
// process the preferredCountries
|
|
266
274
|
this._processPreferredCountries();
|
|
267
275
|
// translate countries according to localizedCountries option
|
|
268
|
-
if (this.options.localizedCountries)
|
|
276
|
+
if (this.options.localizedCountries) {
|
|
277
|
+
this._translateCountriesByLocale();
|
|
278
|
+
}
|
|
269
279
|
// sort countries by name
|
|
270
280
|
if (this.options.onlyCountries.length || this.options.localizedCountries) {
|
|
271
281
|
this.countries.sort(this._countryNameSort);
|
|
@@ -282,7 +292,9 @@
|
|
|
282
292
|
}
|
|
283
293
|
// bail if we already have this country for this countryCode
|
|
284
294
|
for (var i = 0; i < this.countryCodes[countryCode].length; i++) {
|
|
285
|
-
if (this.countryCodes[countryCode][i] === iso2)
|
|
295
|
+
if (this.countryCodes[countryCode][i] === iso2) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
286
298
|
}
|
|
287
299
|
// check for undefined as 0 is falsy
|
|
288
300
|
var index = priority !== undefined ? priority : this.countryCodes[countryCode].length;
|
|
@@ -322,8 +334,12 @@
|
|
|
322
334
|
}, {
|
|
323
335
|
key: "_countryNameSort",
|
|
324
336
|
value: function _countryNameSort(a, b) {
|
|
325
|
-
if (a.name < b.name)
|
|
326
|
-
|
|
337
|
+
if (a.name < b.name) {
|
|
338
|
+
return -1;
|
|
339
|
+
}
|
|
340
|
+
if (a.name > b.name) {
|
|
341
|
+
return 1;
|
|
342
|
+
}
|
|
327
343
|
return 0;
|
|
328
344
|
}
|
|
329
345
|
}, {
|
|
@@ -337,7 +353,9 @@
|
|
|
337
353
|
// first: add dial codes
|
|
338
354
|
for (var i = 0; i < this.countries.length; i++) {
|
|
339
355
|
var c = this.countries[i];
|
|
340
|
-
if (!this.dialCodes[c.dialCode])
|
|
356
|
+
if (!this.dialCodes[c.dialCode]) {
|
|
357
|
+
this.dialCodes[c.dialCode] = true;
|
|
358
|
+
}
|
|
341
359
|
this._addCountryCode(c.iso2, c.dialCode, c.priority);
|
|
342
360
|
}
|
|
343
361
|
// next: add area codes
|
|
@@ -372,17 +390,23 @@
|
|
|
372
390
|
for (var i = 0; i < this.options.preferredCountries.length; i++) {
|
|
373
391
|
var countryCode = this.options.preferredCountries[i].toLowerCase();
|
|
374
392
|
var countryData = this._getCountryData(countryCode, false, true);
|
|
375
|
-
if (countryData)
|
|
393
|
+
if (countryData) {
|
|
394
|
+
this.preferredCountries.push(countryData);
|
|
395
|
+
}
|
|
376
396
|
}
|
|
377
397
|
}
|
|
378
398
|
}, {
|
|
379
399
|
key: "_createEl",
|
|
380
400
|
value: function _createEl(name, attrs, container) {
|
|
381
401
|
var el = document.createElement(name);
|
|
382
|
-
if (attrs)
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
402
|
+
if (attrs) {
|
|
403
|
+
forEachProp(attrs, function(key, value) {
|
|
404
|
+
return el.setAttribute(key, value);
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
if (container) {
|
|
408
|
+
container.appendChild(el);
|
|
409
|
+
}
|
|
386
410
|
return el;
|
|
387
411
|
}
|
|
388
412
|
}, {
|
|
@@ -391,16 +415,22 @@
|
|
|
391
415
|
// if autocomplete does not exist on the element and its form, then
|
|
392
416
|
// prevent autocomplete as there's no safe, cross-browser event we can react to, so it can
|
|
393
417
|
// easily put the plugin in an inconsistent state e.g. the wrong flag selected for the
|
|
394
|
-
// autocompleted number, which on submit could mean wrong number is saved
|
|
418
|
+
// autocompleted number, which on submit could mean wrong number is saved
|
|
395
419
|
if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
|
|
396
420
|
this.telInput.setAttribute("autocomplete", "off");
|
|
397
421
|
}
|
|
398
422
|
var _this$options = this.options, allowDropdown = _this$options.allowDropdown, separateDialCode = _this$options.separateDialCode, showFlags = _this$options.showFlags, customContainer = _this$options.customContainer, hiddenInput = _this$options.hiddenInput, dropdownContainer = _this$options.dropdownContainer;
|
|
399
423
|
// containers (mostly for positioning)
|
|
400
424
|
var parentClass = "iti";
|
|
401
|
-
if (allowDropdown)
|
|
402
|
-
|
|
403
|
-
|
|
425
|
+
if (allowDropdown) {
|
|
426
|
+
parentClass += " iti--allow-dropdown";
|
|
427
|
+
}
|
|
428
|
+
if (separateDialCode) {
|
|
429
|
+
parentClass += " iti--separate-dial-code";
|
|
430
|
+
}
|
|
431
|
+
if (showFlags) {
|
|
432
|
+
parentClass += " iti--show-flags";
|
|
433
|
+
}
|
|
404
434
|
if (customContainer) {
|
|
405
435
|
parentClass += " ".concat(customContainer);
|
|
406
436
|
}
|
|
@@ -485,7 +515,9 @@
|
|
|
485
515
|
var i = name.lastIndexOf("[");
|
|
486
516
|
// if input name contains square brackets, then give the hidden input the same name,
|
|
487
517
|
// replacing the contents of the last set of brackets with the given hiddenInput name
|
|
488
|
-
if (i !== -1)
|
|
518
|
+
if (i !== -1) {
|
|
519
|
+
hiddenInputName = "".concat(name.substr(0, i), "[").concat(hiddenInputName, "]");
|
|
520
|
+
}
|
|
489
521
|
}
|
|
490
522
|
this.hiddenInput = this._createEl("input", {
|
|
491
523
|
type: "hidden",
|
|
@@ -558,15 +590,23 @@
|
|
|
558
590
|
}
|
|
559
591
|
// NOTE: if initialCountry is set to auto, that will be handled separately
|
|
560
592
|
// format - note this wont be run after _updateDialCode as that's only called if no val
|
|
561
|
-
if (val)
|
|
593
|
+
if (val) {
|
|
594
|
+
this._updateValFromNumber(val);
|
|
595
|
+
}
|
|
562
596
|
}
|
|
563
597
|
}, {
|
|
564
598
|
key: "_initListeners",
|
|
565
599
|
value: function _initListeners() {
|
|
566
600
|
this._initKeyListeners();
|
|
567
|
-
if (this.options.autoInsertDialCode)
|
|
568
|
-
|
|
569
|
-
|
|
601
|
+
if (this.options.autoInsertDialCode) {
|
|
602
|
+
this._initBlurListeners();
|
|
603
|
+
}
|
|
604
|
+
if (this.options.allowDropdown) {
|
|
605
|
+
this._initDropdownListeners();
|
|
606
|
+
}
|
|
607
|
+
if (this.hiddenInput) {
|
|
608
|
+
this._initHiddenInputListener();
|
|
609
|
+
}
|
|
570
610
|
}
|
|
571
611
|
}, {
|
|
572
612
|
key: "_initHiddenInputListener",
|
|
@@ -575,7 +615,9 @@
|
|
|
575
615
|
this._handleHiddenInputSubmit = function() {
|
|
576
616
|
_this3.hiddenInput.value = _this3.getNumber();
|
|
577
617
|
};
|
|
578
|
-
if (this.telInput.form)
|
|
618
|
+
if (this.telInput.form) {
|
|
619
|
+
this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
|
|
620
|
+
}
|
|
579
621
|
}
|
|
580
622
|
}, {
|
|
581
623
|
key: "_getClosestLabel",
|
|
@@ -595,10 +637,16 @@
|
|
|
595
637
|
// close it again
|
|
596
638
|
this._handleLabelClick = function(e) {
|
|
597
639
|
// if the dropdown is closed, then focus the input, else ignore the click
|
|
598
|
-
if (_this4.countryList.classList.contains("iti__hide"))
|
|
640
|
+
if (_this4.countryList.classList.contains("iti__hide")) {
|
|
641
|
+
_this4.telInput.focus();
|
|
642
|
+
} else {
|
|
643
|
+
e.preventDefault();
|
|
644
|
+
}
|
|
599
645
|
};
|
|
600
646
|
var label = this._getClosestLabel();
|
|
601
|
-
if (label)
|
|
647
|
+
if (label) {
|
|
648
|
+
label.addEventListener("click", this._handleLabelClick);
|
|
649
|
+
}
|
|
602
650
|
// toggle country dropdown on click
|
|
603
651
|
this._handleClickSelectedFlag = function() {
|
|
604
652
|
// only intercept this event if we're opening the dropdown
|
|
@@ -620,7 +668,9 @@
|
|
|
620
668
|
_this4._showDropdown();
|
|
621
669
|
}
|
|
622
670
|
// allow navigation from dropdown to input on TAB
|
|
623
|
-
if (e.key === "Tab")
|
|
671
|
+
if (e.key === "Tab") {
|
|
672
|
+
_this4._closeDropdown();
|
|
673
|
+
}
|
|
624
674
|
};
|
|
625
675
|
this.flagsContainer.addEventListener("keydown", this._handleFlagsContainerKeydown);
|
|
626
676
|
}
|
|
@@ -639,8 +689,14 @@
|
|
|
639
689
|
window.intlTelInputGlobals.loadUtils(_this5.options.utilsScript);
|
|
640
690
|
});
|
|
641
691
|
}
|
|
642
|
-
} else
|
|
643
|
-
|
|
692
|
+
} else {
|
|
693
|
+
this.resolveUtilsScriptPromise();
|
|
694
|
+
}
|
|
695
|
+
if (this.options.initialCountry === "auto") {
|
|
696
|
+
this._loadAutoCountry();
|
|
697
|
+
} else {
|
|
698
|
+
this.resolveAutoCountryPromise();
|
|
699
|
+
}
|
|
644
700
|
}
|
|
645
701
|
}, {
|
|
646
702
|
key: "_loadAutoCountry",
|
|
@@ -705,7 +761,9 @@
|
|
|
705
761
|
this._handleSubmitOrBlurEvent = function() {
|
|
706
762
|
_this7._removeEmptyDialCode();
|
|
707
763
|
};
|
|
708
|
-
if (this.telInput.form)
|
|
764
|
+
if (this.telInput.form) {
|
|
765
|
+
this.telInput.form.addEventListener("submit", this._handleSubmitOrBlurEvent);
|
|
766
|
+
}
|
|
709
767
|
this.telInput.addEventListener("blur", this._handleSubmitOrBlurEvent);
|
|
710
768
|
}
|
|
711
769
|
}, {
|
|
@@ -753,7 +811,11 @@
|
|
|
753
811
|
}, {
|
|
754
812
|
key: "_toggleClass",
|
|
755
813
|
value: function _toggleClass(el, className, shouldHaveClass) {
|
|
756
|
-
if (shouldHaveClass && !el.classList.contains(className))
|
|
814
|
+
if (shouldHaveClass && !el.classList.contains(className)) {
|
|
815
|
+
el.classList.add(className);
|
|
816
|
+
} else if (!shouldHaveClass && el.classList.contains(className)) {
|
|
817
|
+
el.classList.remove(className);
|
|
818
|
+
}
|
|
757
819
|
}
|
|
758
820
|
}, {
|
|
759
821
|
key: "_setDropdownPosition",
|
|
@@ -809,13 +871,17 @@
|
|
|
809
871
|
this._handleMouseoverCountryList = function(e) {
|
|
810
872
|
// handle event delegation, as we're listening for this event on the countryList
|
|
811
873
|
var listItem = _this9._getClosestListItem(e.target);
|
|
812
|
-
if (listItem)
|
|
874
|
+
if (listItem) {
|
|
875
|
+
_this9._highlightListItem(listItem, false);
|
|
876
|
+
}
|
|
813
877
|
};
|
|
814
878
|
this.countryList.addEventListener("mouseover", this._handleMouseoverCountryList);
|
|
815
879
|
// listen for country selection
|
|
816
880
|
this._handleClickCountryList = function(e) {
|
|
817
881
|
var listItem = _this9._getClosestListItem(e.target);
|
|
818
|
-
if (listItem)
|
|
882
|
+
if (listItem) {
|
|
883
|
+
_this9._selectListItem(listItem);
|
|
884
|
+
}
|
|
819
885
|
};
|
|
820
886
|
this.countryList.addEventListener("click", this._handleClickCountryList);
|
|
821
887
|
// click off to close
|
|
@@ -823,7 +889,9 @@
|
|
|
823
889
|
// we cannot just stopPropagation as it may be needed to close another instance
|
|
824
890
|
var isOpening = true;
|
|
825
891
|
this._handleClickOffToClose = function() {
|
|
826
|
-
if (!isOpening)
|
|
892
|
+
if (!isOpening) {
|
|
893
|
+
_this9._closeDropdown();
|
|
894
|
+
}
|
|
827
895
|
isOpening = false;
|
|
828
896
|
};
|
|
829
897
|
document.documentElement.addEventListener("click", this._handleClickOffToClose);
|
|
@@ -838,9 +906,17 @@
|
|
|
838
906
|
// and enter key from submitting a form etc
|
|
839
907
|
e.preventDefault();
|
|
840
908
|
// up and down to navigate
|
|
841
|
-
if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down")
|
|
909
|
+
if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down") {
|
|
910
|
+
_this9._handleUpDownKey(e.key);
|
|
911
|
+
} else if (e.key === "Enter") {
|
|
912
|
+
_this9._handleEnterKey();
|
|
913
|
+
} else if (e.key === "Escape") {
|
|
914
|
+
_this9._closeDropdown();
|
|
915
|
+
} else if (/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
|
|
842
916
|
// jump to countries that start with the query string
|
|
843
|
-
if (queryTimer)
|
|
917
|
+
if (queryTimer) {
|
|
918
|
+
clearTimeout(queryTimer);
|
|
919
|
+
}
|
|
844
920
|
query += e.key.toLowerCase();
|
|
845
921
|
_this9._searchForCountry(query);
|
|
846
922
|
// if the timer hits 1 second, reset the query
|
|
@@ -866,7 +942,9 @@
|
|
|
866
942
|
}, {
|
|
867
943
|
key: "_handleEnterKey",
|
|
868
944
|
value: function _handleEnterKey() {
|
|
869
|
-
if (this.highlightedItem)
|
|
945
|
+
if (this.highlightedItem) {
|
|
946
|
+
this._selectListItem(this.highlightedItem);
|
|
947
|
+
}
|
|
870
948
|
}
|
|
871
949
|
}, {
|
|
872
950
|
key: "_searchForCountry",
|
|
@@ -902,7 +980,7 @@
|
|
|
902
980
|
}, {
|
|
903
981
|
key: "_updateFlagFromNumber",
|
|
904
982
|
value: function _updateFlagFromNumber(originalNumber) {
|
|
905
|
-
// if we
|
|
983
|
+
// if we already have US/Canada selected, make sure the number starts
|
|
906
984
|
// with a +1 so _getDialCode will be able to extract the area code
|
|
907
985
|
// update: if we dont yet have selectedCountryData, but we're here (trying to update the flag
|
|
908
986
|
// from the number), that means we're initialising the plugin with a number that already has a
|
|
@@ -910,8 +988,10 @@
|
|
|
910
988
|
var number = originalNumber;
|
|
911
989
|
var selectedDialCode = this.selectedCountryData.dialCode;
|
|
912
990
|
var isNanp = selectedDialCode === "1";
|
|
913
|
-
if (number &&
|
|
914
|
-
if (number.charAt(0) !== "1")
|
|
991
|
+
if (number && isNanp && number.charAt(0) !== "+") {
|
|
992
|
+
if (number.charAt(0) !== "1") {
|
|
993
|
+
number = "1".concat(number);
|
|
994
|
+
}
|
|
915
995
|
number = "+".concat(number);
|
|
916
996
|
}
|
|
917
997
|
// if separateDialCode enabled, then consider the selected dial code to be part of the number
|
|
@@ -972,11 +1052,15 @@
|
|
|
972
1052
|
key: "_highlightListItem",
|
|
973
1053
|
value: function _highlightListItem(listItem, shouldFocus) {
|
|
974
1054
|
var prevItem = this.highlightedItem;
|
|
975
|
-
if (prevItem)
|
|
1055
|
+
if (prevItem) {
|
|
1056
|
+
prevItem.classList.remove("iti__highlight");
|
|
1057
|
+
}
|
|
976
1058
|
this.highlightedItem = listItem;
|
|
977
1059
|
this.highlightedItem.classList.add("iti__highlight");
|
|
978
1060
|
this.selectedFlag.setAttribute("aria-activedescendant", listItem.getAttribute("id"));
|
|
979
|
-
if (shouldFocus)
|
|
1061
|
+
if (shouldFocus) {
|
|
1062
|
+
this.highlightedItem.focus();
|
|
1063
|
+
}
|
|
980
1064
|
}
|
|
981
1065
|
}, {
|
|
982
1066
|
key: "_getCountryData",
|
|
@@ -1077,8 +1161,8 @@
|
|
|
1077
1161
|
this._updateDialCode(listItem.getAttribute("data-dial-code"));
|
|
1078
1162
|
// focus the input
|
|
1079
1163
|
this.telInput.focus();
|
|
1080
|
-
// put cursor at end - this fix is required for FF and IE11 (with
|
|
1081
|
-
//
|
|
1164
|
+
// put cursor at end - this fix is required for FF and IE11 (with auto inserting dial code),
|
|
1165
|
+
// who try to put the cursor at the beginning the first time
|
|
1082
1166
|
var len = this.telInput.value.length;
|
|
1083
1167
|
this.telInput.setSelectionRange(len, len);
|
|
1084
1168
|
if (flagChanged) {
|
|
@@ -1100,8 +1184,12 @@
|
|
|
1100
1184
|
this.countryList.removeEventListener("click", this._handleClickCountryList);
|
|
1101
1185
|
// remove menu from container
|
|
1102
1186
|
if (this.options.dropdownContainer) {
|
|
1103
|
-
if (!this.isMobile)
|
|
1104
|
-
|
|
1187
|
+
if (!this.isMobile) {
|
|
1188
|
+
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
1189
|
+
}
|
|
1190
|
+
if (this.dropdown.parentNode) {
|
|
1191
|
+
this.dropdown.parentNode.removeChild(this.dropdown);
|
|
1192
|
+
}
|
|
1105
1193
|
}
|
|
1106
1194
|
this._trigger("close:countrydropdown");
|
|
1107
1195
|
}
|
|
@@ -1121,11 +1209,15 @@
|
|
|
1121
1209
|
var middleOffset = containerHeight / 2 - elementHeight / 2;
|
|
1122
1210
|
if (elementTop < containerTop) {
|
|
1123
1211
|
// scroll up
|
|
1124
|
-
if (middle)
|
|
1212
|
+
if (middle) {
|
|
1213
|
+
newScrollTop -= middleOffset;
|
|
1214
|
+
}
|
|
1125
1215
|
container.scrollTop = newScrollTop;
|
|
1126
1216
|
} else if (elementBottom > containerBottom) {
|
|
1127
1217
|
// scroll down
|
|
1128
|
-
if (middle)
|
|
1218
|
+
if (middle) {
|
|
1219
|
+
newScrollTop += middleOffset;
|
|
1220
|
+
}
|
|
1129
1221
|
var heightDifference = containerHeight - elementHeight;
|
|
1130
1222
|
container.scrollTop = newScrollTop - heightDifference;
|
|
1131
1223
|
}
|
|
@@ -1138,7 +1230,7 @@
|
|
|
1138
1230
|
var newDialCode = "+".concat(newDialCodeBare);
|
|
1139
1231
|
var newNumber;
|
|
1140
1232
|
if (inputVal.charAt(0) === "+") {
|
|
1141
|
-
// there's a plus so we're dealing with a replacement
|
|
1233
|
+
// there's a plus so we're dealing with a replacement
|
|
1142
1234
|
var prevDialCode = this._getDialCode(inputVal);
|
|
1143
1235
|
if (prevDialCode) {
|
|
1144
1236
|
// current number contains a valid dial code, so replace it
|
|
@@ -1272,13 +1364,19 @@
|
|
|
1272
1364
|
this.flagsContainer.removeEventListener("keydown", this._handleFlagsContainerKeydown);
|
|
1273
1365
|
// label click hack
|
|
1274
1366
|
var label = this._getClosestLabel();
|
|
1275
|
-
if (label)
|
|
1367
|
+
if (label) {
|
|
1368
|
+
label.removeEventListener("click", this._handleLabelClick);
|
|
1369
|
+
}
|
|
1276
1370
|
}
|
|
1277
1371
|
// unbind hiddenInput listeners
|
|
1278
|
-
if (this.hiddenInput && form)
|
|
1372
|
+
if (this.hiddenInput && form) {
|
|
1373
|
+
form.removeEventListener("submit", this._handleHiddenInputSubmit);
|
|
1374
|
+
}
|
|
1279
1375
|
// unbind autoInsertDialCode listeners
|
|
1280
1376
|
if (this.options.autoInsertDialCode) {
|
|
1281
|
-
if (form)
|
|
1377
|
+
if (form) {
|
|
1378
|
+
form.removeEventListener("submit", this._handleSubmitOrBlurEvent);
|
|
1379
|
+
}
|
|
1282
1380
|
this.telInput.removeEventListener("blur", this._handleSubmitOrBlurEvent);
|
|
1283
1381
|
}
|
|
1284
1382
|
// unbind key events, and cut/paste events
|
|
@@ -1336,8 +1434,7 @@
|
|
|
1336
1434
|
key: "isValidNumber",
|
|
1337
1435
|
value: function isValidNumber() {
|
|
1338
1436
|
var val = this._getFullNumber().trim();
|
|
1339
|
-
|
|
1340
|
-
return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null;
|
|
1437
|
+
return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
1341
1438
|
}
|
|
1342
1439
|
}, {
|
|
1343
1440
|
key: "setCountry",
|
|
@@ -1383,11 +1480,15 @@
|
|
|
1383
1480
|
var script = document.createElement("script");
|
|
1384
1481
|
script.onload = function() {
|
|
1385
1482
|
forEachInstance("handleUtils");
|
|
1386
|
-
if (handleSuccess)
|
|
1483
|
+
if (handleSuccess) {
|
|
1484
|
+
handleSuccess();
|
|
1485
|
+
}
|
|
1387
1486
|
};
|
|
1388
1487
|
script.onerror = function() {
|
|
1389
1488
|
forEachInstance("rejectUtilsScriptPromise");
|
|
1390
|
-
if (handleFailure)
|
|
1489
|
+
if (handleFailure) {
|
|
1490
|
+
handleFailure();
|
|
1491
|
+
}
|
|
1391
1492
|
};
|
|
1392
1493
|
script.className = "iti-load-utils";
|
|
1393
1494
|
script.async = true;
|
|
@@ -1416,7 +1517,7 @@
|
|
|
1416
1517
|
// default options
|
|
1417
1518
|
intlTelInputGlobals.defaults = defaults;
|
|
1418
1519
|
// version
|
|
1419
|
-
intlTelInputGlobals.version = "18.1.
|
|
1520
|
+
intlTelInputGlobals.version = "18.1.2";
|
|
1420
1521
|
var pluginName = "intlTelInput";
|
|
1421
1522
|
// A really lightweight plugin wrapper around the constructor,
|
|
1422
1523
|
// preventing against multiple instantiations
|