@vaadin/menu-bar 24.3.0-beta2 → 24.3.0-rc1

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.3.0-beta2",
3
+ "version": "24.3.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,20 +37,20 @@
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/a11y-base": "24.3.0-beta2",
41
- "@vaadin/button": "24.3.0-beta2",
42
- "@vaadin/component-base": "24.3.0-beta2",
43
- "@vaadin/context-menu": "24.3.0-beta2",
44
- "@vaadin/item": "24.3.0-beta2",
45
- "@vaadin/list-box": "24.3.0-beta2",
46
- "@vaadin/overlay": "24.3.0-beta2",
47
- "@vaadin/vaadin-lumo-styles": "24.3.0-beta2",
48
- "@vaadin/vaadin-material-styles": "24.3.0-beta2",
49
- "@vaadin/vaadin-themable-mixin": "24.3.0-beta2"
40
+ "@vaadin/a11y-base": "24.3.0-rc1",
41
+ "@vaadin/button": "24.3.0-rc1",
42
+ "@vaadin/component-base": "24.3.0-rc1",
43
+ "@vaadin/context-menu": "24.3.0-rc1",
44
+ "@vaadin/item": "24.3.0-rc1",
45
+ "@vaadin/list-box": "24.3.0-rc1",
46
+ "@vaadin/overlay": "24.3.0-rc1",
47
+ "@vaadin/vaadin-lumo-styles": "24.3.0-rc1",
48
+ "@vaadin/vaadin-material-styles": "24.3.0-rc1",
49
+ "@vaadin/vaadin-themable-mixin": "24.3.0-rc1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@esm-bundle/chai": "^4.3.4",
53
- "@vaadin/icon": "24.3.0-beta2",
53
+ "@vaadin/icon": "24.3.0-rc1",
54
54
  "@vaadin/testing-helpers": "^0.6.0",
55
55
  "sinon": "^13.0.2"
56
56
  },
@@ -58,5 +58,5 @@
58
58
  "web-types.json",
59
59
  "web-types.lit.json"
60
60
  ],
61
- "gitHead": "0bbfb24cb8dcd6e1dca8ecf2269635efac53e4d0"
61
+ "gitHead": "54430cfc0f52bb6fc17b0fc325b0d62e0e49c700"
62
62
  }
