@bioturing/components 0.27.0 → 0.29.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/components/breadcrumb/style.css +1 -1
- package/dist/components/checkbox/component.js.map +1 -1
- package/dist/components/checkbox/style.css +1 -1
- package/dist/components/choice-list/component.js +102 -42
- package/dist/components/choice-list/component.js.map +1 -1
- package/dist/components/choice-list/style.css +1 -1
- package/dist/components/cmdk/index.js.map +1 -1
- package/dist/components/color-select/style.css +1 -1
- package/dist/components/combobox/component.js +232 -0
- package/dist/components/combobox/component.js.map +1 -0
- package/dist/components/combobox/style.css +1 -0
- package/dist/components/drag-drop/style.css +1 -1
- package/dist/components/dropdown-menu/component.js +181 -160
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.js +16 -0
- package/dist/components/dropdown-menu/divider.js.map +1 -0
- package/dist/components/dropdown-menu/item.css +1 -0
- package/dist/components/dropdown-menu/item.js +131 -0
- package/dist/components/dropdown-menu/item.js.map +1 -0
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/ds-root/component.js +22 -17
- package/dist/components/ds-root/component.js.map +1 -1
- package/dist/components/ds-root/style.css +1 -1
- package/dist/components/form/style.css +1 -1
- package/dist/components/hooks/useDraggable.js +77 -0
- package/dist/components/hooks/useDraggable.js.map +1 -0
- package/dist/components/hooks/useHover.js +26 -0
- package/dist/components/hooks/useHover.js.map +1 -0
- package/dist/components/hooks/useTransitionStatus.js +52 -0
- package/dist/components/hooks/useTransitionStatus.js.map +1 -0
- package/dist/components/modal/style.css +1 -1
- package/dist/components/nav/item.js +2 -2
- package/dist/components/nav/style.css +1 -1
- package/dist/components/popup-panel/component.js +81 -92
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/resizable/component.js +165 -97
- package/dist/components/resizable/component.js.map +1 -1
- package/dist/components/resizable/style.css +1 -1
- package/dist/components/scroll-area/component.js +70 -24
- package/dist/components/scroll-area/component.js.map +1 -1
- package/dist/components/scroll-area/style.css +1 -1
- package/dist/components/select/component.js +160 -91
- package/dist/components/select/component.js.map +1 -1
- package/dist/components/select/item.js +54 -0
- package/dist/components/select/item.js.map +1 -0
- package/dist/components/select/style.css +1 -1
- package/dist/components/select-trigger/component.js +150 -0
- package/dist/components/select-trigger/component.js.map +1 -0
- package/dist/components/select-trigger/style.css +1 -0
- package/dist/components/splitter/splitter-panel.js +8 -8
- package/dist/components/splitter/splitter.js +9 -9
- package/dist/components/splitter/useSizes.js +10 -10
- package/dist/components/splitter/useSizes.js.map +1 -1
- package/dist/components/stack/StackChild.js +9 -9
- package/dist/components/switch/style.css +1 -1
- package/dist/components/table/style.css +1 -1
- package/dist/components/theme-provider/component.js.map +1 -1
- package/dist/components/theme-provider/style.css +1 -1
- package/dist/components/tour/style.css +1 -1
- package/dist/components/transition/component.js +1 -1
- package/dist/components/transition/component.js.map +1 -1
- package/dist/components/utils/WithRenderProp.js.map +1 -1
- package/dist/index.d.ts +355 -12
- package/dist/index.js +198 -188
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +21 -7
- package/dist/metadata.js.map +1 -1
- package/dist/tokens/and-theme/tokens.js +12 -12
- package/dist/tokens/and-theme/tokens.js.map +1 -1
- package/package.json +8 -7
|
@@ -1,207 +1,228 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { Menu as
|
|
5
|
-
import { useControlled as
|
|
6
|
-
import { Popover as
|
|
7
|
-
import { Command as
|
|
2
|
+
import { jsx as e, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as w, useRef as Q, createElement as X } from "react";
|
|
4
|
+
import { Menu as P } from "@base-ui-components/react/menu";
|
|
5
|
+
import { useControlled as Y } from "@base-ui-components/utils/useControlled";
|
|
6
|
+
import { Popover as Z } from "@base-ui-components/react/popover";
|
|
7
|
+
import { Command as g } from "../cmdk/index.js";
|
|
8
|
+
import { FormItemInputContext as $ } from "antd/es/form/context";
|
|
8
9
|
import { PopupPanelSize as S } from "../popup-panel/constants.js";
|
|
10
|
+
import { DropdownMenuItem as O } from "./item.js";
|
|
9
11
|
import './style.css';/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
import { DropdownMenuDivider as K } from "./divider.js";
|
|
13
|
+
import { parseAntdPlacement as a } from "../utils/placement.js";
|
|
14
|
+
import { Input as N } from "../input/component.js";
|
|
15
|
+
import { ScrollArea as _ } from "../scroll-area/component.js";
|
|
16
|
+
import { DROPDOWN_COLLISION_AVOIDANCE as s } from "../utils/constants.js";
|
|
17
|
+
import { useCls as oo, useAntdCssVarClassname as ro } from "../utils/antdUtils.js";
|
|
18
|
+
import { clsx as u } from "../utils/cn.js";
|
|
19
|
+
const Go = ({
|
|
20
|
+
children: j,
|
|
21
|
+
items: z,
|
|
22
|
+
placement: B,
|
|
23
|
+
openOnHover: F,
|
|
24
|
+
open: T,
|
|
22
25
|
onOpenChange: v,
|
|
23
|
-
className:
|
|
24
|
-
itemRender:
|
|
25
|
-
classNames:
|
|
26
|
-
size:
|
|
27
|
-
showSearch:
|
|
28
|
-
searchProps:
|
|
26
|
+
className: U,
|
|
27
|
+
itemRender: E,
|
|
28
|
+
classNames: o,
|
|
29
|
+
size: k = "auto",
|
|
30
|
+
showSearch: t,
|
|
31
|
+
searchProps: y = {
|
|
29
32
|
placeholder: "Search..."
|
|
30
|
-
}
|
|
33
|
+
},
|
|
34
|
+
popupMatchTriggerWidth: W,
|
|
35
|
+
beforeList: C,
|
|
36
|
+
afterList: D,
|
|
37
|
+
keepOpenOnSelect: I,
|
|
38
|
+
highlightedItemKey: G,
|
|
39
|
+
selectedItemKeys: h,
|
|
40
|
+
showCheckbox: M
|
|
31
41
|
}) => {
|
|
32
|
-
const [
|
|
33
|
-
controlled:
|
|
42
|
+
const [q, x] = Y({
|
|
43
|
+
controlled: T,
|
|
34
44
|
default: !1,
|
|
35
45
|
name: "open"
|
|
36
|
-
}),
|
|
37
|
-
(
|
|
38
|
-
|
|
46
|
+
}), l = w(
|
|
47
|
+
(r) => {
|
|
48
|
+
x(r), v == null || v(r);
|
|
39
49
|
},
|
|
40
|
-
[
|
|
41
|
-
),
|
|
50
|
+
[x, v]
|
|
51
|
+
), d = oo(), L = ro(), R = a(B), H = Q(null), A = z.reduce((r, n) => (r.length === 0 && n.type !== "header" && r.push({
|
|
42
52
|
label: null,
|
|
43
53
|
items: []
|
|
44
|
-
}),
|
|
45
|
-
label:
|
|
54
|
+
}), n.type === "header" ? r.push({
|
|
55
|
+
label: n.title,
|
|
46
56
|
items: []
|
|
47
|
-
}) : (
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} : void 0,
|
|
68
|
-
render: I ? (y) => I(o, y) : void 0,
|
|
69
|
-
children: [
|
|
70
|
-
o.icon && /* @__PURE__ */ e(
|
|
71
|
-
"span",
|
|
72
|
-
{
|
|
73
|
-
className: d(
|
|
74
|
-
n("dropdown-menu-item-icon"),
|
|
75
|
-
r == null ? void 0 : r.itemIcon
|
|
76
|
-
),
|
|
77
|
-
children: o.icon
|
|
78
|
-
},
|
|
79
|
-
"icon"
|
|
80
|
-
),
|
|
81
|
-
/* @__PURE__ */ e("span", { children: o.label }, "label")
|
|
82
|
-
]
|
|
83
|
-
};
|
|
84
|
-
return i ? /* @__PURE__ */ e(u.Item, { ...D }, t + "-" + p) : /* @__PURE__ */ e(l, { ...D }, t + "-" + p);
|
|
85
|
-
} else if (o.type === "divider")
|
|
86
|
-
return /* @__PURE__ */ e(
|
|
87
|
-
c,
|
|
88
|
-
{
|
|
89
|
-
className: d(
|
|
90
|
-
n("dropdown-menu-divider"),
|
|
91
|
-
r == null ? void 0 : r.separator
|
|
92
|
-
)
|
|
93
|
-
},
|
|
94
|
-
t + "-" + p
|
|
95
|
-
);
|
|
96
|
-
return null;
|
|
97
|
-
},
|
|
98
|
-
[n, r, I, m, i, c]
|
|
99
|
-
), A = M(
|
|
100
|
-
(o, t) => /* @__PURE__ */ g(
|
|
101
|
-
f.Group,
|
|
57
|
+
}) : (n.type === "item" || n.type === "divider") && r.length > 0 && r[r.length - 1].items.push(n), r), []), m = w(
|
|
58
|
+
(r, n, p) => r.type === "item" ? /* @__PURE__ */ e(
|
|
59
|
+
O,
|
|
60
|
+
{
|
|
61
|
+
item: r,
|
|
62
|
+
inCombobox: t,
|
|
63
|
+
selected: h == null ? void 0 : h.includes(r.key),
|
|
64
|
+
onSelect: t ? () => {
|
|
65
|
+
const i = new MouseEvent("click", {
|
|
66
|
+
bubbles: !0,
|
|
67
|
+
cancelable: !0
|
|
68
|
+
});
|
|
69
|
+
r.onClick(i), I || l == null || l(!1);
|
|
70
|
+
} : void 0,
|
|
71
|
+
itemRender: E,
|
|
72
|
+
showCheckbox: M
|
|
73
|
+
},
|
|
74
|
+
n + "-" + p
|
|
75
|
+
) : r.type === "divider" ? /* @__PURE__ */ e(
|
|
76
|
+
K,
|
|
102
77
|
{
|
|
103
|
-
|
|
78
|
+
inCombobox: t,
|
|
79
|
+
className: o == null ? void 0 : o.separator
|
|
80
|
+
},
|
|
81
|
+
n + "-" + p
|
|
82
|
+
) : null,
|
|
83
|
+
[
|
|
84
|
+
o,
|
|
85
|
+
E,
|
|
86
|
+
l,
|
|
87
|
+
t,
|
|
88
|
+
I,
|
|
89
|
+
h,
|
|
90
|
+
M
|
|
91
|
+
]
|
|
92
|
+
), V = w(
|
|
93
|
+
(r, n) => /* @__PURE__ */ b(
|
|
94
|
+
P.Group,
|
|
95
|
+
{
|
|
96
|
+
className: u(d("dropdown-menu-group"), o == null ? void 0 : o.group),
|
|
104
97
|
children: [
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
r.label && /* @__PURE__ */ e(
|
|
99
|
+
P.GroupLabel,
|
|
107
100
|
{
|
|
108
|
-
className:
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
className: u(
|
|
102
|
+
d("dropdown-menu-header"),
|
|
103
|
+
o == null ? void 0 : o.groupLabel
|
|
111
104
|
),
|
|
112
|
-
children: /* @__PURE__ */ e("span", { children:
|
|
105
|
+
children: /* @__PURE__ */ e("span", { children: r.label })
|
|
113
106
|
}
|
|
114
107
|
),
|
|
115
|
-
|
|
108
|
+
r.items.map((p, i) => m(p, n, i))
|
|
116
109
|
]
|
|
117
110
|
},
|
|
118
|
-
"group" +
|
|
111
|
+
"group" + n
|
|
119
112
|
),
|
|
120
|
-
[
|
|
121
|
-
),
|
|
122
|
-
(
|
|
123
|
-
|
|
113
|
+
[d, o, m]
|
|
114
|
+
), c = w(
|
|
115
|
+
(r, n) => r.label ? /* @__PURE__ */ e(
|
|
116
|
+
g.Group,
|
|
124
117
|
{
|
|
125
|
-
className: d(
|
|
118
|
+
className: u(d("dropdown-menu-group"), o == null ? void 0 : o.group),
|
|
126
119
|
heading: /* @__PURE__ */ e(
|
|
127
|
-
|
|
120
|
+
P.GroupLabel,
|
|
128
121
|
{
|
|
129
|
-
className:
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
className: u(
|
|
123
|
+
d("dropdown-menu-header"),
|
|
124
|
+
o == null ? void 0 : o.groupLabel
|
|
132
125
|
),
|
|
133
|
-
children: /* @__PURE__ */ e("span", { children:
|
|
126
|
+
children: /* @__PURE__ */ e("span", { children: r.label })
|
|
134
127
|
}
|
|
135
128
|
),
|
|
136
|
-
children:
|
|
129
|
+
children: r.items.map((p, i) => m(p, n, i))
|
|
137
130
|
},
|
|
138
|
-
"group" +
|
|
139
|
-
) :
|
|
140
|
-
[
|
|
141
|
-
),
|
|
142
|
-
() =>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
131
|
+
"group" + n
|
|
132
|
+
) : r.items.map((p, i) => m(p, n, i)),
|
|
133
|
+
[d, o, m]
|
|
134
|
+
), J = w(
|
|
135
|
+
() => t ? /* @__PURE__ */ b(
|
|
136
|
+
g,
|
|
137
|
+
{
|
|
138
|
+
className: d("dropdown-menu-container"),
|
|
139
|
+
disablePointerSelection: t,
|
|
140
|
+
defaultValue: G ? String(G) : void 0,
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ e($.Provider, { value: {}, children: /* @__PURE__ */ X(
|
|
143
|
+
g.Input,
|
|
144
|
+
{
|
|
145
|
+
...y,
|
|
146
|
+
key: "search",
|
|
147
|
+
render: /* @__PURE__ */ e(
|
|
148
|
+
N,
|
|
149
|
+
{
|
|
150
|
+
allowClear: !0,
|
|
151
|
+
className: d("dropdown-menu-search"),
|
|
152
|
+
placeholder: "Search"
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
) }),
|
|
157
|
+
C,
|
|
158
|
+
/* @__PURE__ */ e(_, { fadeEdges: !0, children: /* @__PURE__ */ b(g.List, { className: d("dropdown-menu-list"), children: [
|
|
159
|
+
/* @__PURE__ */ e(g.Empty, { className: d("dropdown-menu-empty"), children: "No results found." }),
|
|
160
|
+
A.map(c)
|
|
161
|
+
] }) }),
|
|
162
|
+
D
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
) : /* @__PURE__ */ b("div", { className: d("dropdown-menu-container"), children: [
|
|
166
|
+
C,
|
|
167
|
+
/* @__PURE__ */ e(_, { fadeEdges: !0, children: A.map(V) }),
|
|
168
|
+
D
|
|
169
|
+
] }),
|
|
156
170
|
[
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
t,
|
|
172
|
+
d,
|
|
173
|
+
G,
|
|
174
|
+
y,
|
|
175
|
+
C,
|
|
160
176
|
A,
|
|
161
|
-
|
|
162
|
-
|
|
177
|
+
c,
|
|
178
|
+
D,
|
|
179
|
+
V
|
|
163
180
|
]
|
|
164
|
-
),
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
|
|
181
|
+
), f = t ? Z : P;
|
|
182
|
+
return /* @__PURE__ */ b(
|
|
183
|
+
f.Root,
|
|
167
184
|
{
|
|
168
|
-
openOnHover:
|
|
169
|
-
open:
|
|
170
|
-
onOpenChange:
|
|
185
|
+
openOnHover: F,
|
|
186
|
+
open: q,
|
|
187
|
+
onOpenChange: l,
|
|
171
188
|
children: [
|
|
172
189
|
/* @__PURE__ */ e(
|
|
173
|
-
|
|
190
|
+
f.Trigger,
|
|
174
191
|
{
|
|
175
|
-
render:
|
|
176
|
-
ref:
|
|
177
|
-
className:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
192
|
+
render: j,
|
|
193
|
+
ref: H,
|
|
194
|
+
className: u(
|
|
195
|
+
d("dropdown-menu-trigger"),
|
|
196
|
+
o == null ? void 0 : o.trigger,
|
|
197
|
+
L
|
|
181
198
|
)
|
|
182
199
|
}
|
|
183
200
|
),
|
|
184
|
-
/* @__PURE__ */ e(
|
|
185
|
-
|
|
201
|
+
/* @__PURE__ */ e(f.Portal, { children: /* @__PURE__ */ e(
|
|
202
|
+
f.Positioner,
|
|
186
203
|
{
|
|
187
|
-
side:
|
|
188
|
-
align:
|
|
204
|
+
side: R.side,
|
|
205
|
+
align: R.align,
|
|
189
206
|
sideOffset: 4,
|
|
190
|
-
className: d(
|
|
191
|
-
collisionAvoidance:
|
|
207
|
+
className: u(d("dropdown-menu-root"), o == null ? void 0 : o.root),
|
|
208
|
+
collisionAvoidance: s,
|
|
192
209
|
children: /* @__PURE__ */ e(
|
|
193
|
-
|
|
210
|
+
f.Popup,
|
|
194
211
|
{
|
|
195
|
-
className:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
className: u(
|
|
213
|
+
d(
|
|
214
|
+
"dropdown-menu",
|
|
215
|
+
M && "dropdown-menu-show-checkbox",
|
|
216
|
+
W && "dropdown-menu-match-trigger-width"
|
|
217
|
+
),
|
|
218
|
+
U,
|
|
219
|
+
o == null ? void 0 : o.popup,
|
|
220
|
+
L
|
|
200
221
|
),
|
|
201
222
|
style: {
|
|
202
|
-
"--size-width":
|
|
223
|
+
"--size-width": k in S ? S[k] : void 0
|
|
203
224
|
},
|
|
204
|
-
children:
|
|
225
|
+
children: J()
|
|
205
226
|
}
|
|
206
227
|
)
|
|
207
228
|
}
|
|
@@ -211,6 +232,6 @@ const fo = ({
|
|
|
211
232
|
);
|
|
212
233
|
};
|
|
213
234
|
export {
|
|
214
|
-
|
|
235
|
+
Go as DropdownMenu
|
|
215
236
|
};
|
|
216
237
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/dropdown-menu/component.tsx"],"sourcesContent":["\"use client\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { useControlled } from \"@base-ui-components/react/utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { Ref, useCallback, useRef } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n useAntdCssVarClassname,\n useCls,\n BaseUIPlacement,\n} from \"../utils\";\nimport { Command } from \"../cmdk\";\nimport { ScrollArea } from \"../scroll-area\";\n\n// Import component-specific styles\nimport { Input } from \"../input\";\nimport { PopupPanelSize } from \"../popup-panel/constants\";\n\nimport \"./style.css\";\n\nexport type DropdownMenuItemType =\n | {\n type: \"item\";\n label?: React.ReactNode;\n disabled?: boolean;\n icon?: React.ReactNode;\n key: React.Key;\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n danger?: boolean;\n ref?: React.Ref<HTMLElement>;\n }\n | {\n type: \"divider\";\n }\n | {\n type: \"header\";\n title?: React.ReactNode;\n };\n\nexport interface DropdownMenuProps {\n /** Array of menu items to be displayed in the dropdown */\n items: DropdownMenuItemType[];\n /** Custom render function for the trigger element */\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n /**\n * Placement of the dropdown relative to the trigger element\n * @default \"bottomLeft\"\n */\n placement?: PopoverProps[\"placement\"];\n /**\n * Whether to open the dropdown on hover instead of click\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Controlled open state of the dropdown\n */\n open?: boolean;\n /**\n * Callback fired when the dropdown open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional CSS class for the dropdown component\n */\n className?: string;\n /**\n * Custom class names for different parts of the dropdown\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n group?: string;\n groupLabel?: string;\n item?: string;\n itemIcon?: string;\n itemText?: string;\n separator?: string;\n positioner?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to show search input\n * @default false\n */\n showSearch?: boolean;\n /**\n * Size of the dropdown menu\n * @default \"auto\"\n */\n size?: \"auto\" | keyof typeof PopupPanelSize;\n /**\n * Search placeholder\n */\n searchProps?: Omit<\n React.ComponentProps<typeof Command.Input>,\n \"size\" | \"ref\"\n >;\n /**\n *\n */\n}\n\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n searchProps = {\n placeholder: \"Search...\",\n },\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n const MenuSeparator = showSearch ? Command.Separator : Menu.Separator;\n\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n const MenuItem = showSearch ? Command.Item : Menu.Item;\n\n if (item.type === \"item\") {\n const props = {\n className: clsx(cls(\"dropdown-menu-item\"), classNames?.item),\n disabled: item.disabled,\n \"data-danger\": item.danger,\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: item.onClick,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n onSelect: showSearch\n ? () => {\n const e = new MouseEvent(\"click\", {\n bubbles: true,\n cancelable: true,\n }) as unknown as React.MouseEvent<HTMLElement, MouseEvent>;\n item.onClick(e);\n onOpenChange?.(false);\n }\n : undefined,\n render: itemRender\n ? (itemProps: React.HTMLAttributes<HTMLElement>) =>\n itemRender(item, itemProps)\n : undefined,\n children: [\n item.icon && (\n <span\n key=\"icon\"\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n ),\n <span key=\"label\">{item.label}</span>,\n ],\n };\n return showSearch ? (\n <Command.Item key={i + \"-\" + j} {...props}></Command.Item>\n ) : (\n <MenuItem key={i + \"-\" + j} {...props}></MenuItem>\n );\n } else if (item.type === \"divider\") {\n return (\n <MenuSeparator\n key={i + \"-\" + j}\n className={clsx(\n cls(\"dropdown-menu-divider\"),\n classNames?.separator\n )}\n />\n );\n }\n return null;\n },\n [cls, classNames, itemRender, onOpenChange, showSearch, MenuSeparator]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupShowSearch = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Command.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n heading={\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n }\n >\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Command.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderMenuInner = useCallback(\n () =>\n showSearch ? (\n <Command className={cls(\"dropdown-menu-container\")}>\n <Command.Input\n {...searchProps}\n key=\"search\"\n render={\n <Input allowClear className={cls(\"dropdown-menu-search\")} />\n }\n />\n <ScrollArea>\n <Command.List className={cls(\"dropdown-menu-list\")}>\n <Command.Empty className={cls(\"dropdown-menu-empty\")}>\n No results found.\n </Command.Empty>\n {itemGroups.map(renderGroupShowSearch)}\n </Command.List>\n </ScrollArea>\n </Command>\n ) : (\n <div className={cls(\"dropdown-menu-container\")}>\n <ScrollArea>{itemGroups.map(renderGroup)}</ScrollArea>\n </div>\n ),\n [\n showSearch,\n itemGroups,\n renderGroupShowSearch,\n renderGroup,\n searchProps,\n cls,\n ]\n );\n\n const BaseComponent = showSearch ? Popover : Menu;\n\n return (\n <BaseComponent.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <BaseComponent.Trigger\n render={children}\n ref={buttonRef}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n antdCssVarClassname\n )}\n />\n <BaseComponent.Portal>\n <BaseComponent.Positioner\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n className={clsx(cls(\"dropdown-menu-root\"), classNames?.root)}\n collisionAvoidance={DROPDOWN_COLLISION_AVOIDANCE}\n >\n <BaseComponent.Popup\n className={clsx(\n cls(\"dropdown-menu\"),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n style={\n {\n \"--size-width\":\n size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {renderMenuInner()}\n </BaseComponent.Popup>\n </BaseComponent.Positioner>\n </BaseComponent.Portal>\n </BaseComponent.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","className","itemRender","classNames","size","showSearch","searchProps","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","MenuSeparator","Command","Menu","renderMenuItem","item","i","j","MenuItem","props","clsx","e","itemProps","jsx","renderGroup","group","index","jsxs","renderGroupShowSearch","renderMenuInner","createElement","Input","ScrollArea","BaseComponent","Popover","DROPDOWN_COLLISION_AVOIDANCE","PopupPanelSize"],"mappings":";;;;;;;;;;;;;;;AA2HO,MAAMA,KAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,IACZ,aAAa;AAAA,EAAA;AAEjB,MAAyB;AACvB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAc;AAAA,IACpC,YAAYV;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP,GACKW,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACrB,MAAAJ,EAAQI,CAAQ,GAChBZ,KAAA,QAAAA,EAAsBY;AAAA,IACxB;AAAA,IACA,CAACJ,GAASR,CAAmB;AAAA,EAC/B,GACMa,IAAMC,EAAO,GACbC,IAAsBC,EAAuB,GAC7CC,IAAkBC,EAAmBrB,CAAS,GAC9CsB,IAAYC,EAA0B,IAAI,GAC1CC,IAAazB,EAAM,OAA4B,CAAC0B,GAAKC,OAErDD,EAAI,WAAW,KAAKC,EAAQ,SAAS,YACvCD,EAAI,KAAK;AAAA,IACP,OAAO;AAAA,IACP,OAAO,CAAA;AAAA,EAAC,CACT,GAICC,EAAQ,SAAS,WACnBD,EAAI,KAAK;AAAA,IACP,OAAOC,EAAQ;AAAA,IACf,OAAO,CAAA;AAAA,EAAC,CACT,KAIAA,EAAQ,SAAS,UAAUA,EAAQ,SAAS,cAC7CD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own-menu/component.tsx"],"sourcesContent":["\"use client\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { useControlled } from \"@base-ui-components/utils/useControlled\";\nimport { Popover } from \"@base-ui-components/react/popover\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n useAntdCssVarClassname,\n useCls,\n} from \"../utils\";\nimport { Command } from \"../cmdk\";\nimport { ScrollArea } from \"../scroll-area\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\n\n// Import component-specific styles\nimport { Input } from \"../input\";\nimport { PopupPanelSize } from \"../popup-panel/constants\";\nimport { DropdownMenuItem } from \"./item\";\n\nimport \"./style.css\";\nimport { DropdownMenuDivider } from \"./divider\";\n\nexport type DropdownMenuItemType =\n | {\n /**\n * The type of the menu item\n */\n type: \"item\";\n /**\n * The label of the menu item\n */\n label?: React.ReactNode;\n /**\n * Whether the menu item is disabled\n */\n disabled?: boolean;\n /**\n * The icon of the menu item\n */\n icon?: React.ReactNode;\n /**\n * The key of the menu item\n */\n key: React.Key;\n /**\n * The onClick event handler of the menu item\n */\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n /**\n * The onMouseEnter event handler of the menu item\n */\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n /**\n * The onMouseLeave event handler of the menu item\n */\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n /**\n * The onMouseOver event handler of the menu item\n */\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n /**\n * The onMouseOut event handler of the menu item\n */\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n /**\n * The className of the menu item\n */\n className?: string;\n /**\n * Whether the menu item is a danger item\n */\n danger?: boolean;\n /**\n * The ref of the menu item\n */\n ref?: React.Ref<HTMLElement>;\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"divider\";\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"header\";\n /**\n * The title of the menu item\n */\n title?: React.ReactNode;\n /**\n * The className of the menu item\n */\n className?: string;\n };\n\nexport interface DropdownMenuProps {\n /** Array of menu items to be displayed in the dropdown */\n items: DropdownMenuItemType[];\n /** Custom render function for the trigger element */\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n /**\n * Placement of the dropdown relative to the trigger element\n * @default \"bottomLeft\"\n */\n placement?: PopoverProps[\"placement\"];\n /**\n * Whether to open the dropdown on hover instead of click\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Controlled open state of the dropdown\n */\n open?: boolean;\n /**\n * Callback fired when the dropdown open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional CSS class for the dropdown component\n */\n className?: string;\n /**\n * Custom class names for different parts of the dropdown\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n group?: string;\n groupLabel?: string;\n item?: string;\n itemIcon?: string;\n itemText?: string;\n separator?: string;\n positioner?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to show search input\n * @default false\n */\n showSearch?: boolean;\n /**\n * Size of the dropdown menu\n * @default \"auto\"\n */\n size?: \"auto\" | keyof typeof PopupPanelSize;\n /**\n * Search placeholder\n */\n searchProps?: Omit<\n React.ComponentProps<typeof Command.Input>,\n \"size\" | \"ref\"\n >;\n /**\n * Whether to match the width of the popup with the trigger\n * @default false\n */\n popupMatchTriggerWidth?: boolean;\n\n /**\n * Content to display before the list\n */\n beforeList?: React.ReactNode;\n /**\n * Content to display after the list\n */\n afterList?: React.ReactNode;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n}\n\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n searchProps = {\n placeholder: \"Search...\",\n },\n popupMatchTriggerWidth,\n beforeList,\n afterList,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n showCheckbox,\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={showSearch}\n selected={selectedItemKeys?.includes(item.key)}\n onSelect={\n showSearch\n ? () => {\n const e = new MouseEvent(\"click\", {\n bubbles: true,\n cancelable: true,\n }) as unknown as React.MouseEvent<HTMLElement, MouseEvent>;\n item.onClick(e);\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }\n : undefined\n }\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={showSearch}\n className={classNames?.separator}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n showSearch,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupShowSearch = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Command.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n heading={\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n }\n >\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Command.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderMenuInner = useCallback(\n () =>\n showSearch ? (\n <Command\n className={cls(\"dropdown-menu-container\")}\n disablePointerSelection={showSearch}\n defaultValue={\n highlightedItemKey ? String(highlightedItemKey) : undefined\n }\n >\n <FormItemInputContext.Provider value={{}}>\n <Command.Input\n {...searchProps}\n key=\"search\"\n render={\n <Input\n allowClear\n className={cls(\"dropdown-menu-search\")}\n placeholder=\"Search\"\n />\n }\n />\n </FormItemInputContext.Provider>\n {beforeList}\n <ScrollArea fadeEdges>\n <Command.List className={cls(\"dropdown-menu-list\")}>\n <Command.Empty className={cls(\"dropdown-menu-empty\")}>\n No results found.\n </Command.Empty>\n {itemGroups.map(renderGroupShowSearch)}\n </Command.List>\n </ScrollArea>\n {afterList}\n </Command>\n ) : (\n <div className={cls(\"dropdown-menu-container\")}>\n {beforeList}\n <ScrollArea fadeEdges>{itemGroups.map(renderGroup)}</ScrollArea>\n {afterList}\n </div>\n ),\n [\n showSearch,\n cls,\n highlightedItemKey,\n searchProps,\n beforeList,\n itemGroups,\n renderGroupShowSearch,\n afterList,\n renderGroup,\n ]\n );\n\n const BaseComponent = showSearch ? Popover : Menu;\n\n return (\n <BaseComponent.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <BaseComponent.Trigger\n render={children}\n ref={buttonRef}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n antdCssVarClassname\n )}\n />\n <BaseComponent.Portal>\n <BaseComponent.Positioner\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n className={clsx(cls(\"dropdown-menu-root\"), classNames?.root)}\n collisionAvoidance={DROPDOWN_COLLISION_AVOIDANCE}\n >\n <BaseComponent.Popup\n className={clsx(\n cls(\n \"dropdown-menu\",\n showCheckbox && \"dropdown-menu-show-checkbox\",\n popupMatchTriggerWidth && \"dropdown-menu-match-trigger-width\"\n ),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n style={\n {\n \"--size-width\":\n size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {renderMenuInner()}\n </BaseComponent.Popup>\n </BaseComponent.Positioner>\n </BaseComponent.Portal>\n </BaseComponent.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","className","itemRender","classNames","size","showSearch","searchProps","popupMatchTriggerWidth","beforeList","afterList","keepOpenOnSelect","highlightedItemKey","selectedItemKeys","showCheckbox","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","renderMenuItem","item","i","j","jsx","DropdownMenuItem","e","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupShowSearch","Command","renderMenuInner","FormItemInputContext","createElement","Input","ScrollArea","BaseComponent","Popover","DROPDOWN_COLLISION_AVOIDANCE","PopupPanelSize"],"mappings":";;;;;;;;;;;;;;;;;;AA+MO,MAAMA,KAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,wBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AACF,MAAyB;AACvB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAc;AAAA,IACpC,YAAYjB;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP,GACKkB,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACrB,MAAAJ,EAAQI,CAAQ,GAChBnB,KAAA,QAAAA,EAAsBmB;AAAA,IACxB;AAAA,IACA,CAACJ,GAASf,CAAmB;AAAA,EAC/B,GACMoB,IAAMC,GAAO,GACbC,IAAsBC,GAAuB,GAC7CC,IAAkBC,EAAmB5B,CAAS,GAC9C6B,IAAYC,EAA0B,IAAI,GAC1CC,IAAahC,EAAM,OAA4B,CAACiC,GAAKC,OAErDD,EAAI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a,IAAgB/C,IAAagD,IAAUV;AAG3C,SAAA,gBAAAD;AAAA,IAACU,EAAc;AAAA,IAAd;AAAA,MACC,aAAAtD;AAAA,MACA,MAAAgB;AAAA,MACA,cAAAG;AAAA,MAEA,UAAA;AAAA,QAAA,gBAAAkB;AAAA,UAACiB,EAAc;AAAA,UAAd;AAAA,YACC,QAAQzD;AAAA,YACR,KAAK+B;AAAA,YACL,WAAWkB;AAAA,cACTxB,EAAI,uBAAuB;AAAA,cAC3BjB,KAAA,gBAAAA,EAAY;AAAA,cACZmB;AAAA,YAAA;AAAA,UACF;AAAA,QACF;AAAA,QACA,gBAAAa,EAACiB,EAAc,QAAd,EACC,UAAA,gBAAAjB;AAAA,UAACiB,EAAc;AAAA,UAAd;AAAA,YACC,MAAM5B,EAAgB;AAAA,YACtB,OAAOA,EAAgB;AAAA,YACvB,YAAY;AAAA,YACZ,WAAWoB,EAAKxB,EAAI,oBAAoB,GAAGjB,KAAA,gBAAAA,EAAY,IAAI;AAAA,YAC3D,oBAAoBmD;AAAA,YAEpB,UAAA,gBAAAnB;AAAA,cAACiB,EAAc;AAAA,cAAd;AAAA,gBACC,WAAWR;AAAA,kBACTxB;AAAA,oBACE;AAAA,oBACAP,KAAgB;AAAA,oBAChBN,KAA0B;AAAA,kBAC5B;AAAA,kBACAN;AAAA,kBACAE,KAAA,gBAAAA,EAAY;AAAA,kBACZmB;AAAA,gBACF;AAAA,gBACA,OACE;AAAA,kBACE,gBACElB,KAAQmD,IAAiBA,EAAenD,CAAI,IAAI;AAAA,gBACpD;AAAA,gBAGD,UAAgB2C,EAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACnB;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Command as p } from "../cmdk/index.js";
|
|
3
|
+
import { Menu as n } from "@base-ui-components/react/menu";
|
|
4
|
+
import { useCls as s } from "../utils/antdUtils.js";
|
|
5
|
+
import { clsx as a } from "../utils/cn.js";
|
|
6
|
+
const l = ({
|
|
7
|
+
inCombobox: r,
|
|
8
|
+
className: o
|
|
9
|
+
}) => {
|
|
10
|
+
const m = s(), e = r ? p.Separator : n.Separator;
|
|
11
|
+
return /* @__PURE__ */ t(e, { className: a(m("dropdown-menu-divider"), o) });
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
l as DropdownMenuDivider
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.js","sources":["../../../src/components/dropdown-menu/divider.tsx"],"sourcesContent":["import { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { clsx, useCls } from \"../utils\";\n\nexport interface DropdownMenuDividerProps {\n inCombobox?: boolean;\n className?: string;\n}\n\nexport const DropdownMenuDivider = ({\n inCombobox,\n className,\n}: DropdownMenuDividerProps) => {\n const cls = useCls();\n const MenuSeparator = inCombobox ? Command.Separator : Menu.Separator;\n\n return (\n <MenuSeparator className={clsx(cls(\"dropdown-menu-divider\"), className)} />\n );\n};\n"],"names":["DropdownMenuDivider","inCombobox","className","cls","useCls","MenuSeparator","Command","Menu","jsx","clsx"],"mappings":";;;;;AASO,MAAMA,IAAsB,CAAC;AAAA,EAClC,YAAAC;AAAA,EACA,WAAAC;AACF,MAAgC;AAC9B,QAAMC,IAAMC,EAAO,GACbC,IAAgBJ,IAAaK,EAAQ,YAAYC,EAAK;AAG1D,SAAA,gBAAAC,EAACH,KAAc,WAAWI,EAAKN,EAAI,uBAAuB,GAAGD,CAAS,GAAG;AAE7E;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer components{.ds-dropdown-menu-item{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);cursor:pointer;display:flex;align-items:center;transition:all .3s var(--ds-motion-ease-out)}.ds-dropdown-menu-item:focus{outline:none}.ds-dropdown-menu-item:hover,.ds-dropdown-menu-item[data-active=true],.ds-dropdown-menu-item[data-selected=true],.ds-dropdown-menu-item[data-highlighted=true]{background:var(--ds-control-item-bg-hover)}.ds-dropdown-menu-item:active,.ds-dropdown-menu-item:focus,.ds-dropdown-menu-item[data-focus=true]{background:var(--ds-control-item-bg-active);font-weight:500}.ds-dropdown-menu:not(.ds-dropdown-menu-show-checkbox) .ds-dropdown-menu-item[data-actual-selected=true]{background:var(--ds-control-item-bg-active);font-weight:500}.ds-dropdown-menu-item[data-disabled=true]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-dropdown-menu-item[data-danger=true]{color:var(--ds-color-error)}.ds-dropdown-menu-item[data-danger=true]:hover{background:var(--ds-color-error-bg)}.ds-dropdown-menu-item[data-danger=true]:active,.ds-dropdown-menu-item[data-danger=true]:focus,.ds-dropdown-menu-item[data-danger=true][data-focus=true]{background:var(--ds-color-error-bg-hover)}.ds-dropdown-menu-item .ds-checkbox-wrapper{margin-right:.5rem}.ds-dropdown-menu-item .ds-dropdown-menu-item-icon{display:flex;align-items:center;justify-content:center;margin-right:.5rem;font-size:1rem;color:var(--ds-color-icon)}[data-danger=true] .ds-dropdown-menu-item .ds-dropdown-menu-item-icon{color:var(--ds-color-error)}}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as g, Fragment as k, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as x } from "react";
|
|
4
|
+
import { Command as E } from "../cmdk/index.js";
|
|
5
|
+
import { Menu as L } from "@base-ui-components/react/menu";
|
|
6
|
+
import './item.css';/* empty css */
|
|
7
|
+
import { Checkbox as h } from "antd";
|
|
8
|
+
import { useCls as b } from "../utils/antdUtils.js";
|
|
9
|
+
import { clsx as p } from "../utils/cn.js";
|
|
10
|
+
const C = ({
|
|
11
|
+
item: o,
|
|
12
|
+
inCombobox: u = !1,
|
|
13
|
+
selected: i = !1,
|
|
14
|
+
itemRender: t,
|
|
15
|
+
itemProps: w = {},
|
|
16
|
+
classNames: n,
|
|
17
|
+
onSelect: I,
|
|
18
|
+
showCheckbox: e,
|
|
19
|
+
indeterminate: M,
|
|
20
|
+
renderAsNativeElement: O
|
|
21
|
+
}) => {
|
|
22
|
+
const d = b(), y = x(
|
|
23
|
+
() => u ? E.Item : L.Item,
|
|
24
|
+
[u]
|
|
25
|
+
), f = x(() => ({
|
|
26
|
+
className: p(
|
|
27
|
+
d("dropdown-menu-item", u && "dropdown-menu-item-combobox"),
|
|
28
|
+
n == null ? void 0 : n.item,
|
|
29
|
+
o.className
|
|
30
|
+
),
|
|
31
|
+
disabled: o.disabled,
|
|
32
|
+
"data-danger": o.danger,
|
|
33
|
+
"data-actual-selected": i,
|
|
34
|
+
ref: o.ref,
|
|
35
|
+
onClick: o.onClick,
|
|
36
|
+
onMouseEnter: o.onMouseEnter,
|
|
37
|
+
onMouseLeave: o.onMouseLeave,
|
|
38
|
+
onMouseOver: o.onMouseOver,
|
|
39
|
+
onMouseOut: o.onMouseOut,
|
|
40
|
+
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
41
|
+
render: t ? (j) => t(o, j) : void 0,
|
|
42
|
+
children: u ? /* @__PURE__ */ g(k, { children: [
|
|
43
|
+
e && /* @__PURE__ */ r(
|
|
44
|
+
h,
|
|
45
|
+
{
|
|
46
|
+
checked: i,
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
indeterminate: M
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
o.icon && /* @__PURE__ */ r(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: p(
|
|
55
|
+
d("dropdown-menu-item-icon"),
|
|
56
|
+
n == null ? void 0 : n.itemIcon
|
|
57
|
+
),
|
|
58
|
+
children: o.icon
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ r(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
className: p(
|
|
65
|
+
d("dropdown-menu-item-text"),
|
|
66
|
+
n == null ? void 0 : n.itemText
|
|
67
|
+
),
|
|
68
|
+
children: o.label
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }) : /* @__PURE__ */ g(k, { children: [
|
|
72
|
+
e && /* @__PURE__ */ r(
|
|
73
|
+
h,
|
|
74
|
+
{
|
|
75
|
+
checked: i,
|
|
76
|
+
tabIndex: -1,
|
|
77
|
+
indeterminate: M
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
o.icon && /* @__PURE__ */ r(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
className: p(
|
|
84
|
+
d("dropdown-menu-item-icon"),
|
|
85
|
+
n == null ? void 0 : n.itemIcon
|
|
86
|
+
),
|
|
87
|
+
children: o.icon
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
"span",
|
|
92
|
+
{
|
|
93
|
+
className: p(
|
|
94
|
+
d("dropdown-menu-item-text"),
|
|
95
|
+
n == null ? void 0 : n.itemText
|
|
96
|
+
),
|
|
97
|
+
children: o.label
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] })
|
|
101
|
+
}), [
|
|
102
|
+
n == null ? void 0 : n.item,
|
|
103
|
+
n == null ? void 0 : n.itemIcon,
|
|
104
|
+
n == null ? void 0 : n.itemText,
|
|
105
|
+
d,
|
|
106
|
+
u,
|
|
107
|
+
M,
|
|
108
|
+
o,
|
|
109
|
+
t,
|
|
110
|
+
i,
|
|
111
|
+
e
|
|
112
|
+
]);
|
|
113
|
+
if (t)
|
|
114
|
+
return t(o, {
|
|
115
|
+
...f,
|
|
116
|
+
...w
|
|
117
|
+
});
|
|
118
|
+
const { render: v, ...T } = f;
|
|
119
|
+
return O ? v ? v(f) : /* @__PURE__ */ r("div", { onClick: I, ...T }) : /* @__PURE__ */ r(
|
|
120
|
+
y,
|
|
121
|
+
{
|
|
122
|
+
value: String(o.key),
|
|
123
|
+
onSelect: I,
|
|
124
|
+
...f
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
C as DropdownMenuItem
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=item.js.map
|