@dataloop-ai/components 0.17.67 → 0.17.69

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.67",
3
+ "version": "0.17.69",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -6,24 +6,22 @@
6
6
  <div
7
7
  :id="uuid"
8
8
  ref="widget"
9
- :class="widgetStyles"
9
+ :class="widgetClasses"
10
10
  @mouseenter="handleVisibleDragIcon(true)"
11
11
  @mouseleave="handleVisibleDragIcon(false)"
12
12
  >
13
+ <dl-icon
14
+ :style="iconStyles"
15
+ class="dl-widget__drag-icon"
16
+ icon="icon-dl-drag"
17
+ color="dl-color-medium"
18
+ size="15px"
19
+ @mousedown="startDragging"
20
+ />
13
21
  <div class="dl-widget__header">
14
22
  <div class="dl-widget__header--titles">
15
23
  <slot name="header" />
16
24
  </div>
17
- <dl-icon
18
- :style="`visibility: ${
19
- visibleDragIcon && !isDragging ? 'visible' : 'hidden'
20
- }`"
21
- class="dl-widget__header--drag-icon"
22
- icon="icon-dl-drag"
23
- color="dl-color-medium"
24
- size="15px"
25
- @mousedown="startDragging"
26
- />
27
25
  <slot name="menu" />
28
26
  </div>
29
27
 
@@ -65,8 +63,19 @@ export default defineComponent({
65
63
  }
66
64
  },
67
65
  computed: {
68
- widgetStyles() {
66
+ widgetClasses() {
69
67
  return `${this.isDragging ? 'dl-widget__drag' : 'dl-widget'}`
68
+ },
69
+ iconStyles() {
70
+ return {
71
+ '--dl-widget-drag-icon-left': `${
72
+ (this.$refs.widget as HTMLElement)?.offsetWidth / 2
73
+ }px`,
74
+ visibility:
75
+ this.visibleDragIcon && !this.isDragging
76
+ ? 'visible'
77
+ : 'hidden'
78
+ }
70
79
  }
71
80
  },
72
81
  methods: {
@@ -192,19 +201,14 @@ export default defineComponent({
192
201
  height: 100%;
193
202
  display: flex;
194
203
  flex-direction: column;
204
+ position: relative;
195
205
  &__header {
196
206
  display: flex;
197
207
  padding: 10px;
198
208
  border-bottom: 1px solid var(--dl-color-separator);
199
-
200
- &--drag-icon {
201
- flex-grow: 1;
202
- cursor: grab;
203
-
204
- &::v-deep .dl-icon {
205
- transform: rotate(90deg) !important;
206
- }
207
- }
209
+ font-size: 20px;
210
+ color: var(--dl-color-darker);
211
+ justify-content: space-between;
208
212
 
209
213
  &--titles {
210
214
  width: 50%;
@@ -229,6 +233,18 @@ export default defineComponent({
229
233
  color: var(--dl-color-medium);
230
234
  }
231
235
 
236
+ &__drag-icon {
237
+ position: absolute;
238
+ top: 5px;
239
+ left: calc(var(--dl-widget-drag-icon-left) - 5px);
240
+ flex-grow: 1;
241
+ cursor: grab;
242
+
243
+ &::v-deep .dl-icon {
244
+ transform: rotate(90deg) !important;
245
+ }
246
+ }
247
+
232
248
  &__drag {
233
249
  position: relative;
234
250
  &::after {
@@ -61,9 +61,7 @@
61
61
  class="matrix__cell"
62
62
  :style="`background-color: ${getCellBackground(
63
63
  cell.value
64
- )}; color: var(--dl-color-text${
65
- cell.value < 0.5 ? '-darker' : ''
66
- }-buttons)`"
64
+ )}; color: ${getCellTextColor(cell.value)}`"
67
65
  @mouseenter="handleShowTooltip(cell, $event)"
68
66
  @mouseleave="handleHideTooltip"
69
67
  @mousedown="openLink(cell)"
@@ -140,14 +138,14 @@
140
138
  <div
141
139
  v-if="tooltipVisible"
142
140
  :style="tooltipStyles"
143
- class="tooltip"
141
+ class="matrix-tooltip"
144
142
  >
145
- <span class="tooltip__x">{{ tooltipState.xLabel }}</span>
146
- <span class="tooltip__y">{{ tooltipState.yLabel }}</span>
143
+ <span class="matrix-tooltip__x">{{ tooltipState.xLabel }}</span>
144
+ <span class="matrix-tooltip__y">{{ tooltipState.yLabel }}</span>
147
145
  <span>
148
146
  <span
149
147
  v-if="tooltipState.value"
150
- class="tooltip__color"
148
+ class="matrix-tooltip__color"
151
149
  :style="`background-color: ${getCellBackground(
152
150
  tooltipState.value