@@ -4,15 +4,65 @@
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 { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
7
8
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
8
9
  import type { KeyboardDirectionMixinClass } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
9
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
10
11
  import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
11
12
  import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
12
13
 
14
+ export interface MenuBarItem {
15
+ /**
16
+ * Text to be set as the menu button component's textContent.
17
+ */
18
+ text?: string;
19
+ /**
20
+ * Text to be set as the menu button's tooltip.
21
+ * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
22
+ */
23
+ tooltip?: string;
24
+ /**
25
+ * The component to represent the button content.
26
+ * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
27
+ */
28
+ component?: HTMLElement | string;
29
+ /**
30
+ * If true, the button is disabled and cannot be activated.
31
+ */
32
+ disabled?: boolean;
33
+ /**
34
+ * Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
35
+ */
36
+ theme?: string[] | string;
37
+ /**
38
+ * Array of submenu items.
39
+ */
40
+ children?: SubMenuItem[];
41
+
42
+ /**
43
+ * Class/classes to be set to the class attribute of the button.
44
+ */
45
+ className?: string;
46
+ }
47
+
48
+ export interface SubMenuItem {
49
+ text?: string;
50
+ component?: HTMLElement | string;
51
+ disabled?: boolean;
52
+ theme?: string[] | string;
53
+ checked?: boolean;
54
+ className?: string;
55
+ children?: SubMenuItem[];
56
+ }
57
+
58
+ export interface MenuBarI18n {
59
+ moreOptions: string;
60
+ }
61
+
13
62
  export declare function MenuBarMixin<T extends Constructor<HTMLElement>>(
14
63
  base: T,
15
64
  ): Constructor<ControllerMixinClass> &
65
+ Constructor<DisabledMixinClass> &
16
66
  Constructor<FocusMixinClass> &
17
67
  Constructor<KeyboardDirectionMixinClass> &
18
68
  Constructor<KeyboardMixinClass> &
@@ -21,6 +71,67 @@ export declare function MenuBarMixin<T extends Constructor<HTMLElement>>(
21
71
  T;
22
72
 
23
73
  export declare class MenuBarMixinClass {
74
+ /**
75
+ * Defines a hierarchical structure, where root level items represent menu bar buttons,
76
+ * and `children` property configures a submenu with items to be opened below
77
+ * the button on click, Enter, Space, Up and Down arrow keys.
78
+ *
79
+ * #### Example
80
+ *
81
+ * ```js
82
+ * menubar.items = [
83
+ * {
84
+ * text: 'File',
85
+ * className: 'file',
86
+ * children: [
87
+ * {text: 'Open', className: 'file open'}
88
+ * {text: 'Auto Save', checked: true},
89
+ * ]
90
+ * },
91
+ * {component: 'hr'},
92
+ * {
93
+ * text: 'Edit',
94
+ * children: [
95
+ * {text: 'Undo', disabled: true},
96
+ * {text: 'Redo'}
97
+ * ]
98
+ * },
99
+ * {text: 'Help'}
100
+ * ];
101
+ * ```
102
+ */
103
+ items: MenuBarItem[];
104
+
105
+ /**
106
+ * The object used to localize this component.
107
+ * To change the default localization, replace the entire
108
+ * `i18n` object with a custom one.
109
+ *
110
+ * To update individual properties, extend the existing i18n object like so:
111
+ * ```
112
+ * menuBar.i18n = {
113
+ * ...menuBar.i18n,
114
+ * moreOptions: 'More options'
115
+ * }
116
+ * ```
117
+ *
118
+ * The object has the following JSON structure and default values:
119
+ * ```
120
+ * {
121
+ * moreOptions: 'More options'
122
+ * }
123
+ * ```
124
+ */
125
+ i18n: MenuBarI18n;
126
+
127
+ /**
128
+ * A space-delimited list of CSS class names
129
+ * to set on each sub-menu overlay element.
130
+ *
131
+ * @attr {string} overlay-class
132
+ */
133
+ overlayClass: string;
134
+
24
135
  /**
25
136
  * If true, the submenu will open on hover (mouseover) instead of click.
26
137
  * @attr {boolean} open-on-hover
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2019 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
6
7
  import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
7
8
  import { isElementFocused, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
8
9
  import { KeyboardDirectionMixin } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
@@ -12,15 +13,120 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
12
13
 
13
14
  /**
14
15
  * @polymerMixin
16
+ * @mixes DisabledMixin
15
17
  * @mixes ControllerMixin
16
18
  * @mixes FocusMixin
17
19
  * @mixes KeyboardDirectionMixin
18
20
  * @mixes ResizeMixin
19
21
  */
20
22
  export const MenuBarMixin = (superClass) =>
21
- class MenuBarMixinClass extends KeyboardDirectionMixin(ResizeMixin(FocusMixin(ControllerMixin(superClass)))) {
23
+ class MenuBarMixinClass extends KeyboardDirectionMixin(
24
+ ResizeMixin(FocusMixin(DisabledMixin(ControllerMixin(superClass)))),
25
+ ) {
22
26
  static get properties() {
23
27
  return {
28
+ /**
29
+ * @typedef MenuBarItem
30
+ * @type {object}
31
+ * @property {string} text - Text to be set as the menu button component's textContent.
32
+ * @property {string} tooltip - Text to be set as the menu button's tooltip.
33
+ * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
34
+ * @property {union: string | object} component - The component to represent the button content.
35
+ * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
36
+ * @property {boolean} disabled - If true, the button is disabled and cannot be activated.
37
+ * @property {union: string | string[]} theme - Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
38
+ * @property {SubMenuItem[]} children - Array of submenu items.
39
+ */
40
+
41
+ /**
42
+ * @typedef SubMenuItem
43
+ * @type {object}
44
+ * @property {string} text - Text to be set as the menu item component's textContent.
45
+ * @property {union: string | object} component - The component to represent the item.
46
+ * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
47
+ * @property {boolean} disabled - If true, the item is disabled and cannot be selected.
48
+ * @property {boolean} checked - If true, the item shows a checkmark next to it.
49
+ * @property {SubMenuItem[]} children - Array of child submenu items.
50
+ */
51
+
52
+ /**
53
+ * Defines a hierarchical structure, where root level items represent menu bar buttons,
54
+ * and `children` property configures a submenu with items to be opened below
55
+ * the button on click, Enter, Space, Up and Down arrow keys.
56
+ *
57
+ * #### Example
58
+ *
59
+ * ```js
60
+ * menubar.items = [
61
+ * {
62
+ * text: 'File',
63
+ * className: 'file',
64
+ * children: [
65
+ * {text: 'Open', className: 'file open'}
66
+ * {text: 'Auto Save', checked: true},
67
+ * ]
68
+ * },
69
+ * {component: 'hr'},
70
+ * {
71
+ * text: 'Edit',
72
+ * children: [
73
+ * {text: 'Undo', disabled: true},
74
+ * {text: 'Redo'}
75
+ * ]
76
+ * },
77
+ * {text: 'Help'}
78
+ * ];
79
+ * ```
80
+ *
81
+ * @type {!Array<!MenuBarItem>}
82
+ */
83
+ items: {
84
+ type: Array,
85
+ value: () => [],
86
+ },
87
+
88
+ /**
89
+ * The object used to localize this component.
90
+ * To change the default localization, replace the entire
91
+ * `i18n` object with a custom one.
92
+ *
93
+ * To update individual properties, extend the existing i18n object like so:
94
+ * ```
95
+ * menuBar.i18n = {
96
+ * ...menuBar.i18n,
97
+ * moreOptions: 'More options'
98
+ * }
99
+ * ```
100
+ *
101
+ * The object has the following JSON structure and default values:
102
+ * ```
103
+ * {
104
+ * moreOptions: 'More options'
105
+ * }
106
+ * ```
107
+ *
108
+ * @type {!MenuBarI18n}
109
+ * @default {English/US}
110
+ */
111
+ i18n: {
112
+ type: Object,
113
+ value: () => {
114
+ return {
115
+ moreOptions: 'More options',
116
+ };
117
+ },
118
+ },
119
+
120
+ /**
121
+ * A space-delimited list of CSS class names
122
+ * to set on each sub-menu overlay element.
123
+ *
124
+ * @attr {string} overlay-class
125
+ */
126
+ overlayClass: {
127
+ type: String,
128
+ },
129
+
24
130
  /**
25
131
  * If true, the submenu will open on hover (mouseover) instead of click.
26
132
  * @attr {boolean} open-on-hover
@@ -52,10 +158,10 @@ export const MenuBarMixin = (superClass) =>
52
158
 
53
159
  static get observers() {
54
160
  return [
55
- '_itemsChanged(items, items.splices)',
161
+ '_themeChanged(_theme, _overflow, _container)',
56
162
  '__hasOverflowChanged(_hasOverflow, _overflow)',
57
163
  '__i18nChanged(i18n, _overflow)',
58
- '_menuItemsChanged(items, _overflow, _container, items.splices)',
164
+ '_menuItemsChanged(items, _overflow, _container)',
59
165
  ];
60
166
  }
61
167
 
@@ -177,6 +283,43 @@ export const MenuBarMixin = (superClass) =>
177
283
  this.__detectOverflow();
178
284
  }
179
285
 
286
+ /**
287
+ * Override method inherited from `DisabledMixin`
288
+ * to update the `disabled` property for the buttons
289
+ * whenever the property changes on the menu bar.
290
+ *
291
+ * @param {boolean} newValue the new disabled value
292
+ * @param {boolean} oldValue the previous disabled value
293
+ * @override
294
+ * @protected
295
+ */
296
+ _disabledChanged(newValue, oldValue) {
297
+ super._disabledChanged(newValue, oldValue);
298
+ if (oldValue !== newValue) {
299
+ this.__updateButtonsDisabled(newValue);
300
+ }
301
+ }
302
+
303
+ /**
304
+ * A callback for the `_theme` property observer.
305
+ * It propagates the host theme to the buttons and the sub menu.
306
+ *
307
+ * @param {string | null} theme
308
+ * @private
309
+ */
310
+ _themeChanged(theme, overflow, container) {
311
+ if (overflow && container) {
312
+ this._buttons.forEach((btn) => this._setButtonTheme(btn, theme));
313
+ this.__detectOverflow();
314
+ }
315
+
316
+ if (theme) {
317
+ this._subMenu.setAttribute('theme', theme);
318
+ } else {
319
+ this._subMenu.removeAttribute('theme');
320
+ }
321
+ }
322
+
180
323
  /** @private */
181
324
  __hasOverflowChanged(hasOverflow, overflow) {
182
325
  if (overflow) {
@@ -194,6 +337,11 @@ export const MenuBarMixin = (superClass) =>
194
337
  this._oldItems = items;
195
338
  this.__renderButtons(items);
196
339
  }
340
+
341
+ const subMenu = this._subMenu;
342
+ if (subMenu && subMenu.opened) {
343
+ subMenu.close();
344
+ }
197
345
  }
198
346
 
199
347
  /** @private */
@@ -238,6 +386,14 @@ export const MenuBarMixin = (superClass) =>
238
386
  item.removeAttribute('tabindex');
239
387
  }
240
388
 
389
+ /** @private */
390
+ __updateButtonsDisabled(disabled) {
391
+ this._buttons.forEach((btn) => {
392
+ // Disable the button if the entire menu-bar is disabled or the item alone is disabled
393
+ btn.disabled = disabled || (btn.item && btn.item.disabled);
394
+ });
395
+ }
396
+
241
397
  /** @private */
242
398
  __updateOverflow(items) {
243
399
  this._overflow.item = { children: items };
@@ -591,14 +747,6 @@ export const MenuBarMixin = (superClass) =>
591
747
  }
592
748
  }
593
749
 
594
- /** @private */
595
- _itemsChanged() {
596
- const subMenu = this._subMenu;
597
- if (subMenu && subMenu.opened) {
598
- subMenu.close();
599
- }
600
- }
601
-
602
750
  /**
603
751
  * @param {!MouseEvent} e
604
752
  * @protected
@@ -35,17 +35,6 @@ class MenuBarSubmenu extends ContextMenu {
35
35
  </style>
36
36
 
37
37
  <slot id="slot"></slot>
38
-
39
- <vaadin-menu-bar-overlay
40
- id="overlay"
41
- on-opened-changed="_onOverlayOpened"
42
- on-vaadin-overlay-open="_onVaadinOverlayOpen"
43
- modeless="[[_modeless]]"
44
- with-backdrop="[[_phone]]"
45
- phone$="[[_phone]]"
46
- model="[[_context]]"
47
- theme$="[[_theme]]"
48
- ></vaadin-menu-bar-overlay>
49
38
  `;
50
39
  }
51
40
 
@@ -6,55 +6,9 @@
6
6
  import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
7
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
- import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
9
+ import { type MenuBarItem, MenuBarMixin } from './vaadin-menu-bar-mixin.js';
10
10
 
11
- export interface MenuBarItem {
12
- /**
13
- * Text to be set as the menu button component's textContent.
14
- */
15
- text?: string;
16
- /**
17
- * Text to be set as the menu button's tooltip.
18
- * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
19
- */
20
- tooltip?: string;
21
- /**
22
- * The component to represent the button content.
23
- * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
24
- */
25
- component?: HTMLElement | string;
26
- /**
27
- * If true, the button is disabled and cannot be activated.
28
- */
29
- disabled?: boolean;
30
- /**
31
- * Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
32
- */
33
- theme?: string[] | string;
34
- /**
35
- * Array of submenu items.
36
- */
37
- children?: SubMenuItem[];
38
-
39
- /**
40
- * Class/classes to be set to the class attribute of the button.
41
- */
42
- className?: string;
43
- }
44
-
45
- export interface SubMenuItem {
46
- text?: string;
47
- component?: HTMLElement | string;
48
- disabled?: boolean;
49
- theme?: string[] | string;
50
- checked?: boolean;
51
- className?: string;
52
- children?: SubMenuItem[];
53
- }
54
-
55
- export interface MenuBarI18n {
56
- moreOptions: string;
57
- }
11
+ export { MenuBarItem, MenuBarI18n, SubMenuItem } from './vaadin-menu-bar-mixin.js';
58
12
 
59
13
  /**
60
14
  * Fired when a submenu item or menu bar button without children is clicked.
@@ -114,67 +68,6 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
114
68
  * @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
115
69
  */
116
70
  declare class MenuBar extends MenuBarMixin(DisabledMixin(ElementMixin(ThemableMixin(HTMLElement)))) {
117
- /**
118
- * Defines a hierarchical structure, where root level items represent menu bar buttons,
119
- * and `children` property configures a submenu with items to be opened below
120
- * the button on click, Enter, Space, Up and Down arrow keys.
121
- *
122
- * #### Example
123
- *
124
- * ```js
125
- * menubar.items = [
126
- * {
127
- * text: 'File',
128
- * className: 'file',
129
- * children: [
130
- * {text: 'Open', className: 'file open'}
131
- * {text: 'Auto Save', checked: true},
132
- * ]
133
- * },
134
- * {component: 'hr'},
135
- * {
136
- * text: 'Edit',
137
- * children: [
138
- * {text: 'Undo', disabled: true},
139
- * {text: 'Redo'}
140
- * ]
141
- * },
142
- * {text: 'Help'}
143
- * ];
144
- * ```
145
- */
146
- items: MenuBarItem[];
147
-
148
- /**
149
- * The object used to localize this component.
150
- * To change the default localization, replace the entire
151
- * `i18n` object with a custom one.
152
- *
153
- * To update individual properties, extend the existing i18n object like so:
154
- * ```
155
- * menuBar.i18n = {
156
- * ...menuBar.i18n,
157
- * moreOptions: 'More options'
158
- * }
159
- * ```
160
- *
161
- * The object has the following JSON structure and default values:
162
- * ```
163
- * {
164
- * moreOptions: 'More options'
165
- * }
166
- * ```
167
- */
168
- i18n: MenuBarI18n;
169
-
170
- /**
171
- * A space-delimited list of CSS class names
172
- * to set on each sub-menu overlay element.
173
- *
174
- * @attr {string} overlay-class
175
- */
176
- overlayClass: string;
177
-
178
71
  addEventListener<K extends keyof MenuBarEventMap>(
179
72
  type: K,
180
73
  listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
@@ -186,12 +79,6 @@ declare class MenuBar extends MenuBarMixin(DisabledMixin(ElementMixin(ThemableMi
186
79
  listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
187
80
  options?: EventListenerOptions | boolean,
188
81
  ): void;
189
-
190
- /**
191
- * A callback for the `_theme` property observer.
192
- * It propagates the host theme to the buttons and the sub menu.
193
- */
194
- protected _themeChanged(theme: string | null): void;
195
82
  }
196
83
 
197
84
  declare global {
@@ -6,7 +6,6 @@
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 { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
10
9
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
11
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
11
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
@@ -61,12 +60,11 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
61
60
  *
62
61
  * @customElement
63
62
  * @extends HTMLElement
64
- * @mixes DisabledMixin
65
63
  * @mixes ElementMixin
66
64
  * @mixes MenuBarMixin
67
65
  * @mixes ThemableMixin
68
66
  */
69
- class MenuBar extends MenuBarMixin(DisabledMixin(ElementMixin(ThemableMixin(PolymerElement)))) {
67
+ class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolymerElement))) {
70
68
  static get template() {
71
69
  return html`
72
70
  <style>
@@ -101,116 +99,6 @@ class MenuBar extends MenuBarMixin(DisabledMixin(ElementMixin(ThemableMixin(Poly
101
99
  return 'vaadin-menu-bar';
102
100
  }
103
101
 
104
- static get properties() {
105
- return {
106
- /**
107
- * @typedef MenuBarItem
108
- * @type {object}
109
- * @property {string} text - Text to be set as the menu button component's textContent.
110
- * @property {string} tooltip - Text to be set as the menu button's tooltip.
111
- * Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
112
- * @property {union: string | object} component - The component to represent the button content.
113
- * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
114
- * @property {boolean} disabled - If true, the button is disabled and cannot be activated.
115
- * @property {union: string | string[]} theme - Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
116
- * @property {SubMenuItem[]} children - Array of submenu items.
117
- */
118
-
119
- /**
120
- * @typedef SubMenuItem
121
- * @type {object}
122
- * @property {string} text - Text to be set as the menu item component's textContent.
123
- * @property {union: string | object} component - The component to represent the item.
124
- * Either a tagName or an element instance. Defaults to "vaadin-menu-bar-item".
125
- * @property {boolean} disabled - If true, the item is disabled and cannot be selected.
126
- * @property {boolean} checked - If true, the item shows a checkmark next to it.
127
- * @property {SubMenuItem[]} children - Array of child submenu items.
128
- */
129
-
130
- /**
131
- * Defines a hierarchical structure, where root level items represent menu bar buttons,
132
- * and `children` property configures a submenu with items to be opened below
133
- * the button on click, Enter, Space, Up and Down arrow keys.
134
- *
135
- * #### Example
136
- *
137
- * ```js
138
- * menubar.items = [
139
- * {
140
- * text: 'File',
141
- * className: 'file',
142
- * children: [
143
- * {text: 'Open', className: 'file open'}
144
- * {text: 'Auto Save', checked: true},
145
- * ]
146
- * },
147
- * {component: 'hr'},
148
- * {
149
- * text: 'Edit',
150
- * children: [
151
- * {text: 'Undo', disabled: true},
152
- * {text: 'Redo'}
153
- * ]
154
- * },
155
- * {text: 'Help'}
156
- * ];
157
- * ```
158
- *
159
- * @type {!Array<!MenuBarItem>}
160
- */
161
- items: {
162
- type: Array,
163
- value: () => [],
164
- },
165
-
166
- /**
167
- * The object used to localize this component.
168
- * To change the default localization, replace the entire
169
- * `i18n` object with a custom one.
170
- *
171
- * To update individual properties, extend the existing i18n object like so:
172
- * ```
173
- * menuBar.i18n = {
174
- * ...menuBar.i18n,
175
- * moreOptions: 'More options'
176
- * }
177
- * ```
178
- *
179
- * The object has the following JSON structure and default values:
180
- * ```
181
- * {
182
- * moreOptions: 'More options'
183
- * }
184
- * ```
185
- *
186
- * @type {!MenuBarI18n}
187
- * @default {English/US}
188
- */
189
- i18n: {
190
- type: Object,
191
- value: () => {
192
- return {
193
- moreOptions: 'More options',
194
- };
195
- },
196
- },
197
-
198
- /**
199
- * A space-delimited list of CSS class names
200
- * to set on each sub-menu overlay element.
201
- *
202
- * @attr {string} overlay-class
203
- */
204
- overlayClass: {
205
- type: String,
206
- },
207
- };
208
- }
209
-
210
- static get observers() {
211
- return ['_themeChanged(_theme, _overflow, _container)'];
212
- }
213
-
214
102
  /** @protected */
215
103
  ready() {
216
104
  super.ready();
@@ -220,51 +108,6 @@ class MenuBar extends MenuBarMixin(DisabledMixin(ElementMixin(ThemableMixin(Poly
220
108
  this.addController(this._tooltipController);
221
109
  }
222
110
 
223
- /**
224
- * Override method inherited from `DisabledMixin`
225
- * to update the `disabled` property for the buttons
226
- * whenever the property changes on the menu bar.
227
- *
228
- * @param {boolean} newValue the new disabled value
229
- * @param {boolean} oldValue the previous disabled value
230
- * @override
231
- * @protected
232
- */
233
- _disabledChanged(newValue, oldValue) {
234
- super._disabledChanged(newValue, oldValue);
235
- if (oldValue !== newValue) {
236
- this.__updateButtonsDisabled(newValue);
237
- }
238
- }
239
-
240
- /**
241
- * A callback for the `_theme` property observer.
242
- * It propagates the host theme to the buttons and the sub menu.
243
- *
244
- * @param {string | null} theme
245
- * @protected
246
- */
247
- _themeChanged(theme, overflow, container) {
248
- if (overflow && container) {
249
- this._buttons.forEach((btn) => this._setButtonTheme(btn, theme));
250
- this.__detectOverflow();
251
- }
252
-
253
- if (theme) {
254
- this._subMenu.setAttribute('theme', theme);
255
- } else {
256
- this._subMenu.removeAttribute('theme');
257
- }
258
- }
259
-
260
- /** @private */
261
- __updateButtonsDisabled(disabled) {
262
- this._buttons.forEach((btn) => {
263
- // Disable the button if the entire menu-bar is disabled or the item alone is disabled
264
- btn.disabled = disabled || (btn.item && btn.item.disabled);
265
- });
266
- }
267
-
268
111
  /**
269
112
  * Fired when either a submenu item or menu bar button without nested children is clicked.
270
113
  *
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.3.0-beta2",
4
+ "version": "24.3.0-rc1",
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.3.0-beta2/#/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.3.0-beta2/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-beta2/#/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.3.0-beta2/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-beta2/#/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/24.3.0-rc1/#/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.3.0-rc1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-rc1/#/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.3.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-rc1/#/elements/vaadin-overlay).",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -22,22 +22,22 @@
22
22
  }
23
23
  },
24
24
  {
25
- "name": "open-on-hover",
26
- "description": "If true, the submenu will open on hover (mouseover) instead of click.",
25
+ "name": "overlay-class",
26
+ "description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
27
27
  "value": {
28
28
  "type": [
29
- "boolean",
29
+ "string",
30
30
  "null",
31
31
  "undefined"
32
32
  ]
33
33
  }
34
34
  },
35
35
  {
36
- "name": "overlay-class",
37
- "description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
36
+ "name": "open-on-hover",
37
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
38
38
  "value": {
39
39
  "type": [
40
- "string",
40
+ "boolean",
41
41
  "null",
42
42
  "undefined"
43
43
  ]
@@ -68,17 +68,6 @@
68
68
  ]
69
69
  }
70
70
  },
71
- {
72
- "name": "openOnHover",
73
- "description": "If true, the submenu will open on hover (mouseover) instead of click.",
74
- "value": {
75
- "type": [
76
- "boolean",
77
- "null",
78
- "undefined"
79
- ]
80
- }
81
- },
82
71
  {
83
72
  "name": "items",
84
73
  "description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```",
@@ -107,6 +96,17 @@
107
96
  "undefined"
108
97
  ]
109
98
  }
99
+ },
100
+ {
101
+ "name": "openOnHover",
102
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
103
+ "value": {
104
+ "type": [
105
+ "boolean",
106
+ "null",
107
+ "undefined"
108
+ ]
109
+ }
110
110
  }
111
111
  ],
112
112
  "events": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/menu-bar",
4
- "version": "24.3.0-beta2",
4
+ "version": "24.3.0-rc1",
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.3.0-beta2/#/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.3.0-beta2/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-beta2/#/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.3.0-beta2/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-beta2/#/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/24.3.0-rc1/#/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.3.0-rc1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-rc1/#/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.3.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.3.0-rc1/#/elements/vaadin-overlay).",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {