@vaadin/menu-bar 24.8.4 → 25.0.0-alpha10

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.
Files changed (57) hide show
  1. package/README.md +0 -23
  2. package/package.json +18 -19
  3. package/src/styles/vaadin-menu-bar-base-styles.d.ts +8 -0
  4. package/src/styles/vaadin-menu-bar-base-styles.js +55 -0
  5. package/src/styles/vaadin-menu-bar-button-base-styles.d.ts +8 -0
  6. package/src/styles/vaadin-menu-bar-button-base-styles.js +47 -0
  7. package/src/styles/vaadin-menu-bar-button-core-styles.d.ts +8 -0
  8. package/src/styles/vaadin-menu-bar-button-core-styles.js +16 -0
  9. package/src/styles/vaadin-menu-bar-core-styles.d.ts +8 -0
  10. package/src/styles/vaadin-menu-bar-core-styles.js +24 -0
  11. package/src/styles/vaadin-menu-bar-item-base-styles.d.ts +8 -0
  12. package/src/styles/vaadin-menu-bar-item-base-styles.js +8 -0
  13. package/src/styles/vaadin-menu-bar-item-core-styles.d.ts +8 -0
  14. package/src/styles/vaadin-menu-bar-item-core-styles.js +8 -0
  15. package/src/styles/vaadin-menu-bar-overlay-base-styles.d.ts +8 -0
  16. package/src/styles/vaadin-menu-bar-overlay-base-styles.js +9 -0
  17. package/src/styles/vaadin-menu-bar-overlay-core-styles.d.ts +8 -0
  18. package/src/styles/vaadin-menu-bar-overlay-core-styles.js +9 -0
  19. package/src/vaadin-menu-bar-button.js +8 -16
  20. package/src/vaadin-menu-bar-item.js +11 -12
  21. package/src/vaadin-menu-bar-list-box.d.ts +1 -2
  22. package/src/vaadin-menu-bar-list-box.js +17 -26
  23. package/src/vaadin-menu-bar-mixin.d.ts +2 -5
  24. package/src/vaadin-menu-bar-mixin.js +137 -123
  25. package/src/vaadin-menu-bar-overlay.js +16 -11
  26. package/src/vaadin-menu-bar-submenu-mixin.js +3 -3
  27. package/src/vaadin-menu-bar-submenu.js +33 -27
  28. package/src/vaadin-menu-bar.d.ts +3 -6
  29. package/src/vaadin-menu-bar.js +20 -32
  30. package/web-types.json +2 -2
  31. package/web-types.lit.json +2 -2
  32. package/src/vaadin-lit-menu-bar-button.js +0 -67
  33. package/src/vaadin-lit-menu-bar-item.js +0 -62
  34. package/src/vaadin-lit-menu-bar-list-box.js +0 -87
  35. package/src/vaadin-lit-menu-bar-overlay.js +0 -49
  36. package/src/vaadin-lit-menu-bar-submenu.js +0 -57
  37. package/src/vaadin-lit-menu-bar.js +0 -83
  38. package/theme/lumo/vaadin-lit-menu-bar.d.ts +0 -6
  39. package/theme/lumo/vaadin-lit-menu-bar.js +0 -6
  40. package/theme/material/vaadin-lit-menu-bar.d.ts +0 -6
  41. package/theme/material/vaadin-lit-menu-bar.js +0 -6
  42. package/theme/material/vaadin-menu-bar-button-styles.d.ts +0 -1
  43. package/theme/material/vaadin-menu-bar-button-styles.js +0 -111
  44. package/theme/material/vaadin-menu-bar-button.d.ts +0 -2
  45. package/theme/material/vaadin-menu-bar-button.js +0 -2
  46. package/theme/material/vaadin-menu-bar-item-styles.d.ts +0 -1
  47. package/theme/material/vaadin-menu-bar-item-styles.js +0 -23
  48. package/theme/material/vaadin-menu-bar-list-box-styles.d.ts +0 -1
  49. package/theme/material/vaadin-menu-bar-list-box-styles.js +0 -5
  50. package/theme/material/vaadin-menu-bar-overlay-styles.d.ts +0 -1
  51. package/theme/material/vaadin-menu-bar-overlay-styles.js +0 -13
  52. package/theme/material/vaadin-menu-bar-styles.d.ts +0 -1
  53. package/theme/material/vaadin-menu-bar-styles.js +0 -21
  54. package/theme/material/vaadin-menu-bar.d.ts +0 -6
  55. package/theme/material/vaadin-menu-bar.js +0 -6
  56. package/vaadin-lit-menu-bar.d.ts +0 -1
  57. package/vaadin-lit-menu-bar.js +0 -2
