@jielga/tmdatagrid 2.0.0-beta.2 → 2.0.0-beta.21
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 +1664 -632
- package/dist/index.js +5226 -3223
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/anatomy.md +102 -0
- package/docs/cell-selection.md +154 -0
- package/docs/column-layout.md +204 -0
- package/docs/columns.md +262 -0
- package/docs/components.md +304 -0
- package/docs/editing.md +603 -0
- package/docs/editors.md +250 -0
- package/docs/export.md +326 -0
- package/docs/filtering.md +358 -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/pagination.md +144 -0
- package/docs/persistence.md +111 -0
- package/docs/portfolio-rebalancer.md +94 -0
- package/docs/query-builder.md +175 -0
- package/docs/quick-search.md +83 -0
- package/docs/row-details.md +113 -0
- package/docs/row-interaction.md +148 -0
- package/docs/row-pinning.md +132 -0
- package/docs/row-selection.md +134 -0
- package/docs/row-styling.md +133 -0
- package/docs/scrolling.md +111 -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 +309 -0
- package/docs/toolbar.md +161 -0
- package/docs/use-tm-data-grid.md +361 -0
- package/package.json +21 -45
- package/skills/appearance/SKILL.md +70 -17
- package/skills/cell-selection/SKILL.md +70 -76
- package/skills/columns/SKILL.md +131 -32
- package/skills/data/SKILL.md +100 -23
- package/skills/editing/SKILL.md +217 -96
- package/skills/editing/references/common-mistakes.md +111 -24
- package/skills/editing/references/editing-api.md +63 -39
- package/skills/editing/references/editors-and-validation.md +77 -19
- package/skills/filtering/SKILL.md +148 -40
- package/skills/getting-started/SKILL.md +18 -16
- package/skills/grouping/SKILL.md +32 -15
- package/skills/options/SKILL.md +39 -9
- package/skills/rows/SKILL.md +22 -18
- package/skills/server-side/SKILL.md +170 -17
- package/skills/testing/SKILL.md +10 -7
- package/src/{tmdatagrid/TMDataGridContext.ts → TMDataGridContext.ts} +7 -19
- package/src/{tmdatagrid/components → components}/TMDataGrid.module.css +7 -1
- package/src/{tmdatagrid/components → components}/TMDataGrid.tsx +39 -23
- package/src/{tmdatagrid/components → components}/TMDataGridCellEditor.tsx +106 -38
- 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 +4 -4
- package/src/components/TMDataGridDraftActions.tsx +307 -0
- package/src/{tmdatagrid/components → components}/TMDataGridEditColumn.tsx +58 -50
- package/src/{tmdatagrid/components → components}/TMDataGridEntryRows.tsx +150 -115
- 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 +7 -5
- package/src/components/TMDataGridFilterSurface.module.css +54 -0
- package/src/components/TMDataGridFilterSurface.tsx +167 -0
- package/src/{tmdatagrid/components → components}/TMDataGridFooter.tsx +53 -13
- package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.tsx +4 -3
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.module.css +10 -0
- package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.tsx +100 -28
- package/src/components/TMDataGridHeaderFilterRow.module.css +51 -0
- package/src/components/TMDataGridHeaderFilterRow.tsx +301 -0
- package/src/components/TMDataGridMenu.tsx +354 -0
- package/src/{tmdatagrid/components → components}/TMDataGridSelectColumn.tsx +12 -7
- package/src/{tmdatagrid/components → components}/TMDataGridTable.module.css +90 -67
- package/src/{tmdatagrid/components → components}/TMDataGridTable.tsx +678 -156
- package/src/components/TMDataGridToolbar.module.css +21 -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/components/editors/TMDataGridNumberEditor.tsx +70 -0
- 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 +17 -31
- 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/{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}/capabilities.ts +14 -6
- package/src/{tmdatagrid/core → core}/columnOptions.ts +46 -0
- package/src/{tmdatagrid/core → core}/columnOrdering.ts +33 -14
- package/src/{tmdatagrid/core → core}/columnUtils.ts +44 -5
- package/src/core/controlledState.ts +179 -0
- package/src/core/controlledStateSync.ts +108 -0
- package/src/core/deletedRows.ts +34 -0
- package/src/core/dom.ts +74 -0
- package/src/core/editEngine.ts +2476 -0
- package/src/{tmdatagrid/core → core}/editorFocus.ts +8 -4
- package/src/core/export.ts +843 -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}/labels.ts +66 -8
- package/src/{tmdatagrid/core → core}/labelsSv.ts +26 -3
- package/src/core/pageReset.ts +120 -0
- package/src/{tmdatagrid/core → core}/persistence.ts +22 -5
- package/src/core/resizePreview.ts +141 -0
- package/src/core/summary.ts +59 -0
- package/src/core/useSettledTableState.ts +36 -0
- package/src/{tmdatagrid/index.ts → index.ts} +75 -12
- package/src/{tmdatagrid/useTMDataGrid.tsx → useTMDataGrid.tsx} +734 -135
- package/src/useTMDataGridExport.ts +78 -0
- package/src/tmdatagrid/components/TMDataGridEditActions.tsx +0 -162
- package/src/tmdatagrid/components/TMDataGridFilterPanel.module.css +0 -35
- package/src/tmdatagrid/components/TMDataGridFilterPanel.tsx +0 -354
- package/src/tmdatagrid/components/TMDataGridToolbar.module.css +0 -12
- package/src/tmdatagrid/components/TMDataGridToolbar.tsx +0 -162
- package/src/tmdatagrid/components/editors/TMDataGridNumberEditor.tsx +0 -40
- package/src/tmdatagrid/core/cellExport.ts +0 -320
- package/src/tmdatagrid/core/editEngine.ts +0 -1006
- package/src/tmdatagrid/core/summary.ts +0 -35
- /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}/cellNavigation.ts +0 -0
- /package/src/{tmdatagrid/core → core}/cellRange.ts +0 -0
- /package/src/{tmdatagrid/core → core}/draftCellContext.ts +0 -0
- /package/src/{tmdatagrid/core → core}/expanding.ts +0 -0
- /package/src/{tmdatagrid/core → core}/grouping.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}/rowPinning.ts +0 -0
- /package/src/{tmdatagrid/core → core}/rowSelection.ts +0 -0
- /package/src/{tmdatagrid/core → core}/sizes.ts +0 -0
|
@@ -3,24 +3,27 @@ name: filtering
|
|
|
3
3
|
description: >
|
|
4
4
|
Narrow the rows a TMDataGrid shows. Covers the shared tmDataGrid filter
|
|
5
5
|
function and its {operator, value} model, the eighteen operators and which
|
|
6
|
-
meta.type offers each, meta.filter.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
meta.type offers each, meta.filter.operators to offer a column only a subset
|
|
7
|
+
of them, meta.filter.defaultOperator, isFilterActive and the half-typed
|
|
8
|
+
filter, the filters option and its surfaces (popup, sidebar, none, plus
|
|
9
|
+
inHeader for header filters), TMDataGrid.FilterPanel and its layout prop,
|
|
10
|
+
TMDataGrid.FilterButton, TMDataGrid.FilterPills with its api prop,
|
|
11
|
+
openColumnFilter, replacing a value control with DgRangeSliderFilter /
|
|
12
|
+
DgDateRangeFilter / DgAutocompleteFilter / DgTriStateFilter or a
|
|
13
|
+
meta.filter.control component, per-column filterFn, and the quick search:
|
|
14
|
+
TMDataGrid.Search, quickSearchMode fuzzy or contains, fuzzyGlobalFilterFn,
|
|
15
|
+
enableMatchHighlighting and enableGlobalFilter. Load when adding filters,
|
|
16
|
+
choosing operators, building a filter control, showing active filters outside
|
|
17
|
+
the grid, or wiring a search box.
|
|
15
18
|
metadata:
|
|
16
19
|
type: core
|
|
17
20
|
library: '@jielga/tmdatagrid'
|
|
18
|
-
library_version: '2.0.0-beta.
|
|
21
|
+
library_version: '2.0.0-beta.21'
|
|
19
22
|
sources:
|
|
20
|
-
- 'Jielga/TMDataGrid:
|
|
21
|
-
- 'Jielga/TMDataGrid:
|
|
22
|
-
- 'Jielga/TMDataGrid:
|
|
23
|
-
- 'Jielga/TMDataGrid:
|
|
23
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/filtering.md'
|
|
24
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/quick-search.md'
|
|
25
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/filterOperators.ts'
|
|
26
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/quickSearch.ts'
|
|
24
27
|
---
|
|
25
28
|
|
|
26
29
|
# TMDataGrid - Filtering
|
|
@@ -48,7 +51,9 @@ leaving that end open).
|
|
|
48
51
|
|
|
49
52
|
A filter with an empty value **stays in state** so the panel keeps its row while
|
|
50
53
|
the user types. It matches every row, does not set the header indicator and
|
|
51
|
-
produces no pill. `isFilterActive(value)` tests for that state
|
|
54
|
+
produces no pill. `isFilterActive(value)` tests for that state, and
|
|
55
|
+
`activeColumnFilters(columnFilters | table)` applies it across the slice and
|
|
56
|
+
types what it hands back (entries in any other value shape are dropped); presence in
|
|
52
57
|
`columnFilters` does not.
|
|
53
58
|
|
|
54
59
|
## Operators
|
|
@@ -80,16 +85,105 @@ columnHelper.accessor("salary", {
|
|
|
80
85
|
});
|
|
81
86
|
```
|
|
82
87
|
|
|
83
|
-
|
|
88
|
+
`meta.filter.operators` narrows the list a column offers to a subset of its
|
|
89
|
+
type's - for a column whose backend answers only some operators, so the user is
|
|
90
|
+
never offered one the query cannot express. The panel dropdown and the header
|
|
91
|
+
funnel show only those, in the type's order. An operator the type does not
|
|
92
|
+
offer is ignored; a list that leaves nothing falls back to the type's full set.
|
|
93
|
+
Without `defaultOperator`, a fresh filter opens on the type's default when it is
|
|
94
|
+
offered, else on the first offered operator.
|
|
84
95
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
```tsx
|
|
97
|
+
columnHelper.accessor("customer", {
|
|
98
|
+
header: "Customer",
|
|
99
|
+
meta: { filter: { operators: ["contains", "equals", "isEmpty", "isNotEmpty"] } },
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`getColumnOperators(column)` returns the resolved list and
|
|
104
|
+
`getColumnDefaultOperator(column)` the operator a fresh filter opens on. The
|
|
105
|
+
`server-side` skill shows the list typed together with the API mapping table.
|
|
106
|
+
|
|
107
|
+
## The filters option
|
|
108
|
+
|
|
109
|
+
`filters` on `useTMDataGrid` picks the surface. It is read field by field, so a
|
|
110
|
+
literal is fine.
|
|
111
|
+
|
|
112
|
+
| Option | Type | Default | What it does |
|
|
113
|
+
| --- | --- | --- | --- |
|
|
114
|
+
| `surface` | `"popup" \| "sidebar" \| "none"` | `"popup"` | What `TMDataGrid.Table` renders and `FilterButton` toggles. |
|
|
115
|
+
| `sidebarSide` | `"left" \| "right"` | `"right"` | Which side the sidebar sits on. Ignored by the other surfaces. |
|
|
116
|
+
| `sidebarWidth` | `string` | `"280px"` | Sidebar width, any CSS length. Ignored by the other surfaces. |
|
|
117
|
+
| `defaultOpen` | `boolean` | `true` under `"sidebar"`, else `false` | Whether the surface starts open. Read once, at mount. Under `"none"`, the starting value of `ui.state.filterPanelOpen`. |
|
|
118
|
+
| `inHeader` | `boolean` | `false` | A second header row of per-column controls. Independent of `surface`. |
|
|
119
|
+
|
|
120
|
+
`surface` and `inHeader` are separate choices: `{ surface: "none", inHeader: true }`
|
|
121
|
+
is header filters alone, `{ inHeader: true }` keeps the popup as well.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
useTMDataGrid({ data, columns, filters: { surface: "sidebar", inHeader: true } });
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Popup** - the default. Floats over the first body rows. A pointerdown
|
|
128
|
+
outside, Escape, and emptying it (the last row removed, or **Clear all**) all
|
|
129
|
+
close it; `FilterButton` is exempt from the click-away so it stays a toggle.
|
|
130
|
+
|
|
131
|
+
**Sidebar** - the same panel beside the rows, inside the grid frame and under
|
|
132
|
+
the toolbar. The rows give up the width rather than being covered, a click in
|
|
133
|
+
the table does not dismiss it, and clearing the filters leaves it standing.
|
|
134
|
+
Escape closes it. It starts open, being a layout choice; its rows are
|
|
135
|
+
`layout="stacked"`, since 280px has no room for the triple.
|
|
136
|
+
|
|
137
|
+
**Header filters** - `inHeader: true` adds a header row of value controls, one
|
|
138
|
+
per filterable column, on the same column tracks as everything else. The
|
|
139
|
+
column and operator dropdowns are not there: the column is the one the cell
|
|
140
|
+
sits over, and the operator is a funnel button beside the input, tinted off its
|
|
141
|
+
default. The column menu's Filter item and the funnel indicator both come off,
|
|
142
|
+
having nothing left to reveal; the filtered column's tinted title stays. A
|
|
143
|
+
narrow column clips its control - give it a `minSize`.
|
|
90
144
|
|
|
91
|
-
|
|
92
|
-
|
|
145
|
+
Clearing a header control removes the column's `columnFilters` entry rather
|
|
146
|
+
than leaving an empty one, unless the user also picked a non-default operator,
|
|
147
|
+
which is kept. Panel rows still keep their empty filters.
|
|
148
|
+
|
|
149
|
+
`FilterButton` still toggles whatever `surface` names. `openColumnFilter` does
|
|
150
|
+
not: under `inHeader` it always focuses the header control and leaves the
|
|
151
|
+
surface closed.
|
|
152
|
+
|
|
153
|
+
**None** - `surface: "none"` renders no panel and no `FilterButton`, so a
|
|
154
|
+
hand-placed `TMDataGrid.FilterPanel` is the only one. Read
|
|
155
|
+
`ui.state.filterPanelOpen` if it belongs behind a control of your own.
|
|
156
|
+
|
|
157
|
+
## TMDataGrid.FilterPanel
|
|
158
|
+
|
|
159
|
+
The panel of filter rows - one column / operator / value triple per filter, over "Add filter" and "Clear all".
|
|
160
|
+
A plain block with no title, no close button and no open state: it renders wherever it is mounted, and the popup and sidebar surfaces are wrappers around it.
|
|
161
|
+
It must be inside `<TMDataGrid>` (it reads the grid from context) and it only reads and writes `columnFilters`, so a `manualFiltering` grid gets it for free.
|
|
162
|
+
Closing a surface only hides it; the filters stay.
|
|
163
|
+
**Clear all** drops every filter, half-typed ones included.
|
|
164
|
+
|
|
165
|
+
| Prop | Type | Default | Description |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `layout` | `"row" \| "stacked"` | `"row"` | `"row"` is side by side and wants about 550px; `"stacked"` fills a narrow host. Passed to every value control as its `layout`. |
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
<Drawer opened={open} onClose={close}>
|
|
171
|
+
<TMDataGrid.FilterPanel layout="stacked" />
|
|
172
|
+
</Drawer>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## TMDataGrid.FilterButton
|
|
176
|
+
|
|
177
|
+
The toolbar button that toggles the filter surface, tinted with the count of active filters.
|
|
178
|
+
Opening an empty panel seeds a filter row on the first filterable column; with filters already in state it opens on those.
|
|
179
|
+
Renders nothing when no column can be filtered, and nothing under `surface: "none"`.
|
|
180
|
+
No props.
|
|
181
|
+
|
|
182
|
+
## TMDataGrid.FilterPills
|
|
183
|
+
|
|
184
|
+
One pill per **active** filter, `First name: Sofia ✕`, where the ✕ clears it and a click on the label calls `openColumnFilter`.
|
|
185
|
+
The label spells the operator out unless it is the type's default: `Age is greater than 30`, but `First name: Sofia`.
|
|
186
|
+
It takes the grid as an `api` prop instead of reading context, so it renders anywhere on the page.
|
|
93
187
|
|
|
94
188
|
```tsx
|
|
95
189
|
import { TMDataGridFilterPills } from "@jielga/tmdatagrid";
|
|
@@ -97,11 +191,18 @@ import { TMDataGridFilterPills } from "@jielga/tmdatagrid";
|
|
|
97
191
|
<TMDataGridFilterPills api={grid} onPillClick={(columnId) => focus(columnId)} />;
|
|
98
192
|
```
|
|
99
193
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`
|
|
104
|
-
|
|
194
|
+
| Prop | Type | Default | Description |
|
|
195
|
+
| --- | --- | --- | --- |
|
|
196
|
+
| `api` | `TMDataGridApi<TData>` | - | The object returned by `useTMDataGrid`. |
|
|
197
|
+
| `size` | `MantineSize` | `"sm"` | Pill size. |
|
|
198
|
+
| `showClearAll` | `boolean` | `true` | "Clear all", shown once two filters are active. |
|
|
199
|
+
| `onPillClick` | `(columnId: string) => void` | - | Replaces the default click behaviour. |
|
|
200
|
+
| `className` | `string` | - | Added to the wrapper class. |
|
|
201
|
+
|
|
202
|
+
## openColumnFilter
|
|
203
|
+
|
|
204
|
+
`openColumnFilter(api, columnId)` seeds an empty filter if the column has none, then opens the surface on that column's panel row - or, under `inHeader`, scrolls the column's header control into view and focuses it, leaving the surface closed.
|
|
205
|
+
It is what a pill's label and the column menu's Filter item both call.
|
|
105
206
|
|
|
106
207
|
## Replacing the value control
|
|
107
208
|
|
|
@@ -220,12 +321,13 @@ const activeCount = columnFilters.length;
|
|
|
220
321
|
Correct:
|
|
221
322
|
|
|
222
323
|
```tsx
|
|
223
|
-
import {
|
|
324
|
+
import { activeColumnFilters } from "@jielga/tmdatagrid";
|
|
224
325
|
|
|
225
|
-
|
|
326
|
+
// The entries that narrow anything, with `value` typed rather than `unknown`.
|
|
327
|
+
const active = activeColumnFilters(columnFilters);
|
|
226
328
|
```
|
|
227
329
|
|
|
228
|
-
Source: `
|
|
330
|
+
Source: `packages/tmdatagrid/docs/filtering.md` (How a filter is stored).
|
|
229
331
|
|
|
230
332
|
### HIGH Assuming `value` is always a string
|
|
231
333
|
|
|
@@ -246,7 +348,7 @@ if (operatorTakesRangeValue(operator)) {
|
|
|
246
348
|
}
|
|
247
349
|
```
|
|
248
350
|
|
|
249
|
-
Source: `
|
|
351
|
+
Source: `packages/tmdatagrid/src/core/filterOperators.ts`.
|
|
250
352
|
|
|
251
353
|
### HIGH A numeric column with no `meta.type`
|
|
252
354
|
|
|
@@ -255,7 +357,7 @@ Source: `src/tmdatagrid/core/filterOperators.ts`.
|
|
|
255
357
|
`between` never appear in the panel, and comparisons run as text, where `"9"`
|
|
256
358
|
sorts above `"10"`.
|
|
257
359
|
|
|
258
|
-
Source: `
|
|
360
|
+
Source: `packages/tmdatagrid/docs/filtering.md` (Operators).
|
|
259
361
|
|
|
260
362
|
### HIGH A filter control defined inside the component
|
|
261
363
|
|
|
@@ -272,7 +374,7 @@ const StatusFilter: TMDataGridFilterControlComponent = (args) => { /* … */ };
|
|
|
272
374
|
meta: { filter: { control: StatusFilter } }
|
|
273
375
|
```
|
|
274
376
|
|
|
275
|
-
Source: `
|
|
377
|
+
Source: `packages/tmdatagrid/docs/filtering.md` (Writing your own).
|
|
276
378
|
|
|
277
379
|
### MEDIUM Writing the whole filter from a custom control
|
|
278
380
|
|
|
@@ -292,7 +394,7 @@ Correct:
|
|
|
292
394
|
onChange(picked);
|
|
293
395
|
```
|
|
294
396
|
|
|
295
|
-
Source: `
|
|
397
|
+
Source: `packages/tmdatagrid/docs/filtering.md` (Writing your own).
|
|
296
398
|
|
|
297
399
|
### MEDIUM Expecting match highlighting in a custom cell
|
|
298
400
|
|
|
@@ -301,7 +403,7 @@ does not modify a custom renderer's output. A column with a `cell` renderer
|
|
|
301
403
|
shows no marks whatever `enableMatchHighlighting` is set to. Equality operators
|
|
302
404
|
highlight nothing either.
|
|
303
405
|
|
|
304
|
-
Source: `
|
|
406
|
+
Source: `packages/tmdatagrid/docs/quick-search.md` (Match highlighting).
|
|
305
407
|
|
|
306
408
|
### MEDIUM Expecting fuzzy ranking to survive a sort
|
|
307
409
|
|
|
@@ -309,7 +411,7 @@ The rank ordering applies only while the search is the sole narrowing. Any sort
|
|
|
309
411
|
or grouping replaces it. The ordering is derived and never written into
|
|
310
412
|
`sorting`, so there is nothing to clear afterwards.
|
|
311
413
|
|
|
312
|
-
Source: `
|
|
414
|
+
Source: `packages/tmdatagrid/docs/quick-search.md` (Fuzzy by default).
|
|
313
415
|
|
|
314
416
|
## Reference
|
|
315
417
|
|
|
@@ -318,20 +420,26 @@ Source: `src/docs/quick-search.md` (Fuzzy by default).
|
|
|
318
420
|
| `enableColumnFilters` | Table option | `boolean` | `true` | `false` removes the panel, the button and the menu item. |
|
|
319
421
|
| `enableColumnFilter` | Column option | `boolean` | `true` | `false` takes one column out of filtering. |
|
|
320
422
|
| `meta.type` | Column meta | `TMDataGridColumnType` | `"string"` | Selects the operators and the value control. |
|
|
321
|
-
| `meta.filter.
|
|
423
|
+
| `meta.filter.operators` | Column meta | `readonly TMDataGridFilterOperator[]` | The type's list | The operators this column offers, a subset of its type's. |
|
|
424
|
+
| `meta.filter.defaultOperator` | Column meta | `TMDataGridFilterOperator` | The type's default, else the first offered | The operator a fresh filter opens on. |
|
|
322
425
|
| `meta.filter.control` | Column meta | `TMDataGridFilterControlComponent` | By type and operator | Replaces the value control. Module scope. |
|
|
323
426
|
| `filterFn` | Column option | name or fn | `"tmDataGrid"` | Custom matching for one column. |
|
|
324
427
|
| `quickSearchMode` | Option | `"fuzzy" \| "contains"` | `"fuzzy"` | How the quick search matches. |
|
|
325
428
|
| `enableMatchHighlighting` | Option | `boolean` | `false` | Mark matched text in default-rendered cells. |
|
|
326
429
|
| `enableGlobalFilter` | Table option | `boolean` | `true` | Also a column option. Removes the input, or one column's participation. |
|
|
327
430
|
| `globalFilterFn` | Table option | filter fn | fuzzy | Overrides the matching, and the ranking with it. |
|
|
328
|
-
| `TMDataGrid.FilterPanel` | Component |
|
|
431
|
+
| `TMDataGrid.FilterPanel` | Component | `layout: "row" \| "stacked"`, Mantine `BoxProps` | `"row"` | The panel of filter rows, as a plain block. Style props set on it. |
|
|
432
|
+
| `filters` | Table option | `TMDataGridFiltersOptions` | `{ surface: "popup" }` | Which surface holds the filter controls. |
|
|
433
|
+
| `TMDataGridFilterControlArgs.layout` | Type | `"row" \| "stacked" \| "header"` | – | How much room a value control has, and whether it names itself. |
|
|
434
|
+
| `filterValueShape` | Export | `(operator) => "scalar" \| "set" \| "range"` | – | Which shape an operator's value takes. |
|
|
329
435
|
| `TMDataGrid.FilterButton` | Component | – | – | Toolbar button opening the panel, with an active count. |
|
|
330
|
-
| `TMDataGrid.FilterPills` | Component | `api`, `size`, `showClearAll`, `onPillClick`, `
|
|
436
|
+
| `TMDataGrid.FilterPills` | Component | `api`, `size`, `showClearAll`, `onPillClick`, Mantine `BoxProps` | – | Active filters as removable pills, renderable anywhere. Style props set on the wrapper. |
|
|
331
437
|
| `TMDataGrid.Search` | Component | `placeholder`, `debounce` (`250`), `w` (`220`) | – | The debounced quick-search input. |
|
|
332
438
|
| `openColumnFilter` | Export | `(api, columnId) => void` | – | Opens the panel on a column. |
|
|
333
439
|
| `isFilterActive` | Export | `(value) => boolean` | – | Whether a filter value narrows anything. |
|
|
440
|
+
| `activeColumnFilters` | Export | `(columnFilters \| table) => Array<{ id, value }>` | – | The filters in the grid's own value shape that narrow anything, typed. |
|
|
334
441
|
| `getOperatorsForType` | Export | `(type) => operators` | – | The operator list a type offers. |
|
|
442
|
+
| `getColumnOperators` · `getColumnDefaultOperator` | Exports | `(column) => operators` · `(column) => operator` | – | One column's list after `meta.filter.operators`, and the operator a fresh filter on it opens on. |
|
|
335
443
|
| `FILTER_OPERATOR_LABELS` | Export | record | – | The label shown for each operator. |
|
|
336
444
|
| `formatFilterLabel` | Export | `({ label, type, filter }) => string` | – | The one-line description used on the pills. |
|
|
337
445
|
| `emptyValueForOperator` · `operatorNeedsValue` · `operatorTakesArrayValue` · `operatorTakesRangeValue` | Exports | – | – | What shape of value an operator expects. |
|
|
@@ -4,19 +4,19 @@ description: >
|
|
|
4
4
|
Set up TMDataGrid, a compound React data grid built on TanStack Table v9 and
|
|
5
5
|
Mantine. Covers useTMDataGrid, the TMDataGrid root, context, the component
|
|
6
6
|
catalog (Table, Footer, Toolbar, Spacer, SummaryCount, Search,
|
|
7
|
-
LoadingIndicator,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
LoadingIndicator, DraftActions, FilterButton, Menu, FilterPanel, FilterPills,
|
|
8
|
+
ColumnsPanel), the size scale and the bounded-height layout requirement. Load
|
|
9
|
+
when adding a grid, choosing which parts to render, or when rows do not
|
|
10
|
+
appear.
|
|
11
11
|
metadata:
|
|
12
12
|
type: core
|
|
13
13
|
library: '@jielga/tmdatagrid'
|
|
14
|
-
library_version: '2.0.0-beta.
|
|
14
|
+
library_version: '2.0.0-beta.21'
|
|
15
15
|
sources:
|
|
16
|
-
- 'Jielga/TMDataGrid:
|
|
17
|
-
- 'Jielga/TMDataGrid:
|
|
18
|
-
- 'Jielga/TMDataGrid:
|
|
19
|
-
- 'Jielga/TMDataGrid:
|
|
16
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/getting-started.md'
|
|
17
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/docs/anatomy.md'
|
|
18
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/components/TMDataGrid.tsx'
|
|
19
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/sizes.ts'
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
# TMDataGrid - Getting started
|
|
@@ -80,7 +80,9 @@ export function Employees({ data }: { data: Employee[] }) {
|
|
|
80
80
|
<TMDataGrid.SummaryCount />
|
|
81
81
|
<TMDataGrid.Spacer />
|
|
82
82
|
<TMDataGrid.FilterButton />
|
|
83
|
-
<TMDataGrid.
|
|
83
|
+
<TMDataGrid.Menu>
|
|
84
|
+
<TMDataGrid.Menu.Columns />
|
|
85
|
+
</TMDataGrid.Menu>
|
|
84
86
|
</TMDataGrid.Toolbar>
|
|
85
87
|
|
|
86
88
|
<TMDataGrid.Table<Employee> />
|
|
@@ -149,18 +151,18 @@ flex column.
|
|
|
149
151
|
| Component | Props | Notes |
|
|
150
152
|
| --- | --- | --- |
|
|
151
153
|
| `TMDataGrid` | `table`, `ui`, `features`, `size`, `className`, `style` | Root. Provides context. `style` also takes CSS variables: `--dg-row-selected-bg`, `--dg-row-height`, `--dg-header-height`, `--dg-font-size`, `--dg-padding`. |
|
|
152
|
-
| `TMDataGrid.Table` | `onRowClick(row)`, `renderRowContextMenu`, `renderColumnMenuItems`, `rowContextMenuProps` | Header, virtualized body, filter
|
|
154
|
+
| `TMDataGrid.Table` | `onRowClick(row)`, `renderRowContextMenu`, `renderColumnMenuItems`, `rowContextMenuProps` | Header, virtualized body, and whichever filter surface the `filters` option asks for. `onRowClick` runs in addition to selection under `selectionMode: "row"`. |
|
|
153
155
|
| `TMDataGrid.Footer` | `pageSizeOptions` (default `[10, 25, 50, 100]`), `pagination` render prop | Pagination controls. Renders nothing unless pagination is enabled. |
|
|
154
156
|
| `TMDataGrid.Toolbar` | `children` | Flex row above the grid. |
|
|
155
157
|
| `TMDataGrid.Spacer` | - | Pushes later toolbar items right. |
|
|
156
158
|
| `TMDataGrid.SummaryCount` | `children` | Visible rows out of total. |
|
|
157
159
|
| `TMDataGrid.Search` | `placeholder`, `debounce` (default `250`), `w` (default `220`) | Quick search over every column, debounced into `globalFilter`. Renders nothing under `enableGlobalFilter: false`. |
|
|
158
160
|
| `TMDataGrid.LoadingIndicator` | - | Small spinner while `meta.loading` is `true` and rows stay on screen. |
|
|
159
|
-
| `TMDataGrid.
|
|
160
|
-
| `TMDataGrid.FilterButton` | - | Toggles filter
|
|
161
|
-
| `TMDataGrid.
|
|
162
|
-
| `TMDataGrid.FilterPanel` |
|
|
163
|
-
| `TMDataGrid.ColumnsPanel` | - |
|
|
161
|
+
| `TMDataGrid.DraftActions` | `renderActions` | Save with the pending count, and Discard. Renders nothing while editing is off - see the `editing` skill. |
|
|
162
|
+
| `TMDataGrid.FilterButton` | - | Toggles the filter surface, seeding a filter row on the first filterable column. Renders nothing if no column is filterable, or under `filters.surface: "none"`. |
|
|
163
|
+
| `TMDataGrid.Menu` | `children`, `icon`, `label`, Mantine `MenuProps` | The burger and its dropdown: your own `Menu.Item`s, and `TMDataGrid.Menu.Columns`, the column chooser as menu items (renders nothing if no column is hideable). See the `appearance` skill. |
|
|
164
|
+
| `TMDataGrid.FilterPanel` | `layout` (`"row"` \| `"stacked"`, default `"row"`) | Filter rows over "Add filter" / "Clear all", as a plain block. Rendered by `.Table` inside the popup and the sidebar; place it yourself under `filters.surface: "none"`. See the `filtering` skill. |
|
|
165
|
+
| `TMDataGrid.ColumnsPanel` | - | The column chooser as plain controls, for a Popover or a Drawer. |
|
|
164
166
|
| `TMDataGrid.FilterPills` | `api`, `size` (default `"sm"`), `showClearAll` (default `true`), `onPillClick(columnId)`, `className` | One pill per active filter, ✕ to clear it. Takes the api as a prop, so it can be rendered outside the grid. Also exported as `TMDataGridFilterPills`. |
|
|
165
167
|
|
|
166
168
|
Pass the row type so `onRowClick` stays typed:
|
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.0-beta.
|
|
17
|
+
library_version: '2.0.0-beta.21'
|
|
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,7 +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
|
-
-
|
|
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`
|
|
92
|
+
- carry `data-grouped="true"` and `data-depth`, with `--dg-row-group-bg`
|
|
93
|
+
behind them. `data-grouped` is on every row, `"true"` or `"false"`, so match
|
|
94
|
+
the value rather than the bare attribute
|
|
90
95
|
|
|
91
96
|
A group row's checkbox selects every record under it at any depth, including
|
|
92
97
|
records inside collapsed sub-groups, showing a tick once all are selected and a
|
|
@@ -140,7 +145,9 @@ aggregateColumn({ table, columnId: "location", fn: "uniqueCount" });
|
|
|
140
145
|
```
|
|
141
146
|
|
|
142
147
|
It follows the filters deliberately. A total that does not change as the user
|
|
143
|
-
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`.
|
|
144
151
|
|
|
145
152
|
Pinned columns keep their lanes in the summary row, the generated lanes define
|
|
146
153
|
no `footer` so their cells stay blank, and the row is sticky at
|
|
@@ -166,7 +173,7 @@ Correct:
|
|
|
166
173
|
columnHelper.accessor("salary", { header: "Salary", aggregationFn: "sum" });
|
|
167
174
|
```
|
|
168
175
|
|
|
169
|
-
Source: `
|
|
176
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Aggregation).
|
|
170
177
|
|
|
171
178
|
### HIGH Looking for the grouped column in the grid
|
|
172
179
|
|
|
@@ -181,7 +188,7 @@ Correct, when the column must stay:
|
|
|
181
188
|
useTMDataGrid({ data, columns, groupedColumnMode: "reorder" });
|
|
182
189
|
```
|
|
183
190
|
|
|
184
|
-
Source: `
|
|
191
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (What grouping does to the grid).
|
|
185
192
|
|
|
186
193
|
### HIGH Combining the pager with grouping
|
|
187
194
|
|
|
@@ -190,14 +197,16 @@ out instead of paging the tree, so a footer count wired to `getPageCount()`
|
|
|
190
197
|
reports a number nobody can navigate to. Read
|
|
191
198
|
`isPagingActive(table, features)` before trusting the pager state.
|
|
192
199
|
|
|
193
|
-
Source: `
|
|
200
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Grouping suspends pagination).
|
|
194
201
|
|
|
195
202
|
### HIGH Handing a group row to a row callback
|
|
196
203
|
|
|
197
204
|
Group rows do not fire `onRowClick` or the cell handlers, and cannot be pinned,
|
|
198
205
|
expanded or edited. Their `row.original` is an arbitrary child's record, so a
|
|
199
206
|
bulk action built from `row.original` on the tree lane acts on one record
|
|
200
|
-
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.
|
|
201
210
|
|
|
202
211
|
Correct:
|
|
203
212
|
|
|
@@ -205,9 +214,17 @@ Correct:
|
|
|
205
214
|
import { getGroupDataRows } from "@jielga/tmdatagrid";
|
|
206
215
|
|
|
207
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
|
+
/>;
|
|
208
225
|
```
|
|
209
226
|
|
|
210
|
-
Source: `
|
|
227
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Group rows are not data rows).
|
|
211
228
|
|
|
212
229
|
### MEDIUM Totalling the page instead of the data
|
|
213
230
|
|
|
@@ -215,7 +232,7 @@ Source: `src/docs/grouping.md` (Group rows are not data rows).
|
|
|
215
232
|
`table.getRowModel().rows` instead totals only what is currently paged in, and
|
|
216
233
|
under virtualization not even that: only the mounted rows.
|
|
217
234
|
|
|
218
|
-
Source: `
|
|
235
|
+
Source: `packages/tmdatagrid/docs/summary-row.md` (Totalling a column).
|
|
219
236
|
|
|
220
237
|
### MEDIUM Grouping a server-paged grid
|
|
221
238
|
|
|
@@ -235,7 +252,7 @@ useTMDataGrid({
|
|
|
235
252
|
});
|
|
236
253
|
```
|
|
237
254
|
|
|
238
|
-
Source: `
|
|
255
|
+
Source: `packages/tmdatagrid/docs/grouping.md` (Server-side grids).
|
|
239
256
|
|
|
240
257
|
## Reference
|
|
241
258
|
|
|
@@ -256,7 +273,7 @@ Source: `src/docs/grouping.md` (Server-side grids).
|
|
|
256
273
|
| `isPagingActive` | Export | `(table, features) => boolean` | – | Whether the pager is slicing anything. `false` while grouped. |
|
|
257
274
|
| `--dg-row-group-bg` | CSS variable | colour | Themed | Group row background. |
|
|
258
275
|
| `--dg-summary-height` | CSS variable | length | From `size` | Height of the summary row. |
|
|
259
|
-
| `data-grouped` · `data-depth` | Data attributes | – | – |
|
|
276
|
+
| `data-grouped` · `data-depth` | Data attributes | – | – | `"true"` on group rows (published on every row), and the nesting level on every row. |
|
|
260
277
|
|
|
261
278
|
See also: the `rows` skill for selection and the details lane, and the `data`
|
|
262
279
|
skill for the pager grouping suspends.
|
package/skills/options/SKILL.md
CHANGED
|
@@ -14,11 +14,11 @@ description: >
|
|
|
14
14
|
metadata:
|
|
15
15
|
type: core
|
|
16
16
|
library: '@jielga/tmdatagrid'
|
|
17
|
-
library_version: '2.0.0-beta.
|
|
17
|
+
library_version: '2.0.0-beta.21'
|
|
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/src/useTMDataGrid.tsx'
|
|
21
|
+
- 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/persistence.ts'
|
|
22
22
|
---
|
|
23
23
|
|
|
24
24
|
# TMDataGrid - useTMDataGrid
|
|
@@ -62,10 +62,11 @@ rather than forwarded to TanStack.
|
|
|
62
62
|
| `onFocusedCellChange` | `(cell \| null) => void` | – | Fires whenever the focused cell moves. |
|
|
63
63
|
| `overscan` | `number` | `6` | Rows the virtualizer keeps mounted above and below the viewport. Defined by the grid. |
|
|
64
64
|
| `columnResizeMode` | `"onChange" \| "onEnd"` | `"onChange"` | Resize update strategy. |
|
|
65
|
-
| `initialState` | `Partial<TableState>` | See below | Merged over the grid defaults. |
|
|
65
|
+
| `initialState` | `Partial<TableState>` | See below | The state the grid starts from, read once on mount. Merged over the grid defaults. |
|
|
66
|
+
| `state` | `Partial<TableState>` | – | Controlled state. Each slice requires its `onXChange` - see below. |
|
|
66
67
|
| `meta` | `TMDataGridTableMeta` | `{}` | Grid configuration, see below. |
|
|
67
68
|
| `persist` | `TMDataGridPersistence` | – | State persistence, see below. |
|
|
68
|
-
| `editing` | `TMDataGridEditingOptions` | off | Turns editing on. `mode` (`"cell" \| "cellConfirm" \| "row"
|
|
69
|
+
| `editing` | `TMDataGridEditingOptions` | off | Turns editing on. Two axes: `mode` (`"cell" \| "cellConfirm" \| "row"`) picks what counts as a commit, `draft` picks whether it parks in the draft store; the object also holds `onCommit`, `onSaveDrafts`, `rowValidators`, `isRowEditable`, `newRowDefaults`, `newRowsSticky` (keeps committed new rows in the sticky entry block instead of sorting them in with the body), `onRowAdd` and `onRowDelete` - see the `editing` skill. |
|
|
69
70
|
| `labels` | `TMDataGridLabelsOverride` | English | Overrides for the grid's strings and `aria-label`s. |
|
|
70
71
|
|
|
71
72
|
### Default initial state
|
|
@@ -73,9 +74,38 @@ rather than forwarded to TanStack.
|
|
|
73
74
|
| Slice | Default |
|
|
74
75
|
| --- | --- |
|
|
75
76
|
| `pagination` | `{ pageIndex: 0, pageSize: 25 }` - inert until pagination is enabled |
|
|
76
|
-
| `columnPinning.
|
|
77
|
+
| `columnPinning.start` | The checkbox column, followed by any columns you provide |
|
|
77
78
|
| `globalFilterFn` | `"includesString"` |
|
|
78
79
|
|
|
80
|
+
### Controlled state
|
|
81
|
+
|
|
82
|
+
`state` makes a slice controlled: the parent owns the value, the grid reads it
|
|
83
|
+
every render, and all writes go through the matching `onXChange`. Without the
|
|
84
|
+
callback the slice cannot change; the grid logs a console warning in
|
|
85
|
+
development. For a starting value only, use `initialState`.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const [columnVisibility, setColumnVisibility] = useState({ play: false });
|
|
89
|
+
|
|
90
|
+
const grid = useTMDataGrid({
|
|
91
|
+
data,
|
|
92
|
+
columns,
|
|
93
|
+
state: { columnVisibility },
|
|
94
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- A key set to `undefined` is ignored; the slice is uncontrolled.
|
|
99
|
+
- Slices compare structurally between renders, so the `state` object can be
|
|
100
|
+
built inline. `Date`s compare by time; `Map`s and class instances compare by
|
|
101
|
+
identity and belong in `useState` or `useMemo`.
|
|
102
|
+
- `atoms` also controls a slice, with no callback. Takes precedence over
|
|
103
|
+
`state` for the same slice.
|
|
104
|
+
- `columnVisibility` toggles user-defined columns only. Entries for the
|
|
105
|
+
generated columns are ignored; enable or disable those through their feature
|
|
106
|
+
options. The tree column's entry follows `grouping`.
|
|
107
|
+
- `persist` cannot restore a controlled slice; it still writes it to storage.
|
|
108
|
+
|
|
79
109
|
## meta
|
|
80
110
|
|
|
81
111
|
| Field | Type | Default | Description |
|
|
@@ -178,8 +208,8 @@ const filterPanelOpen = useSelector(grid.ui, (state) => state.filterPanelOpen);
|
|
|
178
208
|
| --- | --- |
|
|
179
209
|
| `openFilterPanel` | `(columnId?: string \| null) => void` |
|
|
180
210
|
| `closeFilterPanel` | `() => void` |
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
211
|
+
| `focusPanelFilter` | `(columnId: string \| null) => void` |
|
|
212
|
+
| `focusHeaderFilter` | `(columnId: string \| null) => void` |
|
|
183
213
|
| `startColumnDrag` | `(columnId: string) => void` |
|
|
184
214
|
| `endColumnDrag` | `() => void` |
|
|
185
215
|
| `setHighlightedRow` | `(rowId: string \| null) => void` |
|