react-country-kit 1.1.0 → 1.1.2

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/dist/ui.es.js DELETED
@@ -1,1161 +0,0 @@
1
- import { jsx as e, jsxs as n, Fragment as R } from "react/jsx-runtime";
2
- import L, { useState as w, useEffect as G } from "react";
3
- import * as V from "@radix-ui/react-popover";
4
- import { clsx as K } from "clsx";
5
- import { twMerge as ee } from "tailwind-merge";
6
- import { searchCountries as H, getAllCountries as Q, getCurrencyByCountry as U, searchCurrencies as J, getAllCurrencies as W, getTimezonesByCountry as $, getAllTimezones as te, searchTimezones as ne, searchLanguages as re, getAllLanguages as I, getDivisionsByCountry as oe, usePhoneInput as se } from "react-country-kit-core";
7
- import { getAllCountries as Ce, getAllCurrencies as ke, getAllLanguages as we, getAllTimezones as Le, getCountryByIso2 as ve, getCountryByIso3 as Pe, getCountryByName as Se, getCurrencyByCode as _e, getCurrencyByCountry as Be, getDivisionsByCountry as Oe, getLanguageByCode as Re, getTimezoneByName as Te, getTimezonesByCountry as je, iso2ToFlag as ze, searchCountries as Ee, searchCurrencies as Ve, searchLanguages as Ae, searchTimezones as Qe, useCountryPicker as We, useCurrencyPicker as qe, useDivisionPicker as De, useLanguagePicker as Me, useMultiSelect as Ue, usePhoneInput as $e, useTimezonePicker as Ie } from "react-country-kit-core";
8
- function y(...t) {
9
- return ee(K(t));
10
- }
11
- const Y = V.Root, Z = V.Trigger, z = ({ className: t }) => /* @__PURE__ */ e(
12
- "svg",
13
- {
14
- className: y("h-4 w-4 text-primary", t),
15
- viewBox: "0 0 20 20",
16
- fill: "none",
17
- stroke: "currentColor",
18
- strokeWidth: "2.5",
19
- strokeLinecap: "round",
20
- strokeLinejoin: "round",
21
- children: /* @__PURE__ */ e("polyline", { points: "4 10 8 14 16 6" })
22
- }
23
- );
24
- z.displayName = "CheckIcon";
25
- const q = ({
26
- children: t,
27
- className: r
28
- }) => /* @__PURE__ */ e(
29
- "label",
30
- {
31
- className: y(
32
- "text-[0.65rem] font-bold uppercase tracking-[0.12em] text-muted-foreground/80 ml-1 mb-1.5 block",
33
- r
34
- ),
35
- children: t
36
- }
37
- );
38
- q.displayName = "FieldLabel";
39
- const v = ({ children: t, className: r }) => /* @__PURE__ */ e(
40
- "span",
41
- {
42
- className: y(
43
- "inline-flex items-center rounded-full bg-primary/20 px-2.5 py-0.5 text-[0.7rem] font-bold text-primary tracking-tight",
44
- r
45
- ),
46
- children: t
47
- }
48
- );
49
- v.displayName = "Badge";
50
- const j = ({
51
- iso2: t,
52
- flag: r,
53
- flagUrl: p,
54
- className: l
55
- }) => /* @__PURE__ */ e("span", { className: y("inline-flex items-center justify-center shrink-0 overflow-hidden", l), children: /* @__PURE__ */ e(
56
- "img",
57
- {
58
- src: p,
59
- alt: t,
60
- className: "h-[1em] w-[1.5em] object-cover rounded-[1px] shadow-[0_0_0_1px_rgba(0,0,0,0.05)]",
61
- onError: (i) => {
62
- if (i.target.style.display = "none", i.target.parentElement) {
63
- const c = document.createElement("span");
64
- c.textContent = r, i.target.parentElement.appendChild(c);
65
- }
66
- }
67
- }
68
- ) });
69
- j.displayName = "Flag";
70
- const D = L.forwardRef(({ className: t, align: r = "start", sideOffset: p = 6, onCloseAutoFocus: l, ...i }, c) => /* @__PURE__ */ e(V.Portal, { children: /* @__PURE__ */ e(
71
- V.Content,
72
- {
73
- ref: c,
74
- align: r,
75
- sideOffset: p,
76
- onCloseAutoFocus: (g) => {
77
- g.preventDefault(), l == null || l(g);
78
- },
79
- className: y(
80
- "z-50 w-[var(--radix-popover-trigger-width)] rounded-xl border border-border bg-popover p-0 shadow-lg",
81
- "data-[state=open]:animate-in data-[state=closed]:animate-out",
82
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
83
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
84
- "data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",
85
- t
86
- ),
87
- ...i
88
- }
89
- ) }));
90
- D.displayName = "PopoverContent";
91
- const P = L.forwardRef(({ className: t, ...r }, p) => /* @__PURE__ */ e(
92
- "div",
93
- {
94
- ref: p,
95
- className: y(
96
- "flex h-full w-full flex-col overflow-hidden rounded-xl bg-popover text-popover-foreground",
97
- t
98
- ),
99
- ...r
100
- }
101
- ));
102
- P.displayName = "CommandRoot";
103
- const S = L.forwardRef(
104
- ({ className: t, onValueChange: r, ...p }, l) => /* @__PURE__ */ e("div", { className: "px-3 pt-3 pb-2 border-b border-border", children: /* @__PURE__ */ n("div", { className: y(
105
- "flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/40 transition-colors",
106
- "focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/10"
107
- ), children: [
108
- /* @__PURE__ */ n(
109
- "svg",
110
- {
111
- className: "h-3.5 w-3.5 shrink-0 text-muted-foreground",
112
- viewBox: "0 0 20 20",
113
- fill: "none",
114
- stroke: "currentColor",
115
- strokeWidth: "2",
116
- children: [
117
- /* @__PURE__ */ e("circle", { cx: "8.5", cy: "8.5", r: "5.5" }),
118
- /* @__PURE__ */ e("path", { d: "M17 17l-4-4", strokeLinecap: "round" })
119
- ]
120
- }
121
- ),
122
- /* @__PURE__ */ e(
123
- "input",
124
- {
125
- ref: l,
126
- type: "text",
127
- autoComplete: "off",
128
- autoCorrect: "off",
129
- spellCheck: !1,
130
- className: y(
131
- "flex h-8 w-full bg-transparent text-sm outline-none",
132
- "placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
133
- t
134
- ),
135
- onChange: (i) => r == null ? void 0 : r(i.target.value),
136
- ...p
137
- }
138
- )
139
- ] }) })
140
- );
141
- S.displayName = "CommandInput";
142
- const _ = L.forwardRef(({ className: t, ...r }, p) => /* @__PURE__ */ e(
143
- "div",
144
- {
145
- ref: p,
146
- role: "listbox",
147
- className: y("max-h-72 overflow-y-auto overflow-x-hidden p-1", t),
148
- ...r
149
- }
150
- ));
151
- _.displayName = "CommandList";
152
- const B = L.forwardRef((t, r) => /* @__PURE__ */ e(
153
- "div",
154
- {
155
- ref: r,
156
- className: "flex flex-col items-center justify-center gap-1 py-8 text-sm text-muted-foreground",
157
- ...t
158
- }
159
- ));
160
- B.displayName = "CommandEmpty";
161
- const O = L.forwardRef(
162
- ({ className: t, onSelect: r, onMouseDown: p, onKeyDown: l, disabled: i, selected: c, value: g, ...k }, x) => /* @__PURE__ */ e(
163
- "div",
164
- {
165
- ref: x,
166
- role: "option",
167
- "aria-disabled": i || void 0,
168
- "aria-selected": c,
169
- "data-disabled": i || void 0,
170
- "data-selected": c || void 0,
171
- tabIndex: i ? void 0 : 0,
172
- className: y(
173
- "relative flex cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-2 text-sm outline-none",
174
- "focus:bg-accent focus:text-accent-foreground",
175
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
176
- "hover:bg-accent/50 transition-colors",
177
- c && "bg-accent text-accent-foreground font-semibold",
178
- t
179
- ),
180
- onMouseDown: (s) => {
181
- s.preventDefault(), p == null || p(s);
182
- },
183
- onClick: i ? void 0 : () => r == null ? void 0 : r(),
184
- onKeyDown: (s) => {
185
- !i && s.key === "Enter" && (s.preventDefault(), r == null || r()), l == null || l(s);
186
- },
187
- ...k
188
- }
189
- )
190
- );
191
- O.displayName = "CommandItem";
192
- const E = L.forwardRef(
193
- ({ className: t, isOpen: r, children: p, placeholder: l, hasValue: i, ...c }, g) => /* @__PURE__ */ n(
194
- "button",
195
- {
196
- ref: g,
197
- type: "button",
198
- role: "combobox",
199
- "aria-expanded": r,
200
- "aria-haspopup": "listbox",
201
- className: y(
202
- "flex h-12 w-full items-center justify-between gap-3 rounded-xl border border-input bg-background px-4 py-2 text-sm ring-offset-background",
203
- "placeholder:text-muted-foreground",
204
- "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
205
- "disabled:cursor-not-allowed disabled:opacity-50",
206
- "hover:bg-accent/10 transition-all",
207
- !i && "text-muted-foreground",
208
- t
209
- ),
210
- ...c,
211
- children: [
212
- /* @__PURE__ */ e("span", { className: "flex min-w-0 flex-1 items-center gap-2 truncate", children: p || /* @__PURE__ */ e("span", { children: l }) }),
213
- /* @__PURE__ */ e(
214
- "svg",
215
- {
216
- className: y(
217
- "h-4 w-4 shrink-0 text-muted-foreground/60 transition-transform duration-200",
218
- r && "rotate-180"
219
- ),
220
- viewBox: "0 0 20 20",
221
- fill: "none",
222
- stroke: "currentColor",
223
- strokeWidth: "2.5",
224
- strokeLinecap: "round",
225
- strokeLinejoin: "round",
226
- children: /* @__PURE__ */ e("polyline", { points: "6 8 10 12 14 8" })
227
- }
228
- )
229
- ]
230
- }
231
- )
232
- );
233
- E.displayName = "PickerTrigger";
234
- const T = L.forwardRef(
235
- ({ label: t, trigger: r, children: p, open: l, onOpenChange: i, className: c }, g) => /* @__PURE__ */ n("div", { ref: g, className: y("flex flex-col gap-0", c), children: [
236
- t && /* @__PURE__ */ e(q, { children: t }),
237
- /* @__PURE__ */ n(Y, { open: l, onOpenChange: i, children: [
238
- /* @__PURE__ */ e(Z, { asChild: !0, children: r }),
239
- /* @__PURE__ */ e(D, { className: "p-0", children: p })
240
- ] })
241
- ] })
242
- );
243
- T.displayName = "BasePicker";
244
- const M = L.forwardRef(
245
- ({
246
- value: t,
247
- onRemove: r,
248
- onClear: p,
249
- isOpen: l,
250
- placeholder: i,
251
- renderChip: c,
252
- maxVisible: g = 3,
253
- className: k,
254
- disabled: x,
255
- ...s
256
- }, d) => {
257
- const u = t.slice(0, g), N = t.length - g;
258
- return /* @__PURE__ */ n(
259
- "button",
260
- {
261
- ref: d,
262
- type: "button",
263
- "aria-haspopup": "listbox",
264
- "aria-expanded": l,
265
- disabled: x,
266
- className: y(
267
- "flex min-h-[3rem] w-full items-center gap-3 rounded-xl border border-input bg-background px-4 py-2",
268
- "text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
269
- "disabled:cursor-not-allowed disabled:opacity-50 hover:bg-accent/10 transition-all text-start",
270
- l && "ring-2 ring-ring ring-offset-2",
271
- k
272
- ),
273
- ...s,
274
- children: [
275
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-wrap gap-1.5 min-w-0 items-center", children: t.length === 0 ? /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: i }) : /* @__PURE__ */ n(R, { children: [
276
- u.map((f, b) => /* @__PURE__ */ n(
277
- "span",
278
- {
279
- className: "inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-0.5 text-[0.75rem] font-semibold text-primary",
280
- children: [
281
- c(f),
282
- /* @__PURE__ */ e(
283
- "span",
284
- {
285
- role: "button",
286
- tabIndex: x ? -1 : 0,
287
- onClick: (m) => {
288
- m.stopPropagation(), x || r(f, m);
289
- },
290
- onKeyDown: (m) => {
291
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), m.stopPropagation(), x || r(f, m));
292
- },
293
- className: "ml-0.5 rounded-full text-primary/60 hover:text-primary transition-colors cursor-pointer",
294
- "aria-label": "Remove",
295
- children: /* @__PURE__ */ n("svg", { width: "9", height: "9", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", children: [
296
- /* @__PURE__ */ e("line", { x1: "5", y1: "5", x2: "15", y2: "15" }),
297
- /* @__PURE__ */ e("line", { x1: "15", y1: "5", x2: "5", y2: "15" })
298
- ] })
299
- }
300
- )
301
- ]
302
- },
303
- b
304
- )),
305
- N > 0 && /* @__PURE__ */ n(v, { className: "bg-muted text-muted-foreground/80 px-2", children: [
306
- "+",
307
- N
308
- ] })
309
- ] }) }),
310
- /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-1 ml-auto", children: [
311
- t.length > 0 && /* @__PURE__ */ e(
312
- "span",
313
- {
314
- role: "button",
315
- tabIndex: x ? -1 : 0,
316
- onClick: (f) => {
317
- f.stopPropagation(), x || p(f);
318
- },
319
- onKeyDown: (f) => {
320
- (f.key === "Enter" || f.key === " ") && (f.preventDefault(), f.stopPropagation(), x || p(f));
321
- },
322
- className: "rounded p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent/30 transition-colors cursor-pointer",
323
- "aria-label": "Clear all",
324
- children: /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", children: [
325
- /* @__PURE__ */ e("line", { x1: "5", y1: "5", x2: "15", y2: "15" }),
326
- /* @__PURE__ */ e("line", { x1: "15", y1: "5", x2: "5", y2: "15" })
327
- ] })
328
- }
329
- ),
330
- /* @__PURE__ */ e(
331
- "svg",
332
- {
333
- className: y("h-4 w-4 text-muted-foreground/60 transition-transform duration-200", l && "rotate-180"),
334
- viewBox: "0 0 20 20",
335
- fill: "none",
336
- stroke: "currentColor",
337
- strokeWidth: "2.5",
338
- strokeLinecap: "round",
339
- strokeLinejoin: "round",
340
- children: /* @__PURE__ */ e("polyline", { points: "6 8 10 12 14 8" })
341
- }
342
- )
343
- ] })
344
- ]
345
- }
346
- );
347
- }
348
- );
349
- M.displayName = "MultiSelectTrigger";
350
- function pe({
351
- value: t,
352
- onChange: r,
353
- placeholder: p = "Select a country...",
354
- searchable: l = !0,
355
- showFlag: i = !0,
356
- showPhoneCode: c = !1,
357
- disabled: g = !1,
358
- className: k,
359
- label: x
360
- }) {
361
- const [s, d] = w(!1), [u, N] = w(""), f = u ? H(u) : Q(), b = (m) => {
362
- const a = Q().find(
363
- (h) => h.iso2.toLowerCase() === m.toLowerCase()
364
- );
365
- a && (r(a), d(!1), N(""));
366
- };
367
- return /* @__PURE__ */ e(
368
- T,
369
- {
370
- label: x,
371
- className: k,
372
- open: s,
373
- onOpenChange: d,
374
- trigger: /* @__PURE__ */ e(
375
- E,
376
- {
377
- isOpen: s,
378
- hasValue: !!t,
379
- placeholder: p,
380
- disabled: g,
381
- children: t && /* @__PURE__ */ n(R, { children: [
382
- i && /* @__PURE__ */ e(j, { iso2: t.iso2, flag: t.flag, flagUrl: t.flag_url }),
383
- /* @__PURE__ */ e("span", { className: "flex-1 text-start truncate", children: t.name }),
384
- c && /* @__PURE__ */ n(v, { children: [
385
- "+",
386
- t.phone_code
387
- ] })
388
- ] })
389
- }
390
- ),
391
- children: /* @__PURE__ */ n(P, { children: [
392
- l && /* @__PURE__ */ e(
393
- S,
394
- {
395
- placeholder: "Search country...",
396
- value: u,
397
- onValueChange: N
398
- }
399
- ),
400
- /* @__PURE__ */ n(_, { children: [
401
- f.length === 0 && /* @__PURE__ */ n(B, { children: [
402
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🌍" }),
403
- /* @__PURE__ */ e("span", { children: "No countries found" })
404
- ] }),
405
- f.map((m) => {
406
- const a = (t == null ? void 0 : t.iso2) === m.iso2;
407
- return /* @__PURE__ */ n(
408
- O,
409
- {
410
- onSelect: () => b(m.iso2),
411
- selected: a,
412
- children: [
413
- i && /* @__PURE__ */ e(j, { iso2: m.iso2, flag: m.flag, flagUrl: m.flag_url }),
414
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col gap-0 min-w-0", children: [
415
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: m.name }),
416
- /* @__PURE__ */ n("span", { className: "text-[0.7rem] text-muted-foreground", children: [
417
- m.iso3,
418
- " · ",
419
- m.division_type
420
- ] })
421
- ] }),
422
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 ml-auto shrink-0", children: [
423
- c && /* @__PURE__ */ n("span", { className: "text-[0.7rem] text-muted-foreground tabular-nums bg-muted px-1.5 py-0.5 rounded", children: [
424
- "+",
425
- m.phone_code
426
- ] }),
427
- a && /* @__PURE__ */ e(z, {})
428
- ] })
429
- ]
430
- },
431
- m.iso2
432
- );
433
- })
434
- ] })
435
- ] })
436
- }
437
- );
438
- }
439
- function fe({
440
- value: t,
441
- onChange: r,
442
- placeholder: p = "Select a currency...",
443
- searchable: l = !0,
444
- showSymbol: i = !0,
445
- countryIso2: c,
446
- autoSelect: g = !0,
447
- disabled: k = !1,
448
- className: x,
449
- label: s
450
- }) {
451
- const [d, u] = w(!1), [N, f] = w("");
452
- G(() => {
453
- if (c && g && !t) {
454
- const h = U(c);
455
- h && r(h);
456
- }
457
- }, [c, g, t, r]);
458
- const m = N ? J(N, c) : (() => {
459
- if (c) {
460
- const h = U(c);
461
- return h ? [h] : [];
462
- }
463
- return W();
464
- })(), a = (h) => {
465
- const o = W().find(
466
- (C) => C.code.toLowerCase() === h.toLowerCase()
467
- );
468
- o && (r(o), u(!1), f(""));
469
- };
470
- return /* @__PURE__ */ e(
471
- T,
472
- {
473
- label: s,
474
- className: x,
475
- open: d,
476
- onOpenChange: u,
477
- trigger: /* @__PURE__ */ e(
478
- E,
479
- {
480
- isOpen: d,
481
- hasValue: !!t,
482
- placeholder: p,
483
- disabled: k,
484
- children: t && /* @__PURE__ */ n(R, { children: [
485
- i && /* @__PURE__ */ e("span", { className: "min-w-[1.5rem] text-center font-bold text-primary text-base", children: t.symbol }),
486
- /* @__PURE__ */ n("span", { className: "flex-1 text-start truncate", children: [
487
- t.code,
488
- " — ",
489
- t.name
490
- ] })
491
- ] })
492
- }
493
- ),
494
- children: /* @__PURE__ */ n(P, { children: [
495
- l && /* @__PURE__ */ e(
496
- S,
497
- {
498
- placeholder: "Search currency...",
499
- value: N,
500
- onValueChange: f
501
- }
502
- ),
503
- /* @__PURE__ */ n(_, { children: [
504
- m.length === 0 && /* @__PURE__ */ n(B, { children: [
505
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "💰" }),
506
- /* @__PURE__ */ e("span", { children: "No currencies found" })
507
- ] }),
508
- m.map((h) => {
509
- const o = (t == null ? void 0 : t.code) === h.code;
510
- return /* @__PURE__ */ n(
511
- O,
512
- {
513
- onSelect: () => a(h.code),
514
- selected: o,
515
- children: [
516
- i && /* @__PURE__ */ e("span", { className: "min-w-[1.5rem] text-center font-bold text-primary", children: h.symbol }),
517
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col gap-0 min-w-0", children: [
518
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: h.name }),
519
- /* @__PURE__ */ e("span", { className: "text-[0.7rem] text-muted-foreground", children: h.code })
520
- ] }),
521
- o && /* @__PURE__ */ e(z, { className: "ml-auto shrink-0" })
522
- ]
523
- },
524
- h.code
525
- );
526
- })
527
- ] })
528
- ] })
529
- }
530
- );
531
- }
532
- function he({
533
- value: t,
534
- onChange: r,
535
- placeholder: p = "Select a timezone...",
536
- searchable: l = !0,
537
- countryIso2: i,
538
- autoSelect: c = !0,
539
- disabled: g = !1,
540
- className: k,
541
- label: x
542
- }) {
543
- const [s, d] = w(!1), [u, N] = w("");
544
- G(() => {
545
- if (i && c && !t) {
546
- const a = $(i);
547
- a && a.length > 0 && r(a[0]);
548
- }
549
- }, [i, c, t, r]);
550
- const f = i ? $(i) : te(), b = u ? ne(u, i) : f, m = (a) => {
551
- const h = f.find((o) => o.name === a);
552
- h && (r(h), d(!1), N(""));
553
- };
554
- return /* @__PURE__ */ e(
555
- T,
556
- {
557
- label: x,
558
- className: k,
559
- open: s,
560
- onOpenChange: d,
561
- trigger: /* @__PURE__ */ e(
562
- E,
563
- {
564
- isOpen: s,
565
- hasValue: !!t,
566
- placeholder: p,
567
- disabled: g,
568
- children: t && /* @__PURE__ */ n(R, { children: [
569
- /* @__PURE__ */ e("span", { className: "flex-1 text-start truncate", children: t.name }),
570
- /* @__PURE__ */ e(v, { children: t.offset_name })
571
- ] })
572
- }
573
- ),
574
- children: /* @__PURE__ */ n(P, { children: [
575
- l && /* @__PURE__ */ e(
576
- S,
577
- {
578
- placeholder: "Search timezone...",
579
- value: u,
580
- onValueChange: N
581
- }
582
- ),
583
- /* @__PURE__ */ n(_, { children: [
584
- b.length === 0 && /* @__PURE__ */ n(B, { children: [
585
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🕐" }),
586
- /* @__PURE__ */ e("span", { children: "No timezones found" })
587
- ] }),
588
- b.map((a) => {
589
- const h = (t == null ? void 0 : t.name) === a.name;
590
- return /* @__PURE__ */ n(
591
- O,
592
- {
593
- onSelect: () => m(a.name),
594
- selected: h,
595
- children: [
596
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col gap-0 min-w-0", children: [
597
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: a.name }),
598
- /* @__PURE__ */ n("span", { className: "text-[0.7rem] text-muted-foreground", children: [
599
- a.tzName,
600
- " · ",
601
- a.abbreviation
602
- ] })
603
- ] }),
604
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 ml-auto shrink-0", children: [
605
- /* @__PURE__ */ e(v, { className: "tabular-nums text-[0.65rem]", children: a.offset_name }),
606
- h && /* @__PURE__ */ e(z, {})
607
- ] })
608
- ]
609
- },
610
- a.name
611
- );
612
- })
613
- ] })
614
- ] })
615
- }
616
- );
617
- }
618
- function ue({
619
- value: t,
620
- onChange: r,
621
- placeholder: p = "Select a language...",
622
- searchable: l = !0,
623
- showNativeName: i = !0,
624
- disabled: c = !1,
625
- className: g,
626
- label: k
627
- }) {
628
- const [x, s] = w(!1), [d, u] = w(""), N = d ? re(d) : I(), f = (b) => {
629
- const m = I().find(
630
- (a) => a.code.toLowerCase() === b.toLowerCase()
631
- );
632
- m && (r(m), s(!1), u(""));
633
- };
634
- return /* @__PURE__ */ e(
635
- T,
636
- {
637
- label: k,
638
- className: g,
639
- open: x,
640
- onOpenChange: s,
641
- trigger: /* @__PURE__ */ e(
642
- E,
643
- {
644
- isOpen: x,
645
- hasValue: !!t,
646
- placeholder: p,
647
- disabled: c,
648
- children: t && /* @__PURE__ */ n(R, { children: [
649
- /* @__PURE__ */ e("span", { className: "flex-1 text-start truncate", children: t.english_name }),
650
- i && t.native_name !== t.english_name && /* @__PURE__ */ e("span", { className: "text-xs italic text-muted-foreground shrink-0", children: t.native_name })
651
- ] })
652
- }
653
- ),
654
- children: /* @__PURE__ */ n(P, { children: [
655
- l && /* @__PURE__ */ e(
656
- S,
657
- {
658
- placeholder: "Search language...",
659
- value: d,
660
- onValueChange: u
661
- }
662
- ),
663
- /* @__PURE__ */ n(_, { children: [
664
- N.length === 0 && /* @__PURE__ */ n(B, { children: [
665
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🌐" }),
666
- /* @__PURE__ */ e("span", { children: "No languages found" })
667
- ] }),
668
- N.map((b) => {
669
- const m = (t == null ? void 0 : t.code) === b.code;
670
- return /* @__PURE__ */ n(
671
- O,
672
- {
673
- onSelect: () => f(b.code),
674
- selected: m,
675
- children: [
676
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col gap-0 min-w-0", children: [
677
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: b.english_name }),
678
- i && b.native_name !== b.english_name && /* @__PURE__ */ e("span", { className: "text-[0.7rem] text-muted-foreground italic", children: b.native_name })
679
- ] }),
680
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 ml-auto shrink-0", children: [
681
- /* @__PURE__ */ e(v, { className: "text-[0.6rem]", children: b.code }),
682
- m && /* @__PURE__ */ e(z, {})
683
- ] })
684
- ]
685
- },
686
- b.code
687
- );
688
- })
689
- ] })
690
- ] })
691
- }
692
- );
693
- }
694
- function ge({
695
- countryIso2: t,
696
- value: r,
697
- onChange: p,
698
- placeholder: l = "Select a division...",
699
- searchable: i = !0,
700
- disabled: c = !1,
701
- className: g,
702
- label: k
703
- }) {
704
- const [x, s] = w(!1), [d, u] = w(""), N = oe(t), f = d ? N.filter(
705
- (a) => a.name.toLowerCase().includes(d.toLowerCase()) || a.iso2.toLowerCase().includes(d.toLowerCase()) || a.timezone.toLowerCase().includes(d.toLowerCase())
706
- ) : N, b = c || !t || N.length === 0, m = (a) => {
707
- const h = N.find((o) => o.name === a);
708
- h && (p(h), s(!1), u(""));
709
- };
710
- return /* @__PURE__ */ e(
711
- T,
712
- {
713
- label: k,
714
- className: g,
715
- open: x,
716
- onOpenChange: (a) => !b && s(a),
717
- trigger: /* @__PURE__ */ e(
718
- E,
719
- {
720
- isOpen: x,
721
- hasValue: !!r,
722
- placeholder: t ? l : "Select a country first",
723
- disabled: b,
724
- children: r && /* @__PURE__ */ n(R, { children: [
725
- /* @__PURE__ */ e("span", { className: "flex-1 text-start truncate", children: r.name }),
726
- /* @__PURE__ */ e(v, { children: r.iso2 })
727
- ] })
728
- }
729
- ),
730
- children: /* @__PURE__ */ n(P, { children: [
731
- i && /* @__PURE__ */ e(
732
- S,
733
- {
734
- placeholder: "Search division...",
735
- value: d,
736
- onValueChange: u
737
- }
738
- ),
739
- /* @__PURE__ */ n(_, { children: [
740
- f.length === 0 && /* @__PURE__ */ n(B, { children: [
741
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🗺️" }),
742
- /* @__PURE__ */ e("span", { children: "No divisions found" })
743
- ] }),
744
- f.map((a) => {
745
- const h = (r == null ? void 0 : r.iso2) === a.iso2 && (r == null ? void 0 : r.name) === a.name;
746
- return /* @__PURE__ */ n(
747
- O,
748
- {
749
- onSelect: () => m(a.name),
750
- selected: h,
751
- children: [
752
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col gap-0 min-w-0", children: [
753
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: a.name }),
754
- /* @__PURE__ */ e("span", { className: "text-[0.7rem] text-muted-foreground truncate", children: a.timezone })
755
- ] }),
756
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 ml-auto shrink-0", children: [
757
- /* @__PURE__ */ e(v, { children: a.iso2 }),
758
- h && /* @__PURE__ */ e(z, {})
759
- ] })
760
- ]
761
- },
762
- `${a.iso2}-${a.name}`
763
- );
764
- })
765
- ] })
766
- ] })
767
- }
768
- );
769
- }
770
- const ie = L.forwardRef(
771
- ({
772
- value: t,
773
- onChange: r,
774
- defaultCountryIso2: p = "US",
775
- placeholder: l = "Phone number",
776
- showFlag: i = !0,
777
- disabled: c = !1,
778
- className: g,
779
- label: k
780
- }, x) => {
781
- const s = se(t, r, p);
782
- return /* @__PURE__ */ n("div", { ref: x, className: y("flex flex-col gap-0", g), children: [
783
- k && /* @__PURE__ */ e(q, { children: k }),
784
- /* @__PURE__ */ n(
785
- "div",
786
- {
787
- className: y(
788
- "flex h-12 items-stretch overflow-hidden rounded-xl border border-input bg-background ring-offset-background",
789
- "focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
790
- "transition-shadow",
791
- c && "opacity-50 pointer-events-none"
792
- ),
793
- children: [
794
- /* @__PURE__ */ n(
795
- Y,
796
- {
797
- open: s.isOpen,
798
- onOpenChange: (d) => d ? s.toggle() : s.close(),
799
- children: [
800
- /* @__PURE__ */ e(Z, { asChild: !0, children: /* @__PURE__ */ n(
801
- "button",
802
- {
803
- type: "button",
804
- disabled: c,
805
- className: y(
806
- "flex h-full shrink-0 items-center gap-1.5 border-r border-input bg-muted px-3",
807
- "text-sm font-semibold text-foreground transition-colors outline-none",
808
- "hover:bg-accent/30 focus-visible:bg-accent/30"
809
- ),
810
- children: [
811
- i && s.country && /* @__PURE__ */ e(j, { iso2: s.country.iso2, flag: s.country.flag, flagUrl: s.country.flag_url }),
812
- /* @__PURE__ */ e("span", { className: "tabular-nums text-primary", children: s.country ? `+${s.country.phone_code}` : "+?" }),
813
- /* @__PURE__ */ e(
814
- "svg",
815
- {
816
- className: y(
817
- "h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200",
818
- s.isOpen && "rotate-180"
819
- ),
820
- viewBox: "0 0 20 20",
821
- fill: "none",
822
- stroke: "currentColor",
823
- strokeWidth: "2",
824
- strokeLinecap: "round",
825
- children: /* @__PURE__ */ e("polyline", { points: "5 8 10 13 15 8" })
826
- }
827
- )
828
- ]
829
- }
830
- ) }),
831
- /* @__PURE__ */ e(
832
- D,
833
- {
834
- align: "start",
835
- side: "bottom",
836
- sideOffset: 4,
837
- className: "w-72",
838
- children: /* @__PURE__ */ n(P, { children: [
839
- /* @__PURE__ */ e(
840
- S,
841
- {
842
- placeholder: "Search country or code...",
843
- value: s.searchQuery,
844
- onValueChange: s.setSearchQuery
845
- }
846
- ),
847
- /* @__PURE__ */ n(_, { children: [
848
- s.filteredCountries.length === 0 && /* @__PURE__ */ n(B, { children: [
849
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🌍" }),
850
- /* @__PURE__ */ e("span", { children: "No countries found" })
851
- ] }),
852
- s.filteredCountries.map((d) => {
853
- var N;
854
- const u = ((N = s.country) == null ? void 0 : N.iso2) === d.iso2;
855
- return /* @__PURE__ */ n(
856
- O,
857
- {
858
- onSelect: () => s.selectCountry(d),
859
- selected: u,
860
- children: [
861
- /* @__PURE__ */ e(j, { iso2: d.iso2, flag: d.flag, flagUrl: d.flag_url }),
862
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col min-w-0", children: /* @__PURE__ */ e("span", { className: "truncate font-medium text-sm", children: d.name }) }),
863
- /* @__PURE__ */ n(v, { className: "ml-auto tabular-nums text-[0.7rem]", children: [
864
- "+",
865
- d.phone_code
866
- ] })
867
- ]
868
- },
869
- d.iso2
870
- );
871
- })
872
- ] })
873
- ] })
874
- }
875
- )
876
- ]
877
- }
878
- ),
879
- /* @__PURE__ */ e(
880
- "input",
881
- {
882
- type: "tel",
883
- value: s.number,
884
- onChange: (d) => s.setNumber(d.target.value),
885
- placeholder: l,
886
- disabled: c,
887
- minLength: s.minLength,
888
- maxLength: s.maxLength,
889
- inputMode: "numeric",
890
- autoComplete: "tel-national",
891
- className: y(
892
- "flex-1 min-w-0 bg-transparent px-3 text-sm text-foreground",
893
- "placeholder:text-muted-foreground",
894
- "focus:outline-none"
895
- )
896
- }
897
- )
898
- ]
899
- }
900
- ),
901
- s.value && /* @__PURE__ */ n("p", { className: "text-[0.7rem] text-muted-foreground tabular-nums pl-0.5", children: [
902
- "Full:",
903
- " ",
904
- /* @__PURE__ */ e("span", { className: "font-mono text-primary", children: s.value.full })
905
- ] })
906
- ] });
907
- }
908
- );
909
- ie.displayName = "PhoneInput";
910
- const F = 3;
911
- function xe({
912
- value: t,
913
- onChange: r,
914
- placeholder: p = "Select countries...",
915
- maxItems: l,
916
- showFlags: i = !0,
917
- searchable: c = !0,
918
- disabled: g = !1,
919
- className: k,
920
- label: x
921
- }) {
922
- const [s, d] = w(!1), [u, N] = w(""), f = u ? H(u) : Q(), b = (o) => t.some((C) => C.iso2 === o.iso2), m = (o) => {
923
- if (b(o))
924
- r(t.filter((C) => C.iso2 !== o.iso2));
925
- else {
926
- if (l !== void 0 && t.length >= l) return;
927
- r([...t, o]);
928
- }
929
- }, a = (o, C) => {
930
- C.stopPropagation(), r(t.filter((A) => A.iso2 !== o.iso2));
931
- }, h = (o) => {
932
- o.stopPropagation(), r([]);
933
- };
934
- return t.slice(0, F), t.length - F, /* @__PURE__ */ n(
935
- T,
936
- {
937
- label: x,
938
- className: k,
939
- open: s,
940
- onOpenChange: d,
941
- trigger: /* @__PURE__ */ e(
942
- M,
943
- {
944
- value: t,
945
- onRemove: a,
946
- onClear: h,
947
- isOpen: s,
948
- placeholder: p,
949
- disabled: g,
950
- renderChip: (o) => /* @__PURE__ */ n(R, { children: [
951
- i && /* @__PURE__ */ e(j, { iso2: o.iso2, flag: o.flag, flagUrl: o.flag_url }),
952
- /* @__PURE__ */ e("span", { className: "max-w-[80px] truncate", children: o.name })
953
- ] })
954
- }
955
- ),
956
- children: [
957
- /* @__PURE__ */ n(P, { children: [
958
- c && /* @__PURE__ */ e(S, { placeholder: "Search countries...", value: u, onValueChange: N }),
959
- /* @__PURE__ */ n(_, { children: [
960
- f.length === 0 && /* @__PURE__ */ n(B, { children: [
961
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "🌍" }),
962
- /* @__PURE__ */ e("span", { children: "No countries found" })
963
- ] }),
964
- f.map((o) => {
965
- const C = b(o);
966
- return /* @__PURE__ */ n(
967
- O,
968
- {
969
- onSelect: () => m(o),
970
- selected: C,
971
- children: [
972
- /* @__PURE__ */ e("div", { className: y(
973
- "h-4 w-4 shrink-0 rounded-full border border-border flex items-center justify-center",
974
- C && "bg-primary border-primary"
975
- ), children: C && /* @__PURE__ */ e("svg", { className: "h-2.5 w-2.5 stroke-white", viewBox: "0 0 20 20", fill: "none", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("polyline", { points: "4 10 8 14 16 6" }) }) }),
976
- i && /* @__PURE__ */ e(j, { iso2: o.iso2, flag: o.flag, flagUrl: o.flag_url }),
977
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col min-w-0", children: [
978
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: o.name }),
979
- /* @__PURE__ */ n("span", { className: "text-[0.7rem] text-muted-foreground", children: [
980
- o.iso3,
981
- " · +",
982
- o.phone_code
983
- ] })
984
- ] })
985
- ]
986
- },
987
- o.iso2
988
- );
989
- })
990
- ] })
991
- ] }),
992
- t.length > 0 && /* @__PURE__ */ n("div", { className: "flex items-center justify-between border-t border-border px-3 py-2 text-xs text-muted-foreground", children: [
993
- /* @__PURE__ */ n("span", { children: [
994
- t.length,
995
- " selected",
996
- l ? ` / ${l}` : ""
997
- ] }),
998
- /* @__PURE__ */ e(
999
- "button",
1000
- {
1001
- type: "button",
1002
- onClick: () => {
1003
- r([]), d(!1);
1004
- },
1005
- className: "text-destructive hover:underline font-medium",
1006
- children: "Clear all"
1007
- }
1008
- )
1009
- ] })
1010
- ]
1011
- }
1012
- );
1013
- }
1014
- const X = 3;
1015
- function Ne({
1016
- value: t,
1017
- onChange: r,
1018
- placeholder: p = "Select currencies...",
1019
- maxItems: l,
1020
- showSymbol: i = !0,
1021
- searchable: c = !0,
1022
- disabled: g = !1,
1023
- className: k,
1024
- label: x
1025
- }) {
1026
- const [s, d] = w(!1), [u, N] = w(""), f = u ? J(u) : W(), b = (o) => t.some((C) => C.code === o.code), m = (o) => {
1027
- if (b(o))
1028
- r(t.filter((C) => C.code !== o.code));
1029
- else {
1030
- if (l !== void 0 && t.length >= l) return;
1031
- r([...t, o]);
1032
- }
1033
- }, a = (o, C) => {
1034
- C.stopPropagation(), r(t.filter((A) => A.code !== o.code));
1035
- }, h = (o) => {
1036
- o.stopPropagation(), r([]);
1037
- };
1038
- return t.slice(0, X), t.length - X, /* @__PURE__ */ n(
1039
- T,
1040
- {
1041
- label: x,
1042
- className: k,
1043
- open: s,
1044
- onOpenChange: d,
1045
- trigger: /* @__PURE__ */ e(
1046
- M,
1047
- {
1048
- value: t,
1049
- onRemove: a,
1050
- onClear: h,
1051
- isOpen: s,
1052
- placeholder: p,
1053
- disabled: g,
1054
- renderChip: (o) => /* @__PURE__ */ n(R, { children: [
1055
- i && /* @__PURE__ */ e("span", { className: "font-bold", children: o.symbol }),
1056
- /* @__PURE__ */ e("span", { children: o.code })
1057
- ] })
1058
- }
1059
- ),
1060
- children: [
1061
- /* @__PURE__ */ n(P, { children: [
1062
- c && /* @__PURE__ */ e(S, { placeholder: "Search currencies...", value: u, onValueChange: N }),
1063
- /* @__PURE__ */ n(_, { children: [
1064
- f.length === 0 && /* @__PURE__ */ n(B, { children: [
1065
- /* @__PURE__ */ e("span", { className: "text-2xl opacity-40", children: "💰" }),
1066
- /* @__PURE__ */ e("span", { children: "No currencies found" })
1067
- ] }),
1068
- f.map((o) => {
1069
- const C = b(o);
1070
- return /* @__PURE__ */ n(
1071
- O,
1072
- {
1073
- onSelect: () => m(o),
1074
- selected: C,
1075
- children: [
1076
- /* @__PURE__ */ e("div", { className: y(
1077
- "h-4 w-4 shrink-0 rounded-full border border-border flex items-center justify-center",
1078
- C && "bg-primary border-primary"
1079
- ), children: C && /* @__PURE__ */ e("svg", { className: "h-2.5 w-2.5 stroke-white", viewBox: "0 0 20 20", fill: "none", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("polyline", { points: "4 10 8 14 16 6" }) }) }),
1080
- i && /* @__PURE__ */ e("span", { className: "min-w-[1.5rem] text-center font-bold text-primary", children: o.symbol }),
1081
- /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col min-w-0", children: [
1082
- /* @__PURE__ */ e("span", { className: "truncate font-medium", children: o.name }),
1083
- /* @__PURE__ */ e("span", { className: "text-[0.7rem] text-muted-foreground", children: o.code })
1084
- ] })
1085
- ]
1086
- },
1087
- o.code
1088
- );
1089
- })
1090
- ] })
1091
- ] }),
1092
- t.length > 0 && /* @__PURE__ */ n("div", { className: "flex items-center justify-between border-t border-border px-3 py-2 text-xs text-muted-foreground", children: [
1093
- /* @__PURE__ */ n("span", { children: [
1094
- t.length,
1095
- " selected",
1096
- l ? ` / ${l}` : ""
1097
- ] }),
1098
- /* @__PURE__ */ e(
1099
- "button",
1100
- {
1101
- type: "button",
1102
- onClick: () => {
1103
- r([]), d(!1);
1104
- },
1105
- className: "text-destructive hover:underline font-medium",
1106
- children: "Clear all"
1107
- }
1108
- )
1109
- ] })
1110
- ]
1111
- }
1112
- );
1113
- }
1114
- export {
1115
- v as Badge,
1116
- z as CheckIcon,
1117
- B as CommandEmpty,
1118
- S as CommandInput,
1119
- O as CommandItem,
1120
- _ as CommandList,
1121
- P as CommandRoot,
1122
- xe as CountryMultiSelect,
1123
- pe as CountryPicker,
1124
- Ne as CurrencyMultiSelect,
1125
- fe as CurrencyPicker,
1126
- ge as DivisionPicker,
1127
- ue as LanguagePicker,
1128
- ie as PhoneInput,
1129
- E as PickerTrigger,
1130
- Y as Popover,
1131
- D as PopoverContent,
1132
- Z as PopoverTrigger,
1133
- he as TimezonePicker,
1134
- y as cn,
1135
- Ce as getAllCountries,
1136
- ke as getAllCurrencies,
1137
- we as getAllLanguages,
1138
- Le as getAllTimezones,
1139
- ve as getCountryByIso2,
1140
- Pe as getCountryByIso3,
1141
- Se as getCountryByName,
1142
- _e as getCurrencyByCode,
1143
- Be as getCurrencyByCountry,
1144
- Oe as getDivisionsByCountry,
1145
- Re as getLanguageByCode,
1146
- Te as getTimezoneByName,
1147
- je as getTimezonesByCountry,
1148
- ze as iso2ToFlag,
1149
- Ee as searchCountries,
1150
- Ve as searchCurrencies,
1151
- Ae as searchLanguages,
1152
- Qe as searchTimezones,
1153
- We as useCountryPicker,
1154
- qe as useCurrencyPicker,
1155
- De as useDivisionPicker,
1156
- Me as useLanguagePicker,
1157
- Ue as useMultiSelect,
1158
- $e as usePhoneInput,
1159
- Ie as useTimezonePicker
1160
- };
1161
- //# sourceMappingURL=ui.es.js.map