@pibit.ai/cure-design-system 0.3.20 → 0.3.23

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 (61) hide show
  1. package/README.md +1 -0
  2. package/dist/applications/schedule-calendar/schedule-calendar.d.ts.map +1 -1
  3. package/dist/applications/schedule-calendar/schedule-calendar.js +24 -22
  4. package/dist/applications/schedule-calendar/utils.d.ts +13 -3
  5. package/dist/applications/schedule-calendar/utils.d.ts.map +1 -1
  6. package/dist/applications/schedule-calendar/utils.js +136 -117
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +92 -88
  10. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  11. package/dist/patterns/table/TableWrapper.js +784 -665
  12. package/dist/patterns/table/index.d.ts +1 -1
  13. package/dist/patterns/table/index.d.ts.map +1 -1
  14. package/dist/patterns/table/storyHelpers/useMockTableState.d.ts.map +1 -1
  15. package/dist/patterns/table/table.d.ts.map +1 -1
  16. package/dist/patterns/table/table.js +44 -43
  17. package/dist/patterns/table/toolbar/AlignDropdown.d.ts.map +1 -1
  18. package/dist/patterns/table/toolbar/AlignDropdown.js +19 -25
  19. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts +9 -0
  20. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts.map +1 -1
  21. package/dist/patterns/table/toolbar/ColumnHeaderMenu.js +115 -81
  22. package/dist/patterns/table/toolbar/GroupByDropdown.d.ts.map +1 -1
  23. package/dist/patterns/table/toolbar/GroupByDropdown.js +48 -43
  24. package/dist/patterns/table/toolbar/SummaryFooter.d.ts.map +1 -1
  25. package/dist/patterns/table/toolbar/SummaryFooter.js +34 -27
  26. package/dist/patterns/table/toolbar/TableToolbar.d.ts +2 -0
  27. package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
  28. package/dist/patterns/table/toolbar/TableToolbar.js +2 -1
  29. package/dist/patterns/table/toolbar/index.d.ts +2 -2
  30. package/dist/patterns/table/toolbar/index.d.ts.map +1 -1
  31. package/dist/patterns/table/toolbar/tableToolbarHelpers.d.ts +10 -1
  32. package/dist/patterns/table/toolbar/tableToolbarHelpers.d.ts.map +1 -1
  33. package/dist/patterns/table/toolbar/tableToolbarHelpers.js +117 -117
  34. package/dist/patterns/table/types.d.ts +1 -0
  35. package/dist/patterns/table/types.d.ts.map +1 -1
  36. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts +20 -0
  37. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts.map +1 -0
  38. package/dist/primitives/multi-chips-select/MultiChipsSelect.js +233 -0
  39. package/dist/primitives/multi-chips-select/index.d.ts +3 -0
  40. package/dist/primitives/multi-chips-select/index.d.ts.map +1 -0
  41. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts +3 -0
  42. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts.map +1 -0
  43. package/dist/primitives/multi-chips-select/tagKeyFromLabel.js +6 -0
  44. package/dist/primitives/select/ExpandableSearchInput.d.ts +3 -1
  45. package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
  46. package/dist/primitives/select/ExpandableSearchInput.js +100 -78
  47. package/dist/primitives/select/SearchInput.d.ts +5 -1
  48. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  49. package/dist/primitives/select/SearchInput.js +94 -74
  50. package/dist/primitives/select/searchable-select.d.ts +5 -3
  51. package/dist/primitives/select/searchable-select.d.ts.map +1 -1
  52. package/dist/primitives/select/searchable-select.js +196 -177
  53. package/dist/primitives/select/select-item.d.ts.map +1 -1
  54. package/dist/primitives/select/select-item.js +70 -54
  55. package/dist/primitives/select/select.d.ts +7 -2
  56. package/dist/primitives/select/select.d.ts.map +1 -1
  57. package/dist/primitives/select/select.js +161 -137
  58. package/dist/primitives/tooltip/ellipsis-content.d.ts.map +1 -1
  59. package/dist/primitives/tooltip/ellipsis-content.js +46 -43
  60. package/dist/styles/components.css +1 -1
  61. package/package.json +1 -1
