boreal-ui 0.0.899-experimental.2 → 0.0.899-experimental.3

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.
Files changed (46) hide show
  1. package/dist/core/Dropdown-CQ8mXBk1.js +524 -0
  2. package/dist/core/Dropdown-DhL4sy9b.cjs +1 -0
  3. package/dist/core/Dropdown.cjs.js +1 -1
  4. package/dist/core/Dropdown.js +1 -1
  5. package/dist/core/Menu-CqYM7fgQ.cjs +1 -0
  6. package/dist/core/Menu-Oa4Fvi-_.js +529 -0
  7. package/dist/core/Menu.cjs.js +1 -0
  8. package/dist/core/Menu.css +1 -0
  9. package/dist/core/Menu.js +4 -0
  10. package/dist/core/index.cjs.js +4 -4
  11. package/dist/core/index.js +429 -177
  12. package/dist/generated-docs/Menu.props.js +254 -0
  13. package/dist/generated-docs/index.js +1 -0
  14. package/dist/next/Dropdown-e3qKirn6.js +528 -0
  15. package/dist/next/Dropdown.js +1 -1
  16. package/dist/next/Menu-DwDaoR8D.js +531 -0
  17. package/dist/next/Menu.css +1 -0
  18. package/dist/next/Menu.js +5 -0
  19. package/dist/next/index.js +430 -178
  20. package/dist/tsconfig.build.tsbuildinfo +1 -1
  21. package/dist/types/components/Dropdown/DropdownBase.d.ts.map +1 -1
  22. package/dist/types/components/Menu/Menu.types.d.ts +212 -0
  23. package/dist/types/components/Menu/Menu.types.d.ts.map +1 -0
  24. package/dist/types/components/Menu/MenuBase.d.ts +5 -0
  25. package/dist/types/components/Menu/MenuBase.d.ts.map +1 -0
  26. package/dist/types/components/Menu/core/Menu.d.ts +6 -0
  27. package/dist/types/components/Menu/core/Menu.d.ts.map +1 -0
  28. package/dist/types/components/Menu/next/Menu.d.ts +5 -0
  29. package/dist/types/components/Menu/next/Menu.d.ts.map +1 -0
  30. package/dist/types/core/Menu.d.ts +3 -0
  31. package/dist/types/core/Menu.d.ts.map +1 -0
  32. package/dist/types/generated-docs/Menu.props.d.ts +7 -0
  33. package/dist/types/generated-docs/Menu.props.d.ts.map +1 -0
  34. package/dist/types/generated-docs/index.d.ts +1 -0
  35. package/dist/types/generated-docs/index.d.ts.map +1 -1
  36. package/dist/types/index.core.d.ts +1 -0
  37. package/dist/types/index.core.d.ts.map +1 -1
  38. package/dist/types/index.next.d.ts +1 -0
  39. package/dist/types/index.next.d.ts.map +1 -1
  40. package/dist/types/next/Menu.d.ts +3 -0
  41. package/dist/types/next/Menu.d.ts.map +1 -0
  42. package/dist/types/public.types.d.ts +1 -0
  43. package/package.json +10 -1
  44. package/dist/core/Dropdown-C8lsSPKF.cjs +0 -1
  45. package/dist/core/Dropdown-DHts2OvA.js +0 -483
  46. package/dist/next/Dropdown-CAgRbUFM.js +0 -487
