@bioturing/components 0.28.1 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/components/breadcrumb/style.css +1 -1
  2. package/dist/components/checkbox/style.css +1 -1
  3. package/dist/components/choice-list/component.js +102 -42
  4. package/dist/components/choice-list/component.js.map +1 -1
  5. package/dist/components/choice-list/style.css +1 -1
  6. package/dist/components/color-select/style.css +1 -1
  7. package/dist/components/combobox/component.js +171 -141
  8. package/dist/components/combobox/component.js.map +1 -1
  9. package/dist/components/combobox/style.css +1 -1
  10. package/dist/components/drag-drop/style.css +1 -1
  11. package/dist/components/dropdown-menu/component.js +113 -105
  12. package/dist/components/dropdown-menu/component.js.map +1 -1
  13. package/dist/components/dropdown-menu/item.css +1 -1
  14. package/dist/components/dropdown-menu/style.css +1 -1
  15. package/dist/components/ds-root/component.js +22 -17
  16. package/dist/components/ds-root/component.js.map +1 -1
  17. package/dist/components/ds-root/style.css +1 -1
  18. package/dist/components/form/style.css +1 -1
  19. package/dist/components/modal/style.css +1 -1
  20. package/dist/components/nav/style.css +1 -1
  21. package/dist/components/scroll-area/component.js +70 -24
  22. package/dist/components/scroll-area/component.js.map +1 -1
  23. package/dist/components/scroll-area/style.css +1 -1
  24. package/dist/components/select-trigger/component.js +150 -0
  25. package/dist/components/select-trigger/component.js.map +1 -0
  26. package/dist/components/select-trigger/style.css +1 -0
  27. package/dist/components/switch/style.css +1 -1
  28. package/dist/components/table/style.css +1 -1
  29. package/dist/components/theme-provider/component.js.map +1 -1
  30. package/dist/components/theme-provider/style.css +1 -1
  31. package/dist/components/tour/style.css +1 -1
  32. package/dist/components/utils/WithRenderProp.js.map +1 -1
  33. package/dist/index.d.ts +72 -41
  34. package/dist/index.js +125 -125
  35. package/dist/tokens/and-theme/tokens.js +12 -12
  36. package/dist/tokens/and-theme/tokens.js.map +1 -1
  37. package/package.json +6 -6
  38. package/dist/components/combobox/trigger.js +0 -89
  39. package/dist/components/combobox/trigger.js.map +0 -1
