@vaadin/menu-bar 23.3.0-alpha1 → 23.3.0-alpha2

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": "23.3.0-alpha1",
3
+ "version": "23.3.0-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,16 +37,16 @@
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/button": "23.3.0-alpha1",
41
- "@vaadin/component-base": "23.3.0-alpha1",
42
- "@vaadin/context-menu": "23.3.0-alpha1",
43
- "@vaadin/vaadin-lumo-styles": "23.3.0-alpha1",
44
- "@vaadin/vaadin-material-styles": "23.3.0-alpha1",
45
- "@vaadin/vaadin-themable-mixin": "23.3.0-alpha1"
40
+ "@vaadin/button": "23.3.0-alpha2",
41
+ "@vaadin/component-base": "23.3.0-alpha2",
42
+ "@vaadin/context-menu": "23.3.0-alpha2",
43
+ "@vaadin/vaadin-lumo-styles": "23.3.0-alpha2",
44
+ "@vaadin/vaadin-material-styles": "23.3.0-alpha2",
45
+ "@vaadin/vaadin-themable-mixin": "23.3.0-alpha2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/icon": "23.3.0-alpha1",
49
+ "@vaadin/icon": "23.3.0-alpha2",
50
50
  "@vaadin/testing-helpers": "^0.3.2",
51
51
  "sinon": "^13.0.2"
52
52
  },
@@ -54,5 +54,5 @@
54
54
  "web-types.json",
55
55
  "web-types.lit.json"
56
56
  ],
57
- "gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
57
+ "gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
58
58
  }
@@ -107,10 +107,19 @@ export const InteractionsMixin = (superClass) =>
107
107
  */
108
108
  _showTooltip(button) {
109
109
  // Check if there is a slotted vaadin-tooltip element.
110
- if (this._tooltipController.node && this._tooltipController.node.isConnected && !this._subMenu.opened) {
111
- this._tooltipController.setTarget(button);
112
- this._tooltipController.setContext({ item: button.item });
113
- this._tooltipController.setOpened(true);
110
+ const tooltip = this._tooltipController.node;
111
+ if (tooltip && tooltip.isConnected) {
112
+ // If the tooltip element doesn't have a generator assigned, use a default one
113
+ // that reads the `tooltip` property of an item.
114
+ if (tooltip.generator === undefined) {
115
+ tooltip.generator = ({ item }) => item && item.tooltip;
116
+ }
117
+
118
+ if (!this._subMenu.opened) {
119
+ this._tooltipController.setTarget(button);
120
+ this._tooltipController.setContext({ item: button.item });
121
+ this._tooltipController.setOpened(true);
122
+ }
114
123
  }
115
124
  }
116
125
 
@@ -305,7 +314,10 @@ export const InteractionsMixin = (superClass) =>
305
314
  */
306
315
  _onMouseOver(e) {
307
316
  const button = this._getButtonFromEvent(e);
308
- if (button && button !== this._expandedButton) {
317
+ if (!button) {
318
+ // Hide tooltip on mouseover to disabled button
319
+ this._hideTooltip();
320
+ } else if (button !== this._expandedButton) {
309
321
  const isOpened = this._subMenu.opened;
310
322
  if (button.item.children && (this.openOnHover || isOpened)) {
311
323
  this.__openSubMenu(button, false);
@@ -11,10 +11,31 @@ import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
11
11
  import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
12
12
 
13
13
  export interface MenuBarItem {
14
+ /**
15
+ * Text to be set as the menu button component's textContent.
16
+ */
14
17
  text?: string;
18
+ /**
19
+ * Text to be set as the menu button's tooltip.
20
+ * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
21
+ */
22
+ tooltip?: string;
23
+ /**
24
+ * The component to represent the button content.
25
+ * Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
26
+ */
15
27
  component?: HTMLElement | string;
28
+ /**
29
+ * If true, the button is disabled and cannot be activated.
30
+ */
16
31
  disabled?: boolean;
32
+ /**
33
+ * Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
34
+ */
17
35
  theme?: string[] | string;
36
+ /**
37
+ * Array of submenu items.
38
+ */
18
39
  children?: SubMenuItem[];
19
40
  }
20
41
 
@@ -129,6 +129,8 @@ class MenuBar extends ButtonsMixin(
129
129
  * @typedef MenuBarItem
130
130
  * @type {object}
131
131
  * @property {string} text - Text to be set as the menu button component's textContent.
132
+ * @property {string} tooltip - Text to be set as the menu button's tooltip.
133
+ * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
132
134
  * @property {union: string | object} component - The component to represent the button content.
133
135
  * Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
134
136
  * @property {boolean} disabled - If true, the button is disabled and cannot be activated.
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": "23.3.0-alpha1",
4
+ "version": "23.3.0-alpha2",
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/23.3.0-alpha1/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-overlay).",
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/23.3.0-alpha2/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha2/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-overlay).",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "open-on-hover",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/menu-bar",
4
- "version": "23.3.0-alpha1",
4
+ "version": "23.3.0-alpha2",
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/23.3.0-alpha1/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-overlay).",
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/23.3.0-alpha2/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha2/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-overlay).",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {