@vaadin/menu-bar 23.0.0-alpha2 → 23.0.0-alpha3
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 +9 -9
- package/src/vaadin-menu-bar-button.js +1 -1
- package/src/vaadin-menu-bar-buttons-mixin.d.ts +5 -2
- package/src/vaadin-menu-bar-buttons-mixin.js +11 -15
- package/src/vaadin-menu-bar-interactions-mixin.d.ts +1 -1
- package/src/vaadin-menu-bar-interactions-mixin.js +1 -11
- package/src/vaadin-menu-bar-submenu.js +1 -1
- package/src/vaadin-menu-bar.d.ts +3 -2
- package/src/vaadin-menu-bar.js +28 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
36
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/button": "23.0.0-
|
|
38
|
-
"@vaadin/component-base": "23.0.0-
|
|
39
|
-
"@vaadin/vaadin-context-menu": "23.0.0-
|
|
40
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
41
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
37
|
+
"@vaadin/button": "23.0.0-alpha3",
|
|
38
|
+
"@vaadin/component-base": "23.0.0-alpha3",
|
|
39
|
+
"@vaadin/vaadin-context-menu": "23.0.0-alpha3",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha3",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha3",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
46
|
-
"@vaadin/icon": "23.0.0-
|
|
46
|
+
"@vaadin/icon": "23.0.0-alpha3",
|
|
47
47
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
48
48
|
"sinon": "^9.2.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44"
|
|
51
51
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
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>>(
|
|
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)
|
|
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 {
|
|
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
|
-
/**
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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)
|
|
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)
|
|
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';
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
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
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
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
|
*
|