From d5dd02ede8d1a5f5667813a36e85bda1f251ffb2 Mon Sep 17 00:00:00 2001 From: Jack OConnor Date: Wed, 1 May 2024 12:52:29 +0100 Subject: [PATCH] Release v21.2.8 --- README.md | 6 +++--- build/js/data.js | 2 +- build/js/data.min.js | 2 +- build/js/intlTelInput.js | 4 ++-- build/js/intlTelInput.min.js | 4 ++-- composer.json | 2 +- package-lock.json | 2 +- package.json | 2 +- react/build/IntlTelInput.cjs | 2 +- react/build/IntlTelInput.js | 2 +- react/demo/simple-bundle.js | 2 +- react/demo/validation-bundle.js | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d60903f6c..c5d49757a 100644 --- a/README.md +++ b/README.md @@ -67,16 +67,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because ## Getting Started (Using a CDN) 1. Add the CSS ```html - + ``` 2. Add the plugin script and initialise it on your input element ```html - + ``` diff --git a/build/js/data.js b/build/js/data.js index c8347aee6..f222ee4f9 100644 --- a/build/js/data.js +++ b/build/js/data.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v21.2.7 + * International Telephone Input v21.2.8 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ diff --git a/build/js/data.min.js b/build/js/data.min.js index 21b7394fe..deaa2c099 100644 --- a/build/js/data.min.js +++ b/build/js/data.min.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v21.2.7 + * International Telephone Input v21.2.8 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ diff --git a/build/js/intlTelInput.js b/build/js/intlTelInput.js index 2df3c97bf..07a2d3cbe 100644 --- a/build/js/intlTelInput.js +++ b/build/js/intlTelInput.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v21.2.7 + * International Telephone Input v21.2.8 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ @@ -2883,7 +2883,7 @@ var factoryOutput = (() => { //* A map from instance ID to instance object. instances: {}, loadUtils, - version: "21.2.7" + version: "21.2.8" }; window.intlTelInputGlobals = intlTelInputGlobals; } diff --git a/build/js/intlTelInput.min.js b/build/js/intlTelInput.min.js index 94bd0e485..61ceedaf8 100644 --- a/build/js/intlTelInput.min.js +++ b/build/js/intlTelInput.min.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v21.2.7 + * International Telephone Input v21.2.8 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ @@ -13,7 +13,7 @@ } }(() => { -var factoryOutput=(()=>{var v=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var M=(o,t)=>{for(var e in t)v(o,e,{get:t[e],enumerable:!0})},x=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!N.call(o,n)&&n!==e&&v(o,n,{get:()=>t[n],enumerable:!(i=k(t,n))||i.enumerable});return o};var P=o=>x(v({},"__esModule",{value:!0}),o);var G={};M(G,{Iti:()=>b,default:()=>$});var w=[["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 o=0;oo.replace(/\D/g,""),E=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),F=(o,t,e)=>{e&&!o.classList.contains(t)?o.classList.add(t):!e&&o.classList.contains(t)&&o.classList.remove(t)},S=o=>{let t=f(o);if(t.charAt(0)==="1"){let e=t.substr(1,3);return U.indexOf(e)!==-1}return!1},z=(o,t)=>o.namet.name?1:0,R=(o,t,e,i)=>{if(e===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(o);return t&&Object.entries(t).forEach(([n,s])=>i.setAttribute(n,s)),e&&e.appendChild(i),i},y=o=>{let{instances:t}=window.intlTelInputGlobals;Object.values(t).forEach(e=>e[o]())},b=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;countryContainer;selectedCountry;selectedCountryInner;selectedCountryA11yText;selectedDialCode;dropdownArrow;dropdownContent;searchInput;searchResultsA11yText;countryList;dropdown;hiddenInput;hiddenInputCountry;maxCoreNumberLength;defaultCountry;_a14;_a9;_a10;_a11;_a12;_handleKeydownEvent;_a4;_a0;_a1;_a2;_a3;_a7;resolveAutoCountryPromise;rejectAutoCountryPromise;resolveUtilsScriptPromise;rejectUtilsScriptPromise;constructor(t,e={}){this.id=H++,this.a=t,this.b=null,this.c=null,this.d=Object.assign({},D,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.countrySearch&&!this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!0);let t=this.d.allowDropdown&&!this.d.showSelectedDialCode;!this.d.showFlags&&t&&(this.d.showFlags=!0),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isRTL=!!this.a.closest("[dir=rtl]"),this.d.i18n={...T,...this.d.i18n};let e=new Promise((n,s)=>{this.h=n,this.i=s}),i=new Promise((n,s)=>{this.i0=n,this.i1=s});this.promise=Promise.all([e,i]),this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}_b(){this._d(),this._d2(),this._e(),this._d0(),(this.d.onlyCountries.length||this.d.i18n)&&this.p.sort(z)}_c(t,e,i){e.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=e.length),this.q.hasOwnProperty(e)||(this.q[e]=[]);for(let s=0;sn.toLowerCase());this.p=C.filter(n=>i.indexOf(n.iso2)>-1)}else if(e.length){let i=e.map(n=>n.toLowerCase());this.p=C.filter(n=>i.indexOf(n.iso2)===-1)}else this.p=C}_d0(){for(let t=0;t
`),l+=`${s.name}`,l+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",l)}}_h(t=!1){let e=this.a.getAttribute("value"),i=this.a.value,s=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?e:i,r=this._5(s),d=S(s),{initialCountry:l}=this.d;if(r&&!d)this._v(s);else if(l!=="auto"||t){let a=l?l.toLowerCase():"";a&&this._y(a,!0)?this._z(a):r&&d?this._z("us"):this._z()}s&&this._u(s)}_i(){this._j(),this.d.allowDropdown&&this._i2(),(this.hiddenInput||this.hiddenInputCountry)&&this.a.form&&this._i0()}_i0(){this._a14=()=>{this.hiddenInput&&(this.hiddenInput.value=this.getNumber()),this.hiddenInputCountry&&(this.hiddenInputCountry.value=this.getSelectedCountryData().iso2||"")},this.a.form?.addEventListener("submit",this._a14)}_i2(){this._a9=e=>{this.dropdownContent.classList.contains("iti__hide")?this.a.focus():e.preventDefault()};let t=this.a.closest("label");t&&t.addEventListener("click",this._a9),this._a10=()=>{this.dropdownContent.classList.contains("iti__hide")&&!this.a.disabled&&!this.a.readOnly&&this._n()},this.selectedCountry.addEventListener("click",this._a10),this._a11=e=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),this._n()),e.key==="Tab"&&this._2()},this.k.addEventListener("keydown",this._a11)}_i3(){this.d.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.d.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.d.utilsScript)}):this.i0(),this.d.initialCountry==="auto"&&!this.s.iso2?this._i4():this.h()}_i4(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.d.geoIpLookup=="function"&&this.d.geoIpLookup((t="")=>{let e=t.toLowerCase();e&&this._y(e,!0)?(window.intlTelInputGlobals.autoCountry=e,setTimeout(()=>y("handleAutoCountry"))):(this._h(!0),y("rejectAutoCountryPromise"))},()=>{this._h(!0),y("rejectAutoCountryPromise")}))}_j(){let{strictMode:t,formatAsYouType:e}=this.d,i=!1;this._a12=n=>{this._v(this.a.value)&&this._8();let s=n&&n.data&&/[^+0-9]/.test(n.data),r=n&&n.inputType==="insertFromPaste"&&this.a.value;if(s||r&&!t?i=!0:/[^+0-9]/.test(this.a.value)||(i=!1),e&&!i){let d=this.a.selectionStart||0,a=this.a.value.substring(0,d).replace(/[^+0-9]/g,"").length,p=n&&n.inputType==="deleteContentForward",c=this._9(),u=R(a,c,d,p);this.a.value=c,this.a.setSelectionRange(u,u)}},this.a.addEventListener("input",this._a12),t&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.a.selectionStart===0&&n.key==="+",r=/^[0-9]$/.test(n.key),d=s||r,l=this._6(),a=window.intlTelInputUtils.getCoreNumber(l,this.s.iso2),p=this.maxCoreNumberLength&&a.length>=this.maxCoreNumberLength;(!d||p)&&n.preventDefault()}},this.a.addEventListener("keydown",this._handleKeydownEvent))}_j2(t){let e=parseInt(this.a.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.a.dispatchEvent(e)}_n(){let{fixDropdownWidth:t,countrySearch:e}=this.d;if(t&&(this.dropdownContent.style.width=`${this.a.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._o(),this.b&&!e)this._x(this.b,!1),this._3(this.b,!0);else{let i=this.countryList.firstElementChild;i&&(this._x(i,!1),this.countryList.scrollTop=0),e&&this.searchInput.focus()}this._p(),this.u.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}_o(){if(this.d.dropdownContainer&&this.d.dropdownContainer.appendChild(this.dropdown),!this.d.useFullscreenPopup){let t=this.a.getBoundingClientRect(),e=document.documentElement.scrollTop,i=t.top+e,n=this.a.offsetHeight,s=this.dropdownContent.offsetHeight,r=i+n+se,l=!this.d.countrySearch&&!r&&d;if(F(this.dropdownContent,"iti__dropdown-content--dropup",l),this.d.dropdownContainer){let a=l?0:n;this.dropdown.style.top=`${t.top+a}px`,this.dropdown.style.left=`${t.left}px`,this._a4=()=>this._2(),window.addEventListener("scroll",this._a4)}}}_p(){this._a0=n=>{let s=n.target?.closest(".iti__country");s&&this._x(s,!1)},this.countryList.addEventListener("mouseover",this._a0),this._a1=n=>{let s=n.target?.closest(".iti__country");s&&this._1(s)},this.countryList.addEventListener("click",this._a1);let t=!0;this._a2=()=>{t||this._2(),t=!1},document.documentElement.addEventListener("click",this._a2);let e="",i=null;if(this._a3=n=>{["ArrowUp","ArrowDown","Enter","Escape"].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),n.key==="ArrowUp"||n.key==="ArrowDown"?this._q(n.key):n.key==="Enter"?this._r():n.key==="Escape"&&this._2()),!this.d.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),e+=n.key.toLowerCase(),this._s(e),i=setTimeout(()=>{e=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){let n=()=>{let r=this.searchInput.value.trim();r?this._p3(r):this._p3("",!0)},s=null;this._a7=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._a7),this.searchInput.addEventListener("click",r=>r.stopPropagation())}}_p3(t,e=!1){let i=!0;this.countryList.innerHTML="";let n=E(t);for(let s=0;s1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e){this._3(e,!1);let i=!this.d.countrySearch;this._x(e,i)}}_r(){this.c&&this._1(this.c)}_s(t){for(let e=0;ed){e&&(c+=u);let m=s-l;i.scrollTop=c-m}}_4(t){let e=this.a.value,i=`+${t}`,n;if(e.charAt(0)==="+"){let s=this._5(e);s?n=e.replace(s,i):n=i,this.a.value=n}}_5(t,e){let i="";if(t.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{y("handleUtils"),t&&t()},i.onerror=()=>{y("rejectUtilsScriptPromise"),e&&e()},i.className="iti-load-utils",i.async=!0,i.src=o,document.body.appendChild(i)},j=o=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((t,e)=>O(o,t,e))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let o={defaults:D,documentReady:()=>document.readyState==="complete",getCountryData:()=>C,getInstance:t=>{let e=t.getAttribute("data-intl-tel-input-id");return e?o.instances[e]:null},instances:{},loadUtils:j,version:"21.2.7"};window.intlTelInputGlobals=o}var B=(o,t)=>{let e=new b(o,t);return e._init(),o.setAttribute("data-intl-tel-input-id",e.id.toString()),window.intlTelInputGlobals.instances[e.id]=e,e},$=B;return P(G);})(); +var factoryOutput=(()=>{var v=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var M=(o,t)=>{for(var e in t)v(o,e,{get:t[e],enumerable:!0})},x=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!N.call(o,n)&&n!==e&&v(o,n,{get:()=>t[n],enumerable:!(i=k(t,n))||i.enumerable});return o};var P=o=>x(v({},"__esModule",{value:!0}),o);var G={};M(G,{Iti:()=>b,default:()=>$});var w=[["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 o=0;oo.replace(/\D/g,""),E=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),F=(o,t,e)=>{e&&!o.classList.contains(t)?o.classList.add(t):!e&&o.classList.contains(t)&&o.classList.remove(t)},S=o=>{let t=f(o);if(t.charAt(0)==="1"){let e=t.substr(1,3);return U.indexOf(e)!==-1}return!1},z=(o,t)=>o.namet.name?1:0,R=(o,t,e,i)=>{if(e===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(o);return t&&Object.entries(t).forEach(([n,s])=>i.setAttribute(n,s)),e&&e.appendChild(i),i},y=o=>{let{instances:t}=window.intlTelInputGlobals;Object.values(t).forEach(e=>e[o]())},b=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;countryContainer;selectedCountry;selectedCountryInner;selectedCountryA11yText;selectedDialCode;dropdownArrow;dropdownContent;searchInput;searchResultsA11yText;countryList;dropdown;hiddenInput;hiddenInputCountry;maxCoreNumberLength;defaultCountry;_a14;_a9;_a10;_a11;_a12;_handleKeydownEvent;_a4;_a0;_a1;_a2;_a3;_a7;resolveAutoCountryPromise;rejectAutoCountryPromise;resolveUtilsScriptPromise;rejectUtilsScriptPromise;constructor(t,e={}){this.id=H++,this.a=t,this.b=null,this.c=null,this.d=Object.assign({},D,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.countrySearch&&!this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!0);let t=this.d.allowDropdown&&!this.d.showSelectedDialCode;!this.d.showFlags&&t&&(this.d.showFlags=!0),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isRTL=!!this.a.closest("[dir=rtl]"),this.d.i18n={...T,...this.d.i18n};let e=new Promise((n,s)=>{this.h=n,this.i=s}),i=new Promise((n,s)=>{this.i0=n,this.i1=s});this.promise=Promise.all([e,i]),this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}_b(){this._d(),this._d2(),this._e(),this._d0(),(this.d.onlyCountries.length||this.d.i18n)&&this.p.sort(z)}_c(t,e,i){e.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=e.length),this.q.hasOwnProperty(e)||(this.q[e]=[]);for(let s=0;sn.toLowerCase());this.p=C.filter(n=>i.indexOf(n.iso2)>-1)}else if(e.length){let i=e.map(n=>n.toLowerCase());this.p=C.filter(n=>i.indexOf(n.iso2)===-1)}else this.p=C}_d0(){for(let t=0;t
`),l+=`${s.name}`,l+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",l)}}_h(t=!1){let e=this.a.getAttribute("value"),i=this.a.value,s=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?e:i,r=this._5(s),d=S(s),{initialCountry:l}=this.d;if(r&&!d)this._v(s);else if(l!=="auto"||t){let a=l?l.toLowerCase():"";a&&this._y(a,!0)?this._z(a):r&&d?this._z("us"):this._z()}s&&this._u(s)}_i(){this._j(),this.d.allowDropdown&&this._i2(),(this.hiddenInput||this.hiddenInputCountry)&&this.a.form&&this._i0()}_i0(){this._a14=()=>{this.hiddenInput&&(this.hiddenInput.value=this.getNumber()),this.hiddenInputCountry&&(this.hiddenInputCountry.value=this.getSelectedCountryData().iso2||"")},this.a.form?.addEventListener("submit",this._a14)}_i2(){this._a9=e=>{this.dropdownContent.classList.contains("iti__hide")?this.a.focus():e.preventDefault()};let t=this.a.closest("label");t&&t.addEventListener("click",this._a9),this._a10=()=>{this.dropdownContent.classList.contains("iti__hide")&&!this.a.disabled&&!this.a.readOnly&&this._n()},this.selectedCountry.addEventListener("click",this._a10),this._a11=e=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),this._n()),e.key==="Tab"&&this._2()},this.k.addEventListener("keydown",this._a11)}_i3(){this.d.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.d.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.d.utilsScript)}):this.i0(),this.d.initialCountry==="auto"&&!this.s.iso2?this._i4():this.h()}_i4(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.d.geoIpLookup=="function"&&this.d.geoIpLookup((t="")=>{let e=t.toLowerCase();e&&this._y(e,!0)?(window.intlTelInputGlobals.autoCountry=e,setTimeout(()=>y("handleAutoCountry"))):(this._h(!0),y("rejectAutoCountryPromise"))},()=>{this._h(!0),y("rejectAutoCountryPromise")}))}_j(){let{strictMode:t,formatAsYouType:e}=this.d,i=!1;this._a12=n=>{this._v(this.a.value)&&this._8();let s=n&&n.data&&/[^+0-9]/.test(n.data),r=n&&n.inputType==="insertFromPaste"&&this.a.value;if(s||r&&!t?i=!0:/[^+0-9]/.test(this.a.value)||(i=!1),e&&!i){let d=this.a.selectionStart||0,a=this.a.value.substring(0,d).replace(/[^+0-9]/g,"").length,p=n&&n.inputType==="deleteContentForward",c=this._9(),u=R(a,c,d,p);this.a.value=c,this.a.setSelectionRange(u,u)}},this.a.addEventListener("input",this._a12),t&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.a.selectionStart===0&&n.key==="+",r=/^[0-9]$/.test(n.key),d=s||r,l=this._6(),a=window.intlTelInputUtils.getCoreNumber(l,this.s.iso2),p=this.maxCoreNumberLength&&a.length>=this.maxCoreNumberLength;(!d||p)&&n.preventDefault()}},this.a.addEventListener("keydown",this._handleKeydownEvent))}_j2(t){let e=parseInt(this.a.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.a.dispatchEvent(e)}_n(){let{fixDropdownWidth:t,countrySearch:e}=this.d;if(t&&(this.dropdownContent.style.width=`${this.a.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._o(),this.b&&!e)this._x(this.b,!1),this._3(this.b,!0);else{let i=this.countryList.firstElementChild;i&&(this._x(i,!1),this.countryList.scrollTop=0),e&&this.searchInput.focus()}this._p(),this.u.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}_o(){if(this.d.dropdownContainer&&this.d.dropdownContainer.appendChild(this.dropdown),!this.d.useFullscreenPopup){let t=this.a.getBoundingClientRect(),e=document.documentElement.scrollTop,i=t.top+e,n=this.a.offsetHeight,s=this.dropdownContent.offsetHeight,r=i+n+se,l=!this.d.countrySearch&&!r&&d;if(F(this.dropdownContent,"iti__dropdown-content--dropup",l),this.d.dropdownContainer){let a=l?0:n;this.dropdown.style.top=`${t.top+a}px`,this.dropdown.style.left=`${t.left}px`,this._a4=()=>this._2(),window.addEventListener("scroll",this._a4)}}}_p(){this._a0=n=>{let s=n.target?.closest(".iti__country");s&&this._x(s,!1)},this.countryList.addEventListener("mouseover",this._a0),this._a1=n=>{let s=n.target?.closest(".iti__country");s&&this._1(s)},this.countryList.addEventListener("click",this._a1);let t=!0;this._a2=()=>{t||this._2(),t=!1},document.documentElement.addEventListener("click",this._a2);let e="",i=null;if(this._a3=n=>{["ArrowUp","ArrowDown","Enter","Escape"].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),n.key==="ArrowUp"||n.key==="ArrowDown"?this._q(n.key):n.key==="Enter"?this._r():n.key==="Escape"&&this._2()),!this.d.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),e+=n.key.toLowerCase(),this._s(e),i=setTimeout(()=>{e=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){let n=()=>{let r=this.searchInput.value.trim();r?this._p3(r):this._p3("",!0)},s=null;this._a7=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._a7),this.searchInput.addEventListener("click",r=>r.stopPropagation())}}_p3(t,e=!1){let i=!0;this.countryList.innerHTML="";let n=E(t);for(let s=0;s1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e){this._3(e,!1);let i=!this.d.countrySearch;this._x(e,i)}}_r(){this.c&&this._1(this.c)}_s(t){for(let e=0;ed){e&&(c+=u);let m=s-l;i.scrollTop=c-m}}_4(t){let e=this.a.value,i=`+${t}`,n;if(e.charAt(0)==="+"){let s=this._5(e);s?n=e.replace(s,i):n=i,this.a.value=n}}_5(t,e){let i="";if(t.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{y("handleUtils"),t&&t()},i.onerror=()=>{y("rejectUtilsScriptPromise"),e&&e()},i.className="iti-load-utils",i.async=!0,i.src=o,document.body.appendChild(i)},j=o=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((t,e)=>O(o,t,e))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let o={defaults:D,documentReady:()=>document.readyState==="complete",getCountryData:()=>C,getInstance:t=>{let e=t.getAttribute("data-intl-tel-input-id");return e?o.instances[e]:null},instances:{},loadUtils:j,version:"21.2.8"};window.intlTelInputGlobals=o}var B=(o,t)=>{let e=new b(o,t);return e._init(),o.setAttribute("data-intl-tel-input-id",e.id.toString()),window.intlTelInputGlobals.instances[e.id]=e,e},$=B;return P(G);})(); // UMD return factoryOutput.default; diff --git a/composer.json b/composer.json index 6c5d3b570..8df37d0b7 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "jackocnr/intl-tel-input", - "version": "21.2.7", + "version": "21.2.8", "description": "A JavaScript plugin for entering and validating international telephone numbers", "keywords": [ "international", diff --git a/package-lock.json b/package-lock.json index 14d4c3c83..956408ed6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "intl-tel-input", - "version": "21.2.7", + "version": "21.2.8", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index a72ff7751..ee4978fad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intl-tel-input", - "version": "21.2.7", + "version": "21.2.8", "description": "A JavaScript plugin for entering and validating international telephone numbers", "keywords": [ "international", diff --git a/react/build/IntlTelInput.cjs b/react/build/IntlTelInput.cjs index 76e36a244..7afa118b3 100644 --- a/react/build/IntlTelInput.cjs +++ b/react/build/IntlTelInput.cjs @@ -1 +1 @@ -var M=Object.create;var b=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},I=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of P(e))!U.call(o,n)&&n!==t&&b(o,n,{get:()=>e[n],enumerable:!(i=x(e,n))||i.enumerable});return o};var F=(o,e,t)=>(t=o!=null?M(H(o)):{},I(e||!o||!o.__esModule?b(t,"default",{value:o,enumerable:!0}):t,o)),z=o=>I(b({},"__esModule",{value:!0}),o);var J={};R(J,{default:()=>Y});module.exports=z(J);var m=F(require("react"));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"]]],L=[];for(let o=0;o<_.length;o++){let e=_[o];L[o]={name:"",iso2:e[0],dialCode:e[1],priority:e[2]||0,areaCodes:e[3]||null,nodeById:{}}}var y=L;var T={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 E={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 S={...T,...E};var O=0,A={allowDropdown:!0,autoPlaceholder:"polite",countrySearch:!0,containerClass:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!0,formatAsYouType:!0,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:null,i18n:{},initialCountry:"",nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:[],showFlags:!0,showSelectedDialCode:!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:""},j=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],v=o=>o.replace(/\D/g,""),D=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),B=(o,e,t)=>{t&&!o.classList.contains(e)?o.classList.add(e):!t&&o.classList.contains(e)&&o.classList.remove(e)},k=o=>{let e=v(o);if(e.charAt(0)==="1"){let t=e.substr(1,3);return j.indexOf(t)!==-1}return!1},$=(o,e)=>o.namee.name?1:0,G=(o,e,t,i)=>{if(t===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(o);return e&&Object.entries(e).forEach(([n,s])=>i.setAttribute(n,s)),t&&t.appendChild(i),i},f=o=>{let{instances:e}=window.intlTelInputGlobals;Object.values(e).forEach(t=>t[o]())},w=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;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(e,t={}){this.id=O++,this.telInput=e,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},A,t),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0);let e=this.options.allowDropdown&&!this.options.showSelectedDialCode;!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.i18n={...S,...this.options.i18n};let t=new Promise((n,s)=>{this.resolveAutoCountryPromise=n,this.rejectAutoCountryPromise=s}),i=new Promise((n,s)=>{this.resolveUtilsScriptPromise=n,this.rejectUtilsScriptPromise=s});this.promise=Promise.all([t,i]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort($)}_addToDialCodeMap(e,t,i){t.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=t.length),this.dialCodeToIso2Map.hasOwnProperty(t)||(this.dialCodeToIso2Map[t]=[]);for(let s=0;sn.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)>-1)}else if(t.length){let i=t.map(n=>n.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)===-1)}else this.countries=y}_translateCountryNames(){for(let e=0;e
`),l+=`${s.name}`,l+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",l)}}_setInitialState(e=!1){let t=this.telInput.getAttribute("value"),i=this.telInput.value,s=t&&t.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?t:i,a=this._getDialCode(s),d=k(s),{initialCountry:l}=this.options;if(a&&!d)this._updateCountryFromNumber(s);else if(l!=="auto"||e){let r=l?l.toLowerCase():"";r&&this._getCountryData(r,!0)?this._setCountry(r):a&&d?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=t=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():t.preventDefault()};let e=this.telInput.closest("label");e&&e.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=t=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this._openDropdown()),t.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((e="")=>{let t=e.toLowerCase();t&&this._getCountryData(t,!0)?(window.intlTelInputGlobals.autoCountry=t,setTimeout(()=>f("handleAutoCountry"))):(this._setInitialState(!0),f("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),f("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:t}=this.options,i=!1;this._handleInputEvent=n=>{this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let s=n&&n.data&&/[^+0-9]/.test(n.data),a=n&&n.inputType==="insertFromPaste"&&this.telInput.value;if(s||a&&!e?i=!0:/[^+0-9]/.test(this.telInput.value)||(i=!1),t&&!i){let d=this.telInput.selectionStart||0,r=this.telInput.value.substring(0,d).replace(/[^+0-9]/g,"").length,c=n&&n.inputType==="deleteContentForward",u=this._formatNumberAsYouType(),h=G(r,u,d,c);this.telInput.value=u,this.telInput.setSelectionRange(h,h)}},this.telInput.addEventListener("input",this._handleInputEvent),e&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.telInput.selectionStart===0&&n.key==="+",a=/^[0-9]$/.test(n.key),d=s||a,l=this._getFullNumber(),r=window.intlTelInputUtils.getCoreNumber(l,this.selectedCountryData.iso2),c=this.maxCoreNumberLength&&r.length>=this.maxCoreNumberLength;(!d||c)&&n.preventDefault()}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let t=parseInt(this.telInput.getAttribute("maxlength")||"",10);return t&&e.length>t?e.substr(0,t):e}_trigger(e){let t=new Event(e,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(t)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:t}=this.options;if(e&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&!t)this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0);else{let i=this.countryList.firstElementChild;i&&(this._highlightListItem(i,!1),this.countryList.scrollTop=0),t&&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 e=this.telInput.getBoundingClientRect(),t=document.documentElement.scrollTop,i=e.top+t,n=this.telInput.offsetHeight,s=this.dropdownContent.offsetHeight,a=i+n+st,l=!this.options.countrySearch&&!a&&d;if(B(this.dropdownContent,"iti__dropdown-content--dropup",l),this.options.dropdownContainer){let r=l?0:n;this.dropdown.style.top=`${e.top+r}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let t="",i=null;if(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()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),t+=n.key.toLowerCase(),this._searchForCountry(t),i=setTimeout(()=>{t=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let n=()=>{let a=this.searchInput.value.trim();a?this._filterCountries(a):this._filterCountries("",!0)},s=null;this._handleSearchChange=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",a=>a.stopPropagation())}}_filterCountries(e,t=!1){let i=!0;this.countryList.innerHTML="";let n=D(e);for(let s=0;s1&&(t=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),t){this._scrollTo(t,!1);let i=!this.options.countrySearch;this._highlightListItem(t,i)}}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_searchForCountry(e){for(let t=0;td){t&&(u+=h);let C=s-l;i.scrollTop=u-C}}_updateDialCode(e){let t=this.telInput.value,i=`+${e}`,n;if(t.charAt(0)==="+"){let s=this._getDialCode(t);s?n=t.replace(s,i):n=i,this.telInput.value=n}}_getDialCode(e,t){let i="";if(e.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{f("handleUtils"),e&&e()},i.onerror=()=>{f("rejectUtilsScriptPromise"),t&&t()},i.className="iti-load-utils",i.async=!0,i.src=o,document.body.appendChild(i)},V=o=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((e,t)=>K(o,e,t))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let o={defaults:A,documentReady:()=>document.readyState==="complete",getCountryData:()=>y,getInstance:e=>{let t=e.getAttribute("data-intl-tel-input-id");return t?o.instances[t]:null},instances:{},loadUtils:V,version:"21.2.7"};window.intlTelInputGlobals=o}var q=(o,e)=>{let t=new w(o,e);return t._init(),o.setAttribute("data-intl-tel-input-id",t.id.toString()),window.intlTelInputGlobals.instances[t.id]=t,t},N=q;var W=({initialValue:o="",onChangeNumber:e=()=>{},onChangeCountry:t=()=>{},onChangeValidity:i=()=>{},onChangeErrorCode:n=()=>{},usePreciseValidation:s=!1,initOptions:a={},inputProps:d={}})=>{let l=(0,m.useRef)(null),r=(0,m.useRef)(null),c=()=>{let u=r.current?.getNumber()||"",h=r.current?.getSelectedCountryData().iso2||"";if(e(u),t(h),r.current)if(s?r.current.isValidNumberPrecise():r.current.isValidNumber())i(!0),n(null);else{let g=r.current.getValidationError();i(!1),n(g)}};return(0,m.useEffect)(()=>{let u=l.current;return u&&(r.current=N(u,a),u.addEventListener("countrychange",c),r.current.promise.then(c)),()=>{u&&u.removeEventListener("countrychange",c),r.current?.destroy()}},[]),m.default.createElement("input",{type:"tel",ref:l,onInput:c,defaultValue:o,...d})},Y=W; +var M=Object.create;var b=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},I=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of P(e))!U.call(o,n)&&n!==t&&b(o,n,{get:()=>e[n],enumerable:!(i=x(e,n))||i.enumerable});return o};var F=(o,e,t)=>(t=o!=null?M(H(o)):{},I(e||!o||!o.__esModule?b(t,"default",{value:o,enumerable:!0}):t,o)),z=o=>I(b({},"__esModule",{value:!0}),o);var J={};R(J,{default:()=>Y});module.exports=z(J);var m=F(require("react"));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"]]],L=[];for(let o=0;o<_.length;o++){let e=_[o];L[o]={name:"",iso2:e[0],dialCode:e[1],priority:e[2]||0,areaCodes:e[3]||null,nodeById:{}}}var y=L;var T={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 E={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 S={...T,...E};var O=0,A={allowDropdown:!0,autoPlaceholder:"polite",countrySearch:!0,containerClass:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!0,formatAsYouType:!0,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:null,i18n:{},initialCountry:"",nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:[],showFlags:!0,showSelectedDialCode:!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:""},j=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],v=o=>o.replace(/\D/g,""),D=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),B=(o,e,t)=>{t&&!o.classList.contains(e)?o.classList.add(e):!t&&o.classList.contains(e)&&o.classList.remove(e)},k=o=>{let e=v(o);if(e.charAt(0)==="1"){let t=e.substr(1,3);return j.indexOf(t)!==-1}return!1},$=(o,e)=>o.namee.name?1:0,G=(o,e,t,i)=>{if(t===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(o);return e&&Object.entries(e).forEach(([n,s])=>i.setAttribute(n,s)),t&&t.appendChild(i),i},f=o=>{let{instances:e}=window.intlTelInputGlobals;Object.values(e).forEach(t=>t[o]())},w=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;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(e,t={}){this.id=O++,this.telInput=e,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},A,t),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0);let e=this.options.allowDropdown&&!this.options.showSelectedDialCode;!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.i18n={...S,...this.options.i18n};let t=new Promise((n,s)=>{this.resolveAutoCountryPromise=n,this.rejectAutoCountryPromise=s}),i=new Promise((n,s)=>{this.resolveUtilsScriptPromise=n,this.rejectUtilsScriptPromise=s});this.promise=Promise.all([t,i]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort($)}_addToDialCodeMap(e,t,i){t.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=t.length),this.dialCodeToIso2Map.hasOwnProperty(t)||(this.dialCodeToIso2Map[t]=[]);for(let s=0;sn.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)>-1)}else if(t.length){let i=t.map(n=>n.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)===-1)}else this.countries=y}_translateCountryNames(){for(let e=0;e
`),l+=`${s.name}`,l+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",l)}}_setInitialState(e=!1){let t=this.telInput.getAttribute("value"),i=this.telInput.value,s=t&&t.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?t:i,a=this._getDialCode(s),d=k(s),{initialCountry:l}=this.options;if(a&&!d)this._updateCountryFromNumber(s);else if(l!=="auto"||e){let r=l?l.toLowerCase():"";r&&this._getCountryData(r,!0)?this._setCountry(r):a&&d?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=t=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():t.preventDefault()};let e=this.telInput.closest("label");e&&e.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=t=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this._openDropdown()),t.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((e="")=>{let t=e.toLowerCase();t&&this._getCountryData(t,!0)?(window.intlTelInputGlobals.autoCountry=t,setTimeout(()=>f("handleAutoCountry"))):(this._setInitialState(!0),f("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),f("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:t}=this.options,i=!1;this._handleInputEvent=n=>{this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let s=n&&n.data&&/[^+0-9]/.test(n.data),a=n&&n.inputType==="insertFromPaste"&&this.telInput.value;if(s||a&&!e?i=!0:/[^+0-9]/.test(this.telInput.value)||(i=!1),t&&!i){let d=this.telInput.selectionStart||0,r=this.telInput.value.substring(0,d).replace(/[^+0-9]/g,"").length,c=n&&n.inputType==="deleteContentForward",u=this._formatNumberAsYouType(),h=G(r,u,d,c);this.telInput.value=u,this.telInput.setSelectionRange(h,h)}},this.telInput.addEventListener("input",this._handleInputEvent),e&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.telInput.selectionStart===0&&n.key==="+",a=/^[0-9]$/.test(n.key),d=s||a,l=this._getFullNumber(),r=window.intlTelInputUtils.getCoreNumber(l,this.selectedCountryData.iso2),c=this.maxCoreNumberLength&&r.length>=this.maxCoreNumberLength;(!d||c)&&n.preventDefault()}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let t=parseInt(this.telInput.getAttribute("maxlength")||"",10);return t&&e.length>t?e.substr(0,t):e}_trigger(e){let t=new Event(e,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(t)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:t}=this.options;if(e&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&!t)this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0);else{let i=this.countryList.firstElementChild;i&&(this._highlightListItem(i,!1),this.countryList.scrollTop=0),t&&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 e=this.telInput.getBoundingClientRect(),t=document.documentElement.scrollTop,i=e.top+t,n=this.telInput.offsetHeight,s=this.dropdownContent.offsetHeight,a=i+n+st,l=!this.options.countrySearch&&!a&&d;if(B(this.dropdownContent,"iti__dropdown-content--dropup",l),this.options.dropdownContainer){let r=l?0:n;this.dropdown.style.top=`${e.top+r}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let t="",i=null;if(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()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),t+=n.key.toLowerCase(),this._searchForCountry(t),i=setTimeout(()=>{t=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let n=()=>{let a=this.searchInput.value.trim();a?this._filterCountries(a):this._filterCountries("",!0)},s=null;this._handleSearchChange=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",a=>a.stopPropagation())}}_filterCountries(e,t=!1){let i=!0;this.countryList.innerHTML="";let n=D(e);for(let s=0;s1&&(t=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),t){this._scrollTo(t,!1);let i=!this.options.countrySearch;this._highlightListItem(t,i)}}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_searchForCountry(e){for(let t=0;td){t&&(u+=h);let C=s-l;i.scrollTop=u-C}}_updateDialCode(e){let t=this.telInput.value,i=`+${e}`,n;if(t.charAt(0)==="+"){let s=this._getDialCode(t);s?n=t.replace(s,i):n=i,this.telInput.value=n}}_getDialCode(e,t){let i="";if(e.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{f("handleUtils"),e&&e()},i.onerror=()=>{f("rejectUtilsScriptPromise"),t&&t()},i.className="iti-load-utils",i.async=!0,i.src=o,document.body.appendChild(i)},V=o=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((e,t)=>K(o,e,t))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let o={defaults:A,documentReady:()=>document.readyState==="complete",getCountryData:()=>y,getInstance:e=>{let t=e.getAttribute("data-intl-tel-input-id");return t?o.instances[t]:null},instances:{},loadUtils:V,version:"21.2.8"};window.intlTelInputGlobals=o}var q=(o,e)=>{let t=new w(o,e);return t._init(),o.setAttribute("data-intl-tel-input-id",t.id.toString()),window.intlTelInputGlobals.instances[t.id]=t,t},N=q;var W=({initialValue:o="",onChangeNumber:e=()=>{},onChangeCountry:t=()=>{},onChangeValidity:i=()=>{},onChangeErrorCode:n=()=>{},usePreciseValidation:s=!1,initOptions:a={},inputProps:d={}})=>{let l=(0,m.useRef)(null),r=(0,m.useRef)(null),c=()=>{let u=r.current?.getNumber()||"",h=r.current?.getSelectedCountryData().iso2||"";if(e(u),t(h),r.current)if(s?r.current.isValidNumberPrecise():r.current.isValidNumber())i(!0),n(null);else{let g=r.current.getValidationError();i(!1),n(g)}};return(0,m.useEffect)(()=>{let u=l.current;return u&&(r.current=N(u,a),u.addEventListener("countrychange",c),r.current.promise.then(c)),()=>{u&&u.removeEventListener("countrychange",c),r.current?.destroy()}},[]),m.default.createElement("input",{type:"tel",ref:l,onInput:c,defaultValue:o,...d})},Y=W; diff --git a/react/build/IntlTelInput.js b/react/build/IntlTelInput.js index 34fa06b11..6c286980c 100644 --- a/react/build/IntlTelInput.js +++ b/react/build/IntlTelInput.js @@ -1 +1 @@ -import F,{useRef as k,useEffect as z}from"react";var v=[["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"]]],w=[];for(let l=0;ll.replace(/\D/g,""),T=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),M=(l,e,t)=>{t&&!l.classList.contains(e)?l.classList.add(e):!t&&l.classList.contains(e)&&l.classList.remove(e)},E=l=>{let e=f(l);if(e.charAt(0)==="1"){let t=e.substr(1,3);return N.indexOf(t)!==-1}return!1},x=(l,e)=>l.namee.name?1:0,P=(l,e,t,i)=>{if(t===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(l);return e&&Object.entries(e).forEach(([n,s])=>i.setAttribute(n,s)),t&&t.appendChild(i),i},y=l=>{let{instances:e}=window.intlTelInputGlobals;Object.values(e).forEach(t=>t[l]())},b=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;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(e,t={}){this.id=A++,this.telInput=e,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},S,t),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0);let e=this.options.allowDropdown&&!this.options.showSelectedDialCode;!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.i18n={...L,...this.options.i18n};let t=new Promise((n,s)=>{this.resolveAutoCountryPromise=n,this.rejectAutoCountryPromise=s}),i=new Promise((n,s)=>{this.resolveUtilsScriptPromise=n,this.rejectUtilsScriptPromise=s});this.promise=Promise.all([t,i]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort(x)}_addToDialCodeMap(e,t,i){t.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=t.length),this.dialCodeToIso2Map.hasOwnProperty(t)||(this.dialCodeToIso2Map[t]=[]);for(let s=0;sn.toLowerCase());this.countries=C.filter(n=>i.indexOf(n.iso2)>-1)}else if(t.length){let i=t.map(n=>n.toLowerCase());this.countries=C.filter(n=>i.indexOf(n.iso2)===-1)}else this.countries=C}_translateCountryNames(){for(let e=0;e
`),a+=`${s.name}`,a+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",a)}}_setInitialState(e=!1){let t=this.telInput.getAttribute("value"),i=this.telInput.value,s=t&&t.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?t:i,r=this._getDialCode(s),d=E(s),{initialCountry:a}=this.options;if(r&&!d)this._updateCountryFromNumber(s);else if(a!=="auto"||e){let o=a?a.toLowerCase():"";o&&this._getCountryData(o,!0)?this._setCountry(o):r&&d?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=t=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():t.preventDefault()};let e=this.telInput.closest("label");e&&e.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=t=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this._openDropdown()),t.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((e="")=>{let t=e.toLowerCase();t&&this._getCountryData(t,!0)?(window.intlTelInputGlobals.autoCountry=t,setTimeout(()=>y("handleAutoCountry"))):(this._setInitialState(!0),y("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),y("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:t}=this.options,i=!1;this._handleInputEvent=n=>{this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let s=n&&n.data&&/[^+0-9]/.test(n.data),r=n&&n.inputType==="insertFromPaste"&&this.telInput.value;if(s||r&&!e?i=!0:/[^+0-9]/.test(this.telInput.value)||(i=!1),t&&!i){let d=this.telInput.selectionStart||0,o=this.telInput.value.substring(0,d).replace(/[^+0-9]/g,"").length,c=n&&n.inputType==="deleteContentForward",u=this._formatNumberAsYouType(),h=P(o,u,d,c);this.telInput.value=u,this.telInput.setSelectionRange(h,h)}},this.telInput.addEventListener("input",this._handleInputEvent),e&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.telInput.selectionStart===0&&n.key==="+",r=/^[0-9]$/.test(n.key),d=s||r,a=this._getFullNumber(),o=window.intlTelInputUtils.getCoreNumber(a,this.selectedCountryData.iso2),c=this.maxCoreNumberLength&&o.length>=this.maxCoreNumberLength;(!d||c)&&n.preventDefault()}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let t=parseInt(this.telInput.getAttribute("maxlength")||"",10);return t&&e.length>t?e.substr(0,t):e}_trigger(e){let t=new Event(e,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(t)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:t}=this.options;if(e&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&!t)this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0);else{let i=this.countryList.firstElementChild;i&&(this._highlightListItem(i,!1),this.countryList.scrollTop=0),t&&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 e=this.telInput.getBoundingClientRect(),t=document.documentElement.scrollTop,i=e.top+t,n=this.telInput.offsetHeight,s=this.dropdownContent.offsetHeight,r=i+n+st,a=!this.options.countrySearch&&!r&&d;if(M(this.dropdownContent,"iti__dropdown-content--dropup",a),this.options.dropdownContainer){let o=a?0:n;this.dropdown.style.top=`${e.top+o}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let t="",i=null;if(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()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),t+=n.key.toLowerCase(),this._searchForCountry(t),i=setTimeout(()=>{t=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let n=()=>{let r=this.searchInput.value.trim();r?this._filterCountries(r):this._filterCountries("",!0)},s=null;this._handleSearchChange=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",r=>r.stopPropagation())}}_filterCountries(e,t=!1){let i=!0;this.countryList.innerHTML="";let n=T(e);for(let s=0;s1&&(t=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),t){this._scrollTo(t,!1);let i=!this.options.countrySearch;this._highlightListItem(t,i)}}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_searchForCountry(e){for(let t=0;td){t&&(u+=h);let m=s-a;i.scrollTop=u-m}}_updateDialCode(e){let t=this.telInput.value,i=`+${e}`,n;if(t.charAt(0)==="+"){let s=this._getDialCode(t);s?n=t.replace(s,i):n=i,this.telInput.value=n}}_getDialCode(e,t){let i="";if(e.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{y("handleUtils"),e&&e()},i.onerror=()=>{y("rejectUtilsScriptPromise"),t&&t()},i.className="iti-load-utils",i.async=!0,i.src=l,document.body.appendChild(i)},U=l=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((e,t)=>H(l,e,t))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let l={defaults:S,documentReady:()=>document.readyState==="complete",getCountryData:()=>C,getInstance:e=>{let t=e.getAttribute("data-intl-tel-input-id");return t?l.instances[t]:null},instances:{},loadUtils:U,version:"21.2.7"};window.intlTelInputGlobals=l}var R=(l,e)=>{let t=new b(l,e);return t._init(),l.setAttribute("data-intl-tel-input-id",t.id.toString()),window.intlTelInputGlobals.instances[t.id]=t,t},D=R;var O=({initialValue:l="",onChangeNumber:e=()=>{},onChangeCountry:t=()=>{},onChangeValidity:i=()=>{},onChangeErrorCode:n=()=>{},usePreciseValidation:s=!1,initOptions:r={},inputProps:d={}})=>{let a=k(null),o=k(null),c=()=>{let u=o.current?.getNumber()||"",h=o.current?.getSelectedCountryData().iso2||"";if(e(u),t(h),o.current)if(s?o.current.isValidNumberPrecise():o.current.isValidNumber())i(!0),n(null);else{let g=o.current.getValidationError();i(!1),n(g)}};return z(()=>{let u=a.current;return u&&(o.current=D(u,r),u.addEventListener("countrychange",c),o.current.promise.then(c)),()=>{u&&u.removeEventListener("countrychange",c),o.current?.destroy()}},[]),F.createElement("input",{type:"tel",ref:a,onInput:c,defaultValue:l,...d})},et=O;export{et as default}; +import F,{useRef as k,useEffect as z}from"react";var v=[["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"]]],w=[];for(let l=0;ll.replace(/\D/g,""),T=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),M=(l,e,t)=>{t&&!l.classList.contains(e)?l.classList.add(e):!t&&l.classList.contains(e)&&l.classList.remove(e)},E=l=>{let e=f(l);if(e.charAt(0)==="1"){let t=e.substr(1,3);return N.indexOf(t)!==-1}return!1},x=(l,e)=>l.namee.name?1:0,P=(l,e,t,i)=>{if(t===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(l);return e&&Object.entries(e).forEach(([n,s])=>i.setAttribute(n,s)),t&&t.appendChild(i),i},y=l=>{let{instances:e}=window.intlTelInputGlobals;Object.values(e).forEach(t=>t[l]())},b=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;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(e,t={}){this.id=A++,this.telInput=e,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},S,t),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0);let e=this.options.allowDropdown&&!this.options.showSelectedDialCode;!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.i18n={...L,...this.options.i18n};let t=new Promise((n,s)=>{this.resolveAutoCountryPromise=n,this.rejectAutoCountryPromise=s}),i=new Promise((n,s)=>{this.resolveUtilsScriptPromise=n,this.rejectUtilsScriptPromise=s});this.promise=Promise.all([t,i]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort(x)}_addToDialCodeMap(e,t,i){t.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=t.length),this.dialCodeToIso2Map.hasOwnProperty(t)||(this.dialCodeToIso2Map[t]=[]);for(let s=0;sn.toLowerCase());this.countries=C.filter(n=>i.indexOf(n.iso2)>-1)}else if(t.length){let i=t.map(n=>n.toLowerCase());this.countries=C.filter(n=>i.indexOf(n.iso2)===-1)}else this.countries=C}_translateCountryNames(){for(let e=0;e
`),a+=`${s.name}`,a+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",a)}}_setInitialState(e=!1){let t=this.telInput.getAttribute("value"),i=this.telInput.value,s=t&&t.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?t:i,r=this._getDialCode(s),d=E(s),{initialCountry:a}=this.options;if(r&&!d)this._updateCountryFromNumber(s);else if(a!=="auto"||e){let o=a?a.toLowerCase():"";o&&this._getCountryData(o,!0)?this._setCountry(o):r&&d?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=t=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():t.preventDefault()};let e=this.telInput.closest("label");e&&e.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=t=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this._openDropdown()),t.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((e="")=>{let t=e.toLowerCase();t&&this._getCountryData(t,!0)?(window.intlTelInputGlobals.autoCountry=t,setTimeout(()=>y("handleAutoCountry"))):(this._setInitialState(!0),y("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),y("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:t}=this.options,i=!1;this._handleInputEvent=n=>{this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let s=n&&n.data&&/[^+0-9]/.test(n.data),r=n&&n.inputType==="insertFromPaste"&&this.telInput.value;if(s||r&&!e?i=!0:/[^+0-9]/.test(this.telInput.value)||(i=!1),t&&!i){let d=this.telInput.selectionStart||0,o=this.telInput.value.substring(0,d).replace(/[^+0-9]/g,"").length,c=n&&n.inputType==="deleteContentForward",u=this._formatNumberAsYouType(),h=P(o,u,d,c);this.telInput.value=u,this.telInput.setSelectionRange(h,h)}},this.telInput.addEventListener("input",this._handleInputEvent),e&&(this._handleKeydownEvent=n=>{if(n.key&&n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.telInput.selectionStart===0&&n.key==="+",r=/^[0-9]$/.test(n.key),d=s||r,a=this._getFullNumber(),o=window.intlTelInputUtils.getCoreNumber(a,this.selectedCountryData.iso2),c=this.maxCoreNumberLength&&o.length>=this.maxCoreNumberLength;(!d||c)&&n.preventDefault()}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let t=parseInt(this.telInput.getAttribute("maxlength")||"",10);return t&&e.length>t?e.substr(0,t):e}_trigger(e){let t=new Event(e,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(t)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:t}=this.options;if(e&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&!t)this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0);else{let i=this.countryList.firstElementChild;i&&(this._highlightListItem(i,!1),this.countryList.scrollTop=0),t&&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 e=this.telInput.getBoundingClientRect(),t=document.documentElement.scrollTop,i=e.top+t,n=this.telInput.offsetHeight,s=this.dropdownContent.offsetHeight,r=i+n+st,a=!this.options.countrySearch&&!r&&d;if(M(this.dropdownContent,"iti__dropdown-content--dropup",a),this.options.dropdownContainer){let o=a?0:n;this.dropdown.style.top=`${e.top+o}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let t="",i=null;if(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()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),t+=n.key.toLowerCase(),this._searchForCountry(t),i=setTimeout(()=>{t=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let n=()=>{let r=this.searchInput.value.trim();r?this._filterCountries(r):this._filterCountries("",!0)},s=null;this._handleSearchChange=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",r=>r.stopPropagation())}}_filterCountries(e,t=!1){let i=!0;this.countryList.innerHTML="";let n=T(e);for(let s=0;s1&&(t=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),t){this._scrollTo(t,!1);let i=!this.options.countrySearch;this._highlightListItem(t,i)}}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_searchForCountry(e){for(let t=0;td){t&&(u+=h);let m=s-a;i.scrollTop=u-m}}_updateDialCode(e){let t=this.telInput.value,i=`+${e}`,n;if(t.charAt(0)==="+"){let s=this._getDialCode(t);s?n=t.replace(s,i):n=i,this.telInput.value=n}}_getDialCode(e,t){let i="";if(e.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{y("handleUtils"),e&&e()},i.onerror=()=>{y("rejectUtilsScriptPromise"),t&&t()},i.className="iti-load-utils",i.async=!0,i.src=l,document.body.appendChild(i)},U=l=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((e,t)=>H(l,e,t))):null;if(typeof window=="object"&&!window.intlTelInputGlobals){let l={defaults:S,documentReady:()=>document.readyState==="complete",getCountryData:()=>C,getInstance:e=>{let t=e.getAttribute("data-intl-tel-input-id");return t?l.instances[t]:null},instances:{},loadUtils:U,version:"21.2.8"};window.intlTelInputGlobals=l}var R=(l,e)=>{let t=new b(l,e);return t._init(),l.setAttribute("data-intl-tel-input-id",t.id.toString()),window.intlTelInputGlobals.instances[t.id]=t,t},D=R;var O=({initialValue:l="",onChangeNumber:e=()=>{},onChangeCountry:t=()=>{},onChangeValidity:i=()=>{},onChangeErrorCode:n=()=>{},usePreciseValidation:s=!1,initOptions:r={},inputProps:d={}})=>{let a=k(null),o=k(null),c=()=>{let u=o.current?.getNumber()||"",h=o.current?.getSelectedCountryData().iso2||"";if(e(u),t(h),o.current)if(s?o.current.isValidNumberPrecise():o.current.isValidNumber())i(!0),n(null);else{let g=o.current.getValidationError();i(!1),n(g)}};return z(()=>{let u=a.current;return u&&(o.current=D(u,r),u.addEventListener("countrychange",c),o.current.promise.then(c)),()=>{u&&u.removeEventListener("countrychange",c),o.current?.destroy()}},[]),F.createElement("input",{type:"tel",ref:a,onInput:c,defaultValue:l,...d})},et=O;export{et as default}; diff --git a/react/demo/simple-bundle.js b/react/demo/simple-bundle.js index f4c815776..69b1d9fb3 100644 --- a/react/demo/simple-bundle.js +++ b/react/demo/simple-bundle.js @@ -26358,7 +26358,7 @@ //* A map from instance ID to instance object. instances: {}, loadUtils, - version: "21.2.7" + version: "21.2.8" }; window.intlTelInputGlobals = intlTelInputGlobals; } diff --git a/react/demo/validation-bundle.js b/react/demo/validation-bundle.js index 7a62394ed..93aba5a4f 100644 --- a/react/demo/validation-bundle.js +++ b/react/demo/validation-bundle.js @@ -26358,7 +26358,7 @@ //* A map from instance ID to instance object. instances: {}, loadUtils, - version: "21.2.7" + version: "21.2.8" }; window.intlTelInputGlobals = intlTelInputGlobals; }