@dolusoft/query-table 3.8.0 → 3.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.
- package/dist/query-table.js +359 -65
- package/dist/query-table.js.map +1 -1
- package/dist/types/body/group-runs.d.ts +32 -0
- package/dist/types/contract.d.ts +35 -0
- package/dist/types/parts/table-body.vue.d.ts +4 -3
- package/dist/types/resize/measure-widths.d.ts +10 -1
- package/dist/types/virtual/use-row-window.d.ts +14 -1
- package/package.json +3 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BodyRow } from '../use-query-table.js';
|
|
2
|
+
/** A group key: what `groupBy` returns for a row that belongs to a group. */
|
|
3
|
+
export type GroupKey = string | number;
|
|
4
|
+
/** One group: a run of consecutive rows with the same key (C-103). */
|
|
5
|
+
export interface GroupRun<T> {
|
|
6
|
+
key: GroupKey;
|
|
7
|
+
/** Rows in the group. */
|
|
8
|
+
count: number;
|
|
9
|
+
/** Its first row and that row's index in `rows`. */
|
|
10
|
+
row: T;
|
|
11
|
+
index: number;
|
|
12
|
+
/** Position of its first row among the rows it was computed over. */
|
|
13
|
+
start: number;
|
|
14
|
+
/** Identity of its header row: the key and the how-many-th run of it. */
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
/** The groups of a list of rows and, per row, the group it belongs to. */
|
|
18
|
+
export interface GroupRuns<T> {
|
|
19
|
+
runs: GroupRun<T>[];
|
|
20
|
+
/** Per position: the index of its group in `runs`, or -1. */
|
|
21
|
+
groupOf: Int32Array;
|
|
22
|
+
/** Per position: the number of header rows drawn up to and with it. */
|
|
23
|
+
headersThrough: Int32Array;
|
|
24
|
+
}
|
|
25
|
+
/** The runs as a string (start and count of each), or `null` without groups. */
|
|
26
|
+
export declare const groupShape: <T>(groups: GroupRuns<T> | null) => string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Splits `rows` into runs of consecutive rows with the same `groupBy` key
|
|
29
|
+
* (C-103). The rows are not reordered: a key that comes back after another
|
|
30
|
+
* starts a new run. `null` and `undefined` mean no group.
|
|
31
|
+
*/
|
|
32
|
+
export declare const groupRuns: <T>(rows: readonly BodyRow<T>[], groupBy: (row: T, index: number) => GroupKey | null | undefined) => GroupRuns<T>;
|
package/dist/types/contract.d.ts
CHANGED
|
@@ -215,6 +215,16 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
215
215
|
* writes no attribute.
|
|
216
216
|
*/
|
|
217
217
|
rowKind?: (row: T, index: number) => string | null | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* Group the rows (C-103): called with each row that is not pinned and its
|
|
220
|
+
* index in `rows`, it returns the row's group key. A run of consecutive
|
|
221
|
+
* rows with the same key is one group, drawn under one `tr.qt-group-row`
|
|
222
|
+
* that holds the `group` slot; the table never reorders, so sort the rows
|
|
223
|
+
* by group yourself. `null` or `undefined` puts a row in no group. Group
|
|
224
|
+
* rows are not rows of `rows`: indexes, the selection and `scrollToIndex`
|
|
225
|
+
* count only the rows given.
|
|
226
|
+
*/
|
|
227
|
+
groupBy?: (row: T, index: number) => string | number | null | undefined;
|
|
218
228
|
/** Add a column with a button that emits `rowRightPanelClick`. Defaults to `false`. */
|
|
219
229
|
hasRightPanel?: boolean;
|
|
220
230
|
/**
|
|
@@ -286,6 +296,11 @@ export interface VirtualOptions {
|
|
|
286
296
|
rowHeight?: number;
|
|
287
297
|
/** Height counted for a row not measured yet. Defaults to the first measured row, else `32`. */
|
|
288
298
|
estimateRowHeight?: number;
|
|
299
|
+
/**
|
|
300
|
+
* With `rowHeight` and `groupBy`: height of a group row in pixels (C-104).
|
|
301
|
+
* Defaults to `rowHeight`.
|
|
302
|
+
*/
|
|
303
|
+
groupRowHeight?: number;
|
|
289
304
|
/** Rows drawn beyond each edge of the view. Defaults to `10`. */
|
|
290
305
|
overscan?: number;
|
|
291
306
|
/**
|
|
@@ -304,6 +319,20 @@ export interface ScrollToIndexOptions {
|
|
|
304
319
|
/** Where the row ends up in the container. Defaults to `'auto'`: the nearest edge, nothing when in view. */
|
|
305
320
|
align?: 'start' | 'center' | 'end' | 'auto';
|
|
306
321
|
}
|
|
322
|
+
/** What the `group` slot receives (C-103). */
|
|
323
|
+
export interface GroupSlotProps<T> {
|
|
324
|
+
/**
|
|
325
|
+
* The group key `groupBy` returned (not `key`: Vue keeps `key` off slot
|
|
326
|
+
* props).
|
|
327
|
+
*/
|
|
328
|
+
groupKey: string | number;
|
|
329
|
+
/** The rows in the group. */
|
|
330
|
+
count: number;
|
|
331
|
+
/** The first row of the group. */
|
|
332
|
+
row: T;
|
|
333
|
+
/** Index of the first row in `rows` (named as in the cell slot). */
|
|
334
|
+
rowIndex: number;
|
|
335
|
+
}
|
|
307
336
|
/** What the `load-more` slot receives (C-89). */
|
|
308
337
|
export interface LoadMoreSlotProps {
|
|
309
338
|
/** Ask for the next page now; nothing while `loading` or when `canLoadMore` is false. */
|
|
@@ -582,6 +611,12 @@ export interface TableSlots<T> {
|
|
|
582
611
|
* `tr.qt-load-more-row`, for a "load more" or "try again" control (C-89).
|
|
583
612
|
*/
|
|
584
613
|
'load-more'?(props: LoadMoreSlotProps): unknown;
|
|
614
|
+
/**
|
|
615
|
+
* With `groupBy`: the content of a group row, one `th` that spans every
|
|
616
|
+
* column above the rows of the group (C-103). Without it the cell shows
|
|
617
|
+
* the key.
|
|
618
|
+
*/
|
|
619
|
+
group?(props: GroupSlotProps<T>): unknown;
|
|
585
620
|
/**
|
|
586
621
|
* Header content of one column: `header-${column.field}`. It replaces the
|
|
587
622
|
* sort button or the title only; the header cell, its filter row and its
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { CellContextMenuPayload, LoadMoreSlotProps, TableLabels, TableSlots } from '../contract.js';
|
|
2
2
|
import type { FlashView } from '../flash/use-change-flash.js';
|
|
3
3
|
import type { ColumnEntry } from '../use-query-table.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { BodyItem } from '../virtual/use-row-window.js';
|
|
5
5
|
declare const __VLS_export: <T extends object>(__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<{
|
|
6
6
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
7
7
|
rows: T[];
|
|
8
8
|
/**
|
|
9
9
|
* The rows in drawing order: pinned top, the others, pinned bottom (C-74);
|
|
10
|
-
* with `virtual` only the drawn ones, between spacers (C-83)
|
|
10
|
+
* with `virtual` only the drawn ones, between spacers (C-83); with
|
|
11
|
+
* `groupBy` a group row above the first row of each group (C-103).
|
|
11
12
|
*/
|
|
12
|
-
bodyRows: Array<
|
|
13
|
+
bodyRows: Array<BodyItem<T>>;
|
|
13
14
|
/** Pin a row or unpin it (C-74). */
|
|
14
15
|
pinRow: (row: T, index: number, position: "top" | "bottom" | false) => void;
|
|
15
16
|
/** The consumer is fetching: no empty row, the `loading` row instead (C-52). */
|
|
@@ -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 {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
+
import { type GroupKey, type GroupRun } from '../body/group-runs.js';
|
|
2
3
|
import type { ScrollToIndexOptions, VirtualOptions } from '../contract.js';
|
|
3
4
|
import type { BodyRow } from '../use-query-table.js';
|
|
4
5
|
import { type WindowRange } from './compute-window.js';
|
|
@@ -11,6 +12,14 @@ export interface SpacerRow {
|
|
|
11
12
|
spacer: number;
|
|
12
13
|
key: symbol;
|
|
13
14
|
}
|
|
15
|
+
/** The header row of a group (C-103), with its `aria-rowindex` when virtual. */
|
|
16
|
+
export interface GroupRow<T> {
|
|
17
|
+
group: GroupRun<T>;
|
|
18
|
+
key: symbol;
|
|
19
|
+
aria?: number;
|
|
20
|
+
}
|
|
21
|
+
/** An item of the body: a data row, a spacer or a group row. */
|
|
22
|
+
export type BodyItem<T> = DrawnRow<T> | SpacerRow | GroupRow<T>;
|
|
14
23
|
export interface RowWindowOptions<T> {
|
|
15
24
|
virtual: () => boolean | VirtualOptions | undefined;
|
|
16
25
|
table: Readonly<Ref<HTMLTableElement | null>>;
|
|
@@ -18,6 +27,8 @@ export interface RowWindowOptions<T> {
|
|
|
18
27
|
bodyRows: () => BodyRow<T>[];
|
|
19
28
|
keyOf: (row: T, index: number) => string | number;
|
|
20
29
|
isExpanded: (row: T, index: number) => boolean;
|
|
30
|
+
/** The `groupBy` prop (C-103); absent, no group is drawn. */
|
|
31
|
+
groupBy?: () => ((row: T, index: number) => GroupKey | null | undefined) | undefined;
|
|
21
32
|
}
|
|
22
33
|
/**
|
|
23
34
|
* The virtual body (C-83 to C-87): which rows are drawn, the spacers that
|
|
@@ -27,11 +38,13 @@ export interface RowWindowOptions<T> {
|
|
|
27
38
|
*/
|
|
28
39
|
export declare const useRowWindow: <T extends object>(o: RowWindowOptions<T>) => {
|
|
29
40
|
enabled: () => boolean;
|
|
30
|
-
drawn: import("vue").ComputedRef<
|
|
41
|
+
drawn: import("vue").ComputedRef<BodyItem<T>[]>;
|
|
31
42
|
range: import("vue").ShallowRef<WindowRange, WindowRange>;
|
|
32
43
|
ready: import("vue").ShallowRef<boolean, boolean>;
|
|
33
44
|
centerCount: () => number;
|
|
34
45
|
expandedCount: () => number;
|
|
46
|
+
/** Group rows of the body, drawn or not (C-104). */
|
|
47
|
+
groupCount: () => number;
|
|
35
48
|
scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
|
|
36
49
|
onFocusIn: (event: FocusEvent) => void;
|
|
37
50
|
onFocusOut: (event: FocusEvent) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.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.
|
|
49
|
-
"@dolusoft/query-table-core": "3.
|
|
48
|
+
"@dolusoft/query-protocol": "3.10.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.10.0",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|