@vaadin/menu-bar 23.1.0-alpha3 → 23.1.0-beta2
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 +9 -9
- package/src/vaadin-menu-bar-button.js +1 -1
- package/src/vaadin-menu-bar-buttons-mixin.d.ts +1 -1
- package/src/vaadin-menu-bar-buttons-mixin.js +29 -15
- package/src/vaadin-menu-bar-interactions-mixin.d.ts +1 -1
- package/src/vaadin-menu-bar-interactions-mixin.js +16 -12
- package/src/vaadin-menu-bar-submenu.js +1 -1
- package/src/vaadin-menu-bar.d.ts +2 -2
- package/src/vaadin-menu-bar.js +5 -5
- package/theme/lumo/vaadin-menu-bar-button-styles.js +1 -1
- package/theme/lumo/vaadin-menu-bar-item-styles.js +1 -1
- package/theme/lumo/vaadin-menu-bar-overlay-styles.js +1 -1
- package/theme/material/vaadin-menu-bar-button-styles.js +1 -1
- package/theme/material/vaadin-menu-bar-item-styles.js +1 -1
- package/theme/material/vaadin-menu-bar-overlay-styles.js +1 -1
- package/theme/material/vaadin-menu-bar-styles.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
37
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/button": "23.1.0-
|
|
39
|
-
"@vaadin/component-base": "23.1.0-
|
|
40
|
-
"@vaadin/vaadin-context-menu": "23.1.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
38
|
+
"@vaadin/button": "23.1.0-beta2",
|
|
39
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
40
|
+
"@vaadin/vaadin-context-menu": "23.1.0-beta2",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@esm-bundle/chai": "^4.3.4",
|
|
47
|
-
"@vaadin/icon": "23.1.0-
|
|
47
|
+
"@vaadin/icon": "23.1.0-beta2",
|
|
48
48
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
49
49
|
"sinon": "^13.0.2"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
52
52
|
}
|
|
@@ -7,7 +7,7 @@ import { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
7
7
|
import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
8
8
|
|
|
9
9
|
export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(
|
|
10
|
-
base: T
|
|
10
|
+
base: T,
|
|
11
11
|
): T & Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass>;
|
|
12
12
|
|
|
13
13
|
export declare class ButtonsMixinClass {
|
|
@@ -19,8 +19,8 @@ export const ButtonsMixin = (superClass) =>
|
|
|
19
19
|
*/
|
|
20
20
|
_hasOverflow: {
|
|
21
21
|
type: Boolean,
|
|
22
|
-
value: false
|
|
23
|
-
}
|
|
22
|
+
value: false,
|
|
23
|
+
},
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -28,6 +28,16 @@ export const ButtonsMixin = (superClass) =>
|
|
|
28
28
|
return ['_menuItemsChanged(items, items.splices)'];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Override getter from `ResizeMixin` to observe parent.
|
|
33
|
+
*
|
|
34
|
+
* @protected
|
|
35
|
+
* @override
|
|
36
|
+
*/
|
|
37
|
+
get _observeParent() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
/** @protected */
|
|
32
42
|
ready() {
|
|
33
43
|
super.ready();
|
|
@@ -88,15 +98,20 @@ export const ButtonsMixin = (superClass) =>
|
|
|
88
98
|
btn.style.visibility = '';
|
|
89
99
|
btn.style.position = '';
|
|
90
100
|
|
|
91
|
-
//
|
|
101
|
+
// Teleport item component back from "overflow" sub-menu
|
|
92
102
|
const item = btn.item && btn.item.component;
|
|
93
103
|
if (item instanceof HTMLElement && item.classList.contains('vaadin-menu-item')) {
|
|
94
104
|
btn.appendChild(item);
|
|
95
105
|
item.classList.remove('vaadin-menu-item');
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
|
-
this.
|
|
99
|
-
|
|
108
|
+
this.__updateOverflow([]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @private */
|
|
112
|
+
__updateOverflow(items) {
|
|
113
|
+
this._overflow.item = { children: items };
|
|
114
|
+
this._hasOverflow = items.length > 0;
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
/** @private */
|
|
@@ -113,7 +128,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
113
128
|
const btn = buttons[i - 1];
|
|
114
129
|
const btnStyle = getComputedStyle(btn);
|
|
115
130
|
|
|
116
|
-
//
|
|
131
|
+
// If this button isn't overflowing, then the rest aren't either
|
|
117
132
|
if (
|
|
118
133
|
(!isRTL && btn.offsetLeft + btn.offsetWidth < container.offsetWidth - overflow.offsetWidth) ||
|
|
119
134
|
(isRTL && btn.offsetLeft >= overflow.offsetWidth)
|
|
@@ -124,12 +139,11 @@ export const ButtonsMixin = (superClass) =>
|
|
|
124
139
|
btn.disabled = true;
|
|
125
140
|
btn.style.visibility = 'hidden';
|
|
126
141
|
btn.style.position = 'absolute';
|
|
127
|
-
//
|
|
142
|
+
// Save width for buttons with component
|
|
128
143
|
btn.style.width = btnStyle.width;
|
|
129
144
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
145
|
+
const items = buttons.filter((_, idx) => idx >= i).map((b) => b.item);
|
|
146
|
+
this.__updateOverflow(items);
|
|
133
147
|
}
|
|
134
148
|
}
|
|
135
149
|
|
|
@@ -139,10 +153,10 @@ export const ButtonsMixin = (superClass) =>
|
|
|
139
153
|
const buttons = this._buttons.filter((btn) => btn !== overflow);
|
|
140
154
|
const oldOverflowCount = this.__getOverflowCount(overflow);
|
|
141
155
|
|
|
142
|
-
//
|
|
156
|
+
// Reset all buttons in the menu bar and the overflow button
|
|
143
157
|
this.__restoreButtons(buttons);
|
|
144
158
|
|
|
145
|
-
//
|
|
159
|
+
// Hide any overflowing buttons and put them in the 'overflow' button
|
|
146
160
|
this.__setOverflowItems(buttons, overflow);
|
|
147
161
|
|
|
148
162
|
const newOverflowCount = this.__getOverflowCount(overflow);
|
|
@@ -171,7 +185,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
171
185
|
if (item.component) {
|
|
172
186
|
const component = this.__getComponent(itemCopy);
|
|
173
187
|
itemCopy.component = component;
|
|
174
|
-
//
|
|
188
|
+
// Save item for overflow menu
|
|
175
189
|
component.item = itemCopy;
|
|
176
190
|
button.appendChild(component);
|
|
177
191
|
} else if (item.text) {
|
|
@@ -201,7 +215,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
201
215
|
_setButtonTheme(btn, hostTheme) {
|
|
202
216
|
let theme = hostTheme;
|
|
203
217
|
|
|
204
|
-
//
|
|
218
|
+
// Item theme takes precedence over host theme even if it's empty, as long as it's not undefined or null
|
|
205
219
|
const itemTheme = btn.item && btn.item.theme;
|
|
206
220
|
if (itemTheme != null) {
|
|
207
221
|
theme = Array.isArray(itemTheme) ? itemTheme.join(' ') : itemTheme;
|
|
@@ -225,7 +239,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
225
239
|
let component;
|
|
226
240
|
|
|
227
241
|
const isElement = itemComponent instanceof HTMLElement;
|
|
228
|
-
//
|
|
242
|
+
// Use existing item component, if any
|
|
229
243
|
if (isElement && itemComponent.localName === 'vaadin-context-menu-item') {
|
|
230
244
|
component = itemComponent;
|
|
231
245
|
} else {
|
|
@@ -16,8 +16,8 @@ export const InteractionsMixin = (superClass) =>
|
|
|
16
16
|
* @attr {boolean} open-on-hover
|
|
17
17
|
*/
|
|
18
18
|
openOnHover: {
|
|
19
|
-
type: Boolean
|
|
20
|
-
}
|
|
19
|
+
type: Boolean,
|
|
20
|
+
},
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -160,7 +160,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
160
160
|
idx = buttons.length - 1;
|
|
161
161
|
break;
|
|
162
162
|
default:
|
|
163
|
-
//
|
|
163
|
+
// Do nothing.
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
idx = this._getAvailableIndex(idx, increment, buttons);
|
|
@@ -214,14 +214,14 @@ export const InteractionsMixin = (superClass) =>
|
|
|
214
214
|
const overlay = e.target;
|
|
215
215
|
const { width, height, left } = this._expandedButton.getBoundingClientRect();
|
|
216
216
|
if (overlay.hasAttribute('bottom-aligned')) {
|
|
217
|
-
overlay.style.bottom = parseInt(getComputedStyle(overlay).bottom) + height
|
|
217
|
+
overlay.style.bottom = `${parseInt(getComputedStyle(overlay).bottom) + height}px`;
|
|
218
218
|
}
|
|
219
219
|
const endAligned = overlay.hasAttribute('end-aligned');
|
|
220
220
|
if (endAligned) {
|
|
221
221
|
if (this.__isRTL) {
|
|
222
|
-
overlay.style.left = left
|
|
222
|
+
overlay.style.left = `${left}px`;
|
|
223
223
|
} else {
|
|
224
|
-
overlay.style.right = parseInt(getComputedStyle(overlay).right) - width
|
|
224
|
+
overlay.style.right = `${parseInt(getComputedStyle(overlay).right) - width}px`;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -315,9 +315,9 @@ export const InteractionsMixin = (superClass) =>
|
|
|
315
315
|
button.dispatchEvent(
|
|
316
316
|
new CustomEvent('opensubmenu', {
|
|
317
317
|
detail: {
|
|
318
|
-
children: items
|
|
319
|
-
}
|
|
320
|
-
})
|
|
318
|
+
children: items,
|
|
319
|
+
},
|
|
320
|
+
}),
|
|
321
321
|
);
|
|
322
322
|
|
|
323
323
|
this._setExpanded(button, true);
|
|
@@ -334,7 +334,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
this.__onceOpened(() => {
|
|
337
|
-
//
|
|
337
|
+
// Do not focus item when open not from keyboard
|
|
338
338
|
if (event.type !== 'keydown') {
|
|
339
339
|
subMenu.$.overlay.$.overlay.focus();
|
|
340
340
|
}
|
|
@@ -352,7 +352,9 @@ export const InteractionsMixin = (superClass) =>
|
|
|
352
352
|
_focusLastItem() {
|
|
353
353
|
const list = this._subMenu.$.overlay.firstElementChild;
|
|
354
354
|
const item = list.items[list.items.length - 1];
|
|
355
|
-
|
|
355
|
+
if (item) {
|
|
356
|
+
item.focus();
|
|
357
|
+
}
|
|
356
358
|
}
|
|
357
359
|
|
|
358
360
|
/** @private */
|
|
@@ -397,6 +399,8 @@ export const InteractionsMixin = (superClass) =>
|
|
|
397
399
|
_close(restoreFocus) {
|
|
398
400
|
this.style.pointerEvents = '';
|
|
399
401
|
this.__deactivateButton(restoreFocus);
|
|
400
|
-
this._subMenu.opened
|
|
402
|
+
if (this._subMenu.opened) {
|
|
403
|
+
this._subMenu.close();
|
|
404
|
+
}
|
|
401
405
|
}
|
|
402
406
|
};
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -144,13 +144,13 @@ declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(Eleme
|
|
|
144
144
|
addEventListener<K extends keyof MenuBarEventMap>(
|
|
145
145
|
type: K,
|
|
146
146
|
listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
|
|
147
|
-
options?: boolean | AddEventListenerOptions
|
|
147
|
+
options?: boolean | AddEventListenerOptions,
|
|
148
148
|
): void;
|
|
149
149
|
|
|
150
150
|
removeEventListener<K extends keyof MenuBarEventMap>(
|
|
151
151
|
type: K,
|
|
152
152
|
listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
|
|
153
|
-
options?: boolean | EventListenerOptions
|
|
153
|
+
options?: boolean | EventListenerOptions,
|
|
154
154
|
): void;
|
|
155
155
|
}
|
|
156
156
|
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -164,7 +164,7 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
|
|
|
164
164
|
*/
|
|
165
165
|
items: {
|
|
166
166
|
type: Array,
|
|
167
|
-
value: () => []
|
|
167
|
+
value: () => [],
|
|
168
168
|
},
|
|
169
169
|
|
|
170
170
|
/**
|
|
@@ -194,10 +194,10 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
|
|
|
194
194
|
type: Object,
|
|
195
195
|
value: () => {
|
|
196
196
|
return {
|
|
197
|
-
moreOptions: 'More options'
|
|
197
|
+
moreOptions: 'More options',
|
|
198
198
|
};
|
|
199
|
-
}
|
|
200
|
-
}
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -245,7 +245,7 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
|
|
|
245
245
|
/** @private */
|
|
246
246
|
__updateButtonsDisabled(disabled) {
|
|
247
247
|
this._buttons.forEach((btn) => {
|
|
248
|
-
//
|
|
248
|
+
// Disable the button if the entire menu-bar is disabled or the item alone is disabled
|
|
249
249
|
btn.disabled = disabled || (btn.item && btn.item.disabled);
|
|
250
250
|
});
|
|
251
251
|
}
|