@dataloop-ai/components 0.19.24 → 0.19.26

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.19.24",
3
+ "version": "0.19.26",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -1,5 +1,19 @@
1
1
  <template>
2
+ <div v-if="hasVirtualScroll">
3
+ <dl-virtual-scroll
4
+ v-slot="{ item }"
5
+ style="height: 500px"
6
+ :items="items"
7
+ :styles="{ gridStyles, gridClass }"
8
+ >
9
+ <slot
10
+ name="item-slot"
11
+ v-bind="{ item }"
12
+ />
13
+ </dl-virtual-scroll>
14
+ </div>
2
15
  <div
16
+ v-else
3
17
  ref="grid"
4
18
  :style="gridStyles"
5
19
  :class="gridClass"
@@ -24,9 +38,13 @@ import {
24
38
  import { getGridTemplate, swapElementsInMatrix } from './utils'
25
39
  import { isCustomEvent } from '../utils'
26
40
  import { getElementAbove } from '../../../utils'
27
- import { DlGridMode } from './types'
41
+ import { DlGridMode, GridItem } from './types'
42
+ import { DlVirtualScroll } from '../../shared/DlVirtualScroll'
28
43
 
29
44
  export default defineComponent({
45
+ components: {
46
+ DlVirtualScroll
47
+ },
30
48
  model: {
31
49
  prop: 'modelValue',
32
50
  event: 'update:model-value'
@@ -36,6 +54,10 @@ export default defineComponent({
36
54
  type: Array as PropType<(string | number)[][]>,
37
55
  default: null
38
56
  },
57
+ items: {
58
+ type: Array as PropType<GridItem[]>,
59
+ default: null
60
+ },
39
61
  rowGap: {
40
62
  type: String,
41
63
  default: '30px'
@@ -70,10 +92,16 @@ export default defineComponent({
70
92
  : 'dl-grid-wrapper__flex'
71
93
  )
72
94
 
95
+ const hasVirtualScroll = computed(() => props.items?.length > 100)
96
+
73
97
  const gridStyles = computed(() => {
74
98
  const gridStyles: Dictionary<string | number> = {
75
99
  '--row-gap': rowGap.value,
76
- '--column-gap': columnGap.value
100
+ '--column-gap': columnGap.value,
101
+ display: 'grid',
102
+ rowGap: 'var(--row-gap)',
103
+ columnGap: 'var(--column-gap)',
104
+ gridTemplateColumns: 'repeat(var(--element-per-row), 1fr)'
77
105
  }
78
106
 
79
107
  if (!isGridMode.value) {
@@ -112,7 +140,7 @@ export default defineComponent({
112
140
  }
113
141
 
114
142
  const applyGridElementStyles = () => {
115
- const childrenElements = Array.from(grid.value.children)
143
+ const childrenElements = Array.from(grid.value?.children || [])
116
144
  const layoutOrder = modelValue.value?.flat() ?? []
117
145
 
118
146
  // The check is needed to avoid errors and incorrect behavior
@@ -186,7 +214,8 @@ export default defineComponent({
186
214
  isFlexMode,
187
215
  gridClass,
188
216
  gridStyles,
189
- grid
217
+ grid,
218
+ hasVirtualScroll
190
219
  }
191
220
  }
192
221
  })
@@ -194,12 +223,6 @@ export default defineComponent({
194
223
 
195
224
  <style lang="scss" scoped>
196
225
  .dl-grid-wrapper {
197
- &__grid {
198
- display: grid;
199
- row-gap: var(--row-gap);
200
- column-gap: var(--column-gap);
201
- grid-template-columns: repeat(var(--element-per-row), 1fr);
202
- }
203
226
  &__flex {
204
227
  display: flex;
205
228
  gap: var(--row-gap);
@@ -8,3 +8,8 @@ export enum DlGridMode {
8
8
  FLEX = 'flex',
9
9
  LAYOUT = 'layout'
10
10
  }
11
+
12
+ export interface GridItem {
13
+ id: string | number
14
+ [key: string]: any
15
+ }
@@ -3,6 +3,9 @@
3
3
  ref="menuRef"
4
4
  v-bind="menuProps"
5
5
  :model-value="modelV"
6
+ :menu-class="`dl-popup__menu${dense ? ' dl-popup__menu--dense' : ''}${
7
+ menuClass ? ' ' + menuClass : ''
8
+ }`"
6
9
  @click="handleClick"
7
10
  @escapekey="handleEscape"
8
11
  @before-show="handleBeforeShow"
@@ -68,7 +71,6 @@ import {
68
71
  defineComponent,
69
72
  getCurrentInstance,
70
73
  ref,
71
- watch,
72
74
  computed,
73
75
  PropType,
74
76
  Ref,
@@ -173,7 +175,8 @@ export default defineComponent({
173
175
  triggerPercentage: {
174
176
  type: Number,
175
177
  default: 0
176
- }
178
+ },
179
+ dense: Boolean
177
180
  },
178
181
  emits: [...useModelToggleEmits, 'click', 'escapekey', 'close-button-click'],
179
182
  setup(props, { attrs, slots, emit }) {
@@ -177,7 +177,7 @@
177
177
  handleVisibleColumnsUpdate
178
178
  "
179
179
  >
180
- <dl-menu>
180
+ <dl-popup dense>
181
181
  <slot
182
182
  name="header-cell-visible-columns-menu-content"
183
183
  :visible-columns-state="
@@ -190,7 +190,7 @@
190
190
  handleVisibleColumnsUpdate
191
191
  "
192
192
  >
193
- <dl-list separator>
193
+ <dl-list>
194
194
  <dl-option-group
195
195
  :model-value="
196
196
  computedVisibleCols
@@ -210,7 +210,7 @@
210
210
  />
211
211
  </dl-list>
212
212
  </slot>
213
- </dl-menu>
213
+ </dl-popup>
214
214
  </slot>
215
215
  </dl-button>
216
216
  </div>
@@ -527,7 +527,7 @@
527
527
  handleVisibleColumnsUpdate
528
528
  "
529
529
  >
530
- <dl-menu>
530
+ <dl-popup dense>
531
531
  <slot
532
532
  name="header-cell-visible-columns-menu-content"
533
533
  :visible-columns-state="
@@ -540,7 +540,7 @@
540
540
  handleVisibleColumnsUpdate
541
541
  "
542
542
  >
543
- <dl-list separator>
543
+ <dl-list>
544
544
  <dl-option-group
545
545
  :model-value="
546
546
  computedVisibleCols
@@ -560,7 +560,7 @@
560
560
  />
561
561
  </dl-list>
562
562
  </slot>
563
- </dl-menu>
563
+ </dl-popup>
564
564
  </slot>
565
565
  </dl-button>
566
566
  </div>
@@ -878,14 +878,8 @@ import { applyDraggableColumns, applyResizableColumns } from '../../../utils'
878
878
  import { injectProp } from '../../../utils/inject-object-prop'
879
879
  import { DlTableRow, DlTableProps, DlTableColumn } from './types'
880
880
  import { DlPagination } from '../DlPagination'
881
- import {
882
- DlIcon,
883
- DlCheckbox,
884
- DlProgressBar,
885
- DlMenu,
886
- DlList
887
- } from '../../essential'
888
- import { DlButton } from '../../basic'
881
+ import { DlIcon, DlCheckbox, DlProgressBar, DlList } from '../../essential'
882
+ import { DlButton, DlPopup } from '../../basic'
889
883
  import DlOptionGroup from '../DlOptionGroup/DlOptionGroup.vue'
890
884
  import DlEmptyState from '../../basic/DlEmptyState/DlEmptyState.vue'
891
885
  import { v4 } from 'uuid'
@@ -917,7 +911,7 @@ export default defineComponent({
917
911
  DlEmptyState,
918
912
  DlButton,
919
913
  DlOptionGroup,
920
- DlMenu,
914
+ DlPopup,
921
915
  DlList,
922
916
  Sortable
923
917
  },
@@ -88,7 +88,8 @@ export default defineComponent({
88
88
  })
89
89
 
90
90
  const isDense = computed(() => {
91
- return !!props.props?.dense
91
+ // @ts-ignore
92
+ return !!props.props?.dense || !!props.props?.col?.dense
92
93
  })
93
94
 
94
95
  const column = computed(() => {
@@ -500,6 +500,13 @@ export default defineComponent({
500
500
  </script>
501
501
 
502
502
  <style scoped lang="scss">
503
+ .dl-popup__menu {
504
+ --dl-popup-padding: 16px;
505
+ &--dense {
506
+ --dl-popup-padding: 0;
507
+ }
508
+ }
509
+
503
510
  .dl-menu {
504
511
  position: fixed !important;
505
512
  display: inline-block;
@@ -13,14 +13,15 @@ import {
13
13
  isVue2,
14
14
  h,
15
15
  onUnmounted,
16
- toRefs
16
+ toRefs,
17
+ PropType
17
18
  } from 'vue-demi'
18
19
  import getTableMiddle from '../../compound/DlTable/utils/getTableMiddle'
19
20
  import { listenOpts, mergeSlot } from '../../../utils'
20
21
  import { getScrollTarget } from '../../../utils/scroll'
21
22
  import { DlList } from '../../essential/DlList'
22
23
  import { DlMarkupTable } from '../../basic/DlMarkupTable'
23
- import { useVirtualScroll } from './useVirtualScroll'
24
+ import { useVirtualScroll, GridStyles } from './useVirtualScroll'
24
25
  import { stateManager } from '../../../StateManager'
25
26
 
26
27
  const comps = {
@@ -91,6 +92,11 @@ export default defineComponent({
91
92
  typeOptions.includes(v)
92
93
  },
93
94
 
95
+ styles: {
96
+ type: Object as PropType<GridStyles>,
97
+ default: null
98
+ },
99
+
94
100
  itemsFn: { type: Function, default: null },
95
101
  itemsSize: { type: Number, default: 0 },
96
102
 
@@ -251,7 +257,8 @@ export default defineComponent({
251
257
  type.value as 'list' | 'table' | '__dltable'
252
258
  ] || 'div',
253
259
  virtualScrollScope.value.map(slots.default),
254
- create
260
+ create,
261
+ props.styles
255
262
  )
256
263
 
257
264
  if (isDefined(slots.before)) {
@@ -25,6 +25,11 @@ export interface ScrollDetails {
25
25
  offsetEnd: number
26
26
  }
27
27
 
28
+ export interface GridStyles {
29
+ gridStyles: object
30
+ gridClass: string
31
+ }
32
+
28
33
  const aggBucketSize = 1000
29
34
 
30
35
  const scrollToEdges = [
@@ -828,7 +833,12 @@ export function useVirtualScroll({
828
833
  }
829
834
  }
830
835
 
831
- function padVirtualScroll(tag: string, content: any[], create: Function) {
836
+ function padVirtualScroll(
837
+ tag: string,
838
+ content: any[],
839
+ create: Function,
840
+ styles: GridStyles
841
+ ) {
832
842
  const paddingSize =
833
843
  props.virtualScrollHorizontal === true ? 'width' : 'height'
834
844
 
@@ -874,9 +884,10 @@ export function useVirtualScroll({
874
884
  create(
875
885
  tag,
876
886
  {
877
- class: 'dl-virtual-scroll__content',
887
+ class: `dl-virtual-scroll__content ${styles?.gridClass}`,
888
+ style: styles?.gridStyles,
878
889
  key: 'content',
879
- ref: contentRef,
890
+ ref: styles ? 'grid' : contentRef,
880
891
  tabindex: -1
881
892
  },
882
893
  content.flat()
@@ -1,8 +1,33 @@
1
1
  <template>
2
2
  <div class="widgets-demo-wrapper">
3
- <div>
3
+ <div class="select-wrapper">
4
+ <div style="width: 40%">
5
+ <p>Select mode:</p>
6
+ <dl-select
7
+ v-model="activeMode"
8
+ :options="[flex, grid, layout]"
9
+ />
10
+ </div>
11
+ <div style="width: 40%">
12
+ <p>Select content type:</p>
13
+ <dl-select
14
+ v-model="activeContentType"
15
+ :options="[
16
+ { value: 'images', label: 'Images' },
17
+ { value: 'widgets', label: 'Widgets' },
18
+ {
19
+ value: 'prop',
20
+ label: 'Prop + ItemSlot + VirtualScroll'
21
+ }
22
+ ]"
23
+ />
24
+ </div>
25
+ </div>
26
+
27
+ <div v-if="activeMode === layout">
4
28
  <h3>Layout mode</h3>
5
29
  <dl-button
30
+ v-if="activeContentType.value === 'widgets'"
6
31
  class="select-layout__button"
7
32
  style="width: 200px; margin-bottom: 20px"
8
33
  @click="addWidget(layout)"
@@ -10,6 +35,7 @@
10
35
  Add widget
11
36
  </dl-button>
12
37
  <dl-grid
38
+ v-if="activeContentType.value === 'widgets'"
13
39
  :key="cmWidgets.length"
14
40
  v-model="cmLayout"
15
41
  :max-elements-per-row="cmMaxWidgetsPerRow"
@@ -46,10 +72,22 @@
46
72
  </template>
47
73
  </dl-widget>
48
74
  </dl-grid>
75
+ <dl-grid
76
+ v-if="activeContentType.value === 'images'"
77
+ v-model="cmLayout"
78
+ :mode="layout"
79
+ >
80
+ <img
81
+ v-for="img in images"
82
+ :key="img.id"
83
+ :src="img.src"
84
+ >
85
+ </dl-grid>
49
86
  </div>
50
- <div>
87
+ <div v-else-if="activeMode === grid">
51
88
  <h3>Grid mode</h3>
52
89
  <dl-button
90
+ v-if="activeContentType.value === 'widgets'"
53
91
  class="select-layout__button"
54
92
  style="width: 200px; margin-bottom: 20px"
55
93
  @click="addWidget(grid)"
@@ -57,6 +95,7 @@
57
95
  Add widget
58
96
  </dl-button>
59
97
  <dl-grid
98
+ v-if="activeContentType.value === 'widgets'"
60
99
  :key="dmWidgets.length"
61
100
  v-model="dmLayout"
62
101
  :max-elements-per-row="dmMaxWidgetsPerRow"
@@ -93,10 +132,22 @@
93
132
  </template>
94
133
  </dl-widget>
95
134
  </dl-grid>
135
+ <dl-grid
136
+ v-if="activeContentType.value === 'images'"
137
+ v-model="dmLayout"
138
+ :mode="layout"
139
+ >
140
+ <img
141
+ v-for="img in images"
142
+ :key="img.id"
143
+ :src="img.src"
144
+ >
145
+ </dl-grid>
96
146
  </div>
97
- <div>
147
+ <div v-else-if="activeMode === flex">
98
148
  <h3>Flex mode</h3>
99
149
  <dl-button
150
+ v-if="activeContentType.value === 'widgets'"
100
151
  class="select-layout__button"
101
152
  style="width: 200px; margin-bottom: 20px"
102
153
  @click="addWidget(flex)"
@@ -104,6 +155,7 @@
104
155
  Add widget
105
156
  </dl-button>
106
157
  <dl-grid
158
+ v-if="activeContentType.value === 'widgets'"
107
159
  :key="fmWidgets.length"
108
160
  :mode="flex"
109
161
  >
@@ -140,13 +192,38 @@
140
192
  </template>
141
193
  </dl-widget>
142
194
  </dl-grid>
195
+ <dl-grid
196
+ v-if="activeContentType.value === 'images'"
197
+ :mode="layout"
198
+ >
199
+ <img
200
+ v-for="img in images"
201
+ :key="img.id"
202
+ :src="img.src"
203
+ >
204
+ </dl-grid>
205
+ </div>
206
+ <div v-if="activeContentType.value === 'prop'">
207
+ <dl-grid :items="images">
208
+ <template #item-slot="{ item }">
209
+ <img :src="item.src">
210
+ </template>
211
+ </dl-grid>
143
212
  </div>
144
213
  </div>
145
214
  </template>
146
215
 
147
216
  <script lang="ts">
217
+ import { v4 } from 'uuid'
148
218
  import { defineComponent, Ref, ref } from 'vue-demi'
149
- import { DlWidget, DlGrid, DlBarChart, DlIcon, DlButton } from '../components'
219
+ import {
220
+ DlWidget,
221
+ DlGrid,
222
+ DlBarChart,
223
+ DlIcon,
224
+ DlButton,
225
+ DlSelect
226
+ } from '../components'
150
227
  import { DlGridMode } from '../types'
151
228
 
152
229
  const data = {
@@ -173,9 +250,16 @@ export default defineComponent({
173
250
  DlWidget,
174
251
  DlBarChart,
175
252
  DlIcon,
176
- DlButton
253
+ DlButton,
254
+ DlSelect
177
255
  },
178
256
  setup() {
257
+ const activeMode = ref('layout')
258
+ const activeContentType = ref({
259
+ value: 'images',
260
+ label: 'Images'
261
+ })
262
+
179
263
  const cmLayout: Ref<string[][]> = ref([
180
264
  ['a', 'b', 'c'],
181
265
  ['d', 'e']
@@ -266,6 +350,13 @@ export default defineComponent({
266
350
  return template
267
351
  }
268
352
 
353
+ const images = []
354
+ for (let i = 0; i < 101; i++) {
355
+ images.push({
356
+ id: v4(),
357
+ src: 'https://picsum.photos/200/200'
358
+ })
359
+ }
269
360
  return {
270
361
  data,
271
362
  deleteWidget,
@@ -281,13 +372,22 @@ export default defineComponent({
281
372
  dmMaxWidgetsPerRow,
282
373
  layout: DlGridMode.LAYOUT,
283
374
  flex: DlGridMode.FLEX,
284
- grid: DlGridMode.GRID
375
+ grid: DlGridMode.GRID,
376
+ activeMode,
377
+ activeContentType,
378
+ images
285
379
  }
286
380
  }
287
381
  })
288
382
  </script>
289
383
 
290
384
  <style lang="scss" scoped>
385
+ .select-wrapper {
386
+ width: 100%;
387
+ display: flex;
388
+ flex-direction: row;
389
+ justify-content: space-evenly;
390
+ }
291
391
  .widgets-demo-wrapper {
292
392
  display: flex;
293
393
  flex-direction: column;
@@ -296,8 +396,6 @@ export default defineComponent({
296
396
  gap: 20px;
297
397
 
298
398
  & > * {
299
- display: flex;
300
- flex-direction: column;
301
399
  gap: 10px;
302
400
  border: 1px solid var(--dl-color-separator);
303
401
  padding: 10px;