@desource/phone-mask-react 0.3.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 +13 -0
- package/LICENSE +21 -0
- package/README.md +455 -0
- package/dist/esm/components/PhoneInput.d.ts +11 -0
- package/dist/esm/components/PhoneInput.d.ts.map +1 -0
- package/dist/esm/consts.d.ts +4 -0
- package/dist/esm/consts.d.ts.map +1 -0
- package/dist/esm/hooks/usePhoneMask.d.ts +7 -0
- package/dist/esm/hooks/usePhoneMask.d.ts.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +864 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +181 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/utils.d.ts +16 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/phone-mask-react.cjs +2 -0
- package/dist/phone-mask-react.cjs.map +1 -0
- package/dist/phone-mask-react.css +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../phone-mask/dist/esm/data.min.js","../../../phone-mask/dist/esm/country-code-emodji.js","../../../phone-mask/dist/esm/entries.js","../../../phone-mask/dist/esm/utils.js","../../../phone-mask/dist/esm/services/geoip/consts.js","../../../phone-mask/dist/esm/services/geoip/utils.js","../../src/utils.ts","../../src/consts.ts","../../src/components/PhoneInput.tsx","../../src/hooks/usePhoneMask.ts","../../src/index.ts"],"sourcesContent":["const M={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 #### ######\"]};export{M as default};\n","const t=/^[a-z]{2}$/i,countryCodeEmoji=o=>{if(!t.test(o)){const t=typeof o;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${\"string\"===t?o:t}' instead.`)}const e=[...o.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)};export{countryCodeEmoji};\n","import e from\"./data.min.js\";import{countryCodeEmoji as n}from\"./country-code-emodji.js\";const t=Object.entries(e),divideMask=e=>e.split(/ (.*)/s);function getCodeAndMask(e){let n=\"\",t=\"\";if(Array.isArray(e)){const o=[];for(const t of e){const[e,s]=divideMask(t);n||(n=e),o.push(s)}t=o}else{const[o,s]=divideMask(e);n=o,t=s}return[n,t]}const o=e,s=t.map(([e,n])=>({id:e,mask:n})),a=t.reduce((e,[n,t])=>{const[o,s]=getCodeAndMask(t);return e[n]={code:o,mask:s},e},{}),r=t.map(([e,n])=>{const[t,o]=getCodeAndMask(n);return{id:e,code:t,mask:o}}),d=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o);return e[t]={code:s,mask:a,flag:n(t)},e},{}),c=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,flag:n(e)}}),MasksFullMap=e=>{const o=new Intl.DisplayNames([e],{type:\"region\"});return t.reduce((e,[t,s])=>{const[a,r]=getCodeAndMask(s),d=o.of(t)??\"\";return e[t]={code:a,mask:r,name:d,flag:n(t)},e},{})},MasksFull=e=>{const o=new Intl.DisplayNames([e],{type:\"region\"});return t.map(([e,t])=>{const[s,a]=getCodeAndMask(t);return{id:e,code:s,mask:a,name:o.of(e)??\"\",flag:n(e)}})},m=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o),r=new Intl.DisplayNames([\"en\"],{type:\"region\"});return e[t]={code:s,mask:a,name:r.of(t)??\"\",flag:n(t)},e},{}),i=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,name:new Intl.DisplayNames([\"en\"],{type:\"region\"}).of(e)??\"\",flag:n(e)}}),g=n;export{r as Masks,s as MasksBase,o as MasksBaseMap,MasksFull,i as MasksFullEn,MasksFullMap,m as MasksFullMapEn,a as MasksMap,c as MasksWithFlag,d as MasksWithFlagMap,g as getFlagEmoji};\n","import{MasksFullMapEn as t,MasksFullMap as n}from\"./entries.js\";function getNavigatorLang(){return\"undefined\"!=typeof navigator&&navigator.language||\"en\"}function getMasksFullMapByLocale(e){return e.toLowerCase().startsWith(\"en\")?t:n(e)}function getCountry(t,n){const e=getMasksFullMapByLocale(n),r=t.toUpperCase();return r in e?{id:r,...e[r]}:{id:\"US\",...e.US}}function toArray(t){return Array.isArray(t)?t:[t]}function countPlaceholders(t){return(t.match(/#/g)||[]).length}function removeCountryCodePrefix(t){return t.replace(/^\\+\\d+\\s?/,\"\")}function pickMaskVariant(t,n){if(1===t.length)return t[0];const e=t.map(t=>({mask:t,count:countPlaceholders(t)})),r=e.filter(t=>t.count>=n).sort((t,n)=>t.count-n.count);if(r.length>0)return r[0].mask;const o=e.sort((t,n)=>n.count-t.count)[0];return o?o.mask:t[0]}function formatDigitsWithMap(t,n){let e=\"\";const r=[];let o=0;const a=n.length,i=t.length;for(let u=0;u<i;u++){const i=t[u];if(\"#\"===i){if(!(o<a))break;e+=n[o],r.push(o),o++}else{const n=-1!==t.indexOf(\"#\",u+1)&&o<a;(e.length>0||n)&&(e+=i,r.push(-1))}}return{display:e,map:r}}export{countPlaceholders,formatDigitsWithMap,getCountry,getMasksFullMapByLocale,getNavigatorLang,pickMaskVariant,removeCountryCodePrefix,toArray};\n","const o=\"https://ipapi.co/json/\",e=1500,p=\"@desource/phone-mask:geo\",s=864e5;export{s as CACHE_EXPIRY_MS,p as CACHE_KEY,o as GEO_IP_API_URL,e as GEO_IP_TIMEOUT_MS};\n","import{GEO_IP_API_URL as t,GEO_IP_TIMEOUT_MS as o,CACHE_KEY as e,CACHE_EXPIRY_MS as r}from\"./consts.js\";async function detectCountryFromGeoIP(e=t,r=o){const c=new AbortController,n=setTimeout(()=>c.abort(),r);try{const t=await fetch(e,{signal:c.signal,headers:{Accept:\"application/json\"}});if(clearTimeout(n),!t.ok)return null;const o=await t.json();return(o.country||o.country_code||o.countryCode||o.country_code2||\"\").toString().toUpperCase()||null}catch{return clearTimeout(n),null}}async function detectByGeoIp(t){try{const o=localStorage.getItem(e);if(o){const c=JSON.parse(o),n=Date.now()-c.ts>r;if(!n&&c.country_code&&t(c.country_code))return c.country_code.toUpperCase();n&&localStorage.removeItem(e)}}catch{}const o=await detectCountryFromGeoIP();if(o&&t(o)){try{localStorage.setItem(e,JSON.stringify({country_code:o,ts:Date.now()}))}catch{}return o}return null}export{detectByGeoIp,detectCountryFromGeoIP};\n","// Shared phone formatting utilities\nimport {\n toArray,\n countPlaceholders,\n removeCountryCodePrefix,\n pickMaskVariant,\n formatDigitsWithMap,\n type MaskFull\n} from '@desource/phone-mask';\nimport type { FormatterHelpers } from './types';\n\nexport function createPhoneFormatter(country: MaskFull): FormatterHelpers {\n const variants = toArray(country.mask);\n const variantsDigits = variants.map((m) => countPlaceholders(removeCountryCodePrefix(m)));\n const maxDigits = Math.max(...variantsDigits);\n\n const getMask = (digitLength: number) => {\n const mask = pickMaskVariant(variants, digitLength);\n return removeCountryCodePrefix(mask);\n };\n\n return {\n formatDisplay: (digits: string) => {\n const template = getMask(digits.length);\n return formatDigitsWithMap(template, digits).display;\n },\n\n getMaxDigits: () => maxDigits,\n\n getPlaceholder: () => {\n // Always use minimal mask as a placeholder\n const template = getMask(0);\n return template;\n },\n\n getCaretPosition: (digitIndex: number) => {\n const template = getMask(digitIndex);\n const { display, map } = formatDigitsWithMap(template, '0'.repeat(digitIndex));\n\n for (let i = 0; i < map.length; i++) {\n if (map[i] === digitIndex) return i;\n }\n if (digitIndex >= map.length) return display.length;\n\n for (let i = 0; i < map.length; i++) {\n if (map[i]! > digitIndex) return i;\n }\n return display.length;\n },\n\n getDigitRange: (digits: string, selStart: number, selEnd: number) => {\n const template = getMask(digits.length);\n const { map } = formatDigitsWithMap(template, digits);\n\n let min = Infinity;\n let max = -Infinity;\n\n for (let i = selStart; i < selEnd && i < map.length; i++) {\n const digitIdx = map[i];\n if (digitIdx !== undefined && digitIdx >= 0) {\n min = Math.min(min, digitIdx);\n max = Math.max(max, digitIdx);\n }\n }\n\n return min === Infinity ? null : [min, max + 1];\n },\n\n isComplete: (digits: string) => {\n return variantsDigits.includes(digits.length);\n }\n };\n}\n\n/**\n * Caret manipulation helper\n */\nexport function setCaret(el: HTMLInputElement | null, position: number): void {\n if (!el) return;\n try {\n el.setSelectionRange(position, position);\n } catch {\n // Silently fail if element doesn't support selection\n }\n}\n\n/**\n * Extract digits from any string\n */\nexport function extractDigits(value: string, maxLength?: number): string {\n const digits = value.replace(/\\D/g, '');\n return maxLength ? digits.slice(0, maxLength) : digits;\n}\n\n/**\n * Parse selection range for digit operations\n */\nexport function getSelection(el: HTMLInputElement | null): [number, number] {\n if (!el) return [0, 0];\n return [el.selectionStart ?? 0, el.selectionEnd ?? 0];\n}\n","export const Delimiters = [' ', '-', '(', ')'];\nexport const NavigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End', 'Tab'];\nexport const InvalidPattern = /[^\\d\\s\\-()]/;\n","import React, {\n useImperativeHandle,\n useRef,\n useState,\n useEffect,\n useCallback,\n useMemo,\n type CSSProperties,\n type Ref\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n getNavigatorLang,\n getCountry,\n getMasksFullMapByLocale,\n detectByGeoIp,\n type CountryKey,\n type MaskFull\n} from '@desource/phone-mask';\nimport { createPhoneFormatter, extractDigits, setCaret, getSelection } from '../utils';\nimport { Delimiters, NavigationKeys, InvalidPattern } from '../consts';\nimport type { PhoneInputProps, PhoneInputRef, PhoneNumber } from '../types';\n\n/** Get all countries */\nfunction getCountries(locale: string): MaskFull[] {\n const map = getMasksFullMapByLocale(locale);\n\n return Object.entries(map).map(([id, data]) => ({ id: id as CountryKey, ...data }));\n}\n\ntype PhoneInputComponent = PhoneInputProps & { ref?: Ref<PhoneInputRef> };\n\nexport const PhoneInput = ({ ref, ...props }: PhoneInputComponent) => {\n const {\n value = '',\n country: propCountry,\n detect = true,\n locale: propLocale,\n size = 'normal',\n theme = 'auto',\n disabled = false,\n readonly = false,\n showCopy = true,\n showClear = false,\n withValidity = true,\n searchPlaceholder = 'Search country or code...',\n noResultsText = 'No countries found',\n clearButtonLabel = 'Clear phone number',\n dropdownClass = '',\n disableDefaultStyles = false,\n onChange,\n onPhoneChange,\n onCountryChange,\n onValidationChange,\n onFocus,\n onBlur,\n onCopy,\n onClear,\n renderActionsBefore,\n renderFlag,\n renderCopySvg,\n renderClearSvg\n } = props;\n\n const telRef = useRef<HTMLInputElement>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const liveRef = useRef<HTMLDivElement>(null);\n const selectorRef = useRef<HTMLDivElement>(null);\n\n const locale = propLocale || getNavigatorLang();\n const [country, setCountry] = useState<MaskFull>(() => getCountry(propCountry || 'US', locale));\n const [digits, setDigits] = useState<string>('');\n const [dropdownOpen, setDropdownOpen] = useState(false);\n const [isClosing, setIsClosing] = useState(false);\n const [search, setSearch] = useState('');\n const [focusedIndex, setFocusedIndex] = useState(0);\n const [copied, setCopied] = useState(false);\n const [isCopying, setIsCopying] = useState(false);\n const [dropdownStyle, setDropdownStyle] = useState<CSSProperties>({});\n const [showValidationHint, setShowValidationHint] = useState(false);\n const validationTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const copyTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [hasDropdown, setHasDropdown] = useState<boolean>(!propCountry);\n\n const formatter = useMemo(() => createPhoneFormatter(country), [country]);\n const countries = useMemo(() => getCountries(locale), [locale]);\n\n const displayValue = formatter.formatDisplay(digits);\n const displayPlaceholder = formatter.getPlaceholder();\n const isComplete = formatter.isComplete(digits);\n const isEmpty = digits.length === 0;\n const shouldShowWarn = showValidationHint && !isEmpty && !isComplete;\n\n const full = `${country.code}${digits}`;\n const fullFormatted = digits ? `${country.code} ${displayValue}` : '';\n\n const filteredCountries = useMemo(() => {\n const raw = search.trim();\n if (!raw) return countries;\n const q = raw.toUpperCase();\n const qDigits = q.replace(/\\D/g, '');\n const isNumeric = qDigits.length > 0;\n\n return countries\n .map((c) => {\n const nameUpper = c.name.toUpperCase();\n const idUpper = c.id.toUpperCase();\n const codeUpper = c.code.toUpperCase();\n const codeDigits = c.code.replace(/\\D/g, '');\n let score = 0;\n if (nameUpper.startsWith(q)) score = 1000;\n else if (nameUpper.includes(q)) score = 500;\n\n if (codeUpper.startsWith(q)) score += 100;\n else if (codeUpper.includes(q)) score += 50;\n\n if (idUpper === q) score += 200;\n else if (idUpper.startsWith(q)) score += 150;\n\n if (isNumeric && codeDigits.startsWith(qDigits)) score += 80;\n else if (isNumeric && codeDigits.includes(qDigits)) score += 40;\n\n return { country: c, score };\n })\n .filter((x) => x.score > 0)\n .sort((a, b) => (b.score !== a.score ? b.score - a.score : a.country.name.localeCompare(b.country.name)))\n .map((x) => x.country);\n }, [countries, search]);\n\n const inactive = disabled || readonly;\n const showCopyButton = showCopy && !isEmpty && !disabled;\n const showClearButton = showClear && !isEmpty && !inactive;\n\n // Country initialization and detection with cache + locale fallback\n useEffect(() => {\n setHasDropdown(!propCountry && countries.length > 1);\n\n const hasCountry = (code?: string | null) => {\n if (!code) return false;\n const id = code.toUpperCase();\n return countries.some((c) => c.id === id);\n };\n\n const detectFromLocale = (): string | null => {\n const lang = typeof navigator !== 'undefined' && navigator.language ? navigator.language : '';\n // Use Intl.Locale when available\n try {\n if (Intl.Locale) {\n const loc = new Intl.Locale(lang);\n if (loc?.region && hasCountry(loc.region)) return loc.region.toUpperCase();\n }\n } catch {\n /* ignore */\n }\n const parts = lang.split(/[-_]/);\n if (parts.length > 1 && hasCountry(parts[1])) return parts[1].toUpperCase();\n return null;\n };\n\n (async () => {\n if (propCountry && hasCountry(propCountry)) {\n const newCountry = getCountry(propCountry, locale);\n setCountry((prev) => {\n if (prev.id === newCountry.id) return prev;\n onCountryChange?.(newCountry);\n return newCountry;\n });\n return;\n }\n if (!detect) return;\n const geo = await detectByGeoIp(hasCountry);\n if (geo) {\n const detected = getCountry(geo, locale);\n setCountry((prev) => {\n if (prev.id === detected.id) return prev;\n onCountryChange?.(detected);\n return detected;\n });\n return;\n }\n const loc = detectFromLocale();\n if (loc) {\n const detected = getCountry(loc, locale);\n setCountry((prev) => {\n if (prev.id === detected.id) return prev;\n onCountryChange?.(detected);\n return detected;\n });\n }\n })();\n }, [propCountry, detect, countries, locale]);\n\n // Clamp digits when country or formatter changes\n useEffect(() => {\n const maxDigits = formatter.getMaxDigits();\n if (digits.length > maxDigits) {\n setDigits((d) => d.slice(0, maxDigits));\n }\n }, [formatter]);\n\n // Sync value prop\n useEffect(() => {\n const incomingDigits = extractDigits(value || '');\n if (incomingDigits !== digits) {\n setDigits(incomingDigits);\n }\n }, [value]);\n\n // Notify validation changes\n useEffect(() => {\n onValidationChange?.(isComplete);\n }, [isComplete, onValidationChange]);\n\n // Emit onChange and onPhoneChange\n const emitChange = useCallback(() => {\n onChange?.(digits);\n const phoneData: PhoneNumber = { full, fullFormatted, digits };\n onPhoneChange?.(phoneData);\n }, [digits, full, fullFormatted, onChange, onPhoneChange]);\n\n useEffect(() => {\n emitChange();\n }, [emitChange]);\n\n // Input handlers\n const handleBeforeInput = useCallback((e: InputEvent) => {\n const data = e.data;\n if (e.inputType !== 'insertText' || !data) return;\n const el = telRef.current;\n if (!el) return;\n if (InvalidPattern.test(data) || (data === ' ' && el.value.endsWith(' '))) {\n e.preventDefault();\n }\n }, []);\n\n const handleInput = useCallback(() => {\n const el = telRef.current;\n if (!el || inactive) return;\n const raw = el.value || '';\n const maxDigits = formatter.getMaxDigits();\n const newDigits = extractDigits(raw, maxDigits);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(newDigits.length);\n setCaret(el, pos);\n }, 0);\n // validation hint debounce (500ms)\n setShowValidationHint(false);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n if (newDigits.length > 0) {\n validationTimerRef.current = setTimeout(() => {\n setShowValidationHint(true);\n }, 500);\n }\n }, [formatter, inactive]);\n\n const handleKeydown = useCallback(\n (e: KeyboardEvent) => {\n if (inactive) return;\n const el = telRef.current;\n if (!el) return;\n\n if (e.ctrlKey || e.metaKey || e.altKey || NavigationKeys.includes(e.key)) return;\n\n const [selStart, selEnd] = getSelection(el);\n\n // debounce validation hint during typing (300ms)\n setShowValidationHint(false);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n const scheduleHint = () => {\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n validationTimerRef.current = setTimeout(() => {\n setShowValidationHint(true);\n }, 300);\n };\n\n if (e.key === 'Backspace') {\n e.preventDefault();\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n if (range) {\n const [start, end] = range;\n setDigits(digits.slice(0, start) + digits.slice(end));\n setTimeout(() => setCaret(el, formatter.getCaretPosition(start)), 0);\n }\n } else if (selStart > 0) {\n let prevPos = selStart - 1;\n while (prevPos >= 0 && Delimiters.includes(el.value[prevPos]!)) prevPos--;\n if (prevPos >= 0) {\n const range = formatter.getDigitRange(digits, prevPos, prevPos + 1);\n if (range) {\n const [start] = range;\n setDigits(digits.slice(0, start) + digits.slice(start + 1));\n setTimeout(() => setCaret(el, formatter.getCaretPosition(start)), 0);\n }\n }\n }\n scheduleHint();\n return;\n }\n\n if (e.key === 'Delete') {\n e.preventDefault();\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n if (range) {\n const [start, end] = range;\n setDigits(digits.slice(0, start) + digits.slice(end));\n setTimeout(() => setCaret(el, formatter.getCaretPosition(start)), 0);\n }\n } else if (selStart < el.value.length) {\n const range = formatter.getDigitRange(digits, selStart, selStart + 1);\n if (range) {\n const [start] = range;\n setDigits(digits.slice(0, start) + digits.slice(start + 1));\n setTimeout(() => setCaret(el, formatter.getCaretPosition(start)), 0);\n }\n }\n scheduleHint();\n return;\n }\n\n if (/^[0-9]$/.test(e.key)) {\n if (digits.length >= formatter.getMaxDigits()) e.preventDefault();\n scheduleHint();\n return;\n }\n\n if (e.key.length === 1) e.preventDefault();\n scheduleHint();\n },\n [inactive, formatter, digits]\n );\n\n const handlePaste = useCallback(\n (e: ClipboardEvent) => {\n if (inactive) return;\n e.preventDefault();\n const el = telRef.current;\n if (!el) return;\n\n const text = e.clipboardData?.getData('text') || '';\n const maxDigits = formatter.getMaxDigits();\n const pastedDigits = extractDigits(text, maxDigits);\n if (!pastedDigits) return;\n\n const [selStart, selEnd] = getSelection(el);\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n if (range) {\n const [start, end] = range;\n const newDigits = extractDigits(digits.slice(0, start) + pastedDigits + digits.slice(end), maxDigits);\n setDigits(newDigits);\n setTimeout(() => setCaret(el, formatter.getCaretPosition(start + pastedDigits.length)), 0);\n }\n } else {\n const range = formatter.getDigitRange(digits, selStart, selStart);\n const insertIndex = range ? range[0] : digits.length;\n const newDigits = extractDigits(\n digits.slice(0, insertIndex) + pastedDigits + digits.slice(insertIndex),\n maxDigits\n );\n setDigits(newDigits);\n setTimeout(() => setCaret(el, formatter.getCaretPosition(insertIndex + pastedDigits.length)), 0);\n }\n // show validation hint after paste (300ms)\n setShowValidationHint(false);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n validationTimerRef.current = setTimeout(() => {\n setShowValidationHint(true);\n }, 300);\n },\n [inactive, formatter, digits]\n );\n\n // Close dropdown with animation\n const closeDropdown = useCallback(() => {\n if (!dropdownOpen) return;\n setIsClosing(true);\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n closeTimerRef.current = setTimeout(() => {\n setDropdownOpen(false);\n setIsClosing(false);\n }, 200);\n }, [dropdownOpen]);\n\n // Input focus behavior (close dropdown, keep existing hint state)\n const handleFocusInput = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n closeDropdown();\n onFocus?.(e);\n },\n [onFocus, closeDropdown]\n );\n\n // Attach native event listeners\n useEffect(() => {\n const el = telRef.current;\n if (!el) return;\n\n const beforeInputHandler = handleBeforeInput as unknown as (evt: Event) => void;\n const keydownHandler = handleKeydown as unknown as (evt: Event) => void;\n const pasteHandler = handlePaste as unknown as (evt: Event) => void;\n\n el.addEventListener('beforeinput', beforeInputHandler);\n el.addEventListener('keydown', keydownHandler);\n el.addEventListener('paste', pasteHandler);\n\n return () => {\n el.removeEventListener('beforeinput', beforeInputHandler);\n el.removeEventListener('keydown', keydownHandler);\n el.removeEventListener('paste', pasteHandler);\n };\n }, [handleBeforeInput, handleKeydown, handlePaste]);\n\n // Country selection\n const selectCountry = useCallback(\n (code: CountryKey) => {\n const newCountry = getCountry(code, locale);\n setCountry(newCountry);\n closeDropdown();\n setSearch('');\n setFocusedIndex(0);\n onCountryChange?.(newCountry);\n setTimeout(() => telRef.current?.focus(), 0);\n },\n [locale, onCountryChange, closeDropdown]\n );\n\n // Dropdown positioning\n const positionDropdown = useCallback(() => {\n if (!rootRef.current) return;\n const rect = rootRef.current.getBoundingClientRect();\n setDropdownStyle({\n top: `${rect.bottom + window.scrollY + 8}px`,\n left: `${rect.left + window.scrollX}px`,\n width: `${rect.width}px`\n });\n }, []);\n\n useEffect(() => {\n if (!dropdownOpen) return;\n\n positionDropdown();\n const focusTimer = setTimeout(() => searchRef.current?.focus({ preventScroll: true }), 0);\n\n const onDocClick = (ev: Event) => {\n const target = ev.target as Node | null;\n const dropdownEl = dropdownRef.current;\n const selectorEl = selectorRef.current;\n if (!target) return;\n if (dropdownEl?.contains(target)) return;\n if (selectorEl?.contains(target)) return;\n closeDropdown();\n };\n\n window.addEventListener('resize', positionDropdown);\n window.addEventListener('scroll', positionDropdown, true);\n window.addEventListener('click', onDocClick, true);\n\n return () => {\n clearTimeout(focusTimer);\n window.removeEventListener('resize', positionDropdown);\n window.removeEventListener('scroll', positionDropdown, true);\n window.removeEventListener('click', onDocClick, true);\n };\n }, [dropdownOpen, positionDropdown, closeDropdown]);\n\n // Cleanup timers\n useEffect(() => {\n return () => {\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n if (copyTimerRef.current) clearTimeout(copyTimerRef.current);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n };\n }, []);\n\n // Copy functionality\n const handleCopyClick = useCallback(async () => {\n if (isCopying) return;\n const trimmedValue = fullFormatted.trim();\n if (!trimmedValue) return;\n\n setIsCopying(true);\n try {\n await navigator.clipboard.writeText(trimmedValue);\n setCopied(true);\n onCopy?.(trimmedValue);\n if (liveRef.current) liveRef.current.textContent = 'Phone number copied to clipboard';\n\n if (copyTimerRef.current) clearTimeout(copyTimerRef.current);\n copyTimerRef.current = setTimeout(() => {\n setCopied(false);\n copyTimerRef.current = null;\n }, 1800);\n } catch (err) {\n console.warn('Copy failed', err);\n } finally {\n setIsCopying(false);\n }\n }, [fullFormatted, onCopy, isCopying]);\n\n // Clear functionality\n const handleClearClick = useCallback(() => {\n setDigits('');\n setShowValidationHint(false);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n onChange?.('');\n onPhoneChange?.({ full: '', fullFormatted: '', digits: '' });\n onClear?.();\n setTimeout(() => telRef.current?.focus(), 0);\n }, [onChange, onPhoneChange, onClear]);\n\n // Imperative handle\n useImperativeHandle(\n ref,\n () => ({\n focus: () => telRef.current?.focus(),\n blur: () => telRef.current?.blur(),\n clear: () => {\n setDigits('');\n setShowValidationHint(false);\n if (validationTimerRef.current) clearTimeout(validationTimerRef.current);\n onChange?.('');\n onPhoneChange?.({ full: '', fullFormatted: '', digits: '' });\n onClear?.();\n },\n selectCountry,\n getFullNumber: () => full,\n getFullFormattedNumber: () => fullFormatted,\n getDigits: () => digits,\n isValid: () => isComplete,\n isComplete: () => isComplete\n }),\n [selectCountry, full, fullFormatted, digits, isComplete, onClear, onChange, onPhoneChange]\n );\n\n const scrollFocusedIntoView = (index: number) => {\n setTimeout(() => {\n const list = dropdownRef.current?.lastElementChild;\n const option = list?.children[index];\n if (!list || !option) return;\n\n // Scroll only the list container with smooth behavior\n const listRect = list.getBoundingClientRect();\n const optionRect = option.getBoundingClientRect();\n\n let scrollAmount = 0;\n\n if (optionRect.top < listRect.top) {\n scrollAmount = list.scrollTop - (listRect.top - optionRect.top); // Option is above visible area\n } else if (optionRect.bottom > listRect.bottom) {\n scrollAmount = list.scrollTop + (optionRect.bottom - listRect.bottom); // Option is below visible area\n } else {\n return; // Already visible, no need to scroll\n }\n\n list.scrollTo({ top: scrollAmount, behavior: 'smooth' });\n }, 0);\n };\n\n // Keyboard navigation for dropdown\n const handleSearchKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setFocusedIndex((i) => {\n const next = Math.min(i + 1, filteredCountries.length - 1);\n scrollFocusedIntoView(next);\n return next;\n });\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setFocusedIndex((i) => {\n const prev = Math.max(i - 1, 0);\n scrollFocusedIntoView(prev);\n return prev;\n });\n } else if (e.key === 'Enter' && filteredCountries[focusedIndex]) {\n e.preventDefault();\n selectCountry(filteredCountries[focusedIndex]!.id);\n } else if (e.key === 'Escape') {\n closeDropdown();\n }\n },\n [filteredCountries, focusedIndex, selectCountry, closeDropdown]\n );\n\n // Theme class\n const themeClass = useMemo(() => {\n if (theme !== 'auto') return `theme-${theme}`;\n if (typeof window !== 'undefined' && window.matchMedia?.('(prefers-color-scheme: dark)').matches) {\n return 'theme-dark';\n }\n return 'theme-light';\n }, [theme]);\n\n const rootClasses = [\n 'phone-input',\n `size-${size}`,\n themeClass,\n disabled && 'is-disabled',\n readonly && 'is-readonly',\n disableDefaultStyles && 'is-unstyled',\n withValidity && shouldShowWarn && 'is-incomplete',\n withValidity && isComplete && 'is-complete'\n ]\n .filter(Boolean)\n .join(' ');\n\n const actionsCount = +showCopyButton + +showClearButton + (renderActionsBefore ? 1 : 0);\n\n return (\n <>\n <div\n ref={rootRef}\n className={rootClasses}\n style={{ '--pi-actions-count': actionsCount } as CSSProperties}\n role=\"group\"\n aria-label=\"Phone input with country selector\"\n >\n {/* Country Selector */}\n <div className=\"pi-selector\" ref={selectorRef}>\n <button\n type=\"button\"\n className={`pi-selector-btn ${!hasDropdown || readonly ? 'no-dropdown' : ''}`}\n disabled={disabled}\n tabIndex={inactive || !hasDropdown ? -1 : undefined}\n aria-label={`Selected country: ${country.name}`}\n aria-expanded={dropdownOpen}\n aria-haspopup={hasDropdown ? 'listbox' : undefined}\n onClick={() => {\n if (inactive || !hasDropdown) return;\n if (dropdownOpen) {\n closeDropdown();\n } else {\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n setIsClosing(false);\n setDropdownOpen(true);\n setFocusedIndex(0);\n }\n }}\n >\n <span className=\"pi-flag\" role=\"img\" aria-label={`${country.name} flag`}>\n {renderFlag ? renderFlag(country) : country.flag}\n </span>\n <span className=\"pi-code\">{country.code}</span>\n {!inactive && hasDropdown && (\n <svg\n className={`pi-chevron ${dropdownOpen ? 'is-open' : ''}`}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <path\n d=\"M2.5 4.5L6 8L9.5 4.5\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )}\n </button>\n </div>\n\n {/* Input Container */}\n <div className=\"pi-input-wrap\">\n <input\n ref={telRef}\n type=\"tel\"\n inputMode=\"tel\"\n autoComplete=\"tel-national\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n className=\"pi-input\"\n placeholder={displayPlaceholder}\n value={displayValue}\n disabled={disabled}\n readOnly={readonly}\n aria-invalid={shouldShowWarn}\n onInput={handleInput}\n onFocus={handleFocusInput}\n onBlur={onBlur}\n />\n\n {/* Action Buttons */}\n <div className=\"pi-actions\" role=\"toolbar\" aria-label=\"Phone input actions\">\n {renderActionsBefore && renderActionsBefore()}\n\n {showCopyButton && (\n <button\n type=\"button\"\n className={`pi-btn ${copied ? 'is-copied' : ''}`}\n aria-label={copied ? 'Copied' : `Copy ${country.code} ${displayValue}`}\n title={copied ? 'Copied' : 'Copy phone number'}\n onClick={handleCopyClick}\n >\n {renderCopySvg ? (\n renderCopySvg(copied)\n ) : copied ? (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z\" fill=\"currentColor\" />\n </svg>\n ) : (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n <path\n 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\"\n fill=\"currentColor\"\n />\n </svg>\n )}\n </button>\n )}\n\n {showClearButton && (\n <button\n type=\"button\"\n className=\"pi-btn\"\n aria-label={clearButtonLabel}\n title={clearButtonLabel}\n onClick={handleClearClick}\n >\n {renderClearSvg ? (\n renderClearSvg()\n ) : (\n <svg width=\"11\" height=\"11\" viewBox=\"0 0 14 14\" fill=\"none\" aria-hidden=\"true\">\n <path\n 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\"\n fill=\"currentColor\"\n />\n </svg>\n )}\n </button>\n )}\n </div>\n </div>\n </div>\n\n {/* Dropdown */}\n {dropdownOpen &&\n typeof document !== 'undefined' &&\n createPortal(\n <div\n ref={dropdownRef}\n className={`phone-dropdown ${dropdownClass} ${themeClass} ${isClosing ? 'is-closing' : ''}`}\n style={dropdownStyle}\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label=\"Select country\"\n >\n <div className=\"pi-search-wrap\">\n <input\n ref={searchRef}\n type=\"search\"\n className=\"pi-search\"\n aria-label=\"Search countries\"\n placeholder={searchPlaceholder}\n value={search}\n onChange={(e) => {\n setSearch(e.target.value);\n setFocusedIndex(0);\n }}\n onKeyDown={handleSearchKeydown}\n />\n </div>\n <ul className=\"pi-options\" role=\"listbox\" aria-activedescendant={`option-${focusedIndex}`} tabIndex={-1}>\n {filteredCountries.length > 0 ? (\n filteredCountries.map((c, idx) => (\n <li\n key={c.id}\n id={`option-${idx}`}\n role=\"option\"\n className={`pi-option ${idx === focusedIndex ? 'is-focused' : ''} ${\n c.id === country.id ? 'is-selected' : ''\n }`}\n aria-selected={c.id === country.id}\n title={c.name}\n onClick={() => selectCountry(c.id)}\n onMouseEnter={() => setFocusedIndex(idx)}\n >\n <span className=\"pi-flag\" role=\"img\" aria-label={`${c.name} flag`}>\n {renderFlag ? renderFlag(c) : c.flag}\n </span>\n <span className=\"pi-opt-name\">{c.name}</span>\n <span className=\"pi-opt-code\">{c.code}</span>\n </li>\n ))\n ) : (\n <li className=\"pi-empty\">{noResultsText}</li>\n )}\n </ul>\n </div>,\n document.body\n )}\n\n {/* Screen reader announcements */}\n <div ref={liveRef} className=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" />\n </>\n );\n};\n\nPhoneInput.displayName = 'PhoneInput';\n","import { useRef, useState, useEffect, useCallback } from 'react';\nimport { getNavigatorLang, getCountry, detectCountryFromGeoIP, type MaskFull } from '@desource/phone-mask';\nimport { createPhoneFormatter, extractDigits, getSelection, setCaret } from '../utils';\nimport { Delimiters, InvalidPattern, NavigationKeys } from '../consts';\nimport type { UsePhoneMaskOptions, UsePhoneMaskReturn, PhoneNumber } from '../types';\n\n/**\n * Detect country from browser locale.\n */\nfunction detectCountryFromLocale(): string | null {\n try {\n const lang = getNavigatorLang();\n\n try {\n const loc = new Intl.Locale(lang);\n if (loc.region) return loc.region.toUpperCase();\n } catch {\n // Ignore\n }\n\n const parts = lang.split(/[-_]/);\n if (parts.length > 1) return parts[1]?.toUpperCase() || null;\n } catch {\n // Ignore\n }\n\n return null;\n}\n\n/**\n * React hook for phone number masking.\n * Provides low-level phone masking functionality for custom input implementations.\n */\nexport function usePhoneMask(options: UsePhoneMaskOptions = {}): UsePhoneMaskReturn {\n const inputRef = useRef<HTMLInputElement>(null);\n const [digits, setDigits] = useState<string>('');\n const [country, setCountryState] = useState<MaskFull>(() => {\n const locale = options.locale || getNavigatorLang();\n return getCountry(options.country || 'US', locale);\n });\n\n const locale = options.locale || getNavigatorLang();\n const formatter = createPhoneFormatter(country);\n\n const displayValue = formatter.formatDisplay(digits);\n const full = `${country.code}${digits}`;\n const fullFormatted = digits ? `${country.code} ${displayValue}` : '';\n const isComplete = formatter.isComplete(digits);\n const isEmpty = digits.length === 0;\n const shouldShowWarn = !isEmpty && !isComplete;\n\n // Initialize country detection\n useEffect(() => {\n if (!options.detect) return;\n\n (async () => {\n const geoCountry = await detectCountryFromGeoIP();\n if (geoCountry) {\n const detected = getCountry(geoCountry, locale);\n setCountryState(detected);\n options.onCountryChange?.(detected);\n return;\n }\n\n const localeCountry = detectCountryFromLocale();\n if (localeCountry) {\n const detected = getCountry(localeCountry, locale);\n setCountryState(detected);\n options.onCountryChange?.(detected);\n }\n })();\n }, [options.detect]);\n\n // Sync country when prop changes\n useEffect(() => {\n if (options.country) {\n const newCountry = getCountry(options.country, locale);\n if (newCountry.id !== country.id) {\n setCountryState(newCountry);\n options.onCountryChange?.(newCountry);\n }\n }\n }, [options.country, locale]);\n\n // Update display when digits or country change\n useEffect(() => {\n const el = inputRef.current;\n if (!el) return;\n\n el.value = displayValue;\n el.placeholder = formatter.getPlaceholder();\n }, [displayValue, formatter]);\n\n // Notify onChange callback\n useEffect(() => {\n if (options.onChange) {\n const phoneData: PhoneNumber = {\n full,\n fullFormatted,\n digits\n };\n options.onChange(phoneData);\n }\n }, [digits, full, fullFormatted]);\n\n // Event handler: beforeinput\n const handleBeforeInput = useCallback((e: InputEvent) => {\n const data = e.data;\n if (e.inputType !== 'insertText' || !data) return;\n\n const el = inputRef.current;\n if (!el) return;\n\n // Block invalid characters & multiple spaces\n if (InvalidPattern.test(data) || (data === ' ' && el.value.endsWith(' '))) {\n e.preventDefault();\n }\n }, []);\n\n // Event handler: input\n const handleInput = useCallback(() => {\n const el = inputRef.current;\n if (!el) return;\n\n const raw = el.value || '';\n const maxDigits = formatter.getMaxDigits();\n const newDigits = extractDigits(raw, maxDigits);\n\n setDigits(newDigits);\n\n // Set caret position after state update\n setTimeout(() => {\n const pos = formatter.getCaretPosition(newDigits.length);\n setCaret(el, pos);\n }, 0);\n }, [formatter]);\n\n // Event handler: keydown\n const handleKeydown = useCallback(\n (e: KeyboardEvent) => {\n const el = inputRef.current;\n if (!el) return;\n\n // Allow meta & navigation keys\n if (e.ctrlKey || e.metaKey || e.altKey || NavigationKeys.includes(e.key)) return;\n\n const [selStart, selEnd] = getSelection(el);\n\n if (e.key === 'Backspace') {\n e.preventDefault();\n\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n if (range) {\n const [start, end] = range;\n const newDigits = digits.slice(0, start) + digits.slice(end);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(start);\n setCaret(el, pos);\n }, 0);\n }\n return;\n }\n\n if (selStart > 0) {\n const displayStr = el.value;\n let prevPos = selStart - 1;\n while (prevPos >= 0 && Delimiters.includes(displayStr[prevPos]!)) {\n prevPos--;\n }\n\n if (prevPos >= 0) {\n const range = formatter.getDigitRange(digits, prevPos, prevPos + 1);\n if (range) {\n const [start] = range;\n const newDigits = digits.slice(0, start) + digits.slice(start + 1);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(start);\n setCaret(el, pos);\n }, 0);\n }\n }\n }\n return;\n }\n\n if (e.key === 'Delete') {\n e.preventDefault();\n\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n if (range) {\n const [start, end] = range;\n const newDigits = digits.slice(0, start) + digits.slice(end);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(start);\n setCaret(el, pos);\n }, 0);\n }\n return;\n }\n\n if (selStart < el.value.length) {\n const range = formatter.getDigitRange(digits, selStart, selStart + 1);\n if (range) {\n const [start] = range;\n const newDigits = digits.slice(0, start) + digits.slice(start + 1);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(start);\n setCaret(el, pos);\n }, 0);\n }\n }\n return;\n }\n\n // Block max digits\n if (/^[0-9]$/.test(e.key)) {\n if (digits.length >= formatter.getMaxDigits()) {\n e.preventDefault();\n }\n return;\n }\n\n // Block non-numeric\n if (e.key.length === 1) {\n e.preventDefault();\n }\n },\n [digits, formatter]\n );\n\n // Event handler: paste\n const handlePaste = useCallback(\n (e: ClipboardEvent) => {\n e.preventDefault();\n\n const el = inputRef.current;\n if (!el) return;\n\n const text = e.clipboardData?.getData('text') || '';\n const maxDigits = formatter.getMaxDigits();\n const pastedDigits = extractDigits(text, maxDigits);\n\n if (pastedDigits.length === 0) return;\n\n const [selStart, selEnd] = getSelection(el);\n\n if (selStart !== selEnd) {\n const range = formatter.getDigitRange(digits, selStart, selEnd);\n\n if (range) {\n const [start, end] = range;\n const left = digits.slice(0, start);\n const right = digits.slice(end);\n const newDigits = extractDigits(left + pastedDigits + right, maxDigits);\n setDigits(newDigits);\n setTimeout(() => {\n const pos = formatter.getCaretPosition(start + pastedDigits.length);\n setCaret(el, pos);\n }, 0);\n return;\n }\n }\n\n const range = formatter.getDigitRange(digits, selStart, selStart);\n const insertIndex = range ? range[0] : digits.length;\n\n const left = digits.slice(0, insertIndex);\n const right = digits.slice(insertIndex);\n const newDigits = extractDigits(left + pastedDigits + right, maxDigits);\n setDigits(newDigits);\n\n setTimeout(() => {\n const pos = formatter.getCaretPosition(insertIndex + pastedDigits.length);\n setCaret(el, pos);\n }, 0);\n },\n [digits, formatter]\n );\n\n // Attach event listeners\n useEffect(() => {\n const el = inputRef.current;\n if (!el) return;\n\n el.setAttribute('type', 'tel');\n el.setAttribute('inputmode', 'tel');\n el.setAttribute('placeholder', formatter.getPlaceholder());\n\n const beforeInputHandler = handleBeforeInput as unknown as (evt: Event) => void;\n const keydownHandler = handleKeydown as unknown as (evt: Event) => void;\n const pasteHandler = handlePaste as unknown as (evt: Event) => void;\n\n el.addEventListener('beforeinput', beforeInputHandler);\n el.addEventListener('input', handleInput);\n el.addEventListener('keydown', keydownHandler);\n el.addEventListener('paste', pasteHandler);\n\n return () => {\n el.removeEventListener('beforeinput', beforeInputHandler);\n el.removeEventListener('input', handleInput);\n el.removeEventListener('keydown', keydownHandler);\n el.removeEventListener('paste', pasteHandler);\n };\n }, [handleBeforeInput, handleInput, handleKeydown, handlePaste, formatter]);\n\n const setCountry = useCallback(\n (countryCode: string) => {\n const newCountry = getCountry(countryCode, locale);\n setCountryState(newCountry);\n const newFormatter = createPhoneFormatter(newCountry);\n const maxDigits = newFormatter.getMaxDigits();\n if (digits.length > maxDigits) {\n setDigits(digits.slice(0, maxDigits));\n }\n options.onCountryChange?.(newCountry);\n },\n [locale, digits, options]\n );\n\n const clear = useCallback(() => {\n setDigits('');\n const el = inputRef.current;\n if (el) {\n el.value = '';\n }\n }, []);\n\n return {\n ref: inputRef,\n digits,\n full,\n fullFormatted,\n isComplete,\n isEmpty,\n shouldShowWarn,\n country,\n setCountry,\n clear\n };\n}\n","import {\n getFlagEmoji,\n countPlaceholders,\n formatDigitsWithMap,\n pickMaskVariant,\n removeCountryCodePrefix,\n toArray\n} from '@desource/phone-mask';\n\nexport { PhoneInput } from './components/PhoneInput';\nexport { usePhoneMask } from './hooks/usePhoneMask';\nexport type {\n PhoneInputProps,\n PhoneInputRef,\n PhoneNumber,\n UsePhoneMaskOptions,\n UsePhoneMaskReturn,\n Size as PhoneInputSize,\n Theme as PhoneInputTheme\n} from './types';\n\nexport type {\n CountryKey as PCountryKey,\n MaskBase as PMaskBase,\n MaskBaseMap as PMaskBaseMap,\n Mask as PMask,\n MaskMap as PMaskMap,\n MaskWithFlag as PMaskWithFlag,\n MaskWithFlagMap as PMaskWithFlagMap,\n MaskFull as PMaskFull,\n MaskFullMap as PMaskFullMap\n} from '@desource/phone-mask';\n\nexport const PMaskHelpers = {\n getFlagEmoji,\n countPlaceholders,\n formatDigitsWithMap,\n pickMaskVariant,\n removeCountryCodePrefix,\n toArray\n};\n"],"names":["M","t","countryCodeEmoji","o","e","divideMask","getCodeAndMask","n","s","a","MasksFullMap","r","m","g","getNavigatorLang","getMasksFullMapByLocale","getCountry","toArray","countPlaceholders","removeCountryCodePrefix","pickMaskVariant","formatDigitsWithMap","i","u","p","detectCountryFromGeoIP","c","detectByGeoIp","createPhoneFormatter","country","variants","variantsDigits","maxDigits","getMask","digitLength","mask","digits","template","digitIndex","display","map","selStart","selEnd","min","max","digitIdx","setCaret","el","position","extractDigits","value","maxLength","getSelection","Delimiters","NavigationKeys","InvalidPattern","getCountries","locale","id","data","PhoneInput","ref","props","propCountry","detect","propLocale","size","theme","disabled","readonly","showCopy","showClear","withValidity","searchPlaceholder","noResultsText","clearButtonLabel","dropdownClass","disableDefaultStyles","onChange","onPhoneChange","onCountryChange","onValidationChange","onFocus","onBlur","onCopy","onClear","renderActionsBefore","renderFlag","renderCopySvg","renderClearSvg","telRef","useRef","rootRef","dropdownRef","searchRef","liveRef","selectorRef","setCountry","useState","setDigits","dropdownOpen","setDropdownOpen","isClosing","setIsClosing","search","setSearch","focusedIndex","setFocusedIndex","copied","setCopied","isCopying","setIsCopying","dropdownStyle","setDropdownStyle","showValidationHint","setShowValidationHint","validationTimerRef","closeTimerRef","copyTimerRef","hasDropdown","setHasDropdown","formatter","useMemo","countries","displayValue","displayPlaceholder","isComplete","isEmpty","shouldShowWarn","full","fullFormatted","filteredCountries","raw","q","qDigits","isNumeric","nameUpper","idUpper","codeUpper","codeDigits","score","x","b","inactive","showCopyButton","showClearButton","useEffect","hasCountry","code","detectFromLocale","lang","loc","parts","newCountry","prev","geo","detected","d","incomingDigits","emitChange","useCallback","handleBeforeInput","handleInput","newDigits","pos","handleKeydown","scheduleHint","range","start","end","prevPos","handlePaste","text","pastedDigits","insertIndex","closeDropdown","handleFocusInput","beforeInputHandler","keydownHandler","pasteHandler","selectCountry","positionDropdown","rect","focusTimer","onDocClick","ev","target","dropdownEl","selectorEl","handleCopyClick","trimmedValue","err","handleClearClick","useImperativeHandle","scrollFocusedIntoView","index","list","option","listRect","optionRect","scrollAmount","handleSearchKeydown","next","themeClass","rootClasses","actionsCount","jsxs","Fragment","jsx","createPortal","idx","detectCountryFromLocale","usePhoneMask","options","inputRef","setCountryState","geoCountry","localeCountry","phoneData","displayStr","left","right","countryCode","clear","PMaskHelpers","getFlagEmoji"],"mappings":";;;AAAA,MAAMA,KAAE,EAAC,IAAG,cAAa,IAAG,CAAC,gBAAe,gBAAgB,GAAE,IAAG,CAAC,mBAAkB,oBAAmB,mBAAkB,kBAAkB,GAAE,IAAG,mBAAkB,IAAG,mBAAkB,IAAG,mBAAkB,IAAG,CAAC,mBAAkB,oBAAmB,iBAAgB,gBAAe,gBAAgB,GAAE,IAAG,CAAC,kBAAiB,iBAAiB,GAAE,IAAG,oBAAmB,IAAG,CAAC,oBAAmB,sBAAqB,kBAAkB,GAAE,IAAG,mBAAkB,IAAG,CAAC,mBAAkB,gBAAgB,GAAE,IAAG,CAAC,mBAAkB,mBAAkB,oBAAmB,eAAe,GAAE,IAAG,iBAAgB,IAAG,CAAC,mBAAkB,iBAAiB,GAAE,IAAG,CAAC,qBAAoB,mBAAmB,GAAE,IAAG,CAAC,mBAAkB,iBAAiB,GAAE,IAAG,mBAAkB,IAAG,CAAC,kBAAiB,oBAAmB,kBAAkB,GAAE,IAAG,CAAC,mBAAkB,oBAAm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AG,oBAAoB,WAAWmI,CAAc,GAChDnI,EAAG,oBAAoB,SAASoI,CAAY;AAAA,IAC9C;AAAA,EACF,GAAG,CAAClB,IAAmBC,IAAaG,IAAeM,IAAalD,CAAS,CAAC;AAE1E,QAAMxB,IAAa+D;AAAA,IACjB,CAAC8D,MAAwB;AACvB,YAAMrE,IAAazI,EAAW8M,GAAarK,CAAM;AACjD,MAAA8J,EAAgB9D,CAAU;AAE1B,YAAMzH,IADeJ,GAAqB6H,CAAU,EACrB,aAAA;AAC/B,MAAIrH,EAAO,SAASJ,KAClBmE,EAAU/D,EAAO,MAAM,GAAGJ,CAAS,CAAC,GAEtCqL,EAAQ,kBAAkB5D,CAAU;AAAA,IACtC;AAAA,IACA,CAAChG,GAAQrB,GAAQiL,CAAO;AAAA,EAAA,GAGpBU,IAAQ/D,EAAY,MAAM;AAC9B,IAAA7D,EAAU,EAAE;AACZ,UAAMpD,IAAKuK,EAAS;AACpB,IAAIvK,MACFA,EAAG,QAAQ;AAAA,EAEf,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL,KAAKuK;AAAA,IACL,QAAAlL;AAAA,IACA,MAAA6F;AAAA,IACA,eAAAC;AAAA,IACA,YAAAJ;AAAA,IACA,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,SAAAnG;AAAA,IACA,YAAAoE;AAAA,IACA,OAAA8H;AAAA,EAAA;AAEJ;ACxTO,MAAMC,KAAe;AAAA,EAAA,cAC1BC;AAAAA,EACA,mBAAA/M;AAAA,EACA,qBAAAG;AAAA,EACA,iBAAAD;AAAA,EACA,yBAAAD;AAAA,EACA,SAAAF;AACF;"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { MaskFull, CountryKey } from '@desource/phone-mask';
|
|
2
|
+
import type { ReactNode, FocusEvent, RefObject } from 'react';
|
|
3
|
+
export type Size = 'compact' | 'normal' | 'large';
|
|
4
|
+
export type Theme = 'auto' | 'light' | 'dark';
|
|
5
|
+
export interface PhoneNumber {
|
|
6
|
+
full: string;
|
|
7
|
+
fullFormatted: string;
|
|
8
|
+
digits: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PhoneInputProps {
|
|
11
|
+
/** Controlled value (digits only, without country code) */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Whether to preselect a country by its ISO 3166-1 alpha-2 code */
|
|
14
|
+
country?: CountryKey;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to auto-detect country via geo IP lookup.
|
|
17
|
+
* Note: This requires an external geo IP service and may not work in all environments.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
detect?: boolean;
|
|
21
|
+
/** Locale for country names (defaults to browser language) */
|
|
22
|
+
locale?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Size preset for the component ("compact" | "normal" | "large").
|
|
25
|
+
* @default 'normal'
|
|
26
|
+
*/
|
|
27
|
+
size?: Size;
|
|
28
|
+
/**
|
|
29
|
+
* Theme preset for the component ("auto" | "light" | "dark").
|
|
30
|
+
* @default 'auto'
|
|
31
|
+
*/
|
|
32
|
+
theme?: Theme;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the input is disabled.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the input is readonly.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to show the copy button.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
showCopy?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to show the clear button.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
showClear?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to show validation related styles (border & outline).
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
withValidity?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Custom search placeholder.
|
|
60
|
+
* @default 'Search country or code...'
|
|
61
|
+
*/
|
|
62
|
+
searchPlaceholder?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Custom no results text.
|
|
65
|
+
* @default 'No countries found'
|
|
66
|
+
*/
|
|
67
|
+
noResultsText?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Custom clear button label.
|
|
70
|
+
* @default 'Clear phone number'
|
|
71
|
+
*/
|
|
72
|
+
clearButtonLabel?: string;
|
|
73
|
+
/** Dropdown menu custom class */
|
|
74
|
+
dropdownClass?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Whether to disable default internal styles.
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
disableDefaultStyles?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Callback when the digits value changes.
|
|
82
|
+
* Returns only the digits without country code (e.g. '234567890')
|
|
83
|
+
*/
|
|
84
|
+
onChange?: (digits: string) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Callback when the phone number changes.
|
|
87
|
+
* Provides an object with:
|
|
88
|
+
* - full: Full phone number with country code (e.g. +1234567890)
|
|
89
|
+
* - fullFormatted: Full phone number formatted according to country rules (e.g. +1 234-567-890)
|
|
90
|
+
* - digits: Only the digits of the phone number without country code (e.g. 234567890)
|
|
91
|
+
*/
|
|
92
|
+
onPhoneChange?: (value: PhoneNumber) => void;
|
|
93
|
+
/** Callback when the country changes */
|
|
94
|
+
onCountryChange?: (country: MaskFull) => void;
|
|
95
|
+
/** Callback when validation state changes */
|
|
96
|
+
onValidationChange?: (isValid: boolean) => void;
|
|
97
|
+
/** Callback on focus */
|
|
98
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
99
|
+
/** Callback on blur */
|
|
100
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
101
|
+
/** Callback when phone number is copied */
|
|
102
|
+
onCopy?: (value: string) => void;
|
|
103
|
+
/** Callback when input is cleared */
|
|
104
|
+
onClear?: () => void;
|
|
105
|
+
/** Render custom action buttons before default ones */
|
|
106
|
+
renderActionsBefore?: () => ReactNode;
|
|
107
|
+
/** Render custom flag icons in the country list and country selector */
|
|
108
|
+
renderFlag?: (country: MaskFull) => ReactNode;
|
|
109
|
+
/** Render custom copy button SVG */
|
|
110
|
+
renderCopySvg?: (copied: boolean) => ReactNode;
|
|
111
|
+
/** Render custom clear button SVG */
|
|
112
|
+
renderClearSvg?: () => ReactNode;
|
|
113
|
+
}
|
|
114
|
+
export interface PhoneInputRef {
|
|
115
|
+
/** Focus the phone input */
|
|
116
|
+
focus: () => void;
|
|
117
|
+
/** Blur the phone input */
|
|
118
|
+
blur: () => void;
|
|
119
|
+
/** Clear the phone input */
|
|
120
|
+
clear: () => void;
|
|
121
|
+
/** Select a country by its ISO 3166-1 alpha-2 code */
|
|
122
|
+
selectCountry: (country: CountryKey) => void;
|
|
123
|
+
/** Get the full phone number with country code (e.g. +1234567890) */
|
|
124
|
+
getFullNumber: () => string;
|
|
125
|
+
/** Get the full phone number formatted according to country rules (e.g. +1 234-567-890) */
|
|
126
|
+
getFullFormattedNumber: () => string;
|
|
127
|
+
/** Get only the digits of the phone number without country code (e.g. 234567890) */
|
|
128
|
+
getDigits: () => string;
|
|
129
|
+
/** Check if the current phone number is valid */
|
|
130
|
+
isValid: () => boolean;
|
|
131
|
+
/** Check if the current phone number is complete */
|
|
132
|
+
isComplete: () => boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface FormatterHelpers {
|
|
135
|
+
formatDisplay: (digits: string) => string;
|
|
136
|
+
getMaxDigits: () => number;
|
|
137
|
+
getPlaceholder: () => string;
|
|
138
|
+
getCaretPosition: (digitIndex: number) => number;
|
|
139
|
+
getDigitRange: (digits: string, selStart: number, selEnd: number) => [number, number] | null;
|
|
140
|
+
isComplete: (digits: string) => boolean;
|
|
141
|
+
}
|
|
142
|
+
/** Configuration options for the phone mask hook */
|
|
143
|
+
export interface UsePhoneMaskOptions {
|
|
144
|
+
/** Country ISO code (e.g., 'US', 'DE', 'GB') */
|
|
145
|
+
country?: string;
|
|
146
|
+
/** Locale for country names (default: navigator.language) */
|
|
147
|
+
locale?: string;
|
|
148
|
+
/** Auto-detect country from IP/locale (default: false) */
|
|
149
|
+
detect?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Callback when formatted value changes.
|
|
152
|
+
* Provides full number, formatted phone number, and raw digits.
|
|
153
|
+
*/
|
|
154
|
+
onChange?: (phone: PhoneNumber) => void;
|
|
155
|
+
/** Callback when country changes */
|
|
156
|
+
onCountryChange?: (country: MaskFull) => void;
|
|
157
|
+
}
|
|
158
|
+
/** Return type for usePhoneMask hook */
|
|
159
|
+
export interface UsePhoneMaskReturn {
|
|
160
|
+
/** Ref to attach to input element */
|
|
161
|
+
ref: RefObject<HTMLInputElement | null>;
|
|
162
|
+
/** Raw digits without formatting */
|
|
163
|
+
digits: string;
|
|
164
|
+
/** Full phone number with country code */
|
|
165
|
+
full: string;
|
|
166
|
+
/** Full phone number formatted */
|
|
167
|
+
fullFormatted: string;
|
|
168
|
+
/** Whether the phone number is complete */
|
|
169
|
+
isComplete: boolean;
|
|
170
|
+
/** Whether the input is empty */
|
|
171
|
+
isEmpty: boolean;
|
|
172
|
+
/** Whether to show validation warning */
|
|
173
|
+
shouldShowWarn: boolean;
|
|
174
|
+
/** Current country data */
|
|
175
|
+
country: MaskFull;
|
|
176
|
+
/** Change country programmatically */
|
|
177
|
+
setCountry: (countryCode: string) => void;
|
|
178
|
+
/** Clear the input */
|
|
179
|
+
clear: () => void;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D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O,CAAC;IACjB,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;IACxB,2BAA2B;IAC3B,OAAO,EAAE,QAAQ,CAAC;IAClB,sCAAsC;IACtC,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,sBAAsB;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type MaskFull } from '@desource/phone-mask';
|
|
2
|
+
import type { FormatterHelpers } from './types';
|
|
3
|
+
export declare function createPhoneFormatter(country: MaskFull): FormatterHelpers;
|
|
4
|
+
/**
|
|
5
|
+
* Caret manipulation helper
|
|
6
|
+
*/
|
|
7
|
+
export declare function setCaret(el: HTMLInputElement | null, position: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Extract digits from any string
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractDigits(value: string, maxLength?: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* Parse selection range for digit operations
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSelection(el: HTMLInputElement | null): [number, number];
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,QAAQ,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,gBAAgB,CA6DxE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO5E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E"}
|
|
@@ -0,0 +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;
|
|
2
|
+
//# sourceMappingURL=phone-mask-react.cjs.map
|