@pibit.ai/cure-design-system 0.3.23 → 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 (52) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +157 -140
  4. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  5. package/dist/patterns/table/TableWrapper.js +236 -233
  6. package/dist/patterns/table/index.d.ts +4 -1
  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/ColumnHeaderMenu.d.ts +4 -0
  20. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts.map +1 -1
  21. package/dist/patterns/table/toolbar/ColumnHeaderMenu.js +81 -77
  22. package/dist/patterns/table/toolbar/TableToolbar.d.ts +11 -2
  23. package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
  24. package/dist/patterns/table/toolbar/TableToolbar.js +163 -114
  25. package/dist/patterns/table/toolbar/index.d.ts +1 -1
  26. package/dist/patterns/table/toolbar/index.d.ts.map +1 -1
  27. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts +9 -0
  28. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts.map +1 -0
  29. package/dist/patterns/table/toolbar/useUndoRedoShortcuts.js +21 -0
  30. package/dist/patterns/table/types.d.ts +4 -1
  31. package/dist/patterns/table/types.d.ts.map +1 -1
  32. package/dist/patterns/table/useTableUndoRedo.d.ts +41 -0
  33. package/dist/patterns/table/useTableUndoRedo.d.ts.map +1 -0
  34. package/dist/patterns/table/useTableUndoRedo.js +168 -0
  35. package/dist/primitives/badge/badge.js +5 -5
  36. package/dist/primitives/input/input.d.ts +1 -1
  37. package/dist/primitives/input/input.d.ts.map +1 -1
  38. package/dist/primitives/input/input.js +63 -62
  39. package/dist/primitives/select/ExpandableSearchInput.d.ts +1 -1
  40. package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
  41. package/dist/primitives/select/SearchInput.d.ts +2 -2
  42. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  43. package/dist/primitives/select/SearchInput.js +38 -37
  44. package/dist/primitives/select/combobox.d.ts.map +1 -1
  45. package/dist/primitives/select/combobox.js +48 -47
  46. package/dist/primitives/select/multi-select.d.ts.map +1 -1
  47. package/dist/primitives/select/multi-select.js +50 -49
  48. package/dist/styles/components.css +1 -1
  49. package/dist/utils/keyboard-shortcut.d.ts +4 -0
  50. package/dist/utils/keyboard-shortcut.d.ts.map +1 -0
  51. package/dist/utils/keyboard-shortcut.js +29 -0
  52. package/package.json +1 -1
@@ -1,115 +1,115 @@
1
- import { jsxs as u, jsx as e, Fragment as V } from "react/jsx-runtime";
2
- import { forwardRef as F, useContext as b, createContext as G, useState as R, isValidElement as B, useRef as L, useEffect as J, Children as Q, cloneElement as X } from "react";
1
+ import { jsxs as h, jsx as e, Fragment as V } from "react/jsx-runtime";
2
+ import { forwardRef as F, useContext as N, createContext as G, useState as R, isValidElement as k, useRef as J, useEffect as Q, cloneElement as _, Children as X } from "react";
3
3
  import { Edit01 as Y, Copy01 as Z, Trash01 as ee, HelpCircle as te, ArrowDown as re, ChevronSelectorVertical as oe, ChevronRight as ne } from "@untitledui/icons";
4
- import { Table as se, useTableOptions as C, Cell as T, TableBody as ie, Column as S, Group as le, TableHeader as ae, Collection as A, Row as D } from "react-aria-components";
5
- import { cn as p } from "../../utils/cn.js";
4
+ import { Table as se, useTableOptions as T, Cell as z, TableBody as ie, Column as H, Group as le, TableHeader as ae, Collection as A, Row as B } from "react-aria-components";
5
+ import { cn as d } from "../../utils/cn.js";
6
6
  import { isWithinCellEditor as ce } from "./useGridKeyboardNavigation.js";
7
7
  import { Badge as de } from "../../primitives/badge/badge.js";
8
- import { Dropdown as w } from "../../primitives/dropdown/dropdown.js";
9
- import { Tooltip as E, TooltipTrigger as q } from "../../primitives/tooltip/tooltip.js";
10
- import { Checkbox as O } from "../../primitives/checkbox/checkbox.js";
11
- const be = () => /* @__PURE__ */ u(w.Root, { children: [
12
- /* @__PURE__ */ e(w.DotsButton, {}),
13
- /* @__PURE__ */ e(w.Popover, { className: "w-min", children: /* @__PURE__ */ u(w.Menu, { children: [
14
- /* @__PURE__ */ e(w.Item, { icon: Y, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Edit" }) }),
15
- /* @__PURE__ */ e(w.Item, { icon: Z, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Copy link" }) }),
16
- /* @__PURE__ */ e(w.Item, { icon: ee, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Delete" }) })
8
+ import { Dropdown as b } from "../../primitives/dropdown/dropdown.js";
9
+ import { Tooltip as O, TooltipTrigger as P } from "../../primitives/tooltip/tooltip.js";
10
+ import { Checkbox as M } from "../../primitives/checkbox/checkbox.js";
11
+ const be = () => /* @__PURE__ */ h(b.Root, { children: [
12
+ /* @__PURE__ */ e(b.DotsButton, {}),
13
+ /* @__PURE__ */ e(b.Popover, { className: "w-min", children: /* @__PURE__ */ h(b.Menu, { children: [
14
+ /* @__PURE__ */ e(b.Item, { icon: Y, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Edit" }) }),
15
+ /* @__PURE__ */ e(b.Item, { icon: Z, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Copy link" }) }),
16
+ /* @__PURE__ */ e(b.Item, { icon: ee, children: /* @__PURE__ */ e("span", { className: "pr-4", children: "Delete" }) })
17
17
  ] }) })
18
- ] }), g = G({
18
+ ] }), w = G({
19
19
  size: "sm",
20
20
  expandedRows: /* @__PURE__ */ new Set(),
21
21
  toggleRow: () => {
22
22
  },
23
23
  inlineSelection: !1
24
- }), P = F(({ children: n, className: i, size: s = "md", ...c }, o) => {
25
- const t = L(null), [m, f] = R(!1), [a, x] = R(/* @__PURE__ */ new Set());
26
- J(() => {
24
+ }), W = F(({ children: n, className: i, size: s = "md", ...a }, o) => {
25
+ const t = J(null), [u, f] = R(!1), [l, p] = R(/* @__PURE__ */ new Set());
26
+ Q(() => {
27
27
  const r = t.current;
28
28
  if (!r) return;
29
- const l = () => {
30
- const { scrollWidth: v, clientWidth: z } = r;
31
- f(v > z);
29
+ const y = () => {
30
+ const { scrollWidth: v, clientWidth: m } = r;
31
+ f(v > m);
32
32
  };
33
- l();
34
- const d = new ResizeObserver(l);
35
- return d.observe(r), () => {
36
- d.disconnect();
33
+ y();
34
+ const c = new ResizeObserver(y);
35
+ return c.observe(r), () => {
36
+ c.disconnect();
37
37
  };
38
38
  }, []);
39
- const h = (r) => {
40
- x((l) => {
41
- const d = new Set(l);
42
- return d.has(r) ? d.delete(r) : d.add(r), d;
39
+ const x = (r) => {
40
+ p((y) => {
41
+ const c = new Set(y);
42
+ return c.has(r) ? c.delete(r) : c.add(r), c;
43
43
  });
44
44
  };
45
- return /* @__PURE__ */ e(g.Provider, { value: { size: s, hasOverflow: m, expandedRows: a, toggleRow: h }, children: /* @__PURE__ */ e(
45
+ return /* @__PURE__ */ e(w.Provider, { value: { size: s, hasOverflow: u, expandedRows: l, toggleRow: x }, children: /* @__PURE__ */ e(
46
46
  "div",
47
47
  {
48
48
  ref: (r) => {
49
49
  t.current = r, typeof o == "function" ? o(r) : o && (o.current = r);
50
50
  },
51
- ...c,
52
- className: p("overflow-hidden rounded-lg bg-primary", i),
51
+ ...a,
52
+ className: d("overflow-hidden rounded-lg bg-primary", i),
53
53
  children: n
54
54
  }
55
55
  ) });
56
56
  });
57
- P.displayName = "TableCardRoot";
58
- const _ = ({
57
+ W.displayName = "TableCardRoot";
58
+ const j = ({
59
59
  title: n,
60
60
  badge: i,
61
61
  description: s,
62
- contentTrailing: c,
62
+ contentTrailing: a,
63
63
  className: o
64
64
  }) => {
65
- const { size: t } = b(g);
66
- return /* @__PURE__ */ u(
65
+ const { size: t } = N(w);
66
+ return /* @__PURE__ */ h(
67
67
  "div",
68
68
  {
69
- className: p(
69
+ className: d(
70
70
  "relative flex flex-col items-start gap-4 border-b border-tertiary bg-primary px-4 md:flex-row",
71
71
  t === "sm" ? "py-2 md:px-4" : t === "xs" ? "py-0 md:px-3" : "py-3 md:px-6",
72
72
  o
73
73
  ),
74
74
  children: [
75
- /* @__PURE__ */ u("div", { className: "flex flex-1 flex-col gap-0.5", children: [
76
- /* @__PURE__ */ u("div", { className: "flex items-center gap-2", children: [
75
+ /* @__PURE__ */ h("div", { className: "flex flex-1 flex-col gap-0.5", children: [
76
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
77
77
  /* @__PURE__ */ e(
78
78
  "h2",
79
79
  {
80
- className: p(
80
+ className: d(
81
81
  "font-semibold text-primary",
82
82
  t === "sm" ? "text-md" : t === "xs" ? "text-sm" : "text-lg"
83
83
  ),
84
84
  children: n
85
85
  }
86
86
  ),
87
- i ? B(i) ? i : /* @__PURE__ */ e(de, { color: "brand", size: "sm", children: i }) : null
87
+ i ? k(i) ? i : /* @__PURE__ */ e(de, { color: "brand", size: "sm", children: i }) : null
88
88
  ] }),
89
- s && /* @__PURE__ */ e("p", { className: p("text-sm text-tertiary", t === "xs" ? "text-xs" : "text-sm"), children: s })
89
+ s && /* @__PURE__ */ e("p", { className: d("text-sm text-tertiary", t === "xs" ? "text-xs" : "text-sm"), children: s })
90
90
  ] }),
91
- c
91
+ a
92
92
  ]
93
93
  }
94
94
  );
95
95
  };
96
- _.displayName = "TableCardHeader";
97
- const W = ({
96
+ j.displayName = "TableCardHeader";
97
+ const I = ({
98
98
  className: n,
99
99
  size: i = "sm",
100
100
  isEditable: s = !1,
101
- inlineSelection: c = !1,
101
+ inlineSelection: a = !1,
102
102
  ...o
103
103
  }) => {
104
- const t = b(g), [m, f] = R(/* @__PURE__ */ new Set()), a = (t == null ? void 0 : t.expandedRows) ?? m, x = (t == null ? void 0 : t.toggleRow) ?? ((r) => {
105
- f((l) => {
106
- const d = new Set(l);
107
- return d.has(r) ? d.delete(r) : d.add(r), d;
104
+ const t = N(w), [u, f] = R(/* @__PURE__ */ new Set()), l = (t == null ? void 0 : t.expandedRows) ?? u, p = (t == null ? void 0 : t.toggleRow) ?? ((r) => {
105
+ f((y) => {
106
+ const c = new Set(y);
107
+ return c.has(r) ? c.delete(r) : c.add(r), c;
108
108
  });
109
- }), h = /* @__PURE__ */ e(
109
+ }), x = /* @__PURE__ */ e(
110
110
  se,
111
111
  {
112
- className: (r) => p(
112
+ className: (r) => d(
113
113
  "w-full overflow-x-hidden",
114
114
  i === "xs" && "px-3 py-0",
115
115
  typeof n == "function" ? n(r) : n
@@ -118,14 +118,14 @@ const W = ({
118
118
  }
119
119
  );
120
120
  return /* @__PURE__ */ e(
121
- g.Provider,
121
+ w.Provider,
122
122
  {
123
123
  value: {
124
124
  size: (t == null ? void 0 : t.size) ?? i,
125
125
  hasOverflow: t == null ? void 0 : t.hasOverflow,
126
- expandedRows: a,
127
- toggleRow: x,
128
- inlineSelection: c
126
+ expandedRows: l,
127
+ toggleRow: p,
128
+ inlineSelection: a
129
129
  },
130
130
  children: s ? /* @__PURE__ */ e(
131
131
  "div",
@@ -143,202 +143,228 @@ const W = ({
143
143
  " "
144
144
  ])).has(r.key) && ce(r.target) && r.stopPropagation();
145
145
  },
146
- children: h
146
+ children: x
147
147
  }
148
- ) : h
148
+ ) : x
149
149
  }
150
150
  );
151
151
  };
152
- W.displayName = "Table";
153
- const j = ({
152
+ I.displayName = "Table";
153
+ const K = ({
154
154
  columns: n,
155
155
  children: i,
156
156
  bordered: s = !1,
157
- hasExpandableRows: c = !1,
157
+ hasExpandableRows: a = !1,
158
158
  className: o,
159
159
  ...t
160
160
  }) => {
161
- const { size: m, inlineSelection: f } = b(g), { selectionBehavior: a, selectionMode: x } = C();
162
- return /* @__PURE__ */ u(
161
+ const { size: u, inlineSelection: f } = N(w), { selectionBehavior: l, selectionMode: p } = T();
162
+ return /* @__PURE__ */ h(
163
163
  ae,
164
164
  {
165
165
  ...t,
166
- className: (h) => p(
167
- "sticky top-0 z-30 h-9 rounded-t-lg bg-secondary_subtle [&>tr>th:first-child]:rounded-tl-lg [&>tr>th:last-child]:rounded-tr-lg",
166
+ className: (x) => d(
167
+ "sticky top-0 z-30 rounded-t-lg bg-secondary_subtle [&>tr>th]:h-9 [&>tr>th:first-child]:rounded-tl-lg [&>tr>th:last-child]:rounded-tr-lg",
168
168
  s && "[&>tr>th]:after:pointer-events-none [&>tr>th]:after:absolute [&>tr>th]:after:inset-x-0 [&>tr>th]:after:bottom-0 [&>tr>th]:after:h-px [&>tr>th]:after:bg-border-tertiary [&>tr>th]:focus-visible:after:bg-transparent",
169
- typeof o == "function" ? o(h) : o
169
+ typeof o == "function" ? o(x) : o
170
170
  ),
171
171
  children: [
172
- c && /* @__PURE__ */ e(S, { className: p("relative p-0", m === "sm" ? "w-9" : "w-11") }),
173
- a === "toggle" && !f && /* @__PURE__ */ e(S, { className: p("relative p-0", m === "sm" ? "w-9" : "w-11"), children: x === "multiple" && /* @__PURE__ */ e("div", { className: "flex items-start", children: /* @__PURE__ */ e(O, { slot: "selection" }) }) }),
172
+ a && /* @__PURE__ */ e(H, { className: d("relative p-0", u === "sm" ? "w-9" : "w-11") }),
173
+ l === "toggle" && !f && /* @__PURE__ */ e(H, { className: d("relative p-0", u === "sm" ? "w-9" : "w-11"), children: p === "multiple" && /* @__PURE__ */ e("div", { className: "flex items-start", children: /* @__PURE__ */ e(M, { slot: "selection" }) }) }),
174
174
  /* @__PURE__ */ e(A, { items: n, children: i })
175
175
  ]
176
176
  }
177
177
  );
178
178
  };
179
- j.displayName = "TableHeader";
180
- const K = ({
179
+ K.displayName = "TableHeader";
180
+ const $ = ({
181
181
  className: n,
182
182
  tooltip: i,
183
183
  label: s,
184
- children: c,
184
+ children: a,
185
185
  sticky: o,
186
186
  stickyOffset: t = 0,
187
- headerCellClass: m,
187
+ headerCellClass: u,
188
188
  tooltipHeader: f = !1,
189
- ...a
189
+ headerAction: l,
190
+ ...p
190
191
  }) => {
191
- const { selectionBehavior: x } = C(), { size: h, inlineSelection: r } = b(g);
192
+ const { selectionBehavior: x } = T(), { size: r, inlineSelection: y } = N(w), [c, v] = R(!1);
192
193
  return /* @__PURE__ */ e(
193
- S,
194
+ H,
194
195
  {
195
- ...a,
196
- style: (l) => {
197
- const d = o ? {
196
+ ...p,
197
+ onMouseEnter: () => v(!0),
198
+ onMouseLeave: () => v(!1),
199
+ style: (m) => {
200
+ const S = o ? {
198
201
  position: "sticky",
199
202
  [o]: t,
200
203
  zIndex: 30
201
204
  } : {};
202
- return { ...typeof a.style == "function" ? a.style(l) : a.style || {}, ...d };
205
+ return { ...typeof p.style == "function" ? p.style(m) : p.style || {}, ...S };
203
206
  },
204
- className: (l) => p(
207
+ className: (m) => d(
205
208
  "relative p-0 outline-hidden focus-visible:z-1 focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-bg-primary focus-visible:ring-inset",
206
- h === "xs" && "px-3 py-0",
207
- h === "sm" && "px-4 py-2",
208
- h === "md" && "px-6 py-2",
209
- x === "toggle" && !r && "nth-2:pl-3",
209
+ r === "xs" && "px-3 py-0",
210
+ r === "sm" && "px-4 py-2",
211
+ r === "md" && "px-6 py-2",
212
+ x === "toggle" && !y && "nth-2:pl-3",
210
213
  o && "bg-secondary",
211
- l.allowsSorting && "cursor-pointer",
212
- typeof n == "function" ? n(l) : n
214
+ m.allowsSorting && "cursor-pointer",
215
+ typeof n == "function" ? n(m) : n
213
216
  ),
214
- children: (l) => /* @__PURE__ */ u(le, { className: p("flex items-center gap-1", m), children: [
215
- f ? /* @__PURE__ */ e(E, { title: s, placement: "top", children: /* @__PURE__ */ e(q, { className: "cursor-pointer overflow-hidden text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: /* @__PURE__ */ u("div", { className: "flex items-center gap-1 overflow-hidden", children: [
216
- s && /* @__PURE__ */ e("span", { className: "overflow-hidden text-xs font-medium text-ellipsis whitespace-nowrap text-secondary", children: s }),
217
- typeof c == "function" ? c(l) : c
218
- ] }) }) }) : /* @__PURE__ */ u("div", { className: "flex items-center gap-1 overflow-hidden", children: [
219
- s && /* @__PURE__ */ e("span", { className: "overflow-hidden text-xs font-medium text-ellipsis whitespace-nowrap text-secondary", children: s }),
220
- typeof c == "function" ? c(l) : c
221
- ] }),
222
- i && /* @__PURE__ */ e(E, { title: i, placement: "top", children: /* @__PURE__ */ e(q, { className: "cursor-pointer overflow-hidden text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: /* @__PURE__ */ e(te, { className: "size-4" }) }) }),
223
- l.allowsSorting && (l.sortDirection ? /* @__PURE__ */ e(
224
- re,
225
- {
226
- className: p(
227
- "size-3 stroke-[3px] text-fg-quaternary",
228
- l.sortDirection === "ascending" && "rotate-180"
229
- )
230
- }
231
- ) : /* @__PURE__ */ e(oe, { size: 12, strokeWidth: 3, className: "text-fg-quaternary" }))
232
- ] })
217
+ children: (m) => /* @__PURE__ */ h(
218
+ le,
219
+ {
220
+ className: d(
221
+ "relative flex w-full min-w-0 items-center gap-1",
222
+ l && "pr-5"
223
+ ),
224
+ children: [
225
+ /* @__PURE__ */ h(
226
+ "div",
227
+ {
228
+ className: d(
229
+ "flex min-w-0 flex-1 items-center gap-1 overflow-hidden",
230
+ u
231
+ ),
232
+ children: [
233
+ f ? /* @__PURE__ */ e(O, { title: s, placement: "top", children: /* @__PURE__ */ e(P, { className: "cursor-pointer overflow-hidden text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: /* @__PURE__ */ h("div", { className: "flex items-center gap-1 overflow-hidden", children: [
234
+ s && /* @__PURE__ */ e("span", { className: "overflow-hidden text-xs font-medium text-ellipsis whitespace-nowrap text-secondary", children: s }),
235
+ typeof a == "function" ? a(m) : a
236
+ ] }) }) }) : /* @__PURE__ */ h("div", { className: "flex items-center gap-1 overflow-hidden", children: [
237
+ s && /* @__PURE__ */ e("span", { className: "overflow-hidden text-xs font-medium text-ellipsis whitespace-nowrap text-secondary", children: s }),
238
+ typeof a == "function" ? a(m) : a
239
+ ] }),
240
+ i && /* @__PURE__ */ e(O, { title: i, placement: "top", children: /* @__PURE__ */ e(P, { className: "cursor-pointer overflow-hidden text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: /* @__PURE__ */ e(te, { className: "size-4" }) }) }),
241
+ m.allowsSorting && (m.sortDirection ? /* @__PURE__ */ e(
242
+ re,
243
+ {
244
+ className: d(
245
+ "size-3 stroke-[3px] text-fg-quaternary",
246
+ m.sortDirection === "ascending" && "rotate-180"
247
+ )
248
+ }
249
+ ) : /* @__PURE__ */ e(oe, { size: 12, strokeWidth: 3, className: "text-fg-quaternary" }))
250
+ ]
251
+ }
252
+ ),
253
+ l && /* @__PURE__ */ e("div", { className: "absolute inset-y-0 right-0 flex items-center", children: k(l) ? _(l, {
254
+ isHeaderHovered: c
255
+ }) : l })
256
+ ]
257
+ }
258
+ )
233
259
  }
234
260
  );
235
261
  };
236
- K.displayName = "TableHead";
237
- const $ = ({
262
+ $.displayName = "TableHead";
263
+ const L = ({
238
264
  columns: n,
239
265
  children: i,
240
266
  className: s,
241
- highlightSelectedRow: c = !0,
267
+ highlightSelectedRow: a = !0,
242
268
  isExpandable: o = !1,
243
269
  renderExpandedContent: t,
244
- expandedColSpan: m,
270
+ expandedColSpan: u,
245
271
  ...f
246
272
  }) => {
247
- const { size: a, expandedRows: x, toggleRow: h, inlineSelection: r } = b(g), { selectionBehavior: l } = C(), d = typeof f.id == "string" ? f.id : String(f.id), v = x.has(d), M = o ? /* @__PURE__ */ e(
273
+ const { size: l, expandedRows: p, toggleRow: x, inlineSelection: r } = N(w), { selectionBehavior: y } = T(), c = typeof f.id == "string" ? f.id : String(f.id), v = p.has(c), S = o ? /* @__PURE__ */ e(
248
274
  "button",
249
275
  {
250
276
  type: "button",
251
- onClick: (y) => {
252
- y.stopPropagation(), h(d);
277
+ onClick: (g) => {
278
+ g.stopPropagation(), x(c);
253
279
  },
254
- className: p(
280
+ className: d(
255
281
  "flex items-center justify-center transition-transform duration-200 ease-in-out cursor-pointer hover:bg-secondary_subtle rounded p-1 flex-shrink-0 -ml-1 mr-2",
256
282
  v && "rotate-90"
257
283
  ),
258
284
  "aria-label": v ? "Collapse row" : "Expand row",
259
285
  children: /* @__PURE__ */ e(ne, { className: "size-4 text-fg-quaternary" })
260
286
  }
261
- ) : null, U = o ? (() => {
262
- const y = Q.toArray(i);
263
- if (y.length > 0 && B(y[0])) {
264
- const H = y[0], k = H.props;
287
+ ) : null, E = o ? (() => {
288
+ const g = X.toArray(i);
289
+ if (g.length > 0 && k(g[0])) {
290
+ const D = g[0], q = D.props;
265
291
  return [
266
- X(H, {
267
- ...k,
268
- children: /* @__PURE__ */ u("div", { className: "flex items-center gap-2", children: [
269
- M,
270
- k.children
292
+ _(D, {
293
+ ...q,
294
+ children: /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
295
+ S,
296
+ q.children
271
297
  ] })
272
298
  }),
273
- ...y.slice(1)
299
+ ...g.slice(1)
274
300
  ];
275
301
  }
276
302
  return i;
277
303
  })() : i;
278
- return /* @__PURE__ */ u(V, { children: [
279
- /* @__PURE__ */ u(
280
- D,
304
+ return /* @__PURE__ */ h(V, { children: [
305
+ /* @__PURE__ */ h(
306
+ B,
281
307
  {
282
308
  ...f,
283
- className: (y) => p(
309
+ className: (g) => d(
284
310
  "relative outline-focus-ring transition-colors after:pointer-events-none hover:bg-secondary_subtle focus-visible:outline-2 focus-visible:-outline-offset-2",
285
- a === "xs" ? "h-10" : a === "sm" ? "h-12" : a === "md" ? "h-18" : "h-10",
286
- c && !r && "selected:bg-secondary",
311
+ l === "xs" ? "h-10" : l === "sm" ? "h-12" : l === "md" ? "h-18" : "h-10",
312
+ a && !r && "selected:bg-secondary",
287
313
  r && "selected:!bg-transparent",
288
314
  !v && "[&>td]:after:absolute [&>td]:after:inset-x-0 [&>td]:after:bottom-0 [&>td]:after:h-px [&>td]:after:w-full [&>td]:after:bg-border-tertiary last:[&>td]:after:hidden [&>td]:focus-visible:after:opacity-0 focus-visible:[&>td]:after:opacity-0",
289
- typeof s == "function" ? s(y) : s
315
+ typeof s == "function" ? s(g) : s
290
316
  ),
291
317
  children: [
292
- l === "toggle" && !r && /* @__PURE__ */ e(T, { className: p("relative p-0", a === "sm" ? "w-9" : "w-11"), children: /* @__PURE__ */ e("div", { className: "flex items-end", children: /* @__PURE__ */ e(O, { className: "hidden", slot: "selection" }) }) }),
293
- /* @__PURE__ */ e(A, { items: n, children: U })
318
+ y === "toggle" && !r && /* @__PURE__ */ e(z, { className: d("relative p-0", l === "sm" ? "w-9" : "w-11"), children: /* @__PURE__ */ e("div", { className: "flex items-end", children: /* @__PURE__ */ e(M, { className: "hidden", slot: "selection" }) }) }),
319
+ /* @__PURE__ */ e(A, { items: n, children: E })
294
320
  ]
295
321
  }
296
322
  ),
297
- o && v && t && /* @__PURE__ */ e(D, { id: `${d}-expanded`, className: "relative bg-secondary_subtle", children: /* @__PURE__ */ e(T, { className: "p-0", colSpan: m ?? (n == null ? void 0 : n.length) ?? 1, children: /* @__PURE__ */ e("div", { className: "w-full", children: t(f.value) }) }) })
323
+ o && v && t && /* @__PURE__ */ e(B, { id: `${c}-expanded`, className: "relative bg-secondary_subtle", children: /* @__PURE__ */ e(z, { className: "p-0", colSpan: u ?? (n == null ? void 0 : n.length) ?? 1, children: /* @__PURE__ */ e("div", { className: "w-full", children: t(f.value) }) }) })
298
324
  ] });
299
325
  };
300
- $.displayName = "TableRow";
301
- const I = ({ className: n, children: i, sticky: s, stickyOffset: c = 0, ...o }) => {
302
- const { size: t, inlineSelection: m } = b(g), { selectionBehavior: f } = C();
326
+ L.displayName = "TableRow";
327
+ const U = ({ className: n, children: i, sticky: s, stickyOffset: a = 0, ...o }) => {
328
+ const { size: t, inlineSelection: u } = N(w), { selectionBehavior: f } = T();
303
329
  return /* @__PURE__ */ e(
304
- T,
330
+ z,
305
331
  {
306
332
  ...o,
307
- style: (a) => {
308
- const x = s ? {
333
+ style: (l) => {
334
+ const p = s ? {
309
335
  position: "sticky",
310
- [s]: c,
336
+ [s]: a,
311
337
  zIndex: 20,
312
338
  backgroundColor: "white",
313
339
  boxShadow: s === "right" ? "inset 2px 0 0px 0px var(--color-border-tertiary)" : "inset -2px 0 0px 0px var(--color-border-tertiary)"
314
340
  } : {};
315
- return { ...typeof o.style == "function" ? o.style(a) : o.style || {}, ...x };
341
+ return { ...typeof o.style == "function" ? o.style(l) : o.style || {}, ...p };
316
342
  },
317
- className: (a) => p(
343
+ className: (l) => d(
318
344
  "relative text-secondary outline-focus-ring focus-visible:z-1 focus-visible:outline-2 focus-visible:-outline-offset-2",
319
345
  t === "xs" && "p-0 px-3 py-0 text-xs",
320
346
  t === "sm" && "p-0 px-4 py-2 text-sm",
321
347
  t === "md" && "p-0 px-6 py-2 text-base",
322
- f === "toggle" && !m && "nth-2:pl-3",
323
- typeof n == "function" ? n(a) : n
348
+ f === "toggle" && !u && "nth-2:pl-3",
349
+ typeof n == "function" ? n(l) : n
324
350
  ),
325
351
  children: i
326
352
  }
327
353
  );
328
354
  };
329
- I.displayName = "TableCell";
355
+ U.displayName = "TableCell";
330
356
  const Ne = {
331
- Root: P,
332
- Header: _
333
- }, N = W;
334
- N.Body = ie;
335
- N.Cell = I;
336
- N.Head = K;
337
- N.Header = j;
338
- N.Row = $;
357
+ Root: W,
358
+ Header: j
359
+ }, C = I;
360
+ C.Body = ie;
361
+ C.Cell = U;
362
+ C.Head = $;
363
+ C.Header = K;
364
+ C.Row = L;
339
365
  export {
340
- N as Table,
366
+ C as Table,
341
367
  Ne as TableCard,
342
- I as TableCell,
368
+ U as TableCell,
343
369
  be as TableRowActionsDropdown
344
370
  };
@@ -0,0 +1,38 @@
1
+ import { TableWrapperToolbarConfig, TableWrapperEditChrome } from './types';
2
+ import { SummaryFooterRowProps } from './toolbar/SummaryFooter';
3
+ import { CellAlignment, AggregationType } from './toolbar/tableToolbarHelpers';
4
+ import { RowHeightOption } from './toolbar/RowHeightDropdown';
5
+ import { LegacyFilterCondition, LegacySort } from './toolbar/legacyToolbarTypes';
6
+ import { RowActionsConfig } from './toolbar/RowActionsMenu';
7
+ import { ColumnMenuAction } from './toolbar/ColumnHeaderMenu';
8
+ export type TableUndoSnapshot = {
9
+ hiddenColumns?: Set<string>;
10
+ columnOrder?: string[];
11
+ columnAlignments?: Map<string, CellAlignment>;
12
+ groupBy?: string | null;
13
+ showSummary?: boolean;
14
+ summaryAggregations?: Map<string, AggregationType>;
15
+ rowHeight?: RowHeightOption;
16
+ sorts?: LegacySort[];
17
+ filterConditions?: LegacyFilterCondition[];
18
+ data?: unknown[];
19
+ };
20
+ export type TableUndoSnapshotSources = {
21
+ toolbar?: TableWrapperToolbarConfig;
22
+ columnAlignments?: ReadonlyMap<string, CellAlignment>;
23
+ summaryFooterProps?: SummaryFooterRowProps;
24
+ /** When set, used for filter snapshots instead of `toolbar.filter.pendingConditions`. */
25
+ appliedFilterConditions?: readonly LegacyFilterCondition[];
26
+ data?: unknown[];
27
+ getData?: () => unknown[] | undefined;
28
+ };
29
+ export declare function captureTableUndoSnapshot(sources: TableUndoSnapshotSources): TableUndoSnapshot;
30
+ export declare function applyTableUndoSnapshot(snapshot: TableUndoSnapshot, sources: TableUndoSnapshotSources & {
31
+ onDataRestore?: (data: unknown[]) => void;
32
+ }): void;
33
+ export declare function wrapToolbarWithUndoRedo(toolbar: TableWrapperToolbarConfig, commit: () => void): TableWrapperToolbarConfig;
34
+ export declare function wrapSummaryFooterWithUndoRedo(props: SummaryFooterRowProps, commit: () => void): SummaryFooterRowProps;
35
+ export declare function wrapEditChromeWithUndoRedo(editChrome: TableWrapperEditChrome, commit: () => void): TableWrapperEditChrome;
36
+ export declare function wrapRowActionsWithUndoRedo<T extends Record<string, unknown>>(config: RowActionsConfig<T>, commit: () => void): RowActionsConfig<T>;
37
+ export declare function wrapColumnHeaderActionWithUndoRedo(onColumnHeaderAction: (columnKey: string, action: ColumnMenuAction) => void, commit: () => void): (columnKey: string, action: ColumnMenuAction) => void;
38
+ //# sourceMappingURL=tableUndoRedo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableUndoRedo.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/tableUndoRedo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACnD,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtD,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;IAC3C,yFAAyF;IACzF,uBAAuB,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC3D,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,OAAO,EAAE,GAAG,SAAS,CAAC;CACvC,CAAC;AA4BF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAoB7F;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,wBAAwB,GAAG;IAAE,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CAAE,GAChF,IAAI,CAmCN;AAcD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE,MAAM,IAAI,GACjB,yBAAyB,CAiF3B;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,MAAM,IAAI,GACjB,qBAAqB,CAQvB;AAED,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,sBAAsB,EAClC,MAAM,EAAE,MAAM,IAAI,GACjB,sBAAsB,CAYxB;AAED,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1E,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC3B,MAAM,EAAE,MAAM,IAAI,GACjB,gBAAgB,CAAC,CAAC,CAAC,CAgBrB;AAED,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,KAAK,IAAI,EAC3E,MAAM,EAAE,MAAM,IAAI,GACjB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAOvD"}