@jielga/tmdatagrid 2.0.0-beta.9 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +5 -212
  2. package/dist/index.d.ts +1281 -768
  3. package/dist/index.js +4607 -3250
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +1 -1
  6. package/docs/adding-rows.md +132 -0
  7. package/docs/anatomy.md +119 -0
  8. package/docs/card-view.md +108 -0
  9. package/docs/cell-selection.md +194 -0
  10. package/docs/column-layout.md +182 -0
  11. package/docs/column-menu.md +66 -0
  12. package/docs/columns.md +269 -0
  13. package/docs/components.md +311 -0
  14. package/docs/draft-store.md +242 -0
  15. package/docs/editing.md +303 -0
  16. package/docs/editors.md +250 -0
  17. package/docs/export.md +319 -0
  18. package/docs/filtering.md +362 -0
  19. package/docs/getting-started.md +123 -0
  20. package/docs/grouping.md +165 -0
  21. package/docs/loading-and-empty.md +92 -0
  22. package/docs/localization.md +79 -0
  23. package/docs/menu.md +143 -0
  24. package/docs/migrating-to-2.md +163 -0
  25. package/docs/pagination.md +144 -0
  26. package/docs/persistence.md +114 -0
  27. package/docs/portfolio-rebalancer.md +94 -0
  28. package/docs/query-builder.md +179 -0
  29. package/docs/quick-search.md +84 -0
  30. package/docs/row-details.md +115 -0
  31. package/docs/row-interaction.md +149 -0
  32. package/docs/row-pinning.md +132 -0
  33. package/docs/row-selection.md +136 -0
  34. package/docs/row-styling.md +133 -0
  35. package/docs/scrolling.md +112 -0
  36. package/docs/server-query.md +246 -0
  37. package/docs/server-side.md +206 -0
  38. package/docs/sorting.md +101 -0
  39. package/docs/styling.md +126 -0
  40. package/docs/summary-row.md +76 -0
  41. package/docs/testing.md +744 -0
  42. package/docs/toolbar.md +161 -0
  43. package/docs/use-tm-data-grid.md +361 -0
  44. package/package.json +22 -46
  45. package/skills/appearance/SKILL.md +72 -19
  46. package/skills/cell-selection/SKILL.md +49 -48
  47. package/skills/columns/SKILL.md +125 -70
  48. package/skills/columns/references/columns-api.md +59 -0
  49. package/skills/data/SKILL.md +112 -18
  50. package/skills/editing/SKILL.md +76 -42
  51. package/skills/editing/references/common-mistakes.md +77 -69
  52. package/skills/editing/references/editing-api.md +25 -20
  53. package/skills/editing/references/editors-and-validation.md +80 -18
  54. package/skills/filtering/SKILL.md +155 -41
  55. package/skills/getting-started/SKILL.md +116 -16
  56. package/skills/grouping/SKILL.md +31 -16
  57. package/skills/migrating-to-2/SKILL.md +244 -0
  58. package/skills/options/SKILL.md +24 -12
  59. package/skills/rows/SKILL.md +22 -18
  60. package/skills/rows/references/rows-api.md +10 -6
  61. package/skills/server-side/SKILL.md +170 -17
  62. package/skills/testing/SKILL.md +150 -32
  63. package/skills/testing-components/SKILL.md +230 -0
  64. package/skills/testing-editing/SKILL.md +240 -0
  65. package/src/{tmdatagrid/components → components}/TMDataGrid.tsx +38 -21
  66. package/src/{tmdatagrid/components → components}/TMDataGridCellEditor.tsx +54 -8
  67. package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.module.css +5 -1
  68. package/src/{tmdatagrid/components → components}/TMDataGridColumnsPanel.tsx +47 -55
  69. package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.tsx +5 -51
  70. package/src/{tmdatagrid/components → components}/TMDataGridDraftActions.tsx +41 -24
  71. package/src/{tmdatagrid/components → components}/TMDataGridEditColumn.tsx +12 -59
  72. package/src/{tmdatagrid/components → components}/TMDataGridEntryRows.tsx +164 -92
  73. package/src/components/TMDataGridExportPicker.module.css +77 -0
  74. package/src/components/TMDataGridExportPicker.tsx +234 -0
  75. package/src/components/TMDataGridFilterPanel.module.css +54 -0
  76. package/src/components/TMDataGridFilterPanel.tsx +348 -0
  77. package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.tsx +15 -8
  78. package/src/components/TMDataGridFilterSurface.module.css +54 -0
  79. package/src/components/TMDataGridFilterSurface.tsx +167 -0
  80. package/src/{tmdatagrid/components → components}/TMDataGridFooter.tsx +53 -90
  81. package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.tsx +5 -69
  82. package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.module.css +12 -2
  83. package/src/{tmdatagrid/components → components}/TMDataGridHeaderCell.tsx +58 -21
  84. package/src/components/TMDataGridHeaderFilterRow.module.css +51 -0
  85. package/src/components/TMDataGridHeaderFilterRow.tsx +301 -0
  86. package/src/components/TMDataGridMenu.tsx +357 -0
  87. package/src/{tmdatagrid/components → components}/TMDataGridSelectColumn.tsx +11 -48
  88. package/src/{tmdatagrid/components → components}/TMDataGridTable.module.css +69 -56
  89. package/src/{tmdatagrid/components → components}/TMDataGridTable.tsx +240 -138
  90. package/src/{tmdatagrid/components → components}/TMDataGridToolbar.module.css +5 -0
  91. package/src/components/TMDataGridToolbar.tsx +181 -0
  92. package/src/{tmdatagrid/components → components}/editors/TMDataGridBooleanEditor.tsx +3 -3
  93. package/src/{tmdatagrid/components → components}/editors/TMDataGridDateEditor.tsx +3 -3
  94. package/src/{tmdatagrid/components → components}/editors/TMDataGridMultiSelectEditor.tsx +3 -3
  95. package/src/{tmdatagrid/components → components}/editors/TMDataGridNumberEditor.tsx +3 -3
  96. package/src/{tmdatagrid/components → components}/editors/TMDataGridSelectEditor.tsx +3 -3
  97. package/src/{tmdatagrid/components → components}/editors/TMDataGridStringEditor.tsx +3 -3
  98. package/src/{tmdatagrid/components → components}/editors/editorShared.ts +16 -2
  99. package/src/{tmdatagrid/components → components}/filters/DgAutocompleteFilter.tsx +5 -4
  100. package/src/{tmdatagrid/components → components}/filters/DgDateRangeFilter.tsx +22 -5
  101. package/src/{tmdatagrid/components → components}/filters/DgRangeSliderFilter.tsx +5 -1
  102. package/src/{tmdatagrid/components → components}/filters/DgTriStateFilter.tsx +5 -1
  103. package/src/{tmdatagrid/components → components}/filters/TMDataGridFilterValueInput.tsx +44 -28
  104. package/src/components/filters/controlLayout.ts +32 -0
  105. package/src/components/filters/filterControlFor.ts +65 -0
  106. package/src/components/generatedColumns.tsx +187 -0
  107. package/src/{tmdatagrid/components → components}/icons.ts +1 -0
  108. package/src/{tmdatagrid/components → components}/sticky.module.css +44 -0
  109. package/src/components/useHideableColumns.ts +52 -0
  110. package/src/{tmdatagrid/core → core}/autosize.ts +5 -2
  111. package/src/{tmdatagrid/core → core}/columnOptions.ts +60 -8
  112. package/src/{tmdatagrid/core → core}/columnOrdering.ts +33 -14
  113. package/src/{tmdatagrid/core → core}/columnUtils.ts +44 -5
  114. package/src/core/controlledStateSync.ts +108 -0
  115. package/src/core/deletedRows.ts +34 -0
  116. package/src/core/dom.ts +74 -0
  117. package/src/{tmdatagrid/core → core}/editEngine.ts +1107 -460
  118. package/src/core/export.ts +704 -0
  119. package/src/{tmdatagrid/core → core}/filterControls.ts +38 -1
  120. package/src/{tmdatagrid/core → core}/filterOperators.ts +64 -1
  121. package/src/core/filterSurface.ts +99 -0
  122. package/src/{tmdatagrid/core → core}/grouping.ts +21 -0
  123. package/src/{tmdatagrid/core → core}/labels.ts +51 -6
  124. package/src/{tmdatagrid/core → core}/labelsSv.ts +27 -6
  125. package/src/core/pageReset.ts +120 -0
  126. package/src/core/pagination.ts +81 -0
  127. package/src/{tmdatagrid/core → core}/persistence.ts +22 -5
  128. package/src/{tmdatagrid/core → core}/summary.ts +20 -4
  129. package/src/{tmdatagrid/index.ts → index.ts} +69 -35
  130. package/src/{tmdatagrid/useTMDataGrid.tsx → useTMDataGrid.tsx} +428 -109
  131. package/src/useTMDataGridExport.ts +78 -0
  132. package/src/tmdatagrid/components/TMDataGridFilterPanel.module.css +0 -35
  133. package/src/tmdatagrid/components/TMDataGridFilterPanel.tsx +0 -354
  134. package/src/tmdatagrid/components/TMDataGridToolbar.tsx +0 -161
  135. package/src/tmdatagrid/core/cellExport.ts +0 -320
  136. /package/src/{tmdatagrid/TMDataGridContext.ts → TMDataGridContext.ts} +0 -0
  137. /package/src/{tmdatagrid/components → components}/TMDataGrid.module.css +0 -0
  138. /package/src/{tmdatagrid/components → components}/TMDataGridDetailsColumn.module.css +0 -0
  139. /package/src/{tmdatagrid/components → components}/TMDataGridFilterPills.module.css +0 -0
  140. /package/src/{tmdatagrid/components → components}/TMDataGridFooter.module.css +0 -0
  141. /package/src/{tmdatagrid/components → components}/TMDataGridGroupColumn.module.css +0 -0
  142. /package/src/{tmdatagrid/components → components}/TMDataGridRowNumberColumn.tsx +0 -0
  143. /package/src/{tmdatagrid/components → components}/TMDataGridSearch.tsx +0 -0
  144. /package/src/{tmdatagrid/core → core}/capabilities.ts +0 -0
  145. /package/src/{tmdatagrid/core → core}/cellNavigation.ts +0 -0
  146. /package/src/{tmdatagrid/core → core}/cellRange.ts +0 -0
  147. /package/src/{tmdatagrid/core → core}/controlledState.ts +0 -0
  148. /package/src/{tmdatagrid/core → core}/draftCellContext.ts +0 -0
  149. /package/src/{tmdatagrid/core → core}/editorFocus.ts +0 -0
  150. /package/src/{tmdatagrid/core → core}/expanding.ts +0 -0
  151. /package/src/{tmdatagrid/core → core}/matchHighlight.ts +0 -0
  152. /package/src/{tmdatagrid/core → core}/quickSearch.ts +0 -0
  153. /package/src/{tmdatagrid/core → core}/resizePreview.ts +0 -0
  154. /package/src/{tmdatagrid/core → core}/rowPinning.ts +0 -0
  155. /package/src/{tmdatagrid/core → core}/rowSelection.ts +0 -0
  156. /package/src/{tmdatagrid/core → core}/sizes.ts +0 -0
  157. /package/src/{tmdatagrid/core → core}/useSettledTableState.ts +0 -0
