@bioturing/components 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/choice-list/component.js +26 -28
- package/dist/components/choice-list/component.js.map +1 -1
- package/dist/components/code-block/component.js +10 -10
- package/dist/components/combobox/component.js +113 -112
- package/dist/components/combobox/component.js.map +1 -1
- package/dist/components/command-palette/component.js +79 -0
- package/dist/components/command-palette/component.js.map +1 -0
- package/dist/components/command-palette/style.css +1 -0
- package/dist/components/dropdown-menu/component.js +117 -189
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/item.css +1 -1
- package/dist/components/dropdown-menu/item.js +50 -37
- package/dist/components/dropdown-menu/item.js.map +1 -1
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.js +124 -0
- package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -0
- package/dist/components/keyboard-shortcut/component.js +72 -0
- package/dist/components/keyboard-shortcut/component.js.map +1 -0
- package/dist/components/keyboard-shortcut/style.css +1 -0
- package/dist/components/loader/component.js +15 -0
- package/dist/components/loader/component.js.map +1 -0
- package/dist/components/loader/style.css +1 -0
- package/dist/components/popup-panel/style.css +1 -1
- package/dist/components/theme-provider/style.css +1 -1
- package/dist/components/toast/style.css +1 -1
- package/dist/index.d.ts +180 -51
- package/dist/index.js +203 -197
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +47 -2
- package/dist/metadata.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as v, jsx as t } from "react/jsx-runtime";
|
|
3
3
|
import { Command as d } from "../cmdk/index.js";
|
|
4
|
-
import { useMemo as P, useContext as
|
|
5
|
-
import './style.css';/* empty css */
|
|
4
|
+
import { useMemo as P, useContext as b, useCallback as p } from "react";
|
|
6
5
|
import { FormItemInputContext as x } from "antd/es/form/context";
|
|
7
6
|
import R from "antd/es/config-provider/DisabledContext";
|
|
7
|
+
import './style.css';/* empty css */
|
|
8
8
|
import { Radio as T } from "../radio/component.js";
|
|
9
9
|
import { useControlledState as q } from "../hooks/useControlledState.js";
|
|
10
10
|
import { useCls as w } from "../utils/antdUtils.js";
|
|
@@ -14,7 +14,7 @@ import { Checkbox as S } from "../checkbox/component.js";
|
|
|
14
14
|
import { ScrollArea as H } from "../scroll-area/component.js";
|
|
15
15
|
import { reactNodeToString as J } from "../utils/reactToString.js";
|
|
16
16
|
const ae = ({
|
|
17
|
-
|
|
17
|
+
options: i,
|
|
18
18
|
multiple: a,
|
|
19
19
|
value: g,
|
|
20
20
|
defaultValue: C,
|
|
@@ -28,25 +28,23 @@ const ae = ({
|
|
|
28
28
|
getItemKeywords: m,
|
|
29
29
|
...j
|
|
30
30
|
}) => {
|
|
31
|
-
const [l,
|
|
31
|
+
const [l, n] = q(
|
|
32
32
|
g,
|
|
33
33
|
A,
|
|
34
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(() => {
|
|
35
|
+
), s = P(() => a ? Array.isArray(l) ? l : l ? [l] : [] : Array.isArray(l) ? l.length > 0 ? [l[0]] : [] : l ? [l] : [], [l, a]), { status: B } = b(x), E = b(R), F = V || B, c = D || E, o = w(), L = p(() => {
|
|
38
36
|
if (a) {
|
|
39
37
|
const e = i.map((r) => r.value).filter(Boolean);
|
|
40
|
-
|
|
38
|
+
n(e);
|
|
41
39
|
}
|
|
42
|
-
}, [a, i,
|
|
43
|
-
a &&
|
|
44
|
-
}, [a,
|
|
45
|
-
return /* @__PURE__ */
|
|
40
|
+
}, [a, i, n]), M = p(() => {
|
|
41
|
+
a && n([]);
|
|
42
|
+
}, [a, n]);
|
|
43
|
+
return /* @__PURE__ */ v(
|
|
46
44
|
d,
|
|
47
45
|
{
|
|
48
|
-
className: z(
|
|
49
|
-
"data-disabled":
|
|
46
|
+
className: z(o("choice-list"), N),
|
|
47
|
+
"data-disabled": c,
|
|
50
48
|
"data-status": F,
|
|
51
49
|
...j,
|
|
52
50
|
children: [
|
|
@@ -59,8 +57,8 @@ const ae = ({
|
|
|
59
57
|
G.Search,
|
|
60
58
|
{
|
|
61
59
|
allowClear: !0,
|
|
62
|
-
disabled:
|
|
63
|
-
className:
|
|
60
|
+
disabled: c,
|
|
61
|
+
className: o("choice-list-search"),
|
|
64
62
|
placeholder: y
|
|
65
63
|
}
|
|
66
64
|
)
|
|
@@ -75,9 +73,9 @@ const ae = ({
|
|
|
75
73
|
return /* @__PURE__ */ t(
|
|
76
74
|
"div",
|
|
77
75
|
{
|
|
78
|
-
className:
|
|
76
|
+
className: o("choice-list-item"),
|
|
79
77
|
onClick: () => {
|
|
80
|
-
|
|
78
|
+
c || (h || u ? M() : L());
|
|
81
79
|
},
|
|
82
80
|
children: /* @__PURE__ */ t(
|
|
83
81
|
S,
|
|
@@ -85,31 +83,31 @@ const ae = ({
|
|
|
85
83
|
tabIndex: -1,
|
|
86
84
|
checked: u,
|
|
87
85
|
indeterminate: h,
|
|
88
|
-
disabled:
|
|
86
|
+
disabled: c,
|
|
89
87
|
children: "Select All"
|
|
90
88
|
}
|
|
91
89
|
)
|
|
92
90
|
}
|
|
93
91
|
);
|
|
94
92
|
})(),
|
|
95
|
-
/* @__PURE__ */ t(H, { className:
|
|
96
|
-
/* @__PURE__ */ t(d.Empty, { className:
|
|
93
|
+
/* @__PURE__ */ t(H, { className: o("choice-list-items"), fadeEdges: !0, children: /* @__PURE__ */ v(d.List, { children: [
|
|
94
|
+
/* @__PURE__ */ t(d.Empty, { className: o("choice-list-empty"), children: "No results found." }),
|
|
97
95
|
i.map((e) => /* @__PURE__ */ t(
|
|
98
96
|
d.Item,
|
|
99
97
|
{
|
|
100
|
-
className:
|
|
98
|
+
className: o("choice-list-item"),
|
|
101
99
|
keywords: m ? m(e) : [e.value || "", J(e.label)],
|
|
102
100
|
value: e.value,
|
|
103
101
|
"data-in-choice": e.value ? s.includes(e.value) : !1,
|
|
104
102
|
onSelect: (r) => {
|
|
105
|
-
if (!
|
|
103
|
+
if (!c)
|
|
106
104
|
if (a) {
|
|
107
105
|
const u = s.includes(r) ? s.filter((h) => h !== r) : [.../* @__PURE__ */ new Set([...s, r])];
|
|
108
|
-
|
|
106
|
+
n(
|
|
109
107
|
u
|
|
110
108
|
);
|
|
111
109
|
} else
|
|
112
|
-
|
|
110
|
+
n(
|
|
113
111
|
r
|
|
114
112
|
);
|
|
115
113
|
},
|
|
@@ -118,7 +116,7 @@ const ae = ({
|
|
|
118
116
|
{
|
|
119
117
|
tabIndex: -1,
|
|
120
118
|
checked: e.value ? s.includes(e.value) : !1,
|
|
121
|
-
disabled:
|
|
119
|
+
disabled: c,
|
|
122
120
|
children: e.label
|
|
123
121
|
}
|
|
124
122
|
) : /* @__PURE__ */ t(
|
|
@@ -126,7 +124,7 @@ const ae = ({
|
|
|
126
124
|
{
|
|
127
125
|
tabIndex: -1,
|
|
128
126
|
checked: e.value ? s.includes(e.value) : !1,
|
|
129
|
-
disabled:
|
|
127
|
+
disabled: c,
|
|
130
128
|
children: e.label
|
|
131
129
|
}
|
|
132
130
|
)
|
|
@@ -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, 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,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,EAAU,OAAO,CAACd,MAAUA,MAAU0C,CAAQ,IAC9C,CAAC,GAAO,oBAAA,IAAI,CAAC,GAAG5B,GAAW4B,CAAQ,CAAC,CAAC;AACzC,oBAAA9B;AAAA,sBACE+B;AAAA,oBACF;AAAA,kBAAA;AAEA,oBAAA/B;AAAA,sBACE8B;AAAA,oBACF;AAAA,cAEJ;AAAA,cAEC,UACC3C,IAAA,gBAAAkC;AAAA,gBAACM;AAAA,gBAAA;AAAA,kBACC,UAAU;AAAA,kBACV,SAASX,EAAK,QAAQd,EAAU,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;"}
|
|
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 { FormItemInputContext } from \"antd/es/form/context\";\nimport DisabledContext from \"antd/es/config-provider/DisabledContext\";\n\nexport type ChoiceListOption = {\n label: React.ReactNode;\n value?: string;\n};\n\nimport \"./style.css\";\n\nexport interface ChoiceListProps<M extends boolean = false>\n extends Omit<CommandProps, \"value\" | \"onChange\" | \"defaultValue\"> {\n options: ChoiceListOption[];\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: ChoiceListOption) => string[];\n}\n\nexport const ChoiceList = <M extends boolean = false>({\n options,\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 { status: contextStatus } = 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 = options\n .map((item) => item.value)\n .filter(Boolean) as string[];\n setInternalValue(allValues as M extends true ? string[] : string);\n }\n }, [multiple, options, 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 options.length > 0 &&\n (() => {\n const allValues = options\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 {options.map((item) => (\n <Command.Item\n key={item.value}\n className={cls(\"choice-list-item\")}\n keywords={\n getItemKeywords\n ? getItemKeywords(item)\n : [item.value || \"\", reactNodeToString(item.label)]\n }\n value={item.value}\n data-in-choice={\n item.value ? usedValue.includes(item.value) : false\n }\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","options","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":";;;;;;;;;;;;;;;AAkDO,MAAMA,KAAa,CAA4B;AAAA,EACpD,SAAAC;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,EA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AA9B;AAAA,sBACE+B;AAAA,oBACF;AAAA,kBAAA;AAEA,oBAAA/B;AAAA,sBACE8B;AAAA,oBACF;AAAA,cAEJ;AAAA,cAEC,UACC3C,IAAA,gBAAAkC;AAAA,gBAACM;AAAA,gBAAA;AAAA,kBACC,UAAU;AAAA,kBACV,SAASX,EAAK,QAAQd,EAAU,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,YA1CGA,EAAK;AAAA,UA6Cb,CAAA;AAAA,QAAA,EAAA,CACH,EACF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -5,11 +5,11 @@ 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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
8
|
+
import { Segmented as U } from "../segmented/component.js";
|
|
9
|
+
import { useControlledState as V } from "../hooks/useControlledState.js";
|
|
10
|
+
import { reactNodeToString as X } from "../utils/reactToString.js";
|
|
11
|
+
import { useCls as Y } from "../utils/antdUtils.js";
|
|
12
|
+
import { WithAntdTokens as Z } from "../utils/WithAntdTokens.js";
|
|
13
13
|
import { clsx as H } from "../utils/cn.js";
|
|
14
14
|
import { IconButton as N } from "../icon-button/component.js";
|
|
15
15
|
import { ScrollArea as oo } from "../scroll-area/component.js";
|
|
@@ -30,7 +30,7 @@ const vo = ({
|
|
|
30
30
|
onCopy: C,
|
|
31
31
|
...A
|
|
32
32
|
}) => {
|
|
33
|
-
const [l, y] =
|
|
33
|
+
const [l, y] = V(
|
|
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 ||
|
|
54
|
+
const t = c || X(m);
|
|
55
55
|
try {
|
|
56
56
|
navigator.clipboard.writeText(t).then(() => {
|
|
57
57
|
u(g), S(!0), C && C(t);
|
|
@@ -61,15 +61,15 @@ const vo = ({
|
|
|
61
61
|
}
|
|
62
62
|
}, [c, m, g, C]), F = I(() => {
|
|
63
63
|
u(a), S(!1);
|
|
64
|
-
}, [a]), d =
|
|
64
|
+
}, [a]), d = Y();
|
|
65
65
|
return /* @__PURE__ */ o(R, { theme: "dark", children: /* @__PURE__ */ q(
|
|
66
|
-
|
|
66
|
+
Z,
|
|
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
|
-
|
|
72
|
+
U,
|
|
73
73
|
{
|
|
74
74
|
value: l,
|
|
75
75
|
onChange: y,
|
|
@@ -1,159 +1,159 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
2
|
+
import { jsxs as ue, Fragment as fe, jsx as b } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as me, useState as S, useContext as _, useCallback as p, useMemo as x } from "react";
|
|
4
4
|
import { useControlled as be } from "@base-ui-components/utils/useControlled";
|
|
5
|
-
import { FormItemInputContext as
|
|
6
|
-
import
|
|
5
|
+
import { FormItemInputContext as pe } from "antd/es/form/context";
|
|
6
|
+
import xe from "antd/es/config-provider/DisabledContext";
|
|
7
7
|
import './style.css';/* empty css */
|
|
8
|
-
import { DropdownMenuDivider as
|
|
9
|
-
import { DropdownMenuItem as
|
|
10
|
-
import { DropdownMenu as
|
|
11
|
-
import { SelectTrigger as
|
|
12
|
-
import { useControlledState as
|
|
13
|
-
import { useCls as
|
|
8
|
+
import { DropdownMenuDivider as ye } from "../dropdown-menu/divider.js";
|
|
9
|
+
import { DropdownMenuItem as ge } from "../dropdown-menu/item.js";
|
|
10
|
+
import { DropdownMenu as ve } from "../dropdown-menu/component.js";
|
|
11
|
+
import { SelectTrigger as he } from "../select-trigger/component.js";
|
|
12
|
+
import { useControlledState as Ce } from "../hooks/useControlledState.js";
|
|
13
|
+
import { useCls as Ae } from "../utils/antdUtils.js";
|
|
14
14
|
import { clsx as y } from "../utils/cn.js";
|
|
15
|
-
|
|
15
|
+
import { reactNodeToString as Ve } from "../utils/reactToString.js";
|
|
16
|
+
const ke = ({
|
|
16
17
|
options: g = [],
|
|
17
18
|
value: R,
|
|
18
|
-
defaultValue:
|
|
19
|
+
defaultValue: T,
|
|
19
20
|
onChange: v,
|
|
20
21
|
placeholder: $ = "Select...",
|
|
21
22
|
disabled: B = !1,
|
|
22
23
|
status: E,
|
|
23
|
-
allowClear:
|
|
24
|
+
allowClear: W = !1,
|
|
24
25
|
multiple: t = !1,
|
|
25
|
-
maxTagCount:
|
|
26
|
-
showSearch:
|
|
27
|
-
open:
|
|
28
|
-
onOpenChange:
|
|
29
|
-
placement:
|
|
30
|
-
className:
|
|
26
|
+
maxTagCount: De,
|
|
27
|
+
showSearch: i = !0,
|
|
28
|
+
open: q,
|
|
29
|
+
onOpenChange: z,
|
|
30
|
+
placement: G = "bottomLeft",
|
|
31
|
+
className: H,
|
|
31
32
|
classNames: a,
|
|
32
|
-
size:
|
|
33
|
-
loading:
|
|
34
|
-
optionRender:
|
|
33
|
+
size: J = "middle",
|
|
34
|
+
loading: we = !1,
|
|
35
|
+
optionRender: Me,
|
|
35
36
|
filterOption: h = !0,
|
|
36
37
|
onSearch: C,
|
|
37
|
-
dropdownRender:
|
|
38
|
-
clearIcon:
|
|
39
|
-
suffixIcon:
|
|
40
|
-
dropdownMenuProps:
|
|
38
|
+
dropdownRender: Te,
|
|
39
|
+
clearIcon: Q,
|
|
40
|
+
suffixIcon: U,
|
|
41
|
+
dropdownMenuProps: X,
|
|
41
42
|
triggerProps: A,
|
|
42
|
-
searchProps:
|
|
43
|
+
searchProps: Y,
|
|
43
44
|
showSelectionSummary: F = !1,
|
|
44
|
-
selectionSummaryRender:
|
|
45
|
+
selectionSummaryRender: k,
|
|
45
46
|
showSelectAll: L = !1,
|
|
46
|
-
selectAllRender:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
selectAllRender: Fe,
|
|
48
|
+
getOptionKeywords: Z = (V) => [
|
|
49
|
+
String(V.key),
|
|
50
|
+
Ve(V.label)
|
|
51
|
+
],
|
|
52
|
+
...N
|
|
53
|
+
}, ee) => {
|
|
54
|
+
const [V] = S(
|
|
55
|
+
T !== void 0 ? T : t ? [] : void 0
|
|
56
|
+
), [o, O] = be({
|
|
52
57
|
controlled: R,
|
|
53
|
-
default:
|
|
58
|
+
default: V,
|
|
54
59
|
name: "value"
|
|
55
|
-
}), [
|
|
56
|
-
W,
|
|
60
|
+
}), [j, K] = Ce(
|
|
57
61
|
q,
|
|
62
|
+
z,
|
|
58
63
|
!1
|
|
59
|
-
), [
|
|
60
|
-
status:
|
|
64
|
+
), [d, te] = S(""), c = Ae(), {
|
|
65
|
+
status: le
|
|
61
66
|
// hasFeedback,
|
|
62
67
|
// feedbackIcon,
|
|
63
|
-
} =
|
|
68
|
+
} = _(pe), oe = _(xe), re = E || le, ne = B || oe, n = p(
|
|
64
69
|
(e) => {
|
|
65
70
|
O(e), v == null || v(e);
|
|
66
71
|
},
|
|
67
72
|
[O, v]
|
|
68
|
-
), P =
|
|
73
|
+
), P = p(
|
|
69
74
|
(e) => {
|
|
70
75
|
if (t) {
|
|
71
|
-
const
|
|
72
|
-
n(
|
|
76
|
+
const l = Array.isArray(o) ? o : [], f = l.includes(e) ? l.filter((m) => m !== e) : [...l, e];
|
|
77
|
+
n(f);
|
|
73
78
|
} else
|
|
74
79
|
n(e);
|
|
75
80
|
},
|
|
76
|
-
[t,
|
|
77
|
-
),
|
|
81
|
+
[t, o, n]
|
|
82
|
+
), se = p(
|
|
78
83
|
(e) => {
|
|
79
|
-
|
|
84
|
+
te(e), C == null || C(e);
|
|
80
85
|
},
|
|
81
86
|
[C]
|
|
82
|
-
)
|
|
83
|
-
i(
|
|
84
|
-
(e) => t ? Array.isArray(l) && l.includes(e) : l === e,
|
|
85
|
-
[t, l]
|
|
86
|
-
);
|
|
87
|
-
const o = x(() => !d || !c ? g : g.filter((e) => typeof h == "function" ? h(c, e) : h === !1 ? !0 : (typeof e.label == "string" ? e.label : String(e.value)).toLowerCase().includes(c.toLowerCase())), [g, d, c, h]), k = i(() => {
|
|
87
|
+
), r = x(() => !i || !d ? g : g.filter((e) => typeof h == "function" ? h(d, e) : h === !1 ? !0 : (typeof e.label == "string" ? e.label : String(e.value)).toLowerCase().includes(d.toLowerCase())), [g, i, d, h]), I = p(() => {
|
|
88
88
|
if (t) {
|
|
89
|
-
const e =
|
|
89
|
+
const e = r.map((l) => l.value);
|
|
90
90
|
n(e);
|
|
91
91
|
}
|
|
92
|
-
}, [t,
|
|
92
|
+
}, [t, r, n]), D = p(() => {
|
|
93
93
|
t && n([]);
|
|
94
|
-
}, [t, n]),
|
|
94
|
+
}, [t, n]), ae = x(() => r.map((e) => ({
|
|
95
95
|
type: "item",
|
|
96
96
|
key: e.value,
|
|
97
97
|
icon: e.icon,
|
|
98
98
|
label: e.label,
|
|
99
99
|
disabled: e.disabled,
|
|
100
100
|
onClick: () => !e.disabled && P(e.value)
|
|
101
|
-
})), [
|
|
102
|
-
if (!L || !t ||
|
|
101
|
+
})), [r, P]), ie = x(() => {
|
|
102
|
+
if (!L || !t || r.length === 0)
|
|
103
103
|
return null;
|
|
104
|
-
const e = Array.isArray(
|
|
105
|
-
(M) =>
|
|
106
|
-
), m =
|
|
107
|
-
return /* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
|
|
104
|
+
const e = Array.isArray(o) ? o : [], l = r.map((M) => M.value), f = e.filter(
|
|
105
|
+
(M) => l.includes(M)
|
|
106
|
+
), m = f.length === r.length && r.length > 0, w = f.length > 0 && f.length < r.length;
|
|
107
|
+
return /* @__PURE__ */ ue(fe, { children: [
|
|
108
|
+
/* @__PURE__ */ b(
|
|
109
|
+
ge,
|
|
110
110
|
{
|
|
111
111
|
item: {
|
|
112
112
|
type: "item",
|
|
113
113
|
key: "select_all",
|
|
114
114
|
label: "Select All",
|
|
115
115
|
onClick: () => {
|
|
116
|
-
|
|
116
|
+
w || m ? D() : I();
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
|
-
inCombobox:
|
|
119
|
+
inCombobox: i,
|
|
120
120
|
selected: m,
|
|
121
121
|
showCheckbox: !0,
|
|
122
|
-
indeterminate:
|
|
122
|
+
indeterminate: w,
|
|
123
123
|
renderAsNativeElement: !0,
|
|
124
124
|
onSelect: () => {
|
|
125
|
-
|
|
125
|
+
w || m ? D() : I();
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"select_all"
|
|
129
129
|
),
|
|
130
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ b(ye, {})
|
|
131
131
|
] });
|
|
132
132
|
}, [
|
|
133
133
|
L,
|
|
134
134
|
t,
|
|
135
|
+
r,
|
|
135
136
|
o,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
I
|
|
139
|
-
|
|
140
|
-
]), f = x(() => Array.isArray(l) ? l : l ? [l] : [], [l]), s = f.map((e) => g.find((r) => r.value === e)).filter(Boolean), { displayValue: ie, displayPrefix: de } = x(() => {
|
|
137
|
+
i,
|
|
138
|
+
D,
|
|
139
|
+
I
|
|
140
|
+
]), u = x(() => Array.isArray(o) ? o : o ? [o] : [], [o]), s = u.map((e) => g.find((l) => l.value === e)).filter(Boolean), { displayValue: de, displayPrefix: ce } = x(() => {
|
|
141
141
|
if (s.length === 0)
|
|
142
142
|
return { displayValue: void 0, displayPrefix: void 0 };
|
|
143
143
|
if (t) {
|
|
144
|
-
const
|
|
145
|
-
return F ?
|
|
146
|
-
displayValue:
|
|
144
|
+
const l = `${s.length} ${s.length === 1 ? "item" : "items"} selected`;
|
|
145
|
+
return F ? k ? {
|
|
146
|
+
displayValue: k(u),
|
|
147
147
|
displayPrefix: void 0
|
|
148
148
|
} : {
|
|
149
|
-
displayValue:
|
|
149
|
+
displayValue: l,
|
|
150
150
|
// TODO: Create icon component for multiple selection summary
|
|
151
151
|
displayPrefix: void 0
|
|
152
152
|
} : s.length === 1 ? {
|
|
153
153
|
displayValue: s[0].label,
|
|
154
154
|
displayPrefix: s[0].icon
|
|
155
155
|
} : {
|
|
156
|
-
displayValue:
|
|
156
|
+
displayValue: l,
|
|
157
157
|
displayPrefix: void 0
|
|
158
158
|
};
|
|
159
159
|
}
|
|
@@ -166,67 +166,68 @@ const Ae = ({
|
|
|
166
166
|
s,
|
|
167
167
|
t,
|
|
168
168
|
F,
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
k,
|
|
170
|
+
u
|
|
171
171
|
]);
|
|
172
|
-
return /* @__PURE__ */
|
|
173
|
-
|
|
172
|
+
return /* @__PURE__ */ b("div", { ref: ee, className: y(c("combobox"), H), ...N, children: /* @__PURE__ */ b(
|
|
173
|
+
ve,
|
|
174
174
|
{
|
|
175
|
-
items:
|
|
176
|
-
open:
|
|
177
|
-
onOpenChange:
|
|
178
|
-
placement:
|
|
179
|
-
showSearch:
|
|
175
|
+
items: ae,
|
|
176
|
+
open: j,
|
|
177
|
+
onOpenChange: K,
|
|
178
|
+
placement: G,
|
|
179
|
+
showSearch: i,
|
|
180
180
|
searchProps: {
|
|
181
181
|
placeholder: "Search options...",
|
|
182
|
-
onValueChange:
|
|
183
|
-
value:
|
|
184
|
-
...
|
|
182
|
+
onValueChange: se,
|
|
183
|
+
value: d,
|
|
184
|
+
...Y
|
|
185
185
|
},
|
|
186
|
-
className: y(
|
|
186
|
+
className: y(c("combobox-dropdown")),
|
|
187
187
|
classNames: {
|
|
188
|
-
trigger: y(
|
|
189
|
-
popup: y(
|
|
190
|
-
item: y(
|
|
188
|
+
trigger: y(c("combobox-trigger-wrapper")),
|
|
189
|
+
popup: y(c("combobox-popup")),
|
|
190
|
+
item: y(c("combobox-option"), a == null ? void 0 : a.option),
|
|
191
191
|
...a
|
|
192
192
|
},
|
|
193
193
|
popupMatchTriggerWidth: !0,
|
|
194
194
|
keepOpenOnSelect: t,
|
|
195
|
-
highlightedItemKey: t ? void 0 :
|
|
195
|
+
highlightedItemKey: t ? void 0 : u[0],
|
|
196
196
|
showCheckbox: t,
|
|
197
|
-
beforeList:
|
|
198
|
-
selectedItemKeys:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
beforeList: ie,
|
|
198
|
+
selectedItemKeys: u,
|
|
199
|
+
getItemKeywords: Z,
|
|
200
|
+
...X,
|
|
201
|
+
children: /* @__PURE__ */ b(
|
|
202
|
+
he,
|
|
202
203
|
{
|
|
203
|
-
value:
|
|
204
|
-
prefix:
|
|
204
|
+
value: de,
|
|
205
|
+
prefix: ce,
|
|
205
206
|
placeholder: $,
|
|
206
|
-
disabled:
|
|
207
|
+
disabled: ne,
|
|
207
208
|
status: re,
|
|
208
|
-
open:
|
|
209
|
-
size:
|
|
210
|
-
allowClear:
|
|
211
|
-
suffixIcon:
|
|
212
|
-
clearIcon:
|
|
209
|
+
open: j,
|
|
210
|
+
size: J,
|
|
211
|
+
allowClear: W,
|
|
212
|
+
suffixIcon: U,
|
|
213
|
+
clearIcon: Q,
|
|
213
214
|
classNames: {
|
|
214
215
|
trigger: a == null ? void 0 : a.trigger,
|
|
215
216
|
...A == null ? void 0 : A.classNames
|
|
216
217
|
},
|
|
217
218
|
onClear: () => n(t ? [] : void 0),
|
|
218
|
-
onOpenChange:
|
|
219
|
+
onOpenChange: K,
|
|
219
220
|
role: "combobox",
|
|
220
221
|
...A
|
|
221
222
|
}
|
|
222
223
|
)
|
|
223
224
|
}
|
|
224
225
|
) });
|
|
225
|
-
},
|
|
226
|
+
}, Ie = me(ke), He = Object.assign(Ie, {
|
|
226
227
|
// Add any sub components here if needed
|
|
227
228
|
});
|
|
228
229
|
export {
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
He as Combobox,
|
|
231
|
+
He as default
|
|
231
232
|
};
|
|
232
233
|
//# sourceMappingURL=component.js.map
|