@vaadin/vaadin-context-menu 4.5.0-alpha2 → 4.6.0

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,20 +1,18 @@
1
- [![npm version](https://badgen.net/npm/v/@vaadin/vaadin-context-menu)](https://www.npmjs.com/package/@vaadin/vaadin-context-menu)
2
- [![Bower version](https://badgen.net/github/release/vaadin/vaadin-context-menu)](https://github.com/vaadin/vaadin-context-menu/releases)
3
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/vaadin/vaadin-context-menu)
4
- [![Build Status](https://travis-ci.org/vaadin/vaadin-context-menu.svg?branch=master)](https://travis-ci.org/vaadin/vaadin-context-menu)
5
- [![Coverage Status](https://coveralls.io/repos/github/vaadin/vaadin-context-menu/badge.svg?branch=master)](https://coveralls.io/github/vaadin/vaadin-context-menu?branch=master)
6
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1
+ # <vaadin-context-menu>
7
2
 
8
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-context-menu)
9
- [![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/vaadinvaadin-context-menu.svg)](https://vaadin.com/directory/component/vaadinvaadin-context-menu)
3
+ > ⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the [`vaadin/web-components`](https://github.com/vaadin/web-components/tree/master/packages/vaadin-context-menu) monorepository.
4
+ > This repository contains the source code and releases of `<vaadin-context-menu>` for the Vaadin versions 10 to 19.
10
5
 
11
- # &lt;vaadin-context-menu&gt;
6
+ [&lt;vaadin-context-menu&gt;](https://vaadin.com/components/vaadin-context-menu) is a Web Component providing a contextual menu, part of the [Vaadin components](https://vaadin.com/components).
12
7
 
13
8
  [Live Demo ↗](https://vaadin.com/components/vaadin-context-menu/html-examples)
14
9
  |
15
10
  [API documentation ↗](https://vaadin.com/components/vaadin-context-menu/html-api)
16
11
 
17
- [&lt;vaadin-context-menu&gt;](https://vaadin.com/components/vaadin-context-menu) is a Web Component providing a contextual menu, part of the [Vaadin components](https://vaadin.com/components).
12
+ [![npm version](https://badgen.net/npm/v/@vaadin/vaadin-context-menu)](https://www.npmjs.com/package/@vaadin/vaadin-context-menu)
13
+ [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/vaadin/vaadin-context-menu)
14
+ [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-context-menu)
15
+ [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
18
16
 
19
17
  <!--
20
18
  ```
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "repository": "vaadin/vaadin-context-menu",
11
11
  "homepage": "https://vaadin.com/components",
12
12
  "name": "@vaadin/vaadin-context-menu",
13
- "version": "4.5.0-alpha2",
13
+ "version": "4.6.0",
14
14
  "main": "vaadin-context-menu.js",
15
15
  "author": "Vaadin Ltd",
16
16
  "license": "Apache-2.0",
@@ -25,6 +25,8 @@
25
25
  "theme"
26
26
  ],
27
27
  "resolutions": {
28
+ "es-abstract": "1.17.6",
29
+ "@types/doctrine": "0.0.3",
28
30
  "inherits": "2.0.3",
29
31
  "samsam": "1.1.3",
30
32
  "supports-color": "3.1.2",
@@ -38,19 +40,19 @@
38
40
  "@vaadin/vaadin-lumo-styles": "^1.6.0",
39
41
  "@vaadin/vaadin-material-styles": "^1.3.2",
40
42
  "@vaadin/vaadin-element-mixin": "^2.4.1",
41
- "@vaadin/vaadin-item": "^2.3.0-alpha1",
42
- "@vaadin/vaadin-list-box": "^1.4.0-alpha1"
43
+ "@vaadin/vaadin-item": "^2.3.0",
44
+ "@vaadin/vaadin-list-box": "^1.4.0"
43
45
  },
44
46
  "scripts": {
45
- "generate-typings": "gen-typescript-declarations --outDir . --verify"
46
- },
47
- "devDependencies": {
47
+ "generate-typings": "gen-typescript-declarations --outDir . --verify"
48
+ },
49
+ "devDependencies": {
48
50
  "@polymer/iron-component-page": "^4.0.0",
49
51
  "@polymer/iron-test-helpers": "^3.0.0",
50
- "@vaadin/vaadin-button": "^2.4.0-alpha1",
51
- "@vaadin/vaadin-grid": "^5.7.0-alpha1",
52
+ "@vaadin/vaadin-button": "^2.4.0",
53
+ "@vaadin/vaadin-grid": "^5.7.0-beta1",
52
54
  "@webcomponents/webcomponentsjs": "^2.0.0",
53
55
  "wct-browser-legacy": "^1.0.1",
54
- "@vaadin/vaadin-demo-helpers": "^3.1.0-alpha1"
56
+ "@vaadin/vaadin-demo-helpers": "^3.1.0"
55
57
  }
56
58
  }
@@ -43,7 +43,7 @@ import {addListener, removeListener} from '@polymer/polymer/lib/utils/gestures.j
43
43
  *
44
44
  * ```javascript
45
45
  * contextMenu.items = [
46
- * {text: 'Menu Item 1', children:
46
+ * {text: 'Menu Item 1', theme: 'primary', children:
47
47
  * [
48
48
  * {text: 'Menu Item 1-1', checked: true},
49
49
  * {text: 'Menu Item 1-2'}
@@ -256,6 +256,7 @@ declare class ContextMenuElement extends
256
256
 
257
257
  /**
258
258
  * Event name to listen for opening the context menu.
259
+ * @attr {string} open-on
259
260
  */
260
261
  openOn: string;
261
262
 
@@ -268,6 +269,7 @@ declare class ContextMenuElement extends
268
269
 
269
270
  /**
270
271
  * Event name to listen for closing the context menu.
272
+ * @attr {string} close-on
271
273
  */
272
274
  closeOn: string;
273
275
 
@@ -32,7 +32,7 @@ import { gestures, addListener, removeListener } from '@polymer/polymer/lib/util
32
32
  *
33
33
  * ```javascript
34
34
  * contextMenu.items = [
35
- * {text: 'Menu Item 1', children:
35
+ * {text: 'Menu Item 1', theme: 'primary', children:
36
36
  * [
37
37
  * {text: 'Menu Item 1-1', checked: true},
38
38
  * {text: 'Menu Item 1-2'}
@@ -263,7 +263,7 @@ class ContextMenuElement extends
263
263
  }
264
264
 
265
265
  static get version() {
266
- return '4.5.0-alpha2';
266
+ return '4.6.0';
267
267
  }
268
268
 
269
269
  static get properties() {
@@ -290,6 +290,7 @@ class ContextMenuElement extends
290
290
 
291
291
  /**
292
292
  * Event name to listen for opening the context menu.
293
+ * @attr {string} open-on
293
294
  * @type {string}
294
295
  */
295
296
  openOn: {
@@ -313,6 +314,7 @@ class ContextMenuElement extends
313
314
 
314
315
  /**
315
316
  * Event name to listen for closing the context menu.
317
+ * @attr {string} close-on
316
318
  * @type {string}
317
319
  */
318
320
  closeOn: {
@@ -62,7 +62,7 @@ interface ItemsMixin {
62
62
  *
63
63
  * ```javascript
64
64
  * contextMenu.items = [
65
- * {text: 'Menu Item 1', children:
65
+ * {text: 'Menu Item 1', theme: 'primary', children:
66
66
  * [
67
67
  * {text: 'Menu Item 1-1', checked: true},
68
68
  * {text: 'Menu Item 1-2'}
@@ -85,6 +85,7 @@ interface ItemsMixin {
85
85
  disconnectedCallback(): void;
86
86
  __forwardFocus(): void;
87
87
  __itemsRenderer(root: HTMLElement, menu: ContextMenuElement, context: ContextMenuRendererContext): void;
88
+ _setMenuItemTheme(component: any, item: any, hostTheme: any): void;
88
89
  }
89
90
 
90
91
  import {ContextMenuItem} from '../@types/interfaces';
@@ -42,6 +42,8 @@ export const ItemsMixin = superClass => class ItemsMixin extends superClass {
42
42
  * Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
43
43
  * @property {boolean} disabled - If true, the item is disabled and cannot be selected
44
44
  * @property {boolean} checked - If true, the item shows a checkmark next to it
45
+ * @property {union: string | string[]} theme - If set, sets the given theme(s) as an
46
+ * attribute to the menu item component, overriding any theme set on the context menu.
45
47
  * @property {MenuItem[]} children - Array of child menu items
46
48
  */
47
49
 
@@ -56,7 +58,7 @@ export const ItemsMixin = superClass => class ItemsMixin extends superClass {
56
58
  *
57
59
  * ```javascript
58
60
  * contextMenu.items = [
59
- * {text: 'Menu Item 1', children:
61
+ * {text: 'Menu Item 1', theme: 'primary', children:
60
62
  * [
61
63
  * {text: 'Menu Item 1-1', checked: true},
62
64
  * {text: 'Menu Item 1-2'}
@@ -216,7 +218,7 @@ export const ItemsMixin = superClass => class ItemsMixin extends superClass {
216
218
  } else if (component.localName === 'hr') {
217
219
  component.setAttribute('role', 'separator');
218
220
  }
219
- this.theme && component.setAttribute('theme', this.theme);
221
+ this._setMenuItemTheme(component, item, this.theme);
220
222
 
221
223
  component._item = item;
222
224
 
@@ -240,6 +242,22 @@ export const ItemsMixin = superClass => class ItemsMixin extends superClass {
240
242
  });
241
243
  }
242
244
 
245
+ /** @protected */
246
+ _setMenuItemTheme(component, item, hostTheme) {
247
+ let theme = hostTheme;
248
+
249
+ // item theme takes precedence over host theme even if it's empty, as long as it's not undefined or null
250
+ if (item.theme != null) {
251
+ theme = Array.isArray(item.theme) ? item.theme.join(' ') : item.theme;
252
+ }
253
+
254
+ if (theme) {
255
+ component.setAttribute('theme', theme);
256
+ } else {
257
+ component.removeAttribute('theme');
258
+ }
259
+ }
260
+
243
261
  /** @private */
244
262
  __toggleMenuComponentAttribute(component, attribute, on) {
245
263
  if (on) {