@nocopypaste/vue-grid 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +14 -0
  3. package/README.md +72 -29
  4. package/agent/api.json +19 -2
  5. package/agent/api.md +4 -2
  6. package/agent/grid-config.schema.json +25 -0
  7. package/dist/agent/api.js +16 -2
  8. package/dist/agent/requirements.js +2 -0
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/base.css +1 -1
  11. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +585 -584
  12. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +82 -53
  14. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/VGridSortMarker.js +6 -0
  16. package/dist/components/VGridSortMarker.js.map +1 -0
  17. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js +21 -0
  18. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  19. package/dist/composables/useDataSource.js.map +1 -1
  20. package/dist/composables/useGridKeyboard.js +5 -1
  21. package/dist/composables/useGridKeyboard.js.map +1 -1
  22. package/dist/composables/useGridMenus.js +24 -12
  23. package/dist/composables/useGridMenus.js.map +1 -1
  24. package/dist/composables/useRowGrouping.js.map +1 -1
  25. package/dist/composables/useSorting.js +48 -0
  26. package/dist/composables/useSorting.js.map +1 -0
  27. package/dist/core/grouping.js +1 -1
  28. package/dist/core/grouping.js.map +1 -1
  29. package/dist/core/sort.js +31 -1
  30. package/dist/core/sort.js.map +1 -1
  31. package/dist/core.css +1 -1
  32. package/dist/features/sorting.js +8 -4
  33. package/dist/features/sorting.js.map +1 -1
  34. package/dist/index.js +60 -60
  35. package/dist/internal/context.js.map +1 -1
  36. package/dist/theme.css +1 -1
  37. package/dist/types/components/VGrid.vue.d.ts +10 -1
  38. package/dist/types/components/VGridHeader.vue.d.ts +4 -3
  39. package/dist/types/components/VGridSortMarker.vue.d.ts +9 -0
  40. package/dist/types/composables/useDataSource.d.ts +3 -0
  41. package/dist/types/composables/useGridMenus.d.ts +5 -0
  42. package/dist/types/composables/useRowGrouping.d.ts +2 -1
  43. package/dist/types/composables/useSorting.d.ts +24 -0
  44. package/dist/types/core/grouping.d.ts +5 -2
  45. package/dist/types/core/sort.d.ts +16 -0
  46. package/dist/types/index.d.ts +1 -1
  47. package/dist/types/internal/context.d.ts +2 -0
  48. package/dist/types/types.d.ts +12 -0
  49. package/dist/vue-grid.css +1 -1
  50. package/llms-full.txt +78 -31
  51. package/llms.txt +1 -1
  52. package/package.json +1 -1
