@vaadin/menu-bar 25.0.0-alpha12 → 25.0.0-alpha13
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 +14 -14
- package/src/vaadin-menu-bar-button.d.ts +19 -0
- package/src/vaadin-menu-bar-button.js +2 -0
- package/src/vaadin-menu-bar-mixin.d.ts +3 -10
- package/src/vaadin-menu-bar-mixin.js +0 -14
- package/src/vaadin-menu-bar-submenu.d.ts +20 -0
- package/src/vaadin-menu-bar-submenu.js +57 -3
- package/web-types.json +2 -24
- package/web-types.lit.json +2 -9
- package/src/vaadin-menu-bar-submenu-mixin.js +0 -66
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-alpha13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
38
|
-
"@vaadin/button": "25.0.0-
|
|
39
|
-
"@vaadin/component-base": "25.0.0-
|
|
40
|
-
"@vaadin/context-menu": "25.0.0-
|
|
41
|
-
"@vaadin/item": "25.0.0-
|
|
42
|
-
"@vaadin/list-box": "25.0.0-
|
|
43
|
-
"@vaadin/overlay": "25.0.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
37
|
+
"@vaadin/a11y-base": "25.0.0-alpha13",
|
|
38
|
+
"@vaadin/button": "25.0.0-alpha13",
|
|
39
|
+
"@vaadin/component-base": "25.0.0-alpha13",
|
|
40
|
+
"@vaadin/context-menu": "25.0.0-alpha13",
|
|
41
|
+
"@vaadin/item": "25.0.0-alpha13",
|
|
42
|
+
"@vaadin/list-box": "25.0.0-alpha13",
|
|
43
|
+
"@vaadin/overlay": "25.0.0-alpha13",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha13",
|
|
45
45
|
"lit": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
49
|
-
"@vaadin/icon": "25.0.0-
|
|
50
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
48
|
+
"@vaadin/chai-plugins": "25.0.0-alpha13",
|
|
49
|
+
"@vaadin/icon": "25.0.0-alpha13",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha13",
|
|
51
51
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha13",
|
|
53
53
|
"sinon": "^18.0.0"
|
|
54
54
|
},
|
|
55
55
|
"web-types": [
|
|
56
56
|
"web-types.json",
|
|
57
57
|
"web-types.lit.json"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "182de596226343392135468f021bbce9e6402011"
|
|
60
60
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { Button } from '@vaadin/button/src/vaadin-button.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
10
|
+
*/
|
|
11
|
+
declare class MenuBarButton extends Button {}
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'vaadin-menu-bar-button': MenuBarButton;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { MenuBarButton };
|
|
@@ -10,6 +10,7 @@ import type { KeyboardDirectionMixinClass } from '@vaadin/a11y-base/src/keyboard
|
|
|
10
10
|
import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
|
|
11
11
|
import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
12
12
|
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
13
|
+
import type { MenuBarButton } from './vaadin-menu-bar-button.js';
|
|
13
14
|
|
|
14
15
|
export type MenuBarItem<TItemData extends object = object> = {
|
|
15
16
|
/**
|
|
@@ -134,14 +135,6 @@ export declare class MenuBarMixinClass<TItem extends MenuBarItem = MenuBarItem>
|
|
|
134
135
|
*/
|
|
135
136
|
i18n: MenuBarI18n;
|
|
136
137
|
|
|
137
|
-
/**
|
|
138
|
-
* A space-delimited list of CSS class names
|
|
139
|
-
* to set on each sub-menu overlay element.
|
|
140
|
-
*
|
|
141
|
-
* @attr {string} overlay-class
|
|
142
|
-
*/
|
|
143
|
-
overlayClass: string;
|
|
144
|
-
|
|
145
138
|
/**
|
|
146
139
|
* If true, the submenu will open on hover (mouseover) instead of click.
|
|
147
140
|
* @attr {boolean} open-on-hover
|
|
@@ -167,11 +160,11 @@ export declare class MenuBarMixinClass<TItem extends MenuBarItem = MenuBarItem>
|
|
|
167
160
|
*/
|
|
168
161
|
close(): void;
|
|
169
162
|
|
|
170
|
-
protected readonly _buttons:
|
|
163
|
+
protected readonly _buttons: MenuBarButton[];
|
|
171
164
|
|
|
172
165
|
protected readonly _container: HTMLElement;
|
|
173
166
|
|
|
174
|
-
protected readonly _overflow:
|
|
167
|
+
protected readonly _overflow: MenuBarButton;
|
|
175
168
|
|
|
176
169
|
protected _hasOverflow: boolean;
|
|
177
170
|
}
|
|
@@ -154,16 +154,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
154
154
|
value: () => [],
|
|
155
155
|
},
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* A space-delimited list of CSS class names
|
|
159
|
-
* to set on each sub-menu overlay element.
|
|
160
|
-
*
|
|
161
|
-
* @attr {string} overlay-class
|
|
162
|
-
*/
|
|
163
|
-
overlayClass: {
|
|
164
|
-
type: String,
|
|
165
|
-
},
|
|
166
|
-
|
|
167
157
|
/**
|
|
168
158
|
* If true, the submenu will open on hover (mouseover) instead of click.
|
|
169
159
|
* @attr {boolean} open-on-hover
|
|
@@ -348,10 +338,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
348
338
|
this.__updateSubMenu();
|
|
349
339
|
}
|
|
350
340
|
|
|
351
|
-
if (props.has('overlayClass')) {
|
|
352
|
-
this._subMenu.overlayClass = this.overlayClass;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
341
|
if (props.has('_theme')) {
|
|
356
342
|
this._themeChanged(this._theme);
|
|
357
343
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
7
|
+
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
11
|
+
*/
|
|
12
|
+
declare class MenuBarSubmenu extends ContextMenuMixin(ThemePropertyMixin(HTMLElement)) {}
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'vaadin-menu-bar-submenu': MenuBarSubmenu;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { MenuBarSubmenu };
|
|
@@ -10,19 +10,19 @@ import { css, html, LitElement } from 'lit';
|
|
|
10
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
12
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
|
+
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
13
14
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
14
|
-
import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
18
18
|
*
|
|
19
19
|
* @customElement
|
|
20
20
|
* @extends HTMLElement
|
|
21
|
-
* @mixes
|
|
21
|
+
* @mixes ContextMenuMixin
|
|
22
22
|
* @mixes ThemePropertyMixin
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
|
-
class MenuBarSubmenu extends
|
|
25
|
+
class MenuBarSubmenu extends ContextMenuMixin(ThemePropertyMixin(PolylitMixin(LitElement))) {
|
|
26
26
|
static get is() {
|
|
27
27
|
return 'vaadin-menu-bar-submenu';
|
|
28
28
|
}
|
|
@@ -39,6 +39,21 @@ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitEle
|
|
|
39
39
|
`;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
|
|
45
|
+
this.openOn = 'opensubmenu';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Tag name prefix used by overlay, list-box and items.
|
|
50
|
+
* @protected
|
|
51
|
+
* @return {string}
|
|
52
|
+
*/
|
|
53
|
+
get _tagNamePrefix() {
|
|
54
|
+
return 'vaadin-menu-bar';
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
/** @protected */
|
|
43
58
|
render() {
|
|
44
59
|
return html`
|
|
@@ -61,6 +76,45 @@ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitEle
|
|
|
61
76
|
</vaadin-menu-bar-overlay>
|
|
62
77
|
`;
|
|
63
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Overriding the observer to not add global "contextmenu" listener.
|
|
82
|
+
* @override
|
|
83
|
+
*/
|
|
84
|
+
_openedChanged() {
|
|
85
|
+
// Do nothing
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Overriding the public method to reset expanded button state.
|
|
90
|
+
*/
|
|
91
|
+
close() {
|
|
92
|
+
super.close();
|
|
93
|
+
|
|
94
|
+
// Only handle 1st level submenu
|
|
95
|
+
if (this.hasAttribute('is-root')) {
|
|
96
|
+
this.parentElement._close();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Override method from `ContextMenuMixin` to prevent closing
|
|
102
|
+
* sub-menu on the same click event that was used to open it.
|
|
103
|
+
*
|
|
104
|
+
* @param {Event} event
|
|
105
|
+
* @return {boolean}
|
|
106
|
+
* @protected
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
109
|
+
_shouldCloseOnOutsideClick(event) {
|
|
110
|
+
if (this.hasAttribute('is-root') && event.composedPath().includes(this.listenOn)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return super._shouldCloseOnOutsideClick(event);
|
|
115
|
+
}
|
|
64
116
|
}
|
|
65
117
|
|
|
66
118
|
defineCustomElement(MenuBarSubmenu);
|
|
119
|
+
|
|
120
|
+
export { MenuBarSubmenu };
|
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-alpha13",
|
|
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```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-
|
|
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-alpha13/#/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-alpha13/#/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-alpha13/#/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-alpha13/#/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-alpha13/#/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.",
|
|
@@ -117,17 +106,6 @@
|
|
|
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-alpha13",
|
|
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```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-
|
|
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-alpha13/#/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-alpha13/#/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-alpha13/#/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-alpha13/#/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-alpha13/#/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
|
{
|
|
@@ -61,13 +61,6 @@
|
|
|
61
61
|
"kind": "expression"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
{
|
|
65
|
-
"name": ".overlayClass",
|
|
66
|
-
"description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
|
|
67
|
-
"value": {
|
|
68
|
-
"kind": "expression"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
64
|
{
|
|
72
65
|
"name": "@item-selected",
|
|
73
66
|
"description": "Fired when either a submenu item or menu bar button without nested children is clicked.",
|
|
@@ -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() {
|
|
35
|
-
// Do nothing
|
|
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.parentElement._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
|
-
};
|