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

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.
Files changed (21) hide show
  1. package/package.json +1 -1
  2. package/src/assets/globals.scss +226 -3
  3. package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeRange.vue +106 -101
  4. package/src/components/compound/DlDateTime/DlDateTimeRange/types.ts +0 -5
  5. package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +27 -24
  6. package/src/components/compound/DlInput/DlInput.vue +0 -4
  7. package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +0 -12
  8. package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +8 -3
  9. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +18 -58
  10. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchJsonEditorDialog.vue +45 -187
  11. package/src/components/compound/DlSelect/DlSelect.vue +3 -15
  12. package/src/components/compound/DlSelect/components/DlSelectOption.vue +6 -7
  13. package/src/components/compound/DlTable/DlTable.vue +15 -12
  14. package/src/components/compound/DlTable/hooks/use-sortable.ts +148 -5
  15. package/src/components/compound/DlTreeTable/DlTreeTable.vue +55 -31
  16. package/src/components/compound/DlTreeTable/views/DlTrTreeView.vue +1 -1
  17. package/src/components/essential/DlSwitch/DlSwitch.vue +4 -14
  18. package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +1 -3
  19. package/src/demos/DlDateTimeRangeDemo.vue +0 -20
  20. package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +0 -1
  21. package/src/components/compound/DlDateTime/DlDateTimeRange/DateTimeRangeContent.vue +0 -177
@@ -161,7 +161,7 @@
161
161
  <div
162
162
  v-if="
163
163
  visibleColumns &&
164
- visibleColumns.length
164
+ visibleColumns.length
165
165
  "
166
166
  class="visible-columns-justify-end"
167
167
  style="width: 100%; display: flex"
@@ -274,8 +274,8 @@
274
274
  isRowSelected(getRowKey(props.item))
275
275
  ? 'selected'
276
276
  : hasAnyAction
277
- ? ' cursor-pointer'
278
- : ''
277
+ ? ' cursor-pointer'
278
+ : ''
279
279
  "
280
280
  :no-hover="noHover"
281
281
  @click="
@@ -565,7 +565,7 @@
565
565
  <div
566
566
  v-if="
567
567
  visibleColumns &&
568
- visibleColumns.length
568
+ visibleColumns.length
569
569
  "
570
570
  class="visible-columns-justify-end"
571
571
  style="width: 100%; display: flex"
@@ -674,8 +674,8 @@
674
674
  <dl-top-scroll
675
675
  v-if="
676
676
  tableScroll &&
677
- infiniteScroll &&
678
- !isDataEmpty
677
+ infiniteScroll &&
678
+ !isDataEmpty
679
679
  "
680
680
  :container-ref="tableScroll"
681
681
  @scroll-to-top="
@@ -709,8 +709,8 @@
709
709
  isRowSelected(getRowKey(row))
710
710
  ? 'selected'
711
711
  : hasAnyAction
712
- ? ' cursor-pointer'
713
- : ''
712
+ ? ' cursor-pointer'
713
+ : ''
714
714
  "
715
715
  :no-hover="noHover"
716
716
  @click="onTrClick($event, row, pageIndex)"
@@ -845,8 +845,8 @@
845
845
  <dl-bottom-scroll
846
846
  v-if="
847
847
  tableScroll &&
848
- infiniteScroll &&
849
- !isDataEmpty
848
+ infiniteScroll &&
849
+ !isDataEmpty
850
850
  "
851
851
  :container-ref="tableScroll"
852
852
  @scroll-to-bottom="
@@ -903,7 +903,7 @@
903
903
  <div
904
904
  v-if="
905
905
  hasBottomSelectionBanner &&
906
- selectedRowsLabel(rowsSelectedNumber)
906
+ selectedRowsLabel(rowsSelectedNumber)
907
907
  "
908
908
  class="dl-table__control"
909
909
  >
@@ -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
  }
