@dolusoft/query-table 3.11.1 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/query-table.js +319 -54
- package/dist/query-table.js.map +1 -1
- package/dist/types/body/use-row-navigation.d.ts +35 -0
- package/dist/types/contract.d.ts +78 -3
- package/dist/types/core/labels.d.ts +3 -1
- package/dist/types/core/table-context.d.ts +2 -2
- package/dist/types/filter/use-filter-trigger.d.ts +3 -2
- package/dist/types/query-table.vue.d.ts +2 -1
- package/dist/types/use-query-table.d.ts +6 -3
- package/dist/types/virtual/use-row-window.d.ts +3 -0
- package/package.json +3 -3
package/dist/query-table.js
CHANGED
|
@@ -1,8 +1,176 @@
|
|
|
1
1
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineComponent, effectScope, getCurrentInstance, getCurrentScope, guardReactiveProps, h, inject, mergeProps, nextTick, normalizeProps, normalizeStyle, onActivated, onBeforeUnmount, onBeforeUpdate, onDeactivated, onMounted, onScopeDispose, openBlock, provide, renderList, renderSlot, shallowRef, toDisplayString, toHandlers, toValue, unref, useSlots, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
|
|
2
|
-
import { cloneQuery, columnTypeOf, columnTypeOf as columnTypeOf$1, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, sameQuery, searchOf } from "@dolusoft/query-protocol";
|
|
2
|
+
import { cloneQuery, columnTypeOf, columnTypeOf as columnTypeOf$1, conditionArity, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, sameQuery, searchOf } from "@dolusoft/query-protocol";
|
|
3
3
|
import { createRowChangeTracker } from "@dolusoft/query-table-core/row-changes";
|
|
4
4
|
import { dispose, filterInputFeature, projectServerQuery, serverQueryFeature } from "@dolusoft/query-table-core";
|
|
5
5
|
import { columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, functionalUpdate, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, useTable } from "@tanstack/vue-table";
|
|
6
|
+
//#region src/body/use-row-navigation.ts
|
|
7
|
+
/**
|
|
8
|
+
* The first focusable element of a row, when no `focus` selector is given.
|
|
9
|
+
* Controls that use the arrow keys themselves (text fields, `select`, radio
|
|
10
|
+
* buttons, editable content) are left out: they keep their keys (C-109).
|
|
11
|
+
*/
|
|
12
|
+
var focusable$1 = [
|
|
13
|
+
"a[href]",
|
|
14
|
+
"button:not([disabled])",
|
|
15
|
+
"input[type=\"checkbox\"]:not([disabled])",
|
|
16
|
+
"[tabindex]:not([tabindex=\"-1\"]):not(input, select, textarea, [contenteditable])"
|
|
17
|
+
].join(", ");
|
|
18
|
+
var keys = /* @__PURE__ */ new Set([
|
|
19
|
+
"ArrowUp",
|
|
20
|
+
"ArrowDown",
|
|
21
|
+
"Home",
|
|
22
|
+
"End"
|
|
23
|
+
]);
|
|
24
|
+
/** Frames a move waits for its row to be drawn and to keep the focus. */
|
|
25
|
+
var maxFrames = 30;
|
|
26
|
+
/** Frames the focus must stay on the target before a move is done. */
|
|
27
|
+
var keepFrames = 2;
|
|
28
|
+
/**
|
|
29
|
+
* Keyboard navigation between the data rows (C-109 to C-111): one `keydown`
|
|
30
|
+
* listener on the `tbody`, only while `rowNavigation` is on. A move goes by
|
|
31
|
+
* the row's key, not its index: the rows may change while a virtual body
|
|
32
|
+
* draws the row (C-110), and the focus is put back when moving DOM nodes
|
|
33
|
+
* drops it.
|
|
34
|
+
*/
|
|
35
|
+
var useRowNavigation = (o) => {
|
|
36
|
+
const settings = computed(() => {
|
|
37
|
+
const value = o.rowNavigation();
|
|
38
|
+
return value === true ? {} : value || null;
|
|
39
|
+
});
|
|
40
|
+
const enabled = () => settings.value !== null;
|
|
41
|
+
const body = () => o.table.value?.tBodies[0] ?? null;
|
|
42
|
+
/** The focus target of a drawn row, or `null`. */
|
|
43
|
+
const targetOf = (tr) => tr.querySelector(settings.value?.focus ?? focusable$1);
|
|
44
|
+
/** The data row of the body that holds `element`, or `null`. */
|
|
45
|
+
const rowOf = (element, tbody) => {
|
|
46
|
+
let tr = element?.closest?.("tr") ?? null;
|
|
47
|
+
while (tr && tr.parentElement !== tbody) tr = tr.parentElement?.closest("tr") ?? null;
|
|
48
|
+
return tr?.hasAttribute("data-row-index") ? tr : null;
|
|
49
|
+
};
|
|
50
|
+
/** Position in drawing order of the move's row, or -1. */
|
|
51
|
+
const positionOf = (rows, m) => o.hasRowKey() ? rows.findIndex((item) => o.keyOf(item.row, item.index) === m.key) : rows.findIndex((item) => item.row === m.row);
|
|
52
|
+
/** The next stop from `from` for `key`: a row `skip` does not name. */
|
|
53
|
+
const stopFrom = (rows, from, key) => {
|
|
54
|
+
const skip = settings.value?.skip;
|
|
55
|
+
const stop = (p) => !skip || !skip(rows[p].row, rows[p].index);
|
|
56
|
+
const step = key === "ArrowUp" || key === "End" ? -1 : 1;
|
|
57
|
+
let p = key === "Home" ? 0 : key === "End" ? rows.length - 1 : from + step;
|
|
58
|
+
while (p >= 0 && p < rows.length && !stop(p)) p += step;
|
|
59
|
+
return p >= 0 && p < rows.length ? p : -1;
|
|
60
|
+
};
|
|
61
|
+
let move = null;
|
|
62
|
+
let frame = 0;
|
|
63
|
+
const stop = () => {
|
|
64
|
+
move = null;
|
|
65
|
+
cancelAnimationFrame(frame);
|
|
66
|
+
frame = 0;
|
|
67
|
+
removeEventListener("pointerdown", stop, true);
|
|
68
|
+
};
|
|
69
|
+
const again = () => {
|
|
70
|
+
if (!frame) frame = requestAnimationFrame(tick);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The focus is where the move left it, or nowhere: a click or a script
|
|
74
|
+
* that moved it elsewhere ends the move.
|
|
75
|
+
*/
|
|
76
|
+
const free = (m) => {
|
|
77
|
+
const active = document.activeElement;
|
|
78
|
+
return !active || active === document.body || active === m.origin || active === m.landed || !active.isConnected;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Puts the focus on the move's row; `true` when it has it. A row of a
|
|
82
|
+
* virtual body that is not drawn is scrolled to (C-110): again when the
|
|
83
|
+
* window dropped the scroll because `rows` changed (C-87), and right away
|
|
84
|
+
* with `scroll`.
|
|
85
|
+
*/
|
|
86
|
+
const land = (m, scroll = false) => {
|
|
87
|
+
const tbody = body();
|
|
88
|
+
const rows = o.bodyRows();
|
|
89
|
+
const p = positionOf(rows, m);
|
|
90
|
+
if (!tbody || p < 0) {
|
|
91
|
+
stop();
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const { index, pinned } = rows[p];
|
|
95
|
+
const tr = tbody.querySelector(`:scope > tr[data-row-index="${index}"]`);
|
|
96
|
+
if (!tr) {
|
|
97
|
+
if (o.virtual() && !pinned && (scroll || !o.busy())) o.scrollToIndex(index, { align: "auto" });
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const target = targetOf(tr);
|
|
101
|
+
if (!target) {
|
|
102
|
+
stop();
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
target.focus({ preventScroll: true });
|
|
106
|
+
if (document.activeElement !== target) return false;
|
|
107
|
+
const first = m.landed === null;
|
|
108
|
+
m.landed = target;
|
|
109
|
+
if (first) {
|
|
110
|
+
o.reveal(index);
|
|
111
|
+
o.onFocus({
|
|
112
|
+
row: rows[p].row,
|
|
113
|
+
rowIndex: index,
|
|
114
|
+
key: m.pressed
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
function tick() {
|
|
120
|
+
frame = 0;
|
|
121
|
+
const m = move;
|
|
122
|
+
if (!m) return;
|
|
123
|
+
if (++m.frames > maxFrames || !free(m)) {
|
|
124
|
+
stop();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (m.landed && document.activeElement === m.landed) {
|
|
128
|
+
if (!o.busy() && ++m.kept >= keepFrames) {
|
|
129
|
+
stop();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
again();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!o.busy()) land(m);
|
|
136
|
+
if (move) again();
|
|
137
|
+
}
|
|
138
|
+
const onKeyDown = (event) => {
|
|
139
|
+
if (!enabled() || !keys.has(event.key) || event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
140
|
+
const tbody = event.currentTarget;
|
|
141
|
+
const target = event.target;
|
|
142
|
+
const waiting = move && !move.landed && target === move.origin ? move : null;
|
|
143
|
+
const tr = rowOf(target, tbody);
|
|
144
|
+
if (!waiting && (!tr || targetOf(tr) !== target)) return;
|
|
145
|
+
const rows = o.bodyRows();
|
|
146
|
+
const from = waiting ? positionOf(rows, waiting) : rows.findIndex((item) => item.index === Number(tr.getAttribute("data-row-index")));
|
|
147
|
+
if (from < 0) return;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
const to = stopFrom(rows, from, event.key);
|
|
150
|
+
if (to < 0 || to === from) return;
|
|
151
|
+
stop();
|
|
152
|
+
const { row, index } = rows[to];
|
|
153
|
+
const m = {
|
|
154
|
+
key: o.keyOf(row, index),
|
|
155
|
+
row,
|
|
156
|
+
pressed: event.key,
|
|
157
|
+
origin: waiting ? waiting.origin : target,
|
|
158
|
+
landed: null,
|
|
159
|
+
frames: 0,
|
|
160
|
+
kept: 0
|
|
161
|
+
};
|
|
162
|
+
move = m;
|
|
163
|
+
addEventListener("pointerdown", stop, true);
|
|
164
|
+
land(m, true);
|
|
165
|
+
if (move) again();
|
|
166
|
+
};
|
|
167
|
+
onBeforeUnmount(stop);
|
|
168
|
+
return {
|
|
169
|
+
enabled,
|
|
170
|
+
onKeyDown
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
6
174
|
//#region src/columns/column-layout.ts
|
|
7
175
|
var sideOf = (column) => column.pinned === "left" ? "left" : column.pinned === "right" ? "right" : false;
|
|
8
176
|
/** A copy of `column` without `key`: a default is removed, never set (C-68). */
|
|
@@ -87,6 +255,8 @@ var defaultLabels = {
|
|
|
87
255
|
expandRow: "Expand row",
|
|
88
256
|
openRightPanel: "Open right panel",
|
|
89
257
|
filterInput: (column) => `Filter ${column}`,
|
|
258
|
+
filterInputFrom: (column) => `Filter ${column} from`,
|
|
259
|
+
filterInputTo: (column) => `Filter ${column} to`,
|
|
90
260
|
filterOptions: (column) => `Filter options for ${column}`,
|
|
91
261
|
resizeColumn: (column) => `Resize ${column}`,
|
|
92
262
|
moveColumn: (column) => `Move ${column}`,
|
|
@@ -1270,29 +1440,39 @@ var useFilterTrigger = (options) => defineComponent({
|
|
|
1270
1440
|
//#endregion
|
|
1271
1441
|
//#region src/parts/filter-cell.vue?vue&type=script&setup=true&lang.ts
|
|
1272
1442
|
var _hoisted_1$6 = { class: "qt-filter" };
|
|
1273
|
-
var _hoisted_2$3 = [
|
|
1274
|
-
var _hoisted_3$3 = [
|
|
1443
|
+
var _hoisted_2$3 = [
|
|
1275
1444
|
"type",
|
|
1445
|
+
"aria-label",
|
|
1446
|
+
"value",
|
|
1447
|
+
"onInput"
|
|
1448
|
+
];
|
|
1449
|
+
var _hoisted_3$3 = [
|
|
1276
1450
|
"aria-label",
|
|
1277
1451
|
"value",
|
|
1278
1452
|
"readonly"
|
|
1279
1453
|
];
|
|
1280
1454
|
var _hoisted_4$3 = [
|
|
1455
|
+
"type",
|
|
1456
|
+
"aria-label",
|
|
1457
|
+
"value",
|
|
1458
|
+
"readonly"
|
|
1459
|
+
];
|
|
1460
|
+
var _hoisted_5$1 = [
|
|
1281
1461
|
"aria-label",
|
|
1282
1462
|
"value",
|
|
1283
1463
|
"disabled"
|
|
1284
1464
|
];
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1288
|
-
var
|
|
1465
|
+
var _hoisted_6$1 = { value: "" };
|
|
1466
|
+
var _hoisted_7$1 = { value: "true" };
|
|
1467
|
+
var _hoisted_8$1 = { value: "false" };
|
|
1468
|
+
var _hoisted_9 = [
|
|
1289
1469
|
"type",
|
|
1290
1470
|
"aria-label",
|
|
1291
1471
|
"value",
|
|
1292
1472
|
"readonly"
|
|
1293
1473
|
];
|
|
1294
|
-
var
|
|
1295
|
-
key:
|
|
1474
|
+
var _hoisted_10 = {
|
|
1475
|
+
key: 7,
|
|
1296
1476
|
class: "qt-filter-condition"
|
|
1297
1477
|
};
|
|
1298
1478
|
//#endregion
|
|
@@ -1324,6 +1504,31 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1324
1504
|
const count = filters.multiOf(props.column.field);
|
|
1325
1505
|
return count > 0 ? `(${count})` : filters.draftOf(props.column.field).text;
|
|
1326
1506
|
};
|
|
1507
|
+
const draft = () => filters.draftOf(props.column.field);
|
|
1508
|
+
const isMulti = () => filters.multiOf(props.column.field) > 0;
|
|
1509
|
+
const ordered = [
|
|
1510
|
+
"number",
|
|
1511
|
+
"integer",
|
|
1512
|
+
"date",
|
|
1513
|
+
"datetime"
|
|
1514
|
+
];
|
|
1515
|
+
const isDated = () => props.type === "date" || props.type === "datetime";
|
|
1516
|
+
const hidesInput = () => {
|
|
1517
|
+
const { condition } = draft();
|
|
1518
|
+
return !isMulti() && props.type !== "bool" && condition !== null && conditionArity(condition) === 0;
|
|
1519
|
+
};
|
|
1520
|
+
const isRange = () => !isMulti() && draft().condition === "Between" && ordered.includes(props.type);
|
|
1521
|
+
const bounds = ["lower", "upper"];
|
|
1522
|
+
const boundText = (bound) => bound === "upper" ? draft().text2 ?? "" : draft().text;
|
|
1523
|
+
const boundName = (bound) => {
|
|
1524
|
+
const name = columnName(props.column);
|
|
1525
|
+
return bound === "upper" ? labels().filterInputTo(name) : labels().filterInputFrom(name);
|
|
1526
|
+
};
|
|
1527
|
+
const takes = (condition) => condition === "Between" ? ordered.includes(props.type) : conditionArity(condition) === 0 || conditionOptions[props.type].some((option) => option.value === condition);
|
|
1528
|
+
const offered = () => {
|
|
1529
|
+
const own = props.column.filterConditions;
|
|
1530
|
+
return own ? [...new Set(own)].filter(takes) : conditionOptions[props.type].map(({ value }) => value);
|
|
1531
|
+
};
|
|
1327
1532
|
const currentCondition = () => rulesOf(props.query.filters, props.column.field)[0]?.condition ?? filters.draftOf(props.column.field).condition;
|
|
1328
1533
|
const menuProps = () => {
|
|
1329
1534
|
const { column } = props;
|
|
@@ -1331,7 +1536,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1331
1536
|
column,
|
|
1332
1537
|
rules: rulesOf(props.query.filters, column.field),
|
|
1333
1538
|
condition: currentCondition(),
|
|
1334
|
-
conditions:
|
|
1539
|
+
conditions: offered().map((value) => ({
|
|
1335
1540
|
value,
|
|
1336
1541
|
label: labels().filterCondition(value, props.type)
|
|
1337
1542
|
})),
|
|
@@ -1344,10 +1549,11 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1344
1549
|
control: layout.controlOf(column.field)
|
|
1345
1550
|
};
|
|
1346
1551
|
};
|
|
1347
|
-
const datetimeProps = () => ({
|
|
1552
|
+
const datetimeProps = (bound = null) => ({
|
|
1348
1553
|
column: props.column,
|
|
1349
|
-
value:
|
|
1350
|
-
updateValue: (value) => filters.setInput(props.column.field, value)
|
|
1554
|
+
value: bound ? boundText(bound) : draft().text,
|
|
1555
|
+
updateValue: (value) => filters.setInput(props.column.field, value, bound ?? void 0),
|
|
1556
|
+
bound
|
|
1351
1557
|
});
|
|
1352
1558
|
const inputValue = (event) => event.target.value;
|
|
1353
1559
|
const pick = (event) => {
|
|
@@ -1356,46 +1562,57 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1356
1562
|
};
|
|
1357
1563
|
return (_ctx, _cache) => {
|
|
1358
1564
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
1359
|
-
|
|
1360
|
-
key: 0,
|
|
1565
|
+
isRange() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList(bounds, (bound) => {
|
|
1566
|
+
return openBlock(), createElementBlock(Fragment, { key: bound }, [isDated() && _ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", mergeProps({ ref_for: true }, datetimeProps(bound)), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
|
|
1567
|
+
key: 1,
|
|
1568
|
+
type: isDated() ? "date" : "number",
|
|
1569
|
+
class: "qt-filter-input",
|
|
1570
|
+
"aria-label": boundName(bound),
|
|
1571
|
+
value: boundText(bound),
|
|
1572
|
+
onInput: ($event) => unref(filters).setInput(__props.column.field, inputValue($event), bound),
|
|
1573
|
+
onKeydown: _cache[0] || (_cache[0] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1574
|
+
}, null, 40, _hoisted_2$3))], 64);
|
|
1575
|
+
}), 64)) : hidesInput() ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [], 64)) : __props.type === "string" ? (openBlock(), createElementBlock("input", {
|
|
1576
|
+
key: 2,
|
|
1361
1577
|
type: "text",
|
|
1362
1578
|
class: "qt-filter-input",
|
|
1363
1579
|
"aria-label": inputName(),
|
|
1364
|
-
value:
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1580
|
+
value: inputText(),
|
|
1581
|
+
readonly: isMulti(),
|
|
1582
|
+
onInput: _cache[1] || (_cache[1] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1583
|
+
onKeydown: _cache[2] || (_cache[2] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1584
|
+
}, null, 40, _hoisted_3$3)) : __props.type === "number" || __props.type === "integer" ? (openBlock(), createElementBlock("input", {
|
|
1585
|
+
key: 3,
|
|
1369
1586
|
type: unref(filters).multiOf(__props.column.field) ? "text" : "number",
|
|
1370
1587
|
class: "qt-filter-input",
|
|
1371
1588
|
"aria-label": inputName(),
|
|
1372
1589
|
value: inputText(),
|
|
1373
1590
|
readonly: unref(filters).multiOf(__props.column.field) > 0,
|
|
1374
|
-
onInput: _cache[
|
|
1375
|
-
onKeydown: _cache[
|
|
1376
|
-
}, null, 40,
|
|
1377
|
-
key:
|
|
1591
|
+
onInput: _cache[3] || (_cache[3] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1592
|
+
onKeydown: _cache[4] || (_cache[4] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1593
|
+
}, null, 40, _hoisted_4$3)) : __props.type === "bool" ? (openBlock(), createElementBlock("select", {
|
|
1594
|
+
key: 4,
|
|
1378
1595
|
class: "qt-filter-input",
|
|
1379
1596
|
"aria-label": inputName(),
|
|
1380
1597
|
value: unref(filters).draftOf(__props.column.field).text,
|
|
1381
1598
|
disabled: unref(filters).multiOf(__props.column.field) > 0,
|
|
1382
|
-
onChange: _cache[
|
|
1599
|
+
onChange: _cache[5] || (_cache[5] = ($event) => pick($event))
|
|
1383
1600
|
}, [
|
|
1384
|
-
createElementVNode("option",
|
|
1385
|
-
createElementVNode("option",
|
|
1386
|
-
createElementVNode("option",
|
|
1387
|
-
], 40,
|
|
1601
|
+
createElementVNode("option", _hoisted_6$1, toDisplayString(unref(labels)().boolAll), 1),
|
|
1602
|
+
createElementVNode("option", _hoisted_7$1, toDisplayString(unref(labels)().boolTrue), 1),
|
|
1603
|
+
createElementVNode("option", _hoisted_8$1, toDisplayString(unref(labels)().boolFalse), 1)
|
|
1604
|
+
], 40, _hoisted_5$1)) : (openBlock(), createElementBlock(Fragment, { key: 5 }, [_ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(datetimeProps())), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
|
|
1388
1605
|
key: 1,
|
|
1389
1606
|
type: unref(filters).multiOf(__props.column.field) ? "text" : "date",
|
|
1390
1607
|
class: "qt-filter-input",
|
|
1391
1608
|
"aria-label": inputName(),
|
|
1392
1609
|
value: inputText(),
|
|
1393
1610
|
readonly: unref(filters).multiOf(__props.column.field) > 0,
|
|
1394
|
-
onInput: _cache[
|
|
1395
|
-
onKeydown: _cache[
|
|
1396
|
-
}, null, 40,
|
|
1397
|
-
__props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0,
|
|
1398
|
-
labelOf() ? (openBlock(), createElementBlock("small",
|
|
1611
|
+
onInput: _cache[6] || (_cache[6] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1612
|
+
onKeydown: _cache[7] || (_cache[7] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1613
|
+
}, null, 40, _hoisted_9))], 64)),
|
|
1614
|
+
__props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0, 6) : createCommentVNode("", true),
|
|
1615
|
+
labelOf() ? (openBlock(), createElementBlock("small", _hoisted_10, toDisplayString(labelOf()), 1)) : createCommentVNode("", true)
|
|
1399
1616
|
]);
|
|
1400
1617
|
};
|
|
1401
1618
|
}
|
|
@@ -2862,7 +3079,7 @@ function useQueryTable(options) {
|
|
|
2862
3079
|
const draftOf = (field) => columnById(field)?.getFilterInput() ?? blank;
|
|
2863
3080
|
const filters = {
|
|
2864
3081
|
draftOf,
|
|
2865
|
-
setInput: (field, text) => columnById(field)?.setFilterInput(text),
|
|
3082
|
+
setInput: (field, text, bound) => columnById(field)?.setFilterInput(text, bound),
|
|
2866
3083
|
apply: (field) => columnById(field)?.applyFilterInput(),
|
|
2867
3084
|
flushAll: () => table.flushPendingFilters(),
|
|
2868
3085
|
setCondition: (field, condition) => columnById(field)?.setFilterCondition(condition),
|
|
@@ -3494,12 +3711,12 @@ var useRowWindow = (o) => {
|
|
|
3494
3711
|
let pending = null;
|
|
3495
3712
|
/** Frames a `scrollToIndex` waits for its row before it is given up. */
|
|
3496
3713
|
const pendingFrames = 6;
|
|
3497
|
-
const viewport = () => {
|
|
3498
|
-
if (
|
|
3714
|
+
const viewport = (target = container) => {
|
|
3715
|
+
if (target === null || target === window) return {
|
|
3499
3716
|
top: 0,
|
|
3500
3717
|
height: globalThis.innerHeight
|
|
3501
3718
|
};
|
|
3502
|
-
const element =
|
|
3719
|
+
const element = target;
|
|
3503
3720
|
return {
|
|
3504
3721
|
top: element.getBoundingClientRect().top + element.clientTop,
|
|
3505
3722
|
height: element.clientHeight
|
|
@@ -3511,16 +3728,16 @@ var useRowWindow = (o) => {
|
|
|
3511
3728
|
return tbody.getBoundingClientRect().bottom;
|
|
3512
3729
|
};
|
|
3513
3730
|
const scrollTopOf = (target) => target === window ? window.scrollY : target.scrollTop;
|
|
3514
|
-
const scrollBy = (delta) => {
|
|
3515
|
-
if (Math.abs(delta) < 1 || !
|
|
3516
|
-
|
|
3517
|
-
top: scrollTopOf(
|
|
3731
|
+
const scrollBy = (delta, target = container) => {
|
|
3732
|
+
if (Math.abs(delta) < 1 || !target) return;
|
|
3733
|
+
target.scrollTo({
|
|
3734
|
+
top: scrollTopOf(target) + delta,
|
|
3518
3735
|
behavior: "instant"
|
|
3519
3736
|
});
|
|
3520
3737
|
};
|
|
3521
3738
|
/** How far to scroll to show an item at `top` (client) with `height`. */
|
|
3522
|
-
const alignDelta = (top, height, align, groupCover = 0) => {
|
|
3523
|
-
const view = viewport();
|
|
3739
|
+
const alignDelta = (top, height, align, groupCover = 0, target = container) => {
|
|
3740
|
+
const view = viewport(target);
|
|
3524
3741
|
const head = o.table.value?.tHead?.getBoundingClientRect();
|
|
3525
3742
|
const cover = head && head.top <= view.top + 1 && head.bottom > view.top ? head.bottom - view.top : 0;
|
|
3526
3743
|
const viewTop = view.top + cover + groupCover;
|
|
@@ -3547,6 +3764,16 @@ var useRowWindow = (o) => {
|
|
|
3547
3764
|
const g = groups.value;
|
|
3548
3765
|
return g && g.groupOf[position] >= 0 && !startsGroup(position) ? stickyGroupCover(tbody) : 0;
|
|
3549
3766
|
};
|
|
3767
|
+
/**
|
|
3768
|
+
* Scrolls `target` so the drawn row `tr` (at a center position, or `-1`
|
|
3769
|
+
* for a pinned row) is shown as `align` asks, below a sticky header and a
|
|
3770
|
+
* sticky group row (C-87, C-104).
|
|
3771
|
+
*/
|
|
3772
|
+
const alignRow = (tbody, tr, position, align, target, whole = true) => {
|
|
3773
|
+
const above = startsGroup(position) ? tr.previousElementSibling : null;
|
|
3774
|
+
const head = above?.classList.contains("qt-group-row") ? above : null;
|
|
3775
|
+
scrollBy(alignDelta((head ?? tr).getBoundingClientRect().top, (whole ? itemHeight(tr) : tr.getBoundingClientRect().height) + (head ? head.getBoundingClientRect().height : 0), align, head ? 0 : coverOf(position, tbody), target), target);
|
|
3776
|
+
};
|
|
3550
3777
|
/** After a render: correct the drift (C-84) or a `scrollToIndex` (C-87). */
|
|
3551
3778
|
const settle = () => {
|
|
3552
3779
|
const tbody = body();
|
|
@@ -3560,9 +3787,7 @@ var useRowWindow = (o) => {
|
|
|
3560
3787
|
if (tr) {
|
|
3561
3788
|
const { align, position } = pending;
|
|
3562
3789
|
pending = null;
|
|
3563
|
-
|
|
3564
|
-
const head = above?.classList.contains("qt-group-row") ? above : null;
|
|
3565
|
-
scrollBy(alignDelta((head ?? tr).getBoundingClientRect().top, itemHeight(tr) + (head ? head.getBoundingClientRect().height : 0), align, head ? 0 : coverOf(position, tbody)));
|
|
3790
|
+
alignRow(tbody, tr, position, align, container);
|
|
3566
3791
|
return;
|
|
3567
3792
|
}
|
|
3568
3793
|
if (++pending.tries <= pendingFrames) {
|
|
@@ -3874,6 +4099,24 @@ var useRowWindow = (o) => {
|
|
|
3874
4099
|
scrollBy(alignDelta(itemsTop(tbody) + offsets[position], heights[position], align, coverOf(position, tbody)));
|
|
3875
4100
|
schedule();
|
|
3876
4101
|
};
|
|
4102
|
+
/**
|
|
4103
|
+
* Shows the drawn row with this index in `rows` whole, below a sticky
|
|
4104
|
+
* header and a sticky group row, in its scroll container (C-110); with
|
|
4105
|
+
* `virtual` that is the container of C-85, else the nearest scrolling
|
|
4106
|
+
* ancestor of the table or the window. Only the row: an open subtable row
|
|
4107
|
+
* taller than the view would push it out. A `scrollToIndex` still waiting
|
|
4108
|
+
* is dropped, so it cannot move the view away after. A row not drawn does
|
|
4109
|
+
* nothing.
|
|
4110
|
+
*/
|
|
4111
|
+
const reveal = (index) => {
|
|
4112
|
+
const tbody = body();
|
|
4113
|
+
const table = o.table.value;
|
|
4114
|
+
const tr = tbody?.querySelector(`:scope > tr[data-row-index="${index}"]`);
|
|
4115
|
+
if (!tbody || !table || !tr) return;
|
|
4116
|
+
pending = null;
|
|
4117
|
+
const target = enabled() && container ? container : findContainer(table);
|
|
4118
|
+
alignRow(tbody, tr, tr.hasAttribute("data-pinned-row") ? -1 : positionOf(index), "auto", target, false);
|
|
4119
|
+
};
|
|
3877
4120
|
return {
|
|
3878
4121
|
enabled,
|
|
3879
4122
|
drawn,
|
|
@@ -3884,6 +4127,9 @@ var useRowWindow = (o) => {
|
|
|
3884
4127
|
/** Group rows of the body, drawn or not (C-104). */
|
|
3885
4128
|
groupCount,
|
|
3886
4129
|
scrollToIndex,
|
|
4130
|
+
reveal,
|
|
4131
|
+
/** A `scrollToIndex` or a window update is still to come (C-110). */
|
|
4132
|
+
busy: () => pending !== null || frame !== 0,
|
|
3887
4133
|
onFocusIn,
|
|
3888
4134
|
onFocusOut
|
|
3889
4135
|
};
|
|
@@ -3972,6 +4218,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3972
4218
|
type: [Boolean, Object],
|
|
3973
4219
|
default: false
|
|
3974
4220
|
},
|
|
4221
|
+
rowNavigation: {
|
|
4222
|
+
type: [Boolean, Object],
|
|
4223
|
+
default: false
|
|
4224
|
+
},
|
|
3975
4225
|
scrollBody: {
|
|
3976
4226
|
type: Boolean,
|
|
3977
4227
|
default: false
|
|
@@ -3994,7 +4244,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3994
4244
|
"headerContextMenu",
|
|
3995
4245
|
"columnResize",
|
|
3996
4246
|
"update:columns",
|
|
3997
|
-
"update:rowPinning"
|
|
4247
|
+
"update:rowPinning",
|
|
4248
|
+
"rowFocus"
|
|
3998
4249
|
],
|
|
3999
4250
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4000
4251
|
const props = __props;
|
|
@@ -4117,6 +4368,20 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4117
4368
|
isExpanded: expansion.isExpanded,
|
|
4118
4369
|
groupBy: () => props.groupBy
|
|
4119
4370
|
});
|
|
4371
|
+
const navigation = useRowNavigation({
|
|
4372
|
+
rowNavigation: () => props.rowNavigation,
|
|
4373
|
+
table: bodyTable,
|
|
4374
|
+
bodyRows: () => state.rowPinning.rows.value,
|
|
4375
|
+
keyOf: expansion.keyOf,
|
|
4376
|
+
hasRowKey: () => props.rowKey !== void 0,
|
|
4377
|
+
virtual: rowWindow.enabled,
|
|
4378
|
+
scrollToIndex: rowWindow.scrollToIndex,
|
|
4379
|
+
reveal: rowWindow.reveal,
|
|
4380
|
+
busy: rowWindow.busy,
|
|
4381
|
+
onFocus: (payload) => emit("rowFocus", payload)
|
|
4382
|
+
});
|
|
4383
|
+
/** The `tbody` listener of the navigation: none while it is off (C-111). */
|
|
4384
|
+
const navigationListeners = () => navigation.enabled() ? { keydown: navigation.onKeyDown } : {};
|
|
4120
4385
|
const infinite = useLoadMore({
|
|
4121
4386
|
infinite: () => props.infinite,
|
|
4122
4387
|
rowKey: () => props.rowKey,
|
|
@@ -4267,7 +4532,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4267
4532
|
key: i,
|
|
4268
4533
|
style: normalizeStyle(width === void 0 ? void 0 : { width: `${width}px` })
|
|
4269
4534
|
}, null, 4);
|
|
4270
|
-
}), 128))]), createVNode(table_body_default, {
|
|
4535
|
+
}), 128))]), createVNode(table_body_default, mergeProps({
|
|
4271
4536
|
rows: __props.rows,
|
|
4272
4537
|
"body-rows": unref(rowWindow).drawn.value,
|
|
4273
4538
|
"pin-row": unref(state).rowPinning.pin,
|
|
@@ -4296,12 +4561,12 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4296
4561
|
onCellContextMenu: _cache[2] || (_cache[2] = (payload) => emit("cellContextMenu", payload)),
|
|
4297
4562
|
onFocusin: unref(rowWindow).onFocusIn,
|
|
4298
4563
|
onFocusout: unref(rowWindow).onFocusOut
|
|
4299
|
-
}, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
|
|
4564
|
+
}, toHandlers(navigationListeners())), createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
|
|
4300
4565
|
return {
|
|
4301
4566
|
name,
|
|
4302
4567
|
fn: withCtx((p) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(p)))])
|
|
4303
4568
|
};
|
|
4304
|
-
})]),
|
|
4569
|
+
})]), 1040, [
|
|
4305
4570
|
"rows",
|
|
4306
4571
|
"body-rows",
|
|
4307
4572
|
"pin-row",
|
|
@@ -4386,7 +4651,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4386
4651
|
"slot-names",
|
|
4387
4652
|
"aria-rowindex"
|
|
4388
4653
|
])], 32),
|
|
4389
|
-
createVNode(table_body_default, {
|
|
4654
|
+
createVNode(table_body_default, mergeProps({
|
|
4390
4655
|
rows: __props.rows,
|
|
4391
4656
|
"body-rows": unref(rowWindow).drawn.value,
|
|
4392
4657
|
"pin-row": unref(state).rowPinning.pin,
|
|
@@ -4414,12 +4679,12 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4414
4679
|
onCellContextMenu: _cache[5] || (_cache[5] = (payload) => emit("cellContextMenu", payload)),
|
|
4415
4680
|
onFocusin: unref(rowWindow).onFocusIn,
|
|
4416
4681
|
onFocusout: unref(rowWindow).onFocusOut
|
|
4417
|
-
}, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
|
|
4682
|
+
}, toHandlers(navigationListeners())), createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
|
|
4418
4683
|
return {
|
|
4419
4684
|
name,
|
|
4420
4685
|
fn: withCtx((p) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(p)))])
|
|
4421
4686
|
};
|
|
4422
|
-
})]),
|
|
4687
|
+
})]), 1040, [
|
|
4423
4688
|
"rows",
|
|
4424
4689
|
"body-rows",
|
|
4425
4690
|
"pin-row",
|