@vaadin/menu-bar 23.3.0-alpha2 → 24.0.0-alpha1
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 +8 -0
- package/src/vaadin-menu-bar-buttons-mixin.d.ts +2 -1
- package/src/vaadin-menu-bar-buttons-mixin.js +58 -27
- package/src/vaadin-menu-bar-interactions-mixin.js +21 -43
- package/src/vaadin-menu-bar.d.ts +1 -6
- package/src/vaadin-menu-bar.js +6 -28
- package/theme/lumo/vaadin-menu-bar-button-styles.js +6 -6
- package/theme/lumo/vaadin-menu-bar-styles.js +3 -3
- package/theme/material/vaadin-menu-bar-button-styles.js +6 -6
- package/theme/material/vaadin-menu-bar-styles.js +3 -3
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/button": "
|
|
41
|
-
"@vaadin/component-base": "
|
|
42
|
-
"@vaadin/context-menu": "
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
44
|
-
"@vaadin/vaadin-material-styles": "
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
40
|
+
"@vaadin/button": "24.0.0-alpha1",
|
|
41
|
+
"@vaadin/component-base": "24.0.0-alpha1",
|
|
42
|
+
"@vaadin/context-menu": "24.0.0-alpha1",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha1",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/icon": "
|
|
49
|
+
"@vaadin/icon": "24.0.0-alpha1",
|
|
50
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
51
|
"sinon": "^13.0.2"
|
|
52
52
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
|
|
58
58
|
}
|
|
@@ -9,6 +9,14 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
|
|
|
9
9
|
registerStyles(
|
|
10
10
|
'vaadin-menu-bar-button',
|
|
11
11
|
css`
|
|
12
|
+
:host {
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([slot='overflow']) {
|
|
17
|
+
margin-inline-end: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
[part='label'] ::slotted(vaadin-context-menu-item) {
|
|
13
21
|
position: relative;
|
|
14
22
|
z-index: 1;
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
8
|
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
8
9
|
|
|
9
10
|
export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(
|
|
10
11
|
base: T,
|
|
11
|
-
): Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass> & T;
|
|
12
|
+
): Constructor<ButtonsMixinClass> & Constructor<ControllerMixinClass> & Constructor<ResizeMixinClass> & T;
|
|
12
13
|
|
|
13
14
|
export declare class ButtonsMixinClass {
|
|
14
15
|
protected readonly _buttons: HTMLElement[];
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
* Copyright (c) 2019 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
6
7
|
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
8
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* @polymerMixin
|
|
10
12
|
* @mixes ResizeMixin
|
|
13
|
+
* @mixes ControllerMixin
|
|
11
14
|
*/
|
|
12
15
|
export const ButtonsMixin = (superClass) =>
|
|
13
|
-
class extends ResizeMixin(superClass) {
|
|
16
|
+
class extends ResizeMixin(ControllerMixin(superClass)) {
|
|
14
17
|
static get properties() {
|
|
15
18
|
return {
|
|
16
19
|
/**
|
|
@@ -21,11 +24,20 @@ export const ButtonsMixin = (superClass) =>
|
|
|
21
24
|
type: Boolean,
|
|
22
25
|
value: false,
|
|
23
26
|
},
|
|
27
|
+
|
|
28
|
+
/** @protected */
|
|
29
|
+
_overflow: {
|
|
30
|
+
type: Object,
|
|
31
|
+
},
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
static get observers() {
|
|
28
|
-
return [
|
|
36
|
+
return [
|
|
37
|
+
'__hasOverflowChanged(_hasOverflow, _overflow)',
|
|
38
|
+
'__i18nChanged(i18n, _overflow)',
|
|
39
|
+
'_menuItemsChanged(items, _overflow, items.splices)',
|
|
40
|
+
];
|
|
29
41
|
}
|
|
30
42
|
|
|
31
43
|
/**
|
|
@@ -43,13 +55,24 @@ export const ButtonsMixin = (superClass) =>
|
|
|
43
55
|
super.ready();
|
|
44
56
|
|
|
45
57
|
this.setAttribute('role', 'menubar');
|
|
46
|
-
}
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
this._overflowController = new SlotController(
|
|
60
|
+
this,
|
|
61
|
+
'overflow',
|
|
62
|
+
() => document.createElement('vaadin-menu-bar-button'),
|
|
63
|
+
(_, btn) => {
|
|
64
|
+
btn.setAttribute('hidden', '');
|
|
51
65
|
|
|
52
|
-
|
|
66
|
+
const dots = document.createElement('div');
|
|
67
|
+
dots.setAttribute('aria-hidden', 'true');
|
|
68
|
+
dots.textContent = '···';
|
|
69
|
+
btn.appendChild(dots);
|
|
70
|
+
|
|
71
|
+
this._overflow = btn;
|
|
72
|
+
this._initButtonAttrs(btn);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
this.addController(this._overflowController);
|
|
53
76
|
}
|
|
54
77
|
|
|
55
78
|
/**
|
|
@@ -57,7 +80,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
57
80
|
* @protected
|
|
58
81
|
*/
|
|
59
82
|
get _buttons() {
|
|
60
|
-
return Array.from(this.
|
|
83
|
+
return Array.from(this.querySelectorAll('vaadin-menu-bar-button'));
|
|
61
84
|
}
|
|
62
85
|
|
|
63
86
|
/**
|
|
@@ -68,22 +91,36 @@ export const ButtonsMixin = (superClass) =>
|
|
|
68
91
|
return this.shadowRoot.querySelector('[part="container"]');
|
|
69
92
|
}
|
|
70
93
|
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this.shadowRoot.querySelector('[part="overflow-button"]');
|
|
94
|
+
/** @private */
|
|
95
|
+
__hasOverflowChanged(hasOverflow, overflow) {
|
|
96
|
+
if (overflow) {
|
|
97
|
+
overflow.toggleAttribute('hidden', !hasOverflow);
|
|
98
|
+
}
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
/** @private */
|
|
80
|
-
_menuItemsChanged(items) {
|
|
102
|
+
_menuItemsChanged(items, overflow) {
|
|
103
|
+
if (!overflow) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
if (items !== this._oldItems) {
|
|
82
108
|
this._oldItems = items;
|
|
83
109
|
this.__renderButtons(items);
|
|
84
110
|
}
|
|
85
111
|
}
|
|
86
112
|
|
|
113
|
+
/** @private */
|
|
114
|
+
__i18nChanged(i18n, overflow) {
|
|
115
|
+
if (overflow && i18n && i18n.moreOptions !== undefined) {
|
|
116
|
+
if (i18n.moreOptions) {
|
|
117
|
+
overflow.setAttribute('aria-label', i18n.moreOptions);
|
|
118
|
+
} else {
|
|
119
|
+
overflow.removeAttribute('aria-label');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
87
124
|
/** @private */
|
|
88
125
|
__getOverflowCount(overflow) {
|
|
89
126
|
// We can't use optional chaining due to webpack 4
|
|
@@ -170,17 +207,16 @@ export const ButtonsMixin = (superClass) =>
|
|
|
170
207
|
|
|
171
208
|
/** @protected */
|
|
172
209
|
_removeButtons() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
210
|
+
this._buttons.forEach((button) => {
|
|
211
|
+
if (button !== this._overflow) {
|
|
212
|
+
this.removeChild(button);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
178
215
|
}
|
|
179
216
|
|
|
180
217
|
/** @protected */
|
|
181
218
|
_initButton(item) {
|
|
182
219
|
const button = document.createElement('vaadin-menu-bar-button');
|
|
183
|
-
button.setAttribute('part', 'menu-bar-button');
|
|
184
220
|
|
|
185
221
|
const itemCopy = { ...item };
|
|
186
222
|
button.item = itemCopy;
|
|
@@ -231,11 +267,6 @@ export const ButtonsMixin = (superClass) =>
|
|
|
231
267
|
}
|
|
232
268
|
}
|
|
233
269
|
|
|
234
|
-
/** @protected */
|
|
235
|
-
_appendButton(button) {
|
|
236
|
-
this._container.insertBefore(button, this._overflow);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
270
|
/** @private */
|
|
240
271
|
__getComponent(item) {
|
|
241
272
|
const itemComponent = item.component;
|
|
@@ -268,7 +299,7 @@ export const ButtonsMixin = (superClass) =>
|
|
|
268
299
|
|
|
269
300
|
items.forEach((item) => {
|
|
270
301
|
const button = this._initButton(item);
|
|
271
|
-
this.
|
|
302
|
+
this.insertBefore(button, this._overflow);
|
|
272
303
|
this._setButtonDisabled(button, item.disabled);
|
|
273
304
|
this._initButtonAttrs(button);
|
|
274
305
|
this._setButtonTheme(button, this._theme);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
7
|
-
import { isKeyboardActive } from '@vaadin/component-base/src/focus-utils.js';
|
|
7
|
+
import { isElementFocused, isKeyboardActive } from '@vaadin/component-base/src/focus-utils.js';
|
|
8
8
|
import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -47,7 +47,6 @@ export const InteractionsMixin = (superClass) =>
|
|
|
47
47
|
|
|
48
48
|
const overlay = this._subMenu.$.overlay;
|
|
49
49
|
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
50
|
-
overlay.addEventListener('vaadin-overlay-open', this.__alignOverlayPosition.bind(this));
|
|
51
50
|
|
|
52
51
|
const container = this._container;
|
|
53
52
|
container.addEventListener('click', this.__onButtonClick.bind(this));
|
|
@@ -56,15 +55,15 @@ export const InteractionsMixin = (superClass) =>
|
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* Override getter from `KeyboardDirectionMixin`
|
|
59
|
-
* to
|
|
60
|
-
*
|
|
58
|
+
* to use expanded button for arrow navigation
|
|
59
|
+
* when the sub-menu is opened and has focus.
|
|
61
60
|
*
|
|
62
61
|
* @return {Element | null}
|
|
63
62
|
* @protected
|
|
64
63
|
* @override
|
|
65
64
|
*/
|
|
66
65
|
get focused() {
|
|
67
|
-
return this.
|
|
66
|
+
return (this._getItems() || []).find(isElementFocused) || this._expandedButton;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
/**
|
|
@@ -90,22 +89,17 @@ export const InteractionsMixin = (superClass) =>
|
|
|
90
89
|
return this._buttons;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
/** @private */
|
|
94
|
-
get __isRTL() {
|
|
95
|
-
return this.getAttribute('dir') === 'rtl';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
92
|
/** @protected */
|
|
99
93
|
disconnectedCallback() {
|
|
100
94
|
super.disconnectedCallback();
|
|
101
|
-
this._hideTooltip();
|
|
95
|
+
this._hideTooltip(true);
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
/**
|
|
105
99
|
* @param {HTMLElement} button
|
|
106
100
|
* @protected
|
|
107
101
|
*/
|
|
108
|
-
_showTooltip(button) {
|
|
102
|
+
_showTooltip(button, isHover) {
|
|
109
103
|
// Check if there is a slotted vaadin-tooltip element.
|
|
110
104
|
const tooltip = this._tooltipController.node;
|
|
111
105
|
if (tooltip && tooltip.isConnected) {
|
|
@@ -118,14 +112,22 @@ export const InteractionsMixin = (superClass) =>
|
|
|
118
112
|
if (!this._subMenu.opened) {
|
|
119
113
|
this._tooltipController.setTarget(button);
|
|
120
114
|
this._tooltipController.setContext({ item: button.item });
|
|
121
|
-
|
|
115
|
+
|
|
116
|
+
// Trigger opening using the corresponding delay.
|
|
117
|
+
tooltip._stateController.open({
|
|
118
|
+
hover: isHover,
|
|
119
|
+
focus: !isHover,
|
|
120
|
+
});
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
/** @protected */
|
|
127
|
-
_hideTooltip() {
|
|
128
|
-
this._tooltipController.
|
|
126
|
+
_hideTooltip(immediate) {
|
|
127
|
+
const tooltip = this._tooltipController && this._tooltipController.node;
|
|
128
|
+
if (tooltip) {
|
|
129
|
+
tooltip._stateController.close(immediate);
|
|
130
|
+
}
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
/** @protected */
|
|
@@ -185,7 +187,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
185
187
|
*/
|
|
186
188
|
_setFocused(focused) {
|
|
187
189
|
if (focused) {
|
|
188
|
-
const target = this.
|
|
190
|
+
const target = this.querySelector('[tabindex="0"]');
|
|
189
191
|
if (target) {
|
|
190
192
|
this._buttons.forEach((btn) => {
|
|
191
193
|
this._setTabindex(btn, btn === target);
|
|
@@ -247,7 +249,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
247
249
|
this._close(true);
|
|
248
250
|
}
|
|
249
251
|
|
|
250
|
-
this._hideTooltip();
|
|
252
|
+
this._hideTooltip(true);
|
|
251
253
|
}
|
|
252
254
|
|
|
253
255
|
/**
|
|
@@ -276,30 +278,6 @@ export const InteractionsMixin = (superClass) =>
|
|
|
276
278
|
return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
|
|
277
279
|
}
|
|
278
280
|
|
|
279
|
-
/** @private */
|
|
280
|
-
__alignOverlayPosition(e) {
|
|
281
|
-
/* c8 ignore next */
|
|
282
|
-
if (!this._expandedButton) {
|
|
283
|
-
// When `openOnHover` is true, quickly moving cursor can close submenu,
|
|
284
|
-
// so by the time when event listener gets executed button is null.
|
|
285
|
-
// See https://github.com/vaadin/vaadin-menu-bar/issues/85
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const overlay = e.target;
|
|
289
|
-
const { width, height, left } = this._expandedButton.getBoundingClientRect();
|
|
290
|
-
if (overlay.hasAttribute('bottom-aligned')) {
|
|
291
|
-
overlay.style.bottom = `${parseInt(getComputedStyle(overlay).bottom) + height}px`;
|
|
292
|
-
}
|
|
293
|
-
const endAligned = overlay.hasAttribute('end-aligned');
|
|
294
|
-
if (endAligned) {
|
|
295
|
-
if (this.__isRTL) {
|
|
296
|
-
overlay.style.left = `${left}px`;
|
|
297
|
-
} else {
|
|
298
|
-
overlay.style.right = `${parseInt(getComputedStyle(overlay).right) - width}px`;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
281
|
/** @private */
|
|
304
282
|
_itemsChanged() {
|
|
305
283
|
const subMenu = this._subMenu;
|
|
@@ -328,7 +306,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
328
306
|
if (button === this._overflow || (this.openOnHover && button.item.children)) {
|
|
329
307
|
this._hideTooltip();
|
|
330
308
|
} else {
|
|
331
|
-
this._showTooltip(button);
|
|
309
|
+
this._showTooltip(button, true);
|
|
332
310
|
}
|
|
333
311
|
}
|
|
334
312
|
}
|
|
@@ -398,7 +376,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
398
376
|
},
|
|
399
377
|
}),
|
|
400
378
|
);
|
|
401
|
-
this._hideTooltip();
|
|
379
|
+
this._hideTooltip(true);
|
|
402
380
|
|
|
403
381
|
this._setExpanded(button, true);
|
|
404
382
|
});
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2019 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
6
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -87,8 +86,6 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
|
|
|
87
86
|
* Part name | Description
|
|
88
87
|
* ------------------|----------------
|
|
89
88
|
* `container` | The container wrapping menu bar buttons.
|
|
90
|
-
* `menu-bar-button` | The menu bar button.
|
|
91
|
-
* `overflow-button` | The "overflow" button appearing when menu bar width is not enough to fit all the buttons.
|
|
92
89
|
*
|
|
93
90
|
* The following state attributes are available for styling:
|
|
94
91
|
*
|
|
@@ -111,9 +108,7 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
|
|
|
111
108
|
*
|
|
112
109
|
* @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
113
110
|
*/
|
|
114
|
-
declare class MenuBar extends ButtonsMixin(
|
|
115
|
-
DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement))))),
|
|
116
|
-
) {
|
|
111
|
+
declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement))))) {
|
|
117
112
|
/**
|
|
118
113
|
* Defines a hierarchical structure, where root level items represent menu bar buttons,
|
|
119
114
|
* and `children` property configures a submenu with items to be opened below
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import './vaadin-menu-bar-submenu.js';
|
|
7
7
|
import './vaadin-menu-bar-button.js';
|
|
8
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
9
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
11
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
11
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
@@ -38,8 +37,6 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
|
|
|
38
37
|
* Part name | Description
|
|
39
38
|
* ------------------|----------------
|
|
40
39
|
* `container` | The container wrapping menu bar buttons.
|
|
41
|
-
* `menu-bar-button` | The menu bar button.
|
|
42
|
-
* `overflow-button` | The "overflow" button appearing when menu bar width is not enough to fit all the buttons.
|
|
43
40
|
*
|
|
44
41
|
* The following state attributes are available for styling:
|
|
45
42
|
*
|
|
@@ -63,16 +60,13 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
|
|
|
63
60
|
* @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
64
61
|
*
|
|
65
62
|
* @extends HTMLElement
|
|
66
|
-
* @mixes ControllerMixin
|
|
67
63
|
* @mixes ButtonsMixin
|
|
68
64
|
* @mixes InteractionsMixin
|
|
69
65
|
* @mixes DisabledMixin
|
|
70
66
|
* @mixes ElementMixin
|
|
71
67
|
* @mixes ThemableMixin
|
|
72
68
|
*/
|
|
73
|
-
class MenuBar extends ButtonsMixin(
|
|
74
|
-
DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))))),
|
|
75
|
-
) {
|
|
69
|
+
class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement))))) {
|
|
76
70
|
static get template() {
|
|
77
71
|
return html`
|
|
78
72
|
<style>
|
|
@@ -91,27 +85,11 @@ class MenuBar extends ButtonsMixin(
|
|
|
91
85
|
flex-wrap: nowrap;
|
|
92
86
|
overflow: hidden;
|
|
93
87
|
}
|
|
94
|
-
|
|
95
|
-
[part$='button'] {
|
|
96
|
-
flex-shrink: 0;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
[part='overflow-button'] {
|
|
100
|
-
margin-right: 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.dots::before {
|
|
104
|
-
display: block;
|
|
105
|
-
content: '\\00B7\\00B7\\00B7';
|
|
106
|
-
font-size: inherit;
|
|
107
|
-
line-height: inherit;
|
|
108
|
-
}
|
|
109
88
|
</style>
|
|
110
89
|
|
|
111
90
|
<div part="container">
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
</vaadin-menu-bar-button>
|
|
91
|
+
<slot></slot>
|
|
92
|
+
<slot name="overflow"></slot>
|
|
115
93
|
</div>
|
|
116
94
|
<vaadin-menu-bar-submenu is-root=""></vaadin-menu-bar-submenu>
|
|
117
95
|
|
|
@@ -219,7 +197,7 @@ class MenuBar extends ButtonsMixin(
|
|
|
219
197
|
}
|
|
220
198
|
|
|
221
199
|
static get observers() {
|
|
222
|
-
return ['_themeChanged(_theme)'];
|
|
200
|
+
return ['_themeChanged(_theme, _overflow)'];
|
|
223
201
|
}
|
|
224
202
|
|
|
225
203
|
/** @protected */
|
|
@@ -255,8 +233,8 @@ class MenuBar extends ButtonsMixin(
|
|
|
255
233
|
* @param {string | null} theme
|
|
256
234
|
* @protected
|
|
257
235
|
*/
|
|
258
|
-
_themeChanged(theme) {
|
|
259
|
-
if (
|
|
236
|
+
_themeChanged(theme, overflow) {
|
|
237
|
+
if (overflow) {
|
|
260
238
|
this._buttons.forEach((btn) => this._setButtonTheme(btn, theme));
|
|
261
239
|
this.__detectOverflow();
|
|
262
240
|
}
|
|
@@ -54,7 +54,7 @@ const menuBarButton = css`
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
:host(:nth-last-of-type(2)),
|
|
57
|
-
:host([
|
|
57
|
+
:host([slot='overflow']) {
|
|
58
58
|
border-radius: 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -63,18 +63,18 @@ const menuBarButton = css`
|
|
|
63
63
|
border-radius: var(--lumo-border-radius-m);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
:host([
|
|
66
|
+
:host([slot='overflow']) {
|
|
67
67
|
min-width: var(--lumo-button-size);
|
|
68
68
|
padding-left: calc(var(--lumo-button-size) / 4);
|
|
69
69
|
padding-right: calc(var(--lumo-button-size) / 4);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
:host([
|
|
72
|
+
:host([slot='overflow']) ::slotted(*) {
|
|
73
73
|
font-size: var(--lumo-font-size-xl);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
:host([
|
|
77
|
-
:host([
|
|
76
|
+
:host([slot='overflow']) [part='prefix'],
|
|
77
|
+
:host([slot='overflow']) [part='suffix'] {
|
|
78
78
|
margin-left: 0;
|
|
79
79
|
margin-right: 0;
|
|
80
80
|
}
|
|
@@ -92,7 +92,7 @@ const menuBarButton = css`
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
:host([dir='rtl']:nth-last-of-type(2)),
|
|
95
|
-
:host([dir='rtl'][
|
|
95
|
+
:host([dir='rtl'][slot='overflow']) {
|
|
96
96
|
border-radius: var(--lumo-border-radius-m) 0 0 var(--lumo-border-radius-m);
|
|
97
97
|
}
|
|
98
98
|
`;
|
|
@@ -4,12 +4,12 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
|
|
|
4
4
|
registerStyles(
|
|
5
5
|
'vaadin-menu-bar',
|
|
6
6
|
css`
|
|
7
|
-
:host([has-single-button])
|
|
7
|
+
:host([has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
8
8
|
border-radius: var(--lumo-border-radius-m);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
:host([theme~='end-aligned'])
|
|
12
|
-
:host([theme~='end-aligned'][has-single-button])
|
|
11
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button:first-of-type),
|
|
12
|
+
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
13
13
|
margin-inline-start: auto;
|
|
14
14
|
}
|
|
15
15
|
`,
|
|
@@ -54,17 +54,17 @@ const menuBarButton = css`
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
:host(:nth-last-of-type(2)),
|
|
57
|
-
:host([
|
|
57
|
+
:host([slot='overflow']) {
|
|
58
58
|
border-radius: 0 4px 4px 0;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
:host([
|
|
61
|
+
:host([slot='overflow']) {
|
|
62
62
|
padding-right: 8px;
|
|
63
63
|
padding-left: 8px;
|
|
64
64
|
min-width: 36px;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
:host([
|
|
67
|
+
:host([slot='overflow']) ::slotted(*) {
|
|
68
68
|
font-size: 24px;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -73,7 +73,7 @@ const menuBarButton = css`
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
:host([theme~='outlined']:not([dir='rtl']):nth-last-of-type(2)),
|
|
76
|
-
:host([theme~='outlined']:not([dir='rtl'])[
|
|
76
|
+
:host([theme~='outlined']:not([dir='rtl'])[slot='overflow']) {
|
|
77
77
|
margin-right: 0;
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -88,7 +88,7 @@ const menuBarButton = css`
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
:host([dir='rtl']:nth-last-of-type(2)),
|
|
91
|
-
:host([dir='rtl'][
|
|
91
|
+
:host([dir='rtl'][slot='overflow']) {
|
|
92
92
|
border-radius: 4px 0 0 4px;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -101,7 +101,7 @@ const menuBarButton = css`
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
:host([theme~='outlined'][dir='rtl']:nth-last-of-type(2)),
|
|
104
|
-
:host([theme~='outlined'][dir='rtl'][
|
|
104
|
+
:host([theme~='outlined'][dir='rtl'][slot='overflow']) {
|
|
105
105
|
margin-left: 0;
|
|
106
106
|
}
|
|
107
107
|
`;
|
|
@@ -8,12 +8,12 @@ registerStyles(
|
|
|
8
8
|
padding-bottom: 5px;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
:host([has-single-button])
|
|
11
|
+
:host([has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
12
12
|
border-radius: 4px;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
:host([theme~='end-aligned'])
|
|
16
|
-
:host([theme~='end-aligned'][has-single-button])
|
|
15
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button:first-of-type),
|
|
16
|
+
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
17
17
|
margin-inline-start: auto;
|
|
18
18
|
}
|
|
19
19
|
`,
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "24.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-menu-bar",
|
|
11
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-overlay).",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "open-on-hover",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "24.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-menu-bar",
|
|
19
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/
|
|
19
|
+
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha1/#/elements/vaadin-overlay).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|