@dolusoft/query-table 3.8.0 → 3.9.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.
@@ -726,7 +726,13 @@ var useCellView = (options) => {
726
726
  //#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
727
727
  var _hoisted_1$9 = ["role"];
728
728
  var _hoisted_2$5 = ["role"];
729
- var _hoisted_3$5 = [
729
+ var _hoisted_3$5 = ["role", "aria-rowindex"];
730
+ var _hoisted_4$5 = [
731
+ "colspan",
732
+ "role",
733
+ "aria-colspan"
734
+ ];
735
+ var _hoisted_5$2 = [
730
736
  "role",
731
737
  "data-row-index",
732
738
  "aria-rowindex",
@@ -738,13 +744,13 @@ var _hoisted_3$5 = [
738
744
  "onVnodeBeforeMount",
739
745
  "onVnodeUpdated"
740
746
  ];
741
- var _hoisted_4$5 = ["aria-label", "onClick"];
742
- var _hoisted_5$2 = [
747
+ var _hoisted_6$2 = ["aria-label", "onClick"];
748
+ var _hoisted_7$2 = [
743
749
  "aria-expanded",
744
750
  "aria-label",
745
751
  "onClick"
746
752
  ];
747
- var _hoisted_6$2 = {
753
+ var _hoisted_8$2 = {
748
754
  width: "14",
749
755
  height: "14",
750
756
  viewBox: "0 0 24 24",
@@ -755,29 +761,29 @@ var _hoisted_6$2 = {
755
761
  "stroke-linejoin": "round",
756
762
  "aria-hidden": "true"
757
763
  };
758
- var _hoisted_7$2 = {
764
+ var _hoisted_9$1 = {
759
765
  key: 0,
760
766
  points: "6 9 12 15 18 9"
761
767
  };
762
- var _hoisted_8$2 = {
768
+ var _hoisted_10 = {
763
769
  key: 1,
764
770
  points: "9 6 15 12 9 18"
765
771
  };
766
- var _hoisted_9$1 = [
772
+ var _hoisted_11 = [
767
773
  "aria-label",
768
774
  "checked",
769
775
  "onChange"
770
776
  ];
771
- var _hoisted_10 = ["role", "data-flash"];
772
- var _hoisted_11 = ["role", "data-flash"];
773
- var _hoisted_12 = [
777
+ var _hoisted_12 = ["role", "data-flash"];
778
+ var _hoisted_13 = ["role", "data-flash"];
779
+ var _hoisted_14 = [
774
780
  "role",
775
781
  "aria-rowindex",
776
782
  "data-pinned-row"
777
783
  ];
778
- var _hoisted_13 = ["role"];
779
- var _hoisted_14 = ["role"];
780
784
  var _hoisted_15 = ["role"];
785
+ var _hoisted_16 = ["role"];
786
+ var _hoisted_17 = ["role"];
781
787
  //#endregion
782
788
  //#region src/parts/table-body.vue
783
789
  var table_body_default = /* @__PURE__ */ defineComponent({
@@ -838,6 +844,11 @@ var table_body_default = /* @__PURE__ */ defineComponent({
838
844
  const expandAttrs = () => utilityAttrs("subtable");
839
845
  const selectAttrs = () => utilityAttrs("select");
840
846
  const isSpacer = (item) => "spacer" in item;
847
+ const isGroup = (item) => "group" in item;
848
+ /** A data row: neither a spacer nor a group row. */
849
+ const isRow = (item) => !isSpacer(item) && !isGroup(item);
850
+ /** The identity of a body item in the `v-for`. */
851
+ const itemKey = (item) => isRow(item) ? props.keyOf(item.row, item.index) : item.key;
841
852
  /** `data-row-kind` of a drawn row (C-97): no attribute for an empty kind. */
842
853
  const kindOf = (item) => props.rowKind ? props.rowKind(item.row, item.index) || void 0 : void 0;
843
854
  /** `aria-rowindex` of the subtable row under a drawn row (C-86). */
@@ -847,11 +858,11 @@ var table_body_default = /* @__PURE__ */ defineComponent({
847
858
  expandedSnapshot = null;
848
859
  });
849
860
  const isRowExpanded = (item) => {
850
- if (isSpacer(item)) return false;
861
+ if (!isRow(item)) return false;
851
862
  if (!expandedSnapshot) {
852
863
  const open = /* @__PURE__ */ new Map();
853
864
  if (props.hasSubtable) {
854
- for (const row of props.bodyRows) if (!isSpacer(row)) open.set(String(props.keyOf(row.row, row.index)), props.isExpanded(row.row, row.index));
865
+ for (const row of props.bodyRows) if (isRow(row)) open.set(String(props.keyOf(row.row, row.index)), props.isExpanded(row.row, row.index));
855
866
  }
856
867
  expandedSnapshot = open;
857
868
  }
@@ -863,14 +874,29 @@ var table_body_default = /* @__PURE__ */ defineComponent({
863
874
  onContextmenu: _cache[0] || (_cache[0] = (...args) => unref(onContextMenu) && unref(onContextMenu)(...args))
864
875
  }, [
865
876
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.bodyRows, (item) => {
866
- return openBlock(), createElementBlock(Fragment, { key: isSpacer(item) ? item.key : __props.keyOf(item.row, item.index) }, [isSpacer(item) ? (openBlock(), createElementBlock("tr", {
877
+ return openBlock(), createElementBlock(Fragment, { key: itemKey(item) }, [isSpacer(item) ? (openBlock(), createElementBlock("tr", {
867
878
  key: 0,
868
879
  class: "qt-virtual-spacer",
869
880
  "aria-hidden": "true",
870
881
  role: rowRole(),
871
882
  style: normalizeStyle({ height: `${item.spacer}px` })
872
- }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), null, 16)], 12, _hoisted_2$5)) : (openBlock(), createElementBlock("tr", {
883
+ }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), null, 16)], 12, _hoisted_2$5)) : isGroup(item) ? (openBlock(), createElementBlock("tr", {
873
884
  key: 1,
885
+ class: "qt-group-row",
886
+ role: rowRole(),
887
+ "aria-rowindex": item.aria
888
+ }, [createElementVNode("th", {
889
+ scope: "row",
890
+ colspan: __props.columnCount,
891
+ role: __props.roles ? "rowheader" : void 0,
892
+ "aria-colspan": __props.roles ? __props.columnCount : void 0
893
+ }, [renderSlot(_ctx.$slots, "group", {
894
+ groupKey: item.group.key,
895
+ count: item.group.count,
896
+ row: item.group.row,
897
+ rowIndex: item.group.index
898
+ }, () => [createTextVNode(toDisplayString(item.group.key), 1)])], 8, _hoisted_4$5)], 8, _hoisted_3$5)) : (openBlock(), createElementBlock("tr", {
899
+ key: 2,
874
900
  role: rowRole(),
875
901
  "data-row-index": item.index,
876
902
  "aria-rowindex": item.aria,
@@ -909,7 +935,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
909
935
  y1: "12",
910
936
  x2: "19",
911
937
  y2: "12"
912
- })], -1)])], 8, _hoisted_4$5)], 16)) : createCommentVNode("", true),
938
+ })], -1)])], 8, _hoisted_6$2)], 16)) : createCommentVNode("", true),
913
939
  __props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
