stk-table-vue 0.8.14 → 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 -172
  2. package/lib/src/StkTable/StkTable.vue.d.ts +19 -1
  3. package/lib/src/StkTable/useScrollbar.d.ts +57 -0
  4. package/lib/src/StkTable/utils/index.d.ts +7 -0
  5. package/lib/stk-table-vue.js +396 -205
  6. package/lib/style.css +42 -1
  7. package/package.json +74 -74
  8. package/src/StkTable/StkTable.vue +1730 -1665
  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 -578
  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 -150
  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 -120
  26. package/src/StkTable/useRowExpand.ts +88 -88
  27. package/src/StkTable/useScrollRowByRow.ts +113 -113
  28. package/src/StkTable/useScrollbar.ts +187 -0
  29. package/src/StkTable/useThDrag.ts +102 -102
  30. package/src/StkTable/useTrDrag.ts +113 -113
  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 -258
  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,12 +1,12 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v0.8.13
3
+ * version: v0.9.0-beta.1
4
4
  * description: High performance realtime virtual table for vue3 and vue2.7
5
5
  * author: japlus
6
6
  * homepage: https://ja-plus.github.io/stk-table-vue/
7
7
  * license: MIT
8
8
  */
9
- import { createElementBlock, openBlock, createElementVNode, watch, onMounted, onBeforeUnmount, ref, computed, shallowRef, customRef, onUnmounted, defineComponent, nextTick, toRaw, normalizeStyle, normalizeClass, unref, createCommentVNode, renderSlot, Fragment, renderList, mergeProps, createBlock, resolveDynamicComponent, toDisplayString, createTextVNode, withCtx, createVNode } from "vue";
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";
10
10
  const _export_sfc = (sfc, props) => {
11
11
  const target = sfc.__vccOpts || sfc;
12
12
  for (const [key, val] of props) {
@@ -225,6 +225,26 @@ function getClosestColKey(e) {
225
225
  var _a, _b;
226
226
  return (_b = (_a = e.target) == null ? void 0 : _a.closest("td")) == null ? void 0 : _b.dataset.colKey;
227
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
+ }
228
248
  const DEFAULT_COL_WIDTH = "100";
229
249
  const DEFAULT_TABLE_HEIGHT = 100;
230
250
  const DEFAULT_TABLE_WIDTH = 200;
@@ -1051,6 +1071,133 @@ function useRowExpand({ dataSourceCopy, rowKeyGen, emits }) {
1051
1071
  setRowExpand
1052
1072
  };
1053
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
+ }
1054
1201
  function useScrollRowByRow({ props, tableContainerRef }) {
1055
1202
  let isAddListeners = false;
1056
1203
  const isDragScroll = customRef((track, trigger) => {
@@ -1742,24 +1889,26 @@ function useVirtualScroll({
1742
1889
  clearAllAutoHeight
1743
1890
  };
1744
1891
  }
1745
- const _hoisted_1 = { key: 0 };
1746
- const _hoisted_2 = ["onClick"];
1747
- const _hoisted_3 = ["onMousedown"];
1748
- 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"];
1749
1896
  const _hoisted_5 = ["onMousedown"];
1750
- const _hoisted_6 = {
1897
+ const _hoisted_6 = { class: "table-header-title" };
1898
+ const _hoisted_7 = ["onMousedown"];
1899
+ const _hoisted_8 = {
1751
1900
  key: 0,
1752
1901
  class: "vt-x-left"
1753
1902
  };
1754
- const _hoisted_7 = ["onDrop"];
1755
- const _hoisted_8 = {
1903
+ const _hoisted_9 = ["onDrop"];
1904
+ const _hoisted_10 = {
1756
1905
  key: 0,
1757
1906
  class: "vt-x-left"
1758
1907
  };
1759
- const _hoisted_9 = ["colspan"];
1760
- const _hoisted_10 = { class: "table-cell-wrapper" };
1761
- const _hoisted_11 = ["title"];
1762
- const _hoisted_12 = {
1908
+ const _hoisted_11 = ["colspan"];
1909
+ const _hoisted_12 = { class: "table-cell-wrapper" };
1910
+ const _hoisted_13 = ["title"];
1911
+ const _hoisted_14 = {
1763
1912
  key: 3,
1764
1913
  class: "vt-x-right"
1765
1914
  };
@@ -1812,7 +1961,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1812
1961
  treeConfig: { default: () => ({}) },
1813
1962
  cellFixedMode: { default: "sticky" },
1814
1963
  smoothScroll: { type: Boolean, default: DEFAULT_SMOOTH_SCROLL },
1815
- scrollRowByRow: { type: [Boolean, String], default: false }
1964
+ scrollRowByRow: { type: [Boolean, String], default: false },
1965
+ scrollbar: { type: [Boolean, Object], default: false }
1816
1966
  },
1817
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"],
1818
1968
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -1886,6 +2036,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1886
2036
  return (containerHeight - tableHeaderHeight.value) % rowHeight;
1887
2037
  });
1888
2038
  const rowKeyGenCache = /* @__PURE__ */ new WeakMap();
2039
+ const { scrollbarOptions, scrollbar, showScrollbar, onVerticalScrollbarMouseDown, onHorizontalScrollbarMouseDown, updateCustomScrollbar } = useScrollbar(tableContainerRef, props.scrollbar);
1889
2040
  const { isSRBRActive } = useScrollRowByRow({ props, tableContainerRef });
1890
2041
  const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits, colKeyGen });
1891
2042
  const { onTrDragStart, onTrDrop, onTrDragOver, onTrDragEnd, onTrDragEnter } = useTrDrag({ props, emits, dataSourceCopy });
@@ -1966,6 +2117,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1966
2117
  nextTick(() => {
1967
2118
  initVirtualScrollX();
1968
2119
  updateFixedShadow();
2120
+ updateCustomScrollbar();
1969
2121
  });
1970
2122
  }
1971
2123
  );
