@dataloop-ai/components 0.20.167-ds-v3.0 → 0.20.167-ds-v3.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.20.167-ds-v3.0",
3
+ "version": "0.20.167-ds-v3.2",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -355,6 +355,7 @@ export default defineComponent({
355
355
  const hasFlatTreeData = true
356
356
  const draggedRow = ref<DlTableRow | null>(null)
357
357
  const targetRow = ref<DlTableRow | null>(null)
358
+ const storedValidTarget = ref<DlTableRow | null>(null)
358
359
 
359
360
  const vue2h = ref()
360
361
 
@@ -783,24 +784,43 @@ export default defineComponent({
783
784
  }
784
785
 
785
786
  const handleEndEvent = (event: SortableJs.SortableEvent) => {
787
+ let finalTarget = targetRow.value
788
+ let shouldSkipValidation = false
789
+
790
+ if (storedValidTarget.value && targetRow.value) {
791
+ const targetParent = findParentForChild(
792
+ targetRow.value.id,
793
+ tableRows.value
794
+ )
795
+ if (targetParent === storedValidTarget.value.id) {
796
+ finalTarget = storedValidTarget.value
797
+ shouldSkipValidation = true
798
+ }
799
+ }
800
+
786
801
  emit('row-drag-end', {
787
802
  draggedRow: draggedRow.value,
788
- targetRow: targetRow.value
803
+ targetRow: finalTarget
789
804
  })
790
- const isDragValid = checkParentCondition(
791
- draggedRow.value,
792
- targetRow.value
793
- )
805
+
806
+ const isDragValid =
807
+ shouldSkipValidation ||
808
+ checkParentCondition(draggedRow.value, finalTarget)
794
809
  if (isDragValid) {
810
+ const smartSortingMovement = {
811
+ ...sortingMovement.value,
812
+ lastId: finalTarget?.id || sortingMovement.value.lastId
813
+ }
795
814
  emit(
796
815
  'row-reorder',
797
- moveNestedRow(tableRows.value, event, sortingMovement.value)
816
+ moveNestedRow(tableRows.value, event, smartSortingMovement)
798
817
  )
799
818
  } else {
800
819
  mainTableKey.value = v4()
801
820
  }
802
821
  draggedRow.value = null
803
822
  targetRow.value = null
823
+ storedValidTarget.value = null
804
824
  }
805
825
 
806
826
  const handleChangeEvent = (event: any) => {
@@ -905,7 +925,16 @@ export default defineComponent({
905
925
  return false
906
926
  }
907
927
 
908
- return checkParentCondition(draggedRow.value, targetRow)
928
+ if (targetRow.disableDraggable) {
929
+ return false
930
+ }
931
+
932
+ const isValid = checkParentCondition(draggedRow.value, targetRow)
933
+
934
+ if (isValid) {
935
+ storedValidTarget.value = targetRow
936
+ }
937
+ return isValid
909
938
  }
910
939
 
911
940
  const getTargetRowFromMoveEvent = (
@@ -7,12 +7,14 @@
7
7
  }`"
8
8
  >
9
9
  <label
10
- v-if="!!leftLabel"
10
+ v-if="hasLeftLabel"
11
11
  class="left dl-switch-label"
12
12
  :for="computedId"
13
13
  :style="cssLabelVars"
14
14
  >
15
- {{ leftLabel }}
15
+ <slot name="left-label">
16
+ {{ leftLabel }}
17
+ </slot>
16
18
  </label>
17
19
  <span
18
20
  class="dl-switch-container"
@@ -35,12 +37,14 @@
35
37
  />
36
38
  </span>
37
39
  <label
38
- v-if="!!rightLabel"
40
+ v-if="hasRightLabel"
39
41
  class="right dl-switch-label"
40
42
  :for="computedId"
41
43
  :style="cssLabelVars"
42
44
  >
43
- {{ rightLabel }}
45
+ <slot name="right-label">
46
+ {{ rightLabel }}
47
+ </slot>
44
48
  </label>
45
49
  </div>
46
50
  </template>
@@ -143,6 +147,12 @@ export default defineComponent({
143
147
  ? this.index === -1
144
148
  : toRaw(this.modelValue) === toRaw(this.falseValue)
145
149
  },
150
+ hasLeftLabel(): boolean {
151
+ return !!this.leftLabel || !!this.$slots['left-label']
152
+ },
153
+ hasRightLabel(): boolean {
154
+ return !!this.rightLabel || !!this.$slots['right-label']
155
+ },
146
156
  cssVars(): Record<string, string> {
147
157
  return {
148
158
  '--dl-checkbox-height': `${this.size}px`,