@pibit.ai/cure-design-system 0.5.12 → 0.6.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 (61) hide show
  1. package/dist/applications/date-picker/calendar-value.d.ts +4 -0
  2. package/dist/applications/date-picker/calendar-value.d.ts.map +1 -0
  3. package/dist/applications/date-picker/calendar-value.js +6 -0
  4. package/dist/applications/date-picker/calendar.d.ts.map +1 -1
  5. package/dist/applications/date-picker/calendar.js +130 -124
  6. package/dist/applications/date-picker/date-time-calendar.d.ts.map +1 -1
  7. package/dist/applications/date-picker/date-time-calendar.js +56 -55
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +161 -157
  11. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +6 -6
  12. package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +5 -5
  13. package/dist/node_modules/framer-motion/dist/es/utils/use-composed-ref.js +3 -3
  14. package/dist/node_modules/{@react-stately/data/dist → react-stately/dist/private/data}/useListData.js +61 -64
  15. package/dist/primitives/avatar/avatar.d.ts +46 -28
  16. package/dist/primitives/avatar/avatar.d.ts.map +1 -1
  17. package/dist/primitives/avatar/avatar.js +114 -39
  18. package/dist/primitives/avatar/base-components/avatar-online-indicator.d.ts +8 -0
  19. package/dist/primitives/avatar/base-components/avatar-online-indicator.d.ts.map +1 -0
  20. package/dist/primitives/avatar/base-components/avatar-online-indicator.js +29 -0
  21. package/dist/primitives/avatar/base-components/index.d.ts +3 -0
  22. package/dist/primitives/avatar/base-components/index.d.ts.map +1 -0
  23. package/dist/primitives/avatar/base-components/verified-tick.d.ts +7 -0
  24. package/dist/primitives/avatar/base-components/verified-tick.d.ts.map +1 -0
  25. package/dist/primitives/avatar/base-components/verified-tick.js +41 -0
  26. package/dist/primitives/dropdown/dropdown.d.ts +2 -2
  27. package/dist/primitives/input/input.d.ts.map +1 -1
  28. package/dist/primitives/input/input.js +9 -1
  29. package/dist/primitives/select/SearchInput.d.ts +7 -7
  30. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  31. package/dist/primitives/select/__tests__/multi-select-utils.test.d.ts +2 -0
  32. package/dist/primitives/select/__tests__/multi-select-utils.test.d.ts.map +1 -0
  33. package/dist/primitives/select/combobox.d.ts +1 -2
  34. package/dist/primitives/select/combobox.d.ts.map +1 -1
  35. package/dist/primitives/select/index.d.ts +3 -1
  36. package/dist/primitives/select/index.d.ts.map +1 -1
  37. package/dist/primitives/select/multi-select-utils.d.ts +7 -0
  38. package/dist/primitives/select/multi-select-utils.d.ts.map +1 -0
  39. package/dist/primitives/select/multi-select-utils.js +17 -0
  40. package/dist/primitives/select/multi-select.d.ts +17 -4
  41. package/dist/primitives/select/multi-select.d.ts.map +1 -1
  42. package/dist/primitives/select/multi-select.js +631 -237
  43. package/dist/primitives/select/searchable-select.d.ts +26 -4
  44. package/dist/primitives/select/searchable-select.d.ts.map +1 -1
  45. package/dist/primitives/select/searchable-select.js +292 -189
  46. package/dist/primitives/select/select-checkbox.d.ts +6 -0
  47. package/dist/primitives/select/select-checkbox.d.ts.map +1 -0
  48. package/dist/primitives/select/select-checkbox.js +62 -0
  49. package/dist/primitives/select/select-item.d.ts +3 -1
  50. package/dist/primitives/select/select-item.d.ts.map +1 -1
  51. package/dist/primitives/select/select-item.js +95 -77
  52. package/dist/primitives/select/select-native.d.ts +21 -2
  53. package/dist/primitives/select/select-native.d.ts.map +1 -1
  54. package/dist/primitives/select/select-native.js +88 -0
  55. package/dist/primitives/select/select-shared.d.ts +1 -0
  56. package/dist/primitives/select/select-shared.d.ts.map +1 -1
  57. package/dist/primitives/select/select.d.ts +12 -2
  58. package/dist/primitives/select/select.d.ts.map +1 -1
  59. package/dist/primitives/select/select.js +207 -152
  60. package/dist/styles/components.css +1 -1
  61. package/package.json +4 -4
@@ -1,23 +1,139 @@
1
- import { jsx as i, jsxs as N, Fragment as L } from "react/jsx-runtime";
2
- import { useCallback as F, useRef as E, useState as q, createContext as j, useContext as P } from "react";
3
- import { useFilter as C, FocusScope as V, useFocusManager as $ } from "react-aria";
4
- import { ComboBox as W, ListBox as G, Group as H, ComboBoxStateContext as U, Input as X } from "react-aria-components";
5
- import { Avatar as J } from "../avatar/avatar.js";
6
- import { HintText as O } from "../input/hint-text.js";
7
- import { Label as Q } from "../input/label.js";
8
- import { Popover as Y } from "./popover.js";
9
- import { sizes as Z } from "./select-shared.js";
10
- import { TagCloseX as M } from "../tags/base-components/tag-close-x.js";
11
- import { SelectItem as B } from "./select-item.js";
12
- import { cx as w } from "../../utils/cn.js";
13
- import { getPlatformShortcutLabel as I } from "../../utils/keyboard-shortcut.js";
14
- import { useResizeObserver as ee } from "../../hooks/use-resize-observer.js";
15
- import { useListData as te } from "../../node_modules/@react-stately/data/dist/useListData.js";
16
- const se = {
1
+ import { jsx as i, jsxs as M, Fragment as de } from "react/jsx-runtime";
2
+ import { useId as fe, useCallback as L, useMemo as Q, useRef as U, useState as se, createContext as pe, useContext as q, useLayoutEffect as he } from "react";
3
+ import { useFilter as me, useInteractOutside as ge, FocusScope as we, useFocusManager as ye } from "react-aria";
4
+ import { Minus as be, ChevronDown as xe, SearchMd as ve } from "@untitledui/icons";
5
+ import { ComboBox as De, ListBox as Ne, ComboBoxStateContext as G, ButtonContext as Y, Group as ke, Input as Te } from "react-aria-components";
6
+ import { useListData as Re } from "../../node_modules/react-stately/dist/private/data/useListData.js";
7
+ import { Avatar as Fe } from "../avatar/avatar.js";
8
+ import { HintText as Se } from "../input/hint-text.js";
9
+ import { Label as Me } from "../input/label.js";
10
+ import { Popover as Ae } from "./popover.js";
11
+ import { sizes as Ee } from "./select-shared.js";
12
+ import { TagCloseX as Pe } from "../tags/base-components/tag-close-x.js";
13
+ import { SelectItem as ze } from "./select-item.js";
14
+ import { cx as D } from "../../utils/cn.js";
15
+ import { getPlatformShortcutLabel as Le } from "../../utils/keyboard-shortcut.js";
16
+ import { useResizeObserver as le } from "../../hooks/use-resize-observer.js";
17
+ import { SelectCheckbox as Ke } from "./select-checkbox.js";
18
+ import { multiSelectItemMatchesFilter as ne, getMultiSelectSelectAllLabel as Oe, shouldClearMultiSelectFilterOnSelection as qe } from "./multi-select-utils.js";
19
+ const _e = {
20
+ sm: "py-1.5 px-2 min-h-8 h-auto",
21
+ md: "py-1.5 px-3 min-h-9 h-auto",
22
+ lg: "py-2.5 px-3.5 min-h-11 h-auto"
23
+ };
24
+ function We(...o) {
25
+ return (b) => {
26
+ for (const u of o)
27
+ u != null && (typeof u == "function" ? u(b) : u.current = b);
28
+ };
29
+ }
30
+ const Z = {
17
31
  sm: "text-xs",
18
32
  md: "text-sm",
19
33
  lg: "text-md"
20
- }, K = j({
34
+ }, ie = {
35
+ sm: "text-xs",
36
+ md: "text-sm",
37
+ lg: "text-sm"
38
+ };
39
+ function je(o) {
40
+ return document.getElementById(o);
41
+ }
42
+ function Ve({
43
+ triggerRef: o,
44
+ popoverRef: b
45
+ }) {
46
+ const u = q(G);
47
+ return ge({
48
+ ref: b,
49
+ isDisabled: !(u != null && u.isOpen),
50
+ onInteractOutside: (m) => {
51
+ var s;
52
+ (s = o.current) != null && s.contains(m.target) || u == null || u.close();
53
+ }
54
+ }), null;
55
+ }
56
+ function ae(o) {
57
+ const b = o.target;
58
+ b instanceof Element && b.closest("input, textarea, [contenteditable='true']") || o.preventDefault();
59
+ }
60
+ const He = ({
61
+ value: o,
62
+ placeholder: b,
63
+ listboxId: u,
64
+ onChange: m
65
+ }) => {
66
+ const s = q(G), x = (e) => {
67
+ e.stopPropagation(), s == null || s.open();
68
+ }, k = (e) => {
69
+ e.stopPropagation(), ae(e);
70
+ }, f = (e) => {
71
+ e.stopPropagation();
72
+ }, l = (e) => {
73
+ var r;
74
+ const a = je(u), g = a ? Array.from(a.querySelectorAll('[role="option"]')) : [];
75
+ switch (e.key) {
76
+ case "ArrowDown":
77
+ e.preventDefault(), g.length > 0 && ((a == null ? void 0 : a.querySelector(
78
+ '[role="option"][data-focused="true"]'
79
+ )) ?? g[0]).focus();
80
+ return;
81
+ case "ArrowUp":
82
+ e.preventDefault(), g.length > 0 && g[g.length - 1].focus();
83
+ return;
84
+ case "Enter":
85
+ if (((r = document.activeElement) == null ? void 0 : r.getAttribute("role")) === "option")
86
+ return;
87
+ g.length > 0 && (e.preventDefault(), ((a == null ? void 0 : a.querySelector(
88
+ '[role="option"][data-focused="true"]'
89
+ )) ?? g[0]).click());
90
+ return;
91
+ case "Escape":
92
+ e.preventDefault(), s == null || s.close();
93
+ return;
94
+ default:
95
+ (e.key.length === 1 || e.key === "Backspace" || e.key === "Delete" || e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End" || e.key === "Tab") && e.stopPropagation();
96
+ }
97
+ };
98
+ return /* @__PURE__ */ i(
99
+ "div",
100
+ {
101
+ "data-nested-select-overlay": !0,
102
+ className: "sticky top-0 z-10 border-b border-tertiary bg-primary p-1.5",
103
+ onMouseDown: k,
104
+ onPointerDown: f,
105
+ onClick: (e) => e.stopPropagation(),
106
+ children: /* @__PURE__ */ M(
107
+ "div",
108
+ {
109
+ className: "flex h-8 items-center gap-2 rounded-lg bg-secondary px-2",
110
+ onMouseDown: k,
111
+ children: [
112
+ /* @__PURE__ */ i(ve, { "aria-hidden": !0, className: "size-4 shrink-0 text-fg-quaternary" }),
113
+ /* @__PURE__ */ i(
114
+ "input",
115
+ {
116
+ type: "text",
117
+ role: "combobox",
118
+ "aria-autocomplete": "list",
119
+ "aria-expanded": (s == null ? void 0 : s.isOpen) ?? !1,
120
+ "aria-controls": u,
121
+ value: o,
122
+ onChange: m,
123
+ onMouseDown: x,
124
+ onKeyDown: l,
125
+ onFocus: () => s == null ? void 0 : s.open(),
126
+ placeholder: b,
127
+ className: "w-full bg-transparent text-xs text-primary outline-none placeholder:text-placeholder_subtle",
128
+ autoFocus: !1
129
+ }
130
+ )
131
+ ]
132
+ }
133
+ )
134
+ }
135
+ );
136
+ }, oe = pe({
21
137
  size: "sm",
22
138
  selectedKeys: [],
23
139
  selectedItems: {},
@@ -26,281 +142,559 @@ const se = {
26
142
  onInputChange: () => {
27
143
  },
28
144
  showAvatar: !0,
29
- chipClassName: void 0
30
- }), re = ({
31
- items: f,
145
+ chipClassName: void 0,
146
+ searchable: !1
147
+ }), $e = ({
148
+ items: o,
32
149
  children: b,
33
- size: h = "sm",
34
- selectedItems: l,
35
- onItemCleared: c,
36
- onItemInserted: t,
37
- shortcut: s,
38
- placeholder: d = "Search",
39
- showAvatar: p = !0,
40
- readOnly: g = !1,
41
- chipClassName: k,
150
+ size: u = "sm",
151
+ selectedItems: m,
152
+ onItemCleared: s,
153
+ onItemInserted: x,
154
+ onBulkSelectionChange: k,
155
+ shortcut: f,
156
+ placeholder: l = "Search",
157
+ showAvatar: e = !0,
158
+ readOnly: a = !1,
159
+ chipClassName: g,
160
+ searchable: r = !1,
161
+ searchPlaceholder: F = "Search...",
162
+ showSelectAll: T = !1,
163
+ endAdornment: _,
164
+ description: K,
165
+ onOpenChange: c,
42
166
  // Omit these props to avoid conflicts with the `Select` component
43
- name: R,
44
- className: T,
45
- ...n
167
+ name: p,
168
+ className: S,
169
+ ...h
46
170
  }) => {
47
- var D;
48
- const { contains: x } = C({ sensitivity: "base" }), u = (D = l == null ? void 0 : l.items) != null && D.length ? l.items.map((r) => r.id) : [], e = F(
49
- (r, a) => !u.includes(r.id) && x(r.label || r.supportingText || "", a),
50
- [x, u]
51
- ), o = te({
52
- initialItems: f,
53
- filter: e
54
- }), v = F(
55
- (r) => {
56
- const a = r.values().next().value;
57
- a && (l.remove(a), c == null || c(a));
171
+ var ee;
172
+ const P = fe(), { contains: O } = me({ sensitivity: "base" }), y = (ee = m == null ? void 0 : m.items) != null && ee.length ? m.items.map((n) => n.id) : [], W = L(
173
+ (n, d) => {
174
+ const $ = ne(
175
+ n,
176
+ d,
177
+ O
178
+ );
179
+ return (T || !y.includes(n.id)) && $;
58
180
  },
59
- [l, c]
60
- ), S = (r) => {
61
- if (!r)
181
+ [O, y, T]
182
+ ), w = Re({
183
+ initialItems: o,
184
+ filter: W
185
+ }), E = !!(r && w.filterText.trim()), N = Q(() => o != null && o.length ? E ? o.filter(
186
+ (n) => ne(n, w.filterText, O)
187
+ ) : o : [], [o, E, w.filterText, O]), z = Q(() => {
188
+ if (N.length === 0) return "unselected";
189
+ const n = N.filter(
190
+ (d) => y.includes(d.id)
191
+ ).length;
192
+ return n === 0 ? "unselected" : n === N.length ? "selected" : "indeterminate";
193
+ }, [N, y]), j = L(() => {
194
+ const n = z !== "selected", d = N.map((v) => v.id), $ = new Set(d.map(String)), ue = n ? [.../* @__PURE__ */ new Set([...y, ...d])] : y.filter((v) => !$.has(String(v))), te = N.filter(
195
+ (v) => !y.includes(v.id)
196
+ ), re = N.filter((v) => y.includes(v.id)).map((v) => v.id);
197
+ if (n && te.length > 0 ? m.append(...te) : !n && re.length > 0 && m.remove(...re), k) {
198
+ k(ue);
62
199
  return;
63
- const a = o.getItem(r);
64
- a && (u.includes(r) || (l.append(a), t == null || t(r)), o.setFilterText(""));
65
- }, y = (r) => {
66
- g || o.setFilterText(r);
67
- }, m = E(null), [_, A] = q(""), z = F(() => {
68
- var a;
69
- if (!m.current) return;
70
- let r = (a = m.current) == null ? void 0 : a.getBoundingClientRect();
71
- A(r.width + "px");
72
- }, [m, A]);
73
- return ee({
74
- ref: m,
75
- onResize: z,
200
+ }
201
+ if (n) {
202
+ for (const v of N)
203
+ y.includes(v.id) || x == null || x(v.id);
204
+ return;
205
+ }
206
+ for (const v of N)
207
+ y.includes(v.id) && (s == null || s(v.id));
208
+ }, [
209
+ z,
210
+ N,
211
+ y,
212
+ m,
213
+ k,
214
+ x,
215
+ s
216
+ ]), t = L(
217
+ (n) => {
218
+ const d = n.values().next().value;
219
+ d && (m.remove(d), s == null || s(d));
220
+ },
221
+ [m, s]
222
+ ), R = (n) => {
223
+ if (!n)
224
+ return;
225
+ const d = w.getItem(n);
226
+ d && (T && y.includes(n) ? (m.remove(n), s == null || s(n)) : y.includes(n) || (m.append(d), x == null || x(n)), qe(r) && w.setFilterText(""));
227
+ }, X = L(
228
+ (n) => {
229
+ !n && r && w.setFilterText(""), c == null || c(n);
230
+ },
231
+ [w, c, r]
232
+ ), V = (n) => {
233
+ a || w.setFilterText(n);
234
+ }, A = U(null), H = U(null), [ce, C] = se(0), J = L(() => {
235
+ var d;
236
+ if (!A.current) return;
237
+ let n = (d = A.current) == null ? void 0 : d.getBoundingClientRect();
238
+ C(n.width);
239
+ }, [A, C]);
240
+ le({
241
+ ref: A,
242
+ onResize: J,
76
243
  box: "border-box"
77
- }), /* @__PURE__ */ i(
78
- K.Provider,
244
+ });
245
+ const I = T && !!(o != null && o.length) && (!E || N.length > 0), B = Oe(E);
246
+ return /* @__PURE__ */ i(
247
+ oe.Provider,
79
248
  {
80
249
  value: {
81
- size: h,
82
- selectedKeys: u,
83
- selectedItems: l,
84
- onInputChange: y,
85
- onRemove: v,
86
- showAvatar: p,
87
- chipClassName: k
250
+ size: u,
251
+ selectedKeys: y,
252
+ selectedItems: m,
253
+ onInputChange: V,
254
+ onRemove: t,
255
+ showAvatar: e,
256
+ chipClassName: g,
257
+ searchable: r
88
258
  },
89
259
  children: /* @__PURE__ */ i(
90
- W,
260
+ De,
91
261
  {
92
262
  allowsEmptyCollection: !0,
93
263
  allowsCustomValue: !1,
94
- menuTrigger: "focus",
95
- items: o.items,
96
- onInputChange: y,
97
- inputValue: o.filterText,
264
+ menuTrigger: r || a ? "manual" : "focus",
265
+ items: w.items,
266
+ onInputChange: r ? void 0 : V,
267
+ inputValue: r ? "" : w.filterText,
98
268
  selectedKey: null,
99
- onSelectionChange: S,
100
- ...n,
101
- children: (r) => {
102
- var a;
103
- return /* @__PURE__ */ N("div", { className: "flex flex-col gap-1.5", children: [
104
- n.label && /* @__PURE__ */ i(Q, { isRequired: r.isRequired, tooltip: n.tooltip, children: n.label }),
105
- /* @__PURE__ */ i(
106
- ae,
107
- {
108
- size: h,
109
- shortcut: s,
110
- ref: m,
111
- placeholder: d,
112
- readOnly: g,
113
- onFocus: z,
114
- onPointerEnter: z
115
- }
116
- ),
117
- ((a = o.items) == null ? void 0 : a.length) > 0 && /* @__PURE__ */ i(
118
- Y,
119
- {
120
- size: "md",
121
- triggerRef: m,
122
- style: { width: _ },
123
- className: n == null ? void 0 : n.popoverClassName,
124
- children: /* @__PURE__ */ i(
125
- G,
269
+ onSelectionChange: R,
270
+ onOpenChange: X,
271
+ ...h,
272
+ children: (n) => /* @__PURE__ */ M("div", { className: "flex flex-col gap-1.5", children: [
273
+ /* @__PURE__ */ i(
274
+ Ve,
275
+ {
276
+ triggerRef: A,
277
+ popoverRef: H
278
+ }
279
+ ),
280
+ h.label && /* @__PURE__ */ i(
281
+ Me,
282
+ {
283
+ isRequired: n.isRequired,
284
+ tooltip: h.tooltip,
285
+ className: ie[u],
286
+ children: h.label
287
+ }
288
+ ),
289
+ K && /* @__PURE__ */ i(
290
+ "p",
291
+ {
292
+ className: D(
293
+ "text-tertiary",
294
+ ie[u],
295
+ "-mt-0.5 leading-[18px]"
296
+ ),
297
+ children: K
298
+ }
299
+ ),
300
+ /* @__PURE__ */ i(
301
+ Ge,
302
+ {
303
+ size: u,
304
+ shortcut: f,
305
+ ref: A,
306
+ placeholder: l,
307
+ readOnly: a,
308
+ isInvalid: n.isInvalid,
309
+ endAdornment: _,
310
+ onFocus: J,
311
+ onPointerEnter: J
312
+ }
313
+ ),
314
+ (r || I || w.items.length > 0) && /* @__PURE__ */ M(
315
+ Ae,
316
+ {
317
+ size: "md",
318
+ ref: H,
319
+ triggerRef: A,
320
+ className: D("flex flex-col", h == null ? void 0 : h.popoverClassName),
321
+ style: { width: Math.max(ce, 40) },
322
+ onMouseDown: (d) => {
323
+ d.stopPropagation(), ae(d);
324
+ },
325
+ onPointerDown: (d) => d.stopPropagation(),
326
+ children: [
327
+ r && /* @__PURE__ */ i(
328
+ He,
126
329
  {
127
- selectionMode: "multiple",
128
- className: "size-full outline-hidden",
129
- children: b
330
+ listboxId: P,
331
+ value: w.filterText,
332
+ placeholder: F,
333
+ onChange: (d) => w.setFilterText(d.target.value)
130
334
  }
131
- )
132
- }
133
- ),
134
- n.hint && /* @__PURE__ */ i(O, { isInvalid: r.isInvalid, children: n.hint })
135
- ] });
136
- }
335
+ ),
336
+ I && /* @__PURE__ */ M(
337
+ "div",
338
+ {
339
+ className: D(
340
+ "flex shrink-0 items-center gap-2 border-b border-secondary px-3 py-2.5",
341
+ "cursor-pointer hover:bg-secondary_subtle transition-colors",
342
+ h.isDisabled && "cursor-not-allowed opacity-50"
343
+ ),
344
+ onClick: h.isDisabled ? void 0 : j,
345
+ children: [
346
+ z === "indeterminate" ? /* @__PURE__ */ i(
347
+ "span",
348
+ {
349
+ className: D(
350
+ "flex size-4 shrink-0 items-center justify-center rounded ring-1 ring-inset",
351
+ "bg-brand-solid ring-bg-brand-solid text-fg-white"
352
+ ),
353
+ "aria-hidden": !0,
354
+ children: /* @__PURE__ */ i(be, { className: "size-3 stroke-[2.5]" })
355
+ }
356
+ ) : /* @__PURE__ */ i(
357
+ Ke,
358
+ {
359
+ size: u === "lg" ? "md" : "sm",
360
+ checked: z === "selected",
361
+ onCheckedChange: j,
362
+ onClick: (d) => d.stopPropagation(),
363
+ disabled: h.isDisabled,
364
+ "aria-label": B
365
+ }
366
+ ),
367
+ /* @__PURE__ */ i(
368
+ "span",
369
+ {
370
+ className: D("font-medium text-primary", Z[u]),
371
+ children: B
372
+ }
373
+ )
374
+ ]
375
+ }
376
+ ),
377
+ /* @__PURE__ */ M("div", { className: "flex-1 overflow-y-auto", children: [
378
+ w.items.length === 0 && r && E && /* @__PURE__ */ i("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ i("p", { className: D("text-tertiary", Z[u]), children: "No results" }) }),
379
+ /* @__PURE__ */ i(
380
+ Ne,
381
+ {
382
+ id: P,
383
+ selectionMode: "multiple",
384
+ selectedKeys: T ? new Set(y) : void 0,
385
+ className: D(
386
+ "size-full outline-hidden",
387
+ w.items.length === 0 && "hidden"
388
+ ),
389
+ children: b
390
+ }
391
+ )
392
+ ] })
393
+ ]
394
+ }
395
+ ),
396
+ h.hint && /* @__PURE__ */ i(Se, { isInvalid: n.isInvalid, children: h.hint })
397
+ ] })
137
398
  }
138
399
  )
139
400
  }
140
401
  );
141
- }, ie = ({
142
- isDisabled: f,
402
+ }, Ue = ({
403
+ isDisabled: o,
143
404
  shortcut: b,
144
- shortcutClassName: h,
145
- placeholder: l,
146
- readOnly: c = !1
405
+ shortcutClassName: u,
406
+ placeholder: m,
407
+ readOnly: s = !1,
408
+ isFocusWithin: x,
409
+ inputRef: k
147
410
  }) => {
148
- var T, n, x, u;
149
- const t = $(), s = P(K), d = P(U), p = (e) => {
150
- if (!(!(e.currentTarget.selectionStart === 0 && e.currentTarget.selectionEnd === 0) && e.currentTarget.value !== ""))
151
- switch (e.key) {
411
+ var w, E, N, z, j;
412
+ const f = ye(), l = q(oe), e = q(G), a = x || !!(e != null && e.isOpen), g = U(null), [r, F] = se(!1), T = (w = l == null ? void 0 : l.selectedItems) == null ? void 0 : w.items, _ = (T == null ? void 0 : T.map((t) => t.id).join("\0")) ?? "", K = (e == null ? void 0 : e.inputValue) ?? "", c = L(() => {
413
+ const t = g.current;
414
+ if (!t || a) {
415
+ F(!1);
416
+ return;
417
+ }
418
+ const R = t.scrollWidth > t.clientWidth + 0.5;
419
+ F(
420
+ R && t.scrollLeft + t.clientWidth < t.scrollWidth - 1
421
+ );
422
+ }, [a]);
423
+ le({
424
+ ref: g,
425
+ onResize: c,
426
+ box: "border-box"
427
+ }), he(() => {
428
+ c();
429
+ }, [
430
+ c,
431
+ _,
432
+ a,
433
+ K
434
+ ]);
435
+ const p = (t) => {
436
+ var R;
437
+ t.preventDefault(), (R = k.current) == null || R.focus({ preventScroll: !0 });
438
+ }, S = (t) => {
439
+ if (!(!(t.currentTarget.selectionStart === 0 && t.currentTarget.selectionEnd === 0) && t.currentTarget.value !== ""))
440
+ switch (t.key) {
152
441
  case "Backspace":
153
442
  case "ArrowLeft":
154
- t == null || t.focusPrevious({ wrap: !1, tabbable: !1 });
443
+ f == null || f.focusPrevious({ wrap: !1, tabbable: !1 });
155
444
  break;
156
445
  case "ArrowRight":
157
- t == null || t.focusNext({ wrap: !1, tabbable: !1 });
446
+ f == null || f.focusNext({ wrap: !1, tabbable: !1 });
158
447
  break;
159
448
  }
160
- }, g = (e) => {
161
- d && !d.isOpen && d.open();
162
- }, k = (e, o) => {
163
- var S, y, m;
164
- if (e.key === "Tab")
449
+ }, h = l == null ? void 0 : l.searchable, P = (t) => {
450
+ t.stopPropagation(), e && !e.isOpen && e.open();
451
+ }, O = () => {
452
+ h && e && !e.isOpen && e.open();
453
+ }, y = (t, R) => {
454
+ var V, A, H;
455
+ if (t.key === "Tab")
165
456
  return;
166
- e.preventDefault();
167
- const v = ((m = (y = (S = s == null ? void 0 : s.selectedItems) == null ? void 0 : S.items) == null ? void 0 : y[0]) == null ? void 0 : m.id) === o;
168
- switch (e.key) {
457
+ t.preventDefault();
458
+ const X = ((H = (A = (V = l == null ? void 0 : l.selectedItems) == null ? void 0 : V.items) == null ? void 0 : A[0]) == null ? void 0 : H.id) === R;
459
+ switch (t.key) {
169
460
  case " ":
170
461
  case "Enter":
171
462
  case "Backspace":
172
- v ? t == null || t.focusNext({ wrap: !1, tabbable: !1 }) : t == null || t.focusPrevious({ wrap: !1, tabbable: !1 }), s.onRemove(/* @__PURE__ */ new Set([o]));
463
+ X ? f == null || f.focusNext({ wrap: !1, tabbable: !1 }) : f == null || f.focusPrevious({ wrap: !1, tabbable: !1 }), l.onRemove(/* @__PURE__ */ new Set([R]));
173
464
  break;
174
465
  case "ArrowLeft":
175
- t == null || t.focusPrevious({ wrap: !1, tabbable: !1 });
466
+ f == null || f.focusPrevious({ wrap: !1, tabbable: !1 });
176
467
  break;
177
468
  case "ArrowRight":
178
- t == null || t.focusNext({ wrap: !1, tabbable: !1 });
469
+ f == null || f.focusNext({ wrap: !1, tabbable: !1 });
179
470
  break;
180
471
  case "Escape":
181
- d == null || d.close();
472
+ e == null || e.close();
182
473
  break;
183
474
  }
184
- }, R = ((n = (T = s == null ? void 0 : s.selectedItems) == null ? void 0 : T.items) == null ? void 0 : n.length) === 0;
185
- return /* @__PURE__ */ N("div", { className: "relative flex w-full flex-1 flex-row flex-wrap items-center justify-start gap-1.5", children: [
186
- !R && ((u = (x = s == null ? void 0 : s.selectedItems) == null ? void 0 : x.items) == null ? void 0 : u.map((e) => /* @__PURE__ */ N(
187
- "span",
188
- {
189
- className: w(
190
- "flex items-center rounded-md bg-primary py-0.5 pr-1 pl-1.25 ring-1 ring-[var(--color-gray-100)] ring-inset",
191
- s == null ? void 0 : s.chipClassName
192
- ),
193
- children: [
194
- (s == null ? void 0 : s.showAvatar) && /* @__PURE__ */ i(
195
- J,
196
- {
197
- size: "sm",
198
- alt: e == null ? void 0 : e.label,
199
- src: e == null ? void 0 : e.avatarUrl,
200
- fallback: e == null ? void 0 : e.initials
201
- }
202
- ),
203
- /* @__PURE__ */ i("p", { className: "ml-1.25 truncate text-sm font-medium whitespace-nowrap text-secondary select-none", children: e == null ? void 0 : e.label }),
204
- /* @__PURE__ */ i(
205
- M,
206
- {
207
- size: "md",
208
- isDisabled: f,
209
- className: "ml-0.75",
210
- onKeyDown: (o) => k(o, e.id),
211
- onPress: () => s.onRemove(/* @__PURE__ */ new Set([e.id]))
212
- }
213
- )
214
- ]
215
- },
216
- e.id
217
- ))),
218
- /* @__PURE__ */ N(
475
+ }, W = ((N = (E = l == null ? void 0 : l.selectedItems) == null ? void 0 : E.items) == null ? void 0 : N.length) === 0;
476
+ return /* @__PURE__ */ M("div", { className: "relative min-w-0 w-full flex-1", children: [
477
+ /* @__PURE__ */ M(
219
478
  "div",
220
479
  {
221
- className: w(
222
- "relative flex min-w-[20%] flex-1 flex-row items-center",
223
- !R && "ml-0.5",
224
- b && "min-w-[30%]"
480
+ ref: g,
481
+ onScroll: a ? void 0 : c,
482
+ className: D(
483
+ "flex w-full min-w-0 gap-1.5",
484
+ a ? D(
485
+ "flex-wrap items-start overflow-y-auto scrollbar-hide"
486
+ // multiSelectExpandedMaxHeight[controlSize],
487
+ ) : "flex-nowrap items-center overflow-x-auto overflow-y-hidden scrollbar-hide"
225
488
  ),
226
489
  children: [
227
- /* @__PURE__ */ i(
228
- X,
490
+ /* @__PURE__ */ i(Y.Provider, { value: null, children: !W && ((j = (z = l == null ? void 0 : l.selectedItems) == null ? void 0 : z.items) == null ? void 0 : j.map((t) => /* @__PURE__ */ M(
491
+ "span",
229
492
  {
230
- placeholder: l,
231
- onKeyDown: p,
232
- onMouseDown: g,
233
- readOnly: c,
234
- className: w(
235
- "w-full flex-[1_0_0] appearance-none bg-transparent text-ellipsis text-primary caret-alpha-black/90 outline-none placeholder:text-placeholder_subtle focus:outline-hidden disabled:cursor-not-allowed disabled:text-disabled disabled:placeholder:text-disabled",
236
- c && "cursor-default",
237
- se[(s == null ? void 0 : s.size) || "sm"]
238
- )
239
- }
240
- ),
241
- b && /* @__PURE__ */ i(
493
+ "data-multiselect-chip": !0,
494
+ className: D(
495
+ "flex items-center rounded-md bg-primary py-0.5 pr-1 pl-1.25 ring-1 ring-[var(--color-gray-100)] ring-inset",
496
+ !a && "shrink-0",
497
+ l == null ? void 0 : l.chipClassName
498
+ ),
499
+ children: [
500
+ /* @__PURE__ */ M(
501
+ "span",
502
+ {
503
+ className: "flex min-w-0 items-center",
504
+ onMouseDown: p,
505
+ children: [
506
+ (l == null ? void 0 : l.showAvatar) && /* @__PURE__ */ i(
507
+ Fe,
508
+ {
509
+ size: "xxs",
510
+ alt: t == null ? void 0 : t.label,
511
+ src: t == null ? void 0 : t.avatarUrl,
512
+ initials: t == null ? void 0 : t.initials
513
+ }
514
+ ),
515
+ /* @__PURE__ */ i("p", { className: "ml-1.25 truncate text-xs font-medium whitespace-nowrap text-secondary select-none", children: t == null ? void 0 : t.label })
516
+ ]
517
+ }
518
+ ),
519
+ /* @__PURE__ */ i(
520
+ Pe,
521
+ {
522
+ size: "md",
523
+ isDisabled: o,
524
+ preventFocusOnPress: !a,
525
+ className: "ml-0.75",
526
+ onKeyDown: (R) => y(R, t.id),
527
+ onPress: () => l.onRemove(/* @__PURE__ */ new Set([t.id]))
528
+ }
529
+ )
530
+ ]
531
+ },
532
+ t.id
533
+ ))) }),
534
+ /* @__PURE__ */ M(
242
535
  "div",
243
536
  {
244
- "aria-hidden": "true",
245
- className: w(
246
- "absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8",
247
- h
537
+ className: D(
538
+ "relative flex flex-1 flex-row items-center",
539
+ a ? "min-w-[20%]" : "min-w-0",
540
+ !W && "ml-0.5",
541
+ b && "min-w-[30%]"
248
542
  ),
249
- children: /* @__PURE__ */ i(
250
- "span",
251
- {
252
- className: w(
253
- "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
254
- f && "bg-transparent text-disabled"
255
- ),
256
- children: I(["meta"], "K")
257
- }
258
- )
543
+ children: [
544
+ /* @__PURE__ */ i(
545
+ Te,
546
+ {
547
+ ref: k,
548
+ placeholder: W ? m : void 0,
549
+ onKeyDown: S,
550
+ onMouseDown: P,
551
+ onFocus: O,
552
+ readOnly: s || h,
553
+ className: D(
554
+ "w-full min-w-0 flex-[1_0_0] appearance-none bg-transparent text-ellipsis text-primary caret-alpha-black/90 outline-none placeholder:text-placeholder_subtle focus:outline-hidden disabled:cursor-not-allowed disabled:text-disabled disabled:placeholder:text-disabled",
555
+ s && "cursor-default",
556
+ Z[(l == null ? void 0 : l.size) || "sm"]
557
+ )
558
+ }
559
+ ),
560
+ b && /* @__PURE__ */ i(
561
+ "div",
562
+ {
563
+ "aria-hidden": "true",
564
+ className: D(
565
+ "absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8",
566
+ u
567
+ ),
568
+ children: /* @__PURE__ */ i(
569
+ "span",
570
+ {
571
+ className: D(
572
+ "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
573
+ o && "bg-transparent text-disabled"
574
+ ),
575
+ children: Le(["meta"], "K")
576
+ }
577
+ )
578
+ }
579
+ )
580
+ ]
259
581
  }
260
582
  )
261
583
  ]
262
584
  }
585
+ ),
586
+ !a && r && /* @__PURE__ */ i(
587
+ "div",
588
+ {
589
+ "aria-hidden": !0,
590
+ className: "pointer-events-none absolute inset-y-0 right-0 z-[8] w-6 bg-linear-to-r from-transparent via-primary/40 to-primary"
591
+ }
263
592
  )
264
593
  ] });
265
- }, ae = ({
266
- size: f,
594
+ }, Ge = ({
595
+ size: o,
267
596
  shortcut: b,
268
- placeholder: h,
269
- shortcutClassName: l,
270
- placeholderIcon: c = null,
271
- readOnly: t = !1,
272
- // Omit this prop to avoid invalid HTML attribute warning
273
- isDisabled: s,
274
- ...d
275
- }) => /* @__PURE__ */ i(
276
- H,
277
- {
278
- ...d,
279
- className: ({ isFocusWithin: p, isDisabled: g }) => w(
280
- "relative flex w-full items-center gap-2 rounded-lg bg-primary shadow-xs ring-1 ring-[var(--color-border-secondary)] outline-hidden transition duration-100 ease-linear ring-inset",
281
- g && "cursor-not-allowed bg-disabled_subtle",
282
- p && "ring-2 ring-brand",
283
- Z[f].root
284
- ),
285
- children: ({ isDisabled: p }) => /* @__PURE__ */ N(L, { children: [
286
- c && /* @__PURE__ */ i(c, { className: "pointer-events-none size-5 text-fg-quaternary" }),
287
- /* @__PURE__ */ i(V, { contain: !1, autoFocus: !1, restoreFocus: !1, children: /* @__PURE__ */ i(
288
- ie,
289
- {
290
- isDisabled: p,
291
- size: f,
292
- shortcut: b,
293
- shortcutClassName: l,
294
- placeholder: h,
295
- readOnly: t
597
+ placeholder: u,
598
+ shortcutClassName: m,
599
+ placeholderIcon: s = null,
600
+ readOnly: x = !1,
601
+ isDisabled: k,
602
+ isInvalid: f,
603
+ ref: l,
604
+ endAdornment: e,
605
+ ...a
606
+ }) => {
607
+ const g = U(null), r = q(G), F = q(Y), T = F && typeof F == "object" && "ref" in F ? F.ref : void 0, _ = Q(
608
+ () => We(l ?? void 0, T ?? void 0),
609
+ [l, T]
610
+ ), K = L(
611
+ (c) => {
612
+ var S, h;
613
+ if (k)
614
+ return;
615
+ const p = c.target;
616
+ if (p instanceof Element && !p.closest("button")) {
617
+ if (x) {
618
+ if (p.closest("input") || p.closest("[data-multiselect-chip]"))
619
+ return;
620
+ c.preventDefault(), r != null && r.isOpen ? (r.close(), (S = g.current) == null || S.blur()) : r == null || r.open();
621
+ return;
296
622
  }
297
- ) })
298
- ] })
299
- }
300
- ), le = re;
301
- le.Item = B;
623
+ p.closest("input") || (c.preventDefault(), (h = g.current) == null || h.focus({ preventScroll: !0 }));
624
+ }
625
+ },
626
+ [k, x, r]
627
+ );
628
+ return /* @__PURE__ */ i(
629
+ ke,
630
+ {
631
+ ...a,
632
+ ref: _,
633
+ onMouseDown: (c) => {
634
+ var p;
635
+ c.stopPropagation(), (p = a.onMouseDown) == null || p.call(a, c);
636
+ },
637
+ onPointerDown: (c) => {
638
+ var p;
639
+ c.stopPropagation(), (p = a.onPointerDown) == null || p.call(a, c);
640
+ },
641
+ onMouseDownCapture: (c) => {
642
+ var p;
643
+ (p = a.onMouseDownCapture) == null || p.call(a, c), K(c);
644
+ },
645
+ className: ({ isFocusWithin: c, isDisabled: p }) => {
646
+ const S = c || !!(r != null && r.isOpen);
647
+ return D(
648
+ "relative flex w-full gap-2 rounded-md bg-primary ring-1 outline-hidden duration-100 ease-linear ring-inset",
649
+ f ? "ring-error" : c ? "ring-brand" : "ring-[var(--color-border-secondary)]",
650
+ p && "cursor-not-allowed bg-disabled_subtle",
651
+ S ? "items-start" : "items-center",
652
+ S ? _e[o] : Ee[o].root
653
+ );
654
+ },
655
+ children: ({ isDisabled: c, isFocusWithin: p }) => /* @__PURE__ */ M(de, { children: [
656
+ s && /* @__PURE__ */ i(s, { className: "pointer-events-none size-5 shrink-0 text-fg-quaternary" }),
657
+ /* @__PURE__ */ i(we, { contain: !1, autoFocus: !1, restoreFocus: !1, children: /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ i(
658
+ Ue,
659
+ {
660
+ inputRef: g,
661
+ isDisabled: c,
662
+ isFocusWithin: p,
663
+ shortcut: b,
664
+ shortcutClassName: m,
665
+ placeholder: u,
666
+ readOnly: x
667
+ }
668
+ ) }) }),
669
+ e ? /* @__PURE__ */ i(Y.Provider, { value: null, children: /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center self-center", children: e }) }) : null,
670
+ /* @__PURE__ */ i(
671
+ "button",
672
+ {
673
+ type: "button",
674
+ tabIndex: -1,
675
+ disabled: c,
676
+ "aria-label": r != null && r.isOpen ? "Close options" : "Open options",
677
+ className: "shrink-0 self-center rounded p-0.5 text-fg-quaternary hover:text-fg-secondary disabled:cursor-not-allowed disabled:opacity-50",
678
+ onMouseDown: (S) => {
679
+ var h, P;
680
+ S.preventDefault(), S.stopPropagation(), r != null && r.isOpen ? (r.close(), (h = g.current) == null || h.blur()) : (r == null || r.open(), (P = g.current) == null || P.focus({ preventScroll: !0 }));
681
+ },
682
+ children: /* @__PURE__ */ i(
683
+ xe,
684
+ {
685
+ "aria-hidden": "true",
686
+ className: o === "lg" ? "size-5" : "size-4"
687
+ }
688
+ )
689
+ }
690
+ )
691
+ ] })
692
+ }
693
+ );
694
+ }, Xe = $e;
695
+ Xe.Item = ze;
302
696
  export {
303
- le as MultiSelect,
304
- re as MultiSelectBase,
305
- ae as MultiSelectTagsValue
697
+ Xe as MultiSelect,
698
+ $e as MultiSelectBase,
699
+ Ge as MultiSelectTagsValue
306
700
  };