@jielga/tmdatagrid 2.1.4 → 2.3.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.
Files changed (57) hide show
  1. package/dist/index.d.ts +78 -5
  2. package/dist/index.js +2194 -1992
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/docs/cell-selection.md +1 -1
  6. package/docs/column-layout.md +13 -8
  7. package/docs/columns.md +59 -3
  8. package/docs/components.md +1 -0
  9. package/docs/export.md +2 -2
  10. package/docs/filtering.md +108 -15
  11. package/docs/getting-started.md +40 -0
  12. package/docs/grouping.md +9 -6
  13. package/docs/loading-and-empty.md +29 -9
  14. package/docs/localization.md +130 -3
  15. package/docs/menu.md +1 -1
  16. package/docs/pagination.md +26 -7
  17. package/docs/persistence.md +101 -2
  18. package/docs/row-details.md +41 -4
  19. package/docs/row-interaction.md +2 -2
  20. package/docs/row-selection.md +6 -7
  21. package/docs/row-styling.md +17 -0
  22. package/docs/scrolling.md +1 -1
  23. package/docs/server-side.md +3 -1
  24. package/docs/testing.md +18 -0
  25. package/docs/use-tm-data-grid.md +75 -36
  26. package/package.json +1 -1
  27. package/skills/appearance/SKILL.md +6 -4
  28. package/skills/appearance/references/labels.md +126 -0
  29. package/skills/cell-selection/SKILL.md +2 -2
  30. package/skills/columns/SKILL.md +44 -43
  31. package/skills/columns/references/columns-api.md +16 -1
  32. package/skills/data/SKILL.md +77 -50
  33. package/skills/editing/SKILL.md +1 -1
  34. package/skills/filtering/SKILL.md +94 -60
  35. package/skills/filtering/references/custom-filters.md +118 -0
  36. package/skills/getting-started/SKILL.md +37 -2
  37. package/skills/grouping/SKILL.md +16 -9
  38. package/skills/migrating-to-2/SKILL.md +1 -1
  39. package/skills/options/SKILL.md +206 -55
  40. package/skills/rows/SKILL.md +70 -39
  41. package/skills/server-side/SKILL.md +1 -1
  42. package/skills/testing/SKILL.md +12 -1
  43. package/skills/testing-components/SKILL.md +1 -1
  44. package/skills/testing-editing/SKILL.md +1 -1
  45. package/src/components/TMDataGridFilterPills.module.css +9 -7
  46. package/src/components/TMDataGridTable.module.css +15 -6
  47. package/src/components/TMDataGridTable.tsx +253 -41
  48. package/src/components/sticky.module.css +27 -7
  49. package/src/core/autosize.ts +19 -7
  50. package/src/core/cellRange.ts +11 -2
  51. package/src/core/colSpan.ts +78 -0
  52. package/src/core/columnUtils.ts +7 -0
  53. package/src/core/filterControls.ts +8 -0
  54. package/src/core/filterOperators.ts +29 -1
  55. package/src/core/persistence.ts +322 -26
  56. package/src/index.ts +5 -0
  57. package/src/useTMDataGrid.tsx +133 -14
