@jielga/tmdatagrid 2.0.0-beta.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -212
- package/dist/index.d.ts +1281 -768
- package/dist/index.js +4607 -3250
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/adding-rows.md +132 -0
- package/docs/anatomy.md +119 -0
- package/docs/card-view.md +108 -0
- package/docs/cell-selection.md +194 -0
- package/docs/column-layout.md +182 -0
- package/docs/column-menu.md +66 -0
- package/docs/columns.md +269 -0
- package/docs/components.md +311 -0
- package/docs/draft-store.md +242 -0
- package/docs/editing.md +303 -0
- package/docs/editors.md +250 -0
- package/docs/export.md +319 -0
- package/docs/filtering.md +362 -0
- package/docs/getting-started.md +123 -0
- package/docs/grouping.md +165 -0
- package/docs/loading-and-empty.md +92 -0
- package/docs/localization.md +79 -0
- package/docs/menu.md +143 -0
- package/docs/migrating-to-2.md +163 -0
- package/docs/pagination.md +144 -0
- package/docs/persistence.md +114 -0
- package/docs/portfolio-rebalancer.md +94 -0
- package/docs/query-builder.md +179 -0
- package/docs/quick-search.md +84 -0
- package/docs/row-details.md +115 -0
- package/docs/row-interaction.md +149 -0
- package/docs/row-pinning.md +132 -0
- package/docs/row-selection.md +136 -0
- package/docs/row-styling.md +133 -0
- package/docs/scrolling.md +112 -0
- package/docs/server-query.md +246 -0
- package/docs/server-side.md +206 -0
- package/docs/sorting.md +101 -0
- package/docs/styling.md +126 -0
- package/docs/summary-row.md +76 -0
- package/docs/testing.md +744 -0
- package/docs/toolbar.md +161 -0
- package/docs/use-tm-data-grid.md +361 -0
- package/package.json +22 -46
- package/skills/appearance/SKILL.md +72 -19
- package/skills/cell-selection/SKILL.md +49 -48
- package/skills/columns/SKILL.md +125 -70
- package/skills/columns/references/columns-api.md +59 -0
- package/skills/data/SKILL.md +112 -18
- package/skills/editing/SKILL.md +76 -42
- package/skills/editing/references/common-mistakes.md +77 -69
- package/skills/editing/references/editing-api.md +25 -20
- package/skills/editing/references/editors-and-validation.md +80 -18
- package/skills/filtering/SKILL.md +155 -41
- package/skills/getting-started/SKILL.md +116 -16
- package/skills/grouping/SKILL.md +31 -16
- package/skills/migrating-to-2/SKILL.md +244 -0
- package/skills/options/SKILL.md +24 -12
- package/skills/rows/SKILL.md +22 -18
- package/skills/rows/references/rows-api.md +10 -6
- package/skills/server-side/SKILL.md +170 -17
- package/skills/testing/SKILL.md +150 -32
- package/skills/testing-components/SKILL.md +230 -0
- package/skills/testing-editing/SKILL.md +240 -0
- package/src/{tmdatagrid/components → components}/TMDataGrid.tsx +38 -21
- package/src/{tmdatagrid/components → components}/TMDataGridCellEditor.tsx +54 -8
- package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.module.css +5 -1
- package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.tsx +47 -55
- package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.tsx +5 -51
- package/src/{tmdatagrid/components → components}/TMDataGridDraftActions.tsx +41 -24
- package/src/{tmdatagrid/components → components}/TMDataGridEditColumn.tsx +12 -59
- package/src/{tmdatagrid/components → components}/TMDataGridEntryRows.tsx +164 -92
- package/src/components/TMDataGridExportPicker.module.css +77 -0
- package/src/components/TMDataGridExportPicker.tsx +234 -0
- package/src/components/TMDataGridFilterPanel.module.css +54 -0
- package/src/components/TMDataGridFilterPanel.tsx +348 -0
- package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.tsx +15 -8
- package/src/components/TMDataGridFilterSurface.module.css +54 -0
- package/src/components/TMDataGridFilterSurface.tsx +167 -0
- package/src/{tmdatagrid/components → components}/TMDataGridFooter.tsx +53 -90
- package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.tsx +5 -69
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.module.css +12 -2
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.tsx +58 -21
- package/src/components/TMDataGridHeaderFilterRow.module.css +51 -0
- package/src/components/TMDataGridHeaderFilterRow.tsx +301 -0
- package/src/components/TMDataGridMenu.tsx +357 -0
- package/src/{tmdatagrid/components → components}/TMDataGridSelectColumn.tsx +11 -48
- package/src/{tmdatagrid/components → components}/TMDataGridTable.module.css +69 -56
- package/src/{tmdatagrid/components → components}/TMDataGridTable.tsx +240 -138
- package/src/{tmdatagrid/components → components}/TMDataGridToolbar.module.css +5 -0
- package/src/components/TMDataGridToolbar.tsx +181 -0
- package/src/{tmdatagrid/components → components}/editors/TMDataGridBooleanEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/TMDataGridDateEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/TMDataGridMultiSelectEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/TMDataGridNumberEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/TMDataGridSelectEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/TMDataGridStringEditor.tsx +3 -3
- package/src/{tmdatagrid/components → components}/editors/editorShared.ts +16 -2
- package/src/{tmdatagrid/components → components}/filters/DgAutocompleteFilter.tsx +5 -4
- package/src/{tmdatagrid/components → components}/filters/DgDateRangeFilter.tsx +22 -5
- package/src/{tmdatagrid/components → components}/filters/DgRangeSliderFilter.tsx +5 -1
- package/src/{tmdatagrid/components → components}/filters/DgTriStateFilter.tsx +5 -1
- package/src/{tmdatagrid/components → components}/filters/TMDataGridFilterValueInput.tsx +44 -28
- package/src/components/filters/controlLayout.ts +32 -0
- package/src/components/filters/filterControlFor.ts +65 -0
- package/src/components/generatedColumns.tsx +187 -0
- package/src/{tmdatagrid/components → components}/icons.ts +1 -0
- package/src/{tmdatagrid/components → components}/sticky.module.css +44 -0
- package/src/components/useHideableColumns.ts +52 -0
- package/src/{tmdatagrid/core → core}/autosize.ts +5 -2
- package/src/{tmdatagrid/core → core}/columnOptions.ts +60 -8
- package/src/{tmdatagrid/core → core}/columnOrdering.ts +33 -14
- package/src/{tmdatagrid/core → core}/columnUtils.ts +44 -5
- package/src/core/controlledStateSync.ts +108 -0
- package/src/core/deletedRows.ts +34 -0
- package/src/core/dom.ts +74 -0
- package/src/{tmdatagrid/core → core}/editEngine.ts +1107 -460
- package/src/core/export.ts +704 -0
- package/src/{tmdatagrid/core → core}/filterControls.ts +38 -1
- package/src/{tmdatagrid/core → core}/filterOperators.ts +64 -1
- package/src/core/filterSurface.ts +99 -0
- package/src/{tmdatagrid/core → core}/grouping.ts +21 -0
- package/src/{tmdatagrid/core → core}/labels.ts +51 -6
- package/src/{tmdatagrid/core → core}/labelsSv.ts +27 -6
- package/src/core/pageReset.ts +120 -0
- package/src/core/pagination.ts +81 -0
- package/src/{tmdatagrid/core → core}/persistence.ts +22 -5
- package/src/{tmdatagrid/core → core}/summary.ts +20 -4
- package/src/{tmdatagrid/index.ts → index.ts} +69 -35
- package/src/{tmdatagrid/useTMDataGrid.tsx → useTMDataGrid.tsx} +428 -109
- package/src/useTMDataGridExport.ts +78 -0
- package/src/tmdatagrid/components/TMDataGridFilterPanel.module.css +0 -35
- package/src/tmdatagrid/components/TMDataGridFilterPanel.tsx +0 -354
- package/src/tmdatagrid/components/TMDataGridToolbar.tsx +0 -161
- package/src/tmdatagrid/core/cellExport.ts +0 -320
- /package/src/{tmdatagrid/TMDataGridContext.ts → TMDataGridContext.ts} +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGrid.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridFooter.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.module.css +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridRowNumberColumn.tsx +0 -0
- /package/src/{tmdatagrid/components → components}/TMDataGridSearch.tsx +0 -0
- /package/src/{tmdatagrid/core → core}/capabilities.ts +0 -0
- /package/src/{tmdatagrid/core → core}/cellNavigation.ts +0 -0
- /package/src/{tmdatagrid/core → core}/cellRange.ts +0 -0
- /package/src/{tmdatagrid/core → core}/controlledState.ts +0 -0
- /package/src/{tmdatagrid/core → core}/draftCellContext.ts +0 -0
- /package/src/{tmdatagrid/core → core}/editorFocus.ts +0 -0
- /package/src/{tmdatagrid/core → core}/expanding.ts +0 -0
- /package/src/{tmdatagrid/core → core}/matchHighlight.ts +0 -0
- /package/src/{tmdatagrid/core → core}/quickSearch.ts +0 -0
- /package/src/{tmdatagrid/core → core}/resizePreview.ts +0 -0
- /package/src/{tmdatagrid/core → core}/rowPinning.ts +0 -0
- /package/src/{tmdatagrid/core → core}/rowSelection.ts +0 -0
- /package/src/{tmdatagrid/core → core}/sizes.ts +0 -0
- /package/src/{tmdatagrid/core → core}/useSettledTableState.ts +0 -0
package/skills/grouping/SKILL.md
CHANGED
|
@@ -14,12 +14,12 @@ description: >
|
|
|
14
14
|
metadata:
|
|
15
15
|
type: core
|
|
16
16
|
library: '@jielga/tmdatagrid'
|
|
17
|
-
library_version: '2.0.
|
|
17
|
+
library_version: '2.0.1'
|
|
18
18
|
sources:
|
|
19
|
-
- 'Jielga/TMDataGrid:
|
|
20
|
-
- 'Jielga/TMDataGrid:
|
|
21
|
-
- 'Jielga/TMDataGrid:
|
|
22
|
-
- 'Jielga/TMDataGrid:
|
|
19
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/grouping.md'
|
|
20
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/summary-row.md'
|
|
21
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/grouping.ts'
|
|
22
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/summary.ts'
|
|
23
23
|
---
|
|
24
24
|
|
|
25
25
|
# TMDataGrid - Grouping and totals
|
|
@@ -86,9 +86,12 @@ would pass a row that looks real but is the wrong one. Group rows therefore:
|
|
|
86
86
|
- do not fire `onRowClick` or the cell handlers
|
|
87
87
|
- cannot be highlighted, pinned, or given a details panel
|
|
88
88
|
- never edit
|
|
89
|
+
- are still handed to `rowStyle` and `rowClassName`, with that child's record
|
|
90
|
+
as `original`, so guard a callback reading `original` with
|
|
91
|
+
`row.getIsGrouped()` and colour the group rows with `--dg-row-group-bg`
|
|
89
92
|
- carry `data-grouped="true"` and `data-depth`, with `--dg-row-group-bg`
|
|
90
|
-
behind them. `data-grouped` is on
|
|
91
|
-
|
|
93
|
+
behind them. `data-grouped` is present only on group rows, so
|
|
94
|
+
`[data-grouped]` and `[data-grouped="true"]` are equivalent
|
|
92
95
|
|
|
93
96
|
A group row's checkbox selects every record under it at any depth, including
|
|
94
97
|
records inside collapsed sub-groups, showing a tick once all are selected and a
|
|
@@ -142,7 +145,9 @@ aggregateColumn({ table, columnId: "location", fn: "uniqueCount" });
|
|
|
142
145
|
```
|
|
143
146
|
|
|
144
147
|
It follows the filters deliberately. A total that does not change as the user
|
|
145
|
-
narrows the grid is misleading.
|
|
148
|
+
narrows the grid is misleading. Its only argument is `table`, so a toolbar
|
|
149
|
+
readout or any other component holding the table reads the same total without a
|
|
150
|
+
`footer`.
|
|
146
151
|
|
|
147
152
|
Pinned columns keep their lanes in the summary row, the generated lanes define
|
|
148
153
|
no `footer` so their cells stay blank, and the row is sticky at
|
|
@@ -168,7 +173,7 @@ Correct:
|
|
|
168
173
|
columnHelper.accessor("salary", { header: "Salary", aggregationFn: "sum" });
|
|
169
174
|
```
|
|
170
175
|
|
|
171
|
-
Source: `
|
|
176
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Aggregation).
|
|
172
177
|
|
|
173
178
|
### HIGH Looking for the grouped column in the grid
|
|
174
179
|
|
|
@@ -183,7 +188,7 @@ Correct, when the column must stay:
|
|
|
183
188
|
useTMDataGrid({ data, columns, groupedColumnMode: "reorder" });
|
|
184
189
|
```
|
|
185
190
|
|
|
186
|
-
Source: `
|
|
191
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (What grouping does to the grid).
|
|
187
192
|
|
|
188
193
|
### HIGH Combining the pager with grouping
|
|
189
194
|
|
|
@@ -192,14 +197,16 @@ out instead of paging the tree, so a footer count wired to `getPageCount()`
|
|
|
192
197
|
reports a number nobody can navigate to. Read
|
|
193
198
|
`isPagingActive(table, features)` before trusting the pager state.
|
|
194
199
|
|
|
195
|
-
Source: `
|
|
200
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Grouping suspends pagination).
|
|
196
201
|
|
|
197
202
|
### HIGH Handing a group row to a row callback
|
|
198
203
|
|
|
199
204
|
Group rows do not fire `onRowClick` or the cell handlers, and cannot be pinned,
|
|
200
205
|
expanded or edited. Their `row.original` is an arbitrary child's record, so a
|
|
201
206
|
bulk action built from `row.original` on the tree lane acts on one record
|
|
202
|
-
instead of the group.
|
|
207
|
+
instead of the group. `rowStyle` and `rowClassName` are the callbacks group
|
|
208
|
+
rows do reach, so one reading `row.original` colours the group by whichever
|
|
209
|
+
child came first.
|
|
203
210
|
|
|
204
211
|
Correct:
|
|
205
212
|
|
|
@@ -207,9 +214,17 @@ Correct:
|
|
|
207
214
|
import { getGroupDataRows } from "@jielga/tmdatagrid";
|
|
208
215
|
|
|
209
216
|
const records = getGroupDataRows(groupRow).map((row) => row.original);
|
|
217
|
+
|
|
218
|
+
<TMDataGrid.Table<Employee>
|
|
219
|
+
rowStyle={(row) =>
|
|
220
|
+
!row.getIsGrouped() && row.original.status === "Terminated"
|
|
221
|
+
? { "--row-bg": "color-mix(in srgb, var(--mantine-color-red-6) 12%, transparent)" }
|
|
222
|
+
: undefined
|
|
223
|
+
}
|
|
224
|
+
/>;
|
|
210
225
|
```
|
|
211
226
|
|
|
212
|
-
Source: `
|
|
227
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Group rows are not data rows).
|
|
213
228
|
|
|
214
229
|
### MEDIUM Totalling the page instead of the data
|
|
215
230
|
|
|
@@ -217,7 +232,7 @@ Source: `src/docs/grouping.md` (Group rows are not data rows).
|
|
|
217
232
|
`table.getRowModel().rows` instead totals only what is currently paged in, and
|
|
218
233
|
under virtualization not even that: only the mounted rows.
|
|
219
234
|
|
|
220
|
-
Source: `
|
|
235
|
+
Source: `packages/tmdatagrid/docs/summary-row.md` (Totalling a column).
|
|
221
236
|
|
|
222
237
|
### MEDIUM Grouping a server-paged grid
|
|
223
238
|
|
|
@@ -237,7 +252,7 @@ useTMDataGrid({
|
|
|
237
252
|
});
|
|
238
253
|
```
|
|
239
254
|
|
|
240
|
-
Source: `
|
|
255
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Server-side grids).
|
|
241
256
|
|
|
242
257
|
## Reference
|
|
243
258
|
|
|
@@ -258,7 +273,7 @@ Source: `src/docs/grouping.md` (Server-side grids).
|
|
|
258
273
|
| `isPagingActive` | Export | `(table, features) => boolean` | – | Whether the pager is slicing anything. `false` while grouped. |
|
|
259
274
|
| `--dg-row-group-bg` | CSS variable | colour | Themed | Group row background. |
|
|
260
275
|
| `--dg-summary-height` | CSS variable | length | From `size` | Height of the summary row. |
|
|
261
|
-
| `data-grouped` · `data-depth` | Data attributes | – | – | `"true"` on group rows (
|
|
276
|
+
| `data-grouped` · `data-depth` | Data attributes | – | – | `"true"` on group rows (absent on the rest), and the nesting level on every row. |
|
|
262
277
|
|
|
263
278
|
See also: the `rows` skill for selection and the details lane, and the `data`
|
|
264
279
|
skill for the pager grouping suspends.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrating-to-2
|
|
3
|
+
description: >
|
|
4
|
+
Upgrade code written against a 2.0.0-beta release of TMDataGrid to 2.0.0, as a
|
|
5
|
+
checklist to run over a codebase. Covers the edit.commitAll / saveDrafts /
|
|
6
|
+
addRows result objects and the silent `if (await saveDrafts())` trap, the
|
|
7
|
+
onSaveDrafts return type renamed to TMDataGridSaveDraftsResponse, every
|
|
8
|
+
removed name with its replacement (submitAll, onCommitDrafts, rows / added,
|
|
9
|
+
pendingCount, cellExport, exportGridToCsv, the cell-matrix functions,
|
|
10
|
+
toExcelCsv, downloadTextFile, labels.exportCsv), the helpers no longer
|
|
11
|
+
exported, removing row annotations and casts from meta.options and
|
|
12
|
+
meta.edit.enabled callbacks, and the behaviour changes. Load when upgrading
|
|
13
|
+
@jielga/tmdatagrid from a 2.0 beta, or when an import or a property from the
|
|
14
|
+
beta no longer resolves.
|
|
15
|
+
metadata:
|
|
16
|
+
type: lifecycle
|
|
17
|
+
library: '@jielga/tmdatagrid'
|
|
18
|
+
library_version: '2.0.1'
|
|
19
|
+
sources:
|
|
20
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/migrating-to-2.md'
|
|
21
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/index.ts'
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# TMDataGrid - Migrating from the 2.0 beta to 2.0.0
|
|
25
|
+
|
|
26
|
+
2.0.0 removes every name deprecated during the 2.0 beta, stops exporting a set
|
|
27
|
+
of internal helpers, and changes what three edit calls resolve. Run the steps
|
|
28
|
+
below in order over the codebase. Step 1 finds code that still compiles but
|
|
29
|
+
behaves differently; the compiler finds most of the rest.
|
|
30
|
+
|
|
31
|
+
## 1. CRITICAL Read `ok` from commitAll and saveDrafts
|
|
32
|
+
|
|
33
|
+
`edit.commitAll()` and `edit.saveDrafts()` resolve an object instead of a
|
|
34
|
+
`boolean`. A truthiness check on the old `boolean` still compiles and is now
|
|
35
|
+
always true, so a failed save reports success with no error.
|
|
36
|
+
|
|
37
|
+
Search for: `commitAll(` and `saveDrafts(`, including the `actions.save` and
|
|
38
|
+
`actions.commitAll` of a `TMDataGrid.DraftActions` `renderActions` slot, which
|
|
39
|
+
resolve the same objects.
|
|
40
|
+
|
|
41
|
+
| Call | Resolves |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `edit.commitAll()` · `actions.commitAll()` | `TMDataGridCommitAllResult`: `{ ok, committed, open }` |
|
|
44
|
+
| `edit.saveDrafts()` · `actions.save()` | `TMDataGridSaveDraftsResult`: `{ ok, saved, kept, reopened }` |
|
|
45
|
+
| `edit.addRows(rows, options)` | `TMDataGridAddRowsResult`: `{ ok, committed, open }` - `ok` is new |
|
|
46
|
+
| `edit.commit(rowId)` | `boolean`, unchanged |
|
|
47
|
+
|
|
48
|
+
Wrong (compiles, always true):
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
if (await grid.edit.saveDrafts()) notify("Saved");
|
|
52
|
+
const done = await grid.edit.commitAll();
|
|
53
|
+
if (!done) return;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Correct:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const { ok, kept, reopened } = await grid.edit.saveDrafts();
|
|
60
|
+
if (ok) notify("Saved");
|
|
61
|
+
else notify(`${kept.length + reopened.length} rows need attention`);
|
|
62
|
+
|
|
63
|
+
const { ok: committed } = await grid.edit.commitAll();
|
|
64
|
+
if (!committed) return;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Each list holds row ids, and temp ids for new rows. `ok` is `true` when `open`
|
|
68
|
+
is empty, or, for `saveDrafts()`, when `kept` and `reopened` are both empty.
|
|
69
|
+
Also check every other use of the result: `.then((saved) => ...)`, a `return`
|
|
70
|
+
of it from a `boolean` function, `!result`, `result ? ... : ...` and
|
|
71
|
+
`Boolean(result)`.
|
|
72
|
+
|
|
73
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Read the batch edit results).
|
|
74
|
+
|
|
75
|
+
## 2. Rename the onSaveDrafts return type
|
|
76
|
+
|
|
77
|
+
The type of what `editing.onSaveDrafts` may return is renamed
|
|
78
|
+
`TMDataGridSaveDraftsResponse`. `TMDataGridSaveDraftsResult` is now the type
|
|
79
|
+
`edit.saveDrafts()` resolves, so code that kept the old name for the callback
|
|
80
|
+
fails to compile.
|
|
81
|
+
|
|
82
|
+
Search for: `TMDataGridSaveDraftsResult`. Where it types an `onSaveDrafts`
|
|
83
|
+
callback or its return value, replace it:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
// beta
|
|
87
|
+
import type { TMDataGridSaveDraftsResult } from "@jielga/tmdatagrid";
|
|
88
|
+
|
|
89
|
+
// 2.0.0
|
|
90
|
+
import type { TMDataGridSaveDraftsResponse } from "@jielga/tmdatagrid";
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Where it types the value of `await edit.saveDrafts()`, keep it.
|
|
94
|
+
|
|
95
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Rename the onSaveDrafts return type).
|
|
96
|
+
|
|
97
|
+
## 3. Replace removed names
|
|
98
|
+
|
|
99
|
+
Search for each name in the first column and replace it:
|
|
100
|
+
|
|
101
|
+
| Removed | Use instead |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `edit.submitAll()` | `edit.commitAll()`, then `edit.saveDrafts()` |
|
|
104
|
+
| `editing.onCommitDrafts` | `editing.onSaveDrafts` |
|
|
105
|
+
| `rows` and `added` in the `onSaveDrafts` payload | `updated` and `created` |
|
|
106
|
+
| `TMDataGridEditCommitDraftsArgs` | `TMDataGridSaveDraftsArgs` |
|
|
107
|
+
| `state.pendingCount` in a `TMDataGrid.DraftActions` slot | `state.draftCount` or `state.openCount` |
|
|
108
|
+
| `cellExport` on `TMDataGrid.Table` | `exportOptions` on `useTMDataGrid` |
|
|
109
|
+
| `exportGridToCsv` | `exportGrid` |
|
|
110
|
+
| `TMDataGridCellExportOptions`, `DEFAULT_CELL_EXPORT_OPTIONS`, `fromCellExportOptions` | `TMDataGridExportOptions`, `DEFAULT_EXPORT_OPTIONS` |
|
|
111
|
+
| `buildCellMatrix`, `buildGridCellMatrix`, `BuildCellMatrixArgs`, `TMDataGridCellMatrix` | `buildExportData`, `BuildExportDataArgs`, `TMDataGridExportData` |
|
|
112
|
+
| `toExcelCsv` | `csvExcelFormat` |
|
|
113
|
+
| `downloadTextFile` | `downloadFile` |
|
|
114
|
+
| `labels.exportCsv` | `labels.exportCells` |
|
|
115
|
+
|
|
116
|
+
Search for `onSaveDrafts` as well, and check what each callback reads off its
|
|
117
|
+
payload.
|
|
118
|
+
|
|
119
|
+
### submitAll
|
|
120
|
+
|
|
121
|
+
`submitAll()` was `commitAll()` followed by `saveDrafts()`. Call both, and
|
|
122
|
+
combine the results where one answer is needed:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const committed = await grid.edit.commitAll();
|
|
126
|
+
const saved = await grid.edit.saveDrafts();
|
|
127
|
+
const ok = committed.ok && saved.ok;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### The CSV export options
|
|
131
|
+
|
|
132
|
+
`separator` and `decimalComma` move into a format; `includeHeaders` and
|
|
133
|
+
`fileName` stay in the options. `exportOptions` on the hook applies to every
|
|
134
|
+
export the grid offers, the cell-range menu included.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
// beta
|
|
138
|
+
<TMDataGrid.Table cellExport={{ separator: ",", decimalComma: false, fileName: "orders" }} />;
|
|
139
|
+
exportGridToCsv({ table, options: { separator: ",", decimalComma: false } });
|
|
140
|
+
|
|
141
|
+
// 2.0.0
|
|
142
|
+
const exportOptions = {
|
|
143
|
+
format: csvExcelFormat({ separator: ",", decimalComma: false }),
|
|
144
|
+
fileName: "orders",
|
|
145
|
+
} satisfies TMDataGridExportOptions;
|
|
146
|
+
|
|
147
|
+
const grid = useTMDataGrid({ data, columns, exportOptions });
|
|
148
|
+
await exportGrid({ table: grid.table, options: exportOptions });
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### The matrix functions
|
|
152
|
+
|
|
153
|
+
The export functions now return values, not text. A format writes the text:
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
// beta
|
|
157
|
+
const csv = toExcelCsv(buildGridCellMatrix({ table }), { separator: ";" });
|
|
158
|
+
downloadTextFile({ fileName: "export.csv", text: csv });
|
|
159
|
+
|
|
160
|
+
// 2.0.0
|
|
161
|
+
const data = buildExportData({ table });
|
|
162
|
+
const csv = await csvExcelFormat().write(data, { includeHeaders: true });
|
|
163
|
+
downloadFile({ fileName: "export.csv", content: csv, mimeType: "text/csv;charset=utf-8" });
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
For a cell range, pass `rows` and `bounds` to `buildExportData` instead of
|
|
167
|
+
`rows`, `columns` and `bounds` to `buildCellMatrix`. `toClipboardText(data)`
|
|
168
|
+
writes the tab-separated text for the clipboard.
|
|
169
|
+
|
|
170
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Replace removed names).
|
|
171
|
+
|
|
172
|
+
## 4. Remove annotations and casts from meta callbacks
|
|
173
|
+
|
|
174
|
+
The `row` that `meta.options` and `meta.edit.enabled` callbacks receive is
|
|
175
|
+
typed with the row type of `createTMDataGridColumnHelper<TData>()`:
|
|
176
|
+
`Row<TMDataGridFeatures, TData>`. A callback whose parameter is annotated with
|
|
177
|
+
the untyped row no longer compiles.
|
|
178
|
+
|
|
179
|
+
Search for: `options:` and `enabled:` inside column `meta`, and
|
|
180
|
+
`Row<TMDataGridFeatures, TMDataGridRowData>` or `as ` casts on `row.original`
|
|
181
|
+
next to them. Remove the annotation and the cast:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
// beta
|
|
185
|
+
meta: {
|
|
186
|
+
edit: {
|
|
187
|
+
enabled: (row: Row<TMDataGridFeatures, TMDataGridRowData>) =>
|
|
188
|
+
(row.original as Employee).status !== "Terminated",
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 2.0.0
|
|
193
|
+
meta: {
|
|
194
|
+
edit: { enabled: (row) => row.original.status !== "Terminated" },
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Columns built without the helper keep the untyped row,
|
|
199
|
+
`Row<TMDataGridFeatures, TMDataGridRowData>`; leave those as they are.
|
|
200
|
+
|
|
201
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Remove annotations from meta callbacks).
|
|
202
|
+
|
|
203
|
+
## 5. Replace helpers that are no longer exported
|
|
204
|
+
|
|
205
|
+
These names are internal to the grid and are no longer exported from
|
|
206
|
+
`@jielga/tmdatagrid`. An import of one fails to compile. Search the imports
|
|
207
|
+
from `@jielga/tmdatagrid` for each:
|
|
208
|
+
|
|
209
|
+
| Removed | Use instead |
|
|
210
|
+
| --- | --- |
|
|
211
|
+
| `getDefaultOperator` | `getColumnDefaultOperator(column)` |
|
|
212
|
+
| `isColumnEditableForRow` | `edit.canEditCell(row, column)` |
|
|
213
|
+
| `isColumnReorderable` | `getColumnCapabilities(column, features).canReorder` |
|
|
214
|
+
| `measureColumnContentWidth` | `autosizeColumn` |
|
|
215
|
+
| `tmDataGridFeatures` | The `TMDataGridFeatures` type |
|
|
216
|
+
| `isSameCell`, `resolveCellMove`, `ResolveCellMoveArgs`, `TMDataGridCellCoords`, `TMDataGridCellNav` | No public replacement; internal to the grid. |
|
|
217
|
+
| `boundsCellCount`, `boundsEdges`, `isWithinBounds` | No public replacement; internal to the grid. |
|
|
218
|
+
| `getColumnFilterControl` | No public replacement; internal to the grid. |
|
|
219
|
+
| `TMDataGridColumnLayout` | No public replacement; internal to the grid. |
|
|
220
|
+
|
|
221
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Replace un-exported helpers).
|
|
222
|
+
|
|
223
|
+
## 6. Check the behaviour changes
|
|
224
|
+
|
|
225
|
+
- Under `editing.draft` without `onSaveDrafts`, a deletion whose
|
|
226
|
+
`onRowDelete` throws keeps its deletion mark and is reported in `kept`. In
|
|
227
|
+
the beta, `saveDrafts()` rejected and the mark was lost. Search for a
|
|
228
|
+
`try` / `catch` around `saveDrafts()` that expected the rejection, and read
|
|
229
|
+
`kept` instead.
|
|
230
|
+
- The Swedish labels `TMDATAGRID_LABELS_SV` say "Välj" for selecting: "Välj
|
|
231
|
+
alla", "Välj alla rader", "Välj rad" and "Välj grupp". Update tests that find
|
|
232
|
+
these controls by their Swedish name.
|
|
233
|
+
|
|
234
|
+
Source: `packages/tmdatagrid/docs/migrating-to-2.md` (Behaviour changes).
|
|
235
|
+
|
|
236
|
+
## 7. Verify
|
|
237
|
+
|
|
238
|
+
Run the project's typecheck: an import of a removed or un-exported name, and a
|
|
239
|
+
meta callback annotated with the untyped row, fail there. Then run the tests
|
|
240
|
+
that save or commit edits, since the truthiness check of step 1 and the
|
|
241
|
+
behaviour changes of step 6 compile.
|
|
242
|
+
|
|
243
|
+
See also: the `editing` skill for the result objects and the draft store, and
|
|
244
|
+
the `data` skill for the export API.
|
package/skills/options/SKILL.md
CHANGED
|
@@ -14,11 +14,12 @@ description: >
|
|
|
14
14
|
metadata:
|
|
15
15
|
type: core
|
|
16
16
|
library: '@jielga/tmdatagrid'
|
|
17
|
-
library_version: '2.0.
|
|
17
|
+
library_version: '2.0.1'
|
|
18
18
|
sources:
|
|
19
|
-
- 'Jielga/TMDataGrid:
|
|
20
|
-
- 'Jielga/TMDataGrid:
|
|
21
|
-
- 'Jielga/TMDataGrid:
|
|
19
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/use-tm-data-grid.md'
|
|
20
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/persistence.md'
|
|
21
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/useTMDataGrid.tsx'
|
|
22
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/persistence.ts'
|
|
22
23
|
---
|
|
23
24
|
|
|
24
25
|
# TMDataGrid - useTMDataGrid
|
|
@@ -30,6 +31,8 @@ const grid = useTMDataGrid<TData>(options);
|
|
|
30
31
|
// { table, ui, edit, features, labels, resetSettings, scrollToRow }
|
|
31
32
|
```
|
|
32
33
|
|
|
34
|
+
The signature is
|
|
35
|
+
`useTMDataGrid<TData>(options: UseTMDataGridOptions<TData>): TMDataGridApi<TData>`.
|
|
33
36
|
Spread the result onto `TMDataGrid`.
|
|
34
37
|
|
|
35
38
|
## Options
|
|
@@ -74,7 +77,7 @@ rather than forwarded to TanStack.
|
|
|
74
77
|
| Slice | Default |
|
|
75
78
|
| --- | --- |
|
|
76
79
|
| `pagination` | `{ pageIndex: 0, pageSize: 25 }` - inert until pagination is enabled |
|
|
77
|
-
| `columnPinning.
|
|
80
|
+
| `columnPinning.start` | The checkbox column, followed by any columns you provide |
|
|
78
81
|
| `globalFilterFn` | `"includesString"` |
|
|
79
82
|
|
|
80
83
|
### Controlled state
|
|
@@ -124,9 +127,9 @@ changes. Separate keys let one group be cleared without touching the other.
|
|
|
124
127
|
|
|
125
128
|
| Field | Type | Default | Description |
|
|
126
129
|
| --- | --- | --- | --- |
|
|
127
|
-
| `dataKey` | `string \| [string, DataSlice[]]` | – | Storage key for the data group. |
|
|
128
|
-
| `settingsKey` | `string \| [string, SettingsSlice[]]` | – | Storage key for the settings group. |
|
|
129
|
-
| `storageMode` | `"localStorage" \| "sessionStorage"` | `"localStorage"` | Storage area. |
|
|
130
|
+
| `dataKey` | `TMDataGridPersistKey<TMDataGridDataSlice>`: `string \| [string, DataSlice[]]` | – | Storage key for the data group. |
|
|
131
|
+
| `settingsKey` | `TMDataGridPersistKey<TMDataGridSettingsSlice>`: `string \| [string, SettingsSlice[]]` | – | Storage key for the settings group. |
|
|
132
|
+
| `storageMode` | `TMDataGridStorageMode`: `"localStorage" \| "sessionStorage"` | `"localStorage"` | Storage area. `"sessionStorage"` is per tab. |
|
|
130
133
|
| `serialize` | `(value) => string` | `JSON.stringify` | Serializes before storing. |
|
|
131
134
|
| `deserialize` | `(value: string) => unknown` | `JSON.parse` | Parses a stored payload. |
|
|
132
135
|
|
|
@@ -168,7 +171,8 @@ survives the data changing under it the way the column layout does. `expanded` i
|
|
|
168
171
|
a data slice for the opposite reason.
|
|
169
172
|
|
|
170
173
|
`DATA_STATE_SLICES` and `SETTINGS_STATE_SLICES` export the same values. Slice
|
|
171
|
-
names are typed per group,
|
|
174
|
+
names are typed per group, `TMDataGridDataSlice` and `TMDataGridSettingsSlice`,
|
|
175
|
+
so only valid names are accepted.
|
|
172
176
|
|
|
173
177
|
Restoring happens once on mount through `initialState`. Writing is a subscription
|
|
174
178
|
to the table store, so state changed directly through the table API is persisted
|
|
@@ -176,12 +180,20 @@ too. Only selected slices are read back, and unrecognised keys are ignored. All
|
|
|
176
180
|
storage access is guarded - if storage is unavailable, disabled or full,
|
|
177
181
|
persistence is skipped rather than throwing.
|
|
178
182
|
|
|
183
|
+
A payload from another version is dropped whole, not migrated. Payloads carry
|
|
184
|
+
the exported `PERSIST_PAYLOAD_VERSION`; anything else, including everything
|
|
185
|
+
written by a 0.x build, is discarded. Restored state is realigned against the
|
|
186
|
+
columns that exist: entries naming a column removed between deploys are
|
|
187
|
+
dropped.
|
|
188
|
+
|
|
189
|
+
Source: `packages/tmdatagrid/docs/persistence.md` (Behaviour).
|
|
190
|
+
|
|
179
191
|
## Return value
|
|
180
192
|
|
|
181
193
|
| Field | Type | Description |
|
|
182
194
|
| --- | --- | --- |
|
|
183
195
|
| `table` | `Table<TMDataGridFeatures, TData>` | The TanStack table instance. |
|
|
184
|
-
| `ui` | `Store<TMDataGridUiState, TMDataGridUiActions>` | State of the filter and column panels. |
|
|
196
|
+
| `ui` | `TMDataGridUiStore`: `Store<TMDataGridUiState, TMDataGridUiActions>` | State of the filter and column panels. |
|
|
185
197
|
| `edit` | `TMDataGridEditApi` | The edit engine, inert until `editing` is set. See the `editing` skill. |
|
|
186
198
|
| `features` | `TMDataGridFeatureFlags` | Table-level feature switches, re-read on each render. |
|
|
187
199
|
| `labels` | `TMDataGridLabels` | The resolved label set, overrides merged over English. |
|
|
@@ -208,8 +220,8 @@ const filterPanelOpen = useSelector(grid.ui, (state) => state.filterPanelOpen);
|
|
|
208
220
|
| --- | --- |
|
|
209
221
|
| `openFilterPanel` | `(columnId?: string \| null) => void` |
|
|
210
222
|
| `closeFilterPanel` | `() => void` |
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
223
|
+
| `focusPanelFilter` | `(columnId: string \| null) => void` |
|
|
224
|
+
| `focusHeaderFilter` | `(columnId: string \| null) => void` |
|
|
213
225
|
| `startColumnDrag` | `(columnId: string) => void` |
|
|
214
226
|
| `endColumnDrag` | `() => void` |
|
|
215
227
|
| `setHighlightedRow` | `(rowId: string \| null) => void` |
|
package/skills/rows/SKILL.md
CHANGED
|
@@ -17,14 +17,15 @@ description: >
|
|
|
17
17
|
metadata:
|
|
18
18
|
type: core
|
|
19
19
|
library: '@jielga/tmdatagrid'
|
|
20
|
-
library_version: '2.0.
|
|
20
|
+
library_version: '2.0.1'
|
|
21
21
|
sources:
|
|
22
|
-
- 'Jielga/TMDataGrid:
|
|
23
|
-
- 'Jielga/TMDataGrid:
|
|
24
|
-
- 'Jielga/TMDataGrid:
|
|
25
|
-
- 'Jielga/TMDataGrid:
|
|
26
|
-
- 'Jielga/TMDataGrid:
|
|
27
|
-
- 'Jielga/TMDataGrid:
|
|
22
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/row-selection.md'
|
|
23
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/row-interaction.md'
|
|
24
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/column-menu.md'
|
|
25
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/row-styling.md'
|
|
26
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/row-details.md'
|
|
27
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/row-pinning.md'
|
|
28
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/rowSelection.ts'
|
|
28
29
|
---
|
|
29
30
|
|
|
30
31
|
# TMDataGrid - Rows
|
|
@@ -187,13 +188,15 @@ array rather than a node:
|
|
|
187
188
|
|
|
188
189
|
Returning an empty list leaves the column with no menu button at all.
|
|
189
190
|
|
|
191
|
+
Source: `packages/tmdatagrid/docs/column-menu.md`.
|
|
192
|
+
|
|
190
193
|
## Row styling
|
|
191
194
|
|
|
192
195
|
```tsx
|
|
193
196
|
<TMDataGrid.Table<Employee>
|
|
194
197
|
striped
|
|
195
198
|
rowStyle={(row) =>
|
|
196
|
-
row.original.status === "Terminated"
|
|
199
|
+
!row.getIsGrouped() && row.original.status === "Terminated"
|
|
197
200
|
? { "--row-bg": "color-mix(in srgb, var(--mantine-color-red-6) 12%, transparent)" }
|
|
198
201
|
: undefined
|
|
199
202
|
}
|
|
@@ -211,8 +214,9 @@ are not striped.
|
|
|
211
214
|
Rows carry `data-selected`, `data-selected-bg`, `data-highlighted`,
|
|
212
215
|
`data-grouped`, `data-depth`, `data-context-menu` and `data-row-id`, so a
|
|
213
216
|
stylesheet can target any of it without a callback. The boolean attributes are
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
present, with the value `"true"`, only while they apply - `data-grouped` only
|
|
218
|
+
on group rows - so `[data-grouped]` and `[data-grouped="true"]` are
|
|
219
|
+
equivalent. Pick a `--row-bg` that
|
|
216
220
|
reads under both colour schemes - a `-0` Mantine shade is near-white and
|
|
217
221
|
unreadable in dark mode; mix a mid shade into transparency instead.
|
|
218
222
|
|
|
@@ -295,7 +299,7 @@ Correct:
|
|
|
295
299
|
rowStyle={() => ({ "--row-bg": "pink" })}
|
|
296
300
|
```
|
|
297
301
|
|
|
298
|
-
Source: `
|
|
302
|
+
Source: `packages/tmdatagrid/docs/row-styling.md` (Set `--row-bg`, not `background`).
|
|
299
303
|
|
|
300
304
|
### CRITICAL Reading the selection without subscribing
|
|
301
305
|
|
|
@@ -317,7 +321,7 @@ const selected = useSelector(grid.table.store, () =>
|
|
|
317
321
|
);
|
|
318
322
|
```
|
|
319
323
|
|
|
320
|
-
Source: `
|
|
324
|
+
Source: `packages/tmdatagrid/docs/row-selection.md` (Acting on a selection).
|
|
321
325
|
|
|
322
326
|
### HIGH Looking for the highlight in `rowSelection`
|
|
323
327
|
|
|
@@ -338,7 +342,7 @@ Correct:
|
|
|
338
342
|
const current = useSelector(grid.ui, (state) => state.highlightedRowId);
|
|
339
343
|
```
|
|
340
344
|
|
|
341
|
-
Source: `
|
|
345
|
+
Source: `packages/tmdatagrid/docs/row-selection.md` (The highlight is not a selection).
|
|
342
346
|
|
|
343
347
|
### HIGH Expecting a click handler to replace the built-in behaviour
|
|
344
348
|
|
|
@@ -353,7 +357,7 @@ Correct, when the click should only navigate:
|
|
|
353
357
|
useTMDataGrid({ data, columns, selectionMode: "highlight" });
|
|
354
358
|
```
|
|
355
359
|
|
|
356
|
-
Source: `
|
|
360
|
+
Source: `packages/tmdatagrid/docs/row-interaction.md`.
|
|
357
361
|
|
|
358
362
|
### HIGH Reading `row.getIsExpanded()` in a cell without subscribing
|
|
359
363
|
|
|
@@ -366,7 +370,7 @@ Correct:
|
|
|
366
370
|
const expanded = useSelector(row.table.store, () => row.getIsExpanded());
|
|
367
371
|
```
|
|
368
372
|
|
|
369
|
-
Source: `
|
|
373
|
+
Source: `packages/tmdatagrid/docs/row-details.md` (Opening a row from elsewhere).
|
|
370
374
|
|
|
371
375
|
### MEDIUM Assuming group rows behave like data rows
|
|
372
376
|
|
|
@@ -375,7 +379,7 @@ Group rows are built on their first child's record. They do not fire
|
|
|
375
379
|
never pin, they take no row number, and they have no details panel. A handler
|
|
376
380
|
written as though every row reaches it silently skips them.
|
|
377
381
|
|
|
378
|
-
Source: `
|
|
382
|
+
Source: `packages/tmdatagrid/docs/row-interaction.md`, `packages/tmdatagrid/docs/row-pinning.md`.
|
|
379
383
|
|
|
380
384
|
### MEDIUM Open panels closing when `data` is replaced
|
|
381
385
|
|
|
@@ -388,7 +392,7 @@ Correct:
|
|
|
388
392
|
useTMDataGrid({ data, columns, renderDetails, autoResetExpanded: false });
|
|
389
393
|
```
|
|
390
394
|
|
|
391
|
-
Source: `
|
|
395
|
+
Source: `packages/tmdatagrid/docs/row-details.md`.
|
|
392
396
|
|
|
393
397
|
### MEDIUM Expecting pinned rows to persist
|
|
394
398
|
|
|
@@ -396,7 +400,7 @@ Source: `src/docs/row-details.md`.
|
|
|
396
400
|
layout store outlives any one data set. A pinned id whose row leaves `data` is
|
|
397
401
|
not shown, and returns to its edge if the data comes back.
|
|
398
402
|
|
|
399
|
-
Source: `
|
|
403
|
+
Source: `packages/tmdatagrid/docs/row-pinning.md`.
|
|
400
404
|
|
|
401
405
|
## References
|
|
402
406
|
|
|
@@ -6,7 +6,7 @@ Reference for the `rows` skill.
|
|
|
6
6
|
|
|
7
7
|
| Name | Kind | Type | Default | What it does |
|
|
8
8
|
| --- | --- | --- | --- | --- |
|
|
9
|
-
| `selectionMode` | Option | `"checkbox" \| "row" \| "checkboxAndHighlight" \| "highlight"` | `"checkbox"` | What selecting looks like and what a row click does. |
|
|
9
|
+
| `selectionMode` | Option | `TMDataGridSelectionMode`: `"checkbox" \| "row" \| "checkboxAndHighlight" \| "highlight"` | `"checkbox"` | What selecting looks like and what a row click does. |
|
|
10
10
|
| `enableRowSelection` | Table option | `boolean \| ((row) => boolean)` | `true` | `false` removes the checkbox column and row-click selection. |
|
|
11
11
|
| `enableMultiRowSelection` | Table option | `boolean` | `true` | `false` limits the selection to one row and drops group checkboxes. |
|
|
12
12
|
| `showSelectedBackground` | Option | `boolean` | Follows the mode | Whether selected rows take a background tint. |
|
|
@@ -14,7 +14,8 @@ Reference for the `rows` skill.
|
|
|
14
14
|
| `onHighlightedRowChange` | Callback | `(rowId: string \| null) => void` | – | Fires when the highlight moves. |
|
|
15
15
|
| `SELECT_COLUMN_ID` | Export | `"__select__"` | – | Id of the generated checkbox column. |
|
|
16
16
|
| `getSelectableRowIds` | Export | `(table) => string[]` | – | Ids the header checkbox would select. |
|
|
17
|
-
| `resolveRowSelectionClick` | Export | `(args) => ResolvedRowSelection` | – | The desktop-list click rules, for a custom surface. |
|
|
17
|
+
| `resolveRowSelectionClick` | Export | `(args: ResolveRowSelectionClickArgs) => ResolvedRowSelection` | – | The desktop-list click rules, for a custom surface. |
|
|
18
|
+
| `ResolveRowSelectionClickArgs` · `TMDataGridRowClickModifiers` | Types | `{ rows, rowId, anchorRowId, modifiers, selection }` · `{ toggle, extend }` | – | What `resolveRowSelectionClick` takes, and its `modifiers`. |
|
|
18
19
|
| `getDisplayedRows` | Export | `(table) => Row[]` | – | The rows currently on screen, paging respected. |
|
|
19
20
|
| `isPagingActive` | Export | `(table) => boolean` | – | Whether a pager is in play. |
|
|
20
21
|
|
|
@@ -31,11 +32,13 @@ All are props of `TMDataGrid.Table`, not hook options.
|
|
|
31
32
|
| `onCellClick` | `(args) => void` | Cell click. `args` is `TMDataGridCellEventArgs`. |
|
|
32
33
|
| `onCellDoubleClick` | `(args) => void` | Cell double-click. |
|
|
33
34
|
| `onCellContextMenu` | `(args) => void` | Cell right-click. |
|
|
34
|
-
| `renderRowContextMenu` | `(
|
|
35
|
-
| `renderColumnMenuItems` | `(
|
|
35
|
+
| `renderRowContextMenu` | `TMDataGridRowContextMenuRenderer`: `(args: TMDataGridRowContextMenuArgs) => ReactNode` | Contents of the row's context menu. `null` for no menu. Reading `internalItems` hands the composition over. |
|
|
36
|
+
| `renderColumnMenuItems` | `TMDataGridColumnMenuItemsRenderer`: `(args: TMDataGridColumnMenuItemsArgs) => ReactNode[]` | Contents of a column's menu. An empty list removes the button. |
|
|
36
37
|
| `rowContextMenuProps` | `MenuProps` | Passed to the Mantine `Menu` unchanged, apart from its open state. |
|
|
37
38
|
|
|
38
|
-
`TMDataGridCellEventArgs` is `{ cell, row, column, event }`.
|
|
39
|
+
`TMDataGridCellEventArgs` is `{ cell, row, column, event }`.
|
|
40
|
+
`TMDataGridRowContextMenuArgs` is `{ table, row, cell, close, internalItems }`,
|
|
41
|
+
and `TMDataGridColumnMenuItemsArgs` is `{ column, table, internalItems }`. The context-menu
|
|
39
42
|
slot's `cell` is `null` only when a custom cell renderer stopped the
|
|
40
43
|
event. One `Menu` serves the whole body rather than one per row: a closed
|
|
41
44
|
Mantine `Popover` still runs its hooks on every render, and the virtualized body
|
|
@@ -76,13 +79,14 @@ Row data attributes:
|
|
|
76
79
|
|
|
77
80
|
| Name | Kind | Type | Default | What it does |
|
|
78
81
|
| --- | --- | --- | --- | --- |
|
|
79
|
-
| `renderDetails` | Option | `(
|
|
82
|
+
| `renderDetails` | Option | `TMDataGridDetailsRenderer`: `(args: TMDataGridDetailsArgs) => ReactNode` | – | Contents of the panel. Setting it adds the lane. `TMDataGridDetailsArgs` is `{ row, table }`. |
|
|
80
83
|
| `renderDetailsEstHeight` | Option | `number` | `160` | Height the virtualizer assumes for an unmeasured panel. |
|
|
81
84
|
| `initialState.expanded` | Table option | `ExpandedState` | `{}` | Rows open at mount. A `data` slice, so it persists. |
|
|
82
85
|
| `autoResetExpanded` | Table option | `boolean` | `true` | `false` keeps panels open when `data` changes. |
|
|
83
86
|
| `DETAILS_COLUMN_ID` | Export | `"__details__"` | – | Id of the generated chevron column. |
|
|
84
87
|
| `resolveExpandAll` | Export | `(args) => ExpandedState` | – | Expand or collapse every group, or every panel, but not both. |
|
|
85
88
|
| `areAllRowsExpanded` | Export | `(args) => boolean` | – | Whether every row of one target is open. |
|
|
89
|
+
| `TMDataGridExpandAllArgs` · `TMDataGridExpandTarget` | Types | `{ rows, expanded, target }` · `"groups" \| "details"` | – | What `areAllRowsExpanded` takes (`resolveExpandAll` also takes `expand`), and its `target`. |
|
|
86
90
|
| `data-dg-part="details"` | Data attribute | – | – | The panel element, carrying the row's `data-row-id`. |
|
|
87
91
|
|
|
88
92
|
One `expanded` state opens two unrelated things - a group row into its children,
|