@dolusoft/query-table 3.3.0 → 3.5.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.
@@ -186,6 +186,22 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
186
186
  * `rows`). Defaults to `false`.
187
187
  */
188
188
  hasSubtable?: boolean;
189
+ /**
190
+ * Which rows can expand, with `hasSubtable` (C-98): called with the row and
191
+ * its index in `rows`. A row it returns `false` for gets an empty expand
192
+ * cell (no button), never draws the `subtable` slot, is skipped by
193
+ * `expandAll()` and ignores its `isExpanded` field. Absent, every row can
194
+ * expand.
195
+ */
196
+ rowExpandable?: (row: T, index: number) => boolean;
197
+ /**
198
+ * A kind for a row, written as `data-row-kind` on its `tr` (C-97): called
199
+ * with the row and its index in `rows`. Data, not styling: the table draws
200
+ * nothing by it, and the consumer's CSS selects
201
+ * `tr[data-row-kind="total"]`. An empty string, `null` or `undefined`
202
+ * writes no attribute.
203
+ */
204
+ rowKind?: (row: T, index: number) => string | null | undefined;
189
205
  /** Add a column with a button that emits `rowRightPanelClick`. Defaults to `false`. */
190
206
  hasRightPanel?: boolean;
191
207
  /**
@@ -322,6 +338,14 @@ export interface CellContextMenuPayload<T> {
322
338
  /** Index into `columns`, hidden columns included. */
323
339
  columnIndex: number;
324
340
  }
341
+ /** Payload of the `headerContextMenu` event (C-96). */
342
+ export interface HeaderContextMenuPayload {
343
+ event: MouseEvent;
344
+ /** The column definition the consumer passed. */
345
+ column: Column;
346
+ /** Index into `columns`, hidden columns included. */
347
+ columnIndex: number;
348
+ }
325
349
  /** Payload of the `columnResize` event. */
326
350
  export interface ColumnResizePayload {
327
351
  /** `field` of the resized column. */
@@ -372,6 +396,12 @@ export type TableEmits<T, Q extends Query = TableQuery> = {
372
396
  * suppressed; without one the table emits nothing and keeps it.
373
397
  */
374
398
  cellContextMenu: [payload: CellContextMenuPayload<T>];
399
+ /**
400
+ * A data-column header was right-clicked (C-96). With a listener the
401
+ * browser menu is suppressed; without one the table emits nothing and
402
+ * keeps it. The filter row and utility headers keep the browser menu.
403
+ */
404
+ headerContextMenu: [payload: HeaderContextMenuPayload];
375
405
  /**
376
406
  * The user resized a column: on release of a drag, on an arrow key or on
377
407
  * autofit. Write `width` back to the column (`Column.width`), or the column
@@ -0,0 +1,23 @@
1
+ import type { Column, HeaderContextMenuPayload } from '../contract.js';
2
+ export interface HeaderContextMenuOptions {
3
+ /** The drawn columns (hidden already dropped), in drawing order. */
4
+ columns: () => Column[];
5
+ /**
6
+ * Original index of a drawn column in the consumer's `columns` (hidden
7
+ * included), as C-28's `columnIndex`.
8
+ */
9
+ indexOf: (field: string) => number | undefined;
10
+ /** Someone listens to `headerContextMenu`; without one the menu is left alone. */
11
+ listening: () => boolean;
12
+ onContextMenu: (payload: HeaderContextMenuPayload) => void;
13
+ }
14
+ /**
15
+ * One listener on the `thead` serves every header cell (C-96): a listener per
16
+ * cell would be a new closure per cell on every render. Only a data column
17
+ * header emits (`data-field`); utility cells keep the browser menu. A right
18
+ * click inside the filter row (`.qt-filter`) keeps the browser menu too, so
19
+ * paste and spell-check stay (issue #102 S1(a)).
20
+ */
21
+ export declare const useHeaderContextMenu: (options: HeaderContextMenuOptions) => {
22
+ onContextMenu: (event: MouseEvent) => void;
23
+ };
@@ -29,8 +29,12 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
29
29
  /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
30
30
  offsets: Readonly<Record<string, number>>;
31
31
  keyOf: (row: T, index: number) => string | number;
32
+ /** The row can expand: no expand button otherwise (C-98). */
33
+ canExpand: (row: T, index: number) => boolean;
32
34
  isExpanded: (row: T, index: number) => boolean;
33
35
  toggle: (row: T, index: number) => void;
36
+ /** `data-row-kind` of a row (C-97); absent, no row carries it. */
37
+ rowKind?: (row: T, index: number) => string | null | undefined;
34
38
  labels: TableLabels;
35
39
  /** The consumer listens to `cellContextMenu` (C-28); read at event time. */
36
40
  hasContextMenuListener: () => boolean;
@@ -5,6 +5,7 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
5
5
  onCellContextMenu?: ((payload: import("./contract.js").CellContextMenuPayload<T>) => any) | undefined;
6
6
  "onUpdate:query"?: ((query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => any) | undefined;
7
7
  "onUpdate:selection"?: ((selection: import("./contract.js").RowSelection) => any) | undefined;
8
+ onHeaderContextMenu?: ((payload: import("./contract.js").HeaderContextMenuPayload) => any) | undefined;
8
9
  onColumnResize?: ((payload: import("./contract.js").ColumnResizePayload) => any) | undefined;
9
10
  "onUpdate:columns"?: ((columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => any) | undefined;
10
11
  "onUpdate:rowPinning"?: ((rowPinning: import("./contract.js").RowPinning) => any) | undefined;
@@ -14,7 +15,7 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
14
15
  expose: (exposed: import("vue").ShallowUnwrapRef<QueryTableExpose>) => void;
15
16
  attrs: any;
16
17
  slots: TableSlots<T>;
17
- emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void) & ((evt: "update:columns", columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => void) & ((evt: "update:rowPinning", rowPinning: import("./contract.js").RowPinning) => void);
18
+ emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "headerContextMenu", payload: import("./contract.js").HeaderContextMenuPayload) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void) & ((evt: "update:columns", columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => void) & ((evt: "update:rowPinning", rowPinning: import("./contract.js").RowPinning) => void);
18
19
  }>) => import("vue").VNode & {
19
20
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
20
21
  };
