@nocopypaste/vue-grid 0.9.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 (46) hide show
  1. package/AGENTS.md +67 -33
  2. package/CHANGELOG.md +21 -0
  3. package/README.md +94 -26
  4. package/agent/api.json +67 -1
  5. package/agent/api.md +10 -1
  6. package/agent/grid-config.schema.json +16 -0
  7. package/dist/agent/api.js +65 -1
  8. package/dist/agent/requirements.js +7 -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 +102 -84
  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/composables/useEditing.js +202 -0
  20. package/dist/composables/useEditing.js.map +1 -0
  21. package/dist/core/value.js +18 -2
  22. package/dist/core/value.js.map +1 -1
  23. package/dist/core.css +1 -1
  24. package/dist/features/editing.js +12 -0
  25. package/dist/features/editing.js.map +1 -0
  26. package/dist/features/index.js +30 -28
  27. package/dist/features/index.js.map +1 -1
  28. package/dist/index.js +63 -62
  29. package/dist/internal/context.js.map +1 -1
  30. package/dist/internal/features.js.map +1 -1
  31. package/dist/theme.css +1 -1
  32. package/dist/types/agent/requirements.d.ts +1 -1
  33. package/dist/types/components/VGrid.vue.d.ts +10 -3
  34. package/dist/types/components/VGridCellEditor.vue.d.ts +11 -0
  35. package/dist/types/composables/useEditing.d.ts +73 -0
  36. package/dist/types/core/value.d.ts +6 -0
  37. package/dist/types/features/editing.d.ts +2 -0
  38. package/dist/types/features/index.d.ts +2 -1
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/internal/context.d.ts +4 -0
  41. package/dist/types/internal/features.d.ts +2 -1
  42. package/dist/types/types.d.ts +100 -1
  43. package/dist/vue-grid.css +1 -1
  44. package/llms-full.txt +171 -60
  45. package/llms.txt +1 -1
  46. package/package.json +1 -1
package/llms-full.txt CHANGED
@@ -33,45 +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
- | Sort by several columns ("city, then stake") | `sortingFeature` | `multi-sort`, `v-model:sorts="[{ key, dir }, …]"`; Shift-click adds a column; server: `query.sorts` |
52
- | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
53
- | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
54
- | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
55
- | 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` |
56
- | Nested child rows aligned to the parent's columns | `subGridsFeature` | `:sub-rows="(row) => row.children"` or `:load-sub-rows` + `:has-sub-rows` |
57
- | An expandable panel under a row | — | `#detail="{ row }"` slot (`row-expandable` to limit it) |
58
- | 10,000+ rows | `virtualScrollingFeature` | `:virtual="{ rowHeight: 40 }"` + bounded height |
59
- | Right-click menus (cells, headers) | `menusFeature` | `:context-menu="(ctx) => MenuItem[]"` + `@context-action`; header menu is on by default |
60
- | Freeze columns left / right | `columnPinningFeature` | column `pinned: 'left' \| 'right'`; on narrow grids they scroll unless `pinned-max-share` allows (default half the width) |
61
- | Show / hide columns | `columnVisibilityFeature` | column `hidden: true`; `<VGridColumnMenu>` in `#toolbar` |
62
- | Drag columns to reorder | `columnReorderFeature` | column `reorderable: false` to lock one |
63
- | Drag column edges to resize | `columnResizingFeature` | `minWidth` / `maxWidth`, `resizable: false` |
64
- | Grouped headers ("Q1" over three columns) | `columnGroupsFeature` | column `group: 'Q1'` |
65
- | Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
66
- | A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
67
- | 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` |
68
- | 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 |
69
- | Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
70
- | Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
71
- | 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` |
72
- | Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
73
- | Remember column layout | — | `storage="orders-grid"` (localStorage key) |
74
- | 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) |
75
80
 
76
81
  ## Renderers (pick by data)
77
82
 
