@eturnity/eturnity_reusable_components 7.30.3-EPDM-10647.0 → 7.30.3-EPDM-10576.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/.eslintrc.js +184 -0
- package/.prettierrc +8 -6
- package/package.json +9 -21
- package/src/App.vue +79 -78
- package/src/assets/theme.js +3 -3
- package/src/components/addNewButton/AddNewButton.stories.js +2 -2
- package/src/components/addNewButton/index.vue +48 -51
- package/src/components/banner/actionBanner/index.vue +54 -55
- package/src/components/banner/banner/banner.stories.js +5 -5
- package/src/components/banner/banner/index.vue +159 -159
- package/src/components/banner/infoBanner/index.vue +41 -53
- package/src/components/buttons/buttonIcon/index.vue +125 -122
- package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
- package/src/components/buttons/closeButton/index.vue +49 -49
- package/src/components/buttons/mainButton/index.vue +108 -108
- package/src/components/card/index.vue +70 -70
- package/src/components/collapsableInfoText/index.vue +96 -94
- package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
- package/src/components/deleteIcon/index.vue +54 -54
- package/src/components/draggableInputHandle/index.vue +37 -37
- package/src/components/dropdown/Dropdown.stories.js +9 -10
- package/src/components/dropdown/index.vue +106 -106
- package/src/components/errorMessage/index.vue +52 -52
- package/src/components/filter/filterSettings.vue +486 -452
- package/src/components/filter/index.vue +135 -135
- package/src/components/filter/parentDropdown.vue +73 -73
- package/src/components/icon/Icons.stories.js +7 -7
- package/src/components/icon/iconCollection.vue +53 -53
- package/src/components/icon/index.vue +122 -122
- package/src/components/iconWrapper/index.vue +156 -156
- package/src/components/infoCard/index.vue +30 -32
- package/src/components/infoText/index.vue +142 -137
- package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
- package/src/components/inputs/checkbox/index.vue +190 -180
- package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
- package/src/components/inputs/inputNumber/index.vue +696 -701
- package/src/components/inputs/inputNumberQuestion/index.vue +185 -182
- package/src/components/inputs/inputText/InputText.stories.js +22 -22
- package/src/components/inputs/inputText/index.vue +337 -336
- package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
- package/src/components/inputs/radioButton/index.vue +222 -219
- package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
- package/src/components/inputs/searchInput/index.vue +127 -126
- package/src/components/inputs/select/index.vue +792 -792
- package/src/components/inputs/select/option/index.vue +124 -124
- package/src/components/inputs/select/select.stories.js +31 -32
- package/src/components/inputs/slider/index.vue +99 -99
- package/src/components/inputs/switchField/index.vue +220 -222
- package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
- package/src/components/inputs/textAreaInput/index.vue +171 -173
- package/src/components/inputs/toggle/Toggle.stories.js +14 -14
- package/src/components/inputs/toggle/index.vue +214 -217
- package/src/components/label/index.vue +82 -82
- package/src/components/markerItem/index.vue +68 -66
- package/src/components/modals/actionModal/index.vue +54 -54
- package/src/components/modals/infoModal/index.vue +39 -36
- package/src/components/modals/modal/index.vue +134 -134
- package/src/components/modals/modal/modal.stories.js +5 -5
- package/src/components/navigationTabs/index.vue +96 -94
- package/src/components/pageSubtitle/index.vue +55 -49
- package/src/components/pageTitle/index.vue +56 -56
- package/src/components/pagination/index.vue +92 -89
- package/src/components/progressBar/index.vue +107 -107
- package/src/components/projectMarker/index.vue +246 -244
- package/src/components/rangeSlider/Slider.vue +491 -465
- package/src/components/rangeSlider/index.vue +410 -410
- package/src/components/rangeSlider/utils/dom.js +5 -5
- package/src/components/selectedOptions/index.vue +119 -119
- package/src/components/sideMenu/index.vue +199 -199
- package/src/components/spinner/index.vue +57 -57
- package/src/components/tableDropdown/index.vue +520 -520
- package/src/components/tables/mainTable/index.vue +417 -400
- package/src/components/tables/viewTable/index.vue +171 -171
- package/src/components/threeDots/index.vue +340 -334
- package/src/components/videoThumbnail/index.vue +86 -86
- package/src/components/videoThumbnail/videoThumbnail.stories.js +14 -16
- package/src/helpers/numberConverter.js +2 -2
- package/src/helpers/translateLang.js +9 -9
- package/src/mixins/inputValidations.js +5 -5
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
- package/src/utils/index.js +0 -12
@@ -1,8 +1,8 @@
|
|
1
1
|
<template>
|
2
2
|
<div
|
3
|
+
:class="className"
|
3
4
|
:data-id="dataId"
|
4
5
|
:style="style"
|
5
|
-
:class="className"
|
6
6
|
@mousedown="elementMouseDown"
|
7
7
|
@touchstart="elementTouchDown"
|
8
8
|
>
|
@@ -20,528 +20,554 @@
|
|
20
20
|
</template>
|
21
21
|
|
22
22
|
<script>
|
23
|
-
import {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
} from './utils/dom'
|
28
|
-
import { computeWidth, restrictToBounds, snapToGrid } from './utils/fns'
|
29
|
-
|
30
|
-
const events = {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
const userSelectNone = {
|
44
|
-
userSelect: 'none',
|
45
|
-
MozUserSelect: 'none',
|
46
|
-
WebkitUserSelect: 'none',
|
47
|
-
MsUserSelect: 'none'
|
48
|
-
}
|
49
|
-
|
50
|
-
const userSelectAuto = {
|
51
|
-
userSelect: 'auto',
|
52
|
-
MozUserSelect: 'auto',
|
53
|
-
WebkitUserSelect: 'auto',
|
54
|
-
MsUserSelect: 'auto'
|
55
|
-
}
|
56
|
-
|
57
|
-
let eventsFor = events.mouse
|
58
|
-
|
59
|
-
export default {
|
60
|
-
replace: true,
|
61
|
-
name: 'SliderComponent',
|
62
|
-
props: {
|
63
|
-
dataId: {
|
64
|
-
type: String,
|
65
|
-
default: ''
|
66
|
-
},
|
67
|
-
className: {
|
68
|
-
type: String,
|
69
|
-
default: 'vdr'
|
70
|
-
},
|
71
|
-
disableUserSelect: {
|
72
|
-
type: Boolean,
|
73
|
-
default: true
|
74
|
-
},
|
75
|
-
preventDeactivation: {
|
76
|
-
type: Boolean,
|
77
|
-
default: false
|
78
|
-
},
|
79
|
-
active: {
|
80
|
-
type: Boolean,
|
81
|
-
default: false
|
82
|
-
},
|
83
|
-
draggable: {
|
84
|
-
type: Boolean,
|
85
|
-
default: true
|
86
|
-
},
|
87
|
-
resizable: {
|
88
|
-
type: Boolean,
|
89
|
-
default: true
|
90
|
-
},
|
91
|
-
minWidth: {
|
92
|
-
type: Number,
|
93
|
-
default: 1,
|
94
|
-
validator: (val) => val >= 0
|
95
|
-
},
|
96
|
-
step: {
|
97
|
-
type: Number,
|
98
|
-
default: 1,
|
99
|
-
validator: (val) => val > 0
|
100
|
-
},
|
101
|
-
stepCount: {
|
102
|
-
type: Number,
|
103
|
-
default: 0,
|
104
|
-
validator: (val) => val > 0
|
105
|
-
},
|
106
|
-
subStepCount: {
|
107
|
-
type: Number,
|
108
|
-
default: 0,
|
109
|
-
validator: (val) => val >= 0
|
110
|
-
},
|
111
|
-
h: {
|
112
|
-
type: [Number, String],
|
113
|
-
default: 'auto',
|
114
|
-
validator: (val) => {
|
115
|
-
if (typeof val === 'number') {
|
116
|
-
return val > 0
|
117
|
-
}
|
118
|
-
|
119
|
-
return val === 'auto'
|
120
|
-
}
|
23
|
+
import {
|
24
|
+
matchesSelectorToParentElements,
|
25
|
+
addEvent,
|
26
|
+
removeEvent,
|
27
|
+
} from './utils/dom'
|
28
|
+
import { computeWidth, restrictToBounds, snapToGrid } from './utils/fns'
|
29
|
+
|
30
|
+
const events = {
|
31
|
+
mouse: {
|
32
|
+
start: 'mousedown',
|
33
|
+
move: 'mousemove',
|
34
|
+
stop: 'mouseup',
|
35
|
+
},
|
36
|
+
touch: {
|
37
|
+
start: 'touchstart',
|
38
|
+
move: 'touchmove',
|
39
|
+
stop: 'touchend',
|
121
40
|
},
|
122
|
-
|
123
|
-
type: [String, Number],
|
124
|
-
default: 'auto',
|
125
|
-
validator: (val) => (typeof val === 'string' ? val === 'auto' : val >= 0)
|
126
|
-
},
|
127
|
-
min: {
|
128
|
-
type: Number,
|
129
|
-
default: 0,
|
130
|
-
validator: (val) => val >= 0
|
131
|
-
},
|
132
|
-
max: {
|
133
|
-
type: Number,
|
134
|
-
default: 0,
|
135
|
-
validator: (val) => val >= 0
|
136
|
-
},
|
137
|
-
dragHandle: {
|
138
|
-
type: String,
|
139
|
-
default: null
|
140
|
-
},
|
141
|
-
dragCancel: {
|
142
|
-
type: String,
|
143
|
-
default: null
|
144
|
-
},
|
145
|
-
onDrag: {
|
146
|
-
type: Function,
|
147
|
-
default: () => true
|
148
|
-
},
|
149
|
-
onResize: {
|
150
|
-
type: Function,
|
151
|
-
default: () => true
|
152
|
-
}
|
153
|
-
},
|
154
|
-
|
155
|
-
data: function () {
|
156
|
-
return {
|
157
|
-
left: null,
|
158
|
-
right: null,
|
159
|
-
width: null,
|
160
|
-
height: null,
|
161
|
-
parentWidth: null,
|
162
|
-
parentHeight: null,
|
163
|
-
widthTouched: false,
|
164
|
-
heightTouched: false,
|
165
|
-
|
166
|
-
handle: null,
|
167
|
-
resizing: false,
|
168
|
-
dragging: false,
|
169
|
-
dragEnable: false,
|
170
|
-
resizeEnable: false,
|
171
|
-
enabled: this.active,
|
172
|
-
|
173
|
-
zIndex: this.z,
|
174
|
-
handles: ['ml', 'mr']
|
175
|
-
}
|
176
|
-
},
|
177
|
-
|
178
|
-
created: function () {
|
179
|
-
this.resetBoundsAndMouseState()
|
180
|
-
},
|
181
|
-
mounted: function () {
|
182
|
-
const [parentWidth, parentHeight] = this.getParentSize()
|
183
|
-
|
184
|
-
this.parentWidth = parentWidth
|
185
|
-
this.parentHeight = parentHeight
|
186
|
-
|
187
|
-
this.left = this.min * this.pxPerStep
|
188
|
-
this.right = this.max * this.pxPerStep
|
189
|
-
this.width = computeWidth(this.left, this.right)
|
190
|
-
this.height = this.h !== 'auto' ? this.h : parentHeight
|
191
|
-
|
192
|
-
if (this.active) {
|
193
|
-
this.$emit('activated')
|
194
|
-
}
|
195
|
-
|
196
|
-
addEvent(document.documentElement, 'mousedown', this.deselect)
|
197
|
-
addEvent(document.documentElement, 'touchend touchcancel', this.deselect)
|
198
|
-
|
199
|
-
addEvent(window, 'resize', this.checkParentSize)
|
200
|
-
},
|
201
|
-
beforeUnmount: function () {
|
202
|
-
removeEvent(document.documentElement, 'mousedown', this.deselect)
|
203
|
-
removeEvent(document.documentElement, 'touchstart', this.handleUp)
|
204
|
-
removeEvent(document.documentElement, 'mousemove', this.move)
|
205
|
-
removeEvent(document.documentElement, 'touchmove', this.move)
|
206
|
-
removeEvent(document.documentElement, 'mouseup', this.handleUp)
|
207
|
-
removeEvent(document.documentElement, 'touchend touchcancel', this.deselect)
|
208
|
-
|
209
|
-
removeEvent(window, 'resize', this.checkParentSize)
|
210
|
-
},
|
211
|
-
|
212
|
-
methods: {
|
213
|
-
resetBoundsAndMouseState() {
|
214
|
-
this.mouseClickPosition = { mouseX: 0, mouseY: 0, x: 0, y: 0, w: 0, h: 0 }
|
215
|
-
|
216
|
-
this.bounds = {
|
217
|
-
minLeft: null,
|
218
|
-
maxLeft: null,
|
219
|
-
minRight: null,
|
220
|
-
maxRight: null
|
221
|
-
}
|
222
|
-
},
|
223
|
-
checkParentSize() {
|
224
|
-
const [newParentWidth, newParentHeight] = this.getParentSize()
|
225
|
-
|
226
|
-
this.parentWidth = newParentWidth
|
227
|
-
this.parentHeight = newParentHeight
|
228
|
-
},
|
229
|
-
getParentSize() {
|
230
|
-
const style = window.getComputedStyle(this.$el.parentNode, null)
|
41
|
+
}
|
231
42
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
eventsFor = events.touch
|
43
|
+
const userSelectNone = {
|
44
|
+
userSelect: 'none',
|
45
|
+
MozUserSelect: 'none',
|
46
|
+
WebkitUserSelect: 'none',
|
47
|
+
MsUserSelect: 'none',
|
48
|
+
}
|
239
49
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
50
|
+
const userSelectAuto = {
|
51
|
+
userSelect: 'auto',
|
52
|
+
MozUserSelect: 'auto',
|
53
|
+
WebkitUserSelect: 'auto',
|
54
|
+
MsUserSelect: 'auto',
|
55
|
+
}
|
244
56
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
57
|
+
let eventsFor = events.mouse
|
58
|
+
|
59
|
+
export default {
|
60
|
+
replace: true,
|
61
|
+
name: 'SliderComponent',
|
62
|
+
props: {
|
63
|
+
dataId: {
|
64
|
+
type: String,
|
65
|
+
default: '',
|
66
|
+
},
|
67
|
+
className: {
|
68
|
+
type: String,
|
69
|
+
default: 'vdr',
|
70
|
+
},
|
71
|
+
disableUserSelect: {
|
72
|
+
type: Boolean,
|
73
|
+
default: true,
|
74
|
+
},
|
75
|
+
preventDeactivation: {
|
76
|
+
type: Boolean,
|
77
|
+
default: false,
|
78
|
+
},
|
79
|
+
active: {
|
80
|
+
type: Boolean,
|
81
|
+
default: false,
|
82
|
+
},
|
83
|
+
draggable: {
|
84
|
+
type: Boolean,
|
85
|
+
default: true,
|
86
|
+
},
|
87
|
+
resizable: {
|
88
|
+
type: Boolean,
|
89
|
+
default: true,
|
90
|
+
},
|
91
|
+
minWidth: {
|
92
|
+
type: Number,
|
93
|
+
default: 1,
|
94
|
+
validator: (val) => val >= 0,
|
95
|
+
},
|
96
|
+
step: {
|
97
|
+
type: Number,
|
98
|
+
default: 1,
|
99
|
+
validator: (val) => val > 0,
|
100
|
+
},
|
101
|
+
stepCount: {
|
102
|
+
type: Number,
|
103
|
+
default: 0,
|
104
|
+
validator: (val) => val > 0,
|
105
|
+
},
|
106
|
+
subStepCount: {
|
107
|
+
type: Number,
|
108
|
+
default: 0,
|
109
|
+
validator: (val) => val >= 0,
|
110
|
+
},
|
111
|
+
h: {
|
112
|
+
type: [Number, String],
|
113
|
+
default: 'auto',
|
114
|
+
validator: (val) => {
|
115
|
+
if (typeof val === 'number') {
|
116
|
+
return val > 0
|
117
|
+
}
|
118
|
+
|
119
|
+
return val === 'auto'
|
120
|
+
},
|
121
|
+
},
|
122
|
+
z: {
|
123
|
+
type: [String, Number],
|
124
|
+
default: 'auto',
|
125
|
+
validator: (val) =>
|
126
|
+
typeof val === 'string' ? val === 'auto' : val >= 0,
|
127
|
+
},
|
128
|
+
min: {
|
129
|
+
type: Number,
|
130
|
+
default: 0,
|
131
|
+
validator: (val) => val >= 0,
|
132
|
+
},
|
133
|
+
max: {
|
134
|
+
type: Number,
|
135
|
+
default: 0,
|
136
|
+
validator: (val) => val >= 0,
|
137
|
+
},
|
138
|
+
dragHandle: {
|
139
|
+
type: String,
|
140
|
+
default: null,
|
141
|
+
},
|
142
|
+
dragCancel: {
|
143
|
+
type: String,
|
144
|
+
default: null,
|
145
|
+
},
|
146
|
+
onDrag: {
|
147
|
+
type: Function,
|
148
|
+
default: () => true,
|
149
|
+
},
|
150
|
+
onResize: {
|
151
|
+
type: Function,
|
152
|
+
default: () => true,
|
153
|
+
},
|
154
|
+
},
|
155
|
+
|
156
|
+
data: function () {
|
157
|
+
return {
|
158
|
+
left: null,
|
159
|
+
right: null,
|
160
|
+
width: null,
|
161
|
+
height: null,
|
162
|
+
parentWidth: null,
|
163
|
+
parentHeight: null,
|
164
|
+
widthTouched: false,
|
165
|
+
heightTouched: false,
|
166
|
+
|
167
|
+
handle: null,
|
168
|
+
resizing: false,
|
169
|
+
dragging: false,
|
170
|
+
dragEnable: false,
|
171
|
+
resizeEnable: false,
|
172
|
+
enabled: this.active,
|
173
|
+
|
174
|
+
zIndex: this.z,
|
175
|
+
handles: ['ml', 'mr'],
|
250
176
|
}
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
)
|
262
|
-
(this.dragCancel &&
|
263
|
-
matchesSelectorToParentElements(target, this.dragCancel, this.$el))
|
264
|
-
) {
|
265
|
-
this.dragging = false
|
266
|
-
|
267
|
-
return
|
268
|
-
}
|
269
|
-
|
270
|
-
if (!this.enabled) {
|
271
|
-
this.enabled = true
|
272
|
-
|
273
|
-
this.$emit('activated')
|
274
|
-
this.$emit('update:active', true)
|
177
|
+
},
|
178
|
+
computed: {
|
179
|
+
style() {
|
180
|
+
return {
|
181
|
+
transform: `translate(${this.left}px, 0px)`,
|
182
|
+
width: this.computedWidth,
|
183
|
+
height: this.computedHeight,
|
184
|
+
zIndex: this.zIndex,
|
185
|
+
...(this.dragging && this.disableUserSelect
|
186
|
+
? userSelectNone
|
187
|
+
: userSelectAuto),
|
275
188
|
}
|
276
|
-
|
277
|
-
|
278
|
-
|
189
|
+
},
|
190
|
+
actualHandles() {
|
191
|
+
if (!this.resizable) return []
|
192
|
+
|
193
|
+
return this.handles
|
194
|
+
},
|
195
|
+
pxPerStep() {
|
196
|
+
return this.parentWidth / this.stepCount
|
197
|
+
},
|
198
|
+
minWidthByPx() {
|
199
|
+
return this.minWidth * this.pxPerStep
|
200
|
+
},
|
201
|
+
computedWidth() {
|
202
|
+
if (this.width === 'auto') {
|
203
|
+
if (!this.widthTouched) {
|
204
|
+
return 'auto'
|
205
|
+
}
|
279
206
|
}
|
280
207
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
208
|
+
return this.width + 'px'
|
209
|
+
},
|
210
|
+
computedHeight() {
|
211
|
+
if (this.height === 'auto') {
|
212
|
+
if (!this.heightTouched) {
|
213
|
+
return 'auto'
|
214
|
+
}
|
286
215
|
}
|
287
216
|
|
288
|
-
this.
|
289
|
-
|
290
|
-
|
291
|
-
addEvent(document.documentElement, eventsFor.move, this.move)
|
292
|
-
addEvent(document.documentElement, eventsFor.stop, this.handleUp)
|
293
|
-
}
|
294
|
-
},
|
295
|
-
calcDragLimits() {
|
296
|
-
const limits = {
|
297
|
-
minLeft: null,
|
298
|
-
maxLeft: null,
|
299
|
-
minRight: null,
|
300
|
-
maxRight: null
|
301
|
-
}
|
302
|
-
|
303
|
-
limits.minLeft = 0
|
304
|
-
limits.maxLeft = this.parentWidth - this.width
|
305
|
-
limits.minRight = this.width
|
306
|
-
limits.maxRight = this.parentWidth
|
307
|
-
|
308
|
-
return limits
|
217
|
+
return this.height + 'px'
|
218
|
+
},
|
309
219
|
},
|
310
|
-
deselect(e) {
|
311
|
-
const target = e.target || e.srcElement
|
312
|
-
const regex = new RegExp(this.className + '-([trmbl]{2})', '')
|
313
220
|
|
314
|
-
|
315
|
-
|
316
|
-
|
221
|
+
watch: {
|
222
|
+
active(val) {
|
223
|
+
this.enabled = val
|
317
224
|
|
225
|
+
if (val) {
|
226
|
+
this.$emit('activated')
|
227
|
+
} else {
|
318
228
|
this.$emit('deactivated')
|
319
|
-
this.$emit('update:active', false)
|
320
229
|
}
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
230
|
+
},
|
231
|
+
z(val) {
|
232
|
+
if (val >= 0 || val === 'auto') {
|
233
|
+
this.zIndex = val
|
234
|
+
}
|
235
|
+
},
|
326
236
|
},
|
327
|
-
handleTouchDown(handle, e) {
|
328
|
-
eventsFor = events.touch
|
329
237
|
|
330
|
-
|
238
|
+
created: function () {
|
239
|
+
this.resetBoundsAndMouseState()
|
331
240
|
},
|
332
|
-
|
333
|
-
|
334
|
-
return
|
335
|
-
}
|
241
|
+
mounted: function () {
|
242
|
+
const [parentWidth, parentHeight] = this.getParentSize()
|
336
243
|
|
337
|
-
|
244
|
+
this.parentWidth = parentWidth
|
245
|
+
this.parentHeight = parentHeight
|
338
246
|
|
339
|
-
this.
|
340
|
-
this.
|
247
|
+
this.left = this.min * this.pxPerStep
|
248
|
+
this.right = this.max * this.pxPerStep
|
249
|
+
this.width = computeWidth(this.left, this.right)
|
250
|
+
this.height = this.h !== 'auto' ? this.h : parentHeight
|
341
251
|
|
342
|
-
|
343
|
-
|
344
|
-
mouseX: e.touches ? e.touches[0].pageX : e.pageX,
|
345
|
-
left: this.left,
|
346
|
-
right: this.right
|
252
|
+
if (this.active) {
|
253
|
+
this.$emit('activated')
|
347
254
|
}
|
348
255
|
|
349
|
-
|
350
|
-
|
256
|
+
addEvent(document.documentElement, 'mousedown', this.deselect)
|
257
|
+
addEvent(document.documentElement, 'touchend touchcancel', this.deselect)
|
258
|
+
|
259
|
+
addEvent(window, 'resize', this.checkParentSize)
|
260
|
+
},
|
261
|
+
beforeUnmount: function () {
|
262
|
+
removeEvent(document.documentElement, 'mousedown', this.deselect)
|
263
|
+
removeEvent(document.documentElement, 'touchstart', this.handleUp)
|
264
|
+
removeEvent(document.documentElement, 'mousemove', this.move)
|
265
|
+
removeEvent(document.documentElement, 'touchmove', this.move)
|
266
|
+
removeEvent(document.documentElement, 'mouseup', this.handleUp)
|
267
|
+
removeEvent(
|
268
|
+
document.documentElement,
|
269
|
+
'touchend touchcancel',
|
270
|
+
this.deselect
|
271
|
+
)
|
351
272
|
|
352
|
-
|
353
|
-
addEvent(document.documentElement, eventsFor.stop, this.handleUp)
|
273
|
+
removeEvent(window, 'resize', this.checkParentSize)
|
354
274
|
},
|
355
|
-
calcResizeLimits() {
|
356
|
-
const limits = {
|
357
|
-
minLeft: null,
|
358
|
-
maxLeft: null,
|
359
|
-
minRight: null,
|
360
|
-
maxRight: null
|
361
|
-
}
|
362
275
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
276
|
+
methods: {
|
277
|
+
resetBoundsAndMouseState() {
|
278
|
+
this.mouseClickPosition = {
|
279
|
+
mouseX: 0,
|
280
|
+
mouseY: 0,
|
281
|
+
x: 0,
|
282
|
+
y: 0,
|
283
|
+
w: 0,
|
284
|
+
h: 0,
|
285
|
+
}
|
367
286
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
287
|
+
this.bounds = {
|
288
|
+
minLeft: null,
|
289
|
+
maxLeft: null,
|
290
|
+
minRight: null,
|
291
|
+
maxRight: null,
|
292
|
+
}
|
293
|
+
},
|
294
|
+
checkParentSize() {
|
295
|
+
const [newParentWidth, newParentHeight] = this.getParentSize()
|
296
|
+
|
297
|
+
this.parentWidth = newParentWidth
|
298
|
+
this.parentHeight = newParentHeight
|
299
|
+
},
|
300
|
+
getParentSize() {
|
301
|
+
const style = window.getComputedStyle(this.$el.parentNode, null)
|
302
|
+
|
303
|
+
return [
|
304
|
+
parseInt(style.getPropertyValue('width'), 10),
|
305
|
+
parseInt(style.getPropertyValue('height'), 10),
|
306
|
+
]
|
307
|
+
},
|
308
|
+
elementTouchDown(e) {
|
309
|
+
eventsFor = events.touch
|
310
|
+
|
311
|
+
this.elementDown(e)
|
312
|
+
},
|
313
|
+
elementMouseDown(e) {
|
314
|
+
eventsFor = events.mouse
|
315
|
+
|
316
|
+
this.elementDown(e)
|
317
|
+
},
|
318
|
+
elementDown(e) {
|
319
|
+
if (e instanceof MouseEvent && e.button !== 0) {
|
320
|
+
return
|
321
|
+
}
|
382
322
|
|
383
|
-
|
384
|
-
|
323
|
+
const target = e.target || e.srcElement
|
324
|
+
|
325
|
+
if (this.$el.contains(target)) {
|
326
|
+
if (
|
327
|
+
(this.dragHandle &&
|
328
|
+
!matchesSelectorToParentElements(
|
329
|
+
target,
|
330
|
+
this.dragHandle,
|
331
|
+
this.$el
|
332
|
+
)) ||
|
333
|
+
(this.dragCancel &&
|
334
|
+
matchesSelectorToParentElements(
|
335
|
+
target,
|
336
|
+
this.dragCancel,
|
337
|
+
this.$el
|
338
|
+
))
|
339
|
+
) {
|
340
|
+
this.dragging = false
|
341
|
+
|
342
|
+
return
|
343
|
+
}
|
344
|
+
|
345
|
+
if (!this.enabled) {
|
346
|
+
this.enabled = true
|
347
|
+
|
348
|
+
this.$emit('activated')
|
349
|
+
this.$emit('update:active', true)
|
350
|
+
}
|
351
|
+
|
352
|
+
if (this.draggable) {
|
353
|
+
this.dragEnable = true
|
354
|
+
}
|
355
|
+
|
356
|
+
const newPosition = {
|
357
|
+
...this.mouseClickPosition,
|
358
|
+
mouseX: e.touches ? e.touches[0].pageX : e.pageX,
|
359
|
+
left: this.left,
|
360
|
+
right: this.right,
|
361
|
+
}
|
362
|
+
|
363
|
+
this.mouseClickPosition = newPosition
|
364
|
+
this.bounds = this.calcDragLimits()
|
365
|
+
|
366
|
+
addEvent(document.documentElement, eventsFor.move, this.move)
|
367
|
+
addEvent(document.documentElement, eventsFor.stop, this.handleUp)
|
368
|
+
}
|
369
|
+
},
|
370
|
+
calcDragLimits() {
|
371
|
+
const limits = {
|
372
|
+
minLeft: null,
|
373
|
+
maxLeft: null,
|
374
|
+
minRight: null,
|
375
|
+
maxRight: null,
|
376
|
+
}
|
385
377
|
|
386
|
-
|
378
|
+
limits.minLeft = 0
|
379
|
+
limits.maxLeft = this.parentWidth - this.width
|
380
|
+
limits.minRight = this.width
|
381
|
+
limits.maxRight = this.parentWidth
|
382
|
+
|
383
|
+
return limits
|
384
|
+
},
|
385
|
+
deselect(e) {
|
386
|
+
const target = e.target || e.srcElement
|
387
|
+
const regex = new RegExp(this.className + '-([trmbl]{2})', '')
|
388
|
+
|
389
|
+
if (!this.$el.contains(target) && !regex.test(target.className)) {
|
390
|
+
if (this.enabled && !this.preventDeactivation) {
|
391
|
+
this.enabled = false
|
392
|
+
|
393
|
+
this.$emit('deactivated')
|
394
|
+
this.$emit('update:active', false)
|
395
|
+
}
|
396
|
+
|
397
|
+
removeEvent(
|
398
|
+
document.documentElement,
|
399
|
+
eventsFor.move,
|
400
|
+
this.handleResize
|
401
|
+
)
|
402
|
+
}
|
387
403
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
)
|
404
|
+
this.resetBoundsAndMouseState()
|
405
|
+
},
|
406
|
+
handleTouchDown(handle, e) {
|
407
|
+
eventsFor = events.touch
|
393
408
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
409
|
+
this.handleDown(handle, e)
|
410
|
+
},
|
411
|
+
handleDown(handle, e) {
|
412
|
+
if (e instanceof MouseEvent && e.which !== 1) {
|
413
|
+
return
|
414
|
+
}
|
399
415
|
|
400
|
-
|
401
|
-
this.right = right
|
416
|
+
if (e.stopPropagation) e.stopPropagation()
|
402
417
|
|
403
|
-
|
404
|
-
|
405
|
-
},
|
406
|
-
handleResize(e) {
|
407
|
-
let left = this.left
|
408
|
-
let right = this.right
|
409
|
-
const bounds = this.bounds
|
410
|
-
const mouseClickPosition = this.mouseClickPosition
|
418
|
+
this.handle = handle
|
419
|
+
this.resizeEnable = true
|
411
420
|
|
412
|
-
|
413
|
-
|
421
|
+
const newPosition = {
|
422
|
+
...this.mouseClickPosition,
|
423
|
+
mouseX: e.touches ? e.touches[0].pageX : e.pageX,
|
424
|
+
left: this.left,
|
425
|
+
right: this.right,
|
426
|
+
}
|
414
427
|
|
415
|
-
|
416
|
-
this.
|
417
|
-
}
|
428
|
+
this.mouseClickPosition = newPosition
|
429
|
+
this.bounds = this.calcResizeLimits()
|
418
430
|
|
419
|
-
|
431
|
+
addEvent(document.documentElement, eventsFor.move, this.handleResize)
|
432
|
+
addEvent(document.documentElement, eventsFor.stop, this.handleUp)
|
433
|
+
},
|
434
|
+
calcResizeLimits() {
|
435
|
+
const limits = {
|
436
|
+
minLeft: null,
|
437
|
+
maxLeft: null,
|
438
|
+
minRight: null,
|
439
|
+
maxRight: null,
|
440
|
+
}
|
420
441
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
442
|
+
limits.minLeft = 0
|
443
|
+
limits.maxLeft = this.right - this.minWidthByPx
|
444
|
+
limits.minRight = this.left + this.minWidthByPx
|
445
|
+
limits.maxRight = this.parentWidth
|
446
|
+
|
447
|
+
return limits
|
448
|
+
},
|
449
|
+
move(e) {
|
450
|
+
if (this.resizing) {
|
451
|
+
this.handleResize(e)
|
452
|
+
} else if (this.dragEnable) {
|
453
|
+
this.handleDrag(e)
|
454
|
+
}
|
455
|
+
},
|
456
|
+
handleDrag(e) {
|
457
|
+
let left = this.left
|
458
|
+
let right = this.right
|
459
|
+
const bounds = this.bounds
|
460
|
+
const mouseClickPosition = this.mouseClickPosition
|
461
|
+
|
462
|
+
const tmpDeltaX =
|
463
|
+
mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
|
464
|
+
|
465
|
+
const deltaX = snapToGrid(
|
466
|
+
this.parentWidth / this.subStepCount,
|
467
|
+
tmpDeltaX
|
426
468
|
)
|
427
|
-
|
469
|
+
|
428
470
|
left = restrictToBounds(
|
429
471
|
mouseClickPosition.left - deltaX,
|
430
472
|
bounds.minLeft,
|
431
473
|
bounds.maxLeft
|
432
474
|
)
|
433
|
-
}
|
434
475
|
|
435
|
-
|
476
|
+
right = restrictToBounds(
|
477
|
+
mouseClickPosition.right - deltaX,
|
478
|
+
bounds.minRight,
|
479
|
+
bounds.maxRight
|
480
|
+
)
|
436
481
|
|
437
|
-
|
438
|
-
|
439
|
-
}
|
482
|
+
this.left = left
|
483
|
+
this.right = right
|
440
484
|
|
441
|
-
|
442
|
-
|
443
|
-
|
485
|
+
this.$emit('dragging', this.left, this.right)
|
486
|
+
this.dragging = true
|
487
|
+
},
|
488
|
+
handleResize(e) {
|
489
|
+
let left = this.left
|
490
|
+
let right = this.right
|
491
|
+
const bounds = this.bounds
|
492
|
+
const mouseClickPosition = this.mouseClickPosition
|
444
493
|
|
445
|
-
|
446
|
-
|
447
|
-
},
|
448
|
-
handleUp() {
|
449
|
-
this.handle = null
|
450
|
-
|
451
|
-
this.dragEnable = false
|
452
|
-
this.resizeEnable = false
|
453
|
-
|
454
|
-
if (this.resizing) {
|
455
|
-
this.resizing = false
|
456
|
-
this.$emit('resizeStop', {
|
457
|
-
min: this.roundToNearestStep(this.left),
|
458
|
-
max: this.roundToNearestStep(this.right)
|
459
|
-
})
|
460
|
-
}
|
494
|
+
const tmpDeltaX =
|
495
|
+
mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
|
461
496
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
min: this.roundToNearestStep(this.left),
|
466
|
-
max: this.roundToNearestStep(this.right)
|
467
|
-
})
|
468
|
-
}
|
497
|
+
if (!this.widthTouched && tmpDeltaX) {
|
498
|
+
this.widthTouched = true
|
499
|
+
}
|
469
500
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
const int = 1.0 / this.step
|
476
|
-
return (Math.round(val * int) / int).toFixed(2)
|
477
|
-
}
|
478
|
-
},
|
479
|
-
computed: {
|
480
|
-
style() {
|
481
|
-
return {
|
482
|
-
transform: `translate(${this.left}px, 0px)`,
|
483
|
-
width: this.computedWidth,
|
484
|
-
height: this.computedHeight,
|
485
|
-
zIndex: this.zIndex,
|
486
|
-
...(this.dragging && this.disableUserSelect
|
487
|
-
? userSelectNone
|
488
|
-
: userSelectAuto)
|
489
|
-
}
|
490
|
-
},
|
491
|
-
actualHandles() {
|
492
|
-
if (!this.resizable) return []
|
501
|
+
const deltaX = snapToGrid(
|
502
|
+
this.parentWidth / this.subStepCount,
|
503
|
+
tmpDeltaX
|
504
|
+
)
|
493
505
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
+
if (this.handle.includes('r')) {
|
507
|
+
right = restrictToBounds(
|
508
|
+
mouseClickPosition.right - deltaX,
|
509
|
+
bounds.minRight,
|
510
|
+
bounds.maxRight
|
511
|
+
)
|
512
|
+
} else if (this.handle.includes('l')) {
|
513
|
+
left = restrictToBounds(
|
514
|
+
mouseClickPosition.left - deltaX,
|
515
|
+
bounds.minLeft,
|
516
|
+
bounds.maxLeft
|
517
|
+
)
|
506
518
|
}
|
507
|
-
}
|
508
519
|
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
520
|
+
const width = computeWidth(left, right)
|
521
|
+
|
522
|
+
if (this.onResize(this.handle, left, width, this.height) === false) {
|
523
|
+
return
|
524
|
+
}
|
525
|
+
|
526
|
+
this.left = left
|
527
|
+
this.right = right
|
528
|
+
this.width = width
|
529
|
+
|
530
|
+
this.$emit('resizing', this.left, this.right)
|
531
|
+
this.resizing = true
|
532
|
+
},
|
533
|
+
handleUp() {
|
534
|
+
this.handle = null
|
535
|
+
|
536
|
+
this.dragEnable = false
|
537
|
+
this.resizeEnable = false
|
538
|
+
|
539
|
+
if (this.resizing) {
|
540
|
+
this.resizing = false
|
541
|
+
this.$emit('resizeStop', {
|
542
|
+
min: this.roundToNearestStep(this.left),
|
543
|
+
max: this.roundToNearestStep(this.right),
|
544
|
+
})
|
515
545
|
}
|
516
|
-
}
|
517
546
|
|
518
|
-
|
519
|
-
|
520
|
-
|
547
|
+
if (this.dragging) {
|
548
|
+
this.dragging = false
|
549
|
+
this.$emit('dragStop', {
|
550
|
+
min: this.roundToNearestStep(this.left),
|
551
|
+
max: this.roundToNearestStep(this.right),
|
552
|
+
})
|
553
|
+
}
|
521
554
|
|
522
|
-
|
523
|
-
|
524
|
-
|
555
|
+
removeEvent(document.documentElement, eventsFor.move, this.handleResize)
|
556
|
+
},
|
557
|
+
roundToNearestStep(value) {
|
558
|
+
const val = value / this.pxPerStep
|
525
559
|
|
526
|
-
|
527
|
-
|
528
|
-
}
|
529
|
-
this.$emit('deactivated')
|
530
|
-
}
|
560
|
+
const int = 1.0 / this.step
|
561
|
+
return (Math.round(val * int) / int).toFixed(2)
|
562
|
+
},
|
531
563
|
},
|
532
|
-
z(val) {
|
533
|
-
if (val >= 0 || val === 'auto') {
|
534
|
-
this.zIndex = val
|
535
|
-
}
|
536
|
-
}
|
537
564
|
}
|
538
|
-
}
|
539
565
|
</script>
|
540
566
|
<style scoped>
|
541
|
-
.vdr {
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
}
|
567
|
+
.vdr {
|
568
|
+
touch-action: none;
|
569
|
+
position: absolute;
|
570
|
+
box-sizing: border-box;
|
571
|
+
border: 1px dashed black;
|
572
|
+
}
|
547
573
|
</style>
|