@vaadin/menu-bar
Advanced tools
Comparing version 23.0.0-alpha2 to 23.0.0-alpha3
{ | ||
"name": "@vaadin/menu-bar", | ||
"version": "23.0.0-alpha2", | ||
"version": "23.0.0-alpha3", | ||
"publishConfig": { | ||
@@ -37,16 +37,16 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/button": "23.0.0-alpha2", | ||
"@vaadin/component-base": "23.0.0-alpha2", | ||
"@vaadin/vaadin-context-menu": "23.0.0-alpha2", | ||
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2", | ||
"@vaadin/vaadin-material-styles": "23.0.0-alpha2", | ||
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2" | ||
"@vaadin/button": "23.0.0-alpha3", | ||
"@vaadin/component-base": "23.0.0-alpha3", | ||
"@vaadin/vaadin-context-menu": "23.0.0-alpha3", | ||
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha3", | ||
"@vaadin/vaadin-material-styles": "23.0.0-alpha3", | ||
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha3" | ||
}, | ||
"devDependencies": { | ||
"@esm-bundle/chai": "^4.3.4", | ||
"@vaadin/icon": "23.0.0-alpha2", | ||
"@vaadin/icon": "23.0.0-alpha3", | ||
"@vaadin/testing-helpers": "^0.3.2", | ||
"sinon": "^9.2.1" | ||
}, | ||
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f" | ||
"gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44" | ||
} |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { Constructor } from '@open-wc/dedupe-mixin'; | ||
import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js'; | ||
export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<ButtonsMixinClass>; | ||
export declare function ButtonsMixin<T extends Constructor<HTMLElement>>( | ||
base: T | ||
): T & Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass>; | ||
@@ -10,0 +13,0 @@ export declare class ButtonsMixinClass { |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { animationFrame } from '@vaadin/component-base/src/async.js'; | ||
import { Debouncer } from '@vaadin/component-base/src/debounce.js'; | ||
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js'; | ||
/** | ||
* @polymerMixin | ||
* @mixes ResizeMixin | ||
*/ | ||
export const ButtonsMixin = (superClass) => | ||
class extends superClass { | ||
class extends ResizeMixin(superClass) { | ||
static get properties() { | ||
@@ -36,5 +36,2 @@ return { | ||
this.setAttribute('role', 'menubar'); | ||
this.__resizeObserver = new ResizeObserver(() => this.__onResize()); | ||
this.__resizeObserver.observe(this); | ||
} | ||
@@ -91,3 +88,3 @@ | ||
const btn = buttons[i]; | ||
btn.disabled = btn.item && btn.item.disabled; | ||
btn.disabled = (btn.item && btn.item.disabled) || this.disabled; | ||
btn.style.visibility = ''; | ||
@@ -290,10 +287,9 @@ btn.style.position = ''; | ||
/** @private */ | ||
__onResize() { | ||
this.__debounceOverflow = Debouncer.debounce( | ||
this.__debounceOverflow, | ||
animationFrame, | ||
this.__detectOverflow.bind(this) | ||
); | ||
/** | ||
* @protected | ||
* @override | ||
*/ | ||
_onResize() { | ||
this.__detectOverflow(); | ||
} | ||
}; |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -411,12 +411,2 @@ */ | ||
} | ||
/** | ||
* @deprecated Since Vaadin 23, `notifyResize()` is deprecated. The component uses a | ||
* ResizeObserver internally and doesn't need to be explicitly notified of resizes. | ||
*/ | ||
notifyResize() { | ||
console.warn( | ||
`WARNING: Since Vaadin 23, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.` | ||
); | ||
} | ||
}; |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js'; | ||
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; | ||
@@ -84,3 +85,3 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
*/ | ||
declare class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement)))) { | ||
declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(HTMLElement))))) { | ||
/** | ||
@@ -87,0 +88,0 @@ * Defines a hierarchical structure, where root level items represent menu bar buttons, |
/** | ||
* @license | ||
* Copyright (c) 2021 Vaadin Ltd. | ||
* Copyright (c) 2019 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
@@ -9,2 +9,3 @@ */ | ||
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js'; | ||
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js'; | ||
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; | ||
@@ -62,3 +63,3 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
*/ | ||
class MenuBar extends ButtonsMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement)))) { | ||
class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(PolymerElement))))) { | ||
static get template() { | ||
@@ -206,2 +207,27 @@ return html` | ||
/** | ||
* Override method inherited from `DisabledMixin` | ||
* to update the `disabled` property for the buttons | ||
* whenever the property changes on the menu bar. | ||
* | ||
* @param {boolean} newValue the new disabled value | ||
* @param {boolean} oldValue the previous disabled value | ||
* @override | ||
* @protected | ||
*/ | ||
_disabledChanged(newValue, oldValue) { | ||
super._disabledChanged(newValue, oldValue); | ||
if (oldValue !== newValue) { | ||
this.__updateButtonsDisabled(newValue); | ||
} | ||
} | ||
/** @private */ | ||
__updateButtonsDisabled(disabled) { | ||
this._buttons.forEach((btn) => { | ||
// disable the button if the entire menu-bar is disabled or the item alone is disabled | ||
btn.disabled = disabled || (btn.item && btn.item.disabled); | ||
}); | ||
} | ||
/** | ||
* Fired when either a submenu item or menu bar button without nested children is clicked. | ||
@@ -208,0 +234,0 @@ * |
58939
1351
+ Added@vaadin/button@23.0.0-alpha3(transitive)
+ Added@vaadin/component-base@23.0.0-alpha3(transitive)
+ Added@vaadin/context-menu@23.0.0-alpha3(transitive)
+ Added@vaadin/icon@23.0.0-alpha3(transitive)
+ Added@vaadin/item@23.0.0-alpha3(transitive)
+ Added@vaadin/list-box@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-context-menu@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-list-mixin@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-lumo-styles@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-material-styles@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-overlay@23.0.0-alpha3(transitive)
+ Added@vaadin/vaadin-themable-mixin@23.0.0-alpha3(transitive)
- Removed@vaadin/button@23.0.0-alpha2(transitive)
- Removed@vaadin/component-base@23.0.0-alpha2(transitive)
- Removed@vaadin/context-menu@23.0.0-alpha2(transitive)
- Removed@vaadin/icon@23.0.0-alpha2(transitive)
- Removed@vaadin/item@23.0.0-alpha2(transitive)
- Removed@vaadin/list-box@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-context-menu@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-list-mixin@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-lumo-styles@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-material-styles@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-overlay@23.0.0-alpha2(transitive)
- Removed@vaadin/vaadin-themable-mixin@23.0.0-alpha2(transitive)
Updated@vaadin/button@23.0.0-alpha3