stk-table-vue 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1422 +1,1463 @@
1
- import { onMounted, onBeforeUnmount, watch, ref, computed, defineComponent, shallowRef, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, withDirectives, createElementVNode, vShow, Fragment, renderList, createCommentVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, createTextVNode } from "vue";
2
- import { interpolateRgb } from "d3-interpolate";
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
- light: { from: "#71a2fd", to: "#fff" },
9
- dark: { from: "#1e4c99", to: "#181c21" }
10
- };
11
- const Highlight_Duration = 2e3;
12
- const Highlight_Color_Change_Freq = 100;
13
- let _chromeVersion = 0;
14
- try {
15
- const userAgent = navigator.userAgent.match(/chrome\/\d+/i);
16
- if (userAgent) {
17
- _chromeVersion = +userAgent[0].split("/")[1];
18
- }
19
- } catch (e) {
20
- console.error("Cannot get Chrome version", e);
21
- }
22
- const Is_Legacy_Mode = _chromeVersion < 56;
23
- function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs }) {
24
- let resizeObserver = null;
25
- onMounted(() => {
26
- initResizeObserver();
27
- });
28
- onBeforeUnmount(() => {
29
- removeResizeObserver();
30
- });
31
- function initResizeObserver() {
32
- if (window.ResizeObserver) {
33
- if (!tableContainer.value) {
34
- const watchDom = watch(
35
- () => tableContainer,
36
- () => {
37
- initResizeObserver();
38
- watchDom();
39
- }
40
- );
41
- return;
42
- }
43
- resizeObserver = new ResizeObserver(resizeCallback);
44
- resizeObserver.observe(tableContainer.value);
45
- } else {
46
- window.addEventListener("resize", resizeCallback);
47
- }
48
- }
49
- function removeResizeObserver() {
50
- if (resizeObserver) {
51
- resizeObserver.disconnect();
52
- resizeObserver = null;
53
- } else {
54
- window.removeEventListener("resize", resizeCallback);
55
- }
56
- }
57
- let debounceTime = 0;
58
- function resizeCallback() {
59
- if (debounceTime) {
60
- window.clearTimeout(debounceTime);
61
- }
62
- debounceTime = window.setTimeout(() => {
63
- if (props.autoResize) {
64
- initVirtualScroll();
65
- if (typeof props.autoResize === "function") {
66
- props.autoResize();
67
- }
68
- }
69
- debounceTime = 0;
70
- }, debounceMs);
71
- }
72
- }
73
- function insertToOrderedArray(sortState, newItem, targetArray) {
74
- const { dataIndex, order } = sortState;
75
- let { sortType } = sortState;
76
- if (!sortType)
77
- sortType = typeof newItem[dataIndex];
78
- const data = [...targetArray];
79
- if (!order) {
80
- data.unshift(newItem);
81
- return data;
82
- }
83
- let sIndex = 0;
84
- let eIndex = data.length - 1;
85
- const targetVal = newItem[dataIndex];
86
- while (sIndex <= eIndex) {
87
- const midIndex = Math.floor((sIndex + eIndex) / 2);
88
- const midVal = data[midIndex][dataIndex];
89
- const compareRes = strCompare(midVal, targetVal, sortType);
90
- if (compareRes === 0) {
91
- sIndex = midIndex;
92
- break;
93
- } else if (compareRes === -1) {
94
- if (order === "asc")
95
- sIndex = midIndex + 1;
96
- else
97
- eIndex = midIndex - 1;
98
- } else {
99
- if (order === "asc")
100
- eIndex = midIndex - 1;
101
- else
102
- sIndex = midIndex + 1;
103
- }
104
- }
105
- data.splice(sIndex, 0, newItem);
106
- return data;
107
- }
108
- function strCompare(a, b, type) {
109
- if (type === "number") {
110
- if (+a > +b)
111
- return 1;
112
- else if (+a === +b)
113
- return 0;
114
- else
115
- return -1;
116
- } else {
117
- return String(a).localeCompare(b);
118
- }
119
- }
120
- function tableSort(sortOption, order, dataSource) {
121
- if (!(dataSource == null ? void 0 : dataSource.length))
122
- return dataSource || [];
123
- let targetDataSource = [...dataSource];
124
- if (typeof sortOption.sorter === "function") {
125
- const customSorterData = sortOption.sorter(targetDataSource, { order, column: sortOption });
126
- if (customSorterData)
127
- targetDataSource = customSorterData;
128
- } else if (order) {
129
- const sortField = sortOption.sortField || sortOption.dataIndex;
130
- let { sortType } = sortOption;
131
- if (!sortType)
132
- sortType = typeof dataSource[0][sortField];
133
- if (sortType === "number") {
134
- const nanArr = [];
135
- const numArr = [];
136
- for (let i = 0; i < targetDataSource.length; i++) {
137
- const row = targetDataSource[i];
138
- if (row[sortField] === null || row[sortField] === "" || typeof row[sortField] === "boolean" || Number.isNaN(+row[sortField])) {
139
- nanArr.push(row);
140
- } else {
141
- numArr.push(row);
142
- }
143
- }
144
- if (order === "asc") {
145
- numArr.sort((a, b) => +a[sortField] - +b[sortField]);
146
- targetDataSource = [...nanArr, ...numArr];
147
- } else {
148
- numArr.sort((a, b) => +b[sortField] - +a[sortField]);
149
- targetDataSource = [...numArr, ...nanArr];
150
- }
151
- } else {
152
- if (order === "asc") {
153
- targetDataSource.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]));
154
- } else {
155
- targetDataSource.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]) * -1);
156
- }
157
- }
158
- }
159
- return targetDataSource;
160
- }
161
- function howDeepTheHeader(arr, level = 1) {
162
- const levels = [level];
163
- arr.forEach((item) => {
164
- var _a;
165
- if ((_a = item.children) == null ? void 0 : _a.length) {
166
- levels.push(howDeepTheHeader(item.children, level + 1));
167
- }
168
- });
169
- return Math.max(...levels);
170
- }
171
- function getColWidth(col) {
172
- if (typeof (col == null ? void 0 : col.width) === "number") {
173
- return Math.floor(col.width ?? Default_Col_Width);
174
- }
175
- return parseInt((col == null ? void 0 : col.width) ?? Default_Col_Width);
176
- }
177
- function useColResize({
178
- tableContainer,
179
- tableHeaderLast,
180
- colResizeIndicator,
181
- props,
182
- emits,
183
- colKeyGen
184
- }) {
185
- const isColResizing = ref(false);
186
- let colResizeState = {
187
- currentCol: null,
188
- currentColIndex: 0,
189
- lastCol: null,
190
- startX: 0,
191
- startOffsetTableX: 0
192
- };
193
- onMounted(() => {
194
- initColResizeEvent();
195
- });
196
- onBeforeUnmount(() => {
197
- clearColResizeEvent();
198
- });
199
- function initColResizeEvent() {
200
- window.addEventListener("mousemove", onThResizeMouseMove);
201
- window.addEventListener("mouseup", onThResizeMouseUp);
202
- }
203
- function clearColResizeEvent() {
204
- window.removeEventListener("mousemove", onThResizeMouseMove);
205
- window.removeEventListener("mouseup", onThResizeMouseUp);
206
- }
207
- function onThResizeMouseDown(e, col, isPrev = false) {
208
- if (!tableContainer.value)
209
- return;
210
- e.stopPropagation();
211
- e.preventDefault();
212
- const { clientX } = e;
213
- const { scrollLeft, scrollTop } = tableContainer.value;
214
- const { left } = tableContainer.value.getBoundingClientRect();
215
- let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen(it) === colKeyGen(col));
216
- if (isPrev) {
217
- colIndex -= 1;
218
- col = tableHeaderLast.value[colIndex];
219
- }
220
- const offsetTableX = clientX - left + scrollLeft;
221
- isColResizing.value = true;
222
- Object.assign(colResizeState, {
223
- currentCol: col,
224
- currentColIndex: colIndex,
225
- lastCol: findLastChildCol(col),
226
- startX: clientX,
227
- startOffsetTableX: offsetTableX
228
- });
229
- if (colResizeIndicator.value) {
230
- const style = colResizeIndicator.value.style;
231
- style.display = "block";
232
- style.left = offsetTableX + "px";
233
- style.top = scrollTop + "px";
234
- }
235
- }
236
- function onThResizeMouseMove(e) {
237
- if (!isColResizing.value)
238
- return;
239
- e.stopPropagation();
240
- e.preventDefault();
241
- const { lastCol, startX, startOffsetTableX } = colResizeState;
242
- const { clientX } = e;
243
- let moveX = clientX - startX;
244
- const currentColWidth = getColWidth(lastCol);
245
- if (currentColWidth + moveX < props.colMinWidth) {
246
- moveX = -currentColWidth;
247
- }
248
- const offsetTableX = startOffsetTableX + moveX;
249
- if (!colResizeIndicator.value)
250
- return;
251
- colResizeIndicator.value.style.left = offsetTableX + "px";
252
- }
253
- function onThResizeMouseUp(e) {
254
- if (!isColResizing.value)
255
- return;
256
- const { startX, lastCol } = colResizeState;
257
- const { clientX } = e;
258
- const moveX = clientX - startX;
259
- let width = getColWidth(lastCol) + moveX;
260
- if (width < props.colMinWidth)
261
- width = props.colMinWidth;
262
- const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
263
- if (!curCol)
264
- return;
265
- curCol.width = width + "px";
266
- emits("update:columns", [...props.columns]);
267
- if (colResizeIndicator.value) {
268
- const style = colResizeIndicator.value.style;
269
- style.display = "none";
270
- style.left = "0";
271
- style.top = "0";
272
- }
273
- isColResizing.value = false;
274
- colResizeState = {
275
- currentCol: null,
276
- currentColIndex: 0,
277
- lastCol: null,
278
- startX: 0,
279
- startOffsetTableX: 0
280
- };
281
- }
282
- function findLastChildCol(column) {
283
- var _a;
284
- if ((_a = column == null ? void 0 : column.children) == null ? void 0 : _a.length) {
285
- const lastChild = column.children.at(-1);
286
- return findLastChildCol(lastChild);
287
- }
288
- return column;
289
- }
290
- return {
291
- isColResizing,
292
- onThResizeMouseDown,
293
- onThResizeMouseMove,
294
- onThResizeMouseUp
295
- };
296
- }
297
- function useFixedCol({ props, tableHeaderLast, tableContainer }) {
298
- const fixedShadow = ref({
299
- showL: false,
300
- showR: false
301
- });
302
- let fixedShadowCols = [];
303
- function dealFixedColShadow() {
304
- if (!props.fixedColShadow)
305
- return;
306
- fixedShadowCols = [];
307
- let lastLeftCol = null;
308
- for (let i = tableHeaderLast.value.length - 1; i >= 0; i--) {
309
- const col = tableHeaderLast.value[i];
310
- if (col.fixed === "left") {
311
- lastLeftCol = col;
312
- break;
313
- }
314
- }
315
- let node = { __PARENT__: lastLeftCol };
316
- while (node = node.__PARENT__) {
317
- if (node.fixed) {
318
- fixedShadowCols.push(node);
319
- }
320
- }
321
- const lastRightCol = tableHeaderLast.value.find((it) => it.fixed === "right");
322
- node = { __PARENT__: lastRightCol };
323
- while (node = node.__PARENT__) {
324
- if (node.fixed) {
325
- fixedShadowCols.push(node);
326
- }
327
- }
328
- }
329
- function getFixedColClass(col) {
330
- const { showR, showL } = fixedShadow.value;
331
- const showShadow = props.fixedColShadow && col.fixed && (showL && col.fixed === "left" || showR && col.fixed === "right") && fixedShadowCols.includes(col);
332
- const classObj = {
333
- "fixed-cell": col.fixed,
334
- ["fixed-cell--" + col.fixed]: col.fixed,
335
- "fixed-cell--shadow": showShadow
336
- };
337
- return classObj;
338
- }
339
- function updateFixedShadow() {
340
- if (!props.fixedColShadow)
341
- return;
342
- const { clientWidth, scrollWidth, scrollLeft } = tableContainer.value;
343
- fixedShadow.value.showL = Boolean(scrollLeft);
344
- fixedShadow.value.showR = Math.abs(scrollWidth - scrollLeft - clientWidth) > 0.5;
345
- }
346
- return {
347
- /** 固定列class */
348
- getFixedColClass,
349
- /** 处理固定列阴影 */
350
- dealFixedColShadow,
351
- /** 滚动条变化时,更新需要展示阴影的列 */
352
- updateFixedShadow
353
- };
354
- }
355
- function useFixedStyle({ props, tableHeaderLast, virtualScroll, virtualScrollX, virtualX_on, virtualX_offsetRight }) {
356
- const fixedColumnsPositionStore = computed(() => {
357
- const store = {};
358
- const cols = [...tableHeaderLast.value];
359
- let left = 0;
360
- let rightStartIndex = 0;
361
- for (let i = 0; i < cols.length; i++) {
362
- const item = cols[i];
363
- if (item.fixed === "left") {
364
- store[item.dataIndex] = left;
365
- left += getColWidth(item);
366
- }
367
- if (!rightStartIndex && item.fixed === "right") {
368
- rightStartIndex = i;
369
- }
370
- }
371
- let right = 0;
372
- for (let i = cols.length - 1; i >= rightStartIndex; i--) {
373
- const item = cols[i];
374
- if (item.fixed === "right") {
375
- store[item.dataIndex] = right;
376
- right += getColWidth(item);
377
- }
378
- }
379
- return store;
380
- });
381
- function getFixedStyle(tagType, col, depth = 0) {
382
- const { fixed, dataIndex } = col;
383
- const isFixedLeft = fixed === "left";
384
- const style = {};
385
- if (Is_Legacy_Mode) {
386
- style.position = "relative";
387
- } else {
388
- style.position = "sticky";
389
- }
390
- if (tagType === 1) {
391
- if (Is_Legacy_Mode) {
392
- style.top = virtualScroll.value.scrollTop + depth * props.rowHeight + "px";
393
- } else {
394
- style.top = depth * props.rowHeight + "px";
395
- }
396
- style.zIndex = isFixedLeft ? "5" : "4";
397
- } else {
398
- style.zIndex = isFixedLeft ? "3" : "2";
399
- }
400
- if (fixed === "left" || fixed === "right") {
401
- if (Is_Legacy_Mode) {
402
- if (isFixedLeft) {
403
- if (virtualX_on.value)
404
- style.left = virtualScrollX.value.scrollLeft - virtualScrollX.value.offsetLeft + "px";
405
- else
406
- style.left = virtualScrollX.value.scrollLeft + "px";
407
- } else {
408
- style.right = `${virtualX_offsetRight.value}px`;
409
- }
410
- } else {
411
- if (isFixedLeft) {
412
- style.left = fixedColumnsPositionStore.value[dataIndex] + "px";
413
- } else {
414
- style.right = fixedColumnsPositionStore.value[dataIndex] + "px";
415
- }
416
- }
417
- }
418
- return style;
419
- }
420
- return {
421
- getFixedStyle
422
- };
423
- }
424
- function useHighlight({ props, tableContainer, rowKeyGen }) {
425
- const highlightInter = computed(() => {
426
- return interpolateRgb(Highlight_Color[props.theme].from, Highlight_Color[props.theme].to);
427
- });
428
- const highlightDimRows = /* @__PURE__ */ new Set();
429
- const highlightDimRowsTimeout = /* @__PURE__ */ new Map();
430
- const highlightDimCellsTimeout = /* @__PURE__ */ new Map();
431
- let calcHighlightDimLoop = false;
432
- function calcHighlightLoop() {
433
- if (calcHighlightDimLoop)
434
- return;
435
- calcHighlightDimLoop = true;
436
- const recursion = () => {
437
- window.setTimeout(() => {
438
- const nowTs = Date.now();
439
- const needDeleteRows = [];
440
- highlightDimRows.forEach((row) => {
441
- const progress = (nowTs - row._bgc_progress_ms) / Highlight_Duration;
442
- if (0 < progress && progress < 1) {
443
- row._bgc = highlightInter.value(progress);
444
- } else {
445
- row._bgc = "";
446
- needDeleteRows.push(row);
447
- }
448
- });
449
- needDeleteRows.forEach((row) => highlightDimRows.delete(row));
450
- if (highlightDimRows.size > 0) {
451
- recursion();
452
- } else {
453
- calcHighlightDimLoop = false;
454
- }
455
- }, Highlight_Color_Change_Freq);
456
- };
457
- recursion();
458
- }
459
- function setHighlightDimCell(rowKeyValue, dataIndex) {
460
- var _a;
461
- const cellEl = (_a = tableContainer.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"]>[data-index="${dataIndex}"]`);
462
- if (!cellEl)
463
- return;
464
- if (cellEl.classList.contains("highlight-cell")) {
465
- cellEl.classList.remove("highlight-cell");
466
- void cellEl.offsetHeight;
467
- }
468
- cellEl.classList.add("highlight-cell");
469
- window.clearTimeout(highlightDimCellsTimeout.get(rowKeyValue));
470
- highlightDimCellsTimeout.set(
471
- rowKeyValue,
472
- window.setTimeout(() => {
473
- cellEl.classList.remove("highlight-cell");
474
- highlightDimCellsTimeout.delete(rowKeyValue);
475
- }, Highlight_Duration)
476
- );
477
- }
478
- function setHighlightDimRow(rowKeyValues) {
479
- var _a, _b;
480
- if (!Array.isArray(rowKeyValues))
481
- rowKeyValues = [rowKeyValues];
482
- if (props.virtual) {
483
- const nowTs = Date.now();
484
- for (let i = 0; i < rowKeyValues.length; i++) {
485
- const rowKeyValue = rowKeyValues[i];
486
- const row = props.dataSource.find((it) => rowKeyGen(it) === rowKeyValue);
487
- if (!row)
488
- continue;
489
- row._bgc_progress_ms = nowTs;
490
- highlightDimRows.add(row);
491
- }
492
- calcHighlightLoop();
493
- } else {
494
- let needRepaint = false;
495
- const rowElTemp = [];
496
- for (let i = 0; i < rowKeyValues.length; i++) {
497
- const rowKeyValue = rowKeyValues[i];
498
- const rowEl = (_a = tableContainer.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"]`);
499
- if (!rowEl)
500
- continue;
501
- if (rowEl.classList.contains("highlight-row")) {
502
- rowEl.classList.remove("highlight-row");
503
- needRepaint = true;
504
- }
505
- rowElTemp.push(rowEl);
506
- window.clearTimeout(highlightDimRowsTimeout.get(rowKeyValue));
507
- highlightDimRowsTimeout.set(
508
- rowKeyValue,
509
- window.setTimeout(() => {
510
- rowEl.classList.remove("highlight-row");
511
- highlightDimRowsTimeout.delete(rowKeyValue);
512
- }, Highlight_Duration)
513
- );
514
- }
515
- if (needRepaint) {
516
- void ((_b = tableContainer.value) == null ? void 0 : _b.offsetWidth);
517
- }
518
- rowElTemp.forEach((el) => el.classList.add("highlight-row"));
519
- }
520
- }
521
- return {
522
- setHighlightDimRow,
523
- setHighlightDimCell
524
- };
525
- }
526
- const SCROLL_CODES = ["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft", "PageUp", "PageDown"];
527
- function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders }) {
528
- let isMouseOver = false;
529
- onMounted(() => {
530
- var _a, _b, _c;
531
- window.addEventListener("keydown", handleKeydown);
532
- (_a = targetElement.value) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnter);
533
- (_b = targetElement.value) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeave);
534
- (_c = targetElement.value) == null ? void 0 : _c.addEventListener("mousedown", handleMouseDown);
535
- });
536
- onBeforeUnmount(() => {
537
- var _a, _b, _c;
538
- window.removeEventListener("keydown", handleKeydown);
539
- (_a = targetElement.value) == null ? void 0 : _a.removeEventListener("mouseenter", handleMouseEnter);
540
- (_b = targetElement.value) == null ? void 0 : _b.removeEventListener("mouseleave", handleMouseLeave);
541
- (_c = targetElement.value) == null ? void 0 : _c.removeEventListener("mousedown", handleMouseDown);
542
- });
543
- function handleKeydown(e) {
544
- if (!SCROLL_CODES.includes(e.code))
545
- return;
546
- if (!isMouseOver)
547
- return;
548
- e.preventDefault();
549
- const { scrollTop, rowHeight, pageSize } = virtualScroll.value;
550
- const { scrollLeft } = virtualScrollX.value;
551
- const { headless, headerRowHeight } = props;
552
- const headerHeight = headless ? 0 : tableHeaders.value.length * (headerRowHeight || rowHeight);
553
- if (e.code === SCROLL_CODES[0]) {
554
- scrollTo(scrollTop - rowHeight, null);
555
- } else if (e.code === SCROLL_CODES[1]) {
556
- scrollTo(null, scrollLeft + rowHeight);
557
- } else if (e.code === SCROLL_CODES[2]) {
558
- scrollTo(scrollTop + rowHeight, null);
559
- } else if (e.code === SCROLL_CODES[3]) {
560
- scrollTo(null, scrollLeft - rowHeight);
561
- } else if (e.code === SCROLL_CODES[4]) {
562
- scrollTo(scrollTop - rowHeight * pageSize - headerHeight, null);
563
- } else if (e.code === SCROLL_CODES[5]) {
564
- scrollTo(scrollTop + rowHeight * pageSize - headerHeight, null);
565
- }
566
- }
567
- function handleMouseEnter() {
568
- isMouseOver = true;
569
- }
570
- function handleMouseLeave() {
571
- isMouseOver = false;
572
- }
573
- function handleMouseDown() {
574
- if (!isMouseOver)
575
- isMouseOver = true;
576
- }
577
- }
578
- function useThDrag({ props, emits }) {
579
- let dragStartKey = void 0;
580
- function findParentTH(el) {
581
- let n = el;
582
- while (n) {
583
- if (n.tagName === "TH")
584
- return n;
585
- n = n.parentElement;
586
- }
587
- }
588
- function onThDragStart(e) {
589
- const th = findParentTH(e.target);
590
- if (!th)
591
- return;
592
- dragStartKey = th.dataset.colKey;
593
- emits("th-drag-start", dragStartKey);
594
- }
595
- function onThDragOver(e) {
596
- const th = findParentTH(e.target);
597
- if (!th)
598
- return;
599
- const isHeaderDraggable2 = th.getAttribute("draggable") === "true";
600
- if (!isHeaderDraggable2) {
601
- return;
602
- }
603
- e.preventDefault();
604
- }
605
- function onThDrop(e) {
606
- const th = findParentTH(e.target);
607
- if (!th)
608
- return;
609
- if (dragStartKey !== th.dataset.colKey) {
610
- emits("col-order-change", dragStartKey, th.dataset.colKey);
611
- }
612
- emits("th-drop", th.dataset.colKey);
613
- }
614
- const isHeaderDragFun = typeof props.headerDrag === "function";
615
- function isHeaderDraggable(col) {
616
- if (isHeaderDragFun) {
617
- return props.headerDrag(col);
618
- } else {
619
- return props.headerDrag;
620
- }
621
- }
622
- return {
623
- onThDragStart,
624
- onThDragOver,
625
- onThDrop,
626
- isHeaderDraggable
627
- };
628
- }
629
- const VUE2_SCROLL_TIMEOUT_MS = 200;
630
- function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLast }) {
631
- const virtualScroll = ref({
632
- containerHeight: 0,
633
- rowHeight: props.rowHeight,
634
- pageSize: 10,
635
- startIndex: 0,
636
- endIndex: 0,
637
- offsetTop: 0,
638
- scrollTop: 0
639
- });
640
- const virtualScrollX = ref({
641
- containerWidth: 0,
642
- startIndex: 0,
643
- endIndex: 0,
644
- offsetLeft: 0,
645
- scrollLeft: 0
646
- });
647
- const virtual_on = computed(() => {
648
- return props.virtual && dataSourceCopy.value.length > virtualScroll.value.pageSize * 2;
649
- });
650
- const virtual_dataSourcePart = computed(() => {
651
- if (!virtual_on.value)
652
- return dataSourceCopy.value;
653
- const { startIndex, endIndex } = virtualScroll.value;
654
- return dataSourceCopy.value.slice(startIndex, endIndex);
655
- });
656
- const virtual_offsetBottom = computed(() => {
657
- if (!virtual_on.value)
658
- return 0;
659
- const { startIndex, rowHeight } = virtualScroll.value;
660
- return (dataSourceCopy.value.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
661
- });
662
- const virtualX_on = computed(() => {
663
- return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getColWidth(col), 0) > virtualScrollX.value.containerWidth + 100;
664
- });
665
- const virtualX_columnPart = computed(() => {
666
- if (virtualX_on.value) {
667
- const leftCols = [];
668
- const rightCols = [];
669
- const { startIndex, endIndex } = virtualScrollX.value;
670
- for (let i = 0; i < startIndex; i++) {
671
- const col = tableHeaderLast.value[i];
672
- if (col.fixed === "left")
673
- leftCols.push(col);
674
- }
675
- for (let i = endIndex; i < tableHeaderLast.value.length; i++) {
676
- const col = tableHeaderLast.value[i];
677
- if (col.fixed === "right")
678
- rightCols.push(col);
679
- }
680
- const mainColumns = tableHeaderLast.value.slice(startIndex, endIndex);
681
- return leftCols.concat(mainColumns).concat(rightCols);
682
- }
683
- return tableHeaderLast.value;
684
- });
685
- const virtualX_offsetRight = computed(() => {
686
- if (!virtualX_on.value)
687
- return 0;
688
- let width = 0;
689
- for (let i = virtualScrollX.value.endIndex; i < tableHeaderLast.value.length; i++) {
690
- const col = tableHeaderLast.value[i];
691
- if (col.fixed !== "right") {
692
- width += getColWidth(col);
693
- }
694
- }
695
- return width;
696
- });
697
- function initVirtualScrollY(height) {
698
- if (!virtual_on.value)
699
- return;
700
- const { offsetHeight, scrollTop } = tableContainer.value || {};
701
- const { rowHeight } = virtualScroll.value;
702
- let containerHeight;
703
- if (typeof height === "number") {
704
- containerHeight = height;
705
- } else {
706
- containerHeight = offsetHeight || Default_Table_Height;
707
- }
708
- Object.assign(virtualScroll.value, {
709
- containerHeight,
710
- pageSize: Math.ceil(containerHeight / rowHeight) + 1
711
- // 这里最终+1,因为headless=true无头时,需要上下各预渲染一行。
712
- });
713
- updateVirtualScrollY(scrollTop);
714
- }
715
- function initVirtualScrollX() {
716
- if (!props.virtualX)
717
- return;
718
- const { offsetWidth, scrollLeft } = tableContainer.value || {};
719
- virtualScrollX.value.containerWidth = offsetWidth || Default_Table_Width;
720
- updateVirtualScrollX(scrollLeft);
721
- }
722
- function initVirtualScroll(height) {
723
- initVirtualScrollY(height);
724
- initVirtualScrollX();
725
- }
726
- let vue2ScrollYTimeout = null;
727
- function updateVirtualScrollY(sTop = 0) {
728
- const { rowHeight, pageSize, scrollTop, startIndex: oldStartIndex } = virtualScroll.value;
729
- const startIndex = Math.floor(sTop / rowHeight);
730
- const offsetTop = startIndex * rowHeight;
731
- let endIndex = startIndex + pageSize;
732
- if (endIndex > dataSourceCopy.value.length) {
733
- endIndex = dataSourceCopy.value.length;
734
- }
735
- if (vue2ScrollYTimeout) {
736
- window.clearTimeout(vue2ScrollYTimeout);
737
- }
738
- if (!props.optimizeVue2Scroll || sTop <= scrollTop || Math.abs(oldStartIndex - startIndex) >= pageSize) {
739
- Object.assign(virtualScroll.value, {
740
- startIndex,
741
- offsetTop,
742
- endIndex,
743
- scrollTop: sTop
744
- });
745
- } else {
746
- Object.assign(virtualScroll.value, { endIndex, scrollTop: sTop });
747
- vue2ScrollYTimeout = window.setTimeout(() => {
748
- Object.assign(virtualScroll.value, { startIndex, offsetTop });
749
- }, VUE2_SCROLL_TIMEOUT_MS);
750
- }
751
- }
752
- let vue2ScrollXTimeout = null;
753
- function updateVirtualScrollX(sLeft = 0) {
754
- var _a;
755
- const headerLength = (_a = tableHeaderLast.value) == null ? void 0 : _a.length;
756
- const { scrollLeft } = virtualScrollX.value;
757
- if (!headerLength)
758
- return;
759
- let startIndex = 0;
760
- let offsetLeft = 0;
761
- let colWidthSum = 0;
762
- for (let colIndex = 0; colIndex < headerLength; colIndex++) {
763
- startIndex++;
764
- const col = tableHeaderLast.value[colIndex];
765
- if (col.fixed === "left")
766
- continue;
767
- const colWidth = getColWidth(col);
768
- colWidthSum += colWidth;
769
- if (colWidthSum >= sLeft) {
770
- offsetLeft = colWidthSum - colWidth;
771
- startIndex--;
772
- break;
773
- }
774
- }
775
- colWidthSum = 0;
776
- let endIndex = headerLength;
777
- for (let colIndex = startIndex + 1; colIndex < headerLength; colIndex++) {
778
- const col = tableHeaderLast.value[colIndex];
779
- colWidthSum += getColWidth(col);
780
- if (colWidthSum >= virtualScrollX.value.containerWidth) {
781
- endIndex = colIndex + 1;
782
- break;
783
- }
784
- }
785
- if (endIndex > headerLength) {
786
- endIndex = headerLength;
787
- }
788
- if (vue2ScrollXTimeout) {
789
- window.clearTimeout(vue2ScrollXTimeout);
790
- }
791
- if (!props.optimizeVue2Scroll || sLeft <= scrollLeft) {
792
- Object.assign(virtualScrollX.value, { startIndex, endIndex, offsetLeft, scrollLeft: sLeft });
793
- } else {
794
- Object.assign(virtualScrollX.value, { endIndex, scrollLeft: sLeft });
795
- vue2ScrollXTimeout = window.setTimeout(() => {
796
- Object.assign(virtualScrollX.value, { startIndex, offsetLeft });
797
- }, VUE2_SCROLL_TIMEOUT_MS);
798
- }
799
- }
800
- return {
801
- virtualScroll,
802
- virtualScrollX,
803
- virtual_on,
804
- virtual_dataSourcePart,
805
- virtual_offsetBottom,
806
- virtualX_on,
807
- virtualX_columnPart,
808
- virtualX_offsetRight,
809
- initVirtualScroll,
810
- initVirtualScrollY,
811
- initVirtualScrollX,
812
- updateVirtualScrollY,
813
- updateVirtualScrollX
814
- };
815
- }
816
- const _hoisted_1 = { key: 0 };
817
- const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
818
- const _hoisted_3 = { class: "table-header-cell-wrapper" };
819
- const _hoisted_4 = { class: "table-header-title" };
820
- const _hoisted_5 = {
821
- key: 2,
822
- class: "table-header-sorter"
823
- };
824
- const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
825
- xmlns: "http://www.w3.org/2000/svg",
826
- width: "16px",
827
- height: "16px",
828
- viewBox: "0 0 16 16"
829
- }, [
830
- /* @__PURE__ */ createElementVNode("polygon", {
831
- class: "arrow-up",
832
- fill: "#757699",
833
- points: "8 2 4.8 6 11.2 6"
834
- }),
835
- /* @__PURE__ */ createElementVNode("polygon", {
836
- class: "arrow-down",
837
- transform: "translate(8, 12) rotate(-180) translate(-8, -12) ",
838
- points: "8 10 4.8 14 11.2 14"
839
- })
840
- ], -1);
841
- const _hoisted_7 = [
842
- _hoisted_6
843
- ];
844
- const _hoisted_8 = ["onMousedown"];
845
- const _hoisted_9 = ["onMousedown"];
846
- const _hoisted_10 = {
847
- key: 0,
848
- class: "virtual-x-left",
849
- style: { "padding": "0" }
850
- };
851
- const _hoisted_11 = ["data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
852
- const _hoisted_12 = {
853
- key: 0,
854
- class: "virtual-x-left",
855
- style: { "padding": "0" }
856
- };
857
- const _hoisted_13 = ["data-index", "onClick"];
858
- const _hoisted_14 = ["title"];
859
- const _sfc_main = /* @__PURE__ */ defineComponent({
860
- __name: "StkTable",
861
- props: {
862
- width: { default: "" },
863
- minWidth: { default: "" },
864
- maxWidth: { default: "" },
865
- stripe: { type: Boolean, default: false },
866
- fixedMode: { type: Boolean, default: false },
867
- headless: { type: Boolean, default: false },
868
- theme: { default: "light" },
869
- rowHeight: { default: Default_Row_Height },
870
- headerRowHeight: { default: null },
871
- virtual: { type: Boolean, default: false },
872
- virtualX: { type: Boolean, default: false },
873
- columns: { default: () => [] },
874
- dataSource: { default: () => [] },
875
- rowKey: { type: [String, Function], default: "" },
876
- colKey: { type: [String, Function], default: "dataIndex" },
877
- emptyCellText: { default: "--" },
878
- noDataFull: { type: Boolean, default: false },
879
- showNoData: { type: Boolean, default: true },
880
- sortRemote: { type: Boolean, default: false },
881
- showHeaderOverflow: { type: Boolean, default: false },
882
- showOverflow: { type: Boolean, default: false },
883
- showTrHoverClass: { type: Boolean, default: false },
884
- headerDrag: { type: [Boolean, Function], default: false },
885
- rowClassName: { type: Function, default: () => "" },
886
- colResizable: { type: Boolean, default: false },
887
- colMinWidth: { default: 10 },
888
- bordered: { type: [Boolean, String], default: true },
889
- autoResize: { type: [Boolean, Function], default: true },
890
- fixedColShadow: { type: Boolean, default: false },
891
- optimizeVue2Scroll: { type: Boolean, default: false }
892
- },
893
- 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"],
894
- setup(__props, { expose: __expose, emit: __emit }) {
895
- const props = __props;
896
- const emits = __emit;
897
- const tableContainer = ref();
898
- const colResizeIndicator = ref();
899
- const currentItem = ref(null);
900
- const currentItemKey = ref(null);
901
- const currentHover = ref(null);
902
- let sortCol = ref();
903
- let sortOrderIndex = ref(0);
904
- const sortSwitchOrder = [null, "desc", "asc"];
905
- const tableHeaders = ref([]);
906
- const tableHeaderLast = ref([]);
907
- const dataSourceCopy = shallowRef([...props.dataSource]);
908
- const rowKeyGenStore = /* @__PURE__ */ new WeakMap();
909
- const { isColResizing, onThResizeMouseDown } = useColResize({
910
- props,
911
- emits,
912
- colKeyGen,
913
- colResizeIndicator,
914
- tableContainer,
915
- tableHeaderLast
916
- });
917
- const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
918
- const {
919
- virtualScroll,
920
- virtualScrollX,
921
- virtual_on,
922
- virtual_dataSourcePart,
923
- virtual_offsetBottom,
924
- virtualX_on,
925
- virtualX_columnPart,
926
- virtualX_offsetRight,
927
- initVirtualScroll,
928
- initVirtualScrollY,
929
- initVirtualScrollX,
930
- updateVirtualScrollY,
931
- updateVirtualScrollX
932
- } = useVirtualScroll({ tableContainer, props, dataSourceCopy, tableHeaderLast });
933
- const { getFixedStyle } = useFixedStyle({
934
- props,
935
- tableHeaderLast,
936
- virtualScroll,
937
- virtualScrollX,
938
- virtualX_on,
939
- virtualX_offsetRight
940
- });
941
- const { setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, tableContainer, rowKeyGen });
942
- if (props.autoResize) {
943
- useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs: 200 });
944
- }
945
- useKeyboardArrowScroll(tableContainer, {
946
- props,
947
- scrollTo,
948
- virtualScroll,
949
- virtualScrollX,
950
- tableHeaders
951
- });
952
- const { getFixedColClass, dealFixedColShadow, updateFixedShadow } = useFixedCol({
953
- props,
954
- tableContainer,
955
- tableHeaderLast
956
- });
957
- watch(
958
- () => props.columns,
959
- () => {
960
- dealColumns();
961
- initVirtualScrollX();
962
- }
963
- );
964
- dealColumns();
965
- watch(
966
- () => props.dataSource,
967
- (val) => {
968
- if (!val) {
969
- console.warn("invalid dataSource");
970
- return;
971
- }
972
- let needInitVirtualScrollY = false;
973
- if (dataSourceCopy.value.length !== val.length) {
974
- needInitVirtualScrollY = true;
975
- }
976
- dataSourceCopy.value = [...val];
977
- if (needInitVirtualScrollY)
978
- initVirtualScrollY();
979
- if (sortCol.value) {
980
- const column = tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
981
- onColumnSort(column, false);
982
- }
983
- updateFixedShadow();
984
- },
985
- {
986
- deep: false
987
- }
988
- );
989
- watch(() => props.fixedColShadow, dealFixedColShadow);
990
- onMounted(() => {
991
- initVirtualScroll();
992
- updateFixedShadow();
993
- });
994
- function dealColumns() {
995
- tableHeaders.value = [];
996
- tableHeaderLast.value = [];
997
- const copyColumn = props.columns;
998
- const deep = howDeepTheHeader(copyColumn);
999
- const tempHeaderLast = [];
1000
- if (deep > 1 && props.virtualX) {
1001
- console.error("多级表头不支持横向虚拟滚动");
1002
- }
1003
- function flat(arr, parent, depth = 0) {
1004
- if (!tableHeaders.value[depth]) {
1005
- tableHeaders.value[depth] = [];
1006
- }
1007
- let allChildrenLen = 0;
1008
- arr.forEach((col) => {
1009
- col.__PARENT__ = parent;
1010
- let colChildrenLen = 1;
1011
- if (col.children) {
1012
- colChildrenLen = flat(
1013
- col.children,
1014
- col,
1015
- depth + 1
1016
- /* , col.fixed */
1017
- );
1018
- } else {
1019
- tempHeaderLast.push(col);
1020
- }
1021
- tableHeaders.value[depth].push(col);
1022
- const rowSpan = col.children ? 1 : deep - depth;
1023
- const colSpan = colChildrenLen;
1024
- if (rowSpan !== 1) {
1025
- col.rowSpan = rowSpan;
1026
- }
1027
- if (colSpan !== 1) {
1028
- col.colSpan = colSpan;
1029
- }
1030
- allChildrenLen += colChildrenLen;
1031
- });
1032
- return allChildrenLen;
1033
- }
1034
- flat(copyColumn, null);
1035
- tableHeaderLast.value = tempHeaderLast;
1036
- dealFixedColShadow();
1037
- }
1038
- function rowKeyGen(row) {
1039
- if (!row)
1040
- return;
1041
- let key = rowKeyGenStore.get(row);
1042
- if (!key) {
1043
- key = typeof props.rowKey === "function" ? props.rowKey(row) : row[props.rowKey];
1044
- rowKeyGenStore.set(row, key);
1045
- }
1046
- return key;
1047
- }
1048
- function colKeyGen(col) {
1049
- return typeof props.colKey === "function" ? props.colKey(col) : col[props.colKey];
1050
- }
1051
- function getColWidthStyle(col) {
1052
- const style = {
1053
- width: col.width,
1054
- minWidth: col.minWidth,
1055
- maxWidth: col.maxWidth
1056
- };
1057
- if (props.colResizable) {
1058
- style.minWidth = col.width;
1059
- style.maxWidth = col.width;
1060
- } else {
1061
- style.minWidth = col.minWidth === void 0 ? col.width : col.minWidth;
1062
- style.maxWidth = col.maxWidth === void 0 ? col.width : col.maxWidth;
1063
- }
1064
- return style;
1065
- }
1066
- function getCellStyle(tagType, col, depth) {
1067
- const style = {
1068
- ...getColWidthStyle(col),
1069
- ...getFixedStyle(tagType, col, depth)
1070
- };
1071
- if (tagType === 1) {
1072
- style.textAlign = col.headerAlign;
1073
- } else if (tagType === 2) {
1074
- style.textAlign = col.align;
1075
- }
1076
- return style;
1077
- }
1078
- function onColumnSort(col, click = true, options = {}) {
1079
- if (!(col == null ? void 0 : col.sorter))
1080
- return;
1081
- options = { force: false, emit: false, ...options };
1082
- if (sortCol.value !== col.dataIndex) {
1083
- sortCol.value = col.dataIndex;
1084
- sortOrderIndex.value = 0;
1085
- }
1086
- if (click)
1087
- sortOrderIndex.value++;
1088
- sortOrderIndex.value = sortOrderIndex.value % 3;
1089
- const order = sortSwitchOrder[sortOrderIndex.value];
1090
- if (!props.sortRemote || options.force) {
1091
- dataSourceCopy.value = tableSort(col, order, props.dataSource);
1092
- }
1093
- if (click || options.emit) {
1094
- emits("sort-change", col, order, toRaw(dataSourceCopy.value));
1095
- }
1096
- }
1097
- function onRowClick(e, row) {
1098
- emits("row-click", e, row);
1099
- if (props.rowKey ? currentItemKey.value === rowKeyGen(row) : currentItem.value === row)
1100
- return;
1101
- currentItem.value = row;
1102
- currentItemKey.value = rowKeyGen(row);
1103
- emits("current-change", e, row);
1104
- }
1105
- function onRowDblclick(e, row) {
1106
- emits("row-dblclick", e, row);
1107
- }
1108
- function onHeaderMenu(e) {
1109
- emits("header-row-menu", e);
1110
- }
1111
- function onRowMenu(e, row) {
1112
- emits("row-menu", e, row);
1113
- }
1114
- function onCellClick(e, row, col) {
1115
- emits("cell-click", e, row, col);
1116
- }
1117
- function onHeaderCellClick(e, col) {
1118
- emits("header-cell-click", e, col);
1119
- }
1120
- function onTableWheel(e) {
1121
- if (isColResizing.value) {
1122
- e.preventDefault();
1123
- e.stopPropagation();
1124
- return;
1125
- }
1126
- }
1127
- function onTableScroll(e) {
1128
- if (!(e == null ? void 0 : e.target))
1129
- return;
1130
- const { scrollTop, scrollLeft } = e.target;
1131
- const { scrollTop: vScrollTop } = virtualScroll.value;
1132
- const { scrollLeft: vScrollLeft } = virtualScrollX.value;
1133
- const isYScroll = scrollTop !== vScrollTop;
1134
- const isXScroll = scrollLeft !== vScrollLeft;
1135
- if (isYScroll && virtual_on.value) {
1136
- updateVirtualScrollY(scrollTop);
1137
- }
1138
- if (isXScroll) {
1139
- updateFixedShadow();
1140
- if (virtualX_on.value) {
1141
- updateVirtualScrollX(scrollLeft);
1142
- } else {
1143
- virtualScrollX.value.scrollLeft = scrollLeft;
1144
- }
1145
- }
1146
- const { startIndex, endIndex } = virtualScroll.value;
1147
- const data = { startIndex, endIndex };
1148
- if (isYScroll) {
1149
- emits("scroll", e, data);
1150
- }
1151
- if (isXScroll) {
1152
- emits("scroll-x", e);
1153
- }
1154
- }
1155
- function onTrMouseOver(_e, row) {
1156
- if (props.showTrHoverClass) {
1157
- currentHover.value = rowKeyGen(row);
1158
- }
1159
- }
1160
- function setCurrentRow(rowKey, option = { silent: false }) {
1161
- if (!dataSourceCopy.value.length)
1162
- return;
1163
- currentItem.value = dataSourceCopy.value.find((it) => rowKeyGen(it) === rowKey);
1164
- currentItemKey.value = rowKeyGen(currentItem.value);
1165
- if (!option.silent) {
1166
- emits("current-change", null, currentItem.value);
1167
- }
1168
- }
1169
- function setSorter(dataIndex, order, option = {}) {
1170
- var _a;
1171
- const newOption = { silent: true, sortOption: null, sort: true, ...option };
1172
- sortCol.value = dataIndex;
1173
- sortOrderIndex.value = sortSwitchOrder.findIndex((it) => it === order);
1174
- if (newOption.sort && ((_a = dataSourceCopy.value) == null ? void 0 : _a.length)) {
1175
- const column = newOption.sortOption || tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
1176
- if (column)
1177
- onColumnSort(column, false, { force: true, emit: !newOption.silent });
1178
- else
1179
- console.warn("Can not find column by dataIndex:", sortCol.value);
1180
- }
1181
- return dataSourceCopy.value;
1182
- }
1183
- function resetSorter() {
1184
- sortCol.value = null;
1185
- sortOrderIndex.value = 0;
1186
- dataSourceCopy.value = [...props.dataSource];
1187
- }
1188
- function scrollTo(top = 0, left = 0) {
1189
- if (!tableContainer.value)
1190
- return;
1191
- if (top !== null)
1192
- tableContainer.value.scrollTop = top;
1193
- if (left !== null)
1194
- tableContainer.value.scrollLeft = left;
1195
- }
1196
- function getTableData() {
1197
- return toRaw(dataSourceCopy.value);
1198
- }
1199
- function getSortColumns() {
1200
- const sortOrder = sortSwitchOrder[sortOrderIndex.value];
1201
- if (!sortOrder)
1202
- return [];
1203
- return [{ dataIndex: sortCol.value, order: sortOrder }];
1204
- }
1205
- __expose({
1206
- /** 初始化横向纵向虚拟滚动 */
1207
- initVirtualScroll,
1208
- /** 初始化横向虚拟滚动 */
1209
- initVirtualScrollX,
1210
- /** 初始化纵向虚拟滚动 */
1211
- initVirtualScrollY,
1212
- /** 设置当前选中行 */
1213
- setCurrentRow,
1214
- /** 设置高亮渐暗单元格 */
1215
- setHighlightDimCell,
1216
- /** 设置高亮渐暗行 */
1217
- setHighlightDimRow,
1218
- /** 表格排序列dataIndex */
1219
- sortCol,
1220
- /** 获取当前排序状态 */
1221
- getSortColumns,
1222
- /** 设置排序 */
1223
- setSorter,
1224
- /** 重置排序 */
1225
- resetSorter,
1226
- /** 滚动至 */
1227
- scrollTo,
1228
- /** 获取表格数据 */
1229
- getTableData
1230
- });
1231
- return (_ctx, _cache) => {
1232
- return openBlock(), createElementBlock("div", {
1233
- ref_key: "tableContainer",
1234
- ref: tableContainer,
1235
- class: normalizeClass(["stk-table", {
1236
- virtual: _ctx.virtual,
1237
- "virtual-x": _ctx.virtualX,
1238
- dark: _ctx.theme === "dark",
1239
- headless: _ctx.headless,
1240
- "is-col-resizing": unref(isColResizing),
1241
- "col-resizable": props.colResizable,
1242
- border: props.bordered,
1243
- "border-h": props.bordered === "h",
1244
- "border-v": props.bordered === "v",
1245
- "border-body-v": props.bordered === "body-v",
1246
- stripe: props.stripe
1247
- }]),
1248
- style: normalizeStyle(
1249
- _ctx.virtual && {
1250
- "--row-height": unref(virtualScroll).rowHeight + "px",
1251
- "--header-row-height": (props.headerRowHeight || props.rowHeight) + "px"
1252
- }
1253
- ),
1254
- onScroll: onTableScroll,
1255
- onWheel: onTableWheel
1256
- }, [
1257
- withDirectives(createElementVNode("div", {
1258
- ref_key: "colResizeIndicator",
1259
- ref: colResizeIndicator,
1260
- class: "column-resize-indicator"
1261
- }, null, 512), [
1262
- [vShow, _ctx.colResizable]
1263
- ]),
1264
- createElementVNode("table", {
1265
- class: normalizeClass(["stk-table-main", {
1266
- "fixed-mode": props.fixedMode
1267
- }]),
1268
- style: normalizeStyle({ width: _ctx.width, minWidth: _ctx.minWidth, maxWidth: _ctx.maxWidth })
1269
- }, [
1270
- !_ctx.headless ? (openBlock(), createElementBlock("thead", _hoisted_1, [
1271
- (openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
1272
- return openBlock(), createElementBlock("tr", {
1273
- key: rowIndex,
1274
- onContextmenu: _cache[3] || (_cache[3] = (e) => onHeaderMenu(e))
1275
- }, [
1276
- unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
1277
- key: 0,
1278
- class: "virtual-x-left",
1279
- style: normalizeStyle({
1280
- minWidth: unref(virtualScrollX).offsetLeft + "px",
1281
- width: unref(virtualScrollX).offsetLeft + "px"
1282
- })
1283
- }, null, 4)) : createCommentVNode("", true),
1284
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
1285
- return openBlock(), createElementBlock("th", {
1286
- key: col.dataIndex,
1287
- "data-col-key": colKeyGen(col),
1288
- draggable: unref(isHeaderDraggable)(col) ? "true" : "false",
1289
- rowspan: unref(virtualX_on) ? 1 : col.rowSpan,
1290
- colspan: col.colSpan,
1291
- style: normalizeStyle(getCellStyle(1, col, rowIndex)),
1292
- title: col.title,
1293
- class: normalizeClass([
1294
- col.sorter ? "sortable" : "",
1295
- col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
1296
- _ctx.showHeaderOverflow ? "text-overflow" : "",
1297
- col.headerClassName,
1298
- unref(getFixedColClass)(col)
1299
- ]),
1300
- onClick: (e) => {
1301
- onColumnSort(col);
1302
- onHeaderCellClick(e, col);
1303
- },
1304
- onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
1305
- (...args) => unref(onThDragStart) && unref(onThDragStart)(...args)),
1306
- onDrop: _cache[1] || (_cache[1] = //@ts-ignore
1307
- (...args) => unref(onThDrop) && unref(onThDrop)(...args)),
1308
- onDragover: _cache[2] || (_cache[2] = //@ts-ignore
1309
- (...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
1310
- }, [
1311
- createElementVNode("div", _hoisted_3, [
1312
- col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
1313
- key: 0,
1314
- col
1315
- }, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
1316
- key: 1,
1317
- col
1318
- }, () => [
1319
- createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
1320
- ]),
1321
- col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true),
1322
- _ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
1323
- key: 3,
1324
- class: "table-header-resizer left",
1325
- onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
1326
- }, null, 40, _hoisted_8)) : createCommentVNode("", true),
1327
- _ctx.colResizable ? (openBlock(), createElementBlock("div", {
1328
- key: 4,
1329
- class: "table-header-resizer right",
1330
- onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
1331
- }, null, 40, _hoisted_9)) : createCommentVNode("", true)
1332
- ])
1333
- ], 46, _hoisted_2);
1334
- }), 128)),
1335
- unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
1336
- key: 1,
1337
- class: "virtual-x-right",
1338
- style: normalizeStyle({
1339
- minWidth: unref(virtualX_offsetRight) + "px",
1340
- width: unref(virtualX_offsetRight) + "px"
1341
- })
1342
- }, null, 4)) : createCommentVNode("", true)
1343
- ], 32);
1344
- }), 128))
1345
- ])) : createCommentVNode("", true),
1346
- createElementVNode("tbody", null, [
1347
- unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1348
- key: 0,
1349
- style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
1350
- class: "padding-top-tr"
1351
- }, [
1352
- unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
1353
- _ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
1354
- return openBlock(), createElementBlock("td", {
1355
- key: col.dataIndex,
1356
- style: normalizeStyle(getCellStyle(2, col))
1357
- }, null, 4);
1358
- }), 128)) : createCommentVNode("", true)
1359
- ], 4)) : createCommentVNode("", true),
1360
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, i) => {
1361
- return openBlock(), createElementBlock("tr", {
1362
- key: _ctx.rowKey ? rowKeyGen(row) : i,
1363
- "data-row-key": _ctx.rowKey ? rowKeyGen(row) : i,
1364
- class: normalizeClass({
1365
- active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
1366
- hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
1367
- [_ctx.rowClassName(row, i)]: true
1368
- }),
1369
- style: normalizeStyle({
1370
- backgroundColor: row._bgc
1371
- }),
1372
- onClick: (e) => onRowClick(e, row),
1373
- onDblclick: (e) => onRowDblclick(e, row),
1374
- onContextmenu: (e) => onRowMenu(e, row),
1375
- onMouseover: (e) => onTrMouseOver(e, row)
1376
- }, [
1377
- unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true),
1378
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
1379
- return openBlock(), createElementBlock("td", {
1380
- key: col.dataIndex,
1381
- "data-index": col.dataIndex,
1382
- class: normalizeClass([col.className, _ctx.showOverflow ? "text-overflow" : "", unref(getFixedColClass)(col)]),
1383
- style: normalizeStyle(getCellStyle(2, col)),
1384
- onClick: (e) => onCellClick(e, row, col)
1385
- }, [
1386
- col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
1387
- key: 0,
1388
- col,
1389
- row,
1390
- "cell-value": row[col.dataIndex]
1391
- }, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
1392
- key: 1,
1393
- class: "table-cell-wrapper",
1394
- title: row[col.dataIndex]
1395
- }, toDisplayString(row[col.dataIndex] ?? _ctx.emptyCellText), 9, _hoisted_14))
1396
- ], 14, _hoisted_13);
1397
- }), 128))
1398
- ], 46, _hoisted_11);
1399
- }), 128)),
1400
- unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1401
- key: 1,
1402
- style: normalizeStyle({ height: `${unref(virtual_offsetBottom)}px` })
1403
- }, null, 4)) : createCommentVNode("", true)
1404
- ])
1405
- ], 6),
1406
- (!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
1407
- key: 0,
1408
- class: normalizeClass(["stk-table-no-data", { "no-data-full": _ctx.noDataFull }])
1409
- }, [
1410
- renderSlot(_ctx.$slots, "empty", {}, () => [
1411
- createTextVNode("暂无数据")
1412
- ])
1413
- ], 2)) : createCommentVNode("", true)
1414
- ], 38);
1415
- };
1416
- }
1417
- });
1418
- export {
1419
- _sfc_main as StkTable,
1420
- insertToOrderedArray,
1421
- tableSort
1422
- };
1
+ import { onMounted, onBeforeUnmount, watch, ref, computed, defineComponent, shallowRef, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, withDirectives, createElementVNode, vShow, Fragment, renderList, createCommentVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, createTextVNode } from "vue";
2
+ import { interpolateRgb } from "d3-interpolate";
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
+ light: { from: "#71a2fd", to: "#fff" },
9
+ dark: { from: "#1e4c99", to: "#181c21" }
10
+ };
11
+ const Highlight_Duration = 2e3;
12
+ const Highlight_Color_Change_Freq = 100;
13
+ let _chromeVersion = 0;
14
+ try {
15
+ const userAgent = navigator.userAgent.match(/chrome\/\d+/i);
16
+ if (userAgent) {
17
+ _chromeVersion = +userAgent[0].split("/")[1];
18
+ }
19
+ } catch (e) {
20
+ console.error("Cannot get Chrome version", e);
21
+ }
22
+ const Is_Legacy_Mode = _chromeVersion < 56;
23
+ function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs }) {
24
+ let resizeObserver = null;
25
+ onMounted(() => {
26
+ initResizeObserver();
27
+ });
28
+ onBeforeUnmount(() => {
29
+ removeResizeObserver();
30
+ });
31
+ function initResizeObserver() {
32
+ if (window.ResizeObserver) {
33
+ if (!tableContainer.value) {
34
+ const watchDom = watch(
35
+ () => tableContainer,
36
+ () => {
37
+ initResizeObserver();
38
+ watchDom();
39
+ }
40
+ );
41
+ return;
42
+ }
43
+ resizeObserver = new ResizeObserver(resizeCallback);
44
+ resizeObserver.observe(tableContainer.value);
45
+ } else {
46
+ window.addEventListener("resize", resizeCallback);
47
+ }
48
+ }
49
+ function removeResizeObserver() {
50
+ if (resizeObserver) {
51
+ resizeObserver.disconnect();
52
+ resizeObserver = null;
53
+ } else {
54
+ window.removeEventListener("resize", resizeCallback);
55
+ }
56
+ }
57
+ let debounceTime = 0;
58
+ function resizeCallback() {
59
+ if (debounceTime) {
60
+ window.clearTimeout(debounceTime);
61
+ }
62
+ debounceTime = window.setTimeout(() => {
63
+ if (props.autoResize) {
64
+ initVirtualScroll();
65
+ if (typeof props.autoResize === "function") {
66
+ props.autoResize();
67
+ }
68
+ }
69
+ debounceTime = 0;
70
+ }, debounceMs);
71
+ }
72
+ }
73
+ function insertToOrderedArray(sortState, newItem, targetArray) {
74
+ const { dataIndex, order } = sortState;
75
+ let { sortType } = sortState;
76
+ if (!sortType)
77
+ sortType = typeof newItem[dataIndex];
78
+ const data = [...targetArray];
79
+ if (!order) {
80
+ data.unshift(newItem);
81
+ return data;
82
+ }
83
+ let sIndex = 0;
84
+ let eIndex = data.length - 1;
85
+ const targetVal = newItem[dataIndex];
86
+ while (sIndex <= eIndex) {
87
+ const midIndex = Math.floor((sIndex + eIndex) / 2);
88
+ const midVal = data[midIndex][dataIndex];
89
+ const compareRes = strCompare(midVal, targetVal, sortType);
90
+ if (compareRes === 0) {
91
+ sIndex = midIndex;
92
+ break;
93
+ } else if (compareRes === -1) {
94
+ if (order === "asc")
95
+ sIndex = midIndex + 1;
96
+ else
97
+ eIndex = midIndex - 1;
98
+ } else {
99
+ if (order === "asc")
100
+ eIndex = midIndex - 1;
101
+ else
102
+ sIndex = midIndex + 1;
103
+ }
104
+ }
105
+ data.splice(sIndex, 0, newItem);
106
+ return data;
107
+ }
108
+ function strCompare(a, b, type) {
109
+ if (type === "number") {
110
+ if (+a > +b)
111
+ return 1;
112
+ else if (+a === +b)
113
+ return 0;
114
+ else
115
+ return -1;
116
+ } else {
117
+ return String(a).localeCompare(b);
118
+ }
119
+ }
120
+ function separatedData(sortOption, targetDataSource, isNumber) {
121
+ const emptyArr = [];
122
+ const valueArr = [];
123
+ for (let i = 0; i < targetDataSource.length; i++) {
124
+ const row = targetDataSource[i];
125
+ const sortField = sortOption.sortField || sortOption.dataIndex;
126
+ let isEmpty = row[sortField] === null || row[sortField] === "";
127
+ if (isNumber) {
128
+ isEmpty || (isEmpty = typeof row[sortField] === "boolean" || Number.isNaN(+row[sortField]));
129
+ }
130
+ if (isEmpty) {
131
+ emptyArr.push(row);
132
+ } else {
133
+ valueArr.push(row);
134
+ }
135
+ }
136
+ return [valueArr, emptyArr];
137
+ }
138
+ function tableSort(sortOption, order, dataSource, sortConfig = {}) {
139
+ if (!(dataSource == null ? void 0 : dataSource.length))
140
+ return dataSource || [];
141
+ sortConfig = { emptyToBottom: false, ...sortConfig };
142
+ let targetDataSource = [...dataSource];
143
+ let sortField = sortOption.sortField || sortOption.dataIndex;
144
+ if (!order && sortConfig.defaultSort) {
145
+ order = sortConfig.defaultSort.order;
146
+ sortField = sortConfig.defaultSort.dataIndex;
147
+ }
148
+ if (typeof sortOption.sorter === "function") {
149
+ const customSorterData = sortOption.sorter(targetDataSource, { order, column: sortOption });
150
+ if (customSorterData)
151
+ targetDataSource = customSorterData;
152
+ } else if (order) {
153
+ let { sortType } = sortOption;
154
+ if (!sortType)
155
+ sortType = typeof dataSource[0][sortField];
156
+ const [valueArr, emptyArr] = separatedData(sortOption, targetDataSource, sortType === "number");
157
+ if (sortType === "number") {
158
+ if (order === "asc") {
159
+ valueArr.sort((a, b) => +a[sortField] - +b[sortField]);
160
+ targetDataSource = [...emptyArr, ...valueArr];
161
+ } else {
162
+ valueArr.sort((a, b) => +b[sortField] - +a[sortField]);
163
+ targetDataSource = [...valueArr, ...emptyArr];
164
+ }
165
+ } else {
166
+ if (order === "asc") {
167
+ valueArr.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]));
168
+ targetDataSource = [...emptyArr, ...valueArr];
169
+ } else {
170
+ valueArr.sort((a, b) => String(a[sortField]).localeCompare(b[sortField]) * -1);
171
+ targetDataSource = [...valueArr, ...emptyArr];
172
+ }
173
+ }
174
+ if (sortConfig.emptyToBottom) {
175
+ targetDataSource = [...valueArr, ...emptyArr];
176
+ }
177
+ }
178
+ return targetDataSource;
179
+ }
180
+ function howDeepTheHeader(arr, level = 1) {
181
+ const levels = [level];
182
+ arr.forEach((item) => {
183
+ var _a;
184
+ if ((_a = item.children) == null ? void 0 : _a.length) {
185
+ levels.push(howDeepTheHeader(item.children, level + 1));
186
+ }
187
+ });
188
+ return Math.max(...levels);
189
+ }
190
+ function getColWidth(col) {
191
+ if (typeof (col == null ? void 0 : col.width) === "number") {
192
+ return Math.floor(col.width ?? Default_Col_Width);
193
+ }
194
+ return parseInt((col == null ? void 0 : col.width) ?? Default_Col_Width);
195
+ }
196
+ function useColResize({
197
+ tableContainer,
198
+ tableHeaderLast,
199
+ colResizeIndicator,
200
+ props,
201
+ emits,
202
+ colKeyGen
203
+ }) {
204
+ const isColResizing = ref(false);
205
+ let colResizeState = {
206
+ currentCol: null,
207
+ currentColIndex: 0,
208
+ lastCol: null,
209
+ startX: 0,
210
+ startOffsetTableX: 0
211
+ };
212
+ onMounted(() => {
213
+ initColResizeEvent();
214
+ });
215
+ onBeforeUnmount(() => {
216
+ clearColResizeEvent();
217
+ });
218
+ function initColResizeEvent() {
219
+ window.addEventListener("mousemove", onThResizeMouseMove);
220
+ window.addEventListener("mouseup", onThResizeMouseUp);
221
+ }
222
+ function clearColResizeEvent() {
223
+ window.removeEventListener("mousemove", onThResizeMouseMove);
224
+ window.removeEventListener("mouseup", onThResizeMouseUp);
225
+ }
226
+ function onThResizeMouseDown(e, col, isPrev = false) {
227
+ if (!tableContainer.value)
228
+ return;
229
+ e.stopPropagation();
230
+ e.preventDefault();
231
+ const { clientX } = e;
232
+ const { scrollLeft, scrollTop } = tableContainer.value;
233
+ const { left } = tableContainer.value.getBoundingClientRect();
234
+ let colIndex = tableHeaderLast.value.findIndex((it) => colKeyGen(it) === colKeyGen(col));
235
+ if (isPrev) {
236
+ colIndex -= 1;
237
+ col = tableHeaderLast.value[colIndex];
238
+ }
239
+ const offsetTableX = clientX - left + scrollLeft;
240
+ isColResizing.value = true;
241
+ Object.assign(colResizeState, {
242
+ currentCol: col,
243
+ currentColIndex: colIndex,
244
+ lastCol: findLastChildCol(col),
245
+ startX: clientX,
246
+ startOffsetTableX: offsetTableX
247
+ });
248
+ if (colResizeIndicator.value) {
249
+ const style = colResizeIndicator.value.style;
250
+ style.display = "block";
251
+ style.left = offsetTableX + "px";
252
+ style.top = scrollTop + "px";
253
+ }
254
+ }
255
+ function onThResizeMouseMove(e) {
256
+ if (!isColResizing.value)
257
+ return;
258
+ e.stopPropagation();
259
+ e.preventDefault();
260
+ const { lastCol, startX, startOffsetTableX } = colResizeState;
261
+ const { clientX } = e;
262
+ let moveX = clientX - startX;
263
+ const currentColWidth = getColWidth(lastCol);
264
+ if (currentColWidth + moveX < props.colMinWidth) {
265
+ moveX = -currentColWidth;
266
+ }
267
+ const offsetTableX = startOffsetTableX + moveX;
268
+ if (!colResizeIndicator.value)
269
+ return;
270
+ colResizeIndicator.value.style.left = offsetTableX + "px";
271
+ }
272
+ function onThResizeMouseUp(e) {
273
+ if (!isColResizing.value)
274
+ return;
275
+ const { startX, lastCol } = colResizeState;
276
+ const { clientX } = e;
277
+ const moveX = clientX - startX;
278
+ let width = getColWidth(lastCol) + moveX;
279
+ if (width < props.colMinWidth)
280
+ width = props.colMinWidth;
281
+ const curCol = tableHeaderLast.value.find((it) => colKeyGen(it) === colKeyGen(lastCol));
282
+ if (!curCol)
283
+ return;
284
+ curCol.width = width + "px";
285
+ emits("update:columns", [...props.columns]);
286
+ if (colResizeIndicator.value) {
287
+ const style = colResizeIndicator.value.style;
288
+ style.display = "none";
289
+ style.left = "0";
290
+ style.top = "0";
291
+ }
292
+ isColResizing.value = false;
293
+ colResizeState = {
294
+ currentCol: null,
295
+ currentColIndex: 0,
296
+ lastCol: null,
297
+ startX: 0,
298
+ startOffsetTableX: 0
299
+ };
300
+ }
301
+ function findLastChildCol(column) {
302
+ var _a;
303
+ if ((_a = column == null ? void 0 : column.children) == null ? void 0 : _a.length) {
304
+ const lastChild = column.children.at(-1);
305
+ return findLastChildCol(lastChild);
306
+ }
307
+ return column;
308
+ }
309
+ return {
310
+ isColResizing,
311
+ onThResizeMouseDown,
312
+ onThResizeMouseMove,
313
+ onThResizeMouseUp
314
+ };
315
+ }
316
+ function useFixedCol({ props, tableHeaderLast, tableContainer }) {
317
+ const fixedShadow = ref({
318
+ showL: false,
319
+ showR: false
320
+ });
321
+ let fixedShadowCols = [];
322
+ function dealFixedColShadow() {
323
+ if (!props.fixedColShadow)
324
+ return;
325
+ fixedShadowCols = [];
326
+ let lastLeftCol = null;
327
+ for (let i = tableHeaderLast.value.length - 1; i >= 0; i--) {
328
+ const col = tableHeaderLast.value[i];
329
+ if (col.fixed === "left") {
330
+ lastLeftCol = col;
331
+ break;
332
+ }
333
+ }
334
+ let node = { __PARENT__: lastLeftCol };
335
+ while (node = node.__PARENT__) {
336
+ if (node.fixed) {
337
+ fixedShadowCols.push(node);
338
+ }
339
+ }
340
+ const lastRightCol = tableHeaderLast.value.find((it) => it.fixed === "right");
341
+ node = { __PARENT__: lastRightCol };
342
+ while (node = node.__PARENT__) {
343
+ if (node.fixed) {
344
+ fixedShadowCols.push(node);
345
+ }
346
+ }
347
+ }
348
+ function getFixedColClass(col) {
349
+ const { showR, showL } = fixedShadow.value;
350
+ const showShadow = props.fixedColShadow && col.fixed && (showL && col.fixed === "left" || showR && col.fixed === "right") && fixedShadowCols.includes(col);
351
+ const classObj = {
352
+ "fixed-cell": col.fixed,
353
+ ["fixed-cell--" + col.fixed]: col.fixed,
354
+ "fixed-cell--shadow": showShadow
355
+ };
356
+ return classObj;
357
+ }
358
+ function updateFixedShadow() {
359
+ if (!props.fixedColShadow)
360
+ return;
361
+ const { clientWidth, scrollWidth, scrollLeft } = tableContainer.value;
362
+ fixedShadow.value.showL = Boolean(scrollLeft);
363
+ fixedShadow.value.showR = Math.abs(scrollWidth - scrollLeft - clientWidth) > 0.5;
364
+ }
365
+ return {
366
+ /** 固定列class */
367
+ getFixedColClass,
368
+ /** 处理固定列阴影 */
369
+ dealFixedColShadow,
370
+ /** 滚动条变化时,更新需要展示阴影的列 */
371
+ updateFixedShadow
372
+ };
373
+ }
374
+ function useFixedStyle({ props, tableHeaderLast, virtualScroll, virtualScrollX, virtualX_on, virtualX_offsetRight }) {
375
+ const fixedColumnsPositionStore = computed(() => {
376
+ const store = {};
377
+ const cols = [...tableHeaderLast.value];
378
+ let left = 0;
379
+ let rightStartIndex = 0;
380
+ for (let i = 0; i < cols.length; i++) {
381
+ const item = cols[i];
382
+ if (item.fixed === "left") {
383
+ store[item.dataIndex] = left;
384
+ left += getColWidth(item);
385
+ }
386
+ if (!rightStartIndex && item.fixed === "right") {
387
+ rightStartIndex = i;
388
+ }
389
+ }
390
+ let right = 0;
391
+ for (let i = cols.length - 1; i >= rightStartIndex; i--) {
392
+ const item = cols[i];
393
+ if (item.fixed === "right") {
394
+ store[item.dataIndex] = right;
395
+ right += getColWidth(item);
396
+ }
397
+ }
398
+ return store;
399
+ });
400
+ function getFixedStyle(tagType, col, depth = 0) {
401
+ const { fixed, dataIndex } = col;
402
+ const isFixedLeft = fixed === "left";
403
+ const style = {};
404
+ if (Is_Legacy_Mode) {
405
+ style.position = "relative";
406
+ } else {
407
+ style.position = "sticky";
408
+ }
409
+ if (tagType === 1) {
410
+ if (Is_Legacy_Mode) {
411
+ style.top = virtualScroll.value.scrollTop + depth * props.rowHeight + "px";
412
+ } else {
413
+ style.top = depth * props.rowHeight + "px";
414
+ }
415
+ style.zIndex = isFixedLeft ? "5" : "4";
416
+ } else {
417
+ style.zIndex = isFixedLeft ? "3" : "2";
418
+ }
419
+ if (fixed === "left" || fixed === "right") {
420
+ if (Is_Legacy_Mode) {
421
+ if (isFixedLeft) {
422
+ if (virtualX_on.value)
423
+ style.left = virtualScrollX.value.scrollLeft - virtualScrollX.value.offsetLeft + "px";
424
+ else
425
+ style.left = virtualScrollX.value.scrollLeft + "px";
426
+ } else {
427
+ style.right = `${virtualX_offsetRight.value}px`;
428
+ }
429
+ } else {
430
+ if (isFixedLeft) {
431
+ style.left = fixedColumnsPositionStore.value[dataIndex] + "px";
432
+ } else {
433
+ style.right = fixedColumnsPositionStore.value[dataIndex] + "px";
434
+ }
435
+ }
436
+ }
437
+ return style;
438
+ }
439
+ return {
440
+ getFixedStyle
441
+ };
442
+ }
443
+ const HIGHLIGHT_ROW_CLASS = "highlight-row";
444
+ const HIGHLIGHT_CELL_CLASS = "highlight-cell";
445
+ function useHighlight({ props, tableContainer }) {
446
+ const highlightRowStore = ref({});
447
+ const highlightFrom = Highlight_Color[props.theme].from;
448
+ const highlightTo = Highlight_Color[props.theme].to;
449
+ const highlightInter = computed(() => interpolateRgb(highlightFrom, highlightTo));
450
+ const highlightDimRowKeys = /* @__PURE__ */ new Set();
451
+ const highlightDimRowsTimeout = /* @__PURE__ */ new Map();
452
+ const highlightDimCellsTimeout = /* @__PURE__ */ new Map();
453
+ let calcHighlightDimLoop = false;
454
+ function calcHighlightLoop() {
455
+ if (calcHighlightDimLoop)
456
+ return;
457
+ calcHighlightDimLoop = true;
458
+ const recursion = () => {
459
+ window.setTimeout(() => {
460
+ const nowTs = Date.now();
461
+ highlightDimRowKeys.forEach((rowKeyValue) => {
462
+ const highlightItem = highlightRowStore.value[rowKeyValue];
463
+ const progress = (nowTs - highlightItem.bgc_progress_ms) / Highlight_Duration;
464
+ if (0 < progress && progress < 1) {
465
+ highlightItem.bgc = highlightInter.value(progress);
466
+ } else {
467
+ highlightItem.bgc = "";
468
+ highlightDimRowKeys.delete(rowKeyValue);
469
+ }
470
+ });
471
+ if (highlightDimRowKeys.size > 0) {
472
+ recursion();
473
+ } else {
474
+ calcHighlightDimLoop = false;
475
+ }
476
+ }, Highlight_Color_Change_Freq);
477
+ };
478
+ recursion();
479
+ }
480
+ function setHighlightDimCell(rowKeyValue, dataIndex) {
481
+ var _a;
482
+ const cellEl = (_a = tableContainer.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"]>[data-index="${dataIndex}"]`);
483
+ if (!cellEl)
484
+ return;
485
+ if (cellEl.classList.contains(HIGHLIGHT_CELL_CLASS)) {
486
+ cellEl.classList.remove(HIGHLIGHT_CELL_CLASS);
487
+ void cellEl.offsetHeight;
488
+ }
489
+ cellEl.classList.add(HIGHLIGHT_CELL_CLASS);
490
+ window.clearTimeout(highlightDimCellsTimeout.get(rowKeyValue));
491
+ highlightDimCellsTimeout.set(
492
+ rowKeyValue,
493
+ window.setTimeout(() => {
494
+ cellEl.classList.remove(HIGHLIGHT_CELL_CLASS);
495
+ highlightDimCellsTimeout.delete(rowKeyValue);
496
+ }, Highlight_Duration)
497
+ );
498
+ }
499
+ function setHighlightDimRow(rowKeyValues) {
500
+ var _a, _b;
501
+ if (!Array.isArray(rowKeyValues))
502
+ rowKeyValues = [rowKeyValues];
503
+ if (props.virtual) {
504
+ const nowTs = Date.now();
505
+ for (let i = 0; i < rowKeyValues.length; i++) {
506
+ const rowKeyValue = rowKeyValues[i];
507
+ highlightRowStore.value[rowKeyValue] = {
508
+ bgc: "",
509
+ bgc_progress: 0,
510
+ bgc_progress_ms: nowTs
511
+ };
512
+ highlightDimRowKeys.add(rowKeyValue);
513
+ }
514
+ calcHighlightLoop();
515
+ } else {
516
+ let needRepaint = false;
517
+ const rowElTemp = [];
518
+ for (let i = 0; i < rowKeyValues.length; i++) {
519
+ const rowKeyValue = rowKeyValues[i];
520
+ const rowEl = (_a = tableContainer.value) == null ? void 0 : _a.querySelector(`[data-row-key="${rowKeyValue}"]`);
521
+ if (!rowEl)
522
+ continue;
523
+ if (rowEl.classList.contains(HIGHLIGHT_ROW_CLASS)) {
524
+ rowEl.classList.remove(HIGHLIGHT_ROW_CLASS);
525
+ needRepaint = true;
526
+ }
527
+ rowElTemp.push(rowEl);
528
+ window.clearTimeout(highlightDimRowsTimeout.get(rowKeyValue));
529
+ highlightDimRowsTimeout.set(
530
+ rowKeyValue,
531
+ window.setTimeout(() => {
532
+ rowEl.classList.remove(HIGHLIGHT_ROW_CLASS);
533
+ highlightDimRowsTimeout.delete(rowKeyValue);
534
+ }, Highlight_Duration)
535
+ );
536
+ }
537
+ if (needRepaint) {
538
+ void ((_b = tableContainer.value) == null ? void 0 : _b.offsetWidth);
539
+ }
540
+ rowElTemp.forEach((el) => el.classList.add(HIGHLIGHT_ROW_CLASS));
541
+ }
542
+ }
543
+ return {
544
+ highlightRowStore,
545
+ setHighlightDimRow,
546
+ setHighlightDimCell
547
+ };
548
+ }
549
+ const SCROLL_CODES = ["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft", "PageUp", "PageDown"];
550
+ function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders }) {
551
+ let isMouseOver = false;
552
+ onMounted(() => {
553
+ var _a, _b, _c;
554
+ window.addEventListener("keydown", handleKeydown);
555
+ (_a = targetElement.value) == null ? void 0 : _a.addEventListener("mouseenter", handleMouseEnter);
556
+ (_b = targetElement.value) == null ? void 0 : _b.addEventListener("mouseleave", handleMouseLeave);
557
+ (_c = targetElement.value) == null ? void 0 : _c.addEventListener("mousedown", handleMouseDown);
558
+ });
559
+ onBeforeUnmount(() => {
560
+ var _a, _b, _c;
561
+ window.removeEventListener("keydown", handleKeydown);
562
+ (_a = targetElement.value) == null ? void 0 : _a.removeEventListener("mouseenter", handleMouseEnter);
563
+ (_b = targetElement.value) == null ? void 0 : _b.removeEventListener("mouseleave", handleMouseLeave);
564
+ (_c = targetElement.value) == null ? void 0 : _c.removeEventListener("mousedown", handleMouseDown);
565
+ });
566
+ function handleKeydown(e) {
567
+ if (!SCROLL_CODES.includes(e.code))
568
+ return;
569
+ if (!isMouseOver)
570
+ return;
571
+ e.preventDefault();
572
+ const { scrollTop, rowHeight, pageSize } = virtualScroll.value;
573
+ const { scrollLeft } = virtualScrollX.value;
574
+ const { headless, headerRowHeight } = props;
575
+ const headerHeight = headless ? 0 : tableHeaders.value.length * (headerRowHeight || rowHeight);
576
+ if (e.code === SCROLL_CODES[0]) {
577
+ scrollTo(scrollTop - rowHeight, null);
578
+ } else if (e.code === SCROLL_CODES[1]) {
579
+ scrollTo(null, scrollLeft + rowHeight);
580
+ } else if (e.code === SCROLL_CODES[2]) {
581
+ scrollTo(scrollTop + rowHeight, null);
582
+ } else if (e.code === SCROLL_CODES[3]) {
583
+ scrollTo(null, scrollLeft - rowHeight);
584
+ } else if (e.code === SCROLL_CODES[4]) {
585
+ scrollTo(scrollTop - rowHeight * pageSize - headerHeight, null);
586
+ } else if (e.code === SCROLL_CODES[5]) {
587
+ scrollTo(scrollTop + rowHeight * pageSize - headerHeight, null);
588
+ }
589
+ }
590
+ function handleMouseEnter() {
591
+ isMouseOver = true;
592
+ }
593
+ function handleMouseLeave() {
594
+ isMouseOver = false;
595
+ }
596
+ function handleMouseDown() {
597
+ if (!isMouseOver)
598
+ isMouseOver = true;
599
+ }
600
+ }
601
+ function useThDrag({ props, emits }) {
602
+ let dragStartKey = void 0;
603
+ function findParentTH(el) {
604
+ let n = el;
605
+ while (n) {
606
+ if (n.tagName === "TH")
607
+ return n;
608
+ n = n.parentElement;
609
+ }
610
+ }
611
+ function onThDragStart(e) {
612
+ const th = findParentTH(e.target);
613
+ if (!th)
614
+ return;
615
+ dragStartKey = th.dataset.colKey;
616
+ emits("th-drag-start", dragStartKey);
617
+ }
618
+ function onThDragOver(e) {
619
+ const th = findParentTH(e.target);
620
+ if (!th)
621
+ return;
622
+ const isHeaderDraggable2 = th.getAttribute("draggable") === "true";
623
+ if (!isHeaderDraggable2) {
624
+ return;
625
+ }
626
+ e.preventDefault();
627
+ }
628
+ function onThDrop(e) {
629
+ const th = findParentTH(e.target);
630
+ if (!th)
631
+ return;
632
+ if (dragStartKey !== th.dataset.colKey) {
633
+ emits("col-order-change", dragStartKey, th.dataset.colKey);
634
+ }
635
+ emits("th-drop", th.dataset.colKey);
636
+ }
637
+ const isHeaderDragFun = typeof props.headerDrag === "function";
638
+ function isHeaderDraggable(col) {
639
+ if (isHeaderDragFun) {
640
+ return props.headerDrag(col);
641
+ } else {
642
+ return props.headerDrag;
643
+ }
644
+ }
645
+ return {
646
+ onThDragStart,
647
+ onThDragOver,
648
+ onThDrop,
649
+ isHeaderDraggable
650
+ };
651
+ }
652
+ const VUE2_SCROLL_TIMEOUT_MS = 200;
653
+ function useVirtualScroll({ props, tableContainer, dataSourceCopy, tableHeaderLast }) {
654
+ const virtualScroll = ref({
655
+ containerHeight: 0,
656
+ rowHeight: props.rowHeight,
657
+ pageSize: 10,
658
+ startIndex: 0,
659
+ endIndex: 0,
660
+ offsetTop: 0,
661
+ scrollTop: 0
662
+ });
663
+ const virtualScrollX = ref({
664
+ containerWidth: 0,
665
+ startIndex: 0,
666
+ endIndex: 0,
667
+ offsetLeft: 0,
668
+ scrollLeft: 0
669
+ });
670
+ const virtual_on = computed(() => {
671
+ return props.virtual && dataSourceCopy.value.length > virtualScroll.value.pageSize * 2;
672
+ });
673
+ const virtual_dataSourcePart = computed(() => {
674
+ if (!virtual_on.value)
675
+ return dataSourceCopy.value;
676
+ const { startIndex, endIndex } = virtualScroll.value;
677
+ return dataSourceCopy.value.slice(startIndex, endIndex);
678
+ });
679
+ const virtual_offsetBottom = computed(() => {
680
+ if (!virtual_on.value)
681
+ return 0;
682
+ const { startIndex, rowHeight } = virtualScroll.value;
683
+ return (dataSourceCopy.value.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
684
+ });
685
+ const virtualX_on = computed(() => {
686
+ return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getColWidth(col), 0) > virtualScrollX.value.containerWidth + 100;
687
+ });
688
+ const virtualX_columnPart = computed(() => {
689
+ if (virtualX_on.value) {
690
+ const leftCols = [];
691
+ const rightCols = [];
692
+ const { startIndex, endIndex } = virtualScrollX.value;
693
+ for (let i = 0; i < startIndex; i++) {
694
+ const col = tableHeaderLast.value[i];
695
+ if (col.fixed === "left")
696
+ leftCols.push(col);
697
+ }
698
+ for (let i = endIndex; i < tableHeaderLast.value.length; i++) {
699
+ const col = tableHeaderLast.value[i];
700
+ if (col.fixed === "right")
701
+ rightCols.push(col);
702
+ }
703
+ const mainColumns = tableHeaderLast.value.slice(startIndex, endIndex);
704
+ return leftCols.concat(mainColumns).concat(rightCols);
705
+ }
706
+ return tableHeaderLast.value;
707
+ });
708
+ const virtualX_offsetRight = computed(() => {
709
+ if (!virtualX_on.value)
710
+ return 0;
711
+ let width = 0;
712
+ for (let i = virtualScrollX.value.endIndex; i < tableHeaderLast.value.length; i++) {
713
+ const col = tableHeaderLast.value[i];
714
+ if (col.fixed !== "right") {
715
+ width += getColWidth(col);
716
+ }
717
+ }
718
+ return width;
719
+ });
720
+ function initVirtualScrollY(height) {
721
+ if (!virtual_on.value)
722
+ return;
723
+ const { offsetHeight, scrollTop } = tableContainer.value || {};
724
+ const { rowHeight } = virtualScroll.value;
725
+ let containerHeight;
726
+ if (typeof height === "number") {
727
+ containerHeight = height;
728
+ } else {
729
+ containerHeight = offsetHeight || Default_Table_Height;
730
+ }
731
+ Object.assign(virtualScroll.value, {
732
+ containerHeight,
733
+ pageSize: Math.ceil(containerHeight / rowHeight) + 1
734
+ // 这里最终+1,因为headless=true无头时,需要上下各预渲染一行。
735
+ });
736
+ updateVirtualScrollY(scrollTop);
737
+ }
738
+ function initVirtualScrollX() {
739
+ if (!props.virtualX)
740
+ return;
741
+ const { offsetWidth, scrollLeft } = tableContainer.value || {};
742
+ virtualScrollX.value.containerWidth = offsetWidth || Default_Table_Width;
743
+ updateVirtualScrollX(scrollLeft);
744
+ }
745
+ function initVirtualScroll(height) {
746
+ initVirtualScrollY(height);
747
+ initVirtualScrollX();
748
+ }
749
+ let vue2ScrollYTimeout = null;
750
+ function updateVirtualScrollY(sTop = 0) {
751
+ const { rowHeight, pageSize, scrollTop, startIndex: oldStartIndex } = virtualScroll.value;
752
+ const startIndex = Math.floor(sTop / rowHeight);
753
+ const offsetTop = startIndex * rowHeight;
754
+ let endIndex = startIndex + pageSize;
755
+ if (endIndex > dataSourceCopy.value.length) {
756
+ endIndex = dataSourceCopy.value.length;
757
+ }
758
+ if (vue2ScrollYTimeout) {
759
+ window.clearTimeout(vue2ScrollYTimeout);
760
+ }
761
+ if (!props.optimizeVue2Scroll || sTop <= scrollTop || Math.abs(oldStartIndex - startIndex) >= pageSize) {
762
+ Object.assign(virtualScroll.value, {
763
+ startIndex,
764
+ offsetTop,
765
+ endIndex,
766
+ scrollTop: sTop
767
+ });
768
+ } else {
769
+ Object.assign(virtualScroll.value, { endIndex, scrollTop: sTop });
770
+ vue2ScrollYTimeout = window.setTimeout(() => {
771
+ Object.assign(virtualScroll.value, { startIndex, offsetTop });
772
+ }, VUE2_SCROLL_TIMEOUT_MS);
773
+ }
774
+ }
775
+ let vue2ScrollXTimeout = null;
776
+ function updateVirtualScrollX(sLeft = 0) {
777
+ var _a;
778
+ const headerLength = (_a = tableHeaderLast.value) == null ? void 0 : _a.length;
779
+ const { scrollLeft } = virtualScrollX.value;
780
+ if (!headerLength)
781
+ return;
782
+ let startIndex = 0;
783
+ let offsetLeft = 0;
784
+ let colWidthSum = 0;
785
+ for (let colIndex = 0; colIndex < headerLength; colIndex++) {
786
+ startIndex++;
787
+ const col = tableHeaderLast.value[colIndex];
788
+ if (col.fixed === "left")
789
+ continue;
790
+ const colWidth = getColWidth(col);
791
+ colWidthSum += colWidth;
792
+ if (colWidthSum >= sLeft) {
793
+ offsetLeft = colWidthSum - colWidth;
794
+ startIndex--;
795
+ break;
796
+ }
797
+ }
798
+ colWidthSum = 0;
799
+ let endIndex = headerLength;
800
+ for (let colIndex = startIndex + 1; colIndex < headerLength; colIndex++) {
801
+ const col = tableHeaderLast.value[colIndex];
802
+ colWidthSum += getColWidth(col);
803
+ if (colWidthSum >= virtualScrollX.value.containerWidth) {
804
+ endIndex = colIndex + 1;
805
+ break;
806
+ }
807
+ }
808
+ if (endIndex > headerLength) {
809
+ endIndex = headerLength;
810
+ }
811
+ if (vue2ScrollXTimeout) {
812
+ window.clearTimeout(vue2ScrollXTimeout);
813
+ }
814
+ if (!props.optimizeVue2Scroll || sLeft <= scrollLeft) {
815
+ Object.assign(virtualScrollX.value, { startIndex, endIndex, offsetLeft, scrollLeft: sLeft });
816
+ } else {
817
+ Object.assign(virtualScrollX.value, { endIndex, scrollLeft: sLeft });
818
+ vue2ScrollXTimeout = window.setTimeout(() => {
819
+ Object.assign(virtualScrollX.value, { startIndex, offsetLeft });
820
+ }, VUE2_SCROLL_TIMEOUT_MS);
821
+ }
822
+ }
823
+ return {
824
+ virtualScroll,
825
+ virtualScrollX,
826
+ virtual_on,
827
+ virtual_dataSourcePart,
828
+ virtual_offsetBottom,
829
+ virtualX_on,
830
+ virtualX_columnPart,
831
+ virtualX_offsetRight,
832
+ initVirtualScroll,
833
+ initVirtualScrollY,
834
+ initVirtualScrollX,
835
+ updateVirtualScrollY,
836
+ updateVirtualScrollX
837
+ };
838
+ }
839
+ const _hoisted_1 = { key: 0 };
840
+ const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
841
+ const _hoisted_3 = { class: "table-header-cell-wrapper" };
842
+ const _hoisted_4 = { class: "table-header-title" };
843
+ const _hoisted_5 = {
844
+ key: 2,
845
+ class: "table-header-sorter"
846
+ };
847
+ const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
848
+ xmlns: "http://www.w3.org/2000/svg",
849
+ width: "16px",
850
+ height: "16px",
851
+ viewBox: "0 0 16 16"
852
+ }, [
853
+ /* @__PURE__ */ createElementVNode("polygon", {
854
+ class: "arrow-up",
855
+ fill: "#757699",
856
+ points: "8 2 4.8 6 11.2 6"
857
+ }),
858
+ /* @__PURE__ */ createElementVNode("polygon", {
859
+ class: "arrow-down",
860
+ transform: "translate(8, 12) rotate(-180) translate(-8, -12) ",
861
+ points: "8 10 4.8 14 11.2 14"
862
+ })
863
+ ], -1);
864
+ const _hoisted_7 = [
865
+ _hoisted_6
866
+ ];
867
+ const _hoisted_8 = ["onMousedown"];
868
+ const _hoisted_9 = ["onMousedown"];
869
+ const _hoisted_10 = {
870
+ key: 0,
871
+ class: "virtual-x-left",
872
+ style: { "padding": "0" }
873
+ };
874
+ const _hoisted_11 = ["data-row-key", "onClick", "onDblclick", "onContextmenu", "onMouseover"];
875
+ const _hoisted_12 = {
876
+ key: 0,
877
+ class: "virtual-x-left",
878
+ style: { "padding": "0" }
879
+ };
880
+ const _hoisted_13 = ["data-index", "onClick"];
881
+ const _hoisted_14 = ["title"];
882
+ const _sfc_main = /* @__PURE__ */ defineComponent({
883
+ __name: "StkTable",
884
+ props: {
885
+ width: { default: "" },
886
+ minWidth: { default: "" },
887
+ maxWidth: { default: "" },
888
+ stripe: { type: Boolean, default: false },
889
+ fixedMode: { type: Boolean, default: false },
890
+ headless: { type: Boolean, default: false },
891
+ theme: { default: "light" },
892
+ rowHeight: { default: Default_Row_Height },
893
+ headerRowHeight: { default: null },
894
+ virtual: { type: Boolean, default: false },
895
+ virtualX: { type: Boolean, default: false },
896
+ columns: { default: () => [] },
897
+ dataSource: { default: () => [] },
898
+ rowKey: { type: [String, Number, Function], default: "" },
899
+ colKey: { type: [String, Number, Function], default: "dataIndex" },
900
+ emptyCellText: { default: "--" },
901
+ noDataFull: { type: Boolean, default: false },
902
+ showNoData: { type: Boolean, default: true },
903
+ sortRemote: { type: Boolean, default: false },
904
+ showHeaderOverflow: { type: Boolean, default: false },
905
+ showOverflow: { type: Boolean, default: false },
906
+ showTrHoverClass: { type: Boolean, default: false },
907
+ headerDrag: { type: [Boolean, Function], default: false },
908
+ rowClassName: { type: Function, default: () => "" },
909
+ colResizable: { type: Boolean, default: false },
910
+ colMinWidth: { default: 10 },
911
+ bordered: { type: [Boolean, String], default: true },
912
+ autoResize: { type: [Boolean, Function], default: true },
913
+ fixedColShadow: { type: Boolean, default: false },
914
+ optimizeVue2Scroll: { type: Boolean, default: false },
915
+ sortConfig: { default: () => ({
916
+ emptyToBottom: false
917
+ }) }
918
+ },
919
+ 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"],
920
+ setup(__props, { expose: __expose, emit: __emit }) {
921
+ const props = __props;
922
+ const emits = __emit;
923
+ const tableContainer = ref();
924
+ const colResizeIndicator = ref();
925
+ const currentItem = ref(null);
926
+ const currentItemKey = ref(null);
927
+ const currentHover = ref(null);
928
+ let sortCol = ref();
929
+ let sortOrderIndex = ref(0);
930
+ const sortSwitchOrder = [null, "desc", "asc"];
931
+ const tableHeaders = ref([]);
932
+ const tableHeaderLast = ref([]);
933
+ const dataSourceCopy = shallowRef([...props.dataSource]);
934
+ const rowKeyGenStore = /* @__PURE__ */ new WeakMap();
935
+ const { isColResizing, onThResizeMouseDown } = useColResize({
936
+ props,
937
+ emits,
938
+ colKeyGen,
939
+ colResizeIndicator,
940
+ tableContainer,
941
+ tableHeaderLast
942
+ });
943
+ const { onThDragStart, onThDragOver, onThDrop, isHeaderDraggable } = useThDrag({ props, emits });
944
+ const {
945
+ virtualScroll,
946
+ virtualScrollX,
947
+ virtual_on,
948
+ virtual_dataSourcePart,
949
+ virtual_offsetBottom,
950
+ virtualX_on,
951
+ virtualX_columnPart,
952
+ virtualX_offsetRight,
953
+ initVirtualScroll,
954
+ initVirtualScrollY,
955
+ initVirtualScrollX,
956
+ updateVirtualScrollY,
957
+ updateVirtualScrollX
958
+ } = useVirtualScroll({ tableContainer, props, dataSourceCopy, tableHeaderLast });
959
+ const { getFixedStyle } = useFixedStyle({
960
+ props,
961
+ tableHeaderLast,
962
+ virtualScroll,
963
+ virtualScrollX,
964
+ virtualX_on,
965
+ virtualX_offsetRight
966
+ });
967
+ const { highlightRowStore, setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, tableContainer });
968
+ if (props.autoResize) {
969
+ useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs: 200 });
970
+ }
971
+ useKeyboardArrowScroll(tableContainer, {
972
+ props,
973
+ scrollTo,
974
+ virtualScroll,
975
+ virtualScrollX,
976
+ tableHeaders
977
+ });
978
+ const { getFixedColClass, dealFixedColShadow, updateFixedShadow } = useFixedCol({
979
+ props,
980
+ tableContainer,
981
+ tableHeaderLast
982
+ });
983
+ watch(
984
+ () => props.columns,
985
+ () => {
986
+ dealColumns();
987
+ initVirtualScrollX();
988
+ }
989
+ );
990
+ dealColumns();
991
+ watch(
992
+ () => props.dataSource,
993
+ (val) => {
994
+ if (!val) {
995
+ console.warn("invalid dataSource");
996
+ return;
997
+ }
998
+ let needInitVirtualScrollY = false;
999
+ if (dataSourceCopy.value.length !== val.length) {
1000
+ needInitVirtualScrollY = true;
1001
+ }
1002
+ dataSourceCopy.value = [...val];
1003
+ if (needInitVirtualScrollY)
1004
+ initVirtualScrollY();
1005
+ if (sortCol.value) {
1006
+ const column = tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
1007
+ onColumnSort(column, false);
1008
+ }
1009
+ updateFixedShadow();
1010
+ },
1011
+ {
1012
+ deep: false
1013
+ }
1014
+ );
1015
+ watch(() => props.fixedColShadow, dealFixedColShadow);
1016
+ onMounted(() => {
1017
+ initVirtualScroll();
1018
+ updateFixedShadow();
1019
+ dealDefaultSorter();
1020
+ });
1021
+ function dealDefaultSorter() {
1022
+ if (!props.sortConfig.defaultSort)
1023
+ return;
1024
+ const { dataIndex, order } = props.sortConfig.defaultSort;
1025
+ setSorter(dataIndex, order);
1026
+ }
1027
+ function dealColumns() {
1028
+ tableHeaders.value = [];
1029
+ tableHeaderLast.value = [];
1030
+ const copyColumn = props.columns;
1031
+ const deep = howDeepTheHeader(copyColumn);
1032
+ const tempHeaderLast = [];
1033
+ if (deep > 1 && props.virtualX) {
1034
+ console.error("多级表头不支持横向虚拟滚动");
1035
+ }
1036
+ function flat(arr, parent, depth = 0) {
1037
+ if (!tableHeaders.value[depth]) {
1038
+ tableHeaders.value[depth] = [];
1039
+ }
1040
+ let allChildrenLen = 0;
1041
+ arr.forEach((col) => {
1042
+ col.__PARENT__ = parent;
1043
+ let colChildrenLen = 1;
1044
+ if (col.children) {
1045
+ colChildrenLen = flat(
1046
+ col.children,
1047
+ col,
1048
+ depth + 1
1049
+ /* , col.fixed */
1050
+ );
1051
+ } else {
1052
+ tempHeaderLast.push(col);
1053
+ }
1054
+ tableHeaders.value[depth].push(col);
1055
+ const rowSpan = col.children ? 1 : deep - depth;
1056
+ const colSpan = colChildrenLen;
1057
+ if (rowSpan !== 1) {
1058
+ col.rowSpan = rowSpan;
1059
+ }
1060
+ if (colSpan !== 1) {
1061
+ col.colSpan = colSpan;
1062
+ }
1063
+ allChildrenLen += colChildrenLen;
1064
+ });
1065
+ return allChildrenLen;
1066
+ }
1067
+ flat(copyColumn, null);
1068
+ tableHeaderLast.value = tempHeaderLast;
1069
+ dealFixedColShadow();
1070
+ }
1071
+ function rowKeyGen(row) {
1072
+ if (!row)
1073
+ return;
1074
+ let key = rowKeyGenStore.get(row);
1075
+ if (!key) {
1076
+ key = typeof props.rowKey === "function" ? props.rowKey(row) : row[props.rowKey];
1077
+ rowKeyGenStore.set(row, key);
1078
+ }
1079
+ return key;
1080
+ }
1081
+ function colKeyGen(col) {
1082
+ return typeof props.colKey === "function" ? props.colKey(col) : col[props.colKey];
1083
+ }
1084
+ function getColWidthStyle(col) {
1085
+ const style = {
1086
+ width: col.width,
1087
+ minWidth: col.minWidth,
1088
+ maxWidth: col.maxWidth
1089
+ };
1090
+ if (props.colResizable) {
1091
+ style.minWidth = col.width;
1092
+ style.maxWidth = col.width;
1093
+ } else {
1094
+ style.minWidth = col.minWidth === void 0 ? col.width : col.minWidth;
1095
+ style.maxWidth = col.maxWidth === void 0 ? col.width : col.maxWidth;
1096
+ }
1097
+ return style;
1098
+ }
1099
+ function getCellStyle(tagType, col, depth) {
1100
+ const style = {
1101
+ ...getColWidthStyle(col),
1102
+ ...getFixedStyle(tagType, col, depth)
1103
+ };
1104
+ if (tagType === 1) {
1105
+ style.textAlign = col.headerAlign;
1106
+ } else if (tagType === 2) {
1107
+ style.textAlign = col.align;
1108
+ }
1109
+ return style;
1110
+ }
1111
+ function onColumnSort(col, click = true, options = {}) {
1112
+ if (!(col == null ? void 0 : col.sorter))
1113
+ return;
1114
+ options = { force: false, emit: false, ...options };
1115
+ if (sortCol.value !== col.dataIndex) {
1116
+ sortCol.value = col.dataIndex;
1117
+ sortOrderIndex.value = 0;
1118
+ }
1119
+ if (click)
1120
+ sortOrderIndex.value++;
1121
+ sortOrderIndex.value = sortOrderIndex.value % 3;
1122
+ let order = sortSwitchOrder[sortOrderIndex.value];
1123
+ const sortConfig = props.sortConfig;
1124
+ const defaultSort = sortConfig.defaultSort;
1125
+ if (!order && defaultSort) {
1126
+ order = defaultSort.order;
1127
+ sortOrderIndex.value = sortSwitchOrder.indexOf(order);
1128
+ sortCol.value = defaultSort.dataIndex;
1129
+ }
1130
+ if (!props.sortRemote || options.force) {
1131
+ dataSourceCopy.value = tableSort(col, order, props.dataSource, sortConfig);
1132
+ }
1133
+ if (click || options.emit) {
1134
+ emits("sort-change", col, order, toRaw(dataSourceCopy.value), sortConfig);
1135
+ }
1136
+ }
1137
+ function onRowClick(e, row) {
1138
+ emits("row-click", e, row);
1139
+ if (props.rowKey ? currentItemKey.value === rowKeyGen(row) : currentItem.value === row)
1140
+ return;
1141
+ currentItem.value = row;
1142
+ currentItemKey.value = rowKeyGen(row);
1143
+ emits("current-change", e, row);
1144
+ }
1145
+ function onRowDblclick(e, row) {
1146
+ emits("row-dblclick", e, row);
1147
+ }
1148
+ function onHeaderMenu(e) {
1149
+ emits("header-row-menu", e);
1150
+ }
1151
+ function onRowMenu(e, row) {
1152
+ emits("row-menu", e, row);
1153
+ }
1154
+ function onCellClick(e, row, col) {
1155
+ emits("cell-click", e, row, col);
1156
+ }
1157
+ function onHeaderCellClick(e, col) {
1158
+ emits("header-cell-click", e, col);
1159
+ }
1160
+ function onTableWheel(e) {
1161
+ if (isColResizing.value) {
1162
+ e.preventDefault();
1163
+ e.stopPropagation();
1164
+ return;
1165
+ }
1166
+ }
1167
+ function onTableScroll(e) {
1168
+ if (!(e == null ? void 0 : e.target))
1169
+ return;
1170
+ const { scrollTop, scrollLeft } = e.target;
1171
+ const { scrollTop: vScrollTop } = virtualScroll.value;
1172
+ const { scrollLeft: vScrollLeft } = virtualScrollX.value;
1173
+ const isYScroll = scrollTop !== vScrollTop;
1174
+ const isXScroll = scrollLeft !== vScrollLeft;
1175
+ if (isYScroll && virtual_on.value) {
1176
+ updateVirtualScrollY(scrollTop);
1177
+ }
1178
+ if (isXScroll) {
1179
+ updateFixedShadow();
1180
+ if (virtualX_on.value) {
1181
+ updateVirtualScrollX(scrollLeft);
1182
+ } else {
1183
+ virtualScrollX.value.scrollLeft = scrollLeft;
1184
+ }
1185
+ }
1186
+ const { startIndex, endIndex } = virtualScroll.value;
1187
+ const data = { startIndex, endIndex };
1188
+ if (isYScroll) {
1189
+ emits("scroll", e, data);
1190
+ }
1191
+ if (isXScroll) {
1192
+ emits("scroll-x", e);
1193
+ }
1194
+ }
1195
+ function onTrMouseOver(_e, row) {
1196
+ if (props.showTrHoverClass) {
1197
+ currentHover.value = rowKeyGen(row);
1198
+ }
1199
+ }
1200
+ function setCurrentRow(rowKey, option = { silent: false }) {
1201
+ if (!dataSourceCopy.value.length)
1202
+ return;
1203
+ currentItem.value = dataSourceCopy.value.find((it) => rowKeyGen(it) === rowKey);
1204
+ currentItemKey.value = rowKeyGen(currentItem.value);
1205
+ if (!option.silent) {
1206
+ emits("current-change", null, currentItem.value);
1207
+ }
1208
+ }
1209
+ function setSorter(dataIndex, order, option = {}) {
1210
+ var _a;
1211
+ const newOption = { silent: true, sortOption: null, sort: true, ...option };
1212
+ sortCol.value = dataIndex;
1213
+ sortOrderIndex.value = sortSwitchOrder.indexOf(order);
1214
+ if (newOption.sort && ((_a = dataSourceCopy.value) == null ? void 0 : _a.length)) {
1215
+ const column = newOption.sortOption || tableHeaderLast.value.find((it) => it.dataIndex === sortCol.value);
1216
+ if (column)
1217
+ onColumnSort(column, false, { force: true, emit: !newOption.silent });
1218
+ else
1219
+ console.warn("Can not find column by dataIndex:", sortCol.value);
1220
+ }
1221
+ return dataSourceCopy.value;
1222
+ }
1223
+ function resetSorter() {
1224
+ sortCol.value = null;
1225
+ sortOrderIndex.value = 0;
1226
+ dataSourceCopy.value = [...props.dataSource];
1227
+ }
1228
+ function scrollTo(top = 0, left = 0) {
1229
+ if (!tableContainer.value)
1230
+ return;
1231
+ if (top !== null)
1232
+ tableContainer.value.scrollTop = top;
1233
+ if (left !== null)
1234
+ tableContainer.value.scrollLeft = left;
1235
+ }
1236
+ function getTableData() {
1237
+ return toRaw(dataSourceCopy.value);
1238
+ }
1239
+ function getSortColumns() {
1240
+ const sortOrder = sortSwitchOrder[sortOrderIndex.value];
1241
+ if (!sortOrder)
1242
+ return [];
1243
+ return [{ dataIndex: sortCol.value, order: sortOrder }];
1244
+ }
1245
+ __expose({
1246
+ /** 初始化横向纵向虚拟滚动 */
1247
+ initVirtualScroll,
1248
+ /** 初始化横向虚拟滚动 */
1249
+ initVirtualScrollX,
1250
+ /** 初始化纵向虚拟滚动 */
1251
+ initVirtualScrollY,
1252
+ /** 设置当前选中行 */
1253
+ setCurrentRow,
1254
+ /** 设置高亮渐暗单元格 */
1255
+ setHighlightDimCell,
1256
+ /** 设置高亮渐暗行 */
1257
+ setHighlightDimRow,
1258
+ /** 表格排序列dataIndex */
1259
+ sortCol,
1260
+ /** 获取当前排序状态 */
1261
+ getSortColumns,
1262
+ /** 设置排序 */
1263
+ setSorter,
1264
+ /** 重置排序 */
1265
+ resetSorter,
1266
+ /** 滚动至 */
1267
+ scrollTo,
1268
+ /** 获取表格数据 */
1269
+ getTableData
1270
+ });
1271
+ return (_ctx, _cache) => {
1272
+ return openBlock(), createElementBlock("div", {
1273
+ ref_key: "tableContainer",
1274
+ ref: tableContainer,
1275
+ class: normalizeClass(["stk-table", {
1276
+ virtual: _ctx.virtual,
1277
+ "virtual-x": _ctx.virtualX,
1278
+ dark: _ctx.theme === "dark",
1279
+ headless: _ctx.headless,
1280
+ "is-col-resizing": unref(isColResizing),
1281
+ "col-resizable": props.colResizable,
1282
+ border: props.bordered,
1283
+ "border-h": props.bordered === "h",
1284
+ "border-v": props.bordered === "v",
1285
+ "border-body-v": props.bordered === "body-v",
1286
+ stripe: props.stripe
1287
+ }]),
1288
+ style: normalizeStyle(
1289
+ _ctx.virtual && {
1290
+ "--row-height": unref(virtualScroll).rowHeight + "px",
1291
+ "--header-row-height": (props.headerRowHeight || props.rowHeight) + "px"
1292
+ }
1293
+ ),
1294
+ onScroll: onTableScroll,
1295
+ onWheel: onTableWheel
1296
+ }, [
1297
+ withDirectives(createElementVNode("div", {
1298
+ ref_key: "colResizeIndicator",
1299
+ ref: colResizeIndicator,
1300
+ class: "column-resize-indicator"
1301
+ }, null, 512), [
1302
+ [vShow, _ctx.colResizable]
1303
+ ]),
1304
+ createElementVNode("table", {
1305
+ class: normalizeClass(["stk-table-main", {
1306
+ "fixed-mode": props.fixedMode
1307
+ }]),
1308
+ style: normalizeStyle({ width: _ctx.width, minWidth: _ctx.minWidth, maxWidth: _ctx.maxWidth })
1309
+ }, [
1310
+ !_ctx.headless ? (openBlock(), createElementBlock("thead", _hoisted_1, [
1311
+ (openBlock(true), createElementBlock(Fragment, null, renderList(tableHeaders.value, (row, rowIndex) => {
1312
+ return openBlock(), createElementBlock("tr", {
1313
+ key: rowIndex,
1314
+ onContextmenu: _cache[3] || (_cache[3] = (e) => onHeaderMenu(e))
1315
+ }, [
1316
+ unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
1317
+ key: 0,
1318
+ class: "virtual-x-left",
1319
+ style: normalizeStyle({
1320
+ minWidth: unref(virtualScrollX).offsetLeft + "px",
1321
+ width: unref(virtualScrollX).offsetLeft + "px"
1322
+ })
1323
+ }, null, 4)) : createCommentVNode("", true),
1324
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_on) && rowIndex === tableHeaders.value.length - 1 ? unref(virtualX_columnPart) : row, (col, colIndex) => {
1325
+ return openBlock(), createElementBlock("th", {
1326
+ key: col.dataIndex,
1327
+ "data-col-key": colKeyGen(col),
1328
+ draggable: unref(isHeaderDraggable)(col) ? "true" : "false",
1329
+ rowspan: unref(virtualX_on) ? 1 : col.rowSpan,
1330
+ colspan: col.colSpan,
1331
+ style: normalizeStyle(getCellStyle(1, col, rowIndex)),
1332
+ title: col.title,
1333
+ class: normalizeClass([
1334
+ col.sorter ? "sortable" : "",
1335
+ col.dataIndex === unref(sortCol) && unref(sortOrderIndex) !== 0 && "sorter-" + sortSwitchOrder[unref(sortOrderIndex)],
1336
+ _ctx.showHeaderOverflow ? "text-overflow" : "",
1337
+ col.headerClassName,
1338
+ unref(getFixedColClass)(col)
1339
+ ]),
1340
+ onClick: (e) => {
1341
+ onColumnSort(col);
1342
+ onHeaderCellClick(e, col);
1343
+ },
1344
+ onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
1345
+ (...args) => unref(onThDragStart) && unref(onThDragStart)(...args)),
1346
+ onDrop: _cache[1] || (_cache[1] = //@ts-ignore
1347
+ (...args) => unref(onThDrop) && unref(onThDrop)(...args)),
1348
+ onDragover: _cache[2] || (_cache[2] = //@ts-ignore
1349
+ (...args) => unref(onThDragOver) && unref(onThDragOver)(...args))
1350
+ }, [
1351
+ createElementVNode("div", _hoisted_3, [
1352
+ col.customHeaderCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customHeaderCell), {
1353
+ key: 0,
1354
+ col
1355
+ }, null, 8, ["col"])) : renderSlot(_ctx.$slots, "tableHeader", {
1356
+ key: 1,
1357
+ col
1358
+ }, () => [
1359
+ createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
1360
+ ]),
1361
+ col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true),
1362
+ _ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
1363
+ key: 3,
1364
+ class: "table-header-resizer left",
1365
+ onMousedown: (e) => unref(onThResizeMouseDown)(e, col, true)
1366
+ }, null, 40, _hoisted_8)) : createCommentVNode("", true),
1367
+ _ctx.colResizable ? (openBlock(), createElementBlock("div", {
1368
+ key: 4,
1369
+ class: "table-header-resizer right",
1370
+ onMousedown: (e) => unref(onThResizeMouseDown)(e, col)
1371
+ }, null, 40, _hoisted_9)) : createCommentVNode("", true)
1372
+ ])
1373
+ ], 46, _hoisted_2);
1374
+ }), 128)),
1375
+ unref(virtualX_on) ? (openBlock(), createElementBlock("th", {
1376
+ key: 1,
1377
+ class: "virtual-x-right",
1378
+ style: normalizeStyle({
1379
+ minWidth: unref(virtualX_offsetRight) + "px",
1380
+ width: unref(virtualX_offsetRight) + "px"
1381
+ })
1382
+ }, null, 4)) : createCommentVNode("", true)
1383
+ ], 32);
1384
+ }), 128))
1385
+ ])) : createCommentVNode("", true),
1386
+ createElementVNode("tbody", null, [
1387
+ unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1388
+ key: 0,
1389
+ style: normalizeStyle({ height: `${unref(virtualScroll).offsetTop}px` }),
1390
+ class: "padding-top-tr"
1391
+ }, [
1392
+ unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true),
1393
+ _ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(virtualX_columnPart), (col) => {
1394
+ return openBlock(), createElementBlock("td", {
1395
+ key: col.dataIndex,
1396
+ style: normalizeStyle(getCellStyle(2, col))
1397
+ }, null, 4);
1398
+ }), 128)) : createCommentVNode("", true)
1399
+ ], 4)) : createCommentVNode("", true),
1400
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, i) => {
1401
+ var _a;
1402
+ return openBlock(), createElementBlock("tr", {
1403
+ key: _ctx.rowKey ? rowKeyGen(row) : i,
1404
+ "data-row-key": _ctx.rowKey ? rowKeyGen(row) : i,
1405
+ class: normalizeClass({
1406
+ active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
1407
+ hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
1408
+ [_ctx.rowClassName(row, i)]: true
1409
+ }),
1410
+ style: normalizeStyle({
1411
+ backgroundColor: (_a = unref(highlightRowStore)[rowKeyGen(row)]) == null ? void 0 : _a.bgc
1412
+ }),
1413
+ onClick: (e) => onRowClick(e, row),
1414
+ onDblclick: (e) => onRowDblclick(e, row),
1415
+ onContextmenu: (e) => onRowMenu(e, row),
1416
+ onMouseover: (e) => onTrMouseOver(e, row)
1417
+ }, [
1418
+ unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true),
1419
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
1420
+ return openBlock(), createElementBlock("td", {
1421
+ key: col.dataIndex,
1422
+ "data-index": col.dataIndex,
1423
+ class: normalizeClass([col.className, _ctx.showOverflow ? "text-overflow" : "", unref(getFixedColClass)(col)]),
1424
+ style: normalizeStyle(getCellStyle(2, col)),
1425
+ onClick: (e) => onCellClick(e, row, col)
1426
+ }, [
1427
+ col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
1428
+ key: 0,
1429
+ col,
1430
+ row,
1431
+ "cell-value": row[col.dataIndex]
1432
+ }, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
1433
+ key: 1,
1434
+ class: "table-cell-wrapper",
1435
+ title: row[col.dataIndex]
1436
+ }, toDisplayString(row[col.dataIndex] ?? _ctx.emptyCellText), 9, _hoisted_14))
1437
+ ], 14, _hoisted_13);
1438
+ }), 128))
1439
+ ], 46, _hoisted_11);
1440
+ }), 128)),
1441
+ unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
1442
+ key: 1,
1443
+ style: normalizeStyle({ height: `${unref(virtual_offsetBottom)}px` })
1444
+ }, null, 4)) : createCommentVNode("", true)
1445
+ ])
1446
+ ], 6),
1447
+ (!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
1448
+ key: 0,
1449
+ class: normalizeClass(["stk-table-no-data", { "no-data-full": _ctx.noDataFull }])
1450
+ }, [
1451
+ renderSlot(_ctx.$slots, "empty", {}, () => [
1452
+ createTextVNode("暂无数据")
1453
+ ])
1454
+ ], 2)) : createCommentVNode("", true)
1455
+ ], 38);
1456
+ };
1457
+ }
1458
+ });
1459
+ export {
1460
+ _sfc_main as StkTable,
1461
+ insertToOrderedArray,
1462
+ tableSort
1463
+ };