@dataloop-ai/components 0.18.63 → 0.18.64

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.18.63",
3
+ "version": "0.18.64",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -15,9 +15,10 @@
15
15
  :class="classes"
16
16
  :style="styles"
17
17
  >
18
- <draggable-upper
19
- v-if="draggable"
20
- @move="movePopup"
18
+ <draggable-upper
19
+ v-if="draggable"
20
+ class="popup-dialog-upper"
21
+ @move="movePopup"
21
22
  />
22
23
  <popup-header
23
24
  v-if="
@@ -376,7 +377,7 @@ export default defineComponent({
376
377
 
377
378
  function configureScrollTarget() {
378
379
  if (anchorEl.value !== null || props.scrollTarget) {
379
- (localScrollTarget as Ref<any>).value = getScrollTarget(
380
+ localScrollTarget.value = getScrollTarget(
380
381
  anchorEl.value as HTMLElement,
381
382
  props.scrollTarget
382
383
  )
@@ -505,6 +506,16 @@ export default defineComponent({
505
506
  border-radius: 2px;
506
507
  }
507
508
 
509
+ .popup-dialog-upper {
510
+ opacity: 0;
511
+ position: absolute;
512
+ top: 2px;
513
+ cursor: pointer;
514
+ }
515
+ .popup-dialog-upper:hover {
516
+ opacity: 1;
517
+ }
518
+
508
519
  .popup-content {
509
520
  max-width: 100%;
510
521
  padding: 0 16px;
@@ -1,56 +1,86 @@
1
1
  <template>
2
- <div
3
- ref="draggableUpper"
4
- class="root"
5
- />
2
+ <div
3
+ ref="draggableUpper"
4
+ class="root"
5
+ @mouseenter="visibleDragIcon = true"
6
+ @mouseleave="visibleDragIcon = false"
7
+ >
8
+ <dl-icon
9
+ class="draggable-icon"
10
+ color="dl-color-medium"
11
+ icon="icon-dl-drag"
12
+ size="12px"
13
+ @mousedown="startDragElement"
14
+ />
15
+ </div>
6
16
  </template>
7
17
 
8
18
  <script lang="ts">
9
- import { defineComponent, getCurrentInstance, onMounted } from 'vue-demi'
19
+ import { throttle } from 'lodash'
20
+ import { defineComponent, getCurrentInstance, ref } from 'vue-demi'
21
+ import { DlIcon } from '../../../essential/DlIcon'
10
22
 
11
23
  export default defineComponent({
24
+ components: {
25
+ DlIcon
26
+ },
12
27
  emits: ['move'],
13
- setup() {
14
- const vm = getCurrentInstance()
28
+ setup(props, { emit }) {
29
+ const visibleDragIcon = ref(false)
15
30
 
16
- onMounted(() => {
17
- const root = vm!.refs.draggableUpper as HTMLElement
18
- let newX = 0
19
- let newY = 0
20
- let offsetX = 0
21
- let offsetY = 0
31
+ const draggableOptions = ref({
32
+ draggableX: 0,
33
+ draggableY: 0,
34
+ originalX: 0,
35
+ originalY: 0,
36
+ draggableCursor: 'pointer'
37
+ })
22
38
 
23
- if (root) {
24
- root.onmousedown = dragMouseDown
39
+ const iconStyles = (): Record<string, string> => {
40
+ return {
41
+ cursor: draggableOptions.value.draggableCursor,
42
+ visibility: visibleDragIcon.value ? 'visible' : 'hidden'
25
43
  }
44
+ }
26
45
 
27
- function dragMouseDown(e: any) {
28
- e = e || window.event
29
- e.preventDefault()
30
-
31
- offsetX = e.layerX
32
- offsetY = e.layerY
46
+ const startDragElement = (e: MouseEvent) => {
47
+ e.preventDefault()
33
48
 
34
- newX = e.clientX
35
- newY = e.clientY
36
- document.onmouseup = closeDragElement
49
+ const target: HTMLElement = e.currentTarget as any
50
+ const iconOffsetX = target.parentElement.clientWidth / 2
51
+ const iconOffsetY = target.parentElement.clientHeight / 2
37
52
 
38
- document.onmousemove = elementDrag
53
+ if (
54
+ !draggableOptions.value.originalY &&
55
+ !draggableOptions.value.originalX
56
+ ) {
57
+ draggableOptions.value.originalY = e.y
58
+ draggableOptions.value.originalX = e.x
39
59
  }
40
60
 
41
- function elementDrag(e: any) {
42
- e = e || window.event
61
+ draggableOptions.value.draggableCursor = 'grabbing'
62
+ document.onmousemove = throttle((e: MouseEvent) => {
63
+ e = e || (window.event as MouseEvent)
43
64
  e.preventDefault()
44
- newX = e.clientX - offsetX
45
- newY = e.clientY - offsetY
46
- vm!.emit('move', newX, newY)
47
- }
65
+ const x = e.x - iconOffsetX
66
+ const y = e.y - iconOffsetY
67
+ emit('move', x, y)
68
+ }, 5)
69
+ document.onmouseup = stopDragElement
70
+ }
71
+ const stopDragElement = () => {
72
+ document.onmousemove = null
73
+ document.onmouseup = null
74
+ draggableOptions.value.draggableCursor = 'pointer'
75
+ }
48
76
 
49
- function closeDragElement() {
50
- document.onmouseup = null
51
- document.onmousemove = null
52
- }
53
- })
77
+ return {
78
+ visibleDragIcon,
79
+ draggableOptions,
80
+ iconStyles,
81
+ startDragElement,
82
+ stopDragElement
83
+ }
54
84
  }
55
85
  })
56
86
  </script>
@@ -59,6 +89,16 @@ export default defineComponent({
59
89
  .root {
60
90
  width: 100%;
61
91
  height: 10px;
92
+ display: flex;
93
+ justify-content: center;
94
+ }
95
+ .draggable-icon {
96
+ display: none;
97
+ padding: 0px 10px;
98
+ transform: rotate(90deg);
99
+ }
100
+ .draggable-icon:hover {
62
101
  cursor: move;
102
+ display: flex;
63
103
  }
64
104
  </style>
@@ -6,6 +6,7 @@
6
6
  additional-info="Some additional information"
7
7
  subtitle="Some text for better explanation."
8
8
  with-close-button
9
+ draggable
9
10
  @close-button-click="handleClear"
10
11
  >
11
12
  <dl-text-area