@dolusoft/query-table 3.7.0 → 3.8.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.
@@ -724,8 +724,10 @@ var useCellView = (options) => {
724
724
  };
725
725
  //#endregion
726
726
  //#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
727
- var _hoisted_1$9 = ["colspan"];
728
- var _hoisted_2$5 = [
727
+ var _hoisted_1$9 = ["role"];
728
+ var _hoisted_2$5 = ["role"];
729
+ var _hoisted_3$5 = [
730
+ "role",
729
731
  "data-row-index",
730
732
  "aria-rowindex",
731
733
  "data-pinned-row",
@@ -736,13 +738,13 @@ var _hoisted_2$5 = [
736
738
  "onVnodeBeforeMount",
737
739
  "onVnodeUpdated"
738
740
  ];
739
- var _hoisted_3$5 = ["aria-label", "onClick"];
740
- var _hoisted_4$4 = [
741
+ var _hoisted_4$5 = ["aria-label", "onClick"];
742
+ var _hoisted_5$2 = [
741
743
  "aria-expanded",
742
744
  "aria-label",
743
745
  "onClick"
744
746
  ];
745
- var _hoisted_5$1 = {
747
+ var _hoisted_6$2 = {
746
748
  width: "14",
747
749
  height: "14",
748
750
  viewBox: "0 0 24 24",
@@ -753,38 +755,29 @@ var _hoisted_5$1 = {
753
755
  "stroke-linejoin": "round",
754
756
  "aria-hidden": "true"
755
757
  };
756
- var _hoisted_6$1 = {
758
+ var _hoisted_7$2 = {
757
759
  key: 0,
758
760
  points: "6 9 12 15 18 9"
759
761
  };
760
- var _hoisted_7$1 = {
762
+ var _hoisted_8$2 = {
761
763
  key: 1,
762
764
  points: "9 6 15 12 9 18"
763
765
  };
764
- var _hoisted_8$1 = [
766
+ var _hoisted_9$1 = [
765
767
  "aria-label",
766
768
  "checked",
767
769
  "onChange"
768
770
  ];
769
- var _hoisted_9$1 = ["data-flash"];
770
- var _hoisted_10 = ["data-flash"];
771
- var _hoisted_11 = ["aria-rowindex", "data-pinned-row"];
772
- var _hoisted_12 = ["colspan"];
773
- var _hoisted_13 = {
774
- key: 0,
775
- class: "qt-loading-row"
776
- };
777
- var _hoisted_14 = ["colspan"];
778
- var _hoisted_15 = {
779
- key: 1,
780
- class: "qt-empty-row"
781
- };
782
- var _hoisted_16 = ["colspan"];
783
- var _hoisted_17 = {
784
- key: 2,
785
- class: "qt-load-more-row"
786
- };
787
- var _hoisted_18 = ["colspan"];
771
+ var _hoisted_10 = ["role", "data-flash"];
772
+ var _hoisted_11 = ["role", "data-flash"];
773
+ var _hoisted_12 = [
774
+ "role",
775
+ "aria-rowindex",
776
+ "data-pinned-row"
777
+ ];
778
+ var _hoisted_13 = ["role"];
779
+ var _hoisted_14 = ["role"];
780
+ var _hoisted_15 = ["role"];
788
781
  //#endregion
789
782
  //#region src/parts/table-body.vue
790
783
  var table_body_default = /* @__PURE__ */ defineComponent({
@@ -811,7 +804,8 @@ var table_body_default = /* @__PURE__ */ defineComponent({
811
804
  labels: {},
812
805
  hasContextMenuListener: { type: Function },
813
806
  loadMore: {},
814
- flash: {}
807
+ flash: {},
808
+ roles: { type: Boolean }
815
809
  },
816
810
  emits: ["rowRightPanelClick", "cellContextMenu"],
817
811
  setup(__props, { emit: __emit }) {
@@ -827,7 +821,19 @@ var table_body_default = /* @__PURE__ */ defineComponent({
827
821
  onContextMenu: (payload) => emit("cellContextMenu", payload),
828
822
  pinRow: (row, index, position) => props.pinRow(row, index, position)
829
823
  });
830
- const utilityAttrs = (utility) => pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)]);
824
+ /** `role` of a row and of a cell with `scrollBody` (C-102). */
825
+ const rowRole = () => props.roles ? "row" : void 0;
826
+ const cellRole = () => props.roles ? "cell" : void 0;
827
+ /** A cell over every column; with `scrollBody` also its `aria-colspan`. */
828
+ const spanAttrs = () => ({
829
+ colspan: props.columnCount,
830
+ role: cellRole(),
831
+ "aria-colspan": props.roles ? props.columnCount : void 0
832
+ });
833
+ const utilityAttrs = (utility) => ({
834
+ role: cellRole(),
835
+ ...pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)])
836
+ });
831
837
  const rightPanelAttrs = () => utilityAttrs("right-panel");
832
838
  const expandAttrs = () => utilityAttrs("subtable");
833
839
  const selectAttrs = () => utilityAttrs("select");
@@ -852,15 +858,20 @@ var table_body_default = /* @__PURE__ */ defineComponent({
852
858
  return expandedSnapshot.get(String(props.keyOf(item.row, item.index))) === true;
853
859
  };
854
860
  return (_ctx, _cache) => {
855
- return openBlock(), createElementBlock("tbody", { onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args)) }, [
861
+ return openBlock(), createElementBlock("tbody", {
862
+ role: __props.roles ? "rowgroup" : void 0,
863
+ onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args))
864
+ }, [
856
865
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.bodyRows, (item) => {
857
866
  return openBlock(), createElementBlock(Fragment, { key: isSpacer(item) ? item.key : __props.keyOf(item.row, item.index) }, [isSpacer(item) ? (openBlock(), createElementBlock("tr", {
858
867
  key: 0,
859
868
  class: "qt-virtual-spacer",
860
869
  "aria-hidden": "true",
870
+ role: rowRole(),
861
871
  style: normalizeStyle({ height: `${item.spacer}px` })
862
- }, [createElementVNode("td", { colspan: __props.columnCount }, null, 8, _hoisted_1$9)], 4)) : (openBlock(), createElementBlock("tr", {
872
+ }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), null, 16)], 12, _hoisted_2$5)) : (openBlock(), createElementBlock("tr", {
863
873
  key: 1,
874
+ role: rowRole(),
864
875
  "data-row-index": item.index,
865
876
  "aria-rowindex": item.aria,
866
877
  "data-pinned-row": item.pinned || void 0,
@@ -898,7 +909,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
898
909
  y1: "12",
899
910
  x2: "19",
900
911
  y2: "12"
901
- })], -1)])], 8, _hoisted_3$5)], 16)) : createCommentVNode("", true),
912
+ })], -1)])], 8, _hoisted_4$5)], 16)) : createCommentVNode("", true),
902
913
  __props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
903
914
  key: 1,
904
915
  ref_for: true
@@ -909,7 +920,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
909
920
  "aria-expanded": isRowExpanded(item),
910
921
  "aria-label": __props.labels.expandRow,