153
151
  )}`"
@@ -238,9 +236,19 @@ export default defineComponent({
238
236
  const hex = object[props.color]
239
237
  return hexToRgbA(hex, value)
240
238
  }
239
+
240
+ const getCellTextColor = (value: number) => {
241
+ const isDark =
242
+ document.documentElement.getAttribute('data-theme') ===
243
+ 'dark-mode'
244
+ if (isDark) return 'var(--dl-color-text-buttons)'
245
+ return `var(--dl-color-text${value < 0.5 ? '-darker' : ''}-buttons)`
246
+ }
247
+
241
248
  return {
242
249
  variables,
243
250
  getCellBackground,
251
+ getCellTextColor,
244
252
  cellWidth,
245
253
  tooltipState,
246
254
  currentBrushState
@@ -365,8 +373,8 @@ export default defineComponent({
365
373
  value: ctx.normalized ? cell.value : cell.unnormalizedValue,
366
374
  xLabel: cell.xLabel,
367
375
  yLabel: cell.yLabel,
368
- x: e.pageX,
369
- y: e.pageY,
376
+ x: e.x,
377
+ y: e.y,
370
378
  visible: true
371
379
  }
372
380
  },
@@ -514,7 +522,7 @@ export default defineComponent({
514
522
  }
515
523
  }
516
524
 
517
- .tooltip {
525
+ .matrix-tooltip {
518
526
  position: absolute;
519
527
  border: 1px solid var(--dl-color-separator);
520
528
  padding: 8px;
@@ -522,6 +530,7 @@ export default defineComponent({
522
530
  display: flex;
523
531
  flex-direction: column;
524
532
  background-color: var(--dl-color-shadow);
533
+ color: var(--dl-color-tooltip-background);
525
534
  border-radius: 3px;
526
535
  animation: fadeIn 0.4s;
527
536
 
@@ -142,6 +142,7 @@ export default defineComponent({
142
142
  <style scoped lang="scss">
143
143
  .scroll-bar-wrapper {
144
144
  width: 1%;
145
+ min-width: 5px;
145
146
  }
146
147
  .scroll-bar {
147
148
  background: #d9d9d9;
@@ -152,10 +152,12 @@
152
152
  : ''
153
153
  "
154
154
  :no-hover="noHover"
155
- @click="onTrClick($event, props.item, pageIndex)"
156
- @dblclick="onTrDblClick($event, props.item, pageIndex)"
155
+ @click="onTrClick($event, props.item, props.pageIndex)"
156
+ @dblclick="
157
+ onTrDblClick($event, props.item, props.pageIndex)
158
+ "
157
159
  @contextmenu="
158
- onTrContextMenu($event, props.item, pageIndex)
160
+ onTrContextMenu($event, props.item, props.pageIndex)
159
161
  "
160
162
  >
161
163
  <td
@@ -1069,10 +1071,6 @@ export default defineComponent({
1069
1071
  acc[p] = (props as Record<string, any>)[p]
1070
1072
  })
1071
1073
 
1072
- if (!acc.virtualScrollItemSize) {
1073
- acc.virtualScrollItemSize = props.dense === true ? 30 : 40
1074
- }
1075
-
1076
1074
  return acc
1077
1075
  })
1078
1076
 
@@ -61,10 +61,11 @@ export function useTablePaginationState(
61
61
  sortBy: null,
62
62
  descending: false,
63
63
  page: 1,
64
- rowsPerPage:
65
- props.rowsPerPageOptions.length > 0
66
- ? props.rowsPerPageOptions[0]
67
- : 5,
64
+ rowsPerPage: props.virtualScroll
65
+ ? 0
66
+ : props.rowsPerPageOptions.length > 0
67
+ ? props.rowsPerPageOptions[0]
68
+ : 5,
68
69
  min: 1,
69
70
  maxPages: 0,
70
71
  boundaryNumbers: true,
@@ -74,7 +75,9 @@ export function useTablePaginationState(
74
75
  itemsName: 'Rows',
75
76
  withLegend: true,
76
77
  withRowsPerPage: true,
77
- rowsPerPageOptions: props.rowsPerPageOptions
78
+ rowsPerPageOptions: props.virtualScroll
79
+ ? [0]
80
+ : props.rowsPerPageOptions
78
81
  },
79
82
  props.pagination
80
83
  )
@@ -11,7 +11,8 @@ import {
11
11
  ref,
12
12
  watch,
13
13
  isVue2,
14
- h
14
+ h,
15
+ onUnmounted
15
16
  } from 'vue-demi'
16
17
  import getTableMiddle from '../../compound/DlTable/utils/getTableMiddle'
17
18
  import { listenOpts, mergeSlot } from '../../../utils'
@@ -54,7 +55,7 @@ export default defineComponent({
54
55
  },
55
56
 
56
57
  virtualScrollItemSize: {
57
- type: [Number, String],
58
+ type: Number,
58
59
  required: false,
59
60
  default: 0
60
61
  },
@@ -70,7 +71,7 @@ export default defineComponent({
70
71
  required: false,
71
72
  default: 0
72
73
  },
73
- tableColspan: { type: [Number, String], required: false, default: 1 },
74
+ tableColspan: { type: [Number, String], required: false, default: 100 },
74
75
  virtualScrollHorizontal: {
75
76
  type: Boolean,
76
77
  required: false,
@@ -101,6 +102,7 @@ export default defineComponent({
101
102
  setup(props, { slots, attrs }) {
102
103
  let localScrollTarget: HTMLElement | undefined
103
104
  const rootRef: Ref<HTMLElement | null> = ref(null)
105
+ const scrollSizeItem: Ref<number> = ref(40)
104
106
 
105
107
  const isDefined = (v: any) => v !== undefined && v !== null
106
108
 
@@ -112,6 +114,34 @@ export default defineComponent({
112
114
  : 0
113
115
  })
114
116
 
117
+ onMounted(() => {
118
+ window.addEventListener('load', setItemSize)
119
+ })
120
+
121
+ onUnmounted(() => window.removeEventListener('load', () => {}))
122
+
123
+ const setItemSize = () => {
124
+ scrollSizeItem.value = props.virtualScrollItemSize
125
+ ? props.virtualScrollItemSize
126
+ : typeof rootRef.value?.getElementsByClassName === 'function'
127
+ ? rootRef.value?.getElementsByClassName(
128
+ 'dl-virtual-scroll__content'
129
+ )[0].children[0].clientHeight
130
+ : 40
131
+ }
132
+
133
+ watch(
134
+ props,
135
+ () => {
136
+ setItemSize()
137
+ },
138
+ { deep: true }
139
+ )
140
+
141
+ const virtualScrollItemSizeComputed = computed(() => {
142
+ return scrollSizeItem.value
143
+ })
144
+
115
145
  const {
116
146
  virtualScrollSliceRange,
117
147
  localResetVirtualScroll,
@@ -120,7 +150,8 @@ export default defineComponent({
120
150
  } = useVirtualScroll({
121
151
  virtualScrollLength,
122
152
  getVirtualScrollTarget,
123
- getVirtualScrollEl
153
+ getVirtualScrollEl,
154
+ virtualScrollItemSizeComputed
124
155
  })
125
156
 
126
157
  const virtualScrollScope = computed(() => {
@@ -222,7 +222,6 @@
222
222
  :selected="selected"
223
223
  :separator="separator"
224
224
  :draggable="draggable"
225
- class="sticky-header"
226
225
  :filter="filter"
227
226
  :selection="selection"
228
227
  :dense="dense"
@@ -233,9 +232,7 @@
233
232
  :columns="tableColumns"
234
233
  style="height: 500px"
235
234
  row-key="index"
236
- :pagination="{ rowsPerPage: 0 }"
237
235
  virtual-scroll
238
- :rows-per-page-options="[0]"
239
236
  @virtual-scroll="onScroll"
240
237
  />
241
238
  </div>
@@ -4,9 +4,6 @@
4
4
  <dl-virtual-scroll
5
5
  v-slot="{ item: row, index }"
6
6
  type="table"
7
- :virtual-scroll-item-size="48"
8
- :virtual-scroll-sticky-size-start="48"
9
- :virtual-scroll-sticky-size-end="32"
10
7
  :items="heavyList"
11
8
  style="height: 500px"
12
9
  @virtual-scroll="log"
@@ -27,9 +24,6 @@
27
24
  <dl-virtual-scroll
28
25
  v-slot="{ item, index }"
29
26
  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
27
  :items="horizontalList"
34
28
  virtual-scroll-horizontal
35
29
  >
@@ -47,9 +41,6 @@
47
41
  v-slot="{ item, index }"
48
42
  style="height: 300px"
49
43
  :items="basicList"
50
- :virtual-scroll-item-size="28"
51
- :virtual-scroll-sticky-size-start="28"
52
- :virtual-scroll-sticky-size-end="20"
53
44
  separator
54
45
  @virtual-scroll="log"
55
46
  >
@@ -69,9 +60,9 @@
69
60
  <dl-virtual-scroll
70
61
  style="height: 300px; gap: 20px"
71
62
  :items="customList"
72
- :virtual-scroll-item-size="293"
73
- :virtual-scroll-sticky-size-start="293"
74
- :virtual-scroll-sticky-size-end="200"
63
+ :virtual-scroll-item-size="295"
64
+ :virtual-scroll-sticky-size-start="20"
65
+ :virtual-scroll-sticky-size-end="20"
75
66
  separator
76
67
  @virtual-scroll="log"
77
68
  >
@@ -38,7 +38,7 @@
38
38
  <dl-widget>
39
39
  <template #header>
40
40
  <span>Widget 1</span>
41
- <span style="font-size: 12px; color: gray">Subtitle</span>
41
+ <span style="font-size: 12px; color: var(--dl-color-medium)">Subtitle</span>
42
42
  </template>
43
43
  <template #content>
44
44
  <dl-bar-chart