@@ -1 +1 @@
1
- @layer components{.ds-breadcrumb{display:flex}.ds-breadcrumb ol{display:inline-flex;flex:1;min-width:0;gap:.25rem 0}.ds-breadcrumb>ol>li{display:inline-flex;align-items:center;flex:0 1 0;max-width:100%}.ds-breadcrumb>ol>li.ds-breadcrumb-separator{flex:0}.ds-breadcrumb>ol>li .ds-breadcrumb-link{display:inline-flex;align-items:center;flex:0 1 auto;min-width:0;gap:.5rem}.ds-breadcrumb .ds-breadcrumb-item-name{flex:1 1 auto;min-width:0}.ds-breadcrumb .ds-breadcrumb-item-icon{flex:0 0 auto}.ds-breadcrumb.ds-breadcrumb-nowrap{display:flex;align-items:center;flex-grow:1;min-width:0}.ds-breadcrumb.ds-breadcrumb-nowrap ol{flex-wrap:nowrap}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:not(.ds-breadcrumb-separator){flex:0 1 auto;min-width:0;display:flex;transition:all .2s ease}:is(:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:not(.ds-breadcrumb-separator)) span.ds-breadcrumb-link{display:flex;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:not(.ds-breadcrumb-separator){max-width:100%}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:last-child{flex:0 0 auto}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol):hover li:last-child{flex-shrink:1}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:hover{flex-shrink:0}:is(.ds-breadcrumb.ds-breadcrumb-nowrap ol) li:last-child:hover{flex-shrink:0}}
1
+ @layer components{.ds-breadcrumb{display:flex}.ds-breadcrumb ol{display:inline-flex;flex:1;min-width:0;gap:.25rem 0}.ds-breadcrumb>ol>li{display:inline-flex;align-items:center;flex:0 1 0;max-width:100%}.ds-breadcrumb>ol>li.ds-breadcrumb-separator{flex:0}.ds-breadcrumb>ol>li .ds-breadcrumb-link{display:inline-flex;align-items:center;flex:0 1 auto;min-width:0;gap:.5rem}.ds-breadcrumb .ds-breadcrumb-item-name{flex:1 1 auto;min-width:0}.ds-breadcrumb .ds-breadcrumb-item-icon{flex:0 0 auto}.ds-breadcrumb.ds-breadcrumb-nowrap{display:flex;align-items:center;flex-grow:1;min-width:0}.ds-breadcrumb.ds-breadcrumb-nowrap ol{flex-wrap:nowrap}.ds-breadcrumb.ds-breadcrumb-nowrap ol li:not(.ds-breadcrumb-separator){flex:0 1 auto;min-width:0;display:flex;transition:all .2s ease;max-width:100%}.ds-breadcrumb.ds-breadcrumb-nowrap ol li:not(.ds-breadcrumb-separator) span.ds-breadcrumb-link{display:flex;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.ds-breadcrumb.ds-breadcrumb-nowrap ol li:last-child{flex:0 0 auto}.ds-breadcrumb.ds-breadcrumb-nowrap ol:hover li:last-child{flex-shrink:1}.ds-breadcrumb.ds-breadcrumb-nowrap ol li:hover{flex-shrink:0}.ds-breadcrumb.ds-breadcrumb-nowrap ol li:last-child:hover{flex-shrink:0}}
@@ -1 +1 @@
1
- @layer components{:is(.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate) .ds-checkbox-inner{background-color:var(--ds-color-primary);border-color:var(--ds-color-primary)}:is(:is(.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate) .ds-checkbox-inner):after{background-color:var(--ds-color-white);height:.125rem;border-radius:.125rem}:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner{background-color:transparent}.ds-checkbox-checked:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner{background-color:transparent;--ds-color-border: var(--ds-color-primary);border-color:var(--ds-color-border)}:is(.ds-checkbox-checked:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner):hover{--ds-color-border: var(--ds-color-primary-hover);border-color:var(--ds-color-border)}:is(.ds-checkbox-checked:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner):after{border-color:var(--ds-color-primary)}.ds-checkbox-indeterminate:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner{background-color:transparent;--ds-color-border: var(--ds-color-primary)}:is(.ds-checkbox-indeterminate:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox) .ds-checkbox-inner):after{background-color:var(--ds-color-primary)}:is(.ds-checkbox-checked:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox):hover,.ds-checkbox-indeterminate:is(.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox):hover) .ds-checkbox-inner{background-color:transparent;border-color:var( --ds-color-primary-hover, var(--ds-color-primary) )}}
1
+ @layer components{.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate span.ds-checkbox-inner{background:var(--ds-color-primary);border:1px solid var(--ds-color-primary)}.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate span.ds-checkbox-inner:after{background-color:var(--ds-color-white);height:.125rem;border-radius:.125rem}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox .ds-checkbox-inner{background-color:transparent}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-checked .ds-checkbox-inner{background-color:transparent;--ds-color-border: var(--ds-color-primary);border-color:var(--ds-color-border)}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-checked .ds-checkbox-inner:hover{--ds-color-border: var(--ds-color-primary-hover);border-color:var(--ds-color-border)}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-checked .ds-checkbox-inner:after{border-color:var(--ds-color-primary)}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate .ds-checkbox-inner{background-color:transparent;--ds-color-border: var(--ds-color-primary)}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate .ds-checkbox-inner:after{background-color:var(--ds-color-primary)}.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-checked:hover .ds-checkbox-inner,.ds-checkbox-outlined.ds-checkbox-wrapper .ds-checkbox.ds-checkbox-indeterminate:hover .ds-checkbox-inner{background-color:transparent;border-color:var( --ds-color-primary-hover, var(--ds-color-primary) )}}
@@ -1,57 +1,117 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as s } from "react/jsx-runtime";
3
- import { Command as o } from "../cmdk/index.js";
4
- import { useState as I, useMemo as N, useEffect as S } from "react";
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";
5
5
  import './style.css';/* empty css */