@@ -11,7 +11,6 @@ import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
11
11
  import { isElementFocused, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
12
12
  import { KeyboardDirectionMixin } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
13
13
  import { microTask } from '@vaadin/component-base/src/async.js';
14
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
15
14
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
16
15
  import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
17
16
  import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
@@ -58,7 +57,6 @@ const DEFAULT_I18N = {
58
57
 
59
58
  /**
60
59
  * @polymerMixin
61
- * @mixes ControllerMixin
62
60
  * @mixes DisabledMixin
63
61
  * @mixes FocusMixin
64
62
  * @mixes I18nMixin
@@ -68,7 +66,7 @@ const DEFAULT_I18N = {
68
66
  export const MenuBarMixin = (superClass) =>
69
67
  class MenuBarMixinClass extends I18nMixin(
70
68
  DEFAULT_I18N,
71
- KeyboardDirectionMixin(ResizeMixin(FocusMixin(DisabledMixin(ControllerMixin(superClass))))),
69
+ KeyboardDirectionMixin(ResizeMixin(FocusMixin(DisabledMixin(superClass)))),
72
70
  ) {
73
71
  static get properties() {
74
72
  return {
@@ -193,41 +191,9 @@ export const MenuBarMixin = (superClass) =>
193
191
  type: Boolean,
194
192
  sync: true,
195
193
  },
196
-
197
- /**
198
- * @type {boolean}
199
- * @protected
200
- */
201
- _hasOverflow: {
202
- type: Boolean,
203
- value: false,
204
- sync: true,
205
- },
206
-
207
- /** @protected */
208
- _overflow: {
209
- type: Object,
210
- },
211
-
212
- /** @protected */
213
- _container: {
214
- type: Object,
215
- sync: true,
216
- },
217
194
  };
218
195
  }
219
196
 
220
- static get observers() {
221
- return [
222
- '_themeChanged(_theme, _overflow, _container)',
223
- '__hasOverflowChanged(_hasOverflow, _overflow)',
224
- '__i18nChanged(__effectiveI18n, _overflow)',
225
- '__updateButtons(items, disabled, _overflow, _container)',
226
- '_reverseCollapseChanged(reverseCollapse, _overflow, _container)',
227
- '_tabNavigationChanged(tabNavigation, _overflow, _container)',
228
- ];
229
- }
230
-
231
197
  /**
232
198
  * The object used to localize this component. To change the default
233
199
  * localization, replace this with an object that provides all properties, or
@@ -309,8 +275,15 @@ export const MenuBarMixin = (superClass) =>
309
275
  }
310
276
 
311
277
  /** @private */
312
- get _subMenu() {
313
- return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
278
+ get _hasOverflow() {
279
+ return this._overflow && !this._overflow.hasAttribute('hidden');
280
+ }
281
+
282
+ /** @private */
283
+ set _hasOverflow(hasOverflow) {
284
+ if (this._overflow) {
285
+ this._overflow.toggleAttribute('hidden', !hasOverflow);
286
+ }
314
287
  }
315
288
 
316
289
  /** @protected */
@@ -319,6 +292,20 @@ export const MenuBarMixin = (superClass) =>
319
292
 
320
293
  this.setAttribute('role', 'menubar');
321
294
 
295
+ this._subMenuController = new SlotController(this, 'submenu', 'vaadin-menu-bar-submenu', {
296
+ initializer: (menu) => {
297
+ menu.setAttribute('is-root', '');
298
+
299
+ menu.addEventListener('item-selected', this.__onItemSelected.bind(this));
300
+ menu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
301
+
302
+ const overlay = menu._overlayElement;
303
+ overlay._contentRoot.addEventListener('keydown', this.__boundOnContextMenuKeydown);
304
+
305
+ this._subMenu = menu;
306
+ },
307
+ });
308
+
322
309
  this._overflowController = new SlotController(this, 'overflow', 'vaadin-menu-bar-button', {
323
310
  initializer: (btn) => {
324
311
  btn.setAttribute('hidden', '');
@@ -335,21 +322,51 @@ export const MenuBarMixin = (superClass) =>
335
322
  this._overflow = btn;
336
323
  },
337
324
  });
325
+
326
+ this.addController(this._subMenuController);
338
327
  this.addController(this._overflowController);
339
328
 
340
329
  this.addEventListener('mousedown', () => this._hideTooltip(true));
341
330
  this.addEventListener('mouseleave', () => this._hideTooltip());
342
331
 
343
- this._subMenu.addEventListener('item-selected', this.__onItemSelected.bind(this));
344
- this._subMenu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
332
+ this._container = this.shadowRoot.querySelector('[part="container"]');
333
+ }
345
334
 