package/llms-full.txt CHANGED
@@ -48,6 +48,7 @@ runs in the [live examples](https://eboye.github.io/eboye-vue-grid/), each with
48
48
  | The user wants… | Feature(s) | Props / column options |
49
49
  | ------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
50
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` |
51
52
  | Filters per column, a filter row, quick search | `filteringFeature` | column `filterable: true` (`filter: 'text' \| 'number' \| 'date' \| 'boolean' \| 'set'`); `filter-row`; `<VGridSearch />` in `#toolbar` |
52
53
  | Pages | `paginationFeature` | `pagination` (or `{ pageSizes: [10, 25, 50] }`), `v-model:page`, `v-model:page-size` |
53
54
  | Backend sorting / filtering / paging | `serverDataFeature` (+ the above) | `:data-source="(query, { signal }) => Promise<{ rows, total }>"` |
@@ -501,6 +502,7 @@ only sees stylesheet rules. Density:
501
502
  ## Pitfalls
502
503
 
503
504
  - Nothing sorts → `sort-mode="client"` missing (or `sortingFeature` missing).
505
+ - Shift-click sorts by one column only → add `multi-sort`, and bind `v-model:sorts` (not `sort`) to read every key; a `dataSource` reads `query.sorts`.
504
506
  - Columns are squeezed / the page scrolls sideways → give `width`s (`minmax(8rem, 1fr)`); the grid
505
507
  scrolls horizontally inside itself when columns are wider than it.
506
508
  - Grid grows forever / no sticky header → no bounded height.
@@ -531,7 +533,7 @@ only sees stylesheet rules. Density:
531
533
 
532
534
  ---
533
535
 
534
- # @nocopypaste/vue-grid 0.8.0 — API reference
536
+ # @nocopypaste/vue-grid 0.9.0 — API reference
535
537
 
536
538
  > Generated from the TypeScript sources (`scripts/gen-agent.mjs`). Machine-readable: `agent/api.json`, `agent/grid-config.schema.json`.
537
539
 
@@ -557,7 +559,7 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
557
559
  | `selectionFeature` | Row selection: the `selectable` prop (multi or single), `v-model:selected`, `selection-mode` (cascade through sub-grids), `is-row-selectable`, Space on a row, shift-click (or Shift+Space) for a range, the select-all checkbox, `prune-selection`, and with server data a "select all N matching rows" banner (`v-model:select-all-matching`; it loads on demand, its own chunk). | `selectable` `selectionMode` `isRowSelectable` `pruneSelection` `selected` `selectAllMatching` | |
558
560
  | `serverDataFeature` | Server data: the `dataSource` prop. The grid sends sort, filters and page to your function, cancels superseded requests, and shows loading, error and retry states. | `dataSource` | |
559
561
  | `serverGroupingFeature` | Row grouping with server data: with `group-by` and a `data-source`, the query carries `groupBy` and `groupPath`, the server answers with groups (value, count, aggregates), and each group's contents load when it expands. A group's checkbox selects it by query (`v-model:selected-groups`), without loading its rows. Needs the row grouping and server data features too. Without it, a grouped server grid groups only the rows it has loaded. | `selectedGroups` | |
560
- | `sortingFeature` | Sorting: the sort button on `sortable` column headers, the sort items of the header menu and, with `sort-mode="client"`, sorting the rows in the browser. | | `sortable` `sortValue` `sortFn` |
562
+ | `sortingFeature` | Sorting: the sort button on `sortable` column headers, the sort items of the header menu and, with `sort-mode="client"`, sorting the rows in the browser. | `multiSort` `sorts` | `sortable` `sortValue` `sortFn` |
561
563
  | `statusBarFeature` | A status bar under the grid (`status-bar`): how many rows pass the filters ("84 of 200 rows"), how many are selected, how many filters are on (with Clear), and with `{ summary: ['total'] }` the sum and average of those columns over the selected rows, as the cells show them. The `#status-bar` slot replaces its content. Its component loads on demand (own chunk). | `statusBar` | |
562
564
  | `subGridsFeature` | Sub-grids: nested child rows in a CSS `subgrid`, from `sub-rows` (synchronous) or `load-sub-rows` (lazy, cached, with loading / error / retry). Detail rows (`#detail` slot) don't need it. | `subRows` `loadSubRows` `hasSubRows` | |
563
565
  | `virtualScrollingFeature` | Virtual scrolling: `:virtual="{ rowHeight, overscan?, detailHeight? }"` renders only the rows in view (plus `overscan`), so tens of thousands of rows stay fast — sub-grids and detail rows included, inside the same CSS grid / subgrid layout. Without it, `virtual` is ignored and every row renders. | `virtual` | |
@@ -612,12 +614,14 @@ Opt-in: pass them as `:features="[…]"` on `<VGrid>` or once via `createVueGrid
612
614
  | `totalsLabel` | `string` | | `aggregationFeature` | The totals row's label, in its first column (unless that column has an aggregate). Default: `messages.total`, else `Total`. |
613
615
  | `aggregates` | `Record<string, unknown>` | | `aggregationFeature` | Totals row values by column key, instead of computing them (e.g. totals from a server). |
614
616
  | `groupsExpanded` | `boolean` | `false` | `rowGroupingFeature` | Groups start expanded (row grouping feature). Default: collapsed. |
617
+ | `multiSort` | `boolean` | | `sortingFeature` | Multi-column sort (sorting feature): Shift-click (or Shift+Enter) on a header adds it as the next key, Shift-click again turns it descending, then removes it. `v-model:sorts` holds every key, `v-model:sort` the first; server queries get `sorts` too. |
615
618
 
616
619
  ## `v-model`s
617
620
 
618
621
  | Model | Type | Default | Needs | Description |
619
622
  |---|---|---|---|---|
620
623
  | `v-model:sort` | `SortState \| null` | `null` | | Sort state: a header click cycles asc → desc → none. Header UI needs the sorting feature. |
624
+ | `v-model:sorts` | `SortState[]` | `[]` | `sortingFeature` | Every sort key, the first one first (`multi-sort`). `sort` is the first of them. |
621
625
  | `v-model:columnState` | `ColumnState \| undefined` | `undefined` | | Column order, hidden columns, runtime pins and resized widths (persisted with `storage`). |
622
626
  | `v-model:expanded` | `RowKey[]` | `[]` | | Keys of expanded rows (sub-grids and detail rows). |
623
627
  | `v-model:selected` | `RowKey[]` | `[]` | `selectionFeature` | Keys of selected rows. Needs the selection feature. |
@@ -1379,34 +1383,34 @@ what you import.
1379
1383
 
1380
1384
  | Import (minified / gzip, Vue excluded) | Initial chunk |
1381
1385
  | ---------------------------------------------------------------------------- | ------------------ |
1382
- | `VGrid` (no features) | 43.1 kB / 14.8 kB |
1383
- | `VGrid` + `sortingFeature` | 43.8 kB / 15.1 kB |
1384
- | `VGrid` + `filteringFeature` | 53.8 kB / 18.6 kB |
1385
- | `VGrid` + `serverDataFeature` | 44.5 kB / 15.4 kB |
1386
- | `VGrid` + `paginationFeature` | 43.2 kB / 14.8 kB |
1387
- | `VGrid` + `selectionFeature` | 47.2 kB / 16.2 kB |
1388
- | `VGrid` + `subGridsFeature` | 45.4 kB / 15.6 kB |
1389
- | `VGrid` + `menusFeature` | 53.9 kB / 18.4 kB |
1390
- | `VGrid` + `columnReorderFeature` | 46.7 kB / 16.0 kB |
1391
- | `VGrid` + `columnPinningFeature` | 46.0 kB / 15.8 kB |
1392
- | `VGrid` + `virtualScrollingFeature` | 48.8 kB / 17.0 kB |
1393
- | `VGrid` + `columnVisibilityFeature` | 43.2 kB / 14.8 kB |
1394
- | `VGrid` + `keyboardNavigationFeature` | 45.8 kB / 15.8 kB |
1395
- | `VGrid` + `columnResizingFeature` | 46.3 kB / 16.0 kB |
1396
- | `VGrid` + `columnGroupsFeature` | 44.4 kB / 15.2 kB |
1397
- | `VGrid` + `rowPinningFeature` | 48.0 kB / 16.1 kB |
1398
- | `VGrid` + `aggregationFeature` | 48.2 kB / 16.2 kB |
1399
- | `VGrid` + `rowGroupingFeature` | 53.8 kB / 18.3 kB |
1400
- | `VGrid` + `exportFeature` | 48.0 kB / 16.7 kB |
1401
- | `VGrid` + `statusBarFeature` | 45.5 kB / 15.7 kB |
1402
- | `VGrid` + `serverGroupingFeature` | 46.2 kB / 15.9 kB |
1403
- | `VGrid` + `allFeatures` + `VGridSearch` | 115.0 kB / 38.6 kB |
1404
- | `VGrid` + `currencyRenderer` | 44.4 kB / 15.2 kB |
1405
- | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 50.3 kB / 17.2 kB |
1386
+ | `VGrid` (no features) | 43.7 kB / 15.0 kB |
1387
+ | `VGrid` + `sortingFeature` | 46.4 kB / 16.0 kB |
1388
+ | `VGrid` + `filteringFeature` | 54.5 kB / 18.9 kB |
1389
+ | `VGrid` + `serverDataFeature` | 45.2 kB / 15.6 kB |
1390
+ | `VGrid` + `paginationFeature` | 43.9 kB / 15.1 kB |
1391
+ | `VGrid` + `selectionFeature` | 47.9 kB / 16.5 kB |
1392
+ | `VGrid` + `subGridsFeature` | 46.1 kB / 15.8 kB |
1393
+ | `VGrid` + `menusFeature` | 55.0 kB / 18.8 kB |
1394
+ | `VGrid` + `columnReorderFeature` | 47.4 kB / 16.3 kB |
1395
+ | `VGrid` + `columnPinningFeature` | 46.7 kB / 16.1 kB |
1396
+ | `VGrid` + `virtualScrollingFeature` | 49.5 kB / 17.2 kB |
1397
+ | `VGrid` + `columnVisibilityFeature` | 43.9 kB / 15.1 kB |
1398
+ | `VGrid` + `keyboardNavigationFeature` | 46.5 kB / 16.0 kB |
1399
+ | `VGrid` + `columnResizingFeature` | 47.0 kB / 16.3 kB |
1400
+ | `VGrid` + `columnGroupsFeature` | 45.0 kB / 15.5 kB |
1401
+ | `VGrid` + `rowPinningFeature` | 48.7 kB / 16.3 kB |
1402
+ | `VGrid` + `aggregationFeature` | 48.9 kB / 16.5 kB |
1403
+ | `VGrid` + `rowGroupingFeature` | 54.6 kB / 18.6 kB |
1404
+ | `VGrid` + `exportFeature` | 48.7 kB / 16.9 kB |
1405
+ | `VGrid` + `statusBarFeature` | 46.2 kB / 16.0 kB |
1406
+ | `VGrid` + `serverGroupingFeature` | 46.8 kB / 16.2 kB |
1407
+ | `VGrid` + `allFeatures` + `VGridSearch` | 118.3 kB / 39.8 kB |
1408
+ | `VGrid` + `currencyRenderer` | 45.1 kB / 15.5 kB |
1409
+ | `VGrid` + `VGridPagination` + `VGridColumnMenu` | 51.0 kB / 17.5 kB |
1406
1410
  | `sortRows` only | 0.7 kB / 0.4 kB |
1407
1411
  | `toCsv` only | 1.1 kB / 0.6 kB |
1408
- | everything | 168.7 kB / 54.0 kB |
1409
- | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 72.9 kB / 19.8 kB |
1412
+ | everything | 171.9 kB / 55.2 kB |
1413
+ | `validateGridConfig` (`@nocopypaste/vue-grid/agent`, never in an app bundle) | 73.4 kB / 20.0 kB |
1410
1414
 
1411
1415
  With `filteringFeature`, the filter popover body and the filter-row editors are **on-demand
1412
1416
  chunks**: they load the first time a popover opens or `filter-row` is on. With
@@ -1431,6 +1435,8 @@ chunks that on-demand imports share with the entry, even when nothing uses them.
1431
1435
  | `columns` | `ColumnDef<T>[]` | — | See below. |
1432
1436
  | `rowKey` | `keyof T \| (row) => string \| number` | — | Stable unique id; all row state is keyed by it. |
1433
1437
  | `v-model:sort` | `{ key, dir: 'asc' \| 'desc' } \| null` | `null` | Header click cycles asc → desc → none. Needs `sortingFeature` for the header UI. |
1438
+ | `multiSort` | `boolean` | `false` | Shift-click (Shift+Enter) a header to sort by it next; `v-model:sorts` holds every key. See [Sorting](#sorting). |
1439
+ | `v-model:sorts` | `SortState[]` | `[]` | Every sort key, the first one first (with `multiSort`). `sort` follows its first key. |
1434
1440
  | `sortMode` | `'controlled' \| 'client'` | `'controlled'` | `controlled` only emits (server-side sorting). Ignored with `dataSource`. |
1435
1441
  | `v-model:filters` | `FilterState \| null` | `null` | `{ columns: Record<key, ColumnFilter>, search }`. Needs `filteringFeature` (as do the next four). See [Filtering](#filtering). |
1436
1442
  | `filterMode` | `'client' \| 'controlled'` | `'client'` | `controlled` only emits (server-side filtering). Ignored with `dataSource`. |
@@ -1703,7 +1709,7 @@ typeahead move through items; focus returns to the cell on close.
1703
1709
  ### Column headers
1704
1710
 
1705
1711
  Right-clicking a header opens a built-in menu: **Sort ascending / descending / Clear sort** (sortable
1706
- columns), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
1712
+ columns; with `multi-sort` also **Then sort ascending / descending**, and Clear sort drops only that column), **Pin left / Pin right / Unpin**, **Move left / right**, **Hide column**, **Reset columns**.
1707
1713
  Pin items need `columnPinningFeature`, move items `columnReorderFeature`, Hide column `columnVisibilityFeature`. Runtime pins are stored in column state (`columnState.pinned`) and persisted with `storage`.
1708
1714
 
1709
1715
  ```vue
@@ -1730,6 +1736,47 @@ The same component powers the `actions-menu` renderer and is exported for add-on
1730
1736
  <!-- or imperatively: menuRef.value.openAt(element | { x, y }) -->
1731
1737
  ```
1732
1738
 
1739
+ ## Sorting
1740
+
1741
+ A `sortable` column (with `sortingFeature`) sorts on a header click: ascending, descending, none.
1742
+ `v-model:sort` holds `{ key, dir }`. The grid sorts the rows itself with `sort-mode="client"`;
1743
+ otherwise it only updates `sort` (or asks the `dataSource`). Values sort by type (numbers, dates,
1744
+ text with `localeCompare`), a renderer can define its sort value, and a column can override it with
1745
+ `sortValue: (row) => …` or `sortFn: (a, b) => …`. Empty values sort last in both directions.
1746
+
1747
+ **Several columns.** With `multi-sort`, Shift-click a header (Shift+Enter on a focused one) to sort
1748
+ by it after the others: ascending, then descending, then removed. A plain click still sorts by that
1749
+ column alone. The headers show each column's number (1, 2, …); `aria-sort` stays on the first key, as
1750
+ the ARIA grid pattern has it, and screen readers hear the rest as “sorted 2 of 3, descending”. The
1751
+ header menu adds **Then sort ascending / descending**.
1752
+
1753
+ ```vue
1754
+ <script setup lang="ts">
1755
+ import { VGrid, sortingFeature, type SortState } from '@nocopypaste/vue-grid'
1756
+ const sorts = ref<SortState[]>([
1757
+ { key: 'city', dir: 'asc' },
1758
+ { key: 'stake', dir: 'desc' },
1759
+ ])
1760
+ </script>
1761
+
1762
+ <template>
1763
+ <VGrid
1764
+ v-model:sorts="sorts"
1765
+ multi-sort
1766
+ sort-mode="client"
1767
+ :rows
1768
+ :columns
1769
+ row-key="id"
1770
+ :features="[sortingFeature]"
1771
+ />
1772
+ </template>
1773
+ ```
1774
+
1775
+ `v-model:sort` keeps working beside it: it is the first key, and setting it from outside makes it
1776
+ the only one. A `dataSource` gets every key in `query.sorts` (only with `multi-sort`; `query.sort`
1777
+ is still the first). Row groups follow their own column's key wherever it is in the list.
1778
+ `sortRowsBy(rows, keys)` and `nextSorts(sorts, key)` sort and cycle without a grid.
1779
+
1733
1780
  ## Filtering
1734
1781
 
1735
1782
  ```vue
@@ -1875,7 +1922,7 @@ import {
1875
1922
  } from '@nocopypaste/vue-grid'
1876
1923
 
1877
1924
  const fetchBets: DataSource<Bet> = async (query, { signal }) => {
1878
- // query: { sort: { key, dir } | null, filters: FilterState, page: number, pageSize: number | null }
1925
+ // query: { sort: { key, dir } | null, sorts?: SortState[] (multi-sort), filters: FilterState, page: number, pageSize: number | null }
1879
1926
  const res = await fetch('/api/bets', { method: 'POST', body: JSON.stringify(query), signal })
1880
1927
  if (!res.ok) throw new Error(res.statusText)
1881
1928
  return res.json() // { rows: Bet[], total?: number }
@@ -2345,7 +2392,7 @@ and the grid's own controls (sort buttons, expanders, checkboxes, filter buttons
2345
2392
  normal Tab order.
2346
2393
 
2347
2394
  With `keyboardNavigationFeature` it is an ARIA `grid` (`treegrid` with sub-grids). The grid is one tab stop. Arrow keys move between cells (header, rows, sub-grid rows, detail rows),
2348
- `Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header or activates the
2395
+ `Home`/`End`, `Ctrl+Home`/`Ctrl+End`, `PageUp`/`PageDown`; `ContextMenu` / `Shift+F10` opens the context menu. `Enter` sorts a header (`Shift+Enter` adds it with `multi-sort`) or activates the
2349
2396
  cell's control; `Space` toggles row selection; `→`/`←` on a tree cell expands/collapses; `Alt+←/→` on a
2350
2397
  header moves the column; `Alt+Shift+←/→` on a header resizes it (with `columnResizingFeature`).
2351
2398
 
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # @nocopypaste/vue-grid
2
2
 
3
- > A Vue 3 data grid laid out with CSS Grid and `subgrid`. A plain grid is a read-only table (14.8 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping (also on the server), CSV and Excel export, printing, copying, a status bar, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Every built-in text is translatable (`messages`) and every piece a feature adds can be turned off (`parts`). Typed end to end, accessible, themeable with CSS variables, mobile and touch ready.
3
+ > A Vue 3 data grid laid out with CSS Grid and `subgrid`. A plain grid is a read-only table (15.0 kB gzip); sorting, filtering, server data, pagination, selection, sub-grids, menus, column pinning / reordering / resizing / visibility / groups, pinned rows, totals, row grouping (also on the server), CSV and Excel export, printing, copying, a status bar, virtual scrolling and keyboard navigation are opt-in features, and 29 cell renderers are opt-in imports. Every built-in text is translatable (`messages`) and every piece a feature adds can be turned off (`parts`). Typed end to end, accessible, themeable with CSS variables, mobile and touch ready.
4
4
 
5
5
  Read AGENTS.md first: it lists the rules that cause silent bugs when skipped (register features, pass renderer definitions, `sort-mode="client"`, bounded height), a "which feature for what" table and copy-paste recipes. Validate a grid config with `validateGridConfig()` from `@nocopypaste/vue-grid/agent`.
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocopypaste/vue-grid",
3
- "version": "0.8.0",
3
+ "version": "0.9.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",