stk-table-vue 0.4.15 → 0.5.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.
@@ -1,5 +1,57 @@
1
- import { watch, onMounted, onBeforeUnmount, ref, shallowRef, computed, defineComponent, nextTick, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, createElementVNode, Fragment, renderList, createBlock, resolveDynamicComponent, toDisplayString, renderSlot, createTextVNode } from "vue";
1
+ import { openBlock, createElementBlock, createElementVNode, watch, onMounted, onBeforeUnmount, ref, shallowRef, computed, defineComponent, nextTick, toRaw, normalizeClass, unref, normalizeStyle, createCommentVNode, Fragment, renderList, createBlock, resolveDynamicComponent, toDisplayString, renderSlot, createVNode, createTextVNode } from "vue";
2
2
  import { interpolateRgb } from "d3-interpolate";
3
+ const _export_sfc = (sfc, props) => {
4
+ const target = sfc.__vccOpts || sfc;
5
+ for (const [key, val] of props) {
6
+ target[key] = val;
7
+ }
8
+ return target;
9
+ };
10
+ const _sfc_main$2 = {};
11
+ const _hoisted_1$2 = {
12
+ class: "drag-row-handle",
13
+ draggable: "true"
14
+ };
15
+ const _hoisted_2$2 = /* @__PURE__ */ createElementVNode("svg", {
16
+ viewBox: "0 0 1024 1024",
17
+ width: "16",
18
+ height: "16",
19
+ fill: "currentColor"
20
+ }, [
21
+ /* @__PURE__ */ createElementVNode("path", { d: "M640 853.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3zM384 341.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z" })
22
+ ], -1);
23
+ const _hoisted_3$2 = [
24
+ _hoisted_2$2
25
+ ];
26
+ function _sfc_render$1(_ctx, _cache) {
27
+ return openBlock(), createElementBlock("span", _hoisted_1$2, _hoisted_3$2);
28
+ }
29
+ const DragHandle = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]);
30
+ const _sfc_main$1 = {};
31
+ const _hoisted_1$1 = {
32
+ xmlns: "http://www.w3.org/2000/svg",
33
+ width: "16px",
34
+ height: "16px",
35
+ viewBox: "0 0 16 16"
36
+ };
37
+ const _hoisted_2$1 = /* @__PURE__ */ createElementVNode("polygon", {
38
+ class: "arrow-up",
39
+ fill: "#757699",
40
+ points: "8 2 4.8 6 11.2 6"
41
+ }, null, -1);
42
+ const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("polygon", {
43
+ class: "arrow-down",
44
+ transform: "translate(8, 12) rotate(-180) translate(-8, -12) ",
45
+ points: "8 10 4.8 14 11.2 14"
46
+ }, null, -1);
47
+ const _hoisted_4$1 = [
48
+ _hoisted_2$1,
49
+ _hoisted_3$1
50
+ ];
51
+ function _sfc_render(_ctx, _cache) {
52
+ return openBlock(), createElementBlock("svg", _hoisted_1$1, _hoisted_4$1);
53
+ }
54
+ const SortIcon = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
3
55
  function isEmptyValue(val, isNumber) {
4
56
  let isEmpty = val === null || val === "" || val === void 0;
5
57
  if (isNumber) {
@@ -174,6 +226,7 @@ const _firefoxVersion = getBrowsersVersion("firefox");
174
226
  const IS_LEGACY_MODE = _chromeVersion < 56 || _firefoxVersion < 59;
175
227
  const DEFAULT_SMOOTH_SCROLL = _chromeVersion < 85;
176
228
  const STK_ID_PREFIX = "stk";
229
+ const EXPANDED_ROW_KEY_PREFIX = "expanded-";
177
230
  var TagType = /* @__PURE__ */ ((TagType2) => {
178
231
  TagType2[TagType2["TH"] = 0] = "TH";
179
232
  TagType2[TagType2["TD"] = 1] = "TD";
@@ -859,62 +912,187 @@ function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll,
859
912
  isMouseOver = true;
860
913
  }
861
914
  }
862
- function useThDrag({ props, emits }) {
863
- let dragStartKey = void 0;
864
- function findParentTH(el) {
865
- let n = el;
866
- while (n) {
867
- if (n.tagName === "TH")
868
- return n;
869
- n = n.parentElement;
870
- }
871
- }
915
+ function useThDrag({ props, emits, colKeyGen }) {
916
+ const findParentTH = (e) => e.target.closest("th");
917
+ const dragConfig = computed(() => {
918
+ const headerDrag = props.headerDrag;
919
+ const draggable = headerDrag !== false;
920
+ return {
921
+ draggable,
922
+ mode: "insert",
923
+ disabled: () => !draggable,
924
+ ...headerDrag
925
+ };
926
+ });
872
927
  function onThDragStart(e) {
873
- const th = findParentTH(e.target);
928
+ const th = findParentTH(e);
874
929
  if (!th)
875
930
  return;
876
- dragStartKey = th.dataset.colKey;
931
+ const dragStartKey = th.dataset.colKey || "";
932
+ const dt = e.dataTransfer;
933
+ if (dt) {
934
+ dt.effectAllowed = "move";
935
+ dt.setData("text/plain", dragStartKey);
936
+ }
877
937
  emits("th-drag-start", dragStartKey);
878
938
  }
879
939
  function onThDragOver(e) {
880
- const th = findParentTH(e.target);
940
+ const th = findParentTH(e);
881
941
  if (!th)
882
942
  return;
883
- const isHeaderDraggable2 = th.getAttribute("draggable") === "true";
884
- if (!isHeaderDraggable2) {
943
+ const isHeaderDraggable = th.getAttribute("draggable") === "true";
944
+ if (!isHeaderDraggable)
885
945
  return;
946
+ const dt = e.dataTransfer;
947
+ if (dt) {
948
+ dt.dropEffect = "move";
886
949
  }
887
950
  e.preventDefault();
888
951
  }
889
952
  function onThDrop(e) {
890
- const th = findParentTH(e.target);
953
+ var _a;
954
+ const th = findParentTH(e);
891
955
  if (!th)
892
956
  return;
957
+ const dragStartKey = (_a = e.dataTransfer) == null ? void 0 : _a.getData("text");
893
958
  if (dragStartKey !== th.dataset.colKey) {
894
- emits("col-order-change", dragStartKey, th.dataset.colKey);
959
+ handleColOrderChange(dragStartKey, th.dataset.colKey);
895
960
  }
896
961
  emits("th-drop", th.dataset.colKey);
897
962
  }
898
- const isHeaderDragFun = typeof props.headerDrag === "function";
899
- function isHeaderDraggable(col) {
900
- if (isHeaderDragFun) {
901
- return props.headerDrag(col);
902
- } else {
903
- return props.headerDrag;
963
+ function handleColOrderChange(dragStartKey, dragEndKey) {
964
+ if (!dragStartKey || !dragEndKey)
965
+ return;
966
+ if (dragConfig.value.mode !== "none") {
967
+ const columns = [...props.columns];
968
+ const dragStartIndex = columns.findIndex((col) => colKeyGen.value(col) === dragStartKey);
969
+ const dragEndIndex = columns.findIndex((col) => colKeyGen.value(col) === dragEndKey);
970
+ if (dragStartIndex === -1 || dragEndIndex === -1)
971
+ return;
972
+ const dragStartCol = columns[dragStartIndex];
973
+ if (dragConfig.value.mode === "swap") {
974
+ columns[dragStartIndex] = columns[dragEndIndex];
975
+ columns[dragEndIndex] = dragStartCol;
976
+ } else {
977
+ columns.splice(dragStartIndex, 1);
978
+ columns.splice(dragEndIndex, 0, dragStartCol);
979
+ }
980
+ emits("update:columns", columns);
904
981
  }
982
+ emits("col-order-change", dragStartKey, dragEndKey);
905
983
  }
906
984
  return {
907
985
  onThDragStart,
908
986
  onThDragOver,
909
987
  onThDrop,
910
- isHeaderDraggable
988
+ /** 是否可拖拽 */
989
+ isHeaderDraggable: dragConfig.value.disabled
990
+ };
991
+ }
992
+ const TR_DRAGGING_CLASS = "tr-dragging";
993
+ const TR_DRAG_OVER_CLASS = "tr-dragging-over";
994
+ const DATA_TRANSFER_FORMAT = "text/plain";
995
+ function useTrDrag({ props, emits, dataSourceCopy }) {
996
+ let trDragFlag = false;
997
+ const dragRowConfig = computed(() => {
998
+ return { mode: "insert", ...props.dragRowConfig };
999
+ });
1000
+ function getClosestTr(e) {
1001
+ const target = e.target;
1002
+ const tr = target == null ? void 0 : target.closest("tr");
1003
+ return tr;
1004
+ }
1005
+ function onTrDragStart(e, rowIndex) {
1006
+ var _a;
1007
+ const tr = getClosestTr(e);
1008
+ if (tr) {
1009
+ const trRect = tr.getBoundingClientRect();
1010
+ const x = e.clientX - (trRect.left ?? 0);
1011
+ (_a = e.dataTransfer) == null ? void 0 : _a.setDragImage(tr, x, trRect.height / 2);
1012
+ tr.classList.add(TR_DRAGGING_CLASS);
1013
+ }
1014
+ const dt = e.dataTransfer;
1015
+ if (dt) {
1016
+ dt.effectAllowed = "move";
1017
+ dt.setData(DATA_TRANSFER_FORMAT, String(rowIndex));
1018
+ }
1019
+ trDragFlag = true;
1020
+ }
1021
+ function onTrDragOver(e) {
1022
+ if (!trDragFlag)
1023
+ return;
1024
+ e.preventDefault();
1025
+ const dt = e.dataTransfer;
1026
+ if (dt) {
1027
+ dt.dropEffect = "move";
1028
+ }
1029
+ }
1030
+ let oldTr = null;
1031
+ function onTrDragEnter(e) {
1032
+ if (!trDragFlag)
1033
+ return;
1034
+ e.preventDefault();
1035
+ const tr = getClosestTr(e);
1036
+ if (oldTr && oldTr !== tr) {
1037
+ oldTr.classList.remove(TR_DRAG_OVER_CLASS);
1038
+ }
1039
+ if (tr) {
1040
+ oldTr = tr;
1041
+ tr.classList.add(TR_DRAG_OVER_CLASS);
1042
+ }
1043
+ }
1044
+ function onTrDragEnd(e) {
1045
+ if (!trDragFlag)
1046
+ return;
1047
+ const tr = getClosestTr(e);
1048
+ if (tr) {
1049
+ tr.classList.remove(TR_DRAGGING_CLASS);
1050
+ }
1051
+ if (oldTr) {
1052
+ oldTr.classList.remove(TR_DRAG_OVER_CLASS);
1053
+ oldTr = null;
1054
+ }
1055
+ trDragFlag = false;
1056
+ }
1057
+ function onTrDrop(e, rowIndex) {
1058
+ if (!trDragFlag)
1059
+ return;
1060
+ const dt = e.dataTransfer;
1061
+ if (!dt)
1062
+ return;
1063
+ const mode = dragRowConfig.value.mode;
1064
+ const sourceIndex = Number(dt.getData(DATA_TRANSFER_FORMAT));
1065
+ dt.clearData(DATA_TRANSFER_FORMAT);
1066
+ const endIndex = rowIndex;
1067
+ if (sourceIndex === endIndex)
1068
+ return;
1069
+ if (mode !== "none") {
1070
+ const dataSourceTemp = [...dataSourceCopy.value];
1071
+ const sourceRow = dataSourceTemp[sourceIndex];
1072
+ if (mode === "swap") {
1073
+ dataSourceTemp[sourceIndex] = dataSourceTemp[endIndex];
1074
+ dataSourceTemp[endIndex] = sourceRow;
1075
+ } else {
1076
+ dataSourceTemp.splice(sourceIndex, 1);
1077
+ dataSourceTemp.splice(endIndex, 0, sourceRow);
1078
+ }
1079
+ dataSourceCopy.value = [...dataSourceTemp];
1080
+ }
1081
+ emits("row-order-change", sourceIndex, endIndex);
1082
+ }
1083
+ return {
1084
+ dragRowConfig,
1085
+ onTrDragStart,
1086
+ onTrDragEnter,
1087
+ onTrDragOver,
1088
+ onTrDrop,
1089
+ onTrDragEnd
911
1090
  };
912
1091
  }
913
1092
  const VUE2_SCROLL_TIMEOUT_MS = 200;
914
1093
  function useVirtualScroll({
915
1094
  props,
916
1095
  tableContainerRef,
917
- theadRef,
918
1096
  dataSourceCopy,
919
1097
  tableHeaderLast,
920
1098
  tableHeaders
@@ -1146,40 +1324,22 @@ const _hoisted_4 = {
1146
1324
  key: 3,
1147
1325
  class: "table-header-sorter"
1148
1326
  };
1149
- const _hoisted_5 = /* @__PURE__ */ createElementVNode("svg", {
1150
- xmlns: "http://www.w3.org/2000/svg",
1151
- width: "16px",
1152
- height: "16px",
1153
- viewBox: "0 0 16 16"
1154
- }, [
1155
- /* @__PURE__ */ createElementVNode("polygon", {
1156
- class: "arrow-up",
1157
- fill: "#757699",
1158
- points: "8 2 4.8 6 11.2 6"
1159
- }),
1160
- /* @__PURE__ */ createElementVNode("polygon", {
1161
- class: "arrow-down",
1162
- transform: "translate(8, 12) rotate(-180) translate(-8, -12) ",
1163
- points: "8 10 4.8 14 11.2 14"
1164
- })
1165
- ], -1);
1166
- const _hoisted_6 = [
1167
- _hoisted_5
1168
- ];
1169
- const _hoisted_7 = ["onMousedown"];
1170
- const _hoisted_8 = ["onMousedown"];
1171
- const _hoisted_9 = { class: "stk-tbody-main" };
1172
- const _hoisted_10 = {
1327
+ const _hoisted_5 = ["onMousedown"];
1328
+ const _hoisted_6 = ["onMousedown"];
1329
+ const _hoisted_7 = {
1173
1330
  key: 0,
1174
1331
  class: "vt-x-left"
1175
1332
  };
1176
- const _hoisted_11 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
1177
- const _hoisted_12 = {
1333
+ const _hoisted_8 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover", "onDrop"];
1334
+ const _hoisted_9 = {
1178
1335
  key: 0,
1179
1336
  class: "vt-x-left"
1180
1337
  };
1181
- const _hoisted_13 = ["data-index", "cell-key", "onClick", "onMouseenter", "onMouseleave", "onMouseover"];
1182
- const _hoisted_14 = ["title"];
1338
+ const _hoisted_10 = ["colspan"];
1339
+ const _hoisted_11 = { class: "table-cell-wrapper" };
1340
+ const _hoisted_12 = ["data-index", "cell-key", "onClick", "onMouseenter", "onMouseleave", "onMouseover"];
1341
+ const _hoisted_13 = ["title"];
1342
+ const _hoisted_14 = { key: 1 };
1183
1343
  const _sfc_main = /* @__PURE__ */ defineComponent({
1184
1344
  __name: "StkTable",
1185
1345
  props: {
@@ -1211,7 +1371,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1211
1371
  cellHover: { type: Boolean, default: false },
1212
1372
  cellActive: { type: Boolean, default: false },
1213
1373
  selectedCellRevokable: { type: Boolean, default: true },
1214
- headerDrag: { type: [Boolean, Function], default: false },
1374
+ headerDrag: { default: false },
1215
1375
  rowClassName: { type: Function, default: () => "" },
1216
1376
  colResizable: { type: Boolean, default: false },
1217
1377
  colMinWidth: { default: 10 },
@@ -1226,10 +1386,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1226
1386
  hideHeaderTitle: { type: [Boolean, Array], default: false },
1227
1387
  highlightConfig: { default: () => ({}) },
1228
1388
  seqConfig: { default: () => ({}) },
1389
+ expandConfig: { default: () => ({}) },
1390
+ dragRowConfig: { default: () => ({}) },
1229
1391
  cellFixedMode: { default: "sticky" },
1230
1392
  smoothScroll: { type: Boolean, default: DEFAULT_SMOOTH_SCROLL }
1231
1393
  },
1232
- emits: ["sort-change", "row-click", "current-change", "cell-selected", "row-dblclick", "header-row-menu", "row-menu", "cell-click", "cell-mouseenter", "cell-mouseleave", "cell-mouseover", "header-cell-click", "scroll", "scroll-x", "col-order-change", "th-drag-start", "th-drop", "col-resize", "update:columns"],
1394
+ emits: ["sort-change", "row-click", "current-change", "cell-selected", "row-dblclick", "header-row-menu", "row-menu", "cell-click", "cell-mouseenter", "cell-mouseleave", "cell-mouseover", "header-cell-click", "scroll", "scroll-x", "col-order-change", "th-drag-start", "th-drop", "row-order-change", "col-resize", "toggle-row-expand", "update:columns"],
1233
1395
  setup(__props, { expose: __expose, emit: __emit }) {
1234
1396
  const stkTableId = createStkTableId();
1235
1397
  const props = __props;
@@ -1253,7 +1415,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1253
1415
  if (typeof props.colKey === "function") {
1254
1416
  return (col) => props.colKey(col);
1255
1417
  } else {
1256
- return (col) => col[props.colKey];
1418
+ return (col) => col ? col[props.colKey] : null;
1257
1419
  }
1258
1420
  });
1259
1421
  const getEmptyCellText = computed(() => {
@@ -1264,7 +1426,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1264
1426
  }
1265
1427
  });
1266
1428
  const rowKeyGenStore = /* @__PURE__ */ new WeakMap();
1267
- const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
1429
+ const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits, colKeyGen });
1430
+ const { onTrDragStart, onTrDrop, onTrDragOver, onTrDragEnd, onTrDragEnter } = useTrDrag({ props, emits, dataSourceCopy });
1268
1431
  const {
1269
1432
  virtualScroll,
1270
1433
  virtualScrollX,
@@ -1279,7 +1442,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1279
1442
  initVirtualScrollX,
1280
1443
  updateVirtualScrollY,
1281
1444
  updateVirtualScrollX
1282
- } = useVirtualScroll({ tableContainerRef, theadRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
1445
+ } = useVirtualScroll({ tableContainerRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
1283
1446
  const getFixedColPosition = useGetFixedColPosition({ colKeyGen, tableHeaders });
1284
1447
  const getFixedStyle = useFixedStyle({
1285
1448
  props,
@@ -1457,7 +1620,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1457
1620
  return row;
1458
1621
  let key = rowKeyGenStore.get(row);
1459
1622
  if (!key) {
1460
- key = typeof props.rowKey === "function" ? props.rowKey(row) : row[props.rowKey];
1623
+ if (row.__ROW_KEY__) {
1624
+ key = row.__ROW_KEY__;
1625
+ } else {
1626
+ key = typeof props.rowKey === "function" ? props.rowKey(row) : row[props.rowKey];
1627
+ }
1461
1628
  if (key === void 0) {
1462
1629
  key = Math.random().toString();
1463
1630
  }
@@ -1568,7 +1735,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1568
1735
  emits("row-menu", e, row);
1569
1736
  }
1570
1737
  function onCellClick(e, row, col) {
1571
- if (props.rowActive) {
1738
+ if (props.cellActive) {
1572
1739
  const cellKey = cellKeyGen(row, col);
1573
1740
  if (props.selectedCellRevokable && currentSelectedCellKey.value === cellKey) {
1574
1741
  currentSelectedCellKey.value = void 0;
@@ -1734,6 +1901,51 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1734
1901
  return [];
1735
1902
  return [{ dataIndex: sortCol.value, order: sortOrder }];
1736
1903
  }
1904
+ function toggleExpandRow(row, col) {
1905
+ const isExpand = (row == null ? void 0 : row.__EXPANDED__) === col ? !(row == null ? void 0 : row.__EXPANDED__) : true;
1906
+ setRowExpand(row, isExpand, { col });
1907
+ }
1908
+ function setRowExpand(rowKeyOrRow, expand, data) {
1909
+ let rowKey;
1910
+ if (typeof rowKeyOrRow === "string") {
1911
+ rowKey = rowKeyOrRow;
1912
+ } else {
1913
+ rowKey = rowKeyGen(rowKeyOrRow);
1914
+ }
1915
+ const tempData = [...dataSourceCopy.value];
1916
+ const index = tempData.findIndex((it) => rowKeyGen(it) === rowKey);
1917
+ if (index === -1) {
1918
+ console.warn("expandRow failed.rowKey:", rowKey);
1919
+ return;
1920
+ }
1921
+ for (let i = index + 1; i < tempData.length; i++) {
1922
+ const item = tempData[i];
1923
+ const rowKey2 = item.__ROW_KEY__;
1924
+ if (rowKey2 == null ? void 0 : rowKey2.startsWith(EXPANDED_ROW_KEY_PREFIX)) {
1925
+ tempData.splice(i, 1);
1926
+ i--;
1927
+ } else {
1928
+ break;
1929
+ }
1930
+ }
1931
+ const row = tempData[index];
1932
+ const col = (data == null ? void 0 : data.col) || null;
1933
+ if (expand) {
1934
+ const newExpandRow = {
1935
+ __ROW_KEY__: EXPANDED_ROW_KEY_PREFIX + rowKey,
1936
+ __EXPANDED_ROW__: row,
1937
+ __EXPANDED_COL__: col
1938
+ };
1939
+ tempData.splice(index + 1, 0, newExpandRow);
1940
+ }
1941
+ if (row) {
1942
+ row.__EXPANDED__ = expand ? col : null;
1943
+ }
1944
+ dataSourceCopy.value = tempData;
1945
+ if (!(data == null ? void 0 : data.silent)) {
1946
+ emits("toggle-row-expand", { expanded: Boolean(expand), row, col });
1947
+ }
1948
+ }
1737
1949
  __expose({
1738
1950
  /** @see {@link initVirtualScroll} */
1739
1951
  initVirtualScroll,
@@ -1760,7 +1972,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1760
1972
  /** @see {@link scrollTo} */
1761
1973
  scrollTo,
1762
1974
  /** @see {@link getTableData} */
1763
- getTableData
1975
+ getTableData,
1976
+ /** @see {@link setRowExpand} */
1977
+ setRowExpand
1764
1978
  });
1765
1979
  return (_ctx, _cache) => {
1766
1980
  return openBlock(), createElementBlock("div", {
@@ -1851,7 +2065,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1851
2065
  }, [
1852
2066
  createElementVNode("div", {
1853
2067
  class: "table-header-cell-wrapper",
1854
- style: normalizeStyle(`--row-span:${unref(virtualX_on) ? 1 : col.rowSpan}`)
2068
+ style: normalizeStyle({ "--row-span": unref(virtualX_on) ? 1 : col.rowSpan })
1855
2069
  }, [
1856
2070
  col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
1857
2071
  key: 0,
@@ -1864,17 +2078,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1864
2078
  }, () => [
1865
2079
  createElementVNode("span", _hoisted_3, toDisplayString(col.title), 1)
1866
2080
  ]),
1867
- col.sorter ? (openBlock(), createElementBlock("span", _hoisted_4, _hoisted_6)) : createCommentVNode("", true),
2081
+ col.sorter ? (openBlock(), createElementBlock("span", _hoisted_4, [
2082
+ createVNode(SortIcon)
2083
+ ])) : createCommentVNode("", true),
1868
2084
  _ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
1869
2085
  key: 4,
1870
2086
  class: "table-header-resizer left",
1871
2087
  onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
1872
- }, null, 40, _hoisted_7)) : createCommentVNode("", true),
2088
+ }, null, 40, _hoisted_5)) : createCommentVNode("", true),
1873
2089
  _ctx.colResizable ? (openBlock(), createElementBlock("div", {
1874
2090
  key: 5,
1875
2091
  class: "table-header-resizer right",
1876
2092
  onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
1877
- }, null, 40, _hoisted_8)) : createCommentVNode("", true)
2093
+ }, null, 40, _hoisted_6)) : createCommentVNode("", true)
1878
2094
  ], 4)
1879
2095
  ], 46, _hoisted_1);
1880
2096
  }), 128)),
@@ -1886,13 +2102,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1886
2102
  ], 32);