@@ -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
- // { table, ui, features }
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`, `enableColumnOrdering`, `enablePagination`, `selectionMode`,
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
- `renderDetails`, `renderDetailsEstHeight`, `overscan`, `cellSelection`,
22
- `onFocusedCellChange`, `quickSearchMode`, `labels` and `editing`
23
- (see [Editing](/docs/editing)) are the grid's own options and are consumed here
24
- rather than forwarded to TanStack.
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 | Used by row selection and virtualization. |
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` | Enables sorting for the table. |
37
- | `enableColumnFilters` | `boolean` | `true` | Enables filtering for the table. |
38
- | `enableHiding` | `boolean` | `true` | Enables column visibility for the table. |
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` | Enables resizing for the table. |
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. See [Filtering](/docs/filtering#the-filters-option). |
59
- | `persist` | `TMDataGridPersistence` | – | State persistence. See [persist](#persist). |
60
- | `labels` | `TMDataGridLabelsOverride` | English | Overrides for the grid's strings, see [Localization](#localization). |
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` | – | Displays a loader while the grid is empty. Takes precedence over every empty state. |
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`. Required for server-side data. |
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
 
@@ -161,13 +181,16 @@ toolbar components can read the same strings as the built-in parts.
161
181
  ## persist
162
182
 
163
183
  Restores table state on mount and writes it back on every change. State is
164
- split across two keys: `settingsKey` for the column layout, `dataKey` for
165
- filters, sorting and pagination. Either can be cleared without the other.
184
+ split across three keys: `settingsKey` for the column layout, `dataKey` for
185
+ filters, sorting and pagination, and `urlKey` for data slices kept in the URL
186
+ as a deep link. Each can be cleared without the others.
166
187
 
167
188
  | Field | Type | Default | Description |
168
189
  | --- | --- | --- | --- |
169
190
  | `dataKey` | `string \| [string, DataSlice[]]` | – | Storage key for the data group. |
170
191
  | `settingsKey` | `string \| [string, SettingsSlice[]]` | – | Storage key for the settings group. |
192
+ | `urlKey` | `string \| [string, DataSlice[]]` | – | Search param for data slices kept in the URL. See [Deep links](/docs/persistence#deep-links). |
193
+ | `urlStorage` | `TMDataGridUrlStorage` | `location.search` and `history.replaceState` | Reads and writes the URL param. |
171
194
  | `storageMode` | `"localStorage" \| "sessionStorage"` | `"localStorage"` | Storage area. Use `"sessionStorage"` for per-tab state. |
172
195
  | `serialize` | `(value) => string` | `JSON.stringify` | Serializes a payload before storing. |
173
196
  | `deserialize` | `(value: string) => unknown` | `JSON.parse` | Parses a stored payload. |
@@ -202,6 +225,7 @@ const persist = {
202
225
  | Group | Available slices |
203
226
  | --- | --- |
204
227
  | `dataKey` | `columnFilters`, `globalFilter`, `sorting`, `pagination`, `expanded` |
228
+ | `urlKey` | The data slices. A slice listed here is taken out of `dataKey`. |
205
229
  | `settingsKey` | `columnVisibility`, `columnSizing`, `columnOrder`, `columnPinning`, `grouping` |
206
230
 
207
231
  The exported `DATA_STATE_SLICES` and `SETTINGS_STATE_SLICES` arrays contain the
@@ -247,6 +271,7 @@ identifier if several users can share a browser profile.
247
271
  | `table` | `Table<TMDataGridFeatures, TData>` | The TanStack table instance. |
248
272
  | `ui` | `Store<TMDataGridUiState, TMDataGridUiActions>` | State of the filter and column panels. |
249
273
  | `filters` | `TMDataGridFiltersSettings` | The `filters` option with its defaults filled in. See [Filtering](/docs/filtering#the-filters-option). |
274
+ | `exportOptions` | `TMDataGridExportSettings` | The `exportOptions` option with its defaults filled in. See [Export](/docs/export). |
250
275
  | `edit` | `TMDataGridEditApi` | The edit engine, inert until `editing` is set. See [Editing](/docs/editing). |
251
276
  | `features` | `TMDataGridFeatureFlags` | Table-level feature switches, re-read from options on each render. See [Toolbar](/docs/toolbar#reading-options-reactively). |
252
277
  | `labels` | `TMDataGridLabels` | The resolved label set, overrides merged over English. See [Localization](/docs/localization). |
@@ -278,22 +303,34 @@ The identity is stable, so it is safe in a dependency array. Before
278
303
  `TMDataGrid.Table` has mounted there is nothing to scroll and it returns
279
304
  `false`.
280
305
 
281
- Both stores are subscribable, so a parent component can react to grid state
282
- without holding it:
306
+ ### Reading state
307
+
308
+ `table.store` and `ui` are TanStack stores. Read a slice with `useSelector`
309
+ from `@tanstack/react-store`, which subscribes the component to what the
310
+ selector returns:
283
311
 
284
312
  ```tsx
285
313
  import { useSelector } from "@tanstack/react-store";
286
314
 
