@nocopypaste/vue-grid 0.7.0 → 0.8.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 (44) hide show
  1. package/AGENTS.md +28 -25
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +84 -25
  4. package/agent/api.json +18 -2
  5. package/agent/api.md +4 -2
  6. package/agent/grid-config.schema.json +6 -0
  7. package/dist/agent/api.js +16 -2
  8. package/dist/agent/requirements.js +1 -0
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +406 -370
  11. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +3 -3
  13. package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/dist/composables/useDataSource.js +21 -19
  15. package/dist/composables/useDataSource.js.map +1 -1
  16. package/dist/composables/useGridExport.js +1 -1
  17. package/dist/composables/useGridExport.js.map +1 -1
  18. package/dist/composables/useRowGrouping.js +103 -74
  19. package/dist/composables/useRowGrouping.js.map +1 -1
  20. package/dist/composables/useServerGroups.js +106 -0
  21. package/dist/composables/useServerGroups.js.map +1 -0
  22. package/dist/core/grouping.js +41 -24
  23. package/dist/core/grouping.js.map +1 -1
  24. package/dist/features/index.js +12 -10
  25. package/dist/features/index.js.map +1 -1
  26. package/dist/features/serverGrouping.js +9 -0
  27. package/dist/features/serverGrouping.js.map +1 -0
  28. package/dist/index.js +7 -6
  29. package/dist/internal/features.js.map +1 -1
  30. package/dist/types/agent/requirements.d.ts +1 -1
  31. package/dist/types/components/VGrid.vue.d.ts +11 -2
  32. package/dist/types/composables/useDataSource.d.ts +33 -2
  33. package/dist/types/composables/useGridExport.d.ts +2 -0
  34. package/dist/types/composables/useRowGrouping.d.ts +12 -1
  35. package/dist/types/composables/useServerGroups.d.ts +37 -0
  36. package/dist/types/core/grouping.d.ts +26 -0
  37. package/dist/types/features/index.d.ts +2 -1
  38. package/dist/types/features/serverGrouping.d.ts +9 -0
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/internal/features.d.ts +2 -1
  41. package/dist/types/types.d.ts +5 -1
  42. package/llms-full.txt +116 -52
  43. package/llms.txt +1 -1
  44. package/package.json +1 -1
