stk-table-vue 0.2.9 → 0.3.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.
- package/README.md +79 -7
- package/lib/src/StkTable/StkTable.vue.d.ts +16 -3
- package/lib/src/StkTable/const.d.ts +2 -1
- package/lib/src/StkTable/types/index.d.ts +13 -12
- package/lib/src/StkTable/useAutoResize.d.ts +2 -2
- package/lib/src/StkTable/useColResize.d.ts +5 -5
- package/lib/src/StkTable/useFixedCol.d.ts +5 -5
- package/lib/src/StkTable/useFixedStyle.d.ts +3 -3
- package/lib/src/StkTable/useHighlight.d.ts +11 -11
- package/lib/src/StkTable/useKeyboardArrowScroll.d.ts +4 -3
- package/lib/src/StkTable/useVirtualScroll.d.ts +4 -4
- package/lib/src/StkTable/utils.d.ts +11 -3
- package/lib/stk-table-vue.js +317 -187
- package/lib/style.css +7 -2
- package/package.json +4 -5
- package/src/StkTable/StkTable.vue +70 -43
- package/src/StkTable/const.ts +3 -1
- package/src/StkTable/style.less +10 -6
- package/src/StkTable/types/index.ts +14 -6
- package/src/StkTable/useAutoResize.ts +5 -5
- package/src/StkTable/useColResize.ts +18 -18
- package/src/StkTable/useFixedCol.ts +6 -6
- package/src/StkTable/useFixedStyle.ts +11 -8
- package/src/StkTable/useHighlight.ts +252 -107
- package/src/StkTable/useKeyboardArrowScroll.ts +19 -7
- package/src/StkTable/useVirtualScroll.ts +14 -11
- package/src/StkTable/utils.ts +27 -9
- package/src/vite-env.d.ts +4 -0
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,
|
|
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";
|
|
2
2
|
import { interpolateRgb } from "d3-interpolate";
|
|
3
3
|
const DEFAULT_COL_WIDTH = "100";
|
|
4
4
|
const DEFAULT_TABLE_HEIGHT = 100;
|
|
@@ -9,7 +9,7 @@ const HIGHLIGHT_COLOR = {
|
|
|
9
9
|
dark: { from: "#1e4c99", to: "#181c21" }
|
|
10
10
|
};
|
|
11
11
|
const HIGHLIGHT_DURATION = 2e3;
|
|
12
|
-
const HIGHLIGHT_FREQ =
|
|
12
|
+
const HIGHLIGHT_FREQ = 1e3 / 30;
|
|
13
13
|
const HIGHLIGHT_ROW_CLASS = "highlight-row";
|
|
14
14
|
const HIGHLIGHT_CELL_CLASS = "highlight-cell";
|
|
15
15
|
let _chromeVersion = 0;
|
|
@@ -22,12 +22,13 @@ try {
|
|
|
22
22
|
console.error("Cannot get Chrome version", e);
|
|
23
23
|
}
|
|
24
24
|
const IS_LEGACY_MODE = _chromeVersion < 56;
|
|
25
|
+
const STK_ID_PREFIX = "stk";
|
|
25
26
|
var TagType = /* @__PURE__ */ ((TagType2) => {
|
|
26
27
|
TagType2[TagType2["TH"] = 0] = "TH";
|
|
27
28
|
TagType2[TagType2["TD"] = 1] = "TD";
|
|
28
29
|
return TagType2;
|
|
29
30
|
})(TagType || {});
|
|
30
|
-
function useAutoResize({
|
|
31
|
+
function useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs }) {
|
|
31
32
|
let resizeObserver = null;
|
|
32
33
|
onMounted(() => {
|
|
33
34
|
initResizeObserver();
|
|
@@ -37,9 +38,9 @@ function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs })
|
|
|
37
38
|
});
|
|
38
39
|
function initResizeObserver() {
|
|
39
40
|
if (window.ResizeObserver) {
|
|
40
|
-
if (!
|
|
41
|
+
if (!tableContainerRef.value) {
|
|
41
42
|
const watchDom = watch(
|
|
42
|
-
() =>
|
|
43
|
+
() => tableContainerRef,
|
|
43
44
|
() => {
|
|
44
45
|
initResizeObserver();
|
|
45
46
|
watchDom();
|
|
@@ -48,7 +49,7 @@ function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs })
|
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
resizeObserver = new ResizeObserver(resizeCallback);
|
|
51
|
-
resizeObserver.observe(
|
|
52
|
+
resizeObserver.observe(tableContainerRef.value);
|
|
52
53
|
} else {
|
|
53
54
|
window.addEventListener("resize", resizeCallback);
|
|
54
55
|
}
|
|
@@ -199,23 +200,32 @@ function howDeepTheHeader(arr, level = 1) {
|
|
|
199
200
|
return Math.max(...levels);
|
|
200
201
|
}
|
|
201
202
|
function getColWidth(col) {
|
|
202
|
-
const val = (col == null ? void 0 : col.width) ?? DEFAULT_COL_WIDTH;
|
|
203
|
+
const val = (col == null ? void 0 : col.minWidth) ?? (col == null ? void 0 : col.width) ?? DEFAULT_COL_WIDTH;
|
|
203
204
|
if (typeof val === "number") {
|
|
204
205
|
return Math.floor(val);
|
|
205
206
|
}
|
|
206
207
|
return parseInt(val);
|
|
207
208
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
function getCalculatedColWidth(col) {
|
|
210
|
+
return (col == null ? void 0 : col.__WIDTH__) ?? +DEFAULT_COL_WIDTH;
|
|
211
|
+
}
|
|
212
|
+
function transformWidthToStr(width) {
|
|
213
|
+
if (typeof width === "number") {
|
|
214
|
+
return width + "px";
|
|
215
|
+
}
|
|
216
|
+
return width;
|
|
217
|
+
}
|
|
218
|
+
function createStkTableId() {
|
|
219
|
+
if (!window.__STK_TB_ID_COUNT__) {
|
|
220
|
+
window.__STK_TB_ID_COUNT__ = 0;
|
|
212
221
|
}
|
|
213
|
-
|
|
222
|
+
window.__STK_TB_ID_COUNT__ += 1;
|
|
223
|
+
return STK_ID_PREFIX + window.__STK_TB_ID_COUNT__.toString(36);
|
|
214
224
|
}
|
|
215
225
|
function useColResize({
|
|
216
|
-
|
|
226
|
+
tableContainerRef,
|
|
217
227
|
tableHeaderLast,
|
|
218
|
-
|
|
228
|
+
colResizeIndicatorRef,
|
|
219
229
|
props,
|
|
220
230
|
emits,
|
|
221
231
|
colKeyGen
|
|
@@ -243,13 +253,13 @@ function useColResize({
|
|
|
243
253
|
window.removeEventListener("mouseup", onThResizeMouseUp);
|
|
244
254
|
}
|
|
245
255
|
function onThResizeMouseDown(e, col, isPrev = false) {
|
|
246
|
-
if (!
|
|
256
|
+
if (!tableContainerRef.value)
|
|
247
257
|
return;
|
|
248
258
|
e.stopPropagation();
|
|
249
259
|
e.preventDefault();
|
|
250
260
|
const { clientX } = e;
|
|
251
|
-
const { scrollLeft, scrollTop } =
|
|
252
|
-
const { left } =
|
|
261
|
+
const { scrollLeft, scrollTop } = tableContainerRef.value;
|
|
262
|
+
const { left } = tableContainerRef.value.getBoundingClientRect();
|
|
253
263
|
let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen(it) === colKeyGen(col));
|
|
254
264
|
if (isPrev) {
|
|
255
265
|
colIndex -= 1;
|
|
@@ -264,8 +274,8 @@ function useColResize({
|
|
|
264
274
|
startX: clientX,
|
|
265
275
|
startOffsetTableX: offsetTableX
|
|
266
276
|
});
|
|
267
|
-
if (
|
|
268
|
-
const style =
|
|
277
|
+
if (colResizeIndicatorRef.value) {
|
|
278
|
+
const style = colResizeIndicatorRef.value.style;
|
|
269
279
|
style.display = "block";
|
|
270
280
|
style.left = offsetTableX + "px";
|
|
271
281
|
style.top = scrollTop + "px";
|
|
@@ -279,14 +289,14 @@ function useColResize({
|
|
|
279
289
|
const { lastCol, startX, startOffsetTableX } = colResizeState;
|
|
280
290
|
const { clientX } = e;
|
|
281
291
|
let moveX = clientX - startX;
|
|
282
|
-
const currentColWidth =
|
|
292
|
+
const currentColWidth = getCalculatedColWidth(lastCol);
|
|
283
293
|
if (currentColWidth + moveX < props.colMinWidth) {
|
|
284
294
|
moveX = -currentColWidth;
|
|
285
295
|
}
|
|
286
296
|
const offsetTableX = startOffsetTableX + moveX;
|
|
287
|
-
if (!
|
|
297
|
+
if (!colResizeIndicatorRef.value)
|
|
288
298
|
return;
|
|
289
|
-
|
|
299
|
+
colResizeIndicatorRef.value.style.left = offsetTableX + "px";
|
|
290
300
|
}
|
|
291
301
|
function onThResizeMouseUp(e) {
|
|
292
302
|
if (!isColResizing.value)
|
|
@@ -294,7 +304,7 @@ function useColResize({
|
|
|
294
304
|
const { startX, lastCol } = colResizeState;
|
|
295
305
|
const { clientX } = e;
|
|
296
306
|
const moveX = clientX - startX;
|
|
297
|
-
let width =
|
|
307
|
+
let width = getCalculatedColWidth(lastCol) + moveX;
|
|
298
308
|
if (width < props.colMinWidth)
|
|
299
309
|
width = props.colMinWidth;
|
|
300
310
|
const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
|
|
@@ -302,8 +312,8 @@ function useColResize({
|
|
|
302
312
|
return;
|
|
303
313
|
curCol.width = width + "px";
|
|
304
314
|
emits("update:columns", [...props.columns]);
|
|
305
|
-
if (
|
|
306
|
-
const style =
|
|
315
|
+
if (colResizeIndicatorRef.value) {
|
|
316
|
+
const style = colResizeIndicatorRef.value.style;
|
|
307
317
|
style.display = "none";
|
|
308
318
|
style.left = "0";
|
|
309
319
|
style.top = "0";
|
|
@@ -332,7 +342,7 @@ function useColResize({
|
|
|
332
342
|
onThResizeMouseUp
|
|
333
343
|
};
|
|
334
344
|
}
|
|
335
|
-
function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast,
|
|
345
|
+
function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast, tableContainerRef }) {
|
|
336
346
|
const fixedShadow = ref({
|
|
337
347
|
showL: false,
|
|
338
348
|
showR: false
|
|
@@ -383,7 +393,7 @@ function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast, tableCon
|
|
|
383
393
|
function updateFixedShadow() {
|
|
384
394
|
if (!props.fixedColShadow)
|
|
385
395
|
return;
|
|
386
|
-
const { clientWidth, scrollWidth, scrollLeft } =
|
|
396
|
+
const { clientWidth, scrollWidth, scrollLeft } = tableContainerRef.value;
|
|
387
397
|
fixedShadow.value.showL = Boolean(scrollLeft);
|
|
388
398
|
fixedShadow.value.showR = Math.abs(scrollWidth - scrollLeft - clientWidth) > 0.5;
|
|
389
399
|
}
|
|
@@ -418,7 +428,7 @@ function useFixedStyle({
|
|
|
418
428
|
} else {
|
|
419
429
|
refStore.set(item, left);
|
|
420
430
|
}
|
|
421
|
-
left +=
|
|
431
|
+
left += getCalculatedColWidth(item);
|
|
422
432
|
}
|
|
423
433
|
if (!rightStartIndex && item.fixed === "right") {
|
|
424
434
|
rightStartIndex = i;
|
|
@@ -433,7 +443,7 @@ function useFixedStyle({
|
|
|
433
443
|
} else {
|
|
434
444
|
refStore.set(item, right);
|
|
435
445
|
}
|
|
436
|
-
right +=
|
|
446
|
+
right += getCalculatedColWidth(item);
|
|
437
447
|
}
|
|
438
448
|
}
|
|
439
449
|
});
|
|
@@ -441,6 +451,8 @@ function useFixedStyle({
|
|
|
441
451
|
});
|
|
442
452
|
function getFixedStyle(tagType, col, depth = 0) {
|
|
443
453
|
const { fixed } = col;
|
|
454
|
+
if (tagType === TagType.TD && !fixed)
|
|
455
|
+
return null;
|
|
444
456
|
const isFixedLeft = fixed === "left";
|
|
445
457
|
const style = {};
|
|
446
458
|
const { colKeyStore, refStore } = fixedColumnsPositionStore.value;
|
|
@@ -455,9 +467,9 @@ function useFixedStyle({
|
|
|
455
467
|
} else {
|
|
456
468
|
style.top = depth * props.rowHeight + "px";
|
|
457
469
|
}
|
|
458
|
-
style.zIndex = isFixedLeft ? "5" : "4";
|
|
459
|
-
} else {
|
|
460
470
|
style.zIndex = isFixedLeft ? "3" : "2";
|
|
471
|
+
} else {
|
|
472
|
+
style.zIndex = isFixedLeft ? "2" : "1";
|
|
461
473
|
}
|
|
462
474
|
if (fixed === "left" || fixed === "right") {
|
|
463
475
|
if (IS_LEGACY_MODE) {
|
|
@@ -484,139 +496,240 @@ function useFixedStyle({
|
|
|
484
496
|
getFixedStyle
|
|
485
497
|
};
|
|
486
498
|
}
|
|
487
|
-
function useHighlight({ props,
|
|
488
|
-
var _a, _b;
|
|
499
|
+
function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
489
500
|
const config = props.highlightConfig;
|
|
490
|
-
const
|
|
491
|
-
const
|
|
492
|
-
const frequency = config.fps ? 1e3 / config.fps : HIGHLIGHT_FREQ;
|
|
501
|
+
const highlightDuration = config.duration ? config.duration * 1e3 : HIGHLIGHT_DURATION;
|
|
502
|
+
const highlightFrequency = config.fps ? 1e3 / config.fps : HIGHLIGHT_FREQ;
|
|
493
503
|
const highlightColor = {
|
|
494
|
-
light:
|
|
495
|
-
dark:
|
|
504
|
+
light: HIGHLIGHT_COLOR.light,
|
|
505
|
+
dark: HIGHLIGHT_COLOR.dark
|
|
496
506
|
};
|
|
507
|
+
const highlightSteps = highlightDuration / highlightFrequency;
|
|
497
508
|
const highlightFrom = computed(() => highlightColor[props.theme].from);
|
|
498
509
|
const highlightTo = computed(() => highlightColor[props.theme].to);
|
|
499
510
|
const highlightInter = computed(() => interpolateRgb(highlightFrom.value, highlightTo.value));
|
|
500
|
-
const
|
|
511
|
+
const highlightDimRowsJs = /* @__PURE__ */ new Map();
|
|
512
|
+
let calcHighlightDimLoopJs = false;
|
|
513
|
+
const highlightDimRowsAnimation = /* @__PURE__ */ new Map();
|
|
514
|
+
let calcHighlightDimLoopAnimation = false;
|
|
501
515
|
const highlightDimRowsTimeout = /* @__PURE__ */ new Map();
|
|
502
516
|
const highlightDimCellsTimeout = /* @__PURE__ */ new Map();
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (calcHighlightDimLoop)
|
|
517
|
+
function calcRowHighlightLoop() {
|
|
518
|
+
if (calcHighlightDimLoopAnimation)
|
|
506
519
|
return;
|
|
507
|
-
|
|
520
|
+
calcHighlightDimLoopAnimation = true;
|
|
521
|
+
const recursion = () => {
|
|
522
|
+
window.requestAnimationFrame(
|
|
523
|
+
() => {
|
|
524
|
+
const nowTs = Date.now();
|
|
525
|
+
highlightDimRowsAnimation.forEach((store, rowKeyValue) => {
|
|
526
|
+
const { ts, duration } = store;
|
|
527
|
+
const timeOffset = nowTs - ts;
|
|
528
|
+
if (nowTs - ts < duration) {
|
|
529
|
+
updateRowBgc(rowKeyValue, store, timeOffset);
|
|
530
|
+
} else {
|
|
531
|
+
highlightDimRowsAnimation.delete(rowKeyValue);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
if (highlightDimRowsAnimation.size > 0) {
|
|
535
|
+
recursion();
|
|
536
|
+
} else {
|
|
537
|
+
calcHighlightDimLoopAnimation = false;
|
|
538
|
+
highlightDimRowsAnimation.clear();
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
};
|
|
543
|
+
recursion();
|
|
544
|
+
}
|
|
545
|
+
function calcRowHighlightLoopJs() {
|
|
546
|
+
if (calcHighlightDimLoopJs)
|
|
547
|
+
return;
|
|
548
|
+
calcHighlightDimLoopJs = true;
|
|
508
549
|
const recursion = () => {
|
|
509
550
|
window.setTimeout(() => {
|
|
510
551
|
const nowTs = Date.now();
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
552
|
+
highlightDimRowsJs.forEach((highlightStart, rowKeyValue) => {
|
|
553
|
+
const progress = (nowTs - highlightStart) / highlightDuration;
|
|
554
|
+
let bgc = "";
|
|
514
555
|
if (0 < progress && progress < 1) {
|
|
515
|
-
|
|
556
|
+
bgc = highlightInter.value(progress);
|
|
516
557
|
} else {
|
|
517
|
-
|
|
518
|
-
highlightDimRowKeys.delete(rowKeyValue);
|
|
558
|
+
highlightDimRowsJs.delete(rowKeyValue);
|
|
519
559
|
}
|
|
560
|
+
updateRowBgcJs(rowKeyValue, bgc);
|
|
520
561
|
});
|
|
521
|
-
|
|
522
|
-
if (highlightDimRowKeys.size > 0) {
|
|
562
|
+
if (highlightDimRowsJs.size > 0) {
|
|
523
563
|
recursion();
|
|
524
564
|
} else {
|
|
525
|
-
|
|
565
|
+
calcHighlightDimLoopJs = false;
|
|
566
|
+
highlightDimRowsJs.clear();
|
|
526
567
|
}
|
|
527
|
-
},
|
|
568
|
+
}, highlightFrequency);
|
|
528
569
|
};
|
|
529
570
|
recursion();
|
|
530
571
|
}
|
|
572
|
+
const defaultHighlightDimOption = {
|
|
573
|
+
keyframe: [{ backgroundColor: highlightFrom.value }, { backgroundColor: highlightTo.value }],
|
|
574
|
+
duration: highlightDuration
|
|
575
|
+
};
|
|
531
576
|
function setHighlightDimCell(rowKeyValue, dataIndex, option = {}) {
|
|
532
|
-
var
|
|
533
|
-
const cellEl = (
|
|
534
|
-
const
|
|
577
|
+
var _a;
|
|
578
|
+
const cellEl = (_a = tableContainerRef.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"]>[data-index="${dataIndex}"]`);
|
|
579
|
+
const { className, method, duration, keyframe } = {
|
|
580
|
+
className: HIGHLIGHT_CELL_CLASS,
|
|
581
|
+
method: "css",
|
|
582
|
+
...defaultHighlightDimOption,
|
|
583
|
+
...option
|
|
584
|
+
};
|
|
535
585
|
if (!cellEl)
|
|
536
586
|
return;
|
|
537
|
-
if (
|
|
538
|
-
cellEl.
|
|
587
|
+
if (method === "animation") {
|
|
588
|
+
cellEl.animate(keyframe, duration);
|
|
589
|
+
} else {
|
|
590
|
+
highlightCellsInCssKeyFrame(cellEl, rowKeyValue, className, duration);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function setHighlightDimRow(rowKeyValues, option = {}) {
|
|
594
|
+
if (!Array.isArray(rowKeyValues))
|
|
595
|
+
rowKeyValues = [rowKeyValues];
|
|
596
|
+
const { className, method, useCss, keyframe, duration } = {
|
|
597
|
+
className: HIGHLIGHT_ROW_CLASS,
|
|
598
|
+
method: props.virtual ? "js" : "css",
|
|
599
|
+
...defaultHighlightDimOption,
|
|
600
|
+
...option
|
|
601
|
+
};
|
|
602
|
+
const nowTs = Date.now();
|
|
603
|
+
if (method === "css" || useCss) {
|
|
604
|
+
highlightRowsInCssKeyframe(rowKeyValues, className, duration);
|
|
605
|
+
} else if (method === "animation") {
|
|
606
|
+
if (props.virtual) {
|
|
607
|
+
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
608
|
+
const rowKeyValue = rowKeyValues[i];
|
|
609
|
+
const store = { ts: nowTs, visible: false, keyframe, duration };
|
|
610
|
+
highlightDimRowsAnimation.set(rowKeyValue, store);
|
|
611
|
+
updateRowBgc(rowKeyValue, store, 0);
|
|
612
|
+
}
|
|
613
|
+
calcRowHighlightLoop();
|
|
614
|
+
} else {
|
|
615
|
+
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
616
|
+
const rowEl = document.getElementById(stkTableId + "-" + String(rowKeyValues[i]));
|
|
617
|
+
if (!rowEl)
|
|
618
|
+
continue;
|
|
619
|
+
rowEl.animate(keyframe, duration);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
} else if (method === "js") {
|
|
623
|
+
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
624
|
+
const rowKeyValue = rowKeyValues[i];
|
|
625
|
+
highlightDimRowsJs.set(rowKeyValue, nowTs);
|
|
626
|
+
updateRowBgcJs(rowKeyValue, highlightFrom.value);
|
|
627
|
+
}
|
|
628
|
+
calcRowHighlightLoopJs();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function highlightRowsInCssKeyframe(rowKeyValues, className, duration) {
|
|
632
|
+
var _a;
|
|
633
|
+
let needRepaint = false;
|
|
634
|
+
const rowElTemp = [];
|
|
635
|
+
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
636
|
+
const rowKeyValue = rowKeyValues[i];
|
|
637
|
+
const rowEl = document.getElementById(stkTableId + "-" + String(rowKeyValue));
|
|
638
|
+
if (!rowEl)
|
|
639
|
+
continue;
|
|
640
|
+
if (rowEl.classList.contains(className)) {
|
|
641
|
+
rowEl.classList.remove(className);
|
|
642
|
+
needRepaint = true;
|
|
643
|
+
}
|
|
644
|
+
rowElTemp.push(rowEl);
|
|
645
|
+
window.clearTimeout(highlightDimRowsTimeout.get(rowKeyValue));
|
|
646
|
+
highlightDimRowsTimeout.set(
|
|
647
|
+
rowKeyValue,
|
|
648
|
+
window.setTimeout(() => {
|
|
649
|
+
rowEl.classList.remove(className);
|
|
650
|
+
highlightDimRowsTimeout.delete(rowKeyValue);
|
|
651
|
+
}, duration)
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
if (needRepaint) {
|
|
655
|
+
void ((_a = tableContainerRef.value) == null ? void 0 : _a.offsetWidth);
|
|
656
|
+
}
|
|
657
|
+
rowElTemp.forEach((el) => el.classList.add(className));
|
|
658
|
+
}
|
|
659
|
+
function highlightCellsInCssKeyFrame(cellEl, rowKeyValue, className, duration) {
|
|
660
|
+
if (cellEl.classList.contains(className)) {
|
|
661
|
+
cellEl.classList.remove(className);
|
|
539
662
|
void cellEl.offsetHeight;
|
|
540
663
|
}
|
|
541
|
-
cellEl.classList.add(
|
|
664
|
+
cellEl.classList.add(className);
|
|
542
665
|
window.clearTimeout(highlightDimCellsTimeout.get(rowKeyValue));
|
|
543
666
|
highlightDimCellsTimeout.set(
|
|
544
667
|
rowKeyValue,
|
|
545
668
|
window.setTimeout(() => {
|
|
546
|
-
cellEl.classList.remove(
|
|
669
|
+
cellEl.classList.remove(className);
|
|
547
670
|
highlightDimCellsTimeout.delete(rowKeyValue);
|
|
548
671
|
}, duration)
|
|
549
672
|
);
|
|
550
673
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const nowTs = Date.now();
|
|
558
|
-
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
559
|
-
const rowKeyValue = rowKeyValues[i];
|
|
560
|
-
highlightRowStore.value[rowKeyValue] = {
|
|
561
|
-
bgc: highlightFrom.value,
|
|
562
|
-
bgc_progress: 0,
|
|
563
|
-
bgc_progress_ms: nowTs
|
|
564
|
-
};
|
|
565
|
-
highlightDimRowKeys.add(rowKeyValue);
|
|
566
|
-
}
|
|
567
|
-
calcHighlightLoop();
|
|
568
|
-
} else {
|
|
569
|
-
let needRepaint = false;
|
|
570
|
-
const rowElTemp = [];
|
|
571
|
-
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
572
|
-
const rowKeyValue = rowKeyValues[i];
|
|
573
|
-
const rowEl = (_a2 = tableContainer.value) == null ? void 0 : _a2.querySelector(`[data-row-key="${rowKeyValue}"]`);
|
|
574
|
-
if (!rowEl)
|
|
575
|
-
continue;
|
|
576
|
-
if (rowEl.classList.contains(className)) {
|
|
577
|
-
rowEl.classList.remove(className);
|
|
578
|
-
needRepaint = true;
|
|
579
|
-
}
|
|
580
|
-
rowElTemp.push(rowEl);
|
|
581
|
-
window.clearTimeout(highlightDimRowsTimeout.get(rowKeyValue));
|
|
582
|
-
highlightDimRowsTimeout.set(
|
|
583
|
-
rowKeyValue,
|
|
584
|
-
window.setTimeout(() => {
|
|
585
|
-
rowEl.classList.remove(className);
|
|
586
|
-
highlightDimRowsTimeout.delete(rowKeyValue);
|
|
587
|
-
}, duration)
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
if (needRepaint) {
|
|
591
|
-
void ((_b2 = tableContainer.value) == null ? void 0 : _b2.offsetWidth);
|
|
674
|
+
function updateRowBgc(rowKeyValue, store, timeOffset) {
|
|
675
|
+
const rowEl = document.getElementById(stkTableId + "-" + String(rowKeyValue));
|
|
676
|
+
const { visible, keyframe, duration: initialDuration } = store;
|
|
677
|
+
if (!rowEl) {
|
|
678
|
+
if (visible) {
|
|
679
|
+
store.visible = false;
|
|
592
680
|
}
|
|
593
|
-
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (!visible) {
|
|
684
|
+
store.visible = true;
|
|
685
|
+
const iterationStart = timeOffset / initialDuration;
|
|
686
|
+
rowEl.animate(keyframe, {
|
|
687
|
+
duration: initialDuration - timeOffset,
|
|
688
|
+
/** 从什么时候开始,0-1 */
|
|
689
|
+
iterationStart,
|
|
690
|
+
/** 持续多久 0-1 */
|
|
691
|
+
iterations: 1 - iterationStart
|
|
692
|
+
});
|
|
594
693
|
}
|
|
595
694
|
}
|
|
695
|
+
function updateRowBgcJs(rowKeyValue, color) {
|
|
696
|
+
const rowEl = document.getElementById(stkTableId + "-" + String(rowKeyValue));
|
|
697
|
+
if (!rowEl)
|
|
698
|
+
return;
|
|
699
|
+
rowEl.style.backgroundColor = color;
|
|
700
|
+
}
|
|
596
701
|
return {
|
|
597
|
-
|
|
598
|
-
highlightFrom,
|
|
702
|
+
highlightSteps,
|
|
599
703
|
setHighlightDimRow,
|
|
600
704
|
setHighlightDimCell
|
|
601
705
|
};
|
|
602
706
|
}
|
|
603
707
|
const SCROLL_CODES = ["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft", "PageUp", "PageDown"];
|
|
604
|
-
function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders }) {
|
|
708
|
+
function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders, virtual_on }) {
|
|
605
709
|
let isMouseOver = false;
|
|
606
|
-
|
|
710
|
+
watch(virtual_on, (val) => {
|
|
711
|
+
if (!val) {
|
|
712
|
+
removeListeners();
|
|
713
|
+
} else {
|
|
714
|
+
addEventListeners();
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
onMounted(addEventListeners);
|
|
718
|
+
onBeforeUnmount(removeListeners);
|
|
719
|
+
function addEventListeners() {
|
|
607
720
|
var _a, _b, _c;
|
|
608
721
|
window.addEventListener("keydown", handleKeydown);
|
|
609
722
|
(_a = targetElement.value) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnter);
|
|
610
723
|
(_b = targetElement.value) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeave);
|
|
611
724
|
(_c = targetElement.value) == null ? void 0 : _c.addEventListener("mousedown", handleMouseDown);
|
|
612
|
-
}
|
|
613
|
-
|
|
725
|
+
}
|
|
726
|
+
function removeListeners() {
|
|
614
727
|
var _a, _b, _c;
|
|
615
728
|
window.removeEventListener("keydown", handleKeydown);
|
|
616
729
|
(_a = targetElement.value) == null ? void 0 : _a.removeEventListener("mouseenter", handleMouseEnter);
|
|
617
730
|
(_b = targetElement.value) == null ? void 0 : _b.removeEventListener("mouseleave", handleMouseLeave);
|
|
618
731
|
(_c = targetElement.value) == null ? void 0 : _c.removeEventListener("mousedown", handleMouseDown);
|
|
619
|
-
}
|
|
732
|
+
}
|
|
620
733
|
function handleKeydown(e) {
|
|
621
734
|
if (!SCROLL_CODES.includes(e.code))
|
|
622
735
|
return;
|
|
@@ -707,7 +820,7 @@ function useThDrag({ props, emits }) {
|
|
|
707
820
|
const VUE2_SCROLL_TIMEOUT_MS = 200;
|
|
708
821
|
function useVirtualScroll({
|
|
709
822
|
props,
|
|
710
|
-
|
|
823
|
+
tableContainerRef,
|
|
711
824
|
dataSourceCopy,
|
|
712
825
|
tableHeaderLast,
|
|
713
826
|
tableHeaders
|
|
@@ -744,7 +857,7 @@ function useVirtualScroll({
|
|
|
744
857
|
return (dataSourceCopy.value.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
|
|
745
858
|
});
|
|
746
859
|
const virtualX_on = computed(() => {
|
|
747
|
-
return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum +=
|
|
860
|
+
return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getCalculatedColWidth(col), 0) > virtualScrollX.value.containerWidth + 100;
|
|
748
861
|
});
|
|
749
862
|
const virtualX_columnPart = computed(() => {
|
|
750
863
|
if (virtualX_on.value) {
|
|
@@ -773,7 +886,7 @@ function useVirtualScroll({
|
|
|
773
886
|
for (let i = virtualScrollX.value.endIndex; i < tableHeaderLast.value.length; i++) {
|
|
774
887
|
const col = tableHeaderLast.value[i];
|
|
775
888
|
if (col.fixed !== "right") {
|
|
776
|
-
width +=
|
|
889
|
+
width += getCalculatedColWidth(col);
|
|
777
890
|
}
|
|
778
891
|
}
|
|
779
892
|
return width;
|
|
@@ -781,7 +894,7 @@ function useVirtualScroll({
|
|
|
781
894
|
function initVirtualScrollY(height) {
|
|
782
895
|
if (!virtual_on.value)
|
|
783
896
|
return;
|
|
784
|
-
const { offsetHeight, scrollTop } =
|
|
897
|
+
const { offsetHeight, scrollTop } = tableContainerRef.value || {};
|
|
785
898
|
const { rowHeight } = virtualScroll.value;
|
|
786
899
|
let containerHeight;
|
|
787
900
|
if (typeof height === "number") {
|
|
@@ -801,7 +914,7 @@ function useVirtualScroll({
|
|
|
801
914
|
function initVirtualScrollX() {
|
|
802
915
|
if (!props.virtualX)
|
|
803
916
|
return;
|
|
804
|
-
const { offsetWidth, scrollLeft } =
|
|
917
|
+
const { offsetWidth, scrollLeft } = tableContainerRef.value || {};
|
|
805
918
|
virtualScrollX.value.containerWidth = offsetWidth || DEFAULT_TABLE_WIDTH;
|
|
806
919
|
updateVirtualScrollX(scrollLeft);
|
|
807
920
|
}
|
|
@@ -866,7 +979,7 @@ function useVirtualScroll({
|
|
|
866
979
|
for (let colIndex = 0; colIndex < headerLength; colIndex++) {
|
|
867
980
|
startIndex++;
|
|
868
981
|
const col = tableHeaderLast.value[colIndex];
|
|
869
|
-
const colWidth =
|
|
982
|
+
const colWidth = getCalculatedColWidth(col);
|
|
870
983
|
if (col.fixed === "left") {
|
|
871
984
|
leftColWidthSum += colWidth;
|
|
872
985
|
continue;
|
|
@@ -883,7 +996,7 @@ function useVirtualScroll({
|
|
|
883
996
|
let endIndex = headerLength;
|
|
884
997
|
for (let colIndex = startIndex + 1; colIndex < headerLength; colIndex++) {
|
|
885
998
|
const col = tableHeaderLast.value[colIndex];
|
|
886
|
-
colWidthSum +=
|
|
999
|
+
colWidthSum += getCalculatedColWidth(col);
|
|
887
1000
|
if (colWidthSum >= containerWidth) {
|
|
888
1001
|
endIndex = colIndex + 1;
|
|
889
1002
|
break;
|
|
@@ -923,12 +1036,16 @@ function useVirtualScroll({
|
|
|
923
1036
|
const _hoisted_1 = { key: 0 };
|
|
924
1037
|
const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
925
1038
|
const _hoisted_3 = { class: "table-header-cell-wrapper" };
|
|
926
|
-
const _hoisted_4 = {
|
|
927
|
-
|
|
928
|
-
|
|
1039
|
+
const _hoisted_4 = {
|
|
1040
|
+
key: 1,
|
|
1041
|
+
class: "table-header-title"
|
|
1042
|
+
};
|
|
1043
|
+
const _hoisted_5 = { class: "table-header-title" };
|
|
1044
|
+
const _hoisted_6 = {
|
|
1045
|
+
key: 3,
|
|
929
1046
|
class: "table-header-sorter"
|
|
930
1047
|
};
|
|
931
|
-
const
|
|
1048
|
+
const _hoisted_7 = /* @__PURE__ */ createElementVNode("svg", {
|
|
932
1049
|
xmlns: "http://www.w3.org/2000/svg",
|
|
933
1050
|
width: "16px",
|
|
934
1051
|
height: "16px",
|
|
@@ -945,24 +1062,24 @@ const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
945
1062
|
points: "8 10 4.8 14 11.2 14"
|
|
946
1063
|
})
|
|
947
1064
|
], -1);
|
|
948
|
-
const
|
|
949
|
-
|
|
1065
|
+
const _hoisted_8 = [
|
|
1066
|
+
_hoisted_7
|
|
950
1067
|
];
|
|
951
|
-
const _hoisted_8 = ["onMousedown"];
|
|
952
1068
|
const _hoisted_9 = ["onMousedown"];
|
|
953
|
-
const _hoisted_10 =
|
|
1069
|
+
const _hoisted_10 = ["onMousedown"];
|
|
1070
|
+
const _hoisted_11 = {
|
|
954
1071
|
key: 0,
|
|
955
1072
|
class: "virtual-x-left",
|
|
956
1073
|
style: { "padding": "0" }
|
|
957
1074
|
};
|
|
958
|
-
const
|
|
959
|
-
const
|
|
1075
|
+
const _hoisted_12 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
|
|
1076
|
+
const _hoisted_13 = {
|
|
960
1077
|
key: 0,
|
|
961
1078
|
class: "virtual-x-left",
|
|
962
1079
|
style: { "padding": "0" }
|
|
963
1080
|
};
|
|
964
|
-
const
|
|
965
|
-
const
|
|
1081
|
+
const _hoisted_14 = ["data-index", "onClick"];
|
|
1082
|
+
const _hoisted_15 = ["title"];
|
|
966
1083
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
967
1084
|
__name: "StkTable",
|
|
968
1085
|
props: {
|
|
@@ -1001,22 +1118,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1001
1118
|
stringLocaleCompare: true
|
|
1002
1119
|
}) },
|
|
1003
1120
|
hideHeaderTitle: { type: [Boolean, Array], default: false },
|
|
1004
|
-
highlightConfig: { default: () => ({}) }
|
|
1121
|
+
highlightConfig: { default: () => ({}) },
|
|
1122
|
+
seqConfig: { default: () => ({}) }
|
|
1005
1123
|
},
|
|
1006
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"],
|
|
1007
1125
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1126
|
+
const stkTableId = createStkTableId();
|
|
1008
1127
|
const props = __props;
|
|
1009
1128
|
const emits = __emit;
|
|
1010
|
-
const
|
|
1011
|
-
const
|
|
1129
|
+
const tableContainerRef = ref();
|
|
1130
|
+
const colResizeIndicatorRef = ref();
|
|
1012
1131
|
const currentItem = ref(null);
|
|
1013
1132
|
const currentItemKey = ref(null);
|
|
1014
1133
|
const currentHover = ref(null);
|
|
1015
1134
|
let sortCol = ref();
|
|
1016
1135
|
let sortOrderIndex = ref(0);
|
|
1017
1136
|
const sortSwitchOrder = [null, "desc", "asc"];
|
|
1018
|
-
const tableHeaders =
|
|
1019
|
-
const tableHeaderLast =
|
|
1137
|
+
const tableHeaders = shallowRef([]);
|
|
1138
|
+
const tableHeaderLast = shallowRef([]);
|
|
1020
1139
|
const dataSourceCopy = shallowRef([...props.dataSource]);
|
|
1021
1140
|
const getEmptyCellText = computed(() => {
|
|
1022
1141
|
if (typeof props.emptyCellText === "string") {
|
|
@@ -1030,8 +1149,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1030
1149
|
props,
|
|
1031
1150
|
emits,
|
|
1032
1151
|
colKeyGen,
|
|
1033
|
-
|
|
1034
|
-
|
|
1152
|
+
colResizeIndicatorRef,
|
|
1153
|
+
tableContainerRef,
|
|
1035
1154
|
tableHeaderLast
|
|
1036
1155
|
});
|
|
1037
1156
|
const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
|
|
@@ -1049,7 +1168,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1049
1168
|
initVirtualScrollX,
|
|
1050
1169
|
updateVirtualScrollY,
|
|
1051
1170
|
updateVirtualScrollX
|
|
1052
|
-
} = useVirtualScroll({
|
|
1171
|
+
} = useVirtualScroll({ tableContainerRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
|
|
1053
1172
|
const { getFixedStyle } = useFixedStyle({
|
|
1054
1173
|
props,
|
|
1055
1174
|
tableHeaders,
|
|
@@ -1058,21 +1177,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1058
1177
|
virtualX_on,
|
|
1059
1178
|
virtualX_offsetRight
|
|
1060
1179
|
});
|
|
1061
|
-
const {
|
|
1180
|
+
const { highlightSteps, setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, stkTableId, tableContainerRef });
|
|
1062
1181
|
if (props.autoResize) {
|
|
1063
|
-
useAutoResize({
|
|
1182
|
+
useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs: 200 });
|
|
1064
1183
|
}
|
|
1065
|
-
useKeyboardArrowScroll(
|
|
1184
|
+
useKeyboardArrowScroll(tableContainerRef, {
|
|
1066
1185
|
props,
|
|
1067
1186
|
scrollTo,
|
|
1068
1187
|
virtualScroll,
|
|
1069
1188
|
virtualScrollX,
|
|
1070
|
-
tableHeaders
|
|
1189
|
+
tableHeaders,
|
|
1190
|
+
virtual_on
|
|
1071
1191
|
});
|
|
1072
1192
|
const { fixedColClassMap, dealFixedColShadow, updateFixedShadow } = useFixedCol({
|
|
1073
1193
|
props,
|
|
1074
1194
|
colKeyGen,
|
|
1075
|
-
|
|
1195
|
+
tableContainerRef,
|
|
1076
1196
|
tableHeaders,
|
|
1077
1197
|
tableHeaderLast
|
|
1078
1198
|
});
|
|
@@ -1083,6 +1203,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1083
1203
|
initVirtualScrollX();
|
|
1084
1204
|
}
|
|
1085
1205
|
);
|
|
1206
|
+
watch(
|
|
1207
|
+
() => props.virtualX,
|
|
1208
|
+
() => dealColumns()
|
|
1209
|
+
);
|
|
1086
1210
|
dealColumns();
|
|
1087
1211
|
watch(
|
|
1088
1212
|
() => props.dataSource,
|
|
@@ -1122,7 +1246,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1122
1246
|
}
|
|
1123
1247
|
function dealColumns() {
|
|
1124
1248
|
tableHeaders.value = [];
|
|
1125
|
-
tableHeaderLast.value = [];
|
|
1126
1249
|
const copyColumn = props.columns;
|
|
1127
1250
|
const deep = howDeepTheHeader(copyColumn);
|
|
1128
1251
|
const tempHeaderLast = [];
|
|
@@ -1161,9 +1284,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1161
1284
|
if (colSpan !== 1) {
|
|
1162
1285
|
col.colSpan = colSpan;
|
|
1163
1286
|
}
|
|
1164
|
-
|
|
1165
|
-
col.width = colWidth + "px";
|
|
1166
|
-
}
|
|
1287
|
+
col.__WIDTH__ = colWidth;
|
|
1167
1288
|
allChildrenLen += colChildrenLen;
|
|
1168
1289
|
allChildrenWidthSum += colWidth;
|
|
1169
1290
|
});
|
|
@@ -1192,7 +1313,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1192
1313
|
tableHeaders.value.forEach((cols, depth) => {
|
|
1193
1314
|
cols.forEach((col) => {
|
|
1194
1315
|
const colKey = colKeyGen(col);
|
|
1195
|
-
const width =
|
|
1316
|
+
const width = props.virtualX ? getCalculatedColWidth(col) + "px" : transformWidthToStr(col.width);
|
|
1196
1317
|
const style = {
|
|
1197
1318
|
width
|
|
1198
1319
|
};
|
|
@@ -1200,8 +1321,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1200
1321
|
style.minWidth = width;
|
|
1201
1322
|
style.maxWidth = width;
|
|
1202
1323
|
} else {
|
|
1203
|
-
style.minWidth =
|
|
1204
|
-
style.maxWidth =
|
|
1324
|
+
style.minWidth = transformWidthToStr(col.minWidth) ?? width;
|
|
1325
|
+
style.maxWidth = transformWidthToStr(col.maxWidth) ?? width;
|
|
1205
1326
|
}
|
|
1206
1327
|
const thStyle = {
|
|
1207
1328
|
...style,
|
|
@@ -1346,12 +1467,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1346
1467
|
dataSourceCopy.value = [...props.dataSource];
|
|
1347
1468
|
}
|
|
1348
1469
|
function scrollTo(top = 0, left = 0) {
|
|
1349
|
-
if (!
|
|
1470
|
+
if (!tableContainerRef.value)
|
|
1350
1471
|
return;
|
|
1351
1472
|
if (top !== null)
|
|
1352
|
-
|
|
1473
|
+
tableContainerRef.value.scrollTop = top;
|
|
1353
1474
|
if (left !== null)
|
|
1354
|
-
|
|
1475
|
+
tableContainerRef.value.scrollLeft = left;
|
|
1355
1476
|
}
|
|
1356
1477
|
function getTableData() {
|
|
1357
1478
|
return toRaw(dataSourceCopy.value);
|
|
@@ -1390,8 +1511,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1390
1511
|
});
|
|
1391
1512
|
return (_ctx, _cache) => {
|
|
1392
1513
|
return openBlock(), createElementBlock("div", {
|
|
1393
|
-
ref_key: "
|
|
1394
|
-
ref:
|
|
1514
|
+
ref_key: "tableContainerRef",
|
|
1515
|
+
ref: tableContainerRef,
|
|
1395
1516
|
class: normalizeClass(["stk-table", {
|
|
1396
1517
|
virtual: _ctx.virtual,
|
|
1397
1518
|
"virtual-x": _ctx.virtualX,
|
|
@@ -1411,20 +1532,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1411
1532
|
"--header-row-height": (props.headerRowHeight || props.rowHeight) + "px"
|
|
1412
1533
|
},
|
|
1413
1534
|
{
|
|
1414
|
-
"--highlight-
|
|
1415
|
-
"--highlight-
|
|
1535
|
+
"--highlight-duration": props.highlightConfig.duration && props.highlightConfig.duration + "s",
|
|
1536
|
+
"--highlight-easing": unref(highlightSteps) ? `steps(${unref(highlightSteps)})` : ""
|
|
1416
1537
|
}
|
|
1417
1538
|
]),
|
|
1418
1539
|
onScroll: onTableScroll,
|
|
1419
1540
|
onWheel: onTableWheel
|
|
1420
1541
|
}, [
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1542
|
+
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1543
|
+
key: 0,
|
|
1544
|
+
ref_key: "colResizeIndicatorRef",
|
|
1545
|
+
ref: colResizeIndicatorRef,
|
|
1424
1546
|
class: "column-resize-indicator"
|
|
1425
|
-
}, null, 512),
|
|
1426
|
-
[vShow, _ctx.colResizable]
|
|
1427
|
-
]),
|
|
1547
|
+
}, null, 512)) : createCommentVNode("", true),
|
|
1428
1548
|
createElementVNode("table", {
|
|
1429
1549
|
class: normalizeClass(["stk-table-main", {
|
|
1430
1550
|
"fixed-mode": props.fixedMode
|
|
@@ -1476,23 +1596,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1476
1596
|
col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
|
|
1477
1597
|
key: 0,
|
|
1478
1598
|
col
|
|
1479
|
-
}, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1480
|
-
key:
|
|
1599
|
+
}, null, 8, ["col"])) : col.type === "seq" ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(col.title), 1)) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1600
|
+
key: 2,
|
|
1481
1601
|
col
|
|
1482
1602
|
}, () => [
|
|
1483
|
-
createElementVNode("span",
|
|
1603
|
+
createElementVNode("span", _hoisted_5, toDisplayString(col.title), 1)
|
|
1484
1604
|
]),
|
|
1485
|
-
col.sorter ? (openBlock(), createElementBlock("span",
|
|
1605
|
+
col.sorter ? (openBlock(), createElementBlock("span", _hoisted_6, _hoisted_8)) : createCommentVNode("", true),
|
|
1486
1606
|
_ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
1487
|
-
key:
|
|
1607
|
+
key: 4,
|
|
1488
1608
|
class: "table-header-resizer left",
|
|
1489
1609
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
|
|
1490
|
-
}, null, 40,
|
|
1610
|
+
}, null, 40, _hoisted_9)) : createCommentVNode("", true),
|
|
1491
1611
|
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1492
|
-
key:
|
|
1612
|
+
key: 5,
|
|
1493
1613
|
class: "table-header-resizer right",
|
|
1494
1614
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
|
|
1495
|
-
}, null, 40,
|
|
1615
|
+
}, null, 40, _hoisted_10)) : createCommentVNode("", true)
|
|
1496
1616
|
])
|
|
1497
1617
|
], 46, _hoisted_2);
|
|
1498
1618
|
}), 128)),
|
|
@@ -1513,7 +1633,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1513
1633
|
style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
|
|
1514
1634
|
class: "padding-top-tr"
|
|
1515
1635
|
}, [
|
|
1516
|
-
unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td",
|
|
1636
|
+
unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_11)) : createCommentVNode("", true),
|
|
1517
1637
|
_ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
|
|
1518
1638
|
return openBlock(), createElementBlock("td", {
|
|
1519
1639
|
key: col.dataIndex,
|
|
@@ -1521,30 +1641,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1521
1641
|
}, null, 4);
|
|
1522
1642
|
}), 128)) : createCommentVNode("", true)
|
|
1523
1643
|
], 4)) : createCommentVNode("", true),
|
|
1524
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row,
|
|
1525
|
-
var _a;
|
|
1644
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
|
|
1526
1645
|
return openBlock(), createElementBlock("tr", {
|
|
1527
|
-
|
|
1528
|
-
|
|
1646
|
+
id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : rowIndex),
|
|
1647
|
+
key: _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1648
|
+
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : rowIndex,
|
|
1529
1649
|
class: normalizeClass({
|
|
1530
1650
|
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
|
|
1531
1651
|
hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
|
|
1532
|
-
[_ctx.rowClassName(row,
|
|
1533
|
-
}),
|
|
1534
|
-
style: normalizeStyle({
|
|
1535
|
-
backgroundColor: (_a = unref(highlightRowStore)[rowKeyGen(row)]) == null ? void 0 : _a.bgc
|
|
1652
|
+
[_ctx.rowClassName(row, rowIndex)]: true
|
|
1536
1653
|
}),
|
|
1537
1654
|
onClick: (e) => onRowClick(e, row),
|
|
1538
1655
|
onDblclick: (e) => onRowDblclick(e, row),
|
|
1539
1656
|
onContextmenu: (e) => onRowMenu(e, row),
|
|
1540
1657
|
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1541
1658
|
}, [
|
|
1542
|
-
unref(virtualX_on) ? (openBlock(), createElementBlock("td",
|
|
1543
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
|
|
1659
|
+
unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_13)) : createCommentVNode("", true),
|
|
1660
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col, colIndex) => {
|
|
1544
1661
|
return openBlock(), createElementBlock("td", {
|
|
1545
1662
|
key: col.dataIndex,
|
|
1546
1663
|
"data-index": col.dataIndex,
|
|
1547
|
-
class: normalizeClass([
|
|
1664
|
+
class: normalizeClass([
|
|
1665
|
+
col.className,
|
|
1666
|
+
unref(fixedColClassMap).get(colKeyGen(col)),
|
|
1667
|
+
_ctx.showOverflow ? "text-overflow" : "",
|
|
1668
|
+
col.type === "seq" ? "seq-column" : ""
|
|
1669
|
+
]),
|
|
1548
1670
|
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen(col))),
|
|
1549
1671
|
onClick: (e) => onCellClick(e, row, col)
|
|
1550
1672
|
}, [
|
|
@@ -1552,15 +1674,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1552
1674
|
key: 0,
|
|
1553
1675
|
col,
|
|
1554
1676
|
row,
|
|
1677
|
+
"row-index": rowIndex,
|
|
1678
|
+
"col-index": colIndex,
|
|
1555
1679
|
"cell-value": row[col.dataIndex]
|
|
1556
|
-
}, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1680
|
+
}, null, 8, ["col", "row", "row-index", "col-index", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1557
1681
|
key: 1,
|
|
1558
1682
|
class: "table-cell-wrapper",
|
|
1559
|
-
title: row[col.dataIndex]
|
|
1560
|
-
},
|
|
1561
|
-
|
|
1683
|
+
title: !col.type ? row[col.dataIndex] : ""
|
|
1684
|
+
}, [
|
|
1685
|
+
col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1686
|
+
createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + rowIndex + 1), 1)
|
|
1687
|
+
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1688
|
+
createTextVNode(toDisplayString(row[col.dataIndex] ?? getEmptyCellText.value(col, row)), 1)
|
|
1689
|
+
], 64))
|
|
1690
|
+
], 8, _hoisted_15))
|
|
1691
|
+
], 14, _hoisted_14);
|
|
1562
1692
|
}), 128))
|
|
1563
|
-
],
|
|
1693
|
+
], 42, _hoisted_12);
|
|
1564
1694
|
}), 128)),
|
|
1565
1695
|
unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1566
1696
|
key: 1,
|
|
@@ -1569,7 +1699,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1569
1699
|
])
|
|
1570
1700
|
], 6),
|
|
1571
1701
|
(!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
|
|
1572
|
-
key:
|
|
1702
|
+
key: 1,
|
|
1573
1703
|
class: normalizeClass(["stk-table-no-data", { "no-data-full": _ctx.noDataFull }])
|
|
1574
1704
|
}, [
|
|
1575
1705
|
renderSlot(_ctx.$slots, "empty", {}, () => [
|