@dataloop-ai/components 0.20.186-ds-v3.0 → 0.20.187-ds-v3.0

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.20.186-ds-v3.0",
3
+ "version": "0.20.187-ds-v3.0",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -1,4 +1,4 @@
1
- @import "./theme.css";
1
+ @import './theme.css';
2
2
 
3
3
  body {
4
4
  & > * {
@@ -8,6 +8,231 @@ body {
8
8
  }
9
9
  }
10
10
 
11
+ html.dl-sortable--dragging,
12
+ html.dl-sortable--dragging * {
13
+ cursor: grabbing !important;
14
+ user-select: none !important;
15
+ -webkit-user-select: none !important;
16
+ -moz-user-select: none !important;
17
+ -ms-user-select: none !important;
18
+ }
19
+
20
+ .dl-table-fallback-row.sortable-drag {
21
+ display: table !important;
22
+ table-layout: fixed;
23
+ border-collapse: collapse;
24
+ border-spacing: 0;
25
+ font-family: 'Roboto', sans-serif;
26
+ font-weight: 400;
27
+ font-style: normal;
28
+ font-size: var(--dl-font-size-body);
29
+ line-height: 14px;
30
+ color: var(--dl-color-darker);
31
+ background-color: var(--dl-color-fill-hover);
32
+ }
33
+
34
+ tr.dl-table-fallback-row.sortable-drag {
35
+ display: table !important;
36
+ table-layout: fixed;
37
+ border-collapse: collapse;
38
+ border-spacing: 0;
39
+ font-family: 'Roboto', sans-serif;
40
+ font-weight: 400;
41
+ font-style: normal;
42
+ font-size: var(--dl-font-size-body);
43
+ line-height: 14px;
44
+ color: var(--dl-color-darker);
45
+ }
46
+
47
+ tr.dl-table-fallback-row.sortable-drag > th,
48
+ tr.dl-table-fallback-row.sortable-drag > td {
49
+ display: table-cell;
50
+ box-sizing: border-box;
51
+ background-color: var(--dl-color-fill-hover);
52
+ color: var(--dl-color-darker);
53
+ vertical-align: middle;
54
+ height: 40px;
55
+ padding-top: 0 !important;
56
+ padding-bottom: 0 !important;
57
+ }
58
+
59
+ tbody.dl-table-fallback-row.sortable-drag {
60
+ display: table-row-group !important;
61
+ }
62
+
63
+ .dl-tree-table-fallback-row.sortable-drag {
64
+ display: table !important;
65
+ table-layout: fixed;
66
+ border-collapse: collapse;
67
+ border-spacing: 0;
68
+ font-family: 'Roboto', sans-serif;
69
+ font-weight: 400;
70
+ font-style: normal;
71
+ font-size: var(--dl-font-size-body);
72
+ line-height: 14px;
73
+ color: var(--dl-color-darker);
74
+ background-color: var(--dl-color-panel-background);
75
+ border-radius: 4px;
76
+ overflow: hidden;
77
+ box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
78
+ }
79
+
80
+ tr.dl-tree-table-fallback-row.sortable-drag {
81
+ display: table !important;
82
+ table-layout: fixed;
83
+ border-collapse: collapse;
84
+ border-spacing: 0;
85
+ font-family: 'Roboto', sans-serif;
86
+ font-weight: 400;
87
+ font-style: normal;
88
+ font-size: var(--dl-font-size-body);
89
+ line-height: 14px;
90
+ color: var(--dl-color-darker);
91
+ background-color: var(--dl-color-panel-background);
92
+ }
93
+
94
+ tr.dl-tree-table-fallback-row.sortable-drag > th,
95
+ tr.dl-tree-table-fallback-row.sortable-drag > td {
96
+ display: table-cell;
97
+ box-sizing: border-box;
98
+ background-color: var(--dl-color-fill-hover);
99
+ color: var(--dl-color-darker);
100
+ vertical-align: middle;
101
+ height: 40px;
102
+ padding-top: 0 !important;
103
+ padding-bottom: 0 !important;
104
+ }
105
+
106
+ tbody.dl-tree-table-fallback-row.sortable-drag {
107
+ display: table-row-group !important;
108
+ }
109
+
110
+ .dl-table-fallback-row.sortable-drag > tr {
111
+ display: table-row;
112
+ height: 40px;
113
+ vertical-align: middle;
114
+ }
115
+
116
+ .dl-tree-table-fallback-row.sortable-drag > tr {
117
+ display: table-row;
118
+ height: 40px;
119
+ vertical-align: middle;
120
+ }
121
+
122
+ .dl-table-fallback-row.sortable-drag > tr > th,
123
+ .dl-table-fallback-row.sortable-drag > tr > td {
124
+ display: table-cell;
125
+ box-sizing: border-box;
126
+ background-color: var(--dl-color-fill-hover);
127
+ color: var(--dl-color-darker);
128
+ vertical-align: middle;
129
+ }
130
+
131
+ .dl-tree-table-fallback-row.sortable-drag > tr > th,
132
+ .dl-tree-table-fallback-row.sortable-drag > tr > td {
133
+ display: table-cell;
134
+ box-sizing: border-box;
135
+ background-color: var(--dl-color-fill-hover);
136
+ color: var(--dl-color-darker);
137
+ vertical-align: middle;
138
+ }
139
+
140
+ .dl-tree-table-fallback-row.sortable-drag > tr:first-child > th,
141
+ .dl-tree-table-fallback-row.sortable-drag > tr:first-child > td {
142
+ background-color: var(--dl-color-fill-hover);
143
+ }
144
+
145
+ .dl-tree-table-fallback-row.sortable-drag > tr:not(:first-child) > th,
146
+ .dl-tree-table-fallback-row.sortable-drag > tr:not(:first-child) > td {
147
+ background-color: var(--dl-color-fill-hover);
148
+ }
149
+
150
+ .dl-tree-table-fallback-row.sortable-drag
151
+ tr[data-level]:not([data-level='1'])
152
+ > td:first-child,
153
+ .dl-tree-table-fallback-row.sortable-drag
154
+ tr[data-level]:not([data-level='1'])
155
+ > td.dl-table--col-auto-width,
156
+ .dl-tree-table-fallback-row.sortable-drag
157
+ tr[data-level]:not([data-level='1'])
158
+ > td.chevron-icon-container {
159
+ background-color: transparent !important;
160
+ }
161
+
162
+ .dl-tree-table-fallback-row.sortable-drag
163
+ tr[data-level]:not([data-level='1'])
164
+ > td.chevron-icon-container,
165
+ .dl-tree-table-fallback-row.sortable-drag
166
+ tr[data-level]:not([data-level='1'])
167
+ > td.chevron-icon-container
168
+ *,
169
+ .dl-tree-table-fallback-row.sortable-drag > tr:not(:first-child) .chevron-icon,
170
+ .dl-tree-table-fallback-row.sortable-drag
171
+ tr[data-level]:not([data-level='1'])
172
+ .chevron-icon
173
+ * {
174
+ background-color: transparent !important;
175
+ }
176
+
177
+ .dl-tree-table-fallback-row.sortable-drag
178
+ tbody[data-level]:not([data-level='1'])
179
+ > tr
180
+ > td:first-child,
181
+ .dl-tree-table-fallback-row.sortable-drag
182
+ tbody[data-level]:not([data-level='1'])
183
+ > tr
184
+ > td.dl-table--col-auto-width,
185
+ .dl-tree-table-fallback-row.sortable-drag
186
+ tbody[data-level]:not([data-level='1'])
187
+ > tr
188
+ > td.chevron-icon-container {
189
+ background-color: transparent !important;
190
+ }
191
+
192
+ .dl-tree-table-fallback-row.sortable-drag
193
+ tbody[data-level]:not([data-level='1'])
194
+ > tr
195
+ > td:nth-child(-n + 3) {
196
+ background-color: transparent !important;
197
+ }
198
+
199
+ .dl-tree-table-fallback-row.sortable-drag
200
+ tr:not(:first-child)
201
+ > td:nth-child(-n + 3) {
202
+ background-color: transparent !important;
203
+ }
204
+
205
+ .dl-tree-table-fallback-row.sortable-drag
206
+ tbody[data-level]:not([data-level='1'])
207
+ > tr
208
+ > td.chevron-icon-container,
209
+ .dl-tree-table-fallback-row.sortable-drag
210
+ tbody[data-level]:not([data-level='1'])
211
+ > tr
212
+ > td.chevron-icon-container
213
+ *,
214
+ .dl-tree-table-fallback-row.sortable-drag
215
+ tbody[data-level]:not([data-level='1'])
216
+ .chevron-icon,
217
+ .dl-tree-table-fallback-row.sortable-drag
218
+ tbody[data-level]:not([data-level='1'])
219
+ .chevron-icon
220
+ * {
221
+ background-color: transparent !important;
222
+ }
223
+
224
+ .dl-table-fallback-row.sortable-drag .draggable-icon {
225
+ visibility: hidden !important;
226
+ }
227
+
228
+ .dl-tree-table-fallback-row.sortable-drag .draggable-icon {
229
+ visibility: hidden !important;
230
+ }
231
+
232
+ .dl-table-fallback-row.sortable-drag > tr:not(:first-child) {
233
+ display: none !important;
234
+ }
235
+
11
236
  // tranform
12
237
  .rotate-180 {
13
238
  transform: rotate(180deg);
@@ -145,7 +370,6 @@ body {
145
370
  }
146
371
 
147
372
  .non-draggable {
148
- user-drag: none;
149
373
  -webkit-user-drag: none;
150
374
  user-select: none;
151
375
  -moz-user-select: none;
@@ -185,7 +409,6 @@ body {
185
409
  height: 100%;
186
410
  }
187
411
 
188
-
189
412
  // scrollbar
190
413
 
191
414
  html {
@@ -1159,7 +1159,7 @@ export default defineComponent({
1159
1159
  */
1160
1160
  selectedRowsLabel: {
1161
1161
  type: Function,
1162
- default: (val: number) => null
1162
+ default: (val: number): string | null => null
1163
1163
  },
1164
1164
  /**
1165
1165
  * Label visible when loading is active
@@ -2092,6 +2092,9 @@ export default defineComponent({
2092
2092
  group: props.isTreeTable ? 'nested' : tableUuid,
2093
2093
  animation: 150,
2094
2094
  fallbackOnBody: true,
2095
+ forceFallback: true,
2096
+ fallbackClass: 'dl-table-fallback-row',
2097
+ ghostClass: 'dl-table-ghost-row',
2095
2098
  invertSwap: true,
2096
2099
  swapThreshold: 0.5,
2097
2100
  handle: '.draggable-icon'
@@ -106,26 +106,169 @@ export function useSortable(vm: Record<string, any>) {
106
106
  }
107
107
 
108
108
  if (newRootRef) {
109
+ const DRAGGING_CLASS = 'dl-sortable--dragging'
110
+
111
+ const hasDocument = () =>
112
+ typeof document !== 'undefined' &&
113
+ !!document.documentElement &&
114
+ !!document.body
115
+
116
+ const applyGlobalDraggingState = (active: boolean) => {
117
+ if (!hasDocument()) return
118
+
119
+ document.documentElement.classList.toggle(
120
+ DRAGGING_CLASS,
121
+ active
122
+ )
123
+
124
+ document.documentElement.style.cursor = active ? 'grabbing' : ''
125
+ document.body.style.cursor = active ? 'grabbing' : ''
126
+ }
127
+
128
+ const stopDragging = () => {
129
+ if (!isDragging.value) return
130
+ isDragging.value = false
131
+ didSyncCloneWidths = false
132
+ applyGlobalDraggingState(false)
133
+ removeHardStopListeners()
134
+ }
135
+
136
+ const hardStop = () => {
137
+ stopDragging()
138
+ }
139
+
140
+ const onKeyDown = (e: KeyboardEvent) => {
141
+ if (e.key === 'Escape') hardStop()
142
+ }
143
+
144
+ const addHardStopListeners = () => {
145
+ if (!hasDocument()) return
146
+ window.addEventListener('mouseup', hardStop, true)
147
+ window.addEventListener('pointerup', hardStop, true)
148
+ window.addEventListener('touchend', hardStop, true)
149
+ window.addEventListener('dragend', hardStop, true)
150
+ window.addEventListener('drop', hardStop, true)
151
+ window.addEventListener('keydown', onKeyDown, true)
152
+ }
153
+
154
+ const removeHardStopListeners = () => {
155
+ if (!hasDocument()) return
156
+ window.removeEventListener('mouseup', hardStop, true)
157
+ window.removeEventListener('pointerup', hardStop, true)
158
+ window.removeEventListener('touchend', hardStop, true)
159
+ window.removeEventListener('dragend', hardStop, true)
160
+ window.removeEventListener('drop', hardStop, true)
161
+ window.removeEventListener('keydown', onKeyDown, true)
162
+ }
163
+
164
+ let didSyncCloneWidths = false
165
+
166
+ const _syncDraggingElementColumnWidths = (event: any) => {
167
+ if (didSyncCloneWidths) return
168
+ if (!hasDocument()) return
169
+
170
+ const pickRowEl = (
171
+ el: HTMLElement
172
+ ): HTMLTableRowElement | null => {
173
+ if (el.tagName === 'TR') return el as HTMLTableRowElement
174
+ const tr = el.querySelector('tr')
175
+ return (tr as HTMLTableRowElement) || null
176
+ }
177
+
178
+ const itemEl = event?.item as HTMLElement | null
179
+ const sourceRow = itemEl ? pickRowEl(itemEl) : null
180
+ if (!sourceRow) return
181
+
182
+ const sourceCells = Array.from(
183
+ sourceRow.querySelectorAll('th,td')
184
+ ) as HTMLElement[]
185
+ if (sourceCells.length === 0) return
186
+
187
+ const sourceRowWidth = sourceRow.getBoundingClientRect().width
188
+ const widths = sourceCells.map(
189
+ (cell) => cell.getBoundingClientRect().width
190
+ )
191
+
192
+ requestAnimationFrame(() => {
193
+ const dragEl = document.body.querySelector(
194
+ '.sortable-drag'
195
+ ) as HTMLElement | null
196
+ if (!dragEl) return
197
+
198
+ const dragRow = pickRowEl(dragEl)
199
+ if (!dragRow) return
200
+
201
+ const dragRows =
202
+ dragEl.tagName === 'TR'
203
+ ? ([dragEl] as HTMLElement[])
204
+ : (Array.from(
205
+ dragEl.querySelectorAll('tr')
206
+ ) as HTMLElement[])
207
+ if (dragRows.length === 0) return
208
+
209
+ for (const row of dragRows) {
210
+ const cells = Array.from(
211
+ row.querySelectorAll('th,td')
212
+ ) as HTMLElement[]
213
+ if (cells.length === 0) continue
214
+
215
+ const len = Math.min(widths.length, cells.length)
216
+ for (let i = 0; i < len; i++) {
217
+ const w = widths[i]
218
+ const cell = cells[i]
219
+ if (!w || !cell) continue
220
+ const px = `${w}px`
221
+ cell.style.width = px
222
+ cell.style.minWidth = px
223
+ cell.style.maxWidth = px
224
+ }
225
+ }
226
+
227
+ const dragTable =
228
+ (dragEl.tagName === 'TABLE'
229
+ ? (dragEl as HTMLElement)
230
+ : (dragRow.closest(
231
+ 'table'
232
+ ) as HTMLElement | null)) ||
233
+ (dragEl.querySelector('table') as HTMLElement | null)
234
+ if (dragTable && sourceRowWidth) {
235
+ dragTable.style.width = `${sourceRowWidth}px`
236
+ }
237
+
238
+ if (dragEl.tagName === 'TR' && sourceRowWidth) {
239
+ dragEl.style.width = `${sourceRowWidth}px`
240
+ dragEl.style.minWidth = `${sourceRowWidth}px`
241
+ dragEl.style.maxWidth = `${sourceRowWidth}px`
242
+ }
243
+
244
+ didSyncCloneWidths = true
245
+ })
246
+ }
247
+
109
248
  sortable.value = new Sortable(newRootRef, {
110
249
  ...props.options,
111
250
  onChoose: (event) => emit('choose', event),
112
251
  onUnchoose: (event) => emit('unchoose', event),
113
252
  onStart: (event) => {
114
253
  isDragging.value = true
254
+ applyGlobalDraggingState(true)
255
+ addHardStopListeners()
256
+ _syncDraggingElementColumnWidths(event)
115
257
  emit('start', event)
116
258
  },
117
259
  onEnd: (event) => {
118
- setTimeout(() => {
119
- isDragging.value = false
120
- emit('end', event)
121
- })
260
+ stopDragging()
261
+ emit('end', event)
122
262
  },
123
263
  onAdd: (event) => emit('add', event),
124
264
  onUpdate: (event) => emit('update', event),
125
265
  onSort: (event) => emit('sort', event),
126
266
  onRemove: (event) => emit('remove', event),
127
267
  onFilter: (event) => emit('filter', event),
128
- onClone: (event) => emit('clone', event),
268
+ onClone: (event) => {
269
+ _syncDraggingElementColumnWidths(event)
270
+ emit('clone', event)
271
+ },
129
272
  onChange: (event) => emit('change', event)
130
273
  })
131
274
  }
@@ -754,6 +754,8 @@ export default defineComponent({
754
754
  group: 'nested',
755
755
  animation: 150,
756
756
  fallbackOnBody: true,
757
+ forceFallback: true,
758
+ fallbackClass: 'dl-tree-table-fallback-row',
757
759
  invertSwap: true,
758
760
  swapThreshold: 0.85,
759
761
  handle: '.draggable-icon',
@@ -787,15 +789,20 @@ export default defineComponent({
787
789
  let finalTarget = targetRow.value
788
790
  let shouldSkipValidation = false
789
791
 
790
- if (storedValidTarget.value && targetRow.value) {
791
- const isStoredTargetAncestor = isAncestor(
792
- storedValidTarget.value.id,
793
- targetRow.value.id,
794
- tableRows.value
795
- )
796
- if (isStoredTargetAncestor) {
792
+ if (storedValidTarget.value) {
793
+ if (!targetRow.value) {
797
794
  finalTarget = storedValidTarget.value
798
795
  shouldSkipValidation = true
796
+ } else {
797
+ const isStoredTargetAncestor = isAncestor(
798
+ storedValidTarget.value.id,
799
+ targetRow.value.id,
800
+ tableRows.value
801
+ )
802
+ if (isStoredTargetAncestor) {
803
+ finalTarget = storedValidTarget.value
804
+ shouldSkipValidation = true
805
+ }
799
806
  }
800
807
  }
801
808
 
@@ -825,11 +832,15 @@ export default defineComponent({
825
832
  }
826
833
 
827
834
  const handleChangeEvent = (event: any) => {
828
- const originalEvent = event.originalEvent
829
- const passedElement = getElementAbove(
830
- originalEvent.srcElement,
831
- 'dl-tr'
832
- ) as HTMLElement
835
+ const originalEvent = event?.originalEvent
836
+ if (!originalEvent) {
837
+ return
838
+ }
839
+
840
+ const srcEl = (originalEvent.srcElement ||
841
+ originalEvent.target ||
842
+ null) as HTMLElement | null
843
+ const passedElement = srcEl ? getElementAbove(srcEl, 'dl-tr') : null
833
844
  if (passedElement) {
834
845
  const targetRowId = passedElement.dataset.id
835
846
  const targetLevel = passedElement.getAttribute('data-level')
@@ -861,14 +872,21 @@ export default defineComponent({
861
872
  targetRow: targetRow.value
862
873
  })
863
874
  }
875
+
864
876
  const currentY = originalEvent.clientY
865
- if (currentY > prevMouseY) {
866
- sortingMovement.value.direction = 'down'
867
- } else if (currentY < prevMouseY) {
868
- sortingMovement.value.direction = 'up'
877
+ if (typeof currentY === 'number') {
878
+ if (currentY > prevMouseY) {
879
+ sortingMovement.value.direction = 'down'
880
+ } else if (currentY < prevMouseY) {
881
+ sortingMovement.value.direction = 'up'
882
+ }
883
+ prevMouseY = currentY
884
+ }
885
+
886
+ const lastId = passedElement?.dataset?.id
887
+ if (lastId) {
888
+ sortingMovement.value.lastId = lastId
869
889
  }
870
- prevMouseY = currentY
871
- sortingMovement.value.lastId = passedElement.dataset.id
872
890
  }
873
891
 
874
892
  const handleStartEvent = (event: any) => {
@@ -1161,6 +1179,8 @@ export default defineComponent({
1161
1179
  group: 'nested',
1162
1180
  animation: 150,
1163
1181
  fallbackOnBody: true,
1182
+ forceFallback: true,
1183
+ fallbackClass: 'dl-tree-table-fallback-row',
1164
1184
  invertSwap: true,
1165
1185
  swapThreshold: 0.85,
1166
1186
  handle: '.draggable-icon',
@@ -1287,6 +1307,7 @@ export default defineComponent({
1287
1307
  gap: 10px;
1288
1308
  justify-content: center;
1289
1309
  flex-wrap: wrap;
1310
+
1290
1311
  & > * {
1291
1312
  flex-grow: 1;
1292
1313
  }
@@ -1322,13 +1343,16 @@ tr {
1322
1343
  /* bg color is important for th; just specify one */
1323
1344
  background-color: var(--dl-color-panel-background);
1324
1345
  }
1346
+
1325
1347
  ::v-deep thead tr th {
1326
1348
  position: sticky !important;
1327
1349
  z-index: 1;
1328
1350
  }
1351
+
1329
1352
  ::v-deep thead tr:first-child th {
1330
1353
  top: 0;
1331
1354
  }
1355
+
1332
1356
  /* this is when the loading indicator appears */
1333
1357
  &.dl-table--loading thead tr:last-child th {
1334
1358
  /* height of all previous header rows */