@dolusoft/query-table 3.4.0 → 3.5.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.
package/dist/query-table.js
CHANGED
|
@@ -729,6 +729,7 @@ var _hoisted_2$5 = [
|
|
|
729
729
|
"data-row-index",
|
|
730
730
|
"aria-rowindex",
|
|
731
731
|
"data-pinned-row",
|
|
732
|
+
"data-row-kind",
|
|
732
733
|
"data-expanded",
|
|
733
734
|
"data-selected",
|
|
734
735
|
"data-flash",
|
|
@@ -803,8 +804,10 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
803
804
|
hasPinned: { type: Boolean },
|
|
804
805
|
offsets: {},
|
|
805
806
|
keyOf: { type: Function },
|
|
807
|
+
canExpand: { type: Function },
|
|
806
808
|
isExpanded: { type: Function },
|
|
807
809
|
toggle: { type: Function },
|
|
810
|
+
rowKind: { type: Function },
|
|
808
811
|
labels: {},
|
|
809
812
|
hasContextMenuListener: { type: Function },
|
|
810
813
|
loadMore: {},
|
|
@@ -829,6 +832,8 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
829
832
|
const expandAttrs = () => utilityAttrs("subtable");
|
|
830
833
|
const selectAttrs = () => utilityAttrs("select");
|
|
831
834
|
const isSpacer = (item) => "spacer" in item;
|
|
835
|
+
/** `data-row-kind` of a drawn row (C-97): no attribute for an empty kind. */
|
|
836
|
+
const kindOf = (item) => props.rowKind ? props.rowKind(item.row, item.index) || void 0 : void 0;
|
|
832
837
|
/** `aria-rowindex` of the subtable row under a drawn row (C-86). */
|
|
833
838
|
const nextIndex = (aria) => aria === void 0 ? void 0 : aria + 1;
|
|
834
839
|
let expandedSnapshot = null;
|
|
@@ -859,6 +864,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
859
864
|
"data-row-index": item.index,
|
|
860
865
|
"aria-rowindex": item.aria,
|
|
861
866
|
"data-pinned-row": item.pinned || void 0,
|
|
867
|
+
"data-row-kind": kindOf(item),
|
|
862
868
|
"data-expanded": isRowExpanded(item) ? "" : void 0,
|
|
863
869
|
"data-selected": __props.hasSelection && __props.isSelected(item.row, item.index) ? "" : void 0,
|
|
864
870
|
"data-flash": __props.flash ? __props.flash.row(item.row, item.index) : void 0,
|
|
@@ -896,13 +902,14 @@ var table_body_default = /* @__PURE__ */ defineComponent({
|
|
|
896
902
|
__props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
|
|
897
903
|
key: 1,
|
|
898
904
|
ref_for: true
|
|
899
|
-
}, expandAttrs()), [
|
|
905
|
+
}, expandAttrs()), [__props.canExpand(item.row, item.index) ? (openBlock(), createElementBlock("button", {
|
|
906
|
+
key: 0,
|
|
900
907
|
type: "button",
|
|
901
908
|
class: "qt-expand",
|
|
902
909
|
"aria-expanded": isRowExpanded(item),
|
|
903
910
|
"aria-label": __props.labels.expandRow,
|
|
904
911
|
onClick: ($event) => __props.toggle(item.row, item.index)
|
|
905
|
-
}, [(openBlock(), createElementBlock("svg", _hoisted_5$1, [isRowExpanded(item) ? (openBlock(), createElementBlock("polyline", _hoisted_6$1)) : (openBlock(), createElementBlock("polyline", _hoisted_7$1))]))], 8, _hoisted_4$4)], 16)) : createCommentVNode("", true),
|
|
912
|
+
}, [(openBlock(), createElementBlock("svg", _hoisted_5$1, [isRowExpanded(item) ? (openBlock(), createElementBlock("polyline", _hoisted_6$1)) : (openBlock(), createElementBlock("polyline", _hoisted_7$1))]))], 8, _hoisted_4$4)) : createCommentVNode("", true)], 16)) : createCommentVNode("", true),
|
|
906
913
|
__props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
|
|
907
914
|
key: 2,
|
|
908
915
|
ref_for: true
|
|
@@ -1674,12 +1681,12 @@ var useHeaderGeometry = (options) => {
|
|
|
1674
1681
|
headerCells(table).forEach((cell, index) => {
|
|
1675
1682
|
const drawn = cells[index];
|
|
1676
1683
|
if (drawn) {
|
|
1677
|
-
const
|
|
1678
|
-
next[drawn.key] =
|
|
1684
|
+
const exact = cell.getBoundingClientRect().width;
|
|
1685
|
+
next[drawn.key] = Math.round(exact);
|
|
1679
1686
|
if (drawn.side === "left") {
|
|
1680
1687
|
nextOffsets[drawn.key] = left;
|
|
1681
|
-
left +=
|
|
1682
|
-
} else if (drawn.side === "right") rights.push([drawn.key,
|
|
1688
|
+
left += exact;
|
|
1689
|
+
} else if (drawn.side === "right") rights.push([drawn.key, exact]);
|
|
1683
1690
|
}
|
|
1684
1691
|
});
|
|
1685
1692
|
let right = 0;
|
|
@@ -1913,6 +1920,11 @@ function useQueryTable(options) {
|
|
|
1913
1920
|
const columns = () => toValue(options.columns);
|
|
1914
1921
|
const rowKey = () => toValue(options.rowKey);
|
|
1915
1922
|
const hasSubtable = () => toValue(options.hasSubtable) ?? false;
|
|
1923
|
+
const canExpand = (row, index) => {
|
|
1924
|
+
if (!hasSubtable()) return false;
|
|
1925
|
+
const expandable = toValue(options.rowExpandable);
|
|
1926
|
+
return expandable === void 0 || expandable(row, index);
|
|
1927
|
+
};
|
|
1916
1928
|
const pinnedRows = () => toValue(options.rowPinning);
|
|
1917
1929
|
const pinningEnabled = computed(() => rowKey() !== void 0 && pinnedRows() !== void 0);
|
|
1918
1930
|
const rowPinningState = computed(() => {
|
|
@@ -1985,7 +1997,7 @@ function useQueryTable(options) {
|
|
|
1985
1997
|
},
|
|
1986
1998
|
enableRowSelection: true,
|
|
1987
1999
|
manualExpanding: true,
|
|
1988
|
-
getRowCanExpand: () =>
|
|
2000
|
+
getRowCanExpand: (row) => canExpand(row.original, row.index),
|
|
1989
2001
|
onRowSelectionChange: (updater) => {
|
|
1990
2002
|
const current = toValue(options.selection) ?? {};
|
|
1991
2003
|
options.onSelectionChange?.(selectedOnly(functionalUpdate(updater, current)));
|
|
@@ -2251,8 +2263,10 @@ function useQueryTable(options) {
|
|
|
2251
2263
|
};
|
|
2252
2264
|
const expansion = {
|
|
2253
2265
|
keyOf,
|
|
2254
|
-
|
|
2266
|
+
canExpand,
|
|
2267
|
+
isExpanded: (row, index) => !!expandedState.value[idOf(row, index)] && canExpand(row, index),
|
|
2255
2268
|
toggle: (row, index) => {
|
|
2269
|
+
if (!canExpand(row, index)) return;
|
|
2256
2270
|
const id = idOf(row, index);
|
|
2257
2271
|
setExpanded((state) => {
|
|
2258
2272
|
if (state[id]) delete state[id];
|
|
@@ -2264,7 +2278,7 @@ function useQueryTable(options) {
|
|
|
2264
2278
|
expandAll: () => {
|
|
2265
2279
|
if (hasSubtable()) setExpanded((state) => {
|
|
2266
2280
|
rows().forEach((row, index) => {
|
|
2267
|
-
state[idOf(row, index)] = true;
|
|
2281
|
+
if (canExpand(row, index)) state[idOf(row, index)] = true;
|
|
2268
2282
|
});
|
|
2269
2283
|
return state;
|
|
2270
2284
|
});
|
|
@@ -2279,7 +2293,8 @@ function useQueryTable(options) {
|
|
|
2279
2293
|
}
|
|
2280
2294
|
if (hasSubtable()) current.forEach((row, index) => {
|
|
2281
2295
|
const seeded = row.isExpanded;
|
|
2282
|
-
if (
|
|
2296
|
+
if (!canExpand(row, index)) delete state[idOf(row, index)];
|
|
2297
|
+
else if (seeded === true) state[idOf(row, index)] = true;
|
|
2283
2298
|
else if (seeded === false) delete state[idOf(row, index)];
|
|
2284
2299
|
});
|
|
2285
2300
|
return state;
|
|
@@ -3047,6 +3062,14 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3047
3062
|
type: Boolean,
|
|
3048
3063
|
default: false
|
|
3049
3064
|
},
|
|
3065
|
+
rowExpandable: {
|
|
3066
|
+
type: Function,
|
|
3067
|
+
default: void 0
|
|
3068
|
+
},
|
|
3069
|
+
rowKind: {
|
|
3070
|
+
type: Function,
|
|
3071
|
+
default: void 0
|
|
3072
|
+
},
|
|
3050
3073
|
hasRightPanel: {
|
|
3051
3074
|
type: Boolean,
|
|
3052
3075
|
default: false
|
|
@@ -3098,6 +3121,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3098
3121
|
rowPinning: () => props.rowPinning,
|
|
3099
3122
|
rowKey: () => props.rowKey,
|
|
3100
3123
|
hasSubtable: () => props.hasSubtable,
|
|
3124
|
+
rowExpandable: () => props.rowExpandable,
|
|
3101
3125
|
pageSizeOptions: () => props.pagination?.pageSizeOptions,
|
|
3102
3126
|
onQueryChange: (query, reason) => emit("update:query", query, reason),
|
|
3103
3127
|
onSelectionChange: (selection) => emit("update:selection", selection),
|
|
@@ -3300,8 +3324,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3300
3324
|
"has-pinned": unref(hasPinned),
|
|
3301
3325
|
offsets: unref(offsets),
|
|
3302
3326
|
"key-of": unref(expansion).keyOf,
|
|
3327
|
+
"can-expand": unref(expansion).canExpand,
|
|
3303
3328
|
"is-expanded": unref(expansion).isExpanded,
|
|
3304
3329
|
toggle: unref(expansion).toggle,
|
|
3330
|
+
"row-kind": __props.rowKind,
|
|
3305
3331
|
labels: labels.value,
|
|
3306
3332
|
"has-context-menu-listener": hasContextMenuListener,
|
|
3307
3333
|
"load-more": loadMoreProps.value,
|
|
@@ -3330,8 +3356,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3330
3356
|
"has-pinned",
|
|
3331
3357
|
"offsets",
|
|
3332
3358
|
"key-of",
|
|
3359
|
+
"can-expand",
|
|
3333
3360
|
"is-expanded",
|
|
3334
3361
|
"toggle",
|
|
3362
|
+
"row-kind",
|
|
3335
3363
|
"labels",
|
|
3336
3364
|
"load-more",
|
|
3337
3365
|
"flash",
|
|
@@ -3376,7 +3404,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
|
|
|
3376
3404
|
* a segment without an operator uses `condition`.
|
|
3377
3405
|
* - `number`: one rule with a number value; text that is not a finite number
|
|
3378
3406
|
* gives `[]`.
|
|
3379
|
-
* - `integer`: the same, but only a whole number; `2.5`
|
|
3407
|
+
* - `integer`: the same, but only a whole number in the safe range; `2.5`
|
|
3408
|
+
* and `9007199254740993` give `[]`.
|
|
3380
3409
|
* - `bool`: `'true'` or `'false'` gives one rule with a boolean value;
|
|
3381
3410
|
* anything else gives `[]`.
|
|
3382
3411
|
* - `date` and `datetime`: one rule with the trimmed text as its value; the
|