@@ -1995,7 +2147,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1995
2147
  );
1996
2148
  watch(
1997
2149
  () => props.dataSource,
1998
- (val) => updateDataSource(val)
2150
+ (val) => {
2151
+ updateDataSource(val);
2152
+ nextTick(() => {
2153
+ updateCustomScrollbar();
2154
+ });
2155
+ }
1999
2156
  );
2000
2157
  watch(
2001
2158
  () => props.fixedColShadow,
@@ -2439,6 +2596,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2439
2596
  if (isXScroll) {
2440
2597
  emits("scroll-x", e);
2441
2598
  }
2599
+ updateCustomScrollbar();
2442
2600
  }
2443
2601
  function onTrMouseOver(e) {
2444
2602
  const tr = getClosestTr(e);
@@ -2700,13 +2858,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2700
2858
  "header-text-overflow": props.showHeaderOverflow,
2701
2859
  "fixed-relative-mode": isRelativeMode.value,
2702
2860
  "auto-row-height": props.autoRowHeight,
2703
- "scroll-row-by-row": unref(isSRBRActive)
2861
+ "scroll-row-by-row": unref(isSRBRActive),
2862
+ "scrollbar-on": unref(scrollbarOptions).enabled
2704
2863
  }]),
2705
2864
  style: normalizeStyle({
2706
2865
  "--row-height": props.autoRowHeight ? void 0 : unref(virtualScroll).rowHeight + "px",
2707
2866
  "--header-row-height": props.headerRowHeight + "px",
2708
2867
  "--highlight-duration": props.highlightConfig.duration && props.highlightConfig.duration + "s",
2709
- "--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`
2710
2871
  }),
2711
2872
  onScroll: onTableScroll,
2712
2873
  onWheel: onTableWheel
@@ -2722,208 +2883,238 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2722
2883
  ref: colResizeIndicatorRef,
2723
2884
  class: "column-resize-indicator"
