@desource/phone-mask-react 1.0.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 +31 -0
- package/README.md +23 -1
- package/dist/esm/components/PhoneInput.d.ts.map +1 -1
- package/dist/esm/hooks/internal/useTheme.d.ts.map +1 -1
- package/dist/esm/hooks/usePhoneMask.d.ts.map +1 -1
- package/dist/esm/index.js +454 -462
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +3 -1
- 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 +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),a=require("react"),ct=require("react-dom"),it={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 #### ######"]},lt=/^[a-z]{2}$/i,O=e=>{if(!lt.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)},le="en",$=new Map,Le=e=>{const t=e.toLowerCase(),n=$.get(t);if(n)return n;const r=new Intl.DisplayNames([e],{type:"region"});if($.size>=10){for(const s of $.keys())if(s!==le){$.delete(s);break}}return $.set(t,r),r},B=Object.entries(it),Se=e=>e.split(/ (.*)/s);function j(e){let t="",n="";if(Array.isArray(e)){const r=[];for(const s of e){const[o,i]=Se(s);t||(t=o),r.push(i)}n=r}else{const[r,s]=Se(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:O(t)},e},{});B.map(([e,t])=>{const[n,r]=j(t);return{id:e,code:n,mask:r,flag:O(e)}});const Ie=e=>{const t=Le(e);return B.reduce((n,[r,s])=>{const[o,i]=j(s),c=t.of(r)??"";return n[r]={code:o,mask:i,name:c,flag:O(r)},n},{})},Te=e=>{const t=Le(e);return B.map(([n,r])=>{const[s,o]=j(r);return{id:n,code:s,mask:o,name:t.of(n)??"",flag:O(n)}})},ut=Ie(le);Te(le);const dt=O;function Ae(){return typeof navigator<"u"&&navigator.language||"en"}function ft(){try{const e=Ae();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 pt(e){const t=ut;return e.toUpperCase()in t}function ht(e,t){const n=Ie(t),r=e.toUpperCase();return r in n?{id:r,...n[r]}:{id:"US",...n.US}}function ee(e,t){return e&&pt(e)?e.toUpperCase():t||""}function Ne(e){return Array.isArray(e)?e:[e]}function ue(e){return(e.match(/#/g)||[]).length}function ie(e){return e.replace(/^\+\d+\s?/,"")}function Pe(e,t){if(e.length===1)return e[0];const n=e.map(o=>({mask:o,count:ue(o)})),r=n.filter(o=>o.count>=t).sort((o,i)=>o.count-i.count);if(r.length>0)return r[0].mask;const s=n.sort((o,i)=>i.count-o.count)[0];return s?s.mask:e[0]}function q(e,t){let n="";const r=[];let s=0;const o=t.length,i=e.length;for(let c=0;c<i;c++){const l=e[c];if(l==="#"){if(!(s<o))break;n+=t[s],r.push(s),s++}else{const u=e.indexOf("#",c+1)!==-1&&s<o;(n.length>0||u)&&(n+=l,r.push(-1))}}return{display:n,map:r}}function gt(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 i=o.name.toUpperCase(),c=o.id.toUpperCase(),l=o.code.toUpperCase(),u=o.code.replace(/\D/g,"");let d=0;return i.startsWith(n)?d=1e3:i.includes(n)&&(d=500),l.startsWith(n)?d+=100:l.includes(n)&&(d+=50),c===n?d+=200:c.startsWith(n)&&(d+=150),s&&u.startsWith(r)?d+=80:s&&u.includes(r)&&(d+=40),{country:o,score:d}}).filter(o=>o.score>0).sort((o,i)=>i.score!==o.score?i.score-o.score:o.country.name.localeCompare(i.country.name)).map(o=>o.country)}const mt=[" ","-","(",")"],Ct=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"],yt=/[^\d\s\-()]/;function W(e,t){const n=e.replace(/\D/g,"");return t?n.slice(0,t):n}function Re(e){return e?[e.selectionStart??0,e.selectionEnd??0]:[0,0]}function wt(e,t){if(e)try{e.setSelectionRange(t,t)}catch{}}function Dt(e){if(!e.target)return;const t=e.target,n=e.data;e.inputType==="insertText"&&n&&(yt.test(n)||n===" "&&t.value.endsWith(" "))&&e.preventDefault()}function bt(e,t){if(!e.target)return;const n=e.target,{formatter:r}=t,s=r.getMaxDigits(),o=W(n.value,s);return{newDigits:o,caretDigitIndex:o.length}}function kt(e,t){if(!e.target)return;const n=e.target,{digits:r,formatter:s}=t;if(e.ctrlKey||e.metaKey||e.altKey||Ct.includes(e.key))return;const[o,i]=Re(n);if(e.key!=="Backspace")if(e.key!=="Delete")/^[0-9]$/.test(e.key)?r.length>=s.getMaxDigits()&&e.preventDefault():e.key.length===1&&e.preventDefault();else{if(e.preventDefault(),o!==i){const c=s.getDigitRange(r,o,i);if(c){const[l,u]=c;return{newDigits:r.slice(0,l)+r.slice(u),caretDigitIndex:l}}}if(o<n.value.length){const c=s.getDigitRange(r,o,n.value.length);if(c){const[l]=c;return{newDigits:r.slice(0,l)+r.slice(l+1),caretDigitIndex:l}}}}else{if(e.preventDefault(),o!==i){const c=s.getDigitRange(r,o,i);if(c){const[l,u]=c;return{newDigits:r.slice(0,l)+r.slice(u),caretDigitIndex:l}}}if(o>0){const c=n.value;let l=o-1;for(;l>=0&&mt.includes(c[l]);)l--;if(l>=0){const u=s.getDigitRange(r,l,l+1);if(u){const[d]=u;return{newDigits:r.slice(0,d)+r.slice(d+1),caretDigitIndex:d}}}}}}function vt(e,t){if(!e.target)return;e.preventDefault();const n=e.target,{digits:r,formatter:s}=t,o=e.clipboardData?.getData("text")||"",i=s.getMaxDigits(),c=W(o,i);if(c.length===0)return;const[l,u]=Re(n);if(l!==u){const p=s.getDigitRange(r,l,u);if(p){const[h,M]=p;return{newDigits:W(r.slice(0,h)+c+r.slice(M),i),caretDigitIndex:h+c.length}}}const d=s.getDigitRange(r,0,l),f=d?d[1]:0;return{newDigits:W(r.slice(0,f)+c+r.slice(f),i),caretDigitIndex:f+c.length}}function Mt(e){const t=Ne(e.mask),n=t.map(o=>ue(ie(o))),r=Math.max(...n),s=o=>{const i=Pe(t,o);return ie(i)};return{formatDisplay:o=>{const i=s(o.length);return q(i,o).display},getMaxDigits:()=>r,getPlaceholder:()=>s(0),getCaretPosition:o=>{const i=s(o),{display:c,map:l}=q(i,"0".repeat(o));for(let u=0;u<l.length;u++)if(l[u]===o)return u;if(o>=l.length)return c.length;for(let u=0;u<l.length;u++)if(l[u]>o)return u;return c.length},getDigitRange:(o,i,c)=>{const l=s(o.length),{map:u}=q(l,o);let d=1/0,f=-1/0;for(let p=i;p<c&&p<u.length;p++){const h=u[p];h!==void 0&&h>=0&&(d=Math.min(d,h),f=Math.max(f,h))}return d===1/0?null:[d,f+1]},isComplete:o=>n.includes(o.length)}}const St="https://ipapi.co/json/",xt=1500,ce="@desource/phone-mask:geo",Et=864e5;async function Lt(e=St,t=xt){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 It(){try{const n=localStorage.getItem(ce);if(n){const r=JSON.parse(n),s=Date.now()-r.ts>Et,o=ee(r.country_code);if(o&&!s)return o;localStorage.removeItem(ce)}}catch{}const e=await Lt(),t=ee(e);if(t){try{const n=JSON.stringify({country_code:t,ts:Date.now()});localStorage.setItem(ce,n)}catch{}return t}return null}function Be({country:e,value:t,onChange:n,onPhoneChange:r,onValidationChange:s}){const o=a.useMemo(()=>Mt(e),[e]),i=o.getMaxDigits(),c=a.useMemo(()=>W(t,i),[t,i]),l=o.getPlaceholder(),u=o.formatDisplay(c),d=c?`${e.code}${c}`:"",f=u?`${e.code} ${u}`:"",p=o.isComplete(c),h=c.length===0,M=!h&&!p,b=a.useMemo(()=>({full:d,fullFormatted:f,digits:c}),[d,f,c]);return a.useEffect(()=>{t!==c&&n(c)},[t,c,n]),a.useEffect(()=>{r?.(b)},[b,r]),a.useEffect(()=>{s?.(p)},[p,s]),{digits:c,formatter:o,displayPlaceholder:l,displayValue:u,full:d,fullFormatted:f,isComplete:p,isEmpty:h,shouldShowWarn:M}}function He({country:e,locale:t,detect:n,onCountryChange:r}){const s=a.useMemo(()=>t||Ae(),[t]),[o,i]=a.useState(ee(e,"US")),c=a.useMemo(()=>ht(o,s),[o,s]),l=!!n&&!e,u=a.useCallback(f=>{const p=ee(f);return p?(i(p),!0):!1},[]),d=a.useCallback(async()=>{const f=await It();if(u(f))return;const p=ft();u(p)},[u]);return a.useEffect(()=>{e&&e!==o&&u(e)},[o,e,u]),a.useEffect(()=>{l&&d()},[l,d]),a.useEffect(()=>{r?.(c)},[c,r]),{country:c,setCountry:u,locale:s}}function de(){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 Tt(){const[e,t]=a.useState(!1),n=de(),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 At=500,xe=300;function je(e){const{formatter:t,digits:n,inactive:r,onChange:s,scheduleValidationHint:o}=e,i=a.useCallback((f,p)=>{setTimeout(()=>{if(!f)return;const h=t.getCaretPosition(p);wt(f,h)},0)},[t]),c=a.useCallback(f=>{Dt(Q(f))},[]),l=a.useCallback(f=>{if(r)return;const p=Q(f),h=bt(p,{formatter:t});h&&(s?.(h.newDigits),i(p.target,h.caretDigitIndex),o?.(At))},[r,t,s,i,o]),u=a.useCallback(f=>{if(r)return;const p=Q(f),h=kt(p,{digits:n,formatter:t});h&&(s?.(h.newDigits),i(p.target,h.caretDigitIndex),o?.(xe))},[r,n,t,s,i,o]),d=a.useCallback(f=>{if(r)return;const p=Q(f),h=vt(p,{digits:n,formatter:t});h&&(s?.(h.newDigits),i(p.target,h.caretDigitIndex),o?.(xe))},[r,n,t,s,i,o]);return{handleBeforeInput:c,handleInput:l,handleKeydown:u,handlePaste:d}}function Nt({rootRef:e,dropdownRef:t,searchRef:n,selectorRef:r,locale:s,countryOption:o,inactive:i,onSelectCountry:c,onAfterSelect:l}){const[u,d]=a.useState(""),[f,p]=a.useState(!1),[h,M]=a.useState({}),[b,L]=a.useState(!1),[I,m]=a.useState(0),E=a.useMemo(()=>Te(s),[s]),S=a.useMemo(()=>gt(E,u),[E,u]),x=a.useMemo(()=>!o&&E.length>1,[o,E]),T=a.useCallback(()=>{setTimeout(()=>n.current?.focus({preventScroll:!0}),0)},[]),D=a.useCallback(()=>{f&&L(!0)},[f]),V=a.useCallback(()=>{L(!1),p(!0),m(0),T()},[T]),Z=a.useCallback(()=>{b&&(p(!1),L(!1))},[b]),G=a.useCallback(()=>{i||!x||(f?D():V())},[i,f,x,V,D]),A=a.useCallback(C=>{c(C),D(),d(""),m(0),l?.()},[c,D,l]),Y=a.useCallback(C=>{d(C.target.value),m(0)},[]),H=a.useCallback(C=>{const y=C.target,k=t.current,N=r.current;y&&(k?.contains(y)||N?.contains(y)||D())},[D]),w=a.useCallback(C=>{if(C?.type==="scroll"&&C.target&&t.current?.contains(C.target)||!e?.current)return;const y=e.current.getBoundingClientRect();M({top:`${y.bottom+window.scrollY+8}px`,left:`${y.left+window.scrollX}px`,width:`${y.width}px`})},[]),F=a.useCallback(C=>{setTimeout(()=>{const y=t.current?.lastElementChild,k=y?.children[C];if(!y||!k)return;const N=y.getBoundingClientRect(),P=k.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)},[]),te=a.useCallback(C=>{C.key==="ArrowDown"?(C.preventDefault(),m(y=>{const k=Math.min(y+1,S.length-1);return F(k),k})):C.key==="ArrowUp"?(C.preventDefault(),m(y=>{const k=Math.max(y-1,0);return F(k),k})):C.key==="Enter"&&S[I]?(C.preventDefault(),A(S[I].id)):C.key==="Escape"&&D()},[S,I,A,D,F]);return a.useEffect(()=>{!x&&f&&D()},[x,f,D]),a.useEffect(()=>{if(f)return w(),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),window.addEventListener("click",H,!0),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),window.removeEventListener("click",H,!0)}},[f,w,H]),{dropdownOpen:f,isClosing:b,search:u,focusedIndex:I,dropdownStyle:h,filteredCountries:S,hasDropdown:x,openDropdown:V,closeDropdown:D,toggleDropdown:G,selectCountry:A,setFocusedIndex:m,handleSearchChange:Y,handleSearchKeydown:te,handleDropdownAnimationEnd:Z}}function Pt(e=1800){const[t,n]=a.useState(!1),[r,s]=a.useState(!1),o=de(),i=a.useCallback(async c=>{if(r)return!1;const l=c.trim();if(!l)return!1;s(!0);try{return await navigator.clipboard.writeText(l),n(!0),o.set(()=>{n(!1)},e),!0}catch(u){return console.warn("Copy failed",u),!1}finally{s(!1)}},[r,o]);return{copied:t,isCopying:r,copy:i}}const Ee=1800;function Rt({liveRef:e,fullFormatted:t,onCopy:n}){const r=de(),{copied:s,copy:o}=Pt(Ee),i=a.useMemo(()=>s?"Copied":`Copy ${t}`,[s,t]),c=a.useMemo(()=>s?"Copied":"Copy phone number",[s]),l=a.useCallback(d=>{e?.current&&(e.current.textContent=d,r.set(()=>{e.current&&(e.current.textContent="")},Ee))},[e,r]),u=a.useCallback(async()=>{const d=t.trim();await o(d)&&(n?.(d),l("Phone number copied to clipboard"))},[t,o,n,l]);return{copied:s,copyAriaLabel:i,copyButtonTitle:c,onCopyClick:u}}function Bt({theme:e}){const[t,n]=a.useState(!1),r=a.useMemo(()=>e!=="auto"?`theme-${e}`:t?"theme-dark":"theme-light",[e,t]);return a.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia?.("(prefers-color-scheme: dark)")??null;if(!s)return;n(s.matches);const o=i=>{n(i.matches)};return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),{themeClass:r}}const Ht=(e,t)=>{const{value:n="",country:r,detect:s=!0,locale:o,size:i="normal",theme:c="auto",disabled:l=!1,readonly:u=!1,showCopy:d=!0,showClear:f=!1,withValidity:p=!0,searchPlaceholder:h="Search country or code...",noResultsText:M="No countries found",clearButtonLabel:b="Clear phone number",dropdownClass:L="",disableDefaultStyles:I=!1,onChange:m,onPhoneChange:E,onCountryChange:S,onValidationChange:x,onFocus:T,onBlur:D,onCopy:V,onClear:Z,renderActionsBefore:G,renderFlag:A,renderCopySvg:Y,renderClearSvg:H}=e,{country:w,setCountry:F,locale:te}=He({country:r,locale:o,detect:s,onCountryChange:S}),{digits:C,formatter:y,displayPlaceholder:k,displayValue:N,full:P,fullFormatted:R,isComplete:J,isEmpty:fe,shouldShowWarn:Ge}=Be({country:w,value:n,onChange:m,onPhoneChange:E,onValidationChange:x}),{showValidationHint:Fe,clearValidationHint:_,scheduleValidationHint:Ke}=Tt(),ne=a.useRef(null),pe=a.useRef(null),he=a.useRef(null),ge=a.useRef(null),me=a.useRef(null),Ce=a.useRef(null),K=l||u,ye=Fe&&Ge,we=d&&!fe&&!l,De=f&&!fe&&!K,{copied:oe,copyAriaLabel:Ue,copyButtonTitle:$e,onCopyClick:We}=Rt({liveRef:he,fullFormatted:R,onCopy:V}),U=a.useCallback(()=>{setTimeout(()=>ne.current?.focus(),0)},[]),{handleBeforeInput:Oe,handleInput:Ze,handleKeydown:Ye,handlePaste:Je}=je({formatter:y,digits:C,inactive:K,onChange:m,scheduleValidationHint:Ke}),{dropdownOpen:re,isClosing:_e,search:ze,focusedIndex:be,dropdownStyle:Xe,filteredCountries:ke,hasDropdown:z,closeDropdown:ve,toggleDropdown:Qe,selectCountry:se,setFocusedIndex:qe,handleSearchChange:et,handleSearchKeydown:tt,handleDropdownAnimationEnd:nt}=Nt({rootRef:pe,dropdownRef:ge,searchRef:me,selectorRef:Ce,locale:te,inactive:K,countryOption:r,onSelectCountry:F,onAfterSelect:U}),ot=a.useCallback(v=>{_(!1),ve(),T?.(v)},[T,ve,_]),X=a.useCallback(()=>{m?.(""),_(),Z?.()},[m,Z,_]),rt=a.useCallback(()=>{X(),U()},[X,U]);a.useImperativeHandle(t,()=>({focus:U,blur:()=>ne.current?.blur(),clear:X,selectCountry:se,getFullNumber:()=>P,getFullFormattedNumber:()=>R,getDigits:()=>C,isValid:()=>J,isComplete:()=>J}),[U,se,P,R,C,J,X]);const{themeClass:Me}=Bt({theme:c}),st=["phone-input",`size-${i}`,Me,l&&"is-disabled",u&&"is-readonly",I&&"is-unstyled",p&&ye&&"is-incomplete",p&&J&&"is-complete"].filter(Boolean).join(" "),at=+we+ +De+(G?1:0);return g.jsxs(g.Fragment,{children:[g.jsxs("div",{ref:pe,className:st,style:{"--pi-actions-count":at},role:"group","aria-label":"Phone input with country selector",children:[g.jsx("div",{className:"pi-selector",ref:Ce,children:g.jsxs("button",{type:"button",className:`pi-selector-btn ${!z||u?"no-dropdown":""}`,disabled:l,tabIndex:K||!z?-1:void 0,"aria-label":`Selected country: ${w.name}`,"aria-expanded":re,"aria-haspopup":z?"listbox":void 0,onClick:Qe,children:[g.jsx("span",{className:"pi-flag",role:"img","aria-label":`${w.name} flag`,children:A?A(w):w.flag}),g.jsx("span",{className:"pi-code",children:w.code}),!K&&z&&g.jsx("svg",{className:`pi-chevron ${re?"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:ne,type:"tel",inputMode:"tel",autoComplete:"tel-national",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:"pi-input",placeholder:k,value:N,disabled:l,readOnly:u,"aria-invalid":ye,onInput:Ze,onBeforeInput:Oe,onKeyDown:Ye,onPaste:Je,onFocus:ot,onBlur:D}),g.jsxs("div",{className:"pi-actions",role:"toolbar","aria-label":"Phone input actions",children:[G&&G(),we&&g.jsx("button",{type:"button",className:`pi-btn pi-btn-copy ${oe?"is-copied":""}`,"aria-label":Ue,title:$e,onClick:We,children:Y?Y(oe):oe?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"})})}),De&&g.jsx("button",{type:"button",className:"pi-btn pi-btn-clear","aria-label":b,title:b,onClick:rt,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"})})})]})]})]}),re&&typeof document<"u"&&ct.createPortal(g.jsxs("div",{ref:ge,className:`phone-dropdown ${L} ${Me} ${_e?"is-closing":""}`,style:Xe,role:"dialog","aria-modal":"false","aria-label":"Select country",onAnimationEnd:nt,children:[g.jsx("div",{className:"pi-search-wrap",children:g.jsx("input",{ref:me,type:"search",className:"pi-search","aria-label":"Search countries",placeholder:h,value:ze,onChange:et,onKeyDown:tt})}),g.jsx("ul",{className:"pi-options",role:"listbox","aria-activedescendant":`option-${be}`,tabIndex:-1,children:ke.length>0?ke.map((v,ae)=>g.jsxs("li",{id:`option-${ae}`,role:"option",className:`pi-option ${ae===be?"is-focused":""} ${v.id===w.id?"is-selected":""}`,"aria-selected":v.id===w.id,title:v.name,onClick:()=>se(v.id),onMouseEnter:()=>qe(ae),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-opt-name",children:v.name}),g.jsx("span",{className:"pi-opt-code",children:v.code})]},v.id)):g.jsx("li",{className:"pi-empty",children:M})})]}),document.body),g.jsx("div",{ref:he,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"})]})},Ve=a.forwardRef(Ht);Ve.displayName="PhoneInput";function jt(e){const t=a.useRef(null),{country:n,setCountry:r}=He({country:e.country,locale:e.locale,detect:e.detect,onCountryChange:e.onCountryChange}),{digits:s,formatter:o,displayPlaceholder:i,displayValue:c,full:l,fullFormatted:u,isComplete:d,isEmpty:f,shouldShowWarn:p}=Be({country:n,value:e.value,onChange:e.onChange,onPhoneChange:e.onPhoneChange}),{handleBeforeInput:h,handleInput:M,handleKeydown:b,handlePaste:L}=je({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=c,m.setAttribute("placeholder",i))},[c,i]),a.useEffect(()=>{const m=t.current;if(!m)return;const E=h,S=M,x=b,T=L;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)}},[h,M,b,L]);const I=a.useCallback(()=>{e.onChange("")},[e.onChange]);return{ref:t,digits:s,full:l,fullFormatted:u,isComplete:d,isEmpty:f,shouldShowWarn:p,country:n,setCountry:r,clear:I}}const Vt={getFlagEmoji:dt,countPlaceholders:ue,formatDigitsWithMap:q,pickMaskVariant:Pe,removeCountryCodePrefix:ie,toArray:Ne};exports.PMaskHelpers=Vt;exports.PhoneInput=Ve;exports.usePhoneMask=jt;
|
|
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
|