@@ -266,11 +266,11 @@ export default defineComponent({
266
266
  emptyStateProps: {
267
267
  type: Object as PropType<DlEmptyStateProps>,
268
268
  default: () =>
269
- ({
270
- title: '',
271
- subtitle: 'No data to show yet',
272
- icon: 'icon-dl-dataset-filled'
273
- } as unknown as PropType<DlEmptyStateProps>)
269
+ ({
270
+ title: '',
271
+ subtitle: 'No data to show yet',
272
+ icon: 'icon-dl-dataset-filled'
273
+ } as unknown as PropType<DlEmptyStateProps>)
274
274
  },
275
275
  /**
276
276
  * Custom icon class to use for expanded rows.
@@ -392,7 +392,7 @@ export default defineComponent({
392
392
  typeof props.rowKey === 'function'
393
393
  ? props.rowKey
394
394
  : (row: Record<string, any>) =>
395
- row[props.rowKey as string] ?? ''
395
+ row[props.rowKey as string] ?? ''
396
396
  )
397
397
 
398
398
  const hasDraggableRows = computed(() =>
@@ -537,7 +537,7 @@ export default defineComponent({
537
537
  const onMultipleSelectionSet = (val: boolean) => {
538
538
  const value =
539
539
  selectedData.value.length > 0 &&
540
- selectedData.value.length === tableRows.value.length
540
+ selectedData.value.length === tableRows.value.length
541
541
  ? false
542
542
  : val
543
543
 
@@ -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
 
@@ -804,9 +811,7 @@ export default defineComponent({
804
811
  targetRow: finalTarget
805
812
  })
806
813
 
807
- const isDragValid =
808
- shouldSkipValidation ||
809
- checkParentCondition(draggedRow.value, finalTarget)
814
+ const isDragValid = shouldSkipValidation || checkParentCondition(draggedRow.value, finalTarget)
810
815
  if (isDragValid) {
811
816
  const smartSortingMovement = {
812
817
  ...sortingMovement.value,
@@ -825,11 +830,16 @@ export default defineComponent({
825
830
  }
826
831
 
827
832
  const handleChangeEvent = (event: any) => {
828
- const originalEvent = event.originalEvent
829
- const passedElement = getElementAbove(
830
- originalEvent.srcElement,
831
- 'dl-tr'
832
- ) as HTMLElement
833
+ const originalEvent = event?.originalEvent
834
+ if (!originalEvent) {
835
+ return
836
+ }
837
+
838
+ const srcEl =
839
+ (originalEvent.srcElement ||
840
+ originalEvent.target ||
841
+ null) as HTMLElement | null
842
+ const passedElement = srcEl ? getElementAbove(srcEl, 'dl-tr') : null
833
843
  if (passedElement) {
834
844
  const targetRowId = passedElement.dataset.id
835
845
  const targetLevel = passedElement.getAttribute('data-level')
@@ -861,14 +871,21 @@ export default defineComponent({
861
871
  targetRow: targetRow.value
862
872
  })
863
873
  }
874
+
864
875
  const currentY = originalEvent.clientY
865
- if (currentY > prevMouseY) {
866
- sortingMovement.value.direction = 'down'
867
- } else if (currentY < prevMouseY) {
868
- sortingMovement.value.direction = 'up'
876
+ if (typeof currentY === 'number') {
877
+ if (currentY > prevMouseY) {
878
+ sortingMovement.value.direction = 'down'
879
+ } else if (currentY < prevMouseY) {
880
+ sortingMovement.value.direction = 'up'
881
+ }
882
+ prevMouseY = currentY
883
+ }
884
+
885
+ const lastId = passedElement?.dataset?.id
886
+ if (lastId) {
887
+ sortingMovement.value.lastId = lastId
869
888
  }
870
- prevMouseY = currentY
871
- sortingMovement.value.lastId = passedElement.dataset.id
872
889
  }
873
890
 
874
891
  const handleStartEvent = (event: any) => {
@@ -1161,6 +1178,8 @@ export default defineComponent({
1161
1178
  group: 'nested',
1162
1179
  animation: 150,
1163
1180
  fallbackOnBody: true,
1181
+ forceFallback: true,
1182
+ fallbackClass: 'dl-tree-table-fallback-row',
1164
1183
  invertSwap: true,
1165
1184
  swapThreshold: 0.85,
1166
1185
  handle: '.draggable-icon',
@@ -1224,7 +1243,7 @@ export default defineComponent({
1224
1243
  this.vue2h = vue2h
1225
1244
  const tableBodySlot = isVue2
1226
1245
  ? this.$slots['table-body'] &&
1227
- (() => (this.$slots['table-body'] as any)?.pop())
1246
+ (() => (this.$slots['table-body'] as any)?.pop())
1228
1247
  : this.$slots['table-body']
1229
1248
  const tbody =
1230
1249
  tableBodySlot ?? (this.isDataEmpty ? null : this.renderTBody)
@@ -1287,7 +1306,8 @@ export default defineComponent({
1287
1306
  gap: 10px;
1288
1307
  justify-content: center;
1289
1308
  flex-wrap: wrap;
1290
- & > * {
1309
+
1310
+ &>* {
1291
1311
  flex-grow: 1;
1292
1312
  }
1293
1313
  }
@@ -1316,23 +1336,27 @@ tr {
1316
1336
  }
1317
1337
 
1318
1338
  .sticky-header {
1339
+
1319
1340
  ::v-deep .dl-table__top,
1320
1341
  ::v-deep .dl-table__bottom,
1321
1342
  ::v-deep thead tr:first-child th {
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 */
1335
1359
  top: 40px;
1336
1360
  }
1337
1361
  }
