@dolusoft/query-table 3.0.1 → 3.2.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/local.js +88 -0
- package/dist/local.js.map +1 -0
- package/dist/query-table.js +1394 -180
- package/dist/query-table.js.map +1 -1
- package/dist/types/body/use-cell-view.d.ts +6 -3
- package/dist/types/columns/column-layout.d.ts +20 -0
- package/dist/types/contract.d.ts +154 -7
- package/dist/types/core/table-context.d.ts +10 -4
- package/dist/types/filter/focus-filter.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/local/index.d.ts +2 -0
- package/dist/types/local/use-local-query.d.ts +24 -0
- package/dist/types/parts/reorder-handle.vue.d.ts +7 -0
- package/dist/types/parts/table-body.vue.d.ts +13 -3
- package/dist/types/parts/table-footer.vue.d.ts +4 -2
- package/dist/types/parts/table-header.vue.d.ts +3 -3
- package/dist/types/pin/pin.d.ts +5 -3
- package/dist/types/pin/use-header-geometry.d.ts +8 -6
- package/dist/types/query-table.vue.d.ts +3 -1
- package/dist/types/reorder/use-column-reorder.d.ts +42 -0
- package/dist/types/use-query-table.d.ts +55 -3
- package/dist/types/virtual/compute-window.d.ts +46 -0
- package/dist/types/virtual/use-load-more.d.ts +35 -0
- package/dist/types/virtual/use-row-window.d.ts +38 -0
- package/package.json +7 -3
|
@@ -2,7 +2,7 @@ import { type FilterDraft, type Query } from '@dolusoft/query-protocol';
|
|
|
2
2
|
import { type FilterLabel } from '@dolusoft/query-table-core';
|
|
3
3
|
import { type VueTable } from '@tanstack/vue-table';
|
|
4
4
|
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
5
|
-
import type { Column, FilterCondition, PageCursors, PaginationSlotProps, QueryChangeReason, RowSelection, SortDirection, TableProps, TableQuery } from './contract.js';
|
|
5
|
+
import type { Column, ColumnChangeReason, ColumnControl, FilterCondition, PageCursors, PaginationSlotProps, QueryChangeReason, RowPinning, RowSelection, SortDirection, TableProps, TableQuery } from './contract.js';
|
|
6
6
|
/** The TanStack features of a Query Table, the two plugins included. */
|
|
7
7
|
declare const features: {
|
|
8
8
|
rowSortingFeature: import("@tanstack/table-core").TableFeature;
|
|
@@ -11,7 +11,10 @@ declare const features: {
|
|
|
11
11
|
globalFilteringFeature: import("@tanstack/table-core").TableFeature;
|
|
12
12
|
rowSelectionFeature: import("@tanstack/table-core").TableFeature;
|
|
13
13
|
rowExpandingFeature: import("@tanstack/table-core").TableFeature;
|
|
14
|
+
columnVisibilityFeature: import("@tanstack/table-core").TableFeature;
|
|
15
|
+
columnOrderingFeature: import("@tanstack/table-core").TableFeature;
|
|
14
16
|
columnPinningFeature: import("@tanstack/table-core").TableFeature;
|
|
17
|
+
rowPinningFeature: import("@tanstack/table-core").TableFeature;
|
|
15
18
|
serverQueryFeature: import("@tanstack/table-core").TableFeature;
|
|
16
19
|
filterInputFeature: import("@tanstack/table-core").TableFeature;
|
|
17
20
|
};
|
|
@@ -37,6 +40,11 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
|
|
|
37
40
|
searchDebounce?: MaybeRefOrGetter<number | undefined>;
|
|
38
41
|
/** The selected rows; `undefined` turns selection off. */
|
|
39
42
|
selection?: MaybeRefOrGetter<RowSelection | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* The pinned rows (C-74); `undefined`, or no `rowKey`, turns row pinning
|
|
45
|
+
* off.
|
|
46
|
+
*/
|
|
47
|
+
rowPinning?: MaybeRefOrGetter<RowPinning | undefined>;
|
|
40
48
|
/** Identity of a row. Without it the row index is the identity. */
|
|
41
49
|
rowKey?: MaybeRefOrGetter<RowKey<T>>;
|
|
42
50
|
/** Rows can expand (the `subtable` column). Defaults to `false`. */
|
|
@@ -47,6 +55,32 @@ export interface UseQueryTableOptions<T extends object, Q extends Query = TableQ
|
|
|
47
55
|
onQueryChange: (query: Q, reason: QueryChangeReason) => void;
|
|
48
56
|
/** Called with the new selection (its `true` entries) when the user changes it. */
|
|
49
57
|
onSelectionChange?: (selection: RowSelection) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Called once per user action that changes the layout, with a new array
|
|
60
|
+
* (C-68).
|
|
61
|
+
*/
|
|
62
|
+
onColumnsChange?: (columns: Column[], reason: ColumnChangeReason) => void;
|
|
63
|
+
/** Called with the new map when the user pins or unpins a row (C-74). */
|
|
64
|
+
onRowPinningChange?: (rowPinning: RowPinning) => void;
|
|
65
|
+
}
|
|
66
|
+
/** A row of the body in drawing order (C-74). */
|
|
67
|
+
export interface BodyRow<T> {
|
|
68
|
+
row: T;
|
|
69
|
+
/** The row's index in `rows`. */
|
|
70
|
+
index: number;
|
|
71
|
+
pinned: 'top' | 'bottom' | false;
|
|
72
|
+
}
|
|
73
|
+
/** Row pinning (C-74), owned by the consumer. */
|
|
74
|
+
export interface QueryTableRowPinning<T extends object> {
|
|
75
|
+
/** `rowPinning` and `rowKey` were given: rows can be pinned. */
|
|
76
|
+
enabled: ComputedRef<boolean>;
|
|
77
|
+
/** The rows to draw: pinned to the top first, pinned to the bottom last. */
|
|
78
|
+
rows: ComputedRef<BodyRow<T>[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Pin a row or unpin it (`false`): tells the consumer the new map; nothing
|
|
81
|
+
* for the position the row has, or while row pinning is off.
|
|
82
|
+
*/
|
|
83
|
+
pin: (row: T, index: number, position: 'top' | 'bottom' | false) => void;
|
|
50
84
|
}
|
|
51
85
|
/** A column the table draws and its position in `columns`, hidden ones included. */
|
|
52
86
|
export interface ColumnEntry {
|
|
@@ -120,13 +154,30 @@ export interface QueryTableSelection<T extends object> {
|
|
|
120
154
|
/** Select or deselect every row of the page. */
|
|
121
155
|
toggleAll: (value: boolean) => void;
|
|
122
156
|
}
|
|
157
|
+
/** The column layout actions (C-67 to C-70). */
|
|
158
|
+
export interface QueryTableLayout {
|
|
159
|
+
/** What the `header-<field>` and `filter-menu` slots receive as `control`. */
|
|
160
|
+
controlOf: (field: string) => ColumnControl;
|
|
161
|
+
/** The drawn columns of the field's region (left, center or right), in order. */
|
|
162
|
+
regionOf: (field: string) => string[];
|
|
163
|
+
/**
|
|
164
|
+
* Puts `field` right before or after `target` in `columns` and emits the
|
|
165
|
+
* order; nothing when `target` is not in the same region.
|
|
166
|
+
*/
|
|
167
|
+
moveColumn: (field: string, target: string, place: 'before' | 'after') => void;
|
|
168
|
+
}
|
|
123
169
|
export interface QueryTable<T extends object, Q extends Query = TableQuery> {
|
|
124
170
|
/** The TanStack table, for the advanced path (headless markup). */
|
|
125
171
|
table: VueTable<QueryTableFeatures, T>;
|
|
126
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* The columns to draw: hidden ones dropped; pinned left first, pinned
|
|
174
|
+
* right last (C-69).
|
|
175
|
+
*/
|
|
127
176
|
columns: ComputedRef<ColumnEntry[]>;
|
|
128
|
-
/** Some drawn column is pinned. */
|
|
177
|
+
/** Some drawn column is pinned to the left: the utility cells are pinned with it. */
|
|
129
178
|
hasPinned: ComputedRef<boolean>;
|
|
179
|
+
/** Visibility, order and pinning actions (C-67 to C-70). */
|
|
180
|
+
layout: QueryTableLayout;
|
|
130
181
|
sort: QueryTableSort;
|
|
131
182
|
filters: QueryTableFilters;
|
|
132
183
|
search: QueryTableSearch;
|
|
@@ -134,6 +185,7 @@ export interface QueryTable<T extends object, Q extends Query = TableQuery> {
|
|
|
134
185
|
pagination: ComputedRef<PaginationSlotProps>;
|
|
135
186
|
expansion: QueryTableExpansion<T>;
|
|
136
187
|
selection: QueryTableSelection<T>;
|
|
188
|
+
rowPinning: QueryTableRowPinning<T>;
|
|
137
189
|
/** The query a new action builds on (an update not yet answered included). */
|
|
138
190
|
baseQuery: () => Q;
|
|
139
191
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** A half-open range of item positions: `start` drawn, `end` not. */
|
|
2
|
+
export interface WindowRange {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
}
|
|
6
|
+
export interface WindowInput {
|
|
7
|
+
/**
|
|
8
|
+
* The top of every item from the top of the first one, and last the total
|
|
9
|
+
* height: `count + 1` numbers, never decreasing.
|
|
10
|
+
*/
|
|
11
|
+
offsets: ArrayLike<number>;
|
|
12
|
+
/** The top of the view, from the top of the first item. May be negative. */
|
|
13
|
+
scrollTop: number;
|
|
14
|
+
viewportHeight: number;
|
|
15
|
+
/** Items drawn beyond each edge of the view. */
|
|
16
|
+
overscan: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fills `offsets` from `heights`, starting at position `from` (the offsets
|
|
20
|
+
* before it are kept): `offsets[i + 1] = offsets[i] + heights[i]`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const fillOffsets: (heights: ArrayLike<number>, offsets: Float64Array, from?: number) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The item that holds the point `y`: the last position whose top is at most
|
|
25
|
+
* `y`, clamped to the items (0 for a point above them, the last item for a
|
|
26
|
+
* point below them). `-1` when there is no item.
|
|
27
|
+
*/
|
|
28
|
+
export declare const indexAt: (offsets: ArrayLike<number>, y: number) => number;
|
|
29
|
+
/** The items to draw: the ones in view and `overscan` more on each side. */
|
|
30
|
+
export declare const computeWindow: ({ offsets, scrollTop, viewportHeight, overscan }: WindowInput) => WindowRange;
|
|
31
|
+
/** A run of drawn items, or a spacer that stands for the items left out. */
|
|
32
|
+
export type Segment = {
|
|
33
|
+
from: number;
|
|
34
|
+
to: number;
|
|
35
|
+
} | {
|
|
36
|
+
spacer: number;
|
|
37
|
+
slot: 0 | 1 | 2;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The body between the pinned rows: an upper spacer, the drawn items and a
|
|
41
|
+
* lower spacer. A `kept` item outside the range (it holds the focus, C-86)
|
|
42
|
+
* is drawn on its own, with a spacer of its own between it and the range.
|
|
43
|
+
* Spacers of height 0 are left out. `slot` names a spacer's place, so a
|
|
44
|
+
* spacer keeps its identity while its height changes.
|
|
45
|
+
*/
|
|
46
|
+
export declare const segmentsOf: (offsets: ArrayLike<number>, range: WindowRange, kept: number | null) => Segment[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type PageCursors, type Query } from '@dolusoft/query-protocol';
|
|
2
|
+
import { type ShallowRef } from 'vue';
|
|
3
|
+
import type { InfiniteOptions } from '../contract.js';
|
|
4
|
+
export interface LoadMoreOptions {
|
|
5
|
+
infinite: () => boolean | InfiniteOptions | undefined;
|
|
6
|
+
rowKey: () => unknown;
|
|
7
|
+
rows: () => readonly unknown[];
|
|
8
|
+
query: () => Query;
|
|
9
|
+
totalRows: () => number | null;
|
|
10
|
+
cursors: () => PageCursors | null;
|
|
11
|
+
loading: () => boolean;
|
|
12
|
+
/** The next page action (C-05, C-56). */
|
|
13
|
+
nextPage: () => void;
|
|
14
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
15
|
+
/** The body is virtual (C-83). */
|
|
16
|
+
virtual: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* With `virtual`: the end of the drawn window among the center rows, and
|
|
19
|
+
* their number; `null` until the window was laid out (C-83).
|
|
20
|
+
*/
|
|
21
|
+
window: () => {
|
|
22
|
+
end: number;
|
|
23
|
+
count: number;
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Infinite scroll (C-88 to C-90): whether there is more to load, the
|
|
28
|
+
* automatic request near the end of `rows` and `loadMore`. The rows are
|
|
29
|
+
* the consumer's; the table only emits the next page action.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useLoadMore: (o: LoadMoreOptions) => {
|
|
32
|
+
enabled: import("vue").ComputedRef<boolean>;
|
|
33
|
+
canLoadMore: import("vue").ComputedRef<boolean>;
|
|
34
|
+
loadMore: () => void;
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ShallowRef } from 'vue';
|
|
2
|
+
import type { ScrollToIndexOptions, VirtualOptions } from '../contract.js';
|
|
3
|
+
import type { BodyRow } from '../use-query-table.js';
|
|
4
|
+
import { type WindowRange } from './compute-window.js';
|
|
5
|
+
/** A row the body draws, with its `aria-rowindex` when the body is virtual. */
|
|
6
|
+
export type DrawnRow<T> = BodyRow<T> & {
|
|
7
|
+
aria?: number;
|
|
8
|
+
};
|
|
9
|
+
/** A spacer row: the height of the items it stands for (C-83). */
|
|
10
|
+
export interface SpacerRow {
|
|
11
|
+
spacer: number;
|
|
12
|
+
key: symbol;
|
|
13
|
+
}
|
|
14
|
+
export interface RowWindowOptions<T> {
|
|
15
|
+
virtual: () => boolean | VirtualOptions | undefined;
|
|
16
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
17
|
+
/** The rows in drawing order: pinned top, the others, pinned bottom (C-74). */
|
|
18
|
+
bodyRows: () => BodyRow<T>[];
|
|
19
|
+
keyOf: (row: T, index: number) => string | number;
|
|
20
|
+
isExpanded: (row: T, index: number) => boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The virtual body (C-83 to C-87): which rows are drawn, the spacers that
|
|
24
|
+
* stand for the others, the measured heights, the focused row kept drawn,
|
|
25
|
+
* printing and `scrollToIndex`. Without `virtual` it draws `bodyRows` as
|
|
26
|
+
* they are and touches no DOM.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useRowWindow: <T extends object>(o: RowWindowOptions<T>) => {
|
|
29
|
+
enabled: () => boolean;
|
|
30
|
+
drawn: import("vue").ComputedRef<(SpacerRow | DrawnRow<T>)[]>;
|
|
31
|
+
range: ShallowRef<WindowRange, WindowRange>;
|
|
32
|
+
ready: ShallowRef<boolean, boolean>;
|
|
33
|
+
centerCount: () => number;
|
|
34
|
+
expandedCount: () => number;
|
|
35
|
+
scrollToIndex: (index: number, options?: ScrollToIndexOptions) => void;
|
|
36
|
+
onFocusIn: (event: FocusEvent) => void;
|
|
37
|
+
onFocusOut: (event: FocusEvent) => void;
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.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",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/types/index.d.ts",
|
|
16
16
|
"default": "./dist/query-table.js"
|
|
17
|
+
},
|
|
18
|
+
"./local": {
|
|
19
|
+
"types": "./dist/types/local/index.d.ts",
|
|
20
|
+
"default": "./dist/local.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"engines": {
|
|
@@ -41,8 +45,8 @@
|
|
|
41
45
|
],
|
|
42
46
|
"license": "MIT",
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"@dolusoft/query-protocol": "3.0
|
|
45
|
-
"@dolusoft/query-table-core": "3.0
|
|
48
|
+
"@dolusoft/query-protocol": "3.2.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.2.0",
|
|
46
50
|
"@tanstack/vue-table": "9.2.6"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|