@pibit.ai/cure-design-system 0.3.21 → 0.3.24

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 (68) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +157 -136
  4. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  5. package/dist/patterns/table/TableWrapper.js +330 -323
  6. package/dist/patterns/table/index.d.ts +5 -2
  7. package/dist/patterns/table/index.d.ts.map +1 -1
  8. package/dist/patterns/table/integrateTableUndoRedo.d.ts +41 -0
  9. package/dist/patterns/table/integrateTableUndoRedo.d.ts.map +1 -0
  10. package/dist/patterns/table/integrateTableUndoRedo.js +63 -0
  11. package/dist/patterns/table/storyHelpers/useMockTableState.d.ts +3 -1
  12. package/dist/patterns/table/storyHelpers/useMockTableState.d.ts.map +1 -1
  13. package/dist/patterns/table/table.d.ts +2 -1
  14. package/dist/patterns/table/table.d.ts.map +1 -1
  15. package/dist/patterns/table/table.js +181 -155
  16. package/dist/patterns/table/tableUndoRedo.d.ts +38 -0
  17. package/dist/patterns/table/tableUndoRedo.d.ts.map +1 -0
  18. package/dist/patterns/table/tableUndoRedo.js +147 -0
  19. package/dist/patterns/table/toolbar/AlignDropdown.d.ts.map +1 -1
  20. package/dist/patterns/table/toolbar/AlignDropdown.js +5 -11
  21. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts +4 -0
  22. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts.map +1 -1
  23. package/dist/patterns/table/toolbar/ColumnHeaderMenu.js +81 -77
  24. package/dist/patterns/table/toolbar/GroupByDropdown.d.ts.map +1 -1
  25. package/dist/patterns/table/toolbar/GroupByDropdown.js +48 -43
  26. package/dist/patterns/table/toolbar/TableToolbar.d.ts +12 -1
  27. package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
  28. package/dist/patterns/table/toolbar/TableToolbar.js +164 -114
  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 +116 -116
  34. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts +9 -0
  35. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts.map +1 -0
  36. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.js +21 -0
  37. package/dist/patterns/table/types.d.ts +5 -1
  38. package/dist/patterns/table/types.d.ts.map +1 -1
  39. package/dist/patterns/table/useTableUndoRedo.d.ts +41 -0
  40. package/dist/patterns/table/useTableUndoRedo.d.ts.map +1 -0
  41. package/dist/patterns/table/useTableUndoRedo.js +168 -0
  42. package/dist/primitives/badge/badge.js +5 -5
  43. package/dist/primitives/input/input.d.ts +1 -1
  44. package/dist/primitives/input/input.d.ts.map +1 -1
  45. package/dist/primitives/input/input.js +63 -62
  46. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts +20 -0
  47. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts.map +1 -0
  48. package/dist/primitives/multi-chips-select/MultiChipsSelect.js +233 -0
  49. package/dist/primitives/multi-chips-select/index.d.ts +3 -0
  50. package/dist/primitives/multi-chips-select/index.d.ts.map +1 -0
  51. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts +3 -0
  52. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts.map +1 -0
  53. package/dist/primitives/multi-chips-select/tagKeyFromLabel.js +6 -0
  54. package/dist/primitives/select/ExpandableSearchInput.d.ts +3 -1
  55. package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
  56. package/dist/primitives/select/ExpandableSearchInput.js +100 -78
  57. package/dist/primitives/select/SearchInput.d.ts +5 -1
  58. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  59. package/dist/primitives/select/SearchInput.js +101 -80
  60. package/dist/primitives/select/combobox.d.ts.map +1 -1
  61. package/dist/primitives/select/combobox.js +48 -47
  62. package/dist/primitives/select/multi-select.d.ts.map +1 -1
  63. package/dist/primitives/select/multi-select.js +50 -49
  64. package/dist/styles/components.css +1 -1
  65. package/dist/utils/keyboard-shortcut.d.ts +4 -0
  66. package/dist/utils/keyboard-shortcut.d.ts.map +1 -0
  67. package/dist/utils/keyboard-shortcut.js +29 -0
  68. package/package.json +1 -1
@@ -15,27 +15,27 @@ const y = {
15
15
  addonButton: "hover:bg-utility-gray-100 text-utility-gray-400 hover:text-utility-gray-500"
16
16
  },
