stk-table-vue 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -17
- package/lib/src/StkTable/StkTable.vue.d.ts +373 -367
- package/lib/src/StkTable/const.d.ts +21 -21
- package/lib/src/StkTable/index.d.ts +3 -3
- package/lib/src/StkTable/types/index.d.ts +73 -73
- package/lib/src/StkTable/useAutoResize.d.ts +14 -15
- package/lib/src/StkTable/useColResize.d.ts +18 -18
- package/lib/src/StkTable/useFixedCol.d.ts +20 -20
- package/lib/src/StkTable/useFixedStyle.d.ts +20 -20
- package/lib/src/StkTable/useHighlight.d.ts +19 -19
- package/lib/src/StkTable/useKeyboardArrowScroll.d.ts +17 -17
- package/lib/src/StkTable/useThDrag.d.ts +17 -14
- package/lib/src/StkTable/useVirtualScroll.d.ts +73 -73
- package/lib/src/StkTable/utils.d.ts +25 -23
- package/lib/stk-table-vue.js +1422 -1490
- package/lib/style.css +298 -294
- package/lib/test/StkTable.browser.test.d.ts +1 -1
- package/lib/test/insertToOrderedArray.test.d.ts +1 -1
- package/lib/test/utils/DragResize.d.ts +28 -28
- package/lib/test/utils/h.d.ts +10 -10
- package/package.json +2 -2
- package/src/StkTable/StkTable.vue +20 -8
- package/src/StkTable/style.less +7 -5
- package/src/StkTable/types/index.ts +3 -3
- package/src/StkTable/useAutoResize.ts +2 -3
- package/src/StkTable/useColResize.ts +3 -3
- package/src/StkTable/useFixedCol.ts +1 -1
- package/src/StkTable/useFixedStyle.ts +4 -3
- package/src/StkTable/useHighlight.ts +2 -0
- package/src/StkTable/useThDrag.ts +37 -8
- package/src/StkTable/useVirtualScroll.ts +6 -12
- package/src/StkTable/utils.ts +9 -0
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,1490 +1,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,
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
function
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
const
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
const
|
|
821
|
-
key:
|
|
822
|
-
class: "
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
},
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
},
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
},
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
},
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
},
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
},
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
},
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
}
|
|
1188
|
-
function
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
function
|
|
1197
|
-
|
|
1198
|
-
}
|
|
1199
|
-
function
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
"
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
})
|
|
1424
|
-
}, null, 4)) : createCommentVNode("", true)], 32);
|
|
1425
|
-
}), 128))])) : createCommentVNode("", true), createElementVNode("tbody", null, [unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1426
|
-
key: 0,
|
|
1427
|
-
style: normalizeStyle({
|
|
1428
|
-
height: `${unref(virtualScroll).offsetTop}px`
|
|
1429
|
-
}),
|
|
1430
|
-
class: "padding-top-tr"
|
|
1431
|
-
}, [unref(virtualX_on) && _ctx.fixedMode && _ctx.headless ? (openBlock(), createElementBlock("td", _hoisted_10)) : createCommentVNode("", true), _ctx.fixedMode && _ctx.headless ? (openBlock(true), createElementBlock(Fragment, {
|
|
1432
|
-
key: 1
|
|
1433
|
-
}, renderList(unref(virtualX_columnPart), (col) => {
|
|
1434
|
-
return openBlock(), createElementBlock("td", {
|
|
1435
|
-
key: col.dataIndex,
|
|
1436
|
-
style: normalizeStyle(getCellStyle(2, col))
|
|
1437
|
-
}, null, 4);
|
|
1438
|
-
}), 128)) : createCommentVNode("", true)], 4)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, i) => {
|
|
1439
|
-
return openBlock(), createElementBlock("tr", {
|
|
1440
|
-
key: _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1441
|
-
"data-row-key": _ctx.rowKey ? rowKeyGen(row) : i,
|
|
1442
|
-
class: normalizeClass({
|
|
1443
|
-
active: _ctx.rowKey ? rowKeyGen(row) === rowKeyGen(currentItem.value) : row === currentItem.value,
|
|
1444
|
-
hover: _ctx.rowKey ? rowKeyGen(row) === currentHover.value : row === currentHover.value,
|
|
1445
|
-
[_ctx.rowClassName(row, i)]: true
|
|
1446
|
-
}),
|
|
1447
|
-
style: normalizeStyle({
|
|
1448
|
-
backgroundColor: row._bgc
|
|
1449
|
-
}),
|
|
1450
|
-
onClick: (e) => onRowClick(e, row),
|
|
1451
|
-
onDblclick: (e) => onRowDblclick(e, row),
|
|
1452
|
-
onContextmenu: (e) => onRowMenu(e, row),
|
|
1453
|
-
onMouseover: (e) => onTrMouseOver(e, row)
|
|
1454
|
-
}, [unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_12)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtualX_columnPart), (col) => {
|
|
1455
|
-
return openBlock(), createElementBlock("td", {
|
|
1456
|
-
key: col.dataIndex,
|
|
1457
|
-
"data-index": col.dataIndex,
|
|
1458
|
-
class: normalizeClass([col.className, _ctx.showOverflow ? "text-overflow" : "", unref(getFixedColClass)(col)]),
|
|
1459
|
-
style: normalizeStyle(getCellStyle(2, col)),
|
|
1460
|
-
onClick: (e) => onCellClick(e, row, col)
|
|
1461
|
-
}, [col.customCell ? (openBlock(), createBlock(resolveDynamicComponent(col.customCell), {
|
|
1462
|
-
key: 0,
|
|
1463
|
-
col,
|
|
1464
|
-
row,
|
|
1465
|
-
"cell-value": row[col.dataIndex]
|
|
1466
|
-
}, null, 8, ["col", "row", "cell-value"])) : (openBlock(), createElementBlock("div", {
|
|
1467
|
-
key: 1,
|
|
1468
|
-
class: "table-cell-wrapper",
|
|
1469
|
-
title: row[col.dataIndex]
|
|
1470
|
-
}, toDisplayString(row[col.dataIndex] ?? _ctx.emptyCellText), 9, _hoisted_14))], 14, _hoisted_13);
|
|
1471
|
-
}), 128))], 46, _hoisted_11);
|
|
1472
|
-
}), 128)), unref(virtual_on) ? (openBlock(), createElementBlock("tr", {
|
|
1473
|
-
key: 1,
|
|
1474
|
-
style: normalizeStyle({
|
|
1475
|
-
height: `${unref(virtual_offsetBottom)}px`
|
|
1476
|
-
})
|
|
1477
|
-
}, null, 4)) : createCommentVNode("", true)])], 6), (!dataSourceCopy.value || !dataSourceCopy.value.length) && _ctx.showNoData ? (openBlock(), createElementBlock("div", {
|
|
1478
|
-
key: 0,
|
|
1479
|
-
class: normalizeClass(["stk-table-no-data", {
|
|
1480
|
-
"no-data-full": _ctx.noDataFull
|
|
1481
|
-
}])
|
|
1482
|
-
}, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode("暂无数据")])], 2)) : createCommentVNode("", true)], 38);
|
|
1483
|
-
};
|
|
1484
|
-
}
|
|
1485
|
-
});
|
|
1486
|
-
export {
|
|
1487
|
-
_sfc_main as StkTable,
|
|
1488
|
-
insertToOrderedArray,
|
|
1489
|
-
tableSort
|
|
1490
|
-
};
|
|
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
|
+
};
|