@bioturing/components 0.47.0 → 0.48.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 (66) hide show
  1. package/dist/components/base-menu/index.d.ts +1 -1
  2. package/dist/components/base-menu/index.d.ts.map +1 -1
  3. package/dist/components/base-menu/item.css +1 -1
  4. package/dist/components/base-menu/item.d.ts +13 -2
  5. package/dist/components/base-menu/item.d.ts.map +1 -1
  6. package/dist/components/base-menu/item.js +62 -47
  7. package/dist/components/base-menu/item.js.map +1 -1
  8. package/dist/components/base-menu/style.css +1 -1
  9. package/dist/components/combobox/component.d.ts.map +1 -1
  10. package/dist/components/combobox/component.js +121 -121
  11. package/dist/components/combobox/component.js.map +1 -1
  12. package/dist/components/combobox/style.css +1 -1
  13. package/dist/components/data-table/component.d.ts.map +1 -1
  14. package/dist/components/data-table/component.js +81 -70
  15. package/dist/components/data-table/component.js.map +1 -1
  16. package/dist/components/data-table/components/TableBody.d.ts +3 -2
  17. package/dist/components/data-table/components/TableBody.d.ts.map +1 -1
  18. package/dist/components/data-table/components/TableBody.js +107 -99
  19. package/dist/components/data-table/components/TableBody.js.map +1 -1
  20. package/dist/components/data-table/components/TableHeader.d.ts +3 -1
  21. package/dist/components/data-table/components/TableHeader.d.ts.map +1 -1
  22. package/dist/components/data-table/components/TableHeader.js +121 -93
  23. package/dist/components/data-table/components/TableHeader.js.map +1 -1
  24. package/dist/components/data-table/components/TablePagination.d.ts.map +1 -1
  25. package/dist/components/data-table/components/TablePagination.js +32 -21
  26. package/dist/components/data-table/components/TablePagination.js.map +1 -1
  27. package/dist/components/data-table/hooks.d.ts.map +1 -1
  28. package/dist/components/data-table/hooks.js +98 -84
  29. package/dist/components/data-table/hooks.js.map +1 -1
  30. package/dist/components/data-table/style.css +1 -1
  31. package/dist/components/data-table/utils.js +37 -30
  32. package/dist/components/data-table/utils.js.map +1 -1
  33. package/dist/components/dropdown-menu/component.d.ts.map +1 -1
  34. package/dist/components/dropdown-menu/component.js +121 -144
  35. package/dist/components/dropdown-menu/component.js.map +1 -1
  36. package/dist/components/dropdown-menu/index.d.ts +2 -0
  37. package/dist/components/dropdown-menu/index.d.ts.map +1 -1
  38. package/dist/components/dropdown-menu/item.d.ts +7 -15
  39. package/dist/components/dropdown-menu/item.d.ts.map +1 -1
  40. package/dist/components/dropdown-menu/item.js +132 -81
  41. package/dist/components/dropdown-menu/item.js.map +1 -1
  42. package/dist/components/dropdown-menu/radio-group.d.ts +14 -0
  43. package/dist/components/dropdown-menu/radio-group.d.ts.map +1 -0
  44. package/dist/components/dropdown-menu/radio-group.js +45 -0
  45. package/dist/components/dropdown-menu/radio-group.js.map +1 -0
  46. package/dist/components/dropdown-menu/search-mode.d.ts +4 -0
  47. package/dist/components/dropdown-menu/search-mode.d.ts.map +1 -0
  48. package/dist/components/dropdown-menu/search-mode.js +6 -0
  49. package/dist/components/dropdown-menu/search-mode.js.map +1 -0
  50. package/dist/components/dropdown-menu/style.css +1 -1
  51. package/dist/components/dropdown-menu/submenu.d.ts +25 -0
  52. package/dist/components/dropdown-menu/submenu.d.ts.map +1 -0
  53. package/dist/components/dropdown-menu/submenu.js +96 -0
  54. package/dist/components/dropdown-menu/submenu.js.map +1 -0
  55. package/dist/components/dropdown-menu/types.d.ts +85 -12
  56. package/dist/components/dropdown-menu/types.d.ts.map +1 -1
  57. package/dist/components/dropdown-menu/useDropdownMenu.d.ts +4 -8
  58. package/dist/components/dropdown-menu/useDropdownMenu.d.ts.map +1 -1
  59. package/dist/components/dropdown-menu/useDropdownMenu.js +108 -81
  60. package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -1
  61. package/dist/components/select/component.js +29 -29
  62. package/dist/components/select/component.js.map +1 -1
  63. package/dist/index.js +278 -274
  64. package/dist/index.js.map +1 -1
  65. package/dist/stats.html +1 -1
  66. package/package.json +1 -1
