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