wave-ui 3.6.1 → 3.7.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.
- package/dist/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.es.js +1250 -1237
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +1 -1
- package/src/wave-ui/components/w-checkbox.vue +3 -2
- package/src/wave-ui/components/w-checkboxes.vue +4 -1
- package/src/wave-ui/components/w-menu.vue +11 -0
- package/src/wave-ui/components/w-select.vue +2 -1
- package/src/wave-ui/mixins/detachable.js +23 -5
- package/src/wave-ui/utils/dynamic-css.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wave-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "An emerging UI framework for Vue.js (2 & 3) with only the bright side. :sunny:",
|
|
5
5
|
"author": "Antoni Andre <antoniandre.web@gmail.com>",
|
|
6
6
|
"homepage": "https://antoniandre.github.io/wave-ui",
|
|
@@ -112,8 +112,9 @@ export default {
|
|
|
112
112
|
methods: {
|
|
113
113
|
onInput () {
|
|
114
114
|
this.isChecked = !this.isChecked
|
|
115
|
-
this
|
|
116
|
-
this.$emit('
|
|
115
|
+
const returnValue = this.isChecked && this.returnValue !== undefined ? this.returnValue : this.isChecked
|
|
116
|
+
this.$emit('update:modelValue', returnValue)
|
|
117
|
+
this.$emit('input', returnValue)
|
|
117
118
|
|
|
118
119
|
if (!this.noRipple) {
|
|
119
120
|
if (this.isChecked) {
|
|
@@ -40,6 +40,9 @@ export default {
|
|
|
40
40
|
props: {
|
|
41
41
|
items: { type: Array, required: true }, // All the possible options.
|
|
42
42
|
modelValue: { type: Array }, // v-model on selected option.
|
|
43
|
+
// If true, the returnValue set on each w-checkboxes item will be returned once the checkbox is
|
|
44
|
+
// checked. If false & by default, the return value of the w-checkboxes is an array of booleans.
|
|
45
|
+
returnValues: { type: Boolean },
|
|
43
46
|
labelOnLeft: { type: Boolean },
|
|
44
47
|
itemLabelKey: { type: String, default: 'label' },
|
|
45
48
|
itemValueKey: { type: String, default: 'value' },
|
|
@@ -94,7 +97,7 @@ export default {
|
|
|
94
97
|
|
|
95
98
|
toggleCheck (checkbox, isChecked) {
|
|
96
99
|
checkbox._isChecked = isChecked
|
|
97
|
-
const selection = this.checkboxItems.filter(item => item._isChecked).map(item => item.value)
|
|
100
|
+
const selection = this.checkboxItems.filter(item => item._isChecked).map(item => this.returnValues ? item.returnValue : item.value)
|
|
98
101
|
|
|
99
102
|
this.$emit('update:modelValue', selection)
|
|
100
103
|
this.$emit('input', selection)
|
|
@@ -69,6 +69,7 @@ export default {
|
|
|
69
69
|
contentClass: { type: [String, Object, Array] },
|
|
70
70
|
arrow: { type: Boolean }, // The small triangle pointing toward the activator.
|
|
71
71
|
minWidth: { type: [Number, String] }, // can be like: `40`, `5em`, `activator`.
|
|
72
|
+
maxWidth: { type: [Number, String] }, // can be like: `40`, `5em`, `activator`.
|
|
72
73
|
overlay: { type: Boolean },
|
|
73
74
|
overlayClass: { type: [String, Object, Array] },
|
|
74
75
|
overlayProps: { type: Object }, // Allow passing down an object of props to the w-overlay component.
|
|
@@ -124,6 +125,11 @@ export default {
|
|
|
124
125
|
else return isNaN(this.minWidth) ? this.minWidth : (this.minWidth ? `${this.minWidth}px` : 0)
|
|
125
126
|
},
|
|
126
127
|
|
|
128
|
+
menuMaxWidth () {
|
|
129
|
+
if (this.maxWidth === 'activator') return this.activatorWidth ? `${this.activatorWidth}px` : 0
|
|
130
|
+
else return isNaN(this.maxWidth) ? this.maxWidth : (this.maxWidth ? `${this.maxWidth}px` : 0)
|
|
131
|
+
},
|
|
132
|
+
|
|
127
133
|
menuClasses () {
|
|
128
134
|
return objectifyClasses(this.menuClass)
|
|
129
135
|
},
|
|
@@ -168,6 +174,7 @@ export default {
|
|
|
168
174
|
top: (this.detachableCoords.top && `${~~this.detachableCoords.top}px`) || null,
|
|
169
175
|
left: (this.detachableCoords.left && `${~~this.detachableCoords.left}px`) || null,
|
|
170
176
|
minWidth: (this.minWidth && this.menuMinWidth) || null,
|
|
177
|
+
maxWidth: (this.maxWidth && this.menuMaxWidth) || null,
|
|
171
178
|
'--w-menu-bg-color': this.arrow && (this.$waveui.colors[this.bgColor] || 'rgb(var(--w-base-bg-color-rgb))')
|
|
172
179
|
}
|
|
173
180
|
},
|
|
@@ -248,6 +255,10 @@ export default {
|
|
|
248
255
|
* even while hovering the menu.
|
|
249
256
|
*/
|
|
250
257
|
async close (force = false) {
|
|
258
|
+
// The user may open and close the detachable so fast (like when toggling on hover) that it
|
|
259
|
+
// should not show up at all. This cancels the opening timer (if there is a set delay prop).
|
|
260
|
+
this.openTimeout = clearTimeout(this.openTimeout)
|
|
261
|
+
|
|
251
262
|
// Might be already closed.
|
|
252
263
|
// E.g. showOnHover & hideOnMenuClick: on click, force hide then mouseleave is also firing.
|
|
253
264
|
if (!this.detachableVisible) return
|
|
@@ -16,7 +16,7 @@ component(
|
|
|
16
16
|
|
|
17
17
|
w-menu(
|
|
18
18
|
v-model="showMenu"
|
|
19
|
-
@close="
|
|
19
|
+
@close="closeMenu"
|
|
20
20
|
:menu-class="`w-select__menu ${menuClass || ''}`"
|
|
21
21
|
transition="slide-fade-down"
|
|
22
22
|
:append-to="(menuProps || {}).appendTo !== undefined ? (menuProps || {}).appendTo : undefined"
|
|
@@ -27,6 +27,7 @@ component(
|
|
|
27
27
|
template(#activator="{ on }")
|
|
28
28
|
//- Input wrapper.
|
|
29
29
|
.w-select__selection-wrap(
|
|
30
|
+
v-on="on"
|
|
30
31
|
@click="!isDisabled && !isReadonly && onInputFieldClick()"
|
|
31
32
|
role="button"
|
|
32
33
|
aria-haspopup="listbox"
|
|
@@ -22,7 +22,8 @@ export default {
|
|
|
22
22
|
noPosition: { type: Boolean },
|
|
23
23
|
zIndex: { type: [Number, String, Boolean] },
|
|
24
24
|
// Optionally designate an external activator.
|
|
25
|
-
|
|
25
|
+
// The activator can be a DOM string selector, a ref or a DOM node.
|
|
26
|
+
activator: { type: [String, Object] }
|
|
26
27
|
},
|
|
27
28
|
|
|
28
29
|
inject: {
|
|
@@ -35,7 +36,11 @@ export default {
|
|
|
35
36
|
// as is in an array so we can delete them on destroy.
|
|
36
37
|
// This only applies to the activatorEventHandlers, the other events listeners can be removed
|
|
37
38
|
// normally.
|
|
38
|
-
docEventListenersHandlers: []
|
|
39
|
+
docEventListenersHandlers: [],
|
|
40
|
+
// The user may open and close the detachable so fast (like when toggling on hover) that it
|
|
41
|
+
// should not show up at all. Keep the ability to cancel the opening timer (if there is a set
|
|
42
|
+
// delay prop).
|
|
43
|
+
openTimeout: null
|
|
39
44
|
}),
|
|
40
45
|
|
|
41
46
|
computed: {
|
|
@@ -111,6 +116,13 @@ export default {
|
|
|
111
116
|
(['left', 'right'].includes(this.position) && this.alignBottom && 'bottom') ||
|
|
112
117
|
''
|
|
113
118
|
)
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
shouldShowOnClick () {
|
|
122
|
+
// For props simplicity, the w-tooltip component has the `showOnHover` prop,
|
|
123
|
+
// whereas the w-menu has `showOnClick`.
|
|
124
|
+
return (this.$options.props.showOnHover && !this.showOnHover) ||
|
|
125
|
+
(this.$options.props.showOnClick && this.showOnClick)
|
|
114
126
|
}
|
|
115
127
|
},
|
|
116
128
|
|
|
@@ -119,7 +131,10 @@ export default {
|
|
|
119
131
|
async open (e) {
|
|
120
132
|
// A tiny delay may help positioning the detachable correctly in case of multiple activators
|
|
121
133
|
// with different menu contents.
|
|
122
|
-
if (this.delay) await new Promise(resolve => setTimeout(resolve, this.delay))
|
|
134
|
+
if (this.delay) await new Promise(resolve => (this.openTimeout = setTimeout(resolve, this.delay)))
|
|
135
|
+
|
|
136
|
+
// Cancel opening if the timeout has been cancelled by blur event (when going fast).
|
|
137
|
+
if (this.delay && !this.openTimeout) return
|
|
123
138
|
|
|
124
139
|
this.detachableVisible = true
|
|
125
140
|
|
|
@@ -339,7 +354,7 @@ export default {
|
|
|
339
354
|
if (this.overlay) this.overlayEl = this.$refs.overlay?.$el
|
|
340
355
|
|
|
341
356
|
if (this.modelValue && this.activator) {
|
|
342
|
-
this.toggle({ type: this.
|
|
357
|
+
this.toggle({ type: this.shouldShowOnClick ? 'click' : 'mouseenter', target: this.activatorEl })
|
|
343
358
|
}
|
|
344
359
|
else if (this.modelValue) this.open({ target: this.activatorEl })
|
|
345
360
|
},
|
|
@@ -360,7 +375,10 @@ export default {
|
|
|
360
375
|
|
|
361
376
|
watch: {
|
|
362
377
|
modelValue (bool) {
|
|
363
|
-
if (!!bool !== this.detachableVisible)
|
|
378
|
+
if (!!bool !== this.detachableVisible) {
|
|
379
|
+
if (bool) this.open({ target: this.activatorEl })
|
|
380
|
+
else this.close()
|
|
381
|
+
}
|
|
364
382
|
},
|
|
365
383
|
appendTo () {
|
|
366
384
|
this.removeFromDOM()
|
|
@@ -159,6 +159,7 @@ const genBreakpointLayoutClasses = breakpoints => {
|
|
|
159
159
|
'text-nowrap{white-space:nowrap}',
|
|
160
160
|
'row{flex-direction:row}',
|
|
161
161
|
'column{flex-direction:column}',
|
|
162
|
+
'column-reverse{flex-direction:column-reverse}',
|
|
162
163
|
'grow{flex-grow:1;flex-basis:auto}',
|
|
163
164
|
'no-grow{flex-grow:0}',
|
|
164
165
|
'shrink{flex-shrink:1;margin-left:auto;margin-right:auto}',
|