@vaadin/menu-bar 24.6.0-rc1 → 24.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "24.6.0
|
|
3
|
+
"version": "24.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/a11y-base": "24.6.0
|
|
41
|
-
"@vaadin/button": "24.6.0
|
|
42
|
-
"@vaadin/component-base": "24.6.0
|
|
43
|
-
"@vaadin/context-menu": "24.6.0
|
|
44
|
-
"@vaadin/item": "24.6.0
|
|
45
|
-
"@vaadin/list-box": "24.6.0
|
|
46
|
-
"@vaadin/overlay": "24.6.0
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.6.0
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.6.0
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.6.0
|
|
40
|
+
"@vaadin/a11y-base": "~24.6.0",
|
|
41
|
+
"@vaadin/button": "~24.6.0",
|
|
42
|
+
"@vaadin/component-base": "~24.6.0",
|
|
43
|
+
"@vaadin/context-menu": "~24.6.0",
|
|
44
|
+
"@vaadin/item": "~24.6.0",
|
|
45
|
+
"@vaadin/list-box": "~24.6.0",
|
|
46
|
+
"@vaadin/overlay": "~24.6.0",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "~24.6.0",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "~24.6.0",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "~24.6.0",
|
|
50
50
|
"lit": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vaadin/chai-plugins": "24.6.0
|
|
54
|
-
"@vaadin/icon": "24.6.0
|
|
53
|
+
"@vaadin/chai-plugins": "~24.6.0",
|
|
54
|
+
"@vaadin/icon": "~24.6.0",
|
|
55
55
|
"@vaadin/testing-helpers": "^1.0.0",
|
|
56
56
|
"sinon": "^18.0.0"
|
|
57
57
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"web-types.json",
|
|
60
60
|
"web-types.lit.json"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c0b38aa981494d04fac64da35aa3890ad72551ea"
|
|
63
63
|
}
|
|
@@ -8,22 +8,20 @@ import './vaadin-lit-menu-bar-list-box.js';
|
|
|
8
8
|
import './vaadin-lit-menu-bar-overlay.js';
|
|
9
9
|
import { css, html, LitElement } from 'lit';
|
|
10
10
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
|
-
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
12
11
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
|
-
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
14
12
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
13
|
+
import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
18
17
|
*
|
|
19
18
|
* @customElement
|
|
20
19
|
* @extends HTMLElement
|
|
21
|
-
* @mixes
|
|
22
|
-
* @mixes OverlayClassMixin
|
|
20
|
+
* @mixes SubMenuMixin
|
|
23
21
|
* @mixes ThemePropertyMixin
|
|
24
22
|
* @protected
|
|
25
23
|
*/
|
|
26
|
-
class MenuBarSubmenu extends
|
|
24
|
+
class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitElement))) {
|
|
27
25
|
static get is() {
|
|
28
26
|
return 'vaadin-menu-bar-submenu';
|
|
29
27
|
}
|
|
@@ -40,21 +38,6 @@ class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ThemePropertyMix
|
|
|
40
38
|
`;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
|
|
46
|
-
this.openOn = 'opensubmenu';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Tag name prefix used by overlay, list-box and items.
|
|
51
|
-
* @protected
|
|
52
|
-
* @return {string}
|
|
53
|
-
*/
|
|
54
|
-
get _tagNamePrefix() {
|
|
55
|
-
return 'vaadin-menu-bar';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
41
|
/** @protected */
|
|
59
42
|
render() {
|
|
60
43
|
return html`<slot id="slot"></slot>`;
|
|
@@ -69,25 +52,6 @@ class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ThemePropertyMix
|
|
|
69
52
|
root.appendChild(this._overlayElement);
|
|
70
53
|
return root;
|
|
71
54
|
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Overriding the observer to not add global "contextmenu" listener.
|
|
75
|
-
*/
|
|
76
|
-
_openedChanged(opened) {
|
|
77
|
-
this._overlayElement.opened = opened;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Overriding the public method to reset expanded button state.
|
|
82
|
-
*/
|
|
83
|
-
close() {
|
|
84
|
-
super.close();
|
|
85
|
-
|
|
86
|
-
// Only handle 1st level submenu
|
|
87
|
-
if (this.hasAttribute('is-root')) {
|
|
88
|
-
this.getRootNode().host._close();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
55
|
}
|
|
92
56
|
|
|
93
57
|
defineCustomElement(MenuBarSubmenu);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2024 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
|
+
};
|
|
@@ -9,22 +9,20 @@ import './vaadin-menu-bar-overlay.js';
|
|
|
9
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
10
10
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
11
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
-
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
13
|
-
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
14
12
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
13
|
+
import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
18
17
|
*
|
|
19
18
|
* @customElement
|
|
20
19
|
* @extends HTMLElement
|
|
21
|
-
* @mixes ContextMenuMixin
|
|
22
20
|
* @mixes ControllerMixin
|
|
23
|
-
* @mixes
|
|
21
|
+
* @mixes SubMenuMixin
|
|
24
22
|
* @mixes ThemePropertyMixin
|
|
25
23
|
* @protected
|
|
26
24
|
*/
|
|
27
|
-
class MenuBarSubmenu extends
|
|
25
|
+
class MenuBarSubmenu extends SubMenuMixin(ControllerMixin(ThemePropertyMixin(PolymerElement))) {
|
|
28
26
|
static get is() {
|
|
29
27
|
return 'vaadin-menu-bar-submenu';
|
|
30
28
|
}
|
|
@@ -45,21 +43,6 @@ class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ControllerMixin(
|
|
|
45
43
|
`;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
constructor() {
|
|
49
|
-
super();
|
|
50
|
-
|
|
51
|
-
this.openOn = 'opensubmenu';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Tag name prefix used by overlay, list-box and items.
|
|
56
|
-
* @protected
|
|
57
|
-
* @return {string}
|
|
58
|
-
*/
|
|
59
|
-
get _tagNamePrefix() {
|
|
60
|
-
return 'vaadin-menu-bar';
|
|
61
|
-
}
|
|
62
|
-
|
|
63
46
|
/**
|
|
64
47
|
* @param {DocumentFragment} dom
|
|
65
48
|
* @return {ShadowRoot}
|
|
@@ -72,25 +55,6 @@ class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ControllerMixin(
|
|
|
72
55
|
root.appendChild(this._overlayElement);
|
|
73
56
|
return root;
|
|
74
57
|
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Overriding the observer to not add global "contextmenu" listener.
|
|
78
|
-
*/
|
|
79
|
-
_openedChanged(opened) {
|
|
80
|
-
this._overlayElement.opened = opened;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Overriding the public method to reset expanded button state.
|
|
85
|
-
*/
|
|
86
|
-
close() {
|
|
87
|
-
super.close();
|
|
88
|
-
|
|
89
|
-
// Only handle 1st level submenu
|
|
90
|
-
if (this.hasAttribute('is-root')) {
|
|
91
|
-
this.getRootNode().host._close();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
58
|
}
|
|
95
59
|
|
|
96
60
|
defineCustomElement(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": "24.6.0
|
|
4
|
+
"version": "24.6.0",
|
|
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/24.6.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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/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/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.6.0/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-overlay).\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.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
|
|
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": "24.6.0
|
|
4
|
+
"version": "24.6.0",
|
|
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/24.6.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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/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/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.6.0/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0/#/elements/vaadin-overlay).\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.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|