@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.
@@ -0,0 +1,305 @@
1
+ <template>
2
+ <div>
3
+ <div style="display: flex">
4
+ <dl-virtual-scroll
5
+ v-slot="{ item: row, index }"
6
+ type="table"
7
+ :virtual-scroll-item-size="48"
8
+ :virtual-scroll-sticky-size-start="48"
9
+ :virtual-scroll-sticky-size-end="32"
10
+ :items="heavyList"
11
+ style="height: 500px"
12
+ @virtual-scroll="log"
13
+ >
14
+ <dl-tr :key="index">
15
+ <dl-td>#{{ index }}</dl-td>
16
+ <dl-td
17
+ v-for="col in columns"
18
+ :key="index + '-' + col"
19
+ >
20
+ {{ row[col] }}
21
+ </dl-td>
22
+ </dl-tr>
23
+ </dl-virtual-scroll>
24
+ </div>
25
+ <div style="margin-top: 100px">
26
+ <h3>Horizontal</h3>
27
+ <dl-virtual-scroll
28
+ v-slot="{ item, index }"
29
+ style="max-width: 500px"
30
+ :virtual-scroll-item-size="48"
31
+ :virtual-scroll-sticky-size-start="48"
32
+ :virtual-scroll-sticky-size-end="32"
33
+ :items="horizontalList"
34
+ virtual-scroll-horizontal
35
+ >
36
+ <div
37
+ :key="index"
38
+ :class="item.class"
39
+ >
40
+ #{{ index }} - {{ item.label }}
41
+ </div>
42
+ </dl-virtual-scroll>
43
+ </div>
44
+ <div style="margin-top: 100px">
45
+ <h3>List</h3>
46
+ <dl-virtual-scroll
47
+ v-slot="{ item, index }"
48
+ style="height: 300px"
49
+ :items="basicList"
50
+ :virtual-scroll-item-size="28"
51
+ :virtual-scroll-sticky-size-start="28"
52
+ :virtual-scroll-sticky-size-end="20"
53
+ separator
54
+ @virtual-scroll="log"
55
+ >
56
+ <dl-list-item
57
+ :key="index"
58
+ dense
59
+ >
60
+ <dl-item-section>
61
+ #{{ index }} - {{ item.label }}
62
+ </dl-item-section>
63
+ </dl-list-item>
64
+ </dl-virtual-scroll>
65
+ </div>
66
+
67
+ <div style="margin-top: 100px">
68
+ <h3>Custom Elements</h3>
69
+ <dl-virtual-scroll
70
+ style="height: 300px; gap: 20px"
71
+ :items="customList"
72
+ :virtual-scroll-item-size="293"
73
+ :virtual-scroll-sticky-size-start="293"
74
+ :virtual-scroll-sticky-size-end="200"
75
+ separator
76
+ @virtual-scroll="log"
77
+ >
78
+ <template #default="{ item, index }">
79
+ <dl-list-item
80
+ :key="index"
81
+ style="margin-bottom: 20px"
82
+ dense
83
+ >
84
+ <dl-item-section>
85
+ <div class="row custom-element">
86
+ <DlCard
87
+ v-for="i in item.inner"
88
+ v-bind="cardData"
89
+ :key="i"
90
+ :image="{
91
+ src: `https://picsum.photos/300/150?random=${
92
+ i + index
93
+ }`
94
+ }"
95
+ />
96
+ </div>
97
+ </dl-item-section>
98
+ </dl-list-item>
99
+ </template>
100
+ </dl-virtual-scroll>
101
+ </div>
102
+ </div>
103
+ </template>
104
+
105
+ <script lang="ts">
106
+ const rows = [
107
+ {
108
+ name: 'Frozen Yogurt',
109
+ calories: 159,
110
+ fat: 6.0,
111
+ carbs: 24,
112
+ protein: 4.0,
113
+ sodium: 87,
114
+ calcium: '14%',
115
+ iron: '1%'
116
+ },
117
+ {
118
+ name: 'Ice cream sandwich',
119
+ calories: 237,
120
+ fat: 9.0,
121
+ carbs: 37,
122
+ protein: 4.3,
123
+ sodium: 129,
124
+ calcium: '8%',
125
+ iron: '1%'
126
+ },
127
+ {
128
+ name: 'Eclair',
129
+ calories: 262,
130
+ fat: 16.0,
131
+ carbs: 23,
132
+ protein: 6.0,
133
+ sodium: 337,
134
+ calcium: '6%',
135
+ iron: '7%'
136
+ },
137
+ {
138
+ name: 'Cupcake',
139
+ calories: 305,
140
+ fat: 3.7,
141
+ carbs: 67,
142
+ protein: 4.3,
143
+ sodium: 413,
144
+ calcium: '3%',
145
+ iron: '8%'
146
+ },
147
+ {
148
+ name: 'Gingerbread',
149
+ calories: 356,
150
+ fat: 16.0,
151
+ carbs: 49,
152
+ protein: 3.9,
153
+ sodium: 327,
154
+ calcium: '7%',
155
+ iron: '16%'
156
+ },
157
+ {
158
+ name: 'Jelly bean',
159
+ calories: 375,
160
+ fat: 0.0,
161
+ carbs: 94,
162
+ protein: 0.0,
163
+ sodium: 50,
164
+ calcium: '0%',
165
+ iron: '0%'
166
+ },
167
+ {
168
+ name: 'Lollipop',
169
+ calories: 392,
170
+ fat: 0.2,
171
+ carbs: 98,
172
+ protein: 0,
173
+ sodium: 38,
174
+ calcium: '0%',
175
+ iron: '2%'
176
+ },
177
+ {
178
+ name: 'Honeycomb',
179
+ calories: 408,
180
+ fat: 3.2,
181
+ carbs: 87,
182
+ protein: 6.5,
183
+ sodium: 562,
184
+ calcium: '0%',
185
+ iron: '45%'
186
+ },
187
+ {
188
+ name: 'Donut',
189
+ calories: 452,
190
+ fat: 25.0,
191
+ carbs: 51,
192
+ protein: 4.9,
193
+ sodium: 326,
194
+ calcium: '2%',
195
+ iron: '22%'
196
+ },
197
+ {
198
+ name: 'KitKat',
199
+ calories: 518,
200
+ fat: 26.0,
201
+ carbs: 65,
202
+ protein: 7,
203
+ sodium: 54,
204
+ calcium: '12%',
205
+ iron: '6%'
206
+ }
207
+ ]
208
+
209
+ const columns = [
210
+ 'name',
211
+ 'calories',
212
+ 'fat',
213
+ 'carbs',
214
+ 'protein',
215
+ 'sodium',
216
+ 'calcium',
217
+ 'iron'
218
+ ]
219
+
220
+ import DlVirtualScroll from '../components/shared/DlVirtualScroll/DlVirtualScroll.vue'
221
+ import { DlTr, DlTd, DlListItem, DlItemSection, DlCard } from '../components'
222
+ import { defineComponent, ref } from 'vue-demi'
223
+
224
+ export default defineComponent({
225
+ components: {
226
+ DlVirtualScroll,
227
+ DlTd,
228
+ DlTr,
229
+ DlListItem,
230
+ DlItemSection,
231
+ DlCard
232
+ },
233
+ setup() {
234
+ const heavyList = ref([])
235
+ const basicList = ref([])
236
+ const horizontalList = ref([])
237
+ const customList = ref([])
238
+
239
+ // adding same data multiple times to
240
+ // create a huge list
241
+ for (let i = 0; i <= 1000; i++) {
242
+ Array.prototype.push.apply(heavyList.value, rows)
243
+ basicList.value.push({
244
+ label: 'Option ' + (i + 1)
245
+ })
246
+ horizontalList.value.push({
247
+ label: 'Option ' + (i + 1),
248
+ class: i % 2 === 0 ? 'item item--odd' : 'item'
249
+ })
250
+
251
+ customList.value.push({
252
+ label: 'Option ' + (i + 1),
253
+ inner: ['inner item 1', 'inner item 2', 'inner item 3']
254
+ })
255
+ }
256
+
257
+ const cardData = {
258
+ text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Egestas volutpat quam blandit integer mattis. consectetur adipiscing elit. Egestas volutpat quam blandit integer mattis. ',
259
+ title: 'Lorem ipsum',
260
+ keyboardShortcut: 'Shift + E',
261
+ links: [
262
+ {
263
+ icon: 'icon-dl-list-view',
264
+ href: 'https://www.google.md/?hl=ru',
265
+ title: 'Lorem',
266
+ newtab: true,
267
+ external: true
268
+ },
269
+ {
270
+ href: '#test',
271
+ title: 'Developers',
272
+ icon: 'icon-dl-code'
273
+ }
274
+ ]
275
+ }
276
+
277
+ const log = console.log
278
+
279
+ return {
280
+ heavyList,
281
+ basicList,
282
+ horizontalList,
283
+ customList,
284
+ columns,
285
+ cardData,
286
+ log
287
+ }
288
+ }
289
+ })
290
+ </script>
291
+
292
+ <style scoped lang="scss">
293
+ .item {
294
+ padding: 10px 20px;
295
+ display: flex;
296
+ justify-content: center;
297
+ &--odd {
298
+ background-color: rgba(0, 0, 0, 0.1);
299
+ }
300
+ }
301
+
302
+ .custom-element {
303
+ gap: 20px;
304
+ }
305
+ </style>
@@ -53,6 +53,8 @@ import DlKpiDemo from './DlKpiDemo.vue'
53
53
  import DlEllipsisDemo from './DlEllipsisDemo.vue'
