@vaadin/menu-bar 23.0.0-alpha2 → 23.0.0-beta1

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-alpha2",
3
+ "version": "23.0.0-beta1",
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",
@@ -34,18 +35,18 @@
34
35
  "dependencies": {
35
36
  "@open-wc/dedupe-mixin": "^1.3.0",
36
37
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/button": "23.0.0-alpha2",
38
- "@vaadin/component-base": "23.0.0-alpha2",
39
- "@vaadin/vaadin-context-menu": "23.0.0-alpha2",
40
- "@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
41
- "@vaadin/vaadin-material-styles": "23.0.0-alpha2",
42
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
38
+ "@vaadin/button": "23.0.0-beta1",
39
+ "@vaadin/component-base": "23.0.0-beta1",
40
+ "@vaadin/vaadin-context-menu": "23.0.0-beta1",
41
+ "@vaadin/vaadin-lumo-styles": "23.0.0-beta1",
42
+ "@vaadin/vaadin-material-styles": "23.0.0-beta1",
43
+ "@vaadin/vaadin-themable-mixin": "23.0.0-beta1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@esm-bundle/chai": "^4.3.4",
46
- "@vaadin/icon": "23.0.0-alpha2",
47
+ "@vaadin/icon": "23.0.0-beta1",
47
48
  "@vaadin/testing-helpers": "^0.3.2",
48
49
  "sinon": "^9.2.1"
49
50
  },
50
- "gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
51
+ "gitHead": "467244b76021176c109df675799b07029b293e58"
51
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,16 +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 { animationFrame } from '@vaadin/component-base/src/async.js';
7
- import { Debouncer } from '@vaadin/component-base/src/debounce.js';
6
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
8
7
 
9
8
  /**
10
9
  * @polymerMixin
10
+ * @mixes ResizeMixin
11
11
  */
12
12
  export const ButtonsMixin = (superClass) =>
13
- class extends superClass {
13
+ class extends ResizeMixin(superClass) {
14
14
  static get properties() {
15
15
  return {
16
16
  /**
@@ -33,9 +33,6 @@ export const ButtonsMixin = (superClass) =>
33
33
  super.ready();
34
34
 
35
35
  this.setAttribute('role', 'menubar');
36
-
37
- this.__resizeObserver = new ResizeObserver(() => this.__onResize());
38
- this.__resizeObserver.observe(this);
39
36
  }
40
37
 
41
38
  /** @protected */
@@ -87,7 +84,7 @@ export const ButtonsMixin = (superClass) =>
87
84
  __restoreButtons(buttons) {
88
85
  for (let i = 0; i < buttons.length; i++) {
89
86
  const btn = buttons[i];
90
- btn.disabled = btn.item && btn.item.disabled;
87
+ btn.disabled = (btn.item && btn.item.disabled) || this.disabled;
91
88
  btn.style.visibility = '';
92
89
  btn.style.position = '';
93
90
 
@@ -285,12 +282,11 @@ export const ButtonsMixin = (superClass) =>
285
282
  this.__applyTheme(this.theme);
286
283
  }
287
284
 
288
- /** @private */
289
- __onResize() {
290
- this.__debounceOverflow = Debouncer.debounce(
291
- this.__debounceOverflow,
292
- animationFrame,
293
- this.__detectOverflow.bind(this)
294
- );
285
+ /**
286
+ * @protected
287
+ * @override
288
+ */
289
+ _onResize() {
290
+ this.__detectOverflow();
295
291
  }
296
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';
@@ -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
 
@@ -408,14 +408,4 @@ export const InteractionsMixin = (superClass) =>
408
408
  this.__deactivateButton(restoreFocus);
409
409
  this._subMenu.opened && this._subMenu.close();
410
410
  }
411
-
412
- /**
413
- * @deprecated Since Vaadin 23, `notifyResize()` is deprecated. The component uses a
414
- * ResizeObserver internally and doesn't need to be explicitly notified of resizes.
415
- */
416
- notifyResize() {
417
- console.warn(
418
- `WARNING: Since Vaadin 23, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.`
419
- );
420
- }
421
411
  };
@@ -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,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
  *