6
- import { Radio as k } from "../radio/component.js";
7
- import { useCls as y } from "../utils/antdUtils.js";
8
- import { cn as j } from "../utils/cn.js";
9
- import { Input as C } from "../input/component.js";
10
- import { Checkbox as E } from "../checkbox/component.js";
11
- const F = ({
12
- items: h,
13
- multiple: e,
14
- value: c,
15
- onChange: i,
16
- searchProps: u = { placeholder: "Search..." },
17
- className: p,
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..." },
22
+ showSelectAll: I = !1,
23
+ className: b,
24
+ placeholder: k = "Search",
18
25
  ...x
19
26
  }) => {
20
- const [t, a] = I(
21
- e ? c : [c]
22
- ), l = N(() => typeof c < "u" ? e ? c : [c] : t, [t, e, c]), d = y();
23
- return S(() => {
24
- i && i(e ? t : t[0]);
25
- }, [t, e, i]), /* @__PURE__ */ m(o, { className: j(d("choice-list"), p), ...x, children: [
26
- /* @__PURE__ */ s(
27
- o.Input,
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);
35
+ }
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,
28
42
  {
29
- render: /* @__PURE__ */ s(C, { allowClear: !0, className: d("choice-list-search") }),
30
- ...u
43
+ render: (
44
+ // isolate the input from the form context
45
+ /* @__PURE__ */ c(
46
+ L.Search,
47
+ {
48
+ allowClear: !0,
49
+ className: n("choice-list-search"),
50
+ placeholder: k
51
+ }
52
+ )
53
+ ),
54
+ ...C
31
55
  }
32
- ),
33
- /* @__PURE__ */ m(o.List, { children: [
34
- /* @__PURE__ */ s(o.Empty, { className: d("choice-list-empty"), children: "No results found." }),
35
- h.map((r) => /* @__PURE__ */ s(
36
- o.Item,
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",
37
63
  {
38
- className: d("choice-list-item"),
39
- value: r.value,
40
- "data-in-choice": l.includes(r.value),
41
- onSelect: (n) => {
42
- e ? l.includes(n) ? a(
43
- (f) => f.filter((b) => b !== n)
44
- ) : a((f) => [
45
- .../* @__PURE__ */ new Set([...f, n])
46
- ]) : a([n]);
64
+ className: n("choice-list-item"),
65
+ onClick: () => {
66
+ h || d ? A() : N();
47
67
  },
48
- children: e ? /* @__PURE__ */ s(E, { tabIndex: -1, checked: l.includes(r.value), children: r.label }) : /* @__PURE__ */ s(k, { tabIndex: -1, checked: l.includes(r.value), children: r.label })
68
+ children: /* @__PURE__ */ c(
69
+ p,
70
+ {
71
+ tabIndex: -1,
72
+ checked: d,
73
+ indeterminate: h,
74
+ children: "Select All"
75
+ }
76
+ )
49
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
50
110
  ))
51
- ] })
111
+ ] }) })
52
112
  ] });
53
113
  };
54
114
  export {
55
- F as ChoiceList
115
+ W as ChoiceList
56
116
  };
