@dolusoft/query-table 3.9.0 → 3.11.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.
@@ -1,32 +1,18 @@
1
- import { type Slots } from 'vue';
2
- import type { CellContextMenuPayload, CellSlotProps, Column } from '../contract.js';
1
+ import type { CellContextMenuPayload } from '../contract.js';
3
2
  import type { ColumnEntry } from '../use-query-table.js';
4
3
  export interface CellViewOptions<T extends object> {
5
- /** The slots the body received: `cell-<field>` is looked up. */
6
- slots: Slots;
7
4
  /** The rows of the body, to find the one a context menu event belongs to. */
8
5
  rows: () => T[];
9
6
  /** The drawn columns, to find the one a context menu event belongs to. */
10
7
  entries: () => ColumnEntry[];
11
- /** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
12
- offsets: () => Readonly<Record<string, number>>;
13
8
  /** Someone listens to `cellContextMenu`; without one the menu is left alone. */
14
9
  listening: () => boolean;
15
10
  onContextMenu: (payload: CellContextMenuPayload<T>) => void;
16
- /** Pin a row or unpin it (C-74). */
17
- pinRow: (row: T, index: number, position: 'top' | 'bottom' | false) => void;
18
11
  }
19
12
  /**
20
- * What a body cell shows: its text, its attributes, the props for a
21
- * `cell-<field>` slot and the context menu event (C-27, C-28, C-30).
13
+ * The context menu event of the body cells (C-28). What a cell shows is
14
+ * drawn by its row (`parts/table-row.ts`).
22
15
  */
23
16
  export declare const useCellView: <T extends object>(options: CellViewOptions<T>) => {
24
- cellText: (row: T, column: Column) => string;
25
- cellAttrs: (entry: ColumnEntry) => {
26
- 'data-field': string;
27
- 'data-type': "string" | "number" | "integer" | "date" | "datetime" | "bool" | undefined;
28
- };
29
- hasCellSlot: (column: Column) => boolean;
30
- slotProps: (row: T, column: Column, rowIndex: number, rowPinned: CellSlotProps<T>["rowPinned"]) => CellSlotProps<T>;
31
17
  onContextMenu: (event: MouseEvent) => void;
32
18
  };
@@ -1,5 +1,5 @@
1
- import { type RowsUpdate } from '@dolusoft/query-table-core/row-changes';
2
- import { type Ref, type ShallowRef, type VNode } from 'vue';
1
+ import { type RowChangeKey, type RowsUpdate } from '@dolusoft/query-table-core/row-changes';
2
+ import { type Ref, type ShallowRef } from 'vue';
3
3
  import type { FlashOptions, Query } from '../contract.js';
4
4
  import type { RowKey } from '../use-query-table.js';
5
5
  import { type FlashPhase } from './marks.js';
@@ -14,18 +14,29 @@ export interface ChangeFlashOptions<T extends object> {
14
14
  rowKey: () => RowKey<T>;
15
15
  table: Readonly<Ref<HTMLTableElement | null>>;
16
16
  }
17
+ /**
18
+ * The live marks of one row (K311-6): the `data-flash` value of the row and
19
+ * of each cell with a mark of its own.
20
+ */
21
+ export interface RowFlash {
22
+ row?: FlashPhase;
23
+ cells?: Readonly<Record<string, FlashPhase>>;
24
+ }
17
25
  /** What the body draws with: the marks and the binding hook (C-94). */