287
315
  const selectedCount = useSelector(
288
316
  grid.table.store,
289
- (state) => Object.keys(state.rowSelection).length,
317
+ () => grid.table.getSelectedRowModel().rows.length,
290
318
  );
291
-
319
+ const isGrouped = useSelector(grid.table.store, (state) =>
320
+ state.grouping.includes("department"),
321
+ );
322
+ const pageIndex = useSelector(grid.table.store, (state) => state.pagination.pageIndex);
292
323
  const filterPanelOpen = useSelector(grid.ui, (state) => state.filterPanelOpen);
293
324
  ```
294
325
 
295
- Read state with `useSelector` rather than `grid.table.store.state`. A direct
296
- read does not subscribe the component to the store.
326
+ `grid.table.store.state` is a plain read and does not subscribe the component.
327
+ A bare read is stale in any component that does not call `useTMDataGrid`
328
+ itself, and under the React Compiler also in the one that does; `useSelector`
329
+ subscribes either way. A table or column getter such as
330
+ `table.getSelectedRowModel()` or `column.getIsGrouped()` is a plain read as
331
+ well; call it inside a selector, as above. Note that `table.getState()` does
332
+ not exist in TanStack Table v9, and `table.state` is not part of
333
+ `TMDataGridTable`.
297
334
 
298
335
  ### ui actions
299
336
 
@@ -301,6 +338,8 @@ read does not subscribe the component to the store.
301
338
  | --- | --- |
302
339
  | `openFilterPanel` | `(columnId?: string \| null) => void` |
303
340
  | `closeFilterPanel` | `() => void` |
341
+ | `openExportPicker` | `(request: TMDataGridExportPickerRequest) => void` |
342
+ | `closeExportPicker` | `() => void` |
304
343
  | `focusPanelFilter` | `(columnId: string \| null) => void` |
305
344
  | `focusHeaderFilter` | `(columnId: string \| null) => void` |
306
345
  | `startColumnDrag` | `(columnId: string) => void` |
@@ -316,7 +355,7 @@ focus follows `focusedCell` while the grid holds it, scrolling the row into view
316
355
  when it is off screen.
317
356
 
318
357
  `startColumnDrag` and `endColumnDrag` are called by the header cells while a
319
- column is being dragged. `ui.draggedColumnId` holds the column being moved,
358
+ column is being dragged. `ui.state.draggedColumnId` holds the column being moved,
320
359
  since `dataTransfer` is unreadable until the drop.
321
360
 
322
361
  `openColumnFilter(grid, columnId)` combines two steps used by the column menu:
@@ -342,7 +381,7 @@ to off; ordering, like the options around it, defaults to on.
342
381
  | Option | Level | Interface removed |
343
382
  | --- | --- | --- |
344
383
  | `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 panel, header filter row. See [Filtering](/docs/filtering) |
384
+ | `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
385
  | `enableColumnFilter: false` | Column | That column's filter menu item, panel entry and header control |
347
386
  | `enableGlobalFilter: false` | Table, column | `Search`: the whole input at table level, one column's participation at column level |
348
387
  | `enableHiding: false` | Table, column | Hide column, Manage columns, `TMDataGrid.Menu.Columns`. See [Column layout](/docs/column-layout) |
@@ -359,6 +398,6 @@ to off; ordering, like the options around it, defaults to on.
359
398
  | `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
399
  | `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
400
  | `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) |
401
+ | `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
402
  | `renderDetails` | Table | Opt-in: adds the details lane, and an expanded row opens a panel underneath it. See [Row details](/docs/row-details) |
364
403
  | `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.1.4",
3
+ "version": "2.3.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",
@@ -18,7 +18,7 @@ description: >
18
18
  metadata:
19
19
  type: core
20
20
  library: '@jielga/tmdatagrid'
21
- library_version: '2.1.4'
21
+ library_version: '2.3.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` (Why `features` is a second argument).
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 | `(base, override) => TMDataGridLabels` | – | The merge, for composing dictionaries. |
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.1.4'
17
+ library_version: '2.3.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` | `DEFAULT_EXPORT_OPTIONS` | Format, file name and header row of the Export cells item. |
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. |