wave-ui 1.45.10 → 1.45.14
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
|
@@ -287,9 +287,10 @@ export default {
|
|
|
287
287
|
|
|
288
288
|
mounted () {
|
|
289
289
|
// On page load, check if the field is autofilled by the browser.
|
|
290
|
+
// 20211229. Only a problem on Chrome. Firefox ok, Safari always prompts before filling up.
|
|
290
291
|
setTimeout(() => {
|
|
291
|
-
if (this.$refs.input.
|
|
292
|
-
},
|
|
292
|
+
if (this.$refs.input.matches(':-webkit-autofill')) this.isAutofilled = true
|
|
293
|
+
}, 400) // Can't be less than 350: time for the browser to autofill.
|
|
293
294
|
},
|
|
294
295
|
|
|
295
296
|
watch: {
|
|
@@ -117,25 +117,29 @@ export default {
|
|
|
117
117
|
},
|
|
118
118
|
|
|
119
119
|
// DOM element to attach menu to.
|
|
120
|
+
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
120
121
|
detachToTarget () {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
const defaultTarget = '.w-app'
|
|
123
|
+
|
|
124
|
+
let target = this.detachTo || defaultTarget
|
|
125
|
+
if (target === true) target = defaultTarget
|
|
126
|
+
else if (target && !['object', 'string'].includes(typeof target)) target = defaultTarget
|
|
124
127
|
else if (typeof target === 'object' && !target.nodeType) {
|
|
125
|
-
target =
|
|
128
|
+
target = defaultTarget
|
|
126
129
|
consoleWarn('Invalid node provided in w-menu `detach-to`. Falling back to .w-app.', this)
|
|
127
130
|
}
|
|
128
131
|
if (typeof target === 'string') target = document.querySelector(target)
|
|
129
132
|
|
|
130
133
|
if (!target) {
|
|
131
|
-
consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` :
|
|
132
|
-
target = document.querySelector(
|
|
134
|
+
consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : defaultTarget}`, this)
|
|
135
|
+
target = document.querySelector(defaultTarget)
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
return target
|
|
136
139
|
},
|
|
137
140
|
|
|
138
141
|
// DOM element that will receive the menu.
|
|
142
|
+
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
139
143
|
menuParentEl () {
|
|
140
144
|
return this.detachToTarget
|
|
141
145
|
},
|
|
@@ -227,8 +231,10 @@ export default {
|
|
|
227
231
|
}, 10)
|
|
228
232
|
}
|
|
229
233
|
}
|
|
230
|
-
|
|
231
|
-
if ('ontouchstart' in window)
|
|
234
|
+
// Check the window exists: SSR-proof.
|
|
235
|
+
if (typeof window !== 'undefined' && 'ontouchstart' in window) {
|
|
236
|
+
handlers.click = this.toggleMenu
|
|
237
|
+
}
|
|
232
238
|
}
|
|
233
239
|
else handlers = { click: this.toggleMenu }
|
|
234
240
|
return handlers
|
|
@@ -236,6 +242,7 @@ export default {
|
|
|
236
242
|
},
|
|
237
243
|
|
|
238
244
|
methods: {
|
|
245
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
239
246
|
toggleMenu (e) {
|
|
240
247
|
let shouldShowMenu = this.menuVisible
|
|
241
248
|
if ('ontouchstart' in window && this.showOnHover && e.type === 'click') {
|
|
@@ -263,6 +270,7 @@ export default {
|
|
|
263
270
|
else this.closeMenu()
|
|
264
271
|
},
|
|
265
272
|
|
|
273
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
266
274
|
async openMenu (e) {
|
|
267
275
|
this.menuVisible = true
|
|
268
276
|
await this.insertMenu()
|
|
@@ -289,6 +297,7 @@ export default {
|
|
|
289
297
|
* - click of activator
|
|
290
298
|
* - hover outside if showOnHover
|
|
291
299
|
* - click inside menu if hideOnMenuClick.
|
|
300
|
+
* / ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
292
301
|
*
|
|
293
302
|
* @param {Boolean} force when showOnHover is set to true, hovering menu should keep it open.
|
|
294
303
|
* But if hideOnMenuClick is also set to true, this should force close
|
|
@@ -312,6 +321,7 @@ export default {
|
|
|
312
321
|
window.removeEventListener('resize', this.onResize)
|
|
313
322
|
},
|
|
314
323
|
|
|
324
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
315
325
|
onOutsideMousedown (e) {
|
|
316
326
|
if (!this.menuEl.contains(e.target) && !this.activatorEl.contains(e.target)) {
|
|
317
327
|
this.$emit('update:modelValue', (this.menuVisible = false))
|
|
@@ -327,6 +337,7 @@ export default {
|
|
|
327
337
|
this.computeMenuPosition()
|
|
328
338
|
},
|
|
329
339
|
|
|
340
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
330
341
|
getCoordinates (e) {
|
|
331
342
|
// Get the activator coordinates relative to window.
|
|
332
343
|
const { top, left, width, height } = (e ? e.target : this.activatorEl).getBoundingClientRect()
|
|
@@ -346,6 +357,7 @@ export default {
|
|
|
346
357
|
return coords
|
|
347
358
|
},
|
|
348
359
|
|
|
360
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
349
361
|
computeMenuPosition (e) {
|
|
350
362
|
// Get the activator coordinates.
|
|
351
363
|
let { top, left, width, height } = this.getCoordinates(e)
|
|
@@ -71,25 +71,30 @@ export default {
|
|
|
71
71
|
return this.transition || `w-tooltip-slide-fade-${direction}`
|
|
72
72
|
},
|
|
73
73
|
|
|
74
|
+
// DOM element to attach tooltip to.
|
|
75
|
+
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
74
76
|
detachToTarget () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
const defaultTarget = '.w-app'
|
|
78
|
+
|
|
79
|
+
let target = this.detachTo || defaultTarget
|
|
80
|
+
if (target === true) target = defaultTarget
|
|
81
|
+
else if (target && !['object', 'string'].includes(typeof target)) target = defaultTarget
|
|
78
82
|
else if (typeof target === 'object' && !target.nodeType) {
|
|
79
|
-
target =
|
|
83
|
+
target = defaultTarget
|
|
80
84
|
consoleWarn('Invalid node provided in w-tooltip `attach-to`. Falling back to .w-app.', this)
|
|
81
85
|
}
|
|
82
86
|
if (typeof target === 'string') target = document.querySelector(target)
|
|
83
87
|
|
|
84
88
|
if (!target) {
|
|
85
|
-
consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` :
|
|
86
|
-
target = document.querySelector(
|
|
89
|
+
consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : defaultTarget}`, this)
|
|
90
|
+
target = document.querySelector(defaultTarget)
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
return target
|
|
90
94
|
},
|
|
91
95
|
|
|
92
96
|
// DOM element that will receive the tooltip.
|
|
97
|
+
// ! \ This computed uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
93
98
|
tooltipParentEl () {
|
|
94
99
|
return this.detachTo ? this.detachToTarget : this.$el
|
|
95
100
|
},
|
|
@@ -171,16 +176,18 @@ export default {
|
|
|
171
176
|
mouseleave: this.toggle
|
|
172
177
|
}
|
|
173
178
|
|
|
174
|
-
|
|
179
|
+
// Check the window exists: SSR-proof.
|
|
180
|
+
if (typeof window !== 'undefined' && 'ontouchstart' in window) handlers.click = this.toggle
|
|
175
181
|
}
|
|
176
182
|
return handlers
|
|
177
183
|
}
|
|
178
184
|
},
|
|
179
185
|
|
|
180
186
|
methods: {
|
|
187
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
181
188
|
toggle (e) {
|
|
182
189
|
let shouldShowTooltip = this.showTooltip
|
|
183
|
-
if ('ontouchstart' in window) {
|
|
190
|
+
if (typeof window !== 'undefined' && 'ontouchstart' in window) {
|
|
184
191
|
if (e.type === 'click') shouldShowTooltip = !shouldShowTooltip
|
|
185
192
|
}
|
|
186
193
|
else if (e.type === 'click' && this.showOnClick) shouldShowTooltip = !shouldShowTooltip
|
|
@@ -208,6 +215,7 @@ export default {
|
|
|
208
215
|
}
|
|
209
216
|
},
|
|
210
217
|
|
|
218
|
+
// ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
|
|
211
219
|
getCoordinates () {
|
|
212
220
|
const { top, left, width, height } = this.activatorEl.getBoundingClientRect()
|
|
213
221
|
let coords = { top, left, width, height }
|