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

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-alpha2",
3
+ "version": "23.3.0-alpha4",
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-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"
40
+ "@vaadin/button": "23.3.0-alpha4",
41
+ "@vaadin/component-base": "23.3.0-alpha4",
42
+ "@vaadin/context-menu": "23.3.0-alpha4",
43
+ "@vaadin/vaadin-lumo-styles": "23.3.0-alpha4",
44
+ "@vaadin/vaadin-material-styles": "23.3.0-alpha4",
45
+ "@vaadin/vaadin-themable-mixin": "23.3.0-alpha4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/icon": "23.3.0-alpha2",
49
+ "@vaadin/icon": "23.3.0-alpha4",
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": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
57
+ "gitHead": "da037c0aa36e4b2874f253967300f6ca1af27315"
58
58
  }
@@ -47,7 +47,6 @@ export const InteractionsMixin = (superClass) =>
47
47
 
48
48
  const overlay = this._subMenu.$.overlay;
49
49
  overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
50
- overlay.addEventListener('vaadin-overlay-open', this.__alignOverlayPosition.bind(this));
51
50
 
52
51
  const container = this._container;
53
52
  container.addEventListener('click', this.__onButtonClick.bind(this));
@@ -98,14 +97,14 @@ export const InteractionsMixin = (superClass) =>
98
97
  /** @protected */
99
98
  disconnectedCallback() {
100
99
  super.disconnectedCallback();
101
- this._hideTooltip();
100
+ this._hideTooltip(true);
102
101
  }
103
102
 
104
103
  /**
105
104
  * @param {HTMLElement} button
106
105
  * @protected
107
106
  */
108
- _showTooltip(button) {
107
+ _showTooltip(button, isHover) {
109
108
  // Check if there is a slotted vaadin-tooltip element.
110
109
  const tooltip = this._tooltipController.node;
111
110
  if (tooltip && tooltip.isConnected) {
@@ -118,14 +117,22 @@ export const InteractionsMixin = (superClass) =>
118
117
  if (!this._subMenu.opened) {
119
118
  this._tooltipController.setTarget(button);
120
119
  this._tooltipController.setContext({ item: button.item });
121
- this._tooltipController.setOpened(true);
120
+
121
+ // Trigger opening using the corresponding delay.
122
+ tooltip._stateController.open({
123
+ hover: isHover,
124
+ focus: !isHover,
125
+ });
122
126
  }
123
127
  }
124
128
  }
125
129
 
126
130
  /** @protected */
127
- _hideTooltip() {
128
- this._tooltipController.setOpened(false);
131
+ _hideTooltip(immediate) {
132
+ const tooltip = this._tooltipController.node;
133
+ if (tooltip) {
134
+ tooltip._stateController.close(immediate);
135
+ }
129
136
  }
130
137
 
131
138
  /** @protected */
@@ -247,7 +254,7 @@ export const InteractionsMixin = (superClass) =>
247
254
  this._close(true);
248
255
  }
249
256
 
250
- this._hideTooltip();
257
+ this._hideTooltip(true);
251
258
  }
252
259
 
253
260
  /**
@@ -276,30 +283,6 @@ export const InteractionsMixin = (superClass) =>
276
283
  return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
277
284
  }
278
285
 
279
- /** @private */
280
- __alignOverlayPosition(e) {
281
- /* c8 ignore next */
282
- if (!this._expandedButton) {
283
- // When `openOnHover` is true, quickly moving cursor can close submenu,
284
- // so by the time when event listener gets executed button is null.
285
- // See https://github.com/vaadin/vaadin-menu-bar/issues/85
286
- return;
287
- }
288
- const overlay = e.target;
289
- const { width, height, left } = this._expandedButton.getBoundingClientRect();
290
- if (overlay.hasAttribute('bottom-aligned')) {
291
- overlay.style.bottom = `${parseInt(getComputedStyle(overlay).bottom) + height}px`;
292
- }
293
- const endAligned = overlay.hasAttribute('end-aligned');
294
- if (endAligned) {
295
- if (this.__isRTL) {
296
- overlay.style.left = `${left}px`;
297
- } else {
298
- overlay.style.right = `${parseInt(getComputedStyle(overlay).right) - width}px`;
299
- }
300
- }
301
- }
302
-
303
286
  /** @private */
304
287
  _itemsChanged() {
305
288
  const subMenu = this._subMenu;
@@ -328,7 +311,7 @@ export const InteractionsMixin = (superClass) =>
328
311
  if (button === this._overflow || (this.openOnHover && button.item.children)) {
329
312
  this._hideTooltip();
330
313
  } else {
331
- this._showTooltip(button);
314
+ this._showTooltip(button, true);
332
315
  }
333
316
  }
334
317
  }
@@ -398,7 +381,7 @@ export const InteractionsMixin = (superClass) =>
398
381
  },
399
382
  }),
400
383
  );
401
- this._hideTooltip();
384
+ this._hideTooltip(true);
402
385
 
403
386
  this._setExpanded(button, true);
404
387
  });
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-alpha2",
4
+ "version": "23.3.0-alpha4",
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-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).",
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-alpha4/#/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-alpha4/#/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-alpha4/#/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-alpha4/#/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-alpha4/#/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-alpha2",
4
+ "version": "23.3.0-alpha4",
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-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).",
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-alpha4/#/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-alpha4/#/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-alpha4/#/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-alpha4/#/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-alpha4/#/elements/vaadin-overlay).",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {