wcz-layout 10.1.9 → 10.2.0
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/{Approval-DoD-GRRH.mjs → Approval-D1TfISUL.mjs} +11 -21
- package/dist/Approval-D1TfISUL.mjs.map +1 -0
- package/dist/{LayoutTable-CRo43iWr.d.mts → ChatLayout-BmLySLXy.d.mts} +11 -18
- package/dist/ChatLayout-Tpuwo8-b.mjs +1622 -0
- package/dist/ChatLayout-Tpuwo8-b.mjs.map +1 -0
- package/dist/{DialogsContext-DLqA8RJ_.mjs → DialogsContext-D23fJjYR.mjs} +2 -3
- package/dist/DialogsContext-D23fJjYR.mjs.map +1 -0
- package/dist/{Email-CKUxOURX.d.mts → Email-Dz5k0UWE.d.mts} +1 -3
- package/dist/{Email-BzQQkbe9.mjs → Email-rnz3H0x3.mjs} +3 -5
- package/dist/Email-rnz3H0x3.mjs.map +1 -0
- package/dist/{Employee-agVPiGrJ.d.mts → Employee-C8xIlBxY.d.mts} +1 -7
- package/dist/{FileMeta-Be9viU7D.d.mts → FileMeta-B39e2FLC.d.mts} +1 -3
- package/dist/{FileMeta-DDqUju1Y.mjs → FileMeta-CPBWI_jA.mjs} +2 -3
- package/dist/FileMeta-CPBWI_jA.mjs.map +1 -0
- package/dist/{QueryClientParam-JcH0mJWl.d.mts → QueryClientParam-CTV1vj76.d.mts} +1 -3
- package/dist/RouterListItemButton-CF-8w-08.mjs +62 -0
- package/dist/RouterListItemButton-CF-8w-08.mjs.map +1 -0
- package/dist/{User-D4__w1I1.d.mts → User-aJksXItw.d.mts} +1 -3
- package/dist/{approval-L09uPzTU.mjs → approval-HB2w5jzc.mjs} +4 -5
- package/dist/approval-HB2w5jzc.mjs.map +1 -0
- package/dist/auth.d.mts +0 -4
- package/dist/auth.mjs +5 -6
- package/dist/auth.mjs.map +1 -1
- package/dist/components.d.mts +63 -33
- package/dist/components.mjs +658 -748
- package/dist/components.mjs.map +1 -1
- package/dist/{createApi-BhNkG4jz.mjs → createApi-CKgFi53y.mjs} +4 -6
- package/dist/createApi-CKgFi53y.mjs.map +1 -0
- package/dist/data/client.d.mts +2 -8
- package/dist/data/client.mjs +6 -9
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +2 -4
- package/dist/data/server.mjs +6 -7
- package/dist/data/server.mjs.map +1 -1
- package/dist/env-BwFl7nWc.mjs +48 -0
- package/dist/env-BwFl7nWc.mjs.map +1 -0
- package/dist/{file-Chlljz3o.mjs → file-X1sK4ok6.mjs} +7 -8
- package/dist/file-X1sK4ok6.mjs.map +1 -0
- package/dist/{file-Dl8JCcqy.mjs → file-tkfsnk5F.mjs} +8 -8
- package/dist/file-tkfsnk5F.mjs.map +1 -0
- package/dist/generatedChart-k7NEdi5Z.mjs +211 -0
- package/dist/generatedChart-k7NEdi5Z.mjs.map +1 -0
- package/dist/hooks.d.mts +30 -30
- package/dist/hooks.mjs +1828 -1304
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +11 -14
- package/dist/index.mjs +1273 -1051
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +1 -7
- package/dist/middleware.mjs +5 -8
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +4 -32
- package/dist/models.mjs +7 -11
- package/dist/models.mjs.map +1 -1
- package/dist/{peoplesoft-D6q3cYsH.d.mts → peoplesoft-C-zPdRVj.d.mts} +3 -9
- package/dist/{peoplesoft-BhintHQz.mjs → peoplesoft-RnvfLbWH.mjs} +5 -25
- package/dist/peoplesoft-RnvfLbWH.mjs.map +1 -0
- package/dist/{providers-BvuZWkpD.mjs → providers-BfFg_3eo.mjs} +5 -23
- package/dist/providers-BfFg_3eo.mjs.map +1 -0
- package/dist/{tokens-XuFhVbh5.mjs → tokens-C4SErO-K.mjs} +12 -8
- package/dist/tokens-C4SErO-K.mjs.map +1 -0
- package/dist/{utils-CaeVFWF-.mjs → utils-C2MZoH9U.mjs} +8 -39
- package/dist/utils-C2MZoH9U.mjs.map +1 -0
- package/dist/{utils-Bhi0KiBx.d.mts → utils-CNYCSgip.d.mts} +3 -5
- package/dist/utils-DnMFybj3.mjs +27 -0
- package/dist/utils-DnMFybj3.mjs.map +1 -0
- package/dist/utils.d.mts +11 -2
- package/dist/utils.mjs +3 -5
- package/dist/vite.d.mts +0 -2
- package/dist/vite.mjs +2 -4
- package/dist/vite.mjs.map +1 -1
- package/package.json +131 -131
- package/skills/ai/SKILL.md +136 -39
- package/skills/client-db/SKILL.md +104 -90
- package/skills/db-schema/SKILL.md +28 -20
- package/skills/dialogs/SKILL.md +26 -38
- package/skills/forms/SKILL.md +133 -73
- package/skills/general/SKILL.md +99 -105
- package/skills/general/references/auth.md +70 -0
- package/skills/migrations/versions/migrate-v10-to-v11.md +30 -4
- package/skills/routing/SKILL.md +60 -58
- package/skills/scanning/SKILL.md +67 -0
- package/skills/server-functions/SKILL.md +71 -26
- package/skills/services/SKILL.md +4 -4
- package/skills/services/docs/approval.md +70 -24
- package/skills/services/docs/email.md +24 -3
- package/skills/services/docs/file.md +69 -27
- package/skills/services/docs/peoplesoft.md +55 -39
- package/skills/start/steps/03-apm-setup.md +9 -9
- package/skills/table/SKILL.md +250 -267
- package/dist/AggregatedCell-oGcwbetF.mjs +0 -559
- package/dist/AggregatedCell-oGcwbetF.mjs.map +0 -1
- package/dist/Approval-DoD-GRRH.mjs.map +0 -1
- package/dist/DialogsContext-DLqA8RJ_.mjs.map +0 -1
- package/dist/Email-BzQQkbe9.mjs.map +0 -1
- package/dist/FileMeta-DDqUju1Y.mjs.map +0 -1
- package/dist/RouterListItemButton-ULMlaQh6.mjs +0 -80
- package/dist/RouterListItemButton-ULMlaQh6.mjs.map +0 -1
- package/dist/approval-L09uPzTU.mjs.map +0 -1
- package/dist/createApi-BhNkG4jz.mjs.map +0 -1
- package/dist/file-Chlljz3o.mjs.map +0 -1
- package/dist/file-Dl8JCcqy.mjs.map +0 -1
- package/dist/peoplesoft-BhintHQz.mjs.map +0 -1
- package/dist/providers-BvuZWkpD.mjs.map +0 -1
- package/dist/tokens-XuFhVbh5.mjs.map +0 -1
- package/dist/utils-CaeVFWF-.mjs.map +0 -1
- package/skills/general/references/exports.md +0 -114
package/skills/table/SKILL.md
CHANGED
|
@@ -1,267 +1,250 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: table
|
|
3
|
-
description: "Use when building or changing a data table
|
|
4
|
-
metadata:
|
|
5
|
-
type: convention
|
|
6
|
-
library: wcz-layout
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
`
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
##
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
inside `columnHelper.columns([...])`, and no row models at all.
|
|
252
|
-
|
|
253
|
-
This is v9. v8 column defs either type-error inside `columnHelper.columns()` or
|
|
254
|
-
silently no-op, and row models are gone.
|
|
255
|
-
|
|
256
|
-
### HIGH: Adding your own virtualizer or pager
|
|
257
|
-
|
|
258
|
-
Wrong: wrapping rows in `useVirtualizer` from `@tanstack/react-virtual`, or bolting on
|
|
259
|
-
a `TablePagination`.
|
|
260
|
-
|
|
261
|
-
Correct: render `<LayoutTable table={table} />` and pass `pagination` if the user wants
|
|
262
|
-
a pager.
|
|
263
|
-
|
|
264
|
-
`LayoutTable` already virtualizes rows and columns. A second virtualizer fights the
|
|
265
|
-
first over scroll position.
|
|
266
|
-
|
|
267
|
-
Use only `LayoutTable`'s `pagination` prop for its pager.
|
|
1
|
+
---
|
|
2
|
+
name: table
|
|
3
|
+
description: "Use when building or changing a data table or list page in app: useLayoutTable, LayoutTable, createLayoutColumnHelper, columns and headers, cell formatters, filter variants, sorting, row selection and bulk actions, per-row actions, pagination or server paging, footer aggregation, column sizing, or styling table parts."
|
|
4
|
+
metadata:
|
|
5
|
+
type: convention
|
|
6
|
+
library: wcz-layout
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`useLayoutTable` and `createLayoutColumnHelper` (`wcz-layout/hooks`) are the `useAppTable` and
|
|
10
|
+
`createAppColumnHelper` of TanStack Table v9's `createTableHook`, with wcz-layout's features and
|
|
11
|
+
components; feature APIs: load `@tanstack/table-core#table-features`. Never render a
|
|
12
|
+
`<table>` or `useTable` yourself, and ignore upstream's own virtualization and pagination
|
|
13
|
+
setup: `LayoutTable` (`wcz-layout/components`) does both.
|
|
14
|
+
|
|
15
|
+
## Rules
|
|
16
|
+
|
|
17
|
+
- `const table = useLayoutTable({ data, columns })`, then `<LayoutTable table={table} />`.
|
|
18
|
+
Rows are keyed by `row.id`, so every row needs an `id`. A list page wraps it in
|
|
19
|
+
`Fullscreen` and passes `loading={isLoading}` from `useLiveQuery`.
|
|
20
|
+
- Columns: `columnHelper.columns([...])` with `columnHelper.accessor("field", …)` or
|
|
21
|
+
`columnHelper.display({ id, … })`, from a module-level
|
|
22
|
+
`const columnHelper = createLayoutColumnHelper<Entity>()`. No row models: the features are
|
|
23
|
+
installed.
|
|
24
|
+
- Cells render the bound formatters, `cell.ValueCell`, `NumberCell`, `DateCell`, `DateTimeCell`,
|
|
25
|
+
`BooleanCell`: they carry alignment, locale formats and one-line ellipsis. Raw JSX only for a
|
|
26
|
+
link or another interactive element.
|
|
27
|
+
- Selection and actions display columns: `size: 50`, `enableResizing: false`,
|
|
28
|
+
`enableCellSelection: false`; each extra visible action button adds about 40 px.
|
|
29
|
+
- `meta` keys: `label`, `align`, `variant`, `options`, `flex`. A column whose `header` is not
|
|
30
|
+
a plain string needs `meta.label` (header menu, column selector and filter picker read it).
|
|
31
|
+
- `meta.variant` picks the filter: `"text"` (default), `"number"`, `"boolean"`, `"date"`,
|
|
32
|
+
`"select"`, `"multi-select"`. Select variants build their options from the faceted unique
|
|
33
|
+
values; pass `options` only when labels differ from stored values or the list is fixed, and
|
|
34
|
+
for a database enum derive them from `.enumValues`.
|
|
35
|
+
- `size` is the starting width. `meta.flex` lets a column grow and shrink in proportion, like
|
|
36
|
+
CSS `flex`, so the table fills its container without horizontal scroll; it stops at
|
|
37
|
+
`minSize` (default 20), after which the table scrolls. A resized column keeps its width.
|
|
38
|
+
- Rows and columns virtualize and rows are measured: a cell may wrap onto several lines once
|
|
39
|
+
its content has `whiteSpace: "normal"`.
|
|
40
|
+
- Toolbar actions: create (`RouterIconButton` to the create page), edit when exactly one row is
|
|
41
|
+
selected, delete when any are: `confirm(t("DeleteConfirmation", { count }))`, the optimistic
|
|
42
|
+
delete, `when("settled")`, then `table.resetRowSelection()`; `catch` alerts. Icons are
|
|
43
|
+
`fontSize="small"` inside a `Tooltip`.
|
|
44
|
+
- `LayoutTable` props: `title`, `actions`, `showToolbar`, `loading`, `pagination`,
|
|
45
|
+
`pageSizeOptions`, `onRowClick`, `onRowDoubleClick`, `sx`, and `disableSearch`,
|
|
46
|
+
`disableColumnFilter`, `disableColumnSelector`, `disableColumnMenu`.
|
|
47
|
+
- Server-paged tables (reports, lists sorted over more rows than the browser should hold;
|
|
48
|
+
deep offset collection queries load a growing prefix, see client-db): use Query/server pages.
|
|
49
|
+
Load upstream Query integration/state guidance for request keys, totals and manual flags; pass
|
|
50
|
+
`manualPagination: true`, `rowCount` and controlled `state.pagination` /
|
|
51
|
+
`onPaginationChange` (plus the `manual*` flags for what the server sorts and filters) to
|
|
52
|
+
`useLayoutTable`, with `pagination` on `LayoutTable`.
|
|
53
|
+
|
|
54
|
+
## Example
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
// src/routes/features/index.tsx
|
|
58
|
+
import { Fullscreen, LayoutTable, RouterIconButton, RouterLink } from "wcz-layout/components";
|
|
59
|
+
import {
|
|
60
|
+
createLayoutColumnHelper,
|
|
61
|
+
useDialogs,
|
|
62
|
+
useLayoutTable,
|
|
63
|
+
useTranslation,
|
|
64
|
+
} from "wcz-layout/hooks";
|
|
65
|
+
|
|
66
|
+
export const Route = createFileRoute("/features/")({
|
|
67
|
+
component: RouteComponent,
|
|
68
|
+
beforeLoad: requireAuth("admin"),
|
|
69
|
+
loader: ({ context }) => context.dbClient.preloadLiveQuery(featuresQueryOptions),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const columnHelper = createLayoutColumnHelper<Feature>();
|
|
73
|
+
|
|
74
|
+
function RouteComponent() {
|
|
75
|
+
const { t } = useTranslation();
|
|
76
|
+
const { confirm, alert } = useDialogs();
|
|
77
|
+
const navigate = useNavigate();
|
|
78
|
+
const features = useFeatureCollection();
|
|
79
|
+
const { data, isLoading } = useLiveQuery(featuresQueryOptions);
|
|
80
|
+
|
|
81
|
+
const columns = columnHelper.columns([
|
|
82
|
+
columnHelper.display({
|
|
83
|
+
id: "select",
|
|
84
|
+
header: ({ header }) => <header.SelectAllCell scope="all" />,
|
|
85
|
+
cell: ({ cell }) => <cell.SelectCell />,
|
|
86
|
+
size: 50,
|
|
87
|
+
enableResizing: false,
|
|
88
|
+
enableCellSelection: false,
|
|
89
|
+
}),
|
|
90
|
+
columnHelper.accessor("name", {
|
|
91
|
+
header: t("Feature.Name"),
|
|
92
|
+
cell: ({ cell }) => (
|
|
93
|
+
<RouterLink
|
|
94
|
+
to="/features/$id"
|
|
95
|
+
params={{ id: cell.row.original.id }}
|
|
96
|
+
underline="hover"
|
|
97
|
+
color="inherit"
|
|
98
|
+
>
|
|
99
|
+
{cell.getValue()}
|
|
100
|
+
</RouterLink>
|
|
101
|
+
),
|
|
102
|
+
size: 260,
|
|
103
|
+
meta: { flex: 1 },
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
const table = useLayoutTable({ data, columns });
|
|
108
|
+
const selectedIds = table.getSelectedRowIds();
|
|
109
|
+
|
|
110
|
+
const handleOnDelete = createOptimisticAction<Array<string>>({
|
|
111
|
+
onMutate: (ids) => {
|
|
112
|
+
ids.forEach((id) => {
|
|
113
|
+
features.delete(id);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
mutationFn: async (ids) => {
|
|
117
|
+
await deleteFeatures({ data: ids });
|
|
118
|
+
await features.utils.refetch({ throwOnError: true });
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Fullscreen>
|
|
124
|
+
<LayoutTable
|
|
125
|
+
table={table}
|
|
126
|
+
loading={isLoading}
|
|
127
|
+
showToolbar
|
|
128
|
+
title={t("Feature.Features")}
|
|
129
|
+
onRowDoubleClick={(row) => navigate({ to: "/features/$id", params: { id: row.id } })}
|
|
130
|
+
actions={
|
|
131
|
+
<>
|
|
132
|
+
<Tooltip title={t("Create")}>
|
|
133
|
+
<RouterIconButton to="/features/create">
|
|
134
|
+
<Add fontSize="small" />
|
|
135
|
+
</RouterIconButton>
|
|
136
|
+
</Tooltip>
|
|
137
|
+
{selectedIds.length === 1 && (
|
|
138
|
+
<Tooltip title={t("Edit")}>
|
|
139
|
+
<RouterIconButton to="/features/edit/$id" params={{ id: selectedIds[0] }}>
|
|
140
|
+
<Edit fontSize="small" />
|
|
141
|
+
</RouterIconButton>
|
|
142
|
+
</Tooltip>
|
|
143
|
+
)}
|
|
144
|
+
{selectedIds.length > 0 && (
|
|
145
|
+
<Tooltip title={t("Delete")}>
|
|
146
|
+
<IconButton
|
|
147
|
+
onClick={async () => {
|
|
148
|
+
if (!(await confirm(t("DeleteConfirmation", { count: selectedIds.length }))))
|
|
149
|
+
return;
|
|
150
|
+
try {
|
|
151
|
+
await handleOnDelete(selectedIds).when("settled");
|
|
152
|
+
table.resetRowSelection();
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (error instanceof Error) await alert(error.message);
|
|
155
|
+
}
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<Badge
|
|
159
|
+
badgeContent={selectedIds.length}
|
|
160
|
+
invisible={selectedIds.length <= 1}
|
|
161
|
+
color="error"
|
|
162
|
+
>
|
|
163
|
+
<Delete fontSize="small" />
|
|
164
|
+
</Badge>
|
|
165
|
+
</IconButton>
|
|
166
|
+
</Tooltip>
|
|
167
|
+
)}
|
|
168
|
+
</>
|
|
169
|
+
}
|
|
170
|
+
/>
|
|
171
|
+
</Fullscreen>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Additional columns only when the entity schema has these fields:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { Typography } from "@mui/material";
|
|
180
|
+
import { featureStatusEnum } from "~/server/db/schemas/feature";
|
|
181
|
+
|
|
182
|
+
columnHelper.accessor("quantity", {
|
|
183
|
+
header: t("Feature.Quantity"),
|
|
184
|
+
cell: ({ cell }) => <cell.NumberCell />,
|
|
185
|
+
footer: ({ header }) => <header.AggregationFooter />,
|
|
186
|
+
aggregationFn: "sum",
|
|
187
|
+
meta: { variant: "number", align: "right" },
|
|
188
|
+
});
|
|
189
|
+
columnHelper.accessor("active", {
|
|
190
|
+
header: t("Feature.Active"),
|
|
191
|
+
cell: ({ cell }) => <cell.BooleanCell />,
|
|
192
|
+
meta: { variant: "boolean", align: "center" },
|
|
193
|
+
});
|
|
194
|
+
columnHelper.accessor("dueAt", {
|
|
195
|
+
header: t("Feature.DueAt"),
|
|
196
|
+
cell: ({ cell }) => <cell.DateCell />,
|
|
197
|
+
meta: { variant: "date" },
|
|
198
|
+
});
|
|
199
|
+
columnHelper.accessor("status", {
|
|
200
|
+
header: t("Feature.Status"),
|
|
201
|
+
cell: ({ cell }) => (
|
|
202
|
+
<Typography variant="body2" noWrap>
|
|
203
|
+
{t(`Feature.StatusLabels.${cell.getValue()}`)}
|
|
204
|
+
</Typography>
|
|
205
|
+
),
|
|
206
|
+
meta: {
|
|
207
|
+
variant: "multi-select",
|
|
208
|
+
options: featureStatusEnum.enumValues.map((value) => ({
|
|
209
|
+
value,
|
|
210
|
+
label: t(`Feature.StatusLabels.${value}`),
|
|
211
|
+
})),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// per-row actions: one inline button, the rest in the row menu
|
|
218
|
+
columnHelper.display({
|
|
219
|
+
id: "actions",
|
|
220
|
+
cell: ({ cell }) => (
|
|
221
|
+
<cell.ActionsCell
|
|
222
|
+
actions={[
|
|
223
|
+
{
|
|
224
|
+
label: t("Edit"),
|
|
225
|
+
icon: <Edit fontSize="small" />,
|
|
226
|
+
onClick: (row) => navigate({ to: "/features/edit/$id", params: { id: row.id } }),
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
label: t("Delete"),
|
|
230
|
+
icon: <Delete fontSize="small" />,
|
|
231
|
+
showInMenu: true,
|
|
232
|
+
onClick: (row) => remove(row.id),
|
|
233
|
+
},
|
|
234
|
+
]}
|
|
235
|
+
/>
|
|
236
|
+
),
|
|
237
|
+
size: 50,
|
|
238
|
+
enableResizing: false,
|
|
239
|
+
enableCellSelection: false,
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Bound components
|
|
244
|
+
|
|
245
|
+
Header render prop: `SelectAllCell`, `ExpandAllCell`, `AggregationFooter`, `HeaderMenu`,
|
|
246
|
+
`HeaderSortLabel`, `HeaderResizeHandle`. Cell render prop: `SelectCell`, `ExpandCell`,
|
|
247
|
+
`GroupCell`, `PinRowCell`, `ActionsCell` and the formatters. `LayoutTable` already places the
|
|
248
|
+
menu, sort label and resize handle. A custom cell or header is a plain component reading
|
|
249
|
+
`useCellContext<TValue>()`, `useHeaderContext()` or `useTableContext()` from `wcz-layout/hooks`;
|
|
250
|
+
`layoutTableFeatures` and `LayoutTableFeatures` only type a hand-built table instance.
|