@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Slots } from 'vue';
|
|
2
2
|
import type { CellContextMenuPayload, CellSlotProps, Column } from '../contract.js';
|
|
3
3
|
import type { ColumnEntry } from '../use-query-table.js';
|
|
4
4
|
export interface CellViewOptions<T extends object> {
|
|
@@ -8,11 +8,13 @@ export interface CellViewOptions<T extends object> {
|
|
|
8
8
|
rows: () => T[];
|
|
9
9
|
/** The drawn columns, to find the one a context menu event belongs to. */
|
|
10
10
|
entries: () => ColumnEntry[];
|
|
11
|
-
/** `--qt-pin-left` of each pinned cell, by key (C-47). */
|
|
11
|
+
/** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
|
|
12
12
|
offsets: () => Readonly<Record<string, number>>;
|
|
13
13
|
/** Someone listens to `cellContextMenu`; without one the menu is left alone. */
|
|
14
14
|
listening: () => boolean;
|
|
15
15
|
onContextMenu: (payload: CellContextMenuPayload<T>) => void;
|
|
16
|
+
/** Pin a row or unpin it (C-74). */
|
|
17
|
+
pinRow: (row: T, index: number, position: 'top' | 'bottom' | false) => void;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* What a body cell shows: its text, its attributes, the props for a
|
|
@@ -22,8 +24,9 @@ export declare const useCellView: <T extends object>(options: CellViewOptions<T>
|
|
|
22
24
|
cellText: (row: T, column: Column) => string;
|
|
23
25
|
cellAttrs: (entry: ColumnEntry) => {
|
|
24
26
|
'data-field': string;
|
|
27
|
+
'data-type': "string" | "number" | "integer" | "date" | "datetime" | "bool" | undefined;
|
|
25
28
|
};
|
|
26
29
|
hasCellSlot: (column: Column) => boolean;
|
|
27
|
-
slotProps: (row: T, column: Column, rowIndex: number) => CellSlotProps<T>;
|
|
30
|
+
slotProps: (row: T, column: Column, rowIndex: number, rowPinned: CellSlotProps<T>["rowPinned"]) => CellSlotProps<T>;
|
|
28
31
|
onContextMenu: (event: MouseEvent) => void;
|
|
29
32
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Column } from '../contract.js';
|
|
2
|
+
/** Side a column is pinned to; `false` when it is not pinned. */
|
|
3
|
+
export type PinSide = 'left' | 'right' | false;
|
|
4
|
+
export declare const sideOf: (column: Column) => PinSide;
|
|
5
|
+
/** The columns with the visibility of `visibility`; `null` when nothing changes. */
|
|
6
|
+
export declare const applyVisibility: (columns: Column[], visibility: Record<string, boolean>) => Column[] | null;
|
|
7
|
+
/** The columns in `order` (unknown fields skipped, missing ones kept last); `null` when unchanged. */
|
|
8
|
+
export declare const applyOrder: (columns: Column[], order: string[]) => Column[] | null;
|
|
9
|
+
/** The columns with the sides of `pinning` (start = left, end = right); `null` when unchanged. */
|
|
10
|
+
export declare const applyPinning: (columns: Column[], pinning: {
|
|
11
|
+
start?: string[];
|
|
12
|
+
end?: string[];
|
|
13
|
+
}) => Column[] | null;
|
|
14
|
+
/** The columns with `field` at `width`; `null` when it already has it. */
|
|
15
|
+
export declare const applyWidth: (columns: Column[], field: string, width: string) => Column[] | null;
|
|
16
|
+
/**
|
|
17
|
+
* `field` taken out and put right before or after `target` (C-69): the
|
|
18
|
+
* columns between keep their place, hidden ones included.
|
|
19
|
+
*/
|
|
20
|
+
export declare const moveField: (fields: string[], field: string, target: string, place: "before" | "after") => string[];
|
package/dist/types/contract.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRul
|
|
|
18
18
|
* (`rowKey`, as a string). Only `true` entries count.
|
|
19
19
|
*/
|
|
20
20
|
export type RowSelection = Record<string, boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Rows pinned to the top or the bottom of the page (`v-model:rowPinning`,
|
|
23
|
+
* C-74): row keys (`rowKey` as a string) in the order they were pinned.
|
|
24
|
+
*/
|
|
25
|
+
export interface RowPinning {
|
|
26
|
+
top: string[];
|
|
27
|
+
bottom: string[];
|
|
28
|
+
}
|
|
21
29
|
/**
|
|
22
30
|
* Column definition. Pure data: the table never writes to these objects.
|
|
23
31
|
* Extend it with your own fields (`interface MyColumn extends Column {}`).
|
|
@@ -40,13 +48,16 @@ export interface Column {
|
|
|
40
48
|
*/
|
|
41
49
|
width?: string;
|
|
42
50
|
/**
|
|
43
|
-
* `'left'`
|
|
44
|
-
*
|
|
45
|
-
*
|
|
51
|
+
* `'left'` draws the column before the others, `'right'` after them;
|
|
52
|
+
* inside a side the order of `columns` holds. Their cells get
|
|
53
|
+
* `data-pinned` and the measured offset. Sticky positioning is the
|
|
54
|
+
* consumer's CSS.
|
|
46
55
|
*/
|
|
47
|
-
pinned?: 'left';
|
|
56
|
+
pinned?: 'left' | 'right';
|
|
48
57
|
/** Show a resize handle for this column (needs table `resizable`). Defaults to `true`. */
|
|
49
58
|
resizable?: boolean;
|
|
59
|
+
/** Show a reorder handle for this column (needs table `reorderable`). Defaults to `true`. */
|
|
60
|
+
reorderable?: boolean;
|
|
50
61
|
/**
|
|
51
62
|
* Smallest width a resize gives, in pixels. Defaults to `40`. A value that
|
|
52
63
|
* is not a finite number above `0` counts as unset.
|
|
@@ -57,7 +68,11 @@ export interface Column {
|
|
|
57
68
|
* is not a finite number above `0` counts as unset; a `minWidth` above it wins.
|
|
58
69
|
*/
|
|
59
70
|
maxWidth?: number;
|
|
60
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Not rendered in the header or the body; its rules in `query` still
|
|
73
|
+
* apply. The table emits `update:columns` with `hide: true` when the user
|
|
74
|
+
* hides it (`control.hide()`).
|
|
75
|
+
*/
|
|
61
76
|
hide?: boolean;
|
|
62
77
|
/** Show a filter input for this column (needs table `filterable`). Defaults to `true`. */
|
|
63
78
|
filterable?: boolean;
|
|
@@ -95,13 +110,22 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
95
110
|
* no selection. Keys are the row identity (`rowKey`) as a string.
|
|
96
111
|
*/
|
|
97
112
|
selection?: RowSelection;
|
|
113
|
+
/**
|
|
114
|
+
* Rows pinned to the top or the bottom of the page, used with
|
|
115
|
+
* `v-model:rowPinning` (C-74). Keys are `rowKey` as a string; needs
|
|
116
|
+
* `rowKey`. Keys of rows not in `rows` stay and are not drawn.
|
|
117
|
+
*/
|
|
118
|
+
rowPinning?: RowPinning;
|
|
98
119
|
/**
|
|
99
120
|
* Milliseconds between the last key of a search typed through the
|
|
100
121
|
* `toolbar` slot and the search being applied (C-58). `0` applies every
|
|
101
122
|
* call at once, for a consumer that debounces on its own. Defaults to `300`.
|
|
102
123
|
*/
|
|
103
124
|
searchDebounce?: number;
|
|
104
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Column definitions, used with `v-model:columns` when the user may
|
|
127
|
+
* change the layout. Never mutated.
|
|
128
|
+
*/
|
|
105
129
|
columns: Column[];
|
|
106
130
|
/**
|
|
107
131
|
* Rows of the current page, drawn exactly as given.
|
|
@@ -140,6 +164,12 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
140
164
|
* the width back to `Column.width`.
|
|
141
165
|
*/
|
|
142
166
|
resizable?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Draw a reorder handle at the start of the header cells (needs column
|
|
169
|
+
* `reorderable`): dragging it, or the arrow keys, Home and End on it, move
|
|
170
|
+
* a column within its region and emit `update:columns`. Defaults to `false`.
|
|
171
|
+
*/
|
|
172
|
+
reorderable?: boolean;
|
|
143
173
|
/** Milliseconds between the last key and the filter being applied. `0` applies on every keystroke. Defaults to `100`. */
|
|
144
174
|
filterDebounce?: number;
|
|
145
175
|
/** Options of the `pagination` slot. Paging itself is always on. */
|
|
@@ -167,6 +197,51 @@ export interface TableProps<T extends object = Record<string, unknown>, Q extend
|
|
|
167
197
|
* their English defaults.
|
|
168
198
|
*/
|
|
169
199
|
labels?: Partial<TableLabels>;
|
|
200
|
+
/**
|
|
201
|
+
* Draw only the rows in view of the scroll container, between two spacer
|
|
202
|
+
* rows (C-83). `true` takes the defaults. Give the table
|
|
203
|
+
* `table-layout: fixed` (C-85). Defaults to `false`.
|
|
204
|
+
*/
|
|
205
|
+
virtual?: boolean | VirtualOptions;
|
|
206
|
+
/**
|
|
207
|
+
* Ask for the next page (`update:query`, reason `page`) when the end of
|
|
208
|
+
* `rows` comes into view (C-88); append the rows of a `page` answer and
|
|
209
|
+
* replace them for any other reason. Needs `rowKey`. `true` takes the
|
|
210
|
+
* defaults. Defaults to `false`.
|
|
211
|
+
*/
|
|
212
|
+
infinite?: boolean | InfiniteOptions;
|
|
213
|
+
}
|
|
214
|
+
/** Options of `virtual` (C-83 to C-87). */
|
|
215
|
+
export interface VirtualOptions {
|
|
216
|
+
/** Height of every row in pixels: nothing is measured (C-84). */
|
|
217
|
+
rowHeight?: number;
|
|
218
|
+
/** Height counted for a row not measured yet. Defaults to the first measured row, else `32`. */
|
|
219
|
+
estimateRowHeight?: number;
|
|
220
|
+
/** Rows drawn beyond each edge of the view. Defaults to `10`. */
|
|
221
|
+
overscan?: number;
|
|
222
|
+
/**
|
|
223
|
+
* The scroll container. Defaults to the nearest scrolling ancestor of the
|
|
224
|
+
* table, else the window (C-85).
|
|
225
|
+
*/
|
|
226
|
+
scrollElement?: () => HTMLElement | null;
|
|
227
|
+
}
|
|
228
|
+
/** Options of `infinite` (C-88). */
|
|
229
|
+
export interface InfiniteOptions {
|
|
230
|
+
/** Ask for the next page when the last this many rows come near. Defaults to `5`. */
|
|
231
|
+
threshold?: number;
|
|
232
|
+
}
|
|
233
|
+
/** Options of `scrollToIndex` (C-87). */
|
|
234
|
+
export interface ScrollToIndexOptions {
|
|
235
|
+
/** Where the row ends up in the container. Defaults to `'auto'`: the nearest edge, nothing when in view. */
|
|
236
|
+
align?: 'start' | 'center' | 'end' | 'auto';
|
|
237
|
+
}
|
|
238
|
+
/** What the `load-more` slot receives (C-89). */
|
|
239
|
+
export interface LoadMoreSlotProps {
|
|
240
|
+
/** Ask for the next page now; nothing while `loading` or when `canLoadMore` is false. */
|
|
241
|
+
loadMore: () => void;
|
|
242
|
+
/** There is a next page (C-90). */
|
|
243
|
+
canLoadMore: boolean;
|
|
244
|
+
loading: boolean;
|
|
170
245
|
}
|
|
171
246
|
/**
|
|
172
247
|
* Every human-readable text the table renders itself. A function receives
|
|
@@ -185,6 +260,16 @@ export interface TableLabels {
|
|
|
185
260
|
filterOptions: (column: string) => string;
|
|
186
261
|
/** Name of a column's resize handle. Default `` name => `Resize ${name}` ``. */
|
|
187
262
|
resizeColumn: (column: string) => string;
|
|
263
|
+
/** Name of a column's reorder handle. Default `` name => `Move ${name}` ``. */
|
|
264
|
+
moveColumn: (column: string) => string;
|
|
265
|
+
/**
|
|
266
|
+
* The condition label under a filter input, and the `label` of each entry of
|
|
267
|
+
* `conditions` in the `filter-menu` slot. Receives the condition and the
|
|
268
|
+
* column type: one condition can read differently by type (`GreaterThan` is
|
|
269
|
+
* `'After (>)'` on a date). Default: the label in the protocol's
|
|
270
|
+
* `conditionOptions`, such as `'Contains'` or `'Greater Than (>)'`.
|
|
271
|
+
*/
|
|
272
|
+
filterCondition: (condition: FilterCondition, type: ColumnType) => string;
|
|
188
273
|
/** Bool filter option that removes the filter. Default `'All'`. */
|
|
189
274
|
boolAll: string;
|
|
190
275
|
/** Bool filter option for `true`. Default `'True'`. */
|
|
@@ -215,6 +300,30 @@ export interface ColumnResizePayload {
|
|
|
215
300
|
/** New width in whole pixels, within the column's `minWidth` and `maxWidth`. */
|
|
216
301
|
width: number;
|
|
217
302
|
}
|
|
303
|
+
/** What changed the layout in an `update:columns` event (C-68). */
|
|
304
|
+
export type ColumnChangeReason = 'visibility' | 'order' | 'pin' | 'resize';
|
|
305
|
+
/**
|
|
306
|
+
* Column actions handed to the `header-<field>` and `filter-menu` slots
|
|
307
|
+
* (C-70). Each action emits `update:columns`; the table changes nothing
|
|
308
|
+
* until the consumer writes the new `columns` back.
|
|
309
|
+
*/
|
|
310
|
+
export interface ColumnControl {
|
|
311
|
+
/** Side the column is pinned to, `false` when it is not pinned. */
|
|
312
|
+
pinned: 'left' | 'right' | false;
|
|
313
|
+
/** Pin to a side or unpin: one `update:columns` with reason `pin`. */
|
|
314
|
+
pin: (side: 'left' | 'right' | false) => void;
|
|
315
|
+
/** Hide the column: one `update:columns` with reason `visibility`. */
|
|
316
|
+
hide: () => void;
|
|
317
|
+
/** There is a visible column on the left within the column's region. */
|
|
318
|
+
canMoveLeft: boolean;
|
|
319
|
+
/** There is a visible column on the right within the column's region. */
|
|
320
|
+
canMoveRight: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Move one visible position within the region (C-69): one
|
|
323
|
+
* `update:columns` with reason `order`; nothing at the region's edge.
|
|
324
|
+
*/
|
|
325
|
+
move: (direction: 'left' | 'right') => void;
|
|
326
|
+
}
|
|
218
327
|
/** Events of the table. */
|
|
219
328
|
export type TableEmits<T, Q extends Query = TableQuery> = {
|
|
220
329
|
/**
|
|
@@ -240,12 +349,31 @@ export type TableEmits<T, Q extends Query = TableQuery> = {
|
|
|
240
349
|
* keeps its old width.
|
|
241
350
|
*/
|
|
242
351
|
columnResize: [payload: ColumnResizePayload];
|
|
352
|
+
/**
|
|
353
|
+
* The user changed the layout: visibility, order, pinning or a width
|
|
354
|
+
* (C-68). A new array; changed columns are new objects, the others are
|
|
355
|
+
* yours. Apply it with `v-model:columns`, or the table draws the old one.
|
|
356
|
+
*/
|
|
357
|
+
'update:columns': [columns: Column[], reason: ColumnChangeReason];
|
|
358
|
+
/**
|
|
359
|
+
* The user pinned or unpinned a row (C-74): a new map. Apply it with
|
|
360
|
+
* `v-model:rowPinning`, or the table draws the old order.
|
|
361
|
+
*/
|
|
362
|
+
'update:rowPinning': [rowPinning: RowPinning];
|
|
243
363
|
};
|
|
244
364
|
export interface CellSlotProps<T> {
|
|
245
365
|
row: T;
|
|
246
366
|
rowIndex: number;
|
|
247
367
|
column: Column;
|
|
248
368
|
cellValue: unknown;
|
|
369
|
+
/** Where the row is pinned (C-74): `'top'`, `'bottom'` or `false`. */
|
|
370
|
+
rowPinned: 'top' | 'bottom' | false;
|
|
371
|
+
/**
|
|
372
|
+
* Pin the row to the top or the bottom, or unpin it with `false`: one
|
|
373
|
+
* `update:rowPinning`; nothing for the position the row has, and nothing
|
|
374
|
+
* without `rowKey` and `rowPinning` (C-74).
|
|
375
|
+
*/
|
|
376
|
+
pinRow: (position: 'top' | 'bottom' | false) => void;
|
|
249
377
|
}
|
|
250
378
|
export interface HeaderSlotProps {
|
|
251
379
|
column: Column;
|
|
@@ -255,6 +383,8 @@ export interface HeaderSlotProps {
|
|
|
255
383
|
sortable: boolean;
|
|
256
384
|
/** Sort by this column as a header click does (C-07); does nothing when not `sortable`. */
|
|
257
385
|
toggleSort: () => void;
|
|
386
|
+
/** Layout actions of this column (C-70). */
|
|
387
|
+
control: ColumnControl;
|
|
258
388
|
}
|
|
259
389
|
export interface SubtableSlotProps<T> {
|
|
260
390
|
row: T;
|
|
@@ -279,7 +409,7 @@ export interface FilterMenuSlotProps {
|
|
|
279
409
|
rules: FilterRule[];
|
|
280
410
|
/** Condition shown for the column: the first rule's, else the one picked, else `null`. */
|
|
281
411
|
condition: FilterCondition | null;
|
|
282
|
-
/** Conditions that make sense for the column type. */
|
|
412
|
+
/** Conditions that make sense for the column type, labelled by `labels.filterCondition`. */
|
|
283
413
|
conditions: FilterConditionOption[];
|
|
284
414
|
/**
|
|
285
415
|
* Pick a condition. With a value typed the filter is applied; otherwise the
|
|
@@ -300,6 +430,8 @@ export interface FilterMenuSlotProps {
|
|
|
300
430
|
* single `button.qt-filter-button` and merges the attributes it receives.
|
|
301
431
|
*/
|
|
302
432
|
trigger: Component;
|
|
433
|
+
/** Layout actions of this column (C-70). */
|
|
434
|
+
control: ColumnControl;
|
|
303
435
|
}
|
|
304
436
|
export interface ToolbarSlotProps {
|
|
305
437
|
/** There is a filter rule or typed filter text to clear. */
|
|
@@ -362,6 +494,11 @@ export interface TableSlots<T> {
|
|
|
362
494
|
loading?(): unknown;
|
|
363
495
|
/** Paging controls. The block is drawn only when this slot is given. */
|
|
364
496
|
pagination?(props: PaginationSlotProps): unknown;
|
|
497
|
+
/**
|
|
498
|
+
* With `infinite`: the last row of the body while `loading` is off, in a
|
|
499
|
+
* `tr.qt-load-more-row`, for a "load more" or "try again" control (C-89).
|
|
500
|
+
*/
|
|
501
|
+
'load-more'?(props: LoadMoreSlotProps): unknown;
|
|
365
502
|
/**
|
|
366
503
|
* Header content of one column: `header-${column.field}`. It replaces the
|
|
367
504
|
* sort button or the title only; the header cell, its filter row and its
|
|
@@ -391,4 +528,14 @@ export interface QueryTableExpose {
|
|
|
391
528
|
* that has been emitted when the call returns.
|
|
392
529
|
*/
|
|
393
530
|
flushPendingFilters(): void;
|
|
531
|
+
/**
|
|
532
|
+
* Scroll the row with this index in `rows` into view (C-87). Emits
|
|
533
|
+
* nothing; an index outside `rows` does nothing.
|
|
534
|
+
*/
|
|
535
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
536
|
+
/**
|
|
537
|
+
* With `infinite`: ask for the next page now (C-89), as a retry after an
|
|
538
|
+
* error. Nothing while `loading` or when there is no next page.
|
|
539
|
+
*/
|
|
540
|
+
loadMore(): void;
|
|
394
541
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { TableLabels } from '../contract.js';
|
|
2
|
+
import type { ColumnReorder } from '../reorder/use-column-reorder.js';
|
|
2
3
|
import type { ColumnResize } from '../resize/use-column-resize.js';
|
|
3
|
-
import type { QueryTableFilters, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
|
|
4
|
+
import type { QueryTableFilters, QueryTableLayout, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
|
|
4
5
|
/**
|
|
5
|
-
* What the header parts call: the filter inputs
|
|
6
|
-
* composable, the resize
|
|
7
|
-
* travel here; data (`columns`, `query`)
|
|
6
|
+
* What the header parts call: the filter inputs, the sort gate and the
|
|
7
|
+
* layout actions of the composable, the resize and reorder actions and the
|
|
8
|
+
* labels. Only actions and getters travel here; data (`columns`, `query`)
|
|
9
|
+
* comes down as props.
|
|
8
10
|
*/
|
|
9
11
|
export interface TableContext {
|
|
10
12
|
filters: QueryTableFilters;
|
|
11
13
|
sort: QueryTableSort;
|
|
14
|
+
/** The `control` of the header and filter-menu slots (C-70). */
|
|
15
|
+
layout: QueryTableLayout;
|
|
12
16
|
resize: ColumnResize;
|
|
17
|
+
/** The reorder handles: drag, keys and the drag preview (C-73). */
|
|
18
|
+
reorder: ColumnReorder;
|
|
13
19
|
/** The select-all checkbox of the selection column (C-59). */
|
|
14
20
|
selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'toggleAll'>;
|
|
15
21
|
labels: () => TableLabels;
|
|
@@ -4,3 +4,8 @@
|
|
|
4
4
|
* Returns whether the element took focus.
|
|
5
5
|
*/
|
|
6
6
|
export declare const focusFilterOf: (table: HTMLTableElement | null, field: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Focuses the first filter of this table's header that takes the focus, in
|
|
9
|
+
* column order (C-22). Returns whether one did.
|
|
10
|
+
*/
|
|
11
|
+
export declare const focusFirstFilter: (table: HTMLTableElement | null) => boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import QueryTable from './query-table.vue.js';
|
|
|
2
2
|
export { QueryTable };
|
|
3
3
|
export default QueryTable;
|
|
4
4
|
export { parseFilterInput } from './filter/parse-filter-input.js';
|
|
5
|
-
export { useQueryTable, type ColumnEntry, type QueryTable as QueryTableState, type QueryTableExpansion, type QueryTableFeatures, type QueryTableFilters, type QueryTableSearch, type QueryTableSelection, type QueryTableSort, type RowKey, type UseQueryTableOptions } from './use-query-table.js';
|
|
5
|
+
export { useQueryTable, type BodyRow, type ColumnEntry, type QueryTable as QueryTableState, type QueryTableExpansion, type QueryTableFeatures, type QueryTableFilters, type QueryTableLayout, type QueryTableRowPinning, type QueryTableSearch, type QueryTableSelection, type QueryTableSort, type RowKey, type UseQueryTableOptions } from './use-query-table.js';
|
|
6
6
|
export type * from './contract.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Query } from '@dolusoft/query-protocol';
|
|
2
|
+
import { type Dataset, type LocalQueryError, type SemanticsProfile } from '@dolusoft/query-protocol/local';
|
|
3
|
+
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
export interface UseLocalQueryOptions<T> {
|
|
5
|
+
/** Every row of the source context. In-place changes in a deeply reactive array are seen; replace a shallowRef's array to trigger evaluation. */
|
|
6
|
+
allRows: MaybeRefOrGetter<readonly T[]>;
|
|
7
|
+
/** The consumer's query, read without writing or correcting it. */
|
|
8
|
+
query: MaybeRefOrGetter<Query>;
|
|
9
|
+
/** Replace together with allRows when the schema changes. */
|
|
10
|
+
dataset: MaybeRefOrGetter<Dataset<T>>;
|
|
11
|
+
profile: SemanticsProfile;
|
|
12
|
+
/** false returns every matching row for print or export. Defaults to true. */
|
|
13
|
+
paginate?: MaybeRefOrGetter<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalQuery<T> {
|
|
16
|
+
/** The supplied row objects; empty while error is set. */
|
|
17
|
+
rows: ComputedRef<T[]>;
|
|
18
|
+
/** The matching count; zero while error is set. */
|
|
19
|
+
totalRows: ComputedRef<number>;
|
|
20
|
+
/** Render this separately from an empty result. */
|
|
21
|
+
error: ComputedRef<LocalQueryError | null>;
|
|
22
|
+
}
|
|
23
|
+
/** Evaluates locally without rerunning filtering, search or sorting for a page-only change. */
|
|
24
|
+
export declare function useLocalQuery<T>(options: UseLocalQueryOptions<T>): LocalQuery<T>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Column } from '../contract.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
column: Column;
|
|
4
|
+
};
|
|
5
|
+
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>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import type { CellContextMenuPayload, TableLabels, TableSlots } from '../contract.js';
|
|
1
|
+
import type { CellContextMenuPayload, LoadMoreSlotProps, TableLabels, TableSlots } from '../contract.js';
|
|
2
2
|
import type { ColumnEntry } from '../use-query-table.js';
|
|
3
|
+
import type { DrawnRow, SpacerRow } from '../virtual/use-row-window.js';
|
|
3
4
|
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<{
|
|
4
5
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
5
6
|
rows: T[];
|
|
7
|
+
/**
|
|
8
|
+
* The rows in drawing order: pinned top, the others, pinned bottom (C-74);
|
|
9
|
+
* with `virtual` only the drawn ones, between spacers (C-83).
|
|
10
|
+
*/
|
|
11
|
+
bodyRows: Array<DrawnRow<T> | SpacerRow>;
|
|
12
|
+
/** Pin a row or unpin it (C-74). */
|
|
13
|
+
pinRow: (row: T, index: number, position: "top" | "bottom" | false) => void;
|
|
6
14
|
/** The consumer is fetching: no empty row, the `loading` row instead (C-52). */
|
|
7
15
|
loading: boolean;
|
|
8
16
|
/** The columns to draw, hidden ones already dropped. */
|
|
@@ -15,9 +23,9 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
15
23
|
hasSelection: boolean;
|
|
16
24
|
isSelected: (row: T, index: number) => boolean;
|
|
17
25
|
toggleSelected: (row: T, index: number) => void;
|
|
18
|
-
/**
|
|
26
|
+
/** Some column is pinned to the left: the utilities get `data-pinned` (C-46). */
|
|
19
27
|
hasPinned: boolean;
|
|
20
|
-
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
28
|
+
/** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
|
|
21
29
|
offsets: Readonly<Record<string, number>>;
|
|
22
30
|
keyOf: (row: T, index: number) => string | number;
|
|
23
31
|
isExpanded: (row: T, index: number) => boolean;
|
|
@@ -25,6 +33,8 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
25
33
|
labels: TableLabels;
|
|
26
34
|
/** The consumer listens to `cellContextMenu` (C-28); read at event time. */
|
|
27
35
|
hasContextMenuListener: () => boolean;
|
|
36
|
+
/** With `infinite`: what the `load-more` slot receives, else `null` (C-89). */
|
|
37
|
+
loadMore: LoadMoreSlotProps | null;
|
|
28
38
|
} & {
|
|
29
39
|
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
30
40
|
onCellContextMenu?: ((payload: CellContextMenuPayload<T>) => any) | undefined;
|
|
@@ -5,10 +5,12 @@ type __VLS_Props = {
|
|
|
5
5
|
entries: ColumnEntry[];
|
|
6
6
|
/** Cells before the first column (right panel, expand button). */
|
|
7
7
|
utilityCount: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Some column is pinned to the left: the utility cell gets `data-pinned` (C-46). */
|
|
9
9
|
hasPinned: boolean;
|
|
10
|
-
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
10
|
+
/** `--qt-pin-left` or `--qt-pin-right` of each pinned cell, by key (C-47, C-71). */
|
|
11
11
|
offsets: Readonly<Record<string, number>>;
|
|
12
|
+
/** With `virtual`: `aria-rowindex` of the first footer row (C-86). */
|
|
13
|
+
firstRowIndex?: number;
|
|
12
14
|
};
|
|
13
15
|
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>;
|
|
14
16
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Column, FilterDatetimeSlotProps, FilterMenuSlotProps, HeaderSlotProps, Query } from '../contract.js';
|
|
2
2
|
import { type Utility } from '../pin/pin.js';
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/** Columns to draw: hidden ones dropped, pinned
|
|
4
|
+
/** Columns to draw: hidden ones dropped, pinned left first, pinned right last. */
|
|
5
5
|
columns: Column[];
|
|
6
6
|
query: Query;
|
|
7
7
|
filterable: boolean;
|
|
8
8
|
/** Utility cells before the columns, in order. */
|
|
9
9
|
utilities: Utility[];
|
|
10
|
-
/**
|
|
10
|
+
/** Some column is pinned to the left: the utilities get `data-pinned` (C-46). */
|
|
11
11
|
hasPinned: boolean;
|
|
12
|
-
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
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
14
|
/**
|
|
15
15
|
* The header slots the consumer gave (`header-<field>`, `filter-datetime`,
|
package/dist/types/pin/pin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PinSide } from '../columns/column-layout.js';
|
|
1
2
|
/**
|
|
2
3
|
* Cells before the first column, in drawing order: the right panel, the
|
|
3
4
|
* expand button, the selection checkbox.
|
|
@@ -6,8 +7,9 @@ export type Utility = 'right-panel' | 'subtable' | 'select';
|
|
|
6
7
|
/** Geometry key of a utility cell; a column's key is its `field`. */
|
|
7
8
|
export declare const utilityKey: (utility: string) => string;
|
|
8
9
|
/**
|
|
9
|
-
* Attributes of a pinned cell (C-47): `data-pinned`
|
|
10
|
-
*
|
|
10
|
+
* Attributes of a pinned cell (C-47, C-71): `data-pinned` (`''` on the left,
|
|
11
|
+
* `'right'` on the right) and, once measured, the `--qt-pin-left` or
|
|
12
|
+
* `--qt-pin-right` offset in pixels, next to an optional `width`. Nothing but
|
|
11
13
|
* the width for a cell that is not pinned; no `style` when both are absent.
|
|
12
14
|
*/
|
|
13
|
-
export declare const pinAttrs: (
|
|
15
|
+
export declare const pinAttrs: (side: PinSide, offset: number | undefined, width?: string) => Record<string, unknown>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { type ShallowRef } from 'vue';
|
|
2
|
-
|
|
2
|
+
import type { PinSide } from '../columns/column-layout.js';
|
|
3
|
+
/** A drawn header cell, in order: its key (`field`, or the utility) and side. */
|
|
3
4
|
interface HeaderCellKey {
|
|
4
5
|
key: string;
|
|
5
|
-
|
|
6
|
+
side: PinSide;
|
|
6
7
|
}
|
|
7
8
|
export interface HeaderGeometryOptions {
|
|
8
9
|
/** The `table` element once it is mounted. */
|
|
9
10
|
table: ShallowRef<HTMLTableElement | null>;
|
|
10
11
|
/** The header cells as drawn: utilities first, then the columns. */
|
|
11
12
|
cells: () => HeaderCellKey[];
|
|
12
|
-
/** Some column is pinned (C-46) or has a resize handle (C-48). */
|
|
13
|
+
/** Some column is pinned on either side (C-46, C-71) or has a resize handle (C-48). */
|
|
13
14
|
active: () => boolean;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
* Measured header geometry (C-47, C-48): the rendered width of every
|
|
17
|
-
* cell and, for the pinned cells, the cumulative
|
|
18
|
-
* `--qt-pin-left
|
|
17
|
+
* Measured header geometry (C-47, C-48, C-71): the rendered width of every
|
|
18
|
+
* header cell and, for the pinned cells, the cumulative offset: from the left
|
|
19
|
+
* for a left-pinned cell (`--qt-pin-left`), from the right for a
|
|
20
|
+
* right-pinned one (`--qt-pin-right`). One `ResizeObserver` watches the header cells and the
|
|
19
21
|
* table; it reports width changes from any cause (a resize, a font that
|
|
20
22
|
* loads, a container that narrows) in one batched callback, after layout, so
|
|
21
23
|
* reading the cells there forces no extra layout. The observer is rebuilt
|
|
@@ -6,13 +6,15 @@ declare const __VLS_export: <T extends object, Q extends Query = TableQuery>(__V
|
|
|
6
6
|
"onUpdate:query"?: ((query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "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
|
+
"onUpdate:columns"?: ((columns: import("./contract.js").Column[], reason: import("./contract.js").ColumnChangeReason) => any) | undefined;
|
|
10
|
+
"onUpdate:rowPinning"?: ((rowPinning: import("./contract.js").RowPinning) => any) | undefined;
|
|
9
11
|
}> & (typeof globalThis extends {
|
|
10
12
|
__VLS_PROPS_FALLBACK: infer P;
|
|
11
13
|
} ? P : {});
|
|
12
14
|
expose: (exposed: import("vue").ShallowUnwrapRef<QueryTableExpose>) => void;
|
|
13
15
|
attrs: any;
|
|
14
16
|
slots: TableSlots<T>;
|
|
15
|
-
emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "search") => void) & ((evt: "update:selection", selection: import("./contract.js").RowSelection) => void) & ((evt: "columnResize", payload: import("./contract.js").ColumnResizePayload) => void);
|
|
17
|
+
emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: import("./contract.js").CellContextMenuPayload<T>) => void) & ((evt: "update:query", query: Q, reason: "page" | "pageSize" | "sort" | "filter" | "reset" | "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);
|
|
16
18
|
}>) => import("vue").VNode & {
|
|
17
19
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
18
20
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ShallowRef } from 'vue';
|
|
2
|
+
import type { Column } from '../contract.js';
|
|
3
|
+
import type { QueryTableLayout } from '../use-query-table.js';
|
|
4
|
+
export interface ColumnReorderOptions {
|
|
5
|
+
/** The `reorderable` prop: whether the table draws reorder handles. */
|
|
6
|
+
reorderable: () => boolean;
|
|
7
|
+
/** The table element: drop targets and refocus look at its own header only. */
|
|
8
|
+
table: ShallowRef<HTMLTableElement | null>;
|
|
9
|
+
layout: QueryTableLayout;
|
|
10
|
+
/** The `columns` prop: an outside change ends a drag (C-73). */
|
|
11
|
+
columns: () => Column[];
|
|
12
|
+
}
|
|
13
|
+
/** What the header shows while a column is dragged (C-73). */
|
|
14
|
+
export interface ColumnDrag {
|
|
15
|
+
field: string;
|
|
16
|
+
/** The header cell the column would be placed next to, if any. */
|
|
17
|
+
target: string | null;
|
|
18
|
+
place: 'before' | 'after';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reordering a column with its handle (C-73): a pointer drag or the arrow
|
|
22
|
+
* keys, Home and End, inside the column's region. The table keeps only the
|
|
23
|
+
* drag in progress (P15); the order itself goes out as `update:columns` and
|
|
24
|
+
* comes back, if the consumer wants it, as the order of `columns`. Like the
|
|
25
|
+
* resize handle, the handle captures the pointer, so every drag event
|
|
26
|
+
* arrives at the handle itself, and it has the focus, so Escape does too.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useColumnReorder: (options: ColumnReorderOptions) => {
|
|
29
|
+
isReorderable: (column: Column) => boolean;
|
|
30
|
+
dragging: ShallowRef<ColumnDrag | null, ColumnDrag | null>;
|
|
31
|
+
listeners: (column: () => Column) => {
|
|
32
|
+
pointerdown: (event: Event) => void;
|
|
33
|
+
pointermove: (event: Event) => void;
|
|
34
|
+
pointerup: (event: Event) => void;
|
|
35
|
+
pointercancel: (event: Event) => void;
|
|
36
|
+
lostpointercapture: (event: Event) => void;
|
|
37
|
+
keydown: (event: Event) => void;
|
|
38
|
+
blur: () => void;
|
|
39
|
+
click: (event: Event) => void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type ColumnReorder = ReturnType<typeof useColumnReorder>;
|