stk-table-vue 0.8.13 → 0.9.0-beta.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.
Files changed (38) hide show
  1. package/README.md +172 -180
  2. package/lib/src/StkTable/StkTable.vue.d.ts +22 -2
  3. package/lib/src/StkTable/useScrollbar.d.ts +57 -0
  4. package/lib/src/StkTable/utils/index.d.ts +10 -0
  5. package/lib/stk-table-vue.js +563 -294
  6. package/lib/style.css +49 -2
  7. package/package.json +74 -72
  8. package/src/StkTable/StkTable.vue +1730 -1653
  9. package/src/StkTable/components/DragHandle.vue +9 -9
  10. package/src/StkTable/components/SortIcon.vue +6 -6
  11. package/src/StkTable/components/TriangleIcon.vue +3 -3
  12. package/src/StkTable/const.ts +50 -50
  13. package/src/StkTable/index.ts +4 -4
  14. package/src/StkTable/style.less +627 -580
  15. package/src/StkTable/types/highlightDimOptions.ts +26 -26
  16. package/src/StkTable/types/index.ts +297 -297
  17. package/src/StkTable/useAutoResize.ts +91 -91
  18. package/src/StkTable/useColResize.ts +216 -216
  19. package/src/StkTable/useFixedCol.ts +150 -148
  20. package/src/StkTable/useFixedStyle.ts +75 -75
  21. package/src/StkTable/useGetFixedColPosition.ts +65 -65
  22. package/src/StkTable/useHighlight.ts +257 -257
  23. package/src/StkTable/useKeyboardArrowScroll.ts +112 -112
  24. package/src/StkTable/useMaxRowSpan.ts +55 -55
  25. package/src/StkTable/useMergeCells.ts +120 -123
  26. package/src/StkTable/useRowExpand.ts +88 -88
  27. package/src/StkTable/useScrollRowByRow.ts +114 -79
  28. package/src/StkTable/useScrollbar.ts +187 -0
  29. package/src/StkTable/useThDrag.ts +102 -102
  30. package/src/StkTable/useTrDrag.ts +113 -118
  31. package/src/StkTable/useTree.ts +161 -161
  32. package/src/StkTable/useVirtualScroll.ts +494 -494
  33. package/src/StkTable/utils/constRefUtils.ts +29 -29
  34. package/src/StkTable/utils/index.ts +287 -242
  35. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  36. package/src/VirtualTree.vue +622 -622
  37. package/src/VirtualTreeSelect.vue +367 -367
  38. package/src/vite-env.d.ts +10 -10