@@ -1,9 +1,5 @@
1
1
  import { default as React } from 'react';
2
- export type DropdownMenuItemType = {
3
- /**
4
- * The type of the menu item
5
- */
6
- type: "item";
2
+ export type DropdownMenuInteractiveItemBase = {
7
3
  /**
8
4
  * The label of the menu item
9
5
  */
@@ -16,6 +12,10 @@ export type DropdownMenuItemType = {
16
12
  * The icon of the menu item
17
13
  */
18
14
  icon?: React.ReactNode;
15
+ /**
16
+ * The description of the menu item
17
+ */
18
+ description?: React.ReactNode;
19
19
  /**
20
20
  * The suffix of the menu item
21
21
  */
@@ -24,12 +24,6 @@ export type DropdownMenuItemType = {
24
24
  * The key of the menu item
25
25
  */
26
26
  key: React.Key;
27
- /**
28
- * The onSelect event handler of the menu item
29
- */
30
- onSelect?: (item: DropdownMenuItemType & {
31
- type: "item";
32
- }) => void;
33
27
  /**
34
28
  * The onClick event handler of the menu item
35
29
  */
@@ -71,7 +65,85 @@ export type DropdownMenuItemType = {
71
65
  text?: string;
72
66
  suffix?: string;
73
67
  };
74
- } | {
68
+ };
69
+ export type DropdownMenuActionItem = DropdownMenuInteractiveItemBase & {
70
+ /**
71
+ * The type of the menu item
72
+ */
73
+ type: "item";
74
+ /**
75
+ * The onSelect event handler of the menu item
76
+ */
77
+ onSelect?: (item: DropdownMenuActionItem) => void;
78
+ /**
79
+ * Submenu items that appear when this item is hovered/clicked.
80
+ * Only supported in menu mode (not in search/combobox mode).
81
+ */
82
+ children?: DropdownMenuItemType[];
83
+ };
84
+ export type DropdownMenuCheckboxItem = DropdownMenuInteractiveItemBase & {
85
+ /**
86
+ * The type of the menu item
87
+ */
88
+ type: "checkbox";
89
+ /**
90
+ * Controlled checked state
91
+ */
92
+ checked?: boolean;
93
+ /**
94
+ * Uncontrolled initial checked state
95
+ */
96
+ defaultChecked?: boolean;
97
+ /**
98
+ * Called when the checked state changes
99
+ */
100
+ onCheckedChange?: (checked: boolean, item: DropdownMenuCheckboxItem) => void;
101
+ /**
102
+ * Called when the checkbox item is selected
103
+ */
104
+ onSelect?: (item: DropdownMenuCheckboxItem) => void;
105
+ };
106
+ export type DropdownMenuRadioItem = DropdownMenuInteractiveItemBase & {
107
+ /**
108
+ * The type of the menu item
109
+ */
110
+ type: "radio";
111
+ /**
112
+ * Radio value within the group
113
+ */
114
+ value: string;
115
+ /**
116
+ * Called when the radio item is selected
117
+ */
118
+ onSelect?: (item: DropdownMenuRadioItem) => void;
119
+ };
120
+ export type DropdownMenuRadioGroupItem = {
121
+ /**
122
+ * Stable key for preserving radio-group identity across rerenders
123
+ */
124
+ key?: React.Key;
125
+ /**
126
+ * The type of the menu item
127
+ */
128
+ type: "radio-group";
129
+ /**
130
+ * Controlled selected value
131
+ */
132
+ value?: string;
133
+ /**
134
+ * Uncontrolled initial selected value
135
+ */
136
+ defaultValue?: string;
137
+ /**
138
+ * Called when the selected value changes
139
+ */
140
+ onValueChange?: (value: string) => void;
141
+ /**
142
+ * Radio items in the group
143
+ */
144
+ children: DropdownMenuRadioItem[];
145
+ };
146
+ export type DropdownMenuItemType = DropdownMenuActionItem | DropdownMenuCheckboxItem | DropdownMenuRadioGroupItem | {
75
147
  /**
76
148
  * The type of the menu item
77
149
  */
@@ -90,6 +162,7 @@ export type DropdownMenuItemType = {
90
162
  */
91
163
  className?: string;
92
164
  };
165
+ export type DropdownMenuInteractiveItem = DropdownMenuActionItem | DropdownMenuCheckboxItem | DropdownMenuRadioItem;
93
166
  export type DropdownMenuGroup = {
94
167
  label: React.ReactNode | null;
95
168
  items: DropdownMenuItemType[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAC5B;IACE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;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AG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B,sBAAsB,GACtB,wBAAwB,GACxB,0BAA0B,GAC1B;IACE;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,2BAA2B,GACnC,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { DropdownMenuItemType, DropdownMenuGroup } from './types';
1
+ import { DropdownMenuItemType, DropdownMenuGroup, DropdownMenuInteractiveItem } from './types';
2
2
  export interface UseDropdownMenuProps {
3
3
  /**
4
4
  * Callback function to handle the open state change of the dropdown menu.
@@ -17,13 +17,11 @@ export interface UseDropdownMenuProps {
17
17
  /**
18
18
  * Custom render function for menu items
19
19
  */
20
- itemRender?: (item: DropdownMenuItemType, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
20
+ itemRender?: (item: DropdownMenuInteractiveItem, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
21
21
  /**
22
22
  * Custom render function for menu item labels
23
23
  */
24
- itemLabelRender?: (item: DropdownMenuItemType & {
25
- type: "item";
26
- }, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
24
+ itemLabelRender?: (item: DropdownMenuInteractiveItem, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
27
25
  /**
28
26
  * Whether to keep the dropdown open when an item is selected
29
27
  * @default false
@@ -46,9 +44,7 @@ export interface UseDropdownMenuProps {
46
44
  * Function to extract keywords from the item for search filtering
47
45
  * @default (item) => [String(item.key), reactNodeToString(item.label)]
48
46
  */
49
- getItemKeywords?: (item: DropdownMenuItemType & {
50
- type: "item";
51
- }) => string[];
47
+ getItemKeywords?: (item: DropdownMenuInteractiveItem) => string[];
52
48
  }
53
49
  export declare const useDropdownMenu: ({ items, inCombobox, classNames, selectedItemKeys, keepOpenOnSelect, showCheckbox, getItemKeywords, onOpenChange, itemRender, itemLabelRender, }: UseDropdownMenuProps) => {
54
50
  itemGroups: DropdownMenuGroup[];
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAMlE,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,M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E,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,2BAA2B,EACjC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,CAChB,IAAI,EAAE,2BAA2B,EACjC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,KACrC,KAAK,CAAC,YAAY,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,2BAA2B,KAAK,MAAM,EAAE,CAAC;CACnE;AAED,eAAO,MAAM,eAAe,GAAI,kJAW7B,oBAAoB;;2BAGZ,oBAAoB,KAAK,MAAM,KAAK,MAAM;yBAyGzC,iBAAiB,SAAS,MAAM;CA8D3C,CAAC"}
@@ -1,128 +1,155 @@
1
- import { jsx as i, jsxs as w } from "react/jsx-runtime";
2
- import { useCallback as m, useMemo as L } from "react";
3
- import { DropdownMenuItem as I } from "./item.js";
4
- import { DropdownMenuDivider as j } from "./divider.js";
5
- import { Menu as v, Combobox as f } from "@base-ui/react";
1
+ import { jsx as u, jsxs as w } from "react/jsx-runtime";
2
+ import { useCallback as M, useMemo as I } from "react";
3
+ import { DropdownMenuItem as $ } from "./item.js";
4
+ import { DropdownMenuDivider as L } from "./divider.js";
5
+ import { DropdownMenuSubmenu as T } from "./submenu.js";
6
+ import { DropdownMenuRadioGroup as j } from "./radio-group.js";
7
+ import { isDropdownMenuSearchSupportedItem as q } from "./search-mode.js";
8
+ import { Menu as b, Combobox as v } from "@base-ui/react";
6
9
  import './style.css';/* empty css */
7
- import { useCls as k } from "../utils/antdUtils.js";
8
- import { reactNodeToString as x } from "../utils/reactToString.js";
9
- import { clsx as d } from "../utils/cn.js";
10
- const J = ({
11
- items: s,
12
- inCombobox: n = !1,
10
+ import { reactNodeToString as z } from "../utils/reactToString.js";
11
+ import { useCls as A } from "../utils/antdUtils.js";
12
+ import { clsx as y } from "../utils/cn.js";
13
+ const _ = ({
14
+ items: D,
15
+ inCombobox: t = !1,
13
16
  classNames: o = {},
14
- selectedItemKeys: h,
15
- keepOpenOnSelect: a,
17
+ selectedItemKeys: S,
18
+ keepOpenOnSelect: f,
16
19
  showCheckbox: G = !1,
17
- getItemKeywords: b = (l) => [String(l.key), x(l.label)],
18
- onOpenChange: g,
19
- itemRender: y,
20
- itemLabelRender: M
20
+ getItemKeywords: n = (p) => [String(p.key), z(p.label)],
21
+ onOpenChange: m,
22
+ itemRender: h,
23
+ itemLabelRender: g
21
24
  }) => {
22
- const l = k(), p = m(
23
- (e, r, t) => e.type === "item" ? /* @__PURE__ */ i(
24
- I,
25
+ const p = A(), d = M(
26
+ (r, i, e) => r.type === "item" || r.type === "checkbox" ? r.type === "item" && !t && r.children && r.children.length > 0 ? /* @__PURE__ */ u(
27
+ T,
25
28
  {
26
- item: e,
27
- inCombobox: n,
28
- selected: h?.includes(e.key),
29
+ item: r,
30
+ itemRender: h,
31
+ itemLabelRender: g,
32
+ showCheckbox: G,
33
+ getItemKeywords: n,
34
+ selectedItemKeys: S,
35
+ keepOpenOnSelect: f,
36
+ onOpenChange: m,
37
+ classNames: {
38
+ item: o.item,
39
+ itemIcon: o.itemIcon,
40
+ itemSuffix: o.itemSuffix,
41
+ group: o.group,
42
+ groupLabel: o.groupLabel,
43
+ divider: o.divider
44
+ }
45
+ },
46
+ String(r.key)
47
+ ) : /* @__PURE__ */ u(
48
+ $,
49
+ {
50
+ item: r,
51
+ inCombobox: t,
52
+ selected: S?.includes(r.key),
29
53
  afterSelect: () => {
30
- a || g?.(!1);
54
+ f || m?.(!1);
31
55
  },
32
- itemRender: y,
56
+ itemRender: h,
33
57
  showCheckbox: G,
34
- getItemKeywords: b,
35
- itemLabelRender: M,
58
+ getItemKeywords: n,
59
+ itemLabelRender: g,
36
60
  classNames: {
37
61
  item: o.item,
38
62
  itemIcon: o.itemIcon,
39
63
  itemSuffix: o.itemSuffix
40
64
  }
41
65
  },
42
- r + "-" + t
43
- ) : e.type === "divider" ? /* @__PURE__ */ i(
66
+ String(r.key)
67
+ ) : r.type === "radio-group" ? /* @__PURE__ */ u(
44
68
  j,
45
69
  {
46
- inCombobox: n,
70
+ group: r,
71
+ itemRender: h,
72
+ itemLabelRender: g,
73
+ getItemKeywords: n,
74
+ keepOpenOnSelect: f,
75
+ onOpenChange: m,
76
+ classNames: {
77
+ item: o.item,
78
+ itemIcon: o.itemIcon,
79
+ itemText: void 0,
80
+ itemSuffix: o.itemSuffix
81
+ }
82
+ },
83
+ r.key != null ? String(r.key) : `radio-group-${i}-${e}`
84
+ ) : r.type === "divider" ? /* @__PURE__ */ u(
85
+ L,
86
+ {
87
+ inCombobox: t,
47
88
  className: o?.divider
48
89
  },
49
- r + "-" + t
90
+ `divider-${i}-${e}`
50
91
  ) : null,
51
92
  [
52
93
  o,
53
- y,
54
- g,
55
- n,
56
- a,
57
94
  h,
95
+ m,
96
+ t,
97
+ f,
98
+ S,
58
99
  G,
59
- b,
60
- M
100
+ n,
101
+ g
61
102
  ]
62
- ), D = m(
63
- (e, r) => /* @__PURE__ */ w(
64
- v.Group,
103
+ ), k = M(
104
+ (r, i) => /* @__PURE__ */ w(
105
+ b.Group,
65
106
  {
66
- className: d(l("dropdown-menu-group"), o?.group),
107
+ className: y(p("dropdown-menu-group"), o?.group),
67
108
  children: [
68
- e.label && /* @__PURE__ */ i(
69
- v.GroupLabel,
70
- {
71
- className: d(
72
- l("dropdown-menu-header"),
73
- o?.groupLabel
74
- ),
75
- children: /* @__PURE__ */ i("span", { children: e.label })
76
- }
77
- ),
78
- e.items.map((t, u) => p(t, r, u))
109
+ r.label && /* @__PURE__ */ u(b.GroupLabel, { className: y(p("dropdown-menu-header"), o?.groupLabel), children: /* @__PURE__ */ u("span", { children: r.label }) }),
110
+ r.items.map((e, l) => d(e, i, l))
79
111
  ]
80
112
  },
81
- "group" + r
113
+ "group" + i
82
114
  ),
83
- [l, o, p]
84
- ), S = m(
85
- (e, r) => e.label ? /* @__PURE__ */ w(
86
- f.Group,
115
+ [p, o, d]
116
+ ), x = M(
117
+ (r, i) => r.label ? /* @__PURE__ */ w(
118
+ v.Group,
87
119
  {
88
- className: d(l("dropdown-menu-group"), o?.group),
89
- items: e.items,
120
+ className: y(p("dropdown-menu-group"), o?.group),
121
+ items: r.items,
90
122
  children: [
91
- /* @__PURE__ */ i(
92
- f.GroupLabel,
123
+ /* @__PURE__ */ u(
124
+ v.GroupLabel,
93
125
  {
94
- className: d(
95
- l("dropdown-menu-header"),
96
- o?.groupLabel
97
- ),
98
- children: /* @__PURE__ */ i("span", { children: e.label })
126
+ className: y(p("dropdown-menu-header"), o?.groupLabel),
127
+ children: /* @__PURE__ */ u("span", { children: r.label })
99
128
  }
100
129
  ),
101
- /* @__PURE__ */ i(f.Collection, { children: (t, u) => p(t, r, u) })
130
+ /* @__PURE__ */ u(v.Collection, { children: (e, l) => d(e, i, l) })
102
131
  ]
103
132
  },
104
- "group" + r
105
- ) : e.items.map((t, u) => p(t, r, u)),
106
- [l, o, p]
133
+ "group" + i
134
+ ) : r.items.map((e, l) => d(e, i, l)),
135
+ [p, o, d]
107
136
  );
108
137
  return {
109
- itemGroups: L(
110
- () => s.reduce((e, r) => (e.length === 0 && r.type !== "header" && e.push({
138
+ itemGroups: I(
139
+ () => D.reduce((r, i) => (t && !q(i) || (r.length === 0 && i.type !== "header" && r.push({
111
140
  label: null,
112
141
  items: []
113
- }), r.type === "header" ? e.push({
114
- label: r.title,
142
+ }), i.type === "header" ? r.push({
143
+ label: i.title,
115
144
  items: []
116
- }) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push({
117
- ...r
118
- }), e), []),
119
- [s]
145
+ }) : (i.type === "item" || i.type === "checkbox" || i.type === "radio-group" || i.type === "divider") && r.length > 0 && r[r.length - 1].items.push(i)), r), []),
146
+ [t, D]
120
147
  ),
121
- renderMenuItem: p,
122
- renderGroup: n ? S : D
148
+ renderMenuItem: d,
149
+ renderGroup: t ? x : k
123
150
  };
124
151
  };
125
152
  export {
126
- J as useDropdownMenu
153
+ _ as useDropdownMenu
127
154
  };
128
155
  //# sourceMappingURL=useDropdownMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Combobox, Menu } from \"@base-ui/react\";\n\nimport \"./style.css\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n /**\n * Function to extract keywords from the item for search filtering\n * @default (item) => [String(item.key), reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: DropdownMenuItemType & { type: \"item\" }) => string[];\n}\n\nexport const useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n afterSelect={() => {\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }}\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n itemLabelRender={itemLabelRender}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={inCombobox}\n className={classNames?.divider}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n inCombobox,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupCombobox = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Combobox.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n items={group.items}\n >\n <Combobox.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Combobox.GroupLabel>\n <Combobox.Collection>\n {(item, i) => renderMenuItem(item, index, i)}\n </Combobox.Collection>\n </Combobox.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const itemGroups = useMemo(\n () =>\n items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push({\n ...current,\n });\n }\n // Skip dividers\n return acc;\n }, []),\n [items]\n );\n return {\n itemGroups,\n renderMenuItem,\n renderGroup: inCombobox ? renderGroupCombobox : renderGroup,\n };\n};\n"],"names":["useDropdownMenu","items","inCombobox","classNames","selectedItemKeys","keepOpenOnSelect","showCheckbox","getItemKeywords","item","reactNodeToString","onOpenChange","itemRender","itemLabelRender","cls","useCls","renderMenuItem","useCallback","i","j","jsx","DropdownMenuItem","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupCombobox","Combobox","useMemo","acc","current"],"mappings":";;;;;;;;;AA+DO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,YAAAC,IAAa,CAAA;AAAA,EACb,kBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB,CAACC,MAAS,CAAC,OAAOA,EAAK,GAAG,GAAGC,EAAkBD,EAAK,KAAK,CAAC;AAAA,EAC5E,cAAAE;AAAA,EACA,YAAAC;AAAA,EACA,iBAAAC;AACF,MAA4B;AAC1B,QAAMC,IAAMC,EAAA,GACNC,IAAiBC;AAAA,IACrB,CAACR,GAA4BS,GAAWC,MAClCV,EAAK,SAAS,SAEd,gBAAAW;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,MAAAZ;AAAA,QACA,YAAAN;AAAA,QACA,UAAUE,GAAkB,SAASI,EAAK,GAAG;AAAA,QAC7C,aAAa,MAAM;AACjB,UAAKH,KAAkBK,IAAe,EAAK;AAAA,QAC7C;AAAA,QACA,YAAAC;AAAA,QACA,cAAAL;AAAA,QACA,iBAAAC;AAAA,QACA,iBAAAK;AAAA,QACA,YAAY;AAAA,UACV,MAAMT,EAAW;AAAA,UACjB,UAAUA,EAAW;AAAA,UACrB,YAAYA,EAAW;AAAA,QAAA;AAAA,MACzB;AAAA,MAfKc,IAAI,MAAMC;AAAA,IAAA,IAkBVV,EAAK,SAAS,YAErB,gBAAAW;AAAA,MAACE;AAAA,MAAA;AAAA,QAEC,YAAAnB;AAAA,QACA,WAAWC,GAAY;AAAA,MAAA;AAAA,MAFlBc,IAAI,MAAMC;AAAA,IAAA,IAMd;AAAA,IAET;AAAA,MACEf;AAAA,MACAQ;AAAA,MACAD;AAAA,MACAR;AAAA,MACAG;AAAA,MACAD;AAAA,MACAE;AAAA,MACAC;AAAA,MACAK;A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BjBD,EAAM,MAAM,IAAI,CAACf,GAAMU,MAAMH,EAAeP,GAAMgB,GAAON,CAAC,CAAC;AAAA,IAE/D,CAACL,GAAKV,GAAYY,CAAc;AAAA,EAAA;AAmClC,SAAO;AAAA,IACL,YAjCiBe;AAAA,MACjB,MACE7B,EAAM,OAA4B,CAAC8B,GAAKC,OAElCD,EAAI,WAAW,KAAKC,EAAQ,SAAS,YACvCD,EAAI,KAAK;AAAA,QACP,OAAO;AAAA,QACP,OAAO,CAAA;AAAA,MAAC,CACT,GAICC,EAAQ,SAAS,WACnBD,EAAI,KAAK;AAAA,QACP,OAAOC,EAAQ;AAAA,QACf,OAAO,CAAA;AAAA,MAAC,CACT,KAIAA,EAAQ,SAAS,UAAUA,EAAQ,SAAS,cAC7CD,EAAI,SAAS,KAEbA,EAAIA,EAAI,SAAS,CAAC,EAAE,MAAM,KAAK;AAAA,QAC7B,GAAGC;AAAA,MAAA,CACJ,GAGID,IACN,CAAA,CAAE;AAAA,MACP,CAAC9B,CAAK;AAAA,IAAA;AAAA,IAIN,gBAAAc;AAAA,IACA,aAAab,IAAa0B,IAAsBN;AAAA,EAAA;AAEpD;"}
1
+ {"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport {\n DropdownMenuItemType,\n DropdownMenuGroup,\n DropdownMenuInteractiveItem,\n DropdownMenuActionItem,\n} from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { DropdownMenuSubmenu } from \"./submenu\";\nimport { DropdownMenuRadioGroup } from \"./radio-group\";\nimport { isDropdownMenuSearchSupportedItem } from \"./search-mode\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Combobox, Menu } from \"@base-ui/react\";\n\nimport \"./style.css\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuInteractiveItem,\n props: React.HTMLAttributes<HTMLElement>,\n ) => React.ReactElement;\n /**\n * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuInteractiveItem,\n props: React.HTMLAttributes<HTMLElement>,\n ) => React.ReactElement;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n /**\n * Function to extract keywords from the item for search filtering\n * @default (item) => [String(item.key), reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: DropdownMenuInteractiveItem) => string[];\n}\n\nexport const useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\" || item.type === \"checkbox\") {\n if (item.type === \"item\" && !inCombobox && item.children && item.children.length > 0) {\n return (\n <DropdownMenuSubmenu\n key={String(item.key)}\n item={item as DropdownMenuActionItem}\n itemRender={itemRender}\n itemLabelRender={itemLabelRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n selectedItemKeys={selectedItemKeys}\n keepOpenOnSelect={keepOpenOnSelect}\n onOpenChange={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 }\n return (\n <DropdownMenuItem\n key={String(item.key)}\n item={item}\n inCombobox={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n afterSelect={() => {\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }}\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n itemLabelRender={itemLabelRender}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"radio-group\") {\n return (\n <DropdownMenuRadioGroup\n key={item.key != null ? String(item.key) : `radio-group-${i}-${j}`}\n group={item}\n itemRender={itemRender}\n itemLabelRender={itemLabelRender}\n getItemKeywords={getItemKeywords}\n keepOpenOnSelect={keepOpenOnSelect}\n onOpenChange={onOpenChange}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemText: undefined,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={`divider-${i}-${j}`}\n inCombobox={inCombobox}\n className={classNames?.divider}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n inCombobox,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n ],\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel className={clsx(cls(\"dropdown-menu-header\"), classNames?.groupLabel)}>\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem],\n );\n\n const renderGroupCombobox = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Combobox.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n items={group.items}\n >\n <Combobox.GroupLabel\n className={clsx(cls(\"dropdown-menu-header\"), classNames?.groupLabel)}\n >\n <span>{group.label}</span>\n </Combobox.GroupLabel>\n <Combobox.Collection>{(item, i) => renderMenuItem(item, index, i)}</Combobox.Collection>\n </Combobox.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem],\n );\n\n const itemGroups = useMemo(\n () =>\n items.reduce<DropdownMenuGroup[]>((acc, current) => {\n if (inCombobox && !isDropdownMenuSearchSupportedItem(current)) {\n return acc;\n }\n\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" ||\n current.type === \"checkbox\" ||\n current.type === \"radio-group\" ||\n current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []),\n [inCombobox, items],\n );\n return {\n itemGroups,\n renderMenuItem,\n renderGroup: inCombobox ? renderGroupCombobox : renderGroup,\n };\n};\n"],"names":["useDropdownMenu","items","inCombobox","classNames","selectedItemKeys","keepOpenOnSelect","showCheckbox","getItemKeywords","item","reactNodeToString","onOpenChange","itemRender","itemLabelRender","cls","useCls","renderMenuItem","useCallback","j","jsx","DropdownMenuSubmenu","DropdownMenuItem","DropdownMenuRadioGroup","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupCombobox","Combobox","i","useMemo","acc","current","isDropdownMenuSearchSupportedItem"],"mappings":";;;;;;;;;;;;AAuEO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,YAA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EAAI,SAAS,CAAC,EAAE,MAAM,KAAKC,CAAO,IAGjCD,IACN,CAAA,CAAE;AAAA,MACP,CAAC/B,GAAYD,CAAK;AAAA,IAAA;AAAA,IAIlB,gBAAAc;AAAA,IACA,aAAab,IAAa2B,IAAsBN;AAAA,EAAA;AAEpD;"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { jsx as t, Fragment as y, jsxs as G } from "react/jsx-runtime";
2
+ import { jsx as o, Fragment as b, jsxs as G } from "react/jsx-runtime";
3
3
  import { CaretDown as de } from "@bioturing/assets";
4
- import { useFloatingPortalNode as fe, offset as ge, autoPlacement as he, shift as be, size as ye, useFloating as Ae, autoUpdate as Ce, FloatingOverlay as Re } from "@floating-ui/react";
4
+ import { useFloatingPortalNode as fe, offset as ge, autoPlacement as he, shift as ye, size as be, useFloating as Ae, autoUpdate as Ce, FloatingOverlay as Re } from "@floating-ui/react";
5
5
  import V from "antd/es/checkbox";
6
6
  import R from "antd/es/select";
7
7
  import { toMerged as ke } from "es-toolkit";
@@ -44,19 +44,19 @@ const Oe = ({
44
44
  B,
45
45
  J || L,
46
46
  H
47
- ), m = Me(), [o, g] = W(
47
+ ), m = Me(), [r, g] = W(
48
48
  Z,
49
49
  _,
50
50
  z
51
- ), h = C(X), b = C(Y), P = C(ee), N = n(
51
+ ), h = C(X), y = C(Y), P = C(ee), N = n(
52
52
  ({
53
53
  availableHeight: e,
54
- availableWidth: r,
54
+ availableWidth: t,
55
55
  elements: i
56
56
  }) => {
57
57
  i.floating.style.setProperty(
58
58
  "--available-width",
59
- r + "px"
59
+ t + "px"
60
60
  ), i.floating.style.setProperty(
61
61
  "--available-height",
62
62
  e + "px"
@@ -78,10 +78,10 @@ const Oe = ({
78
78
  "top"
79
79
  ]
80
80
  }),
81
- be({
81
+ ye({
82
82
  padding: 8
83
83
  }),
84
- ye({
84
+ be({
85
85
  padding: 8,
86
86
  apply: N
87
87
  })
@@ -95,8 +95,8 @@ const Oe = ({
95
95
  whileElementsMounted: Ce
96
96
  }), ne = n(
97
97
  (e) => {
98
- const r = Array.isArray(e) ? e.length : 1;
99
- return p ? r + ` ${r == 1 ? "item" : "items"} selected` : /* @__PURE__ */ t(y, { children: e });
98
+ const t = Array.isArray(e) ? e.length : 1;
99
+ return p ? t + ` ${t == 1 ? "item" : "items"} selected` : /* @__PURE__ */ o(b, { children: e });
100
100
  },
101
101
  [p]
102
102
  ), se = T(
@@ -111,8 +111,8 @@ const Oe = ({
111
111
  }), j = n(
112
112
  (e) => {
113
113
  if (!e) return;
114
- const r = e.closest(".ds-select-dropdown");
115
- u.setFloating(r);
114
+ const t = e.closest(".ds-select-dropdown");
115
+ u.setFloating(t);
116
116
  },
117
117
  [u]
118
118
  ), ce = $(
@@ -127,11 +127,11 @@ const Oe = ({
127
127
  k?.popup?.root || K
128
128
  ), ie = l && typeof l == "string" && l in U ? U[l] : typeof l == "number" ? l + "px" : l || "fit-content", d = n(
129
129
  (e) => {
130
- const r = h.current ? h.current(e) : b.current ? b.current(e) : e;
131
- if (!M) return r;
132
- const i = Array.isArray(o) && o.length > 0, ue = Array.isArray(o) && o.length && o.length < c.length;
133
- return /* @__PURE__ */ G(y, { children: [
134
- /* @__PURE__ */ t(
130
+ const t = h.current ? h.current(e) : y.current ? y.current(e) : e;
131
+ if (!M) return t;
132
+ const i = Array.isArray(r) && r.length > 0, ue = Array.isArray(r) && r.length && r.length < c.length;
133
+ return /* @__PURE__ */ G(b, { children: [
134
+ /* @__PURE__ */ o(
135
135
  we,
136
136
  {
137
137
  className: m(
@@ -149,15 +149,15 @@ const Oe = ({
149
149
  onDeselectAll: F
150
150
  }
151
151
  ),
152
- /* @__PURE__ */ t(ve, {}),
153
- r
152
+ /* @__PURE__ */ o(ve, {}),
153
+ t
154
154
  ] });
155
155
  },
156
156
  [
157
157
  h,
158
- b,
158
+ y,
159
159
  M,
160
- o,
160
+ r,
161
161
  c,
162
162
  m,
163
163
  P,
@@ -170,23 +170,23 @@ const Oe = ({
170
170
  },
171
171
  [a, u]
172
172
  ), E = n(
173
- (e) => /* @__PURE__ */ G(y, { children: [
174
- /* @__PURE__ */ t(Re, { lockScroll: !0, onClick: I }),
175
- /* @__PURE__ */ t("div", { ref: j, children: d(e) })
173
+ (e) => /* @__PURE__ */ G(b, { children: [
174
+ /* @__PURE__ */ o(Re, { lockScroll: !0, onClick: I }),
175
+ /* @__PURE__ */ o("div", { ref: j, children: d(e) })
176
176
  ] }),
177
177
  [I, j, d]
178
178
  ), me = n(
179
179
  (e) => s ? E(e) : d(e),
180
180
  [s, d, E]
181
181
  );
182
- return /* @__PURE__ */ t(
182
+ return /* @__PURE__ */ o(
183
183
  R,
184
184
  {
185
185
  ref: pe,
186
- suffixIcon: /* @__PURE__ */ t(de, { weight: "bold" }),
186
+ suffixIcon: /* @__PURE__ */ o(de, { weight: "bold" }),
187
187
  open: O,
188
188
  onOpenChange: S,
189
- value: o,
189
+ value: r,
190
190
  onChange: g,
191
191
  classNames: {
192
192
  popup: {
@@ -195,7 +195,7 @@ const Oe = ({
195
195
  ...k
196
196
  },
197
197
  ...p ? {
198
- menuItemSelectedIcon: ({ isSelected: e }) => /* @__PURE__ */ t("span", { className: "ant-select-checkbox-indicator", children: e ? /* @__PURE__ */ t(V, { checked: !0 }) : /* @__PURE__ */ t(V, { checked: !1 }) })
198
+ menuItemSelectedIcon: ({ isSelected: e, disabled: t }) => /* @__PURE__ */ o("span", { className: "ant-select-checkbox-indicator", children: e ? /* @__PURE__ */ o(V, { checked: !0, disabled: t }) : /* @__PURE__ */ o(V, { checked: !1, disabled: t }) })
199
199
  } : {},
200
200
  mode: f,
201
201
  className: ce,
@@ -214,7 +214,7 @@ const Oe = ({
214
214
  ...v ? {
215
215
  maxTagCount: 1,
216
216
  showSearch: !1,
217
- labelRender: () => w ? w(o) : ne(o)
217
+ labelRender: () => w ? w(r) : ne(r)
218
218
  } : {},
219
219
  ...te
220
220
  }