package/AGENTS.md CHANGED
@@ -45,31 +45,32 @@ runs in the [live examples](https://eboye.github.io/eboye-vue-grid/), each with
45
45
 
46
46
  ## Which feature for what
47
47
 
48
- | The user wants… | Feature(s) | Props / column options |
49
- | ------------------------------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
50
- | Click a header to sort | `sortingFeature` | column `sortable: true`; `sort-mode="client"` (or handle `v-model:sort`) |
51
- | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
52
- | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
53
- | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
54
- | 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` |
55
- | Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
56
- | An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
57
- | 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
58
- | Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
59
- | Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'`; on narrow grids they scroll unless `pinned-max-share` allows (default half the width) |
60
- | Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
61
- | Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
62
- | Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
63
- | Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
64
- | Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
65
- | A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
66
- | 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 |
67
- | Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
68
- | Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
69
- | Translate / reword the grid, drop built-in pieces | — | `messages` (`GridMessages`), `parts` (`GridParts`): app-wide in `createVueGrid` or per grid; slots `#load-error`, `#no-match`, `#select-all-banner` |
70
- | Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
71
- | Remember column layout | — | `storage="orders-grid"` (localStorage key) |
72
- | Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
48
+ | The user wants… | Feature(s) | Props / column options |
49
+ | ------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
50
+ | Click a header to sort | `sortingFeature` | column `sortable: true`; `sort-mode="client"` (or handle `v-model:sort`) |
51
+ | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
52
+ | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
53
+ | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
54
+ | 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` |
55
+ | Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
56
+ | An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
57
+ | 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
58
+ | Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
59
+ | Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'`; on narrow grids they scroll unless `pinned-max-share` allows (default half the width) |
60
+ | Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
61
+ | Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
62
+ | Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
63
+ | Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
64
+ | Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
65
+ | A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
66
+ | Group server data across all rows (not the page) | `serverGroupingFeature` (+ `rowGroupingFeature`, `serverDataFeature`) | return `{ groups: [{ value, count, aggregates }], total }` for `query.groupBy` / `query.groupPath`, `{ rows }` at the last level; `v-model:selected-groups` |
67
+ | 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 |
68
+ | Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
69
+ | Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
70
+ | Translate / reword the grid, drop built-in pieces | — | `messages` (`GridMessages`), `parts` (`GridParts`): app-wide in `createVueGrid` or per grid; slots `#load-error`, `#no-match`, `#select-all-banner` |
71
+ | Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
72
+ | Remember column layout | — | `storage="orders-grid"` (localStorage key) |
73
+ | Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
73
74
 
74
75
  ## Renderers (pick by data)
75
76
 
@@ -518,6 +519,8 @@ only sees stylesheet rules. Density:
518
519
  - Printing the page (Ctrl+P) shows only the rows on screen, clipped to the grid → use `grid.print()`.
519
520
  - Translating by replacing components or CSS `content` → set `messages` (every built-in text has a key).
520
521
  - Hiding a built-in piece with CSS → `parts: { filterButtons: false, … }` leaves it out of the DOM (and the tab order).
522
+ - Grouped server data shows groups of one page only → add `serverGroupingFeature` and answer `query.groupBy` with `{ groups }` (`count` per group, `total` = number of groups).
523
+ - A batch action on a selected server group touched only loaded rows → act on `selectedGroups` (paths) with the filters on the server.
521
524
  - Copied numbers come out as `€1,234.50` → copying uses displayed values; pass `{ values: 'raw' }`
522
525
  (CSV exports are raw by default).
523
526
  - `group-by` names a field, not a column → it takes column `key`s; add a (hidden) column for it.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0 — 2026-11-24
4
+
5
+ **Server-side row grouping** (`serverGroupingFeature`, with `rowGroupingFeature` and
6
+ `serverDataFeature`): a grouped grid with a `data-source` asks the server for groups instead of
7
+ grouping only the rows it has loaded. The query gains `groupBy` and `groupPath`; the source
8
+ answers with `groups: [{ value, count, aggregates }]` (or `rows` at the last level). Only the
9
+ top-level groups load first; expanding a group loads its sub-groups or rows, once, with the
10
+ loading row and error / Retry of lazy sub-grids. `pagination` pages the top-level groups;
11
+ `rowTotal` feeds the status bar. A group's checkbox selects it by query, without loading its
12
+ rows (`v-model:selected-groups`, paths like `[[{ key: 'status', value: 'Won' }]]`); rows inside
13
+ show ticked and locked, the header checkbox selects every top-level group, and the selected groups
14
+ end with a new filter or grouping. Exports cover the loaded rows. Works with virtual scrolling and
15
+ keyboard navigation. New exported types `GroupPath`, `ServerGroup`; group rows gain `count` and
16
+ `path`; `DataSourceResult` gains `groups` and `rowTotal` (`rows` is optional). Without the
17
+ feature, grouped server grids work as before, with a dev hint. Grids without it grow by 0.3 kB
18
+ gzip (the `selected-groups` model and the grouped query), grids with row grouping by 0.6 kB more.
19
+
20
+ Docs: the bundle sizes are measured again. 0.7.0's table was not updated for its own changes:
21
+ a plain grid was 14.5 kB gzip there, not 14.1 (now 14.8).
22
+
3
23
  ## 0.7.0 — 2026-11-24
4
24
 
5
25
  **Text and parts are configurable.** `messages` (`GridMessages`) replaces any built-in text: menus,
package/README.md CHANGED
@@ -132,6 +132,7 @@ an opt-in feature:
132
132
  | `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 |
133
133
  | `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
134
134
  | `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 |
135
+ | `serverGroupingFeature` | With a `data-source`: groups from the server (`query.groupBy` / `groupPath`), each one's contents loaded on expand, groups selected by query (`v-model:selected-groups`). See [Server-side grouping](#server-side-grouping) |
135
136
  | `exportFeature` | `exportCsv()` / `getCsv()`, `exportXlsx()` / `getXlsx()` (Excel, typed cells), `print()` (every row, header on each page), `copyRows()`, Ctrl/⌘+C for the selected rows or the focused cell, the `copy` event; column `exportValue` / `exportable` |
136
137
  | `statusBarFeature` | `status-bar`: a bar under the grid with the rows that pass the filters, the selected rows, the active filters (with Clear), and `{ summary: [keys] }` columns' sum and average over the selected rows; the `#status-bar` slot |
137
138
 
@@ -177,33 +178,34 @@ what you import.
177
178
 
178
179
  | Import (minified / gzip, Vue excluded) | Initial chunk |
179
180
  | ---------------------------------------------------------------------------- | ------------------ |
180
- | `VGrid` (no features) | 40.5 kB / 14.1 kB |
181
- | `VGrid` + `sortingFeature` | 41.2 kB / 14.4 kB |
182
- | `VGrid` + `filteringFeature` | 51.1 kB / 17.8 kB |
183
- | `VGrid` + `serverDataFeature` | 41.8 kB / 14.7 kB |
184
- | `VGrid` + `paginationFeature` | 40.6 kB / 14.1 kB |
185
- | `VGrid` + `selectionFeature` | 44.6 kB / 15.5 kB |
186
- | `VGrid` + `subGridsFeature` | 42.8 kB / 14.9 kB |
187
- | `VGrid` + `menusFeature` | 50.9 kB / 17.6 kB |
188
- | `VGrid` + `columnReorderFeature` | 44.2 kB / 15.3 kB |
189
- | `VGrid` + `columnPinningFeature` | 43.4 kB / 15.1 kB |
190
- | `VGrid` + `virtualScrollingFeature` | 46.2 kB / 16.3 kB |
191
- | `VGrid` + `columnVisibilityFeature` | 40.6 kB / 14.1 kB |
192
- | `VGrid` + `keyboardNavigationFeature` | 43.2 kB / 15.1 kB |
193
- | `VGrid` + `columnResizingFeature` | 43.7 kB / 15.3 kB |
194
- | `VGrid` + `columnGroupsFeature` | 41.8 kB / 14.5 kB |
195
- | `VGrid` + `rowPinningFeature` | 45.4 kB / 15.4 kB |
196
- | `VGrid` + `aggregationFeature` | 45.6 kB / 15.5 kB |
197
- | `VGrid` + `rowGroupingFeature` | 50.2 kB / 16.9 kB |
198
- | `VGrid` + `exportFeature` | 45.4 kB / 16.0 kB |
199
- | `VGrid` + `statusBarFeature` | 42.8 kB / 15.0 kB |
200
- | `VGrid` + `allFeatures` + `VGridSearch` | 108.1 kB / 36.5 kB |
201
- | `VGrid` + `currencyRenderer` | 41.9 kB / 14.5 kB |
202
- | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 47.2 kB / 16.3 kB |
181
+ | `VGrid` (no features) | 43.1 kB / 14.8 kB |
182
+ | `VGrid` + `sortingFeature` | 43.8 kB / 15.1 kB |
183
+ | `VGrid` + `filteringFeature` | 53.8 kB / 18.6 kB |
184
+ | `VGrid` + `serverDataFeature` | 44.5 kB / 15.4 kB |
185
+ | `VGrid` + `paginationFeature` | 43.2 kB / 14.8 kB |
186
+ | `VGrid` + `selectionFeature` | 47.2 kB / 16.2 kB |
187
+ | `VGrid` + `subGridsFeature` | 45.4 kB / 15.6 kB |
188
+ | `VGrid` + `menusFeature` | 53.9 kB / 18.4 kB |
189
+ | `VGrid` + `columnReorderFeature` | 46.7 kB / 16.0 kB |
190
+ | `VGrid` + `columnPinningFeature` | 46.0 kB / 15.8 kB |
191
+ | `VGrid` + `virtualScrollingFeature` | 48.8 kB / 17.0 kB |
192
+ | `VGrid` + `columnVisibilityFeature` | 43.2 kB / 14.8 kB |
193
+ | `VGrid` + `keyboardNavigationFeature` | 45.8 kB / 15.8 kB |
194
+ | `VGrid` + `columnResizingFeature` | 46.3 kB / 16.0 kB |
195
+ | `VGrid` + `columnGroupsFeature` | 44.4 kB / 15.2 kB |
196
+ | `VGrid` + `rowPinningFeature` | 48.0 kB / 16.1 kB |
197
+ | `VGrid` + `aggregationFeature` | 48.2 kB / 16.2 kB |
198
+ | `VGrid` + `rowGroupingFeature` | 53.8 kB / 18.3 kB |
199
+ | `VGrid` + `exportFeature` | 48.0 kB / 16.7 kB |
200
+ | `VGrid` + `statusBarFeature` | 45.5 kB / 15.7 kB |
201
+ | `VGrid` + `serverGroupingFeature` | 46.2 kB / 15.9 kB |
202
+ | `VGrid` + `allFeatures` + `VGridSearch` | 115.0 kB / 38.6 kB |
203
+ | `VGrid` + `currencyRenderer` | 44.4 kB / 15.2 kB |
204
+ | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 50.3 kB / 17.2 kB |
203
205
  | `sortRows` only | 0.7 kB / 0.4 kB |
204
206
  | `toCsv` only | 1.1 kB / 0.6 kB |
205
- | everything | 160.7 kB / 51.5 kB |
206
- | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 70.5 kB / 19.2 kB |
207
+ | everything | 168.7 kB / 54.0 kB |
208
+ | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 72.9 kB / 19.8 kB |
207
209
 
208
210
  With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
209
211
  chunks**: they load the first time a popover opens or `filter-row` is on. With
@@ -258,6 +260,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
258
260
  | `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
259
261
  | `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). |
