@nocopypaste/vue-grid 0.8.0 → 0.10.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 (74) hide show
  1. package/AGENTS.md +68 -32
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +140 -29
  4. package/agent/api.json +85 -2
  5. package/agent/api.md +13 -2
  6. package/agent/grid-config.schema.json +41 -0
  7. package/dist/agent/api.js +80 -2
  8. package/dist/agent/requirements.js +9 -2
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/base.css +1 -1
  11. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +595 -576
  12. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +78 -56
  14. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/VGridCellEditor.js +6 -0
  16. package/dist/components/VGridCellEditor.js.map +1 -0
  17. package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js +208 -0
  18. package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js.map +1 -0
  19. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +82 -53
  20. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/VGridSortMarker.js +6 -0
  22. package/dist/components/VGridSortMarker.js.map +1 -0
  23. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js +21 -0
  24. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  25. package/dist/composables/useDataSource.js.map +1 -1
  26. package/dist/composables/useEditing.js +202 -0
  27. package/dist/composables/useEditing.js.map +1 -0
  28. package/dist/composables/useGridKeyboard.js +5 -1
  29. package/dist/composables/useGridKeyboard.js.map +1 -1
  30. package/dist/composables/useGridMenus.js +24 -12
  31. package/dist/composables/useGridMenus.js.map +1 -1
  32. package/dist/composables/useRowGrouping.js.map +1 -1
  33. package/dist/composables/useSorting.js +48 -0
  34. package/dist/composables/useSorting.js.map +1 -0
  35. package/dist/core/grouping.js +1 -1
  36. package/dist/core/grouping.js.map +1 -1
  37. package/dist/core/sort.js +31 -1
  38. package/dist/core/sort.js.map +1 -1
  39. package/dist/core/value.js +18 -2
  40. package/dist/core/value.js.map +1 -1
  41. package/dist/core.css +1 -1
  42. package/dist/features/editing.js +12 -0
  43. package/dist/features/editing.js.map +1 -0
  44. package/dist/features/index.js +30 -28
  45. package/dist/features/index.js.map +1 -1
  46. package/dist/features/sorting.js +8 -4
  47. package/dist/features/sorting.js.map +1 -1
  48. package/dist/index.js +63 -62
  49. package/dist/internal/context.js.map +1 -1
  50. package/dist/internal/features.js.map +1 -1
  51. package/dist/theme.css +1 -1
  52. package/dist/types/agent/requirements.d.ts +1 -1
  53. package/dist/types/components/VGrid.vue.d.ts +20 -4
  54. package/dist/types/components/VGridCellEditor.vue.d.ts +11 -0
  55. package/dist/types/components/VGridHeader.vue.d.ts +4 -3
  56. package/dist/types/components/VGridSortMarker.vue.d.ts +9 -0
  57. package/dist/types/composables/useDataSource.d.ts +3 -0
  58. package/dist/types/composables/useEditing.d.ts +73 -0
  59. package/dist/types/composables/useGridMenus.d.ts +5 -0
  60. package/dist/types/composables/useRowGrouping.d.ts +2 -1
  61. package/dist/types/composables/useSorting.d.ts +24 -0
  62. package/dist/types/core/grouping.d.ts +5 -2
  63. package/dist/types/core/sort.d.ts +16 -0
  64. package/dist/types/core/value.d.ts +6 -0
  65. package/dist/types/features/editing.d.ts +2 -0
  66. package/dist/types/features/index.d.ts +2 -1
  67. package/dist/types/index.d.ts +2 -2
  68. package/dist/types/internal/context.d.ts +6 -0
  69. package/dist/types/internal/features.d.ts +2 -1
  70. package/dist/types/types.d.ts +112 -1
  71. package/dist/vue-grid.css +1 -1
  72. package/llms-full.txt +221 -63
  73. package/llms.txt +1 -1
  74. package/package.json +1 -1
package/llms-full.txt CHANGED
@@ -33,44 +33,50 @@ runs in the [live examples](https://eboye.github.io/eboye-vue-grid/), each with
33
33
  row that height, px) and a bounded height. `pagination` is ignored while `virtual` is on.
34
34
  8. **Rows are never mutated** by the grid. To change a cell: assign the field on a reactive row, or