54
54
  import DlSeparatorDemo from './DlSeparatorDemo.vue'
55
55
  import DlCardDemo from './DlCardDemo.vue'
56
+ import DlMarkupTableDemo from './DlMarkupTableDemo.vue'
57
+ import DlVirtualScrollDemo from './DlVirtualScrollDemo.vue'
56
58
 
57
59
  export default {
58
60
  AvatarDemo,
@@ -109,5 +111,7 @@ export default {
109
111
  DlEllipsisDemo,
110
112
  DlSeparatorDemo,
111
113
  DlKpiDemo,
112
- DlCardDemo
114
+ DlCardDemo,
115
+ DlMarkupTableDemo,
116
+ DlVirtualScrollDemo
113
117
  }
@@ -1,8 +1,23 @@
1
1
  export const listenOpts: Record<string, any> = {
2
2
  hasPassive: false,
3
3
  passiveCapture: true,
4
- notPassiveCapture: true,
5
- passive: false
4
+ notPassiveCapture: true
5
+ }
6
+
7
+ try {
8
+ const opts = Object.defineProperty({}, 'passive', {
9
+ get() {
10
+ Object.assign(listenOpts, {
11
+ hasPassive: true,
12
+ passive: { passive: true },
13
+ notPassive: { passive: false },
14
+ passiveCapture: { passive: true, capture: true },
15
+ notPassiveCapture: { passive: false, capture: true }
16
+ })
17
+ }
18
+ })
19
+ } catch (e) {
20
+ console.log(e)
6
21
  }
7
22
 
8
23
  export function stopAndPrevent(e: Event) {
@@ -12,6 +27,8 @@ export function stopAndPrevent(e: Event) {
12
27
  e.stopPropagation()
13
28
  }
14
29
 
30
+ export function noop() {}
31
+
15
32
  export function leftClick(e: MouseEvent) {
16
33
  return e.button === 0
17
34
  }
@@ -13,6 +13,14 @@ export const createElement = (
13
13
  return h(el, opts, slots)
14
14
  }
15
15
 
16
+ /**
17
+ * Source definitely exists,
18
+ * so it's merged with the possible slot
19
+ */
20
+ export function mergeSlot(slot: any, source: any) {
21
+ return slot !== void 0 ? source.concat(slot()) : source
22
+ }
23
+
16
24
  export const hSlot = (
17
25
  slots: any,
18
26
  elements: any = [],