@vaadin/menu-bar 23.1.0-beta1 → 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
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
|
}
|
|
@@ -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 {
|
|
@@ -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);
|
|
@@ -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
|
}
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -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
|
}
|