@vaadin/menu-bar 25.0.0-alpha8 → 25.0.0-alpha9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -14
- package/src/styles/vaadin-menu-bar-base-styles.js +0 -1
- package/src/vaadin-menu-bar-mixin.js +51 -8
- package/src/vaadin-menu-bar-overlay.js +1 -0
- package/src/vaadin-menu-bar-submenu-mixin.js +2 -2
- package/src/vaadin-menu-bar-submenu.js +20 -11
- package/src/vaadin-menu-bar.d.ts +1 -4
- package/src/vaadin-menu-bar.js +1 -4
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
41
|
-
"@vaadin/button": "25.0.0-
|
|
42
|
-
"@vaadin/component-base": "25.0.0-
|
|
43
|
-
"@vaadin/context-menu": "25.0.0-
|
|
44
|
-
"@vaadin/item": "25.0.0-
|
|
45
|
-
"@vaadin/list-box": "25.0.0-
|
|
46
|
-
"@vaadin/overlay": "25.0.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.0.0-alpha9",
|
|
41
|
+
"@vaadin/button": "25.0.0-alpha9",
|
|
42
|
+
"@vaadin/component-base": "25.0.0-alpha9",
|
|
43
|
+
"@vaadin/context-menu": "25.0.0-alpha9",
|
|
44
|
+
"@vaadin/item": "25.0.0-alpha9",
|
|
45
|
+
"@vaadin/list-box": "25.0.0-alpha9",
|
|
46
|
+
"@vaadin/overlay": "25.0.0-alpha9",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
|
|
49
49
|
"lit": "^3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
53
|
-
"@vaadin/icon": "25.0.0-
|
|
54
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
52
|
+
"@vaadin/chai-plugins": "25.0.0-alpha9",
|
|
53
|
+
"@vaadin/icon": "25.0.0-alpha9",
|
|
54
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha9",
|
|
55
55
|
"@vaadin/testing-helpers": "^2.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": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
|
|
63
63
|
}
|
|
@@ -22,7 +22,6 @@ export const menuBarStyles = css`
|
|
|
22
22
|
padding: calc(var(--vaadin-focus-ring-width) + 1px);
|
|
23
23
|
position: relative;
|
|
24
24
|
width: 100%;
|
|
25
|
-
/* stylelint-disable length-zero-no-unit */
|
|
26
25
|
--_gap: var(--vaadin-menu-bar-gap, 0px);
|
|
27
26
|
--_bw: var(--vaadin-button-border-width, 1px);
|
|
28
27
|
gap: var(--_gap);
|
|
@@ -300,7 +300,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
300
300
|
menu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
|
|
301
301
|
|
|
302
302
|
const overlay = menu._overlayElement;
|
|
303
|
-
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
303
|
+
overlay._contentRoot.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
304
304
|
|
|
305
305
|
this._subMenu = menu;
|
|
306
306
|
},
|
|
@@ -742,6 +742,34 @@ export const MenuBarMixin = (superClass) =>
|
|
|
742
742
|
return Array.from(e.composedPath()).find((el) => el.localName === 'vaadin-menu-bar-button');
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Override method inherited from `FocusMixin`
|
|
747
|
+
*
|
|
748
|
+
* @override
|
|
749
|
+
* @protected
|
|
750
|
+
*/
|
|
751
|
+
_shouldSetFocus(event) {
|
|
752
|
+
// Ignore events from the submenu
|
|
753
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return super._shouldSetFocus(event);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Override method inherited from `FocusMixin`
|
|
761
|
+
*
|
|
762
|
+
* @override
|
|
763
|
+
* @protected
|
|
764
|
+
*/
|
|
765
|
+
_shouldRemoveFocus(event) {
|
|
766
|
+
// Ignore events from the submenu
|
|
767
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
return super._shouldRemoveFocus(event);
|
|
771
|
+
}
|
|
772
|
+
|
|
745
773
|
/**
|
|
746
774
|
* Override method inherited from `FocusMixin`
|
|
747
775
|
*
|
|
@@ -824,6 +852,16 @@ export const MenuBarMixin = (superClass) =>
|
|
|
824
852
|
* @override
|
|
825
853
|
*/
|
|
826
854
|
_onKeyDown(event) {
|
|
855
|
+
// Ignore events from the submenu
|
|
856
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
this._handleKeyDown(event);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** @private */
|
|
864
|
+
_handleKeyDown(event) {
|
|
827
865
|
switch (event.key) {
|
|
828
866
|
case 'ArrowDown':
|
|
829
867
|
this._onArrowDown(event);
|
|
@@ -838,11 +876,16 @@ export const MenuBarMixin = (superClass) =>
|
|
|
838
876
|
}
|
|
839
877
|
|
|
840
878
|
/**
|
|
841
|
-
* @param {!MouseEvent}
|
|
879
|
+
* @param {!MouseEvent} event
|
|
842
880
|
* @protected
|
|
843
881
|
*/
|
|
844
|
-
_onMouseOver(
|
|
845
|
-
|
|
882
|
+
_onMouseOver(event) {
|
|
883
|
+
// Ignore events from the submenu
|
|
884
|
+
if (event.composedPath().includes(this._subMenu)) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
const button = this._getButtonFromEvent(event);
|
|
846
889
|
if (!button) {
|
|
847
890
|
// Hide tooltip on mouseover to disabled button
|
|
848
891
|
this._hideTooltip();
|
|
@@ -874,11 +917,11 @@ export const MenuBarMixin = (superClass) =>
|
|
|
874
917
|
if (e.keyCode === 37 || (e.keyCode === 39 && !item._item.children)) {
|
|
875
918
|
// Prevent ArrowLeft from being handled in context-menu
|
|
876
919
|
e.stopImmediatePropagation();
|
|
877
|
-
this.
|
|
920
|
+
this._handleKeyDown(e);
|
|
878
921
|
}
|
|
879
922
|
|
|
880
923
|
if (e.key === 'Tab' && this.tabNavigation) {
|
|
881
|
-
this.
|
|
924
|
+
this._handleKeyDown(e);
|
|
882
925
|
}
|
|
883
926
|
}
|
|
884
927
|
}
|
|
@@ -961,13 +1004,13 @@ export const MenuBarMixin = (superClass) =>
|
|
|
961
1004
|
|
|
962
1005
|
/** @private */
|
|
963
1006
|
_focusFirstItem() {
|
|
964
|
-
const list = this._subMenu._overlayElement.firstElementChild;
|
|
1007
|
+
const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
|
|
965
1008
|
list.focus();
|
|
966
1009
|
}
|
|
967
1010
|
|
|
968
1011
|
/** @private */
|
|
969
1012
|
_focusLastItem() {
|
|
970
|
-
const list = this._subMenu._overlayElement.firstElementChild;
|
|
1013
|
+
const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
|
|
971
1014
|
const item = list.items[list.items.length - 1];
|
|
972
1015
|
if (item) {
|
|
973
1016
|
item.focus();
|
|
@@ -7,6 +7,7 @@ import './vaadin-menu-bar-item.js';
|
|
|
7
7
|
import './vaadin-menu-bar-list-box.js';
|
|
8
8
|
import './vaadin-menu-bar-overlay.js';
|
|
9
9
|
import { css, html, LitElement } from 'lit';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
12
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
13
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
@@ -40,17 +41,25 @@ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitEle
|
|
|
40
41
|
|
|
41
42
|
/** @protected */
|
|
42
43
|
render() {
|
|
43
|
-
return html
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
return html`
|
|
45
|
+
<vaadin-menu-bar-overlay
|
|
46
|
+
id="overlay"
|
|
47
|
+
.owner="${this}"
|
|
48
|
+
.opened="${this.opened}"
|
|
49
|
+
.model="${this._context}"
|
|
50
|
+
.modeless="${this._modeless}"
|
|
51
|
+
.renderer="${this.__itemsRenderer}"
|
|
52
|
+
.withBackdrop="${this._phone}"
|
|
53
|
+
?phone="${this._phone}"
|
|
54
|
+
theme="${ifDefined(this._theme)}"
|
|
55
|
+
exportparts="backdrop, overlay, content"
|
|
56
|
+
@opened-changed="${this._onOverlayOpened}"
|
|
57
|
+
@vaadin-overlay-open="${this._onVaadinOverlayOpen}"
|
|
58
|
+
>
|
|
59
|
+
<slot name="overlay"></slot>
|
|
60
|
+
<slot name="submenu" slot="submenu"></slot>
|
|
61
|
+
</vaadin-menu-bar-overlay>
|
|
62
|
+
`;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -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
|
@@ -57,7 +57,7 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
57
57
|
* - `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
|
|
58
58
|
* - `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
59
59
|
* - `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
|
|
60
|
-
* - `<vaadin-menu-bar-
|
|
60
|
+
* - `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](#/elements/vaadin-context-menu).
|
|
61
61
|
*
|
|
62
62
|
* The `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes
|
|
63
63
|
* on top of the built-in `<vaadin-item>` state attributes:
|
|
@@ -66,9 +66,6 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
66
66
|
* ---------- |-------------
|
|
67
67
|
* `expanded` | Expanded parent item.
|
|
68
68
|
*
|
|
69
|
-
* Note: the `theme` attribute value set on `<vaadin-menu-bar>` is
|
|
70
|
-
* propagated to the internal components listed above.
|
|
71
|
-
*
|
|
72
69
|
* @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
73
70
|
*
|
|
74
71
|
* @customElement
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-menu-bar",
|
|
11
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```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-alpha9/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-context-menu).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-menu-bar",
|
|
19
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```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-alpha9/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-submenu>` - has the same API as [`<vaadin-context-menu>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha9/#/elements/vaadin-context-menu).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|