@vaadin/menu-bar 25.0.0-alpha7 → 25.0.0-alpha9
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 +16 -14
- package/src/styles/vaadin-menu-bar-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-base-styles.js +55 -0
- package/src/styles/vaadin-menu-bar-button-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-button-base-styles.js +47 -0
- package/src/styles/vaadin-menu-bar-item-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-item-base-styles.js +8 -0
- package/src/styles/vaadin-menu-bar-item-core-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-item-core-styles.js +8 -0
- package/src/styles/vaadin-menu-bar-overlay-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-overlay-base-styles.js +9 -0
- package/src/vaadin-menu-bar-item.js +3 -3
- package/src/vaadin-menu-bar-list-box.js +1 -1
- package/src/vaadin-menu-bar-mixin.js +71 -18
- package/src/vaadin-menu-bar-overlay.js +2 -1
- package/src/vaadin-menu-bar-submenu-mixin.js +3 -3
- package/src/vaadin-menu-bar-submenu.js +20 -11
- package/src/vaadin-menu-bar.d.ts +3 -6
- package/src/vaadin-menu-bar.js +6 -8
- 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": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -35,21 +37,21 @@
|
|
|
35
37
|
],
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
39
|
-
"@vaadin/button": "25.0.0-
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/context-menu": "25.0.0-
|
|
42
|
-
"@vaadin/item": "25.0.0-
|
|
43
|
-
"@vaadin/list-box": "25.0.0-
|
|
44
|
-
"@vaadin/overlay": "25.0.0-
|
|
45
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.0.0-alpha9",
|
|
41
|
+
"@vaadin/button": "25.0.0-alpha9",
|
|
42
|
+
"@vaadin/component-base": "25.0.0-alpha9",
|
|
43
|
+
"@vaadin/context-menu": "25.0.0-alpha9",
|
|
44
|
+
"@vaadin/item": "25.0.0-alpha9",
|
|
45
|
+
"@vaadin/list-box": "25.0.0-alpha9",
|
|
46
|
+
"@vaadin/overlay": "25.0.0-alpha9",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
|
|
47
49
|
"lit": "^3.0.0"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
51
|
-
"@vaadin/icon": "25.0.0-
|
|
52
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
52
|
+
"@vaadin/chai-plugins": "25.0.0-alpha9",
|
|
53
|
+
"@vaadin/icon": "25.0.0-alpha9",
|
|
54
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha9",
|
|
53
55
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
54
56
|
"sinon": "^18.0.0"
|
|
55
57
|
},
|
|
@@ -57,5 +59,5 @@
|
|
|
57
59
|
"web-types.json",
|
|
58
60
|
"web-types.lit.json"
|
|
59
61
|
],
|
|
60
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
|
|
61
63
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const menuBarStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part='container'] {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: nowrap;
|
|
20
|
+
margin: calc((var(--vaadin-focus-ring-width) + 1px) * -1);
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
padding: calc(var(--vaadin-focus-ring-width) + 1px);
|
|
23
|
+
position: relative;
|
|
24
|
+
width: 100%;
|
|
25
|
+
--_gap: var(--vaadin-menu-bar-gap, 0px);
|
|
26
|
+
--_bw: var(--vaadin-button-border-width, 1px);
|
|
27
|
+
gap: var(--_gap);
|
|
28
|
+
--_rad-button: var(--vaadin-button-border-radius, var(--vaadin-radius-m));
|
|
29
|
+
--_rad: min(var(--_gap) * 1000, var(--_rad-button));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
::slotted(vaadin-menu-bar-button:not(:first-of-type)) {
|
|
33
|
+
margin-inline-start: min(var(--_bw) * -1 + var(--_gap) * 1000, 0px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(vaadin-menu-bar-button) {
|
|
37
|
+
border-radius: var(--_rad);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
::slotted([first-visible]),
|
|
41
|
+
:host([has-single-button]) ::slotted([slot='overflow']) {
|
|
42
|
+
border-start-start-radius: var(--_rad-button);
|
|
43
|
+
border-end-start-radius: var(--_rad-button);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
::slotted(:is([last-visible], [slot='overflow'])) {
|
|
47
|
+
border-start-end-radius: var(--_rad-button);
|
|
48
|
+
border-end-end-radius: var(--_rad-button);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button[first-visible]),
|
|
52
|
+
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
53
|
+
margin-inline-start: auto;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const menuBarButtonStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([focus-ring]) {
|
|
14
|
+
z-index: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([slot='overflow']) {
|
|
18
|
+
margin-inline-end: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vaadin-button-container {
|
|
22
|
+
gap: inherit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix'] {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: inherit;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix']::after {
|
|
32
|
+
background: currentColor;
|
|
33
|
+
content: '';
|
|
34
|
+
height: var(--vaadin-icon-size, 1lh);
|
|
35
|
+
mask-image: var(--_vaadin-icon-chevron-down);
|
|
36
|
+
width: var(--vaadin-icon-size, 1lh);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
::slotted(vaadin-menu-bar-item) {
|
|
40
|
+
padding: 0;
|
|
41
|
+
gap: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
::slotted(vaadin-menu-bar-item)::after {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { contextMenuItemStyles } from '@vaadin/context-menu/src/styles/vaadin-context-menu-item-base-styles.js';
|
|
7
|
+
|
|
8
|
+
export const menuBarItemStyles = contextMenuItemStyles;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
|
|
7
|
+
|
|
8
|
+
export const menuBarItemStyles = [itemStyles];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { menuOverlayStyles } from '@vaadin/context-menu/src/styles/vaadin-menu-overlay-base-styles.js';
|
|
7
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
|
|
8
|
+
|
|
9
|
+
export const menuBarOverlayStyles = [overlayStyles, menuOverlayStyles];
|
|
@@ -7,10 +7,10 @@ import { html, LitElement } from 'lit';
|
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
|
|
11
10
|
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
12
11
|
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
13
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { menuBarItemStyles } from './styles/vaadin-menu-bar-item-core-styles.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
@@ -22,13 +22,13 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
22
22
|
* @mixes ThemableMixin
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
|
-
class MenuBarItem extends ItemMixin(ThemableMixin(DirMixin(LumoInjectionMixin(
|
|
25
|
+
class MenuBarItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
26
26
|
static get is() {
|
|
27
27
|
return 'vaadin-menu-bar-item';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
static get styles() {
|
|
31
|
-
return
|
|
31
|
+
return menuBarItemStyles;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** @protected */
|
|
@@ -22,7 +22,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
22
22
|
* @mixes ThemableMixin
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
|
-
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(LumoInjectionMixin(
|
|
25
|
+
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
26
26
|
static get is() {
|
|
27
27
|
return 'vaadin-menu-bar-list-box';
|
|
28
28
|
}
|
|
@@ -274,11 +274,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
274
274
|
return Array.from(this.querySelectorAll('vaadin-menu-bar-button'));
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
/** @private */
|
|
278
|
-
get _subMenu() {
|
|
279
|
-
return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
277
|
/** @private */
|
|
283
278
|
get _hasOverflow() {
|
|
284
279
|
return this._overflow && !this._overflow.hasAttribute('hidden');
|
|
@@ -297,6 +292,20 @@ export const MenuBarMixin = (superClass) =>
|
|
|
297
292
|
|
|
298
293
|
this.setAttribute('role', 'menubar');
|
|
299
294
|
|
|
295
|
+
this._subMenuController = new SlotController(this, 'submenu', 'vaadin-menu-bar-submenu', {
|
|
296
|
+
initializer: (menu) => {
|
|
297
|
+
menu.setAttribute('is-root', '');
|
|
298
|
+
|
|
299
|
+
menu.addEventListener('item-selected', this.__onItemSelected.bind(this));
|
|
300
|
+
menu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
|
|
301
|
+
|
|
302
|
+
const overlay = menu._overlayElement;
|
|
303
|
+
overlay._contentRoot.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
304
|
+
|
|
305
|
+
this._subMenu = menu;
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
300
309
|
this._overflowController = new SlotController(this, 'overflow', 'vaadin-menu-bar-button', {
|
|
301
310
|
initializer: (btn) => {
|
|
302
311
|
btn.setAttribute('hidden', '');
|
|
@@ -313,17 +322,13 @@ export const MenuBarMixin = (superClass) =>
|
|
|
313
322
|
this._overflow = btn;
|
|
314
323
|
},
|
|
315
324
|
});
|
|
325
|
+
|
|
326
|
+
this.addController(this._subMenuController);
|
|
316
327
|
this.addController(this._overflowController);
|
|
317
328
|
|
|
318
329
|
this.addEventListener('mousedown', () => this._hideTooltip(true));
|
|
319
330
|
this.addEventListener('mouseleave', () => this._hideTooltip());
|
|
320
331
|
|
|
321
|
-
this._subMenu.addEventListener('item-selected', this.__onItemSelected.bind(this));
|
|
322
|
-
this._subMenu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
|
|
323
|
-
|
|
324
|
-
const overlay = this._subMenu._overlayElement;
|
|
325
|
-
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
326
|
-
|
|
327
332
|
this._container = this.shadowRoot.querySelector('[part="container"]');
|
|
328
333
|
}
|
|
329
334
|
|
|
@@ -343,6 +348,10 @@ export const MenuBarMixin = (superClass) =>
|
|
|
343
348
|
this.__updateSubMenu();
|
|
344
349
|
}
|
|
345
350
|
|
|
351
|
+
if (props.has('overlayClass')) {
|
|
352
|
+
this._subMenu.overlayClass = this.overlayClass;
|
|
353
|
+
}
|
|
354
|
+
|
|
346
355
|
if (props.has('_theme')) {
|
|
347
356
|
this._themeChanged(this._theme);
|
|
348
357
|
}
|
|
@@ -669,6 +678,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
669
678
|
_hideTooltip(immediate) {
|
|
670
679
|
const tooltip = this._tooltipController && this._tooltipController.node;
|
|
671
680
|
if (tooltip) {
|
|
681
|
+
this._tooltipController.setContext({ item: null });
|
|
672
682
|
tooltip._stateController.close(immediate);
|
|
673
683
|
}
|
|
674
684
|
}
|
|
@@ -732,6 +742,34 @@ export const MenuBarMixin = (superClass) =>
|
|
|
732
742
|
return Array.from(e.composedPath()).find((el) => el.localName === 'vaadin-menu-bar-button');
|
|
733
743
|
}
|
|
734
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Override method inherited from `FocusMixin`
|
|
747
|
+
*
|
|
748
|
+
* @override
|
|
749
|
+
* @protected
|
|
750
|
+
*/
|
|
751
|
+
_shouldSetFocus(event) {
|
|
752
|
+
// Ignore events from the submenu
|
|
753
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return super._shouldSetFocus(event);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Override method inherited from `FocusMixin`
|
|
761
|
+
*
|
|
762
|
+
* @override
|
|
763
|
+
* @protected
|
|
764
|
+
*/
|
|
765
|
+
_shouldRemoveFocus(event) {
|
|
766
|
+
// Ignore events from the submenu
|
|
767
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
return super._shouldRemoveFocus(event);
|
|
771
|
+
}
|
|
772
|
+
|
|
735
773
|
/**
|
|
736
774
|
* Override method inherited from `FocusMixin`
|
|
737
775
|
*
|
|
@@ -814,6 +852,16 @@ export const MenuBarMixin = (superClass) =>
|
|
|
814
852
|
* @override
|
|
815
853
|
*/
|
|
816
854
|
_onKeyDown(event) {
|
|
855
|
+
// Ignore events from the submenu
|
|
856
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
this._handleKeyDown(event);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** @private */
|
|
864
|
+
_handleKeyDown(event) {
|
|
817
865
|
switch (event.key) {
|
|
818
866
|
case 'ArrowDown':
|
|
819
867
|
this._onArrowDown(event);
|
|
@@ -828,11 +876,16 @@ export const MenuBarMixin = (superClass) =>
|
|
|
828
876
|
}
|
|
829
877
|
|
|
830
878
|
/**
|
|
831
|
-
* @param {!MouseEvent}
|
|
879
|
+
* @param {!MouseEvent} event
|
|
832
880
|
* @protected
|
|
833
881
|
*/
|
|
834
|
-
_onMouseOver(
|
|
835
|
-
|
|
882
|
+
_onMouseOver(event) {
|
|
883
|
+
// Ignore events from the submenu
|
|
884
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
const button = this._getButtonFromEvent(event);
|
|
836
889
|
if (!button) {
|
|
837
890
|
// Hide tooltip on mouseover to disabled button
|
|
838
891
|
this._hideTooltip();
|
|
@@ -864,11 +917,11 @@ export const MenuBarMixin = (superClass) =>
|
|
|
864
917
|
if (e.keyCode === 37 || (e.keyCode === 39 && !item._item.children)) {
|
|
865
918
|
// Prevent ArrowLeft from being handled in context-menu
|
|
866
919
|
e.stopImmediatePropagation();
|
|
867
|
-
this.
|
|
920
|
+
this._handleKeyDown(e);
|
|
868
921
|
}
|
|
869
922
|
|
|
870
923
|
if (e.key === 'Tab' && this.tabNavigation) {
|
|
871
|
-
this.
|
|
924
|
+
this._handleKeyDown(e);
|
|
872
925
|
}
|
|
873
926
|
}
|
|
874
927
|
}
|
|
@@ -951,13 +1004,13 @@ export const MenuBarMixin = (superClass) =>
|
|
|
951
1004
|
|
|
952
1005
|
/** @private */
|
|
953
1006
|
_focusFirstItem() {
|
|
954
|
-
const list = this._subMenu._overlayElement.firstElementChild;
|
|
1007
|
+
const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
|
|
955
1008
|
list.focus();
|
|
956
1009
|
}
|
|
957
1010
|
|
|
958
1011
|
/** @private */
|
|
959
1012
|
_focusLastItem() {
|
|
960
|
-
const list = this._subMenu._overlayElement.firstElementChild;
|
|
1013
|
+
const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
|
|
961
1014
|
const item = list.items[list.items.length - 1];
|
|
962
1015
|
if (item) {
|
|
963
1016
|
item.focus();
|
|
@@ -25,7 +25,7 @@ import { menuBarOverlayStyles } from './styles/vaadin-menu-bar-overlay-core-styl
|
|
|
25
25
|
* @protected
|
|
26
26
|
*/
|
|
27
27
|
export class MenuBarOverlay extends MenuOverlayMixin(
|
|
28
|
-
OverlayMixin(DirMixin(ThemableMixin(LumoInjectionMixin(
|
|
28
|
+
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
29
29
|
) {
|
|
30
30
|
static get is() {
|
|
31
31
|
return 'vaadin-menu-bar-overlay';
|
|
@@ -42,6 +42,7 @@ export class MenuBarOverlay extends MenuOverlayMixin(
|
|
|
42
42
|
<div part="overlay" id="overlay" tabindex="0">
|
|
43
43
|
<div part="content" id="content">
|
|
44
44
|
<slot></slot>
|
|
45
|
+
<slot name="submenu"></slot>
|
|
45
46
|
</div>
|
|
46
47
|
</div>
|
|
47
48
|
`;
|
|
@@ -31,8 +31,8 @@ export const SubMenuMixin = (superClass) =>
|
|
|
31
31
|
/**
|
|
32
32
|
* Overriding the observer to not add global "contextmenu" listener.
|
|
33
33
|
*/
|
|
34
|
-
_openedChanged(
|
|
35
|
-
|
|
34
|
+
_openedChanged() {
|
|
35
|
+
// Do nothing
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -43,7 +43,7 @@ export const SubMenuMixin = (superClass) =>
|
|
|
43
43
|
|
|
44
44
|
// Only handle 1st level submenu
|
|
45
45
|
if (this.hasAttribute('is-root')) {
|
|
46
|
-
this.
|
|
46
|
+
this.parentElement._close();
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -7,6 +7,7 @@ import './vaadin-menu-bar-item.js';
|
|
|
7
7
|
import './vaadin-menu-bar-list-box.js';
|
|
8
8
|
import './vaadin-menu-bar-overlay.js';
|
|
9
9
|
import { css, html, LitElement } from 'lit';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
12
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
13
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
@@ -40,17 +41,25 @@ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitEle
|
|
|
40
41
|
|
|
41
42
|
/** @protected */
|
|
42
43
|
render() {
|
|
43
|
-
return html
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
return html`
|
|
45
|
+
<vaadin-menu-bar-overlay
|
|
46
|
+
id="overlay"
|
|
47
|
+
.owner="${this}"
|
|
48
|
+
.opened="${this.opened}"
|
|
49
|
+
.model="${this._context}"
|
|
50
|
+
.modeless="${this._modeless}"
|
|
51
|
+
.renderer="${this.__itemsRenderer}"
|
|
52
|
+
.withBackdrop="${this._phone}"
|
|
53
|
+
?phone="${this._phone}"
|
|
54
|
+
theme="${ifDefined(this._theme)}"
|
|
55
|
+
exportparts="backdrop, overlay, content"
|
|
56
|
+
@opened-changed="${this._onOverlayOpened}"
|
|
57
|
+
@vaadin-overlay-open="${this._onVaadinOverlayOpen}"
|
|
58
|
+
>
|
|
59
|
+
<slot name="overlay"></slot>
|
|
60
|
+
<slot name="submenu" slot="submenu"></slot>
|
|
61
|
+
</vaadin-menu-bar-overlay>
|
|
62
|
+
`;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -30,13 +30,13 @@ export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
|
|
|
30
30
|
*
|
|
31
31
|
* To create the menu bar, first add the component to the page:
|
|
32
32
|
*
|
|
33
|
-
* ```
|
|
33
|
+
* ```html
|
|
34
34
|
* <vaadin-menu-bar></vaadin-menu-bar>
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
|
|
38
38
|
*
|
|
39
|
-
* ```
|
|
39
|
+
* ```js
|
|
40
40
|
* document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
|
|
41
41
|
* ```
|
|
42
42
|
*
|
|
@@ -65,7 +65,7 @@ export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
|
|
|
65
65
|
* - `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
|
|
66
66
|
* - `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
67
67
|
* - `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
|
|
68
|
-
* - `<vaadin-menu-bar-
|
|
68
|
+
* - `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](#/elements/vaadin-context-menu).
|
|
69
69
|
*
|
|
70
70
|
* The `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes
|
|
71
71
|
* on top of the built-in `<vaadin-item>` state attributes:
|
|
@@ -74,9 +74,6 @@ export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
|
|
|
74
74
|
* ---------- |-------------
|
|
75
75
|
* `expanded` | Expanded parent item.
|
|
76
76
|
*
|
|
77
|
-
* Note: the `theme` attribute value set on `<vaadin-menu-bar>` is
|
|
78
|
-
* propagated to the internal components listed above.
|
|
79
|
-
*
|
|
80
77
|
* @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
81
78
|
*/
|
|
82
79
|
declare class MenuBar<TItem extends MenuBarItem = MenuBarItem> extends HTMLElement {
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -22,13 +22,13 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
22
22
|
*
|
|
23
23
|
* To create the menu bar, first add the component to the page:
|
|
24
24
|
*
|
|
25
|
-
* ```
|
|
25
|
+
* ```html
|
|
26
26
|
* <vaadin-menu-bar></vaadin-menu-bar>
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
|
|
30
30
|
*
|
|
31
|
-
* ```
|
|
31
|
+
* ```js
|
|
32
32
|
* document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
|
|
33
33
|
* ```
|
|
34
34
|
*
|
|
@@ -57,7 +57,7 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
57
57
|
* - `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
|
|
58
58
|
* - `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
59
59
|
* - `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
|
|
60
|
-
* - `<vaadin-menu-bar-
|
|
60
|
+
* - `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](#/elements/vaadin-context-menu).
|
|
61
61
|
*
|
|
62
62
|
* The `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes
|
|
63
63
|
* on top of the built-in `<vaadin-item>` state attributes:
|
|
@@ -66,9 +66,6 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
66
66
|
* ---------- |-------------
|
|
67
67
|
* `expanded` | Expanded parent item.
|
|
68
68
|
*
|
|
69
|
-
* Note: the `theme` attribute value set on `<vaadin-menu-bar>` is
|
|
70
|
-
* propagated to the internal components listed above.
|
|
71
|
-
*
|
|
72
69
|
* @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
73
70
|
*
|
|
74
71
|
* @customElement
|
|
@@ -77,7 +74,7 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
77
74
|
* @mixes MenuBarMixin
|
|
78
75
|
* @mixes ThemableMixin
|
|
79
76
|
*/
|
|
80
|
-
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(LumoInjectionMixin(
|
|
77
|
+
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
81
78
|
static get is() {
|
|
82
79
|
return 'vaadin-menu-bar';
|
|
83
80
|
}
|
|
@@ -93,7 +90,8 @@ class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(LumoInjectionMixin
|
|
|
93
90
|
<slot></slot>
|
|
94
91
|
<slot name="overflow"></slot>
|
|
95
92
|
</div>
|
|
96
|
-
|
|
93
|
+
|
|
94
|
+
<slot name="submenu"></slot>
|
|
97
95
|
|
|
98
96
|
<slot name="tooltip"></slot>
|
|
99
97
|
`;
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha9",
|
|
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
|
|
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```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\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/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/25.0.0-alpha9/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-context-menu).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha9",
|
|
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
|
|
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```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\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/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/25.0.0-alpha9/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-context-menu).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|