911
922
  onClick: ($event) => __props.toggle(item.row, item.index)
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),
923
+ }, [(openBlock(), createElementBlock("svg", _hoisted_6$2, [isRowExpanded(item) ? (openBlock(), createElementBlock("polyline", _hoisted_7$2)) : (openBlock(), createElementBlock("polyline", _hoisted_8$2))]))], 8, _hoisted_5$2)) : createCommentVNode("", true)], 16)) : createCommentVNode("", true),
913
924
  __props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
914
925
  key: 2,
915
926
  ref_for: true
@@ -919,38 +930,59 @@ var table_body_default = /* @__PURE__ */ defineComponent({
919
930
  "aria-label": __props.labels.selectRow,
920
931
  checked: __props.isSelected(item.row, item.index),
921
932
  onChange: ($event) => __props.toggleSelected(item.row, item.index)
922
- }, null, 40, _hoisted_8$1)], 16)) : createCommentVNode("", true),
933
+ }, null, 40, _hoisted_9$1)], 16)) : createCommentVNode("", true),
923
934
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
924
935
  return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
925
936
  key: 0,
926
- ref_for: true
927
- }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(item.row, entry.column, item.index, item.pinned)))], 16, _hoisted_9$1)) : (openBlock(), createElementBlock("td", mergeProps({
937
+ role: cellRole()
938
+ }, { ref_for: true }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(item.row, entry.column, item.index, item.pinned)))], 16, _hoisted_10)) : (openBlock(), createElementBlock("td", mergeProps({
928
939
  key: 1,
929
- ref_for: true
930
- }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), toDisplayString(unref(cellText)(item.row, entry.column)), 17, _hoisted_10))], 64);
940
+ role: cellRole()
941
+ }, { ref_for: true }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), toDisplayString(unref(cellText)(item.row, entry.column)), 17, _hoisted_11))], 64);
931
942
  }), 128))
932
- ], 8, _hoisted_2$5)), !isSpacer(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
943
+ ], 8, _hoisted_3$5)), !isSpacer(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
933
944
  key: 2,
934
945
  class: "qt-subtable-row",
946
+ role: rowRole(),
935
947
  "aria-rowindex": nextIndex(item.aria),
936
948
  "data-pinned-row": item.pinned || void 0
937
- }, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "subtable", {
949
+ }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), [renderSlot(_ctx.$slots, "subtable", {
938
950
  row: item.row,
939
951
  rowIndex: item.index
940
- })], 8, _hoisted_12)], 8, _hoisted_11)) : createCommentVNode("", true)], 64);
952
+ })], 16)], 8, _hoisted_12)) : createCommentVNode("", true)], 64);
941
953
  }), 128)),
942
- __props.loading && slots.loading ? (openBlock(), createElementBlock("tr", _hoisted_13, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "loading")], 8, _hoisted_14)])) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", _hoisted_15, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "empty")], 8, _hoisted_16)])) : createCommentVNode("", true),
943
- !__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", _hoisted_17, [createElementVNode("td", { colspan: __props.columnCount }, [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 8, _hoisted_18)])) : createCommentVNode("", true)
944
- ], 32);
954
+ __props.loading && slots.loading ? (openBlock(), createElementBlock("tr", {
955
+ key: 0,
956
+ class: "qt-loading-row",
957
+ role: rowRole()
958
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "loading")], 16)], 8, _hoisted_13)) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", {
959
+ key: 1,
960
+ class: "qt-empty-row",
961
+ role: rowRole()
962
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "empty")], 16)], 8, _hoisted_14)) : createCommentVNode("", true),
963
+ !__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", {
964
+ key: 2,
965
+ class: "qt-load-more-row",
966
+ role: rowRole()
967
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 16)], 8, _hoisted_15)) : createCommentVNode("", true)
968
+ ], 40, _hoisted_1$9);
945
969
  };
946
970
  }
947
971
  });
948
972
  //#endregion
949
973
  //#region src/parts/table-footer.vue?vue&type=script&setup=true&lang.ts
950
- var _hoisted_1$8 = { class: "qt-footer" };
951
- var _hoisted_2$4 = ["aria-rowindex"];
952
- var _hoisted_3$4 = ["colspan"];
953
- var _hoisted_4$3 = ["data-field", "data-type"];
974
+ var _hoisted_1$8 = ["role"];
975
+ var _hoisted_2$4 = ["role", "aria-rowindex"];
976
+ var _hoisted_3$4 = [
977
+ "colspan",
978
+ "role",
979
+ "aria-colspan"
980
+ ];
981
+ var _hoisted_4$4 = [
982
+ "data-field",
983
+ "data-type",
984
+ "role"
985
+ ];
954
986
  //#endregion
955
987
  //#region src/parts/table-footer.vue
956
988
  var table_footer_default = /* @__PURE__ */ defineComponent({
@@ -961,26 +993,34 @@ var table_footer_default = /* @__PURE__ */ defineComponent({
961
993
  utilityCount: {},
962
994
  hasPinned: { type: Boolean },
963
995
  offsets: {},
964
- firstRowIndex: {}
996
+ firstRowIndex: {},
997
+ roles: { type: Boolean }
965
998
  },
966
999
  setup(__props) {
967
1000
  const footerText = (row, column) => row.cells.find((cell) => cell.field === column.field)?.text;
968
1001
  return (_ctx, _cache) => {
969
- return openBlock(), createElementBlock("tfoot", _hoisted_1$8, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.footerRows, (footerRow, i) => {
1002
+ return openBlock(), createElementBlock("tfoot", {
1003
+ class: "qt-footer",
1004
+ role: __props.roles ? "rowgroup" : void 0
1005
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.footerRows, (footerRow, i) => {
970
1006
  return openBlock(), createElementBlock("tr", {
971
1007
  key: i,
1008
+ role: __props.roles ? "row" : void 0,
972
1009
  "aria-rowindex": __props.firstRowIndex === void 0 ? void 0 : __props.firstRowIndex + i
973
1010
  }, [__props.utilityCount > 0 ? (openBlock(), createElementBlock("td", mergeProps({
974
1011
  key: 0,
975
- colspan: __props.utilityCount
1012
+ colspan: __props.utilityCount,
1013
+ role: __props.roles ? "cell" : void 0,
1014
+ "aria-colspan": __props.roles ? __props.utilityCount : void 0
976
1015
  }, { ref_for: true }, unref(pinAttrs)(__props.hasPinned ? "left" : false, 0)), null, 16, _hoisted_3$4)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
977
1016
  return openBlock(), createElementBlock("td", mergeProps({
978
1017
  key: entry.column.field,
979
1018
  "data-field": entry.column.field,
980
- "data-type": unref(columnTypeOf$1)(entry.column)
981
- }, { ref_for: true }, unref(pinAttrs)(unref(sideOf)(entry.column), __props.offsets[entry.column.field])), toDisplayString(footerText(footerRow, entry.column)), 17, _hoisted_4$3);
1019
+ "data-type": unref(columnTypeOf$1)(entry.column),
1020
+ role: __props.roles ? "cell" : void 0
1021
+ }, { ref_for: true }, unref(pinAttrs)(unref(sideOf)(entry.column), __props.offsets[entry.column.field])), toDisplayString(footerText(footerRow, entry.column)), 17, _hoisted_4$4);
982
1022
  }), 128))], 8, _hoisted_2$4);
983
- }), 128))]);
1023
+ }), 128))], 8, _hoisted_1$8);
984
1024
  };
985
1025
  }