260
262
  | `groupsExpanded` | `boolean` | `false` | Groups start expanded. |
263
+ | `v-model:selectedGroups` | `GroupPath[]` | `[]` | Server-side grouping: groups selected by query, by path (`[[{ key, value }]]`), without their rows. |
261
264
  | `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
262
265
  | `rowClass` | `(row, index) => ClassValue` | — | |
263
266
  | `highlightedRows` | `RowKey[]` | — | |
@@ -868,6 +871,62 @@ Style group rows with `.vg-rowgroup` (and `[data-group-level]`), `.vg-rowgroup-n
868
871
  `--vg-rowgroup-font-weight` tokens. `groupRows()` and `isRowGroup()` are exported for using the
869
872
  same grouping elsewhere.
870
873
 
874
+ ### Server-side grouping
875
+
876
+ With a `data-source`, `serverGroupingFeature` groups across all the data on the server instead of
877
+ only the rows the grid has loaded. The query then carries `groupBy` and `groupPath`, and your source
878
+ answers with **groups** instead of rows:
879
+
880
+ ```ts
881
+ const source: DataSource<Bet> = async (query, { signal }) => {
882
+ const res = await fetch('/api/bets/search', {
883
+ method: 'POST',
884
+ body: JSON.stringify(query),
885
+ signal,
886
+ })
887
+ return res.json()
888
+ }
889
+ // query.groupBy = ['status', 'city'], query.groupPath = [] → the top-level groups
890
+ // { groups: [{ value: 'Won', count: 1204, aggregates: { stake: 98211.5 } }, …], total: 4 }
891
+ // query.groupPath = [{ key: 'status', value: 'Won' }] → the groups inside "Won"
892
+ // { groups: [{ value: 'Niš', count: 310, aggregates: { … } }, …] }
893
+ // query.groupPath = [{ key: 'status', value: 'Won' }, { key: 'city', value: 'Niš' }]
894
+ // → the last level: { rows: [ …310 rows… ] }
895
+ ```
896
+
897
+ ```vue
898
+ <VGrid
899
+ v-model:group-by="groupBy"
900
+ v-model:selected="selected"
901
+ v-model:selected-groups="selectedGroups"
902
+ :data-source="source"
903
+ :columns="columns"
904
+ row-key="id"
905
+ selectable
906
+ :features="[serverDataFeature, rowGroupingFeature, serverGroupingFeature, selectionFeature]"
907
+ />
908
+ ```
909
+
910
+ - **Lazy.** The first request returns only the top-level groups (`value`, `count`, `aggregates`).
911
+ Expanding a group asks for its sub-groups, or at the last level all its rows; a level loads
912
+ once, with a loading row meanwhile and the error and Retry of lazy sub-grids when it fails
913
+ (`load-error` fires). Requests for a group carry the current sort and filters, `page: 1`,
914
+ `pageSize: null`.
915
+ - **Paging.** `pagination` pages the top-level groups: return their number as `total`. Return
916
+ `rowTotal` (every matching row) for the status bar; without it the groups' counts are added up.
917
+ - **Sort, filters, page.** A new query asks for the top-level groups again; open groups load their
918
+ contents again.
919
+ - **Selection by query.** A group's checkbox selects it by its path in `v-model:selected-groups`
920
+ (`[[{ key: 'status', value: 'Won' }]]`), without loading its rows; rows and sub-groups inside a
921
+ selected group show ticked and locked. The header checkbox selects every top-level group. Act on
922
+ `selectedGroups` + `selected` + the filters on the server. The selected groups end when the
923
+ filters or the grouping change, or with `clearSelection()`; the status bar and the toolbar's
924
+ `selectedCount` add their counts.
925
+ - **Export, print, totals.** `exportCsv()`, `print()` and the others cover the rows that are loaded.
926
+ For the totals row pass `aggregates` (the server's totals).
927
+ - Without the feature, a grouped grid with a data source groups only the rows it has loaded (with
928
+ a dev warning). A source that returns `rows` to a grouped query gets the same.
929
+
871
930
  ## Export and copy
872
931
 
873
932
  `exportFeature` turns the grid's rows into CSV or an Excel workbook, prints them, and copies them to
package/agent/api.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@nocopypaste/vue-grid",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "component": "VGrid",
5
5
  "props": [
6
6
  {
@@ -386,6 +386,13 @@
386
386
  "default": "false",
387
387
  "description": "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.",
388
388
  "feature": "selection"
389
+ },
390
+ {
391
+ "name": "selectedGroups",
392
+ "type": "GroupPath[]",
393
+ "default": "[]",
394
+ "description": "Server data with row grouping: groups selected by query, by their paths, without loading their rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or the grouping change. Needs the selection and row grouping features.",
395
+ "feature": "serverGrouping"
389
396
  }
390
397
  ],
391
398
  "events": [
@@ -498,7 +505,7 @@
498
505
  },
499
506
  {
500
507
  "name": "toolbar",
501
- "scope": "{ 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 }",
508
+ "scope": "{ 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; selectedGroups: GroupPath[]; selectAllMatching: boolean; clearSelection: () => void }",
502
509
  "description": "Above the grid: put a search box, column menu, filter summary or batch actions here."
503
510
  }
504
511
  ],