@@ -454,6 +459,31 @@ function onAction(e: CellActionEvent<Order>) {
454
459
  </template>
455
460
  ```
456
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
+
457
487
  ### Editable checkbox (controlled)
458
488
 
459
489
  ```ts
@@ -502,6 +532,10 @@ only sees stylesheet rules. Density:
502
532
  ## Pitfalls
503
533
 
504
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.
505
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`.
506
540
  - Columns are squeezed / the page scrolls sideways → give `width`s (`minmax(8rem, 1fr)`); the grid
507
541
  scrolls horizontally inside itself when columns are wider than it.
@@ -533,7 +567,7 @@ only sees stylesheet rules. Density:
533
567
 
534
568
  ---
535
569
 
536
- # @nocopypaste/vue-grid 0.9.0 — API reference
570
+ # @nocopypaste/vue-grid 0.10.0 — API reference
537
571
 
538
572
  > Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
539
573
 
@@ -549,6 +583,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
549
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` |
550
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` |
551
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` |
552
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` |
553
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` |
554
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. | | |
@@ -575,6 +610,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
575
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. |
576
611
  | `pagination` | `boolean \| PaginationOptions` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
577
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. |
578
614
  | `messages` | `GridMessages` | | | Built-in text (translations, wording), over `createVueGrid({ messages })`. |
579
615
  | `parts` | `GridParts` | | | Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. |
580
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`. |
@@ -642,6 +678,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
642
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). |
643
679
  | `cell-click` | `[event: CellClickEvent<T>]` | A cell of a `clickable: true` column was clicked. |
644
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. |
645
682
  | `sub-rows-error` | `[event: { row: T; error: unknown }]` | `loadSubRows` rejected for a row. |
646
683
  | `context-action` | `[event: ContextActionEvent<T>]` | An item of the body-cell context menu was chosen. |
647
684
  | `header-action` | `[event: HeaderActionEvent<T>]` | A custom item of the header menu was chosen (built-in items act by themselves). |
@@ -688,6 +725,8 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
688
725
  | `exportXlsx` | `Promise<void>` | | Downloads the rows as an Excel file (`filename`, default `export.xlsx`). Export feature. |
689
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. |
690
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. |
691
730
 
692
731
  ## `ColumnDef<T>`
693
732
 
@@ -727,6 +766,10 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
727
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). |
728
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. |
729
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. |
730
773
  | `cellClass` | `ClassValue \| ((row: T) => ClassValue)` | | Extra classes for the column's body cells (or a function of the row). |
731
774
  | `headerClass` | `ClassValue` | | Extra classes for the column's header cell. |
732
775
 
@@ -1340,6 +1383,7 @@ an opt-in feature:
1340
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) |
1341
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` |
1342
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) |
1343
1387
 