@@ -0,0 +1,524 @@
1
+ import { jsxs as P, jsx as p, Fragment as Ke } from "react/jsx-runtime";
2
+ import { e as Me } from "./propAliases-C-VkrhZR.js";
3
+ import { useState as Q, useRef as X, useId as Ve, useCallback as g, useLayoutEffect as pe, useEffect as Z, useMemo as Ue } from "react";
4
+ import { c as O } from "./classNames-Dz0_huu_.js";
5
+ import { c as F } from "./capitalize-D_pj4b3P.js";
6
+ import { g as Ye, f as Je, b as me, a as he } from "./styleConfig-4yWEoquf.js";
7
+ import { I as Qe } from "./IconButton-BrtJ7tw0.js";
8
+ import './Dropdown.css';const Xe = (o) => /* @__PURE__ */ P(
9
+ "svg",
10
+ {
11
+ width: "24px",
12
+ height: "24px",
13
+ strokeWidth: "1.5",
14
+ viewBox: "0 0 24 24",
15
+ fill: "none",
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ color: "currentColor",
18
+ ...o,
19
+ children: [
20
+ /* @__PURE__ */ p(
21
+ "path",
22
+ {
23
+ d: "M3 5H21",
24
+ stroke: "currentColor",
25
+ strokeWidth: "1.5",
26
+ strokeLinecap: "round",
27
+ strokeLinejoin: "round"
28
+ }
29
+ ),
30
+ /* @__PURE__ */ p(
31
+ "path",
32
+ {
33
+ d: "M3 12H21",
34
+ stroke: "currentColor",
35
+ strokeWidth: "1.5",
36
+ strokeLinecap: "round",
37
+ strokeLinejoin: "round"
38
+ }
39
+ ),
40
+ /* @__PURE__ */ p(
41
+ "path",
42
+ {
43
+ d: "M3 19H21",
44
+ stroke: "currentColor",
45
+ strokeWidth: "1.5",
46
+ strokeLinecap: "round",
47
+ strokeLinejoin: "round"
48
+ }
49
+ )
50
+ ]
51
+ }
52
+ ), I = "root", w = 8, Ze = (o, m) => o ? `${o}.${m}` : `${m}`, be = (o) => {
53
+ const m = o.split(".");
54
+ return m.length <= 1 ? null : m.slice(0, -1).join(".");
55
+ }, ge = (o, m) => o === m || (o == null ? void 0 : o.startsWith(`${m}.`)) === !0, ye = (o) => Array.isArray(o.items) && o.items.length > 0, _e = (o) => o.getAttribute("aria-disabled") === "true" || o instanceof HTMLButtonElement && o.disabled, Ie = ({
56
+ triggerIcon: o,
57
+ items: m,
58
+ align: ee = "right",
59
+ className: ke,
60
+ menuClassName: ne,
61
+ "aria-label": te = "Dropdown menu",
62
+ "aria-labelledby": re,
63
+ "aria-describedby": ve,
64
+ menuAriaLabel: Le,
65
+ menuAriaLabelledby: oe,
66
+ menuAriaDescribedby: De,
67
+ menuId: Ce,
68
+ triggerId: xe,
69
+ focusFirstItemOnOpen: de = !0,
70
+ closeOnSelect: G = !0,
71
+ theme: R = Ye(),
72
+ glass: q = Je(),
73
+ toggleRounding: Ne = me(),
74
+ menuRounding: S = me(),
75
+ toggleShadow: $e = he(),
76
+ menuShadow: H = he(),
77
+ toggleOutline: Ae = !1,
78
+ state: x,
79
+ title: Ee,
80
+ triggerProps: We,
81
+ menuProps: b,
82
+ "data-testid": Se,
83
+ testId: B = Se ?? "dropdown",
84
+ IconButton: He,
85
+ classMap: r,
86
+ ...Te
87
+ }) => {
88
+ const [l, ae] = Q(!1), [K, k] = Q(null), [Oe, se] = Q({}), j = X(null), v = X(null), ie = X(null), Pe = Ve(), M = Ce ?? Pe, Re = o ?? Xe, N = g((n) => n ? Array.from(
89
+ n.querySelectorAll('[data-dropdown-menu-item="true"]')
90
+ ).filter((e) => e.closest("[data-dropdown-panel]") === n && !_e(e)) : [], []), z = g(
91
+ (n) => {
92
+ var e;
93
+ (e = N(n)[0]) == null || e.focus();
94
+ },
95
+ [N]
96
+ ), T = g(
97
+ (n, e) => {
98
+ var d;
99
+ const t = N(n);
100
+ if (t.length === 0) return;
101
+ const f = (e + t.length) % t.length;
102
+ (d = t[f]) == null || d.focus();
103
+ },
104
+ [N]
105
+ ), ue = g(
106
+ (n) => {
107
+ const e = () => {
108
+ const t = document.getElementById(n);
109
+ t instanceof HTMLElement && z(t);
110
+ };
111
+ window.requestAnimationFrame ? window.requestAnimationFrame(e) : window.setTimeout(e);
112
+ },
113
+ [z]
114
+ ), $ = g((n = !0) => {
115
+ if (!l || !v.current) {
116
+ se({});
117
+ return;
118
+ }
119
+ const e = window.innerWidth || document.documentElement.clientWidth || 0, t = window.innerHeight || document.documentElement.clientHeight || 0, f = `${Math.max(120, t - w * 2)}px`, d = `${Math.max(160, e - w * 2)}px`, a = [
120
+ v.current,
121
+ ...Array.from(
122
+ v.current.querySelectorAll("[data-dropdown-panel]")
123
+ )
124
+ ];
125
+ se((s) => {
126
+ const u = n ? {} : {
127
+ [I]: s[I]
128
+ };
129
+ return a.forEach((h) => {
130
+ const _ = h.dataset.dropdownPanelPath ?? I;
131
+ if (_ === I && !n)
132
+ return;
133
+ const c = h.getBoundingClientRect(), A = {
134
+ "--dropdown-panel-max-height": f,
135
+ "--dropdown-panel-max-width": d
136
+ };
137
+ if (_ === I) {
138
+ u[_] = {
139
+ overflowLeft: c.left < w,
140
+ overflowRight: c.right > e - w,
141
+ style: A
142
+ };
143
+ return;
144
+ }
145
+ const E = h.closest(
146
+ '[data-dropdown-item-wrapper="true"]'
147
+ ), L = E == null ? void 0 : E.getBoundingClientRect(), J = Math.max(c.width, h.offsetWidth, 160), W = L ? e - L.right - w : e - c.right - w, i = L ? L.left - w : c.left - w, D = W >= J || W >= i ? "right" : "left";
148
+ let C = 0;
149
+ c.bottom > t - w && (C -= c.bottom - (t - w)), c.top + C < w && (C += w - (c.top + C)), A["--dropdown-panel-offset-y"] = `${Math.round(C)}px`, u[_] = {
150
+ placement: D,
151
+ style: A
152
+ };
153
+ }), u;
154
+ });
155
+ }, [l]), qe = () => {
156
+ ae((n) => (n && k(null), !n));
157
+ }, y = g(() => {
158
+ var n, e;
159
+ ae(!1), k(null), (e = (n = ie.current) == null ? void 0 : n.focus) == null || e.call(n);
160
+ }, []), V = g((n) => {
161
+ k((e) => e === n || e != null && e.startsWith(`${n}.`) ? e : n);
162
+ }, []), le = g((n) => {
163
+ k((e) => e === n || e != null && e.startsWith(`${n}.`) ? be(n) : n);
164
+ }, []), Be = g(
165
+ (n) => {
166
+ var e;
167
+ n.disabled || ye(n) || ((e = n.onClick) == null || e.call(n), G && y());
168
+ },
169
+ [y, G]
170
+ );
171
+ pe(() => {
172
+ l && $(!0);
173
+ }, [m, l, $]), pe(() => {
174
+ !l || !K || $(!1);
175
+ }, [l, K, $]), Z(() => {
176
+ if (!l) return;
177
+ const n = (e) => {
178
+ var f;
179
+ const t = e == null ? void 0 : e.target;
180
+ (e == null ? void 0 : e.type) === "scroll" && t instanceof Node && ((f = v.current) != null && f.contains(t)) || $(!0);
181
+ };
182
+ return window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
183
+ window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
184
+ };
185
+ }, [l, $]), Z(() => {
186
+ l && de && z(v.current);
187
+ }, [z, de, l]), Z(() => {
188
+ const n = (e) => {
189
+ j.current && !j.current.contains(e.target) && y();
190
+ };
191
+ return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
192
+ }, [y]);
193
+ const je = g(
194
+ (n) => {
195
+ var a;
196
+ if (!l) return;
197
+ const e = document.activeElement instanceof HTMLElement ? document.activeElement : null, t = (e == null ? void 0 : e.closest("[data-dropdown-panel]")) ?? v.current;
198
+ if (n.key === "Escape") {
199
+ n.preventDefault(), y();
200
+ return;
201
+ }
202
+ if (n.key === "Tab") {
203
+ y();
204
+ return;
205
+ }
206
+ const f = N(t), d = e ? f.indexOf(e) : -1;
207
+ if (n.key === "ArrowDown") {
208
+ n.preventDefault(), T(t, d + 1);
209
+ return;
210
+ }
211
+ if (n.key === "ArrowUp") {
212
+ n.preventDefault(), T(
213
+ t,
214
+ d < 0 ? f.length - 1 : d - 1
215
+ );
216
+ return;
217
+ }
218
+ if (n.key === "Home") {
219
+ n.preventDefault(), T(t, 0);
220
+ return;
221
+ }
222
+ if (n.key === "End") {
223
+ n.preventDefault(), T(t, f.length - 1);
224
+ return;
225
+ }
226
+ if (n.key === "ArrowRight") {
227
+ const s = e == null ? void 0 : e.dataset.dropdownItemPath, u = e == null ? void 0 : e.getAttribute("aria-controls");
228
+ (e == null ? void 0 : e.dataset.dropdownHasSubmenu) === "true" && s && u && (n.preventDefault(), V(s), ue(u));
229
+ return;
230
+ }
231
+ if (n.key === "ArrowLeft") {
232
+ const s = t == null ? void 0 : t.dataset.dropdownPanelPath;
233
+ if (s && s !== I) {
234
+ n.preventDefault();
235
+ const u = be(s);
236
+ k(u);
237
+ const h = (a = j.current) == null ? void 0 : a.querySelector(
238
+ `[data-dropdown-item-path="${s}"][data-dropdown-menu-item="true"]`
239
+ );
240
+ h == null || h.focus();
241
+ }
242
+ return;
243
+ }
244
+ if (n.key === "Enter" || n.key === " ") {
245
+ const s = (e == null ? void 0 : e.dataset.dropdownMenuItem) === "true" ? e : null;
246
+ if (!s || _e(s)) return;
247
+ if (n.preventDefault(), s.dataset.dropdownHasSubmenu === "true") {
248
+ const u = s.dataset.dropdownItemPath;
249
+ u && le(u);
250
+ return;
251
+ }
252
+ s.click();
253
+ }
254
+ },
255
+ [
256
+ y,
257
+ T,
258
+ ue,
259
+ N,
260
+ l,
261
+ V,
262
+ le
263
+ ]
264
+ ), ze = Ue(
265
+ () => O(
266
+ r.menu,
267
+ ee === "right" ? r.alignRight : r.alignLeft,
268
+ r[R],
269
+ x && r[x],
270
+ q && r.glass,
271
+ H && r[`shadow${F(H)}`],
272
+ S && r[`round${F(S)}`],
273
+ ne,
274
+ b == null ? void 0 : b.className
275
+ ),
276
+ [
277
+ r,
278
+ ee,
279
+ R,
280
+ x,
281
+ q,
282
+ H,
283
+ S,
284
+ ne,
285
+ b == null ? void 0 : b.className
286
+ ]
287
+ ), ce = (n) => {
288
+ const e = Oe[n];
289
+ return {
290
+ "data-overflow-left": e != null && e.overflowLeft ? "true" : void 0,
291
+ "data-overflow-right": e != null && e.overflowRight ? "true" : void 0,
292
+ "data-placement": e == null ? void 0 : e.placement,
293
+ style: e == null ? void 0 : e.style
294
+ };
295
+ }, Fe = (n) => O(
296
+ r.menu,
297
+ r.submenu,
298
+ n && r.submenuOpen,
299
+ r[R],
300
+ x && r[x],
301
+ q && r.glass,
302
+ H && r[`shadow${F(H)}`],
303
+ S && r[`round${F(S)}`]
304
+ ), U = (n, e) => /* @__PURE__ */ P(Ke, { children: [
305
+ /* @__PURE__ */ P("span", { className: r.itemContent, children: [
306
+ n.icon && /* @__PURE__ */ p("span", { className: r.icon, "aria-hidden": "true", children: n.icon }),
307
+ n.label
308
+ ] }),
309
+ e && /* @__PURE__ */ p("span", { className: r.submenuIndicator, "aria-hidden": "true", children: "›" })
310
+ ] }), fe = (n, e = "") => n.map((t, f) => {
311
+ const d = Ze(e, f), a = ye(t), s = a && ge(K, d), u = t["data-testid"] ?? t.testId, h = t.submenuId ?? `${M}-${d}-submenu`, _ = () => {
312
+ a && !t.disabled && V(d);
313
+ }, c = () => {
314
+ a && !t.disabled && k(d);
315
+ }, A = () => {
316
+ a || k((i) => i && (e ? ge(i, e) ? e : i : null));
317
+ }, E = () => {
318
+ if (a) {
319
+ _();
320
+ return;
321
+ }
322
+ A();
323
+ }, L = (i) => {
324
+ const D = i.target, C = i.currentTarget.closest(
325
+ "[data-dropdown-panel]"
326
+ ), we = D.closest("[data-dropdown-panel]"), Ge = D.closest(
327
+ '[data-dropdown-item-wrapper="true"]'
328
+ );
329
+ we && we !== C || Ge === i.currentTarget && (a ? c() : A());
330
+ }, J = O(
331
+ r.item,
332
+ a && r.submenuTrigger,
333
+ t.disabled ? r.disabled : ""
334
+ ), W = {
335
+ id: t.id,
336
+ className: J,
337
+ "aria-label": t["aria-label"],
338
+ "aria-describedby": t["aria-describedby"],
339
+ "aria-current": t["aria-current"],
340
+ "aria-disabled": t.disabled || void 0,
341
+ "aria-haspopup": a ? "menu" : void 0,
342
+ "aria-expanded": a ? s : void 0,
343
+ "aria-controls": a ? h : void 0,
344
+ title: t.title,
345
+ "data-dropdown-menu-item": "true",
346
+ "data-dropdown-item-path": d,
347
+ "data-dropdown-has-submenu": a ? "true" : void 0,
348
+ "data-testid": u
349
+ };
350
+ return /* @__PURE__ */ P(
351
+ "div",
352
+ {
353
+ className: O(
354
+ r.itemWrapper,
355
+ a && r.hasSubmenu
356
+ ),
357
+ "data-dropdown-item-wrapper": "true",
358
+ "data-dropdown-item-path": d,
359
+ onMouseEnter: E,
360
+ onMouseOver: L,
361
+ onPointerEnter: E,
362
+ onPointerOver: L,
363
+ children: [
364
+ a ? /* @__PURE__ */ p(
365
+ "button",
366
+ {
367
+ type: "button",
368
+ disabled: t.disabled,
369
+ ...W,
370
+ onMouseEnter: _,
371
+ onMouseOver: c,
372
+ onPointerEnter: _,
373
+ onPointerOver: c,
374
+ onClick: (i) => {
375
+ i.stopPropagation(), c();
376
+ },
377
+ children: U(t, !0)
378
+ }
379
+ ) : t.href ? /* @__PURE__ */ p(
380
+ "a",
381
+ {
382
+ href: t.disabled ? void 0 : t.href,
383
+ target: t.disabled ? void 0 : t.target,
384
+ rel: t.rel ?? (t.target === "_blank" ? "noopener noreferrer" : void 0),
385
+ ...W,
386
+ onClick: (i) => {
387
+ var D;
388
+ if (i.stopPropagation(), t.disabled) {
389
+ i.preventDefault();
390
+ return;
391
+ }
392
+ (D = t.onClick) == null || D.call(t), G && y();
393
+ },
394
+ children: U(t, !1)
395
+ }
396
+ ) : /* @__PURE__ */ p(
397
+ "button",
398
+ {
399
+ type: "button",
400
+ disabled: t.disabled,
401
+ ...W,
402
+ onClick: (i) => {
403
+ i.stopPropagation(), Be(t);
404
+ },
405
+ children: U(t, !1)
406
+ }
407
+ ),
408
+ a && s && /* @__PURE__ */ p(
409
+ "div",
410
+ {
411
+ id: h,
412
+ className: Fe(s),
413
+ "aria-label": t.submenuAriaLabel ?? t.label,
414
+ "data-dropdown-panel": "true",
415
+ "data-dropdown-panel-path": d,
416
+ "data-testid": u ? `${u}-submenu` : `${B}-${d}-submenu`,
417
+ ...ce(d),
418
+ children: fe(t.items ?? [], d)
419
+ }
420
+ )
421
+ ]
422
+ },
423
+ t.id ?? d
424
+ );
425
+ }), Y = ce(I);
426
+ return /* @__PURE__ */ P(
427
+ "div",
428
+ {
429
+ ref: j,
430
+ className: O(r.wrapper, ke),
431
+ onKeyDown: je,
432
+ "data-testid": B,
433
+ ...Te,
434
+ children: [
435
+ /* @__PURE__ */ p(
436
+ He,
437
+ {
438
+ ref: ie,
439
+ id: xe,
440
+ icon: Re,
441
+ "aria-label": re ? void 0 : te,
442
+ "aria-labelledby": re,
443
+ "aria-describedby": ve,
444
+ "aria-haspopup": "menu",
445
+ "aria-expanded": l,
446
+ "aria-controls": M,
447
+ rounding: Ne,
448
+ shadow: $e,
449
+ outline: Ae,
450
+ glass: q,
451
+ theme: R,
452
+ state: x,
453
+ onClick: qe,
454
+ title: Ee,
455
+ "data-testid": `${B}-trigger`,
456
+ ...We
457
+ }
458
+ ),
459
+ l && /* @__PURE__ */ p(
460
+ "div",
461
+ {
462
+ ...b,
463
+ id: M,
464
+ ref: v,
465
+ "aria-label": oe ? void 0 : Le ?? te,
466
+ "aria-labelledby": oe,
467
+ "aria-describedby": De,
468
+ className: ze,
469
+ "data-dropdown-panel": "true",
470
+ "data-dropdown-panel-path": I,
471
+ "data-overflow-left": Y["data-overflow-left"],
472
+ "data-overflow-right": Y["data-overflow-right"],
473
+ "data-testid": `${B}-menu`,
474
+ style: {
475
+ ...Y.style,
476
+ ...b == null ? void 0 : b.style
477
+ },
478
+ children: fe(m)
479
+ }
480
+ )
481
+ ]
482
+ }
483
+ );
484
+ };
485
+ Ie.displayName = "BaseDropdown";
486
+ const en = {
487
+ wrapper: "dropdown",
488
+ menu: "dropdown_menu",
489
+ item: "dropdown_item",
490
+ itemWrapper: "dropdown_itemWrapper",
491
+ itemContent: "dropdown_itemContent",
492
+ icon: "dropdown_icon",
493
+ hasSubmenu: "dropdown_hasSubmenu",
494
+ submenu: "dropdown_submenu",
495
+ submenuOpen: "dropdown_submenu_open",
496
+ submenuTrigger: "dropdown_submenuTrigger",
497
+ submenuIndicator: "dropdown_submenuIndicator",
498
+ alignRight: "dropdown_menu_right",
499
+ alignLeft: "dropdown_menu_left",
500
+ primary: "dropdown_primary",
501
+ secondary: "dropdown_secondary",
502
+ tertiary: "dropdown_tertiary",
503
+ quaternary: "dropdown_quaternary",
504
+ clear: "dropdown_clear",
505
+ success: "dropdown_success",
506
+ info: "dropdown_info",
507
+ error: "dropdown_error",
508
+ warning: "dropdown_warning",
509
+ disabled: "dropdown_disabled",
510
+ glass: "dropdown_glass",
511
+ shadowNone: "menu_shadow-None",
512
+ shadowLight: "menu_shadow-Light",
513
+ shadowMedium: "menu_shadow-Medium",
514
+ shadowStrong: "menu_shadow-Strong",
515
+ shadowIntense: "menu_shadow-Intense",
516
+ roundNone: "menu_round-None",
517
+ roundSmall: "menu_round-Small",
518
+ roundMedium: "menu_round-Medium",
519
+ roundLarge: "menu_round-Large"
520
+ }, nn = (o) => /* @__PURE__ */ p(Ie, { ...o, IconButton: Qe, classMap: Me(en) });
521
+ nn.displayName = "Dropdown";
522
+ export {
523
+ nn as D
524
+ };
@@ -0,0 +1 @@
1
+ "use strict";require('./Dropdown.css');const i=require("react/jsx-runtime"),Pe=require("./propAliases-Bfsf5cJN.cjs"),o=require("react"),q=require("./classNames-C7V3kfBj.cjs"),F=require("./capitalize-CnTiekgk.cjs"),S=require("./styleConfig-BB8MdwYx.cjs"),Be=require("./IconButton-BAw_T9gw.cjs"),ze=a=>i.jsxs("svg",{width:"24px",height:"24px",strokeWidth:"1.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",color:"currentColor",...a,children:[i.jsx("path",{d:"M3 5H21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M3 19H21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),C="root",b=8,Fe=(a,h)=>a?`${a}.${h}`:`${h}`,ce=a=>{const h=a.split(".");return h.length<=1?null:h.slice(0,-1).join(".")},fe=(a,h)=>a===h||(a==null?void 0:a.startsWith(`${h}.`))===!0,we=a=>Array.isArray(a.items)&&a.items.length>0,pe=a=>a.getAttribute("aria-disabled")==="true"||a instanceof HTMLButtonElement&&a.disabled,be=({triggerIcon:a,items:h,align:Q="right",className:me,menuClassName:X,"aria-label":Z="Dropdown menu","aria-labelledby":ee,"aria-describedby":ge,menuAriaLabel:ye,menuAriaLabelledby:te,menuAriaDescribedby:ke,menuId:Ce,triggerId:_e,focusFirstItemOnOpen:ne=!0,closeOnSelect:G=!0,theme:T=S.getDefaultTheme(),glass:O=S.getDefaultGlass(),toggleRounding:xe=S.getDefaultRounding(),menuRounding:W=S.getDefaultRounding(),toggleShadow:Ie=S.getDefaultShadow(),menuShadow:R=S.getDefaultShadow(),toggleOutline:De=!1,state:v,title:Le,triggerProps:ve,menuProps:g,"data-testid":Ne,testId:P=Ne??"dropdown",IconButton:je,classMap:r,...Ee})=>{const[f,re]=o.useState(!1),[K,_]=o.useState(null),[$e,oe]=o.useState({}),B=o.useRef(null),x=o.useRef(null),ae=o.useRef(null),Ae=o.useId(),M=Ce??Ae,Se=a??ze,N=o.useCallback(t=>t?Array.from(t.querySelectorAll('[data-dropdown-menu-item="true"]')).filter(e=>e.closest("[data-dropdown-panel]")===t&&!pe(e)):[],[]),z=o.useCallback(t=>{var e;(e=N(t)[0])==null||e.focus()},[N]),H=o.useCallback((t,e)=>{var d;const n=N(t);if(n.length===0)return;const p=(e+n.length)%n.length;(d=n[p])==null||d.focus()},[N]),de=o.useCallback(t=>{const e=()=>{const n=document.getElementById(t);n instanceof HTMLElement&&z(n)};window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e)},[z]),j=o.useCallback((t=!0)=>{if(!f||!x.current){oe({});return}const e=window.innerWidth||document.documentElement.clientWidth||0,n=window.innerHeight||document.documentElement.clientHeight||0,p=`${Math.max(120,n-b*2)}px`,d=`${Math.max(160,e-b*2)}px`,s=[x.current,...Array.from(x.current.querySelectorAll("[data-dropdown-panel]"))];oe(u=>{const c=t?{}:{[C]:u[C]};return s.forEach(m=>{const k=m.dataset.dropdownPanelPath??C;if(k===C&&!t)return;const w=m.getBoundingClientRect(),E={"--dropdown-panel-max-height":p,"--dropdown-panel-max-width":d};if(k===C){c[k]={overflowLeft:w.left<b,overflowRight:w.right>e-b,style:E};return}const $=m.closest('[data-dropdown-item-wrapper="true"]'),I=$==null?void 0:$.getBoundingClientRect(),J=Math.max(w.width,m.offsetWidth,160),A=I?e-I.right-b:e-w.right-b,l=I?I.left-b:w.left-b,D=A>=J||A>=l?"right":"left";let L=0;w.bottom>n-b&&(L-=w.bottom-(n-b)),w.top+L<b&&(L+=b-(w.top+L)),E["--dropdown-panel-offset-y"]=`${Math.round(L)}px`,c[k]={placement:D,style:E}}),c})},[f]),We=()=>{re(t=>(t&&_(null),!t))},y=o.useCallback(()=>{var t,e;re(!1),_(null),(e=(t=ae.current)==null?void 0:t.focus)==null||e.call(t)},[]),V=o.useCallback(t=>{_(e=>e===t||e!=null&&e.startsWith(`${t}.`)?e:t)},[]),se=o.useCallback(t=>{_(e=>e===t||e!=null&&e.startsWith(`${t}.`)?ce(t):t)},[]),Re=o.useCallback(t=>{var e;t.disabled||we(t)||((e=t.onClick)==null||e.call(t),G&&y())},[y,G]);o.useLayoutEffect(()=>{f&&j(!0)},[h,f,j]),o.useLayoutEffect(()=>{!f||!K||j(!1)},[f,K,j]),o.useEffect(()=>{if(!f)return;const t=e=>{var p;const n=e==null?void 0:e.target;(e==null?void 0:e.type)==="scroll"&&n instanceof Node&&((p=x.current)!=null&&p.contains(n))||j(!0)};return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[f,j]),o.useEffect(()=>{f&&ne&&z(x.current)},[z,ne,f]),o.useEffect(()=>{const t=e=>{B.current&&!B.current.contains(e.target)&&y()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[y]);const He=o.useCallback(t=>{var s;if(!f)return;const e=document.activeElement instanceof HTMLElement?document.activeElement:null,n=(e==null?void 0:e.closest("[data-dropdown-panel]"))??x.current;if(t.key==="Escape"){t.preventDefault(),y();return}if(t.key==="Tab"){y();return}const p=N(n),d=e?p.indexOf(e):-1;if(t.key==="ArrowDown"){t.preventDefault(),H(n,d+1);return}if(t.key==="ArrowUp"){t.preventDefault(),H(n,d<0?p.length-1:d-1);return}if(t.key==="Home"){t.preventDefault(),H(n,0);return}if(t.key==="End"){t.preventDefault(),H(n,p.length-1);return}if(t.key==="ArrowRight"){const u=e==null?void 0:e.dataset.dropdownItemPath,c=e==null?void 0:e.getAttribute("aria-controls");(e==null?void 0:e.dataset.dropdownHasSubmenu)==="true"&&u&&c&&(t.preventDefault(),V(u),de(c));return}if(t.key==="ArrowLeft"){const u=n==null?void 0:n.dataset.dropdownPanelPath;if(u&&u!==C){t.preventDefault();const c=ce(u);_(c);const m=(s=B.current)==null?void 0:s.querySelector(`[data-dropdown-item-path="${u}"][data-dropdown-menu-item="true"]`);m==null||m.focus()}return}if(t.key==="Enter"||t.key===" "){const u=(e==null?void 0:e.dataset.dropdownMenuItem)==="true"?e:null;if(!u||pe(u))return;if(t.preventDefault(),u.dataset.dropdownHasSubmenu==="true"){const c=u.dataset.dropdownItemPath;c&&se(c);return}u.click()}},[y,H,de,N,f,V,se]),qe=o.useMemo(()=>q.combineClassNames(r.menu,Q==="right"?r.alignRight:r.alignLeft,r[T],v&&r[v],O&&r.glass,R&&r[`shadow${F.capitalize(R)}`],W&&r[`round${F.capitalize(W)}`],X,g==null?void 0:g.className),[r,Q,T,v,O,R,W,X,g==null?void 0:g.className]),ue=t=>{const e=$e[t];return{"data-overflow-left":e!=null&&e.overflowLeft?"true":void 0,"data-overflow-right":e!=null&&e.overflowRight?"true":void 0,"data-placement":e==null?void 0:e.placement,style:e==null?void 0:e.style}},Te=t=>q.combineClassNames(r.menu,r.submenu,t&&r.submenuOpen,r[T],v&&r[v],O&&r.glass,R&&r[`shadow${F.capitalize(R)}`],W&&r[`round${F.capitalize(W)}`]),U=(t,e)=>i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:r.itemContent,children:[t.icon&&i.jsx("span",{className:r.icon,"aria-hidden":"true",children:t.icon}),t.label]}),e&&i.jsx("span",{className:r.submenuIndicator,"aria-hidden":"true",children:"›"})]}),ie=(t,e="")=>t.map((n,p)=>{const d=Fe(e,p),s=we(n),u=s&&fe(K,d),c=n["data-testid"]??n.testId,m=n.submenuId??`${M}-${d}-submenu`,k=()=>{s&&!n.disabled&&V(d)},w=()=>{s&&!n.disabled&&_(d)},E=()=>{s||_(l=>l&&(e?fe(l,e)?e:l:null))},$=()=>{if(s){k();return}E()},I=l=>{const D=l.target,L=l.currentTarget.closest("[data-dropdown-panel]"),le=D.closest("[data-dropdown-panel]"),Oe=D.closest('[data-dropdown-item-wrapper="true"]');le&&le!==L||Oe===l.currentTarget&&(s?w():E())},J=q.combineClassNames(r.item,s&&r.submenuTrigger,n.disabled?r.disabled:""),A={id:n.id,className:J,"aria-label":n["aria-label"],"aria-describedby":n["aria-describedby"],"aria-current":n["aria-current"],"aria-disabled":n.disabled||void 0,"aria-haspopup":s?"menu":void 0,"aria-expanded":s?u:void 0,"aria-controls":s?m:void 0,title:n.title,"data-dropdown-menu-item":"true","data-dropdown-item-path":d,"data-dropdown-has-submenu":s?"true":void 0,"data-testid":c};return i.jsxs("div",{className:q.combineClassNames(r.itemWrapper,s&&r.hasSubmenu),"data-dropdown-item-wrapper":"true","data-dropdown-item-path":d,onMouseEnter:$,onMouseOver:I,onPointerEnter:$,onPointerOver:I,children:[s?i.jsx("button",{type:"button",disabled:n.disabled,...A,onMouseEnter:k,onMouseOver:w,onPointerEnter:k,onPointerOver:w,onClick:l=>{l.stopPropagation(),w()},children:U(n,!0)}):n.href?i.jsx("a",{href:n.disabled?void 0:n.href,target:n.disabled?void 0:n.target,rel:n.rel??(n.target==="_blank"?"noopener noreferrer":void 0),...A,onClick:l=>{var D;if(l.stopPropagation(),n.disabled){l.preventDefault();return}(D=n.onClick)==null||D.call(n),G&&y()},children:U(n,!1)}):i.jsx("button",{type:"button",disabled:n.disabled,...A,onClick:l=>{l.stopPropagation(),Re(n)},children:U(n,!1)}),s&&u&&i.jsx("div",{id:m,className:Te(u),"aria-label":n.submenuAriaLabel??n.label,"data-dropdown-panel":"true","data-dropdown-panel-path":d,"data-testid":c?`${c}-submenu`:`${P}-${d}-submenu`,...ue(d),children:ie(n.items??[],d)})]},n.id??d)}),Y=ue(C);return i.jsxs("div",{ref:B,className:q.combineClassNames(r.wrapper,me),onKeyDown:He,"data-testid":P,...Ee,children:[i.jsx(je,{ref:ae,id:_e,icon:Se,"aria-label":ee?void 0:Z,"aria-labelledby":ee,"aria-describedby":ge,"aria-haspopup":"menu","aria-expanded":f,"aria-controls":M,rounding:xe,shadow:Ie,outline:De,glass:O,theme:T,state:v,onClick:We,title:Le,"data-testid":`${P}-trigger`,...ve}),f&&i.jsx("div",{...g,id:M,ref:x,"aria-label":te?void 0:ye??Z,"aria-labelledby":te,"aria-describedby":ke,className:qe,"data-dropdown-panel":"true","data-dropdown-panel-path":C,"data-overflow-left":Y["data-overflow-left"],"data-overflow-right":Y["data-overflow-right"],"data-testid":`${P}-menu`,style:{...Y.style,...g==null?void 0:g.style},children:ie(h)})]})};be.displayName="BaseDropdown";const Ge={wrapper:"dropdown",menu:"dropdown_menu",item:"dropdown_item",itemWrapper:"dropdown_itemWrapper",itemContent:"dropdown_itemContent",icon:"dropdown_icon",hasSubmenu:"dropdown_hasSubmenu",submenu:"dropdown_submenu",submenuOpen:"dropdown_submenu_open",submenuTrigger:"dropdown_submenuTrigger",submenuIndicator:"dropdown_submenuIndicator",alignRight:"dropdown_menu_right",alignLeft:"dropdown_menu_left",primary:"dropdown_primary",secondary:"dropdown_secondary",tertiary:"dropdown_tertiary",quaternary:"dropdown_quaternary",clear:"dropdown_clear",success:"dropdown_success",info:"dropdown_info",error:"dropdown_error",warning:"dropdown_warning",disabled:"dropdown_disabled",glass:"dropdown_glass",shadowNone:"menu_shadow-None",shadowLight:"menu_shadow-Light",shadowMedium:"menu_shadow-Medium",shadowStrong:"menu_shadow-Strong",shadowIntense:"menu_shadow-Intense",roundNone:"menu_round-None",roundSmall:"menu_round-Small",roundMedium:"menu_round-Medium",roundLarge:"menu_round-Large"},he=a=>i.jsx(be,{...a,IconButton:Be.IconButton,classMap:Pe.expandClassMap(Ge)});he.displayName="Dropdown";exports.Dropdown=he;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Dropdown-C8lsSPKF.cjs");exports.default=e.Dropdown;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Dropdown-DhL4sy9b.cjs");exports.default=e.Dropdown;
@@ -1,4 +1,4 @@
1
- import { D as f } from "./Dropdown-DHts2OvA.js";
1
+ import { D as f } from "./Dropdown-CQ8mXBk1.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -0,0 +1 @@
1
+ "use strict";require('./Menu.css');const l=require("react/jsx-runtime"),Ke=require("./propAliases-Bfsf5cJN.cjs"),s=require("react"),k=require("./classNames-C7V3kfBj.cjs"),Q=require("./capitalize-CnTiekgk.cjs"),Z=require("./styleConfig-BB8MdwYx.cjs"),H="root",m=8,Pe=(o,p)=>o?`${o}.${p}`:`${p}`,en=o=>{const p=o.split(".");return p.length>1?p.slice(0,-1).join("."):null},Ne=o=>Array.isArray(o.items)&&o.items.length>0,de=(o,p)=>o===p||(o==null?void 0:o.startsWith(`${p}.`))===!0,Ce=o=>o.getAttribute("aria-disabled")==="true"||o instanceof HTMLButtonElement&&o.disabled,Se=({items:o,children:p,trigger:K,open:ce,defaultOpen:$e=!1,position:M,activation:P=K?"click":"contextmenu",onOpenChange:O,onPositionChange:B,closeOnSelect:Le=!0,focusFirstItemOnOpen:me=!0,theme:ee=Z.getDefaultTheme(),glass:ne=Z.getDefaultGlass(),rounding:R=Z.getDefaultRounding(),shadow:j=Z.getDefaultShadow(),state:A,className:Ee,targetClassName:Re,triggerClassName:je,menuClassName:fe,itemClassName:Ae,id:De,menuId:Te,"aria-label":qe="Context menu","aria-labelledby":be,"aria-describedby":We,"data-testid":ve,testId:N=ve??"menu",triggerProps:h,menuProps:w,onKeyDown:te,classMap:u,...C})=>{const[He,Me]=s.useState($e),[Oe,Be]=s.useState(M??{x:0,y:0}),[he,D]=s.useState(null),[ae,ye]=s.useState({}),ue=s.useRef(null),re=s.useRef(null),z=s.useRef(null),S=s.useRef(null),ze=s.useId(),xe=ce!==void 0,b=ce??He,se=Te??`${ze}-menu`,F=M??Oe,Y=s.useCallback(e=>{xe||Me(e),e||D(null),O==null||O(e)},[xe,O]),pe=s.useCallback(e=>{M||Be(e),B==null||B(e)},[B,M]),X=s.useCallback(e=>{pe(e),Y(!0)},[pe,Y]),T=s.useCallback(()=>{var e;Y(!1),(e=z.current)==null||e.focus()},[Y]),q=s.useCallback(e=>e?Array.from(e.querySelectorAll('[data-menu-item="true"]')).filter(t=>t.closest("[data-menu-panel]")===e&&!Ce(t)):[],[]),G=s.useCallback((e,t)=>{var r;const n=q(e);if(n.length===0)return;const i=(t+n.length)%n.length;(r=n[i])==null||r.focus()},[q]),oe=s.useCallback(e=>{var t;(t=q(e)[0])==null||t.focus()},[q]),I=s.useCallback(()=>{if(!b||!S.current){ye({});return}const e=window.innerWidth||document.documentElement.clientWidth||0,t=window.innerHeight||document.documentElement.clientHeight||0,n=`${Math.max(120,t-m*2)}px`,i=`${Math.max(160,e-m*2)}px`,r=[S.current,...Array.from(S.current.querySelectorAll("[data-menu-panel]"))],y={};r.forEach(f=>{const a=f.dataset.menuPanelPath??H,d=f.getBoundingClientRect(),x={"--menu-panel-max-height":n,"--menu-panel-max-width":i};if(a===H){const v=Math.min(Math.max(m,F.x),Math.max(m,e-d.width-m)),J=Math.min(Math.max(m,F.y),Math.max(m,t-d.height-m));x.left=`${Math.round(v)}px`,x.top=`${Math.round(J)}px`,y[a]={style:x};return}const $=f.closest('[data-menu-item-wrapper="true"]'),_=$==null?void 0:$.getBoundingClientRect(),L=Math.max(d.width,f.offsetWidth,160),W=_?e-_.right-m:e-d.right-m,U=_?_.left-m:d.left-m,V=W>=L||W>=U?"right":"left";let g=0;d.bottom>t-m&&(g-=d.bottom-(t-m)),d.top+g<m&&(g+=m-(d.top+g)),x["--menu-panel-offset-y"]=`${Math.round(g)}px`,y[a]={placement:V,style:x}}),ye(y)},[b,F.x,F.y]);s.useLayoutEffect(()=>{b&&I()},[b,o,he,I]),s.useEffect(()=>{if(b)return window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[b,I]),s.useEffect(()=>{!b||!me||oe(S.current)},[me,oe,b]),s.useEffect(()=>{if(!b)return;const e=t=>{var n;(n=ue.current)!=null&&n.contains(t.target)||T()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[T,b]);const Fe=s.useMemo(()=>k.combineClassNames(u.menu,u[ee],A&&u[A],ne&&u.glass,j&&u[`shadow${Q.capitalize(j)}`],R&&u[`round${Q.capitalize(R)}`],fe,w==null?void 0:w.className),[u,ne,fe,w==null?void 0:w.className,R,j,A,ee]),Ye=e=>k.combineClassNames(u.menu,u.submenu,e&&u.submenuOpen,u[ee],A&&u[A],ne&&u.glass,j&&u[`shadow${Q.capitalize(j)}`],R&&u[`round${Q.capitalize(R)}`]),le=ae[H],Xe=e=>{var t;(t=C.onContextMenu)==null||t.call(C,e),!(e.defaultPrevented||!["contextmenu","both"].includes(P))&&(e.preventDefault(),X({x:e.clientX,y:e.clientY}))},Ge=e=>{var i,r,y,f;if((i=C.onClick)==null||i.call(C,e),e.defaultPrevented||!["click","both"].includes(P))return;const t=e.target;if((r=S.current)!=null&&r.contains(t)||(y=z.current)!=null&&y.contains(t))return;const n=(f=re.current)==null?void 0:f.getBoundingClientRect();X({x:(n==null?void 0:n.left)??e.clientX,y:(n==null?void 0:n.bottom)??e.clientY})},Ue=e=>{var n,i;if((n=h==null?void 0:h.onClick)==null||n.call(h,e),e.defaultPrevented)return;e.stopPropagation();const t=(i=z.current)==null?void 0:i.getBoundingClientRect();X({x:(t==null?void 0:t.left)??e.clientX,y:(t==null?void 0:t.bottom)??e.clientY})},we=(e,t)=>{var n,i;e.stopPropagation(),!(t.disabled||Ne(t))&&((n=t.onSelect)==null||n.call(t,e),(i=t.onClick)==null||i.call(t),!e.defaultPrevented&&Le&&T())},Ve=e=>{const t=()=>{const n=document.getElementById(e);n instanceof HTMLElement&&oe(n)};window.requestAnimationFrame?window.requestAnimationFrame(t):window.setTimeout(t)},Je=e=>{var y,f;if(te==null||te(e),e.defaultPrevented)return;if(!b&&(e.key==="ContextMenu"||e.shiftKey&&e.key==="F10")){e.preventDefault();const a=(y=re.current)==null?void 0:y.getBoundingClientRect();X({x:(a==null?void 0:a.left)??m,y:(a==null?void 0:a.bottom)??m});return}if(!b)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=(t==null?void 0:t.closest("[data-menu-panel]"))??S.current,i=q(n),r=t?i.indexOf(t):-1;if(e.key==="Escape"){e.preventDefault(),T();return}if(e.key==="Tab"){T();return}if(e.key==="ArrowDown"){e.preventDefault(),G(n,r+1);return}if(e.key==="ArrowUp"){e.preventDefault(),G(n,r<0?i.length-1:r-1);return}if(e.key==="Home"){e.preventDefault(),G(n,0);return}if(e.key==="End"){e.preventDefault(),G(n,i.length-1);return}if(e.key==="ArrowRight"){const a=t==null?void 0:t.dataset.menuItemPath,d=t==null?void 0:t.getAttribute("aria-controls");(t==null?void 0:t.dataset.menuHasSubmenu)==="true"&&a&&d&&(e.preventDefault(),D(a),Ve(d));return}if(e.key==="ArrowLeft"){const a=n==null?void 0:n.dataset.menuPanelPath;if(a&&a!==H){e.preventDefault();const d=en(a);D(d);const x=(f=ue.current)==null?void 0:f.querySelector(`[data-menu-item-path="${a}"][data-menu-item="true"]`);x==null||x.focus()}return}if(e.key==="Enter"||e.key===" "){const a=(t==null?void 0:t.dataset.menuItem)==="true"?t:null;if(!a||Ce(a))return;e.preventDefault(),a.click()}},ie=(e,t)=>l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:u.itemContent,children:[e.icon&&l.jsx("span",{className:u.icon,"aria-hidden":"true",children:e.icon}),e.label&&l.jsx("span",{className:u.label,children:e.label})]}),e.shortcut&&l.jsx("span",{className:u.shortcut,"aria-hidden":"true",children:e.shortcut}),t&&l.jsx("span",{className:u.submenuIndicator,"aria-hidden":"true",children:">"})]}),_e=(e,t="")=>e.map((n,i)=>{var J,ge;const r=Pe(t,i),y=n.type??"item",f=n["data-testid"]??n.testId;if(y==="separator")return l.jsx("div",{role:"separator",className:u.separator,"data-testid":f??`${N}-${r}-separator`},n.id??r);if(y==="label")return l.jsx("div",{role:"none",className:k.combineClassNames(u.sectionLabel,n.className),"data-testid":f??`${N}-${r}-label`,children:n.label},n.id??r);const a=Ne(n),d=a&&de(he,r),x=n.submenuId??`${se}-${r}-submenu`,$=n.role??"menuitem",_=(c=!0)=>{a&&!n.disabled&&D(E=>c&&E&&de(E,r)?E:r)},L=()=>_(!1),W=()=>{a||D(c=>c&&(t?de(c,t)?t:c:null))},U=()=>{if(a){_();return}W()},V=()=>{_()},g=c=>{const E=c.target,Qe=c.currentTarget.closest("[data-menu-panel]"),ke=E.closest("[data-menu-panel]"),Ze=E.closest('[data-menu-item-wrapper="true"]');ke&&ke!==Qe||Ze===c.currentTarget&&(a?L():W())},v={id:n.id,className:k.combineClassNames(u.item,n.destructive&&u.destructive,n.inset&&u.inset,a&&u.submenuTrigger,n.disabled&&u.disabled,Ae,n.className),role:$,title:n.title,"aria-label":n["aria-label"],"aria-describedby":n["aria-describedby"],"aria-current":n["aria-current"],"aria-disabled":n.disabled||void 0,"aria-checked":$==="menuitemcheckbox"||$==="menuitemradio"?n.checked:void 0,"aria-haspopup":a?"menu":void 0,"aria-expanded":a?d:void 0,"aria-controls":a?x:void 0,"data-menu-item":"true","data-menu-item-path":r,"data-menu-has-submenu":a?"true":void 0,"data-testid":f};return l.jsxs("div",{className:k.combineClassNames(u.itemWrapper,a&&u.hasSubmenu),role:"group","data-menu-item-wrapper":"true","data-menu-item-path":r,onMouseEnter:U,onMouseOver:g,onPointerEnter:U,onPointerOver:g,children:[a?l.jsx("button",{type:"button",disabled:n.disabled,...v,onMouseEnter:V,onMouseOver:L,onPointerEnter:V,onPointerOver:L,onClick:c=>{c.stopPropagation(),L()},children:ie(n,!0)}):n.href?l.jsx("a",{href:n.disabled?void 0:n.href,target:n.disabled?void 0:n.target,rel:n.rel??(n.target==="_blank"?"noopener noreferrer":void 0),...v,onClick:c=>{if(c.stopPropagation(),n.disabled){c.preventDefault();return}we(c,n)},children:ie(n,!1)}):l.jsx("button",{type:"button",disabled:n.disabled,...v,onClick:c=>we(c,n),children:ie(n,!1)}),a&&d&&l.jsx("div",{id:x,role:"menu","aria-label":n.submenuAriaLabel??(typeof n.label=="string"?n.label:void 0),className:Ye(d),"data-menu-panel":"true","data-menu-panel-path":r,"data-placement":(J=ae[r])==null?void 0:J.placement,"data-testid":f?`${f}-submenu`:`${N}-${r}-submenu`,style:(ge=ae[r])==null?void 0:ge.style,children:_e(n.items??[],r)})]},n.id??r)});return l.jsxs("div",{...C,id:De,ref:ue,className:k.combineClassNames(u.wrapper,Ee),"data-testid":N,onContextMenu:Xe,onClick:Ge,onKeyDown:Je,children:[K&&l.jsx("button",{...h,ref:z,type:(h==null?void 0:h.type)??"button",className:k.combineClassNames(u.trigger,je,h==null?void 0:h.className),"aria-haspopup":"menu","aria-expanded":b,"aria-controls":se,"data-testid":`${N}-trigger`,onClick:Ue,children:K}),p&&l.jsx("div",{ref:re,className:k.combineClassNames(u.target,Re),tabIndex:P==="manual"?void 0:0,"data-testid":`${N}-target`,children:p}),b&&l.jsx("div",{...w,id:se,ref:S,role:"menu","aria-label":be?void 0:qe,"aria-labelledby":be,"aria-describedby":We,className:Fe,"data-menu-panel":"true","data-menu-panel-path":H,"data-testid":`${N}-menu`,style:{...le==null?void 0:le.style,...w==null?void 0:w.style},children:_e(o)})]})};Se.displayName="BaseMenu";const nn={wrapper:"menu",target:"menu_target",trigger:"menu_trigger",menu:"menu_panel",item:"menu_item",itemWrapper:"menu_itemWrapper",itemContent:"menu_itemContent",icon:"menu_icon",label:"menu_label",shortcut:"menu_shortcut",separator:"menu_separator",sectionLabel:"menu_sectionLabel",hasSubmenu:"menu_hasSubmenu",submenu:"menu_submenu",submenuOpen:"menu_submenu_open",submenuTrigger:"menu_submenuTrigger",submenuIndicator:"menu_submenuIndicator",destructive:"menu_destructive",inset:"menu_inset",primary:"menu_primary",secondary:"menu_secondary",tertiary:"menu_tertiary",quaternary:"menu_quaternary",clear:"menu_clear",success:"menu_success",info:"menu_info",error:"menu_error",warning:"menu_warning",disabled:"menu_disabled",glass:"menu_glass",shadowNone:"menu_shadow-None",shadowLight:"menu_shadow-Light",shadowMedium:"menu_shadow-Medium",shadowStrong:"menu_shadow-Strong",shadowIntense:"menu_shadow-Intense",roundNone:"menu_round-None",roundSmall:"menu_round-Small",roundMedium:"menu_round-Medium",roundLarge:"menu_round-Large"},Ie=o=>l.jsx(Se,{...o,classMap:Ke.expandClassMap(nn)});Ie.displayName="Menu";exports.Menu=Ie;