@@ -1032,6 +1039,15 @@
1032
1039
  ],
1033
1040
  "columnOptions": []
1034
1041
  },
1042
+ {
1043
+ "id": "serverGrouping",
1044
+ "export": "serverGroupingFeature",
1045
+ "description": "Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without loading its rows. Needs the row grouping and server data features too. Without it, a grouped server grid groups only the rows it has loaded.",
1046
+ "props": [
1047
+ "selectedGroups"
1048
+ ],
1049
+ "columnOptions": []
1050
+ },
1035
1051
  {
1036
1052
  "id": "sorting",
1037
1053
  "export": "sortingFeature",
package/agent/api.md CHANGED
@@ -1,4 +1,4 @@
1
- # @nocopypaste/vue-grid 0.7.0 — API reference
1
+ # @nocopypaste/vue-grid 0.8.0 — API reference
2
2
 
3
3
  > Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
4
4
 
@@ -23,6 +23,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
23
23
  | `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` | |
24
24
  | `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` | |
25
25
  | `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` | |
26
+ | `serverGroupingFeature` | Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without loading its rows. Needs the row grouping and server data features too. Without it, a grouped server grid groups only the rows it has loaded. | `selectedGroups` | |
26
27
  | `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` |
27
28
  | `statusBarFeature` | A status bar under the grid (`status-bar`): how many rows pass the filters ("84 of 200 rows"), how many are selected, how many filters are on (with Clear), and with `{ summary: ['total'] }` the sum and average of those columns over the selected rows, as the cells show them. The `#status-bar` slot replaces its content. Its component loads on demand (own chunk). | `statusBar` | |
28
29
  | `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` | |
@@ -93,6 +94,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
93
94
  | `v-model:pinnedRows` | `PinnedRowsState \| null` | `null` | `rowPinningFeature` | Top-level rows pinned above / below the body, by key: `{ top, bottom }`. Needs the row pinning feature. |
94
95
  | `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. |
95
96
  | `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. |
97
+ | `v-model:selectedGroups` | `GroupPath[]` | `[]` | `serverGroupingFeature` | Server data with row grouping: groups selected by query, by their paths, without loading their rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or the grouping change. Needs the selection and row grouping features. |
96
98
 
97
99
  ## Events
98
100
 
@@ -124,7 +126,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
124
126
  | `status-bar` | `StatusBarScope` | The status bar's content (status bar feature): replaces the counts and the summary. |
125
127
  | `loading` | | Shown while loading with no rows yet. |
126
128
  | `sub-rows-loading` | `{ row: T }` | Shown while a row's lazy children load. |
127
- | `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. |
129
+ | `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; selectedGroups: GroupPath[]; selectAllMatching: boolean; clearSelection: () => void }` | Above the grid: put a search box, column menu, filter summary or batch actions here. |
128
130
 
129
131
  ## Exposed methods (`ref<VGridExposed>()`)
130
132
 
@@ -40,6 +40,7 @@
40
40
  "rowPinningFeature",
41
41
  "selectionFeature",
42
42
  "serverDataFeature",
43
+ "serverGroupingFeature",
43
44
  "sortingFeature",
44
45
  "statusBarFeature",
45
46
  "subGridsFeature",
@@ -432,6 +433,11 @@
432
433
  "selectAllMatching": {
433
434
  "type": "boolean",
434
435
  "description": "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."
436
+ },
437
+ "selectedGroups": {
438
+ "type": "array",
439
+ "items": {},
440
+ "description": "Server data with row grouping: groups selected by query, by their paths, without loading their rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or the grouping change. Needs the selection and row grouping features."
435
441
  }
436
442
  },
437
443
  "required": [
package/dist/agent/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/agent/api.json
2
- var e = "0.7.0", t = "VGrid", n = [
2
+ var e = "0.8.0", t = "VGrid", n = [
3
3
  {
4
4
  name: "rows",
5
5
  type: "readonly T[]",
@@ -382,6 +382,13 @@ var e = "0.7.0", t = "VGrid", n = [
382
382
  default: "false",
383
383
  description: "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.",
384
384
  feature: "selection"
385
+ },
386
+ {
387
+ name: "selectedGroups",
388
+ type: "GroupPath[]",
389
+ default: "[]",
390
+ description: "Server data with row grouping: groups selected by query, by their paths, without loading their rows (a group's checkbox). Act on these with `selected` and the filters. Ends when the filters or the grouping change. Needs the selection and row grouping features.",
391
+ feature: "serverGrouping"
385
392
  }
386
393
  ], i = [
387
394
  {
@@ -492,7 +499,7 @@ var e = "0.7.0", t = "VGrid", n = [
492
499
  },
493
500
  {
494
501
  name: "toolbar",
495
- scope: "{ 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 }",
502
+ scope: "{ 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; selectedGroups: GroupPath[]; selectAllMatching: boolean; clearSelection: () => void }",
496
503
  description: "Above the grid: put a search box, column menu, filter summary or batch actions here."
497
504
  }
498
505
  ], o = [
@@ -992,6 +999,13 @@ var e = "0.7.0", t = "VGrid", n = [
992
999
  props: ["dataSource"],
993
1000
  columnOptions: []
994
1001
  },
1002
+ {
1003
+ id: "serverGrouping",
1004
+ export: "serverGroupingFeature",
1005
+ description: "Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without loading its rows. Needs the row grouping and server data features too. Without it, a grouped server grid groups only the rows it has loaded.",
1006
+ props: ["selectedGroups"],
1007
+ columnOptions: []
1008
+ },
995
1009
  {
996
1010
  id: "sorting",
997
1011
  export: "sortingFeature",
@@ -30,6 +30,7 @@ var e = {
30
30
  aggregates: "aggregation",
31
31
  groupBy: "rowGrouping",
32
32
  groupsExpanded: "rowGrouping",
33
+ selectedGroups: "serverGrouping",
33
34
  statusBar: "statusBar"
34
35
  }, t = {
35
36
  sortable: "sorting",
@@ -1 +1 @@
1
- {"version":3,"file":"requirements.js","names":["propFeatures","columnFeatures","optOuts","featureExport","id"],"sources":["../../src/agent/requirements.ts"],"sourcesContent":["/**\n * Which feature each grid prop and column option needs (without it the option does nothing). The\n * one fact about the API the types don't carry: the agent API reference (`api.json`), the JSON\n * Schema and `validateGridConfig()` all read it from here.\n */\nexport type FeatureId =\n | 'sorting'\n | 'filtering'\n | 'serverData'\n | 'pagination'\n | 'selection'\n | 'subGrids'\n | 'menus'\n | 'columnReorder'\n | 'columnPinning'\n | 'virtualScrolling'\n | 'columnVisibility'\n | 'keyboardNavigation'\n | 'columnResizing'\n | 'columnGroups'\n | 'rowPinning'\n | 'aggregation'\n | 'rowGrouping'\n | 'export'\n | 'statusBar'\n\n/** Grid props (and `v-model`s) that need a feature. */\nexport const propFeatures: Readonly<Record<string, FeatureId>> = {\n dataSource: 'serverData',\n pagination: 'pagination',\n page: 'pagination',\n pageSize: 'pagination',\n selectable: 'selection',\n selected: 'selection',\n pruneSelection: 'selection',\n selectAllMatching: 'selection',\n selectionMode: 'selection',\n pinnedMaxShare: 'columnPinning',\n isRowSelectable: 'selection',\n subRows: 'subGrids',\n loadSubRows: 'subGrids',\n hasSubRows: 'subGrids',\n virtual: 'virtualScrolling',\n contextMenu: 'menus',\n headerMenu: 'menus',\n filters: 'filtering',\n filterMode: 'filtering',\n filterRow: 'filtering',\n filterStorage: 'filtering',\n noMatchText: 'filtering',\n pinnedRows: 'rowPinning',\n pinnedTopRows: 'rowPinning',\n pinnedBottomRows: 'rowPinning',\n totals: 'aggregation',\n totalsLabel: 'aggregation',\n aggregates: 'aggregation',\n groupBy: 'rowGrouping',\n groupsExpanded: 'rowGrouping',\n statusBar: 'statusBar',\n}\n\n/** Column options that need a feature. */\nexport const columnFeatures: Readonly<Record<string, FeatureId>> = {\n sortable: 'sorting',\n sortValue: 'sorting',\n sortFn: 'sorting',\n filterable: 'filtering',\n filter: 'filtering',\n filterValue: 'filtering',\n filterFn: 'filtering',\n filterComponent: 'filtering',\n searchable: 'filtering',\n pinned: 'columnPinning',\n pinnable: 'columnPinning',\n hidden: 'columnVisibility',\n hideable: 'columnVisibility',\n reorderable: 'columnReorder',\n resizable: 'columnResizing',\n maxWidth: 'columnResizing',\n group: 'columnGroups',\n aggregate: 'aggregation',\n groupable: 'rowGrouping',\n groupValue: 'rowGrouping',\n exportValue: 'export',\n exportable: 'export',\n}\n\n/**\n * Options whose default is \"on\" and that only opt *out*: setting them without the feature changes\n * nothing worth a warning (`pinnable: false` on a grid without pinning is fine).\n */\nexport const optOuts: ReadonlySet<string> = new Set([\n 'pinnable',\n 'hideable',\n 'reorderable',\n 'resizable',\n 'searchable',\n 'headerMenu',\n 'exportable',\n 'pinnedMaxShare',\n])\n\n/** The export name of a feature: `sorting` → `sortingFeature`. */\nexport const featureExport = (id: FeatureId) => `${id}Feature`\n"],"mappings":";AA2BA,IAAaA,IAAoD;CAC/D,YAAY;CACZ,YAAY;CACZ,MAAM;CACN,UAAU;CACV,YAAY;CACZ,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,SAAS;CACT,aAAa;CACb,YAAY;CACZ,SAAS;CACT,aAAa;CACb,YAAY;CACZ,SAAS;CACT,YAAY;CACZ,WAAW;CACX,eAAe;CACf,aAAa;CACb,YAAY;CACZ,eAAe;CACf,kBAAkB;CAClB,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,SAAS;CACT,gBAAgB;CAChB,WAAW;AACb,GAGaC,IAAsD;CACjE,UAAU;CACV,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,UAAU;CACV,iBAAiB;CACjB,YAAY;CACZ,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,UAAU;CACV,OAAO;CACP,WAAW;CACX,WAAW;CACX,YAAY;CACZ,aAAa;CACb,YAAY;AACd,GAMaC,oBAA+B,IAAI,IAAI;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGYC,KAAiB,MAAkB,GAAGC,EAAG"}
1
+ {"version":3,"file":"requirements.js","names":["propFeatures","columnFeatures","optOuts","featureExport","id"],"sources":["../../src/agent/requirements.ts"],"sourcesContent":["/**\n * Which feature each grid prop and column option needs (without it the option does nothing). The\n * one fact about the API the types don't carry: the agent API reference (`api.json`), the JSON\n * Schema and `validateGridConfig()` all read it from here.\n */\nexport type FeatureId =\n | 'sorting'\n | 'filtering'\n | 'serverData'\n | 'pagination'\n | 'selection'\n | 'subGrids'\n | 'menus'\n | 'columnReorder'\n | 'columnPinning'\n | 'virtualScrolling'\n | 'columnVisibility'\n | 'keyboardNavigation'\n | 'columnResizing'\n | 'columnGroups'\n | 'rowPinning'\n | 'aggregation'\n | 'rowGrouping'\n | 'export'\n | 'statusBar'\n | 'serverGrouping'\n\n/** Grid props (and `v-model`s) that need a feature. */\nexport const propFeatures: Readonly<Record<string, FeatureId>> = {\n dataSource: 'serverData',\n pagination: 'pagination',\n page: 'pagination',\n pageSize: 'pagination',\n selectable: 'selection',\n selected: 'selection',\n pruneSelection: 'selection',\n selectAllMatching: 'selection',\n selectionMode: 'selection',\n pinnedMaxShare: 'columnPinning',\n isRowSelectable: 'selection',\n subRows: 'subGrids',\n loadSubRows: 'subGrids',\n hasSubRows: 'subGrids',\n virtual: 'virtualScrolling',\n contextMenu: 'menus',\n headerMenu: 'menus',\n filters: 'filtering',\n filterMode: 'filtering',\n filterRow: 'filtering',\n filterStorage: 'filtering',\n noMatchText: 'filtering',\n pinnedRows: 'rowPinning',\n pinnedTopRows: 'rowPinning',\n pinnedBottomRows: 'rowPinning',\n totals: 'aggregation',\n totalsLabel: 'aggregation',\n aggregates: 'aggregation',\n groupBy: 'rowGrouping',\n groupsExpanded: 'rowGrouping',\n selectedGroups: 'serverGrouping',\n statusBar: 'statusBar',\n}\n\n/** Column options that need a feature. */\nexport const columnFeatures: Readonly<Record<string, FeatureId>> = {\n sortable: 'sorting',\n sortValue: 'sorting',\n sortFn: 'sorting',\n filterable: 'filtering',\n filter: 'filtering',\n filterValue: 'filtering',\n filterFn: 'filtering',\n filterComponent: 'filtering',\n searchable: 'filtering',\n pinned: 'columnPinning',\n pinnable: 'columnPinning',\n hidden: 'columnVisibility',\n hideable: 'columnVisibility',\n reorderable: 'columnReorder',\n resizable: 'columnResizing',\n maxWidth: 'columnResizing',\n group: 'columnGroups',\n aggregate: 'aggregation',\n groupable: 'rowGrouping',\n groupValue: 'rowGrouping',\n exportValue: 'export',\n exportable: 'export',\n}\n\n/**\n * Options whose default is \"on\" and that only opt *out*: setting them without the feature changes\n * nothing worth a warning (`pinnable: false` on a grid without pinning is fine).\n */\nexport const optOuts: ReadonlySet<string> = new Set([\n 'pinnable',\n 'hideable',\n 'reorderable',\n 'resizable',\n 'searchable',\n 'headerMenu',\n 'exportable',\n 'pinnedMaxShare',\n])\n\n/** The export name of a feature: `sorting` → `sortingFeature`. */\nexport const featureExport = (id: FeatureId) => `${id}Feature`\n"],"mappings":";AA4BA,IAAaA,IAAoD;CAC/D,YAAY;CACZ,YAAY;CACZ,MAAM;CACN,UAAU;CACV,YAAY;CACZ,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,SAAS;CACT,aAAa;CACb,YAAY;CACZ,SAAS;CACT,aAAa;CACb,YAAY;CACZ,SAAS;CACT,YAAY;CACZ,WAAW;CACX,eAAe;CACf,aAAa;CACb,YAAY;CACZ,eAAe;CACf,kBAAkB;CAClB,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,SAAS;CACT,gBAAgB;CAChB,gBAAgB;CAChB,WAAW;AACb,GAGaC,IAAsD;CACjE,UAAU;CACV,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,UAAU;CACV,iBAAiB;CACjB,YAAY;CACZ,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;CACX,UAAU;CACV,OAAO;CACP,WAAW;CACX,WAAW;CACX,YAAY;CACZ,aAAa;CACb,YAAY;AACd,GAMaC,oBAA+B,IAAI,IAAI;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGYC,KAAiB,MAAkB,GAAGC,EAAG"}