@tempots/beatui 0.85.0 → 0.86.1
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/beatui.css +34 -52
- package/dist/beatui.tailwind.css +34 -52
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +1798 -1809
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +183 -196
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +93 -93
- package/dist/lexical/index.cjs.js +1 -1
- package/dist/lexical/index.es.js +1 -1
- package/dist/menu-De_-sGeb.cjs +1 -0
- package/dist/menu-Ui4lUPHM.js +373 -0
- package/dist/types/components/form/input/combobox-tags-input.d.ts +3 -3
- package/dist/{widget-customization-BngYjPvO.cjs → widget-customization-B9Oc1bG4.cjs} +1 -1
- package/dist/{widget-customization-D-Vvr4vg.js → widget-customization-Ct2eqKKR.js} +69 -73
- package/package.json +2 -2
- package/dist/menu-DMAhcoJ2.js +0 -377
- package/dist/menu-q8xJaBIb.cjs +0 -1
package/dist/menu-DMAhcoJ2.js
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import { prop as K, WithElement as H, Fragment as u, aria as c, OneOfValue as U, OnDispose as q, on as b, Value as E, attr as s, html as D, computedOf as j, dataAttr as G } from "@tempots/dom";
|
|
2
|
-
import { PopOver as J } from "@tempots/ui";
|
|
3
|
-
import { g as N } from "./timer-Rd2sKnvH.js";
|
|
4
|
-
import { u as Q, A as X } from "./use-animated-toggle-89fKlXxy.js";
|
|
5
|
-
import { s as z } from "./session-id-3KiilioY.js";
|
|
6
|
-
function Y(f) {
|
|
7
|
-
const l = { fade: !0, scale: !0 };
|
|
8
|
-
return f.startsWith("top") ? (l.slide = "down", l.transformOrigin = "bottom") : f.startsWith("bottom") ? (l.slide = "up", l.transformOrigin = "top") : f.startsWith("left") ? (l.slide = "right", l.transformOrigin = "right") : f.startsWith("right") && (l.slide = "left", l.transformOrigin = "left"), l;
|
|
9
|
-
}
|
|
10
|
-
function R(f) {
|
|
11
|
-
const {
|
|
12
|
-
content: l,
|
|
13
|
-
placement: P = "top",
|
|
14
|
-
showDelay: x = 250,
|
|
15
|
-
hideDelay: C = 500,
|
|
16
|
-
mainAxisOffset: I = 8,
|
|
17
|
-
crossAxisOffset: V = 0,
|
|
18
|
-
showOn: g = "hover-focus",
|
|
19
|
-
closable: y = !0,
|
|
20
|
-
arrow: L,
|
|
21
|
-
role: h,
|
|
22
|
-
hasPopup: S = "dialog"
|
|
23
|
-
} = f;
|
|
24
|
-
return J((w, v) => {
|
|
25
|
-
const o = Q({
|
|
26
|
-
initialStatus: "closed"
|
|
27
|
-
}), T = z("flyout"), d = K(!1);
|
|
28
|
-
let k = null, p = null, $ = !1, A;
|
|
29
|
-
function _() {
|
|
30
|
-
e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), p && (p(), p = null), k && (document.removeEventListener("keydown", k), k = null), d.set(!1), $ = !1;
|
|
31
|
-
}
|
|
32
|
-
function W() {
|
|
33
|
-
E.get(y) && (k = (i) => {
|
|
34
|
-
i.key === "Escape" && a();
|
|
35
|
-
}, document.addEventListener("keydown", k)), $ = !0, d.set(!0), w({
|
|
36
|
-
placement: P ?? "top",
|
|
37
|
-
mainAxisOffset: I,
|
|
38
|
-
crossAxisOffset: V,
|
|
39
|
-
arrow: L,
|
|
40
|
-
content: H((i) => {
|
|
41
|
-
o.setElement(i);
|
|
42
|
-
const r = typeof g == "function" ? null : E.get(g);
|
|
43
|
-
(r === "hover" || r === "hover-focus") && (i.addEventListener("mouseenter", () => t()), i.addEventListener("mouseleave", () => a())), p = N(() => {
|
|
44
|
-
o.open(), p = null;
|
|
45
|
-
});
|
|
46
|
-
const m = (M) => {
|
|
47
|
-
E.get(y) && M.key === "Escape" && (M.preventDefault(), M.stopPropagation(), a(), d.set(!1));
|
|
48
|
-
};
|
|
49
|
-
document.addEventListener("keydown", m, !0);
|
|
50
|
-
let O = null;
|
|
51
|
-
return E.get(y) && (O = (M) => {
|
|
52
|
-
const F = M.target;
|
|
53
|
-
!i.contains(F) && !A?.contains(F) && a();
|
|
54
|
-
}, document.addEventListener("click", O)), u(
|
|
55
|
-
q(() => {
|
|
56
|
-
O && (document.removeEventListener("click", O), O = null), _(), document.removeEventListener("keydown", m, !0);
|
|
57
|
-
}),
|
|
58
|
-
s.class("bc-flyout-container"),
|
|
59
|
-
X({
|
|
60
|
-
animation: E.map(P, Y),
|
|
61
|
-
status: o.status
|
|
62
|
-
}),
|
|
63
|
-
s.id(T),
|
|
64
|
-
s.tabindex(-1),
|
|
65
|
-
// Make focusable for screen readers
|
|
66
|
-
D.div(
|
|
67
|
-
s.class("bc-flyout"),
|
|
68
|
-
h ? s.role(h) : s.role("dialog"),
|
|
69
|
-
// Default to dialog role
|
|
70
|
-
l()
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
let e = null;
|
|
77
|
-
function t() {
|
|
78
|
-
if (e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), o.isOpened.value || o.isOpening.value || o.isStartOpening.value)
|
|
79
|
-
return;
|
|
80
|
-
if (o.isClosing.value || o.isStartClosing.value) {
|
|
81
|
-
o.open();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const i = E.get(x);
|
|
85
|
-
e = setTimeout(() => {
|
|
86
|
-
e = null, W();
|
|
87
|
-
}, i);
|
|
88
|
-
}
|
|
89
|
-
let n = null;
|
|
90
|
-
function a() {
|
|
91
|
-
if (e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), d.set(!1), p && (p(), p = null, $)) {
|
|
92
|
-
v(), _();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const i = E.get(C);
|
|
96
|
-
n = setTimeout(() => {
|
|
97
|
-
n = null, o.close(), o.listenOnClosed(() => {
|
|
98
|
-
v(), _();
|
|
99
|
-
});
|
|
100
|
-
}, i);
|
|
101
|
-
}
|
|
102
|
-
return H((i) => {
|
|
103
|
-
A = i;
|
|
104
|
-
const r = () => {
|
|
105
|
-
t(), d.set(!0);
|
|
106
|
-
}, m = () => {
|
|
107
|
-
a(), d.set(!1);
|
|
108
|
-
}, O = u(
|
|
109
|
-
c.expanded(d),
|
|
110
|
-
c.controls(T),
|
|
111
|
-
c.haspopup(
|
|
112
|
-
S
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
return typeof g == "function" ? u(
|
|
116
|
-
O,
|
|
117
|
-
g(r, m)
|
|
118
|
-
) : u(
|
|
119
|
-
O,
|
|
120
|
-
U(g, {
|
|
121
|
-
"hover-focus": () => u(
|
|
122
|
-
b.mouseenter(() => r()),
|
|
123
|
-
b.mouseleave(() => m()),
|
|
124
|
-
b.focus(() => r()),
|
|
125
|
-
b.blur(() => m())
|
|
126
|
-
),
|
|
127
|
-
hover: () => u(
|
|
128
|
-
b.mouseenter(() => r()),
|
|
129
|
-
b.mouseleave(() => m())
|
|
130
|
-
),
|
|
131
|
-
focus: () => u(
|
|
132
|
-
b.focus(() => r()),
|
|
133
|
-
b.blur(() => m())
|
|
134
|
-
),
|
|
135
|
-
click: () => {
|
|
136
|
-
function F() {
|
|
137
|
-
document.removeEventListener("click", B);
|
|
138
|
-
}
|
|
139
|
-
function B() {
|
|
140
|
-
F(), m();
|
|
141
|
-
}
|
|
142
|
-
return u(
|
|
143
|
-
q(F),
|
|
144
|
-
b.click(() => {
|
|
145
|
-
r(), N(() => {
|
|
146
|
-
document.addEventListener("click", B, {
|
|
147
|
-
once: !0
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
},
|
|
153
|
-
never: () => null
|
|
154
|
-
})
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function oe(f) {
|
|
160
|
-
const {
|
|
161
|
-
items: l,
|
|
162
|
-
placement: P = "bottom-start",
|
|
163
|
-
showDelay: x = 0,
|
|
164
|
-
hideDelay: C = 100,
|
|
165
|
-
mainAxisOffset: I = 4,
|
|
166
|
-
crossAxisOffset: V = 0,
|
|
167
|
-
showOn: g = "click",
|
|
168
|
-
closable: y = !0,
|
|
169
|
-
onClose: L,
|
|
170
|
-
onAction: h,
|
|
171
|
-
ariaLabel: S,
|
|
172
|
-
ariaLabelledBy: w
|
|
173
|
-
} = f, v = z("menu"), o = K(-1), T = K([]);
|
|
174
|
-
let d = null;
|
|
175
|
-
return u(
|
|
176
|
-
R({
|
|
177
|
-
content: () => H((k) => {
|
|
178
|
-
d = document.activeElement;
|
|
179
|
-
const p = (e, t, n) => {
|
|
180
|
-
if (t.length === 0) return -1;
|
|
181
|
-
let a = e + n, i = 0;
|
|
182
|
-
for (; i < t.length; ) {
|
|
183
|
-
a >= t.length && (a = 0), a < 0 && (a = t.length - 1);
|
|
184
|
-
const r = t[a];
|
|
185
|
-
if (r && r.getAttribute("aria-disabled") !== "true")
|
|
186
|
-
return a;
|
|
187
|
-
a += n, i++;
|
|
188
|
-
}
|
|
189
|
-
return e;
|
|
190
|
-
}, $ = (e) => {
|
|
191
|
-
const t = T.value, n = o.value;
|
|
192
|
-
switch (e.key) {
|
|
193
|
-
case "ArrowDown":
|
|
194
|
-
e.preventDefault(), e.stopPropagation();
|
|
195
|
-
const a = p(n, t, 1);
|
|
196
|
-
A(a, t);
|
|
197
|
-
break;
|
|
198
|
-
case "ArrowUp":
|
|
199
|
-
e.preventDefault(), e.stopPropagation();
|
|
200
|
-
const i = p(n, t, -1);
|
|
201
|
-
A(i, t);
|
|
202
|
-
break;
|
|
203
|
-
case "Enter":
|
|
204
|
-
case " ":
|
|
205
|
-
if (e.preventDefault(), e.stopPropagation(), n >= 0 && t[n]) {
|
|
206
|
-
const r = t[n];
|
|
207
|
-
if (r.getAttribute("aria-disabled") === "true")
|
|
208
|
-
return;
|
|
209
|
-
const m = r.getAttribute("data-key");
|
|
210
|
-
m && h && h(m), r.click(), L?.();
|
|
211
|
-
}
|
|
212
|
-
break;
|
|
213
|
-
case "Escape":
|
|
214
|
-
L?.();
|
|
215
|
-
break;
|
|
216
|
-
case "Home":
|
|
217
|
-
e.preventDefault(), e.stopPropagation(), t.length > 0 && A(0, t);
|
|
218
|
-
break;
|
|
219
|
-
case "End":
|
|
220
|
-
e.preventDefault(), e.stopPropagation(), t.length > 0 && A(t.length - 1, t);
|
|
221
|
-
break;
|
|
222
|
-
case "ArrowRight":
|
|
223
|
-
if (e.preventDefault(), e.stopPropagation(), n >= 0 && t[n]) {
|
|
224
|
-
const r = t[n];
|
|
225
|
-
r.classList.contains(
|
|
226
|
-
"bc-menu-item--has-submenu"
|
|
227
|
-
) && r.dispatchEvent(new Event("mouseenter"));
|
|
228
|
-
}
|
|
229
|
-
break;
|
|
230
|
-
case "ArrowLeft":
|
|
231
|
-
e.preventDefault(), e.stopPropagation(), L?.();
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}, A = (e, t) => {
|
|
235
|
-
o.value >= 0 && t[o.value] && (t[o.value].classList.remove(
|
|
236
|
-
"bc-menu-item--focused"
|
|
237
|
-
), t[o.value].removeAttribute("aria-selected")), e >= 0 && t[e] && (t[e].classList.add("bc-menu-item--focused"), t[e].setAttribute("aria-selected", "true"), o.set(e), typeof t[e].scrollIntoView == "function" && t[e].scrollIntoView({ block: "nearest" }));
|
|
238
|
-
}, _ = () => {
|
|
239
|
-
const e = Array.from(
|
|
240
|
-
k.querySelectorAll('[role="menuitem"]')
|
|
241
|
-
);
|
|
242
|
-
if (T.set(e), e.length > 0) {
|
|
243
|
-
const t = e.findIndex(
|
|
244
|
-
(n) => n.getAttribute("aria-disabled") !== "true"
|
|
245
|
-
);
|
|
246
|
-
t >= 0 && A(t, e);
|
|
247
|
-
}
|
|
248
|
-
}, W = new MutationObserver(_);
|
|
249
|
-
return W.observe(k, { childList: !0, subtree: !0 }), setTimeout(() => {
|
|
250
|
-
_(), k.focus();
|
|
251
|
-
}, 0), document.addEventListener("keydown", $, !0), u(
|
|
252
|
-
q(() => {
|
|
253
|
-
W.disconnect(), document.removeEventListener("keydown", $, !0), d && d.focus();
|
|
254
|
-
}),
|
|
255
|
-
s.class("bc-menu"),
|
|
256
|
-
s.id(v),
|
|
257
|
-
s.role("menu"),
|
|
258
|
-
s.tabindex(-1),
|
|
259
|
-
c.orientation("vertical"),
|
|
260
|
-
S ? c.label(S) : u(),
|
|
261
|
-
w ? c.labelledby(w) : u(),
|
|
262
|
-
c.activedescendant(
|
|
263
|
-
o.map((e) => {
|
|
264
|
-
const t = T.value;
|
|
265
|
-
return e >= 0 && t[e] ? t[e].id || `${v}-item-${e}` : "";
|
|
266
|
-
})
|
|
267
|
-
),
|
|
268
|
-
b.click((e) => {
|
|
269
|
-
const n = e.target.closest(
|
|
270
|
-
'[role="menuitem"]'
|
|
271
|
-
);
|
|
272
|
-
if (n && n.getAttribute("aria-disabled") !== "true") {
|
|
273
|
-
const a = n.getAttribute("data-key");
|
|
274
|
-
a && h && h(a);
|
|
275
|
-
}
|
|
276
|
-
}),
|
|
277
|
-
// Live region for screen reader announcements
|
|
278
|
-
D.div(
|
|
279
|
-
s.class("sr-only"),
|
|
280
|
-
c.live("polite"),
|
|
281
|
-
c.atomic(!0),
|
|
282
|
-
o.map((e) => {
|
|
283
|
-
const t = T.value;
|
|
284
|
-
if (e >= 0 && t[e]) {
|
|
285
|
-
const n = t[e].textContent || "";
|
|
286
|
-
return t[e].getAttribute("aria-disabled") === "true" ? `${n}, disabled` : `${n}, ${e + 1} of ${t.length}`;
|
|
287
|
-
}
|
|
288
|
-
return "";
|
|
289
|
-
})
|
|
290
|
-
),
|
|
291
|
-
...l()
|
|
292
|
-
);
|
|
293
|
-
}),
|
|
294
|
-
placement: P,
|
|
295
|
-
showDelay: x,
|
|
296
|
-
hideDelay: C,
|
|
297
|
-
mainAxisOffset: I,
|
|
298
|
-
crossAxisOffset: V,
|
|
299
|
-
showOn: g,
|
|
300
|
-
closable: y,
|
|
301
|
-
role: "menu"
|
|
302
|
-
})
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
function ae(f) {
|
|
306
|
-
const {
|
|
307
|
-
key: l,
|
|
308
|
-
content: P,
|
|
309
|
-
startContent: x,
|
|
310
|
-
endContent: C,
|
|
311
|
-
disabled: I = !1,
|
|
312
|
-
onClick: V,
|
|
313
|
-
ariaLabel: g,
|
|
314
|
-
submenu: y,
|
|
315
|
-
submenuPlacement: L = "right-start"
|
|
316
|
-
} = f, h = l ?? z("menu-item"), S = `menu-item-${h}`, w = y != null;
|
|
317
|
-
return D.div(
|
|
318
|
-
s.class(
|
|
319
|
-
j(I)(
|
|
320
|
-
(v) => `bc-menu-item ${v ? "bc-menu-item--disabled" : ""} ${w ? "bc-menu-item--has-submenu" : ""}`
|
|
321
|
-
)
|
|
322
|
-
),
|
|
323
|
-
s.id(S),
|
|
324
|
-
s.role("menuitem"),
|
|
325
|
-
s.tabindex(-1),
|
|
326
|
-
G.key(h),
|
|
327
|
-
c.disabled(I),
|
|
328
|
-
c.selected(!1),
|
|
329
|
-
// Will be updated by focus management
|
|
330
|
-
w ? c.expanded(!1) : u(),
|
|
331
|
-
g ? c.label(g) : u(),
|
|
332
|
-
b.click((v) => {
|
|
333
|
-
if (E.get(I)) {
|
|
334
|
-
v.preventDefault(), v.stopPropagation();
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
V?.();
|
|
338
|
-
}),
|
|
339
|
-
// Start content
|
|
340
|
-
x && D.span(s.class("bc-menu-item__start"), x),
|
|
341
|
-
// Main content
|
|
342
|
-
D.span(s.class("bc-menu-item__content"), P),
|
|
343
|
-
// End content
|
|
344
|
-
C && D.span(s.class("bc-menu-item__end"), C),
|
|
345
|
-
// Submenu (if present)
|
|
346
|
-
w && y ? R({
|
|
347
|
-
content: () => u(
|
|
348
|
-
s.class("bc-menu bc-submenu"),
|
|
349
|
-
s.role("menu"),
|
|
350
|
-
...y()
|
|
351
|
-
),
|
|
352
|
-
placement: L,
|
|
353
|
-
showOn: "hover",
|
|
354
|
-
hasPopup: "menu",
|
|
355
|
-
showDelay: 100,
|
|
356
|
-
hideDelay: 300,
|
|
357
|
-
mainAxisOffset: 0,
|
|
358
|
-
crossAxisOffset: 0,
|
|
359
|
-
role: "menu"
|
|
360
|
-
}) : u()
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
function re(f = {}) {
|
|
364
|
-
const { label: l } = f;
|
|
365
|
-
return D.div(
|
|
366
|
-
s.class("bc-menu-separator"),
|
|
367
|
-
s.role("separator"),
|
|
368
|
-
c.orientation("horizontal"),
|
|
369
|
-
l && D.span(s.class("bc-menu-separator__label"), l)
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
export {
|
|
373
|
-
R as F,
|
|
374
|
-
oe as M,
|
|
375
|
-
re as a,
|
|
376
|
-
ae as b
|
|
377
|
-
};
|
package/dist/menu-q8xJaBIb.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("@tempots/dom"),q=require("@tempots/ui"),_=require("./timer-BJHOsuS6.cjs"),W=require("./use-animated-toggle-DrqK7nUS.cjs"),S=require("./session-id-B5lJMzbB.cjs");function K(c){const l={fade:!0,scale:!0};return c.startsWith("top")?(l.slide="down",l.transformOrigin="bottom"):c.startsWith("bottom")?(l.slide="up",l.transformOrigin="top"):c.startsWith("left")?(l.slide="right",l.transformOrigin="right"):c.startsWith("right")&&(l.slide="left",l.transformOrigin="left"),l}function M(c){const{content:l,placement:I="top",showDelay:D=250,hideDelay:F=500,mainAxisOffset:w=8,crossAxisOffset:V=0,showOn:f="hover-focus",closable:b=!0,arrow:O,role:p,hasPopup:L="dialog"}=c;return q.PopOver((v,g)=>{const r=W.useAnimatedElementToggle({initialStatus:"closed"}),A=S.sessionId("flyout"),m=e.prop(!1);let h=null,d=null,T=!1,y;function P(){t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),d&&(d(),d=null),h&&(document.removeEventListener("keydown",h),h=null),m.set(!1),T=!1}function x(){e.Value.get(b)&&(h=i=>{i.key==="Escape"&&s()},document.addEventListener("keydown",h)),T=!0,m.set(!0),v({placement:I??"top",mainAxisOffset:w,crossAxisOffset:V,arrow:O,content:e.WithElement(i=>{r.setElement(i);const o=typeof f=="function"?null:e.Value.get(f);(o==="hover"||o==="hover-focus")&&(i.addEventListener("mouseenter",()=>n()),i.addEventListener("mouseleave",()=>s())),d=_.g(()=>{r.open(),d=null});const u=E=>{e.Value.get(b)&&E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),s(),m.set(!1))};document.addEventListener("keydown",u,!0);let k=null;return e.Value.get(b)&&(k=E=>{const C=E.target;!i.contains(C)&&!y?.contains(C)&&s()},document.addEventListener("click",k)),e.Fragment(e.OnDispose(()=>{k&&(document.removeEventListener("click",k),k=null),P(),document.removeEventListener("keydown",u,!0)}),e.attr.class("bc-flyout-container"),W.AnimatedToggleClass({animation:e.Value.map(I,K),status:r.status}),e.attr.id(A),e.attr.tabindex(-1),e.html.div(e.attr.class("bc-flyout"),p?e.attr.role(p):e.attr.role("dialog"),l()))})})}let t=null;function n(){if(t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),r.isOpened.value||r.isOpening.value||r.isStartOpening.value)return;if(r.isClosing.value||r.isStartClosing.value){r.open();return}const i=e.Value.get(D);t=setTimeout(()=>{t=null,x()},i)}let a=null;function s(){if(t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),m.set(!1),d&&(d(),d=null,T)){g(),P();return}const i=e.Value.get(F);a=setTimeout(()=>{a=null,r.close(),r.listenOnClosed(()=>{g(),P()})},i)}return e.WithElement(i=>{y=i;const o=()=>{n(),m.set(!0)},u=()=>{s(),m.set(!1)},k=e.Fragment(e.aria.expanded(m),e.aria.controls(A),e.aria.haspopup(L));if(typeof f=="function")return e.Fragment(k,f(o,u));const E=f;return e.Fragment(k,e.OneOfValue(E,{"hover-focus":()=>e.Fragment(e.on.mouseenter(()=>o()),e.on.mouseleave(()=>u()),e.on.focus(()=>o()),e.on.blur(()=>u())),hover:()=>e.Fragment(e.on.mouseenter(()=>o()),e.on.mouseleave(()=>u())),focus:()=>e.Fragment(e.on.focus(()=>o()),e.on.blur(()=>u())),click:()=>{function C(){document.removeEventListener("click",$)}function $(){C(),u()}return e.Fragment(e.OnDispose(C),e.on.click(()=>{o(),_.g(()=>{document.addEventListener("click",$,{once:!0})})}))},never:()=>null}))})})}function H(c){const{items:l,placement:I="bottom-start",showDelay:D=0,hideDelay:F=100,mainAxisOffset:w=4,crossAxisOffset:V=0,showOn:f="click",closable:b=!0,onClose:O,onAction:p,ariaLabel:L,ariaLabelledBy:v}=c,g=S.sessionId("menu"),r=e.prop(-1),A=e.prop([]);let m=null;return e.Fragment(M({content:()=>e.WithElement(h=>{m=document.activeElement;const d=(t,n,a)=>{if(n.length===0)return-1;let s=t+a,i=0;for(;i<n.length;){s>=n.length&&(s=0),s<0&&(s=n.length-1);const o=n[s];if(o&&o.getAttribute("aria-disabled")!=="true")return s;s+=a,i++}return t},T=t=>{const n=A.value,a=r.value;switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation();const s=d(a,n,1);y(s,n);break;case"ArrowUp":t.preventDefault(),t.stopPropagation();const i=d(a,n,-1);y(i,n);break;case"Enter":case" ":if(t.preventDefault(),t.stopPropagation(),a>=0&&n[a]){const o=n[a];if(o.getAttribute("aria-disabled")==="true")return;const u=o.getAttribute("data-key");u&&p&&p(u),o.click(),O?.()}break;case"Escape":O?.();break;case"Home":t.preventDefault(),t.stopPropagation(),n.length>0&&y(0,n);break;case"End":t.preventDefault(),t.stopPropagation(),n.length>0&&y(n.length-1,n);break;case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),a>=0&&n[a]){const o=n[a];o.classList.contains("bc-menu-item--has-submenu")&&o.dispatchEvent(new Event("mouseenter"))}break;case"ArrowLeft":t.preventDefault(),t.stopPropagation(),O?.();break}},y=(t,n)=>{r.value>=0&&n[r.value]&&(n[r.value].classList.remove("bc-menu-item--focused"),n[r.value].removeAttribute("aria-selected")),t>=0&&n[t]&&(n[t].classList.add("bc-menu-item--focused"),n[t].setAttribute("aria-selected","true"),r.set(t),typeof n[t].scrollIntoView=="function"&&n[t].scrollIntoView({block:"nearest"}))},P=()=>{const t=Array.from(h.querySelectorAll('[role="menuitem"]'));if(A.set(t),t.length>0){const n=t.findIndex(a=>a.getAttribute("aria-disabled")!=="true");n>=0&&y(n,t)}},x=new MutationObserver(P);return x.observe(h,{childList:!0,subtree:!0}),setTimeout(()=>{P(),h.focus()},0),document.addEventListener("keydown",T,!0),e.Fragment(e.OnDispose(()=>{x.disconnect(),document.removeEventListener("keydown",T,!0),m&&m.focus()}),e.attr.class("bc-menu"),e.attr.id(g),e.attr.role("menu"),e.attr.tabindex(-1),e.aria.orientation("vertical"),L?e.aria.label(L):e.Fragment(),v?e.aria.labelledby(v):e.Fragment(),e.aria.activedescendant(r.map(t=>{const n=A.value;return t>=0&&n[t]?n[t].id||`${g}-item-${t}`:""})),e.on.click(t=>{const a=t.target.closest('[role="menuitem"]');if(a&&a.getAttribute("aria-disabled")!=="true"){const s=a.getAttribute("data-key");s&&p&&p(s)}}),e.html.div(e.attr.class("sr-only"),e.aria.live("polite"),e.aria.atomic(!0),r.map(t=>{const n=A.value;if(t>=0&&n[t]){const a=n[t].textContent||"";return n[t].getAttribute("aria-disabled")==="true"?`${a}, disabled`:`${a}, ${t+1} of ${n.length}`}return""})),...l())}),placement:I,showDelay:D,hideDelay:F,mainAxisOffset:w,crossAxisOffset:V,showOn:f,closable:b,role:"menu"}))}function z(c){const{key:l,content:I,startContent:D,endContent:F,disabled:w=!1,onClick:V,ariaLabel:f,submenu:b,submenuPlacement:O="right-start"}=c,p=l??S.sessionId("menu-item"),L=`menu-item-${p}`,v=b!=null;return e.html.div(e.attr.class(e.computedOf(w)(g=>`bc-menu-item ${g?"bc-menu-item--disabled":""} ${v?"bc-menu-item--has-submenu":""}`)),e.attr.id(L),e.attr.role("menuitem"),e.attr.tabindex(-1),e.dataAttr.key(p),e.aria.disabled(w),e.aria.selected(!1),v?e.aria.expanded(!1):e.Fragment(),f?e.aria.label(f):e.Fragment(),e.on.click(g=>{if(e.Value.get(w)){g.preventDefault(),g.stopPropagation();return}V?.()}),D&&e.html.span(e.attr.class("bc-menu-item__start"),D),e.html.span(e.attr.class("bc-menu-item__content"),I),F&&e.html.span(e.attr.class("bc-menu-item__end"),F),v&&b?M({content:()=>e.Fragment(e.attr.class("bc-menu bc-submenu"),e.attr.role("menu"),...b()),placement:O,showOn:"hover",hasPopup:"menu",showDelay:100,hideDelay:300,mainAxisOffset:0,crossAxisOffset:0,role:"menu"}):e.Fragment())}function B(c={}){const{label:l}=c;return e.html.div(e.attr.class("bc-menu-separator"),e.attr.role("separator"),e.aria.orientation("horizontal"),l&&e.html.span(e.attr.class("bc-menu-separator__label"),l))}exports.Flyout=M;exports.Menu=H;exports.MenuItem=z;exports.MenuSeparator=B;
|