@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.
@@ -1,7 +1,7 @@
1
- import { BaseMenuPopup as e, BaseMenuRoot as o, BaseMenuDivider as s, BaseMenuList as i } from "./component.js";
1
+ import { BaseMenuRoot as e, BaseMenuPopup as o, BaseMenuDivider as s, BaseMenuList as i } from "./component.js";
2
2
  const u = {
3
- Root: o,
4
- Popup: e,
3
+ Root: e,
4
+ Popup: o,
5
5
  List: i,
6
6
  Divider: s
7
7
  };
@@ -1,6 +1,5 @@
1
1
  import { Menu } from '@base-ui-components/react/menu';
2
2
  import { PopoverProps } from 'antd/es/popover';
3
- import { Command } from '../cmdk';
4
3
  import { PopupPanelSize } from '../popup-panel/constants';
5
4
  import { DropdownMenuItemType } from './types';
6
5
  import { UseDropdownMenuProps } from './useDropdownMenu';
@@ -60,7 +59,10 @@ export interface DropdownMenuProps extends Omit<UseDropdownMenuProps, "className
60
59
  /**
61
60
  * Search placeholder
62
61
  */
63
- searchProps?: Omit<React.ComponentProps<typeof Command.Input>, "size" | "ref">;
62
+ searchProps?: {
63
+ placeholder?: string;
64
+ className?: string;
65
+ };
64
66
  /**
65
67
  * Whether to match the width of the popup with the trigger
66
68
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAEtD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMlC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAmB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAM1E,MAAM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CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEvC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,OAAO,cAAc,CAAC;IAC5C;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,eAAO,MAAM,YAAY,GAAI,sWA0B1B,iBAAiB,4CA2KnB,CAAC"}
@@ -1,176 +1,175 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as e } from "react/jsx-runtime";
3
- import { useRef as L, useCallback as U, createElement as W } from "react";
4
- import { Menu as q } from "@base-ui-components/react/menu";
5
- import { Popover as H } from "@base-ui-components/react/popover";
6
- import { Command as i } from "../cmdk/index.js";
7
- import { FormItemInputContext as J } from "antd/es/form/context";
8
- import { PopupPanelSize as I } from "../popup-panel/constants.js";
9
- import { useDropdownMenu as Q } from "./useDropdownMenu.js";
10
- import { BaseMenu as x } from "../base-menu/index.js";
11
- import { parseAntdPlacement as X } from "../utils/placement.js";
12
- import { Input as Y } from "../input/component.js";
13
- import { ScrollArea as O } from "../scroll-area/component.js";
14
- import { DROPDOWN_COLLISION_AVOIDANCE as Z } from "../utils/constants.js";
15
- import { useControlledState as $ } from "../hooks/useControlledState.js";
16
- import { useCls as K } from "../utils/antdUtils.js";
17
- import { useTheme as ee } from "../theme-provider/context/themeStore.js";
18
- import { clsx as s } from "../utils/cn.js";
19
- const ve = ({
20
- children: b,
21
- items: N,
22
- placement: S,
23
- openOnHover: A,
24
- open: D,
25
- onOpenChange: E,
26
- defaultOpen: M = !1,
27
- className: R,
28
- itemRender: k,
29
- classNames: o,
30
- size: f = "auto",
31
- showSearch: n,
32
- inCombobox: g,
33
- searchProps: C = {
2
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
3
+ import { Menu as d } from "@base-ui-components/react/menu";
4
+ import { Combobox as t } from "@base-ui-components/react/combobox";
5
+ import { useRef as J, useState as Q, useCallback as X } from "react";
6
+ import { FormItemInputContext as Y } from "antd/es/form/context";
7
+ import { PopupPanelSize as T } from "../popup-panel/constants.js";
8
+ import { useDropdownMenu as Z } from "./useDropdownMenu.js";
9
+ import { BaseMenu as R } from "../base-menu/index.js";
10
+ import { parseAntdPlacement as $ } from "../utils/placement.js";
11
+ import { Input as ee } from "../input/component.js";
12
+ import { ScrollArea as A } from "../scroll-area/component.js";
13
+ import { DROPDOWN_COLLISION_AVOIDANCE as oe } from "../utils/constants.js";
14
+ import { useControlledState as re } from "../hooks/useControlledState.js";
15
+ import { useCls as ne } from "../utils/antdUtils.js";
16
+ import { useTheme as te } from "../theme-provider/context/themeStore.js";
17
+ import { clsx as u } from "../utils/cn.js";
18
+ import { reactNodeToString as ie } from "../utils/reactToString.js";
19
+ const Ne = ({
20
+ children: D,
21
+ items: M,
22
+ placement: V,
23
+ openOnHover: E,
24
+ open: j,
25
+ onOpenChange: k,
26
+ defaultOpen: B = !1,
27
+ className: G,
28
+ itemRender: L,
29
+ classNames: r,
30
+ size: P = "auto",
31
+ showSearch: p,
32
+ inCombobox: w,
33
+ searchProps: i = {
34
34
  placeholder: "Search..."
35
35
  },
36
- popupMatchTriggerWidth: y,
37
- beforeList: d,
38
- afterList: p,
39
- keepOpenOnSelect: B,
40
- highlightedItemKey: l,
41
- selectedItemKeys: j,
42
- getItemKeywords: G,
43
- showCheckbox: w,
44
- itemLabelRender: T
36
+ popupMatchTriggerWidth: _,
37
+ beforeList: c,
38
+ afterList: a,
39
+ keepOpenOnSelect: z,
40
+ highlightedItemKey: me,
41
+ selectedItemKeys: F,
42
+ getItemKeywords: K,
43
+ showCheckbox: C,
44
+ itemLabelRender: U
45
45
  }) => {
46
- const V = typeof g == "boolean" ? g : n, [_, v] = $(
47
- D,
48
- E,
49
- M
50
- ), r = K(), { className: P } = ee(), h = X(S), z = L(null), { itemGroups: u, renderGroup: a } = Q({
51
- items: N,
52
- keepOpenOnSelect: B,
53
- selectedItemKeys: j,
54
- showCheckbox: w,
55
- getItemKeywords: G,
56
- itemLabelRender: T,
57
- itemRender: k,
58
- inCombobox: V,
59
- onOpenChange: v,
46
+ const W = typeof w == "boolean" ? w : p, [S, s] = re(
47
+ j,
48
+ k,
49
+ B
50
+ ), n = ne(), { className: v } = te(), x = $(V), q = J(null), { itemGroups: f, renderGroup: g } = Z({
51
+ items: M,
52
+ keepOpenOnSelect: z,
53
+ selectedItemKeys: F,
54
+ showCheckbox: C,
55
+ getItemKeywords: K,
56
+ itemLabelRender: U,
57
+ itemRender: L,
58
+ inCombobox: W,
59
+ onOpenChange: s,
60
60
  classNames: {
61
- item: o?.item,
62
- itemIcon: o?.itemIcon,
63
- itemSuffix: o?.itemSuffix,
64
- group: o?.group,
65
- groupLabel: o?.groupLabel,
66
- divider: o?.divider
61
+ item: r?.item,
62
+ itemIcon: r?.itemIcon,
63
+ itemSuffix: r?.itemSuffix,
64
+ group: r?.group,
65
+ groupLabel: r?.groupLabel,
66
+ divider: r?.divider
67
67
  }
68
- }), F = U(
69
- () => n ? /* @__PURE__ */ m(
70
- i,
71
- {
72
- className: r("dropdown-menu-container"),
73
- disablePointerSelection: n,
74
- defaultValue: l ? String(l) : void 0,
75
- children: [
76
- /* @__PURE__ */ e(J.Provider, { value: {}, children: /* @__PURE__ */ W(
77
- i.Input,
68
+ }), [h, H] = Q(""), I = X(
69
+ () => p ? /* @__PURE__ */ l("div", { className: n("dropdown-menu-container"), children: [
70
+ /* @__PURE__ */ e(Y.Provider, { value: {}, children: /* @__PURE__ */ e(
71
+ t.Input,
72
+ {
73
+ placeholder: i?.placeholder || "Search",
74
+ render: ({ ref: o, ...b }) => /* @__PURE__ */ e(
75
+ ee,
78
76
  {
79
- ...C,
80
- key: "search",
81
- render: /* @__PURE__ */ e(
82
- Y,
83
- {
84
- allowClear: !0,
85
- className: r("dropdown-menu-search"),
86
- placeholder: "Search"
87
- }
77
+ ...b,
78
+ ref: (m) => {
79
+ if (!m || !m.input) return;
80
+ o(m.input);
81
+ },
82
+ allowClear: !0,
83
+ placeholder: i?.placeholder || "Search",
84
+ value: h,
85
+ onChange: (m) => H(m.target.value),
86
+ className: u(
87
+ n("dropdown-menu-search"),
88
+ i?.className
88
89
  )
89
90
  }
90
- ) }),
91
- d,
92
- /* @__PURE__ */ e(O, { fadeEdges: !0, children: /* @__PURE__ */ m(i.List, { className: r("dropdown-menu-list"), children: [
93
- /* @__PURE__ */ e(i.Empty, { className: r("dropdown-menu-empty"), children: "No results found." }),
94
- u.map(a)
95
- ] }) }),
96
- p
97
- ]
98
- }
99
- ) : /* @__PURE__ */ m("div", { className: r("dropdown-menu-container"), children: [
100
- d,
101
- /* @__PURE__ */ e(O, { fadeEdges: !0, children: u.map(a) }),
102
- p
91
+ ),
92
+ ...i
93
+ },
94
+ "search"
95
+ ) }),
96
+ c,
97
+ /* @__PURE__ */ l(A, { fadeEdges: !0, children: [
98
+ /* @__PURE__ */ e(t.Empty, { className: n("dropdown-menu-empty"), children: "No results found." }),
99
+ /* @__PURE__ */ e(t.List, { className: n("dropdown-menu-list"), children: (o, b) => g(o, b) })
100
+ ] }),
101
+ a
102
+ ] }) : /* @__PURE__ */ l("div", { className: n("dropdown-menu-container"), children: [
103
+ c,
104
+ /* @__PURE__ */ e(A, { fadeEdges: !0, children: f.map(g) }),
105
+ a
103
106
  ] }),
104
107
  [
105
- n,
106
- r,
107
- l,
108
- C,
109
- d,
110
- u,
111
108
  p,
112
- a
109
+ n,
110
+ i,
111
+ h,
112
+ c,
113
+ a,
114
+ f,
115
+ g
113
116
  ]
114
- ), t = n ? H : q;
115
- return /* @__PURE__ */ m(
117
+ ), N = {
118
+ render: D,
119
+ ref: q,
120
+ nativeButton: !1,
121
+ openOnHover: E,
122
+ className: u(
123
+ n("dropdown-menu-trigger"),
124
+ r?.trigger,
125
+ v
126
+ )
127
+ }, y = {
128
+ side: x.side,
129
+ align: x.align,
130
+ sideOffset: 4,
131
+ className: u(
132
+ n("dropdown-menu-root"),
133
+ v,
134
+ r?.root
135
+ ),
136
+ collisionAvoidance: oe,
137
+ render: (o) => /* @__PURE__ */ e(R.Root, { ...o })
138
+ }, O = {
139
+ className: u(
140
+ n(
141
+ "dropdown-menu",
142
+ C && "dropdown-menu-show-checkbox",
143
+ _ && "dropdown-menu-match-trigger-width"
144
+ ),
145
+ G,
146
+ r?.popup
147
+ ),
148
+ style: {
149
+ "--size-width": P in T ? T[P] : void 0
150
+ },
151
+ render: (o) => /* @__PURE__ */ e(R.Popup, { ...o })
152
+ };
153
+ return p ? /* @__PURE__ */ l(
116
154
  t.Root,
117
155
  {
118
- open: _,
119
- onOpenChange: v,
156
+ open: S,
157
+ onOpenChange: s,
158
+ items: f,
159
+ itemToStringLabel: (o) => o.type == "item" ? ie(o.label) : "",
160
+ itemToStringValue: (o) => o.type == "item" ? String(o.key) : "",
161
+ inputValue: h,
120
162
  children: [
121
- /* @__PURE__ */ e(
122
- t.Trigger,
123
- {
124
- render: b,
125
- ref: z,
126
- nativeButton: !1,
127
- openOnHover: A,
128
- className: s(
129
- r("dropdown-menu-trigger"),
130
- o?.trigger,
131
- P
132
- )
133
- }
134
- ),
135
- /* @__PURE__ */ e(t.Portal, { children: /* @__PURE__ */ e(
136
- t.Positioner,
137
- {
138
- side: h.side,
139
- align: h.align,
140
- sideOffset: 4,
141
- className: s(
142
- r("dropdown-menu-root"),
143
- P,
144
- o?.root
145
- ),
146
- collisionAvoidance: Z,
147
- render: (c) => /* @__PURE__ */ e(x.Root, { ...c }),
148
- children: /* @__PURE__ */ e(
149
- t.Popup,
150
- {
151
- className: s(
152
- r(
153
- "dropdown-menu",
154
- w && "dropdown-menu-show-checkbox",
155
- y && "dropdown-menu-match-trigger-width"
156
- ),
157
- R,
158
- o?.popup
159
- ),
160
- style: {
161
- "--size-width": f in I ? I[f] : void 0
162
- },
163
- render: (c) => /* @__PURE__ */ e(x.Popup, { ...c }),
164
- children: F()
165
- }
166
- )
167
- }
168
- ) })
163
+ /* @__PURE__ */ e(t.Trigger, { ...N }),
164
+ /* @__PURE__ */ e(t.Portal, { children: /* @__PURE__ */ e(t.Positioner, { ...y, children: /* @__PURE__ */ e(t.Popup, { ...O, children: I() }) }) })
169
165
  ]
170
166
  }
171
- );
167
+ ) : /* @__PURE__ */ l(d.Root, { open: S, onOpenChange: s, children: [
168
+ /* @__PURE__ */ e(d.Trigger, { ...N }),
169
+ /* @__PURE__ */ e(d.Portal, { children: /* @__PURE__ */ e(d.Positioner, { ...y, children: /* @__PURE__ */ e(d.Popup, { ...O, children: I() }) }) })
170
+ ] });
172
171
  };
