From 156ca7e1ea812f2b636367d7ec48e84ec84c4945 Mon Sep 17 00:00:00 2001 From: Jack OConnor Date: Wed, 10 Apr 2024 14:59:42 +0100 Subject: [PATCH] Expose react CJS module --- package.json | 1 + react/build.js | 17 +++++++++++++++-- react/build/IntlTelInput.cjs | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 react/build/IntlTelInput.cjs diff --git a/package.json b/package.json index 840e26dfd..117b611b4 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,7 @@ "./data": "./build/js/data.js", "./react": { "types": "./react/build/IntlTelInput.d.ts", + "require": "./react/build/IntlTelInput.cjs", "default": "./react/build/IntlTelInput.js" }, "./*": "./*" diff --git a/react/build.js b/react/build.js index c7ba876c5..f8644c60f 100644 --- a/react/build.js +++ b/react/build.js @@ -3,30 +3,43 @@ const { build } = require("esbuild"); const packageJson = require("../package.json"); -build({ +const mainShared = { bundle: true, entryPoints: ["react/src/intl-tel-input/react.tsx"], external: ["react", "react-dom", "prop-types"], logLevel: "info", minify: true, define: { "process.env.VERSION": `"${packageJson.version}"` }, +}; + +//* React Component - CommonJS +build({ + ...mainShared, + format: "cjs", + outfile: "react/build/IntlTelInput.cjs", +}); + +//* React Component - Default (ES Modules) +build({ + ...mainShared, format: "esm", outfile: "react/build/IntlTelInput.js", }); -//* Demo Files const demoShared = { bundle: true, define: { "process.env.VERSION": `"${packageJson.version}"` }, format: "iife", }; +//* Simple demo app build({ ...demoShared, entryPoints: ["react/demo/SimpleApp.tsx"], outfile: "react/demo/simple-bundle.js", }); +//* Validation demo app build({ ...demoShared, entryPoints: ["react/demo/ValidationApp.tsx"], diff --git a/react/build/IntlTelInput.cjs b/react/build/IntlTelInput.cjs new file mode 100644 index 000000000..bcb68abc8 --- /dev/null +++ b/react/build/IntlTelInput.cjs @@ -0,0 +1 @@ +var N=Object.create;var b=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var P=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},I=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of M(e))!x.call(o,n)&&n!==t&&b(o,n,{get:()=>e[n],enumerable:!(i=A(e,n))||i.enumerable});return o};var H=(o,e,t)=>(t=o!=null?N(k(o)):{},I(e||!o||!o.__esModule?b(t,"default",{value:o,enumerable:!0}):t,o)),U=o=>I(b({},"__esModule",{value:!0}),o);var W={};P(W,{default:()=>V});module.exports=U(W);var m=H(require("react"));var _=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua & Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria","at","43"],["Azerbaijan","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus","by","375"],["Belgium","be","32"],["Belize","bz","501"],["Benin","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia & Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","263","289","306","343","354","365","367","368","382","387","403","416","418","428","431","437","438","450","584","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros","km","269"],["Congo - Brazzaville","cg","242"],["Congo - Kinshasa","cd","243"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["C\xF4te d\u2019Ivoire","ci","225"],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xE7ao","cw","599",0],["Cyprus","cy","357"],["Czech Republic","cz","420"],["Denmark","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands","fk","500"],["Faroe Islands","fo","298"],["Fiji","fj","679"],["Finland","fi","358",0],["France","fr","33"],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49"],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong","hk","852"],["Hungary","hu","36"],["Iceland","is","354"],["India","in","91"],["Indonesia","id","62"],["Iran","ir","98"],["Iraq","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel","il","972"],["Italy","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan","jo","962"],["Kazakhstan","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996"],["Laos","la","856"],["Latvia","lv","371"],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico","mx","52"],["Micronesia","fm","691"],["Moldova","md","373"],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco","ma","212",0],["Mozambique","mz","258"],["Myanmar (Burma)","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31"],["New Caledonia","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea","kp","850"],["North Macedonia","mk","389"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway","no","47",0],["Oman","om","968"],["Pakistan","pk","92"],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63"],["Poland","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar","qa","974"],["R\xE9union","re","262",0],["Romania","ro","40"],["Russia","ru","7",0],["Rwanda","rw","250"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xE3o Tom\xE9 & Pr\xEDncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82"],["South Sudan","ss","211"],["Spain","es","34"],["Sri Lanka","lk","94"],["St Barth\xE9lemy","bl","590",1],["St Helena","sh","290"],["St Kitts & Nevis","kn","1",18,["869"]],["St Lucia","lc","1",19,["758"]],["St Martin","mf","590",2],["St Pierre & Miquelon","pm","508"],["St Vincent & Grenadines","vc","1",20,["784"]],["Sudan","sd","249"],["Suriname","sr","597"],["Svalbard & Jan Mayen","sj","47",1,["79"]],["Sweden","se","46"],["Switzerland","ch","41"],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad & Tobago","tt","1",22,["868"]],["Tunisia","tn","216"],["Turkey","tr","90"],["Turkmenistan","tm","993"],["Turks & Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380"],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["US Virgin Islands","vi","1",24,["340"]],["Uzbekistan","uz","998"],["Vanuatu","vu","678"],["Vatican City","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681"],["Western Sahara","eh","212",1,["5288","5289"]],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["\xC5land Islands","ax","358",1,["18"]]],L=[];for(let o=0;o<_.length;o++){let e=_[o];L[o]={name:e[0],iso2:e[1],dialCode:e[2],priority:e[3]||0,areaCodes:e[4]||null,nodeById:{}}}var y=L;var F=0,S={allowDropdown:!0,autoPlaceholder:"polite",countrySearch:!0,containerClass:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!0,formatAsYouType:!0,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:null,i18n:{},initialCountry:"",nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:[],showFlags:!0,showSelectedDialCode:!1,strictMode:!1,useFullscreenPopup:typeof navigator<"u"&&typeof window<"u"?/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=500:!1,utilsScript:""},R=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],v=o=>o.replace(/\D/g,""),T=(o="")=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),O=(o,e,t)=>{t&&!o.classList.contains(e)?o.classList.add(e):!t&&o.classList.contains(e)&&o.classList.remove(e)},E=o=>{let e=v(o);if(e.charAt(0)==="1"){let t=e.substr(1,3);return R.indexOf(t)!==-1}return!1},B=(o,e)=>o.namee.name?1:0,j=(o,e,t,i)=>{if(t===0&&!i)return 0;let n=0;for(let s=0;s{let i=document.createElement(o);return e&&Object.entries(e).forEach(([n,s])=>i.setAttribute(n,s)),t&&t.appendChild(i),i},f=o=>{let{instances:e}=window.intlTelInputGlobals;Object.values(e).forEach(t=>t[o]())},w=class{id;promise;telInput;activeItem;highlightedItem;options;hadInitialPlaceholder;isRTL;selectedCountryData;countries;dialCodeMaxLen;dialCodeToIso2Map;dialCodes;preferredCountries;countryContainer;selectedCountry;selectedCountryInner;selectedCountryA11yText;selectedDialCode;dropdownArrow;dropdownContent;searchInput;searchResultsA11yText;countryList;dropdown;hiddenInput;hiddenInputCountry;maxCoreNumberLength;defaultCountry;_handleHiddenInputSubmit;_handleLabelClick;_handleClickSelectedCountry;_handleCountryContainerKeydown;_handleInputEvent;_handleKeydownEvent;_handleWindowScroll;_handleMouseoverCountryList;_handleClickCountryList;_handleClickOffToClose;_handleKeydownOnDropdown;_handleSearchChange;resolveAutoCountryPromise;rejectAutoCountryPromise;resolveUtilsScriptPromise;rejectUtilsScriptPromise;constructor(e,t={}){this.id=F++,this.telInput=e,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},S,t),this.hadInitialPlaceholder=!!e.getAttribute("placeholder")}_init(){this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0);let e=this.options.allowDropdown&&!this.options.showSelectedDialCode;!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]");let t=new Promise((n,s)=>{this.resolveAutoCountryPromise=n,this.rejectAutoCountryPromise=s}),i=new Promise((n,s)=>{this.resolveUtilsScriptPromise=n,this.rejectUtilsScriptPromise=s});this.promise=Promise.all([t,i]),this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}_processCountryData(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort(B)}_addToDialCodeMap(e,t,i){t.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=t.length),this.dialCodeToIso2Map.hasOwnProperty(t)||(this.dialCodeToIso2Map[t]=[]);for(let s=0;sn.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)>-1)}else if(t.length){let i=t.map(n=>n.toLowerCase());this.countries=y.filter(n=>i.indexOf(n.iso2)===-1)}else this.countries=y}_translateCountryNames(){for(let e=0;e
`),l+=`${s.name}`,l+=`+${s.dialCode}`,d.insertAdjacentHTML("beforeend",l)}}_setInitialState(e=!1){let t=this.telInput.getAttribute("value"),i=this.telInput.value,s=t&&t.charAt(0)==="+"&&(!i||i.charAt(0)!=="+")?t:i,a=this._getDialCode(s),d=E(s),{initialCountry:l}=this.options;if(a&&!d)this._updateCountryFromNumber(s);else if(l!=="auto"||e){let r=l?l.toLowerCase():"";r&&this._getCountryData(r,!0)?this._setCountry(r):a&&d?this._setCountry("us"):this._setCountry()}s&&this._updateValFromNumber(s)}_initListeners(){this._initTelInputListeners(),this.options.allowDropdown&&this._initDropdownListeners(),(this.hiddenInput||this.hiddenInputCountry)&&this.telInput.form&&this._initHiddenInputListener()}_initHiddenInputListener(){this._handleHiddenInputSubmit=()=>{this.hiddenInput&&(this.hiddenInput.value=this.getNumber()),this.hiddenInputCountry&&(this.hiddenInputCountry.value=this.getSelectedCountryData().iso2||"")},this.telInput.form?.addEventListener("submit",this._handleHiddenInputSubmit)}_initDropdownListeners(){this._handleLabelClick=t=>{this.dropdownContent.classList.contains("iti__hide")?this.telInput.focus():t.preventDefault()};let e=this.telInput.closest("label");e&&e.addEventListener("click",this._handleLabelClick),this._handleClickSelectedCountry=()=>{this.dropdownContent.classList.contains("iti__hide")&&!this.telInput.disabled&&!this.telInput.readOnly&&this._openDropdown()},this.selectedCountry.addEventListener("click",this._handleClickSelectedCountry),this._handleCountryContainerKeydown=t=>{this.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this._openDropdown()),t.key==="Tab"&&this._closeDropdown()},this.countryContainer.addEventListener("keydown",this._handleCountryContainerKeydown)}_initRequests(){this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",()=>{window.intlTelInputGlobals.loadUtils(this.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}_loadAutoCountry(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup((e="")=>{let t=e.toLowerCase();t&&this._getCountryData(t,!0)?(window.intlTelInputGlobals.autoCountry=t,setTimeout(()=>f("handleAutoCountry"))):(this._setInitialState(!0),f("rejectAutoCountryPromise"))},()=>{this._setInitialState(!0),f("rejectAutoCountryPromise")}))}_initTelInputListeners(){let{strictMode:e,formatAsYouType:t}=this.options,i=!1;this._handleInputEvent=n=>{this._updateCountryFromNumber(this.telInput.value)&&this._triggerCountryChange();let s=n&&n.data&&/[^+0-9]/.test(n.data),a=n&&n.inputType==="insertFromPaste"&&this.telInput.value;if(s||a&&!e?i=!0:/[^+0-9]/.test(this.telInput.value)||(i=!1),t&&!i){let d=this.telInput.selectionStart||0,r=this.telInput.value.substring(0,d).replace(/[^+0-9]/g,"").length,c=n&&n.inputType==="deleteContentForward",u=this._formatNumberAsYouType(),h=j(r,u,d,c);this.telInput.value=u,this.telInput.setSelectionRange(h,h)}},this.telInput.addEventListener("input",this._handleInputEvent),e&&(this._handleKeydownEvent=n=>{if(n.key.length===1&&!n.altKey&&!n.ctrlKey&&!n.metaKey){let s=this.telInput.selectionStart===0&&n.key==="+",a=/^[0-9]$/.test(n.key),d=s||a,l=this._getFullNumber(),r=window.intlTelInputUtils.getCoreNumber(l,this.selectedCountryData.iso2),c=this.maxCoreNumberLength&&r.length>=this.maxCoreNumberLength;(!d||c)&&n.preventDefault()}},this.telInput.addEventListener("keydown",this._handleKeydownEvent))}_cap(e){let t=parseInt(this.telInput.getAttribute("maxlength")||"",10);return t&&e.length>t?e.substr(0,t):e}_trigger(e){let t=new Event(e,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(t)}_openDropdown(){let{fixDropdownWidth:e,countrySearch:t}=this.options;if(e&&(this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`),this.dropdownContent.classList.remove("iti__hide"),this.selectedCountry.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&!t)this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0);else{let i=this.countryList.firstElementChild;i&&(this._highlightListItem(i,!1),this.countryList.scrollTop=0),t&&this.searchInput.focus()}this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}_setDropdownPosition(){if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){let e=this.telInput.getBoundingClientRect(),t=document.documentElement.scrollTop,i=e.top+t,n=this.dropdownContent.offsetHeight,s=i+this.telInput.offsetHeight+nt,d=!this.options.countrySearch&&!s&&a;if(O(this.dropdownContent,"iti__dropdown-content--dropup",d),this.options.dropdownContainer){let l=d?0:this.telInput.offsetHeight;this.dropdown.style.top=`${i+l}px`,this.dropdown.style.left=`${e.left+document.body.scrollLeft}px`,this._handleWindowScroll=()=>this._closeDropdown(),window.addEventListener("scroll",this._handleWindowScroll)}}}_bindDropdownListeners(){this._handleMouseoverCountryList=n=>{let s=n.target?.closest(".iti__country");s&&this._highlightListItem(s,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=n=>{let s=n.target?.closest(".iti__country");s&&this._selectListItem(s)},this.countryList.addEventListener("click",this._handleClickCountryList);let e=!0;this._handleClickOffToClose=()=>{e||this._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);let t="",i=null;if(this._handleKeydownOnDropdown=n=>{["ArrowUp","ArrowDown","Enter","Escape"].includes(n.key)&&(n.preventDefault(),n.stopPropagation(),n.key==="ArrowUp"||n.key==="ArrowDown"?this._handleUpDownKey(n.key):n.key==="Enter"?this._handleEnterKey():n.key==="Escape"&&this._closeDropdown()),!this.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(n.key)&&(n.stopPropagation(),i&&clearTimeout(i),t+=n.key.toLowerCase(),this._searchForCountry(t),i=setTimeout(()=>{t=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){let n=()=>{let a=this.searchInput.value.trim();a?this._filterCountries(a):this._filterCountries("",!0)},s=null;this._handleSearchChange=()=>{s&&clearTimeout(s),s=setTimeout(()=>{n(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",a=>a.stopPropagation())}}_filterCountries(e,t=!1){let i=!0;this.countryList.innerHTML="";let n=T(e);for(let s=0;s1&&(t=e==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),t){this._scrollTo(t,!1);let i=!this.options.countrySearch;this._highlightListItem(t,i)}}_handleEnterKey(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}_searchForCountry(e){for(let t=0;td){t&&(u+=h);let C=s-l;i.scrollTop=u-C}}_updateDialCode(e){let t=this.telInput.value,i=`+${e}`,n;if(t.charAt(0)==="+"){let s=this._getDialCode(t);s?n=t.replace(s,i):n=i,this.telInput.value=n}}_getDialCode(e,t){let i="";if(e.charAt(0)==="+"){let n="";for(let s=0;s{let i=document.createElement("script");i.onload=()=>{f("handleUtils"),e&&e()},i.onerror=()=>{f("rejectUtilsScriptPromise"),t&&t()},i.className="iti-load-utils",i.async=!0,i.src=o,document.body.appendChild(i)},$=o=>!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript?(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,new Promise((e,t)=>z(o,e,t))):null;if(typeof window=="object"){let o={defaults:S,documentReady:()=>document.readyState==="complete",getCountryData:()=>y,getInstance:e=>{let t=e.getAttribute("data-intl-tel-input-id");return t?o.instances[t]:null},instances:{},loadUtils:$,version:"21.1.1"};window.intlTelInputGlobals=o}var G=(o,e)=>{let t=new w(o,e);return t._init(),o.setAttribute("data-intl-tel-input-id",t.id.toString()),window.intlTelInputGlobals.instances[t.id]=t,t},D=G;var K=({initialValue:o="",onChangeNumber:e=()=>{},onChangeCountry:t=()=>{},onChangeValidity:i=()=>{},onChangeErrorCode:n=()=>{},usePreciseValidation:s=!1,initOptions:a={},inputProps:d={}})=>{let l=(0,m.useRef)(null),r=(0,m.useRef)(null),c=()=>{let u=r.current?.getNumber()||"",h=r.current?.getSelectedCountryData().iso2||"";if(e(u),t(h),r.current)if(s?r.current.isValidNumberPrecise():r.current.isValidNumber())i(!0),n(null);else{let g=r.current.getValidationError();i(!1),n(g)}};return(0,m.useEffect)(()=>{let u=l.current;return u&&(r.current=D(u,a),u.addEventListener("countrychange",c)),()=>{u&&u.removeEventListener("countrychange",c),r.current?.destroy()}},[]),m.default.createElement("input",{type:"tel",ref:l,onInput:c,defaultValue:o,...d})},V=K;