From 947a8b20348fb43f9ecd9cdddcce6d7466a4c894 Mon Sep 17 00:00:00 2001 From: Jack OConnor Date: Wed, 17 Jul 2024 19:49:50 +0100 Subject: [PATCH] Remove added input padding in destroy method --- build/js/intlTelInput.d.ts | 2 ++ build/js/intlTelInput.js | 17 ++++++++++++++++- build/js/intlTelInput.min.js | 2 +- build/js/intlTelInputWithUtils.js | 17 ++++++++++++++++- build/js/intlTelInputWithUtils.min.js | 2 +- react/build/IntlTelInput.cjs | 17 ++++++++++++++++- react/build/IntlTelInput.d.ts | 2 ++ react/build/IntlTelInput.js | 17 ++++++++++++++++- react/build/IntlTelInputWithUtils.cjs | 17 ++++++++++++++++- react/build/IntlTelInputWithUtils.js | 17 ++++++++++++++++- react/demo/set-number-bundle.js | 17 ++++++++++++++++- react/demo/simple-bundle.js | 17 ++++++++++++++++- react/demo/validation-bundle.js | 17 ++++++++++++++++- src/js/intl-tel-input.ts | 22 +++++++++++++++++++++- 14 files changed, 171 insertions(+), 12 deletions(-) diff --git a/build/js/intlTelInput.d.ts b/build/js/intlTelInput.d.ts index 306d5a79..82be2b91 100644 --- a/build/js/intlTelInput.d.ts +++ b/build/js/intlTelInput.d.ts @@ -897,6 +897,8 @@ declare module "intl-tel-input" { private hiddenInputCountry; private maxCoreNumberLength; private defaultCountry; + private originalPaddingRight; + private originalPaddingLeft; private _handleHiddenInputSubmit; private _handleLabelClick; private _handleClickSelectedCountry; diff --git a/build/js/intlTelInput.js b/build/js/intlTelInput.js index 5da21d5e..3b621f05 100644 --- a/build/js/intlTelInput.js +++ b/build/js/intlTelInput.js @@ -1536,6 +1536,13 @@ var factoryOutput = (() => { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2653,7 +2660,8 @@ var factoryOutput = (() => { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2677,6 +2685,13 @@ var factoryOutput = (() => { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/build/js/intlTelInput.min.js b/build/js/intlTelInput.min.js index 13ad40ab..752a9afe 100644 --- a/build/js/intlTelInput.min.js +++ b/build/js/intlTelInput.min.js @@ -13,7 +13,7 @@ } }(() => { -var factoryOutput=(()=>{var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var H=(l,t)=>{for(var e in t)I(l,e,{get:t[e],enumerable:!0})},O=(l,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!P.call(l,n)&&n!==e&&I(l,n,{get:()=>t[n],enumerable:!(i=M(t,n))||i.enumerable});return l};var z=l=>O(I({},"__esModule",{value:!0}),l);var U={};H(U,{Iti:()=>_,default:()=>K});var T=[["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"]]],E=[];for(let l=0;ll.replace(/\D/g,""),k=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),A=l=>{let t=v(l);if(t.charAt(0)==="1"){let e=t.substr(1,3);return F.indexOf(e)!==-1}return!1},j=(l,t,e,i)=>{if(e===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(l);return t&&Object.entries(t).forEach(([n,s])=>i.setAttribute(n,s)),e&&e.appendChild(i),i},b=l=>{let{instances:t}=a;Object.values(t).forEach(e=>e[l]())},_=class{constructor(t,e={}){this.id=R++,this.a=t,this.c=null,this.d=Object.assign({},N,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.separateDialCode&&(this.d.allowDropdown=!0,this.d.nationalMode=!1,this.d.countrySearch=!0),!this.d.showFlags&&!this.d.separateDialCode&&(this.d.nationalMode=!1),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isAndroid=typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1,this.isRTL=!!this.a.closest("[dir=rtl]"),this.d.i18n={...w,...this.d.i18n};let t=new Promise((i,n)=>{this.h=i,this.i=n}),e=new Promise((i,n)=>{this.i0=i,this.i1=n});this.promise=Promise.all([t,e]),this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}_b(){this._d(),this._d2(),this._d0(),this.d.countryOrder&&(this.d.countryOrder=this.d.countryOrder.map(t=>t.toLowerCase())),this._sortCountries()}_sortCountries(){this.p.sort((t,e)=>{let{countryOrder:i}=this.d;if(i){let n=i.indexOf(t.iso2),s=i.indexOf(e.iso2),o=n>-1,r=s>-1;if(o||r)return o&&r?n-s:o?-1:1}return t.namee.name?1:0})}_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=f.filter(n=>i.indexOf(n.iso2)>-1)}else if(e.length){let i=e.map(n=>n.toLowerCase());this.p=f.filter(n=>i.indexOf(n.iso2)===-1)}else this.p=f}_d0(){for(let t=0;t
`),s+=`${e.name}`,s+=`+${e.dialCode}`,n.insertAdjacentHTML("beforeend",s)}}_h(t=!1){let e=this.a.getAttribute("value"),i=this.a.value,s=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?e:i,o=this._5(s),r=A(s),{initialCountry:u,geoIpLookup:h}=this.d,g=u==="auto"&&h;if(o&&!r)this._v(s);else if(!g||t){let d=u?u.toLowerCase():"";d&&this._y(d,!0)?this._z(d):o&&r?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(){let{utilsScript:t,initialCountry:e,geoIpLookup:i}=this.d;t&&!a.utils?a.documentReady()?a.loadUtils(t):window.addEventListener("load",()=>{a.loadUtils(t)}):this.i0(),e==="auto"&&i&&!this.s.iso2?this._i4():this.h()}_i4(){a.autoCountry?this.handleAutoCountry():a.startedLoadingAutoCountry||(a.startedLoadingAutoCountry=!0,typeof this.d.geoIpLookup=="function"&&this.d.geoIpLookup((t="")=>{let e=t.toLowerCase();e&&this._y(e,!0)?(a.autoCountry=e,setTimeout(()=>b("handleAutoCountry"))):(this._h(!0),b("rejectAutoCountryPromise"))},()=>{this._h(!0),b("rejectAutoCountryPromise")}))}_j(){let{strictMode:t,formatAsYouType:e,separateDialCode:i,formatOnDisplay:n}=this.d,s=!1,o=()=>{this._n(),this.searchInput.value="+",this._p3("",!0)};this._a12=r=>{if(this.isAndroid&&r?.data==="+"&&i){let d=this.a.selectionStart||0,p=this.a.value.substring(0,d-1),m=this.a.value.substring(d);this.a.value=p+m,o();return}this._v(this.a.value)&&this._8();let u=r?.data&&/[^+0-9]/.test(r.data),h=r?.inputType==="insertFromPaste"&&this.a.value;u||h&&!t?s=!0:/[^+0-9]/.test(this.a.value)||(s=!1);let g=r?.detail&&r.detail.isSetNumber&&!n;if(e&&!s&&!g){let d=this.a.selectionStart||0,m=this.a.value.substring(0,d).replace(/[^+0-9]/g,"").length,y=r?.inputType==="deleteContentForward",C=this._9(),L=j(m,C,d,y);this.a.value=C,this.a.setSelectionRange(L,L)}},this.a.addEventListener("input",this._a12),(t||i)&&(this._handleKeydownEvent=r=>{if(r.key&&r.key.length===1&&!r.altKey&&!r.ctrlKey&&!r.metaKey){if(i&&r.key==="+"){r.preventDefault(),o();return}if(t){let u=this.a.selectionStart===0&&r.key==="+",h=/^[0-9]$/.test(r.key),g=u||h,d=this._6(),p=a.utils.getCoreNumber(d,this.s.iso2),m=this.maxCoreNumberLength&&p.length>=this.maxCoreNumberLength,y=this.a.value.substring(this.a.selectionStart,this.a.selectionEnd),C=/\d/.test(y);(!g||m&&!C)&&r.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,e={}){let i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:e});this.a.dispatchEvent(i)}_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(),e){let i=this.countryList.firstElementChild;i&&(this._x(i,!1),this.countryList.scrollTop=0),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=this.a.offsetHeight;this.d.dropdownContainer&&(this.dropdown.style.top=`${t.top+e}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._searchForCountry(e),i=setTimeout(()=>{e=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){let n=()=>{let o=this.searchInput.value.trim();o?this._p3(o):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",o=>o.stopPropagation())}}_searchForCountry(t){for(let e=0;e1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e&&(this._3(e),this._x(e,!1))}_r(){this.c&&this._1(this.c)}_u(t){let e=t;if(this.d.formatOnDisplay&&a.utils&&this.s){let i=this.d.nationalMode||e.charAt(0)!=="+"&&!this.d.separateDialCode,{NATIONAL:n,INTERNATIONAL:s}=a.utils.numberFormat,o=i?n:s;e=a.utils.formatNumber(e,this.s.iso2,o)}e=this._7(e),this.a.value=e}_v(t){let e=t.indexOf("+"),i=e?t.substring(e):t,n=this.s.dialCode;i&&n==="1"&&i.charAt(0)!=="+"&&(i.charAt(0)!=="1"&&(i=`1${i}`),i=`+${i}`),this.d.separateDialCode&&n&&i.charAt(0)!=="+"&&(i=`+${n}${i}`);let o=this._5(i,!0),r=v(i),u=null;if(o){let h=this.q[v(o)],g=h.indexOf(this.s.iso2)!==-1&&r.length<=o.length-1;if(!(n==="1"&&A(r))&&!g){for(let p=0;po){let d=n-r;e.scrollTop=g-d}}_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!a.utils&&!a.startedLoadingUtilsScript?(a.startedLoadingUtilsScript=!0,new Promise((t,e)=>{import(/* webpackIgnore: true */ l).then(({default:i})=>{a.utils=i,b("handleUtils"),t(!0)}).catch(()=>{b("rejectUtilsScriptPromise"),e()})})):null,a=Object.assign((l,t)=>{let e=new _(l,t);return e._init(),l.setAttribute("data-intl-tel-input-id",e.id.toString()),a.instances[e.id]=e,e},{defaults:N,documentReady:()=>document.readyState==="complete",getCountryData:()=>f,getInstance:l=>{let t=l.getAttribute("data-intl-tel-input-id");return t?a.instances[t]:null},instances:{},loadUtils:B,version:"23.4.0"}),K=a;return z(U);})(); +var factoryOutput=(()=>{var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var H=(l,t)=>{for(var e in t)I(l,e,{get:t[e],enumerable:!0})},O=(l,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!P.call(l,n)&&n!==e&&I(l,n,{get:()=>t[n],enumerable:!(i=M(t,n))||i.enumerable});return l};var R=l=>O(I({},"__esModule",{value:!0}),l);var U={};H(U,{Iti:()=>_,default:()=>K});var T=[["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"]]],E=[];for(let l=0;ll.replace(/\D/g,""),k=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),A=l=>{let t=v(l);if(t.charAt(0)==="1"){let e=t.substr(1,3);return F.indexOf(e)!==-1}return!1},j=(l,t,e,i)=>{if(e===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(l);return t&&Object.entries(t).forEach(([n,s])=>i.setAttribute(n,s)),e&&e.appendChild(i),i},b=l=>{let{instances:t}=a;Object.values(t).forEach(e=>e[l]())},_=class{constructor(t,e={}){this.id=z++,this.a=t,this.c=null,this.d=Object.assign({},N,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.separateDialCode&&(this.d.allowDropdown=!0,this.d.nationalMode=!1,this.d.countrySearch=!0),!this.d.showFlags&&!this.d.separateDialCode&&(this.d.nationalMode=!1),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isAndroid=typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1,this.isRTL=!!this.a.closest("[dir=rtl]"),this.d.separateDialCode&&(this.isRTL?this.originalPaddingRight=this.a.style.paddingRight:this.originalPaddingLeft=this.a.style.paddingLeft),this.d.i18n={...w,...this.d.i18n};let t=new Promise((i,n)=>{this.h=i,this.i=n}),e=new Promise((i,n)=>{this.i0=i,this.i1=n});this.promise=Promise.all([t,e]),this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}_b(){this._d(),this._d2(),this._d0(),this.d.countryOrder&&(this.d.countryOrder=this.d.countryOrder.map(t=>t.toLowerCase())),this._sortCountries()}_sortCountries(){this.p.sort((t,e)=>{let{countryOrder:i}=this.d;if(i){let n=i.indexOf(t.iso2),s=i.indexOf(e.iso2),o=n>-1,r=s>-1;if(o||r)return o&&r?n-s:o?-1:1}return t.namee.name?1:0})}_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=f.filter(n=>i.indexOf(n.iso2)>-1)}else if(e.length){let i=e.map(n=>n.toLowerCase());this.p=f.filter(n=>i.indexOf(n.iso2)===-1)}else this.p=f}_d0(){for(let t=0;t
`),s+=`${e.name}`,s+=`+${e.dialCode}`,n.insertAdjacentHTML("beforeend",s)}}_h(t=!1){let e=this.a.getAttribute("value"),i=this.a.value,s=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?e:i,o=this._5(s),r=A(s),{initialCountry:u,geoIpLookup:h}=this.d,g=u==="auto"&&h;if(o&&!r)this._v(s);else if(!g||t){let d=u?u.toLowerCase():"";d&&this._y(d,!0)?this._z(d):o&&r?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(){let{utilsScript:t,initialCountry:e,geoIpLookup:i}=this.d;t&&!a.utils?a.documentReady()?a.loadUtils(t):window.addEventListener("load",()=>{a.loadUtils(t)}):this.i0(),e==="auto"&&i&&!this.s.iso2?this._i4():this.h()}_i4(){a.autoCountry?this.handleAutoCountry():a.startedLoadingAutoCountry||(a.startedLoadingAutoCountry=!0,typeof this.d.geoIpLookup=="function"&&this.d.geoIpLookup((t="")=>{let e=t.toLowerCase();e&&this._y(e,!0)?(a.autoCountry=e,setTimeout(()=>b("handleAutoCountry"))):(this._h(!0),b("rejectAutoCountryPromise"))},()=>{this._h(!0),b("rejectAutoCountryPromise")}))}_j(){let{strictMode:t,formatAsYouType:e,separateDialCode:i,formatOnDisplay:n}=this.d,s=!1,o=()=>{this._n(),this.searchInput.value="+",this._p3("",!0)};this._a12=r=>{if(this.isAndroid&&r?.data==="+"&&i){let d=this.a.selectionStart||0,p=this.a.value.substring(0,d-1),m=this.a.value.substring(d);this.a.value=p+m,o();return}this._v(this.a.value)&&this._8();let u=r?.data&&/[^+0-9]/.test(r.data),h=r?.inputType==="insertFromPaste"&&this.a.value;u||h&&!t?s=!0:/[^+0-9]/.test(this.a.value)||(s=!1);let g=r?.detail&&r.detail.isSetNumber&&!n;if(e&&!s&&!g){let d=this.a.selectionStart||0,m=this.a.value.substring(0,d).replace(/[^+0-9]/g,"").length,y=r?.inputType==="deleteContentForward",C=this._9(),L=j(m,C,d,y);this.a.value=C,this.a.setSelectionRange(L,L)}},this.a.addEventListener("input",this._a12),(t||i)&&(this._handleKeydownEvent=r=>{if(r.key&&r.key.length===1&&!r.altKey&&!r.ctrlKey&&!r.metaKey){if(i&&r.key==="+"){r.preventDefault(),o();return}if(t){let u=this.a.selectionStart===0&&r.key==="+",h=/^[0-9]$/.test(r.key),g=u||h,d=this._6(),p=a.utils.getCoreNumber(d,this.s.iso2),m=this.maxCoreNumberLength&&p.length>=this.maxCoreNumberLength,y=this.a.value.substring(this.a.selectionStart,this.a.selectionEnd),C=/\d/.test(y);(!g||m&&!C)&&r.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,e={}){let i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:e});this.a.dispatchEvent(i)}_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(),e){let i=this.countryList.firstElementChild;i&&(this._x(i,!1),this.countryList.scrollTop=0),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=this.a.offsetHeight;this.d.dropdownContainer&&(this.dropdown.style.top=`${t.top+e}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._searchForCountry(e),i=setTimeout(()=>{e=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){let n=()=>{let o=this.searchInput.value.trim();o?this._p3(o):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",o=>o.stopPropagation())}}_searchForCountry(t){for(let e=0;e1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e&&(this._3(e),this._x(e,!1))}_r(){this.c&&this._1(this.c)}_u(t){let e=t;if(this.d.formatOnDisplay&&a.utils&&this.s){let i=this.d.nationalMode||e.charAt(0)!=="+"&&!this.d.separateDialCode,{NATIONAL:n,INTERNATIONAL:s}=a.utils.numberFormat,o=i?n:s;e=a.utils.formatNumber(e,this.s.iso2,o)}e=this._7(e),this.a.value=e}_v(t){let e=t.indexOf("+"),i=e?t.substring(e):t,n=this.s.dialCode;i&&n==="1"&&i.charAt(0)!=="+"&&(i.charAt(0)!=="1"&&(i=`1${i}`),i=`+${i}`),this.d.separateDialCode&&n&&i.charAt(0)!=="+"&&(i=`+${n}${i}`);let o=this._5(i,!0),r=v(i),u=null;if(o){let h=this.q[v(o)],g=h.indexOf(this.s.iso2)!==-1&&r.length<=o.length-1;if(!(n==="1"&&A(r))&&!g){for(let p=0;po){let d=n-r;e.scrollTop=g-d}}_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!a.utils&&!a.startedLoadingUtilsScript?(a.startedLoadingUtilsScript=!0,new Promise((t,e)=>{import(/* webpackIgnore: true */ l).then(({default:i})=>{a.utils=i,b("handleUtils"),t(!0)}).catch(()=>{b("rejectUtilsScriptPromise"),e()})})):null,a=Object.assign((l,t)=>{let e=new _(l,t);return e._init(),l.setAttribute("data-intl-tel-input-id",e.id.toString()),a.instances[e.id]=e,e},{defaults:N,documentReady:()=>document.readyState==="complete",getCountryData:()=>f,getInstance:l=>{let t=l.getAttribute("data-intl-tel-input-id");return t?a.instances[t]:null},instances:{},loadUtils:B,version:"23.4.0"}),K=a;return R(U);})(); // UMD return factoryOutput.default; diff --git a/build/js/intlTelInputWithUtils.js b/build/js/intlTelInputWithUtils.js index 400f27c6..65d74d7d 100644 --- a/build/js/intlTelInputWithUtils.js +++ b/build/js/intlTelInputWithUtils.js @@ -1535,6 +1535,13 @@ var factoryOutput = (() => { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2652,7 +2659,8 @@ var factoryOutput = (() => { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2676,6 +2684,13 @@ var factoryOutput = (() => { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/build/js/intlTelInputWithUtils.min.js b/build/js/intlTelInputWithUtils.min.js index 488e2011..0752ab72 100644 --- a/build/js/intlTelInputWithUtils.min.js +++ b/build/js/intlTelInputWithUtils.min.js @@ -13,7 +13,7 @@ } }(() => { -var factoryOutput=(()=>{var m1=Object.defineProperty;var D2=Object.getOwnPropertyDescriptor;var x2=Object.getOwnPropertyNames;var P2=Object.prototype.hasOwnProperty;var k2=(C,n)=>{for(var $ in n)m1(C,$,{get:n[$],enumerable:!0})},R2=(C,n,$,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of x2(n))!P2.call(C,a)&&a!==$&&m1(C,a,{get:()=>n[a],enumerable:!(r=D2(n,a))||r.enumerable});return C};var O2=C=>R2(m1({},"__esModule",{value:!0}),C);var j2={};k2(j2,{default:()=>F2});var n2=[["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"]]],$2=[];for(let C=0;CC.replace(/\D/g,""),s2=(C="")=>C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),o2=C=>{let n=l1(C);if(n.charAt(0)==="1"){let $=n.substr(1,3);return G2.indexOf($)!==-1}return!1},H2=(C,n,$,r)=>{if($===0&&!r)return 0;let a=0;for(let l=0;l{let r=document.createElement(C);return n&&Object.entries(n).forEach(([a,l])=>r.setAttribute(a,l)),$&&$.appendChild(r),r},d1=C=>{let{instances:n}=m;Object.values(n).forEach($=>$[C]())},y1=class{constructor(n,$={}){this.id=B2++,this.telInput=n,this.highlightedItem=null,this.options=Object.assign({},u2,$),this.hadInitialPlaceholder=!!n.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.separateDialCode&&(this.options.allowDropdown=!0,this.options.nationalMode=!1,this.options.countrySearch=!0),!this.options.showFlags&&!this.options.separateDialCode&&(this.options.nationalMode=!1),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isAndroid=typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1,this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.i18n={...C1,...this.options.i18n};let n=new Promise((r,a)=>{this.resolveAutoCountryPromise=r,this.rejectAutoCountryPromise=a}),$=new Promise((r,a)=>{this.resolveUtilsScriptPromise=r,this.rejectUtilsScriptPromise=a});this.promise=Promise.all([n,$]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._translateCountryNames(),this.options.countryOrder&&(this.options.countryOrder=this.options.countryOrder.map(n=>n.toLowerCase())),this._sortCountries()}_sortCountries(){this.countries.sort((n,$)=>{let{countryOrder:r}=this.options;if(r){let a=r.indexOf(n.iso2),l=r.indexOf($.iso2),g=a>-1,p=l>-1;if(g||p)return g&&p?a-l:g?-1:1}return n.name<$.name?-1:n.name>$.name?1:0})}_addToDialCodeMap(n,$,r){$.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=$.length),this.dialCodeToIso2Map.hasOwnProperty($)||(this.dialCodeToIso2Map[$]=[]);for(let l=0;la.toLowerCase());this.countries=F.filter(a=>r.indexOf(a.iso2)>-1)}else if($.length){let r=$.map(a=>a.toLowerCase());this.countries=F.filter(a=>r.indexOf(a.iso2)===-1)}else this.countries=F}_translateCountryNames(){for(let n=0;n
`),l+=`${$.name}`,l+=`+${$.dialCode}`,a.insertAdjacentHTML("beforeend",l)}}_setInitialState(n=!1){let $=this.telInput.getAttribute("value"),r=this.telInput.value,l=$&&$.charAt(0)==="+"&&(!r||r.charAt(0)!=="+")?$:r,g=this._getDialCode(l),p=o2(l),{initialCountry:y,geoIpLookup:_}=this.options,w=y==="auto"&&_;if(g&&!p)this._updateCountryFromNumber(l);else if(!w||n){let I=y?y.toLowerCase():"";I&&this._getCountryData(I,!0)?this._setCountry(I):g&&p?this._setCountry("us"):this._setCountry()}l&&this._updateValFromNumber(l)}_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=$=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():$.preventDefault()};let n=this.telInput.closest("label");n&&n.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=$=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes($.key)&&($.preventDefault(),$.stopPropagation(),this._openDropdown()),$.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){let{utilsScript:n,initialCountry:$,geoIpLookup:r}=this.options;n&&!m.utils?m.documentReady()?m.loadUtils(n):window.addEventListener("load",()=>{m.loadUtils(n)}):this.resolveUtilsScriptPromise(),$==="auto"&&r&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){m.autoCountry?this.handleAutoCountry():m.startedLoadingAutoCountry||(m.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((n="")=>{let $=n.toLowerCase();$&&this._getCountryData($,!0)?(m.autoCountry=$,setTimeout(()=>d1("handleAutoCountry"))):(this._setInitialState(!0),d1("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),d1("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:n,formatAsYouType:$,separateDialCode:r,formatOnDisplay:a}=this.options,l=!1,g=()=>{this._openDropdown(),this.searchInput.value="+",this._filterCountries("",!0)};this._handleInputEvent=p=>{if(this.isAndroid&&p?.data==="+"&&r){let I=this.telInput.selectionStart||0,S=this.telInput.value.substring(0,I-1),P=this.telInput.value.substring(I);this.telInput.value=S+P,g();return}this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let y=p?.data&&/[^+0-9]/.test(p.data),_=p?.inputType==="insertFromPaste"&&this.telInput.value;y||_&&!n?l=!0:/[^+0-9]/.test(this.telInput.value)||(l=!1);let w=p?.detail&&p.detail.isSetNumber&&!a;if($&&!l&&!w){let I=this.telInput.selectionStart||0,P=this.telInput.value.substring(0,I).replace(/[^+0-9]/g,"").length,k=p?.inputType==="deleteContentForward",O=this._formatNumberAsYouType(),t1=H2(P,O,I,k);this.telInput.value=O,this.telInput.setSelectionRange(t1,t1)}},this.telInput.addEventListener("input",this._handleInputEvent),(n||r)&&(this._handleKeydownEvent=p=>{if(p.key&&p.key.length===1&&!p.altKey&&!p.ctrlKey&&!p.metaKey){if(r&&p.key==="+"){p.preventDefault(),g();return}if(n){let y=this.telInput.selectionStart===0&&p.key==="+",_=/^[0-9]$/.test(p.key),w=y||_,I=this._getFullNumber(),S=m.utils.getCoreNumber(I,this.selectedCountryData.iso2),P=this.maxCoreNumberLength&&S.length>=this.maxCoreNumberLength,k=this.telInput.value.substring(this.telInput.selectionStart,this.telInput.selectionEnd),O=/\d/.test(k);(!w||P&&!O)&&p.preventDefault()}}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(n){let $=parseInt(this.telInput.getAttribute("maxlength")||"",10);return $&&n.length>$?n.substr(0,$):n}_trigger(n,$={}){let r=new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:$});this.telInput.dispatchEvent(r)}_openDropdown(){let{fixDropdownWidth:n,countrySearch:$}=this.options;if(n&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),$){let r=this.countryList.firstElementChild;r&&(this._highlightListItem(r,!1),this.countryList.scrollTop=0),this.searchInput.focus()}this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}_setDropdownPosition(){if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){let n=this.telInput.getBoundingClientRect(),$=this.telInput.offsetHeight;this.options.dropdownContainer&&(this.dropdown.style.top=`${n.top+$}px`,this.dropdown.style.left=`${n.left}px`,this._handleWindowScroll=()=>this._closeDropdown(),window.addEventListener("scroll",this._handleWindowScroll))}}_bindDropdownListeners(){this._handleMouseoverCountryList=a=>{let l=a.target?.closest(".iti__country");l&&this._highlightListItem(l,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=a=>{let l=a.target?.closest(".iti__country");l&&this._selectListItem(l)},this.countryList.addEventListener("click",this._handleClickCountryList);let n=!0;this._handleClickOffToClose=()=>{n||this._closeDropdown(),n=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let $="",r=null;if(this._handleKeydownOnDropdown=a=>{["ArrowUp","ArrowDown","Enter","Escape"].includes(a.key)&&(a.preventDefault(),a.stopPropagation(),a.key==="ArrowUp"||a.key==="ArrowDown"?this._handleUpDownKey(a.key):a.key==="Enter"?this._handleEnterKey():a.key==="Escape"&&this._closeDropdown()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(a.key)&&(a.stopPropagation(),r&&clearTimeout(r),$+=a.key.toLowerCase(),this._searchForCountry($),r=setTimeout(()=>{$=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let a=()=>{let g=this.searchInput.value.trim();g?this._filterCountries(g):this._filterCountries("",!0)},l=null;this._handleSearchChange=()=>{l&&clearTimeout(l),l=setTimeout(()=>{a(),l=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",g=>g.stopPropagation())}}_searchForCountry(n){for(let $=0;$1&&($=n==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),$&&(this._scrollTo($),this._highlightListItem($,!1))}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_updateValFromNumber(n){let $=n;if(this.options.formatOnDisplay&&m.utils&&this.selectedCountryData){let r=this.options.nationalMode||$.charAt(0)!=="+"&&!this.options.separateDialCode,{NATIONAL:a,INTERNATIONAL:l}=m.utils.numberFormat,g=r?a:l;$=m.utils.formatNumber($,this.selectedCountryData.iso2,g)}$=this._beforeSetNumber($),this.telInput.value=$}_updateCountryFromNumber(n){let $=n.indexOf("+"),r=$?n.substring($):n,a=this.selectedCountryData.dialCode;r&&a==="1"&&r.charAt(0)!=="+"&&(r.charAt(0)!=="1"&&(r=`1${r}`),r=`+${r}`),this.options.separateDialCode&&a&&r.charAt(0)!=="+"&&(r=`+${a}${r}`);let g=this._getDialCode(r,!0),p=l1(r),y=null;if(g){let _=this.dialCodeToIso2Map[l1(g)],w=_.indexOf(this.selectedCountryData.iso2)!==-1&&p.length<=g.length-1;if(!(a==="1"&&o2(p))&&!w){for(let S=0;S<_.length;S++)if(_[S]){y=_[S];break}}}else r.charAt(0)==="+"&&p.length?y="":(!r||r==="+")&&!this.selectedCountryData.iso2&&(y=this.defaultCountry);return y!==null?this._setCountry(y):!1}_highlightListItem(n,$){let r=this.highlightedItem;if(r&&(r.classList.remove("iti__highlight"),r.setAttribute("aria-selected","false")),this.highlightedItem=n,this.highlightedItem){this.highlightedItem.classList.add("iti__highlight"),this.highlightedItem.setAttribute("aria-selected","true");let a=this.highlightedItem.getAttribute("id")||"";this.selectedCountry.setAttribute("aria-activedescendant",a),this.options.countrySearch&&this.searchInput.setAttribute("aria-activedescendant",a)}$&&this.highlightedItem.focus()}_getCountryData(n,$){for(let r=0;rg){let I=a-p;$.scrollTop=w-I}}_updateDialCode(n){let $=this.telInput.value,r=`+${n}`,a;if($.charAt(0)==="+"){let l=this._getDialCode($);l?a=$.replace(l,r):a=r,this.telInput.value=a}}_getDialCode(n,$){let r="";if(n.charAt(0)==="+"){let a="";for(let l=0;l!m.utils&&!m.startedLoadingUtilsScript?(m.startedLoadingUtilsScript=!0,new Promise((n,$)=>{import_INTENTIONALLY_BROKEN(/* webpackIgnore: true */ C).then(({default:r})=>{m.utils=r,d1("handleUtils"),n(!0)}).catch(()=>{d1("rejectUtilsScriptPromise"),$()})})):null,m=Object.assign((C,n)=>{let $=new y1(C,n);return $._init(),C.setAttribute("data-intl-tel-input-id",$.id.toString()),m.instances[$.id]=$,$},{defaults:u2,documentReady:()=>document.readyState==="complete",getCountryData:()=>F,getInstance:C=>{let n=C.getAttribute("data-intl-tel-input-id");return n?m.instances[n]:null},instances:{},loadUtils:U2,version:"23.4.0"}),v1=m;(function(){var C=this||self;function n(d,t){d=d.split(".");var e=C;d[0]in e||typeof e.execScript>"u"||e.execScript("var "+d[0]);for(var i;d.length&&(i=d.shift());)d.length||t===void 0?e[i]&&e[i]!==Object.prototype[i]?e=e[i]:e=e[i]={}:e[i]=t}function $(d,t){function e(){}e.prototype=t.prototype,d.ma=t.prototype,d.prototype=new e,d.prototype.constructor=d,d.sa=function(i,s,o){for(var u=Array(arguments.length-2),h=2;hd.length?!1:B(T2,d)}function x1(d){return B(_2,d)?i1(d,C2):i1(d,c1)}function P1(d){var t=x1(d.toString());x(d),d.g(t)}function k1(d){return d!=null&&(H(d,9)!=1||N(d,9)[0]!=-1)}function i1(d,t){for(var e=new T,i,s=d.length,o=0;ot?2:o[o.length-1]=s&&s<=i;++s)if(e=parseInt(d.substring(0,s),10),e in Y)return t.g(d.substring(s)),e;return 0}function U1(d,t,e,i,s,o){if(t.length==0)return 0;t=new T(t);var u;e!=null&&(u=c(e,11)),u==null&&(u="NonMatch");var h=t.toString();if(h.length==0)u=20;else if(J.test(h))h=h.replace(J,""),x(t),t.g(x1(h)),u=1;else{if(h=new RegExp(u),P1(t),u=t.toString(),u.search(h)==0){h=u.match(h)[0].length;var f=u.substring(h).match(A1);f&&f[1]!=null&&0=t.h.length)throw Error("Phone number too short after IDD");if(d=H1(t,i),d!=0)return E(o,1,d),d;throw Error("Invalid country calling code")}return e!=null&&(u=v(e,10),h=""+u,f=t.toString(),f.lastIndexOf(h,0)==0&&(h=new T(f.substring(h.length)),f=c(e,1),f=new RegExp(v(f,2)),K1(h,e,null),h=h.toString(),!B(f,t.toString())&&B(f,h)||o1(d,t.toString(),e,-1)==3))?(i.g(h),s&&E(o,6,10),E(o,1,u),u):(E(o,1,0),0)}function K1(d,t,e){var i=d.toString(),s=i.length,o=c(t,15);if(s!=0&&o!=null&&o.length!=0){var u=new RegExp("^(?:"+o+")");if(s=u.exec(i)){o=new RegExp(v(c(t,1),2));var h=B(o,i),f=s.length-1;t=c(t,16),t==null||t.length==0||s[f]==null||s[f].length==0?(!h||B(o,i.substring(s[0].length)))&&(e!=null&&0=t.length)o="";else{var u=t.indexOf(";",o);o=u!==-1?t.substring(o,u):t.substring(o)}var h=o;if(h==null?u=!0:h.length===0?u=!1:(u=S2.exec(h),h=w2.exec(h),u=u!==null||h!==null),!u||(o!=null?(o.charAt(0)==="+"&&s.g(o),o=t.indexOf("tel:"),s.g(t.substring(0<=o?o+4:0,t.indexOf(";phone-context=")))):(o=s.g,u=t??"",h=u.search(v2),0<=h?(u=u.substring(h),u=u.replace(b2,""),h=u.search(I2),0<=h&&(u=u.substring(0,h))):u="",o.call(s,u)),o=s.toString(),u=o.indexOf(";isub="),0t.h.length||(u!=null&&(e=new T,s=new T(t.toString()),K1(s,u,e),d=o1(d,s.toString(),u,-1),d!=2&&d!=4&&d!=5&&(t=s,i&&0d))throw Error("The string supplied is too short to be a phone number");if(17{try{let e=d.replace(/[^+0-9]/g,""),i=new A2(t);t="";for(let s=0;s{try{let s=A.g(),o=z(s,d,t);var i=u1(s,o,-1);return i==0||i==4?s.format(o,typeof e>"u"?0:e):d}catch{return d}}),n("intlTelInputUtilsTemp.getExampleNumber",(d,t,e,i)=>{try{let f=A.g();d:{var s=f;if(r1(d)){var o=s1(K(s,d),e);try{if(D(o,6)){var u=c(o,6),h=F1(s,u,d,!1);break d}}catch{}}h=null}return f.format(h,i?0:t?2:1)}catch{return""}}),n("intlTelInputUtilsTemp.getExtension",(d,t)=>{try{return c(z(A.g(),d,t),3)}catch{return""}}),n("intlTelInputUtilsTemp.getNumberType",(d,t)=>{try{let u=A.g(),h=z(u,d,t);var e=B1(u,h),i=q(u,v(h,1),e);if(i==null)var s=-1;else{var o=X(h);s=p1(o,i)}return s}catch{return-99}}),n("intlTelInputUtilsTemp.getValidationError",(d,t)=>{try{let e=A.g(),i=z(e,d,t);return u1(e,i,-1)}catch(e){return e.message==="Invalid country calling code"?1:3>=d.length||e.message==="Phone number too short after IDD"||e.message==="The string supplied is too short to be a phone number"?2:e.message==="The string supplied is too long to be a phone number"?3:-99}}),n("intlTelInputUtilsTemp.isValidNumber",(d,t)=>{try{let f=A.g();var e=z(f,d,t),i=B1(f,e);d=f;var s=v(e,1),o=q(d,s,i);if(o==null||i!="001"&&s!=G1(d,i))var u=!1;else{var h=X(e);u=p1(h,o)!=-1}return u}catch{return!1}}),n("intlTelInputUtilsTemp.isPossibleNumber",(d,t,e)=>{try{let i=A.g(),s=z(i,d,t);return e?u1(i,s,e2[e])===0:u1(i,s,-1)===0}catch{return!1}}),n("intlTelInputUtilsTemp.getCoreNumber",(d,t)=>{try{return c(z(A.g(),d,t),2).toString()}catch{return""}}),n("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3}),n("intlTelInputUtilsTemp.numberType",e2),n("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5})})();var K2=window.intlTelInputUtilsTemp;delete window.intlTelInputUtilsTemp;var a2=K2;v1.utils=a2;var F2=v1;return O2(j2);})(); +var factoryOutput=(()=>{var m1=Object.defineProperty;var D2=Object.getOwnPropertyDescriptor;var x2=Object.getOwnPropertyNames;var P2=Object.prototype.hasOwnProperty;var R2=(C,n)=>{for(var $ in n)m1(C,$,{get:n[$],enumerable:!0})},k2=(C,n,$,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of x2(n))!P2.call(C,u)&&u!==$&&m1(C,u,{get:()=>n[u],enumerable:!(r=D2(n,u))||r.enumerable});return C};var O2=C=>k2(m1({},"__esModule",{value:!0}),C);var j2={};R2(j2,{default:()=>F2});var n2=[["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"]]],$2=[];for(let C=0;CC.replace(/\D/g,""),s2=(C="")=>C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),o2=C=>{let n=l1(C);if(n.charAt(0)==="1"){let $=n.substr(1,3);return G2.indexOf($)!==-1}return!1},H2=(C,n,$,r)=>{if($===0&&!r)return 0;let u=0;for(let l=0;l{let r=document.createElement(C);return n&&Object.entries(n).forEach(([u,l])=>r.setAttribute(u,l)),$&&$.appendChild(r),r},d1=C=>{let{instances:n}=m;Object.values(n).forEach($=>$[C]())},y1=class{constructor(n,$={}){this.id=B2++,this.telInput=n,this.highlightedItem=null,this.options=Object.assign({},u2,$),this.hadInitialPlaceholder=!!n.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.separateDialCode&&(this.options.allowDropdown=!0,this.options.nationalMode=!1,this.options.countrySearch=!0),!this.options.showFlags&&!this.options.separateDialCode&&(this.options.nationalMode=!1),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isAndroid=typeof navigator<"u"?/Android/i.test(navigator.userAgent):!1,this.isRTL=!!this.telInput.closest("[dir=rtl]"),this.options.separateDialCode&&(this.isRTL?this.originalPaddingRight=this.telInput.style.paddingRight:this.originalPaddingLeft=this.telInput.style.paddingLeft),this.options.i18n={...C1,...this.options.i18n};let n=new Promise((r,u)=>{this.resolveAutoCountryPromise=r,this.rejectAutoCountryPromise=u}),$=new Promise((r,u)=>{this.resolveUtilsScriptPromise=r,this.rejectUtilsScriptPromise=u});this.promise=Promise.all([n,$]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._translateCountryNames(),this.options.countryOrder&&(this.options.countryOrder=this.options.countryOrder.map(n=>n.toLowerCase())),this._sortCountries()}_sortCountries(){this.countries.sort((n,$)=>{let{countryOrder:r}=this.options;if(r){let u=r.indexOf(n.iso2),l=r.indexOf($.iso2),g=u>-1,p=l>-1;if(g||p)return g&&p?u-l:g?-1:1}return n.name<$.name?-1:n.name>$.name?1:0})}_addToDialCodeMap(n,$,r){$.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=$.length),this.dialCodeToIso2Map.hasOwnProperty($)||(this.dialCodeToIso2Map[$]=[]);for(let l=0;lu.toLowerCase());this.countries=F.filter(u=>r.indexOf(u.iso2)>-1)}else if($.length){let r=$.map(u=>u.toLowerCase());this.countries=F.filter(u=>r.indexOf(u.iso2)===-1)}else this.countries=F}_translateCountryNames(){for(let n=0;n
`),l+=`${$.name}`,l+=`+${$.dialCode}`,u.insertAdjacentHTML("beforeend",l)}}_setInitialState(n=!1){let $=this.telInput.getAttribute("value"),r=this.telInput.value,l=$&&$.charAt(0)==="+"&&(!r||r.charAt(0)!=="+")?$:r,g=this._getDialCode(l),p=o2(l),{initialCountry:y,geoIpLookup:_}=this.options,w=y==="auto"&&_;if(g&&!p)this._updateCountryFromNumber(l);else if(!w||n){let I=y?y.toLowerCase():"";I&&this._getCountryData(I,!0)?this._setCountry(I):g&&p?this._setCountry("us"):this._setCountry()}l&&this._updateValFromNumber(l)}_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=$=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():$.preventDefault()};let n=this.telInput.closest("label");n&&n.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=$=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes($.key)&&($.preventDefault(),$.stopPropagation(),this._openDropdown()),$.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){let{utilsScript:n,initialCountry:$,geoIpLookup:r}=this.options;n&&!m.utils?m.documentReady()?m.loadUtils(n):window.addEventListener("load",()=>{m.loadUtils(n)}):this.resolveUtilsScriptPromise(),$==="auto"&&r&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){m.autoCountry?this.handleAutoCountry():m.startedLoadingAutoCountry||(m.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((n="")=>{let $=n.toLowerCase();$&&this._getCountryData($,!0)?(m.autoCountry=$,setTimeout(()=>d1("handleAutoCountry"))):(this._setInitialState(!0),d1("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),d1("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:n,formatAsYouType:$,separateDialCode:r,formatOnDisplay:u}=this.options,l=!1,g=()=>{this._openDropdown(),this.searchInput.value="+",this._filterCountries("",!0)};this._handleInputEvent=p=>{if(this.isAndroid&&p?.data==="+"&&r){let I=this.telInput.selectionStart||0,S=this.telInput.value.substring(0,I-1),P=this.telInput.value.substring(I);this.telInput.value=S+P,g();return}this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let y=p?.data&&/[^+0-9]/.test(p.data),_=p?.inputType==="insertFromPaste"&&this.telInput.value;y||_&&!n?l=!0:/[^+0-9]/.test(this.telInput.value)||(l=!1);let w=p?.detail&&p.detail.isSetNumber&&!u;if($&&!l&&!w){let I=this.telInput.selectionStart||0,P=this.telInput.value.substring(0,I).replace(/[^+0-9]/g,"").length,R=p?.inputType==="deleteContentForward",O=this._formatNumberAsYouType(),t1=H2(P,O,I,R);this.telInput.value=O,this.telInput.setSelectionRange(t1,t1)}},this.telInput.addEventListener("input",this._handleInputEvent),(n||r)&&(this._handleKeydownEvent=p=>{if(p.key&&p.key.length===1&&!p.altKey&&!p.ctrlKey&&!p.metaKey){if(r&&p.key==="+"){p.preventDefault(),g();return}if(n){let y=this.telInput.selectionStart===0&&p.key==="+",_=/^[0-9]$/.test(p.key),w=y||_,I=this._getFullNumber(),S=m.utils.getCoreNumber(I,this.selectedCountryData.iso2),P=this.maxCoreNumberLength&&S.length>=this.maxCoreNumberLength,R=this.telInput.value.substring(this.telInput.selectionStart,this.telInput.selectionEnd),O=/\d/.test(R);(!w||P&&!O)&&p.preventDefault()}}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(n){let $=parseInt(this.telInput.getAttribute("maxlength")||"",10);return $&&n.length>$?n.substr(0,$):n}_trigger(n,$={}){let r=new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:$});this.telInput.dispatchEvent(r)}_openDropdown(){let{fixDropdownWidth:n,countrySearch:$}=this.options;if(n&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),$){let r=this.countryList.firstElementChild;r&&(this._highlightListItem(r,!1),this.countryList.scrollTop=0),this.searchInput.focus()}this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}_setDropdownPosition(){if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){let n=this.telInput.getBoundingClientRect(),$=this.telInput.offsetHeight;this.options.dropdownContainer&&(this.dropdown.style.top=`${n.top+$}px`,this.dropdown.style.left=`${n.left}px`,this._handleWindowScroll=()=>this._closeDropdown(),window.addEventListener("scroll",this._handleWindowScroll))}}_bindDropdownListeners(){this._handleMouseoverCountryList=u=>{let l=u.target?.closest(".iti__country");l&&this._highlightListItem(l,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=u=>{let l=u.target?.closest(".iti__country");l&&this._selectListItem(l)},this.countryList.addEventListener("click",this._handleClickCountryList);let n=!0;this._handleClickOffToClose=()=>{n||this._closeDropdown(),n=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let $="",r=null;if(this._handleKeydownOnDropdown=u=>{["ArrowUp","ArrowDown","Enter","Escape"].includes(u.key)&&(u.preventDefault(),u.stopPropagation(),u.key==="ArrowUp"||u.key==="ArrowDown"?this._handleUpDownKey(u.key):u.key==="Enter"?this._handleEnterKey():u.key==="Escape"&&this._closeDropdown()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(u.key)&&(u.stopPropagation(),r&&clearTimeout(r),$+=u.key.toLowerCase(),this._searchForCountry($),r=setTimeout(()=>{$=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let u=()=>{let g=this.searchInput.value.trim();g?this._filterCountries(g):this._filterCountries("",!0)},l=null;this._handleSearchChange=()=>{l&&clearTimeout(l),l=setTimeout(()=>{u(),l=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",g=>g.stopPropagation())}}_searchForCountry(n){for(let $=0;$1&&($=n==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),$&&(this._scrollTo($),this._highlightListItem($,!1))}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_updateValFromNumber(n){let $=n;if(this.options.formatOnDisplay&&m.utils&&this.selectedCountryData){let r=this.options.nationalMode||$.charAt(0)!=="+"&&!this.options.separateDialCode,{NATIONAL:u,INTERNATIONAL:l}=m.utils.numberFormat,g=r?u:l;$=m.utils.formatNumber($,this.selectedCountryData.iso2,g)}$=this._beforeSetNumber($),this.telInput.value=$}_updateCountryFromNumber(n){let $=n.indexOf("+"),r=$?n.substring($):n,u=this.selectedCountryData.dialCode;r&&u==="1"&&r.charAt(0)!=="+"&&(r.charAt(0)!=="1"&&(r=`1${r}`),r=`+${r}`),this.options.separateDialCode&&u&&r.charAt(0)!=="+"&&(r=`+${u}${r}`);let g=this._getDialCode(r,!0),p=l1(r),y=null;if(g){let _=this.dialCodeToIso2Map[l1(g)],w=_.indexOf(this.selectedCountryData.iso2)!==-1&&p.length<=g.length-1;if(!(u==="1"&&o2(p))&&!w){for(let S=0;S<_.length;S++)if(_[S]){y=_[S];break}}}else r.charAt(0)==="+"&&p.length?y="":(!r||r==="+")&&!this.selectedCountryData.iso2&&(y=this.defaultCountry);return y!==null?this._setCountry(y):!1}_highlightListItem(n,$){let r=this.highlightedItem;if(r&&(r.classList.remove("iti__highlight"),r.setAttribute("aria-selected","false")),this.highlightedItem=n,this.highlightedItem){this.highlightedItem.classList.add("iti__highlight"),this.highlightedItem.setAttribute("aria-selected","true");let u=this.highlightedItem.getAttribute("id")||"";this.selectedCountry.setAttribute("aria-activedescendant",u),this.options.countrySearch&&this.searchInput.setAttribute("aria-activedescendant",u)}$&&this.highlightedItem.focus()}_getCountryData(n,$){for(let r=0;rg){let I=u-p;$.scrollTop=w-I}}_updateDialCode(n){let $=this.telInput.value,r=`+${n}`,u;if($.charAt(0)==="+"){let l=this._getDialCode($);l?u=$.replace(l,r):u=r,this.telInput.value=u}}_getDialCode(n,$){let r="";if(n.charAt(0)==="+"){let u="";for(let l=0;l!m.utils&&!m.startedLoadingUtilsScript?(m.startedLoadingUtilsScript=!0,new Promise((n,$)=>{import_INTENTIONALLY_BROKEN(/* webpackIgnore: true */ C).then(({default:r})=>{m.utils=r,d1("handleUtils"),n(!0)}).catch(()=>{d1("rejectUtilsScriptPromise"),$()})})):null,m=Object.assign((C,n)=>{let $=new y1(C,n);return $._init(),C.setAttribute("data-intl-tel-input-id",$.id.toString()),m.instances[$.id]=$,$},{defaults:u2,documentReady:()=>document.readyState==="complete",getCountryData:()=>F,getInstance:C=>{let n=C.getAttribute("data-intl-tel-input-id");return n?m.instances[n]:null},instances:{},loadUtils:U2,version:"23.4.0"}),v1=m;(function(){var C=this||self;function n(d,t){d=d.split(".");var e=C;d[0]in e||typeof e.execScript>"u"||e.execScript("var "+d[0]);for(var i;d.length&&(i=d.shift());)d.length||t===void 0?e[i]&&e[i]!==Object.prototype[i]?e=e[i]:e=e[i]={}:e[i]=t}function $(d,t){function e(){}e.prototype=t.prototype,d.ma=t.prototype,d.prototype=new e,d.prototype.constructor=d,d.sa=function(i,s,o){for(var a=Array(arguments.length-2),h=2;hd.length?!1:B(T2,d)}function x1(d){return B(_2,d)?i1(d,C2):i1(d,c1)}function P1(d){var t=x1(d.toString());x(d),d.g(t)}function R1(d){return d!=null&&(H(d,9)!=1||N(d,9)[0]!=-1)}function i1(d,t){for(var e=new T,i,s=d.length,o=0;ot?2:o[o.length-1]=s&&s<=i;++s)if(e=parseInt(d.substring(0,s),10),e in Y)return t.g(d.substring(s)),e;return 0}function U1(d,t,e,i,s,o){if(t.length==0)return 0;t=new T(t);var a;e!=null&&(a=c(e,11)),a==null&&(a="NonMatch");var h=t.toString();if(h.length==0)a=20;else if(J.test(h))h=h.replace(J,""),x(t),t.g(x1(h)),a=1;else{if(h=new RegExp(a),P1(t),a=t.toString(),a.search(h)==0){h=a.match(h)[0].length;var f=a.substring(h).match(A1);f&&f[1]!=null&&0=t.h.length)throw Error("Phone number too short after IDD");if(d=H1(t,i),d!=0)return E(o,1,d),d;throw Error("Invalid country calling code")}return e!=null&&(a=v(e,10),h=""+a,f=t.toString(),f.lastIndexOf(h,0)==0&&(h=new T(f.substring(h.length)),f=c(e,1),f=new RegExp(v(f,2)),K1(h,e,null),h=h.toString(),!B(f,t.toString())&&B(f,h)||o1(d,t.toString(),e,-1)==3))?(i.g(h),s&&E(o,6,10),E(o,1,a),a):(E(o,1,0),0)}function K1(d,t,e){var i=d.toString(),s=i.length,o=c(t,15);if(s!=0&&o!=null&&o.length!=0){var a=new RegExp("^(?:"+o+")");if(s=a.exec(i)){o=new RegExp(v(c(t,1),2));var h=B(o,i),f=s.length-1;t=c(t,16),t==null||t.length==0||s[f]==null||s[f].length==0?(!h||B(o,i.substring(s[0].length)))&&(e!=null&&0=t.length)o="";else{var a=t.indexOf(";",o);o=a!==-1?t.substring(o,a):t.substring(o)}var h=o;if(h==null?a=!0:h.length===0?a=!1:(a=S2.exec(h),h=w2.exec(h),a=a!==null||h!==null),!a||(o!=null?(o.charAt(0)==="+"&&s.g(o),o=t.indexOf("tel:"),s.g(t.substring(0<=o?o+4:0,t.indexOf(";phone-context=")))):(o=s.g,a=t??"",h=a.search(v2),0<=h?(a=a.substring(h),a=a.replace(b2,""),h=a.search(I2),0<=h&&(a=a.substring(0,h))):a="",o.call(s,a)),o=s.toString(),a=o.indexOf(";isub="),0t.h.length||(a!=null&&(e=new T,s=new T(t.toString()),K1(s,a,e),d=o1(d,s.toString(),a,-1),d!=2&&d!=4&&d!=5&&(t=s,i&&0d))throw Error("The string supplied is too short to be a phone number");if(17{try{let e=d.replace(/[^+0-9]/g,""),i=new A2(t);t="";for(let s=0;s{try{let s=A.g(),o=z(s,d,t);var i=u1(s,o,-1);return i==0||i==4?s.format(o,typeof e>"u"?0:e):d}catch{return d}}),n("intlTelInputUtilsTemp.getExampleNumber",(d,t,e,i)=>{try{let f=A.g();d:{var s=f;if(r1(d)){var o=s1(K(s,d),e);try{if(D(o,6)){var a=c(o,6),h=F1(s,a,d,!1);break d}}catch{}}h=null}return f.format(h,i?0:t?2:1)}catch{return""}}),n("intlTelInputUtilsTemp.getExtension",(d,t)=>{try{return c(z(A.g(),d,t),3)}catch{return""}}),n("intlTelInputUtilsTemp.getNumberType",(d,t)=>{try{let a=A.g(),h=z(a,d,t);var e=B1(a,h),i=q(a,v(h,1),e);if(i==null)var s=-1;else{var o=X(h);s=p1(o,i)}return s}catch{return-99}}),n("intlTelInputUtilsTemp.getValidationError",(d,t)=>{try{let e=A.g(),i=z(e,d,t);return u1(e,i,-1)}catch(e){return e.message==="Invalid country calling code"?1:3>=d.length||e.message==="Phone number too short after IDD"||e.message==="The string supplied is too short to be a phone number"?2:e.message==="The string supplied is too long to be a phone number"?3:-99}}),n("intlTelInputUtilsTemp.isValidNumber",(d,t)=>{try{let f=A.g();var e=z(f,d,t),i=B1(f,e);d=f;var s=v(e,1),o=q(d,s,i);if(o==null||i!="001"&&s!=G1(d,i))var a=!1;else{var h=X(e);a=p1(h,o)!=-1}return a}catch{return!1}}),n("intlTelInputUtilsTemp.isPossibleNumber",(d,t,e)=>{try{let i=A.g(),s=z(i,d,t);return e?u1(i,s,e2[e])===0:u1(i,s,-1)===0}catch{return!1}}),n("intlTelInputUtilsTemp.getCoreNumber",(d,t)=>{try{return c(z(A.g(),d,t),2).toString()}catch{return""}}),n("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3}),n("intlTelInputUtilsTemp.numberType",e2),n("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5})})();var K2=window.intlTelInputUtilsTemp;delete window.intlTelInputUtilsTemp;var a2=K2;v1.utils=a2;var F2=v1;return O2(j2);})(); // UMD return factoryOutput.default; diff --git a/react/build/IntlTelInput.cjs b/react/build/IntlTelInput.cjs index b3fb51c7..2c4b446a 100644 --- a/react/build/IntlTelInput.cjs +++ b/react/build/IntlTelInput.cjs @@ -1531,6 +1531,13 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2648,7 +2655,8 @@ var Iti = class { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2672,6 +2680,13 @@ var Iti = class { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/build/IntlTelInput.d.ts b/react/build/IntlTelInput.d.ts index 228786ed..4bf52441 100644 --- a/react/build/IntlTelInput.d.ts +++ b/react/build/IntlTelInput.d.ts @@ -897,6 +897,8 @@ declare module "intl-tel-input" { private hiddenInputCountry; private maxCoreNumberLength; private defaultCountry; + private originalPaddingRight; + private originalPaddingLeft; private _handleHiddenInputSubmit; private _handleLabelClick; private _handleClickSelectedCountry; diff --git a/react/build/IntlTelInput.js b/react/build/IntlTelInput.js index b4399d3d..f2465e7d 100644 --- a/react/build/IntlTelInput.js +++ b/react/build/IntlTelInput.js @@ -1495,6 +1495,13 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2612,7 +2619,8 @@ var Iti = class { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2636,6 +2644,13 @@ var Iti = class { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/build/IntlTelInputWithUtils.cjs b/react/build/IntlTelInputWithUtils.cjs index a8988392..e12f3afb 100644 --- a/react/build/IntlTelInputWithUtils.cjs +++ b/react/build/IntlTelInputWithUtils.cjs @@ -1531,6 +1531,13 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2648,7 +2655,8 @@ var Iti = class { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2672,6 +2680,13 @@ var Iti = class { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/build/IntlTelInputWithUtils.js b/react/build/IntlTelInputWithUtils.js index 8bcd0dea..e08c9048 100644 --- a/react/build/IntlTelInputWithUtils.js +++ b/react/build/IntlTelInputWithUtils.js @@ -1495,6 +1495,13 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -2612,7 +2619,8 @@ var Iti = class { //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -2636,6 +2644,13 @@ var Iti = class { this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/demo/set-number-bundle.js b/react/demo/set-number-bundle.js index ae24cda7..5da12abc 100644 --- a/react/demo/set-number-bundle.js +++ b/react/demo/set-number-bundle.js @@ -25024,6 +25024,13 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -26141,7 +26148,8 @@ //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -26165,6 +26173,13 @@ this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/demo/simple-bundle.js b/react/demo/simple-bundle.js index 9e97b71e..19cbd482 100644 --- a/react/demo/simple-bundle.js +++ b/react/demo/simple-bundle.js @@ -25024,6 +25024,13 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -26141,7 +26148,8 @@ //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -26165,6 +26173,13 @@ this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/react/demo/validation-bundle.js b/react/demo/validation-bundle.js index f14674de..b1ea4584 100644 --- a/react/demo/validation-bundle.js +++ b/react/demo/validation-bundle.js @@ -25024,6 +25024,13 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } this.options.i18n = { ...en_default, ...this.options.i18n }; const autoCountryPromise = new Promise((resolve, reject) => { this.resolveAutoCountryPromise = resolve; @@ -26141,7 +26148,8 @@ //******************** //* Remove plugin. destroy() { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { this._closeDropdown(); this.selectedCountry.removeEventListener( "click", @@ -26165,6 +26173,13 @@ this.telInput.removeEventListener("keydown", this._handleKeydownEvent); } this.telInput.removeAttribute("data-intl-tel-input-id"); + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper); wrapper?.parentNode?.removeChild(wrapper); diff --git a/src/js/intl-tel-input.ts b/src/js/intl-tel-input.ts index b73795e9..2f3ebc25 100644 --- a/src/js/intl-tel-input.ts +++ b/src/js/intl-tel-input.ts @@ -511,6 +511,8 @@ export class Iti { private hiddenInputCountry: HTMLInputElement; private maxCoreNumberLength: number | null; private defaultCountry: string | null; + private originalPaddingRight: string; + private originalPaddingLeft: string; private _handleHiddenInputSubmit: () => void; private _handleLabelClick: (e: Event) => void; @@ -569,6 +571,14 @@ export class Iti { //* Check if input has one parent with RTL. this.isRTL = !!this.telInput.closest("[dir=rtl]"); + //* Store original styling before we override it. + if (this.options.separateDialCode) { + if (this.isRTL) { + this.originalPaddingRight = this.telInput.style.paddingRight; + } else { + this.originalPaddingLeft = this.telInput.style.paddingLeft; + } + } //* Allow overriding the default interface strings. this.options.i18n = { ...defaultEnglishStrings, ...this.options.i18n }; @@ -2121,7 +2131,8 @@ export class Iti { //* Remove plugin. destroy(): void { - if (this.options.allowDropdown) { + const { allowDropdown, separateDialCode } = this.options; + if (allowDropdown) { //* Make sure the dropdown is closed (and unbind listeners). this._closeDropdown(); this.selectedCountry.removeEventListener( @@ -2154,6 +2165,15 @@ export class Iti { //* Remove attribute of id instance: data-intl-tel-input-id. this.telInput.removeAttribute("data-intl-tel-input-id"); + //* Restore original styling + if (separateDialCode) { + if (this.isRTL) { + this.telInput.style.paddingRight = this.originalPaddingRight; + } else { + this.telInput.style.paddingLeft = this.originalPaddingLeft; + } + } + //* Remove markup (but leave the original input). const wrapper = this.telInput.parentNode; wrapper?.parentNode?.insertBefore(this.telInput, wrapper);