1344
1388
  ```ts
1345
1389
  // per grid
@@ -1383,34 +1427,35 @@ what you import.
1383
1427
 
1384
1428
  | Import (minified / gzip, Vue excluded) | Initial chunk |
1385
1429
  | ---------------------------------------------------------------------------- | ------------------ |
1386
- | `VGrid` (no features) | 43.7 kB / 15.0 kB |
1387
- | `VGrid` + `sortingFeature` | 46.4 kB / 16.0 kB |
1388
- | `VGrid` + `filteringFeature` | 54.5 kB / 18.9 kB |
1389
- | `VGrid` + `serverDataFeature` | 45.2 kB / 15.6 kB |
1390
- | `VGrid` + `paginationFeature` | 43.9 kB / 15.1 kB |
1391
- | `VGrid` + `selectionFeature` | 47.9 kB / 16.5 kB |
1392
- | `VGrid` + `subGridsFeature` | 46.1 kB / 15.8 kB |
1393
- | `VGrid` + `menusFeature` | 55.0 kB / 18.8 kB |
1394
- | `VGrid` + `columnReorderFeature` | 47.4 kB / 16.3 kB |
1395
- | `VGrid` + `columnPinningFeature` | 46.7 kB / 16.1 kB |
1396
- | `VGrid` + `virtualScrollingFeature` | 49.5 kB / 17.2 kB |
1397
- | `VGrid` + `columnVisibilityFeature` | 43.9 kB / 15.1 kB |
1398
- | `VGrid` + `keyboardNavigationFeature` | 46.5 kB / 16.0 kB |
1399
- | `VGrid` + `columnResizingFeature` | 47.0 kB / 16.3 kB |
1400
- | `VGrid` + `columnGroupsFeature` | 45.0 kB / 15.5 kB |
1401
- | `VGrid` + `rowPinningFeature` | 48.7 kB / 16.3 kB |
1402
- | `VGrid` + `aggregationFeature` | 48.9 kB / 16.5 kB |
1403
- | `VGrid` + `rowGroupingFeature` | 54.6 kB / 18.6 kB |
1404
- | `VGrid` + `exportFeature` | 48.7 kB / 16.9 kB |
1405
- | `VGrid` + `statusBarFeature` | 46.2 kB / 16.0 kB |
1406
- | `VGrid` + `serverGroupingFeature` | 46.8 kB / 16.2 kB |
1407
- | `VGrid` + `allFeatures` + `VGridSearch` | 118.3 kB / 39.8 kB |
1408
- | `VGrid` + `currencyRenderer` | 45.1 kB / 15.5 kB |
1409
- | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 51.0 kB / 17.5 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 |
1410
1455
  | `sortRows` only | 0.7 kB / 0.4 kB |
1411
1456
  | `toCsv` only | 1.1 kB / 0.6 kB |
1412
- | everything | 171.9 kB / 55.2 kB |
1413
- | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 73.4 kB / 20.0 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 |
1414
1459
 
1415
1460
  With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
1416
1461
  chunks**: they load the first time a popover opens or `filter-row` is on. With
@@ -1479,6 +1524,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1479
1524
  | `emptyText` | `string` | `messages.empty` | Shown when there are no rows (`No data to show.`). |
1480
1525
  | `ariaLabel` | `string` | — | |
1481
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). |
1482
1528
  | `messages` | `GridMessages` | — | Built-in text (translations, wording), over `createVueGrid({ messages })`. See [Text and parts](#text-and-parts). |
1483
1529
  | `parts` | `GridParts` | — | Built-in parts to leave out (`{ filterButtons: false }`), over `createVueGrid({ parts })`. |
1484
1530
  | `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
@@ -1492,6 +1538,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1492
1538
  `query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
1493
1539
  `copy({ kind, text, rows, columns })` (rows or a cell were copied: `exportFeature`) ·
1494
1540
  `load-error(error)` (a `dataSource` call failed) ·
1541
+ `cell-edit({ row, rowKey, column, value, oldValue })` (an edited cell: `editingFeature`; update your data) ·
1495
1542
  plus the `update:*` events of every `v-model`.
1496
1543
 
1497
1544
  Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
@@ -1518,6 +1565,7 @@ grid.value?.clearSelection() // selectionFeature: clears the selection, "all mat
1518
1565
  grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
1519
1566
  grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
1520
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
1521
1569
  ```
1522
1570
 
1523
1571
  `reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
@@ -1582,6 +1630,10 @@ animate on the compositor (GPU): a busy live feed costs the main thread about a
1582
1630
  groupValue?: (row) => unknown // what rows are grouped by (default: the cell value), e.g. the month of a date
1583
1631
  exportValue?: (row) => unknown // what CSV exports and copying use (exportFeature), e.g. an id instead of a link
1584
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
1585
1637
  cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
1586
1638
  }
1587
1639
  ```
@@ -2276,6 +2328,65 @@ await grid.value?.print({ title: 'Orders', totals: true, landscape: true })
2276
2328
  (a heading, also the document title) and `landscape`.
2277
2329
  - It resolves when printing is over. The printing code (1.1 kB gzip) loads on first use.
2278
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
+
2279
2390
  ## Status bar
2280
2391
 
2281
2392
  `statusBarFeature` adds a bar under the grid, like a spreadsheet's:
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 (15.0 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.9.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",