@bioturing/components 0.29.1 → 0.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,117 +1,144 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as c } from "react/jsx-runtime";
3
- import { Command as s } from "../cmdk/index.js";
4
- import { useMemo as y, useCallback as f } from "react";
2
+ import { jsxs as p, jsx as t } from "react/jsx-runtime";
3
+ import { Command as d } from "../cmdk/index.js";
4
+ import { useMemo as P, useContext as v, useCallback as b } from "react";
5
5
  import './style.css';/* empty css */
6
- import { FormItemInputContext as V } from "antd/es/form/context";
7
- import { Radio as j } from "../radio/component.js";
8
- import { useControlledState as B } from "../hooks/useControlledState.js";
9
- import { useCls as E } from "../utils/antdUtils.js";
10
- import { cn as F } from "../utils/cn.js";
11
- import { Input as L } from "../input/component.js";
12
- import { Checkbox as p } from "../checkbox/component.js";
13
- import { ScrollArea as w } from "../scroll-area/component.js";
14
- import { reactNodeToString as D } from "../utils/reactToString.js";
15
- const W = ({
16
- items: a,
17
- multiple: r,
18
- value: v,
19
- defaultValue: g,
20
- onChange: S,
21
- searchProps: C = { placeholder: "Search..." },
6
+ import { FormItemInputContext as x } from "antd/es/form/context";
7
+ import R from "antd/es/config-provider/DisabledContext";
8
+ import { Radio as T } from "../radio/component.js";
9
+ import { useControlledState as q } from "../hooks/useControlledState.js";
10
+ import { useCls as w } from "../utils/antdUtils.js";
11
+ import { cn as z } from "../utils/cn.js";
12
+ import { Input as G } from "../input/component.js";
13
+ import { Checkbox as S } from "../checkbox/component.js";
14
+ import { ScrollArea as H } from "../scroll-area/component.js";
15
+ import { reactNodeToString as J } from "../utils/reactToString.js";
16
+ const ae = ({
17
+ items: i,
18
+ multiple: a,
19
+ value: g,
20
+ defaultValue: C,
21
+ onChange: A,
22
+ searchProps: k = { placeholder: "Search..." },
22
23
  showSelectAll: I = !1,
23
- className: b,
24
- placeholder: k = "Search",
25
- ...x
24
+ className: N,
25
+ placeholder: y = "Search",
26
+ disabled: D = !1,
27
+ status: V,
28
+ getItemKeywords: m,
29
+ ...j
26
30
  }) => {
27
- const [i, t] = B(
28
- v,
29
- S,
30
- g
31
- ), o = y(() => r ? i || [] : i ? [i] : [], [i, r]), n = E(), N = f(() => {
32
- if (r) {
33
- const e = a.map((l) => l.value).filter(Boolean);
34
- t(e);
31
+ const [l, c] = q(
32
+ g,
33
+ A,
34
+ C
35
+ ), s = P(() => a ? Array.isArray(l) ? l : l ? [l] : [] : Array.isArray(l) ? l.length > 0 ? [l[0]] : [] : l ? [l] : [], [l, a]), {
36
+ status: B
37
+ } = v(x), E = v(R), F = V || B, o = D || E, n = w(), L = b(() => {
38
+ if (a) {
39
+ const e = i.map((r) => r.value).filter(Boolean);
40
+ c(e);
35
41
  }
36
- }, [r, a, t]), A = f(() => {
37
- r && t([]);
38
- }, [r, t]);
39
- return /* @__PURE__ */ u(s, { className: F(n("choice-list"), b), ...x, children: [
40
- /* @__PURE__ */ c(V.Provider, { value: {}, children: /* @__PURE__ */ c(
41
- s.Input,
42
- {
43
- render: (
44
- // isolate the input from the form context
45
- /* @__PURE__ */ c(
46
- L.Search,
42
+ }, [a, i, c]), M = b(() => {
43
+ a && c([]);
44
+ }, [a, c]);
45
+ return /* @__PURE__ */ p(
46
+ d,
47
+ {
48
+ className: z(n("choice-list"), N),
49
+ "data-disabled": o,
50
+ "data-status": F,
51
+ ...j,
52
+ children: [
53
+ /* @__PURE__ */ t(x.Provider, { value: {}, children: /* @__PURE__ */ t(
54
+ d.Input,
55
+ {
56
+ render: (
57
+ // isolate the input from the form context
58
+ /* @__PURE__ */ t(
59
+ G.Search,
60
+ {
61
+ allowClear: !0,
62
+ disabled: o,
63
+ className: n("choice-list-search"),
64
+ placeholder: y
65
+ }
66
+ )
67
+ ),
68
+ ...k
69
+ }
70
+ ) }),
71
+ I && a && i.length > 0 && (() => {
72
+ const e = i.map((f) => f.value).filter(Boolean), r = s.filter(
73
+ (f) => e.includes(f)
74
+ ), u = r.length === e.length && e.length > 0, h = r.length > 0 && r.length < e.length;
75
+ return /* @__PURE__ */ t(
76
+ "div",
47
77
  {
48
- allowClear: !0,
49
- className: n("choice-list-search"),
50
- placeholder: k
78
+ className: n("choice-list-item"),
79
+ onClick: () => {
80
+ o || (h || u ? M() : L());
81
+ },
82
+ children: /* @__PURE__ */ t(
83
+ S,
84
+ {
85
+ tabIndex: -1,
86
+ checked: u,
87
+ indeterminate: h,
88
+ disabled: o,
89
+ children: "Select All"
90
+ }
91
+ )
51
92
  }
52
- )
53
- ),
54
- ...C
55
- }
56
- ) }),
57
- I && r && a.length > 0 && (() => {
58
- const e = a.map((m) => m.value).filter(Boolean), l = o.filter(
59
- (m) => e.includes(m)
60
- ), d = l.length === e.length && e.length > 0, h = l.length > 0 && l.length < e.length;
61
- return /* @__PURE__ */ c(
62
- "div",
63
- {
64
- className: n("choice-list-item"),
65
- onClick: () => {
66
- h || d ? A() : N();
67
- },
68
- children: /* @__PURE__ */ c(
69
- p,
93
+ );
94
+ })(),
95
+ /* @__PURE__ */ t(H, { className: n("choice-list-items"), fadeEdges: !0, children: /* @__PURE__ */ p(d.List, { children: [
96
+ /* @__PURE__ */ t(d.Empty, { className: n("choice-list-empty"), children: "No results found." }),
97
+ i.map((e) => /* @__PURE__ */ t(
98
+ d.Item,
70
99
  {
71
- tabIndex: -1,
72
- checked: d,
73
- indeterminate: h,
74
- children: "Select All"
75
- }
76
- )
77
- }
78
- );
79
- })(),
80
- /* @__PURE__ */ c(w, { className: n("choice-list-items"), fadeEdges: !0, children: /* @__PURE__ */ u(s.List, { children: [
81
- /* @__PURE__ */ c(s.Empty, { className: n("choice-list-empty"), children: "No results found." }),
82
- a.map((e) => /* @__PURE__ */ c(
83
- s.Item,
84
- {
85
- className: n("choice-list-item"),
86
- keywords: [e.value, D(e.label)],
87
- value: e.value,
88
- "data-in-choice": o.includes(e.value),
89
- onSelect: (l) => {
90
- if (r) {
91
- const d = o.includes(l) ? o.filter((h) => h !== l) : [.../* @__PURE__ */ new Set([...o, l])];
92
- t(
93
- d
94
- );
95
- } else
96
- t(
97
- l
98
- );
99
- },
100
- children: r ? /* @__PURE__ */ c(
101
- p,
102
- {
103
- tabIndex: -1,
104
- checked: o.includes(e.value),
105
- children: e.label
106
- }
107
- ) : /* @__PURE__ */ c(j, { tabIndex: -1, checked: o.includes(e.value), children: e.label })
108
- },
109
- e.value
110
- ))
111
- ] }) })
112
- ] });
100
+ className: n("choice-list-item"),
101
+ keywords: m ? m(e) : [e.value || "", J(e.label)],
102
+ value: e.value,
103
+ "data-in-choice": e.value ? s.includes(e.value) : !1,
104
+ onSelect: (r) => {
105
+ if (!o)
106
+ if (a) {
107
+ const u = s.includes(r) ? s.filter((h) => h !== r) : [.../* @__PURE__ */ new Set([...s, r])];
108
+ c(
109
+ u
110
+ );
111
+ } else
112
+ c(
113
+ r
114
+ );
115
+ },
116
+ children: a ? /* @__PURE__ */ t(
117
+ S,
118
+ {
119
+ tabIndex: -1,
120
+ checked: e.value ? s.includes(e.value) : !1,
121
+ disabled: o,
122
+ children: e.label
123
+ }
124
+ ) : /* @__PURE__ */ t(
125
+ T,
126
+ {
127
+ tabIndex: -1,
128
+ checked: e.value ? s.includes(e.value) : !1,
129
+ disabled: o,
130
+ children: e.label
131
+ }
132
+ )
133
+ },
134
+ e.value
135
+ ))
136
+ ] }) })
137
+ ]
138
+ }
139
+ );
113
140
  };
114
141
  export {
115
- W as ChoiceList
142
+ ae as ChoiceList
116
143
  };
117
144
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/choice-list/component.tsx"],"sourcesContent":["\"use client\";\nimport { Command, CommandProps } from \"../cmdk\";\nimport { Input } from \"../input\";\nimport { useCallback, useMemo } from \"react\";\nimport { useCls, cn, reactNodeToString } from \"../utils\";\nimport { useControlledState } from \"../hooks\";\nimport { Radio } from \"../radio\";\nimport { Checkbox } from \"../checkbox\";\nimport { ScrollArea } from \"../scroll-area\";\n\nimport \"./style.css\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\n\nexport type ChoiceListItem = {\n label: React.ReactNode;\n value?: string;\n};\n\nexport interface ChoiceListProps<M extends boolean = false>\n extends Omit<CommandProps, \"value\" | \"onChange\" | \"defaultValue\"> {\n items: ChoiceListItem[];\n multiple?: M;\n value?: M extends true ? string[] : string;\n defaultValue?: M extends true ? string[] : string;\n onChange?: (value: M extends true ? string[] : string) => void;\n searchProps?: React.ComponentProps<typeof Command.Input>;\n /**\n * Show select all option when in multiple mode\n * @default false\n */\n showSelectAll?: boolean;\n placeholder?: string;\n}\n\nexport const ChoiceList = <M extends boolean = false>({\n items,\n multiple,\n value,\n defaultValue,\n onChange,\n searchProps = { placeholder: \"Search...\" },\n showSelectAll = false,\n className,\n placeholder = \"Search\",\n ...rest\n}: ChoiceListProps<M>) => {\n const [internalValue, setInternalValue] = useControlledState(\n value,\n onChange,\n defaultValue,\n );\n\n const usedValue = useMemo(() => {\n if (multiple) {\n return (internalValue as string[]) || [];\n } else {\n return internalValue ? [internalValue as string] : [];\n }\n }, [internalValue, multiple]);\n const cls = useCls();\n\n const handleSelectAll = useCallback(() => {\n if (multiple) {\n const allValues = items\n .map((item) => item.value)\n .filter(Boolean) as string[];\n setInternalValue(allValues as M extends true ? string[] : string);\n }\n }, [multiple, items, setInternalValue]);\n\n const handleDeselectAll = useCallback(() => {\n if (multiple) {\n setInternalValue([] as M extends true ? string[] : string);\n }\n }, [multiple, setInternalValue]);\n\n return (\n <Command className={cn(cls(\"choice-list\"), className)} {...rest}>\n <FormItemInputContext.Provider value={{}}>\n <Command.Input\n render={\n // isolate the input from the form context\n <Input.Search\n allowClear\n className={cls(\"choice-list-search\")}\n placeholder={placeholder}\n />\n }\n {...searchProps}\n />\n </FormItemInputContext.Provider>\n {showSelectAll &&\n multiple &&\n items.length > 0 &&\n (() => {\n const allValues = items\n .map((item) => item.value)\n .filter(Boolean) as string[];\n const selectedFromAll = usedValue.filter((val) =>\n allValues.includes(val),\n );\n const checked =\n selectedFromAll.length === allValues.length && allValues.length > 0;\n const indeterminate =\n selectedFromAll.length > 0 &&\n selectedFromAll.length < allValues.length;\n\n return (\n <div\n className={cls(\"choice-list-item\")}\n onClick={() => {\n if (indeterminate || checked) {\n handleDeselectAll();\n } else {\n handleSelectAll();\n }\n }}\n >\n <Checkbox\n tabIndex={-1}\n checked={checked}\n indeterminate={indeterminate}\n >\n Select All\n </Checkbox>\n </div>\n );\n })()}\n <ScrollArea className={cls(\"choice-list-items\")} fadeEdges>\n <Command.List>\n <Command.Empty className={cls(\"choice-list-empty\")}>\n No results found.\n </Command.Empty>\n {items.map((item) => (\n <Command.Item\n key={item.value}\n className={cls(\"choice-list-item\")}\n keywords={[item.value, reactNodeToString(item.label)]}\n value={item.value}\n data-in-choice={usedValue.includes(item.value)}\n onSelect={(newValue) => {\n if (multiple) {\n const newValues = usedValue.includes(newValue)\n ? usedValue.filter((value) => value !== newValue)\n : [...new Set([...usedValue, newValue])];\n setInternalValue(\n newValues as M extends true ? string[] : string,\n );\n } else {\n setInternalValue(\n newValue as M extends true ? string[] : string,\n );\n }\n }}\n >\n {multiple ? (\n <Checkbox\n tabIndex={-1}\n checked={usedValue.includes(item.value)}\n >\n {item.label}\n </Checkbox>\n ) : (\n <Radio tabIndex={-1} checked={usedValue.includes(item.value)}>\n {item.label}\n </Radio>\n )}\n </Command.Item>\n ))}\n </Command.List>\n </ScrollArea>\n </Command>\n );\n};\n"],"names":["ChoiceList","items","multiple","value","defaultValue","onChange","searchProps","showSelectAll","className","placeholder","rest","internalValue","setInternalValue","useControlledState","usedValue","useMemo","cls","useCls","handleSelectAll","useCallback","allValues","item","handleDeselectAll","jsxs","Command","cn","jsx","FormItemInputContext","Input","selectedFromAll","val","checked","indeterminate","Checkbox","ScrollArea","reactNodeToString","newValue","newValues","Radio"],"mappings":";;;;;;;;;;;;;;AAkCO,MAAMA,IAAa,CAA4B;AAAA,EACpD,OAAAC;AAAA,EACA,UAAAC;A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AAO,oBAAA,IAAI,CAAC,GAAGtB,GAAWsB,CAAQ,CAAC,CAAC;AACzC,cAAAxB;AAAA,gBACEyB;AAAA,cACF;AAAA,YAAA;AAEA,cAAAzB;AAAA,gBACEwB;AAAA,cACF;AAAA,UAEJ;AAAA,UAEC,UACClC,IAAA,gBAAAwB;AAAA,YAACO;AAAA,YAAA;AAAA,cACC,UAAU;AAAA,cACV,SAASnB,EAAU,SAASO,EAAK,KAAK;AAAA,cAErC,UAAKA,EAAA;AAAA,YAAA;AAAA,UAGR,IAAA,gBAAAK,EAACY,GAAM,EAAA,UAAU,IAAI,SAASxB,EAAU,SAASO,EAAK,KAAK,GACxD,UAAAA,EAAK,MACR,CAAA;AAAA,QAAA;AAAA,QA9BGA,EAAK;AAAA,MAiCb,CAAA;AAAA,IAAA,EAAA,CACH,EACF,CAAA;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/choice-list/component.tsx"],"sourcesContent":["\"use client\";\nimport { Command, CommandProps } from \"../cmdk\";\nimport { Input } from \"../input\";\nimport { useCallback, useMemo, useContext } from \"react\";\nimport { useCls, cn, reactNodeToString } from \"../utils\";\nimport { useControlledState } from \"../hooks\";\nimport { Radio } from \"../radio\";\nimport { Checkbox } from \"../checkbox\";\nimport { ScrollArea } from \"../scroll-area\";\n\nimport \"./style.css\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\nimport DisabledContext from \"antd/es/config-provider/DisabledContext\";\n\nexport type ChoiceListItem = {\n label: React.ReactNode;\n value?: string;\n};\n\nexport interface ChoiceListProps<M extends boolean = false>\n extends Omit<CommandProps, \"value\" | \"onChange\" | \"defaultValue\"> {\n items: ChoiceListItem[];\n multiple?: M;\n value?: M extends true ? string[] : string;\n defaultValue?: M extends true ? string[] : string;\n onChange?: (value: M extends true ? string[] : string) => void;\n searchProps?: React.ComponentProps<typeof Command.Input>;\n /**\n * Show select all option when in multiple mode\n * @default false\n */\n showSelectAll?: boolean;\n placeholder?: string;\n /**\n * Whether the choice list is disabled\n * @default false\n */\n disabled?: boolean;\n /**\n * Validation status\n */\n status?: \"error\" | \"warning\" | \"success\" | \"validating\";\n /**\n * Function to extract keywords from the item for search filtering\n * @default (item) => [item.value, reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: ChoiceListItem) => string[];\n}\n\nexport const ChoiceList = <M extends boolean = false>({\n items,\n multiple,\n value,\n defaultValue,\n onChange,\n searchProps = { placeholder: \"Search...\" },\n showSelectAll = false,\n className,\n placeholder = \"Search\",\n disabled: disabledProp = false,\n status: statusProp,\n getItemKeywords,\n ...rest\n}: ChoiceListProps<M>) => {\n const [internalValue, setInternalValue] = useControlledState(\n value,\n onChange,\n defaultValue,\n );\n\n const usedValue = useMemo(() => {\n if (multiple) {\n // Ensure we always return an array for multiple mode\n if (Array.isArray(internalValue)) {\n return internalValue;\n }\n return internalValue ? [internalValue as string] : [];\n } else {\n // For single mode, convert to array for consistent usage\n if (Array.isArray(internalValue)) {\n return internalValue.length > 0 ? [internalValue[0]] : [];\n }\n return internalValue ? [internalValue as string] : [];\n }\n }, [internalValue, multiple]);\n\n // Get form context values\n const {\n status: contextStatus,\n } = useContext(FormItemInputContext);\n const contextDisabled = useContext(DisabledContext);\n\n // Merge context values with props\n const mergedStatus = statusProp || contextStatus;\n const disabled = disabledProp || contextDisabled;\n\n const cls = useCls();\n\n const handleSelectAll = useCallback(() => {\n if (multiple) {\n const allValues = items\n .map((item) => item.value)\n .filter(Boolean) as string[];\n setInternalValue(allValues as M extends true ? string[] : string);\n }\n }, [multiple, items, setInternalValue]);\n\n const handleDeselectAll = useCallback(() => {\n if (multiple) {\n setInternalValue([] as M extends true ? string[] : string);\n }\n }, [multiple, setInternalValue]);\n\n return (\n <Command \n className={cn(cls(\"choice-list\"), className)} \n data-disabled={disabled}\n data-status={mergedStatus}\n {...rest}\n >\n <FormItemInputContext.Provider value={{}}>\n <Command.Input\n render={\n // isolate the input from the form context\n <Input.Search\n allowClear\n disabled={disabled}\n className={cls(\"choice-list-search\")}\n placeholder={placeholder}\n />\n }\n {...searchProps}\n />\n </FormItemInputContext.Provider>\n {showSelectAll &&\n multiple &&\n items.length > 0 &&\n (() => {\n const allValues = items\n .map((item) => item.value)\n .filter(Boolean) as string[];\n const selectedFromAll = usedValue.filter((val) =>\n allValues.includes(val),\n );\n const checked =\n selectedFromAll.length === allValues.length && allValues.length > 0;\n const indeterminate =\n selectedFromAll.length > 0 &&\n selectedFromAll.length < allValues.length;\n\n return (\n <div\n className={cls(\"choice-list-item\")}\n onClick={() => {\n if (disabled) return;\n if (indeterminate || checked) {\n handleDeselectAll();\n } else {\n handleSelectAll();\n }\n }}\n >\n <Checkbox\n tabIndex={-1}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n >\n Select All\n </Checkbox>\n </div>\n );\n })()}\n <ScrollArea className={cls(\"choice-list-items\")} fadeEdges>\n <Command.List>\n <Command.Empty className={cls(\"choice-list-empty\")}>\n No results found.\n </Command.Empty>\n {items.map((item) => (\n <Command.Item\n key={item.value}\n className={cls(\"choice-list-item\")}\n keywords={getItemKeywords ? getItemKeywords(item) : [item.value || '', reactNodeToString(item.label)]}\n value={item.value}\n data-in-choice={item.value ? usedValue.includes(item.value) : false}\n onSelect={(newValue) => {\n if (disabled) return;\n if (multiple) {\n const newValues = usedValue.includes(newValue)\n ? usedValue.filter((value) => value !== newValue)\n : [...new Set([...usedValue, newValue])];\n setInternalValue(\n newValues as M extends true ? string[] : string,\n );\n } else {\n setInternalValue(\n newValue as M extends true ? string[] : string,\n );\n }\n }}\n >\n {multiple ? (\n <Checkbox\n tabIndex={-1}\n checked={item.value ? usedValue.includes(item.value) : false}\n disabled={disabled}\n >\n {item.label}\n </Checkbox>\n ) : (\n <Radio \n tabIndex={-1} \n checked={item.value ? usedValue.includes(item.value) : false}\n disabled={disabled}\n >\n {item.label}\n </Radio>\n )}\n </Command.Item>\n ))}\n </Command.List>\n </ScrollArea>\n </Command>\n );\n};\n"],"names":["ChoiceList","items","multiple","value","defaultValue","onChange","searchProps","showSelectAll","className","placeholder","disabledProp","statusProp","getItemKeywords","rest","internalValue","setInternalValue","useControlledState","usedValue","useMemo","contextStatus","useContext","FormItemInputContext","contextDisabled","DisabledContext","mergedStatus","disabled","cls","useCls","handleSelectAll","useCallback","allValues","item","handleDeselectAll","jsxs","Command","cn","jsx","Input","selectedFromAll","val","checked","indeterminate","Checkbox","ScrollArea","reactNodeToString","newValue","newValues","Radio"],"mappings":";;;;;;;;;;;;;;;AAiDO,MAAMA,KAAa,CAA4B;AAAA,EACpD,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc,EAAE,aAAa,YAAY;AAAA,EACzC,eAAAC,IAAgB;AAAA,EAChB,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,UAAUC,IAAe;AAAA,EACzB,QAAQC;AAAA,EACR,iBAAAC;AAAA,EACA,GAAGC;AACL,MAA0B;AAClB,QAAA,CAACC,GAAeC,CAAgB,IAAIC;AAAA,IACxCb;AAAA,IACAE;AAAA,IACAD;AAAA,EACF,GAEMa,IAAYC,EAAQ,MACpBhB,IAEE,MAAM,QAAQY,CAAa,IACtBA,IAEFA,IAAgB,CAACA,CAAuB,IAAI,CAAC,IAGhD,MAAM,QAAQA,CAAa,IACtBA,EAAc,SAAS,IAAI,CAACA,EAAc,CAAC,CAAC,IAAI,CAAC,IAEnDA,IAAgB,CAACA,CAAuB,IAAI,CAAC,GAErD,CAACA,GAAeZ,CAAQ,CAAC,GAGtB;AAAA,IACJ,QAAQiB;AAAA,EAAA,IACNC,EAAWC,CAAoB,GAC7BC,IAAkBF,EAAWG,CAAe,GAG5CC,IAAeb,KAAcQ,GAC7BM,IAAWf,KAAgBY,GAE3BI,IAAMC,EAAO,GAEbC,IAAkBC,EAAY,MAAM;AACxC,QAAI3B,GAAU;AACN,YAAA4B,IAAY7B,EACf,IAAI,CA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U,SAASc,EAAK,KAAK,IAAI;AAAA,kBACvD,UAAAN;AAAA,kBAEC,UAAKM,EAAA;AAAA,gBAAA;AAAA,cAAA,IAGR,gBAAAK;AAAA,gBAACW;AAAA,gBAAA;AAAA,kBACC,UAAU;AAAA,kBACV,SAAShB,EAAK,QAAQd,EAAU,SAASc,EAAK,KAAK,IAAI;AAAA,kBACvD,UAAAN;AAAA,kBAEC,UAAKM,EAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YACR;AAAA,YApCGA,EAAK;AAAA,UAuCb,CAAA;AAAA,QAAA,EAAA,CACH,EACF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -5,10 +5,10 @@ import { Highlight as J, themes as K } from "prism-react-renderer";
5
5
  import { useState as p, useEffect as Q, useCallback as I } from "react";
