@vaadin/menu-bar 23.2.0-dev.48e5e3967 → 23.2.0-rc1

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.2.0-dev.48e5e3967",
3
+ "version": "23.2.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,7 +23,9 @@
23
23
  "src",
24
24
  "theme",
25
25
  "vaadin-*.d.ts",
26
- "vaadin-*.js"
26
+ "vaadin-*.js",
27
+ "web-types.json",
28
+ "web-types.lit.json"
27
29
  ],
28
30
  "keywords": [
29
31
  "Vaadin",
@@ -35,18 +37,22 @@
35
37
  "dependencies": {
36
38
  "@open-wc/dedupe-mixin": "^1.3.0",
37
39
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/button": "23.2.0-dev.48e5e3967",
39
- "@vaadin/component-base": "23.2.0-dev.48e5e3967",
40
- "@vaadin/vaadin-context-menu": "23.2.0-dev.48e5e3967",
41
- "@vaadin/vaadin-lumo-styles": "23.2.0-dev.48e5e3967",
42
- "@vaadin/vaadin-material-styles": "23.2.0-dev.48e5e3967",
43
- "@vaadin/vaadin-themable-mixin": "23.2.0-dev.48e5e3967"
40
+ "@vaadin/button": "23.2.0-rc1",
41
+ "@vaadin/component-base": "23.2.0-rc1",
42
+ "@vaadin/context-menu": "23.2.0-rc1",
43
+ "@vaadin/vaadin-lumo-styles": "23.2.0-rc1",
44
+ "@vaadin/vaadin-material-styles": "23.2.0-rc1",
45
+ "@vaadin/vaadin-themable-mixin": "23.2.0-rc1"
44
46
  },
45
47
  "devDependencies": {
46
48
  "@esm-bundle/chai": "^4.3.4",
47
- "@vaadin/icon": "23.2.0-dev.48e5e3967",
49
+ "@vaadin/icon": "23.2.0-rc1",
48
50
  "@vaadin/testing-helpers": "^0.3.2",
49
51
  "sinon": "^13.0.2"
50
52
  },
51
- "gitHead": "961bc4ae5b707c3c02f12b99819b3c12c9b478aa"
53
+ "web-types": [
54
+ "web-types.json",
55
+ "web-types.lit.json"
56
+ ],
57
+ "gitHead": "e78a1f2fe6f42d78cefa3f48085b09a3033c9588"
52
58
  }
@@ -3,12 +3,12 @@
3
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 { Constructor } from '@open-wc/dedupe-mixin';
7
- import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
8
8
 
9
9
  export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(
10
10
  base: T,
11
- ): T & Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass>;
11
+ ): Constructor<ButtonsMixinClass> & Constructor<ResizeMixinClass> & T;
12
12
 
13
13
  export declare class ButtonsMixinClass {
14
14
  protected readonly _buttons: HTMLElement[];
@@ -163,6 +163,9 @@ export const ButtonsMixin = (superClass) =>
163
163
  if (oldOverflowCount !== newOverflowCount && this._subMenu.opened) {
164
164
  this._subMenu.close();
165
165
  }
166
+
167
+ const isSingleButton = newOverflowCount === buttons.length || (newOverflowCount === 0 && buttons.length === 1);
168
+ this.toggleAttribute('has-single-button', isSingleButton);
166
169
  }
167
170
 
168
171
  /** @protected */
@@ -3,11 +3,11 @@
3
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 { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function InteractionsMixin<T extends Constructor<HTMLElement>>(
9
9
  base: T,
10
- ): T & Constructor<InteractionsMixinClass>;
10
+ ): Constructor<InteractionsMixinClass> & T;
11
11
 