1338
- </style>
1362
+ </style>
@@ -16,7 +16,7 @@
16
16
  }`"
17
17
  >
18
18
  <dl-icon
19
- v-if="hasDraggableRows && !row.disableDraggable"
19
+ v-if="hasDraggableRows && !row.disableDraggable"
20
20
  class="draggable-icon"
21
21
  icon="icon-dl-drag"
22
22
  size="12px"
@@ -7,14 +7,12 @@
7
7
  }`"
8
8
  >
9
9
  <label
10
- v-if="hasLeftLabel"
10
+ v-if="!!leftLabel"
11
11
  class="left dl-switch-label"
12
12
  :for="computedId"
13
13
  :style="cssLabelVars"
14
14
  >
15
- <slot name="left-label">
16
- {{ leftLabel }}
17
- </slot>
15
+ {{ leftLabel }}
18
16
  </label>
19
17
  <span
20
18
  class="dl-switch-container"
@@ -37,14 +35,12 @@
37
35
  />
38
36
  </span>
39
37
  <label
40
- v-if="hasRightLabel"
38
+ v-if="!!rightLabel"
41
39
  class="right dl-switch-label"
42
40
  :for="computedId"
43
41
  :style="cssLabelVars"
44
42
  >
45
- <slot name="right-label">
46
- {{ rightLabel }}
47
- </slot>
43
+ {{ rightLabel }}
48
44
  </label>
49
45
  </div>
50
46
  </template>
@@ -147,12 +143,6 @@ export default defineComponent({
147
143
  ? this.index === -1
148
144
  : toRaw(this.modelValue) === toRaw(this.falseValue)
149
145
  },
150
- hasLeftLabel(): boolean {
151
- return !!this.leftLabel || !!this.$slots['left-label']
152
- },
153
- hasRightLabel(): boolean {
154
- return !!this.rightLabel || !!this.$slots['right-label']
155
- },
156
146
  cssVars(): Record<string, string> {
157
147
  return {
158
148
  '--dl-checkbox-height': `${this.size}px`,
@@ -124,9 +124,7 @@ export default defineComponent({
124
124
 
125
125
  let localScrollTarget: HTMLElement | undefined
126
126
  const rootRef: Ref<HTMLElement | null> = ref(null)
127
- const scrollSizeItem: Ref<number> = ref(
128
- virtualScrollItemSize.value || 40
129
- )
127
+ const scrollSizeItem: Ref<number> = ref(40)
130
128
 
131
129
  const isDefined = (v: any) => v !== undefined && v !== null
132
130
 
@@ -176,26 +176,6 @@
176
176
  @change="handleModelValueUpdate"
177
177
  />
178
178
  </div>
179
- <div style="width: 500px; margin-top: 30px">
180
- <div style="margin-bottom: 10px; font-weight: bold">
181
- Inline Mode
182
- </div>
183
- <dl-date-time-range
184
- v-model="date"
185
- :type="type"
186
- width="100%"
187
- :available-range="range ? availableRange : null"
188
- :mode="mode"
189
- :show-time="showTime"
190
- :auto-close="autoClose"
191
- :including-current-month="includesCurrentMonthEnd"
192
- :should-clear-select-first-option="shouldClearSelectFirstOption"
193
- :disabled-type="type === 'day' ? 'month' : 'day'"
194
- view-mode="inline"
195
- @set-type="handleSetType"
196
- @change="handleModelValueUpdate"
197
- />
198
- </div>
199
179
  </div>
200
180
  </template>
201
181
  <script lang="ts">
@@ -42,7 +42,6 @@
42
42
 
43
43
  <dl-smart-search-input
44
44
  v-model="queryObject"
45
- no-tooltip
46
45
  :aliases="aliases"
47
46
  :schema="schema"
48
47
  :color-schema="colorSchema"