@bioturing/components 0.41.0 → 0.42.0-beta.0

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.
Files changed (60) hide show
  1. package/dist/base.d.ts +1 -0
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +1 -0
  4. package/dist/base.js.map +1 -1
  5. package/dist/components/alert/component.d.ts.map +1 -1
  6. package/dist/components/alert/component.js +37 -42
  7. package/dist/components/alert/component.js.map +1 -1
  8. package/dist/components/alert/style.css +1 -1
  9. package/dist/components/data-table/style.css +1 -1
  10. package/dist/components/dropdown-menu/component.d.ts.map +1 -1
  11. package/dist/components/dropdown-menu/component.js +153 -155
  12. package/dist/components/dropdown-menu/component.js.map +1 -1
  13. package/dist/components/dropdown-menu/item.d.ts.map +1 -1
  14. package/dist/components/dropdown-menu/item.js +41 -40
  15. package/dist/components/dropdown-menu/item.js.map +1 -1
  16. package/dist/components/dropdown-menu/style.css +1 -1
  17. package/dist/components/dropdown-menu/types.d.ts +9 -0
  18. package/dist/components/dropdown-menu/types.d.ts.map +1 -1
  19. package/dist/components/form/FormItem/FormItemInput.d.ts +50 -0
  20. package/dist/components/form/FormItem/FormItemInput.d.ts.map +1 -0
  21. package/dist/components/form/FormItem/FormItemInput.js +137 -0
  22. package/dist/components/form/FormItem/FormItemInput.js.map +1 -0
  23. package/dist/components/form/FormItem/FormItemLabel.d.ts +48 -0
  24. package/dist/components/form/FormItem/FormItemLabel.d.ts.map +1 -0
  25. package/dist/components/form/FormItem/FormItemLabel.js +80 -0
  26. package/dist/components/form/FormItem/FormItemLabel.js.map +1 -0
  27. package/dist/components/form/FormItem/ItemHolder.d.ts +33 -0
  28. package/dist/components/form/FormItem/ItemHolder.d.ts.map +1 -0
  29. package/dist/components/form/FormItem/ItemHolder.js +168 -0
  30. package/dist/components/form/FormItem/ItemHolder.js.map +1 -0
  31. package/dist/components/form/FormItem/index.d.ts +106 -0
  32. package/dist/components/form/FormItem/index.d.ts.map +1 -0
  33. package/dist/components/form/FormItem/index.js +234 -0
  34. package/dist/components/form/FormItem/index.js.map +1 -0
  35. package/dist/components/form/component.d.ts +7 -1
  36. package/dist/components/form/component.d.ts.map +1 -1
  37. package/dist/components/form/component.js +4 -4
  38. package/dist/components/form/item.d.ts +27 -23
  39. package/dist/components/form/item.d.ts.map +1 -1
  40. package/dist/components/form/label.d.ts.map +1 -1
  41. package/dist/components/form/label.js +33 -31
  42. package/dist/components/form/label.js.map +1 -1
  43. package/dist/components/form/style.css +1 -1
  44. package/dist/components/scroll-area/style.css +1 -1
  45. package/dist/components/splitter/style.css +1 -1
  46. package/dist/components/theme-provider/style.css +1 -1
  47. package/dist/components/toast/function.d.ts +1 -1
  48. package/dist/components/toast/function.d.ts.map +1 -1
  49. package/dist/components/toast/style.css +1 -1
  50. package/dist/components/tour/style.css +1 -1
  51. package/dist/components/tree/style.css +1 -1
  52. package/dist/components/utils/renderProp.d.ts +1 -1
  53. package/dist/components/utils/renderProp.d.ts.map +1 -1
  54. package/dist/components/utils/renderProp.js +16 -10
  55. package/dist/components/utils/renderProp.js.map +1 -1
  56. package/dist/components/vertical-collapsible-panel/style.css +1 -1
  57. package/dist/stats.html +1 -1
  58. package/package.json +4 -3
  59. package/dist/components/form/item.js +0 -43
  60. package/dist/components/form/item.js.map +0 -1
@@ -1,202 +1,200 @@
1
1
  "use client";
2
- import { jsxs as c, jsx as e } from "react/jsx-runtime";
3
- import { Menu as u } from "@base-ui/react/menu";
2
+ import { jsxs as p, jsx as e } from "react/jsx-runtime";
3
+ import { Menu as d } from "@base-ui/react/menu";
4
4
  import { Combobox as t } from "@base-ui/react/combobox";