1887
2103
  }), 128))
1888
2104
  ], 512)) : createCommentVNode("", true),
1889
- createElementVNode("tbody", _hoisted_9, [
2105
+ createElementVNode("tbody", {
2106
+ class: "stk-tbody-main",
2107
+ onDragover: _cache[4] || (_cache[4] = //@ts-ignore
2108
+ (...args) => unref(onTrDragOver) && unref(onTrDragOver)(...args)),
2109
+ onDragenter: _cache[5] || (_cache[5] = //@ts-ignore
2110
+ (...args) => unref(onTrDragEnter) && unref(onTrDragEnter)(...args)),
2111
+ onDragend: _cache[6] || (_cache[6] = //@ts-ignore
2112
+ (...args) => unref(onTrDragEnd) && unref(onTrDragEnd)(...args))
2113
+ }, [
1890
2114
  unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1891
2115
  key: 0,
1892
2116
  style: normalizeStyle(`height:${unref(virtualScroll).offsetTop}px`),
1893
2117
  class: "padding-top-tr"
1894
2118
  }, [
1895
- unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
2119
+ unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_7)) : createCommentVNode("", true),
1896
2120
  _ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
1897
2121
  return openBlock(), createElementBlock("td", {
1898
2122
  key: col.dataIndex,
@@ -1901,22 +2125,44 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1901
2125
  }), 128)) : createCommentVNode("", true)
