@dolusoft/query-table 3.7.0 → 3.8.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 +497 -106
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +11 -0
- package/dist/types/flash/use-change-flash.d.ts +2 -2
- package/dist/types/parts/table-body.vue.d.ts +2 -0
- 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 +14 -1
- package/dist/types/resize/use-auto-width.d.ts +2 -0
- package/dist/types/resize/use-column-resize.d.ts +7 -1
- package/dist/types/resize/width-scale.d.ts +34 -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 +4 -4
- package/package.json +3 -3
package/dist/types/contract.d.ts
CHANGED
|
@@ -238,6 +238,17 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
238
238
|
* `table-layout: fixed` (C-85). Defaults to `false`.
|
|
239
239
|
*/
|
|
240
240
|
virtual?: boolean | VirtualOptions;
|
|
241
|
+
/**
|
|
242
|
+
* Draw the header, the body and the footer as three tables in
|
|
243
|
+
* `.qt-table-head`, `.qt-table-body` and `.qt-table-foot`, so the body
|
|
244
|
+
* scrolls under a header that stays outside it (C-101, C-102). The columns
|
|
245
|
+
* of the body and footer take the widths of the header cells, and the
|
|
246
|
+
* three scroll sideways together. In your CSS give the three wrappers
|
|
247
|
+
* `overflow-y: scroll`, the body a height and `overflow-x: auto`, the
|
|
248
|
+
* header and footer `overflow-x: hidden` and a transparent scrollbar, and
|
|
249
|
+
* the body and footer tables `table-layout: fixed`. Defaults to `false`.
|
|
250
|
+
*/
|
|
251
|
+
scrollBody?: boolean;
|
|
241
252
|
/**
|
|
242
253
|
* Ask for the next page (`update:query`, reason `page`) when the end of
|
|
243
254
|
* `rows` comes into view (C-88); append the rows of a `page` answer and
|
|
@@ -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> {
|
|
@@ -45,6 +45,8 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
45
45
|
* the body draws what it drew in 3.2 and calls nothing per row (C-95).
|
|
46
46
|
*/
|
|
47
47
|
flash: FlashView<T> | null;
|
|
48
|
+
/** With `scrollBody`: the ARIA table roles of C-102. */
|
|
49
|
+
roles?: boolean;
|
|
48
50
|
} & {
|
|
49
51
|
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
50
52
|
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 {};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets inline declarations for one read and puts every `style` attribute
|
|
3
|
+
* back exactly as it was, absent included, so the markup after the call is
|
|
4
|
+
* the markup before it (C-31). `!important` so a consumer's `!important`
|
|
5
|
+
* rule cannot keep the fixed layout during the read.
|
|
6
|
+
*/
|
|
7
|
+
export declare const styleSwap: () => {
|
|
8
|
+
set(element: HTMLElement, property: string, value: string): void;
|
|
9
|
+
restore(): void;
|
|
10
|
+
};
|
|
1
11
|
/**
|
|
2
12
|
* The max-content width of each drawn column, by `field`: header label and
|
|
3
13
|
* the cells of the drawn data rows, padding and border included, in whole
|
|
@@ -7,5 +17,8 @@
|
|
|
7
17
|
* between, and slot content that draws a block or a flex box counts with the
|
|
8
18
|
* width its content needs, not the width its cell gives it. Only `fields`
|
|
9
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.
|
|
10
23
|
*/
|
|
11
|
-
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
|
/**
|
|
@@ -25,15 +27,19 @@ export declare const clampWidth: (column: Column, width: number) => number;
|
|
|
25
27
|
* drag is under way (the preview, P2); every committed width goes out as a
|
|
26
28
|
* `columnResize` event and comes back, if the consumer wants it, as
|
|
27
29
|
* `Column.width`. The handle captures the pointer, so all drag events arrive
|
|
28
|
-
* at the handle itself, and it has the focus, so Escape does too.
|
|
30
|
+
* at the handle itself, and it has the focus, so Escape does too. The pointer
|
|
31
|
+
* and the arrow keys move the drawn width; what the table writes and emits is
|
|
32
|
+
* the declared width that draws it (`measureWidthScale`).
|
|
29
33
|
*/
|
|
30
34
|
export declare const useColumnResize: (options: ColumnResizeOptions) => {
|
|
31
35
|
preview: import("vue").ShallowRef<{
|
|
32
36
|
field: string;
|
|
33
37
|
width: number;
|
|
38
|
+
rendered: number;
|
|
34
39
|
} | null, {
|
|
35
40
|
field: string;
|
|
36
41
|
width: number;
|
|
42
|
+
rendered: number;
|
|
37
43
|
} | null>;
|
|
38
44
|
isResizable: (column: Column) => boolean;
|
|
39
45
|
widthOf: (column: Column) => number;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** How a column's declared width maps to the width it is drawn at. */
|
|
2
|
+
export interface WidthScale {
|
|
3
|
+
/** The declared width that draws the column `rendered` pixels wide. */
|
|
4
|
+
declared: (rendered: number) => number;
|
|
5
|
+
/** The width the column is drawn at with the `declared` width. */
|
|
6
|
+
rendered: (declared: number) => number;
|
|
7
|
+
}
|
|
8
|
+
/** The declared width is the drawn one. */
|
|
9
|
+
export declare const identityScale: WidthScale;
|
|
10
|
+
/**
|
|
11
|
+
* A table whose cells take `space` (a container's width, with
|
|
12
|
+
* `min-width: 100%`) and whose columns are declared narrower: the fixed
|
|
13
|
+
* layout spreads the rest over the columns by their declared widths, so a
|
|
14
|
+
* column declared `w` next to `others` is drawn `w * space / (w + others)`
|
|
15
|
+
* wide until the columns fill the space, and `w` from there on. With no other
|
|
16
|
+
* column the one column takes the space whatever its width: the identity.
|
|
17
|
+
*/
|
|
18
|
+
export declare const stretchedScale: (space: number, others: number) => WidthScale;
|
|
19
|
+
/**
|
|
20
|
+
* How the declared width of the column of `th` maps to its drawn width, read
|
|
21
|
+
* from the layout. The column is drawn once at the width it is drawn at now.
|
|
22
|
+
* Wider there, the table stretches it: its row's cells take the whole space,
|
|
23
|
+
* and the other columns' declared widths follow from the stretch; the fit
|
|
24
|
+
* must then give back the width the column is drawn at now. Not wider, the
|
|
25
|
+
* column is drawn once more at `low`, the narrowest width a resize writes. A
|
|
26
|
+
* table that stretches it there widens every cell of the row by one factor,
|
|
27
|
+
* the column at least as much (content the fixed layout keeps wider than
|
|
28
|
+
* `low` only adds to it), and its cells then take the space the columns can
|
|
29
|
+
* shrink into before the table stretches them. Any other layout gets the
|
|
30
|
+
* identity: one that never stretches, a column without a width that takes
|
|
31
|
+
* what is left, one that spreads the space otherwise. Every style is put back before the
|
|
32
|
+
* function returns (C-31), so nothing is painted in between.
|
|
33
|
+
*/
|
|
34
|
+
export declare const measureWidthScale: (th: HTMLElement, low: number) => WidthScale;
|
|
@@ -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,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
2
|
import type { ScrollToIndexOptions, VirtualOptions } from '../contract.js';
|
|
3
3
|
import type { BodyRow } from '../use-query-table.js';
|
|
4
4
|
import { type WindowRange } from './compute-window.js';
|
|
@@ -13,7 +13,7 @@ export interface SpacerRow {
|
|
|
13
13
|
}
|
|
14
14
|
export interface RowWindowOptions<T> {
|
|
15
15
|
virtual: () => boolean | VirtualOptions | undefined;
|
|
16
|
-
table:
|
|
16
|
+
table: Readonly<Ref<HTMLTableElement | null>>;
|
|
17
17
|
/** The rows in drawing order: pinned top, the others, pinned bottom (C-74). */
|
|
18
18
|
bodyRows: () => BodyRow<T>[];
|
|
19
19
|
keyOf: (row: T, index: number) => string | number;
|
|
@@ -28,8 +28,8 @@ export interface RowWindowOptions<T> {
|
|
|
28
28
|
export declare const useRowWindow: <T extends object>(o: RowWindowOptions<T>) => {
|
|
29
29
|
enabled: () => boolean;
|
|
30
30
|
drawn: import("vue").ComputedRef<(SpacerRow | DrawnRow<T>)[]>;
|
|
31
|
-
range: ShallowRef<WindowRange, WindowRange>;
|
|
32
|
-
ready: ShallowRef<boolean, boolean>;
|
|
31
|
+
range: import("vue").ShallowRef<WindowRange, WindowRange>;
|
|
32
|
+
ready: import("vue").ShallowRef<boolean, boolean>;
|
|
33
33
|
centerCount: () => number;
|
|
34
34
|
expandedCount: () => number;
|
|
35
35
|
scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.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.8.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.8.0",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|