@@ -5,24 +5,27 @@ description: >
5
5
  xl) and what it drives, every --dg-* CSS variable for metrics, colours and the
6
6
  stacking ladder, the two stylesheets styles.css and styles.layer.css and why
7
7
  only one may be imported, the bounded-height layout rule with minHeight 0,
8
- toolbar composition through children and TMDataGrid.Spacer, writing a toolbar
8
+ toolbar composition through children and TMDataGrid.Spacer, Mantine BoxProps
9
+ (mb, px, hiddenFrom) and withBottomBorder on the toolbar, writing a toolbar
9
10
  button with useTMDataGridContext, hiding it the way the built-ins do with
10
11
  getGridCapabilities and getColumnCapabilities, why capabilities take a
11
12
  features argument under the React Compiler, and localization through the
12
13
  labels option, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, mergeLabels and
13
14
  grid.labels. Load when styling or theming the grid, choosing a density,
14
- building a toolbar, adding a button beside the built-in ones, or translating
15
- the interface.
15
+ building a toolbar, adding a button beside the built-in ones, filling the grid
16
+ menu (TMDataGrid.Menu, the column chooser as menu items), or translating the
17
+ interface.
16
18
  metadata:
17
19
  type: core
18
20
  library: '@jielga/tmdatagrid'
