@vaadin/menu-bar 23.2.2 → 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.2.2",
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.2.2",
41
- "@vaadin/component-base": "~23.2.2",
42
- "@vaadin/context-menu": "~23.2.2",
43
- "@vaadin/vaadin-lumo-styles": "~23.2.2",
44
- "@vaadin/vaadin-material-styles": "~23.2.2",
45
- "@vaadin/vaadin-themable-mixin": "~23.2.2"
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.2.2",
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": "a98818979098f4542ce557a58858fb6dad910a25"
57
+ "gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
58
58
  }
@@ -4,10 +4,17 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
8
+ import type { KeyboardDirectionMixinClass } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
9
+ import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
7
10
 
8
11
  export declare function InteractionsMixin<T extends Constructor<HTMLElement>>(
9
12
  base: T,
10
- ): Constructor<InteractionsMixinClass> & T;
13
+ ): Constructor<FocusMixinClass> &
14
+ Constructor<InteractionsMixinClass> &
15
+ Constructor<KeyboardDirectionMixinClass> &
16
+ Constructor<KeyboardMixinClass> &
17
+ T;
11
18
 
12
19
  export declare class InteractionsMixinClass {
13
20
  /**
@@ -3,12 +3,17 @@
3
3
  * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
7
+ import { isKeyboardActive } from '@vaadin/component-base/src/focus-utils.js';
8
+ import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
6
9
 
7
10
  /**
8
11
  * @polymerMixin
12
+ * @mixes FocusMixin
13
+ * @mixes KeyboardDirectionMixinClass
9
14
  */
10
15
  export const InteractionsMixin = (superClass) =>
11
- class InteractionsMixin extends superClass {
16
+ class InteractionsMixin extends KeyboardDirectionMixin(FocusMixin(superClass)) {
12
17
  static get properties() {
13
18
  return {
14
19
  /**
@@ -34,8 +39,8 @@ export const InteractionsMixin = (superClass) =>
34
39
  ready() {
35
40
  super.ready();
36
41
 
37
- this.addEventListener('keydown', (e) => this._onKeydown(e));
38
- this.addEventListener('focusin', (e) => this._onFocusin(e));
42
+ this.addEventListener('mousedown', () => this._hideTooltip());
43
+ this.addEventListener('mouseleave', () => this._hideTooltip());
39
44
 
40
45
  this._subMenu.addEventListener('item-selected', this.__onItemSelected.bind(this));
41
46
  this._subMenu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
@@ -49,11 +54,80 @@ export const InteractionsMixin = (superClass) =>
49
54
  container.addEventListener('mouseover', (e) => this._onMouseOver(e));
50
55
  }
51
56
 
57
+ /**
58
+ * Override getter from `KeyboardDirectionMixin`
59
+ * to look for activeElement in shadow root, or
60
+ * use the expanded button as a fallback.
61
+ *
62
+ * @return {Element | null}
63
+ * @protected
64
+ * @override
65
+ */
66
+ get focused() {
67
+ return this.shadowRoot.activeElement || this._expandedButton;
68
+ }
69
+
70
+ /**
71
+ * Override getter from `KeyboardDirectionMixin`.
72
+ *
73
+ * @return {boolean}
74
+ * @protected
75
+ * @override
76
+ */
77
+ get _vertical() {
78
+ return false;
79
+ }
80
+
81
+ /**
82
+ * Override method inherited from `KeyboardDirectionMixin`
83
+ * to use the list of menu-bar buttons as items.
84
+ *
85
+ * @return {Element[]}
86
+ * @protected
87
+ * @override
88
+ */
89
+ _getItems() {
90
+ return this._buttons;
91
+ }
92
+
52
93
  /** @private */
53
94
  get __isRTL() {
54
95
  return this.getAttribute('dir') === 'rtl';
55
96
  }
56
97
 
98
+ /** @protected */
99
+ disconnectedCallback() {
100
+ super.disconnectedCallback();
101
+ this._hideTooltip();
102
+ }
103
+
104
+ /**
105
+ * @param {HTMLElement} button
106
+ * @protected
107
+ */
108
+ _showTooltip(button) {
109
+ // Check if there is a slotted vaadin-tooltip element.
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
+ }
123
+ }
124
+ }
125
+
126
+ /** @protected */
127
+ _hideTooltip() {
128
+ this._tooltipController.setOpened(false);
129
+ }
130
+
57
131
  /** @protected */
58
132
  _setExpanded(button, expanded) {
59
133
  button.toggleAttribute('expanded', expanded);
@@ -66,135 +140,135 @@ export const InteractionsMixin = (superClass) =>
66
140
  button.setAttribute('tabindex', focused ? '0' : '-1');
67
141
  }
68
142
 
69
- /** @private */
70
- _focusButton(button) {
71
- button.focus();
72
- button.setAttribute('focus-ring', '');
143
+ /**
144
+ * Override method inherited from `KeyboardDirectionMixin`
145
+ * to close the submenu for the previously focused button
146
+ * and open another one for the newly focused button.
147
+ *
148
+ * @param {Element} item
149
+ * @param {boolean} navigating
150
+ * @protected
151
+ * @override
152
+ */
153
+ _focusItem(item, navigating) {
154
+ const wasExpanded = navigating && this.focused === this._expandedButton;
155
+ if (wasExpanded) {
156
+ this._close();
157
+ }
158
+
159
+ super._focusItem(item, navigating);
160
+
73
161
  this._buttons.forEach((btn) => {
74
- this._setTabindex(btn, btn === button);
162
+ this._setTabindex(btn, btn === item);
75
163
  });
76
- }
77
164
 
78
- /** @private */
79
- _getButtonFromEvent(e) {
80
- return Array.from(e.composedPath()).filter((el) => el.localName === 'vaadin-menu-bar-button')[0];
165
+ if (wasExpanded && item.item && item.item.children) {
166
+ this.__openSubMenu(item, true, { keepFocus: true });
167
+ } else if (item === this._overflow) {
168
+ this._hideTooltip();
169
+ } else {
170
+ this._showTooltip(item);
171
+ }
81
172
  }
82
173
 
83
174
  /** @private */
84
- _getCurrentButton() {
85
- return this.shadowRoot.activeElement || this._expandedButton;
175
+ _getButtonFromEvent(e) {
176
+ return Array.from(e.composedPath()).find((el) => el.localName === 'vaadin-menu-bar-button');
86
177
  }
87
178
 
88
179
  /**
89
- * @param {!FocusEvent} event
180
+ * Override method inherited from `FocusMixin`
181
+ *
182
+ * @param {boolean} focused
183
+ * @override
90
184
  * @protected
91
185
  */
92
- _onFocusin() {
93
- const target = this.shadowRoot.querySelector('[part$="button"][tabindex="0"]');
94
- if (target) {
95
- this._buttons.forEach((btn) => {
96
- this._setTabindex(btn, btn === target);
97
- });
186
+ _setFocused(focused) {
187
+ if (focused) {
188
+ const target = this.shadowRoot.querySelector('[part$="button"][tabindex="0"]');
189
+ if (target) {
190
+ this._buttons.forEach((btn) => {
191
+ this._setTabindex(btn, btn === target);
192
+ if (btn === target && btn !== this._overflow && isKeyboardActive()) {
193
+ this._showTooltip(btn);
194
+ }
195
+ });
196
+ }
197
+ } else {
198
+ this._hideTooltip();
98
199
  }
99
200
  }
100
201
 
101
202
  /**
102
203
  * @param {!KeyboardEvent} event
103
- * @protected
204
+ * @private
104
205
  */
105
- _onKeydown(event) {
206
+ _onArrowDown(event) {
207
+ // Prevent page scroll.
208
+ event.preventDefault();
209
+
106
210
  const button = this._getButtonFromEvent(event);
107
- if (button) {
108
- if (event.keyCode === 40) {
109
- // ArrowDown, prevent page scroll
110
- event.preventDefault();
111
- if (button === this._expandedButton) {
112
- // Menu opened previously, focus first item
113
- this._focusFirstItem();
114
- } else {
115
- this.__openSubMenu(button, event);
116
- }
117
- } else if (event.keyCode === 38) {
118
- // ArrowUp, prevent page scroll
119
- event.preventDefault();
120
- if (button === this._expandedButton) {
121
- // Menu opened previously, focus last item
122
- this._focusLastItem();
123
- } else {
124
- this.__openSubMenu(button, event, { focusLast: true });
125
- }
126
- } else if (event.keyCode === 27 && button === this._expandedButton) {
127
- this._close(true);
128
- } else {
129
- this._navigateByKey(event);
130
- }
211
+ if (button === this._expandedButton) {
212
+ // Menu opened previously, focus first item
213
+ this._focusFirstItem();
214
+ } else {
215
+ this.__openSubMenu(button, true);
131
216
  }
132
217
  }
133
218
 
134
- /** @private */
135
- _navigateByKey(event) {
136
- // IE names for arrows do not include the Arrow prefix
137
- const key = event.key.replace(/^Arrow/, '');
138
- const buttons = this._buttons;
139
- const currentBtn = this._getCurrentButton();
140
- const currentIdx = buttons.indexOf(currentBtn);
141
- let idx;
142
- let increment;
143
- const dirIncrement = this.__isRTL ? -1 : 1;
144
-
145
- switch (key) {
146
- case 'Left':
147
- increment = -dirIncrement;
148
- idx = currentIdx - dirIncrement;
149
- break;
150
- case 'Right':
151
- increment = dirIncrement;
152
- idx = currentIdx + dirIncrement;
153
- break;
154
- case 'Home':
155
- increment = 1;
156
- idx = 0;
157
- break;
158
- case 'End':
159
- increment = -1;
160
- idx = buttons.length - 1;
161
- break;
162
- default:
163
- // Do nothing.
164
- }
219
+ /**
220
+ * @param {!KeyboardEvent} event
221
+ * @private
222
+ */
223
+ _onArrowUp(event) {
224
+ // Prevent page scroll.
225
+ event.preventDefault();
165
226
 
166
- idx = this._getAvailableIndex(idx, increment, buttons);
167
- if (idx >= 0) {
168
- event.preventDefault();
169
- const btn = buttons[idx];
170
- const wasExpanded = currentBtn === this._expandedButton;
171
- if (wasExpanded) {
172
- this._close();
173
- }
174
- this._focusButton(btn);
175
- if (wasExpanded && btn.item && btn.item.children) {
176
- this.__openSubMenu(btn, event, { keepFocus: true });
177
- }
227
+ const button = this._getButtonFromEvent(event);
228
+ if (button === this._expandedButton) {
229
+ // Menu opened previously, focus last item
230
+ this._focusLastItem();
231
+ } else {
232
+ this.__openSubMenu(button, true, { focusLast: true });
178
233
  }
179
234
  }
180
235
 
181
- /** @private */
182
- _getAvailableIndex(index, increment, buttons) {
183
- const totalItems = buttons.length;
184
- let idx = index;
185
- for (let i = 0; typeof idx === 'number' && i < totalItems; i++, idx += increment || 1) {
186
- if (idx < 0) {
187
- idx = totalItems - 1;
188
- } else if (idx >= totalItems) {
189
- idx = 0;
190
- }
236
+ /**
237
+ * Override an event listener from `KeyboardMixin`:
238
+ * - to close the sub-menu for expanded button,
239
+ * - to close a tooltip for collapsed button.
240
+ *
241
+ * @param {!KeyboardEvent} event
242
+ * @protected
243
+ * @override
244
+ */
245
+ _onEscape(event) {
246
+ if (event.composedPath().includes(this._expandedButton)) {
247
+ this._close(true);
248
+ }
191
249
 
192
- const btn = buttons[idx];
193
- if (!btn.disabled && !btn.hasAttribute('hidden')) {
194
- return idx;
195
- }
250
+ this._hideTooltip();
251
+ }
252
+
253
+ /**
254
+ * Override an event listener from `KeyboardMixin`.
255
+ *
256
+ * @param {!KeyboardEvent} event
257
+ * @protected
258
+ * @override
259
+ */
260
+ _onKeyDown(event) {
261
+ switch (event.key) {
262
+ case 'ArrowDown':
263
+ this._onArrowDown(event);
264
+ break;
265
+ case 'ArrowUp':
266
+ this._onArrowUp(event);
267
+ break;
268
+ default:
269
+ super._onKeyDown(event);
270
+ break;
196
271
  }
197
- return -1;
198
272
  }
199
273
 
200
274
  /** @private */
@@ -240,19 +314,28 @@ export const InteractionsMixin = (superClass) =>
240
314
  */
241
315
  _onMouseOver(e) {
242
316
  const button = this._getButtonFromEvent(e);
243
- 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) {
244
321
  const isOpened = this._subMenu.opened;
245
322
  if (button.item.children && (this.openOnHover || isOpened)) {
246
- this.__openSubMenu(button, e);
323
+ this.__openSubMenu(button, false);
247
324
  } else if (isOpened) {
248
325
  this._close();
249
326
  }
327
+
328
+ if (button === this._overflow || (this.openOnHover && button.item.children)) {
329
+ this._hideTooltip();
330
+ } else {
331
+ this._showTooltip(button);
332
+ }
250
333
  }
251
334
  }
252
335
 
253
336
  /** @private */
254
337
  __onContextMenuKeydown(e) {
255
- const item = Array.from(e.composedPath()).filter((el) => el._item)[0];
338
+ const item = Array.from(e.composedPath()).find((el) => el._item);
256
339
  if (item) {
257
340
  const list = item.parentNode;
258
341
  if (e.keyCode === 38 && item === list.items[0]) {
@@ -262,11 +345,7 @@ export const InteractionsMixin = (superClass) =>
262
345
  if (e.keyCode === 37 || (e.keyCode === 39 && !item._item.children)) {
263
346
  // Prevent ArrowLeft from being handled in context-menu
264
347
  e.stopImmediatePropagation();
265
- this._navigateByKey(e);
266
- const button = this.shadowRoot.activeElement;
267
- if (button && button.item && button.item.children) {
268
- this.__openSubMenu(button, e, { keepFocus: true });
269
- }
348
+ this._onKeyDown(e);
270
349
  }
271
350
  }
272
351
  }
@@ -281,12 +360,12 @@ export const InteractionsMixin = (superClass) =>
281
360
  e.stopPropagation();
282
361
  const button = this._getButtonFromEvent(e);
283
362
  if (button) {
284
- this.__openSubMenu(button, e);
363
+ this.__openSubMenu(button, false);
285
364
  }
286
365
  }
287
366
 
288
367
  /** @private */
289
- __openSubMenu(button, event, options = {}) {
368
+ __openSubMenu(button, keydown, options = {}) {
290
369
  const subMenu = this._subMenu;
291
370
  const item = button.item;
292
371
 
@@ -319,27 +398,33 @@ export const InteractionsMixin = (superClass) =>
319
398
  },
320
399
  }),
321
400
  );
401
+ this._hideTooltip();
322
402
 
323
403
  this._setExpanded(button, true);
324
404
  });
325
405
 
326
- if (options.focusLast) {
327
- this.__onceOpened(() => this._focusLastItem());
328
- }
406
+ this.style.pointerEvents = 'auto';
329
407
 
330
- if (options.keepFocus) {
331
- this.__onceOpened(() => {
332
- this._focusButton(this._expandedButton);
333
- });
334
- }
408
+ overlay.addEventListener(
409
+ 'vaadin-overlay-open',
410
+ () => {
411
+ if (options.focusLast) {
412
+ this._focusLastItem();
413
+ }
335
414
 
336
- this.__onceOpened(() => {
337
- // Do not focus item when open not from keyboard
338
- if (event.type !== 'keydown') {
339
- subMenu.$.overlay.$.overlay.focus();
340
- }
341
- overlay._updatePosition();
342
- });
415
+ if (options.keepFocus) {
416
+ this._focusItem(this._expandedButton, false);
417
+ }
418
+
419
+ // Do not focus item when open not from keyboard
420
+ if (!keydown) {
421
+ overlay.$.overlay.focus();
422
+ }
423
+
424
+ overlay._updatePosition();
425
+ },
426
+ { once: true },
427
+ );
343
428
  }
344
429
 
345
430
  /** @private */
@@ -357,17 +442,6 @@ export const InteractionsMixin = (superClass) =>
357
442
  }
358
443
  }
359
444
 
360
- /** @private */
361
- __onceOpened(cb) {
362
- this.style.pointerEvents = 'auto';
363
- const overlay = this._subMenu.$.overlay;
364
- const listener = () => {
365
- cb();
366
- overlay.removeEventListener('vaadin-overlay-open', listener);
367
- };
368
- overlay.addEventListener('vaadin-overlay-open', listener);
369
- }
370
-
371
445
  /** @private */
372
446
  __onItemSelected(e) {
373
447
  e.stopPropagation();
@@ -386,7 +460,7 @@ export const InteractionsMixin = (superClass) =>
386
460
  if (button && button.hasAttribute('expanded')) {
387
461
  this._setExpanded(button, false);
388
462
  if (restoreFocus) {
389
- this._focusButton(button);
463
+ this._focusItem(button, false);
390
464
  }
391
465
  this._expandedButton = null;
392
466
  }
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2019 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
6
7
  import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
7
8
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
9
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -10,10 +11,31 @@ import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
10
11
  import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
11
12
 
12
13
  export interface MenuBarItem {
14
+ /**
15
+ * Text to be set as the menu button component's textContent.
16
+ */
13
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
+ */
14
27
  component?: HTMLElement | string;
28
+ /**
29
+ * If true, the button is disabled and cannot be activated.
30
+ */
15
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
+ */
16
35
  theme?: string[] | string;
36
+ /**
37
+ * Array of submenu items.
38
+ */
17
39
  children?: SubMenuItem[];
18
40
  }
19
41
 
@@ -89,7 +111,9 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
89
111
  *
90
112
  * @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
91
113
  */
92
- declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement))))) {
114
+ declare class MenuBar extends ButtonsMixin(
115
+ DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement))))),
116
+ ) {
93
117
  /**
94
118
  * Defines a hierarchical structure, where root level items represent menu bar buttons,
95
119
  * and `children` property configures a submenu with items to be opened below
@@ -6,8 +6,10 @@
6
6
  import './vaadin-menu-bar-submenu.js';
7
7
  import './vaadin-menu-bar-button.js';
8
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
9
10
  import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
10
11
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
11
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
14
  import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
13
15
  import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
@@ -61,13 +63,16 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
61
63
  * @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
62
64
  *
63
65
  * @extends HTMLElement
66
+ * @mixes ControllerMixin
64
67
  * @mixes ButtonsMixin
65
68
  * @mixes InteractionsMixin
66
69
  * @mixes DisabledMixin
67
70
  * @mixes ElementMixin
68
71
  * @mixes ThemableMixin
69
72
  */
70
- class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement))))) {
73
+ class MenuBar extends ButtonsMixin(
74
+ DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))))),
75
+ ) {
71
76
  static get template() {
72
77
  return html`
73
78
  <style>
@@ -109,6 +114,8 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
109
114
  </vaadin-menu-bar-button>
110
115
  </div>
111
116
  <vaadin-menu-bar-submenu is-root=""></vaadin-menu-bar-submenu>
117
+
118
+ <slot name="tooltip"></slot>
112
119
  `;
113
120
  }
114
121
 
@@ -122,6 +129,8 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
122
129
  * @typedef MenuBarItem
123
130
  * @type {object}
124
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>`.
125
134
  * @property {union: string | object} component - The component to represent the button content.
126
135
  * Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
127
136
  * @property {boolean} disabled - If true, the button is disabled and cannot be activated.
@@ -213,6 +222,15 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
213
222
  return ['_themeChanged(_theme)'];
214
223
  }
215
224
 
225
+ /** @protected */
226
+ ready() {
227
+ super.ready();
228
+
229
+ this._tooltipController = new TooltipController(this);
230
+ this._tooltipController.setManual(true);
231
+ this.addController(this._tooltipController);
232
+ }
233
+
216
234
  /**
217
235
  * Override method inherited from `DisabledMixin`
218
236
  * to update the `disabled` property for the buttons
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.2.2",
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.2.2/#/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.2.2/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/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.2.2/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/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.2.2",
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.2.2/#/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.2.2/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/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.2.2/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/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
  {