173
172
  export {
174
- ve as DropdownMenu
173
+ Ne as DropdownMenu
175
174
  };
176
175
  //# 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 { 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 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\";\n\nimport { DropdownMenuItemType } from \"./types\";\nimport { useDropdownMenu, UseDropdownMenuProps } from \"./useDropdownMenu\";\nimport { useControlledState } from \"../hooks\";\n\nimport { useTheme } from \"../theme-provider\";\nimport { BaseMenu } from \"../base-menu\";\n\nexport interface DropdownMenuProps\n extends Omit<UseDropdownMenuProps, \"classNames\"> {\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 * Default open state of the dropdown\n */\n defaultOpen?: boolean;\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 itemIcon?: string;\n itemText?: string;\n positioner?: string;\n } & UseDropdownMenuProps[\"classNames\"];\n\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 * 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\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n defaultOpen = false,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n inCombobox: inComboboxProp,\n searchProps = {\n placeholder: \"Search...\",\n },\n popupMatchTriggerWidth,\n beforeList,\n afterList,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n getItemKeywords,\n showCheckbox,\n itemLabelRender,\n}: DropdownMenuProps) => {\n const inCombobox =\n typeof inComboboxProp === \"boolean\" ? inComboboxProp : showSearch;\n const [open, onOpenChange] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen\n );\n const cls = useCls();\n const { className: themeClassName } = useTheme();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { itemGroups, renderGroup } = useDropdownMenu({\n items,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n itemRender,\n inCombobox,\n onOpenChange,\n classNames: {\n item: classNames?.item,\n itemIcon: classNames?.itemIcon,\n itemSuffix: classNames?.itemSuffix,\n group: classNames?.group,\n groupLabel: classNames?.groupLabel,\n divider: classNames?.divider,\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 // filter={(value, search, keywords) => {\n // console.log({ value, search, keywords });\n // const extendValue = value + \" \" + keywords.join(\" \");\n // if (extendValue.toLowerCase().includes(search.toLowerCase()))\n // return 1;\n // return 0;\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(renderGroup)}\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 afterList,\n renderGroup,\n ]\n );\n const BaseComponent = showSearch ? Popover : Menu;\n\n return (\n <BaseComponent.Root\n open={open}\n onOpenChange={onOpenChange}\n >\n <BaseComponent.Trigger\n render={children}\n ref={buttonRef}\n nativeButton={false}\n openOnHover={openOnHover}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n themeClassName\n )}\n />\n <BaseComponent.Portal>\n <BaseComponent.Positioner\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n className={clsx(\n cls(\"dropdown-menu-root\"),\n themeClassName,\n classNames?.root\n )}\n collisionAvoidance={DROPDOWN_COLLISION_AVOIDANCE}\n render={(props) => <BaseMenu.Root {...props} />}\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 )}\n style={\n {\n \"--size-width\":\n size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n render={(props) => <BaseMenu.Popup {...props} />}\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","defaultOpen","className","itemRender","classNames","size","showSearch","inComboboxProp","searchProps","popupMatchTriggerWidth","beforeList","afterList","keepOpenOnSelect","highlightedItemKey","selectedItemKeys","getItemKeywords","showCheckbox","itemLabelRender","inCombobox","open","onOpenChange","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","renderGroup","useDropdownMenu","renderMenuInner","useCallback","jsxs","Command","jsx","FormItemInputContext","createElement","Input","ScrollArea","BaseComponent","Popover","Menu","clsx","DROPDOWN_COLLISION_AVOIDANCE","props","BaseMenu","PopupPanelSize"],"mappings":";;;;;;;;;;;;;;;;;;AAuGO,MAAMA,KAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,aAAAC,IAAc;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,aAAAC,IAAc;AAAA,IACZ,aAAa;AAAA,EAAA;AAAA,EAEf,wBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC;AACF,MAAyB;AACvB,QAAMC,IACJ,OAAOX,KAAmB,YAAYA,IAAiBD,GACnD,CAACa,GAAMC,CAAY,IAAIC;AAAA,IAC3BtB;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,GAEIqB,IAAMC,EAAA,GACN,EAAE,WAAWC,EAAA,IAAmBC,GAAA,GAChCC,IAAkBC,EAAmB9B,CAAS,GAC9C+B,IAAYC,EAA0B,IAAI,GAC1C,EAAE,YAAAC,GAAY,aAAAC,EAAA,IAAgBC,EAAgB;AAAA,IAClD,OAAApC;AAAA,IACA,kBAAAgB;AAAA,IAEA,kBAAAE;AAAA,IACA,cAAAE;AAAA,IACA,iBAAAD;AAAA,IACA,iBAAAE;AAAA,IACA,YAAAd;AAAA,IACA,YAAAe;AAAA,IACA,cAAAE;AAAA,IACA,YAAY;AAAA,MACV,MAAMhB,GAAY;AAAA,MAClB,UAAUA,GAAY;AAAA,M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AAAA,YAAA;AAAA,UACnB;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
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 { Combobox } from \"@base-ui-components/react/combobox\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef, useState, RefCallback } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n reactNodeToString,\n useCls,\n} from \"../utils\";\nimport { ScrollArea } from \"../scroll-area\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\n\n// Import component-specific styles\nimport { PopupPanelSize } from \"../popup-panel/constants\";\n\nimport { DropdownMenuItemType } from \"./types\";\nimport { useDropdownMenu, UseDropdownMenuProps } from \"./useDropdownMenu\";\nimport { useControlledState } from \"../hooks\";\n\nimport { useTheme } from \"../theme-provider\";\nimport { BaseMenu } from \"../base-menu\";\n\nimport { Input } from \"../input\";\n\nexport interface DropdownMenuProps\n extends Omit<UseDropdownMenuProps, \"classNames\"> {\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 * Default open state of the dropdown\n */\n defaultOpen?: boolean;\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 itemIcon?: string;\n itemText?: string;\n positioner?: string;\n } & UseDropdownMenuProps[\"classNames\"];\n\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?: {\n placeholder?: string;\n className?: string;\n };\n /**\n * Whether to match the width of the popup with the trigger\n * @default false\n */\n popupMatchTriggerWidth?: boolean;\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\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n defaultOpen = false,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n inCombobox: inComboboxProp,\n searchProps = {\n placeholder: \"Search...\",\n },\n popupMatchTriggerWidth,\n beforeList,\n afterList,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n getItemKeywords,\n showCheckbox,\n itemLabelRender,\n}: DropdownMenuProps) => {\n const inCombobox =\n typeof inComboboxProp === \"boolean\" ? inComboboxProp : showSearch;\n const [open, onOpenChange] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen\n );\n const cls = useCls();\n const { className: themeClassName } = useTheme();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { itemGroups, renderGroup } = useDropdownMenu({\n items,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n itemRender,\n inCombobox,\n onOpenChange,\n classNames: {\n item: classNames?.item,\n itemIcon: classNames?.itemIcon,\n itemSuffix: classNames?.itemSuffix,\n group: classNames?.group,\n groupLabel: classNames?.groupLabel,\n divider: classNames?.divider,\n },\n });\n\n const [searchValue, setSearchValue] = useState(\"\");\n\n const renderMenuInner = useCallback(\n () =>\n showSearch ? (\n <div className={cls(\"dropdown-menu-container\")}>\n <FormItemInputContext.Provider value={{}}>\n <Combobox.Input\n key=\"search\"\n placeholder={searchProps?.placeholder || \"Search\"}\n render={({ ref, ...props }) => (\n <Input\n {...props}\n ref={(antdInputRef) => {\n if (!antdInputRef || !antdInputRef.input) return;\n const comboboxRef = ref as RefCallback<HTMLInputElement>;\n comboboxRef(antdInputRef.input);\n }}\n allowClear\n placeholder={searchProps?.placeholder || \"Search\"}\n value={searchValue}\n onChange={(e) => setSearchValue(e.target.value)}\n className={clsx(\n cls(\"dropdown-menu-search\"),\n searchProps?.className\n )}\n />\n )}\n {...searchProps}\n />\n </FormItemInputContext.Provider>\n {beforeList}\n <ScrollArea fadeEdges>\n <Combobox.Empty className={cls(\"dropdown-menu-empty\")}>\n No results found.\n </Combobox.Empty>\n <Combobox.List className={cls(\"dropdown-menu-list\")}>\n {(group, i) => renderGroup(group, i)}\n </Combobox.List>\n </ScrollArea>\n {afterList}\n </div>\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 searchProps,\n searchValue,\n beforeList,\n afterList,\n itemGroups,\n renderGroup,\n ]\n );\n\n const commonTriggerProps = {\n render: children,\n ref: buttonRef,\n nativeButton: false,\n openOnHover,\n className: clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n themeClassName\n ),\n };\n\n const commonPositionerProps = {\n side: baseUIPlacement.side,\n align: baseUIPlacement.align,\n sideOffset: 4,\n className: clsx(\n cls(\"dropdown-menu-root\"),\n themeClassName,\n classNames?.root\n ),\n collisionAvoidance: DROPDOWN_COLLISION_AVOIDANCE,\n render: (props: React.ComponentPropsWithoutRef<\"div\">) => (\n <BaseMenu.Root {...props} />\n ),\n };\n\n const commonPopupProps = {\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 ),\n style: {\n \"--size-width\": size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties,\n render: (props: React.ComponentPropsWithoutRef<\"div\">) => (\n <BaseMenu.Popup {...props} />\n ),\n };\n\n return showSearch ? (\n <Combobox.Root<DropdownMenuItemType>\n open={open}\n onOpenChange={onOpenChange}\n items={itemGroups}\n itemToStringLabel={(item) =>\n item.type == \"item\" ? reactNodeToString(item.label) : \"\"\n }\n itemToStringValue={(item) =>\n item.type == \"item\" ? String(item.key) : \"\"\n }\n inputValue={searchValue}\n >\n <Combobox.Trigger {...commonTriggerProps} />\n <Combobox.Portal>\n <Combobox.Positioner {...commonPositionerProps}>\n <Combobox.Popup {...commonPopupProps}>\n {renderMenuInner()}\n </Combobox.Popup>\n </Combobox.Positioner>\n </Combobox.Portal>\n </Combobox.Root>\n ) : (\n <Menu.Root open={open} onOpenChange={onOpenChange}>\n <Menu.Trigger {...commonTriggerProps} />\n <Menu.Portal>\n <Menu.Positioner {...commonPositionerProps}>\n <Menu.Popup {...commonPopupProps}>{renderMenuInner()}</Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n </Menu.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","defaultOpen","className","itemRender","classNames","size","showSearch","inComboboxProp","searchProps","popupMatchTriggerWidth","beforeList","afterList","keepOpenOnSelect","highlightedItemKey","selectedItemKeys","getItemKeywords","showCheckbox","itemLabelRender","inCombobox","open","onOpenChange","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","renderGroup","useDropdownMenu","searchValue","setSearchValue","useState","renderMenuInner","useCallback","jsxs","jsx","FormItemInputContext","Combobox","ref","props","Input","antdInputRef","e","clsx","ScrollArea","group","i","commonTriggerProps","commonPositionerProps","DROPDOWN_COLLISION_AVOIDANCE","BaseMenu","commonPopupProps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,CAAC2B,MAClBA,EAAK,QAAQ,SAASC,GAAkBD,EAAK,KAAK,IAAI;AAAA,MAExD,mBAAmB,CAACA,MAClBA,EAAK,QAAQ,SAAS,OAAOA,EAAK,GAAG,IAAI;AAAA,MAE3C,YAAYxB;AAAA,MAEZ,UAAA;AAAA,QAAA,gBAAAM,EAACE,EAAS,SAAT,EAAkB,GAAGU,EAAA,CAAoB;AAAA,0BACzCV,EAAS,QAAT,EACC,UAAA,gBAAAF,EAACE,EAAS,YAAT,EAAqB,GAAGW,GACvB,UAAA,gBAAAb,EAACE,EAAS,OAAT,EAAgB,GAAGc,GACjB,UAAAnB,EAAA,GACH,GACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAGF,gBAAAE,EAACqB,EAAK,MAAL,EAAU,MAAAxC,GAAY,cAAAC,GACrB,UAAA;AAAA,IAAA,gBAAAmB,EAACoB,EAAK,SAAL,EAAc,GAAGR,EAAA,CAAoB;AAAA,sBACrCQ,EAAK,QAAL,EACC,UAAA,gBAAApB,EAACoB,EAAK,YAAL,EAAiB,GAAGP,GACnB,UAAA,gBAAAb,EAACoB,EAAK,OAAL,EAAY,GAAGJ,GAAmB,UAAAnB,EAAA,GAAkB,GACvD,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,23 +1,23 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { Command as p } from "../cmdk/index.js";
3
- import { Menu as i } from "@base-ui-components/react/menu";
2
+ import { Combobox as n } from "@base-ui-components/react/combobox";
3
+ import { Menu as p } from "@base-ui-components/react/menu";
4
4
  import { BaseMenu as s } from "../base-menu/index.js";