914
940
  key: 1,
915
941
  ref_for: true
@@ -920,7 +946,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
920
946
  "aria-expanded": isRowExpanded(item),
921
947
  "aria-label": __props.labels.expandRow,
922
948
  onClick: ($event) => __props.toggle(item.row, item.index)
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),
949
+ }, [(openBlock(), createElementBlock("svg", _hoisted_8$2, [isRowExpanded(item) ? (openBlock(), createElementBlock("polyline", _hoisted_9$1)) : (openBlock(), createElementBlock("polyline", _hoisted_10))]))], 8, _hoisted_7$2)) : createCommentVNode("", true)], 16)) : createCommentVNode("", true),
924
950
  __props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
925
951
  key: 2,
926
952
  ref_for: true
@@ -930,18 +956,18 @@ var table_body_default = /* @__PURE__ */ defineComponent({
930
956
  "aria-label": __props.labels.selectRow,
931
957
  checked: __props.isSelected(item.row, item.index),
932
958
  onChange: ($event) => __props.toggleSelected(item.row, item.index)
933
- }, null, 40, _hoisted_9$1)], 16)) : createCommentVNode("", true),
959
+ }, null, 40, _hoisted_11)], 16)) : createCommentVNode("", true),
934
960
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
935
961
  return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
936
962
  key: 0,