35
35
  replace rows (`patchRows(rows, patches, rowKey)` keeps unchanged rows' identity).
36
- 9. **Editable renderers are controlled** (`checkbox`, `switch`, `radio`, `icon-toggle`, `edit`,
37
- buttons, menus): they emit `@cell-action="{ name, payload, row, rowKey, column }"`; your handler
38
- updates the data.
39
- 10. **Type columns** with `const col = createColumnHelper<Row>()` → `col({ ... })`: `rendererOptions`
36
+ 9. **Inline editing is controlled too** (`editingFeature`, `editable` columns): the grid emits
37
+ `@cell-edit="{ row, rowKey, column, value, oldValue }"` and never writes the value; store it
38
+ (`setCellValue(e.row, e.column, e.value)` on reactive rows), or do it in `:save-cell` (may return a
39
+ Promise; a rejection keeps the editor open with the message).
40
+ 10. **Editable renderers are controlled** (`checkbox`, `switch`, `radio`, `icon-toggle`, `edit`,
41
+ buttons, menus): they emit `@cell-action="{ name, payload, row, rowKey, column }"`; your handler
42
+ updates the data.
43
+ 11. **Type columns** with `const col = createColumnHelper<Row>()` → `col({ ... })`: `rendererOptions`
40
44
  are then checked against the chosen renderer.
41
- 11. **Server data** (`:data-source` + `serverDataFeature`): don't also pass `rows`; pass the
45
+ 12. **Server data** (`:data-source` + `serverDataFeature`): don't also pass `rows`; pass the
42
46
  `signal` to `fetch`; return `{ rows, total }` (`total` drives the pager).
43
- 12. Width is any CSS grid track as a **string**: `'8rem'`, `'1fr'`, `'minmax(10rem, 2fr)'`,
47
+ 13. Width is any CSS grid track as a **string**: `'8rem'`, `'1fr'`, `'minmax(10rem, 2fr)'`,
44
48
  `'min-content'` (default `auto`). Numbers are not accepted.
45
49
 
46
50
  ## Which feature for what
47
51
 
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) |
52
+ | The user wants… | Feature(s) | Props / column options |
53
+ | ------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
+ | Click a header to sort | `sortingFeature` | column `sortable: true`; `sort-mode="client"` (or handle `v-model:sort`) |
55
+ | Sort by several columns ("city, then stake") | `sortingFeature` | `multi-sort`, `v-model:sorts="[{ key, dir }, …]"`; Shift-click adds a column; server: `query.sorts` |
56
+ | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
57
+ | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
58
+ | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
59
+ | 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` |
60
+ | Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
61
+ | An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
62
+ | 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
63
+ | Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
64
+ | Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'`; on narrow grids they scroll unless `pinned-max-share` allows (default half the width) |
65
+ | Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
66
+ | Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
67
+ | Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
68
+ | Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
69
+ | Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
70
+ | A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
71
+ | 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` |
72
+ | 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 |
73
+ | Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
74
+ | Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
75
+ | Edit cells in place (spreadsheet-like) | `editingFeature` (+ `keyboardNavigationFeature` for typing / Enter) | column `editable: true \| (row) => boolean`, `editor`, `editorOptions`, `validate`; `@cell-edit` (store `value`: `setCellValue(e.row, e.column, e.value)`), `:save-cell` (async, rejection = error) |
76
+ | 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` |
77
+ | Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
78
+ | Remember column layout | — | `storage="orders-grid"` (localStorage key) |
79
+ | Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
74
80
 
75
81
  ## Renderers (pick by data)
76
82
 
