@dolusoft/query-table 3.6.0 → 3.7.1
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 +226 -10
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +13 -0
- package/dist/types/parts/table-header.vue.d.ts +2 -0
- package/dist/types/resize/measure-widths.d.ts +10 -0
- package/dist/types/resize/use-auto-width.d.ts +28 -0
- package/dist/types/resize/use-column-resize.d.ts +11 -1
- package/dist/types/resize/width-scale.d.ts +34 -0
- package/package.json +3 -3
package/dist/types/contract.d.ts
CHANGED
|
@@ -170,6 +170,19 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
170
170
|
* the width back to `Column.width`.
|
|
171
171
|
*/
|
|
172
172
|
resizable?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Draw each visible column without `Column.width` at the width its content
|
|
175
|
+
* needs (C-100): `measureColumnWidths` after the drawn rows change, clamped
|
|
176
|
+
* as a resize is. The width is drawn, not emitted or written to `columns`;
|
|
177
|
+
* a column with a `width` keeps it. Within one query (paging position,
|
|
178
|
+
* page size and sort aside) the widths only grow. Defaults to `false`.
|
|
179
|
+
*/
|
|
180
|
+
autoWidth?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* With `autoWidth`, the widest automatic width of a column without
|
|
183
|
+
* `maxWidth`, in pixels (C-100). Absent, there is no limit.
|
|
184
|
+
*/
|
|
185
|
+
autoWidthMax?: number;
|
|
173
186
|
/**
|
|
174
187
|
* Draw a reorder handle at the start of the header cells (needs column
|
|
175
188
|
* `reorderable`): dragging it, or the arrow keys, Home and End on it, move
|
|
@@ -11,6 +11,8 @@ type __VLS_Props = {
|
|
|
11
11
|
hasPinned: boolean;
|
|
12
12
|
/** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
|
|
13
13
|
offsets: Readonly<Record<string, number>>;
|
|
14
|
+
/** Automatic width of each column without a width, by `field` (C-100). */
|
|
15
|
+
autoWidths: Readonly<Record<string, number>>;
|
|
14
16
|
/**
|
|
15
17
|
* The header slots the consumer gave (`header-<field>`, `filter-datetime`,
|
|
16
18
|
* `filter-menu`), space-separated. The slots below are always passed so
|
|
@@ -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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Query } from '@dolusoft/query-protocol';
|
|
2
|
+
import type { RowsUpdate } from '@dolusoft/query-table-core/row-changes';
|
|
3
|
+
import { type ShallowRef } from 'vue';
|
|
4
|
+
import type { Column } from '../contract.js';
|
|
5
|
+
export interface AutoWidthOptions {
|
|
6
|
+
/** The `autoWidth` prop. */
|
|
7
|
+
enabled: () => boolean;
|
|
8
|
+
/** The `autoWidthMax` prop: the limit of a column without `maxWidth`. */
|
|
9
|
+
max: () => number | undefined;
|
|
10
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
11
|
+
/** The visible columns, as given. */
|
|
12
|
+
columns: () => Column[];
|
|
13
|
+
rows: () => readonly unknown[];
|
|
14
|
+
query: () => Query;
|
|
15
|
+
rowsUpdate: () => RowsUpdate | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Automatic column widths (C-100, ADR 0014). With `autoWidth`, every visible
|
|
19
|
+
* column without `Column.width` is measured (C-99) after the drawn rows
|
|
20
|
+
* change, clamped as a resize is (C-49), and drawn at that width. The widths
|
|
21
|
+
* are UI state (P2): never emitted, never written to `columns`, gone when
|
|
22
|
+
* `autoWidth` is off or the column gets a width. Within one result (the query
|
|
23
|
+
* apart from its paging position, page size and sort) they only grow, so a
|
|
24
|
+
* page, a sort or a live tick never narrows a column.
|
|
25
|
+
*/
|
|
26
|
+
export declare const useAutoWidth: (options: AutoWidthOptions) => {
|
|
27
|
+
widths: ShallowRef<Readonly<Record<string, number>>, Readonly<Record<string, number>>>;
|
|
28
|
+
};
|
|
@@ -8,6 +8,12 @@ export interface ColumnResizeOptions {
|
|
|
8
8
|
tableWidth: () => number;
|
|
9
9
|
emit: (payload: ColumnResizePayload) => void;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* A width limit a consumer gave, or `undefined` when it cannot be one. The
|
|
13
|
+
* types say `number`, but a loosely typed consumer can pass `''`, `NaN`,
|
|
14
|
+
* `0` or a negative: those count as unset instead of clamping to 0.
|
|
15
|
+
*/
|
|
16
|
+
export declare const limitOf: (value: unknown) => number | undefined;
|
|
11
17
|
/**
|
|
12
18
|
* The smallest width: `Column.minWidth`, else the default 40 (which gives way
|
|
13
19
|
* to a smaller `Column.maxWidth`, so a maximum alone keeps working).
|
|
@@ -19,15 +25,19 @@ export declare const clampWidth: (column: Column, width: number) => number;
|
|
|
19
25
|
* drag is under way (the preview, P2); every committed width goes out as a
|
|
20
26
|
* `columnResize` event and comes back, if the consumer wants it, as
|
|
21
27
|
* `Column.width`. The handle captures the pointer, so all drag events arrive
|
|
22
|
-
* at the handle itself, and it has the focus, so Escape does too.
|
|
28
|
+
* at the handle itself, and it has the focus, so Escape does too. The pointer
|
|
29
|
+
* and the arrow keys move the drawn width; what the table writes and emits is
|
|
30
|
+
* the declared width that draws it (`measureWidthScale`).
|
|
23
31
|
*/
|
|
24
32
|
export declare const useColumnResize: (options: ColumnResizeOptions) => {
|
|
25
33
|
preview: import("vue").ShallowRef<{
|
|
26
34
|
field: string;
|
|
27
35
|
width: number;
|
|
36
|
+
rendered: number;
|
|
28
37
|
} | null, {
|
|
29
38
|
field: string;
|
|
30
39
|
width: number;
|
|
40
|
+
rendered: number;
|
|
31
41
|
} | null>;
|
|
32
42
|
isResizable: (column: Column) => boolean;
|
|
33
43
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
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.7.1",
|
|
49
|
+
"@dolusoft/query-table-core": "3.7.1",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|