12
12
  export declare class InteractionsMixinClass {
13
13
  /**
@@ -3,7 +3,7 @@
3
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 { ContextMenu } from '@vaadin/vaadin-context-menu/src/vaadin-context-menu.js';
6
+ import { ContextMenu } from '@vaadin/context-menu/src/vaadin-context-menu.js';
7
7
 
8
8
  /**
9
9
  * An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
@@ -11,17 +11,17 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
11
11
 
12
12
  export interface MenuBarItem {
13
13
  text?: string;
14
- component?: string | HTMLElement;
14
+ component?: HTMLElement | string;
15
15
  disabled?: boolean;
16
- theme?: string | string[];
16
+ theme?: string[] | string;
17
17
  children?: SubMenuItem[];
18
18
  }
19
19
 
20
20
  export interface SubMenuItem {
21
21
  text?: string;
22
- component?: string | HTMLElement;
22
+ component?: HTMLElement | string;
23
23
  disabled?: boolean;
24
- theme?: string | string[];
24
+ theme?: string[] | string;
25
25
  checked?: boolean;
26
26
  children?: SubMenuItem[];
27
27
  }
@@ -68,6 +68,13 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
68
68
  * `menu-bar-button` | The menu bar button.
69
69
  * `overflow-button` | The "overflow" button appearing when menu bar width is not enough to fit all the buttons.
70
70
  *
71
+ * The following state attributes are available for styling:
72
+ *
73
+ * Attribute | Description
74
+ * --------------------|----------------------------------
75
+ * `disabled` | Set when the menu bar is disabled
76
+ * `has-single-button` | Set when there is only one button visible
77
+ *
71
78
  * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
72
79
  *
73
80
  * ### Internal components
@@ -138,13 +145,13 @@ declare class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(Eleme
138
145
  addEventListener<K extends keyof MenuBarEventMap>(
139
146
  type: K,
140
147
  listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
141
- options?: boolean | AddEventListenerOptions,
148
+ options?: AddEventListenerOptions | boolean,
142
149
  ): void;
143
150
 
144
151
  removeEventListener<K extends keyof MenuBarEventMap>(
145
152
  type: K,
146
153
  listener: (this: MenuBar, ev: MenuBarEventMap[K]) => void,
147
- options?: boolean | EventListenerOptions,
154
+ options?: EventListenerOptions | boolean,
148
155
  ): void;
149
156
 
150
157
  /**
@@ -39,6 +39,13 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
39
39
  * `menu-bar-button` | The menu bar button.
40
40
  * `overflow-button` | The "overflow" button appearing when menu bar width is not enough to fit all the buttons.
41
41
  *
42
+ * The following state attributes are available for styling:
43
+ *
44
+ * Attribute | Description
45
+ * --------------------|----------------------------------
46
+ * `disabled` | Set when the menu bar is disabled
47
+ * `has-single-button` | Set when there is only one button visible
48
+ *
42
49
  * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
43
50
  *
44
51
  * ### Internal components
@@ -56,6 +63,7 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
56
63
  * @extends HTMLElement
57
64
  * @mixes ButtonsMixin
58
65
  * @mixes InteractionsMixin
66
+ * @mixes DisabledMixin
59
67
  * @mixes ElementMixin
60
68
  * @mixes ThemableMixin
61
69
  */
@@ -0,0 +1,17 @@
1
+ import '@vaadin/vaadin-lumo-styles/style.js';
2
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
+
4
+ registerStyles(
5
+ 'vaadin-menu-bar',
6
+ css`
7
+ :host([has-single-button]) [part$='button'] {
8
+ border-radius: var(--lumo-border-radius-m);
9
+ }
10
+
11
+ :host([theme~='end-aligned']) [part$='button']:first-child,
12
+ :host([theme~='end-aligned'][has-single-button]) [part$='button'] {
13
+ margin-inline-start: auto;
14
+ }
15
+ `,
16
+ { moduleId: 'lumo-menu-bar' },
17
+ );
@@ -1,5 +1,6 @@
1
1
  import './vaadin-menu-bar-button.js';
2
2
  import './vaadin-menu-bar-item-styles.js';
3
3
  import './vaadin-menu-bar-overlay-styles.js';
4
- import '@vaadin/vaadin-context-menu/theme/lumo/vaadin-context-menu.js';
4
+ import './vaadin-menu-bar-styles.js';
5
+ import '@vaadin/context-menu/theme/lumo/vaadin-context-menu.js';
5
6
  import '../../src/vaadin-menu-bar.js';
@@ -14,8 +14,8 @@ const menuBarButton = css`
14
14
  justify-content: center;
15
15
  }
16
16
 
17
- :host([theme='outlined']),
18
- :host([theme='contained']) {
17
+ :host([theme~='outlined']),
18
+ :host([theme~='contained']) {
19
19
  border-radius: 0;
20
20
  }
21
21
 
@@ -36,7 +36,7 @@ const menuBarButton = css`
36
36
  transition: 0s;
37
37
  }
