@nocopypaste/vue-grid 0.5.0 → 0.7.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 +10 -2
- package/CHANGELOG.md +37 -0
- package/README.md +177 -79
- package/agent/api.json +63 -9
- package/agent/api.md +16 -6
- package/agent/grid-config.schema.json +9 -11
- package/dist/agent/api.js +63 -9
- package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +545 -518
- 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 +4 -3
- package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js +58 -53
- package/dist/components/VGridColumnMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js +50 -49
- package/dist/components/VGridFilterInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js +151 -146
- package/dist/components/VGridFilterPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js +44 -43
- package/dist/components/VGridFilterPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js +10 -8
- package/dist/components/VGridGroupCells.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +62 -57
- package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js +59 -58
- package/dist/components/VGridMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js +62 -55
- package/dist/components/VGridPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VGridResizeHandle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js +60 -59
- package/dist/components/VGridRows.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js +27 -26
- package/dist/components/VGridSearch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js +12 -11
- package/dist/components/VGridSelectionBanner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js +37 -30
- package/dist/components/VGridStatusBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useGridExport.js +98 -51
- package/dist/composables/useGridExport.js.map +1 -1
- package/dist/composables/useGridMenus.js +41 -41
- package/dist/composables/useGridMenus.js.map +1 -1
- package/dist/composables/useStatusBar.js +9 -0
- package/dist/composables/useStatusBar.js.map +1 -1
- package/dist/core/xlsx.js +172 -0
- package/dist/core/xlsx.js.map +1 -0
- package/dist/features/export.js.map +1 -1
- package/dist/index.js +55 -54
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/messages.js +20 -0
- package/dist/internal/messages.js.map +1 -0
- package/dist/internal/print.js +51 -0
- package/dist/internal/print.js.map +1 -0
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js +31 -30
- package/dist/renderers/ActionsMenuCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js +28 -27
- package/dist/renderers/ChangeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js +22 -21
- package/dist/renderers/CopyCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js +37 -36
- package/dist/renderers/DetailsCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js +16 -15
- package/dist/renderers/EditCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/IconToggleCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js +21 -20
- package/dist/renderers/JsonTreeCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js +18 -17
- package/dist/renderers/ListCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/renderers/MultiLineCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/renderers/parts/CopyButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/types/components/VGrid.vue.d.ts +34 -7
- package/dist/types/components/VGridColumnMenu.vue.d.ts +4 -5
- package/dist/types/components/VGridMenu.vue.d.ts +1 -1
- package/dist/types/components/VGridPagination.vue.d.ts +8 -3
- package/dist/types/components/VGridSearch.vue.d.ts +2 -2
- package/dist/types/composables/useGridExport.d.ts +6 -1
- package/dist/types/composables/useGridMenus.d.ts +3 -1
- package/dist/types/composables/useStatusBar.d.ts +7 -0
- package/dist/types/core/xlsx.d.ts +34 -0
- package/dist/types/features/export.d.ts +6 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internal/context.d.ts +5 -1
- package/dist/types/internal/messages.d.ts +16 -0
- package/dist/types/internal/print.d.ts +16 -0
- package/dist/types/renderers/parts/CopyButton.vue.d.ts +1 -3
- package/dist/types/types.d.ts +314 -0
- package/llms-full.txt +203 -87
- package/llms.txt +1 -1
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -64,8 +64,9 @@ runs in the [live examples](https://eboye.github.io/eboye-vue-grid/), each with
|
|
|
64
64
|
| Rows that stay on top / bottom | `rowPinningFeature` | `v-model:pinned-rows="{ top: [id], bottom: [] }"`, `pinRow()`, `pinned-top-rows` |
|
|
65
65
|
| A totals row (sum, avg, …) | `aggregationFeature` | column `aggregate: 'sum' \| 'avg' \| 'min' \| 'max' \| 'count' \| fn`; `totals` (or `'top'`) |
|
|
66
66
|
| Group rows by a column ("by status, then city") | `rowGroupingFeature` | `v-model:group-by="['status', 'city']"`, `groups-expanded`; column `groupable: true` (header menu), `groupValue: (row) => …` (e.g. month); `aggregate` shows per group |
|
|
67
|
-
| Download CSV, copy rows / cells
|
|
67
|
+
| Download CSV / Excel, print, copy rows / cells | `exportFeature` | `grid.exportCsv()`, `getCsv()`, `exportXlsx()`, `getXlsx()`, `print()`, `copyRows()`, `@copy`; column `exportValue`, `exportable: false` |
|
|
68
68
|
| Row / selection counts, sum of the selected rows | `statusBarFeature` | `status-bar` (or `{ summary: ['total'], aggregates?: ['sum', 'avg'] }`); `#status-bar="{ rowCount, selectedCount, summary, … }"` |
|
|
69
|
+
| Translate / reword the grid, drop built-in pieces | — | `messages` (`GridMessages`), `parts` (`GridParts`): app-wide in `createVueGrid` or per grid; slots `#load-error`, `#no-match`, `#select-all-banner` |
|
|
69
70
|
| Arrow-key navigation (ARIA grid) | `keyboardNavigationFeature` | — |
|
|
70
71
|
| Remember column layout | — | `storage="orders-grid"` (localStorage key) |
|
|
71
72
|
| Cell type (money, date, badge, link, …) | — | `renderer: currencyRenderer` etc. (list below) |
|
|
@@ -365,7 +366,7 @@ visible column and runs across the next ones up to the first with an `aggregate`
|
|
|
365
366
|
column it drops the column name and ellipsizes the value (full label as tooltip), so give it room
|
|
366
367
|
where the value matters. `#group-<key>="{ value, count }"` renders a group's value yourself.
|
|
367
368
|
|
|
368
|
-
### CSV export and copy
|
|
369
|
+
### CSV / Excel export and copy
|
|
369
370
|
|
|
370
371
|
```vue
|
|
371
372
|
<script setup lang="ts">
|
|
@@ -398,6 +399,10 @@ const grid = ref<VGridExposed>()
|
|
|
398
399
|
raw values; `copyRows` and Ctrl/⌘+C to the selected rows as displayed, tab-separated. Options:
|
|
399
400
|
`rows: 'filtered' | 'all' | 'page' | 'selected'`, `columns: [keys]`, `values: 'raw' | 'formatted'`,
|
|
400
401
|
`header`, `totals`, `children`, `delimiter`. `toCsv(rows, columns)` works without a grid.
|
|
402
|
+
`exportXlsx({ filename, sheetName })` / `getXlsx()` (a Promise) write an Excel file with typed cells
|
|
403
|
+
(numbers, dates, booleans) and number formats from the renderers; `toXlsx(rows, columns)` without a grid.
|
|
404
|
+
`print({ title, totals, landscape })` prints every matching row as a table (header on each page);
|
|
405
|
+
Ctrl+P on the page only prints what is on screen.
|
|
401
406
|
|
|
402
407
|
### Row actions and context menu
|
|
403
408
|
|
|
@@ -510,6 +515,9 @@ only sees stylesheet rules. Density:
|
|
|
510
515
|
- Ctrl+C copies nothing for a clicked cell → cells only take focus with `keyboardNavigationFeature`
|
|
511
516
|
(or select rows first); `exportFeature` must be registered too.
|
|
512
517
|
- An exported column of `⋯` / buttons / `[object Object]` → `exportable: false`, or `exportValue: (row) => …`.
|
|
518
|
+
- Printing the page (Ctrl+P) shows only the rows on screen, clipped to the grid → use `grid.print()`.
|
|
519
|
+
- Translating by replacing components or CSS `content` → set `messages` (every built-in text has a key).
|
|
520
|
+
- Hiding a built-in piece with CSS → `parts: { filterButtons: false, … }` leaves it out of the DOM (and the tab order).
|
|
513
521
|
- Copied numbers come out as `€1,234.50` → copying uses displayed values; pass `{ values: 'raw' }`
|
|
514
522
|
(CSV exports are raw by default).
|
|
515
523
|
- `group-by` names a field, not a column → it takes column `key`s; add a (hidden) column for it.
|
|
@@ -520,7 +528,7 @@ only sees stylesheet rules. Density:
|
|
|
520
528
|
|
|
521
529
|
---
|
|
522
530
|
|
|
523
|
-
# @nocopypaste/vue-grid 0.
|
|
531
|
+
# @nocopypaste/vue-grid 0.7.0 — API reference
|
|
524
532
|
|
|
525
533
|
> Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
|
|
526
534
|
|
|
@@ -536,7 +544,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
536
544
|
| `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` |
|
|
537
545
|
| `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` |
|
|
538
546
|
| `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` |
|
|
539
|
-
| `exportFeature` | CSV export and copying: `grid.exportCsv()` downloads the filtered, sorted rows as a CSV file, `grid.getCsv()` returns the text, `grid.copyRows()` copies rows as tab-separated text, and Ctrl/⌘+C copies the selected rows, else the focused cell, as displayed. Columns can set `exportValue` and `exportable: false`. Without it those methods only warn. | | `exportValue` `exportable` |
|
|
547
|
+
| `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` |
|
|
540
548
|
| `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` |
|
|
541
549
|
| `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. | | |
|
|
542
550
|
| `menusFeature` | Context menus: the built-in header menu (sort, filter, pin, move, hide, reset, your own items via `header-menu`) and body-cell menus (`context-menu`), opened by right-click, the ContextMenu key or Shift+F10. Without it the browser's own menu shows. The standalone `<VGridMenu>` and the `actions-menu` renderer don't need it. | `contextMenu` `headerMenu` | |
|
|
@@ -559,13 +567,15 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
559
567
|
| `rowKey` (required) | `RowKeyGetter<T>` | | | Stable unique id of a row: a property name or `(row) => string \| number`. All row state is keyed by it. |
|
|
560
568
|
| `features` | `readonly GridFeature[]` | | | Opt-in features for this grid (added to the app-wide `createVueGrid({ features })`): `sortingFeature`, `filteringFeature`, `serverDataFeature`, `paginationFeature`, or `allFeatures`. Read once, when the grid is created. |
|
|
561
569
|
| `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. |
|
|
562
|
-
| `pagination` | `boolean \|
|
|
570
|
+
| `pagination` | `boolean \| PaginationOptions` | `false` | `paginationFeature` | Built-in pagination under the grid (server-side with `dataSource`, client-side otherwise). |
|
|
563
571
|
| `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. |
|
|
572
|
+
| `messages` | `GridMessages` | | | Built-in text (translations, wording), over `createVueGrid({ messages })`. |
|
|
573
|
+
| `parts` | `GridParts` | | | Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. |
|
|
564
574
|
| `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`. |
|
|
565
575
|
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `filteringFeature` | `client` (default): the grid filters its rows. `controlled`: it only emits `update:filters`. |
|
|
566
576
|
| `filterRow` | `boolean` | `false` | `filteringFeature` | Show the filter row: an input under each filterable column's header. |
|
|
567
577
|
| `filterStorage` | `FilterStateStorage \| string` | | `filteringFeature` | Persist the filter model (`string` = localStorage key). |
|
|
568
|
-
| `noMatchText` | `string` |
|
|
578
|
+
| `noMatchText` | `string` | | `filteringFeature` | Shown when filters hide every row. Default: `messages.noMatch`, else `No rows match the current filters.` |
|
|
569
579
|
| `selectable` | `boolean \| 'single'` | `false` | `selectionFeature` | A selection column: `true` = multi-select (with select-all), `'single'` = one row. |
|
|
570
580
|
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | `selectionFeature` | `cascade` (default): selecting a parent selects its children. `independent`: rows alone. |
|
|
571
581
|
| `isRowSelectable` | `(row: T) => boolean` | | `selectionFeature` | Rows that can't be selected get a disabled checkbox. |
|
|
@@ -587,7 +597,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
587
597
|
| `timeZone` | `string` | | | IANA time zone for date renderers and date filters. |
|
|
588
598
|
| `density` | `Density` | | | Cell padding scale. |
|
|
589
599
|
| `loading` | `boolean` | `false` | | Shows a progress bar and sets `aria-busy` (server data sets it by itself). |
|
|
590
|
-
| `emptyText` | `string` |
|
|
600
|
+
| `emptyText` | `string` | | | Shown when there are no rows. Default: `messages.empty`, else `No data to show.` |
|
|
591
601
|
| `ariaLabel` | `string` | | | Accessible name of the grid. |
|
|
592
602
|
| `ui` | `Partial<Record<GridPart, ClassValue>>` | | | Extra classes per part (`root`, `header`, `headerCell`, `row`, `cell`, `subgrid`, `detail`, `empty`), e.g. Tailwind utilities. |
|
|
593
603
|
| `contextMenu` | `(ctx: CellContext<T>) => MenuItem[] \| null \| undefined` | | `menusFeature` | Right-click menu items for a body cell. Return `null`/`[]` to keep the browser's menu. |
|
|
@@ -595,7 +605,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
595
605
|
| `pinnedTopRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows above the body, not part of the data (row pinning feature). |
|
|
596
606
|
| `pinnedBottomRows` | `readonly T[]` | | `rowPinningFeature` | Extra rows below the body, not part of the data (row pinning feature). |
|
|
597
607
|
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | `aggregationFeature` | A totals row with each column's `aggregate` (aggregation feature): `true` / `'bottom'` sticks it to the bottom, `'top'` under the header. |
|
|
598
|
-
| `totalsLabel` | `string` |
|
|
608
|
+
| `totalsLabel` | `string` | | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). Default: `messages.total`, else `Total`. |
|
|
599
609
|
| `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
|
|
600
610
|
| `groupsExpanded` | `boolean` | `false` | `rowGroupingFeature` | Groups start expanded (row grouping feature). Default: collapsed. |
|
|
601
611
|
|
|
@@ -638,6 +648,9 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
638
648
|
| `group-<key>` | `{ value: unknown; count: number; rows: readonly T[]; column: ColumnDef<T>; group: RowGroup<T> }` | The value of a group row grouped by this column (row grouping feature): `#group-<key>`. |
|
|
639
649
|
| `detail` | `{ row: T; rowKey: RowKey; depth: number }` | Expandable detail row under a row: any content, even another grid. |
|
|
640
650
|
| `empty` | | Shown when there are no rows. |
|
|
651
|
+
| `no-match` | `{ clearFilters: () => void; filterCount: number }` | Shown when filters hide every row, instead of the message and its Clear filters button. |
|
|
652
|
+
| `load-error` | `{ error: unknown; retry: () => Promise<void>; stale: boolean }` | A failed server request (server data): `stale` when the rows from before stay on screen (the notice above them), else in place of the rows. `retry()` asks again. |
|
|
653
|
+
| `select-all-banner` | `{ total: number; page: number; all: boolean; selectAll: () => void; clearSelection: () => void }` | Selection with server data: the "Select all N rows" banner. |
|
|
641
654
|
| `status-bar` | `StatusBarScope` | The status bar's content (status bar feature): replaces the counts and the summary. |
|
|
642
655
|
| `loading` | | Shown while loading with no rows yet. |
|
|
643
656
|
| `sub-rows-loading` | `{ row: T }` | Shown while a row's lazy children load. |
|
|
@@ -662,6 +675,9 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
|
|
|
662
675
|
| `clearSelection` | `void` | | Clears the selection, "all matching rows" included. Selection feature. |
|
|
663
676
|
| `getCsv` | `string` | | The rows as CSV text: the filtered, sorted rows, visible columns, raw values. Export feature. |
|
|
664
677
|
| `exportCsv` | `void` | | Downloads the rows as a CSV file (`filename`, default `export.csv`; UTF-8 with a BOM). Export feature. |
|
|
678
|
+
| `getXlsx` | `Promise<Blob>` | | The rows as an Excel workbook (.xlsx): typed cells (numbers, dates, booleans), number formats from the columns' renderers, a bold frozen header. The writer loads on demand. Export feature. |
|
|
679
|
+
| `exportXlsx` | `Promise<void>` | | Downloads the rows as an Excel file (`filename`, default `export.xlsx`). Export feature. |
|
|
680
|
+
| `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. |
|
|
665
681
|
| `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. |
|
|
666
682
|
|
|
667
683
|
## `ColumnDef<T>`
|
|
@@ -1171,6 +1187,8 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
|
|
|
1171
1187
|
| `currency`? | `string` | Default ISO 4217 currency for currency renderers. |
|
|
1172
1188
|
| `timeZone`? | `string` | Default IANA time zone for date renderers and date filters. |
|
|
1173
1189
|
| `density`? | `Density` | Default density: `compact`, `cozy` (default) or `comfortable`. |
|
|
1190
|
+
| `messages`? | `GridMessages` | Built-in text for every grid (translations, wording); a grid's own `messages` win. |
|
|
1191
|
+
| `parts`? | `GridParts` | Built-in parts to turn off in every grid; a grid's own `parts` win. |
|
|
1174
1192
|
|
|
1175
1193
|
---
|
|
1176
1194
|
|
|
@@ -1178,6 +1196,8 @@ The first items of a list, with a “+N more” toggle. Emits `expand`. Align: `
|
|
|
1178
1196
|
|
|
1179
1197
|
# @nocopypaste/vue-grid
|
|
1180
1198
|
|
|
1199
|
+
[](https://eboye.github.io/eboye-vue-grid/) — every feature running live, with its source.
|
|
1200
|
+
|
|
1181
1201
|
A data grid for Vue 3 built on **CSS Grid** — with real `subgrid` sub-rows, pinned columns, column
|
|
1182
1202
|
reorder/visibility with persistence, selection, virtual scrolling, pagination, a pluggable
|
|
1183
1203
|
**cell-renderer registry** for 3rd-party addons, and a theme you customise with **CSS variables**.
|
|
@@ -1308,7 +1328,7 @@ an opt-in feature:
|
|
|
1308
1328
|
| `rowPinningFeature` | `v-model:pinned-rows` / `pinRow()`: rows that stay in view above or below the body, plus `pinned-top-rows` / `pinned-bottom-rows` for rows that aren't in the data |
|
|
1309
1329
|
| `aggregationFeature` | Column `aggregate` (`sum`, `avg`, `min`, `max`, `count`, a function) and `totals`: a sticky totals row over the filtered rows |
|
|
1310
1330
|
| `rowGroupingFeature` | `v-model:group-by`: rows grouped by one or more columns into collapsible group rows with the value, row count and aggregates; Group by / Ungroup in the header menu for `groupable` columns |
|
|
1311
|
-
| `exportFeature` | `exportCsv()` / `getCsv()` / `copyRows()`, Ctrl/⌘+C for the selected rows or the focused cell, the `copy` event; column `exportValue` / `exportable`
|
|
1331
|
+
| `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` |
|
|
1312
1332
|
| `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 |
|
|
1313
1333
|
|
|
1314
1334
|
```ts
|
|
@@ -1353,33 +1373,33 @@ what you import.
|
|
|
1353
1373
|
|
|
1354
1374
|
| Import (minified / gzip, Vue excluded) | Initial chunk |
|
|
1355
1375
|
| ---------------------------------------------------------------------------- | ------------------ |
|
|
1356
|
-
| `VGrid` (no features) | 40.
|
|
1357
|
-
| `VGrid` + `sortingFeature` | 41.
|
|
1358
|
-
| `VGrid` + `filteringFeature` |
|
|
1359
|
-
| `VGrid` + `serverDataFeature` | 41.
|
|
1360
|
-
| `VGrid` + `paginationFeature` | 40.
|
|
1361
|
-
| `VGrid` + `selectionFeature` | 44.
|
|
1362
|
-
| `VGrid` + `subGridsFeature` | 42.
|
|
1363
|
-
| `VGrid` + `menusFeature` | 50.
|
|
1364
|
-
| `VGrid` + `columnReorderFeature` | 44.
|
|
1365
|
-
| `VGrid` + `columnPinningFeature` | 43.
|
|
1366
|
-
| `VGrid` + `virtualScrollingFeature` | 46.
|
|
1367
|
-
| `VGrid` + `columnVisibilityFeature` | 40.
|
|
1368
|
-
| `VGrid` + `keyboardNavigationFeature` | 43.
|
|
1369
|
-
| `VGrid` + `columnResizingFeature` | 43.
|
|
1370
|
-
| `VGrid` + `columnGroupsFeature` | 41.
|
|
1371
|
-
| `VGrid` + `rowPinningFeature` | 45.
|
|
1372
|
-
| `VGrid` + `aggregationFeature` | 45.
|
|
1373
|
-
| `VGrid` + `rowGroupingFeature` | 50.
|
|
1374
|
-
| `VGrid` + `exportFeature` |
|
|
1375
|
-
| `VGrid` + `statusBarFeature` | 42.
|
|
1376
|
-
| `VGrid` + `allFeatures` + `VGridSearch` |
|
|
1377
|
-
| `VGrid` + `currencyRenderer` | 41.
|
|
1378
|
-
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 47.
|
|
1376
|
+
| `VGrid` (no features) | 40.5 kB / 14.1 kB |
|
|
1377
|
+
| `VGrid` + `sortingFeature` | 41.2 kB / 14.4 kB |
|
|
1378
|
+
| `VGrid` + `filteringFeature` | 51.1 kB / 17.8 kB |
|
|
1379
|
+
| `VGrid` + `serverDataFeature` | 41.8 kB / 14.7 kB |
|
|
1380
|
+
| `VGrid` + `paginationFeature` | 40.6 kB / 14.1 kB |
|
|
1381
|
+
| `VGrid` + `selectionFeature` | 44.6 kB / 15.5 kB |
|
|
1382
|
+
| `VGrid` + `subGridsFeature` | 42.8 kB / 14.9 kB |
|
|
1383
|
+
| `VGrid` + `menusFeature` | 50.9 kB / 17.6 kB |
|
|
1384
|
+
| `VGrid` + `columnReorderFeature` | 44.2 kB / 15.3 kB |
|
|
1385
|
+
| `VGrid` + `columnPinningFeature` | 43.4 kB / 15.1 kB |
|
|
1386
|
+
| `VGrid` + `virtualScrollingFeature` | 46.2 kB / 16.3 kB |
|
|
1387
|
+
| `VGrid` + `columnVisibilityFeature` | 40.6 kB / 14.1 kB |
|
|
1388
|
+
| `VGrid` + `keyboardNavigationFeature` | 43.2 kB / 15.1 kB |
|
|
1389
|
+
| `VGrid` + `columnResizingFeature` | 43.7 kB / 15.3 kB |
|
|
1390
|
+
| `VGrid` + `columnGroupsFeature` | 41.8 kB / 14.5 kB |
|
|
1391
|
+
| `VGrid` + `rowPinningFeature` | 45.4 kB / 15.4 kB |
|
|
1392
|
+
| `VGrid` + `aggregationFeature` | 45.6 kB / 15.5 kB |
|
|
1393
|
+
| `VGrid` + `rowGroupingFeature` | 50.2 kB / 16.9 kB |
|
|
1394
|
+
| `VGrid` + `exportFeature` | 45.4 kB / 16.0 kB |
|
|
1395
|
+
| `VGrid` + `statusBarFeature` | 42.8 kB / 15.0 kB |
|
|
1396
|
+
| `VGrid` + `allFeatures` + `VGridSearch` | 108.1 kB / 36.5 kB |
|
|
1397
|
+
| `VGrid` + `currencyRenderer` | 41.9 kB / 14.5 kB |
|
|
1398
|
+
| `VGrid` + `VGridPagination` + `VGridColumnMenu` | 47.2 kB / 16.3 kB |
|
|
1379
1399
|
| `sortRows` only | 0.7 kB / 0.4 kB |
|
|
1380
1400
|
| `toCsv` only | 1.1 kB / 0.6 kB |
|
|
1381
|
-
| everything |
|
|
1382
|
-
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) |
|
|
1401
|
+
| everything | 160.7 kB / 51.5 kB |
|
|
1402
|
+
| `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 70.5 kB / 19.2 kB |
|
|
1383
1403
|
|
|
1384
1404
|
With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
|
|
1385
1405
|
chunks**: they load the first time a popover opens or `filter-row` is on. With
|
|
@@ -1396,57 +1416,60 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
|
|
|
1396
1416
|
|
|
1397
1417
|
### Props
|
|
1398
1418
|
|
|
1399
|
-
| Prop | Type | Default
|
|
1400
|
-
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
1401
|
-
| `rows` | `T[]` | `[]`
|
|
1402
|
-
| `features` | `GridFeature[]` | —
|
|
1403
|
-
| `dataSource` | `(query, { signal }) => Promise<{ rows, total? }>` | —
|
|
1404
|
-
| `columns` | `ColumnDef<T>[]` | —
|
|
1405
|
-
| `rowKey` | `keyof T \| (row) => string \| number` | —
|
|
1406
|
-
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null`
|
|
1407
|
-
| `sortMode` | `'controlled' \| 'client'` | `'controlled'`
|
|
1408
|
-
| `v-model:filters` | `FilterState \| null` | `null`
|
|
1409
|
-
| `filterMode` | `'client' \| 'controlled'` | `'client'`
|
|
1410
|
-
| `filterRow` | `boolean` | `false`
|
|
1411
|
-
| `filterStorage` | `string \| FilterStateStorage` | —
|
|
1412
|
-
| `noMatchText` | `string` | `
|
|
1413
|
-
| `pagination` | `boolean \|
|
|
1414
|
-
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25`
|
|
1415
|
-
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived
|
|
1416
|
-
| `storage` | `string \| ColumnStateStorage` | —
|
|
1417
|
-
| `pinnedMaxShare` | `number \| false` | `0.5`
|
|
1418
|
-
| `v-model:expanded` | `RowKey[]` | `[]`
|
|
1419
|
-
| `subRows` | `(row) => T[] \| undefined` | —
|
|
1420
|
-
| `loadSubRows` | `(row) => Promise<T[]>` | —
|
|
1421
|
-
| `hasSubRows` | `(row) => boolean` | —
|
|
1422
|
-
| `rowExpandable` | `(row) => boolean` | —
|
|
1423
|
-
| `selectable` | `boolean \| 'single'` | `false`
|
|
1424
|
-
| `v-model:selected` | `RowKey[]` | `[]`
|
|
1425
|
-
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'`
|
|
1426
|
-
| `isRowSelectable` | `(row) => boolean` | —
|
|
1427
|
-
| `pruneSelection` | `boolean` | `false`
|
|
1428
|
-
| `v-model:selectAllMatching` | `boolean` | `false`
|
|
1429
|
-
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false`
|
|
1430
|
-
| `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null`
|
|
1431
|
-
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | —
|
|
1432
|
-
| `totals` | `boolean \| 'top' \| 'bottom'` | `false`
|
|
1433
|
-
| `totalsLabel` | `string` | `
|
|
1434
|
-
| `aggregates` | `Record<string, unknown>` | —
|
|
1435
|
-
| `v-model:groupBy` | `string[] \| string \| null` | `null`
|
|
1436
|
-
| `groupsExpanded` | `boolean` | `false`
|
|
1437
|
-
| `rowClickable` | `boolean` | `false`
|
|
1438
|
-
| `rowClass` | `(row, index) => ClassValue` | —
|
|
1439
|
-
| `highlightedRows` | `RowKey[]` | —
|
|
1440
|
-
| `flash` | `boolean \| 'direction'` | `false`
|
|
1441
|
-
| `renderers` | `CellRendererDefinition[]` | —
|
|
1442
|
-
| `locale` / `currency` / `timeZone` | `string` | plugin → browser
|
|
1443
|
-
| `density` | `'compact' \| 'cozy' \| 'comfortable'` | `'cozy'`
|
|
1444
|
-
| `loading` | `boolean` | `false`
|
|
1445
|
-
| `emptyText` | `string` | `
|
|
1446
|
-
| `ariaLabel` | `string` | —
|
|
1447
|
-
| `
|
|
1448
|
-
| `
|
|
1449
|
-
| `
|
|
1419
|
+
| Prop | Type | Default | |
|
|
1420
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1421
|
+
| `rows` | `T[]` | `[]` | Your data objects, used as-is (never mutated). Not needed with `dataSource`. |
|
|
1422
|
+
| `features` | `GridFeature[]` | — | Opt-in features for this grid, added to the app-wide ones. See [Features](#features-everything-optional). |
|
|
1423
|
+
| `dataSource` | `(query, { signal }) => Promise<{ rows, total? }>` | — | Server rows: the grid calls it whenever sort, filters or page change. Needs `serverDataFeature`. See [Server data](#server-data). |
|
|
1424
|
+
| `columns` | `ColumnDef<T>[]` | — | See below. |
|
|
1425
|
+
| `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
|
|
1426
|
+
| `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
|
|
1427
|
+
| `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
|
|
1428
|
+
| `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
|
|
1429
|
+
| `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
|
|
1430
|
+
| `filterRow` | `boolean` | `false` | A row of inline filter inputs under the headers. |
|
|
1431
|
+
| `filterStorage` | `string \| FilterStateStorage` | — | Persist filters (`string` = localStorage key). |
|
|
1432
|
+
| `noMatchText` | `string` | `messages.noMatch` | Shown, with a _Clear filters_ button, when filters hide every row (`No rows match the current filters.`). |
|
|
1433
|
+
| `pagination` | `boolean \| PaginationOptions` | `false` | The built-in pager (pagination feature): `{ pageSizes, siblings, summary, firstLast }`. |
|
|
1434
|
+
| `v-model:page` / `v-model:pageSize` | `number` | `1` / `25` | Reset to page 1 when sort or filters change. |
|
|
1435
|
+
| `v-model:columnState` | `{ order: string[]; hidden: string[]; pinned?: Record<string, "left" \| "right" \| null>; widths?: Record<string, string> }` | derived | Column order, visibility and runtime pins. |
|
|
1436
|
+
| `storage` | `string \| ColumnStateStorage` | — | Persist column state (`string` = localStorage key). |
|
|
1437
|
+
| `pinnedMaxShare` | `number \| false` | `0.5` | Pinned columns scroll like the others while together they'd take more than this share of the grid's width (a phone, a narrow panel), and pin again once there's room. `false`: always pinned. Needs `columnPinningFeature`. |
|
|
1438
|
+
| `v-model:expanded` | `RowKey[]` | `[]` | Expanded rows (sub-grids and detail rows). |
|
|
1439
|
+
| `subRows` | `(row) => T[] \| undefined` | — | Synchronous children → sub-grid. Needs `subGridsFeature` (as do the next two). |
|
|
1440
|
+
| `loadSubRows` | `(row) => Promise<T[]>` | — | Lazy children (cached, loading/error/retry). |
|
|
1441
|
+
| `hasSubRows` | `(row) => boolean` | — | Which rows get an expander when lazy. |
|
|
1442
|
+
| `rowExpandable` | `(row) => boolean` | — | Which rows can open the `#detail` slot. |
|
|
1443
|
+
| `selectable` | `boolean \| 'single'` | `false` | Adds a selection column. Needs `selectionFeature` (as do the next five). See [Selection and batch actions](#selection-and-batch-actions). |
|
|
1444
|
+
| `v-model:selected` | `RowKey[]` | `[]` | |
|
|
1445
|
+
| `selectionMode` | `'cascade' \| 'independent'` | `'cascade'` | Whether selecting a parent selects its children. |
|
|
1446
|
+
| `isRowSelectable` | `(row) => boolean` | — | |
|
|
1447
|
+
| `pruneSelection` | `boolean` | `false` | Drop selected keys whose rows left the data (reload, delete, another server page). |
|
|
1448
|
+
| `v-model:selectAllMatching` | `boolean` | `false` | Server data: every row matching the query is selected (from the banner). |
|
|
1449
|
+
| `virtual` | `{ rowHeight: number; overscan?: number; detailHeight?: number } \| false` | `false` | Virtual scrolling (fixed-height rows; sub-grids and measured detail rows included). Needs `virtualScrollingFeature`. |
|
|
1450
|
+
| `v-model:pinnedRows` | `{ top?: RowKey[]; bottom?: RowKey[] } \| null` | `null` | Top-level rows pinned above / below the body. Needs `rowPinningFeature` (as do the next two). See [Pinned rows and totals](#pinned-rows-and-totals). |
|
|
1451
|
+
| `pinnedTopRows` / `pinnedBottomRows` | `T[]` | — | Extra pinned rows that aren't part of `rows` (a target, last year's figures). |
|
|
1452
|
+
| `totals` | `boolean \| 'top' \| 'bottom'` | `false` | A totals row with each column's `aggregate`; `true` = `'bottom'`. Needs `aggregationFeature` (as do the next two). |
|
|
1453
|
+
| `totalsLabel` | `string` | `messages.total` | Shown in the totals row's first column (unless that column has an aggregate). `Total` by default. |
|
|
1454
|
+
| `aggregates` | `Record<string, unknown>` | — | Totals by column key, used instead of computing them (e.g. from a server). |
|
|
1455
|
+
| `v-model:groupBy` | `string[] \| string \| null` | `null` | Column keys to group the rows by, outermost first. Needs `rowGroupingFeature` (as does the next one). See [Row grouping](#row-grouping). |
|
|
1456
|
+
| `groupsExpanded` | `boolean` | `false` | Groups start expanded. |
|
|
1457
|
+
| `rowClickable` | `boolean` | `false` | Pointer cursor; `row-click` is always emitted. |
|
|
1458
|
+
| `rowClass` | `(row, index) => ClassValue` | — | |
|
|
1459
|
+
| `highlightedRows` | `RowKey[]` | — | |
|
|
1460
|
+
| `flash` | `boolean \| 'direction'` | `false` | Briefly highlight cells whose value changes; `'direction'` = green up / red down. Columns override with `flash`. |
|
|
1461
|
+
| `renderers` | `CellRendererDefinition[]` | — | Renderers usable by name in this grid (override plugin ones). |
|
|
1462
|
+
| `locale` / `currency` / `timeZone` | `string` | plugin → browser | Formatting context for renderers. |
|
|
1463
|
+
| `density` | `'compact' \| 'cozy' \| 'comfortable'` | `'cozy'` | Scales cell padding. |
|
|
1464
|
+
| `loading` | `boolean` | `false` | Progress bar + `aria-busy`. |
|
|
1465
|
+
| `emptyText` | `string` | `messages.empty` | Shown when there are no rows (`No data to show.`). |
|
|
1466
|
+
| `ariaLabel` | `string` | — | |
|
|
1467
|
+
| `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). |
|
|
1468
|
+
| `messages` | `GridMessages` | — | Built-in text (translations, wording), over `createVueGrid({ messages })`. See [Text and parts](#text-and-parts). |
|
|
1469
|
+
| `parts` | `GridParts` | — | Built-in parts to leave out (`{ filterButtons: false }`), over `createVueGrid({ parts })`. |
|
|
1470
|
+
| `contextMenu` | `(ctx: { row, rowKey, column, value }) => MenuItem[] \| null` | — | Right-click menu for body cells. Needs `menusFeature`. |
|
|
1471
|
+
| `headerMenu` | `boolean \| ({ column, items }) => MenuItem[] \| null` | `true` | Built-in header menu (sort, pin, move, hide, reset). Needs `menusFeature`. |
|
|
1472
|
+
| `ui` | `Partial<Record<'root' \| 'header' \| 'headerCell' \| 'row' \| 'cell' \| 'subgrid' \| 'detail' \| 'empty', ClassValue>>` | — | Extra classes per part (Tailwind-friendly). |
|
|
1450
1473
|
|
|
1451
1474
|
### Events
|
|
1452
1475
|
|
|
@@ -1465,7 +1488,9 @@ Clicks on links, buttons and inputs inside a cell never trigger `row-click`.
|
|
|
1465
1488
|
`total-<key>` (`{ value, column, group? }`, a cell of the totals row or a group row) ·
|
|
1466
1489
|
`group-<key>` (`{ value, count, rows, column, group }`, the value of a group row) · `detail` (`{ row, rowKey, depth }`) ·
|
|
1467
1490
|
`toolbar` (`{ columns, columnState, setColumnState, filters, setFilters, clearFilters, activeFilterCount, selected, selectedCount, selectAllMatching, clearSelection }`) ·
|
|
1468
|
-
`empty` · `loading` · `sub-rows-loading` (`{ row }`)
|
|
1491
|
+
`empty` · `loading` · `sub-rows-loading` (`{ row }`) · `no-match` (`{ clearFilters, filterCount }`) ·
|
|
1492
|
+
`load-error` (`{ error, retry, stale }`, server data) · `select-all-banner` (`{ total, page, all, selectAll, clearSelection }`) ·
|
|
1493
|
+
`status-bar` (`StatusBarScope`).
|
|
1469
1494
|
|
|
1470
1495
|
### Exposed methods
|
|
1471
1496
|
|
|
@@ -2041,7 +2066,8 @@ same grouping elsewhere.
|
|
|
2041
2066
|
|
|
2042
2067
|
## Export and copy
|
|
2043
2068
|
|
|
2044
|
-
`exportFeature` turns the grid's rows into CSV and copies them to
|
|
2069
|
+
`exportFeature` turns the grid's rows into CSV or an Excel workbook, prints them, and copies them to
|
|
2070
|
+
the clipboard.
|
|
2045
2071
|
|
|
2046
2072
|
```vue
|
|
2047
2073
|
<script setup lang="ts">
|
|
@@ -2100,6 +2126,45 @@ Without the grid: `toCsv(rows, columns, { delimiter, header, guard })` writes CS
|
|
|
2100
2126
|
and column definitions (raw values, `exportValue`, `exportable`); `toDelimited(table)`,
|
|
2101
2127
|
`plainText(value)` and `guardFormula(text)` are its parts.
|
|
2102
2128
|
|
|
2129
|
+
### Excel (.xlsx)
|
|
2130
|
+
|
|
2131
|
+
**`exportXlsx(options)`** downloads an Excel workbook (`filename`, default `export.xlsx`) and
|
|
2132
|
+
**`getXlsx(options)`** resolves to it as a `Blob`; both take the options above (but `delimiter` and
|
|
2133
|
+
`guard`) plus `sheetName`.
|
|
2134
|
+
|
|
2135
|
+
```ts
|
|
2136
|
+
await grid.value?.exportXlsx({ filename: 'orders.xlsx', sheetName: 'Orders', totals: true })
|
|
2137
|
+
```
|
|
2138
|
+
|
|
2139
|
+
- **Typed cells**: numbers stay numbers, booleans booleans, and dates are Excel dates, so the sheet
|
|
2140
|
+
can sum, sort and filter them. Number formats follow the renderer: `currency` (and `change` with
|
|
2141
|
+
`currency`) → `#,##0.00`, a percent `number` → `0.00%`, `date` → `yyyy-mm-dd`, `datetime` →
|
|
2142
|
+
`yyyy-mm-dd hh:mm`, in the grid's `time-zone` (date-only values stay that day).
|
|
2143
|
+
- A bold header frozen at the top, the totals as a bold last line, column widths from the content.
|
|
2144
|
+
- Text is written as text, never as a formula. `values: 'formatted'` writes the cells as shown.
|
|
2145
|
+
- The writer (2.9 kB gzip) loads the first time you export; it has no dependencies.
|
|
2146
|
+
|
|
2147
|
+
Without the grid: `toXlsx(rows, columns, { sheetName, header, timeZone, formats })` returns the
|
|
2148
|
+
file's bytes (`Uint8Array`); `formats` overrides the guess per column key (`'money'`, `'percent'`,
|
|
2149
|
+
`'date'`, `'datetime'`, `'number'`, `'auto'`).
|
|
2150
|
+
|
|
2151
|
+
### Print
|
|
2152
|
+
|
|
2153
|
+
**`print(options)`** prints the rows as a table from a hidden frame, with the browser's print
|
|
2154
|
+
dialog: every row that passes the filters (not just the ones a virtual grid has in view), sorted,
|
|
2155
|
+
as the cells show them. Printing the page itself (Ctrl+P) gives only what is on screen, clipped
|
|
2156
|
+
to the grid's frame.
|
|
2157
|
+
|
|
2158
|
+
```ts
|
|
2159
|
+
await grid.value?.print({ title: 'Orders', totals: true, landscape: true })
|
|
2160
|
+
```
|
|
2161
|
+
|
|
2162
|
+
- A real `<table>`: the header repeats on every printed page, numbers and money are
|
|
2163
|
+
right-aligned as in the grid, the totals print once, in bold, after the last row.
|
|
2164
|
+
- Options: `rows`, `children`, `columns`, `header`, `totals` as for the exports, plus `title`
|
|
2165
|
+
(a heading, also the document title) and `landscape`.
|
|
2166
|
+
- It resolves when printing is over. The printing code (1.1 kB gzip) loads on first use.
|
|
2167
|
+
|
|
2103
2168
|
## Status bar
|
|
2104
2169
|
|
|
2105
2170
|
`statusBarFeature` adds a bar under the grid, like a spreadsheet's:
|
|
@@ -2126,6 +2191,7 @@ and column definitions (raw values, `exportValue`, `exportable`); `toDelimited(t
|
|
|
2126
2191
|
(server data) the summary hides: only the loaded page is known.
|
|
2127
2192
|
- **Your own content**: the `#status-bar` slot gets `{ rowCount, totalRowCount, selectedCount,
|
|
2128
2193
|
allSelected, filterCount, summary, clearFilters }` and replaces the default content.
|
|
2194
|
+
- Leave items out with `rows: false`, `selected: false`, `filters: false` or `clear: false`.
|
|
2129
2195
|
- The bar is a `group` labelled "Grid status"; style it with `.vg-status-bar`. Its component loads
|
|
2130
2196
|
on demand (own chunk).
|
|
2131
2197
|
|
|
@@ -2336,6 +2402,56 @@ with `rendererOptions`). Emit `action(name, payload)`; the grid re-emits it as `
|
|
|
2336
2402
|
row and column. `useGridContext()` gives `{ locale, currency, timeZone }`. Lookup order:
|
|
2337
2403
|
a definition or component on the column → `:renderers` → plugin → `text` (the only renderer built in).
|
|
2338
2404
|
|
|
2405
|
+
## Text and parts
|
|
2406
|
+
|
|
2407
|
+
Everything a feature adds is configurable: its text, and whether each piece shows at all.
|
|
2408
|
+
|
|
2409
|
+
**Text.** Every built-in string (menus, filters, the pager, the status bar, notices, screen-reader
|
|
2410
|
+
labels, renderer buttons) has a key in `GridMessages`. Set the ones you need; the rest stay English.
|
|
2411
|
+
Functions get the values that go into the text.
|
|
2412
|
+
|
|
2413
|
+
```ts
|
|
2414
|
+
app.use(
|
|
2415
|
+
createVueGrid({
|
|
2416
|
+
messages: {
|
|
2417
|
+
sortAscending: 'Rastuće',
|
|
2418
|
+
empty: 'Nema podataka.',
|
|
2419
|
+
groupBy: (column) => `Grupiši po: ${column}`,
|
|
2420
|
+
pageSummary: (from, to, total) => `${from}–${to} od ${total}`,
|
|
2421
|
+
rowCount: (shown, total) => (total ? `${shown} od ${total} redova` : `${shown} redova`),
|
|
2422
|
+
},
|
|
2423
|
+
}),
|
|
2424
|
+
)
|
|
2425
|
+
```
|
|
2426
|
+
|
|
2427
|
+
A grid's own `:messages` win over the app's, and props that name a text (`empty-text`,
|
|
2428
|
+
`no-match-text`, `totals-label`, `<VGridSearch placeholder>`, a renderer's `label`…) win over both.
|
|
2429
|
+
`<VGridPagination>`, `<VGridSearch>`, `<VGridColumnMenu>` and `<VGridMenu>` use the app's messages on
|
|
2430
|
+
their own too. Every key, with its English default, is in the API reference (`GridMessages`).
|
|
2431
|
+
|
|
2432
|
+
**Parts.** `GridParts` turns off what a feature adds, each on by default; app-wide in
|
|
2433
|
+
`createVueGrid({ parts })`, per grid with `:parts`:
|
|
2434
|
+
|
|
2435
|
+
| Part | Leaves out |
|
|
2436
|
+
| -------------------- | ---------------------------------------------------------------------------- |
|
|
2437
|
+
| `progressBar` | The thin bar at the top while loading (`aria-busy` stays) |
|
|
2438
|
+
| `loadErrorNotice` | The notice above the rows when a request fails while rows are shown |
|
|
2439
|
+
| `retry` | The Retry buttons of load errors and of lazy children |
|
|
2440
|
+
| `clearFiltersButton` | The Clear filters button of the no-match message |
|
|
2441
|
+
| `selectAll` | The select-all checkbox in the header (rows still select) |
|
|
2442
|
+
| `selectAllBanner` | The "Select all N rows" banner (server data) |
|
|
2443
|
+
| `filterButtons` | The funnels in `filterable` headers (the filter row and search still filter) |
|
|
2444
|
+
| `resizeGrips` | The grips on header edges (Fit width / Reset width stay in the header menu) |
|
|
2445
|
+
| `headerDrag` | Dragging headers to reorder (Alt+←/→ and the header menu still move columns) |
|
|
2446
|
+
| `copyShortcut` | Ctrl/⌘+C copying in the grid (`copyRows()` still works) |
|
|
2447
|
+
| `groupCounts` | The row count on group rows |
|
|
2448
|
+
|
|
2449
|
+
Some parts can be replaced instead: `#load-error`, `#no-match`, `#select-all-banner` and
|
|
2450
|
+
`#status-bar`. The pager takes `pagination: { firstLast: false, summary: '' }`, the status bar
|
|
2451
|
+
`{ rows, selected, filters, clear }` flags. Per column, `sortable`, `filterable`, `resizable`,
|
|
2452
|
+
`reorderable`, `pinnable`, `hideable`, `groupable` and `exportable` work as before, and
|
|
2453
|
+
`header-menu` (`false`, or a function that edits the built-in items) shapes the header menu.
|
|
2454
|
+
|
|
2339
2455
|
## Theming
|
|
2340
2456
|
|
|
2341
2457
|
Override any token on `:root`, a wrapper, or the grid itself:
|
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.
|
|
3
|
+
> A Vue 3 data grid laid out with CSS Grid and `subgrid`. A plain grid is a read-only table (14.1 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping, 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.
|
|
3
|
+
"version": "0.7.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",
|