2724
2885
  }, null, 512)) : createCommentVNode("", true),
2725
- createElementVNode("table", {
2726
- class: normalizeClass(["stk-table-main", {
2727
- "fixed-mode": props.fixedMode
2728
- }]),
2729
- style: normalizeStyle({ width: __props.width, minWidth: __props.minWidth, maxWidth: __props.maxWidth }),
2730
- onDragover: _cache[4] || (_cache[4] = //@ts-ignore
2731
- (...args) => unref(onTrDragOver) && unref(onTrDragOver)(...args)),
2732
- onDragenter: _cache[5] || (_cache[5] = //@ts-ignore
2733
- (...args) => unref(onTrDragEnter) && unref(onTrDragEnter)(...args)),
2734
- onDragend: _cache[6] || (_cache[6] = //@ts-ignore
2735
- (...args) => unref(onTrDragEnd) && unref(onTrDragEnd)(...args)),
2736
- onClick: onRowClick,
2737
- onDblclick: onRowDblclick,
2738
- onContextmenu: onRowMenu,
2739
- onMouseover: onTrMouseOver
2740
- }, [
2741
- !__props.headless ? (openBlock(), createElementBlock("thead", _hoisted_1, [
2742
- (openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
2743
- return openBlock(), createElementBlock("tr", {
2744
- key: rowIndex,
2745
- onContextmenu: _cache[3] || (_cache[3] = ($event) => onHeaderMenu($event))
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))
2909
+ }, [
2910
+ unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
2911
+ key: 0,
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", {
2957
+ key: 1,
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("th", {
2970
+ unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2748
2971
  key: 0,
2749
- class: "vt-x-left",
2750
- style: normalizeStyle(`min-width:${unref(virtualScrollX).offsetLeft}px;width:${unref(virtualScrollX).offsetLeft}px`)
2751
- }, null, 4)) : createCommentVNode("", true),
2752
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
2753
- return openBlock(), createElementBlock("th", mergeProps({
2754
- key: colKeyGen.value(col)
2755
- }, { ref_for: true }, getTHProps(col), {
2756
- onClick: (e) => onHeaderCellClick(e, col),
2757
- onDragstart: _cache[0] || (_cache[0] = ($event) => __props.headerDrag ? unref(onThDragStart) : void 0),
2758
- onDrop: _cache[1] || (_cache[1] = ($event) => __props.headerDrag ? unref(onThDrop) : void 0),
2759
- onDragover: _cache[2] || (_cache[2] = ($event) => __props.headerDrag ? unref(onThDragOver) : void 0)
2972
+ style: normalizeStyle(`height:${unref(virtualScroll).offsetTop}px`),
2973
+ class: "padding-top-tr"
2974
+ }, [
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
2760
2992
  }), [
2761
- unref(colResizeOn)(col) && colIndex > 0 ? (openBlock(), createElementBlock("div", {
2762
- key: 0,
2763
- class: "table-header-resizer left",
2764
- onMousedown: ($event) => unref(onThResizeMouseDown)($event, col, true)
2765
- }, null, 40, _hoisted_3)) : createCommentVNode("", true),
2766
- createElementVNode("div", {
2767
- class: "table-header-cell-wrapper",
2768
- style: normalizeStyle(`--row-span:${unref(virtualX_on) ? 1 : col.__R_SP__}`)
2769
- }, [
2770
- col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
2771
- key: 0,
2772
- col,
2773
- colIndex,
2774
- rowIndex
2775
- }, null, 8, ["col", "colIndex", "rowIndex"])) : renderSlot(_ctx.$slots, "tableHeader", {
2776
- key: 1,
2777
- col
2778
- }, () => [
2779
- createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
2780
- ]),
2781
- col.sorter ? (openBlock(), createBlock(SortIcon, {
2782
- key: 2,
2783
- class: "table-header-sorter"
2784
- })) : createCommentVNode("", true)
2785
- ], 4),
2786
- unref(colResizeOn)(col) ? (openBlock(), createElementBlock("div", {
2993
+ unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
2994
+ row && row.__EXP_R__ ? (openBlock(), createElementBlock("td", {
2787
2995
  key: 1,
2788
- class: "table-header-resizer right",
2789
- onMousedown: ($event) => unref(onThResizeMouseDown)($event, col)
2790
- }, null, 40, _hoisted_5)) : createCommentVNode("", true)
2791
- ], 16, _hoisted_2);
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), {
3019
+ key: 0,
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);
2792
3070
  }), 128)),
