@nocopypaste/vue-grid 0.2.0 → 0.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 (91) hide show
  1. package/AGENTS.md +70 -5
  2. package/CHANGELOG.md +39 -0
  3. package/README.md +198 -33
  4. package/agent/api.json +130 -13
  5. package/agent/api.md +26 -10
  6. package/agent/grid-config.schema.json +50 -5
  7. package/dist/agent/api.js +121 -13
  8. package/dist/agent/requirements.js +12 -3
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/agent/validate.js +6 -2
  11. package/dist/agent/validate.js.map +1 -1
  12. package/dist/base.css +1 -1
  13. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +498 -414
  14. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +1 -1
  16. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
  17. package/dist/components/VGridCheckbox.vue_vue_type_script_setup_true_lang.js +7 -2
  18. package/dist/components/VGridCheckbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
  19. package/dist/components/VGridGroupCells.js +6 -0
  20. package/dist/components/VGridGroupCells.js.map +1 -0
  21. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +181 -0
  22. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -0
  23. package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +69 -56
  24. package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/VGridSelectionBanner.js +6 -0
  26. package/dist/components/VGridSelectionBanner.js.map +1 -0
  27. package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +33 -0
  28. package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -0
  29. package/dist/composables/useGridExport.js +135 -0
  30. package/dist/composables/useGridExport.js.map +1 -0
  31. package/dist/composables/useGridKeyboard.js +5 -1
  32. package/dist/composables/useGridKeyboard.js.map +1 -1
  33. package/dist/composables/useGridMenus.js +21 -1
  34. package/dist/composables/useGridMenus.js.map +1 -1
  35. package/dist/composables/useGridSelection.js +113 -50
  36. package/dist/composables/useGridSelection.js.map +1 -1
  37. package/dist/composables/useRowGrouping.js +103 -0
  38. package/dist/composables/useRowGrouping.js.map +1 -0
  39. package/dist/composables/useVirtualRows.js +5 -5
  40. package/dist/composables/useVirtualRows.js.map +1 -1
  41. package/dist/core/csv.js +28 -0
  42. package/dist/core/csv.js.map +1 -0
  43. package/dist/core/grouping.js +66 -0
  44. package/dist/core/grouping.js.map +1 -0
  45. package/dist/core.css +1 -1
  46. package/dist/features/export.js +9 -0
  47. package/dist/features/export.js.map +1 -0
  48. package/dist/features/index.js +25 -21
  49. package/dist/features/index.js.map +1 -1
  50. package/dist/features/rowGrouping.js +11 -0
  51. package/dist/features/rowGrouping.js.map +1 -0
  52. package/dist/features/selection.js +5 -3
  53. package/dist/features/selection.js.map +1 -1
  54. package/dist/index.js +55 -51
  55. package/dist/internal/clipboard.js +8 -2
  56. package/dist/internal/clipboard.js.map +1 -1
  57. package/dist/internal/context.js.map +1 -1
  58. package/dist/internal/features.js.map +1 -1
  59. package/dist/renderers/index.js +94 -83
  60. package/dist/renderers/index.js.map +1 -1
  61. package/dist/renderers/plainText.js +34 -0
  62. package/dist/renderers/plainText.js.map +1 -0
  63. package/dist/theme.css +1 -1
  64. package/dist/types/agent/requirements.d.ts +1 -1
  65. package/dist/types/components/VGrid.vue.d.ts +42 -4
  66. package/dist/types/components/VGridCheckbox.vue.d.ts +2 -2
  67. package/dist/types/components/VGridGroupCells.vue.d.ts +14 -0
  68. package/dist/types/components/VGridMenu.vue.d.ts +2 -2
  69. package/dist/types/components/VGridPagination.vue.d.ts +1 -1
  70. package/dist/types/components/VGridSelectionBanner.vue.d.ts +18 -0
  71. package/dist/types/composables/useGridExport.d.ts +49 -0
  72. package/dist/types/composables/useGridMenus.d.ts +8 -0
  73. package/dist/types/composables/useGridSelection.d.ts +26 -2
  74. package/dist/types/composables/useRowGrouping.d.ts +50 -0
  75. package/dist/types/composables/useVirtualRows.d.ts +2 -0
  76. package/dist/types/core/csv.d.ts +25 -0
  77. package/dist/types/core/grouping.d.ts +51 -0
  78. package/dist/types/features/export.d.ts +8 -0
  79. package/dist/types/features/index.d.ts +3 -1
  80. package/dist/types/features/rowGrouping.d.ts +8 -0
  81. package/dist/types/features/selection.d.ts +3 -1
  82. package/dist/types/index.d.ts +2 -0
  83. package/dist/types/internal/clipboard.d.ts +5 -1
  84. package/dist/types/internal/context.d.ts +8 -1
  85. package/dist/types/internal/features.d.ts +3 -1
  86. package/dist/types/renderers/plainText.d.ts +17 -0
  87. package/dist/types/types.d.ts +81 -3
  88. package/dist/vue-grid.css +1 -1
  89. package/llms-full.txt +294 -48
  90. package/llms.txt +1 -1
  91. package/package.json +1 -1
package/llms-full.txt CHANGED
@@ -15,7 +15,7 @@ JSON Schema. The `@nocopypaste/vue-grid-mcp` MCP server serves all of this as to
15
15
  1. **Import the CSS once**: `import '@nocopypaste/vue-grid/style.css'` (in `main.ts`). Without it the
16
16
  grid has no layout.
17
17
  2. **Register every feature an option needs.** `sortable`, `filterable`, `pagination`,
18
- `selectable`, `sub-rows`, `virtual`, `pinned`, `hidden`, `group`, `aggregate`, `totals`,
18
+ `selectable`, `sub-rows`, `virtual`, `pinned`, `hidden`, `group`, `aggregate`, `totals`, `group-by`,
19
19
  `pinned-rows`, `context-menu`… each needs its feature (table below). Without it the option
20
20
  **silently does nothing** (dev builds log a `[vue-grid]` warning naming the feature). Per grid:
21
21
  `:features="[sortingFeature, filteringFeature]"`; app-wide: `createVueGrid({ features: [...] })`;
@@ -50,7 +50,7 @@ JSON Schema. The `@nocopypaste/vue-grid-mcp` MCP server serves all of this as to
50
50
  | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
51
51
  | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
52
52
  | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
53
- | Checkboxes / row selection | `selectionFeature` | `selectable` (or `'single'`), `v-model:selected`, `is-row-selectable` |
53
+ | Checkboxes / row selection, batch actions | `selectionFeature` | `selectable` (or `'single'`), `v-model:selected`, `is-row-selectable`, `prune-selection`; `#toolbar="{ selected, selectedCount, clearSelection }"`; server data: `v-model:select-all-matching` |
54
54
  | Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
55
55
  | An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
56
56
  | 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
@@ -62,6 +62,8 @@ JSON Schema. The `@nocopypaste/vue-grid-mcp` MCP server serves all of this as to
62
62
  | Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
63
63
  | Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
64
64
  | A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
65
+ | Group rows by a column ("by status, then city") | `rowGroupingFeature` | `v-model:group-by="['status', 'city']"`, `groups-expanded`; column `groupable: true` (header menu), `groupValue: (row) => …` (e.g. month); `aggregate` shows per group |
66
+ | Download CSV, copy rows / cells (Ctrl+C) | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
65
67
  | Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
66
68
  | Remember column layout | — | `storage="orders-grid"` (localStorage key) |
67
69
  | Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
@@ -184,13 +186,22 @@ another `<VGrid>` inside.
184
186
  </VGrid>