986
1026
  });
@@ -1041,15 +1081,15 @@ var _hoisted_3$3 = [
1041
1081
  "value",
1042
1082
  "readonly"
1043
1083
  ];
1044
- var _hoisted_4$2 = [
1084
+ var _hoisted_4$3 = [
1045
1085
  "aria-label",
1046
1086
  "value",
1047
1087
  "disabled"
1048
1088
  ];
1049
- var _hoisted_5 = { value: "" };
1050
- var _hoisted_6 = { value: "true" };
1051
- var _hoisted_7 = { value: "false" };
1052
- var _hoisted_8 = [
1089
+ var _hoisted_5$1 = { value: "" };
1090
+ var _hoisted_6$1 = { value: "true" };
1091
+ var _hoisted_7$1 = { value: "false" };
1092
+ var _hoisted_8$1 = [
1053
1093
  "type",
1054
1094
  "aria-label",
1055
1095
  "value",
@@ -1145,10 +1185,10 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
1145
1185
  disabled: unref(filters).multiOf(__props.column.field) > 0,
1146
1186
  onChange: _cache[4] || (_cache[4] = ($event) => pick($event))
1147
1187
  }, [
1148
- createElementVNode("option", _hoisted_5, toDisplayString(unref(labels)().boolAll), 1),
1149
- createElementVNode("option", _hoisted_6, toDisplayString(unref(labels)().boolTrue), 1),
1150
- createElementVNode("option", _hoisted_7, toDisplayString(unref(labels)().boolFalse), 1)
1151
- ], 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", {
1188
+ createElementVNode("option", _hoisted_5$1, toDisplayString(unref(labels)().boolAll), 1),
1189
+ createElementVNode("option", _hoisted_6$1, toDisplayString(unref(labels)().boolTrue), 1),
1190
+ createElementVNode("option", _hoisted_7$1, toDisplayString(unref(labels)().boolFalse), 1)
1191
+ ], 40, _hoisted_4$3)) : (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", {
1152
1192
  key: 1,
1153
1193
  type: unref(filters).multiOf(__props.column.field) ? "text" : "date",
1154
1194
  class: "qt-filter-input",
@@ -1157,7 +1197,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
1157
1197
  readonly: unref(filters).multiOf(__props.column.field) > 0,
1158
1198
  onInput: _cache[5] || (_cache[5] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
1159
1199
  onKeydown: _cache[6] || (_cache[6] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
1160
- }, null, 40, _hoisted_8))], 64)),
1200
+ }, null, 40, _hoisted_8$1))], 64)),
1161
1201
  __props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0, 4) : createCommentVNode("", true),
1162
1202
  labelOf() ? (openBlock(), createElementBlock("small", _hoisted_9, toDisplayString(labelOf()), 1)) : createCommentVNode("", true)
1163
1203
  ]);