@@ -453,6 +459,31 @@ function onAction(e: CellActionEvent<Order>) {
453
459
  </template>
454
460
  ```
455
461
 
462
+ ### Inline editing
463
+
464
+ ```ts
465
+ import { editingFeature, keyboardNavigationFeature, setCellValue } from '@nocopypaste/vue-grid'
466
+ const rows = reactive(bets) // the handler writes into them
467
+ const columns = [
468
+ col({
469
+ key: 'player',
470
+ field: 'player.name',
471
+ editable: true,
472
+ validate: (v) => (String(v).trim() ? undefined : 'Required'),
473
+ }),
474
+ col({ key: 'stake', renderer: currencyRenderer, editable: true, editorOptions: { min: 0 } }), // number
475
+ col({ key: 'status', renderer: statusRenderer, editable: (b) => b.status !== 'Void' }), // select
476
+ col({ key: 'verified', renderer: booleanRenderer, editable: true }), // flips at once
477
+ ]
478
+ // <VGrid :rows :columns row-key="id" :features="[editingFeature, keyboardNavigationFeature]"
479
+ // @cell-edit="(e) => setCellValue(e.row, e.column, e.value)" />
480
+ // async: :save-cell="async (e) => { await api.save(e); setCellValue(e.row, e.column, e.value) }"
481
+ ```
482
+
483
+ The editor comes from the renderer (number, date, datetime, select, checkbox, text) or `editor`
484
+ (a name or your component). Double-click / Enter / F2 / typing opens it; Enter saves, Tab moves to
485
+ the next editable cell, Esc cancels.
486
+
456
487
  ### Editable checkbox (controlled)
457
488
 
458
489
  ```ts
@@ -501,6 +532,11 @@ only sees stylesheet rules. Density:
501
532
  ## Pitfalls
502
533
 
503
534
  - Nothing sorts → `sort-mode="client"` missing (or `sortingFeature` missing).
535
+ - An edited cell snaps back to its old value → nothing stores it: handle `@cell-edit` (or
536
+ `save-cell`) and write `e.value` into reactive rows (`setCellValue`); the grid never does.
537
+ - Typing / Enter on a cell doesn't start editing → cells only take focus with
538
+ `keyboardNavigationFeature`; without it, double-click.
539
+ - Shift-click sorts by one column only → add `multi-sort`, and bind `v-model:sorts` (not `sort`) to read every key; a `dataSource` reads `query.sorts`.
504
540
  - Columns are squeezed / the page scrolls sideways → give `width`s (`minmax(8rem, 1fr)`); the grid
505
541
  scrolls horizontally inside itself when columns are wider than it.
506
542
  - Grid grows forever / no sticky header → no bounded height.
@@ -531,7 +567,7 @@ only sees stylesheet rules. Density:
531
567
 
532
568
  ---
533
569
 
534
- # @nocopypaste/vue-grid 0.8.0 — API reference
570
+ # @nocopypaste/vue-grid 0.10.0 — API reference
535
571
 
536
572
  > Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
537
573
 
@@ -547,6 +583,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
547
583
  | `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` |
548
584
  | `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` |
549
585
  | `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` |
586
+ | `editingFeature` | | `saveCell` | `editable` `editor` `editorOptions` `validate` |
550
587
  | `exportFeature` | CSV and Excel export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file, `grid.getCsv()` returns the text, `grid.exportXlsx()` / `grid.getXlsx()` write an Excel workbook with typed cells (the writer loads on demand), `grid.print()` prints every matching row as a table with the header on each page, `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` |
551
588
  | `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` |
552
589
  | `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. | | |
@@ -557,7 +594,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
557
594
  | `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` | |
558
595
  | `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` | |
559
596
  | `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` | |
560
- | `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` |
597
+ | `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. | `multiSort` `sorts` | `sortable` `sortValue` `sortFn` |
561
598
  | `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` | |
562
599
  | `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` | |
563
600
  | `virtualScrollingFeature` | Virtual scrolling: `:virtual="{ rowHeight, overscan?, detailHeight? }"` renders only the rows in view (plus `overscan`), so tens of thousands of rows stay fast — sub-grids and detail rows included, inside the same CSS grid / subgrid layout. Without it, `virtual` is ignored and every row renders. | `virtual` | |
@@ -573,6 +610,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
573
610
  | `dataSource` | `DataSource<T>` | | `serverDataFeature` | Server data: called with the current query (sort, filters, search, page) whenever it changes. The grid cancels superseded requests, shows loading and errors, and sorts / filters / pages nothing itself. |
574
611
  | `pagination` | `boolean \| PaginationOptions` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
575
612
  | `statusBar` | `boolean \| StatusBarOptions` | | `statusBarFeature` | A status bar under the grid (status bar feature): rows that pass the filters ("84 of 200 rows"), selected rows, active filters with Clear; `{ summary: ['total'] }` adds the sum and average of those columns over the selected rows. `#status-bar` replaces its content. |
613
+ | `saveCell` | `(event: CellEditEvent<T>) => unknown` | | `editingFeature` | Saves an edited cell (editing feature), after `cell-edit`: return a Promise and the cell shows it saving; a rejection keeps the editor open with the error's message. Without it, `cell-edit` alone carries the change. |
576
614
  | `messages` | `GridMessages` | | | Built-in text (translations, wording), over `createVueGrid({ messages })`. |
577
615
  | `parts` | `GridParts` | | | Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. |
578
616
  | `sortMode` | `'controlled' \| 'client'` | `'controlled'` | | `controlled` (default): a header click only updates `v-model:sort` (sort on the server or in your own code). `client`: the grid sorts the rows itself. Ignored with `dataSource`. |
@@ -612,12 +650,14 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
612
650
  | `totalsLabel` | `string` | | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). Default: `messages.total`, else `Total`. |
