@nocopypaste/vue-grid 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/AGENTS.md +68 -32
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +140 -29
  4. package/agent/api.json +85 -2
  5. package/agent/api.md +13 -2
  6. package/agent/grid-config.schema.json +41 -0
  7. package/dist/agent/api.js +80 -2
  8. package/dist/agent/requirements.js +9 -2
  9. package/dist/agent/requirements.js.map +1 -1
  10. package/dist/base.css +1 -1
  11. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js +595 -576
  12. package/dist/components/VGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js +78 -56
  14. package/dist/components/VGridCell.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/VGridCellEditor.js +6 -0
  16. package/dist/components/VGridCellEditor.js.map +1 -0
  17. package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js +208 -0
  18. package/dist/components/VGridCellEditor.vue_vue_type_script_setup_true_lang.js.map +1 -0
  19. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js +82 -53
  20. package/dist/components/VGridHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/VGridSortMarker.js +6 -0
  22. package/dist/components/VGridSortMarker.js.map +1 -0
  23. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js +21 -0
  24. package/dist/components/VGridSortMarker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  25. package/dist/composables/useDataSource.js.map +1 -1
  26. package/dist/composables/useEditing.js +202 -0
  27. package/dist/composables/useEditing.js.map +1 -0
  28. package/dist/composables/useGridKeyboard.js +5 -1
  29. package/dist/composables/useGridKeyboard.js.map +1 -1
  30. package/dist/composables/useGridMenus.js +24 -12
  31. package/dist/composables/useGridMenus.js.map +1 -1
  32. package/dist/composables/useRowGrouping.js.map +1 -1
  33. package/dist/composables/useSorting.js +48 -0
  34. package/dist/composables/useSorting.js.map +1 -0
  35. package/dist/core/grouping.js +1 -1
  36. package/dist/core/grouping.js.map +1 -1
  37. package/dist/core/sort.js +31 -1
  38. package/dist/core/sort.js.map +1 -1
  39. package/dist/core/value.js +18 -2
  40. package/dist/core/value.js.map +1 -1
  41. package/dist/core.css +1 -1
  42. package/dist/features/editing.js +12 -0
  43. package/dist/features/editing.js.map +1 -0
  44. package/dist/features/index.js +30 -28
  45. package/dist/features/index.js.map +1 -1
  46. package/dist/features/sorting.js +8 -4
  47. package/dist/features/sorting.js.map +1 -1
  48. package/dist/index.js +63 -62
  49. package/dist/internal/context.js.map +1 -1
  50. package/dist/internal/features.js.map +1 -1
  51. package/dist/theme.css +1 -1
  52. package/dist/types/agent/requirements.d.ts +1 -1
  53. package/dist/types/components/VGrid.vue.d.ts +20 -4
  54. package/dist/types/components/VGridCellEditor.vue.d.ts +11 -0
  55. package/dist/types/components/VGridHeader.vue.d.ts +4 -3
  56. package/dist/types/components/VGridSortMarker.vue.d.ts +9 -0
  57. package/dist/types/composables/useDataSource.d.ts +3 -0
  58. package/dist/types/composables/useEditing.d.ts +73 -0
  59. package/dist/types/composables/useGridMenus.d.ts +5 -0
  60. package/dist/types/composables/useRowGrouping.d.ts +2 -1
  61. package/dist/types/composables/useSorting.d.ts +24 -0
  62. package/dist/types/core/grouping.d.ts +5 -2
  63. package/dist/types/core/sort.d.ts +16 -0
  64. package/dist/types/core/value.d.ts +6 -0
  65. package/dist/types/features/editing.d.ts +2 -0
  66. package/dist/types/features/index.d.ts +2 -1
  67. package/dist/types/index.d.ts +2 -2
  68. package/dist/types/internal/context.d.ts +6 -0
  69. package/dist/types/internal/features.d.ts +2 -1
  70. package/dist/types/types.d.ts +112 -1
  71. package/dist/vue-grid.css +1 -1
  72. package/llms-full.txt +221 -63
  73. package/llms.txt +1 -1
  74. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import type { RowGroup } from '../core/grouping';
2
2
  import { type RowKeyGetter } from '../core/value';
3
3
  import type { DataSource, GridQuery, GroupPath } from '../composables/useDataSource';
4
- import type { CellActionEvent, CellClickEvent, CellContext, CellRendererDefinition, ClassValue, ColumnDef, ColumnState, FlashMode, FilterState, GridFeature, FilterStateStorage, ColumnStateStorage, ContextActionEvent, CopyEvent, Density, GridPart, HeaderActionEvent, HeaderMenuContext, MenuItem, PinnedRowsState, RowKey, SortState, PaginationOptions, StatusBarOptions, StatusBarScope, GridMessages, GridParts, VGridExposed, VirtualOptions } from '../types';
4
+ import type { CellActionEvent, CellClickEvent, CellEditEvent, CellContext, CellRendererDefinition, ClassValue, ColumnDef, ColumnState, FlashMode, FilterState, GridFeature, FilterStateStorage, ColumnStateStorage, ContextActionEvent, CopyEvent, Density, GridPart, HeaderActionEvent, HeaderMenuContext, MenuItem, PinnedRowsState, RowKey, SortState, PaginationOptions, StatusBarOptions, StatusBarScope, GridMessages, GridParts, VGridExposed, VirtualOptions } from '../types';
5
5
  declare const _default: typeof __VLS_export;