57
117
  //# 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 { useEffect, useMemo, useState } from \"react\";\nimport { useCls, cn } from \"../utils\";\nimport { Radio } from \"../radio\";\nimport { Checkbox } from \"../checkbox\";\n\nimport \"./style.css\";\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\"> {\n items: ChoiceListItem[];\n multiple?: M;\n value?: M extends true ? string[] : string;\n onChange?: (value: M extends true ? string[] : string) => void;\n searchProps?: React.ComponentProps<typeof Command.Input>;\n}\n\nexport const ChoiceList = <M extends boolean = false>({\n items,\n multiple,\n value,\n onChange,\n searchProps = { placeholder: \"Search...\" },\n className,\n ...rest\n}: ChoiceListProps<M>) => {\n const [selectedValue, setSelectedValue] = useState<string[]>(\n multiple ? (value as string[]) : [value as string]\n );\n const usedValue = useMemo(() => {\n if (typeof value !== \"undefined\") {\n if (multiple) {\n return value as string[];\n } else {\n return [value as string];\n }\n }\n return selectedValue;\n }, [selectedValue, multiple, value]);\n const cls = useCls();\n useEffect(() => {\n if (!onChange) return;\n if (multiple) {\n (onChange as (value: string[]) => void)(selectedValue as string[]);\n } else {\n (onChange as (value: string) => void)(selectedValue[0] as string);\n }\n }, [selectedValue, multiple, onChange]);\n\n return (\n <Command className={cn(cls(\"choice-list\"), className)} {...rest}>\n <Command.Input\n render={<Input allowClear className={cls(\"choice-list-search\")} />}\n {...searchProps}\n />\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 className={cls(\"choice-list-item\")}\n value={item.value}\n data-in-choice={usedValue.includes(item.value)}\n onSelect={(newValue) => {\n if (multiple) {\n if (usedValue.includes(newValue)) {\n setSelectedValue((prev: string[]) =>\n prev.filter((value) => value !== newValue)\n );\n } else {\n setSelectedValue((prev: string[]) => [\n ...new Set([...prev, newValue]),\n ]);\n }\n } else {\n setSelectedValue([newValue]);\n }\n }}\n >\n {multiple ? (\n <Checkbox tabIndex={-1} checked={usedValue.includes(item.value)}>\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 </Command>\n );\n};\n"],"names":["ChoiceList","items","multiple","value","onChange","searchProps","className","rest","selectedValue","setSelectedValue","useState","usedValue","useMemo","cls","useCls","useEffect","jsxs","Command","cn","jsx","Input","item","newValue","prev","Checkbox","Radio"],"mappings":";;;;;;;;;;AAwBO,MAAMA,IAAa,CAA4B;AAAA,EACpD,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc,EAAE,aAAa,YAAY;AAAA,EACzC,WAAAC;AAAA,EACA,GAAGC;AACL,MAA0B;AAClB,QAAA,CAACC,GAAeC,CAAgB,IAAIC;AAAA,IACxCR,IAAYC,IAAqB,CAACA,CAAe;AAAA,EACnD,GACMQ,IAAYC,EAAQ,MACpB,OAAOT,IAAU,MACfD,IACKC,IAEA,CAACA,CAAe,IAGpBK,GACN,CAACA,GAAeN,GAAUC,CAAK,CAAC,GAC7BU,IAAMC,EAAO;AACnB,SAAAC,EAAU,MAAM;AACd,IAAKX,KAEFA,EADCF,IACsCM,IAEFA,EAAc,CAAC,CAFY;AAAA,EAIlE,GAAA,CAACA,GAAeN,GAAUE,CAAQ,CAAC,GAGpC,gBAAAY,EAACC,GAAQ,EAAA,WAAWC,EAAGL,EAAI,aAAa,GAAGP,CAAS,GAAI,GAAGC,GACzD,UAAA;AAAA,IAAA,gBAAAY;AAAA,MAACF,EAAQ;AAAA,MAAR;AAAA,QACC,0BAASG,GAAM,EAAA,YAAU,IAAC,WAAWP,EAAI,oBAAoB,GAAG;AAAA,QAC/D,GAAGR;AAAA,MAAA;AAAA,IACN;AAAA,IACA,gBAAAW,EAACC,EAAQ,MAAR,EACC,UAAA;AAAA,MAAA,gBAAAE,EAACF,EAAQ,OAAR,EAAc,WAAWJ,EAAI,mBAAmB,GAAG,UAEpD,qBAAA;AAAA,MACCZ,EAAM,IAAI,CAACoB,MACV,gBAAAF;AAAA,QAACF,EAAQ;AAAA,QAAR;AAAA,UACC,WAAWJ,EAAI,kBAAkB;AAAA,UACjC,OAAOQ,EAAK;AAAA,UACZ,kBAAgBV,EAAU,SAASU,EAAK,KAAK;AAAA,UAC7C,UAAU,CAACC,MAAa;AACtB,YAAIpB,IACES,EAAU,SAASW,CAAQ,IAC7Bb;AAAA,cAAiB,CAACc,MAChBA,EAAK,OAAO,CAACpB,MAAUA,MAAUmB,CAAQ;AAAA,YAC3C,IAEAb,EAAiB,CAACc,MAAmB;AAAA,cACnC,GAAO,oBAAA,IAAI,CAAC,GAAGA,GAAMD,CAAQ,CAAC;AAAA,YAAA,CAC/B,IAGcb,EAAA,CAACa,CAAQ,CAAC;AAAA,UAE/B;AAAA,UAEC,UAAApB,IACE,gBAAAiB,EAAAK,GAAA,EAAS,UAAU,IAAI,SAASb,EAAU,SAASU,EAAK,KAAK,GAC3D,UAAAA,EAAK,MACR,CAAA,IAEA,gBAAAF,EAACM,GAAM,EAAA,UAAU,IAAI,SAASd,EAAU,SAASU,EAAK,KAAK,GACxD,UAAAA,EAAK,MACR,CAAA;AAAA,QAAA;AAAA,MAGL,CAAA;AAAA,IAAA,EACH,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 } 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":"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"}