5
5
  import { useCls as a } from "../utils/antdUtils.js";
6
6
  import { clsx as d } from "../utils/cn.js";
7
- const x = ({
7
+ const v = ({
8
8
  inCombobox: o,
9
9
  className: e
10
10
  }) => {
11
- const m = a(), t = o ? p.Separator : i.Separator;
11
+ const m = a(), t = o ? n.Separator : p.Separator;
12
12
  return /* @__PURE__ */ r(
13
13
  t,
14
14
  {
15
15
  className: d(m("dropdown-menu-divider"), e),
16
- render: (n) => /* @__PURE__ */ r(s.Divider, { ...n })
16
+ render: (i) => /* @__PURE__ */ r(s.Divider, { ...i })
17
17
  }
18
18
  );
19
19
  };
20
20
  export {
21
- x as DropdownMenuDivider
21
+ v as DropdownMenuDivider
22
22
  };
23
23
  //# sourceMappingURL=divider.js.map
@@ -1 +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\";\nimport { BaseMenu } from \"../base-menu\";\nimport { HTMLAttributes } from \"react\";\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\n className={clsx(cls(\"dropdown-menu-divider\"), className)}\n render={(props: HTMLAttributes<HTMLDivElement>) => (\n <BaseMenu.Divider {...props} />\n )}\n />\n );\n};\n"],"names":["DropdownMenuDivider","inCombobox","className","cls","useCls","MenuSeparator","Command","Menu","jsx","clsx","props","BaseMenu"],"mappings":";;;;;;AAWO,MAAMA,IAAsB,CAAC;AAAA,EAClC,YAAAC;AAAA,EACA,WAAAC;AACF,MAAgC;AAC9B,QAAMC,IAAMC,EAAA,GACNC,IAAgBJ,IAAaK,EAAQ,YAAYC,EAAK;AAE5D,SACE,gBAAAC;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,WAAWI,EAAKN,EAAI,uBAAuB,GAAGD,CAAS;AAAA,MACvD,QAAQ,CAACQ,MACP,gBAAAF,EAACG,EAAS,SAAT,EAAkB,GAAGD,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAIrC;"}
1
+ {"version":3,"file":"divider.js","sources":["../../../src/components/dropdown-menu/divider.tsx"],"sourcesContent":["import { Combobox } from \"@base-ui-components/react/combobox\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { clsx, useCls } from \"../utils\";\nimport { BaseMenu } from \"../base-menu\";\nimport { HTMLAttributes } from \"react\";\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 ? Combobox.Separator : Menu.Separator;\n\n return (\n <MenuSeparator\n className={clsx(cls(\"dropdown-menu-divider\"), className)}\n render={(props: HTMLAttributes<HTMLDivElement>) => (\n <BaseMenu.Divider {...props} />\n )}\n />\n );\n};\n"],"names":["DropdownMenuDivider","inCombobox","className","cls","useCls","MenuSeparator","Combobox","Menu","jsx","clsx","props","BaseMenu"],"mappings":";;;;;;AAWO,MAAMA,IAAsB,CAAC;AAAA,EAClC,YAAAC;AAAA,EACA,WAAAC;AACF,MAAgC;AAC9B,QAAMC,IAAMC,EAAA,GACNC,IAAgBJ,IAAaK,EAAS,YAAYC,EAAK;AAE7D,SACE,gBAAAC;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,WAAWI,EAAKN,EAAI,uBAAuB,GAAGD,CAAS;AAAA,MACvD,QAAQ,CAACQ,MACP,gBAAAF,EAACG,EAAS,SAAT,EAAkB,GAAGD,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAIrC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/item.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAOzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKpD,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C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AK,MAAM,EAAE,CAAC;CAC/E;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsH5D,CAAC"}
@@ -1,27 +1,27 @@
1
1
  "use client";