@@ -49,6 +49,12 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
49
49
  rowKey?: MaybeRefOrGetter<RowKey<T>>;
50
50
  /** Rows can expand (the `subtable` column). Defaults to `false`. */
51
51
  hasSubtable?: MaybeRefOrGetter<boolean | undefined>;
52
+ /**
53
+ * Which rows can expand, with `hasSubtable` (C-98); without it every row
54
+ * can. Give a getter or a ref that holds the function (`() => fn`): a bare
55
+ * function is read as a getter.
56
+ */
57
+ rowExpandable?: MaybeRefOrGetter<TableProps<T>['rowExpandable']>;
52
58
  /** Page sizes offered. Defaults to `[10, 20, 30, 50, 100]`. */
53
59
  pageSizeOptions?: MaybeRefOrGetter<number[] | undefined>;
54
60
  /** Called once per user action that changes the query, with a new object. */
@@ -135,10 +141,13 @@ export interface QueryTableSearch {
135
141
  export interface QueryTableExpansion<T extends object> {
136
142
  /** Identity of a row: `rowKey`, else its index. */
137
143
  keyOf: (row: T, index: number) => string | number;
144
+ /** `hasSubtable` is on and `rowExpandable` lets the row expand (C-98). */
145
+ canExpand: (row: T, index: number) => boolean;
138
146
  isExpanded: (row: T, index: number) => boolean;
147
+ /** Opens or closes the row; nothing for a row that cannot expand (C-98). */
139
148
  toggle: (row: T, index: number) => void;
140
149
  collapseAll: () => void;
141
- /** Opens every row given; nothing is fetched. */
150
+ /** Opens every row given that can expand; nothing is fetched. */
142
151
  expandAll: () => void;
143
152
  }
144
153
  /** Row selection (C-59), owned by the consumer. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/query-table",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "A thin Vue 3 table for server-side data: it renders rows and emits sort, filter, search and paging changes. Built on TanStack Table.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -45,8 +45,8 @@
45
45
  ],
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@dolusoft/query-protocol": "3.3.0",
49
- "@dolusoft/query-table-core": "3.3.0",
48
+ "@dolusoft/query-protocol": "3.5.0",
49
+ "@dolusoft/query-table-core": "3.5.0",
50
50
  "@tanstack/vue-table": "9.2.6"
51
51
  },
52
52
  "devDependencies": {