wave-ui 2.30.0 → 2.31.3
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/README.md +3 -3
- package/dist/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +226 -170
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +13 -10
- package/src/wave-ui/components/w-confirm.vue +1 -1
- package/src/wave-ui/components/w-input.vue +111 -32
- package/src/wave-ui/components/w-menu.vue +24 -83
- package/src/wave-ui/components/w-notification-manager.vue +9 -2
- package/src/wave-ui/components/w-progress.vue +4 -1
- package/src/wave-ui/components/w-rating.vue +1 -1
- package/src/wave-ui/components/w-select.vue +1 -1
- package/src/wave-ui/components/w-spinner.vue +2 -2
- package/src/wave-ui/components/w-table.vue +2 -2
- package/src/wave-ui/components/w-tooltip.vue +22 -75
- package/src/wave-ui/core.js +0 -8
- package/src/wave-ui/mixins/detachable.js +134 -2
- package/src/wave-ui/scss/_mixins.scss +5 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.w-tooltip-wrap
|
|
3
|
-
slot(name="activator" :on="
|
|
3
|
+
slot(name="activator" :on="activatorEventHandlers")
|
|
4
4
|
transition(:name="transitionName" appear)
|
|
5
5
|
.w-tooltip(
|
|
6
6
|
v-if="detachableVisible"
|
|
@@ -41,21 +41,11 @@ export default {
|
|
|
41
41
|
round: { type: Boolean },
|
|
42
42
|
transition: { type: String },
|
|
43
43
|
tooltipClass: { type: [String, Object, Array] },
|
|
44
|
-
// Position.
|
|
45
|
-
detachTo: { type: [String, Boolean, Object], deprecated: true },
|
|
46
|
-
appendTo: { type: [String, Boolean, Object] },
|
|
47
|
-
fixed: { type: Boolean },
|
|
48
|
-
top: { type: Boolean },
|
|
49
|
-
bottom: { type: Boolean },
|
|
50
|
-
left: { type: Boolean },
|
|
51
|
-
right: { type: Boolean },
|
|
52
|
-
alignTop: { type: Boolean },
|
|
53
|
-
alignBottom: { type: Boolean },
|
|
54
|
-
alignLeft: { type: Boolean },
|
|
55
|
-
alignRight: { type: Boolean },
|
|
56
|
-
zIndex: { type: [Number, String, Boolean] },
|
|
57
44
|
persistent: { type: Boolean },
|
|
58
|
-
|
|
45
|
+
delay: { type: Number }
|
|
46
|
+
// Other props in the detachable mixin:
|
|
47
|
+
// detachTo, appendTo, fixed, top, bottom, left, right, alignTop, alignBottom, alignLeft,
|
|
48
|
+
// alignRight, noPosition, zIndex, activator.
|
|
59
49
|
},
|
|
60
50
|
|
|
61
51
|
emits: ['input', 'update:modelValue', 'open', 'close'],
|
|
@@ -63,12 +53,11 @@ export default {
|
|
|
63
53
|
data: () => ({
|
|
64
54
|
detachableVisible: false,
|
|
65
55
|
hoveringActivator: false,
|
|
66
|
-
// The
|
|
56
|
+
// The tooltip computed top & left coordinates.
|
|
67
57
|
detachableCoords: {
|
|
68
58
|
top: 0,
|
|
69
59
|
left: 0
|
|
70
60
|
},
|
|
71
|
-
activatorEl: null,
|
|
72
61
|
detachableEl: null,
|
|
73
62
|
timeoutId: null
|
|
74
63
|
}),
|
|
@@ -78,6 +67,9 @@ export default {
|
|
|
78
67
|
* Other computed in the detachable mixin:
|
|
79
68
|
* - `appendToTarget`
|
|
80
69
|
* - `detachableParentEl`
|
|
70
|
+
* - `activatorEl`
|
|
71
|
+
* - `position`
|
|
72
|
+
* - `alignment`
|
|
81
73
|
**/
|
|
82
74
|
|
|
83
75
|
tooltipClasses () {
|
|
@@ -89,26 +81,6 @@ export default {
|
|
|
89
81
|
return this.transition || `w-tooltip-slide-fade-${direction}`
|
|
90
82
|
},
|
|
91
83
|
|
|
92
|
-
position () {
|
|
93
|
-
return (
|
|
94
|
-
(this.top && 'top') ||
|
|
95
|
-
(this.bottom && 'bottom') ||
|
|
96
|
-
(this.left && 'left') ||
|
|
97
|
-
(this.right && 'right') ||
|
|
98
|
-
'bottom'
|
|
99
|
-
)
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
alignment () {
|
|
103
|
-
return (
|
|
104
|
-
(['top', 'bottom'].includes(this.position) && this.alignLeft && 'left') ||
|
|
105
|
-
(['top', 'bottom'].includes(this.position) && this.alignRight && 'right') ||
|
|
106
|
-
(['left', 'right'].includes(this.position) && this.alignTop && 'top') ||
|
|
107
|
-
(['left', 'right'].includes(this.position) && this.alignBottom && 'bottom') ||
|
|
108
|
-
''
|
|
109
|
-
)
|
|
110
|
-
},
|
|
111
|
-
|
|
112
84
|
classes () {
|
|
113
85
|
return {
|
|
114
86
|
[this.color]: this.color,
|
|
@@ -135,7 +107,7 @@ export default {
|
|
|
135
107
|
}
|
|
136
108
|
},
|
|
137
109
|
|
|
138
|
-
|
|
110
|
+
activatorEventHandlers () {
|
|
139
111
|
let handlers = {}
|
|
140
112
|
if (this.showOnClick) handlers = { click: this.toggle }
|
|
141
113
|
else {
|
|
@@ -181,19 +153,22 @@ export default {
|
|
|
181
153
|
else if (['mouseleave', 'blur'].includes(e.type) && !this.showOnClick) shouldShowTooltip = false
|
|
182
154
|
|
|
183
155
|
this.timeoutId = clearTimeout(this.timeoutId)
|
|
184
|
-
if (shouldShowTooltip)
|
|
185
|
-
this.$emit('update:modelValue', (this.detachableVisible = true))
|
|
186
|
-
this.$emit('input', true)
|
|
187
|
-
this.$emit('open')
|
|
188
|
-
|
|
189
|
-
this.open(e)
|
|
190
|
-
}
|
|
156
|
+
if (shouldShowTooltip) this.open(e)
|
|
191
157
|
else this.close()
|
|
192
158
|
},
|
|
193
159
|
|
|
194
160
|
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
195
161
|
async open (e) {
|
|
162
|
+
// A tiny delay may help positioning the detachable correctly in case of multiple activators
|
|
163
|
+
// with different menu contents.
|
|
164
|
+
if (this.delay) await new Promise(resolve => setTimeout(resolve, this.delay))
|
|
165
|
+
|
|
196
166
|
this.detachableVisible = true
|
|
167
|
+
|
|
168
|
+
// If the activator is external, there might be multiple,
|
|
169
|
+
// so on open, the activator will be set to the event target.
|
|
170
|
+
if (this.activator) this.activatorEl = e.target
|
|
171
|
+
|
|
197
172
|
await this.insertInDOM()
|
|
198
173
|
|
|
199
174
|
if (this.minWidth === 'activator') this.activatorWidth = this.activatorEl.offsetWidth
|
|
@@ -241,37 +216,9 @@ export default {
|
|
|
241
216
|
document.removeEventListener('mousedown', this.onOutsideMousedown)
|
|
242
217
|
window.removeEventListener('resize', this.onResize)
|
|
243
218
|
}
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
mounted () {
|
|
247
|
-
const wrapper = this.$el
|
|
248
|
-
this.activatorEl = wrapper.firstElementChild
|
|
249
|
-
|
|
250
|
-
// Unwrap the activator element.
|
|
251
|
-
wrapper.parentNode.insertBefore(this.activatorEl, wrapper)
|
|
252
|
-
|
|
253
|
-
if (this.modelValue) this.toggle({ type: 'click', target: this.activatorEl })
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
beforeUnmount () {
|
|
257
|
-
this.removeFromDOM()
|
|
258
|
-
|
|
259
|
-
if (this.activatorEl && this.activatorEl.parentNode) this.activatorEl.remove()
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
watch: {
|
|
263
|
-
modelValue (bool) {
|
|
264
|
-
if (bool !== this.detachableVisible) this.toggle({ type: 'click', target: this.activatorEl })
|
|
265
|
-
},
|
|
266
|
-
detachTo () {
|
|
267
|
-
this.removeFromDOM()
|
|
268
|
-
this.insertInDOM()
|
|
269
|
-
},
|
|
270
|
-
appendTo () {
|
|
271
|
-
this.removeFromDOM()
|
|
272
|
-
this.insertInDOM()
|
|
273
|
-
}
|
|
274
219
|
}
|
|
220
|
+
|
|
221
|
+
// watch, mounted & beforeDestroy hooks are set in the detachable.js mixin.
|
|
275
222
|
}
|
|
276
223
|
</script>
|
|
277
224
|
|
package/src/wave-ui/core.js
CHANGED
|
@@ -85,14 +85,6 @@ export default class WaveUI {
|
|
|
85
85
|
// Merge user options into the default config.
|
|
86
86
|
mergeConfig(options)
|
|
87
87
|
|
|
88
|
-
// @todo: remove this warning in version 1.40+.
|
|
89
|
-
if (config.disableColorShades) {
|
|
90
|
-
consoleWarn(
|
|
91
|
-
'WARNING - Since version 1.30 (Vue 2) & 2.17 (Vue 3), the option `disableColorShades` is replaced with `css.colorShades`.\n' +
|
|
92
|
-
'https://antoniandre.github.io/wave-ui/release-notes'
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
88
|
// Add color shades for each custom color given in options.
|
|
97
89
|
if (config.css.colorShades) {
|
|
98
90
|
config.colorShades = {}
|
|
@@ -7,6 +7,33 @@
|
|
|
7
7
|
import { consoleWarn } from '../utils/console'
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
|
+
props: {
|
|
11
|
+
// Position.
|
|
12
|
+
detachTo: { type: [String, Boolean, Object], deprecated: true },
|
|
13
|
+
appendTo: { type: [String, Boolean, Object] },
|
|
14
|
+
fixed: { type: Boolean },
|
|
15
|
+
top: { type: Boolean },
|
|
16
|
+
bottom: { type: Boolean },
|
|
17
|
+
left: { type: Boolean },
|
|
18
|
+
right: { type: Boolean },
|
|
19
|
+
alignTop: { type: Boolean },
|
|
20
|
+
alignBottom: { type: Boolean },
|
|
21
|
+
alignLeft: { type: Boolean },
|
|
22
|
+
alignRight: { type: Boolean },
|
|
23
|
+
noPosition: { type: Boolean },
|
|
24
|
+
zIndex: { type: [Number, String, Boolean] },
|
|
25
|
+
activator: { type: String } // Optionally designate an external activator.
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
data: () => ({
|
|
29
|
+
// The event listeners handlers have to be removed the exact same way they have been attached.
|
|
30
|
+
// Since the handler functions have variables that change after hot-reload, keep them exactly
|
|
31
|
+
// as is in an array so we can delete them on destroy.
|
|
32
|
+
// This only applies to the activatorEventHandlers, the other events listeners can be removed
|
|
33
|
+
// normally.
|
|
34
|
+
docAEventListenersHandlers: []
|
|
35
|
+
}),
|
|
36
|
+
|
|
10
37
|
computed: {
|
|
11
38
|
// DOM element to attach tooltip/menu to.
|
|
12
39
|
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
@@ -40,6 +67,40 @@ export default {
|
|
|
40
67
|
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
41
68
|
detachableParentEl () {
|
|
42
69
|
return this.appendToTarget
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
hasSeparateActivator () {
|
|
73
|
+
return !this.$slots.activator && typeof this.activator === 'string'
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
activatorEl: {
|
|
77
|
+
get () {
|
|
78
|
+
if (this.hasSeparateActivator) return document.querySelector(this.activator)
|
|
79
|
+
return this.$el.firstElementChild
|
|
80
|
+
},
|
|
81
|
+
set () {
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
position () {
|
|
87
|
+
return (
|
|
88
|
+
(this.top && 'top') ||
|
|
89
|
+
(this.bottom && 'bottom') ||
|
|
90
|
+
(this.left && 'left') ||
|
|
91
|
+
(this.right && 'right') ||
|
|
92
|
+
'bottom'
|
|
93
|
+
)
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
alignment () {
|
|
97
|
+
return (
|
|
98
|
+
(['top', 'bottom'].includes(this.position) && this.alignLeft && 'left') ||
|
|
99
|
+
(['top', 'bottom'].includes(this.position) && this.alignRight && 'right') ||
|
|
100
|
+
(['left', 'right'].includes(this.position) && this.alignTop && 'top') ||
|
|
101
|
+
(['left', 'right'].includes(this.position) && this.alignBottom && 'bottom') ||
|
|
102
|
+
''
|
|
103
|
+
)
|
|
43
104
|
}
|
|
44
105
|
},
|
|
45
106
|
|
|
@@ -176,14 +237,85 @@ export default {
|
|
|
176
237
|
|
|
177
238
|
// Move the tooltip/menu elsewhere in the DOM.
|
|
178
239
|
// wrapper.parentNode.insertBefore(this.detachableEl, wrapper)
|
|
179
|
-
this.appendToTarget.appendChild(this.detachableEl)
|
|
240
|
+
if (this.detachableEl) this.appendToTarget.appendChild(this.detachableEl)
|
|
180
241
|
resolve()
|
|
181
242
|
})
|
|
182
243
|
})
|
|
183
244
|
},
|
|
184
245
|
|
|
185
246
|
removeFromDOM () {
|
|
186
|
-
|
|
247
|
+
document.removeEventListener('mousedown', this.onOutsideMousedown)
|
|
248
|
+
window.removeEventListener('resize', this.onResize)
|
|
249
|
+
if (this.detachableEl && this.detachableEl.parentNode) {
|
|
250
|
+
this.detachableVisible = false
|
|
251
|
+
this.detachableEl.remove()
|
|
252
|
+
this.detachableEl = null
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
mounted () {
|
|
258
|
+
const wrapper = this.$el
|
|
259
|
+
|
|
260
|
+
// Unwrap the activator element if the activator is in the activator slot.
|
|
261
|
+
if (this.$slots.activator) wrapper.parentNode.insertBefore(this.activatorEl, wrapper)
|
|
262
|
+
|
|
263
|
+
// If the activator is external, add event listeners to the document and check the target is
|
|
264
|
+
// the activator when toggling.
|
|
265
|
+
// This way, the activator can be a future DOM element, that is not yet in the DOM.
|
|
266
|
+
else if (this.activator) {
|
|
267
|
+
Object.entries(this.activatorEventHandlers).forEach(([eventName, handler]) => {
|
|
268
|
+
// Convert mouseenter to mouseover & mouseleave to mouseout because we are attaching
|
|
269
|
+
// event to the document, so it can accept future nodes.
|
|
270
|
+
eventName = eventName.replace('mouseenter', 'mouseover').replace('mouseleave', 'mouseout')
|
|
271
|
+
const handlerWrap = e => {
|
|
272
|
+
if (e.target?.matches && e.target.matches(this.activator)) handler(e)
|
|
273
|
+
}
|
|
274
|
+
document.addEventListener(eventName, handlerWrap)
|
|
275
|
+
// The event listeners handlers have to be removed the exact same way they have been attached.
|
|
276
|
+
// Since the handler functions have variables that change after hot-reload, keep them exactly
|
|
277
|
+
// as is in an array so we can delete them on destroy.
|
|
278
|
+
this.docAEventListenersHandlers.push({ eventName, handler: handlerWrap })
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Unwrap the overlay if any.
|
|
283
|
+
if (this.overlay) {
|
|
284
|
+
this.overlayEl = this.$refs.overlay?.$el
|
|
285
|
+
wrapper.parentNode.insertBefore(this.overlayEl, wrapper)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (this.modelValue) this.toggleMenu({ type: 'click', target: this.activatorEl })
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
beforeUnmount () {
|
|
292
|
+
this.close()
|
|
293
|
+
|
|
294
|
+
this.removeFromDOM()
|
|
295
|
+
|
|
296
|
+
// Remove the event listeners the exact same way they have been defined.
|
|
297
|
+
// Fixes issues on hot-reloading.
|
|
298
|
+
if (this.docAEventListenersHandlers.length) {
|
|
299
|
+
this.docAEventListenersHandlers.forEach(({ eventName, handler }) => {
|
|
300
|
+
document.removeEventListener(eventName, handler)
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (this.overlay && this.overlayEl.parentNode) this.overlayEl.remove()
|
|
305
|
+
if (this.activatorEl?.parentNode && this.$slots.activator) this.activatorEl.remove()
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
watch: {
|
|
309
|
+
modelValue (bool) {
|
|
310
|
+
if (!!bool !== this.detachableVisible) this.toggle({ type: 'click', target: this.activatorEl })
|
|
311
|
+
},
|
|
312
|
+
detachTo () {
|
|
313
|
+
this.removeFromDOM()
|
|
314
|
+
this.insertInDOM()
|
|
315
|
+
},
|
|
316
|
+
appendTo () {
|
|
317
|
+
this.removeFromDOM()
|
|
318
|
+
this.insertInDOM()
|
|
187
319
|
}
|
|
188
320
|
}
|
|
189
321
|
}
|
|
@@ -6,14 +6,11 @@
|
|
|
6
6
|
transition: $duration $delay cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @param $size: the triangle size at the base.
|
|
15
|
-
* @param $thickness: the border thickness, 0 to remove the border.
|
|
16
|
-
*/
|
|
9
|
+
// Generates a triangle arrow on the edge of an element.
|
|
10
|
+
// @param $color: the color to apply to the triangle.
|
|
11
|
+
// @param $selector: the element selector that receives the modifiers (--top, --left, etc.).
|
|
12
|
+
// @param $size: the triangle size at the base.
|
|
13
|
+
// @param $thickness: the border thickness, 0 to remove the border.
|
|
17
14
|
@mixin triangle($color: white, $selector: '', $size: 7px, $thickness: 1px) {
|
|
18
15
|
@if ($thickness > 0) {
|
|
19
16
|
// The underneath border triangle.
|