@dolusoft/query-table 3.2.1 → 3.3.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 +503 -18
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +29 -0
- package/dist/types/flash/marks.d.ts +45 -0
- package/dist/types/flash/read-duration.d.ts +13 -0
- package/dist/types/flash/use-change-flash.d.ts +38 -0
- package/dist/types/parts/table-body.vue.d.ts +6 -0
- package/dist/types/query-table.vue.d.ts +2 -2
- package/package.json +3 -3
package/dist/types/contract.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ColumnType, FilterCondition, FilterRule, PageCursors, Query, QueryChangeReason, SortDirection, TableQuery } from '@dolusoft/query-protocol';
|
|
2
|
+
import type { RowsUpdate } from '@dolusoft/query-table-core/row-changes';
|
|
2
3
|
import type { Component } from 'vue';
|
|
3
4
|
/**
|
|
4
5
|
* Public contract of `QueryTable`.
|
|
@@ -13,6 +14,11 @@ import type { Component } from 'vue';
|
|
|
13
14
|
* again so a consumer of the Vue package imports them from here, as in 2.2.x.
|
|
14
15
|
*/
|
|
15
16
|
export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRule, FilterValue, PageCursors, Query, QueryChangeReason, SortDirection, SortState, TableQuery } from '@dolusoft/query-protocol';
|
|
17
|
+
/**
|
|
18
|
+
* What produced the `rows` given with it (C-93), from the core's row-change
|
|
19
|
+
* module (`@dolusoft/query-table-core/row-changes`).
|
|
20
|
+
*/
|
|
21
|
+
export type { RowsUpdate } from '@dolusoft/query-table-core/row-changes';
|
|
16
22
|
/**
|
|
17
23
|
* Rows the user selected (`v-model:selection`), keyed by the row identity
|
|
18
24
|
* (`rowKey`, as a string). Only `true` entries count.
|
|
@@ -210,6 +216,29 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
210
216
|
* defaults. Defaults to `false`.
|
|
211
217
|
*/
|
|
212
218
|
infinite?: boolean | InfiniteOptions;
|
|
219
|
+
/**
|
|
220
|
+
* Flash the rows that are new and the cells whose value changed while the
|
|
221
|
+
* query stays the same (C-93, C-94). Off by default; needs `rowKey`, and a
|
|
222
|
+
* changed row must be a new object. The table finds the change and marks
|
|
223
|
+
* it with `data-flash`; the skin draws it and sets its length with
|
|
224
|
+
* `--qt-flash-duration`. `true` flashes both; `{ rows, cells }` picks.
|
|
225
|
+
*/
|
|
226
|
+
flash?: boolean | FlashOptions;
|
|
227
|
+
/**
|
|
228
|
+
* What produced the current `rows`, read when `rows` changes (C-93):
|
|
229
|
+
* `live` may flash; `snapshot` (an answer to a query), `append` (a page
|
|
230
|
+
* added) and `reset` (another source) never do, and `snapshot` and
|
|
231
|
+
* `reset` clear every flash. Without it the table tells an answer from a
|
|
232
|
+
* live change by the query, `loading` and the first rows: a best effort.
|
|
233
|
+
*/
|
|
234
|
+
rowsUpdate?: RowsUpdate;
|
|
235
|
+
}
|
|
236
|
+
/** Options of `flash` (C-93). */
|
|
237
|
+
export interface FlashOptions {
|
|
238
|
+
/** Flash a row whose key is new. Defaults to `true`. */
|
|
239
|
+
rows?: boolean;
|
|
240
|
+
/** Flash a cell whose value changed. Defaults to `true`. */
|
|
241
|
+
cells?: boolean;
|
|
213
242
|
}
|
|
214
243
|
/** Options of `virtual` (C-83 to C-87). */
|
|
215
244
|
export interface VirtualOptions {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { RowChangeKey } from '@dolusoft/query-table-core/row-changes';
|
|
2
|
+
/** The value of `data-flash`: a new value restarts the CSS animation. */
|
|
3
|
+
export type FlashPhase = 'a' | 'b';
|
|
4
|
+
/**
|
|
5
|
+
* One running flash. Updated in place when it restarts, so a stream of
|
|
6
|
+
* changes allocates nothing per change (C-94).
|
|
7
|
+
*/
|
|
8
|
+
export interface Mark {
|
|
9
|
+
/** `performance.now()` when the flash began. */
|
|
10
|
+
start: number;
|
|
11
|
+
/** `start` plus the duration: from then on the mark is not drawn. */
|
|
12
|
+
end: number;
|
|
13
|
+
/** Bumped on every start or restart: the identity of this flash. */
|
|
14
|
+
gen: number;
|
|
15
|
+
phase: FlashPhase;
|
|
16
|
+
/** The frame the phase last changed in: one change per frame. */
|
|
17
|
+
flipFrame: number;
|
|
18
|
+
}
|
|
19
|
+
/** The marks of one row key: the row flash and the cell flashes by field. */
|
|
20
|
+
export interface RowMarks {
|
|
21
|
+
row: Mark | null;
|
|
22
|
+
cells: Map<string, Mark> | null;
|
|
23
|
+
}
|
|
24
|
+
/** A mark that is still running at `now`, else `null`. */
|
|
25
|
+
export declare const live: (mark: Mark | null | undefined, now: number) => Mark | null;
|
|
26
|
+
/**
|
|
27
|
+
* The marks of one table (C-94): row and cell flashes by row key. Starting
|
|
28
|
+
* a flash that runs already restarts it, and the phase changes at most once
|
|
29
|
+
* a frame, so changes within one frame are one visual restart (K33-4).
|
|
30
|
+
*/
|
|
31
|
+
export declare const createMarks: () => {
|
|
32
|
+
get: (key: RowChangeKey) => RowMarks | undefined;
|
|
33
|
+
readonly size: number;
|
|
34
|
+
/** The generation of the last start. */
|
|
35
|
+
readonly gen: number;
|
|
36
|
+
flashRow: (key: RowChangeKey, now: number, duration: number, frame: number) => void;
|
|
37
|
+
flashCell: (key: RowChangeKey, field: string, now: number, duration: number, frame: number) => void;
|
|
38
|
+
clearRows: () => boolean;
|
|
39
|
+
clearCells: (fields?: readonly string[]) => boolean;
|
|
40
|
+
clear: () => boolean;
|
|
41
|
+
prune: (until: number) => {
|
|
42
|
+
nearest: number;
|
|
43
|
+
dropped: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CSS time in milliseconds: `250ms`, `2s`, `.5s`. Anything else (a
|
|
3
|
+
* missing value, `calc()`, a negative or a zero time, a number without a
|
|
4
|
+
* unit) is `0`: no flash.
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseDuration: (text: string) => number;
|
|
7
|
+
/**
|
|
8
|
+
* The flash duration the skin set on the table root (`.qt-datatable`) or
|
|
9
|
+
* above it, in milliseconds; `0` without one. One style read: the caller
|
|
10
|
+
* reads it at most once a frame, and only for an update that marks
|
|
11
|
+
* something (C-94).
|
|
12
|
+
*/
|
|
13
|
+
export declare const readDuration: (table: Element | null) => number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type RowsUpdate } from '@dolusoft/query-table-core/row-changes';
|
|
2
|
+
import { type ShallowRef, type VNode } from 'vue';
|
|
3
|
+
import type { FlashOptions, Query } from '../contract.js';
|
|
4
|
+
import type { RowKey } from '../use-query-table.js';
|
|
5
|
+
import { type FlashPhase } from './marks.js';
|
|
6
|
+
export interface ChangeFlashOptions<T extends object> {
|
|
7
|
+
flash: () => boolean | FlashOptions | undefined;
|
|
8
|
+
rowsUpdate: () => RowsUpdate | undefined;
|
|
9
|
+
rows: () => readonly T[];
|
|
10
|
+
query: () => Query;
|
|
11
|
+
loading: () => boolean;
|
|
12
|
+
/** The fields of the drawn columns. */
|
|
13
|
+
fields: () => readonly string[];
|
|
14
|
+
rowKey: () => RowKey<T>;
|
|
15
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
16
|
+
}
|
|
17
|
+
/** 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;
|
|
23
|
+
/**
|
|
24
|
+
* `onVnodeBeforeMount` and `onVnodeUpdated` of a data row: writes
|
|
25
|
+
* `--qt-flash-elapsed` on the row and on its cells that were bound after
|
|
26
|
+
* their flash began, or whose flash changed.
|
|
27
|
+
*/
|
|
28
|
+
bind: (vnode: VNode) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The change flash of `QueryTable` (C-93 to C-95). Off, it sets up one
|
|
32
|
+
* watcher that reads `flash` and nothing else: no comparison, timer, frame
|
|
33
|
+
* callback, listener, style read or memory per row. On, the same watcher
|
|
34
|
+
* also reads what the tracker compares, and the flash runs in an effect
|
|
35
|
+
* scope of its own; stopping that scope undoes everything. Nothing runs on
|
|
36
|
+
* the server: the flash starts once the table is mounted.
|
|
37
|
+
*/
|
|
38
|
+
export declare const useChangeFlash: <T extends object>(o: ChangeFlashOptions<T>) => ShallowRef<FlashView<T> | null>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CellContextMenuPayload, LoadMoreSlotProps, TableLabels, TableSlots } from '../contract.js';
|
|
2
|
+
import type { FlashView } from '../flash/use-change-flash.js';
|
|
2
3
|
import type { ColumnEntry } from '../use-query-table.js';
|
|
3
4
|
import type { DrawnRow, SpacerRow } from '../virtual/use-row-window.js';
|
|
4
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<{
|
|
@@ -35,6 +36,11 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
35
36
|
hasContextMenuListener: () => boolean;
|
|
36
37
|
/** With `infinite`: what the `load-more` slot receives, else `null` (C-89). */
|
|
37
38
|
loadMore: LoadMoreSlotProps | null;
|
|
39
|
+
/**
|
|
40
|
+
* With `flash`: the marks and the binding hook (C-94), else `null`; off,
|
|
41
|
+
* the body draws what it drew in 3.2 and calls nothing per row (C-95).
|
|
42
|
+
*/
|
|
43
|
+
flash: FlashView<T> | null;
|
|
38
44
|
} & {
|
|
39
45
|
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
40
46
|
onCellContextMenu?: ((payload: CellContextMenuPayload<T>) => any) | undefined;
|
|
@@ -3,7 +3,7 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
|
|
|
3
3
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<TableProps<T, Q> & {
|
|
4
4
|
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
5
5
|
onCellContextMenu?: ((payload: import("./contract.js").CellContextMenuPayload<T>) => any) | undefined;
|
|
6
|
-
"onUpdate:query"?: ((query: Q, reason: "
|
|
6
|
+
"onUpdate:query"?: ((query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => any) | undefined;
|
|
7
7
|
"onUpdate:selection"?: ((selection: import("./contract.js").RowSelection) => any) | undefined;
|
|
8
8
|
onColumnResize?: ((payload: import("./contract.js").ColumnResizePayload) => any) | undefined;
|
|
9
9
|
"onUpdate:columns"?: ((columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => any) | undefined;
|
|
@@ -14,7 +14,7 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
|
|
|
14
14
|
expose: (exposed: import("vue").ShallowUnwrapRef<QueryTableExpose>) => void;
|
|
15
15
|
attrs: any;
|
|
16
16
|
slots: TableSlots<T>;
|
|
17
|
-
emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "
|
|
17
|
+
emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "reset" | "page" | "pageSize" | "sort" | "filter" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void) & ((evt: "update:columns", columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => void) & ((evt: "update:rowPinning", rowPinning: import("./contract.js").RowPinning) => void);
|
|
18
18
|
}>) => import("vue").VNode & {
|
|
19
19
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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.3.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.3.0",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|