@vaadin/menu-bar 22.0.0-beta1 → 22.0.1

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/README.md CHANGED
@@ -1,54 +1,66 @@
1
- # <vaadin-menu-bar>
1
+ # @vaadin/menu-bar
2
2
 
3
- [Live Demo ↗](https://vaadin.com/components/vaadin-menu-bar/html-examples)
4
- |
5
- [API documentation ↗](https://vaadin.com/components/vaadin-menu-bar/html-api)
3
+ A web component for creating a horizontal button bar with hierarchical drop-down menus.
6
4
 
7
- [<vaadin-menu-bar>](https://vaadin.com/components/vaadin-menu-bar) is a Web Component providing application menu functionality, part of the [Vaadin components](https://vaadin.com/components).
5
+ [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/menu-bar)
8
6
 
9
7
  [![npm version](https://badgen.net/npm/v/@vaadin/menu-bar)](https://www.npmjs.com/package/@vaadin/menu-bar)
10
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-menu-bar)
11
8
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
12
9
 
13
10
  ```html
14
11
  <vaadin-menu-bar></vaadin-menu-bar>
12
+
13
+ <script>
14
+ document.querySelector('vaadin-menu-bar').items = [
15
+ { text: 'View' },
16
+ { text: 'Edit' },
17
+ {
18
+ text: 'Move',
19
+ children: [{ text: 'To folder' }, { text: 'To trash' }]
20
+ },
21
+ { text: 'Duplicate' }
22
+ ];
23
+ </script>
15
24
  ```
16
25
 
17
- [<img src="https://raw.githubusercontent.com/vaadin/vaadin-menu-bar/master/screenshot.png" width="200" alt="Screenshot of vaadin-menu-bar">](https://vaadin.com/components/vaadin-menu-bar)
26
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/menu-bar/screenshot.png" width="345" alt="Screenshot of vaadin-menu-bar">](https://vaadin.com/docs/latest/ds/components/menu-bar)
18
27
 
19
28
  ## Installation
20
29
 
21
- Install `vaadin-menu-bar`:
30
+ Install the component:
22
31
 
23
32
  ```sh
24
- npm i @vaadin/menu-bar --save
33
+ npm i @vaadin/menu-bar
25
34
  ```
26
35
 
27
- Once installed, import it in your application:
36
+ Once installed, import the component in your application:
28
37
 
29
38
  ```js
30
- import '@vaadin/menu-bar/vaadin-menu-bar.js';
39
+ import '@vaadin/menu-bar';
31
40
  ```
32
41
 
33
- ## Getting started
34
-
35
- Vaadin components use the Lumo theme by default.
36
-
37
- To use the Material theme, import the correspondent file from the `theme/material` folder.
42
+ ## Themes
38
43
 
39
- ## Entry points
44
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
45
+ The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/menu-bar/vaadin-menu-bar.js) of the package uses the Lumo theme.
40
46
 
41
- - The component with the Lumo theme:
47
+ To use the Material theme, import the component from the `theme/material` folder:
42
48
 
43
- `theme/lumo/vaadin-menu-bar.js`
49
+ ```js
50
+ import '@vaadin/menu-bar/theme/material/vaadin-menu-bar.js';
51
+ ```
44
52
 
45
- - The component with the Material theme:
53
+ You can also import the Lumo version of the component explicitly:
46
54
 
47
- `theme/material/vaadin-menu-bar.js`
55
+ ```js
56
+ import '@vaadin/menu-bar/theme/lumo/vaadin-menu-bar.js';
57
+ ```
48
58
 
49
- - Alias for `theme/lumo/vaadin-menu-bar.js`:
59
+ Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
50
60
 
51
- `vaadin-menu-bar.js`
61
+ ```js
62
+ import '@vaadin/menu-bar/src/vaadin-menu-bar.js';
63
+ ```
52
64
 
53
65
  ## Contributing
54
66
 
@@ -58,4 +70,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
58
70
 
59
71
  Apache License 2.0
60
72
 
61
- Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
73
+ Vaadin collects usage statistics at development time to improve this product.
74
+ For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/menu-bar",
3
- "version": "22.0.0-beta1",
3
+ "version": "22.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,20 +32,21 @@
32
32
  "polymer"
33
33
  ],
34
34
  "dependencies": {
35
+ "@open-wc/dedupe-mixin": "^1.3.0",
35
36
  "@polymer/iron-resizable-behavior": "^3.0.0",
36
37
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/button": "22.0.0-beta1",
38
- "@vaadin/component-base": "22.0.0-beta1",
39
- "@vaadin/vaadin-context-menu": "22.0.0-beta1",
40
- "@vaadin/vaadin-lumo-styles": "22.0.0-beta1",
41
- "@vaadin/vaadin-material-styles": "22.0.0-beta1",
42
- "@vaadin/vaadin-themable-mixin": "22.0.0-beta1"
38
+ "@vaadin/button": "^22.0.1",
39
+ "@vaadin/component-base": "^22.0.1",
40
+ "@vaadin/vaadin-context-menu": "^22.0.1",
41
+ "@vaadin/vaadin-lumo-styles": "^22.0.1",
42
+ "@vaadin/vaadin-material-styles": "^22.0.1",
43
+ "@vaadin/vaadin-themable-mixin": "^22.0.1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@esm-bundle/chai": "^4.3.4",
46
- "@vaadin/icon": "22.0.0-beta1",
47
- "@vaadin/testing-helpers": "^0.3.0",
47
+ "@vaadin/icon": "^22.0.1",
48
+ "@vaadin/testing-helpers": "^0.3.2",
48
49
  "sinon": "^9.2.1"
49
50
  },
50
- "gitHead": "4cf8a9d0504994200c610e44b3676114fef49c1e"
51
+ "gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
51
52
  }
@@ -4,7 +4,7 @@
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';
7
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
7
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
8
 
9
9
  registerStyles(
10
10
  'vaadin-menu-bar-button',
@@ -3,21 +3,16 @@
3
3
  * Copyright (c) 2021 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
7
 
7
- declare function ButtonsMixin<T extends new (...args: any[]) => {}>(base: T): T & ButtonsMixinConstructor;
8
+ export declare function ButtonsMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<ButtonsMixinClass>;
8
9
 
9
- interface ButtonsMixinConstructor {
10
- new (...args: any[]): ButtonsMixin;
11
- }
12
-
13
- interface ButtonsMixin {
14
- readonly _buttons: HTMLElement[];
10
+ export declare class ButtonsMixinClass {
11
+ protected readonly _buttons: HTMLElement[];
15
12
 
16
- readonly _container: HTMLElement;
13
+ protected readonly _container: HTMLElement;
17
14
 
18
- readonly _overflow: HTMLElement;
15
+ protected readonly _overflow: HTMLElement;
19
16
 
20
- _hasOverflow: boolean;
17
+ protected _hasOverflow: boolean;
21
18
  }
22
-
23
- export { ButtonsMixin, ButtonsMixinConstructor };
@@ -3,14 +3,13 @@
3
3
  * Copyright (c) 2021 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
7
 
7
- declare function InteractionsMixin<T extends new (...args: any[]) => {}>(base: T): T & InteractionsMixinConstructor;
8
+ export declare function InteractionsMixin<T extends Constructor<HTMLElement>>(
9
+ base: T
10
+ ): T & Constructor<InteractionsMixinClass>;
8
11
 
9
- interface InteractionsMixinConstructor {
10
- new (...args: any[]): InteractionsMixin;
11
- }
12
-
13
- interface InteractionsMixin {
12
+ export declare class InteractionsMixinClass {
14
13
  /**
15
14
  * If true, the submenu will open on hover (mouseover) instead of click.
16
15
  * @attr {boolean} open-on-hover
@@ -23,5 +22,3 @@ interface InteractionsMixin {
23
22
  */
24
23
  notifyResize(): void;
25
24
  }
26
-
27
- export { InteractionsMixin, InteractionsMixinConstructor };
@@ -314,16 +314,16 @@ export const InteractionsMixin = (superClass) =>
314
314
 
315
315
  subMenu.items = items;
316
316
  subMenu.listenOn = button;
317
- this._expandedButton = button;
317
+ const overlay = subMenu.$.overlay;
318
+ overlay.positionTarget = button;
319
+ overlay.noVerticalOverlap = true;
318
320
 
319
- const rect = button.getBoundingClientRect();
321
+ this._expandedButton = button;
320
322
 
321
323
  requestAnimationFrame(() => {
322
324
  button.dispatchEvent(
323
325
  new CustomEvent('opensubmenu', {
324
326
  detail: {
325
- x: this.__isRTL ? rect.right : rect.left,
326
- y: rect.bottom,
327
327
  children: items
328
328
  }
329
329
  })
@@ -342,12 +342,13 @@ export const InteractionsMixin = (superClass) =>
342
342
  });
343
343
  }
344
344
 
345
- // do not focus item when open not from keyboard
346
- if (event.type !== 'keydown') {
347
- this.__onceOpened(() => {
345
+ this.__onceOpened(() => {
346
+ // do not focus item when open not from keyboard
347
+ if (event.type !== 'keydown') {
348
348
  subMenu.$.overlay.$.overlay.focus();
349
- });
350
- }
349
+ }
350
+ overlay._updatePosition();
351
+ });
351
352
  }
352
353
 
353
354
  /** @private */
@@ -20,6 +20,7 @@ export interface SubMenuItem {
20
20
  text?: string;
21
21
  component?: string | HTMLElement;
22
22
  disabled?: boolean;
23
+ theme?: string | string[];
23
24
  checked?: boolean;
24
25
  children?: SubMenuItem[];
25
26
  }
@@ -3,13 +3,13 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
6
+ import './vaadin-menu-bar-submenu.js';
7
+ import './vaadin-menu-bar-button.js';
8
+ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
11
  import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
10
12
  import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
11
- import './vaadin-menu-bar-submenu.js';
12
- import './vaadin-menu-bar-button.js';
13
13
 
14
14
  /**
15
15
  * `<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering
@@ -1,5 +1,5 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import { button } from '@vaadin/button/theme/lumo/vaadin-button-styles.js';
2
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
3
 
4
4
  const menuBarButton = css`
5
5
  :host {
@@ -15,6 +15,7 @@ const menuBarButton = css`
15
15
  /* NOTE(web-padawan): avoid using shorthand padding property for IE11 */
16
16
  [part='label'] ::slotted(vaadin-context-menu-item) {
17
17
  justify-content: center;
18
+ background-color: transparent;
18
19
  height: var(--lumo-button-size);
19
20
  margin: 0 calc((var(--lumo-size-m) / 3 + var(--lumo-border-radius-m) / 2) * -1);
20
21
  padding-left: calc(var(--lumo-size-m) / 3 + var(--lumo-border-radius-m) / 2);
@@ -1,6 +1,6 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-lumo-styles/sizing.js';
3
2
  import '@vaadin/vaadin-lumo-styles/spacing.js';
3
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
4
 
5
5
  registerStyles(
6
6
  'vaadin-context-menu-item',
@@ -1,4 +1,4 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
 
3
3
  registerStyles(
4
4
  'vaadin-context-menu-overlay',
@@ -1,5 +1,5 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import { button } from '@vaadin/button/theme/material/vaadin-button-styles';
2
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
3
 
4
4
  const menuBarButton = css`
5
5
  [part='label'] {
@@ -8,6 +8,7 @@ const menuBarButton = css`
8
8
 
9
9
  [part='label'] ::slotted(vaadin-context-menu-item) {
10
10
  line-height: 20px;
11
+ background-color: transparent;
11
12
  margin: -8px;
12
13
  padding: 8px;
13
14
  justify-content: center;
@@ -1,5 +1,5 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-material-styles/typography.js';
2
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
3
 
4
4
  registerStyles(
5
5
  'vaadin-context-menu-item',
@@ -1,4 +1,4 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
 
3
3
  registerStyles(
4
4
  'vaadin-context-menu-overlay',
@@ -1,4 +1,4 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
 
3
3
  registerStyles(
4
4
  'vaadin-menu-bar',