@dataloop-ai/components 0.17.0 → 0.17.2

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.17.0",
3
+ "version": "0.17.2",
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": {
@@ -380,8 +380,7 @@ export default defineComponent({
380
380
  line-height: 1;
381
381
  z-index: 0;
382
382
  user-select: none !important;
383
- min-width: 1.5em;
384
- gap: var(--dl-button-gap, 7px);
383
+ gap: var(--dl-button-content-gap, 7px);
385
384
  }
386
385
 
387
386
  .dl-chip.first-letter-capitalized {
@@ -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>
@@ -0,0 +1,2 @@
1
+ import DlMarkupTable from './DlMarkupTable.vue'
2
+ export { DlMarkupTable }
@@ -11,3 +11,4 @@ export * from './DlPanelContainer'
11
11
  export * from './DlProgressChart'
12
12
  export * from './DlEllipsis'
13
13
  export * from './DlCard'
14
+ export * from './DlMarkupTable'
@@ -9,7 +9,7 @@
9
9
  v-show="!!title.length || !!tooltip.length"
10
10
  :class="{
11
11
  'dl-select__title-container': true,
12
- 'title-container--s': isSmall
12
+ 'dl-select__title-container--s': isSmall
13
13
  }"
14
14
  >
15
15
  <label
@@ -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
  >
@@ -476,7 +476,8 @@ import {
476
476
  watch,
477
477
  getCurrentInstance,
478
478
  ComputedRef,
479
- onMounted
479
+ onMounted,
480
+ toRef
480
481
  } from 'vue-demi'
481
482
  import {
482
483
  useTablePagination,
@@ -491,7 +492,7 @@ import {
491
492
  commonVirtScrollProps,
492
493
  ScrollDetails
493
494
  } from '../../shared/DlVirtualScroll/useVirtualScroll'
494
- import { DlVirtualScroll } from '../../shared/DlVirtualScroll'
495
+ import DlVirtualScroll from '../../shared/DlVirtualScroll/DlVirtualScroll.vue'
495
496
  import { useTableFilter, useTableFilterProps } from './hooks/tableFilter'
496
497
  import { useTableSort, useTableSortProps } from './hooks/tableSort'
497
498
  import {
@@ -520,6 +521,11 @@ import { DlIcon, DlCheckbox, DlProgressBar } from '../../essential'
520
521
  import { ResizableManager } from './utils'
521
522
  import { v4 } from 'uuid'
522
523
 
524
+ const commonVirtPropsObj = {} as Record<string, any>
525
+ commonVirtPropsList.forEach((p) => {
526
+ commonVirtPropsObj[p] = {}
527
+ })
528
+
523
529
  export default defineComponent({
524
530
  name: 'DlTable',
525
531
  components: {
@@ -865,12 +871,13 @@ export default defineComponent({
865
871
  )
866
872
 
867
873
  const { computedFilterMethod } = useTableFilter(props, setPagination)
874
+ const rowsPropRef = toRef(props, 'rows')
868
875
 
869
876
  const { isRowExpanded, setExpanded, updateExpanded } =
870
877
  useTableRowExpand(props, emit)
871
878
 
872
879
  const filteredSortedRows = computed(() => {
873
- let rows = props.rows as DlTableRow[]
880
+ let rows = rowsPropRef.value as DlTableRow[]
874
881
 
875
882
  if (rows.length === 0) {
876
883
  return rows
@@ -889,7 +896,7 @@ export default defineComponent({
889
896
 
890
897
  if (columnToSort.value !== null) {
891
898
  rows = computedSortMethod.value(
892
- props.rows === rows ? rows.slice() : rows,
899
+ rowsPropRef.value === rows ? rows.slice() : rows,
893
900
  sortBy,
894
901
  descending
895
902
  )
@@ -908,7 +915,7 @@ export default defineComponent({
908
915
  const { rowsPerPage } = computedPagination.value
909
916
 
910
917
  if (rowsPerPage !== 0) {
911
- if (firstRowIndex.value === 0 && props.rows !== rows) {
918
+ if (firstRowIndex.value === 0 && rowsPropRef.value !== rows) {
912
919
  if (rows.length > lastRowIndex.value) {
913
920
  rows = rows.slice(0, lastRowIndex.value)
914
921
  }
@@ -979,7 +986,7 @@ export default defineComponent({
979
986
  () =>
980
987
  multipleSelection.value === true &&
981
988
  computedRows.value.length > 0 &&
982
- computedRows.value.length < props.rows.length
989
+ computedRows.value.length < rowsPropRef.value.length
983
990
  )
984
991
 
985
992
  function onMultipleSelectionSet(val: boolean) {
@@ -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 {
@@ -0,0 +1,5 @@
1
+ export default function (props: any, content: any[], create: Function) {
2
+ return create('div', props, [
3
+ create('table', { class: 'dl-table' }, content)
4
+ ])
5
+ }
@@ -1,10 +1,11 @@
1
1
  <template>
2
- <div
2
+ <component
3
+ :is="tag"
3
4
  :id="uuid"
4
5
  :class="classes"
5
6
  >
6
7
  <slot :clickable="clickable" />
7
- </div>
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 { listenOpts } from '../../../utils'
16
+ import getTableMiddle from '../../compound/DlTable/utils/getTableMiddle'
17
+ import { listenOpts, mergeSlot } from '../../../utils'
77
18
  import { getScrollTarget } from '../../../utils/scroll'
78
- import { useVirtualScroll, useVirtualScrollProps } from './useVirtualScroll'
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: 'DlVirtualScroll',
37
+ name: 'DllVirtualScroll',
82
38
  props: {
83
- ...useVirtualScrollProps,
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
- draggableClasses: {
91
- type: [String, Array, Object],
92
- default: null
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
- props.itemsSize && props.itemsSize >= 0 && props.itemsFn !== void 0
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
- onVirtualScrollEvt,
120
- virtualScrollPaddingBefore,
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
- if (props.itemsFn === void 0) {
143
- return props.items
144
- .slice(
145
- virtualScrollSliceRange.value.from,
146
- virtualScrollSliceRange.value.to
147
- )
148
- .map(mapFn)
149
- }
150
-
151
- return (props.itemsFn as Function)(
152
- virtualScrollSliceRange.value.from,
153
- virtualScrollSliceRange.value.to -
154
- virtualScrollSliceRange.value.from
155
- ).map(mapFn)
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
- 'dl-virtual-scroll dl-virtual-scroll--vertical' +
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
- uuid: `dl-virtual-scroll-${v4()}`,
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
- hasBeforeSlot,
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>