stk-table-vue 0.3.1 → 0.3.3
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.
- package/README.md +32 -3
- package/lib/src/StkTable/StkTable.vue.d.ts +42 -6
- package/lib/src/StkTable/useColResize.d.ts +3 -3
- package/lib/src/StkTable/useFixedCol.d.ts +4 -4
- package/lib/src/StkTable/useVirtualScroll.d.ts +4 -1
- package/lib/stk-table-vue.js +117 -76
- package/lib/style.css +116 -123
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +106 -46
- package/src/StkTable/style.less +205 -229
- package/src/StkTable/useColResize.ts +5 -5
- package/src/StkTable/useFixedCol.ts +4 -4
- package/src/StkTable/useFixedStyle.ts +30 -9
- package/src/StkTable/useHighlight.ts +5 -4
- package/src/StkTable/useVirtualScroll.ts +19 -15
- package/src/StkTable/utils.ts +1 -1
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onMounted, onBeforeUnmount, watch, ref, shallowRef, computed, defineComponent, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, createElementVNode, Fragment, renderList, createBlock, resolveDynamicComponent, toDisplayString, renderSlot, createTextVNode } from "vue";
|
|
1
|
+
import { onMounted, onBeforeUnmount, watch, ref, shallowRef, computed, defineComponent, nextTick, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, createElementVNode, Fragment, renderList, createBlock, resolveDynamicComponent, toDisplayString, renderSlot, createTextVNode } from "vue";
|
|
2
2
|
import { interpolateRgb } from "d3-interpolate";
|
|
3
3
|
const DEFAULT_COL_WIDTH = "100";
|
|
4
4
|
const DEFAULT_TABLE_HEIGHT = 100;
|
|
@@ -81,7 +81,7 @@ function useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs
|
|
|
81
81
|
function isEmptyValue(val, isNumber) {
|
|
82
82
|
let isEmpty = val === null || val === "";
|
|
83
83
|
if (isNumber) {
|
|
84
|
-
isEmpty
|
|
84
|
+
isEmpty = isEmpty || typeof val === "boolean" || Number.isNaN(+val);
|
|
85
85
|
}
|
|
86
86
|
return isEmpty;
|
|
87
87
|
}
|
|
@@ -260,7 +260,7 @@ function useColResize({
|
|
|
260
260
|
const { clientX } = e;
|
|
261
261
|
const { scrollLeft, scrollTop } = tableContainerRef.value;
|
|
262
262
|
const { left } = tableContainerRef.value.getBoundingClientRect();
|
|
263
|
-
let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen(it) === colKeyGen(col));
|
|
263
|
+
let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen.value(it) === colKeyGen.value(col));
|
|
264
264
|
if (isPrev) {
|
|
265
265
|
colIndex -= 1;
|
|
266
266
|
col = tableHeaderLast.value[colIndex];
|
|
@@ -307,7 +307,7 @@ function useColResize({
|
|
|
307
307
|
let width = getCalculatedColWidth(lastCol) + moveX;
|
|
308
308
|
if (width < props.colMinWidth)
|
|
309
309
|
width = props.colMinWidth;
|
|
310
|
-
const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
|
|
310
|
+
const curCol = tableHeaderLast.value.find((it) => colKeyGen.value(it) === colKeyGen.value(lastCol));
|
|
311
311
|
if (!curCol)
|
|
312
312
|
return;
|
|
313
313
|
curCol.width = width + "px";
|
|
@@ -359,7 +359,7 @@ function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast, tableCon
|
|
|
359
359
|
["fixed-cell--" + col.fixed]: col.fixed,
|
|
360
360
|
"fixed-cell--shadow": showShadow
|
|
361
361
|
};
|
|
362
|
-
colMap.set(colKeyGen(col), classObj);
|
|
362
|
+
colMap.set(colKeyGen.value(col), classObj);
|
|
363
363
|
});
|
|
364
364
|
});
|
|
365
365
|
return colMap;
|
|
@@ -453,33 +453,45 @@ function useFixedStyle({
|
|
|
453
453
|
const { fixed } = col;
|
|
454
454
|
if (tagType === TagType.TD && !fixed)
|
|
455
455
|
return null;
|
|
456
|
-
const isFixedLeft = fixed === "left";
|
|
457
456
|
const style = {};
|
|
458
457
|
const { colKeyStore, refStore } = fixedColumnsPositionStore.value;
|
|
458
|
+
let isRelativeMode = true;
|
|
459
|
+
if (props.cellFixedMode === "sticky") {
|
|
460
|
+
isRelativeMode = false;
|
|
461
|
+
}
|
|
459
462
|
if (IS_LEGACY_MODE) {
|
|
463
|
+
isRelativeMode = true;
|
|
464
|
+
}
|
|
465
|
+
const { scrollLeft, scrollWidth, offsetLeft, containerWidth } = virtualScrollX.value;
|
|
466
|
+
const scrollRight = scrollWidth - containerWidth - scrollLeft;
|
|
467
|
+
if (virtualScrollX.value.scrollLeft === 0 && fixed === "left" && tagType === TagType.TD) {
|
|
468
|
+
style.position = void 0;
|
|
469
|
+
} else if (scrollRight === 0 && fixed === "right" && tagType === TagType.TD) {
|
|
470
|
+
style.position = void 0;
|
|
471
|
+
} else if (isRelativeMode) {
|
|
460
472
|
style.position = "relative";
|
|
461
473
|
} else {
|
|
462
474
|
style.position = "sticky";
|
|
463
475
|
}
|
|
476
|
+
const isFixedLeft = fixed === "left";
|
|
464
477
|
if (tagType === TagType.TH) {
|
|
465
|
-
if (
|
|
466
|
-
style.top = virtualScroll.value.scrollTop +
|
|
478
|
+
if (isRelativeMode) {
|
|
479
|
+
style.top = virtualScroll.value.scrollTop + "px";
|
|
467
480
|
} else {
|
|
468
481
|
style.top = depth * props.rowHeight + "px";
|
|
469
482
|
}
|
|
470
483
|
style.zIndex = isFixedLeft ? "3" : "2";
|
|
471
484
|
} else {
|
|
472
|
-
|
|
485
|
+
if (isFixedLeft) {
|
|
486
|
+
style.zIndex = "2";
|
|
487
|
+
}
|
|
473
488
|
}
|
|
474
489
|
if (fixed === "left" || fixed === "right") {
|
|
475
|
-
if (
|
|
490
|
+
if (isRelativeMode) {
|
|
476
491
|
if (isFixedLeft) {
|
|
477
|
-
|
|
478
|
-
style.left = virtualScrollX.value.scrollLeft - virtualScrollX.value.offsetLeft + "px";
|
|
479
|
-
else
|
|
480
|
-
style.left = virtualScrollX.value.scrollLeft + "px";
|
|
492
|
+
style.left = scrollLeft - (virtualX_on.value ? offsetLeft : 0) + "px";
|
|
481
493
|
} else {
|
|
482
|
-
style.right =
|
|
494
|
+
style.right = Math.max(scrollRight - (virtualX_on.value ? virtualX_offsetRight.value : 0), 0) + "px";
|
|
483
495
|
}
|
|
484
496
|
} else {
|
|
485
497
|
const lr = (col.dataIndex ? colKeyStore[col.dataIndex] : refStore.get(col)) + "px";
|
|
@@ -552,7 +564,7 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
552
564
|
highlightDimRowsJs.forEach((highlightStart, rowKeyValue) => {
|
|
553
565
|
const progress = (nowTs - highlightStart) / highlightDuration;
|
|
554
566
|
let bgc = "";
|
|
555
|
-
if (0
|
|
567
|
+
if (0 <= progress && progress <= 1) {
|
|
556
568
|
bgc = highlightInter.value(progress);
|
|
557
569
|
} else {
|
|
558
570
|
highlightDimRowsJs.delete(rowKeyValue);
|
|
@@ -599,11 +611,11 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
599
611
|
...defaultHighlightDimOption,
|
|
600
612
|
...option
|
|
601
613
|
};
|
|
602
|
-
const nowTs = Date.now();
|
|
603
614
|
if (method === "css" || useCss) {
|
|
604
615
|
highlightRowsInCssKeyframe(rowKeyValues, className, duration);
|
|
605
616
|
} else if (method === "animation") {
|
|
606
617
|
if (props.virtual) {
|
|
618
|
+
const nowTs = Date.now();
|
|
607
619
|
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
608
620
|
const rowKeyValue = rowKeyValues[i];
|
|
609
621
|
const store = { ts: nowTs, visible: false, keyframe, duration };
|
|
@@ -620,6 +632,7 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
620
632
|
}
|
|
621
633
|
}
|
|
622
634
|
} else if (method === "js") {
|
|
635
|
+
const nowTs = Date.now();
|
|
623
636
|
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
624
637
|
const rowKeyValue = rowKeyValues[i];
|
|
625
638
|
highlightDimRowsJs.set(rowKeyValue, nowTs);
|
|
@@ -836,6 +849,7 @@ function useVirtualScroll({
|
|
|
836
849
|
});
|
|
837
850
|
const virtualScrollX = ref({
|
|
838
851
|
containerWidth: 0,
|
|
852
|
+
scrollWidth: 0,
|
|
839
853
|
startIndex: 0,
|
|
840
854
|
endIndex: 0,
|
|
841
855
|
offsetLeft: 0,
|
|
@@ -848,7 +862,7 @@ function useVirtualScroll({
|
|
|
848
862
|
if (!virtual_on.value)
|
|
849
863
|
return dataSourceCopy.value;
|
|
850
864
|
const { startIndex, endIndex } = virtualScroll.value;
|
|
851
|
-
return dataSourceCopy.value.slice(startIndex, endIndex);
|
|
865
|
+
return dataSourceCopy.value.slice(startIndex, endIndex + 1);
|
|
852
866
|
});
|
|
853
867
|
const virtual_offsetBottom = computed(() => {
|
|
854
868
|
if (!virtual_on.value)
|
|
@@ -912,10 +926,9 @@ function useVirtualScroll({
|
|
|
912
926
|
updateVirtualScrollY(scrollTop);
|
|
913
927
|
}
|
|
914
928
|
function initVirtualScrollX() {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
virtualScrollX.value.containerWidth = offsetWidth || DEFAULT_TABLE_WIDTH;
|
|
929
|
+
const { clientWidth, scrollLeft, scrollWidth } = tableContainerRef.value || {};
|
|
930
|
+
virtualScrollX.value.containerWidth = clientWidth || DEFAULT_TABLE_WIDTH;
|
|
931
|
+
virtualScrollX.value.scrollWidth = scrollWidth || DEFAULT_TABLE_WIDTH;
|
|
919
932
|
updateVirtualScrollX(scrollLeft);
|
|
920
933
|
}
|
|
921
934
|
function initVirtualScroll(height) {
|
|
@@ -926,6 +939,8 @@ function useVirtualScroll({
|
|
|
926
939
|
function updateVirtualScrollY(sTop = 0) {
|
|
927
940
|
const { rowHeight, pageSize, scrollTop, startIndex: oldStartIndex } = virtualScroll.value;
|
|
928
941
|
virtualScroll.value.scrollTop = sTop;
|
|
942
|
+
if (!virtual_on.value)
|
|
943
|
+
return;
|
|
929
944
|
let startIndex = Math.floor(sTop / rowHeight);
|
|
930
945
|
if (props.stripe) {
|
|
931
946
|
startIndex -= 1;
|
|
@@ -941,14 +956,12 @@ function useVirtualScroll({
|
|
|
941
956
|
startIndex -= 1;
|
|
942
957
|
}
|
|
943
958
|
}
|
|
944
|
-
let endIndex = startIndex + pageSize
|
|
959
|
+
let endIndex = startIndex + pageSize;
|
|
945
960
|
if (props.stripe) {
|
|
946
|
-
endIndex +=
|
|
961
|
+
endIndex += 1;
|
|
947
962
|
}
|
|
948
963
|
const offsetTop = startIndex * rowHeight;
|
|
949
|
-
|
|
950
|
-
endIndex = dataSourceCopy.value.length;
|
|
951
|
-
}
|
|
964
|
+
endIndex = Math.min(endIndex, dataSourceCopy.value.length);
|
|
952
965
|
if (vue2ScrollYTimeout) {
|
|
953
966
|
window.clearTimeout(vue2ScrollYTimeout);
|
|
954
967
|
}
|
|
@@ -968,6 +981,8 @@ function useVirtualScroll({
|
|
|
968
981
|
let vue2ScrollXTimeout = null;
|
|
969
982
|
function updateVirtualScrollX(sLeft = 0) {
|
|
970
983
|
var _a;
|
|
984
|
+
if (!props.virtualX)
|
|
985
|
+
return;
|
|
971
986
|
const headerLength = (_a = tableHeaderLast.value) == null ? void 0 : _a.length;
|
|
972
987
|
const { scrollLeft } = virtualScrollX.value;
|
|
973
988
|
if (!headerLength)
|
|
@@ -1002,9 +1017,7 @@ function useVirtualScroll({
|
|
|
1002
1017
|
break;
|
|
1003
1018
|
}
|
|
1004
1019
|
}
|
|
1005
|
-
|
|
1006
|
-
endIndex = headerLength;
|
|
1007
|
-
}
|
|
1020
|
+
endIndex = Math.min(endIndex, headerLength);
|
|
1008
1021
|
if (vue2ScrollXTimeout) {
|
|
1009
1022
|
window.clearTimeout(vue2ScrollXTimeout);
|
|
1010
1023
|
}
|
|
@@ -1069,16 +1082,14 @@ const _hoisted_9 = ["onMousedown"];
|
|
|
1069
1082
|
const _hoisted_10 = ["onMousedown"];
|
|
1070
1083
|
const _hoisted_11 = {
|
|
1071
1084
|
key: 0,
|
|
1072
|
-
class: "virtual-x-left"
|
|
1073
|
-
style: { "padding": "0" }
|
|
1085
|
+
class: "virtual-x-left"
|
|
1074
1086
|
};
|
|
1075
1087
|
const _hoisted_12 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
|
|
1076
1088
|
const _hoisted_13 = {
|
|
1077
1089
|
key: 0,
|
|
1078
|
-
class: "virtual-x-left"
|
|
1079
|
-
style: { "padding": "0" }
|
|
1090
|
+
class: "virtual-x-left"
|
|
1080
1091
|
};
|
|
1081
|
-
const _hoisted_14 = ["data-index", "onClick"];
|
|
1092
|
+
const _hoisted_14 = ["data-index", "onClick", "onMouseenter", "onMouseleave", "onMouseover"];
|
|
1082
1093
|
const _hoisted_15 = ["title"];
|
|
1083
1094
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1084
1095
|
__name: "StkTable",
|
|
@@ -1105,6 +1116,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1105
1116
|
showHeaderOverflow: { type: Boolean, default: false },
|
|
1106
1117
|
showOverflow: { type: Boolean, default: false },
|
|
1107
1118
|
showTrHoverClass: { type: Boolean, default: false },
|
|
1119
|
+
cellHover: { type: Boolean, default: false },
|
|
1108
1120
|
headerDrag: { type: [Boolean, Function], default: false },
|
|
1109
1121
|
rowClassName: { type: Function, default: () => "" },
|
|
1110
1122
|
colResizable: { type: Boolean, default: false },
|
|
@@ -1119,24 +1131,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1119
1131
|
}) },
|
|
1120
1132
|
hideHeaderTitle: { type: [Boolean, Array], default: false },
|
|
1121
1133
|
highlightConfig: { default: () => ({}) },
|
|
1122
|
-
seqConfig: { default: () => ({}) }
|
|
1134
|
+
seqConfig: { default: () => ({}) },
|
|
1135
|
+
cellFixedMode: { default: "sticky" }
|
|
1123
1136
|
},
|
|
1124
|
-
emits: ["sort-change", "row-click", "current-change", "row-dblclick", "header-row-menu", "row-menu", "cell-click", "header-cell-click", "scroll", "scroll-x", "col-order-change", "th-drag-start", "th-drop", "update:columns"],
|
|
1137
|
+
emits: ["sort-change", "row-click", "current-change", "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", "update:columns"],
|
|
1125
1138
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1126
1139
|
const stkTableId = createStkTableId();
|
|
1127
1140
|
const props = __props;
|
|
1128
1141
|
const emits = __emit;
|
|
1129
1142
|
const tableContainerRef = ref();
|
|
1130
1143
|
const colResizeIndicatorRef = ref();
|
|
1131
|
-
const
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1144
|
+
const currentRow = ref(null);
|
|
1145
|
+
const currentRowKey = ref(null);
|
|
1146
|
+
let currentHoverRow = null;
|
|
1147
|
+
const currentHoverRowKey = ref(null);
|
|
1134
1148
|
let sortCol = ref();
|
|
1135
1149
|
let sortOrderIndex = ref(0);
|
|
1136
1150
|
const sortSwitchOrder = [null, "desc", "asc"];
|
|
1137
1151
|
const tableHeaders = shallowRef([]);
|
|
1138
1152
|
const tableHeaderLast = shallowRef([]);
|
|
1139
1153
|
const dataSourceCopy = shallowRef([...props.dataSource]);
|
|
1154
|
+
const colKeyGen = computed(() => {
|
|
1155
|
+
if (typeof props.colKey === "function") {
|
|
1156
|
+
return (col) => props.colKey(col);
|
|
1157
|
+
} else {
|
|
1158
|
+
return (col) => col[props.colKey];
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1140
1161
|
const getEmptyCellText = computed(() => {
|
|
1141
1162
|
if (typeof props.emptyCellText === "string") {
|
|
1142
1163
|
return () => props.emptyCellText;
|
|
@@ -1200,14 +1221,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1200
1221
|
() => props.columns,
|
|
1201
1222
|
() => {
|
|
1202
1223
|
dealColumns();
|
|
1203
|
-
initVirtualScrollX
|
|
1224
|
+
nextTick(initVirtualScrollX);
|
|
1204
1225
|
}
|
|
1205
1226
|
);
|
|
1206
1227
|
watch(
|
|
1207
1228
|
() => props.virtualX,
|
|
1208
|
-
() =>
|
|
1229
|
+
() => {
|
|
1230
|
+
dealColumns();
|
|
1231
|
+
nextTick(initVirtualScrollX);
|
|
1232
|
+
}
|
|
1209
1233
|
);
|
|
1210
|
-
dealColumns();
|
|
1211
1234
|
watch(
|
|
1212
1235
|
() => props.dataSource,
|
|
1213
1236
|
(val) => {
|
|
@@ -1233,6 +1256,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1233
1256
|
}
|
|
1234
1257
|
);
|
|
1235
1258
|
watch(() => props.fixedColShadow, dealFixedColShadow);
|
|
1259
|
+
dealColumns();
|
|
1236
1260
|
onMounted(() => {
|
|
1237
1261
|
initVirtualScroll();
|
|
1238
1262
|
updateFixedShadow();
|
|
@@ -1304,15 +1328,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1304
1328
|
}
|
|
1305
1329
|
return key;
|
|
1306
1330
|
}
|
|
1307
|
-
function colKeyGen(col) {
|
|
1308
|
-
return typeof props.colKey === "function" ? props.colKey(col) : col[props.colKey];
|
|
1309
|
-
}
|
|
1310
1331
|
const cellStyleMap = computed(() => {
|
|
1311
1332
|
const thMap = /* @__PURE__ */ new Map();
|
|
1312
1333
|
const tdMap = /* @__PURE__ */ new Map();
|
|
1313
1334
|
tableHeaders.value.forEach((cols, depth) => {
|
|
1314
1335
|
cols.forEach((col) => {
|
|
1315
|
-
const colKey = colKeyGen(col);
|
|
1336
|
+
const colKey = colKeyGen.value(col);
|
|
1316
1337
|
const width = props.virtualX ? getCalculatedColWidth(col) + "px" : transformWidthToStr(col.width);
|
|
1317
1338
|
const style = {
|
|
1318
1339
|
width
|
|
@@ -1377,11 +1398,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1377
1398
|
}
|
|
1378
1399
|
function onRowClick(e, row) {
|
|
1379
1400
|
emits("row-click", e, row);
|
|
1380
|
-
if (props.rowKey ?
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1401
|
+
if (props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row) {
|
|
1402
|
+
currentRow.value = null;
|
|
1403
|
+
currentRowKey.value = null;
|
|
1404
|
+
emits("current-change", e, row, { select: false });
|
|
1405
|
+
} else {
|
|
1406
|
+
currentRow.value = row;
|
|
1407
|
+
currentRowKey.value = rowKeyGen(row);
|
|
1408
|
+
emits("current-change", e, row, { select: true });
|
|
1409
|
+
}
|
|
1385
1410
|
}
|
|
1386
1411
|
function onRowDblclick(e, row) {
|
|
1387
1412
|
emits("row-dblclick", e, row);
|
|
@@ -1398,6 +1423,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1398
1423
|
function onHeaderCellClick(e, col) {
|
|
1399
1424
|
emits("header-cell-click", e, col);
|
|
1400
1425
|
}
|
|
1426
|
+
function onCellMouseEnter(e, row, col) {
|
|
1427
|
+
emits("cell-mouseenter", e, row, col);
|
|
1428
|
+
}
|
|
1429
|
+
function onCellMouseLeave(e, row, col) {
|
|
1430
|
+
emits("cell-mouseleave", e, row, col);
|
|
1431
|
+
}
|
|
1432
|
+
function onCellMouseOver(e, row, col) {
|
|
1433
|
+
emits("cell-mouseover", e, row, col);
|
|
1434
|
+
}
|
|
1401
1435
|
function onTableWheel(e) {
|
|
1402
1436
|
if (isColResizing.value) {
|
|
1403
1437
|
e.preventDefault();
|
|
@@ -1413,7 +1447,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1413
1447
|
const { scrollLeft: vScrollLeft } = virtualScrollX.value;
|
|
1414
1448
|
const isYScroll = scrollTop !== vScrollTop;
|
|
1415
1449
|
const isXScroll = scrollLeft !== vScrollLeft;
|
|
1416
|
-
if (isYScroll
|
|
1450
|
+
if (isYScroll) {
|
|
1417
1451
|
updateVirtualScrollY(scrollTop);
|
|
1418
1452
|
}
|
|
1419
1453
|
if (isXScroll) {
|
|
@@ -1434,17 +1468,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1434
1468
|
}
|
|
1435
1469
|
}
|
|
1436
1470
|
function onTrMouseOver(_e, row) {
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
|
|
1471
|
+
if (currentHoverRow === row)
|
|
1472
|
+
return;
|
|
1473
|
+
currentHoverRow = row;
|
|
1474
|
+
currentHoverRowKey.value = rowKeyGen(row);
|
|
1440
1475
|
}
|
|
1441
1476
|
function setCurrentRow(rowKey, option = { silent: false }) {
|
|
1442
1477
|
if (!dataSourceCopy.value.length)
|
|
1443
1478
|
return;
|
|
1444
|
-
|
|
1445
|
-
|
|
1479
|
+
currentRow.value = dataSourceCopy.value.find((it) => rowKeyGen(it) === rowKey);
|
|
1480
|
+
currentRowKey.value = rowKeyGen(currentRow.value);
|
|
1446
1481
|
if (!option.silent) {
|
|
1447
|
-
emits(
|
|
1482
|
+
emits(
|
|
1483
|
+
"current-change",
|
|
1484
|
+
/** no Event */
|
|
1485
|
+
null,
|
|
1486
|
+
currentRow.value,
|
|
1487
|
+
{ select: Boolean(currentRowKey.value) }
|
|
1488
|
+
);
|
|
1448
1489
|
}
|
|
1449
1490
|
}
|
|
1450
1491
|
function setSorter(dataIndex, order, option = {}) {
|
|
@@ -1524,7 +1565,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1524
1565
|
"border-h": props.bordered === "h",
|
|
1525
1566
|
"border-v": props.bordered === "v",
|
|
1526
1567
|
"border-body-v": props.bordered === "body-v",
|
|
1527
|
-
stripe: props.stripe
|
|
1568
|
+
stripe: props.stripe,
|
|
1569
|
+
"cell-hover": props.cellHover,
|
|
1570
|
+
"text-overflow": props.showOverflow,
|
|
1571
|
+
"header-text-overflow": props.showHeaderOverflow
|
|
1528
1572
|
}]),
|
|
1529
1573
|
style: normalizeStyle([
|
|
1530
1574
|
_ctx.virtual && {
|
|
@@ -1568,18 +1612,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1568
1612
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
|
|
1569
1613
|
return openBlock(), createElementBlock("th", {
|
|
1570
1614
|
key: col.dataIndex,
|
|
1571
|
-
"data-col-key": colKeyGen(col),
|
|
1615
|
+
"data-col-key": colKeyGen.value(col),
|
|
1572
1616
|
draggable: unref(isHeaderDraggable)(col) ? "true" : "false",
|
|
1573
1617
|
rowspan: unref(virtualX_on) ? 1 : col.rowSpan,
|
|
1574
1618
|
colspan: col.colSpan,
|
|
1575
|
-
style: normalizeStyle(cellStyleMap.value[unref(TagType).TH].get(colKeyGen(col))),
|
|
1619
|
+
style: normalizeStyle(cellStyleMap.value[unref(TagType).TH].get(colKeyGen.value(col))),
|
|
1576
1620
|
title: getHeaderTitle(col),
|
|
1577
1621
|
class: normalizeClass([
|
|
1578
1622
|
col.sorter ? "sortable" : "",
|
|
1579
1623
|
col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
|
|
1580
|
-
_ctx.showHeaderOverflow ? "text-overflow" : "",
|
|
1581
1624
|
col.headerClassName,
|
|
1582
|
-
unref(fixedColClassMap).get(colKeyGen(col))
|
|
1625
|
+
unref(fixedColClassMap).get(colKeyGen.value(col))
|
|
1583
1626
|
]),
|
|
1584
1627
|
onClick: (e) => {
|
|
1585
1628
|
onColumnSort(col);
|
|
@@ -1637,7 +1680,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1637
1680
|
_ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
|
|
1638
1681
|
return openBlock(), createElementBlock("td", {
|
|
1639
1682
|
key: col.dataIndex,
|
|
1640
|
-
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen(col)))
|
|
1683
|
+
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen.value(col)))
|
|
1641
1684
|
}, null, 4);
|
|
1642
1685
|
}), 128)) : createCommentVNode("", true)
|
|
1643
1686
|
], 4)) : createCommentVNode("", true),
|
|
@@ -1647,8 +1690,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1647
1690
|
key: _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1648
1691
|
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1649
1692
|
class: normalizeClass({
|
|
1650
|
-
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(
|
|
1651
|
-
hover: _ctx.rowKey ? rowKeyGen(row) ===
|
|
1693
|
+
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentRow.value) : row === currentRow.value,
|
|
1694
|
+
hover: props.showTrHoverClass && (_ctx.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
|
|
1652
1695
|
[_ctx.rowClassName(row, rowIndex)]: true
|
|
1653
1696
|
}),
|
|
1654
1697
|
onClick: (e) => onRowClick(e, row),
|
|
@@ -1661,14 +1704,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1661
1704
|
return openBlock(), createElementBlock("td", {
|
|
1662
1705
|
key: col.dataIndex,
|
|
1663
1706
|
"data-index": col.dataIndex,
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen(col))),
|
|
1671
|
-
onClick: (e) => onCellClick(e, row, col)
|
|
1707
|
+
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen.value(col))),
|
|
1708
|
+
class: normalizeClass([col.className, unref(fixedColClassMap).get(colKeyGen.value(col)), col.type === "seq" ? "seq-column" : ""]),
|
|
1709
|
+
onClick: (e) => onCellClick(e, row, col),
|
|
1710
|
+
onMouseenter: (e) => onCellMouseEnter(e, row, col),
|
|
1711
|
+
onMouseleave: (e) => onCellMouseLeave(e, row, col),
|
|
1712
|
+
onMouseover: (e) => onCellMouseOver(e, row, col)
|
|
1672
1713
|
}, [
|
|
1673
1714
|
col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
|
|
1674
1715
|
key: 0,
|
|
@@ -1688,7 +1729,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1688
1729
|
createTextVNode(toDisplayString(row[col.dataIndex] ?? getEmptyCellText.value(col, row)), 1)
|
|
1689
1730
|
], 64))
|
|
1690
1731
|
], 8, _hoisted_15))
|
|
1691
|
-
],
|
|
1732
|
+
], 46, _hoisted_14);
|
|
1692
1733
|
}), 128))
|
|
1693
1734
|
], 42, _hoisted_12);
|
|
1694
1735
|
}), 128)),
|