@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
|
@@ -18,7 +18,7 @@ description: >
|
|
|
18
18
|
metadata:
|
|
19
19
|
type: core
|
|
20
20
|
library: '@jielga/tmdatagrid'
|
|
21
|
-
library_version: '2.
|
|
21
|
+
library_version: '2.2.0'
|
|
22
22
|
sources:
|
|
23
23
|
- 'Jielga/react:packages/tmdatagrid/docs/styling.md'
|
|
24
24
|
- 'Jielga/react:packages/tmdatagrid/docs/toolbar.md'
|
|
@@ -250,7 +250,9 @@ const labels = {
|
|
|
250
250
|
`TMDataGridLabels` is the full dictionary type, so a missing key in a new
|
|
251
251
|
translation is a compile error. The resolved dictionary comes back as
|
|
252
252
|
`grid.labels` and from `useTMDataGridContext().labels`, so a component of your
|
|
253
|
-
own uses the same strings as the built-in parts.
|
|
253
|
+
own uses the same strings as the built-in parts. Every key, with its English
|
|
254
|
+
default and where the grid shows it, is in
|
|
255
|
+
[references/labels.md](references/labels.md).
|
|
254
256
|
|
|
255
257
|
## Common mistakes
|
|
256
258
|
|
|
@@ -319,7 +321,7 @@ const { canSort } = getColumnCapabilities(column, features);
|
|
|
319
321
|
if (!canSort) return null;
|
|
320
322
|
```
|
|
321
323
|
|
|
322
|
-
Source: `packages/tmdatagrid/docs/toolbar.md` (
|
|
324
|
+
Source: `packages/tmdatagrid/docs/toolbar.md` (Reading options reactively).
|
|
323
325
|
|
|
324
326
|
### MEDIUM An inline `labels` object
|
|
325
327
|
|
|
@@ -370,7 +372,7 @@ Source: `packages/tmdatagrid/docs/toolbar.md` (The built-in parts).
|
|
|
370
372
|
| `grid.labels` | Hook return | `TMDataGridLabels` | – | The resolved dictionary. |
|
|
371
373
|
| `TMDATAGRID_LABELS_EN` · `TMDATAGRID_LABELS_SV` | Exports | `TMDataGridLabels` | – | The English base, and a complete Swedish dictionary. |
|
|
372
374
|
| `TMDataGridLabels` · `TMDataGridLabelsOverride` | Exports | types | – | The full dictionary, and a partial one. |
|
|
373
|
-
| `mergeLabels` | Export | `(
|
|
375
|
+
| `mergeLabels` | Export | `(override?: TMDataGridLabelsOverride) => TMDataGridLabels` | – | Folds a partial override over the English defaults. Returns `TMDATAGRID_LABELS_EN` itself without an argument. |
|
|
374
376
|
| `meta.noResultsLabel` | Option | `string` | `labels.noResults` | Per-instance override of the filtered-empty message. |
|
|
375
377
|
|
|
376
378
|
The CSS layer name `tmdatagrid` in `styles.layer.css` is public API and never
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# TMDataGrid labels
|
|
2
|
+
|
|
3
|
+
Reference for the `appearance` skill: every key of `TMDataGridLabels`, its English default, and where the grid shows it; a function label shows its template.
|
|
4
|
+
`TMDataGridLabels` has a fixed set of keys, so a full translation sets every key.
|
|
5
|
+
The `labels` option takes a partial override, `TMDataGridLabelsOverride`, merged over English key by key; `operators` merges per operator.
|
|
6
|
+
|
|
7
|
+
| Key | Default | Where it shows |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `operators.contains` | `contains` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
10
|
+
| `operators.equals` | `equals` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
11
|
+
| `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. |
|
|
12
|
+
| `operators.startsWith` | `starts with` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
13
|
+
| `operators.endsWith` | `ends with` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
14
|
+
| `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. |
|
|
15
|
+
| `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. |
|
|
16
|
+
| `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. |
|
|
17
|
+
| `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. |
|
|
18
|
+
| `operators.between` | `is between` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
19
|
+
| `operators.before` | `is before` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
20
|
+
| `operators.after` | `is after` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
21
|
+
| `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. |
|
|
22
|
+
| `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. |
|
|
23
|
+
| `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. |
|
|
24
|
+
| `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. |
|
|
25
|
+
| `operators.isEmpty` | `is empty` | The operator select of `TMDataGrid.FilterPanel`, the text of a filter pill, and the operator button of a header filter. |
|
|
26
|
+
| `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. |
|
|
27
|
+
| `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`. |
|
|
28
|
+
| `searchPlaceholder` | `Search` | Placeholder of `TMDataGrid.Search`. Its `placeholder` prop wins. |
|
|
29
|
+
| `searchLabel` | `Search rows` | `aria-label` of the `TMDataGrid.Search` input. |
|
|
30
|
+
| `clearSearch` | `Clear search` | `aria-label` of the clear button in `TMDataGrid.Search`. |
|
|
31
|
+
| `menuButton` | `Menu` | Tooltip and `aria-label` of the `TMDataGrid.Menu` trigger. Its `label` prop wins. |
|
|
32
|
+
| `manageColumns` | `Manage columns` | Column menu: the submenu that lists the columns. |
|
|
33
|
+
| `columnsSearchPlaceholder` | `Search` | Search box of `TMDataGrid.ColumnsPanel`, `TMDataGrid.Menu.Columns` and the export column picker. |
|
|
34
|
+
| `columnsNoMatch` | `` `No columns match “${search}”` `` | The same three lists, when the search matches no column. |
|
|
35
|
+
| `columnsShowHideAll` | `Show/Hide All` | `TMDataGrid.ColumnsPanel` and `TMDataGrid.Menu.ShowHideAll`. |
|
|
36
|
+
| `columnsReset` | `Reset layout` | `TMDataGrid.ColumnsPanel` and `TMDataGrid.Menu.ResetLayout`. |
|
|
37
|
+
| `columnsResetHint` | `Resets column visibility, order, widths, pinning and grouping` | Tooltip of the reset button in `TMDataGrid.ColumnsPanel`. |
|
|
38
|
+
| `rowNumberColumnLabel` | `Row number` | `meta.label` of the generated row-number lane. |
|
|
39
|
+
| `noRows` | `No rows to show` | Body, when the view is empty, no column filter is active (`isFilterActive`) and the quick search is blank. |
|
|
40
|
+
| `filterColumn` | `Column` | Label of the column field in `TMDataGrid.FilterPanel`. |
|
|
41
|
+
| `filterOperator` | `Operator` | Label of the operator field in `TMDataGrid.FilterPanel`. |
|
|
42
|
+
| `filterValue` | `Value` | Label of the value field in `TMDataGrid.FilterPanel`. |
|
|
43
|
+
| `filterValuePlaceholder` | `Filter value` | Placeholder of the filter value input. |
|
|
44
|
+
| `filterFrom` | `From` | The lower bound of a `between` filter: its input, or its slider thumb. |
|
|
45
|
+
| `filterTo` | `To` | The upper bound of a `between` filter: its input, or its slider thumb. |
|
|
46
|
+
| `filterAll` | `All` | The no-filter segment of the tri-state filter. |
|
|
47
|
+
| `booleanTrue` | `Yes` | The `true` choice of a boolean filter value control and of the tri-state filter. |
|
|
48
|
+
| `booleanFalse` | `No` | The `false` choice of a boolean filter value control and of the tri-state filter. |
|
|
49
|
+
| `addFilter` | `Add filter` | Button in `TMDataGrid.FilterPanel`. |
|
|
50
|
+
| `clearAllFilters` | `Clear all` | Button in `TMDataGrid.FilterPanel` and in `TMDataGrid.FilterPills`. |
|
|
51
|
+
| `closeFilters` | `Close filters` | `aria-label` of the close button of the filter popup and sidebar. |
|
|
52
|
+
| `removeFilter` | `Remove filter` | `aria-label` of the remove button on a filter row in `TMDataGrid.FilterPanel`. |
|
|
53
|
+
| `filterOperatorFor` | `` `${column} filter operator` `` | `aria-label` of the operator button of a header filter. |
|
|
54
|
+
| `activeFilters` | `Active filters` | `aria-label` of the `TMDataGrid.FilterPills` group. |
|
|
55
|
+
| `clearFilter` | `` `Clear ${column} filter` `` | `aria-label` of the remove button on a filter pill. |
|
|
56
|
+
| `sortAsc` | `Sort ascending` | Column menu item. |
|
|
57
|
+
| `sortDesc` | `Sort descending` | Column menu item. |
|
|
58
|
+
| `filterMenuItem` | `Filter` | Column menu item. |
|
|
59
|
+
| `groupBy` | `` `Group by ${column}` `` | Column menu item. |
|
|
60
|
+
| `ungroup` | `` `Ungroup ${column}` `` | Column menu item. |
|
|
61
|
+
| `expandAllGroups` | `Expand all groups` | Column menu item. |
|
|
62
|
+
| `collapseAllGroups` | `Collapse all groups` | Column menu item. |
|
|
63
|
+
| `pinLeft` | `Pin to left` | Column menu item. |
|
|
64
|
+
| `pinRight` | `Pin to right` | Column menu item. |
|
|
65
|
+
| `unpin` | `Unpin` | Column menu item. |
|
|
66
|
+
| `moveLeft` | `Move left` | Column menu item. |
|
|
67
|
+
| `moveRight` | `Move right` | Column menu item. |
|
|
68
|
+
| `autosizeColumn` | `Autosize column` | Column menu item. |
|
|
69
|
+
| `hideColumn` | `Hide column` | Column menu item. |
|
|
70
|
+
| `filterOn` | `` `Filter on ${column}` `` | `aria-label` of the header filter button, of a header filter cell, and of the value control in it. |
|
|
71
|
+
| `sortColumn` | `` `Sort ${column}` `` | `aria-label` of the header sort button. |
|
|
72
|
+
| `columnMenu` | `` `${column} column menu` `` | `aria-label` of the column menu trigger. |
|
|
73
|
+
| `rowsPerPage` | `Rows per page:` | `TMDataGrid.Footer`: the text before the page size select. |
|
|
74
|
+
| `pageRange` | `` `${from}–${to} of ${total}` `` | `TMDataGrid.Footer`: the range of rows on the page. |
|
|
75
|
+
| `pageNumber` | `` `Page ${page} of ${pageCount}` ``, or `` `Page ${page}` `` when `pageCount` is `-1` | `TMDataGrid.Footer`: the page number. |
|
|
76
|
+
| `groupedAllRows` | `` `Grouped · all ${total} rows` `` | `TMDataGrid.Footer`: in place of the range and the page number while the rows are grouped. |
|
|
77
|
+
| `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. |
|
|
78
|
+
| `previousPage` | `Previous page` | `TMDataGrid.Footer`: `aria-label` of the previous page button. |
|
|
79
|
+
| `nextPage` | `Next page` | `TMDataGrid.Footer`: `aria-label` of the next page button. |
|
|
80
|
+
| `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. |
|
|
81
|
+
| `loading` | `Loading` | `aria-label` of the body loader, of `TMDataGrid.LoadingIndicator`, and of the edit lane spinner while a row saves. |
|
|
82
|
+
| `editCell` | `` `Edit ${column}` `` | `aria-label` of an open cell editor. |
|
|
83
|
+
| `confirmEdit` | `Save` | `aria-label` of the ✓ button beside a cell editor. |
|
|
84
|
+
| `cancelEdit` | `Cancel` | `aria-label` of the ✕ button beside a cell editor. |
|
|
85
|
+
| `editColumnLabel` | `Edit` | `meta.label` of the generated edit lane. |
|
|
86
|
+
| `editRow` | `Edit row` | Edit lane: tooltip and `aria-label` of the pencil button. |
|
|
87
|
+
| `saveRow` | `Save row` | Edit lane: tooltip and `aria-label` of the ✓ button while a row edit is open. |
|
|
88
|
+
| `cancelRowEdit` | `Cancel edit` | Edit lane: tooltip and `aria-label` of the ✕ button while a row edit is open. |
|
|
89
|
+
| `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. |
|
|
90
|
+
| `saveAllEdits` | `"Save 1 row"` when `rows` is 1, else `` `Save ${rows} rows` `` | `TMDataGrid.DraftActions`: the save button. |
|
|
91
|
+
| `discardAllEdits` | `Discard` | `TMDataGrid.DraftActions`: the discard button. |
|
|
92
|
+
| `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. |
|
|
93
|
+
| `confirmNewRow` | `Add row` | Edit lane: tooltip and `aria-label` of the ✓ button on the entry row. |
|
|
94
|
+
| `discardNewRow` | `Discard new row` | Edit lane: tooltip and `aria-label` of the ✕ button on the entry row. |
|
|
95
|
+
| `deleteRow` | `Delete row` | Edit lane: tooltip and `aria-label` of the trash button. |
|
|
96
|
+
| `restoreRow` | `Restore row` | Edit lane: tooltip and `aria-label` of the undo button on a row marked for deletion. |
|
|
97
|
+
| `revertRow` | `Revert changes` | Edit lane: tooltip and `aria-label` of the undo button on a row with a draft. |
|
|
98
|
+
| `rowStateNew` | `New row` | Edit lane: the row-state marker of a confirmed entry row. |
|
|
99
|
+
| `rowStateEdited` | `Edited row` | Edit lane: the row-state marker of a row with a draft. |
|
|
100
|
+
| `rowStateDeleted` | `Marked for deletion` | Edit lane: the row-state marker of a row marked for deletion. |
|
|
101
|
+
| `cellCount` | `"1 cell"` when `count` is 1, else `` `${count} cells` `` | Cell-selection context menu: its heading. |
|
|
102
|
+
| `copy` | `Copy` | Cell-selection context menu item. |
|
|
103
|
+
| `exportCells` | `Export cells` | Cell-selection context menu item. |
|
|
104
|
+
| `includeHeaders` | `Include headers` | Cell-selection context menu: the checkbox. |
|
|
105
|
+
| `exportAll` | `Export all rows` | `TMDataGrid.Menu.Export`. Its `label` prop wins. |
|
|
106
|
+
| `exportSelected` | `"Export 1 selected row"` when `count` is 1, else `` `Export ${count} selected rows` `` | `TMDataGrid.Menu.ExportSelected`. Its `label` prop wins. |
|
|
107
|
+
| `exportPickerTitle` | `` `Export as ${format}` `` | Export column picker: the title. `format` is the file extension in upper case. |
|
|
108
|
+
| `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. |
|
|
109
|
+
| `exportPickerConfirm` | `Export` | Export column picker: the confirm button. |
|
|
110
|
+
| `exportPickerCancel` | `Cancel` | Export column picker: the cancel button. |
|
|
111
|
+
| `exportPickerSelectAll` | `Select all` | Export column picker: the select-all checkbox over the list. |
|
|
112
|
+
| `exportPickerCount` | `` `${checked} of ${total}` `` | Export column picker: the count beside the select-all checkbox. |
|
|
113
|
+
| `exportPickerHidden` | `Hidden` | Export column picker: the mark on a column the grid hides. |
|
|
114
|
+
| `selectColumnLabel` | `Checkbox selection` | `meta.label` of the generated checkbox lane. |
|
|
115
|
+
| `selectAllRows` | `Select all rows` | `aria-label` of the header checkbox. |
|
|
116
|
+
| `selectRow` | `Select row` | `aria-label` of a row checkbox. |
|
|
117
|
+
| `selectGroup` | `Select group` | `aria-label` of a group row checkbox. |
|
|
118
|
+
| `detailsColumnLabel` | `Details` | `meta.label` of the generated details lane. |
|
|
119
|
+
| `showDetails` | `Show details` | `aria-label` of a collapsed row's details toggle. |
|
|
120
|
+
| `hideDetails` | `Hide details` | `aria-label` of an expanded row's details toggle. |
|
|
121
|
+
| `expandAllDetails` | `Expand all details` | `aria-label` of the details lane's header toggle while some row is collapsed. |
|
|
122
|
+
| `collapseAllDetails` | `Collapse all details` | `aria-label` of the details lane's header toggle while every row is expanded. |
|
|
123
|
+
| `groupColumnLabel` | `Group` | `meta.label` of the generated tree lane, and its header text while nothing is grouped. |
|
|
124
|
+
| `blankGroupValue` | `(Blank)` | Group row text for an empty group key. |
|
|
125
|
+
| `expandGroup` | `` `Expand ${label}` `` | `aria-label` of a collapsed group row's toggle. |
|
|
126
|
+
| `collapseGroup` | `` `Collapse ${label}` `` | `aria-label` of an expanded group row's toggle. |
|
|
@@ -14,7 +14,7 @@ description: >
|
|
|
14
14
|
metadata:
|
|
15
15
|
type: core
|
|
16
16
|
library: '@jielga/tmdatagrid'
|
|
17
|
-
library_version: '2.
|
|
17
|
+
library_version: '2.2.0'
|
|
18
18
|
sources:
|
|
19
19
|
- 'Jielga/react:packages/tmdatagrid/docs/cell-selection.md'
|
|
20
20
|
- 'Jielga/react:packages/tmdatagrid/src/core/cellNavigation.ts'
|
|
@@ -215,7 +215,7 @@ Source: `packages/tmdatagrid/docs/cell-selection.md` (Copy and export).
|
|
|
215
215
|
| --- | --- | --- | --- | --- |
|
|
216
216
|
| `cellSelection` | Option | `TMDataGridCellSelectionMode`: `"none" \| "single" \| "range"` | `"none"`, or `"single"` under `editing` | Turns the cursor, and the rectangle, on. |
|
|
217
217
|
| `onFocusedCellChange` | Callback | `(cell \| null) => void` | – | Follows the cursor. |
|
|
218
|
-
| `exportOptions` | Option | `TMDataGridExportOptions` | `
|
|
218
|
+
| `exportOptions` | Option | `TMDataGridExportOptions` | `csvExcelFormat()`, `"export"`, headers on, `"visible"` columns | Format, file name and header row of the Export cells item. |
|
|
219
219
|
| `ui.state.focusedCell` | UI state | `{ rowId, columnId } \| null` | `null` | The cursor. |
|
|
220
220
|
| `ui.state.cellRange` | UI state | `{ anchor, focus } \| null` | `null` | The rectangle's two corners. |
|
|
221
221
|
| `ui.actions.setFocusedCell` · `setCellRange` | UI actions | – | – | Move either from your own code. |
|
package/skills/columns/SKILL.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: columns
|
|
3
3
|
description: >
|
|
4
4
|
Define and arrange TMDataGrid columns. Covers createTMDataGridColumnHelper,
|
|
5
|
-
every column meta field (label, type, options, flex, align, autoSize,
|
|
5
|
+
every column meta field (label, type, options, flex, align, colSpan, autoSize,
|
|
6
6
|
enableOrdering, and the meta.filter and meta.edit namespaces holding
|
|
7
7
|
operators, defaultOperator, control, enabled, field, editor, validate and
|
|
8
8
|
mapValue), the six column types, fluid minmax sizing versus fixed width with
|
|
@@ -16,7 +16,7 @@ description: >
|
|
|
16
16
|
metadata:
|
|
17
17
|
type: core
|
|
18
18
|
library: '@jielga/tmdatagrid'
|
|
19
|
-
library_version: '2.
|
|
19
|
+
library_version: '2.2.0'
|
|
20
20
|
sources:
|
|
21
21
|
- 'Jielga/react:packages/tmdatagrid/docs/columns.md'
|
|
22
22
|
- 'Jielga/react:packages/tmdatagrid/docs/column-layout.md'
|
|
@@ -84,6 +84,7 @@ columnHelper.group({
|
|
|
84
84
|
| `options` | `TMDataGridOptionsSource` | – | Choices for a `select` / `multiSelect` column: an array, `"faceted"`, or a function. One declaration feeds the filter panel and the editor. |
|
|
85
85
|
| `flex` | `number` | `1` | Share of the remaining width. |
|
|
86
86
|
| `align` | `"left" \| "right" \| "center"` | `"left"` | Applied to both header and cells. |
|
|
87
|
+
| `colSpan` | `number \| ({ row, table }) => number` | `1` | Columns the cell covers on a row, counting itself; the covered cells do not render there. See below. |
|
|
87
88
|
| `autoSize` | `boolean` | `false` | Size to the widest mounted content once, after the first rows render. |
|
|
88
89
|
| `enableOrdering` | `boolean` | `true` | `false` keeps the column where it is. |
|
|
89
90
|
| `filter` | `TMDataGridColumnFilterOptions` | – | How this column filters. See below. |
|
|
@@ -117,6 +118,11 @@ annotation. A column written without the helper keeps the untyped row,
|
|
|
117
118
|
TanStack defines no column option for. `meta.edit` only acts once `editing` is
|
|
118
119
|
set: see the `editing` skill. `meta.filter` belongs to the `filtering` skill.
|
|
119
120
|
|
|
121
|
+
`colSpan` (args `TMDataGridColSpanArgs`, `{ row, table }`) is display only, never
|
|
122
|
+
covers a generated lane or leaves its pinned block, and is ignored on group rows,
|
|
123
|
+
on rows in row edit mode, and on a row whose open cell editor a span would cover.
|
|
124
|
+
Source: `packages/tmdatagrid/docs/columns.md` (Spanning columns).
|
|
125
|
+
|
|
120
126
|
### Column types
|
|
121
127
|
|
|
122
128
|
`meta.type` is one of `"string"`, `"number"`, `"boolean"`, `"date"`,
|
|
@@ -163,10 +169,11 @@ Columns are fluid. Each track is `minmax(minSize, flex fr)`.
|
|
|
163
169
|
|
|
164
170
|
| Option | Effect |
|
|
165
171
|
| --- | --- |
|
|
166
|
-
| `minSize` | Minimum width, and the column's contribution to the grid minimum width. Defaults to `80`. |
|
|
172
|
+
| `minSize` | Minimum width, and the column's contribution to the grid minimum width. Also the floor of a resize and of a pinned width. Defaults to `80`, through `defaultColumn.minSize`. |
|
|
173
|
+
| `maxSize` | Ceiling of a resize, an autosize and a pinned width. Does not cap a fluid track. No default. |
|
|
167
174
|
| `meta.flex` | Share of the remaining width. Defaults to `1`. |
|
|
168
175
|
| `minSize === maxSize` | Fixed width. The column is never fluid. |
|
|
169
|
-
| `size` |
|
|
176
|
+
| `size` | Width of a column pinned at mount, clamped by `minSize` and `maxSize`. Ignored on a fluid column; a resize or an interactive pin stores the rendered width instead. Defaults to `150`. |
|
|
170
177
|
|
|
171
178
|
```tsx
|
|
172
179
|
// Fixed 64px action column that never flexes.
|
|
@@ -191,21 +198,23 @@ consumer code.
|
|
|
191
198
|
|
|
192
199
|
All three write state that persists together, so a grid comes back arranged the
|
|
193
200
|
way it was left. `resetSettings()` from the hook clears visibility, order,
|
|
194
|
-
pinning and
|
|
195
|
-
layout**.
|
|
201
|
+
pinning, widths and grouping in one go, and the column chooser offers it as
|
|
202
|
+
**Reset layout**.
|
|
196
203
|
|
|
197
204
|
**Hiding** is `columnVisibility`, driven by "Hide column" in a column menu and by
|
|
198
|
-
the column chooser
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
the column chooser, which comes in three forms (see the `appearance` skill):
|
|
206
|
+
|
|
207
|
+
- `TMDataGrid.Menu.Columns` in the grid menu.
|
|
208
|
+
- **Manage columns**, a submenu of every column menu.
|
|
209
|
+
- `TMDataGrid.ColumnsPanel`, plain controls for a host that is not a menu.
|
|
201
210
|
|
|
202
211
|
**Pinning** is "Pin to left" / "Pin to right" in the column menu. A pinned
|
|
203
212
|
column also becomes fixed-width: sticky offsets are computed from `getSize()`,
|
|
204
213
|
which cannot resolve an `fr` value, so the grid stores the rendered width in
|
|
205
214
|
`columnSizing` at the moment it is pinned and nothing jumps. A column pinned
|
|
206
215
|
from `initialState.columnPinning` has no rendered width to store, so it takes
|
|
207
|
-
its `size` - TanStack's default of `150` where none is set -
|
|
208
|
-
|
|
216
|
+
its `size` - TanStack's default of `150` where none is set - clamped by
|
|
217
|
+
`minSize` and `maxSize`.
|
|
209
218
|
|
|
210
219
|
**Ordering** is header dragging plus "Move left" / "Move right". A column can
|
|
211
220
|
only move **within its own pinned region** - pinning splits the grid into left,
|
|
@@ -253,24 +262,18 @@ const grid = useTMDataGrid({
|
|
|
253
262
|
```
|
|
254
263
|
|
|
255
264
|
`sortFn` on a column takes any registered name or a
|
|
256
|
-
`(rowA, rowB, columnId) => number` function
|
|
257
|
-
`sortingFn
|
|
265
|
+
`(rowA, rowB, columnId) => number` function. `sortFn` is v9's name for v8's
|
|
266
|
+
`sortingFn`. Sorting writes
|
|
258
267
|
TanStack's `sorting` state, an array of `{ id, desc }` in priority order. It is
|
|
259
268
|
a **data** slice, persisted under `dataKey`, while the column layout below is a
|
|
260
269
|
settings slice under `settingsKey`.
|
|
261
270
|
|
|
262
271
|
## Column-level feature options
|
|
263
272
|
|
|
264
|
-
Standard TanStack column options
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
| `enableSorting` | No sort indicator, no sort menu items, no click-to-sort. |
|
|
269
|
-
| `enableColumnFilter` | No filter menu item. Excluded from the filter panel's column list, and its header filter cell is empty. |
|
|
270
|
-
| `enableHiding` | No hide menu item. Checkbox disabled in the column manager. |
|
|
271
|
-
| `enablePinning` | No pin menu items. |
|
|
272
|
-
| `enableResizing` | The divider is displayed but cannot be dragged. |
|
|
273
|
-
| `enableGrouping` | No "Group by" menu item. |
|
|
273
|
+
Standard TanStack column options, each removing its interface when `false`:
|
|
274
|
+
`enableSorting`, `enableMultiSort`, `enableColumnFilter`, `enableHiding`,
|
|
275
|
+
`enablePinning`, `enableResizing` and `enableGrouping`. What each one removes is
|
|
276
|
+
in [references/columns-api.md](references/columns-api.md#column-level-feature-options).
|
|
274
277
|
|
|
275
278
|
`meta.enableOrdering: false` belongs to the same set. A column whose menu has no
|
|
276
279
|
remaining items renders no menu button and takes no right-click, so the
|
|
@@ -294,16 +297,17 @@ columns and edit.
|
|
|
294
297
|
They are structural: fixed width, no column menu, and they cannot be sorted,
|
|
295
298
|
filtered, resized, re-pinned or moved. The checkbox lane anchors the left pinned
|
|
296
299
|
region, so no column can be placed in front of it. `isControlColumn(columnId)`
|
|
297
|
-
identifies them.
|
|
300
|
+
identifies them. To locate a lane in a test, use the constant with
|
|
301
|
+
`data-column-id`; see the `testing` skill.
|
|
298
302
|
|
|
299
303
|
## Common mistakes
|
|
300
304
|
|
|
301
305
|
### CRITICAL Setting `size` to control width
|
|
302
306
|
|
|
303
|
-
`size`
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
`size` applies only to a column pinned at mount. On a fluid column it is
|
|
308
|
+
ignored - the track is `minmax(minSize, flex fr)` - so a column given
|
|
309
|
+
`size: 200` renders at whatever the flex share works out to. A resize or an
|
|
310
|
+
interactive pin stores the rendered width, not `size`.
|
|
307
311
|
|
|
308
312
|
Wrong:
|
|
309
313
|
|
|
@@ -322,29 +326,28 @@ columnHelper.accessor("email", {
|
|
|
322
326
|
});
|
|
323
327
|
```
|
|
324
328
|
|
|
325
|
-
|
|
326
|
-
column that is pinned needs one.
|
|
329
|
+
A column pinned at mount is fixed-width and does use `size`, so give it one.
|
|
327
330
|
|
|
328
331
|
Source: `packages/tmdatagrid/docs/column-layout.md` (Sizing).
|
|
329
332
|
|
|
330
|
-
### HIGH Pinning a column at mount without
|
|
333
|
+
### HIGH Pinning a column at mount without a width
|
|
331
334
|
|
|
332
335
|
A column pinned interactively keeps the width it was rendering, which the grid
|
|
333
336
|
writes into `columnSizing`. A column pinned from `initialState.columnPinning`
|
|
334
|
-
has no rendered width, so it takes `size`
|
|
335
|
-
none is set
|
|
337
|
+
has no rendered width, so it takes `size` clamped by `minSize` / `maxSize`:
|
|
338
|
+
TanStack's `150` when none is set, whatever the content needs.
|
|
336
339
|
|
|
337
340
|
Wrong:
|
|
338
341
|
|
|
339
342
|
```tsx
|
|
340
|
-
columnHelper.accessor("name", { header: "Name"
|
|
343
|
+
columnHelper.accessor("name", { header: "Name" });
|
|
341
344
|
initialState: { columnPinning: { start: ["name"], end: [] } },
|
|
342
345
|
```
|
|
343
346
|
|
|
344
347
|
Correct:
|
|
345
348
|
|
|
346
349
|
```tsx
|
|
347
|
-
columnHelper.accessor("name", { header: "Name",
|
|
350
|
+
columnHelper.accessor("name", { header: "Name", size: 220 });
|
|
348
351
|
initialState: { columnPinning: { start: ["name"], end: [] } },
|
|
349
352
|
```
|
|
350
353
|
|
|
@@ -399,8 +402,7 @@ Source: `packages/tmdatagrid/src/core/columnUtils.ts`.
|
|
|
399
402
|
|
|
400
403
|
`getColumnType(column)` defaults to `"string"`, so a numeric column that omits
|
|
401
404
|
`meta: { type: "number" }` offers only the string operators, and comparisons run
|
|
402
|
-
as text - `"9"` above `"10"`. The column still sorts and filters
|
|
403
|
-
it is easy to miss.
|
|
405
|
+
as text - `"9"` above `"10"`. The column still sorts and filters.
|
|
404
406
|
|
|
405
407
|
Source: `packages/tmdatagrid/src/core/filterOperators.ts`.
|
|
406
408
|
|
|
@@ -421,10 +423,9 @@ Source: `packages/tmdatagrid/docs/column-layout.md` (Regions).
|
|
|
421
423
|
|
|
422
424
|
### HIGH Reaching for the v8 name of a v9 option
|
|
423
425
|
|
|
424
|
-
TanStack v9 renamed the column comparator to `sortFn`. `sortingFn` is
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
custom ordering never appears.
|
|
426
|
+
TanStack v9 renamed the column comparator to `sortFn`. `sortingFn` is an
|
|
427
|
+
unknown key in v9; TypeScript does not always report it, and the column keeps
|
|
428
|
+
its automatic comparator, so the custom ordering never appears.
|
|
428
429
|
|
|
429
430
|
Wrong:
|
|
430
431
|
|
|
@@ -22,6 +22,20 @@ Reference for the `columns` skill.
|
|
|
22
22
|
| `validate` | `TMDataGridFieldValidate` | – | Field-level validation. A bare schema means `onChange`. |
|
|
23
23
|
| `mapValue` | `TMDataGridEditValueMap` | – | Maps each value an editor writes, on every keystroke. |
|
|
24
24
|
|
|
25
|
+
## Column-level feature options
|
|
26
|
+
|
|
27
|
+
Standard TanStack column options. Each also removes the corresponding interface.
|
|
28
|
+
|
|
29
|
+
| Option | Effect when `false` |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `enableSorting` | No sort indicator, no sort menu items, no click-to-sort. |
|
|
32
|
+
| `enableMultiSort` | Shift+click on this header replaces the sort instead of adding to it. |
|
|
33
|
+
| `enableColumnFilter` | No filter menu item. Excluded from the filter panel's column list, and its header filter cell is empty. |
|
|
34
|
+
| `enableHiding` | No hide menu item. Checkbox disabled in the column manager. |
|
|
35
|
+
| `enablePinning` | No pin menu items. |
|
|
36
|
+
| `enableResizing` | The divider is displayed but cannot be dragged. |
|
|
37
|
+
| `enableGrouping` | No "Group by" menu item. |
|
|
38
|
+
|
|
25
39
|
## Exports and options
|
|
26
40
|
|
|
27
41
|
| Name | Kind | Type | Default | What it does |
|
|
@@ -34,7 +48,7 @@ Reference for the `columns` skill.
|
|
|
34
48
|
| `TMDataGridOptionsArgs` | Type | `{ table, column, row? }` | – | What a `meta.options` function receives. `row` is absent when the filter panel asks. |
|
|
35
49
|
| `resolveColumnOptions` | Export | `({ table, column, row?, fallback? }) => Array<TMDataGridOption>` | – | Normalises all three `meta.options` forms. Empty when the column declares none. |
|
|
36
50
|
| `optionsToComboboxData` | Export | `(options) => ComboboxData` | – | Options as Mantine `Select` / `MultiSelect` data, groups folded in. |
|
|
37
|
-
| `minSize` / `maxSize` / `size` | Column options | `number` | `80` / – /
|
|
51
|
+
| `minSize` / `maxSize` / `size` | Column options | `number` | `80` / – / `150` | Floor of the fluid track, a resize and a pinned width; ceiling of a resize and a pinned width; width of a column pinned at mount. |
|
|
38
52
|
| `enableSorting` · `enableColumnFilter` · `enableHiding` · `enablePinning` · `enableResizing` · `enableGrouping` | Column options | `boolean` | `true` | Per-column switches, each removing its interface. |
|
|
39
53
|
| `enableColumnOrdering` | Option | `boolean` | `true` | Header dragging and the move menu items. Grid-defined. |
|
|
40
54
|
| `enableMultiSort` · `maxMultiSortColCount` · `isMultiSortEvent` | Table options | – | Shift held | Multi-column sorting. |
|