asterui 0.12.74 → 0.12.76
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,87 +1,96 @@
|
|
|
1
|
-
import { jsx as i, jsxs as K, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { useConfig as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
1
|
+
import { jsx as i, jsxs as K, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import u, { forwardRef as xe, useId as X, useState as j, useRef as L, useImperativeHandle as ve, useCallback as O, useEffect as V, createContext as Ee, useContext as Me } from "react";
|
|
3
|
+
import { useConfig as Ae } from "../providers/ConfigProvider.js";
|
|
4
|
+
const Te = "dropdown", Re = "dropdown-top", Se = "dropdown-bottom", Ke = "dropdown-left", Le = "dropdown-right", Ne = "dropdown-center", Pe = "dropdown-end", Oe = "dropdown-hover", $e = "dropdown-open", je = "dropdown-content", ne = "menu", oe = Ee(void 0);
|
|
5
|
+
function Z() {
|
|
6
|
+
const p = Me(oe);
|
|
7
|
+
if (!p)
|
|
8
8
|
throw new Error("Dropdown compound components must be used within Dropdown");
|
|
9
|
-
return
|
|
9
|
+
return p;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const Be = xe(function({
|
|
12
12
|
children: c,
|
|
13
|
-
|
|
14
|
-
trigger:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
open:
|
|
18
|
-
onOpenChange:
|
|
19
|
-
disabled:
|
|
13
|
+
menu: f,
|
|
14
|
+
trigger: m = ["hover"],
|
|
15
|
+
placement: y = "bottomLeft",
|
|
16
|
+
autoAdjustOverflow: l = !0,
|
|
17
|
+
open: r,
|
|
18
|
+
onOpenChange: o,
|
|
19
|
+
disabled: d,
|
|
20
20
|
arrow: w = !1,
|
|
21
|
-
mouseEnterDelay:
|
|
22
|
-
mouseLeaveDelay:
|
|
23
|
-
getPopupContainer:
|
|
24
|
-
destroyOnHidden:
|
|
25
|
-
popupRender:
|
|
26
|
-
"data-testid":
|
|
27
|
-
className:
|
|
21
|
+
mouseEnterDelay: g = 0.15,
|
|
22
|
+
mouseLeaveDelay: h = 0.1,
|
|
23
|
+
getPopupContainer: I,
|
|
24
|
+
destroyOnHidden: n = !1,
|
|
25
|
+
popupRender: v,
|
|
26
|
+
"data-testid": E,
|
|
27
|
+
className: C = "",
|
|
28
28
|
...F
|
|
29
|
-
},
|
|
30
|
-
const { componentDisabled:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
}, s) {
|
|
30
|
+
const { componentDisabled: t } = Ae(), b = d ?? t ?? !1, k = {
|
|
31
|
+
top: { position: "top", align: "center" },
|
|
32
|
+
topLeft: { position: "top", align: "start" },
|
|
33
|
+
topRight: { position: "top", align: "end" },
|
|
34
|
+
bottom: { position: "bottom", align: "center" },
|
|
35
|
+
bottomLeft: { position: "bottom", align: "start" },
|
|
36
|
+
bottomRight: { position: "bottom", align: "end" },
|
|
37
|
+
left: { position: "left", align: "start" },
|
|
38
|
+
right: { position: "right", align: "start" }
|
|
39
|
+
}, { position: M, align: N } = k[y], se = X(), G = X(), [ae, ie] = j(!1), [le, q] = j(-1), [ce, de] = j(0), [ue, ee] = j(!n), te = L(/* @__PURE__ */ new Map()), z = L(null), A = L(null), R = m;
|
|
40
|
+
ve(s, () => z.current, []);
|
|
41
|
+
const pe = (e) => E ? `${E}-${e}` : void 0, H = r !== void 0, S = H ? r : ae, x = O((e, D = "trigger") => {
|
|
42
|
+
b || (H || ie(e), e && ee(!0), o?.(e, { source: D }));
|
|
43
|
+
}, [b, H, o]), fe = O(() => {
|
|
44
|
+
x(!1, "menu"), q(-1), document.getElementById(G)?.focus();
|
|
45
|
+
}, [x, G]), me = O((e, D, a) => {
|
|
46
|
+
D ? te.current.set(e, { ref: D, disabled: a }) : te.current.delete(e);
|
|
38
47
|
}, []);
|
|
39
48
|
V(() => {
|
|
40
|
-
if (
|
|
41
|
-
const e = setTimeout(() =>
|
|
49
|
+
if (n && !S) {
|
|
50
|
+
const e = setTimeout(() => ee(!1), 300);
|
|
42
51
|
return () => clearTimeout(e);
|
|
43
52
|
}
|
|
44
|
-
}, [S,
|
|
53
|
+
}, [S, n]), V(() => {
|
|
45
54
|
const e = (D) => {
|
|
46
|
-
z.current && !z.current.contains(D.target) && (
|
|
55
|
+
z.current && !z.current.contains(D.target) && (x(!1, "trigger"), q(-1));
|
|
47
56
|
};
|
|
48
57
|
if (S)
|
|
49
58
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
50
|
-
}, [S,
|
|
51
|
-
const
|
|
52
|
-
R.includes("hover") && (
|
|
53
|
-
|
|
59
|
+
}, [S, x]);
|
|
60
|
+
const be = O(() => {
|
|
61
|
+
R.includes("hover") && (A.current && clearTimeout(A.current), A.current = setTimeout(() => {
|
|
62
|
+
x(!0, "trigger");
|
|
63
|
+
}, g * 1e3));
|
|
64
|
+
}, [R, g, x]), we = O(() => {
|
|
65
|
+
R.includes("hover") && (A.current && clearTimeout(A.current), A.current = setTimeout(() => {
|
|
66
|
+
x(!1, "trigger"), q(-1);
|
|
54
67
|
}, h * 1e3));
|
|
55
|
-
}, [R, h,
|
|
56
|
-
R.includes("
|
|
57
|
-
|
|
58
|
-
}, I * 1e3));
|
|
59
|
-
}, [R, I, k]), me = $((e) => {
|
|
60
|
-
R.includes("contextMenu") && (e.preventDefault(), k(!0, "trigger"));
|
|
61
|
-
}, [R, k]);
|
|
68
|
+
}, [R, h, x]), ge = O((e) => {
|
|
69
|
+
R.includes("contextMenu") && (e.preventDefault(), x(!0, "trigger"));
|
|
70
|
+
}, [R, x]);
|
|
62
71
|
V(() => () => {
|
|
63
|
-
|
|
72
|
+
A.current && clearTimeout(A.current);
|
|
64
73
|
}, []);
|
|
65
|
-
const
|
|
66
|
-
top:
|
|
67
|
-
bottom:
|
|
68
|
-
left:
|
|
69
|
-
right:
|
|
70
|
-
},
|
|
74
|
+
const he = {
|
|
75
|
+
top: Re,
|
|
76
|
+
bottom: Se,
|
|
77
|
+
left: Ke,
|
|
78
|
+
right: Le
|
|
79
|
+
}, De = {
|
|
71
80
|
start: "",
|
|
72
|
-
center:
|
|
73
|
-
end:
|
|
74
|
-
},
|
|
81
|
+
center: Ne,
|
|
82
|
+
end: Pe
|
|
83
|
+
}, ye = typeof w == "boolean" ? w : !!w, W = f ? (ue || !n) && /* @__PURE__ */ i(Y, { children: f?.items ? f.items.map((e, D) => {
|
|
75
84
|
if ("type" in e && e.type === "divider")
|
|
76
85
|
return /* @__PURE__ */ i(re, {}, e.key || `divider-${D}`);
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
|
|
86
|
+
const a = e;
|
|
87
|
+
return a.children && a.children.length > 0 ? /* @__PURE__ */ i(
|
|
88
|
+
_,
|
|
80
89
|
{
|
|
81
|
-
title:
|
|
82
|
-
icon:
|
|
83
|
-
disabled:
|
|
84
|
-
children:
|
|
90
|
+
title: a.label,
|
|
91
|
+
icon: a.icon,
|
|
92
|
+
disabled: a.disabled,
|
|
93
|
+
children: a.children.map((P) => /* @__PURE__ */ i(
|
|
85
94
|
U,
|
|
86
95
|
{
|
|
87
96
|
icon: P.icon,
|
|
@@ -93,174 +102,175 @@ const Le = Ie(function({
|
|
|
93
102
|
P.key
|
|
94
103
|
))
|
|
95
104
|
},
|
|
96
|
-
|
|
105
|
+
a.key
|
|
97
106
|
) : /* @__PURE__ */ i(
|
|
98
107
|
U,
|
|
99
108
|
{
|
|
100
|
-
icon:
|
|
101
|
-
disabled:
|
|
102
|
-
danger:
|
|
103
|
-
onClick:
|
|
104
|
-
children:
|
|
109
|
+
icon: a.icon,
|
|
110
|
+
disabled: a.disabled,
|
|
111
|
+
danger: a.danger,
|
|
112
|
+
onClick: a.onClick,
|
|
113
|
+
children: a.label
|
|
105
114
|
},
|
|
106
|
-
|
|
115
|
+
a.key
|
|
107
116
|
);
|
|
108
|
-
}) : null }) : null,
|
|
109
|
-
(e) =>
|
|
110
|
-
),
|
|
111
|
-
(e) =>
|
|
117
|
+
}) : null }) : null, T = u.Children.toArray(c), Ie = T.some(
|
|
118
|
+
(e) => u.isValidElement(e) && e.type === B
|
|
119
|
+
), Ce = T.some(
|
|
120
|
+
(e) => u.isValidElement(e) && e.type === Y
|
|
112
121
|
);
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
115
|
-
const e =
|
|
116
|
-
(D) =>
|
|
122
|
+
let $, J = !1;
|
|
123
|
+
if (f) {
|
|
124
|
+
const e = T.find(
|
|
125
|
+
(D) => u.isValidElement(D) && D.type === B
|
|
117
126
|
);
|
|
118
|
-
!e &&
|
|
119
|
-
/* @__PURE__ */ i(
|
|
120
|
-
|
|
121
|
-
] })) :
|
|
127
|
+
!e && T[0] && u.isValidElement(T[0]) ? (J = !0, $ = /* @__PURE__ */ K(Q, { children: [
|
|
128
|
+
/* @__PURE__ */ i(B, { className: C, children: T[0] }),
|
|
129
|
+
v ? v(W) : W
|
|
130
|
+
] })) : $ = /* @__PURE__ */ K(Q, { children: [
|
|
122
131
|
e,
|
|
123
|
-
|
|
132
|
+
v ? v(W) : W
|
|
124
133
|
] });
|
|
125
|
-
} else if (!
|
|
126
|
-
const [e, D, ...
|
|
127
|
-
|
|
128
|
-
e &&
|
|
134
|
+
} else if (!Ie && !Ce && T.length >= 2) {
|
|
135
|
+
const [e, D, ...a] = T;
|
|
136
|
+
J = !0, $ = /* @__PURE__ */ K(Q, { children: [
|
|
137
|
+
e && u.isValidElement(e) && /* @__PURE__ */ i(B, { className: C, children: e }),
|
|
129
138
|
D,
|
|
130
|
-
|
|
139
|
+
a
|
|
131
140
|
] });
|
|
132
141
|
} else
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
R.includes("hover") &&
|
|
139
|
-
S &&
|
|
140
|
-
!
|
|
142
|
+
$ = c;
|
|
143
|
+
const ke = [
|
|
144
|
+
Te,
|
|
145
|
+
he[M],
|
|
146
|
+
De[N],
|
|
147
|
+
R.includes("hover") && Oe,
|
|
148
|
+
S && $e,
|
|
149
|
+
!J && C
|
|
141
150
|
].filter(Boolean).join(" ");
|
|
142
151
|
return /* @__PURE__ */ i(
|
|
143
|
-
|
|
152
|
+
oe.Provider,
|
|
144
153
|
{
|
|
145
154
|
value: {
|
|
146
|
-
position:
|
|
147
|
-
align:
|
|
148
|
-
menuId:
|
|
149
|
-
triggerId:
|
|
155
|
+
position: M,
|
|
156
|
+
align: N,
|
|
157
|
+
menuId: se,
|
|
158
|
+
triggerId: G,
|
|
150
159
|
isOpen: S,
|
|
151
|
-
setIsOpen:
|
|
152
|
-
focusedIndex:
|
|
160
|
+
setIsOpen: x,
|
|
161
|
+
focusedIndex: le,
|
|
153
162
|
setFocusedIndex: q,
|
|
154
|
-
registerItem:
|
|
155
|
-
itemCount:
|
|
156
|
-
setItemCount:
|
|
157
|
-
disabled:
|
|
158
|
-
arrow:
|
|
159
|
-
closeDropdown:
|
|
160
|
-
getTestId:
|
|
163
|
+
registerItem: me,
|
|
164
|
+
itemCount: ce,
|
|
165
|
+
setItemCount: de,
|
|
166
|
+
disabled: b,
|
|
167
|
+
arrow: ye,
|
|
168
|
+
closeDropdown: fe,
|
|
169
|
+
getTestId: pe,
|
|
170
|
+
menuOnClick: f?.onClick
|
|
161
171
|
},
|
|
162
172
|
children: /* @__PURE__ */ i(
|
|
163
173
|
"div",
|
|
164
174
|
{
|
|
165
175
|
ref: z,
|
|
166
|
-
className:
|
|
176
|
+
className: ke,
|
|
167
177
|
"data-state": S ? "open" : "closed",
|
|
168
|
-
"data-testid":
|
|
169
|
-
"aria-disabled":
|
|
170
|
-
onMouseEnter:
|
|
171
|
-
onMouseLeave:
|
|
172
|
-
onContextMenu:
|
|
178
|
+
"data-testid": E,
|
|
179
|
+
"aria-disabled": b || void 0,
|
|
180
|
+
onMouseEnter: be,
|
|
181
|
+
onMouseLeave: we,
|
|
182
|
+
onContextMenu: ge,
|
|
173
183
|
...F,
|
|
174
|
-
children:
|
|
184
|
+
children: $
|
|
175
185
|
}
|
|
176
186
|
)
|
|
177
187
|
}
|
|
178
188
|
);
|
|
179
189
|
});
|
|
180
|
-
function
|
|
181
|
-
const { menuId:
|
|
182
|
-
switch (
|
|
190
|
+
function B({ children: p, className: c = "" }) {
|
|
191
|
+
const { menuId: f, triggerId: m, isOpen: y, setIsOpen: l, setFocusedIndex: r, itemCount: o, disabled: d } = Z(), w = (n) => {
|
|
192
|
+
switch (n.key) {
|
|
183
193
|
case "Enter":
|
|
184
194
|
case " ":
|
|
185
195
|
case "ArrowDown":
|
|
186
|
-
|
|
196
|
+
n.preventDefault(), l(!0), r(0);
|
|
187
197
|
break;
|
|
188
198
|
case "ArrowUp":
|
|
189
|
-
|
|
199
|
+
n.preventDefault(), l(!0), r(o - 1);
|
|
190
200
|
break;
|
|
191
201
|
case "Escape":
|
|
192
|
-
|
|
202
|
+
n.preventDefault(), l(!1), r(-1);
|
|
193
203
|
break;
|
|
194
204
|
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
return
|
|
199
|
-
id:
|
|
200
|
-
tabIndex:
|
|
205
|
+
}, g = () => {
|
|
206
|
+
l(!y), y || r(0);
|
|
207
|
+
}, h = u.Children.only(p), I = h.props;
|
|
208
|
+
return u.cloneElement(h, {
|
|
209
|
+
id: m,
|
|
210
|
+
tabIndex: d ? -1 : 0,
|
|
201
211
|
"aria-haspopup": "menu",
|
|
202
|
-
"aria-expanded":
|
|
203
|
-
"aria-controls":
|
|
204
|
-
onClick: (
|
|
205
|
-
|
|
212
|
+
"aria-expanded": y,
|
|
213
|
+
"aria-controls": f,
|
|
214
|
+
onClick: (n) => {
|
|
215
|
+
g(), I.onClick?.(n);
|
|
206
216
|
},
|
|
207
|
-
onKeyDown: (
|
|
208
|
-
w(
|
|
217
|
+
onKeyDown: (n) => {
|
|
218
|
+
w(n), I.onKeyDown?.(n);
|
|
209
219
|
},
|
|
210
|
-
className: `${
|
|
220
|
+
className: `${I.className || ""} ${c}`.trim()
|
|
211
221
|
});
|
|
212
222
|
}
|
|
213
|
-
function
|
|
214
|
-
const { menuId:
|
|
215
|
-
(
|
|
223
|
+
function Y({ children: p, className: c = "" }) {
|
|
224
|
+
const { menuId: f, triggerId: m, isOpen: y, setIsOpen: l, focusedIndex: r, setFocusedIndex: o, setItemCount: d, arrow: w, position: g, getTestId: h } = Z(), I = L(null), n = u.Children.toArray(p).filter(
|
|
225
|
+
(t) => u.isValidElement(t) && t.type === U
|
|
216
226
|
);
|
|
217
227
|
V(() => {
|
|
218
|
-
|
|
219
|
-
}, [
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
(
|
|
228
|
+
d(n.length);
|
|
229
|
+
}, [n.length, d]), V(() => {
|
|
230
|
+
y && r >= 0 && I.current && I.current.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')[r]?.focus();
|
|
231
|
+
}, [y, r]);
|
|
232
|
+
const v = (t) => {
|
|
233
|
+
const k = n.filter(
|
|
234
|
+
(M) => u.isValidElement(M) && !M.props.disabled
|
|
225
235
|
).length;
|
|
226
|
-
switch (
|
|
236
|
+
switch (t.key) {
|
|
227
237
|
case "ArrowDown":
|
|
228
|
-
|
|
238
|
+
t.preventDefault(), o((r + 1) % k);
|
|
229
239
|
break;
|
|
230
240
|
case "ArrowUp":
|
|
231
|
-
|
|
241
|
+
t.preventDefault(), o((r - 1 + k) % k);
|
|
232
242
|
break;
|
|
233
243
|
case "Home":
|
|
234
|
-
|
|
244
|
+
t.preventDefault(), o(0);
|
|
235
245
|
break;
|
|
236
246
|
case "End":
|
|
237
|
-
|
|
247
|
+
t.preventDefault(), o(k - 1);
|
|
238
248
|
break;
|
|
239
249
|
case "Escape":
|
|
240
|
-
|
|
250
|
+
t.preventDefault(), l(!1), o(-1), document.getElementById(m)?.focus();
|
|
241
251
|
break;
|
|
242
252
|
case "Tab":
|
|
243
|
-
|
|
253
|
+
l(!1), o(-1);
|
|
244
254
|
break;
|
|
245
255
|
}
|
|
246
|
-
},
|
|
247
|
-
|
|
256
|
+
}, E = [
|
|
257
|
+
je,
|
|
248
258
|
ne,
|
|
249
259
|
"bg-base-100",
|
|
250
260
|
"rounded-box",
|
|
251
261
|
"z-50",
|
|
252
262
|
"shadow",
|
|
253
263
|
c
|
|
254
|
-
].filter(Boolean).join(" "),
|
|
255
|
-
if (
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
return
|
|
259
|
-
if (
|
|
260
|
-
return
|
|
264
|
+
].filter(Boolean).join(" "), C = u.Children.map(p, (t, b) => {
|
|
265
|
+
if (u.isValidElement(t)) {
|
|
266
|
+
const k = t.key != null ? String(t.key) : void 0;
|
|
267
|
+
if (t.type === U)
|
|
268
|
+
return u.cloneElement(t, { _index: b, _key: k });
|
|
269
|
+
if (t.type === _)
|
|
270
|
+
return u.cloneElement(t, { _key: k });
|
|
261
271
|
}
|
|
262
|
-
return
|
|
263
|
-
}),
|
|
272
|
+
return t;
|
|
273
|
+
}), s = w ? /* @__PURE__ */ i(
|
|
264
274
|
"span",
|
|
265
275
|
{
|
|
266
276
|
className: `absolute w-0 h-0 border-8 border-solid ${{
|
|
@@ -268,53 +278,53 @@ function Q({ children: u, className: c = "" }) {
|
|
|
268
278
|
bottom: "top-0 left-1/2 -translate-x-1/2 -translate-y-full border-b-base-100 border-l-transparent border-r-transparent border-t-transparent",
|
|
269
279
|
left: "right-0 top-1/2 -translate-y-1/2 translate-x-full border-l-base-100 border-t-transparent border-b-transparent border-r-transparent",
|
|
270
280
|
right: "left-0 top-1/2 -translate-y-1/2 -translate-x-full border-r-base-100 border-t-transparent border-b-transparent border-l-transparent"
|
|
271
|
-
}[
|
|
281
|
+
}[g || "bottom"]}`,
|
|
272
282
|
"aria-hidden": "true"
|
|
273
283
|
}
|
|
274
284
|
) : null;
|
|
275
285
|
return /* @__PURE__ */ K(
|
|
276
286
|
"ul",
|
|
277
287
|
{
|
|
278
|
-
ref:
|
|
279
|
-
id:
|
|
288
|
+
ref: I,
|
|
289
|
+
id: f,
|
|
280
290
|
role: "menu",
|
|
281
|
-
"aria-labelledby":
|
|
291
|
+
"aria-labelledby": m,
|
|
282
292
|
tabIndex: -1,
|
|
283
|
-
className: `${
|
|
284
|
-
"data-testid":
|
|
285
|
-
onKeyDown:
|
|
293
|
+
className: `${E} ${w ? "relative" : ""}`,
|
|
294
|
+
"data-testid": h("menu"),
|
|
295
|
+
onKeyDown: v,
|
|
286
296
|
children: [
|
|
287
|
-
|
|
288
|
-
|
|
297
|
+
s,
|
|
298
|
+
C
|
|
289
299
|
]
|
|
290
300
|
}
|
|
291
301
|
);
|
|
292
302
|
}
|
|
293
303
|
function U({
|
|
294
|
-
children:
|
|
304
|
+
children: p,
|
|
295
305
|
icon: c,
|
|
296
|
-
label:
|
|
297
|
-
onClick:
|
|
298
|
-
active:
|
|
299
|
-
disabled:
|
|
300
|
-
danger:
|
|
301
|
-
className:
|
|
302
|
-
_key:
|
|
306
|
+
label: f,
|
|
307
|
+
onClick: m,
|
|
308
|
+
active: y = !1,
|
|
309
|
+
disabled: l = !1,
|
|
310
|
+
danger: r = !1,
|
|
311
|
+
className: o = "",
|
|
312
|
+
_key: d
|
|
303
313
|
}) {
|
|
304
|
-
const { closeDropdown: w, getTestId: h } =
|
|
305
|
-
|
|
306
|
-
},
|
|
307
|
-
(C.key === "Enter" || C.key === " ") && !
|
|
308
|
-
}, E =
|
|
309
|
-
return /* @__PURE__ */ i("li", { className: I, role: "none", "data-key":
|
|
314
|
+
const { closeDropdown: w, getTestId: g, menuOnClick: h } = Z(), I = [y && "active", l && "disabled", o].filter(Boolean).join(" "), n = () => {
|
|
315
|
+
l || (m?.(), h && d && h({ key: d, keyPath: [d] }), w());
|
|
316
|
+
}, v = (C) => {
|
|
317
|
+
(C.key === "Enter" || C.key === " ") && !l && (C.preventDefault(), n());
|
|
318
|
+
}, E = f || p;
|
|
319
|
+
return /* @__PURE__ */ i("li", { className: I, role: "none", "data-key": d, "data-testid": d ? g(`item-${d}`) : void 0, children: /* @__PURE__ */ K(
|
|
310
320
|
"a",
|
|
311
321
|
{
|
|
312
322
|
role: "menuitem",
|
|
313
|
-
tabIndex:
|
|
314
|
-
"aria-disabled":
|
|
315
|
-
className: `whitespace-nowrap ${
|
|
316
|
-
onClick:
|
|
317
|
-
onKeyDown:
|
|
323
|
+
tabIndex: l ? -1 : 0,
|
|
324
|
+
"aria-disabled": l || void 0,
|
|
325
|
+
className: `whitespace-nowrap ${r ? "text-error" : ""}`,
|
|
326
|
+
onClick: n,
|
|
327
|
+
onKeyDown: v,
|
|
318
328
|
children: [
|
|
319
329
|
c && /* @__PURE__ */ i("span", { className: "mr-2 inline-flex items-center", children: c }),
|
|
320
330
|
E
|
|
@@ -322,83 +332,83 @@ function U({
|
|
|
322
332
|
}
|
|
323
333
|
) });
|
|
324
334
|
}
|
|
325
|
-
function
|
|
326
|
-
children:
|
|
335
|
+
function _({
|
|
336
|
+
children: p,
|
|
327
337
|
title: c,
|
|
328
|
-
icon:
|
|
329
|
-
disabled:
|
|
330
|
-
className:
|
|
331
|
-
_key:
|
|
338
|
+
icon: f,
|
|
339
|
+
disabled: m = !1,
|
|
340
|
+
className: y = "",
|
|
341
|
+
_key: l
|
|
332
342
|
}) {
|
|
333
|
-
const [
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
},
|
|
343
|
+
const [r, o] = j(!1), d = L(null), w = L(null), g = L(null), h = X(), I = () => {
|
|
344
|
+
m || o(!0);
|
|
345
|
+
}, n = () => {
|
|
346
|
+
o(!1);
|
|
347
|
+
}, v = () => {
|
|
338
348
|
setTimeout(() => {
|
|
339
|
-
|
|
349
|
+
g.current?.querySelector('[role="menuitem"]:not([aria-disabled="true"])')?.focus();
|
|
340
350
|
}, 0);
|
|
341
|
-
},
|
|
342
|
-
if (!
|
|
343
|
-
switch (
|
|
351
|
+
}, E = (s) => {
|
|
352
|
+
if (!m)
|
|
353
|
+
switch (s.key) {
|
|
344
354
|
case "ArrowRight":
|
|
345
355
|
case "Enter":
|
|
346
356
|
case " ":
|
|
347
|
-
|
|
357
|
+
s.preventDefault(), s.stopPropagation(), o(!0), v();
|
|
348
358
|
break;
|
|
349
359
|
case "ArrowLeft":
|
|
350
360
|
case "Escape":
|
|
351
|
-
|
|
361
|
+
s.preventDefault(), s.stopPropagation(), o(!1);
|
|
352
362
|
break;
|
|
353
363
|
}
|
|
354
|
-
},
|
|
355
|
-
switch (
|
|
364
|
+
}, C = (s) => {
|
|
365
|
+
switch (s.key) {
|
|
356
366
|
case "ArrowLeft":
|
|
357
367
|
case "Escape":
|
|
358
|
-
|
|
368
|
+
s.preventDefault(), s.stopPropagation(), o(!1), w.current?.focus();
|
|
359
369
|
break;
|
|
360
370
|
case "ArrowDown":
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
|
|
371
|
+
s.preventDefault(), s.stopPropagation();
|
|
372
|
+
const t = g.current?.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])');
|
|
373
|
+
if (t) {
|
|
374
|
+
const M = (Array.from(t).findIndex((N) => N === document.activeElement) + 1) % t.length;
|
|
375
|
+
t[M]?.focus();
|
|
366
376
|
}
|
|
367
377
|
break;
|
|
368
378
|
case "ArrowUp":
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
const
|
|
373
|
-
|
|
379
|
+
s.preventDefault(), s.stopPropagation();
|
|
380
|
+
const b = g.current?.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])');
|
|
381
|
+
if (b) {
|
|
382
|
+
const M = (Array.from(b).findIndex((N) => N === document.activeElement) - 1 + b.length) % b.length;
|
|
383
|
+
b[M]?.focus();
|
|
374
384
|
}
|
|
375
385
|
break;
|
|
376
386
|
}
|
|
377
|
-
}, F = [
|
|
387
|
+
}, F = [m && "disabled", y].filter(Boolean).join(" ");
|
|
378
388
|
return /* @__PURE__ */ i(
|
|
379
389
|
"li",
|
|
380
390
|
{
|
|
381
|
-
ref:
|
|
391
|
+
ref: d,
|
|
382
392
|
className: F,
|
|
383
393
|
role: "none",
|
|
384
|
-
"data-key":
|
|
385
|
-
onMouseEnter:
|
|
386
|
-
onMouseLeave:
|
|
387
|
-
children: /* @__PURE__ */ K("details", { open:
|
|
394
|
+
"data-key": l,
|
|
395
|
+
onMouseEnter: I,
|
|
396
|
+
onMouseLeave: n,
|
|
397
|
+
children: /* @__PURE__ */ K("details", { open: r, children: [
|
|
388
398
|
/* @__PURE__ */ K(
|
|
389
399
|
"summary",
|
|
390
400
|
{
|
|
391
401
|
ref: w,
|
|
392
402
|
role: "menuitem",
|
|
393
|
-
tabIndex:
|
|
394
|
-
"aria-disabled":
|
|
403
|
+
tabIndex: m ? -1 : 0,
|
|
404
|
+
"aria-disabled": m || void 0,
|
|
395
405
|
"aria-haspopup": "menu",
|
|
396
|
-
"aria-expanded":
|
|
397
|
-
"aria-controls":
|
|
406
|
+
"aria-expanded": r,
|
|
407
|
+
"aria-controls": h,
|
|
398
408
|
className: "whitespace-nowrap",
|
|
399
|
-
onKeyDown:
|
|
409
|
+
onKeyDown: E,
|
|
400
410
|
children: [
|
|
401
|
-
|
|
411
|
+
f && /* @__PURE__ */ i("span", { className: "mr-2 inline-flex items-center", children: f }),
|
|
402
412
|
c
|
|
403
413
|
]
|
|
404
414
|
}
|
|
@@ -406,31 +416,31 @@ function Y({
|
|
|
406
416
|
/* @__PURE__ */ i(
|
|
407
417
|
"ul",
|
|
408
418
|
{
|
|
409
|
-
ref:
|
|
410
|
-
id:
|
|
419
|
+
ref: g,
|
|
420
|
+
id: h,
|
|
411
421
|
className: `${ne} bg-base-100 rounded-box z-50 shadow`,
|
|
412
422
|
role: "menu",
|
|
413
423
|
"aria-label": typeof c == "string" ? c : void 0,
|
|
414
|
-
onKeyDown:
|
|
415
|
-
children:
|
|
424
|
+
onKeyDown: C,
|
|
425
|
+
children: p
|
|
416
426
|
}
|
|
417
427
|
)
|
|
418
428
|
] })
|
|
419
429
|
}
|
|
420
430
|
);
|
|
421
431
|
}
|
|
422
|
-
function re({ className:
|
|
423
|
-
const c = ["border-base-content/10",
|
|
432
|
+
function re({ className: p = "" }) {
|
|
433
|
+
const c = ["border-base-content/10", p].filter(Boolean).join(" ");
|
|
424
434
|
return /* @__PURE__ */ i("li", { role: "separator", className: "my-1", children: /* @__PURE__ */ i("hr", { className: c }) });
|
|
425
435
|
}
|
|
426
|
-
const
|
|
427
|
-
Trigger:
|
|
428
|
-
Menu:
|
|
436
|
+
const ze = Object.assign(Be, {
|
|
437
|
+
Trigger: B,
|
|
438
|
+
Menu: Y,
|
|
429
439
|
Item: U,
|
|
430
|
-
SubMenu:
|
|
440
|
+
SubMenu: _,
|
|
431
441
|
Divider: re
|
|
432
442
|
});
|
|
433
443
|
export {
|
|
434
|
-
|
|
444
|
+
ze as Dropdown
|
|
435
445
|
};
|
|
436
446
|
//# sourceMappingURL=Dropdown.js.map
|