@@ -1232,8 +1272,11 @@ var styleSwap = () => {
1232
1272
  * between, and slot content that draws a block or a flex box counts with the
1233
1273
  * width its content needs, not the width its cell gives it. Only `fields`
1234
1274
  * when given; a column with no box (the table not displayed) is left out.
1275
+ * With `scrollBody` the data rows are in a table of their own, `body`
1276
+ * (C-101): it is laid out the same way, its `col` widths left out, and a
1277
+ * column takes the wider of its header cell and its body cells.
1235
1278
  */
1236
- var measureColumnWidths = (table, fields) => {
1279
+ var measureColumnWidths = (table, fields, body) => {
1237
1280
  const widths = {};
1238
1281
  if (!table?.tHead) return widths;
1239
1282
  const wanted = fields ? new Set(fields) : null;
@@ -1245,10 +1288,20 @@ var measureColumnWidths = (table, fields) => {
1245
1288
  swap.set(table, "min-width", "0");
1246
1289
  for (const th of headers) swap.set(th, "width", "auto");
1247
1290
  for (const part of Array.from(table.querySelectorAll(notCounted))) swap.set(part, "display", "none");
1291
+ const split = body && body !== table ? body : null;
1292
+ if (split) {
1293
+ swap.set(split, "table-layout", "auto");
1294
+ swap.set(split, "width", "max-content");
1295
+ swap.set(split, "min-width", "0");
1296
+ for (const col of Array.from(split.querySelectorAll(":scope > colgroup > col"))) swap.set(col, "width", "auto");
1297
+ for (const part of Array.from(split.querySelectorAll(":scope > tbody > tr:not([data-row-index])"))) swap.set(part, "display", "none");
1298
+ }
1299
+ const firstRow = split?.querySelector(":scope > tbody > tr[data-row-index]");
1248
1300
  for (const th of headers) {
1249
1301
  const field = th.dataset.field;
1250
1302
  if (field === void 0 || wanted && !wanted.has(field)) continue;
1251
- const width = th.getBoundingClientRect().width;
1303
+ const cell = firstRow?.querySelector(`:scope > td[data-field="${CSS.escape(field)}"]`);
1304
+ const width = Math.max(th.getBoundingClientRect().width, cell?.getBoundingClientRect().width ?? 0);
1252
1305
  if (width > 0) widths[field] = Math.ceil(width);
1253
1306
  }
1254
1307
  } finally {
@@ -1257,6 +1310,68 @@ var measureColumnWidths = (table, fields) => {
1257
1310
  return widths;
1258
1311
  };
1259
1312
  //#endregion
1313
+ //#region src/resize/width-scale.ts
1314
+ var same = (width) => width;
1315
+ var sum = (widths) => widths.reduce((a, b) => a + b, 0);
1316
+ /** The declared width is the drawn one. */
1317
+ var identityScale = {
1318
+ declared: same,
1319
+ rendered: same
1320
+ };
1321
+ /**
1322
+ * A table whose cells take `space` (a container's width, with
1323
+ * `min-width: 100%`) and whose columns are declared narrower: the fixed
1324
+ * layout spreads the rest over the columns by their declared widths, so a
1325
+ * column declared `w` next to `others` is drawn `w * space / (w + others)`
1326
+ * wide until the columns fill the space, and `w` from there on. With no other
1327
+ * column the one column takes the space whatever its width: the identity.
1328
+ */
1329
+ var stretchedScale = (space, others) => others > 0 && space > others ? {
1330
+ declared: (rendered) => rendered >= space - others ? rendered : rendered * others / (space - rendered),
1331
+ rendered: (declared) => declared + others >= space ? declared : declared * space / (declared + others)
1332
+ } : identityScale;
1333
+ /**
1334
+ * How the declared width of the column of `th` maps to its drawn width, read
1335
+ * from the layout. The column is drawn once at the width it is drawn at now.
1336
+ * Wider there, the table stretches it: its row's cells take the whole space,
1337
+ * and the other columns' declared widths follow from the stretch; the fit
1338
+ * must then give back the width the column is drawn at now. Not wider, the
1339
+ * column is drawn once more at `low`, the narrowest width a resize writes. A
1340
+ * table that stretches it there widens every cell of the row by one factor,
1341
+ * the column at least as much (content the fixed layout keeps wider than
1342
+ * `low` only adds to it), and its cells then take the space the columns can
1343
+ * shrink into before the table stretches them. Any other layout gets the
1344
+ * identity: one that never stretches, a column without a width that takes
1345
+ * what is left, one that spreads the space otherwise. Every style is put back before the
1346
+ * function returns (C-31), so nothing is painted in between.
1347
+ */
1348
+ var measureWidthScale = (th, low) => {
1349
+ const now = th.getBoundingClientRect().width;
1350
+ const others = Array.from(th.parentElement?.children ?? []).filter((cell) => cell !== th);
1351
+ const widths = () => others.map((cell) => cell.getBoundingClientRect().width);
1352
+ const swap = styleSwap();
1353
+ /** Draws the column `width` wide; the width it takes. */
1354
+ const draw = (width) => {
1355
+ swap.set(th, "width", `${width}px`);
1356
+ return th.getBoundingClientRect().width;
1357
+ };
1358
+ try {
1359
+ const drawn = draw(now);
1360
+ const before = widths();
1361
+ const rest = sum(before);
1362
+ if (drawn > now + .5) {
1363
+ const scale = stretchedScale(drawn + rest, now * rest / drawn);
1364
+ return Math.abs(draw(scale.declared(now)) - now) <= 1 ? scale : identityScale;
1365
+ }
1366
+ const narrow = draw(low);
1367
+ const after = widths();
1368
+ const factor = sum(after) / rest;
1369
+ return factor > 1 && narrow >= low * factor - 1 && after.every((width, i) => Math.abs(width - before[i] * factor) <= 1) ? stretchedScale(narrow + sum(after), rest) : identityScale;
1370
+ } finally {
1371
+ swap.restore();
1372
+ }
1373
+ };
1374
+ //#endregion
1260
1375
  //#region src/resize/use-column-resize.ts
1261
1376
  /** Default `Column.minWidth`, in pixels. */
1262
1377
  var defaultMinWidth = 40;
@@ -1286,18 +1401,27 @@ var cellOf = (event) => event.currentTarget.closest("th");
1286
1401
  */
1287
1402
  var edgeOf = (column) => column.pinned === "right" ? -1 : 1;
1288
1403
  /**
1404
+ * The scale of a column's widths, read from the layout once per drag or key:
1405
+ * a table stretched to its container draws a column wider than declared.
1406
+ */
1407
+ var scaleOf = (th, column) => measureWidthScale(th, clampWidth(column, 0));
1408
+ /**
1289
1409
  * Resizing a column (C-48 to C-50). The table holds a width only while a
1290
1410
  * drag is under way (the preview, P2); every committed width goes out as a
1291
1411
  * `columnResize` event and comes back, if the consumer wants it, as
1292
1412
  * `Column.width`. The handle captures the pointer, so all drag events arrive
1293
- * at the handle itself, and it has the focus, so Escape does too.
1413
+ * at the handle itself, and it has the focus, so Escape does too. The pointer
1414
+ * and the arrow keys move the drawn width; what the table writes and emits is
1415
+ * the declared width that draws it (`measureWidthScale`).
1294
1416
  */
1295
1417
  var useColumnResize = (options) => {
1418
+ /** `width` is declared (the inline style), `rendered` drawn. */
1296
1419
  const preview = shallowRef(null);
1297
1420
  let drag = null;
1298
1421
  const isResizable = (column) => options.resizable() && column.resizable !== false;
1299
1422
  /** The width the header shows: the preview while dragging, else measured. */
1300
- const widthOf = (column) => preview.value?.field === column.field ? preview.value.width : Math.round(options.measuredWidth(column.field) ?? 0);
1423
+ const widthOf = (column) => preview.value?.field === column.field ? preview.value.rendered : Math.round(options.measuredWidth(column.field) ?? 0);
1424
+ /** Emits the declared width `width`, unless it is the declared `from`. */
1301
1425
  const commit = (column, from, width) => {
1302
1426
  const next = clampWidth(column, width);
1303
1427
  if (next !== Math.round(from)) options.emit({
@@ -1305,14 +1429,15 @@ var useColumnResize = (options) => {
1305
1429
  width: next
1306
1430
  });
1307
1431
  };
1308
- const dragged = (current) => current.startWidth + edgeOf(current.column) * (current.lastX - current.startX);
1432
+ /** The declared width that draws the column where the pointer is. */
1433
+ const dragged = (current) => current.scale.declared(current.startWidth + edgeOf(current.column) * (current.lastX - current.startX));
1309
1434
  const end = (apply) => {
1310
1435
  const current = drag;
1311
1436
  if (current) {
1312
1437
  drag = null;
1313
1438
  cancelAnimationFrame(current.frame);
1314
1439
  preview.value = null;
1315
- if (apply) commit(current.column, current.startWidth, dragged(current));
1440
+ if (apply) commit(current.column, current.scale.declared(current.startWidth), dragged(current));
1316
1441
  }
1317
1442
  };
1318
1443
  /** Every pointer event of a handle; one listener for the whole drag. */
@@ -1329,6 +1454,7 @@ var useColumnResize = (options) => {
1329
1454
  pointerId: event.pointerId,
1330
1455
  startX: event.clientX,
1331
1456
  startWidth: th.getBoundingClientRect().width,
1457
+ scale: scaleOf(th, column),
1332
1458
  lastX: event.clientX,
1333
1459
  frame: 0
1334
1460
  };
@@ -1339,15 +1465,20 @@ var useColumnResize = (options) => {
1339
1465
  if (event.type === "pointermove") drag.frame ||= requestAnimationFrame(() => {
1340
1466
  if (drag) {
1341
1467
  drag.frame = 0;
1468
+ const width = clampWidth(drag.column, dragged(drag));
1342
1469
  preview.value = {
1343
1470
  field: drag.column.field,
1344
- width: clampWidth(drag.column, dragged(drag))
1471
+ width,
1472
+ rendered: Math.round(drag.scale.rendered(width))
1345
1473
  };
1346
1474
  }
1347
1475
  });
1348
1476
  else end(event.type === "pointerup");
1349
1477
  };
1350
- /** Arrow keys step the width, Enter fits it; both from the rendered width. */
1478
+ /**
1479
+ * Arrow keys step the drawn width, Enter fits it to the content (the
1480
+ * declared width `measureColumnWidths` gives, as it is).
1481
+ */
1351
1482
  const onKey = (event, column) => {
1352
1483
  const { key } = event;
1353
1484
  if (drag) {
@@ -1362,8 +1493,11 @@ var useColumnResize = (options) => {
1362
1493
  const th = cellOf(event);
1363
1494
  if (th && (sign || key === "Enter" || event.type === "dblclick")) {
1364
1495
  event.preventDefault();
1365
- const from = th.getBoundingClientRect().width;
1366
- const to = sign ? Math.round(from) + sign * (event.shiftKey ? 50 : 10) : measureColumnWidths(th.closest("table"), [column.field])[column.field];
1496
+ const drawn = th.getBoundingClientRect().width;
1497
+ const scale = scaleOf(th, column);
1498
+ const from = scale.declared(drawn);
1499
+ const step = scale.declared(Math.round(drawn) + sign * (event.shiftKey ? 50 : 10));
1500
+ const to = sign ? from + sign * Math.max(1, Math.abs(step - from)) : measureColumnWidths(th.closest("table"), [column.field], options.body())[column.field];
1367
1501
  if (to !== void 0) commit(column, from, to);
1368
1502
  }
1369
1503
  };
@@ -1457,7 +1591,7 @@ var _hoisted_3$2 = {
1457
1591
  viewBox: "0 0 16 16",
1458
1592
  "aria-hidden": "true"
1459
1593
  };
1460
- var _hoisted_4$1 = {
1594
+ var _hoisted_4$2 = {
1461
1595
  key: 2,
1462
1596
  class: "qt-sort-icon",
1463
1597
  width: "14",
@@ -1487,7 +1621,7 @@ var sort_button_default = /* @__PURE__ */ defineComponent({
1487
1621
  }, null, -1)])])) : __props.direction === "desc" ? (openBlock(), createElementBlock("svg", _hoisted_3$2, [..._cache[2] || (_cache[2] = [createElementVNode("path", {
1488
1622
  d: "M8 12.5L3.5 6.5H12.5L8 12.5Z",
1489
1623
  fill: "currentColor"
1490
- }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_4$1, [..._cache[3] || (_cache[3] = [createElementVNode("path", {
1624
+ }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_4$2, [..._cache[3] || (_cache[3] = [createElementVNode("path", {
1491
1625
  d: "M8 3L11.5 7H4.5L8 3Z",
1492
1626
  fill: "currentColor"
1493
1627
  }, null, -1), createElementVNode("path", {
@@ -1503,17 +1637,22 @@ var sort_button_default = /* @__PURE__ */ defineComponent({
1503
1637
  var ariaSort = (direction) => direction === "asc" ? "ascending" : direction === "desc" ? "descending" : void 0;
1504
1638
  //#endregion
1505
1639
  //#region src/parts/table-header.vue?vue&type=script&setup=true&lang.ts
1506
- var _hoisted_1$2 = [
1640
+ var _hoisted_1$2 = ["role"];
1641
+ var _hoisted_2$1 = ["role"];
1642
+ var _hoisted_3$1 = [
1507
1643
  "aria-label",
1508
1644
  "checked",
1509
1645
  "indeterminate"
1510
1646
  ];
1511
- var _hoisted_2$1 = [
1647
+ var _hoisted_4$1 = ["role"];
1648
+ var _hoisted_5 = ["role"];
1649
+ var _hoisted_6 = [
1512
1650
  "title",
1513
1651
  "aria-label",
1514
1652
  "disabled"
1515
1653
  ];
1516
- var _hoisted_3$1 = [
1654
+ var _hoisted_7 = [
1655
+ "role",
1517
1656
  "data-field",
1518
1657
  "data-type",
1519
1658
  "data-sort",
@@ -1521,7 +1660,7 @@ var _hoisted_3$1 = [
1521
1660
  "data-filtered",
1522
1661
  "aria-sort"
1523
1662
  ];
1524
- var _hoisted_4 = {
1663
+ var _hoisted_8 = {
1525
1664
  key: 3,
1526
1665
  class: "qt-title"
1527
1666
  };
@@ -1537,7 +1676,8 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1537
1676
  hasPinned: { type: Boolean },
1538
1677
  offsets: {},
1539
1678
  autoWidths: {},
1540
- slotNames: {}
1679
+ slotNames: {},
1680
+ roles: { type: Boolean }
1541
1681
  },
1542
1682
  setup(__props) {
1543
1683
  const props = __props;
@@ -1584,10 +1724,11 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1584
1724
  control: layout.controlOf(column.field)
1585
1725
  });
1586
1726
  return (_ctx, _cache) => {
1587
- return openBlock(), createElementBlock("tr", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.utilities, (utility) => {
1727
+ return openBlock(), createElementBlock("tr", { role: __props.roles ? "row" : void 0 }, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.utilities, (utility) => {
1588
1728
  return openBlock(), createElementBlock(Fragment, { key: utility }, [utility === "select" ? (openBlock(), createElementBlock("th", mergeProps({
1589
1729
  key: 0,
1590
- scope: "col"
1730
+ scope: "col",
1731
+ role: __props.roles ? "columnheader" : void 0
1591
1732
  }, { ref_for: true }, utilityAttrs(utility)), [createElementVNode("input", {
1592
1733
  type: "checkbox",
1593
1734
  class: "qt-select-all",
@@ -1595,12 +1736,13 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1595
1736
  checked: unref(selection).allSelected.value,
1596
1737
  indeterminate: unref(selection).someSelected.value,
1597
1738
  onChange: _cache[0] || (_cache[0] = ($event) => unref(selection).toggleAll($event.target.checked))
1598
- }, null, 40, _hoisted_1$2)], 16)) : !hostsClearAll(utility) ? (openBlock(), createElementBlock("td", mergeProps({
1739
+ }, null, 40, _hoisted_3$1)], 16, _hoisted_2$1)) : !hostsClearAll(utility) ? (openBlock(), createElementBlock("td", mergeProps({
1599
1740
  key: 1,
1600
- ref_for: true
1601
- }, utilityAttrs(utility)), null, 16)) : (openBlock(), createElementBlock("th", mergeProps({
1741
+ role: __props.roles ? "cell" : void 0
1742
+ }, { ref_for: true }, utilityAttrs(utility)), null, 16, _hoisted_4$1)) : (openBlock(), createElementBlock("th", mergeProps({
1602
1743
  key: 2,
1603
- scope: "col"
1744
+ scope: "col",
1745
+ role: __props.roles ? "columnheader" : void 0
1604
1746
  }, { ref_for: true }, utilityAttrs(utility)), [createElementVNode("button", {
1605
1747
  type: "button",
1606
1748
  class: "qt-clear-all-button",
@@ -1628,11 +1770,12 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1628
1770
  y1: "6",
1629
1771
  x2: "18",
1630
1772
  y2: "18"
1631
- })], -1)])], 8, _hoisted_2$1)], 16))], 64);
1773
+ })], -1)])], 8, _hoisted_6)], 16, _hoisted_5))], 64);
1632
1774
  }), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
1633
1775
  return openBlock(), createElementBlock("th", mergeProps({
1634
1776
  key: column.field,
1635
1777
  scope: "col",
1778
+ role: __props.roles ? "columnheader" : void 0,
1636
1779
  "data-field": column.field,
1637
1780
  "data-type": unref(columnTypeOf$1)(column),
1638
1781
  "data-sort": unref(sort).sortOf(column) ?? void 0,
@@ -1656,7 +1799,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1656
1799
  "column",
1657
1800
  "direction",
1658
1801
  "onClick"
1659
- ])) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(column.title), 1)),
1802
+ ])) : (openBlock(), createElementBlock("span", _hoisted_8, toDisplayString(column.title), 1)),
1660
1803
  hasFilter(column) ? (openBlock(), createBlock(filter_cell_default, {
1661
1804
  key: 4,
1662
1805
  column,
@@ -1679,8 +1822,8 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1679
1822
  key: 5,
1680
1823
  column
1681
1824
  }, null, 8, ["column"])) : createCommentVNode("", true)
1682
- ], 16, _hoisted_3$1);
1683
- }), 128))]);
1825
+ ], 16, _hoisted_7);
1826
+ }), 128))], 8, _hoisted_1$2);
1684
1827
  };