613
651
  | `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
614
652
  | `groupsExpanded` | `boolean` | `false` | `rowGroupingFeature` | Groups start expanded (row grouping feature). Default: collapsed. |
653
+ | `multiSort` | `boolean` | | `sortingFeature` | Multi-column sort (sorting feature): Shift-click (or Shift+Enter) on a header adds it as the next key, Shift-click again turns it descending, then removes it. `v-model:sorts` holds every key, `v-model:sort` the first; server queries get `sorts` too. |
615
654
 
616
655
  ## `v-model`s
617
656
 
618
657
  | Model | Type | Default | Needs | Description |
619
658
  |---|---|---|---|---|
620
659
  | `v-model:sort` | `SortState \| null` | `null` | | Sort state: a header click cycles asc → desc → none. Header UI needs the sorting feature. |
660
+ | `v-model:sorts` | `SortState[]` | `[]` | `sortingFeature` | Every sort key, the first one first (`multi-sort`). `sort` is the first of them. |
621
661
  | `v-model:columnState` | `ColumnState \| undefined` | `undefined` | | Column order, hidden columns, runtime pins and resized widths (persisted with `storage`). |
622
662
  | `v-model:expanded` | `RowKey[]` | `[]` | | Keys of expanded rows (sub-grids and detail rows). |
623
663
  | `v-model:selected` | `RowKey[]` | `[]` | `selectionFeature` | Keys of selected rows. Needs the selection feature. |
@@ -638,6 +678,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
638
678
  | `row-click` | `[row: T, event: MouseEvent \| KeyboardEvent]` | A row was clicked (not on a link, button or input inside it, nor a `clickable` column). |
639
679
  | `cell-click` | `[event: CellClickEvent<T>]` | A cell of a `clickable: true` column was clicked. |
640
680
  | `cell-action` | `[event: CellActionEvent<T>]` | A renderer emitted an action (buttons, toggles, menus, edit, copy). |
681
+ | `cell-edit` | `[event: CellEditEvent<T>]` | A cell was edited (editing feature): update your data with `value`. The grid doesn't. |
641
682
  | `sub-rows-error` | `[event: { row: T; error: unknown }]` | `loadSubRows` rejected for a row. |
642
683
  | `context-action` | `[event: ContextActionEvent<T>]` | An item of the body-cell context menu was chosen. |
643
684
  | `header-action` | `[event: HeaderActionEvent<T>]` | A custom item of the header menu was chosen (built-in items act by themselves). |
@@ -684,6 +725,8 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
684
725
  | `exportXlsx` | `Promise<void>` | | Downloads the rows as an Excel file (`filename`, default `export.xlsx`). Export feature. |
685
726
  | `print` | `Promise<void>` | | Prints the rows as a table (the browser's print dialog): the filtered, sorted rows on every page (not just those in view), as the cells show them, the header repeated on each printed page, numbers right-aligned, the totals in bold. Resolves when printing is over. Export feature. |
686
727
  | `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. |
728
+ | `startEdit` | `boolean` | | Opens the editor of a cell (editing feature), if the column is `editable` for that row and the row is on screen. Returns whether it opened. |
729
+ | `stopEdit` | `void` | | Closes the open editor: saves its value, or with `cancel` drops it. Editing feature. |
687
730
 
688
731
  ## `ColumnDef<T>`
689
732
 
@@ -723,6 +766,10 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
723
766
  | `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). |
724
767
  | `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. |
725
768
  | `exportable` | `boolean` | `exportFeature` | Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns. |
769
+ | `editable` | `boolean \| ((row: T) => boolean)` | `editingFeature` | Cells can be edited in place (editing feature): `true`, or per row. Double-click, Enter or F2 on a focused cell, or typing, opens the editor; the grid emits `cell-edit` and your handler updates the data (the grid never changes rows itself). |
770
+ | `editor` | `EditorName \| Component` | `editingFeature` | The editor (editing feature): `text`, `number`, `date`, `datetime`, `select`, `checkbox`, or your own component (`CellEditorProps`). Default from the renderer: numbers and money → number, dates → date, booleans → checkbox, status / chip → select, else text. |
771
+ | `editorOptions` | `EditorOptions` | `editingFeature` | Options of the editor: the choices of a select, a number's `min` / `max`, a `placeholder`. |
772
+ | `validate` | `(value: unknown, row: T) => string \| null \| undefined \| void` | `editingFeature` | Checks an edited value before it is saved (editing feature): return an error message to keep the editor open with it, or nothing to accept the value. |
726
773
  | `cellClass` | `ClassValue \| ((row: T) => ClassValue)` | | Extra classes for the column's body cells (or a function of the row). |
727
774
  | `headerClass` | `ClassValue` | | Extra classes for the column's header cell. |
728
775
 
@@ -1336,6 +1383,7 @@ an opt-in feature:
1336
1383
  | `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) |
1337
1384
  | `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` |
1338
1385
  | `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 |