@@ -1,104 +1,104 @@
1
- import { jsx as e, jsxs as u, Fragment as P } from "react/jsx-runtime";
2
- import { useState as V, useCallback as S, isValidElement as q } from "react";
3
- import { ChevronDown as U } from "@untitledui/icons";
4
- import { Select as z, ListBox as B, Button as O, SelectValue as R } from "react-aria-components";
5
- import { Avatar as _ } from "../avatar/avatar.js";
6
- import { HintText as A } from "../input/hint-text.js";
7
- import { Label as E } from "../input/label.js";
8
- import { Popover as F } from "./popover.js";
9
- import { SelectItem as H } from "./select-item.js";
10
- import { SelectContext as K, fontSizes as I, sizes as L } from "./select.js";
11
- import { cx as a } from "../../utils/cn.js";
12
- import { isReactComponent as M } from "../../utils/is-react-component.js";
13
- import G from "./SearchInput.js";
14
- import { LoadingIndicator as J } from "../../applications/loading-indicator/loading-indicator.js";
15
- const Q = {
1
+ import { jsx as t, jsxs as f, Fragment as q } from "react/jsx-runtime";
2
+ import { useState as M, useRef as _, useCallback as w, isValidElement as A } from "react";
3
+ import { ChevronDown as C } from "@untitledui/icons";
4
+ import { Select as E, ListBox as F, Button as H, SelectValue as L } from "react-aria-components";
5
+ import { Avatar as D } from "../avatar/avatar.js";
6
+ import { HintText as G } from "../input/hint-text.js";
7
+ import { Label as J } from "../input/label.js";
8
+ import { Popover as Q } from "./popover.js";
9
+ import { SelectItem as W } from "./select-item.js";
10
+ import { SelectContext as X, fontSizes as S, sizes as Y } from "./select.js";
11
+ import { cx as s } from "../../utils/cn.js";
12
+ import { isReactComponent as Z } from "../../utils/is-react-component.js";
13
+ import $ from "./SearchInput.js";
14
+ import { LoadingIndicator as ee } from "../../applications/loading-indicator/loading-indicator.js";
15
+ const te = {
16
16
  sm: "rounded-md",
17
17
  md: "rounded-md",
18
18
  lg: "rounded-lg"
19
- }, W = {
19
+ }, re = {
20
20
  sm: "text-xs",
21
21
  md: "text-xs",
22
22
  lg: "text-sm"
23
- }, X = "relative flex w-full cursor-pointer items-center bg-primary ring-1 ring-secondary outline-hidden transition duration-100 ease-linear ring-inset", Y = ({
24
- isOpen: N,
25
- isFocused: v,
26
- isDisabled: o,
27
- size: r,
28
- placeholder: f,
23
+ }, le = "relative flex w-full cursor-pointer items-center bg-primary ring-1 ring-secondary outline-hidden transition duration-100 ease-linear ring-inset", ne = ({
24
+ isOpen: P,
25
+ isFocused: R,
26
+ isDisabled: i,
27
+ size: l,
28
+ placeholder: x,
29
29
  placeholderIcon: h,
30
- textStyles: x,
31
- selectedDisplayValue: c
32
- }) => /* @__PURE__ */ e(
33
- O,
30
+ textStyles: g,
31
+ selectedDisplayValue: d
32
+ }) => /* @__PURE__ */ t(
33
+ H,
34
34
  {
35
- className: a(
36
- X,
37
- Q[r],
38
- (v || N) && "ring-1 ring-brand",
39
- o && "cursor-not-allowed bg-disabled_subtle text-disabled"
35
+ className: s(
36
+ le,
37
+ te[l],
38
+ (R || P) && "ring-1 ring-brand",
39
+ i && "cursor-not-allowed bg-disabled_subtle text-disabled"
40
40
  ),
41
- children: /* @__PURE__ */ e(
42
- R,
41
+ children: /* @__PURE__ */ t(
42
+ L,
43
43
  {
44
- className: a(
44
+ className: s(
45
45
  "flex h-max w-full items-center justify-start gap-2 truncate text-left align-middle",
46
46
  "*:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:text-fg-quaternary in-disabled:*:data-icon:text-fg-disabled",
47
- L[r].root
47
+ Y[l].root
48
48
  ),
49
49
  children: (n) => {
50
- var p, g, b, i, y;
51
- const d = ((p = n.selectedItem) == null ? void 0 : p.icon) || h, s = !!n.selectedItem, m = !s && !!c;
52
- return /* @__PURE__ */ u(P, { children: [
53
- (g = n.selectedItem) != null && g.avatarUrl ? /* @__PURE__ */ e(
54
- _,
50
+ var u, o, y, v, I;
51
+ const m = ((u = n.selectedItem) == null ? void 0 : u.icon) || h, c = !!n.selectedItem, a = !c && !!d;
52
+ return /* @__PURE__ */ f(q, { children: [
53
+ (o = n.selectedItem) != null && o.avatarUrl ? /* @__PURE__ */ t(
54
+ D,
55
55
  {
56
56
  size: "sm",
57
57
  src: n.selectedItem.avatarUrl,
58
58
  alt: n.selectedItem.label
59
59
  }
60
- ) : M(d) ? /* @__PURE__ */ e(d, { "data-icon": !0, "aria-hidden": "true" }) : q(d) ? d : null,
61
- s ? /* @__PURE__ */ u("section", { className: "flex w-full gap-2 truncate", children: [
62
- /* @__PURE__ */ e(
60
+ ) : Z(m) ? /* @__PURE__ */ t(m, { "data-icon": !0, "aria-hidden": "true" }) : A(m) ? m : null,
61
+ c ? /* @__PURE__ */ f("section", { className: "flex w-full gap-2 truncate", children: [
62
+ /* @__PURE__ */ t(
63
63
  "p",
64
64
  {
65
- className: a(
65
+ className: s(
66
66
  "truncate font-medium text-primary",
67
- I[r],
68
- x
67
+ S[l],
68
+ g
69
69
  ),
70
- children: (b = n.selectedItem) == null ? void 0 : b.label
70
+ children: (y = n.selectedItem) == null ? void 0 : y.label
71
71
  }
72
72
  ),
73
- ((i = n.selectedItem) == null ? void 0 : i.supportingText) && /* @__PURE__ */ e("p", { className: a("text-tertiary", I[r]), children: (y = n.selectedItem) == null ? void 0 : y.supportingText })
74
- ] }) : m ? /* @__PURE__ */ e("section", { className: "flex w-full gap-2 truncate", children: /* @__PURE__ */ e(
73
+ ((v = n.selectedItem) == null ? void 0 : v.supportingText) && /* @__PURE__ */ t("p", { className: s("text-tertiary", S[l]), children: (I = n.selectedItem) == null ? void 0 : I.supportingText })
74
+ ] }) : a ? /* @__PURE__ */ t("section", { className: "flex w-full gap-2 truncate", children: /* @__PURE__ */ t(
75
75
  "p",
76
76
  {
77
- className: a(
77
+ className: s(
78
78
  "truncate font-medium text-primary",
79
- I[r],
80
- x
79
+ S[l],
80
+ g
81
81
  ),
82
- children: c
82
+ children: d
83
83
  }
84
- ) }) : /* @__PURE__ */ e(
84
+ ) }) : /* @__PURE__ */ t(
85
85
  "p",
86
86
  {
87
- className: a(
87
+ className: s(
88
88
  "text-placeholder_subtle",
89
- I[r],
90
- o && "text-disabled"
89
+ S[l],
90
+ i && "text-disabled"
91
91
  ),
92
- children: f
92
+ children: x
93
93
  }
94
94
  ),
95
- /* @__PURE__ */ e(
96
- U,
95
+ /* @__PURE__ */ t(
96
+ C,
97
97
  {
98
98
  "aria-hidden": "true",
99
- className: a(
99
+ className: s(
100
100
  "ml-auto shrink-0 text-fg-quaternary",
101
- r === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
101
+ l === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
102
102
  )
103
103
  }
104
104
  )
@@ -107,133 +107,152 @@ const Q = {
107
107
  }
108
108
  )
109
109
  }
110
- ), pe = ({
111
- placeholder: N = "Select",
112
- placeholderIcon: v,
113
- size: o = "sm",
114
- items: r,
115
- label: f,
110
+ ), ve = ({
111
+ placeholder: P = "Select",
112
+ placeholderIcon: R,
113
+ size: i = "sm",
114
+ items: l,
115
+ label: x,
116
116
  hint: h,
117
- tooltip: x,
118
- className: c,
117
+ tooltip: g,
118
+ className: d,
119
119
  textStyles: n,
120
- popoverClassName: d,
121
- onSearchChange: s,
122
- onSelectionChange: m,
123
- isLoading: p = !1,
124
- searchPlaceholder: g = "Search...",
125
- selectedDisplayValue: b,
126
- ...i
120
+ popoverClassName: m,
121
+ onSearchChange: c,
122
+ onSelectionChange: a,
123
+ isLoading: u = !1,
124
+ isDeselectable: o = !1,
125
+ searchPlaceholder: y = "Search...",
126
+ selectedDisplayValue: v,
127
+ ...I
127
128
  }) => {
128
- const [y, w] = V(""), T = S(
129
- (l) => {
130
- w(l), s(l);
129
+ const [K, k] = M(""), T = _(!1), { selectedKey: N, ...p } = I, b = N === void 0 ? void 0 : N == null || String(N) === "" ? null : N, V = w(
130
+ (r) => {
131
+ k(r), c(r);
131
132
  },
132
- [s]
133
- ), j = S(
134
- (l) => {
135
- var t;
136
- l || (w(""), s("")), (t = i.onOpenChange) == null || t.call(i, l);
133
+ [c]
134
+ ), j = w(
135
+ (r) => {
136
+ var e;
137
+ r || (k(""), c("")), (e = p.onOpenChange) == null || e.call(p, r);
137
138
  },
138
- [s, i.onOpenChange]
139
- ), k = S(
140
- (l) => {
141
- l !== null && (m == null || m(String(l)));
139
+ [p.onOpenChange, c]
140
+ ), U = w(() => {
141
+ !o || b == null || (T.current = !0, a == null || a(null), j(!1), queueMicrotask(() => {
142
+ T.current = !1;
143
+ }));
144
+ }, [j, o, a, b]), z = w(
145
+ (r) => {
146
+ if (T.current) return;
147
+ const e = r == null || String(r) === "" ? null : String(r);
148
+ e === null && !o || a == null || a(e);
142
149
  },
143
- [m]
144
- ), C = [{ id: "none", label: "none" }], D = r.length > 0 ? r : C;
145
- return /* @__PURE__ */ e(K.Provider, { value: { size: o }, children: /* @__PURE__ */ e(
146
- z,
150
+ [o, a]
151
+ ), B = [{ id: "none", label: "none" }], O = l.length > 0 ? l : B;
152
+ return /* @__PURE__ */ t(
153
+ X.Provider,
147
154
  {
148
- ...i,
149
- onOpenChange: j,
150
- onSelectionChange: k,
151
- className: (l) => a(
152
- "flex flex-col gap-1.5",
153
- typeof c == "function" ? c(l) : c
154
- ),
155
- children: (l) => /* @__PURE__ */ u(P, { children: [
156
- f && /* @__PURE__ */ e(
157
- E,
158
- {
159
- isRequired: l.isRequired,
160
- tooltip: x,
161
- className: W[o],
162
- children: f
163
- }
164
- ),
165
- /* @__PURE__ */ e(
166
- Y,
167
- {
168
- ...l,
169
- size: o,
170
- placeholder: N,
171
- placeholderIcon: v,
172
- textStyles: n,
173
- selectedDisplayValue: b
174
- }
175
- ),
176
- /* @__PURE__ */ u(
177
- F,
178
- {
179
- size: o,
180
- className: a("flex flex-col", d),
181
- children: [
182
- /* @__PURE__ */ e(
183
- "div",
184
- {
185
- className: "sticky top-0 z-10 bg-primary p-1.5",
186
- onMouseDown: (t) => t.stopPropagation(),
187
- onPointerDown: (t) => t.stopPropagation(),
188
- onClick: (t) => t.stopPropagation(),
189
- children: /* @__PURE__ */ e(
190
- G,
155
+ value: {
156
+ size: i,
157
+ isDeselectable: o,
158
+ selectedKey: b,
159
+ onReselectCurrent: o ? U : void 0
160
+ },
161
+ children: /* @__PURE__ */ t(
162
+ E,
163
+ {
164
+ ...p,
165
+ selectedKey: b,
166
+ onOpenChange: j,
167
+ onSelectionChange: z,
168
+ className: (r) => s(
169
+ "flex flex-col gap-1.5",
170
+ typeof d == "function" ? d(r) : d
171
+ ),
172
+ children: (r) => /* @__PURE__ */ f(q, { children: [
173
+ x && /* @__PURE__ */ t(
174
+ J,
175
+ {
176
+ isRequired: r.isRequired,
177
+ tooltip: g,
178
+ className: re[i],
179
+ children: x
180
+ }
181
+ ),
182
+ /* @__PURE__ */ t(
183
+ ne,
184
+ {
185
+ ...r,
186
+ size: i,
187
+ placeholder: P,
188
+ placeholderIcon: R,
189
+ textStyles: n,
190
+ selectedDisplayValue: v
191
+ }
192
+ ),
193
+ /* @__PURE__ */ f(
194
+ Q,
195
+ {
196
+ size: i,
197
+ className: s("flex flex-col", m),
198
+ children: [
199
+ /* @__PURE__ */ t(
200
+ "div",
191
201
  {
192
- size: "sm",
193
- placeholder: g,
194
- value: y,
195
- onChange: (t) => T(t),
196
- onKeyDown: (t) => t.stopPropagation(),
197
- className: "w-full ring-0 outline-hidden bg-secondary rounded-lg"
202
+ className: "sticky top-0 z-10 bg-primary p-1.5",
203
+ onMouseDown: (e) => e.stopPropagation(),
204
+ onPointerDown: (e) => e.stopPropagation(),
205
+ onClick: (e) => e.stopPropagation(),
206
+ children: /* @__PURE__ */ t(
207
+ $,
208
+ {
209
+ size: "sm",
210
+ placeholder: y,
211
+ value: K,
212
+ onChange: (e) => V(e),
213
+ onKeyDown: (e) => e.stopPropagation(),
214
+ className: "w-full ring-0 outline-hidden bg-secondary rounded-lg"
215
+ }
216
+ )
198
217
  }
199
- )
200
- }
201
- ),
202
- /* @__PURE__ */ u("div", { className: "flex-1 overflow-y-auto", children: [
203
- p && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e(J, { size: "xs", type: "line-simple" }) }),
204
- !p && r.length === 0 && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e("p", { className: "text-sm text-tertiary", children: "No results" }) }),
205
- /* @__PURE__ */ e(
206
- B,
207
- {
208
- items: D,
209
- className: a(
210
- "size-full outline-hidden px-1",
211
- (p || r.length === 0) && "hidden"
212
- ),
213
- children: (t) => /* @__PURE__ */ e(
214
- H,
218
+ ),
219
+ /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto", children: [
220
+ u && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ t(ee, { size: "xs", type: "line-simple" }) }),
221
+ !u && l.length === 0 && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ t("p", { className: "text-sm text-tertiary", children: "No results" }) }),
222
+ /* @__PURE__ */ t(
223
+ F,
215
224
  {
216
- id: t.id,
217
- label: t.label,
218
- avatarUrl: t.avatarUrl,
219
- supportingText: t.supportingText,
220
- isDisabled: t.isDisabled,
221
- icon: t.icon,
222
- textStyles: n
223
- },
224
- t.id
225
+ items: O,
226
+ className: s(
227
+ "size-full outline-hidden px-1",
228
+ (u || l.length === 0) && "hidden"
229
+ ),
230
+ children: (e) => /* @__PURE__ */ t(
231
+ W,
232
+ {
233
+ id: e.id,
234
+ label: e.label,
235
+ avatarUrl: e.avatarUrl,
236
+ supportingText: e.supportingText,
237
+ isDisabled: e.isDisabled,
238
+ icon: e.icon,
239
+ textStyles: n
240
+ },
241
+ e.id
242
+ )
243
+ }
225
244
  )
226
- }
227
- )
228
- ] })
229
- ]
230
- }
231
- ),
232
- h && /* @__PURE__ */ e(A, { isInvalid: l.isInvalid, children: h })
233
- ] })
245
+ ] })
246
+ ]
247
+ }
248
+ ),
249
+ h && /* @__PURE__ */ t(G, { isInvalid: r.isInvalid, children: h })
250
+ ] })
251
+ }
252
+ )
234
253
  }
235
- ) });
254
+ );
236
255
  };
237
256
  export {
238
- pe as SearchableSelect
257
+ ve as SearchableSelect
239
258
  };
@@ -1 +1 @@
1
- {"version":3,"file":"select-item.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/select-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAMtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW/C,UAAU,eACR,SAAQ,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,GAAI,oHAYxB,eAAe,4CAmGjB,CAAC"}
1
+ {"version":3,"file":"select-item.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/select-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAMtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW/C,UAAU,eACR,SAAQ,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,GAAI,oHAYxB,eAAe,4CAqIjB,CAAC"}
@@ -1,52 +1,68 @@
1
- import { jsx as i, jsxs as f } from "react/jsx-runtime";
2
- import { useContext as w, isValidElement as v } from "react";
3
- import { Check as z } from "@untitledui/icons";
4
- import { ListBoxItem as C, Text as x } from "react-aria-components";
5
- import { Avatar as S } from "../avatar/avatar.js";
6
- import { SelectContext as D, fontSizes as u } from "./select.js";
7
- import { cx as n } from "../../utils/cn.js";
8
- import { isReactComponent as N } from "../../utils/is-react-component.js";
9
- const V = {
1
+ import { jsx as n, jsxs as p } from "react/jsx-runtime";
2
+ import { useContext as k, isValidElement as N } from "react";
3
+ import { Check as R } from "@untitledui/icons";
4
+ import { ListBoxItem as V, Text as w } from "react-aria-components";
5
+ import { Avatar as j } from "../avatar/avatar.js";
6
+ import { SelectContext as q, fontSizes as C } from "./select.js";
7
+ import { cx as l } from "../../utils/cn.js";
8
+ import { isReactComponent as A } from "../../utils/is-react-component.js";
9
+ const B = {
10
10
  sm: "p-2 pr-2.5",
11
11
  md: "p-2.5 pl-2",
12
12
  xs: "p-1.5"
13
- }, O = ({
14
- label: a,
15
- id: c,
16
- value: b,
17
- avatarUrl: s,
13
+ }, J = ({
14
+ label: d,
15
+ id: s,
16
+ value: v,
17
+ avatarUrl: m,
18
18
  supportingText: r,
19
- isDisabled: p,
20
- icon: t,
21
- className: d,
22
- children: o,
23
- textStyles: h,
24
- ...y
19
+ isDisabled: c,
20
+ icon: o,
21
+ className: u,
22
+ children: a,
23
+ textStyles: D,
24
+ ...t
25
25
  }) => {
26
- const { size: l } = w(D), m = a || (typeof o == "string" ? o : ""), g = r ? m + " " + r : m;
27
- return /* @__PURE__ */ i(
28
- C,
26
+ const { size: f, isDeselectable: P, selectedKey: b, onReselectCurrent: h } = k(q), y = P && b != null && s != null && String(s) === String(b), S = (e) => {
27
+ !y || c || (e.preventDefault(), e.stopPropagation());
28
+ }, g = (e) => {
29
+ !y || c || !h || ("preventDefault" in e && (e.preventDefault(), e.stopPropagation()), h());
30
+ }, x = d || (typeof a == "string" ? a : ""), z = r ? x + " " + r : x;
31
+ return /* @__PURE__ */ n(
32
+ V,
29
33
  {
30
- id: c,
31
- value: b ?? {
32
- id: c,
33
- label: m,
34
- avatarUrl: s,
34
+ id: s,
35
+ value: v ?? {
36
+ id: s,
37
+ label: x,
38
+ avatarUrl: m,
35
39
  supportingText: r,
36
- isDisabled: p,
37
- icon: t
40
+ isDisabled: c,
41
+ icon: o
38
42
  },
39
- textValue: g,
40
- isDisabled: p,
41
- ...y,
42
- className: (e) => n(
43
+ textValue: z,
44
+ isDisabled: c,
45
+ ...t,
46
+ onPointerDownCapture: (e) => {
47
+ var i;
48
+ (i = t.onPointerDownCapture) == null || i.call(t, e), S(e);
49
+ },
50
+ onPointerUpCapture: (e) => {
51
+ var i;
52
+ (i = t.onPointerUpCapture) == null || i.call(t, e), g(e);
53
+ },
54
+ onPress: (e) => {
55
+ var i;
56
+ (i = t.onPress) == null || i.call(t, e), e.pointerType === "keyboard" && g(e);
57
+ },
58
+ className: (e) => l(
43
59
  "w-full px-1.5 py-px outline-hidden",
44
- typeof d == "function" ? d(e) : d
60
+ typeof u == "function" ? u(e) : u
45
61
  ),
46
- children: (e) => /* @__PURE__ */ f(
62
+ children: (e) => /* @__PURE__ */ p(
47
63
  "div",
48
64
  {
49
- className: n(
65
+ className: l(
50
66
  "flex cursor-pointer items-center gap-2 rounded-md outline-hidden select-none hover:bg-primary_hover",
51
67
  e.isSelected && "bg-brand-primary text-brand-600 hover:bg-brand-primary hover:text-brand-600",
52
68
  e.isDisabled && "cursor-not-allowed",
@@ -55,42 +71,42 @@ const V = {
55
71
  "*:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:text-fg-quaternary",
56
72
  e.isDisabled && "*:data-icon:text-fg-disabled",
57
73
  // @ts-ignore
58
- V[l]
74
+ B[f]
59
75
  ),
60
76
  children: [
61
- s ? /* @__PURE__ */ i(S, { "aria-hidden": "true", size: "sm", src: s, alt: a }) : N(t) ? /* @__PURE__ */ i(t, { "data-icon": !0, "aria-hidden": "true" }) : v(t) ? t : null,
62
- /* @__PURE__ */ f("div", { className: "flex w-full min-w-0 flex-1 flex-wrap gap-x-2", children: [
63
- /* @__PURE__ */ i(
64
- x,
77
+ m ? /* @__PURE__ */ n(j, { "aria-hidden": "true", size: "sm", src: m, alt: d }) : A(o) ? /* @__PURE__ */ n(o, { "data-icon": !0, "aria-hidden": "true" }) : N(o) ? o : null,
78
+ /* @__PURE__ */ p("div", { className: "flex w-full min-w-0 flex-1 flex-wrap gap-x-2", children: [
79
+ /* @__PURE__ */ n(
80
+ w,
65
81
  {
66
82
  slot: "label",
67
- className: n(
83
+ className: l(
68
84
  "truncate font-medium whitespace-nowrap text-primary",
69
85
  e.isDisabled && "text-disabled",
70
- h,
71
- u[l]
86
+ D,
87
+ C[f]
72
88
  ),
73
- children: a || (typeof o == "function" ? o(e) : o)
89
+ children: d || (typeof a == "function" ? a(e) : a)
74
90
  }
75
91
  ),
76
- r && /* @__PURE__ */ i(
77
- x,
92
+ r && /* @__PURE__ */ n(
93
+ w,
78
94
  {
79
95
  slot: "description",
80
- className: n(
96
+ className: l(
81
97
  "whitespace-nowrap text-tertiary",
82
- u[l],
98
+ C[f],
83
99
  e.isDisabled && "text-disabled"
84
100
  ),
85
101
  children: r
86
102
  }
87
103
  )
88
104
  ] }),
89
- e.isSelected && /* @__PURE__ */ i(
90
- z,
105
+ e.isSelected && /* @__PURE__ */ n(
106
+ R,
91
107
  {
92
108
  "aria-hidden": "true",
93
- className: n(
109
+ className: l(
94
110
  "ml-auto text-fg-brand-primary",
95
111
  e.isDisabled && "text-fg-disabled"
96
112
  ),
@@ -104,5 +120,5 @@ const V = {
104
120
  );
105
121
  };
106
122
  export {
107
- O as SelectItem
123
+ J as SelectItem
108
124
  };
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode, RefAttributes } from 'react';
2
- import { SelectProps as AriaSelectProps } from 'react-aria-components';
2
+ import { Key, SelectProps as AriaSelectProps } from 'react-aria-components';
3
3
  import { ComboBox } from './combobox';
4
4
  import { SelectItem } from './select-item';
5
5
  import { SearchableSelect } from './searchable-select';
@@ -28,6 +28,8 @@ export interface SelectProps extends Omit<AriaSelectProps<SelectItemType>, "chil
28
28
  showChevron?: boolean;
29
29
  /** When true, shows a clear button when a value is selected. Clearing calls onSelectionChange(null). Default false. */
30
30
  isClearable?: boolean;
31
+ /** When true, clicking the already-selected option in the dropdown clears the selection. Default false. */
32
+ isDeselectable?: boolean;
31
33
  }
32
34
  export declare const sizes: {
33
35
  sm: {
@@ -50,8 +52,11 @@ export declare const fontSizes: {
50
52
  };
51
53
  export declare const SelectContext: import('react').Context<{
52
54
  size: "sm" | "md" | "lg";
55
+ isDeselectable?: boolean;
56
+ selectedKey?: Key | null;
57
+ onReselectCurrent?: () => void;
53
58
  }>;
54
- declare const Select: ({ placeholder, placeholderIcon, size, children, items, label, hint, tooltip, className, textStyles, showChevron, isClearable, ...rest }: SelectProps) => import("react/jsx-runtime").JSX.Element;
59
+ declare const Select: ({ placeholder, placeholderIcon, size, children, items, label, hint, tooltip, className, textStyles, showChevron, isClearable, isDeselectable, ...rest }: SelectProps) => import("react/jsx-runtime").JSX.Element;
55
60
  declare const _Select: typeof Select & {
56
61
  ComboBox: typeof ComboBox;
57
62
  Item: typeof SelectItem;