@@ -1 +1 @@
1
- @layer components{.ds-choice-list{display:flex;flex-direction:column}.ds-choice-list-search{flex:1;margin-bottom:.25rem}.ds-choice-list-item{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center}.ds-choice-list-item:focus{outline:none}.ds-choice-list-item:hover{background:var(--ds-control-item-bg-hover)}.ds-choice-list-item:active,.ds-choice-list-item:focus,.ds-choice-list-item[data-focus=true],.ds-choice-list-item[data-selected=true]{background:var(--ds-control-item-bg-active)}.ds-choice-list-item[data-disabled=true]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-choice-list-item[data-danger=true]{color:var(--ds-color-error)}.ds-choice-list-item[data-danger=true]:hover{background:var(--ds-color-error-bg)}.ds-choice-list-item[data-danger=true]:active,.ds-choice-list-item[data-danger=true]:focus,.ds-choice-list-item[data-danger=true][data-focus=true]{background:var(--ds-color-error-bg-hover)}.ds-choice-list-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}}
1
+ @layer components{.ds-choice-list{display:flex;flex-direction:column}.ds-choice-list-search{flex-grow:0;margin-bottom:.25rem;flex-shrink:0}.ds-choice-list-list{flex-grow:1;flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-choice-list-item{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center}.ds-choice-list-item:focus{outline:none}.ds-choice-list-item:hover{background:var(--ds-control-item-bg-hover)}.ds-choice-list-item:active,.ds-choice-list-item:focus,.ds-choice-list-item[data-focus=true],.ds-choice-list-item[data-selected=true]{background:var(--ds-control-item-bg-active)}.ds-choice-list-item[data-disabled=true]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-choice-list-item[data-danger=true]{color:var(--ds-color-error)}.ds-choice-list-item[data-danger=true]:hover{background:var(--ds-color-error-bg)}.ds-choice-list-item[data-danger=true]:active,.ds-choice-list-item[data-danger=true]:focus,.ds-choice-list-item[data-danger=true][data-focus=true]{background:var(--ds-color-error-bg-hover)}.ds-choice-list-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}}
@@ -1 +1 @@
1
- @layer components{.ds-color-select{border-color:var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.25rem;background:var(--ds-color-bg-container);border-width:var(--ds-line-width);border-style:var(--ds-line-type);transition:all var(--ds-motion-duration-mid)}.ds-color-select[data-focus=true]{border-color:var(--ds-input-color-border-active);box-shadow:var(--ds-input-shadow-active);outline:0;background-color:var(--ds-input-active-bg)}.ds-color-select .ds-tag{margin-right:0}.ds-color-select-option{display:flex;align-items:center;gap:.5rem}.ds-color-select-tag{display:flex;align-items:center}.ds-color-select-swatch{width:16px;height:16px;border-radius:9999px;border:1px solid var(--ds-color-border);flex-shrink:0}.ds-color-select-input{outline:none;border:none;background:transparent;color:var(--ds-color-text);font-size:var(--ds-font-size);font-family:var(--ds-font-family);line-height:var(--ds-line-height);flex:1;min-width:11rem;width:100%;margin-left:.25rem}.ds-color-select-input:first-child{margin-left:.7rem}}
1
+ @layer components{.ds-color-select{border-color:var(--ds-color-border);border-radius:var(--ds-border-radius);padding:.25rem;background:var(--ds-color-bg-container);border-width:var(--ds-line-width);border-style:var(--ds-line-type);transition:all var(--ds-motion-duration-mid)}.ds-color-select[data-focus=true]{border-color:var(--ds-input-color-border-active);box-shadow:var(--ds-control-shadow-active);outline:0;background-color:var(--ds-input-active-bg)}.ds-color-select .ds-tag{margin-right:0}.ds-color-select-option{display:flex;align-items:center;gap:.5rem}.ds-color-select-tag{display:flex;align-items:center}.ds-color-select-swatch{width:16px;height:16px;border-radius:9999px;border:1px solid var(--ds-color-border);flex-shrink:0}.ds-color-select-input{outline:none;border:none;background:transparent;color:var(--ds-color-text);font-size:var(--ds-font-size);font-family:var(--ds-font-family);line-height:var(--ds-line-height);flex:1;min-width:11rem;width:100%;margin-left:.25rem}.ds-color-select-input:first-child{margin-left:.7rem}}
@@ -1,202 +1,232 @@
1
1
  "use client";
2
- import { jsxs as re, Fragment as oe, jsx as m } from "react/jsx-runtime";
3
- import { forwardRef as le, useState as R, useCallback as s, useMemo as I } from "react";
4
- import { useControlled as ne } from "@base-ui-components/utils/useControlled";
5
- import { ComboboxTrigger as se } from "./trigger.js";
2
+ import { jsxs as ce, Fragment as ue, jsx as p } from "react/jsx-runtime";
3
+ import { forwardRef as fe, useState as _, useContext as K, useCallback as i, useMemo as x } from "react";
4
+ import { useControlled as be } from "@base-ui-components/utils/useControlled";
5
+ import { FormItemInputContext as me } from "antd/es/form/context";
6
+ import pe from "antd/es/config-provider/DisabledContext";
6
7
  import './style.css';/* empty css */
