@dataloop-ai/components 0.17.1 → 0.17.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.
- package/package.json +2 -2
- package/src/components/basic/DlMarkupTable/DlMarkupTable.vue +58 -0
- package/src/components/basic/DlMarkupTable/index.ts +2 -0
- package/src/components/basic/index.ts +1 -0
- package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +12 -3
- package/src/components/compound/DlTable/DlTable.vue +8 -3
- package/src/components/compound/DlTable/styles/dl-table-styles.scss +20 -0
- package/src/components/compound/DlTable/utils/getTableMiddle.ts +5 -0
- package/src/components/essential/DlList/DlList.vue +8 -3
- package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +140 -162
- package/src/components/shared/DlVirtualScroll/styles/dl-virtual-scroll-styles.scss +52 -0
- package/src/components/shared/DlVirtualScroll/useVirtualScroll.ts +186 -43
- package/src/demos/DlMarkupTableDemo.vue +167 -0
- package/src/demos/DlVirtualScrollDemo.vue +305 -0
- package/src/demos/index.ts +5 -1
- package/src/utils/events.ts +19 -2
- package/src/utils/render.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"format": "prettier --write ./src",
|
|
19
19
|
"lint-staged": "lint-staged",
|
|
20
20
|
"test": "vitest",
|
|
21
|
-
"test:coverage": "vitest run --coverage",
|
|
21
|
+
"test:coverage": "vitest run --coverage --silent",
|
|
22
22
|
"check-only": "if grep -E -H -r --exclude-dir=.git --exclude-dir=node_modules --exclude=*.json --exclude=*.yml '^(describe|it).only' .; then echo 'Found only in test files' && exit 1; fi"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
:class="classes"
|
|
5
|
+
>
|
|
6
|
+
<table class="dl-table">
|
|
7
|
+
<slot />
|
|
8
|
+
</table>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { v4 } from 'uuid'
|
|
14
|
+
import { defineComponent, computed, ref } from 'vue-demi'
|
|
15
|
+
|
|
16
|
+
const separatorValues = ['horizontal', 'vertical', 'cell', 'none']
|
|
17
|
+
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'DlMarkupTable',
|
|
20
|
+
props: {
|
|
21
|
+
dense: Boolean,
|
|
22
|
+
flat: Boolean,
|
|
23
|
+
bordered: Boolean,
|
|
24
|
+
square: Boolean,
|
|
25
|
+
wrapCells: Boolean,
|
|
26
|
+
|
|
27
|
+
separator: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'horizontal',
|
|
30
|
+
validator: (v: (typeof separatorValues)[number]) =>
|
|
31
|
+
separatorValues.includes(v)
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setup(props) {
|
|
35
|
+
const uuid = ref(`dl-markup-table-${v4()}`)
|
|
36
|
+
|
|
37
|
+
const classes = computed(
|
|
38
|
+
() =>
|
|
39
|
+
'dl-markup-table dl-table__container dl-table__card' +
|
|
40
|
+
` dl-table--${props.separator}-separator` +
|
|
41
|
+
(props.dense === true ? ' dl-table--dense' : '') +
|
|
42
|
+
(props.flat === true ? ' dl-table--flat' : '') +
|
|
43
|
+
(props.bordered === true ? ' dl-table--bordered' : '') +
|
|
44
|
+
(props.square === true ? ' dl-table--square' : '') +
|
|
45
|
+
(props.wrapCells === false ? ' dl-table--no-wrap' : '')
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
classes,
|
|
50
|
+
uuid
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<style scoped lang="scss">
|
|
57
|
+
@import '../../compound/DlTable/styles/dl-table-styles.scss';
|
|
58
|
+
</style>
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
disableDropdown === true
|
|
116
116
|
"
|
|
117
117
|
:disabled="disabled === true || disableMainButton === true"
|
|
118
|
-
:style="mainButtonStyle"
|
|
118
|
+
:style="[mainButtonStyle, cssVars]"
|
|
119
119
|
:no-wrap="props.noWrap"
|
|
120
120
|
:tooltip="tooltip"
|
|
121
121
|
:max-width="maxWidth"
|
|
@@ -316,6 +316,14 @@ export default defineComponent({
|
|
|
316
316
|
}
|
|
317
317
|
})
|
|
318
318
|
|
|
319
|
+
const cssVars = computed(() => {
|
|
320
|
+
return {
|
|
321
|
+
'--justify-content': props.fluid
|
|
322
|
+
? 'space-between'
|
|
323
|
+
: 'space-around'
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
|
|
319
327
|
watch(
|
|
320
328
|
() => props.modelValue,
|
|
321
329
|
(val) => {
|
|
@@ -416,7 +424,8 @@ export default defineComponent({
|
|
|
416
424
|
menuModel,
|
|
417
425
|
props,
|
|
418
426
|
setHighlightedIndex,
|
|
419
|
-
handleSelectedItem
|
|
427
|
+
handleSelectedItem,
|
|
428
|
+
cssVars
|
|
420
429
|
}
|
|
421
430
|
}
|
|
422
431
|
})
|
|
@@ -467,7 +476,7 @@ export default defineComponent({
|
|
|
467
476
|
&__title {
|
|
468
477
|
display: flex;
|
|
469
478
|
align-items: center;
|
|
470
|
-
justify-content:
|
|
479
|
+
justify-content: var(--justify-content);
|
|
471
480
|
text-align: center;
|
|
472
481
|
padding: 0;
|
|
473
482
|
flex: 10000 1 0%;
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
<DlVirtualScroll
|
|
58
58
|
v-if="hasVirtScroll"
|
|
59
59
|
ref="virtScrollRef"
|
|
60
|
+
type="__dltable"
|
|
60
61
|
:class="tableClass"
|
|
61
|
-
:draggable-classes="additionalClasses"
|
|
62
62
|
:style="tableStyle"
|
|
63
|
+
:table-colspan="computedColspan"
|
|
63
64
|
:scroll-target="virtualScrollTarget"
|
|
64
65
|
:items="computedRows"
|
|
65
|
-
:table-colspan="computedColspan"
|
|
66
66
|
v-bind="virtProps"
|
|
67
67
|
@virtual-scroll="onVScroll"
|
|
68
68
|
>
|
|
@@ -492,7 +492,7 @@ import {
|
|
|
492
492
|
commonVirtScrollProps,
|
|
493
493
|
ScrollDetails
|
|
494
494
|
} from '../../shared/DlVirtualScroll/useVirtualScroll'
|
|
495
|
-
import
|
|
495
|
+
import DlVirtualScroll from '../../shared/DlVirtualScroll/DlVirtualScroll.vue'
|
|
496
496
|
import { useTableFilter, useTableFilterProps } from './hooks/tableFilter'
|
|
497
497
|
import { useTableSort, useTableSortProps } from './hooks/tableSort'
|
|
498
498
|
import {
|
|
@@ -521,6 +521,11 @@ import { DlIcon, DlCheckbox, DlProgressBar } from '../../essential'
|
|
|
521
521
|
import { ResizableManager } from './utils'
|
|
522
522
|
import { v4 } from 'uuid'
|
|
523
523
|
|
|
524
|
+
const commonVirtPropsObj = {} as Record<string, any>
|
|
525
|
+
commonVirtPropsList.forEach((p) => {
|
|
526
|
+
commonVirtPropsObj[p] = {}
|
|
527
|
+
})
|
|
528
|
+
|
|
524
529
|
export default defineComponent({
|
|
525
530
|
name: 'DlTable',
|
|
526
531
|
components: {
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
.dl-markup-table {
|
|
2
|
+
overflow: auto;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.dl-table {
|
|
2
6
|
width: 100%;
|
|
3
7
|
max-width: 100%;
|
|
4
8
|
border-collapse: separate;
|
|
5
9
|
border-spacing: 0;
|
|
6
10
|
|
|
11
|
+
//markup-table
|
|
12
|
+
|
|
13
|
+
&__card {
|
|
14
|
+
background-color: var(--dl-color-panel-background);
|
|
15
|
+
border-radius: 2px;
|
|
16
|
+
|
|
17
|
+
.dl-table__middle {
|
|
18
|
+
flex: 1 1 auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dl-table__top,
|
|
22
|
+
.dl-table__bottom {
|
|
23
|
+
flex: 0 0 auto;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
.dl-table__top,
|
|
8
28
|
.dl-table__bottom,
|
|
9
29
|
thead tr:first-child th {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<component
|
|
3
|
+
:is="tag"
|
|
3
4
|
:id="uuid"
|
|
4
5
|
:class="classes"
|
|
5
6
|
>
|
|
6
7
|
<slot :clickable="clickable" />
|
|
7
|
-
</
|
|
8
|
+
</component>
|
|
8
9
|
</template>
|
|
9
10
|
|
|
10
11
|
<script lang="ts">
|
|
@@ -16,7 +17,11 @@ export default defineComponent({
|
|
|
16
17
|
bordered: Boolean,
|
|
17
18
|
separator: Boolean,
|
|
18
19
|
padding: Boolean,
|
|
19
|
-
clickable: Boolean
|
|
20
|
+
clickable: Boolean,
|
|
21
|
+
tag: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'div'
|
|
24
|
+
}
|
|
20
25
|
},
|
|
21
26
|
data() {
|
|
22
27
|
return {
|
|
@@ -1,69 +1,7 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- Component was created based on Quasar: https://github.com/quasarframework/quasar/blob/dev/ui/src/components/virtual-scroll/QVirtualScroll.js -->
|
|
3
|
-
<div
|
|
4
|
-
:id="uuid"
|
|
5
|
-
ref="rootRef"
|
|
6
|
-
:style="cssVars"
|
|
7
|
-
class="dl-table__middle"
|
|
8
|
-
:class="classes"
|
|
9
|
-
>
|
|
10
|
-
<table
|
|
11
|
-
class="dl-table"
|
|
12
|
-
:class="draggableClasses"
|
|
13
|
-
>
|
|
14
|
-
<slot
|
|
15
|
-
v-if="hasBeforeSlot"
|
|
16
|
-
name="before"
|
|
17
|
-
/>
|
|
18
|
-
<tbody
|
|
19
|
-
key="before"
|
|
20
|
-
ref="beforeRef"
|
|
21
|
-
class="dl-virtual-scroll__padding"
|
|
22
|
-
>
|
|
23
|
-
<tr>
|
|
24
|
-
<td
|
|
25
|
-
class="dl-virtual-scroll__before"
|
|
26
|
-
:colspan="colspanAttr"
|
|
27
|
-
/>
|
|
28
|
-
</tr>
|
|
29
|
-
</tbody>
|
|
30
|
-
<tbody
|
|
31
|
-
id="draggable"
|
|
32
|
-
key="content"
|
|
33
|
-
ref="contentRef"
|
|
34
|
-
class="dl-virtual-scroll__content"
|
|
35
|
-
tabindex="-1"
|
|
36
|
-
>
|
|
37
|
-
<slot
|
|
38
|
-
v-for="scope in virtualScrollScope"
|
|
39
|
-
:item="scope.item"
|
|
40
|
-
/>
|
|
41
|
-
</tbody>
|
|
42
|
-
<tbody
|
|
43
|
-
key="after"
|
|
44
|
-
ref="afterRef"
|
|
45
|
-
class="dl-virtual-scroll__padding"
|
|
46
|
-
>
|
|
47
|
-
<tr>
|
|
48
|
-
<td
|
|
49
|
-
class="dl-virtual-scroll__after"
|
|
50
|
-
:colspan="colspanAttr"
|
|
51
|
-
/>
|
|
52
|
-
</tr>
|
|
53
|
-
</tbody>
|
|
54
|
-
<slot
|
|
55
|
-
v-if="hasAfterSlot"
|
|
56
|
-
name="after"
|
|
57
|
-
/>
|
|
58
|
-
</table>
|
|
59
|
-
</div>
|
|
60
|
-
</template>
|
|
61
1
|
<script lang="ts">
|
|
62
|
-
import { v4 } from 'uuid'
|
|
63
2
|
import {
|
|
64
3
|
computed,
|
|
65
4
|
defineComponent,
|
|
66
|
-
getCurrentInstance,
|
|
67
5
|
onActivated,
|
|
68
6
|
onBeforeMount,
|
|
69
7
|
onBeforeUnmount,
|
|
@@ -71,25 +9,75 @@ import {
|
|
|
71
9
|
onMounted,
|
|
72
10
|
Ref,
|
|
73
11
|
ref,
|
|
74
|
-
watch
|
|
12
|
+
watch,
|
|
13
|
+
isVue2,
|
|
14
|
+
h
|
|
75
15
|
} from 'vue-demi'
|
|
76
|
-
import
|
|
16
|
+
import getTableMiddle from '../../compound/DlTable/utils/getTableMiddle'
|
|
17
|
+
import { listenOpts, mergeSlot } from '../../../utils'
|
|
77
18
|
import { getScrollTarget } from '../../../utils/scroll'
|
|
78
|
-
import {
|
|
19
|
+
import { DlList } from '../../essential/DlList'
|
|
20
|
+
import { DlMarkupTable } from '../../basic/DlMarkupTable'
|
|
21
|
+
import { useVirtualScroll } from './useVirtualScroll'
|
|
22
|
+
|
|
23
|
+
const comps = {
|
|
24
|
+
list: DlList,
|
|
25
|
+
table: DlMarkupTable
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const virtualScrollRootTag = {
|
|
29
|
+
list: 'div',
|
|
30
|
+
table: 'tbody',
|
|
31
|
+
__dltable: 'tbody'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const typeOptions = ['list', 'table', '__dltable']
|
|
79
35
|
|
|
80
36
|
export default defineComponent({
|
|
81
|
-
name: '
|
|
37
|
+
name: 'DllVirtualScroll',
|
|
82
38
|
props: {
|
|
83
|
-
|
|
39
|
+
virtualScrollSliceSize: {
|
|
40
|
+
type: [Number, String],
|
|
41
|
+
default: null as number
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
virtualScrollSliceRatioBefore: {
|
|
45
|
+
type: [Number, String],
|
|
46
|
+
default: 1
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
virtualScrollSliceRatioAfter: {
|
|
50
|
+
type: [Number, String],
|
|
51
|
+
default: 1
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
virtualScrollItemSize: {
|
|
55
|
+
type: [Number, String],
|
|
56
|
+
default: 0
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
virtualScrollStickySizeStart: {
|
|
60
|
+
type: [Number, String],
|
|
61
|
+
default: 0
|
|
62
|
+
},
|
|
84
63
|
|
|
64
|
+
virtualScrollStickySizeEnd: {
|
|
65
|
+
type: [Number, String],
|
|
66
|
+
default: 0
|
|
67
|
+
},
|
|
68
|
+
tableColspan: [Number, String],
|
|
69
|
+
virtualScrollHorizontal: Boolean,
|
|
70
|
+
onVirtualScroll: Function,
|
|
85
71
|
items: {
|
|
86
72
|
type: Array,
|
|
87
73
|
default: () => [] as Record<string, any>[]
|
|
88
74
|
},
|
|
89
75
|
|
|
90
|
-
|
|
91
|
-
type:
|
|
92
|
-
default:
|
|
76
|
+
type: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: 'list',
|
|
79
|
+
validator: (v: (typeof typeOptions)[number]) =>
|
|
80
|
+
typeOptions.includes(v)
|
|
93
81
|
},
|
|
94
82
|
|
|
95
83
|
itemsFn: { type: Function, default: void 0 },
|
|
@@ -99,30 +87,24 @@ export default defineComponent({
|
|
|
99
87
|
default: void 0
|
|
100
88
|
}
|
|
101
89
|
},
|
|
90
|
+
emits: ['virtual-scroll'],
|
|
102
91
|
setup(props, { slots, attrs }) {
|
|
103
|
-
const vm = getCurrentInstance()
|
|
104
|
-
|
|
105
92
|
let localScrollTarget: HTMLElement | undefined
|
|
106
93
|
const rootRef: Ref<HTMLElement | null> = ref(null)
|
|
107
94
|
|
|
108
|
-
const virtualScrollLength = computed(() =>
|
|
109
|
-
|
|
95
|
+
const virtualScrollLength = computed(() => {
|
|
96
|
+
return props.itemsSize >= 0 && props.itemsFn !== void 0
|
|
110
97
|
? parseInt(props.itemsSize as unknown as string, 10)
|
|
111
98
|
: Array.isArray(props.items)
|
|
112
99
|
? props.items.length
|
|
113
100
|
: 0
|
|
114
|
-
)
|
|
101
|
+
})
|
|
115
102
|
|
|
116
103
|
const {
|
|
117
104
|
virtualScrollSliceRange,
|
|
118
105
|
localResetVirtualScroll,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
virtualScrollPaddingAfter,
|
|
122
|
-
beforeRef,
|
|
123
|
-
afterRef,
|
|
124
|
-
contentRef,
|
|
125
|
-
colspanAttr
|
|
106
|
+
padVirtualScroll,
|
|
107
|
+
onVirtualScrollEvt
|
|
126
108
|
} = useVirtualScroll({
|
|
127
109
|
virtualScrollLength,
|
|
128
110
|
getVirtualScrollTarget,
|
|
@@ -139,44 +121,35 @@ export default defineComponent({
|
|
|
139
121
|
item
|
|
140
122
|
})
|
|
141
123
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
124
|
+
return props.itemsFn === void 0
|
|
125
|
+
? props.items
|
|
126
|
+
.slice(
|
|
127
|
+
virtualScrollSliceRange.value.from,
|
|
128
|
+
virtualScrollSliceRange.value.to
|
|
129
|
+
)
|
|
130
|
+
.map(mapFn)
|
|
131
|
+
: props
|
|
132
|
+
.itemsFn(
|
|
133
|
+
virtualScrollSliceRange.value.from,
|
|
134
|
+
virtualScrollSliceRange.value.to -
|
|
135
|
+
virtualScrollSliceRange.value.from
|
|
136
|
+
)
|
|
137
|
+
.map(mapFn)
|
|
156
138
|
})
|
|
157
139
|
|
|
158
140
|
const classes = computed(
|
|
159
141
|
() =>
|
|
160
|
-
|
|
142
|
+
`dl-virtual-scroll dl-virtual-scroll` +
|
|
143
|
+
(props.virtualScrollHorizontal === true
|
|
144
|
+
? '--horizontal'
|
|
145
|
+
: '--vertical') +
|
|
161
146
|
(props.scrollTarget !== void 0 ? '' : ' scroll')
|
|
162
147
|
)
|
|
163
148
|
|
|
164
|
-
const cssVars = computed(() => {
|
|
165
|
-
return {
|
|
166
|
-
'--item-height-before': virtualScrollPaddingBefore.value + 'px',
|
|
167
|
-
'--item-height-after': virtualScrollPaddingAfter.value + 'px',
|
|
168
|
-
'--dl-virtual-scroll-item-height':
|
|
169
|
-
props.virtualScrollItemSize + 'px'
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
|
|
173
149
|
const attributes = computed(() =>
|
|
174
150
|
props.scrollTarget !== void 0 ? {} : { tabindex: 0 }
|
|
175
151
|
)
|
|
176
152
|
|
|
177
|
-
const hasBeforeSlot = computed(() => !!slots['before'])
|
|
178
|
-
const hasAfterSlot = computed(() => !!slots['after'])
|
|
179
|
-
|
|
180
153
|
watch(virtualScrollLength, () => {
|
|
181
154
|
localResetVirtualScroll()
|
|
182
155
|
})
|
|
@@ -190,9 +163,7 @@ export default defineComponent({
|
|
|
190
163
|
)
|
|
191
164
|
|
|
192
165
|
function getVirtualScrollEl() {
|
|
193
|
-
return (
|
|
194
|
-
(rootRef.value && (rootRef.value as any).$el) || rootRef.value
|
|
195
|
-
)
|
|
166
|
+
return (rootRef.value as any)?.$el || rootRef.value
|
|
196
167
|
}
|
|
197
168
|
|
|
198
169
|
function getVirtualScrollTarget() {
|
|
@@ -223,6 +194,22 @@ export default defineComponent({
|
|
|
223
194
|
}
|
|
224
195
|
}
|
|
225
196
|
|
|
197
|
+
function __getVirtualChildren(create: Function) {
|
|
198
|
+
let child = padVirtualScroll(
|
|
199
|
+
virtualScrollRootTag[
|
|
200
|
+
props.type as 'list' | 'table' | '__dltable'
|
|
201
|
+
] || 'div',
|
|
202
|
+
virtualScrollScope.value.map(slots.default),
|
|
203
|
+
create
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if (slots.before !== void 0) {
|
|
207
|
+
child = slots.before().concat(child)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return mergeSlot(slots.after, child)
|
|
211
|
+
}
|
|
212
|
+
|
|
226
213
|
onBeforeMount(() => {
|
|
227
214
|
localResetVirtualScroll()
|
|
228
215
|
})
|
|
@@ -243,63 +230,54 @@ export default defineComponent({
|
|
|
243
230
|
unconfigureScrollTarget()
|
|
244
231
|
})
|
|
245
232
|
|
|
233
|
+
const hasDefaultSlot = computed(() => {
|
|
234
|
+
return !!slots.default
|
|
235
|
+
})
|
|
236
|
+
|
|
246
237
|
return {
|
|
247
|
-
|
|
238
|
+
hasDefaultSlot,
|
|
239
|
+
getVirtualChildren: __getVirtualChildren,
|
|
240
|
+
tag: (comps as Record<string, any>)[props.type] || props.type,
|
|
241
|
+
attrs,
|
|
248
242
|
rootRef,
|
|
249
|
-
beforeRef,
|
|
250
|
-
afterRef,
|
|
251
|
-
contentRef,
|
|
252
|
-
virtualScrollScope,
|
|
253
|
-
virtualScrollPaddingBefore,
|
|
254
|
-
virtualScrollPaddingAfter,
|
|
255
|
-
attributes,
|
|
256
243
|
classes,
|
|
257
|
-
|
|
258
|
-
hasAfterSlot,
|
|
259
|
-
colspanAttr,
|
|
260
|
-
cssVars
|
|
244
|
+
attributes
|
|
261
245
|
}
|
|
246
|
+
},
|
|
247
|
+
render(createElement: Function) {
|
|
248
|
+
const renderFn = isVue2 ? createElement : h
|
|
249
|
+
const renderSlot = (fn: Function) => (isVue2 ? fn() : () => fn())
|
|
250
|
+
|
|
251
|
+
if (!this.hasDefaultSlot) {
|
|
252
|
+
console.error(
|
|
253
|
+
'DlVirtualScroll: default scoped slot is required for rendering'
|
|
254
|
+
)
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return this.$props.type === '__dltable'
|
|
259
|
+
? getTableMiddle(
|
|
260
|
+
{
|
|
261
|
+
ref: 'rootRef',
|
|
262
|
+
class: 'dl-table__middle ' + this.classes
|
|
263
|
+
},
|
|
264
|
+
this.getVirtualChildren(renderFn),
|
|
265
|
+
renderFn
|
|
266
|
+
)
|
|
267
|
+
: renderFn(
|
|
268
|
+
this.tag,
|
|
269
|
+
{
|
|
270
|
+
...this.attrs,
|
|
271
|
+
ref: 'rootRef',
|
|
272
|
+
class: [this.attrs.class, this.classes],
|
|
273
|
+
...this.attributes
|
|
274
|
+
},
|
|
275
|
+
renderSlot(() => this.getVirtualChildren(renderFn))
|
|
276
|
+
)
|
|
262
277
|
}
|
|
263
278
|
})
|
|
264
279
|
</script>
|
|
265
280
|
<style scoped lang="scss">
|
|
281
|
+
@import './styles/dl-virtual-scroll-styles.scss';
|
|
266
282
|
@import '../../compound/DlTable/styles/dl-table-styles.scss';
|
|
267
|
-
.dl-virtual-scroll {
|
|
268
|
-
&:focus {
|
|
269
|
-
outline: 0;
|
|
270
|
-
}
|
|
271
|
-
&__content {
|
|
272
|
-
outline: none;
|
|
273
|
-
contain: content;
|
|
274
|
-
|
|
275
|
-
> * {
|
|
276
|
-
overflow-anchor: none;
|
|
277
|
-
}
|
|
278
|
-
> [data-dl-vs-anchor] {
|
|
279
|
-
overflow-anchor: auto;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
&__before {
|
|
283
|
-
height: var(--item-height-before);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
&__after {
|
|
287
|
-
height: var(--item-height-after);
|
|
288
|
-
}
|
|
289
|
-
&__padding {
|
|
290
|
-
background: repeating-linear-gradient(
|
|
291
|
-
rgba(128, 128, 128, 0.03),
|
|
292
|
-
rgba(128, 128, 128, 0.08) var(--dl-virtual-scroll-item-height, 50px)
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
.dl-table & {
|
|
296
|
-
tr {
|
|
297
|
-
height: 0 !important;
|
|
298
|
-
}
|
|
299
|
-
td {
|
|
300
|
-
padding: 0 !important;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
283
|
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.dl-virtual-scroll {
|
|
2
|
+
&:focus {
|
|
3
|
+
outline: 0;
|
|
4
|
+
}
|
|
5
|
+
&__content {
|
|
6
|
+
outline: none;
|
|
7
|
+
contain: content;
|
|
8
|
+
|
|
9
|
+
& > * {
|
|
10
|
+
overflow-anchor: none;
|
|
11
|
+
}
|
|
12
|
+
& > [data-dl-vs-anchor] {
|
|
13
|
+
overflow-anchor: auto;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
&__padding {
|
|
17
|
+
background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,0) 20%, rgba(128, 128, 128, .03) 20%, rgba(128, 128, 128, .08) 50%, rgba(128, 128, 128, .03) 80%, rgba(255,255,255,0) 80%, rgba(255,255,255,0)) #{"/* rtl:ignore */"};
|
|
18
|
+
background-size: var(--dl-virtual-scroll-item-width, 100%) var(--dl-virtual-scroll-item-height, 50px) #{"/* rtl:ignore */"};
|
|
19
|
+
|
|
20
|
+
.dl-table & {
|
|
21
|
+
tr {
|
|
22
|
+
height: 0 !important;
|
|
23
|
+
}
|
|
24
|
+
td {
|
|
25
|
+
padding: 0 !important;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
&--horizontal {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
flex-wrap: nowrap;
|
|
33
|
+
align-items: stretch;
|
|
34
|
+
|
|
35
|
+
.dl-virtual-scroll {
|
|
36
|
+
&__content {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
flex-wrap: nowrap;
|
|
40
|
+
}
|
|
41
|
+
&__padding,
|
|
42
|
+
&__content,
|
|
43
|
+
&__content > * {
|
|
44
|
+
flex: 0 0 auto;
|
|
45
|
+
}
|
|
46
|
+
&__padding {
|
|
47
|
+
background: linear-gradient(to left, rgba(255,255,255,0), rgba(255,255,255,0) 20%, rgba(128, 128, 128, .03) 20%, rgba(128, 128, 128, .08) 50%, rgba(128, 128, 128, .03) 80%, rgba(255,255,255,0) 80%, rgba(255,255,255,0)) #{"/* rtl:ignore */"};
|
|
48
|
+
background-size: var(--dl-virtual-scroll-item-width, 50px) var(--dl-virtual-scroll-item-height, 100%) #{"/* rtl:ignore */"};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|