@dolusoft/query-table 3.0.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/LICENSE.md +22 -0
- package/dist/query-table.js +1643 -0
- package/dist/query-table.js.map +1 -0
- package/dist/types/body/use-cell-view.d.ts +29 -0
- package/dist/types/contract.d.ts +394 -0
- package/dist/types/core/column.d.ts +3 -0
- package/dist/types/core/labels.d.ts +4 -0
- package/dist/types/core/table-context.d.ts +18 -0
- package/dist/types/filter/focus-filter.d.ts +6 -0
- package/dist/types/filter/parse-filter-input.d.ts +22 -0
- package/dist/types/filter/use-filter-trigger.d.ts +16 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/parts/filter-cell.vue.d.ts +19 -0
- package/dist/types/parts/filter-icon.vue.d.ts +6 -0
- package/dist/types/parts/resize-handle.vue.d.ts +7 -0
- package/dist/types/parts/sort-button.vue.d.ts +13 -0
- package/dist/types/parts/table-body.vue.d.ts +47 -0
- package/dist/types/parts/table-footer.vue.d.ts +15 -0
- package/dist/types/parts/table-header.vue.d.ts +35 -0
- package/dist/types/parts/table-pagination.vue.d.ts +16 -0
- package/dist/types/pin/pin.d.ts +13 -0
- package/dist/types/pin/use-header-geometry.d.ts +30 -0
- package/dist/types/query-table.vue.d.ts +25 -0
- package/dist/types/resize/use-column-resize.d.ts +46 -0
- package/dist/types/sort/sort.d.ts +3 -0
- package/dist/types/use-query-table.d.ts +146 -0
- package/package.json +57 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import type { ColumnType, FilterCondition, FilterRule, PageCursors, Query, QueryChangeReason, SortDirection, TableQuery } from '@dolusoft/query-protocol';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Public contract of `QueryTable`.
|
|
5
|
+
*
|
|
6
|
+
* Every type a consumer can touch lives in this file. The rendered component
|
|
7
|
+
* is described by `TableProps`, `TableEmits`, `TableSlots` and
|
|
8
|
+
* `QueryTableExpose`; `CONTRACT.md` is generated from this file and from
|
|
9
|
+
* the component, and `contract/rules.md` holds the behavior rules.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The query types are the protocol's (`@dolusoft/query-protocol`), exported
|
|
13
|
+
* again so a consumer of the Vue package imports them from here, as in 2.2.x.
|
|
14
|
+
*/
|
|
15
|
+
export type { ColumnType, CursorQuery, CursorRequest, FilterCondition, FilterRule, FilterValue, PageCursors, Query, QueryChangeReason, SortDirection, SortState, TableQuery } from '@dolusoft/query-protocol';
|
|
16
|
+
/**
|
|
17
|
+
* Rows the user selected (`v-model:selection`), keyed by the row identity
|
|
18
|
+
* (`rowKey`, as a string). Only `true` entries count.
|
|
19
|
+
*/
|
|
20
|
+
export type RowSelection = Record<string, boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Column definition. Pure data: the table never writes to these objects.
|
|
23
|
+
* Extend it with your own fields (`interface MyColumn extends Column {}`).
|
|
24
|
+
*/
|
|
25
|
+
export interface Column {
|
|
26
|
+
/**
|
|
27
|
+
* Row property shown in the column. A dotted path (`'a.b'`) reads nested
|
|
28
|
+
* values. The same string is used as `field` in `query.sort` and
|
|
29
|
+
* `query.filters`.
|
|
30
|
+
*/
|
|
31
|
+
field: string;
|
|
32
|
+
/** Header text. */
|
|
33
|
+
title?: string;
|
|
34
|
+
/** Defaults to `'string'`. Case-insensitive at runtime. */
|
|
35
|
+
type?: ColumnType;
|
|
36
|
+
/**
|
|
37
|
+
* Header width, any CSS length, written as the header cell's inline
|
|
38
|
+
* `width`. A resizable column takes the pixel width of a `columnResize`
|
|
39
|
+
* event back here (`${width}px`): the table keeps no width of its own.
|
|
40
|
+
*/
|
|
41
|
+
width?: string;
|
|
42
|
+
/**
|
|
43
|
+
* `'left'` keeps the column at the start of the table: pinned columns are
|
|
44
|
+
* drawn first, in their order, and their cells get `data-pinned` and the
|
|
45
|
+
* `--qt-pin-left` offset. Sticky positioning is the consumer's CSS.
|
|
46
|
+
*/
|
|
47
|
+
pinned?: 'left';
|
|
48
|
+
/** Show a resize handle for this column (needs table `resizable`). Defaults to `true`. */
|
|
49
|
+
resizable?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Smallest width a resize gives, in pixels. Defaults to `40`. A value that
|
|
52
|
+
* is not a finite number above `0` counts as unset.
|
|
53
|
+
*/
|
|
54
|
+
minWidth?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Largest width a resize gives, in pixels. No limit by default. A value that
|
|
57
|
+
* is not a finite number above `0` counts as unset; a `minWidth` above it wins.
|
|
58
|
+
*/
|
|
59
|
+
maxWidth?: number;
|
|
60
|
+
/** Not rendered in the header or the body; its rules in `query` still apply. */
|
|
61
|
+
hide?: boolean;
|
|
62
|
+
/** Show a filter input for this column (needs table `filterable`). Defaults to `true`. */
|
|
63
|
+
filterable?: boolean;
|
|
64
|
+
/** Allow sorting by this column (needs table `sortable`). Defaults to `true`. */
|
|
65
|
+
sortable?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** One row of the totals block under the body. */
|
|
68
|
+
export interface FooterRow {
|
|
69
|
+
cells: Array<{
|
|
70
|
+
field: string;
|
|
71
|
+
text: string | number;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
export interface PaginationOptions {
|
|
75
|
+
/** Offered page sizes, passed to the `pagination` slot. Defaults to `[10, 20, 30, 50, 100]`; `[]` offers none. */
|
|
76
|
+
pageSizeOptions?: number[];
|
|
77
|
+
/** Render the pagination block even when there are no rows and no total. Defaults to `false`. */
|
|
78
|
+
alwaysShow?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface TableProps<T extends object = Record<string, unknown>, Q extends Query = TableQuery> {
|
|
81
|
+
/**
|
|
82
|
+
* The table state, used with `v-model:query`. Required: the table is
|
|
83
|
+
* always controlled. A `CursorQuery` (a `cursor` key) pages by cursor.
|
|
84
|
+
*/
|
|
85
|
+
query: Q;
|
|
86
|
+
/**
|
|
87
|
+
* Cursor mode: the cursors of the page shown (C-56). The next and previous
|
|
88
|
+
* page controls step to them; without the one on a side there is no page
|
|
89
|
+
* on that side.
|
|
90
|
+
*/
|
|
91
|
+
cursors?: PageCursors | null;
|
|
92
|
+
/**
|
|
93
|
+
* Rows the user selected, used with `v-model:selection`. Given, a column
|
|
94
|
+
* of checkboxes is drawn after the other utility columns; absent, there is
|
|
95
|
+
* no selection. Keys are the row identity (`rowKey`) as a string.
|
|
96
|
+
*/
|
|
97
|
+
selection?: RowSelection;
|
|
98
|
+
/**
|
|
99
|
+
* Milliseconds between the last key of a search typed through the
|
|
100
|
+
* `toolbar` slot and the search being applied (C-58). `0` applies every
|
|
101
|
+
* call at once, for a consumer that debounces on its own. Defaults to `300`.
|
|
102
|
+
*/
|
|
103
|
+
searchDebounce?: number;
|
|
104
|
+
/** Column definitions. Never mutated. */
|
|
105
|
+
columns: Column[];
|
|
106
|
+
/**
|
|
107
|
+
* Rows of the current page, drawn exactly as given.
|
|
108
|
+
*
|
|
109
|
+
* With `hasSubtable` a row may carry an optional `isExpanded` boolean to
|
|
110
|
+
* seed its expansion state (for example a print or report view that opens
|
|
111
|
+
* every row). Whenever `rows` changes, `isExpanded: true` opens the row,
|
|
112
|
+
* `isExpanded: false` closes it, and a row without the field (or with any
|
|
113
|
+
* other value) keeps what the state is. It is a seed, not a binding: the
|
|
114
|
+
* table never writes it back, and the user's toggles stand until `rows`
|
|
115
|
+
* changes again. The field is not part of `T`; it is read from the row
|
|
116
|
+
* object as given.
|
|
117
|
+
*/
|
|
118
|
+
rows?: T[];
|
|
119
|
+
/**
|
|
120
|
+
* Total number of rows on the server, `null` when unknown. It only feeds
|
|
121
|
+
* the `pagination` slot; it never decides whether rows are drawn.
|
|
122
|
+
*/
|
|
123
|
+
totalRows?: number | null;
|
|
124
|
+
/** Rows of totals drawn in a `tfoot`. */
|
|
125
|
+
footerRows?: FooterRow[];
|
|
126
|
+
/**
|
|
127
|
+
* The consumer is fetching. The root gets `data-loading` and
|
|
128
|
+
* `aria-busy="true"`, the rows given stay drawn, the empty state is not
|
|
129
|
+
* shown and the `loading` slot is drawn as the last row of the body. The
|
|
130
|
+
* table blocks no interaction. Defaults to `false`.
|
|
131
|
+
*/
|
|
132
|
+
loading?: boolean;
|
|
133
|
+
/** Allow sorting from the headers (needs column `sortable`). Defaults to `false`. */
|
|
134
|
+
sortable?: boolean;
|
|
135
|
+
/** Show the filter row. Defaults to `false`. */
|
|
136
|
+
filterable?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Draw a resize handle in the header cells (needs column `resizable`).
|
|
139
|
+
* Defaults to `false`. The table emits `columnResize`; the consumer writes
|
|
140
|
+
* the width back to `Column.width`.
|
|
141
|
+
*/
|
|
142
|
+
resizable?: boolean;
|
|
143
|
+
/** Milliseconds between the last key and the filter being applied. `0` applies on every keystroke. Defaults to `100`. */
|
|
144
|
+
filterDebounce?: number;
|
|
145
|
+
/** Options of the `pagination` slot. Paging itself is always on. */
|
|
146
|
+
pagination?: PaginationOptions;
|
|
147
|
+
/**
|
|
148
|
+
* Add a column with an expand button and render the `subtable` slot under
|
|
149
|
+
* expanded rows. A row can start expanded with its `isExpanded` field (see
|
|
150
|
+
* `rows`). Defaults to `false`.
|
|
151
|
+
*/
|
|
152
|
+
hasSubtable?: boolean;
|
|
153
|
+
/** Add a column with a button that emits `rowRightPanelClick`. Defaults to `false`. */
|
|
154
|
+
hasRightPanel?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Identity of a row, for expansion state and for the rendered row (a row
|
|
157
|
+
* keeps the state of its `subtable` components when `rows` reorder): a
|
|
158
|
+
* property name or a function. A string is a direct property read, not a
|
|
159
|
+
* dotted path; use the function form for a nested value. Keys must be
|
|
160
|
+
* unique. Without it the row index is the identity and the expansion state
|
|
161
|
+
* resets whenever `rows` changes.
|
|
162
|
+
*/
|
|
163
|
+
rowKey?: (keyof T & string) | ((row: T, index: number) => string | number);
|
|
164
|
+
/**
|
|
165
|
+
* Text the table writes for people: accessible names and the options of a
|
|
166
|
+
* bool filter. Give only the entries you want to change; the rest keep
|
|
167
|
+
* their English defaults.
|
|
168
|
+
*/
|
|
169
|
+
labels?: Partial<TableLabels>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Every human-readable text the table renders itself. A function receives
|
|
173
|
+
* the column name: its `title`, else its `field`.
|
|
174
|
+
*/
|
|
175
|
+
export interface TableLabels {
|
|
176
|
+
/** Name and tooltip of the clear-all button. Default `'Clear all filters'`. */
|
|
177
|
+
clearAllFilters: string;
|
|
178
|
+
/** Name of a row's expand button. Default `'Expand row'`. */
|
|
179
|
+
expandRow: string;
|
|
180
|
+
/** Name of a row's right panel button. Default `'Open right panel'`. */
|
|
181
|
+
openRightPanel: string;
|
|
182
|
+
/** Name of a filter input. Default `` name => `Filter ${name}` ``. */
|
|
183
|
+
filterInput: (column: string) => string;
|
|
184
|
+
/** Name and tooltip of a filter button. Default `` name => `Filter options for ${name}` ``. */
|
|
185
|
+
filterOptions: (column: string) => string;
|
|
186
|
+
/** Name of a column's resize handle. Default `` name => `Resize ${name}` ``. */
|
|
187
|
+
resizeColumn: (column: string) => string;
|
|
188
|
+
/** Bool filter option that removes the filter. Default `'All'`. */
|
|
189
|
+
boolAll: string;
|
|
190
|
+
/** Bool filter option for `true`. Default `'True'`. */
|
|
191
|
+
boolTrue: string;
|
|
192
|
+
/** Bool filter option for `false`. Default `'False'`. */
|
|
193
|
+
boolFalse: string;
|
|
194
|
+
/** Name of a row's selection checkbox. Default `'Select row'`. */
|
|
195
|
+
selectRow: string;
|
|
196
|
+
/** Name of the checkbox that selects every row of the page. Default `'Select all rows'`. */
|
|
197
|
+
selectAllRows: string;
|
|
198
|
+
}
|
|
199
|
+
/** Payload of the `cellContextMenu` event. */
|
|
200
|
+
export interface CellContextMenuPayload<T> {
|
|
201
|
+
event: MouseEvent;
|
|
202
|
+
row: T;
|
|
203
|
+
/** The column definition the consumer passed. */
|
|
204
|
+
column: Column;
|
|
205
|
+
/** Value of the cell (`field` read from `row`). */
|
|
206
|
+
cellValue: unknown;
|
|
207
|
+
rowIndex: number;
|
|
208
|
+
/** Index into `columns`, hidden columns included. */
|
|
209
|
+
columnIndex: number;
|
|
210
|
+
}
|
|
211
|
+
/** Payload of the `columnResize` event. */
|
|
212
|
+
export interface ColumnResizePayload {
|
|
213
|
+
/** `field` of the resized column. */
|
|
214
|
+
field: string;
|
|
215
|
+
/** New width in whole pixels, within the column's `minWidth` and `maxWidth`. */
|
|
216
|
+
width: number;
|
|
217
|
+
}
|
|
218
|
+
/** Events of the table. */
|
|
219
|
+
export type TableEmits<T, Q extends Query = TableQuery> = {
|
|
220
|
+
/**
|
|
221
|
+
* The user changed the query. `reason` says how. The query is a new object
|
|
222
|
+
* with new `filters` and rule objects; apply it with `v-model:query`.
|
|
223
|
+
*/
|
|
224
|
+
'update:query': [query: Q, reason: QueryChangeReason];
|
|
225
|
+
/**
|
|
226
|
+
* The user changed the selection: a new object holding the `true` entries
|
|
227
|
+
* (C-59). Apply it with `v-model:selection`.
|
|
228
|
+
*/
|
|
229
|
+
'update:selection': [selection: RowSelection];
|
|
230
|
+
/** The right-panel button of a row was clicked. */
|
|
231
|
+
rowRightPanelClick: [row: T];
|
|
232
|
+
/**
|
|
233
|
+
* A cell was right-clicked. With a listener the browser menu is
|
|
234
|
+
* suppressed; without one the table emits nothing and keeps it.
|
|
235
|
+
*/
|
|
236
|
+
cellContextMenu: [payload: CellContextMenuPayload<T>];
|
|
237
|
+
/**
|
|
238
|
+
* The user resized a column: on release of a drag, on an arrow key or on
|
|
239
|
+
* autofit. Write `width` back to the column (`Column.width`), or the column
|
|
240
|
+
* keeps its old width.
|
|
241
|
+
*/
|
|
242
|
+
columnResize: [payload: ColumnResizePayload];
|
|
243
|
+
};
|
|
244
|
+
export interface CellSlotProps<T> {
|
|
245
|
+
row: T;
|
|
246
|
+
rowIndex: number;
|
|
247
|
+
column: Column;
|
|
248
|
+
cellValue: unknown;
|
|
249
|
+
}
|
|
250
|
+
export interface HeaderSlotProps {
|
|
251
|
+
column: Column;
|
|
252
|
+
/** Direction this column is sorted in, `null` when it is not the sorted one. */
|
|
253
|
+
sortDirection: SortDirection | null;
|
|
254
|
+
/** Sorting by this column is possible (table and column `sortable`). */
|
|
255
|
+
sortable: boolean;
|
|
256
|
+
/** Sort by this column as a header click does (C-07); does nothing when not `sortable`. */
|
|
257
|
+
toggleSort: () => void;
|
|
258
|
+
}
|
|
259
|
+
export interface SubtableSlotProps<T> {
|
|
260
|
+
row: T;
|
|
261
|
+
rowIndex: number;
|
|
262
|
+
}
|
|
263
|
+
export interface FilterDatetimeSlotProps {
|
|
264
|
+
column: Column;
|
|
265
|
+
/** Text currently in the filter input. */
|
|
266
|
+
value: string | undefined;
|
|
267
|
+
/** Replace the input text; the filter is applied after the debounce. */
|
|
268
|
+
updateValue: (value: string) => void;
|
|
269
|
+
}
|
|
270
|
+
/** One entry of the condition list offered for a column. */
|
|
271
|
+
export interface FilterConditionOption {
|
|
272
|
+
value: FilterCondition;
|
|
273
|
+
/** English label, for example `'Starts With'`. */
|
|
274
|
+
label: string;
|
|
275
|
+
}
|
|
276
|
+
export interface FilterMenuSlotProps {
|
|
277
|
+
column: Column;
|
|
278
|
+
/** Rules of this column currently in `query.filters`. */
|
|
279
|
+
rules: FilterRule[];
|
|
280
|
+
/** Condition shown for the column: the first rule's, else the one picked, else `null`. */
|
|
281
|
+
condition: FilterCondition | null;
|
|
282
|
+
/** Conditions that make sense for the column type. */
|
|
283
|
+
conditions: FilterConditionOption[];
|
|
284
|
+
/**
|
|
285
|
+
* Pick a condition. With a value typed the filter is applied; otherwise the
|
|
286
|
+
* pick waits for a value. `null` clears the filter.
|
|
287
|
+
*/
|
|
288
|
+
setCondition: (condition: FilterCondition | null) => void;
|
|
289
|
+
/** Remove the rules of this column. Sort is left alone. */
|
|
290
|
+
clear: () => void;
|
|
291
|
+
/** Sorting by this column is possible (table and column `sortable`). */
|
|
292
|
+
sortable: boolean;
|
|
293
|
+
/** Direction this column is sorted in, `null` when it is not the sorted one. */
|
|
294
|
+
sortDirection: SortDirection | null;
|
|
295
|
+
/** Sort by this column. */
|
|
296
|
+
setSort: (direction: SortDirection) => void;
|
|
297
|
+
/**
|
|
298
|
+
* The filter button, as a component to place in your popover trigger:
|
|
299
|
+
* `<PopoverTrigger as-child><trigger /></PopoverTrigger>`. It renders a
|
|
300
|
+
* single `button.qt-filter-button` and merges the attributes it receives.
|
|
301
|
+
*/
|
|
302
|
+
trigger: Component;
|
|
303
|
+
}
|
|
304
|
+
export interface ToolbarSlotProps {
|
|
305
|
+
/** There is a filter rule or typed filter text to clear. */
|
|
306
|
+
canClearFilters: boolean;
|
|
307
|
+
/** Remove every filter rule, the same as the clear-all button (C-22). */
|
|
308
|
+
clearFilters: () => void;
|
|
309
|
+
/** Search text to show: the text being typed, else `query.search`, else `''`. */
|
|
310
|
+
search: string;
|
|
311
|
+
/**
|
|
312
|
+
* The search input changed: the text is applied after `searchDebounce`,
|
|
313
|
+
* at once when it is `0` (C-58).
|
|
314
|
+
*/
|
|
315
|
+
setSearch: (text: string) => void;
|
|
316
|
+
/** Apply a typed search now (Enter). Does nothing when nothing is pending. */
|
|
317
|
+
applySearch: () => void;
|
|
318
|
+
}
|
|
319
|
+
export interface PaginationSlotProps {
|
|
320
|
+
page: number;
|
|
321
|
+
pageSize: number;
|
|
322
|
+
/** `null` when `totalRows` is unknown. */
|
|
323
|
+
pageCount: number | null;
|
|
324
|
+
totalRows: number | null;
|
|
325
|
+
pageSizeOptions: number[];
|
|
326
|
+
canPrevious: boolean;
|
|
327
|
+
/** `page < pageCount` when the total is known, else `rows.length >= pageSize`. */
|
|
328
|
+
canNext: boolean;
|
|
329
|
+
/** Go to a page; clamped to `[1, pageCount]` when the total is known. */
|
|
330
|
+
setPage: (page: number) => void;
|
|
331
|
+
nextPage: () => void;
|
|
332
|
+
previousPage: () => void;
|
|
333
|
+
/** Change the page size and return to page 1 in one update. */
|
|
334
|
+
setPageSize: (size: number) => void;
|
|
335
|
+
/**
|
|
336
|
+
* The query pages by cursor (C-56). There is no page number then: `page`
|
|
337
|
+
* is `1`, `pageCount` is `null`, and `canPrevious` / `canNext` say whether
|
|
338
|
+
* `cursors` hold a cursor on that side.
|
|
339
|
+
*/
|
|
340
|
+
cursorMode: boolean;
|
|
341
|
+
}
|
|
342
|
+
/** Slots of the table. Slot names are kebab-case. */
|
|
343
|
+
export interface TableSlots<T> {
|
|
344
|
+
/** Content above the table. */
|
|
345
|
+
toolbar?(props: ToolbarSlotProps): unknown;
|
|
346
|
+
/** Replaces the date input of `date` and `datetime` filters. */
|
|
347
|
+
'filter-datetime'?(props: FilterDatetimeSlotProps): unknown;
|
|
348
|
+
/**
|
|
349
|
+
* Content of the filter menu of a column; see `FilterMenuSlotProps`.
|
|
350
|
+
* Without it there is no filter button. A `bool` column does not render it:
|
|
351
|
+
* its select has no condition to pick.
|
|
352
|
+
*/
|
|
353
|
+
'filter-menu'?(props: FilterMenuSlotProps): unknown;
|
|
354
|
+
/** Content of an expanded row (needs `hasSubtable`). */
|
|
355
|
+
subtable?(props: SubtableSlotProps<T>): unknown;
|
|
356
|
+
/** Shown when there are no rows and `loading` is off. */
|
|
357
|
+
empty?(): unknown;
|
|
358
|
+
/**
|
|
359
|
+
* Drawn while `loading` is on, in a `tr.qt-loading-row` that is the last
|
|
360
|
+
* row of the body. The rows stay; place the row over them in your CSS.
|
|
361
|
+
*/
|
|
362
|
+
loading?(): unknown;
|
|
363
|
+
/** Paging controls. The block is drawn only when this slot is given. */
|
|
364
|
+
pagination?(props: PaginationSlotProps): unknown;
|
|
365
|
+
/**
|
|
366
|
+
* Header content of one column: `header-${column.field}`. It replaces the
|
|
367
|
+
* sort button or the title only; the header cell, its filter row and its
|
|
368
|
+
* resize handle stay. Draw a sort control with `toggleSort` if you want one.
|
|
369
|
+
*/
|
|
370
|
+
[key: `header-${string}`]: ((props: HeaderSlotProps) => unknown) | undefined;
|
|
371
|
+
/** Cell content of one column: `cell-${column.field}`. */
|
|
372
|
+
[key: `cell-${string}`]: ((props: CellSlotProps<T>) => unknown) | undefined;
|
|
373
|
+
}
|
|
374
|
+
/** What a template ref to the table exposes. */
|
|
375
|
+
export interface QueryTableExpose {
|
|
376
|
+
/** Close every expanded row. */
|
|
377
|
+
collapseAll(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Open every row in `rows` (needs `hasSubtable`). Rows that arrive later
|
|
380
|
+
* are not opened, and nothing is fetched.
|
|
381
|
+
*/
|
|
382
|
+
expandAll(): void;
|
|
383
|
+
/**
|
|
384
|
+
* Move focus to the filter of a column: its filter input, or the first
|
|
385
|
+
* focusable element the `filter-datetime` slot draws. Returns `false` when
|
|
386
|
+
* nothing took focus (no filter drawn for the field, a disabled select).
|
|
387
|
+
*/
|
|
388
|
+
focusFilter(field: string): boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Apply typed-but-not-yet-applied filter text now, in one `update:query`
|
|
391
|
+
* that has been emitted when the call returns.
|
|
392
|
+
*/
|
|
393
|
+
flushPendingFilters(): void;
|
|
394
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Column, TableLabels } from '../contract.js';
|
|
2
|
+
export declare const resolveLabels: (labels: Partial<TableLabels> | undefined) => TableLabels;
|
|
3
|
+
/** The name of a column in a label: its `title`, else its `field`. */
|
|
4
|
+
export declare const columnName: (column: Column) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TableLabels } from '../contract.js';
|
|
2
|
+
import type { ColumnResize } from '../resize/use-column-resize.js';
|
|
3
|
+
import type { QueryTableFilters, QueryTableSelection, QueryTableSort } from '../use-query-table.js';
|
|
4
|
+
/**
|
|
5
|
+
* What the header parts call: the filter inputs and the sort gate of the
|
|
6
|
+
* composable, the resize actions and the labels. Only actions and getters
|
|
7
|
+
* travel here; data (`columns`, `query`) comes down as props.
|
|
8
|
+
*/
|
|
9
|
+
export interface TableContext {
|
|
10
|
+
filters: QueryTableFilters;
|
|
11
|
+
sort: QueryTableSort;
|
|
12
|
+
resize: ColumnResize;
|
|
13
|
+
/** The select-all checkbox of the selection column (C-59). */
|
|
14
|
+
selection: Pick<QueryTableSelection<object>, 'allSelected' | 'someSelected' | 'toggleAll'>;
|
|
15
|
+
labels: () => TableLabels;
|
|
16
|
+
}
|
|
17
|
+
export declare const provideTableContext: (context: TableContext) => void;
|
|
18
|
+
export declare const useTableContext: () => TableContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focuses the filter of `field` in this table's own header (C-54). Header
|
|
3
|
+
* cells are walked directly, so a table nested in a slot is never searched.
|
|
4
|
+
* Returns whether the element took focus.
|
|
5
|
+
*/
|
|
6
|
+
export declare const focusFilterOf: (table: HTMLTableElement | null, field: string) => boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Column, FilterCondition, FilterRule } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* The rules the table emits when `text` is typed into the filter input of
|
|
4
|
+
* `column` (C-53): the same grammar and the same coercion per column type.
|
|
5
|
+
*
|
|
6
|
+
* - `string`: operator shortcuts (`*a*`, `a*`, `*a`, `!a`, `!*a*`, `a,b`);
|
|
7
|
+
* a segment without an operator uses `condition`.
|
|
8
|
+
* - `number`: one rule with a number value; text that is not a finite number
|
|
9
|
+
* gives `[]`.
|
|
10
|
+
* - `integer`: the same, but only a whole number; `2.5` gives `[]`.
|
|
11
|
+
* - `bool`: `'true'` or `'false'` gives one rule with a boolean value;
|
|
12
|
+
* anything else gives `[]`.
|
|
13
|
+
* - `date` and `datetime`: one rule with the trimmed text as its value; the
|
|
14
|
+
* text is not validated, as the input already gives an ISO date.
|
|
15
|
+
*
|
|
16
|
+
* `condition` is the one picked in the filter menu; without it the column
|
|
17
|
+
* type's default applies (`Contains` for text, `Equal` otherwise). Empty or
|
|
18
|
+
* blank text, and text that is only operators (`*`, `!`, `!*`), gives `[]`.
|
|
19
|
+
* Invalid input never throws. Pure: no Vue, no DOM; the column is not written.
|
|
20
|
+
* The grammar is the protocol's (`@dolusoft/query-protocol`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseFilterInput(text: string, column: Column, condition?: FilterCondition | null): FilterRule[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Component } from 'vue';
|
|
2
|
+
import type { Column, TableLabels } from '../contract.js';
|
|
3
|
+
export interface FilterTriggerOptions {
|
|
4
|
+
/** The column of this header cell, as the table has it now. */
|
|
5
|
+
column: () => Column;
|
|
6
|
+
labels: () => TableLabels;
|
|
7
|
+
isFiltered: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The filter button a `filter-menu` slot receives as `trigger` (C-34). It is
|
|
11
|
+
* created once, so a popover wrapped around it does not remount the button on
|
|
12
|
+
* every render. It reads reactive state when it renders, so it still updates:
|
|
13
|
+
* the column and the labels come from getters on each render, not from a
|
|
14
|
+
* capture, so a new title or label shows at once.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useFilterTrigger: (options: FilterTriggerOptions) => Component;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import QueryTable from './query-table.vue.js';
|
|
2
|
+
export { QueryTable };
|
|
3
|
+
export default QueryTable;
|
|
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';
|
|
6
|
+
export type * from './contract.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Column, ColumnType, FilterDatetimeSlotProps, FilterMenuSlotProps, Query } from '../contract.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
column: Column;
|
|
4
|
+
type: ColumnType;
|
|
5
|
+
query: Query;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
'filter-datetime'?(props: FilterDatetimeSlotProps): unknown;
|
|
9
|
+
'filter-menu'?(props: FilterMenuSlotProps): unknown;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: 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>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
filled?: boolean;
|
|
3
|
+
};
|
|
4
|
+
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>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Column, SortDirection } from '../contract.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
column: Column;
|
|
4
|
+
/** The direction the table is sorted in on this column, if any. */
|
|
5
|
+
direction: SortDirection | null;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
click: () => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
10
|
+
onClick?: (() => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CellContextMenuPayload, TableLabels, TableSlots } from '../contract.js';
|
|
2
|
+
import type { ColumnEntry } from '../use-query-table.js';
|
|
3
|
+
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
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
5
|
+
rows: T[];
|
|
6
|
+
/** The consumer is fetching: no empty row, the `loading` row instead (C-52). */
|
|
7
|
+
loading: boolean;
|
|
8
|
+
/** The columns to draw, hidden ones already dropped. */
|
|
9
|
+
entries: ColumnEntry[];
|
|
10
|
+
/** Cells a full-width row (subtable, empty) spans. */
|
|
11
|
+
columnCount: number;
|
|
12
|
+
hasSubtable: boolean;
|
|
13
|
+
hasRightPanel: boolean;
|
|
14
|
+
/** Draw the selection checkbox column (C-59). */
|
|
15
|
+
hasSelection: boolean;
|
|
16
|
+
isSelected: (row: T, index: number) => boolean;
|
|
17
|
+
toggleSelected: (row: T, index: number) => void;
|
|
18
|
+
/** Pinned cells, utilities included, get `data-pinned` (C-47). */
|
|
19
|
+
hasPinned: boolean;
|
|
20
|
+
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
21
|
+
offsets: Readonly<Record<string, number>>;
|
|
22
|
+
keyOf: (row: T, index: number) => string | number;
|
|
23
|
+
isExpanded: (row: T, index: number) => boolean;
|
|
24
|
+
toggle: (row: T, index: number) => void;
|
|
25
|
+
labels: TableLabels;
|
|
26
|
+
/** The consumer listens to `cellContextMenu` (C-28); read at event time. */
|
|
27
|
+
hasContextMenuListener: () => boolean;
|
|
28
|
+
} & {
|
|
29
|
+
onRowRightPanelClick?: ((row: T) => any) | undefined;
|
|
30
|
+
onCellContextMenu?: ((payload: CellContextMenuPayload<T>) => any) | undefined;
|
|
31
|
+
}> & (typeof globalThis extends {
|
|
32
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
33
|
+
} ? P : {});
|
|
34
|
+
expose: (exposed: {}) => void;
|
|
35
|
+
attrs: any;
|
|
36
|
+
slots: TableSlots<T>;
|
|
37
|
+
emit: ((evt: "rowRightPanelClick", row: T) => void) & ((evt: "cellContextMenu", payload: CellContextMenuPayload<T>) => void);
|
|
38
|
+
}>) => import("vue").VNode & {
|
|
39
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
40
|
+
};
|
|
41
|
+
declare const _default: typeof __VLS_export;
|
|
42
|
+
export default _default;
|
|
43
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
44
|
+
[K in keyof T]: T[K];
|
|
45
|
+
} : {
|
|
46
|
+
[K in keyof T as K]: T[K];
|
|
47
|
+
}) & {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FooterRow } from '../contract.js';
|
|
2
|
+
import type { ColumnEntry } from '../use-query-table.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
footerRows: FooterRow[];
|
|
5
|
+
entries: ColumnEntry[];
|
|
6
|
+
/** Cells before the first column (right panel, expand button). */
|
|
7
|
+
utilityCount: number;
|
|
8
|
+
/** Pinned cells, the utility cell included, get `data-pinned` (C-47). */
|
|
9
|
+
hasPinned: boolean;
|
|
10
|
+
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
11
|
+
offsets: Readonly<Record<string, number>>;
|
|
12
|
+
};
|
|
13
|
+
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
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Column, FilterDatetimeSlotProps, FilterMenuSlotProps, HeaderSlotProps, Query } from '../contract.js';
|
|
2
|
+
import { type Utility } from '../pin/pin.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** Columns to draw: hidden ones dropped, pinned ones first. */
|
|
5
|
+
columns: Column[];
|
|
6
|
+
query: Query;
|
|
7
|
+
filterable: boolean;
|
|
8
|
+
/** Utility cells before the columns, in order. */
|
|
9
|
+
utilities: Utility[];
|
|
10
|
+
/** Pinned cells, utilities included, get `data-pinned` (C-47). */
|
|
11
|
+
hasPinned: boolean;
|
|
12
|
+
/** `--qt-pin-left` of each pinned cell, by key. */
|
|
13
|
+
offsets: Readonly<Record<string, number>>;
|
|
14
|
+
/**
|
|
15
|
+
* The header slots the consumer gave (`header-<field>`, `filter-datetime`,
|
|
16
|
+
* `filter-menu`), space-separated. The slots below are always passed so
|
|
17
|
+
* that they stay stable; this says which ones to draw.
|
|
18
|
+
*/
|
|
19
|
+
slotNames: string;
|
|
20
|
+
};
|
|
21
|
+
type __VLS_Slots = {
|
|
22
|
+
'filter-datetime'?(props: FilterDatetimeSlotProps): unknown;
|
|
23
|
+
'filter-menu'?(props: FilterMenuSlotProps): unknown;
|
|
24
|
+
/** Draws the consumer's `header-<field>` slot for `column`. */
|
|
25
|
+
header?(props: HeaderSlotProps): unknown;
|
|
26
|
+
};
|
|
27
|
+
declare const __VLS_base: 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>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
32
|
+
new (): {
|
|
33
|
+
$slots: S;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PaginationSlotProps } from '../contract.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
paginationProps: PaginationSlotProps;
|
|
4
|
+
};
|
|
5
|
+
type __VLS_Slots = {
|
|
6
|
+
pagination(props: PaginationSlotProps): unknown;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: 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>;
|
|
9
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cells before the first column, in drawing order: the right panel, the
|
|
3
|
+
* expand button, the selection checkbox.
|
|
4
|
+
*/
|
|
5
|
+
export type Utility = 'right-panel' | 'subtable' | 'select';
|
|
6
|
+
/** Geometry key of a utility cell; a column's key is its `field`. */
|
|
7
|
+
export declare const utilityKey: (utility: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Attributes of a pinned cell (C-47): `data-pinned` and, once measured, the
|
|
10
|
+
* `--qt-pin-left` offset in pixels, next to an optional `width`. Nothing but
|
|
11
|
+
* the width for a cell that is not pinned; no `style` when both are absent.
|
|
12
|
+
*/
|
|
13
|
+
export declare const pinAttrs: (pinned: boolean, offset: number | undefined, width?: string) => Record<string, unknown>;
|