@dolusoft/query-table 3.5.1 → 3.7.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 +211 -27
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +24 -0
- package/dist/types/parts/table-header.vue.d.ts +2 -0
- package/dist/types/resize/measure-widths.d.ts +11 -0
- package/dist/types/resize/use-auto-width.d.ts +28 -0
- package/dist/types/resize/use-column-resize.d.ts +6 -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
|
|
@@ -597,4 +610,15 @@ export interface QueryTableExpose {
|
|
|
597
610
|
* error. Nothing while `loading` or when there is no next page.
|
|
598
611
|
*/
|
|
599
612
|
loadMore(): void;
|
|
613
|
+
/**
|
|
614
|
+
* The width each drawn column needs for its content (C-99), by `field`:
|
|
615
|
+
* the header label and the cells of the drawn data rows, padding and
|
|
616
|
+
* border included, in whole pixels rounded up, as the browser lays them
|
|
617
|
+
* out without widths. The filter row and the resize handle do not count.
|
|
618
|
+
* Not clamped to `minWidth` and `maxWidth`. Only `fields`, when given; a
|
|
619
|
+
* hidden column, or a table that is not displayed, is left out. Emits
|
|
620
|
+
* nothing and keeps no width: writing one back as `Column.width` is the
|
|
621
|
+
* consumer's.
|
|
622
|
+
*/
|
|
623
|
+
measureColumnWidths(fields?: readonly string[]): Record<string, number>;
|
|
600
624
|
}
|
|
@@ -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
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The max-content width of each drawn column, by `field`: header label and
|
|
3
|
+
* the cells of the drawn data rows, padding and border included, in whole
|
|
4
|
+
* pixels rounded up. The browser lays the table out once with its automatic
|
|
5
|
+
* layout and no widths, the parts that do not count taken out, and every
|
|
6
|
+
* style is put back before the function returns: nothing is painted in
|
|
7
|
+
* between, and slot content that draws a block or a flex box counts with the
|
|
8
|
+
* width its content needs, not the width its cell gives it. Only `fields`
|
|
9
|
+
* when given; a column with no box (the table not displayed) is left out.
|
|
10
|
+
*/
|
|
11
|
+
export declare const measureColumnWidths: (table: HTMLTableElement | null | undefined, fields?: readonly string[]) => Record<string, number>;
|
|
@@ -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).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolusoft/query-table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.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.7.0",
|
|
49
|
+
"@dolusoft/query-table-core": "3.7.0",
|
|
50
50
|
"@tanstack/vue-table": "9.2.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|