diff --git a/README.md b/README.md index 573b283a8..113f07772 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,7 @@ Set this to false to hide the flags e.g. for political reasons. Instead, it will **separateDialCode** Type: `Boolean` Default: `false` -Display the selected country's international dial code next to the input, so it looks like it's part of the typed number. Since the user cannot edit the displayed dial code, they may try to type a new one - in this case, to avoid having two dial codes next to each other, we automatically open the country dropdown and put the new dial code in the search input instead. So if they type +54, then Argentina will be highlighted in the dropdown and they can simply press Enter to select it, updating the displayed dial code. For this reason, we force `allowDropdown` to `true`. Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--separatedialcode) (using the React component). +Display the selected country's international dial code next to the input, so it looks like it's part of the typed number. Since the user cannot edit the displayed dial code, they may try to type a new one - in this case, to avoid having two dial codes next to each other, we automatically open the country dropdown and put the new dial code in the search input instead. So if they type +54, then Argentina will be highlighted in the dropdown and they can simply press Enter to select it, updating the displayed dial code. Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--separatedialcode) (using the React component). Separate Dial Code diff --git a/build/js/intlTelInput.d.ts b/build/js/intlTelInput.d.ts index f638074b4..2d8652c93 100644 --- a/build/js/intlTelInput.d.ts +++ b/build/js/intlTelInput.d.ts @@ -420,6 +420,7 @@ declare module "intl-tel-input" { private _initDropdownListeners; private _initRequests; private _loadAutoCountry; + private _openDropdownWithPlus; private _initTelInputListeners; private _cap; private _trigger; diff --git a/build/js/intlTelInput.js b/build/js/intlTelInput.js index 0e3c06abc..f9ac421f6 100644 --- a/build/js/intlTelInput.js +++ b/build/js/intlTelInput.js @@ -1767,7 +1767,6 @@ var factoryOutput = (() => { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1779,6 +1778,8 @@ var factoryOutput = (() => { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1940,10 +1941,9 @@ var factoryOutput = (() => { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2241,25 +2241,25 @@ var factoryOutput = (() => { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2288,15 +2288,15 @@ var factoryOutput = (() => { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/build/js/intlTelInput.min.js b/build/js/intlTelInput.min.js index d213beda9..0cf890b42 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 P=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var O=(l,t)=>{for(var e in t)I(l,e,{get:t[e],enumerable:!0})},H=(l,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!x.call(l,n)&&n!==e&&I(l,n,{get:()=>t[n],enumerable:!(i=M(t,n))||i.enumerable});return l};var R=l=>H(I({},"__esModule",{value:!0}),l);var G={};O(G,{Iti:()=>_,default:()=>$});var T=[["af","93"],["ax","358",1,["18"]],["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"]],E=[];for(let l=0;ll.replace(/\D/g,""),A=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),S=l=>{let t=v(l);if(t.charAt(0)==="1"){let e=t.substr(1,3);return K.indexOf(e)!==-1}return!1},U=(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=j++,this.a=t,this.c=null,this.d=Object.assign({},k,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.onlyCountries.length===1&&(this.d.initialCountry=this.d.onlyCountries[0]),this.d.separateDialCode&&(this.d.allowDropdown=!0,this.d.nationalMode=!1,this.d.countrySearch=!0),this.d.allowDropdown&&!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._sortCountries()}_sortCountries(){this.d.countryOrder&&(this.d.countryOrder=this.d.countryOrder.map(t=>t.toLowerCase())),this.p.sort((t,e)=>{let{countryOrder:i}=this.d;if(i){let n=i.indexOf(t.iso2),s=i.indexOf(e.iso2),r=n>-1,o=s>-1;if(r||o)return r&&o?n-s:r?-1:1}return t.name.localeCompare(e.name)})}_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,r=this._5(s),o=S(s),{initialCountry:u,geoIpLookup:c}=this.d,d=u==="auto"&&c;if(r&&!o)this._v(s);else if(!d||t){let h=u?u.toLowerCase():"";h&&this._y(h,!0)?this._z(h):r&&o?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;/\p{L}/u.test(this.a.value)&&(s=!0);let r=()=>{this._n(),this.searchInput.value="+",this._p3("",!0)};this._a12=o=>{if(this.isAndroid&&o?.data==="+"&&i){let h=this.a.selectionStart||0,m=this.a.value.substring(0,h-1),C=this.a.value.substring(h);this.a.value=m+C,r();return}this._v(this.a.value)&&this._8();let u=o?.data&&/[^+0-9]/.test(o.data),c=o?.inputType==="insertFromPaste"&&this.a.value;u||c&&!t?s=!0:/[^+0-9]/.test(this.a.value)||(s=!1);let d=o?.detail&&o.detail.isSetNumber&&!n;if(e&&!s&&!d){let h=this.a.selectionStart||0,C=this.a.value.substring(0,h).replace(/[^+0-9]/g,"").length,g=o?.inputType==="deleteContentForward",y=this._9(),L=U(C,y,h,g);this.a.value=y,this.a.setSelectionRange(L,L)}},this.a.addEventListener("input",this._a12),(t||i)&&(this._handleKeydownEvent=o=>{if(o.key&&o.key.length===1&&!o.altKey&&!o.ctrlKey&&!o.metaKey){if(i&&o.key==="+"){o.preventDefault(),r();return}if(t){let u=this.a.selectionStart===0&&o.key==="+",c=/^[0-9]$/.test(o.key),d=u||c,h=this._6(),m=a.utils.getCoreNumber(h,this.s.iso2),C=this.maxCoreNumberLength&&m.length>=this.maxCoreNumberLength,g=this.a.value.substring(this.a.selectionStart,this.a.selectionEnd),y=/\d/.test(g);(!d||C&&!y)&&o.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 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())}}_searchForCountry(t){for(let e=0;ed[0]).join("").toLowerCase(),c=`+${r.dialCode}`;if(e||o.includes(n)||c.includes(n)||r.iso2.includes(n)||u.includes(n)){let d=r.nodeById[this.id];d&&this.countryList.appendChild(d),i&&(this._x(d,!1),i=!1)}}i&&this._x(null,!1),this.countryList.scrollTop=0,this._p4()}_p4(){let{i18n:t}=this.d,e=this.countryList.childElementCount,i;e===0?i=t.zeroSearchResults:e===1?i=t.oneSearchResult:i=t.multipleSearchResults.replace("${count}",e.toString()),this.searchResultsA11yText.textContent=i}_q(t){let e=t==="ArrowUp"?this.c?.previousElementSibling:this.c?.nextElementSibling;!e&&this.countryList.childElementCount>1&&(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,r=i?n:s;e=a.utils.formatNumber(e,this.s.iso2,r)}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 r=this._5(i,!0),o=v(i),u=null;if(r){let c=this.q[v(r)],d=c.indexOf(this.s.iso2)!==-1&&o.length<=r.length-1;if(!(n==="1"&&S(o))&&!d){for(let m=0;mr){let h=n-o;e.scrollTop=d-h}}_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-1){let i=t.substring(0,e),n=this._utilsIsPossibleNumber(i),s=this._utilsIsPossibleNumber(t);return n&&s}return this._utilsIsPossibleNumber(t)}_utilsIsPossibleNumber(t){return a.utils?a.utils.isPossibleNumber(t,this.s.iso2,this.d.validationNumberType):null}isValidNumberPrecise(){let t=this._6(),e=t.search(/\p{L}/u);if(e>-1){let i=t.substring(0,e),n=this._utilsIsValidNumber(i),s=this._utilsIsValidNumber(t);return n&&s}return this._utilsIsValidNumber(t)}_utilsIsValidNumber(t){return a.utils?a.utils.isValidNumber(t,this.s.iso2):null}setCountry(t){let e=t?.toLowerCase(),i=this.s.iso2;(t&&e!==i||!t&&i)&&(this._z(e),this._4(this.s.dialCode),this._8())}setNumber(t){let e=this._v(t);this._u(t),e&&this._8(),this._trigger("input",{isSetNumber:!0})}setPlaceholderNumberType(t){this.d.placeholderNumberType=t,this._0()}setDisabled(t){this.a.disabled=t,t?this.selectedCountry.setAttribute("disabled","true"):this.selectedCountry.removeAttribute("disabled")}},V=l=>!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:k,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:V,version:"24.2.1"}),$=a;return R(G);})(); +var factoryOutput=(()=>{var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var O=(l,t)=>{for(var e in t)I(l,e,{get:t[e],enumerable:!0})},H=(l,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!x.call(l,n)&&n!==e&&I(l,n,{get:()=>t[n],enumerable:!(i=M(t,n))||i.enumerable});return l};var R=l=>H(I({},"__esModule",{value:!0}),l);var W={};O(W,{Iti:()=>_,default:()=>$});var T=[["af","93"],["ax","358",1,["18"]],["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"]],D=[];for(let l=0;ll.replace(/\D/g,""),A=(l="")=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),S=l=>{let t=v(l);if(t.charAt(0)==="1"){let e=t.substr(1,3);return K.indexOf(e)!==-1}return!1},U=(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=j++,this.a=t,this.c=null,this.d=Object.assign({},k,e),this.e=!!t.getAttribute("placeholder")}_init(){this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.onlyCountries.length===1&&(this.d.initialCountry=this.d.onlyCountries[0]),this.d.separateDialCode&&(this.d.nationalMode=!1,this.d.countrySearch=!0),this.d.allowDropdown&&!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]");let t=this.d.allowDropdown||this.d.separateDialCode;this.showSelectedCountryOnLeft=this.isRTL?!t:t,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 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._d0(),this._sortCountries()}_sortCountries(){this.d.countryOrder&&(this.d.countryOrder=this.d.countryOrder.map(t=>t.toLowerCase())),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.name.localeCompare(e.name)})}_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=S(s),{initialCountry:u,geoIpLookup:c}=this.d,d=u==="auto"&&c;if(o&&!r)this._v(s);else if(!d||t){let h=u?u.toLowerCase():"";h&&this._y(h,!0)?this._z(h):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")}))}_nWithPlus(){this._n(),this.searchInput.value="+",this._p3("",!0)}_j(){let{strictMode:t,formatAsYouType:e,separateDialCode:i,formatOnDisplay:n,allowDropdown:s}=this.d,o=!1;/\p{L}/u.test(this.a.value)&&(o=!0),this._a12=r=>{if(this.isAndroid&&r?.data==="+"&&i&&s){let h=this.a.selectionStart||0,m=this.a.value.substring(0,h-1),C=this.a.value.substring(h);this.a.value=m+C,this._nWithPlus();return}this._v(this.a.value)&&this._8();let u=r?.data&&/[^+0-9]/.test(r.data),c=r?.inputType==="insertFromPaste"&&this.a.value;u||c&&!t?o=!0:/[^+0-9]/.test(this.a.value)||(o=!1);let d=r?.detail&&r.detail.isSetNumber&&!n;if(e&&!o&&!d){let h=this.a.selectionStart||0,C=this.a.value.substring(0,h).replace(/[^+0-9]/g,"").length,g=r?.inputType==="deleteContentForward",y=this._9(),L=U(C,y,h,g);this.a.value=y,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&&s&&r.key==="+"){r.preventDefault(),this._nWithPlus();return}if(t){let u=this.a.selectionStart===0&&r.key==="+",c=/^[0-9]$/.test(r.key),d=i?c:u||c,h=this._6(),m=a.utils.getCoreNumber(h,this.s.iso2),C=this.maxCoreNumberLength&&m.length>=this.maxCoreNumberLength,g=this.a.value.substring(this.a.selectionStart,this.a.selectionEnd),y=/\d/.test(g);(!d||C&&!y)&&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;ed[0]).join("").toLowerCase(),c=`+${o.dialCode}`;if(e||r.includes(n)||c.includes(n)||o.iso2.includes(n)||u.includes(n)){let d=o.nodeById[this.id];d&&this.countryList.appendChild(d),i&&(this._x(d,!1),i=!1)}}i&&this._x(null,!1),this.countryList.scrollTop=0,this._p4()}_p4(){let{i18n:t}=this.d,e=this.countryList.childElementCount,i;e===0?i=t.zeroSearchResults:e===1?i=t.oneSearchResult:i=t.multipleSearchResults.replace("${count}",e.toString()),this.searchResultsA11yText.textContent=i}_q(t){let e=t==="ArrowUp"?this.c?.previousElementSibling:this.c?.nextElementSibling;!e&&this.countryList.childElementCount>1&&(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 c=this.q[v(o)],d=c.indexOf(this.s.iso2)!==-1&&r.length<=o.length-1;if(!(n==="1"&&S(r))&&!d){for(let m=0;mo){let h=n-r;e.scrollTop=d-h}}_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-1){let i=t.substring(0,e),n=this._utilsIsPossibleNumber(i),s=this._utilsIsPossibleNumber(t);return n&&s}return this._utilsIsPossibleNumber(t)}_utilsIsPossibleNumber(t){return a.utils?a.utils.isPossibleNumber(t,this.s.iso2,this.d.validationNumberType):null}isValidNumberPrecise(){let t=this._6(),e=t.search(/\p{L}/u);if(e>-1){let i=t.substring(0,e),n=this._utilsIsValidNumber(i),s=this._utilsIsValidNumber(t);return n&&s}return this._utilsIsValidNumber(t)}_utilsIsValidNumber(t){return a.utils?a.utils.isValidNumber(t,this.s.iso2):null}setCountry(t){let e=t?.toLowerCase(),i=this.s.iso2;(t&&e!==i||!t&&i)&&(this._z(e),this._4(this.s.dialCode),this._8())}setNumber(t){let e=this._v(t);this._u(t),e&&this._8(),this._trigger("input",{isSetNumber:!0})}setPlaceholderNumberType(t){this.d.placeholderNumberType=t,this._0()}setDisabled(t){this.a.disabled=t,t?this.selectedCountry.setAttribute("disabled","true"):this.selectedCountry.removeAttribute("disabled")}},V=l=>!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:k,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:V,version:"24.2.1"}),$=a;return R(W);})(); // UMD return factoryOutput.default; diff --git a/build/js/intlTelInputWithUtils.js b/build/js/intlTelInputWithUtils.js index 430ce270d..139e3c682 100644 --- a/build/js/intlTelInputWithUtils.js +++ b/build/js/intlTelInputWithUtils.js @@ -1766,7 +1766,6 @@ var factoryOutput = (() => { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1778,6 +1777,8 @@ var factoryOutput = (() => { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1939,10 +1940,9 @@ var factoryOutput = (() => { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2240,25 +2240,25 @@ var factoryOutput = (() => { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2287,15 +2287,15 @@ var factoryOutput = (() => { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/build/js/intlTelInputWithUtils.min.js b/build/js/intlTelInputWithUtils.min.js index 8246f0b33..e8ea8b60b 100644 --- a/build/js/intlTelInputWithUtils.min.js +++ b/build/js/intlTelInputWithUtils.min.js @@ -13,7 +13,7 @@ } }(() => { -var factoryOutput=(()=>{var C1=Object.defineProperty;var D2=Object.getOwnPropertyDescriptor;var x2=Object.getOwnPropertyNames;var P2=Object.prototype.hasOwnProperty;var R2=(C,e)=>{for(var n in e)C1(C,n,{get:e[n],enumerable:!0})},O2=(C,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of x2(e))!P2.call(C,u)&&u!==n&&C1(C,u,{get:()=>e[u],enumerable:!(r=D2(e,u))||r.enumerable});return C};var k2=C=>O2(C1({},"__esModule",{value:!0}),C);var z2={};R2(z2,{default:()=>W2});var $2=[["af","93"],["ax","358",1,["18"]],["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"]],n2=[];for(let C=0;C<$2.length;C++){let e=$2[C];n2[C]={name:"",iso2:e[0],dialCode:e[1],priority:e[2]||0,areaCodes:e[3]||null,nodeById:{}}}var K=n2;var B2={ad:"Andorra",ae:"United Arab Emirates",af:"Afghanistan",ag:"Antigua & Barbuda",ai:"Anguilla",al:"Albania",am:"Armenia",ao:"Angola",ar:"Argentina",as:"American Samoa",at:"Austria",au:"Australia",aw:"Aruba",ax:"\xC5land Islands",az:"Azerbaijan",ba:"Bosnia & Herzegovina",bb:"Barbados",bd:"Bangladesh",be:"Belgium",bf:"Burkina Faso",bg:"Bulgaria",bh:"Bahrain",bi:"Burundi",bj:"Benin",bl:"St. Barth\xE9lemy",bm:"Bermuda",bn:"Brunei",bo:"Bolivia",bq:"Caribbean Netherlands",br:"Brazil",bs:"Bahamas",bt:"Bhutan",bw:"Botswana",by:"Belarus",bz:"Belize",ca:"Canada",cc:"Cocos (Keeling) Islands",cd:"Congo - Kinshasa",cf:"Central African Republic",cg:"Congo - Brazzaville",ch:"Switzerland",ci:"C\xF4te d\u2019Ivoire",ck:"Cook Islands",cl:"Chile",cm:"Cameroon",cn:"China",co:"Colombia",cr:"Costa Rica",cu:"Cuba",cv:"Cape Verde",cw:"Cura\xE7ao",cx:"Christmas Island",cy:"Cyprus",cz:"Czechia",de:"Germany",dj:"Djibouti",dk:"Denmark",dm:"Dominica",do:"Dominican Republic",dz:"Algeria",ec:"Ecuador",ee:"Estonia",eg:"Egypt",eh:"Western Sahara",er:"Eritrea",es:"Spain",et:"Ethiopia",fi:"Finland",fj:"Fiji",fk:"Falkland Islands",fm:"Micronesia",fo:"Faroe Islands",fr:"France",ga:"Gabon",gb:"United Kingdom",gd:"Grenada",ge:"Georgia",gf:"French Guiana",gg:"Guernsey",gh:"Ghana",gi:"Gibraltar",gl:"Greenland",gm:"Gambia",gn:"Guinea",gp:"Guadeloupe",gq:"Equatorial Guinea",gr:"Greece",gt:"Guatemala",gu:"Guam",gw:"Guinea-Bissau",gy:"Guyana",hk:"Hong Kong SAR China",hn:"Honduras",hr:"Croatia",ht:"Haiti",hu:"Hungary",id:"Indonesia",ie:"Ireland",il:"Israel",im:"Isle of Man",in:"India",io:"British Indian Ocean Territory",iq:"Iraq",ir:"Iran",is:"Iceland",it:"Italy",je:"Jersey",jm:"Jamaica",jo:"Jordan",jp:"Japan",ke:"Kenya",kg:"Kyrgyzstan",kh:"Cambodia",ki:"Kiribati",km:"Comoros",kn:"St. Kitts & Nevis",kp:"North Korea",kr:"South Korea",kw:"Kuwait",ky:"Cayman Islands",kz:"Kazakhstan",la:"Laos",lb:"Lebanon",lc:"St. Lucia",li:"Liechtenstein",lk:"Sri Lanka",lr:"Liberia",ls:"Lesotho",lt:"Lithuania",lu:"Luxembourg",lv:"Latvia",ly:"Libya",ma:"Morocco",mc:"Monaco",md:"Moldova",me:"Montenegro",mf:"St. Martin",mg:"Madagascar",mh:"Marshall Islands",mk:"North Macedonia",ml:"Mali",mm:"Myanmar (Burma)",mn:"Mongolia",mo:"Macao SAR China",mp:"Northern Mariana Islands",mq:"Martinique",mr:"Mauritania",ms:"Montserrat",mt:"Malta",mu:"Mauritius",mv:"Maldives",mw:"Malawi",mx:"Mexico",my:"Malaysia",mz:"Mozambique",na:"Namibia",nc:"New Caledonia",ne:"Niger",nf:"Norfolk Island",ng:"Nigeria",ni:"Nicaragua",nl:"Netherlands",no:"Norway",np:"Nepal",nr:"Nauru",nu:"Niue",nz:"New Zealand",om:"Oman",pa:"Panama",pe:"Peru",pf:"French Polynesia",pg:"Papua New Guinea",ph:"Philippines",pk:"Pakistan",pl:"Poland",pm:"St. Pierre & Miquelon",pr:"Puerto Rico",ps:"Palestinian Territories",pt:"Portugal",pw:"Palau",py:"Paraguay",qa:"Qatar",re:"R\xE9union",ro:"Romania",rs:"Serbia",ru:"Russia",rw:"Rwanda",sa:"Saudi Arabia",sb:"Solomon Islands",sc:"Seychelles",sd:"Sudan",se:"Sweden",sg:"Singapore",sh:"St. Helena",si:"Slovenia",sj:"Svalbard & Jan Mayen",sk:"Slovakia",sl:"Sierra Leone",sm:"San Marino",sn:"Senegal",so:"Somalia",sr:"Suriname",ss:"South Sudan",st:"S\xE3o Tom\xE9 & Pr\xEDncipe",sv:"El Salvador",sx:"Sint Maarten",sy:"Syria",sz:"Eswatini",tc:"Turks & Caicos Islands",td:"Chad",tg:"Togo",th:"Thailand",tj:"Tajikistan",tk:"Tokelau",tl:"Timor-Leste",tm:"Turkmenistan",tn:"Tunisia",to:"Tonga",tr:"Turkey",tt:"Trinidad & Tobago",tv:"Tuvalu",tw:"Taiwan",tz:"Tanzania",ua:"Ukraine",ug:"Uganda",us:"United States",uy:"Uruguay",uz:"Uzbekistan",va:"Vatican City",vc:"St. Vincent & Grenadines",ve:"Venezuela",vg:"British Virgin Islands",vi:"U.S. Virgin Islands",vn:"Vietnam",vu:"Vanuatu",wf:"Wallis & Futuna",ws:"Samoa",ye:"Yemen",yt:"Mayotte",za:"South Africa",zm:"Zambia",zw:"Zimbabwe"},i2=B2;var G2={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"},r2=G2;var H2={...i2,...r2},y1=H2;for(let C=0;CC.replace(/\D/g,""),o2=(C="")=>C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),s2=C=>{let e=h1(C);if(e.charAt(0)==="1"){let n=e.substr(1,3);return F2.indexOf(n)!==-1}return!1},K2=(C,e,n,r)=>{if(n===0&&!r)return 0;let u=0;for(let l=0;l{let r=document.createElement(C);return e&&Object.entries(e).forEach(([u,l])=>r.setAttribute(u,l)),n&&n.appendChild(r),r},t1=C=>{let{instances:e}=m;Object.values(e).forEach(n=>n[C]())},v1=class{constructor(e,n={}){this.id=U2++,this.telInput=e,this.highlightedItem=null,this.options=Object.assign({},u2,n),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.onlyCountries.length===1&&(this.options.initialCountry=this.options.onlyCountries[0]),this.options.separateDialCode&&(this.options.allowDropdown=!0,this.options.nationalMode=!1,this.options.countrySearch=!0),this.options.allowDropdown&&!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={...y1,...this.options.i18n};let e=new Promise((r,u)=>{this.resolveAutoCountryPromise=r,this.rejectAutoCountryPromise=u}),n=new Promise((r,u)=>{this.resolveUtilsScriptPromise=r,this.rejectUtilsScriptPromise=u});this.promise=Promise.all([e,n]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._translateCountryNames(),this._sortCountries()}_sortCountries(){this.options.countryOrder&&(this.options.countryOrder=this.options.countryOrder.map(e=>e.toLowerCase())),this.countries.sort((e,n)=>{let{countryOrder:r}=this.options;if(r){let u=r.indexOf(e.iso2),l=r.indexOf(n.iso2),f=u>-1,p=l>-1;if(f||p)return f&&p?u-l:f?-1:1}return e.name.localeCompare(n.name)})}_addToDialCodeMap(e,n,r){n.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=n.length),this.dialCodeToIso2Map.hasOwnProperty(n)||(this.dialCodeToIso2Map[n]=[]);for(let l=0;lu.toLowerCase());this.countries=K.filter(u=>r.indexOf(u.iso2)>-1)}else if(n.length){let r=n.map(u=>u.toLowerCase());this.countries=K.filter(u=>r.indexOf(u.iso2)===-1)}else this.countries=K}_translateCountryNames(){for(let e=0;e`),l+=`${n.name}`,l+=`+${n.dialCode}`,u.insertAdjacentHTML("beforeend",l)}}_setInitialState(e=!1){let n=this.telInput.getAttribute("value"),r=this.telInput.value,l=n&&n.charAt(0)==="+"&&(!r||r.charAt(0)!=="+")?n:r,f=this._getDialCode(l),p=s2(l),{initialCountry:v,geoIpLookup:S}=this.options,I=v==="auto"&&S;if(f&&!p)this._updateCountryFromNumber(l);else if(!I||e){let _=v?v.toLowerCase():"";_&&this._getCountryData(_,!0)?this._setCountry(_):f&&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=n=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():n.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=n=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),this._openDropdown()),n.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){let{utilsScript:e,initialCountry:n,geoIpLookup:r}=this.options;e&&!m.utils?m.documentReady()?m.loadUtils(e):window.addEventListener("load",()=>{m.loadUtils(e)}):this.resolveUtilsScriptPromise(),n==="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((e="")=>{let n=e.toLowerCase();n&&this._getCountryData(n,!0)?(m.autoCountry=n,setTimeout(()=>t1("handleAutoCountry"))):(this._setInitialState(!0),t1("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),t1("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:n,separateDialCode:r,formatOnDisplay:u}=this.options,l=!1;/\p{L}/u.test(this.telInput.value)&&(l=!0);let f=()=>{this._openDropdown(),this.searchInput.value="+",this._filterCountries("",!0)};this._handleInputEvent=p=>{if(this.isAndroid&&p?.data==="+"&&r){let _=this.telInput.selectionStart||0,T=this.telInput.value.substring(0,_-1),P=this.telInput.value.substring(_);this.telInput.value=T+P,f();return}this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let v=p?.data&&/[^+0-9]/.test(p.data),S=p?.inputType==="insertFromPaste"&&this.telInput.value;v||S&&!e?l=!0:/[^+0-9]/.test(this.telInput.value)||(l=!1);let I=p?.detail&&p.detail.isSetNumber&&!u;if(n&&!l&&!I){let _=this.telInput.selectionStart||0,P=this.telInput.value.substring(0,_).replace(/[^+0-9]/g,"").length,R=p?.inputType==="deleteContentForward",k=this._formatNumberAsYouType(),e1=K2(P,k,_,R);this.telInput.value=k,this.telInput.setSelectionRange(e1,e1)}},this.telInput.addEventListener("input",this._handleInputEvent),(e||r)&&(this._handleKeydownEvent=p=>{if(p.key&&p.key.length===1&&!p.altKey&&!p.ctrlKey&&!p.metaKey){if(r&&p.key==="+"){p.preventDefault(),f();return}if(e){let v=this.telInput.selectionStart===0&&p.key==="+",S=/^[0-9]$/.test(p.key),I=v||S,_=this._getFullNumber(),T=m.utils.getCoreNumber(_,this.selectedCountryData.iso2),P=this.maxCoreNumberLength&&T.length>=this.maxCoreNumberLength,R=this.telInput.value.substring(this.telInput.selectionStart,this.telInput.selectionEnd),k=/\d/.test(R);(!I||P&&!k)&&p.preventDefault()}}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let n=parseInt(this.telInput.getAttribute("maxlength")||"",10);return n&&e.length>n?e.substr(0,n):e}_trigger(e,n={}){let r=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});this.telInput.dispatchEvent(r)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:n}=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(),n){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 e=this.telInput.getBoundingClientRect(),n=this.telInput.offsetHeight;this.options.dropdownContainer&&(this.dropdown.style.top=`${e.top+n}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let n="",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),n+=u.key.toLowerCase(),this._searchForCountry(n),r=setTimeout(()=>{n=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let u=()=>{let f=this.searchInput.value.trim();f?this._filterCountries(f):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",f=>f.stopPropagation())}}_searchForCountry(e){for(let n=0;nI[0]).join("").toLowerCase(),S=`+${f.dialCode}`;if(n||p.includes(u)||S.includes(u)||f.iso2.includes(u)||v.includes(u)){let I=f.nodeById[this.id];I&&this.countryList.appendChild(I),r&&(this._highlightListItem(I,!1),r=!1)}}r&&this._highlightListItem(null,!1),this.countryList.scrollTop=0,this._updateSearchResultsText()}_updateSearchResultsText(){let{i18n:e}=this.options,n=this.countryList.childElementCount,r;n===0?r=e.zeroSearchResults:n===1?r=e.oneSearchResult:r=e.multipleSearchResults.replace("${count}",n.toString()),this.searchResultsA11yText.textContent=r}_handleUpDownKey(e){let n=e==="ArrowUp"?this.highlightedItem?.previousElementSibling:this.highlightedItem?.nextElementSibling;!n&&this.countryList.childElementCount>1&&(n=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),n&&(this._scrollTo(n),this._highlightListItem(n,!1))}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_updateValFromNumber(e){let n=e;if(this.options.formatOnDisplay&&m.utils&&this.selectedCountryData){let r=this.options.nationalMode||n.charAt(0)!=="+"&&!this.options.separateDialCode,{NATIONAL:u,INTERNATIONAL:l}=m.utils.numberFormat,f=r?u:l;n=m.utils.formatNumber(n,this.selectedCountryData.iso2,f)}n=this._beforeSetNumber(n),this.telInput.value=n}_updateCountryFromNumber(e){let n=e.indexOf("+"),r=n?e.substring(n):e,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 f=this._getDialCode(r,!0),p=h1(r),v=null;if(f){let S=this.dialCodeToIso2Map[h1(f)],I=S.indexOf(this.selectedCountryData.iso2)!==-1&&p.length<=f.length-1;if(!(u==="1"&&s2(p))&&!I){for(let T=0;Tf){let _=u-p;n.scrollTop=I-_}}_updateDialCode(e){let n=this.telInput.value,r=`+${e}`,u;if(n.charAt(0)==="+"){let l=this._getDialCode(n);l?u=n.replace(l,r):u=r,this.telInput.value=u}}_getDialCode(e,n){let r="";if(e.charAt(0)==="+"){let u="";for(let l=0;l-1){let r=e.substring(0,n),u=this._utilsIsPossibleNumber(r),l=this._utilsIsPossibleNumber(e);return u&&l}return this._utilsIsPossibleNumber(e)}_utilsIsPossibleNumber(e){return m.utils?m.utils.isPossibleNumber(e,this.selectedCountryData.iso2,this.options.validationNumberType):null}isValidNumberPrecise(){let e=this._getFullNumber(),n=e.search(/\p{L}/u);if(n>-1){let r=e.substring(0,n),u=this._utilsIsValidNumber(r),l=this._utilsIsValidNumber(e);return u&&l}return this._utilsIsValidNumber(e)}_utilsIsValidNumber(e){return m.utils?m.utils.isValidNumber(e,this.selectedCountryData.iso2):null}setCountry(e){let n=e?.toLowerCase(),r=this.selectedCountryData.iso2;(e&&n!==r||!e&&r)&&(this._setCountry(n),this._updateDialCode(this.selectedCountryData.dialCode),this._triggerCountryChange())}setNumber(e){let n=this._updateCountryFromNumber(e);this._updateValFromNumber(e),n&&this._triggerCountryChange(),this._trigger("input",{isSetNumber:!0})}setPlaceholderNumberType(e){this.options.placeholderNumberType=e,this._updatePlaceholder()}setDisabled(e){this.telInput.disabled=e,e?this.selectedCountry.setAttribute("disabled","true"):this.selectedCountry.removeAttribute("disabled")}},V2=C=>!m.utils&&!m.startedLoadingUtilsScript?(m.startedLoadingUtilsScript=!0,new Promise((e,n)=>{import_INTENTIONALLY_BROKEN(/* webpackIgnore: true */ C).then(({default:r})=>{m.utils=r,t1("handleUtils"),e(!0)}).catch(()=>{t1("rejectUtilsScriptPromise"),n()})})):null,m=Object.assign((C,e)=>{let n=new v1(C,e);return n._init(),C.setAttribute("data-intl-tel-input-id",n.id.toString()),m.instances[n.id]=n,n},{defaults:u2,documentReady:()=>document.readyState==="complete",getCountryData:()=>K,getInstance:C=>{let e=C.getAttribute("data-intl-tel-input-id");return e?m.instances[e]:null},instances:{},loadUtils:V2,version:"24.2.1"}),I1=m;(function(){var C=this||self;function e(d,t){d=d.split(".");var $=C;d[0]in $||typeof $.execScript>"u"||$.execScript("var "+d[0]);for(var i;d.length&&(i=d.shift());)d.length||t===void 0?$[i]&&$[i]!==Object.prototype[i]?$=$[i]:$=$[i]={}:$[i]=t}function n(d,t){function $(){}$.prototype=t.prototype,d.ma=t.prototype,d.prototype=new $,d.prototype.constructor=d,d.sa=function(i,o,s){for(var a=Array(arguments.length-2),h=2;hd.length?!1:B(L2,d)}function P1(d){return B(b2,d)?r1(d,C2):r1(d,p1)}function R1(d){var t=P1(d.toString());x(d),d.g(t)}function O1(d){return d!=null&&(H(d,9)!=1||N(d,9)[0]!=-1)}function r1(d,t){for(var $=new L,i,o=d.length,s=0;st?2:s[s.length-1]=o&&o<=i;++o)if($=parseInt(d.substring(0,o),10),$ in J)return t.g(d.substring(o)),$;return 0}function F1(d,t,$,i,o,s){if(t.length==0)return 0;t=new L(t);var a;$!=null&&(a=c($,11)),a==null&&(a="NonMatch");var h=t.toString();if(h.length==0)a=20;else if(q.test(h))h=h.replace(q,""),x(t),t.g(P1(h)),a=1;else{if(h=new RegExp(a),R1(t),a=t.toString(),a.search(h)==0){h=a.match(h)[0].length;var g=a.substring(h).match(N1);g&&g[1]!=null&&0=t.h.length)throw Error("Phone number too short after IDD");if(d=U1(t,i),d!=0)return E(s,1,d),d;throw Error("Invalid country calling code")}return $!=null&&(a=y($,10),h=""+a,g=t.toString(),g.lastIndexOf(h,0)==0&&(h=new L(g.substring(h.length)),g=c($,1),g=new RegExp(y(g,2)),K1(h,$,null),h=h.toString(),!B(g,t.toString())&&B(g,h)||u1(d,t.toString(),$,-1)==3))?(i.g(h),o&&E(s,6,10),E(s,1,a),a):(E(s,1,0),0)}function K1(d,t,$){var i=d.toString(),o=i.length,s=c(t,15);if(o!=0&&s!=null&&s.length!=0){var a=new RegExp("^(?:"+s+")");if(o=a.exec(i)){s=new RegExp(y(c(t,1),2));var h=B(s,i),g=o.length-1;t=c(t,16),t==null||t.length==0||o[g]==null||o[g].length==0?(!h||B(s,i.substring(o[0].length)))&&($!=null&&0=t.length)s="";else{var a=t.indexOf(";",s);s=a!==-1?t.substring(s,a):t.substring(s)}var h=s;if(h==null?a=!0:h.length===0?a=!1:(a=S2.exec(h),h=T2.exec(h),a=a!==null||h!==null),!a||(s!=null?(s.charAt(0)==="+"&&o.g(s),s=t.indexOf("tel:"),o.g(t.substring(0<=s?s+4:0,t.indexOf(";phone-context=")))):(s=o.g,a=t??"",h=a.search(v2),0<=h?(a=a.substring(h),a=a.replace(_2,""),h=a.search(I2),0<=h&&(a=a.substring(0,h))):a="",s.call(o,a)),s=o.toString(),a=s.indexOf(";isub="),0t.h.length||(a!=null&&($=new L,o=new L(t.toString()),K1(o,a,$),d=u1(d,o.toString(),a,-1),d!=2&&d!=4&&d!=5&&(t=o,i&&0<$.toString().length&&E(s,7,$.toString()))),i=t.toString(),d=i.length,2>d))throw Error("The string supplied is too short to be a phone number");if(17{try{let $=d.replace(/[^+0-9]/g,""),i=new A2(t);t="";for(let o=0;o<$.length;o++)i.ja=M2(i,$.charAt(o)),t=i.ja;return t}catch{return d}}),e("intlTelInputUtilsTemp.formatNumber",(d,t,$)=>{try{let o=A.g(),s=W(o,d,t);var i=Z(o,s,-1);return i==0||i==4?o.format(s,typeof $>"u"?0:$):d}catch{return d}}),e("intlTelInputUtilsTemp.getExampleNumber",(d,t,$,i)=>{try{let g=A.g();d:{var o=g;if(o1(d)){var s=s1(F(o,d),$);try{if(D(s,6)){var a=c(s,6),h=V1(o,a,d,!1);break d}}catch{}}h=null}return g.format(h,i?0:t?2:1)}catch{return""}}),e("intlTelInputUtilsTemp.getExtension",(d,t)=>{try{return c(W(A.g(),d,t),3)}catch{return""}}),e("intlTelInputUtilsTemp.getNumberType",(d,t)=>{try{let a=A.g(),h=W(a,d,t);var $=G1(a,h),i=X(a,y(h,1),$);if(i==null)var o=-1;else{var s=Q(h);o=f1(s,i)}return o}catch{return-99}}),e("intlTelInputUtilsTemp.getValidationError",(d,t)=>{try{let $=A.g(),i=W($,d,t);return Z($,i,-1)}catch($){return $.message==="Invalid country calling code"?1:3>=d.length||$.message==="Phone number too short after IDD"||$.message==="The string supplied is too short to be a phone number"?2:$.message==="The string supplied is too long to be a phone number"?3:-99}}),e("intlTelInputUtilsTemp.isValidNumber",(d,t)=>{try{let g=A.g();var $=W(g,d,t),i=G1(g,$);d=g;var o=y($,1),s=X(d,o,i);if(s==null||i!="001"&&o!=H1(d,i))var a=!1;else{var h=Q($);a=f1(h,s)!=-1}return a}catch{return!1}}),e("intlTelInputUtilsTemp.isPossibleNumber",(d,t,$)=>{try{let i=A.g(),o=W(i,d,t);if($){let s=Z(i,o,l1[$])===0;if($==="FIXED_LINE_OR_MOBILE"){let a=Z(i,o,l1.MOBILE)===0,h=Z(i,o,l1.FIXED_LINE)===0;return a||h||s}return s}return Z(i,o,-1)===0}catch{return!1}}),e("intlTelInputUtilsTemp.getCoreNumber",(d,t)=>{try{return c(W(A.g(),d,t),2).toString()}catch{return""}}),e("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3}),e("intlTelInputUtilsTemp.numberType",l1),e("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5})})();var j2=window.intlTelInputUtilsTemp;delete window.intlTelInputUtilsTemp;var a2=j2;I1.utils=a2;var W2=I1;return k2(z2);})(); +var factoryOutput=(()=>{var C1=Object.defineProperty;var D2=Object.getOwnPropertyDescriptor;var P2=Object.getOwnPropertyNames;var x2=Object.prototype.hasOwnProperty;var R2=(C,e)=>{for(var n in e)C1(C,n,{get:e[n],enumerable:!0})},O2=(C,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of P2(e))!x2.call(C,u)&&u!==n&&C1(C,u,{get:()=>e[u],enumerable:!(r=D2(e,u))||r.enumerable});return C};var k2=C=>O2(C1({},"__esModule",{value:!0}),C);var z2={};R2(z2,{default:()=>W2});var $2=[["af","93"],["ax","358",1,["18"]],["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"]],n2=[];for(let C=0;C<$2.length;C++){let e=$2[C];n2[C]={name:"",iso2:e[0],dialCode:e[1],priority:e[2]||0,areaCodes:e[3]||null,nodeById:{}}}var K=n2;var B2={ad:"Andorra",ae:"United Arab Emirates",af:"Afghanistan",ag:"Antigua & Barbuda",ai:"Anguilla",al:"Albania",am:"Armenia",ao:"Angola",ar:"Argentina",as:"American Samoa",at:"Austria",au:"Australia",aw:"Aruba",ax:"\xC5land Islands",az:"Azerbaijan",ba:"Bosnia & Herzegovina",bb:"Barbados",bd:"Bangladesh",be:"Belgium",bf:"Burkina Faso",bg:"Bulgaria",bh:"Bahrain",bi:"Burundi",bj:"Benin",bl:"St. Barth\xE9lemy",bm:"Bermuda",bn:"Brunei",bo:"Bolivia",bq:"Caribbean Netherlands",br:"Brazil",bs:"Bahamas",bt:"Bhutan",bw:"Botswana",by:"Belarus",bz:"Belize",ca:"Canada",cc:"Cocos (Keeling) Islands",cd:"Congo - Kinshasa",cf:"Central African Republic",cg:"Congo - Brazzaville",ch:"Switzerland",ci:"C\xF4te d\u2019Ivoire",ck:"Cook Islands",cl:"Chile",cm:"Cameroon",cn:"China",co:"Colombia",cr:"Costa Rica",cu:"Cuba",cv:"Cape Verde",cw:"Cura\xE7ao",cx:"Christmas Island",cy:"Cyprus",cz:"Czechia",de:"Germany",dj:"Djibouti",dk:"Denmark",dm:"Dominica",do:"Dominican Republic",dz:"Algeria",ec:"Ecuador",ee:"Estonia",eg:"Egypt",eh:"Western Sahara",er:"Eritrea",es:"Spain",et:"Ethiopia",fi:"Finland",fj:"Fiji",fk:"Falkland Islands",fm:"Micronesia",fo:"Faroe Islands",fr:"France",ga:"Gabon",gb:"United Kingdom",gd:"Grenada",ge:"Georgia",gf:"French Guiana",gg:"Guernsey",gh:"Ghana",gi:"Gibraltar",gl:"Greenland",gm:"Gambia",gn:"Guinea",gp:"Guadeloupe",gq:"Equatorial Guinea",gr:"Greece",gt:"Guatemala",gu:"Guam",gw:"Guinea-Bissau",gy:"Guyana",hk:"Hong Kong SAR China",hn:"Honduras",hr:"Croatia",ht:"Haiti",hu:"Hungary",id:"Indonesia",ie:"Ireland",il:"Israel",im:"Isle of Man",in:"India",io:"British Indian Ocean Territory",iq:"Iraq",ir:"Iran",is:"Iceland",it:"Italy",je:"Jersey",jm:"Jamaica",jo:"Jordan",jp:"Japan",ke:"Kenya",kg:"Kyrgyzstan",kh:"Cambodia",ki:"Kiribati",km:"Comoros",kn:"St. Kitts & Nevis",kp:"North Korea",kr:"South Korea",kw:"Kuwait",ky:"Cayman Islands",kz:"Kazakhstan",la:"Laos",lb:"Lebanon",lc:"St. Lucia",li:"Liechtenstein",lk:"Sri Lanka",lr:"Liberia",ls:"Lesotho",lt:"Lithuania",lu:"Luxembourg",lv:"Latvia",ly:"Libya",ma:"Morocco",mc:"Monaco",md:"Moldova",me:"Montenegro",mf:"St. Martin",mg:"Madagascar",mh:"Marshall Islands",mk:"North Macedonia",ml:"Mali",mm:"Myanmar (Burma)",mn:"Mongolia",mo:"Macao SAR China",mp:"Northern Mariana Islands",mq:"Martinique",mr:"Mauritania",ms:"Montserrat",mt:"Malta",mu:"Mauritius",mv:"Maldives",mw:"Malawi",mx:"Mexico",my:"Malaysia",mz:"Mozambique",na:"Namibia",nc:"New Caledonia",ne:"Niger",nf:"Norfolk Island",ng:"Nigeria",ni:"Nicaragua",nl:"Netherlands",no:"Norway",np:"Nepal",nr:"Nauru",nu:"Niue",nz:"New Zealand",om:"Oman",pa:"Panama",pe:"Peru",pf:"French Polynesia",pg:"Papua New Guinea",ph:"Philippines",pk:"Pakistan",pl:"Poland",pm:"St. Pierre & Miquelon",pr:"Puerto Rico",ps:"Palestinian Territories",pt:"Portugal",pw:"Palau",py:"Paraguay",qa:"Qatar",re:"R\xE9union",ro:"Romania",rs:"Serbia",ru:"Russia",rw:"Rwanda",sa:"Saudi Arabia",sb:"Solomon Islands",sc:"Seychelles",sd:"Sudan",se:"Sweden",sg:"Singapore",sh:"St. Helena",si:"Slovenia",sj:"Svalbard & Jan Mayen",sk:"Slovakia",sl:"Sierra Leone",sm:"San Marino",sn:"Senegal",so:"Somalia",sr:"Suriname",ss:"South Sudan",st:"S\xE3o Tom\xE9 & Pr\xEDncipe",sv:"El Salvador",sx:"Sint Maarten",sy:"Syria",sz:"Eswatini",tc:"Turks & Caicos Islands",td:"Chad",tg:"Togo",th:"Thailand",tj:"Tajikistan",tk:"Tokelau",tl:"Timor-Leste",tm:"Turkmenistan",tn:"Tunisia",to:"Tonga",tr:"Turkey",tt:"Trinidad & Tobago",tv:"Tuvalu",tw:"Taiwan",tz:"Tanzania",ua:"Ukraine",ug:"Uganda",us:"United States",uy:"Uruguay",uz:"Uzbekistan",va:"Vatican City",vc:"St. Vincent & Grenadines",ve:"Venezuela",vg:"British Virgin Islands",vi:"U.S. Virgin Islands",vn:"Vietnam",vu:"Vanuatu",wf:"Wallis & Futuna",ws:"Samoa",ye:"Yemen",yt:"Mayotte",za:"South Africa",zm:"Zambia",zw:"Zimbabwe"},i2=B2;var G2={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"},r2=G2;var H2={...i2,...r2},y1=H2;for(let C=0;CC.replace(/\D/g,""),o2=(C="")=>C.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),s2=C=>{let e=h1(C);if(e.charAt(0)==="1"){let n=e.substr(1,3);return F2.indexOf(n)!==-1}return!1},K2=(C,e,n,r)=>{if(n===0&&!r)return 0;let u=0;for(let l=0;l{let r=document.createElement(C);return e&&Object.entries(e).forEach(([u,l])=>r.setAttribute(u,l)),n&&n.appendChild(r),r},t1=C=>{let{instances:e}=m;Object.values(e).forEach(n=>n[C]())},v1=class{constructor(e,n={}){this.id=U2++,this.telInput=e,this.highlightedItem=null,this.options=Object.assign({},u2,n),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.onlyCountries.length===1&&(this.options.initialCountry=this.options.onlyCountries[0]),this.options.separateDialCode&&(this.options.nationalMode=!1,this.options.countrySearch=!0),this.options.allowDropdown&&!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]");let e=this.options.allowDropdown||this.options.separateDialCode;this.showSelectedCountryOnLeft=this.isRTL?!e:e,this.options.separateDialCode&&(this.isRTL?this.originalPaddingRight=this.telInput.style.paddingRight:this.originalPaddingLeft=this.telInput.style.paddingLeft),this.options.i18n={...y1,...this.options.i18n};let n=new Promise((u,l)=>{this.resolveAutoCountryPromise=u,this.rejectAutoCountryPromise=l}),r=new Promise((u,l)=>{this.resolveUtilsScriptPromise=u,this.rejectUtilsScriptPromise=l});this.promise=Promise.all([n,r]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._translateCountryNames(),this._sortCountries()}_sortCountries(){this.options.countryOrder&&(this.options.countryOrder=this.options.countryOrder.map(e=>e.toLowerCase())),this.countries.sort((e,n)=>{let{countryOrder:r}=this.options;if(r){let u=r.indexOf(e.iso2),l=r.indexOf(n.iso2),p=u>-1,f=l>-1;if(p||f)return p&&f?u-l:p?-1:1}return e.name.localeCompare(n.name)})}_addToDialCodeMap(e,n,r){n.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=n.length),this.dialCodeToIso2Map.hasOwnProperty(n)||(this.dialCodeToIso2Map[n]=[]);for(let l=0;lu.toLowerCase());this.countries=K.filter(u=>r.indexOf(u.iso2)>-1)}else if(n.length){let r=n.map(u=>u.toLowerCase());this.countries=K.filter(u=>r.indexOf(u.iso2)===-1)}else this.countries=K}_translateCountryNames(){for(let e=0;e`),l+=`${n.name}`,l+=`+${n.dialCode}`,u.insertAdjacentHTML("beforeend",l)}}_setInitialState(e=!1){let n=this.telInput.getAttribute("value"),r=this.telInput.value,l=n&&n.charAt(0)==="+"&&(!r||r.charAt(0)!=="+")?n:r,p=this._getDialCode(l),f=s2(l),{initialCountry:v,geoIpLookup:S}=this.options,I=v==="auto"&&S;if(p&&!f)this._updateCountryFromNumber(l);else if(!I||e){let _=v?v.toLowerCase():"";_&&this._getCountryData(_,!0)?this._setCountry(_):p&&f?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=n=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():n.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=n=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),this._openDropdown()),n.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){let{utilsScript:e,initialCountry:n,geoIpLookup:r}=this.options;e&&!m.utils?m.documentReady()?m.loadUtils(e):window.addEventListener("load",()=>{m.loadUtils(e)}):this.resolveUtilsScriptPromise(),n==="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((e="")=>{let n=e.toLowerCase();n&&this._getCountryData(n,!0)?(m.autoCountry=n,setTimeout(()=>t1("handleAutoCountry"))):(this._setInitialState(!0),t1("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),t1("rejectAutoCountryPromise")}))}_openDropdownWithPlus(){this._openDropdown(),this.searchInput.value="+",this._filterCountries("",!0)}_initTelInputListeners(){let{strictMode:e,formatAsYouType:n,separateDialCode:r,formatOnDisplay:u,allowDropdown:l}=this.options,p=!1;/\p{L}/u.test(this.telInput.value)&&(p=!0),this._handleInputEvent=f=>{if(this.isAndroid&&f?.data==="+"&&r&&l){let _=this.telInput.selectionStart||0,T=this.telInput.value.substring(0,_-1),x=this.telInput.value.substring(_);this.telInput.value=T+x,this._openDropdownWithPlus();return}this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let v=f?.data&&/[^+0-9]/.test(f.data),S=f?.inputType==="insertFromPaste"&&this.telInput.value;v||S&&!e?p=!0:/[^+0-9]/.test(this.telInput.value)||(p=!1);let I=f?.detail&&f.detail.isSetNumber&&!u;if(n&&!p&&!I){let _=this.telInput.selectionStart||0,x=this.telInput.value.substring(0,_).replace(/[^+0-9]/g,"").length,R=f?.inputType==="deleteContentForward",k=this._formatNumberAsYouType(),e1=K2(x,k,_,R);this.telInput.value=k,this.telInput.setSelectionRange(e1,e1)}},this.telInput.addEventListener("input",this._handleInputEvent),(e||r)&&(this._handleKeydownEvent=f=>{if(f.key&&f.key.length===1&&!f.altKey&&!f.ctrlKey&&!f.metaKey){if(r&&l&&f.key==="+"){f.preventDefault(),this._openDropdownWithPlus();return}if(e){let v=this.telInput.selectionStart===0&&f.key==="+",S=/^[0-9]$/.test(f.key),I=r?S:v||S,_=this._getFullNumber(),T=m.utils.getCoreNumber(_,this.selectedCountryData.iso2),x=this.maxCoreNumberLength&&T.length>=this.maxCoreNumberLength,R=this.telInput.value.substring(this.telInput.selectionStart,this.telInput.selectionEnd),k=/\d/.test(R);(!I||x&&!k)&&f.preventDefault()}}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let n=parseInt(this.telInput.getAttribute("maxlength")||"",10);return n&&e.length>n?e.substr(0,n):e}_trigger(e,n={}){let r=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});this.telInput.dispatchEvent(r)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:n}=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(),n){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 e=this.telInput.getBoundingClientRect(),n=this.telInput.offsetHeight;this.options.dropdownContainer&&(this.dropdown.style.top=`${e.top+n}px`,this.dropdown.style.left=`${e.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 e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let n="",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),n+=u.key.toLowerCase(),this._searchForCountry(n),r=setTimeout(()=>{n=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let u=()=>{let p=this.searchInput.value.trim();p?this._filterCountries(p):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",p=>p.stopPropagation())}}_searchForCountry(e){for(let n=0;nI[0]).join("").toLowerCase(),S=`+${p.dialCode}`;if(n||f.includes(u)||S.includes(u)||p.iso2.includes(u)||v.includes(u)){let I=p.nodeById[this.id];I&&this.countryList.appendChild(I),r&&(this._highlightListItem(I,!1),r=!1)}}r&&this._highlightListItem(null,!1),this.countryList.scrollTop=0,this._updateSearchResultsText()}_updateSearchResultsText(){let{i18n:e}=this.options,n=this.countryList.childElementCount,r;n===0?r=e.zeroSearchResults:n===1?r=e.oneSearchResult:r=e.multipleSearchResults.replace("${count}",n.toString()),this.searchResultsA11yText.textContent=r}_handleUpDownKey(e){let n=e==="ArrowUp"?this.highlightedItem?.previousElementSibling:this.highlightedItem?.nextElementSibling;!n&&this.countryList.childElementCount>1&&(n=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),n&&(this._scrollTo(n),this._highlightListItem(n,!1))}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_updateValFromNumber(e){let n=e;if(this.options.formatOnDisplay&&m.utils&&this.selectedCountryData){let r=this.options.nationalMode||n.charAt(0)!=="+"&&!this.options.separateDialCode,{NATIONAL:u,INTERNATIONAL:l}=m.utils.numberFormat,p=r?u:l;n=m.utils.formatNumber(n,this.selectedCountryData.iso2,p)}n=this._beforeSetNumber(n),this.telInput.value=n}_updateCountryFromNumber(e){let n=e.indexOf("+"),r=n?e.substring(n):e,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 p=this._getDialCode(r,!0),f=h1(r),v=null;if(p){let S=this.dialCodeToIso2Map[h1(p)],I=S.indexOf(this.selectedCountryData.iso2)!==-1&&f.length<=p.length-1;if(!(u==="1"&&s2(f))&&!I){for(let T=0;Tp){let _=u-f;n.scrollTop=I-_}}_updateDialCode(e){let n=this.telInput.value,r=`+${e}`,u;if(n.charAt(0)==="+"){let l=this._getDialCode(n);l?u=n.replace(l,r):u=r,this.telInput.value=u}}_getDialCode(e,n){let r="";if(e.charAt(0)==="+"){let u="";for(let l=0;l-1){let r=e.substring(0,n),u=this._utilsIsPossibleNumber(r),l=this._utilsIsPossibleNumber(e);return u&&l}return this._utilsIsPossibleNumber(e)}_utilsIsPossibleNumber(e){return m.utils?m.utils.isPossibleNumber(e,this.selectedCountryData.iso2,this.options.validationNumberType):null}isValidNumberPrecise(){let e=this._getFullNumber(),n=e.search(/\p{L}/u);if(n>-1){let r=e.substring(0,n),u=this._utilsIsValidNumber(r),l=this._utilsIsValidNumber(e);return u&&l}return this._utilsIsValidNumber(e)}_utilsIsValidNumber(e){return m.utils?m.utils.isValidNumber(e,this.selectedCountryData.iso2):null}setCountry(e){let n=e?.toLowerCase(),r=this.selectedCountryData.iso2;(e&&n!==r||!e&&r)&&(this._setCountry(n),this._updateDialCode(this.selectedCountryData.dialCode),this._triggerCountryChange())}setNumber(e){let n=this._updateCountryFromNumber(e);this._updateValFromNumber(e),n&&this._triggerCountryChange(),this._trigger("input",{isSetNumber:!0})}setPlaceholderNumberType(e){this.options.placeholderNumberType=e,this._updatePlaceholder()}setDisabled(e){this.telInput.disabled=e,e?this.selectedCountry.setAttribute("disabled","true"):this.selectedCountry.removeAttribute("disabled")}},V2=C=>!m.utils&&!m.startedLoadingUtilsScript?(m.startedLoadingUtilsScript=!0,new Promise((e,n)=>{import_INTENTIONALLY_BROKEN(/* webpackIgnore: true */ C).then(({default:r})=>{m.utils=r,t1("handleUtils"),e(!0)}).catch(()=>{t1("rejectUtilsScriptPromise"),n()})})):null,m=Object.assign((C,e)=>{let n=new v1(C,e);return n._init(),C.setAttribute("data-intl-tel-input-id",n.id.toString()),m.instances[n.id]=n,n},{defaults:u2,documentReady:()=>document.readyState==="complete",getCountryData:()=>K,getInstance:C=>{let e=C.getAttribute("data-intl-tel-input-id");return e?m.instances[e]:null},instances:{},loadUtils:V2,version:"24.2.1"}),I1=m;(function(){var C=this||self;function e(d,t){d=d.split(".");var $=C;d[0]in $||typeof $.execScript>"u"||$.execScript("var "+d[0]);for(var i;d.length&&(i=d.shift());)d.length||t===void 0?$[i]&&$[i]!==Object.prototype[i]?$=$[i]:$=$[i]={}:$[i]=t}function n(d,t){function $(){}$.prototype=t.prototype,d.ma=t.prototype,d.prototype=new $,d.prototype.constructor=d,d.sa=function(i,o,s){for(var a=Array(arguments.length-2),h=2;hd.length?!1:B(w2,d)}function x1(d){return B(b2,d)?r1(d,C2):r1(d,p1)}function R1(d){var t=x1(d.toString());P(d),d.g(t)}function O1(d){return d!=null&&(H(d,9)!=1||N(d,9)[0]!=-1)}function r1(d,t){for(var $=new w,i,o=d.length,s=0;st?2:s[s.length-1]=o&&o<=i;++o)if($=parseInt(d.substring(0,o),10),$ in J)return t.g(d.substring(o)),$;return 0}function F1(d,t,$,i,o,s){if(t.length==0)return 0;t=new w(t);var a;$!=null&&(a=c($,11)),a==null&&(a="NonMatch");var h=t.toString();if(h.length==0)a=20;else if(q.test(h))h=h.replace(q,""),P(t),t.g(x1(h)),a=1;else{if(h=new RegExp(a),R1(t),a=t.toString(),a.search(h)==0){h=a.match(h)[0].length;var g=a.substring(h).match(N1);g&&g[1]!=null&&0=t.h.length)throw Error("Phone number too short after IDD");if(d=U1(t,i),d!=0)return E(s,1,d),d;throw Error("Invalid country calling code")}return $!=null&&(a=y($,10),h=""+a,g=t.toString(),g.lastIndexOf(h,0)==0&&(h=new w(g.substring(h.length)),g=c($,1),g=new RegExp(y(g,2)),K1(h,$,null),h=h.toString(),!B(g,t.toString())&&B(g,h)||u1(d,t.toString(),$,-1)==3))?(i.g(h),o&&E(s,6,10),E(s,1,a),a):(E(s,1,0),0)}function K1(d,t,$){var i=d.toString(),o=i.length,s=c(t,15);if(o!=0&&s!=null&&s.length!=0){var a=new RegExp("^(?:"+s+")");if(o=a.exec(i)){s=new RegExp(y(c(t,1),2));var h=B(s,i),g=o.length-1;t=c(t,16),t==null||t.length==0||o[g]==null||o[g].length==0?(!h||B(s,i.substring(o[0].length)))&&($!=null&&0=t.length)s="";else{var a=t.indexOf(";",s);s=a!==-1?t.substring(s,a):t.substring(s)}var h=s;if(h==null?a=!0:h.length===0?a=!1:(a=S2.exec(h),h=T2.exec(h),a=a!==null||h!==null),!a||(s!=null?(s.charAt(0)==="+"&&o.g(s),s=t.indexOf("tel:"),o.g(t.substring(0<=s?s+4:0,t.indexOf(";phone-context=")))):(s=o.g,a=t??"",h=a.search(v2),0<=h?(a=a.substring(h),a=a.replace(_2,""),h=a.search(I2),0<=h&&(a=a.substring(0,h))):a="",s.call(o,a)),s=o.toString(),a=s.indexOf(";isub="),0t.h.length||(a!=null&&($=new w,o=new w(t.toString()),K1(o,a,$),d=u1(d,o.toString(),a,-1),d!=2&&d!=4&&d!=5&&(t=o,i&&0<$.toString().length&&E(s,7,$.toString()))),i=t.toString(),d=i.length,2>d))throw Error("The string supplied is too short to be a phone number");if(17{try{let $=d.replace(/[^+0-9]/g,""),i=new A2(t);t="";for(let o=0;o<$.length;o++)i.ja=M2(i,$.charAt(o)),t=i.ja;return t}catch{return d}}),e("intlTelInputUtilsTemp.formatNumber",(d,t,$)=>{try{let o=A.g(),s=W(o,d,t);var i=Z(o,s,-1);return i==0||i==4?o.format(s,typeof $>"u"?0:$):d}catch{return d}}),e("intlTelInputUtilsTemp.getExampleNumber",(d,t,$,i)=>{try{let g=A.g();d:{var o=g;if(o1(d)){var s=s1(F(o,d),$);try{if(D(s,6)){var a=c(s,6),h=V1(o,a,d,!1);break d}}catch{}}h=null}return g.format(h,i?0:t?2:1)}catch{return""}}),e("intlTelInputUtilsTemp.getExtension",(d,t)=>{try{return c(W(A.g(),d,t),3)}catch{return""}}),e("intlTelInputUtilsTemp.getNumberType",(d,t)=>{try{let a=A.g(),h=W(a,d,t);var $=G1(a,h),i=X(a,y(h,1),$);if(i==null)var o=-1;else{var s=Q(h);o=f1(s,i)}return o}catch{return-99}}),e("intlTelInputUtilsTemp.getValidationError",(d,t)=>{try{let $=A.g(),i=W($,d,t);return Z($,i,-1)}catch($){return $.message==="Invalid country calling code"?1:3>=d.length||$.message==="Phone number too short after IDD"||$.message==="The string supplied is too short to be a phone number"?2:$.message==="The string supplied is too long to be a phone number"?3:-99}}),e("intlTelInputUtilsTemp.isValidNumber",(d,t)=>{try{let g=A.g();var $=W(g,d,t),i=G1(g,$);d=g;var o=y($,1),s=X(d,o,i);if(s==null||i!="001"&&o!=H1(d,i))var a=!1;else{var h=Q($);a=f1(h,s)!=-1}return a}catch{return!1}}),e("intlTelInputUtilsTemp.isPossibleNumber",(d,t,$)=>{try{let i=A.g(),o=W(i,d,t);if($){let s=Z(i,o,l1[$])===0;if($==="FIXED_LINE_OR_MOBILE"){let a=Z(i,o,l1.MOBILE)===0,h=Z(i,o,l1.FIXED_LINE)===0;return a||h||s}return s}return Z(i,o,-1)===0}catch{return!1}}),e("intlTelInputUtilsTemp.getCoreNumber",(d,t)=>{try{return c(W(A.g(),d,t),2).toString()}catch{return""}}),e("intlTelInputUtilsTemp.numberFormat",{E164:0,INTERNATIONAL:1,NATIONAL:2,RFC3966:3}),e("intlTelInputUtilsTemp.numberType",l1),e("intlTelInputUtilsTemp.validationError",{IS_POSSIBLE:0,INVALID_COUNTRY_CODE:1,TOO_SHORT:2,TOO_LONG:3,IS_POSSIBLE_LOCAL_ONLY:4,INVALID_LENGTH:5})})();var j2=window.intlTelInputUtilsTemp;delete window.intlTelInputUtilsTemp;var a2=j2;I1.utils=a2;var W2=I1;return k2(z2);})(); // UMD return factoryOutput.default; diff --git a/react/build/IntlTelInput.cjs b/react/build/IntlTelInput.cjs index 8f1d4e06d..41a3a95bc 100644 --- a/react/build/IntlTelInput.cjs +++ b/react/build/IntlTelInput.cjs @@ -1762,7 +1762,6 @@ var Iti = class { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1774,6 +1773,8 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1935,10 +1936,9 @@ var Iti = class { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2236,25 +2236,25 @@ var Iti = class { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2283,15 +2283,15 @@ var Iti = class { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/build/IntlTelInput.d.ts b/react/build/IntlTelInput.d.ts index 0bb172b1e..4d1c55be0 100644 --- a/react/build/IntlTelInput.d.ts +++ b/react/build/IntlTelInput.d.ts @@ -420,6 +420,7 @@ declare module "intl-tel-input" { private _initDropdownListeners; private _initRequests; private _loadAutoCountry; + private _openDropdownWithPlus; private _initTelInputListeners; private _cap; private _trigger; diff --git a/react/build/IntlTelInput.js b/react/build/IntlTelInput.js index 2c49c5604..1ba3d06b7 100644 --- a/react/build/IntlTelInput.js +++ b/react/build/IntlTelInput.js @@ -1726,7 +1726,6 @@ var Iti = class { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1738,6 +1737,8 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1899,10 +1900,9 @@ var Iti = class { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2200,25 +2200,25 @@ var Iti = class { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2247,15 +2247,15 @@ var Iti = class { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/build/IntlTelInputWithUtils.cjs b/react/build/IntlTelInputWithUtils.cjs index 87e8777fd..f2182599d 100644 --- a/react/build/IntlTelInputWithUtils.cjs +++ b/react/build/IntlTelInputWithUtils.cjs @@ -1762,7 +1762,6 @@ var Iti = class { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1774,6 +1773,8 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1935,10 +1936,9 @@ var Iti = class { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2236,25 +2236,25 @@ var Iti = class { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2283,15 +2283,15 @@ var Iti = class { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/build/IntlTelInputWithUtils.js b/react/build/IntlTelInputWithUtils.js index d59a932ac..47932f3bd 100644 --- a/react/build/IntlTelInputWithUtils.js +++ b/react/build/IntlTelInputWithUtils.js @@ -1726,7 +1726,6 @@ var Iti = class { this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -1738,6 +1737,8 @@ var Iti = class { } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -1899,10 +1900,9 @@ var Iti = class { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -2200,25 +2200,25 @@ var Iti = class { } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -2247,15 +2247,15 @@ var Iti = class { if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/demo/set-number/set-number-bundle.js b/react/demo/set-number/set-number-bundle.js index 8f322dbd9..70de36f16 100644 --- a/react/demo/set-number/set-number-bundle.js +++ b/react/demo/set-number/set-number-bundle.js @@ -25313,7 +25313,6 @@ this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -25325,6 +25324,8 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -25486,10 +25487,9 @@ if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -25787,25 +25787,25 @@ } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -25834,15 +25834,15 @@ if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/demo/simple/simple-bundle.js b/react/demo/simple/simple-bundle.js index a8d85570c..be250cb81 100644 --- a/react/demo/simple/simple-bundle.js +++ b/react/demo/simple/simple-bundle.js @@ -25313,7 +25313,6 @@ this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -25325,6 +25324,8 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -25486,10 +25487,9 @@ if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -25787,25 +25787,25 @@ } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -25834,15 +25834,15 @@ if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/demo/toggle-disabled/toggle-disabled-bundle.js b/react/demo/toggle-disabled/toggle-disabled-bundle.js index 7d569491f..2af03f864 100644 --- a/react/demo/toggle-disabled/toggle-disabled-bundle.js +++ b/react/demo/toggle-disabled/toggle-disabled-bundle.js @@ -25313,7 +25313,6 @@ this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -25325,6 +25324,8 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -25486,10 +25487,9 @@ if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -25787,25 +25787,25 @@ } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -25834,15 +25834,15 @@ if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/react/demo/validation/validation-bundle.js b/react/demo/validation/validation-bundle.js index 58c8c68ff..22fa6e6b0 100644 --- a/react/demo/validation/validation-bundle.js +++ b/react/demo/validation/validation-bundle.js @@ -25313,7 +25313,6 @@ this.options.initialCountry = this.options.onlyCountries[0]; } if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -25325,6 +25324,8 @@ } this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false; this.isRTL = !!this.telInput.closest("[dir=rtl]"); + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; if (this.options.separateDialCode) { if (this.isRTL) { this.originalPaddingRight = this.telInput.style.paddingRight; @@ -25486,10 +25487,9 @@ if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = allowDropdown && !this.isRTL || !allowDropdown && this.isRTL; const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - if (allowDropdown || showFlags) { + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -25787,25 +25787,25 @@ } } } + _openDropdownWithPlus() { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; this._handleInputEvent = (e) => { - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (this._updateCountryFromNumber(this.telInput.value)) { @@ -25834,15 +25834,15 @@ if (strictMode || separateDialCode) { this._handleKeydownEvent = (e) => { if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/src/js/intl-tel-input.ts b/src/js/intl-tel-input.ts index 001bbd804..0409b87e6 100644 --- a/src/js/intl-tel-input.ts +++ b/src/js/intl-tel-input.ts @@ -305,9 +305,8 @@ export class Iti { this.options.initialCountry = this.options.onlyCountries[0]; } - //* When separateDialCode enabled, we force nationalMode to false (because the displayed dial code is supposed to be thought of as part of the typed number), AND we force allowDropdown to true as we need the dropdown to select the dial code, AND we force countrySearch to true because that is used when the user types a plus in the tel input. + //* When separateDialCode enabled, we force nationalMode to false (because the displayed dial code is supposed to be thought of as part of the typed number), AND we force countrySearch to true because that is used when the user types a plus in the tel input. if (this.options.separateDialCode) { - this.options.allowDropdown = true; this.options.nationalMode = false; this.options.countrySearch = true; } @@ -326,6 +325,10 @@ export class Iti { //* Check if input has one parent with RTL. this.isRTL = !!this.telInput.closest("[dir=rtl]"); + + const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide; + //* Store original styling before we override it. if (this.options.separateDialCode) { if (this.isRTL) { @@ -563,13 +566,12 @@ export class Iti { if (!useFullscreenPopup) { parentClass += " iti--inline-dropdown"; } - this.showSelectedCountryOnLeft = (allowDropdown && !this.isRTL) || (!allowDropdown && this.isRTL); const wrapper = createEl("div", { class: parentClass }); this.telInput.parentNode?.insertBefore(wrapper, this.telInput); - //* Even if allowDropdown is disabled, we still want to show the flag for the currently typed number. - if (allowDropdown || showFlags) { + //* If we need a countryContainer + if (allowDropdown || showFlags || separateDialCode) { this.countryContainer = createEl( "div", { @@ -959,31 +961,31 @@ export class Iti { } } + private _openDropdownWithPlus(): void { + this._openDropdown(); + this.searchInput.value = "+"; + this._filterCountries("", true); + } + //* Initialize the tel input listeners. private _initTelInputListeners(): void { - const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options; + const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown } = this.options; let userOverrideFormatting = false; //* If the initial val contains any alpha chars (e.g. the extension separator "ext."), then set the override, as libphonenumber's AYT-formatter cannot handle alphas. if (/\p{L}/u.test(this.telInput.value)) { userOverrideFormatting = true; } - const openDropdownWithPlus = () => { - this._openDropdown(); - this.searchInput.value = "+"; - this._filterCountries("", true); - }; - //* On input event: (1) Update selected country, (2) Format-as-you-type. //* Note that this fires AFTER the input is updated. this._handleInputEvent = (e: InputEvent): void => { //* Android workaround for handling plus when separateDialCode enabled (as impossible to handle with keydown/keyup, for which e.key always returns "Unidentified", see https://stackoverflow.com/q/59584061/217866) - if (this.isAndroid && e?.data === "+" && separateDialCode) { + if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown) { const currentCaretPos = this.telInput.selectionStart || 0; const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1); const valueAfterCaret = this.telInput.value.substring(currentCaretPos); this.telInput.value = valueBeforeCaret + valueAfterCaret; - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } @@ -1029,16 +1031,16 @@ export class Iti { //* Only interested in actual character presses, rather than ctrl, alt, command, arrow keys, delete/backspace, cut/copy/paste etc. if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) { //* If separateDialCode, handle the plus key differently: open dropdown and put plus in the search input instead. - if (separateDialCode && e.key === "+") { + if (separateDialCode && allowDropdown && e.key === "+") { e.preventDefault(); - openDropdownWithPlus(); + this._openDropdownWithPlus(); return; } //* If strictMode, prevent invalid characters. if (strictMode) { const isInitialPlus = this.telInput.selectionStart === 0 && e.key === "+"; const isNumeric = /^[0-9]$/.test(e.key); - const isAllowedChar = isInitialPlus || isNumeric; + const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric; const fullNumber = this._getFullNumber(); const coreNumber = intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); const hasReachedMaxLength = this.maxCoreNumberLength && coreNumber.length >= this.maxCoreNumberLength; diff --git a/vue/build/IntlTelInput.mjs b/vue/build/IntlTelInput.mjs index 54b830396..f920a178e 100644 --- a/vue/build/IntlTelInput.mjs +++ b/vue/build/IntlTelInput.mjs @@ -1,4 +1,4 @@ -import { mergeModels as v, useModel as k, ref as w, onMounted as T, watch as x, onUnmounted as P, withDirectives as E, openBlock as M, createElementBlock as B, vModelText as V } from "vue"; +import { mergeModels as v, useModel as k, ref as w, onMounted as T, watch as P, onUnmounted as x, withDirectives as E, openBlock as M, createElementBlock as B, vModelText as O } from "vue"; const L = [ [ "af", @@ -1318,7 +1318,7 @@ for (let l = 0; l < L.length; l++) { nodeById: {} }; } -const O = { +const V = { ad: "Andorra", ae: "United Arab Emirates", af: "Afghanistan", @@ -1561,7 +1561,7 @@ const O = { za: "South Africa", zm: "Zambia", zw: "Zimbabwe" -}, R = { +}, F = { selectedCountryAriaLabel: "Selected country", noCountrySelected: "No country selected", countryListAriaLabel: "List of countries", @@ -1572,10 +1572,10 @@ const O = { // additional countries (not supported by country-list library) ac: "Ascension Island", xk: "Kosovo" -}, A = { ...O, ...R }; +}, A = { ...V, ...F }; for (let l = 0; l < g.length; l++) g[l].name = A[g[l].iso2]; -let F = 0; +let R = 0; const S = { //* Whether or not to allow the dropdown. allowDropdown: !0, @@ -1676,17 +1676,19 @@ const S = { }; class j { constructor(t, e = {}) { - this.id = F++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, S, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder"); + this.id = R++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, S, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder"); } //* Can't be private as it's called from intlTelInput convenience wrapper. _init() { - this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.allowDropdown = !0, this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !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 = { ...A, ...this.options.i18n }; - const t = new Promise((i, s) => { - this.resolveAutoCountryPromise = i, this.rejectAutoCountryPromise = s; - }), e = new Promise((i, s) => { - this.resolveUtilsScriptPromise = i, this.rejectUtilsScriptPromise = s; + this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !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]"); + const t = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...A, ...this.options.i18n }; + const e = new Promise((s, n) => { + this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n; + }), i = new Promise((s, n) => { + this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = n; }); - this.promise = Promise.all([t, e]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests(); + this.promise = Promise.all([e, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests(); } //******************** //* PRIVATE METHODS @@ -1782,9 +1784,9 @@ class j { i18n: h } = this.options; let c = "iti"; - t && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), u || (c += " iti--inline-dropdown"), this.showSelectedCountryOnLeft = t && !this.isRTL || !t && this.isRTL; + t && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), u || (c += " iti--inline-dropdown"); const C = m("div", { class: c }); - if ((d = this.telInput.parentNode) == null || d.insertBefore(C, this.telInput), t || i) { + if ((d = this.telInput.parentNode) == null || d.insertBefore(C, this.telInput), t || i || e) { this.countryContainer = m( "div", { @@ -1954,36 +1956,35 @@ class j { } )); } + _openDropdownWithPlus() { + this._openDropdown(), this.searchInput.value = "+", this._filterCountries("", !0); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode: t, formatAsYouType: e, separateDialCode: i, formatOnDisplay: s } = this.options; - let n = !1; - new RegExp("\\p{L}", "u").test(this.telInput.value) && (n = !0); - const a = () => { - this._openDropdown(), this.searchInput.value = "+", this._filterCountries("", !0); - }; - this._handleInputEvent = (o) => { - if (this.isAndroid && (o == null ? void 0 : o.data) === "+" && i) { + const { strictMode: t, formatAsYouType: e, separateDialCode: i, formatOnDisplay: s, allowDropdown: n } = this.options; + let a = !1; + new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (o) => { + if (this.isAndroid && (o == null ? void 0 : o.data) === "+" && i && n) { const c = this.telInput.selectionStart || 0, C = this.telInput.value.substring(0, c - 1), d = this.telInput.value.substring(c); - this.telInput.value = C + d, a(); + this.telInput.value = C + d, this._openDropdownWithPlus(); return; } this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange(); const u = (o == null ? void 0 : o.data) && /[^+0-9]/.test(o.data), p = (o == null ? void 0 : o.inputType) === "insertFromPaste" && this.telInput.value; - u || p && !t ? n = !0 : /[^+0-9]/.test(this.telInput.value) || (n = !1); + u || p && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1); const h = (o == null ? void 0 : o.detail) && o.detail.isSetNumber && !s; - if (e && !n && !h) { + if (e && !a && !h) { const c = this.telInput.selectionStart || 0, d = this.telInput.value.substring(0, c).replace(/[^+0-9]/g, "").length, y = (o == null ? void 0 : o.inputType) === "deleteContentForward", f = this._formatNumberAsYouType(), b = $(d, f, c, y); this.telInput.value = f, this.telInput.setSelectionRange(b, b); } }, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (o) => { if (o.key && o.key.length === 1 && !o.altKey && !o.ctrlKey && !o.metaKey) { - if (i && o.key === "+") { - o.preventDefault(), a(); + if (i && n && o.key === "+") { + o.preventDefault(), this._openDropdownWithPlus(); return; } if (t) { - const u = this.telInput.selectionStart === 0 && o.key === "+", p = /^[0-9]$/.test(o.key), h = u || p, c = this._getFullNumber(), C = r.utils.getCoreNumber(c, this.selectedCountryData.iso2), d = this.maxCoreNumberLength && C.length >= this.maxCoreNumberLength, y = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), f = /\d/.test(y); + const u = this.telInput.selectionStart === 0 && o.key === "+", p = /^[0-9]$/.test(o.key), h = i ? p : u || p, c = this._getFullNumber(), C = r.utils.getCoreNumber(c, this.selectedCountryData.iso2), d = this.maxCoreNumberLength && C.length >= this.maxCoreNumberLength, y = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), f = /\d/.test(y); (!h || d && !f) && o.preventDefault(); } } @@ -2501,13 +2502,13 @@ const K = (l) => !r.utils && !r.startedLoadingUtilsScript ? (r.startedLoadingUti }; return T(() => { a.value && (o.value = r(a.value, s.options), s.value && o.value.setNumber(s.value), s.disabled && o.value.setDisabled(s.disabled)); - }), x( + }), P( () => s.disabled, (d) => { var y; return (y = o.value) == null ? void 0 : y.setDisabled(d); } - ), P(() => { + ), x(() => { var d; return (d = o.value) == null ? void 0 : d.destroy(); }), t({ instance: o, input: a }), (d, y) => E((M(), B("input", { @@ -2518,7 +2519,7 @@ const K = (l) => !r.utils && !r.startedLoadingUtilsScript ? (r.startedLoadingUti onCountrychange: C, onInput: c }, null, 544)), [ - [V, i.value] + [O, i.value] ]); } }; diff --git a/vue/build/IntlTelInputWithUtils.mjs b/vue/build/IntlTelInputWithUtils.mjs index 85415f2c0..93c279617 100644 --- a/vue/build/IntlTelInputWithUtils.mjs +++ b/vue/build/IntlTelInputWithUtils.mjs @@ -1,4 +1,4 @@ -import { mergeModels as d2, useModel as A2, ref as m1, onMounted as L2, watch as N2, onUnmounted as E2, withDirectives as M2, openBlock as D2, createElementBlock as x2, vModelText as P2 } from "vue"; +import { mergeModels as d2, useModel as A2, ref as m1, onMounted as N2, watch as L2, onUnmounted as E2, withDirectives as D2, openBlock as M2, createElementBlock as x2, vModelText as P2 } from "vue"; const t2 = [ [ "af", @@ -1667,7 +1667,7 @@ const n2 = { return a; } return e.length; -}, L = (m, e, i) => { +}, N = (m, e, i) => { const s = document.createElement(m); return e && Object.entries(e).forEach(([u, a]) => s.setAttribute(u, a)), i && i.appendChild(s), s; }, e1 = (m) => { @@ -1680,13 +1680,15 @@ class U2 { } //* Can't be private as it's called from intlTelInput convenience wrapper. _init() { - this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.allowDropdown = !0, this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !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 = { ...i2, ...this.options.i18n }; - const e = new Promise((s, u) => { - this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = u; - }), i = new Promise((s, u) => { - this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = u; + this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !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]"); + const e = this.options.allowDropdown || this.options.separateDialCode; + this.showSelectedCountryOnLeft = this.isRTL ? !e : e, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...i2, ...this.options.i18n }; + const i = new Promise((u, a) => { + this.resolveAutoCountryPromise = u, this.rejectAutoCountryPromise = a; + }), s = new Promise((u, a) => { + this.resolveUtilsScriptPromise = u, this.rejectUtilsScriptPromise = a; }); - this.promise = Promise.all([e, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests(); + this.promise = Promise.all([i, s]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests(); } //******************** //* PRIVATE METHODS @@ -1778,21 +1780,21 @@ class U2 { dropdownContainer: f, fixDropdownWidth: h, useFullscreenPopup: y, - countrySearch: b, + countrySearch: w, i18n: I } = this.options; let S = "iti"; - e && (S += " iti--allow-dropdown"), s && (S += " iti--show-flags"), u && (S += ` ${u}`), y || (S += " iti--inline-dropdown"), this.showSelectedCountryOnLeft = e && !this.isRTL || !e && this.isRTL; - const T = L("div", { class: S }); - if ((_ = this.telInput.parentNode) == null || _.insertBefore(T, this.telInput), e || s) { - this.countryContainer = L( + e && (S += " iti--allow-dropdown"), s && (S += " iti--show-flags"), u && (S += ` ${u}`), y || (S += " iti--inline-dropdown"); + const T = N("div", { class: S }); + if ((_ = this.telInput.parentNode) == null || _.insertBefore(T, this.telInput), e || s || i) { + this.countryContainer = N( "div", { class: "iti__country-container", style: this.showSelectedCountryOnLeft ? "left: 0" : "right: 0" }, T - ), e ? (this.selectedCountry = L( + ), e ? (this.selectedCountry = N( "button", { type: "button", @@ -1804,30 +1806,30 @@ class U2 { role: "combobox" }, this.countryContainer - ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = L( + ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = N( "div", { class: "iti__selected-country" }, this.countryContainer ); - const N = L("div", { class: "iti__selected-country-primary" }, this.selectedCountry); - if (this.selectedCountryInner = L("div", { class: "iti__flag" }, N), this.selectedCountryA11yText = L( + const L = N("div", { class: "iti__selected-country-primary" }, this.selectedCountry); + if (this.selectedCountryInner = N("div", { class: "iti__flag" }, L), this.selectedCountryA11yText = N( "span", { class: "iti__a11y-text" }, this.selectedCountryInner - ), e && (this.dropdownArrow = L( + ), e && (this.dropdownArrow = N( "div", { class: "iti__arrow", "aria-hidden": "true" }, - N - )), i && (this.selectedDialCode = L( + L + )), i && (this.selectedDialCode = N( "div", { class: "iti__selected-dial-code" }, this.selectedCountry )), e) { - const D = h ? "" : "iti--flexible-dropdown-width"; - if (this.dropdownContent = L("div", { + const M = h ? "" : "iti--flexible-dropdown-width"; + if (this.dropdownContent = N("div", { id: `iti-${this.id}__dropdown-content`, - class: `iti__dropdown-content iti__hide ${D}` - }), b && (this.searchInput = L( + class: `iti__dropdown-content iti__hide ${M}` + }), w && (this.searchInput = N( "input", { type: "text", @@ -1841,11 +1843,11 @@ class U2 { autocomplete: "off" }, this.dropdownContent - ), this.searchResultsA11yText = L( + ), this.searchResultsA11yText = N( "span", { class: "iti__a11y-text" }, this.dropdownContent - )), this.countryList = L( + )), this.countryList = N( "ul", { class: "iti__country-list", @@ -1854,28 +1856,28 @@ class U2 { "aria-label": I.countryListAriaLabel }, this.dropdownContent - ), this._appendListItems(), b && this._updateSearchResultsText(), f) { + ), this._appendListItems(), w && this._updateSearchResultsText(), f) { let U = "iti iti--container"; - y ? U += " iti--fullscreen-popup" : U += " iti--inline-dropdown", this.dropdown = L("div", { class: U }), this.dropdown.appendChild(this.dropdownContent); + y ? U += " iti--fullscreen-popup" : U += " iti--inline-dropdown", this.dropdown = N("div", { class: U }), this.dropdown.appendChild(this.dropdownContent); } else this.countryContainer.appendChild(this.dropdownContent); } } if (T.appendChild(this.telInput), this._updateInputPadding(), a) { - const N = this.telInput.getAttribute("name") || "", D = a(N); - D.phone && (this.hiddenInput = L("input", { + const L = this.telInput.getAttribute("name") || "", M = a(L); + M.phone && (this.hiddenInput = N("input", { type: "hidden", - name: D.phone - }), T.appendChild(this.hiddenInput)), D.country && (this.hiddenInputCountry = L("input", { + name: M.phone + }), T.appendChild(this.hiddenInput)), M.country && (this.hiddenInputCountry = N("input", { type: "hidden", - name: D.country + name: M.country }), T.appendChild(this.hiddenInputCountry)); } } //* For each country: add a country list item
  • to the countryList
      container. _appendListItems() { for (let e = 0; e < this.countries.length; e++) { - const i = this.countries[e], s = e === 0 ? "iti__highlight" : "", u = L( + const i = this.countries[e], s = e === 0 ? "iti__highlight" : "", u = N( "li", { id: `iti-${this.id}__item-${i.iso2}`, @@ -1897,7 +1899,7 @@ class U2 { //* 1. Extracting a dial code from the given number //* 2. Using explicit initialCountry _setInitialState(e = !1) { - const i = this.telInput.getAttribute("value"), s = this.telInput.value, a = i && i.charAt(0) === "+" && (!s || s.charAt(0) !== "+") ? i : s, f = this._getDialCode(a), h = $2(a), { initialCountry: y, geoIpLookup: b } = this.options, I = y === "auto" && b; + const i = this.telInput.getAttribute("value"), s = this.telInput.value, a = i && i.charAt(0) === "+" && (!s || s.charAt(0) !== "+") ? i : s, f = this._getDialCode(a), h = $2(a), { initialCountry: y, geoIpLookup: w } = this.options, I = y === "auto" && w; if (f && !h) this._updateCountryFromNumber(a); else if (!I || e) { @@ -1954,37 +1956,36 @@ class U2 { } )); } + _openDropdownWithPlus() { + this._openDropdown(), this.searchInput.value = "+", this._filterCountries("", !0); + } //* Initialize the tel input listeners. _initTelInputListeners() { - const { strictMode: e, formatAsYouType: i, separateDialCode: s, formatOnDisplay: u } = this.options; - let a = !1; - new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0); - const f = () => { - this._openDropdown(), this.searchInput.value = "+", this._filterCountries("", !0); - }; - this._handleInputEvent = (h) => { - if (this.isAndroid && (h == null ? void 0 : h.data) === "+" && s) { + const { strictMode: e, formatAsYouType: i, separateDialCode: s, formatOnDisplay: u, allowDropdown: a } = this.options; + let f = !1; + new RegExp("\\p{L}", "u").test(this.telInput.value) && (f = !0), this._handleInputEvent = (h) => { + if (this.isAndroid && (h == null ? void 0 : h.data) === "+" && s && a) { const S = this.telInput.selectionStart || 0, T = this.telInput.value.substring(0, S - 1), _ = this.telInput.value.substring(S); - this.telInput.value = T + _, f(); + this.telInput.value = T + _, this._openDropdownWithPlus(); return; } this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange(); - const y = (h == null ? void 0 : h.data) && /[^+0-9]/.test(h.data), b = (h == null ? void 0 : h.inputType) === "insertFromPaste" && this.telInput.value; - y || b && !e ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1); + const y = (h == null ? void 0 : h.data) && /[^+0-9]/.test(h.data), w = (h == null ? void 0 : h.inputType) === "insertFromPaste" && this.telInput.value; + y || w && !e ? f = !0 : /[^+0-9]/.test(this.telInput.value) || (f = !1); const I = (h == null ? void 0 : h.detail) && h.detail.isSetNumber && !u; - if (i && !a && !I) { - const S = this.telInput.selectionStart || 0, _ = this.telInput.value.substring(0, S).replace(/[^+0-9]/g, "").length, N = (h == null ? void 0 : h.inputType) === "deleteContentForward", D = this._formatNumberAsYouType(), U = G2(_, D, S, N); - this.telInput.value = D, this.telInput.setSelectionRange(U, U); + if (i && !f && !I) { + const S = this.telInput.selectionStart || 0, _ = this.telInput.value.substring(0, S).replace(/[^+0-9]/g, "").length, L = (h == null ? void 0 : h.inputType) === "deleteContentForward", M = this._formatNumberAsYouType(), U = G2(_, M, S, L); + this.telInput.value = M, this.telInput.setSelectionRange(U, U); } }, this.telInput.addEventListener("input", this._handleInputEvent), (e || s) && (this._handleKeydownEvent = (h) => { if (h.key && h.key.length === 1 && !h.altKey && !h.ctrlKey && !h.metaKey) { - if (s && h.key === "+") { - h.preventDefault(), f(); + if (s && a && h.key === "+") { + h.preventDefault(), this._openDropdownWithPlus(); return; } if (e) { - const y = this.telInput.selectionStart === 0 && h.key === "+", b = /^[0-9]$/.test(h.key), I = y || b, S = this._getFullNumber(), T = C.utils.getCoreNumber(S, this.selectedCountryData.iso2), _ = this.maxCoreNumberLength && T.length >= this.maxCoreNumberLength, N = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), D = /\d/.test(N); - (!I || _ && !D) && h.preventDefault(); + const y = this.telInput.selectionStart === 0 && h.key === "+", w = /^[0-9]$/.test(h.key), I = s ? w : y || w, S = this._getFullNumber(), T = C.utils.getCoreNumber(S, this.selectedCountryData.iso2), _ = this.maxCoreNumberLength && T.length >= this.maxCoreNumberLength, L = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), M = /\d/.test(L); + (!I || _ && !M) && h.preventDefault(); } } }, this.telInput.addEventListener("keydown", this._handleKeydownEvent)); @@ -2075,8 +2076,8 @@ class U2 { this.countryList.innerHTML = ""; const u = e2(e); for (let a = 0; a < this.countries.length; a++) { - const f = this.countries[a], h = e2(f.name), y = f.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((I) => I[0]).join("").toLowerCase(), b = `+${f.dialCode}`; - if (i || h.includes(u) || b.includes(u) || f.iso2.includes(u) || y.includes(u)) { + const f = this.countries[a], h = e2(f.name), y = f.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((I) => I[0]).join("").toLowerCase(), w = `+${f.dialCode}`; + if (i || h.includes(u) || w.includes(u) || f.iso2.includes(u) || y.includes(u)) { const I = f.nodeById[this.id]; I && this.countryList.appendChild(I), s && (this._highlightListItem(I, !1), s = !1); } @@ -2123,11 +2124,11 @@ class U2 { const f = this._getDialCode(s, !0), h = h1(s); let y = null; if (f) { - const b = this.dialCodeToIso2Map[h1(f)], I = b.indexOf(this.selectedCountryData.iso2) !== -1 && h.length <= f.length - 1; + const w = this.dialCodeToIso2Map[h1(f)], I = w.indexOf(this.selectedCountryData.iso2) !== -1 && h.length <= f.length - 1; if (!(u === "1" && $2(h)) && !I) { - for (let T = 0; T < b.length; T++) - if (b[T]) { - y = b[T]; + for (let T = 0; T < w.length; T++) + if (w[T]) { + y = w[T]; break; } } @@ -2252,10 +2253,10 @@ class U2 { } //* Check if an element is visible within it's container, else scroll until it is. _scrollTo(e) { - const i = this.countryList, s = document.documentElement.scrollTop, u = i.offsetHeight, a = i.getBoundingClientRect().top + s, f = a + u, h = e.offsetHeight, y = e.getBoundingClientRect().top + s, b = y + h, I = y - a + i.scrollTop; + const i = this.countryList, s = document.documentElement.scrollTop, u = i.offsetHeight, a = i.getBoundingClientRect().top + s, f = a + u, h = e.offsetHeight, y = e.getBoundingClientRect().top + s, w = y + h, I = y - a + i.scrollTop; if (y < a) i.scrollTop = I; - else if (b > f) { + else if (w > f) { const S = u - h; i.scrollTop = I - S; } @@ -2510,7 +2511,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } new h(); const y = {}; - class b { + class w { constructor() { if (y !== y) throw Error("SafeStyleSheet is not meant to be built directly"); } @@ -2518,7 +2519,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt return ""; } } - new b(); + new w(); const I = {}; class S { constructor() { @@ -2533,18 +2534,18 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt new S(); function T(d, t) { switch (this.g = d, this.l = !!t.aa, this.h = t.i, this.s = t.type, this.o = !1, this.h) { - case D: + case M: case U: case s2: case r2: case o2: - case N: + case L: case _: this.o = !0; } this.j = t.defaultValue; } - var _ = 1, N = 2, D = 3, U = 4, s2 = 6, r2 = 16, o2 = 18; + var _ = 1, L = 2, M = 3, U = 4, s2 = 6, r2 = 16, o2 = 18; function u2(d, t) { for (this.h = d, this.g = {}, d = 0; d < t.length; d++) { var $ = t[d]; @@ -2685,10 +2686,10 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } i(j, P); var v1 = null; - function w() { + function b() { P.call(this); } - i(w, P); + i(b, P); var S1 = null; function W() { P.call(this); @@ -2698,30 +2699,30 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt j.prototype.m = function() { var d = v1; return d || (v1 = d = i1(j, { 0: { name: "NumberFormat", ia: "i18n.phonenumbers.NumberFormat" }, 1: { name: "pattern", required: !0, i: 9, type: String }, 2: { name: "format", required: !0, i: 9, type: String }, 3: { name: "leading_digits_pattern", aa: !0, i: 9, type: String }, 4: { name: "national_prefix_formatting_rule", i: 9, type: String }, 6: { name: "national_prefix_optional_when_formatting", i: 8, defaultValue: !1, type: Boolean }, 5: { name: "domestic_carrier_code_formatting_rule", i: 9, type: String } })), d; - }, j.m = j.prototype.m, w.prototype.m = function() { + }, j.m = j.prototype.m, b.prototype.m = function() { var d = S1; - return d || (S1 = d = i1(w, { 0: { name: "PhoneNumberDesc", ia: "i18n.phonenumbers.PhoneNumberDesc" }, 2: { name: "national_number_pattern", i: 9, type: String }, 9: { name: "possible_length", aa: !0, i: 5, type: Number }, 10: { name: "possible_length_local_only", aa: !0, i: 5, type: Number }, 6: { name: "example_number", i: 9, type: String } })), d; - }, w.m = w.prototype.m, W.prototype.m = function() { + return d || (S1 = d = i1(b, { 0: { name: "PhoneNumberDesc", ia: "i18n.phonenumbers.PhoneNumberDesc" }, 2: { name: "national_number_pattern", i: 9, type: String }, 9: { name: "possible_length", aa: !0, i: 5, type: Number }, 10: { name: "possible_length_local_only", aa: !0, i: 5, type: Number }, 6: { name: "example_number", i: 9, type: String } })), d; + }, b.m = b.prototype.m, W.prototype.m = function() { var d = w1; return d || (w1 = d = i1(W, { 0: { name: "PhoneMetadata", ia: "i18n.phonenumbers.PhoneMetadata" }, - 1: { name: "general_desc", i: 11, type: w }, - 2: { name: "fixed_line", i: 11, type: w }, - 3: { name: "mobile", i: 11, type: w }, - 4: { name: "toll_free", i: 11, type: w }, - 5: { name: "premium_rate", i: 11, type: w }, - 6: { name: "shared_cost", i: 11, type: w }, - 7: { name: "personal_number", i: 11, type: w }, - 8: { name: "voip", i: 11, type: w }, - 21: { name: "pager", i: 11, type: w }, - 25: { name: "uan", i: 11, type: w }, - 27: { name: "emergency", i: 11, type: w }, - 28: { name: "voicemail", i: 11, type: w }, - 29: { name: "short_code", i: 11, type: w }, - 30: { name: "standard_rate", i: 11, type: w }, - 31: { name: "carrier_specific", i: 11, type: w }, - 33: { name: "sms_services", i: 11, type: w }, - 24: { name: "no_international_dialling", i: 11, type: w }, + 1: { name: "general_desc", i: 11, type: b }, + 2: { name: "fixed_line", i: 11, type: b }, + 3: { name: "mobile", i: 11, type: b }, + 4: { name: "toll_free", i: 11, type: b }, + 5: { name: "premium_rate", i: 11, type: b }, + 6: { name: "shared_cost", i: 11, type: b }, + 7: { name: "personal_number", i: 11, type: b }, + 8: { name: "voip", i: 11, type: b }, + 21: { name: "pager", i: 11, type: b }, + 25: { name: "uan", i: 11, type: b }, + 27: { name: "emergency", i: 11, type: b }, + 28: { name: "voicemail", i: 11, type: b }, + 29: { name: "short_code", i: 11, type: b }, + 30: { name: "standard_rate", i: 11, type: b }, + 31: { name: "carrier_specific", i: 11, type: b }, + 33: { name: "sms_services", i: 11, type: b }, + 24: { name: "no_international_dialling", i: 11, type: b }, 9: { name: "id", required: !0, i: 9, type: String }, 10: { name: "country_code", i: 5, type: Number }, 11: { name: "international_prefix", i: 9, type: String }, @@ -7983,11 +7984,11 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt ], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "001", 888, , , , , , , , 1, [[, "(\\d{3})(\\d{3})(\\d{5})", "$1 $2 $3"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , "\\d{11}", , , , "12345678901"], , , [, , , , , , , , , [-1]]], 979: [, [, , "[1359]\\d{8}", , , , , , , [9], [8]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , "[1359]\\d{8}", , , , "123456789", , , , [8]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "001", 979, , , , , , , , 1, [[, "(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[1359]"]]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]] }; - function M() { + function D() { this.g = {}; } - M.h = void 0, M.g = function() { - return M.h ? M.h : M.h = new M(); + D.h = void 0, D.g = function() { + return D.h ? D.h : D.h = new D(); }; var f1 = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", "0": "0", "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6", "7": "7", "8": "8", "9": "9", "٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9", "۰": "0", "۱": "1", "۲": "2", "۳": "3", "۴": "4", "۵": "5", "۶": "6", "۷": "7", "۸": "8", "۹": "9" }, h2 = { 0: "0", @@ -8074,18 +8075,18 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt function Z(d) { return "([0-90-9٠-٩۰-۹]{1," + d + "})"; } - function L1() { + function N1() { return ";ext=" + Z("20") + "|[  \\t,]*(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)[:\\..]?[  \\t,-]*" + (Z("20") + "#?|[  \\t,]*(?:[xx##~~]|int|int)[:\\..]?[  \\t,-]*") + (Z("9") + "#?|[- ]+") + (Z("6") + "#|[  \\t]*(?:,{2}|;)[:\\..]?[  \\t,-]*") + (Z("15") + "#?|[  \\t]*(?:,)+[:\\..]?[  \\t,-]*") + (Z("9") + "#?"); } - var N1 = new RegExp("(?:" + L1() + ")$", "i"), I2 = new RegExp("^[0-90-9٠-٩۰-۹]{2}$|^[++]*(?:[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~*]*[0-90-9٠-٩۰-۹]){3,}[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~*A-Za-z0-90-9٠-٩۰-۹]*(?:" + L1() + ")?$", "i"), v2 = /(\$\d)/, S2 = /^\(?\$1\)?$/; + var L1 = new RegExp("(?:" + N1() + ")$", "i"), I2 = new RegExp("^[0-90-9٠-٩۰-۹]{2}$|^[++]*(?:[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~*]*[0-90-9٠-٩۰-۹]){3,}[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~*A-Za-z0-90-9٠-٩۰-۹]*(?:" + N1() + ")?$", "i"), v2 = /(\$\d)/, S2 = /^\(?\$1\)?$/; function E1(d) { return 2 > d.length ? !1 : O(I2, d); } - function M1(d) { + function D1(d) { return O(m2, d) ? s1(d, c2) : s1(d, f1); } - function D1(d) { - var t = M1(d.toString()); + function M1(d) { + var t = D1(d.toString()); B(d), d.g(t); } function x1(d) { @@ -8101,7 +8102,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt function r1(d) { return d != null && isNaN(d) && d.toUpperCase() in T1; } - M.prototype.format = function(d, t) { + D.prototype.format = function(d, t) { if (p(d, 2) == 0 && R(d, 5)) { var $ = v(d, 5); if (0 < $.length) return $; @@ -8246,9 +8247,9 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt $ != null && (l = p($, 11)), l == null && (l = "NonMatch"); var c = t.toString(); if (c.length == 0) l = 20; - else if (X.test(c)) c = c.replace(X, ""), B(t), t.g(M1(c)), l = 1; + else if (X.test(c)) c = c.replace(X, ""), B(t), t.g(D1(c)), l = 1; else { - if (c = new RegExp(l), D1(t), l = t.toString(), l.search(c) == 0) { + if (c = new RegExp(l), M1(t), l = t.toString(), l.search(c) == 0) { c = l.match(c)[0].length; var g = l.substring(c).match(A1); g && g[1] != null && 0 < g[1].length && s1(g[1], f1) == "0" ? l = !1 : (B(t), t.g(l.substring(c)), l = !0); @@ -8292,8 +8293,8 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt if (o = r.toString(), !(r1($) || o != null && 0 < o.length && X.test(o))) throw Error("Invalid country calling code"); o = new V(), n && E(o, 5, t); d: { - if (t = r.toString(), l = t.search(N1), 0 <= l && E1(t.substring(0, l))) { - c = t.match(N1); + if (t = r.toString(), l = t.search(L1), 0 <= l && E1(t.substring(0, l))) { + c = t.match(L1); for (var g = c.length, G = 1; G < g; ++G) if (c[G] != null && 0 < c[G].length) { B(r), r.g(t.substring(0, l)), t = c[G]; break d; @@ -8309,7 +8310,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt if (g = g.replace(X, ""), c = G1(d, g, l, t, n, o), c == 0) throw C1; } else throw C1; } - if (c != 0 ? (r = t1(c), r != $ && (l = Q(d, c, r))) : (D1(r), t.g(r.toString()), $ != null ? (c = v(l, 10), E( + if (c != 0 ? (r = t1(c), r != $ && (l = Q(d, c, r))) : (M1(r), t.g(r.toString()), $ != null ? (c = v(l, 10), E( o, 1, c @@ -8325,7 +8326,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt return !!((d = typeof d == "string" ? t.match("^(?:" + d + ")$") : t.match(d)) && d[0].length == t.length); } function w2(d) { - this.fa = RegExp(" "), this.ja = "", this.v = new A(), this.da = "", this.s = new A(), this.ba = new A(), this.u = !0, this.ea = this.ca = this.la = !1, this.ga = M.g(), this.$ = 0, this.h = new A(), this.ha = !1, this.o = "", this.g = new A(), this.j = [], this.ka = d, this.l = H1(this, this.ka); + this.fa = RegExp(" "), this.ja = "", this.v = new A(), this.da = "", this.s = new A(), this.ba = new A(), this.u = !0, this.ea = this.ca = this.la = !1, this.ga = D.g(), this.$ = 0, this.h = new A(), this.ha = !1, this.o = "", this.g = new A(), this.j = [], this.ka = d, this.l = H1(this, this.ka); } var V1 = new W(); E(V1, 11, "NA"); @@ -8445,7 +8446,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.formatNumber", (d, t, $) => { try { - const r = M.g(), o = z(r, d, t); + const r = D.g(), o = z(r, d, t); var n = Y(r, o, -1); return n == 0 || n == 4 ? r.format(o, typeof $ > "u" ? 0 : $) : d; } catch { @@ -8453,7 +8454,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.getExampleNumber", (d, t, $, n) => { try { - const g = M.g(); + const g = D.g(); d: { var r = g; if (r1(d)) { @@ -8474,13 +8475,13 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.getExtension", (d, t) => { try { - return p(z(M.g(), d, t), 3); + return p(z(D.g(), d, t), 3); } catch { return ""; } }), e("intlTelInputUtilsTemp.getNumberType", (d, t) => { try { - const l = M.g(), c = z(l, d, t); + const l = D.g(), c = z(l, d, t); var $ = B1(l, c), n = Q(l, v(c, 1), $); if (n == null) var r = -1; else { @@ -8493,14 +8494,14 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.getValidationError", (d, t) => { try { - const $ = M.g(), n = z($, d, t); + const $ = D.g(), n = z($, d, t); return Y($, n, -1); } catch ($) { return $.message === "Invalid country calling code" ? 1 : 3 >= d.length || $.message === "Phone number too short after IDD" || $.message === "The string supplied is too short to be a phone number" ? 2 : $.message === "The string supplied is too long to be a phone number" ? 3 : -99; } }), e("intlTelInputUtilsTemp.isValidNumber", (d, t) => { try { - const g = M.g(); + const g = D.g(); var $ = z(g, d, t), n = B1(g, $); d = g; var r = v($, 1), o = Q(d, r, n); @@ -8515,7 +8516,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.isPossibleNumber", (d, t, $) => { try { - const n = M.g(), r = z(n, d, t); + const n = D.g(), r = z(n, d, t); if ($) { const o = Y(n, r, a1[$]) === 0; if ($ === "FIXED_LINE_OR_MOBILE") { @@ -8530,7 +8531,7 @@ const F2 = (m) => !C.utils && !C.startedLoadingUtilsScript ? (C.startedLoadingUt } }), e("intlTelInputUtilsTemp.getCoreNumber", (d, t) => { try { - return p(z(M.g(), d, t), 2).toString(); + return p(z(D.g(), d, t), 2).toString(); } catch { return ""; } @@ -8562,8 +8563,8 @@ const H2 = { }), emits: /* @__PURE__ */ d2(["changeNumber", "changeCountry", "changeValidity", "changeErrorCode"], ["update:modelValue"]), setup(m, { expose: e, emit: i }) { - const s = A2(m, "modelValue"), u = m, a = i, f = m1(), h = m1(), y = m1(!1), b = () => h.value ? u.options.strictMode ? h.value.isValidNumberPrecise() : h.value.isValidNumber() : null, I = () => { - let _ = b(); + const s = A2(m, "modelValue"), u = m, a = i, f = m1(), h = m1(), y = m1(!1), w = () => h.value ? u.options.strictMode ? h.value.isValidNumberPrecise() : h.value.isValidNumber() : null, I = () => { + let _ = w(); y.value !== _ && (y.value = _, a("changeValidity", !!_), a("changeErrorCode", _ ? null : h.value.getValidationError())); }, S = () => { var _; @@ -8572,21 +8573,21 @@ const H2 = { var _; a("changeCountry", ((_ = h.value) == null ? void 0 : _.getSelectedCountryData().iso2) ?? ""), S(), I(); }; - return L2(() => { + return N2(() => { f.value && (h.value = C(f.value, u.options), u.value && h.value.setNumber(u.value), u.disabled && h.value.setDisabled(u.disabled)); - }), N2( + }), L2( () => u.disabled, (_) => { - var N; - return (N = h.value) == null ? void 0 : N.setDisabled(_); + var L; + return (L = h.value) == null ? void 0 : L.setDisabled(_); } ), E2(() => { var _; return (_ = h.value) == null ? void 0 : _.destroy(); - }), e({ instance: h, input: f }), (_, N) => M2((D2(), x2("input", { + }), e({ instance: h, input: f }), (_, L) => D2((M2(), x2("input", { ref_key: "input", ref: f, - "onUpdate:modelValue": N[0] || (N[0] = (D) => s.value = D), + "onUpdate:modelValue": L[0] || (L[0] = (M) => s.value = M), type: "tel", onCountrychange: T, onInput: S