@dolusoft/query-table 3.19.0 → 3.21.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/cells.js +203 -0
- package/dist/cells.js.map +1 -0
- package/dist/data-table.js +2 -1
- package/dist/data-table.js.map +1 -1
- package/dist/query-table.js +1 -1
- package/dist/{src-BTIXBmwM.js → src-DvUx4ur-.js} +456 -86
- package/dist/src-DvUx4ur-.js.map +1 -0
- package/dist/table-labels-DYrDE2Sq.js +58 -0
- package/dist/table-labels-DYrDE2Sq.js.map +1 -0
- package/dist/types/cells/cell-action.vue.d.ts +16 -0
- package/dist/types/cells/cell-actions.vue.d.ts +13 -0
- package/dist/types/cells/cell-badge.vue.d.ts +17 -0
- package/dist/types/cells/cell-copy.vue.d.ts +8 -0
- package/dist/types/cells/cell-preview.vue.d.ts +8 -0
- package/dist/types/cells/cell-stack.vue.d.ts +16 -0
- package/dist/types/cells/cell-value.vue.d.ts +4 -0
- package/dist/types/cells/contract.d.ts +44 -0
- package/dist/types/cells/index.d.ts +8 -0
- package/dist/types/contract.d.ts +64 -0
- package/dist/types/core/cell-labels.d.ts +10 -0
- package/dist/types/core/table-context.d.ts +20 -2
- package/dist/types/core/table-labels.d.ts +20 -0
- package/dist/types/parts/table-body.vue.d.ts +2 -0
- package/dist/types/parts/table-row.d.ts +17 -1
- package/dist/types/resize/grow-shares.d.ts +29 -0
- package/dist/types/resize/use-column-resize.d.ts +7 -0
- package/dist/types/resize/use-growing-columns.d.ts +37 -0
- package/dist/types/use-query-table.d.ts +23 -3
- package/package.json +7 -3
- package/dist/src-BTIXBmwM.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as cellLabelDefaults, i as useTableContext, r as provideTableContext, t as IconSlot } from "./table-labels-DYrDE2Sq.js";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, effectScope, getCurrentInstance, getCurrentScope, guardReactiveProps, h, mergeProps, nextTick, normalizeProps, normalizeStyle, onActivated, onBeforeUnmount, onBeforeUpdate, onDeactivated, onMounted, onScopeDispose, openBlock, renderList, renderSlot, shallowRef, toDisplayString, toHandlers, toValue, unref, useSlots, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
|
|
2
3
|
import { cloneQuery, columnTypeOf, columnTypeOf as columnTypeOf$1, conditionArity, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput, rulesOf, sameQuery, searchOf } from "@dolusoft/query-protocol";
|
|
3
4
|
import { createRowChangeTracker } from "@dolusoft/query-table-core/row-changes";
|
|
4
5
|
import { dispose, filterInputFeature, projectServerQuery, serverQueryFeature } from "@dolusoft/query-table-core";
|
|
@@ -265,7 +266,8 @@ var defaultLabels = {
|
|
|
265
266
|
boolTrue: "True",
|
|
266
267
|
boolFalse: "False",
|
|
267
268
|
selectRow: "Select row",
|
|
268
|
-
selectAllRows: "Select all rows"
|
|
269
|
+
selectAllRows: "Select all rows",
|
|
270
|
+
...cellLabelDefaults
|
|
269
271
|
};
|
|
270
272
|
var resolveLabels = (labels) => ({
|
|
271
273
|
...defaultLabels,
|
|
@@ -274,17 +276,6 @@ var resolveLabels = (labels) => ({
|
|
|
274
276
|
/** The name of a column in a label: its `title`, else its `field`. */
|
|
275
277
|
var columnName = (column) => column.title || column.field;
|
|
276
278
|
//#endregion
|
|
277
|
-
//#region src/core/table-context.ts
|
|
278
|
-
var tableContextKey = Symbol("query-table");
|
|
279
|
-
var provideTableContext = (context) => {
|
|
280
|
-
provide(tableContextKey, context);
|
|
281
|
-
};
|
|
282
|
-
var useTableContext = () => {
|
|
283
|
-
const context = inject(tableContextKey);
|
|
284
|
-
if (!context) throw new Error("Header parts must be rendered inside a QueryTable");
|
|
285
|
-
return context;
|
|
286
|
-
};
|
|
287
|
-
//#endregion
|
|
288
279
|
//#region src/filter/focus-filter.ts
|
|
289
280
|
var focusable = "input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
290
281
|
/**
|
|
@@ -949,6 +940,7 @@ var expandDynamic = [
|
|
|
949
940
|
var selectDynamic = [
|
|
950
941
|
"aria-label",
|
|
951
942
|
"checked",
|
|
943
|
+
"disabled",
|
|
952
944
|
"onChange"
|
|
953
945
|
];
|
|
954
946
|
/** Text of a cell, whole: the table never cuts it. */
|
|
@@ -980,6 +972,8 @@ var tableRow = defineComponent({
|
|
|
980
972
|
/** `data-row-kind` (C-97); `undefined` for none. */
|
|
981
973
|
kind: value(),
|
|
982
974
|
selected: needed(),
|
|
975
|
+
/** The checkbox can be used; `disabled` otherwise (C-130). */
|
|
976
|
+
selectable: needed(),
|
|
983
977
|
expanded: needed(),
|
|
984
978
|
/** An expand button is drawn (C-98). */
|
|
985
979
|
expandable: needed(),
|
|
@@ -1026,25 +1020,26 @@ var tableRow = defineComponent({
|
|
|
1026
1020
|
onVnodeBeforeMount: props.flashBind ? bind : void 0,
|
|
1027
1021
|
onVnodeUpdated: props.flashBind ? bind : void 0
|
|
1028
1022
|
}, [
|
|
1029
|
-
utilities.panel ? (openBlock(), createElementBlock("td", mergeProps({ key: 0 }, utilities.panel), [createElementVNode("button", {
|
|
1023
|
+
utilities.panel ? (openBlock(), createElementBlock("td", mergeProps({ key: utilities.panelSlot ? 3 : 0 }, utilities.panel), [createElementVNode("button", {
|
|
1030
1024
|
type: "button",
|
|
1031
1025
|
class: "qt-right-panel-button",
|
|
1032
1026
|
"aria-label": props.labelPanel,
|
|
1033
1027
|
onClick: onPanel
|
|
1034
|
-
}, [...panelCache ??= [panelIcon()]], 8, panelDynamic)], 16)) : off(),
|
|
1035
|
-
utilities.expand ? (openBlock(), createElementBlock("td", mergeProps({ key: 1 }, utilities.expand), [props.expandable ? (openBlock(), createElementBlock("button", {
|
|
1028
|
+
}, utilities.panelSlot ? [renderSlot(utilities.iconSlots, "icon-right-panel")] : [...panelCache ??= [panelIcon()]], 8, panelDynamic)], 16)) : off(),
|
|
1029
|
+
utilities.expand ? (openBlock(), createElementBlock("td", mergeProps({ key: utilities.expandSlot ? 4 : 1 }, utilities.expand), [props.expandable ? (openBlock(), createElementBlock("button", {
|
|
1036
1030
|
key: 0,
|
|
1037
1031
|
type: "button",
|
|
1038
1032
|
class: "qt-expand",
|
|
1039
1033
|
"aria-expanded": props.expanded,
|
|
1040
1034
|
"aria-label": props.labelExpand,
|
|
1041
1035
|
onClick: onToggle
|
|
1042
|
-
}, [(openBlock(), createElementBlock("svg", expandIcon, [props.expanded ? (openBlock(), createElementBlock("polyline", chevronDown)) : (openBlock(), createElementBlock("polyline", chevronRight))]))], 8, expandDynamic)) : off()], 16)) : off(),
|
|
1036
|
+
}, [utilities.expandSlot ? renderSlot(utilities.iconSlots, "icon-expand", { expanded: props.expanded }) : (openBlock(), createElementBlock("svg", expandIcon, [props.expanded ? (openBlock(), createElementBlock("polyline", chevronDown)) : (openBlock(), createElementBlock("polyline", chevronRight))]))], 8, expandDynamic)) : off()], 16)) : off(),
|
|
1043
1037
|
utilities.select ? (openBlock(), createElementBlock("td", mergeProps({ key: 2 }, utilities.select), [createElementVNode("input", {
|
|
1044
1038
|
type: "checkbox",
|
|
1045
1039
|
class: "qt-select-row",
|
|
1046
1040
|
"aria-label": props.labelSelect,
|
|
1047
1041
|
checked: props.selected,
|
|
1042
|
+
disabled: !props.selectable,
|
|
1048
1043
|
onChange: onSelect
|
|
1049
1044
|
}, null, 40, selectDynamic)], 16)) : off(),
|
|
1050
1045
|
(openBlock(true), createElementBlock(Fragment, null, renderList(cells, (cell) => (openBlock(), createElementBlock(Fragment, { key: cell.field }, [cell.slot ? (openBlock(), createElementBlock("td", mergeProps({ key: 0 }, cell.attrs, { "data-flash": cellFlash?.[cell.field] }), [renderSlot(slots, cell.slot, {
|
|
@@ -1112,6 +1107,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
1112
1107
|
hasRightPanel: { type: Boolean },
|
|
1113
1108
|
hasSelection: { type: Boolean },
|
|
1114
1109
|
isSelected: { type: Function },
|
|
1110
|
+
canSelect: { type: Function },
|
|
1115
1111
|
toggleSelected: { type: Function },
|
|
1116
1112
|
hasPinned: { type: Boolean },
|
|
1117
1113
|
offsets: {},
|
|
@@ -1184,15 +1180,18 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
1184
1180
|
});
|
|
1185
1181
|
return same && previous ? previous : next;
|
|
1186
1182
|
});
|
|
1183
|
+
const { icons } = useTableContext();
|
|
1187
1184
|
const utilities = computed((previous) => {
|
|
1188
1185
|
const role = cellRole();
|
|
1189
1186
|
const side = props.hasPinned ? "left" : false;
|
|
1190
1187
|
const offsetOf = (utility) => props.offsets[utilityKey(utility)];
|
|
1188
|
+
const panelSlot = props.hasRightPanel && icons.has("right-panel");
|
|
1189
|
+
const expandSlot = props.hasSubtable && icons.has("expand");
|
|
1191
1190
|
const signature = [
|
|
1192
1191
|
role,
|
|
1193
1192
|
side,
|
|
1194
|
-
props.hasRightPanel && `p${offsetOf("right-panel")}`,
|
|
1195
|
-
props.hasSubtable && `e${offsetOf("subtable")}`,
|
|
1193
|
+
props.hasRightPanel && `p${offsetOf("right-panel")}${panelSlot ? "i" : ""}`,
|
|
1194
|
+
props.hasSubtable && `e${offsetOf("subtable")}${expandSlot ? "i" : ""}`,
|
|
1196
1195
|
props.hasSelection && `s${offsetOf("select")}`
|
|
1197
1196
|
].join("|");
|
|
1198
1197
|
if (previous?.signature === signature) return previous;
|
|
@@ -1204,6 +1203,9 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
1204
1203
|
panel: attrs(props.hasRightPanel, "right-panel"),
|
|
1205
1204
|
expand: attrs(props.hasSubtable, "subtable"),
|
|
1206
1205
|
select: attrs(props.hasSelection, "select"),
|
|
1206
|
+
iconSlots: panelSlot || expandSlot ? icons.slots : null,
|
|
1207
|
+
panelSlot,
|
|
1208
|
+
expandSlot,
|
|
1207
1209
|
signature
|
|
1208
1210
|
};
|
|
1209
1211
|
});
|
|
@@ -1268,6 +1270,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
1268
1270
|
pinned: item.pinned,
|
|
1269
1271
|
kind: kindOf(item),
|
|
1270
1272
|
selected: __props.hasSelection && __props.isSelected(item.row, item.index),
|
|
1273
|
+
selectable: !__props.hasSelection || __props.canSelect(item.row, item.index),
|
|
1271
1274
|
expanded: isRowExpanded(item),
|
|
1272
1275
|
expandable: __props.hasSubtable && __props.canExpand(item.row, item.index),
|
|
1273
1276
|
flash: __props.flash ? __props.flash.of(__props.keyOf(item.row, item.index)) : void 0,
|
|
@@ -1291,6 +1294,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
1291
1294
|
"pinned",
|
|
1292
1295
|
"kind",
|
|
1293
1296
|
"selected",
|
|
1297
|
+
"selectable",
|
|
1294
1298
|
"expanded",
|
|
1295
1299
|
"expandable",
|
|
1296
1300
|
"flash",
|
|
@@ -1400,17 +1404,23 @@ var filter_icon_default = /* @__PURE__ */ defineComponent({
|
|
|
1400
1404
|
props: { filled: { type: Boolean } },
|
|
1401
1405
|
setup(__props) {
|
|
1402
1406
|
return (_ctx, _cache) => {
|
|
1403
|
-
return openBlock(),
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1407
|
+
return openBlock(), createBlock(unref(IconSlot), {
|
|
1408
|
+
name: "filter",
|
|
1409
|
+
state: { filled: __props.filled }
|
|
1410
|
+
}, {
|
|
1411
|
+
default: withCtx(() => [(openBlock(), createElementBlock("svg", {
|
|
1412
|
+
viewBox: "0 0 24 24",
|
|
1413
|
+
width: "14",
|
|
1414
|
+
height: "14",
|
|
1415
|
+
stroke: "currentColor",
|
|
1416
|
+
"stroke-width": "1.5",
|
|
1417
|
+
fill: __props.filled ? "currentColor" : "none",
|
|
1418
|
+
"stroke-linecap": "round",
|
|
1419
|
+
"stroke-linejoin": "round",
|
|
1420
|
+
"aria-hidden": "true"
|
|
1421
|
+
}, [..._cache[0] || (_cache[0] = [createElementVNode("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" }, null, -1)])], 8, _hoisted_1$7))]),
|
|
1422
|
+
_: 1
|
|
1423
|
+
}, 8, ["state"]);
|
|
1414
1424
|
};
|
|
1415
1425
|
}
|
|
1416
1426
|
});
|
|
@@ -1668,7 +1678,47 @@ var reorder_handle_default = /* @__PURE__ */ defineComponent({
|
|
|
1668
1678
|
class: "qt-reorder-handle",
|
|
1669
1679
|
"aria-label": unref(labels)().moveColumn(unref(columnName)(__props.column)),
|
|
1670
1680
|
"aria-keyshortcuts": "ArrowLeft ArrowRight Home End"
|
|
1671
|
-
}, toHandlers(unref(on), true)), [
|
|
1681
|
+
}, toHandlers(unref(on), true)), [createVNode(unref(IconSlot), { name: "reorder" }, {
|
|
1682
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createElementVNode("svg", {
|
|
1683
|
+
width: "14",
|
|
1684
|
+
height: "14",
|
|
1685
|
+
viewBox: "0 0 24 24",
|
|
1686
|
+
fill: "currentColor",
|
|
1687
|
+
"aria-hidden": "true"
|
|
1688
|
+
}, [
|
|
1689
|
+
createElementVNode("circle", {
|
|
1690
|
+
cx: "9",
|
|
1691
|
+
cy: "6",
|
|
1692
|
+
r: "1.5"
|
|
1693
|
+
}),
|
|
1694
|
+
createElementVNode("circle", {
|
|
1695
|
+
cx: "15",
|
|
1696
|
+
cy: "6",
|
|
1697
|
+
r: "1.5"
|
|
1698
|
+
}),
|
|
1699
|
+
createElementVNode("circle", {
|
|
1700
|
+
cx: "9",
|
|
1701
|
+
cy: "12",
|
|
1702
|
+
r: "1.5"
|
|
1703
|
+
}),
|
|
1704
|
+
createElementVNode("circle", {
|
|
1705
|
+
cx: "15",
|
|
1706
|
+
cy: "12",
|
|
1707
|
+
r: "1.5"
|
|
1708
|
+
}),
|
|
1709
|
+
createElementVNode("circle", {
|
|
1710
|
+
cx: "9",
|
|
1711
|
+
cy: "18",
|
|
1712
|
+
r: "1.5"
|
|
1713
|
+
}),
|
|
1714
|
+
createElementVNode("circle", {
|
|
1715
|
+
cx: "15",
|
|
1716
|
+
cy: "18",
|
|
1717
|
+
r: "1.5"
|
|
1718
|
+
})
|
|
1719
|
+
], -1)])]),
|
|
1720
|
+
_: 1
|
|
1721
|
+
})], 16, _hoisted_1$5);
|
|
1672
1722
|
};
|
|
1673
1723
|
}
|
|
1674
1724
|
});
|
|
@@ -1946,11 +1996,6 @@ var cellOf = (event) => event.currentTarget.closest("th");
|
|
|
1946
1996
|
*/
|
|
1947
1997
|
var edgeOf = (column) => column.pinned === "right" ? -1 : 1;
|
|
1948
1998
|
/**
|
|
1949
|
-
* The scale of a column's widths, read from the layout once per drag or key:
|
|
1950
|
-
* a table stretched to its container draws a column wider than declared.
|
|
1951
|
-
*/
|
|
1952
|
-
var scaleOf = (th, column) => measureWidthScale(th, clampWidth(column, 0));
|
|
1953
|
-
/**
|
|
1954
1999
|
* Resizing a column (C-48 to C-50). The table holds a width only while a
|
|
1955
2000
|
* drag is under way (the preview, P2); every committed width goes out as a
|
|
1956
2001
|
* `columnResize` event and comes back, if the consumer wants it, as
|
|
@@ -1964,12 +2009,24 @@ var useColumnResize = (options) => {
|
|
|
1964
2009
|
const preview = shallowRef(null);
|
|
1965
2010
|
let drag = null;
|
|
1966
2011
|
const isResizable = (column) => options.resizable() && column.resizable !== false;
|
|
2012
|
+
/**
|
|
2013
|
+
* The scale of a column's widths, read from the layout once per drag or
|
|
2014
|
+
* key: a table stretched to its container draws a column wider than
|
|
2015
|
+
* declared. A table whose growing columns take the room is not stretched:
|
|
2016
|
+
* they take the difference instead (C-132).
|
|
2017
|
+
*/
|
|
2018
|
+
const scaleOf = (th, column) => options.growing?.() ? identityScale : measureWidthScale(th, clampWidth(column, 0));
|
|
1967
2019
|
/** The width the header shows: the preview while dragging, else measured. */
|
|
1968
2020
|
const widthOf = (column) => preview.value?.field === column.field ? preview.value.rendered : Math.round(options.measuredWidth(column.field) ?? 0);
|
|
1969
|
-
/**
|
|
1970
|
-
const
|
|
1971
|
-
|
|
1972
|
-
|
|
2021
|
+
/** What a declared width `width` is emitted as (C-132, D-05). */
|
|
2022
|
+
const out = (column, width) => options.emitted ? options.emitted(column.field, width) : width;
|
|
2023
|
+
/**
|
|
2024
|
+
* Emits the declared width `width`, unless it is the declared `from`.
|
|
2025
|
+
* `fitted` is a width already emitted as it is: autofit's.
|
|
2026
|
+
*/
|
|
2027
|
+
const commit = (column, from, width, fitted = false) => {
|
|
2028
|
+
const next = clampWidth(column, fitted ? width : out(column, width));
|
|
2029
|
+
if (next !== Math.round(out(column, from))) options.emit({
|
|
1973
2030
|
field: column.field,
|
|
1974
2031
|
width: next
|
|
1975
2032
|
});
|
|
@@ -2043,7 +2100,7 @@ var useColumnResize = (options) => {
|
|
|
2043
2100
|
const from = scale.declared(drawn);
|
|
2044
2101
|
const step = scale.declared(Math.round(drawn) + sign * (event.shiftKey ? 50 : 10));
|
|
2045
2102
|
const to = sign ? from + sign * Math.max(1, Math.abs(step - from)) : measureColumnWidths(th.closest("table"), [column.field], options.body(), { filters: true })[column.field];
|
|
2046
|
-
if (to !== void 0) commit(column, from, to);
|
|
2103
|
+
if (to !== void 0) commit(column, from, to, !sign);
|
|
2047
2104
|
}
|
|
2048
2105
|
};
|
|
2049
2106
|
/**
|
|
@@ -2160,19 +2217,25 @@ var sort_button_default = /* @__PURE__ */ defineComponent({
|
|
|
2160
2217
|
class: "qt-sort",
|
|
2161
2218
|
"aria-label": __props.column.title ? void 0 : __props.column.field,
|
|
2162
2219
|
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click"))
|
|
2163
|
-
}, [createTextVNode(toDisplayString(__props.column.title) + " ", 1),
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
},
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2220
|
+
}, [createTextVNode(toDisplayString(__props.column.title) + " ", 1), createVNode(unref(IconSlot), {
|
|
2221
|
+
name: "sort",
|
|
2222
|
+
state: { direction: __props.direction ?? false }
|
|
2223
|
+
}, {
|
|
2224
|
+
default: withCtx(() => [__props.direction === "asc" ? (openBlock(), createElementBlock("svg", _hoisted_2$2, [..._cache[1] || (_cache[1] = [createElementVNode("path", {
|
|
2225
|
+
d: "M8 3.5L12.5 9.5H3.5L8 3.5Z",
|
|
2226
|
+
fill: "currentColor"
|
|
2227
|
+
}, null, -1)])])) : __props.direction === "desc" ? (openBlock(), createElementBlock("svg", _hoisted_3$2, [..._cache[2] || (_cache[2] = [createElementVNode("path", {
|
|
2228
|
+
d: "M8 12.5L3.5 6.5H12.5L8 12.5Z",
|
|
2229
|
+
fill: "currentColor"
|
|
2230
|
+
}, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_4$2, [..._cache[3] || (_cache[3] = [createElementVNode("path", {
|
|
2231
|
+
d: "M8 3L11.5 7H4.5L8 3Z",
|
|
2232
|
+
fill: "currentColor"
|
|
2233
|
+
}, null, -1), createElementVNode("path", {
|
|
2234
|
+
d: "M8 13L4.5 9H11.5L8 13Z",
|
|
2235
|
+
fill: "currentColor"
|
|
2236
|
+
}, null, -1)])]))]),
|
|
2237
|
+
_: 1
|
|
2238
|
+
}, 8, ["state"])], 8, _hoisted_1$3);
|
|
2176
2239
|
};
|
|
2177
2240
|
}
|
|
2178
2241
|
});
|
|
@@ -2187,7 +2250,8 @@ var _hoisted_2$1 = ["role"];
|
|
|
2187
2250
|
var _hoisted_3$1 = [
|
|
2188
2251
|
"aria-label",
|
|
2189
2252
|
"checked",
|
|
2190
|
-
"indeterminate"
|
|
2253
|
+
"indeterminate",
|
|
2254
|
+
"disabled"
|
|
2191
2255
|
];
|
|
2192
2256
|
var _hoisted_4$1 = ["role"];
|
|
2193
2257
|
var _hoisted_5$1 = ["role"];
|
|
@@ -2227,7 +2291,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
2227
2291
|
setup(__props) {
|
|
2228
2292
|
const props = __props;
|
|
2229
2293
|
const given = (name) => props.slotNames.split("\n").includes(name);
|
|
2230
|
-
const { filters, sort, layout, resize, reorder, selection, labels } = useTableContext();
|
|
2294
|
+
const { filters, sort, layout, resize, reorder, selection, labels, grow } = useTableContext();
|
|
2231
2295
|
const dragAttrs = (column) => {
|
|
2232
2296
|
const drag = reorder.dragging.value;
|
|
2233
2297
|
return {
|
|
@@ -2251,6 +2315,8 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
2251
2315
|
const hostsClearAll = (utility) => props.filterable && utility === props.utilities.find((candidate) => candidate !== "select");
|
|
2252
2316
|
const utilityAttrs = (utility) => pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)]);
|
|
2253
2317
|
const widthOf = (column) => {
|
|
2318
|
+
const grown = grow.widthOf(column.field);
|
|
2319
|
+
if (grown !== void 0) return `${grown}px`;
|
|
2254
2320
|
if (column.width) return column.width;
|
|
2255
2321
|
const auto = props.autoWidths[column.field];
|
|
2256
2322
|
return auto === void 0 ? void 0 : `${auto}px`;
|
|
@@ -2280,6 +2346,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
2280
2346
|
"aria-label": unref(labels)().selectAllRows,
|
|
2281
2347
|
checked: unref(selection).allSelected.value,
|
|
2282
2348
|
indeterminate: unref(selection).someSelected.value,
|
|
2349
|
+
disabled: !unref(selection).canToggleAll.value,
|
|
2283
2350
|
onChange: _cache[0] || (_cache[0] = ($event) => unref(selection).toggleAll($event.target.checked))
|
|
2284
2351
|
}, null, 40, _hoisted_3$1)], 16, _hoisted_2$1)) : !hostsClearAll(utility) ? (openBlock(), createElementBlock("td", mergeProps({
|
|
2285
2352
|
key: 1,
|
|
@@ -2295,27 +2362,30 @@ var table_header_default = /* @__PURE__ */ defineComponent({
|
|
|
2295
2362
|
"aria-label": unref(labels)().clearAllFilters,
|
|
2296
2363
|
disabled: !canClearAll.value,
|
|
2297
2364
|
onClick: withModifiers(onClearAll, ["stop"])
|
|
2298
|
-
}, [
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2365
|
+
}, [createVNode(unref(IconSlot), { name: "clear-all" }, {
|
|
2366
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
|
|
2367
|
+
width: "14",
|
|
2368
|
+
height: "14",
|
|
2369
|
+
viewBox: "0 0 24 24",
|
|
2370
|
+
fill: "none",
|
|
2371
|
+
stroke: "currentColor",
|
|
2372
|
+
"stroke-width": "2",
|
|
2373
|
+
"stroke-linecap": "round",
|
|
2374
|
+
"stroke-linejoin": "round",
|
|
2375
|
+
"aria-hidden": "true"
|
|
2376
|
+
}, [createElementVNode("line", {
|
|
2377
|
+
x1: "18",
|
|
2378
|
+
y1: "6",
|
|
2379
|
+
x2: "6",
|
|
2380
|
+
y2: "18"
|
|
2381
|
+
}), createElementVNode("line", {
|
|
2382
|
+
x1: "6",
|
|
2383
|
+
y1: "6",
|
|
2384
|
+
x2: "18",
|
|
2385
|
+
y2: "18"
|
|
2386
|
+
})], -1)])]),
|
|
2387
|
+
_: 1
|
|
2388
|
+
})], 8, _hoisted_6)], 16, _hoisted_5$1))], 64);
|
|
2319
2389
|
}), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
|
|
2320
2390
|
return openBlock(), createElementBlock("th", mergeProps({
|
|
2321
2391
|
key: column.field,
|
|
@@ -2646,7 +2716,7 @@ var sameWidths = (a, b) => {
|
|
|
2646
2716
|
const keys = Object.keys(a);
|
|
2647
2717
|
return keys.length === Object.keys(b).length && keys.every((key) => a[key] === b[key]);
|
|
2648
2718
|
};
|
|
2649
|
-
var none = Object.freeze({});
|
|
2719
|
+
var none$1 = Object.freeze({});
|
|
2650
2720
|
/**
|
|
2651
2721
|
* Automatic column widths (C-100, ADR 0014). With `autoWidth`, every visible
|
|
2652
2722
|
* column without `Column.width` is measured (C-99) after the drawn rows
|
|
@@ -2657,7 +2727,7 @@ var none = Object.freeze({});
|
|
|
2657
2727
|
* page, a sort or a live tick never narrows a column.
|
|
2658
2728
|
*/
|
|
2659
2729
|
var useAutoWidth = (options) => {
|
|
2660
|
-
const widths = shallowRef(none);
|
|
2730
|
+
const widths = shallowRef(none$1);
|
|
2661
2731
|
/** The result the widths were last measured for, `null` before one. */
|
|
2662
2732
|
let result = null;
|
|
2663
2733
|
/** The next measure starts over: the result moved before it could run. */
|
|
@@ -2667,7 +2737,7 @@ var useAutoWidth = (options) => {
|
|
|
2667
2737
|
let observer = null;
|
|
2668
2738
|
const autoColumns = () => options.columns().filter((column) => !column.width);
|
|
2669
2739
|
const clear = () => {
|
|
2670
|
-
widths.value = none;
|
|
2740
|
+
widths.value = none$1;
|
|
2671
2741
|
result = null;
|
|
2672
2742
|
fromScratch = false;
|
|
2673
2743
|
waiting = false;
|
|
@@ -2738,6 +2808,264 @@ var useAutoWidth = (options) => {
|
|
|
2738
2808
|
return { widths };
|
|
2739
2809
|
};
|
|
2740
2810
|
//#endregion
|
|
2811
|
+
//#region src/resize/grow-shares.ts
|
|
2812
|
+
/**
|
|
2813
|
+
* The share of `room` each growing column takes, by `field`, in whole
|
|
2814
|
+
* pixels (K321-2). The room is divided by the weights; a column that would
|
|
2815
|
+
* pass its `max` stops there and the others divide what it leaves, as
|
|
2816
|
+
* flexbox does. Each share is rounded down and the pixels the rounding
|
|
2817
|
+
* leaves go to the last column that is not at its `max`, so the shares add up
|
|
2818
|
+
* to the whole pixels of the room. When every column is at its `max`, what is
|
|
2819
|
+
* left is not given out. No room, no shares.
|
|
2820
|
+
*/
|
|
2821
|
+
var divideRoom = (room, columns) => {
|
|
2822
|
+
const shares = {};
|
|
2823
|
+
if (!(room >= 1) || columns.length === 0) return shares;
|
|
2824
|
+
const exact = /* @__PURE__ */ new Map();
|
|
2825
|
+
let open = columns.filter((column) => column.weight > 0);
|
|
2826
|
+
let left = room;
|
|
2827
|
+
for (;;) {
|
|
2828
|
+
const total = open.reduce((sum, column) => sum + column.weight, 0);
|
|
2829
|
+
const capped = open.find((column) => column.max !== void 0 && column.base + left * column.weight / total > column.max);
|
|
2830
|
+
if (!capped) {
|
|
2831
|
+
for (const column of open) exact.set(column.field, left * column.weight / total);
|
|
2832
|
+
break;
|
|
2833
|
+
}
|
|
2834
|
+
const share = Math.max(0, (capped.max ?? capped.base) - capped.base);
|
|
2835
|
+
exact.set(capped.field, share);
|
|
2836
|
+
left -= share;
|
|
2837
|
+
open = open.filter((column) => column !== capped);
|
|
2838
|
+
if (open.length === 0) break;
|
|
2839
|
+
}
|
|
2840
|
+
let given = 0;
|
|
2841
|
+
for (const column of columns) {
|
|
2842
|
+
const share = Math.floor(exact.get(column.field) ?? 0);
|
|
2843
|
+
shares[column.field] = share;
|
|
2844
|
+
given += share;
|
|
2845
|
+
}
|
|
2846
|
+
const last = open.at(-1);
|
|
2847
|
+
if (last) {
|
|
2848
|
+
const whole = Math.floor([...exact.values()].reduce((sum, share) => sum + share, 0));
|
|
2849
|
+
shares[last.field] += Math.max(0, whole - given);
|
|
2850
|
+
}
|
|
2851
|
+
return shares;
|
|
2852
|
+
};
|
|
2853
|
+
/**
|
|
2854
|
+
* The base that draws a growing column `drawn` pixels wide once the room is
|
|
2855
|
+
* divided again with it growing (ADR 0024, amendment, #136 D-05). `room` is
|
|
2856
|
+
* the room with the column's base taken out, `weight` its weight and `total`
|
|
2857
|
+
* the weights of every growing column. Alone, or wider than the room, the
|
|
2858
|
+
* column's base is the drawn width; the other columns' `max` is not solved
|
|
2859
|
+
* for.
|
|
2860
|
+
*/
|
|
2861
|
+
var baseAt = (drawn, room, weight, total) => total - weight <= 0 || drawn > room ? drawn : (drawn * total - room * weight) / (total - weight);
|
|
2862
|
+
//#endregion
|
|
2863
|
+
//#region src/resize/use-growing-columns.ts
|
|
2864
|
+
var isDevelopment$2 = () => {
|
|
2865
|
+
try {
|
|
2866
|
+
return process.env.NODE_ENV !== "production";
|
|
2867
|
+
} catch {
|
|
2868
|
+
return true;
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
/** `Column.grow` when it is a weight above `0`, else `0` (K321-1). */
|
|
2872
|
+
var growOf = (column) => typeof column.grow === "number" && Number.isFinite(column.grow) && column.grow > 0 ? column.grow : 0;
|
|
2873
|
+
/** A CSS length in pixels (`'180px'`), else `undefined`. */
|
|
2874
|
+
var pixels = (width) => {
|
|
2875
|
+
const match = width === void 0 ? null : /^(\d+(?:\.\d+)?)px$/.exec(width);
|
|
2876
|
+
return match ? Number(match[1]) : void 0;
|
|
2877
|
+
};
|
|
2878
|
+
var none = Object.freeze({});
|
|
2879
|
+
/** The content width of the container: inside its scrollbar and padding. */
|
|
2880
|
+
var innerWidth = (element) => {
|
|
2881
|
+
const style = getComputedStyle(element);
|
|
2882
|
+
return element.clientWidth - (Number.parseFloat(style.paddingLeft) || 0) - (Number.parseFloat(style.paddingRight) || 0);
|
|
2883
|
+
};
|
|
2884
|
+
/**
|
|
2885
|
+
* Growing columns (C-132, ADR 0024). The room of a container wider than the
|
|
2886
|
+
* table goes to the columns with `grow`, by their weights, on top of their
|
|
2887
|
+
* bases; the table is then as wide as the container and the browser spreads
|
|
2888
|
+
* nothing. The shares are UI state (P2): drawn as the header cell's `width`,
|
|
2889
|
+
* never emitted, never written to `columns`. The table reads its natural
|
|
2890
|
+
* width once per change of its columns; a change of the container's width
|
|
2891
|
+
* only divides the room again.
|
|
2892
|
+
*/
|
|
2893
|
+
var useGrowingColumns = (options) => {
|
|
2894
|
+
const reading = shallowRef(null);
|
|
2895
|
+
const container = shallowRef(0);
|
|
2896
|
+
/** A read found the table not displayed: read once it is. */
|
|
2897
|
+
let waiting = false;
|
|
2898
|
+
let warned = false;
|
|
2899
|
+
let observer = null;
|
|
2900
|
+
const growing = () => options.columns().filter((column) => growOf(column) > 0);
|
|
2901
|
+
/**
|
|
2902
|
+
* K321-9: a visible column that does not grow and has no width, given or
|
|
2903
|
+
* automatic, takes what is left in a fixed layout, so no share is drawn.
|
|
2904
|
+
*/
|
|
2905
|
+
const blocked = () => {
|
|
2906
|
+
const auto = options.autoWidths();
|
|
2907
|
+
return options.columns().some((column) => growOf(column) === 0 && !column.width && auto[column.field] === void 0);
|
|
2908
|
+
};
|
|
2909
|
+
/**
|
|
2910
|
+
* The width `column` is drawn at in the read, a growing one at its base, in
|
|
2911
|
+
* pixels. Drawn, not declared: a skin's own limits (a `min-width` on the
|
|
2912
|
+
* header cells) can draw a column wider than declared, and the room is
|
|
2913
|
+
* what the drawn widths leave. Its declared width when it has no box.
|
|
2914
|
+
*/
|
|
2915
|
+
const drawnOf = (column, read) => read.drawn[column.field] ?? pixels(column.width) ?? options.autoWidths()[column.field] ?? (growOf(column) > 0 ? minWidthOf(column) : 0);
|
|
2916
|
+
/** The width a growing column is read at: its base (K321-3). */
|
|
2917
|
+
const baseCss = (column) => {
|
|
2918
|
+
if (column.width) return column.width;
|
|
2919
|
+
return `${options.autoWidths()[column.field] ?? minWidthOf(column)}px`;
|
|
2920
|
+
};
|
|
2921
|
+
const clear = () => {
|
|
2922
|
+
reading.value = null;
|
|
2923
|
+
waiting = false;
|
|
2924
|
+
observer?.disconnect();
|
|
2925
|
+
observer = null;
|
|
2926
|
+
};
|
|
2927
|
+
const read = () => {
|
|
2928
|
+
const table = options.table.value;
|
|
2929
|
+
const parent = table?.parentElement;
|
|
2930
|
+
if (!table || !parent) return;
|
|
2931
|
+
const byField = new Map(options.columns().map((column) => [column.field, column]));
|
|
2932
|
+
const headers = Array.from(table.querySelectorAll(":scope > thead > tr > th[data-field]"));
|
|
2933
|
+
const swap = styleSwap();
|
|
2934
|
+
let natural = 0;
|
|
2935
|
+
const drawn = {};
|
|
2936
|
+
try {
|
|
2937
|
+
swap.set(table, "min-width", "0");
|
|
2938
|
+
swap.set(table, "width", "max-content");
|
|
2939
|
+
for (const th of headers) {
|
|
2940
|
+
const column = byField.get(th.dataset.field ?? "");
|
|
2941
|
+
if (column && growOf(column) > 0) swap.set(th, "width", baseCss(column));
|
|
2942
|
+
}
|
|
2943
|
+
natural = table.getBoundingClientRect().width;
|
|
2944
|
+
for (const th of headers) drawn[th.dataset.field ?? ""] = th.getBoundingClientRect().width;
|
|
2945
|
+
} finally {
|
|
2946
|
+
swap.restore();
|
|
2947
|
+
}
|
|
2948
|
+
const inner = innerWidth(parent);
|
|
2949
|
+
if (natural === 0 || inner <= 0) {
|
|
2950
|
+
waiting = true;
|
|
2951
|
+
return;
|
|
2952
|
+
}
|
|
2953
|
+
waiting = false;
|
|
2954
|
+
container.value = inner;
|
|
2955
|
+
reading.value = {
|
|
2956
|
+
natural,
|
|
2957
|
+
drawn
|
|
2958
|
+
};
|
|
2959
|
+
};
|
|
2960
|
+
const shares = computed(() => {
|
|
2961
|
+
const current = reading.value;
|
|
2962
|
+
if (!current || !options.enabled()) return none;
|
|
2963
|
+
let natural = current.natural;
|
|
2964
|
+
let columns = growing();
|
|
2965
|
+
const preview = options.preview();
|
|
2966
|
+
if (preview) {
|
|
2967
|
+
const column = options.columns().find((candidate) => candidate.field === preview.field);
|
|
2968
|
+
if (column) {
|
|
2969
|
+
natural += preview.width - drawnOf(column, current);
|
|
2970
|
+
columns = columns.filter((candidate) => candidate !== column);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
return divideRoom(container.value - natural, columns.map((column) => ({
|
|
2974
|
+
field: column.field,
|
|
2975
|
+
weight: growOf(column),
|
|
2976
|
+
base: drawnOf(column, current),
|
|
2977
|
+
max: limitOf(column.maxWidth)
|
|
2978
|
+
})));
|
|
2979
|
+
});
|
|
2980
|
+
/** The shares are drawn: the table is as wide as its container. */
|
|
2981
|
+
const active = computed(() => Object.values(shares.value).some((share) => share > 0));
|
|
2982
|
+
/** The width the shares make the table: to tell a change we did not make. */
|
|
2983
|
+
const expected = () => {
|
|
2984
|
+
const current = reading.value;
|
|
2985
|
+
if (!current) return;
|
|
2986
|
+
return current.natural + Object.values(shares.value).reduce((sum, share) => sum + share, 0);
|
|
2987
|
+
};
|
|
2988
|
+
const observe = (table) => {
|
|
2989
|
+
observer?.disconnect();
|
|
2990
|
+
observer = null;
|
|
2991
|
+
const parent = table?.parentElement;
|
|
2992
|
+
if (!table || !parent || typeof ResizeObserver === "undefined") return;
|
|
2993
|
+
observer = new ResizeObserver(() => {
|
|
2994
|
+
if (waiting) {
|
|
2995
|
+
read();
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
container.value = innerWidth(parent);
|
|
2999
|
+
const want = expected();
|
|
3000
|
+
if (want !== void 0 && !options.preview() && Math.abs(table.getBoundingClientRect().width - want) > 1 && Object.keys(shares.value).length > 0) read();
|
|
3001
|
+
});
|
|
3002
|
+
observer.observe(parent);
|
|
3003
|
+
observer.observe(table);
|
|
3004
|
+
};
|
|
3005
|
+
watch([
|
|
3006
|
+
() => options.enabled(),
|
|
3007
|
+
() => options.table.value,
|
|
3008
|
+
() => options.columns().map((column) => [
|
|
3009
|
+
column.field,
|
|
3010
|
+
column.width ?? "",
|
|
3011
|
+
growOf(column),
|
|
3012
|
+
column.minWidth ?? "",
|
|
3013
|
+
column.maxWidth ?? ""
|
|
3014
|
+
].join(" ")).join("|"),
|
|
3015
|
+
() => JSON.stringify(options.autoWidths()),
|
|
3016
|
+
() => options.utilities()
|
|
3017
|
+
], ([enabled, table], [, oldTable]) => {
|
|
3018
|
+
if (!enabled || growing().length === 0) {
|
|
3019
|
+
clear();
|
|
3020
|
+
return;
|
|
3021
|
+
}
|
|
3022
|
+
if (blocked()) {
|
|
3023
|
+
clear();
|
|
3024
|
+
if (!options.autoWidth() && !warned && isDevelopment$2()) {
|
|
3025
|
+
warned = true;
|
|
3026
|
+
console.warn("[QueryTable] `grow`: a visible column that does not grow has no `width`, so the room is not divided. Give that column a `width` or turn `autoWidth` on (C-132).");
|
|
3027
|
+
}
|
|
3028
|
+
return;
|
|
3029
|
+
}
|
|
3030
|
+
if (table !== oldTable || !observer) observe(table);
|
|
3031
|
+
read();
|
|
3032
|
+
}, {
|
|
3033
|
+
immediate: true,
|
|
3034
|
+
flush: "post"
|
|
3035
|
+
});
|
|
3036
|
+
/** The width a column is drawn at, or `undefined` to draw it as declared. */
|
|
3037
|
+
const widthOf = (field) => {
|
|
3038
|
+
const share = shares.value[field];
|
|
3039
|
+
const current = reading.value;
|
|
3040
|
+
if (!share || !current) return;
|
|
3041
|
+
const column = options.columns().find((candidate) => candidate.field === field);
|
|
3042
|
+
return column ? drawnOf(column, current) + share : void 0;
|
|
3043
|
+
};
|
|
3044
|
+
/**
|
|
3045
|
+
* The width a resize of `field` emits for the drawn width `drawn`: the base
|
|
3046
|
+
* that keeps a growing column there once the room is divided again (D-05),
|
|
3047
|
+
* else `drawn`.
|
|
3048
|
+
*/
|
|
3049
|
+
const emitted = (field, drawn) => {
|
|
3050
|
+
const current = reading.value;
|
|
3051
|
+
const column = options.columns().find((candidate) => candidate.field === field);
|
|
3052
|
+
if (!current || !column || growOf(column) === 0 || !active.value) return drawn;
|
|
3053
|
+
const all = growing();
|
|
3054
|
+
const base = drawnOf(column, current);
|
|
3055
|
+
return baseAt(drawn, container.value - (current.natural - base), growOf(column), all.reduce((sum, candidate) => sum + growOf(candidate), 0));
|
|
3056
|
+
};
|
|
3057
|
+
onBeforeUnmount(() => {
|
|
3058
|
+
observer?.disconnect();
|
|
3059
|
+
observer = null;
|
|
3060
|
+
});
|
|
3061
|
+
return {
|
|
3062
|
+
shares,
|
|
3063
|
+
active,
|
|
3064
|
+
widthOf,
|
|
3065
|
+
emitted
|
|
3066
|
+
};
|
|
3067
|
+
};
|
|
3068
|
+
//#endregion
|
|
2741
3069
|
//#region src/scroll/use-scroll-body.ts
|
|
2742
3070
|
var isDevelopment$1 = () => {
|
|
2743
3071
|
try {
|
|
@@ -2887,6 +3215,11 @@ function useQueryTable(options) {
|
|
|
2887
3215
|
const expandable = toValue(options.rowExpandable);
|
|
2888
3216
|
return expandable === void 0 || expandable(row, index);
|
|
2889
3217
|
};
|
|
3218
|
+
const canSelect = (row, index) => {
|
|
3219
|
+
const selectable = toValue(options.rowSelectable);
|
|
3220
|
+
return selectable === void 0 || selectable(row, index);
|
|
3221
|
+
};
|
|
3222
|
+
const enableRowSelection = computed(() => toValue(options.rowSelectable) === void 0 ? true : (row) => canSelect(row.original, row.index));
|
|
2890
3223
|
const pinnedRows = () => toValue(options.rowPinning);
|
|
2891
3224
|
const pinningEnabled = computed(() => rowKey() !== void 0 && pinnedRows() !== void 0);
|
|
2892
3225
|
const rowPinningState = computed(() => {
|
|
@@ -2958,7 +3291,9 @@ function useQueryTable(options) {
|
|
|
2958
3291
|
get filterDebounce() {
|
|
2959
3292
|
return toValue(options.filterDebounce) ?? 100;
|
|
2960
3293
|
},
|
|
2961
|
-
enableRowSelection
|
|
3294
|
+
get enableRowSelection() {
|
|
3295
|
+
return enableRowSelection.value;
|
|
3296
|
+
},
|
|
2962
3297
|
manualExpanding: true,
|
|
2963
3298
|
getRowCanExpand: (row) => canExpand(row.original, row.index),
|
|
2964
3299
|
onRowSelectionChange: (updater) => {
|
|
@@ -3298,10 +3633,13 @@ function useQueryTable(options) {
|
|
|
3298
3633
|
watch(single, (isSingle) => {
|
|
3299
3634
|
if (isSingle) setExpanded((state) => keepFirstOpen(state, rows()));
|
|
3300
3635
|
});
|
|
3636
|
+
const allSelected = computed(() => table.getIsAllPageRowsSelected());
|
|
3301
3637
|
const selection = {
|
|
3302
3638
|
enabled: computed(() => toValue(options.selection) !== void 0),
|
|
3639
|
+
canSelect,
|
|
3303
3640
|
isSelected: (row, index) => !!toValue(options.selection)?.[idOf(row, index)],
|
|
3304
3641
|
toggle: (row, index) => {
|
|
3642
|
+
if (!canSelect(row, index)) return;
|
|
3305
3643
|
const id = idOf(row, index);
|
|
3306
3644
|
table.setRowSelection((old) => {
|
|
3307
3645
|
const next = { ...old };
|
|
@@ -3310,8 +3648,9 @@ function useQueryTable(options) {
|
|
|
3310
3648
|
return next;
|
|
3311
3649
|
});
|
|
3312
3650
|
},
|
|
3313
|
-
allSelected
|
|
3314
|
-
someSelected: computed(() => table.getIsSomePageRowsSelected()),
|
|
3651
|
+
allSelected,
|
|
3652
|
+
someSelected: computed(() => !allSelected.value && table.getIsSomePageRowsSelected()),
|
|
3653
|
+
canToggleAll: computed(() => toValue(options.rowSelectable) === void 0 || rows().some((row, index) => canSelect(row, index))),
|
|
3315
3654
|
toggleAll: (value) => table.toggleAllPageRowsSelected(value)
|
|
3316
3655
|
};
|
|
3317
3656
|
const bodyRows = computed(() => {
|
|
@@ -4277,6 +4616,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4277
4616
|
query: {},
|
|
4278
4617
|
cursors: { default: null },
|
|
4279
4618
|
selection: { default: void 0 },
|
|
4619
|
+
rowSelectable: {
|
|
4620
|
+
type: Function,
|
|
4621
|
+
default: void 0
|
|
4622
|
+
},
|
|
4280
4623
|
rowPinning: { default: void 0 },
|
|
4281
4624
|
searchDebounce: { default: 300 },
|
|
4282
4625
|
columns: {},
|
|
@@ -4379,6 +4722,15 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4379
4722
|
const emit = __emit;
|
|
4380
4723
|
const slots = useSlots();
|
|
4381
4724
|
const rawSlots = useSlots();
|
|
4725
|
+
const iconSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("icon-")).sort().join("\n");
|
|
4726
|
+
const givenIcons = shallowRef(iconSlotNames());
|
|
4727
|
+
onBeforeUpdate(() => {
|
|
4728
|
+
givenIcons.value = iconSlotNames();
|
|
4729
|
+
});
|
|
4730
|
+
const icons = {
|
|
4731
|
+
has: (name) => givenIcons.value.split("\n").includes(`icon-${name}`),
|
|
4732
|
+
slots: rawSlots
|
|
4733
|
+
};
|
|
4382
4734
|
const split = () => props.header && props.scrollBody;
|
|
4383
4735
|
/** Rows of the header in the row count (C-86): none without it. */
|
|
4384
4736
|
const headerRows = () => props.header ? 1 : 0;
|
|
@@ -4398,6 +4750,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4398
4750
|
filterDebounce: () => props.filterDebounce,
|
|
4399
4751
|
searchDebounce: () => props.searchDebounce,
|
|
4400
4752
|
selection: () => props.selection,
|
|
4753
|
+
rowSelectable: () => props.rowSelectable,
|
|
4401
4754
|
rowPinning: () => props.rowPinning,
|
|
4402
4755
|
rowKey: () => props.rowKey,
|
|
4403
4756
|
hasSubtable: () => props.hasSubtable,
|
|
@@ -4486,7 +4839,9 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4486
4839
|
emit("columnResize", payload);
|
|
4487
4840
|
const next = applyWidth(props.columns, payload.field, `${payload.width}px`);
|
|
4488
4841
|
if (next) emit("update:columns", next, "resize");
|
|
4489
|
-
}
|
|
4842
|
+
},
|
|
4843
|
+
growing: () => grow.active.value,
|
|
4844
|
+
emitted: (field, drawn) => grow.emitted(field, drawn)
|
|
4490
4845
|
});
|
|
4491
4846
|
const autoWidth = useAutoWidth({
|
|
4492
4847
|
enabled: () => props.header && props.autoWidth,
|
|
@@ -4498,6 +4853,15 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4498
4853
|
query: () => props.query,
|
|
4499
4854
|
rowsUpdate: () => props.rowsUpdate
|
|
4500
4855
|
});
|
|
4856
|
+
const grow = useGrowingColumns({
|
|
4857
|
+
enabled: () => props.header,
|
|
4858
|
+
table: tableEl,
|
|
4859
|
+
columns: () => visibleColumns.value,
|
|
4860
|
+
autoWidth: () => props.autoWidth,
|
|
4861
|
+
autoWidths: () => autoWidth.widths.value,
|
|
4862
|
+
utilities: () => utilities.value.join(" "),
|
|
4863
|
+
preview: () => resize.preview.value
|
|
4864
|
+
});
|
|
4501
4865
|
const rowWindow = useRowWindow({
|
|
4502
4866
|
virtual: () => props.virtual,
|
|
4503
4867
|
table: bodyTable,
|
|
@@ -4578,7 +4942,9 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4578
4942
|
resize,
|
|
4579
4943
|
reorder,
|
|
4580
4944
|
selection: rowSelection,
|
|
4581
|
-
labels: () => labels.value
|
|
4945
|
+
labels: () => labels.value,
|
|
4946
|
+
icons,
|
|
4947
|
+
grow
|
|
4582
4948
|
});
|
|
4583
4949
|
const showPagination = computed(() => !!slots.pagination && (props.rows.length > 0 || (props.totalRows ?? 0) > 0 || (props.pagination?.alwaysShow ?? false)));
|
|
4584
4950
|
const canClearFilters = computed(() => filters.canClearAll());
|
|
@@ -4685,6 +5051,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4685
5051
|
"has-right-panel": __props.hasRightPanel,
|
|
4686
5052
|
"has-selection": unref(rowSelection).enabled.value,
|
|
4687
5053
|
"is-selected": unref(rowSelection).isSelected,
|
|
5054
|
+
"can-select": unref(rowSelection).canSelect,
|
|
4688
5055
|
"toggle-selected": unref(rowSelection).toggle,
|
|
4689
5056
|
"has-pinned": unref(hasPinned),
|
|
4690
5057
|
offsets: unref(offsets),
|
|
@@ -4719,6 +5086,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4719
5086
|
"has-right-panel",
|
|
4720
5087
|
"has-selection",
|
|
4721
5088
|
"is-selected",
|
|
5089
|
+
"can-select",
|
|
4722
5090
|
"toggle-selected",
|
|
4723
5091
|
"has-pinned",
|
|
4724
5092
|
"offsets",
|
|
@@ -4814,6 +5182,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4814
5182
|
"has-right-panel": __props.hasRightPanel,
|
|
4815
5183
|
"has-selection": unref(rowSelection).enabled.value,
|
|
4816
5184
|
"is-selected": unref(rowSelection).isSelected,
|
|
5185
|
+
"can-select": unref(rowSelection).canSelect,
|
|
4817
5186
|
"toggle-selected": unref(rowSelection).toggle,
|
|
4818
5187
|
"has-pinned": unref(hasPinned),
|
|
4819
5188
|
offsets: unref(offsets),
|
|
@@ -4847,6 +5216,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
4847
5216
|
"has-right-panel",
|
|
4848
5217
|
"has-selection",
|
|
4849
5218
|
"is-selected",
|
|
5219
|
+
"can-select",
|
|
4850
5220
|
"toggle-selected",
|
|
4851
5221
|
"has-pinned",
|
|
4852
5222
|
"offsets",
|
|
@@ -4925,4 +5295,4 @@ var src_default = query_table_default;
|
|
|
4925
5295
|
//#endregion
|
|
4926
5296
|
export { useQueryTable as i, parseFilterInput$1 as n, query_table_default as r, src_default as t };
|
|
4927
5297
|
|
|
4928
|
-
//# sourceMappingURL=src-
|
|
5298
|
+
//# sourceMappingURL=src-DvUx4ur-.js.map
|