1386
+ | `editingFeature` | `editable` columns: an editor in the cell (text, number, date, select, checkbox, or your own) on double-click, Enter / F2 or typing; `cell-edit`, and `save-cell` for async saves. See [Inline editing](#inline-editing) |
1339
1387
 
1340
1388
  ```ts
1341
1389
  // per grid
@@ -1379,34 +1427,35 @@ what you import.
1379
1427
 
1380
1428
  | Import (minified / gzip, Vue excluded) | Initial chunk |
1381
1429
  | ---------------------------------------------------------------------------- | ------------------ |
1382
- | `VGrid` (no features) | 43.1 kB / 14.8 kB |
1383
- | `VGrid` + `sortingFeature` | 43.8 kB / 15.1 kB |
1384
- | `VGrid` + `filteringFeature` | 53.8 kB / 18.6 kB |
1385
- | `VGrid` + `serverDataFeature` | 44.5 kB / 15.4 kB |
1386
- | `VGrid` + `paginationFeature` | 43.2 kB / 14.8 kB |
1387
- | `VGrid` + `selectionFeature` | 47.2 kB / 16.2 kB |
1388
- | `VGrid` + `subGridsFeature` | 45.4 kB / 15.6 kB |
1389
- | `VGrid` + `menusFeature` | 53.9 kB / 18.4 kB |
1390
- | `VGrid` + `columnReorderFeature` | 46.7 kB / 16.0 kB |
1391
- | `VGrid` + `columnPinningFeature` | 46.0 kB / 15.8 kB |
1392
- | `VGrid` + `virtualScrollingFeature` | 48.8 kB / 17.0 kB |
1393
- | `VGrid` + `columnVisibilityFeature` | 43.2 kB / 14.8 kB |
1394
- | `VGrid` + `keyboardNavigationFeature` | 45.8 kB / 15.8 kB |
1395
- | `VGrid` + `columnResizingFeature` | 46.3 kB / 16.0 kB |
1396
- | `VGrid` + `columnGroupsFeature` | 44.4 kB / 15.2 kB |
1397
- | `VGrid` + `rowPinningFeature` | 48.0 kB / 16.1 kB |
1398
- | `VGrid` + `aggregationFeature` | 48.2 kB / 16.2 kB |
1399
- | `VGrid` + `rowGroupingFeature` | 53.8 kB / 18.3 kB |
1400
- | `VGrid` + `exportFeature` | 48.0 kB / 16.7 kB |
1401
- | `VGrid` + `statusBarFeature` | 45.5 kB / 15.7 kB |
1402
- | `VGrid` + `serverGroupingFeature` | 46.2 kB / 15.9 kB |
1403
- | `VGrid` + `allFeatures` + `VGridSearch` | 115.0 kB / 38.6 kB |
1404
- | `VGrid` + `currencyRenderer` | 44.4 kB / 15.2 kB |
1405
- | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 50.3 kB / 17.2 kB |
1430
+ | `VGrid` (no features) | 44.5 kB / 15.3 kB |
1431
+ | `VGrid` + `sortingFeature` | 47.2 kB / 16.3 kB |
1432
+ | `VGrid` + `filteringFeature` | 55.2 kB / 19.1 kB |
1433
+ | `VGrid` + `serverDataFeature` | 45.9 kB / 15.9 kB |
1434
+ | `VGrid` + `paginationFeature` | 44.6 kB / 15.3 kB |
1435
+ | `VGrid` + `selectionFeature` | 48.6 kB / 16.7 kB |
1436
+ | `VGrid` + `subGridsFeature` | 46.8 kB / 16.1 kB |
1437
+ | `VGrid` + `menusFeature` | 55.7 kB / 19.1 kB |
1438
+ | `VGrid` + `columnReorderFeature` | 48.1 kB / 16.5 kB |
1439
+ | `VGrid` + `columnPinningFeature` | 47.4 kB / 16.3 kB |
1440
+ | `VGrid` + `virtualScrollingFeature` | 50.2 kB / 17.5 kB |
1441
+ | `VGrid` + `columnVisibilityFeature` | 44.6 kB / 15.3 kB |
1442
+ | `VGrid` + `keyboardNavigationFeature` | 47.2 kB / 16.3 kB |
1443
+ | `VGrid` + `columnResizingFeature` | 47.7 kB / 16.5 kB |
1444
+ | `VGrid` + `columnGroupsFeature` | 45.8 kB / 15.7 kB |
1445
+ | `VGrid` + `rowPinningFeature` | 49.4 kB / 16.6 kB |
1446
+ | `VGrid` + `aggregationFeature` | 49.6 kB / 16.7 kB |
1447
+ | `VGrid` + `rowGroupingFeature` | 55.3 kB / 18.8 kB |
1448
+ | `VGrid` + `exportFeature` | 49.4 kB / 17.2 kB |
1449
+ | `VGrid` + `statusBarFeature` | 46.9 kB / 16.2 kB |
1450
+ | `VGrid` + `serverGroupingFeature` | 47.6 kB / 16.4 kB |
1451
+ | `VGrid` + `editingFeature` | 48.8 kB / 17.0 kB |
1452
+ | `VGrid` + `allFeatures` + `VGridSearch` | 123.4 kB / 41.7 kB |
1453
+ | `VGrid` + `currencyRenderer` | 45.8 kB / 15.7 kB |
1454
+ | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 51.7 kB / 17.7 kB |
1406
1455
  | `sortRows` only | 0.7 kB / 0.4 kB |
1407
1456
  | `toCsv` only | 1.1 kB / 0.6 kB |
1408
- | everything | 168.7 kB / 54.0 kB |
1409
- | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 72.9 kB / 19.8 kB |
1457
+ | everything | 177.3 kB / 57.2 kB |
1458
+ | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 75.6 kB / 20.7 kB |
1410
1459
 
1411
1460
  With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
1412
1461
  chunks**: they load the first time a popover opens or `filter-row` is on. With
@@ -1431,6 +1480,8 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1431
1480
  | `columns` | `ColumnDef<T>[]` | — | See below. |
1432
1481
  | `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
1433
1482
  | `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
1483
+ | `multiSort` | `boolean` | `false` | Shift-click (Shift+Enter) a header to sort by it next; `v-model:sorts` holds every key. See [Sorting](#sorting). |
1484
+ | `v-model:sorts` | `SortState[]` | `[]` | Every sort key, the first one first (with `multiSort`). `sort` follows its first key. |
1434
1485
  | `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
1435
1486
  | `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
1436
1487
  | `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
@@ -1473,6 +1524,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1473
1524
  | `emptyText` | `string` | `messages.empty` | Shown when there are no rows (`No data to show.`). |
1474
1525
  | `ariaLabel` | `string` | — | |
1475
1526
  | `statusBar` | `boolean \| StatusBarOptions` | `false` | A status bar under the grid (status bar feature): counts, and `{ summary: [keys] }` sums of the selected rows. See [Status bar](#status-bar). |
1527
+ | `saveCell` | `(event: CellEditEvent) => unknown` | — | Saves an edited cell (editing feature): return a Promise and the cell shows it saving; a rejection keeps the editor open with its message. See [Inline editing](#inline-editing). |
1476
1528
  | `messages` | `GridMessages` | — | Built-in text (translations, wording), over `createVueGrid({ messages })`. See [Text and parts](#text-and-parts). |
1477
1529
  | `parts` | `GridParts` | — | Built-in parts to leave out (`{ filterButtons: false }`), over `createVueGrid({ parts })`. |
1478
1530
  | `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
@@ -1486,6 +1538,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1486
1538
  `query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
1487
1539
  `copy({ kind, text, rows, columns })` (rows or a cell were copied: `exportFeature`) ·
1488
1540
  `load-error(error)` (a `dataSource` call failed) ·
1541
+ `cell-edit({ row, rowKey, column, value, oldValue })` (an edited cell: `editingFeature`; update your data) ·
1489
1542
  plus the `update:*` events of every `v-model`.
1490
1543
 
1491
1544
  Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
@@ -1512,6 +1565,7 @@ grid.value?.clearSelection() // selectionFeature: clears the selection, "all mat
1512
1565
  grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
1513
1566
  grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
1514
1567
  grid.value?.exportCsv({ filename: 'orders.csv' }) / getCsv() / copyRows() // exportFeature, see Export and copy
1568
+ grid.value?.startEdit(42, 'stake') / stopEdit() // editingFeature: open a cell's editor; save (or stopEdit(true): drop) the open one
1515
1569
  ```
1516
1570
 
1517
1571
  `reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
@@ -1576,6 +1630,10 @@ animate on the compositor (GPU): a busy live feed costs the main thread about a
1576
1630
  groupValue?: (row) => unknown // what rows are grouped by (default: the cell value), e.g. the month of a date
1577
1631
  exportValue?: (row) => unknown // what CSV exports and copying use (exportFeature), e.g. an id instead of a link
1578
1632
  exportable?: boolean // in exports and copied rows (default true); false for action columns
1633
+ editable?: boolean | ((row) => boolean) // edit cells in place (editingFeature)
1634
+ editor?: 'text' | 'number' | 'date' | 'datetime' | 'select' | 'checkbox' | Component // default from the renderer
1635
+ editorOptions?: { options?, min?, max?, placeholder?, maxLength? } // a select's choices, a number's range…
1636
+ validate?: (value, row) => string | void // an error message keeps the editor open
1579
1637
  cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
1580
1638
  }
1581
1639
  ```
@@ -1703,7 +1761,7 @@ typeahead move through items; focus returns to the cell on close.
1703
1761
  ### Column headers
1704
1762
 
1705
1763
  Right-clicking a header opens a built-in menu: **Sort ascending / descending / Clear sort** (sortable
1706
- columns), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
1764
+ columns; with `multi-sort` also **Then sort ascending / descending**, and Clear sort drops only that column), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
1707
1765
  Pin items need `columnPinningFeature`, move items `columnReorderFeature`, Hide column `columnVisibilityFeature`. Runtime pins are stored in column state (`columnState.pinned`) and persisted with `storage`.
1708
1766
 
1709
1767
  ```vue
@@ -1730,6 +1788,47 @@ The same component powers the `actions-menu` renderer and is exported for add-on
1730
1788
  <!-- or imperatively: menuRef.value.openAt(element | { x, y }) -->
1731
1789
  ```
1732
1790
 
1791
+ ## Sorting
1792
+
1793
+ A `sortable` column (with `sortingFeature`) sorts on a header click: ascending, descending, none.
1794
+ `v-model:sort` holds `{ key, dir }`. The grid sorts the rows itself with `sort-mode="client"`;
1795
+ otherwise it only updates `sort` (or asks the `dataSource`). Values sort by type (numbers, dates,
1796
+ text with `localeCompare`), a renderer can define its sort value, and a column can override it with
1797
+ `sortValue: (row) => …` or `sortFn: (a, b) => …`. Empty values sort last in both directions.
1798
+
1799
+ **Several columns.** With `multi-sort`, Shift-click a header (Shift+Enter on a focused one) to sort
1800
+ by it after the others: ascending, then descending, then removed. A plain click still sorts by that
1801
+ column alone. The headers show each column's number (1, 2, …); `aria-sort` stays on the first key, as
1802
+ the ARIA grid pattern has it, and screen readers hear the rest as “sorted 2 of 3, descending”. The
1803
+ header menu adds **Then sort ascending / descending**.
1804
+
1805
+ ```vue
1806
+ <script setup lang="ts">
1807
+ import { VGrid, sortingFeature, type SortState } from '@nocopypaste/vue-grid'
1808
+ const sorts = ref<SortState[]>([
1809
+ { key: 'city', dir: 'asc' },
1810
+ { key: 'stake', dir: 'desc' },
1811
+ ])
1812
+ </script>
1813
+
1814
+ <template>
1815
+ <VGrid
1816
+ v-model:sorts="sorts"
1817
+ multi-sort
1818
+ sort-mode="client"
1819
+ :rows
1820
+ :columns
1821
+ row-key="id"
1822
+ :features="[sortingFeature]"
1823
+ />
1824
+ </template>
1825
+ ```
1826
+
1827
+ `v-model:sort` keeps working beside it: it is the first key, and setting it from outside makes it
1828
+ the only one. A `dataSource` gets every key in `query.sorts` (only with `multi-sort`; `query.sort`
1829
+ is still the first). Row groups follow their own column's key wherever it is in the list.
1830
+ `sortRowsBy(rows, keys)` and `nextSorts(sorts, key)` sort and cycle without a grid.
1831
+
1733
1832
  ## Filtering
1734
1833
 
1735
1834
  ```vue
@@ -1875,7 +1974,7 @@ import {
1875
1974
  } from '@nocopypaste/vue-grid'
1876
1975
 
1877
1976
  const fetchBets: DataSource<Bet> = async (query, { signal }) => {
1878
- // query: { sort: { key, dir } | null, filters: FilterState, page: number, pageSize: number | null }
1977
+ // query: { sort: { key, dir } | null, sorts?: SortState[] (multi-sort), filters: FilterState, page: number, pageSize: number | null }
1879
1978
  const res = await fetch('/api/bets', { method: 'POST', body: JSON.stringify(query), signal })
1880
1979
  if (!res.ok) throw new Error(res.statusText)
1881
1980
  return res.json() // { rows: Bet[], total?: number }
@@ -2229,6 +2328,65 @@ await grid.value?.print({ title: 'Orders', totals: true, landscape: true })
2229
2328
  (a heading, also the document title) and `landscape`.
2230
2329
  - It resolves when printing is over. The printing code (1.1 kB gzip) loads on first use.
2231
2330
 
2331
+ ## Inline editing
2332
+
2333
+ `editingFeature` edits cells in place. Mark columns `editable` (or `(row) => boolean`). A cell opens
2334
+ its editor on double-click, on Enter or F2 when focused, or when you start typing on it (the
2335
+ keys replace the value). **Enter** saves, **Tab** / **Shift+Tab** save and edit the next / previous
2336
+ editable cell, **Esc** cancels, and clicking elsewhere saves.
2337
+
2338
+ The editor follows the column's renderer: numbers and money → a number input, `date` → a date
2339
+ picker, `datetime` → date and time, `boolean` → it flips at once (no editor), `status` / `chip`
2340
+ → a select of the column's values, anything else → text. `editor` picks another, or your own
2341
+ component (`CellEditorProps`: `v-model`, emit `commit` / `cancel`; Enter, Tab and Esc work around it).
2342
+
2343
+ The grid never changes your rows: it emits `cell-edit` with the typed `value` (a number, a date
2344
+ string in the cell's own format, a select's value) and `oldValue`, and your handler stores it.
2345
+ `setCellValue(row, column, value)` writes along the column's `field` path.
2346
+
2347
+ ```vue
2348
+ <script setup lang="ts">
2349
+ import { VGrid, editingFeature, setCellValue, type CellEditEvent } from '@nocopypaste/vue-grid'
2350
+
2351
+ const rows = reactive(await loadBets())
2352
+ const columns = [
2353
+ col({
2354
+ key: 'player',
2355
+ field: 'player.name',
2356
+ editable: true,
2357
+ validate: (v) => (String(v).trim() ? undefined : 'A player needs a name.'),
2358
+ }),
2359
+ col({ key: 'stake', renderer: currencyRenderer, editable: true, editorOptions: { min: 0 } }),
2360
+ col({
2361
+ key: 'status',
2362
+ renderer: statusRenderer,
2363
+ editable: (bet) => bet.status !== 'Void',
2364
+ editorOptions: { options: ['Open', 'Won', 'Lost', 'Void'] },
2365
+ }),
2366
+ col({ key: 'verified', renderer: booleanRenderer, editable: true }),
2367
+ ]
2368
+
2369
+ // optional: an async save. The cell shows it saving; a rejection keeps the editor open with the message.
2370
+ async function saveCell(e: CellEditEvent<Bet>) {
2371
+ await api.patch(`/bets/${e.rowKey}`, { [e.column.key]: e.value }) // throws on a 4xx
2372
+ setCellValue(e.row, e.column, e.value)
2373
+ }
2374
+ </script>
2375
+
2376
+ <template>
2377
+ <VGrid :rows :columns row-key="id" :save-cell="saveCell" :features="[editingFeature]" />
2378
+ <!-- or without a save function: @cell-edit="(e) => setCellValue(e.row, e.column, e.value)" -->
2379
+ </template>
2380
+ ```
2381
+
2382
+ `validate` returns a message to keep the editor open with it (shown below the cell, and as the
2383
+ input's description for screen readers); a number outside `min` / `max` or not a number is refused
2384
+ the same way. One cell edits at a time. With `keyboardNavigationFeature` cells take focus, so typing
2385
+ and Enter / F2 work; without it, double-click. Pinned rows and group rows aren't editable. The
2386
+ editor's code loads on demand, while the browser is idle, once a grid has an editable column.
2387
+ `grid.startEdit(rowKey, columnKey)` opens an editor from code, `grid.stopEdit()` closes it. Its
2388
+ text (`Edit {column}`, `Enter a number.`, `Saving…`) is in `messages`.
2389
+
2232
2390
  ## Status bar
2233
2391
 
2234
2392
  `statusBarFeature` adds a bar under the grid, like a spreadsheet's:
@@ -2345,7 +2503,7 @@ and the grid's own controls (sort buttons, expanders, checkboxes, filter buttons
2345
2503
  normal Tab order.
2346
2504
 
2347
2505
  With `keyboardNavigationFeature` it is an ARIA `grid` (`treegrid` with sub-grids). The grid is one tab stop. Arrow keys move between cells (header, rows, sub-grid rows, detail rows),
2348
- `Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header or activates the
2506
+ `Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header (`Shift+Enter` adds it with `multi-sort`) or activates the
2349
2507
  cell's control; `Space` toggles row selection; `→`/`←` on a tree cell expands/collapses; `Alt+←/→` on a
2350
2508
  header moves the column; `Alt+Shift+←/→` on a header resizes it (with `columnResizingFeature`).
2351
2509
 
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 (14.8 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping (also on the server), CSV and Excel export, printing, copying, a status bar, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Every built-in text is translatable (`messages`) and every piece a feature adds can be turned off (`parts`). 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 (15.3 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping (also on the server), inline cell editing, CSV and Excel export, printing, copying, a status bar, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Every built-in text is translatable (`messages`) and every piece a feature adds can be turned off (`parts`). 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.8.0",
3
+ "version": "0.10.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",