5
- import { useRef as O, useState as V, useEffect as te, useCallback as ie } from "react";
6
- import { FormItemInputContext as le } from "antd/es/form/context";
7
- import { PopupPanelSize as B } from "../popup-panel/constants.js";
8
- import { useDropdownMenu as me } from "./useDropdownMenu.js";
9
- import { BaseMenu as F } from "../base-menu/index.js";
10
- import { parseAntdPlacement as ce } from "../utils/placement.js";
11
- import { useBaseUIPlacement as ue } from "../hooks/useBaseUIPlacement.js";
12
- import { ScrollArea as _ } from "../scroll-area/component.js";
13
- import { DROPDOWN_COLLISION_AVOIDANCE as pe } from "../utils/constants.js";
14
- import { Input as de } from "../input/component.js";
15
- import { createRenderProp as se } from "../utils/renderProp.js";
16
- import { useControlledState as ae } from "../hooks/useControlledState.js";
17
- import { useCls as fe } from "../utils/antdUtils.js";
18
- import { useTheme as ge } from "../theme-provider/context/themeStore.js";
19
- import { clsx as f } from "../utils/cn.js";
20
- import { reactNodeToString as he } from "../utils/reactToString.js";
21
- const je = ({
22
- children: j,
23
- items: k,
24
- placement: G,
25
- openOnHover: H,
26
- open: L,
27
- onOpenChange: U,
28
- defaultOpen: z = !1,
29
- className: K,
30
- itemRender: W,
31
- classNames: r,
32
- size: R = "auto",
33
- showSearch: p,
34
- inCombobox: N,
35
- searchProps: l = {
5
+ import { useRef as oe, useState as D, useCallback as re } from "react";
6
+ import { FormItemInputContext as ne } from "antd/es/form/context";
7
+ import { PopupPanelSize as M } from "../popup-panel/constants.js";
8
+ import { useDropdownMenu as te } from "./useDropdownMenu.js";
9
+ import { BaseMenu as V } from "../base-menu/index.js";
10
+ import { parseAntdPlacement as ie } from "../utils/placement.js";
11
+ import { useBaseUIPlacement as me } from "../hooks/useBaseUIPlacement.js";
12
+ import { ScrollArea as E } from "../scroll-area/component.js";
13
+ import { DROPDOWN_COLLISION_AVOIDANCE as le } from "../utils/constants.js";
14
+ import { Input as pe } from "../input/component.js";
15
+ import { createRenderProp as de } from "../utils/renderProp.js";
16
+ import { useControlledState as ce } from "../hooks/useControlledState.js";
17
+ import { useCls as ue } from "../utils/antdUtils.js";
18
+ import { useTheme as ae } from "../theme-provider/context/themeStore.js";
19
+ import { clsx as c } from "../utils/cn.js";
20
+ import { reactNodeToString as se } from "../utils/reactToString.js";
21
+ const _e = ({
22
+ children: _,
23
+ items: j,
24
+ placement: k,
25
+ openOnHover: B,
26
+ open: G,
27
+ onOpenChange: H,
28
+ defaultOpen: L = !1,
29
+ className: U,
30
+ itemRender: z,
31
+ classNames: n,
32
+ size: C = "auto",
33
+ showSearch: u,
34
+ inCombobox: I,
35
+ searchProps: i = {
36
36
  placeholder: "Search..."
37
37
  },
38
- popupMatchTriggerWidth: q,
39
- beforeList: g,
40
- afterList: h,
41
- keepOpenOnSelect: J,
42
- highlightedItemKey: Pe,
43
- selectedItemKeys: Q,
44
- getItemKeywords: X,
45
- showCheckbox: y,
46
- itemLabelRender: Y
38
+ popupMatchTriggerWidth: F,
39
+ beforeList: f,
40
+ afterList: g,
41
+ keepOpenOnSelect: K,
42
+ highlightedItemKey: fe,
43
+ selectedItemKeys: W,
44
+ getItemKeywords: q,
45
+ showCheckbox: x,
46
+ itemLabelRender: J
47
47
  }) => {
48
- const Z = typeof N == "boolean" ? N : p, [P, b] = ae(
49
- L,
50
- U,
51
- z
52
- ), n = fe(), { className: T } = ge(), d = ce(G), $ = O(null), { itemGroups: S, renderGroup: w } = me({
53
- items: k,
54
- keepOpenOnSelect: J,
55
- selectedItemKeys: Q,
56
- showCheckbox: y,
57
- getItemKeywords: X,
58
- itemLabelRender: Y,
59
- itemRender: W,
60
- inCombobox: Z,
61
- onOpenChange: b,
48
+ const Q = typeof I == "boolean" ? I : u, [h, P] = ce(
49
+ G,
50
+ H,
51
+ L
52
+ ), r = ue(), { className: N } = ae(), a = ie(k), X = oe(null), { itemGroups: w, renderGroup: b } = te({
53
+ items: j,
54
+ keepOpenOnSelect: K,
55
+ selectedItemKeys: W,
56
+ showCheckbox: x,
57
+ getItemKeywords: q,
58
+ itemLabelRender: J,
59
+ itemRender: z,
60
+ inCombobox: Q,
61
+ onOpenChange: P,
62
62
  classNames: {
63
- item: r?.item,
64
- itemIcon: r?.itemIcon,
65
- itemSuffix: r?.itemSuffix,
66
- group: r?.group,
67
- groupLabel: r?.groupLabel,
68
- divider: r?.divider
63
+ item: n?.item,
64
+ itemIcon: n?.itemIcon,
65
+ itemSuffix: n?.itemSuffix,
66
+ group: n?.group,
67
+ groupLabel: n?.groupLabel,
68
+ divider: n?.divider
69
69
  }
70
- }), [C, ee] = V(""), [oe, re] = V(
70
+ }), [S, Y] = D(""), [Z, $] = D(
71
71
  null
72
- ), v = O(null), x = O(!1), { currentSide: ne } = ue({
73
- positionerRef: oe,
74
- open: P,
75
- initialSide: d.side,
76
- initialAlign: d.align
77
- }), s = ne === "top";
78
- te(() => {
79
- x.current && v.current && v.current.focus();
80
- }, [s]);
81
- const A = ie(() => {
82
- if (!p)
83
- return /* @__PURE__ */ c("div", { className: n("dropdown-menu-container"), children: [
84
- g,
85
- /* @__PURE__ */ e(_, { fadeEdges: !0, children: S.map(w) }),
86
- h
72
+ ), { currentSide: ee } = me({
73
+ positionerRef: Z,
74
+ open: h,
75
+ initialSide: a.side,
76
+ initialAlign: a.align
77
+ }), O = ee === "top", R = re(() => {
78
+ if (!u)
79
+ return /* @__PURE__ */ p("div", { className: r("dropdown-menu-container"), children: [
80
+ f,
81
+ /* @__PURE__ */ e(E, { fadeEdges: !0, children: w.map(b) }),
82
+ g
87
83
  ] });
88
- const o = /* @__PURE__ */ e(le.Provider, { value: {}, children: /* @__PURE__ */ e(
84
+ const o = /* @__PURE__ */ e(ne.Provider, { value: {}, children: /* @__PURE__ */ e(
89
85
  t.Input,
90
86
  {
91
- placeholder: l?.placeholder || "Search",
92
- render: ({ ref: a, ...m }) => /* @__PURE__ */ e(
93
- de,
87
+ placeholder: i?.placeholder || "Search",
88
+ render: ({ ref: s, ...m }) => /* @__PURE__ */ e(
89
+ pe,
94
90
  {
95
91
  ...m,
96
- ref: (i) => {
97
- if (!i || !i.input) return;
98
- a(i.input), v.current = i.input;
92
+ ref: (l) => {
93
+ if (!l || !l.input) return;
94
+ s(l.input);
99
95
  },
100
96
  allowClear: !0,
101
- placeholder: l?.placeholder || "Search",
102
- value: C,
103
- onChange: (i) => ee(i.target.value),
104
- onFocus: () => {
105
- x.current = !0;
106
- },
107
- onBlur: () => {
108
- x.current = !1;
109
- },
110
- className: f(
111
- n("dropdown-menu-search"),
112
- l?.className
97
+ placeholder: i?.placeholder || "Search",
98
+ value: S,
99
+ onChange: (l) => Y(l.target.value),
100
+ className: c(
101
+ r("dropdown-menu-search"),
102
+ i?.className
113
103
  )
114
104
  }
115
105
  ),
116
- ...l
106
+ ...i
117
107
  },
118
108
  "search"
119
- ) }), I = /* @__PURE__ */ c(_, { fadeEdges: !0, children: [
120
- /* @__PURE__ */ e(t.Empty, { className: n("dropdown-menu-empty"), children: "No results found." }),
121
- /* @__PURE__ */ e(t.List, { className: n("dropdown-menu-list"), children: (a, m) => w(a, m) })
109
+ ) }), v = /* @__PURE__ */ p(E, { fadeEdges: !0, children: [
110
+ /* @__PURE__ */ e(t.Empty, { className: r("dropdown-menu-empty"), children: "No results found." }),
111
+ /* @__PURE__ */ e(t.List, { className: r("dropdown-menu-list"), children: (s, m) => b(s, m) })
122
112
  ] });
123
- return /* @__PURE__ */ c("div", { className: n("dropdown-menu-container"), children: [
124
- !s && o,
125
- g,
126
- I,
127
- h,
128
- s && o
113
+ return /* @__PURE__ */ p("div", { className: r("dropdown-menu-container"), children: [
114
+ /* @__PURE__ */ e(
115
+ "div",
116
+ {
117
+ className: c(
118
+ r("dropdown-menu-search-wrapper"),
119
+ O && r("dropdown-menu-search-wrapper-bottom")
120
+ ),
121
+ children: o
122
+ }
123
+ ),
124
+ f,
125
+ v,
126
+ g
129
127
  ] });
130
128
  }, [
131
- p,
132
- n,
133
- l,
134
- C,
135
- g,
136
- h,
129
+ u,
130
+ r,
131
+ i,
137
132
  S,
133
+ f,
134
+ g,
138
135
  w,
139
- s
140
- ]), D = {
141
- ref: $,
136
+ b,
137
+ O
138
+ ]), y = {
139
+ ref: X,
142
140
  // nativeButton: false,
143
- openOnHover: H,
144
- className: f(
145
- n("dropdown-menu-trigger"),
146
- r?.trigger,
147
- T
141
+ openOnHover: B,
142
+ className: c(
143
+ r("dropdown-menu-trigger"),
144
+ n?.trigger,
145
+ N
148
146
  ),
149
- render: (o, I) => {
150
- const { openOnHover: a, ...m } = o;
151
- return se(j, m, I);
147
+ render: (o, v) => {
148
+ const { openOnHover: s, ...m } = o;
149
+ return de(_, m, v);
152
150
  }
153
- }, E = {
154
- ref: re,
155
- side: d.side,
156
- align: d.align,
151
+ }, T = {
152
+ ref: $,
153
+ side: a.side,
154
+ align: a.align,
157
155
  sideOffset: 4,
158
- className: f(
159
- n("dropdown-menu-root"),
160
- T,
161
- r?.root
156
+ className: c(
157
+ r("dropdown-menu-root"),
158
+ N,
159
+ n?.root
162
160
  ),
163
- collisionAvoidance: pe,
164
- render: (o) => /* @__PURE__ */ e(F.Root, { ...o })
165
- }, M = {
166
- className: f(
167
- n(
161
+ collisionAvoidance: le,
162
+ render: (o) => /* @__PURE__ */ e(V.Root, { ...o })
163
+ }, A = {
164
+ className: c(
165
+ r(
168
166
  "dropdown-menu",
169
- y && "dropdown-menu-show-checkbox",
170
- q && "dropdown-menu-match-trigger-width"
167
+ x && "dropdown-menu-show-checkbox",
168
+ F && "dropdown-menu-match-trigger-width"
171
169
  ),
172
- K,
173
- r?.popup
170
+ U,
171
+ n?.popup
174
172
  ),
175
173
  style: {
176
- "--size-width": R in B ? B[R] : void 0
174
+ "--size-width": C in M ? M[C] : void 0
177
175
  },
178
- render: (o) => /* @__PURE__ */ e(F.Popup, { ...o })
176
+ render: (o) => /* @__PURE__ */ e(V.Popup, { ...o })
179
177
  };
180
- return p ? /* @__PURE__ */ c(
178
+ return u ? /* @__PURE__ */ p(
181
179
  t.Root,
182
180
  {
183
- open: P,
184
- onOpenChange: b,
185
- items: S,
186
- itemToStringLabel: (o) => o.type == "item" ? he(o.label) : "",
181
+ open: h,
182
+ onOpenChange: P,
183
+ items: w,
184
+ itemToStringLabel: (o) => o.type == "item" ? se(o.label) : "",
187
185
  itemToStringValue: (o) => o.type == "item" ? String(o.key) : "",
188
- inputValue: C,
186
+ inputValue: S,
189
187
  children: [
190
- /* @__PURE__ */ e(t.Trigger, { ...D }),
191
- /* @__PURE__ */ e(t.Portal, { children: /* @__PURE__ */ e(t.Positioner, { ...E, children: /* @__PURE__ */ e(t.Popup, { ...M, children: A() }) }) })
188
+ /* @__PURE__ */ e(t.Trigger, { ...y }),
189
+ /* @__PURE__ */ e(t.Portal, { children: /* @__PURE__ */ e(t.Positioner, { ...T, children: /* @__PURE__ */ e(t.Popup, { ...A, children: R() }) }) })
192
190
  ]
193
191
  }
194
- ) : /* @__PURE__ */ c(u.Root, { open: P, onOpenChange: b, children: [
195
- /* @__PURE__ */ e(u.Trigger, { ...D }),
196
- /* @__PURE__ */ e(u.Portal, { children: /* @__PURE__ */ e(u.Positioner, { ...E, children: /* @__PURE__ */ e(u.Popup, { ...M, children: A() }) }) })
192
+ ) : /* @__PURE__ */ p(d.Root, { open: h, onOpenChange: P, children: [
193
+ /* @__PURE__ */ e(d.Trigger, { ...y }),
194
+ /* @__PURE__ */ e(d.Portal, { children: /* @__PURE__ */ e(d.Positioner, { ...T, children: /* @__PURE__ */ e(d.Popup, { ...A, children: R() }) }) })
197
195
  ] });
198
196
  };
199
197
  export {
200
- je as DropdownMenu
198
+ _e as DropdownMenu
201
199
  };
202
200
  //# 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/react/menu\";\nimport { Combobox } from \"@base-ui/react/combobox\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef, useState, RefCallback, useEffect } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n reactNodeToString,\n useCls,\n createRenderProp,\n} from \"../utils\";\nimport { useBaseUIPlacement } from \"../hooks\";\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 const [positionerRef, setPositionerRef] = useState<HTMLDivElement | null>(\n null\n );\n const inputRef = useRef<HTMLInputElement | null>(null);\n const wasFocusedRef = useRef(false);\n\n // Track placement changes to conditionally position search input\n const { currentSide } = useBaseUIPlacement({\n positionerRef,\n open,\n initialSide: baseUIPlacement.side,\n initialAlign: baseUIPlacement.align,\n });\n\n // When placement is on top, move search to bottom for better UX\n const isTopPlacement = currentSide === \"top\";\n\n // Restore focus after placement changes\n useEffect(() => {\n if (wasFocusedRef.current && inputRef.current) {\n inputRef.current.focus();\n // Don't reset wasFocusedRef - let onBlur handle it\n }\n }, [isTopPlacement]);\n\n const renderMenuInner = useCallback(() => {\n if (!showSearch) {\n return (\n <div className={cls(\"dropdown-menu-container\")}>\n {beforeList}\n <ScrollArea fadeEdges>{itemGroups.map(renderGroup)}</ScrollArea>\n {afterList}\n </div>\n );\n }\n\n const searchInput = (\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 inputRef.current = antdInputRef.input;\n }}\n allowClear\n placeholder={searchProps?.placeholder || \"Search\"}\n value={searchValue}\n onChange={(e) => setSearchValue(e.target.value)}\n onFocus={() => {\n wasFocusedRef.current = true;\n }}\n onBlur={() => {\n wasFocusedRef.current = false;\n }}\n className={clsx(\n cls(\"dropdown-menu-search\"),\n searchProps?.className\n )}\n />\n )}\n {...searchProps}\n />\n </FormItemInputContext.Provider>\n );\n\n const listContent = (\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 );\n\n return (\n <div className={cls(\"dropdown-menu-container\")}>\n {!isTopPlacement && searchInput}\n {beforeList}\n {listContent}\n {afterList}\n {isTopPlacement && searchInput}\n </div>\n );\n }, [\n showSearch,\n cls,\n searchProps,\n searchValue,\n beforeList,\n afterList,\n itemGroups,\n renderGroup,\n isTopPlacement,\n ]);\n\n const commonTriggerProps = {\n ref: buttonRef,\n // nativeButton: false,\n openOnHover,\n className: clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n themeClassName\n ),\n render: (props, state) => {\n const { openOnHover: _openOnHover, ...rest } = props;\n return createRenderProp(children, rest, state);\n },\n };\n\n const commonPositionerProps = {\n ref: setPositionerRef,\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","positionerRef","setPositionerRef","inputRef","wasFocusedRef","currentSide","useBaseUIPlacement","isTopPlacement","useEffect","renderMenuInner","useCallback","jsxs","ScrollArea","searchInput","jsx","FormItemInputContext","Combobox","ref","props","Input","antdInputRef","e","clsx","listContent","group","i","commonTriggerProps","state","_openOnHover","rest","createRenderProp","commonPositionerProps","DROPDOWN_COLLISION_AVOIDANCE","BaseMenu","commonPopupProps","PopupPanelSize","item","reactNodeToString","Menu"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0GO,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,GAAA,GACN,EAAE,WAAWC,EAAA,IAAmBC,GAAA,GAChCC,IAAkBC,GAAmB9B,CAAS,GAC9C+B,IAAYC,EAA0B,IAAI,GAC1C,EAAE,YAAAC,GAAY,aAAAC,EAAA,IAAgBC,GAAgB;AAAA,IAClD,OAAApC;AAAA,IACA,kBAAAgB;AAAA,IAEA,kBAAAE;AAAA,IACA,cAAAE;AAAA,IACA,iBAA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MAE3C,YAAYtC;AAAA,MAEZ,UAAA;AAAA,QAAA,gBAAAgB,EAACE,EAAS,SAAT,EAAkB,GAAGU,EAAA,CAAoB;AAAA,0BACzCV,EAAS,QAAT,EACC,UAAA,gBAAAF,EAACE,EAAS,YAAT,EAAqB,GAAGe,GACvB,UAAA,gBAAAjB,EAACE,EAAS,OAAT,EAAgB,GAAGkB,GACjB,UAAAzB,EAAA,GACH,GACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAGF,gBAAAE,EAAC2B,EAAK,MAAL,EAAU,MAAAtD,GAAY,cAAAC,GACrB,UAAA;AAAA,IAAA,gBAAA6B,EAACwB,EAAK,SAAL,EAAc,GAAGZ,EAAA,CAAoB;AAAA,sBACrCY,EAAK,QAAL,EACC,UAAA,gBAAAxB,EAACwB,EAAK,YAAL,EAAiB,GAAGP,GACnB,UAAA,gBAAAjB,EAACwB,EAAK,OAAL,EAAY,GAAGJ,GAAmB,UAAAzB,EAAA,GAAkB,GACvD,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/dropdown-menu/component.tsx"],"sourcesContent":["\"use client\";\nimport { Menu } from \"@base-ui/react/menu\";\nimport { Combobox } from \"@base-ui/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 createRenderProp,\n} from \"../utils\";\nimport { useBaseUIPlacement } from \"../hooks\";\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 extends Omit<\n UseDropdownMenuProps,\n \"classNames\"\n> {\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 const [positionerRef, setPositionerRef] = useState<HTMLDivElement | null>(\n null,\n );\n\n // Track placement changes to conditionally position search input\n const { currentSide } = useBaseUIPlacement({\n positionerRef,\n open,\n initialSide: baseUIPlacement.side,\n initialAlign: baseUIPlacement.align,\n });\n\n // When placement is on top, move search to bottom for better UX\n const isTopPlacement = currentSide === \"top\";\n\n const renderMenuInner = useCallback(() => {\n if (!showSearch) {\n return (\n <div className={cls(\"dropdown-menu-container\")}>\n {beforeList}\n <ScrollArea fadeEdges>{itemGroups.map(renderGroup)}</ScrollArea>\n {afterList}\n </div>\n );\n }\n\n const searchInput = (\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 );\n\n const listContent = (\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 );\n\n return (\n <div className={cls(\"dropdown-menu-container\")}>\n <div\n className={clsx(\n cls(\"dropdown-menu-search-wrapper\"),\n isTopPlacement && cls(\"dropdown-menu-search-wrapper-bottom\"),\n )}\n >\n {searchInput}\n </div>\n {beforeList}\n {listContent}\n {afterList}\n </div>\n );\n }, [\n showSearch,\n cls,\n searchProps,\n searchValue,\n beforeList,\n afterList,\n itemGroups,\n renderGroup,\n isTopPlacement,\n ]);\n\n const commonTriggerProps = {\n ref: buttonRef,\n // nativeButton: false,\n openOnHover,\n className: clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n themeClassName,\n ),\n render: (props, state) => {\n const { openOnHover: _openOnHover, ...rest } = props;\n return createRenderProp(children, rest, state);\n },\n };\n\n const commonPositionerProps = {\n ref: setPositionerRef,\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","positionerRef","setPositionerRef","currentSide","useBaseUIPlacement","isTopPlacement","renderMenuInner","useCallback","jsxs","ScrollArea","searchInput","jsx","FormItemInputContext","Combobox","ref","props","Input","antdInputRef","e","clsx","listContent","group","i","commonTriggerProps","state","_openOnHover","rest","createRenderProp","commonPositionerProps","DROPDOWN_COLLISION_AVOIDANCE","BaseMenu","commonPopupProps","PopupPanelSize","item","reactNodeToString","Menu"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4GO,M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;KACrB,CAAC;IACF;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACtE;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;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,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAuH5D,CAAC"}
@@ -1,100 +1,101 @@
1
1
  "use client";
2
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/react/combobox";
5
- import { Menu as O } from "@base-ui/react/menu";
6
- import { BaseMenuItem as S } from "../base-menu/item.js";
3
+ import { useCallback as b, useMemo as g } from "react";
4
+ import { Combobox as O } from "@base-ui/react/combobox";
5
+ import { Menu as S } from "@base-ui/react/menu";
6
+ import { BaseMenuItem as i } from "../base-menu/item.js";
7
7
  import y from "../utils/createSyntheticClickEvent.js";
8
8
  import { reactNodeToString as C } from "../utils/reactToString.js";
9
9
  import { useCls as E } from "../utils/antdUtils.js";
10
- import { clsx as M } from "../utils/cn.js";
10
+ import { clsx as e } from "../utils/cn.js";
11
11
  const q = ({
12
12
  item: o,
13
- inCombobox: e = !1,
14
- selected: u = !1,
15
- itemRender: c,
16
- itemLabelRender: d,
13
+ inCombobox: r = !1,
14
+ selected: a = !1,
15
+ itemRender: d,
16
+ itemLabelRender: t,
17
17
  itemProps: p = {},
18
18
  classNames: n,
19
19
  afterSelect: l,
20
20
  showCheckbox: v,
21
21
  indeterminate: k,
22
- getItemKeywords: a
22
+ getItemKeywords: u
23
23
  }) => {
24
- const t = E(), s = g(
25
- (r) => {
24
+ const M = E(), c = b(
25
+ (s) => {
26
26
  if (o.onSelect)
27
27
  o.onSelect(o);
28
28
  else if (o.onClick)
29
- if (typeof r == "object")
30
- o.onClick(r);
29
+ if (typeof s == "object")
30
+ o.onClick(s);
31
31
  else {
32
- const b = y(null);
33
- o.onClick(b);
32
+ const x = y(null);
33
+ o.onClick(x);
34
34
  }
35
35
  l && l(o);
36
36
  },
37
37
  [l, o]
38
38
  );
39
- return i(
40
- () => a ? a(o) : [String(o.key), C(o.label)],
41
- [a, o]
42
- ), c ? c(o, {
43
- className: M(
44
- t("dropdown-menu-item", e && "dropdown-menu-item-combobox"),
39
+ return g(
40
+ () => u ? u(o) : [String(o.key), C(o.label)],
41
+ [u, o]
42
+ ), d ? d(o, {
43
+ className: e(
44
+ M("dropdown-menu-item", r && "dropdown-menu-item-combobox"),
45
45
  n?.item,
46
46
  o.className
47
47
  ),
48
48
  "data-danger": o.danger,
49
- "data-actual-selected": u,
49
+ "data-actual-selected": a,
50
50
  "data-value": typeof o.label == "string" ? o.label : String(o.key),
51
51
  ref: o.ref,
52
- onClick: s,
52
+ onClick: c,
53
53
  onMouseEnter: o.onMouseEnter,
54
54
  onMouseLeave: o.onMouseLeave,
55
55
  onMouseOver: o.onMouseOver,
56
56
  onMouseOut: o.onMouseOut,
57
57
  ...p
58
58
  }) : /* @__PURE__ */ f(
59
- S,
59
+ i,
60
60
  {
61
61
  disabled: o.disabled,
62
62
  danger: o.danger,
63
- selected: u,
63
+ selected: a,
64
64
  showCheckbox: v,
65
65
  indeterminate: k,
66
66
  icon: o.icon,
67
- suffix: e ? void 0 : o.suffix,
67
+ suffix: r ? void 0 : o.suffix,
68
68
  classNames: {
69
- root: M(
70
- t(
69
+ root: e(
70
+ M(
71
71
  "dropdown-menu-item",
72
- e && "dropdown-menu-item-combobox"
72
+ r && "dropdown-menu-item-combobox"
73
73
  ),
74
74
  n?.item,
75
- o.className
75
+ o.className,
76
+ o.classNames?.root
76
77
  ),
77
- icon: n?.itemIcon,
78
- text: n?.itemText,
79
- suffix: n?.itemSuffix
78
+ icon: e(n?.itemIcon, o.classNames?.icon),
79
+ text: e(n?.itemText, o.classNames?.text),
80
+ suffix: e(n?.itemSuffix, o.classNames?.suffix)
80
81
  },
81
- labelRender: d ? (r) => d(o, r) : void 0,
82
+ labelRender: t ? (s) => t(o, s) : void 0,
82
83
  ref: o.ref,
83
84
  onMouseEnter: o.onMouseEnter,
84
85
  onMouseLeave: o.onMouseLeave,
85
86
  onMouseOver: o.onMouseOver,
86
87
  onMouseOut: o.onMouseOut,
87
88
  "data-value": typeof o.label == "string" ? o.label : String(o.key),
88
- "data-actual-selected": u,
89
- render: e ? /* @__PURE__ */ f(
90
- x.Item,
89
+ "data-actual-selected": a,
90
+ render: r ? /* @__PURE__ */ f(
91
+ O.Item,
91
92
  {
92
93
  role: "option",
93
94
  value: String(o.key),
94
- onClick: s
95
+ onClick: c
95
96
  },
96
97
  String(o.key)
97
- ) : /* @__PURE__ */ f(O.Item, { onClick: s }),
98
+ ) : /* @__PURE__ */ f(S.Item, { onClick: c }),
98
99
  children: o.label
99
100
  }
100
101
  );
@@ -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 { Combobox } from \"@base-ui/react/combobox\";\nimport { Menu } from \"@base-ui/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","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AA,IACjB,GAAGK;AAAA,EAAA,CACiC,IAItC,gBAAAgB;AAAA,IAACC;AAAA,IAAA;AAAA,MAEC,UAAUtB,EAAK;AAAA,MACf,QAAQA,EAAK;AAAA,MACb,UAAAE;AAAA,MACA,cAAAM;AAAA,MACA,eAAAC;AAAA,MACA,MAAMT,EAAK;AAAA,MACX,QAASC,IAA2B,SAAdD,EAAK;AAAA,MAC3B,YAAY;AAAA,QACV,MAAMoB;AAAA,UACJT;AAAA,YACE;AAAA,YACAV,KAAc;AAAA,UAAA;AAAA,UAEhBK,GAAY;AAAA,UACZN,EAAK;AAAA,QAAA;AAAA,QAEP,MAAMM,GAAY;AAAA,QAClB,MAAMA,GAAY;AAAA,QAClB,QAAQA,GAAY;AAAA,MAAA;AAAA,MAEtB,aACEF,IACI,CAACmB,MACCnB,EAAgBJ,GAAMuB,CAAK,IAC7B;AAAA,MAEN,KAAKvB,EAAK;AAAA,MACV,cAAcA,EAAK;AAAA,MACnB,cAAcA,EAAK;AAAA,MACnB,aAAaA,EAAK;AAAA,MAClB,YAAYA,EAAK;AAAA,MACjB,cACE,OAAOA,EAAK,SAAU,WAAWA,EAAK,QAAQ,OAAOA,EAAK,GAAG;AAAA,MAE/D,wBAAsBE;AAAA,MAEtB,QACED,IACE,gBAAAoB;AAAA,QAACG,EAAS;AAAA,QAAT;AAAA,UACC,MAAK;AAAA,UAEL,OAAO,OAAOxB,EAAK,GAAG;AAAA,UACtB,SAASa;AAAA,QAAA;AAAA,QAFJ,OAAOb,EAAK,GAAG;AAAA,MAAA,IAKtB,gBAAAqB,EAACI,EAAK,MAAL,EAAU,SAASZ,EAAA,CAAS;AAAA,MAIhC,UAAAb,EAAK;AAAA,IAAA;AAAA,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/react/combobox\";\nimport { Menu } from \"@base-ui/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 item.classNames?.root\n ),\n icon: clsx(classNames?.itemIcon, item.classNames?.icon),\n text: clsx(classNames?.itemText, item.classNames?.text),\n suffix: clsx(classNames?.itemSuffix, item.classNames?.suffix),\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,CAACU,GAAiBV,CAAI;AAAA,EAAA,GAIpBG,IACKA,EAAWH,GAAM;AAAA,IACtB,WAAWoB;AAAA,MACTT,EAAI,sBAAsBV,KAAc,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ACED,IACE,gBAAAoB;AAAA,QAACG,EAAS;AAAA,QAAT;AAAA,UACC,MAAK;AAAA,UAEL,OAAO,OAAOxB,EAAK,GAAG;AAAA,UACtB,SAASa;AAAA,QAAA;AAAA,QAFJ,OAAOb,EAAK,GAAG;AAAA,MAAA,IAKtB,gBAAAqB,EAACI,EAAK,MAAL,EAAU,SAASZ,EAAA,CAAS;AAAA,MAIhC,UAAAb,EAAK;AAAA,IAAA;AAAA,EAAA;AAGZ;"}
@@ -1 +1 @@
1
- @layer components{.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;gap:.25rem}}
1
+ @layer components{.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;gap:.25rem}.ds-dropdown-menu-search-wrapper{order:-1}.ds-dropdown-menu-search-wrapper-bottom{order:1}}