@eturnity/eturnity_reusable_components 7.24.3-EPDM-10576.1 → 7.24.3-EPDM-11320.0

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