1902
2126
  ], 4)) : createCommentVNode("", true),
1903
2127
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
2128
+ var _a, _b;
1904
2129
  return openBlock(), createElementBlock("tr", {
1905
- id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : rowIndex),
1906
- key: _ctx.rowKey ? rowKeyGen(row) : rowIndex,
1907
- "data-row-key": _ctx.rowKey ? rowKeyGen(row) : rowIndex,
2130
+ id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : unref(virtualScroll).startIndex + rowIndex),
2131
+ key: _ctx.rowKey ? rowKeyGen(row) : unref(virtualScroll).startIndex + rowIndex,
2132
+ "data-row-key": _ctx.rowKey ? rowKeyGen(row) : unref(virtualScroll).startIndex + rowIndex,
1908
2133
  class: normalizeClass({
1909
2134
  active: _ctx.rowKey ? rowKeyGen(row) === currentRowKey.value : row === currentRow.value,
1910
2135
  hover: props.showTrHoverClass && (_ctx.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
1911
- [_ctx.rowClassName(row, rowIndex)]: true
2136
+ [_ctx.rowClassName(row, unref(virtualScroll).startIndex + rowIndex)]: true,
2137
+ expanded: row == null ? void 0 : row.__EXPANDED__,
2138
+ "expanded-row": row && row.__EXPANDED_ROW__
2139
+ }),
2140
+ style: normalizeStyle({
2141
+ "--row-height": row && row.__EXPANDED_ROW__ && unref(virtual_on) && ((_a = props.expandConfig) == null ? void 0 : _a.height) && ((_b = props.expandConfig) == null ? void 0 : _b.height) + "px"
1912
2142
  }),
1913
2143
  onClick: (e) => onRowClick(e, row),
1914
2144
  onDblclick: (e) => onRowDblclick(e, row),
1915
2145
  onContextmenu: (e) => onRowMenu(e, row),
1916
- onMouseover: (e) => onTrMouseOver(e, row)
2146
+ onMouseover: (e) => onTrMouseOver(e, row),
2147
+ onDrop: (e) => unref(onTrDrop)(e, unref(virtualScroll).startIndex + rowIndex)
1917
2148
  }, [
1918
- unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true),
1919
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col, colIndex) => {
2149
+ unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_9)) : createCommentVNode("", true),
2150
+ row && row.__EXPANDED_ROW__ ? (openBlock(), createElementBlock("td", {
2151
+ key: 1,
2152
+ colspan: unref(virtualX_columnPart).length
2153
+ }, [
2154
+ createElementVNode("div", _hoisted_11, [
2155
+ renderSlot(_ctx.$slots, "expand", {
2156
+ row: row.__EXPANDED_ROW__,
2157
+ col: row.__EXPANDED_COL__
2158
+ }, () => {
2159
+ var _a2;
2160
+ return [
2161
+ createTextVNode(toDisplayString(((_a2 = row.__EXPANDED_ROW__) == null ? void 0 : _a2[row.__EXPANDED_COL__.dataIndex]) ?? ""), 1)
2162
+ ];
2163
+ })
2164
+ ])
2165
+ ], 8, _hoisted_10)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(unref(virtualX_columnPart), (col, colIndex) => {
1920
2166
  return openBlock(), createElementBlock("td", {
1921
2167
  key: col.dataIndex,
1922
2168
  "data-index": col.dataIndex,
@@ -1927,41 +2173,54 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1927
2173
  unref(fixedColClassMap).get(colKeyGen.value(col)),
1928
2174
  {
1929
2175
  "seq-column": col.type === "seq",
1930
- active: currentSelectedCellKey.value === cellKeyGen(row, col)
2176
+ active: currentSelectedCellKey.value === cellKeyGen(row, col),
2177
+ "expand-cell": col.type === "expand",
2178
+ expanded: col.type === "expand" && colKeyGen.value(row == null ? void 0 : row.__EXPANDED__) === colKeyGen.value(col),
2179
+ "drag-row-cell": col.type === "dragRow"
1931
2180
  }
1932
2181
  ]),
1933
- onClick: (e) => onCellClick(e, row, col),
2182
+ onClick: (e) => {
2183
+ col.type === "expand" && toggleExpandRow(row, col);
2184
+ onCellClick(e, row, col);
2185
+ },
1934
2186
  onMouseenter: (e) => onCellMouseEnter(e, row, col),
1935
2187
  onMouseleave: (e) => onCellMouseLeave(e, row, col),
1936
2188
  onMouseover: (e) => onCellMouseOver(e, row, col)
1937
2189
  }, [
1938
2190
  col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
1939
2191
  key: 0,
2192
+ class: "table-cell-wrapper",
1940
2193
  col,
1941
2194
  row,
1942
- rowIndex,
2195
+ rowIndex: unref(virtualScroll).startIndex + rowIndex,
1943
2196
  colIndex,
1944
- cellValue: row == null ? void 0 : row[col.dataIndex]
1945
- }, null, 8, ["col", "row", "rowIndex", "colIndex", "cellValue"])) : (openBlock(), createElementBlock("div", {
2197
+ cellValue: row == null ? void 0 : row[col.dataIndex],
2198
+ expanded: (row == null ? void 0 : row.__EXPANDED__) || null
2199
+ }, null, 8, ["col", "row", "rowIndex", "colIndex", "cellValue", "expanded"])) : (openBlock(), createElementBlock("div", {
1946
2200
  key: 1,
1947
- class: "table-cell-wrapper",
1948
- title: !col.type ? row == null ? void 0 : row[col.dataIndex] : ""
2201
+ class: normalizeClass(["table-cell-wrapper", { "expanded-cell-wrapper": col.type === "expand" }]),
2202
+ title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : ""
1949
2203
  }, [
1950
2204
  col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1951
- createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + rowIndex + 1), 1)
1952
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2205
+ createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + unref(virtualScroll).startIndex + rowIndex + 1), 1)
2206
+ ], 64)) : col.type === "expand" ? (openBlock(), createElementBlock("span", _hoisted_14, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)) : col.type === "dragRow" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2207
+ createVNode(DragHandle, {
2208
+ onDragstart: (e) => unref(onTrDragStart)(e, unref(virtualScroll).startIndex + rowIndex)
2209
+ }, null, 8, ["onDragstart"]),
2210
+ createElementVNode("span", null, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)
2211
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
1953
2212
  createTextVNode(toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? getEmptyCellText.value(col, row)), 1)
1954
2213
  ], 64))
1955
- ], 8, _hoisted_14))
1956
- ], 46, _hoisted_13);
2214
+ ], 10, _hoisted_13))
2215
+ ], 46, _hoisted_12);
1957
2216
  }), 128))
1958
- ], 42, _hoisted_11);
2217
+ ], 46, _hoisted_8);
1959
2218
  }), 128)),
1960
2219
  unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1961
2220
  key: 1,
1962
2221
  style: normalizeStyle(`height: ${unref(virtual_offsetBottom)}px`)
1963
2222
  }, null, 4)) : createCommentVNode("", true)
1964
- ])
2223
+ ], 32)
1965
2224
  ], 6),
1966
2225
  (!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
1967
2226
  key: 1,