19
- library_version: '2.0.0-beta.9'
21
+ library_version: '2.0.1'
20
22
  sources:
21
- - 'Jielga/TMDataGrid:src/docs/styling.md'
22
- - 'Jielga/TMDataGrid:src/docs/toolbar.md'
23
- - 'Jielga/TMDataGrid:src/docs/localization.md'
24
- - 'Jielga/TMDataGrid:src/tmdatagrid/core/capabilities.ts'
25
- - 'Jielga/TMDataGrid:src/tmdatagrid/core/labels.ts'
23
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/docs/styling.md'
24
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/docs/toolbar.md'
25
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/docs/menu.md'
26
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/docs/localization.md'
27
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/capabilities.ts'
28
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/labels.ts'
26
29
  ---
27
30
 
28
31
  # TMDataGrid - Appearance, toolbar and labels
@@ -118,7 +121,9 @@ element, and `TMDataGrid.Spacer` pushes what follows to the right.
118
121
  <TMDataGrid.LoadingIndicator />
119
122
  <ExportButton />
120
123
  <TMDataGrid.FilterButton />
121
- <TMDataGrid.ColumnsButton />
124
+ <TMDataGrid.Menu>
125
+ <TMDataGrid.Menu.Columns />
126
+ </TMDataGrid.Menu>
122
127
  </TMDataGrid.Toolbar>
