@desource/phone-mask-svelte 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 +35 -0
- package/LICENSE +21 -0
- package/README.md +529 -0
- package/dist/index.cjs +1301 -0
- package/dist/index.mjs +1284 -0
- package/dist/phone-mask-svelte.css +383 -0
- package/dist/types/composables/internal/useCopyAction.svelte.d.ts +13 -0
- package/dist/types/composables/internal/useCopyAction.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useCountry.svelte.d.ts +17 -0
- package/dist/types/composables/internal/useCountry.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useCountrySelector.svelte.d.ts +31 -0
- package/dist/types/composables/internal/useCountrySelector.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useFormatter.svelte.d.ts +29 -0
- package/dist/types/composables/internal/useFormatter.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useInputHandlers.svelte.d.ts +18 -0
- package/dist/types/composables/internal/useInputHandlers.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useTheme.svelte.d.ts +9 -0
- package/dist/types/composables/internal/useTheme.svelte.d.ts.map +1 -0
- package/dist/types/composables/internal/useValidationHint.svelte.d.ts +6 -0
- package/dist/types/composables/internal/useValidationHint.svelte.d.ts.map +1 -0
- package/dist/types/composables/usePhoneMask.svelte.d.ts +31 -0
- package/dist/types/composables/usePhoneMask.svelte.d.ts.map +1 -0
- package/dist/types/composables/utility/useClipboard.svelte.d.ts +6 -0
- package/dist/types/composables/utility/useClipboard.svelte.d.ts.map +1 -0
- package/dist/types/composables/utility/useTimer.svelte.d.ts +8 -0
- package/dist/types/composables/utility/useTimer.svelte.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +84 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +77 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("svelte/internal/disclose-version");
|
|
4
|
+
const $ = require("svelte/internal/client");
|
|
5
|
+
const svelte = require("svelte");
|
|
6
|
+
function _interopNamespaceDefault(e2) {
|
|
7
|
+
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e2) {
|
|
9
|
+
for (const k2 in e2) {
|
|
10
|
+
if (k2 !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e2, k2);
|
|
12
|
+
Object.defineProperty(n2, k2, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e2[k2]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n2.default = e2;
|
|
20
|
+
return Object.freeze(n2);
|
|
21
|
+
}
|
|
22
|
+
const $__namespace = /* @__PURE__ */ _interopNamespaceDefault($);
|
|
23
|
+
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 #### ######"] };
|
|
24
|
+
const t$1 = /^[a-z]{2}$/i, countryCodeEmoji = (o2) => {
|
|
25
|
+
if (!t$1.test(o2)) {
|
|
26
|
+
const t2 = typeof o2;
|
|
27
|
+
throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string" === t2 ? o2 : t2}' instead.`);
|
|
28
|
+
}
|
|
29
|
+
const e2 = [...o2.toUpperCase()].map((t2) => (t2.codePointAt(0) ?? 0) + 127397);
|
|
30
|
+
return String.fromCodePoint(...e2);
|
|
31
|
+
};
|
|
32
|
+
const o$1 = "en", n = /* @__PURE__ */ new Map(), getDisplayNames = (e2) => {
|
|
33
|
+
const t2 = e2.toLowerCase(), s2 = n.get(t2);
|
|
34
|
+
if (s2) return s2;
|
|
35
|
+
const r = new Intl.DisplayNames([e2], { type: "region" });
|
|
36
|
+
if (n.size >= 10) {
|
|
37
|
+
for (const e3 of n.keys()) if (e3 !== o$1) {
|
|
38
|
+
n.delete(e3);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return n.set(t2, r), r;
|
|
43
|
+
}, s$1 = Object.entries(M), divideMask = (e2) => e2.split(/ (.*)/s);
|
|
44
|
+
function getCodeAndMask(e2) {
|
|
45
|
+
let t2 = "", o2 = "";
|
|
46
|
+
if (Array.isArray(e2)) {
|
|
47
|
+
const n2 = [];
|
|
48
|
+
for (const o3 of e2) {
|
|
49
|
+
const [e3, s2] = divideMask(o3);
|
|
50
|
+
t2 || (t2 = e3), n2.push(s2);
|
|
51
|
+
}
|
|
52
|
+
o2 = n2;
|
|
53
|
+
} else {
|
|
54
|
+
const [n2, s2] = divideMask(e2);
|
|
55
|
+
t2 = n2, o2 = s2;
|
|
56
|
+
}
|
|
57
|
+
return [t2, o2];
|
|
58
|
+
}
|
|
59
|
+
s$1.map(([e2, t2]) => ({ id: e2, mask: t2 }));
|
|
60
|
+
s$1.reduce((e2, [t2, o2]) => {
|
|
61
|
+
const [n2, s2] = getCodeAndMask(o2);
|
|
62
|
+
return e2[t2] = { code: n2, mask: s2 }, e2;
|
|
63
|
+
}, {});
|
|
64
|
+
s$1.map(([e2, t2]) => {
|
|
65
|
+
const [o2, n2] = getCodeAndMask(t2);
|
|
66
|
+
return { id: e2, code: o2, mask: n2 };
|
|
67
|
+
});
|
|
68
|
+
s$1.reduce((e2, [o2, n2]) => {
|
|
69
|
+
const [s2, r] = getCodeAndMask(n2);
|
|
70
|
+
return e2[o2] = { code: s2, mask: r, flag: countryCodeEmoji(o2) }, e2;
|
|
71
|
+
}, {});
|
|
72
|
+
s$1.map(([e2, o2]) => {
|
|
73
|
+
const [n2, s2] = getCodeAndMask(o2);
|
|
74
|
+
return { id: e2, code: n2, mask: s2, flag: countryCodeEmoji(e2) };
|
|
75
|
+
});
|
|
76
|
+
const MasksFullMap = (e2) => {
|
|
77
|
+
const o2 = getDisplayNames(e2);
|
|
78
|
+
return s$1.reduce((e3, [n2, s2]) => {
|
|
79
|
+
const [r, a] = getCodeAndMask(s2), d = o2.of(n2) ?? "";
|
|
80
|
+
return e3[n2] = { code: r, mask: a, name: d, flag: countryCodeEmoji(n2) }, e3;
|
|
81
|
+
}, {});
|
|
82
|
+
}, MasksFull = (e2) => {
|
|
83
|
+
const o2 = getDisplayNames(e2);
|
|
84
|
+
return s$1.map(([e3, n2]) => {
|
|
85
|
+
const [s2, r] = getCodeAndMask(n2);
|
|
86
|
+
return { id: e3, code: s2, mask: r, name: o2.of(e3) ?? "", flag: countryCodeEmoji(e3) };
|
|
87
|
+
});
|
|
88
|
+
}, f = MasksFullMap(o$1);
|
|
89
|
+
MasksFull(o$1);
|
|
90
|
+
const k = countryCodeEmoji;
|
|
91
|
+
function getNavigatorLang() {
|
|
92
|
+
return "undefined" != typeof navigator && navigator.language || "en";
|
|
93
|
+
}
|
|
94
|
+
function detectCountryFromLocale() {
|
|
95
|
+
try {
|
|
96
|
+
const t2 = getNavigatorLang();
|
|
97
|
+
try {
|
|
98
|
+
const e3 = new Intl.Locale(t2);
|
|
99
|
+
if (e3.region) return e3.region.toUpperCase();
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
const e2 = t2.split(/[-_]/);
|
|
103
|
+
if (e2.length > 1) return e2[1]?.toUpperCase() || null;
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function hasCountry(t2) {
|
|
109
|
+
const r = f;
|
|
110
|
+
return t2.toUpperCase() in r;
|
|
111
|
+
}
|
|
112
|
+
function getCountry(e2, r) {
|
|
113
|
+
const n2 = MasksFullMap(r), o2 = e2.toUpperCase();
|
|
114
|
+
return o2 in n2 ? { id: o2, ...n2[o2] } : { id: "US", ...n2.US };
|
|
115
|
+
}
|
|
116
|
+
function parseCountryCode(t2, e2) {
|
|
117
|
+
return t2 && hasCountry(t2) ? t2.toUpperCase() : e2 || "";
|
|
118
|
+
}
|
|
119
|
+
function toArray(t2) {
|
|
120
|
+
return Array.isArray(t2) ? t2 : [t2];
|
|
121
|
+
}
|
|
122
|
+
function countPlaceholders(t2) {
|
|
123
|
+
return (t2.match(/#/g) || []).length;
|
|
124
|
+
}
|
|
125
|
+
function removeCountryCodePrefix(t2) {
|
|
126
|
+
return t2.replace(/^\+\d+\s?/, "");
|
|
127
|
+
}
|
|
128
|
+
function pickMaskVariant(t2, e2) {
|
|
129
|
+
if (1 === t2.length) return t2[0];
|
|
130
|
+
const r = t2.map((t3) => ({ mask: t3, count: countPlaceholders(t3) })), n2 = r.filter((t3) => t3.count >= e2).sort((t3, e3) => t3.count - e3.count);
|
|
131
|
+
if (n2.length > 0) return n2[0].mask;
|
|
132
|
+
const o2 = r.sort((t3, e3) => e3.count - t3.count)[0];
|
|
133
|
+
return o2 ? o2.mask : t2[0];
|
|
134
|
+
}
|
|
135
|
+
function formatDigitsWithMap(t2, e2) {
|
|
136
|
+
let r = "";
|
|
137
|
+
const n2 = [];
|
|
138
|
+
let o2 = 0;
|
|
139
|
+
const a = e2.length, s2 = t2.length;
|
|
140
|
+
for (let c = 0; c < s2; c++) {
|
|
141
|
+
const s3 = t2[c];
|
|
142
|
+
if ("#" === s3) {
|
|
143
|
+
if (!(o2 < a)) break;
|
|
144
|
+
r += e2[o2], n2.push(o2), o2++;
|
|
145
|
+
} else {
|
|
146
|
+
const e3 = -1 !== t2.indexOf("#", c + 1) && o2 < a;
|
|
147
|
+
(r.length > 0 || e3) && (r += s3, n2.push(-1));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { display: r, map: n2 };
|
|
151
|
+
}
|
|
152
|
+
function filterCountries(t2, e2) {
|
|
153
|
+
const r = e2.trim().toUpperCase();
|
|
154
|
+
if (!r) return t2;
|
|
155
|
+
const n2 = r.replace(/\D/g, ""), o2 = n2.length > 0;
|
|
156
|
+
return t2.map((t3) => {
|
|
157
|
+
const e3 = t3.name.toUpperCase(), a = t3.id.toUpperCase(), s2 = t3.code.toUpperCase(), c = t3.code.replace(/\D/g, "");
|
|
158
|
+
let i2 = 0;
|
|
159
|
+
return e3.startsWith(r) ? i2 = 1e3 : e3.includes(r) && (i2 = 500), s2.startsWith(r) ? i2 += 100 : s2.includes(r) && (i2 += 50), a === r ? i2 += 200 : a.startsWith(r) && (i2 += 150), o2 && c.startsWith(n2) ? i2 += 80 : o2 && c.includes(n2) && (i2 += 40), { country: t3, score: i2 };
|
|
160
|
+
}).filter((t3) => t3.score > 0).sort((t3, e3) => e3.score !== t3.score ? e3.score - t3.score : t3.country.name.localeCompare(e3.country.name)).map((t3) => t3.country);
|
|
161
|
+
}
|
|
162
|
+
const t = [" ", "-", "(", ")"], e$1 = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "Tab"], i = /[^\d\s\-()]/;
|
|
163
|
+
function extractDigits(t2, e2) {
|
|
164
|
+
const i2 = t2.replace(/\D/g, "");
|
|
165
|
+
return e2 ? i2.slice(0, e2) : i2;
|
|
166
|
+
}
|
|
167
|
+
function getSelection(t2) {
|
|
168
|
+
return t2 ? [t2.selectionStart ?? 0, t2.selectionEnd ?? 0] : [0, 0];
|
|
169
|
+
}
|
|
170
|
+
function setCaret(t2, e2) {
|
|
171
|
+
if (t2) try {
|
|
172
|
+
t2.setSelectionRange(e2, e2);
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function processBeforeInput(t2) {
|
|
177
|
+
if (!t2.target) return;
|
|
178
|
+
const e2 = t2.target, n2 = t2.data;
|
|
179
|
+
"insertText" === t2.inputType && n2 && (i.test(n2) || " " === n2 && e2.value.endsWith(" ")) && t2.preventDefault();
|
|
180
|
+
}
|
|
181
|
+
function processInput(t2, e2) {
|
|
182
|
+
if (!t2.target) return;
|
|
183
|
+
const i2 = t2.target, { formatter: n2 } = e2, r = n2.getMaxDigits(), s2 = extractDigits(i2.value, r);
|
|
184
|
+
return { newDigits: s2, caretDigitIndex: s2.length };
|
|
185
|
+
}
|
|
186
|
+
function processKeydown(i2, n2) {
|
|
187
|
+
if (!i2.target) return;
|
|
188
|
+
const r = i2.target, { digits: s2, formatter: c } = n2;
|
|
189
|
+
if (i2.ctrlKey || i2.metaKey || i2.altKey || e$1.includes(i2.key)) return;
|
|
190
|
+
const [g, a] = getSelection(r);
|
|
191
|
+
if ("Backspace" !== i2.key) if ("Delete" !== i2.key) /^[0-9]$/.test(i2.key) ? s2.length >= c.getMaxDigits() && i2.preventDefault() : 1 === i2.key.length && i2.preventDefault();
|
|
192
|
+
else {
|
|
193
|
+
if (i2.preventDefault(), g !== a) {
|
|
194
|
+
const t2 = c.getDigitRange(s2, g, a);
|
|
195
|
+
if (t2) {
|
|
196
|
+
const [e2, i3] = t2;
|
|
197
|
+
return { newDigits: s2.slice(0, e2) + s2.slice(i3), caretDigitIndex: e2 };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (g < r.value.length) {
|
|
201
|
+
const t2 = c.getDigitRange(s2, g, r.value.length);
|
|
202
|
+
if (t2) {
|
|
203
|
+
const [e2] = t2;
|
|
204
|
+
return { newDigits: s2.slice(0, e2) + s2.slice(e2 + 1), caretDigitIndex: e2 };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
if (i2.preventDefault(), g !== a) {
|
|
210
|
+
const t2 = c.getDigitRange(s2, g, a);
|
|
211
|
+
if (t2) {
|
|
212
|
+
const [e2, i3] = t2;
|
|
213
|
+
return { newDigits: s2.slice(0, e2) + s2.slice(i3), caretDigitIndex: e2 };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (g > 0) {
|
|
217
|
+
const e2 = r.value;
|
|
218
|
+
let i3 = g - 1;
|
|
219
|
+
for (; i3 >= 0 && t.includes(e2[i3]); ) i3--;
|
|
220
|
+
if (i3 >= 0) {
|
|
221
|
+
const t2 = c.getDigitRange(s2, i3, i3 + 1);
|
|
222
|
+
if (t2) {
|
|
223
|
+
const [e3] = t2;
|
|
224
|
+
return { newDigits: s2.slice(0, e3) + s2.slice(e3 + 1), caretDigitIndex: e3 };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function processPaste(t2, e2) {
|
|
231
|
+
if (!t2.target) return;
|
|
232
|
+
t2.preventDefault();
|
|
233
|
+
const i2 = t2.target, { digits: n2, formatter: r } = e2, s2 = t2.clipboardData?.getData("text") || "", c = r.getMaxDigits(), g = extractDigits(s2, c);
|
|
234
|
+
if (0 === g.length) return;
|
|
235
|
+
const [a, o2] = getSelection(i2);
|
|
236
|
+
if (a !== o2) {
|
|
237
|
+
const t3 = r.getDigitRange(n2, a, o2);
|
|
238
|
+
if (t3) {
|
|
239
|
+
const [e3, i3] = t3;
|
|
240
|
+
return { newDigits: extractDigits(n2.slice(0, e3) + g + n2.slice(i3), c), caretDigitIndex: e3 + g.length };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const l = r.getDigitRange(n2, 0, a), f2 = l ? l[1] : 0;
|
|
244
|
+
return { newDigits: extractDigits(n2.slice(0, f2) + g + n2.slice(f2), c), caretDigitIndex: f2 + g.length };
|
|
245
|
+
}
|
|
246
|
+
function createPhoneFormatter(o2) {
|
|
247
|
+
const a = toArray(o2.mask), i2 = a.map((n2) => countPlaceholders(removeCountryCodePrefix(n2))), g = Math.max(...i2), getMask = (t2) => {
|
|
248
|
+
const n2 = pickMaskVariant(a, t2);
|
|
249
|
+
return removeCountryCodePrefix(n2);
|
|
250
|
+
};
|
|
251
|
+
return { formatDisplay: (t2) => {
|
|
252
|
+
const e2 = getMask(t2.length);
|
|
253
|
+
return formatDigitsWithMap(e2, t2).display;
|
|
254
|
+
}, getMaxDigits: () => g, getPlaceholder: () => getMask(0), getCaretPosition: (t2) => {
|
|
255
|
+
const e2 = getMask(t2), { display: r, map: l } = formatDigitsWithMap(e2, "0".repeat(t2));
|
|
256
|
+
for (let e3 = 0; e3 < l.length; e3++) if (l[e3] === t2) return e3;
|
|
257
|
+
if (t2 >= l.length) return r.length;
|
|
258
|
+
for (let e3 = 0; e3 < l.length; e3++) if (l[e3] > t2) return e3;
|
|
259
|
+
return r.length;
|
|
260
|
+
}, getDigitRange: (t2, e2, r) => {
|
|
261
|
+
const l = getMask(t2.length), { map: o3 } = formatDigitsWithMap(l, t2);
|
|
262
|
+
let a2 = 1 / 0, i3 = -1 / 0;
|
|
263
|
+
for (let t3 = e2; t3 < r && t3 < o3.length; t3++) {
|
|
264
|
+
const e3 = o3[t3];
|
|
265
|
+
void 0 !== e3 && e3 >= 0 && (a2 = Math.min(a2, e3), i3 = Math.max(i3, e3));
|
|
266
|
+
}
|
|
267
|
+
return a2 === 1 / 0 ? null : [a2, i3 + 1];
|
|
268
|
+
}, isComplete: (t2) => i2.includes(t2.length) };
|
|
269
|
+
}
|
|
270
|
+
const o = "https://ipapi.co/json/", e = 1500, p = "@desource/phone-mask:geo", s = 864e5;
|
|
271
|
+
async function detectCountryFromGeoIP(t2 = o, r = e) {
|
|
272
|
+
const n2 = new AbortController(), c = setTimeout(() => n2.abort(), r);
|
|
273
|
+
try {
|
|
274
|
+
const o2 = await fetch(t2, { signal: n2.signal, headers: { Accept: "application/json" } });
|
|
275
|
+
if (clearTimeout(c), !o2.ok) return null;
|
|
276
|
+
const e2 = await o2.json();
|
|
277
|
+
return (e2.country || e2.country_code || e2.countryCode || e2.country_code2 || "").toString().toUpperCase() || null;
|
|
278
|
+
} catch {
|
|
279
|
+
return clearTimeout(c), null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async function detectByGeoIp() {
|
|
283
|
+
try {
|
|
284
|
+
const o3 = localStorage.getItem(p);
|
|
285
|
+
if (o3) {
|
|
286
|
+
const e3 = JSON.parse(o3), c = Date.now() - e3.ts > s, a = parseCountryCode(e3.country_code);
|
|
287
|
+
if (a && !c) return a;
|
|
288
|
+
localStorage.removeItem(p);
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
}
|
|
292
|
+
const o2 = await detectCountryFromGeoIP(), e2 = parseCountryCode(o2);
|
|
293
|
+
if (e2) {
|
|
294
|
+
try {
|
|
295
|
+
const t2 = JSON.stringify({ country_code: e2, ts: Date.now() });
|
|
296
|
+
localStorage.setItem(p, t2);
|
|
297
|
+
} catch {
|
|
298
|
+
}
|
|
299
|
+
return e2;
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
function useCountry({
|
|
304
|
+
country: countryOption,
|
|
305
|
+
locale: localeOption,
|
|
306
|
+
detect,
|
|
307
|
+
onCountryChange
|
|
308
|
+
} = {}) {
|
|
309
|
+
let countryCode = $__namespace.state($__namespace.proxy(parseCountryCode(countryOption?.(), "US")));
|
|
310
|
+
const locale = $__namespace.derived(() => localeOption?.() || getNavigatorLang());
|
|
311
|
+
const country = $__namespace.derived(() => getCountry($__namespace.get(countryCode), $__namespace.get(locale)));
|
|
312
|
+
const setCountry = (code) => {
|
|
313
|
+
const parsed = parseCountryCode(code);
|
|
314
|
+
if (parsed) {
|
|
315
|
+
$__namespace.set(countryCode, parsed, true);
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
};
|
|
320
|
+
const detectCountry = async () => {
|
|
321
|
+
const geoCountry = await detectByGeoIp();
|
|
322
|
+
if (setCountry(geoCountry)) return;
|
|
323
|
+
const localeCountry = detectCountryFromLocale();
|
|
324
|
+
setCountry(localeCountry);
|
|
325
|
+
};
|
|
326
|
+
$__namespace.user_effect(() => {
|
|
327
|
+
const newCountry = countryOption?.();
|
|
328
|
+
if (newCountry && newCountry !== $__namespace.get(countryCode)) {
|
|
329
|
+
setCountry(newCountry);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
$__namespace.user_effect(() => {
|
|
333
|
+
if (detect?.() && !countryOption?.()) {
|
|
334
|
+
detectCountry();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
$__namespace.user_effect(() => {
|
|
338
|
+
onCountryChange?.($__namespace.get(country));
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
get country() {
|
|
342
|
+
return $__namespace.get(country);
|
|
343
|
+
},
|
|
344
|
+
get locale() {
|
|
345
|
+
return $__namespace.get(locale);
|
|
346
|
+
},
|
|
347
|
+
setCountry
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function useFormatter({ country, value, onChange, onPhoneChange, onValidationChange }) {
|
|
351
|
+
const formatter = $__namespace.derived(() => createPhoneFormatter(country()));
|
|
352
|
+
const maxDigits = $__namespace.derived(() => $__namespace.get(formatter).getMaxDigits());
|
|
353
|
+
const digits = $__namespace.derived(() => extractDigits(value(), $__namespace.get(maxDigits)));
|
|
354
|
+
const displayPlaceholder = $__namespace.derived(() => $__namespace.get(formatter).getPlaceholder());
|
|
355
|
+
const displayValue = $__namespace.derived(() => $__namespace.get(formatter).formatDisplay($__namespace.get(digits)));
|
|
356
|
+
const full = $__namespace.derived(() => $__namespace.get(digits) ? `${country().code}${$__namespace.get(digits)}` : "");
|
|
357
|
+
const fullFormatted = $__namespace.derived(() => $__namespace.get(displayValue) ? `${country().code} ${$__namespace.get(displayValue)}` : "");
|
|
358
|
+
const isComplete = $__namespace.derived(() => $__namespace.get(formatter).isComplete($__namespace.get(digits)));
|
|
359
|
+
const isEmpty = $__namespace.derived(() => $__namespace.get(digits).length === 0);
|
|
360
|
+
const shouldShowWarn = $__namespace.derived(() => !$__namespace.get(isEmpty) && !$__namespace.get(isComplete));
|
|
361
|
+
const phoneData = $__namespace.derived(() => ({
|
|
362
|
+
full: $__namespace.get(full),
|
|
363
|
+
fullFormatted: $__namespace.get(fullFormatted),
|
|
364
|
+
digits: $__namespace.get(digits)
|
|
365
|
+
}));
|
|
366
|
+
$__namespace.user_pre_effect(() => {
|
|
367
|
+
const raw = value();
|
|
368
|
+
const clamped = $__namespace.get(digits);
|
|
369
|
+
if (raw !== clamped) {
|
|
370
|
+
onChange(clamped);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
$__namespace.user_effect(() => {
|
|
374
|
+
onPhoneChange?.($__namespace.get(phoneData));
|
|
375
|
+
});
|
|
376
|
+
$__namespace.user_effect(() => {
|
|
377
|
+
onValidationChange?.($__namespace.get(isComplete));
|
|
378
|
+
});
|
|
379
|
+
return {
|
|
380
|
+
get digits() {
|
|
381
|
+
return $__namespace.get(digits);
|
|
382
|
+
},
|
|
383
|
+
get formatter() {
|
|
384
|
+
return $__namespace.get(formatter);
|
|
385
|
+
},
|
|
386
|
+
get displayPlaceholder() {
|
|
387
|
+
return $__namespace.get(displayPlaceholder);
|
|
388
|
+
},
|
|
389
|
+
get displayValue() {
|
|
390
|
+
return $__namespace.get(displayValue);
|
|
391
|
+
},
|
|
392
|
+
get full() {
|
|
393
|
+
return $__namespace.get(full);
|
|
394
|
+
},
|
|
395
|
+
get fullFormatted() {
|
|
396
|
+
return $__namespace.get(fullFormatted);
|
|
397
|
+
},
|
|
398
|
+
get isComplete() {
|
|
399
|
+
return $__namespace.get(isComplete);
|
|
400
|
+
},
|
|
401
|
+
get isEmpty() {
|
|
402
|
+
return $__namespace.get(isEmpty);
|
|
403
|
+
},
|
|
404
|
+
get shouldShowWarn() {
|
|
405
|
+
return $__namespace.get(shouldShowWarn);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function useTimer() {
|
|
410
|
+
let timerRef = null;
|
|
411
|
+
const clear = () => {
|
|
412
|
+
if (timerRef) {
|
|
413
|
+
clearTimeout(timerRef);
|
|
414
|
+
timerRef = null;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const set = (callback, delay) => {
|
|
418
|
+
clear();
|
|
419
|
+
timerRef = setTimeout(callback, delay);
|
|
420
|
+
};
|
|
421
|
+
svelte.onDestroy(clear);
|
|
422
|
+
return { set, clear };
|
|
423
|
+
}
|
|
424
|
+
function useValidationHint() {
|
|
425
|
+
let showValidationHint = $__namespace.state(false);
|
|
426
|
+
const validationTimer = useTimer();
|
|
427
|
+
const clearValidationHint = (hideHint = true) => {
|
|
428
|
+
if (hideHint) $__namespace.set(showValidationHint, false);
|
|
429
|
+
validationTimer.clear();
|
|
430
|
+
};
|
|
431
|
+
const scheduleValidationHint = (delay) => {
|
|
432
|
+
$__namespace.set(showValidationHint, false);
|
|
433
|
+
validationTimer.set(
|
|
434
|
+
() => {
|
|
435
|
+
$__namespace.set(showValidationHint, true);
|
|
436
|
+
},
|
|
437
|
+
delay
|
|
438
|
+
);
|
|
439
|
+
};
|
|
440
|
+
return {
|
|
441
|
+
get showValidationHint() {
|
|
442
|
+
return $__namespace.get(showValidationHint);
|
|
443
|
+
},
|
|
444
|
+
clearValidationHint,
|
|
445
|
+
scheduleValidationHint
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const HINT_DELAY_INPUT = 500;
|
|
449
|
+
const HINT_DELAY_ACTION = 300;
|
|
450
|
+
function useInputHandlers(options) {
|
|
451
|
+
const {
|
|
452
|
+
formatter,
|
|
453
|
+
digits,
|
|
454
|
+
inactive,
|
|
455
|
+
onChange,
|
|
456
|
+
scheduleValidationHint
|
|
457
|
+
} = options;
|
|
458
|
+
const scheduleCaretUpdate = (el, digitIndex) => {
|
|
459
|
+
svelte.tick().then(() => {
|
|
460
|
+
if (!el) return;
|
|
461
|
+
const pos = formatter().getCaretPosition(digitIndex);
|
|
462
|
+
setCaret(el, pos);
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
const handleBeforeInput = (e2) => {
|
|
466
|
+
processBeforeInput(e2);
|
|
467
|
+
};
|
|
468
|
+
const handleInput = (e2) => {
|
|
469
|
+
if (inactive?.()) return;
|
|
470
|
+
const result = processInput(e2, { formatter: formatter() });
|
|
471
|
+
if (!result) return;
|
|
472
|
+
onChange?.(result.newDigits);
|
|
473
|
+
scheduleCaretUpdate(e2.target, result.caretDigitIndex);
|
|
474
|
+
scheduleValidationHint?.(HINT_DELAY_INPUT);
|
|
475
|
+
};
|
|
476
|
+
const handleKeydown = (e2) => {
|
|
477
|
+
if (inactive?.()) return;
|
|
478
|
+
const result = processKeydown(e2, { digits: digits(), formatter: formatter() });
|
|
479
|
+
if (!result) return;
|
|
480
|
+
onChange?.(result.newDigits);
|
|
481
|
+
scheduleCaretUpdate(e2.target, result.caretDigitIndex);
|
|
482
|
+
scheduleValidationHint?.(HINT_DELAY_ACTION);
|
|
483
|
+
};
|
|
484
|
+
const handlePaste = (e2) => {
|
|
485
|
+
if (inactive?.()) return;
|
|
486
|
+
const result = processPaste(e2, { digits: digits(), formatter: formatter() });
|
|
487
|
+
if (!result) return;
|
|
488
|
+
onChange?.(result.newDigits);
|
|
489
|
+
scheduleCaretUpdate(e2.target, result.caretDigitIndex);
|
|
490
|
+
scheduleValidationHint?.(HINT_DELAY_ACTION);
|
|
491
|
+
};
|
|
492
|
+
return { handleBeforeInput, handleInput, handleKeydown, handlePaste };
|
|
493
|
+
}
|
|
494
|
+
function useCountrySelector({
|
|
495
|
+
rootRef,
|
|
496
|
+
dropdownRef,
|
|
497
|
+
searchRef,
|
|
498
|
+
selectorRef,
|
|
499
|
+
locale,
|
|
500
|
+
countryOption,
|
|
501
|
+
inactive,
|
|
502
|
+
onSelectCountry,
|
|
503
|
+
onAfterSelect
|
|
504
|
+
}) {
|
|
505
|
+
let search = $__namespace.state("");
|
|
506
|
+
let dropdownOpen = $__namespace.state(false);
|
|
507
|
+
let isClosing = $__namespace.state(false);
|
|
508
|
+
let dropdownStyle = $__namespace.state($__namespace.proxy({}));
|
|
509
|
+
let focusedIndex = $__namespace.state(0);
|
|
510
|
+
const countries = $__namespace.derived(() => MasksFull(locale()));
|
|
511
|
+
const filteredCountries = $__namespace.derived(() => filterCountries($__namespace.get(countries), $__namespace.get(search)));
|
|
512
|
+
const hasDropdown = $__namespace.derived(() => !countryOption?.() && $__namespace.get(countries).length > 1);
|
|
513
|
+
const setFocusedIndex = (index) => {
|
|
514
|
+
$__namespace.set(focusedIndex, index, true);
|
|
515
|
+
};
|
|
516
|
+
const focusSearch = () => {
|
|
517
|
+
svelte.tick().then(() => searchRef()?.focus({ preventScroll: true }));
|
|
518
|
+
};
|
|
519
|
+
const closeDropdown = () => {
|
|
520
|
+
if (!$__namespace.get(dropdownOpen)) return;
|
|
521
|
+
$__namespace.set(isClosing, true);
|
|
522
|
+
};
|
|
523
|
+
const openDropdown = () => {
|
|
524
|
+
$__namespace.set(isClosing, false);
|
|
525
|
+
$__namespace.set(dropdownOpen, true);
|
|
526
|
+
setFocusedIndex(0);
|
|
527
|
+
focusSearch();
|
|
528
|
+
};
|
|
529
|
+
const handleDropdownAnimationEnd = () => {
|
|
530
|
+
if (!$__namespace.get(isClosing)) return;
|
|
531
|
+
$__namespace.set(dropdownOpen, false);
|
|
532
|
+
$__namespace.set(isClosing, false);
|
|
533
|
+
};
|
|
534
|
+
const toggleDropdown = () => {
|
|
535
|
+
if (inactive?.() || !$__namespace.get(hasDropdown)) return;
|
|
536
|
+
if ($__namespace.get(dropdownOpen)) {
|
|
537
|
+
closeDropdown();
|
|
538
|
+
} else {
|
|
539
|
+
openDropdown();
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
const selectCountry = (code) => {
|
|
543
|
+
onSelectCountry(code);
|
|
544
|
+
closeDropdown();
|
|
545
|
+
$__namespace.set(search, "");
|
|
546
|
+
setFocusedIndex(0);
|
|
547
|
+
onAfterSelect?.();
|
|
548
|
+
};
|
|
549
|
+
const handleSearchChange = (e2) => {
|
|
550
|
+
$__namespace.set(search, e2.target.value, true);
|
|
551
|
+
setFocusedIndex(0);
|
|
552
|
+
};
|
|
553
|
+
const onDocClick = (ev) => {
|
|
554
|
+
const target = ev.target;
|
|
555
|
+
const dropdownEl = dropdownRef();
|
|
556
|
+
const selectorEl = selectorRef();
|
|
557
|
+
if (!target) return;
|
|
558
|
+
if (dropdownEl?.contains(target)) return;
|
|
559
|
+
if (selectorEl?.contains(target)) return;
|
|
560
|
+
closeDropdown();
|
|
561
|
+
};
|
|
562
|
+
const positionDropdown = (e2) => {
|
|
563
|
+
if (e2?.type === "scroll" && e2.target && dropdownRef()?.contains(e2.target)) return;
|
|
564
|
+
const root2 = rootRef();
|
|
565
|
+
if (!root2) return;
|
|
566
|
+
const rect = root2.getBoundingClientRect();
|
|
567
|
+
$__namespace.set(
|
|
568
|
+
dropdownStyle,
|
|
569
|
+
{
|
|
570
|
+
top: `${rect.bottom + window.scrollY + 8}px`,
|
|
571
|
+
left: `${rect.left + window.scrollX}px`,
|
|
572
|
+
width: `${rect.width}px`
|
|
573
|
+
},
|
|
574
|
+
true
|
|
575
|
+
);
|
|
576
|
+
};
|
|
577
|
+
const scrollFocusedIntoView = () => {
|
|
578
|
+
svelte.tick().then(() => {
|
|
579
|
+
const list = dropdownRef()?.lastElementChild;
|
|
580
|
+
const option = list?.children[$__namespace.get(focusedIndex)];
|
|
581
|
+
if (!list || !option) return;
|
|
582
|
+
const listRect = list.getBoundingClientRect();
|
|
583
|
+
const optionRect = option.getBoundingClientRect();
|
|
584
|
+
let scrollAmount = 0;
|
|
585
|
+
if (optionRect.top < listRect.top) {
|
|
586
|
+
scrollAmount = list.scrollTop - (listRect.top - optionRect.top);
|
|
587
|
+
} else if (optionRect.bottom > listRect.bottom) {
|
|
588
|
+
scrollAmount = list.scrollTop + (optionRect.bottom - listRect.bottom);
|
|
589
|
+
} else {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
list.scrollTo({ top: scrollAmount, behavior: "smooth" });
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
const handleSearchKeydown = (e2) => {
|
|
596
|
+
if (e2.key === "ArrowDown") {
|
|
597
|
+
e2.preventDefault();
|
|
598
|
+
setFocusedIndex(Math.min($__namespace.get(focusedIndex) + 1, $__namespace.get(filteredCountries).length - 1));
|
|
599
|
+
scrollFocusedIntoView();
|
|
600
|
+
} else if (e2.key === "ArrowUp") {
|
|
601
|
+
e2.preventDefault();
|
|
602
|
+
setFocusedIndex(Math.max($__namespace.get(focusedIndex) - 1, 0));
|
|
603
|
+
scrollFocusedIntoView();
|
|
604
|
+
} else if (e2.key === "Enter" && $__namespace.get(filteredCountries)[$__namespace.get(focusedIndex)]) {
|
|
605
|
+
e2.preventDefault();
|
|
606
|
+
selectCountry($__namespace.get(filteredCountries)[$__namespace.get(focusedIndex)].id);
|
|
607
|
+
} else if (e2.key === "Escape") {
|
|
608
|
+
closeDropdown();
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const removeListeners = () => {
|
|
612
|
+
window.removeEventListener("resize", positionDropdown);
|
|
613
|
+
window.removeEventListener("scroll", positionDropdown, true);
|
|
614
|
+
window.removeEventListener("click", onDocClick, true);
|
|
615
|
+
};
|
|
616
|
+
$__namespace.user_effect(() => {
|
|
617
|
+
if (!$__namespace.get(hasDropdown) && $__namespace.get(dropdownOpen)) {
|
|
618
|
+
closeDropdown();
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
$__namespace.user_effect(() => {
|
|
622
|
+
if (!$__namespace.get(dropdownOpen)) {
|
|
623
|
+
removeListeners();
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
positionDropdown();
|
|
627
|
+
window.addEventListener("resize", positionDropdown);
|
|
628
|
+
window.addEventListener("scroll", positionDropdown, true);
|
|
629
|
+
window.addEventListener("click", onDocClick, true);
|
|
630
|
+
});
|
|
631
|
+
svelte.onDestroy(removeListeners);
|
|
632
|
+
return {
|
|
633
|
+
get dropdownOpen() {
|
|
634
|
+
return $__namespace.get(dropdownOpen);
|
|
635
|
+
},
|
|
636
|
+
get isClosing() {
|
|
637
|
+
return $__namespace.get(isClosing);
|
|
638
|
+
},
|
|
639
|
+
get search() {
|
|
640
|
+
return $__namespace.get(search);
|
|
641
|
+
},
|
|
642
|
+
get focusedIndex() {
|
|
643
|
+
return $__namespace.get(focusedIndex);
|
|
644
|
+
},
|
|
645
|
+
get dropdownStyle() {
|
|
646
|
+
return $__namespace.get(dropdownStyle);
|
|
647
|
+
},
|
|
648
|
+
get filteredCountries() {
|
|
649
|
+
return $__namespace.get(filteredCountries);
|
|
650
|
+
},
|
|
651
|
+
get hasDropdown() {
|
|
652
|
+
return $__namespace.get(hasDropdown);
|
|
653
|
+
},
|
|
654
|
+
openDropdown,
|
|
655
|
+
closeDropdown,
|
|
656
|
+
toggleDropdown,
|
|
657
|
+
selectCountry,
|
|
658
|
+
setFocusedIndex,
|
|
659
|
+
handleSearchChange,
|
|
660
|
+
handleSearchKeydown,
|
|
661
|
+
handleDropdownAnimationEnd
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function useClipboard(delay = 1800) {
|
|
665
|
+
let copied = $__namespace.state(false);
|
|
666
|
+
let isCopying = $__namespace.state(false);
|
|
667
|
+
const copyTimer = useTimer();
|
|
668
|
+
const copy = async (text) => {
|
|
669
|
+
if ($__namespace.get(isCopying)) return false;
|
|
670
|
+
const trimmedText = text.trim();
|
|
671
|
+
if (!trimmedText) return false;
|
|
672
|
+
$__namespace.set(isCopying, true);
|
|
673
|
+
try {
|
|
674
|
+
await navigator.clipboard.writeText(trimmedText);
|
|
675
|
+
$__namespace.set(copied, true);
|
|
676
|
+
copyTimer.set(
|
|
677
|
+
() => {
|
|
678
|
+
$__namespace.set(copied, false);
|
|
679
|
+
},
|
|
680
|
+
delay
|
|
681
|
+
);
|
|
682
|
+
return true;
|
|
683
|
+
} catch (err) {
|
|
684
|
+
console.warn("Copy failed", err);
|
|
685
|
+
return false;
|
|
686
|
+
} finally {
|
|
687
|
+
$__namespace.set(isCopying, false);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
return {
|
|
691
|
+
get copied() {
|
|
692
|
+
return $__namespace.get(copied);
|
|
693
|
+
},
|
|
694
|
+
get isCopying() {
|
|
695
|
+
return $__namespace.get(isCopying);
|
|
696
|
+
},
|
|
697
|
+
copy
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
const DELAY = 1800;
|
|
701
|
+
function useCopyAction({ liveRef, fullFormatted, onCopy }) {
|
|
702
|
+
const liveTimer = useTimer();
|
|
703
|
+
const clipboard = useClipboard(DELAY);
|
|
704
|
+
const copyAriaLabel = $__namespace.derived(() => clipboard.copied ? "Copied" : `Copy ${fullFormatted()}`);
|
|
705
|
+
const copyButtonTitle = $__namespace.derived(() => clipboard.copied ? "Copied" : "Copy phone number");
|
|
706
|
+
const announceToScreenReader = (message) => {
|
|
707
|
+
const el = liveRef?.();
|
|
708
|
+
if (!el) return;
|
|
709
|
+
el.textContent = message;
|
|
710
|
+
liveTimer.set(
|
|
711
|
+
() => {
|
|
712
|
+
const el2 = liveRef?.();
|
|
713
|
+
if (el2) el2.textContent = "";
|
|
714
|
+
},
|
|
715
|
+
DELAY
|
|
716
|
+
);
|
|
717
|
+
};
|
|
718
|
+
const onCopyClick = async () => {
|
|
719
|
+
const valueToCopy = fullFormatted().trim();
|
|
720
|
+
const success = await clipboard.copy(valueToCopy);
|
|
721
|
+
if (success) {
|
|
722
|
+
onCopy?.(valueToCopy);
|
|
723
|
+
announceToScreenReader("Phone number copied to clipboard");
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
return {
|
|
727
|
+
get copied() {
|
|
728
|
+
return clipboard.copied;
|
|
729
|
+
},
|
|
730
|
+
get copyAriaLabel() {
|
|
731
|
+
return $__namespace.get(copyAriaLabel);
|
|
732
|
+
},
|
|
733
|
+
get copyButtonTitle() {
|
|
734
|
+
return $__namespace.get(copyButtonTitle);
|
|
735
|
+
},
|
|
736
|
+
onCopyClick
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function useTheme({ theme }) {
|
|
740
|
+
let systemDark = $__namespace.state(false);
|
|
741
|
+
const themeClass = $__namespace.derived(() => theme() !== "auto" ? `theme-${theme()}` : $__namespace.get(systemDark) ? "theme-dark" : "theme-light");
|
|
742
|
+
$__namespace.user_effect(() => {
|
|
743
|
+
if (typeof window === "undefined") return;
|
|
744
|
+
const mq = window.matchMedia?.("(prefers-color-scheme: dark)") ?? null;
|
|
745
|
+
if (!mq) return;
|
|
746
|
+
$__namespace.set(systemDark, mq.matches, true);
|
|
747
|
+
const handler = (e2) => {
|
|
748
|
+
$__namespace.set(systemDark, e2.matches, true);
|
|
749
|
+
};
|
|
750
|
+
mq.addEventListener("change", handler);
|
|
751
|
+
return () => mq.removeEventListener("change", handler);
|
|
752
|
+
});
|
|
753
|
+
return {
|
|
754
|
+
get themeClass() {
|
|
755
|
+
return $__namespace.get(themeClass);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
var root_3 = $__namespace.from_svg(`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`);
|
|
760
|
+
var root_7 = $__namespace.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z" fill="currentColor"></path></svg>`);
|
|
761
|
+
var root_8 = $__namespace.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><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"></path></svg>`);
|
|
762
|
+
var root_5 = $__namespace.from_html(`<button type="button"><!></button>`);
|
|
763
|
+
var root_11 = $__namespace.from_svg(`<svg width="11" height="11" viewBox="0 0 14 14" fill="none" aria-hidden="true"><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"></path></svg>`);
|
|
764
|
+
var root_9 = $__namespace.from_html(`<button type="button" class="pi-btn pi-btn-clear"><!></button>`);
|
|
765
|
+
var root_13 = $__namespace.from_html(`<li role="option"><span class="pi-flag" role="img"><!></span> <span class="pi-opt-name"> </span> <span class="pi-opt-code"> </span></li>`);
|
|
766
|
+
var root_16 = $__namespace.from_html(`<li class="pi-empty"> </li>`);
|
|
767
|
+
var root_12 = $__namespace.from_html(`<div role="dialog" aria-modal="false" aria-label="Select country"><div class="pi-search-wrap"><input type="search" class="pi-search" aria-label="Search countries"/></div> <ul class="pi-options" role="listbox" tabindex="-1"></ul></div>`);
|
|
768
|
+
var root = $__namespace.from_html(`<div><div class="pi-selector"><button type="button"><span class="pi-flag" role="img"><!></span> <span class="pi-code"> </span> <!></button></div> <div class="pi-input-wrap"><input type="tel" inputmode="tel" autocomplete="tel-national" autocorrect="off" autocapitalize="off" spellcheck="false" class="pi-input"/> <div class="pi-actions" role="toolbar" aria-label="Phone input actions"><!> <!> <!></div></div></div> <!> <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>`, 1);
|
|
769
|
+
function PhoneInput$1($$anchor, $$props) {
|
|
770
|
+
$__namespace.push($$props, true);
|
|
771
|
+
let value = $__namespace.prop($$props, "value", 15, ""), detect = $__namespace.prop($$props, "detect", 3, true), size = $__namespace.prop($$props, "size", 3, "normal"), theme = $__namespace.prop($$props, "theme", 3, "auto"), disabled = $__namespace.prop($$props, "disabled", 3, false), readonly = $__namespace.prop($$props, "readonly", 3, false), showCopy = $__namespace.prop($$props, "showCopy", 3, true), showClear = $__namespace.prop($$props, "showClear", 3, false), withValidity = $__namespace.prop($$props, "withValidity", 3, true), searchPlaceholder = $__namespace.prop($$props, "searchPlaceholder", 3, "Search country or code..."), noResultsText = $__namespace.prop($$props, "noResultsText", 3, "No countries found"), clearButtonLabel = $__namespace.prop($$props, "clearButtonLabel", 3, "Clear phone number"), dropdownClass = $__namespace.prop($$props, "dropdownClass", 3, ""), disableDefaultStyles = $__namespace.prop($$props, "disableDefaultStyles", 3, false), restProps = $__namespace.rest_props($$props, [
|
|
772
|
+
"$$slots",
|
|
773
|
+
"$$events",
|
|
774
|
+
"$$legacy",
|
|
775
|
+
"value",
|
|
776
|
+
"country",
|
|
777
|
+
"detect",
|
|
778
|
+
"locale",
|
|
779
|
+
"size",
|
|
780
|
+
"theme",
|
|
781
|
+
"disabled",
|
|
782
|
+
"readonly",
|
|
783
|
+
"showCopy",
|
|
784
|
+
"showClear",
|
|
785
|
+
"withValidity",
|
|
786
|
+
"searchPlaceholder",
|
|
787
|
+
"noResultsText",
|
|
788
|
+
"clearButtonLabel",
|
|
789
|
+
"dropdownClass",
|
|
790
|
+
"disableDefaultStyles",
|
|
791
|
+
"onchange",
|
|
792
|
+
"oncountrychange",
|
|
793
|
+
"onvalidationchange",
|
|
794
|
+
"onfocus",
|
|
795
|
+
"onblur",
|
|
796
|
+
"oncopy",
|
|
797
|
+
"onclear",
|
|
798
|
+
"flag",
|
|
799
|
+
"copysvg",
|
|
800
|
+
"clearsvg",
|
|
801
|
+
"actionsbefore",
|
|
802
|
+
"class"
|
|
803
|
+
]);
|
|
804
|
+
let rootEl = $__namespace.state(null);
|
|
805
|
+
let telEl = $__namespace.state(null);
|
|
806
|
+
let liveEl = $__namespace.state(null);
|
|
807
|
+
let dropdownEl = $__namespace.state(null);
|
|
808
|
+
let searchEl = $__namespace.state(null);
|
|
809
|
+
let selectorEl = $__namespace.state(null);
|
|
810
|
+
const countryData = useCountry({
|
|
811
|
+
country: () => $$props.country,
|
|
812
|
+
locale: () => $$props.locale,
|
|
813
|
+
detect: () => detect(),
|
|
814
|
+
onCountryChange: (...args) => $$props.oncountrychange?.(...args)
|
|
815
|
+
});
|
|
816
|
+
const formatterData = useFormatter({
|
|
817
|
+
country: () => countryData.country,
|
|
818
|
+
value: () => value(),
|
|
819
|
+
onChange: (v) => value(v),
|
|
820
|
+
onPhoneChange: (...args) => $$props.onchange?.(...args),
|
|
821
|
+
onValidationChange: (...args) => $$props.onvalidationchange?.(...args)
|
|
822
|
+
});
|
|
823
|
+
const validationHint = useValidationHint();
|
|
824
|
+
const inactive = $__namespace.derived(() => disabled() || readonly());
|
|
825
|
+
const incomplete = $__namespace.derived(() => validationHint.showValidationHint && formatterData.shouldShowWarn);
|
|
826
|
+
const showCopyButton = $__namespace.derived(() => showCopy() && !formatterData.isEmpty && !disabled());
|
|
827
|
+
const showClearButton = $__namespace.derived(() => showClear() && !formatterData.isEmpty && !$__namespace.get(inactive));
|
|
828
|
+
const copyData = useCopyAction({
|
|
829
|
+
liveRef: () => $__namespace.get(liveEl),
|
|
830
|
+
fullFormatted: () => formatterData.fullFormatted,
|
|
831
|
+
onCopy: (...args) => $$props.oncopy?.(...args)
|
|
832
|
+
});
|
|
833
|
+
const focusInput = () => svelte.tick().then(() => $__namespace.get(telEl)?.focus());
|
|
834
|
+
const selectorData = useCountrySelector({
|
|
835
|
+
rootRef: () => $__namespace.get(rootEl),
|
|
836
|
+
dropdownRef: () => $__namespace.get(dropdownEl),
|
|
837
|
+
searchRef: () => $__namespace.get(searchEl),
|
|
838
|
+
selectorRef: () => $__namespace.get(selectorEl),
|
|
839
|
+
locale: () => countryData.locale,
|
|
840
|
+
countryOption: () => $$props.country,
|
|
841
|
+
inactive: () => $__namespace.get(inactive),
|
|
842
|
+
onSelectCountry: countryData.setCountry,
|
|
843
|
+
onAfterSelect: focusInput
|
|
844
|
+
});
|
|
845
|
+
const inputHandlers = useInputHandlers({
|
|
846
|
+
formatter: () => formatterData.formatter,
|
|
847
|
+
digits: () => formatterData.digits,
|
|
848
|
+
inactive: () => $__namespace.get(inactive),
|
|
849
|
+
onChange: (v) => value(v),
|
|
850
|
+
scheduleValidationHint: validationHint.scheduleValidationHint
|
|
851
|
+
});
|
|
852
|
+
const handleFocus = (e2) => {
|
|
853
|
+
validationHint.clearValidationHint(false);
|
|
854
|
+
selectorData.closeDropdown();
|
|
855
|
+
$$props.onfocus?.(e2);
|
|
856
|
+
};
|
|
857
|
+
const handleBlur = (e2) => $$props.onblur?.(e2);
|
|
858
|
+
function focus() {
|
|
859
|
+
focusInput();
|
|
860
|
+
}
|
|
861
|
+
function blur() {
|
|
862
|
+
$__namespace.get(telEl)?.blur();
|
|
863
|
+
}
|
|
864
|
+
function clear() {
|
|
865
|
+
value("");
|
|
866
|
+
validationHint.clearValidationHint();
|
|
867
|
+
$$props.onclear?.();
|
|
868
|
+
}
|
|
869
|
+
function selectCountry(code) {
|
|
870
|
+
countryData.setCountry(code);
|
|
871
|
+
}
|
|
872
|
+
function getFullNumber() {
|
|
873
|
+
return formatterData.full;
|
|
874
|
+
}
|
|
875
|
+
function getFullFormattedNumber() {
|
|
876
|
+
return formatterData.fullFormatted;
|
|
877
|
+
}
|
|
878
|
+
function getDigits() {
|
|
879
|
+
return formatterData.digits;
|
|
880
|
+
}
|
|
881
|
+
function isValid() {
|
|
882
|
+
return formatterData.isComplete;
|
|
883
|
+
}
|
|
884
|
+
function isComplete() {
|
|
885
|
+
return formatterData.isComplete;
|
|
886
|
+
}
|
|
887
|
+
const handleClearClick = () => {
|
|
888
|
+
clear();
|
|
889
|
+
focusInput();
|
|
890
|
+
};
|
|
891
|
+
const themeData = useTheme({ theme: () => theme() });
|
|
892
|
+
const rootClasses = $__namespace.derived(() => [
|
|
893
|
+
"phone-input",
|
|
894
|
+
`size-${size()}`,
|
|
895
|
+
themeData.themeClass,
|
|
896
|
+
disabled() && "is-disabled",
|
|
897
|
+
readonly() && "is-readonly",
|
|
898
|
+
disableDefaultStyles() && "is-unstyled",
|
|
899
|
+
withValidity() && $__namespace.get(incomplete) && "is-incomplete",
|
|
900
|
+
withValidity() && formatterData.isComplete && "is-complete",
|
|
901
|
+
$$props.class
|
|
902
|
+
].filter(Boolean).join(" "));
|
|
903
|
+
const actionsCount = $__namespace.derived(() => +$__namespace.get(showCopyButton) + +$__namespace.get(showClearButton) + ($$props.actionsbefore ? 1 : 0));
|
|
904
|
+
function portal(node) {
|
|
905
|
+
document.body.appendChild(node);
|
|
906
|
+
return { destroy: () => node.remove() };
|
|
907
|
+
}
|
|
908
|
+
var $$exports = {
|
|
909
|
+
focus,
|
|
910
|
+
blur,
|
|
911
|
+
clear,
|
|
912
|
+
selectCountry,
|
|
913
|
+
getFullNumber,
|
|
914
|
+
getFullFormattedNumber,
|
|
915
|
+
getDigits,
|
|
916
|
+
isValid,
|
|
917
|
+
isComplete
|
|
918
|
+
};
|
|
919
|
+
var fragment = root();
|
|
920
|
+
var div = $__namespace.first_child(fragment);
|
|
921
|
+
$__namespace.attribute_effect(div, () => ({
|
|
922
|
+
class: $__namespace.get(rootClasses),
|
|
923
|
+
...restProps,
|
|
924
|
+
role: "group",
|
|
925
|
+
"aria-label": "Phone input with country selector",
|
|
926
|
+
[$__namespace.STYLE]: { "--pi-actions-count": $__namespace.get(actionsCount) }
|
|
927
|
+
}));
|
|
928
|
+
var div_1 = $__namespace.child(div);
|
|
929
|
+
var button = $__namespace.child(div_1);
|
|
930
|
+
let classes;
|
|
931
|
+
var span = $__namespace.child(button);
|
|
932
|
+
var node_1 = $__namespace.child(span);
|
|
933
|
+
{
|
|
934
|
+
var consequent = ($$anchor2) => {
|
|
935
|
+
var fragment_1 = $__namespace.comment();
|
|
936
|
+
var node_2 = $__namespace.first_child(fragment_1);
|
|
937
|
+
$__namespace.snippet(node_2, () => $$props.flag, () => countryData.country);
|
|
938
|
+
$__namespace.append($$anchor2, fragment_1);
|
|
939
|
+
};
|
|
940
|
+
var alternate = ($$anchor2) => {
|
|
941
|
+
var text = $__namespace.text();
|
|
942
|
+
$__namespace.template_effect(() => $__namespace.set_text(text, countryData.country.flag));
|
|
943
|
+
$__namespace.append($$anchor2, text);
|
|
944
|
+
};
|
|
945
|
+
$__namespace.if(node_1, ($$render) => {
|
|
946
|
+
if ($$props.flag) $$render(consequent);
|
|
947
|
+
else $$render(alternate, -1);
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
$__namespace.reset(span);
|
|
951
|
+
var span_1 = $__namespace.sibling(span, 2);
|
|
952
|
+
var text_1 = $__namespace.child(span_1, true);
|
|
953
|
+
$__namespace.reset(span_1);
|
|
954
|
+
var node_3 = $__namespace.sibling(span_1, 2);
|
|
955
|
+
{
|
|
956
|
+
var consequent_1 = ($$anchor2) => {
|
|
957
|
+
var svg = root_3();
|
|
958
|
+
let classes_1;
|
|
959
|
+
$__namespace.template_effect(() => classes_1 = $__namespace.set_class(svg, 0, "pi-chevron", null, classes_1, { "is-open": selectorData.dropdownOpen }));
|
|
960
|
+
$__namespace.append($$anchor2, svg);
|
|
961
|
+
};
|
|
962
|
+
$__namespace.if(node_3, ($$render) => {
|
|
963
|
+
if (!$__namespace.get(inactive) && selectorData.hasDropdown) $$render(consequent_1);
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
$__namespace.reset(button);
|
|
967
|
+
$__namespace.reset(div_1);
|
|
968
|
+
$__namespace.bind_this(div_1, ($$value) => $__namespace.set(selectorEl, $$value), () => $__namespace.get(selectorEl));
|
|
969
|
+
var div_2 = $__namespace.sibling(div_1, 2);
|
|
970
|
+
var input = $__namespace.child(div_2);
|
|
971
|
+
$__namespace.remove_input_defaults(input);
|
|
972
|
+
$__namespace.bind_this(input, ($$value) => $__namespace.set(telEl, $$value), () => $__namespace.get(telEl));
|
|
973
|
+
var div_3 = $__namespace.sibling(input, 2);
|
|
974
|
+
var node_4 = $__namespace.child(div_3);
|
|
975
|
+
{
|
|
976
|
+
var consequent_2 = ($$anchor2) => {
|
|
977
|
+
var fragment_3 = $__namespace.comment();
|
|
978
|
+
var node_5 = $__namespace.first_child(fragment_3);
|
|
979
|
+
$__namespace.snippet(node_5, () => $$props.actionsbefore);
|
|
980
|
+
$__namespace.append($$anchor2, fragment_3);
|
|
981
|
+
};
|
|
982
|
+
$__namespace.if(node_4, ($$render) => {
|
|
983
|
+
if ($$props.actionsbefore) $$render(consequent_2);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
var node_6 = $__namespace.sibling(node_4, 2);
|
|
987
|
+
{
|
|
988
|
+
var consequent_5 = ($$anchor2) => {
|
|
989
|
+
var button_1 = root_5();
|
|
990
|
+
let classes_2;
|
|
991
|
+
var node_7 = $__namespace.child(button_1);
|
|
992
|
+
{
|
|
993
|
+
var consequent_3 = ($$anchor3) => {
|
|
994
|
+
var fragment_4 = $__namespace.comment();
|
|
995
|
+
var node_8 = $__namespace.first_child(fragment_4);
|
|
996
|
+
$__namespace.snippet(node_8, () => $$props.copysvg, () => copyData.copied);
|
|
997
|
+
$__namespace.append($$anchor3, fragment_4);
|
|
998
|
+
};
|
|
999
|
+
var consequent_4 = ($$anchor3) => {
|
|
1000
|
+
var svg_1 = root_7();
|
|
1001
|
+
$__namespace.append($$anchor3, svg_1);
|
|
1002
|
+
};
|
|
1003
|
+
var alternate_1 = ($$anchor3) => {
|
|
1004
|
+
var svg_2 = root_8();
|
|
1005
|
+
$__namespace.append($$anchor3, svg_2);
|
|
1006
|
+
};
|
|
1007
|
+
$__namespace.if(node_7, ($$render) => {
|
|
1008
|
+
if ($$props.copysvg) $$render(consequent_3);
|
|
1009
|
+
else if (copyData.copied) $$render(consequent_4, 1);
|
|
1010
|
+
else $$render(alternate_1, -1);
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
$__namespace.reset(button_1);
|
|
1014
|
+
$__namespace.template_effect(() => {
|
|
1015
|
+
classes_2 = $__namespace.set_class(button_1, 1, "pi-btn pi-btn-copy", null, classes_2, { "is-copied": copyData.copied });
|
|
1016
|
+
$__namespace.set_attribute(button_1, "aria-label", copyData.copyAriaLabel);
|
|
1017
|
+
$__namespace.set_attribute(button_1, "title", copyData.copyButtonTitle);
|
|
1018
|
+
});
|
|
1019
|
+
$__namespace.delegated("click", button_1, function(...$$args) {
|
|
1020
|
+
copyData.onCopyClick?.apply(this, $$args);
|
|
1021
|
+
});
|
|
1022
|
+
$__namespace.append($$anchor2, button_1);
|
|
1023
|
+
};
|
|
1024
|
+
$__namespace.if(node_6, ($$render) => {
|
|
1025
|
+
if ($__namespace.get(showCopyButton)) $$render(consequent_5);
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
var node_9 = $__namespace.sibling(node_6, 2);
|
|
1029
|
+
{
|
|
1030
|
+
var consequent_7 = ($$anchor2) => {
|
|
1031
|
+
var button_2 = root_9();
|
|
1032
|
+
var node_10 = $__namespace.child(button_2);
|
|
1033
|
+
{
|
|
1034
|
+
var consequent_6 = ($$anchor3) => {
|
|
1035
|
+
var fragment_5 = $__namespace.comment();
|
|
1036
|
+
var node_11 = $__namespace.first_child(fragment_5);
|
|
1037
|
+
$__namespace.snippet(node_11, () => $$props.clearsvg);
|
|
1038
|
+
$__namespace.append($$anchor3, fragment_5);
|
|
1039
|
+
};
|
|
1040
|
+
var alternate_2 = ($$anchor3) => {
|
|
1041
|
+
var svg_3 = root_11();
|
|
1042
|
+
$__namespace.append($$anchor3, svg_3);
|
|
1043
|
+
};
|
|
1044
|
+
$__namespace.if(node_10, ($$render) => {
|
|
1045
|
+
if ($$props.clearsvg) $$render(consequent_6);
|
|
1046
|
+
else $$render(alternate_2, -1);
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
$__namespace.reset(button_2);
|
|
1050
|
+
$__namespace.template_effect(() => {
|
|
1051
|
+
$__namespace.set_attribute(button_2, "aria-label", clearButtonLabel());
|
|
1052
|
+
$__namespace.set_attribute(button_2, "title", clearButtonLabel());
|
|
1053
|
+
});
|
|
1054
|
+
$__namespace.delegated("click", button_2, handleClearClick);
|
|
1055
|
+
$__namespace.append($$anchor2, button_2);
|
|
1056
|
+
};
|
|
1057
|
+
$__namespace.if(node_9, ($$render) => {
|
|
1058
|
+
if ($__namespace.get(showClearButton)) $$render(consequent_7);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
$__namespace.reset(div_3);
|
|
1062
|
+
$__namespace.reset(div_2);
|
|
1063
|
+
$__namespace.reset(div);
|
|
1064
|
+
$__namespace.bind_this(div, ($$value) => $__namespace.set(rootEl, $$value), () => $__namespace.get(rootEl));
|
|
1065
|
+
var node_12 = $__namespace.sibling(div, 2);
|
|
1066
|
+
{
|
|
1067
|
+
var consequent_9 = ($$anchor2) => {
|
|
1068
|
+
var div_4 = root_12();
|
|
1069
|
+
let classes_3;
|
|
1070
|
+
let styles;
|
|
1071
|
+
var div_5 = $__namespace.child(div_4);
|
|
1072
|
+
var input_1 = $__namespace.child(div_5);
|
|
1073
|
+
$__namespace.remove_input_defaults(input_1);
|
|
1074
|
+
$__namespace.bind_this(input_1, ($$value) => $__namespace.set(searchEl, $$value), () => $__namespace.get(searchEl));
|
|
1075
|
+
$__namespace.reset(div_5);
|
|
1076
|
+
var ul = $__namespace.sibling(div_5, 2);
|
|
1077
|
+
$__namespace.each(
|
|
1078
|
+
ul,
|
|
1079
|
+
23,
|
|
1080
|
+
() => selectorData.filteredCountries,
|
|
1081
|
+
(c) => c.id,
|
|
1082
|
+
($$anchor3, c, idx) => {
|
|
1083
|
+
var li = root_13();
|
|
1084
|
+
let classes_4;
|
|
1085
|
+
var span_2 = $__namespace.child(li);
|
|
1086
|
+
var node_13 = $__namespace.child(span_2);
|
|
1087
|
+
{
|
|
1088
|
+
var consequent_8 = ($$anchor4) => {
|
|
1089
|
+
var fragment_6 = $__namespace.comment();
|
|
1090
|
+
var node_14 = $__namespace.first_child(fragment_6);
|
|
1091
|
+
$__namespace.snippet(node_14, () => $$props.flag, () => $__namespace.get(c));
|
|
1092
|
+
$__namespace.append($$anchor4, fragment_6);
|
|
1093
|
+
};
|
|
1094
|
+
var alternate_3 = ($$anchor4) => {
|
|
1095
|
+
var text_2 = $__namespace.text();
|
|
1096
|
+
$__namespace.template_effect(() => $__namespace.set_text(text_2, $__namespace.get(c).flag));
|
|
1097
|
+
$__namespace.append($$anchor4, text_2);
|
|
1098
|
+
};
|
|
1099
|
+
$__namespace.if(node_13, ($$render) => {
|
|
1100
|
+
if ($$props.flag) $$render(consequent_8);
|
|
1101
|
+
else $$render(alternate_3, -1);
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
$__namespace.reset(span_2);
|
|
1105
|
+
var span_3 = $__namespace.sibling(span_2, 2);
|
|
1106
|
+
var text_3 = $__namespace.child(span_3, true);
|
|
1107
|
+
$__namespace.reset(span_3);
|
|
1108
|
+
var span_4 = $__namespace.sibling(span_3, 2);
|
|
1109
|
+
var text_4 = $__namespace.child(span_4, true);
|
|
1110
|
+
$__namespace.reset(span_4);
|
|
1111
|
+
$__namespace.reset(li);
|
|
1112
|
+
$__namespace.template_effect(() => {
|
|
1113
|
+
$__namespace.set_attribute(li, "id", `option-${$__namespace.get(idx) ?? ""}`);
|
|
1114
|
+
classes_4 = $__namespace.set_class(li, 1, "pi-option", null, classes_4, {
|
|
1115
|
+
"is-focused": $__namespace.get(idx) === selectorData.focusedIndex,
|
|
1116
|
+
"is-selected": $__namespace.get(c).id === countryData.country.id
|
|
1117
|
+
});
|
|
1118
|
+
$__namespace.set_attribute(li, "aria-selected", $__namespace.get(c).id === countryData.country.id);
|
|
1119
|
+
$__namespace.set_attribute(li, "title", $__namespace.get(c).name);
|
|
1120
|
+
$__namespace.set_attribute(span_2, "aria-label", `${$__namespace.get(c).name ?? ""} flag`);
|
|
1121
|
+
$__namespace.set_text(text_3, $__namespace.get(c).name);
|
|
1122
|
+
$__namespace.set_text(text_4, $__namespace.get(c).code);
|
|
1123
|
+
});
|
|
1124
|
+
$__namespace.delegated("click", li, () => selectorData.selectCountry($__namespace.get(c).id));
|
|
1125
|
+
$__namespace.delegated("keydown", li, (e2) => {
|
|
1126
|
+
if (e2.key === "Enter" || e2.key === " ") {
|
|
1127
|
+
e2.preventDefault();
|
|
1128
|
+
selectorData.selectCountry($__namespace.get(c).id);
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
$__namespace.event("mouseenter", li, () => selectorData.setFocusedIndex($__namespace.get(idx)));
|
|
1132
|
+
$__namespace.append($$anchor3, li);
|
|
1133
|
+
},
|
|
1134
|
+
($$anchor3) => {
|
|
1135
|
+
var li_1 = root_16();
|
|
1136
|
+
var text_5 = $__namespace.child(li_1, true);
|
|
1137
|
+
$__namespace.reset(li_1);
|
|
1138
|
+
$__namespace.template_effect(() => $__namespace.set_text(text_5, noResultsText()));
|
|
1139
|
+
$__namespace.append($$anchor3, li_1);
|
|
1140
|
+
}
|
|
1141
|
+
);
|
|
1142
|
+
$__namespace.reset(ul);
|
|
1143
|
+
$__namespace.reset(div_4);
|
|
1144
|
+
$__namespace.action(div_4, ($$node) => portal?.($$node));
|
|
1145
|
+
$__namespace.bind_this(div_4, ($$value) => $__namespace.set(dropdownEl, $$value), () => $__namespace.get(dropdownEl));
|
|
1146
|
+
$__namespace.template_effect(() => {
|
|
1147
|
+
classes_3 = $__namespace.set_class(div_4, 1, `phone-dropdown ${dropdownClass() ?? ""} ${themeData.themeClass ?? ""}`, null, classes_3, { "is-closing": selectorData.isClosing });
|
|
1148
|
+
styles = $__namespace.set_style(div_4, "", styles, {
|
|
1149
|
+
position: "absolute",
|
|
1150
|
+
top: selectorData.dropdownStyle.top,
|
|
1151
|
+
left: selectorData.dropdownStyle.left,
|
|
1152
|
+
width: selectorData.dropdownStyle.width
|
|
1153
|
+
});
|
|
1154
|
+
$__namespace.set_attribute(input_1, "placeholder", searchPlaceholder());
|
|
1155
|
+
$__namespace.set_value(input_1, selectorData.search);
|
|
1156
|
+
$__namespace.set_attribute(ul, "aria-activedescendant", `option-${selectorData.focusedIndex ?? ""}`);
|
|
1157
|
+
});
|
|
1158
|
+
$__namespace.event("animationend", div_4, function(...$$args) {
|
|
1159
|
+
selectorData.handleDropdownAnimationEnd?.apply(this, $$args);
|
|
1160
|
+
});
|
|
1161
|
+
$__namespace.delegated("keydown", input_1, function(...$$args) {
|
|
1162
|
+
selectorData.handleSearchKeydown?.apply(this, $$args);
|
|
1163
|
+
});
|
|
1164
|
+
$__namespace.delegated("input", input_1, function(...$$args) {
|
|
1165
|
+
selectorData.handleSearchChange?.apply(this, $$args);
|
|
1166
|
+
});
|
|
1167
|
+
$__namespace.append($$anchor2, div_4);
|
|
1168
|
+
};
|
|
1169
|
+
$__namespace.if(node_12, ($$render) => {
|
|
1170
|
+
if (selectorData.dropdownOpen) $$render(consequent_9);
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
var div_6 = $__namespace.sibling(node_12, 2);
|
|
1174
|
+
$__namespace.bind_this(div_6, ($$value) => $__namespace.set(liveEl, $$value), () => $__namespace.get(liveEl));
|
|
1175
|
+
$__namespace.template_effect(() => {
|
|
1176
|
+
classes = $__namespace.set_class(button, 1, "pi-selector-btn", null, classes, { "no-dropdown": !selectorData.hasDropdown || readonly() });
|
|
1177
|
+
button.disabled = disabled();
|
|
1178
|
+
$__namespace.set_attribute(button, "tabindex", $__namespace.get(inactive) || !selectorData.hasDropdown ? -1 : void 0);
|
|
1179
|
+
$__namespace.set_attribute(button, "aria-label", `Selected country: ${countryData.country.name ?? ""}`);
|
|
1180
|
+
$__namespace.set_attribute(button, "aria-expanded", selectorData.dropdownOpen);
|
|
1181
|
+
$__namespace.set_attribute(button, "aria-haspopup", selectorData.hasDropdown ? "listbox" : void 0);
|
|
1182
|
+
$__namespace.set_attribute(span, "aria-label", `${countryData.country.name ?? ""} flag`);
|
|
1183
|
+
$__namespace.set_text(text_1, countryData.country.code);
|
|
1184
|
+
$__namespace.set_attribute(input, "placeholder", formatterData.displayPlaceholder);
|
|
1185
|
+
$__namespace.set_value(input, formatterData.displayValue);
|
|
1186
|
+
input.disabled = disabled();
|
|
1187
|
+
input.readOnly = readonly();
|
|
1188
|
+
$__namespace.set_attribute(input, "aria-invalid", $__namespace.get(incomplete));
|
|
1189
|
+
});
|
|
1190
|
+
$__namespace.delegated("click", button, function(...$$args) {
|
|
1191
|
+
selectorData.toggleDropdown?.apply(this, $$args);
|
|
1192
|
+
});
|
|
1193
|
+
$__namespace.delegated("beforeinput", input, function(...$$args) {
|
|
1194
|
+
inputHandlers.handleBeforeInput?.apply(this, $$args);
|
|
1195
|
+
});
|
|
1196
|
+
$__namespace.delegated("input", input, function(...$$args) {
|
|
1197
|
+
inputHandlers.handleInput?.apply(this, $$args);
|
|
1198
|
+
});
|
|
1199
|
+
$__namespace.delegated("keydown", input, function(...$$args) {
|
|
1200
|
+
inputHandlers.handleKeydown?.apply(this, $$args);
|
|
1201
|
+
});
|
|
1202
|
+
$__namespace.event("paste", input, function(...$$args) {
|
|
1203
|
+
inputHandlers.handlePaste?.apply(this, $$args);
|
|
1204
|
+
});
|
|
1205
|
+
$__namespace.event("focus", input, handleFocus);
|
|
1206
|
+
$__namespace.event("blur", input, handleBlur);
|
|
1207
|
+
$__namespace.append($$anchor, fragment);
|
|
1208
|
+
return $__namespace.pop($$exports);
|
|
1209
|
+
}
|
|
1210
|
+
$__namespace.delegate(["click", "beforeinput", "input", "keydown"]);
|
|
1211
|
+
function usePhoneMask(options) {
|
|
1212
|
+
let inputRef = $__namespace.state(null);
|
|
1213
|
+
const countryData = useCountry({
|
|
1214
|
+
country: options.country,
|
|
1215
|
+
locale: options.locale,
|
|
1216
|
+
detect: options.detect,
|
|
1217
|
+
onCountryChange: options.onCountryChange
|
|
1218
|
+
});
|
|
1219
|
+
const formatterData = useFormatter({
|
|
1220
|
+
country: () => countryData.country,
|
|
1221
|
+
value: options.value,
|
|
1222
|
+
onChange: options.onChange,
|
|
1223
|
+
onPhoneChange: options.onPhoneChange
|
|
1224
|
+
});
|
|
1225
|
+
const { handleBeforeInput, handleInput, handleKeydown, handlePaste } = useInputHandlers({
|
|
1226
|
+
formatter: () => formatterData.formatter,
|
|
1227
|
+
digits: () => formatterData.digits,
|
|
1228
|
+
onChange: options.onChange
|
|
1229
|
+
});
|
|
1230
|
+
$__namespace.user_effect(() => {
|
|
1231
|
+
const el = $__namespace.get(inputRef);
|
|
1232
|
+
if (!el) return;
|
|
1233
|
+
el.setAttribute("type", "tel");
|
|
1234
|
+
el.setAttribute("inputmode", "tel");
|
|
1235
|
+
el.addEventListener("beforeinput", handleBeforeInput);
|
|
1236
|
+
el.addEventListener("input", handleInput);
|
|
1237
|
+
el.addEventListener("keydown", handleKeydown);
|
|
1238
|
+
el.addEventListener("paste", handlePaste);
|
|
1239
|
+
return () => {
|
|
1240
|
+
el.removeEventListener("beforeinput", handleBeforeInput);
|
|
1241
|
+
el.removeEventListener("input", handleInput);
|
|
1242
|
+
el.removeEventListener("keydown", handleKeydown);
|
|
1243
|
+
el.removeEventListener("paste", handlePaste);
|
|
1244
|
+
};
|
|
1245
|
+
});
|
|
1246
|
+
$__namespace.user_effect(() => {
|
|
1247
|
+
const el = $__namespace.get(inputRef);
|
|
1248
|
+
if (!el) return;
|
|
1249
|
+
el.value = formatterData.displayValue;
|
|
1250
|
+
el.setAttribute("placeholder", formatterData.displayPlaceholder);
|
|
1251
|
+
});
|
|
1252
|
+
const clear = () => {
|
|
1253
|
+
options.onChange("");
|
|
1254
|
+
};
|
|
1255
|
+
return {
|
|
1256
|
+
get inputRef() {
|
|
1257
|
+
return $__namespace.get(inputRef);
|
|
1258
|
+
},
|
|
1259
|
+
set inputRef(el) {
|
|
1260
|
+
$__namespace.set(inputRef, el, true);
|
|
1261
|
+
},
|
|
1262
|
+
get digits() {
|
|
1263
|
+
return formatterData.digits;
|
|
1264
|
+
},
|
|
1265
|
+
get full() {
|
|
1266
|
+
return formatterData.full;
|
|
1267
|
+
},
|
|
1268
|
+
get fullFormatted() {
|
|
1269
|
+
return formatterData.fullFormatted;
|
|
1270
|
+
},
|
|
1271
|
+
get isComplete() {
|
|
1272
|
+
return formatterData.isComplete;
|
|
1273
|
+
},
|
|
1274
|
+
get isEmpty() {
|
|
1275
|
+
return formatterData.isEmpty;
|
|
1276
|
+
},
|
|
1277
|
+
get shouldShowWarn() {
|
|
1278
|
+
return formatterData.shouldShowWarn;
|
|
1279
|
+
},
|
|
1280
|
+
get country() {
|
|
1281
|
+
return countryData.country;
|
|
1282
|
+
},
|
|
1283
|
+
get locale() {
|
|
1284
|
+
return countryData.locale;
|
|
1285
|
+
},
|
|
1286
|
+
setCountry: countryData.setCountry,
|
|
1287
|
+
clear
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
const PhoneInput = PhoneInput$1;
|
|
1291
|
+
const PMaskHelpers = {
|
|
1292
|
+
getFlagEmoji: k,
|
|
1293
|
+
countPlaceholders,
|
|
1294
|
+
formatDigitsWithMap,
|
|
1295
|
+
pickMaskVariant,
|
|
1296
|
+
removeCountryCodePrefix,
|
|
1297
|
+
toArray
|
|
1298
|
+
};
|
|
1299
|
+
exports.PMaskHelpers = PMaskHelpers;
|
|
1300
|
+
exports.PhoneInput = PhoneInput;
|
|
1301
|
+
exports.usePhoneMask = usePhoneMask;
|