38
38
 
39
- :host([theme='contained'][expanded]) {
39
+ :host([theme~='contained'][expanded]) {
40
40
  box-shadow: var(--material-shadow-elevation-8dp);
41
41
  }
42
42
 
@@ -45,7 +45,7 @@ const menuBarButton = css`
45
45
  opacity: 0;
46
46
  }
47
47
 
48
- :host([theme='contained']:not([dir='rtl'])) {
48
+ :host([theme~='contained']:not([dir='rtl'])) {
49
49
  margin-right: 1px;
50
50
  }
51
51
 
@@ -68,16 +68,16 @@ const menuBarButton = css`
68
68
  font-size: 24px;
69
69
  }
70
70
 
71
- :host([theme='outlined']:not([dir='rtl'])) {
71
+ :host([theme~='outlined']:not([dir='rtl'])) {
72
72
  margin-right: -1px;
73
73
  }
74
74
 
75
- :host([theme='outlined']:not([dir='rtl']):nth-last-of-type(2)),
76
- :host([theme='outlined']:not([dir='rtl'])[part~='overflow-button']) {
75
+ :host([theme~='outlined']:not([dir='rtl']):nth-last-of-type(2)),
76
+ :host([theme~='outlined']:not([dir='rtl'])[part~='overflow-button']) {
77
77
  margin-right: 0;
78
78
  }
79
79
 
80
- :host([theme='text']),
80
+ :host([theme~='text']),
81
81
  :host(:not([theme])) {
82
82
  border-radius: 4px;
83
83
  }
@@ -92,16 +92,16 @@ const menuBarButton = css`
92
92
  border-radius: 4px 0 0 4px;
93
93
  }
94
94
 
95
- :host([dir='rtl'][theme='contained']) {
95
+ :host([dir='rtl'][theme~='contained']) {
96
96
  margin-left: 1px;
97
97
  }
98
98
 
99
- :host([dir='rtl'][theme='outlined']) {
99
+ :host([dir='rtl'][theme~='outlined']) {
100
100
  margin-left: -1px;
101
101
  }
102
102
 
103
- :host([theme='outlined'][dir='rtl']:nth-last-of-type(2)),
104
- :host([theme='outlined'][dir='rtl'][part~='overflow-button']) {
103
+ :host([theme~='outlined'][dir='rtl']:nth-last-of-type(2)),
104
+ :host([theme~='outlined'][dir='rtl'][part~='overflow-button']) {
105
105
  margin-left: 0;
106
106
  }
107
107
  `;
@@ -7,6 +7,15 @@ registerStyles(
7
7
  /* To retain the box-shadow */
8
8
  padding-bottom: 5px;
9
9
  }
10
+
11
+ :host([has-single-button]) [part$='button'] {
12
+ border-radius: 4px;
13
+ }
14
+
15
+ :host([theme~='end-aligned']) [part$='button']:first-child,
16
+ :host([theme~='end-aligned'][has-single-button]) [part$='button'] {
17
+ margin-inline-start: auto;
18
+ }
10
19
  `,
11
20
  { moduleId: 'material-menu-bar' },
12
21
  );
@@ -2,5 +2,5 @@ import './vaadin-menu-bar-button.js';
2
2
  import './vaadin-menu-bar-item-styles.js';
3
3
  import './vaadin-menu-bar-styles.js';
4
4
  import './vaadin-menu-bar-overlay-styles.js';
5
- import '@vaadin/vaadin-context-menu/theme/material/vaadin-context-menu.js';
5
+ import '@vaadin/context-menu/theme/material/vaadin-context-menu.js';
6
6
  import '../../src/vaadin-menu-bar.js';
package/web-types.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/menu-bar",
4
+ "version": "23.2.0-rc1",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
10
+ "name": "vaadin-menu-bar",
11
+ "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-overlay).",
12
+ "attributes": [
13
+ {
14
+ "name": "open-on-hover",
15
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
16
+ "value": {
17
+ "type": [
18
+ "boolean",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "name": "disabled",
26
+ "description": "If true, the user cannot interact with this element.",
27
+ "value": {
28
+ "type": [
29
+ "boolean",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "theme",
37
+ "description": "The theme variants to apply to the component.",
38
+ "value": {
39
+ "type": [
40
+ "string",
41
+ "null",
42
+ "undefined"
43
+ ]
44
+ }
45
+ }
46
+ ],
47
+ "js": {
48
+ "properties": [
49
+ {
50
+ "name": "openOnHover",
51
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
52
+ "value": {
53
+ "type": [
54
+ "boolean",
55
+ "null",
56
+ "undefined"
57
+ ]
58
+ }
59
+ },
60
+ {
61
+ "name": "disabled",
62
+ "description": "If true, the user cannot interact with this element.",
63
+ "value": {
64
+ "type": [
65
+ "boolean",
66
+ "null",
67
+ "undefined"
68
+ ]
69
+ }
70
+ },
71
+ {
72
+ "name": "items",
73
+ "description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n children: [\n {text: 'Open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```",
74
+ "value": {
75
+ "type": [
76
+ "Array.<MenuBarItem>"
77
+ ]
78
+ }
79
+ },
80
+ {
81
+ "name": "i18n",
82
+ "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\nmenuBar.i18n = {\n ...menuBar.i18n,\n moreOptions: 'More options'\n}\n```\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
83
+ "value": {
84
+ "type": [
85
+ "MenuBarI18n"
86
+ ]
87
+ }
88
+ }
89
+ ],
90
+ "events": [
91
+ {
92
+ "name": "item-selected",
93
+ "description": "Fired when either a submenu item or menu bar button without nested children is clicked."
94
+ }
95
+ ]
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/menu-bar",
4
+ "version": "23.2.0-rc1",
5
+ "description-markup": "markdown",
6
+ "framework": "lit",
7
+ "framework-config": {
8
+ "enable-when": {
9
+ "node-packages": [
10
+ "lit"
11
+ ]
12
+ }
13
+ },
14
+ "contributions": {
15
+ "html": {
16
+ "elements": [
17
+ {
18
+ "name": "vaadin-menu-bar",
19
+ "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.2.0-rc1/#/elements/vaadin-overlay).",
20
+ "extension": true,
21
+ "attributes": [
22
+ {
23
+ "name": "?openOnHover",
24
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
29
+ {
30
+ "name": "?disabled",
31
+ "description": "If true, the user cannot interact with this element.",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
36
+ {
37
+ "name": ".items",
38
+ "description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n children: [\n {text: 'Open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
42
+ },
43
+ {
44
+ "name": ".i18n",
45
+ "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\nmenuBar.i18n = {\n ...menuBar.i18n,\n moreOptions: 'More options'\n}\n```\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
50
+ {
51
+ "name": "@item-selected",
52
+ "description": "Fired when either a submenu item or menu bar button without nested children is clicked.",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ }
57
+ ]
58
+ }
59
+ ]
60
+ }
61
+ }
62
+ }