@dolusoft/query-table 3.2.1 → 3.3.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 +503 -18
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +29 -0
- package/dist/types/flash/marks.d.ts +45 -0
- package/dist/types/flash/read-duration.d.ts +13 -0
- package/dist/types/flash/use-change-flash.d.ts +38 -0
- package/dist/types/parts/table-body.vue.d.ts +6 -0
- package/dist/types/query-table.vue.d.ts +2 -2
- package/package.json +3 -3
package/dist/query-table.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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";
|
|
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, onDeactivated, onMounted, 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
|
+
import { createRowChangeTracker } from "@dolusoft/query-table-core/row-changes";
|
|
3
4
|
import { dispose, filterInputFeature, projectServerQuery, serverQueryFeature } from "@dolusoft/query-table-core";
|
|
4
5
|
import { columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, functionalUpdate, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, useTable } from "@tanstack/vue-table";
|
|
5
6
|
//#region src/columns/column-layout.ts
|
|
@@ -145,6 +146,464 @@ var focusFirstFilter = (table) => {
|
|
|
145
146
|
return false;
|
|
146
147
|
};
|
|
147
148
|
//#endregion
|
|
149
|
+
//#region src/flash/marks.ts
|
|
150
|
+
/** A mark that is still running at `now`, else `null`. */
|
|
151
|
+
var live = (mark, now) => mark && mark.end > now ? mark : null;
|
|
152
|
+
/**
|
|
153
|
+
* The marks of one table (C-94): row and cell flashes by row key. Starting
|
|
154
|
+
* a flash that runs already restarts it, and the phase changes at most once
|
|
155
|
+
* a frame, so changes within one frame are one visual restart (K33-4).
|
|
156
|
+
*/
|
|
157
|
+
var createMarks = () => {
|
|
158
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
159
|
+
let gen = 0;
|
|
160
|
+
const restart = (mark, now, duration, frame) => {
|
|
161
|
+
gen++;
|
|
162
|
+
if (!mark) return {
|
|
163
|
+
start: now,
|
|
164
|
+
end: now + duration,
|
|
165
|
+
gen,
|
|
166
|
+
phase: "a",
|
|
167
|
+
flipFrame: frame
|
|
168
|
+
};
|
|
169
|
+
mark.start = now;
|
|
170
|
+
mark.end = now + duration;
|
|
171
|
+
mark.gen = gen;
|
|
172
|
+
if (mark.flipFrame !== frame) {
|
|
173
|
+
mark.phase = mark.phase === "a" ? "b" : "a";
|
|
174
|
+
mark.flipFrame = frame;
|
|
175
|
+
}
|
|
176
|
+
return mark;
|
|
177
|
+
};
|
|
178
|
+
const entry = (key) => {
|
|
179
|
+
let marks = byKey.get(key);
|
|
180
|
+
if (!marks) {
|
|
181
|
+
marks = {
|
|
182
|
+
row: null,
|
|
183
|
+
cells: null
|
|
184
|
+
};
|
|
185
|
+
byKey.set(key, marks);
|
|
186
|
+
}
|
|
187
|
+
return marks;
|
|
188
|
+
};
|
|
189
|
+
/** Flash the row of `key`; its cell flashes go (a new row is new as a whole). */
|
|
190
|
+
const flashRow = (key, now, duration, frame) => {
|
|
191
|
+
const marks = entry(key);
|
|
192
|
+
marks.row = restart(marks.row, now, duration, frame);
|
|
193
|
+
marks.cells?.clear();
|
|
194
|
+
};
|
|
195
|
+
const flashCell = (key, field, now, duration, frame) => {
|
|
196
|
+
const marks = entry(key);
|
|
197
|
+
const cells = marks.cells ??= /* @__PURE__ */ new Map();
|
|
198
|
+
cells.set(field, restart(cells.get(field), now, duration, frame));
|
|
199
|
+
};
|
|
200
|
+
const isEmpty = (marks) => marks.row === null && (marks.cells === null || marks.cells.size === 0);
|
|
201
|
+
/** Drop every row flash (`flash.rows` turned off). True when one went. */
|
|
202
|
+
const clearRows = () => {
|
|
203
|
+
let dropped = false;
|
|
204
|
+
for (const [key, marks] of byKey) {
|
|
205
|
+
if (marks.row) {
|
|
206
|
+
marks.row = null;
|
|
207
|
+
dropped = true;
|
|
208
|
+
}
|
|
209
|
+
if (isEmpty(marks)) byKey.delete(key);
|
|
210
|
+
}
|
|
211
|
+
return dropped;
|
|
212
|
+
};
|
|
213
|
+
/** Drop the cell flashes of `fields`, or of every field. True when one went. */
|
|
214
|
+
const clearCells = (fields) => {
|
|
215
|
+
let dropped = false;
|
|
216
|
+
for (const [key, marks] of byKey) {
|
|
217
|
+
const cells = marks.cells;
|
|
218
|
+
if (cells && cells.size > 0) {
|
|
219
|
+
if (fields) for (const field of fields) dropped = cells.delete(field) || dropped;
|
|
220
|
+
else {
|
|
221
|
+
cells.clear();
|
|
222
|
+
dropped = true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (isEmpty(marks)) byKey.delete(key);
|
|
226
|
+
}
|
|
227
|
+
return dropped;
|
|
228
|
+
};
|
|
229
|
+
/** Drop everything. True when something went. */
|
|
230
|
+
const clear = () => {
|
|
231
|
+
const had = byKey.size > 0;
|
|
232
|
+
byKey.clear();
|
|
233
|
+
return had;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Drop the marks that end by `until`; the nearest end of the ones left,
|
|
237
|
+
* or `Infinity`. True in `dropped` when one went.
|
|
238
|
+
*/
|
|
239
|
+
const prune = (until) => {
|
|
240
|
+
let nearest = Infinity;
|
|
241
|
+
let dropped = false;
|
|
242
|
+
for (const [key, marks] of byKey) {
|
|
243
|
+
if (marks.row) {
|
|
244
|
+
if (marks.row.end <= until) {
|
|
245
|
+
marks.row = null;
|
|
246
|
+
dropped = true;
|
|
247
|
+
} else nearest = Math.min(nearest, marks.row.end);
|
|
248
|
+
}
|
|
249
|
+
if (marks.cells) for (const [field, mark] of marks.cells) if (mark.end <= until) {
|
|
250
|
+
marks.cells.delete(field);
|
|
251
|
+
dropped = true;
|
|
252
|
+
} else nearest = Math.min(nearest, mark.end);
|
|
253
|
+
if (isEmpty(marks)) byKey.delete(key);
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
nearest,
|
|
257
|
+
dropped
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
get: (key) => byKey.get(key),
|
|
262
|
+
get size() {
|
|
263
|
+
return byKey.size;
|
|
264
|
+
},
|
|
265
|
+
/** The generation of the last start. */
|
|
266
|
+
get gen() {
|
|
267
|
+
return gen;
|
|
268
|
+
},
|
|
269
|
+
flashRow,
|
|
270
|
+
flashCell,
|
|
271
|
+
clearRows,
|
|
272
|
+
clearCells,
|
|
273
|
+
clear,
|
|
274
|
+
prune
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/flash/read-duration.ts
|
|
279
|
+
/** The custom property a skin sets the flash duration with (C-94). */
|
|
280
|
+
var durationProperty = "--qt-flash-duration";
|
|
281
|
+
/**
|
|
282
|
+
* A CSS time in milliseconds: `250ms`, `2s`, `.5s`. Anything else (a
|
|
283
|
+
* missing value, `calc()`, a negative or a zero time, a number without a
|
|
284
|
+
* unit) is `0`: no flash.
|
|
285
|
+
*/
|
|
286
|
+
var parseDuration = (text) => {
|
|
287
|
+
const match = /^\s*(\d*\.?\d+(?:e[+-]?\d+)?)(ms|s)\s*$/i.exec(text);
|
|
288
|
+
if (!match) return 0;
|
|
289
|
+
const value = Number(match[1]) * (match[2].toLowerCase() === "s" ? 1e3 : 1);
|
|
290
|
+
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* The flash duration the skin set on the table root (`.qt-datatable`) or
|
|
294
|
+
* above it, in milliseconds; `0` without one. One style read: the caller
|
|
295
|
+
* reads it at most once a frame, and only for an update that marks
|
|
296
|
+
* something (C-94).
|
|
297
|
+
*/
|
|
298
|
+
var readDuration = (table) => {
|
|
299
|
+
const root = table?.closest(".qt-datatable");
|
|
300
|
+
if (!root) return 0;
|
|
301
|
+
return parseDuration(getComputedStyle(root).getPropertyValue(durationProperty));
|
|
302
|
+
};
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/flash/use-change-flash.ts
|
|
305
|
+
var warn = (message) => {
|
|
306
|
+
try {
|
|
307
|
+
if (process.env.NODE_ENV === "production") return;
|
|
308
|
+
} catch {}
|
|
309
|
+
console.warn(`[QueryTable] ${message}`);
|
|
310
|
+
};
|
|
311
|
+
/** The inline custom property of an element bound after its flash began. */
|
|
312
|
+
var elapsedProperty = "--qt-flash-elapsed";
|
|
313
|
+
var kindsOf = (value) => typeof value === "object" ? {
|
|
314
|
+
rows: value.rows !== false,
|
|
315
|
+
cells: value.cells !== false
|
|
316
|
+
} : {
|
|
317
|
+
rows: true,
|
|
318
|
+
cells: true
|
|
319
|
+
};
|
|
320
|
+
var keyReader = (rowKey) => (row, index) => typeof rowKey === "function" ? rowKey(row, index) : row[rowKey];
|
|
321
|
+
/**
|
|
322
|
+
* The flash of one table while `flash` is on: feeds the tracker, keeps the
|
|
323
|
+
* marks, reads the duration, runs the one timer and binds the elapsed time.
|
|
324
|
+
* It lives in the effect scope it is created in and goes with it.
|
|
325
|
+
*/
|
|
326
|
+
var startFlash = (o) => {
|
|
327
|
+
let rowKey = o.rowKey();
|
|
328
|
+
let keyOf = rowKey === void 0 ? null : keyReader(rowKey);
|
|
329
|
+
const newTracker = () => createRowChangeTracker((row, index) => keyOf(row, index));
|
|
330
|
+
let tracker = newTracker();
|
|
331
|
+
const marks = createMarks();
|
|
332
|
+
/** Bumped when the drawn marks change: the body reads it. */
|
|
333
|
+
const version = shallowRef(0);
|
|
334
|
+
let kinds = kindsOf(o.flash());
|
|
335
|
+
let active = true;
|
|
336
|
+
let warnedKey = false;
|
|
337
|
+
let warnedBadKeys = false;
|
|
338
|
+
let frame = 0;
|
|
339
|
+
let frameRequest;
|
|
340
|
+
/** The duration read in this frame (valid while a frame is requested). */
|
|
341
|
+
let duration = 0;
|
|
342
|
+
let timer;
|
|
343
|
+
/** The end the timer wakes at. */
|
|
344
|
+
let timerAt = Infinity;
|
|
345
|
+
/**
|
|
346
|
+
* The first generation started in the update being drawn: an element
|
|
347
|
+
* bound to it in the same render gets no elapsed time.
|
|
348
|
+
*/
|
|
349
|
+
let freshFrom = Infinity;
|
|
350
|
+
/** A frame went by: the next change flips the phase, the duration is read again. */
|
|
351
|
+
const requestFrame = () => {
|
|
352
|
+
frameRequest ??= requestAnimationFrame(() => {
|
|
353
|
+
frameRequest = void 0;
|
|
354
|
+
frame++;
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
const durationNow = () => {
|
|
358
|
+
if (frameRequest === void 0) {
|
|
359
|
+
duration = readDuration(o.table.value);
|
|
360
|
+
requestFrame();
|
|
361
|
+
}
|
|
362
|
+
return duration;
|
|
363
|
+
};
|
|
364
|
+
const stopClock = () => {
|
|
365
|
+
if (timer !== void 0) {
|
|
366
|
+
clearTimeout(timer);
|
|
367
|
+
timer = void 0;
|
|
368
|
+
timerAt = Infinity;
|
|
369
|
+
}
|
|
370
|
+
if (frameRequest !== void 0) {
|
|
371
|
+
cancelAnimationFrame(frameRequest);
|
|
372
|
+
frameRequest = void 0;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
/** Wake at `end`: drop what ended, then wake at the next end. */
|
|
376
|
+
const wakeAt = (end) => {
|
|
377
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
378
|
+
timerAt = end;
|
|
379
|
+
timer = setTimeout(() => {
|
|
380
|
+
timer = void 0;
|
|
381
|
+
timerAt = Infinity;
|
|
382
|
+
const { nearest, dropped } = marks.prune(performance.now());
|
|
383
|
+
if (dropped) version.value++;
|
|
384
|
+
if (nearest !== Infinity) wakeAt(nearest);
|
|
385
|
+
}, Math.max(0, end - performance.now()));
|
|
386
|
+
};
|
|
387
|
+
/** Everything goes: marks, timer, frame and the rows compared against. */
|
|
388
|
+
const resetAll = () => {
|
|
389
|
+
tracker.clear();
|
|
390
|
+
stopClock();
|
|
391
|
+
if (marks.clear()) version.value++;
|
|
392
|
+
};
|
|
393
|
+
const update = () => {
|
|
394
|
+
if (!active) return;
|
|
395
|
+
if (o.rowKey() !== rowKey) {
|
|
396
|
+
rowKey = o.rowKey();
|
|
397
|
+
keyOf = rowKey === void 0 ? null : keyReader(rowKey);
|
|
398
|
+
resetAll();
|
|
399
|
+
tracker = newTracker();
|
|
400
|
+
}
|
|
401
|
+
if (keyOf === null) {
|
|
402
|
+
if (!warnedKey) {
|
|
403
|
+
warnedKey = true;
|
|
404
|
+
warn("`flash` needs `rowKey`; it is ignored without one (C-93).");
|
|
405
|
+
}
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
let changed = false;
|
|
409
|
+
const next = kindsOf(o.flash());
|
|
410
|
+
if (!next.rows && kinds.rows) changed = marks.clearRows() || changed;
|
|
411
|
+
if (!next.cells && kinds.cells) changed = marks.clearCells() || changed;
|
|
412
|
+
kinds = next;
|
|
413
|
+
const result = tracker.update({
|
|
414
|
+
rows: o.rows(),
|
|
415
|
+
query: o.query(),
|
|
416
|
+
loading: o.loading(),
|
|
417
|
+
fields: kinds.cells ? o.fields() : [],
|
|
418
|
+
hint: o.rowsUpdate(),
|
|
419
|
+
quiet: document.hidden
|
|
420
|
+
});
|
|
421
|
+
if (result.badKeys && !warnedBadKeys) {
|
|
422
|
+
warnedBadKeys = true;
|
|
423
|
+
warn("`flash` found a row without a `rowKey` value, or a key two rows share; the index is never used instead (C-93).");
|
|
424
|
+
}
|
|
425
|
+
if (result.reset) {
|
|
426
|
+
stopClock();
|
|
427
|
+
changed = marks.clear() || changed;
|
|
428
|
+
}
|
|
429
|
+
if (result.droppedFields.length > 0) changed = marks.clearCells(result.droppedFields) || changed;
|
|
430
|
+
const added = kinds.rows ? result.added : [];
|
|
431
|
+
const cells = kinds.cells ? result.changed : null;
|
|
432
|
+
if (added.length > 0 || cells !== null && cells.size > 0) {
|
|
433
|
+
const length = durationNow();
|
|
434
|
+
if (length > 0) {
|
|
435
|
+
const at = performance.now();
|
|
436
|
+
const firstGen = marks.gen + 1;
|
|
437
|
+
for (const key of added) marks.flashRow(key, at, length, frame);
|
|
438
|
+
cells?.forEach((fields, key) => {
|
|
439
|
+
for (const field of fields) marks.flashCell(key, field, at, length, frame);
|
|
440
|
+
});
|
|
441
|
+
changed = true;
|
|
442
|
+
if (freshFrom === Infinity) {
|
|
443
|
+
freshFrom = firstGen;
|
|
444
|
+
nextTick(() => {
|
|
445
|
+
freshFrom = Infinity;
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
requestFrame();
|
|
449
|
+
if (at + length < timerAt) wakeAt(at + length);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (changed) version.value++;
|
|
453
|
+
};
|
|
454
|
+
update();
|
|
455
|
+
const rowMarksOf = (row, index) => {
|
|
456
|
+
version.value;
|
|
457
|
+
return keyOf === null ? void 0 : marks.get(keyOf(row, index));
|
|
458
|
+
};
|
|
459
|
+
/** The generation bound to an element, and the elapsed value written on it. */
|
|
460
|
+
const bound = /* @__PURE__ */ new WeakMap();
|
|
461
|
+
const written = /* @__PURE__ */ new WeakMap();
|
|
462
|
+
/** Rows with something bound on them or on one of their cells. */
|
|
463
|
+
const boundRows = /* @__PURE__ */ new WeakSet();
|
|
464
|
+
/** The row flash a cell was last seen under. */
|
|
465
|
+
const seenUnder = /* @__PURE__ */ new WeakMap();
|
|
466
|
+
const bindTo = (el, mark, now, blockInherited) => {
|
|
467
|
+
const gen = bound.get(el);
|
|
468
|
+
if (!mark) {
|
|
469
|
+
if (gen !== void 0) {
|
|
470
|
+
bound.delete(el);
|
|
471
|
+
written.delete(el);
|
|
472
|
+
el.style.removeProperty(elapsedProperty);
|
|
473
|
+
}
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (gen === mark.gen) {
|
|
477
|
+
const value = written.get(el) ?? "";
|
|
478
|
+
if (value !== "" && el.style.getPropertyValue(elapsedProperty) === "") el.style.setProperty(elapsedProperty, value);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const elapsed = mark.gen >= freshFrom ? 0 : now - mark.start;
|
|
482
|
+
const value = elapsed >= 1 ? `${Math.round(elapsed)}ms` : blockInherited ? "0ms" : "";
|
|
483
|
+
if (value === "") el.style.removeProperty(elapsedProperty);
|
|
484
|
+
else el.style.setProperty(elapsedProperty, value);
|
|
485
|
+
bound.set(el, mark.gen);
|
|
486
|
+
written.set(el, value);
|
|
487
|
+
};
|
|
488
|
+
const view = {
|
|
489
|
+
row: (row, index) => {
|
|
490
|
+
const mark = rowMarksOf(row, index)?.row;
|
|
491
|
+
return mark ? live(mark, performance.now())?.phase : void 0;
|
|
492
|
+
},
|
|
493
|
+
cell: (row, index, field) => {
|
|
494
|
+
const mark = rowMarksOf(row, index)?.cells?.get(field);
|
|
495
|
+
return mark ? live(mark, performance.now())?.phase : void 0;
|
|
496
|
+
},
|
|
497
|
+
bind: (vnode) => {
|
|
498
|
+
const tr = vnode.el;
|
|
499
|
+
const index = Number(vnode.props?.["data-row-index"]);
|
|
500
|
+
const row = o.rows()[index];
|
|
501
|
+
if (!tr || row === void 0 || keyOf === null) return;
|
|
502
|
+
const rowMarks = marks.get(keyOf(row, index));
|
|
503
|
+
if (!rowMarks && !boundRows.has(tr)) return;
|
|
504
|
+
const now = performance.now();
|
|
505
|
+
const rowMark = live(rowMarks?.row, now);
|
|
506
|
+
const rowWasBound = rowMark !== null && bound.get(tr) === rowMark.gen;
|
|
507
|
+
bindTo(tr, rowMark, now, false);
|
|
508
|
+
const rowValue = written.get(tr) ?? "";
|
|
509
|
+
let any = bound.has(tr);
|
|
510
|
+
const cells = tr.children;
|
|
511
|
+
for (let i = 0; i < cells.length; i++) {
|
|
512
|
+
const td = cells[i];
|
|
513
|
+
const field = td.getAttribute("data-field");
|
|
514
|
+
const own = field === null ? null : live(rowMarks?.cells?.get(field), now);
|
|
515
|
+
if (own) bindTo(td, own, now, rowValue !== "");
|
|
516
|
+
else if (rowMark && (bound.get(td) === rowMark.gen || rowWasBound && seenUnder.get(td) !== rowMark.gen)) bindTo(td, rowMark, now, false);
|
|
517
|
+
else bindTo(td, null, now, false);
|
|
518
|
+
if (rowMark) seenUnder.set(td, rowMark.gen);
|
|
519
|
+
any ||= bound.has(td);
|
|
520
|
+
}
|
|
521
|
+
if (any) boundRows.add(tr);
|
|
522
|
+
else boundRows.delete(tr);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
/** Remove the elapsed times written on the body. */
|
|
526
|
+
const unbindAll = () => {
|
|
527
|
+
const body = o.table.value?.tBodies[0];
|
|
528
|
+
if (!body) return;
|
|
529
|
+
const rows = body.children;
|
|
530
|
+
for (let i = 0; i < rows.length; i++) {
|
|
531
|
+
const tr = rows[i];
|
|
532
|
+
tr.style.removeProperty(elapsedProperty);
|
|
533
|
+
const cells = tr.children;
|
|
534
|
+
for (let j = 0; j < cells.length; j++) cells[j].style.removeProperty(elapsedProperty);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
onScopeDispose(stopClock);
|
|
538
|
+
return {
|
|
539
|
+
view,
|
|
540
|
+
unbind: unbindAll,
|
|
541
|
+
update,
|
|
542
|
+
deactivate: () => {
|
|
543
|
+
active = false;
|
|
544
|
+
resetAll();
|
|
545
|
+
unbindAll();
|
|
546
|
+
},
|
|
547
|
+
activate: () => {
|
|
548
|
+
active = true;
|
|
549
|
+
update();
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* The change flash of `QueryTable` (C-93 to C-95). Off, it sets up one
|
|
555
|
+
* watcher that reads `flash` and nothing else: no comparison, timer, frame
|
|
556
|
+
* callback, listener, style read or memory per row. On, the same watcher
|
|
557
|
+
* also reads what the tracker compares, and the flash runs in an effect
|
|
558
|
+
* scope of its own; stopping that scope undoes everything. Nothing runs on
|
|
559
|
+
* the server: the flash starts once the table is mounted.
|
|
560
|
+
*/
|
|
561
|
+
var useChangeFlash = (o) => {
|
|
562
|
+
const view = shallowRef(null);
|
|
563
|
+
const instance = getCurrentInstance();
|
|
564
|
+
const owner = getCurrentScope();
|
|
565
|
+
let scope = null;
|
|
566
|
+
let controller = null;
|
|
567
|
+
let hooked = false;
|
|
568
|
+
let mounted = false;
|
|
569
|
+
const start = () => {
|
|
570
|
+
scope = owner.run(() => effectScope());
|
|
571
|
+
controller = scope.run(() => startFlash(o));
|
|
572
|
+
view.value = controller.view;
|
|
573
|
+
if (!hooked) {
|
|
574
|
+
hooked = true;
|
|
575
|
+
onDeactivated(() => controller?.deactivate(), instance);
|
|
576
|
+
onActivated(() => controller?.activate(), instance);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
const stop = () => {
|
|
580
|
+
controller?.unbind();
|
|
581
|
+
scope?.stop();
|
|
582
|
+
scope = null;
|
|
583
|
+
controller = null;
|
|
584
|
+
view.value = null;
|
|
585
|
+
};
|
|
586
|
+
watch(() => o.flash() ? [
|
|
587
|
+
o.flash(),
|
|
588
|
+
o.rows(),
|
|
589
|
+
o.query(),
|
|
590
|
+
o.loading(),
|
|
591
|
+
o.rowsUpdate(),
|
|
592
|
+
o.rowKey(),
|
|
593
|
+
o.fields()
|
|
594
|
+
] : null, (on) => {
|
|
595
|
+
if (!mounted) return;
|
|
596
|
+
if (!on) stop();
|
|
597
|
+
else if (controller) controller.update();
|
|
598
|
+
else start();
|
|
599
|
+
});
|
|
600
|
+
onMounted(() => {
|
|
601
|
+
mounted = true;
|
|
602
|
+
if (o.flash()) start();
|
|
603
|
+
});
|
|
604
|
+
return view;
|
|
605
|
+
};
|
|
606
|
+
//#endregion
|
|
148
607
|
//#region src/core/column.ts
|
|
149
608
|
/** Reads a dotted path (`'a.b'`) from a row. */
|
|
150
609
|
var valueAt = (row, path) => path.split(".").reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], row);
|
|
@@ -240,7 +699,10 @@ var _hoisted_2$5 = [
|
|
|
240
699
|
"aria-rowindex",
|
|
241
700
|
"data-pinned-row",
|
|
242
701
|
"data-expanded",
|
|
243
|
-
"data-selected"
|
|
702
|
+
"data-selected",
|
|
703
|
+
"data-flash",
|
|
704
|
+
"onVnodeBeforeMount",
|
|
705
|
+
"onVnodeUpdated"
|
|
244
706
|
];
|
|
245
707
|
var _hoisted_3$5 = ["aria-label", "onClick"];
|
|
246
708
|
var _hoisted_4$4 = [
|
|
@@ -272,23 +734,25 @@ var _hoisted_8$1 = [
|
|
|
272
734
|
"checked",
|
|
273
735
|
"onChange"
|
|
274
736
|
];
|
|
275
|
-
var _hoisted_9$1 = ["
|
|
276
|
-
var _hoisted_10 = ["
|
|
277
|
-
var _hoisted_11 =
|
|
737
|
+
var _hoisted_9$1 = ["data-flash"];
|
|
738
|
+
var _hoisted_10 = ["data-flash"];
|
|
739
|
+
var _hoisted_11 = ["aria-rowindex", "data-pinned-row"];
|
|
740
|
+
var _hoisted_12 = ["colspan"];
|
|
741
|
+
var _hoisted_13 = {
|
|
278
742
|
key: 0,
|
|
279
743
|
class: "qt-loading-row"
|
|
280
744
|
};
|
|
281
|
-
var
|
|
282
|
-
var
|
|
745
|
+
var _hoisted_14 = ["colspan"];
|
|
746
|
+
var _hoisted_15 = {
|
|
283
747
|
key: 1,
|
|
284
748
|
class: "qt-empty-row"
|
|
285
749
|
};
|
|
286
|
-
var
|
|
287
|
-
var
|
|
750
|
+
var _hoisted_16 = ["colspan"];
|
|
751
|
+
var _hoisted_17 = {
|
|
288
752
|
key: 2,
|
|
289
753
|
class: "qt-load-more-row"
|
|
290
754
|
};
|
|
291
|
-
var
|
|
755
|
+
var _hoisted_18 = ["colspan"];
|
|
292
756
|
//#endregion
|
|
293
757
|
//#region src/parts/table-body.vue
|
|
294
758
|
var table_body_default = /* @__PURE__ */ defineComponent({
|
|
@@ -312,7 +776,8 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
312
776
|
toggle: { type: Function },
|
|
313
777
|
labels: {},
|
|
314
778
|
hasContextMenuListener: { type: Function },
|
|
315
|
-
loadMore: {}
|
|
779
|
+
loadMore: {},
|
|
780
|
+
flash: {}
|
|
316
781
|
},
|
|
317
782
|
emits: ["rowRightPanelClick", "cellContextMenu"],
|
|
318
783
|
setup(__props, { emit: __emit }) {
|
|
@@ -348,7 +813,10 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
348
813
|
"aria-rowindex": item.aria,
|
|
349
814
|
"data-pinned-row": item.pinned || void 0,
|
|
350
815
|
"data-expanded": __props.isExpanded(item.row, item.index) ? "" : void 0,
|
|
351
|
-
"data-selected": __props.hasSelection && __props.isSelected(item.row, item.index) ? "" : void 0
|
|
816
|
+
"data-selected": __props.hasSelection && __props.isSelected(item.row, item.index) ? "" : void 0,
|
|
817
|
+
"data-flash": __props.flash ? __props.flash.row(item.row, item.index) : void 0,
|
|
818
|
+
onVnodeBeforeMount: __props.flash ? __props.flash.bind : void 0,
|
|
819
|
+
onVnodeUpdated: __props.flash ? __props.flash.bind : void 0
|
|
352
820
|
}, [
|
|
353
821
|
__props.hasRightPanel ? (openBlock(), createElementBlock("td", mergeProps({
|
|
354
822
|
key: 0,
|
|
@@ -402,10 +870,10 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
402
870
|
return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
|
|
403
871
|
key: 0,
|
|
404
872
|
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({
|
|
873
|
+
}, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(item.row, entry.column, item.index, item.pinned)))], 16, _hoisted_9$1)) : (openBlock(), createElementBlock("td", mergeProps({
|
|
406
874
|
key: 1,
|
|
407
875
|
ref_for: true
|
|
408
|
-
}, unref(cellAttrs)(entry)), toDisplayString(unref(cellText)(item.row, entry.column)), 17))], 64);
|
|
876
|
+
}, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), toDisplayString(unref(cellText)(item.row, entry.column)), 17, _hoisted_10))], 64);
|
|
409
877
|
}), 128))
|
|
410
878
|
], 8, _hoisted_2$5), __props.isExpanded(item.row, item.index) ? (openBlock(), createElementBlock("tr", {
|
|
411
879
|
key: 0,
|
|
@@ -415,10 +883,10 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
415
883
|
}, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "subtable", {
|
|
416
884
|
row: item.row,
|
|
417
885
|
rowIndex: item.index
|
|
418
|
-
})], 8,
|
|
886
|
+
})], 8, _hoisted_12)], 8, _hoisted_11)) : createCommentVNode("", true)], 64))], 64);
|
|
419
887
|
}), 128)),
|
|
420
|
-
__props.loading && slots.loading ? (openBlock(), createElementBlock("tr",
|
|
421
|
-
!__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr",
|
|
888
|
+
__props.loading && slots.loading ? (openBlock(), createElementBlock("tr", _hoisted_13, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "loading")], 8, _hoisted_14)])) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", _hoisted_15, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "empty")], 8, _hoisted_16)])) : createCommentVNode("", true),
|
|
889
|
+
!__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", _hoisted_17, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 8, _hoisted_18)])) : createCommentVNode("", true)
|
|
422
890
|
], 32);
|
|
423
891
|
};
|
|
424
892
|
}
|
|
@@ -2548,7 +3016,12 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
2548
3016
|
infinite: {
|
|
2549
3017
|
type: [Boolean, Object],
|
|
2550
3018
|
default: false
|
|
2551
|
-
}
|
|
3019
|
+
},
|
|
3020
|
+
flash: {
|
|
3021
|
+
type: [Boolean, Object],
|
|
3022
|
+
default: false
|
|
3023
|
+
},
|
|
3024
|
+
rowsUpdate: { default: void 0 }
|
|
2552
3025
|
},
|
|
2553
3026
|
emits: [
|
|
2554
3027
|
"update:query",
|
|
@@ -2666,6 +3139,16 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
2666
3139
|
});
|
|
2667
3140
|
/** `aria-rowindex` of the first footer row, or `undefined` (C-86). */
|
|
2668
3141
|
const footerRowIndex = computed(() => !rowWindow.enabled() || growing() ? void 0 : 2 + props.rows.length + rowWindow.expandedCount());
|
|
3142
|
+
const flashView = useChangeFlash({
|
|
3143
|
+
flash: () => props.flash,
|
|
3144
|
+
rowsUpdate: () => props.rowsUpdate,
|
|
3145
|
+
rows: () => props.rows,
|
|
3146
|
+
query: () => props.query,
|
|
3147
|
+
loading: () => props.loading,
|
|
3148
|
+
fields: () => entries.value.map((entry) => entry.column.field),
|
|
3149
|
+
rowKey: () => props.rowKey,
|
|
3150
|
+
table: tableEl
|
|
3151
|
+
});
|
|
2669
3152
|
const reorder = useColumnReorder({
|
|
2670
3153
|
reorderable: () => props.reorderable,
|
|
2671
3154
|
table: tableEl,
|
|
@@ -2764,6 +3247,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
2764
3247
|
labels: labels.value,
|
|
2765
3248
|
"has-context-menu-listener": hasContextMenuListener,
|
|
2766
3249
|
"load-more": loadMoreProps.value,
|
|
3250
|
+
flash: unref(flashView),
|
|
2767
3251
|
onRowRightPanelClick: _cache[0] || (_cache[0] = (row) => emit("rowRightPanelClick", row)),
|
|
2768
3252
|
onCellContextMenu: _cache[1] || (_cache[1] = (payload) => emit("cellContextMenu", payload)),
|
|
2769
3253
|
onFocusin: unref(rowWindow).onFocusIn,
|
|
@@ -2792,6 +3276,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
2792
3276
|
"toggle",
|
|
2793
3277
|
"labels",
|
|
2794
3278
|
"load-more",
|
|
3279
|
+
"flash",
|
|
2795
3280
|
"onFocusin",
|
|
2796
3281
|
"onFocusout"
|
|
2797
3282
|
]),
|