@vaadin/menu-bar 23.0.0-alpha1 → 23.0.0-alpha5

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.0.0-alpha1",
3
+ "version": "23.0.0-alpha5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "main": "vaadin-menu-bar.js",
20
20
  "module": "vaadin-menu-bar.js",
21
+ "type": "module",
21
22
  "files": [
22
23
  "src",
23
24
  "theme",
@@ -33,20 +34,19 @@
33
34
  ],
34
35
  "dependencies": {
35
36
  "@open-wc/dedupe-mixin": "^1.3.0",
36
- "@polymer/iron-resizable-behavior": "^3.0.0",
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/button": "23.0.0-alpha1",
39
- "@vaadin/component-base": "23.0.0-alpha1",
40
- "@vaadin/vaadin-context-menu": "23.0.0-alpha1",
41
- "@vaadin/vaadin-lumo-styles": "23.0.0-alpha1",
42
- "@vaadin/vaadin-material-styles": "23.0.0-alpha1",
43
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha1"
38
+ "@vaadin/button": "23.0.0-alpha5",
39
+ "@vaadin/component-base": "23.0.0-alpha5",
40
+ "@vaadin/vaadin-context-menu": "23.0.0-alpha5",
41
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha5",
42
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha5",
43
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
47
- "@vaadin/icon": "23.0.0-alpha1",
47
+ "@vaadin/icon": "23.0.0-alpha5",
48
48
  "@vaadin/testing-helpers": "^0.3.2",
49
49
  "sinon": "^9.2.1"
50
50
  },
51
- "gitHead": "fbcb07328fdf88260e3b461088d207426b21c710"
51
+ "gitHead": "74f9294964eb8552d96578c14af6ad214f5257bc"
52
52
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
6
  import { Button } from '@vaadin/button/src/vaadin-button.js';
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
6
  import { Constructor } from '@open-wc/dedupe-mixin';
7
+ import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
7
8
 
8
- export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<ButtonsMixinClass>;
9
+ export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(
10
+ base: T
11
+ ): T & Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass>;
9
12
 
