@dolusoft/query-table 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1643 @@
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";
2
+ import { columnTypeOf, columnTypeOf as columnTypeOf$1, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, searchOf } from "@dolusoft/query-protocol";
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";
5
+ //#region src/core/labels.ts
6
+ /** English defaults of the `labels` prop (C-44). */
7
+ var defaultLabels = {
8
+ clearAllFilters: "Clear all filters",
9
+ expandRow: "Expand row",
10
+ openRightPanel: "Open right panel",
11
+ filterInput: (column) => `Filter ${column}`,
12
+ filterOptions: (column) => `Filter options for ${column}`,
13
+ resizeColumn: (column) => `Resize ${column}`,
14
+ boolAll: "All",
15
+ boolTrue: "True",
16
+ boolFalse: "False",
17
+ selectRow: "Select row",
18
+ selectAllRows: "Select all rows"
19
+ };
20
+ var resolveLabels = (labels) => ({
21
+ ...defaultLabels,
22
+ ...labels
23
+ });
24
+ /** The name of a column in a label: its `title`, else its `field`. */
25
+ var columnName = (column) => column.title || column.field;
26
+ //#endregion
27
+ //#region src/core/table-context.ts
28
+ var tableContextKey = Symbol("query-table");
29
+ var provideTableContext = (context) => {
30
+ provide(tableContextKey, context);
31
+ };
32
+ var useTableContext = () => {
33
+ const context = inject(tableContextKey);
34
+ if (!context) throw new Error("Header parts must be rendered inside a QueryTable");
35
+ return context;
36
+ };
37
+ //#endregion
38
+ //#region src/filter/focus-filter.ts
39
+ var focusable = "input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
40
+ /**
41
+ * Focuses the filter of `field` in this table's own header (C-54). Header
42
+ * cells are walked directly, so a table nested in a slot is never searched.
43
+ * Returns whether the element took focus.
44
+ */
45
+ var focusFilterOf = (table, field) => {
46
+ const head = [...table?.children ?? []].find((child) => child.tagName === "THEAD");
47
+ for (const row of head?.children ?? []) for (const cell of row.children) {
48
+ if (cell.getAttribute("data-field") !== field) continue;
49
+ const target = [...[...cell.children].find((child) => child.classList.contains("qt-filter"))?.querySelectorAll(focusable) ?? []].find((element) => !element.classList.contains("qt-filter-button"));
50
+ if (!target) return false;
51
+ target.focus();
52
+ return target.ownerDocument.activeElement === target;
53
+ }
54
+ return false;
55
+ };
56
+ //#endregion
57
+ //#region src/core/column.ts
58
+ /** Reads a dotted path (`'a.b'`) from a row. */
59
+ var valueAt = (row, path) => path.split(".").reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], row);
60
+ //#endregion
61
+ //#region src/pin/pin.ts
62
+ /** Geometry key of a utility cell; a column's key is its `field`. */
63
+ var utilityKey = (utility) => `utility:${utility}`;
64
+ /**
65
+ * Attributes of a pinned cell (C-47): `data-pinned` and, once measured, the
66
+ * `--qt-pin-left` offset in pixels, next to an optional `width`. Nothing but
67
+ * the width for a cell that is not pinned; no `style` when both are absent.
68
+ */
69
+ var pinAttrs = (pinned, offset, width) => {
70
+ const style = {};
71
+ if (width) style.width = width;
72
+ if (pinned && offset !== void 0) style["--qt-pin-left"] = `${offset}px`;
73
+ return {
74
+ "data-pinned": pinned ? "" : void 0,
75
+ style: width || style["--qt-pin-left"] ? style : void 0
76
+ };
77
+ };
78
+ //#endregion
79
+ //#region src/body/use-cell-view.ts
80
+ /**
81
+ * What a body cell shows: its text, its attributes, the props for a
82
+ * `cell-<field>` slot and the context menu event (C-27, C-28, C-30).
83
+ */
84
+ var useCellView = (options) => {
85
+ /** Text of a cell, whole: the table never cuts it. */
86
+ const cellText = (row, column) => String(valueAt(row, column.field) ?? "");
87
+ const cellAttrs = (entry) => ({
88
+ "data-field": entry.column.field,
89
+ ...pinAttrs(entry.column.pinned === "left", options.offsets()[entry.column.field])
90
+ });
91
+ /**
92
+ * One listener on the `tbody` serves every cell (C-28): a listener per cell
93
+ * would be a new closure per cell on every render. The cell is the nearest
94
+ * `td` whose row is a direct child of this body. A table nested in a
95
+ * subtable row: the walk ends on the subtable `td`, which has no
96
+ * `data-field`, so this body stays quiet and the inner table answers for its
97
+ * own cells. A table nested in a `cell-<field>` slot: the inner table emits
98
+ * for its cell, then this body emits for the outer cell that holds it (the
99
+ * same as a listener on every cell did). Only a data cell counts: it carries
100
+ * `data-field`, and its row carries `data-row-index`.
101
+ */
102
+ const onContextMenu = (event) => {
103
+ if (!options.listening()) return;
104
+ const body = event.currentTarget;
105
+ let cell = event.target?.closest("td") ?? null;
106
+ while (cell && cell.parentElement?.parentElement !== body) cell = cell.parentElement?.closest("td") ?? null;
107
+ const field = cell?.getAttribute("data-field") ?? null;
108
+ const index = cell?.parentElement?.getAttribute("data-row-index") ?? null;
109
+ if (field === null || index === null) return;
110
+ const rowIndex = Number(index);
111
+ const row = options.rows()[rowIndex];
112
+ const entry = options.entries().find((e) => e.column.field === field);
113
+ if (row === void 0 || !entry) return;
114
+ event.preventDefault();
115
+ options.onContextMenu({
116
+ event,
117
+ row,
118
+ column: entry.column,
119
+ cellValue: valueAt(row, field),
120
+ rowIndex,
121
+ columnIndex: entry.index
122
+ });
123
+ };
124
+ const hasCellSlot = (column) => !!options.slots[`cell-${column.field}`];
125
+ const slotProps = (row, column, rowIndex) => ({
126
+ row,
127
+ rowIndex,
128
+ column,
129
+ cellValue: valueAt(row, column.field)
130
+ });
131
+ return {
132
+ cellText,
133
+ cellAttrs,
134
+ hasCellSlot,
135
+ slotProps,
136
+ onContextMenu
137
+ };
138
+ };
139
+ //#endregion
140
+ //#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
141
+ var _hoisted_1$8 = [
142
+ "data-row-index",
143
+ "data-expanded",
144
+ "data-selected"
145
+ ];
146
+ var _hoisted_2$5 = ["aria-label", "onClick"];
147
+ var _hoisted_3$4 = [
148
+ "aria-expanded",
149
+ "aria-label",
150
+ "onClick"
151
+ ];
152
+ var _hoisted_4$3 = {
153
+ width: "14",
154
+ height: "14",
155
+ viewBox: "0 0 24 24",
156
+ fill: "none",
157
+ stroke: "currentColor",
158
+ "stroke-width": "2",
159
+ "stroke-linecap": "round",
160
+ "stroke-linejoin": "round",
161
+ "aria-hidden": "true"
162
+ };
163
+ var _hoisted_5$1 = {
164
+ key: 0,
165
+ points: "6 9 12 15 18 9"
166
+ };
167
+ var _hoisted_6$1 = {
168
+ key: 1,
169
+ points: "9 6 15 12 9 18"
170
+ };
171
+ var _hoisted_7$1 = [
172
+ "aria-label",
173
+ "checked",
174
+ "onChange"
175
+ ];
176
+ var _hoisted_8$1 = {
177
+ key: 0,
178
+ class: "qt-subtable-row"
179
+ };
180
+ var _hoisted_9$1 = ["colspan"];
181
+ var _hoisted_10 = {
182
+ key: 0,
183
+ class: "qt-loading-row"
184
+ };
185
+ var _hoisted_11 = ["colspan"];
186
+ var _hoisted_12 = {
187
+ key: 1,
188
+ class: "qt-empty-row"
189
+ };
190
+ var _hoisted_13 = ["colspan"];
191
+ //#endregion
192
+ //#region src/parts/table-body.vue
193
+ var table_body_default = /* @__PURE__ */ defineComponent({
194
+ __name: "table-body",
195
+ props: {
196
+ rows: {},
197
+ loading: { type: Boolean },
198
+ entries: {},
199
+ columnCount: {},
200
+ hasSubtable: { type: Boolean },
201
+ hasRightPanel: { type: Boolean },
202
+ hasSelection: { type: Boolean },
203
+ isSelected: { type: Function },
204
+ toggleSelected: { type: Function },
205
+ hasPinned: { type: Boolean },
206
+ offsets: {},
207
+ keyOf: { type: Function },
208
+ isExpanded: { type: Function },
209
+ toggle: { type: Function },
210
+ labels: {},
211
+ hasContextMenuListener: { type: Function }
212
+ },
213
+ emits: ["rowRightPanelClick", "cellContextMenu"],
214
+ setup(__props, { emit: __emit }) {
215
+ const props = __props;
216
+ const emit = __emit;
217
+ const slots = useSlots();
218
+ const { cellText, cellAttrs, hasCellSlot, slotProps, onContextMenu } = useCellView({
219
+ slots: useSlots(),
220
+ rows: () => props.rows,
221
+ entries: () => props.entries,
222
+ offsets: () => props.offsets,
223
+ listening: () => props.hasContextMenuListener(),
224
+ onContextMenu: (payload) => emit("cellContextMenu", payload)
225
+ });
226
+ const rightPanelAttrs = () => pinAttrs(props.hasPinned, props.offsets[utilityKey("right-panel")]);
227
+ const expandAttrs = () => pinAttrs(props.hasPinned, props.offsets[utilityKey("subtable")]);
228
+ const selectAttrs = () => pinAttrs(props.hasPinned, props.offsets[utilityKey("select")]);
229
+ return (_ctx, _cache) => {
230
+ return openBlock(), createElementBlock("tbody", { onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args)) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.rows, (row, i) => {
231
+ return openBlock(), createElementBlock(Fragment, { key: __props.keyOf(row, i) }, [createElementVNode("tr", {
232
+ "data-row-index": i,
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({
237
+ key: 0,
238
+ ref_for: true
239
+ }, rightPanelAttrs()), [createElementVNode("button", {
240
+ type: "button",
241
+ class: "qt-right-panel-button",
242
+ "aria-label": __props.labels.openRightPanel,
243
+ onClick: withModifiers(($event) => emit("rowRightPanelClick", row), ["stop"])
244
+ }, [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
245
+ width: "14",
246
+ height: "14",
247
+ viewBox: "0 0 24 24",
248
+ fill: "none",
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({
286
+ key: 0,
287
+ ref_for: true
288
+ }, unref(cellAttrs)(entry)), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(row, entry.column, i)))], 16)) : (openBlock(), createElementBlock("td", mergeProps({
289
+ key: 1,
290
+ ref_for: true
291
+ }, unref(cellAttrs)(entry)), toDisplayString(unref(cellText)(row, entry.column)), 17))], 64);
292
+ }), 128))
293
+ ], 8, _hoisted_1$8), __props.isExpanded(row, i) ? (openBlock(), createElementBlock("tr", _hoisted_8$1, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "subtable", {
294
+ row,
295
+ rowIndex: i
296
+ })], 8, _hoisted_9$1)])) : createCommentVNode("", true)], 64);
297
+ }), 128)), __props.loading && slots.loading ? (openBlock(), createElementBlock("tr", _hoisted_10, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "loading")], 8, _hoisted_11)])) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", _hoisted_12, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "empty")], 8, _hoisted_13)])) : createCommentVNode("", true)], 32);
298
+ };
299
+ }
300
+ });
301
+ //#endregion
302
+ //#region src/parts/table-footer.vue?vue&type=script&setup=true&lang.ts
303
+ var _hoisted_1$7 = { class: "qt-footer" };
304
+ var _hoisted_2$4 = ["colspan"];
305
+ var _hoisted_3$3 = ["data-field"];
306
+ //#endregion
307
+ //#region src/parts/table-footer.vue
308
+ var table_footer_default = /* @__PURE__ */ defineComponent({
309
+ __name: "table-footer",
310
+ props: {
311
+ footerRows: {},
312
+ entries: {},
313
+ utilityCount: {},
314
+ hasPinned: { type: Boolean },
315
+ offsets: {}
316
+ },
317
+ setup(__props) {
318
+ const footerText = (row, column) => row.cells.find((cell) => cell.field === column.field)?.text;
319
+ return (_ctx, _cache) => {
320
+ return openBlock(), createElementBlock("tfoot", _hoisted_1$7, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.footerRows, (footerRow, i) => {
321
+ return openBlock(), createElementBlock("tr", { key: i }, [__props.utilityCount > 0 ? (openBlock(), createElementBlock("td", mergeProps({
322
+ key: 0,
323
+ colspan: __props.utilityCount
324
+ }, { ref_for: true }, unref(pinAttrs)(__props.hasPinned, 0)), null, 16, _hoisted_2$4)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
325
+ return openBlock(), createElementBlock("td", mergeProps({
326
+ key: entry.column.field,
327
+ "data-field": entry.column.field
328
+ }, { ref_for: true }, unref(pinAttrs)(entry.column.pinned === "left", __props.offsets[entry.column.field])), toDisplayString(footerText(footerRow, entry.column)), 17, _hoisted_3$3);
329
+ }), 128))]);
330
+ }), 128))]);
331
+ };
332
+ }
333
+ });
334
+ //#endregion
335
+ //#region src/parts/filter-icon.vue?vue&type=script&setup=true&lang.ts
336
+ var _hoisted_1$6 = ["fill"];
337
+ //#endregion
338
+ //#region src/parts/filter-icon.vue
339
+ var filter_icon_default = /* @__PURE__ */ defineComponent({
340
+ __name: "filter-icon",
341
+ props: { filled: { type: Boolean } },
342
+ setup(__props) {
343
+ return (_ctx, _cache) => {
344
+ return openBlock(), createElementBlock("svg", {
345
+ viewBox: "0 0 24 24",
346
+ width: "14",
347
+ height: "14",
348
+ stroke: "currentColor",
349
+ "stroke-width": "1.5",
350
+ fill: __props.filled ? "currentColor" : "none",
351
+ "stroke-linecap": "round",
352
+ "stroke-linejoin": "round",
353
+ "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$6);
355
+ };
356
+ }
357
+ });
358
+ //#endregion
359
+ //#region src/filter/use-filter-trigger.ts
360
+ /**
361
+ * The filter button a `filter-menu` slot receives as `trigger` (C-34). It is
362
+ * created once, so a popover wrapped around it does not remount the button on
363
+ * every render. It reads reactive state when it renders, so it still updates:
364
+ * the column and the labels come from getters on each render, not from a
365
+ * capture, so a new title or label shows at once.
366
+ */
367
+ var useFilterTrigger = (options) => defineComponent({
368
+ name: "FilterTrigger",
369
+ setup: () => () => {
370
+ const name = options.labels().filterOptions(columnName(options.column()));
371
+ const filtered = options.isFiltered();
372
+ return h("button", {
373
+ type: "button",
374
+ class: "qt-filter-button",
375
+ title: name,
376
+ "aria-label": name,
377
+ "data-filtered": filtered ? "" : void 0
378
+ }, [h(filter_icon_default, { filled: filtered })]);
379
+ }
380
+ });
381
+ //#endregion
382
+ //#region src/parts/filter-cell.vue?vue&type=script&setup=true&lang.ts
383
+ var _hoisted_1$5 = { class: "qt-filter" };
384
+ var _hoisted_2$3 = ["aria-label", "value"];
385
+ var _hoisted_3$2 = [
386
+ "type",
387
+ "aria-label",
388
+ "value",
389
+ "readonly"
390
+ ];
391
+ var _hoisted_4$2 = [
392
+ "aria-label",
393
+ "value",
394
+ "disabled"
395
+ ];
396
+ var _hoisted_5 = { value: "" };
397
+ var _hoisted_6 = { value: "true" };
398
+ var _hoisted_7 = { value: "false" };
399
+ var _hoisted_8 = [
400
+ "type",
401
+ "aria-label",
402
+ "value",
403
+ "readonly"
404
+ ];
405
+ var _hoisted_9 = {
406
+ key: 5,
407
+ class: "qt-filter-condition"
408
+ };
409
+ //#endregion
410
+ //#region src/parts/filter-cell.vue
411
+ var filter_cell_default = /* @__PURE__ */ defineComponent({
412
+ __name: "filter-cell",
413
+ props: {
414
+ column: {},
415
+ type: {},
416
+ query: {}
417
+ },
418
+ setup(__props) {
419
+ const props = __props;
420
+ const { filters, sort, labels } = useTableContext();
421
+ const inputName = () => labels().filterInput(columnName(props.column));
422
+ const isFiltered = () => rulesOf(props.query.filters, props.column.field).length > 0;
423
+ const trigger = useFilterTrigger({
424
+ column: () => props.column,
425
+ labels,
426
+ isFiltered
427
+ });
428
+ const labelOf = () => {
429
+ const label = filters.labelOf(props.column.field);
430
+ if (!label) return "";
431
+ const text = conditionLabel(props.type, label.condition);
432
+ return label.count > 1 ? `${text} (${label.count})` : text;
433
+ };
434
+ const inputText = () => {
435
+ const count = filters.multiOf(props.column.field);
436
+ return count > 0 ? `(${count})` : filters.draftOf(props.column.field).text;
437
+ };
438
+ const currentCondition = () => rulesOf(props.query.filters, props.column.field)[0]?.condition ?? filters.draftOf(props.column.field).condition;
439
+ const menuProps = () => {
440
+ const { column } = props;
441
+ return {
442
+ column,
443
+ rules: rulesOf(props.query.filters, column.field),
444
+ condition: currentCondition(),
445
+ conditions: conditionOptions[props.type],
446
+ setCondition: (condition) => filters.setCondition(column.field, condition),
447
+ clear: () => filters.clear(column.field),
448
+ sortable: sort.isSortable(column),
449
+ sortDirection: sort.sortOf(column),
450
+ setSort: (direction) => sort.sortBy(column, direction),
451
+ trigger
452
+ };
453
+ };
454
+ const datetimeProps = () => ({
455
+ column: props.column,
456
+ value: filters.draftOf(props.column.field).text,
457
+ updateValue: (value) => filters.setInput(props.column.field, value)
458
+ });
459
+ const inputValue = (event) => event.target.value;
460
+ const pick = (event) => {
461
+ filters.setInput(props.column.field, inputValue(event));
462
+ filters.apply(props.column.field);
463
+ };
464
+ return (_ctx, _cache) => {
465
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
466
+ __props.type === "string" ? (openBlock(), createElementBlock("input", {
467
+ key: 0,
468
+ type: "text",
469
+ class: "qt-filter-input",
470
+ "aria-label": inputName(),
471
+ value: unref(filters).draftOf(__props.column.field).text,
472
+ onInput: _cache[0] || (_cache[0] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
473
+ onKeydown: _cache[1] || (_cache[1] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
474
+ }, null, 40, _hoisted_2$3)) : __props.type === "number" || __props.type === "integer" ? (openBlock(), createElementBlock("input", {
475
+ key: 1,
476
+ type: unref(filters).multiOf(__props.column.field) ? "text" : "number",
477
+ class: "qt-filter-input",
478
+ "aria-label": inputName(),
479
+ value: inputText(),
480
+ readonly: unref(filters).multiOf(__props.column.field) > 0,
481
+ onInput: _cache[2] || (_cache[2] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
482
+ onKeydown: _cache[3] || (_cache[3] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
483
+ }, null, 40, _hoisted_3$2)) : __props.type === "bool" ? (openBlock(), createElementBlock("select", {
484
+ key: 2,
485
+ class: "qt-filter-input",
486
+ "aria-label": inputName(),
487
+ value: unref(filters).draftOf(__props.column.field).text,
488
+ disabled: unref(filters).multiOf(__props.column.field) > 0,
489
+ onChange: _cache[4] || (_cache[4] = ($event) => pick($event))
490
+ }, [
491
+ createElementVNode("option", _hoisted_5, toDisplayString(unref(labels)().boolAll), 1),
492
+ createElementVNode("option", _hoisted_6, toDisplayString(unref(labels)().boolTrue), 1),
493
+ createElementVNode("option", _hoisted_7, toDisplayString(unref(labels)().boolFalse), 1)
494
+ ], 40, _hoisted_4$2)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [_ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(datetimeProps())), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
495
+ key: 1,
496
+ type: unref(filters).multiOf(__props.column.field) ? "text" : "date",
497
+ class: "qt-filter-input",
498
+ "aria-label": inputName(),
499
+ value: inputText(),
500
+ readonly: unref(filters).multiOf(__props.column.field) > 0,
501
+ onInput: _cache[5] || (_cache[5] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
502
+ onKeydown: _cache[6] || (_cache[6] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
503
+ }, null, 40, _hoisted_8))], 64)),
504
+ __props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0, 4) : createCommentVNode("", true),
505
+ labelOf() ? (openBlock(), createElementBlock("small", _hoisted_9, toDisplayString(labelOf()), 1)) : createCommentVNode("", true)
506
+ ]);
507
+ };
508
+ }
509
+ });
510
+ //#endregion
511
+ //#region src/resize/use-column-resize.ts
512
+ /** Default `Column.minWidth`, in pixels. */
513
+ var defaultMinWidth = 40;
514
+ /**
515
+ * A width limit a consumer gave, or `undefined` when it cannot be one. The
516
+ * types say `number`, but a loosely typed consumer can pass `''`, `NaN`,
517
+ * `0` or a negative: those count as unset instead of clamping to 0.
518
+ */
519
+ var limitOf = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
520
+ /**
521
+ * The smallest width: `Column.minWidth`, else the default 40 (which gives way
522
+ * to a smaller `Column.maxWidth`, so a maximum alone keeps working).
523
+ */
524
+ var minWidthOf = (column) => limitOf(column.minWidth) ?? Math.min(defaultMinWidth, limitOf(column.maxWidth) ?? defaultMinWidth);
525
+ /** The largest width, or `undefined` for none. A `minWidth` above it wins. */
526
+ var maxWidthOf = (column) => {
527
+ const max = limitOf(column.maxWidth);
528
+ return max === void 0 ? void 0 : Math.max(max, minWidthOf(column));
529
+ };
530
+ var clampWidth = (column, width) => Math.round(Math.min(maxWidthOf(column) ?? Infinity, Math.max(minWidthOf(column), width)));
531
+ /** Width of the content of a cell up to `until` (exclusive), padding and border included. */
532
+ var contentWidth = (cell, until) => {
533
+ const range = document.createRange();
534
+ range.selectNodeContents(cell);
535
+ if (until) range.setEndBefore(until);
536
+ const style = getComputedStyle(cell);
537
+ return [
538
+ style.paddingLeft,
539
+ style.paddingRight,
540
+ style.borderLeftWidth,
541
+ style.borderRightWidth
542
+ ].reduce((sum, value) => sum + (parseFloat(value) || 0), range.getBoundingClientRect().width);
543
+ };
544
+ /**
545
+ * The widest rendered content of a column: the header label (the part before
546
+ * the filter row and the handle) and the column's cells in this table's own
547
+ * body rows. Only the rows given are measured (C-50).
548
+ */
549
+ var autofitWidth = (th, field) => {
550
+ let widest = contentWidth(th, th.querySelector(":scope > .qt-filter, :scope > .qt-resize-handle"));
551
+ for (const cell of th.closest("table")?.tBodies[0]?.querySelectorAll(`:scope > tr[data-row-index] > td[data-field="${CSS.escape(field)}"]`) ?? []) widest = Math.max(widest, contentWidth(cell));
552
+ return Math.ceil(widest);
553
+ };
554
+ var cellOf = (event) => event.currentTarget.closest("th");
555
+ /**
556
+ * Resizing a column (C-48 to C-50). The table holds a width only while a
557
+ * drag is under way (the preview, P2); every committed width goes out as a
558
+ * `columnResize` event and comes back, if the consumer wants it, as
559
+ * `Column.width`. The handle captures the pointer, so all drag events arrive
560
+ * at the handle itself, and it has the focus, so Escape does too.
561
+ */
562
+ var useColumnResize = (options) => {
563
+ const preview = shallowRef(null);
564
+ let drag = null;
565
+ const isResizable = (column) => options.resizable() && column.resizable !== false;
566
+ /** The width the header shows: the preview while dragging, else measured. */
567
+ const widthOf = (column) => preview.value?.field === column.field ? preview.value.width : Math.round(options.measuredWidth(column.field) ?? 0);
568
+ const commit = (column, from, width) => {
569
+ const next = clampWidth(column, width);
570
+ if (next !== Math.round(from)) options.emit({
571
+ field: column.field,
572
+ width: next
573
+ });
574
+ };
575
+ const dragged = (current) => current.startWidth + current.lastX - current.startX;
576
+ const end = (apply) => {
577
+ const current = drag;
578
+ if (current) {
579
+ drag = null;
580
+ cancelAnimationFrame(current.frame);
581
+ preview.value = null;
582
+ if (apply) commit(current.column, current.startWidth, dragged(current));
583
+ }
584
+ };
585
+ /** Every pointer event of a handle; one listener for the whole drag. */
586
+ const onPointer = (event, column) => {
587
+ if (event.type === "pointerdown") {
588
+ const th = cellOf(event);
589
+ if (event.button !== 0 || drag || !th) return;
590
+ const handle = event.currentTarget;
591
+ event.preventDefault();
592
+ handle.focus({ preventScroll: true });
593
+ handle.setPointerCapture(event.pointerId);
594
+ drag = {
595
+ column,
596
+ pointerId: event.pointerId,
597
+ startX: event.clientX,
598
+ startWidth: th.getBoundingClientRect().width,
599
+ lastX: event.clientX,
600
+ frame: 0
601
+ };
602
+ return;
603
+ }
604
+ if (!drag || event.pointerId !== drag.pointerId) return;
605
+ drag.lastX = event.clientX;
606
+ if (event.type === "pointermove") drag.frame ||= requestAnimationFrame(() => {
607
+ if (drag) {
608
+ drag.frame = 0;
609
+ preview.value = {
610
+ field: drag.column.field,
611
+ width: clampWidth(drag.column, dragged(drag))
612
+ };
613
+ }
614
+ });
615
+ else end(event.type === "pointerup");
616
+ };
617
+ /** Arrow keys step the width, Enter fits it; both from the rendered width. */
618
+ const onKey = (event, column) => {
619
+ const { key } = event;
620
+ if (drag) {
621
+ if (key === "Escape") {
622
+ event.preventDefault();
623
+ event.stopPropagation();
624
+ end(false);
625
+ }
626
+ return;
627
+ }
628
+ const sign = key === "ArrowRight" ? 1 : key === "ArrowLeft" ? -1 : 0;
629
+ const th = cellOf(event);
630
+ if (th && (sign || key === "Enter" || event.type === "dblclick")) {
631
+ event.preventDefault();
632
+ const from = th.getBoundingClientRect().width;
633
+ commit(column, from, sign ? Math.round(from) + sign * (event.shiftKey ? 50 : 10) : autofitWidth(th, column.field));
634
+ }
635
+ };
636
+ /**
637
+ * The listeners of one handle, as one `v-on` object made once per handle.
638
+ * Pointer capture sends every drag event to the handle itself.
639
+ */
640
+ const listeners = (column) => {
641
+ const pointer = (event) => {
642
+ onPointer(event, column());
643
+ };
644
+ const key = (event) => {
645
+ onKey(event, column());
646
+ };
647
+ return {
648
+ pointerdown: pointer,
649
+ pointermove: pointer,
650
+ pointerup: pointer,
651
+ pointercancel: pointer,
652
+ lostpointercapture: pointer,
653
+ keydown: key,
654
+ dblclick: key,
655
+ click: (event) => {
656
+ event.stopPropagation();
657
+ }
658
+ };
659
+ };
660
+ /** `aria-valuemax`: `maxWidth`, or else the table width (what can show). */
661
+ const maxOf = (column) => maxWidthOf(column) ?? Math.max(widthOf(column), Math.round(options.tableWidth()));
662
+ onBeforeUnmount(() => {
663
+ if (drag) {
664
+ cancelAnimationFrame(drag.frame);
665
+ drag = null;
666
+ }
667
+ });
668
+ return {
669
+ preview,
670
+ isResizable,
671
+ widthOf,
672
+ maxOf,
673
+ listeners
674
+ };
675
+ };
676
+ //#endregion
677
+ //#region src/parts/resize-handle.vue?vue&type=script&setup=true&lang.ts
678
+ var _hoisted_1$4 = [
679
+ "aria-label",
680
+ "aria-valuenow",
681
+ "aria-valuemin",
682
+ "aria-valuemax"
683
+ ];
684
+ //#endregion
685
+ //#region src/parts/resize-handle.vue
686
+ var resize_handle_default = /* @__PURE__ */ defineComponent({
687
+ __name: "resize-handle",
688
+ props: { column: {} },
689
+ setup(__props) {
690
+ const props = __props;
691
+ const { resize, labels } = useTableContext();
692
+ const on = resize.listeners(() => props.column);
693
+ return (_ctx, _cache) => {
694
+ return openBlock(), createElementBlock("div", mergeProps({
695
+ class: "qt-resize-handle",
696
+ role: "separator",
697
+ "aria-orientation": "vertical",
698
+ tabindex: "0",
699
+ "aria-label": unref(labels)().resizeColumn(unref(columnName)(__props.column)),
700
+ "aria-valuenow": unref(resize).widthOf(__props.column),
701
+ "aria-valuemin": unref(minWidthOf)(__props.column),
702
+ "aria-valuemax": unref(resize).maxOf(__props.column)
703
+ }, toHandlers(unref(on), true)), null, 16, _hoisted_1$4);
704
+ };
705
+ }
706
+ });
707
+ //#endregion
708
+ //#region src/parts/sort-button.vue?vue&type=script&setup=true&lang.ts
709
+ var _hoisted_1$3 = ["aria-label"];
710
+ var _hoisted_2$2 = {
711
+ key: 0,
712
+ class: "qt-sort-icon",
713
+ width: "14",
714
+ height: "14",
715
+ viewBox: "0 0 16 16",
716
+ "aria-hidden": "true"
717
+ };
718
+ var _hoisted_3$1 = {
719
+ key: 1,
720
+ class: "qt-sort-icon",
721
+ width: "14",
722
+ height: "14",
723
+ viewBox: "0 0 16 16",
724
+ "aria-hidden": "true"
725
+ };
726
+ var _hoisted_4$1 = {
727
+ key: 2,
728
+ class: "qt-sort-icon",
729
+ width: "14",
730
+ height: "14",
731
+ viewBox: "0 0 16 16",
732
+ "aria-hidden": "true"
733
+ };
734
+ //#endregion
735
+ //#region src/parts/sort-button.vue
736
+ var sort_button_default = /* @__PURE__ */ defineComponent({
737
+ __name: "sort-button",
738
+ props: {
739
+ column: {},
740
+ direction: {}
741
+ },
742
+ emits: ["click"],
743
+ setup(__props) {
744
+ return (_ctx, _cache) => {
745
+ return openBlock(), createElementBlock("button", {
746
+ type: "button",
747
+ class: "qt-sort",
748
+ "aria-label": __props.column.title ? void 0 : __props.column.field,
749
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click"))
750
+ }, [createTextVNode(toDisplayString(__props.column.title) + " ", 1), __props.direction === "asc" ? (openBlock(), createElementBlock("svg", _hoisted_2$2, [..._cache[1] || (_cache[1] = [createElementVNode("path", {
751
+ d: "M8 3.5L12.5 9.5H3.5L8 3.5Z",
752
+ fill: "currentColor"
753
+ }, null, -1)])])) : __props.direction === "desc" ? (openBlock(), createElementBlock("svg", _hoisted_3$1, [..._cache[2] || (_cache[2] = [createElementVNode("path", {
754
+ d: "M8 12.5L3.5 6.5H12.5L8 12.5Z",
755
+ fill: "currentColor"
756
+ }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_4$1, [..._cache[3] || (_cache[3] = [createElementVNode("path", {
757
+ d: "M8 3L11.5 7H4.5L8 3Z",
758
+ fill: "currentColor"
759
+ }, null, -1), createElementVNode("path", {
760
+ d: "M8 13L4.5 9H11.5L8 13Z",
761
+ fill: "currentColor"
762
+ }, null, -1)])]))], 8, _hoisted_1$3);
763
+ };
764
+ }
765
+ });
766
+ //#endregion
767
+ //#region src/sort/sort.ts
768
+ /** Value of the `aria-sort` attribute for a direction. */
769
+ var ariaSort = (direction) => direction === "asc" ? "ascending" : direction === "desc" ? "descending" : void 0;
770
+ //#endregion
771
+ //#region src/parts/table-header.vue?vue&type=script&setup=true&lang.ts
772
+ var _hoisted_1$2 = [
773
+ "aria-label",
774
+ "checked",
775
+ "indeterminate"
776
+ ];
777
+ var _hoisted_2$1 = [
778
+ "title",
779
+ "aria-label",
780
+ "disabled"
781
+ ];
782
+ var _hoisted_3 = [
783
+ "data-field",
784
+ "data-sort",
785
+ "data-sortable",
786
+ "data-filtered",
787
+ "aria-sort"
788
+ ];
789
+ var _hoisted_4 = {
790
+ key: 2,
791
+ class: "qt-title"
792
+ };
793
+ //#endregion
794
+ //#region src/parts/table-header.vue
795
+ var table_header_default = /* @__PURE__ */ defineComponent({
796
+ __name: "table-header",
797
+ props: {
798
+ columns: {},
799
+ query: {},
800
+ filterable: { type: Boolean },
801
+ utilities: {},
802
+ hasPinned: { type: Boolean },
803
+ offsets: {},
804
+ slotNames: {}
805
+ },
806
+ setup(__props) {
807
+ const props = __props;
808
+ const given = (name) => props.slotNames.split(" ").includes(name);
809
+ const { filters, sort, resize, selection, labels } = useTableContext();
810
+ const canClearAll = computed(() => filters.canClearAll());
811
+ const isFiltered = (column) => rulesOf(props.query.filters, column.field).length > 0;
812
+ const hasFilter = (column) => props.filterable && column.filterable !== false;
813
+ const hostsClearAll = (utility) => props.filterable && utility === props.utilities.find((candidate) => candidate !== "select");
814
+ const utilityAttrs = (utility) => pinAttrs(props.hasPinned, props.offsets[utilityKey(utility)]);
815
+ const cellAttrs = (column) => {
816
+ const preview = resize.preview.value;
817
+ return pinAttrs(column.pinned === "left", props.offsets[column.field], preview?.field === column.field ? `${preview.width}px` : column.width);
818
+ };
819
+ const headerSlotProps = (column) => ({
820
+ column,
821
+ sortDirection: sort.sortOf(column),
822
+ sortable: sort.isSortable(column),
823
+ toggleSort: () => {
824
+ sort.sortBy(column);
825
+ }
826
+ });
827
+ return (_ctx, _cache) => {
828
+ return openBlock(), createElementBlock("tr", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.utilities, (utility) => {
829
+ return openBlock(), createElementBlock(Fragment, { key: utility }, [utility === "select" ? (openBlock(), createElementBlock("th", mergeProps({
830
+ key: 0,
831
+ scope: "col"
832
+ }, { ref_for: true }, utilityAttrs(utility)), [createElementVNode("input", {
833
+ type: "checkbox",
834
+ class: "qt-select-all",
835
+ "aria-label": unref(labels)().selectAllRows,
836
+ checked: unref(selection).allSelected.value,
837
+ indeterminate: unref(selection).someSelected.value,
838
+ onChange: _cache[0] || (_cache[0] = ($event) => unref(selection).toggleAll($event.target.checked))
839
+ }, null, 40, _hoisted_1$2)], 16)) : !hostsClearAll(utility) ? (openBlock(), createElementBlock("td", mergeProps({
840
+ key: 1,
841
+ ref_for: true
842
+ }, utilityAttrs(utility)), null, 16)) : (openBlock(), createElementBlock("th", mergeProps({
843
+ key: 2,
844
+ scope: "col"
845
+ }, { ref_for: true }, utilityAttrs(utility)), [createElementVNode("button", {
846
+ type: "button",
847
+ class: "qt-clear-all-button",
848
+ title: unref(labels)().clearAllFilters,
849
+ "aria-label": unref(labels)().clearAllFilters,
850
+ disabled: !canClearAll.value,
851
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => unref(filters).clearAll(), ["stop"]))
852
+ }, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
853
+ width: "14",
854
+ height: "14",
855
+ viewBox: "0 0 24 24",
856
+ fill: "none",
857
+ stroke: "currentColor",
858
+ "stroke-width": "2",
859
+ "stroke-linecap": "round",
860
+ "stroke-linejoin": "round",
861
+ "aria-hidden": "true"
862
+ }, [createElementVNode("line", {
863
+ x1: "18",
864
+ y1: "6",
865
+ x2: "6",
866
+ y2: "18"
867
+ }), createElementVNode("line", {
868
+ x1: "6",
869
+ y1: "6",
870
+ x2: "18",
871
+ y2: "18"
872
+ })], -1)])], 8, _hoisted_2$1)], 16))], 64);
873
+ }), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
874
+ return openBlock(), createElementBlock("th", mergeProps({
875
+ key: column.field,
876
+ scope: "col",
877
+ "data-field": column.field,
878
+ "data-sort": unref(sort).sortOf(column) ?? void 0,
879
+ "data-sortable": unref(sort).isSortable(column) ? "" : void 0,
880
+ "data-filtered": isFiltered(column) ? "" : void 0,
881
+ "aria-sort": unref(ariaSort)(unref(sort).sortOf(column))
882
+ }, { ref_for: true }, cellAttrs(column)), [
883
+ given(`header-${column.field}`) ? renderSlot(_ctx.$slots, "header", mergeProps({ ref_for: true }, headerSlotProps(column)), void 0, void 0, 0) : unref(sort).isSortable(column) ? (openBlock(), createBlock(sort_button_default, {
884
+ key: 1,
885
+ column,
886
+ direction: unref(sort).sortOf(column),
887
+ onClick: ($event) => unref(sort).sortBy(column)
888
+ }, null, 8, [
889
+ "column",
890
+ "direction",
891
+ "onClick"
892
+ ])) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(column.title), 1)),
893
+ hasFilter(column) ? (openBlock(), createBlock(filter_cell_default, {
894
+ key: 3,
895
+ column,
896
+ type: unref(columnTypeOf$1)(column),
897
+ query: __props.query
898
+ }, createSlots({ _: 2 }, [given("filter-datetime") ? {
899
+ name: "filter-datetime",
900
+ fn: withCtx((p) => [renderSlot(_ctx.$slots, "filter-datetime", mergeProps({ ref_for: true }, p))]),
901
+ key: "0"
902
+ } : void 0, given("filter-menu") ? {
903
+ name: "filter-menu",
904
+ fn: withCtx((p) => [renderSlot(_ctx.$slots, "filter-menu", mergeProps({ ref_for: true }, p))]),
905
+ key: "1"
906
+ } : void 0]), 1032, [
907
+ "column",
908
+ "type",
909
+ "query"
910
+ ])) : createCommentVNode("", true),
911
+ unref(resize).isResizable(column) ? (openBlock(), createBlock(resize_handle_default, {
912
+ key: 4,
913
+ column
914
+ }, null, 8, ["column"])) : createCommentVNode("", true)
915
+ ], 16, _hoisted_3);
916
+ }), 128))]);
917
+ };
918
+ }
919
+ });
920
+ //#endregion
921
+ //#region src/parts/table-pagination.vue?vue&type=script&setup=true&lang.ts
922
+ var _hoisted_1$1 = { class: "qt-pagination" };
923
+ //#endregion
924
+ //#region src/parts/table-pagination.vue
925
+ var table_pagination_default = /* @__PURE__ */ defineComponent({
926
+ __name: "table-pagination",
927
+ props: { paginationProps: {} },
928
+ setup(__props) {
929
+ return (_ctx, _cache) => {
930
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [renderSlot(_ctx.$slots, "pagination", normalizeProps(guardReactiveProps(__props.paginationProps)))]);
931
+ };
932
+ }
933
+ });
934
+ //#endregion
935
+ //#region src/pin/use-header-geometry.ts
936
+ /** One string per map: compares two maps in one step. */
937
+ var signature = (numbers) => JSON.stringify(numbers);
938
+ /**
939
+ * Measured header geometry (C-47, C-48): the rendered width of every header
940
+ * cell and, for the pinned cells, the cumulative left offset written as
941
+ * `--qt-pin-left`. One `ResizeObserver` watches the header cells and the
942
+ * table; it reports width changes from any cause (a resize, a font that
943
+ * loads, a container that narrows) in one batched callback, after layout, so
944
+ * reading the cells there forces no extra layout. The observer is rebuilt
945
+ * only when the drawn cells change, not when a width does. Nothing is
946
+ * measured while inactive, and the observer is disconnected on unmount.
947
+ */
948
+ var useHeaderGeometry = (options) => {
949
+ /** Rendered width of each header cell, by key. */
950
+ const widths = shallowRef({});
951
+ /** Rendered width of the table. */
952
+ const tableWidth = shallowRef(0);
953
+ /** `--qt-pin-left` of each pinned cell, by key, in pixels. */
954
+ const offsets = shallowRef({});
955
+ let observer = null;
956
+ const headerCells = (table) => table.querySelectorAll(":scope > thead > tr > *");
957
+ const measure = (table) => {
958
+ tableWidth.value = table.getBoundingClientRect().width;
959
+ const cells = options.cells();
960
+ const next = {};
961
+ const nextOffsets = {};
962
+ let left = 0;
963
+ headerCells(table).forEach((cell, index) => {
964
+ const drawn = cells[index];
965
+ if (drawn) {
966
+ const width = cell.getBoundingClientRect().width;
967
+ next[drawn.key] = width;
968
+ if (drawn.pinned) {
969
+ nextOffsets[drawn.key] = left;
970
+ left += width;
971
+ }
972
+ }
973
+ });
974
+ if (signature(next) !== signature(widths.value)) widths.value = next;
975
+ if (signature(nextOffsets) !== signature(offsets.value)) offsets.value = nextOffsets;
976
+ };
977
+ const observe = () => {
978
+ observer?.disconnect();
979
+ observer = null;
980
+ const table = options.table.value;
981
+ if (!table || !options.active() || typeof ResizeObserver === "undefined") {
982
+ if (Object.keys(offsets.value).length > 0) offsets.value = {};
983
+ return;
984
+ }
985
+ const current = new ResizeObserver(() => {
986
+ measure(table);
987
+ });
988
+ observer = current;
989
+ current.observe(table);
990
+ headerCells(table).forEach((cell) => {
991
+ current.observe(cell);
992
+ });
993
+ measure(table);
994
+ };
995
+ watch([
996
+ () => options.table.value,
997
+ options.active,
998
+ () => options.cells().map((cell) => cell.pinned ? `${cell.key}*` : cell.key).join("|")
999
+ ], () => {
1000
+ nextTick(observe);
1001
+ }, {
1002
+ immediate: true,
1003
+ flush: "post"
1004
+ });
1005
+ onBeforeUnmount(() => {
1006
+ observer?.disconnect();
1007
+ observer = null;
1008
+ });
1009
+ return {
1010
+ widths,
1011
+ tableWidth,
1012
+ offsets
1013
+ };
1014
+ };
1015
+ //#endregion
1016
+ //#region src/use-query-table.ts
1017
+ /** The TanStack features of a Query Table, the two plugins included. */
1018
+ var features = tableFeatures({
1019
+ rowSortingFeature,
1020
+ rowPaginationFeature,
1021
+ columnFilteringFeature,
1022
+ globalFilteringFeature,
1023
+ rowSelectionFeature,
1024
+ rowExpandingFeature,
1025
+ columnPinningFeature,
1026
+ serverQueryFeature,
1027
+ filterInputFeature
1028
+ });
1029
+ var blank = Object.freeze({
1030
+ text: "",
1031
+ condition: null
1032
+ });
1033
+ var defaultPageSizes = [
1034
+ 10,
1035
+ 20,
1036
+ 30,
1037
+ 50,
1038
+ 100
1039
+ ];
1040
+ /** Only the `true` entries: the selection a consumer stores. */
1041
+ var selectedOnly = (selection) => Object.fromEntries(Object.entries(selection).filter(([, value]) => value));
1042
+ /**
1043
+ * The state and actions of a server-side table: TanStack Table with
1044
+ * `serverQueryFeature` and `filterInputFeature`, in a Vue scope. Disposed
1045
+ * with the scope (C-62).
1046
+ */
1047
+ function useQueryTable(options) {
1048
+ const query = () => toValue(options.query);
1049
+ const rows = () => toValue(options.rows) ?? [];
1050
+ const totalRows = () => toValue(options.totalRows) ?? null;
1051
+ const cursors = () => toValue(options.cursors) ?? null;
1052
+ const columns = () => toValue(options.columns);
1053
+ const rowKey = () => toValue(options.rowKey);
1054
+ const hasSubtable = () => toValue(options.hasSubtable) ?? false;
1055
+ const keyOf = (row, index) => {
1056
+ const key = rowKey();
1057
+ if (typeof key === "function") return key(row, index);
1058
+ if (typeof key === "string") return row[key];
1059
+ return index;
1060
+ };
1061
+ const idOf = (row, index) => String(keyOf(row, index));
1062
+ const projection = computed(() => projectServerQuery({
1063
+ query: query(),
1064
+ rowCount: totalRows(),
1065
+ cursors: cursors(),
1066
+ pageRows: rows().length
1067
+ }));
1068
+ const columnDefs = computed(() => columns().map((column) => ({
1069
+ id: column.field,
1070
+ accessorFn: (row) => valueAt(row, column.field),
1071
+ enableSorting: column.sortable !== false,
1072
+ filterType: columnTypeOf(column)
1073
+ })));
1074
+ const columnPinning = computed(() => ({
1075
+ start: columns().filter((column) => column.pinned === "left").map((column) => column.field),
1076
+ end: []
1077
+ }));
1078
+ /** Updates emitted so far: tells whether an action emitted one. */
1079
+ let emits = 0;
1080
+ const table = useTable({
1081
+ features,
1082
+ columns: columnDefs,
1083
+ get data() {
1084
+ return rows();
1085
+ },
1086
+ getRowId: (row, index) => idOf(row, index),
1087
+ get query() {
1088
+ return query();
1089
+ },
1090
+ onQueryChange: (next, reason) => {
1091
+ emits += 1;
1092
+ options.onQueryChange(next, reason);
1093
+ },
1094
+ get cursors() {
1095
+ return cursors();
1096
+ },
1097
+ get rowCount() {
1098
+ return totalRows() ?? void 0;
1099
+ },
1100
+ get pageCount() {
1101
+ return projection.value.pageCount;
1102
+ },
1103
+ get enableSorting() {
1104
+ return toValue(options.sortable) ?? false;
1105
+ },
1106
+ get filterDebounce() {
1107
+ return toValue(options.filterDebounce) ?? 100;
1108
+ },
1109
+ enableRowSelection: true,
1110
+ manualExpanding: true,
1111
+ getRowCanExpand: () => hasSubtable(),
1112
+ onRowSelectionChange: (updater) => {
1113
+ const current = toValue(options.selection) ?? {};
1114
+ options.onSelectionChange?.(selectedOnly(functionalUpdate(updater, current)));
1115
+ },
1116
+ state: {
1117
+ get sorting() {
1118
+ return projection.value.state.sorting;
1119
+ },
1120
+ get columnFilters() {
1121
+ return projection.value.state.columnFilters;
1122
+ },
1123
+ get pagination() {
1124
+ return projection.value.state.pagination;
1125
+ },
1126
+ get globalFilter() {
1127
+ return projection.value.state.globalFilter;
1128
+ },
1129
+ get rowSelection() {
1130
+ return toValue(options.selection) ?? {};
1131
+ },
1132
+ get columnPinning() {
1133
+ return columnPinning.value;
1134
+ }
1135
+ }
1136
+ });
1137
+ onScopeDispose(() => dispose(table));
1138
+ const columnById = (field) => table.getAllLeafColumns().find((column) => column.id === field);
1139
+ const entries = computed(() => {
1140
+ const byField = new Map(columns().map((column, index) => [column.field, {
1141
+ column,
1142
+ index
1143
+ }]));
1144
+ return [...table.getStartLeafColumns(), ...table.getCenterLeafColumns()].map((column) => byField.get(column.id)).filter((entry) => !!entry && !entry.column.hide);
1145
+ });
1146
+ const hasPinned = computed(() => entries.value.some((entry) => entry.column.pinned === "left"));
1147
+ /** Typed and not yet answered; `null` when the input shows the query. */
1148
+ const typed = shallowRef(null);
1149
+ let searchTimer;
1150
+ const cancelSearch = () => {
1151
+ if (searchTimer !== void 0) {
1152
+ clearTimeout(searchTimer);
1153
+ searchTimer = void 0;
1154
+ }
1155
+ };
1156
+ const applySearch = () => {
1157
+ const pending = searchTimer !== void 0;
1158
+ cancelSearch();
1159
+ if (!pending || typed.value === null) return false;
1160
+ const text = typed.value;
1161
+ const before = emits;
1162
+ table.setGlobalFilter(text);
1163
+ const emitted = emits !== before;
1164
+ if (!emitted || searchOf(query()) === text) typed.value = null;
1165
+ return emitted;
1166
+ };
1167
+ const setSearch = (text) => {
1168
+ typed.value = text;
1169
+ cancelSearch();
1170
+ const wait = toValue(options.searchDebounce) ?? 300;
1171
+ searchTimer = setTimeout(applySearch, Math.max(0, wait));
1172
+ if (wait <= 0 || text.trim() === "") applySearch();
1173
+ };
1174
+ watch(() => searchOf(query()), () => {
1175
+ if (searchTimer === void 0) typed.value = null;
1176
+ }, { flush: "sync" });
1177
+ onScopeDispose(cancelSearch);
1178
+ const search = {
1179
+ text: computed(() => typed.value ?? searchOf(query())),
1180
+ set: setSearch,
1181
+ apply: applySearch
1182
+ };
1183
+ const draftOf = (field) => columnById(field)?.getFilterInput() ?? blank;
1184
+ const filters = {
1185
+ draftOf,
1186
+ setInput: (field, text) => columnById(field)?.setFilterInput(text),
1187
+ apply: (field) => columnById(field)?.applyFilterInput(),
1188
+ flushAll: () => table.flushPendingFilters(),
1189
+ setCondition: (field, condition) => columnById(field)?.setFilterCondition(condition),
1190
+ clear: (field) => columnById(field)?.clearFilterInput(),
1191
+ clearAll: () => table.clearAllFilters(),
1192
+ canClearAll: () => table.getCanClearAllFilters(),
1193
+ labelOf: (field) => columnById(field)?.getFilterLabel() ?? null,
1194
+ multiOf: (field) => draftOf(field).multi ?? 0
1195
+ };
1196
+ const isSortable = (column) => (toValue(options.sortable) ?? false) && column.sortable !== false;
1197
+ const sort = {
1198
+ isSortable,
1199
+ sortOf: (column) => {
1200
+ const current = query().sort;
1201
+ return current?.field === column.field ? current.direction : null;
1202
+ },
1203
+ sortBy: (column, direction) => {
1204
+ const target = columnById(column.field);
1205
+ if (!isSortable(column) || !target) return;
1206
+ applySearch();
1207
+ if (direction) target.toggleSorting(direction === "desc", false);
1208
+ else target.toggleQuerySorting();
1209
+ }
1210
+ };
1211
+ const pageCountFor = (pageSize) => {
1212
+ const total = totalRows();
1213
+ return total !== null && pageSize >= 1 ? Math.max(1, Math.ceil(total / pageSize)) : null;
1214
+ };
1215
+ /** Page mode: there is a page after `base.page` (C-23). */
1216
+ const hasNext = (base) => {
1217
+ const count = pageCountFor(base.pageSize);
1218
+ return count !== null ? base.page < count : rows().length >= base.pageSize;
1219
+ };
1220
+ const baseQuery = () => table.getBaseQuery();
1221
+ /**
1222
+ * Applies pending search and filter text before a page action; `true`
1223
+ * when that changed the query, so the page asked for is dropped (C-14).
1224
+ */
1225
+ const flushBeforePage = () => {
1226
+ const searched = applySearch();
1227
+ const filtered = table.flushPendingFilters();
1228
+ return searched || filtered;
1229
+ };
1230
+ const goTo = (page) => {
1231
+ table.setPagination((old) => ({
1232
+ ...old,
1233
+ pageIndex: page - 1
1234
+ }));
1235
+ };
1236
+ const step = (by) => {
1237
+ table.setPagination((old) => ({
1238
+ ...old,
1239
+ pageIndex: old.pageIndex + by
1240
+ }));
1241
+ };
1242
+ const setPage = (page) => {
1243
+ if (!Number.isFinite(page) || flushBeforePage()) return;
1244
+ const base = baseQuery();
1245
+ if (isCursorQuery(base)) return;
1246
+ const count = pageCountFor(base.pageSize);
1247
+ const target = Math.max(1, Math.trunc(page));
1248
+ goTo(count === null ? target : Math.min(target, count));
1249
+ };
1250
+ const nextPage = () => {
1251
+ if (flushBeforePage()) return;
1252
+ const base = baseQuery();
1253
+ if (isCursorQuery(base)) step(1);
1254
+ else if (hasNext(base)) goTo(base.page + 1);
1255
+ };
1256
+ const previousPage = () => {
1257
+ if (flushBeforePage()) return;
1258
+ const base = baseQuery();
1259
+ if (isCursorQuery(base)) step(-1);
1260
+ else goTo(Math.max(1, base.page - 1));
1261
+ };
1262
+ const setPageSize = (size) => {
1263
+ if (!Number.isInteger(size) || size < 1) return;
1264
+ applySearch();
1265
+ table.flushPendingFilters();
1266
+ table.setPagination((old) => ({
1267
+ ...old,
1268
+ pageSize: size
1269
+ }));
1270
+ };
1271
+ const pagination = computed(() => {
1272
+ const current = query();
1273
+ const cursorMode = isCursorQuery(current);
1274
+ const around = cursors();
1275
+ return {
1276
+ page: cursorMode ? 1 : current.page,
1277
+ pageSize: current.pageSize,
1278
+ pageCount: cursorMode ? null : pageCountFor(current.pageSize),
1279
+ totalRows: totalRows(),
1280
+ pageSizeOptions: toValue(options.pageSizeOptions) ?? defaultPageSizes,
1281
+ canPrevious: cursorMode ? !!around?.prev : current.page > 1,
1282
+ canNext: cursorMode ? !!around?.next : hasNext(current),
1283
+ setPage,
1284
+ nextPage,
1285
+ previousPage,
1286
+ setPageSize,
1287
+ cursorMode
1288
+ };
1289
+ });
1290
+ const expanded = () => {
1291
+ const state = table.atoms.expanded.get();
1292
+ return state === true ? {} : state;
1293
+ };
1294
+ const setExpanded = (update) => {
1295
+ table.setExpanded((old) => update(old === true ? {} : { ...old }));
1296
+ };
1297
+ const expansion = {
1298
+ keyOf,
1299
+ isExpanded: (row, index) => hasSubtable() && !!expanded()[idOf(row, index)],
1300
+ toggle: (row, index) => {
1301
+ const id = idOf(row, index);
1302
+ setExpanded((state) => {
1303
+ if (state[id]) delete state[id];
1304
+ else state[id] = true;
1305
+ return state;
1306
+ });
1307
+ },
1308
+ collapseAll: () => table.setExpanded({}),
1309
+ expandAll: () => {
1310
+ if (hasSubtable()) setExpanded((state) => {
1311
+ rows().forEach((row, index) => {
1312
+ state[idOf(row, index)] = true;
1313
+ });
1314
+ return state;
1315
+ });
1316
+ }
1317
+ };
1318
+ watch(rows, (current) => {
1319
+ setExpanded((state) => {
1320
+ if (rowKey() === void 0) state = {};
1321
+ else {
1322
+ const present = new Set(current.map(idOf));
1323
+ for (const id of Object.keys(state)) if (!present.has(id)) delete state[id];
1324
+ }
1325
+ if (hasSubtable()) current.forEach((row, index) => {
1326
+ const seeded = row.isExpanded;
1327
+ if (seeded === true) state[idOf(row, index)] = true;
1328
+ else if (seeded === false) delete state[idOf(row, index)];
1329
+ });
1330
+ return state;
1331
+ });
1332
+ }, { immediate: true });
1333
+ return {
1334
+ table,
1335
+ columns: entries,
1336
+ hasPinned,
1337
+ sort,
1338
+ filters,
1339
+ search,
1340
+ pagination,
1341
+ expansion,
1342
+ selection: {
1343
+ enabled: computed(() => toValue(options.selection) !== void 0),
1344
+ isSelected: (row, index) => !!toValue(options.selection)?.[idOf(row, index)],
1345
+ toggle: (row, index) => {
1346
+ const id = idOf(row, index);
1347
+ table.setRowSelection((old) => {
1348
+ const next = { ...old };
1349
+ if (next[id]) delete next[id];
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)
1357
+ },
1358
+ baseQuery
1359
+ };
1360
+ }
1361
+ //#endregion
1362
+ //#region src/query-table.vue?vue&type=script&setup=true&lang.ts
1363
+ var _hoisted_1 = [
1364
+ "data-empty",
1365
+ "data-loading",
1366
+ "aria-busy"
1367
+ ];
1368
+ var _hoisted_2 = { class: "qt-table-responsive" };
1369
+ //#endregion
1370
+ //#region src/query-table.vue
1371
+ var query_table_default = /* @__PURE__ */ defineComponent({
1372
+ name: "QueryTable",
1373
+ __name: "query-table",
1374
+ props: {
1375
+ query: {},
1376
+ cursors: { default: null },
1377
+ selection: { default: void 0 },
1378
+ searchDebounce: { default: 300 },
1379
+ columns: {},
1380
+ rows: { default: () => [] },
1381
+ totalRows: { default: null },
1382
+ footerRows: { default: () => [] },
1383
+ loading: {
1384
+ type: Boolean,
1385
+ default: false
1386
+ },
1387
+ sortable: {
1388
+ type: Boolean,
1389
+ default: false
1390
+ },
1391
+ filterable: {
1392
+ type: Boolean,
1393
+ default: false
1394
+ },
1395
+ resizable: {
1396
+ type: Boolean,
1397
+ default: false
1398
+ },
1399
+ filterDebounce: { default: 100 },
1400
+ pagination: {},
1401
+ hasSubtable: {
1402
+ type: Boolean,
1403
+ default: false
1404
+ },
1405
+ hasRightPanel: {
1406
+ type: Boolean,
1407
+ default: false
1408
+ },
1409
+ rowKey: {
1410
+ type: [String, Function],
1411
+ default: void 0
1412
+ },
1413
+ labels: { default: void 0 }
1414
+ },
1415
+ emits: [
1416
+ "update:query",
1417
+ "update:selection",
1418
+ "rowRightPanelClick",
1419
+ "cellContextMenu",
1420
+ "columnResize"
1421
+ ],
1422
+ setup(__props, { expose: __expose, emit: __emit }) {
1423
+ const props = __props;
1424
+ const emit = __emit;
1425
+ const slots = useSlots();
1426
+ const rawSlots = useSlots();
1427
+ const state = useQueryTable({
1428
+ query: () => props.query,
1429
+ columns: () => props.columns,
1430
+ rows: () => props.rows,
1431
+ totalRows: () => props.totalRows,
1432
+ cursors: () => props.cursors,
1433
+ sortable: () => props.sortable,
1434
+ filterDebounce: () => props.filterDebounce,
1435
+ searchDebounce: () => props.searchDebounce,
1436
+ selection: () => props.selection,
1437
+ rowKey: () => props.rowKey,
1438
+ hasSubtable: () => props.hasSubtable,
1439
+ pageSizeOptions: () => props.pagination?.pageSizeOptions,
1440
+ onQueryChange: (query, reason) => emit("update:query", query, reason),
1441
+ onSelectionChange: (selection) => emit("update:selection", selection)
1442
+ });
1443
+ const { filters, sort, search, expansion } = state;
1444
+ const rowSelection = state.selection;
1445
+ const paginationProps = state.pagination;
1446
+ const labels = computed(() => resolveLabels(props.labels));
1447
+ const instance = getCurrentInstance();
1448
+ const hasContextMenuListener = () => {
1449
+ const vnodeProps = instance?.vnode.props;
1450
+ return !!(vnodeProps?.onCellContextMenu || vnodeProps?.onCellContextMenuOnce);
1451
+ };
1452
+ const entries = state.columns;
1453
+ const visibleColumns = computed(() => entries.value.map((e) => e.column));
1454
+ const hasPinned = state.hasPinned;
1455
+ /** Right panel first, then subtable, then selection (C-22: the first hosts clear-all). */
1456
+ const utilities = computed(() => [
1457
+ props.hasRightPanel ? "right-panel" : null,
1458
+ props.hasSubtable ? "subtable" : null,
1459
+ rowSelection.enabled.value ? "select" : null
1460
+ ].filter((name) => name !== null));
1461
+ const utilityCount = computed(() => utilities.value.length);
1462
+ const columnCount = computed(() => entries.value.length + utilityCount.value);
1463
+ const tableEl = shallowRef(null);
1464
+ const { widths, tableWidth, offsets } = useHeaderGeometry({
1465
+ table: tableEl,
1466
+ cells: () => [...utilities.value.map((utility) => ({
1467
+ key: utilityKey(utility),
1468
+ pinned: hasPinned.value
1469
+ })), ...entries.value.map(({ column }) => ({
1470
+ key: column.field,
1471
+ pinned: column.pinned === "left"
1472
+ }))],
1473
+ active: () => hasPinned.value || props.resizable && entries.value.some((entry) => entry.column.resizable !== false)
1474
+ });
1475
+ provideTableContext({
1476
+ filters,
1477
+ sort,
1478
+ resize: useColumnResize({
1479
+ resizable: () => props.resizable,
1480
+ measuredWidth: (field) => widths.value[field],
1481
+ tableWidth: () => tableWidth.value,
1482
+ emit: (payload) => emit("columnResize", payload)
1483
+ }),
1484
+ selection: rowSelection,
1485
+ labels: () => labels.value
1486
+ });
1487
+ const showPagination = computed(() => !!slots.pagination && (props.rows.length > 0 || (props.totalRows ?? 0) > 0 || (props.pagination?.alwaysShow ?? false)));
1488
+ const canClearFilters = computed(() => filters.canClearAll());
1489
+ const toolbarProps = () => ({
1490
+ canClearFilters: canClearFilters.value,
1491
+ clearFilters: () => {
1492
+ filters.clearAll();
1493
+ },
1494
+ search: search.text.value,
1495
+ setSearch: search.set,
1496
+ applySearch: () => {
1497
+ search.apply();
1498
+ }
1499
+ });
1500
+ const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading");
1501
+ const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join(" ");
1502
+ __expose({
1503
+ collapseAll: expansion.collapseAll,
1504
+ expandAll: expansion.expandAll,
1505
+ focusFilter: (field) => focusFilterOf(tableEl.value, field),
1506
+ flushPendingFilters: () => {
1507
+ filters.flushAll();
1508
+ }
1509
+ });
1510
+ return (_ctx, _cache) => {
1511
+ return openBlock(), createElementBlock("div", {
1512
+ class: "qt-datatable",
1513
+ "data-empty": !__props.loading && __props.rows.length === 0 ? "" : void 0,
1514
+ "data-loading": __props.loading ? "" : void 0,
1515
+ "aria-busy": __props.loading ? "true" : void 0
1516
+ }, [
1517
+ renderSlot(_ctx.$slots, "toolbar", normalizeProps(guardReactiveProps(toolbarProps()))),
1518
+ createElementVNode("div", _hoisted_2, [createElementVNode("table", {
1519
+ ref_key: "tableEl",
1520
+ ref: tableEl,
1521
+ class: "qt-table"
1522
+ }, [
1523
+ createElementVNode("thead", null, [createVNode(table_header_default, {
1524
+ columns: visibleColumns.value,
1525
+ query: __props.query,
1526
+ filterable: __props.filterable,
1527
+ utilities: utilities.value,
1528
+ "has-pinned": unref(hasPinned),
1529
+ offsets: unref(offsets),
1530
+ "slot-names": headerSlotNames()
1531
+ }, {
1532
+ header: withCtx((p) => [renderSlot(_ctx.$slots, `header-${p.column.field}`, normalizeProps(guardReactiveProps(p)))]),
1533
+ "filter-datetime": withCtx((p) => [renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(p)))]),
1534
+ "filter-menu": withCtx((p) => [renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(p)))]),
1535
+ _: 3
1536
+ }, 8, [
1537
+ "columns",
1538
+ "query",
1539
+ "filterable",
1540
+ "utilities",
1541
+ "has-pinned",
1542
+ "offsets",
1543
+ "slot-names"
1544
+ ])]),
1545
+ createVNode(table_body_default, {
1546
+ rows: __props.rows,
1547
+ loading: __props.loading,
1548
+ entries: unref(entries),
1549
+ "column-count": columnCount.value,
1550
+ "has-subtable": __props.hasSubtable,
1551
+ "has-right-panel": __props.hasRightPanel,
1552
+ "has-selection": unref(rowSelection).enabled.value,
1553
+ "is-selected": unref(rowSelection).isSelected,
1554
+ "toggle-selected": unref(rowSelection).toggle,
1555
+ "has-pinned": unref(hasPinned),
1556
+ offsets: unref(offsets),
1557
+ "key-of": unref(expansion).keyOf,
1558
+ "is-expanded": unref(expansion).isExpanded,
1559
+ toggle: unref(expansion).toggle,
1560
+ labels: labels.value,
1561
+ "has-context-menu-listener": hasContextMenuListener,
1562
+ onRowRightPanelClick: _cache[0] || (_cache[0] = (row) => emit("rowRightPanelClick", row)),
1563
+ onCellContextMenu: _cache[1] || (_cache[1] = (payload) => emit("cellContextMenu", payload))
1564
+ }, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
1565
+ return {
1566
+ name,
1567
+ fn: withCtx((p) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(p)))])
1568
+ };
1569
+ })]), 1032, [
1570
+ "rows",
1571
+ "loading",
1572
+ "entries",
1573
+ "column-count",
1574
+ "has-subtable",
1575
+ "has-right-panel",
1576
+ "has-selection",
1577
+ "is-selected",
1578
+ "toggle-selected",
1579
+ "has-pinned",
1580
+ "offsets",
1581
+ "key-of",
1582
+ "is-expanded",
1583
+ "toggle",
1584
+ "labels"
1585
+ ]),
1586
+ __props.footerRows.length > 0 ? (openBlock(), createBlock(table_footer_default, {
1587
+ key: 0,
1588
+ "footer-rows": __props.footerRows,
1589
+ entries: unref(entries),
1590
+ "utility-count": utilityCount.value,
1591
+ "has-pinned": unref(hasPinned),
1592
+ offsets: unref(offsets)
1593
+ }, null, 8, [
1594
+ "footer-rows",
1595
+ "entries",
1596
+ "utility-count",
1597
+ "has-pinned",
1598
+ "offsets"
1599
+ ])) : createCommentVNode("", true)
1600
+ ], 512)]),
1601
+ showPagination.value ? (openBlock(), createBlock(table_pagination_default, {
1602
+ key: 0,
1603
+ "pagination-props": unref(paginationProps)
1604
+ }, {
1605
+ pagination: withCtx((p) => [renderSlot(_ctx.$slots, "pagination", normalizeProps(guardReactiveProps(p)))]),
1606
+ _: 3
1607
+ }, 8, ["pagination-props"])) : createCommentVNode("", true)
1608
+ ], 8, _hoisted_1);
1609
+ };
1610
+ }
1611
+ });
1612
+ //#endregion
1613
+ //#region src/filter/parse-filter-input.ts
1614
+ /**
1615
+ * The rules the table emits when `text` is typed into the filter input of
1616
+ * `column` (C-53): the same grammar and the same coercion per column type.
1617
+ *
1618
+ * - `string`: operator shortcuts (`*a*`, `a*`, `*a`, `!a`, `!*a*`, `a,b`);
1619
+ * a segment without an operator uses `condition`.
1620
+ * - `number`: one rule with a number value; text that is not a finite number
1621
+ * gives `[]`.
1622
+ * - `integer`: the same, but only a whole number; `2.5` gives `[]`.
1623
+ * - `bool`: `'true'` or `'false'` gives one rule with a boolean value;
1624
+ * anything else gives `[]`.
1625
+ * - `date` and `datetime`: one rule with the trimmed text as its value; the
1626
+ * text is not validated, as the input already gives an ISO date.
1627
+ *
1628
+ * `condition` is the one picked in the filter menu; without it the column
1629
+ * type's default applies (`Contains` for text, `Equal` otherwise). Empty or
1630
+ * blank text, and text that is only operators (`*`, `!`, `!*`), gives `[]`.
1631
+ * Invalid input never throws. Pure: no Vue, no DOM; the column is not written.
1632
+ * The grammar is the protocol's (`@dolusoft/query-protocol`).
1633
+ */
1634
+ function parseFilterInput(text, column, condition = null) {
1635
+ return parseFilterInput$1(text, column, condition);
1636
+ }
1637
+ //#endregion
1638
+ //#region src/index.ts
1639
+ var src_default = query_table_default;
1640
+ //#endregion
1641
+ export { query_table_default as QueryTable, src_default as default, parseFilterInput, useQueryTable };
1642
+
1643
+ //# sourceMappingURL=query-table.js.map