346
- const overlay = this._subMenu._overlayElement;
347
- overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
335
+ /** @protected */
336
+ updated(props) {
337
+ super.updated(props);
338
+
339
+ if (props.has('items') || props.has('_theme') || props.has('disabled')) {
340
+ this.__renderButtons(this.items);
341
+ }
348
342
 
349
- const container = this.shadowRoot.querySelector('[part="container"]');
350
- container.addEventListener('click', this.__onButtonClick.bind(this));
351
- container.addEventListener('mouseover', (e) => this._onMouseOver(e));
352
- this._container = container;
343
+ if (props.has('items') || props.has('_theme') || props.has('reverseCollapse')) {
344
+ this.__scheduleOverflow();
345
+ }
346
+
347
+ if (props.has('items')) {
348
+ this.__updateSubMenu();
349
+ }
350
+
351
+ if (props.has('overlayClass')) {
352
+ this._subMenu.overlayClass = this.overlayClass;
353
+ }
354
+
355
+ if (props.has('_theme')) {
356
+ this._themeChanged(this._theme);
357
+ }
358
+
359
+ if (props.has('disabled')) {
360
+ this._overflow.toggleAttribute('disabled', this.disabled);
361
+ }
362
+
363
+ if (props.has('tabNavigation')) {
364
+ this._tabNavigationChanged(this.tabNavigation);
365
+ }
366
+
367
+ if (props.has('__effectiveI18n')) {
368
+ this.__i18nChanged(this.__effectiveI18n);
369
+ }
353
370
  }
354
371
 
355
372
  /**
@@ -381,81 +398,34 @@ export const MenuBarMixin = (superClass) =>
381
398
  this.__scheduleOverflow();
382
399
  }
383
400
 
384
- /**
385
- * A callback for the `_theme` property observer.
386
- * It propagates the host theme to the buttons and the sub menu.
387
- *
388
- * @param {string | null} theme
389
- * @private
390
- */
391
- _themeChanged(theme, overflow, container) {
392
- if (overflow && container) {
393
- this.__renderButtons(this.items);
394
- this.__scheduleOverflow();
395
-
396
- if (theme) {
397
- overflow.setAttribute('theme', theme);
398
- this._subMenu.setAttribute('theme', theme);
399
- } else {
400
- overflow.removeAttribute('theme');
401
- this._subMenu.removeAttribute('theme');
402
- }
403
- }
404
- }
405
-
406
- /**
407
- * A callback for the 'reverseCollapse' property observer.
408
- *
409
- * @param {boolean | null} _reverseCollapse
410
- * @private
411
- */
412
- _reverseCollapseChanged(_reverseCollapse, overflow, container) {
413
- if (overflow && container) {
414
- this.__scheduleOverflow();
415
- }
416
- }
417
-
418
401
  /** @private */
