stk-table-vue 0.3.1 → 0.3.2
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 +21 -3
- package/lib/src/StkTable/StkTable.vue.d.ts +21 -4
- package/lib/stk-table-vue.js +63 -42
- package/lib/style.css +113 -114
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +73 -29
- package/src/StkTable/style.less +201 -204
- package/src/StkTable/useFixedStyle.ts +1 -1
- package/src/StkTable/useHighlight.ts +5 -4
- package/src/StkTable/useVirtualScroll.ts +11 -10
- package/src/StkTable/utils.ts +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ repo:
|
|
|
32
32
|
* [x] 排序
|
|
33
33
|
- [x] 基本表头点击排序。
|
|
34
34
|
- [x] 支持配置 `null` | `undefined` 永远排最后。
|
|
35
|
-
- [] 支持配置 string 使用 `String.prototype.localCompare` 排序。
|
|
35
|
+
- [x] 支持配置 string 使用 `String.prototype.localCompare` 排序。
|
|
36
36
|
* [x] 多级表头。
|
|
37
37
|
- [x] 支持最多`2级`表头。
|
|
38
38
|
- [x] 支持更多级表头。
|
|
@@ -45,6 +45,7 @@ repo:
|
|
|
45
45
|
* [x] vue2.7支持(引入源码使用)。
|
|
46
46
|
- [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。(`v0.2.0`)
|
|
47
47
|
* [x] 支持配置序号列。`StkTableColumn['type']`。(`v0.3.0`)
|
|
48
|
+
* [x] `props.cellHover`单元格悬浮样式。(`v0.3.2`)
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
|
|
@@ -166,6 +167,8 @@ export type StkProps = {
|
|
|
166
167
|
showOverflow?: boolean;
|
|
167
168
|
/** 是否增加行hover class */
|
|
168
169
|
showTrHoverClass?: boolean;
|
|
170
|
+
/** 是否高亮鼠标悬浮的单元格 */
|
|
171
|
+
cellHover?: boolean;
|
|
169
172
|
/** 表头是否可拖动。支持回调函数。 */
|
|
170
173
|
headerDrag?: boolean | ((col: StkTableColumn<DT>) => boolean);
|
|
171
174
|
/**
|
|
@@ -246,9 +249,9 @@ export type StkProps = {
|
|
|
246
249
|
(e: 'row-click', ev: MouseEvent, row: DT): void;
|
|
247
250
|
/**
|
|
248
251
|
* 选中一行触发。ev返回null表示不是点击事件触发的
|
|
249
|
-
* ```(ev: MouseEvent | null, row: DT)```
|
|
252
|
+
* ```(ev: MouseEvent | null, row: DT, data: { select: boolean })```
|
|
250
253
|
*/
|
|
251
|
-
(e: 'current-change', ev: MouseEvent | null, row: DT): void;
|
|
254
|
+
(e: 'current-change', ev: MouseEvent | null, row: DT, data: { select: boolean }): void;
|
|
252
255
|
/**
|
|
253
256
|
* 行双击事件
|
|
254
257
|
* ```(ev: MouseEvent, row: DT)```
|
|
@@ -269,6 +272,21 @@ export type StkProps = {
|
|
|
269
272
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
270
273
|
*/
|
|
271
274
|
(e: 'cell-click', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
275
|
+
/**
|
|
276
|
+
* 单元格鼠标进入事件
|
|
277
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
278
|
+
*/
|
|
279
|
+
(e: 'cell-mouseenter', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
280
|
+
/**
|
|
281
|
+
* 单元格鼠标移出事件
|
|
282
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
283
|
+
*/
|
|
284
|
+
(e: 'cell-mouseleave', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
285
|
+
/**
|
|
286
|
+
* 单元格悬浮事件
|
|
287
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
288
|
+
*/
|
|
289
|
+
(e: 'cell-mouseover', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
272
290
|
/**
|
|
273
291
|
* 表头单元格点击事件
|
|
274
292
|
* ```(ev: MouseEvent, col: StkTableColumn<DT>)```
|
|
@@ -3,7 +3,7 @@ import { HighlightConfig, Order, SeqConfig, SortConfig, SortOption, SortState, S
|
|
|
3
3
|
type DT = any;
|
|
4
4
|
/**
|
|
5
5
|
* 选中一行,
|
|
6
|
-
* @param {string} rowKey
|
|
6
|
+
* @param {string} rowKey selected rowKey, null to unselect
|
|
7
7
|
* @param {boolean} option.silent 是否触发回调
|
|
8
8
|
*/
|
|
9
9
|
declare function setCurrentRow(rowKey: string, option?: {
|
|
@@ -83,6 +83,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
83
83
|
showOverflow?: boolean | undefined;
|
|
84
84
|
/** 是否增加行hover class */
|
|
85
85
|
showTrHoverClass?: boolean | undefined;
|
|
86
|
+
/** 是否高亮鼠标悬浮的单元格 */
|
|
87
|
+
cellHover?: boolean | undefined;
|
|
86
88
|
/** 表头是否可拖动。支持回调函数。 */
|
|
87
89
|
headerDrag?: boolean | ((col: StkTableColumn<any>) => boolean) | undefined;
|
|
88
90
|
/**
|
|
@@ -147,6 +149,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
147
149
|
showHeaderOverflow: boolean;
|
|
148
150
|
showOverflow: boolean;
|
|
149
151
|
showTrHoverClass: boolean;
|
|
152
|
+
cellHover: boolean;
|
|
150
153
|
headerDrag: boolean;
|
|
151
154
|
rowClassName: () => "";
|
|
152
155
|
colResizable: boolean;
|
|
@@ -183,7 +186,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
183
186
|
method?: "css" | "animation" | "js" | undefined;
|
|
184
187
|
useCss?: boolean | undefined;
|
|
185
188
|
className?: string | undefined;
|
|
186
|
-
keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined;
|
|
189
|
+
keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined;
|
|
187
190
|
duration?: number | undefined;
|
|
188
191
|
}) => void;
|
|
189
192
|
/** 表格排序列dataIndex */
|
|
@@ -201,11 +204,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
201
204
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
202
205
|
"sort-change": (col: StkTableColumn<any>, order: Order, data: any[], sortConfig: SortConfig<any>) => void;
|
|
203
206
|
"row-click": (ev: MouseEvent, row: any) => void;
|
|
204
|
-
"current-change": (ev: MouseEvent | null, row: any
|
|
207
|
+
"current-change": (ev: MouseEvent | null, row: any, data: {
|
|
208
|
+
select: boolean;
|
|
209
|
+
}) => void;
|
|
205
210
|
"row-dblclick": (ev: MouseEvent, row: any) => void;
|
|
206
211
|
"header-row-menu": (ev: MouseEvent) => void;
|
|
207
212
|
"row-menu": (ev: MouseEvent, row: any) => void;
|
|
208
213
|
"cell-click": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
|
|
214
|
+
"cell-mouseenter": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
|
|
215
|
+
"cell-mouseleave": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
|
|
216
|
+
"cell-mouseover": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
|
|
209
217
|
"header-cell-click": (ev: MouseEvent, col: StkTableColumn<any>) => void;
|
|
210
218
|
scroll: (ev: Event, data: {
|
|
211
219
|
startIndex: number;
|
|
@@ -263,6 +271,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
263
271
|
showOverflow?: boolean | undefined;
|
|
264
272
|
/** 是否增加行hover class */
|
|
265
273
|
showTrHoverClass?: boolean | undefined;
|
|
274
|
+
/** 是否高亮鼠标悬浮的单元格 */
|
|
275
|
+
cellHover?: boolean | undefined;
|
|
266
276
|
/** 表头是否可拖动。支持回调函数。 */
|
|
267
277
|
headerDrag?: boolean | ((col: StkTableColumn<any>) => boolean) | undefined;
|
|
268
278
|
/**
|
|
@@ -327,6 +337,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
327
337
|
showHeaderOverflow: boolean;
|
|
328
338
|
showOverflow: boolean;
|
|
329
339
|
showTrHoverClass: boolean;
|
|
340
|
+
cellHover: boolean;
|
|
330
341
|
headerDrag: boolean;
|
|
331
342
|
rowClassName: () => "";
|
|
332
343
|
colResizable: boolean;
|
|
@@ -353,11 +364,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
353
364
|
"onTh-drop"?: ((targetColKey: string) => any) | undefined;
|
|
354
365
|
"onSort-change"?: ((col: StkTableColumn<any>, order: Order, data: any[], sortConfig: SortConfig<any>) => any) | undefined;
|
|
355
366
|
"onRow-click"?: ((ev: MouseEvent, row: any) => any) | undefined;
|
|
356
|
-
"onCurrent-change"?: ((ev: MouseEvent | null, row: any
|
|
367
|
+
"onCurrent-change"?: ((ev: MouseEvent | null, row: any, data: {
|
|
368
|
+
select: boolean;
|
|
369
|
+
}) => any) | undefined;
|
|
357
370
|
"onRow-dblclick"?: ((ev: MouseEvent, row: any) => any) | undefined;
|
|
358
371
|
"onHeader-row-menu"?: ((ev: MouseEvent) => any) | undefined;
|
|
359
372
|
"onRow-menu"?: ((ev: MouseEvent, row: any) => any) | undefined;
|
|
360
373
|
"onCell-click"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
|
|
374
|
+
"onCell-mouseenter"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
|
|
375
|
+
"onCell-mouseleave"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
|
|
376
|
+
"onCell-mouseover"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
|
|
361
377
|
"onHeader-cell-click"?: ((ev: MouseEvent, col: StkTableColumn<any>) => any) | undefined;
|
|
362
378
|
"onScroll-x"?: ((ev: Event) => any) | undefined;
|
|
363
379
|
}, {
|
|
@@ -386,6 +402,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
386
402
|
showHeaderOverflow: boolean;
|
|
387
403
|
showOverflow: boolean;
|
|
388
404
|
showTrHoverClass: boolean;
|
|
405
|
+
cellHover: boolean;
|
|
389
406
|
headerDrag: boolean | ((col: StkTableColumn<any>) => boolean);
|
|
390
407
|
rowClassName: (row: any, i: number) => string;
|
|
391
408
|
colResizable: boolean;
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -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
|
}
|
|
@@ -463,7 +463,7 @@ function useFixedStyle({
|
|
|
463
463
|
}
|
|
464
464
|
if (tagType === TagType.TH) {
|
|
465
465
|
if (IS_LEGACY_MODE) {
|
|
466
|
-
style.top = virtualScroll.value.scrollTop +
|
|
466
|
+
style.top = virtualScroll.value.scrollTop + "px";
|
|
467
467
|
} else {
|
|
468
468
|
style.top = depth * props.rowHeight + "px";
|
|
469
469
|
}
|
|
@@ -552,7 +552,7 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
552
552
|
highlightDimRowsJs.forEach((highlightStart, rowKeyValue) => {
|
|
553
553
|
const progress = (nowTs - highlightStart) / highlightDuration;
|
|
554
554
|
let bgc = "";
|
|
555
|
-
if (0
|
|
555
|
+
if (0 <= progress && progress <= 1) {
|
|
556
556
|
bgc = highlightInter.value(progress);
|
|
557
557
|
} else {
|
|
558
558
|
highlightDimRowsJs.delete(rowKeyValue);
|
|
@@ -599,11 +599,11 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
599
599
|
...defaultHighlightDimOption,
|
|
600
600
|
...option
|
|
601
601
|
};
|
|
602
|
-
const nowTs = Date.now();
|
|
603
602
|
if (method === "css" || useCss) {
|
|
604
603
|
highlightRowsInCssKeyframe(rowKeyValues, className, duration);
|
|
605
604
|
} else if (method === "animation") {
|
|
606
605
|
if (props.virtual) {
|
|
606
|
+
const nowTs = Date.now();
|
|
607
607
|
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
608
608
|
const rowKeyValue = rowKeyValues[i];
|
|
609
609
|
const store = { ts: nowTs, visible: false, keyframe, duration };
|
|
@@ -620,6 +620,7 @@ function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
} else if (method === "js") {
|
|
623
|
+
const nowTs = Date.now();
|
|
623
624
|
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
624
625
|
const rowKeyValue = rowKeyValues[i];
|
|
625
626
|
highlightDimRowsJs.set(rowKeyValue, nowTs);
|
|
@@ -848,7 +849,7 @@ function useVirtualScroll({
|
|
|
848
849
|
if (!virtual_on.value)
|
|
849
850
|
return dataSourceCopy.value;
|
|
850
851
|
const { startIndex, endIndex } = virtualScroll.value;
|
|
851
|
-
return dataSourceCopy.value.slice(startIndex, endIndex);
|
|
852
|
+
return dataSourceCopy.value.slice(startIndex, endIndex + 1);
|
|
852
853
|
});
|
|
853
854
|
const virtual_offsetBottom = computed(() => {
|
|
854
855
|
if (!virtual_on.value)
|
|
@@ -926,6 +927,8 @@ function useVirtualScroll({
|
|
|
926
927
|
function updateVirtualScrollY(sTop = 0) {
|
|
927
928
|
const { rowHeight, pageSize, scrollTop, startIndex: oldStartIndex } = virtualScroll.value;
|
|
928
929
|
virtualScroll.value.scrollTop = sTop;
|
|
930
|
+
if (!virtual_on.value)
|
|
931
|
+
return;
|
|
929
932
|
let startIndex = Math.floor(sTop / rowHeight);
|
|
930
933
|
if (props.stripe) {
|
|
931
934
|
startIndex -= 1;
|
|
@@ -941,14 +944,12 @@ function useVirtualScroll({
|
|
|
941
944
|
startIndex -= 1;
|
|
942
945
|
}
|
|
943
946
|
}
|
|
944
|
-
let endIndex = startIndex + pageSize
|
|
947
|
+
let endIndex = startIndex + pageSize;
|
|
945
948
|
if (props.stripe) {
|
|
946
|
-
endIndex +=
|
|
949
|
+
endIndex += 1;
|
|
947
950
|
}
|
|
948
951
|
const offsetTop = startIndex * rowHeight;
|
|
949
|
-
|
|
950
|
-
endIndex = dataSourceCopy.value.length;
|
|
951
|
-
}
|
|
952
|
+
endIndex = Math.min(endIndex, dataSourceCopy.value.length);
|
|
952
953
|
if (vue2ScrollYTimeout) {
|
|
953
954
|
window.clearTimeout(vue2ScrollYTimeout);
|
|
954
955
|
}
|
|
@@ -1002,9 +1003,7 @@ function useVirtualScroll({
|
|
|
1002
1003
|
break;
|
|
1003
1004
|
}
|
|
1004
1005
|
}
|
|
1005
|
-
|
|
1006
|
-
endIndex = headerLength;
|
|
1007
|
-
}
|
|
1006
|
+
endIndex = Math.min(endIndex, headerLength);
|
|
1008
1007
|
if (vue2ScrollXTimeout) {
|
|
1009
1008
|
window.clearTimeout(vue2ScrollXTimeout);
|
|
1010
1009
|
}
|
|
@@ -1078,7 +1077,7 @@ const _hoisted_13 = {
|
|
|
1078
1077
|
class: "virtual-x-left",
|
|
1079
1078
|
style: { "padding": "0" }
|
|
1080
1079
|
};
|
|
1081
|
-
const _hoisted_14 = ["data-index", "onClick"];
|
|
1080
|
+
const _hoisted_14 = ["data-index", "onClick", "onMouseenter", "onMouseleave", "onMouseover"];
|
|
1082
1081
|
const _hoisted_15 = ["title"];
|
|
1083
1082
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1084
1083
|
__name: "StkTable",
|
|
@@ -1105,6 +1104,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1105
1104
|
showHeaderOverflow: { type: Boolean, default: false },
|
|
1106
1105
|
showOverflow: { type: Boolean, default: false },
|
|
1107
1106
|
showTrHoverClass: { type: Boolean, default: false },
|
|
1107
|
+
cellHover: { type: Boolean, default: false },
|
|
1108
1108
|
headerDrag: { type: [Boolean, Function], default: false },
|
|
1109
1109
|
rowClassName: { type: Function, default: () => "" },
|
|
1110
1110
|
colResizable: { type: Boolean, default: false },
|
|
@@ -1121,16 +1121,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1121
1121
|
highlightConfig: { default: () => ({}) },
|
|
1122
1122
|
seqConfig: { default: () => ({}) }
|
|
1123
1123
|
},
|
|
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"],
|
|
1124
|
+
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
1125
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1126
1126
|
const stkTableId = createStkTableId();
|
|
1127
1127
|
const props = __props;
|
|
1128
1128
|
const emits = __emit;
|
|
1129
1129
|
const tableContainerRef = ref();
|
|
1130
1130
|
const colResizeIndicatorRef = ref();
|
|
1131
|
-
const
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1131
|
+
const currentRow = ref(null);
|
|
1132
|
+
const currentRowKey = ref(null);
|
|
1133
|
+
let currentHoverRow = null;
|
|
1134
|
+
const currentHoverRowKey = ref(null);
|
|
1134
1135
|
let sortCol = ref();
|
|
1135
1136
|
let sortOrderIndex = ref(0);
|
|
1136
1137
|
const sortSwitchOrder = [null, "desc", "asc"];
|
|
@@ -1377,11 +1378,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1377
1378
|
}
|
|
1378
1379
|
function onRowClick(e, row) {
|
|
1379
1380
|
emits("row-click", e, row);
|
|
1380
|
-
if (props.rowKey ?
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1381
|
+
if (props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row) {
|
|
1382
|
+
currentRow.value = null;
|
|
1383
|
+
currentRowKey.value = null;
|
|
1384
|
+
emits("current-change", e, row, { select: false });
|
|
1385
|
+
} else {
|
|
1386
|
+
currentRow.value = row;
|
|
1387
|
+
currentRowKey.value = rowKeyGen(row);
|
|
1388
|
+
emits("current-change", e, row, { select: true });
|
|
1389
|
+
}
|
|
1385
1390
|
}
|
|
1386
1391
|
function onRowDblclick(e, row) {
|
|
1387
1392
|
emits("row-dblclick", e, row);
|
|
@@ -1398,6 +1403,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1398
1403
|
function onHeaderCellClick(e, col) {
|
|
1399
1404
|
emits("header-cell-click", e, col);
|
|
1400
1405
|
}
|
|
1406
|
+
function onCellMouseEnter(e, row, col) {
|
|
1407
|
+
emits("cell-mouseenter", e, row, col);
|
|
1408
|
+
}
|
|
1409
|
+
function onCellMouseLeave(e, row, col) {
|
|
1410
|
+
emits("cell-mouseleave", e, row, col);
|
|
1411
|
+
}
|
|
1412
|
+
function onCellMouseOver(e, row, col) {
|
|
1413
|
+
emits("cell-mouseover", e, row, col);
|
|
1414
|
+
}
|
|
1401
1415
|
function onTableWheel(e) {
|
|
1402
1416
|
if (isColResizing.value) {
|
|
1403
1417
|
e.preventDefault();
|
|
@@ -1413,7 +1427,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1413
1427
|
const { scrollLeft: vScrollLeft } = virtualScrollX.value;
|
|
1414
1428
|
const isYScroll = scrollTop !== vScrollTop;
|
|
1415
1429
|
const isXScroll = scrollLeft !== vScrollLeft;
|
|
1416
|
-
if (isYScroll
|
|
1430
|
+
if (isYScroll) {
|
|
1417
1431
|
updateVirtualScrollY(scrollTop);
|
|
1418
1432
|
}
|
|
1419
1433
|
if (isXScroll) {
|
|
@@ -1434,17 +1448,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1434
1448
|
}
|
|
1435
1449
|
}
|
|
1436
1450
|
function onTrMouseOver(_e, row) {
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
|
|
1451
|
+
if (currentHoverRow === row)
|
|
1452
|
+
return;
|
|
1453
|
+
currentHoverRow = row;
|
|
1454
|
+
currentHoverRowKey.value = rowKeyGen(row);
|
|
1440
1455
|
}
|
|
1441
1456
|
function setCurrentRow(rowKey, option = { silent: false }) {
|
|
1442
1457
|
if (!dataSourceCopy.value.length)
|
|
1443
1458
|
return;
|
|
1444
|
-
|
|
1445
|
-
|
|
1459
|
+
currentRow.value = dataSourceCopy.value.find((it) => rowKeyGen(it) === rowKey);
|
|
1460
|
+
currentRowKey.value = rowKeyGen(currentRow.value);
|
|
1446
1461
|
if (!option.silent) {
|
|
1447
|
-
emits(
|
|
1462
|
+
emits(
|
|
1463
|
+
"current-change",
|
|
1464
|
+
/** no Event */
|
|
1465
|
+
null,
|
|
1466
|
+
currentRow.value,
|
|
1467
|
+
{ select: Boolean(currentRowKey.value) }
|
|
1468
|
+
);
|
|
1448
1469
|
}
|
|
1449
1470
|
}
|
|
1450
1471
|
function setSorter(dataIndex, order, option = {}) {
|
|
@@ -1524,7 +1545,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1524
1545
|
"border-h": props.bordered === "h",
|
|
1525
1546
|
"border-v": props.bordered === "v",
|
|
1526
1547
|
"border-body-v": props.bordered === "body-v",
|
|
1527
|
-
stripe: props.stripe
|
|
1548
|
+
stripe: props.stripe,
|
|
1549
|
+
"cell-hover": props.cellHover,
|
|
1550
|
+
"text-overflow": props.showOverflow,
|
|
1551
|
+
"header-text-overflow": props.showHeaderOverflow
|
|
1528
1552
|
}]),
|
|
1529
1553
|
style: normalizeStyle([
|
|
1530
1554
|
_ctx.virtual && {
|
|
@@ -1577,7 +1601,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1577
1601
|
class: normalizeClass([
|
|
1578
1602
|
col.sorter ? "sortable" : "",
|
|
1579
1603
|
col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
|
|
1580
|
-
_ctx.showHeaderOverflow ? "text-overflow" : "",
|
|
1581
1604
|
col.headerClassName,
|
|
1582
1605
|
unref(fixedColClassMap).get(colKeyGen(col))
|
|
1583
1606
|
]),
|
|
@@ -1647,8 +1670,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1647
1670
|
key: _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1648
1671
|
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1649
1672
|
class: normalizeClass({
|
|
1650
|
-
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(
|
|
1651
|
-
hover: _ctx.rowKey ? rowKeyGen(row) ===
|
|
1673
|
+
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentRow.value) : row === currentRow.value,
|
|
1674
|
+
hover: props.showTrHoverClass && (_ctx.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
|
|
1652
1675
|
[_ctx.rowClassName(row, rowIndex)]: true
|
|
1653
1676
|
}),
|
|
1654
1677
|
onClick: (e) => onRowClick(e, row),
|
|
@@ -1661,14 +1684,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1661
1684
|
return openBlock(), createElementBlock("td", {
|
|
1662
1685
|
key: col.dataIndex,
|
|
1663
1686
|
"data-index": col.dataIndex,
|
|
1664
|
-
class: normalizeClass([
|
|
1665
|
-
col.className,
|
|
1666
|
-
unref(fixedColClassMap).get(colKeyGen(col)),
|
|
1667
|
-
_ctx.showOverflow ? "text-overflow" : "",
|
|
1668
|
-
col.type === "seq" ? "seq-column" : ""
|
|
1669
|
-
]),
|
|
1670
1687
|
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen(col))),
|
|
1671
|
-
|
|
1688
|
+
class: normalizeClass([col.className, unref(fixedColClassMap).get(colKeyGen(col)), col.type === "seq" ? "seq-column" : ""]),
|
|
1689
|
+
onClick: (e) => onCellClick(e, row, col),
|
|
1690
|
+
onMouseenter: (e) => onCellMouseEnter(e, row, col),
|
|
1691
|
+
onMouseleave: (e) => onCellMouseLeave(e, row, col),
|
|
1692
|
+
onMouseover: (e) => onCellMouseOver(e, row, col)
|
|
1672
1693
|
}, [
|
|
1673
1694
|
col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
|
|
1674
1695
|
key: 0,
|
|
@@ -1688,7 +1709,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1688
1709
|
createTextVNode(toDisplayString(row[col.dataIndex] ?? getEmptyCellText.value(col, row)), 1)
|
|
1689
1710
|
], 64))
|
|
1690
1711
|
], 8, _hoisted_15))
|
|
1691
|
-
],
|
|
1712
|
+
], 46, _hoisted_14);
|
|
1692
1713
|
}), 128))
|
|
1693
1714
|
], 42, _hoisted_12);
|
|
1694
1715
|
}), 128)),
|