937
963
  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({
964
+ }, { 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_12)) : (openBlock(), createElementBlock("td", mergeProps({
939
965
  key: 1,
940
966
  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);
967
+ }, { 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_13))], 64);
942
968
  }), 128))
943
- ], 8, _hoisted_3$5)), !isSpacer(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
944
- key: 2,
969
+ ], 8, _hoisted_5$2)), isRow(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
970
+ key: 3,
945
971
  class: "qt-subtable-row",
946
972
  role: rowRole(),
947
973
  "aria-rowindex": nextIndex(item.aria),
@@ -949,22 +975,22 @@ var table_body_default = /* @__PURE__ */ defineComponent({
949
975
  }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), [renderSlot(_ctx.$slots, "subtable", {
950
976
  row: item.row,
951
977
  rowIndex: item.index
952
- })], 16)], 8, _hoisted_12)) : createCommentVNode("", true)], 64);
978
+ })], 16)], 8, _hoisted_14)) : createCommentVNode("", true)], 64);
953
979
  }), 128)),
954
980
  __props.loading && slots.loading ? (openBlock(), createElementBlock("tr", {
955
981
  key: 0,
956
982
  class: "qt-loading-row",
957
983
  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", {
984
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "loading")], 16)], 8, _hoisted_15)) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", {
959
985
  key: 1,
960
986
  class: "qt-empty-row",
961
987
  role: rowRole()
962
- }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "empty")], 16)], 8, _hoisted_14)) : createCommentVNode("", true),
988
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "empty")], 16)], 8, _hoisted_16)) : createCommentVNode("", true),
963
989
  !__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", {
964
990
  key: 2,
965
991
  class: "qt-load-more-row",
966
992
  role: rowRole()
967
- }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 16)], 8, _hoisted_15)) : createCommentVNode("", true)
993
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 16)], 8, _hoisted_17)) : createCommentVNode("", true)
968
994
  ], 40, _hoisted_1$9);
969
995
  };
970
996
  }
@@ -2823,6 +2849,52 @@ var useLoadMore = (o) => {
2823
2849
  };
2824
2850
  };
2825
2851
  //#endregion
