@cfx-dev/ui-components 4.3.10 → 4.3.11

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.
@@ -1,1013 +1,74 @@
1
- import { jsx as s, jsxs as De } from "react/jsx-runtime";
2
- import * as a from "react";
3
- import { useRef as vo, useState as ho, useEffect as Mo } from "react";
4
- import { c as me, P as O, e as g, u as U, d as ye, g as Co, b as Ro, h as Te } from "../../index-DCuJlMqr.js";
5
- import { c as Ae, u as Ne } from "../../index-BMU9X4M-.js";
6
- import { u as de, a as _e, c as Oe, R as So, A as Io, h as bo, b as Do, d as Eo, F as xo, D as Po, C as yo, e as To } from "../../Combination-DFb92tMK.js";
7
- import { P as ge } from "../../index-DWzyrn_L.js";
8
- import Ao from "../Flex/Flex.js";
9
- import { clsx as Ee } from "../../utils/clsx.js";
10
- import { Icon as No } from "../Icon/Icon.js";
11
- import { mergeRefs as Oo } from "../../utils/mergeRefs.js";
12
- import { ui as xe } from "../../utils/ui/ui.js";
13
- var le = "rovingFocusGroup.onEntryFocus", Fo = { bubbles: !1, cancelable: !0 }, Z = "RovingFocusGroup", [fe, Fe, ko] = Ae(Z), [Go, ke] = me(
14
- Z,
15
- [ko]
16
- ), [Lo, Ko] = Go(Z), Ge = a.forwardRef(
17
- (e, n) => /* @__PURE__ */ s(fe.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ s(fe.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ s(zo, { ...e, ref: n }) }) })
18
- );
19
- Ge.displayName = Z;
20
- var zo = a.forwardRef((e, n) => {
21
- const {
22
- __scopeRovingFocusGroup: o,
23
- orientation: t,
24
- loop: r = !1,
25
- dir: c,
26
- currentTabStopId: l,
27
- defaultCurrentTabStopId: d,
28
- onCurrentTabStopIdChange: m,
29
- onEntryFocus: _,
30
- preventScrollOnEntryFocus: u = !1,
31
- ...i
32
- } = e, f = a.useRef(null), h = U(n, f), v = Ne(c), [R, w] = ye({
33
- prop: l,
34
- defaultProp: d ?? null,
35
- onChange: m,
36
- caller: Z
37
- }), [S, A] = a.useState(!1), M = _e(_), E = Fe(o), $ = a.useRef(!1), [Q, F] = a.useState(0);
38
- return a.useEffect(() => {
39
- const C = f.current;
40
- if (C)
41
- return C.addEventListener(le, M), () => C.removeEventListener(le, M);
42
- }, [M]), /* @__PURE__ */ s(
43
- Lo,
44
- {
45
- scope: o,
46
- orientation: t,
47
- dir: v,
48
- loop: r,
49
- currentTabStopId: R,
50
- onItemFocus: a.useCallback(
51
- (C) => w(C),
52
- [w]
53
- ),
54
- onItemShiftTab: a.useCallback(() => A(!0), []),
55
- onFocusableItemAdd: a.useCallback(
56
- () => F((C) => C + 1),
57
- []
58
- ),
59
- onFocusableItemRemove: a.useCallback(
60
- () => F((C) => C - 1),
61
- []
62
- ),
63
- children: /* @__PURE__ */ s(
64
- O.div,
65
- {
66
- tabIndex: S || Q === 0 ? -1 : 0,
67
- "data-orientation": t,
68
- ...i,
69
- ref: h,
70
- style: { outline: "none", ...e.style },
71
- onMouseDown: g(e.onMouseDown, () => {
72
- $.current = !0;
73
- }),
74
- onFocus: g(e.onFocus, (C) => {
75
- const L = !$.current;
76
- if (C.target === C.currentTarget && L && !S) {
77
- const k = new CustomEvent(le, Fo);
78
- if (C.currentTarget.dispatchEvent(k), !k.defaultPrevented) {
79
- const W = E().filter((P) => P.focusable), V = W.find((P) => P.active), ee = W.find((P) => P.id === R), se = [V, ee, ...W].filter(
80
- Boolean
81
- ).map((P) => P.ref.current);
82
- ze(se, u);
83
- }
84
- }
85
- $.current = !1;
86
- }),
87
- onBlur: g(e.onBlur, () => A(!1))
88
- }
89
- )
90
- }
91
- );
92
- }), Le = "RovingFocusGroupItem", Ke = a.forwardRef(
93
- (e, n) => {
94
- const {
95
- __scopeRovingFocusGroup: o,
96
- focusable: t = !0,
97
- active: r = !1,
98
- tabStopId: c,
99
- children: l,
100
- ...d
101
- } = e, m = de(), _ = c || m, u = Ko(Le, o), i = u.currentTabStopId === _, f = Fe(o), { onFocusableItemAdd: h, onFocusableItemRemove: v, currentTabStopId: R } = u;
102
- return a.useEffect(() => {
103
- if (t)
104
- return h(), () => v();
105
- }, [t, h, v]), /* @__PURE__ */ s(
106
- fe.ItemSlot,
107
- {
108
- scope: o,
109
- id: _,
110
- focusable: t,
111
- active: r,
112
- children: /* @__PURE__ */ s(
113
- O.span,
114
- {
115
- tabIndex: i ? 0 : -1,
116
- "data-orientation": u.orientation,
117
- ...d,
118
- ref: n,
119
- onMouseDown: g(e.onMouseDown, (w) => {
120
- t ? u.onItemFocus(_) : w.preventDefault();
121
- }),
122
- onFocus: g(e.onFocus, () => u.onItemFocus(_)),
123
- onKeyDown: g(e.onKeyDown, (w) => {
124
- if (w.key === "Tab" && w.shiftKey) {
125
- u.onItemShiftTab();
126
- return;
127
- }
128
- if (w.target !== w.currentTarget) return;
129
- const S = $o(w, u.orientation, u.dir);
130
- if (S !== void 0) {
131
- if (w.metaKey || w.ctrlKey || w.altKey || w.shiftKey) return;
132
- w.preventDefault();
133
- let M = f().filter((E) => E.focusable).map((E) => E.ref.current);
134
- if (S === "last") M.reverse();
135
- else if (S === "prev" || S === "next") {
136
- S === "prev" && M.reverse();
137
- const E = M.indexOf(w.currentTarget);
138
- M = u.loop ? Wo(M, E + 1) : M.slice(E + 1);
139
- }
140
- setTimeout(() => ze(M));
141
- }
142
- }),
143
- children: typeof l == "function" ? l({ isCurrentTabStop: i, hasTabStop: R != null }) : l
144
- }
145
- )
146
- }
147
- );
148
- }
149
- );
150
- Ke.displayName = Le;
151
- var Uo = {
152
- ArrowLeft: "prev",
153
- ArrowUp: "prev",
154
- ArrowRight: "next",
155
- ArrowDown: "next",
156
- PageUp: "first",
157
- Home: "first",
158
- PageDown: "last",
159
- End: "last"
160
- };
161
- function Bo(e, n) {
162
- return n !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
163
- }
164
- function $o(e, n, o) {
165
- const t = Bo(e.key, o);
166
- if (!(n === "vertical" && ["ArrowLeft", "ArrowRight"].includes(t)) && !(n === "horizontal" && ["ArrowUp", "ArrowDown"].includes(t)))
167
- return Uo[t];
168
- }
169
- function ze(e, n = !1) {
170
- const o = document.activeElement;
171
- for (const t of e)
172
- if (t === o || (t.focus({ preventScroll: n }), document.activeElement !== o)) return;
173
- }
174
- function Wo(e, n) {
175
- return e.map((o, t) => e[(n + t) % e.length]);
176
- }
177
- var Vo = Ge, Yo = Ke, pe = ["Enter", " "], Xo = ["ArrowDown", "PageUp", "Home"], Ue = ["ArrowUp", "PageDown", "End"], jo = [...Xo, ...Ue], Ho = {
178
- ltr: [...pe, "ArrowRight"],
179
- rtl: [...pe, "ArrowLeft"]
180
- }, Zo = {
181
- ltr: ["ArrowLeft"],
182
- rtl: ["ArrowRight"]
183
- }, q = "Menu", [j, qo, Jo] = Ae(q), [G, Be] = me(q, [
184
- Jo,
185
- Oe,
186
- ke
187
- ]), re = Oe(), $e = ke(), [Qo, B] = G(q), [en, J] = G(q), We = (e) => {
188
- const { __scopeMenu: n, open: o = !1, children: t, dir: r, onOpenChange: c, modal: l = !0 } = e, d = re(n), [m, _] = a.useState(null), u = a.useRef(!1), i = _e(c), f = Ne(r);
189
- return a.useEffect(() => {
190
- const h = () => {
191
- u.current = !0, document.addEventListener("pointerdown", v, { capture: !0, once: !0 }), document.addEventListener("pointermove", v, { capture: !0, once: !0 });
192
- }, v = () => u.current = !1;
193
- return document.addEventListener("keydown", h, { capture: !0 }), () => {
194
- document.removeEventListener("keydown", h, { capture: !0 }), document.removeEventListener("pointerdown", v, { capture: !0 }), document.removeEventListener("pointermove", v, { capture: !0 });
195
- };
196
- }, []), /* @__PURE__ */ s(So, { ...d, children: /* @__PURE__ */ s(
197
- Qo,
198
- {
199
- scope: n,
200
- open: o,
201
- onOpenChange: i,
202
- content: m,
203
- onContentChange: _,
204
- children: /* @__PURE__ */ s(
205
- en,
206
- {
207
- scope: n,
208
- onClose: a.useCallback(() => i(!1), [i]),
209
- isUsingKeyboardRef: u,
210
- dir: f,
211
- modal: l,
212
- children: t
213
- }
214
- )
215
- }
216
- ) });
217
- };
218
- We.displayName = q;
219
- var on = "MenuAnchor", we = a.forwardRef(
220
- (e, n) => {
221
- const { __scopeMenu: o, ...t } = e, r = re(o);
222
- return /* @__PURE__ */ s(Io, { ...r, ...t, ref: n });
223
- }
224
- );
225
- we.displayName = on;
226
- var nn = "MenuPortal", [Et, Ve] = G(nn, {
227
- forceMount: void 0
228
- }), D = "MenuContent", [tn, ve] = G(D), Ye = a.forwardRef(
229
- (e, n) => {
230
- const o = Ve(D, e.__scopeMenu), { forceMount: t = o.forceMount, ...r } = e, c = B(D, e.__scopeMenu), l = J(D, e.__scopeMenu);
231
- return /* @__PURE__ */ s(j.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ s(ge, { present: t || c.open, children: /* @__PURE__ */ s(j.Slot, { scope: e.__scopeMenu, children: l.modal ? /* @__PURE__ */ s(rn, { ...r, ref: n }) : /* @__PURE__ */ s(an, { ...r, ref: n }) }) }) });
232
- }
233
- ), rn = a.forwardRef(
234
- (e, n) => {
235
- const o = B(D, e.__scopeMenu), t = a.useRef(null), r = U(n, t);
236
- return a.useEffect(() => {
237
- const c = t.current;
238
- if (c) return bo(c);
239
- }, []), /* @__PURE__ */ s(
240
- he,
241
- {
242
- ...e,
243
- ref: r,
244
- trapFocus: o.open,
245
- disableOutsidePointerEvents: o.open,
246
- disableOutsideScroll: !0,
247
- onFocusOutside: g(
248
- e.onFocusOutside,
249
- (c) => c.preventDefault(),
250
- { checkForDefaultPrevented: !1 }
251
- ),
252
- onDismiss: () => o.onOpenChange(!1)
253
- }
254
- );
255
- }
256
- ), an = a.forwardRef((e, n) => {
257
- const o = B(D, e.__scopeMenu);
258
- return /* @__PURE__ */ s(
259
- he,
260
- {
261
- ...e,
262
- ref: n,
263
- trapFocus: !1,
264
- disableOutsidePointerEvents: !1,
265
- disableOutsideScroll: !1,
266
- onDismiss: () => o.onOpenChange(!1)
267
- }
268
- );
269
- }), cn = Ro("MenuContent.ScrollLock"), he = a.forwardRef(
270
- (e, n) => {
271
- const {
272
- __scopeMenu: o,
273
- loop: t = !1,
274
- trapFocus: r,
275
- onOpenAutoFocus: c,
276
- onCloseAutoFocus: l,
277
- disableOutsidePointerEvents: d,
278
- onEntryFocus: m,
279
- onEscapeKeyDown: _,
280
- onPointerDownOutside: u,
281
- onFocusOutside: i,
282
- onInteractOutside: f,
283
- onDismiss: h,
284
- disableOutsideScroll: v,
285
- ...R
286
- } = e, w = B(D, o), S = J(D, o), A = re(o), M = $e(o), E = qo(o), [$, Q] = a.useState(null), F = a.useRef(null), C = U(n, F, w.onContentChange), L = a.useRef(0), k = a.useRef(""), W = a.useRef(0), V = a.useRef(null), ee = a.useRef("right"), oe = a.useRef(0), se = v ? Eo : a.Fragment, P = v ? { as: cn, allowPinchZoom: !0 } : void 0, wo = (p) => {
287
- var z, Ie;
288
- const b = k.current + p, x = E().filter((y) => !y.disabled), N = document.activeElement, ie = (z = x.find((y) => y.ref.current === N)) == null ? void 0 : z.textValue, ue = x.map((y) => y.textValue), Se = hn(ue, b, ie), Y = (Ie = x.find((y) => y.textValue === Se)) == null ? void 0 : Ie.ref.current;
289
- (function y(be) {
290
- k.current = be, window.clearTimeout(L.current), be !== "" && (L.current = window.setTimeout(() => y(""), 1e3));
291
- })(b), Y && setTimeout(() => Y.focus());
292
- };
293
- a.useEffect(() => () => window.clearTimeout(L.current), []), Do();
294
- const K = a.useCallback((p) => {
295
- var x, N;
296
- return ee.current === ((x = V.current) == null ? void 0 : x.side) && Cn(p, (N = V.current) == null ? void 0 : N.area);
297
- }, []);
298
- return /* @__PURE__ */ s(
299
- tn,
300
- {
301
- scope: o,
302
- searchRef: k,
303
- onItemEnter: a.useCallback(
304
- (p) => {
305
- K(p) && p.preventDefault();
306
- },
307
- [K]
308
- ),
309
- onItemLeave: a.useCallback(
310
- (p) => {
311
- var b;
312
- K(p) || ((b = F.current) == null || b.focus(), Q(null));
313
- },
314
- [K]
315
- ),
316
- onTriggerLeave: a.useCallback(
317
- (p) => {
318
- K(p) && p.preventDefault();
319
- },
320
- [K]
321
- ),
322
- pointerGraceTimerRef: W,
323
- onPointerGraceIntentChange: a.useCallback((p) => {
324
- V.current = p;
325
- }, []),
326
- children: /* @__PURE__ */ s(se, { ...P, children: /* @__PURE__ */ s(
327
- xo,
328
- {
329
- asChild: !0,
330
- trapped: r,
331
- onMountAutoFocus: g(c, (p) => {
332
- var b;
333
- p.preventDefault(), (b = F.current) == null || b.focus({ preventScroll: !0 });
334
- }),
335
- onUnmountAutoFocus: l,
336
- children: /* @__PURE__ */ s(
337
- Po,
338
- {
339
- asChild: !0,
340
- disableOutsidePointerEvents: d,
341
- onEscapeKeyDown: _,
342
- onPointerDownOutside: u,
343
- onFocusOutside: i,
344
- onInteractOutside: f,
345
- onDismiss: h,
346
- children: /* @__PURE__ */ s(
347
- Vo,
348
- {
349
- asChild: !0,
350
- ...M,
351
- dir: S.dir,
352
- orientation: "vertical",
353
- loop: t,
354
- currentTabStopId: $,
355
- onCurrentTabStopIdChange: Q,
356
- onEntryFocus: g(m, (p) => {
357
- S.isUsingKeyboardRef.current || p.preventDefault();
358
- }),
359
- preventScrollOnEntryFocus: !0,
360
- children: /* @__PURE__ */ s(
361
- yo,
362
- {
363
- role: "menu",
364
- "aria-orientation": "vertical",
365
- "data-state": io(w.open),
366
- "data-radix-menu-content": "",
367
- dir: S.dir,
368
- ...A,
369
- ...R,
370
- ref: C,
371
- style: { outline: "none", ...R.style },
372
- onKeyDown: g(R.onKeyDown, (p) => {
373
- const x = p.target.closest("[data-radix-menu-content]") === p.currentTarget, N = p.ctrlKey || p.altKey || p.metaKey, ie = p.key.length === 1;
374
- x && (p.key === "Tab" && p.preventDefault(), !N && ie && wo(p.key));
375
- const ue = F.current;
376
- if (p.target !== ue || !jo.includes(p.key)) return;
377
- p.preventDefault();
378
- const Y = E().filter((z) => !z.disabled).map((z) => z.ref.current);
379
- Ue.includes(p.key) && Y.reverse(), wn(Y);
380
- }),
381
- onBlur: g(e.onBlur, (p) => {
382
- p.currentTarget.contains(p.target) || (window.clearTimeout(L.current), k.current = "");
383
- }),
384
- onPointerMove: g(
385
- e.onPointerMove,
386
- H((p) => {
387
- const b = p.target, x = oe.current !== p.clientX;
388
- if (p.currentTarget.contains(b) && x) {
389
- const N = p.clientX > oe.current ? "right" : "left";
390
- ee.current = N, oe.current = p.clientX;
391
- }
392
- })
393
- )
394
- }
395
- )
396
- }
397
- )
398
- }
399
- )
400
- }
401
- ) })
402
- }
403
- );
404
- }
405
- );
406
- Ye.displayName = D;
407
- var sn = "MenuGroup", Me = a.forwardRef(
408
- (e, n) => {
409
- const { __scopeMenu: o, ...t } = e;
410
- return /* @__PURE__ */ s(O.div, { role: "group", ...t, ref: n });
411
- }
412
- );
413
- Me.displayName = sn;
414
- var un = "MenuLabel", Xe = a.forwardRef(
415
- (e, n) => {
416
- const { __scopeMenu: o, ...t } = e;
417
- return /* @__PURE__ */ s(O.div, { ...t, ref: n });
418
- }
419
- );
420
- Xe.displayName = un;
421
- var ne = "MenuItem", Pe = "menu.itemSelect", ae = a.forwardRef(
422
- (e, n) => {
423
- const { disabled: o = !1, onSelect: t, ...r } = e, c = a.useRef(null), l = J(ne, e.__scopeMenu), d = ve(ne, e.__scopeMenu), m = U(n, c), _ = a.useRef(!1), u = () => {
424
- const i = c.current;
425
- if (!o && i) {
426
- const f = new CustomEvent(Pe, { bubbles: !0, cancelable: !0 });
427
- i.addEventListener(Pe, (h) => t == null ? void 0 : t(h), { once: !0 }), Co(i, f), f.defaultPrevented ? _.current = !1 : l.onClose();
428
- }
429
- };
430
- return /* @__PURE__ */ s(
431
- je,
432
- {
433
- ...r,
434
- ref: m,
435
- disabled: o,
436
- onClick: g(e.onClick, u),
437
- onPointerDown: (i) => {
438
- var f;
439
- (f = e.onPointerDown) == null || f.call(e, i), _.current = !0;
440
- },
441
- onPointerUp: g(e.onPointerUp, (i) => {
442
- var f;
443
- _.current || (f = i.currentTarget) == null || f.click();
444
- }),
445
- onKeyDown: g(e.onKeyDown, (i) => {
446
- const f = d.searchRef.current !== "";
447
- o || f && i.key === " " || pe.includes(i.key) && (i.currentTarget.click(), i.preventDefault());
448
- })
449
- }
450
- );
451
- }
452
- );
453
- ae.displayName = ne;
454
- var je = a.forwardRef(
455
- (e, n) => {
456
- const { __scopeMenu: o, disabled: t = !1, textValue: r, ...c } = e, l = ve(ne, o), d = $e(o), m = a.useRef(null), _ = U(n, m), [u, i] = a.useState(!1), [f, h] = a.useState("");
457
- return a.useEffect(() => {
458
- const v = m.current;
459
- v && h((v.textContent ?? "").trim());
460
- }, [c.children]), /* @__PURE__ */ s(
461
- j.ItemSlot,
462
- {
463
- scope: o,
464
- disabled: t,
465
- textValue: r ?? f,
466
- children: /* @__PURE__ */ s(Yo, { asChild: !0, ...d, focusable: !t, children: /* @__PURE__ */ s(
467
- O.div,
468
- {
469
- role: "menuitem",
470
- "data-highlighted": u ? "" : void 0,
471
- "aria-disabled": t || void 0,
472
- "data-disabled": t ? "" : void 0,
473
- ...c,
474
- ref: _,
475
- onPointerMove: g(
476
- e.onPointerMove,
477
- H((v) => {
478
- t ? l.onItemLeave(v) : (l.onItemEnter(v), v.defaultPrevented || v.currentTarget.focus({ preventScroll: !0 }));
479
- })
480
- ),
481
- onPointerLeave: g(
482
- e.onPointerLeave,
483
- H((v) => l.onItemLeave(v))
484
- ),
485
- onFocus: g(e.onFocus, () => i(!0)),
486
- onBlur: g(e.onBlur, () => i(!1))
487
- }
488
- ) })
489
- }
490
- );
491
- }
492
- ), ln = "MenuCheckboxItem", He = a.forwardRef(
493
- (e, n) => {
494
- const { checked: o = !1, onCheckedChange: t, ...r } = e;
495
- return /* @__PURE__ */ s(eo, { scope: e.__scopeMenu, checked: o, children: /* @__PURE__ */ s(
496
- ae,
497
- {
498
- role: "menuitemcheckbox",
499
- "aria-checked": te(o) ? "mixed" : o,
500
- ...r,
501
- ref: n,
502
- "data-state": Re(o),
503
- onSelect: g(
504
- r.onSelect,
505
- () => t == null ? void 0 : t(te(o) ? !0 : !o),
506
- { checkForDefaultPrevented: !1 }
507
- )
508
- }
509
- ) });
510
- }
511
- );
512
- He.displayName = ln;
513
- var Ze = "MenuRadioGroup", [dn, fn] = G(
514
- Ze,
515
- { value: void 0, onValueChange: () => {
516
- } }
517
- ), qe = a.forwardRef(
518
- (e, n) => {
519
- const { value: o, onValueChange: t, ...r } = e, c = _e(t);
520
- return /* @__PURE__ */ s(dn, { scope: e.__scopeMenu, value: o, onValueChange: c, children: /* @__PURE__ */ s(Me, { ...r, ref: n }) });
521
- }
522
- );
523
- qe.displayName = Ze;
524
- var Je = "MenuRadioItem", Qe = a.forwardRef(
525
- (e, n) => {
526
- const { value: o, ...t } = e, r = fn(Je, e.__scopeMenu), c = o === r.value;
527
- return /* @__PURE__ */ s(eo, { scope: e.__scopeMenu, checked: c, children: /* @__PURE__ */ s(
528
- ae,
529
- {
530
- role: "menuitemradio",
531
- "aria-checked": c,
532
- ...t,
533
- ref: n,
534
- "data-state": Re(c),
535
- onSelect: g(
536
- t.onSelect,
537
- () => {
538
- var l;
539
- return (l = r.onValueChange) == null ? void 0 : l.call(r, o);
540
- },
541
- { checkForDefaultPrevented: !1 }
542
- )
543
- }
544
- ) });
545
- }
546
- );
547
- Qe.displayName = Je;
548
- var Ce = "MenuItemIndicator", [eo, pn] = G(
549
- Ce,
550
- { checked: !1 }
551
- ), oo = a.forwardRef(
552
- (e, n) => {
553
- const { __scopeMenu: o, forceMount: t, ...r } = e, c = pn(Ce, o);
554
- return /* @__PURE__ */ s(
555
- ge,
556
- {
557
- present: t || te(c.checked) || c.checked === !0,
558
- children: /* @__PURE__ */ s(
559
- O.span,
560
- {
561
- ...r,
562
- ref: n,
563
- "data-state": Re(c.checked)
564
- }
565
- )
566
- }
567
- );
568
- }
569
- );
570
- oo.displayName = Ce;
571
- var mn = "MenuSeparator", no = a.forwardRef(
572
- (e, n) => {
573
- const { __scopeMenu: o, ...t } = e;
574
- return /* @__PURE__ */ s(
575
- O.div,
576
- {
577
- role: "separator",
578
- "aria-orientation": "horizontal",
579
- ...t,
580
- ref: n
581
- }
582
- );
583
- }
584
- );
585
- no.displayName = mn;
586
- var _n = "MenuArrow", to = a.forwardRef(
587
- (e, n) => {
588
- const { __scopeMenu: o, ...t } = e, r = re(o);
589
- return /* @__PURE__ */ s(To, { ...r, ...t, ref: n });
590
- }
591
- );
592
- to.displayName = _n;
593
- var gn = "MenuSub", [xt, ro] = G(gn), X = "MenuSubTrigger", ao = a.forwardRef(
594
- (e, n) => {
595
- const o = B(X, e.__scopeMenu), t = J(X, e.__scopeMenu), r = ro(X, e.__scopeMenu), c = ve(X, e.__scopeMenu), l = a.useRef(null), { pointerGraceTimerRef: d, onPointerGraceIntentChange: m } = c, _ = { __scopeMenu: e.__scopeMenu }, u = a.useCallback(() => {
596
- l.current && window.clearTimeout(l.current), l.current = null;
597
- }, []);
598
- return a.useEffect(() => u, [u]), a.useEffect(() => {
599
- const i = d.current;
600
- return () => {
601
- window.clearTimeout(i), m(null);
602
- };
603
- }, [d, m]), /* @__PURE__ */ s(we, { asChild: !0, ..._, children: /* @__PURE__ */ s(
604
- je,
605
- {
606
- id: r.triggerId,
607
- "aria-haspopup": "menu",
608
- "aria-expanded": o.open,
609
- "aria-controls": r.contentId,
610
- "data-state": io(o.open),
611
- ...e,
612
- ref: Te(n, r.onTriggerChange),
613
- onClick: (i) => {
614
- var f;
615
- (f = e.onClick) == null || f.call(e, i), !(e.disabled || i.defaultPrevented) && (i.currentTarget.focus(), o.open || o.onOpenChange(!0));
616
- },
617
- onPointerMove: g(
618
- e.onPointerMove,
619
- H((i) => {
620
- c.onItemEnter(i), !i.defaultPrevented && !e.disabled && !o.open && !l.current && (c.onPointerGraceIntentChange(null), l.current = window.setTimeout(() => {
621
- o.onOpenChange(!0), u();
622
- }, 100));
623
- })
624
- ),
625
- onPointerLeave: g(
626
- e.onPointerLeave,
627
- H((i) => {
628
- var h, v;
629
- u();
630
- const f = (h = o.content) == null ? void 0 : h.getBoundingClientRect();
631
- if (f) {
632
- const R = (v = o.content) == null ? void 0 : v.dataset.side, w = R === "right", S = w ? -5 : 5, A = f[w ? "left" : "right"], M = f[w ? "right" : "left"];
633
- c.onPointerGraceIntentChange({
634
- area: [
635
- // Apply a bleed on clientX to ensure that our exit point is
636
- // consistently within polygon bounds
637
- { x: i.clientX + S, y: i.clientY },
638
- { x: A, y: f.top },
639
- { x: M, y: f.top },
640
- { x: M, y: f.bottom },
641
- { x: A, y: f.bottom }
642
- ],
643
- side: R
644
- }), window.clearTimeout(d.current), d.current = window.setTimeout(
645
- () => c.onPointerGraceIntentChange(null),
646
- 300
647
- );
648
- } else {
649
- if (c.onTriggerLeave(i), i.defaultPrevented) return;
650
- c.onPointerGraceIntentChange(null);
651
- }
652
- })
653
- ),
654
- onKeyDown: g(e.onKeyDown, (i) => {
655
- var h;
656
- const f = c.searchRef.current !== "";
657
- e.disabled || f && i.key === " " || Ho[t.dir].includes(i.key) && (o.onOpenChange(!0), (h = o.content) == null || h.focus(), i.preventDefault());
658
- })
659
- }
660
- ) });
661
- }
662
- );
663
- ao.displayName = X;
664
- var co = "MenuSubContent", so = a.forwardRef(
665
- (e, n) => {
666
- const o = Ve(D, e.__scopeMenu), { forceMount: t = o.forceMount, ...r } = e, c = B(D, e.__scopeMenu), l = J(D, e.__scopeMenu), d = ro(co, e.__scopeMenu), m = a.useRef(null), _ = U(n, m);
667
- return /* @__PURE__ */ s(j.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ s(ge, { present: t || c.open, children: /* @__PURE__ */ s(j.Slot, { scope: e.__scopeMenu, children: /* @__PURE__ */ s(
668
- he,
669
- {
670
- id: d.contentId,
671
- "aria-labelledby": d.triggerId,
672
- ...r,
673
- ref: _,
674
- align: "start",
675
- side: l.dir === "rtl" ? "left" : "right",
676
- disableOutsidePointerEvents: !1,
677
- disableOutsideScroll: !1,
678
- trapFocus: !1,
679
- onOpenAutoFocus: (u) => {
680
- var i;
681
- l.isUsingKeyboardRef.current && ((i = m.current) == null || i.focus()), u.preventDefault();
682
- },
683
- onCloseAutoFocus: (u) => u.preventDefault(),
684
- onFocusOutside: g(e.onFocusOutside, (u) => {
685
- u.target !== d.trigger && c.onOpenChange(!1);
686
- }),
687
- onEscapeKeyDown: g(e.onEscapeKeyDown, (u) => {
688
- l.onClose(), u.preventDefault();
689
- }),
690
- onKeyDown: g(e.onKeyDown, (u) => {
691
- var h;
692
- const i = u.currentTarget.contains(u.target), f = Zo[l.dir].includes(u.key);
693
- i && f && (c.onOpenChange(!1), (h = d.trigger) == null || h.focus(), u.preventDefault());
694
- })
695
- }
696
- ) }) }) });
697
- }
698
- );
699
- so.displayName = co;
700
- function io(e) {
701
- return e ? "open" : "closed";
702
- }
703
- function te(e) {
704
- return e === "indeterminate";
705
- }
706
- function Re(e) {
707
- return te(e) ? "indeterminate" : e ? "checked" : "unchecked";
708
- }
709
- function wn(e) {
710
- const n = document.activeElement;
711
- for (const o of e)
712
- if (o === n || (o.focus(), document.activeElement !== n)) return;
713
- }
714
- function vn(e, n) {
715
- return e.map((o, t) => e[(n + t) % e.length]);
716
- }
717
- function hn(e, n, o) {
718
- const r = n.length > 1 && Array.from(n).every((_) => _ === n[0]) ? n[0] : n, c = o ? e.indexOf(o) : -1;
719
- let l = vn(e, Math.max(c, 0));
720
- r.length === 1 && (l = l.filter((_) => _ !== o));
721
- const m = l.find(
722
- (_) => _.toLowerCase().startsWith(r.toLowerCase())
723
- );
724
- return m !== o ? m : void 0;
725
- }
726
- function Mn(e, n) {
727
- const { x: o, y: t } = e;
728
- let r = !1;
729
- for (let c = 0, l = n.length - 1; c < n.length; l = c++) {
730
- const d = n[c], m = n[l], _ = d.x, u = d.y, i = m.x, f = m.y;
731
- u > t != f > t && o < (i - _) * (t - u) / (f - u) + _ && (r = !r);
732
- }
733
- return r;
734
- }
735
- function Cn(e, n) {
736
- if (!n) return !1;
737
- const o = { x: e.clientX, y: e.clientY };
738
- return Mn(o, n);
739
- }
740
- function H(e) {
741
- return (n) => n.pointerType === "mouse" ? e(n) : void 0;
742
- }
743
- var Rn = We, Sn = we, In = Ye, bn = Me, Dn = Xe, En = ae, xn = He, Pn = qe, yn = Qe, Tn = oo, An = no, Nn = to, On = ao, Fn = so, ce = "DropdownMenu", [kn, Pt] = me(
744
- ce,
745
- [Be]
746
- ), I = Be(), [Gn, uo] = kn(ce), lo = (e) => {
747
- const {
748
- __scopeDropdownMenu: n,
749
- children: o,
750
- dir: t,
751
- open: r,
752
- defaultOpen: c,
753
- onOpenChange: l,
754
- modal: d = !0
755
- } = e, m = I(n), _ = a.useRef(null), [u, i] = ye({
756
- prop: r,
757
- defaultProp: c ?? !1,
758
- onChange: l,
759
- caller: ce
760
- });
761
- return /* @__PURE__ */ s(
762
- Gn,
763
- {
764
- scope: n,
765
- triggerId: de(),
766
- triggerRef: _,
767
- contentId: de(),
768
- open: u,
769
- onOpenChange: i,
770
- onOpenToggle: a.useCallback(() => i((f) => !f), [i]),
771
- modal: d,
772
- children: /* @__PURE__ */ s(Rn, { ...m, open: u, onOpenChange: i, dir: t, modal: d, children: o })
773
- }
774
- );
775
- };
776
- lo.displayName = ce;
777
- var fo = "DropdownMenuTrigger", po = a.forwardRef(
778
- (e, n) => {
779
- const { __scopeDropdownMenu: o, disabled: t = !1, ...r } = e, c = uo(fo, o), l = I(o);
780
- return /* @__PURE__ */ s(Sn, { asChild: !0, ...l, children: /* @__PURE__ */ s(
781
- O.button,
782
- {
783
- type: "button",
784
- id: c.triggerId,
785
- "aria-haspopup": "menu",
786
- "aria-expanded": c.open,
787
- "aria-controls": c.open ? c.contentId : void 0,
788
- "data-state": c.open ? "open" : "closed",
789
- "data-disabled": t ? "" : void 0,
790
- disabled: t,
791
- ...r,
792
- ref: Te(n, c.triggerRef),
793
- onPointerDown: g(e.onPointerDown, (d) => {
794
- !t && d.button === 0 && d.ctrlKey === !1 && (c.onOpenToggle(), c.open || d.preventDefault());
795
- }),
796
- onKeyDown: g(e.onKeyDown, (d) => {
797
- t || (["Enter", " "].includes(d.key) && c.onOpenToggle(), d.key === "ArrowDown" && c.onOpenChange(!0), ["Enter", " ", "ArrowDown"].includes(d.key) && d.preventDefault());
798
- })
799
- }
800
- ) });
801
- }
802
- );
803
- po.displayName = fo;
804
- var mo = "DropdownMenuContent", _o = a.forwardRef(
805
- (e, n) => {
806
- const { __scopeDropdownMenu: o, ...t } = e, r = uo(mo, o), c = I(o), l = a.useRef(!1);
807
- return /* @__PURE__ */ s(
808
- In,
809
- {
810
- id: r.contentId,
811
- "aria-labelledby": r.triggerId,
812
- ...c,
813
- ...t,
814
- ref: n,
815
- onCloseAutoFocus: g(e.onCloseAutoFocus, (d) => {
816
- var m;
817
- l.current || (m = r.triggerRef.current) == null || m.focus(), l.current = !1, d.preventDefault();
818
- }),
819
- onInteractOutside: g(e.onInteractOutside, (d) => {
820
- const m = d.detail.originalEvent, _ = m.button === 0 && m.ctrlKey === !0, u = m.button === 2 || _;
821
- (!r.modal || u) && (l.current = !0);
822
- }),
823
- style: {
824
- ...e.style,
825
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
826
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
827
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
828
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
829
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
830
- }
831
- }
832
- );
833
- }
834
- );
835
- _o.displayName = mo;
836
- var Ln = "DropdownMenuGroup", Kn = a.forwardRef(
837
- (e, n) => {
838
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
839
- return /* @__PURE__ */ s(bn, { ...r, ...t, ref: n });
840
- }
841
- );
842
- Kn.displayName = Ln;
843
- var zn = "DropdownMenuLabel", Un = a.forwardRef(
844
- (e, n) => {
845
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
846
- return /* @__PURE__ */ s(Dn, { ...r, ...t, ref: n });
847
- }
848
- );
849
- Un.displayName = zn;
850
- var Bn = "DropdownMenuItem", go = a.forwardRef(
851
- (e, n) => {
852
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
853
- return /* @__PURE__ */ s(En, { ...r, ...t, ref: n });
854
- }
855
- );
856
- go.displayName = Bn;
857
- var $n = "DropdownMenuCheckboxItem", Wn = a.forwardRef((e, n) => {
858
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
859
- return /* @__PURE__ */ s(xn, { ...r, ...t, ref: n });
860
- });
861
- Wn.displayName = $n;
862
- var Vn = "DropdownMenuRadioGroup", Yn = a.forwardRef((e, n) => {
863
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
864
- return /* @__PURE__ */ s(Pn, { ...r, ...t, ref: n });
865
- });
866
- Yn.displayName = Vn;
867
- var Xn = "DropdownMenuRadioItem", jn = a.forwardRef((e, n) => {
868
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
869
- return /* @__PURE__ */ s(yn, { ...r, ...t, ref: n });
870
- });
871
- jn.displayName = Xn;
872
- var Hn = "DropdownMenuItemIndicator", Zn = a.forwardRef((e, n) => {
873
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
874
- return /* @__PURE__ */ s(Tn, { ...r, ...t, ref: n });
875
- });
876
- Zn.displayName = Hn;
877
- var qn = "DropdownMenuSeparator", Jn = a.forwardRef((e, n) => {
878
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
879
- return /* @__PURE__ */ s(An, { ...r, ...t, ref: n });
880
- });
881
- Jn.displayName = qn;
882
- var Qn = "DropdownMenuArrow", et = a.forwardRef(
883
- (e, n) => {
884
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
885
- return /* @__PURE__ */ s(Nn, { ...r, ...t, ref: n });
886
- }
887
- );
888
- et.displayName = Qn;
889
- var ot = "DropdownMenuSubTrigger", nt = a.forwardRef((e, n) => {
890
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
891
- return /* @__PURE__ */ s(On, { ...r, ...t, ref: n });
892
- });
893
- nt.displayName = ot;
894
- var tt = "DropdownMenuSubContent", rt = a.forwardRef((e, n) => {
895
- const { __scopeDropdownMenu: o, ...t } = e, r = I(o);
896
- return /* @__PURE__ */ s(
897
- Fn,
898
- {
899
- ...r,
900
- ...t,
901
- ref: n,
902
- style: {
903
- ...e.style,
904
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
905
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
906
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
907
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
908
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
909
- }
910
- }
911
- );
912
- });
913
- rt.displayName = tt;
914
- var at = lo, ct = po, st = _o, it = go;
915
- const ut = "cfxui__DropdownSelect__icon__d05b8", lt = "cfxui__DropdownSelect__trigger__c03df", dt = "cfxui__DropdownSelect__onlight__f0191", ft = "cfxui__DropdownSelect__fullWidth__dce56", pt = "cfxui__DropdownSelect__placeholder__e0d89", mt = "cfxui__DropdownSelect__content__05ed8", _t = "cfxui__DropdownSelect__item__0e45f", T = {
916
- icon: ut,
917
- trigger: lt,
918
- onlight: dt,
919
- fullWidth: ft,
920
- placeholder: pt,
921
- content: mt,
922
- item: _t,
923
- "dropdownselect-size-initial-large": "cfxui__DropdownSelect__dropdownselect-size-initial-large__d6bf3",
924
- "dropdownselect-size-initial-small": "cfxui__DropdownSelect__dropdownselect-size-initial-small__56570",
925
- "dropdownselect-size-small-large": "cfxui__DropdownSelect__dropdownselect-size-small-large__7f027",
926
- "dropdownselect-size-small-small": "cfxui__DropdownSelect__dropdownselect-size-small-small__bea7a",
927
- "dropdownselect-size-small-medium-large": "cfxui__DropdownSelect__dropdownselect-size-small-medium-large__c82c6",
928
- "dropdownselect-size-small-medium-small": "cfxui__DropdownSelect__dropdownselect-size-small-medium-small__f719a",
929
- "dropdownselect-size-medium-large": "cfxui__DropdownSelect__dropdownselect-size-medium-large__eb839",
930
- "dropdownselect-size-medium-small": "cfxui__DropdownSelect__dropdownselect-size-medium-small__698db",
931
- "dropdownselect-size-medium-large-large": "cfxui__DropdownSelect__dropdownselect-size-medium-large-large__dd545",
932
- "dropdownselect-size-medium-large-small": "cfxui__DropdownSelect__dropdownselect-size-medium-large-small__8cd70",
933
- "dropdownselect-size-large-large": "cfxui__DropdownSelect__dropdownselect-size-large-large__3b065",
934
- "dropdownselect-size-large-small": "cfxui__DropdownSelect__dropdownselect-size-large-small__5bca7",
935
- "dropdownselect-size-xlarge-large": "cfxui__DropdownSelect__dropdownselect-size-xlarge-large__23eae",
936
- "dropdownselect-size-xlarge-small": "cfxui__DropdownSelect__dropdownselect-size-xlarge-small__d232d"
937
- }, yt = {
1
+ import { jsxs as c, jsx as l } from "react/jsx-runtime";
2
+ import { g as w, R as C, T as D, D as W } from "../../DropdownContent-Robn2rha.js";
3
+ import N, { useRef as R, useState as b, useEffect as v } from "react";
4
+ import z from "../Flex/Flex.js";
5
+ import { clsx as I } from "../../utils/clsx.js";
6
+ import { Icon as T } from "../Icon/Icon.js";
7
+ import { mergeRefs as j } from "../../utils/mergeRefs.js";
8
+ const E = "cfxui__DropdownSelect__icon__d05b8", k = "cfxui__DropdownSelect__trigger__c03df", y = "cfxui__DropdownSelect__onlight__f0191", A = "cfxui__DropdownSelect__fullWidth__dce56", B = "cfxui__DropdownSelect__placeholder__e0d89", e = {
9
+ icon: E,
10
+ trigger: k,
11
+ onlight: y,
12
+ fullWidth: A,
13
+ placeholder: B
14
+ }, H = {
938
15
  small: "xxsmall",
939
16
  normal: "xsmall",
940
17
  large: "normal"
941
18
  };
942
- function Tt(e) {
19
+ function J(i) {
943
20
  const {
944
- options: n,
945
- value: o,
946
- onChange: t,
947
- size: r = "normal",
948
- fullWidth: c = !1,
949
- onlight: l = !1,
950
- disabled: d,
951
- placeholder: m = "Select...",
952
- ref: _
953
- } = e, u = vo(null), [i, f] = ho(void 0);
954
- Mo(() => {
955
- c && u.current && f(u.current.offsetWidth);
956
- }, [c]);
957
- const h = xe.getResponsiveFlatClassnames("dropdownselect-size", r).map((w) => T[w]), v = Ee(
958
- T.trigger,
959
- h,
960
- {
961
- [T.placeholder]: !o,
962
- [T.fullWidth]: c,
963
- [T.onlight]: l
964
- }
965
- ), R = Ee(
966
- T.content,
967
- h,
21
+ options: a,
22
+ value: r,
23
+ onChange: n,
24
+ size: s = "normal",
25
+ fullWidth: t = !1,
26
+ onlight: d = !1,
27
+ disabled: f,
28
+ placeholder: _ = "Select...",
29
+ ref: g
30
+ } = i, o = R(null), [m, h] = b(void 0);
31
+ v(() => {
32
+ t && o.current && h(o.current.offsetWidth);
33
+ }, [t]);
34
+ const p = w(s, "trigger"), u = I(
35
+ p,
36
+ e.trigger,
968
37
  {
969
- [T.fullWidth]: c
38
+ [e.placeholder]: !r,
39
+ [e.fullWidth]: t,
40
+ [e.onlight]: d
970
41
  }
971
- );
972
- return /* @__PURE__ */ De(at, { children: [
973
- /* @__PURE__ */ s(
974
- ct,
42
+ ), x = N.useCallback((S) => {
43
+ n(S);
44
+ }, [n]);
45
+ return /* @__PURE__ */ c(C, { children: [
46
+ /* @__PURE__ */ l(
47
+ D,
975
48
  {
976
- ref: Oo(_, u),
977
- className: v,
978
- disabled: d,
979
- children: /* @__PURE__ */ De(Ao, { gap: "small", centered: !0, spaceBetween: !0, children: [
980
- o || m,
981
- /* @__PURE__ */ s(No, { className: T.icon, name: "DownChevron" })
49
+ ref: j(g, o),
50
+ className: u,
51
+ disabled: f,
52
+ children: /* @__PURE__ */ c(z, { gap: "small", centered: !0, spaceBetween: !0, children: [
53
+ r || _,
54
+ /* @__PURE__ */ l(T, { className: e.icon, name: "DownChevron" })
982
55
  ] })
983
56
  }
984
57
  ),
985
- /* @__PURE__ */ s(
986
- st,
58
+ /* @__PURE__ */ l(
59
+ W,
987
60
  {
988
- align: "end",
989
- side: "bottom",
990
- className: R,
991
- style: {
992
- width: i,
993
- zIndex: xe.zindex("max")
994
- },
995
- children: n.map((w) => /* @__PURE__ */ s(
996
- it,
997
- {
998
- className: T.item,
999
- onSelect: () => t(w.value),
1000
- style: { width: i },
1001
- children: w.label
1002
- },
1003
- w.value
1004
- ))
61
+ triggerWidth: m,
62
+ options: a,
63
+ size: s,
64
+ fullWidth: t,
65
+ onSelect: x
1005
66
  }
1006
67
  )
1007
68
  ] });
1008
69
  }
1009
70
  export {
1010
- Tt as DropdownSelect,
1011
- yt as ICON_SIZE_MAP,
1012
- Tt as default
71
+ J as DropdownSelect,
72
+ H as ICON_SIZE_MAP,
73
+ J as default
1013
74
  };