@vaadin/menu-bar 25.0.0-alpha2 → 25.0.0-alpha21
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 +15 -16
- package/src/styles/vaadin-menu-bar-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-base-styles.js +56 -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-overlay-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-overlay-base-styles.js +9 -0
- package/src/vaadin-menu-bar-button.d.ts +19 -0
- package/src/vaadin-menu-bar-button.js +4 -13
- package/src/vaadin-menu-bar-item.js +5 -11
- package/src/vaadin-menu-bar-list-box.js +5 -18
- package/src/vaadin-menu-bar-mixin.d.ts +5 -12
- package/src/vaadin-menu-bar-mixin.js +161 -161
- package/src/vaadin-menu-bar-overlay.js +7 -4
- package/src/vaadin-menu-bar-submenu.d.ts +20 -0
- package/src/vaadin-menu-bar-submenu.js +83 -8
- package/src/vaadin-menu-bar.d.ts +3 -6
- package/src/vaadin-menu-bar.js +11 -27
- package/vaadin-menu-bar.js +1 -1
- package/web-types.json +4 -26
- package/web-types.lit.json +4 -11
- package/src/vaadin-menu-bar-submenu-mixin.js +0 -66
- package/theme/lumo/vaadin-menu-bar-button-styles.d.ts +0 -1
- package/theme/lumo/vaadin-menu-bar-button-styles.js +0 -128
- package/theme/lumo/vaadin-menu-bar-button.d.ts +0 -2
- package/theme/lumo/vaadin-menu-bar-button.js +0 -2
- package/theme/lumo/vaadin-menu-bar-item-styles.d.ts +0 -2
- package/theme/lumo/vaadin-menu-bar-item-styles.js +0 -27
- package/theme/lumo/vaadin-menu-bar-list-box-styles.d.ts +0 -1
- package/theme/lumo/vaadin-menu-bar-list-box-styles.js +0 -5
- package/theme/lumo/vaadin-menu-bar-overlay-styles.d.ts +0 -1
- package/theme/lumo/vaadin-menu-bar-overlay-styles.js +0 -13
- package/theme/lumo/vaadin-menu-bar-styles.d.ts +0 -1
- package/theme/lumo/vaadin-menu-bar-styles.js +0 -17
- package/theme/lumo/vaadin-menu-bar.d.ts +0 -6
- package/theme/lumo/vaadin-menu-bar.js +0 -6
|
@@ -7,21 +7,22 @@ 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';
|
|
13
|
+
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
12
14
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
13
|
-
import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
17
18
|
*
|
|
18
19
|
* @customElement
|
|
19
20
|
* @extends HTMLElement
|
|
20
|
-
* @mixes
|
|
21
|
+
* @mixes ContextMenuMixin
|
|
21
22
|
* @mixes ThemePropertyMixin
|
|
22
23
|
* @protected
|
|
23
24
|
*/
|
|
24
|
-
class MenuBarSubmenu extends
|
|
25
|
+
class MenuBarSubmenu extends ContextMenuMixin(ThemePropertyMixin(PolylitMixin(LitElement))) {
|
|
25
26
|
static get is() {
|
|
26
27
|
return 'vaadin-menu-bar-submenu';
|
|
27
28
|
}
|
|
@@ -38,20 +39,94 @@ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitEle
|
|
|
38
39
|
`;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
static get properties() {
|
|
43
|
+
return {
|
|
44
|
+
isRoot: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
reflectToAttribute: true,
|
|
47
|
+
sync: true,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
|
|
55
|
+
this.openOn = 'opensubmenu';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Tag name prefix used by overlay, list-box and items.
|
|
60
|
+
* @protected
|
|
61
|
+
* @return {string}
|
|
62
|
+
*/
|
|
63
|
+
get _tagNamePrefix() {
|
|
64
|
+
return 'vaadin-menu-bar';
|
|
65
|
+
}
|
|
66
|
+
|
|
41
67
|
/** @protected */
|
|
42
68
|
render() {
|
|
43
|
-
return html
|
|
69
|
+
return html`
|
|
70
|
+
<vaadin-menu-bar-overlay
|
|
71
|
+
id="overlay"
|
|
72
|
+
.owner="${this}"
|
|
73
|
+
.opened="${this.opened}"
|
|
74
|
+
.model="${this._context}"
|
|
75
|
+
.modeless="${this._modeless}"
|
|
76
|
+
.renderer="${this.__itemsRenderer}"
|
|
77
|
+
.withBackdrop="${this._phone}"
|
|
78
|
+
.positionTarget="${this._positionTarget}"
|
|
79
|
+
?no-horizontal-overlap="${!this.isRoot}"
|
|
80
|
+
?phone="${this._phone}"
|
|
81
|
+
theme="${ifDefined(this._theme)}"
|
|
82
|
+
exportparts="backdrop, overlay, content"
|
|
83
|
+
@opened-changed="${this._onOverlayOpened}"
|
|
84
|
+
@vaadin-overlay-open="${this._onVaadinOverlayOpen}"
|
|
85
|
+
>
|
|
86
|
+
<slot name="overlay"></slot>
|
|
87
|
+
<slot name="submenu" slot="submenu"></slot>
|
|
88
|
+
</vaadin-menu-bar-overlay>
|
|
89
|
+
`;
|
|
44
90
|
}
|
|
45
91
|
|
|
46
92
|
/**
|
|
93
|
+
* Overriding the observer to not add global "contextmenu" listener.
|
|
94
|
+
* @override
|
|
95
|
+
*/
|
|
96
|
+
_openedChanged() {
|
|
97
|
+
// Do nothing
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Overriding the public method to reset expanded button state.
|
|
102
|
+
*/
|
|
103
|
+
close() {
|
|
104
|
+
super.close();
|
|
105
|
+
|
|
106
|
+
// Only handle 1st level submenu
|
|
107
|
+
if (this.hasAttribute('is-root')) {
|
|
108
|
+
this.parentElement._close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Override method from `ContextMenuMixin` to prevent closing
|
|
114
|
+
* sub-menu on the same click event that was used to open it.
|
|
115
|
+
*
|
|
116
|
+
* @param {Event} event
|
|
117
|
+
* @return {boolean}
|
|
47
118
|
* @protected
|
|
48
119
|
* @override
|
|
49
120
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
121
|
+
_shouldCloseOnOutsideClick(event) {
|
|
122
|
+
if (this.hasAttribute('is-root') && event.composedPath().includes(this.listenOn)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return super._shouldCloseOnOutsideClick(event);
|
|
54
127
|
}
|
|
55
128
|
}
|
|
56
129
|
|
|
57
130
|
defineCustomElement(MenuBarSubmenu);
|
|
131
|
+
|
|
132
|
+
export { MenuBarSubmenu };
|
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
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-menu-bar-submenu.js';
|
|
7
7
|
import './vaadin-menu-bar-button.js';
|
|
8
|
-
import {
|
|
8
|
+
import { html, LitElement } from 'lit';
|
|
9
9
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
11
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
12
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
13
14
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
+
import { menuBarStyles } from './styles/vaadin-menu-bar-base-styles.js';
|
|
14
16
|
import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -20,13 +22,13 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
20
22
|
*
|
|
21
23
|
* To create the menu bar, first add the component to the page:
|
|
22
24
|
*
|
|
23
|
-
* ```
|
|
25
|
+
* ```html
|
|
24
26
|
* <vaadin-menu-bar></vaadin-menu-bar>
|
|
25
27
|
* ```
|
|
26
28
|
*
|
|
27
29
|
* And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
|
|
28
30
|
*
|
|
29
|
-
* ```
|
|
31
|
+
* ```js
|
|
30
32
|
* document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
|
|
31
33
|
* ```
|
|
32
34
|
*
|
|
@@ -55,7 +57,7 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
55
57
|
* - `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
|
|
56
58
|
* - `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
57
59
|
* - `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
|
|
58
|
-
* - `<vaadin-menu-bar-
|
|
60
|
+
* - `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](#/elements/vaadin-context-menu).
|
|
59
61
|
*
|
|
60
62
|
* The `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes
|
|
61
63
|
* on top of the built-in `<vaadin-item>` state attributes:
|
|
@@ -64,9 +66,6 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
64
66
|
* ---------- |-------------
|
|
65
67
|
* `expanded` | Expanded parent item.
|
|
66
68
|
*
|
|
67
|
-
* Note: the `theme` attribute value set on `<vaadin-menu-bar>` is
|
|
68
|
-
* propagated to the internal components listed above.
|
|
69
|
-
*
|
|
70
69
|
* @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
71
70
|
*
|
|
72
71
|
* @customElement
|
|
@@ -75,39 +74,24 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
75
74
|
* @mixes MenuBarMixin
|
|
76
75
|
* @mixes ThemableMixin
|
|
77
76
|
*/
|
|
78
|
-
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
77
|
+
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
79
78
|
static get is() {
|
|
80
79
|
return 'vaadin-menu-bar';
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
static get styles() {
|
|
84
|
-
return
|
|
85
|
-
:host {
|
|
86
|
-
display: block;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
:host([hidden]) {
|
|
90
|
-
display: none !important;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[part='container'] {
|
|
94
|
-
position: relative;
|
|
95
|
-
display: flex;
|
|
96
|
-
width: 100%;
|
|
97
|
-
flex-wrap: nowrap;
|
|
98
|
-
overflow: hidden;
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
83
|
+
return menuBarStyles;
|
|
101
84
|
}
|
|
102
85
|
|
|
103
86
|
/** @protected */
|
|
104
87
|
render() {
|
|
105
88
|
return html`
|
|
106
|
-
<div part="container">
|
|
89
|
+
<div part="container" @click="${this.__onButtonClick}" @mouseover="${this._onMouseOver}">
|
|
107
90
|
<slot></slot>
|
|
108
91
|
<slot name="overflow"></slot>
|
|
109
92
|
</div>
|
|
110
|
-
|
|
93
|
+
|
|
94
|
+
<slot name="submenu"></slot>
|
|
111
95
|
|
|
112
96
|
<slot name="tooltip"></slot>
|
|
113
97
|
`;
|
package/vaadin-menu-bar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './src/vaadin-menu-bar.js';
|
|
2
2
|
export * from './src/vaadin-menu-bar.js';
|
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-alpha21",
|
|
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-alpha21/#/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-alpha21/#/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-alpha21/#/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-alpha21/#/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-alpha21/#/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",
|
|
@@ -30,17 +30,6 @@
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
{
|
|
34
|
-
"name": "overlay-class",
|
|
35
|
-
"description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
|
|
36
|
-
"value": {
|
|
37
|
-
"type": [
|
|
38
|
-
"string",
|
|
39
|
-
"null",
|
|
40
|
-
"undefined"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
33
|
{
|
|
45
34
|
"name": "open-on-hover",
|
|
46
35
|
"description": "If true, the submenu will open on hover (mouseover) instead of click.",
|
|
@@ -101,7 +90,7 @@
|
|
|
101
90
|
},
|
|
102
91
|
{
|
|
103
92
|
"name": "i18n",
|
|
104
|
-
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n
|
|
93
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n moreOptions: 'More options'\n}\n```",
|
|
105
94
|
"value": {
|
|
106
95
|
"type": [
|
|
107
96
|
"MenuBarI18n"
|
|
@@ -110,24 +99,13 @@
|
|
|
110
99
|
},
|
|
111
100
|
{
|
|
112
101
|
"name": "items",
|
|
113
|
-
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n
|
|
102
|
+
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```js\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```",
|
|
114
103
|
"value": {
|
|
115
104
|
"type": [
|
|
116
105
|
"Array.<MenuBarItem>"
|
|
117
106
|
]
|
|
118
107
|
}
|
|
119
108
|
},
|
|
120
|
-
{
|
|
121
|
-
"name": "overlayClass",
|
|
122
|
-
"description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
|
|
123
|
-
"value": {
|
|
124
|
-
"type": [
|
|
125
|
-
"string",
|
|
126
|
-
"null",
|
|
127
|
-
"undefined"
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
109
|
{
|
|
132
110
|
"name": "openOnHover",
|
|
133
111
|
"description": "If true, the submenu will open on hover (mouseover) instead of click.",
|
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-alpha21",
|
|
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-alpha21/#/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-alpha21/#/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-alpha21/#/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-alpha21/#/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-alpha21/#/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
|
{
|
|
@@ -49,21 +49,14 @@
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"name": ".i18n",
|
|
52
|
-
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n
|
|
52
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n moreOptions: 'More options'\n}\n```",
|
|
53
53
|
"value": {
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": ".items",
|
|
59
|
-
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n
|
|
60
|
-
"value": {
|
|
61
|
-
"kind": "expression"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"name": ".overlayClass",
|
|
66
|
-
"description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
|
|
59
|
+
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```js\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```",
|
|
67
60
|
"value": {
|
|
68
61
|
"kind": "expression"
|
|
69
62
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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 { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
7
|
-
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @polymerMixin
|
|
11
|
-
* @mixes ContextMenuMixin
|
|
12
|
-
* @mixes OverlayClassMixin
|
|
13
|
-
*/
|
|
14
|
-
export const SubMenuMixin = (superClass) =>
|
|
15
|
-
class SubMenuMixinClass extends ContextMenuMixin(OverlayClassMixin(superClass)) {
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
|
|
19
|
-
this.openOn = 'opensubmenu';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Tag name prefix used by overlay, list-box and items.
|
|
24
|
-
* @protected
|
|
25
|
-
* @return {string}
|
|
26
|
-
*/
|
|
27
|
-
get _tagNamePrefix() {
|
|
28
|
-
return 'vaadin-menu-bar';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Overriding the observer to not add global "contextmenu" listener.
|
|
33
|
-
*/
|
|
34
|
-
_openedChanged(opened) {
|
|
35
|
-
this._overlayElement.opened = opened;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Overriding the public method to reset expanded button state.
|
|
40
|
-
*/
|
|
41
|
-
close() {
|
|
42
|
-
super.close();
|
|
43
|
-
|
|
44
|
-
// Only handle 1st level submenu
|
|
45
|
-
if (this.hasAttribute('is-root')) {
|
|
46
|
-
this.getRootNode().host._close();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Override method from `ContextMenuMixin` to prevent closing
|
|
52
|
-
* sub-menu on the same click event that was used to open it.
|
|
53
|
-
*
|
|
54
|
-
* @param {Event} event
|
|
55
|
-
* @return {boolean}
|
|
56
|
-
* @protected
|
|
57
|
-
* @override
|
|
58
|
-
*/
|
|
59
|
-
_shouldCloseOnOutsideClick(event) {
|
|
60
|
-
if (this.hasAttribute('is-root') && event.composedPath().includes(this.listenOn)) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return super._shouldCloseOnOutsideClick(event);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { button } from '@vaadin/button/theme/lumo/vaadin-button-styles.js';
|
|
2
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
3
|
-
|
|
4
|
-
const menuBarButton = css`
|
|
5
|
-
:host {
|
|
6
|
-
margin: calc(var(--lumo-space-xs) / 2);
|
|
7
|
-
margin-left: 0;
|
|
8
|
-
border-radius: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
[part='label'] {
|
|
12
|
-
width: 100%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* NOTE(web-padawan): avoid using shorthand padding property for IE11 */
|
|
16
|
-
[part='label'] ::slotted(vaadin-menu-bar-item) {
|
|
17
|
-
justify-content: center;
|
|
18
|
-
background-color: transparent;
|
|
19
|
-
height: var(--lumo-button-size);
|
|
20
|
-
margin: 0 calc((var(--lumo-size-m) / 3 + var(--lumo-border-radius-m) / 2) * -1);
|
|
21
|
-
padding-left: calc(var(--lumo-size-m) / 3 + var(--lumo-border-radius-m) / 2);
|
|
22
|
-
padding-right: calc(var(--lumo-size-m) / 3 + var(--lumo-border-radius-m) / 2);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host([theme~='small']) [part='label'] ::slotted(vaadin-menu-bar-item) {
|
|
26
|
-
min-height: var(--lumo-size-s);
|
|
27
|
-
margin: 0 calc((var(--lumo-size-s) / 3 + var(--lumo-border-radius-m) / 2) * -1);
|
|
28
|
-
padding-left: calc(var(--lumo-size-s) / 3 + var(--lumo-border-radius-m) / 2);
|
|
29
|
-
padding-right: calc(var(--lumo-size-s) / 3 + var(--lumo-border-radius-m) / 2);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
:host([theme~='tertiary']) [part='label'] ::slotted(vaadin-menu-bar-item) {
|
|
33
|
-
margin: 0 calc((var(--lumo-button-size) / 6) * -1);
|
|
34
|
-
padding-left: calc(var(--lumo-button-size) / 6);
|
|
35
|
-
padding-right: calc(var(--lumo-button-size) / 6);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
:host([theme~='tertiary-inline']) {
|
|
39
|
-
margin-top: calc(var(--lumo-space-xs) / 2);
|
|
40
|
-
margin-bottom: calc(var(--lumo-space-xs) / 2);
|
|
41
|
-
margin-right: calc(var(--lumo-space-xs) / 2);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
:host([theme~='tertiary-inline']) [part='label'] ::slotted(vaadin-menu-bar-item) {
|
|
45
|
-
margin: 0;
|
|
46
|
-
padding: 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
:host([first-visible]) {
|
|
50
|
-
border-radius: var(--lumo-border-radius-m) 0 0 var(--lumo-border-radius-m);
|
|
51
|
-
|
|
52
|
-
/* Needed to retain the focus-ring with border-radius */
|
|
53
|
-
margin-left: calc(var(--lumo-space-xs) / 2);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
:host([last-visible]),
|
|
57
|
-
:host([slot='overflow']) {
|
|
58
|
-
border-radius: 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
:host([theme~='tertiary']),
|
|
62
|
-
:host([theme~='tertiary-inline']) {
|
|
63
|
-
border-radius: var(--lumo-border-radius-m);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
:host([slot='overflow']) {
|
|
67
|
-
min-width: var(--lumo-button-size);
|
|
68
|
-
padding-left: calc(var(--lumo-button-size) / 4);
|
|
69
|
-
padding-right: calc(var(--lumo-button-size) / 4);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([slot='overflow']) ::slotted(*) {
|
|
73
|
-
font-size: var(--lumo-font-size-xl);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
:host([slot='overflow']) [part='prefix'],
|
|
77
|
-
:host([slot='overflow']) [part='suffix'] {
|
|
78
|
-
margin-left: 0;
|
|
79
|
-
margin-right: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix'] {
|
|
83
|
-
margin-inline-start: 0;
|
|
84
|
-
width: 1em;
|
|
85
|
-
height: 1em;
|
|
86
|
-
line-height: 1;
|
|
87
|
-
font-size: var(--lumo-icon-size-s);
|
|
88
|
-
position: relative;
|
|
89
|
-
inset-inline-start: 0.15em;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* prettier-ignore */
|
|
93
|
-
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix']::after {
|
|
94
|
-
font-family: lumo-icons;
|
|
95
|
-
content: var(--lumo-icons-dropdown);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* prettier-ignore */
|
|
99
|
-
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[theme~='tertiary'][aria-haspopup]) [part='suffix'] {
|
|
100
|
-
inset-inline-start: 0.05em;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/* prettier-ignore */
|
|
104
|
-
:host([theme~='dropdown-indicators']:not([slot='overflow']):not([theme~='icon'])[theme~='tertiary-inline'][aria-haspopup]) [part='suffix'] {
|
|
105
|
-
inset-inline-start: 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* RTL styles */
|
|
109
|
-
:host([dir='rtl']) {
|
|
110
|
-
margin-left: calc(var(--lumo-space-xs) / 2);
|
|
111
|
-
margin-right: 0;
|
|
112
|
-
border-radius: 0;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:host([dir='rtl'][first-visible]) {
|
|
116
|
-
border-radius: 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0;
|
|
117
|
-
margin-right: calc(var(--lumo-space-xs) / 2);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
:host([dir='rtl'][last-visible]),
|
|
121
|
-
:host([dir='rtl'][slot='overflow']) {
|
|
122
|
-
border-radius: var(--lumo-border-radius-m) 0 0 var(--lumo-border-radius-m);
|
|
123
|
-
}
|
|
124
|
-
`;
|
|
125
|
-
|
|
126
|
-
registerStyles('vaadin-menu-bar-button', [button, menuBarButton], {
|
|
127
|
-
moduleId: 'lumo-menu-bar-button',
|
|
128
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
2
|
-
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
3
|
-
import { contextMenuItem } from '@vaadin/context-menu/theme/lumo/vaadin-context-menu-item-styles.js';
|
|
4
|
-
import { item } from '@vaadin/item/theme/lumo/vaadin-item-styles.js';
|
|
5
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
6
|
-
|
|
7
|
-
const menuBarItem = css`
|
|
8
|
-
[part='content'] {
|
|
9
|
-
display: flex;
|
|
10
|
-
/* tweak to inherit centering from menu bar button */
|
|
11
|
-
align-items: inherit;
|
|
12
|
-
justify-content: inherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
[part='content'] ::slotted(vaadin-icon) {
|
|
16
|
-
display: inline-block;
|
|
17
|
-
width: var(--lumo-icon-size-m);
|
|
18
|
-
height: var(--lumo-icon-size-m);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
[part='content'] ::slotted(vaadin-icon[icon^='vaadin:']) {
|
|
22
|
-
padding: var(--lumo-space-xs);
|
|
23
|
-
box-sizing: border-box !important;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
registerStyles('vaadin-menu-bar-item', [item, contextMenuItem, menuBarItem], { moduleId: 'lumo-menu-bar-item' });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { contextMenuListBox } from '@vaadin/context-menu/theme/lumo/vaadin-context-menu-list-box-styles.js';
|
|
2
|
-
import { listBox } from '@vaadin/list-box/theme/lumo/vaadin-list-box-styles.js';
|
|
3
|
-
import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
|
-
|
|
5
|
-
registerStyles('vaadin-menu-bar-list-box', [listBox, contextMenuListBox], { moduleId: 'lumo-menu-bar-list-box' });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|