10
13
  export declare class ButtonsMixinClass {
11
14
  protected readonly _buttons: HTMLElement[];
@@ -1,18 +1,16 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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 { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
7
- import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
8
- import { animationFrame } from '@vaadin/component-base/src/async.js';
9
- import { Debouncer } from '@vaadin/component-base/src/debounce.js';
6
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
10
7
 
11
8
  /**
12
9
  * @polymerMixin
10
+ * @mixes ResizeMixin
13
11
  */
14
12
  export const ButtonsMixin = (superClass) =>
15
- class extends mixinBehaviors(IronResizableBehavior, superClass) {
13
+ class extends ResizeMixin(superClass) {
16
14
  static get properties() {
17
15
  return {
18
16
  /**
@@ -30,12 +28,6 @@ export const ButtonsMixin = (superClass) =>
30
28
  return ['_menuItemsChanged(items, items.splices)'];
31
29
  }
32
30
 
33
- constructor() {
34
- super();
35
-
36
- this.__boundOnResize = this.__onResize.bind(this);
37
- }
38
-
39
31
  /** @protected */
40
32
  ready() {
41
33
  super.ready();
@@ -48,14 +40,6 @@ export const ButtonsMixin = (superClass) =>
48
40
  super.connectedCallback();
49
41
 
50
42
  this._initButtonAttrs(this._overflow);
51
- this.addEventListener('iron-resize', this.__boundOnResize);
52
- }
53
-
54
- /** @protected */
55
- disconnectedCallback() {
56
- super.disconnectedCallback();
57
-
58
- this.removeEventListener('iron-resize', this.__boundOnResize);
59
43
  }
60
44
 
61
45
  /**
@@ -100,7 +84,7 @@ export const ButtonsMixin = (superClass) =>
100
84
  __restoreButtons(buttons) {
101
85
  for (let i = 0; i < buttons.length; i++) {
102
86
  const btn = buttons[i];
103
- btn.disabled = btn.item && btn.item.disabled;
87
+ btn.disabled = (btn.item && btn.item.disabled) || this.disabled;
104
88
  btn.style.visibility = '';
105
89
  btn.style.position = '';
106
90
 
@@ -181,7 +165,7 @@ export const ButtonsMixin = (superClass) =>
181
165
  const button = document.createElement('vaadin-menu-bar-button');
182
166
  button.setAttribute('part', 'menu-bar-button');
183
167
 
184
- const itemCopy = Object.assign({}, item);
168
+ const itemCopy = { ...item };
185
169
  button.item = itemCopy;
186
170
 
187
171
  if (item.component) {
@@ -298,12 +282,11 @@ export const ButtonsMixin = (superClass) =>
298
282
  this.__applyTheme(this.theme);
299
283
  }
300
284
 
301
- /** @private */
302
- __onResize() {
303
- this.__debounceOverflow = Debouncer.debounce(
304
- this.__debounceOverflow,
305
- animationFrame,
306
- this.__detectOverflow.bind(this)
307
- );
285
+ /**
286
+ * @protected
287
+ * @override
288
+ */
289
+ _onResize() {
290
+ this.__detectOverflow();
308
291
  }
309
292
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
6
  import { Constructor } from '@open-wc/dedupe-mixin';
@@ -17,8 +17,8 @@ export declare class InteractionsMixinClass {
17
17
  openOnHover: boolean | null | undefined;
18
18
 
19
19
  /**
20
- * Can be called to manually notify a resizable and its descendant
21
- * resizables of a resize change.
20
+ * @deprecated Since Vaadin 23, `notifyResize()` is deprecated. The component uses a
21
+ * ResizeObserver internally and doesn't need to be explicitly notified of resizes.
22
22
  */
23
23
  notifyResize(): void;
24
24
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
6
  import { ContextMenu } from '@vaadin/vaadin-context-menu/src/vaadin-context-menu.js';
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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 { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
6
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
9
  import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
@@ -20,6 +21,7 @@ export interface SubMenuItem {
20
21
  text?: string;
21
22
  component?: string | HTMLElement;
22
23
  disabled?: boolean;
24
+ theme?: string | string[];
23
25
  checked?: boolean;
24
26
  children?: SubMenuItem[];
25
27
  }
@@ -80,7 +82,7 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
80
82
  *
81
83
  * @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
82
84
  */
83
- declare class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement)))) {
85
+ declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement))))) {
84
86
  /**
85
87
  * Defines a hierarchical structure, where root level items represent menu bar buttons,
86
88
  * and `children` property configures a submenu with items to be opened below
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
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
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/component-base/src/disabled-mixin.js';
9
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
12
  import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
@@ -58,12 +59,13 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
58
59
  * @mixes ElementMixin
59
60
  * @mixes ThemableMixin
60
61
  */
61
- class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement)))) {
62
+ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement))))) {
62
63
  static get template() {
63
64
  return html`
64
65
  <style>
65
66
  :host {
66
67
  display: block;
68
+ width: 100%; /* make overflow work in flex */
67
69
  }
68
70
 
69
71
  :host([hidden]) {
@@ -200,6 +202,31 @@ class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(
200
202
  };
201
203
  }
202
204
 
205
+ /**
206
+ * Override method inherited from `DisabledMixin`
207
+ * to update the `disabled` property for the buttons
208
+ * whenever the property changes on the menu bar.
209
+ *
210
+ * @param {boolean} newValue the new disabled value
211
+ * @param {boolean} oldValue the previous disabled value
212
+ * @override
213
+ * @protected
214
+ */
215
+ _disabledChanged(newValue, oldValue) {
216
+ super._disabledChanged(newValue, oldValue);
217
+ if (oldValue !== newValue) {
218
+ this.__updateButtonsDisabled(newValue);
219
+ }
220
+ }
221
+
222
+ /** @private */
223
+ __updateButtonsDisabled(disabled) {
224
+ this._buttons.forEach((btn) => {
225
+ // disable the button if the entire menu-bar is disabled or the item alone is disabled
226
+ btn.disabled = disabled || (btn.item && btn.item.disabled);
227
+ });
228
+ }
229
+
203
230
  /**
204
231
  * Fired when either a submenu item or menu bar button without nested children is clicked.
205
232
  *