1
1
<template >
2
2
<div class =' dg-wrapper' >
3
- <div class = ' dg- scroller' v-virtual = ' virtual ' >
3
+ <virt-scroller ref = ' scroller' class = ' dg-scroller ' >
4
4
<table class =' dg' :class =' selected && "dg-selectable"' >
5
5
<thead >
6
6
<tr >
19
19
</tr >
20
20
<tr v-if =' loading' class =' dg-loader' ></tr >
21
21
</thead >
22
- <tbody @click =' toggle($event.target)' >
23
- <tr :style =' { height: virtual.topGap + "px" }' ></tr >
24
- <tr v-for =' d of virtual' :key =' d.id'
25
- class =' dg-row' :class =' selected && selected.has(d) && "dg-selected"'
26
- :true-value =' d' >
22
+ <virt-body @click =' toggle($event.target)' v-slot =' { items }' >
23
+ <tr v-for =' d of items()' :key =' d.id' v-item =' d'
24
+ class =' dg-row' :class =' selected && selected.has(d) && "dg-selected"' >
27
25
<td v-if =' selected' class =' dg-cell' >
28
26
<input type =' checkbox' :checked =' selected.has(d)' />
29
27
</td >
30
28
<td v-for =' c of columns' v-text =' d[c.data]' class =' dg-cell' :class =' c.right && "dg-right"' />
31
29
<td class =' dg-cell dg-fill' />
32
30
</tr >
33
- <tr :style =' { height: virtual.bottomGap + "px" }' ></tr >
34
- </tbody >
31
+ </virt-body >
35
32
</table >
36
- </div >
33
+ </virt-scroller >
37
34
</div >
38
35
</template >
39
36
40
37
<script lang="ts">
41
38
import { shallowRef as sref , watch } from ' vue' ;
42
39
import { Column } from " ./column" ;
43
- import { useSelection } from " ./selection" ;
40
+ import { useSelection , ItemDirective } from " ./selection" ;
44
41
import SortIndicator from ' ./sort-indicator' ;
45
42
import { useSorting } from " ./sorting" ;
46
- import { useVirtual , VirtualTable } from " ./virtual" ;
43
+ import { useVirtual , VirtualBody , VirtualScroller } from " ./virtual/index " ;
47
44
48
45
export default {
49
46
components: {
50
47
' sort-indicator' : SortIndicator ,
48
+ ' virt-body' : VirtualBody ,
49
+ ' virt-scroller' : VirtualScroller ,
51
50
},
52
51
53
52
directives: {
54
- ' virtual ' : VirtualTable ,
53
+ ' item ' : ItemDirective ,
55
54
},
56
55
57
56
props: {
@@ -65,13 +64,13 @@ export default {
65
64
const data = sref ([] as object []);
66
65
const selection = useSelection (data , props .selected );
67
66
const sorting = useSorting (data );
68
- const virtual = useVirtual (sorting .data );
67
+ const { scrollToTop } = useVirtual (sorting .data );
69
68
70
69
watch (async () => {
71
70
loading .value = true ;
72
71
data .value = await props .data ! ;
73
72
loading .value = false ;
74
- virtual . scrollToTop ();
73
+ scrollToTop ();
75
74
});
76
75
77
76
return {
@@ -80,7 +79,6 @@ export default {
80
79
selected: props .selected ,
81
80
... selection ,
82
81
... sorting ,
83
- virtual ,
84
82
};
85
83
}
86
84
};
0 commit comments