7
- import { DropdownMenuDivider as ce } from "../dropdown-menu/divider.js";
8
- import { DropdownMenuItem as ae } from "../dropdown-menu/item.js";
9
- import { DropdownMenu as de } from "../dropdown-menu/component.js";
10
- import { useControlledState as ie } from "../hooks/useControlledState.js";
11
- import { useCls as fe } from "../utils/antdUtils.js";
12
- import { clsx as b } from "../utils/cn.js";
13
- const ue = ({
8
+ import { DropdownMenuDivider as xe } from "../dropdown-menu/divider.js";
9
+ import { DropdownMenuItem as ye } from "../dropdown-menu/item.js";
10
+ import { DropdownMenu as ge } from "../dropdown-menu/component.js";
11
+ import { SelectTrigger as ve } from "../select-trigger/component.js";
12
+ import { useControlledState as he } from "../hooks/useControlledState.js";
13
+ import { useCls as Ce } from "../utils/antdUtils.js";
14
+ import { clsx as y } from "../utils/cn.js";
15
+ const Ae = ({
14
16
  options: g = [],
15
- value: j,
17
+ value: R,
16
18
  defaultValue: w,
17
- onChange: p,
18
- placeholder: F = "Select...",
19
- disabled: D = !1,
20
- allowClear: T = !1,
19
+ onChange: v,
20
+ placeholder: $ = "Select...",
21
+ disabled: B = !1,
22
+ status: E,
23
+ allowClear: S = !1,
21
24
  multiple: t = !1,
22
- maxTagCount: be,
23
- showSearch: c = !0,
24
- open: _,
25
- onOpenChange: K,
26
- placement: S = "bottomLeft",
27
- className: B,
25
+ maxTagCount: ke,
26
+ showSearch: d = !0,
27
+ open: W,
28
+ onOpenChange: q,
29
+ placement: z = "bottomLeft",
30
+ className: G,
28
31
  classNames: a,
29
- size: E = "middle",
30
- loading: ge = !1,
31
- optionRender: pe,
32
- filterOption: v = !0,
33
- onSearch: x,
34
- dropdownRender: ve,
35
- clearIcon: P,
36
- suffixIcon: W,
37
- dropdownMenuProps: q,
38
- triggerProps: z,
39
- searchProps: G,
40
- showSelectionSummary: H = !1,
41
- selectionSummaryRender: J,
42
- showSelectAll: M = !1,
43
- selectAllRender: xe,
44
- ...Q
45
- }, U) => {
46
- const [X] = R(
32
+ size: H = "middle",
33
+ loading: Ie = !1,
34
+ optionRender: De,
35
+ filterOption: h = !0,
36
+ onSearch: C,
37
+ dropdownRender: Me,
38
+ clearIcon: J,
39
+ suffixIcon: Q,
40
+ dropdownMenuProps: U,
41
+ triggerProps: A,
42
+ searchProps: X,
43
+ showSelectionSummary: F = !1,
44
+ selectionSummaryRender: V,
45
+ showSelectAll: L = !1,
46
+ selectAllRender: we,
47
+ ...Y
48
+ }, Z) => {
49
+ const [N] = _(
47
50
  w !== void 0 ? w : t ? [] : void 0
48
- ), [r, O] = ne({
49
- controlled: j,
50
- default: X,
51
+ ), [l, O] = be({
52
+ controlled: R,
53
+ default: N,
51
54
  name: "value"
52
- }), [V, Y] = ie(
53
- _,
54
- K,
55
+ }), [T, j] = he(
56
+ W,
57
+ q,
55
58
  !1
56
- ), [d, Z] = R(""), i = fe(), n = s(
59
+ ), [c, ee] = _(""), u = Ce(), {
60
+ status: te
61
+ // hasFeedback,
62
+ // feedbackIcon,
63
+ } = K(me), le = K(pe), re = E || te, oe = B || le, n = i(
57
64
  (e) => {
58
- O(e), p == null || p(e);
65
+ O(e), v == null || v(e);
59
66
  },
60
- [O, p]
61
- ), L = s(
67
+ [O, v]
68
+ ), P = i(
62
69
  (e) => {
63
70
  if (t) {
64
- const l = Array.isArray(r) ? r : [], f = l.includes(e) ? l.filter((u) => u !== e) : [...l, e];
65
- n(f);
71
+ const r = Array.isArray(l) ? l : [], b = r.includes(e) ? r.filter((m) => m !== e) : [...r, e];
72
+ n(b);
66
73
  } else
67
74
  n(e);
68
75
  },
69
- [t, r, n]
70
- ), $ = s(
76
+ [t, l, n]
77
+ ), ne = i(
71
78
  (e) => {
72
- Z(e), x == null || x(e);
79
+ ee(e), C == null || C(e);
73
80
  },
74
- [x]
81
+ [C]
75
82
  );
76
- s(
77
- (e) => t ? Array.isArray(r) && r.includes(e) : r === e,
78
- [t, r]
83
+ i(
84
+ (e) => t ? Array.isArray(l) && l.includes(e) : l === e,
85
+ [t, l]
79
86
  );
80
- const o = I(() => !c || !d ? g : g.filter((e) => typeof v == "function" ? v(d, e) : v === !1 ? !0 : (typeof e.label == "string" ? e.label : String(e.value)).toLowerCase().includes(d.toLowerCase())), [g, c, d, v]), y = s(() => {
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(() => {
81
88
  if (t) {
82
- const e = o.map((l) => l.value);
89
+ const e = o.map((r) => r.value);
83
90
  n(e);
84
91
  }
85
- }, [t, o, n]), C = s(() => {
92
+ }, [t, o, n]), I = i(() => {
86
93
  t && n([]);
87
- }, [t, n]), N = I(() => o.map((e) => ({
94
+ }, [t, n]), se = x(() => o.map((e) => ({
88
95
  type: "item",
89
96
  key: e.value,
90
97
  icon: e.icon,
91
98
  label: e.label,
92
99
  disabled: e.disabled,
93
- onClick: () => !e.disabled && L(e.value)
94
- })), [o, L]), ee = I(() => {
95
- if (!M || !t || o.length === 0)
100
+ onClick: () => !e.disabled && P(e.value)
101
+ })), [o, P]), ae = x(() => {
102
+ if (!L || !t || o.length === 0)
96
103
  return null;
97
- const e = Array.isArray(r) ? r : [], l = o.map((k) => k.value), f = e.filter(
98
- (k) => l.includes(k)
99
- ), u = f.length === o.length && o.length > 0, A = f.length > 0 && f.length < o.length;
100
- return /* @__PURE__ */ re(oe, { children: [
101
- /* @__PURE__ */ m(
102
- ae,
104
+ const e = Array.isArray(l) ? l : [], r = o.map((M) => M.value), b = e.filter(
105
+ (M) => r.includes(M)
106
+ ), m = b.length === o.length && o.length > 0, D = b.length > 0 && b.length < o.length;
107
+ return /* @__PURE__ */ ce(ue, { children: [
108
+ /* @__PURE__ */ p(
109
+ ye,
103
110
  {
104
111
  item: {
105
112
  type: "item",
106
113
  key: "select_all",
107
114
  label: "Select All",
108
115
  onClick: () => {
109
- A || u ? C() : y();
116
+ D || m ? I() : k();
110
117
  }
111
118
  },
112
- inCombobox: c,
113
- selected: u,
119
+ inCombobox: d,
120
+ selected: m,
114
121
  showCheckbox: !0,
115
- indeterminate: A,
122
+ indeterminate: D,
116
123
  renderAsNativeElement: !0,
117
124
  onSelect: () => {
118
- A || u ? C() : y();
125
+ D || m ? I() : k();
119
126
  }
120
127
  },
121
128
  "select_all"
122
129
  ),
123
- /* @__PURE__ */ m(ce, {})
130
+ /* @__PURE__ */ p(xe, {})
124
131
  ] });
125
132
  }, [
126
- M,
133
+ L,
127
134
  t,
128
135
  o,
129
- r,
130
- c,
131
- C,
132
- y
133
- ]), h = Array.isArray(r) ? r : r ? [r] : [], te = h.map((e) => g.find((l) => l.value === e)).filter(Boolean);
134
- return /* @__PURE__ */ m(
135
- "div",
136
+ l,
137
+ d,
138
+ I,
139
+ k
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(() => {
141
+ if (s.length === 0)
142
+ return { displayValue: void 0, displayPrefix: void 0 };
143
+ if (t) {
144
+ const r = `${s.length} ${s.length === 1 ? "item" : "items"} selected`;
145
+ return F ? V ? {
146
+ displayValue: V(f),
147
+ displayPrefix: void 0
148
+ } : {
149
+ displayValue: r,
150
+ // TODO: Create icon component for multiple selection summary
151
+ displayPrefix: void 0
152
+ } : s.length === 1 ? {
153
+ displayValue: s[0].label,
154
+ displayPrefix: s[0].icon
155
+ } : {
156
+ displayValue: r,
157
+ displayPrefix: void 0
158
+ };
159
+ }
160
+ const e = s[0];
161
+ return {
162
+ displayValue: e == null ? void 0 : e.label,
163
+ displayPrefix: e == null ? void 0 : e.icon
164
+ };
165
+ }, [
166
+ s,
167
+ t,
168
+ F,
169
+ V,
170
+ f
171
+ ]);
172
+ return /* @__PURE__ */ p("div", { ref: Z, className: y(u("combobox"), G), ...Y, children: /* @__PURE__ */ p(
173
+ ge,
136
174
  {
137
- ref: U,
138
- className: b(
139
- i("combobox"),
140
- B,
141
- D && "pointer-events-none opacity-50"
142
- ),
143
- ...Q,
144
- children: /* @__PURE__ */ m(
145
- de,
175
+ items: se,
176
+ open: T,
177
+ onOpenChange: j,
178
+ placement: z,
179
+ showSearch: d,
180
+ searchProps: {
181
+ placeholder: "Search options...",
182
+ onValueChange: ne,
183
+ value: c,
184
+ ...X
185
+ },
186
+ className: y(u("combobox-dropdown")),
187
+ classNames: {
188
+ trigger: y(u("combobox-trigger-wrapper")),
189
+ popup: y(u("combobox-popup")),
190
+ item: y(u("combobox-option"), a == null ? void 0 : a.option),
191
+ ...a
192
+ },
193
+ popupMatchTriggerWidth: !0,
194
+ keepOpenOnSelect: t,
195
+ highlightedItemKey: t ? void 0 : f[0],
196
+ showCheckbox: t,
197
+ beforeList: ae,
198
+ selectedItemKeys: f,
199
+ ...U,
200
+ children: /* @__PURE__ */ p(
201
+ ve,
146
202
  {
147
- items: N,
148
- open: V,
149
- onOpenChange: Y,
150
- placement: S,
151
- showSearch: c,
152
- searchProps: {
153
- placeholder: "Search options...",
154
- onValueChange: $,
155
- value: d,
156
- ...G
157
- },
158
- className: b(i("combobox-dropdown")),
203
+ value: ie,
204
+ prefix: de,
205
+ placeholder: $,
206
+ disabled: oe,
207
+ status: re,
208
+ open: T,
209
+ size: H,
210
+ allowClear: S,
211
+ suffixIcon: Q,
212
+ clearIcon: J,
159
213
  classNames: {
160
- trigger: b(i("combobox-trigger-wrapper")),
161
- popup: b(i("combobox-popup")),
162
- item: b(i("combobox-option"), a == null ? void 0 : a.option),
163
- ...a
214
+ trigger: a == null ? void 0 : a.trigger,
215
+ ...A == null ? void 0 : A.classNames
164
216
  },
165
- popupMatchTriggerWidth: !0,
166
- keepOpenOnSelect: t,
167
- highlightedItemKey: t ? void 0 : h[0],
168
- showCheckbox: t,
169
- beforeList: ee,
170
- selectedItemKeys: h,
171
- ...q,
172
- children: /* @__PURE__ */ m(
173
- se,
174
- {
175
- selectedOptions: te,
176
- placeholder: F,
177
- multiple: t,
178
- disabled: D,
179
- open: V,
180
- size: E,
181
- allowClear: T,
182
- suffixIcon: W,
183
- clearIcon: P,
184
- classNames: a,
185
- onClear: () => n(t ? [] : void 0),
186
- showSelectionSummary: H,
187
- selectionSummaryRender: J,
188
- ...z
189
- }
190
- )
217
+ onClear: () => n(t ? [] : void 0),
218
+ onOpenChange: j,
219
+ role: "combobox",
220
+ ...A
191
221
  }
192
222
  )
193
223
  }
194
- );
195
- }, me = le(ue), Re = Object.assign(me, {
224
+ ) });
225
+ }, Ve = fe(Ae), qe = Object.assign(Ve, {
196
226
  // Add any sub components here if needed
197
227
  });
198
228
  export {
199
- Re as Combobox,
200
- Re as default
229
+ qe as Combobox,
230
+ qe as default
201
231
  };
202
232
  //# sourceMappingURL=component.js.map