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
package/build/js/intlTelInput.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// Order (if >1 country with same dial code),
|
|
25
25
|
// Area codes
|
|
26
26
|
// ]
|
|
27
|
-
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" ] ] ];
|
|
27
|
+
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" ] ] ];
|
|
28
28
|
// loop over all of the countries above, restructuring the data to be objects with named keys
|
|
29
29
|
for (var i = 0; i < allCountries.length; i++) {
|
|
30
30
|
var c = allCountries[i];
|
|
@@ -113,7 +113,9 @@
|
|
|
113
113
|
return document.readyState === "complete";
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
if (typeof window === "object")
|
|
116
|
+
if (typeof window === "object") {
|
|
117
|
+
window.intlTelInputGlobals = intlTelInputGlobals;
|
|
118
|
+
}
|
|
117
119
|
// these vars persist through all instances of the plugin
|
|
118
120
|
var id = 0;
|
|
119
121
|
var defaults = {
|
|
@@ -142,7 +144,7 @@
|
|
|
142
144
|
initialCountry: "",
|
|
143
145
|
// localized country names e.g. { 'de': 'Deutschland' }
|
|
144
146
|
localizedCountries: null,
|
|
145
|
-
//
|
|
147
|
+
// national vs international formatting for numbers e.g. placeholders and displaying existing numbers
|
|
146
148
|
nationalMode: true,
|
|
147
149
|
// display only these countries
|
|
148
150
|
onlyCountries: [],
|
|
@@ -197,9 +199,13 @@
|
|
|
197
199
|
value: function _init() {
|
|
198
200
|
var _this2 = this;
|
|
199
201
|
// if in nationalMode, do not insert dial codes
|
|
200
|
-
if (this.options.nationalMode)
|
|
202
|
+
if (this.options.nationalMode) {
|
|
203
|
+
this.options.autoInsertDialCode = false;
|
|
204
|
+
}
|
|
201
205
|
// if separateDialCode enabled, do not insert dial codes
|
|
202
|
-
if (this.options.separateDialCode)
|
|
206
|
+
if (this.options.separateDialCode) {
|
|
207
|
+
this.options.autoInsertDialCode = false;
|
|
208
|
+
}
|
|
203
209
|
// force showFlags=true if there's a dropdown and we're not displaying the dial code,
|
|
204
210
|
// as otherwise you just have a down arrow on it's own which doesn't make sense
|
|
205
211
|
var forceShowFlags = this.options.allowDropdown && !this.options.separateDialCode;
|
|
@@ -216,7 +222,9 @@
|
|
|
216
222
|
// trigger the mobile dropdown css
|
|
217
223
|
document.body.classList.add("iti-mobile");
|
|
218
224
|
// on mobile, we want a full screen dropdown, so we must append it to the body
|
|
219
|
-
if (!this.options.dropdownContainer)
|
|
225
|
+
if (!this.options.dropdownContainer) {
|
|
226
|
+
this.options.dropdownContainer = document.body;
|
|
227
|
+
}
|
|
220
228
|
}
|
|
221
229
|
// these promises get resolved when their individual requests complete
|
|
222
230
|
// this way the dev can do something like iti.promise.then(...) to know when all requests are
|
|
@@ -260,7 +268,9 @@
|
|
|
260
268
|
// process the preferredCountries
|
|
261
269
|
this._processPreferredCountries();
|
|
262
270
|
// translate countries according to localizedCountries option
|
|
263
|
-
if (this.options.localizedCountries)
|
|
271
|
+
if (this.options.localizedCountries) {
|
|
272
|
+
this._translateCountriesByLocale();
|
|
273
|
+
}
|
|
264
274
|
// sort countries by name
|
|
265
275
|
if (this.options.onlyCountries.length || this.options.localizedCountries) {
|
|
266
276
|
this.countries.sort(this._countryNameSort);
|
|
@@ -277,7 +287,9 @@
|
|
|
277
287
|
}
|
|
278
288
|
// bail if we already have this country for this countryCode
|
|
279
289
|
for (var i = 0; i < this.countryCodes[countryCode].length; i++) {
|
|
280
|
-
if (this.countryCodes[countryCode][i] === iso2)
|
|
290
|
+
if (this.countryCodes[countryCode][i] === iso2) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
281
293
|
}
|
|
282
294
|
// check for undefined as 0 is falsy
|
|
283
295
|
var index = priority !== undefined ? priority : this.countryCodes[countryCode].length;
|
|
@@ -317,8 +329,12 @@
|
|
|
317
329
|
}, {
|
|
318
330
|
key: "_countryNameSort",
|
|
319
331
|
value: function _countryNameSort(a, b) {
|
|
320
|
-
if (a.name < b.name)
|
|
321
|
-
|
|
332
|
+
if (a.name < b.name) {
|
|
333
|
+
return -1;
|
|
334
|
+
}
|
|
335
|
+
if (a.name > b.name) {
|
|
336
|
+
return 1;
|
|
337
|
+
}
|
|
322
338
|
return 0;
|
|
323
339
|
}
|
|
324
340
|
}, {
|
|
@@ -332,7 +348,9 @@
|
|
|
332
348
|
// first: add dial codes
|
|
333
349
|
for (var i = 0; i < this.countries.length; i++) {
|
|
334
350
|
var c = this.countries[i];
|
|
335
|
-
if (!this.dialCodes[c.dialCode])
|
|
351
|
+
if (!this.dialCodes[c.dialCode]) {
|
|
352
|
+
this.dialCodes[c.dialCode] = true;
|
|
353
|
+
}
|
|
336
354
|
this._addCountryCode(c.iso2, c.dialCode, c.priority);
|
|
337
355
|
}
|
|
338
356
|
// next: add area codes
|
|
@@ -367,17 +385,23 @@
|
|
|
367
385
|
for (var i = 0; i < this.options.preferredCountries.length; i++) {
|
|
368
386
|
var countryCode = this.options.preferredCountries[i].toLowerCase();
|
|
369
387
|
var countryData = this._getCountryData(countryCode, false, true);
|
|
370
|
-
if (countryData)
|
|
388
|
+
if (countryData) {
|
|
389
|
+
this.preferredCountries.push(countryData);
|
|
390
|
+
}
|
|
371
391
|
}
|
|
372
392
|
}
|
|
373
393
|
}, {
|
|
374
394
|
key: "_createEl",
|
|
375
395
|
value: function _createEl(name, attrs, container) {
|
|
376
396
|
var el = document.createElement(name);
|
|
377
|
-
if (attrs)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
397
|
+
if (attrs) {
|
|
398
|
+
forEachProp(attrs, function(key, value) {
|
|
399
|
+
return el.setAttribute(key, value);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
if (container) {
|
|
403
|
+
container.appendChild(el);
|
|
404
|
+
}
|
|
381
405
|
return el;
|
|
382
406
|
}
|
|
383
407
|
}, {
|
|
@@ -386,16 +410,22 @@
|
|
|
386
410
|
// if autocomplete does not exist on the element and its form, then
|
|
387
411
|
// prevent autocomplete as there's no safe, cross-browser event we can react to, so it can
|
|
388
412
|
// easily put the plugin in an inconsistent state e.g. the wrong flag selected for the
|
|
389
|
-
// autocompleted number, which on submit could mean wrong number is saved
|
|
413
|
+
// autocompleted number, which on submit could mean wrong number is saved
|
|
390
414
|
if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
|
|
391
415
|
this.telInput.setAttribute("autocomplete", "off");
|
|
392
416
|
}
|
|
393
417
|
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;
|
|
394
418
|
// containers (mostly for positioning)
|
|
395
419
|
var parentClass = "iti";
|
|
396
|
-
if (allowDropdown)
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
if (allowDropdown) {
|
|
421
|
+
parentClass += " iti--allow-dropdown";
|
|
422
|
+
}
|
|
423
|
+
if (separateDialCode) {
|
|
424
|
+
parentClass += " iti--separate-dial-code";
|
|
425
|
+
}
|
|
426
|
+
if (showFlags) {
|
|
427
|
+
parentClass += " iti--show-flags";
|
|
428
|
+
}
|
|
399
429
|
if (customContainer) {
|
|
400
430
|
parentClass += " ".concat(customContainer);
|
|
401
431
|
}
|
|
@@ -480,7 +510,9 @@
|
|
|
480
510
|
var i = name.lastIndexOf("[");
|
|
481
511
|
// if input name contains square brackets, then give the hidden input the same name,
|
|
482
512
|
// replacing the contents of the last set of brackets with the given hiddenInput name
|
|
483
|
-
if (i !== -1)
|
|
513
|
+
if (i !== -1) {
|
|
514
|
+
hiddenInputName = "".concat(name.substr(0, i), "[").concat(hiddenInputName, "]");
|
|
515
|
+
}
|
|
484
516
|
}
|
|
485
517
|
this.hiddenInput = this._createEl("input", {
|
|
486
518
|
type: "hidden",
|
|
@@ -553,15 +585,23 @@
|
|
|
553
585
|
}
|
|
554
586
|
// NOTE: if initialCountry is set to auto, that will be handled separately
|
|
555
587
|
// format - note this wont be run after _updateDialCode as that's only called if no val
|
|
556
|
-
if (val)
|
|
588
|
+
if (val) {
|
|
589
|
+
this._updateValFromNumber(val);
|
|
590
|
+
}
|
|
557
591
|
}
|
|
558
592
|
}, {
|
|
559
593
|
key: "_initListeners",
|
|
560
594
|
value: function _initListeners() {
|
|
561
595
|
this._initKeyListeners();
|
|
562
|
-
if (this.options.autoInsertDialCode)
|
|
563
|
-
|
|
564
|
-
|
|
596
|
+
if (this.options.autoInsertDialCode) {
|
|
597
|
+
this._initBlurListeners();
|
|
598
|
+
}
|
|
599
|
+
if (this.options.allowDropdown) {
|
|
600
|
+
this._initDropdownListeners();
|
|
601
|
+
}
|
|
602
|
+
if (this.hiddenInput) {
|
|
603
|
+
this._initHiddenInputListener();
|
|
604
|
+
}
|
|
565
605
|
}
|
|
566
606
|
}, {
|
|
567
607
|
key: "_initHiddenInputListener",
|
|
@@ -570,7 +610,9 @@
|
|
|
570
610
|
this._handleHiddenInputSubmit = function() {
|
|
571
611
|
_this3.hiddenInput.value = _this3.getNumber();
|
|
572
612
|
};
|
|
573
|
-
if (this.telInput.form)
|
|
613
|
+
if (this.telInput.form) {
|
|
614
|
+
this.telInput.form.addEventListener("submit", this._handleHiddenInputSubmit);
|
|
615
|
+
}
|
|
574
616
|
}
|
|
575
617
|
}, {
|
|
576
618
|
key: "_getClosestLabel",
|
|
@@ -590,10 +632,16 @@
|
|
|
590
632
|
// close it again
|
|
591
633
|
this._handleLabelClick = function(e) {
|
|
592
634
|
// if the dropdown is closed, then focus the input, else ignore the click
|
|
593
|
-
if (_this4.countryList.classList.contains("iti__hide"))
|
|
635
|
+
if (_this4.countryList.classList.contains("iti__hide")) {
|
|
636
|
+
_this4.telInput.focus();
|
|
637
|
+
} else {
|
|
638
|
+
e.preventDefault();
|
|
639
|
+
}
|
|
594
640
|
};
|
|
595
641
|
var label = this._getClosestLabel();
|
|
596
|
-
if (label)
|
|
642
|
+
if (label) {
|
|
643
|
+
label.addEventListener("click", this._handleLabelClick);
|
|
644
|
+
}
|
|
597
645
|
// toggle country dropdown on click
|
|
598
646
|
this._handleClickSelectedFlag = function() {
|
|
599
647
|
// only intercept this event if we're opening the dropdown
|
|
@@ -615,7 +663,9 @@
|
|
|
615
663
|
_this4._showDropdown();
|
|
616
664
|
}
|
|
617
665
|
// allow navigation from dropdown to input on TAB
|
|
618
|
-
if (e.key === "Tab")
|
|
666
|
+
if (e.key === "Tab") {
|
|
667
|
+
_this4._closeDropdown();
|
|
668
|
+
}
|
|
619
669
|
};
|
|
620
670
|
this.flagsContainer.addEventListener("keydown", this._handleFlagsContainerKeydown);
|
|
621
671
|
}
|
|
@@ -634,8 +684,14 @@
|
|
|
634
684
|
window.intlTelInputGlobals.loadUtils(_this5.options.utilsScript);
|
|
635
685
|
});
|
|
636
686
|
}
|
|
637
|
-
} else
|
|
638
|
-
|
|
687
|
+
} else {
|
|
688
|
+
this.resolveUtilsScriptPromise();
|
|
689
|
+
}
|
|
690
|
+
if (this.options.initialCountry === "auto") {
|
|
691
|
+
this._loadAutoCountry();
|
|
692
|
+
} else {
|
|
693
|
+
this.resolveAutoCountryPromise();
|
|
694
|
+
}
|
|
639
695
|
}
|
|
640
696
|
}, {
|
|
641
697
|
key: "_loadAutoCountry",
|
|
@@ -700,7 +756,9 @@
|
|
|
700
756
|
this._handleSubmitOrBlurEvent = function() {
|
|
701
757
|
_this7._removeEmptyDialCode();
|
|
702
758
|
};
|
|
703
|
-
if (this.telInput.form)
|
|
759
|
+
if (this.telInput.form) {
|
|
760
|
+
this.telInput.form.addEventListener("submit", this._handleSubmitOrBlurEvent);
|
|
761
|
+
}
|
|
704
762
|
this.telInput.addEventListener("blur", this._handleSubmitOrBlurEvent);
|
|
705
763
|
}
|
|
706
764
|
}, {
|
|
@@ -748,7 +806,11 @@
|
|
|
748
806
|
}, {
|
|
749
807
|
key: "_toggleClass",
|
|
750
808
|
value: function _toggleClass(el, className, shouldHaveClass) {
|
|
751
|
-
if (shouldHaveClass && !el.classList.contains(className))
|
|
809
|
+
if (shouldHaveClass && !el.classList.contains(className)) {
|
|
810
|
+
el.classList.add(className);
|
|
811
|
+
} else if (!shouldHaveClass && el.classList.contains(className)) {
|
|
812
|
+
el.classList.remove(className);
|
|
813
|
+
}
|
|
752
814
|
}
|
|
753
815
|
}, {
|
|
754
816
|
key: "_setDropdownPosition",
|
|
@@ -804,13 +866,17 @@
|
|
|
804
866
|
this._handleMouseoverCountryList = function(e) {
|
|
805
867
|
// handle event delegation, as we're listening for this event on the countryList
|
|
806
868
|
var listItem = _this9._getClosestListItem(e.target);
|
|
807
|
-
if (listItem)
|
|
869
|
+
if (listItem) {
|
|
870
|
+
_this9._highlightListItem(listItem, false);
|
|
871
|
+
}
|
|
808
872
|
};
|
|
809
873
|
this.countryList.addEventListener("mouseover", this._handleMouseoverCountryList);
|
|
810
874
|
// listen for country selection
|
|
811
875
|
this._handleClickCountryList = function(e) {
|
|
812
876
|
var listItem = _this9._getClosestListItem(e.target);
|
|
813
|
-
if (listItem)
|
|
877
|
+
if (listItem) {
|
|
878
|
+
_this9._selectListItem(listItem);
|
|
879
|
+
}
|
|
814
880
|
};
|
|
815
881
|
this.countryList.addEventListener("click", this._handleClickCountryList);
|
|
816
882
|
// click off to close
|
|
@@ -818,7 +884,9 @@
|
|
|
818
884
|
// we cannot just stopPropagation as it may be needed to close another instance
|
|
819
885
|
var isOpening = true;
|
|
820
886
|
this._handleClickOffToClose = function() {
|
|
821
|
-
if (!isOpening)
|
|
887
|
+
if (!isOpening) {
|
|
888
|
+
_this9._closeDropdown();
|
|
889
|
+
}
|
|
822
890
|
isOpening = false;
|
|
823
891
|
};
|
|
824
892
|
document.documentElement.addEventListener("click", this._handleClickOffToClose);
|
|
@@ -833,9 +901,17 @@
|
|
|
833
901
|
// and enter key from submitting a form etc
|
|
834
902
|
e.preventDefault();
|
|
835
903
|
// up and down to navigate
|
|
836
|
-
if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down")
|
|
904
|
+
if (e.key === "ArrowUp" || e.key === "Up" || e.key === "ArrowDown" || e.key === "Down") {
|
|
905
|
+
_this9._handleUpDownKey(e.key);
|
|
906
|
+
} else if (e.key === "Enter") {
|
|
907
|
+
_this9._handleEnterKey();
|
|
908
|
+
} else if (e.key === "Escape") {
|
|
909
|
+
_this9._closeDropdown();
|
|
910
|
+
} else if (/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
|
|
837
911
|
// jump to countries that start with the query string
|
|
838
|
-
if (queryTimer)
|
|
912
|
+
if (queryTimer) {
|
|
913
|
+
clearTimeout(queryTimer);
|
|
914
|
+
}
|
|
839
915
|
query += e.key.toLowerCase();
|
|
840
916
|
_this9._searchForCountry(query);
|
|
841
917
|
// if the timer hits 1 second, reset the query
|
|
@@ -861,7 +937,9 @@
|
|
|
861
937
|
}, {
|
|
862
938
|
key: "_handleEnterKey",
|
|
863
939
|
value: function _handleEnterKey() {
|
|
864
|
-
if (this.highlightedItem)
|
|
940
|
+
if (this.highlightedItem) {
|
|
941
|
+
this._selectListItem(this.highlightedItem);
|
|
942
|
+
}
|
|
865
943
|
}
|
|
866
944
|
}, {
|
|
867
945
|
key: "_searchForCountry",
|
|
@@ -897,7 +975,7 @@
|
|
|
897
975
|
}, {
|
|
898
976
|
key: "_updateFlagFromNumber",
|
|
899
977
|
value: function _updateFlagFromNumber(originalNumber) {
|
|
900
|
-
// if we
|
|
978
|
+
// if we already have US/Canada selected, make sure the number starts
|
|
901
979
|
// with a +1 so _getDialCode will be able to extract the area code
|
|
902
980
|
// update: if we dont yet have selectedCountryData, but we're here (trying to update the flag
|
|
903
981
|
// from the number), that means we're initialising the plugin with a number that already has a
|
|
@@ -905,8 +983,10 @@
|
|
|
905
983
|
var number = originalNumber;
|
|
906
984
|
var selectedDialCode = this.selectedCountryData.dialCode;
|
|
907
985
|
var isNanp = selectedDialCode === "1";
|
|
908
|
-
if (number &&
|
|
909
|
-
if (number.charAt(0) !== "1")
|
|
986
|
+
if (number && isNanp && number.charAt(0) !== "+") {
|
|
987
|
+
if (number.charAt(0) !== "1") {
|
|
988
|
+
number = "1".concat(number);
|
|
989
|
+
}
|
|
910
990
|
number = "+".concat(number);
|
|
911
991
|
}
|
|
912
992
|
// if separateDialCode enabled, then consider the selected dial code to be part of the number
|
|
@@ -967,11 +1047,15 @@
|
|
|
967
1047
|
key: "_highlightListItem",
|
|
968
1048
|
value: function _highlightListItem(listItem, shouldFocus) {
|
|
969
1049
|
var prevItem = this.highlightedItem;
|
|
970
|
-
if (prevItem)
|
|
1050
|
+
if (prevItem) {
|
|
1051
|
+
prevItem.classList.remove("iti__highlight");
|
|
1052
|
+
}
|
|
971
1053
|
this.highlightedItem = listItem;
|
|
972
1054
|
this.highlightedItem.classList.add("iti__highlight");
|
|
973
1055
|
this.selectedFlag.setAttribute("aria-activedescendant", listItem.getAttribute("id"));
|
|
974
|
-
if (shouldFocus)
|
|
1056
|
+
if (shouldFocus) {
|
|
1057
|
+
this.highlightedItem.focus();
|
|
1058
|
+
}
|
|
975
1059
|
}
|
|
976
1060
|
}, {
|
|
977
1061
|
key: "_getCountryData",
|
|
@@ -1072,8 +1156,8 @@
|
|
|
1072
1156
|
this._updateDialCode(listItem.getAttribute("data-dial-code"));
|
|
1073
1157
|
// focus the input
|
|
1074
1158
|
this.telInput.focus();
|
|
1075
|
-
// put cursor at end - this fix is required for FF and IE11 (with
|
|
1076
|
-
//
|
|
1159
|
+
// put cursor at end - this fix is required for FF and IE11 (with auto inserting dial code),
|
|
1160
|
+
// who try to put the cursor at the beginning the first time
|
|
1077
1161
|
var len = this.telInput.value.length;
|
|
1078
1162
|
this.telInput.setSelectionRange(len, len);
|
|
1079
1163
|
if (flagChanged) {
|
|
@@ -1095,8 +1179,12 @@
|
|
|
1095
1179
|
this.countryList.removeEventListener("click", this._handleClickCountryList);
|
|
1096
1180
|
// remove menu from container
|
|
1097
1181
|
if (this.options.dropdownContainer) {
|
|
1098
|
-
if (!this.isMobile)
|
|
1099
|
-
|
|
1182
|
+
if (!this.isMobile) {
|
|
1183
|
+
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
1184
|
+
}
|
|
1185
|
+
if (this.dropdown.parentNode) {
|
|
1186
|
+
this.dropdown.parentNode.removeChild(this.dropdown);
|
|
1187
|
+
}
|
|
1100
1188
|
}
|
|
1101
1189
|
this._trigger("close:countrydropdown");
|
|
1102
1190
|
}
|
|
@@ -1116,11 +1204,15 @@
|
|
|
1116
1204
|
var middleOffset = containerHeight / 2 - elementHeight / 2;
|
|
1117
1205
|
if (elementTop < containerTop) {
|
|
1118
1206
|
// scroll up
|
|
1119
|
-
if (middle)
|
|
1207
|
+
if (middle) {
|
|
1208
|
+
newScrollTop -= middleOffset;
|
|
1209
|
+
}
|
|
1120
1210
|
container.scrollTop = newScrollTop;
|
|
1121
1211
|
} else if (elementBottom > containerBottom) {
|
|
1122
1212
|
// scroll down
|
|
1123
|
-
if (middle)
|
|
1213
|
+
if (middle) {
|
|
1214
|
+
newScrollTop += middleOffset;
|
|
1215
|
+
}
|
|
1124
1216
|
var heightDifference = containerHeight - elementHeight;
|
|
1125
1217
|
container.scrollTop = newScrollTop - heightDifference;
|
|
1126
1218
|
}
|
|
@@ -1133,7 +1225,7 @@
|
|
|
1133
1225
|
var newDialCode = "+".concat(newDialCodeBare);
|
|
1134
1226
|
var newNumber;
|
|
1135
1227
|
if (inputVal.charAt(0) === "+") {
|
|
1136
|
-
// there's a plus so we're dealing with a replacement
|
|
1228
|
+
// there's a plus so we're dealing with a replacement
|
|
1137
1229
|
var prevDialCode = this._getDialCode(inputVal);
|
|
1138
1230
|
if (prevDialCode) {
|
|
1139
1231
|
// current number contains a valid dial code, so replace it
|
|
@@ -1267,13 +1359,19 @@
|
|
|
1267
1359
|
this.flagsContainer.removeEventListener("keydown", this._handleFlagsContainerKeydown);
|
|
1268
1360
|
// label click hack
|
|
1269
1361
|
var label = this._getClosestLabel();
|
|
1270
|
-
if (label)
|
|
1362
|
+
if (label) {
|
|
1363
|
+
label.removeEventListener("click", this._handleLabelClick);
|
|
1364
|
+
}
|
|
1271
1365
|
}
|
|
1272
1366
|
// unbind hiddenInput listeners
|
|
1273
|
-
if (this.hiddenInput && form)
|
|
1367
|
+
if (this.hiddenInput && form) {
|
|
1368
|
+
form.removeEventListener("submit", this._handleHiddenInputSubmit);
|
|
1369
|
+
}
|
|
1274
1370
|
// unbind autoInsertDialCode listeners
|
|
1275
1371
|
if (this.options.autoInsertDialCode) {
|
|
1276
|
-
if (form)
|
|
1372
|
+
if (form) {
|
|
1373
|
+
form.removeEventListener("submit", this._handleSubmitOrBlurEvent);
|
|
1374
|
+
}
|
|
1277
1375
|
this.telInput.removeEventListener("blur", this._handleSubmitOrBlurEvent);
|
|
1278
1376
|
}
|
|
1279
1377
|
// unbind key events, and cut/paste events
|
|
@@ -1331,8 +1429,7 @@
|
|
|
1331
1429
|
key: "isValidNumber",
|
|
1332
1430
|
value: function isValidNumber() {
|
|
1333
1431
|
var val = this._getFullNumber().trim();
|
|
1334
|
-
|
|
1335
|
-
return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, countryCode) : null;
|
|
1432
|
+
return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
1336
1433
|
}
|
|
1337
1434
|
}, {
|
|
1338
1435
|
key: "setCountry",
|
|
@@ -1378,11 +1475,15 @@
|
|
|
1378
1475
|
var script = document.createElement("script");
|
|
1379
1476
|
script.onload = function() {
|
|
1380
1477
|
forEachInstance("handleUtils");
|
|
1381
|
-
if (handleSuccess)
|
|
1478
|
+
if (handleSuccess) {
|
|
1479
|
+
handleSuccess();
|
|
1480
|
+
}
|
|
1382
1481
|
};
|
|
1383
1482
|
script.onerror = function() {
|
|
1384
1483
|
forEachInstance("rejectUtilsScriptPromise");
|
|
1385
|
-
if (handleFailure)
|
|
1484
|
+
if (handleFailure) {
|
|
1485
|
+
handleFailure();
|
|
1486
|
+
}
|
|
1386
1487
|
};
|
|
1387
1488
|
script.className = "iti-load-utils";
|
|
1388
1489
|
script.async = true;
|
|
@@ -1411,7 +1512,7 @@
|
|
|
1411
1512
|
// default options
|
|
1412
1513
|
intlTelInputGlobals.defaults = defaults;
|
|
1413
1514
|
// version
|
|
1414
|
-
intlTelInputGlobals.version = "18.1.
|
|
1515
|
+
intlTelInputGlobals.version = "18.1.2";
|
|
1415
1516
|
// convenience wrapper
|
|
1416
1517
|
return function(input, options) {
|
|
1417
1518
|
var iti = new Iti(input, options);
|