2852
+ //#region src/body/group-runs.ts
2853
+ /** The runs as a string (start and count of each), or `null` without groups. */
2854
+ var groupShape = (groups) => groups ? groups.runs.map((run) => `${run.start}:${run.count}`).join(",") : null;
2855
+ /**
2856
+ * Splits `rows` into runs of consecutive rows with the same `groupBy` key
2857
+ * (C-103). The rows are not reordered: a key that comes back after another
2858
+ * starts a new run. `null` and `undefined` mean no group.
2859
+ */
2860
+ var groupRuns = (rows, groupBy) => {
2861
+ const runs = [];
2862
+ const groupOf = new Int32Array(rows.length);
2863
+ const headersThrough = new Int32Array(rows.length);
2864
+ const seen = /* @__PURE__ */ new Map();
2865
+ let current = null;
2866
+ for (let p = 0; p < rows.length; p++) {
2867
+ const { row, index } = rows[p];
2868
+ const key = groupBy(row, index);
2869
+ if (key === null || key === void 0 || Number.isNaN(key)) {
2870
+ current = null;
2871
+ groupOf[p] = -1;
2872
+ } else if (current && current.key === key) {
2873
+ current.count++;
2874
+ groupOf[p] = runs.length - 1;
2875
+ } else {
2876
+ const nth = seen.get(key) ?? 0;
2877
+ seen.set(key, nth + 1);
2878
+ current = {
2879
+ key,
2880
+ count: 1,
2881
+ row,
2882
+ index,
2883
+ start: p,
2884
+ id: `${typeof key}:${String(key)}#${nth}`
2885
+ };
2886
+ runs.push(current);
2887
+ groupOf[p] = runs.length - 1;
2888
+ }
2889
+ headersThrough[p] = runs.length;
2890
+ }
2891
+ return {
2892
+ runs,
2893
+ groupOf,
2894
+ headersThrough
2895
+ };
2896
+ };
2897
+ //#endregion
2826
2898
  //#region src/virtual/compute-window.ts
2827
2899
  /**
2828
2900
  * Fills `offsets` from `heights`, starting at position `from` (the offsets
@@ -2931,7 +3003,7 @@ var useRowWindow = (o) => {
2931
3003
  const settings = computed((previous) => {
2932
3004
  const value = o.virtual();
2933
3005
  const next = value === true ? {} : value || null;
2934
- return previous && next && previous.overscan === next.overscan && previous.rowHeight === next.rowHeight && previous.estimateRowHeight === next.estimateRowHeight && previous.scrollElement === next.scrollElement ? previous : next;
3006
+ return previous && next && previous.overscan === next.overscan && previous.rowHeight === next.rowHeight && previous.estimateRowHeight === next.estimateRowHeight && previous.groupRowHeight === next.groupRowHeight && previous.scrollElement === next.scrollElement ? previous : next;
2935
3007
  });
2936
3008
  const enabled = () => settings.value !== null;
2937
3009
  const overscan = () => Math.max(0, settings.value?.overscan ?? 10);
@@ -2950,6 +3022,44 @@ var useRowWindow = (o) => {
2950
3022
  };
2951
3023
  });
2952
3024
  const center = () => parts.value.center;
3025
+ /** The groups of the center rows (C-103), or `null` without `groupBy`. */
3026
+ const groups = computed(() => {
3027
+ const groupBy = o.groupBy?.();
3028
+ return groupBy ? groupRuns(center(), groupBy) : null;
3029
+ });
3030
+ /** The center position starts a group: its group row is drawn above it. */
3031
+ const startsGroup = (position) => {
3032
+ const g = groups.value;
3033
+ if (!g) return false;
3034
+ const at = g.groupOf[position];
3035
+ return at >= 0 && g.runs[at].start === position;
3036
+ };
3037
+ let groupKeys = /* @__PURE__ */ new Map();
3038
+ watch(groups, (g) => {
3039
+ if (!g) {
3040
+ groupKeys = /* @__PURE__ */ new Map();
3041
+ return;
3042
+ }
3043
+ const kept = /* @__PURE__ */ new Map();
3044
+ for (const run of g.runs) {
3045
+ const known = groupKeys.get(run.id);
3046
+ if (known) kept.set(run.id, known);
3047
+ }
3048
+ groupKeys = kept;
3049
+ });
3050
+ const groupKey = (id) => {
3051
+ let key = groupKeys.get(id);
3052
+ if (!key) {
3053
+ key = Symbol(id);
3054
+ groupKeys.set(id, key);
3055
+ }
3056
+ return key;
3057
+ };
3058
+ const groupRowOf = (run, aria) => ({
3059
+ group: run,
3060
+ key: groupKey(run.id),
3061
+ aria
3062
+ });
2953
3063
  /** Position of a row index among the center rows (ascending), or -1. */
