@vaadin/menu-bar 24.5.4 → 24.5.6

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.5.4",
3
+ "version": "24.5.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,21 +39,21 @@
39
39
  "dependencies": {
40
40
  "@open-wc/dedupe-mixin": "^1.3.0",
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/a11y-base": "~24.5.4",
43
- "@vaadin/button": "~24.5.4",
44
- "@vaadin/component-base": "~24.5.4",
45
- "@vaadin/context-menu": "~24.5.4",
46
- "@vaadin/item": "~24.5.4",
47
- "@vaadin/list-box": "~24.5.4",
48
- "@vaadin/overlay": "~24.5.4",
49
- "@vaadin/vaadin-lumo-styles": "~24.5.4",
50
- "@vaadin/vaadin-material-styles": "~24.5.4",
51
- "@vaadin/vaadin-themable-mixin": "~24.5.4",
42
+ "@vaadin/a11y-base": "~24.5.6",
43
+ "@vaadin/button": "~24.5.6",
44
+ "@vaadin/component-base": "~24.5.6",
45
+ "@vaadin/context-menu": "~24.5.6",
46
+ "@vaadin/item": "~24.5.6",
47
+ "@vaadin/list-box": "~24.5.6",
48
+ "@vaadin/overlay": "~24.5.6",
49
+ "@vaadin/vaadin-lumo-styles": "~24.5.6",
50
+ "@vaadin/vaadin-material-styles": "~24.5.6",
51
+ "@vaadin/vaadin-themable-mixin": "~24.5.6",
52
52
  "lit": "^3.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@vaadin/chai-plugins": "~24.5.4",
56
- "@vaadin/icon": "~24.5.4",
55
+ "@vaadin/chai-plugins": "~24.5.6",
56
+ "@vaadin/icon": "~24.5.6",
57
57
  "@vaadin/testing-helpers": "^1.0.0",
58
58
  "sinon": "^18.0.0"
59
59
  },
@@ -61,5 +61,5 @@
61
61
  "web-types.json",
62
62
  "web-types.lit.json"
63
63
  ],
64
- "gitHead": "0993b6e95bd5826642065356b8f5854a65a6b677"
64
+ "gitHead": "2c20ec16149e8016e0733a80e349231da13660bc"
65
65
  }
@@ -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 ContextMenuMixin
22
- * @mixes OverlayClassMixin
20
+ * @mixes SubMenuMixin
23
21
  * @mixes ThemePropertyMixin
24
22
  * @protected
25
23
  */
26
- class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ThemePropertyMixin(PolylitMixin(LitElement)))) {
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);
@@ -904,7 +904,6 @@ export const MenuBarMixin = (superClass) =>
904
904
 
905
905
  /** @private */
906
906
  __onButtonClick(e) {
907
- e.stopPropagation();
908
907
  const button = this._getButtonFromEvent(e);
909
908
  if (button) {
910
909
  this.__openSubMenu(button, button.__triggeredWithActiveKeys);
@@ -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 OverlayClassMixin
21
+ * @mixes SubMenuMixin
24
22
  * @mixes ThemePropertyMixin
25
23
  * @protected
26
24
  */
27
- class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ControllerMixin(ThemePropertyMixin(PolymerElement)))) {
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.5.4",
4
+ "version": "24.5.6",
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.5.4/#/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.5.4/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.5.4/#/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.5.4/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.5.4/#/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.",
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.5.6/#/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.5.6/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.5.6/#/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.5.6/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.5.6/#/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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/menu-bar",
4
- "version": "24.5.4",
4
+ "version": "24.5.6",
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.5.4/#/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.5.4/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.5.4/#/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.5.4/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.5.4/#/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.",
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.5.6/#/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.5.6/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.5.6/#/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.5.6/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.5.6/#/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
  {