@desource/phone-mask-react 0.3.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/README.md +51 -23
- package/dist/esm/components/PhoneInput.d.ts +2 -9
- package/dist/esm/components/PhoneInput.d.ts.map +1 -1
- package/dist/esm/hooks/internal/useCopyAction.d.ts +14 -0
- package/dist/esm/hooks/internal/useCopyAction.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useCountry.d.ts +21 -0
- package/dist/esm/hooks/internal/useCountry.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useCountrySelector.d.ts +32 -0
- package/dist/esm/hooks/internal/useCountrySelector.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useFormatter.d.ts +45 -0
- package/dist/esm/hooks/internal/useFormatter.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useInputHandlers.d.ts +21 -0
- package/dist/esm/hooks/internal/useInputHandlers.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useTheme.d.ts +9 -0
- package/dist/esm/hooks/internal/useTheme.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useValidationHint.d.ts +6 -0
- package/dist/esm/hooks/internal/useValidationHint.d.ts.map +1 -0
- package/dist/esm/hooks/usePhoneMask.d.ts +2 -1
- package/dist/esm/hooks/usePhoneMask.d.ts.map +1 -1
- package/dist/esm/hooks/utility/useClipboard.d.ts +6 -0
- package/dist/esm/hooks/utility/useClipboard.d.ts.map +1 -0
- package/dist/esm/hooks/utility/useTimer.d.ts +9 -0
- package/dist/esm/hooks/utility/useTimer.d.ts.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +751 -705
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +18 -20
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/phone-mask-react.cjs +1 -1
- package/dist/phone-mask-react.cjs.map +1 -1
- package/dist/phone-mask-react.css +1 -1
- package/package.json +13 -11
- package/dist/esm/consts.d.ts +0 -4
- package/dist/esm/consts.d.ts.map +0 -1
- package/dist/esm/utils.d.ts +0 -16
- package/dist/esm/utils.d.ts.map +0 -1
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),i=require("react"),yt=require("react-dom"),wt={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},Dt=/^[a-z]{2}$/i,de=e=>{if(!Dt.test(e)){const t=typeof e;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${t==="string"?e:t}' instead.`)}const r=[...e.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...r)},q=Object.entries(wt),_e=e=>e.split(/ (.*)/s);function te(e){let r="",t="";if(Array.isArray(e)){const s=[];for(const p of e){const[l,w]=_e(p);r||(r=l),s.push(w)}t=s}else{const[s,p]=_e(e);r=s,t=p}return[r,t]}q.map(([e,r])=>({id:e,mask:r}));q.reduce((e,[r,t])=>{const[s,p]=te(t);return e[r]={code:s,mask:p},e},{});q.map(([e,r])=>{const[t,s]=te(r);return{id:e,code:t,mask:s}});q.reduce((e,[r,t])=>{const[s,p]=te(t);return e[r]={code:s,mask:p,flag:de(r)},e},{});q.map(([e,r])=>{const[t,s]=te(r);return{id:e,code:t,mask:s,flag:de(e)}});const vt=e=>{const r=new Intl.DisplayNames([e],{type:"region"});return q.reduce((t,[s,p])=>{const[l,w]=te(p),f=r.of(s)??"";return t[s]={code:l,mask:w,name:f,flag:de(s)},t},{})},Tt=q.reduce((e,[r,t])=>{const[s,p]=te(t),l=new Intl.DisplayNames(["en"],{type:"region"});return e[r]={code:s,mask:p,name:l.of(r)??"",flag:de(r)},e},{});q.map(([e,r])=>{const[t,s]=te(r);return{id:e,code:t,mask:s,name:new Intl.DisplayNames(["en"],{type:"region"}).of(e)??"",flag:de(e)}});const kt=de;function be(){return typeof navigator<"u"&&navigator.language||"en"}function ze(e){return e.toLowerCase().startsWith("en")?Tt:vt(e)}function $(e,r){const t=ze(r),s=e.toUpperCase();return s in t?{id:s,...t[s]}:{id:"US",...t.US}}function Xe(e){return Array.isArray(e)?e:[e]}function Ae(e){return(e.match(/#/g)||[]).length}function Ne(e){return e.replace(/^\+\d+\s?/,"")}function qe(e,r){if(e.length===1)return e[0];const t=e.map(l=>({mask:l,count:Ae(l)})),s=t.filter(l=>l.count>=r).sort((l,w)=>l.count-w.count);if(s.length>0)return s[0].mask;const p=t.sort((l,w)=>w.count-l.count)[0];return p?p.mask:e[0]}function Se(e,r){let t="";const s=[];let p=0;const l=r.length,w=e.length;for(let f=0;f<w;f++){const S=e[f];if(S==="#"){if(!(p<l))break;t+=r[p],s.push(p),p++}else{const T=e.indexOf("#",f+1)!==-1&&p<l;(t.length>0||T)&&(t+=S,s.push(-1))}}return{display:t,map:s}}const St="https://ipapi.co/json/",bt=1500,Re="@desource/phone-mask:geo",Mt=864e5;async function Qe(e=St,r=bt){const t=new AbortController,s=setTimeout(()=>t.abort(),r);try{const p=await fetch(e,{signal:t.signal,headers:{Accept:"application/json"}});if(clearTimeout(s),!p.ok)return null;const l=await p.json();return(l.country||l.country_code||l.countryCode||l.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(s),null}}async function xt(e){try{const t=localStorage.getItem(Re);if(t){const s=JSON.parse(t),p=Date.now()-s.ts>Mt;if(!p&&s.country_code&&e(s.country_code))return s.country_code.toUpperCase();p&&localStorage.removeItem(Re)}}catch{}const r=await Qe();if(r&&e(r)){try{localStorage.setItem(Re,JSON.stringify({country_code:r,ts:Date.now()}))}catch{}return r}return null}function Ie(e){const r=Xe(e.mask),t=r.map(l=>Ae(Ne(l))),s=Math.max(...t),p=l=>{const w=qe(r,l);return Ne(w)};return{formatDisplay:l=>{const w=p(l.length);return Se(w,l).display},getMaxDigits:()=>s,getPlaceholder:()=>p(0),getCaretPosition:l=>{const w=p(l),{display:f,map:S}=Se(w,"0".repeat(l));for(let T=0;T<S.length;T++)if(S[T]===l)return T;if(l>=S.length)return f.length;for(let T=0;T<S.length;T++)if(S[T]>l)return T;return f.length},getDigitRange:(l,w,f)=>{const S=p(l.length),{map:T}=Se(S,l);let U=1/0,W=-1/0;for(let H=w;H<f&&H<T.length;H++){const Z=T[H];Z!==void 0&&Z>=0&&(U=Math.min(U,Z),W=Math.max(W,Z))}return U===1/0?null:[U,W+1]},isComplete:l=>t.includes(l.length)}}function N(e,r){if(e)try{e.setSelectionRange(r,r)}catch{}}function O(e,r){const t=e.replace(/\D/g,"");return r?t.slice(0,r):t}function Me(e){return e?[e.selectionStart??0,e.selectionEnd??0]:[0,0]}const et=[" ","-","(",")"],tt=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],nt=/[^\d\s\-()]/;function Lt(e){const r=ze(e);return Object.entries(r).map(([t,s])=>({id:t,...s}))}const rt=({ref:e,...r})=>{const{value:t="",country:s,detect:p=!0,locale:l,size:w="normal",theme:f="auto",disabled:S=!1,readonly:T=!1,showCopy:U=!0,showClear:W=!1,withValidity:H=!0,searchPlaceholder:Z="Search country or code...",noResultsText:we="No countries found",clearButtonLabel:ne="Clear phone number",dropdownClass:De="",disableDefaultStyles:ve=!1,onChange:Y,onPhoneChange:J,onCountryChange:o,onValidationChange:h,onFocus:y,onBlur:b,onCopy:k,onClear:D,renderActionsBefore:P,renderFlag:L,renderCopySvg:A,renderClearSvg:re}=r,B=i.useRef(null),fe=i.useRef(null),_=i.useRef(null),pe=i.useRef(null),ge=i.useRef(null),Te=i.useRef(null),j=l||be(),[R,oe]=i.useState(()=>$(s||"US",j)),[m,F]=i.useState(""),[z,Be]=i.useState(!1),[ot,xe]=i.useState(!1),[Le,je]=i.useState(""),[me,se]=i.useState(0),[he,Fe]=i.useState(!1),[Ue,He]=i.useState(!1),[st,it]=i.useState({}),[at,X]=i.useState(!1),M=i.useRef(null),Q=i.useRef(null),ie=i.useRef(null),[Ce,ct]=i.useState(!s),v=i.useMemo(()=>Ie(R),[R]),ae=i.useMemo(()=>Lt(j),[j]),Ee=v.formatDisplay(m),lt=v.getPlaceholder(),ee=v.isComplete(m),Pe=m.length===0,Ge=at&&!Pe&&!ee,ke=`${R.code}${m}`,ce=m?`${R.code} ${Ee}`:"",le=i.useMemo(()=>{const n=Le.trim();if(!n)return ae;const a=n.toUpperCase(),u=a.replace(/\D/g,""),g=u.length>0;return ae.map(c=>{const d=c.name.toUpperCase(),x=c.id.toUpperCase(),E=c.code.toUpperCase(),V=c.code.replace(/\D/g,"");let I=0;return d.startsWith(a)?I=1e3:d.includes(a)&&(I=500),E.startsWith(a)?I+=100:E.includes(a)&&(I+=50),x===a?I+=200:x.startsWith(a)&&(I+=150),g&&V.startsWith(u)?I+=80:g&&V.includes(u)&&(I+=40),{country:c,score:I}}).filter(c=>c.score>0).sort((c,d)=>d.score!==c.score?d.score-c.score:c.country.name.localeCompare(d.country.name)).map(c=>c.country)},[ae,Le]),G=S||T,$e=U&&!Pe&&!S,Ke=W&&!Pe&&!G;i.useEffect(()=>{ct(!s&&ae.length>1);const n=u=>{if(!u)return!1;const g=u.toUpperCase();return ae.some(c=>c.id===g)},a=()=>{const u=typeof navigator<"u"&&navigator.language?navigator.language:"";try{if(Intl.Locale){const c=new Intl.Locale(u);if(c?.region&&n(c.region))return c.region.toUpperCase()}}catch{}const g=u.split(/[-_]/);return g.length>1&&n(g[1])?g[1].toUpperCase():null};(async()=>{if(s&&n(s)){const c=$(s,j);oe(d=>d.id===c.id?d:(o?.(c),c));return}if(!p)return;const u=await xt(n);if(u){const c=$(u,j);oe(d=>d.id===c.id?d:(o?.(c),c));return}const g=a();if(g){const c=$(g,j);oe(d=>d.id===c.id?d:(o?.(c),c))}})()},[s,p,ae,j]),i.useEffect(()=>{const n=v.getMaxDigits();m.length>n&&F(a=>a.slice(0,n))},[v]),i.useEffect(()=>{const n=O(t||"");n!==m&&F(n)},[t]),i.useEffect(()=>{h?.(ee)},[ee,h]);const Ve=i.useCallback(()=>{Y?.(m),J?.({full:ke,fullFormatted:ce,digits:m})},[m,ke,ce,Y,J]);i.useEffect(()=>{Ve()},[Ve]);const Oe=i.useCallback(n=>{const a=n.data;if(n.inputType!=="insertText"||!a)return;const u=B.current;u&&(nt.test(a)||a===" "&&u.value.endsWith(" "))&&n.preventDefault()},[]),ut=i.useCallback(()=>{const n=B.current;if(!n||G)return;const a=n.value||"",u=v.getMaxDigits(),g=O(a,u);F(g),setTimeout(()=>{const c=v.getCaretPosition(g.length);N(n,c)},0),X(!1),M.current&&clearTimeout(M.current),g.length>0&&(M.current=setTimeout(()=>{X(!0)},500))},[v,G]),We=i.useCallback(n=>{if(G)return;const a=B.current;if(!a||n.ctrlKey||n.metaKey||n.altKey||tt.includes(n.key))return;const[u,g]=Me(a);X(!1),M.current&&clearTimeout(M.current);const c=()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{X(!0)},300)};if(n.key==="Backspace"){if(n.preventDefault(),u!==g){const d=v.getDigitRange(m,u,g);if(d){const[x,E]=d;F(m.slice(0,x)+m.slice(E)),setTimeout(()=>N(a,v.getCaretPosition(x)),0)}}else if(u>0){let d=u-1;for(;d>=0&&et.includes(a.value[d]);)d--;if(d>=0){const x=v.getDigitRange(m,d,d+1);if(x){const[E]=x;F(m.slice(0,E)+m.slice(E+1)),setTimeout(()=>N(a,v.getCaretPosition(E)),0)}}}c();return}if(n.key==="Delete"){if(n.preventDefault(),u!==g){const d=v.getDigitRange(m,u,g);if(d){const[x,E]=d;F(m.slice(0,x)+m.slice(E)),setTimeout(()=>N(a,v.getCaretPosition(x)),0)}}else if(u<a.value.length){const d=v.getDigitRange(m,u,u+1);if(d){const[x]=d;F(m.slice(0,x)+m.slice(x+1)),setTimeout(()=>N(a,v.getCaretPosition(x)),0)}}c();return}if(/^[0-9]$/.test(n.key)){m.length>=v.getMaxDigits()&&n.preventDefault(),c();return}n.key.length===1&&n.preventDefault(),c()},[G,v,m]),Ze=i.useCallback(n=>{if(G)return;n.preventDefault();const a=B.current;if(!a)return;const u=n.clipboardData?.getData("text")||"",g=v.getMaxDigits(),c=O(u,g);if(!c)return;const[d,x]=Me(a);if(d!==x){const E=v.getDigitRange(m,d,x);if(E){const[V,I]=E,Ct=O(m.slice(0,V)+c+m.slice(I),g);F(Ct),setTimeout(()=>N(a,v.getCaretPosition(V+c.length)),0)}}else{const E=v.getDigitRange(m,d,d),V=E?E[0]:m.length,I=O(m.slice(0,V)+c+m.slice(V),g);F(I),setTimeout(()=>N(a,v.getCaretPosition(V+c.length)),0)}X(!1),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{X(!0)},300)},[G,v,m]),K=i.useCallback(()=>{z&&(xe(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{Be(!1),xe(!1)},200))},[z]),dt=i.useCallback(n=>{M.current&&clearTimeout(M.current),K(),y?.(n)},[y,K]);i.useEffect(()=>{const n=B.current;if(!n)return;const a=Oe,u=We,g=Ze;return n.addEventListener("beforeinput",a),n.addEventListener("keydown",u),n.addEventListener("paste",g),()=>{n.removeEventListener("beforeinput",a),n.removeEventListener("keydown",u),n.removeEventListener("paste",g)}},[Oe,We,Ze]);const ye=i.useCallback(n=>{const a=$(n,j);oe(a),K(),je(""),se(0),o?.(a),setTimeout(()=>B.current?.focus(),0)},[j,o,K]),ue=i.useCallback(()=>{if(!fe.current)return;const n=fe.current.getBoundingClientRect();it({top:`${n.bottom+window.scrollY+8}px`,left:`${n.left+window.scrollX}px`,width:`${n.width}px`})},[]);i.useEffect(()=>{if(!z)return;ue();const n=setTimeout(()=>pe.current?.focus({preventScroll:!0}),0),a=u=>{const g=u.target,c=_.current,d=Te.current;g&&(c?.contains(g)||d?.contains(g)||K())};return window.addEventListener("resize",ue),window.addEventListener("scroll",ue,!0),window.addEventListener("click",a,!0),()=>{clearTimeout(n),window.removeEventListener("resize",ue),window.removeEventListener("scroll",ue,!0),window.removeEventListener("click",a,!0)}},[z,ue,K]),i.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current),ie.current&&clearTimeout(ie.current),M.current&&clearTimeout(M.current)},[]);const ft=i.useCallback(async()=>{if(Ue)return;const n=ce.trim();if(n){He(!0);try{await navigator.clipboard.writeText(n),Fe(!0),k?.(n),ge.current&&(ge.current.textContent="Phone number copied to clipboard"),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{Fe(!1),ie.current=null},1800)}catch(a){console.warn("Copy failed",a)}finally{He(!1)}}},[ce,k,Ue]),pt=i.useCallback(()=>{F(""),X(!1),M.current&&clearTimeout(M.current),Y?.(""),J?.({full:"",fullFormatted:"",digits:""}),D?.(),setTimeout(()=>B.current?.focus(),0)},[Y,J,D]);i.useImperativeHandle(e,()=>({focus:()=>B.current?.focus(),blur:()=>B.current?.blur(),clear:()=>{F(""),X(!1),M.current&&clearTimeout(M.current),Y?.(""),J?.({full:"",fullFormatted:"",digits:""}),D?.()},selectCountry:ye,getFullNumber:()=>ke,getFullFormattedNumber:()=>ce,getDigits:()=>m,isValid:()=>ee,isComplete:()=>ee}),[ye,ke,ce,m,ee,D,Y,J]);const Ye=n=>{setTimeout(()=>{const a=_.current?.lastElementChild,u=a?.children[n];if(!a||!u)return;const g=a.getBoundingClientRect(),c=u.getBoundingClientRect();let d=0;if(c.top<g.top)d=a.scrollTop-(g.top-c.top);else if(c.bottom>g.bottom)d=a.scrollTop+(c.bottom-g.bottom);else return;a.scrollTo({top:d,behavior:"smooth"})},0)},gt=i.useCallback(n=>{n.key==="ArrowDown"?(n.preventDefault(),se(a=>{const u=Math.min(a+1,le.length-1);return Ye(u),u})):n.key==="ArrowUp"?(n.preventDefault(),se(a=>{const u=Math.max(a-1,0);return Ye(u),u})):n.key==="Enter"&&le[me]?(n.preventDefault(),ye(le[me].id)):n.key==="Escape"&&K()},[le,me,ye,K]),Je=i.useMemo(()=>f!=="auto"?`theme-${f}`:typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"theme-dark":"theme-light",[f]),mt=["phone-input",`size-${w}`,Je,S&&"is-disabled",T&&"is-readonly",ve&&"is-unstyled",H&&Ge&&"is-incomplete",H&&ee&&"is-complete"].filter(Boolean).join(" "),ht=+$e+ +Ke+(P?1:0);return C.jsxs(C.Fragment,{children:[C.jsxs("div",{ref:fe,className:mt,style:{"--pi-actions-count":ht},role:"group","aria-label":"Phone input with country selector",children:[C.jsx("div",{className:"pi-selector",ref:Te,children:C.jsxs("button",{type:"button",className:`pi-selector-btn ${!Ce||T?"no-dropdown":""}`,disabled:S,tabIndex:G||!Ce?-1:void 0,"aria-label":`Selected country: ${R.name}`,"aria-expanded":z,"aria-haspopup":Ce?"listbox":void 0,onClick:()=>{G||!Ce||(z?K():(Q.current&&clearTimeout(Q.current),xe(!1),Be(!0),se(0)))},children:[C.jsx("span",{className:"pi-flag",role:"img","aria-label":`${R.name} flag`,children:L?L(R):R.flag}),C.jsx("span",{className:"pi-code",children:R.code}),!G&&Ce&&C.jsx("svg",{className:`pi-chevron ${z?"is-open":""}`,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:C.jsx("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),C.jsxs("div",{className:"pi-input-wrap",children:[C.jsx("input",{ref:B,type:"tel",inputMode:"tel",autoComplete:"tel-national",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:"pi-input",placeholder:lt,value:Ee,disabled:S,readOnly:T,"aria-invalid":Ge,onInput:ut,onFocus:dt,onBlur:b}),C.jsxs("div",{className:"pi-actions",role:"toolbar","aria-label":"Phone input actions",children:[P&&P(),$e&&C.jsx("button",{type:"button",className:`pi-btn ${he?"is-copied":""}`,"aria-label":he?"Copied":`Copy ${R.code} ${Ee}`,title:he?"Copied":"Copy phone number",onClick:ft,children:A?A(he):he?C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:C.jsx("path",{d:"M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z",fill:"currentColor"})}):C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:C.jsx("path",{d:"M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z",fill:"currentColor"})})}),Ke&&C.jsx("button",{type:"button",className:"pi-btn","aria-label":ne,title:ne,onClick:pt,children:re?re():C.jsx("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:C.jsx("path",{d:"M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z",fill:"currentColor"})})})]})]})]}),z&&typeof document<"u"&&yt.createPortal(C.jsxs("div",{ref:_,className:`phone-dropdown ${De} ${Je} ${ot?"is-closing":""}`,style:st,role:"dialog","aria-modal":"false","aria-label":"Select country",children:[C.jsx("div",{className:"pi-search-wrap",children:C.jsx("input",{ref:pe,type:"search",className:"pi-search","aria-label":"Search countries",placeholder:Z,value:Le,onChange:n=>{je(n.target.value),se(0)},onKeyDown:gt})}),C.jsx("ul",{className:"pi-options",role:"listbox","aria-activedescendant":`option-${me}`,tabIndex:-1,children:le.length>0?le.map((n,a)=>C.jsxs("li",{id:`option-${a}`,role:"option",className:`pi-option ${a===me?"is-focused":""} ${n.id===R.id?"is-selected":""}`,"aria-selected":n.id===R.id,title:n.name,onClick:()=>ye(n.id),onMouseEnter:()=>se(a),children:[C.jsx("span",{className:"pi-flag",role:"img","aria-label":`${n.name} flag`,children:L?L(n):n.flag}),C.jsx("span",{className:"pi-opt-name",children:n.name}),C.jsx("span",{className:"pi-opt-code",children:n.code})]},n.id)):C.jsx("li",{className:"pi-empty",children:we})})]}),document.body),C.jsx("div",{ref:ge,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"})]})};rt.displayName="PhoneInput";function Et(){try{const e=be();try{const t=new Intl.Locale(e);if(t.region)return t.region.toUpperCase()}catch{}const r=e.split(/[-_]/);if(r.length>1)return r[1]?.toUpperCase()||null}catch{}return null}function Pt(e={}){const r=i.useRef(null),[t,s]=i.useState(""),[p,l]=i.useState(()=>{const o=e.locale||be();return $(e.country||"US",o)}),w=e.locale||be(),f=Ie(p),S=f.formatDisplay(t),T=`${p.code}${t}`,U=t?`${p.code} ${S}`:"",W=f.isComplete(t),H=t.length===0,Z=!H&&!W;i.useEffect(()=>{e.detect&&(async()=>{const o=await Qe();if(o){const y=$(o,w);l(y),e.onCountryChange?.(y);return}const h=Et();if(h){const y=$(h,w);l(y),e.onCountryChange?.(y)}})()},[e.detect]),i.useEffect(()=>{if(e.country){const o=$(e.country,w);o.id!==p.id&&(l(o),e.onCountryChange?.(o))}},[e.country,w]),i.useEffect(()=>{const o=r.current;o&&(o.value=S,o.placeholder=f.getPlaceholder())},[S,f]),i.useEffect(()=>{if(e.onChange){const o={full:T,fullFormatted:U,digits:t};e.onChange(o)}},[t,T,U]);const we=i.useCallback(o=>{const h=o.data;if(o.inputType!=="insertText"||!h)return;const y=r.current;y&&(nt.test(h)||h===" "&&y.value.endsWith(" "))&&o.preventDefault()},[]),ne=i.useCallback(()=>{const o=r.current;if(!o)return;const h=o.value||"",y=f.getMaxDigits(),b=O(h,y);s(b),setTimeout(()=>{const k=f.getCaretPosition(b.length);N(o,k)},0)},[f]),De=i.useCallback(o=>{const h=r.current;if(!h||o.ctrlKey||o.metaKey||o.altKey||tt.includes(o.key))return;const[y,b]=Me(h);if(o.key==="Backspace"){if(o.preventDefault(),y!==b){const k=f.getDigitRange(t,y,b);if(k){const[D,P]=k,L=t.slice(0,D)+t.slice(P);s(L),setTimeout(()=>{const A=f.getCaretPosition(D);N(h,A)},0)}return}if(y>0){const k=h.value;let D=y-1;for(;D>=0&&et.includes(k[D]);)D--;if(D>=0){const P=f.getDigitRange(t,D,D+1);if(P){const[L]=P,A=t.slice(0,L)+t.slice(L+1);s(A),setTimeout(()=>{const re=f.getCaretPosition(L);N(h,re)},0)}}}return}if(o.key==="Delete"){if(o.preventDefault(),y!==b){const k=f.getDigitRange(t,y,b);if(k){const[D,P]=k,L=t.slice(0,D)+t.slice(P);s(L),setTimeout(()=>{const A=f.getCaretPosition(D);N(h,A)},0)}return}if(y<h.value.length){const k=f.getDigitRange(t,y,y+1);if(k){const[D]=k,P=t.slice(0,D)+t.slice(D+1);s(P),setTimeout(()=>{const L=f.getCaretPosition(D);N(h,L)},0)}}return}if(/^[0-9]$/.test(o.key)){t.length>=f.getMaxDigits()&&o.preventDefault();return}o.key.length===1&&o.preventDefault()},[t,f]),ve=i.useCallback(o=>{o.preventDefault();const h=r.current;if(!h)return;const y=o.clipboardData?.getData("text")||"",b=f.getMaxDigits(),k=O(y,b);if(k.length===0)return;const[D,P]=Me(h);if(D!==P){const _=f.getDigitRange(t,D,P);if(_){const[pe,ge]=_,Te=t.slice(0,pe),j=t.slice(ge),R=O(Te+k+j,b);s(R),setTimeout(()=>{const oe=f.getCaretPosition(pe+k.length);N(h,oe)},0);return}}const L=f.getDigitRange(t,D,D),A=L?L[0]:t.length,re=t.slice(0,A),B=t.slice(A),fe=O(re+k+B,b);s(fe),setTimeout(()=>{const _=f.getCaretPosition(A+k.length);N(h,_)},0)},[t,f]);i.useEffect(()=>{const o=r.current;if(!o)return;o.setAttribute("type","tel"),o.setAttribute("inputmode","tel"),o.setAttribute("placeholder",f.getPlaceholder());const h=we,y=De,b=ve;return o.addEventListener("beforeinput",h),o.addEventListener("input",ne),o.addEventListener("keydown",y),o.addEventListener("paste",b),()=>{o.removeEventListener("beforeinput",h),o.removeEventListener("input",ne),o.removeEventListener("keydown",y),o.removeEventListener("paste",b)}},[we,ne,De,ve,f]);const Y=i.useCallback(o=>{const h=$(o,w);l(h);const b=Ie(h).getMaxDigits();t.length>b&&s(t.slice(0,b)),e.onCountryChange?.(h)},[w,t,e]),J=i.useCallback(()=>{s("");const o=r.current;o&&(o.value="")},[]);return{ref:r,digits:t,full:T,fullFormatted:U,isComplete:W,isEmpty:H,shouldShowWarn:Z,country:p,setCountry:Y,clear:J}}const Rt={getFlagEmoji:kt,countPlaceholders:Ae,formatDigitsWithMap:Se,pickMaskVariant:qe,removeCountryCodePrefix:Ne,toArray:Xe};exports.PMaskHelpers=Rt;exports.PhoneInput=rt;exports.usePhoneMask=Pt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),a=require("react"),ft=require("react-dom"),ht={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 # ## ## ## ##","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 # ## ## ## ##","+212 ##-#######"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},gt=/^[a-z]{2}$/i,W=e=>{if(!gt.test(e)){const n=typeof e;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${n==="string"?e:n}' instead.`)}const t=[...e.toUpperCase()].map(n=>(n.codePointAt(0)??0)+127397);return String.fromCodePoint(...t)},pe="en",F=new Map,Pe=e=>{const t=e.toLowerCase(),n=F.get(t);if(n)return n;const r=new Intl.DisplayNames([e],{type:"region"});if(F.size>=10){for(const s of F.keys())if(s!==pe){F.delete(s);break}}return F.set(t,r),r},B=Object.entries(ht),Le=e=>e.split(/ (.*)/s);function j(e){let t="",n="";if(Array.isArray(e)){const r=[];for(const s of e){const[o,c]=Le(s);t||(t=o),r.push(c)}n=r}else{const[r,s]=Le(e);t=r,n=s}return[t,n]}B.map(([e,t])=>({id:e,mask:t}));B.reduce((e,[t,n])=>{const[r,s]=j(n);return e[t]={code:r,mask:s},e},{});B.map(([e,t])=>{const[n,r]=j(t);return{id:e,code:n,mask:r}});B.reduce((e,[t,n])=>{const[r,s]=j(n);return e[t]={code:r,mask:s,flag:W(t)},e},{});B.map(([e,t])=>{const[n,r]=j(t);return{id:e,code:n,mask:r,flag:W(e)}});const Re=e=>{const t=Pe(e);return B.reduce((n,[r,s])=>{const[o,c]=j(s),i=t.of(r)??"";return n[r]={code:o,mask:c,name:i,flag:W(r)},n},{})},Be=e=>{const t=Pe(e);return B.map(([n,r])=>{const[s,o]=j(r);return{id:n,code:s,mask:o,name:t.of(n)??"",flag:W(n)}})},mt=Re(pe);Be(pe);const Ct=W;function He(){return globalThis.navigator?.language||"en"}function yt(){try{const e=He();try{const n=new Intl.Locale(e);if(n.region)return n.region.toUpperCase()}catch{}const t=e.split(/[-_]/);if(t.length>1)return t[1]?.toUpperCase()||null}catch{}return null}function bt(e){const t=mt;return e.toUpperCase()in t}function Dt(e,t){const n=Re(t),r=e.toUpperCase();return r in n?{id:r,...n[r]}:{id:"US",...n.US}}function te(e,t){return e&&bt(e)?e.toUpperCase():t||""}function je(e){return Array.isArray(e)?e:[e]}function fe(e){return(e.match(/#/g)||[]).length}function ue(e){return e.replace(/^\+\d+\s?/,"")}function Ve(e,t){if(!e.length)return"";if(e.length===1)return e[0];const n=e.map(o=>({mask:o,count:fe(o)})),r=n.filter(o=>o.count>=t).sort((o,c)=>o.count-c.count);if(r.length>0)return r[0].mask;const s=n.sort((o,c)=>c.count-o.count)[0];return s?s.mask:e[0]}function ee(e,t){let n="";const r=[];let s=0;const o=t.length,c=e.length;for(let i=0;i<c;i++){const h=e[i];if(h==="#"){if(!(s<o))break;n+=t[s],r.push(s),s++}else{const l=e.indexOf("#",i+1)!==-1&&s<o;(n.length>0||l)&&(n+=h,r.push(-1))}}return{display:n,map:r}}function vt(e,t){const n=t.trim().toUpperCase();if(!n)return e;const r=n.replace(/\D/g,""),s=r.length>0;return e.map(o=>{const c=o.name.toUpperCase(),i=o.id.toUpperCase(),h=o.code.toUpperCase(),l=o.code.replace(/\D/g,"");let d=0;return c.startsWith(n)?d=1e3:c.includes(n)&&(d=500),h.startsWith(n)?d+=100:h.includes(n)&&(d+=50),i===n?d+=200:i.startsWith(n)&&(d+=150),s&&l.startsWith(r)?d+=80:s&&l.includes(r)&&(d+=40),{country:o,score:d}}).filter(o=>o.score>0).sort((o,c)=>c.score===o.score?o.country.name.localeCompare(c.country.name):c.score-o.score).map(o=>o.country)}const kt=[" ","-","(",")"],wt=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],Mt=/[^\d\s\-()]/;function de(e,t,n){return{newDigits:e.slice(0,t)+e.slice(n),caretDigitIndex:t}}function Te(e,t,n,r){if(n===r)return;const s=t.getDigitRange(e,n,r);if(!s)return;const[o,c]=s;return de(e,o,c)}function U(e,t){const n=e.replace(/\D/g,"");return t?n.slice(0,t):n}function $e(e){return e?[e.selectionStart??0,e.selectionEnd??0]:[0,0]}function St(e,t){if(e)try{e.setSelectionRange(t,t)}catch{}}function xt(e){if(!e.target)return;const t=e.target,n=e.data;e.inputType==="insertText"&&n&&(Mt.test(n)||n===" "&&t.value.endsWith(" "))&&e.preventDefault()}function Et(e,t){if(!e.target)return;const n=e.target,{formatter:r}=t,s=r.getMaxDigits(),o=U(n.value,s);return{newDigits:o,caretDigitIndex:o.length}}function It(e,t){if(!e.target)return;const n=e.target,{digits:r,formatter:s}=t;if((function(l){return l.ctrlKey||l.metaKey||l.altKey||wt.includes(l.key)})(e))return;const[o,c]=$e(n),i=n.value;return e.key==="Backspace"?(e.preventDefault(),Te(r,s,o,c)??(function(l,d,u,p){if(p<=0)return;let f=p-1;for(;f>=0&&kt.includes(u[f]);)f--;if(f<0)return;const b=d.getDigitRange(l,f,f+1);if(!b)return;const[D]=b;return de(l,D,D+1)})(r,s,i,o)):e.key==="Delete"?(e.preventDefault(),Te(r,s,o,c)??(function(l,d,u,p){if(p>=u.length)return;const f=d.getDigitRange(l,p,u.length);if(!f)return;const[b]=f;return de(l,b,b+1)})(r,s,i,o)):void(/^\d$/.test(e.key)?r.length>=s.getMaxDigits()&&e.preventDefault():e.key.length===1&&e.preventDefault())}function Lt(e,t){if(!e.target)return;e.preventDefault();const n=e.target,{digits:r,formatter:s}=t,o=e.clipboardData?.getData("text")||"",c=s.getMaxDigits(),i=U(o,c);if(i.length===0)return;const[h,l]=$e(n);if(h!==l){const p=s.getDigitRange(r,h,l);if(p){const[f,b]=p;return{newDigits:U(r.slice(0,f)+i+r.slice(b),c),caretDigitIndex:f+i.length}}}const d=s.getDigitRange(r,0,h),u=d?d[1]:0;return{newDigits:U(r.slice(0,u)+i+r.slice(u),c),caretDigitIndex:u+i.length}}function Tt(e){const t=je(e.mask),n=t.map(o=>fe(ue(o))),r=Math.max(...n),s=o=>{const c=Ve(t,o);return ue(c)};return{formatDisplay:o=>{const c=s(o.length);return ee(c,o).display},getMaxDigits:()=>r,getPlaceholder:()=>s(0),getCaretPosition:o=>{const c=Math.max(0,o);if(c===0)return 0;const i=s(c),{display:h}=ee(i,"0".repeat(c));return h.length},getDigitRange:(o,c,i)=>{const h=s(o.length),{map:l}=ee(h,o);let d=1/0,u=-1/0;for(let p=c;p<i&&p<l.length;p++){const f=l[p];f!==void 0&&f>=0&&(d=Math.min(d,f),u=Math.max(u,f))}return d===1/0?null:[d,u+1]},isComplete:o=>n.includes(o.length)}}const At="https://ipapi.co/json/",Nt=1500,le="@desource/phone-mask:geo",Pt=864e5;async function Rt(e=At,t=Nt){const n=new AbortController,r=setTimeout(()=>n.abort(),t);try{const s=await fetch(e,{signal:n.signal,headers:{Accept:"application/json"}});if(clearTimeout(r),!s.ok)return null;const o=await s.json();return(o.country||o.country_code||o.countryCode||o.country_code2||"").toString().toUpperCase()||null}catch{return clearTimeout(r),null}}async function Bt(){try{const n=localStorage.getItem(le);if(n){const r=JSON.parse(n),s=Date.now()-r.ts>Pt,o=te(r.country_code);if(o&&!s)return o;localStorage.removeItem(le)}}catch{}const e=await Rt(),t=te(e);if(t){try{const n=JSON.stringify({country_code:t,ts:Date.now()});localStorage.setItem(le,n)}catch{}return t}return null}function Ge({country:e,value:t,onChange:n,onPhoneChange:r,onValidationChange:s}){const o=a.useMemo(()=>Tt(e),[e]),c=o.getMaxDigits(),i=a.useMemo(()=>U(t,c),[t,c]),h=o.getPlaceholder(),l=o.formatDisplay(i),d=i?`${e.code}${i}`:"",u=l?`${e.code} ${l}`:"",p=o.isComplete(i),f=i.length===0,b=!f&&!p,D=a.useMemo(()=>({full:d,fullFormatted:u,digits:i}),[d,u,i]);return a.useEffect(()=>{t!==i&&n(i)},[t,i,n]),a.useEffect(()=>{r?.(D)},[D,r]),a.useEffect(()=>{s?.(p)},[p,s]),{digits:i,formatter:o,displayPlaceholder:h,displayValue:l,full:d,fullFormatted:u,isComplete:p,isEmpty:f,shouldShowWarn:b}}function Ke({country:e,locale:t,detect:n,onCountryChange:r}){const s=a.useMemo(()=>t||He(),[t]),[o,c]=a.useState(te(e,"US")),i=a.useMemo(()=>Dt(o,s),[o,s]),h=!!n&&!e,l=a.useCallback(u=>{const p=te(u);return p?(c(p),!0):!1},[]),d=a.useCallback(async()=>{const u=await Bt();if(l(u))return;const p=yt();l(p)},[l]);return a.useEffect(()=>{e&&e!==o&&l(e)},[o,e,l]),a.useEffect(()=>{h&&d()},[h,d]),a.useEffect(()=>{r?.(i)},[i,r]),{country:i,setCountry:l,locale:s}}function he(){const e=a.useRef(null),t=a.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null)},[]),n=a.useCallback((r,s)=>{t(),e.current=setTimeout(r,s)},[t]);return a.useEffect(()=>t,[t]),a.useMemo(()=>({set:n,clear:t}),[n,t])}function Ht(){const[e,t]=a.useState(!1),n=he(),r=a.useCallback((o=!0)=>{o&&t(!1),n.clear()},[n]),s=a.useCallback(o=>{t(!1),n.set(()=>{t(!0)},o)},[n]);return{showValidationHint:e,clearValidationHint:r,scheduleValidationHint:s}}function q(e){return"nativeEvent"in e?e.nativeEvent:e}const jt=500,Ae=300;function Fe(e){const{formatter:t,digits:n,inactive:r,onChange:s,scheduleValidationHint:o}=e,c=a.useCallback((u,p)=>{setTimeout(()=>{if(!u)return;const f=t.getCaretPosition(p);St(u,f)},0)},[t]),i=a.useCallback(u=>{xt(q(u))},[]),h=a.useCallback(u=>{if(r)return;const p=q(u),f=Et(p,{formatter:t});f&&(s?.(f.newDigits),c(p.target,f.caretDigitIndex),o?.(jt))},[r,t,s,c,o]),l=a.useCallback(u=>{if(r)return;const p=q(u),f=It(p,{digits:n,formatter:t});f&&(s?.(f.newDigits),c(p.target,f.caretDigitIndex),o?.(Ae))},[r,n,t,s,c,o]),d=a.useCallback(u=>{if(r)return;const p=q(u),f=Lt(p,{digits:n,formatter:t});f&&(s?.(f.newDigits),c(p.target,f.caretDigitIndex),o?.(Ae))},[r,n,t,s,c,o]);return{handleBeforeInput:i,handleInput:h,handleKeydown:l,handlePaste:d}}function Vt({rootRef:e,dropdownRef:t,searchRef:n,selectorRef:r,locale:s,countryOption:o,inactive:c,onSelectCountry:i,onAfterSelect:h}){const[l,d]=a.useState(""),[u,p]=a.useState(!1),[f,b]=a.useState({}),[D,I]=a.useState(!1),[L,m]=a.useState(0),E=a.useMemo(()=>Be(s),[s]),S=a.useMemo(()=>vt(E,l),[E,l]),x=a.useMemo(()=>!o&&E.length>1,[o,E]),T=a.useCallback(()=>{setTimeout(()=>n.current?.focus({preventScroll:!0}),0)},[]),k=a.useCallback(()=>{u&&I(!0)},[u]),V=a.useCallback(()=>{I(!1),p(!0),m(0),T()},[T]),O=a.useCallback(()=>{D&&(p(!1),I(!1))},[D]),Z=a.useCallback(()=>{c||!x||(u?k():V())},[c,u,x,V,k]),A=a.useCallback(C=>{i(C),k(),d(""),m(0),h?.()},[i,k,h]),Y=a.useCallback(C=>{d(C.target.value),m(0)},[]),H=a.useCallback(C=>{const y=C.target,w=t.current,N=r.current;y&&(w?.contains(y)||N?.contains(y)||k())},[k]),v=a.useCallback(C=>{if(C?.type==="scroll"&&C.target&&t.current?.contains(C.target)||!e?.current)return;const y=e.current.getBoundingClientRect();b({top:`${y.bottom+globalThis.scrollY+8}px`,left:`${y.left+globalThis.scrollX}px`,width:`${y.width}px`})},[]),$=a.useCallback(C=>{setTimeout(()=>{const y=t.current?.lastElementChild,w=y?.children[C];if(!y||!w)return;const N=y.getBoundingClientRect(),P=w.getBoundingClientRect();let R=0;if(P.top<N.top)R=y.scrollTop-(N.top-P.top);else if(P.bottom>N.bottom)R=y.scrollTop+(P.bottom-N.bottom);else return;y.scrollTo({top:R,behavior:"smooth"})},0)},[]),ne=a.useCallback(C=>{C.key==="ArrowDown"?(C.preventDefault(),m(y=>{const w=Math.min(y+1,S.length-1);return $(w),w})):C.key==="ArrowUp"?(C.preventDefault(),m(y=>{const w=Math.max(y-1,0);return $(w),w})):C.key==="Enter"&&S[L]?(C.preventDefault(),A(S[L].id)):C.key==="Escape"&&k()},[S,L,A,k,$]);return a.useEffect(()=>{!x&&u&&k()},[x,u,k]),a.useEffect(()=>{if(u)return v(),globalThis.addEventListener("resize",v),globalThis.addEventListener("scroll",v,!0),globalThis.addEventListener("click",H,!0),()=>{globalThis.removeEventListener("resize",v),globalThis.removeEventListener("scroll",v,!0),globalThis.removeEventListener("click",H,!0)}},[u,v,H]),{dropdownOpen:u,isClosing:D,search:l,focusedIndex:L,dropdownStyle:f,filteredCountries:S,hasDropdown:x,openDropdown:V,closeDropdown:k,toggleDropdown:Z,selectCountry:A,setFocusedIndex:m,handleSearchChange:Y,handleSearchKeydown:ne,handleDropdownAnimationEnd:O}}function $t(e=1800){const[t,n]=a.useState(!1),[r,s]=a.useState(!1),o=he(),c=a.useCallback(async i=>{if(r)return!1;const h=i.trim();if(!h)return!1;s(!0);try{return await navigator.clipboard.writeText(h),n(!0),o.set(()=>{n(!1)},e),!0}catch(l){return console.warn("Copy failed",l),!1}finally{s(!1)}},[r,o]);return{copied:t,isCopying:r,copy:c}}const Ne=1800;function Gt({liveRef:e,fullFormatted:t,onCopy:n}){const r=he(),{copied:s,copy:o}=$t(Ne),c=a.useMemo(()=>s?"Copied":`Copy ${t}`,[s,t]),i=a.useMemo(()=>s?"Copied":"Copy phone number",[s]),h=a.useCallback(d=>{e?.current&&(e.current.textContent=d,r.set(()=>{e.current&&(e.current.textContent="")},Ne))},[e,r]),l=a.useCallback(async()=>{const d=t.trim();await o(d)&&(n?.(d),h("Phone number copied to clipboard"))},[t,o,n,h]);return{copied:s,copyAriaLabel:c,copyButtonTitle:i,onCopyClick:l}}function Kt({theme:e}){const[t,n]=a.useState(!1),r=a.useMemo(()=>e==="auto"?t?"theme-dark":"theme-light":`theme-${e}`,[e,t]);return a.useEffect(()=>{const s=globalThis.matchMedia?.("(prefers-color-scheme: dark)")??null;if(!s)return;n(s.matches);const o=c=>{n(c.matches)};return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),{themeClass:r}}const Ft=(e,t)=>{const{value:n="",country:r,detect:s=!0,locale:o,size:c="normal",theme:i="auto",disabled:h=!1,readonly:l=!1,showCopy:d=!0,showClear:u=!1,withValidity:p=!0,searchPlaceholder:f="Search country or code...",noResultsText:b="No countries found",clearButtonLabel:D="Clear phone number",dropdownClass:I="",disableDefaultStyles:L=!1,onChange:m,onPhoneChange:E,onCountryChange:S,onValidationChange:x,onFocus:T,onBlur:k,onCopy:V,onClear:O,renderActionsBefore:Z,renderFlag:A,renderCopySvg:Y,renderClearSvg:H}=e,{country:v,setCountry:$,locale:ne}=Ke({country:r,locale:o,detect:s,onCountryChange:S}),{digits:C,formatter:y,displayPlaceholder:w,displayValue:N,full:P,fullFormatted:R,isComplete:J,isEmpty:ge,shouldShowWarn:We}=Ge({country:v,value:n,onChange:m,onPhoneChange:E,onValidationChange:x}),{showValidationHint:Oe,clearValidationHint:_,scheduleValidationHint:Ze}=Ht(),me=a.useId(),oe=a.useRef(null),Ce=a.useRef(null),ye=a.useRef(null),be=a.useRef(null),De=a.useRef(null),ve=a.useRef(null),G=h||l,ke=Oe&&We,we=d&&!ge&&!h,Me=u&&!ge&&!G,{copied:re,copyAriaLabel:Ye,copyButtonTitle:Je,onCopyClick:_e}=Gt({liveRef:ye,fullFormatted:R,onCopy:V}),K=a.useCallback(()=>{setTimeout(()=>oe.current?.focus(),0)},[]),{handleBeforeInput:ze,handleInput:Xe,handleKeydown:Qe,handlePaste:qe}=Fe({formatter:y,digits:C,inactive:G,onChange:m,scheduleValidationHint:Ze}),{dropdownOpen:z,isClosing:et,search:tt,focusedIndex:se,dropdownStyle:nt,filteredCountries:ae,hasDropdown:X,closeDropdown:Se,toggleDropdown:ot,selectCountry:ce,setFocusedIndex:rt,handleSearchChange:st,handleSearchKeydown:at,handleDropdownAnimationEnd:ct}=Vt({rootRef:Ce,dropdownRef:be,searchRef:De,selectorRef:ve,locale:ne,inactive:G,countryOption:r,onSelectCountry:$,onAfterSelect:K}),it=a.useCallback(M=>{_(!1),Se(),T?.(M)},[T,Se,_]),Q=a.useCallback(()=>{m?.(""),_(),O?.()},[m,O,_]),lt=a.useCallback(()=>{Q(),K()},[Q,K]);a.useImperativeHandle(t,()=>({focus:K,blur:()=>oe.current?.blur(),clear:Q,selectCountry:ce,getFullNumber:()=>P,getFullFormattedNumber:()=>R,getDigits:()=>C,isValid:()=>J,isComplete:()=>J}),[K,ce,P,R,C,J,Q]);const{themeClass:xe}=Kt({theme:i}),ut=["phone-input",`size-${c}`,xe,h&&"is-disabled",l&&"is-readonly",L&&"is-unstyled",p&&ke&&"is-incomplete",p&&J&&"is-complete"].filter(Boolean).join(" "),dt=+we+ +Me+(Z?1:0),Ee=`pi-options-${me}`,Ie=`pi-option-${me}`,pt=z&&ae[se]?`${Ie}-${se}`:void 0;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{ref:Ce,className:ut,style:{"--pi-actions-count":dt},role:"group","aria-label":"Phone input with country selector",children:[g.jsx("div",{className:"pi-selector",ref:ve,children:g.jsxs("button",{type:"button",className:`pi-selector-btn ${!X||l?"no-dropdown":""}`,disabled:h,tabIndex:G||!X?-1:void 0,"aria-label":`Selected country: ${v.name}`,"aria-expanded":z,"aria-haspopup":X?"listbox":void 0,onClick:ot,children:[g.jsx("span",{className:"pi-flag",role:"img","aria-label":`${v.name} flag`,children:A?A(v):v.flag}),g.jsx("span",{className:"pi-code",children:v.code}),!G&&X&&g.jsx("svg",{className:`pi-chevron ${z?"is-open":""}`,width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:g.jsx("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),g.jsxs("div",{className:"pi-input-wrap",children:[g.jsx("input",{ref:oe,type:"tel",inputMode:"tel",autoComplete:"tel-national",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:"pi-input",placeholder:w,value:N,disabled:h,readOnly:l,"aria-invalid":ke,onInput:Xe,onBeforeInput:ze,onKeyDown:Qe,onPaste:qe,onFocus:it,onBlur:k}),g.jsxs("div",{className:"pi-actions",role:"toolbar","aria-label":"Phone input actions",children:[Z?.(),we&&g.jsx("button",{type:"button",className:`pi-btn pi-btn-copy ${re?"is-copied":""}`,"aria-label":Ye,title:Je,onClick:_e,children:Y?Y(re):re?g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:g.jsx("path",{d:"M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z",fill:"currentColor"})}):g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:g.jsx("path",{d:"M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z",fill:"currentColor"})})}),Me&&g.jsx("button",{type:"button",className:"pi-btn pi-btn-clear","aria-label":D,title:D,onClick:lt,children:H?H():g.jsx("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:g.jsx("path",{d:"M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z",fill:"currentColor"})})})]})]})]}),z&&typeof document<"u"&&ft.createPortal(g.jsxs("div",{ref:be,className:`phone-dropdown ${I} ${xe} ${et?"is-closing":""}`,style:nt,role:"dialog","aria-modal":"false","aria-label":"Select country",onAnimationEnd:ct,children:[g.jsx("div",{className:"pi-search-wrap",children:g.jsx("input",{ref:De,type:"search",className:"pi-search","aria-label":"Search countries","aria-controls":Ee,"aria-activedescendant":pt,placeholder:f,value:tt,onChange:st,onKeyDown:at})}),g.jsx("ul",{id:Ee,className:"pi-options",role:"listbox",tabIndex:-1,children:ae.length>0?ae.map((M,ie)=>g.jsxs("li",{id:`${Ie}-${ie}`,role:"option",className:`pi-option ${ie===se?"is-focused":""} ${M.id===v.id?"is-selected":""}`,"aria-selected":M.id===v.id,title:M.name,onClick:()=>ce(M.id),onMouseEnter:()=>rt(ie),children:[g.jsx("span",{className:"pi-flag",role:"img","aria-label":`${M.name} flag`,children:A?A(M):M.flag}),g.jsx("span",{className:"pi-opt-name",children:M.name}),g.jsx("span",{className:"pi-opt-code",children:M.code})]},M.id)):g.jsx("li",{className:"pi-empty",children:b})})]}),document.body),g.jsx("div",{ref:ye,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"})]})},Ue=a.forwardRef(Ft);Ue.displayName="PhoneInput";function Ut(e){const t=a.useRef(null),{country:n,setCountry:r}=Ke({country:e.country,locale:e.locale,detect:e.detect,onCountryChange:e.onCountryChange}),{digits:s,formatter:o,displayPlaceholder:c,displayValue:i,full:h,fullFormatted:l,isComplete:d,isEmpty:u,shouldShowWarn:p}=Ge({country:n,value:e.value,onChange:e.onChange,onPhoneChange:e.onPhoneChange}),{handleBeforeInput:f,handleInput:b,handleKeydown:D,handlePaste:I}=Fe({formatter:o,digits:s,onChange:e.onChange});a.useEffect(()=>{const m=t.current;m&&(m.setAttribute("type","tel"),m.setAttribute("inputmode","tel"))},[]),a.useEffect(()=>{const m=t.current;m&&(m.value=i,m.setAttribute("placeholder",c))},[i,c]),a.useEffect(()=>{const m=t.current;if(!m)return;const E=f,S=b,x=D,T=I;return m.addEventListener("beforeinput",E),m.addEventListener("input",S),m.addEventListener("keydown",x),m.addEventListener("paste",T),()=>{m.removeEventListener("beforeinput",E),m.removeEventListener("input",S),m.removeEventListener("keydown",x),m.removeEventListener("paste",T)}},[f,b,D,I]);const L=a.useCallback(()=>{e.onChange("")},[e.onChange]);return{ref:t,digits:s,formatter:o,full:h,fullFormatted:l,isComplete:d,isEmpty:u,shouldShowWarn:p,country:n,setCountry:r,clear:L}}const Wt={getFlagEmoji:Ct,countPlaceholders:fe,formatDigitsWithMap:ee,pickMaskVariant:Ve,removeCountryCodePrefix:ue,toArray:je};exports.PMaskHelpers=Wt;exports.PhoneInput=Ue;exports.usePhoneMask=Ut;
|
|
2
2
|
//# sourceMappingURL=phone-mask-react.cjs.map
|