123
128
  ```
124
129
 
@@ -126,12 +131,60 @@ Each built-in renders nothing when its feature is off, so a read-only grid needs
126
131
  no conditionals: `FilterButton` under `enableColumnFilters: false` renders
127
132
  nothing at all.
128
133
 
134
+ `TMDataGrid.Toolbar` and `TMDataGrid.Spacer` take Mantine's `BoxProps` - the
135
+ style props (`mb`, `px`, `h`, `hiddenFrom`), `className`, `style` and `mod` -
136
+ set on the element itself. `withBottomBorder` on the toolbar draws a 1px line in
137
+ the theme's default border colour under it, the same line the header draws;
138
+ default `false`. `TMDataGrid.Footer`, `FilterPanel`, `FilterPills` and
139
+ `ColumnsPanel` take the same `BoxProps` on top of their own props.
140
+
141
+ ```tsx
142
+ <TMDataGrid.Toolbar withBottomBorder px="sm" mb="xs">
143
+ <TMDataGrid.SummaryCount />
144
+ <TMDataGrid.Spacer hiddenFrom="sm" />
145
+ <TMDataGrid.FilterButton />
146
+ </TMDataGrid.Toolbar>
147
+ ```
148
+
149
+ ### The grid menu
150
+
151
+ `TMDataGrid.Menu` is the burger: a Mantine `Menu` whose children are the
152
+ dropdown, so your own `Menu.Item`s sit beside the built-in items. It takes
153
+ Mantine `MenuProps` (defaults `position="bottom-end"`, `shadow="md"`,
154
+ `width={260}`, `withinPortal`), `icon` and `label` (default `labels.menuButton`).
155
+
156
+ ```tsx
157
+ import { Menu } from "@mantine/core";
158
+
159
+ <TMDataGrid.Menu>
160
+ <Menu.Item onClick={exportReport}>Export report</Menu.Item>
161
+ <Menu.Divider />
162
+ <Menu.Label>Columns</Menu.Label>
163
+ <TMDataGrid.Menu.Columns />
164
+ </TMDataGrid.Menu>
165
+ ```
166
+
167
+ `TMDataGrid.Menu.Columns` is the column chooser as menu items: `Menu.Search`,
168
+ one checkbox item per hideable column, show/hide all and reset layout;
169
+ it renders nothing when no column can be hidden. Its pieces
170
+ `TMDataGrid.Menu.ColumnToggles` (`search` narrows the list),
171
+ `.ShowHideAll` and `.ResetLayout` are exported for menus that want only some of
172
+ them. Every piece needs a Mantine `Menu` around it and reads the grid from
173
+ context, so it works in any Mantine menu rendered inside `TMDataGrid`, and in a
174
+ `Menu.Sub` (pass `searchable={false}` there: `Menu.Search` registers on the
175
+ root menu and switches off its type-ahead and arrow keys).
176
+
177
+ The menu always renders, since it cannot see what its children render; a menu
178
+ holding only `Menu.Columns` should be hidden with `canHideAny` under
179
+ `enableHiding: false`. `TMDataGrid.ColumnsPanel` is the same chooser as plain
180
+ controls, for a Popover, a Drawer or an inline layout.
181
+
129
182
  A button of your own reads the grid from context, which returns
130
183
  `{ table, ui, features, labels, controlSize, resetSettings }`:
131
184
 
132
185
  ```tsx
