@jielga/tmdatagrid 2.1.3 → 2.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/README.md +1 -1
- package/dist/index.d.ts +38 -2
- package/dist/index.js +1329 -1246
- package/dist/index.js.map +1 -1
- package/docs/cell-selection.md +1 -1
- package/docs/column-layout.md +13 -8
- package/docs/columns.md +57 -2
- package/docs/export.md +2 -2
- package/docs/filtering.md +105 -15
- package/docs/getting-started.md +40 -0
- package/docs/grouping.md +9 -6
- package/docs/loading-and-empty.md +29 -9
- package/docs/localization.md +130 -3
- package/docs/menu.md +1 -1
- package/docs/pagination.md +26 -7
- package/docs/row-details.md +36 -4
- package/docs/row-interaction.md +1 -1
- package/docs/row-selection.md +6 -7
- package/docs/scrolling.md +1 -1
- package/docs/server-side.md +3 -1
- package/docs/testing.md +18 -0
- package/docs/use-tm-data-grid.md +69 -34
- package/package.json +2 -2
- package/skills/appearance/SKILL.md +6 -4
- package/skills/appearance/references/labels.md +126 -0
- package/skills/cell-selection/SKILL.md +2 -2
- package/skills/columns/SKILL.md +42 -41
- package/skills/columns/references/columns-api.md +15 -1
- package/skills/data/SKILL.md +77 -50
- package/skills/editing/SKILL.md +1 -1
- package/skills/filtering/SKILL.md +71 -49
- package/skills/filtering/references/custom-filters.md +118 -0
- package/skills/getting-started/SKILL.md +37 -2
- package/skills/grouping/SKILL.md +16 -9
- package/skills/migrating-to-2/SKILL.md +1 -1
- package/skills/options/SKILL.md +131 -51
- package/skills/rows/SKILL.md +53 -31
- package/skills/server-side/SKILL.md +1 -1
- package/skills/testing/SKILL.md +12 -1
- package/skills/testing-components/SKILL.md +1 -1
- package/skills/testing-editing/SKILL.md +1 -1
- package/src/components/TMDataGridTable.tsx +241 -41
- package/src/core/autosize.ts +19 -7
- package/src/core/cellRange.ts +11 -2
- package/src/core/colSpan.ts +78 -0
- package/src/core/columnUtils.ts +7 -0
- package/src/core/filterOperators.ts +16 -1
- package/src/index.ts +4 -0
- package/src/useTMDataGrid.tsx +38 -0
package/docs/localization.md
CHANGED
|
@@ -59,12 +59,139 @@ context as `useTMDataGridContext().labels`, so a
|
|
|
59
59
|
[toolbar component of your own](/docs/toolbar) uses the same strings as the
|
|
60
60
|
built-in parts, in whatever language is configured.
|
|
61
61
|
|
|
62
|
-
`mergeLabels(
|
|
63
|
-
|
|
62
|
+
`mergeLabels(override)` is the merge itself: it folds a partial override over
|
|
63
|
+
the English defaults, `operators` included, and returns the full dictionary.
|
|
64
|
+
Called without an argument, it returns `TMDATAGRID_LABELS_EN` itself.
|
|
64
65
|
|
|
65
66
|
`meta.noResultsLabel` remains as a per-instance override of
|
|
66
67
|
`labels.noResults`.
|
|
67
68
|
|
|
69
|
+
## Label keys
|
|
70
|
+
|
|
71
|
+
Every key of `TMDataGridLabels`, with its English default and where the grid
|
|
72
|
+
shows it; a function label shows its template:
|
|
73
|
+
|
|
74
|
+
| Key | Default | Where it shows |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `operators.contains` | `contains` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
77
|
+
| `operators.equals` | `equals` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
78
|
+
| `operators.notEquals` | `does not equal` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
79
|
+
| `operators.startsWith` | `starts with` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
80
|
+
| `operators.endsWith` | `ends with` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
81
|
+
| `operators.greaterThan` | `is greater than` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
82
|
+
| `operators.greaterThanOrEqual` | `is greater than or equal to` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
83
|
+
| `operators.lessThan` | `is less than` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
84
|
+
| `operators.lessThanOrEqual` | `is less than or equal to` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
85
|
+
| `operators.between` | `is between` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
86
|
+
| `operators.before` | `is before` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
87
|
+
| `operators.after` | `is after` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
88
|
+
| `operators.onOrBefore` | `is on or before` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
89
|
+
| `operators.onOrAfter` | `is on or after` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
90
|
+
| `operators.isAnyOf` | `is any of` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
91
|
+
| `operators.isNoneOf` | `is none of` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
92
|
+
| `operators.isEmpty` | `is empty` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
93
|
+
| `operators.isNotEmpty` | `is not empty` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
94
|
+
| `filters` | `Filters` | Tooltip and `aria-label` of `TMDataGrid.FilterButton`, the title and `aria-label` of the filter popup and sidebar, and the `aria-label` of `TMDataGrid.FilterPanel`. |
|
|
95
|
+
| `searchPlaceholder` | `Search` | Placeholder of `TMDataGrid.Search`. Its `placeholder` prop wins. |
|
|
96
|
+
| `searchLabel` | `Search rows` | `aria-label` of the `TMDataGrid.Search` input. |
|
|
97
|
+
| `clearSearch` | `Clear search` | `aria-label` of the clear button in `TMDataGrid.Search`. |
|
|
98
|
+
| `menuButton` | `Menu` | Tooltip and `aria-label` of the `TMDataGrid.Menu` trigger. Its `label` prop wins. |
|
|
99
|
+
| `manageColumns` | `Manage columns` | Column menu: the submenu that lists the columns. |
|
|
100
|
+
| `columnsSearchPlaceholder` | `Search` | Search box of `TMDataGrid.ColumnsPanel`, `TMDataGrid.Menu.Columns` and the export column picker. |
|
|
101
|
+
| `columnsNoMatch` | `` `No columns match “${search}”` `` | The same three lists, when the search matches no column. |
|
|
102
|
+
| `columnsShowHideAll` | `Show/Hide All` | `TMDataGrid.ColumnsPanel` and `TMDataGrid.Menu.ShowHideAll`. |
|
|
103
|
+
| `columnsReset` | `Reset layout` | `TMDataGrid.ColumnsPanel` and `TMDataGrid.Menu.ResetLayout`. |
|
|
104
|
+
| `columnsResetHint` | `Resets column visibility, order, widths, pinning and grouping` | Tooltip of the reset button in `TMDataGrid.ColumnsPanel`. |
|
|
105
|
+
| `rowNumberColumnLabel` | `Row number` | `meta.label` of the generated row-number lane. |
|
|
106
|
+
| `noRows` | `No rows to show` | Body, when the view is empty, no column filter is active (`isFilterActive`) and the quick search is blank. |
|
|
107
|
+
| `filterColumn` | `Column` | Label of the column field in `TMDataGrid.FilterPanel`. |
|
|
108
|
+
| `filterOperator` | `Operator` | Label of the operator field in `TMDataGrid.FilterPanel`. |
|
|
109
|
+
| `filterValue` | `Value` | Label of the value field in `TMDataGrid.FilterPanel`. |
|
|
110
|
+
| `filterValuePlaceholder` | `Filter value` | Placeholder of the filter value input. |
|
|
111
|
+
| `filterFrom` | `From` | The lower bound of a `between` filter: its input, or its slider thumb. |
|
|
112
|
+
| `filterTo` | `To` | The upper bound of a `between` filter: its input, or its slider thumb. |
|
|
113
|
+
| `filterAll` | `All` | The no-filter segment of the tri-state filter. |
|
|
114
|
+
| `booleanTrue` | `Yes` | The `true` choice of a boolean filter value control and of the tri-state filter. |
|
|
115
|
+
| `booleanFalse` | `No` | The `false` choice of a boolean filter value control and of the tri-state filter. |
|
|
116
|
+
| `addFilter` | `Add filter` | Button in `TMDataGrid.FilterPanel`. |
|
|
117
|
+
| `clearAllFilters` | `Clear all` | Button in `TMDataGrid.FilterPanel` and in `TMDataGrid.FilterPills`. |
|
|
118
|
+
| `closeFilters` | `Close filters` | `aria-label` of the close button of the filter popup and sidebar. |
|
|
119
|
+
| `removeFilter` | `Remove filter` | `aria-label` of the remove button on a filter row in `TMDataGrid.FilterPanel`. |
|
|
120
|
+
| `filterOperatorFor` | `` `${column} filter operator` `` | `aria-label` of the operator button of a header filter. |
|
|
121
|
+
| `activeFilters` | `Active filters` | `aria-label` of the `TMDataGrid.FilterPills` group. |
|
|
122
|
+
| `clearFilter` | `` `Clear ${column} filter` `` | `aria-label` of the remove button on a filter pill. |
|
|
123
|
+
| `sortAsc` | `Sort ascending` | Column menu item. |
|
|
124
|
+
| `sortDesc` | `Sort descending` | Column menu item. |
|
|
125
|
+
| `filterMenuItem` | `Filter` | Column menu item. |
|
|
126
|
+
| `groupBy` | `` `Group by ${column}` `` | Column menu item. |
|
|
127
|
+
| `ungroup` | `` `Ungroup ${column}` `` | Column menu item. |
|
|
128
|
+
| `expandAllGroups` | `Expand all groups` | Column menu item. |
|
|
129
|
+
| `collapseAllGroups` | `Collapse all groups` | Column menu item. |
|
|
130
|
+
| `pinLeft` | `Pin to left` | Column menu item. |
|
|
131
|
+
| `pinRight` | `Pin to right` | Column menu item. |
|
|
132
|
+
| `unpin` | `Unpin` | Column menu item. |
|
|
133
|
+
| `moveLeft` | `Move left` | Column menu item. |
|
|
134
|
+
| `moveRight` | `Move right` | Column menu item. |
|
|
135
|
+
| `autosizeColumn` | `Autosize column` | Column menu item. |
|
|
136
|
+
| `hideColumn` | `Hide column` | Column menu item. |
|
|
137
|
+
| `filterOn` | `` `Filter on ${column}` `` | `aria-label` of the header filter button, of a header filter cell, and of the value control in it. |
|
|
138
|
+
| `sortColumn` | `` `Sort ${column}` `` | `aria-label` of the header sort button. |
|
|
139
|
+
| `columnMenu` | `` `${column} column menu` `` | `aria-label` of the column menu trigger. |
|
|
140
|
+
| `rowsPerPage` | `Rows per page:` | `TMDataGrid.Footer`: the text before the page size select. |
|
|
141
|
+
| `pageRange` | `` `${from}–${to} of ${total}` `` | `TMDataGrid.Footer`: the range of rows on the page. |
|
|
142
|
+
| `pageNumber` | `` `Page ${page} of ${pageCount}` ``, or `` `Page ${page}` `` when `pageCount` is `-1` | `TMDataGrid.Footer`: the page number. |
|
|
143
|
+
| `groupedAllRows` | `` `Grouped · all ${total} rows` `` | `TMDataGrid.Footer`: in place of the range and the page number while the rows are grouped. |
|
|
144
|
+
| `pagingSuspendedHint` | `Paging is off while the rows are grouped, and every row is shown. Ungroup to page again.` | `TMDataGrid.Footer`: tooltip of the pager while the rows are grouped. |
|
|
145
|
+
| `previousPage` | `Previous page` | `TMDataGrid.Footer`: `aria-label` of the previous page button. |
|
|
146
|
+
| `nextPage` | `Next page` | `TMDataGrid.Footer`: `aria-label` of the next page button. |
|
|
147
|
+
| `noResults` | `No rows match your filters` | Body, when the view is empty and a column filter is active (`isFilterActive`) or the quick search is not blank. `meta.noResultsLabel` overrides it. |
|
|
148
|
+
| `loading` | `Loading` | `aria-label` of the body loader, of `TMDataGrid.LoadingIndicator`, and of the edit lane spinner while a row saves. |
|
|
149
|
+
| `editCell` | `` `Edit ${column}` `` | `aria-label` of an open cell editor. |
|
|
150
|
+
| `confirmEdit` | `Save` | `aria-label` of the ✓ button beside a cell editor. |
|
|
151
|
+
| `cancelEdit` | `Cancel` | `aria-label` of the ✕ button beside a cell editor. |
|
|
152
|
+
| `editColumnLabel` | `Edit` | `meta.label` of the generated edit lane. |
|
|
153
|
+
| `editRow` | `Edit row` | Edit lane: tooltip and `aria-label` of the pencil button. |
|
|
154
|
+
| `saveRow` | `Save row` | Edit lane: tooltip and `aria-label` of the ✓ button while a row edit is open. |
|
|
155
|
+
| `cancelRowEdit` | `Cancel edit` | Edit lane: tooltip and `aria-label` of the ✕ button while a row edit is open. |
|
|
156
|
+
| `editRowErrors` | `Fix the marked cells` | Edit lane: tooltip of the save button when field errors block the row and the row has no message of its own. |
|
|
157
|
+
| `saveAllEdits` | `"Save 1 row"` when `rows` is 1, else `` `Save ${rows} rows` `` | `TMDataGrid.DraftActions`: the save button. |
|
|
158
|
+
| `discardAllEdits` | `Discard` | `TMDataGrid.DraftActions`: the discard button. |
|
|
159
|
+
| `editRowsStillOpen` | `"1 row still being edited"` when `rows` is 1, else `` `${rows} rows still being edited` `` | `TMDataGrid.DraftActions`: the note shown while rows are still open in an edit. |
|
|
160
|
+
| `confirmNewRow` | `Add row` | Edit lane: tooltip and `aria-label` of the ✓ button on the entry row. |
|
|
161
|
+
| `discardNewRow` | `Discard new row` | Edit lane: tooltip and `aria-label` of the ✕ button on the entry row. |
|
|
162
|
+
| `deleteRow` | `Delete row` | Edit lane: tooltip and `aria-label` of the trash button. |
|
|
163
|
+
| `restoreRow` | `Restore row` | Edit lane: tooltip and `aria-label` of the undo button on a row marked for deletion. |
|
|
164
|
+
| `revertRow` | `Revert changes` | Edit lane: tooltip and `aria-label` of the undo button on a row with a draft. |
|
|
165
|
+
| `rowStateNew` | `New row` | Edit lane: the row-state marker of a confirmed entry row. |
|
|
166
|
+
| `rowStateEdited` | `Edited row` | Edit lane: the row-state marker of a row with a draft. |
|
|
167
|
+
| `rowStateDeleted` | `Marked for deletion` | Edit lane: the row-state marker of a row marked for deletion. |
|
|
168
|
+
| `cellCount` | `"1 cell"` when `count` is 1, else `` `${count} cells` `` | Cell-selection context menu: its heading. |
|
|
169
|
+
| `copy` | `Copy` | Cell-selection context menu item. |
|
|
170
|
+
| `exportCells` | `Export cells` | Cell-selection context menu item. |
|
|
171
|
+
| `includeHeaders` | `Include headers` | Cell-selection context menu: the checkbox. |
|
|
172
|
+
| `exportAll` | `Export all rows` | `TMDataGrid.Menu.Export`. Its `label` prop wins. |
|
|
173
|
+
| `exportSelected` | `"Export 1 selected row"` when `count` is 1, else `` `Export ${count} selected rows` `` | `TMDataGrid.Menu.ExportSelected`. Its `label` prop wins. |
|
|
174
|
+
| `exportPickerTitle` | `` `Export as ${format}` `` | Export column picker: the title. `format` is the file extension in upper case. |
|
|
175
|
+
| `exportPickerHint` | `"Select the columns to export"` when `selected` is `null`, `"Select the columns to export for the selected row"` when it is 1, else `` `Select the columns to export for the ${selected} selected rows` `` | Export column picker: the line under the title. |
|
|
176
|
+
| `exportPickerConfirm` | `Export` | Export column picker: the confirm button. |
|
|
177
|
+
| `exportPickerCancel` | `Cancel` | Export column picker: the cancel button. |
|
|
178
|
+
| `exportPickerSelectAll` | `Select all` | Export column picker: the select-all checkbox over the list. |
|
|
179
|
+
| `exportPickerCount` | `` `${checked} of ${total}` `` | Export column picker: the count beside the select-all checkbox. |
|
|
180
|
+
| `exportPickerHidden` | `Hidden` | Export column picker: the mark on a column the grid hides. |
|
|
181
|
+
| `selectColumnLabel` | `Checkbox selection` | `meta.label` of the generated checkbox lane. |
|
|
182
|
+
| `selectAllRows` | `Select all rows` | `aria-label` of the header checkbox. |
|
|
183
|
+
| `selectRow` | `Select row` | `aria-label` of a row checkbox. |
|
|
184
|
+
| `selectGroup` | `Select group` | `aria-label` of a group row checkbox. |
|
|
185
|
+
| `detailsColumnLabel` | `Details` | `meta.label` of the generated details lane. |
|
|
186
|
+
| `showDetails` | `Show details` | `aria-label` of a collapsed row's details toggle. |
|
|
187
|
+
| `hideDetails` | `Hide details` | `aria-label` of an expanded row's details toggle. |
|
|
188
|
+
| `expandAllDetails` | `Expand all details` | `aria-label` of the details lane's header toggle while some row is collapsed. |
|
|
189
|
+
| `collapseAllDetails` | `Collapse all details` | `aria-label` of the details lane's header toggle while every row is expanded. |
|
|
190
|
+
| `groupColumnLabel` | `Group` | `meta.label` of the generated tree lane, and its header text while nothing is grouped. |
|
|
191
|
+
| `blankGroupValue` | `(Blank)` | Group row text for an empty group key. |
|
|
192
|
+
| `expandGroup` | `` `Expand ${label}` `` | `aria-label` of a collapsed group row's toggle. |
|
|
193
|
+
| `collapseGroup` | `` `Collapse ${label}` `` | `aria-label` of an expanded group row's toggle. |
|
|
194
|
+
|
|
68
195
|
## Reference
|
|
69
196
|
|
|
70
197
|
| Name | Kind | Type | Default | What it does |
|
|
@@ -75,5 +202,5 @@ dictionaries before passing one in.
|
|
|
75
202
|
| `TMDATAGRID_LABELS_SV` | Export | `TMDataGridLabels` | – | A complete Swedish dictionary. |
|
|
76
203
|
| `TMDataGridLabels` | Export | type | – | The full dictionary. What a new translation must cover. |
|
|
77
204
|
| `TMDataGridLabelsOverride` | Export | type | – | A partial dictionary. |
|
|
78
|
-
| `mergeLabels` | Export | `(
|
|
205
|
+
| `mergeLabels` | Export | `(override?: TMDataGridLabelsOverride) => TMDataGridLabels` | – | Folds a partial override over the English defaults. Returns `TMDATAGRID_LABELS_EN` itself without an argument. |
|
|
79
206
|
| `meta.noResultsLabel` | Option | `string` | `labels.noResults` | Per-instance override of the filtered-empty message. |
|
package/docs/menu.md
CHANGED
|
@@ -54,7 +54,7 @@ The pieces it is made of are exported for menus that want only some of them.
|
|
|
54
54
|
| `TMDataGrid.Menu.Columns` | `Menu.Search`, the toggles, a divider, show/hide all and reset layout. By default the search box shows from six columns; `searchable` shows it always and `searchable={false}` never. |
|
|
55
55
|
| `TMDataGrid.Menu.ColumnToggles` | One item per hideable column, with a checkbox that shows both states. `search` narrows the list to the labels containing it. |
|
|
56
56
|
| `TMDataGrid.Menu.ShowHideAll` | One checkbox item over the same list. An indeterminate box marks a partial state, and a click then shows all. |
|
|
57
|
-
| `TMDataGrid.Menu.ResetLayout` | One item calling `resetSettings()`: visibility, order, pinning and
|
|
57
|
+
| `TMDataGrid.Menu.ResetLayout` | One item calling `resetSettings()`: visibility, order, pinning, widths and grouping. |
|
|
58
58
|
|
|
59
59
|
Each of them needs a Mantine `Menu` around it and reads the grid from context, so they work in any Mantine menu rendered inside `TMDataGrid`, not only in the burger:
|
|
60
60
|
|
package/docs/pagination.md
CHANGED
|
@@ -21,6 +21,18 @@ its pager. Initial page size is 25, configurable through
|
|
|
21
21
|
const grid = useTMDataGrid({ data, columns, enablePagination: true });
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
The Footer renders a rows-per-page select, the range (`1–25 of 300`, from
|
|
25
|
+
`table.getRowCount()`) and previous and next buttons. The select offers
|
|
26
|
+
`pageSizeOptions`, by default `[10, 25, 50, 100]`, with the current size folded
|
|
27
|
+
in when it is not in the list. Pass a module-scope array: the select is
|
|
28
|
+
memoized on it, and an inline literal remounts it on every render.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
const PAGE_SIZES = [10, 20, 50];
|
|
32
|
+
|
|
33
|
+
<TMDataGrid.Footer pageSizeOptions={PAGE_SIZES} />
|
|
34
|
+
```
|
|
35
|
+
|
|
24
36
|
**Manual pagination** - the server pages, and the grid stops.
|
|
25
37
|
`manualPagination: true` implies `enablePagination`, so no extra flag is
|
|
26
38
|
needed. See [Server-side data](/docs/server-side).
|
|
@@ -102,15 +114,20 @@ It reads `pageCount`, so a grid declaring `pageCount: -1` shows "Page 3" alone.
|
|
|
102
114
|
and `isPagingActive`. `actions` carries `setPageIndex`, `setPageSize`,
|
|
103
115
|
`previousPage`, `nextPage`, `firstPage` and `lastPage`.
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
Outside the Footer,
|
|
118
|
+
`getTMDataGridPaginationApi(table, isPagingActive(table, grid.features))`
|
|
119
|
+
returns the same `{ state, actions }`, for a pager that lives elsewhere on the
|
|
120
|
+
page. Without the second argument `state.isPagingActive` is `true`, also while
|
|
121
|
+
the rows are grouped. `Controls` is not included: those components are bound to
|
|
122
|
+
the grid's context and work only inside the slot.
|
|
109
123
|
|
|
110
124
|
## Grouping
|
|
111
125
|
|
|
112
126
|
While a column is grouped the pager greys itself out and the range is replaced
|
|
113
|
-
with `Grouped · all N rows`.
|
|
127
|
+
with `Grouped · all N rows`. The default footer also carries
|
|
128
|
+
`data-paging-suspended` on its bar and shows `labels.pagingSuspendedHint` as a
|
|
129
|
+
tooltip; a footer with `renderPagination` has neither. The body shows every filtered
|
|
130
|
+
row. There is no option to keep the built-in pager active while grouped. See
|
|
114
131
|
[Grouping](/docs/grouping#grouping-and-pagination).
|
|
115
132
|
|
|
116
133
|
A custom pager can grey itself out the same way:
|
|
@@ -134,11 +151,13 @@ paging is switched on at all. The two differ while a grouping is active.
|
|
|
134
151
|
| `enablePagination` | Option | `boolean` | `false` | Client-side paging and the Footer's pager. Grid-defined. |
|
|
135
152
|
| `manualPagination` | Table option | `boolean` | `false` | The server pages. Implies `enablePagination`. |
|
|
136
153
|
| `rowCount` | Table option | `number` | – | The true total, required under `manualPagination`. |
|
|
137
|
-
| `initialState.pagination` | Table option | `{ pageIndex, pageSize }` | `{ 0, 25 }` | Where paging starts. A data slice, so it persists. |
|
|
154
|
+
| `initialState.pagination` | Table option | `{ pageIndex, pageSize }` | `{ pageIndex: 0, pageSize: 25 }` | Where paging starts. A data slice, so it persists. |
|
|
138
155
|
| `onPaginationChange` | Table option | `OnChangeFn` | – | Controls the pagination state. |
|
|
139
156
|
| `resetPageOnQueryChange` | Option | `boolean` | `true` | Back to page 1 when a filter, the quick search, the sort or the grouping changes. `false` keeps the page. See [Server-side data](/docs/server-side#the-page-index). |
|
|
140
157
|
| `TMDataGrid.Footer` | Component | – | – | The footer bar. Renders nothing when paging is off. |
|
|
158
|
+
| `Footer` `pageSizeOptions` | Prop | `ReadonlyArray<number>` | `[10, 25, 50, 100]` | The rows-per-page choices. Keep the array referentially stable. |
|
|
141
159
|
| `Footer` `renderPagination` | Slot | `({ state, actions, Controls }) => ReactNode` | Built-in pager | Replaces the pager, and hands over its pieces. |
|
|
142
|
-
| `
|
|
160
|
+
| `data-paging-suspended` | Data attribute | – | – | On the default footer bar while grouping suspends paging. |
|
|
161
|
+
| `getTMDataGridPaginationApi` | Export | `(table, isPaging?) => { state, actions }` | `isPaging`: `true` | The pager API, outside the Footer. Pass `isPagingActive(table, features)` as `isPaging`. |
|
|
143
162
|
| `TMDataGridPaginationState` · `TMDataGridPaginationActions` · `TMDataGridPaginationControls` | Exports | types | – | The three parts of the slot's argument. |
|
|
144
163
|
| `isPagingActive` | Export | `(table, features) => boolean` | – | Whether the pager is slicing anything right now. |
|
package/docs/row-details.md
CHANGED
|
@@ -19,10 +19,13 @@ hint: Expand a few rows - the panels differ in height, and each one is measured.
|
|
|
19
19
|
height: 460
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
The panel
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
The panel opens below the row's cells, which stay where they are; there is no
|
|
23
|
+
mode in which a panel replaces the row. The panel is as tall as whatever it
|
|
24
|
+
renders. The grid measures each one, so they need not be uniform.
|
|
25
|
+
`renderDetailsEstHeight` (default `160`) is what the virtualizer assumes for a
|
|
26
|
+
panel it has not measured yet, which keeps the scrollbar accurate for rows that
|
|
27
|
+
open off screen. Set it to the typical panel height; the estimate only decides
|
|
28
|
+
how far the scrollbar is off until the panel has mounted.
|
|
26
29
|
|
|
27
30
|
## The details lane
|
|
28
31
|
|
|
@@ -87,6 +90,12 @@ Because it is the standard state, `table.toggleAllRowsExpanded()`,
|
|
|
87
90
|
> `autoResetExpanded: false`; pass `autoResetExpanded: true` to have a new
|
|
88
91
|
> `data` array close the panels.
|
|
89
92
|
|
|
93
|
+
## A wider cell on an open row
|
|
94
|
+
|
|
95
|
+
To have an open row show something wider in the row itself - a title across
|
|
96
|
+
the columns, say - give that column a `meta.colSpan` that depends on
|
|
97
|
+
`row.getIsExpanded()`. See [Spanning columns](/docs/columns#spanning-columns).
|
|
98
|
+
|
|
90
99
|
## The two kinds of expanding
|
|
91
100
|
|
|
92
101
|
TanStack keeps one `expanded` state, and the grid uses it for two unrelated
|
|
@@ -121,6 +130,29 @@ not select or highlight the row underneath. It carries
|
|
|
121
130
|
|
|
122
131
|
Group rows have no panel. Expanding one opens its children.
|
|
123
132
|
|
|
133
|
+
Rows are virtualized. A row that leaves the viewport and the `overscan`
|
|
134
|
+
unmounts, and its panel unmounts with it, so state held inside the panel is
|
|
135
|
+
lost. Keep such state outside the grid, keyed by `row.id`. Rows pinned to an
|
|
136
|
+
edge never unmount.
|
|
137
|
+
|
|
138
|
+
`renderDetails` runs on every render of the body. Give a heavy panel a memoized
|
|
139
|
+
component and pass it the record, not the row:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
const EmployeeDetails = memo(function EmployeeDetails({ employee }: { employee: Employee }) {
|
|
143
|
+
return <EmployeeCard employee={employee} />;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const grid = useTMDataGrid({
|
|
147
|
+
data,
|
|
148
|
+
columns,
|
|
149
|
+
renderDetails: ({ row }) => <EmployeeDetails employee={row.original} />,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Key a stateful child by `row.id`; that is stable only when `getRowId` returns
|
|
154
|
+
the entity id.
|
|
155
|
+
|
|
124
156
|
## Reference
|
|
125
157
|
|
|
126
158
|
| Name | Kind | Type | Default | What it does |
|
package/docs/row-interaction.md
CHANGED
|
@@ -100,7 +100,7 @@ copy and export items too. By default they appear above a divider and yours
|
|
|
100
100
|
below, which is what happens when the render prop does not use `internalItems`.
|
|
101
101
|
See [Cell selection](/docs/cell-selection#copy-and-export).
|
|
102
102
|
|
|
103
|
-
`internalItems`
|
|
103
|
+
`internalItems` holds those built-in items. **Using it takes over the
|
|
104
104
|
composition**: the menu becomes exactly what you return, in the order you
|
|
105
105
|
return it.
|
|
106
106
|
|
package/docs/row-selection.md
CHANGED
|
@@ -18,8 +18,7 @@ file: rows/SelectionModes.tsx
|
|
|
18
18
|
## The four modes
|
|
19
19
|
|
|
20
20
|
`selectionMode` sets what selecting looks like and what a bare row click does.
|
|
21
|
-
A click
|
|
22
|
-
are one option rather than two.
|
|
21
|
+
A bare click either toggles the selection or moves the highlight, never both.
|
|
23
22
|
|
|
24
23
|
| Mode | Checkbox column | Row click |
|
|
25
24
|
| ---- | --------------- | --------- |
|
|
@@ -28,8 +27,8 @@ are one option rather than two.
|
|
|
28
27
|
| `"checkboxAndHighlight"` | yes, multi-select | highlights one row |
|
|
29
28
|
| `"highlight"` | no | highlights one row - no selection at all |
|
|
30
29
|
|
|
31
|
-
The first two write to TanStack's `rowSelection`, so
|
|
32
|
-
`
|
|
30
|
+
The first two write to TanStack's `rowSelection`, so `getSelectedRowModel()`
|
|
31
|
+
and `onRowSelectionChange` behave the same either way.
|
|
33
32
|
|
|
34
33
|
Under `"row"` the click follows the usual desktop-list conventions: a plain
|
|
35
34
|
click replaces the selection with this row, Ctrl/Cmd toggles it and leaves the
|
|
@@ -71,9 +70,9 @@ For a panel that opens under the row instead of beside the grid, see
|
|
|
71
70
|
|
|
72
71
|
Read the selection through the table store with TanStack Store's
|
|
73
72
|
[`useSelector`](https://tanstack.com/store/latest/docs/framework/react/reference), rather
|
|
74
|
-
than by calling a method directly.
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
than by calling a method directly. A bare read is stale in any component that
|
|
74
|
+
does not call `useTMDataGrid` itself, and under the React Compiler also in the
|
|
75
|
+
one that does; `useSelector` subscribes either way.
|
|
77
76
|
|
|
78
77
|
```tsx
|
|
79
78
|
const selected = useSelector(
|
package/docs/scrolling.md
CHANGED
|
@@ -103,7 +103,7 @@ boundary and the pinned band is always on.
|
|
|
103
103
|
| Name | Kind | Type | Default | What it does |
|
|
104
104
|
| --- | --- | --- | --- | --- |
|
|
105
105
|
| `overscan` | Option | `number` | `6` | Rows kept mounted beyond each edge of the viewport. |
|
|
106
|
-
| `meta.rowHeight` | Option | `number` |
|
|
106
|
+
| `meta.rowHeight` | Option | `number` | `52` at the default `md` size; see [the size scale](/docs/styling#the-size-scale) | Row height, in pixels. The virtualizer needs a number. |
|
|
107
107
|
| `scrollToRow` | Hook return | `({ rowId, align? }) => boolean` | `align: "auto"` | Scrolls a row into view, mounted or not. Answers whether it could be reached. |
|
|
108
108
|
| `TMDataGridScrollToRowArgs` | Type | `{ rowId, align? }` | – | What `scrollToRow` takes. |
|
|
109
109
|
| `onScrollToTop` · `onScrollToBottom` · `onScrollToLeft` · `onScrollToRight` | Table props | `() => void` | – | Fire once on arriving at that edge. |
|
package/docs/server-side.md
CHANGED
|
@@ -64,7 +64,7 @@ column manager behave identically in both modes.
|
|
|
64
64
|
|
|
65
65
|
## The page index
|
|
66
66
|
|
|
67
|
-
A column filter, the quick search or a
|
|
67
|
+
A column filter, the quick search, a sort or a grouping changes what page 3 means.
|
|
68
68
|
The result set is a different one, and it may not have a page 3 at all - so the grid resets `pageIndex` to 0 whenever the query changes, on every grid.
|
|
69
69
|
The reset is applied in the same event as the change, so one request goes out, for the first page of the new query.
|
|
70
70
|
|
|
@@ -139,6 +139,8 @@ even though they are no longer mounted. Read the state rather than the row
|
|
|
139
139
|
models:
|
|
140
140
|
|
|
141
141
|
```ts
|
|
142
|
+
// In an event handler. In render, subscribe instead:
|
|
143
|
+
// useSelector(grid.table.store, (state) => Object.keys(state.rowSelection))
|
|
142
144
|
const selectedIds = Object.keys(grid.table.store.state.rowSelection);
|
|
143
145
|
```
|
|
144
146
|
|
package/docs/testing.md
CHANGED
|
@@ -66,6 +66,24 @@ const cell = orders.locator(
|
|
|
66
66
|
Body cells carry no `data-dg-part`; the coordinate pair identifies them.
|
|
67
67
|
The `editor` part of an open cell carries the same pair, so `:not([data-dg-part])` keeps the locator on the cell while the cell is being edited.
|
|
68
68
|
|
|
69
|
+
The generated lanes are columns like any other, with exported ids:
|
|
70
|
+
|
|
71
|
+
| Constant | `data-column-id` | Lane |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `ROW_NUMBER_COLUMN_ID` | `__rowNumber__` | Row numbers |
|
|
74
|
+
| `SELECT_COLUMN_ID` | `__select__` | Selection checkboxes |
|
|
75
|
+
| `GROUP_COLUMN_ID` | `__group__` | The grouping tree |
|
|
76
|
+
| `DETAILS_COLUMN_ID` | `__details__` | Details toggles |
|
|
77
|
+
| `EDIT_COLUMN_ID` | `__edit__` | Row editing |
|
|
78
|
+
|
|
79
|
+
A lane's header is `[data-dg-part="header"][data-column-id="__select__"]` and
|
|
80
|
+
a lane cell `[data-row-id="42"][data-column-id="__select__"]:not([data-dg-part])`.
|
|
81
|
+
The control inside a lane cell has a part of its own, keyed by the row:
|
|
82
|
+
`select-row`, `details-toggle`, `group-toggle` and the edit lane's buttons (see
|
|
83
|
+
[Keyed by `data-row-id`](#keyed-by-data-row-id)); `select-all` and
|
|
84
|
+
`details-toggle-all` sit in the lane headers. The checkbox parts are on the
|
|
85
|
+
`<input>` itself, so `check()` works on them directly.
|
|
86
|
+
|
|
69
87
|
**The body scrolls inside the scroll container.** The element carrying
|
|
70
88
|
`data-dg-scroll-container` is the one to scroll in a test, whether to load the
|
|
71
89
|
next page of an infinite-scroll grid or to move the virtualizer without the api:
|
package/docs/use-tm-data-grid.md
CHANGED
|
@@ -4,7 +4,7 @@ Creates the table instance and the state used by the grid interface.
|
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
6
|
const grid = useTMDataGrid<TData>(options);
|
|
7
|
-
//
|
|
7
|
+
// TMDataGridApi<TData>, see Return value
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
Spread the result onto `TMDataGrid`.
|
|
@@ -16,48 +16,69 @@ including `data`, `columns`, `getRowId`, `state` and the `onXChange` callbacks
|
|
|
16
16
|
(see [Controlled state](#controlled-state)), the `manual*` flags and `rowCount`.
|
|
17
17
|
The `features` option is supplied internally and cannot be overridden.
|
|
18
18
|
|
|
19
|
-
`persist`, `
|
|
19
|
+
The grid defines these options itself: `persist`, `labels`, `editing`,
|
|
20
|
+
`filters`, `exportOptions`, `enableColumnOrdering`, `enablePagination`,
|
|
21
|
+
`resetPageOnQueryChange`, `enableRowNumbers`, `selectionMode`,
|
|
20
22
|
`showSelectedBackground`, `defaultHighlightedRowId`, `onHighlightedRowChange`,
|
|
21
|
-
`
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
`cellSelection`, `onFocusedCellChange`, `renderDetails`,
|
|
24
|
+
`renderDetailsEstHeight`, `detailsColumnPosition`, `overscan`,
|
|
25
|
+
`quickSearchMode` and `enableMatchHighlighting`. The table below marks them
|
|
26
|
+
"Defined by the grid"; every other row is a TanStack option, listed where the
|
|
27
|
+
grid changes its default or where it decides something visible. A TanStack
|
|
28
|
+
default the grid changes reads, for example, `"remove"` (grid default;
|
|
29
|
+
TanStack: `"reorder"`). A TanStack option that is not listed passes through
|
|
30
|
+
with TanStack's own default.
|
|
25
31
|
|
|
26
32
|
| Option | Type | Default | Description |
|
|
27
33
|
| --- | --- | --- | --- |
|
|
28
|
-
| `data` | `TData[]` | – | Row data. When the reference changes the table reprocesses the row models, so keep it stable with `useMemo
|
|
29
|
-
| `columns` | `ColumnDef[]` | – | Created with `createTMDataGridColumnHelper`. |
|
|
30
|
-
| `getRowId` | `(row, index) => string` | Row index |
|
|
34
|
+
| `data` | `TData[]` | – | Row data. When the reference changes the table reprocesses the row models, so keep it stable with `useMemo`; a fresh `[]` for the empty case belongs in a module-scope constant. |
|
|
35
|
+
| `columns` | `ColumnDef[]` | – | Created with `createTMDataGridColumnHelper`. Define them outside the component. |
|
|
36
|
+
| `getRowId` | `(row, index, parent?) => string` | Row index | The id that row selection, expansion, row pinning and editing are keyed by. The index points at another record after a sort or a refetch, so return the entity id. Required once `editing` is set. |
|
|
37
|
+
| `defaultColumn` | `Partial<ColumnDef>` | `{ minSize: 80 }` (grid default; TanStack: `{}`) | Defaults merged under every column. The grid sets `filterFn: "tmDataGrid"` and clears `aggregationFn` and `aggregatedCell` on every column, so those three keys have no effect here; a value on the column wins. |
|
|
31
38
|
| `enableRowSelection` | `boolean \| (row) => boolean` | `true` | `false` removes row selection and its checkbox column. |
|
|
39
|
+
| `enableMultiRowSelection` | `boolean \| (row) => boolean` | `true` | `false` removes the select-all checkbox and limits the selection to one row. |
|
|
32
40
|
| `selectionMode` | `"checkbox" \| "row" \| "checkboxAndHighlight" \| "highlight"` | `"checkbox"` | What selecting looks like and what a bare row click does. Defined by the grid, see [Row selection](/docs/row-selection). |
|
|
33
41
|
| `showSelectedBackground` | `boolean` | On for `"row"`, off for `"checkbox"` | Determines whether selected rows take a background tint, coloured by `--dg-row-selected-bg`. Defined by the grid, see [Row selection](/docs/row-selection). |
|
|
34
|
-
| `defaultHighlightedRowId` | `string \| null` | – | Row highlighted on mount, under a mode with a highlight. Read once, like `initialState`. |
|
|
35
|
-
| `onHighlightedRowChange` | `(rowId: string \| null) => void` | – | Follows the highlighted row, from clicks and from `ui.actions.setHighlightedRow`. |
|
|
36
|
-
| `enableSorting` | `boolean` | `true` |
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
42
|
+
| `defaultHighlightedRowId` | `string \| null` | – | Row highlighted on mount, under a mode with a highlight. Read once, like `initialState`. Defined by the grid. |
|
|
43
|
+
| `onHighlightedRowChange` | `(rowId: string \| null) => void` | – | Follows the highlighted row, from clicks and from `ui.actions.setHighlightedRow`. Defined by the grid. |
|
|
44
|
+
| `enableSorting` | `boolean` | `true` | `false` removes the sort indicator, the sort menu items and click-to-sort. Also a column option. See [Sorting](/docs/sorting). |
|
|
45
|
+
| `enableMultiSort` | `boolean` | `true` for accessor columns | Shift+click on a header adds a sort instead of replacing it. Also a column option. See [Sorting](/docs/sorting). |
|
|
46
|
+
| `maxMultiSortColCount` | `number` | `Number.MAX_SAFE_INTEGER` | How many sorts are kept; past it the oldest is dropped. |
|
|
47
|
+
| `enableColumnFilters` | `boolean` | `true` | `false` removes the filter menu item, the `FilterButton`, the header filter row and the panel's column list, and disables the panel's "Add filter" button. Filters already in state still apply. See [Filtering](/docs/filtering#turning-it-off). |
|
|
48
|
+
| `enableGlobalFilter` | `boolean` | `true` | `false` removes `Search`. Also a column option, removing one column from the search. See [Quick search](/docs/quick-search). |
|
|
49
|
+
| `globalFilterFn` | filter fn \| name | `"tmDataGridFuzzy"`; `"includesString"` under `quickSearchMode: "contains"` (grid default; TanStack: `"auto"`) | How the quick search matches. An explicit value also switches the fuzzy rank ordering off. |
|
|
50
|
+
| `enableHiding` | `boolean` | `true` | `false` removes the Hide column item, the Manage columns submenu and the column chooser. Also a column option. |
|
|
39
51
|
| `enableColumnPinning` | `boolean` | `true` | Enables pinning for the table. `false` removes the pin menu items; the generated lanes stay pinned. |
|
|
40
|
-
| `enableColumnResizing` | `boolean` | `true` |
|
|
52
|
+
| `enableColumnResizing` | `boolean` | `true` | With `false` the divider is displayed but cannot be dragged, and double-click autosize and the Autosize menu item are removed. Also a column option, as `enableResizing`. |
|
|
41
53
|
| `enableColumnOrdering` | `boolean` | `true` | Enables header dragging and the move menu items. Defined by the grid, see [Column layout](/docs/column-layout#ordering). |
|
|
54
|
+
| `enableGrouping` | `boolean` | `true`; `false` under `manualPagination` (grid default; TanStack: `true`) | `false` removes the Group by and Ungroup menu items and the tree lane. Also a column option. See [Grouping](/docs/grouping). |
|
|
55
|
+
| `groupedColumnMode` | `"remove" \| "reorder" \| false` | `"remove"` (grid default; TanStack: `"reorder"`) | What happens to a column the rows are grouped by: `"remove"` takes it out of the grid, `"reorder"` moves it to the front, `false` leaves it in place. See [Grouping](/docs/grouping). |
|
|
42
56
|
| `enablePagination` | `boolean` | `false` | Enables client-side paging and the `Footer` pager. Implied by `manualPagination`. Defined by the grid, see [Pagination](/docs/pagination). |
|
|
57
|
+
| `resetPageOnQueryChange` | `boolean` | `true` | Returns to the first page when a column filter, the quick search, the sorting or the grouping changes through the table. A `data` change does not count. Defined by the grid, see [Pagination](/docs/pagination). |
|
|
58
|
+
| `autoResetPageIndex` | `boolean` | `false` (grid default; TanStack: `!manualPagination`) | TanStack's return to the first page on every `data` change. Off, since `resetPageOnQueryChange` covers the query. |
|
|
59
|
+
| `autoResetExpanded` | `boolean` | `false` (grid default; TanStack: `!manualExpanding`) | TanStack's collapse of every expanded row on a `data` change. Off, so open details panels survive a refetch. |
|
|
60
|
+
| `manualFiltering`, `manualSorting`, `manualGrouping`, `manualPagination` | `boolean` | `false` | The server does that step and the grid shows `data` as given. `manualPagination` also implies `enablePagination`. See [Server-side data](/docs/server-side). |
|
|
61
|
+
| `rowCount` | `number` | – | The total row count under `manualPagination`, read by the pager. |
|
|
43
62
|
| `enableRowNumbers` | `boolean` | `false` | The row-number gutter, outermost left. Defined by the grid, see [Row pinning and numbering](/docs/row-pinning). |
|
|
44
|
-
| `enableRowPinning` | `boolean \| (row) => boolean` | `false` | Rows can be pinned to sticky edge blocks with `row.pin()`. See [Row pinning and numbering](/docs/row-pinning). |
|
|
63
|
+
| `enableRowPinning` | `boolean \| (row) => boolean` | `false` (grid default; TanStack: `true`) | Rows can be pinned to sticky edge blocks with `row.pin()`. See [Row pinning and numbering](/docs/row-pinning). |
|
|
45
64
|
| `quickSearchMode` | `"fuzzy" \| "contains"` | `"fuzzy"` | How `Search` matches. Fuzzy forgives typos and orders unsorted results by match quality; `"contains"` is plain substring matching. Defined by the grid, see [Quick search](/docs/quick-search). |
|
|
46
65
|
| `enableMatchHighlighting` | `boolean` | `false` | Cells mark the matched text while a contains-family filter or the quick search is active. Defined by the grid, see [Quick search](/docs/quick-search#match-highlighting). |
|
|
47
66
|
| `renderDetails` | `({ row, table }) => ReactNode` | – | Panel rendered under an expanded row, spanning every column. Setting it turns row details on and adds the pinned chevron lane. Defined by the grid, see [Row details](/docs/row-details). |
|
|
48
|
-
| `renderDetailsEstHeight` | `number` | `160` | What the virtualizer assumes for a panel it has not measured yet. Panels are measured once mounted, so an approximation is enough. |
|
|
67
|
+
| `renderDetailsEstHeight` | `number` | `160` | What the virtualizer assumes for a panel it has not measured yet. Panels are measured once mounted, so an approximation is enough. Defined by the grid. |
|
|
49
68
|
| `detailsColumnPosition` | `"left" \| "right"` | `"left"` | Which edge the details lane is pinned to. `"right"` places it after every column, inside the edit lane. Defined by the grid, see [Row details](/docs/row-details). |
|
|
50
69
|
| `cellSelection` | `"none" \| "single" \| "range"` | `"none"` | Cell cursor and, under `"range"`, a selectable rectangle with Ctrl+C and CSV export. Defined by the grid, see [Cell selection](/docs/cell-selection). |
|
|
51
|
-
| `onFocusedCellChange` | `(cell: TMDataGridCellPosition \| null) => void` | – | Called whenever the focused cell moves, by key, click or `setFocusedCell`. |
|
|
52
|
-
| `overscan` | `number` | `6` | Rows the virtualizer keeps mounted above and below the viewport. Raise it if fast scrolling flashes blank rows, lower it when rows are expensive to render. |
|
|
70
|
+
| `onFocusedCellChange` | `(cell: TMDataGridCellPosition \| null) => void` | – | Called whenever the focused cell moves, by key, click or `setFocusedCell`. Defined by the grid. |
|
|
71
|
+
| `overscan` | `number` | `6` | Rows the virtualizer keeps mounted above and below the viewport. Raise it if fast scrolling flashes blank rows, lower it when rows are expensive to render. Defined by the grid. |
|
|
53
72
|
| `columnResizeMode` | `"onChange" \| "onEnd"` | `"onEnd"` | When a resize drag writes `columnSizing`. The grid paints a running drag itself either way; `"onChange"` also publishes a width on every pointer move, which re-renders the grid with each of them. |
|
|
54
73
|
| `initialState` | `Partial<TableState>` | – | Starting state, read once on mount. Merged over the [grid defaults](#default-initial-state). |
|
|
55
74
|
| `state` | `Partial<TableState>` | – | Controlled state. Each slice requires its `onXChange`. See [Controlled state](#controlled-state). |
|
|
56
75
|
| `atoms` | `Partial<Record<slice, Atom>>` | – | External atoms owning state slices. No callback required. Takes precedence over `state`. |
|
|
57
76
|
| `meta` | `TMDataGridTableMeta` | `{}` | Grid configuration. See [meta](#meta). |
|
|
58
|
-
| `filters` | `TMDataGridFiltersOptions` | `{ surface: "popup" }` | Where the filter controls go - a popup, a sidebar, the column headers, or nowhere.
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
77
|
+
| `filters` | `TMDataGridFiltersOptions` | `{ surface: "popup" }` | Where the filter controls go - a popup, a sidebar, the column headers, or nowhere. Defined by the grid, see [Filtering](/docs/filtering#the-filters-option). |
|
|
78
|
+
| `exportOptions` | `TMDataGridExportOptions` | `csvExcelFormat()`, `"export"`, headers on, `"visible"` columns | The export's `format`, `fileName`, `includeHeaders` and `columns`. Defined by the grid, see [Export](/docs/export). |
|
|
79
|
+
| `editing` | `TMDataGridEditingOptions` | off | Turns editing on. `mode` picks what counts as a commit and `draft` whether edits collect in the draft store. Requires `getRowId`. Defined by the grid, see [Editing](/docs/editing). |
|
|
80
|
+
| `persist` | `TMDataGridPersistence` | – | State persistence. Defined by the grid, see [persist](#persist). |
|
|
81
|
+
| `labels` | `TMDataGridLabelsOverride` | English | Overrides for the grid's strings and `aria-label`s. Defined by the grid, see [Localization](#localization). |
|
|
61
82
|
|
|
62
83
|
### Default initial state
|
|
63
84
|
|
|
@@ -66,7 +87,6 @@ rather than forwarded to TanStack.
|
|
|
66
87
|
| `pagination` | `{ pageIndex: 0, pageSize: 25 }`. Inert until pagination is enabled |
|
|
67
88
|
| `columnPinning.start` | The row number, checkbox, tree and details columns, followed by any columns you provide. The details column moves to `end` under `detailsColumnPosition: "right"` |
|
|
68
89
|
| `columnPinning.end` | Any columns you provide, then the details column under `detailsColumnPosition: "right"`, then the edit column |
|
|
69
|
-
| `globalFilterFn` | `"tmDataGridFuzzy"`, the fuzzy matcher behind `quickSearchMode`. `"includesString"` under `quickSearchMode: "contains"` |
|
|
70
90
|
|
|
71
91
|
### Controlled state
|
|
72
92
|
|
|
@@ -110,10 +130,10 @@ Grid configuration, passed through the `meta` option.
|
|
|
110
130
|
|
|
111
131
|
| Field | Type | Default | Description |
|
|
112
132
|
| --- | --- | --- | --- |
|
|
113
|
-
| `loading` | `boolean` |
|
|
133
|
+
| `loading` | `boolean` | `false` | Displays a loader while the grid is empty. Takes precedence over every empty state. |
|
|
114
134
|
| `noResultsLabel` | `string` | `"No rows match your filters"` | The filtered-empty message. A grid with no data and no filters says `labels.noRows` instead; `renderEmptyState` on the Table replaces both. |
|
|
115
135
|
| `rowHeight` | `number` | From `size` | Row height in px. Overrides the size scale. |
|
|
116
|
-
| `totalRowCount` | `number` | – | Unfiltered total used by `SummaryCount`.
|
|
136
|
+
| `totalRowCount` | `number` | – | Unfiltered total used by `SummaryCount`. Without it a `manualFiltering` or `manualPagination` grid shows the shown count alone. |
|
|
117
137
|
|
|
118
138
|
## Localization
|
|
119
139
|
|
|
@@ -247,6 +267,7 @@ identifier if several users can share a browser profile.
|
|
|
247
267
|
| `table` | `Table<TMDataGridFeatures, TData>` | The TanStack table instance. |
|
|
248
268
|
| `ui` | `Store<TMDataGridUiState, TMDataGridUiActions>` | State of the filter and column panels. |
|
|
249
269
|
| `filters` | `TMDataGridFiltersSettings` | The `filters` option with its defaults filled in. See [Filtering](/docs/filtering#the-filters-option). |
|
|
270
|
+
| `exportOptions` | `TMDataGridExportSettings` | The `exportOptions` option with its defaults filled in. See [Export](/docs/export). |
|
|
250
271
|
| `edit` | `TMDataGridEditApi` | The edit engine, inert until `editing` is set. See [Editing](/docs/editing). |
|
|
251
272
|
| `features` | `TMDataGridFeatureFlags` | Table-level feature switches, re-read from options on each render. See [Toolbar](/docs/toolbar#reading-options-reactively). |
|
|
252
273
|
| `labels` | `TMDataGridLabels` | The resolved label set, overrides merged over English. See [Localization](/docs/localization). |
|
|
@@ -278,22 +299,34 @@ The identity is stable, so it is safe in a dependency array. Before
|
|
|
278
299
|
`TMDataGrid.Table` has mounted there is nothing to scroll and it returns
|
|
279
300
|
`false`.
|
|
280
301
|
|
|
281
|
-
|
|
282
|
-
|
|
302
|
+
### Reading state
|
|
303
|
+
|
|
304
|
+
`table.store` and `ui` are TanStack stores. Read a slice with `useSelector`
|
|
305
|
+
from `@tanstack/react-store`, which subscribes the component to what the
|
|
306
|
+
selector returns:
|
|
283
307
|
|
|
284
308
|
```tsx
|
|
285
309
|
import { useSelector } from "@tanstack/react-store";
|
|
286
310
|
|
|
287
311
|
const selectedCount = useSelector(
|
|
288
312
|
grid.table.store,
|
|
289
|
-
(
|
|
313
|
+
() => grid.table.getSelectedRowModel().rows.length,
|
|
290
314
|
);
|
|
291
|
-
|
|
315
|
+
const isGrouped = useSelector(grid.table.store, (state) =>
|
|
316
|
+
state.grouping.includes("department"),
|
|
317
|
+
);
|
|
318
|
+
const pageIndex = useSelector(grid.table.store, (state) => state.pagination.pageIndex);
|
|
292
319
|
const filterPanelOpen = useSelector(grid.ui, (state) => state.filterPanelOpen);
|
|
293
320
|
```
|
|
294
321
|
|
|
295
|
-
|
|
296
|
-
read
|
|
322
|
+
`grid.table.store.state` is a plain read and does not subscribe the component.
|
|
323
|
+
A bare read is stale in any component that does not call `useTMDataGrid`
|
|
324
|
+
itself, and under the React Compiler also in the one that does; `useSelector`
|
|
325
|
+
subscribes either way. A table or column getter such as
|
|
326
|
+
`table.getSelectedRowModel()` or `column.getIsGrouped()` is a plain read as
|
|
327
|
+
well; call it inside a selector, as above. Note that `table.getState()` does
|
|
328
|
+
not exist in TanStack Table v9, and `table.state` is not part of
|
|
329
|
+
`TMDataGridTable`.
|
|
297
330
|
|
|
298
331
|
### ui actions
|
|
299
332
|
|
|
@@ -301,6 +334,8 @@ read does not subscribe the component to the store.
|
|
|
301
334
|
| --- | --- |
|
|
302
335
|
| `openFilterPanel` | `(columnId?: string \| null) => void` |
|
|
303
336
|
| `closeFilterPanel` | `() => void` |
|
|
337
|
+
| `openExportPicker` | `(request: TMDataGridExportPickerRequest) => void` |
|
|
338
|
+
| `closeExportPicker` | `() => void` |
|
|
304
339
|
| `focusPanelFilter` | `(columnId: string \| null) => void` |
|
|
305
340
|
| `focusHeaderFilter` | `(columnId: string \| null) => void` |
|
|
306
341
|
| `startColumnDrag` | `(columnId: string) => void` |
|
|
@@ -316,7 +351,7 @@ focus follows `focusedCell` while the grid holds it, scrolling the row into view
|
|
|
316
351
|
when it is off screen.
|
|
317
352
|
|
|
318
353
|
`startColumnDrag` and `endColumnDrag` are called by the header cells while a
|
|
319
|
-
column is being dragged. `ui.draggedColumnId` holds the column being moved,
|
|
354
|
+
column is being dragged. `ui.state.draggedColumnId` holds the column being moved,
|
|
320
355
|
since `dataTransfer` is unreadable until the drop.
|
|
321
356
|
|
|
322
357
|
`openColumnFilter(grid, columnId)` combines two steps used by the column menu:
|
|
@@ -342,7 +377,7 @@ to off; ordering, like the options around it, defaults to on.
|
|
|
342
377
|
| Option | Level | Interface removed |
|
|
343
378
|
| --- | --- | --- |
|
|
344
379
|
| `enableSorting: false` | Table, column | Sort indicator, sort menu items, click-to-sort. See [Sorting](/docs/sorting) |
|
|
345
|
-
| `enableColumnFilters: false` | Table | Filter menu item, `FilterButton`, filter
|
|
380
|
+
| `enableColumnFilters: false` | Table | Filter menu item, `FilterButton`, header filter row, the panel's column list; the panel's "Add filter" button is disabled. Filters already in state still apply, with their pills and header indicators. See [Filtering](/docs/filtering#turning-it-off) |
|
|
346
381
|
| `enableColumnFilter: false` | Column | That column's filter menu item, panel entry and header control |
|
|
347
382
|
| `enableGlobalFilter: false` | Table, column | `Search`: the whole input at table level, one column's participation at column level |
|
|
348
383
|
| `enableHiding: false` | Table, column | Hide column, Manage columns, `TMDataGrid.Menu.Columns`. See [Column layout](/docs/column-layout) |
|
|
@@ -359,6 +394,6 @@ to off; ordering, like the options around it, defaults to on.
|
|
|
359
394
|
| `enableRowNumbers: true` | Table | Opt-in: the row-number gutter, outermost left. Numbers the current view: sorted, filtered, continuing across pages. Group rows take no number |
|
|
360
395
|
| `enableRowPinning: true` | Table | Opt-in: rows can be pinned to sticky edge blocks with `row.pin()`. Also takes a per-row predicate. See [Row pinning](/docs/row-pinning) |
|
|
361
396
|
| `enableMatchHighlighting: true` | Table | Opt-in: cells mark the matched text while a contains-family filter or the quick search is active. See [Quick search](/docs/quick-search#match-highlighting) |
|
|
362
|
-
| `enableGrouping: false` | Table, column | Group by and Ungroup menu items. See [Grouping](/docs/grouping) |
|
|
397
|
+
| `enableGrouping: false` | Table, column | Group by and Ungroup menu items, and the tree lane at table level. The default is `false` under `manualPagination`. See [Grouping](/docs/grouping) |
|
|
363
398
|
| `renderDetails` | Table | Opt-in: adds the details lane, and an expanded row opens a panel underneath it. See [Row details](/docs/row-details) |
|
|
364
399
|
| `detailsColumnPosition: "right"` | Table | The details lane on the right edge, inside the edit lane, instead of the left. See [Row details](/docs/row-details) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jielga/tmdatagrid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A React data grid built on TanStack Table v9 and Mantine - always virtualized, with resizable, reorderable, sortable, filterable, hideable and pinnable columns.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "git+https://github.com/Jielga/react.git",
|
|
13
13
|
"directory": "packages/tmdatagrid"
|
|
14
14
|
},
|
|
15
|
-
"homepage": "https://jielga.github.io/react/",
|
|
15
|
+
"homepage": "https://jielga.github.io/react/tmdatagrid/",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/Jielga/react/issues"
|
|
18
18
|
},
|