@bioturing/components 0.39.0 → 0.39.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/base-menu/index.js +3 -3
- package/dist/components/dropdown-menu/component.d.ts +4 -2
- package/dist/components/dropdown-menu/component.d.ts.map +1 -1
- package/dist/components/dropdown-menu/component.js +153 -154
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.js +6 -6
- package/dist/components/dropdown-menu/divider.js.map +1 -1
- package/dist/components/dropdown-menu/item.d.ts.map +1 -1
- package/dist/components/dropdown-menu/item.js +27 -26
- package/dist/components/dropdown-menu/item.js.map +1 -1
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/dropdown-menu/types.d.ts +2 -2
- package/dist/components/dropdown-menu/types.d.ts.map +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.js +72 -68
- package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-dropdown-menu-search{margin-bottom:.25rem}.ds-dropdown-menu-header{font-size:.75rem;font-weight:500;line-height:1rem;text-transform:uppercase;color:var(--ds-color-text-tertiary);padding:.75rem .75rem .25rem}.ds-dropdown-menu-header:first-child{padding-top:.5rem}.ds-dropdown-menu-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}.ds-dropdown-menu-match-trigger-width{width:min(var(--anchor-width),var(--available-width))}.ds-dropdown-menu-container{display:flex;flex-direction:column;flex-shrink:1;min-height:0}}
|
|
1
|
+
@layer components{.ds-dropdown-menu-search{margin-bottom:.25rem}.ds-dropdown-menu-header{font-size:.75rem;font-weight:500;line-height:1rem;text-transform:uppercase;color:var(--ds-color-text-tertiary);padding:.75rem .75rem .25rem}.ds-dropdown-menu-header:first-child{padding-top:.5rem}.ds-dropdown-menu-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}.ds-dropdown-menu-empty:empty{display:none}.ds-dropdown-menu-match-trigger-width{width:min(var(--anchor-width),var(--available-width))}.ds-dropdown-menu-container{display:flex;flex-direction:column;flex-shrink:1;min-height:0}}
|
|
@@ -81,8 +81,8 @@ export type DropdownMenuItemType = {
|
|
|
81
81
|
*/
|
|
82
82
|
className?: string;
|
|
83
83
|
};
|
|
84
|
-
export
|
|
84
|
+
export type DropdownMenuGroup = {
|
|
85
85
|
label: React.ReactNode | null;
|
|
86
86
|
items: DropdownMenuItemType[];
|
|
87
|
-
}
|
|
87
|
+
};
|
|
88
88
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAC5B;IACE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC;IACvD;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IACjE;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IACjE;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,CAAC;IAC/D;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;IAC7D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CAC9B,GACD;IACE;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAC5B;IACE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE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],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useDropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAMlE,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,oBAAoB,EAC1B,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,CAChB,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAC7C,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,EAAE,CAAC;CAC/E;AAED,eAAO,MAAM,eAAe,GAAI,kJAW7B,oBAAoB;;2BAGZ,oBAAoB,KAAK,MAAM,KAAK,MAAM;yBAqEzC,iBAAiB,SAAS,MAAM;CA8D3C,CAAC"}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useCallback as m, useMemo as
|
|
3
|
-
import { DropdownMenuItem as
|
|
4
|
-
import { DropdownMenuDivider as
|
|
5
|
-
import { Menu as
|
|
6
|
-
import { Command as L } from "../cmdk/index.js";
|
|
1
|
+
import { jsx as i, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as m, useMemo as L } from "react";
|
|
3
|
+
import { DropdownMenuItem as I } from "./item.js";
|
|
4
|
+
import { DropdownMenuDivider as j } from "./divider.js";
|
|
5
|
+
import { Menu as v, Combobox as f } from "@base-ui-components/react";
|
|
7
6
|
import './style.css';/* empty css */
|
|
8
|
-
import { useCls as
|
|
9
|
-
import { reactNodeToString as
|
|
7
|
+
import { useCls as k } from "../utils/antdUtils.js";
|
|
8
|
+
import { reactNodeToString as x } from "../utils/reactToString.js";
|
|
10
9
|
import { clsx as d } from "../utils/cn.js";
|
|
11
|
-
const
|
|
12
|
-
items:
|
|
13
|
-
inCombobox:
|
|
10
|
+
const J = ({
|
|
11
|
+
items: s,
|
|
12
|
+
inCombobox: n = !1,
|
|
14
13
|
classNames: o = {},
|
|
15
|
-
selectedItemKeys:
|
|
16
|
-
keepOpenOnSelect:
|
|
17
|
-
showCheckbox:
|
|
18
|
-
getItemKeywords:
|
|
19
|
-
onOpenChange:
|
|
14
|
+
selectedItemKeys: h,
|
|
15
|
+
keepOpenOnSelect: a,
|
|
16
|
+
showCheckbox: G = !1,
|
|
17
|
+
getItemKeywords: b = (l) => [String(l.key), x(l.label)],
|
|
18
|
+
onOpenChange: g,
|
|
20
19
|
itemRender: y,
|
|
21
20
|
itemLabelRender: M
|
|
22
21
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
(e, r,
|
|
25
|
-
|
|
22
|
+
const l = k(), p = m(
|
|
23
|
+
(e, r, t) => e.type === "item" ? /* @__PURE__ */ i(
|
|
24
|
+
I,
|
|
26
25
|
{
|
|
27
26
|
item: e,
|
|
28
|
-
inCombobox:
|
|
29
|
-
selected:
|
|
27
|
+
inCombobox: n,
|
|
28
|
+
selected: h?.includes(e.key),
|
|
30
29
|
afterSelect: () => {
|
|
31
|
-
|
|
30
|
+
a || g?.(!1);
|
|
32
31
|
},
|
|
33
32
|
itemRender: y,
|
|
34
|
-
showCheckbox:
|
|
35
|
-
getItemKeywords:
|
|
33
|
+
showCheckbox: G,
|
|
34
|
+
getItemKeywords: b,
|
|
36
35
|
itemLabelRender: M,
|
|
37
36
|
classNames: {
|
|
38
37
|
item: o.item,
|
|
@@ -40,85 +39,90 @@ const U = ({
|
|
|
40
39
|
itemSuffix: o.itemSuffix
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
|
-
r + "-" +
|
|
44
|
-
) : e.type === "divider" ? /* @__PURE__ */
|
|
45
|
-
|
|
42
|
+
r + "-" + t
|
|
43
|
+
) : e.type === "divider" ? /* @__PURE__ */ i(
|
|
44
|
+
j,
|
|
46
45
|
{
|
|
47
|
-
inCombobox:
|
|
46
|
+
inCombobox: n,
|
|
48
47
|
className: o?.divider
|
|
49
48
|
},
|
|
50
|
-
r + "-" +
|
|
49
|
+
r + "-" + t
|
|
51
50
|
) : null,
|
|
52
51
|
[
|
|
53
52
|
o,
|
|
54
53
|
y,
|
|
55
|
-
G,
|
|
56
|
-
u,
|
|
57
|
-
h,
|
|
58
|
-
s,
|
|
59
|
-
a,
|
|
60
54
|
g,
|
|
55
|
+
n,
|
|
56
|
+
a,
|
|
57
|
+
h,
|
|
58
|
+
G,
|
|
59
|
+
b,
|
|
61
60
|
M
|
|
62
61
|
]
|
|
63
|
-
),
|
|
64
|
-
(e, r) => /* @__PURE__ */
|
|
65
|
-
|
|
62
|
+
), D = m(
|
|
63
|
+
(e, r) => /* @__PURE__ */ w(
|
|
64
|
+
v.Group,
|
|
66
65
|
{
|
|
67
|
-
className: d(
|
|
66
|
+
className: d(l("dropdown-menu-group"), o?.group),
|
|
68
67
|
children: [
|
|
69
|
-
e.label && /* @__PURE__ */
|
|
70
|
-
|
|
68
|
+
e.label && /* @__PURE__ */ i(
|
|
69
|
+
v.GroupLabel,
|
|
71
70
|
{
|
|
72
71
|
className: d(
|
|
73
|
-
|
|
72
|
+
l("dropdown-menu-header"),
|
|
74
73
|
o?.groupLabel
|
|
75
74
|
),
|
|
76
|
-
children: /* @__PURE__ */
|
|
75
|
+
children: /* @__PURE__ */ i("span", { children: e.label })
|
|
77
76
|
}
|
|
78
77
|
),
|
|
79
|
-
e.items.map((
|
|
78
|
+
e.items.map((t, u) => p(t, r, u))
|
|
80
79
|
]
|
|
81
80
|
},
|
|
82
81
|
"group" + r
|
|
83
82
|
),
|
|
84
|
-
[
|
|
85
|
-
),
|
|
86
|
-
(e, r) => e.label ? /* @__PURE__ */
|
|
87
|
-
|
|
83
|
+
[l, o, p]
|
|
84
|
+
), S = m(
|
|
85
|
+
(e, r) => e.label ? /* @__PURE__ */ w(
|
|
86
|
+
f.Group,
|
|
88
87
|
{
|
|
89
|
-
className: d(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
className: d(l("dropdown-menu-group"), o?.group),
|
|
89
|
+
items: e.items,
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ i(
|
|
92
|
+
f.GroupLabel,
|
|
93
|
+
{
|
|
94
|
+
className: d(
|
|
95
|
+
l("dropdown-menu-header"),
|
|
96
|
+
o?.groupLabel
|
|
97
|
+
),
|
|
98
|
+
children: /* @__PURE__ */ i("span", { children: e.label })
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ i(f.Collection, { children: (t, u) => p(t, r, u) })
|
|
102
|
+
]
|
|
101
103
|
},
|
|
102
104
|
"group" + r
|
|
103
|
-
) : e.items.map((
|
|
104
|
-
[
|
|
105
|
+
) : e.items.map((t, u) => p(t, r, u)),
|
|
106
|
+
[l, o, p]
|
|
105
107
|
);
|
|
106
108
|
return {
|
|
107
|
-
itemGroups:
|
|
108
|
-
() =>
|
|
109
|
+
itemGroups: L(
|
|
110
|
+
() => s.reduce((e, r) => (e.length === 0 && r.type !== "header" && e.push({
|
|
109
111
|
label: null,
|
|
110
112
|
items: []
|
|
111
113
|
}), r.type === "header" ? e.push({
|
|
112
114
|
label: r.title,
|
|
113
115
|
items: []
|
|
114
|
-
}) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push(
|
|
115
|
-
|
|
116
|
+
}) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push({
|
|
117
|
+
...r
|
|
118
|
+
}), e), []),
|
|
119
|
+
[s]
|
|
116
120
|
),
|
|
117
|
-
renderMenuItem:
|
|
118
|
-
renderGroup:
|
|
121
|
+
renderMenuItem: p,
|
|
122
|
+
renderGroup: n ? S : D
|
|
119
123
|
};
|
|
120
124
|
};
|
|
121
125
|
export {
|
|
122
|
-
|
|
126
|
+
J as useDropdownMenu
|
|
123
127
|
};
|
|
124
128
|
//# sourceMappingURL=useDropdownMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Menu } from \"@base-ui-components/react\";\
|
|
1
|
+
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Combobox, Menu } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: 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 * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\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 * Function to extract keywords from the item for search filtering\n * @default (item) => [String(item.key), reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: DropdownMenuItemType & { type: \"item\" }) => string[];\n}\n\nexport const useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\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={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n afterSelect={() => {\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }}\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n itemLabelRender={itemLabelRender}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={inCombobox}\n className={classNames?.divider}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n inCombobox,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\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 renderGroupCombobox = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Combobox.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n items={group.items}\n >\n <Combobox.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Combobox.GroupLabel>\n <Combobox.Collection>\n {(item, i) => renderMenuItem(item, index, i)}\n </Combobox.Collection>\n </Combobox.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const itemGroups = useMemo(\n () =>\n 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({\n ...current,\n });\n }\n // Skip dividers\n return acc;\n }, []),\n [items]\n );\n return {\n itemGroups,\n renderMenuItem,\n renderGroup: inCombobox ? renderGroupCombobox : renderGroup,\n };\n};\n"],"names":["useDropdownMenu","items","inCombobox","classNames","selectedItemKeys","keepOpenOnSelect","showCheckbox","getItemKeywords","item","reactNodeToString","onOpenChange","itemRender","itemLabelRender","cls","useCls","renderMenuItem","useCallback","i","j","jsx","DropdownMenuItem","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupCombobox","Combobox","useMemo","acc","current"],"mappings":";;;;;;;;;AA+DO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,YAAAC,IAAa,CAAA;AAAA,EACb,kBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB,CAACC,MAAS,CAAC,OAAOA,EAAK,GAAG,GAAGC,EAAkBD,EAAK,KAAK,CAAC;AAAA,EAC5E,cAAAE;AAAA,EACA,YAAAC;AAAA,EACA,iBAAAC;AACF,MAA4B;AAC1B,QAAMC,IAAMC,EAAA,GACNC,IAAiBC;AAAA,IACrB,CAACR,GAA4BS,GAAWC,MAClCV,EAAK,SAAS,SAEd,gB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