@vaadin/menu-bar 24.4.0-alpha9 → 24.4.0-beta2
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/README.md +0 -1
- package/package.json +16 -13
- package/src/vaadin-lit-menu-bar-button.js +58 -0
- package/src/vaadin-lit-menu-bar-item.js +62 -0
- package/src/vaadin-lit-menu-bar-list-box.js +87 -0
- package/src/vaadin-lit-menu-bar-overlay.js +65 -0
- package/src/vaadin-lit-menu-bar-submenu.js +93 -0
- package/src/vaadin-lit-menu-bar.js +83 -0
- package/src/vaadin-menu-bar-button.js +13 -0
- package/src/vaadin-menu-bar-mixin.d.ts +7 -0
- package/src/vaadin-menu-bar-mixin.js +75 -16
- package/theme/lumo/vaadin-lit-menu-bar.d.ts +6 -0
- package/theme/lumo/vaadin-lit-menu-bar.js +6 -0
- package/theme/lumo/vaadin-menu-bar-button-styles.js +4 -4
- package/theme/lumo/vaadin-menu-bar-styles.js +1 -1
- package/theme/material/vaadin-lit-menu-bar.d.ts +6 -0
- package/theme/material/vaadin-lit-menu-bar.js +6 -0
- package/theme/material/vaadin-menu-bar-button-styles.js +6 -6
- package/theme/material/vaadin-menu-bar-styles.js +1 -1
- package/web-types.json +24 -2
- package/web-types.lit.json +9 -2
package/README.md
CHANGED
|
@@ -5,7 +5,6 @@ A web component for creating a horizontal button bar with hierarchical drop-down
|
|
|
5
5
|
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/components/menu-bar)
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@vaadin/menu-bar)
|
|
8
|
-
[](https://discord.gg/PHmkCKC)
|
|
9
8
|
|
|
10
9
|
```html
|
|
11
10
|
<vaadin-menu-bar></vaadin-menu-bar>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "24.4.0-
|
|
3
|
+
"version": "24.4.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"theme",
|
|
25
25
|
"vaadin-*.d.ts",
|
|
26
26
|
"vaadin-*.js",
|
|
27
|
+
"!vaadin-lit-*.d.ts",
|
|
28
|
+
"!vaadin-lit-*.js",
|
|
27
29
|
"web-types.json",
|
|
28
30
|
"web-types.lit.json"
|
|
29
31
|
],
|
|
@@ -37,20 +39,21 @@
|
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
41
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/a11y-base": "24.4.0-
|
|
41
|
-
"@vaadin/button": "24.4.0-
|
|
42
|
-
"@vaadin/component-base": "24.4.0-
|
|
43
|
-
"@vaadin/context-menu": "24.4.0-
|
|
44
|
-
"@vaadin/item": "24.4.0-
|
|
45
|
-
"@vaadin/list-box": "24.4.0-
|
|
46
|
-
"@vaadin/overlay": "24.4.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.4.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.4.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.4.0-
|
|
42
|
+
"@vaadin/a11y-base": "24.4.0-beta2",
|
|
43
|
+
"@vaadin/button": "24.4.0-beta2",
|
|
44
|
+
"@vaadin/component-base": "24.4.0-beta2",
|
|
45
|
+
"@vaadin/context-menu": "24.4.0-beta2",
|
|
46
|
+
"@vaadin/item": "24.4.0-beta2",
|
|
47
|
+
"@vaadin/list-box": "24.4.0-beta2",
|
|
48
|
+
"@vaadin/overlay": "24.4.0-beta2",
|
|
49
|
+
"@vaadin/vaadin-lumo-styles": "24.4.0-beta2",
|
|
50
|
+
"@vaadin/vaadin-material-styles": "24.4.0-beta2",
|
|
51
|
+
"@vaadin/vaadin-themable-mixin": "24.4.0-beta2",
|
|
52
|
+
"lit": "^3.0.0"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/icon": "24.4.0-
|
|
56
|
+
"@vaadin/icon": "24.4.0-beta2",
|
|
54
57
|
"@vaadin/testing-helpers": "^0.6.0",
|
|
55
58
|
"sinon": "^13.0.2"
|
|
56
59
|
},
|
|
@@ -58,5 +61,5 @@
|
|
|
58
61
|
"web-types.json",
|
|
59
62
|
"web-types.lit.json"
|
|
60
63
|
],
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "886ab2e7ccb8353ac3b7a42ebb96dfe2d1211556"
|
|
62
65
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { Button } from '@vaadin/button/src/vaadin-lit-button.js';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
12
|
+
*
|
|
13
|
+
* @customElement
|
|
14
|
+
* @extends Button
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
class MenuBarButton extends Button {
|
|
18
|
+
static get is() {
|
|
19
|
+
return 'vaadin-menu-bar-button';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static get styles() {
|
|
23
|
+
return [
|
|
24
|
+
super.styles,
|
|
25
|
+
css`
|
|
26
|
+
:host {
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([slot='overflow']) {
|
|
31
|
+
margin-inline-end: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[part='label'] ::slotted(vaadin-menu-bar-item) {
|
|
35
|
+
position: relative;
|
|
36
|
+
z-index: 1;
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Override method inherited from `ButtonMixin` to set a flag based on whether the key
|
|
44
|
+
* is Enter and Space. Unlike mouse click, these keys should also focus the first item.
|
|
45
|
+
* This flag is used in menu bar to identify the action that triggered the click.
|
|
46
|
+
*
|
|
47
|
+
* @param {KeyboardEvent} event
|
|
48
|
+
* @protected
|
|
49
|
+
* @override
|
|
50
|
+
*/
|
|
51
|
+
_onKeyDown(event) {
|
|
52
|
+
this.__triggeredWithActiveKeys = this._activeKeys.includes(event.key);
|
|
53
|
+
super._onKeyDown(event);
|
|
54
|
+
this.__triggeredWithActiveKeys = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
defineCustomElement(MenuBarButton);
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { css, html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
11
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
15
|
+
*
|
|
16
|
+
* @customElement
|
|
17
|
+
* @extends HTMLElement
|
|
18
|
+
* @mixes DirMixin
|
|
19
|
+
* @mixes ItemMixin
|
|
20
|
+
* @mixes ThemableMixin
|
|
21
|
+
* @protected
|
|
22
|
+
*/
|
|
23
|
+
class MenuBarItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
+
static get is() {
|
|
25
|
+
return 'vaadin-menu-bar-item';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get styles() {
|
|
29
|
+
return css`
|
|
30
|
+
:host {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([hidden]) {
|
|
35
|
+
display: none !important;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @protected */
|
|
41
|
+
render() {
|
|
42
|
+
return html`
|
|
43
|
+
<span part="checkmark" aria-hidden="true"></span>
|
|
44
|
+
<div part="content">
|
|
45
|
+
<slot></slot>
|
|
46
|
+
</div>
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @protected */
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback();
|
|
53
|
+
|
|
54
|
+
// Set role in `connectedCallback()` instead of `ready()`
|
|
55
|
+
// because the role is removed when teleporting to button.
|
|
56
|
+
this.setAttribute('role', 'menuitem');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
defineCustomElement(MenuBarItem);
|
|
61
|
+
|
|
62
|
+
export { MenuBarItem };
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { css, html, LitElement } from 'lit';
|
|
7
|
+
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
8
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
15
|
+
*
|
|
16
|
+
* @customElement
|
|
17
|
+
* @extends HTMLElement
|
|
18
|
+
* @mixes DirMixin
|
|
19
|
+
* @mixes ListMixin
|
|
20
|
+
* @mixes ThemableMixin
|
|
21
|
+
* @protected
|
|
22
|
+
*/
|
|
23
|
+
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
+
static get is() {
|
|
25
|
+
return 'vaadin-menu-bar-list-box';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get styles() {
|
|
29
|
+
return css`
|
|
30
|
+
:host {
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([hidden]) {
|
|
35
|
+
display: none !important;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[part='items'] {
|
|
39
|
+
height: 100%;
|
|
40
|
+
width: 100%;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
-webkit-overflow-scrolling: touch;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static get properties() {
|
|
48
|
+
return {
|
|
49
|
+
// We don't need to define this property since super default is vertical,
|
|
50
|
+
// but we don't want it to be modified, or be shown in the API docs.
|
|
51
|
+
/** @private */
|
|
52
|
+
orientation: {
|
|
53
|
+
type: String,
|
|
54
|
+
readOnly: true,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @return {!HTMLElement}
|
|
61
|
+
* @protected
|
|
62
|
+
* @override
|
|
63
|
+
*/
|
|
64
|
+
get _scrollerElement() {
|
|
65
|
+
return this.shadowRoot.querySelector('[part="items"]');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** @protected */
|
|
69
|
+
render() {
|
|
70
|
+
return html`
|
|
71
|
+
<div part="items">
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @protected */
|
|
78
|
+
ready() {
|
|
79
|
+
super.ready();
|
|
80
|
+
|
|
81
|
+
this.setAttribute('role', 'menu');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
defineCustomElement(MenuBarListBox);
|
|
86
|
+
|
|
87
|
+
export { MenuBarListBox };
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { html, LitElement } from 'lit';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { MenuOverlayMixin } from '@vaadin/context-menu/src/vaadin-menu-overlay-mixin.js';
|
|
11
|
+
import { styles } from '@vaadin/context-menu/src/vaadin-menu-overlay-styles.js';
|
|
12
|
+
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
13
|
+
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
14
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
18
|
+
*
|
|
19
|
+
* @customElement
|
|
20
|
+
* @extends HTMLElement
|
|
21
|
+
* @mixes DirMixin
|
|
22
|
+
* @mixes MenuOverlayMixin
|
|
23
|
+
* @mixes OverlayMixin
|
|
24
|
+
* @mixes ThemableMixin
|
|
25
|
+
* @protected
|
|
26
|
+
*/
|
|
27
|
+
export class MenuBarOverlay extends MenuOverlayMixin(OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement))))) {
|
|
28
|
+
static get is() {
|
|
29
|
+
return 'vaadin-menu-bar-overlay';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static get properties() {
|
|
33
|
+
return {
|
|
34
|
+
/**
|
|
35
|
+
* When true, the overlay is visible and attached to body.
|
|
36
|
+
* This property config is overridden to set `sync: true`.
|
|
37
|
+
*/
|
|
38
|
+
opened: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
notify: true,
|
|
41
|
+
observer: '_openedChanged',
|
|
42
|
+
reflectToAttribute: true,
|
|
43
|
+
sync: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static get styles() {
|
|
49
|
+
return [overlayStyles, styles];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @protected */
|
|
53
|
+
render() {
|
|
54
|
+
return html`
|
|
55
|
+
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
56
|
+
<div part="overlay" id="overlay" tabindex="0">
|
|
57
|
+
<div part="content" id="content">
|
|
58
|
+
<slot></slot>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
defineCustomElement(MenuBarOverlay);
|
|
@@ -0,0 +1,93 @@
|
|
|
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 './vaadin-lit-menu-bar-item.js';
|
|
7
|
+
import './vaadin-lit-menu-bar-list-box.js';
|
|
8
|
+
import './vaadin-lit-menu-bar-overlay.js';
|
|
9
|
+
import { css, html, LitElement } from 'lit';
|
|
10
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
|
+
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
12
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
13
|
+
import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js';
|
|
14
|
+
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
18
|
+
*
|
|
19
|
+
* @customElement
|
|
20
|
+
* @extends HTMLElement
|
|
21
|
+
* @mixes ContextMenuMixin
|
|
22
|
+
* @mixes OverlayClassMixin
|
|
23
|
+
* @mixes ThemePropertyMixin
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ThemePropertyMixin(PolylitMixin(LitElement)))) {
|
|
27
|
+
static get is() {
|
|
28
|
+
return 'vaadin-menu-bar-submenu';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return css`
|
|
33
|
+
:host {
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([hidden]) {
|
|
38
|
+
display: none !important;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
|
|
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
|
+
/** @protected */
|
|
59
|
+
render() {
|
|
60
|
+
return html`<slot id="slot"></slot>`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @protected
|
|
65
|
+
* @override
|
|
66
|
+
*/
|
|
67
|
+
createRenderRoot() {
|
|
68
|
+
const root = super.createRenderRoot();
|
|
69
|
+
root.appendChild(this._overlayElement);
|
|
70
|
+
return root;
|
|
71
|
+
}
|
|
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
|
+
}
|
|
92
|
+
|
|
93
|
+
defineCustomElement(MenuBarSubmenu);
|
|
@@ -0,0 +1,83 @@
|
|
|
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 './vaadin-lit-menu-bar-submenu.js';
|
|
7
|
+
import './vaadin-lit-menu-bar-button.js';
|
|
8
|
+
import { css, html, LitElement } from 'lit';
|
|
9
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
|
+
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
+
import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* LitElement based version of `<vaadin-menu-bar>` web component.
|
|
18
|
+
*
|
|
19
|
+
* ## Disclaimer
|
|
20
|
+
*
|
|
21
|
+
* This component is an experiment not intended for publishing to npm.
|
|
22
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
23
|
+
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
24
|
+
*/
|
|
25
|
+
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
26
|
+
static get is() {
|
|
27
|
+
return 'vaadin-menu-bar';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get styles() {
|
|
31
|
+
return css`
|
|
32
|
+
:host {
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([hidden]) {
|
|
37
|
+
display: none !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[part='container'] {
|
|
41
|
+
position: relative;
|
|
42
|
+
display: flex;
|
|
43
|
+
width: 100%;
|
|
44
|
+
flex-wrap: nowrap;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @protected */
|
|
51
|
+
render() {
|
|
52
|
+
return html`
|
|
53
|
+
<div part="container">
|
|
54
|
+
<slot></slot>
|
|
55
|
+
<slot name="overflow"></slot>
|
|
56
|
+
</div>
|
|
57
|
+
<vaadin-menu-bar-submenu is-root .overlayClass="${this.overlayClass}"></vaadin-menu-bar-submenu>
|
|
58
|
+
|
|
59
|
+
<slot name="tooltip"></slot>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @protected */
|
|
64
|
+
ready() {
|
|
65
|
+
super.ready();
|
|
66
|
+
|
|
67
|
+
this._tooltipController = new TooltipController(this);
|
|
68
|
+
this._tooltipController.setManual(true);
|
|
69
|
+
this.addController(this._tooltipController);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Fired when either a submenu item or menu bar button without nested children is clicked.
|
|
74
|
+
*
|
|
75
|
+
* @event item-selected
|
|
76
|
+
* @param {Object} detail
|
|
77
|
+
* @param {Object} detail.value the selected menu bar item
|
|
78
|
+
*/
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
defineCustomElement(MenuBar);
|
|
82
|
+
|
|
83
|
+
export { MenuBar };
|
|
@@ -37,6 +37,19 @@ class MenuBarButton extends Button {
|
|
|
37
37
|
static get is() {
|
|
38
38
|
return 'vaadin-menu-bar-button';
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Override method inherited from `ButtonMixin`. Sets a flag based on whether the key is an active key. Unlike a mouse click, Enter and Space should also focus the first item. This flag is used in menu bar to identify the action that triggered the click.
|
|
43
|
+
*
|
|
44
|
+
* @param {KeyboardEvent} event
|
|
45
|
+
* @protected
|
|
46
|
+
* @override
|
|
47
|
+
*/
|
|
48
|
+
_onKeyDown(event) {
|
|
49
|
+
this.__triggeredWithActiveKeys = this._activeKeys.includes(event.key);
|
|
50
|
+
super._onKeyDown(event);
|
|
51
|
+
this.__triggeredWithActiveKeys = null;
|
|
52
|
+
}
|
|
40
53
|
}
|
|
41
54
|
|
|
42
55
|
defineCustomElement(MenuBarButton);
|
|
@@ -138,6 +138,13 @@ export declare class MenuBarMixinClass {
|
|
|
138
138
|
*/
|
|
139
139
|
openOnHover: boolean | null | undefined;
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* If true, the buttons will be collapsed into the overflow menu
|
|
143
|
+
* starting from the "start" end of the bar instead of the "end".
|
|
144
|
+
* @attr {boolean} reverse-collapse
|
|
145
|
+
*/
|
|
146
|
+
reverseCollapse: boolean | null | undefined;
|
|
147
|
+
|
|
141
148
|
/**
|
|
142
149
|
* Closes the current submenu.
|
|
143
150
|
*/
|
|
@@ -135,6 +135,15 @@ export const MenuBarMixin = (superClass) =>
|
|
|
135
135
|
type: Boolean,
|
|
136
136
|
},
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* If true, the buttons will be collapsed into the overflow menu
|
|
140
|
+
* starting from the "start" end of the bar instead of the "end".
|
|
141
|
+
* @attr {boolean} reverse-collapse
|
|
142
|
+
*/
|
|
143
|
+
reverseCollapse: {
|
|
144
|
+
type: Boolean,
|
|
145
|
+
},
|
|
146
|
+
|
|
138
147
|
/**
|
|
139
148
|
* @type {boolean}
|
|
140
149
|
* @protected
|
|
@@ -142,6 +151,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
142
151
|
_hasOverflow: {
|
|
143
152
|
type: Boolean,
|
|
144
153
|
value: false,
|
|
154
|
+
sync: true,
|
|
145
155
|
},
|
|
146
156
|
|
|
147
157
|
/** @protected */
|
|
@@ -162,12 +172,14 @@ export const MenuBarMixin = (superClass) =>
|
|
|
162
172
|
'__hasOverflowChanged(_hasOverflow, _overflow)',
|
|
163
173
|
'__i18nChanged(i18n, _overflow)',
|
|
164
174
|
'_menuItemsChanged(items, _overflow, _container)',
|
|
175
|
+
'_reverseCollapseChanged(reverseCollapse, _overflow, _container)',
|
|
165
176
|
];
|
|
166
177
|
}
|
|
167
178
|
|
|
168
179
|
constructor() {
|
|
169
180
|
super();
|
|
170
181
|
this.__boundOnContextMenuKeydown = this.__onContextMenuKeydown.bind(this);
|
|
182
|
+
this.__boundOnTooltipMouseLeave = this.__onTooltipOverlayMouseLeave.bind(this);
|
|
171
183
|
}
|
|
172
184
|
|
|
173
185
|
/**
|
|
@@ -251,7 +263,12 @@ export const MenuBarMixin = (superClass) =>
|
|
|
251
263
|
container.addEventListener('click', this.__onButtonClick.bind(this));
|
|
252
264
|
container.addEventListener('mouseover', (e) => this._onMouseOver(e));
|
|
253
265
|
|
|
254
|
-
|
|
266
|
+
// Delay setting container to avoid rendering buttons immediately,
|
|
267
|
+
// which would also trigger detecting overflow and force re-layout
|
|
268
|
+
// See https://github.com/vaadin/web-components/issues/7271
|
|
269
|
+
queueMicrotask(() => {
|
|
270
|
+
this._container = container;
|
|
271
|
+
});
|
|
255
272
|
}
|
|
256
273
|
|
|
257
274
|
/**
|
|
@@ -320,6 +337,18 @@ export const MenuBarMixin = (superClass) =>
|
|
|
320
337
|
}
|
|
321
338
|
}
|
|
322
339
|
|
|
340
|
+
/**
|
|
341
|
+
* A callback for the 'reverseCollapse' property observer.
|
|
342
|
+
*
|
|
343
|
+
* @param {boolean | null} _reverseCollapse
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
_reverseCollapseChanged(_reverseCollapse, overflow, container) {
|
|
347
|
+
if (overflow && container) {
|
|
348
|
+
this.__detectOverflow();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
323
352
|
/** @private */
|
|
324
353
|
__hasOverflowChanged(hasOverflow, overflow) {
|
|
325
354
|
if (overflow) {
|
|
@@ -408,42 +437,47 @@ export const MenuBarMixin = (superClass) =>
|
|
|
408
437
|
this._hasOverflow = true;
|
|
409
438
|
|
|
410
439
|
const isRTL = this.__isRTL;
|
|
411
|
-
const containerLeft = container.
|
|
440
|
+
const containerLeft = container.offsetLeft;
|
|
412
441
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const
|
|
416
|
-
const
|
|
417
|
-
const btnLeft = btn.getBoundingClientRect().left - containerLeft;
|
|
442
|
+
const remaining = [...buttons];
|
|
443
|
+
while (remaining.length) {
|
|
444
|
+
const lastButton = remaining[remaining.length - 1];
|
|
445
|
+
const btnLeft = lastButton.offsetLeft - containerLeft;
|
|
418
446
|
|
|
419
447
|
// If this button isn't overflowing, then the rest aren't either
|
|
420
448
|
if (
|
|
421
|
-
(!isRTL && btnLeft +
|
|
449
|
+
(!isRTL && btnLeft + lastButton.offsetWidth < container.offsetWidth - overflow.offsetWidth) ||
|
|
422
450
|
(isRTL && btnLeft >= overflow.offsetWidth)
|
|
423
451
|
) {
|
|
424
452
|
break;
|
|
425
453
|
}
|
|
426
454
|
|
|
455
|
+
const btn = this.reverseCollapse ? remaining.shift() : remaining.pop();
|
|
456
|
+
|
|
457
|
+
// Save width for buttons with component
|
|
458
|
+
btn.style.width = getComputedStyle(btn).width;
|
|
427
459
|
btn.disabled = true;
|
|
428
460
|
btn.style.visibility = 'hidden';
|
|
429
461
|
btn.style.position = 'absolute';
|
|
430
|
-
// Save width for buttons with component
|
|
431
|
-
btn.style.width = btnStyle.width;
|
|
432
462
|
}
|
|
433
|
-
|
|
463
|
+
|
|
464
|
+
const items = buttons.filter((b) => !remaining.includes(b)).map((b) => b.item);
|
|
434
465
|
this.__updateOverflow(items);
|
|
435
466
|
|
|
436
|
-
const remaining = buttons.slice(0, i);
|
|
437
467
|
// Ensure there is at least one button with tabindex set to 0
|
|
438
468
|
// so that menu-bar is not skipped when navigating with Tab
|
|
439
|
-
if (
|
|
440
|
-
this._setTabindex(remaining[
|
|
469
|
+
if (remaining.length && !remaining.some((btn) => btn.getAttribute('tabindex') === '0')) {
|
|
470
|
+
this._setTabindex(remaining[remaining.length - 1], true);
|
|
441
471
|
}
|
|
442
472
|
}
|
|
443
473
|
}
|
|
444
474
|
|
|
445
475
|
/** @private */
|
|
446
476
|
__detectOverflow() {
|
|
477
|
+
if (!this._container) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
447
481
|
const overflow = this._overflow;
|
|
448
482
|
const buttons = this._buttons.filter((btn) => btn !== overflow);
|
|
449
483
|
const oldOverflowCount = this.__getOverflowCount(overflow);
|
|
@@ -461,6 +495,14 @@ export const MenuBarMixin = (superClass) =>
|
|
|
461
495
|
|
|
462
496
|
const isSingleButton = newOverflowCount === buttons.length || (newOverflowCount === 0 && buttons.length === 1);
|
|
463
497
|
this.toggleAttribute('has-single-button', isSingleButton);
|
|
498
|
+
|
|
499
|
+
// Apply first/last visible attributes to the visible buttons
|
|
500
|
+
buttons
|
|
501
|
+
.filter((btn) => btn.style.visibility !== 'hidden')
|
|
502
|
+
.forEach((btn, index, visibleButtons) => {
|
|
503
|
+
btn.toggleAttribute('first-visible', index === 0);
|
|
504
|
+
btn.toggleAttribute('last-visible', !this._hasOverflow && index === visibleButtons.length - 1);
|
|
505
|
+
});
|
|
464
506
|
}
|
|
465
507
|
|
|
466
508
|
/** @protected */
|
|
@@ -583,6 +625,11 @@ export const MenuBarMixin = (superClass) =>
|
|
|
583
625
|
tooltip.generator = ({ item }) => item && item.tooltip;
|
|
584
626
|
}
|
|
585
627
|
|
|
628
|
+
if (!tooltip._mouseLeaveListenerAdded) {
|
|
629
|
+
tooltip._overlayElement.addEventListener('mouseleave', this.__boundOnTooltipMouseLeave);
|
|
630
|
+
tooltip._mouseLeaveListenerAdded = true;
|
|
631
|
+
}
|
|
632
|
+
|
|
586
633
|
if (!this._subMenu.opened) {
|
|
587
634
|
this._tooltipController.setTarget(button);
|
|
588
635
|
this._tooltipController.setContext({ item: button.item });
|
|
@@ -604,6 +651,13 @@ export const MenuBarMixin = (superClass) =>
|
|
|
604
651
|
}
|
|
605
652
|
}
|
|
606
653
|
|
|
654
|
+
/** @private */
|
|
655
|
+
__onTooltipOverlayMouseLeave(event) {
|
|
656
|
+
if (event.relatedTarget !== this._tooltipController.target) {
|
|
657
|
+
this._hideTooltip();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
607
661
|
/** @protected */
|
|
608
662
|
_setExpanded(button, expanded) {
|
|
609
663
|
button.toggleAttribute('expanded', expanded);
|
|
@@ -799,7 +853,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
799
853
|
e.stopPropagation();
|
|
800
854
|
const button = this._getButtonFromEvent(e);
|
|
801
855
|
if (button) {
|
|
802
|
-
this.__openSubMenu(button,
|
|
856
|
+
this.__openSubMenu(button, button.__triggeredWithActiveKeys);
|
|
803
857
|
}
|
|
804
858
|
}
|
|
805
859
|
|
|
@@ -824,7 +878,9 @@ export const MenuBarMixin = (superClass) =>
|
|
|
824
878
|
subMenu.items = items;
|
|
825
879
|
subMenu.listenOn = button;
|
|
826
880
|
const overlay = subMenu._overlayElement;
|
|
827
|
-
|
|
881
|
+
// Unset old positioning to prevent flashing.
|
|
882
|
+
overlay.removeAttribute('style');
|
|
883
|
+
overlay.positionTarget = undefined;
|
|
828
884
|
overlay.noVerticalOverlap = true;
|
|
829
885
|
|
|
830
886
|
this._expandedButton = button;
|
|
@@ -860,6 +916,9 @@ export const MenuBarMixin = (superClass) =>
|
|
|
860
916
|
overlay.$.overlay.focus();
|
|
861
917
|
}
|
|
862
918
|
|
|
919
|
+
// Delay setting position target until overlay is rendered
|
|
920
|
+
// to correctly measure item content in Lit based version.
|
|
921
|
+
overlay.positionTarget = button;
|
|
863
922
|
overlay._updatePosition();
|
|
864
923
|
},
|
|
865
924
|
{ once: true },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './vaadin-menu-bar-button-styles.js';
|
|
2
|
+
import './vaadin-menu-bar-item-styles.js';
|
|
3
|
+
import './vaadin-menu-bar-list-box-styles.js';
|
|
4
|
+
import './vaadin-menu-bar-overlay-styles.js';
|
|
5
|
+
import './vaadin-menu-bar-styles.js';
|
|
6
|
+
import '../../src/vaadin-lit-menu-bar.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './vaadin-menu-bar-button-styles.js';
|
|
2
|
+
import './vaadin-menu-bar-item-styles.js';
|
|
3
|
+
import './vaadin-menu-bar-list-box-styles.js';
|
|
4
|
+
import './vaadin-menu-bar-overlay-styles.js';
|
|
5
|
+
import './vaadin-menu-bar-styles.js';
|
|
6
|
+
import '../../src/vaadin-lit-menu-bar.js';
|
|
@@ -46,14 +46,14 @@ const menuBarButton = css`
|
|
|
46
46
|
padding: 0;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
:host(
|
|
49
|
+
:host([first-visible]) {
|
|
50
50
|
border-radius: var(--lumo-border-radius-m) 0 0 var(--lumo-border-radius-m);
|
|
51
51
|
|
|
52
52
|
/* Needed to retain the focus-ring with border-radius */
|
|
53
53
|
margin-left: calc(var(--lumo-space-xs) / 2);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
:host(
|
|
56
|
+
:host([last-visible]),
|
|
57
57
|
:host([slot='overflow']) {
|
|
58
58
|
border-radius: 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0;
|
|
59
59
|
}
|
|
@@ -86,12 +86,12 @@ const menuBarButton = css`
|
|
|
86
86
|
border-radius: 0;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
:host([dir='rtl']
|
|
89
|
+
:host([dir='rtl'][first-visible]) {
|
|
90
90
|
border-radius: 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0;
|
|
91
91
|
margin-right: calc(var(--lumo-space-xs) / 2);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
:host([dir='rtl']
|
|
94
|
+
:host([dir='rtl'][last-visible]),
|
|
95
95
|
:host([dir='rtl'][slot='overflow']) {
|
|
96
96
|
border-radius: var(--lumo-border-radius-m) 0 0 var(--lumo-border-radius-m);
|
|
97
97
|
}
|
|
@@ -8,7 +8,7 @@ registerStyles(
|
|
|
8
8
|
border-radius: var(--lumo-border-radius-m);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button
|
|
11
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button[first-visible]),
|
|
12
12
|
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
13
13
|
margin-inline-start: auto;
|
|
14
14
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './vaadin-menu-bar-button-styles.js';
|
|
2
|
+
import './vaadin-menu-bar-item-styles.js';
|
|
3
|
+
import './vaadin-menu-bar-list-box-styles.js';
|
|
4
|
+
import './vaadin-menu-bar-overlay-styles.js';
|
|
5
|
+
import './vaadin-menu-bar-styles.js';
|
|
6
|
+
import '../../src/vaadin-lit-menu-bar.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './vaadin-menu-bar-button-styles.js';
|
|
2
|
+
import './vaadin-menu-bar-item-styles.js';
|
|
3
|
+
import './vaadin-menu-bar-list-box-styles.js';
|
|
4
|
+
import './vaadin-menu-bar-overlay-styles.js';
|
|
5
|
+
import './vaadin-menu-bar-styles.js';
|
|
6
|
+
import '../../src/vaadin-lit-menu-bar.js';
|
|
@@ -49,11 +49,11 @@ const menuBarButton = css`
|
|
|
49
49
|
margin-right: 1px;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
:host(
|
|
52
|
+
:host([first-visible]) {
|
|
53
53
|
border-radius: 4px 0 0 4px;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
:host(
|
|
56
|
+
:host([last-visible]),
|
|
57
57
|
:host([slot='overflow']) {
|
|
58
58
|
border-radius: 0 4px 4px 0;
|
|
59
59
|
}
|
|
@@ -72,7 +72,7 @@ const menuBarButton = css`
|
|
|
72
72
|
margin-right: -1px;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
:host([theme~='outlined']:not([dir='rtl'])
|
|
75
|
+
:host([theme~='outlined']:not([dir='rtl'])[last-visible]),
|
|
76
76
|
:host([theme~='outlined']:not([dir='rtl'])[slot='overflow']) {
|
|
77
77
|
margin-right: 0;
|
|
78
78
|
}
|
|
@@ -83,11 +83,11 @@ const menuBarButton = css`
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/* RTL styles */
|
|
86
|
-
:host([dir='rtl']
|
|
86
|
+
:host([dir='rtl'][first-visible]) {
|
|
87
87
|
border-radius: 0 4px 4px 0;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
:host([dir='rtl']
|
|
90
|
+
:host([dir='rtl'][last-visible]),
|
|
91
91
|
:host([dir='rtl'][slot='overflow']) {
|
|
92
92
|
border-radius: 4px 0 0 4px;
|
|
93
93
|
}
|
|
@@ -100,7 +100,7 @@ const menuBarButton = css`
|
|
|
100
100
|
margin-left: -1px;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
:host([theme~='outlined'][dir='rtl']
|
|
103
|
+
:host([theme~='outlined'][dir='rtl'][last-visible]),
|
|
104
104
|
:host([theme~='outlined'][dir='rtl'][slot='overflow']) {
|
|
105
105
|
margin-left: 0;
|
|
106
106
|
}
|
|
@@ -12,7 +12,7 @@ registerStyles(
|
|
|
12
12
|
border-radius: 4px;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button
|
|
15
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button[first-visible]),
|
|
16
16
|
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
17
17
|
margin-inline-start: auto;
|
|
18
18
|
}
|
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.4.0-
|
|
4
|
+
"version": "24.4.0-beta2",
|
|
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.4.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.4.0-beta2/#/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.4.0-beta2/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-beta2/#/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.4.0-beta2/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-beta2/#/elements/vaadin-overlay).",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
|
@@ -43,6 +43,17 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"name": "reverse-collapse",
|
|
48
|
+
"description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
|
|
49
|
+
"value": {
|
|
50
|
+
"type": [
|
|
51
|
+
"boolean",
|
|
52
|
+
"null",
|
|
53
|
+
"undefined"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
46
57
|
{
|
|
47
58
|
"name": "theme",
|
|
48
59
|
"description": "The theme variants to apply to the component.",
|
|
@@ -107,6 +118,17 @@
|
|
|
107
118
|
"undefined"
|
|
108
119
|
]
|
|
109
120
|
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "reverseCollapse",
|
|
124
|
+
"description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
|
|
125
|
+
"value": {
|
|
126
|
+
"type": [
|
|
127
|
+
"boolean",
|
|
128
|
+
"null",
|
|
129
|
+
"undefined"
|
|
130
|
+
]
|
|
131
|
+
}
|
|
110
132
|
}
|
|
111
133
|
],
|
|
112
134
|
"events": [
|
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.4.0-
|
|
4
|
+
"version": "24.4.0-beta2",
|
|
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.4.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.4.0-beta2/#/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.4.0-beta2/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-beta2/#/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.4.0-beta2/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-beta2/#/elements/vaadin-overlay).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -33,6 +33,13 @@
|
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
"name": "?reverseCollapse",
|
|
38
|
+
"description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
|
|
39
|
+
"value": {
|
|
40
|
+
"kind": "expression"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
36
43
|
{
|
|
37
44
|
"name": ".items",
|
|
38
45
|
"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```",
|