18
- export interface FlashView<T> {
19
- /** `data-flash` of a data row. */
20
- row: (row: T, index: number) => FlashPhase | undefined;
21
- /** `data-flash` of a data cell. */
22
- cell: (row: T, index: number, field: string) => FlashPhase | undefined;
26
+ export interface FlashView {
27
+ /**
28
+ * The live marks of the row of `key`, or `undefined`. Read in the body's
29
+ * render: a change of the marks draws the body again. Equal marks give the
30
+ * same object, so a row whose marks did not change is not drawn again.
31
+ */
32
+ of: (key: RowChangeKey) => RowFlash | undefined;
23
33
  /**
24
- * `onVnodeBeforeMount` and `onVnodeUpdated` of a data row: writes
34
+ * Called with a data row's `tr` after it is mounted or patched: writes
25
35
  * `--qt-flash-elapsed` on the row and on its cells that were bound after
26
- * their flash began, or whose flash changed.
36
+ * their flash began, or whose flash changed. Reads nothing reactive: it
37
+ * runs while the row's render effect is active.
27
38
  */
28
- bind: (vnode: VNode) => void;
39
+ bind: (el: HTMLElement, key: RowChangeKey) => void;
29
40
  }
30
41
  /**
31
42
  * The change flash of `QueryTable` (C-93 to C-95). Off, it sets up one
@@ -35,4 +46,4 @@ export interface FlashView<T> {
35
46
  * scope of its own; stopping that scope undoes everything. Nothing runs on
36
47
  * the server: the flash starts once the table is mounted.
37
48
  */
38
- export declare const useChangeFlash: <T extends object>(o: ChangeFlashOptions<T>) => ShallowRef<FlashView<T> | null>;
49
+ export declare const useChangeFlash: <T extends object>(o: ChangeFlashOptions<T>) => ShallowRef<FlashView | null>;
@@ -17,6 +17,12 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
17
17
  loading: boolean;
18
18
  /** The columns to draw, hidden ones already dropped. */
19
19
  entries: ColumnEntry[];
20
+ /**
21
+ * The `cell-<field>` slots the consumer gives, one per line (a field name
22
+ * may hold a space, never a line break). Slots are not reactive; a slot
23
+ * that comes or goes changes this text (K311-3).
24
+ */
25
+ slotNames: string;
20
26
  /** Cells a full-width row (subtable, empty) spans. */
21
27
  columnCount: number;
22
28
  hasSubtable: boolean;
@@ -45,7 +51,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
45
51
  * With `flash`: the marks and the binding hook (C-94), else `null`; off,
46
52
  * the body draws what it drew in 3.2 and calls nothing per row (C-95).
47
53
  */
48
- flash: FlashView<T> | null;
54
+ flash: FlashView | null;
49
55
  /** With `scrollBody`: the ARIA table roles of C-102. */
50
56
  roles?: boolean;
51
57
  } & {
@@ -15,7 +15,8 @@ type __VLS_Props = {
15
15
  autoWidths: Readonly<Record<string, number>>;
16
16
  /**
17
17
  * The header slots the consumer gave (`header-<field>`, `filter-datetime`,
18
- * `filter-menu`), space-separated. The slots below are always passed so
18
+ * `filter-menu`), one per line: a field name may hold a space, never a
19
+ * line break. The slots below are always passed so
19
20
  * that they stay stable; this says which ones to draw.
20
21
  */
21
22
  slotNames: string;
@@ -0,0 +1,218 @@
1
+ import { type PropType, type VNode } from 'vue';
2
+ import type { PinSide } from '../columns/column-layout.js';
3
+ import type { Column } from '../contract.js';
4
+ import type { RowFlash } from '../flash/use-change-flash.js';
5
+ /**
6
+ * One drawn column of a data row, kept by value by the body (K311-2): the
7
+ * same object while its column, place, type, pinning, slot and role stay.
8
+ */
9
+ export interface RowCell {
10
+ field: string;
11
+ column: Column;
12
+ type: string;
13
+ side: PinSide;
14
+ offset: number | undefined;
15
+ role: string | undefined;
16
+ /** `cell-<field>` when the consumer gives that slot, else `null`. */
17
+ slot: string | null;
18
+ /** The `td` attributes before `data-flash`, in the order 3.10 wrote them. */
19
+ attrs: Record<string, unknown>;
20
+ }
21
+ /**
22
+ * The utility cells of a data row (C-46, C-59, C-98): the attributes of
23
+ * each one drawn, `null` for one that is not. Kept by value by the body.
24
+ */
25
+ export interface RowUtilities {
26
+ panel: Record<string, unknown> | null;
27
+ expand: Record<string, unknown> | null;
28
+ select: Record<string, unknown> | null;
29
+ /** What the attributes were made from: equal keys, equal cells. */
30
+ signature: string;
31
+ }
32
+ type PinRow = (row: object, index: number, position: 'top' | 'bottom' | false) => void;
33
+ /**
34
+ * One data row of the body (ADR 0017, C-106 to C-108): its `tr`, the
35
+ * utility cells and the column cells with their `cell-<field>` slots.
36
+ * Internal: not exported from the package.
37
+ *
38
+ * Every prop is a value the body computed for this row (K311-2), so Vue
39
+ * skips a row whose props did not change; the row's render calls no
40
+ * function that reads shared state. Its cell slots are called here, so what
41
+ * a slot reads reactively belongs to this row (K311-4). The render is
42
+ * written with the helpers compiled templates use, and draws the vnodes the
43
+ * `tr` branch of the body's template drew in 3.10 (C-108).
44
+ */
45
+ export declare const tableRow: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
46
+ row: {
47
+ type: PropType<object>;
48
+ required: true;
49
+ };
50
+ /** The row's key, as the body keys it (C-26). */
51
+ rowKey: {
52
+ type: PropType<string | number>;
53
+ required: true;
54
+ };
55
+ /** `data-row-index`: the row's index in `rows`. */
56
+ index: {
57
+ type: PropType<number>;
58
+ required: true;
59
+ };
60
+ /** `aria-rowindex`, with `virtual` only (C-86). */
61
+ aria: {
62
+ type: PropType<number | undefined>;
63
+ };
64
+ pinned: {
65
+ type: PropType<false | "top" | "bottom">;
66
+ required: true;
67
+ };
68
+ /** `data-row-kind` (C-97); `undefined` for none. */
69
+ kind: {
70
+ type: PropType<string | undefined>;
71
+ };
72
+ selected: {
73
+ type: PropType<boolean>;
74
+ required: true;
75
+ };
76
+ expanded: {
77
+ type: PropType<boolean>;
78
+ required: true;
79
+ };
80
+ /** An expand button is drawn (C-98). */
81
+ expandable: {
82
+ type: PropType<boolean>;
83
+ required: true;
84
+ };
85
+ /** The row's flash marks (C-94), or `undefined`. */
86
+ flash: {
87
+ type: PropType<RowFlash | undefined>;
88
+ };
89
+ cells: {
90
+ type: PropType<readonly RowCell[]>;
91
+ required: true;
92
+ };
93
+ utilities: {
94
+ type: PropType<RowUtilities>;
95
+ required: true;
96
+ };
97
+ labelPanel: {
98
+ type: PropType<string>;
99
+ required: true;
100
+ };
101
+ labelExpand: {
102
+ type: PropType<string>;
103
+ required: true;
104
+ };
105
+ labelSelect: {
106
+ type: PropType<string>;
107
+ required: true;
108
+ };
109
+ /** `scrollBody`: the ARIA roles of C-102. */
110
+ roles: {
111
+ type: PropType<boolean | undefined>;
112
+ };
113
+ /** The body's slots object: the same object for the body's life (K311-3). */
114
+ slots: {
115
+ type: PropType<Readonly<{
116
+ [name: string]: import("vue").Slot<any> | undefined;
117
+ }>>;
118
+ required: true;
119
+ };
120
+ /** With `flash`: binds the elapsed time after a render (K311-6). */
121
+ flashBind: {
122
+ type: PropType<((el: HTMLElement, key: string | number) => void) | undefined>;
123
+ };
124
+ pinRow: {
125
+ type: PropType<PinRow>;
126
+ required: true;
127
+ };
128
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
129
+ [key: string]: any;
130
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("toggleSelected" | "toggle" | "rightPanel")[], "toggleSelected" | "toggle" | "rightPanel", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
131
+ row: {
132
+ type: PropType<object>;
133
+ required: true;
134
+ };
135
+ /** The row's key, as the body keys it (C-26). */
136
+ rowKey: {
137
+ type: PropType<string | number>;
138
+ required: true;
139
+ };
140
+ /** `data-row-index`: the row's index in `rows`. */
141
+ index: {
142
+ type: PropType<number>;
143
+ required: true;
144
+ };
145
+ /** `aria-rowindex`, with `virtual` only (C-86). */
146
+ aria: {
147
+ type: PropType<number | undefined>;
148
+ };
149
+ pinned: {
150
+ type: PropType<false | "top" | "bottom">;
151
+ required: true;
152
+ };
153
+ /** `data-row-kind` (C-97); `undefined` for none. */
154
+ kind: {
155
+ type: PropType<string | undefined>;
156
+ };
157
+ selected: {
158
+ type: PropType<boolean>;
159
+ required: true;
160
+ };
161
+ expanded: {
162
+ type: PropType<boolean>;
163
+ required: true;
164
+ };
165
+ /** An expand button is drawn (C-98). */
166
+ expandable: {
167
+ type: PropType<boolean>;
168
+ required: true;
169
+ };
170
+ /** The row's flash marks (C-94), or `undefined`. */
171
+ flash: {
172
+ type: PropType<RowFlash | undefined>;
173
+ };
174
+ cells: {
175
+ type: PropType<readonly RowCell[]>;
176
+ required: true;
177
+ };
178
+ utilities: {
179
+ type: PropType<RowUtilities>;
180
+ required: true;
181
+ };
182
+ labelPanel: {
183
+ type: PropType<string>;
184
+ required: true;
185
+ };
186
+ labelExpand: {
187
+ type: PropType<string>;
188
+ required: true;
189
+ };
190
+ labelSelect: {
191
+ type: PropType<string>;
192
+ required: true;
193
+ };
194
+ /** `scrollBody`: the ARIA roles of C-102. */
195
+ roles: {
196
+ type: PropType<boolean | undefined>;
197
+ };
198
+ /** The body's slots object: the same object for the body's life (K311-3). */
199
+ slots: {
200
+ type: PropType<Readonly<{
201
+ [name: string]: import("vue").Slot<any> | undefined;
202
+ }>>;
203
+ required: true;
204
+ };
205
+ /** With `flash`: binds the elapsed time after a render (K311-6). */
206
+ flashBind: {
207
+ type: PropType<((el: HTMLElement, key: string | number) => void) | undefined>;
208
+ };
209
+ pinRow: {
210
+ type: PropType<PinRow>;
211
+ required: true;
212
+ };
213
+ }>> & Readonly<{
214
+ onToggleSelected?: ((...args: any[]) => any) | undefined;
215
+ onToggle?: ((...args: any[]) => any) | undefined;
216
+ onRightPanel?: ((...args: any[]) => any) | undefined;
217
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
218
+ export {};
@@ -1,3 +1,11 @@
1
+ interface MeasureOptions {
2
+ /**
3
+ * The filter row counts as a floor (C-100): laid out at the width it
4
+ * needs, its controls side by side and six characters of text in each
5
+ * input, so a column is never drawn narrower than its filter.
6
+ */
7
+ filters?: boolean;
8
+ }
1
9
  /**
2
10
  * Sets inline declarations for one read and puts every `style` attribute
3
11
  * back exactly as it was, absent included, so the markup after the call is
@@ -21,4 +29,5 @@ export declare const styleSwap: () => {
21
29
  * (C-101): it is laid out the same way, its `col` widths left out, and a
22
30
  * column takes the wider of its header cell and its body cells.
23
31
  */
24
- export declare const measureColumnWidths: (table: HTMLTableElement | null | undefined, fields?: readonly string[], body?: HTMLTableElement | null) => Record<string, number>;
32
+ export declare const measureColumnWidths: (table: HTMLTableElement | null | undefined, fields?: readonly string[], body?: HTMLTableElement | null, options?: MeasureOptions) => Record<string, number>;
33
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolusoft/query-table",
3
- "version": "3.9.0",
3
+ "version": "3.11.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.9.0",
49
- "@dolusoft/query-table-core": "3.9.0",
48
+ "@dolusoft/query-protocol": "3.11.0",
49
+ "@dolusoft/query-table-core": "3.11.0",
50
50
  "@tanstack/vue-table": "9.2.6"
51
51
  },
52
52
  "devDependencies": {