stk-table-vue 0.2.8 → 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 +97 -10
- package/lib/src/StkTable/StkTable.vue.d.ts +27 -4
- package/lib/src/StkTable/const.d.ts +13 -8
- package/lib/src/StkTable/types/index.d.ts +19 -0
- 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 +16 -16
- 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 +349 -199
- package/lib/style.css +8 -2
- package/package.json +4 -5
- package/src/StkTable/StkTable.vue +81 -47
- package/src/StkTable/const.ts +15 -8
- package/src/StkTable/style.less +11 -6
- package/src/StkTable/types/index.ts +21 -0
- 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 +15 -12
- package/src/StkTable/useHighlight.ts +267 -109
- package/src/StkTable/useKeyboardArrowScroll.ts +19 -7
- package/src/StkTable/useVirtualScroll.ts +25 -17
- package/src/StkTable/utils.ts +27 -9
- package/src/vite-env.d.ts +4 -0
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
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
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
3
|
+
const DEFAULT_COL_WIDTH = "100";
|
|
4
|
+
const DEFAULT_TABLE_HEIGHT = 100;
|
|
5
|
+
const DEFAULT_TABLE_WIDTH = 200;
|
|
6
|
+
const DEFAULT_ROW_HEIGHT = 28;
|
|
7
|
+
const HIGHLIGHT_COLOR = {
|
|
8
8
|
light: { from: "#71a2fd", to: "#fff" },
|
|
9
9
|
dark: { from: "#1e4c99", to: "#181c21" }
|
|
10
10
|
};
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const HIGHLIGHT_DURATION = 2e3;
|
|
12
|
+
const HIGHLIGHT_FREQ = 1e3 / 30;
|
|
13
|
+
const HIGHLIGHT_ROW_CLASS = "highlight-row";
|
|
14
|
+
const HIGHLIGHT_CELL_CLASS = "highlight-cell";
|
|
13
15
|
let _chromeVersion = 0;
|
|
14
16
|
try {
|
|
15
17
|
const userAgent = navigator.userAgent.match(/chrome\/\d+/i);
|
|
@@ -19,13 +21,14 @@ try {
|
|
|
19
21
|
} catch (e) {
|
|
20
22
|
console.error("Cannot get Chrome version", e);
|
|
21
23
|
}
|
|
22
|
-
const
|
|
24
|
+
const IS_LEGACY_MODE = _chromeVersion < 56;
|
|
25
|
+
const STK_ID_PREFIX = "stk";
|
|
23
26
|
var TagType = /* @__PURE__ */ ((TagType2) => {
|
|
24
27
|
TagType2[TagType2["TH"] = 0] = "TH";
|
|
25
28
|
TagType2[TagType2["TD"] = 1] = "TD";
|
|
26
29
|
return TagType2;
|
|
27
30
|
})(TagType || {});
|
|
28
|
-
function useAutoResize({
|
|
31
|
+
function useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs }) {
|
|
29
32
|
let resizeObserver = null;
|
|
30
33
|
onMounted(() => {
|
|
31
34
|
initResizeObserver();
|
|
@@ -35,9 +38,9 @@ function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs })
|
|
|
35
38
|
});
|
|
36
39
|
function initResizeObserver() {
|
|
37
40
|
if (window.ResizeObserver) {
|
|
38
|
-
if (!
|
|
41
|
+
if (!tableContainerRef.value) {
|
|
39
42
|
const watchDom = watch(
|
|
40
|
-
() =>
|
|
43
|
+
() => tableContainerRef,
|
|
41
44
|
() => {
|
|
42
45
|
initResizeObserver();
|
|
43
46
|
watchDom();
|
|
@@ -46,7 +49,7 @@ function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs })
|
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
resizeObserver = new ResizeObserver(resizeCallback);
|
|
49
|
-
resizeObserver.observe(
|
|
52
|
+
resizeObserver.observe(tableContainerRef.value);
|
|
50
53
|
} else {
|
|
51
54
|
window.addEventListener("resize", resizeCallback);
|
|
52
55
|
}
|
|
@@ -197,23 +200,32 @@ function howDeepTheHeader(arr, level = 1) {
|
|
|
197
200
|
return Math.max(...levels);
|
|
198
201
|
}
|
|
199
202
|
function getColWidth(col) {
|
|
200
|
-
const val = (col == null ? void 0 : col.width) ??
|
|
203
|
+
const val = (col == null ? void 0 : col.minWidth) ?? (col == null ? void 0 : col.width) ?? DEFAULT_COL_WIDTH;
|
|
201
204
|
if (typeof val === "number") {
|
|
202
205
|
return Math.floor(val);
|
|
203
206
|
}
|
|
204
207
|
return parseInt(val);
|
|
205
208
|
}
|
|
206
|
-
function
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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;
|
|
210
221
|
}
|
|
211
|
-
|
|
222
|
+
window.__STK_TB_ID_COUNT__ += 1;
|
|
223
|
+
return STK_ID_PREFIX + window.__STK_TB_ID_COUNT__.toString(36);
|
|
212
224
|
}
|
|
213
225
|
function useColResize({
|
|
214
|
-
|
|
226
|
+
tableContainerRef,
|
|
215
227
|
tableHeaderLast,
|
|
216
|
-
|
|
228
|
+
colResizeIndicatorRef,
|
|
217
229
|
props,
|
|
218
230
|
emits,
|
|
219
231
|
colKeyGen
|
|
@@ -241,13 +253,13 @@ function useColResize({
|
|
|
241
253
|
window.removeEventListener("mouseup", onThResizeMouseUp);
|
|
242
254
|
}
|
|
243
255
|
function onThResizeMouseDown(e, col, isPrev = false) {
|
|
244
|
-
if (!
|
|
256
|
+
if (!tableContainerRef.value)
|
|
245
257
|
return;
|
|
246
258
|
e.stopPropagation();
|
|
247
259
|
e.preventDefault();
|
|
248
260
|
const { clientX } = e;
|
|
249
|
-
const { scrollLeft, scrollTop } =
|
|
250
|
-
const { left } =
|
|
261
|
+
const { scrollLeft, scrollTop } = tableContainerRef.value;
|
|
262
|
+
const { left } = tableContainerRef.value.getBoundingClientRect();
|
|
251
263
|
let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen(it) === colKeyGen(col));
|
|
252
264
|
if (isPrev) {
|
|
253
265
|
colIndex -= 1;
|
|
@@ -262,8 +274,8 @@ function useColResize({
|
|
|
262
274
|
startX: clientX,
|
|
263
275
|
startOffsetTableX: offsetTableX
|
|
264
276
|
});
|
|
265
|
-
if (
|
|
266
|
-
const style =
|
|
277
|
+
if (colResizeIndicatorRef.value) {
|
|
278
|
+
const style = colResizeIndicatorRef.value.style;
|
|
267
279
|
style.display = "block";
|
|
268
280
|
style.left = offsetTableX + "px";
|
|
269
281
|
style.top = scrollTop + "px";
|
|
@@ -277,14 +289,14 @@ function useColResize({
|
|
|
277
289
|
const { lastCol, startX, startOffsetTableX } = colResizeState;
|
|
278
290
|
const { clientX } = e;
|
|
279
291
|
let moveX = clientX - startX;
|
|
280
|
-
const currentColWidth =
|
|
292
|
+
const currentColWidth = getCalculatedColWidth(lastCol);
|
|
281
293
|
if (currentColWidth + moveX < props.colMinWidth) {
|
|
282
294
|
moveX = -currentColWidth;
|
|
283
295
|
}
|
|
284
296
|
const offsetTableX = startOffsetTableX + moveX;
|
|
285
|
-
if (!
|
|
297
|
+
if (!colResizeIndicatorRef.value)
|
|
286
298
|
return;
|
|
287
|
-
|
|
299
|
+
colResizeIndicatorRef.value.style.left = offsetTableX + "px";
|
|
288
300
|
}
|
|
289
301
|
function onThResizeMouseUp(e) {
|
|
290
302
|
if (!isColResizing.value)
|
|
@@ -292,7 +304,7 @@ function useColResize({
|
|
|
292
304
|
const { startX, lastCol } = colResizeState;
|
|
293
305
|
const { clientX } = e;
|
|
294
306
|
const moveX = clientX - startX;
|
|
295
|
-
let width =
|
|
307
|
+
let width = getCalculatedColWidth(lastCol) + moveX;
|
|
296
308
|
if (width < props.colMinWidth)
|
|
297
309
|
width = props.colMinWidth;
|
|
298
310
|
const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
|
|
@@ -300,8 +312,8 @@ function useColResize({
|
|
|
300
312
|
return;
|
|
301
313
|
curCol.width = width + "px";
|
|
302
314
|
emits("update:columns", [...props.columns]);
|
|
303
|
-
if (
|
|
304
|
-
const style =
|
|
315
|
+
if (colResizeIndicatorRef.value) {
|
|
316
|
+
const style = colResizeIndicatorRef.value.style;
|
|
305
317
|
style.display = "none";
|
|
306
318
|
style.left = "0";
|
|
307
319
|
style.top = "0";
|
|
@@ -330,7 +342,7 @@ function useColResize({
|
|
|
330
342
|
onThResizeMouseUp
|
|
331
343
|
};
|
|
332
344
|
}
|
|
333
|
-
function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast,
|
|
345
|
+
function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast, tableContainerRef }) {
|
|
334
346
|
const fixedShadow = ref({
|
|
335
347
|
showL: false,
|
|
336
348
|
showR: false
|
|
@@ -381,7 +393,7 @@ function useFixedCol({ props, colKeyGen, tableHeaders, tableHeaderLast, tableCon
|
|
|
381
393
|
function updateFixedShadow() {
|
|
382
394
|
if (!props.fixedColShadow)
|
|
383
395
|
return;
|
|
384
|
-
const { clientWidth, scrollWidth, scrollLeft } =
|
|
396
|
+
const { clientWidth, scrollWidth, scrollLeft } = tableContainerRef.value;
|
|
385
397
|
fixedShadow.value.showL = Boolean(scrollLeft);
|
|
386
398
|
fixedShadow.value.showR = Math.abs(scrollWidth - scrollLeft - clientWidth) > 0.5;
|
|
387
399
|
}
|
|
@@ -416,7 +428,7 @@ function useFixedStyle({
|
|
|
416
428
|
} else {
|
|
417
429
|
refStore.set(item, left);
|
|
418
430
|
}
|
|
419
|
-
left +=
|
|
431
|
+
left += getCalculatedColWidth(item);
|
|
420
432
|
}
|
|
421
433
|
if (!rightStartIndex && item.fixed === "right") {
|
|
422
434
|
rightStartIndex = i;
|
|
@@ -431,7 +443,7 @@ function useFixedStyle({
|
|
|
431
443
|
} else {
|
|
432
444
|
refStore.set(item, right);
|
|
433
445
|
}
|
|
434
|
-
right +=
|
|
446
|
+
right += getCalculatedColWidth(item);
|
|
435
447
|
}
|
|
436
448
|
}
|
|
437
449
|
});
|
|
@@ -439,26 +451,28 @@ function useFixedStyle({
|
|
|
439
451
|
});
|
|
440
452
|
function getFixedStyle(tagType, col, depth = 0) {
|
|
441
453
|
const { fixed } = col;
|
|
454
|
+
if (tagType === TagType.TD && !fixed)
|
|
455
|
+
return null;
|
|
442
456
|
const isFixedLeft = fixed === "left";
|
|
443
457
|
const style = {};
|
|
444
458
|
const { colKeyStore, refStore } = fixedColumnsPositionStore.value;
|
|
445
|
-
if (
|
|
459
|
+
if (IS_LEGACY_MODE) {
|
|
446
460
|
style.position = "relative";
|
|
447
461
|
} else {
|
|
448
462
|
style.position = "sticky";
|
|
449
463
|
}
|
|
450
464
|
if (tagType === TagType.TH) {
|
|
451
|
-
if (
|
|
465
|
+
if (IS_LEGACY_MODE) {
|
|
452
466
|
style.top = virtualScroll.value.scrollTop + depth * props.rowHeight + "px";
|
|
453
467
|
} else {
|
|
454
468
|
style.top = depth * props.rowHeight + "px";
|
|
455
469
|
}
|
|
456
|
-
style.zIndex = isFixedLeft ? "5" : "4";
|
|
457
|
-
} else {
|
|
458
470
|
style.zIndex = isFixedLeft ? "3" : "2";
|
|
471
|
+
} else {
|
|
472
|
+
style.zIndex = isFixedLeft ? "2" : "1";
|
|
459
473
|
}
|
|
460
474
|
if (fixed === "left" || fixed === "right") {
|
|
461
|
-
if (
|
|
475
|
+
if (IS_LEGACY_MODE) {
|
|
462
476
|
if (isFixedLeft) {
|
|
463
477
|
if (virtualX_on.value)
|
|
464
478
|
style.left = virtualScrollX.value.scrollLeft - virtualScrollX.value.offsetLeft + "px";
|
|
@@ -482,130 +496,240 @@ function useFixedStyle({
|
|
|
482
496
|
getFixedStyle
|
|
483
497
|
};
|
|
484
498
|
}
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
|
|
499
|
+
function useHighlight({ props, stkTableId, tableContainerRef }) {
|
|
500
|
+
const config = props.highlightConfig;
|
|
501
|
+
const highlightDuration = config.duration ? config.duration * 1e3 : HIGHLIGHT_DURATION;
|
|
502
|
+
const highlightFrequency = config.fps ? 1e3 / config.fps : HIGHLIGHT_FREQ;
|
|
503
|
+
const highlightColor = {
|
|
504
|
+
light: HIGHLIGHT_COLOR.light,
|
|
505
|
+
dark: HIGHLIGHT_COLOR.dark
|
|
506
|
+
};
|
|
507
|
+
const highlightSteps = highlightDuration / highlightFrequency;
|
|
508
|
+
const highlightFrom = computed(() => highlightColor[props.theme].from);
|
|
509
|
+
const highlightTo = computed(() => highlightColor[props.theme].to);
|
|
491
510
|
const highlightInter = computed(() => interpolateRgb(highlightFrom.value, highlightTo.value));
|
|
492
|
-
const
|
|
511
|
+
const highlightDimRowsJs = /* @__PURE__ */ new Map();
|
|
512
|
+
let calcHighlightDimLoopJs = false;
|
|
513
|
+
const highlightDimRowsAnimation = /* @__PURE__ */ new Map();
|
|
514
|
+
let calcHighlightDimLoopAnimation = false;
|
|
493
515
|
const highlightDimRowsTimeout = /* @__PURE__ */ new Map();
|
|
494
516
|
const highlightDimCellsTimeout = /* @__PURE__ */ new Map();
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
if (calcHighlightDimLoop)
|
|
517
|
+
function calcRowHighlightLoop() {
|
|
518
|
+
if (calcHighlightDimLoopAnimation)
|
|
498
519
|
return;
|
|
499
|
-
|
|
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;
|
|
500
549
|
const recursion = () => {
|
|
501
550
|
window.setTimeout(() => {
|
|
502
551
|
const nowTs = Date.now();
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
552
|
+
highlightDimRowsJs.forEach((highlightStart, rowKeyValue) => {
|
|
553
|
+
const progress = (nowTs - highlightStart) / highlightDuration;
|
|
554
|
+
let bgc = "";
|
|
506
555
|
if (0 < progress && progress < 1) {
|
|
507
|
-
|
|
556
|
+
bgc = highlightInter.value(progress);
|
|
508
557
|
} else {
|
|
509
|
-
|
|
510
|
-
highlightDimRowKeys.delete(rowKeyValue);
|
|
558
|
+
highlightDimRowsJs.delete(rowKeyValue);
|
|
511
559
|
}
|
|
560
|
+
updateRowBgcJs(rowKeyValue, bgc);
|
|
512
561
|
});
|
|
513
|
-
|
|
514
|
-
if (highlightDimRowKeys.size > 0) {
|
|
562
|
+
if (highlightDimRowsJs.size > 0) {
|
|
515
563
|
recursion();
|
|
516
564
|
} else {
|
|
517
|
-
|
|
565
|
+
calcHighlightDimLoopJs = false;
|
|
566
|
+
highlightDimRowsJs.clear();
|
|
518
567
|
}
|
|
519
|
-
},
|
|
568
|
+
}, highlightFrequency);
|
|
520
569
|
};
|
|
521
570
|
recursion();
|
|
522
571
|
}
|
|
523
|
-
|
|
572
|
+
const defaultHighlightDimOption = {
|
|
573
|
+
keyframe: [{ backgroundColor: highlightFrom.value }, { backgroundColor: highlightTo.value }],
|
|
574
|
+
duration: highlightDuration
|
|
575
|
+
};
|
|
576
|
+
function setHighlightDimCell(rowKeyValue, dataIndex, option = {}) {
|
|
524
577
|
var _a;
|
|
525
|
-
const cellEl = (_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
|
+
};
|
|
526
585
|
if (!cellEl)
|
|
527
586
|
return;
|
|
528
|
-
if (
|
|
529
|
-
cellEl.
|
|
530
|
-
|
|
587
|
+
if (method === "animation") {
|
|
588
|
+
cellEl.animate(keyframe, duration);
|
|
589
|
+
} else {
|
|
590
|
+
highlightCellsInCssKeyFrame(cellEl, rowKeyValue, className, duration);
|
|
531
591
|
}
|
|
532
|
-
cellEl.classList.add(HIGHLIGHT_CELL_CLASS);
|
|
533
|
-
window.clearTimeout(highlightDimCellsTimeout.get(rowKeyValue));
|
|
534
|
-
highlightDimCellsTimeout.set(
|
|
535
|
-
rowKeyValue,
|
|
536
|
-
window.setTimeout(() => {
|
|
537
|
-
cellEl.classList.remove(HIGHLIGHT_CELL_CLASS);
|
|
538
|
-
highlightDimCellsTimeout.delete(rowKeyValue);
|
|
539
|
-
}, Highlight_Duration)
|
|
540
|
-
);
|
|
541
592
|
}
|
|
542
593
|
function setHighlightDimRow(rowKeyValues, option = {}) {
|
|
543
|
-
var _a, _b;
|
|
544
594
|
if (!Array.isArray(rowKeyValues))
|
|
545
595
|
rowKeyValues = [rowKeyValues];
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
+
}
|
|
556
621
|
}
|
|
557
|
-
|
|
558
|
-
} else {
|
|
559
|
-
let needRepaint = false;
|
|
560
|
-
const rowElTemp = [];
|
|
622
|
+
} else if (method === "js") {
|
|
561
623
|
for (let i = 0; i < rowKeyValues.length; i++) {
|
|
562
624
|
const rowKeyValue = rowKeyValues[i];
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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;
|
|
579
643
|
}
|
|
580
|
-
|
|
581
|
-
|
|
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);
|
|
662
|
+
void cellEl.offsetHeight;
|
|
663
|
+
}
|
|
664
|
+
cellEl.classList.add(className);
|
|
665
|
+
window.clearTimeout(highlightDimCellsTimeout.get(rowKeyValue));
|
|
666
|
+
highlightDimCellsTimeout.set(
|
|
667
|
+
rowKeyValue,
|
|
668
|
+
window.setTimeout(() => {
|
|
669
|
+
cellEl.classList.remove(className);
|
|
670
|
+
highlightDimCellsTimeout.delete(rowKeyValue);
|
|
671
|
+
}, duration)
|
|
672
|
+
);
|
|
673
|
+
}
|
|
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;
|
|
582
680
|
}
|
|
583
|
-
|
|
681
|
+
return;
|
|
584
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
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function updateRowBgcJs(rowKeyValue, color) {
|
|
696
|
+
const rowEl = document.getElementById(stkTableId + "-" + String(rowKeyValue));
|
|
697
|
+
if (!rowEl)
|
|
698
|
+
return;
|
|
699
|
+
rowEl.style.backgroundColor = color;
|
|
585
700
|
}
|
|
586
701
|
return {
|
|
587
|
-
|
|
702
|
+
highlightSteps,
|
|
588
703
|
setHighlightDimRow,
|
|
589
704
|
setHighlightDimCell
|
|
590
705
|
};
|
|
591
706
|
}
|
|
592
707
|
const SCROLL_CODES = ["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft", "PageUp", "PageDown"];
|
|
593
|
-
function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders }) {
|
|
708
|
+
function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders, virtual_on }) {
|
|
594
709
|
let isMouseOver = false;
|
|
595
|
-
|
|
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() {
|
|
596
720
|
var _a, _b, _c;
|
|
597
721
|
window.addEventListener("keydown", handleKeydown);
|
|
598
722
|
(_a = targetElement.value) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnter);
|
|
599
723
|
(_b = targetElement.value) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeave);
|
|
600
724
|
(_c = targetElement.value) == null ? void 0 : _c.addEventListener("mousedown", handleMouseDown);
|
|
601
|
-
}
|
|
602
|
-
|
|
725
|
+
}
|
|
726
|
+
function removeListeners() {
|
|
603
727
|
var _a, _b, _c;
|
|
604
728
|
window.removeEventListener("keydown", handleKeydown);
|
|
605
729
|
(_a = targetElement.value) == null ? void 0 : _a.removeEventListener("mouseenter", handleMouseEnter);
|
|
606
730
|
(_b = targetElement.value) == null ? void 0 : _b.removeEventListener("mouseleave", handleMouseLeave);
|
|
607
731
|
(_c = targetElement.value) == null ? void 0 : _c.removeEventListener("mousedown", handleMouseDown);
|
|
608
|
-
}
|
|
732
|
+
}
|
|
609
733
|
function handleKeydown(e) {
|
|
610
734
|
if (!SCROLL_CODES.includes(e.code))
|
|
611
735
|
return;
|
|
@@ -696,7 +820,7 @@ function useThDrag({ props, emits }) {
|
|
|
696
820
|
const VUE2_SCROLL_TIMEOUT_MS = 200;
|
|
697
821
|
function useVirtualScroll({
|
|
698
822
|
props,
|
|
699
|
-
|
|
823
|
+
tableContainerRef,
|
|
700
824
|
dataSourceCopy,
|
|
701
825
|
tableHeaderLast,
|
|
702
826
|
tableHeaders
|
|
@@ -733,7 +857,7 @@ function useVirtualScroll({
|
|
|
733
857
|
return (dataSourceCopy.value.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
|
|
734
858
|
});
|
|
735
859
|
const virtualX_on = computed(() => {
|
|
736
|
-
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;
|
|
737
861
|
});
|
|
738
862
|
const virtualX_columnPart = computed(() => {
|
|
739
863
|
if (virtualX_on.value) {
|
|
@@ -762,7 +886,7 @@ function useVirtualScroll({
|
|
|
762
886
|
for (let i = virtualScrollX.value.endIndex; i < tableHeaderLast.value.length; i++) {
|
|
763
887
|
const col = tableHeaderLast.value[i];
|
|
764
888
|
if (col.fixed !== "right") {
|
|
765
|
-
width +=
|
|
889
|
+
width += getCalculatedColWidth(col);
|
|
766
890
|
}
|
|
767
891
|
}
|
|
768
892
|
return width;
|
|
@@ -770,13 +894,13 @@ function useVirtualScroll({
|
|
|
770
894
|
function initVirtualScrollY(height) {
|
|
771
895
|
if (!virtual_on.value)
|
|
772
896
|
return;
|
|
773
|
-
const { offsetHeight, scrollTop } =
|
|
897
|
+
const { offsetHeight, scrollTop } = tableContainerRef.value || {};
|
|
774
898
|
const { rowHeight } = virtualScroll.value;
|
|
775
899
|
let containerHeight;
|
|
776
900
|
if (typeof height === "number") {
|
|
777
901
|
containerHeight = height;
|
|
778
902
|
} else {
|
|
779
|
-
containerHeight = offsetHeight ||
|
|
903
|
+
containerHeight = offsetHeight || DEFAULT_TABLE_HEIGHT;
|
|
780
904
|
}
|
|
781
905
|
const { headless, headerRowHeight } = props;
|
|
782
906
|
let pageSize = Math.ceil(containerHeight / rowHeight);
|
|
@@ -790,8 +914,8 @@ function useVirtualScroll({
|
|
|
790
914
|
function initVirtualScrollX() {
|
|
791
915
|
if (!props.virtualX)
|
|
792
916
|
return;
|
|
793
|
-
const { offsetWidth, scrollLeft } =
|
|
794
|
-
virtualScrollX.value.containerWidth = offsetWidth ||
|
|
917
|
+
const { offsetWidth, scrollLeft } = tableContainerRef.value || {};
|
|
918
|
+
virtualScrollX.value.containerWidth = offsetWidth || DEFAULT_TABLE_WIDTH;
|
|
795
919
|
updateVirtualScrollX(scrollLeft);
|
|
796
920
|
}
|
|
797
921
|
function initVirtualScroll(height) {
|
|
@@ -851,12 +975,15 @@ function useVirtualScroll({
|
|
|
851
975
|
let startIndex = 0;
|
|
852
976
|
let offsetLeft = 0;
|
|
853
977
|
let colWidthSum = 0;
|
|
978
|
+
let leftColWidthSum = 0;
|
|
854
979
|
for (let colIndex = 0; colIndex < headerLength; colIndex++) {
|
|
855
980
|
startIndex++;
|
|
856
981
|
const col = tableHeaderLast.value[colIndex];
|
|
857
|
-
|
|
982
|
+
const colWidth = getCalculatedColWidth(col);
|
|
983
|
+
if (col.fixed === "left") {
|
|
984
|
+
leftColWidthSum += colWidth;
|
|
858
985
|
continue;
|
|
859
|
-
|
|
986
|
+
}
|
|
860
987
|
colWidthSum += colWidth;
|
|
861
988
|
if (colWidthSum >= sLeft) {
|
|
862
989
|
offsetLeft = colWidthSum - colWidth;
|
|
@@ -865,11 +992,12 @@ function useVirtualScroll({
|
|
|
865
992
|
}
|
|
866
993
|
}
|
|
867
994
|
colWidthSum = 0;
|
|
995
|
+
const containerWidth = virtualScrollX.value.containerWidth - leftColWidthSum;
|
|
868
996
|
let endIndex = headerLength;
|
|
869
997
|
for (let colIndex = startIndex + 1; colIndex < headerLength; colIndex++) {
|
|
870
998
|
const col = tableHeaderLast.value[colIndex];
|
|
871
|
-
colWidthSum +=
|
|
872
|
-
if (colWidthSum >=
|
|
999
|
+
colWidthSum += getCalculatedColWidth(col);
|
|
1000
|
+
if (colWidthSum >= containerWidth) {
|
|
873
1001
|
endIndex = colIndex + 1;
|
|
874
1002
|
break;
|
|
875
1003
|
}
|
|
@@ -908,12 +1036,16 @@ function useVirtualScroll({
|
|
|
908
1036
|
const _hoisted_1 = { key: 0 };
|
|
909
1037
|
const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
910
1038
|
const _hoisted_3 = { class: "table-header-cell-wrapper" };
|
|
911
|
-
const _hoisted_4 = {
|
|
912
|
-
|
|
913
|
-
|
|
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,
|
|
914
1046
|
class: "table-header-sorter"
|
|
915
1047
|
};
|
|
916
|
-
const
|
|
1048
|
+
const _hoisted_7 = /* @__PURE__ */ createElementVNode("svg", {
|
|
917
1049
|
xmlns: "http://www.w3.org/2000/svg",
|
|
918
1050
|
width: "16px",
|
|
919
1051
|
height: "16px",
|
|
@@ -930,24 +1062,24 @@ const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
|
|
|
930
1062
|
points: "8 10 4.8 14 11.2 14"
|
|
931
1063
|
})
|
|
932
1064
|
], -1);
|
|
933
|
-
const
|
|
934
|
-
|
|
1065
|
+
const _hoisted_8 = [
|
|
1066
|
+
_hoisted_7
|
|
935
1067
|
];
|
|
936
|
-
const _hoisted_8 = ["onMousedown"];
|
|
937
1068
|
const _hoisted_9 = ["onMousedown"];
|
|
938
|
-
const _hoisted_10 =
|
|
1069
|
+
const _hoisted_10 = ["onMousedown"];
|
|
1070
|
+
const _hoisted_11 = {
|
|
939
1071
|
key: 0,
|
|
940
1072
|
class: "virtual-x-left",
|
|
941
1073
|
style: { "padding": "0" }
|
|
942
1074
|
};
|
|
943
|
-
const
|
|
944
|
-
const
|
|
1075
|
+
const _hoisted_12 = ["id", "data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
|
|
1076
|
+
const _hoisted_13 = {
|
|
945
1077
|
key: 0,
|
|
946
1078
|
class: "virtual-x-left",
|
|
947
1079
|
style: { "padding": "0" }
|
|
948
1080
|
};
|
|
949
|
-
const
|
|
950
|
-
const
|
|
1081
|
+
const _hoisted_14 = ["data-index", "onClick"];
|
|
1082
|
+
const _hoisted_15 = ["title"];
|
|
951
1083
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
952
1084
|
__name: "StkTable",
|
|
953
1085
|
props: {
|
|
@@ -958,7 +1090,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
958
1090
|
fixedMode: { type: Boolean, default: false },
|
|
959
1091
|
headless: { type: Boolean, default: false },
|
|
960
1092
|
theme: { default: "light" },
|
|
961
|
-
rowHeight: { default:
|
|
1093
|
+
rowHeight: { default: DEFAULT_ROW_HEIGHT },
|
|
962
1094
|
headerRowHeight: { default: null },
|
|
963
1095
|
virtual: { type: Boolean, default: false },
|
|
964
1096
|
virtualX: { type: Boolean, default: false },
|
|
@@ -985,22 +1117,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
985
1117
|
emptyToBottom: false,
|
|
986
1118
|
stringLocaleCompare: true
|
|
987
1119
|
}) },
|
|
988
|
-
hideHeaderTitle: { type: [Boolean, Array], default: false }
|
|
1120
|
+
hideHeaderTitle: { type: [Boolean, Array], default: false },
|
|
1121
|
+
highlightConfig: { default: () => ({}) },
|
|
1122
|
+
seqConfig: { default: () => ({}) }
|
|
989
1123
|
},
|
|
990
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"],
|
|
991
1125
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1126
|
+
const stkTableId = createStkTableId();
|
|
992
1127
|
const props = __props;
|
|
993
1128
|
const emits = __emit;
|
|
994
|
-
const
|
|
995
|
-
const
|
|
1129
|
+
const tableContainerRef = ref();
|
|
1130
|
+
const colResizeIndicatorRef = ref();
|
|
996
1131
|
const currentItem = ref(null);
|
|
997
1132
|
const currentItemKey = ref(null);
|
|
998
1133
|
const currentHover = ref(null);
|
|
999
1134
|
let sortCol = ref();
|
|
1000
1135
|
let sortOrderIndex = ref(0);
|
|
1001
1136
|
const sortSwitchOrder = [null, "desc", "asc"];
|
|
1002
|
-
const tableHeaders =
|
|
1003
|
-
const tableHeaderLast =
|
|
1137
|
+
const tableHeaders = shallowRef([]);
|
|
1138
|
+
const tableHeaderLast = shallowRef([]);
|
|
1004
1139
|
const dataSourceCopy = shallowRef([...props.dataSource]);
|
|
1005
1140
|
const getEmptyCellText = computed(() => {
|
|
1006
1141
|
if (typeof props.emptyCellText === "string") {
|
|
@@ -1014,8 +1149,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1014
1149
|
props,
|
|
1015
1150
|
emits,
|
|
1016
1151
|
colKeyGen,
|
|
1017
|
-
|
|
1018
|
-
|
|
1152
|
+
colResizeIndicatorRef,
|
|
1153
|
+
tableContainerRef,
|
|
1019
1154
|
tableHeaderLast
|
|
1020
1155
|
});
|
|
1021
1156
|
const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
|
|
@@ -1033,7 +1168,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1033
1168
|
initVirtualScrollX,
|
|
1034
1169
|
updateVirtualScrollY,
|
|
1035
1170
|
updateVirtualScrollX
|
|
1036
|
-
} = useVirtualScroll({
|
|
1171
|
+
} = useVirtualScroll({ tableContainerRef, props, dataSourceCopy, tableHeaderLast, tableHeaders });
|
|
1037
1172
|
const { getFixedStyle } = useFixedStyle({
|
|
1038
1173
|
props,
|
|
1039
1174
|
tableHeaders,
|
|
@@ -1042,21 +1177,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1042
1177
|
virtualX_on,
|
|
1043
1178
|
virtualX_offsetRight
|
|
1044
1179
|
});
|
|
1045
|
-
const {
|
|
1180
|
+
const { highlightSteps, setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, stkTableId, tableContainerRef });
|
|
1046
1181
|
if (props.autoResize) {
|
|
1047
|
-
useAutoResize({
|
|
1182
|
+
useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs: 200 });
|
|
1048
1183
|
}
|
|
1049
|
-
useKeyboardArrowScroll(
|
|
1184
|
+
useKeyboardArrowScroll(tableContainerRef, {
|
|
1050
1185
|
props,
|
|
1051
1186
|
scrollTo,
|
|
1052
1187
|
virtualScroll,
|
|
1053
1188
|
virtualScrollX,
|
|
1054
|
-
tableHeaders
|
|
1189
|
+
tableHeaders,
|
|
1190
|
+
virtual_on
|
|
1055
1191
|
});
|
|
1056
1192
|
const { fixedColClassMap, dealFixedColShadow, updateFixedShadow } = useFixedCol({
|
|
1057
1193
|
props,
|
|
1058
1194
|
colKeyGen,
|
|
1059
|
-
|
|
1195
|
+
tableContainerRef,
|
|
1060
1196
|
tableHeaders,
|
|
1061
1197
|
tableHeaderLast
|
|
1062
1198
|
});
|
|
@@ -1067,6 +1203,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1067
1203
|
initVirtualScrollX();
|
|
1068
1204
|
}
|
|
1069
1205
|
);
|
|
1206
|
+
watch(
|
|
1207
|
+
() => props.virtualX,
|
|
1208
|
+
() => dealColumns()
|
|
1209
|
+
);
|
|
1070
1210
|
dealColumns();
|
|
1071
1211
|
watch(
|
|
1072
1212
|
() => props.dataSource,
|
|
@@ -1106,7 +1246,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1106
1246
|
}
|
|
1107
1247
|
function dealColumns() {
|
|
1108
1248
|
tableHeaders.value = [];
|
|
1109
|
-
tableHeaderLast.value = [];
|
|
1110
1249
|
const copyColumn = props.columns;
|
|
1111
1250
|
const deep = howDeepTheHeader(copyColumn);
|
|
1112
1251
|
const tempHeaderLast = [];
|
|
@@ -1145,9 +1284,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1145
1284
|
if (colSpan !== 1) {
|
|
1146
1285
|
col.colSpan = colSpan;
|
|
1147
1286
|
}
|
|
1148
|
-
|
|
1149
|
-
col.width = colWidth + "px";
|
|
1150
|
-
}
|
|
1287
|
+
col.__WIDTH__ = colWidth;
|
|
1151
1288
|
allChildrenLen += colChildrenLen;
|
|
1152
1289
|
allChildrenWidthSum += colWidth;
|
|
1153
1290
|
});
|
|
@@ -1176,7 +1313,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1176
1313
|
tableHeaders.value.forEach((cols, depth) => {
|
|
1177
1314
|
cols.forEach((col) => {
|
|
1178
1315
|
const colKey = colKeyGen(col);
|
|
1179
|
-
const width =
|
|
1316
|
+
const width = props.virtualX ? getCalculatedColWidth(col) + "px" : transformWidthToStr(col.width);
|
|
1180
1317
|
const style = {
|
|
1181
1318
|
width
|
|
1182
1319
|
};
|
|
@@ -1184,8 +1321,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1184
1321
|
style.minWidth = width;
|
|
1185
1322
|
style.maxWidth = width;
|
|
1186
1323
|
} else {
|
|
1187
|
-
style.minWidth =
|
|
1188
|
-
style.maxWidth =
|
|
1324
|
+
style.minWidth = transformWidthToStr(col.minWidth) ?? width;
|
|
1325
|
+
style.maxWidth = transformWidthToStr(col.maxWidth) ?? width;
|
|
1189
1326
|
}
|
|
1190
1327
|
const thStyle = {
|
|
1191
1328
|
...style,
|
|
@@ -1330,12 +1467,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1330
1467
|
dataSourceCopy.value = [...props.dataSource];
|
|
1331
1468
|
}
|
|
1332
1469
|
function scrollTo(top = 0, left = 0) {
|
|
1333
|
-
if (!
|
|
1470
|
+
if (!tableContainerRef.value)
|
|
1334
1471
|
return;
|
|
1335
1472
|
if (top !== null)
|
|
1336
|
-
|
|
1473
|
+
tableContainerRef.value.scrollTop = top;
|
|
1337
1474
|
if (left !== null)
|
|
1338
|
-
|
|
1475
|
+
tableContainerRef.value.scrollLeft = left;
|
|
1339
1476
|
}
|
|
1340
1477
|
function getTableData() {
|
|
1341
1478
|
return toRaw(dataSourceCopy.value);
|
|
@@ -1374,8 +1511,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1374
1511
|
});
|
|
1375
1512
|
return (_ctx, _cache) => {
|
|
1376
1513
|
return openBlock(), createElementBlock("div", {
|
|
1377
|
-
ref_key: "
|
|
1378
|
-
ref:
|
|
1514
|
+
ref_key: "tableContainerRef",
|
|
1515
|
+
ref: tableContainerRef,
|
|
1379
1516
|
class: normalizeClass(["stk-table", {
|
|
1380
1517
|
virtual: _ctx.virtual,
|
|
1381
1518
|
"virtual-x": _ctx.virtualX,
|
|
@@ -1389,22 +1526,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1389
1526
|
"border-body-v": props.bordered === "body-v",
|
|
1390
1527
|
stripe: props.stripe
|
|
1391
1528
|
}]),
|
|
1392
|
-
style: normalizeStyle(
|
|
1529
|
+
style: normalizeStyle([
|
|
1393
1530
|
_ctx.virtual && {
|
|
1394
1531
|
"--row-height": unref(virtualScroll).rowHeight + "px",
|
|
1395
1532
|
"--header-row-height": (props.headerRowHeight || props.rowHeight) + "px"
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
"--highlight-duration": props.highlightConfig.duration && props.highlightConfig.duration + "s",
|
|
1536
|
+
"--highlight-easing": unref(highlightSteps) ? `steps(${unref(highlightSteps)})` : ""
|
|
1396
1537
|
}
|
|
1397
|
-
),
|
|
1538
|
+
]),
|
|
1398
1539
|
onScroll: onTableScroll,
|
|
1399
1540
|
onWheel: onTableWheel
|
|
1400
1541
|
}, [
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1542
|
+
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1543
|
+
key: 0,
|
|
1544
|
+
ref_key: "colResizeIndicatorRef",
|
|
1545
|
+
ref: colResizeIndicatorRef,
|
|
1404
1546
|
class: "column-resize-indicator"
|
|
1405
|
-
}, null, 512),
|
|
1406
|
-
[vShow, _ctx.colResizable]
|
|
1407
|
-
]),
|
|
1547
|
+
}, null, 512)) : createCommentVNode("", true),
|
|
1408
1548
|
createElementVNode("table", {
|
|
1409
1549
|
class: normalizeClass(["stk-table-main", {
|
|
1410
1550
|
"fixed-mode": props.fixedMode
|
|
@@ -1456,23 +1596,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1456
1596
|
col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
|
|
1457
1597
|
key: 0,
|
|
1458
1598
|
col
|
|
1459
|
-
}, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1460
|
-
key:
|
|
1599
|
+
}, null, 8, ["col"])) : col.type === "seq" ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(col.title), 1)) : renderSlot(_ctx.$slots, "tableHeader", {
|
|
1600
|
+
key: 2,
|
|
1461
1601
|
col
|
|
1462
1602
|
}, () => [
|
|
1463
|
-
createElementVNode("span",
|
|
1603
|
+
createElementVNode("span", _hoisted_5, toDisplayString(col.title), 1)
|
|
1464
1604
|
]),
|
|
1465
|
-
col.sorter ? (openBlock(), createElementBlock("span",
|
|
1605
|
+
col.sorter ? (openBlock(), createElementBlock("span", _hoisted_6, _hoisted_8)) : createCommentVNode("", true),
|
|
1466
1606
|
_ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
1467
|
-
key:
|
|
1607
|
+
key: 4,
|
|
1468
1608
|
class: "table-header-resizer left",
|
|
1469
1609
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
|
|
1470
|
-
}, null, 40,
|
|
1610
|
+
}, null, 40, _hoisted_9)) : createCommentVNode("", true),
|
|
1471
1611
|
_ctx.colResizable ? (openBlock(), createElementBlock("div", {
|
|
1472
|
-
key:
|
|
1612
|
+
key: 5,
|
|
1473
1613
|
class: "table-header-resizer right",
|
|
1474
1614
|
onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
|
|
1475
|
-
}, null, 40,
|
|
1615
|
+
}, null, 40, _hoisted_10)) : createCommentVNode("", true)
|
|
1476
1616
|
])
|
|
1477
1617
|
], 46, _hoisted_2);
|
|
1478
1618
|
}), 128)),
|
|
@@ -1493,7 +1633,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1493
1633
|
style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
|
|
1494
1634
|
class: "padding-top-tr"
|
|
1495
1635
|
}, [
|
|
1496
|
-
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),
|
|
1497
1637
|
_ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
|
|
1498
1638
|
return openBlock(), createElementBlock("td", {
|
|
1499
1639
|
key: col.dataIndex,
|
|
@@ -1501,30 +1641,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1501
1641
|
}, null, 4);
|
|
1502
1642
|
}), 128)) : createCommentVNode("", true)
|
|
1503
1643
|
], 4)) : createCommentVNode("", true),
|
|
1504
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row,
|
|
1505
|
-
var _a;
|
|
1644
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
|
|
1506
1645
|
return openBlock(), createElementBlock("tr", {
|
|
1507
|
-
|
|
1508
|
-
|
|
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,
|
|
1509
1649
|
class: normalizeClass({
|
|
1510
1650
|
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
|
|
1511
1651
|
hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
|
|
1512
|
-
[_ctx.rowClassName(row,
|
|
1513
|
-
}),
|
|
1514
|
-
style: normalizeStyle({
|
|
1515
|
-
backgroundColor: (_a = unref(highlightRowStore)[rowKeyGen(row)]) == null ? void 0 : _a.bgc
|
|
1652
|
+
[_ctx.rowClassName(row, rowIndex)]: true
|
|
1516
1653
|
}),
|
|
1517
1654
|
onClick: (e) => onRowClick(e, row),
|
|
1518
1655
|
onDblclick: (e) => onRowDblclick(e, row),
|
|
1519
1656
|
onContextmenu: (e) => onRowMenu(e, row),
|
|
1520
1657
|
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1521
1658
|
}, [
|
|
1522
|
-
unref(virtualX_on) ? (openBlock(), createElementBlock("td",
|
|
1523
|
-
(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) => {
|
|
1524
1661
|
return openBlock(), createElementBlock("td", {
|
|
1525
1662
|
key: col.dataIndex,
|
|
1526
1663
|
"data-index": col.dataIndex,
|
|
1527
|
-
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
|
+
]),
|
|
1528
1670
|
style: normalizeStyle(cellStyleMap.value[unref(TagType).TD].get(colKeyGen(col))),
|
|
1529
1671
|
onClick: (e) => onCellClick(e, row, col)
|
|
1530
1672
|
}, [
|
|
@@ -1532,15 +1674,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1532
1674
|
key: 0,
|
|
1533
1675
|
col,
|
|
1534
1676
|
row,
|
|
1677
|
+
"row-index": rowIndex,
|
|
1678
|
+
"col-index": colIndex,
|
|
1535
1679
|
"cell-value": row[col.dataIndex]
|
|
1536
|
-
}, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1680
|
+
}, null, 8, ["col", "row", "row-index", "col-index", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1537
1681
|
key: 1,
|
|
1538
1682
|
class: "table-cell-wrapper",
|
|
1539
|
-
title: row[col.dataIndex]
|
|
1540
|
-
},
|
|
1541
|
-
|
|
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);
|
|
1542
1692
|
}), 128))
|
|
1543
|
-
],
|
|
1693
|
+
], 42, _hoisted_12);
|
|
1544
1694
|
}), 128)),
|
|
1545
1695
|
unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1546
1696
|
key: 1,
|
|
@@ -1549,7 +1699,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1549
1699
|
])
|
|
1550
1700
|
], 6),
|
|
1551
1701
|
(!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
|
|
1552
|
-
key:
|
|
1702
|
+
key: 1,
|
|
1553
1703
|
class: normalizeClass(["stk-table-no-data", { "no-data-full": _ctx.noDataFull }])
|
|
1554
1704
|
}, [
|
|
1555
1705
|
renderSlot(_ctx.$slots, "empty", {}, () => [
|