stk-table-vue 0.4.1 → 0.4.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 -28
- package/lib/src/StkTable/StkTable.vue.d.ts +82 -60
- package/lib/src/StkTable/index.d.ts +0 -1
- package/lib/src/StkTable/types/index.d.ts +29 -11
- package/lib/src/StkTable/useAutoResize.d.ts +1 -0
- package/lib/src/StkTable/useColResize.d.ts +1 -0
- package/lib/src/StkTable/useFixedCol.d.ts +1 -0
- package/lib/src/StkTable/useFixedStyle.d.ts +1 -0
- package/lib/src/StkTable/useGetFixedColPosition.d.ts +1 -0
- package/lib/src/StkTable/useHighlight.d.ts +1 -0
- package/lib/src/StkTable/useKeyboardArrowScroll.d.ts +1 -0
- package/lib/src/StkTable/useThDrag.d.ts +1 -0
- package/lib/src/StkTable/useVirtualScroll.d.ts +12 -7
- package/lib/src/StkTable/utils/index.d.ts +3 -1
- package/lib/src/StkTable/utils/useTriggerRef.d.ts +1 -0
- package/lib/stk-table-vue.js +117 -60
- package/lib/style.css +7 -7
- package/package.json +64 -64
- package/src/StkTable/StkTable.vue +79 -35
- package/src/StkTable/style.less +22 -18
- package/src/StkTable/types/index.ts +31 -10
- package/src/StkTable/useFixedCol.ts +5 -5
- package/src/StkTable/useVirtualScroll.ts +49 -10
- package/src/StkTable/utils/index.ts +2 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComputedRef, Ref, ShallowRef } from 'vue';
|
|
2
2
|
import { StkTableColumn } from './types';
|
|
3
3
|
import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
|
|
4
|
+
|
|
4
5
|
type Options<DT extends Record<string, any>> = {
|
|
5
6
|
props: any;
|
|
6
7
|
scrollTo: (y: number | null, x: number | null) => void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Ref, ShallowRef } from 'vue';
|
|
2
2
|
import { StkTableColumn } from './types';
|
|
3
|
+
|
|
3
4
|
type Option<DT extends Record<string, any>> = {
|
|
4
5
|
props: any;
|
|
5
6
|
tableContainerRef: Ref<HTMLElement | undefined>;
|
|
7
|
+
theadRef: Ref<HTMLElement | undefined>;
|
|
6
8
|
dataSourceCopy: ShallowRef<DT[]>;
|
|
7
9
|
tableHeaderLast: ShallowRef<StkTableColumn<DT>[]>;
|
|
8
10
|
tableHeaders: ShallowRef<StkTableColumn<DT>[][]>;
|
|
@@ -23,6 +25,8 @@ export type VirtualScrollStore = {
|
|
|
23
25
|
offsetTop: number;
|
|
24
26
|
/** 纵向滚动条位置,用于判断是横向滚动还是纵向 */
|
|
25
27
|
scrollTop: number;
|
|
28
|
+
/** 总滚动高度 */
|
|
29
|
+
scrollHeight: number;
|
|
26
30
|
};
|
|
27
31
|
/** 暂存横向虚拟滚动的数据 */
|
|
28
32
|
export type VirtualScrollXStore = {
|
|
@@ -44,7 +48,7 @@ export type VirtualScrollXStore = {
|
|
|
44
48
|
* @param param0
|
|
45
49
|
* @returns
|
|
46
50
|
*/
|
|
47
|
-
export declare function useVirtualScroll<DT extends Record<string, any>>({ props, tableContainerRef, dataSourceCopy, tableHeaderLast, tableHeaders, }: Option<DT>): {
|
|
51
|
+
export declare function useVirtualScroll<DT extends Record<string, any>>({ props, tableContainerRef, theadRef, dataSourceCopy, tableHeaderLast, tableHeaders, }: Option<DT>): {
|
|
48
52
|
virtualScroll: Ref<{
|
|
49
53
|
containerHeight: number;
|
|
50
54
|
pageSize: number;
|
|
@@ -53,6 +57,7 @@ export declare function useVirtualScroll<DT extends Record<string, any>>({ props
|
|
|
53
57
|
rowHeight: number;
|
|
54
58
|
offsetTop: number;
|
|
55
59
|
scrollTop: number;
|
|
60
|
+
scrollHeight: number;
|
|
56
61
|
}>;
|
|
57
62
|
virtualScrollX: Ref<{
|
|
58
63
|
containerWidth: number;
|
|
@@ -62,12 +67,12 @@ export declare function useVirtualScroll<DT extends Record<string, any>>({ props
|
|
|
62
67
|
offsetLeft: number;
|
|
63
68
|
scrollLeft: number;
|
|
64
69
|
}>;
|
|
65
|
-
virtual_on: import(
|
|
66
|
-
virtual_dataSourcePart: import(
|
|
67
|
-
virtual_offsetBottom: import(
|
|
68
|
-
virtualX_on: import(
|
|
69
|
-
virtualX_columnPart: import(
|
|
70
|
-
virtualX_offsetRight: import(
|
|
70
|
+
virtual_on: import('vue').ComputedRef<any>;
|
|
71
|
+
virtual_dataSourcePart: import('vue').ComputedRef<DT[]>;
|
|
72
|
+
virtual_offsetBottom: import('vue').ComputedRef<number>;
|
|
73
|
+
virtualX_on: import('vue').ComputedRef<any>;
|
|
74
|
+
virtualX_columnPart: import('vue').ComputedRef<StkTableColumn<DT>[]>;
|
|
75
|
+
virtualX_offsetRight: import('vue').ComputedRef<number>;
|
|
71
76
|
initVirtualScroll: (height?: number) => void;
|
|
72
77
|
initVirtualScrollY: (height?: number) => void;
|
|
73
78
|
initVirtualScrollX: () => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Order, SortConfig, SortOption, SortState, StkTableColumn } from '../types';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* 对有序数组插入新数据
|
|
4
5
|
* @param sortState
|
|
@@ -7,8 +8,9 @@ import { Order, SortConfig, SortOption, SortState, StkTableColumn } from '../typ
|
|
|
7
8
|
* @param sortState.sortType 排序方式
|
|
8
9
|
* @param newItem 要插入的数据
|
|
9
10
|
* @param targetArray 表格数据
|
|
11
|
+
* @return targetArray 的浅拷贝
|
|
10
12
|
*/
|
|
11
|
-
export declare function insertToOrderedArray<T extends object>(sortState: SortState<
|
|
13
|
+
export declare function insertToOrderedArray<T extends object>(sortState: SortState<T>, newItem: any, targetArray: T[], sortConfig?: SortConfig<T>): T[];
|
|
12
14
|
/**
|
|
13
15
|
* 表格排序抽离
|
|
14
16
|
* 可以在组件外部自己实现表格排序,组件配置remote,使表格不排序。
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -400,11 +400,19 @@ function useFixedCol({
|
|
|
400
400
|
const fixedShadowColsTemp = [];
|
|
401
401
|
let clientWidth, scrollLeft;
|
|
402
402
|
if (virtualScrollX == null ? void 0 : virtualScrollX.value) {
|
|
403
|
-
const {
|
|
403
|
+
const {
|
|
404
|
+
containerWidth: cw,
|
|
405
|
+
/* scrollWidth: sw, */
|
|
406
|
+
scrollLeft: sl
|
|
407
|
+
} = virtualScrollX.value;
|
|
404
408
|
clientWidth = cw;
|
|
405
409
|
scrollLeft = sl;
|
|
406
410
|
} else {
|
|
407
|
-
const {
|
|
411
|
+
const {
|
|
412
|
+
clientWidth: cw,
|
|
413
|
+
/* scrollWidth: sw, */
|
|
414
|
+
scrollLeft: sl
|
|
415
|
+
} = tableContainerRef.value;
|
|
408
416
|
clientWidth = cw;
|
|
409
417
|
scrollLeft = sl;
|
|
410
418
|
}
|
|
@@ -852,10 +860,12 @@ const VUE2_SCROLL_TIMEOUT_MS = 200;
|
|
|
852
860
|
function useVirtualScroll({
|
|
853
861
|
props,
|
|
854
862
|
tableContainerRef,
|
|
863
|
+
theadRef,
|
|
855
864
|
dataSourceCopy,
|
|
856
865
|
tableHeaderLast,
|
|
857
866
|
tableHeaders
|
|
858
867
|
}) {
|
|
868
|
+
const tableHeaderHeight = ref(props.headerRowHeight ?? props.rowHeight);
|
|
859
869
|
const virtualScroll = ref({
|
|
860
870
|
containerHeight: 0,
|
|
861
871
|
rowHeight: props.rowHeight,
|
|
@@ -863,7 +873,8 @@ function useVirtualScroll({
|
|
|
863
873
|
startIndex: 0,
|
|
864
874
|
endIndex: 0,
|
|
865
875
|
offsetTop: 0,
|
|
866
|
-
scrollTop: 0
|
|
876
|
+
scrollTop: 0,
|
|
877
|
+
scrollHeight: 0
|
|
867
878
|
});
|
|
868
879
|
const virtualScrollX = ref({
|
|
869
880
|
containerWidth: 0,
|
|
@@ -925,23 +936,35 @@ function useVirtualScroll({
|
|
|
925
936
|
}
|
|
926
937
|
return width;
|
|
927
938
|
});
|
|
939
|
+
function getTableHeaderHeight() {
|
|
940
|
+
const { headerRowHeight } = props;
|
|
941
|
+
return headerRowHeight * tableHeaders.value.length;
|
|
942
|
+
}
|
|
928
943
|
function initVirtualScrollY(height) {
|
|
944
|
+
var _a;
|
|
929
945
|
if (height !== void 0 && typeof height !== "number") {
|
|
930
946
|
console.warn("initVirtualScrollY: height must be a number");
|
|
931
947
|
height = 0;
|
|
932
948
|
}
|
|
933
949
|
if (!virtual_on.value)
|
|
934
950
|
return;
|
|
935
|
-
const { offsetHeight,
|
|
951
|
+
const { offsetHeight, scrollHeight } = tableContainerRef.value || {};
|
|
952
|
+
let scrollTop = ((_a = tableContainerRef.value) == null ? void 0 : _a.scrollTop) || 0;
|
|
936
953
|
const { rowHeight } = virtualScroll.value;
|
|
937
954
|
const containerHeight = height || offsetHeight || DEFAULT_TABLE_HEIGHT;
|
|
938
|
-
const { headless
|
|
955
|
+
const { headless } = props;
|
|
939
956
|
let pageSize = Math.ceil(containerHeight / rowHeight);
|
|
957
|
+
const headerHeight = getTableHeaderHeight();
|
|
958
|
+
tableHeaderHeight.value = headerHeight;
|
|
940
959
|
if (!headless) {
|
|
941
|
-
const headerToBodyRowHeightCount = Math.floor(
|
|
960
|
+
const headerToBodyRowHeightCount = Math.floor(headerHeight) / rowHeight;
|
|
942
961
|
pageSize -= headerToBodyRowHeightCount;
|
|
943
962
|
}
|
|
944
|
-
|
|
963
|
+
const maxScrollTop = dataSourceCopy.value.length * rowHeight + tableHeaderHeight.value - containerHeight;
|
|
964
|
+
if (scrollTop > maxScrollTop) {
|
|
965
|
+
scrollTop = maxScrollTop;
|
|
966
|
+
}
|
|
967
|
+
Object.assign(virtualScroll.value, { containerHeight, pageSize, scrollHeight });
|
|
945
968
|
updateVirtualScrollY(scrollTop);
|
|
946
969
|
}
|
|
947
970
|
function initVirtualScrollX() {
|
|
@@ -958,8 +981,9 @@ function useVirtualScroll({
|
|
|
958
981
|
function updateVirtualScrollY(sTop = 0) {
|
|
959
982
|
const { rowHeight, pageSize, scrollTop, startIndex: oldStartIndex } = virtualScroll.value;
|
|
960
983
|
virtualScroll.value.scrollTop = sTop;
|
|
961
|
-
if (!virtual_on.value)
|
|
984
|
+
if (!virtual_on.value) {
|
|
962
985
|
return;
|
|
986
|
+
}
|
|
963
987
|
let startIndex = Math.floor(sTop / rowHeight);
|
|
964
988
|
if (startIndex < 0) {
|
|
965
989
|
startIndex = 0;
|
|
@@ -974,11 +998,14 @@ function useVirtualScroll({
|
|
|
974
998
|
if (props.stripe) {
|
|
975
999
|
endIndex += 1;
|
|
976
1000
|
}
|
|
977
|
-
const offsetTop = startIndex * rowHeight;
|
|
978
1001
|
endIndex = Math.min(endIndex, dataSourceCopy.value.length);
|
|
1002
|
+
if (startIndex >= endIndex) {
|
|
1003
|
+
startIndex = endIndex - pageSize;
|
|
1004
|
+
}
|
|
979
1005
|
if (vue2ScrollYTimeout) {
|
|
980
1006
|
window.clearTimeout(vue2ScrollYTimeout);
|
|
981
1007
|
}
|
|
1008
|
+
const offsetTop = startIndex * rowHeight;
|
|
982
1009
|
if (!props.optimizeVue2Scroll || sTop <= scrollTop || Math.abs(oldStartIndex - startIndex) >= pageSize) {
|
|
983
1010
|
Object.assign(virtualScroll.value, {
|
|
984
1011
|
startIndex,
|
|
@@ -1062,19 +1089,18 @@ function useVirtualScroll({
|
|
|
1062
1089
|
updateVirtualScrollX
|
|
1063
1090
|
};
|
|
1064
1091
|
}
|
|
1065
|
-
const _hoisted_1 =
|
|
1066
|
-
const _hoisted_2 =
|
|
1067
|
-
const _hoisted_3 = {
|
|
1068
|
-
const _hoisted_4 = {
|
|
1092
|
+
const _hoisted_1 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
1093
|
+
const _hoisted_2 = { class: "table-header-cell-wrapper" };
|
|
1094
|
+
const _hoisted_3 = {
|
|
1069
1095
|
key: 1,
|
|
1070
1096
|
class: "table-header-title"
|
|
1071
1097
|
};
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1098
|
+
const _hoisted_4 = { class: "table-header-title" };
|
|
1099
|
+
const _hoisted_5 = {
|
|
1074
1100
|
key: 3,
|
|
1075
1101
|
class: "table-header-sorter"
|
|
1076
1102
|
};
|
|
1077
|
-
const
|
|
1103
|
+
const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
|
|
1078
1104
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1079
1105
|
width: "16px",
|
|
1080
1106
|
height: "16px",
|
|
@@ -1091,28 +1117,28 @@ const _hoisted_7 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
1091
1117
|
points: "8 10 4.8 14 11.2 14"
|
|
1092
1118
|
})
|
|
1093
1119
|
], -1);
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1120
|
+
const _hoisted_7 = [
|
|
1121
|
+
_hoisted_6
|
|
1096
1122
|
];
|
|
1123
|
+
const _hoisted_8 = ["onMousedown"];
|
|
1097
1124
|
const _hoisted_9 = ["onMousedown"];
|
|
1098
|
-
const _hoisted_10 =
|
|
1099
|
-
const _hoisted_11 = {
|
|
1125
|
+
const _hoisted_10 = {
|
|
1100
1126
|
key: 1,
|
|
1101
1127
|
class: "virtual-top"
|
|
1102
1128
|
};
|
|
1103
|
-
const
|
|
1129
|
+
const _hoisted_11 = {
|
|
1104
1130
|
key: 0,
|
|
1105
1131
|
class: "virtual-x-left"
|
|
1106
1132
|
};
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1109
|
-
const
|
|
1133
|
+
const _hoisted_12 = { class: "stk-tbody-main" };
|
|
1134
|
+
const _hoisted_13 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
|
|
1135
|
+
const _hoisted_14 = {
|
|
1110
1136
|
key: 0,
|
|
1111
1137
|
class: "virtual-x-left"
|
|
1112
1138
|
};
|
|
1113
|
-
const
|
|
1114
|
-
const
|
|
1115
|
-
const
|
|
1139
|
+
const _hoisted_15 = ["data-index", "onClick", "onMouseenter", "onMouseleave", "onMouseover"];
|
|
1140
|
+
const _hoisted_16 = ["title"];
|
|
1141
|
+
const _hoisted_17 = {
|
|
1116
1142
|
key: 2,
|
|
1117
1143
|
class: "virtual-bottom"
|
|
1118
1144
|
};
|
|
@@ -1127,6 +1153,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1127
1153
|
headless: { type: Boolean, default: false },
|
|
1128
1154
|
theme: { default: "light" },
|
|
1129
1155
|
rowHeight: { default: DEFAULT_ROW_HEIGHT },
|
|
1156
|
+
rowHover: { type: Boolean, default: true },
|
|
1157
|
+
rowActive: { type: Boolean, default: true },
|
|
1158
|
+
rowCurrentRevokable: { type: Boolean, default: true },
|
|
1130
1159
|
headerRowHeight: { default: null },
|
|
1131
1160
|
virtual: { type: Boolean, default: false },
|
|
1132
1161
|
virtualX: { type: Boolean, default: false },
|
|
@@ -1165,9 +1194,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1165
1194
|
const props = __props;
|
|
1166
1195
|
const emits = __emit;
|
|
1167
1196
|
const tableContainerRef = ref();
|
|
1197
|
+
const theadRef = ref();
|
|
1168
1198
|
const colResizeIndicatorRef = ref();
|
|
1169
1199
|
const isRelativeMode = ref(IS_LEGACY_MODE ? true : props.cellFixedMode === "relative");
|
|
1170
|
-
const currentRow =
|
|
1200
|
+
const currentRow = shallowRef();
|
|
1171
1201
|
const currentRowKey = ref(null);
|
|
1172
1202
|
let currentHoverRow = null;
|
|
1173
1203
|
const currentHoverRowKey = ref(null);
|
|
@@ -1215,7 +1245,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1215
1245
|
initVirtualScrollX,
|
|
1216
1246
|
updateVirtualScrollY,
|
|
1217
1247
|
updateVirtualScrollX
|
|
1218
|
-
} = useVirtualScroll({ tableContainerRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
|
|
1248
|
+
} = useVirtualScroll({ tableContainerRef, theadRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
|
|
1219
1249
|
const getFixedColPosition = useGetFixedColPosition({ colKeyGen, tableHeaders });
|
|
1220
1250
|
const getFixedStyle = useFixedStyle({
|
|
1221
1251
|
props,
|
|
@@ -1278,8 +1308,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1278
1308
|
needInitVirtualScrollY = true;
|
|
1279
1309
|
}
|
|
1280
1310
|
dataSourceCopy.value = [...val];
|
|
1281
|
-
if (needInitVirtualScrollY)
|
|
1282
|
-
initVirtualScrollY();
|
|
1311
|
+
if (needInitVirtualScrollY) {
|
|
1312
|
+
nextTick(() => initVirtualScrollY());
|
|
1313
|
+
}
|
|
1283
1314
|
if (sortCol.value) {
|
|
1284
1315
|
const column = tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
|
|
1285
1316
|
onColumnSort(column, false);
|
|
@@ -1372,10 +1403,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1372
1403
|
}
|
|
1373
1404
|
function rowKeyGen(row) {
|
|
1374
1405
|
if (!row)
|
|
1375
|
-
return;
|
|
1406
|
+
return row;
|
|
1376
1407
|
let key = rowKeyGenStore.get(row);
|
|
1377
1408
|
if (!key) {
|
|
1378
1409
|
key = typeof props.rowKey === "function" ? props.rowKey(row) : row[props.rowKey];
|
|
1410
|
+
if (key === void 0) {
|
|
1411
|
+
key = Math.random().toString();
|
|
1412
|
+
}
|
|
1379
1413
|
rowKeyGenStore.set(row, key);
|
|
1380
1414
|
}
|
|
1381
1415
|
return key;
|
|
@@ -1448,9 +1482,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1448
1482
|
}
|
|
1449
1483
|
function onRowClick(e, row) {
|
|
1450
1484
|
emits("row-click", e, row);
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1485
|
+
const isCurrentRow = props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row;
|
|
1486
|
+
if (isCurrentRow) {
|
|
1487
|
+
if (!props.rowCurrentRevokable) {
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
currentRow.value = void 0;
|
|
1491
|
+
currentRowKey.value = void 0;
|
|
1454
1492
|
emits("current-change", e, row, { select: false });
|
|
1455
1493
|
} else {
|
|
1456
1494
|
currentRow.value = row;
|
|
@@ -1483,7 +1521,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1483
1521
|
emits("cell-mouseover", e, row, col);
|
|
1484
1522
|
}
|
|
1485
1523
|
function onTableWheel(e) {
|
|
1486
|
-
e.preventDefault();
|
|
1487
1524
|
if (isColResizing.value) {
|
|
1488
1525
|
e.stopPropagation();
|
|
1489
1526
|
return;
|
|
@@ -1491,11 +1528,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1491
1528
|
const dom = tableContainerRef.value;
|
|
1492
1529
|
if (!dom)
|
|
1493
1530
|
return;
|
|
1531
|
+
const { containerHeight, scrollTop, scrollHeight, rowHeight } = virtualScroll.value;
|
|
1532
|
+
const { containerWidth, scrollLeft, scrollWidth } = virtualScrollX.value;
|
|
1533
|
+
const isScrollBottom = scrollHeight - containerHeight - scrollTop < rowHeight;
|
|
1534
|
+
const isScrollRight = scrollWidth - containerWidth - scrollLeft < 100;
|
|
1494
1535
|
const { deltaY, deltaX } = e;
|
|
1495
|
-
if (deltaY)
|
|
1536
|
+
if (virtual_on && deltaY) {
|
|
1537
|
+
if (deltaY > 0 && !isScrollBottom || deltaY < 0 && scrollTop > 0) {
|
|
1538
|
+
e.preventDefault();
|
|
1539
|
+
}
|
|
1496
1540
|
dom.scrollTop += deltaY;
|
|
1497
|
-
|
|
1541
|
+
}
|
|
1542
|
+
if (virtualX_on && deltaX) {
|
|
1543
|
+
if (deltaX > 0 && !isScrollRight || deltaX < 0 && scrollLeft > 0) {
|
|
1544
|
+
e.preventDefault();
|
|
1545
|
+
}
|
|
1498
1546
|
dom.scrollLeft += deltaX;
|
|
1547
|
+
}
|
|
1499
1548
|
}
|
|
1500
1549
|
function onTableScroll(e) {
|
|
1501
1550
|
if (!(e == null ? void 0 : e.target))
|
|
@@ -1561,7 +1610,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1561
1610
|
return dataSourceCopy.value;
|
|
1562
1611
|
}
|
|
1563
1612
|
function resetSorter() {
|
|
1564
|
-
sortCol.value =
|
|
1613
|
+
sortCol.value = void 0;
|
|
1565
1614
|
sortOrderIndex.value = 0;
|
|
1566
1615
|
dataSourceCopy.value = [...props.dataSource];
|
|
1567
1616
|
}
|
|
@@ -1625,6 +1674,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1625
1674
|
"border-body-v": props.bordered === "body-v",
|
|
1626
1675
|
stripe: props.stripe,
|
|
1627
1676
|
"cell-hover": props.cellHover,
|
|
1677
|
+
"row-hover": props.rowHover,
|
|
1678
|
+
"row-active": props.rowActive,
|
|
1628
1679
|
"text-overflow": props.showOverflow,
|
|
1629
1680
|
"header-text-overflow": props.showHeaderOverflow,
|
|
1630
1681
|
"fixed-relative-mode": isRelativeMode.value
|
|
@@ -1650,7 +1701,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1650
1701
|
}]),
|
|
1651
1702
|
style: normalizeStyle({ width: _ctx.width, minWidth: _ctx.minWidth, maxWidth: _ctx.maxWidth })
|
|
1652
1703
|
}, [
|
|
1653
|
-
!_ctx.headless ? (openBlock(), createElementBlock("thead",
|
|
1704
|
+
!_ctx.headless ? (openBlock(), createElementBlock("thead", {
|
|
1705
|
+
key: 0,
|
|
1706
|
+
ref_key: "theadRef",
|
|
1707
|
+
ref: theadRef
|
|
1708
|
+
}, [
|
|
1654
1709
|
(openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
|
|
1655
1710
|
return openBlock(), createElementBlock("tr", {
|
|
1656
1711
|
key: rowIndex,
|
|
@@ -1690,29 +1745,31 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1690
1745
|
onDragover: _cache[2] || (_cache[2] = //@ts-ignore
|
|
1691
1746
|
(...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
|
|
1692
1747
|
}, [
|
|
1693
|
-
createElementVNode("div",
|
|
1748
|
+
createElementVNode("div", _hoisted_2, [
|
|
1694
1749
|
col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
|
|
1695
1750
|
key: 0,
|
|
1696
|
-
col
|
|
1697
|
-
|
|
1751
|
+
col,
|
|
1752
|
+
colIndex,
|
|
1753
|
+
rowIndex
|
|
1754
|
+
}, null, 8, ["col", "colIndex", "rowIndex"])) : col.type === "seq" ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(col.title), 1)) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1698
1755
|
key: 2,
|
|
1699
1756
|
col
|
|
1700
1757
|
}, () => [
|
|
1701
|
-
createElementVNode("span",
|
|
1758
|
+
createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
|
|
1702
1759
|
]),
|
|
1703
|
-
col.sorter ? (openBlock(), createElementBlock("span",
|
|
1760
|
+
col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true),
|
|
1704
1761
|
_ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
1705
1762
|
key: 4,
|
|
1706
1763
|
class: "table-header-resizer left",
|
|
1707
1764
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
|
|
1708
|
-
}, null, 40,
|
|
1765
|
+
}, null, 40, _hoisted_8)) : createCommentVNode("", true),
|
|
1709
1766
|
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1710
1767
|
key: 5,
|
|
1711
1768
|
class: "table-header-resizer right",
|
|
1712
1769
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
|
|
1713
|
-
}, null, 40,
|
|
1770
|
+
}, null, 40, _hoisted_9)) : createCommentVNode("", true)
|
|
1714
1771
|
])
|
|
1715
|
-
], 46,
|
|
1772
|
+
], 46, _hoisted_1);
|
|
1716
1773
|
}), 128)),
|
|
1717
1774
|
unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
|
|
1718
1775
|
key: 1,
|
|
@@ -1724,13 +1781,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1724
1781
|
}, null, 4)) : createCommentVNode("", true)
|
|
1725
1782
|
], 32);
|
|
1726
1783
|
}), 128))
|
|
1727
|
-
])) : createCommentVNode("", true),
|
|
1728
|
-
unref(virtual_on) ? (openBlock(), createElementBlock("tbody",
|
|
1784
|
+
], 512)) : createCommentVNode("", true),
|
|
1785
|
+
unref(virtual_on) ? (openBlock(), createElementBlock("tbody", _hoisted_10, [
|
|
1729
1786
|
createElementVNode("tr", {
|
|
1730
1787
|
style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
|
|
1731
1788
|
class: "padding-top-tr"
|
|
1732
1789
|
}, [
|
|
1733
|
-
unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td",
|
|
1790
|
+
unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_11)) : createCommentVNode("", true),
|
|
1734
1791
|
_ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
|
|
1735
1792
|
return openBlock(), createElementBlock("td", {
|
|
1736
1793
|
key: col.dataIndex,
|
|
@@ -1739,7 +1796,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1739
1796
|
}), 128)) : createCommentVNode("", true)
|
|
1740
1797
|
], 4)
|
|
1741
1798
|
])) : createCommentVNode("", true),
|
|
1742
|
-
createElementVNode("tbody",
|
|
1799
|
+
createElementVNode("tbody", _hoisted_12, [
|
|
1743
1800
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
|
|
1744
1801
|
return openBlock(), createElementBlock("tr", {
|
|
1745
1802
|
id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : rowIndex),
|
|
@@ -1755,7 +1812,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1755
1812
|
onContextmenu: (e) => onRowMenu(e, row),
|
|
1756
1813
|
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1757
1814
|
}, [
|
|
1758
|
-
unref(virtualX_on) ? (openBlock(), createElementBlock("td",
|
|
1815
|
+
unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_14)) : createCommentVNode("", true),
|
|
1759
1816
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col, colIndex) => {
|
|
1760
1817
|
return openBlock(), createElementBlock("td", {
|
|
1761
1818
|
key: col.dataIndex,
|
|
@@ -1773,24 +1830,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1773
1830
|
row,
|
|
1774
1831
|
rowIndex,
|
|
1775
1832
|
colIndex,
|
|
1776
|
-
cellValue: row[col.dataIndex]
|
|
1833
|
+
cellValue: row == null ? void 0 : row[col.dataIndex]
|
|
1777
1834
|
}, null, 8, ["col", "row", "rowIndex", "colIndex", "cellValue"])) : (openBlock(), createElementBlock("div", {
|
|
1778
1835
|
key: 1,
|
|
1779
1836
|
class: "table-cell-wrapper",
|
|
1780
|
-
title: !col.type ? row[col.dataIndex] : ""
|
|
1837
|
+
title: !col.type ? row == null ? void 0 : row[col.dataIndex] : ""
|
|
1781
1838
|
}, [
|
|
1782
1839
|
col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1783
1840
|
createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + rowIndex + 1), 1)
|
|
1784
1841
|
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1785
|
-
createTextVNode(toDisplayString(row[col.dataIndex] ?? getEmptyCellText.value(col, row)), 1)
|
|
1842
|
+
createTextVNode(toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? getEmptyCellText.value(col, row)), 1)
|
|
1786
1843
|
], 64))
|
|
1787
|
-
], 8,
|
|
1788
|
-
], 46,
|
|
1844
|
+
], 8, _hoisted_16))
|
|
1845
|
+
], 46, _hoisted_15);
|
|
1789
1846
|
}), 128))
|
|
1790
|
-
], 42,
|
|
1847
|
+
], 42, _hoisted_13);
|
|
1791
1848
|
}), 128))
|
|
1792
1849
|
]),
|
|
1793
|
-
unref(virtual_on) ? (openBlock(), createElementBlock("tbody",
|
|
1850
|
+
unref(virtual_on) ? (openBlock(), createElementBlock("tbody", _hoisted_17, [
|
|
1794
1851
|
createElementVNode("tr", {
|
|
1795
1852
|
style: normalizeStyle({ height: `${unref(virtual_offsetBottom)}px` })
|
|
1796
1853
|
}, null, 4)
|
package/lib/style.css
CHANGED
|
@@ -94,6 +94,12 @@
|
|
|
94
94
|
.stk-table.stripe tbody tr:nth-child(even){
|
|
95
95
|
background-color:var(--stripe-bgc);
|
|
96
96
|
}
|
|
97
|
+
.stk-table.row-hover tbody tr:hover{
|
|
98
|
+
background-color:var(--tr-hover-bgc);
|
|
99
|
+
}
|
|
100
|
+
.stk-table.row-active tbody tr.active{
|
|
101
|
+
background-color:var(--tr-active-bgc);
|
|
102
|
+
}
|
|
97
103
|
.stk-table.cell-hover tbody td:hover{
|
|
98
104
|
box-shadow:inset 0 0 0 2px var(--td-hover-color);
|
|
99
105
|
}
|
|
@@ -177,16 +183,10 @@
|
|
|
177
183
|
background-color:var(--th-bgc);
|
|
178
184
|
height:var(--header-row-height);
|
|
179
185
|
}
|
|
180
|
-
.stk-table
|
|
186
|
+
.stk-table tbody tr{
|
|
181
187
|
background-color:var(--td-bgc);
|
|
182
188
|
height:var(--row-height);
|
|
183
189
|
}
|
|
184
|
-
.stk-table .stk-table-main tbody tr:hover{
|
|
185
|
-
background-color:var(--tr-hover-bgc);
|
|
186
|
-
}
|
|
187
|
-
.stk-table .stk-table-main tbody tr.active{
|
|
188
|
-
background-color:var(--tr-active-bgc);
|
|
189
|
-
}
|
|
190
190
|
.stk-table .virtual-x-left,
|
|
191
191
|
.stk-table .virtual-x-right{
|
|
192
192
|
padding:0;
|