@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.
- package/AGENTS.md +67 -33
- package/CHANGELOG.md +21 -0
- package/README.md +94 -26
- package/agent/api.json +67 -1
- package/agent/api.md +10 -1
- package/agent/grid-config.schema.json +16 -0
- package/dist/agent/api.js +65 -1
- package/dist/agent/requirements.js +7 -2
- package/dist/agent/requirements.js.map +1 -1
- package/dist/base.css +1 -1
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +102 -84
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +78 -56
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridCellEditor.js +6 -0
- package/dist/components/VGridCellEditor.js.map +1 -0
- package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js +208 -0
- package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/composables/useEditing.js +202 -0
- package/dist/composables/useEditing.js.map +1 -0
- package/dist/core/value.js +18 -2
- package/dist/core/value.js.map +1 -1
- package/dist/core.css +1 -1
- package/dist/features/editing.js +12 -0
- package/dist/features/editing.js.map +1 -0
- package/dist/features/index.js +30 -28
- package/dist/features/index.js.map +1 -1
- package/dist/index.js +63 -62
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/features.js.map +1 -1
- package/dist/theme.css +1 -1
- package/dist/types/agent/requirements.d.ts +1 -1
- package/dist/types/components/VGrid.vue.d.ts +10 -3
- package/dist/types/components/VGridCellEditor.vue.d.ts +11 -0
- package/dist/types/composables/useEditing.d.ts +73 -0
- package/dist/types/core/value.d.ts +6 -0
- package/dist/types/features/editing.d.ts +2 -0
- package/dist/types/features/index.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/context.d.ts +4 -0
- package/dist/types/internal/features.d.ts +2 -1
- package/dist/types/types.d.ts +100 -1
- package/dist/vue-grid.css +1 -1
- package/llms-full.txt +171 -60
- package/llms.txt +1 -1
- package/package.json +1 -1
package/AGENTS.md
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. **
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
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.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 — 2026-11-25
|
|
4
|
+
|
|
5
|
+
**Inline cell editing** (`editingFeature`, opt-in): mark columns `editable` (or `(row) => boolean`).
|
|
6
|
+
A cell opens its editor on double-click, on Enter or F2 when focused, or when you start typing on
|
|
7
|
+
it (the keys replace the value, even typed before the editor has loaded). Enter saves, Tab /
|
|
8
|
+
Shift+Tab save and edit the next / previous editable cell (a checkbox cell only takes focus), Esc
|
|
9
|
+
cancels, clicking elsewhere saves. The editor follows the renderer: number (money, numbers),
|
|
10
|
+
date, date and time, a select of the column's values (status, chip), a checkbox that flips at
|
|
11
|
+
once, else text; `editor` picks another or your own component (`CellEditorProps`), `editorOptions`
|
|
12
|
+
sets a select's choices, a number's `min` / `max`, a placeholder. `validate(value, row)` returns a
|
|
13
|
+
message to keep the editor open with it, shown below the cell (and as the input's description);
|
|
14
|
+
numbers are checked too. The grid emits `cell-edit({ row, rowKey, column, value, oldValue })` and
|
|
15
|
+
never writes the value; `save-cell` may return a Promise: the cell shows it saving, and a rejection
|
|
16
|
+
keeps the editor open with the error. The cell keeps its width while editing. `startEdit(rowKey,
|
|
17
|
+
columnKey)` / `stopEdit(cancel?)` from code. New exports: `editingFeature` (also in
|
|
18
|
+
`allFeatures`), `setCellValue(row, column, value)`, types `CellEditEvent`, `CellEditorProps`,
|
|
19
|
+
`EditorName`, `EditorOptions`, `EditorOption`; messages `editCell`, `editNotANumber`,
|
|
20
|
+
`editOutOfRange`, `editSaveFailed`, `editSaving`. The editor (3.0 kB gzip) loads on demand, while
|
|
21
|
+
the browser is idle, once a grid has an editable column. A plain grid grows by 0.3 kB gzip (to 15.3),
|
|
22
|
+
a grid with editing is 17.0 kB plus the editor's chunk.
|
|
23
|
+
|
|
3
24
|
## 0.9.0 — 2026-11-24
|
|
4
25
|
|
|
5
26
|
**Multi-column sort** (`sortingFeature`): with `multi-sort`, Shift-click a header (Shift+Enter on
|
package/README.md
CHANGED
|
@@ -135,6 +135,7 @@ an opt-in feature:
|
|
|
135
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) |
|
|
136
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` |
|
|
137
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 |
|
|
138
|
+
| `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) |
|
|
138
139
|
|
|
139
140
|
```ts
|
|
140
141
|
// per grid
|
|
@@ -178,34 +179,35 @@ what you import.
|
|
|
178
179
|
|
|
179
180
|
| Import (minified / gzip, Vue excluded) | Initial chunk |
|
|
180
181
|
| ---------------------------------------------------------------------------- | ------------------ |
|
|
181
|
-
| `VGrid` (no features) |
|
|
182
|
-
| `VGrid` + `sortingFeature` |
|
|
183
|
-
| `VGrid` + `filteringFeature` |
|
|
184
|
-
| `VGrid` + `serverDataFeature` | 45.
|
|
185
|
-
| `VGrid` + `paginationFeature` |
|
|
186
|
-
| `VGrid` + `selectionFeature` |
|
|
187
|
-
| `VGrid` + `subGridsFeature` | 46.
|
|
188
|
-
| `VGrid` + `menusFeature` | 55.
|
|
189
|
-
| `VGrid` + `columnReorderFeature` |
|
|
190
|
-
| `VGrid` + `columnPinningFeature` |
|
|
191
|
-
| `VGrid` + `virtualScrollingFeature` |
|
|
192
|
-
| `VGrid` + `columnVisibilityFeature` |
|
|
193
|
-
| `VGrid` + `keyboardNavigationFeature` |
|
|
194
|
-
| `VGrid` + `columnResizingFeature` | 47.
|
|
195
|
-
| `VGrid` + `columnGroupsFeature` | 45.
|
|
196
|
-
| `VGrid` + `rowPinningFeature` |
|
|
197
|
-
| `VGrid` + `aggregationFeature` |
|
|
198
|
-
| `VGrid` + `rowGroupingFeature` |
|
|
199
|
-
| `VGrid` + `exportFeature` |
|
|
200
|
-
| `VGrid` + `statusBarFeature` | 46.
|
|
201
|
-
| `VGrid` + `serverGroupingFeature` |
|
|
202
|
-
| `VGrid` + `
|
|
203
|
-
| `VGrid` + `
|
|
204
|
-
| `VGrid` + `
|
|
182
|
+
| `VGrid` (no features) | 44.5 kB / 15.3 kB |
|
|
183
|
+
| `VGrid` + `sortingFeature` | 47.2 kB / 16.3 kB |
|
|
184
|
+
| `VGrid` + `filteringFeature` | 55.2 kB / 19.1 kB |
|
|
185
|
+
| `VGrid` + `serverDataFeature` | 45.9 kB / 15.9 kB |
|
|
186
|
+
| `VGrid` + `paginationFeature` | 44.6 kB / 15.3 kB |
|
|
187
|
+
| `VGrid` + `selectionFeature` | 48.6 kB / 16.7 kB |
|
|
188
|
+
| `VGrid` + `subGridsFeature` | 46.8 kB / 16.1 kB |
|
|
189
|
+
| `VGrid` + `menusFeature` | 55.7 kB / 19.1 kB |
|
|
190
|
+
| `VGrid` + `columnReorderFeature` | 48.1 kB / 16.5 kB |
|
|
191
|
+
| `VGrid` + `columnPinningFeature` | 47.4 kB / 16.3 kB |
|
|
192
|
+
| `VGrid` + `virtualScrollingFeature` | 50.2 kB / 17.5 kB |
|
|
193
|
+
| `VGrid` + `columnVisibilityFeature` | 44.6 kB / 15.3 kB |
|
|
194
|
+
| `VGrid` + `keyboardNavigationFeature` | 47.2 kB / 16.3 kB |
|
|
195
|
+
| `VGrid` + `columnResizingFeature` | 47.7 kB / 16.5 kB |
|
|
196
|
+
| `VGrid` + `columnGroupsFeature` | 45.8 kB / 15.7 kB |
|
|
197
|
+
| `VGrid` + `rowPinningFeature` | 49.4 kB / 16.6 kB |
|
|
198
|
+
| `VGrid` + `aggregationFeature` | 49.6 kB / 16.7 kB |
|
|
199
|
+
| `VGrid` + `rowGroupingFeature` | 55.3 kB / 18.8 kB |
|
|
200
|
+
| `VGrid` + `exportFeature` | 49.4 kB / 17.2 kB |
|
|
201
|
+
| `VGrid` + `statusBarFeature` | 46.9 kB / 16.2 kB |
|
|
202
|
+
| `VGrid` + `serverGroupingFeature` | 47.6 kB / 16.4 kB |
|
|
203
|
+
| `VGrid` + `editingFeature` | 48.8 kB / 17.0 kB |
|
|
204
|
+
| `VGrid` + `allFeatures` + `VGridSearch` | 123.4 kB / 41.7 kB |
|
|
205
|
+
| `VGrid` + `currencyRenderer` | 45.8 kB / 15.7 kB |
|
|
206
|
+
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 51.7 kB / 17.7 kB |
|
|
205
207
|
| `sortRows` only | 0.7 kB / 0.4 kB |
|
|
206
208
|
| `toCsv` only | 1.1 kB / 0.6 kB |
|
|
207
|
-
| everything |
|
|
208
|
-
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) |
|
|
209
|
+
| everything | 177.3 kB / 57.2 kB |
|
|
210
|
+
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 75.6 kB / 20.7 kB |
|
|
209
211
|
|
|
210
212
|
With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
|
|
211
213
|
chunks**: they load the first time a popover opens or `filter-row` is on. With
|
|
@@ -274,6 +276,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
|
|
|
274
276
|
| `emptyText` | `string` | `messages.empty` | Shown when there are no rows (`No data to show.`). |
|
|
275
277
|
| `ariaLabel` | `string` | — | |
|
|
276
278
|
| `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). |
|
|
279
|
+
| `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). |
|
|
277
280
|
| `messages` | `GridMessages` | — | Built-in text (translations, wording), over `createVueGrid({ messages })`. See [Text and parts](#text-and-parts). |
|
|
278
281
|
| `parts` | `GridParts` | — | Built-in parts to leave out (`{ filterButtons: false }`), over `createVueGrid({ parts })`. |
|
|
279
282
|
| `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
|
|
@@ -287,6 +290,7 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
|
|
|
287
290
|
`query-change(query: GridQuery)` (sort + filters + page as one object, on mount and on every real change) ·
|
|
288
291
|
`copy({ kind, text, rows, columns })` (rows or a cell were copied: `exportFeature`) ·
|
|
289
292
|
`load-error(error)` (a `dataSource` call failed) ·
|
|
293
|
+
`cell-edit({ row, rowKey, column, value, oldValue })` (an edited cell: `editingFeature`; update your data) ·
|
|
290
294
|
plus the `update:*` events of every `v-model`.
|
|
291
295
|
|
|
292
296
|
Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
|
|
@@ -313,6 +317,7 @@ grid.value?.clearSelection() // selectionFeature: clears the selection, "all mat
|
|
|
313
317
|
grid.value?.reloadSubRows('c2') // forget lazily loaded children (of one row, or all): they load again
|
|
314
318
|
grid.value?.pinRow(42, 'top') // pin a row above the body ('bottom' below it, null to unpin): rowPinningFeature
|
|
315
319
|
grid.value?.exportCsv({ filename: 'orders.csv' }) / getCsv() / copyRows() // exportFeature, see Export and copy
|
|
320
|
+
grid.value?.startEdit(42, 'stake') / stopEdit() // editingFeature: open a cell's editor; save (or stopEdit(true): drop) the open one
|
|
316
321
|
```
|
|
317
322
|
|
|
318
323
|
`reload()` also forgets lazily loaded children, as does passing a different `load-sub-rows`
|
|
@@ -377,6 +382,10 @@ animate on the compositor (GPU): a busy live feed costs the main thread about a
|
|
|
377
382
|
groupValue?: (row) => unknown // what rows are grouped by (default: the cell value), e.g. the month of a date
|
|
378
383
|
exportValue?: (row) => unknown // what CSV exports and copying use (exportFeature), e.g. an id instead of a link
|
|
379
384
|
exportable?: boolean // in exports and copied rows (default true); false for action columns
|
|
385
|
+
editable?: boolean | ((row) => boolean) // edit cells in place (editingFeature)
|
|
386
|
+
editor?: 'text' | 'number' | 'date' | 'datetime' | 'select' | 'checkbox' | Component // default from the renderer
|
|
387
|
+
editorOptions?: { options?, min?, max?, placeholder?, maxLength? } // a select's choices, a number's range…
|
|
388
|
+
validate?: (value, row) => string | void // an error message keeps the editor open
|
|
380
389
|
cellClass?: ClassValue | ((row) => ClassValue); headerClass?: ClassValue
|
|
381
390
|
}
|
|
382
391
|
```
|
|
@@ -1071,6 +1080,65 @@ await grid.value?.print({ title: 'Orders', totals: true, landscape: true })
|
|
|
1071
1080
|
(a heading, also the document title) and `landscape`.
|
|
1072
1081
|
- It resolves when printing is over. The printing code (1.1 kB gzip) loads on first use.
|
|
1073
1082
|
|
|
1083
|
+
## Inline editing
|
|
1084
|
+
|
|
1085
|
+
`editingFeature` edits cells in place. Mark columns `editable` (or `(row) => boolean`). A cell opens
|
|
1086
|
+
its editor on double-click, on Enter or F2 when focused, or when you start typing on it (the
|
|
1087
|
+
keys replace the value). **Enter** saves, **Tab** / **Shift+Tab** save and edit the next / previous
|
|
1088
|
+
editable cell, **Esc** cancels, and clicking elsewhere saves.
|
|
1089
|
+
|
|
1090
|
+
The editor follows the column's renderer: numbers and money → a number input, `date` → a date
|
|
1091
|
+
picker, `datetime` → date and time, `boolean` → it flips at once (no editor), `status` / `chip`
|
|
1092
|
+
→ a select of the column's values, anything else → text. `editor` picks another, or your own
|
|
1093
|
+
component (`CellEditorProps`: `v-model`, emit `commit` / `cancel`; Enter, Tab and Esc work around it).
|
|
1094
|
+
|
|
1095
|
+
The grid never changes your rows: it emits `cell-edit` with the typed `value` (a number, a date
|
|
1096
|
+
string in the cell's own format, a select's value) and `oldValue`, and your handler stores it.
|
|
1097
|
+
`setCellValue(row, column, value)` writes along the column's `field` path.
|
|
1098
|
+
|
|
1099
|
+
```vue
|
|
1100
|
+
<script setup lang="ts">
|
|
1101
|
+
import { VGrid, editingFeature, setCellValue, type CellEditEvent } from '@nocopypaste/vue-grid'
|
|
1102
|
+
|
|
1103
|
+
const rows = reactive(await loadBets())
|
|
1104
|
+
const columns = [
|
|
1105
|
+
col({
|
|
1106
|
+
key: 'player',
|
|
1107
|
+
field: 'player.name',
|
|
1108
|
+
editable: true,
|
|
1109
|
+
validate: (v) => (String(v).trim() ? undefined : 'A player needs a name.'),
|
|
1110
|
+
}),
|
|
1111
|
+
col({ key: 'stake', renderer: currencyRenderer, editable: true, editorOptions: { min: 0 } }),
|
|
1112
|
+
col({
|
|
1113
|
+
key: 'status',
|
|
1114
|
+
renderer: statusRenderer,
|
|
1115
|
+
editable: (bet) => bet.status !== 'Void',
|
|
1116
|
+
editorOptions: { options: ['Open', 'Won', 'Lost', 'Void'] },
|
|
1117
|
+
}),
|
|
1118
|
+
col({ key: 'verified', renderer: booleanRenderer, editable: true }),
|
|
1119
|
+
]
|
|
1120
|
+
|
|
1121
|
+
// optional: an async save. The cell shows it saving; a rejection keeps the editor open with the message.
|
|
1122
|
+
async function saveCell(e: CellEditEvent<Bet>) {
|
|
1123
|
+
await api.patch(`/bets/${e.rowKey}`, { [e.column.key]: e.value }) // throws on a 4xx
|
|
1124
|
+
setCellValue(e.row, e.column, e.value)
|
|
1125
|
+
}
|
|
1126
|
+
</script>
|
|
1127
|
+
|
|
1128
|
+
<template>
|
|
1129
|
+
<VGrid :rows :columns row-key="id" :save-cell="saveCell" :features="[editingFeature]" />
|
|
1130
|
+
<!-- or without a save function: @cell-edit="(e) => setCellValue(e.row, e.column, e.value)" -->
|
|
1131
|
+
</template>
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
`validate` returns a message to keep the editor open with it (shown below the cell, and as the
|
|
1135
|
+
input's description for screen readers); a number outside `min` / `max` or not a number is refused
|
|
1136
|
+
the same way. One cell edits at a time. With `keyboardNavigationFeature` cells take focus, so typing
|
|
1137
|
+
and Enter / F2 work; without it, double-click. Pinned rows and group rows aren't editable. The
|
|
1138
|
+
editor's code loads on demand, while the browser is idle, once a grid has an editable column.
|
|
1139
|
+
`grid.startEdit(rowKey, columnKey)` opens an editor from code, `grid.stopEdit()` closes it. Its
|
|
1140
|
+
text (`Edit {column}`, `Enter a number.`, `Saving…`) is in `messages`.
|
|
1141
|
+
|
|
1074
1142
|
## Status bar
|
|
1075
1143
|
|
|
1076
1144
|
`statusBarFeature` adds a bar under the grid, like a spreadsheet's:
|
package/agent/api.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@nocopypaste/vue-grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"component": "VGrid",
|
|
5
5
|
"props": [
|
|
6
6
|
{
|
|
@@ -50,6 +50,13 @@
|
|
|
50
50
|
"description": "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.",
|
|
51
51
|
"feature": "statusBar"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"name": "saveCell",
|
|
55
|
+
"type": "(event: CellEditEvent<T>) => unknown",
|
|
56
|
+
"required": false,
|
|
57
|
+
"description": "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.",
|
|
58
|
+
"feature": "editing"
|
|
59
|
+
},
|
|
53
60
|
{
|
|
54
61
|
"name": "messages",
|
|
55
62
|
"type": "GridMessages",
|
|
@@ -435,6 +442,11 @@
|
|
|
435
442
|
"payload": "[event: CellActionEvent<T>]",
|
|
436
443
|
"description": "A renderer emitted an action (buttons, toggles, menus, edit, copy)."
|
|
437
444
|
},
|
|
445
|
+
{
|
|
446
|
+
"name": "cell-edit",
|
|
447
|
+
"payload": "[event: CellEditEvent<T>]",
|
|
448
|
+
"description": "A cell was edited (editing feature): update your data with `value`. The grid doesn't."
|
|
449
|
+
},
|
|
438
450
|
{
|
|
439
451
|
"name": "sub-rows-error",
|
|
440
452
|
"payload": "[event: { row: T; error: unknown }]",
|
|
@@ -642,6 +654,18 @@
|
|
|
642
654
|
"type": "Promise<boolean>",
|
|
643
655
|
"required": true,
|
|
644
656
|
"description": "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."
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"name": "startEdit",
|
|
660
|
+
"type": "boolean",
|
|
661
|
+
"required": true,
|
|
662
|
+
"description": "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."
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"name": "stopEdit",
|
|
666
|
+
"type": "void",
|
|
667
|
+
"required": true,
|
|
668
|
+
"description": "Closes the open editor: saves its value, or with `cancel` drops it. Editing feature."
|
|
645
669
|
}
|
|
646
670
|
],
|
|
647
671
|
"column": [
|
|
@@ -871,6 +895,34 @@
|
|
|
871
895
|
"description": "Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns.",
|
|
872
896
|
"feature": "export"
|
|
873
897
|
},
|
|
898
|
+
{
|
|
899
|
+
"name": "editable",
|
|
900
|
+
"type": "boolean | ((row: T) => boolean)",
|
|
901
|
+
"required": false,
|
|
902
|
+
"description": "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).",
|
|
903
|
+
"feature": "editing"
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"name": "editor",
|
|
907
|
+
"type": "EditorName | Component",
|
|
908
|
+
"required": false,
|
|
909
|
+
"description": "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.",
|
|
910
|
+
"feature": "editing"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
"name": "editorOptions",
|
|
914
|
+
"type": "EditorOptions",
|
|
915
|
+
"required": false,
|
|
916
|
+
"description": "Options of the editor: the choices of a select, a number's `min` / `max`, a `placeholder`.",
|
|
917
|
+
"feature": "editing"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"name": "validate",
|
|
921
|
+
"type": "(value: unknown, row: T) => string | null | undefined | void",
|
|
922
|
+
"required": false,
|
|
923
|
+
"description": "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.",
|
|
924
|
+
"feature": "editing"
|
|
925
|
+
},
|
|
874
926
|
{
|
|
875
927
|
"name": "cellClass",
|
|
876
928
|
"type": "ClassValue | ((row: T) => ClassValue)",
|
|
@@ -948,6 +1000,20 @@
|
|
|
948
1000
|
"hideable"
|
|
949
1001
|
]
|
|
950
1002
|
},
|
|
1003
|
+
{
|
|
1004
|
+
"id": "editing",
|
|
1005
|
+
"export": "editingFeature",
|
|
1006
|
+
"description": "",
|
|
1007
|
+
"props": [
|
|
1008
|
+
"saveCell"
|
|
1009
|
+
],
|
|
1010
|
+
"columnOptions": [
|
|
1011
|
+
"editable",
|
|
1012
|
+
"editor",
|
|
1013
|
+
"editorOptions",
|
|
1014
|
+
"validate"
|
|
1015
|
+
]
|
|
1016
|
+
},
|
|
951
1017
|
{
|
|
952
1018
|
"id": "export",
|
|
953
1019
|
"export": "exportFeature",
|
package/agent/api.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @nocopypaste/vue-grid 0.
|
|
1
|
+
# @nocopypaste/vue-grid 0.10.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
|
|
|
@@ -14,6 +14,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
14
14
|
| `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` |
|
|
15
15
|
| `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` |
|
|
16
16
|
| `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` |
|
|
17
|
+
| `editingFeature` | | `saveCell` | `editable` `editor` `editorOptions` `validate` |
|
|
17
18
|
| `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` |
|
|
18
19
|
| `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` |
|
|
19
20
|
| `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. | | |
|
|
@@ -40,6 +41,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
40
41
|
| `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. |
|
|
41
42
|
| `pagination` | `boolean \| PaginationOptions` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
|
|
42
43
|
| `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. |
|
|
44
|
+
| `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. |
|
|
43
45
|
| `messages` | `GridMessages` | | | Built-in text (translations, wording), over `createVueGrid({ messages })`. |
|
|
44
46
|
| `parts` | `GridParts` | | | Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. |
|
|
45
47
|
| `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`. |
|
|
@@ -107,6 +109,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
107
109
|
| `row-click` | `[row: T, event: MouseEvent \| KeyboardEvent]` | A row was clicked (not on a link, button or input inside it, nor a `clickable` column). |
|
|
108
110
|
| `cell-click` | `[event: CellClickEvent<T>]` | A cell of a `clickable: true` column was clicked. |
|
|
109
111
|
| `cell-action` | `[event: CellActionEvent<T>]` | A renderer emitted an action (buttons, toggles, menus, edit, copy). |
|
|
112
|
+
| `cell-edit` | `[event: CellEditEvent<T>]` | A cell was edited (editing feature): update your data with `value`. The grid doesn't. |
|
|
110
113
|
| `sub-rows-error` | `[event: { row: T; error: unknown }]` | `loadSubRows` rejected for a row. |
|
|
111
114
|
| `context-action` | `[event: ContextActionEvent<T>]` | An item of the body-cell context menu was chosen. |
|
|
112
115
|
| `header-action` | `[event: HeaderActionEvent<T>]` | A custom item of the header menu was chosen (built-in items act by themselves). |
|
|
@@ -153,6 +156,8 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
153
156
|
| `exportXlsx` | `Promise<void>` | | Downloads the rows as an Excel file (`filename`, default `export.xlsx`). Export feature. |
|
|
154
157
|
| `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. |
|
|
155
158
|
| `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. |
|
|
159
|
+
| `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. |
|
|
160
|
+
| `stopEdit` | `void` | | Closes the open editor: saves its value, or with `cancel` drops it. Editing feature. |
|
|
156
161
|
|
|
157
162
|
## `ColumnDef<T>`
|
|
158
163
|
|
|
@@ -192,6 +197,10 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
192
197
|
| `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). |
|
|
193
198
|
| `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. |
|
|
194
199
|
| `exportable` | `boolean` | `exportFeature` | Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns. |
|
|
200
|
+
| `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). |
|
|
201
|
+
| `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. |
|
|
202
|
+
| `editorOptions` | `EditorOptions` | `editingFeature` | Options of the editor: the choices of a select, a number's `min` / `max`, a `placeholder`. |
|
|
203
|
+
| `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. |
|
|
195
204
|
| `cellClass` | `ClassValue \| ((row: T) => ClassValue)` | | Extra classes for the column's body cells (or a function of the row). |
|
|
196
205
|
| `headerClass` | `ClassValue` | | Extra classes for the column's header cell. |
|
|
197
206
|
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"columnReorderFeature",
|
|
32
32
|
"columnResizingFeature",
|
|
33
33
|
"columnVisibilityFeature",
|
|
34
|
+
"editingFeature",
|
|
34
35
|
"exportFeature",
|
|
35
36
|
"filteringFeature",
|
|
36
37
|
"keyboardNavigationFeature",
|
|
@@ -58,6 +59,9 @@
|
|
|
58
59
|
"statusBar": {
|
|
59
60
|
"description": "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."
|
|
60
61
|
},
|
|
62
|
+
"saveCell": {
|
|
63
|
+
"description": "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."
|
|
64
|
+
},
|
|
61
65
|
"messages": {
|
|
62
66
|
"description": "Built-in text (translations, wording), over `createVueGrid({ messages })`."
|
|
63
67
|
},
|
|
@@ -688,6 +692,18 @@
|
|
|
688
692
|
"type": "boolean",
|
|
689
693
|
"description": "Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns."
|
|
690
694
|
},
|
|
695
|
+
"editable": {
|
|
696
|
+
"description": "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)."
|
|
697
|
+
},
|
|
698
|
+
"editor": {
|
|
699
|
+
"description": "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."
|
|
700
|
+
},
|
|
701
|
+
"editorOptions": {
|
|
702
|
+
"description": "Options of the editor: the choices of a select, a number's `min` / `max`, a `placeholder`."
|
|
703
|
+
},
|
|
704
|
+
"validate": {
|
|
705
|
+
"description": "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."
|
|
706
|
+
},
|
|
691
707
|
"cellClass": {
|
|
692
708
|
"description": "Extra classes for the column's body cells (or a function of the row)."
|
|
693
709
|
},
|