6
6
  export default _default;
7
7
  declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
@@ -32,6 +32,12 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
32
32
  * average of those columns over the selected rows. `#status-bar` replaces its content.
33
33
  */
34
34
  statusBar?: boolean | StatusBarOptions;
35
+ /**
36
+ * Saves an edited cell (editing feature), after `cell-edit`: return a Promise and the cell shows
37
+ * it saving; a rejection keeps the editor open with the error's message. Without it, `cell-edit`
38
+ * alone carries the change.
39
+ */
40
+ saveCell?: (event: CellEditEvent<T>) => unknown;
35
41
  /** Built-in text (translations, wording), over `createVueGrid({ messages })`. */
36
42
  messages?: GridMessages;
37
43
  /** Built-in parts to leave out (`{ progressBar: false }`), over `createVueGrid({ parts })`. */
@@ -132,9 +138,17 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
132
138
  aggregates?: Record<string, unknown>;
133
139
  /** Groups start expanded (row grouping feature). Default: collapsed. */
134
140
  groupsExpanded?: boolean;
141
+ /**
142
+ * Multi-column sort (sorting feature): Shift-click (or Shift+Enter) on a header adds it as the
143
+ * next key, Shift-click again turns it descending, then removes it. `v-model:sorts` holds every
144
+ * key, `v-model:sort` the first; server queries get `sorts` too.
145
+ */
146
+ multiSort?: boolean;
135
147
  } & {
136
148
  /** Sort state: a header click cycles asc → desc → none. Header UI needs the sorting feature. */
137
149
  sort?: SortState | null;
150
+ /** Every sort key, the first one first (`multi-sort`). `sort` is the first of them. */
151
+ sorts?: SortState[];
138
152
  /** Column order, hidden columns, runtime pins and resized widths (persisted with `storage`). */
139
153
  columnState?: ColumnState | undefined;
140
154
  /** Keys of expanded rows (sub-grids and detail rows). */
@@ -170,9 +184,10 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
170
184
  onCopy?: ((event: CopyEvent<T>) => any) | undefined;
171
185
  "onQuery-change"?: ((query: GridQuery) => any) | undefined;
172
186
  "onLoad-error"?: ((error: unknown) => any) | undefined;
173
- "onRow-click"?: ((row: T, event: MouseEvent | KeyboardEvent) => any) | undefined;
187
+ "onRow-click"?: ((row: T, event: KeyboardEvent | MouseEvent) => any) | undefined;
174
188
  "onCell-click"?: ((event: CellClickEvent<T>) => any) | undefined;
175
189
  "onCell-action"?: ((event: CellActionEvent<T>) => any) | undefined;
190
+ "onCell-edit"?: ((event: CellEditEvent<T>) => any) | undefined;
176
191
  "onSub-rows-error"?: ((event: {
177
192
  row: T;
178
193
  error: unknown;
@@ -180,6 +195,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
180
195
  "onContext-action"?: ((event: ContextActionEvent<T>) => any) | undefined;
181
196
  "onHeader-action"?: ((event: HeaderActionEvent<T>) => any) | undefined;
182
197
  "onUpdate:sort"?: ((value: SortState | null) => any) | undefined;
198
+ "onUpdate:sorts"?: ((value: SortState[]) => any) | undefined;
183
199
  "onUpdate:columnState"?: ((value: ColumnState | undefined) => any) | undefined;
184
200
  "onUpdate:expanded"?: ((value: RowKey[]) => any) | undefined;
185
201
  "onUpdate:selected"?: ((value: RowKey[]) => any) | undefined;
@@ -279,10 +295,10 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
279
295
  clearSelection: () => void;
280
296
  }) => unknown;
281
297
  };
282
- emit: (((evt: "copy", event: CopyEvent<T>) => void) & ((evt: "query-change", query: GridQuery) => void) & ((evt: "load-error", error: unknown) => void) & ((evt: "row-click", row: T, event: MouseEvent | KeyboardEvent) => void) & ((evt: "cell-click", event: CellClickEvent<T>) => void) & ((evt: "cell-action", event: CellActionEvent<T>) => void) & ((evt: "sub-rows-error", event: {
298
+ emit: (((evt: "copy", event: CopyEvent<T>) => void) & ((evt: "query-change", query: GridQuery) => void) & ((evt: "load-error", error: unknown) => void) & ((evt: "row-click", row: T, event: KeyboardEvent | MouseEvent) => void) & ((evt: "cell-click", event: CellClickEvent<T>) => void) & ((evt: "cell-action", event: CellActionEvent<T>) => void) & ((evt: "cell-edit", event: CellEditEvent<T>) => void) & ((evt: "sub-rows-error", event: {
283
299
  row: T;
284
300
  error: unknown;
285
- }) => void) & ((evt: "context-action", event: ContextActionEvent<T>) => void) & ((evt: "header-action", event: HeaderActionEvent<T>) => void)) & (((event: "update:sort", value: SortState | null) => void) & ((event: "update:columnState", value: ColumnState | undefined) => void) & ((event: "update:expanded", value: RowKey[]) => void) & ((event: "update:selected", value: RowKey[]) => void) & ((event: "update:filters", value: FilterState | null) => void) & ((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: number) => void) & ((event: "update:pinnedRows", value: PinnedRowsState | null) => void) & ((event: "update:groupBy", value: string | readonly string[] | null) => void) & ((event: "update:selectAllMatching", value: boolean) => void) & ((event: "update:selectedGroups", value: GroupPath[]) => void));
301
+ }) => void) & ((evt: "context-action", event: ContextActionEvent<T>) => void) & ((evt: "header-action", event: HeaderActionEvent<T>) => void)) & (((event: "update:sort", value: SortState | null) => void) & ((event: "update:sorts", value: SortState[]) => void) & ((event: "update:columnState", value: ColumnState | undefined) => void) & ((event: "update:expanded", value: RowKey[]) => void) & ((event: "update:selected", value: RowKey[]) => void) & ((event: "update:filters", value: FilterState | null) => void) & ((event: "update:page", value: number) => void) & ((event: "update:pageSize", value: number) => void) & ((event: "update:pinnedRows", value: PinnedRowsState | null) => void) & ((event: "update:groupBy", value: string | readonly string[] | null) => void) & ((event: "update:selectAllMatching", value: boolean) => void) & ((event: "update:selectedGroups", value: GroupPath[]) => void));
286
302
  }>) => import("vue").VNode & {
287
303
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
288
304
  };
