@desource/phone-mask-react 0.3.0 → 1.0.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 +34 -0
- package/README.md +28 -22
- package/dist/esm/components/PhoneInput.d.ts +2 -9
- package/dist/esm/components/PhoneInput.d.ts.map +1 -1
- package/dist/esm/hooks/internal/useCopyAction.d.ts +14 -0
- package/dist/esm/hooks/internal/useCopyAction.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useCountry.d.ts +21 -0
- package/dist/esm/hooks/internal/useCountry.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useCountrySelector.d.ts +32 -0
- package/dist/esm/hooks/internal/useCountrySelector.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useFormatter.d.ts +45 -0
- package/dist/esm/hooks/internal/useFormatter.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useInputHandlers.d.ts +21 -0
- package/dist/esm/hooks/internal/useInputHandlers.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useTheme.d.ts +9 -0
- package/dist/esm/hooks/internal/useTheme.d.ts.map +1 -0
- package/dist/esm/hooks/internal/useValidationHint.d.ts +6 -0
- package/dist/esm/hooks/internal/useValidationHint.d.ts.map +1 -0
- package/dist/esm/hooks/usePhoneMask.d.ts +2 -1
- package/dist/esm/hooks/usePhoneMask.d.ts.map +1 -1
- package/dist/esm/hooks/utility/useClipboard.d.ts +6 -0
- package/dist/esm/hooks/utility/useClipboard.d.ts.map +1 -0
- package/dist/esm/hooks/utility/useTimer.d.ts +9 -0
- package/dist/esm/hooks/utility/useTimer.d.ts.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +758 -704
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +15 -19
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/phone-mask-react.cjs +1 -1
- package/dist/phone-mask-react.cjs.map +1 -1
- package/dist/phone-mask-react.css +1 -1
- package/package.json +13 -11
- package/dist/esm/consts.d.ts +0 -4
- package/dist/esm/consts.d.ts.map +0 -1
- package/dist/esm/utils.d.ts +0 -16
- package/dist/esm/utils.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,531 +1,719 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const St = { 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 #### ######"] }, kt = /^[a-z]{2}$/i, me = (e) => {
|
|
5
|
-
if (!
|
|
6
|
-
const
|
|
7
|
-
throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${
|
|
1
|
+
import { jsxs as F, Fragment as dt, jsx as C } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as I, useEffect as v, useState as T, useCallback as h, useRef as R, forwardRef as pt, useImperativeHandle as ft } from "react";
|
|
3
|
+
import { createPortal as ht } from "react-dom";
|
|
4
|
+
const gt = { 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 #### ######"] }, mt = /^[a-z]{2}$/i, z = (e) => {
|
|
5
|
+
if (!mt.test(e)) {
|
|
6
|
+
const n = typeof e;
|
|
7
|
+
throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${n === "string" ? e : n}' instead.`);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
return String.fromCodePoint(...
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const t = [...e.toUpperCase()].map((n) => (n.codePointAt(0) ?? 0) + 127397);
|
|
10
|
+
return String.fromCodePoint(...t);
|
|
11
|
+
}, he = "en", j = /* @__PURE__ */ new Map(), xe = (e) => {
|
|
12
|
+
const t = e.toLowerCase(), n = j.get(t);
|
|
13
|
+
if (n) return n;
|
|
14
|
+
const r = new Intl.DisplayNames([e], { type: "region" });
|
|
15
|
+
if (j.size >= 10) {
|
|
16
|
+
for (const s of j.keys()) if (s !== he) {
|
|
17
|
+
j.delete(s);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return j.set(t, r), r;
|
|
22
|
+
}, K = Object.entries(gt), Ae = (e) => e.split(/ (.*)/s);
|
|
23
|
+
function $(e) {
|
|
24
|
+
let t = "", n = "";
|
|
14
25
|
if (Array.isArray(e)) {
|
|
15
|
-
const
|
|
16
|
-
for (const
|
|
17
|
-
const [
|
|
18
|
-
|
|
26
|
+
const r = [];
|
|
27
|
+
for (const s of e) {
|
|
28
|
+
const [o, a] = Ae(s);
|
|
29
|
+
t || (t = o), r.push(a);
|
|
19
30
|
}
|
|
20
|
-
|
|
31
|
+
n = r;
|
|
21
32
|
} else {
|
|
22
|
-
const [
|
|
23
|
-
|
|
33
|
+
const [r, s] = Ae(e);
|
|
34
|
+
t = r, n = s;
|
|
24
35
|
}
|
|
25
|
-
return [
|
|
36
|
+
return [t, n];
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const [
|
|
30
|
-
return e[
|
|
38
|
+
K.map(([e, t]) => ({ id: e, mask: t }));
|
|
39
|
+
K.reduce((e, [t, n]) => {
|
|
40
|
+
const [r, s] = $(n);
|
|
41
|
+
return e[t] = { code: r, mask: s }, e;
|
|
31
42
|
}, {});
|
|
32
|
-
|
|
33
|
-
const [
|
|
34
|
-
return { id: e, code:
|
|
43
|
+
K.map(([e, t]) => {
|
|
44
|
+
const [n, r] = $(t);
|
|
45
|
+
return { id: e, code: n, mask: r };
|
|
35
46
|
});
|
|
36
|
-
|
|
37
|
-
const [
|
|
38
|
-
return e[
|
|
47
|
+
K.reduce((e, [t, n]) => {
|
|
48
|
+
const [r, s] = $(n);
|
|
49
|
+
return e[t] = { code: r, mask: s, flag: z(t) }, e;
|
|
39
50
|
}, {});
|
|
40
|
-
|
|
41
|
-
const [
|
|
42
|
-
return { id: e, code:
|
|
51
|
+
K.map(([e, t]) => {
|
|
52
|
+
const [n, r] = $(t);
|
|
53
|
+
return { id: e, code: n, mask: r, flag: z(e) };
|
|
43
54
|
});
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
const [
|
|
48
|
-
return
|
|
55
|
+
const Be = (e) => {
|
|
56
|
+
const t = xe(e);
|
|
57
|
+
return K.reduce((n, [r, s]) => {
|
|
58
|
+
const [o, a] = $(s), i = t.of(r) ?? "";
|
|
59
|
+
return n[r] = { code: o, mask: a, name: i, flag: z(r) }, n;
|
|
49
60
|
}, {});
|
|
50
|
-
},
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
function
|
|
61
|
+
}, He = (e) => {
|
|
62
|
+
const t = xe(e);
|
|
63
|
+
return K.map(([n, r]) => {
|
|
64
|
+
const [s, o] = $(r);
|
|
65
|
+
return { id: n, code: s, mask: o, name: t.of(n) ?? "", flag: z(n) };
|
|
66
|
+
});
|
|
67
|
+
}, Ct = Be(he);
|
|
68
|
+
He(he);
|
|
69
|
+
const yt = z;
|
|
70
|
+
function Re() {
|
|
60
71
|
return typeof navigator < "u" && navigator.language || "en";
|
|
61
72
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
73
|
+
function wt() {
|
|
74
|
+
try {
|
|
75
|
+
const e = Re();
|
|
76
|
+
try {
|
|
77
|
+
const n = new Intl.Locale(e);
|
|
78
|
+
if (n.region) return n.region.toUpperCase();
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
const t = e.split(/[-_]/);
|
|
82
|
+
if (t.length > 1) return t[1]?.toUpperCase() || null;
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function Dt(e) {
|
|
88
|
+
const t = Ct;
|
|
89
|
+
return e.toUpperCase() in t;
|
|
90
|
+
}
|
|
91
|
+
function vt(e, t) {
|
|
92
|
+
const n = Be(t), r = e.toUpperCase();
|
|
93
|
+
return r in n ? { id: r, ...n[r] } : { id: "US", ...n.US };
|
|
64
94
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
return s in t ? { id: s, ...t[s] } : { id: "US", ...t.US };
|
|
95
|
+
function se(e, t) {
|
|
96
|
+
return e && Dt(e) ? e.toUpperCase() : t || "";
|
|
68
97
|
}
|
|
69
|
-
function
|
|
98
|
+
function Ve(e) {
|
|
70
99
|
return Array.isArray(e) ? e : [e];
|
|
71
100
|
}
|
|
72
|
-
function
|
|
101
|
+
function ge(e) {
|
|
73
102
|
return (e.match(/#/g) || []).length;
|
|
74
103
|
}
|
|
75
|
-
function
|
|
104
|
+
function fe(e) {
|
|
76
105
|
return e.replace(/^\+\d+\s?/, "");
|
|
77
106
|
}
|
|
78
|
-
function
|
|
107
|
+
function Ge(e, t) {
|
|
79
108
|
if (e.length === 1) return e[0];
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
function
|
|
86
|
-
let
|
|
87
|
-
const
|
|
88
|
-
let
|
|
89
|
-
const
|
|
90
|
-
for (let
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
if (!(
|
|
94
|
-
|
|
109
|
+
const n = e.map((o) => ({ mask: o, count: ge(o) })), r = n.filter((o) => o.count >= t).sort((o, a) => o.count - a.count);
|
|
110
|
+
if (r.length > 0) return r[0].mask;
|
|
111
|
+
const s = n.sort((o, a) => a.count - o.count)[0];
|
|
112
|
+
return s ? s.mask : e[0];
|
|
113
|
+
}
|
|
114
|
+
function re(e, t) {
|
|
115
|
+
let n = "";
|
|
116
|
+
const r = [];
|
|
117
|
+
let s = 0;
|
|
118
|
+
const o = t.length, a = e.length;
|
|
119
|
+
for (let i = 0; i < a; i++) {
|
|
120
|
+
const c = e[i];
|
|
121
|
+
if (c === "#") {
|
|
122
|
+
if (!(s < o)) break;
|
|
123
|
+
n += t[s], r.push(s), s++;
|
|
95
124
|
} else {
|
|
96
|
-
const
|
|
97
|
-
(
|
|
125
|
+
const l = e.indexOf("#", i + 1) !== -1 && s < o;
|
|
126
|
+
(n.length > 0 || l) && (n += c, r.push(-1));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { display: n, map: r };
|
|
130
|
+
}
|
|
131
|
+
function Lt(e, t) {
|
|
132
|
+
const n = t.trim().toUpperCase();
|
|
133
|
+
if (!n) return e;
|
|
134
|
+
const r = n.replace(/\D/g, ""), s = r.length > 0;
|
|
135
|
+
return e.map((o) => {
|
|
136
|
+
const a = o.name.toUpperCase(), i = o.id.toUpperCase(), c = o.code.toUpperCase(), l = o.code.replace(/\D/g, "");
|
|
137
|
+
let u = 0;
|
|
138
|
+
return a.startsWith(n) ? u = 1e3 : a.includes(n) && (u = 500), c.startsWith(n) ? u += 100 : c.includes(n) && (u += 50), i === n ? u += 200 : i.startsWith(n) && (u += 150), s && l.startsWith(r) ? u += 80 : s && l.includes(r) && (u += 40), { country: o, score: u };
|
|
139
|
+
}).filter((o) => o.score > 0).sort((o, a) => a.score !== o.score ? a.score - o.score : o.country.name.localeCompare(a.country.name)).map((o) => o.country);
|
|
140
|
+
}
|
|
141
|
+
const St = [" ", "-", "(", ")"], Mt = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "Tab"], It = /[^\d\s\-()]/;
|
|
142
|
+
function _(e, t) {
|
|
143
|
+
const n = e.replace(/\D/g, "");
|
|
144
|
+
return t ? n.slice(0, t) : n;
|
|
145
|
+
}
|
|
146
|
+
function Fe(e) {
|
|
147
|
+
return e ? [e.selectionStart ?? 0, e.selectionEnd ?? 0] : [0, 0];
|
|
148
|
+
}
|
|
149
|
+
function bt(e, t) {
|
|
150
|
+
if (e) try {
|
|
151
|
+
e.setSelectionRange(t, t);
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function Et(e) {
|
|
156
|
+
if (!e.target) return;
|
|
157
|
+
const t = e.target, n = e.data;
|
|
158
|
+
e.inputType === "insertText" && n && (It.test(n) || n === " " && t.value.endsWith(" ")) && e.preventDefault();
|
|
159
|
+
}
|
|
160
|
+
function kt(e, t) {
|
|
161
|
+
if (!e.target) return;
|
|
162
|
+
const n = e.target, { formatter: r } = t, s = r.getMaxDigits(), o = _(n.value, s);
|
|
163
|
+
return { newDigits: o, caretDigitIndex: o.length };
|
|
164
|
+
}
|
|
165
|
+
function Tt(e, t) {
|
|
166
|
+
if (!e.target) return;
|
|
167
|
+
const n = e.target, { digits: r, formatter: s } = t;
|
|
168
|
+
if (e.ctrlKey || e.metaKey || e.altKey || Mt.includes(e.key)) return;
|
|
169
|
+
const [o, a] = Fe(n);
|
|
170
|
+
if (e.key !== "Backspace") if (e.key !== "Delete") /^[0-9]$/.test(e.key) ? r.length >= s.getMaxDigits() && e.preventDefault() : e.key.length === 1 && e.preventDefault();
|
|
171
|
+
else {
|
|
172
|
+
if (e.preventDefault(), o !== a) {
|
|
173
|
+
const i = s.getDigitRange(r, o, a);
|
|
174
|
+
if (i) {
|
|
175
|
+
const [c, l] = i;
|
|
176
|
+
return { newDigits: r.slice(0, c) + r.slice(l), caretDigitIndex: c };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (o < n.value.length) {
|
|
180
|
+
const i = s.getDigitRange(r, o, n.value.length);
|
|
181
|
+
if (i) {
|
|
182
|
+
const [c] = i;
|
|
183
|
+
return { newDigits: r.slice(0, c) + r.slice(c + 1), caretDigitIndex: c };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
if (e.preventDefault(), o !== a) {
|
|
189
|
+
const i = s.getDigitRange(r, o, a);
|
|
190
|
+
if (i) {
|
|
191
|
+
const [c, l] = i;
|
|
192
|
+
return { newDigits: r.slice(0, c) + r.slice(l), caretDigitIndex: c };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (o > 0) {
|
|
196
|
+
const i = n.value;
|
|
197
|
+
let c = o - 1;
|
|
198
|
+
for (; c >= 0 && St.includes(i[c]); ) c--;
|
|
199
|
+
if (c >= 0) {
|
|
200
|
+
const l = s.getDigitRange(r, c, c + 1);
|
|
201
|
+
if (l) {
|
|
202
|
+
const [u] = l;
|
|
203
|
+
return { newDigits: r.slice(0, u) + r.slice(u + 1), caretDigitIndex: u };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function At(e, t) {
|
|
210
|
+
if (!e.target) return;
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
const n = e.target, { digits: r, formatter: s } = t, o = e.clipboardData?.getData("text") || "", a = s.getMaxDigits(), i = _(o, a);
|
|
213
|
+
if (i.length === 0) return;
|
|
214
|
+
const [c, l] = Fe(n);
|
|
215
|
+
if (c !== l) {
|
|
216
|
+
const p = s.getDigitRange(r, c, l);
|
|
217
|
+
if (p) {
|
|
218
|
+
const [f, b] = p;
|
|
219
|
+
return { newDigits: _(r.slice(0, f) + i + r.slice(b), a), caretDigitIndex: f + i.length };
|
|
98
220
|
}
|
|
99
221
|
}
|
|
100
|
-
|
|
222
|
+
const u = s.getDigitRange(r, 0, c), d = u ? u[1] : 0;
|
|
223
|
+
return { newDigits: _(r.slice(0, d) + i + r.slice(d), a), caretDigitIndex: d + i.length };
|
|
101
224
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
225
|
+
function Nt(e) {
|
|
226
|
+
const t = Ve(e.mask), n = t.map((o) => ge(fe(o))), r = Math.max(...n), s = (o) => {
|
|
227
|
+
const a = Ge(t, o);
|
|
228
|
+
return fe(a);
|
|
229
|
+
};
|
|
230
|
+
return { formatDisplay: (o) => {
|
|
231
|
+
const a = s(o.length);
|
|
232
|
+
return re(a, o).display;
|
|
233
|
+
}, getMaxDigits: () => r, getPlaceholder: () => s(0), getCaretPosition: (o) => {
|
|
234
|
+
const a = s(o), { display: i, map: c } = re(a, "0".repeat(o));
|
|
235
|
+
for (let l = 0; l < c.length; l++) if (c[l] === o) return l;
|
|
236
|
+
if (o >= c.length) return i.length;
|
|
237
|
+
for (let l = 0; l < c.length; l++) if (c[l] > o) return l;
|
|
238
|
+
return i.length;
|
|
239
|
+
}, getDigitRange: (o, a, i) => {
|
|
240
|
+
const c = s(o.length), { map: l } = re(c, o);
|
|
241
|
+
let u = 1 / 0, d = -1 / 0;
|
|
242
|
+
for (let p = a; p < i && p < l.length; p++) {
|
|
243
|
+
const f = l[p];
|
|
244
|
+
f !== void 0 && f >= 0 && (u = Math.min(u, f), d = Math.max(d, f));
|
|
245
|
+
}
|
|
246
|
+
return u === 1 / 0 ? null : [u, d + 1];
|
|
247
|
+
}, isComplete: (o) => n.includes(o.length) };
|
|
248
|
+
}
|
|
249
|
+
const Pt = "https://ipapi.co/json/", xt = 1500, pe = "@desource/phone-mask:geo", Bt = 864e5;
|
|
250
|
+
async function Ht(e = Pt, t = xt) {
|
|
251
|
+
const n = new AbortController(), r = setTimeout(() => n.abort(), t);
|
|
105
252
|
try {
|
|
106
|
-
const
|
|
107
|
-
if (clearTimeout(
|
|
108
|
-
const
|
|
109
|
-
return (
|
|
253
|
+
const s = await fetch(e, { signal: n.signal, headers: { Accept: "application/json" } });
|
|
254
|
+
if (clearTimeout(r), !s.ok) return null;
|
|
255
|
+
const o = await s.json();
|
|
256
|
+
return (o.country || o.country_code || o.countryCode || o.country_code2 || "").toString().toUpperCase() || null;
|
|
110
257
|
} catch {
|
|
111
|
-
return clearTimeout(
|
|
258
|
+
return clearTimeout(r), null;
|
|
112
259
|
}
|
|
113
260
|
}
|
|
114
|
-
async function
|
|
261
|
+
async function Rt() {
|
|
115
262
|
try {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
|
|
263
|
+
const n = localStorage.getItem(pe);
|
|
264
|
+
if (n) {
|
|
265
|
+
const r = JSON.parse(n), s = Date.now() - r.ts > Bt, o = se(r.country_code);
|
|
266
|
+
if (o && !s) return o;
|
|
267
|
+
localStorage.removeItem(pe);
|
|
121
268
|
}
|
|
122
269
|
} catch {
|
|
123
270
|
}
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
271
|
+
const e = await Ht(), t = se(e);
|
|
272
|
+
if (t) {
|
|
126
273
|
try {
|
|
127
|
-
|
|
274
|
+
const n = JSON.stringify({ country_code: t, ts: Date.now() });
|
|
275
|
+
localStorage.setItem(pe, n);
|
|
128
276
|
} catch {
|
|
129
277
|
}
|
|
130
|
-
return
|
|
278
|
+
return t;
|
|
131
279
|
}
|
|
132
280
|
return null;
|
|
133
281
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
for (let K = y; K < d && K < D.length; K++) {
|
|
159
|
-
const _ = D[K];
|
|
160
|
-
_ !== void 0 && _ >= 0 && ($ = Math.min($, _), J = Math.max(J, _));
|
|
161
|
-
}
|
|
162
|
-
return $ === 1 / 0 ? null : [$, J + 1];
|
|
163
|
-
},
|
|
164
|
-
isComplete: (c) => t.includes(c.length)
|
|
282
|
+
function Ke({
|
|
283
|
+
country: e,
|
|
284
|
+
value: t,
|
|
285
|
+
onChange: n,
|
|
286
|
+
onPhoneChange: r,
|
|
287
|
+
onValidationChange: s
|
|
288
|
+
}) {
|
|
289
|
+
const o = I(() => Nt(e), [e]), a = o.getMaxDigits(), i = I(() => _(t, a), [t, a]), c = o.getPlaceholder(), l = o.formatDisplay(i), u = i ? `${e.code}${i}` : "", d = l ? `${e.code} ${l}` : "", p = o.isComplete(i), f = i.length === 0, b = !f && !p, L = I(() => ({ full: u, fullFormatted: d, digits: i }), [u, d, i]);
|
|
290
|
+
return v(() => {
|
|
291
|
+
t !== i && n(i);
|
|
292
|
+
}, [t, i, n]), v(() => {
|
|
293
|
+
r?.(L);
|
|
294
|
+
}, [L, r]), v(() => {
|
|
295
|
+
s?.(p);
|
|
296
|
+
}, [p, s]), {
|
|
297
|
+
digits: i,
|
|
298
|
+
formatter: o,
|
|
299
|
+
displayPlaceholder: c,
|
|
300
|
+
displayValue: l,
|
|
301
|
+
full: u,
|
|
302
|
+
fullFormatted: d,
|
|
303
|
+
isComplete: p,
|
|
304
|
+
isEmpty: f,
|
|
305
|
+
shouldShowWarn: b
|
|
165
306
|
};
|
|
166
307
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
308
|
+
function Ue({
|
|
309
|
+
country: e,
|
|
310
|
+
locale: t,
|
|
311
|
+
detect: n,
|
|
312
|
+
onCountryChange: r
|
|
313
|
+
}) {
|
|
314
|
+
const s = I(() => t || Re(), [t]), [o, a] = T(se(e, "US")), i = I(() => vt(o, s), [o, s]), c = !!n && !e, l = h((d) => {
|
|
315
|
+
const p = se(d);
|
|
316
|
+
return p ? (a(p), !0) : !1;
|
|
317
|
+
}, []), u = h(async () => {
|
|
318
|
+
const d = await Rt();
|
|
319
|
+
if (l(d)) return;
|
|
320
|
+
const p = wt();
|
|
321
|
+
l(p);
|
|
322
|
+
}, [l]);
|
|
323
|
+
return v(() => {
|
|
324
|
+
e && e !== o && l(e);
|
|
325
|
+
}, [o, e, l]), v(() => {
|
|
326
|
+
c && u();
|
|
327
|
+
}, [c, u]), v(() => {
|
|
328
|
+
r?.(i);
|
|
329
|
+
}, [i, r]), { country: i, setCountry: l, locale: s };
|
|
173
330
|
}
|
|
174
|
-
function
|
|
175
|
-
const
|
|
176
|
-
|
|
331
|
+
function me() {
|
|
332
|
+
const e = R(null), t = h(() => {
|
|
333
|
+
e.current && (clearTimeout(e.current), e.current = null);
|
|
334
|
+
}, []), n = h(
|
|
335
|
+
(r, s) => {
|
|
336
|
+
t(), e.current = setTimeout(r, s);
|
|
337
|
+
},
|
|
338
|
+
[t]
|
|
339
|
+
);
|
|
340
|
+
return v(() => t, [t]), I(() => ({ set: n, clear: t }), [n, t]);
|
|
177
341
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
342
|
+
function Vt() {
|
|
343
|
+
const [e, t] = T(!1), n = me(), r = h(
|
|
344
|
+
(o = !0) => {
|
|
345
|
+
o && t(!1), n.clear();
|
|
346
|
+
},
|
|
347
|
+
[n]
|
|
348
|
+
), s = h(
|
|
349
|
+
(o) => {
|
|
350
|
+
t(!1), n.set(() => {
|
|
351
|
+
t(!0);
|
|
352
|
+
}, o);
|
|
353
|
+
},
|
|
354
|
+
[n]
|
|
355
|
+
);
|
|
356
|
+
return { showValidationHint: e, clearValidationHint: r, scheduleValidationHint: s };
|
|
180
357
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const r = tt(e);
|
|
184
|
-
return Object.entries(r).map(([t, s]) => ({ id: t, ...s }));
|
|
358
|
+
function oe(e) {
|
|
359
|
+
return "nativeEvent" in e ? e.nativeEvent : e;
|
|
185
360
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
readonly: D = !1,
|
|
196
|
-
showCopy: $ = !0,
|
|
197
|
-
showClear: J = !1,
|
|
198
|
-
withValidity: K = !0,
|
|
199
|
-
searchPlaceholder: _ = "Search country or code...",
|
|
200
|
-
noResultsText: Me = "No countries found",
|
|
201
|
-
clearButtonLabel: ie = "Clear phone number",
|
|
202
|
-
dropdownClass: Le = "",
|
|
203
|
-
disableDefaultStyles: Se = !1,
|
|
204
|
-
onChange: z,
|
|
205
|
-
onPhoneChange: X,
|
|
206
|
-
onCountryChange: o,
|
|
207
|
-
onValidationChange: m,
|
|
208
|
-
onFocus: h,
|
|
209
|
-
onBlur: L,
|
|
210
|
-
onCopy: T,
|
|
211
|
-
onClear: C,
|
|
212
|
-
renderActionsBefore: N,
|
|
213
|
-
renderFlag: E,
|
|
214
|
-
renderCopySvg: F,
|
|
215
|
-
renderClearSvg: ae
|
|
216
|
-
} = r, U = W(null), he = W(null), Q = W(null), ye = W(null), Ce = W(null), ke = W(null), H = c || Ne(), [I, ce] = x(() => O(s || "US", H)), [g, G] = x(""), [q, $e] = x(!1), [ct, Re] = x(!1), [Ae, Ke] = x(""), [we, le] = x(0), [De, Ve] = x(!1), [We, Oe] = x(!1), [lt, ut] = x({}), [dt, ee] = x(!1), S = W(null), ne = W(null), ue = W(null), [ve, ft] = x(!s), w = Ee(() => He(I), [I]), de = Ee(() => xt(H), [H]), xe = w.formatDisplay(g), pt = w.getPlaceholder(), re = w.isComplete(g), Be = g.length === 0, Ze = dt && !Be && !re, be = `${I.code}${g}`, fe = g ? `${I.code} ${xe}` : "", pe = Ee(() => {
|
|
217
|
-
const n = Ae.trim();
|
|
218
|
-
if (!n) return de;
|
|
219
|
-
const i = n.toUpperCase(), l = i.replace(/\D/g, ""), p = l.length > 0;
|
|
220
|
-
return de.map((a) => {
|
|
221
|
-
const u = a.name.toUpperCase(), k = a.id.toUpperCase(), P = a.code.toUpperCase(), Y = a.code.replace(/\D/g, "");
|
|
222
|
-
let A = 0;
|
|
223
|
-
return u.startsWith(i) ? A = 1e3 : u.includes(i) && (A = 500), P.startsWith(i) ? A += 100 : P.includes(i) && (A += 50), k === i ? A += 200 : k.startsWith(i) && (A += 150), p && Y.startsWith(l) ? A += 80 : p && Y.includes(l) && (A += 40), { country: a, score: A };
|
|
224
|
-
}).filter((a) => a.score > 0).sort((a, u) => u.score !== a.score ? u.score - a.score : a.country.name.localeCompare(u.country.name)).map((a) => a.country);
|
|
225
|
-
}, [de, Ae]), V = M || D, Ye = $ && !Be && !M, je = J && !Be && !V;
|
|
226
|
-
B(() => {
|
|
227
|
-
ft(!s && de.length > 1);
|
|
228
|
-
const n = (l) => {
|
|
229
|
-
if (!l) return !1;
|
|
230
|
-
const p = l.toUpperCase();
|
|
231
|
-
return de.some((a) => a.id === p);
|
|
232
|
-
}, i = () => {
|
|
233
|
-
const l = typeof navigator < "u" && navigator.language ? navigator.language : "";
|
|
234
|
-
try {
|
|
235
|
-
if (Intl.Locale) {
|
|
236
|
-
const a = new Intl.Locale(l);
|
|
237
|
-
if (a?.region && n(a.region)) return a.region.toUpperCase();
|
|
238
|
-
}
|
|
239
|
-
} catch {
|
|
240
|
-
}
|
|
241
|
-
const p = l.split(/[-_]/);
|
|
242
|
-
return p.length > 1 && n(p[1]) ? p[1].toUpperCase() : null;
|
|
243
|
-
};
|
|
244
|
-
(async () => {
|
|
245
|
-
if (s && n(s)) {
|
|
246
|
-
const a = O(s, H);
|
|
247
|
-
ce((u) => u.id === a.id ? u : (o?.(a), a));
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (!f) return;
|
|
251
|
-
const l = await At(n);
|
|
252
|
-
if (l) {
|
|
253
|
-
const a = O(l, H);
|
|
254
|
-
ce((u) => u.id === a.id ? u : (o?.(a), a));
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
const p = i();
|
|
258
|
-
if (p) {
|
|
259
|
-
const a = O(p, H);
|
|
260
|
-
ce((u) => u.id === a.id ? u : (o?.(a), a));
|
|
261
|
-
}
|
|
262
|
-
})();
|
|
263
|
-
}, [s, f, de, H]), B(() => {
|
|
264
|
-
const n = w.getMaxDigits();
|
|
265
|
-
g.length > n && G((i) => i.slice(0, n));
|
|
266
|
-
}, [w]), B(() => {
|
|
267
|
-
const n = j(t || "");
|
|
268
|
-
n !== g && G(n);
|
|
269
|
-
}, [t]), B(() => {
|
|
270
|
-
m?.(re);
|
|
271
|
-
}, [re, m]);
|
|
272
|
-
const Je = b(() => {
|
|
273
|
-
z?.(g), X?.({ full: be, fullFormatted: fe, digits: g });
|
|
274
|
-
}, [g, be, fe, z, X]);
|
|
275
|
-
B(() => {
|
|
276
|
-
Je();
|
|
277
|
-
}, [Je]);
|
|
278
|
-
const _e = b((n) => {
|
|
279
|
-
const i = n.data;
|
|
280
|
-
if (n.inputType !== "insertText" || !i) return;
|
|
281
|
-
const l = U.current;
|
|
282
|
-
l && (at.test(i) || i === " " && l.value.endsWith(" ")) && n.preventDefault();
|
|
283
|
-
}, []), gt = b(() => {
|
|
284
|
-
const n = U.current;
|
|
285
|
-
if (!n || V) return;
|
|
286
|
-
const i = n.value || "", l = w.getMaxDigits(), p = j(i, l);
|
|
287
|
-
G(p), setTimeout(() => {
|
|
288
|
-
const a = w.getCaretPosition(p.length);
|
|
289
|
-
R(n, a);
|
|
290
|
-
}, 0), ee(!1), S.current && clearTimeout(S.current), p.length > 0 && (S.current = setTimeout(() => {
|
|
291
|
-
ee(!0);
|
|
292
|
-
}, 500));
|
|
293
|
-
}, [w, V]), ze = b(
|
|
294
|
-
(n) => {
|
|
295
|
-
if (V) return;
|
|
296
|
-
const i = U.current;
|
|
297
|
-
if (!i || n.ctrlKey || n.metaKey || n.altKey || it.includes(n.key)) return;
|
|
298
|
-
const [l, p] = Ie(i);
|
|
299
|
-
ee(!1), S.current && clearTimeout(S.current);
|
|
300
|
-
const a = () => {
|
|
301
|
-
S.current && clearTimeout(S.current), S.current = setTimeout(() => {
|
|
302
|
-
ee(!0);
|
|
303
|
-
}, 300);
|
|
304
|
-
};
|
|
305
|
-
if (n.key === "Backspace") {
|
|
306
|
-
if (n.preventDefault(), l !== p) {
|
|
307
|
-
const u = w.getDigitRange(g, l, p);
|
|
308
|
-
if (u) {
|
|
309
|
-
const [k, P] = u;
|
|
310
|
-
G(g.slice(0, k) + g.slice(P)), setTimeout(() => R(i, w.getCaretPosition(k)), 0);
|
|
311
|
-
}
|
|
312
|
-
} else if (l > 0) {
|
|
313
|
-
let u = l - 1;
|
|
314
|
-
for (; u >= 0 && st.includes(i.value[u]); ) u--;
|
|
315
|
-
if (u >= 0) {
|
|
316
|
-
const k = w.getDigitRange(g, u, u + 1);
|
|
317
|
-
if (k) {
|
|
318
|
-
const [P] = k;
|
|
319
|
-
G(g.slice(0, P) + g.slice(P + 1)), setTimeout(() => R(i, w.getCaretPosition(P)), 0);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
a();
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (n.key === "Delete") {
|
|
327
|
-
if (n.preventDefault(), l !== p) {
|
|
328
|
-
const u = w.getDigitRange(g, l, p);
|
|
329
|
-
if (u) {
|
|
330
|
-
const [k, P] = u;
|
|
331
|
-
G(g.slice(0, k) + g.slice(P)), setTimeout(() => R(i, w.getCaretPosition(k)), 0);
|
|
332
|
-
}
|
|
333
|
-
} else if (l < i.value.length) {
|
|
334
|
-
const u = w.getDigitRange(g, l, l + 1);
|
|
335
|
-
if (u) {
|
|
336
|
-
const [k] = u;
|
|
337
|
-
G(g.slice(0, k) + g.slice(k + 1)), setTimeout(() => R(i, w.getCaretPosition(k)), 0);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
a();
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (/^[0-9]$/.test(n.key)) {
|
|
344
|
-
g.length >= w.getMaxDigits() && n.preventDefault(), a();
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
n.key.length === 1 && n.preventDefault(), a();
|
|
361
|
+
const Gt = 500, Ne = 300;
|
|
362
|
+
function $e(e) {
|
|
363
|
+
const { formatter: t, digits: n, inactive: r, onChange: s, scheduleValidationHint: o } = e, a = h(
|
|
364
|
+
(d, p) => {
|
|
365
|
+
setTimeout(() => {
|
|
366
|
+
if (!d) return;
|
|
367
|
+
const f = t.getCaretPosition(p);
|
|
368
|
+
bt(d, f);
|
|
369
|
+
}, 0);
|
|
348
370
|
},
|
|
349
|
-
[
|
|
350
|
-
),
|
|
351
|
-
(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
} else {
|
|
366
|
-
const P = w.getDigitRange(g, u, u), Y = P ? P[0] : g.length, A = j(
|
|
367
|
-
g.slice(0, Y) + a + g.slice(Y),
|
|
368
|
-
p
|
|
369
|
-
);
|
|
370
|
-
G(A), setTimeout(() => R(i, w.getCaretPosition(Y + a.length)), 0);
|
|
371
|
-
}
|
|
372
|
-
ee(!1), S.current && clearTimeout(S.current), S.current = setTimeout(() => {
|
|
373
|
-
ee(!0);
|
|
374
|
-
}, 300);
|
|
371
|
+
[t]
|
|
372
|
+
), i = h((d) => {
|
|
373
|
+
Et(oe(d));
|
|
374
|
+
}, []), c = h(
|
|
375
|
+
(d) => {
|
|
376
|
+
if (r) return;
|
|
377
|
+
const p = oe(d), f = kt(p, { formatter: t });
|
|
378
|
+
f && (s?.(f.newDigits), a(p.target, f.caretDigitIndex), o?.(Gt));
|
|
379
|
+
},
|
|
380
|
+
[r, t, s, a, o]
|
|
381
|
+
), l = h(
|
|
382
|
+
(d) => {
|
|
383
|
+
if (r) return;
|
|
384
|
+
const p = oe(d), f = Tt(p, { digits: n, formatter: t });
|
|
385
|
+
f && (s?.(f.newDigits), a(p.target, f.caretDigitIndex), o?.(Ne));
|
|
375
386
|
},
|
|
376
|
-
[
|
|
377
|
-
),
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
(n) => {
|
|
383
|
-
S.current && clearTimeout(S.current), Z(), h?.(n);
|
|
387
|
+
[r, n, t, s, a, o]
|
|
388
|
+
), u = h(
|
|
389
|
+
(d) => {
|
|
390
|
+
if (r) return;
|
|
391
|
+
const p = oe(d), f = At(p, { digits: n, formatter: t });
|
|
392
|
+
f && (s?.(f.newDigits), a(p.target, f.caretDigitIndex), o?.(Ne));
|
|
384
393
|
},
|
|
385
|
-
[
|
|
394
|
+
[r, n, t, s, a, o]
|
|
386
395
|
);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
return {
|
|
397
|
+
handleBeforeInput: i,
|
|
398
|
+
handleInput: c,
|
|
399
|
+
handleKeydown: l,
|
|
400
|
+
handlePaste: u
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function Ft({
|
|
404
|
+
rootRef: e,
|
|
405
|
+
dropdownRef: t,
|
|
406
|
+
searchRef: n,
|
|
407
|
+
selectorRef: r,
|
|
408
|
+
locale: s,
|
|
409
|
+
countryOption: o,
|
|
410
|
+
inactive: a,
|
|
411
|
+
onSelectCountry: i,
|
|
412
|
+
onAfterSelect: c
|
|
413
|
+
}) {
|
|
414
|
+
const [l, u] = T(""), [d, p] = T(!1), [f, b] = T({}), [L, N] = T(!1), [P, g] = T(0), A = I(() => He(s), [s]), E = I(() => Lt(A, l), [A, l]), k = I(() => !o && A.length > 1, [o, A]), x = h(() => {
|
|
415
|
+
setTimeout(() => n.current?.focus({ preventScroll: !0 }), 0);
|
|
416
|
+
}, []), D = h(() => {
|
|
417
|
+
d && N(!0);
|
|
418
|
+
}, [d]), W = h(() => {
|
|
419
|
+
N(!1), p(!0), g(0), x();
|
|
420
|
+
}, [x]), X = h(() => {
|
|
421
|
+
L && (p(!1), N(!1));
|
|
422
|
+
}, [L]), Z = h(() => {
|
|
423
|
+
a || !k || (d ? D() : W());
|
|
424
|
+
}, [a, d, k, W, D]), B = h(
|
|
425
|
+
(m) => {
|
|
426
|
+
i(m), D(), u(""), g(0), c?.();
|
|
427
|
+
},
|
|
428
|
+
[i, D, c]
|
|
429
|
+
), Q = h((m) => {
|
|
430
|
+
u(m.target.value), g(0);
|
|
431
|
+
}, []), U = h(
|
|
432
|
+
(m) => {
|
|
433
|
+
const y = m.target, S = t.current, H = r.current;
|
|
434
|
+
y && (S?.contains(y) || H?.contains(y) || D());
|
|
399
435
|
},
|
|
400
|
-
[
|
|
401
|
-
),
|
|
402
|
-
if (
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
top: `${
|
|
406
|
-
left: `${
|
|
407
|
-
width: `${
|
|
436
|
+
[D]
|
|
437
|
+
), w = h((m) => {
|
|
438
|
+
if (m?.type === "scroll" && m.target && t.current?.contains(m.target) || !e?.current) return;
|
|
439
|
+
const y = e.current.getBoundingClientRect();
|
|
440
|
+
b({
|
|
441
|
+
top: `${y.bottom + window.scrollY + 8}px`,
|
|
442
|
+
left: `${y.left + window.scrollX}px`,
|
|
443
|
+
width: `${y.width}px`
|
|
408
444
|
});
|
|
409
|
-
}, [])
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
445
|
+
}, []), O = h((m) => {
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
const y = t.current?.lastElementChild, S = y?.children[m];
|
|
448
|
+
if (!y || !S) return;
|
|
449
|
+
const H = y.getBoundingClientRect(), V = S.getBoundingClientRect();
|
|
450
|
+
let G = 0;
|
|
451
|
+
if (V.top < H.top)
|
|
452
|
+
G = y.scrollTop - (H.top - V.top);
|
|
453
|
+
else if (V.bottom > H.bottom)
|
|
454
|
+
G = y.scrollTop + (V.bottom - H.bottom);
|
|
455
|
+
else
|
|
456
|
+
return;
|
|
457
|
+
y.scrollTo({ top: G, behavior: "smooth" });
|
|
458
|
+
}, 0);
|
|
459
|
+
}, []), ie = h(
|
|
460
|
+
(m) => {
|
|
461
|
+
m.key === "ArrowDown" ? (m.preventDefault(), g((y) => {
|
|
462
|
+
const S = Math.min(y + 1, E.length - 1);
|
|
463
|
+
return O(S), S;
|
|
464
|
+
})) : m.key === "ArrowUp" ? (m.preventDefault(), g((y) => {
|
|
465
|
+
const S = Math.max(y - 1, 0);
|
|
466
|
+
return O(S), S;
|
|
467
|
+
})) : m.key === "Enter" && E[P] ? (m.preventDefault(), B(E[P].id)) : m.key === "Escape" && D();
|
|
468
|
+
},
|
|
469
|
+
[E, P, B, D, O]
|
|
470
|
+
);
|
|
471
|
+
return v(() => {
|
|
472
|
+
!k && d && D();
|
|
473
|
+
}, [k, d, D]), v(() => {
|
|
474
|
+
if (d)
|
|
475
|
+
return w(), window.addEventListener("resize", w), window.addEventListener("scroll", w, !0), window.addEventListener("click", U, !0), () => {
|
|
476
|
+
window.removeEventListener("resize", w), window.removeEventListener("scroll", w, !0), window.removeEventListener("click", U, !0);
|
|
477
|
+
};
|
|
478
|
+
}, [d, w, U]), {
|
|
479
|
+
// State
|
|
480
|
+
dropdownOpen: d,
|
|
481
|
+
isClosing: L,
|
|
482
|
+
search: l,
|
|
483
|
+
focusedIndex: P,
|
|
484
|
+
dropdownStyle: f,
|
|
485
|
+
// Derived
|
|
486
|
+
filteredCountries: E,
|
|
487
|
+
hasDropdown: k,
|
|
488
|
+
// Actions
|
|
489
|
+
openDropdown: W,
|
|
490
|
+
closeDropdown: D,
|
|
491
|
+
toggleDropdown: Z,
|
|
492
|
+
selectCountry: B,
|
|
493
|
+
setFocusedIndex: g,
|
|
494
|
+
handleSearchChange: Q,
|
|
495
|
+
handleSearchKeydown: ie,
|
|
496
|
+
handleDropdownAnimationEnd: X
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function Kt(e = 1800) {
|
|
500
|
+
const [t, n] = T(!1), [r, s] = T(!1), o = me(), a = h(
|
|
501
|
+
async (i) => {
|
|
502
|
+
if (r) return !1;
|
|
503
|
+
const c = i.trim();
|
|
504
|
+
if (!c) return !1;
|
|
505
|
+
s(!0);
|
|
428
506
|
try {
|
|
429
|
-
await navigator.clipboard.writeText(
|
|
430
|
-
|
|
431
|
-
},
|
|
432
|
-
} catch (
|
|
433
|
-
console.warn("Copy failed",
|
|
507
|
+
return await navigator.clipboard.writeText(c), n(!0), o.set(() => {
|
|
508
|
+
n(!1);
|
|
509
|
+
}, e), !0;
|
|
510
|
+
} catch (l) {
|
|
511
|
+
return console.warn("Copy failed", l), !1;
|
|
434
512
|
} finally {
|
|
435
|
-
|
|
513
|
+
s(!1);
|
|
436
514
|
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
515
|
+
},
|
|
516
|
+
[r, o]
|
|
517
|
+
);
|
|
518
|
+
return { copied: t, isCopying: r, copy: a };
|
|
519
|
+
}
|
|
520
|
+
const Pe = 1800;
|
|
521
|
+
function Ut({ liveRef: e, fullFormatted: t, onCopy: n }) {
|
|
522
|
+
const r = me(), { copied: s, copy: o } = Kt(Pe), a = I(() => s ? "Copied" : `Copy ${t}`, [s, t]), i = I(() => s ? "Copied" : "Copy phone number", [s]), c = h(
|
|
523
|
+
(u) => {
|
|
524
|
+
e?.current && (e.current.textContent = u, r.set(() => {
|
|
525
|
+
e.current && (e.current.textContent = "");
|
|
526
|
+
}, Pe));
|
|
527
|
+
},
|
|
528
|
+
[e, r]
|
|
529
|
+
), l = h(async () => {
|
|
530
|
+
const u = t.trim();
|
|
531
|
+
await o(u) && (n?.(u), c("Phone number copied to clipboard"));
|
|
532
|
+
}, [t, o, n, c]);
|
|
533
|
+
return {
|
|
534
|
+
copied: s,
|
|
535
|
+
copyAriaLabel: a,
|
|
536
|
+
copyButtonTitle: i,
|
|
537
|
+
onCopyClick: l
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function $t({ theme: e }) {
|
|
541
|
+
const [t, n] = T(!1), r = I(() => e !== "auto" ? `theme-${e}` : t ? "theme-dark" : "theme-light", [e, t]);
|
|
542
|
+
return v(() => {
|
|
543
|
+
if (typeof window > "u") return;
|
|
544
|
+
const s = window.matchMedia?.("(prefers-color-scheme: dark)") ?? null;
|
|
545
|
+
if (!s) return;
|
|
546
|
+
n(s.matches);
|
|
547
|
+
const o = (a) => {
|
|
548
|
+
n(a.matches);
|
|
549
|
+
};
|
|
550
|
+
return s.addEventListener("change", o), () => s.removeEventListener("change", o);
|
|
551
|
+
}, []), {
|
|
552
|
+
themeClass: r
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const Wt = (e, t) => {
|
|
556
|
+
const {
|
|
557
|
+
value: n = "",
|
|
558
|
+
country: r,
|
|
559
|
+
detect: s = !0,
|
|
560
|
+
locale: o,
|
|
561
|
+
size: a = "normal",
|
|
562
|
+
theme: i = "auto",
|
|
563
|
+
disabled: c = !1,
|
|
564
|
+
readonly: l = !1,
|
|
565
|
+
showCopy: u = !0,
|
|
566
|
+
showClear: d = !1,
|
|
567
|
+
withValidity: p = !0,
|
|
568
|
+
searchPlaceholder: f = "Search country or code...",
|
|
569
|
+
noResultsText: b = "No countries found",
|
|
570
|
+
clearButtonLabel: L = "Clear phone number",
|
|
571
|
+
dropdownClass: N = "",
|
|
572
|
+
disableDefaultStyles: P = !1,
|
|
573
|
+
onChange: g,
|
|
574
|
+
onPhoneChange: A,
|
|
575
|
+
onCountryChange: E,
|
|
576
|
+
onValidationChange: k,
|
|
577
|
+
onFocus: x,
|
|
578
|
+
onBlur: D,
|
|
579
|
+
onCopy: W,
|
|
580
|
+
onClear: X,
|
|
581
|
+
renderActionsBefore: Z,
|
|
582
|
+
renderFlag: B,
|
|
583
|
+
renderCopySvg: Q,
|
|
584
|
+
renderClearSvg: U
|
|
585
|
+
} = e, { country: w, setCountry: O, locale: ie } = Ue({
|
|
586
|
+
country: r,
|
|
587
|
+
locale: o,
|
|
588
|
+
detect: s,
|
|
589
|
+
onCountryChange: E
|
|
590
|
+
}), {
|
|
591
|
+
digits: m,
|
|
592
|
+
formatter: y,
|
|
593
|
+
displayPlaceholder: S,
|
|
594
|
+
displayValue: H,
|
|
595
|
+
full: V,
|
|
596
|
+
fullFormatted: G,
|
|
597
|
+
isComplete: q,
|
|
598
|
+
isEmpty: Ce,
|
|
599
|
+
shouldShowWarn: We
|
|
600
|
+
} = Ke({
|
|
601
|
+
country: w,
|
|
602
|
+
value: n,
|
|
603
|
+
onChange: g,
|
|
604
|
+
onPhoneChange: A,
|
|
605
|
+
onValidationChange: k
|
|
606
|
+
}), { showValidationHint: Ze, clearValidationHint: ee, scheduleValidationHint: Oe } = Vt(), ae = R(null), ye = R(null), we = R(null), De = R(null), ve = R(null), Le = R(null), Y = c || l, Se = Ze && We, Me = u && !Ce && !c, Ie = d && !Ce && !Y, {
|
|
607
|
+
copied: ce,
|
|
608
|
+
copyAriaLabel: Ye,
|
|
609
|
+
copyButtonTitle: Je,
|
|
610
|
+
onCopyClick: je
|
|
611
|
+
} = Ut({
|
|
612
|
+
liveRef: we,
|
|
613
|
+
fullFormatted: G,
|
|
614
|
+
onCopy: W
|
|
615
|
+
}), J = h(() => {
|
|
616
|
+
setTimeout(() => ae.current?.focus(), 0);
|
|
617
|
+
}, []), { handleBeforeInput: _e, handleInput: ze, handleKeydown: Xe, handlePaste: Qe } = $e({
|
|
618
|
+
formatter: y,
|
|
619
|
+
digits: m,
|
|
620
|
+
inactive: Y,
|
|
621
|
+
onChange: g,
|
|
622
|
+
scheduleValidationHint: Oe
|
|
623
|
+
}), {
|
|
624
|
+
dropdownOpen: le,
|
|
625
|
+
isClosing: qe,
|
|
626
|
+
search: et,
|
|
627
|
+
focusedIndex: be,
|
|
628
|
+
dropdownStyle: tt,
|
|
629
|
+
filteredCountries: Ee,
|
|
630
|
+
hasDropdown: te,
|
|
631
|
+
closeDropdown: ke,
|
|
632
|
+
toggleDropdown: nt,
|
|
633
|
+
selectCountry: ue,
|
|
634
|
+
setFocusedIndex: ot,
|
|
635
|
+
handleSearchChange: rt,
|
|
636
|
+
handleSearchKeydown: st,
|
|
637
|
+
handleDropdownAnimationEnd: it
|
|
638
|
+
} = Ft({
|
|
639
|
+
rootRef: ye,
|
|
640
|
+
dropdownRef: De,
|
|
641
|
+
searchRef: ve,
|
|
642
|
+
selectorRef: Le,
|
|
643
|
+
locale: ie,
|
|
644
|
+
inactive: Y,
|
|
645
|
+
countryOption: r,
|
|
646
|
+
onSelectCountry: O,
|
|
647
|
+
onAfterSelect: J
|
|
648
|
+
}), at = h(
|
|
649
|
+
(M) => {
|
|
650
|
+
ee(!1), ke(), x?.(M);
|
|
651
|
+
},
|
|
652
|
+
[x, ke, ee]
|
|
653
|
+
), ne = h(() => {
|
|
654
|
+
g?.(""), ee(), X?.();
|
|
655
|
+
}, [g, X, ee]), ct = h(() => {
|
|
656
|
+
ne(), J();
|
|
657
|
+
}, [ne, J]);
|
|
658
|
+
ft(
|
|
659
|
+
t,
|
|
443
660
|
() => ({
|
|
444
|
-
focus:
|
|
445
|
-
blur: () =>
|
|
446
|
-
clear:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
isValid: () => re,
|
|
454
|
-
isComplete: () => re
|
|
661
|
+
focus: J,
|
|
662
|
+
blur: () => ae.current?.blur(),
|
|
663
|
+
clear: ne,
|
|
664
|
+
selectCountry: ue,
|
|
665
|
+
getFullNumber: () => V,
|
|
666
|
+
getFullFormattedNumber: () => G,
|
|
667
|
+
getDigits: () => m,
|
|
668
|
+
isValid: () => q,
|
|
669
|
+
isComplete: () => q
|
|
455
670
|
}),
|
|
456
|
-
[
|
|
671
|
+
[J, ue, V, G, m, q, ne]
|
|
457
672
|
);
|
|
458
|
-
const
|
|
459
|
-
setTimeout(() => {
|
|
460
|
-
const i = Q.current?.lastElementChild, l = i?.children[n];
|
|
461
|
-
if (!i || !l) return;
|
|
462
|
-
const p = i.getBoundingClientRect(), a = l.getBoundingClientRect();
|
|
463
|
-
let u = 0;
|
|
464
|
-
if (a.top < p.top)
|
|
465
|
-
u = i.scrollTop - (p.top - a.top);
|
|
466
|
-
else if (a.bottom > p.bottom)
|
|
467
|
-
u = i.scrollTop + (a.bottom - p.bottom);
|
|
468
|
-
else
|
|
469
|
-
return;
|
|
470
|
-
i.scrollTo({ top: u, behavior: "smooth" });
|
|
471
|
-
}, 0);
|
|
472
|
-
}, Ct = b(
|
|
473
|
-
(n) => {
|
|
474
|
-
n.key === "ArrowDown" ? (n.preventDefault(), le((i) => {
|
|
475
|
-
const l = Math.min(i + 1, pe.length - 1);
|
|
476
|
-
return Qe(l), l;
|
|
477
|
-
})) : n.key === "ArrowUp" ? (n.preventDefault(), le((i) => {
|
|
478
|
-
const l = Math.max(i - 1, 0);
|
|
479
|
-
return Qe(l), l;
|
|
480
|
-
})) : n.key === "Enter" && pe[we] ? (n.preventDefault(), Te(pe[we].id)) : n.key === "Escape" && Z();
|
|
481
|
-
},
|
|
482
|
-
[pe, we, Te, Z]
|
|
483
|
-
), qe = Ee(() => d !== "auto" ? `theme-${d}` : typeof window < "u" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "theme-dark" : "theme-light", [d]), wt = [
|
|
673
|
+
const { themeClass: Te } = $t({ theme: i }), lt = [
|
|
484
674
|
"phone-input",
|
|
485
|
-
`size-${
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
].filter(Boolean).join(" "),
|
|
493
|
-
return /* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */
|
|
675
|
+
`size-${a}`,
|
|
676
|
+
Te,
|
|
677
|
+
c && "is-disabled",
|
|
678
|
+
l && "is-readonly",
|
|
679
|
+
P && "is-unstyled",
|
|
680
|
+
p && Se && "is-incomplete",
|
|
681
|
+
p && q && "is-complete"
|
|
682
|
+
].filter(Boolean).join(" "), ut = +Me + +Ie + (Z ? 1 : 0);
|
|
683
|
+
return /* @__PURE__ */ F(dt, { children: [
|
|
684
|
+
/* @__PURE__ */ F(
|
|
495
685
|
"div",
|
|
496
686
|
{
|
|
497
|
-
ref:
|
|
498
|
-
className:
|
|
499
|
-
style: { "--pi-actions-count":
|
|
687
|
+
ref: ye,
|
|
688
|
+
className: lt,
|
|
689
|
+
style: { "--pi-actions-count": ut },
|
|
500
690
|
role: "group",
|
|
501
691
|
"aria-label": "Phone input with country selector",
|
|
502
692
|
children: [
|
|
503
|
-
/* @__PURE__ */
|
|
693
|
+
/* @__PURE__ */ C("div", { className: "pi-selector", ref: Le, children: /* @__PURE__ */ F(
|
|
504
694
|
"button",
|
|
505
695
|
{
|
|
506
696
|
type: "button",
|
|
507
|
-
className: `pi-selector-btn ${!
|
|
508
|
-
disabled:
|
|
509
|
-
tabIndex:
|
|
510
|
-
"aria-label": `Selected country: ${
|
|
511
|
-
"aria-expanded":
|
|
512
|
-
"aria-haspopup":
|
|
513
|
-
onClick:
|
|
514
|
-
V || !ve || (q ? Z() : (ne.current && clearTimeout(ne.current), Re(!1), $e(!0), le(0)));
|
|
515
|
-
},
|
|
697
|
+
className: `pi-selector-btn ${!te || l ? "no-dropdown" : ""}`,
|
|
698
|
+
disabled: c,
|
|
699
|
+
tabIndex: Y || !te ? -1 : void 0,
|
|
700
|
+
"aria-label": `Selected country: ${w.name}`,
|
|
701
|
+
"aria-expanded": le,
|
|
702
|
+
"aria-haspopup": te ? "listbox" : void 0,
|
|
703
|
+
onClick: nt,
|
|
516
704
|
children: [
|
|
517
|
-
/* @__PURE__ */
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
-
!
|
|
705
|
+
/* @__PURE__ */ C("span", { className: "pi-flag", role: "img", "aria-label": `${w.name} flag`, children: B ? B(w) : w.flag }),
|
|
706
|
+
/* @__PURE__ */ C("span", { className: "pi-code", children: w.code }),
|
|
707
|
+
!Y && te && /* @__PURE__ */ C(
|
|
520
708
|
"svg",
|
|
521
709
|
{
|
|
522
|
-
className: `pi-chevron ${
|
|
710
|
+
className: `pi-chevron ${le ? "is-open" : ""}`,
|
|
523
711
|
width: "12",
|
|
524
712
|
height: "12",
|
|
525
713
|
viewBox: "0 0 12 12",
|
|
526
714
|
fill: "none",
|
|
527
715
|
"aria-hidden": "true",
|
|
528
|
-
children: /* @__PURE__ */
|
|
716
|
+
children: /* @__PURE__ */ C(
|
|
529
717
|
"path",
|
|
530
718
|
{
|
|
531
719
|
d: "M2.5 4.5L6 8L9.5 4.5",
|
|
@@ -540,11 +728,11 @@ const Bt = ({ ref: e, ...r }) => {
|
|
|
540
728
|
]
|
|
541
729
|
}
|
|
542
730
|
) }),
|
|
543
|
-
/* @__PURE__ */
|
|
544
|
-
/* @__PURE__ */
|
|
731
|
+
/* @__PURE__ */ F("div", { className: "pi-input-wrap", children: [
|
|
732
|
+
/* @__PURE__ */ C(
|
|
545
733
|
"input",
|
|
546
734
|
{
|
|
547
|
-
ref:
|
|
735
|
+
ref: ae,
|
|
548
736
|
type: "tel",
|
|
549
737
|
inputMode: "tel",
|
|
550
738
|
autoComplete: "tel-national",
|
|
@@ -552,27 +740,30 @@ const Bt = ({ ref: e, ...r }) => {
|
|
|
552
740
|
autoCapitalize: "off",
|
|
553
741
|
spellCheck: !1,
|
|
554
742
|
className: "pi-input",
|
|
555
|
-
placeholder:
|
|
556
|
-
value:
|
|
557
|
-
disabled:
|
|
558
|
-
readOnly:
|
|
559
|
-
"aria-invalid":
|
|
560
|
-
onInput:
|
|
561
|
-
|
|
562
|
-
|
|
743
|
+
placeholder: S,
|
|
744
|
+
value: H,
|
|
745
|
+
disabled: c,
|
|
746
|
+
readOnly: l,
|
|
747
|
+
"aria-invalid": Se,
|
|
748
|
+
onInput: ze,
|
|
749
|
+
onBeforeInput: _e,
|
|
750
|
+
onKeyDown: Xe,
|
|
751
|
+
onPaste: Qe,
|
|
752
|
+
onFocus: at,
|
|
753
|
+
onBlur: D
|
|
563
754
|
}
|
|
564
755
|
),
|
|
565
|
-
/* @__PURE__ */
|
|
566
|
-
|
|
567
|
-
|
|
756
|
+
/* @__PURE__ */ F("div", { className: "pi-actions", role: "toolbar", "aria-label": "Phone input actions", children: [
|
|
757
|
+
Z && Z(),
|
|
758
|
+
Me && /* @__PURE__ */ C(
|
|
568
759
|
"button",
|
|
569
760
|
{
|
|
570
761
|
type: "button",
|
|
571
|
-
className: `pi-btn ${
|
|
572
|
-
"aria-label":
|
|
573
|
-
title:
|
|
574
|
-
onClick:
|
|
575
|
-
children:
|
|
762
|
+
className: `pi-btn pi-btn-copy ${ce ? "is-copied" : ""}`,
|
|
763
|
+
"aria-label": Ye,
|
|
764
|
+
title: Je,
|
|
765
|
+
onClick: je,
|
|
766
|
+
children: Q ? Q(ce) : ce ? /* @__PURE__ */ C("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ C("path", { d: "M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z", fill: "currentColor" }) }) : /* @__PURE__ */ C("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ C(
|
|
576
767
|
"path",
|
|
577
768
|
{
|
|
578
769
|
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",
|
|
@@ -581,15 +772,15 @@ const Bt = ({ ref: e, ...r }) => {
|
|
|
581
772
|
) })
|
|
582
773
|
}
|
|
583
774
|
),
|
|
584
|
-
|
|
775
|
+
Ie && /* @__PURE__ */ C(
|
|
585
776
|
"button",
|
|
586
777
|
{
|
|
587
778
|
type: "button",
|
|
588
|
-
className: "pi-btn",
|
|
589
|
-
"aria-label":
|
|
590
|
-
title:
|
|
591
|
-
onClick:
|
|
592
|
-
children:
|
|
779
|
+
className: "pi-btn pi-btn-clear",
|
|
780
|
+
"aria-label": L,
|
|
781
|
+
title: L,
|
|
782
|
+
onClick: ct,
|
|
783
|
+
children: U ? U() : /* @__PURE__ */ C("svg", { width: "11", height: "11", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ C(
|
|
593
784
|
"path",
|
|
594
785
|
{
|
|
595
786
|
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",
|
|
@@ -603,262 +794,125 @@ const Bt = ({ ref: e, ...r }) => {
|
|
|
603
794
|
]
|
|
604
795
|
}
|
|
605
796
|
),
|
|
606
|
-
|
|
607
|
-
/* @__PURE__ */
|
|
797
|
+
le && typeof document < "u" && ht(
|
|
798
|
+
/* @__PURE__ */ F(
|
|
608
799
|
"div",
|
|
609
800
|
{
|
|
610
|
-
ref:
|
|
611
|
-
className: `phone-dropdown ${
|
|
612
|
-
style:
|
|
801
|
+
ref: De,
|
|
802
|
+
className: `phone-dropdown ${N} ${Te} ${qe ? "is-closing" : ""}`,
|
|
803
|
+
style: tt,
|
|
613
804
|
role: "dialog",
|
|
614
805
|
"aria-modal": "false",
|
|
615
806
|
"aria-label": "Select country",
|
|
807
|
+
onAnimationEnd: it,
|
|
616
808
|
children: [
|
|
617
|
-
/* @__PURE__ */
|
|
809
|
+
/* @__PURE__ */ C("div", { className: "pi-search-wrap", children: /* @__PURE__ */ C(
|
|
618
810
|
"input",
|
|
619
811
|
{
|
|
620
|
-
ref:
|
|
812
|
+
ref: ve,
|
|
621
813
|
type: "search",
|
|
622
814
|
className: "pi-search",
|
|
623
815
|
"aria-label": "Search countries",
|
|
624
|
-
placeholder:
|
|
625
|
-
value:
|
|
626
|
-
onChange:
|
|
627
|
-
|
|
628
|
-
},
|
|
629
|
-
onKeyDown: Ct
|
|
816
|
+
placeholder: f,
|
|
817
|
+
value: et,
|
|
818
|
+
onChange: rt,
|
|
819
|
+
onKeyDown: st
|
|
630
820
|
}
|
|
631
821
|
) }),
|
|
632
|
-
/* @__PURE__ */
|
|
822
|
+
/* @__PURE__ */ C("ul", { className: "pi-options", role: "listbox", "aria-activedescendant": `option-${be}`, tabIndex: -1, children: Ee.length > 0 ? Ee.map((M, de) => /* @__PURE__ */ F(
|
|
633
823
|
"li",
|
|
634
824
|
{
|
|
635
|
-
id: `option-${
|
|
825
|
+
id: `option-${de}`,
|
|
636
826
|
role: "option",
|
|
637
|
-
className: `pi-option ${
|
|
638
|
-
"aria-selected":
|
|
639
|
-
title:
|
|
640
|
-
onClick: () =>
|
|
641
|
-
onMouseEnter: () =>
|
|
827
|
+
className: `pi-option ${de === be ? "is-focused" : ""} ${M.id === w.id ? "is-selected" : ""}`,
|
|
828
|
+
"aria-selected": M.id === w.id,
|
|
829
|
+
title: M.name,
|
|
830
|
+
onClick: () => ue(M.id),
|
|
831
|
+
onMouseEnter: () => ot(de),
|
|
642
832
|
children: [
|
|
643
|
-
/* @__PURE__ */
|
|
644
|
-
/* @__PURE__ */
|
|
645
|
-
/* @__PURE__ */
|
|
833
|
+
/* @__PURE__ */ C("span", { className: "pi-flag", role: "img", "aria-label": `${M.name} flag`, children: B ? B(M) : M.flag }),
|
|
834
|
+
/* @__PURE__ */ C("span", { className: "pi-opt-name", children: M.name }),
|
|
835
|
+
/* @__PURE__ */ C("span", { className: "pi-opt-code", children: M.code })
|
|
646
836
|
]
|
|
647
837
|
},
|
|
648
|
-
|
|
649
|
-
)) : /* @__PURE__ */
|
|
838
|
+
M.id
|
|
839
|
+
)) : /* @__PURE__ */ C("li", { className: "pi-empty", children: b }) })
|
|
650
840
|
]
|
|
651
841
|
}
|
|
652
842
|
),
|
|
653
843
|
document.body
|
|
654
844
|
),
|
|
655
|
-
/* @__PURE__ */
|
|
845
|
+
/* @__PURE__ */ C("div", { ref: we, className: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" })
|
|
656
846
|
] });
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
function
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
e.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}, [e.country, y]), B(() => {
|
|
698
|
-
const o = r.current;
|
|
699
|
-
o && (o.value = M, o.placeholder = d.getPlaceholder());
|
|
700
|
-
}, [M, d]), B(() => {
|
|
701
|
-
if (e.onChange) {
|
|
702
|
-
const o = {
|
|
703
|
-
full: D,
|
|
704
|
-
fullFormatted: $,
|
|
705
|
-
digits: t
|
|
706
|
-
};
|
|
707
|
-
e.onChange(o);
|
|
708
|
-
}
|
|
709
|
-
}, [t, D, $]);
|
|
710
|
-
const Me = b((o) => {
|
|
711
|
-
const m = o.data;
|
|
712
|
-
if (o.inputType !== "insertText" || !m) return;
|
|
713
|
-
const h = r.current;
|
|
714
|
-
h && (at.test(m) || m === " " && h.value.endsWith(" ")) && o.preventDefault();
|
|
715
|
-
}, []), ie = b(() => {
|
|
716
|
-
const o = r.current;
|
|
717
|
-
if (!o) return;
|
|
718
|
-
const m = o.value || "", h = d.getMaxDigits(), L = j(m, h);
|
|
719
|
-
s(L), setTimeout(() => {
|
|
720
|
-
const T = d.getCaretPosition(L.length);
|
|
721
|
-
R(o, T);
|
|
722
|
-
}, 0);
|
|
723
|
-
}, [d]), Le = b(
|
|
724
|
-
(o) => {
|
|
725
|
-
const m = r.current;
|
|
726
|
-
if (!m || o.ctrlKey || o.metaKey || o.altKey || it.includes(o.key)) return;
|
|
727
|
-
const [h, L] = Ie(m);
|
|
728
|
-
if (o.key === "Backspace") {
|
|
729
|
-
if (o.preventDefault(), h !== L) {
|
|
730
|
-
const T = d.getDigitRange(t, h, L);
|
|
731
|
-
if (T) {
|
|
732
|
-
const [C, N] = T, E = t.slice(0, C) + t.slice(N);
|
|
733
|
-
s(E), setTimeout(() => {
|
|
734
|
-
const F = d.getCaretPosition(C);
|
|
735
|
-
R(m, F);
|
|
736
|
-
}, 0);
|
|
737
|
-
}
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (h > 0) {
|
|
741
|
-
const T = m.value;
|
|
742
|
-
let C = h - 1;
|
|
743
|
-
for (; C >= 0 && st.includes(T[C]); )
|
|
744
|
-
C--;
|
|
745
|
-
if (C >= 0) {
|
|
746
|
-
const N = d.getDigitRange(t, C, C + 1);
|
|
747
|
-
if (N) {
|
|
748
|
-
const [E] = N, F = t.slice(0, E) + t.slice(E + 1);
|
|
749
|
-
s(F), setTimeout(() => {
|
|
750
|
-
const ae = d.getCaretPosition(E);
|
|
751
|
-
R(m, ae);
|
|
752
|
-
}, 0);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
if (o.key === "Delete") {
|
|
759
|
-
if (o.preventDefault(), h !== L) {
|
|
760
|
-
const T = d.getDigitRange(t, h, L);
|
|
761
|
-
if (T) {
|
|
762
|
-
const [C, N] = T, E = t.slice(0, C) + t.slice(N);
|
|
763
|
-
s(E), setTimeout(() => {
|
|
764
|
-
const F = d.getCaretPosition(C);
|
|
765
|
-
R(m, F);
|
|
766
|
-
}, 0);
|
|
767
|
-
}
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
if (h < m.value.length) {
|
|
771
|
-
const T = d.getDigitRange(t, h, h + 1);
|
|
772
|
-
if (T) {
|
|
773
|
-
const [C] = T, N = t.slice(0, C) + t.slice(C + 1);
|
|
774
|
-
s(N), setTimeout(() => {
|
|
775
|
-
const E = d.getCaretPosition(C);
|
|
776
|
-
R(m, E);
|
|
777
|
-
}, 0);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
if (/^[0-9]$/.test(o.key)) {
|
|
783
|
-
t.length >= d.getMaxDigits() && o.preventDefault();
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
o.key.length === 1 && o.preventDefault();
|
|
787
|
-
},
|
|
788
|
-
[t, d]
|
|
789
|
-
), Se = b(
|
|
790
|
-
(o) => {
|
|
791
|
-
o.preventDefault();
|
|
792
|
-
const m = r.current;
|
|
793
|
-
if (!m) return;
|
|
794
|
-
const h = o.clipboardData?.getData("text") || "", L = d.getMaxDigits(), T = j(h, L);
|
|
795
|
-
if (T.length === 0) return;
|
|
796
|
-
const [C, N] = Ie(m);
|
|
797
|
-
if (C !== N) {
|
|
798
|
-
const Q = d.getDigitRange(t, C, N);
|
|
799
|
-
if (Q) {
|
|
800
|
-
const [ye, Ce] = Q, ke = t.slice(0, ye), H = t.slice(Ce), I = j(ke + T + H, L);
|
|
801
|
-
s(I), setTimeout(() => {
|
|
802
|
-
const ce = d.getCaretPosition(ye + T.length);
|
|
803
|
-
R(m, ce);
|
|
804
|
-
}, 0);
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
const E = d.getDigitRange(t, C, C), F = E ? E[0] : t.length, ae = t.slice(0, F), U = t.slice(F), he = j(ae + T + U, L);
|
|
809
|
-
s(he), setTimeout(() => {
|
|
810
|
-
const Q = d.getCaretPosition(F + T.length);
|
|
811
|
-
R(m, Q);
|
|
812
|
-
}, 0);
|
|
813
|
-
},
|
|
814
|
-
[t, d]
|
|
815
|
-
);
|
|
816
|
-
B(() => {
|
|
817
|
-
const o = r.current;
|
|
818
|
-
if (!o) return;
|
|
819
|
-
o.setAttribute("type", "tel"), o.setAttribute("inputmode", "tel"), o.setAttribute("placeholder", d.getPlaceholder());
|
|
820
|
-
const m = Me, h = Le, L = Se;
|
|
821
|
-
return o.addEventListener("beforeinput", m), o.addEventListener("input", ie), o.addEventListener("keydown", h), o.addEventListener("paste", L), () => {
|
|
822
|
-
o.removeEventListener("beforeinput", m), o.removeEventListener("input", ie), o.removeEventListener("keydown", h), o.removeEventListener("paste", L);
|
|
847
|
+
}, Zt = pt(Wt);
|
|
848
|
+
Zt.displayName = "PhoneInput";
|
|
849
|
+
function jt(e) {
|
|
850
|
+
const t = R(null), { country: n, setCountry: r } = Ue({
|
|
851
|
+
country: e.country,
|
|
852
|
+
locale: e.locale,
|
|
853
|
+
detect: e.detect,
|
|
854
|
+
onCountryChange: e.onCountryChange
|
|
855
|
+
}), {
|
|
856
|
+
digits: s,
|
|
857
|
+
formatter: o,
|
|
858
|
+
displayPlaceholder: a,
|
|
859
|
+
displayValue: i,
|
|
860
|
+
full: c,
|
|
861
|
+
fullFormatted: l,
|
|
862
|
+
isComplete: u,
|
|
863
|
+
isEmpty: d,
|
|
864
|
+
shouldShowWarn: p
|
|
865
|
+
} = Ke({
|
|
866
|
+
country: n,
|
|
867
|
+
value: e.value,
|
|
868
|
+
onChange: e.onChange,
|
|
869
|
+
onPhoneChange: e.onPhoneChange
|
|
870
|
+
}), { handleBeforeInput: f, handleInput: b, handleKeydown: L, handlePaste: N } = $e({
|
|
871
|
+
formatter: o,
|
|
872
|
+
digits: s,
|
|
873
|
+
onChange: e.onChange
|
|
874
|
+
});
|
|
875
|
+
v(() => {
|
|
876
|
+
const g = t.current;
|
|
877
|
+
g && (g.setAttribute("type", "tel"), g.setAttribute("inputmode", "tel"));
|
|
878
|
+
}, []), v(() => {
|
|
879
|
+
const g = t.current;
|
|
880
|
+
g && (g.value = i, g.setAttribute("placeholder", a));
|
|
881
|
+
}, [i, a]), v(() => {
|
|
882
|
+
const g = t.current;
|
|
883
|
+
if (!g) return;
|
|
884
|
+
const A = f, E = b, k = L, x = N;
|
|
885
|
+
return g.addEventListener("beforeinput", A), g.addEventListener("input", E), g.addEventListener("keydown", k), g.addEventListener("paste", x), () => {
|
|
886
|
+
g.removeEventListener("beforeinput", A), g.removeEventListener("input", E), g.removeEventListener("keydown", k), g.removeEventListener("paste", x);
|
|
823
887
|
};
|
|
824
|
-
}, [
|
|
825
|
-
const
|
|
826
|
-
(
|
|
827
|
-
|
|
828
|
-
c(m);
|
|
829
|
-
const L = He(m).getMaxDigits();
|
|
830
|
-
t.length > L && s(t.slice(0, L)), e.onCountryChange?.(m);
|
|
831
|
-
},
|
|
832
|
-
[y, t, e]
|
|
833
|
-
), X = b(() => {
|
|
834
|
-
s("");
|
|
835
|
-
const o = r.current;
|
|
836
|
-
o && (o.value = "");
|
|
837
|
-
}, []);
|
|
888
|
+
}, [f, b, L, N]);
|
|
889
|
+
const P = h(() => {
|
|
890
|
+
e.onChange("");
|
|
891
|
+
}, [e.onChange]);
|
|
838
892
|
return {
|
|
839
|
-
ref:
|
|
840
|
-
digits:
|
|
841
|
-
full:
|
|
842
|
-
fullFormatted:
|
|
843
|
-
isComplete:
|
|
844
|
-
isEmpty:
|
|
845
|
-
shouldShowWarn:
|
|
846
|
-
country:
|
|
847
|
-
setCountry:
|
|
848
|
-
clear:
|
|
893
|
+
ref: t,
|
|
894
|
+
digits: s,
|
|
895
|
+
full: c,
|
|
896
|
+
fullFormatted: l,
|
|
897
|
+
isComplete: u,
|
|
898
|
+
isEmpty: d,
|
|
899
|
+
shouldShowWarn: p,
|
|
900
|
+
country: n,
|
|
901
|
+
setCountry: r,
|
|
902
|
+
clear: P
|
|
849
903
|
};
|
|
850
904
|
}
|
|
851
|
-
const
|
|
852
|
-
getFlagEmoji:
|
|
853
|
-
countPlaceholders:
|
|
854
|
-
formatDigitsWithMap:
|
|
855
|
-
pickMaskVariant:
|
|
856
|
-
removeCountryCodePrefix:
|
|
857
|
-
toArray:
|
|
905
|
+
const _t = {
|
|
906
|
+
getFlagEmoji: yt,
|
|
907
|
+
countPlaceholders: ge,
|
|
908
|
+
formatDigitsWithMap: re,
|
|
909
|
+
pickMaskVariant: Ge,
|
|
910
|
+
removeCountryCodePrefix: fe,
|
|
911
|
+
toArray: Ve
|
|
858
912
|
};
|
|
859
913
|
export {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
914
|
+
_t as PMaskHelpers,
|
|
915
|
+
Zt as PhoneInput,
|
|
916
|
+
jt as usePhoneMask
|
|
863
917
|
};
|
|
864
918
|
//# sourceMappingURL=index.js.map
|