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