185
187
  ```
186
188
 
187
- ### Selection
189
+ ### Selection and batch actions
188
190
 
189
191
  ```vue
190
- <VGrid v-model:selected="selected" :rows="rows" :columns="columns" row-key="id" selectable
191
- :is-row-selectable="(r) => r.status !== 'locked'" :features="[selectionFeature]" />
192
+ <VGrid v-model:selected="selected" :rows="rows" :columns="columns" row-key="id" selectable prune-selection
193
+ :is-row-selectable="(r) => r.status !== 'locked'" :features="[selectionFeature]">
194
+ <template #toolbar="{ selected, selectedCount, clearSelection }">
195
+ <span v-if="selectedCount">{{ selectedCount }} selected
196
+ <button @click="approve(selected).then(clearSelection)">Approve</button></span>
197
+ </template>
198
+ </VGrid>
192
199
  ```
193
200
 
201
+ Don't build a checkbox column with a renderer and your own `ref` of ids: `selectable` gives the
202
+ column, select-all, shift-click ranges, disabled rows and keyboard support. With `data-source`,
203
+ the banner's "Select all N rows" sets `v-model:select-all-matching`; act on the query then.
204
+
194
205
  ### 10,000+ rows
195
206
 
196
207
  ```vue
@@ -214,6 +225,49 @@ const pinned = ref<PinnedRowsState>({ top: [42] })
214
225
  <!-- grid.value.pinRow(key, 'top' | 'bottom' | null) from your own button or context menu -->
215
226
  ```
216
227
 
228
+ ### Row grouping
229
+
230
+ ```ts
231
+ const columns = [
232
+ col({ key: 'customer', field: 'customer.name' }),
233
+ col({ key: 'status', renderer: statusRenderer, groupable: true }),
234
+ col({ key: 'placedAt', renderer: dateRenderer, groupable: true, groupValue: (o) => o.placedAt.slice(0, 7) }),
235
+ col({ key: 'total', renderer: currencyRenderer, aggregate: 'sum' }), // shown in every group row
236
+ ]
237
+ const groupBy = ref(['status'])
238
+ ```
239
+
240
+ ```vue
241
+ <VGrid v-model:group-by="groupBy" :rows="orders" :columns="columns" row-key="id" sort-mode="client"
242
+ :features="[rowGroupingFeature, sortingFeature, menusFeature]" style="height: 480px" />
243
+ ```
244
+
245
+ Groups start collapsed (`groups-expanded` to open them); the group label sits in the first
246
+ visible column, so keep that column wide enough (or give the next columns no `aggregate`, so the
247
+ label runs across them). `#group-<key>="{ value, count }"` renders a group's value yourself.
248
+
249
+ ### CSV export and copy
250
+
251
+ ```vue
252
+ <script setup lang="ts">
253
+ import { exportFeature, keyboardNavigationFeature, selectionFeature, type VGridExposed } from '@nocopypaste/vue-grid'
254
+ const grid = ref<VGridExposed>()
255
+ // columns: `exportable: false` on action columns; `exportValue: (row) => row.id` where the cell isn't the data
256
+ </script>
257
+
258
+ <template>
259
+ <button @click="grid?.exportCsv({ filename: 'orders.csv' })">Download CSV</button>
260
+ <button @click="grid?.copyRows()">Copy selected</button>
261
+ <VGrid ref="grid" :rows="orders" :columns="columns" row-key="id" selectable
262
+ :features="[exportFeature, selectionFeature, keyboardNavigationFeature]" @copy="(e) => notify(e.text)" />
263
+ </template>
264
+ ```
265
+
266
+ `exportCsv` / `getCsv` default to the filtered, sorted rows on every page, the visible columns and
267
+ raw values; `copyRows` and Ctrl/⌘+C to the selected rows as displayed, tab-separated. Options:
268
+ `rows: 'filtered' | 'all' | 'page' | 'selected'`, `columns: [keys]`, `values: 'raw' | 'formatted'`,
269
+ `header`, `totals`, `children`, `delimiter`. `toCsv(rows, columns)` works without a grid.
270
+
217
271
  ### Row actions and context menu
218
272
 
219
273
  ```vue
@@ -283,10 +337,21 @@ Tokens: `--vg-*` (see README → Theming). Dark mode follows `color-scheme`. Den
283
337
  - Virtual grid with variable row content → rows must share `rowHeight`; use `lines`/`ellipsis` to keep them uniform.
284
338
  - `dataSource` plus `rows` → `rows` is ignored with a data source.
285
339
  - A nested child with different columns → not a sub-grid; use `#detail` with another `<VGrid>`.
340
+ - One group per date or timestamp → group by a coarser value: `groupValue: (row) => row.date.slice(0, 7)`.
341
+ - Ctrl+C copies nothing for a clicked cell → cells only take focus with `keyboardNavigationFeature`
342
+ (or select rows first); `exportFeature` must be registered too.
343
+ - An exported column of `⋯` / buttons / `[object Object]` → `exportable: false`, or `exportValue: (row) => …`.
344
+ - Copied numbers come out as `€1,234.50` → copying uses displayed values; pass `{ values: 'raw' }`
345
+ (CSV exports are raw by default).
346
+ - `group-by` names a field, not a column → it takes column `key`s; add a (hidden) column for it.
347
+ - `selected` still holds deleted or reloaded rows' keys → add `prune-selection` (keys are kept by
348
+ default so a selection can span server pages).
349
+ - A batch action on "Select all N rows" only touched one page → check `selectAllMatching` and act on
350
+ the query, not on `selected` (which holds the loaded rows only).
286
351
 
287
352
  ---
288
353
 
289
- # @nocopypaste/vue-grid 0.2.0 — API reference
354
+ # @nocopypaste/vue-grid 0.3.0 — API reference
290
355
 
291
356
  > Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
292
357
 
@@ -302,12 +367,14 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
302
367
  | `columnReorderFeature` | Column reordering: drag a header (mouse, pen, touch), Alt+←/→ on a focused header, and the header menu's Move left / Move right. Columns opt out with `reorderable: false`. The order is part of `v-model:column-state` and persisted with `storage`; `<VGridColumnMenu>` works without it. | | `reorderable` |
303
368
  | `columnResizingFeature` | Column resizing: drag a header's edge (mouse, pen, touch), use ←/→ on the focused edge (Alt+Shift+←/→ on a header with keyboard navigation), or double-click the edge to fit the content. `minWidth` / `maxWidth` bound it; columns opt out with `resizable: false`. Widths are kept in `columnState.widths` and persisted with `storage`. The header menu gains Fit width / Reset width. | | `maxWidth` `resizable` |
304
369
  | `columnVisibilityFeature` | Column visibility: `hidden: true` columns, `columnState.hidden` (persisted with `storage`), the header menu's Hide column item and `<VGridColumnMenu>`'s checkboxes. Columns opt out with `hideable: false`. Without it, every column shows. | | `hidden` `hideable` |
370
+ | `exportFeature` | CSV export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file, `grid.getCsv()` returns the text, `grid.copyRows()` copies rows as tab-separated text, and Ctrl/⌘+C copies the selected rows, else the focused cell, as displayed. Columns can set `exportValue` and `exportable: false`. Without it those methods only warn. | | `exportValue` `exportable` |
305
371
  | `filteringFeature` | Filtering: header funnels with typed filter popovers on `filterable` columns, the filter row, `<VGridSearch>`, the filter items of the header menu, `v-model:filters` and filter persistence. The popover body and the filter-row editors load on demand (own chunks). | `filterMode` `filterRow` `filterStorage` `noMatchText` `filters` | `filterable` `filter` `filterValue` `filterFn` `filterComponent` `searchable` |