2
- import { jsx as c } from "react/jsx-runtime";
3
- import { useCallback as i, useMemo as x } from "react";
4
- import { Command as y } from "../cmdk/index.js";
2
+ import { jsx as f } from "react/jsx-runtime";
3
+ import { useCallback as g, useMemo as i } from "react";
4
+ import { Combobox as x } from "@base-ui-components/react/combobox";
5
5
  import { Menu as O } from "@base-ui-components/react/menu";
6
6
  import { BaseMenuItem as S } from "../base-menu/item.js";
7
- import C from "../utils/createSyntheticClickEvent.js";
8
- import { reactNodeToString as w } from "../utils/reactToString.js";
7
+ import y from "../utils/createSyntheticClickEvent.js";
8
+ import { reactNodeToString as C } from "../utils/reactToString.js";
9
9
  import { useCls as E } from "../utils/antdUtils.js";
10
10
  import { clsx as M } from "../utils/cn.js";
11
- const z = ({
11
+ const q = ({
12
12
  item: o,
13
13
  inCombobox: e = !1,
14
14
  selected: u = !1,
15
- itemRender: d,
16
- itemLabelRender: f,
15
+ itemRender: c,
16
+ itemLabelRender: d,
17
17
  itemProps: p = {},
18
18
  classNames: n,
19
- afterSelect: a,
19
+ afterSelect: l,
20
20
  showCheckbox: v,
21
21
  indeterminate: k,
22
- getItemKeywords: l
22
+ getItemKeywords: a
23
23
  }) => {
24
- const t = E(), s = i(
24
+ const t = E(), s = g(
25
25
  (r) => {
26
26
  if (o.onSelect)
27
27
  o.onSelect(o);
@@ -29,17 +29,17 @@ const z = ({
29
29
  if (typeof r == "object")
30
30
  o.onClick(r);
31
31
  else {
32
- const b = C(null);
32
+ const b = y(null);
33
33
  o.onClick(b);
34
34
  }
35
- a && a(o);
35
+ l && l(o);
36
36
  },
37
- [a, o]
38
- ), g = x(
39
- () => l ? l(o) : [String(o.key), w(o.label)],
40
37
  [l, o]
41
38
  );
42
- return d ? d(o, {
39
+ return i(
40
+ () => a ? a(o) : [String(o.key), C(o.label)],
41
+ [a, o]
42
+ ), c ? c(o, {
43
43
  className: M(
44
44
  t("dropdown-menu-item", e && "dropdown-menu-item-combobox"),
45
45
  n?.item,
@@ -55,7 +55,7 @@ const z = ({
55
55
  onMouseOver: o.onMouseOver,
56
56
  onMouseOut: o.onMouseOut,
57
57
  ...p
58
- }) : /* @__PURE__ */ c(
58
+ }) : /* @__PURE__ */ f(
59
59
  S,
60
60
  {
61
61
  disabled: o.disabled,
@@ -78,7 +78,7 @@ const z = ({
78
78
  text: n?.itemText,
79
79
  suffix: n?.itemSuffix
80
80
  },
81
- labelRender: f ? (r) => f(o, r) : void 0,
81
+ labelRender: d ? (r) => d(o, r) : void 0,
82
82
  ref: o.ref,
83
83
  onMouseEnter: o.onMouseEnter,
84
84
  onMouseLeave: o.onMouseLeave,
@@ -86,19 +86,20 @@ const z = ({
86
86
  onMouseOut: o.onMouseOut,
87
87
  "data-value": typeof o.label == "string" ? o.label : String(o.key),
88
88
  "data-actual-selected": u,
89
- render: e ? /* @__PURE__ */ c(
90
- y.Item,
89
+ render: e ? /* @__PURE__ */ f(
90
+ x.Item,
91
91
  {
92
+ role: "option",
92
93
  value: String(o.key),
93
- keywords: g || void 0,
94
- onSelect: s
95
- }
96
- ) : /* @__PURE__ */ c(O.Item, { onClick: s }),
94
+ onClick: s
95
+ },
96
+ String(o.key)
97
+ ) : /* @__PURE__ */ f(O.Item, { onClick: s }),
97
98
  children: o.label
98
99
  }
99
100
  );
100
101
  };
101
102
  export {
102
- z as DropdownMenuItem
103
+ q as DropdownMenuItem
103
104
  };
104
105
  //# sourceMappingURL=item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useCallback, useMemo } from \"react\";\nimport {\n clsx,\n createSyntheticClickEvent,\n reactNodeToString,\n useCls,\n} from \"../utils\";\nimport type { DropdownMenuItemType } from \"./types\";\nimport { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { BaseMenuItem } from \"../base-menu\";\n\nexport interface DropdownMenuItemProps {\n /**\n * The menu item data\n */\n item: DropdownMenuItemType & { type: \"item\" };\n /**\n * Custom render function for the item\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for the item label\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Additional props to pass to the item\n */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /**\n * Class names from parent DropdownMenu\n */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n itemSuffix?: string;\n };\n /**\n * Function to be called after the menu item is selected\n */\n afterSelect?: (item: DropdownMenuItemType & { type: \"item\" }) => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is selected (for combobox)\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to show checkbox (only for decoration purpose)\n */\n showCheckbox?: boolean;\n /**\n * Whether the menu item checkbox is indeterminate (for combobox)\n * @default false\n */\n indeterminate?: 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 DropdownMenuItem: React.FC<DropdownMenuItemProps> = ({\n item,\n inCombobox = false,\n selected = false,\n itemRender,\n itemLabelRender,\n itemProps = {},\n classNames,\n afterSelect,\n showCheckbox,\n indeterminate,\n getItemKeywords,\n}) => {\n const cls = useCls();\n\n const handler = useCallback(\n (e?: React.MouseEvent<HTMLElement, MouseEvent> | string) => {\n // onSelect has priority over onClick\n if (item.onSelect) {\n item.onSelect(item);\n } else if (item.onClick) {\n if (typeof e === \"object\") {\n item.onClick(e);\n } else {\n const event = createSyntheticClickEvent(null);\n item.onClick(event);\n }\n }\n if (afterSelect) afterSelect(item);\n },\n [afterSelect, item]\n );\n\n const keywords = useMemo(\n () =>\n getItemKeywords\n ? getItemKeywords(item)\n : [String(item.key), reactNodeToString(item.label)],\n [getItemKeywords, item]\n );\n\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: handler,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n ...itemProps,\n } as React.HTMLAttributes<HTMLElement>);\n }\n\n return (\n <BaseMenuItem\n // BaseMenuItem props\n disabled={item.disabled}\n danger={item.danger}\n selected={selected}\n showCheckbox={showCheckbox}\n indeterminate={indeterminate}\n icon={item.icon}\n suffix={!inCombobox ? item.suffix : undefined}\n classNames={{\n root: clsx(\n cls(\n \"dropdown-menu-item\",\n inCombobox && \"dropdown-menu-item-combobox\"\n ),\n classNames?.item,\n item.className\n ),\n icon: classNames?.itemIcon,\n text: classNames?.itemText,\n suffix: classNames?.itemSuffix,\n }}\n labelRender={\n itemLabelRender\n ? (props: React.HTMLAttributes<HTMLElement>) =>\n itemLabelRender(item, props)\n : undefined\n }\n ref={item.ref as Ref<HTMLDivElement>}\n onMouseEnter={item.onMouseEnter}\n onMouseLeave={item.onMouseLeave}\n onMouseOver={item.onMouseOver}\n onMouseOut={item.onMouseOut}\n data-value={\n typeof item.label === \"string\" ? item.label : String(item.key)\n }\n data-actual-selected={selected}\n // Render prop to use Base UI components\n render={\n inCombobox ? (\n <Command.Item\n value={String(item.key)}\n keywords={keywords || undefined}\n onSelect={handler}\n />\n ) : (\n <Menu.Item onClick={handler} />\n )\n }\n >\n {item.label}\n </BaseMenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemLabelRender","itemProps","classNames","afterSelect","showCheckbox","indeterminate","getItemKeywords","cls","useCls","handler","useCallback","e","event","createSyntheticClickEvent","keywords","useMemo","reactNodeToString","clsx","jsx","BaseMenuItem","props","Command","Menu"],"mappings":";;;;;;;;;;AA0EO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAC,IAAY,CAAA;AAAA,EACZ,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AACF,MAAM;AACJ,QAAMC,IAAMC,EAAA,GAENC,IAAUC;AAAA,IACd,CAACC,MAA2D;AAE1D,UAAIf,EAAK;AACP,QAAAA,EAAK,SAASA,CAAI;AAAA,eACTA,EAAK;AACd,YAAI,OAAOe,KAAM;AACf,UAAAf,EAAK,QAAQe,CAAC;AAAA,aACT;AACL,gBAAMC,IAAQC,EAA0B,IAAI;AAC5C,UAAAjB,EAAK,QAAQgB,CAAK;AAAA,QACpB;AAEF,MAAIT,OAAyBP,CAAI;AAAA,IACnC;AAAA,IACA,CAACO,GAAaP,CAAI;AAAA,EAAA,GAGdkB,IAAWC;AAAA,IACf,MACET,IACIA,EAAgBV,CAAI,IACpB,CAAC,OAAOA,EAAK,GAAG,GAAGoB,EAAkBpB,EAAK,KAAK,CAAC;AAAA,IACtD,CAACU,GAAiBV,CAAI;AAAA,EAAA;AAIxB,SAAIG,IACKA,EAAWH,GAAM;AAAA,IACtB,WAAWqB;AAAA,MACTV,EAAI,sBAAsBV,KAAc,6BAA6B;AAAA,MACrEK,GAAY;AAAA,MACZN,EAAK;AAAA,IAAA;AAAA,IAEP,eAAeA,EAAK;AAAA,IACpB,wBAAwBE;AAAA,IACxB,cACE,OAAOF,E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A,EAAA;AAGZ;"}
1
+ {"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useCallback, useMemo } from \"react\";\nimport {\n clsx,\n createSyntheticClickEvent,\n reactNodeToString,\n useCls,\n} from \"../utils\";\nimport type { DropdownMenuItemType } from \"./types\";\nimport { Combobox } from \"@base-ui-components/react/combobox\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { BaseMenuItem } from \"../base-menu\";\n\nexport interface DropdownMenuItemProps {\n /**\n * The menu item data\n */\n item: DropdownMenuItemType & { type: \"item\" };\n /**\n * Custom render function for the item\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for the item label\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Additional props to pass to the item\n */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /**\n * Class names from parent DropdownMenu\n */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n itemSuffix?: string;\n };\n /**\n * Function to be called after the menu item is selected\n */\n afterSelect?: (item: DropdownMenuItemType & { type: \"item\" }) => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is selected (for combobox)\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to show checkbox (only for decoration purpose)\n */\n showCheckbox?: boolean;\n /**\n * Whether the menu item checkbox is indeterminate (for combobox)\n * @default false\n */\n indeterminate?: 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 DropdownMenuItem: React.FC<DropdownMenuItemProps> = ({\n item,\n inCombobox = false,\n selected = false,\n itemRender,\n itemLabelRender,\n itemProps = {},\n classNames,\n afterSelect,\n showCheckbox,\n indeterminate,\n getItemKeywords,\n}) => {\n const cls = useCls();\n\n const handler = useCallback(\n (e?: React.MouseEvent<HTMLElement, MouseEvent> | string) => {\n // onSelect has priority over onClick\n if (item.onSelect) {\n item.onSelect(item);\n } else if (item.onClick) {\n if (typeof e === \"object\") {\n item.onClick(e);\n } else {\n const event = createSyntheticClickEvent(null);\n item.onClick(event);\n }\n }\n if (afterSelect) afterSelect(item);\n },\n [afterSelect, item]\n );\n\n const keywords = useMemo(\n () =>\n getItemKeywords\n ? getItemKeywords(item)\n : [String(item.key), reactNodeToString(item.label)],\n [getItemKeywords, item]\n );\n\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: handler,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n ...itemProps,\n } as React.HTMLAttributes<HTMLElement>);\n }\n\n return (\n <BaseMenuItem\n // BaseMenuItem props\n disabled={item.disabled}\n danger={item.danger}\n selected={selected}\n showCheckbox={showCheckbox}\n indeterminate={indeterminate}\n icon={item.icon}\n suffix={!inCombobox ? item.suffix : undefined}\n classNames={{\n root: clsx(\n cls(\n \"dropdown-menu-item\",\n inCombobox && \"dropdown-menu-item-combobox\"\n ),\n classNames?.item,\n item.className\n ),\n icon: classNames?.itemIcon,\n text: classNames?.itemText,\n suffix: classNames?.itemSuffix,\n }}\n labelRender={\n itemLabelRender\n ? (props: React.HTMLAttributes<HTMLElement>) =>\n itemLabelRender(item, props)\n : undefined\n }\n ref={item.ref as Ref<HTMLDivElement>}\n onMouseEnter={item.onMouseEnter}\n onMouseLeave={item.onMouseLeave}\n onMouseOver={item.onMouseOver}\n onMouseOut={item.onMouseOut}\n data-value={\n typeof item.label === \"string\" ? item.label : String(item.key)\n }\n data-actual-selected={selected}\n // Render prop to use Base UI components\n render={\n inCombobox ? (\n <Combobox.Item\n role=\"option\"\n key={String(item.key)}\n value={String(item.key)}\n onClick={handler}\n />\n ) : (\n <Menu.Item onClick={handler} />\n )\n }\n >\n {item.label}\n </BaseMenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemLabelRender","itemProps","classNames","afterSelect","showCheckbox","indeterminate","getItemKeywords","cls","useCls","handler","useCallback","e","event","createSyntheticClickEvent","useMemo","reactNodeToString","clsx","jsx","BaseMenuItem","props","Combobox","Menu"],"mappings":";;;;;;;;;;AA0EO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAC,IAAY,CAAA;AAAA,EACZ,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AACF,MAAM;AACJ,QAAMC,IAAMC,EAAA,GAENC,IAAUC;AAAA,IACd,CAACC,MAA2D;AAE1D,UAAIf,EAAK;AACP,QAAAA,EAAK,SAASA,CAAI;AAAA,eACTA,EAAK;AACd,YAAI,OAAOe,KAAM;AACf,UAAAf,EAAK,QAAQe,CAAC;AAAA,aACT;AACL,gBAAMC,IAAQC,EAA0B,IAAI;AAC5C,UAAAjB,EAAK,QAAQgB,CAAK;AAAA,QACpB;AAEF,MAAIT,OAAyBP,CAAI;AAAA,IACnC;AAAA,IACA,CAACO,GAAaP,CAAI;AAAA,EAAA;AAYpB,SATiBkB;AAAA,IACf,MACER,IACIA,EAAgBV,CAAI,IACpB,CAAC,OAAOA,EAAK,GAAG,GAAGmB,EAAkBnB,EAAK,KAAK,CAAC;AAAA,IACtD,C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