@@ -1,4 +1,12 @@
1
- import { createElementBlock, openBlock, createElementVNode, watch, onMounted, onBeforeUnmount, ref, computed, shallowRef, onUnmounted, defineComponent, nextTick, toRaw, normalizeStyle, normalizeClass, unref, createCommentVNode, renderSlot, Fragment, renderList, createBlock, resolveDynamicComponent, toDisplayString, createTextVNode, mergeProps, withCtx, createVNode } from "vue";
1
+ /**
2
+ * name: stk-table-vue
3
+ * version: v0.9.0-beta.1
4
+ * description: High performance realtime virtual table for vue3 and vue2.7
5
+ * author: japlus
6
+ * homepage: https://ja-plus.github.io/stk-table-vue/
7
+ * license: MIT
8
+ */
9
+ import { createElementBlock, openBlock, createElementVNode, watch, onMounted, onBeforeUnmount, ref, computed, shallowRef, onUnmounted, nextTick, customRef, defineComponent, toRaw, normalizeStyle, normalizeClass, unref, createCommentVNode, renderSlot, Fragment, renderList, mergeProps, createBlock, resolveDynamicComponent, toDisplayString, createTextVNode, withCtx, createVNode } from "vue";
2
10
  const _export_sfc = (sfc, props) => {
3
11
  const target = sfc.__vccOpts || sfc;
4
12
  for (const [key, val] of props) {
@@ -203,6 +211,40 @@ function getBrowsersVersion(browserName) {
203
211
  function pureCellKeyGen(rowKey, colKey) {
204
212
  return rowKey + CELL_KEY_SEPARATE + colKey;
205
213
  }
214
+ function getClosestTr(e) {
215
+ const target = e.target;
216
+ const tr = target == null ? void 0 : target.closest("tr");
217
+ return tr;
218
+ }
219
+ function getClosestTrIndex(e) {
220
+ const tr = getClosestTr(e);
221
+ if (!tr) return -1;
222
+ return Number(tr.dataset.rowI);
223
+ }
224
+ function getClosestColKey(e) {
225
+ var _a, _b;
226
+ return (_b = (_a = e.target) == null ? void 0 : _a.closest("td")) == null ? void 0 : _b.dataset.colKey;
227
+ }
228
+ function throttle(fn, delay) {
229
+ let timer;
230
+ let lastArgs = null;
231
+ const callFn = function() {
232
+ if (lastArgs) {
233
+ fn(...lastArgs);
234
+ lastArgs = null;
235
+ }
236
+ };
237
+ return function(...args) {
238
+ lastArgs = args;
239
+ if (!timer) {
240
+ callFn();
241
+ timer = self.setTimeout(() => {
242
+ callFn();
243
+ timer = 0;
244
+ }, delay);
245
+ }
246
+ };
247
+ }
206
248
  const DEFAULT_COL_WIDTH = "100";
207
249
  const DEFAULT_TABLE_HEIGHT = 100;
208
250
  const DEFAULT_TABLE_WIDTH = 200;
@@ -483,19 +525,19 @@ function useFixedCol({
483
525
  tableHeaders.value.forEach((cols) => {
484
526
  cols.forEach((col) => {
485
527
  const fixed = col.fixed;
486
- const showShadow = fixedColShadow && fixed && fixedShadowColsValue.includes(col);
487
- const classObj = {
488
- "fixed-cell--active": fixedColsValue.includes(col)
489
- // 表示该列正在被固定
490
- };
528
+ const showShadow = fixed && fixedColShadow && fixedShadowColsValue.includes(col);
529
+ const classList = [];
530
+ if (fixedColsValue.includes(col)) {
531
+ classList.push("fixed-cell--active");
532
+ }
491
533
  if (fixed) {
492
- classObj["fixed-cell"] = true;
493
- classObj["fixed-cell--" + fixed] = true;
534
+ classList.push("fixed-cell");
535
+ classList.push("fixed-cell--" + fixed);
494
536
  }
495
537
  if (showShadow) {
496
- classObj["fixed-cell--shadow"] = true;
538
+ classList.push("fixed-cell--shadow");
497
539
  }
498
- colMap.set(colKey(col), classObj);
540
+ colMap.set(colKey(col), classList);
499
541
  });
500
542
  });
501
543
  return colMap;
@@ -686,7 +728,7 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
686
728
  }
687
729
  function setHighlightDimCell(rowKeyValue, colKeyValue, option = {}) {
688
730
  var _a;
689
- const cellEl = (_a = tableContainerRef.value) == null ? void 0 : _a.querySelector(`[data-cell-key="${pureCellKeyGen(rowKeyValue, colKeyValue)}"]`);
731
+ const cellEl = (_a = tableContainerRef.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"] [data-col-key="${colKeyValue}"]`);
690
732
  if (!cellEl) return;
691
733
  const { className, method, duration, keyframe } = {
692
734
  className: HIGHLIGHT_CELL_CLASS,
@@ -920,10 +962,8 @@ function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKeyGen, v
920
962
  function hideCells(rowKey, colKey, colspan, isSelfRow = false, mergeCellKey) {
921
963
  const startIndex = tableHeaderLast.value.findIndex((item) => colKeyGen.value(item) === colKey);
922
964
  for (let i = startIndex; i < startIndex + colspan; i++) {
923
- if (!isSelfRow) {
924
- if (!hoverRowMap.value[rowKey]) hoverRowMap.value[rowKey] = /* @__PURE__ */ new Set();
925
- hoverRowMap.value[rowKey].add(mergeCellKey);
926
- }
965
+ if (!hoverRowMap.value[rowKey]) hoverRowMap.value[rowKey] = /* @__PURE__ */ new Set();
966
+ hoverRowMap.value[rowKey].add(mergeCellKey);
927
967
  if (isSelfRow && i === startIndex) {
928
968
  continue;
929
969
  }
@@ -959,7 +999,7 @@ function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKeyGen, v
959
999
  function updateActiveMergedCells(clear, rowKey) {
960
1000
  if (!rowActiveProp.value.enabled) return;
961
1001
  if (clear) {
962
- activeMergedCells.value.clear();
1002
+ activeMergedCells.value = /* @__PURE__ */ new Set();
963
1003
  return;
964
1004
  }
965
1005
  activeMergedCells.value = rowKey !== void 0 && hoverRowMap.value[rowKey] || new Set(hoverMergedCells.value);
@@ -1031,11 +1071,164 @@ function useRowExpand({ dataSourceCopy, rowKeyGen, emits }) {
1031
1071
  setRowExpand
1032
1072
  };
1033
1073
  }
1074
+ function useScrollbar(containerRef, options = false) {
1075
+ const defaultOptions = {
1076
+ enabled: true,
1077
+ minHeight: 20,
1078
+ minWidth: 20,
1079
+ width: 8,
1080
+ height: 8
1081
+ };
1082
+ const mergedOptions = {
1083
+ ...defaultOptions,
1084
+ ...typeof options === "boolean" ? { enabled: options } : options
1085
+ };
1086
+ const showScrollbar = ref({ x: false, y: false });
1087
+ const scrollbar = ref({ h: 0, w: 0, top: 0, left: 0 });
1088
+ let isDraggingVertical = false;
1089
+ let isDraggingHorizontal = false;
1090
+ let dragStartY = 0;
1091
+ let dragStartX = 0;
1092
+ let dragStartTop = 0;
1093
+ let dragStartLeft = 0;
1094
+ let resizeObserver = null;
1095
+ const throttledUpdateScrollbar = throttle(() => {
1096
+ updateCustomScrollbar();
1097
+ }, 200);
1098
+ onMounted(() => {
1099
+ if (mergedOptions.enabled && containerRef.value) {
1100
+ resizeObserver = new ResizeObserver(throttledUpdateScrollbar);
1101
+ resizeObserver.observe(containerRef.value);
1102
+ }
1103
+ initScrollbar();
1104
+ });
1105
+ onUnmounted(() => {
1106
+ if (resizeObserver) {
1107
+ resizeObserver.disconnect();
1108
+ resizeObserver = null;
1109
+ }
1110
+ });
1111
+ function updateCustomScrollbar() {
1112
+ if (!mergedOptions.enabled || !containerRef.value) return;
1113
+ const container = containerRef.value;
1114
+ const { scrollHeight, clientHeight, scrollWidth, clientWidth, scrollTop, scrollLeft } = container;
1115
+ const needVertical = scrollHeight > clientHeight;
1116
+ const needHorizontal = scrollWidth > clientWidth;
1117
+ showScrollbar.value = { x: needHorizontal, y: needVertical };
1118
+ if (needVertical) {
1119
+ const ratio = clientHeight / scrollHeight;
1120
+ scrollbar.value.h = Math.max(mergedOptions.minHeight, ratio * clientHeight);
1121
+ scrollbar.value.top = scrollTop / (scrollHeight - clientHeight) * (clientHeight - scrollbar.value.h);
1122
+ }
1123
+ if (needHorizontal) {
1124
+ const ratio = clientWidth / scrollWidth;
1125
+ scrollbar.value.w = Math.max(mergedOptions.minWidth, ratio * clientWidth);
1126
+ scrollbar.value.left = scrollLeft / (scrollWidth - clientWidth) * (clientWidth - scrollbar.value.w);
1127
+ }
1128
+ }
1129
+ function onVerticalScrollbarMouseDown(e) {
1130
+ e.preventDefault();
1131
+ isDraggingVertical = true;
1132
+ const container = containerRef.value;
1133
+ if (!container) return;
1134
+ dragStartTop = container.scrollTop;
1135
+ dragStartY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1136
+ document.addEventListener("mousemove", onVerticalDrag);
1137
+ document.addEventListener("mouseup", onDragEnd);
1138
+ document.addEventListener("touchmove", onVerticalDrag, { passive: false });
1139
+ document.addEventListener("touchend", onDragEnd);
1140
+ }
1141
+ function onHorizontalScrollbarMouseDown(e) {
1142
+ e.preventDefault();
1143
+ isDraggingHorizontal = true;
1144
+ const container = containerRef.value;
1145
+ if (!container) return;
1146
+ dragStartLeft = container.scrollLeft;
1147
+ dragStartX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1148
+ document.addEventListener("mousemove", onHorizontalDrag);
1149
+ document.addEventListener("mouseup", onDragEnd);
1150
+ document.addEventListener("touchmove", onHorizontalDrag, { passive: false });
1151
+ document.addEventListener("touchend", onDragEnd);
1152
+ }
1153
+ function onVerticalDrag(e) {
1154
+ if (!isDraggingVertical || !containerRef.value) return;
1155
+ e.preventDefault();
1156
+ const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1157
+ const deltaY = clientY - dragStartY;
1158
+ const container = containerRef.value;
1159
+ const { scrollHeight, clientHeight } = container;
1160
+ const scrollRange = scrollHeight - clientHeight;
1161
+ const trackRange = clientHeight - scrollbar.value.h;
1162
+ const scrollDelta = deltaY / trackRange * scrollRange;
1163
+ container.scrollTop = dragStartTop + scrollDelta;
1164
+ }
1165
+ function onHorizontalDrag(e) {
1166
+ if (!isDraggingHorizontal || !containerRef.value) return;
1167
+ e.preventDefault();
1168
+ const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1169
+ const deltaX = clientX - dragStartX;
1170
+ const container = containerRef.value;
1171
+ const { scrollWidth, clientWidth } = container;
1172
+ const scrollRange = scrollWidth - clientWidth;
1173
+ const trackRange = clientWidth - scrollbar.value.w;
1174
+ const scrollDelta = deltaX / trackRange * scrollRange;
1175
+ container.scrollLeft = dragStartLeft + scrollDelta;
1176
+ }
1177
+ function onDragEnd() {
1178
+ isDraggingVertical = false;
1179
+ isDraggingHorizontal = false;
1180
+ document.removeEventListener("mousemove", onVerticalDrag);
1181
+ document.removeEventListener("mousemove", onHorizontalDrag);
1182
+ document.removeEventListener("mouseup", onDragEnd);
1183
+ document.removeEventListener("touchmove", onVerticalDrag);
1184
+ document.removeEventListener("touchmove", onHorizontalDrag);
1185
+ document.removeEventListener("touchend", onDragEnd);
1186
+ }
1187
+ function initScrollbar() {
1188
+ nextTick(() => {
1189
+ updateCustomScrollbar();
1190
+ });
1191
+ }
1192
+ return {
1193
+ scrollbarOptions: mergedOptions,
1194
+ scrollbar,
1195
+ showScrollbar,
1196
+ onVerticalScrollbarMouseDown,
1197
+ onHorizontalScrollbarMouseDown,
1198
+ updateCustomScrollbar
1199
+ };
1200
+ }
1034
1201
  function useScrollRowByRow({ props, tableContainerRef }) {
1035
- let isMouseDown = false;
1036
1202
  let isAddListeners = false;
1037
- let lastScrollTop = 0;
1038
- const isDragScroll = ref(false);
1203
+ const isDragScroll = customRef((track, trigger) => {
1204
+ let value = false;
1205
+ let debounceTimer = 0;
1206
+ return {
1207
+ get() {
1208
+ track();
1209
+ return value;
1210
+ },
1211
+ set(newValue) {
1212
+ if (value && !newValue) {
1213
+ if (debounceTimer) {
1214
+ window.clearTimeout(debounceTimer);
1215
+ }
1216
+ debounceTimer = window.setTimeout(() => {
1217
+ value = newValue;
1218
+ trigger();
1219
+ debounceTimer = 0;
1220
+ }, 300);
1221
+ } else {
1222
+ if (debounceTimer) {
1223
+ window.clearTimeout(debounceTimer);
1224
+ debounceTimer = 0;
1225
+ }
1226
+ value = newValue;
1227
+ trigger();
1228
+ }
1229
+ }
1230
+ };
1231
+ });
1039
1232
  const onlyDragScroll = computed(() => props.scrollRowByRow === "scrollbar");
1040
1233
  const isSRBRActive = computed(() => {
1041
1234
  if (onlyDragScroll.value) {
@@ -1062,7 +1255,6 @@ function useScrollRowByRow({ props, tableContainerRef }) {
1062
1255
  if (!container) return;
1063
1256
  container.addEventListener("mousedown", handleMouseDown);
1064
1257
  container.addEventListener("mouseup", handleMouseUp);
1065
- container.addEventListener("scroll", handleScroll);
1066
1258
  isAddListeners = true;
1067
1259
  }
1068
1260
  function removeEventListener() {
@@ -1070,22 +1262,16 @@ function useScrollRowByRow({ props, tableContainerRef }) {
1070
1262
  if (!container) return;
1071
1263
  container.removeEventListener("mousedown", handleMouseDown);
1072
1264
  container.removeEventListener("mouseup", handleMouseUp);
1073
- container.removeEventListener("scroll", handleScroll);
1074
1265
  isAddListeners = false;
1075
1266
  }
1076
1267
  function handleMouseDown(e) {
1077
- isMouseDown = true;
1078
- lastScrollTop = e.target.scrollTop;
1268
+ const el = e.target;
1269
+ if (el.classList.contains("stk-table")) {
1270
+ isDragScroll.value = true;
1271
+ }
1079
1272
  }
1080
1273
  function handleMouseUp() {
1081
- isMouseDown = false;
1082
1274
  isDragScroll.value = false;
1083
- lastScrollTop = 0;
1084
- }
1085
- function handleScroll(e) {
1086
- const scrollTop = e.target.scrollTop;
1087
- if (!isMouseDown || scrollTop === lastScrollTop) return;
1088
- isDragScroll.value = true;
1089
1275
  }
1090
1276
  return { isSRBRActive, isDragScroll };
1091
1277
  }
@@ -1168,11 +1354,6 @@ function useTrDrag({ props, emits, dataSourceCopy }) {
1168
1354
  const dragRowConfig = computed(() => {
1169
1355
  return { mode: "insert", ...props.dragRowConfig };
1170
1356
  });
1171
- function getClosestTr(e) {
1172
- const target = e.target;
1173
- const tr = target == null ? void 0 : target.closest("tr");
1174
- return tr;
1175
- }
1176
1357
  function onTrDragStart(e, rowIndex) {
1177
1358
  var _a;
1178
1359
  const tr = getClosestTr(e);
@@ -1708,24 +1889,29 @@ function useVirtualScroll({
1708
1889
  clearAllAutoHeight
1709
1890
  };
1710
1891
  }
1711
- const _hoisted_1 = { key: 0 };
1712
- const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
1713
- const _hoisted_3 = ["onMousedown"];
1714
- const _hoisted_4 = { class: "table-header-title" };
1892
+ const _hoisted_1 = { style: { "display": "flex" } };
1893
+ const _hoisted_2 = { style: { "display": "flex", "flex-direction": "column" } };
1894
+ const _hoisted_3 = { key: 0 };
1895
+ const _hoisted_4 = ["onClick"];
1715
1896
  const _hoisted_5 = ["onMousedown"];
1716
- const _hoisted_6 = {
1897
+ const _hoisted_6 = { class: "table-header-title" };
1898
+ const _hoisted_7 = ["onMousedown"];
1899
+ const _hoisted_8 = {
1717
1900
  key: 0,
1718
1901
  class: "vt-x-left"
1719
1902
  };
1720
- const _hoisted_7 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover", "onDrop"];
1721
- const _hoisted_8 = {
1903
+ const _hoisted_9 = ["onDrop"];
1904
+ const _hoisted_10 = {
1722
1905
  key: 0,
1723
1906
  class: "vt-x-left"
1724
1907
  };
1725
- const _hoisted_9 = ["colspan"];
1726
- const _hoisted_10 = { class: "table-cell-wrapper" };
1727
- const _hoisted_11 = ["onClick", "onMousedown", "onMouseenter", "onMouseleave", "onMouseover"];
1728
- const _hoisted_12 = ["title"];
1908
+ const _hoisted_11 = ["colspan"];
1909
+ const _hoisted_12 = { class: "table-cell-wrapper" };
1910
+ const _hoisted_13 = ["title"];
1911
+ const _hoisted_14 = {
1912
+ key: 3,
1913
+ class: "vt-x-right"
1914
+ };
1729
1915
  const _sfc_main = /* @__PURE__ */ defineComponent({
1730
1916
  __name: "StkTable",
1731
1917
  props: {
@@ -1775,7 +1961,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1775
1961
  treeConfig: { default: () => ({}) },
1776
1962
  cellFixedMode: { default: "sticky" },
1777
1963
  smoothScroll: { type: Boolean, default: DEFAULT_SMOOTH_SCROLL },
1778
- scrollRowByRow: { type: [Boolean, String], default: false }
1964
+ scrollRowByRow: { type: [Boolean, String], default: false },
1965
+ scrollbar: { type: [Boolean, Object], default: false }
1779
1966
  },
1780
1967
  emits: ["sort-change", "row-click", "current-change", "cell-selected", "row-dblclick", "header-row-menu", "row-menu", "cell-click", "cell-mouseenter", "cell-mouseleave", "cell-mouseover", "cell-mousedown", "header-cell-click", "scroll", "scroll-x", "col-order-change", "th-drag-start", "th-drop", "row-order-change", "col-resize", "toggle-row-expand", "toggle-tree-expand", "update:columns"],
1781
1968
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -1849,6 +2036,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1849
2036
  return (containerHeight - tableHeaderHeight.value) % rowHeight;
1850
2037
  });
1851
2038
  const rowKeyGenCache = /* @__PURE__ */ new WeakMap();
2039
+ const { scrollbarOptions, scrollbar, showScrollbar, onVerticalScrollbarMouseDown, onHorizontalScrollbarMouseDown, updateCustomScrollbar } = useScrollbar(tableContainerRef, props.scrollbar);
1852
2040
  const { isSRBRActive } = useScrollRowByRow({ props, tableContainerRef });
1853
2041
  const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits, colKeyGen });
1854
2042
  const { onTrDragStart, onTrDrop, onTrDragOver, onTrDragEnd, onTrDragEnter } = useTrDrag({ props, emits, dataSourceCopy });
@@ -1929,6 +2117,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1929
2117
  nextTick(() => {
1930
2118
  initVirtualScrollX();
1931
2119
  updateFixedShadow();
2120
+ updateCustomScrollbar();
1932
2121
  });
1933
2122
  }
1934
2123
  );
@@ -1958,7 +2147,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1958
2147
  );
1959
2148
  watch(
1960
2149
  () => props.dataSource,
1961
- (val) => updateDataSource(val)
2150
+ (val) => {
2151
+ updateDataSource(val);
2152
+ nextTick(() => {
2153
+ updateCustomScrollbar();
2154
+ });
2155
+ }
1962
2156
  );
1963
2157
  watch(
1964
2158
  () => props.fixedColShadow,
@@ -2117,7 +2311,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2117
2311
  };
2118
2312
  });
2119
2313
  function getRowIndex(rowIndex) {
2120
- return rowIndex + (virtual_on.value ? virtualScroll.value.startIndex : 0);
2314
+ return rowIndex + virtualScroll.value.startIndex;
2121
2315
  }
2122
2316
  function getHeaderTitle(col) {
2123
2317
  const colKey = colKeyGen.value(col);
@@ -2126,7 +2320,48 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2126
2320
  }
2127
2321
  return col.title || "";
2128
2322
  }
2129
- function getTDProps(row, col) {
2323
+ function getTRProps(row, index) {
2324
+ var _a, _b;
2325
+ const rowIndex = getRowIndex(index);
2326
+ const rowKey = rowKeyGen(row);
2327
+ let classStr = props.rowClassName(row, rowIndex) || " " + ((row == null ? void 0 : row.__EXP__) ? "expanded" : "") + " " + ((row == null ? void 0 : row.__EXP_R__) ? "expanded-row" : "");
2328
+ if (currentRowKey.value === rowKey || row === currentRow.value) {
2329
+ classStr += " active";
2330
+ }
2331
+ if (props.showTrHoverClass && (rowKey === currentHoverRowKey.value || row === currentHoverRow)) {
2332
+ classStr += " hover";
2333
+ }
2334
+ const result = {
2335
+ id: stkTableId + "-" + rowKey,
2336
+ "data-row-key": rowKey,
2337
+ "data-row-i": rowIndex,
2338
+ class: classStr,
2339
+ style: ""
2340
+ };
2341
+ const needRowHeight = (row == null ? void 0 : row.__EXP_R__) && props.virtual && ((_a = props.expandConfig) == null ? void 0 : _a.height);
2342
+ if (needRowHeight) {
2343
+ result.style = `--row-height: ${(_b = props.expandConfig) == null ? void 0 : _b.height}px`;
2344
+ }
2345
+ return result;
2346
+ }
2347
+ function getTHProps(col) {
2348
+ const colKey = colKeyGen.value(col);
2349
+ return {
2350
+ "data-col-key": colKey,
2351
+ draggable: Boolean(isHeaderDraggable(col)),
2352
+ rowspan: virtualX_on.value ? 1 : col.__R_SP__,
2353
+ colspan: col.__C_SP__,
2354
+ style: cellStyleMap.value[TagType.TH].get(colKey),
2355
+ title: getHeaderTitle(col),
2356
+ class: [
2357
+ col.sorter ? "sortable" : "",
2358
+ colKey === sortCol.value && sortOrderIndex.value !== 0 && "sorter-" + sortSwitchOrder[sortOrderIndex.value],
2359
+ col.headerClassName,
2360
+ fixedColClassMap.value.get(colKey)
2361
+ ]
2362
+ };
2363
+ }
2364
+ function getTDProps(row, col, rowIndex, colIndex) {
2130
2365
  const colKey = colKeyGen.value(col);
2131
2366
  if (!row) {
2132
2367
  return {
@@ -2134,7 +2369,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2134
2369
  };
2135
2370
  }
2136
2371
  const cellKey = cellKeyGen(row, col);
2137
- const classList = [col.className, fixedColClassMap.value.get(colKeyGen.value(col))];
2372
+ const classList = [col.className, fixedColClassMap.value.get(colKey)];
2138
2373
  if (col.mergeCells) {
2139
2374
  if (hoverMergedCells.value.has(cellKey)) {
2140
2375
  classList.push("cell-hover");
@@ -2148,17 +2383,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2148
2383
  }
2149
2384
  if (col.type === "seq") {
2150
2385
  classList.push("seq-column");
2151
- } else if (col.type === "expand" && (row.__EXP__ ? colKeyGen.value(row.__EXP__) === colKeyGen.value(col) : false)) {
2386
+ } else if (col.type === "expand" && (row.__EXP__ ? colKeyGen.value(row.__EXP__) === colKey : false)) {
2152
2387
  classList.push("expanded");
2153
- } else if (col.type === "tree-node" && row.__T_EXP__) {
2388
+ } else if (row.__T_EXP__ && col.type === "tree-node") {
2154
2389
  classList.push("tree-expanded");
2155
2390
  } else if (col.type === "dragRow") {
2156
2391
  classList.push("drag-row-cell");
2157
2392
  }
2158
2393
  return {
2159
- "data-cell-key": cellKey,
2394
+ "data-col-key": colKey,
2160
2395
  style: cellStyleMap.value[TagType.TD].get(colKey),
2161
- class: classList
2396
+ class: classList,
2397
+ ...mergeCellsWrapper(row, col, rowIndex, colIndex)
2162
2398
  };
2163
2399
  }
2164
2400
  function onColumnSort(col, click = true, options = {}) {
@@ -2216,8 +2452,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2216
2452
  emits("sort-change", col, order, toRaw(dataSourceTemp), sortConfig);
2217
2453
  }
2218
2454
  }
2219
- function onRowClick(e, row, rowIndex) {
2455
+ function onRowClick(e) {
2220
2456
  var _a, _b;
2457
+ const rowIndex = getClosestTrIndex(e);
2458
+ const row = dataSourceCopy.value[rowIndex];
2459
+ if (!row) return;
2221
2460
  emits("row-click", e, row, { rowIndex });
2222
2461
  if ((_b = (_a = rowActiveProp.value).disabled) == null ? void 0 : _b.call(_a, row)) return;
2223
2462
  const isCurrentRow = props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row;
@@ -2231,13 +2470,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2231
2470
  }
2232
2471
  emits("current-change", e, row, { select: !isCurrentRow });
2233
2472
  }
2234
- function onRowDblclick(e, row, rowIndex) {
2473
+ function onRowDblclick(e) {
2474
+ const rowIndex = getClosestTrIndex(e);
2475
+ const row = dataSourceCopy.value[rowIndex];
2476
+ if (!row) return;
2235
2477
  emits("row-dblclick", e, row, { rowIndex });
2236
2478
  }
2237
2479
  function onHeaderMenu(e) {
2238
2480
  emits("header-row-menu", e);
2239
2481
  }
2240
- function onRowMenu(e, row, rowIndex) {
2482
+ function onRowMenu(e) {
2483
+ const rowIndex = getClosestTrIndex(e);
2484
+ const row = dataSourceCopy.value[rowIndex];
2485
+ if (!row) return;
2241
2486
  emits("row-menu", e, row, { rowIndex });
2242
2487
  }
2243
2488
  function triangleClick(e, row, col) {
@@ -2247,7 +2492,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2247
2492
  toggleTreeNode(row, col);
2248
2493
  }
2249
2494
  }
2250
- function onCellClick(e, row, col, rowIndex) {
2495
+ function onCellClick(e) {
2496
+ const rowIndex = getClosestTrIndex(e);
2497
+ const row = dataSourceCopy.value[rowIndex];
2498
+ if (!row) return;
2499
+ const colKey = getClosestColKey(e);
2500
+ const col = tableHeaderLast.value.find((item) => colKeyGen.value(item) === colKey);
2501
+ if (!col) return;
2251
2502
  if (props.cellActive) {
2252
2503
  const cellKey = cellKeyGen(row, col);
2253
2504
  const result = { row, col, select: false, rowIndex };
@@ -2261,19 +2512,31 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2261
2512
  }
2262
2513
  emits("cell-click", e, row, col, { rowIndex });
2263
2514
  }
2515
+ function getCellEventData(e) {
2516
+ const rowIndex = getClosestTrIndex(e) || 0;
2517
+ const row = dataSourceCopy.value[rowIndex];
2518
+ const colKey = getClosestColKey(e);
2519
+ const col = tableHeaderLast.value.find((item) => colKeyGen.value(item) === colKey);
2520
+ return { row, col, rowIndex };
2521
+ }
2264
2522
  function onHeaderCellClick(e, col) {
2523
+ onColumnSort(col);
2265
2524
  emits("header-cell-click", e, col);
2266
2525
  }
2267
- function onCellMouseEnter(e, row, col) {
2526
+ function onCellMouseEnter(e) {
2527
+ const { row, col } = getCellEventData(e);
2268
2528
  emits("cell-mouseenter", e, row, col);
2269
2529
  }
2270
- function onCellMouseLeave(e, row, col) {
2530
+ function onCellMouseLeave(e) {
2531
+ const { row, col } = getCellEventData(e);
2271
2532
  emits("cell-mouseleave", e, row, col);
2272
2533
  }
2273
- function onCellMouseOver(e, row, col) {
2534
+ function onCellMouseOver(e) {
2535
+ const { row, col } = getCellEventData(e);
2274
2536
  emits("cell-mouseover", e, row, col);
2275
2537
  }
2276
- function onCellMouseDown(e, row, col, rowIndex) {
2538
+ function onCellMouseDown(e) {
2539
+ const { row, col, rowIndex } = getCellEventData(e);
2277
2540
  emits("cell-mousedown", e, row, col, { rowIndex });
2278
2541
  }
2279
2542
  function onTableWheel(e) {
@@ -2285,20 +2548,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2285
2548
  return;
2286
2549
  }
2287
2550
  const dom = tableContainerRef.value;
2288
- if (!dom) return;
2289
- if (!virtual_on.value && !virtualX_on.value) return;
2290
- const { containerHeight, scrollTop, scrollHeight } = virtualScroll.value;
2291
- const { containerWidth, scrollLeft, scrollWidth } = virtualScrollX.value;
2292
- const isScrollBottom = scrollHeight - containerHeight - scrollTop < 10;
2293
- const isScrollRight = scrollWidth - containerWidth - scrollLeft < 10;
2551
+ if (!virtual_on.value && !virtualX_on.value || !dom) return;
2294
2552
  const { deltaY, deltaX, shiftKey } = e;
2295
2553
  if (virtual_on.value && deltaY && !shiftKey) {
2554
+ const { containerHeight, scrollTop, scrollHeight } = virtualScroll.value;
2555
+ const isScrollBottom = scrollHeight - containerHeight - scrollTop < 10;
2296
2556
  if (deltaY > 0 && !isScrollBottom || deltaY < 0 && scrollTop > 0) {
2297
2557
  e.preventDefault();
2298
2558
  }
2299
2559
  dom.scrollTop += deltaY;
2300
2560
  }
2301
2561
  if (virtualX_on.value) {
2562
+ const { containerWidth, scrollLeft, scrollWidth } = virtualScrollX.value;
2563
+ const isScrollRight = scrollWidth - containerWidth - scrollLeft < 10;
2302
2564
  let distance = deltaX;
2303
2565
  if (shiftKey && deltaY) {
2304
2566
  distance = deltaY;
@@ -2334,13 +2596,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2334
2596
  if (isXScroll) {
2335
2597
  emits("scroll-x", e);
2336
2598
  }
2599
+ updateCustomScrollbar();
2337
2600
  }
2338
- function onTrMouseOver(_e, row) {
2601
+ function onTrMouseOver(e) {
2602
+ const tr = getClosestTr(e);
2603
+ if (!tr) return;
2604
+ const rowIndex = Number(tr.dataset.rowI);
2605
+ const row = dataSourceCopy.value[rowIndex];
2339
2606
  if (currentHoverRow === row) return;
2340
2607
  currentHoverRow = row;
2341
- const rowKey = rowKeyGen(row);
2608
+ const rowKey = tr.dataset.rowKey;
2342
2609
  if (props.showTrHoverClass) {
2343
- currentHoverRowKey.value = rowKey;
2610
+ currentHoverRowKey.value = rowKey || null;
2344
2611
  }
2345
2612
  if (props.rowHover) {
2346
2613
  updateHoverMergedCells(rowKey);
@@ -2591,13 +2858,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2591
2858
  "header-text-overflow": props.showHeaderOverflow,
2592
2859
  "fixed-relative-mode": isRelativeMode.value,
2593
2860
  "auto-row-height": props.autoRowHeight,
2594
- "scroll-row-by-row": unref(isSRBRActive)
2861
+ "scroll-row-by-row": unref(isSRBRActive),
2862
+ "scrollbar-on": unref(scrollbarOptions).enabled
2595
2863
  }]),
2596
2864
  style: normalizeStyle({
2597
2865
  "--row-height": props.autoRowHeight ? void 0 : unref(virtualScroll).rowHeight + "px",
2598
2866
  "--header-row-height": props.headerRowHeight + "px",
2599
2867
  "--highlight-duration": props.highlightConfig.duration && props.highlightConfig.duration + "s",
2600
- "--highlight-timing-function": unref(highlightSteps) ? `steps(${unref(highlightSteps)})` : ""
2868
+ "--highlight-timing-function": unref(highlightSteps) ? `steps(${unref(highlightSteps)})` : "",
2869
+ "--sb-width": `${unref(scrollbarOptions).width}px`,
2870
+ "--sb-height": `${unref(scrollbarOptions).height}px`
2601
2871
  }),
2602
2872
  onScroll: onTableScroll,
2603
2873
  onWheel: onTableWheel
@@ -2613,239 +2883,238 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2613
2883
  ref: colResizeIndicatorRef,
2614
2884
  class: "column-resize-indicator"
2615
2885
  }, null, 512)) : createCommentVNode("", true),
2616
- createElementVNode("table", {
2617
- class: normalizeClass(["stk-table-main", {
2618
- "fixed-mode": props.fixedMode
2619
- }]),
2620
- style: normalizeStyle({ width: __props.width, minWidth: __props.minWidth, maxWidth: __props.maxWidth })
2621
- }, [
2622
- !__props.headless ? (openBlock(), createElementBlock("thead", _hoisted_1, [
2623
- (openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
2624
- return openBlock(), createElementBlock("tr", {
2625
- key: rowIndex,
2626
- onContextmenu: _cache[3] || (_cache[3] = ($event) => onHeaderMenu($event))
2627
- }, [
2628
- unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
2629
- key: 0,
2630
- class: "vt-x-left",
2631
- style: normalizeStyle(`min-width:${unref(virtualScrollX).offsetLeft}px;width:${unref(virtualScrollX).offsetLeft}px`)
2632
- }, null, 4)) : createCommentVNode("", true),
2633
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
2634
- return openBlock(), createElementBlock("th", {
2635
- key: colKeyGen.value(col),
2636
- "data-col-key": colKeyGen.value(col),
2637
- draggable: unref(isHeaderDraggable)(col) ? "true" : "false",
2638
- rowspan: unref(virtualX_on) ? 1 : col.__R_SP__,
2639
- colspan: col.__C_SP__,
2640
- style: normalizeStyle(cellStyleMap.value[unref(TagType).TH].get(colKeyGen.value(col))),
2641
- title: getHeaderTitle(col),
2642
- class: normalizeClass([
2643
- col.sorter ? "sortable" : "",
2644
- colKeyGen.value(col) === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
2645
- col.headerClassName,
2646
- unref(fixedColClassMap).get(colKeyGen.value(col))
2647
- ]),
2648
- onClick: (e) => {
2649
- onColumnSort(col);
2650
- onHeaderCellClick(e, col);
2651
- },
2652
- onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
2653
- (...args) => unref(onThDragStart) && unref(onThDragStart)(...args)),
2654
- onDrop: _cache[1] || (_cache[1] = //@ts-ignore
2655
- (...args) => unref(onThDrop) && unref(onThDrop)(...args)),
2656
- onDragover: _cache[2] || (_cache[2] = //@ts-ignore
2657
- (...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
2886
+ createElementVNode("div", _hoisted_1, [
2887
+ createElementVNode("div", _hoisted_2, [
2888
+ createElementVNode("table", {
2889
+ class: normalizeClass(["stk-table-main", {
2890
+ "fixed-mode": props.fixedMode
2891
+ }]),
2892
+ style: normalizeStyle({ width: __props.width, minWidth: __props.minWidth, maxWidth: __props.maxWidth }),
2893
+ onDragover: _cache[4] || (_cache[4] = //@ts-ignore
2894
+ (...args) => unref(onTrDragOver) && unref(onTrDragOver)(...args)),
2895
+ onDragenter: _cache[5] || (_cache[5] = //@ts-ignore
2896
+ (...args) => unref(onTrDragEnter) && unref(onTrDragEnter)(...args)),
2897
+ onDragend: _cache[6] || (_cache[6] = //@ts-ignore
2898
+ (...args) => unref(onTrDragEnd) && unref(onTrDragEnd)(...args)),
2899
+ onClick: onRowClick,
2900
+ onDblclick: onRowDblclick,
2901
+ onContextmenu: onRowMenu,
2902
+ onMouseover: onTrMouseOver
2903
+ }, [
2904
+ !__props.headless ? (openBlock(), createElementBlock("thead", _hoisted_3, [
2905
+ (openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
2906
+ return openBlock(), createElementBlock("tr", {
2907
+ key: rowIndex,
2908
+ onContextmenu: _cache[3] || (_cache[3] = ($event) => onHeaderMenu($event))
2658
2909
  }, [
2659
- unref(colResizeOn)(col) && colIndex > 0 ? (openBlock(), createElementBlock("div", {
2910
+ unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
2660
2911
  key: 0,
2661
- class: "table-header-resizer left",
2662
- onMousedown: ($event) => unref(onThResizeMouseDown)($event, col, true)
2663
- }, null, 40, _hoisted_3)) : createCommentVNode("", true),
2664
- createElementVNode("div", {
2665
- class: "table-header-cell-wrapper",
2666
- style: normalizeStyle({ "--row-span": unref(virtualX_on) ? 1 : col.__R_SP__ })
2667
- }, [
2668
- col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
2669
- key: 0,
2670
- col,
2671
- colIndex,
2672
- rowIndex
2673
- }, null, 8, ["col", "colIndex", "rowIndex"])) : renderSlot(_ctx.$slots, "tableHeader", {
2674
- key: 1,
2675
- col
2676
- }, () => [
2677
- createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
2678
- ]),
2679
- col.sorter ? (openBlock(), createBlock(SortIcon, {
2680
- key: 2,
2681
- class: "table-header-sorter"
2682
- })) : createCommentVNode("", true)
2683
- ], 4),
2684
- unref(colResizeOn)(col) ? (openBlock(), createElementBlock("div", {
2912
+ class: "vt-x-left",
2913
+ style: normalizeStyle(`min-width:${unref(virtualScrollX).offsetLeft}px;width:${unref(virtualScrollX).offsetLeft}px`)
2914
+ }, null, 4)) : createCommentVNode("", true),
2915
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
2916
+ return openBlock(), createElementBlock("th", mergeProps({
2917
+ key: colKeyGen.value(col)
2918
+ }, { ref_for: true }, getTHProps(col), {
2919
+ onClick: (e) => onHeaderCellClick(e, col),
2920
+ onDragstart: _cache[0] || (_cache[0] = ($event) => __props.headerDrag ? unref(onThDragStart) : void 0),
2921
+ onDrop: _cache[1] || (_cache[1] = ($event) => __props.headerDrag ? unref(onThDrop) : void 0),
2922
+ onDragover: _cache[2] || (_cache[2] = ($event) => __props.headerDrag ? unref(onThDragOver) : void 0)
2923
+ }), [
2924
+ unref(colResizeOn)(col) && colIndex > 0 ? (openBlock(), createElementBlock("div", {
2925
+ key: 0,
2926
+ class: "table-header-resizer left",
2927
+ onMousedown: ($event) => unref(onThResizeMouseDown)($event, col, true)
2928
+ }, null, 40, _hoisted_5)) : createCommentVNode("", true),
2929
+ createElementVNode("div", {
2930
+ class: "table-header-cell-wrapper",
2931
+ style: normalizeStyle(`--row-span:${unref(virtualX_on) ? 1 : col.__R_SP__}`)
2932
+ }, [
2933
+ col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
2934
+ key: 0,
2935
+ col,
2936
+ colIndex,
2937
+ rowIndex
2938
+ }, null, 8, ["col", "colIndex", "rowIndex"])) : renderSlot(_ctx.$slots, "tableHeader", {
2939
+ key: 1,
2940
+ col
2941
+ }, () => [
2942
+ createElementVNode("span", _hoisted_6, toDisplayString(col.title), 1)
2943
+ ]),
2944
+ col.sorter ? (openBlock(), createBlock(SortIcon, {
2945
+ key: 2,
2946
+ class: "table-header-sorter"
2947
+ })) : createCommentVNode("", true)
2948
+ ], 4),
2949
+ unref(colResizeOn)(col) ? (openBlock(), createElementBlock("div", {
2950
+ key: 1,
2951
+ class: "table-header-resizer right",
2952
+ onMousedown: ($event) => unref(onThResizeMouseDown)($event, col)
2953
+ }, null, 40, _hoisted_7)) : createCommentVNode("", true)
2954
+ ], 16, _hoisted_4);
2955
+ }), 128)),
2956
+ unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
2685
2957
  key: 1,
2686
- class: "table-header-resizer right",
2687
- onMousedown: ($event) => unref(onThResizeMouseDown)($event, col)
2688
- }, null, 40, _hoisted_5)) : createCommentVNode("", true)
2689
- ], 46, _hoisted_2);
2690
- }), 128)),
2691
- unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
2692
- key: 1,
2693
- class: "vt-x-right",
2694
- style: normalizeStyle(`min-width:${unref(virtualX_offsetRight)}px;width:${unref(virtualX_offsetRight)}px`)
2695
- }, null, 4)) : createCommentVNode("", true)
2696
- ], 32);
2697
- }), 128))
2698
- ])) : createCommentVNode("", true),
2699
- createElementVNode("tbody", {
2700
- class: "stk-tbody-main",
2701
- onDragover: _cache[5] || (_cache[5] = //@ts-ignore
2702
- (...args) => unref(onTrDragOver) && unref(onTrDragOver)(...args)),
2703
- onDragenter: _cache[6] || (_cache[6] = //@ts-ignore
2704
- (...args) => unref(onTrDragEnter) && unref(onTrDragEnter)(...args)),
2705
- onDragend: _cache[7] || (_cache[7] = //@ts-ignore
2706
- (...args) => unref(onTrDragEnd) && unref(onTrDragEnd)(...args))
2707
- }, [
2708
- unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2709
- key: 0,
2710
- style: normalizeStyle(`height:${unref(virtualScroll).offsetTop}px`),
2711
- class: "padding-top-tr"
2712
- }, [
2713
- unref(virtualX_on) && __props.fixedMode && __props.headless ? (openBlock(), createElementBlock("td", _hoisted_6)) : createCommentVNode("", true),
2714
- __props.fixedMode && __props.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
2715
- return openBlock(), createElementBlock("td", {
2716
- key: colKeyGen.value(col),
2717
- style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen.value(col)))
2718
- }, null, 4);
2719
- }), 128)) : createCommentVNode("", true)
2720
- ], 4)) : createCommentVNode("", true),
2721
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
2722
- var _a, _b;
2723
- return openBlock(), createElementBlock("tr", {
2724
- id: unref(stkTableId) + "-" + (__props.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex)),
2725
- ref_for: true,
2726
- ref_key: "trRef",
2727
- ref: trRef,
2728
- key: __props.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex),
2729
- "data-row-key": __props.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex),
2730
- class: normalizeClass({
2731
- active: __props.rowKey ? rowKeyGen(row) === currentRowKey.value : row === currentRow.value,
2732
- hover: props.showTrHoverClass && (__props.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
2733
- [__props.rowClassName(row, getRowIndex(rowIndex)) || ""]: true,
2734
- expanded: row && row.__EXP__,
2735
- "expanded-row": row && row.__EXP_R__
2736
- }),
2737
- style: normalizeStyle({
2738
- "--row-height": row && row.__EXP_R__ && props.virtual && ((_a = props.expandConfig) == null ? void 0 : _a.height) && ((_b = props.expandConfig) == null ? void 0 : _b.height) + "px"
2739
- }),
2740
- onClick: ($event) => onRowClick($event, row, getRowIndex(rowIndex)),
2741
- onDblclick: ($event) => onRowDblclick($event, row, getRowIndex(rowIndex)),
2742
- onContextmenu: ($event) => onRowMenu($event, row, getRowIndex(rowIndex)),
2743
- onMouseover: ($event) => onTrMouseOver($event, row),
2744
- onMouseleave: _cache[4] || (_cache[4] = ($event) => onTrMouseLeave($event)),
2745
- onDrop: ($event) => unref(onTrDrop)($event, getRowIndex(rowIndex))
2958
+ class: "vt-x-right",
2959
+ style: normalizeStyle(`min-width:${unref(virtualX_offsetRight)}px;width:${unref(virtualX_offsetRight)}px`)
2960
+ }, null, 4)) : createCommentVNode("", true)
2961
+ ], 32);
2962
+ }), 128))
2963
+ ])) : createCommentVNode("", true),
2964
+ createElementVNode("tbody", {
2965
+ class: "stk-tbody-main",
2966
+ onClick: onCellClick,
2967
+ onMousedown: onCellMouseDown,
2968
+ onMouseover: onCellMouseOver
2746
2969
  }, [
2747
- unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_8)) : createCommentVNode("", true),
2748
- row && row.__EXP_R__ ? (openBlock(), createElementBlock("td", {
2749
- key: 1,
2750
- colspan: unref(virtualX_columnPart).length
2970
+ unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2971
+ key: 0,
2972
+ style: normalizeStyle(`height:${unref(virtualScroll).offsetTop}px`),
2973
+ class: "padding-top-tr"
2751
2974
  }, [
2752
- createElementVNode("div", _hoisted_10, [
2753
- renderSlot(_ctx.$slots, "expand", {
2754
- row: row.__EXP_R__,
2755
- col: row.__EXP_C__
2756
- }, () => {
2757
- var _a2;
2758
- return [
2759
- createTextVNode(toDisplayString(((_a2 = row.__EXP_R__) == null ? void 0 : _a2[row.__EXP_C__.dataIndex]) ?? ""), 1)
2760
- ];
2761
- })
2762
- ])
2763
- ], 8, _hoisted_9)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(unref(virtualX_columnPart), (col, colIndex) => {
2764
- var _a2;
2765
- return openBlock(), createElementBlock(Fragment, null, [
2766
- !((_a2 = unref(hiddenCellMap)[rowKeyGen(row)]) == null ? void 0 : _a2.has(colKeyGen.value(col))) ? (openBlock(), createElementBlock("td", mergeProps({
2767
- key: colKeyGen.value(col)
2768
- }, { ref_for: true }, {
2769
- ...getTDProps(row, col),
2770
- ...unref(mergeCellsWrapper)(row, col, rowIndex, colIndex)
2771
- }, {
2772
- onClick: ($event) => onCellClick($event, row, col, getRowIndex(rowIndex)),
2773
- onMousedown: ($event) => onCellMouseDown($event, row, col, getRowIndex(rowIndex)),
2774
- onMouseenter: ($event) => onCellMouseEnter($event, row, col),
2775
- onMouseleave: ($event) => onCellMouseLeave($event, row, col),
2776
- onMouseover: ($event) => onCellMouseOver($event, row, col)
2777
- }), [
2778
- col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
2779
- key: 0,
2780
- class: "table-cell-wrapper",
2781
- col,
2782
- row,
2783
- rowIndex: getRowIndex(rowIndex),
2784
- colIndex,
2785
- cellValue: row && row[col.dataIndex],
2786
- expanded: row && row.__EXP__,
2787
- "tree-expanded": row && row.__T_EXP__
2788
- }, {
2789
- stkFoldIcon: withCtx(() => [
2790
- createVNode(TriangleIcon, {
2791
- onClick: ($event) => triangleClick($event, row, col)
2792
- }, null, 8, ["onClick"])
2793
- ]),
2794
- stkDragIcon: withCtx(() => [
2795
- createVNode(DragHandle, {
2796
- onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
2797
- }, null, 8, ["onDragstart"])
2798
- ]),
2799
- _: 2
2800
- }, 1032, ["col", "row", "rowIndex", "colIndex", "cellValue", "expanded", "tree-expanded"])) : (openBlock(), createElementBlock("div", {
2801
- key: 1,
2802
- class: "table-cell-wrapper",
2803
- title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : "",
2804
- style: normalizeStyle(col.type === "tree-node" ? { paddingLeft: row.__T_LV__ && row.__T_LV__ * 16 + "px" } : {})
2805
- }, [
2806
- col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2807
- createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + getRowIndex(rowIndex) + 1), 1)
2808
- ], 64)) : col.type === "dragRow" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2809
- createVNode(DragHandle, {
2810
- onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
2811
- }, null, 8, ["onDragstart"]),
2812
- createElementVNode("span", null, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)
2813
- ], 64)) : col.type === "expand" || col.type === "tree-node" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2814
- col.type === "expand" || col.type === "tree-node" && row.children !== void 0 ? (openBlock(), createBlock(TriangleIcon, {
2975
+ unref(virtualX_on) && __props.fixedMode && __props.headless ? (openBlock(), createElementBlock("td", _hoisted_8)) : createCommentVNode("", true),
2976
+ __props.fixedMode && __props.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
2977
+ return openBlock(), createElementBlock("td", {
2978
+ key: colKeyGen.value(col),
2979
+ style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen.value(col)))
2980
+ }, null, 4);
2981
+ }), 128)) : createCommentVNode("", true)
2982
+ ], 4)) : createCommentVNode("", true),
2983
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
2984
+ return openBlock(), createElementBlock("tr", mergeProps({
2985
+ ref_for: true,
2986
+ ref_key: "trRef",
2987
+ ref: trRef,
2988
+ key: rowKeyGen(row)
2989
+ }, { ref_for: true }, getTRProps(row, rowIndex), {
2990
+ onDrop: ($event) => unref(onTrDrop)($event, getRowIndex(rowIndex)),
2991
+ onMouseleave: onTrMouseLeave
2992
+ }), [
2993
+ unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
2994
+ row && row.__EXP_R__ ? (openBlock(), createElementBlock("td", {
2995
+ key: 1,
2996
+ colspan: unref(virtualX_columnPart).length
2997
+ }, [
2998
+ createElementVNode("div", _hoisted_12, [
2999
+ renderSlot(_ctx.$slots, "expand", {
3000
+ row: row.__EXP_R__,
3001
+ col: row.__EXP_C__
3002
+ }, () => {
3003
+ var _a;
3004
+ return [
3005
+ createTextVNode(toDisplayString(((_a = row.__EXP_R__) == null ? void 0 : _a[row.__EXP_C__.dataIndex]) ?? ""), 1)
3006
+ ];
3007
+ })
3008
+ ])
3009
+ ], 8, _hoisted_11)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(unref(virtualX_columnPart), (col, colIndex) => {
3010
+ var _a;
3011
+ return openBlock(), createElementBlock(Fragment, null, [
3012
+ !((_a = unref(hiddenCellMap)[rowKeyGen(row)]) == null ? void 0 : _a.has(colKeyGen.value(col))) ? (openBlock(), createElementBlock("td", mergeProps({
3013
+ key: colKeyGen.value(col)
3014
+ }, { ref_for: true }, getTDProps(row, col, rowIndex, colIndex), {
3015
+ onMouseenter: onCellMouseEnter,
3016
+ onMouseleave: onCellMouseLeave
3017
+ }), [
3018
+ col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
2815
3019
  key: 0,
2816
- onClick: ($event) => triangleClick($event, row, col)
2817
- }, null, 8, ["onClick"])) : createCommentVNode("", true),
2818
- createElementVNode("span", {
2819
- style: normalizeStyle(col.type === "tree-node" && !row.children ? "padding-left: 16px;" : "")
2820
- }, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 5)
2821
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2822
- createTextVNode(toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? getEmptyCellText.value(col, row)), 1)
2823
- ], 64))
2824
- ], 12, _hoisted_12))
2825
- ], 16, _hoisted_11)) : createCommentVNode("", true)
2826
- ], 64);
2827
- }), 256))
2828
- ], 46, _hoisted_7);
2829
- }), 128)),
2830
- unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2831
- key: 1,
2832
- style: normalizeStyle(`height: ${unref(virtual_offsetBottom)}px`)
2833
- }, null, 4)) : createCommentVNode("", true),
2834
- SRBRBottomHeight.value ? (openBlock(), createElementBlock("tr", {
2835
- key: 2,
2836
- style: normalizeStyle(`height: ${SRBRBottomHeight.value}px`)
2837
- }, null, 4)) : createCommentVNode("", true)
2838
- ], 32)
2839
- ], 6),
3020
+ class: "table-cell-wrapper",
3021
+ col,
3022
+ row,
3023
+ rowIndex: getRowIndex(rowIndex),
3024
+ colIndex,
3025
+ cellValue: row && row[col.dataIndex],
3026
+ expanded: row && row.__EXP__,
3027
+ "tree-expanded": row && row.__T_EXP__
3028
+ }, {
3029
+ stkFoldIcon: withCtx(() => [
3030
+ createVNode(TriangleIcon, {
3031
+ onClick: ($event) => triangleClick($event, row, col)
3032
+ }, null, 8, ["onClick"])
3033
+ ]),
3034
+ stkDragIcon: withCtx(() => [
3035
+ createVNode(DragHandle, {
3036
+ onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
3037
+ }, null, 8, ["onDragstart"])
3038
+ ]),
3039
+ _: 2
3040
+ }, 1032, ["col", "row", "rowIndex", "colIndex", "cellValue", "expanded", "tree-expanded"])) : (openBlock(), createElementBlock("div", {
3041
+ key: 1,
3042
+ class: "table-cell-wrapper",
3043
+ title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : "",
3044
+ style: normalizeStyle(col.type === "tree-node" && row.__T_LV__ ? `padding-left:${row.__T_LV__ * 16}px` : "")
3045
+ }, [
3046
+ col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3047
+ createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + getRowIndex(rowIndex) + 1), 1)
3048
+ ], 64)) : col.type === "dragRow" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
3049
+ createVNode(DragHandle, {
3050
+ onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
3051
+ }, null, 8, ["onDragstart"]),
3052
+ createElementVNode("span", null, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)
3053
+ ], 64)) : col.type === "expand" || col.type === "tree-node" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3054
+ col.type === "expand" || col.type === "tree-node" && row.children !== void 0 ? (openBlock(), createBlock(TriangleIcon, {
3055
+ key: 0,
3056
+ onClick: ($event) => triangleClick($event, row, col)
3057
+ }, null, 8, ["onClick"])) : createCommentVNode("", true),
3058
+ createElementVNode("span", {
3059
+ style: normalizeStyle(col.type === "tree-node" && !row.children ? "padding-left: 16px;" : "")
3060
+ }, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 5)
3061
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
3062
+ createTextVNode(toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? getEmptyCellText.value(col, row)), 1)
3063
+ ], 64))
3064
+ ], 12, _hoisted_13))
3065
+ ], 16)) : createCommentVNode("", true)
3066
+ ], 64);
3067
+ }), 256)),
3068
+ unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_14)) : createCommentVNode("", true)
3069
+ ], 16, _hoisted_9);
3070
+ }), 128)),
3071
+ unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
3072
+ key: 1,
3073
+ style: normalizeStyle(`height: ${unref(virtual_offsetBottom)}px`)
3074
+ }, null, 4)) : createCommentVNode("", true),
3075
+ SRBRBottomHeight.value ? (openBlock(), createElementBlock("tr", {
3076
+ key: 2,
3077
+ style: normalizeStyle(`height: ${SRBRBottomHeight.value}px`)
3078
+ }, null, 4)) : createCommentVNode("", true)
3079
+ ], 32)
3080
+ ], 38),
3081
+ renderSlot(_ctx.$slots, "customBottom")
3082
+ ]),
3083
+ unref(showScrollbar).y ? (openBlock(), createElementBlock("div", {
3084
+ key: 0,
3085
+ ref: "verticalScrollbarRef",
3086
+ class: "stk-sb-thumb vertical",
3087
+ style: normalizeStyle({
3088
+ height: `${unref(scrollbar).h}px`,
3089
+ transform: `translateY(${unref(scrollbar).top}px)`
3090
+ }),
3091
+ onMousedown: _cache[7] || (_cache[7] = //@ts-ignore
3092
+ (...args) => unref(onVerticalScrollbarMouseDown) && unref(onVerticalScrollbarMouseDown)(...args)),
3093
+ onTouchstart: _cache[8] || (_cache[8] = //@ts-ignore
3094
+ (...args) => unref(onVerticalScrollbarMouseDown) && unref(onVerticalScrollbarMouseDown)(...args))
3095
+ }, null, 36)) : createCommentVNode("", true)
3096
+ ]),
2840
3097
  (!dataSourceCopy.value || !dataSourceCopy.value.length) && __props.showNoData ? (openBlock(), createElementBlock("div", {
2841
3098
  key: 2,
2842
3099
  class: normalizeClass(["stk-table-no-data", { "no-data-full": __props.noDataFull }])
2843
3100
  }, [
2844
3101
  renderSlot(_ctx.$slots, "empty", {}, () => [
2845
- _cache[8] || (_cache[8] = createTextVNode("暂无数据", -1))
3102
+ _cache[11] || (_cache[11] = createTextVNode("暂无数据", -1))
2846
3103
  ])
2847
3104
  ], 2)) : createCommentVNode("", true),
2848
- renderSlot(_ctx.$slots, "customBottom")
3105
+ unref(showScrollbar).x ? (openBlock(), createElementBlock("div", {
3106
+ key: 3,
3107
+ ref: "horizontalScrollbarRef",
3108
+ class: "stk-sb-thumb horizontal",
3109
+ style: normalizeStyle({
3110
+ width: `${unref(scrollbar).w}px`,
3111
+ transform: `translateX(${unref(scrollbar).left}px)`
3112
+ }),
3113
+ onMousedown: _cache[9] || (_cache[9] = //@ts-ignore
3114
+ (...args) => unref(onHorizontalScrollbarMouseDown) && unref(onHorizontalScrollbarMouseDown)(...args)),
3115
+ onTouchstart: _cache[10] || (_cache[10] = //@ts-ignore
3116
+ (...args) => unref(onHorizontalScrollbarMouseDown) && unref(onHorizontalScrollbarMouseDown)(...args))
3117
+ }, null, 36)) : createCommentVNode("", true)
2849
3118
  ], 38);
2850
3119
  };
2851
3120
  }