6
6
  import { ThemeProvider as R } from "../theme-provider/component.js";
7
7
  import './style.css';/* empty css */
8
- import { reactNodeToString as U } from "../utils/reactToString.js";
9
- import { WithAntdTokens as V } from "../utils/WithAntdTokens.js";
10
- import { Segmented as X } from "../segmented/component.js";
11
- import { useControlledState as Y } from "../hooks/useControlledState.js";
8
+ import { WithAntdTokens as U } from "../utils/WithAntdTokens.js";
9
+ import { Segmented as V } from "../segmented/component.js";
10
+ import { useControlledState as X } from "../hooks/useControlledState.js";
11
+ import { reactNodeToString as Y } from "../utils/reactToString.js";
12
12
  import { useCls as Z } from "../utils/antdUtils.js";
13
13
  import { clsx as H } from "../utils/cn.js";
14
14
  import { IconButton as N } from "../icon-button/component.js";
@@ -30,7 +30,7 @@ const vo = ({
30
30
  onCopy: C,
31
31
  ...A
32
32
  }) => {
33
- const [l, y] = Y(
33
+ const [l, y] = X(
34
34
  j,
35
35
  x,
36
36
  b
@@ -51,7 +51,7 @@ const vo = ({
51
51
  y
52
52
  ]);
53
53
  const [T, u] = p(a), [D, S] = p(!1), E = I(() => {
54
- const t = c || U(m);
54
+ const t = c || Y(m);
55
55
  try {
56
56
  navigator.clipboard.writeText(t).then(() => {
57
57
  u(g), S(!0), C && C(t);
@@ -63,13 +63,13 @@ const vo = ({
63
63
  u(a), S(!1);
64
64
  }, [a]), d = Z();
65
65
  return /* @__PURE__ */ o(R, { theme: "dark", children: /* @__PURE__ */ q(
66
- V,
66
+ U,
67
67
  {
68
68
  className: H(d("code-block"), O, e == null ? void 0 : e.root),
69
69
  ...A,
70
70
  children: [
71
71
  f && /* @__PURE__ */ o("div", { className: d("code-block-header", e == null ? void 0 : e.header), children: /* @__PURE__ */ o(
72
- X,
72
+ V,
73
73
  {
74
74
  value: l,
75
75
  onChange: y,
@@ -1,22 +1,22 @@
1
1
  "use client";
2
2
  import { jsx as e, jsxs as b } from "react/jsx-runtime";
3
- import { useCallback as w, useRef as Q, createElement as X } from "react";
3
+ import { useCallback as w, useRef as X, createElement as Y } from "react";
4
4
  import { Menu as P } from "@base-ui-components/react/menu";
5
- import { useControlled as Y } from "@base-ui-components/utils/useControlled";
6
- import { Popover as Z } from "@base-ui-components/react/popover";
5
+ import { useControlled as Z } from "@base-ui-components/utils/useControlled";
6
+ import { Popover as $ } from "@base-ui-components/react/popover";
7
7
  import { Command as g } from "../cmdk/index.js";
8
- import { FormItemInputContext as $ } from "antd/es/form/context";
8
+ import { FormItemInputContext as O } from "antd/es/form/context";
9
9
  import { PopupPanelSize as S } from "../popup-panel/constants.js";
10
- import { DropdownMenuItem as O } from "./item.js";
10
+ import { DropdownMenuItem as K } from "./item.js";
11
11
  import './style.css';/* empty css */
12
- import { DropdownMenuDivider as K } from "./divider.js";
13
- import { parseAntdPlacement as a } from "../utils/placement.js";
14
- import { Input as N } from "../input/component.js";
12
+ import { DropdownMenuDivider as a } from "./divider.js";
13
+ import { parseAntdPlacement as N } from "../utils/placement.js";
14
+ import { Input as s } from "../input/component.js";
15
15
  import { ScrollArea as _ } from "../scroll-area/component.js";
16
- import { DROPDOWN_COLLISION_AVOIDANCE as s } from "../utils/constants.js";
17
- import { useCls as oo, useAntdCssVarClassname as ro } from "../utils/antdUtils.js";
16
+ import { DROPDOWN_COLLISION_AVOIDANCE as oo } from "../utils/constants.js";
17
+ import { useCls as ro, useAntdCssVarClassname as no } from "../utils/antdUtils.js";
18
18
  import { clsx as u } from "../utils/cn.js";
19
- const Go = ({
19
+ const Mo = ({
20
20
  children: j,
21
21
  items: z,
22
22
  placement: B,
@@ -37,9 +37,10 @@ const Go = ({
37
37
  keepOpenOnSelect: I,
38
38
  highlightedItemKey: G,
39
39
  selectedItemKeys: h,
40
- showCheckbox: M
40
+ showCheckbox: M,
41
+ getItemKeywords: q
41
42
  }) => {
42
- const [q, x] = Y({
43
+ const [H, x] = Z({
43
44
  controlled: T,
44
45
  default: !1,
45
46
  name: "open"
@@ -48,7 +49,7 @@ const Go = ({
48
49
  x(r), v == null || v(r);
49
50
  },
50
51
  [x, v]
51
- ), d = oo(), L = ro(), R = a(B), H = Q(null), A = z.reduce((r, n) => (r.length === 0 && n.type !== "header" && r.push({
52
+ ), d = ro(), L = no(), R = N(B), J = X(null), A = z.reduce((r, n) => (r.length === 0 && n.type !== "header" && r.push({
52
53
  label: null,
53
54
  items: []
54
55
  }), n.type === "header" ? r.push({
@@ -56,7 +57,7 @@ const Go = ({
56
57
  items: []
57
58
  }) : (n.type === "item" || n.type === "divider") && r.length > 0 && r[r.length - 1].items.push(n), r), []), m = w(
58
59
  (r, n, p) => r.type === "item" ? /* @__PURE__ */ e(
59
- O,
60
+ K,
60
61
  {
61
62
  item: r,
62
63
  inCombobox: t,
@@ -69,11 +70,12 @@ const Go = ({
69
70
  r.onClick(i), I || l == null || l(!1);
70
71
  } : void 0,
71
72
  itemRender: E,
72
- showCheckbox: M
73
+ showCheckbox: M,
74
+ getItemKeywords: q
73
75
  },
74
76
  n + "-" + p
75
77
  ) : r.type === "divider" ? /* @__PURE__ */ e(
76
- K,
78
+ a,
77
79
  {
78
80
  inCombobox: t,
79
81
  className: o == null ? void 0 : o.separator
@@ -131,7 +133,7 @@ const Go = ({
131
133
  "group" + n
132
134
  ) : r.items.map((p, i) => m(p, n, i)),
133
135
  [d, o, m]
134
- ), J = w(
136
+ ), Q = w(
135
137
  () => t ? /* @__PURE__ */ b(
136
138
  g,
137
139
  {
@@ -139,13 +141,13 @@ const Go = ({
139
141
  disablePointerSelection: t,
140
142
  defaultValue: G ? String(G) : void 0,
141
143
  children: [
142
- /* @__PURE__ */ e($.Provider, { value: {}, children: /* @__PURE__ */ X(
144
+ /* @__PURE__ */ e(O.Provider, { value: {}, children: /* @__PURE__ */ Y(
143
145
  g.Input,
144
146
  {
145
147
  ...y,
146
148
  key: "search",
147
149
  render: /* @__PURE__ */ e(
148
- N,
150
+ s,
149
151
  {
150
152
  allowClear: !0,
151
153
  className: d("dropdown-menu-search"),
@@ -178,19 +180,19 @@ const Go = ({
178
180
  D,
179
181
  V
180
182
  ]
181
- ), f = t ? Z : P;
183
+ ), f = t ? $ : P;
182
184
  return /* @__PURE__ */ b(
183
185
  f.Root,
184
186
  {
185
187
  openOnHover: F,
186
- open: q,
188
+ open: H,
187
189
  onOpenChange: l,
188
190
  children: [
189
191
  /* @__PURE__ */ e(
190
192
  f.Trigger,
191
193
  {
192
194
  render: j,
193
- ref: H,
195
+ ref: J,
194
196
  className: u(
195
197
  d("dropdown-menu-trigger"),
196
198
  o == null ? void 0 : o.trigger,
@@ -205,7 +207,7 @@ const Go = ({
205
207
  align: R.align,
206
208
  sideOffset: 4,
207
209
  className: u(d("dropdown-menu-root"), o == null ? void 0 : o.root),
208
- collisionAvoidance: s,
210
+ collisionAvoidance: oo,
209
211
  children: /* @__PURE__ */ e(
210
212
  f.Popup,
211
213
  {
@@ -222,7 +224,7 @@ const Go = ({
222
224
  style: {
223
225
  "--size-width": k in S ? S[k] : void 0
224
226
  },
225
- children: J()
227
+ children: Q()
226
228
  }
227
229
  )
228
230
  }
@@ -232,6 +234,6 @@ const Go = ({
232
234
  );
233
235
  };
234
236
  export {
235
- Go as DropdownMenu
237
+ Mo as DropdownMenu
236
238
  };
237
239
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/dropdown-menu/component.tsx"],"sourcesContent":["\"use client\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { useControlled } from \"@base-ui-components/utils/useControlled\";\nimport { Popover } from \"@base-ui-components/react/popover\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n useAntdCssVarClassname,\n useCls,\n} from \"../utils\";\nimport { Command } from \"../cmdk\";\nimport { ScrollArea } from \"../scroll-area\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\n\n// Import component-specific styles\nimport { Input } from \"../input\";\nimport { PopupPanelSize } from \"../popup-panel/constants\";\nimport { DropdownMenuItem } from \"./item\";\n\nimport \"./style.css\";\nimport { DropdownMenuDivider } from \"./divider\";\n\nexport type DropdownMenuItemType =\n | {\n /**\n * The type of the menu item\n */\n type: \"item\";\n /**\n * The label of the menu item\n */\n label?: React.ReactNode;\n /**\n * Whether the menu item is disabled\n */\n disabled?: boolean;\n /**\n * The icon of the menu item\n */\n icon?: React.ReactNode;\n /**\n * The key of the menu item\n */\n key: React.Key;\n /**\n * The onClick event handler of the menu item\n */\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n /**\n * The onMouseEnter event handler of the menu item\n */\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n /**\n * The onMouseLeave event handler of the menu item\n */\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n /**\n * The onMouseOver event handler of the menu item\n */\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n /**\n * The onMouseOut event handler of the menu item\n */\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n /**\n * The className of the menu item\n */\n className?: string;\n /**\n * Whether the menu item is a danger item\n */\n danger?: boolean;\n /**\n * The ref of the menu item\n */\n ref?: React.Ref<HTMLElement>;\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"divider\";\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"header\";\n /**\n * The title of the menu item\n */\n title?: React.ReactNode;\n /**\n * The className of the menu item\n */\n className?: string;\n };\n\nexport interface DropdownMenuProps {\n /** Array of menu items to be displayed in the dropdown */\n items: DropdownMenuItemType[];\n /** Custom render function for the trigger element */\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n /**\n * Placement of the dropdown relative to the trigger element\n * @default \"bottomLeft\"\n */\n placement?: PopoverProps[\"placement\"];\n /**\n * Whether to open the dropdown on hover instead of click\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Controlled open state of the dropdown\n */\n open?: boolean;\n /**\n * Callback fired when the dropdown open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional CSS class for the dropdown component\n */\n className?: string;\n /**\n * Custom class names for different parts of the dropdown\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n group?: string;\n groupLabel?: string;\n item?: string;\n itemIcon?: string;\n itemText?: string;\n separator?: string;\n positioner?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to show search input\n * @default false\n */\n showSearch?: boolean;\n /**\n * Size of the dropdown menu\n * @default \"auto\"\n */\n size?: \"auto\" | keyof typeof PopupPanelSize;\n /**\n * Search placeholder\n */\n searchProps?: Omit<\n React.ComponentProps<typeof Command.Input>,\n \"size\" | \"ref\"\n >;\n /**\n * Whether to match the width of the popup with the trigger\n * @default false\n */\n popupMatchTriggerWidth?: boolean;\n\n /**\n * Content to display before the list\n */\n beforeList?: React.ReactNode;\n /**\n * Content to display after the list\n */\n afterList?: React.ReactNode;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n}\n\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n searchProps = {\n placeholder: \"Search...\",\n },\n popupMatchTriggerWidth,\n beforeList,\n afterList,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n showCheckbox,\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={showSearch}\n selected={selectedItemKeys?.includes(item.key)}\n onSelect={\n showSearch\n ? () => {\n const e = new MouseEvent(\"click\", {\n bubbles: true,\n cancelable: true,\n }) as unknown as React.MouseEvent<HTMLElement, MouseEvent>;\n item.onClick(e);\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }\n : undefined\n }\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={showSearch}\n className={classNames?.separator}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n showSearch,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupShowSearch = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Command.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n heading={\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n }\n >\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Command.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderMenuInner = useCallback(\n () =>\n showSearch ? (\n <Command\n className={cls(\"dropdown-menu-container\")}\n disablePointerSelection={showSearch}\n defaultValue={\n highlightedItemKey ? String(highlightedItemKey) : undefined\n }\n >\n <FormItemInputContext.Provider value={{}}>\n <Command.Input\n {...searchProps}\n key=\"search\"\n render={\n <Input\n allowClear\n className={cls(\"dropdown-menu-search\")}\n placeholder=\"Search\"\n />\n }\n />\n </FormItemInputContext.Provider>\n {beforeList}\n <ScrollArea fadeEdges>\n <Command.List className={cls(\"dropdown-menu-list\")}>\n <Command.Empty className={cls(\"dropdown-menu-empty\")}>\n No results found.\n </Command.Empty>\n {itemGroups.map(renderGroupShowSearch)}\n </Command.List>\n </ScrollArea>\n {afterList}\n </Command>\n ) : (\n <div className={cls(\"dropdown-menu-container\")}>\n {beforeList}\n <ScrollArea fadeEdges>{itemGroups.map(renderGroup)}</ScrollArea>\n {afterList}\n </div>\n ),\n [\n showSearch,\n cls,\n highlightedItemKey,\n searchProps,\n beforeList,\n itemGroups,\n renderGroupShowSearch,\n afterList,\n renderGroup,\n ]\n );\n\n const BaseComponent = showSearch ? Popover : Menu;\n\n return (\n <BaseComponent.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <BaseComponent.Trigger\n render={children}\n ref={buttonRef}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n antdCssVarClassname\n )}\n />\n <BaseComponent.Portal>\n <BaseComponent.Positioner\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n className={clsx(cls(\"dropdown-menu-root\"), classNames?.root)}\n collisionAvoidance={DROPDOWN_COLLISION_AVOIDANCE}\n >\n <BaseComponent.Popup\n className={clsx(\n cls(\n \"dropdown-menu\",\n showCheckbox && \"dropdown-menu-show-checkbox\",\n popupMatchTriggerWidth && \"dropdown-menu-match-trigger-width\"\n ),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n style={\n {\n \"--size-width\":\n size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {renderMenuInner()}\n </BaseComponent.Popup>\n </BaseComponent.Positioner>\n </BaseComponent.Portal>\n </BaseComponent.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","className","itemRender","classNames","size","showSearch","searchProps","popupMatchTriggerWidth","beforeList","afterList","keepOpenOnSelect","highlightedItemKey","selectedItemKeys","showCheckbox","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","renderMenuItem","item","i","j","jsx","DropdownMenuItem","e","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupShowSearch","Command","renderMenuInner","FormItemInputContext","createElement","Input","ScrollArea","BaseComponent","Popover","DROPDOWN_COLLISION_AVOIDANCE","PopupPanelSize"],"mappings":";;;;;;;;;;;;;;;;;;AA+MO,MAAMA,KAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,wBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AACF,MAAyB;AACvB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAc;AAAA,IACpC,YAAYjB;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP,GACKkB,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACrB,MAAAJ,EAAQI,CAAQ,GAChBnB,KAAA,QAAAA,EAAsBmB;AAAA,IACxB;AAAA,IACA,CAACJ,GAASf,CAAmB;AAAA,EAC/B,GACMoB,IAAMC,GAAO,GACbC,IAAsBC,GAAuB,GAC7CC,IAAkBC,EAAmB5B,CAAS,GAC9C6B,IAAYC,EAA0B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MACAiB;AAAA,MACApC;AAAA,MACA8B;AAAA,IAAA;AAAA,EAEJ,GAEMa,IAAgB/C,IAAagD,IAAUV;AAG3C,SAAA,gBAAAD;AAAA,IAACU,EAAc;AAAA,IAAd;AAAA,MACC,aAAAtD;AAAA,MACA,MAAAgB;AAAA,MACA,cAAAG;AAAA,MAEA,UAAA;AAAA,QAAA,gBAAAkB;AAAA,UAACiB,EAAc;AAAA,UAAd;AAAA,YACC,QAAQzD;AAAA,YACR,KAAK+B;AAAA,YACL,WAAWkB;AAAA,cACTxB,EAAI,uBAAuB;AAAA,cAC3BjB,KAAA,gBAAAA,EAAY;AAAA,cACZmB;AAAA,YAAA;AAAA,UACF;AAAA,QACF;AAAA,QACA,gBAAAa,EAACiB,EAAc,QAAd,EACC,UAAA,gBAAAjB;AAAA,UAACiB,EAAc;AAAA,UAAd;AAAA,YACC,MAAM5B,EAAgB;AAAA,YACtB,OAAOA,EAAgB;AAAA,YACvB,YAAY;AAAA,YACZ,WAAWoB,EAAKxB,EAAI,oBAAoB,GAAGjB,KAAA,gBAAAA,EAAY,IAAI;AAAA,YAC3D,oBAAoBmD;AAAA,YAEpB,UAAA,gBAAAnB;AAAA,cAACiB,EAAc;AAAA,cAAd;AAAA,gBACC,WAAWR;AAAA,kBACTxB;AAAA,oBACE;AAAA,oBACAP,KAAgB;AAAA,oBAChBN,KAA0B;AAAA,kBAC5B;AAAA,kBACAN;AAAA,kBACAE,KAAA,gBAAAA,EAAY;AAAA,kBACZmB;AAAA,gBACF;AAAA,gBACA,OACE;AAAA,kBACE,gBACElB,KAAQmD,IAAiBA,EAAenD,CAAI,IAAI;AAAA,gBACpD;AAAA,gBAGD,UAAgB2C,EAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACnB;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/dropdown-menu/component.tsx"],"sourcesContent":["\"use client\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { useControlled } from \"@base-ui-components/utils/useControlled\";\nimport { Popover } from \"@base-ui-components/react/popover\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef } from \"react\";\nimport {\n clsx,\n DROPDOWN_COLLISION_AVOIDANCE,\n parseAntdPlacement,\n useAntdCssVarClassname,\n useCls,\n} from \"../utils\";\nimport { Command } from \"../cmdk\";\nimport { ScrollArea } from \"../scroll-area\";\nimport { FormItemInputContext } from \"antd/es/form/context\";\n\n// Import component-specific styles\nimport { Input } from \"../input\";\nimport { PopupPanelSize } from \"../popup-panel/constants\";\nimport { DropdownMenuItem } from \"./item\";\n\nimport \"./style.css\";\nimport { DropdownMenuDivider } from \"./divider\";\n\nexport type DropdownMenuItemType =\n | {\n /**\n * The type of the menu item\n */\n type: \"item\";\n /**\n * The label of the menu item\n */\n label?: React.ReactNode;\n /**\n * Whether the menu item is disabled\n */\n disabled?: boolean;\n /**\n * The icon of the menu item\n */\n icon?: React.ReactNode;\n /**\n * The key of the menu item\n */\n key: React.Key;\n /**\n * The onClick event handler of the menu item\n */\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n /**\n * The onMouseEnter event handler of the menu item\n */\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n /**\n * The onMouseLeave event handler of the menu item\n */\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n /**\n * The onMouseOver event handler of the menu item\n */\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n /**\n * The onMouseOut event handler of the menu item\n */\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n /**\n * The className of the menu item\n */\n className?: string;\n /**\n * Whether the menu item is a danger item\n */\n danger?: boolean;\n /**\n * The ref of the menu item\n */\n ref?: React.Ref<HTMLElement>;\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"divider\";\n }\n | {\n /**\n * The type of the menu item\n */\n type: \"header\";\n /**\n * The title of the menu item\n */\n title?: React.ReactNode;\n /**\n * The className of the menu item\n */\n className?: string;\n };\n\nexport interface DropdownMenuProps {\n /** Array of menu items to be displayed in the dropdown */\n items: DropdownMenuItemType[];\n /** Custom render function for the trigger element */\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n /**\n * Placement of the dropdown relative to the trigger element\n * @default \"bottomLeft\"\n */\n placement?: PopoverProps[\"placement\"];\n /**\n * Whether to open the dropdown on hover instead of click\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Controlled open state of the dropdown\n */\n open?: boolean;\n /**\n * Callback fired when the dropdown open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional CSS class for the dropdown component\n */\n className?: string;\n /**\n * Custom class names for different parts of the dropdown\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n group?: string;\n groupLabel?: string;\n item?: string;\n itemIcon?: string;\n itemText?: string;\n separator?: string;\n positioner?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to show search input\n * @default false\n */\n showSearch?: boolean;\n /**\n * Size of the dropdown menu\n * @default \"auto\"\n */\n size?: \"auto\" | keyof typeof PopupPanelSize;\n /**\n * Search placeholder\n */\n searchProps?: Omit<\n React.ComponentProps<typeof Command.Input>,\n \"size\" | \"ref\"\n >;\n /**\n * Whether to match the width of the popup with the trigger\n * @default false\n */\n popupMatchTriggerWidth?: boolean;\n\n /**\n * Content to display before the list\n */\n beforeList?: React.ReactNode;\n /**\n * Content to display after the list\n */\n afterList?: React.ReactNode;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n /**\n * 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\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n className,\n itemRender,\n classNames,\n size = \"auto\",\n showSearch,\n searchProps = {\n placeholder: \"Search...\",\n },\n popupMatchTriggerWidth,\n beforeList,\n afterList,\n keepOpenOnSelect,\n highlightedItemKey,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const baseUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={showSearch}\n selected={selectedItemKeys?.includes(item.key)}\n onSelect={\n showSearch\n ? () => {\n const e = new MouseEvent(\"click\", {\n bubbles: true,\n cancelable: true,\n }) as unknown as React.MouseEvent<HTMLElement, MouseEvent>;\n item.onClick(e);\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }\n : undefined\n }\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={showSearch}\n className={classNames?.separator}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n showSearch,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupShowSearch = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Command.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n heading={\n <Menu.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n }\n >\n {group.items.map((item, j) => renderMenuItem(item, index, j))}\n </Command.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderMenuInner = useCallback(\n () =>\n showSearch ? (\n <Command\n className={cls(\"dropdown-menu-container\")}\n disablePointerSelection={showSearch}\n defaultValue={\n highlightedItemKey ? String(highlightedItemKey) : undefined\n }\n >\n <FormItemInputContext.Provider value={{}}>\n <Command.Input\n {...searchProps}\n key=\"search\"\n render={\n <Input\n allowClear\n className={cls(\"dropdown-menu-search\")}\n placeholder=\"Search\"\n />\n }\n />\n </FormItemInputContext.Provider>\n {beforeList}\n <ScrollArea fadeEdges>\n <Command.List className={cls(\"dropdown-menu-list\")}>\n <Command.Empty className={cls(\"dropdown-menu-empty\")}>\n No results found.\n </Command.Empty>\n {itemGroups.map(renderGroupShowSearch)}\n </Command.List>\n </ScrollArea>\n {afterList}\n </Command>\n ) : (\n <div className={cls(\"dropdown-menu-container\")}>\n {beforeList}\n <ScrollArea fadeEdges>{itemGroups.map(renderGroup)}</ScrollArea>\n {afterList}\n </div>\n ),\n [\n showSearch,\n cls,\n highlightedItemKey,\n searchProps,\n beforeList,\n itemGroups,\n renderGroupShowSearch,\n afterList,\n renderGroup,\n ]\n );\n\n const BaseComponent = showSearch ? Popover : Menu;\n\n return (\n <BaseComponent.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <BaseComponent.Trigger\n render={children}\n ref={buttonRef}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n antdCssVarClassname\n )}\n />\n <BaseComponent.Portal>\n <BaseComponent.Positioner\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n className={clsx(cls(\"dropdown-menu-root\"), classNames?.root)}\n collisionAvoidance={DROPDOWN_COLLISION_AVOIDANCE}\n >\n <BaseComponent.Popup\n className={clsx(\n cls(\n \"dropdown-menu\",\n showCheckbox && \"dropdown-menu-show-checkbox\",\n popupMatchTriggerWidth && \"dropdown-menu-match-trigger-width\"\n ),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n style={\n {\n \"--size-width\":\n size in PopupPanelSize ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n {renderMenuInner()}\n </BaseComponent.Popup>\n </BaseComponent.Positioner>\n </BaseComponent.Portal>\n </BaseComponent.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","className","itemRender","classNames","size","showSearch","searchProps","popupMatchTriggerWidth","beforeList","afterList","keepOpenOnSelect","highlightedItemKey","selectedItemKeys","showCheckbox","getItemKeywords","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","baseUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","renderMenuItem","item","i","j","jsx","DropdownMenuItem","e","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupShowSearch","Command","renderMenuInner","FormItemInputContext","createElement","Input","ScrollArea","BaseComponent","Popover","DROPDOWN_COLLISION_AVOIDANCE","PopupPanelSize"],"mappings":";;;;;;;;;;;;;;;;;;AAoNO,MAAMA,KAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,wBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC;AACF,MAAyB;AACvB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAc;AAAA,IACpC,YAAYlB;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP,GACKmB,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACrB,MAAAJ,EAAQI,CAAQ,GAChBpB,KAAA,QAAAA,EAAsBoB;AAAA,IACxB;AAAA,IACA,CAACJ,GAAShB,CAAmB;AAAA,EAC/B,GACMqB,IAAMC,GAAO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,IAAA;AAAA,EACF;AAEJ;"}
@@ -1,36 +1,38 @@
1
1
  "use client";
2
- import { jsxs as g, Fragment as k, jsx as r } from "react/jsx-runtime";
3
- import { useMemo as x } from "react";
4
- import { Command as E } from "../cmdk/index.js";
5
- import { Menu as L } from "@base-ui-components/react/menu";
2
+ import { jsxs as I, Fragment as x, jsx as r } from "react/jsx-runtime";
3
+ import { useMemo as h } from "react";
4
+ import { Command as j } from "../cmdk/index.js";
5
+ import { Menu as E } from "@base-ui-components/react/menu";
6
6
  import './item.css';/* empty css */
7
- import { Checkbox as h } from "antd";
8
- import { useCls as b } from "../utils/antdUtils.js";
9
- import { clsx as p } from "../utils/cn.js";
10
- const C = ({
7
+ import { Checkbox as w } from "antd";
8
+ import { reactNodeToString as L } from "../utils/reactToString.js";
9
+ import { useCls as D } from "../utils/antdUtils.js";
10
+ import { clsx as t } from "../utils/cn.js";
11
+ const J = ({
11
12
  item: o,
12
13
  inCombobox: u = !1,
13
- selected: i = !1,
14
- itemRender: t,
15
- itemProps: w = {},
14
+ selected: f = !1,
15
+ itemRender: p,
16
+ itemProps: y = {},
16
17
  classNames: n,
17
- onSelect: I,
18
- showCheckbox: e,
19
- indeterminate: M,
20
- renderAsNativeElement: O
18
+ onSelect: k,
19
+ showCheckbox: M,
20
+ indeterminate: e,
21
+ renderAsNativeElement: O,
22
+ getItemKeywords: g
21
23
  }) => {
22
- const d = b(), y = x(
23
- () => u ? E.Item : L.Item,
24
+ const d = D(), T = h(
25
+ () => u ? j.Item : E.Item,
24
26
  [u]
25
- ), f = x(() => ({
26
- className: p(
27
+ ), i = h(() => ({
28
+ className: t(
27
29
  d("dropdown-menu-item", u && "dropdown-menu-item-combobox"),
28
30
  n == null ? void 0 : n.item,
29
31
  o.className
30
32
  ),
31
33
  disabled: o.disabled,
32
34
  "data-danger": o.danger,
33
- "data-actual-selected": i,
35
+ "data-actual-selected": f,
34
36
  ref: o.ref,
35
37
  onClick: o.onClick,
36
38
  onMouseEnter: o.onMouseEnter,
@@ -38,20 +40,20 @@ const C = ({
38
40
  onMouseOver: o.onMouseOver,
39
41
  onMouseOut: o.onMouseOut,
40
42
  "data-value": typeof o.label == "string" ? o.label : String(o.key),
41
- render: t ? (j) => t(o, j) : void 0,
42
- children: u ? /* @__PURE__ */ g(k, { children: [
43
- e && /* @__PURE__ */ r(
44
- h,
43
+ render: p ? (b) => p(o, b) : void 0,
44
+ children: u ? /* @__PURE__ */ I(x, { children: [
45
+ M && /* @__PURE__ */ r(
46
+ w,
45
47
  {
46
- checked: i,
48
+ checked: f,
47
49
  tabIndex: -1,
48
- indeterminate: M
50
+ indeterminate: e
49
51
  }
50
52
  ),
51
53
  o.icon && /* @__PURE__ */ r(
52
54
  "span",
53
55
  {
54
- className: p(
56
+ className: t(
55
57
  d("dropdown-menu-item-icon"),
56
58
  n == null ? void 0 : n.itemIcon
57
59
  ),
@@ -61,26 +63,26 @@ const C = ({
61
63
  /* @__PURE__ */ r(
62
64
  "span",
63
65
  {
64
- className: p(
66
+ className: t(
65
67
  d("dropdown-menu-item-text"),
66
68
  n == null ? void 0 : n.itemText
67
69
  ),
68
70
  children: o.label
69
71
  }
70
72
  )
71
- ] }) : /* @__PURE__ */ g(k, { children: [
72
- e && /* @__PURE__ */ r(
73
- h,
73
+ ] }) : /* @__PURE__ */ I(x, { children: [
74
+ M && /* @__PURE__ */ r(
75
+ w,
74
76
  {
75
- checked: i,
77
+ checked: f,
76
78
  tabIndex: -1,
77
- indeterminate: M
79
+ indeterminate: e
78
80
  }
79
81
  ),
80
82
  o.icon && /* @__PURE__ */ r(
81
83
  "span",
82
84
  {
83
- className: p(
85
+ className: t(
84
86
  d("dropdown-menu-item-icon"),
85
87
  n == null ? void 0 : n.itemIcon
86
88
  ),
@@ -90,7 +92,7 @@ const C = ({
90
92
  /* @__PURE__ */ r(
91
93
  "span",
92
94
  {
93
- className: p(
95
+ className: t(
94
96
  d("dropdown-menu-item-text"),
95
97
  n == null ? void 0 : n.itemText
96
98
  ),
@@ -104,28 +106,29 @@ const C = ({
104
106
  n == null ? void 0 : n.itemText,
105
107
  d,
106
108
  u,
107
- M,
109
+ e,
108
110
  o,
109
- t,
110
- i,
111
- e
111
+ p,
112
+ f,
113
+ M
112
114
  ]);
113
- if (t)
114
- return t(o, {
115
- ...f,
116
- ...w
115
+ if (p)
116
+ return p(o, {
117
+ ...i,
118
+ ...y
117
119
  });
118
- const { render: v, ...T } = f;
119
- return O ? v ? v(f) : /* @__PURE__ */ r("div", { onClick: I, ...T }) : /* @__PURE__ */ r(
120
- y,
120
+ const { render: v, ...S } = i;
121
+ return O ? v ? v(i) : /* @__PURE__ */ r("div", { onClick: k, ...S }) : /* @__PURE__ */ r(
122
+ T,
121
123
  {
122
124
  value: String(o.key),
123
- onSelect: I,
124
- ...f
125
+ keywords: g ? g(o) : [String(o.key), L(o.label)],
126
+ onSelect: k,
127
+ ...i
125
128
  }
126
129
  );
127
130
  };
128
131
  export {
129
- C as DropdownMenuItem
132
+ J as DropdownMenuItem
130
133
  };
131
134
  //# sourceMappingURL=item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useMemo } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport type { DropdownMenuItemType } from \"./component\";\nimport { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\n\nimport \"./item.css\";\nimport { Checkbox } from \"antd\";\n\nexport interface DropdownMenuItemProps {\n /** The menu item data */\n item: DropdownMenuItemType & { type: \"item\" };\n /** Custom render function for the item */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /** Additional props to pass to the item */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /** Class names from parent DropdownMenu */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n };\n onSelect?: () => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is in a menu\n */\n renderAsNativeElement?: 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\nexport const DropdownMenuItem: React.FC<DropdownMenuItemProps> = ({\n item,\n inCombobox = false,\n selected = false,\n itemRender,\n itemProps = {},\n classNames,\n onSelect,\n showCheckbox,\n indeterminate,\n renderAsNativeElement,\n}) => {\n const cls = useCls();\n\n const MenuItem = useMemo(\n () => (inCombobox ? Command.Item : Menu.Item),\n [inCombobox]\n );\n\n const props = useMemo(() => {\n return {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n disabled: item.disabled,\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: item.onClick,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n render: itemRender\n ? (itemProps: React.HTMLAttributes<HTMLElement>) =>\n itemRender(item, itemProps)\n : undefined,\n children: inCombobox ? (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ) : (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ),\n };\n }, [\n classNames?.item,\n classNames?.itemIcon,\n classNames?.itemText,\n cls,\n inCombobox,\n indeterminate,\n item,\n itemRender,\n selected,\n showCheckbox,\n ]);\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n ...props,\n ...itemProps,\n });\n }\n const { render, ...restProps } = props;\n // Default rendering\n return renderAsNativeElement ? (\n render ? (\n render(props)\n ) : (\n <div onClick={onSelect} {...restProps} />\n )\n ) : (\n <MenuItem\n value={String(item.key)}\n onSelect={onSelect}\n {...props}\n ></MenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemProps","classNames","onSelect","showCheckbox","indeterminate","renderAsNativeElement","cls","useCls","MenuItem","useMemo","Command","Menu","props","clsx","jsxs","Fragment","jsx","Checkbox","render","restProps"],"mappings":";;;;;;;;;AAmDO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,WAAAC,IAAY,CAAC;AAAA,EACb,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,uBAAAC;AACF,MAAM;AACJ,QAAMC,IAAMC,EAAO,GAEbC,IAAWC;AAAA,IACf,MAAOZ,IAAaa,EAAQ,OAAOC,EAAK;AAAA,IACxC,CAACd,CAAU;AAAA,EACb,GAEMe,IAAQH,EAAQ,OACb;AAAA,IACL,WAAWI;AAAA,MACTP,EAAI,sBAAsBT,KAAc,6BAA6B;AAAA,MACrEI,KAAA,gBAAAA,EAAY;AAAA,MACZL,EAAK;AAAA,IACP;AAAA,IACA,UAAUA,EAAK;AAAA,IACf,eAAeA,EAAK;AAAA,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L,EAAA;AAAA,QAAA;AAAA,MACR;AAAA,MAEF,gBAAAoB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWH;AAAA,YACTP,EAAI,yBAAyB;AAAA,YAC7BL,KAAA,gBAAAA,EAAY;AAAA,UACd;AAAA,UAEC,UAAKL,EAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACR,EACF,CAAA;AAAA,EAEJ,IACC;AAAA,IACDK,KAAA,gBAAAA,EAAY;AAAA,IACZA,KAAA,gBAAAA,EAAY;AAAA,IACZA,KAAA,gBAAAA,EAAY;AAAA,IACZK;AAAA,IACAT;AAAA,IACAO;AAAA,IACAR;AAAA,IACAG;AAAA,IACAD;AAAA,IACAK;AAAA,EAAA,CACD;AAED,MAAIJ;AACF,WAAOA,EAAWH,GAAM;AAAA,MACtB,GAAGgB;AAAA,MACH,GAAGZ;AAAA,IAAA,CACJ;AAEH,QAAM,EAAE,QAAAkB,GAAQ,GAAGC,EAAA,IAAcP;AAE1B,SAAAP,IACLa,IACEA,EAAON,CAAK,IAEX,gBAAAI,EAAA,OAAA,EAAI,SAASd,GAAW,GAAGiB,EAAA,CAAW,IAGzC,gBAAAH;AAAA,IAACR;AAAA,IAAA;AAAA,MACC,OAAO,OAAOZ,EAAK,GAAG;AAAA,MACtB,UAAAM;AAAA,MACC,GAAGU;AAAA,IAAA;AAAA,EACL;AAEL;"}
1
+ {"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useMemo } from \"react\";\nimport { clsx, reactNodeToString, useCls } from \"../utils\";\nimport type { DropdownMenuItemType } from \"./component\";\nimport { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\n\nimport \"./item.css\";\nimport { Checkbox } from \"antd\";\n\nexport interface DropdownMenuItemProps {\n /** The menu item data */\n item: DropdownMenuItemType & { type: \"item\" };\n /** Custom render function for the item */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /** Additional props to pass to the item */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /** Class names from parent DropdownMenu */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n };\n onSelect?: () => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is in a menu\n */\n renderAsNativeElement?: 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 itemProps = {},\n classNames,\n onSelect,\n showCheckbox,\n indeterminate,\n renderAsNativeElement,\n getItemKeywords,\n}) => {\n const cls = useCls();\n\n const MenuItem = useMemo(\n () => (inCombobox ? Command.Item : Menu.Item),\n [inCombobox]\n );\n\n const props = useMemo(() => {\n return {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n disabled: item.disabled,\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: item.onClick,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n render: itemRender\n ? (itemProps: React.HTMLAttributes<HTMLElement>) =>\n itemRender(item, itemProps)\n : undefined,\n children: inCombobox ? (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ) : (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ),\n };\n }, [\n classNames?.item,\n classNames?.itemIcon,\n classNames?.itemText,\n cls,\n inCombobox,\n indeterminate,\n item,\n itemRender,\n selected,\n showCheckbox,\n ]);\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n ...props,\n ...itemProps,\n });\n }\n const { render, ...restProps } = props;\n // Default rendering\n return renderAsNativeElement ? (\n render ? (\n render(props)\n ) : (\n <div onClick={onSelect} {...restProps} />\n )\n ) : (\n <MenuItem\n value={String(item.key)}\n keywords={getItemKeywords ? getItemKeywords(item) : [String(item.key), reactNodeToString(item.label)]}\n onSelect={onSelect}\n {...props}\n ></MenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemProps","classNames","onSelect","showCheckbox","indeterminate","renderAsNativeElement","getItemKeywords","cls","useCls","MenuItem","useMemo","Command","Menu","props","clsx","jsxs","Fragment","jsx","Checkbox","render","restProps","reactNodeToString"],"mappings":";;;;;;;;;;AAwDO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,WAAAC,IAAY,CAAC;AAAA,EACb,YAAAC;AAAA,EACA,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V,CAAI,IAAI,CAAC,OAAOA,EAAK,GAAG,GAAGyB,EAAkBzB,EAAK,KAAK,CAAC;AAAA,MACpG,UAAAM;AAAA,MACC,GAAGW;AAAA,IAAA;AAAA,EACL;AAEL;"}
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as n } from "react/jsx-runtime";
3
- import T, { useState as R, useCallback as U, useEffect as W, isValidElement as X } from "react";
4
- import { useResizable as Y } from "react-use-resizable";
5
- import Z from "merge-refs";
6
- import { mergeProps as K } from "@base-ui-components/react";
3
+ import U, { useState as R, useCallback as X, useEffect as W, isValidElement as Y } from "react";
4
+ import { useResizable as Z } from "react-use-resizable";
5
+ import K from "merge-refs";
6
+ import { mergeProps as A } from "@base-ui-components/react";
7
7
  import './style.css';/* empty css */
8
8
  import { getReactElementProp as x } from "../utils/reactElement.js";
9
- import { useCls as A } from "../utils/antdUtils.js";
10
- import { clsx as h, cn as s } from "../utils/cn.js";
11
- import { WithRenderProp as a } from "../utils/WithRenderProp.js";
9
+ import { useCls as s } from "../utils/antdUtils.js";
10
+ import { clsx as h, cn as a } from "../utils/cn.js";
11
+ import { WithRenderProp as N } from "../utils/WithRenderProp.js";
12
12
  const ue = ({
13
13
  children: p,
14
14
  resizable: c = !1,
@@ -24,11 +24,11 @@ const ue = ({
24
24
  minHeight: q,
25
25
  onResize: F,
26
26
  maintainAspectRatio: r = !1,
27
- ...N
27
+ ...G
28
28
  }) => {
29
- const l = A(), [u, G] = R(null), [b, v] = R(), [H, y] = R(), [P, D] = R(!1), J = U(
29
+ const l = s(), [u, J] = R(null), [b, v] = R(), [H, y] = R(), [P, D] = R(!1), L = X(
30
30
  (e) => {
31
- if (G(e), e && !b && !H) {
31
+ if (J(e), e && !b && !H) {
32
32
  const i = e.getBoundingClientRect();
33
33
  i.width > 0 && i.height > 0 && r && (v(i.width), y(i.height));
34
34
  }
@@ -42,7 +42,7 @@ const ue = ({
42
42
  e.width > 0 && e.height > 0 && (r ? (v(e.width), y(e.height)) : (v(void 0), y(void 0)));
43
43
  }
44
44
  }, [B, u, r]);
45
- const w = Y({
45
+ const w = Z({
46
46
  initialWidth: r ? b : void 0,
47
47
  initialHeight: r ? H : void 0,
48
48
  maxWidth: _,
@@ -58,11 +58,11 @@ const ue = ({
58
58
  }
59
59
  },
60
60
  onDragEnd: () => D(!1)
61
- }), S = X(p);
61
+ }), S = Y(p);
62
62
  W(() => {
63
63
  P ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
64
64
  }, [P]);
65
- const { ref: L, ...M } = w.getRootProps(), d = w.getHandleProps, g = w.rootRef, C = (e, i) => {
65
+ const { ref: M, ...O } = w.getRootProps(), d = w.getHandleProps, g = w.rootRef, C = (e, i) => {
66
66
  if (!e.current || !V) return;
67
67
  const { widthDiff: E } = i;
68
68
  e.current.style.left = `${parseInt(e.current.style.left || "0") - E}px`;
@@ -70,7 +70,7 @@ const ue = ({
70
70
  if (!e.current || !V) return;
71
71
  const { heightDiff: E } = i;
72
72
  e.current.style.top = `${parseInt(e.current.style.top || "0") - E}px`;
73
- }, O = c ? [
73
+ }, Q = c ? [
74
74
  o.top && !r && /* @__PURE__ */ n(
75
75
  "div",
76
76
  {
@@ -198,16 +198,16 @@ const ue = ({
198
198
  style: x(f, "style"),
199
199
  children: x(f, "children"),
200
200
  ref: f.ref
201
- }, Q = {
202
- className: s(
201
+ }, T = {
202
+ className: a(
203
203
  c && l("resizable"),
204
204
  t == null ? void 0 : t.root,
205
205
  z.className,
206
206
  m
207
207
  ),
208
- ref: Z(
209
- c ? L : void 0,
210
- J,
208
+ ref: K(
209
+ c ? M : void 0,
210
+ L,
211
211
  // Always need this for dimension measurement
212
212
  f == null ? void 0 : f.ref
213
213
  ),
@@ -216,20 +216,21 @@ const ue = ({
216
216
  ...c ? { "data-resizable": !0 } : {},
217
217
  children: S ? [
218
218
  ...Array.isArray(z.children) ? z.children : [z.children],
219
- ...O.filter(Boolean)
219
+ ...Q.filter(Boolean)
220
220
  ] : p
221
221
  };
222
222
  return /* @__PURE__ */ n(
223
- a,
223
+ N,
224
224
  {
225
225
  render: (e) => {
226
- const i = K(
226
+ const i = A(
227
227
  e,
228
- Q,
229
- c ? M : {}
228
+ T,
229
+ c ? O : {}
230
230
  );
231
- return S ? T.cloneElement(f, i) : /* @__PURE__ */ n("div", { ...i, children: p });
232
- }
231
+ return S ? U.cloneElement(f, i) : /* @__PURE__ */ n("div", { ...i, children: p });
232
+ },
233
+ ...G
233
234
  }
234
235
  );
235
236
  };
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useState, isValidElement } from \"react\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface ResizableProps extends WithRenderPropProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n /**\n * Whether to use absolute positioning for left handle resizing\n * Set to true when used in absolutely positioned containers like PopupPanel\n * @default false\n */\n absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = ({\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n absolutePositioning = false,\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio = false,\n ...rest\n}: ResizableProps) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n // For aspect ratio maintenance, we need initial dimensions immediately\n // Otherwise, preserve natural width/height behavior\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // Need dimensions for aspect ratio calculation\n setWidth(rect.width);\n setHeight(rect.height);\n }\n // For non-aspect-ratio cases, don't set dimensions to preserve natural behavior\n }\n }\n },\n [width, height, maintainAspectRatio]\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // For aspect ratio maintenance, re-measure and set dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n } else {\n // Reset state to allow natural dimensions again\n setWidth(undefined);\n setHeight(undefined);\n }\n\n // Don't apply any explicit dimensions - let them remain natural\n // panelRef.style.width = `${rect.width}px`;\n // panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef, maintainAspectRatio]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n // For aspect ratio maintenance, we need initial dimensions\n // Otherwise, preserve natural width/height behavior until user starts resizing\n const resizableHook = useResizable({\n initialWidth: maintainAspectRatio ? width : undefined,\n initialHeight: maintainAspectRatio ? height : undefined,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio,\n onDragStart: () => {\n setResizing(true);\n // Capture natural dimensions when user starts resizing\n if (panelRef) {\n const rect = panelRef.getBoundingClientRect();\n if (rect.width > 0 && !width) {\n setWidth(rect.width);\n }\n if (rect.height > 0 && !height) {\n setHeight(rect.height);\n }\n }\n },\n onDragEnd: () => setResizing(false),\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n const rootRef = resizableHook.rootRef;\n\n // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n // Handle reverse handle change for vertical resizing (only for absolute positioning)\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n const resizeHandles = resizable\n ? [\n handles.top && !maintainAspectRatio && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && !maintainAspectRatio && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && !maintainAspectRatio && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n handles.right && !maintainAspectRatio && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n // For aspect ratio maintenance, add corner handles that can resize both dimensions\n handles.right && handles.bottom && (\n <div\n key=\"bottom-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-right-corner\"\n {...getHandleProps({\n // No locks - allow both horizontal and vertical resizing\n })}\n />\n ),\n maintainAspectRatio && handles.left && handles.bottom && (\n <div\n key=\"bottom-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n maintainAspectRatio && handles.right && handles.top && (\n <div\n key=\"top-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.left && handles.top && (\n <div\n key=\"top-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) => {\n onReverseHandleChangeHorizontal(rootRef, values);\n onReverseHandleChangeVertical(rootRef, values);\n },\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n ...(resizable ? { \"data-resizable\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {}\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n />\n );\n};\n"],"names":["Resizable","children","resizable","handles","absolutePositioning","classNames","containerClassName","containerStyle","resetKey","maxWidth","maxHeight","minWidth","minHeight","onResize","maintainAspectRatio","rest","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","rootRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","onReverseHandleChangeVertical","heightDiff","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AAkFO,MAAMA,KAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,EAAE,QAAQ,IAAM,OAAO,IAAM,MAAM,IAAM,KAAK,GAAK;AAAA,EAC7D,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,WAAWC;AAAA,EACX,OAAOC;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,GAAGC;AACL,MAAsB;AAQpB,QAAMC,IAAMC,EAAO,GACb,CAACC,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAAIJ,EAAiB,GACvC,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK,GAExCO,IAAcC;AAAA,IAClB,CAACC,MAAyB;AAMxB,UALAV,EAAYU,CAAI,GAKZA,KAAQ,CAACR,KAAS,CAACE,GAAQ;AACvB,cAAAO,IAAOD,EAAK,sBAAsB;AACxC,QAAIC,EAAK,QAAQ,KAAKA,EAAK,SAAS,KAC9BhB,MAEFQ,EAASQ,EAAK,KAAK,GACnBN,EAAUM,EAAK,MAAM;AAAA,MAGzB;AAAA,IAEJ;AAAA,IACA,CAACT,GAAOE,GAAQT,CAAmB;AAAA,EACrC;AAGA,EAAAiB,EAAU,MAAM;AACV,QAAAvB,MAAa,UAAaU,GAAU;AAEtC,MAAAA,EA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AAAA,IAAA,IAEjC7C;AAAA,EACN;AAGE,SAAA,gBAAA8C;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,QAAQ,CAACC,MAAU;AAEjB,cAAMC,IAAcC;AAAA,UAClBF;AAAA,UACAJ;AAAA,UACAlD,IAAYmC,IAAsB,CAAA;AAAA,QACpC;AACA,eAAIH,IACKyB,EAAM,aAAaV,GAAcQ,CAAW,IAE3C,gBAAAV,EAAA,OAAA,EAAK,GAAGU,GAAc,UAAAxD,EAAS,CAAA;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useState, isValidElement } from \"react\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface ResizableProps extends WithRenderPropProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n /**\n * Whether to use absolute positioning for left handle resizing\n * Set to true when used in absolutely positioned containers like PopupPanel\n * @default false\n */\n absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = ({\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n absolutePositioning = false,\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio = false,\n ...rest\n}: ResizableProps) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n // For aspect ratio maintenance, we need initial dimensions immediately\n // Otherwise, preserve natural width/height behavior\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // Need dimensions for aspect ratio calculation\n setWidth(rect.width);\n setHeight(rect.height);\n }\n // For non-aspect-ratio cases, don't set dimensions to preserve natural behavior\n }\n }\n },\n [width, height, maintainAspectRatio]\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // For aspect ratio maintenance, re-measure and set dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n } else {\n // Reset state to allow natural dimensions again\n setWidth(undefined);\n setHeight(undefined);\n }\n\n // Don't apply any explicit dimensions - let them remain natural\n // panelRef.style.width = `${rect.width}px`;\n // panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef, maintainAspectRatio]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n // For aspect ratio maintenance, we need initial dimensions\n // Otherwise, preserve natural width/height behavior until user starts resizing\n const resizableHook = useResizable({\n initialWidth: maintainAspectRatio ? width : undefined,\n initialHeight: maintainAspectRatio ? height : undefined,\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n onResize,\n maintainAspectRatio,\n onDragStart: () => {\n setResizing(true);\n // Capture natural dimensions when user starts resizing\n if (panelRef) {\n const rect = panelRef.getBoundingClientRect();\n if (rect.width > 0 && !width) {\n setWidth(rect.width);\n }\n if (rect.height > 0 && !height) {\n setHeight(rect.height);\n }\n }\n },\n onDragEnd: () => setResizing(false),\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n const rootRef = resizableHook.rootRef;\n\n // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n // Handle reverse handle change for vertical resizing (only for absolute positioning)\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n const resizeHandles = resizable\n ? [\n handles.top && !maintainAspectRatio && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && !maintainAspectRatio && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && !maintainAspectRatio && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n handles.right && !maintainAspectRatio && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n // For aspect ratio maintenance, add corner handles that can resize both dimensions\n handles.right && handles.bottom && (\n <div\n key=\"bottom-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-right-corner\"\n {...getHandleProps({\n // No locks - allow both horizontal and vertical resizing\n })}\n />\n ),\n maintainAspectRatio && handles.left && handles.bottom && (\n <div\n key=\"bottom-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n maintainAspectRatio && handles.right && handles.top && (\n <div\n key=\"top-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.left && handles.top && (\n <div\n key=\"top-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) => {\n onReverseHandleChangeHorizontal(rootRef, values);\n onReverseHandleChangeVertical(rootRef, values);\n },\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n ...(resizable ? { \"data-resizable\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {}\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n {...rest}\n />\n );\n};\n"],"names":["Resizable","children","resizable","handles","absolutePositioning","classNames","containerClassName","containerStyle","resetKey","maxWidth","maxHeight","minWidth","minHeight","onResize","maintainAspectRatio","rest","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","rootRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","onReverseHandleChangeVertical","heightDiff","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AAkFO,MAAMA,KAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,EAAE,QAAQ,IAAM,OAAO,IAAM,MAAM,IAAM,KAAK,GAAK;AAAA,EAC7D,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,WAAWC;AAAA,EACX,OAAOC;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,GAAGC;AACL,MAAsB;AAQpB,QAAMC,IAAMC,EAAO,GACb,CAACC,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAAIJ,EAAiB,GACvC,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK,GAExCO,IAAcC;AAAA,IAClB,CAACC,MAAyB;AAMxB,UALAV,EAAYU,CAAI,GAKZA,KAAQ,CAACR,KAAS,CAACE,GAAQ;AACvB,cAAAO,IAAOD,EAAK,sBAAsB;AACxC,QAAIC,EAAK,QAAQ,KAAKA,EAAK,SAAS,KAC9BhB,MAEFQ,EAASQ,EAAK,KAAK,GACnBN,EAAUM,EAAK,MAAM;AAAA,MAGzB;AAAA,IAEJ;AAAA,IACA,CAACT,GAAOE,GAAQT,CAAmB;AAAA,EACrC;AAGA,EAAAiB,EAAU,M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EAAkB,QAAQ;AAAA,MAC/B,GAAGJ,EAAc,OAAO,OAAO;AAAA,IAAA,IAEjC7C;AAAA,EACN;AAGE,SAAA,gBAAA8C;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,QAAQ,CAACC,MAAU;AAEjB,cAAMC,IAAcC;AAAA,UAClBF;AAAA,UACAJ;AAAA,UACAlD,IAAYmC,IAAsB,CAAA;AAAA,QACpC;AACA,eAAIH,IACKyB,EAAM,aAAaV,GAAcQ,CAAW,IAE3C,gBAAAV,EAAA,OAAA,EAAK,GAAGU,GAAc,UAAAxD,EAAS,CAAA;AAAA,MAE3C;AAAA,MACC,GAAGc;AAAA,IAAA;AAAA,EACN;AAEJ;"}
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import { jsxs as c, jsx as r } from "react/jsx-runtime";
3
- import { X as g, CircleNotch as w, CheckCircle as C, XCircle as T, WarningCircle as k, Info as b } from "@bioturing/assets";
3
+ import { XIcon as g, CircleNotchIcon as w, CheckCircleIcon as C, XCircleIcon as I, WarningCircleIcon as T, InfoIcon as k } from "@bioturing/assets";
4
4
  import { Toast as t } from "@base-ui-components/react";
5
5
  import { toastManager as a } from "./function.js";
6
- import { useEffect as v, useCallback as x } from "react";
7
- import { Button as P } from "../button/component.js";
8
- import { Modal as B } from "../modal/index.js";
6
+ import { useEffect as b, useCallback as v } from "react";
7
+ import { Button as x } from "../button/component.js";
8
+ import { Modal as P } from "../modal/index.js";
9
9
  import './style.css';/* empty css */
10
- import { isTracebackError as I } from "../utils/isTracebackError.js";
10
+ import { isTracebackError as B } from "../utils/isTracebackError.js";
11
11
  import { CodeBlock as M } from "../code-block/component.js";
12
12
  import { useCls as f } from "../utils/antdUtils.js";
13
13
  import { IconButton as j } from "../icon-button/component.js";
@@ -17,16 +17,16 @@ function u({
17
17
  }) {
18
18
  var l;
19
19
  const o = f(), n = {
20
- info: /* @__PURE__ */ r(b, { weight: "fill" }),
21
- warning: /* @__PURE__ */ r(k, { weight: "fill" }),
22
- error: /* @__PURE__ */ r(T, { weight: "fill" }),
20
+ info: /* @__PURE__ */ r(k, { weight: "fill" }),
21
+ warning: /* @__PURE__ */ r(T, { weight: "fill" }),
22
+ error: /* @__PURE__ */ r(I, { weight: "fill" }),
23
23
  success: /* @__PURE__ */ r(C, { weight: "fill" }),
24
24
  progress: /* @__PURE__ */ r(w, {})
25
- }, i = ((l = e.data) == null ? void 0 : l.type) || "info", s = I(e == null ? void 0 : e.description);
26
- v(() => {
25
+ }, i = ((l = e.data) == null ? void 0 : l.type) || "info", s = B(e == null ? void 0 : e.description);
26
+ b(() => {
27
27
  s && a.update(e.id, { timeout: 0 });
28
28
  }, [s, e.id]);
29
- const h = x(
29
+ const h = v(
30
30
  (N) => {
31
31
  const { children: d, className: m, ...p } = N;
32
32
  return s ? /* @__PURE__ */ c(
@@ -45,11 +45,11 @@ function u({
45
45
  "Please contact us with error details for support."
46
46
  ] }),
47
47
  /* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
48
- P,
48
+ x,
49
49
  {
50
50
  size: "small",
51
51
  onClick: () => {
52
- B.open({
52
+ P.open({
53
53
  title: "Error details",
54
54
  content: /* @__PURE__ */ r(M, { children: d }),
55
55
  hideOkButton: !0
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/toast/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx } from \"../utils\";\nimport {\n CheckCircle,\n CircleNotch,\n Info,\n WarningCircle,\n X,\n XCircle,\n} from \"@bioturing/assets\";\nimport { Toast as BaseToast } from \"@base-ui-components/react\";\nimport { IconButton } from \"../icon-button\";\nimport { ToastData } from \"./types\";\nimport { toastManager } from \"./function\";\nimport { isTracebackError, type GenericHTMLProps } from \"../utils\";\nimport { useCallback, useEffect } from \"react\";\nimport { Button } from \"../button/component\";\nimport { Modal } from \"../modal\";\nimport { CodeBlock } from \"../code-block\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nfunction InnerToast({\n toast,\n}: {\n toast: BaseToast.Root.ToastObject<ToastData>;\n}) {\n const cls = useCls();\n const toastIconMap = {\n info: <Info weight=\"fill\" />,\n warning: <WarningCircle weight=\"fill\" />,\n error: <XCircle weight=\"fill\" />,\n success: <CheckCircle weight=\"fill\" />,\n progress: <CircleNotch />,\n };\n const type = toast.data?.type || \"info\";\n const isTraceback = isTracebackError(toast?.description);\n\n // Update manager timeout for traceback to disable auto-dismiss\n useEffect(() => {\n if (isTraceback) {\n toastManager.update(toast.id, { timeout: 0 });\n }\n }, [isTraceback, toast.id]);\n // console.log(toast);\n const renderDescription: BaseToast.Description.Props[\"render\"] = useCallback(\n (props: GenericHTMLProps) => {\n const { children, className, ...rest } = props;\n if (isTraceback) {\n return (\n <div\n {...rest}\n className={cls(\n \"toast-description\",\n isTraceback ? \"toast-description-traceback\" : \"\",\n className\n )}\n >\n <p>\n An unexpected error occurred.\n <br />\n Please contact us with error details for support.\n </p>\n <p>\n <Button\n size=\"small\"\n onClick={() => {\n Modal.open({\n title: \"Error details\",\n content: <CodeBlock>{children}</CodeBlock>,\n hideOkButton: true,\n });\n toastManager.close(toast.id);\n }}\n >\n View error details\n </Button>\n </p>\n </div>\n );\n }\n return (\n <p {...rest} className={cls(\"toast-description\", className)}>\n {children}\n </p>\n );\n },\n [isTraceback, cls, toast.id]\n );\n return (\n <BaseToast.Root toast={toast} className={cls(\"toast\")}>\n <span className={cls(\"toast-icon-wrap\")}>\n <span className={cls(\"toast-icon\", `toast-icon-${type}`)}>\n {toastIconMap[type]}\n </span>\n </span>\n <div className={cls(\"toast-content\")}>\n <BaseToast.Title className={cls(\"toast-title\")} />\n <BaseToast.Description render={renderDescription} />\n </div>\n <BaseToast.Close\n className={cls(\"toast-close\")}\n render={\n <span>\n <IconButton size=\"small\">\n <X />\n </IconButton>\n </span>\n }\n ></BaseToast.Close>\n </BaseToast.Root>\n );\n}\n\nfunction ToastList({ className }: { className?: string }) {\n const { toasts } = BaseToast.useToastManager();\n const cls = useCls();\n\n return (\n <BaseToast.Portal>\n <BaseToast.Viewport className={clsx(cls(\"toast-viewport\"), className)}>\n {toasts.map((toast) => (\n <InnerToast key={toast.id} toast={toast} />\n ))}\n </BaseToast.Viewport>\n </BaseToast.Portal>\n );\n}\n\nfunction ToastProvider(props: BaseToast.Provider.Props) {\n return <BaseToast.Provider toastManager={toastManager} {...props} />;\n}\n\nexport const Toast = Object.assign(InnerToast, {\n List: ToastList,\n Provider: ToastProvider,\n});\n"],"names":["InnerToast","toast","cls","useCls","toastIconMap","jsx","Info","WarningCircle","XCircle","CheckCircle","CircleNotch","type","_a","isTraceback","isTracebackError","useEffect","toastManager","renderDescription","useCallback","props","children","className","rest","jsxs","Button","Modal","CodeBlock","BaseToast","IconButton","X","ToastList","toasts","clsx","ToastProvider","Toast"],"mappings":";;;;;;;;;;;;;;AAuBA,SAASA,EAAW;AAAA,EAClB,OAAAC;AACF,GAEG;;AACD,QAAMC,IAAMC,EAAO,GACbC,IAAe;AAAA,IACnB,MAAM,gBAAAC,EAACC,GAAK,EAAA,QAAO,OAAO,CAAA;AAAA,IAC1B,SAAS,gBAAAD,EAACE,GAAc,EAAA,QAAO,OAAO,CAAA;AAAA,IACtC,OAAO,gBAAAF,EAACG,GAAQ,EAAA,QAAO,OAAO,CAAA;AAAA,IAC9B,SAAS,gBAAAH,EAACI,GAAY,EAAA,QAAO,OAAO,CAAA;AAAA,IACpC,4BAAWC,GAAY,CAAA,CAAA;AAAA,EACzB,GACMC,MAAOC,IAAAX,EAAM,SAAN,gBAAAW,EAAY,SAAQ,QAC3BC,IAAcC,EAAiBb,KAAA,gBAAAA,EAAO,WAAW;AAGvD,EAAAc,EAAU,MAAM;AACd,IAAIF,KACFG,EAAa,OAAOf,EAAM,IAAI,EAAE,SAAS,GAAG;AAAA,EAE7C,GAAA,CAACY,GAAaZ,EAAM,EAAE,CAAC;AAE1B,QAAMgB,IAA2DC;AAAA,IAC/D,CAACC,MAA4B;AAC3B,YAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,G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AI,aAAa,GAAG;AAAA,MAC/C,gBAAAG,EAAAsB,EAAU,aAAV,EAAsB,QAAQV,EAAmB,CAAA;AAAA,IAAA,GACpD;AAAA,IACA,gBAAAZ;AAAA,MAACsB,EAAU;AAAA,MAAV;AAAA,QACC,WAAWzB,EAAI,aAAa;AAAA,QAC5B,QACG,gBAAAG,EAAA,QAAA,EACC,UAAC,gBAAAA,EAAAuB,GAAA,EAAW,MAAK,SACf,UAAA,gBAAAvB,EAACwB,GAAE,CAAA,CAAA,EACL,CAAA,EACF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEH,GACH;AAEJ;AAEA,SAASC,EAAU,EAAE,WAAAT,KAAqC;AACxD,QAAM,EAAE,QAAAU,EAAA,IAAWJ,EAAU,gBAAgB,GACvCzB,IAAMC,EAAO;AAGjB,SAAA,gBAAAE,EAACsB,EAAU,QAAV,EACC,UAAA,gBAAAtB,EAACsB,EAAU,UAAV,EAAmB,WAAWK,EAAK9B,EAAI,gBAAgB,GAAGmB,CAAS,GACjE,UAAAU,EAAO,IAAI,CAAC9B,MACX,gBAAAI,EAACL,GAA0B,EAAA,OAAAC,EAAA,GAAVA,EAAM,EAAkB,CAC1C,EAAA,CACH,EACF,CAAA;AAEJ;AAEA,SAASgC,EAAcd,GAAiC;AACtD,2BAAQQ,EAAU,UAAV,EAAmB,cAAAX,GAA6B,GAAGG,GAAO;AACpE;AAEa,MAAAe,IAAQ,OAAO,OAAOlC,GAAY;AAAA,EAC7C,MAAM8B;AAAA,EACN,UAAUG;AACZ,CAAC;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/toast/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx } from \"../utils\";\nimport {\n CheckCircleIcon,\n CircleNotchIcon,\n InfoIcon,\n WarningCircleIcon,\n XIcon,\n XCircleIcon,\n} from \"@bioturing/assets\";\nimport { Toast as BaseToast } from \"@base-ui-components/react\";\nimport { IconButton } from \"../icon-button\";\nimport { ToastData } from \"./types\";\nimport { toastManager } from \"./function\";\nimport { isTracebackError, type GenericHTMLProps } from \"../utils\";\nimport { useCallback, useEffect } from \"react\";\nimport { Button } from \"../button/component\";\nimport { Modal } from \"../modal\";\nimport { CodeBlock } from \"../code-block\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nfunction InnerToast({\n toast,\n}: {\n toast: BaseToast.Root.ToastObject<ToastData>;\n}) {\n const cls = useCls();\n const toastIconMap = {\n info: <InfoIcon weight=\"fill\" />,\n warning: <WarningCircleIcon weight=\"fill\" />,\n error: <XCircleIcon weight=\"fill\" />,\n success: <CheckCircleIcon weight=\"fill\" />,\n progress: <CircleNotchIcon />,\n };\n const type = toast.data?.type || \"info\";\n const isTraceback = isTracebackError(toast?.description);\n\n // Update manager timeout for traceback to disable auto-dismiss\n useEffect(() => {\n if (isTraceback) {\n toastManager.update(toast.id, { timeout: 0 });\n }\n }, [isTraceback, toast.id]);\n // console.log(toast);\n const renderDescription: BaseToast.Description.Props[\"render\"] = useCallback(\n (props: GenericHTMLProps) => {\n const { children, className, ...rest } = props;\n if (isTraceback) {\n return (\n <div\n {...rest}\n className={cls(\n \"toast-description\",\n isTraceback ? \"toast-description-traceback\" : \"\",\n className\n )}\n >\n <p>\n An unexpected error occurred.\n <br />\n Please contact us with error details for support.\n </p>\n <p>\n <Button\n size=\"small\"\n onClick={() => {\n Modal.open({\n title: \"Error details\",\n content: <CodeBlock>{children}</CodeBlock>,\n hideOkButton: true,\n });\n toastManager.close(toast.id);\n }}\n >\n View error details\n </Button>\n </p>\n </div>\n );\n }\n return (\n <p {...rest} className={cls(\"toast-description\", className)}>\n {children}\n </p>\n );\n },\n [isTraceback, cls, toast.id]\n );\n return (\n <BaseToast.Root toast={toast} className={cls(\"toast\")}>\n <span className={cls(\"toast-icon-wrap\")}>\n <span className={cls(\"toast-icon\", `toast-icon-${type}`)}>\n {toastIconMap[type]}\n </span>\n </span>\n <div className={cls(\"toast-content\")}>\n <BaseToast.Title className={cls(\"toast-title\")} />\n <BaseToast.Description render={renderDescription} />\n </div>\n <BaseToast.Close\n className={cls(\"toast-close\")}\n render={\n <span>\n <IconButton size=\"small\">\n <XIcon />\n </IconButton>\n </span>\n }\n ></BaseToast.Close>\n </BaseToast.Root>\n );\n}\n\nfunction ToastList({ className }: { className?: string }) {\n const { toasts } = BaseToast.useToastManager();\n const cls = useCls();\n\n return (\n <BaseToast.Portal>\n <BaseToast.Viewport className={clsx(cls(\"toast-viewport\"), className)}>\n {toasts.map((toast) => (\n <InnerToast key={toast.id} toast={toast} />\n ))}\n </BaseToast.Viewport>\n </BaseToast.Portal>\n );\n}\n\nfunction ToastProvider(props: BaseToast.Provider.Props) {\n return <BaseToast.Provider toastManager={toastManager} {...props} />;\n}\n\nexport const Toast = Object.assign(InnerToast, {\n List: ToastList,\n Provider: ToastProvider,\n});\n"],"names":["InnerToast","toast","cls","useCls","toastIconMap","jsx","InfoIcon","WarningCircleIcon","XCircleIcon","CheckCircleIcon","CircleNotchIcon","type","_a","isTraceback","isTracebackError","useEffect","toastManager","renderDescription","useCallback","props","children","className","rest","jsxs","Button","Modal","CodeBlock","BaseToast","IconButton","XIcon","ToastList","toasts","clsx","ToastProvider","Toast"],"mappings":";;;;;;;;;;;;;;AAuBA,SAASA,EAAW;AAAA,EAClB,OAAAC;AACF,GAEG;;AACD,QAAMC,IAAMC,EAAO,GACbC,IAAe;AAAA,IACnB,MAAM,gBAAAC,EAACC,GAAS,EAAA,QAAO,OAAO,CAAA;AAAA,IAC9B,SAAS,gBAAAD,EAACE,GAAkB,EAAA,QAAO,OAAO,CAAA;AAAA,IAC1C,OAAO,gBAAAF,EAACG,GAAY,EAAA,QAAO,OAAO,CAAA;AAAA,IAClC,SAAS,gBAAAH,EAACI,GAAgB,EAAA,QAAO,OAAO,CAAA;AAAA,IACxC,4BAAWC,GAAgB,CAAA,CAAA;AAAA,EAC7B,GACMC,MAAOC,IAAAX,EAAM,SAAN,gBAAAW,EAAY,SAAQ,QAC3BC,IAAcC,EAAiBb,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.d.ts CHANGED
@@ -456,7 +456,7 @@ declare type Children = {
456
456
  children?: default_2.ReactNode;
457
457
  };
458
458
 
459
- export declare const ChoiceList: <M extends boolean = false>({ items, multiple, value, defaultValue, onChange, searchProps, showSelectAll, className, placeholder, ...rest }: ChoiceListProps<M>) => JSX.Element;
459
+ export declare const ChoiceList: <M extends boolean = false>({ items, multiple, value, defaultValue, onChange, searchProps, showSelectAll, className, placeholder, disabled: disabledProp, status: statusProp, getItemKeywords, ...rest }: ChoiceListProps<M>) => JSX.Element;
460
460
 
461
461
  export declare type ChoiceListItem = {
462
462
  label: React.ReactNode;
@@ -476,6 +476,20 @@ export declare interface ChoiceListProps<M extends boolean = false> extends Omit
476
476
  */
477
477
  showSelectAll?: boolean;
478
478
  placeholder?: string;
479
+ /**
480
+ * Whether the choice list is disabled
481
+ * @default false
482
+ */
483
+ disabled?: boolean;
484
+ /**
485
+ * Validation status
486
+ */
487
+ status?: "error" | "warning" | "success" | "validating";
488
+ /**
489
+ * Function to extract keywords from the item for search filtering
490
+ * @default (item) => [item.value, reactNodeToString(item.label)]
491
+ */
492
+ getItemKeywords?: (item: ChoiceListItem) => string[];
479
493
  }
480
494
 
481
495
  export declare interface ClassArray extends Array<ClassValue> {
@@ -1787,7 +1801,7 @@ export declare const DROPDOWN_COLLISION_AVOIDANCE: {
1787
1801
  readonly fallbackAxisSide: "none";
1788
1802
  };
1789
1803
 
1790
- export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, className, itemRender, classNames, size, showSearch, searchProps, popupMatchTriggerWidth, beforeList, afterList, keepOpenOnSelect, highlightedItemKey, selectedItemKeys, showCheckbox, }: DropdownMenuProps) => JSX.Element;
1804
+ export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, className, itemRender, classNames, size, showSearch, searchProps, popupMatchTriggerWidth, beforeList, afterList, keepOpenOnSelect, highlightedItemKey, selectedItemKeys, showCheckbox, getItemKeywords, }: DropdownMenuProps) => JSX.Element;
1791
1805
 
1792
1806
  export declare const DropdownMenuItem: default_2.FC<DropdownMenuItemProps>;
1793
1807
 
@@ -1829,6 +1843,13 @@ export declare interface DropdownMenuItemProps {
1829
1843
  * @default false
1830
1844
  */
1831
1845
  indeterminate?: boolean;
1846
+ /**
1847
+ * Function to extract keywords from the item for search filtering
1848
+ * @default (item) => [String(item.key), reactNodeToString(item.label)]
1849
+ */
1850
+ getItemKeywords?: (item: DropdownMenuItemType & {
1851
+ type: "item";
1852
+ }) => string[];
1832
1853
  }
1833
1854
 
1834
1855
  export declare type DropdownMenuItemType = {
@@ -1996,6 +2017,13 @@ export declare interface DropdownMenuProps {
1996
2017
  * @default false
1997
2018
  */
1998
2019
  showCheckbox?: boolean;
2020
+ /**
2021
+ * Function to extract keywords from the item for search filtering
2022
+ * @default (item) => [String(item.key), reactNodeToString(item.label)]
2023
+ */
2024
+ getItemKeywords?: (item: DropdownMenuItemType & {
2025
+ type: "item";
2026
+ }) => string[];
1999
2027
  }
2000
2028
 
2001
2029
  export { DropDownProps }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bioturing/components",
3
- "version": "0.29.1",
3
+ "version": "0.29.2",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",