@vaadin/menu-bar 22.0.2 → 23.0.0-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/menu-bar",
3
- "version": "22.0.2",
3
+ "version": "23.0.0-alpha4",
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": "^22.0.2",
39
- "@vaadin/component-base": "^22.0.2",
40
- "@vaadin/vaadin-context-menu": "^22.0.2",
41
- "@vaadin/vaadin-lumo-styles": "^22.0.2",
42
- "@vaadin/vaadin-material-styles": "^22.0.2",
43
- "@vaadin/vaadin-themable-mixin": "^22.0.2"
38
+ "@vaadin/button": "23.0.0-alpha4",
39
+ "@vaadin/component-base": "23.0.0-alpha4",
40
+ "@vaadin/vaadin-context-menu": "23.0.0-alpha4",
41
+ "@vaadin/vaadin-lumo-styles": "23.0.0-alpha4",
42
+ "@vaadin/vaadin-material-styles": "23.0.0-alpha4",
43
+ "@vaadin/vaadin-themable-mixin": "23.0.0-alpha4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
47
- "@vaadin/icon": "^22.0.2",
47
+ "@vaadin/icon": "23.0.0-alpha4",
48
48
  "@vaadin/testing-helpers": "^0.3.2",
49
49
  "sinon": "^9.2.1"
50
50
  },
51
- "gitHead": "df21370c4a655a38eac11f79686021ab3b0887ad"
51
+ "gitHead": "81e2deee5147bb7c1f4884760f4598613306f1fb"
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';
@@ -81,7 +82,7 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
81
82
  *
82
83
  * @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
83
84
  */
84
- declare class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement)))) {
85
+ declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement))))) {
85
86
  /**
86
87
  * Defines a hierarchical structure, where root level items represent menu bar buttons,
87
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,7 +59,7 @@ 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>
@@ -200,6 +201,31 @@ class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(
200
201
  };
201
202
  }
202
203
 
204
+ /**
205
+ * Override method inherited from `DisabledMixin`
206
+ * to update the `disabled` property for the buttons
207
+ * whenever the property changes on the menu bar.
208
+ *
209
+ * @param {boolean} newValue the new disabled value
210
+ * @param {boolean} oldValue the previous disabled value
211
+ * @override
212
+ * @protected
213
+ */
214
+ _disabledChanged(newValue, oldValue) {
215
+ super._disabledChanged(newValue, oldValue);
216
+ if (oldValue !== newValue) {
217
+ this.__updateButtonsDisabled(newValue);
218
+ }
219
+ }
220
+
221
+ /** @private */
222
+ __updateButtonsDisabled(disabled) {
223
+ this._buttons.forEach((btn) => {
224
+ // disable the button if the entire menu-bar is disabled or the item alone is disabled
225
+ btn.disabled = disabled || (btn.item && btn.item.disabled);
226
+ });
227
+ }
228
+
203
229
  /**
204
230
  * Fired when either a submenu item or menu bar button without nested children is clicked.
205
231
  *