2954
3064
  const positionOf = (index) => {
2955
3065
  const rows = center();
@@ -2966,7 +3076,11 @@ var useRowWindow = (o) => {
2966
3076
  return -1;
2967
3077
  };
2968
3078
  let heights = /* @__PURE__ */ new Float64Array(0);
3079
+ /** Item heights without the group row above an item (C-104). */
3080
+ let base = /* @__PURE__ */ new Float64Array(0);
2969
3081
  let measured = /* @__PURE__ */ new Uint8Array(0);
3082
+ /** The measured height of a group row, `0` until one is measured. */
3083
+ let groupMeasured = 0;
2970
3084
  let offsets = /* @__PURE__ */ new Float64Array(1);
2971
3085
  let byKey = /* @__PURE__ */ new Map();
2972
3086
  /** The first measured height, the estimate when none is given. */
@@ -2974,25 +3088,34 @@ var useRowWindow = (o) => {
2974
3088
  /** Bumped whenever `offsets` change, so the spacers are drawn again. */
2975
3089
  const version = shallowRef(0);
2976
3090
  const estimate = () => fixed() ?? settings.value?.estimateRowHeight ?? (firstMeasured || 32);
3091
+ /** Height counted for a group row (C-104). */
3092
+ const groupHeight = () => {
3093
+ const height = fixed();
3094
+ if (height !== void 0) return settings.value?.groupRowHeight ?? height;
3095
+ return groupMeasured || estimate();
3096
+ };
3097
+ /** An item's height: its row and, above it, its group row. */
3098
+ const withGroup = (position) => base[position] + (startsGroup(position) ? groupHeight() : 0);
2977
3099
  const rebuild = () => {
2978
3100
  const rows = enabled() ? center() : [];
2979
3101
  const height = fixed();
2980
3102
  heights = new Float64Array(rows.length);
3103
+ base = groups.value ? new Float64Array(rows.length) : heights;
2981
3104
  measured = new Uint8Array(rows.length);
2982
3105
  const kept = /* @__PURE__ */ new Map();
2983
3106
  for (let i = 0; i < rows.length; i++) {
2984
- if (height !== void 0) {
2985
- heights[i] = height;
2986
- continue;
2987
- }
2988
- const key = o.keyOf(rows[i].row, rows[i].index);
2989
- const known = byKey.get(key);
2990
- if (known === void 0) heights[i] = estimate();
3107
+ if (height !== void 0) base[i] = height;
2991
3108
  else {
2992
- kept.set(key, known);
2993
- heights[i] = known;
2994
- measured[i] = 1;
3109
+ const key = o.keyOf(rows[i].row, rows[i].index);
3110
+ const known = byKey.get(key);
3111
+ if (known === void 0) base[i] = estimate();
3112
+ else {
3113
+ kept.set(key, known);
3114
+ base[i] = known;
3115
+ measured[i] = 1;
3116
+ }
2995
3117
  }
3118
+ heights[i] = withGroup(i);
2996
3119
  }
2997
3120
  byKey = kept;
2998
3121
  pending = null;
@@ -3017,6 +3140,14 @@ var useRowWindow = (o) => {
3017
3140
  const rows = center();
3018
3141
  let from = -1;
3019
3142
  for (const tr of tbody.children) {
3143
+ if (groups.value && tr.classList.contains("qt-group-row")) {
3144
+ const height = tr.getBoundingClientRect().height;
3145
+ if (height > 0 && Math.abs(height - groupMeasured) > .5) {
3146
+ groupMeasured = height;
3147
+ from = 0;
3148
+ }
3149
+ continue;
3150
+ }
3020
3151
  const at = tr.getAttribute("data-row-index");
3021
3152
  if (at === null || tr.hasAttribute("data-pinned-row")) continue;
3022
3153
  const position = positionOf(Number(at));
@@ -3024,17 +3155,18 @@ var useRowWindow = (o) => {
3024
3155
  const height = itemHeight(tr);
3025
3156
  if (!firstMeasured && height > 0 && settings.value?.estimateRowHeight === void 0) {
3026
3157
  firstMeasured = height;
3027
- for (let i = 0; i < heights.length; i++) if (!measured[i]) heights[i] = height;
3158
+ for (let i = 0; i < base.length; i++) if (!measured[i]) base[i] = height;
3028
3159
  from = 0;
3029
3160
  }
3030
- if (!measured[position] || Math.abs(heights[position] - height) > .5) {
3031
- heights[position] = height;
3161
+ if (!measured[position] || Math.abs(base[position] - height) > .5) {
3162
+ base[position] = height;
3032
3163
  measured[position] = 1;
3033
3164
  byKey.set(o.keyOf(rows[position].row, rows[position].index), height);
3034
3165
  from = from < 0 ? position : Math.min(from, position);
3035
3166
  }
3036
3167
  }
3037
3168
  if (from >= 0) {
3169
+ for (let i = from; i < heights.length; i++) heights[i] = withGroup(i);
3038
3170
  fillOffsets(heights, offsets, from);
3039
3171
  version.value++;
3040
3172
  return true;
@@ -3086,11 +3218,11 @@ var useRowWindow = (o) => {
3086
3218
  });
3087
3219
  };
3088
3220
  /** How far to scroll to show an item at `top` (client) with `height`. */
3089
- const alignDelta = (top, height, align) => {
3221
+ const alignDelta = (top, height, align, groupCover = 0) => {
3090
3222
  const view = viewport();
3091
3223
  const head = o.table.value?.tHead?.getBoundingClientRect();
3092
3224
  const cover = head && head.top <= view.top + 1 && head.bottom > view.top ? head.bottom - view.top : 0;
3093
- const viewTop = view.top + cover;
3225
+ const viewTop = view.top + cover + groupCover;
3094
3226
  const viewBottom = view.top + view.height;
3095
3227
  const bottom = top + height;
3096
3228
  switch (align) {
@@ -3100,6 +3232,20 @@ var useRowWindow = (o) => {
3100
3232
  default: return top < viewTop ? top - viewTop : bottom > viewBottom ? bottom - viewBottom : 0;
3101
3233
  }
3102
3234
  };
3235
+ /**
3236
+ * Height of a group row the consumer's CSS made sticky, which covers a
3237
+ * row aligned to the top of its group (C-104); `0` without one.
3238
+ */
3239
+ const stickyGroupCover = (tbody) => {
3240
+ if (!groups.value) return 0;
3241
+ const cell = tbody.querySelector(":scope > tr.qt-group-row > th");
3242
+ return cell && getComputedStyle(cell).position === "sticky" ? cell.getBoundingClientRect().height : 0;
3243
+ };
3244
+ /** The sticky cover over a row: only a grouped row that does not start its group. */
3245
+ const coverOf = (position, tbody) => {
3246
+ const g = groups.value;
3247
+ return g && g.groupOf[position] >= 0 && !startsGroup(position) ? stickyGroupCover(tbody) : 0;
3248
+ };
3103
3249
  /** After a render: correct the drift (C-84) or a `scrollToIndex` (C-87). */
3104
3250
  const settle = () => {
3105
3251
  const tbody = body();
@@ -3111,9 +3257,11 @@ var useRowWindow = (o) => {
3111
3257
  if (pending) {
3112
3258
  const tr = rowElement(tbody, pending.position);
3113
3259
  if (tr) {
3114
- const { align } = pending;
3260
+ const { align, position } = pending;
3115
3261
  pending = null;
3116
- scrollBy(alignDelta(tr.getBoundingClientRect().top, itemHeight(tr), align));
3262
+ const above = startsGroup(position) ? tr.previousElementSibling : null;
3263
+ const head = above?.classList.contains("qt-group-row") ? above : null;
3264
+ scrollBy(alignDelta((head ?? tr).getBoundingClientRect().top, itemHeight(tr) + (head ? head.getBoundingClientRect().height : 0), align, head ? 0 : coverOf(position, tbody)));
3117
3265
  return;
3118
3266
  }
3119
3267
  if (++pending.tries <= pendingFrames) {
@@ -3209,19 +3357,57 @@ var useRowWindow = (o) => {
3209
3357
  for (let i = 0; i < all.length; i++) counts[i + 1] = counts[i] + (o.isExpanded(all[i].row, all[i].index) ? 1 : 0);
3210
3358
  return counts;
3211
3359
  });
3360
+ /** Group rows drawn up to and with the center position (C-104). */
3361
+ const groupsThrough = (position) => groups.value ? groups.value.headersThrough[position] : 0;
3362
+ const groupCount = () => groups.value?.runs.length ?? 0;
3212
3363
  const drawn = computed(() => {
3213
3364
  const { all, top } = parts.value;
3214
- if (!enabled()) return all;
3365
+ const g = groups.value;
3366
+ if (!enabled()) {
3367
+ if (!g) return all;
3368
+ const out = [];
3369
+ for (let q = 0; q < all.length; q++) {
3370
+ const p = q - top;
3371
+ if (p >= 0 && p < g.groupOf.length && startsGroup(p)) out.push(groupRowOf(g.runs[g.groupOf[p]]));
3372
+ out.push(all[q]);
3373
+ }
3374
+ return out;
3375
+ }
3215
3376
  version.value;
3216
3377
  const rows = center();
3217
3378
  const before = expandedBefore.value;
3379
+ const headersBefore = (q) => q < top ? 0 : q < top + rows.length ? groupsThrough(q - top) : groupCount();
3380
+ const ariaOf = (q) => q + before[q] + headersBefore(q) + 2;
3218
3381
  const at = (q) => ({
3219
3382
  ...all[q],
3220
- aria: q + before[q] + 2
3383
+ aria: ariaOf(q)
3221
3384
  });
3222
3385
  const out = [];
3386
+ /** The group whose row was drawn last, or -1. */
3387
+ let drawnGroup = -1;
3388
+ /** The center row at `p`, after its group row when it needs one. */
3389
+ const push = (p, carry) => {
3390
+ const group = g ? g.groupOf[p] : -1;
3391
+ if (g && group >= 0 && group !== drawnGroup) {
3392
+ const run = g.runs[group];
3393
+ if (run.start === p) out.push(groupRowOf(run, ariaOf(top + p) - 1));
3394
+ else if (carry) {
3395
+ const last = out[out.length - 1];
3396
+ if (last && "spacer" in last) {
3397
+ const height = Math.max(0, last.spacer - groupHeight());
3398
+ out[out.length - 1] = {
3399
+ spacer: height,
3400
+ key: last.key
3401
+ };
3402
+ }
3403
+ out.push(groupRowOf(run, ariaOf(top + run.start) - 1));
3404
+ }
3405
+ }
3406
+ drawnGroup = group;
3407
+ out.push(at(top + p));
3408
+ };
3223
3409
  for (let q = 0; q < top; q++) out.push(at(q));
3224
- if (printing.value) for (let p = 0; p < rows.length; p++) out.push(at(top + p));
3410
+ if (printing.value) for (let p = 0; p < rows.length; p++) push(p, false);
3225
3411
  else {
3226
3412
  const end = Math.min(range.value.end, rows.length);
3227
3413
  const win = {
@@ -3232,10 +3418,10 @@ var useRowWindow = (o) => {
3232
3418
  spacer: segment.spacer,
3233
3419
  key: spacerKeys[segment.slot]
3234
3420
  });
3235
- else for (let p = segment.from; p < segment.to; p++) out.push(at(top + p));
3421
+ else for (let p = segment.from; p < segment.to; p++) push(p, p === segment.from);
3236
3422
  }
3237
3423
  for (let q = top + rows.length; q < all.length; q++) out.push(at(q));
3238
- return out;
3424
+ return g ? out.filter((item) => !("spacer" in item) || item.spacer > 0) : out;
3239
3425
  });
3240
3426
  let box = null;
3241
3427
  let rowsObserver = null;
@@ -3328,6 +3514,8 @@ var useRowWindow = (o) => {
3328
3514
  () => parts.value.center,
3329
3515
  () => settings.value?.rowHeight,
3330
3516
  () => settings.value?.estimateRowHeight,
3517
+ () => settings.value?.groupRowHeight,
3518
+ () => groupShape(groups.value),
3331
3519
  enabled
3332
3520
  ], rebuild, { immediate: true });
3333
3521
  watch([
@@ -3382,7 +3570,7 @@ var useRowWindow = (o) => {
3382
3570
  align,
3383
3571
  tries: 0
3384
3572
  };
3385
- scrollBy(alignDelta(itemsTop(tbody) + offsets[position], heights[position], align));
3573
+ scrollBy(alignDelta(itemsTop(tbody) + offsets[position], heights[position], align, coverOf(position, tbody)));
3386
3574
  schedule();
3387
3575
  };
3388
3576
  return {
@@ -3392,6 +3580,8 @@ var useRowWindow = (o) => {
3392
3580
  ready,
3393
3581
  centerCount: () => center().length,
3394
3582
  expandedCount: () => expandedBefore.value[expandedBefore.value.length - 1],
3583
+ /** Group rows of the body, drawn or not (C-104). */
3584
+ groupCount,
3395
3585
  scrollToIndex,
3396
3586
  onFocusIn,
3397
3587
  onFocusOut
@@ -3464,6 +3654,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3464
3654
  type: Function,
3465
3655
  default: void 0
3466
3656
  },
3657
+ groupBy: {
3658
+ type: Function,
3659
+ default: void 0
3660
+ },
3467
3661
  hasRightPanel: {
3468
3662
  type: Boolean,
3469
3663
  default: false
@@ -3616,7 +3810,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3616
3810
  table: bodyTable,
3617
3811
  bodyRows: () => state.rowPinning.rows.value,
3618
3812
  keyOf: expansion.keyOf,
3619
- isExpanded: expansion.isExpanded
3813
+ isExpanded: expansion.isExpanded,
3814
+ groupBy: () => props.groupBy
3620
3815
  });
3621
3816
  const infinite = useLoadMore({
3622
3817
  infinite: () => props.infinite,
@@ -3645,11 +3840,11 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3645
3840
  const ariaRowCount = computed(() => {
3646
3841
  if (!rowWindow.enabled()) return;
3647
3842
  const total = props.totalRows;
3648
- if (growing() && total === null) return -1;
3649
- return 1 + (growing() && total !== null ? total : props.rows.length) + rowWindow.expandedCount() + footerCount.value;
3843
+ if (growing() && (total === null || rowWindow.groupCount() > 0)) return -1;
3844
+ return 1 + (growing() && total !== null ? total : props.rows.length) + rowWindow.expandedCount() + rowWindow.groupCount() + footerCount.value;
3650
3845
  });
3651
3846
  /** `aria-rowindex` of the first footer row, or `undefined` (C-86). */
3652
- const footerRowIndex = computed(() => !rowWindow.enabled() || growing() ? void 0 : 2 + props.rows.length + rowWindow.expandedCount());
3847
+ const footerRowIndex = computed(() => !rowWindow.enabled() || growing() ? void 0 : 2 + props.rows.length + rowWindow.expandedCount() + rowWindow.groupCount());
3653
3848
  const flashView = useChangeFlash({
3654
3849
  flash: () => props.flash,
3655
3850
  rowsUpdate: () => props.rowsUpdate,
@@ -3688,7 +3883,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3688
3883
  search.apply();
3689
3884
  }
3690
3885
  });
3691
- const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading" || name === "load-more");
3886
+ const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading" || name === "load-more" || name === "group");
3692
3887
  const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join(" ");
3693
3888
  __expose({
3694
3889
  collapseAll: expansion.collapseAll,