@dolusoft/query-table 3.7.1 → 3.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.
- package/dist/query-table.js +637 -132
- package/dist/query-table.js.map +1 -1
- package/dist/types/body/group-runs.d.ts +32 -0
- package/dist/types/contract.d.ts +46 -0
- package/dist/types/flash/use-change-flash.d.ts +2 -2
- package/dist/types/parts/table-body.vue.d.ts +6 -3
- package/dist/types/parts/table-footer.vue.d.ts +2 -0
- package/dist/types/parts/table-header.vue.d.ts +2 -0
- package/dist/types/pin/use-header-geometry.d.ts +5 -1
- package/dist/types/resize/measure-widths.d.ts +4 -1
- package/dist/types/resize/use-auto-width.d.ts +2 -0
- package/dist/types/resize/use-column-resize.d.ts +2 -0
- package/dist/types/scroll/use-scroll-body.d.ts +22 -0
- package/dist/types/virtual/use-load-more.d.ts +2 -2
- package/dist/types/virtual/use-row-window.d.ts +18 -5
- 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
|
/**
|
|
@@ -238,6 +248,17 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
238
248
|
* `table-layout: fixed` (C-85). Defaults to `false`.
|
|
239
249
|
*/
|
|
240
250
|
virtual?: boolean | VirtualOptions;
|
|
251
|
+
/**
|
|
252
|
+
* Draw the header, the body and the footer as three tables in
|
|
253
|
+
* `.qt-table-head`, `.qt-table-body` and `.qt-table-foot`, so the body
|
|
254
|
+
* scrolls under a header that stays outside it (C-101, C-102). The columns
|
|
255
|
+
* of the body and footer take the widths of the header cells, and the
|
|
256
|
+
* three scroll sideways together. In your CSS give the three wrappers
|
|
257
|
+
* `overflow-y: scroll`, the body a height and `overflow-x: auto`, the
|
|
258
|
+
* header and footer `overflow-x: hidden` and a transparent scrollbar, and
|
|
259
|
+
* the body and footer tables `table-layout: fixed`. Defaults to `false`.
|
|
260
|
+
*/
|
|
261
|
+
scrollBody?: boolean;
|
|
241
262
|
/**
|
|
242
263
|
* Ask for the next page (`update:query`, reason `page`) when the end of
|
|
243
264
|
* `rows` comes into view (C-88); append the rows of a `page` answer and
|
|
@@ -275,6 +296,11 @@ export interface VirtualOptions {
|
|
|
275
296
|
rowHeight?: number;
|
|
276
297
|
/** Height counted for a row not measured yet. Defaults to the first measured row, else `32`. */
|
|
277
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;
|
|
278
304
|
/** Rows drawn beyond each edge of the view. Defaults to `10`. */
|
|
279
305
|
overscan?: number;
|
|
280
306
|
/**
|
|
@@ -293,6 +319,20 @@ export interface ScrollToIndexOptions {
|
|
|
293
319
|
/** Where the row ends up in the container. Defaults to `'auto'`: the nearest edge, nothing when in view. */
|
|
294
320
|
align?: 'start' | 'center' | 'end' | 'auto';
|
|
295
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
|
+
}
|
|
296
336
|
/** What the `load-more` slot receives (C-89). */
|
|
297
337
|
export interface LoadMoreSlotProps {
|
|
298
338
|
/** Ask for the next page now; nothing while `loading` or when `canLoadMore` is false. */
|
|
@@ -571,6 +611,12 @@ export interface TableSlots<T> {
|
|
|
571
611
|
* `tr.qt-load-more-row`, for a "load more" or "try again" control (C-89).
|
|
572
612
|
*/
|
|
573
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;
|
|
574
620
|
/**
|
|
575
621
|
* Header content of one column: `header-${column.field}`. It replaces the
|
|
576
622
|
* sort button or the title only; the header cell, its filter row and its
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RowsUpdate } from '@dolusoft/query-table-core/row-changes';
|
|
2
|
-
import { type ShallowRef, type VNode } from 'vue';
|
|
2
|
+
import { type Ref, type ShallowRef, type VNode } 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';
|
|
@@ -12,7 +12,7 @@ export interface ChangeFlashOptions<T extends object> {
|
|
|
12
12
|
/** The fields of the drawn columns. */
|
|
13
13
|
fields: () => readonly string[];
|
|
14
14
|
rowKey: () => RowKey<T>;
|
|
15
|
-
table:
|
|
15
|
+
table: Readonly<Ref<HTMLTableElement | null>>;
|
|
16
16
|
}
|
|
17
17
|
/** What the body draws with: the marks and the binding hook (C-94). */
|
|
18
18
|
export interface FlashView<T> {
|
|
@@ -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). */
|
|
@@ -45,6 +46,8 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
45
46
|
* the body draws what it drew in 3.2 and calls nothing per row (C-95).
|
|
46
47
|
*/
|
|
47
48
|
flash: FlashView<T> | null;
|
|
49
|
+
/** With `scrollBody`: the ARIA table roles of C-102. */
|
|
50
|
+
roles?: boolean;
|
|
48
51
|
} & {
|
|
49
52
|
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
50
53
|
onCellContextMenu?: ((payload: CellContextMenuPayload<T>) => any) | undefined;
|
|
@@ -11,6 +11,8 @@ type __VLS_Props = {
|
|
|
11
11
|
offsets: Readonly<Record<string, number>>;
|
|
12
12
|
/** With `virtual`: `aria-rowindex` of the first footer row (C-86). */
|
|
13
13
|
firstRowIndex?: number;
|
|
14
|
+
/** With `scrollBody`: the ARIA table roles of C-102. */
|
|
15
|
+
roles?: boolean;
|
|
14
16
|
};
|
|
15
17
|
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>;
|
|
16
18
|
declare const _default: typeof __VLS_export;
|
|
@@ -19,6 +19,8 @@ type __VLS_Props = {
|
|
|
19
19
|
* that they stay stable; this says which ones to draw.
|
|
20
20
|
*/
|
|
21
21
|
slotNames: string;
|
|
22
|
+
/** With `scrollBody`: the ARIA table roles of C-102. */
|
|
23
|
+
roles?: boolean;
|
|
22
24
|
};
|
|
23
25
|
type __VLS_Slots = {
|
|
24
26
|
'filter-datetime'?(props: FilterDatetimeSlotProps): unknown;
|
|
@@ -10,7 +10,10 @@ export interface HeaderGeometryOptions {
|
|
|
10
10
|
table: ShallowRef<HTMLTableElement | null>;
|
|
11
11
|
/** The header cells as drawn: utilities first, then the columns. */
|
|
12
12
|
cells: () => HeaderCellKey[];
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Some column is pinned on either side (C-46, C-71) or has a resize handle
|
|
15
|
+
* (C-48), or the body is a table of its own (`scrollBody`, C-101).
|
|
16
|
+
*/
|
|
14
17
|
active: () => boolean;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
@@ -28,5 +31,6 @@ export declare const useHeaderGeometry: (options: HeaderGeometryOptions) => {
|
|
|
28
31
|
widths: ShallowRef<Readonly<Record<string, number>>, Readonly<Record<string, number>>>;
|
|
29
32
|
tableWidth: ShallowRef<number, number>;
|
|
30
33
|
offsets: ShallowRef<Readonly<Record<string, number>>, Readonly<Record<string, number>>>;
|
|
34
|
+
columns: ShallowRef<readonly number[], readonly number[]>;
|
|
31
35
|
};
|
|
32
36
|
export {};
|
|
@@ -17,5 +17,8 @@ export declare const styleSwap: () => {
|
|
|
17
17
|
* between, and slot content that draws a block or a flex box counts with the
|
|
18
18
|
* width its content needs, not the width its cell gives it. Only `fields`
|
|
19
19
|
* when given; a column with no box (the table not displayed) is left out.
|
|
20
|
+
* With `scrollBody` the data rows are in a table of their own, `body`
|
|
21
|
+
* (C-101): it is laid out the same way, its `col` widths left out, and a
|
|
22
|
+
* column takes the wider of its header cell and its body cells.
|
|
20
23
|
*/
|
|
21
|
-
export declare const measureColumnWidths: (table: HTMLTableElement | null | undefined, fields?: readonly string[]) => Record<string, number>;
|
|
24
|
+
export declare const measureColumnWidths: (table: HTMLTableElement | null | undefined, fields?: readonly string[], body?: HTMLTableElement | null) => Record<string, number>;
|
|
@@ -8,6 +8,8 @@ export interface AutoWidthOptions {
|
|
|
8
8
|
/** The `autoWidthMax` prop: the limit of a column without `maxWidth`. */
|
|
9
9
|
max: () => number | undefined;
|
|
10
10
|
table: ShallowRef<HTMLTableElement | null>;
|
|
11
|
+
/** With `scrollBody`: the table of the body rows (C-101), else `null`. */
|
|
12
|
+
body: () => HTMLTableElement | null;
|
|
11
13
|
/** The visible columns, as given. */
|
|
12
14
|
columns: () => Column[];
|
|
13
15
|
rows: () => readonly unknown[];
|
|
@@ -6,6 +6,8 @@ export interface ColumnResizeOptions {
|
|
|
6
6
|
measuredWidth: (field: string) => number | undefined;
|
|
7
7
|
/** Measured width of the table. */
|
|
8
8
|
tableWidth: () => number;
|
|
9
|
+
/** With `scrollBody`: the table of the body rows (C-101), else `null`. */
|
|
10
|
+
body: () => HTMLTableElement | null;
|
|
9
11
|
emit: (payload: ColumnResizePayload) => void;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The wrappers of `scrollBody`, `null` while not drawn. */
|
|
2
|
+
interface ScrollBodyWrappers {
|
|
3
|
+
head: HTMLElement | null;
|
|
4
|
+
body: HTMLElement | null;
|
|
5
|
+
foot: HTMLElement | null;
|
|
6
|
+
}
|
|
7
|
+
export interface ScrollBodyOptions {
|
|
8
|
+
/** The `scrollBody` prop. */
|
|
9
|
+
enabled: () => boolean;
|
|
10
|
+
wrappers: () => ScrollBodyWrappers;
|
|
11
|
+
/** The table of the body rows: its layout is checked once (C-101). */
|
|
12
|
+
bodyTable: () => HTMLTableElement | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Header, body and footer of `scrollBody` scroll sideways together (C-101):
|
|
16
|
+
* one passive `scroll` listener on each wrapper sets the `scrollLeft` of the
|
|
17
|
+
* others to its own. A position written here is remembered, so the `scroll`
|
|
18
|
+
* event it fires is not taken for one of the user's. The table writes no
|
|
19
|
+
* style and no attribute to the wrappers. Off, nothing is listened to.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useScrollBody: (options: ScrollBodyOptions) => void;
|
|
22
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PageCursors, type Query } from '@dolusoft/query-protocol';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Ref } from 'vue';
|
|
3
3
|
import type { InfiniteOptions } from '../contract.js';
|
|
4
4
|
export interface LoadMoreOptions {
|
|
5
5
|
infinite: () => boolean | InfiniteOptions | undefined;
|
|
@@ -11,7 +11,7 @@ export interface LoadMoreOptions {
|
|
|
11
11
|
loading: () => boolean;
|
|
12
12
|
/** The next page action (C-05, C-56). */
|
|
13
13
|
nextPage: () => void;
|
|
14
|
-
table:
|
|
14
|
+
table: Readonly<Ref<HTMLTableElement | null>>;
|
|
15
15
|
/** The body is virtual (C-83). */
|
|
16
16
|
virtual: () => boolean;
|
|
17
17
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
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,13 +12,23 @@ 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
|
-
table:
|
|
25
|
+
table: Readonly<Ref<HTMLTableElement | null>>;
|
|
17
26
|
/** The rows in drawing order: pinned top, the others, pinned bottom (C-74). */
|
|
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<
|
|
31
|
-
range: ShallowRef<WindowRange, WindowRange>;
|
|
32
|
-
ready: ShallowRef<boolean, boolean>;
|
|
41
|
+
drawn: import("vue").ComputedRef<BodyItem<T>[]>;
|
|
42
|
+
range: import("vue").ShallowRef<WindowRange, WindowRange>;
|
|
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.9.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.9.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.9.0",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|