306
372
  | `keyboardNavigationFeature` | Keyboard navigation (the ARIA grid pattern): the grid is one tab stop, arrow keys / Home / End / PageUp / PageDown move between cells, Enter activates a cell's control, Space selects a row, →/← expand and collapse, Alt+←/→ move a column, ContextMenu / Shift+F10 open the cell menu. Without it the grid is an ARIA `table`: its own controls (sort buttons, expanders, checkboxes, filter buttons) sit in the normal Tab order instead. | | |
307
373
  | `menusFeature` | Context menus: the built-in header menu (sort, filter, pin, move, hide, reset, your own items via `header-menu`) and body-cell menus (`context-menu`), opened by right-click, the ContextMenu key or Shift+F10. Without it the browser's own menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it. | `contextMenu` `headerMenu` | |
308
374
  | `paginationFeature` | Built-in pagination: the `pagination` prop and `v-model:page` / `v-model:page-size`. Pages the client rows, or asks the `dataSource` for pages. The pager loads on demand (own chunk). Not needed for the standalone `<VGridPagination>` component. | `pagination` `page` `pageSize` | |
375
+ | `rowGroupingFeature` | Row grouping: `v-model:group-by="['region', 'status']"` groups the rows by those columns into collapsible group rows with their value, row count and the aggregates of columns with an `aggregate`. Columns with `groupable: true` get Group by / Ungroup items in the header menu. Without it, `group-by` is ignored. | `groupsExpanded` `groupBy` | `groupable` `groupValue` |
309
376
  | `rowPinningFeature` | Pinned rows: `v-model:pinned-rows` (`{ top, bottom }` row keys), `pinned-top-rows` / `pinned-bottom-rows` (extra rows that aren't in the data) and the `pinRow()` method. Pinned rows stay in view (sticky) under the header or at the bottom while the body scrolls, and aren't filtered, sorted or paged. Without it, those options are ignored. | `pinnedTopRows` `pinnedBottomRows` `pinnedRows` | |
310
- | `selectionFeature` | Row selection: the `selectable` prop (multi or single), `v-model:selected`, `selection-mode` (cascade through sub-grids), `is-row-selectable`, Space on a row and the select-all checkbox. | `selectable` `selectionMode` `isRowSelectable` `selected` | |
377
+ | `selectionFeature` | Row selection: the `selectable` prop (multi or single), `v-model:selected`, `selection-mode` (cascade through sub-grids), `is-row-selectable`, Space on a row, shift-click (or Shift+Space) for a range, the select-all checkbox, `prune-selection`, and with server data a "select all N matching rows" banner (`v-model:select-all-matching`; it loads on demand, its own chunk). | `selectable` `selectionMode` `isRowSelectable` `pruneSelection` `selected` `selectAllMatching` | |
311
378
  | `serverDataFeature` | Server data: the `dataSource` prop. The grid sends sort, filters and page to your function, cancels superseded requests, and shows loading, error and retry states. | `dataSource` | |
312
379
  | `sortingFeature` | Sorting: the sort button on `sortable` column headers, the sort items of the header menu and, with `sort-mode="client"`, sorting the rows in the browser. | | `sortable` `sortValue` `sortFn` |
313
380
  | `subGridsFeature` | Sub-grids: nested child rows in a CSS `subgrid`, from `sub-rows` (synchronous) or `load-sub-rows` (lazy, cached, with loading / error / retry). Detail rows (`#detail` slot) don't need it. | `subRows` `loadSubRows` `hasSubRows` | |
@@ -331,6 +398,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
331
398
  | `selectable` | `boolean \| 'single'` | `false` | `selectionFeature` | A selection column: `true` = multi-select (with select-all), `'single'` = one row. |
332
399
  | `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | `selectionFeature` | `cascade` (default): selecting a parent selects its children. `independent`: rows alone. |
333
400
  | `isRowSelectable` | `(row: T) => boolean` | | `selectionFeature` | Rows that can't be selected get a disabled checkbox. |
401
+ | `pruneSelection` | `boolean` | `false` | `selectionFeature` | Drop selected keys whose rows are no longer in the data (after a reload, a delete, a new server page). Default: keys are kept, so a selection can span server pages. |
334
402
  | `subRows` | `(row: T) => T[] \| undefined \| null` | | `subGridsFeature` | Synchronous child rows of a row: shown in a nested sub-grid when expanded. |
335
403
  | `loadSubRows` | `(row: T) => Promise<T[]>` | | `subGridsFeature` | Lazy child rows, loaded on first expand (cached, with loading / error / retry). |
336
404
  | `hasSubRows` | `(row: T) => boolean` | | `subGridsFeature` | With `loadSubRows`: which rows get an expander (default: every row). |
@@ -357,6 +425,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
357
425
  | `totals` | `boolean \| 'top' \| 'bottom'` | `false` | `aggregationFeature` | A totals row with each column's `aggregate` (aggregation feature): `true` / `'bottom'` sticks it to the bottom, `'top'` under the header. |
358
426
  | `totalsLabel` | `string` | `'Total'` | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). |
359
427
  | `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
428
+ | `groupsExpanded` | `boolean` | `false` | `rowGroupingFeature` | Groups start expanded (row grouping feature). Default: collapsed. |
360
429
 
361
430
  ## `v-model`s
362
431
 
@@ -370,6 +439,8 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
370
439
  | `v-model:page` | `number` | `1` | `paginationFeature` | Current page (1-based); resets to 1 when sort or filters change. Needs the pagination feature. |
371
440
  | `v-model:pageSize` | `number` | `25` | `paginationFeature` | Rows per page. Needs the pagination feature. |
372
441
  | `v-model:pinnedRows` | `PinnedRowsState \| null` | `null` | `rowPinningFeature` | Top-level rows pinned above / below the body, by key: `{ top, bottom }`. Needs the row pinning feature. |
442
+ | `v-model:groupBy` | `readonly string[] \| string \| null` | `null` | `rowGroupingFeature` | Column keys to group the rows by, outermost first (`['region', 'status']`, or one key). Group rows show the value, the row count and the columns' aggregates. Needs the row grouping feature. |
443
+ | `v-model:selectAllMatching` | `boolean` | `false` | `selectionFeature` | Server data: every row matching the query is selected, not just the loaded ones (set from the "Select all N rows" banner; ends when filters change or a row is unticked). Act on the query then, not on `selected`. Needs the selection feature. |
373
444
 
374
445
  ## Events
375
446
 
@@ -383,6 +454,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
383
454
  | `sub-rows-error` | `[event: { row: T; error: unknown }]` | `loadSubRows` rejected for a row. |
384
455
  | `context-action` | `[event: ContextActionEvent<T>]` | An item of the body-cell context menu was chosen. |
385
456
  | `header-action` | `[event: HeaderActionEvent<T>]` | A custom item of the header menu was chosen (built-in items act by themselves). |
457
+ | `copy` | `[event: CopyEvent<T>]` | Rows or a cell were copied to the clipboard (export feature: `copyRows()`, Ctrl/⌘+C). |
386
458
 
387
459
  ## Slots
388
460
 
@@ -390,12 +462,13 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
390
462
  |---|---|---|
391
463
  | `cell-<key>` | `{ row: T; value: unknown; rowKey: RowKey; rowIndex: number; depth: number; column: ColumnDef<T> }` | A column's body cell, replacing its renderer: `#cell-<key>`. |
392
464
  | `header-<key>` | `{ column: ColumnDef<T> }` | A column's header content: `#header-<key>`. |
393
- | `total-<key>` | `{ value: unknown; column: ColumnDef<T> }` | A column's cell in the totals row (aggregation feature). |
465
+ | `total-<key>` | `{ value: unknown; column: ColumnDef<T>; group?: RowGroup<T> }` | A column's cell in the totals row and in group rows (aggregation, row grouping); `group` in group rows. |
466
+ | `group-<key>` | `{ value: unknown; count: number; rows: readonly T[]; column: ColumnDef<T>; group: RowGroup<T> }` | The value of a group row grouped by this column (row grouping feature): `#group-<key>`. |
394
467
  | `detail` | `{ row: T; rowKey: RowKey; depth: number }` | Expandable detail row under a row: any content, even another grid. |
395
468
  | `empty` | | Shown when there are no rows. |
396
469
  | `loading` | | Shown while loading with no rows yet. |
397
470
  | `sub-rows-loading` | `{ row: T }` | Shown while a row's lazy children load. |
398
- | `toolbar` | `{ columns: readonly ColumnDef<T>[]; columnState: ColumnState; setColumnState: (state: ColumnState) => void; filters: FilterState; setFilters: (state: FilterState) => void; clearFilters: () => void; activeFilterCount: number }` | Above the grid: put a search box, column menu or filter summary here. |
471
+ | `toolbar` | `{ columns: readonly ColumnDef<T>[]; columnState: ColumnState; setColumnState: (state: ColumnState) => void; filters: FilterState; setFilters: (state: FilterState) => void; clearFilters: () => void; activeFilterCount: number; selected: readonly RowKey[]; selectedCount: number; selectAllMatching: boolean; clearSelection: () => void }` | Above the grid: put a search box, column menu, filter summary or batch actions here. |
399
472
 
400
473
  ## Exposed methods (`ref<VGridExposed>()`)
401
474
 
@@ -406,13 +479,17 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
406
479
  | `expandAll` | `void` | | Expands every expandable row (sub-grids and detail rows) that passes the filters. |
407
480
  | `collapseAll` | `void` | | Collapses every row. |
408
481
  | `setColumnState` | `void` | | Replaces the column state (order, hidden, pins, widths), and saves it with `storage`. |
409
- | `patchLoadedRows` | `number` | | Applies field patches to lazily loaded child rows (`loadSubRows`), which the grid caches and the; app can't reach. Top-level and synchronous `subRows` data belong to the app: update them there (assign fields on reactive rows, or use `patchRows`). Returns the number of rows patched. |
482
+ | `patchLoadedRows` | `number` | | Applies field patches to lazily loaded child rows (`loadSubRows`), which the grid caches and the app can't reach. Top-level and synchronous `subRows` data belong to the app: update them there (assign fields on reactive rows, or use `patchRows`). Returns the number of rows patched. |
410
483
  | `setFilters` | `void` | `filteringFeature` | Replaces the filter model (also persisted with `filter-storage`). |
411
484
  | `clearFilters` | `void` | `filteringFeature` | Removes every column filter and the search. |
412
485
  | `openFilter` | `void` | `filteringFeature` | Opens a column's filter popover. |
413
486
  | `reload` | `Promise<void>` | `serverDataFeature` | Re-runs the `dataSource` with the current query; lazily loaded child rows load again too. |
414
487
  | `reloadSubRows` | `void` | | Forgets lazily loaded child rows (one row's, or all): expanded rows load them again. |
415
488
  | `pinRow` | `void` | `rowPinningFeature` | Pins a top-level row above or below the body, or unpins it (`null`). Row pinning feature. |
489
+ | `clearSelection` | `void` | | Clears the selection, "all matching rows" included. Selection feature. |
490
+ | `getCsv` | `string` | | The rows as CSV text: the filtered, sorted rows, visible columns, raw values. Export feature. |
491
+ | `exportCsv` | `void` | | Downloads the rows as a CSV file (`filename`, default `export.csv`; UTF-8 with a BOM). Export feature. |
492
+ | `copyRows` | `Promise<boolean>` | | Copies rows to the clipboard as tab-separated text (pastes as cells into spreadsheets): the selected rows by default, as displayed, no header. Resolves `false` if nothing was copied. Export feature. |
416
493
 
417
494
  ## `ColumnDef<T>`
418
495
 
@@ -429,7 +506,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
429
506
  | `minWidth` | `string` | | Lower bound; combined with `width` into `minmax(minWidth, width)`, and the resize minimum. |
430
507
  | `maxWidth` | `string` | `columnResizingFeature` | Upper bound when the user resizes the column (column resizing feature). |
431
508
  | `resizable` | `boolean` | `columnResizingFeature` | Can the user resize this column (column resizing feature)? Default `true`. |
432
- | `group` | `string` | `columnGroupsFeature` | Header group label (column groups feature): adjacent visible columns with the same `group`; share one header cell above their own headers. |
509
+ | `group` | `string` | `columnGroupsFeature` | Header group label (column groups feature): adjacent visible columns with the same `group` share one header cell above their own headers. |
433
510
  | `align` | `Align` | | Cell and header alignment (default: the renderer's, e.g. `end` for numbers, else `start`). |
434
511
  | `sortable` | `boolean` | `sortingFeature` | A sort button in the header (sorting feature). Client sorting needs `sort-mode="client"`. |
435
512
  | `sortValue` | `(row: T) => unknown` | `sortingFeature` | The value client sorting compares (default: the renderer's sort value, else the cell value). |
@@ -447,7 +524,11 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
447
524
  | `filterComponent` | `Component` | `filteringFeature` | Custom filter UI (popover), receives `modelValue` / emits `update:modelValue` with a filter. |
448
525
  | `searchable` | `boolean` | `filteringFeature` | Include in the quick search. Default `true` for visible columns. |
449
526
  | `flash` | `FlashMode` | | Briefly highlight the cell when its value changes (overrides the grid's `flash` prop). `'direction'`: green when a number goes up, red when it goes down. |
450
- | `aggregate` | `AggregateName \| AggregateFn<T>` | `aggregationFeature` | The column's value in the totals row (aggregation feature): `'sum' \| 'avg' \| 'min' \| 'max'`; over the cell values (empty values skipped), `'count'` of rows, or a function of the values and; the rows. Shown with the column's renderer (`count` as a plain number). |
527
+ | `aggregate` | `AggregateName \| AggregateFn<T>` | `aggregationFeature` | The column's value in the totals row (aggregation feature): `'sum' \| 'avg' \| 'min' \| 'max'` over the cell values (empty values skipped), `'count'` of rows, or a function of the values and the rows. Shown with the column's renderer (`count` as a plain number). |
528
+ | `groupable` | `boolean` | `rowGroupingFeature` | The header menu offers Group by / Ungroup for this column (row grouping feature). Any column can be grouped through `v-model:group-by`; this only adds the menu items. |
529
+ | `groupValue` | `(row: T) => unknown` | `rowGroupingFeature` | The value rows are grouped by (row grouping feature), e.g. `(row) => row.placedAt.slice(0, 7)` for months. Default: the cell value, shown with the column's renderer; a `groupValue` is shown as text (or with the `#group-<key>` slot). |
530
+ | `exportValue` | `(row: T) => unknown` | `exportFeature` | The value exports and copying use (export feature), e.g. a plain id for a link or an object. Wins over the cell value and the renderer's text. |
531
+ | `exportable` | `boolean` | `exportFeature` | Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns. |
451
532
  | `cellClass` | `ClassValue \| ((row: T) => ClassValue)` | | Extra classes for the column's body cells (or a function of the row). |
452
533
  | `headerClass` | `ClassValue` | | Extra classes for the column's header cell. |
453
534
 
@@ -807,7 +888,7 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
807
888
  |---|---|---|
808
889
  | `rowHeight` | `number` | Fixed row height in px. |
809
890
  | `overscan`? | `number` | Extra rows rendered above/below the viewport. Default 6. |
810
- | `detailHeight`? | `number` | Estimated height in px of a detail row (`#detail` slot) until it has been rendered and; measured. Default 4 × `rowHeight`. Data rows always have `rowHeight`. |
891
+ | `detailHeight`? | `number` | Estimated height in px of a detail row (`#detail` slot) until it has been rendered and measured. Default 4 × `rowHeight`. Data rows always have `rowHeight`. |
811
892
 
812
893
  ### `PinnedRowsState`
813
894
 
@@ -822,7 +903,7 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
822
903
  |---|---|---|
823
904
  | `order` | `string[]` | Column keys in display order (all known columns, visible or not). |
824
905
  | `hidden` | `string[]` | Keys of hidden columns. |
825
- | `pinned`? | `Record<string, PinSide \| null>` | Runtime pin overrides (e.g. from the header menu). `null` = explicitly unpinned; a missing key; falls back to the column's `pinned` definition. Optional so older persisted state still loads. |
906
+ | `pinned`? | `Record<string, PinSide \| null>` | Runtime pin overrides (e.g. from the header menu). `null` = explicitly unpinned; a missing key falls back to the column's `pinned` definition. Optional so older persisted state still loads. |
826
907
  | `widths`? | `Record<string, string>` | Widths the user resized columns to (CSS lengths, e.g. `'240px'`). Column resizing feature. |
827
908
 
828
909
  ### `SortState`
@@ -837,7 +918,7 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
837
918
  | Field | Type | Description |
838
919
  |---|---|---|
839
920
  | `type`? | `FilterType` | |
840
- | `options`? | `readonly FilterOption[] \| FilterOptionsLoader` | Choices for a `set` filter: a list, or a loader called with the search text (e.g. from a; backend — honour `signal`). Default: distinct values from the rows. |
921
+ | `options`? | `readonly FilterOption[] \| FilterOptionsLoader` | Choices for a `set` filter: a list, or a loader called with the search text (e.g. from a backend — honour `signal`). Default: distinct values from the rows. |
841
922
  | `placeholder`? | `string` | Placeholder of the filter-row input. |
842
923
 
843
924
  ### `FilterOption`
@@ -1023,7 +1104,7 @@ an opt-in feature:
1023
1104
  | `filteringFeature` | Funnels on `filterable` headers, `filter-row`, `<VGridSearch>`, `v-model:filters`, `filter-storage`, the header menu's filter items |
1024
1105
  | `serverDataFeature` | `data-source`: the grid fetches sorted, filtered pages itself |
1025
1106
  | `paginationFeature` | `pagination` and `v-model:page` / `v-model:page-size` (the standalone `<VGridPagination>` doesn't need it) |
1026
- | `selectionFeature` | `selectable` (multi or single), `v-model:selected`, `selection-mode`, `is-row-selectable`, select-all, Space to select |
1107
+ | `selectionFeature` | `selectable` (multi or single), `v-model:selected`, `selection-mode`, `is-row-selectable`, select-all, Space to select, shift-click / Shift+Space ranges, `prune-selection`, the selection in `#toolbar` for batch actions, "select all N matching rows" with server data (`v-model:select-all-matching`) |
1027
1108
  | `subGridsFeature` | `sub-rows` / `load-sub-rows` / `has-sub-rows`: nested rows in a CSS `subgrid` (detail rows don't need it) |
1028
1109
  | `menusFeature` | The header right-click menu (`header-menu`) and body-cell menus (`context-menu`); without it the browser's menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it |
1029
1110
  | `columnReorderFeature` | Dragging headers to reorder (mouse and pen; on touch, hold the header first), Alt+←/→ on a header, the header menu's Move items |
@@ -1035,6 +1116,8 @@ an opt-in feature:
1035
1116
  | `columnGroupsFeature` | Grouped column headers: columns with the same `group` share a header cell in a sticky row above theirs; groups follow reordering, hiding, resizing and pinning (a pin boundary splits a group) |
1036
1117
  | `rowPinningFeature` | `v-model:pinned-rows` / `pinRow()`: rows that stay in view above or below the body, plus `pinned-top-rows` / `pinned-bottom-rows` for rows that aren't in the data |
1037
1118
  | `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
1119
+ | `rowGroupingFeature` | `v-model:group-by`: rows grouped by one or more columns into collapsible group rows with the value, row count and aggregates; Group by / Ungroup in the header menu for `groupable` columns |
1120
+ | `exportFeature` | `exportCsv()` / `getCsv()` / `copyRows()`, Ctrl/⌘+C for the selected rows or the focused cell, the `copy` event; column `exportValue` / `exportable` |
1038
1121
 
1039
1122
  ```ts
1040
1123
  // per grid
@@ -1068,44 +1151,53 @@ what you import.
1068
1151
  | File | What | gzip |
1069
1152
  |---|---|---|
1070
1153
  | `base.css` | Structure only: grid layout, subgrid, sticky header and pins, tree indent, popover placement, virtual rows, pinned rows, truncation | 2.2 kB |
1071
- | `theme.css` | The default look on top of `base.css`: `--vg-*` tokens, colours, dark mode, densities, spacing, borders, typography, shadows, animation | 3.2 kB |
1072
- | `core.css` | `base.css` + `theme.css` | 5.0 kB |
1154
+ | `theme.css` | The default look on top of `base.css`: `--vg-*` tokens, colours, dark mode, densities, spacing, borders, typography, shadows, animation | 3.3 kB |
1155
+ | `core.css` | `base.css` + `theme.css` | 5.1 kB |
1073
1156
  | `renderers.css` | Styles for the cell renderers (other than text); uses the theme's tokens | 2.2 kB |
1074
- | `style.css` | All of the above | 6.5 kB |
1157
+ | `style.css` | All of the above | 6.6 kB |
1075
1158
 
1076
1159
  For a fully custom look, import only `base.css` (and `renderers.css` if you use renderers)
1077
1160
  and style the `.vg-*` classes yourself. See [Theming](#theming).
1078
1161
 
1079
1162
  | Import (minified / gzip, Vue excluded) | Initial chunk |
1080
1163
  |---|---|
1081
- | `VGrid` (no features) | 37.2 kB / 13.2 kB |
1082
- | `VGrid` + `sortingFeature` | 38.0 kB / 13.5 kB |
1083
- | `VGrid` + `filteringFeature` | 40.9 kB / 14.5 kB |
1084
- | `VGrid` + `serverDataFeature` | 38.6 kB / 13.8 kB |
1085
- | `VGrid` + `paginationFeature` | 37.4 kB / 13.2 kB |
1086
- | `VGrid` + `selectionFeature` | 39.6 kB / 14.0 kB |
1087
- | `VGrid` + `subGridsFeature` | 39.5 kB / 14.0 kB |
1088
- | `VGrid` + `menusFeature` | 47.7 kB / 16.8 kB |
1089
- | `VGrid` + `columnReorderFeature` | 40.9 kB / 14.5 kB |
1090
- | `VGrid` + `columnPinningFeature` | 39.5 kB / 14.1 kB |
1091
- | `VGrid` + `virtualScrollingFeature` | 43.0 kB / 15.5 kB |
1092
- | `VGrid` + `columnVisibilityFeature` | 37.4 kB / 13.2 kB |
1093
- | `VGrid` + `keyboardNavigationFeature` | 39.6 kB / 14.0 kB |
1094
- | `VGrid` + `columnResizingFeature` | 40.1 kB / 14.3 kB |
1095
- | `VGrid` + `columnGroupsFeature` | 38.8 kB / 13.8 kB |
1096
- | `VGrid` + `rowPinningFeature` | 42.4 kB / 14.7 kB |
1097
- | `VGrid` + `aggregationFeature` | 42.7 kB / 14.8 kB |
1098
- | `VGrid` + `allFeatures` + `VGridSearch` | 81.0 kB / 28.1 kB |
1099
- | `VGrid` + `currencyRenderer` | 38.5 kB / 13.6 kB |
1100
- | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 41.6 kB / 14.7 kB |
1101
- | `sortRows` only | 0.7 kB / 0.5 kB |
1102
- | everything | 124.1 kB / 40.4 kB |
1103
- | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 57.5 kB / 15.4 kB |
1164
+ | `VGrid` (no features) | 39.0 kB / 13.6 kB |
1165
+ | `VGrid` + `sortingFeature` | 39.8 kB / 13.9 kB |
1166
+ | `VGrid` + `filteringFeature` | 49.7 kB / 17.4 kB |
1167
+ | `VGrid` + `serverDataFeature` | 40.4 kB / 14.2 kB |
1168
+ | `VGrid` + `paginationFeature` | 39.2 kB / 13.7 kB |
1169
+ | `VGrid` + `selectionFeature` | 43.2 kB / 15.1 kB |
1170
+ | `VGrid` + `subGridsFeature` | 41.4 kB / 14.5 kB |
1171
+ | `VGrid` + `menusFeature` | 49.6 kB / 17.2 kB |
1172
+ | `VGrid` + `columnReorderFeature` | 42.7 kB / 14.9 kB |
1173
+ | `VGrid` + `columnPinningFeature` | 41.2 kB / 14.5 kB |
1174
+ | `VGrid` + `virtualScrollingFeature` | 44.8 kB / 15.8 kB |
1175
+ | `VGrid` + `columnVisibilityFeature` | 39.2 kB / 13.7 kB |
1176
+ | `VGrid` + `keyboardNavigationFeature` | 41.5 kB / 14.5 kB |
1177
+ | `VGrid` + `columnResizingFeature` | 41.8 kB / 14.7 kB |
1178
+ | `VGrid` + `columnGroupsFeature` | 40.3 kB / 14.1 kB |
1179
+ | `VGrid` + `rowPinningFeature` | 44.0 kB / 15.0 kB |
1180
+ | `VGrid` + `aggregationFeature` | 44.2 kB / 15.1 kB |
1181
+ | `VGrid` + `rowGroupingFeature` | 48.6 kB / 16.4 kB |
1182
+ | `VGrid` + `exportFeature` | 42.8 kB / 15.1 kB |
1183
+ | `VGrid` + `allFeatures` + `VGridSearch` | 102.8 kB / 34.7 kB |
1184
+ | `VGrid` + `currencyRenderer` | 40.4 kB / 14.1 kB |
1185
+ | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 45.8 kB / 15.9 kB |
1186
+ | `sortRows` only | 0.7 kB / 0.4 kB |
1187
+ | `toCsv` only | 1.1 kB / 0.6 kB |
1188
+ | everything | 147.4 kB / 47.2 kB |
1189
+ | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 63.7 kB / 17.1 kB |
1104
1190
 
1105
1191
  With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
1106
1192
  chunks**: they load the first time a popover opens or `filter-row` is on. With
1107
- `paginationFeature`, the pager is one too. Measured with esbuild (`--bundle --minify --splitting`,
1108
- `process.env.NODE_ENV` set to `production`, which also drops the dev warnings).
1193
+ `paginationFeature`, the pager is one too, and with `selectionFeature` the "select all N rows" banner.
1194
+
1195
+ Measured with Rolldown (the bundler in Vite) on tiny apps importing the published build:
1196
+ minified, gzipped, Vue external, `process.env.NODE_ENV` set to `production` (which also drops the
1197
+ dev warnings). "Initial" counts the entry and every chunk it loads up front; on-demand chunks are
1198
+ left out. esbuild with `--splitting` tree-shakes the package too, but also loads the pager's and
1199
+ the filter core's chunks (5.2 kB, 2.3 kB gzip) in a grid without those features: esbuild keeps
1200
+ chunks that on-demand imports share with the entry, even when nothing uses them.
1109
1201
 
1110
1202
  ## `<VGrid>` API
1111
1203
 
@@ -1134,16 +1226,20 @@ chunks**: they load the first time a popover opens or `filter-row` is on. With
1134
1226
  | `loadSubRows` | `(row) => Promise<T[]>` | — | Lazy children (cached, loading/error/retry). |
1135
1227
  | `hasSubRows` | `(row) => boolean` | — | Which rows get an expander when lazy. |
1136
1228
  | `rowExpandable` | `(row) => boolean` | — | Which rows can open the `#detail` slot. |
1137
- | `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next three). |
1229
+ | `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next five). See [Selection and batch actions](#selection-and-batch-actions). |
1138
1230
  | `v-model:selected` | `RowKey[]` | `[]` | |
1139
1231
  | `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | Whether selecting a parent selects its children. |
1140
1232
  | `isRowSelectable` | `(row) => boolean` | — | |
1233
+ | `pruneSelection` | `boolean` | `false` | Drop selected keys whose rows left the data (reload, delete, another server page). |
1234
+ | `v-model:selectAllMatching` | `boolean` | `false` | Server data: every row matching the query is selected (from the banner). |
1141
1235
  | `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false` | Virtual scrolling (fixed-height rows; sub-grids and measured detail rows included). Needs `virtualScrollingFeature`. |
1142
1236
  | `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null` | Top-level rows pinned above / below the body. Needs `rowPinningFeature` (as do the next two). See [Pinned rows and totals](#pinned-rows-and-totals). |
1143
1237
  | `pinnedTopRows` / `pinnedBottomRows` | `T[]` | — | Extra pinned rows that aren't part of `rows` (a target, last year's figures). |
1144
1238
  | `totals` | `boolean \| 'top' \| 'bottom'` | `false` | A totals row with each column's `aggregate`; `true` = `'bottom'`. Needs `aggregationFeature` (as do the next two). |
1145
1239
  | `totalsLabel` | `string` | `'Total'` | Shown in the totals row's first column (unless that column has an aggregate). |
1146
1240
  | `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
1241
+ | `v-model:groupBy` | `string[] \| string \| null` | `null` | Column keys to group the rows by, outermost first. Needs `rowGroupingFeature` (as does the next one). See [Row grouping](#row-grouping). |
1242
+ | `groupsExpanded` | `boolean` | `false` | Groups start expanded. |
1147
1243
  | `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
1148
1244
  | `rowClass` | `(row, index) => ClassValue` | — | |
1149
1245
  | `highlightedRows` | `RowKey[]` | — | |
@@ -1163,6 +1259,7 @@ chunks**: they load the first time a popover opens or `filter-row` is on. With
1163
1259
  `row-click(row, event)` · `cell-click({ row, rowKey, column, value, event })` (columns with `clickable: true`) ·
1164
1260
  `cell-action({ name, payload, row, rowKey, column })` (from renderers) · `sub-rows-error({ row, error })` · `context-action({ name, item, row, rowKey, column, value })` · `header-action({ name, item, column })` ·
1165
1261
  `query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
1262
+ `copy({ kind, text, rows, columns })` (rows or a cell were copied: `exportFeature`) ·
1166
1263
  `load-error(error)` (a `dataSource` call failed) ·
1167
1264
  plus the `update:*` events of every `v-model`.
1168
1265
 
@@ -1171,8 +1268,9 @@ Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
1171
1268
  ### Slots
1172
1269
 
1173
1270
  `cell-<key>` (`{ row, value, rowKey, rowIndex, depth, column }`) · `header-<key>` (`{ column }`) ·
1174
- `total-<key>` (`{ value, column }`, a cell of the totals row) · `detail` (`{ row, rowKey, depth }`) ·
1175
- `toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount }`) ·
1271
+ `total-<key>` (`{ value, column, group? }`, a cell of the totals row or a group row) ·
1272
+ `group-<key>` (`{ value, count, rows, column, group }`, the value of a group row) · `detail` (`{ row, rowKey, depth }`) ·
1273
+ `toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount, selected, selectedCount, selectAllMatching, clearSelection }`) ·
1176
1274
  `empty` · `loading` · `sub-rows-loading` (`{ row }`).
1177
1275
 
1178
1276
  ### Exposed methods
@@ -1183,8 +1281,10 @@ grid.value?.scrollToTop() / scrollToRow(key) / expandAll() / collapseAll() / set
1183
1281
  grid.value?.patchLoadedRows([{ id: 'c2', city: 'Niš' }]) // field updates for lazy children and dataSource rows
1184
1282
  grid.value?.setFilters({ columns: { city: { type: 'text', op: 'contains', value: 'nis' } } })
1185
1283
  grid.value?.clearFilters() / openFilter('city') / reload() // reload: re-run the dataSource query
1284
+ grid.value?.clearSelection() // selectionFeature: clears the selection, "all matching" included
1186
1285
  grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
1187
1286
  grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
1287
+ grid.value?.exportCsv({ filename: 'orders.csv' }) / getCsv() / copyRows() // exportFeature, see Export and copy
1188
1288
  ```
1189
1289
 
1190
1290
  `reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
@@ -1244,11 +1344,52 @@ animate on the compositor (GPU): a busy live feed costs the main thread about a
1244
1344
  filterFn?: (row, filter) => boolean // replaces the built-in matching for this column
1245
1345
  filterComponent?: Component // custom popover body: props { modelValue, column }, emits update:modelValue
1246
1346
  searchable?: boolean // included in the quick search (default true for visible columns)
1247
- aggregate?: 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values, rows) => unknown) // totals row (aggregationFeature)
1347
+ aggregate?: 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values, rows) => unknown) // totals row (aggregationFeature) and group rows
1348
+ groupable?: boolean // Group by / Ungroup in the header menu (rowGroupingFeature)
1349
+ groupValue?: (row) => unknown // what rows are grouped by (default: the cell value), e.g. the month of a date
1350
+ exportValue?: (row) => unknown // what CSV exports and copying use (exportFeature), e.g. an id instead of a link
1351
+ exportable?: boolean // in exports and copied rows (default true); false for action columns
1248
1352
  cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
1249
1353
  }
1250
1354
  ```
1251
1355
 
1356
+ ## Selection and batch actions
1357
+
1358
+ `selectionFeature` adds a checkbox column. `v-model:selected` holds the selected row keys; the
1359
+ `#toolbar` slot gets them too, so a batch-action bar lives in the grid:
1360
+
1361
+ ```vue
1362
+ <VGrid v-model:selected="selected" :rows="requests" :columns="columns" row-key="id" selectable prune-selection
1363
+ :is-row-selectable="(r) => r.status === 'pending'" :features="[selectionFeature]">
1364
+ <template #toolbar="{ selected, selectedCount, clearSelection }">
1365
+ <template v-if="selectedCount">
1366
+ {{ selectedCount }} selected
1367
+ <button @click="approve(selected).then(clearSelection)">Approve</button>
1368
+ <button @click="clearSelection()">Clear</button>
1369
+ </template>
1370
+ </template>
1371
+ </VGrid>
1372
+ ```
1373
+
1374
+ - **Ranges.** Shift-click a checkbox (or Shift+Space with keyboard navigation) to give every row
1375
+ on screen from the last toggled one to this one the clicked row's new state. Ranges follow the
1376
+ display order (sort, filters, expanded sub-grids, open groups) and skip rows that can't be
1377
+ selected.
1378
+ - **Select all.** The header checkbox selects every selectable row that passes the filters, on
1379
+ every page; `selectable="single"` has radio buttons and no select-all.
1380
+ - **Rows that leave.** By default selected keys stay when their rows leave the data, so a
1381
+ selection can span server pages. `prune-selection` drops them instead: after a reload, a batch
1382
+ delete or a new page, `selected` only holds rows that exist.
1383
+ - **All matching rows (server data).** With a `data-source`, the header checkbox selects the loaded
1384
+ page; a banner then offers *Select all N rows* (N = the `total` the source returned). That sets
1385
+ `v-model:select-all-matching`: every row shows ticked, `selectedCount` is N, and your batch
1386
+ action should run on the query (`@query-change`) rather than on `selected`. Changing the
1387
+ filters, unticking a row (the keys already in `selected` stay, plus the rest of the loaded page) or
1388
+ *Clear selection* ends it.
1389
+ - `grid.clearSelection()` clears it all from code. Cascading through sub-grids, group checkboxes
1390
+ (row grouping) and copying the selected rows (export feature) work as described in their
1391
+ sections.
1392
+
1252
1393
  ## Sub-grids (CSS `subgrid`)
1253
1394
 
1254
1395
  ```vue
@@ -1521,6 +1662,109 @@ With virtual scrolling, `aria-rowindex` / `aria-rowcount` count them. Style them
1521
1662
  `.vg-pinned-top`, `.vg-pinned-bottom`, `.vg-row-pinned`, `.vg-row-total` and the
1522
1663
  `--vg-total-row-bg` / `--vg-total-row-font-weight` tokens.
1523
1664
 
1665
+ ## Row grouping
1666
+
1667
+ `rowGroupingFeature` groups the rows by one or more columns. Each group is a row with the grouped
1668
+ column's name, the value, the number of rows and each column's `aggregate` over the group; expand
1669
+ it to see its sub-groups or, at the last level, its rows.
1670
+
1671
+ ```vue
1672
+ <script setup lang="ts">
1673
+ const columns = [
1674
+ col({ key: 'player', field: 'player.name' }),
1675
+ col({ key: 'city', field: 'player.city', groupable: true }),
1676
+ col({ key: 'status', renderer: statusRenderer, groupable: true }),
1677
+ col({ key: 'stake', renderer: currencyRenderer, aggregate: 'sum' }),
1678
+ col({ key: 'placedAt', renderer: dateRenderer, groupable: true, groupValue: (b) => b.placedAt.slice(0, 7) }),
1679
+ ]
1680
+ const groupBy = ref(['status', 'city'])
1681
+ </script>
1682
+
1683
+ <template>
1684
+ <VGrid v-model:group-by="groupBy" :rows="bets" :columns="columns" row-key="id" totals
1685
+ :features="[rowGroupingFeature, aggregationFeature]" />
1686
+ </template>
1687
+ ```
1688
+
1689
+ - **What a group shows.** The first column holds the expander, the grouped column's header, the
1690
+ value (with that column's renderer, so a status groups under its badge; a `groupValue` shows as
1691
+ text) and the row count. That cell runs across the columns after it up to the first one with
1692
+ an `aggregate`; those show the group's own aggregate. The `group-<key>` slot renders the value
1693
+ yourself (`{ value, count, rows, column, group }`); `total-<key>` also renders group cells
1694
+ (with `group` set). Empty values form a `(blank)` group, last.
1695
+ - **Order, filters, pages.** Groups follow the filters and are ordered by value, descending when
1696
+ the grid is sorted descending by the grouped column; sorting by any other column orders the
1697
+ rows inside each group. Pagination pages the top-level groups. With server data, the rows of
1698
+ the current page are grouped.
1699
+ - **Expanding.** Groups start collapsed (`groups-expanded` opens them). Click a group's label or its
1700
+ arrow, or use →/← with keyboard navigation; `expandAll()` / `collapseAll()` include groups.
1701
+ Changing `group-by` starts over.
1702
+ - **Selection.** A group's checkbox selects or clears every row in it, and shows partly
1703
+ selected groups as indeterminate.
1704
+ - **Header menu.** Columns with `groupable: true` get *Group by* (adds a level) / *Ungroup*, and
1705
+ *Ungroup all*. Any column can be grouped through `v-model:group-by`.
1706
+ - **Virtual scrolling.** Group rows are part of the virtual layout: thousands of rows in a few
1707
+ groups render only what's in view.
1708
+
1709
+ Style group rows with `.vg-rowgroup` (and `[data-group-level]`), `.vg-rowgroup-name`,
1710
+ `.vg-rowgroup-value`, `.vg-rowgroup-count` and the `--vg-rowgroup-bg` /
1711
+ `--vg-rowgroup-font-weight` tokens. `groupRows()` and `isRowGroup()` are exported for using the
1712
+ same grouping elsewhere.
1713
+
1714
+ ## Export and copy
1715
+
1716
+ `exportFeature` turns the grid's rows into CSV and copies them to the clipboard.
1717
+
1718
+ ```vue
1719
+ <script setup lang="ts">
1720
+ const grid = ref<VGridExposed>()
1721
+ const columns = [
1722
+ col({ key: 'customer', field: 'customer.name' }),
1723
+ col({ key: 'total', renderer: currencyRenderer, aggregate: 'sum' }),
1724
+ col({ key: 'link', renderer: linkRenderer, exportValue: (o) => o.id }), // export the id, not the link
1725
+ col({ key: 'actions', renderer: actionsMenuRenderer, exportable: false }), // left out
1726
+ ]
1727
+ </script>
1728
+
1729
+ <template>
1730
+ <button @click="grid?.exportCsv({ filename: 'orders.csv', totals: true })">Download CSV</button>
1731
+ <button @click="grid?.copyRows()">Copy selected</button>
1732
+ <VGrid ref="grid" :rows="orders" :columns="columns" row-key="id" selectable totals
1733
+ :features="[exportFeature, selectionFeature, aggregationFeature, keyboardNavigationFeature]"
1734
+ @copy="(e) => toast(`Copied ${e.rows.length} rows`)" />
1735
+ </template>
1736
+ ```
1737
+
1738
+ - **`exportCsv(options)`** downloads a `.csv` file (`filename`, default `export.csv`) in UTF-8 with
1739
+ a BOM, so Excel shows accents right (`bom: false` to drop it). **`getCsv(options)`** returns the
1740
+ same text, for uploading or previewing.
1741
+ - **`copyRows(options)`** copies rows as tab-separated text, which pastes as cells into Excel,
1742
+ Google Sheets or Numbers. It resolves `false` when nothing was copied.
1743
+ - **Ctrl / ⌘ + C** inside the grid copies the selected rows; with none selected, the focused cell
1744
+ (cells take focus with `keyboardNavigationFeature`). A text selection, or focus in an input,
1745
+ is left to the browser.
1746
+ - **Options** (all methods): `rows` — `'filtered'` (default for exports: the rows that pass the
1747
+ filters, sorted, every page), `'all'`, `'page'`, `'selected'` (default for copying, nested rows
1748
+ included); `children: true` adds the known sub-grid rows after their parent; `columns` — keys,
1749
+ in order, hidden columns allowed (default: the visible columns without `exportable: false`);
1750
+ `values` — `'raw'` (default for exports: numbers and ISO dates a spreadsheet can compute with)
1751
+ or `'formatted'` (default for copying: as the cells show them); `header` (default `true` for
1752
+ exports, `false` for copying); `totals: true` adds the totals row; `delimiter` (`,` / tab);
1753
+ `guard` (default `true`).
1754
+ - **Values.** A column's `exportValue(row)` wins. Formatted values come from the renderer's
1755
+ `format` (numbers, currency, change, dates, date-times, booleans, status, chips and lists have
1756
+ one; your own renderers can add it); other values are written as text: dates in ISO 8601,
1757
+ arrays joined with `, `, objects as JSON. Grouped grids export their rows, not the group rows.
1758
+ - **Safe for spreadsheets.** Fields are quoted per RFC 4180, and text that a spreadsheet would run
1759
+ as a formula (`=…`, `+…`, `-…`, `@…`) gets a leading `'`; numbers are left alone.
1760
+ - **Clipboard.** Copying uses the Clipboard API and falls back to the browser's copy command where
1761
+ that API is missing or refused (pages served over plain http), as does the copy button of
1762
+ text cells.
1763
+
1764
+ Without the grid: `toCsv(rows, columns, { delimiter, header, guard })` writes CSV from any rows
1765
+ and column definitions (raw values, `exportValue`, `exportable`); `toDelimited(table)`,
1766
+ `plainText(value)` and `guardFormula(text)` are its parts.
1767
+
1524
1768
  ## Virtual scrolling
1525
1769
 
1526
1770
  ```vue
@@ -1691,6 +1935,8 @@ declare module '@nocopypaste/vue-grid' {
1691
1935
  }
1692
1936
  export const ratingRenderer = defineCellRenderer<{ max?: number }>({
1693
1937
  name: 'rating', component: RatingCell, defaults: { max: 5 }, sortValue: (v) => Number(v),
1938
+ // what Ctrl+C and formatted CSV exports copy (export feature); without it the raw value
1939
+ format: (v, options, ctx, row) => `${Number(v ?? 0)} of ${options.max ?? 5}`,
1694
1940
  })
1695
1941
  // app.use(createVueGrid({ renderers: [ratingRenderer] })) or <VGrid :renderers="[ratingRenderer]">
1696
1942
  ```
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # @nocopypaste/vue-grid
2
2
 
3
- > A Vue 3 data grid laid out with CSS Grid and `subgrid`. A plain grid is a read-only table (13.2 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Typed end to end, accessible, themeable with CSS variables, mobile and touch ready.
3
+ > A Vue 3 data grid laid out with CSS Grid and `subgrid`. A plain grid is a read-only table (13.6 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping, CSV export and copy, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Typed end to end, accessible, themeable with CSS variables, mobile and touch ready.
4
4
 
5
5
  Read AGENTS.md first: it lists the rules that cause silent bugs when skipped (register features, pass renderer definitions, `sort-mode="client"`, bounded height), a "which feature for what" table and copy-paste recipes. Validate a grid config with `validateGridConfig()` from `@nocopypaste/vue-grid/agent`.
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocopypaste/vue-grid",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CSS-Grid based data grid for Vue 3 with opt-in features, pluggable cell renderers, sub-grids and CSS-variable theming — documented for coding agents (AGENTS.md, llms.txt, JSON Schema, validator).",
5
5
  "license": "MIT",
6
6
  "type": "module",