17
17
  brand: {
18
- root: "bg-utility-brand-50 text-utility-brand-600 ring-utility-brand-50",
18
+ root: "bg-utility-brand-50 text-utility-brand-700 ring-utility-brand-50",
19
19
  addon: "text-utility-brand-500",
20
20
  addonButton: "hover:bg-utility-brand-100 text-utility-brand-400 hover:text-utility-brand-500"
21
21
  },
22
22
  error: {
23
- root: "bg-utility-error-100 text-utility-error-700 ring-utility-error-100",
23
+ root: "bg-utility-error-50 text-utility-error-700 ring-utility-error-50",
24
24
  addon: "text-utility-error-500",
25
25
  addonButton: "hover:bg-utility-error-100 text-utility-error-400 hover:text-utility-error-500"
26
26
  },
27
27
  warning: {
28
- root: "bg-utility-warning-100 text-utility-warning-700 ring-utility-warning-100",
28
+ root: "bg-utility-warning-50 text-utility-warning-700 ring-utility-warning-50",
29
29
  addon: "text-utility-warning-500",
30
30
  addonButton: "hover:bg-utility-warning-100 text-utility-warning-400 hover:text-utility-warning-500"
31
31
  },
32
32
  success: {
33
- root: "bg-utility-success-100 text-utility-success-700 ring-utility-success-100",
33
+ root: "bg-utility-success-50 text-utility-success-700 ring-utility-success-50",
34
34
  addon: "text-utility-success-500",
35
35
  addonButton: "hover:bg-utility-success-100 text-utility-success-400 hover:text-utility-success-500"
36
36
  },
37
37
  "gray-blue": {
38
- root: "bg-utility-gray-blue-100 text-utility-gray-blue-700 ring-utility-gray-blue-100",
38
+ root: "bg-utility-gray-blue-100 text-utility-gray-blue-500 ring-utility-gray-blue-100",
39
39
  addon: "text-utility-gray-blue-500",
40
40
  addonButton: "hover:bg-utility-gray-blue-100 text-utility-gray-blue-400 hover:text-utility-gray-blue-500"
41
41
  },
@@ -20,7 +20,7 @@ export interface InputBaseProps extends TextFieldProps {
20
20
  wrapperClassName?: string;
21
21
  /** Class name for the tooltip. */
22
22
  tooltipClassName?: string;
23
- /** Keyboard shortcut to display. */
23
+ /** Keyboard shortcut to display. When `true`, shows the platform-specific primary shortcut hint (⌘K on Apple platforms, Ctrl+K elsewhere). */
24
24
  shortcut?: string | boolean;
25
25
  ref?: Ref<HTMLInputElement>;
26
26
  groupRef?: Ref<HTMLDivElement>;
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/primitives/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,IAAI,kBAAkB,EACrC,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAqB3E,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,+CAA+C;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oCAAo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AC;IAC3B,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK;qUAyBf,UAAU;;CA+EZ,CAAC"}
@@ -1,33 +1,34 @@
1
- import { jsx as r, jsxs as R, Fragment as Y } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as S, Fragment as Y } from "react/jsx-runtime";
2
2
  import { TextField as Z, Group as A, Input as W } from "react-aria-components";
3
3
  import { cx as i, sortCx as D } from "../../utils/cn.js";
4
- import { useState as P, createContext as ee, useContext as re, useEffect as ae } from "react";
4
+ import { useState as O, createContext as ee, useContext as re, useEffect as ae } from "react";
5
5
  import { HintText as V } from "./hint-text.js";
6
- import { EyeOff as te, Eye as ie, XClose as se, HelpCircle as ne, InfoCircle as le } from "@untitledui/icons";
6
+ import { EyeOff as te, Eye as ie, XClose as le, HelpCircle as se, InfoCircle as ne } from "@untitledui/icons";
7
7
  import { Label as oe } from "./label.js";
8
8
  import { Tooltip as de, TooltipTrigger as pe } from "../tooltip/tooltip.js";
9
- import { Badge as ue } from "../badge/badge.js";
9
+ import { getPlatformShortcutLabel as ue } from "../../utils/keyboard-shortcut.js";
10
+ import { Badge as ge } from "../badge/badge.js";
10
11
  const G = {
11
12
  sm: "text-xs",
12
13
  md: "text-sm",
13
14
  lg: "text-md"
14
- }, ge = {
15
+ }, me = {
15
16
  sm: "text-xs",
16
17
  md: "text-xs",
17
18
  lg: "text-sm"
18
19
  }, I = ({
19
20
  ref: d,
20
21
  isReadOnly: c,
21
- tooltip: y,
22
+ tooltip: h,
22
23
  shortcut: N,
23
24
  groupRef: C,
24
25
  size: _ = "sm",
25
- isInvalid: h,
26
+ isInvalid: y,
26
27
  isDisabled: o,
27
28
  icon: b,
28
29
  iconTrailing: v,
29
30
  placeholder: B,
30
- wrapperClassName: S,
31
+ wrapperClassName: R,
31
32
  tooltipClassName: j,
32
33
  inputClassName: k,
33
34
  iconClassName: L,
@@ -39,7 +40,7 @@ const G = {
39
40
  customStyles: E,
40
41
  ...F
41
42
  }) => {
42
- const z = y || h || v || T, q = b, [f, p] = P([]), [x, w] = P(""), e = re(X), s = (e == null ? void 0 : e.size) || _, n = D({
43
+ const z = h || y || v || T, q = b, [f, p] = O([]), [x, w] = O(""), e = re(X), l = (e == null ? void 0 : e.size) || _, s = D({
43
44
  sm: {
44
45
  root: i(
45
46
  "p-2 h-8",
@@ -85,15 +86,15 @@ const G = {
85
86
  tag: "rounded-md bg-primary border border-secondary p-2.5",
86
87
  wrapper: "rounded-lg"
87
88
  }
88
- }), $ = () => {
89
+ }), P = () => {
89
90
  var t;
90
91
  const a = x.trim();
91
92
  a && ((t = e == null ? void 0 : e.onChange) == null || t.call(
92
93
  e,
93
94
  e != null && e.value ? (e == null ? void 0 : e.value) + "," + a : a
94
- ), p((l) => [...l, a]), w(""));
95
+ ), p((n) => [...n, a]), w(""));
95
96
  }, M = (a) => {
96
- var t, l, K;
97
+ var t, n, $;
97
98
  if (m === "tag") {
98
99
  if (a.key === "Enter" || a.key === ",") {
99
100
  a.preventDefault();
@@ -101,22 +102,22 @@ const G = {
101
102
  u && ((t = e == null ? void 0 : e.onChange) == null || t.call(
102
103
  e,
103
104
  e != null && e.value ? (e == null ? void 0 : e.value) + "," + u : u
104
- ), p((O) => [...O, u]), w(""));
105
+ ), p((K) => [...K, u]), w(""));
105
106
  }
106
107
  if (a.key === "Backspace" && !x)
107
108
  if (e != null && e.value) {
108
- const u = e.value.split(",").map((O) => O.trim()).filter(Boolean);
109
- u.pop(), (l = e.onChange) == null || l.call(e, u.join(", "));
109
+ const u = e.value.split(",").map((K) => K.trim()).filter(Boolean);
110
+ u.pop(), (n = e.onChange) == null || n.call(e, u.join(", "));
110
111
  } else
111
- (K = e == null ? void 0 : e.onChange) == null || K.call(e, "");
112
+ ($ = e == null ? void 0 : e.onChange) == null || $.call(e, "");
112
113
  }
113
114
  }, Q = (a) => {
114
115
  const t = a.target.value;
115
116
  m === "tag" && w(t);
116
117
  }, U = (a) => {
117
- var l;
118
- const t = f.filter((K, u) => u !== a);
119
- p(t), (l = e == null ? void 0 : e.onChange) == null || l.call(e, t.join(", "));
118
+ var n;
119
+ const t = f.filter(($, u) => u !== a);
120
+ p(t), (n = e == null ? void 0 : e.onChange) == null || n.call(e, t.join(", "));
120
121
  };
121
122
  return ae(() => {
122
123
  if (m === "tag")
@@ -125,27 +126,27 @@ const G = {
125
126
  p(a);
126
127
  } else
127
128
  p([]);
128
- }, [e == null ? void 0 : e.value]), /* @__PURE__ */ R(
129
+ }, [e == null ? void 0 : e.value]), /* @__PURE__ */ S(
129
130
  A,
130
131
  {
131
132
  isDisabled: o,
132
- isInvalid: h,
133
+ isInvalid: y,
133
134
  ref: C,
134
- className: ({ isFocusWithin: a, isDisabled: t, isInvalid: l }) => i(
135
+ className: ({ isFocusWithin: a, isDisabled: t, isInvalid: n }) => i(
135
136
  "relative flex w-full flex-row place-content-center place-items-center bg-primary border border-secondary duration-100 ease-linear",
136
137
  a && !t && !c && "ring-1 ring-brand",
137
138
  // Disabled state styles
138
139
  t && "cursor-not-allowed bg-disabled_subtle ring-disabled",
139
140
  "group-disabled:cursor-not-allowed group-disabled:bg-disabled_subtle group-disabled:ring-disabled",
140
141
  // Invalid state styles
141
- l && "ring-error_subtle",
142
+ n && "ring-error_subtle",
142
143
  "group-invalid:ring-error_subtle",
143
144
  // Invalid state with focus-within styles
144
- l && a && "ring-2 ring-error",
145
+ n && a && "ring-2 ring-error",
145
146
  a && "group-invalid:ring-2 group-invalid:ring-error",
146
147
  e == null ? void 0 : e.wrapperClassName,
147
- S,
148
- n[s].wrapper
148
+ R,
149
+ s[l].wrapper
149
150
  ),
150
151
  children: [
151
152
  b && /* @__PURE__ */ r(
@@ -154,13 +155,13 @@ const G = {
154
155
  className: i(
155
156
  "pointer-events-none absolute size-5 text-fg-quaternary",
156
157
  o && "text-fg-disabled",
157
- n[s].iconLeading,
158
+ s[l].iconLeading,
158
159
  e == null ? void 0 : e.iconClassName,
159
160
  L
160
161
  )
161
162
  }
162
163
  ),
163
- m === "tag" && /* @__PURE__ */ R(
164
+ m === "tag" && /* @__PURE__ */ S(
164
165
  "div",
165
166
  {
166
167
  className: i(
@@ -170,10 +171,10 @@ const G = {
170
171
  children: [
171
172
  f.map((a, t) => (
172
173
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
173
- /* @__PURE__ */ r("div", { onClick: (l) => l.stopPropagation(), children: /* @__PURE__ */ R(ue, { className: "rounded-md bg-primary border border-secondary px-2 py-1 pointer-events-auto!", children: [
174
+ /* @__PURE__ */ r("div", { onClick: (n) => n.stopPropagation(), children: /* @__PURE__ */ S(ge, { className: "rounded-md bg-primary border border-secondary px-2 py-1 pointer-events-auto!", children: [
174
175
  a,
175
176
  /* @__PURE__ */ r(
176
- se,
177
+ le,
177
178
  {
178
179
  className: "size-4 cursor-pointer text-fg-quaternary hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
179
180
  onClick: () => U(t)
@@ -190,12 +191,12 @@ const G = {
190
191
  onKeyDown: M,
191
192
  placeholder: f.length === 0 ? B : "",
192
193
  disabled: o,
193
- onBlur: $,
194
+ onBlur: P,
194
195
  className: i(
195
196
  "bg-transparent outline-none flex-1 min-w-[50px] w-full text-primary placeholder:text-placeholder_subtle",
196
197
  o && "cursor-not-allowed text-disabled",
197
- n[s].root,
198
- G[s],
198
+ s[l].root,
199
+ G[l],
199
200
  k
200
201
  )
201
202
  }
@@ -212,8 +213,8 @@ const G = {
212
213
  className: i(
213
214
  "m-0 w-full bg-transparent text-primary ring-0 outline-hidden placeholder:text-placeholder_subtle autofill:rounded-lg autofill:text-primary",
214
215
  o && "cursor-not-allowed text-disabled",
215
- n[s].root,
216
- G[s],
216
+ s[l].root,
217
+ G[l],
217
218
  e == null ? void 0 : e.inputClassName,
218
219
  k
219
220
  ),
@@ -225,30 +226,30 @@ const G = {
225
226
  {
226
227
  className: i(
227
228
  "absolute flex items-center justify-center",
228
- n[s].iconTrailing,
229
- n[s].trailingIconCount
229
+ s[l].iconTrailing,
230
+ s[l].trailingIconCount
230
231
  ),
231
232
  children: T
232
233
  }
233
234
  ),
234
- y && !h && /* @__PURE__ */ r(de, { title: y, placement: "top", children: /* @__PURE__ */ r(
235
+ h && !y && /* @__PURE__ */ r(de, { title: h, placement: "top", children: /* @__PURE__ */ r(
235
236
  pe,
236
237
  {
237
238
  className: i(
238
239
  "absolute cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
239
- n[s].iconTrailing,
240
+ s[l].iconTrailing,
240
241
  e == null ? void 0 : e.tooltipClassName,
241
242
  j
242
243
  ),
243
- children: /* @__PURE__ */ r(ne, { className: "size-4" })
244
+ children: /* @__PURE__ */ r(se, { className: "size-4" })
244
245
  }
245
246
  ) }),
246
- h && /* @__PURE__ */ r(
247
- le,
247
+ y && /* @__PURE__ */ r(
248
+ ne,
248
249
  {
249
250
  className: i(
250
251
  "pointer-events-none absolute size-4 text-fg-error-secondary",
251
- n[s].iconTrailing,
252
+ s[l].iconTrailing,
252
253
  e == null ? void 0 : e.tooltipClassName,
253
254
  j
254
255
  )
@@ -259,7 +260,7 @@ const G = {
259
260
  {
260
261
  className: i(
261
262
  "pointer-events-none absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent pl-8",
262
- n[s].shortcut
263
+ s[l].shortcut
263
264
  ),
264
265
  children: /* @__PURE__ */ r(
265
266
  "span",
@@ -269,7 +270,7 @@ const G = {
269
270
  o && "bg-transparent text-disabled"
270
271
  ),
271
272
  "aria-hidden": "true",
272
- children: typeof N == "string" ? N : "K"
273
+ children: typeof N == "string" ? N : ue(["meta"], "K")
273
274
  }
274
275
  )
275
276
  }
@@ -280,7 +281,7 @@ const G = {
280
281
  className: i(
281
282
  "pointer-events-none absolute size-5 text-fg-quaternary",
282
283
  o && "text-fg-disabled",
283
- n[s].iconTrailing,
284
+ s[l].iconTrailing,
284
285
  e == null ? void 0 : e.iconClassName,
285
286
  L
286
287
  )
@@ -296,26 +297,26 @@ const X = ee({}), J = ({ className: d, ...c }) => /* @__PURE__ */ r(X.Provider,
296
297
  {
297
298
  ...c,
298
299
  "data-input-wrapper": !0,
299
- className: (y) => i(
300
+ className: (h) => i(
300
301
  "group flex h-max w-full flex-col items-start justify-start gap-1.5",
301
- typeof d == "function" ? d(y) : d
302
+ typeof d == "function" ? d(h) : d
302
303
  )
303
304
  }
304
305
  ) });
305
306
  J.displayName = "TextField";
306
- const me = ({
307
+ const fe = ({
307
308
  size: d = "sm",
308
309
  placeholder: c,
309
- icon: y,
310
+ icon: h,
310
311
  iconTrailing: N,
311
312
  label: C,
312
313
  supportingText: _,
313
- hint: h,
314
+ hint: y,
314
315
  shortcut: o,
315
316
  hideRequiredIndicator: b,
316
317
  className: v,
317
318
  ref: B,
318
- groupRef: S,
319
+ groupRef: R,
319
320
  tooltip: j,
320
321
  iconClassName: k,
321
322
  inputClassName: L,
@@ -329,7 +330,7 @@ const me = ({
329
330
  mode: q,
330
331
  ...f
331
332
  }) => {
332
- const [p, x] = P(!1), w = m === "password", e = w ? p ? "text" : "password" : m, s = f == null ? void 0 : f.isReadOnly;
333
+ const [p, x] = O(!1), w = m === "password", e = w ? p ? "text" : "password" : m, l = f == null ? void 0 : f.isReadOnly;
333
334
  return /* @__PURE__ */ r(
334
335
  J,
335
336
  {
@@ -337,12 +338,12 @@ const me = ({
337
338
  "aria-label": C ? void 0 : c,
338
339
  ...f,
339
340
  className: v,
340
- children: ({ isRequired: n, isInvalid: $ }) => /* @__PURE__ */ R(Y, { children: [
341
+ children: ({ isRequired: s, isInvalid: P }) => /* @__PURE__ */ S(Y, { children: [
341
342
  C && /* @__PURE__ */ r(
342
343
  oe,
343
344
  {
344
- className: i("color-text-label", ge[d]),
345
- isRequired: b ? !b : n,
345
+ className: i("color-text-label", me[d]),
346
+ isRequired: b ? !b : s,
346
347
  children: C
347
348
  }
348
349
  ),
@@ -351,11 +352,11 @@ const me = ({
351
352
  I,
352
353
  {
353
354
  ref: B,
354
- groupRef: S,
355
+ groupRef: R,
355
356
  size: d,
356
357
  placeholder: c,
357
- isReadOnly: s,
358
- icon: y,
358
+ isReadOnly: l,
359
+ icon: h,
359
360
  iconTrailing: N,
360
361
  shortcut: o,
361
362
  iconClassName: k,
@@ -378,14 +379,14 @@ const me = ({
378
379
  trailingIconCount: z
379
380
  }
380
381
  ),
381
- h && /* @__PURE__ */ r(V, { size: d, isInvalid: $, children: h })
382
+ y && /* @__PURE__ */ r(V, { size: d, isInvalid: P, children: y })
382
383
  ] })
383
384
  }
384
385
  );
385
386
  };
386
- me.displayName = "Input";
387
+ fe.displayName = "Input";
387
388
  export {
388
- me as Input,
389
+ fe as Input,
389
390
  I as InputBase,
390
391
  J as TextField
391
392
  };
@@ -0,0 +1,20 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ export interface SelectOption {
3
+ id: string;
4
+ label: string;
5
+ }
6
+ export interface MultiChipsSelectProps {
7
+ loading?: boolean;
8
+ options: SelectOption[];
9
+ selectedValues: SelectOption[];
10
+ onChange: Dispatch<SetStateAction<SelectOption[]>>;
11
+ /** Renders above the control (e.g. "Add document tags"). */
12
+ fieldLabel?: string;
13
+ placeholder?: string;
14
+ /** Invoked when the user chooses **Create "…"**; parent decides persistence / options refresh. */
15
+ onAddOption?: (label: string, key: string) => Promise<void>;
16
+ isDisabled?: boolean;
17
+ isSearchable?: boolean;
18
+ }
19
+ export declare function MultiChipsSelect({ loading, options, selectedValues, onChange, fieldLabel, placeholder, onAddOption, isDisabled, isSearchable, }: MultiChipsSelectProps): import("react/jsx-runtime").JSX.Element;
20
+ //# sourceMappingURL=MultiChipsSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiChipsSelect.d.ts","sourceRoot":"","sources":["../../../src/primitives/multi-chips-select/MultiChipsSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EAGb,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAMf,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACnD,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAoBD,wBAAgB,gBAAgB,CAAC,EAC/B,OAAe,EACf,OAAO,EACP,cAAc,EACd,QAAQ,EACR,UAAU,EACV,WAAmC,EACnC,WAAW,EACX,UAAkB,EAClB,YAAmB,GACpB,EAAE,qBAAqB,2CAoSvB"}
@@ -0,0 +1,233 @@
1
+ import { jsxs as m, jsx as o, Fragment as X } from "react/jsx-runtime";
2
+ import { useState as E, useRef as z, useMemo as I, useCallback as $, useEffect as q } from "react";
3
+ import { XClose as G, ChevronDown as H } from "@untitledui/icons";
4
+ import { LoadingIndicator as J } from "../../applications/loading-indicator/loading-indicator.js";
5
+ import { cx as F } from "../../utils/cn.js";
6
+ import { tagKeyFromLabel as K } from "./tagKeyFromLabel.js";
7
+ function _(f, l) {
8
+ const n = l.trim().toLowerCase();
9
+ return n ? f.some((d) => d.label.trim().toLowerCase() === n) : !1;
10
+ }
11
+ function A(f, l) {
12
+ const n = l.trim().toLowerCase();
13
+ if (!n) return !1;
14
+ const d = K(l);
15
+ return f.some(
16
+ (g) => g.label.trim().toLowerCase() === n || g.id === d
17
+ );
18
+ }
19
+ function re({
20
+ loading: f = !1,
21
+ options: l,
22
+ selectedValues: n,
23
+ onChange: d,
24
+ fieldLabel: g,
25
+ placeholder: O = "Search or add tags…",
26
+ onAddOption: w,
27
+ isDisabled: t = !1,
28
+ isSearchable: Q = !0
29
+ }) {
30
+ const [x, s] = E(!1), [N, S] = E(""), [i, p] = E(0), C = z(null), h = z(null), c = N.trim(), v = c.toLowerCase(), k = I(() => {
31
+ const e = new Set(n.map((r) => r.id));
32
+ return l.filter((r) => !e.has(r.id));
33
+ }, [l, n]), a = I(() => v ? k.filter(
34
+ (e) => e.label.toLowerCase().includes(v)
35
+ ) : k, [k, v]), y = I(() => !(!c || t || _(l, c) || A(n, c)), [c, l, n, t]), L = $(() => {
36
+ s(!1);
37
+ }, []), b = a.length + (y ? 1 : 0);
38
+ q(() => {
39
+ p(0);
40
+ }, [v, a.length, y]), q(() => {
41
+ x || p(0);
42
+ }, [x]), q(() => {
43
+ const e = (r) => {
44
+ C.current && !C.current.contains(r.target) && L();
45
+ };
46
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
47
+ }, [L]);
48
+ const M = (e) => {
49
+ n.some((r) => r.id === e.id) || (d((r) => [...r, e]), S(""), s(!0), p(0));
50
+ }, R = async () => {
51
+ if (!c || t || f) return;
52
+ const e = K(c), r = c.replace(/\s+/g, " ").trim();
53
+ _(l, r) || A(n, r) || (await (w == null ? void 0 : w(r, e)), M({ id: e, label: r }));
54
+ }, T = (e) => {
55
+ d(n.filter((r) => r.id !== e));
56
+ }, B = () => {
57
+ t || (s(!0), requestAnimationFrame(() => {
58
+ var e;
59
+ return (e = h.current) == null ? void 0 : e.focus();
60
+ }));
61
+ }, P = (e) => {
62
+ if (t) return;
63
+ const r = e.target;
64
+ if (!r.closest("button[data-chip-remove]")) {
65
+ if (h.current && (r === h.current || h.current.contains(r))) {
66
+ x || s(!0);
67
+ return;
68
+ }
69
+ e.preventDefault(), B();
70
+ }
71
+ }, U = (e) => {
72
+ var r;
73
+ if (e.key === "Escape") {
74
+ L(), (r = h.current) == null || r.blur();
75
+ return;
76
+ }
77
+ if (e.key === "ArrowDown" && !t && b > 0) {
78
+ e.preventDefault(), s(!0), p((u) => u < 0 ? 0 : u < b - 1 ? u + 1 : u);
79
+ return;
80
+ }
81
+ if (e.key === "ArrowUp" && !t && b > 0) {
82
+ e.preventDefault(), s(!0), p((u) => u <= 0 ? 0 : u - 1);
83
+ return;
84
+ }
85
+ if (e.key === "Enter") {
86
+ x && !t && i >= 0 && i < b && (e.preventDefault(), y && i === a.length ? R() : i < a.length && M(a[i]));
87
+ return;
88
+ }
89
+ e.key === "Backspace" && !N && n.length > 0 && (e.preventDefault(), d(n.slice(0, -1)));
90
+ }, j = x && !t && (a.length > 0 || y);
91
+ return /* @__PURE__ */ m("div", { ref: C, className: "relative w-full", children: [
92
+ g ? /* @__PURE__ */ o("span", { className: "mb-1.5 block text-xs font-medium text-secondary", children: g }) : null,
93
+ /* @__PURE__ */ m(
94
+ "div",
95
+ {
96
+ role: "combobox",
97
+ "aria-expanded": j,
98
+ "aria-haspopup": "listbox",
99
+ "aria-disabled": t,
100
+ onMouseDown: P,
101
+ className: F(
102
+ "flex min-h-9 w-full flex-wrap items-center gap-1 rounded-md border border-secondary bg-primary px-2 py-1 text-xs transition-all",
103
+ !t && "cursor-text",
104
+ t && "cursor-not-allowed opacity-60",
105
+ x && !t && "ring-1 ring-brand border-brand"
106
+ ),
107
+ children: [
108
+ n.map((e) => /* @__PURE__ */ m(
109
+ "span",
110
+ {
111
+ className: "flex max-w-full items-center gap-0.5 rounded py-px pl-1 pr-0.5 ring-1 ring-[var(--color-gray-200)]",
112
+ children: [
113
+ /* @__PURE__ */ o("span", { className: "max-w-[200px] truncate font-medium text-secondary", children: e.label }),
114
+ /* @__PURE__ */ o(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ "data-chip-remove": !0,
119
+ disabled: t,
120
+ onClick: (r) => {
121
+ r.stopPropagation(), t || T(e.id);
122
+ },
123
+ className: "flex shrink-0 items-center justify-center rounded-sm text-fg-quaternary hover:text-error-600 disabled:pointer-events-none",
124
+ "aria-label": `Remove ${e.label}`,
125
+ children: /* @__PURE__ */ o(G, { size: 12 })
126
+ }
127
+ )
128
+ ]
129
+ },
130
+ e.id
131
+ )),
132
+ /* @__PURE__ */ o(
133
+ "input",
134
+ {
135
+ ref: h,
136
+ type: "text",
137
+ disabled: t,
138
+ className: "min-w-[4ch] flex-1 border-0 bg-transparent py-0.5 text-xs outline-none ring-0 focus:ring-0 disabled:cursor-not-allowed",
139
+ placeholder: n.length === 0 ? O : void 0,
140
+ value: N,
141
+ onChange: (e) => {
142
+ S(e.target.value), t || s(!0);
143
+ },
144
+ onFocus: () => {
145
+ t || s(!0);
146
+ },
147
+ onKeyDown: U,
148
+ readOnly: !Q
149
+ }
150
+ ),
151
+ /* @__PURE__ */ o(
152
+ "button",
153
+ {
154
+ type: "button",
155
+ tabIndex: -1,
156
+ disabled: t,
157
+ className: "ml-auto flex shrink-0 items-center text-fg-quaternary",
158
+ "aria-label": "Toggle tag list",
159
+ onMouseDown: (e) => {
160
+ e.preventDefault(), !t && (s((r) => !r), requestAnimationFrame(() => {
161
+ var r;
162
+ return (r = h.current) == null ? void 0 : r.focus();
163
+ }));
164
+ },
165
+ children: /* @__PURE__ */ o(H, { size: 14 })
166
+ }
167
+ )
168
+ ]
169
+ }
170
+ ),
171
+ j ? /* @__PURE__ */ m(
172
+ "div",
173
+ {
174
+ className: "absolute z-50 mt-1 w-full overflow-hidden rounded-lg border border-secondary bg-white shadow-lg",
175
+ role: "listbox",
176
+ children: [
177
+ /* @__PURE__ */ o("div", { className: "max-h-60 overflow-y-auto py-1", children: a.map((e, r) => /* @__PURE__ */ o(
178
+ "div",
179
+ {
180
+ role: "option",
181
+ "aria-selected": i === r,
182
+ onMouseEnter: () => p(r),
183
+ onMouseDown: (u) => {
184
+ u.preventDefault(), M(e);
185
+ },
186
+ className: F(
187
+ "cursor-pointer px-3 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary_hover",
188
+ i === r && "bg-primary_hover"
189
+ ),
190
+ children: e.label
191
+ },
192
+ e.id
193
+ )) }),
194
+ y && w ? /* @__PURE__ */ m(X, { children: [
195
+ /* @__PURE__ */ o("div", { className: "border-t border-secondary" }),
196
+ /* @__PURE__ */ m(
197
+ "button",
198
+ {
199
+ type: "button",
200
+ disabled: f,
201
+ "aria-selected": i === a.length,
202
+ onMouseEnter: () => p(a.length),
203
+ className: F(
204
+ "flex w-full items-center justify-between cursor-pointer px-3 py-2.5 text-left text-xs transition-colors hover:bg-primary_hover",
205
+ i === a.length && "bg-primary_hover",
206
+ f && "cursor-not-allowed opacity-60"
207
+ ),
208
+ onMouseDown: (e) => {
209
+ e.preventDefault(), R();
210
+ },
211
+ children: [
212
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
213
+ /* @__PURE__ */ o("span", { className: "text-tertiary", children: "Create " }),
214
+ /* @__PURE__ */ m("span", { className: "font-medium text-primary", children: [
215
+ '"',
216
+ c,
217
+ '"'
218
+ ] })
219
+ ] }),
220
+ f ? /* @__PURE__ */ o(J, { size: "xs" }) : null
221
+ ]
222
+ }
223
+ )
224
+ ] }) : null,
225
+ a.length === 0 && !y ? /* @__PURE__ */ o("div", { className: "px-3 py-4 text-center text-xs text-tertiary", children: "No matching tags" }) : null
226
+ ]
227
+ }
228
+ ) : null
229
+ ] });
230
+ }
231
+ export {
232
+ re as MultiChipsSelect
233
+ };
@@ -0,0 +1,3 @@
1
+ export { MultiChipsSelect, type MultiChipsSelectProps, type SelectOption, } from './MultiChipsSelect';
2
+ export { tagKeyFromLabel } from './tagKeyFromLabel';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/multi-chips-select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}