419
- _tabNavigationChanged(tabNavigation, overflow, container) {
420
- if (overflow && container) {
421
- const target = this.querySelector('[tabindex="0"]');
422
- this._buttons.forEach((btn) => {
423
- if (target) {
424
- this._setTabindex(btn, btn === target);
425
- } else {
426
- this._setTabindex(btn, false);
427
- }
428
- btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
429
- });
402
+ _themeChanged(theme) {
403
+ if (theme) {
404
+ this._overflow.setAttribute('theme', theme);
405
+ this._subMenu.setAttribute('theme', theme);
406
+ } else {
407
+ this._overflow.removeAttribute('theme');
408
+ this._subMenu.removeAttribute('theme');
430
409
  }
431
- this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
432
410
  }
433
411
 
434
412
  /** @private */
435
- __hasOverflowChanged(hasOverflow, overflow) {
436
- if (overflow) {
437
- overflow.toggleAttribute('hidden', !hasOverflow);
438
- }
413
+ _tabNavigationChanged(tabNavigation) {
414
+ const target = this.querySelector('[tabindex="0"]');
415
+ this._buttons.forEach((btn) => {
416
+ if (target) {
417
+ this._setTabindex(btn, btn === target);
418
+ } else {
419
+ this._setTabindex(btn, false);
420
+ }
421
+ btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
422
+ });
423
+
424
+ this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
439
425
  }
440
426
 
441
427
  /** @private */
442
- __updateButtons(items, disabled, overflow, container) {
443
- if (!overflow || !container) {
444
- return;
445
- }
446
-
447
- if (items !== this._oldItems) {
448
- this._oldItems = items;
449
- this.__renderButtons(items);
450
- this.__scheduleOverflow();
451
- }
452
-
453
- if (disabled !== this._oldDisabled) {
454
- this._oldDisabled = disabled;
455
- this.__renderButtons(items);
456
- overflow.toggleAttribute('disabled', disabled);
457
- }
458
-
428
+ __updateSubMenu() {
459
429
  const subMenu = this._subMenu;
460
430
  if (subMenu && subMenu.opened) {
461
431
  const button = subMenu._overlayElement.positionTarget;
@@ -469,12 +439,12 @@ export const MenuBarMixin = (superClass) =>
469
439
  }
470
440
 
471
441
  /** @private */
472
- __i18nChanged(effectiveI18n, overflow) {
473
- if (overflow && effectiveI18n && effectiveI18n.moreOptions !== undefined) {
442
+ __i18nChanged(effectiveI18n) {
443
+ if (effectiveI18n && effectiveI18n.moreOptions !== undefined) {
474
444
  if (effectiveI18n.moreOptions) {
475
- overflow.setAttribute('aria-label', effectiveI18n.moreOptions);
445
+ this._overflow.setAttribute('aria-label', effectiveI18n.moreOptions);
476
446
  } else {
477
- overflow.removeAttribute('aria-label');
447
+ this._overflow.removeAttribute('aria-label');
478
448
  }
479
449
  }
480
450
  }
@@ -708,6 +678,7 @@ export const MenuBarMixin = (superClass) =>
708
678
  _hideTooltip(immediate) {
709
679
  const tooltip = this._tooltipController && this._tooltipController.node;
710
680
  if (tooltip) {
681
+ this._tooltipController.setContext({ item: null });
711
682
  tooltip._stateController.close(immediate);
712
683
  }
713
684
  }
@@ -771,6 +742,34 @@ export const MenuBarMixin = (superClass) =>
771
742
  return Array.from(e.composedPath()).find((el) => el.localName === 'vaadin-menu-bar-button');
772
743
  }
773
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
+
774
773
  /**
775
774
  * Override method inherited from `FocusMixin`
776
775
  *
@@ -853,6 +852,16 @@ export const MenuBarMixin = (superClass) =>
853
852
  * @override
854
853
  */
855
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) {
856
865
  switch (event.key) {
857
866
  case 'ArrowDown':
858
867
  this._onArrowDown(event);
@@ -867,11 +876,16 @@ export const MenuBarMixin = (superClass) =>
867
876
  }
868
877
 
869
878
  /**
870
- * @param {!MouseEvent} e
879
+ * @param {!MouseEvent} event
871
880
  * @protected
872
881
  */
873
- _onMouseOver(e) {
874
- const button = this._getButtonFromEvent(e);
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);
875
889
  if (!button) {
876
890
  // Hide tooltip on mouseover to disabled button
877
891
  this._hideTooltip();
@@ -903,11 +917,11 @@ export const MenuBarMixin = (superClass) =>
903
917
  if (e.keyCode === 37 || (e.keyCode === 39 && !item._item.children)) {
904
918
  // Prevent ArrowLeft from being handled in context-menu
905
919
  e.stopImmediatePropagation();
906
- this._onKeyDown(e);
920
+ this._handleKeyDown(e);
907
921
  }
908
922
 
909
923
  if (e.key === 'Tab' && this.tabNavigation) {
910
- this._onKeyDown(e);
924
+ this._handleKeyDown(e);
911
925
  }
912
926
  }
913
927
  }
@@ -990,13 +1004,13 @@ export const MenuBarMixin = (superClass) =>
990
1004
 
991
1005
  /** @private */
992
1006
  _focusFirstItem() {
993
- const list = this._subMenu._overlayElement.firstElementChild;
1007
+ const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
994
1008
  list.focus();
995
1009
  }
996
1010
 
997
1011
  /** @private */
998
1012
  _focusLastItem() {
999
- const list = this._subMenu._overlayElement.firstElementChild;
1013
+ const list = this._subMenu._overlayElement._contentRoot.firstElementChild;
1000
1014
  const item = list.items[list.items.length - 1];
1001
1015
  if (item) {
1002
1016
  item.focus();
@@ -3,18 +3,15 @@
3
3
  * Copyright (c) 2019 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
10
  import { MenuOverlayMixin } from '@vaadin/context-menu/src/vaadin-menu-overlay-mixin.js';
10
- import { styles } from '@vaadin/context-menu/src/vaadin-menu-overlay-styles.js';
11
11
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
12
- import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
13
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
-
15
- registerStyles('vaadin-menu-bar-overlay', [overlayStyles, styles], {
16
- moduleId: 'vaadin-menu-bar-overlay-styles',
17
- });
12
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
13
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+ import { menuBarOverlayStyles } from './styles/vaadin-menu-bar-overlay-core-styles.js';
18
15
 
19
16
  /**
20
17
  * An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
@@ -27,17 +24,25 @@ registerStyles('vaadin-menu-bar-overlay', [overlayStyles, styles], {
27
24
  * @mixes ThemableMixin
28
25
  * @protected
29
26
  */
30
- export class MenuBarOverlay extends MenuOverlayMixin(OverlayMixin(DirMixin(ThemableMixin(PolymerElement)))) {
27
+ export class MenuBarOverlay extends MenuOverlayMixin(
28
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
29
+ ) {
31
30
  static get is() {
32
31
  return 'vaadin-menu-bar-overlay';
33
32
  }
34
33
 
35
- static get template() {
34
+ static get styles() {
35
+ return menuBarOverlayStyles;
36
+ }
37
+
38
+ /** @protected */
39
+ render() {
36
40
  return html`
37
- <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div>
41
+ <div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
38
42
  <div part="overlay" id="overlay" tabindex="0">
39
43
  <div part="content" id="content">
40
44
  <slot></slot>
45
+ <slot name="submenu"></slot>
41
46
  </div>
42
47
  </div>
43
48
  `;
@@ -31,8 +31,8 @@ export const SubMenuMixin = (superClass) =>
31
31
  /**
32
32
  * Overriding the observer to not add global "contextmenu" listener.
33
33
  */
34
- _openedChanged(opened) {
35
- this._overlayElement.opened = opened;
34
+ _openedChanged() {
35
+ // Do nothing
36
36
  }
37
37
 
38
38
  /**
@@ -43,7 +43,7 @@ export const SubMenuMixin = (superClass) =>
43
43
 
44
44
  // Only handle 1st level submenu
45
45
  if (this.hasAttribute('is-root')) {
46
- this.getRootNode().host._close();
46
+ this.parentElement._close();
47
47
  }
48
48
  }
49
49
 
@@ -6,9 +6,10 @@
6
6
  import './vaadin-menu-bar-item.js';
7
7
  import './vaadin-menu-bar-list-box.js';
8
8
  import './vaadin-menu-bar-overlay.js';
9
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
10
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
9
+ import { css, html, LitElement } from 'lit';
10
+ import { ifDefined } from 'lit/directives/if-defined.js';
11
11
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
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';
13
14
  import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
14
15
 
@@ -17,43 +18,48 @@ import { SubMenuMixin } from './vaadin-menu-bar-submenu-mixin.js';
17
18
  *
18
19
  * @customElement
19
20
  * @extends HTMLElement
20
- * @mixes ControllerMixin
21
21
  * @mixes SubMenuMixin
22
22
  * @mixes ThemePropertyMixin
23
23
  * @protected
24
24
  */
25
- class MenuBarSubmenu extends SubMenuMixin(ControllerMixin(ThemePropertyMixin(PolymerElement))) {
25
+ class MenuBarSubmenu extends SubMenuMixin(ThemePropertyMixin(PolylitMixin(LitElement))) {
26
26
  static get is() {
27
27
  return 'vaadin-menu-bar-submenu';
28
28
  }
29
29
 
30
- static get template() {
31
- return html`
32
- <style>
33
- :host {
34
- display: block;
35
- }
36
-
37
- :host([hidden]) {
38
- display: none !important;
39
- }
40
- </style>
30
+ static get styles() {
31
+ return css`
32
+ :host {
33
+ display: block;
34
+ }
41
35
 
42
- <slot id="slot"></slot>
36
+ :host([hidden]) {
37
+ display: none !important;
38
+ }
43
39
  `;
44
40
  }
45
41
 
46
- /**
47
- * @param {DocumentFragment} dom
48
- * @return {ShadowRoot}
49
- * @protected
50
- * @override
51
- */
52
- _attachDom(dom) {
53
- const root = this.attachShadow({ mode: 'open' });
54
- root.appendChild(dom);
55
- root.appendChild(this._overlayElement);
56
- return root;
42
+ /** @protected */
43
+ render() {
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
+ `;
57
63
  }
58
64
  }
59
65
 
@@ -30,13 +30,13 @@ export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
30
30
  *
31
31
  * To create the menu bar, first add the component to the page:
32
32
  *
33
- * ```
33
+ * ```html
34
34
  * <vaadin-menu-bar></vaadin-menu-bar>
35
35
  * ```
36
36
  *
37
37
  * And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
38
38
  *
39
- * ```
39
+ * ```js
40
40
  * document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
41
41
  * ```
42
42
  *
@@ -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-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
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 {