@pibit.ai/cure-design-system 0.3.23 → 0.3.26
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.
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -140
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +376 -369
- package/dist/patterns/table/index.d.ts +4 -1
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/integrateTableUndoRedo.d.ts +41 -0
- package/dist/patterns/table/integrateTableUndoRedo.d.ts.map +1 -0
- package/dist/patterns/table/integrateTableUndoRedo.js +63 -0
- package/dist/patterns/table/storyHelpers/useMockTableState.d.ts +3 -1
- package/dist/patterns/table/storyHelpers/useMockTableState.d.ts.map +1 -1
- package/dist/patterns/table/table.d.ts +2 -1
- package/dist/patterns/table/table.d.ts.map +1 -1
- package/dist/patterns/table/table.js +181 -155
- package/dist/patterns/table/tableUndoRedo.d.ts +38 -0
- package/dist/patterns/table/tableUndoRedo.d.ts.map +1 -0
- package/dist/patterns/table/tableUndoRedo.js +147 -0
- package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts +4 -0
- package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/ColumnHeaderMenu.js +81 -77
- package/dist/patterns/table/toolbar/TableToolbar.d.ts +11 -2
- package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/TableToolbar.js +163 -114
- package/dist/patterns/table/toolbar/index.d.ts +1 -1
- package/dist/patterns/table/toolbar/index.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts +9 -0
- package/dist/patterns/table/toolbar/useUndoRedoShortcuts.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/useUndoRedoShortcuts.js +21 -0
- package/dist/patterns/table/types.d.ts +5 -1
- package/dist/patterns/table/types.d.ts.map +1 -1
- package/dist/patterns/table/useTableUndoRedo.d.ts +41 -0
- package/dist/patterns/table/useTableUndoRedo.d.ts.map +1 -0
- package/dist/patterns/table/useTableUndoRedo.js +168 -0
- package/dist/primitives/badge/badge.js +5 -5
- package/dist/primitives/input/input.d.ts +1 -1
- package/dist/primitives/input/input.d.ts.map +1 -1
- package/dist/primitives/input/input.js +63 -62
- package/dist/primitives/select/ExpandableSearchInput.d.ts +1 -1
- package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
- package/dist/primitives/select/SearchInput.d.ts +2 -2
- package/dist/primitives/select/SearchInput.d.ts.map +1 -1
- package/dist/primitives/select/SearchInput.js +38 -37
- package/dist/primitives/select/combobox.d.ts.map +1 -1
- package/dist/primitives/select/combobox.js +48 -47
- package/dist/primitives/select/multi-select.d.ts.map +1 -1
- package/dist/primitives/select/multi-select.js +50 -49
- package/dist/styles/components.css +1 -1
- package/dist/utils/keyboard-shortcut.d.ts +4 -0
- package/dist/utils/keyboard-shortcut.d.ts.map +1 -0
- package/dist/utils/keyboard-shortcut.js +29 -0
- package/package.json +1 -1
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as F, useContext as
|
|
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
|
|
5
|
-
import { cn as
|
|
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
|
|
9
|
-
import { Tooltip as
|
|
10
|
-
import { Checkbox as
|
|
11
|
-
const be = () => /* @__PURE__ */
|
|
12
|
-
/* @__PURE__ */ e(
|
|
13
|
-
/* @__PURE__ */ e(
|
|
14
|
-
/* @__PURE__ */ e(
|
|
15
|
-
/* @__PURE__ */ e(
|
|
16
|
-
/* @__PURE__ */ e(
|
|
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
|
-
] }),
|
|
18
|
+
] }), w = G({
|
|
19
19
|
size: "sm",
|
|
20
20
|
expandedRows: /* @__PURE__ */ new Set(),
|
|
21
21
|
toggleRow: () => {
|
|
22
22
|
},
|
|
23
23
|
inlineSelection: !1
|
|
24
|
-
}),
|
|
25
|
-
const t =
|
|
26
|
-
|
|
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
|
|
30
|
-
const { scrollWidth: v, clientWidth:
|
|
31
|
-
f(v >
|
|
29
|
+
const y = () => {
|
|
30
|
+
const { scrollWidth: v, clientWidth: m } = r;
|
|
31
|
+
f(v > m);
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
|
|
33
|
+
y();
|
|
34
|
+
const c = new ResizeObserver(y);
|
|
35
|
+
return c.observe(r), () => {
|
|
36
|
+
c.disconnect();
|
|
37
37
|
};
|
|
38
38
|
}, []);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
return
|
|
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(
|
|
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
|
-
...
|
|
52
|
-
className:
|
|
51
|
+
...a,
|
|
52
|
+
className: d("overflow-hidden rounded-lg bg-primary", i),
|
|
53
53
|
children: n
|
|
54
54
|
}
|
|
55
55
|
) });
|
|
56
56
|
});
|
|
57
|
-
|
|
58
|
-
const
|
|
57
|
+
W.displayName = "TableCardRoot";
|
|
58
|
+
const j = ({
|
|
59
59
|
title: n,
|
|
60
60
|
badge: i,
|
|
61
61
|
description: s,
|
|
62
|
-
contentTrailing:
|
|
62
|
+
contentTrailing: a,
|
|
63
63
|
className: o
|
|
64
64
|
}) => {
|
|
65
|
-
const { size: t } =
|
|
66
|
-
return /* @__PURE__ */
|
|
65
|
+
const { size: t } = N(w);
|
|
66
|
+
return /* @__PURE__ */ h(
|
|
67
67
|
"div",
|
|
68
68
|
{
|
|
69
|
-
className:
|
|
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__ */
|
|
76
|
-
/* @__PURE__ */
|
|
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:
|
|
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 ?
|
|
87
|
+
i ? k(i) ? i : /* @__PURE__ */ e(de, { color: "brand", size: "sm", children: i }) : null
|
|
88
88
|
] }),
|
|
89
|
-
s && /* @__PURE__ */ e("p", { className:
|
|
89
|
+
s && /* @__PURE__ */ e("p", { className: d("text-sm text-tertiary", t === "xs" ? "text-xs" : "text-sm"), children: s })
|
|
90
90
|
] }),
|
|
91
|
-
|
|
91
|
+
a
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
const
|
|
96
|
+
j.displayName = "TableCardHeader";
|
|
97
|
+
const I = ({
|
|
98
98
|
className: n,
|
|
99
99
|
size: i = "sm",
|
|
100
100
|
isEditable: s = !1,
|
|
101
|
-
inlineSelection:
|
|
101
|
+
inlineSelection: a = !1,
|
|
102
102
|
...o
|
|
103
103
|
}) => {
|
|
104
|
-
const t =
|
|
105
|
-
f((
|
|
106
|
-
const
|
|
107
|
-
return
|
|
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
|
-
}),
|
|
109
|
+
}), x = /* @__PURE__ */ e(
|
|
110
110
|
se,
|
|
111
111
|
{
|
|
112
|
-
className: (r) =>
|
|
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
|
-
|
|
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:
|
|
127
|
-
toggleRow:
|
|
128
|
-
inlineSelection:
|
|
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:
|
|
146
|
+
children: x
|
|
147
147
|
}
|
|
148
|
-
) :
|
|
148
|
+
) : x
|
|
149
149
|
}
|
|
150
150
|
);
|
|
151
151
|
};
|
|
152
|
-
|
|
153
|
-
const
|
|
152
|
+
I.displayName = "Table";
|
|
153
|
+
const K = ({
|
|
154
154
|
columns: n,
|
|
155
155
|
children: i,
|
|
156
156
|
bordered: s = !1,
|
|
157
|
-
hasExpandableRows:
|
|
157
|
+
hasExpandableRows: a = !1,
|
|
158
158
|
className: o,
|
|
159
159
|
...t
|
|
160
160
|
}) => {
|
|
161
|
-
const { size:
|
|
162
|
-
return /* @__PURE__ */
|
|
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: (
|
|
167
|
-
"sticky top-0 z-30
|
|
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(
|
|
169
|
+
typeof o == "function" ? o(x) : o
|
|
170
170
|
),
|
|
171
171
|
children: [
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
180
|
-
const
|
|
179
|
+
K.displayName = "TableHeader";
|
|
180
|
+
const $ = ({
|
|
181
181
|
className: n,
|
|
182
182
|
tooltip: i,
|
|
183
183
|
label: s,
|
|
184
|
-
children:
|
|
184
|
+
children: a,
|
|
185
185
|
sticky: o,
|
|
186
186
|
stickyOffset: t = 0,
|
|
187
|
-
headerCellClass:
|
|
187
|
+
headerCellClass: u,
|
|
188
188
|
tooltipHeader: f = !1,
|
|
189
|
-
|
|
189
|
+
headerAction: l,
|
|
190
|
+
...p
|
|
190
191
|
}) => {
|
|
191
|
-
const { selectionBehavior: x } =
|
|
192
|
+
const { selectionBehavior: x } = T(), { size: r, inlineSelection: y } = N(w), [c, v] = R(!1);
|
|
192
193
|
return /* @__PURE__ */ e(
|
|
193
|
-
|
|
194
|
+
H,
|
|
194
195
|
{
|
|
195
|
-
...
|
|
196
|
-
|
|
197
|
-
|
|
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
|
|
205
|
+
return { ...typeof p.style == "function" ? p.style(m) : p.style || {}, ...S };
|
|
203
206
|
},
|
|
204
|
-
className: (
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
x === "toggle" && !
|
|
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
|
-
|
|
212
|
-
typeof n == "function" ? n(
|
|
214
|
+
m.allowsSorting && "cursor-pointer",
|
|
215
|
+
typeof n == "function" ? n(m) : n
|
|
213
216
|
),
|
|
214
|
-
children: (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
237
|
-
const
|
|
262
|
+
$.displayName = "TableHead";
|
|
263
|
+
const L = ({
|
|
238
264
|
columns: n,
|
|
239
265
|
children: i,
|
|
240
266
|
className: s,
|
|
241
|
-
highlightSelectedRow:
|
|
267
|
+
highlightSelectedRow: a = !0,
|
|
242
268
|
isExpandable: o = !1,
|
|
243
269
|
renderExpandedContent: t,
|
|
244
|
-
expandedColSpan:
|
|
270
|
+
expandedColSpan: u,
|
|
245
271
|
...f
|
|
246
272
|
}) => {
|
|
247
|
-
const { size:
|
|
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: (
|
|
252
|
-
|
|
277
|
+
onClick: (g) => {
|
|
278
|
+
g.stopPropagation(), x(c);
|
|
253
279
|
},
|
|
254
|
-
className:
|
|
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,
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
const
|
|
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
|
-
|
|
267
|
-
...
|
|
268
|
-
children: /* @__PURE__ */
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
...
|
|
299
|
+
...g.slice(1)
|
|
274
300
|
];
|
|
275
301
|
}
|
|
276
302
|
return i;
|
|
277
303
|
})() : i;
|
|
278
|
-
return /* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */
|
|
280
|
-
|
|
304
|
+
return /* @__PURE__ */ h(V, { children: [
|
|
305
|
+
/* @__PURE__ */ h(
|
|
306
|
+
B,
|
|
281
307
|
{
|
|
282
308
|
...f,
|
|
283
|
-
className: (
|
|
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
|
-
|
|
286
|
-
|
|
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(
|
|
315
|
+
typeof s == "function" ? s(g) : s
|
|
290
316
|
),
|
|
291
317
|
children: [
|
|
292
|
-
|
|
293
|
-
/* @__PURE__ */ e(A, { items: n, children:
|
|
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(
|
|
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
|
-
|
|
301
|
-
const
|
|
302
|
-
const { size: t, inlineSelection:
|
|
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
|
-
|
|
330
|
+
z,
|
|
305
331
|
{
|
|
306
332
|
...o,
|
|
307
|
-
style: (
|
|
308
|
-
const
|
|
333
|
+
style: (l) => {
|
|
334
|
+
const p = s ? {
|
|
309
335
|
position: "sticky",
|
|
310
|
-
[s]:
|
|
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(
|
|
341
|
+
return { ...typeof o.style == "function" ? o.style(l) : o.style || {}, ...p };
|
|
316
342
|
},
|
|
317
|
-
className: (
|
|
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" && !
|
|
323
|
-
typeof n == "function" ? 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
|
-
|
|
355
|
+
U.displayName = "TableCell";
|
|
330
356
|
const Ne = {
|
|
331
|
-
Root:
|
|
332
|
-
Header:
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
366
|
+
C as Table,
|
|
341
367
|
Ne as TableCard,
|
|
342
|
-
|
|
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"}
|