@@ -0,0 +1,11 @@
1
+ import { type ResolvedColumn } from '../internal/context';
2
+ import type { RowKey } from '../types';
3
+ /** The editor inside a cell being edited (editing feature). */
4
+ type __VLS_Props = {
5
+ row: unknown;
6
+ rowKey: RowKey;
7
+ column: ResolvedColumn;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -1,7 +1,8 @@
1
1
  import type { SelectionSummary } from '../core/selection';
2
2
  import type { SortState } from '../types';
3
3
  type __VLS_Props = {
4
- sort: SortState | null | undefined;
4
+ /** The sort keys, the first one first. */
5
+ sorts: readonly SortState[];
5
6
  allState: SelectionSummary;
6
7
  hasSelectableRows: boolean;
7
8
  dragging: string | null;
@@ -12,12 +13,12 @@ type __VLS_Props = {
12
13
  canReorder: (key: string) => boolean;
13
14
  };
14
15
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
- sort: (key: string) => any;
16
+ sort: (key: string, add: boolean) => any;
16
17
  toggleAll: () => any;
17
18
  dragStart: (event: PointerEvent, key: string) => any;
18
19
  headerClick: (event: MouseEvent) => any;
19
20
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
- onSort?: ((key: string) => any) | undefined;
21
+ onSort?: ((key: string, add: boolean) => any) | undefined;
21
22
  onToggleAll?: (() => any) | undefined;
22
23
  onDragStart?: ((event: PointerEvent, key: string) => any) | undefined;
23
24
  onHeaderClick?: ((event: MouseEvent) => any) | undefined;
@@ -0,0 +1,9 @@
1
+ /** A column's place in a multi-column sort (sorting feature): its number, and for screen readers its direction. */
2
+ type __VLS_Props = {
3
+ position: number;
4
+ count: number;
5
+ dir: 'asc' | 'desc';
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -4,7 +4,10 @@ import type { FilterState } from '../core/filter';
4
4
  import type { SortState } from '../types';
5
5
  /** Everything a backend needs to produce the rows the grid shows. */
6
6
  export interface GridQuery {
7
+ /** The sort (with `multi-sort`, its first key). */
7
8
  sort: SortState | null;
9
+ /** With `multi-sort`: every sort key, the first one first (absent without it). */
10
+ sorts?: SortState[];
8
11
  filters: FilterState;
9
12
  /** 1-based; with `pageSize: null` (no pagination) always 1. */
10
13
  page: number;
@@ -0,0 +1,73 @@
1
+ import { type Ref } from 'vue';
2
+ import type { CellEditEvent, CellRendererDefinition, ColumnDef, EditorName, EditorOption, GridMessages, RowKey } from '../types';
3
+ /** What the open editor edits. */
4
+ export interface EditState<T = unknown> {
5
+ row: T;
6
+ rowKey: RowKey;
7
+ column: ColumnDef<T>;
8
+ definition: CellRendererDefinition | undefined;
9
+ /** Started by typing: this text replaces the value. */
10
+ initial?: string;
11
+ /** Enter / Tab pressed while the editor was still opening: done once it opens. */
12
+ queued?: EditMove;
13
+ /** A value that failed validation or saving, shown again in the editor. */
14
+ draft?: {
15
+ value: unknown;
16
+ };
17
+ error?: string;
18
+ saving: boolean;
19
+ }
20
+ export interface EditingOptions<T> {
21
+ root: Ref<HTMLElement | undefined>;
22
+ messages: () => GridMessages;
23
+ emit: (event: CellEditEvent<T>) => void;
24
+ /** `save-cell`: may return a Promise; a rejection keeps the editor open with its message. */
25
+ save: () => ((event: CellEditEvent<T>) => unknown) | undefined;
26
+ /** The rows a select's default choices come from (their distinct values). */
27
+ rows: () => readonly T[];
28
+ columns: () => readonly ColumnDef<T>[];
29
+ /** Loads the editor's chunk. */
30
+ preload: () => Promise<unknown>;
31
+ }
32
+ /** What a cell tells the editing feature about itself. */
33
+ export interface EditCell<T> {
34
+ row: T;
35
+ rowKey: RowKey;
36
+ pinned?: boolean;
37
+ column: {
38
+ kind: string;
39
+ key: string;
40
+ def: ColumnDef<T>;
41
+ definition: CellRendererDefinition | undefined;
42
+ };
43
+ }
44
+ /** Where focus goes after a commit: the next / previous editable cell, or back to this cell. */
45
+ export type EditMove = -1 | 0 | 1;
46
+ /** The editor a column gets: its own, else one that fits its renderer. */
47
+ export declare function editorOf(column: ColumnDef, definition: CellRendererDefinition | undefined): EditorName | 'custom';
48
+ /**
49
+ * Inline cell editing (editing feature): one editor at a time. Opens on double-click, Enter / F2
50
+ * or typing on a focused cell; Enter commits, Tab commits and edits the next editable cell, Esc
51
+ * cancels. A commit validates, emits `cell-edit` and awaits `save-cell`; the grid never writes the
52
+ * value itself.
53
+ */
54
+ export declare function useEditing<T>(opts: EditingOptions<T>): {
55
+ forCell: (cell: () => EditCell<T>) => {
56
+ editable: import("vue").ComputedRef<boolean>;
57
+ active: import("vue").ComputedRef<boolean>;
58
+ onKeyDown(event: KeyboardEvent): void;
59
+ onDblClick(event: MouseEvent): void;
60
+ };
61
+ state: import("vue").ShallowRef<EditState<T> | null, EditState<T> | null>;
62
+ canEdit: (row: T, column: ColumnDef<T>) => boolean;
63
+ isEditing: (rowKey: RowKey, key: string) => boolean;
64
+ start: (row: T, rowKey: RowKey, column: ColumnDef<T>, definition: CellRendererDefinition | undefined, initial?: string) => boolean;
65
+ commit: (value: unknown, move?: EditMove | "blur") => Promise<void>;
66
+ cancel: (refocus?: boolean) => void;
67
+ stop: (cancelIt?: boolean) => void;
68
+ register: (fn: (() => unknown) | null) => (() => unknown) | null;
69
+ choices: (column: ColumnDef<T>) => EditorOption[];
70
+ onCellKeyDown: (event: KeyboardEvent, row: T, rowKey: RowKey, column: ColumnDef<T>, definition: CellRendererDefinition | undefined) => void;
71
+ startAt: (rowKey: RowKey, key: string) => boolean;
72
+ };
73
+ export type Editing<T = unknown> = ReturnType<typeof useEditing<T>>;
@@ -12,6 +12,11 @@ export interface GridMenusOptions<T> {
12
12
  columnState: () => ColumnState;
13
13
  setColumnState: (state: ColumnState) => void;
14
14
  sort: Ref<SortState | null>;
15
+ /** Every sort key (multi-column sort), the first one first. */
16
+ sorts: () => readonly SortState[];
17
+ setSorts: (sorts: SortState[]) => void;
18
+ /** `multi-sort` is on: the menu can add a column as a further key. */
19
+ multiSort: () => boolean;
15
20
  /** Whether a column can be sorted (the sorting feature is on and the column is `sortable`). */
16
21
  sortable: (column: ColumnDef<T>) => boolean;
17
22
  /** Whether the pin items show (the pinning feature is on and the column is `pinnable`). */
@@ -11,7 +11,8 @@ export interface RowGroupingOptions<T> {
11
11
  columns: () => readonly ColumnDef<T>[];
12
12
  /** The rows to group: filtered and sorted. */
13
13
  rows: () => readonly T[];
14
- sort: () => SortState | null;
14
+ /** The sort keys (multi-column sort: every key). */
15
+ sort: () => readonly SortState[];
15
16
  /** The `groups-expanded` prop: groups start expanded. */
16
17
  expandedByDefault: () => boolean;
17
18
  /** The selected row keys (a group's checkbox selects its rows). */
@@ -0,0 +1,24 @@
1
+ import { type Ref } from 'vue';
2
+ import type { ColumnDef, SortState } from '../types';
3
+ export interface SortingOptions<T> {
4
+ /** `v-model:sort`: the (first) sort key. */
5
+ sort: Ref<SortState | null>;
6
+ /** `v-model:sorts`: every key (multi-column sort). */
7
+ sorts: Ref<SortState[]>;
8
+ multiSort: () => boolean;
9
+ /** The grid sorts its rows itself (`sort-mode="client"`, no data source). */
10
+ client: () => boolean;
11
+ columns: () => readonly ColumnDef<T>[];
12
+ /** A column's value to sort by: its `sortValue`, the renderer's, or the cell value. */
13
+ valueOf: (col: ColumnDef<T>) => (row: T) => unknown;
14
+ }
15
+ /**
16
+ * The sorting feature's state: the sort keys (one, or several with `multi-sort`), kept in step
17
+ * with `v-model:sort` / `v-model:sorts`, header clicks (Shift adds a key), and the client sorter.
18
+ */
19
+ export declare function useSorting<T>(opts: SortingOptions<T>): {
20
+ list: import("vue").ComputedRef<SortState[]>;
21
+ set: (next: SortState[]) => void;
22
+ onSort: (key: string, add?: boolean) => void;
23
+ sorter: () => ((rows: readonly T[]) => T[]) | undefined;
24
+ };
@@ -47,8 +47,11 @@ export interface GroupRowsOptions<T> {
47
47
  columns: readonly ColumnDef<T>[];
48
48
  /** Every column: the ones with an `aggregate` get group aggregates. */
49
49
  allColumns: readonly ColumnDef<T>[];
50
- /** Groups of the sorted column follow its direction; other groups are ascending. */
51
- sort?: SortState | null;
50
+ /**
51
+ * Groups of a sorted column follow its direction; other groups are ascending. One sort, or every
52
+ * key of a multi-column sort.
53
+ */
54
+ sort?: SortState | readonly SortState[] | null;
52
55
  }
53
56
  /**
54
57
  * Groups rows by one or more columns. The rows keep their order inside each group (pass them
@@ -8,3 +8,19 @@ export declare function compareValues(a: unknown, b: unknown): number;
8
8
  * regardless of direction. `compare`, when given, replaces value comparison entirely.
9
9
  */
10
10
  export declare function sortRows<T>(rows: readonly T[], dir: SortDir, getValue: (row: T) => unknown, compare?: (a: T, b: T) => number): T[];
11
+ /** One key of a multi-column sort: a direction and how to read (or compare) the rows. */
12
+ export interface SortKey<T> {
13
+ dir: SortDir;
14
+ getValue: (row: T) => unknown;
15
+ compare?: (a: T, b: T) => number;
16
+ }
17
+ /**
18
+ * Stable sort by several keys, the first one first: ties on a key go to the next. Per key, nil
19
+ * values go last whatever the direction, and `compare` replaces value comparison. Never mutates.
20
+ */
21
+ export declare function sortRowsBy<T>(rows: readonly T[], keys: readonly SortKey<T>[]): T[];
22
+ /**
23
+ * Shift-click on a header in a multi-column sort: a new key is added ascending, an ascending one
24
+ * turns descending, a descending one is removed.
25
+ */
26
+ export declare function nextSorts(current: readonly SortState[], key: string): SortState[];
@@ -2,5 +2,11 @@ import type { ColumnDef, RowKey } from '../types';
2
2
  /** Reads a dot path (`a.b.c`) from own properties only — never walks the prototype chain. */
3
3
  export declare function getByPath(source: unknown, path: string): unknown;
4
4
  export declare function getCellValue<T>(row: T, column: Pick<ColumnDef<T>, 'key' | 'field' | 'value'>): unknown;
5
+ /**
6
+ * Writes a cell value into its row along the column's `field` (or `key`) path, e.g. in a
7
+ * `cell-edit` handler: `setCellValue(e.row, e.column, e.value)`. Returns `false` when it can't: a
8
+ * computed column (`value` without `field`), or a path through a missing object.
9
+ */
10
+ export declare function setCellValue<T>(row: T, column: Pick<ColumnDef<T>, 'key' | 'field' | 'value'>, value: unknown): boolean;
5
11
  export type RowKeyGetter<T> = keyof T | ((row: T) => RowKey);
6
12
  export declare function resolveRowKey<T>(row: T, rowKey: RowKeyGetter<T>): RowKey;
@@ -0,0 +1,2 @@
1
+ import type { EditingFeature } from '../types';
2
+ export declare const editingFeature: EditingFeature;
@@ -5,6 +5,7 @@ import { columnPinningFeature } from './columnPinning';
5
5
  import { columnResizingFeature } from './columnResizing';
6
6
  import { columnReorderFeature } from './columnReorder';
7
7
  import { columnVisibilityFeature } from './columnVisibility';
8
+ import { editingFeature } from './editing';
8
9
  import { exportFeature } from './export';
9
10
  import { filteringFeature } from './filtering';
10
11
  import { keyboardNavigationFeature } from './keyboardNavigation';
@@ -19,6 +20,6 @@ import { sortingFeature } from './sorting';
19
20
  import { statusBarFeature } from './statusBar';
20
21
  import { subGridsFeature } from './subGrids';
21
22
  import { virtualScrollingFeature } from './virtualScrolling';
22
- export { aggregationFeature, columnGroupsFeature, columnPinningFeature, columnReorderFeature, columnResizingFeature, columnVisibilityFeature, exportFeature, filteringFeature, keyboardNavigationFeature, menusFeature, paginationFeature, rowGroupingFeature, rowPinningFeature, selectionFeature, serverDataFeature, serverGroupingFeature, sortingFeature, statusBarFeature, subGridsFeature, virtualScrollingFeature, };
23
+ export { aggregationFeature, columnGroupsFeature, columnPinningFeature, columnReorderFeature, columnResizingFeature, columnVisibilityFeature, editingFeature, exportFeature, filteringFeature, keyboardNavigationFeature, menusFeature, paginationFeature, rowGroupingFeature, rowPinningFeature, selectionFeature, serverDataFeature, serverGroupingFeature, sortingFeature, statusBarFeature, subGridsFeature, virtualScrollingFeature, };
23
24
  /** Every built-in feature, for apps that want them all: `createVueGrid({ features: allFeatures })`. */
24
25
  export declare const allFeatures: readonly GridFeature[];
@@ -6,9 +6,9 @@ export { default as VGridSearch } from './components/VGridSearch.vue';
6
6
  export { anchorNameFor, supportsAnchorPositioning } from './internal/anchor';
7
7
  export { createVueGrid, useGridContext, GRID_CONFIG_KEY } from './registry/plugin';
8
8
  export { defineCellRenderer, createRendererRegistry, isRendererDefinition, type RendererRegistry, } from './registry/registry';
9
- export { getByPath, getCellValue, resolveRowKey, type RowKeyGetter } from './core/value';
9
+ export { getByPath, getCellValue, setCellValue, resolveRowKey, type RowKeyGetter, } from './core/value';
10
10
  export { normalizeColumnState, visibleColumns, moveColumn, moveColumnRelative, setColumnHidden, setColumnPinned, effectivePin, } from './core/columns';
11
- export { nextSort, sortRows, compareValues } from './core/sort';
11
+ export { nextSort, nextSorts, sortRows, sortRowsBy, compareValues, type SortKey } from './core/sort';
12
12
  export { aggregateRows, aggregateValues } from './core/aggregate';
13
13
  export { groupRows, isRowGroup, type RowGroup, type GroupRowsOptions } from './core/grouping';
14
14
  export { toCsv, toDelimited, plainText, guardFormula, type ToCsvOptions } from './core/csv';
@@ -43,6 +43,12 @@ export interface GridContext {
43
43
  sortRows(rows: readonly any[]): any[];
44
44
  /** The sorting feature is on and the column is `sortable`. */
45
45
  sortable(col: ColumnDef): boolean;
46
+ /** Editing feature: the open editor and how cells start one. */
47
+ editing?: import('../composables/useEditing').Editing<any> & {
48
+ Editor: Component;
49
+ };
50
+ /** Sorting feature: a column's number in a multi-column sort. */
51
+ SortMarker?: Component;
46
52
  /** Only with the column resizing feature. */
47
53
  resize?: {
48
54
  /** The header edge grip component. */
@@ -1,4 +1,4 @@
1
- import type { AggregationFeature, ExportFeature, RowGroupingFeature, RowPinningFeature, ColumnGroupsFeature, ColumnPinningFeature, ColumnResizingFeature, ColumnReorderFeature, ColumnVisibilityFeature, FilteringFeature, KeyboardNavigationFeature, GridFeature, MenusFeature, PaginationFeature, SelectionFeature, ServerDataFeature, ServerGroupingFeature, SortingFeature, StatusBarFeature, SubGridsFeature, VirtualScrollingFeature } from '../types';
1
+ import type { AggregationFeature, ExportFeature, RowGroupingFeature, RowPinningFeature, ColumnGroupsFeature, ColumnPinningFeature, ColumnResizingFeature, ColumnReorderFeature, ColumnVisibilityFeature, FilteringFeature, KeyboardNavigationFeature, GridFeature, MenusFeature, PaginationFeature, SelectionFeature, ServerDataFeature, ServerGroupingFeature, SortingFeature, StatusBarFeature, EditingFeature, SubGridsFeature, VirtualScrollingFeature } from '../types';
2
2
  /** The features a grid has, by name. */
3
3
  export interface FeatureSet {
4
4
  sorting?: SortingFeature;
@@ -20,6 +20,7 @@ export interface FeatureSet {
20
20
  rowGrouping?: RowGroupingFeature;
21
21
  export?: ExportFeature;
22
22
  statusBar?: StatusBarFeature;
23
+ editing?: EditingFeature;
23
24
  serverGrouping?: ServerGroupingFeature;
24
25
  }
25
26
  /** Merges feature lists (app-wide, then per grid); a later entry with the same name wins. */
@@ -176,6 +176,25 @@ export interface ColumnDef<T = any, R extends RendererRef = RendererName> {
176
176
  exportValue?: (row: T) => unknown;
177
177
  /** Included in CSV exports and copied rows (export feature)? Default `true`; set `false` on action columns. */
178
178
  exportable?: boolean;
179
+ /**
180
+ * Cells can be edited in place (editing feature): `true`, or per row. Double-click, Enter or F2
181
+ * on a focused cell, or typing, opens the editor; the grid emits `cell-edit` and your handler
182
+ * updates the data (the grid never changes rows itself).
183
+ */
184
+ editable?: boolean | ((row: T) => boolean);
185
+ /**
186
+ * The editor (editing feature): `text`, `number`, `date`, `datetime`, `select`,
187
+ * `checkbox`, or your own component (`CellEditorProps`). Default from the renderer: numbers
188
+ * and money → number, dates → date, booleans → checkbox, status / chip → select, else text.
189
+ */
190
+ editor?: EditorName | Component;
191
+ /** Options of the editor: the choices of a select, a number's `min` / `max`, a `placeholder`. */
192
+ editorOptions?: EditorOptions;
193
+ /**
194
+ * Checks an edited value before it is saved (editing feature): return an error message to keep
195
+ * the editor open with it, or nothing to accept the value.
196
+ */
197
+ validate?: (value: unknown, row: T) => string | null | undefined | void;
179
198
  /** Extra classes for the column's body cells (or a function of the row). */
180
199
  cellClass?: ClassValue | ((row: T) => ClassValue);
181
200
  /** Extra classes for the column's header cell. */
@@ -238,6 +257,61 @@ export interface CellActionEvent<T = any> {
238
257
  /** The cell’s column definition. */
239
258
  column: ColumnDef<T>;
240
259
  }
260
+ /** A built-in cell editor (editing feature). */
261
+ export type EditorName = 'text' | 'number' | 'date' | 'datetime' | 'select' | 'checkbox';
262
+ /** A choice of a select editor: a value, and the text shown for it (default: the value). */
263
+ export interface EditorOption {
264
+ value: unknown;
265
+ label?: string;
266
+ }
267
+ /** Options of a column's editor (`editorOptions`). */
268
+ export interface EditorOptions {
269
+ /** Select: the choices (default: the column's distinct values in the rows). */
270
+ options?: readonly (EditorOption | string | number | boolean)[];
271
+ /** Number: the smallest value. */
272
+ min?: number;
273
+ /** Number: the largest value. */
274
+ max?: number;
275
+ /** Text and number: shown while empty. */
276
+ placeholder?: string;
277
+ /** Text: the longest value. */
278
+ maxLength?: number;
279
+ /** Anything your own editor component needs. */
280
+ [option: string]: unknown;
281
+ }
282
+ /**
283
+ * Props of your own editor component (`editor: MyEditor`). Emit `update:modelValue` as the value
284
+ * changes; Enter, Tab and Esc are handled around it (commit, commit and move, cancel). Emit
285
+ * `commit` / `cancel` yourself where a key or a click should do that.
286
+ */
287
+ export interface CellEditorProps<T = any> {
288
+ /** The value being edited (starts as the cell value). */
289
+ modelValue: unknown;
290
+ row: T;
291
+ column: ColumnDef<T>;
292
+ options: EditorOptions;
293
+ /** The validation or save error, if any. */
294
+ error?: string;
295
+ /** Saving: the value can't change. */
296
+ disabled?: boolean;
297
+ /** The accessible name for the control, e.g. "Edit Stake". */
298
+ label: string;
299
+ /** Editing started by typing a character: it replaces the value. */
300
+ initial?: string;
301
+ }
302
+ /** An edited cell value, committed (editing feature): `cell-edit` and `save-cell` get it. */
303
+ export interface CellEditEvent<T = any> {
304
+ /** The row the cell belongs to. */
305
+ row: T;
306
+ /** The row's key (`row-key`). */
307
+ rowKey: RowKey;
308
+ /** The edited column. */
309
+ column: ColumnDef<T>;
310
+ /** The new value, typed by the editor: a number, a string, a date, a boolean, a select's value. */
311
+ value: unknown;
312
+ /** The value before the edit. */
313
+ oldValue: unknown;
314
+ }
241
315
  export interface CellClickEvent<T = any> {
242
316
  /** The row the cell belongs to. */
243
317
  row: T;
@@ -371,6 +445,13 @@ export interface VGridExposed {
371
445
  * Export feature.
372
446
  */
373
447
  copyRows(options?: ExportOptions): Promise<boolean>;
448
+ /**
449
+ * Opens the editor of a cell (editing feature), if the column is `editable` for that row and the
450
+ * row is on screen. Returns whether it opened.
451
+ */
452
+ startEdit(rowKey: RowKey, columnKey: string): boolean;
453
+ /** Closes the open editor: saves its value, or with `cancel` drops it. Editing feature. */
454
+ stopEdit(cancel?: boolean): void;
374
455
  }
375
456
  /** Which rows, columns and values an export or copy takes (export feature). */
376
457
  export interface ExportOptions {
@@ -478,6 +559,9 @@ export interface StatusBarScope {
478
559
  export interface SortingFeature {
479
560
  readonly feature: 'sorting';
480
561
  sortRows: typeof import('./core/sort').sortRows;
562
+ useSorting: typeof import('./composables/useSorting').useSorting;
563
+ /** A header's place in a multi-column sort. */
564
+ SortMarker: Component;
481
565
  }
482
566
  export interface FilteringFeature {
483
567
  readonly feature: 'filtering';
@@ -574,11 +658,19 @@ export interface StatusBarFeature {
574
658
  /** The status bar's default content. */
575
659
  StatusBar: Component;
576
660
  }
661
+ export interface EditingFeature {
662
+ readonly feature: 'editing';
663
+ useEditing: typeof import('./composables/useEditing').useEditing;
664
+ /** The cell editor (loads on demand). */
665
+ Editor: Component;
666
+ /** Loads the editor's chunk ahead of the first edit (when a grid has editable columns). */
667
+ preload: () => Promise<unknown>;
668
+ }
577
669
  export interface ServerGroupingFeature {
578
670
  readonly feature: 'serverGrouping';
579
671
  useServerGroups: typeof import('./composables/useServerGroups').useServerGroups;
580
672
  }
581
- export type GridFeature = ServerGroupingFeature | StatusBarFeature | ExportFeature | RowGroupingFeature | AggregationFeature | RowPinningFeature | ColumnGroupsFeature | ColumnResizingFeature | KeyboardNavigationFeature | ColumnVisibilityFeature | VirtualScrollingFeature | ColumnReorderFeature | ColumnPinningFeature | SortingFeature | FilteringFeature | ServerDataFeature | PaginationFeature | SelectionFeature | SubGridsFeature | MenusFeature;
673
+ export type GridFeature = EditingFeature | ServerGroupingFeature | StatusBarFeature | ExportFeature | RowGroupingFeature | AggregationFeature | RowPinningFeature | ColumnGroupsFeature | ColumnResizingFeature | KeyboardNavigationFeature | ColumnVisibilityFeature | VirtualScrollingFeature | ColumnReorderFeature | ColumnPinningFeature | SortingFeature | FilteringFeature | ServerDataFeature | PaginationFeature | SelectionFeature | SubGridsFeature | MenusFeature;
582
674
  export type GridFeatureName = GridFeature['feature'];
583
675
  export interface VueGridConfig {
584
676
  /** Renderers every grid can use by name (`renderer: 'currency'`); `allRenderers` for all of them. */
@@ -659,6 +751,15 @@ export interface GridMessages {
659
751
  sortDescending?: string;
660
752
  /** Default `Clear sort`. */
661
753
  clearSort?: string;
754
+ /** Multi-column sort: the header menu item that adds a column ascending. Default `Then sort ascending`. */
755
+ thenSortAscending?: string;
756
+ /** Default `Then sort descending`. */
757
+ thenSortDescending?: string;
758
+ /**
759
+ * Multi-column sort, for screen readers on a sorted header. Default
760
+ * `` `, sorted ${position} of ${count}, ascending` `` (`count`: how many keys).
761
+ */
762
+ sortPosition?: (position: number, dir: 'asc' | 'desc') => string;
662
763
  /** The header menu item that opens the column's filter. Default `Filter…`. */
663
764
  filterMenu?: string;
664
765
  /** Default `Clear filter`. */
@@ -803,6 +904,16 @@ export interface GridMessages {
803
904
  min?: string;
804
905
  /** Default `Max`. */
805
906
  max?: string;
907
+ /** The editor's accessible name. Default `Edit ${column}`. */
908
+ editCell?: (column: string) => string;
909
+ /** A number editor holds something else. Default `Enter a number.` */
910
+ editNotANumber?: string;
911
+ /** A number editor's value is outside `min` / `max`. Default `Enter a number from ${min} to ${max}.` (or at least / at most). */
912
+ editOutOfRange?: (min: number | undefined, max: number | undefined) => string;
913
+ /** `save-cell` rejected without a message. Default `Couldn't save the change.` */
914
+ editSaveFailed?: string;
915
+ /** Default `Saving…` (for screen readers while `save-cell` runs). */
916
+ editSaving?: string;
806
917
  /** `json`'s button. Default `View`. */
807
918
  view?: string;
808
919
  /** Dialogs and popovers. Default `Close`. */