@vaadin/menu-bar 22.0.1 → 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 -10
- 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 +12 -29
- package/src/vaadin-menu-bar-interactions-mixin.d.ts +3 -3
- package/src/vaadin-menu-bar-interactions-mixin.js +1 -1
- 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": "
|
|
3
|
+
"version": "23.0.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,20 +33,19 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
|
-
"@polymer/iron-resizable-behavior": "^3.0.0",
|
|
37
36
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/button": "
|
|
39
|
-
"@vaadin/component-base": "
|
|
40
|
-
"@vaadin/vaadin-context-menu": "
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
42
|
-
"@vaadin/vaadin-material-styles": "
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
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"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
47
|
-
"@vaadin/icon": "
|
|
46
|
+
"@vaadin/icon": "23.0.0-alpha3",
|
|
48
47
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
49
48
|
"sinon": "^9.2.1"
|
|
50
49
|
},
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "490037919a9e054cc002c1b3be0c94a1603e1a44"
|
|
52
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,18 +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 { 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
|
|
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 =
|
|
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
|
-
/**
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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)
|
|
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
|
-
*
|
|
21
|
-
*
|
|
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)
|
|
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
|
*
|