@dataloop-ai/components 0.16.4 → 0.16.5
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
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
class="dialog-wrapper"
|
|
15
15
|
:style="{
|
|
16
16
|
width: Number(width) ? `${width}px` : width,
|
|
17
|
-
height: Number(height) ? `${height}px` : height
|
|
17
|
+
height: Number(height) ? `${height}px` : height,
|
|
18
|
+
transform: `translate(${draggableOptions.draggableX}px, ${draggableOptions.draggableY}px)`
|
|
18
19
|
}"
|
|
19
20
|
:class="{
|
|
20
21
|
'dialog-wrapper--fullscreen': fullscreen,
|
|
@@ -23,6 +24,15 @@
|
|
|
23
24
|
'dialog-wrapper--left': position === 'left'
|
|
24
25
|
}"
|
|
25
26
|
>
|
|
27
|
+
<dl-icon
|
|
28
|
+
v-if="draggable"
|
|
29
|
+
:style="{ cursor: draggableOptions.draggableCursor }"
|
|
30
|
+
class="dialog-wrapper--draggable-icon"
|
|
31
|
+
color="dl-color-medium"
|
|
32
|
+
icon="icon-dl-drag"
|
|
33
|
+
size="15px"
|
|
34
|
+
@mousedown="startDragElement"
|
|
35
|
+
/>
|
|
26
36
|
<div
|
|
27
37
|
v-if="hasHeader"
|
|
28
38
|
class="header"
|
|
@@ -52,9 +62,12 @@
|
|
|
52
62
|
<script lang="ts">
|
|
53
63
|
import { v4 } from 'uuid'
|
|
54
64
|
import { defineComponent, PropType } from 'vue-demi'
|
|
65
|
+
import DlIcon from '../../essential/DlIcon/DlIcon.vue'
|
|
66
|
+
import { throttle } from 'lodash'
|
|
55
67
|
|
|
56
68
|
export default defineComponent({
|
|
57
69
|
name: 'DlDialogBox',
|
|
70
|
+
components: { DlIcon },
|
|
58
71
|
model: {
|
|
59
72
|
prop: 'modelValue',
|
|
60
73
|
event: 'update:modelValue'
|
|
@@ -70,13 +83,24 @@ export default defineComponent({
|
|
|
70
83
|
default: 'center'
|
|
71
84
|
},
|
|
72
85
|
modelValue: Boolean,
|
|
73
|
-
volatile: { type: Boolean, default: false }
|
|
86
|
+
volatile: { type: Boolean, default: false },
|
|
87
|
+
draggable: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
90
|
+
}
|
|
74
91
|
},
|
|
75
92
|
emits: ['update:modelValue', 'hide', 'show'],
|
|
76
93
|
data() {
|
|
77
94
|
return {
|
|
78
95
|
uuid: `dl-dialog-box-${v4()}`,
|
|
79
|
-
show: this.modelValue
|
|
96
|
+
show: this.modelValue,
|
|
97
|
+
draggableOptions: {
|
|
98
|
+
draggableX: 0,
|
|
99
|
+
draggableY: 0,
|
|
100
|
+
originalX: 0,
|
|
101
|
+
originalY: 0,
|
|
102
|
+
draggableCursor: 'pointer'
|
|
103
|
+
}
|
|
80
104
|
}
|
|
81
105
|
},
|
|
82
106
|
computed: {
|
|
@@ -112,6 +136,33 @@ export default defineComponent({
|
|
|
112
136
|
}
|
|
113
137
|
},
|
|
114
138
|
methods: {
|
|
139
|
+
startDragElement(e: {
|
|
140
|
+
preventDefault: () => void
|
|
141
|
+
y: number
|
|
142
|
+
x: number
|
|
143
|
+
}) {
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
if (
|
|
146
|
+
!this.draggableOptions.originalY &&
|
|
147
|
+
!this.draggableOptions.originalX
|
|
148
|
+
) {
|
|
149
|
+
this.draggableOptions.originalY = e.y
|
|
150
|
+
this.draggableOptions.originalX = e.x
|
|
151
|
+
}
|
|
152
|
+
this.draggableOptions.draggableCursor = 'grabbing'
|
|
153
|
+
document.onmousemove = throttle((e) => {
|
|
154
|
+
this.draggableOptions.draggableX =
|
|
155
|
+
e.x - this.draggableOptions.originalX
|
|
156
|
+
this.draggableOptions.draggableY =
|
|
157
|
+
e.y - this.draggableOptions.originalY
|
|
158
|
+
}, 5)
|
|
159
|
+
document.onmouseup = this.stopDragElement
|
|
160
|
+
},
|
|
161
|
+
stopDragElement() {
|
|
162
|
+
document.onmousemove = null
|
|
163
|
+
document.onmouseup = null
|
|
164
|
+
this.draggableOptions.draggableCursor = 'pointer'
|
|
165
|
+
},
|
|
115
166
|
closeModal() {
|
|
116
167
|
if ((this.$el as HTMLElement)?.blur) {
|
|
117
168
|
(this.$el as HTMLElement).blur()
|
|
@@ -183,15 +234,26 @@ export default defineComponent({
|
|
|
183
234
|
height: 100vh !important;
|
|
184
235
|
border-radius: 0px;
|
|
185
236
|
}
|
|
237
|
+
|
|
186
238
|
&--fullheight {
|
|
187
239
|
margin: 0;
|
|
188
240
|
height: 100vh !important;
|
|
189
241
|
border-radius: 0px;
|
|
190
242
|
}
|
|
243
|
+
|
|
244
|
+
&--draggable-icon {
|
|
245
|
+
position: absolute;
|
|
246
|
+
top: -1px;
|
|
247
|
+
left: 3px;
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
transform: rotate(90deg);
|
|
250
|
+
}
|
|
251
|
+
|
|
191
252
|
&--right {
|
|
192
253
|
position: absolute !important;
|
|
193
254
|
right: 0;
|
|
194
255
|
}
|
|
256
|
+
|
|
195
257
|
&--left {
|
|
196
258
|
position: absolute !important;
|
|
197
259
|
left: 0;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<
|
|
3
|
+
<dl-switch
|
|
4
|
+
v-model="draggable"
|
|
5
|
+
left-label="Draggable"
|
|
6
|
+
/>
|
|
7
|
+
<dl-button @click="openModal">
|
|
4
8
|
Open modal
|
|
5
|
-
</button>
|
|
9
|
+
</dl-button>
|
|
6
10
|
<dl-dialog-box
|
|
7
11
|
ref="modalOne"
|
|
8
12
|
v-model="isOpenedFirstModal"
|
|
13
|
+
:draggable="draggable"
|
|
9
14
|
>
|
|
10
15
|
<template #header>
|
|
11
16
|
<dl-dialog-box-header
|
|
@@ -112,12 +117,13 @@
|
|
|
112
117
|
|
|
113
118
|
<script lang="ts">
|
|
114
119
|
import { defineComponent, ref } from 'vue-demi'
|
|
115
|
-
import { DlDialogBox,
|
|
120
|
+
import { DlButton, DlDialogBox, DlSwitch } from '../components'
|
|
116
121
|
import { DlDialogBoxHeader, DlDialogBoxFooter } from '../components'
|
|
117
122
|
|
|
118
123
|
export default defineComponent({
|
|
119
124
|
name: 'DlDialogBoxDemo',
|
|
120
125
|
components: {
|
|
126
|
+
DlSwitch,
|
|
121
127
|
DlButton,
|
|
122
128
|
DlDialogBox,
|
|
123
129
|
DlDialogBoxHeader,
|
|
@@ -126,7 +132,7 @@ export default defineComponent({
|
|
|
126
132
|
setup() {
|
|
127
133
|
const modalOne = ref<any>(null)
|
|
128
134
|
const modalTwo = ref<any>(null)
|
|
129
|
-
|
|
135
|
+
const draggable = ref(true)
|
|
130
136
|
const isOpenedFirstModal = ref(false)
|
|
131
137
|
|
|
132
138
|
const openModal = () => {
|
|
@@ -168,7 +174,8 @@ export default defineComponent({
|
|
|
168
174
|
closeSecondModal,
|
|
169
175
|
modalOne,
|
|
170
176
|
modalTwo,
|
|
171
|
-
isOpenedFirstModal
|
|
177
|
+
isOpenedFirstModal,
|
|
178
|
+
draggable
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
})
|