1685
1828
  }
1686
1829
  });
@@ -1723,6 +1866,11 @@ var useHeaderGeometry = (options) => {
1723
1866
  * right-pinned one, by key, in pixels.
1724
1867
  */
1725
1868
  const offsets = shallowRef({});
1869
+ /**
1870
+ * The exact width of every header cell, in drawing order: the `col` widths
1871
+ * of the body and footer tables with `scrollBody` (C-101).
1872
+ */
1873
+ const columns = shallowRef([]);
1726
1874
  let observer = null;
1727
1875
  const headerCells = (table) => table.querySelectorAll(":scope > thead > tr > *");
1728
1876
  const measure = (table) => {
@@ -1731,11 +1879,13 @@ var useHeaderGeometry = (options) => {
1731
1879
  const next = {};
1732
1880
  const nextOffsets = {};
1733
1881
  const rights = [];
1882
+ const nextColumns = [];
1734
1883
  let left = 0;
1735
1884
  headerCells(table).forEach((cell, index) => {
1736
1885
  const drawn = cells[index];
1737
1886
  if (drawn) {
1738
1887
  const exact = cell.getBoundingClientRect().width;
1888
+ nextColumns.push(exact);
1739
1889
  next[drawn.key] = Math.round(exact);
1740
1890
  if (drawn.side === "left") {
1741
1891
  nextOffsets[drawn.key] = left;
@@ -1751,6 +1901,7 @@ var useHeaderGeometry = (options) => {
1751
1901
  }
1752
1902
  if (signature(next) !== signature(widths.value)) widths.value = next;
1753
1903
  if (signature(nextOffsets) !== signature(offsets.value)) offsets.value = nextOffsets;
1904
+ if (signature(nextColumns) !== signature(columns.value)) columns.value = nextColumns;
1754
1905
  };
1755
1906
  const observe = () => {
1756
1907
  observer?.disconnect();
@@ -1758,6 +1909,7 @@ var useHeaderGeometry = (options) => {
1758
1909
  const table = options.table.value;
1759
1910
  if (!table || !options.active() || typeof ResizeObserver === "undefined") {
1760
1911
  if (Object.keys(offsets.value).length > 0) offsets.value = {};
1912
+ if (columns.value.length > 0) columns.value = [];
1761
1913
  return;
1762
1914
  }
1763
1915
  const current = new ResizeObserver(() => {
@@ -1787,7 +1939,8 @@ var useHeaderGeometry = (options) => {
1787
1939
  return {
1788
1940
  widths,
1789
1941
  tableWidth,
1790
- offsets
1942
+ offsets,
1943
+ columns
1791
1944
  };
1792
1945
  };
1793
1946
  //#endregion
@@ -1986,7 +2139,7 @@ var useAutoWidth = (options) => {
1986
2139
  result = cloneQuery(query);
1987
2140
  }
1988
2141
  if (options.rows().length === 0) return;
1989
- const measured = measureColumnWidths(table, columns.map((column) => column.field));
2142
+ const measured = measureColumnWidths(table, columns.map((column) => column.field), options.body());
1990
2143
  if (Object.keys(measured).length === 0) {
1991
2144
  waiting = true;
1992
2145
  return;
@@ -2040,6 +2193,71 @@ var useAutoWidth = (options) => {
2040
2193
  return { widths };
2041
2194
  };
2042
2195
  //#endregion
2196
+ //#region src/scroll/use-scroll-body.ts
2197
+ var isDevelopment$1 = () => {
2198
+ try {
2199
+ return process.env.NODE_ENV !== "production";
2200
+ } catch {
2201
+ return true;
2202
+ }
2203
+ };
2204
+ /**
2205
+ * Header, body and footer of `scrollBody` scroll sideways together (C-101):
2206
+ * one passive `scroll` listener on each wrapper sets the `scrollLeft` of the
2207
+ * others to its own. A position written here is remembered, so the `scroll`
2208
+ * event it fires is not taken for one of the user's. The table writes no
2209
+ * style and no attribute to the wrappers. Off, nothing is listened to.
2210
+ */
2211
+ var useScrollBody = (options) => {
2212
+ let attached = [];
2213
+ /** The `scrollLeft` this table wrote to a wrapper, until its event. */
2214
+ const written = /* @__PURE__ */ new WeakMap();
2215
+ let warned = false;
2216
+ let clamped = false;
2217
+ /** Every wrapper but `source` to `left`, remembering what was written. */
2218
+ const follow = (source, left) => {
2219
+ for (const element of attached) if (element !== source && element.scrollLeft !== left) {
2220
+ element.scrollLeft = left;
2221
+ written.set(element, element.scrollLeft);
2222
+ if (!clamped && source === options.wrappers().body && left - element.scrollLeft >= 1 && isDevelopment$1()) {
2223
+ clamped = true;
2224
+ console.warn("[QueryTable] `scrollBody`: `.qt-table-head` or `.qt-table-foot` cannot scroll sideways as far as `.qt-table-body`, so its columns end shifted. Give it a vertical scrollbar as wide as that of the body (`overflow-y: scroll`; a transparent `scrollbar-color` hides it) (C-101).");
2225
+ }
2226
+ }
2227
+ };
2228
+ const onScroll = (event) => {
2229
+ const source = event.currentTarget;
2230
+ const left = source.scrollLeft;
2231
+ const echo = written.get(source);
2232
+ written.delete(source);
2233
+ if (echo !== left) follow(source, left);
2234
+ };
2235
+ const detach = () => {
2236
+ for (const element of attached) element.removeEventListener("scroll", onScroll);
2237
+ attached = [];
2238
+ };
2239
+ watch(() => options.enabled() ? options.wrappers() : null, (wrappers) => {
2240
+ detach();
2241
+ if (!wrappers) return;
2242
+ attached = [
2243
+ wrappers.head,
2244
+ wrappers.body,
2245
+ wrappers.foot
2246
+ ].filter((element) => element !== null);
2247
+ for (const element of attached) element.addEventListener("scroll", onScroll, { passive: true });
2248
+ if (wrappers.body) follow(wrappers.body, wrappers.body.scrollLeft);
2249
+ const table = options.bodyTable();
2250
+ if (table && !warned && isDevelopment$1() && getComputedStyle(table).tableLayout !== "fixed") {
2251
+ warned = true;
2252
+ console.warn("[QueryTable] `scrollBody` with `table-layout: auto` on the body table: its columns follow its rows, not the header. Set `table-layout: fixed` (C-101).");
2253
+ }
2254
+ }, {
2255
+ flush: "post",
2256
+ immediate: true
2257
+ });
2258
+ onBeforeUnmount(detach);
2259
+ };
2260
+ //#endregion
2043
2261
  //#region src/use-query-table.ts
2044
2262
  /** The TanStack features of a Query Table, the two plugins included. */
2045
2263
  var features = tableFeatures({
@@ -3186,8 +3404,12 @@ var _hoisted_1 = [
3186
3404
  "data-loading",
3187
3405
  "aria-busy"
3188
3406
  ];
3189
- var _hoisted_2 = { class: "qt-table-responsive" };
3190
- var _hoisted_3 = ["aria-rowcount"];
3407
+ var _hoisted_2 = ["role", "aria-rowcount"];
3408
+ var _hoisted_3 = {
3409
+ class: "qt-table",
3410
+ role: "presentation"
3411
+ };
3412
+ var _hoisted_4 = ["aria-rowcount"];
3191
3413
  //#endregion
3192
3414
  //#region src/query-table.vue
3193
3415
  var query_table_default = /* @__PURE__ */ defineComponent({
@@ -3255,6 +3477,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3255
3477
  type: [Boolean, Object],
3256
3478
  default: false
3257
3479
  },
3480
+ scrollBody: {
3481
+ type: Boolean,
3482
+ default: false
3483
+ },
3258
3484
  infinite: {
3259
3485
  type: [Boolean, Object],
3260
3486
  default: false
@@ -3332,8 +3558,17 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3332
3558
  const columnCount = computed(() => entries.value.length + utilityCount.value);
3333
3559
  /** Utilities are pinned only with a left-pinned column (C-46, C-71). */
3334
3560
  const utilitySide = () => hasPinned.value ? "left" : false;
3561
+ /** The table of the header: with `scrollBody` the first of three (C-101). */
3335
3562
  const tableEl = shallowRef(null);
3336
- const { widths, tableWidth, offsets } = useHeaderGeometry({
3563
+ const bodyTableEl = shallowRef(null);
3564
+ const headWrap = shallowRef(null);
3565
+ const bodyWrap = shallowRef(null);
3566
+ const footWrap = shallowRef(null);
3567
+ /** The table of the body rows. */
3568
+ const bodyTable = computed(() => bodyTableEl.value ?? tableEl.value);
3569
+ /** With `scrollBody`, the body table to measure apart from the header. */
3570
+ const splitBody = () => props.scrollBody ? bodyTableEl.value : null;
3571
+ const { widths, tableWidth, offsets, columns: cellWidths } = useHeaderGeometry({
3337
3572
  table: tableEl,
3338
3573
  cells: () => [...utilities.value.map((utility) => ({
3339
3574
  key: utilityKey(utility),
@@ -3342,12 +3577,24 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3342
3577
  key: column.field,
3343
3578
  side: sideOf(column)
3344
3579
  }))],
3345
- active: () => entries.value.some((entry) => sideOf(entry.column) !== false) || props.resizable && entries.value.some((entry) => entry.column.resizable !== false)
3580
+ active: () => props.scrollBody || entries.value.some((entry) => sideOf(entry.column) !== false) || props.resizable && entries.value.some((entry) => entry.column.resizable !== false)
3581
+ });
3582
+ /** The `col` widths of the body and footer tables (C-101), in pixels. */
3583
+ const colWidths = computed(() => Array.from({ length: columnCount.value }, (_, i) => cellWidths.value[i]));
3584
+ useScrollBody({
3585
+ enabled: () => props.scrollBody,
3586
+ wrappers: () => ({
3587
+ head: headWrap.value,
3588
+ body: bodyWrap.value,
3589
+ foot: footWrap.value
3590
+ }),
3591
+ bodyTable: () => bodyTableEl.value
3346
3592
  });
3347
3593
  const resize = useColumnResize({
3348
3594
  resizable: () => props.resizable,
3349
3595
  measuredWidth: (field) => widths.value[field],
3350
3596
  tableWidth: () => tableWidth.value,
3597
+ body: splitBody,
3351
3598
  emit: (payload) => {
3352
3599
  emit("columnResize", payload);
3353
3600
  const next = applyWidth(props.columns, payload.field, `${payload.width}px`);
@@ -3358,6 +3605,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3358
3605
  enabled: () => props.autoWidth,
3359
3606
  max: () => props.autoWidthMax,
3360
3607
  table: tableEl,
3608
+ body: splitBody,
3361
3609
  columns: () => visibleColumns.value,
3362
3610
  rows: () => props.rows,
3363
3611
  query: () => props.query,
@@ -3365,7 +3613,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3365
3613
  });
3366
3614
  const rowWindow = useRowWindow({
3367
3615
  virtual: () => props.virtual,
3368
- table: tableEl,
3616
+ table: bodyTable,
3369
3617
  bodyRows: () => state.rowPinning.rows.value,
3370
3618
  keyOf: expansion.keyOf,
3371
3619
  isExpanded: expansion.isExpanded
@@ -3379,7 +3627,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3379
3627
  cursors: () => props.cursors,
3380
3628
  loading: () => props.loading,
3381
3629
  nextPage: () => paginationProps.value.nextPage(),
3382
- table: tableEl,
3630
+ table: bodyTable,
3383
3631
  virtual: rowWindow.enabled,
3384
3632
  window: () => rowWindow.ready.value ? {
3385
3633
  end: rowWindow.range.value.end,
@@ -3410,7 +3658,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3410
3658
  loading: () => props.loading,
3411
3659
  fields: () => entries.value.map((entry) => entry.column.field),
3412
3660
  rowKey: () => props.rowKey,
3413
- table: tableEl
3661
+ table: bodyTable
3414
3662
  });
3415
3663
  const reorder = useColumnReorder({
3416
3664
  reorderable: () => props.reorderable,
@@ -3451,7 +3699,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3451
3699
  },
3452
3700
  scrollToIndex: rowWindow.scrollToIndex,
3453
3701
  loadMore: infinite.loadMore,
3454
- measureColumnWidths: (fields) => measureColumnWidths(tableEl.value, fields)
3702
+ measureColumnWidths: (fields) => measureColumnWidths(tableEl.value, fields, splitBody())
3455
3703
  });
3456
3704
  return (_ctx, _cache) => {
3457
3705
  return openBlock(), createElementBlock("div", {
@@ -3461,13 +3709,156 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3461
3709
  "aria-busy": __props.loading ? "true" : void 0
3462
3710
  }, [
3463
3711
  renderSlot(_ctx.$slots, "toolbar", normalizeProps(guardReactiveProps(toolbarProps()))),
3464
- createElementVNode("div", _hoisted_2, [createElementVNode("table", {
3712
+ createElementVNode("div", {
3713
+ class: "qt-table-responsive",
3714
+ role: __props.scrollBody ? "table" : void 0,
3715
+ "aria-rowcount": __props.scrollBody ? ariaRowCount.value : void 0
3716
+ }, [__props.scrollBody ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3717
+ createElementVNode("div", {
3718
+ ref_key: "headWrap",
3719
+ ref: headWrap,
3720
+ class: "qt-table-head"
3721
+ }, [createElementVNode("table", {
3722
+ ref_key: "tableEl",
3723
+ ref: tableEl,
3724
+ class: "qt-table",
3725
+ role: "presentation"
3726
+ }, [createElementVNode("thead", {
3727
+ role: "rowgroup",
3728
+ onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onHeaderContextMenu) && unref(onHeaderContextMenu)(...args))
3729
+ }, [createVNode(table_header_default, {
3730
+ columns: visibleColumns.value,
3731
+ query: __props.query,
3732
+ filterable: __props.filterable,
3733
+ utilities: utilities.value,
3734
+ "has-pinned": unref(hasPinned),
3735
+ offsets: unref(offsets),
3736
+ "auto-widths": unref(autoWidth).widths.value,
3737
+ "slot-names": headerSlotNames(),
3738
+ "aria-rowindex": unref(rowWindow).enabled() ? 1 : void 0,
3739
+ roles: ""
3740
+ }, {
3741
+ header: withCtx((p) => [renderSlot(_ctx.$slots, `header-${p.column.field}`, normalizeProps(guardReactiveProps(p)))]),
3742
+ "filter-datetime": withCtx((p) => [renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(p)))]),
3743
+ "filter-menu": withCtx((p) => [renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(p)))]),
3744
+ _: 3
3745
+ }, 8, [
3746
+ "columns",
3747
+ "query",
3748
+ "filterable",
3749
+ "utilities",
3750
+ "has-pinned",
3751
+ "offsets",
3752
+ "auto-widths",
3753
+ "slot-names",
3754
+ "aria-rowindex"
3755
+ ])], 32)], 512)], 512),
3756
+ createElementVNode("div", {
3757
+ ref_key: "bodyWrap",
3758
+ ref: bodyWrap,
3759
+ class: "qt-table-body"
3760
+ }, [createElementVNode("table", {
3761
+ ref_key: "bodyTableEl",
3762
+ ref: bodyTableEl,
3763
+ class: "qt-table",
3764
+ role: "presentation"
3765
+ }, [createElementVNode("colgroup", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(colWidths.value, (width, i) => {
3766
+ return openBlock(), createElementBlock("col", {
3767
+ key: i,
3768
+ style: normalizeStyle(width === void 0 ? void 0 : { width: `${width}px` })
3769
+ }, null, 4);
3770
+ }), 128))]), createVNode(table_body_default, {
3771
+ rows: __props.rows,
3772
+ "body-rows": unref(rowWindow).drawn.value,
3773
+ "pin-row": unref(state).rowPinning.pin,
3774
+ loading: __props.loading,
3775
+ entries: unref(entries),
3776
+ "column-count": columnCount.value,
3777
+ "has-subtable": __props.hasSubtable,
3778
+ "has-right-panel": __props.hasRightPanel,
3779
+ "has-selection": unref(rowSelection).enabled.value,
3780
+ "is-selected": unref(rowSelection).isSelected,
3781
+ "toggle-selected": unref(rowSelection).toggle,
3782
+ "has-pinned": unref(hasPinned),
3783
+ offsets: unref(offsets),
3784
+ "key-of": unref(expansion).keyOf,
3785
+ "can-expand": unref(expansion).canExpand,
3786
+ "is-expanded": unref(expansion).isExpanded,
3787
+ toggle: unref(expansion).toggle,
3788
+ "row-kind": __props.rowKind,
3789
+ labels: labels.value,
3790
+ "has-context-menu-listener": hasContextMenuListener,
3791
+ "load-more": loadMoreProps.value,
3792
+ flash: unref(flashView),
3793
+ roles: "",
3794
+ onRowRightPanelClick: _cache[1] || (_cache[1] = (row) => emit("rowRightPanelClick", row)),
3795
+ onCellContextMenu: _cache[2] || (_cache[2] = (payload) => emit("cellContextMenu", payload)),
3796
+ onFocusin: unref(rowWindow).onFocusIn,
3797
+ onFocusout: unref(rowWindow).onFocusOut
3798
+ }, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
3799
+ return {
3800
+ name,
3801
+ fn: withCtx((p) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(p)))])
3802
+ };
3803
+ })]), 1032, [
3804
+ "rows",
3805
+ "body-rows",
3806
+ "pin-row",
3807
+ "loading",
3808
+ "entries",
3809
+ "column-count",
3810
+ "has-subtable",
3811
+ "has-right-panel",
3812
+ "has-selection",
3813
+ "is-selected",
3814
+ "toggle-selected",
3815
+ "has-pinned",
3816
+ "offsets",
3817
+ "key-of",
3818
+ "can-expand",
3819
+ "is-expanded",
3820
+ "toggle",
3821
+ "row-kind",
3822
+ "labels",
3823
+ "load-more",
3824
+ "flash",
3825
+ "onFocusin",
3826
+ "onFocusout"
3827
+ ])], 512)], 512),
3828
+ __props.footerRows.length > 0 ? (openBlock(), createElementBlock("div", {
3829
+ key: 0,
3830
+ ref_key: "footWrap",
3831
+ ref: footWrap,
3832
+ class: "qt-table-foot"
3833
+ }, [createElementVNode("table", _hoisted_3, [createElementVNode("colgroup", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(colWidths.value, (width, i) => {
3834
+ return openBlock(), createElementBlock("col", {
3835
+ key: i,
3836
+ style: normalizeStyle(width === void 0 ? void 0 : { width: `${width}px` })
3837
+ }, null, 4);
3838
+ }), 128))]), createVNode(table_footer_default, {
3839
+ "footer-rows": __props.footerRows,
3840
+ entries: unref(entries),
3841
+ "utility-count": utilityCount.value,
3842
+ "has-pinned": unref(hasPinned),
3843
+ offsets: unref(offsets),
3844
+ "first-row-index": footerRowIndex.value,
3845
+ roles: ""
3846
+ }, null, 8, [
3847
+ "footer-rows",
3848
+ "entries",
3849
+ "utility-count",
3850
+ "has-pinned",
3851
+ "offsets",
3852
+ "first-row-index"
3853
+ ])])], 512)) : createCommentVNode("", true)
3854
+ ], 64)) : (openBlock(), createElementBlock("table", {
3855
+ key: 1,
3465
3856
  ref_key: "tableEl",
3466
3857
  ref: tableEl,
3467
3858
  class: "qt-table",
3468
3859
  "aria-rowcount": ariaRowCount.value
3469
3860
  }, [
3470
- createElementVNode("thead", { onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onHeaderContextMenu) && unref(onHeaderContextMenu)(...args)) }, [createVNode(table_header_default, {
3861
+ createElementVNode("thead", { onContextmenu: _cache[3] || (_cache[3] = (...args) => unref(onHeaderContextMenu) && unref(onHeaderContextMenu)(...args)) }, [createVNode(table_header_default, {
3471
3862
  columns: visibleColumns.value,
3472
3863
  query: __props.query,
3473
3864
  filterable: __props.filterable,
@@ -3516,8 +3907,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3516
3907
  "has-context-menu-listener": hasContextMenuListener,
3517
3908
  "load-more": loadMoreProps.value,
3518
3909
  flash: unref(flashView),
3519
- onRowRightPanelClick: _cache[1] || (_cache[1] = (row) => emit("rowRightPanelClick", row)),
3520
- onCellContextMenu: _cache[2] || (_cache[2] = (payload) => emit("cellContextMenu", payload)),
3910
+ onRowRightPanelClick: _cache[4] || (_cache[4] = (row) => emit("rowRightPanelClick", row)),
3911
+ onCellContextMenu: _cache[5] || (_cache[5] = (payload) => emit("cellContextMenu", payload)),
3521
3912
  onFocusin: unref(rowWindow).onFocusIn,
3522
3913
  onFocusout: unref(rowWindow).onFocusOut
3523
3914
  }, createSlots({ _: 2 }, [renderList(bodySlotNames(), (name) => {
@@ -3566,7 +3957,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3566
3957
  "offsets",
3567
3958
  "first-row-index"
3568
3959
  ])) : createCommentVNode("", true)
3569
- ], 8, _hoisted_3)]),
3960
+ ], 8, _hoisted_4))], 8, _hoisted_2),
3570
3961
  showPagination.value ? (openBlock(), createBlock(table_pagination_default, {
3571
3962
  key: 0,
3572
3963
  "pagination-props": unref(paginationProps)