2793
- unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
3071
+ unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2794
3072
  key: 1,
2795
- class: "vt-x-right",
2796
- style: normalizeStyle(`min-width:${unref(virtualX_offsetRight)}px;width:${unref(virtualX_offsetRight)}px`)
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`)
2797
3078
  }, null, 4)) : createCommentVNode("", true)
2798
- ], 32);
2799
- }), 128))
2800
- ])) : createCommentVNode("", true),
2801
- createElementVNode("tbody", {
2802
- class: "stk-tbody-main",
2803
- onClick: onCellClick,
2804
- onMousedown: onCellMouseDown,
2805
- onMouseover: onCellMouseOver
2806
- }, [
2807
- unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2808
- key: 0,
2809
- style: normalizeStyle(`height:${unref(virtualScroll).offsetTop}px`),
2810
- class: "padding-top-tr"
2811
- }, [
2812
- unref(virtualX_on) && __props.fixedMode && __props.headless ? (openBlock(), createElementBlock("td", _hoisted_6)) : createCommentVNode("", true),
2813
- __props.fixedMode && __props.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
2814
- return openBlock(), createElementBlock("td", {
2815
- key: colKeyGen.value(col),
2816
- style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen.value(col)))
2817
- }, null, 4);
2818
- }), 128)) : createCommentVNode("", true)
2819
- ], 4)) : createCommentVNode("", true),
2820
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
2821
- return openBlock(), createElementBlock("tr", mergeProps({
2822
- ref_for: true,
2823
- ref_key: "trRef",
2824
- ref: trRef,
2825
- key: rowKeyGen(row)
2826
- }, { ref_for: true }, getTRProps(row, rowIndex), {
2827
- onDrop: ($event) => unref(onTrDrop)($event, getRowIndex(rowIndex)),
2828
- onMouseleave: onTrMouseLeave
2829
- }), [
2830
- unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_8)) : createCommentVNode("", true),
2831
- row && row.__EXP_R__ ? (openBlock(), createElementBlock("td", {
2832
- key: 1,
2833
- colspan: unref(virtualX_columnPart).length
2834
- }, [
2835
- createElementVNode("div", _hoisted_10, [
2836
- renderSlot(_ctx.$slots, "expand", {
2837
- row: row.__EXP_R__,
2838
- col: row.__EXP_C__
2839
- }, () => {
2840
- var _a;
2841
- return [
2842
- createTextVNode(toDisplayString(((_a = row.__EXP_R__) == null ? void 0 : _a[row.__EXP_C__.dataIndex]) ?? ""), 1)
2843
- ];
2844
- })
2845
- ])
2846
- ], 8, _hoisted_9)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(unref(virtualX_columnPart), (col, colIndex) => {
2847
- var _a;
2848
- return openBlock(), createElementBlock(Fragment, null, [
2849
- !((_a = unref(hiddenCellMap)[rowKeyGen(row)]) == null ? void 0 : _a.has(colKeyGen.value(col))) ? (openBlock(), createElementBlock("td", mergeProps({
2850
- key: colKeyGen.value(col)
2851
- }, { ref_for: true }, getTDProps(row, col, rowIndex, colIndex), {
2852
- onMouseenter: onCellMouseEnter,
2853
- onMouseleave: onCellMouseLeave
2854
- }), [
2855
- col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
2856
- key: 0,
2857
- class: "table-cell-wrapper",
2858
- col,
2859
- row,
2860
- rowIndex: getRowIndex(rowIndex),
2861
- colIndex,
2862
- cellValue: row && row[col.dataIndex],
2863
- expanded: row && row.__EXP__,
2864
- "tree-expanded": row && row.__T_EXP__
2865
- }, {
2866
- stkFoldIcon: withCtx(() => [
2867
- createVNode(TriangleIcon, {
2868
- onClick: ($event) => triangleClick($event, row, col)
2869
- }, null, 8, ["onClick"])
2870
- ]),
2871
- stkDragIcon: withCtx(() => [
2872
- createVNode(DragHandle, {
2873
- onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
2874
- }, null, 8, ["onDragstart"])
2875
- ]),
2876
- _: 2
2877
- }, 1032, ["col", "row", "rowIndex", "colIndex", "cellValue", "expanded", "tree-expanded"])) : (openBlock(), createElementBlock("div", {
2878
- key: 1,
2879
- class: "table-cell-wrapper",
2880
- title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : "",
2881
- style: normalizeStyle(col.type === "tree-node" && row.__T_LV__ ? `padding-left:${row.__T_LV__ * 16}px` : "")
2882
- }, [
2883
- col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2884
- createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + getRowIndex(rowIndex) + 1), 1)
2885
- ], 64)) : col.type === "dragRow" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2886
- createVNode(DragHandle, {
2887
- onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
2888
- }, null, 8, ["onDragstart"]),
2889
- createElementVNode("span", null, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)
2890
- ], 64)) : col.type === "expand" || col.type === "tree-node" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2891
- col.type === "expand" || col.type === "tree-node" && row.children !== void 0 ? (openBlock(), createBlock(TriangleIcon, {
2892
- key: 0,
2893
- onClick: ($event) => triangleClick($event, row, col)
2894
- }, null, 8, ["onClick"])) : createCommentVNode("", true),
2895
- createElementVNode("span", {
2896
- style: normalizeStyle(col.type === "tree-node" && !row.children ? "padding-left: 16px;" : "")
2897
- }, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 5)
2898
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2899
- createTextVNode(toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? getEmptyCellText.value(col, row)), 1)
2900
- ], 64))
2901
- ], 12, _hoisted_11))
2902
- ], 16)) : createCommentVNode("", true)
2903
- ], 64);
2904
- }), 256)),
2905
- unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true)
2906
- ], 16, _hoisted_7);
2907
- }), 128)),
2908
- unref(virtual_on) && !unref(isSRBRActive) ? (openBlock(), createElementBlock("tr", {
2909
- key: 1,
2910
- style: normalizeStyle(`height: ${unref(virtual_offsetBottom)}px`)
2911
- }, null, 4)) : createCommentVNode("", true),
2912
- SRBRBottomHeight.value ? (openBlock(), createElementBlock("tr", {
2913
- key: 2,
2914
- style: normalizeStyle(`height: ${SRBRBottomHeight.value}px`)
2915
- }, null, 4)) : createCommentVNode("", true)
2916
- ], 32)
2917
- ], 38),
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
+ ]),
2918
3097
  (!dataSourceCopy.value || !dataSourceCopy.value.length) && __props.showNoData ? (openBlock(), createElementBlock("div", {
2919
3098
  key: 2,
2920
3099
  class: normalizeClass(["stk-table-no-data", { "no-data-full": __props.noDataFull }])
2921
3100
  }, [
2922
3101
  renderSlot(_ctx.$slots, "empty", {}, () => [
2923
- _cache[7] || (_cache[7] = createTextVNode("暂无数据", -1))
3102
+ _cache[11] || (_cache[11] = createTextVNode("暂无数据", -1))
2924
3103
  ])
2925
3104
  ], 2)) : createCommentVNode("", true),
2926
- 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)
2927
3118
  ], 38);
2928
3119
  };
2929
3120
  }