133
186
  import {
134
- exportGridToCsv,
187
+ exportGrid,
135
188
  getGridCapabilities,
136
189
  useTMDataGridContext,
137
190
  } from "@jielga/tmdatagrid";
@@ -143,7 +196,7 @@ function ExportButton() {
143
196
  if (!canFilterAny) return null;
144
197
 
145
198
  return (
146
- <Button size={controlSize} onClick={() => exportGridToCsv({ table })}>
199
+ <Button size={controlSize} onClick={() => void exportGrid({ table })}>
147
200
  Export
148
201
  </Button>
149
202
  );
@@ -206,7 +259,7 @@ own uses the same strings as the built-in parts.
206
259
  so an application that ordered its layers to put the grid underneath its own
207
260
  overrides silently gets the opposite.
208
261
 
209
- Source: `src/docs/styling.md` (The stylesheet).
262
+ Source: `packages/tmdatagrid/docs/styling.md` (The stylesheet).
210
263
 
211
264
  ### CRITICAL A grid with no bounded height
212
265
 
@@ -226,7 +279,7 @@ Correct:
226
279
  <TMDataGrid {...grid} style={{ flex: 1, minHeight: 0 }} />
227
280
  ```
228
281
 
229
- Source: `src/docs/styling.md` (Layout).
282
+ Source: `packages/tmdatagrid/docs/styling.md` (Layout).
230
283
 
231
284
  ### HIGH Setting `--dg-row-height` to change density
232
285
 
@@ -241,7 +294,7 @@ Correct:
241
294
  useTMDataGrid({ data, columns, meta: { rowHeight: 64 } });
242
295
  ```
243
296
 
244
- Source: `src/docs/styling.md` (The size scale).
297
+ Source: `packages/tmdatagrid/docs/styling.md` (The size scale).
245
298
 
246
299
  ### HIGH A capability check without `features`
247
300
 
@@ -264,7 +317,7 @@ const { canSort } = getColumnCapabilities(column, features);
264
317
  if (!canSort) return null;
265
318
  ```
266
319
 
267
- Source: `src/docs/toolbar.md` (Why `features` is a second argument).
320
+ Source: `packages/tmdatagrid/docs/toolbar.md` (Why `features` is a second argument).
268
321
 
269
322
  ### MEDIUM An inline `labels` object
270
323
 
@@ -286,7 +339,7 @@ const labels = { noResults: "Inga träffar" } satisfies TMDataGridLabelsOverride
286
339
  useTMDataGrid({ data, columns, labels });
287
340
  ```
288
341
 
289
- Source: `src/docs/localization.md` (Keep the object stable).
342
+ Source: `packages/tmdatagrid/docs/localization.md` (Keep the object stable).
290
343
 
291
344
  ### MEDIUM Conditionally rendering built-in toolbar parts
292
345
 
@@ -294,7 +347,7 @@ Each built-in already renders nothing when its feature is off. Wrapping them in
294
347
  your own checks duplicates the capability logic, and the two drift apart the
295
348
  first time an option changes.
296
349
 
297
- Source: `src/docs/toolbar.md` (The built-in parts).
350
+ Source: `packages/tmdatagrid/docs/toolbar.md` (The built-in parts).
298
351
 
299
352
  ## Reference
300
353
 
@@ -306,7 +359,7 @@ Source: `src/docs/toolbar.md` (The built-in parts).
306
359
  | `SIZE_ROW_HEIGHT` | Export | `Record<MantineSize, number>` | – | The row heights the scale table lists. |
307
360
  | `SIZE_CONTROL_SIZE` | Export | `Record<MantineSize, MantineSize>` | – | Which control size each grid size uses. |
308
361
  | `DEFAULT_TMDATAGRID_SIZE` | Export | `"md"` | – | The default size. |
309
- | `TMDataGrid.Toolbar` · `Spacer` | Components | `children` | – | The flex row, and the push-right. |
362
+ | `TMDataGrid.Toolbar` · `Spacer` | Components | `children`, `withBottomBorder`, Mantine `BoxProps` | `withBottomBorder: false` | The flex row, and the push-right. Style props set on the element. |
310
363
  | `useTMDataGridContext` | Hook | `() => TMDataGridContextValue` | – | `{ table, ui, features, labels, controlSize, resetSettings }`. |
311
364
  | `getGridCapabilities` | Export | `(table, features) => TMDataGridCapabilities` | – | What this grid can do, reactively. |
312
365
  | `getColumnCapabilities` | Export | `(column, features) => TMDataGridColumnCapabilities` | – | The same for one column. |
@@ -1,25 +1,25 @@
1
1
  ---
2
2
  name: cell-selection
3
3
  description: >
4
- Cell cursor, ranges, clipboard and CSV export in TMDataGrid. Covers the
5
- cellSelection option and its none / single / range modes, the keyboard map
6
- (arrows, Shift+arrows, PageUp/PageDown, Home/End, Enter, F2, Escape, Space,
7
- Ctrl+C), the one-tab-stop rule and the in-row Tab walk over controls inside
8
- cells, the role flip from table/cell to grid/gridcell, ui.state.focusedCell
9
- and ui.state.cellRange keyed by id, onFocusedCellChange, the copy and export
10
- context menu, the cellExport options and their Nordic Excel defaults, and
11
- exportGridToCsv over every filtered row. Load when adding keyboard cell
12
- navigation, selecting blocks of cells, copying to a spreadsheet, exporting
13
- CSV, or when Tab walks through controls inside the grid body.
4
+ Cell cursor, ranges and the clipboard in TMDataGrid. Covers the cellSelection
5
+ option and its none / single / range modes, the keyboard map (arrows,
6
+ Shift+arrows, PageUp/PageDown, Home/End, Enter, F2, Escape, Space, Ctrl+C),
7
+ the one-tab-stop rule and the in-row Tab walk over controls inside cells, the
8
+ role flip from table/cell to grid/gridcell, ui.state.focusedCell and
9
+ ui.state.cellRange keyed by id, onFocusedCellChange, and the Copy / Export
10
+ cells / Include headers context menu that writes the rectangle in the grid's
11
+ exportOptions format. Load when adding keyboard cell navigation, selecting
12
+ blocks of cells, copying to a spreadsheet, or when Tab walks through controls
13
+ inside the grid body. Exporting whole rows is the data skill.
14
14
  metadata:
15
15
  type: core
16
16
  library: '@jielga/tmdatagrid'
17
- library_version: '2.0.0-beta.9'
17
+ library_version: '2.0.1'
18
18
  sources:
19
- - 'Jielga/TMDataGrid:src/docs/cell-selection.md'
20
- - 'Jielga/TMDataGrid:src/tmdatagrid/core/cellNavigation.ts'
21
- - 'Jielga/TMDataGrid:src/tmdatagrid/core/cellRange.ts'
22
- - 'Jielga/TMDataGrid:src/tmdatagrid/core/cellExport.ts'
19
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/docs/cell-selection.md'
20
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/cellNavigation.ts'
21
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/cellRange.ts'
22
+ - 'Jielga/TMDataGrid:packages/tmdatagrid/src/core/export.ts'
23
23
  ---
24
24
 
25
25
  # TMDataGrid - Cell selection
@@ -115,31 +115,33 @@ Ctrl+C puts the block on the clipboard as tab-separated text with CRLF between
115
115
  rows, the format Excel, Sheets and Numbers all produce themselves. Values only:
116
116
  Excel's own copy carries no header row either.
117
117
 
118
- Right-clicking inside the selection opens Copy, "Export as CSV for Excel" and an
118
+ Right-clicking inside the selection opens Copy, "Export cells" and an
119
119
  "Include headers" toggle. A right-click outside it moves the selection there
120
120
  first, the way a spreadsheet does. Your own `renderRowContextMenu` items are appended
121
121
  below a divider, so nothing is lost by turning cell selection on.
122
122
 
123
- The CSV is written for a Nordic Excel: a `sep=;` first line, a UTF-8 BOM, CRLF
124
- endings, semicolons between fields and a comma as the decimal mark. That
125
- combination opens straight into columns with å ä ö intact.
123
+ "Export cells" writes the rectangle in the grid's export format - by default a
124
+ CSV for a Nordic Excel: a `sep=;` first line, a UTF-8 BOM, CRLF endings,
125
+ semicolons between fields and a comma as the decimal mark. The format, the file
126
+ name and the header row are the grid's `exportOptions`:
126
127
 
127
128
  ```tsx
128
- <TMDataGrid.Table
129
- cellExport={{ separator: ",", decimalComma: false, fileName: "employees" }}
130
- />
129
+ const grid = useTMDataGrid({
130
+ data,
131
+ columns,
132
+ cellSelection: "range",
133
+ exportOptions: { format: csvFormat(), fileName: "employees" },
134
+ });
131
135
  ```
132
136
 
133
- What gets written is the cell's **value**, not what it renders. Dates come out
134
- in the `sv-SE` form (`2026-07-31`), which Excel reads as a date.
137
+ What gets written is the cell's **value**, not what it renders, for the file and
138
+ for Ctrl+C alike; `meta.exportValue` substitutes a value and
139
+ `meta.enableExport: false` drops a column from both. Ctrl+C writes numbers with
140
+ the format's decimal mark, so what is pasted matches what is exported.
135
141
 
136
- `exportGridToCsv({ table, options })` takes **every filtered row** instead of the
137
- selected block, with the same options and defaults. There is no built-in button
138
- for it:
139
-
140
- ```tsx
141
- <Button onClick={() => exportGridToCsv({ table: grid.table })}>Export</Button>
142
- ```
142
+ Exporting every filtered row rather than the rectangle is
143
+ `TMDataGrid.Menu.Export`, `TMDataGrid.Menu.ExportSelected` and
144
+ `useTMDataGridExport`, covered by the data skill.
143
145
 
144
146
  ## Common mistakes
145
147
 
@@ -166,7 +168,7 @@ Correct:
166
168
  const OpenButton = ({ row }) => <Button onClick={() => open(row.id)}>Open</Button>;
167
169
  ```
168
170
 
169
- Source: `src/docs/cell-selection.md` (One tab stop).
171
+ Source: `packages/tmdatagrid/docs/cell-selection.md` (One tab stop).
170
172
 
171
173
  ### HIGH Selectors written for `table` / `cell` roles
172
174
 
@@ -174,7 +176,7 @@ The grid reports `grid` and `gridcell` once cell selection is on, so a test or a
174
176
  query written against `getByRole("cell")` stops resolving the moment the option
175
177
  is set - including when `editing` turns it on implicitly.
176
178
 
177
- Source: `src/docs/cell-selection.md`, and the `testing` skill.
179
+ Source: `packages/tmdatagrid/docs/cell-selection.md`, and the `testing` skill.
178
180
 
179
181
  ### HIGH Reading the selection as row and column indices
180
182
 
@@ -189,41 +191,40 @@ const row = grid.table.getRow(focusedCell.rowId);
189
191
  const value = row.getValue(focusedCell.columnId);
190
192
  ```
191
193
 
192
- Source: `src/docs/cell-selection.md` (Where the selection lives).
194
+ Source: `packages/tmdatagrid/docs/cell-selection.md` (Where the selection lives).
193
195
 
194
196
  ### MEDIUM Expecting the export to match what the cells show
195
197
 
196
198
  A cell renders React - often a badge, a link or a formatted string - and the
197
199
  export writes the underlying value. A currency cell showing `32 000 kr` exports
198
- `32000`. Format in the data, or post-process the matrix from `buildCellMatrix`,
199
- if the file must match the screen.
200
+ `32000`. Set `meta.exportValue` on the column, or post-process the data from
201
+ `buildExportData`, if the file must match the screen.
200
202
 
201
- Source: `src/docs/cell-selection.md` (The CSV).
203
+ Source: `packages/tmdatagrid/docs/cell-selection.md` (The file).
202
204
 
203
205
  ### MEDIUM Expecting headers in the clipboard
204
206
 
205
207
  Ctrl+C copies values only, matching Excel's own copy. Headers are an option of
206
- the export menu and of `cellExport`, not of the clipboard path.
208
+ the export menu and of `exportOptions`, not of the clipboard path.
207
209
 
208
- Source: `src/docs/cell-selection.md` (Copy and export).
210
+ Source: `packages/tmdatagrid/docs/cell-selection.md` (Copy and export).
209
211
 
210
212
  ## Reference
211
213
 
212
214
  | Name | Kind | Type | Default | What it does |
213
215
  | --- | --- | --- | --- | --- |
214
- | `cellSelection` | Option | `"none" \| "single" \| "range"` | `"none"`, or `"single"` under `editing` | Turns the cursor, and the rectangle, on. |
216
+ | `cellSelection` | Option | `TMDataGridCellSelectionMode`: `"none" \| "single" \| "range"` | `"none"`, or `"single"` under `editing` | Turns the cursor, and the rectangle, on. |
215
217
  | `onFocusedCellChange` | Callback | `(cell \| null) => void` | – | Follows the cursor. |
216
- | `cellExport` | Table prop | `TMDataGridCellExportOptions` | Nordic Excel | Separator, decimal mark, headers, file name. |
218
+ | `exportOptions` | Option | `TMDataGridExportOptions` | `DEFAULT_EXPORT_OPTIONS` | Format, file name and header row of the Export cells item. |
217
219
  | `ui.state.focusedCell` | UI state | `{ rowId, columnId } \| null` | `null` | The cursor. |
218
220
  | `ui.state.cellRange` | UI state | `{ anchor, focus } \| null` | `null` | The rectangle's two corners. |
219
221
  | `ui.actions.setFocusedCell` · `setCellRange` | UI actions | – | – | Move either from your own code. |
220
- | `exportGridToCsv` | Export | `({ table, options? }) => void` | – | Downloads every filtered row as CSV. |
221
- | `buildGridCellMatrix` · `buildCellMatrix` | Exports | – | – | The value matrix behind the file, for post-processing. |
222
- | `toClipboardText` · `toExcelCsv` · `writeClipboardText` · `downloadTextFile` | Exports | – | – | The pieces behind Ctrl+C and the file. |
223
- | `formatExportValue` | Export | `(value, options) => string` | – | One value, formatted as the export would. |
224
- | `DEFAULT_CELL_EXPORT_OPTIONS` | Export | object | – | The Nordic Excel defaults, to spread over. |
225
- | `isSameCell` · `resolveCellMove` | Exports | – | – | The cursor arithmetic, for a custom navigator. |
226
- | `resolveRangeBounds` · `isWithinBounds` · `boundsEdges` · `boundsCellCount` | Exports | – | – | The rectangle arithmetic. |
222
+ | `buildExportData` | Export | `({ table, rows, bounds }) => TMDataGridExportData` | – | The rectangle's values, with `bounds`; the whole grid without. |
223
+ | `toClipboardText` · `writeClipboardText` | Exports | `(data, options?) => string` · `(text) => Promise<boolean>` | – | The pieces behind Ctrl+C: the tab-separated text, and the write that reports whether it landed. |
224
+ | `TMDataGridClipboardTextOptions` | Type | `{ decimalComma?, escapeFormulas? }` | `true` · `true` | The options of `toClipboardText`. |
225
+ | `formatExportValue` | Export | `(value, options) => string` | – | One value, formatted as the text formats would. |
226
+ | `resolveRangeBounds` | Export | `({ range, rowIndexOf, columnIndexOf }) => TMDataGridRangeBounds \| null` | – | The range as row and column indices - the `bounds` for `buildExportData`, over `getDisplayedRows`. |
227
+ | `ResolveRangeBoundsArgs` · `TMDataGridRangeBounds` | Types | – · `{ top, bottom, left, right }` | – | What `resolveRangeBounds` takes, and what it returns. |
227
228
  | `data-focused` | Data attribute | – | – | On the focused cell. |
228
229
  | `data-edge-top` · `-bottom` · `-left` · `-right` | Data attributes | – | – | On cells at the rectangle's border. |
229
230