@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
package/dist/query-table.js
CHANGED
|
@@ -1,7 +1,84 @@
|
|
|
1
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, getCurrentInstance, guardReactiveProps, h, inject, mergeProps, nextTick, normalizeProps, onBeforeUnmount, onScopeDispose, openBlock, provide, renderList, renderSlot, shallowRef, toDisplayString, toHandlers, toValue, unref, useSlots, watch, withCtx, withKeys, withModifiers } from "vue";
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineComponent, getCurrentInstance, guardReactiveProps, h, inject, mergeProps, nextTick, normalizeProps, normalizeStyle, onBeforeUnmount, onScopeDispose, openBlock, provide, renderList, renderSlot, shallowRef, toDisplayString, toHandlers, toValue, unref, useSlots, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
|
|
2
2
|
import { columnTypeOf, columnTypeOf as columnTypeOf$1, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, searchOf } from "@dolusoft/query-protocol";
|
|
3
3
|
import { dispose, filterInputFeature, projectServerQuery, serverQueryFeature } from "@dolusoft/query-table-core";
|
|
4
|
-
import { columnFilteringFeature, columnPinningFeature, functionalUpdate, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, useTable } from "@tanstack/vue-table";
|
|
4
|
+
import { columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, functionalUpdate, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, useTable } from "@tanstack/vue-table";
|
|
5
|
+
//#region src/columns/column-layout.ts
|
|
6
|
+
var sideOf = (column) => column.pinned === "left" ? "left" : column.pinned === "right" ? "right" : false;
|
|
7
|
+
/** A copy of `column` without `key`: a default is removed, never set (C-68). */
|
|
8
|
+
var without = (column, key) => {
|
|
9
|
+
const copy = { ...column };
|
|
10
|
+
delete copy[key];
|
|
11
|
+
return copy;
|
|
12
|
+
};
|
|
13
|
+
/** The columns with the visibility of `visibility`; `null` when nothing changes. */
|
|
14
|
+
var applyVisibility = (columns, visibility) => {
|
|
15
|
+
let changed = false;
|
|
16
|
+
const next = columns.map((column) => {
|
|
17
|
+
const visible = visibility[column.field] ?? true;
|
|
18
|
+
if (visible === !column.hide) return column;
|
|
19
|
+
changed = true;
|
|
20
|
+
return visible ? without(column, "hide") : {
|
|
21
|
+
...column,
|
|
22
|
+
hide: true
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
return changed ? next : null;
|
|
26
|
+
};
|
|
27
|
+
/** The columns in `order` (unknown fields skipped, missing ones kept last); `null` when unchanged. */
|
|
28
|
+
var applyOrder = (columns, order) => {
|
|
29
|
+
const byField = new Map(columns.map((column) => [column.field, column]));
|
|
30
|
+
const placed = /* @__PURE__ */ new Set();
|
|
31
|
+
const next = [];
|
|
32
|
+
for (const field of order) {
|
|
33
|
+
const column = byField.get(field);
|
|
34
|
+
if (column && !placed.has(field)) {
|
|
35
|
+
placed.add(field);
|
|
36
|
+
next.push(column);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
next.push(...columns.filter((column) => !placed.has(column.field)));
|
|
40
|
+
return next.every((column, index) => column === columns[index]) ? null : next;
|
|
41
|
+
};
|
|
42
|
+
/** The columns with the sides of `pinning` (start = left, end = right); `null` when unchanged. */
|
|
43
|
+
var applyPinning = (columns, pinning) => {
|
|
44
|
+
const left = new Set(pinning.start ?? []);
|
|
45
|
+
const right = new Set(pinning.end ?? []);
|
|
46
|
+
let changed = false;
|
|
47
|
+
const next = columns.map((column) => {
|
|
48
|
+
const side = left.has(column.field) ? "left" : right.has(column.field) ? "right" : false;
|
|
49
|
+
if (side === sideOf(column)) return column;
|
|
50
|
+
changed = true;
|
|
51
|
+
return side ? {
|
|
52
|
+
...column,
|
|
53
|
+
pinned: side
|
|
54
|
+
} : without(column, "pinned");
|
|
55
|
+
});
|
|
56
|
+
return changed ? next : null;
|
|
57
|
+
};
|
|
58
|
+
/** The columns with `field` at `width`; `null` when it already has it. */
|
|
59
|
+
var applyWidth = (columns, field, width) => {
|
|
60
|
+
const at = columns.findIndex((column) => column.field === field);
|
|
61
|
+
if (at < 0 || columns[at].width === width) return null;
|
|
62
|
+
const next = [...columns];
|
|
63
|
+
next[at] = {
|
|
64
|
+
...columns[at],
|
|
65
|
+
width
|
|
66
|
+
};
|
|
67
|
+
return next;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* `field` taken out and put right before or after `target` (C-69): the
|
|
71
|
+
* columns between keep their place, hidden ones included.
|
|
72
|
+
*/
|
|
73
|
+
var moveField = (fields, field, target, place) => {
|
|
74
|
+
if (field === target || !fields.includes(field)) return fields;
|
|
75
|
+
const rest = fields.filter((name) => name !== field);
|
|
76
|
+
const at = rest.indexOf(target);
|
|
77
|
+
if (at < 0) return fields;
|
|
78
|
+
rest.splice(place === "before" ? at : at + 1, 0, field);
|
|
79
|
+
return rest;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
5
82
|
//#region src/core/labels.ts
|
|
6
83
|
/** English defaults of the `labels` prop (C-44). */
|
|
7
84
|
var defaultLabels = {
|
|
@@ -11,6 +88,8 @@ var defaultLabels = {
|
|
|
11
88
|
filterInput: (column) => `Filter ${column}`,
|
|
12
89
|
filterOptions: (column) => `Filter options for ${column}`,
|
|
13
90
|
resizeColumn: (column) => `Resize ${column}`,
|
|
91
|
+
moveColumn: (column) => `Move ${column}`,
|
|
92
|
+
filterCondition: (condition, type) => conditionLabel(type, condition),
|
|
14
93
|
boolAll: "All",
|
|
15
94
|
boolTrue: "True",
|
|
16
95
|
boolFalse: "False",
|
|
@@ -53,6 +132,18 @@ var focusFilterOf = (table, field) => {
|
|
|
53
132
|
}
|
|
54
133
|
return false;
|
|
55
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Focuses the first filter of this table's header that takes the focus, in
|
|
137
|
+
* column order (C-22). Returns whether one did.
|
|
138
|
+
*/
|
|
139
|
+
var focusFirstFilter = (table) => {
|
|
140
|
+
const head = [...table?.children ?? []].find((child) => child.tagName === "THEAD");
|
|
141
|
+
for (const row of head?.children ?? []) for (const cell of row.children) {
|
|
142
|
+
const field = cell.getAttribute("data-field");
|
|
143
|
+
if (field !== null && focusFilterOf(table, field)) return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
};
|
|
56
147
|
//#endregion
|
|
57
148
|
//#region src/core/column.ts
|
|
58
149
|
/** Reads a dotted path (`'a.b'`) from a row. */
|
|
@@ -62,17 +153,18 @@ var valueAt = (row, path) => path.split(".").reduce((value, key) => value === nu
|
|
|
62
153
|
/** Geometry key of a utility cell; a column's key is its `field`. */
|
|
63
154
|
var utilityKey = (utility) => `utility:${utility}`;
|
|
64
155
|
/**
|
|
65
|
-
* Attributes of a pinned cell (C-47): `data-pinned`
|
|
66
|
-
*
|
|
156
|
+
* Attributes of a pinned cell (C-47, C-71): `data-pinned` (`''` on the left,
|
|
157
|
+
* `'right'` on the right) and, once measured, the `--qt-pin-left` or
|
|
158
|
+
* `--qt-pin-right` offset in pixels, next to an optional `width`. Nothing but
|
|
67
159
|
* the width for a cell that is not pinned; no `style` when both are absent.
|
|
68
160
|
*/
|
|
69
|
-
var pinAttrs = (
|
|
161
|
+
var pinAttrs = (side, offset, width) => {
|
|
70
162
|
const style = {};
|
|
71
163
|
if (width) style.width = width;
|
|
72
|
-
if (
|
|
164
|
+
if (side && offset !== void 0) style[side === "left" ? "--qt-pin-left" : "--qt-pin-right"] = `${offset}px`;
|
|
73
165
|
return {
|
|
74
|
-
"data-pinned":
|
|
75
|
-
style:
|
|
166
|
+
"data-pinned": side === "left" ? "" : side === "right" ? "right" : void 0,
|
|
167
|
+
style: Object.keys(style).length > 0 ? style : void 0
|
|
76
168
|
};
|
|
77
169
|
};
|
|
78
170
|
//#endregion
|
|
@@ -84,9 +176,11 @@ var pinAttrs = (pinned, offset, width) => {
|
|
|
84
176
|
var useCellView = (options) => {
|
|
85
177
|
/** Text of a cell, whole: the table never cuts it. */
|
|
86
178
|
const cellText = (row, column) => String(valueAt(row, column.field) ?? "");
|
|
179
|
+
const types = computed(() => new Map(options.entries().map((entry) => [entry.column.field, columnTypeOf$1(entry.column)])));
|
|
87
180
|
const cellAttrs = (entry) => ({
|
|
88
181
|
"data-field": entry.column.field,
|
|
89
|
-
|
|
182
|
+
"data-type": types.value.get(entry.column.field),
|
|
183
|
+
...pinAttrs(sideOf(entry.column), options.offsets()[entry.column.field])
|
|
90
184
|
});
|
|
91
185
|
/**
|
|
92
186
|
* One listener on the `tbody` serves every cell (C-28): a listener per cell
|
|
@@ -122,11 +216,13 @@ var useCellView = (options) => {
|
|
|
122
216
|
});
|
|
123
217
|
};
|
|
124
218
|
const hasCellSlot = (column) => !!options.slots[`cell-${column.field}`];
|
|
125
|
-
const slotProps = (row, column, rowIndex) => ({
|
|
219
|
+
const slotProps = (row, column, rowIndex, rowPinned) => ({
|
|
126
220
|
row,
|
|
127
221
|
rowIndex,
|
|
128
222
|
column,
|
|
129
|
-
cellValue: valueAt(row, column.field)
|
|
223
|
+
cellValue: valueAt(row, column.field),
|
|
224
|
+
rowPinned,
|
|
225
|
+
pinRow: (position) => options.pinRow(row, rowIndex, position)
|
|
130
226
|
});
|
|
131
227
|
return {
|
|
132
228
|
cellText,
|
|
@@ -138,18 +234,21 @@ var useCellView = (options) => {
|
|
|
138
234
|
};
|
|
139
235
|
//#endregion
|
|
140
236
|
//#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
|
|
141
|
-
var _hoisted_1$
|
|
237
|
+
var _hoisted_1$9 = ["colspan"];
|
|
238
|
+
var _hoisted_2$5 = [
|
|
142
239
|
"data-row-index",
|
|
240
|
+
"aria-rowindex",
|
|
241
|
+
"data-pinned-row",
|
|
143
242
|
"data-expanded",
|
|
144
243
|
"data-selected"
|
|
145
244
|
];
|
|
146
|
-
var
|
|
147
|
-
var
|
|
245
|
+
var _hoisted_3$5 = ["aria-label", "onClick"];
|
|
246
|
+
var _hoisted_4$4 = [
|
|
148
247
|
"aria-expanded",
|
|
149
248
|
"aria-label",
|
|
150
249
|
"onClick"
|
|
151
250
|
];
|
|
152
|
-
var
|
|
251
|
+
var _hoisted_5$1 = {
|
|
153
252
|
width: "14",
|
|
154
253
|
height: "14",
|
|
155
254
|
viewBox: "0 0 24 24",
|
|
@@ -160,40 +259,44 @@ var _hoisted_4$3 = {
|
|
|
160
259
|
"stroke-linejoin": "round",
|
|
161
260
|
"aria-hidden": "true"
|
|
162
261
|
};
|
|
163
|
-
var
|
|
262
|
+
var _hoisted_6$1 = {
|
|
164
263
|
key: 0,
|
|
165
264
|
points: "6 9 12 15 18 9"
|
|
166
265
|
};
|
|
167
|
-
var
|
|
266
|
+
var _hoisted_7$1 = {
|
|
168
267
|
key: 1,
|
|
169
268
|
points: "9 6 15 12 9 18"
|
|
170
269
|
};
|
|
171
|
-
var
|
|
270
|
+
var _hoisted_8$1 = [
|
|
172
271
|
"aria-label",
|
|
173
272
|
"checked",
|
|
174
273
|
"onChange"
|
|
175
274
|
];
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
180
|
-
var _hoisted_9$1 = ["colspan"];
|
|
181
|
-
var _hoisted_10 = {
|
|
275
|
+
var _hoisted_9$1 = ["aria-rowindex", "data-pinned-row"];
|
|
276
|
+
var _hoisted_10 = ["colspan"];
|
|
277
|
+
var _hoisted_11 = {
|
|
182
278
|
key: 0,
|
|
183
279
|
class: "qt-loading-row"
|
|
184
280
|
};
|
|
185
|
-
var
|
|
186
|
-
var
|
|
281
|
+
var _hoisted_12 = ["colspan"];
|
|
282
|
+
var _hoisted_13 = {
|
|
187
283
|
key: 1,
|
|
188
284
|
class: "qt-empty-row"
|
|
189
285
|
};
|
|
190
|
-
var
|
|
286
|
+
var _hoisted_14 = ["colspan"];
|
|
287
|
+
var _hoisted_15 = {
|
|
288
|
+
key: 2,
|
|
289
|
+
class: "qt-load-more-row"
|
|
290
|
+
};
|
|
291
|
+
var _hoisted_16 = ["colspan"];
|
|
191
292
|
//#endregion
|
|
192
293
|
//#region src/parts/table-body.vue
|
|
193
294
|
var table_body_default = /* @__PURE__ */ defineComponent({
|
|
194
295
|
__name: "table-body",
|
|
195
296
|
props: {
|
|
196
297
|
rows: {},
|
|
298
|
+
bodyRows: {},
|
|
299
|
+
pinRow: { type: Function },
|
|
197
300
|
loading: { type: Boolean },
|
|
198
301
|
entries: {},
|
|
199
302
|
columnCount: {},
|
|
@@ -208,7 +311,8 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
208
311
|
isExpanded: { type: Function },
|
|
209
312
|
toggle: { type: Function },
|
|
210
313
|
labels: {},
|
|
211
|
-
hasContextMenuListener: { type: Function }
|
|
314
|
+
hasContextMenuListener: { type: Function },
|
|
315
|
+
loadMore: {}
|
|
212
316
|
},
|
|
213
317
|
emits: ["rowRightPanelClick", "cellContextMenu"],
|
|
214
318
|
setup(__props, { emit: __emit }) {
|
|
@@ -221,88 +325,110 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
221
325
|
entries: () => props.entries,
|
|
222
326
|
offsets: () => props.offsets,
|
|
223
327
|
listening: () => props.hasContextMenuListener(),
|
|
224
|
-
onContextMenu: (payload) => emit("cellContextMenu", payload)
|
|
328
|
+
onContextMenu: (payload) => emit("cellContextMenu", payload),
|
|
329
|
+
pinRow: (row, index, position) => props.pinRow(row, index, position)
|
|
225
330
|
});
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const
|
|
331
|
+
const utilityAttrs = (utility) => pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)]);
|
|
332
|
+
const rightPanelAttrs = () => utilityAttrs("right-panel");
|
|
333
|
+
const expandAttrs = () => utilityAttrs("subtable");
|
|
334
|
+
const selectAttrs = () => utilityAttrs("select");
|
|
335
|
+
const isSpacer = (item) => "spacer" in item;
|
|
336
|
+
/** `aria-rowindex` of the subtable row under a drawn row (C-86). */
|
|
337
|
+
const nextIndex = (aria) => aria === void 0 ? void 0 : aria + 1;
|
|
229
338
|
return (_ctx, _cache) => {
|
|
230
|
-
return openBlock(), createElementBlock("tbody", { onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args)) }, [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
"data-expanded": __props.isExpanded(row, i) ? "" : void 0,
|
|
234
|
-
"data-selected": __props.hasSelection && __props.isSelected(row, i) ? "" : void 0
|
|
235
|
-
}, [
|
|
236
|
-
__props.hasRightPanel ? (openBlock(), createElementBlock("td", mergeProps({
|
|
339
|
+
return openBlock(), createElementBlock("tbody", { onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args)) }, [
|
|
340
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.bodyRows, (item) => {
|
|
341
|
+
return openBlock(), createElementBlock(Fragment, { key: isSpacer(item) ? item.key : __props.keyOf(item.row, item.index) }, [isSpacer(item) ? (openBlock(), createElementBlock("tr", {
|
|
237
342
|
key: 0,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
"
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
stroke: "currentColor",
|
|
250
|
-
"stroke-width": "2",
|
|
251
|
-
"stroke-linecap": "round",
|
|
252
|
-
"aria-hidden": "true"
|
|
253
|
-
}, [createElementVNode("line", {
|
|
254
|
-
x1: "12",
|
|
255
|
-
y1: "5",
|
|
256
|
-
x2: "12",
|
|
257
|
-
y2: "19"
|
|
258
|
-
}), createElementVNode("line", {
|
|
259
|
-
x1: "5",
|
|
260
|
-
y1: "12",
|
|
261
|
-
x2: "19",
|
|
262
|
-
y2: "12"
|
|
263
|
-
})], -1)])], 8, _hoisted_2$5)], 16)) : createCommentVNode("", true),
|
|
264
|
-
__props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
|
|
265
|
-
key: 1,
|
|
266
|
-
ref_for: true
|
|
267
|
-
}, expandAttrs()), [createElementVNode("button", {
|
|
268
|
-
type: "button",
|
|
269
|
-
class: "qt-expand",
|
|
270
|
-
"aria-expanded": __props.isExpanded(row, i),
|
|
271
|
-
"aria-label": __props.labels.expandRow,
|
|
272
|
-
onClick: ($event) => __props.toggle(row, i)
|
|
273
|
-
}, [(openBlock(), createElementBlock("svg", _hoisted_4$3, [__props.isExpanded(row, i) ? (openBlock(), createElementBlock("polyline", _hoisted_5$1)) : (openBlock(), createElementBlock("polyline", _hoisted_6$1))]))], 8, _hoisted_3$4)], 16)) : createCommentVNode("", true),
|
|
274
|
-
__props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
|
|
275
|
-
key: 2,
|
|
276
|
-
ref_for: true
|
|
277
|
-
}, selectAttrs()), [createElementVNode("input", {
|
|
278
|
-
type: "checkbox",
|
|
279
|
-
class: "qt-select-row",
|
|
280
|
-
"aria-label": __props.labels.selectRow,
|
|
281
|
-
checked: __props.isSelected(row, i),
|
|
282
|
-
onChange: ($event) => __props.toggleSelected(row, i)
|
|
283
|
-
}, null, 40, _hoisted_7$1)], 16)) : createCommentVNode("", true),
|
|
284
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
|
|
285
|
-
return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
|
|
343
|
+
class: "qt-virtual-spacer",
|
|
344
|
+
"aria-hidden": "true",
|
|
345
|
+
style: normalizeStyle({ height: `${item.spacer}px` })
|
|
346
|
+
}, [createElementVNode("td", { colspan: __props.columnCount }, null, 8, _hoisted_1$9)], 4)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("tr", {
|
|
347
|
+
"data-row-index": item.index,
|
|
348
|
+
"aria-rowindex": item.aria,
|
|
349
|
+
"data-pinned-row": item.pinned || void 0,
|
|
350
|
+
"data-expanded": __props.isExpanded(item.row, item.index) ? "" : void 0,
|
|
351
|
+
"data-selected": __props.hasSelection && __props.isSelected(item.row, item.index) ? "" : void 0
|
|
352
|
+
}, [
|
|
353
|
+
__props.hasRightPanel ? (openBlock(), createElementBlock("td", mergeProps({
|
|
286
354
|
key: 0,
|
|
287
355
|
ref_for: true
|
|
288
|
-
},
|
|
356
|
+
}, rightPanelAttrs()), [createElementVNode("button", {
|
|
357
|
+
type: "button",
|
|
358
|
+
class: "qt-right-panel-button",
|
|
359
|
+
"aria-label": __props.labels.openRightPanel,
|
|
360
|
+
onClick: withModifiers(($event) => emit("rowRightPanelClick", item.row), ["stop"])
|
|
361
|
+
}, [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
|
|
362
|
+
width: "14",
|
|
363
|
+
height: "14",
|
|
364
|
+
viewBox: "0 0 24 24",
|
|
365
|
+
fill: "none",
|
|
366
|
+
stroke: "currentColor",
|
|
367
|
+
"stroke-width": "2",
|
|
368
|
+
"stroke-linecap": "round",
|
|
369
|
+
"aria-hidden": "true"
|
|
370
|
+
}, [createElementVNode("line", {
|
|
371
|
+
x1: "12",
|
|
372
|
+
y1: "5",
|
|
373
|
+
x2: "12",
|
|
374
|
+
y2: "19"
|
|
375
|
+
}), createElementVNode("line", {
|
|
376
|
+
x1: "5",
|
|
377
|
+
y1: "12",
|
|
378
|
+
x2: "19",
|
|
379
|
+
y2: "12"
|
|
380
|
+
})], -1)])], 8, _hoisted_3$5)], 16)) : createCommentVNode("", true),
|
|
381
|
+
__props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
|
|
289
382
|
key: 1,
|
|
290
383
|
ref_for: true
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
384
|
+
}, expandAttrs()), [createElementVNode("button", {
|
|
385
|
+
type: "button",
|
|
386
|
+
class: "qt-expand",
|
|
387
|
+
"aria-expanded": __props.isExpanded(item.row, item.index),
|
|
388
|
+
"aria-label": __props.labels.expandRow,
|
|
389
|
+
onClick: ($event) => __props.toggle(item.row, item.index)
|
|
390
|
+
}, [(openBlock(), createElementBlock("svg", _hoisted_5$1, [__props.isExpanded(item.row, item.index) ? (openBlock(), createElementBlock("polyline", _hoisted_6$1)) : (openBlock(), createElementBlock("polyline", _hoisted_7$1))]))], 8, _hoisted_4$4)], 16)) : createCommentVNode("", true),
|
|
391
|
+
__props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
|
|
392
|
+
key: 2,
|
|
393
|
+
ref_for: true
|
|
394
|
+
}, selectAttrs()), [createElementVNode("input", {
|
|
395
|
+
type: "checkbox",
|
|
396
|
+
class: "qt-select-row",
|
|
397
|
+
"aria-label": __props.labels.selectRow,
|
|
398
|
+
checked: __props.isSelected(item.row, item.index),
|
|
399
|
+
onChange: ($event) => __props.toggleSelected(item.row, item.index)
|
|
400
|
+
}, null, 40, _hoisted_8$1)], 16)) : createCommentVNode("", true),
|
|
401
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
|
|
402
|
+
return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
|
|
403
|
+
key: 0,
|
|
404
|
+
ref_for: true
|
|
405
|
+
}, unref(cellAttrs)(entry)), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(item.row, entry.column, item.index, item.pinned)))], 16)) : (openBlock(), createElementBlock("td", mergeProps({
|
|
406
|
+
key: 1,
|
|
407
|
+
ref_for: true
|
|
408
|
+
}, unref(cellAttrs)(entry)), toDisplayString(unref(cellText)(item.row, entry.column)), 17))], 64);
|
|
409
|
+
}), 128))
|
|
410
|
+
], 8, _hoisted_2$5), __props.isExpanded(item.row, item.index) ? (openBlock(), createElementBlock("tr", {
|
|
411
|
+
key: 0,
|
|
412
|
+
class: "qt-subtable-row",
|
|
413
|
+
"aria-rowindex": nextIndex(item.aria),
|
|
414
|
+
"data-pinned-row": item.pinned || void 0
|
|
415
|
+
}, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "subtable", {
|
|
416
|
+
row: item.row,
|
|
417
|
+
rowIndex: item.index
|
|
418
|
+
})], 8, _hoisted_10)], 8, _hoisted_9$1)) : createCommentVNode("", true)], 64))], 64);
|
|
419
|
+
}), 128)),
|
|
420
|
+
__props.loading && slots.loading ? (openBlock(), createElementBlock("tr", _hoisted_11, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "loading")], 8, _hoisted_12)])) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", _hoisted_13, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "empty")], 8, _hoisted_14)])) : createCommentVNode("", true),
|
|
421
|
+
!__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", _hoisted_15, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 8, _hoisted_16)])) : createCommentVNode("", true)
|
|
422
|
+
], 32);
|
|
298
423
|
};
|
|
299
424
|
}
|
|
300
425
|
});
|
|
301
426
|
//#endregion
|
|
302
427
|
//#region src/parts/table-footer.vue?vue&type=script&setup=true&lang.ts
|
|
303
|
-
var _hoisted_1$
|
|
304
|
-
var _hoisted_2$4 = ["
|
|
305
|
-
var _hoisted_3$
|
|
428
|
+
var _hoisted_1$8 = { class: "qt-footer" };
|
|
429
|
+
var _hoisted_2$4 = ["aria-rowindex"];
|
|
430
|
+
var _hoisted_3$4 = ["colspan"];
|
|
431
|
+
var _hoisted_4$3 = ["data-field", "data-type"];
|
|
306
432
|
//#endregion
|
|
307
433
|
//#region src/parts/table-footer.vue
|
|
308
434
|
var table_footer_default = /* @__PURE__ */ defineComponent({
|
|
@@ -312,28 +438,33 @@ var table_footer_default = /* @__PURE__ */ defineComponent({
|
|
|
312
438
|
entries: {},
|
|
313
439
|
utilityCount: {},
|
|
314
440
|
hasPinned: { type: Boolean },
|
|
315
|
-
offsets: {}
|
|
441
|
+
offsets: {},
|
|
442
|
+
firstRowIndex: {}
|
|
316
443
|
},
|
|
317
444
|
setup(__props) {
|
|
318
445
|
const footerText = (row, column) => row.cells.find((cell) => cell.field === column.field)?.text;
|
|
319
446
|
return (_ctx, _cache) => {
|
|
320
|
-
return openBlock(), createElementBlock("tfoot", _hoisted_1$
|
|
321
|
-
return openBlock(), createElementBlock("tr", {
|
|
447
|
+
return openBlock(), createElementBlock("tfoot", _hoisted_1$8, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.footerRows, (footerRow, i) => {
|
|
448
|
+
return openBlock(), createElementBlock("tr", {
|
|
449
|
+
key: i,
|
|
450
|
+
"aria-rowindex": __props.firstRowIndex === void 0 ? void 0 : __props.firstRowIndex + i
|
|
451
|
+
}, [__props.utilityCount > 0 ? (openBlock(), createElementBlock("td", mergeProps({
|
|
322
452
|
key: 0,
|
|
323
453
|
colspan: __props.utilityCount
|
|
324
|
-
}, { ref_for: true }, unref(pinAttrs)(__props.hasPinned, 0)), null, 16,
|
|
454
|
+
}, { ref_for: true }, unref(pinAttrs)(__props.hasPinned ? "left" : false, 0)), null, 16, _hoisted_3$4)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
|
|
325
455
|
return openBlock(), createElementBlock("td", mergeProps({
|
|
326
456
|
key: entry.column.field,
|
|
327
|
-
"data-field": entry.column.field
|
|
328
|
-
|
|
329
|
-
|
|
457
|
+
"data-field": entry.column.field,
|
|
458
|
+
"data-type": unref(columnTypeOf$1)(entry.column)
|
|
459
|
+
}, { ref_for: true }, unref(pinAttrs)(unref(sideOf)(entry.column), __props.offsets[entry.column.field])), toDisplayString(footerText(footerRow, entry.column)), 17, _hoisted_4$3);
|
|
460
|
+
}), 128))], 8, _hoisted_2$4);
|
|
330
461
|
}), 128))]);
|
|
331
462
|
};
|
|
332
463
|
}
|
|
333
464
|
});
|
|
334
465
|
//#endregion
|
|
335
466
|
//#region src/parts/filter-icon.vue?vue&type=script&setup=true&lang.ts
|
|
336
|
-
var _hoisted_1$
|
|
467
|
+
var _hoisted_1$7 = ["fill"];
|
|
337
468
|
//#endregion
|
|
338
469
|
//#region src/parts/filter-icon.vue
|
|
339
470
|
var filter_icon_default = /* @__PURE__ */ defineComponent({
|
|
@@ -351,7 +482,7 @@ var filter_icon_default = /* @__PURE__ */ defineComponent({
|
|
|
351
482
|
"stroke-linecap": "round",
|
|
352
483
|
"stroke-linejoin": "round",
|
|
353
484
|
"aria-hidden": "true"
|
|
354
|
-
}, [..._cache[0] || (_cache[0] = [createElementVNode("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" }, null, -1)])], 8, _hoisted_1$
|
|
485
|
+
}, [..._cache[0] || (_cache[0] = [createElementVNode("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" }, null, -1)])], 8, _hoisted_1$7);
|
|
355
486
|
};
|
|
356
487
|
}
|
|
357
488
|
});
|
|
@@ -380,9 +511,9 @@ var useFilterTrigger = (options) => defineComponent({
|
|
|
380
511
|
});
|
|
381
512
|
//#endregion
|
|
382
513
|
//#region src/parts/filter-cell.vue?vue&type=script&setup=true&lang.ts
|
|
383
|
-
var _hoisted_1$
|
|
514
|
+
var _hoisted_1$6 = { class: "qt-filter" };
|
|
384
515
|
var _hoisted_2$3 = ["aria-label", "value"];
|
|
385
|
-
var _hoisted_3$
|
|
516
|
+
var _hoisted_3$3 = [
|
|
386
517
|
"type",
|
|
387
518
|
"aria-label",
|
|
388
519
|
"value",
|
|
@@ -417,7 +548,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
417
548
|
},
|
|
418
549
|
setup(__props) {
|
|
419
550
|
const props = __props;
|
|
420
|
-
const { filters, sort, labels } = useTableContext();
|
|
551
|
+
const { filters, sort, layout, labels } = useTableContext();
|
|
421
552
|
const inputName = () => labels().filterInput(columnName(props.column));
|
|
422
553
|
const isFiltered = () => rulesOf(props.query.filters, props.column.field).length > 0;
|
|
423
554
|
const trigger = useFilterTrigger({
|
|
@@ -428,7 +559,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
428
559
|
const labelOf = () => {
|
|
429
560
|
const label = filters.labelOf(props.column.field);
|
|
430
561
|
if (!label) return "";
|
|
431
|
-
const text =
|
|
562
|
+
const text = labels().filterCondition(label.condition, props.type);
|
|
432
563
|
return label.count > 1 ? `${text} (${label.count})` : text;
|
|
433
564
|
};
|
|
434
565
|
const inputText = () => {
|
|
@@ -442,13 +573,17 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
442
573
|
column,
|
|
443
574
|
rules: rulesOf(props.query.filters, column.field),
|
|
444
575
|
condition: currentCondition(),
|
|
445
|
-
conditions: conditionOptions[props.type]
|
|
576
|
+
conditions: conditionOptions[props.type].map(({ value }) => ({
|
|
577
|
+
value,
|
|
578
|
+
label: labels().filterCondition(value, props.type)
|
|
579
|
+
})),
|
|
446
580
|
setCondition: (condition) => filters.setCondition(column.field, condition),
|
|
447
581
|
clear: () => filters.clear(column.field),
|
|
448
582
|
sortable: sort.isSortable(column),
|
|
449
583
|
sortDirection: sort.sortOf(column),
|
|
450
584
|
setSort: (direction) => sort.sortBy(column, direction),
|
|
451
|
-
trigger
|
|
585
|
+
trigger,
|
|
586
|
+
control: layout.controlOf(column.field)
|
|
452
587
|
};
|
|
453
588
|
};
|
|
454
589
|
const datetimeProps = () => ({
|
|
@@ -462,7 +597,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
462
597
|
filters.apply(props.column.field);
|
|
463
598
|
};
|
|
464
599
|
return (_ctx, _cache) => {
|
|
465
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
600
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
466
601
|
__props.type === "string" ? (openBlock(), createElementBlock("input", {
|
|
467
602
|
key: 0,
|
|
468
603
|
type: "text",
|
|
@@ -480,7 +615,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
480
615
|
readonly: unref(filters).multiOf(__props.column.field) > 0,
|
|
481
616
|
onInput: _cache[2] || (_cache[2] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
482
617
|
onKeydown: _cache[3] || (_cache[3] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
483
|
-
}, null, 40, _hoisted_3$
|
|
618
|
+
}, null, 40, _hoisted_3$3)) : __props.type === "bool" ? (openBlock(), createElementBlock("select", {
|
|
484
619
|
key: 2,
|
|
485
620
|
class: "qt-filter-input",
|
|
486
621
|
"aria-label": inputName(),
|
|
@@ -508,6 +643,28 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
508
643
|
}
|
|
509
644
|
});
|
|
510
645
|
//#endregion
|
|
646
|
+
//#region src/parts/reorder-handle.vue?vue&type=script&setup=true&lang.ts
|
|
647
|
+
var _hoisted_1$5 = ["aria-label"];
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/parts/reorder-handle.vue
|
|
650
|
+
var reorder_handle_default = /* @__PURE__ */ defineComponent({
|
|
651
|
+
__name: "reorder-handle",
|
|
652
|
+
props: { column: {} },
|
|
653
|
+
setup(__props) {
|
|
654
|
+
const props = __props;
|
|
655
|
+
const { reorder, labels } = useTableContext();
|
|
656
|
+
const on = reorder.listeners(() => props.column);
|
|
657
|
+
return (_ctx, _cache) => {
|
|
658
|
+
return openBlock(), createElementBlock("button", mergeProps({
|
|
659
|
+
type: "button",
|
|
660
|
+
class: "qt-reorder-handle",
|
|
661
|
+
"aria-label": unref(labels)().moveColumn(unref(columnName)(__props.column)),
|
|
662
|
+
"aria-keyshortcuts": "ArrowLeft ArrowRight Home End"
|
|
663
|
+
}, toHandlers(unref(on), true)), [..._cache[0] || (_cache[0] = [createStaticVNode("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"6\" r=\"1.5\"></circle><circle cx=\"15\" cy=\"6\" r=\"1.5\"></circle><circle cx=\"9\" cy=\"12\" r=\"1.5\"></circle><circle cx=\"15\" cy=\"12\" r=\"1.5\"></circle><circle cx=\"9\" cy=\"18\" r=\"1.5\"></circle><circle cx=\"15\" cy=\"18\" r=\"1.5\"></circle></svg>", 1)])], 16, _hoisted_1$5);
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
//#endregion
|
|
511
668
|
//#region src/resize/use-column-resize.ts
|
|
512
669
|
/** Default `Column.minWidth`, in pixels. */
|
|
513
670
|
var defaultMinWidth = 40;
|
|
@@ -553,6 +710,13 @@ var autofitWidth = (th, field) => {
|
|
|
553
710
|
};
|
|
554
711
|
var cellOf = (event) => event.currentTarget.closest("th");
|
|
555
712
|
/**
|
|
713
|
+
* Which edge of the column the handle stands for: `1` for the right edge,
|
|
714
|
+
* `-1` for the left one. A right-pinned column stays at the right edge of the
|
|
715
|
+
* scroll container, so it grows to the left: its handle stands for its left
|
|
716
|
+
* edge, and moving that edge to the left widens it (C-71).
|
|
717
|
+
*/
|
|
718
|
+
var edgeOf = (column) => column.pinned === "right" ? -1 : 1;
|
|
719
|
+
/**
|
|
556
720
|
* Resizing a column (C-48 to C-50). The table holds a width only while a
|
|
557
721
|
* drag is under way (the preview, P2); every committed width goes out as a
|
|
558
722
|
* `columnResize` event and comes back, if the consumer wants it, as
|
|
@@ -572,7 +736,7 @@ var useColumnResize = (options) => {
|
|
|
572
736
|
width: next
|
|
573
737
|
});
|
|
574
738
|
};
|
|
575
|
-
const dragged = (current) => current.startWidth + current.lastX - current.startX;
|
|
739
|
+
const dragged = (current) => current.startWidth + edgeOf(current.column) * (current.lastX - current.startX);
|
|
576
740
|
const end = (apply) => {
|
|
577
741
|
const current = drag;
|
|
578
742
|
if (current) {
|
|
@@ -625,7 +789,7 @@ var useColumnResize = (options) => {
|
|
|
625
789
|
}
|
|
626
790
|
return;
|
|
627
791
|
}
|
|
628
|
-
const sign = key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0;
|
|
792
|
+
const sign = (key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0) * edgeOf(column);
|
|
629
793
|
const th = cellOf(event);
|
|
630
794
|
if (th && (sign || key === "Enter" || event.type === "dblclick")) {
|
|
631
795
|
event.preventDefault();
|
|
@@ -715,7 +879,7 @@ var _hoisted_2$2 = {
|
|
|
715
879
|
viewBox: "0 0 16 16",
|
|
716
880
|
"aria-hidden": "true"
|
|
717
881
|
};
|
|
718
|
-
var _hoisted_3$
|
|
882
|
+
var _hoisted_3$2 = {
|
|
719
883
|
key: 1,
|
|
720
884
|
class: "qt-sort-icon",
|
|
721
885
|
width: "14",
|
|
@@ -750,7 +914,7 @@ var sort_button_default = /* @__PURE__ */ defineComponent({
|
|
|
750
914
|
}, [createTextVNode(toDisplayString(__props.column.title) + " ", 1), __props.direction === "asc" ? (openBlock(), createElementBlock("svg", _hoisted_2$2, [..._cache[1] || (_cache[1] = [createElementVNode("path", {
|
|
751
915
|
d: "M8 3.5L12.5 9.5H3.5L8 3.5Z",
|
|
752
916
|
fill: "currentColor"
|
|
753
|
-
}, null, -1)])])) : __props.direction === "desc" ? (openBlock(), createElementBlock("svg", _hoisted_3$
|
|
917
|
+
}, null, -1)])])) : __props.direction === "desc" ? (openBlock(), createElementBlock("svg", _hoisted_3$2, [..._cache[2] || (_cache[2] = [createElementVNode("path", {
|
|
754
918
|
d: "M8 12.5L3.5 6.5H12.5L8 12.5Z",
|
|
755
919
|
fill: "currentColor"
|
|
756
920
|
}, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_4$1, [..._cache[3] || (_cache[3] = [createElementVNode("path", {
|
|
@@ -779,15 +943,16 @@ var _hoisted_2$1 = [
|
|
|
779
943
|
"aria-label",
|
|
780
944
|
"disabled"
|
|
781
945
|
];
|
|
782
|
-
var _hoisted_3 = [
|
|
946
|
+
var _hoisted_3$1 = [
|
|
783
947
|
"data-field",
|
|
948
|
+
"data-type",
|
|
784
949
|
"data-sort",
|
|
785
950
|
"data-sortable",
|
|
786
951
|
"data-filtered",
|
|
787
952
|
"aria-sort"
|
|
788
953
|
];
|
|
789
954
|
var _hoisted_4 = {
|
|
790
|
-
key:
|
|
955
|
+
key: 3,
|
|
791
956
|
class: "qt-title"
|
|
792
957
|
};
|
|
793
958
|
//#endregion
|
|
@@ -806,15 +971,32 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
806
971
|
setup(__props) {
|
|
807
972
|
const props = __props;
|
|
808
973
|
const given = (name) => props.slotNames.split(" ").includes(name);
|
|
809
|
-
const { filters, sort, resize, selection, labels } = useTableContext();
|
|
974
|
+
const { filters, sort, layout, resize, reorder, selection, labels } = useTableContext();
|
|
975
|
+
const dragAttrs = (column) => {
|
|
976
|
+
const drag = reorder.dragging.value;
|
|
977
|
+
return {
|
|
978
|
+
"data-dragging": drag?.field === column.field ? "" : void 0,
|
|
979
|
+
"data-drop": drag?.target === column.field ? drag.place : void 0
|
|
980
|
+
};
|
|
981
|
+
};
|
|
810
982
|
const canClearAll = computed(() => filters.canClearAll());
|
|
983
|
+
const onClearAll = async (event) => {
|
|
984
|
+
const button = event.currentTarget;
|
|
985
|
+
const doc = button.ownerDocument;
|
|
986
|
+
const keyed = event.detail === 0 && doc.activeElement === button;
|
|
987
|
+
filters.clearAll();
|
|
988
|
+
if (!keyed) return;
|
|
989
|
+
await nextTick();
|
|
990
|
+
const active = doc.activeElement;
|
|
991
|
+
if (button.disabled && (active === button || active === doc.body || active === null)) focusFirstFilter(button.closest("table"));
|
|
992
|
+
};
|
|
811
993
|
const isFiltered = (column) => rulesOf(props.query.filters, column.field).length > 0;
|
|
812
994
|
const hasFilter = (column) => props.filterable && column.filterable !== false;
|
|
813
995
|
const hostsClearAll = (utility) => props.filterable && utility === props.utilities.find((candidate) => candidate !== "select");
|
|
814
|
-
const utilityAttrs = (utility) => pinAttrs(props.hasPinned, props.offsets[utilityKey(utility)]);
|
|
996
|
+
const utilityAttrs = (utility) => pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)]);
|
|
815
997
|
const cellAttrs = (column) => {
|
|
816
998
|
const preview = resize.preview.value;
|
|
817
|
-
return pinAttrs(column
|
|
999
|
+
return pinAttrs(sideOf(column), props.offsets[column.field], preview?.field === column.field ? `${preview.width}px` : column.width);
|
|
818
1000
|
};
|
|
819
1001
|
const headerSlotProps = (column) => ({
|
|
820
1002
|
column,
|
|
@@ -822,7 +1004,8 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
822
1004
|
sortable: sort.isSortable(column),
|
|
823
1005
|
toggleSort: () => {
|
|
824
1006
|
sort.sortBy(column);
|
|
825
|
-
}
|
|
1007
|
+
},
|
|
1008
|
+
control: layout.controlOf(column.field)
|
|
826
1009
|
});
|
|
827
1010
|
return (_ctx, _cache) => {
|
|
828
1011
|
return openBlock(), createElementBlock("tr", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.utilities, (utility) => {
|
|
@@ -848,8 +1031,8 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
848
1031
|
title: unref(labels)().clearAllFilters,
|
|
849
1032
|
"aria-label": unref(labels)().clearAllFilters,
|
|
850
1033
|
disabled: !canClearAll.value,
|
|
851
|
-
onClick:
|
|
852
|
-
}, [..._cache[
|
|
1034
|
+
onClick: withModifiers(onClearAll, ["stop"])
|
|
1035
|
+
}, [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
|
|
853
1036
|
width: "14",
|
|
854
1037
|
height: "14",
|
|
855
1038
|
viewBox: "0 0 24 24",
|
|
@@ -875,13 +1058,21 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
875
1058
|
key: column.field,
|
|
876
1059
|
scope: "col",
|
|
877
1060
|
"data-field": column.field,
|
|
1061
|
+
"data-type": unref(columnTypeOf$1)(column),
|
|
878
1062
|
"data-sort": unref(sort).sortOf(column) ?? void 0,
|
|
879
1063
|
"data-sortable": unref(sort).isSortable(column) ? "" : void 0,
|
|
880
1064
|
"data-filtered": isFiltered(column) ? "" : void 0,
|
|
881
1065
|
"aria-sort": unref(ariaSort)(unref(sort).sortOf(column))
|
|
882
|
-
}, { ref_for: true },
|
|
883
|
-
|
|
884
|
-
|
|
1066
|
+
}, { ref_for: true }, {
|
|
1067
|
+
...cellAttrs(column),
|
|
1068
|
+
...dragAttrs(column)
|
|
1069
|
+
}), [
|
|
1070
|
+
unref(reorder).isReorderable(column) ? (openBlock(), createBlock(reorder_handle_default, {
|
|
1071
|
+
key: 0,
|
|
1072
|
+
column
|
|
1073
|
+
}, null, 8, ["column"])) : createCommentVNode("", true),
|
|
1074
|
+
given(`header-${column.field}`) ? renderSlot(_ctx.$slots, "header", mergeProps({ ref_for: true }, headerSlotProps(column)), void 0, void 0, 1) : unref(sort).isSortable(column) ? (openBlock(), createBlock(sort_button_default, {
|
|
1075
|
+
key: 2,
|
|
885
1076
|
column,
|
|
886
1077
|
direction: unref(sort).sortOf(column),
|
|
887
1078
|
onClick: ($event) => unref(sort).sortBy(column)
|
|
@@ -891,7 +1082,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
891
1082
|
"onClick"
|
|
892
1083
|
])) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(column.title), 1)),
|
|
893
1084
|
hasFilter(column) ? (openBlock(), createBlock(filter_cell_default, {
|
|
894
|
-
key:
|
|
1085
|
+
key: 4,
|
|
895
1086
|
column,
|
|
896
1087
|
type: unref(columnTypeOf$1)(column),
|
|
897
1088
|
query: __props.query
|
|
@@ -909,10 +1100,10 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
909
1100
|
"query"
|
|
910
1101
|
])) : createCommentVNode("", true),
|
|
911
1102
|
unref(resize).isResizable(column) ? (openBlock(), createBlock(resize_handle_default, {
|
|
912
|
-
key:
|
|
1103
|
+
key: 5,
|
|
913
1104
|
column
|
|
914
1105
|
}, null, 8, ["column"])) : createCommentVNode("", true)
|
|
915
|
-
], 16, _hoisted_3);
|
|
1106
|
+
], 16, _hoisted_3$1);
|
|
916
1107
|
}), 128))]);
|
|
917
1108
|
};
|
|
918
1109
|
}
|
|
@@ -936,9 +1127,10 @@ var table_pagination_default = /* @__PURE__ */ defineComponent({
|
|
|
936
1127
|
/** One string per map: compares two maps in one step. */
|
|
937
1128
|
var signature = (numbers) => JSON.stringify(numbers);
|
|
938
1129
|
/**
|
|
939
|
-
* Measured header geometry (C-47, C-48): the rendered width of every
|
|
940
|
-
* cell and, for the pinned cells, the cumulative
|
|
941
|
-
* `--qt-pin-left
|
|
1130
|
+
* Measured header geometry (C-47, C-48, C-71): the rendered width of every
|
|
1131
|
+
* header cell and, for the pinned cells, the cumulative offset: from the left
|
|
1132
|
+
* for a left-pinned cell (`--qt-pin-left`), from the right for a
|
|
1133
|
+
* right-pinned one (`--qt-pin-right`). One `ResizeObserver` watches the header cells and the
|
|
942
1134
|
* table; it reports width changes from any cause (a resize, a font that
|
|
943
1135
|
* loads, a container that narrows) in one batched callback, after layout, so
|
|
944
1136
|
* reading the cells there forces no extra layout. The observer is rebuilt
|
|
@@ -950,7 +1142,10 @@ var useHeaderGeometry = (options) => {
|
|
|
950
1142
|
const widths = shallowRef({});
|
|
951
1143
|
/** Rendered width of the table. */
|
|
952
1144
|
const tableWidth = shallowRef(0);
|
|
953
|
-
/**
|
|
1145
|
+
/**
|
|
1146
|
+
* `--qt-pin-left` of each left-pinned cell and `--qt-pin-right` of each
|
|
1147
|
+
* right-pinned one, by key, in pixels.
|
|
1148
|
+
*/
|
|
954
1149
|
const offsets = shallowRef({});
|
|
955
1150
|
let observer = null;
|
|
956
1151
|
const headerCells = (table) => table.querySelectorAll(":scope > thead > tr > *");
|
|
@@ -959,18 +1154,25 @@ var useHeaderGeometry = (options) => {
|
|
|
959
1154
|
const cells = options.cells();
|
|
960
1155
|
const next = {};
|
|
961
1156
|
const nextOffsets = {};
|
|
1157
|
+
const rights = [];
|
|
962
1158
|
let left = 0;
|
|
963
1159
|
headerCells(table).forEach((cell, index) => {
|
|
964
1160
|
const drawn = cells[index];
|
|
965
1161
|
if (drawn) {
|
|
966
1162
|
const width = cell.getBoundingClientRect().width;
|
|
967
1163
|
next[drawn.key] = width;
|
|
968
|
-
if (drawn.
|
|
1164
|
+
if (drawn.side === "left") {
|
|
969
1165
|
nextOffsets[drawn.key] = left;
|
|
970
1166
|
left += width;
|
|
971
|
-
}
|
|
1167
|
+
} else if (drawn.side === "right") rights.push([drawn.key, width]);
|
|
972
1168
|
}
|
|
973
1169
|
});
|
|
1170
|
+
let right = 0;
|
|
1171
|
+
for (let i = rights.length - 1; i >= 0; i--) {
|
|
1172
|
+
const [key, width] = rights[i];
|
|
1173
|
+
nextOffsets[key] = right;
|
|
1174
|
+
right += width;
|
|
1175
|
+
}
|
|
974
1176
|
if (signature(next) !== signature(widths.value)) widths.value = next;
|
|
975
1177
|
if (signature(nextOffsets) !== signature(offsets.value)) offsets.value = nextOffsets;
|
|
976
1178
|
};
|
|
@@ -995,7 +1197,7 @@ var useHeaderGeometry = (options) => {
|
|
|
995
1197
|
watch([
|
|
996
1198
|
() => options.table.value,
|
|
997
1199
|
options.active,
|
|
998
|
-
() => options.cells().map((cell) => cell.
|
|
1200
|
+
() => options.cells().map((cell) => cell.side === "left" ? `${cell.key}*` : cell.side === "right" ? `${cell.key}>` : cell.key).join("|")
|
|
999
1201
|
], () => {
|
|
1000
1202
|
nextTick(observe);
|
|
1001
1203
|
}, {
|
|
@@ -1013,6 +1215,142 @@ var useHeaderGeometry = (options) => {
|
|
|
1013
1215
|
};
|
|
1014
1216
|
};
|
|
1015
1217
|
//#endregion
|
|
1218
|
+
//#region src/reorder/use-column-reorder.ts
|
|
1219
|
+
var placeOf = (key) => key === "ArrowLeft" || key === "Home" ? "before" : "after";
|
|
1220
|
+
/**
|
|
1221
|
+
* Reordering a column with its handle (C-73): a pointer drag or the arrow
|
|
1222
|
+
* keys, Home and End, inside the column's region. The table keeps only the
|
|
1223
|
+
* drag in progress (P15); the order itself goes out as `update:columns` and
|
|
1224
|
+
* comes back, if the consumer wants it, as the order of `columns`. Like the
|
|
1225
|
+
* resize handle, the handle captures the pointer, so every drag event
|
|
1226
|
+
* arrives at the handle itself, and it has the focus, so Escape does too.
|
|
1227
|
+
*/
|
|
1228
|
+
var useColumnReorder = (options) => {
|
|
1229
|
+
const dragging = shallowRef(null);
|
|
1230
|
+
let drag = null;
|
|
1231
|
+
/** The column whose handle moved it by key and still has the focus. */
|
|
1232
|
+
let refocus = null;
|
|
1233
|
+
/** Between the new `columns` and their render: a blur then is the move's. */
|
|
1234
|
+
let patching = false;
|
|
1235
|
+
const isReorderable = (column) => options.reorderable() && column.reorderable !== false;
|
|
1236
|
+
/** This table's own header cell, never one of a nested table. */
|
|
1237
|
+
const headerCell = (field) => options.table.value?.querySelector(`:scope > thead > tr > th[data-field="${CSS.escape(field)}"]`) ?? null;
|
|
1238
|
+
const end = () => {
|
|
1239
|
+
drag = null;
|
|
1240
|
+
dragging.value = null;
|
|
1241
|
+
};
|
|
1242
|
+
/** Every pointer event of a handle; one listener for the whole drag. */
|
|
1243
|
+
const onPointer = (event, column) => {
|
|
1244
|
+
if (event.type === "pointerdown") {
|
|
1245
|
+
if (event.button !== 0 || drag) return;
|
|
1246
|
+
const handle = event.currentTarget;
|
|
1247
|
+
event.preventDefault();
|
|
1248
|
+
handle.focus({ preventScroll: true });
|
|
1249
|
+
handle.setPointerCapture(event.pointerId);
|
|
1250
|
+
refocus = null;
|
|
1251
|
+
drag = {
|
|
1252
|
+
field: column.field,
|
|
1253
|
+
pointerId: event.pointerId,
|
|
1254
|
+
cells: options.layout.regionOf(column.field).flatMap((field) => {
|
|
1255
|
+
const box = headerCell(field)?.getBoundingClientRect();
|
|
1256
|
+
return box ? [{
|
|
1257
|
+
field,
|
|
1258
|
+
left: box.left,
|
|
1259
|
+
right: box.right
|
|
1260
|
+
}] : [];
|
|
1261
|
+
})
|
|
1262
|
+
};
|
|
1263
|
+
dragging.value = {
|
|
1264
|
+
field: column.field,
|
|
1265
|
+
target: null,
|
|
1266
|
+
place: "after"
|
|
1267
|
+
};
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
1271
|
+
if (event.type === "pointermove") {
|
|
1272
|
+
const x = event.clientX;
|
|
1273
|
+
const over = drag.cells.find((cell) => x >= cell.left && x < cell.right);
|
|
1274
|
+
const target = over && over.field !== drag.field ? over.field : null;
|
|
1275
|
+
const place = over && x < (over.left + over.right) / 2 ? "before" : "after";
|
|
1276
|
+
const current = dragging.value;
|
|
1277
|
+
if (current?.target !== target || current.place !== place) dragging.value = {
|
|
1278
|
+
field: drag.field,
|
|
1279
|
+
target,
|
|
1280
|
+
place
|
|
1281
|
+
};
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
const done = dragging.value;
|
|
1285
|
+
end();
|
|
1286
|
+
if (event.type === "pointerup" && done?.target) options.layout.moveColumn(done.field, done.target, done.place);
|
|
1287
|
+
};
|
|
1288
|
+
const onKey = (event, column) => {
|
|
1289
|
+
const { key } = event;
|
|
1290
|
+
if (drag) {
|
|
1291
|
+
if (key === "Escape") {
|
|
1292
|
+
event.preventDefault();
|
|
1293
|
+
event.stopPropagation();
|
|
1294
|
+
end();
|
|
1295
|
+
}
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
1299
|
+
const region = options.layout.regionOf(column.field);
|
|
1300
|
+
const at = region.indexOf(column.field);
|
|
1301
|
+
const target = key === "ArrowLeft" ? region[at - 1] : key === "ArrowRight" ? region[at + 1] : key === "Home" ? region[0] : key === "End" ? region[region.length - 1] : void 0;
|
|
1302
|
+
if (at < 0 || target === void 0) return;
|
|
1303
|
+
event.preventDefault();
|
|
1304
|
+
if (target !== column.field) {
|
|
1305
|
+
refocus = column.field;
|
|
1306
|
+
options.layout.moveColumn(column.field, target, placeOf(key));
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
watch(options.columns, () => {
|
|
1310
|
+
patching = true;
|
|
1311
|
+
});
|
|
1312
|
+
watch(options.columns, () => {
|
|
1313
|
+
patching = false;
|
|
1314
|
+
if (drag) end();
|
|
1315
|
+
const field = refocus;
|
|
1316
|
+
if (field !== null) nextTick(() => {
|
|
1317
|
+
const handle = headerCell(field)?.querySelector(":scope > .qt-reorder-handle");
|
|
1318
|
+
if (handle && refocus === field && document.activeElement !== handle) handle.focus({ preventScroll: true });
|
|
1319
|
+
});
|
|
1320
|
+
}, { flush: "post" });
|
|
1321
|
+
onBeforeUnmount(end);
|
|
1322
|
+
/**
|
|
1323
|
+
* The listeners of one handle, as one `v-on` object made once per handle.
|
|
1324
|
+
* Pointer capture sends every drag event to the handle itself.
|
|
1325
|
+
*/
|
|
1326
|
+
const listeners = (column) => {
|
|
1327
|
+
const pointer = (event) => {
|
|
1328
|
+
onPointer(event, column());
|
|
1329
|
+
};
|
|
1330
|
+
return {
|
|
1331
|
+
pointerdown: pointer,
|
|
1332
|
+
pointermove: pointer,
|
|
1333
|
+
pointerup: pointer,
|
|
1334
|
+
pointercancel: pointer,
|
|
1335
|
+
lostpointercapture: pointer,
|
|
1336
|
+
keydown: (event) => {
|
|
1337
|
+
onKey(event, column());
|
|
1338
|
+
},
|
|
1339
|
+
blur: () => {
|
|
1340
|
+
if (!patching) refocus = null;
|
|
1341
|
+
},
|
|
1342
|
+
click: (event) => {
|
|
1343
|
+
event.stopPropagation();
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
};
|
|
1347
|
+
return {
|
|
1348
|
+
isReorderable,
|
|
1349
|
+
dragging,
|
|
1350
|
+
listeners
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
//#endregion
|
|
1016
1354
|
//#region src/use-query-table.ts
|
|
1017
1355
|
/** The TanStack features of a Query Table, the two plugins included. */
|
|
1018
1356
|
var features = tableFeatures({
|
|
@@ -1022,7 +1360,10 @@ var features = tableFeatures({
|
|
|
1022
1360
|
globalFilteringFeature,
|
|
1023
1361
|
rowSelectionFeature,
|
|
1024
1362
|
rowExpandingFeature,
|
|
1363
|
+
columnVisibilityFeature,
|
|
1364
|
+
columnOrderingFeature,
|
|
1025
1365
|
columnPinningFeature,
|
|
1366
|
+
rowPinningFeature,
|
|
1026
1367
|
serverQueryFeature,
|
|
1027
1368
|
filterInputFeature
|
|
1028
1369
|
});
|
|
@@ -1039,6 +1380,11 @@ var defaultPageSizes = [
|
|
|
1039
1380
|
];
|
|
1040
1381
|
/** Only the `true` entries: the selection a consumer stores. */
|
|
1041
1382
|
var selectedOnly = (selection) => Object.fromEntries(Object.entries(selection).filter(([, value]) => value));
|
|
1383
|
+
var noPinnedRows = Object.freeze({
|
|
1384
|
+
top: Object.freeze([]),
|
|
1385
|
+
bottom: Object.freeze([])
|
|
1386
|
+
});
|
|
1387
|
+
var sameKeys = (a, b) => a.length === b.length && a.every((key, i) => key === b[i]);
|
|
1042
1388
|
/**
|
|
1043
1389
|
* The state and actions of a server-side table: TanStack Table with
|
|
1044
1390
|
* `serverQueryFeature` and `filterInputFeature`, in a Vue scope. Disposed
|
|
@@ -1052,6 +1398,16 @@ function useQueryTable(options) {
|
|
|
1052
1398
|
const columns = () => toValue(options.columns);
|
|
1053
1399
|
const rowKey = () => toValue(options.rowKey);
|
|
1054
1400
|
const hasSubtable = () => toValue(options.hasSubtable) ?? false;
|
|
1401
|
+
const pinnedRows = () => toValue(options.rowPinning);
|
|
1402
|
+
const pinningEnabled = computed(() => rowKey() !== void 0 && pinnedRows() !== void 0);
|
|
1403
|
+
const rowPinningState = computed(() => {
|
|
1404
|
+
if (!pinningEnabled.value) return noPinnedRows;
|
|
1405
|
+
const map = pinnedRows();
|
|
1406
|
+
return {
|
|
1407
|
+
top: map.top ?? [],
|
|
1408
|
+
bottom: map.bottom ?? []
|
|
1409
|
+
};
|
|
1410
|
+
});
|
|
1055
1411
|
const keyOf = (row, index) => {
|
|
1056
1412
|
const key = rowKey();
|
|
1057
1413
|
if (typeof key === "function") return key(row, index);
|
|
@@ -1071,10 +1427,16 @@ function useQueryTable(options) {
|
|
|
1071
1427
|
enableSorting: column.sortable !== false,
|
|
1072
1428
|
filterType: columnTypeOf(column)
|
|
1073
1429
|
})));
|
|
1430
|
+
const columnVisibility = computed(() => Object.fromEntries(columns().map((column) => [column.field, !column.hide])));
|
|
1431
|
+
const columnOrder = computed(() => columns().map((column) => column.field));
|
|
1074
1432
|
const columnPinning = computed(() => ({
|
|
1075
|
-
start: columns().filter((column) => column
|
|
1076
|
-
end:
|
|
1433
|
+
start: columns().filter((column) => sideOf(column) === "left").map((column) => column.field),
|
|
1434
|
+
end: columns().filter((column) => sideOf(column) === "right").map((column) => column.field)
|
|
1077
1435
|
}));
|
|
1436
|
+
/** A layout change goes to the consumer; an equal result is no change (C-68). */
|
|
1437
|
+
const tell = (next, reason) => {
|
|
1438
|
+
if (next) options.onColumnsChange?.(next, reason);
|
|
1439
|
+
};
|
|
1078
1440
|
/** Updates emitted so far: tells whether an action emitted one. */
|
|
1079
1441
|
let emits = 0;
|
|
1080
1442
|
const table = useTable({
|
|
@@ -1113,6 +1475,21 @@ function useQueryTable(options) {
|
|
|
1113
1475
|
const current = toValue(options.selection) ?? {};
|
|
1114
1476
|
options.onSelectionChange?.(selectedOnly(functionalUpdate(updater, current)));
|
|
1115
1477
|
},
|
|
1478
|
+
onColumnVisibilityChange: (updater) => tell(applyVisibility(columns(), functionalUpdate(updater, columnVisibility.value)), "visibility"),
|
|
1479
|
+
onColumnOrderChange: (updater) => tell(applyOrder(columns(), functionalUpdate(updater, columnOrder.value)), "order"),
|
|
1480
|
+
onColumnPinningChange: (updater) => tell(applyPinning(columns(), functionalUpdate(updater, columnPinning.value)), "pin"),
|
|
1481
|
+
get enableRowPinning() {
|
|
1482
|
+
return pinningEnabled.value;
|
|
1483
|
+
},
|
|
1484
|
+
onRowPinningChange: (updater) => {
|
|
1485
|
+
if (!pinningEnabled.value) return;
|
|
1486
|
+
const current = rowPinningState.value;
|
|
1487
|
+
const next = functionalUpdate(updater, current);
|
|
1488
|
+
if (!sameKeys(next.top, current.top) || !sameKeys(next.bottom, current.bottom)) options.onRowPinningChange?.({
|
|
1489
|
+
top: [...next.top],
|
|
1490
|
+
bottom: [...next.bottom]
|
|
1491
|
+
});
|
|
1492
|
+
},
|
|
1116
1493
|
state: {
|
|
1117
1494
|
get sorting() {
|
|
1118
1495
|
return projection.value.state.sorting;
|
|
@@ -1129,8 +1506,17 @@ function useQueryTable(options) {
|
|
|
1129
1506
|
get rowSelection() {
|
|
1130
1507
|
return toValue(options.selection) ?? {};
|
|
1131
1508
|
},
|
|
1509
|
+
get columnVisibility() {
|
|
1510
|
+
return columnVisibility.value;
|
|
1511
|
+
},
|
|
1512
|
+
get columnOrder() {
|
|
1513
|
+
return columnOrder.value;
|
|
1514
|
+
},
|
|
1132
1515
|
get columnPinning() {
|
|
1133
1516
|
return columnPinning.value;
|
|
1517
|
+
},
|
|
1518
|
+
get rowPinning() {
|
|
1519
|
+
return rowPinningState.value;
|
|
1134
1520
|
}
|
|
1135
1521
|
}
|
|
1136
1522
|
});
|
|
@@ -1141,9 +1527,63 @@ function useQueryTable(options) {
|
|
|
1141
1527
|
column,
|
|
1142
1528
|
index
|
|
1143
1529
|
}]));
|
|
1144
|
-
return [
|
|
1530
|
+
return [
|
|
1531
|
+
...table.getStartVisibleLeafColumns(),
|
|
1532
|
+
...table.getCenterVisibleLeafColumns(),
|
|
1533
|
+
...table.getEndVisibleLeafColumns()
|
|
1534
|
+
].map((column) => byField.get(column.id)).filter((entry) => !!entry);
|
|
1145
1535
|
});
|
|
1146
|
-
const hasPinned = computed(() => entries.value.some((entry) => entry.column
|
|
1536
|
+
const hasPinned = computed(() => entries.value.some((entry) => sideOf(entry.column) === "left"));
|
|
1537
|
+
const regionOf = (field) => {
|
|
1538
|
+
const own = entries.value.find((entry) => entry.column.field === field);
|
|
1539
|
+
if (!own) return [];
|
|
1540
|
+
const side = sideOf(own.column);
|
|
1541
|
+
return entries.value.filter((entry) => sideOf(entry.column) === side).map((entry) => entry.column.field);
|
|
1542
|
+
};
|
|
1543
|
+
const moveColumn = (field, target, place) => {
|
|
1544
|
+
if (field !== target && regionOf(field).includes(target)) table.setColumnOrder(moveField(columnOrder.value, field, target, place));
|
|
1545
|
+
};
|
|
1546
|
+
/**
|
|
1547
|
+
* A column's control. Every slot of every column gets one, so making it
|
|
1548
|
+
* does no work: `pinned`, `canMoveLeft` and `canMoveRight` read the layout
|
|
1549
|
+
* when they are read (a region is O(n)), and a slot that never reads them
|
|
1550
|
+
* costs nothing. A control kept past a re-render reads the current layout.
|
|
1551
|
+
*/
|
|
1552
|
+
const controlOf = (field) => {
|
|
1553
|
+
const place = () => {
|
|
1554
|
+
const region = regionOf(field);
|
|
1555
|
+
return {
|
|
1556
|
+
at: region.indexOf(field),
|
|
1557
|
+
size: region.length
|
|
1558
|
+
};
|
|
1559
|
+
};
|
|
1560
|
+
return {
|
|
1561
|
+
get pinned() {
|
|
1562
|
+
const column = columns().find((candidate) => candidate.field === field);
|
|
1563
|
+
return column ? sideOf(column) : false;
|
|
1564
|
+
},
|
|
1565
|
+
pin: (side) => columnById(field)?.pin(side === "left" ? "start" : side === "right" ? "end" : false),
|
|
1566
|
+
hide: () => columnById(field)?.toggleVisibility(false),
|
|
1567
|
+
get canMoveLeft() {
|
|
1568
|
+
return place().at > 0;
|
|
1569
|
+
},
|
|
1570
|
+
get canMoveRight() {
|
|
1571
|
+
const { at, size } = place();
|
|
1572
|
+
return at >= 0 && at < size - 1;
|
|
1573
|
+
},
|
|
1574
|
+
move: (direction) => {
|
|
1575
|
+
const current = regionOf(field);
|
|
1576
|
+
const from = current.indexOf(field);
|
|
1577
|
+
const target = current[from + (direction === "left" ? -1 : 1)];
|
|
1578
|
+
if (from >= 0 && target !== void 0) moveColumn(field, target, direction === "left" ? "before" : "after");
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
};
|
|
1582
|
+
const layout = {
|
|
1583
|
+
controlOf,
|
|
1584
|
+
regionOf,
|
|
1585
|
+
moveColumn
|
|
1586
|
+
};
|
|
1147
1587
|
/** Typed and not yet answered; `null` when the input shows the query. */
|
|
1148
1588
|
const typed = shallowRef(null);
|
|
1149
1589
|
let searchTimer;
|
|
@@ -1330,35 +1770,719 @@ function useQueryTable(options) {
|
|
|
1330
1770
|
return state;
|
|
1331
1771
|
});
|
|
1332
1772
|
}, { immediate: true });
|
|
1773
|
+
const selection = {
|
|
1774
|
+
enabled: computed(() => toValue(options.selection) !== void 0),
|
|
1775
|
+
isSelected: (row, index) => !!toValue(options.selection)?.[idOf(row, index)],
|
|
1776
|
+
toggle: (row, index) => {
|
|
1777
|
+
const id = idOf(row, index);
|
|
1778
|
+
table.setRowSelection((old) => {
|
|
1779
|
+
const next = { ...old };
|
|
1780
|
+
if (next[id]) delete next[id];
|
|
1781
|
+
else next[id] = true;
|
|
1782
|
+
return next;
|
|
1783
|
+
});
|
|
1784
|
+
},
|
|
1785
|
+
allSelected: computed(() => table.getIsAllPageRowsSelected()),
|
|
1786
|
+
someSelected: computed(() => table.getIsSomePageRowsSelected()),
|
|
1787
|
+
toggleAll: (value) => table.toggleAllPageRowsSelected(value)
|
|
1788
|
+
};
|
|
1789
|
+
const bodyRows = computed(() => {
|
|
1790
|
+
if (!pinningEnabled.value) return rows().map((row, index) => ({
|
|
1791
|
+
row,
|
|
1792
|
+
index,
|
|
1793
|
+
pinned: false
|
|
1794
|
+
}));
|
|
1795
|
+
const of = (row, pinned) => ({
|
|
1796
|
+
row: row.original,
|
|
1797
|
+
index: row.index,
|
|
1798
|
+
pinned
|
|
1799
|
+
});
|
|
1800
|
+
return [
|
|
1801
|
+
...table.getTopRows().map((row) => of(row, "top")),
|
|
1802
|
+
...table.getCenterRows().map((row) => of(row, false)),
|
|
1803
|
+
...table.getBottomRows().map((row) => of(row, "bottom"))
|
|
1804
|
+
];
|
|
1805
|
+
});
|
|
1806
|
+
const positionOf = (id) => {
|
|
1807
|
+
const { top, bottom } = rowPinningState.value;
|
|
1808
|
+
return top.includes(id) ? "top" : bottom.includes(id) ? "bottom" : false;
|
|
1809
|
+
};
|
|
1333
1810
|
return {
|
|
1334
1811
|
table,
|
|
1335
1812
|
columns: entries,
|
|
1336
1813
|
hasPinned,
|
|
1814
|
+
layout,
|
|
1337
1815
|
sort,
|
|
1338
1816
|
filters,
|
|
1339
1817
|
search,
|
|
1340
1818
|
pagination,
|
|
1341
1819
|
expansion,
|
|
1342
|
-
selection
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1820
|
+
selection,
|
|
1821
|
+
rowPinning: {
|
|
1822
|
+
enabled: pinningEnabled,
|
|
1823
|
+
rows: bodyRows,
|
|
1824
|
+
pin: (row, index, position) => {
|
|
1346
1825
|
const id = idOf(row, index);
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
else next[id] = true;
|
|
1351
|
-
return next;
|
|
1352
|
-
});
|
|
1353
|
-
},
|
|
1354
|
-
allSelected: computed(() => table.getIsAllPageRowsSelected()),
|
|
1355
|
-
someSelected: computed(() => table.getIsSomePageRowsSelected()),
|
|
1356
|
-
toggleAll: (value) => table.toggleAllPageRowsSelected(value)
|
|
1826
|
+
if (!pinningEnabled.value || positionOf(id) === position) return;
|
|
1827
|
+
table.getRow(id, true)?.pin(position);
|
|
1828
|
+
}
|
|
1357
1829
|
},
|
|
1358
1830
|
baseQuery
|
|
1359
1831
|
};
|
|
1360
1832
|
}
|
|
1361
1833
|
//#endregion
|
|
1834
|
+
//#region src/virtual/use-load-more.ts
|
|
1835
|
+
/**
|
|
1836
|
+
* Infinite scroll (C-88 to C-90): whether there is more to load, the
|
|
1837
|
+
* automatic request near the end of `rows` and `loadMore`. The rows are
|
|
1838
|
+
* the consumer's; the table only emits the next page action.
|
|
1839
|
+
*/
|
|
1840
|
+
var useLoadMore = (o) => {
|
|
1841
|
+
const enabled = computed(() => !!o.infinite() && o.rowKey() !== void 0);
|
|
1842
|
+
const threshold = () => {
|
|
1843
|
+
const value = o.infinite();
|
|
1844
|
+
const given = typeof value === "object" ? value.threshold : void 0;
|
|
1845
|
+
return given !== void 0 && given >= 0 ? Math.trunc(given) : 5;
|
|
1846
|
+
};
|
|
1847
|
+
const canLoadMore = computed(() => {
|
|
1848
|
+
const query = o.query();
|
|
1849
|
+
if (isCursorQuery(query)) return !!o.cursors()?.next;
|
|
1850
|
+
const total = o.totalRows();
|
|
1851
|
+
return total !== null ? query.page < Math.max(1, Math.ceil(total / query.pageSize)) : o.rows().length >= query.page * query.pageSize;
|
|
1852
|
+
});
|
|
1853
|
+
const loadMore = () => {
|
|
1854
|
+
if (enabled.value && canLoadMore.value && !o.loading()) o.nextPage();
|
|
1855
|
+
};
|
|
1856
|
+
const seen = shallowRef(false);
|
|
1857
|
+
let observer = null;
|
|
1858
|
+
watch([
|
|
1859
|
+
enabled,
|
|
1860
|
+
o.virtual,
|
|
1861
|
+
o.rows,
|
|
1862
|
+
o.table
|
|
1863
|
+
], () => {
|
|
1864
|
+
observer?.disconnect();
|
|
1865
|
+
observer = null;
|
|
1866
|
+
seen.value = false;
|
|
1867
|
+
const count = o.rows().length;
|
|
1868
|
+
const tbody = o.table.value?.tBodies[0];
|
|
1869
|
+
if (!enabled.value || o.virtual() || !tbody || count === 0 || typeof IntersectionObserver === "undefined") return;
|
|
1870
|
+
const others = tbody.querySelectorAll(":scope > tr[data-row-index]:not([data-pinned-row])");
|
|
1871
|
+
const target = others[Math.max(0, others.length - 1 - threshold())];
|
|
1872
|
+
if (target) {
|
|
1873
|
+
observer = new IntersectionObserver((entries) => {
|
|
1874
|
+
seen.value = entries.some((entry) => entry.isIntersecting);
|
|
1875
|
+
});
|
|
1876
|
+
observer.observe(target);
|
|
1877
|
+
}
|
|
1878
|
+
}, {
|
|
1879
|
+
flush: "post",
|
|
1880
|
+
immediate: true
|
|
1881
|
+
});
|
|
1882
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
1883
|
+
let asked = "";
|
|
1884
|
+
watchEffect(() => {
|
|
1885
|
+
if (!enabled.value || !canLoadMore.value || o.loading()) return;
|
|
1886
|
+
const range = o.window();
|
|
1887
|
+
if (!(o.virtual() ? range !== null && range.end >= range.count - threshold() : seen.value)) return;
|
|
1888
|
+
const signature = `${JSON.stringify(o.query())}#${o.rows().length}`;
|
|
1889
|
+
if (signature !== asked) {
|
|
1890
|
+
asked = signature;
|
|
1891
|
+
o.nextPage();
|
|
1892
|
+
}
|
|
1893
|
+
}, { flush: "post" });
|
|
1894
|
+
let warned = false;
|
|
1895
|
+
watchEffect(() => {
|
|
1896
|
+
if (!warned && o.infinite() && o.rowKey() === void 0) {
|
|
1897
|
+
warned = true;
|
|
1898
|
+
try {
|
|
1899
|
+
if (process.env.NODE_ENV === "production") return;
|
|
1900
|
+
} catch {}
|
|
1901
|
+
console.warn("[QueryTable] `infinite` needs `rowKey`; it is ignored without one (C-88).");
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
return {
|
|
1905
|
+
enabled,
|
|
1906
|
+
canLoadMore,
|
|
1907
|
+
loadMore
|
|
1908
|
+
};
|
|
1909
|
+
};
|
|
1910
|
+
//#endregion
|
|
1911
|
+
//#region src/virtual/compute-window.ts
|
|
1912
|
+
/**
|
|
1913
|
+
* Fills `offsets` from `heights`, starting at position `from` (the offsets
|
|
1914
|
+
* before it are kept): `offsets[i + 1] = offsets[i] + heights[i]`.
|
|
1915
|
+
*/
|
|
1916
|
+
var fillOffsets = (heights, offsets, from = 0) => {
|
|
1917
|
+
for (let i = from; i < heights.length; i++) offsets[i + 1] = offsets[i] + heights[i];
|
|
1918
|
+
};
|
|
1919
|
+
/**
|
|
1920
|
+
* The item that holds the point `y`: the last position whose top is at most
|
|
1921
|
+
* `y`, clamped to the items (0 for a point above them, the last item for a
|
|
1922
|
+
* point below them). `-1` when there is no item.
|
|
1923
|
+
*/
|
|
1924
|
+
var indexAt = (offsets, y) => {
|
|
1925
|
+
let low = 0;
|
|
1926
|
+
let high = offsets.length - 2;
|
|
1927
|
+
if (high < 0) return -1;
|
|
1928
|
+
while (low < high) {
|
|
1929
|
+
const mid = low + high + 1 >> 1;
|
|
1930
|
+
if (offsets[mid] <= y) low = mid;
|
|
1931
|
+
else high = mid - 1;
|
|
1932
|
+
}
|
|
1933
|
+
return low;
|
|
1934
|
+
};
|
|
1935
|
+
/** The items to draw: the ones in view and `overscan` more on each side. */
|
|
1936
|
+
var computeWindow = ({ offsets, scrollTop, viewportHeight, overscan }) => {
|
|
1937
|
+
const count = offsets.length - 1;
|
|
1938
|
+
if (count <= 0) return {
|
|
1939
|
+
start: 0,
|
|
1940
|
+
end: 0
|
|
1941
|
+
};
|
|
1942
|
+
const first = indexAt(offsets, scrollTop);
|
|
1943
|
+
const bottom = scrollTop + Math.max(0, viewportHeight);
|
|
1944
|
+
let last = indexAt(offsets, bottom);
|
|
1945
|
+
if (last > first && offsets[last] >= bottom) last -= 1;
|
|
1946
|
+
return {
|
|
1947
|
+
start: Math.max(0, first - overscan),
|
|
1948
|
+
end: Math.min(count, last + 1 + overscan)
|
|
1949
|
+
};
|
|
1950
|
+
};
|
|
1951
|
+
/**
|
|
1952
|
+
* The body between the pinned rows: an upper spacer, the drawn items and a
|
|
1953
|
+
* lower spacer. A `kept` item outside the range (it holds the focus, C-86)
|
|
1954
|
+
* is drawn on its own, with a spacer of its own between it and the range.
|
|
1955
|
+
* Spacers of height 0 are left out. `slot` names a spacer's place, so a
|
|
1956
|
+
* spacer keeps its identity while its height changes.
|
|
1957
|
+
*/
|
|
1958
|
+
var segmentsOf = (offsets, range, kept) => {
|
|
1959
|
+
const count = offsets.length - 1;
|
|
1960
|
+
const total = count > 0 ? offsets[count] : 0;
|
|
1961
|
+
const out = [];
|
|
1962
|
+
const spacer = (height, slot) => {
|
|
1963
|
+
if (height > 0) out.push({
|
|
1964
|
+
spacer: height,
|
|
1965
|
+
slot
|
|
1966
|
+
});
|
|
1967
|
+
};
|
|
1968
|
+
const run = (from, to) => {
|
|
1969
|
+
if (to > from) out.push({
|
|
1970
|
+
from,
|
|
1971
|
+
to
|
|
1972
|
+
});
|
|
1973
|
+
};
|
|
1974
|
+
const { start, end } = range;
|
|
1975
|
+
if (kept !== null && kept >= 0 && kept < start) {
|
|
1976
|
+
spacer(offsets[kept], 0);
|
|
1977
|
+
run(kept, kept + 1);
|
|
1978
|
+
spacer(offsets[start] - offsets[kept + 1], 1);
|
|
1979
|
+
run(start, end);
|
|
1980
|
+
spacer(total - offsets[end], 2);
|
|
1981
|
+
} else if (kept !== null && kept >= end && kept < count) {
|
|
1982
|
+
spacer(offsets[start], 0);
|
|
1983
|
+
run(start, end);
|
|
1984
|
+
spacer(offsets[kept] - offsets[end], 1);
|
|
1985
|
+
run(kept, kept + 1);
|
|
1986
|
+
spacer(total - offsets[kept + 1], 2);
|
|
1987
|
+
} else {
|
|
1988
|
+
spacer(offsets[start], 0);
|
|
1989
|
+
run(start, end);
|
|
1990
|
+
spacer(total - offsets[end], 2);
|
|
1991
|
+
}
|
|
1992
|
+
return out;
|
|
1993
|
+
};
|
|
1994
|
+
//#endregion
|
|
1995
|
+
//#region src/virtual/use-row-window.ts
|
|
1996
|
+
var isDevelopment = () => {
|
|
1997
|
+
try {
|
|
1998
|
+
return process.env.NODE_ENV !== "production";
|
|
1999
|
+
} catch {
|
|
2000
|
+
return true;
|
|
2001
|
+
}
|
|
2002
|
+
};
|
|
2003
|
+
/** One identity per spacer place: above, between, below (`segmentsOf`). */
|
|
2004
|
+
var spacerKeys = [
|
|
2005
|
+
Symbol("above"),
|
|
2006
|
+
Symbol("between"),
|
|
2007
|
+
Symbol("below")
|
|
2008
|
+
];
|
|
2009
|
+
/**
|
|
2010
|
+
* The virtual body (C-83 to C-87): which rows are drawn, the spacers that
|
|
2011
|
+
* stand for the others, the measured heights, the focused row kept drawn,
|
|
2012
|
+
* printing and `scrollToIndex`. Without `virtual` it draws `bodyRows` as
|
|
2013
|
+
* they are and touches no DOM.
|
|
2014
|
+
*/
|
|
2015
|
+
var useRowWindow = (o) => {
|
|
2016
|
+
const settings = computed((previous) => {
|
|
2017
|
+
const value = o.virtual();
|
|
2018
|
+
const next = value === true ? {} : value || null;
|
|
2019
|
+
return previous && next && previous.overscan === next.overscan && previous.rowHeight === next.rowHeight && previous.estimateRowHeight === next.estimateRowHeight && previous.scrollElement === next.scrollElement ? previous : next;
|
|
2020
|
+
});
|
|
2021
|
+
const enabled = () => settings.value !== null;
|
|
2022
|
+
const overscan = () => Math.max(0, settings.value?.overscan ?? 10);
|
|
2023
|
+
const fixed = () => settings.value?.rowHeight;
|
|
2024
|
+
/** Pinned rows sit at both ends of `bodyRows`; the window is the middle. */
|
|
2025
|
+
const parts = computed(() => {
|
|
2026
|
+
const all = o.bodyRows();
|
|
2027
|
+
let top = 0;
|
|
2028
|
+
while (top < all.length && all[top].pinned === "top") top++;
|
|
2029
|
+
let bottom = all.length;
|
|
2030
|
+
while (bottom > top && all[bottom - 1].pinned === "bottom") bottom--;
|
|
2031
|
+
return {
|
|
2032
|
+
all,
|
|
2033
|
+
top,
|
|
2034
|
+
center: top === 0 && bottom === all.length ? all : all.slice(top, bottom)
|
|
2035
|
+
};
|
|
2036
|
+
});
|
|
2037
|
+
const center = () => parts.value.center;
|
|
2038
|
+
/** Position of a row index among the center rows (ascending), or -1. */
|
|
2039
|
+
const positionOf = (index) => {
|
|
2040
|
+
const rows = center();
|
|
2041
|
+
if (rows[index]?.index === index) return index;
|
|
2042
|
+
let low = 0;
|
|
2043
|
+
let high = rows.length - 1;
|
|
2044
|
+
while (low <= high) {
|
|
2045
|
+
const mid = low + high >> 1;
|
|
2046
|
+
const at = rows[mid].index;
|
|
2047
|
+
if (at === index) return mid;
|
|
2048
|
+
if (at < index) low = mid + 1;
|
|
2049
|
+
else high = mid - 1;
|
|
2050
|
+
}
|
|
2051
|
+
return -1;
|
|
2052
|
+
};
|
|
2053
|
+
let heights = /* @__PURE__ */ new Float64Array(0);
|
|
2054
|
+
let measured = /* @__PURE__ */ new Uint8Array(0);
|
|
2055
|
+
let offsets = /* @__PURE__ */ new Float64Array(1);
|
|
2056
|
+
let byKey = /* @__PURE__ */ new Map();
|
|
2057
|
+
/** The first measured height, the estimate when none is given. */
|
|
2058
|
+
let firstMeasured = 0;
|
|
2059
|
+
/** Bumped whenever `offsets` change, so the spacers are drawn again. */
|
|
2060
|
+
const version = shallowRef(0);
|
|
2061
|
+
const estimate = () => fixed() ?? settings.value?.estimateRowHeight ?? (firstMeasured || 32);
|
|
2062
|
+
const rebuild = () => {
|
|
2063
|
+
const rows = enabled() ? center() : [];
|
|
2064
|
+
const height = fixed();
|
|
2065
|
+
heights = new Float64Array(rows.length);
|
|
2066
|
+
measured = new Uint8Array(rows.length);
|
|
2067
|
+
const kept = /* @__PURE__ */ new Map();
|
|
2068
|
+
for (let i = 0; i < rows.length; i++) {
|
|
2069
|
+
if (height !== void 0) {
|
|
2070
|
+
heights[i] = height;
|
|
2071
|
+
continue;
|
|
2072
|
+
}
|
|
2073
|
+
const key = o.keyOf(rows[i].row, rows[i].index);
|
|
2074
|
+
const known = byKey.get(key);
|
|
2075
|
+
if (known === void 0) heights[i] = estimate();
|
|
2076
|
+
else {
|
|
2077
|
+
kept.set(key, known);
|
|
2078
|
+
heights[i] = known;
|
|
2079
|
+
measured[i] = 1;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
byKey = kept;
|
|
2083
|
+
pending = null;
|
|
2084
|
+
offsets = new Float64Array(rows.length + 1);
|
|
2085
|
+
fillOffsets(heights, offsets);
|
|
2086
|
+
version.value++;
|
|
2087
|
+
};
|
|
2088
|
+
const body = () => o.table.value?.tBodies[0] ?? null;
|
|
2089
|
+
/** The drawn data row at a center position. */
|
|
2090
|
+
const rowElement = (tbody, position) => {
|
|
2091
|
+
const row = center()[position];
|
|
2092
|
+
return row ? tbody.querySelector(`:scope > tr[data-row-index="${row.index}"]:not([data-pinned-row])`) : null;
|
|
2093
|
+
};
|
|
2094
|
+
/** Height of a drawn item: its row and its subtable row. */
|
|
2095
|
+
const itemHeight = (tr) => {
|
|
2096
|
+
const next = tr.nextElementSibling;
|
|
2097
|
+
return tr.getBoundingClientRect().height + (next?.classList.contains("qt-subtable-row") ? next.getBoundingClientRect().height : 0);
|
|
2098
|
+
};
|
|
2099
|
+
/** Reads the drawn items; `true` when a height changed. */
|
|
2100
|
+
const measure = (tbody) => {
|
|
2101
|
+
if (fixed() !== void 0) return false;
|
|
2102
|
+
const rows = center();
|
|
2103
|
+
let from = -1;
|
|
2104
|
+
for (const tr of tbody.children) {
|
|
2105
|
+
const at = tr.getAttribute("data-row-index");
|
|
2106
|
+
if (at === null || tr.hasAttribute("data-pinned-row")) continue;
|
|
2107
|
+
const position = positionOf(Number(at));
|
|
2108
|
+
if (position < 0) continue;
|
|
2109
|
+
const height = itemHeight(tr);
|
|
2110
|
+
if (!firstMeasured && height > 0 && settings.value?.estimateRowHeight === void 0) {
|
|
2111
|
+
firstMeasured = height;
|
|
2112
|
+
for (let i = 0; i < heights.length; i++) if (!measured[i]) heights[i] = height;
|
|
2113
|
+
from = 0;
|
|
2114
|
+
}
|
|
2115
|
+
if (!measured[position] || Math.abs(heights[position] - height) > .5) {
|
|
2116
|
+
heights[position] = height;
|
|
2117
|
+
measured[position] = 1;
|
|
2118
|
+
byKey.set(o.keyOf(rows[position].row, rows[position].index), height);
|
|
2119
|
+
from = from < 0 ? position : Math.min(from, position);
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (from >= 0) {
|
|
2123
|
+
fillOffsets(heights, offsets, from);
|
|
2124
|
+
version.value++;
|
|
2125
|
+
return true;
|
|
2126
|
+
}
|
|
2127
|
+
return false;
|
|
2128
|
+
};
|
|
2129
|
+
const range = shallowRef({
|
|
2130
|
+
start: 0,
|
|
2131
|
+
end: Math.ceil((globalThis.innerHeight || 800) / 32) + 10
|
|
2132
|
+
});
|
|
2133
|
+
/** The window was computed from the layout at least once. */
|
|
2134
|
+
const ready = shallowRef(false);
|
|
2135
|
+
let container = null;
|
|
2136
|
+
let frame = 0;
|
|
2137
|
+
/** The first visible item and its top before the window moved (C-84). */
|
|
2138
|
+
let anchor = null;
|
|
2139
|
+
/**
|
|
2140
|
+
* The container's scroll position the window was computed for. The
|
|
2141
|
+
* browser's own scroll anchoring may move it when the drawn rows change
|
|
2142
|
+
* (it anchors to a spacer when no row is in view); it is put back.
|
|
2143
|
+
*/
|
|
2144
|
+
let expected = null;
|
|
2145
|
+
/** A `scrollToIndex` to correct once its row is drawn (C-87). */
|
|
2146
|
+
let pending = null;
|
|
2147
|
+
/** Frames a `scrollToIndex` waits for its row before it is given up. */
|
|
2148
|
+
const pendingFrames = 6;
|
|
2149
|
+
const viewport = () => {
|
|
2150
|
+
if (container === null || container === window) return {
|
|
2151
|
+
top: 0,
|
|
2152
|
+
height: globalThis.innerHeight
|
|
2153
|
+
};
|
|
2154
|
+
const element = container;
|
|
2155
|
+
return {
|
|
2156
|
+
top: element.getBoundingClientRect().top + element.clientTop,
|
|
2157
|
+
height: element.clientHeight
|
|
2158
|
+
};
|
|
2159
|
+
};
|
|
2160
|
+
/** Client top of the first center item: below the top-pinned rows. */
|
|
2161
|
+
const itemsTop = (tbody) => {
|
|
2162
|
+
for (const tr of tbody.children) if (tr.getAttribute("data-pinned-row") !== "top") return tr.getBoundingClientRect().top;
|
|
2163
|
+
return tbody.getBoundingClientRect().bottom;
|
|
2164
|
+
};
|
|
2165
|
+
const scrollTopOf = (target) => target === window ? window.scrollY : target.scrollTop;
|
|
2166
|
+
const scrollBy = (delta) => {
|
|
2167
|
+
if (Math.abs(delta) < 1 || !container) return;
|
|
2168
|
+
container.scrollTo({
|
|
2169
|
+
top: scrollTopOf(container) + delta,
|
|
2170
|
+
behavior: "instant"
|
|
2171
|
+
});
|
|
2172
|
+
};
|
|
2173
|
+
/** How far to scroll to show an item at `top` (client) with `height`. */
|
|
2174
|
+
const alignDelta = (top, height, align) => {
|
|
2175
|
+
const view = viewport();
|
|
2176
|
+
const head = o.table.value?.tHead?.getBoundingClientRect();
|
|
2177
|
+
const cover = head && head.top <= view.top + 1 && head.bottom > view.top ? head.bottom - view.top : 0;
|
|
2178
|
+
const viewTop = view.top + cover;
|
|
2179
|
+
const viewBottom = view.top + view.height;
|
|
2180
|
+
const bottom = top + height;
|
|
2181
|
+
switch (align) {
|
|
2182
|
+
case "start": return top - viewTop;
|
|
2183
|
+
case "end": return bottom - viewBottom;
|
|
2184
|
+
case "center": return (top + bottom - viewTop - viewBottom) / 2;
|
|
2185
|
+
default: return top < viewTop ? top - viewTop : bottom > viewBottom ? bottom - viewBottom : 0;
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
/** After a render: correct the drift (C-84) or a `scrollToIndex` (C-87). */
|
|
2189
|
+
const settle = () => {
|
|
2190
|
+
const tbody = body();
|
|
2191
|
+
if (!tbody) return;
|
|
2192
|
+
if (expected !== null && container) {
|
|
2193
|
+
scrollBy(expected - scrollTopOf(container));
|
|
2194
|
+
expected = null;
|
|
2195
|
+
}
|
|
2196
|
+
if (pending) {
|
|
2197
|
+
const tr = rowElement(tbody, pending.position);
|
|
2198
|
+
if (tr) {
|
|
2199
|
+
const { align } = pending;
|
|
2200
|
+
pending = null;
|
|
2201
|
+
scrollBy(alignDelta(tr.getBoundingClientRect().top, itemHeight(tr), align));
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
if (++pending.tries <= pendingFrames) {
|
|
2205
|
+
schedule();
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
pending = null;
|
|
2209
|
+
}
|
|
2210
|
+
if (anchor) {
|
|
2211
|
+
const tr = rowElement(tbody, anchor.position);
|
|
2212
|
+
if (tr) scrollBy(tr.getBoundingClientRect().top - anchor.top);
|
|
2213
|
+
anchor = null;
|
|
2214
|
+
}
|
|
2215
|
+
};
|
|
2216
|
+
const update = () => {
|
|
2217
|
+
frame = 0;
|
|
2218
|
+
const tbody = body();
|
|
2219
|
+
if (!tbody || !container || printing.value) return;
|
|
2220
|
+
measure(tbody);
|
|
2221
|
+
const view = viewport();
|
|
2222
|
+
const scrollTop = view.top - itemsTop(tbody);
|
|
2223
|
+
const next = computeWindow({
|
|
2224
|
+
offsets,
|
|
2225
|
+
scrollTop,
|
|
2226
|
+
viewportHeight: view.height,
|
|
2227
|
+
overscan: overscan()
|
|
2228
|
+
});
|
|
2229
|
+
ready.value = true;
|
|
2230
|
+
const current = range.value;
|
|
2231
|
+
if (next.start === current.start && next.end === current.end) {
|
|
2232
|
+
settle();
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
if (!pending && fixed() === void 0) {
|
|
2236
|
+
const position = Math.min(Math.max(indexAt(offsets, scrollTop), current.start), current.end - 1);
|
|
2237
|
+
const tr = position < 0 ? null : rowElement(tbody, position);
|
|
2238
|
+
anchor = tr ? {
|
|
2239
|
+
position,
|
|
2240
|
+
top: tr.getBoundingClientRect().top
|
|
2241
|
+
} : null;
|
|
2242
|
+
}
|
|
2243
|
+
expected = scrollTopOf(container);
|
|
2244
|
+
range.value = next;
|
|
2245
|
+
};
|
|
2246
|
+
const schedule = () => {
|
|
2247
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
2248
|
+
};
|
|
2249
|
+
const printing = shallowRef(false);
|
|
2250
|
+
const startPrint = () => {
|
|
2251
|
+
printing.value = true;
|
|
2252
|
+
};
|
|
2253
|
+
const endPrint = () => {
|
|
2254
|
+
printing.value = false;
|
|
2255
|
+
schedule();
|
|
2256
|
+
};
|
|
2257
|
+
const onPrintMedia = (event) => {
|
|
2258
|
+
if (event.matches) startPrint();
|
|
2259
|
+
else endPrint();
|
|
2260
|
+
};
|
|
2261
|
+
let printMedia = null;
|
|
2262
|
+
const kept = shallowRef(null);
|
|
2263
|
+
/** The row index of the item (data row or subtable row) holding `target`. */
|
|
2264
|
+
const itemOf = (target, tbody) => {
|
|
2265
|
+
let tr = target?.closest?.("tr") ?? null;
|
|
2266
|
+
while (tr && tr.parentElement !== tbody) tr = tr.parentElement?.closest("tr") ?? null;
|
|
2267
|
+
if (tr?.classList.contains("qt-subtable-row")) tr = tr.previousElementSibling;
|
|
2268
|
+
const at = tr?.getAttribute("data-row-index");
|
|
2269
|
+
return !tr || at === null || at === void 0 || tr.hasAttribute("data-pinned-row") ? -1 : positionOf(Number(at));
|
|
2270
|
+
};
|
|
2271
|
+
const onFocusIn = (event) => {
|
|
2272
|
+
if (!enabled()) return;
|
|
2273
|
+
const position = itemOf(event.target, event.currentTarget);
|
|
2274
|
+
if (position >= 0) kept.value = {
|
|
2275
|
+
row: center()[position].row,
|
|
2276
|
+
position
|
|
2277
|
+
};
|
|
2278
|
+
};
|
|
2279
|
+
const onFocusOut = (event) => {
|
|
2280
|
+
if (kept.value && itemOf(event.relatedTarget, event.currentTarget) !== kept.value.position) kept.value = null;
|
|
2281
|
+
};
|
|
2282
|
+
const keptPosition = () => {
|
|
2283
|
+
const focus = kept.value;
|
|
2284
|
+
if (!focus) return null;
|
|
2285
|
+
const rows = center();
|
|
2286
|
+
if (rows[focus.position]?.row === focus.row) return focus.position;
|
|
2287
|
+
const found = rows.findIndex((row) => row.row === focus.row);
|
|
2288
|
+
return found < 0 ? null : found;
|
|
2289
|
+
};
|
|
2290
|
+
/** Open subtable rows before each row of `bodyRows`, and in all (C-86). */
|
|
2291
|
+
const expandedBefore = computed(() => {
|
|
2292
|
+
const all = enabled() ? parts.value.all : [];
|
|
2293
|
+
const counts = new Int32Array(all.length + 1);
|
|
2294
|
+
for (let i = 0; i < all.length; i++) counts[i + 1] = counts[i] + (o.isExpanded(all[i].row, all[i].index) ? 1 : 0);
|
|
2295
|
+
return counts;
|
|
2296
|
+
});
|
|
2297
|
+
const drawn = computed(() => {
|
|
2298
|
+
const { all, top } = parts.value;
|
|
2299
|
+
if (!enabled()) return all;
|
|
2300
|
+
version.value;
|
|
2301
|
+
const rows = center();
|
|
2302
|
+
const before = expandedBefore.value;
|
|
2303
|
+
const at = (q) => ({
|
|
2304
|
+
...all[q],
|
|
2305
|
+
aria: q + before[q] + 2
|
|
2306
|
+
});
|
|
2307
|
+
const out = [];
|
|
2308
|
+
for (let q = 0; q < top; q++) out.push(at(q));
|
|
2309
|
+
if (printing.value) for (let p = 0; p < rows.length; p++) out.push(at(top + p));
|
|
2310
|
+
else {
|
|
2311
|
+
const end = Math.min(range.value.end, rows.length);
|
|
2312
|
+
const win = {
|
|
2313
|
+
start: Math.min(range.value.start, end),
|
|
2314
|
+
end
|
|
2315
|
+
};
|
|
2316
|
+
for (const segment of segmentsOf(offsets, win, keptPosition())) if ("spacer" in segment) out.push({
|
|
2317
|
+
spacer: segment.spacer,
|
|
2318
|
+
key: spacerKeys[segment.slot]
|
|
2319
|
+
});
|
|
2320
|
+
else for (let p = segment.from; p < segment.to; p++) out.push(at(top + p));
|
|
2321
|
+
}
|
|
2322
|
+
for (let q = top + rows.length; q < all.length; q++) out.push(at(q));
|
|
2323
|
+
return out;
|
|
2324
|
+
});
|
|
2325
|
+
let box = null;
|
|
2326
|
+
let rowsObserver = null;
|
|
2327
|
+
/**
|
|
2328
|
+
* Watches the table for coming into the layout: a table mounted inside
|
|
2329
|
+
* `display: none` has no scrolling ancestor yet, so the container is
|
|
2330
|
+
* looked for again once it has a size.
|
|
2331
|
+
*/
|
|
2332
|
+
let shown = null;
|
|
2333
|
+
let hadSize = false;
|
|
2334
|
+
let watchedTable = null;
|
|
2335
|
+
const watchShown = (table) => {
|
|
2336
|
+
if (table === watchedTable) return;
|
|
2337
|
+
shown?.disconnect();
|
|
2338
|
+
shown = null;
|
|
2339
|
+
watchedTable = table;
|
|
2340
|
+
if (!table || typeof ResizeObserver === "undefined") return;
|
|
2341
|
+
hadSize = table.getBoundingClientRect().height > 0;
|
|
2342
|
+
shown = new ResizeObserver(() => {
|
|
2343
|
+
const hasSize = table.getBoundingClientRect().height > 0;
|
|
2344
|
+
if (hasSize !== hadSize) {
|
|
2345
|
+
hadSize = hasSize;
|
|
2346
|
+
if (hasSize) attach();
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
shown.observe(table);
|
|
2350
|
+
};
|
|
2351
|
+
const observed = /* @__PURE__ */ new Set();
|
|
2352
|
+
let warned = false;
|
|
2353
|
+
const findContainer = (table) => {
|
|
2354
|
+
const given = settings.value?.scrollElement?.();
|
|
2355
|
+
if (given) return given;
|
|
2356
|
+
for (let element = table.parentElement; element && element !== document.body && element !== document.documentElement; element = element.parentElement) {
|
|
2357
|
+
const overflow = getComputedStyle(element).overflowY;
|
|
2358
|
+
if ((overflow === "auto" || overflow === "scroll") && element.scrollHeight > element.clientHeight) return element;
|
|
2359
|
+
}
|
|
2360
|
+
return window;
|
|
2361
|
+
};
|
|
2362
|
+
const detach = () => {
|
|
2363
|
+
container?.removeEventListener("scroll", schedule);
|
|
2364
|
+
container = null;
|
|
2365
|
+
box?.disconnect();
|
|
2366
|
+
box = null;
|
|
2367
|
+
removeEventListener("resize", schedule);
|
|
2368
|
+
};
|
|
2369
|
+
const attach = () => {
|
|
2370
|
+
const table = o.table.value;
|
|
2371
|
+
if (!table || !enabled()) {
|
|
2372
|
+
watchShown(null);
|
|
2373
|
+
detach();
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
watchShown(table);
|
|
2377
|
+
const next = findContainer(table);
|
|
2378
|
+
if (next !== container) {
|
|
2379
|
+
detach();
|
|
2380
|
+
container = next;
|
|
2381
|
+
next.addEventListener("scroll", schedule, { passive: true });
|
|
2382
|
+
addEventListener("resize", schedule);
|
|
2383
|
+
if (next !== window && typeof ResizeObserver !== "undefined") {
|
|
2384
|
+
box = new ResizeObserver(schedule);
|
|
2385
|
+
box.observe(next);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
if (!warned && isDevelopment() && getComputedStyle(table).tableLayout !== "fixed") {
|
|
2389
|
+
warned = true;
|
|
2390
|
+
console.warn("[QueryTable] `virtual` with `table-layout: auto`: column widths follow the drawn rows. Set `table-layout: fixed` (C-85).");
|
|
2391
|
+
}
|
|
2392
|
+
schedule();
|
|
2393
|
+
};
|
|
2394
|
+
/** Watches the drawn rows for size changes; measured on the next frame. */
|
|
2395
|
+
const observeRows = () => {
|
|
2396
|
+
const tbody = body();
|
|
2397
|
+
if (!tbody || !enabled() || fixed() !== void 0 || typeof ResizeObserver === "undefined") {
|
|
2398
|
+
rowsObserver?.disconnect();
|
|
2399
|
+
observed.clear();
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
rowsObserver ??= new ResizeObserver(schedule);
|
|
2403
|
+
for (const element of observed) if (element.parentElement !== tbody) {
|
|
2404
|
+
rowsObserver.unobserve(element);
|
|
2405
|
+
observed.delete(element);
|
|
2406
|
+
}
|
|
2407
|
+
for (const tr of tbody.children) if (!observed.has(tr) && !tr.classList.contains("qt-virtual-spacer")) {
|
|
2408
|
+
rowsObserver.observe(tr);
|
|
2409
|
+
observed.add(tr);
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
watch([
|
|
2413
|
+
() => parts.value.center,
|
|
2414
|
+
() => settings.value?.rowHeight,
|
|
2415
|
+
() => settings.value?.estimateRowHeight,
|
|
2416
|
+
enabled
|
|
2417
|
+
], rebuild, { immediate: true });
|
|
2418
|
+
watch([
|
|
2419
|
+
() => o.table.value,
|
|
2420
|
+
enabled,
|
|
2421
|
+
() => settings.value?.scrollElement,
|
|
2422
|
+
() => parts.value.center
|
|
2423
|
+
], attach, {
|
|
2424
|
+
flush: "post",
|
|
2425
|
+
immediate: true
|
|
2426
|
+
});
|
|
2427
|
+
watch(drawn, () => {
|
|
2428
|
+
observeRows();
|
|
2429
|
+
settle();
|
|
2430
|
+
}, { flush: "post" });
|
|
2431
|
+
watch(enabled, (on) => {
|
|
2432
|
+
printMedia?.removeEventListener("change", onPrintMedia);
|
|
2433
|
+
removeEventListener("beforeprint", startPrint);
|
|
2434
|
+
removeEventListener("afterprint", endPrint);
|
|
2435
|
+
printMedia = null;
|
|
2436
|
+
if (on && typeof window !== "undefined") {
|
|
2437
|
+
addEventListener("beforeprint", startPrint);
|
|
2438
|
+
addEventListener("afterprint", endPrint);
|
|
2439
|
+
printMedia = window.matchMedia?.("print") ?? null;
|
|
2440
|
+
printMedia?.addEventListener("change", onPrintMedia);
|
|
2441
|
+
}
|
|
2442
|
+
}, { immediate: true });
|
|
2443
|
+
onBeforeUnmount(() => {
|
|
2444
|
+
detach();
|
|
2445
|
+
watchShown(null);
|
|
2446
|
+
cancelAnimationFrame(frame);
|
|
2447
|
+
rowsObserver?.disconnect();
|
|
2448
|
+
printMedia?.removeEventListener("change", onPrintMedia);
|
|
2449
|
+
removeEventListener("beforeprint", startPrint);
|
|
2450
|
+
removeEventListener("afterprint", endPrint);
|
|
2451
|
+
});
|
|
2452
|
+
const scrollToIndex = (index, options = {}) => {
|
|
2453
|
+
const align = options.align ?? "auto";
|
|
2454
|
+
const tbody = body();
|
|
2455
|
+
if (!tbody || !Number.isInteger(index) || index < 0) return;
|
|
2456
|
+
const position = enabled() && container && !printing.value ? positionOf(index) : -1;
|
|
2457
|
+
if (position < 0) {
|
|
2458
|
+
tbody.querySelector(`:scope > tr[data-row-index="${index}"]`)?.scrollIntoView({
|
|
2459
|
+
block: align === "auto" ? "nearest" : align,
|
|
2460
|
+
behavior: "instant"
|
|
2461
|
+
});
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
anchor = null;
|
|
2465
|
+
pending = {
|
|
2466
|
+
position,
|
|
2467
|
+
align,
|
|
2468
|
+
tries: 0
|
|
2469
|
+
};
|
|
2470
|
+
scrollBy(alignDelta(itemsTop(tbody) + offsets[position], heights[position], align));
|
|
2471
|
+
schedule();
|
|
2472
|
+
};
|
|
2473
|
+
return {
|
|
2474
|
+
enabled,
|
|
2475
|
+
drawn,
|
|
2476
|
+
range,
|
|
2477
|
+
ready,
|
|
2478
|
+
centerCount: () => center().length,
|
|
2479
|
+
expandedCount: () => expandedBefore.value[expandedBefore.value.length - 1],
|
|
2480
|
+
scrollToIndex,
|
|
2481
|
+
onFocusIn,
|
|
2482
|
+
onFocusOut
|
|
2483
|
+
};
|
|
2484
|
+
};
|
|
2485
|
+
//#endregion
|
|
1362
2486
|
//#region src/query-table.vue?vue&type=script&setup=true&lang.ts
|
|
1363
2487
|
var _hoisted_1 = [
|
|
1364
2488
|
"data-empty",
|
|
@@ -1366,6 +2490,7 @@ var _hoisted_1 = [
|
|
|
1366
2490
|
"aria-busy"
|
|
1367
2491
|
];
|
|
1368
2492
|
var _hoisted_2 = { class: "qt-table-responsive" };
|
|
2493
|
+
var _hoisted_3 = ["aria-rowcount"];
|
|
1369
2494
|
//#endregion
|
|
1370
2495
|
//#region src/query-table.vue
|
|
1371
2496
|
var query_table_default = /* @__PURE__ */ defineComponent({
|
|
@@ -1375,6 +2500,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1375
2500
|
query: {},
|
|
1376
2501
|
cursors: { default: null },
|
|
1377
2502
|
selection: { default: void 0 },
|
|
2503
|
+
rowPinning: { default: void 0 },
|
|
1378
2504
|
searchDebounce: { default: 300 },
|
|
1379
2505
|
columns: {},
|
|
1380
2506
|
rows: { default: () => [] },
|
|
@@ -1396,6 +2522,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1396
2522
|
type: Boolean,
|
|
1397
2523
|
default: false
|
|
1398
2524
|
},
|
|
2525
|
+
reorderable: {
|
|
2526
|
+
type: Boolean,
|
|
2527
|
+
default: false
|
|
2528
|
+
},
|
|
1399
2529
|
filterDebounce: { default: 100 },
|
|
1400
2530
|
pagination: {},
|
|
1401
2531
|
hasSubtable: {
|
|
@@ -1410,14 +2540,24 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1410
2540
|
type: [String, Function],
|
|
1411
2541
|
default: void 0
|
|
1412
2542
|
},
|
|
1413
|
-
labels: { default: void 0 }
|
|
2543
|
+
labels: { default: void 0 },
|
|
2544
|
+
virtual: {
|
|
2545
|
+
type: [Boolean, Object],
|
|
2546
|
+
default: false
|
|
2547
|
+
},
|
|
2548
|
+
infinite: {
|
|
2549
|
+
type: [Boolean, Object],
|
|
2550
|
+
default: false
|
|
2551
|
+
}
|
|
1414
2552
|
},
|
|
1415
2553
|
emits: [
|
|
1416
2554
|
"update:query",
|
|
1417
2555
|
"update:selection",
|
|
1418
2556
|
"rowRightPanelClick",
|
|
1419
2557
|
"cellContextMenu",
|
|
1420
|
-
"columnResize"
|
|
2558
|
+
"columnResize",
|
|
2559
|
+
"update:columns",
|
|
2560
|
+
"update:rowPinning"
|
|
1421
2561
|
],
|
|
1422
2562
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1423
2563
|
const props = __props;
|
|
@@ -1434,11 +2574,14 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1434
2574
|
filterDebounce: () => props.filterDebounce,
|
|
1435
2575
|
searchDebounce: () => props.searchDebounce,
|
|
1436
2576
|
selection: () => props.selection,
|
|
2577
|
+
rowPinning: () => props.rowPinning,
|
|
1437
2578
|
rowKey: () => props.rowKey,
|
|
1438
2579
|
hasSubtable: () => props.hasSubtable,
|
|
1439
2580
|
pageSizeOptions: () => props.pagination?.pageSizeOptions,
|
|
1440
2581
|
onQueryChange: (query, reason) => emit("update:query", query, reason),
|
|
1441
|
-
onSelectionChange: (selection) => emit("update:selection", selection)
|
|
2582
|
+
onSelectionChange: (selection) => emit("update:selection", selection),
|
|
2583
|
+
onColumnsChange: (columns, reason) => emit("update:columns", columns, reason),
|
|
2584
|
+
onRowPinningChange: (rowPinning) => emit("update:rowPinning", rowPinning)
|
|
1442
2585
|
});
|
|
1443
2586
|
const { filters, sort, search, expansion } = state;
|
|
1444
2587
|
const rowSelection = state.selection;
|
|
@@ -1460,27 +2603,81 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1460
2603
|
].filter((name) => name !== null));
|
|
1461
2604
|
const utilityCount = computed(() => utilities.value.length);
|
|
1462
2605
|
const columnCount = computed(() => entries.value.length + utilityCount.value);
|
|
2606
|
+
/** Utilities are pinned only with a left-pinned column (C-46, C-71). */
|
|
2607
|
+
const utilitySide = () => hasPinned.value ? "left" : false;
|
|
1463
2608
|
const tableEl = shallowRef(null);
|
|
1464
2609
|
const { widths, tableWidth, offsets } = useHeaderGeometry({
|
|
1465
2610
|
table: tableEl,
|
|
1466
2611
|
cells: () => [...utilities.value.map((utility) => ({
|
|
1467
2612
|
key: utilityKey(utility),
|
|
1468
|
-
|
|
2613
|
+
side: utilitySide()
|
|
1469
2614
|
})), ...entries.value.map(({ column }) => ({
|
|
1470
2615
|
key: column.field,
|
|
1471
|
-
|
|
2616
|
+
side: sideOf(column)
|
|
1472
2617
|
}))],
|
|
1473
|
-
active: () =>
|
|
2618
|
+
active: () => entries.value.some((entry) => sideOf(entry.column) !== false) || props.resizable && entries.value.some((entry) => entry.column.resizable !== false)
|
|
2619
|
+
});
|
|
2620
|
+
const resize = useColumnResize({
|
|
2621
|
+
resizable: () => props.resizable,
|
|
2622
|
+
measuredWidth: (field) => widths.value[field],
|
|
2623
|
+
tableWidth: () => tableWidth.value,
|
|
2624
|
+
emit: (payload) => {
|
|
2625
|
+
emit("columnResize", payload);
|
|
2626
|
+
const next = applyWidth(props.columns, payload.field, `${payload.width}px`);
|
|
2627
|
+
if (next) emit("update:columns", next, "resize");
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
const rowWindow = useRowWindow({
|
|
2631
|
+
virtual: () => props.virtual,
|
|
2632
|
+
table: tableEl,
|
|
2633
|
+
bodyRows: () => state.rowPinning.rows.value,
|
|
2634
|
+
keyOf: expansion.keyOf,
|
|
2635
|
+
isExpanded: expansion.isExpanded
|
|
2636
|
+
});
|
|
2637
|
+
const infinite = useLoadMore({
|
|
2638
|
+
infinite: () => props.infinite,
|
|
2639
|
+
rowKey: () => props.rowKey,
|
|
2640
|
+
rows: () => props.rows,
|
|
2641
|
+
query: () => props.query,
|
|
2642
|
+
totalRows: () => props.totalRows,
|
|
2643
|
+
cursors: () => props.cursors,
|
|
2644
|
+
loading: () => props.loading,
|
|
2645
|
+
nextPage: () => paginationProps.value.nextPage(),
|
|
2646
|
+
table: tableEl,
|
|
2647
|
+
virtual: rowWindow.enabled,
|
|
2648
|
+
window: () => rowWindow.ready.value ? {
|
|
2649
|
+
end: rowWindow.range.value.end,
|
|
2650
|
+
count: rowWindow.centerCount()
|
|
2651
|
+
} : null
|
|
2652
|
+
});
|
|
2653
|
+
const loadMoreProps = computed(() => infinite.enabled.value ? {
|
|
2654
|
+
loadMore: infinite.loadMore,
|
|
2655
|
+
canLoadMore: infinite.canLoadMore.value,
|
|
2656
|
+
loading: props.loading
|
|
2657
|
+
} : null);
|
|
2658
|
+
const footerCount = computed(() => props.footerRows.length);
|
|
2659
|
+
/** More to load in an infinite list: the count is not the rows given (C-86). */
|
|
2660
|
+
const growing = () => infinite.enabled.value && infinite.canLoadMore.value;
|
|
2661
|
+
const ariaRowCount = computed(() => {
|
|
2662
|
+
if (!rowWindow.enabled()) return;
|
|
2663
|
+
const total = props.totalRows;
|
|
2664
|
+
if (growing() && total === null) return -1;
|
|
2665
|
+
return 1 + (growing() && total !== null ? total : props.rows.length) + rowWindow.expandedCount() + footerCount.value;
|
|
2666
|
+
});
|
|
2667
|
+
/** `aria-rowindex` of the first footer row, or `undefined` (C-86). */
|
|
2668
|
+
const footerRowIndex = computed(() => !rowWindow.enabled() || growing() ? void 0 : 2 + props.rows.length + rowWindow.expandedCount());
|
|
2669
|
+
const reorder = useColumnReorder({
|
|
2670
|
+
reorderable: () => props.reorderable,
|
|
2671
|
+
table: tableEl,
|
|
2672
|
+
layout: state.layout,
|
|
2673
|
+
columns: () => props.columns
|
|
1474
2674
|
});
|
|
1475
2675
|
provideTableContext({
|
|
1476
2676
|
filters,
|
|
1477
2677
|
sort,
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
tableWidth: () => tableWidth.value,
|
|
1482
|
-
emit: (payload) => emit("columnResize", payload)
|
|
1483
|
-
}),
|
|
2678
|
+
layout: state.layout,
|
|
2679
|
+
resize,
|
|
2680
|
+
reorder,
|
|
1484
2681
|
selection: rowSelection,
|
|
1485
2682
|
labels: () => labels.value
|
|
1486
2683
|
});
|
|
@@ -1497,7 +2694,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1497
2694
|
search.apply();
|
|
1498
2695
|
}
|
|
1499
2696
|
});
|
|
1500
|
-
const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading");
|
|
2697
|
+
const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading" || name === "load-more");
|
|
1501
2698
|
const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join(" ");
|
|
1502
2699
|
__expose({
|
|
1503
2700
|
collapseAll: expansion.collapseAll,
|
|
@@ -1505,7 +2702,9 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1505
2702
|
focusFilter: (field) => focusFilterOf(tableEl.value, field),
|
|
1506
2703
|
flushPendingFilters: () => {
|
|
1507
2704
|
filters.flushAll();
|
|
1508
|
-
}
|
|
2705
|
+
},
|
|
2706
|
+
scrollToIndex: rowWindow.scrollToIndex,
|
|
2707
|
+
loadMore: infinite.loadMore
|
|
1509
2708
|
});
|
|
1510
2709
|
return (_ctx, _cache) => {
|
|
1511
2710
|
return openBlock(), createElementBlock("div", {
|
|
@@ -1518,7 +2717,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1518
2717
|
createElementVNode("div", _hoisted_2, [createElementVNode("table", {
|
|
1519
2718
|
ref_key: "tableEl",
|
|
1520
2719
|
ref: tableEl,
|
|
1521
|
-
class: "qt-table"
|
|
2720
|
+
class: "qt-table",
|
|
2721
|
+
"aria-rowcount": ariaRowCount.value
|
|
1522
2722
|
}, [
|
|
1523
2723
|
createElementVNode("thead", null, [createVNode(table_header_default, {
|
|
1524
2724
|
columns: visibleColumns.value,
|
|
@@ -1527,7 +2727,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1527
2727
|
utilities: utilities.value,
|
|
1528
2728
|
"has-pinned": unref(hasPinned),
|
|
1529
2729
|
offsets: unref(offsets),
|
|
1530
|
-
"slot-names": headerSlotNames()
|
|
2730
|
+
"slot-names": headerSlotNames(),
|
|
2731
|
+
"aria-rowindex": unref(rowWindow).enabled() ? 1 : void 0
|
|
1531
2732
|
}, {
|
|
1532
2733
|
header: withCtx((p) => [renderSlot(_ctx.$slots, `header-${p.column.field}`, normalizeProps(guardReactiveProps(p)))]),
|
|
1533
2734
|
"filter-datetime": withCtx((p) => [renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(p)))]),
|
|
@@ -1540,10 +2741,13 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1540
2741
|
"utilities",
|
|
1541
2742
|
"has-pinned",
|
|
1542
2743
|
"offsets",
|
|
1543
|
-
"slot-names"
|
|
2744
|
+
"slot-names",
|
|
2745
|
+
"aria-rowindex"
|
|
1544
2746
|
])]),
|
|
1545
2747
|
createVNode(table_body_default, {
|
|
1546
2748
|
rows: __props.rows,
|
|
2749
|
+
"body-rows": unref(rowWindow).drawn.value,
|
|
2750
|
+
"pin-row": unref(state).rowPinning.pin,
|
|
1547
2751
|
loading: __props.loading,
|
|
1548
2752
|
entries: unref(entries),
|
|
1549
2753
|
"column-count": columnCount.value,
|
|
@@ -1559,8 +2763,11 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1559
2763
|
toggle: unref(expansion).toggle,
|
|
1560
2764
|
labels: labels.value,
|
|
1561
2765
|
"has-context-menu-listener": hasContextMenuListener,
|
|
2766
|
+
"load-more": loadMoreProps.value,
|
|
1562
2767
|
onRowRightPanelClick: _cache[0] || (_cache[0] = (row) => emit("rowRightPanelClick", row)),
|
|
1563
|
-
onCellContextMenu: _cache[1] || (_cache[1] = (payload) => emit("cellContextMenu", payload))
|
|
2768
|
+
onCellContextMenu: _cache[1] || (_cache[1] = (payload) => emit("cellContextMenu", payload)),
|
|
2769
|
+
onFocusin: unref(rowWindow).onFocusIn,
|
|
2770
|
+
onFocusout: unref(rowWindow).onFocusOut
|
|
1564
2771
|
}, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
|
|
1565
2772
|
return {
|
|
1566
2773
|
name,
|
|
@@ -1568,6 +2775,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1568
2775
|
};
|
|
1569
2776
|
})]), 1032, [
|
|
1570
2777
|
"rows",
|
|
2778
|
+
"body-rows",
|
|
2779
|
+
"pin-row",
|
|
1571
2780
|
"loading",
|
|
1572
2781
|
"entries",
|
|
1573
2782
|
"column-count",
|
|
@@ -1581,7 +2790,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1581
2790
|
"key-of",
|
|
1582
2791
|
"is-expanded",
|
|
1583
2792
|
"toggle",
|
|
1584
|
-
"labels"
|
|
2793
|
+
"labels",
|
|
2794
|
+
"load-more",
|
|
2795
|
+
"onFocusin",
|
|
2796
|
+
"onFocusout"
|
|
1585
2797
|
]),
|
|
1586
2798
|
__props.footerRows.length > 0 ? (openBlock(), createBlock(table_footer_default, {
|
|
1587
2799
|
key: 0,
|
|
@@ -1589,15 +2801,17 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
1589
2801
|
entries: unref(entries),
|
|
1590
2802
|
"utility-count": utilityCount.value,
|
|
1591
2803
|
"has-pinned": unref(hasPinned),
|
|
1592
|
-
offsets: unref(offsets)
|
|
2804
|
+
offsets: unref(offsets),
|
|
2805
|
+
"first-row-index": footerRowIndex.value
|
|
1593
2806
|
}, null, 8, [
|
|
1594
2807
|
"footer-rows",
|
|
1595
2808
|
"entries",
|
|
1596
2809
|
"utility-count",
|
|
1597
2810
|
"has-pinned",
|
|
1598
|
-
"offsets"
|
|
2811
|
+
"offsets",
|
|
2812
|
+
"first-row-index"
|
|
1599
2813
|
])) : createCommentVNode("", true)
|
|
1600
|
-
],
|
|
2814
|
+
], 8, _hoisted_3)]),
|
|
1601
2815
|
showPagination.value ? (openBlock(), createBlock(table_pagination_default, {
|
|
1602
2816
|
key: 0,
|
|
1603
2817
|
"pagination-props": unref(paginationProps)
|