@vaadin/context-menu 23.3.3 → 24.0.0-alpha10
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 +10 -11
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-context-menu-overlay.js +2 -2
- package/src/vaadin-context-menu.d.ts +3 -2
- package/src/vaadin-context-menu.js +14 -18
- package/src/vaadin-contextmenu-event.js +1 -1
- package/src/vaadin-contextmenu-items-mixin.d.ts +1 -3
- package/src/vaadin-contextmenu-items-mixin.js +7 -15
- package/theme/lumo/vaadin-context-menu-styles.js +10 -23
- package/theme/material/vaadin-context-menu-styles.js +10 -14
- package/web-types.json +24 -2
- package/web-types.lit.json +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/context-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,18 +39,17 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
41
41
|
"@polymer/polymer": "^3.0.0",
|
|
42
|
-
"@vaadin/component-base": "
|
|
43
|
-
"@vaadin/item": "
|
|
44
|
-
"@vaadin/list-box": "
|
|
45
|
-
"@vaadin/lit-renderer": "
|
|
46
|
-
"@vaadin/overlay": "
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
48
|
-
"@vaadin/vaadin-material-styles": "
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
42
|
+
"@vaadin/component-base": "24.0.0-alpha10",
|
|
43
|
+
"@vaadin/item": "24.0.0-alpha10",
|
|
44
|
+
"@vaadin/list-box": "24.0.0-alpha10",
|
|
45
|
+
"@vaadin/lit-renderer": "24.0.0-alpha10",
|
|
46
|
+
"@vaadin/overlay": "24.0.0-alpha10",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha10",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/polymer-legacy-adapter": "~23.3.3",
|
|
54
53
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
54
|
"lit": "^2.0.0",
|
|
56
55
|
"sinon": "^13.0.2"
|
|
@@ -59,5 +58,5 @@
|
|
|
59
58
|
"web-types.json",
|
|
60
59
|
"web-types.lit.json"
|
|
61
60
|
],
|
|
62
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
|
|
63
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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 { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
@@ -77,7 +77,7 @@ class ContextMenuOverlay extends PositionMixin(Overlay) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
getFirstChild() {
|
|
80
|
-
return this.
|
|
80
|
+
return this.querySelector(':not(style):not(slot)');
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
_themeChanged() {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
|
+
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
7
8
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
8
9
|
import { ContextMenuItem, ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
9
10
|
|
|
@@ -223,7 +224,7 @@ export interface ContextMenuEventMap extends HTMLElementEventMap, ContextMenuCus
|
|
|
223
224
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
224
225
|
* @fires {CustomEvent} item-selected - Fired when an item is selected when the context menu is populated using the `items` API.
|
|
225
226
|
*/
|
|
226
|
-
declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(HTMLElement))) {
|
|
227
|
+
declare class ContextMenu extends OverlayClassMixin(ElementMixin(ThemePropertyMixin(ItemsMixin(HTMLElement)))) {
|
|
227
228
|
/**
|
|
228
229
|
* CSS selector that can be used to target any child element
|
|
229
230
|
* of the context menu to listen for `openOn` events.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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-contextmenu-event.js';
|
|
@@ -11,6 +11,7 @@ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'
|
|
|
11
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
12
|
import { addListener, gestures, removeListener } from '@vaadin/component-base/src/gestures.js';
|
|
13
13
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
14
|
+
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
14
15
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
15
16
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
16
17
|
import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
@@ -199,10 +200,13 @@ import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
|
199
200
|
* @extends HTMLElement
|
|
200
201
|
* @mixes ElementMixin
|
|
201
202
|
* @mixes ControllerMixin
|
|
203
|
+
* @mixes OverlayClassMixin
|
|
202
204
|
* @mixes ThemePropertyMixin
|
|
203
205
|
* @mixes ItemsMixin
|
|
204
206
|
*/
|
|
205
|
-
class ContextMenu extends
|
|
207
|
+
class ContextMenu extends OverlayClassMixin(
|
|
208
|
+
ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElement)))),
|
|
209
|
+
) {
|
|
206
210
|
static get template() {
|
|
207
211
|
return html`
|
|
208
212
|
<style>
|
|
@@ -308,12 +312,6 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
|
|
|
308
312
|
/** @private */
|
|
309
313
|
_context: Object,
|
|
310
314
|
|
|
311
|
-
/** @private */
|
|
312
|
-
_boundClose: Object,
|
|
313
|
-
|
|
314
|
-
/** @private */
|
|
315
|
-
_boundOpen: Object,
|
|
316
|
-
|
|
317
315
|
/** @private */
|
|
318
316
|
_phone: {
|
|
319
317
|
type: Boolean,
|
|
@@ -351,6 +349,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
|
|
|
351
349
|
super();
|
|
352
350
|
this._boundOpen = this.open.bind(this);
|
|
353
351
|
this._boundClose = this.close.bind(this);
|
|
352
|
+
this._boundPreventDefault = this._preventDefault.bind(this);
|
|
354
353
|
this._boundOnGlobalContextMenu = this._onGlobalContextMenu.bind(this);
|
|
355
354
|
}
|
|
356
355
|
|
|
@@ -445,22 +444,19 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
|
|
|
445
444
|
|
|
446
445
|
/** @private */
|
|
447
446
|
_closeOnChanged(closeOn, oldCloseOn) {
|
|
448
|
-
// Listen on this.$.overlay.root to workaround issue on
|
|
449
|
-
// ShadyDOM polyfill: https://github.com/webcomponents/shadydom/issues/159
|
|
450
|
-
|
|
451
447
|
// Outside click event from overlay
|
|
452
448
|
const evtOverlay = 'vaadin-overlay-outside-click';
|
|
453
449
|
|
|
450
|
+
const overlay = this.$.overlay;
|
|
451
|
+
|
|
454
452
|
if (oldCloseOn) {
|
|
455
|
-
this._unlisten(
|
|
456
|
-
this._unlisten(this.$.overlay.root, oldCloseOn, this._boundClose);
|
|
453
|
+
this._unlisten(overlay, oldCloseOn, this._boundClose);
|
|
457
454
|
}
|
|
458
455
|
if (closeOn) {
|
|
459
|
-
this._listen(
|
|
460
|
-
|
|
461
|
-
this._unlisten(this.$.overlay, evtOverlay, this._preventDefault);
|
|
456
|
+
this._listen(overlay, closeOn, this._boundClose);
|
|
457
|
+
overlay.removeEventListener(evtOverlay, this._boundPreventDefault);
|
|
462
458
|
} else {
|
|
463
|
-
|
|
459
|
+
overlay.addEventListener(evtOverlay, this._boundPreventDefault);
|
|
464
460
|
}
|
|
465
461
|
}
|
|
466
462
|
|
|
@@ -545,7 +541,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
|
|
|
545
541
|
};
|
|
546
542
|
|
|
547
543
|
if (this._context.target) {
|
|
548
|
-
|
|
544
|
+
e.preventDefault();
|
|
549
545
|
e.stopPropagation();
|
|
550
546
|
|
|
551
547
|
// Used in alignment which is delayed until overlay is rendered
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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 { isIOS } from '@vaadin/component-base/src/browser-utils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -69,6 +69,4 @@ export declare class ItemsMixinClass {
|
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
items: ContextMenuItem[] | undefined;
|
|
72
|
-
|
|
73
|
-
protected readonly __isRTL: boolean;
|
|
74
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 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 { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
@@ -126,14 +126,6 @@ export const ItemsMixin = (superClass) =>
|
|
|
126
126
|
document.documentElement.removeEventListener('click', this.__itemsOutsideClickListener);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* @return {boolean}
|
|
131
|
-
* @protected
|
|
132
|
-
*/
|
|
133
|
-
get __isRTL() {
|
|
134
|
-
return this.getAttribute('dir') === 'rtl';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
129
|
/** @protected */
|
|
138
130
|
__forwardFocus() {
|
|
139
131
|
const overlay = this.$.overlay;
|
|
@@ -152,9 +144,10 @@ export const ItemsMixin = (superClass) =>
|
|
|
152
144
|
}
|
|
153
145
|
|
|
154
146
|
/** @private */
|
|
155
|
-
__openSubMenu(subMenu, itemElement) {
|
|
147
|
+
__openSubMenu(subMenu, itemElement, overlayClass) {
|
|
156
148
|
subMenu.items = itemElement._item.children;
|
|
157
149
|
subMenu.listenOn = itemElement;
|
|
150
|
+
subMenu.overlayClass = overlayClass;
|
|
158
151
|
|
|
159
152
|
const parent = this.$.overlay;
|
|
160
153
|
|
|
@@ -211,7 +204,6 @@ export const ItemsMixin = (superClass) =>
|
|
|
211
204
|
|
|
212
205
|
if (component instanceof Item) {
|
|
213
206
|
component.setAttribute('role', 'menuitem');
|
|
214
|
-
component.classList.add('vaadin-menu-item');
|
|
215
207
|
} else if (component.localName === 'hr') {
|
|
216
208
|
component.setAttribute('role', 'separator');
|
|
217
209
|
}
|
|
@@ -228,9 +220,7 @@ export const ItemsMixin = (superClass) =>
|
|
|
228
220
|
this.__toggleMenuComponentAttribute(component, 'disabled', item.disabled);
|
|
229
221
|
|
|
230
222
|
component.setAttribute('aria-haspopup', 'false');
|
|
231
|
-
component.classList.remove('vaadin-context-menu-parent-item');
|
|
232
223
|
if (item.children && item.children.length) {
|
|
233
|
-
component.classList.add('vaadin-context-menu-parent-item');
|
|
234
224
|
component.setAttribute('aria-haspopup', 'true');
|
|
235
225
|
component.setAttribute('aria-expanded', 'false');
|
|
236
226
|
component.removeAttribute('expanded');
|
|
@@ -278,7 +268,6 @@ export const ItemsMixin = (superClass) =>
|
|
|
278
268
|
if (this._theme) {
|
|
279
269
|
listBox.setAttribute('theme', this._theme);
|
|
280
270
|
}
|
|
281
|
-
listBox.classList.add('vaadin-menu-list-box');
|
|
282
271
|
requestAnimationFrame(() => listBox.setAttribute('role', 'menu'));
|
|
283
272
|
|
|
284
273
|
const subMenu = document.createElement(this.constructor.is);
|
|
@@ -358,7 +347,10 @@ export const ItemsMixin = (superClass) =>
|
|
|
358
347
|
if (itemElement._item.children && itemElement._item.children.length) {
|
|
359
348
|
itemElement.setAttribute('aria-expanded', 'true');
|
|
360
349
|
itemElement.setAttribute('expanded', '');
|
|
361
|
-
|
|
350
|
+
|
|
351
|
+
// Forward parent overlay class
|
|
352
|
+
const { overlayClass } = menu;
|
|
353
|
+
this.__openSubMenu(subMenu, itemElement, overlayClass);
|
|
362
354
|
} else {
|
|
363
355
|
subMenu.listenOn.focus();
|
|
364
356
|
}
|
|
@@ -37,49 +37,36 @@ registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay],
|
|
|
37
37
|
registerStyles(
|
|
38
38
|
'vaadin-context-menu-list-box',
|
|
39
39
|
css`
|
|
40
|
-
:host
|
|
40
|
+
:host {
|
|
41
41
|
--_lumo-list-box-item-selected-icon-display: block;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/* Normal item */
|
|
45
|
-
[part='items'] ::slotted(
|
|
45
|
+
[part='items'] ::slotted([role='menuitem']) {
|
|
46
46
|
-webkit-tap-highlight-color: var(--lumo-primary-color-10pct);
|
|
47
47
|
cursor: default;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[part='items'] ::slotted(.vaadin-menu-item) {
|
|
51
48
|
outline: none;
|
|
52
49
|
border-radius: var(--lumo-border-radius-m);
|
|
53
|
-
padding-left: var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
54
|
-
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
:host(.vaadin-menu-list-box) [part='items'] ::slotted(.vaadin-menu-item) {
|
|
58
50
|
padding-left: calc(var(--lumo-border-radius-m) / 4);
|
|
59
51
|
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
/* Hovered item */
|
|
63
55
|
/* TODO a workaround until we have "focus-follows-mouse". After that, use the hover style for focus-ring as well */
|
|
64
|
-
[part='items'] ::slotted(
|
|
65
|
-
[part='items'] ::slotted(
|
|
56
|
+
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])),
|
|
57
|
+
[part='items'] ::slotted([role='menuitem'][expanded]:not([disabled])) {
|
|
66
58
|
background-color: var(--lumo-primary-color-10pct);
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
/* RTL styles */
|
|
70
|
-
:host([dir='rtl'])[part='items'] ::slotted(
|
|
71
|
-
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
72
|
-
padding-right: var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:host([dir='rtl'].vaadin-menu-list-box) [part='items'] ::slotted(.vaadin-menu-item) {
|
|
62
|
+
:host([dir='rtl']) [part='items'] ::slotted([role='menuitem']) {
|
|
76
63
|
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
77
64
|
padding-right: calc(var(--lumo-border-radius-m) / 4);
|
|
78
65
|
}
|
|
79
66
|
|
|
80
67
|
/* Focused item */
|
|
81
68
|
@media (pointer: coarse) {
|
|
82
|
-
[part='items'] ::slotted(
|
|
69
|
+
[part='items'] ::slotted([role='menuitem']:hover:not([expanded]):not([disabled])) {
|
|
83
70
|
background-color: transparent;
|
|
84
71
|
}
|
|
85
72
|
}
|
|
@@ -97,18 +84,18 @@ registerStyles(
|
|
|
97
84
|
-webkit-user-select: none;
|
|
98
85
|
}
|
|
99
86
|
|
|
100
|
-
:host(
|
|
87
|
+
:host([role='menuitem'][menu-item-checked]) [part='checkmark']::before {
|
|
101
88
|
opacity: 1;
|
|
102
89
|
}
|
|
103
90
|
|
|
104
|
-
:host(
|
|
91
|
+
:host([aria-haspopup='true'])::after {
|
|
105
92
|
font-family: lumo-icons;
|
|
106
93
|
font-size: var(--lumo-icon-size-xs);
|
|
107
94
|
content: var(--lumo-icons-angle-right);
|
|
108
95
|
color: var(--lumo-tertiary-text-color);
|
|
109
96
|
}
|
|
110
97
|
|
|
111
|
-
:host(:not([dir='rtl'])
|
|
98
|
+
:host(:not([dir='rtl'])[aria-haspopup='true'])::after {
|
|
112
99
|
margin-right: calc(var(--lumo-space-m) * -1);
|
|
113
100
|
padding-left: var(--lumo-space-m);
|
|
114
101
|
}
|
|
@@ -118,7 +105,7 @@ registerStyles(
|
|
|
118
105
|
}
|
|
119
106
|
|
|
120
107
|
/* RTL styles */
|
|
121
|
-
:host([dir='rtl']
|
|
108
|
+
:host([dir='rtl'][aria-haspopup='true'])::after {
|
|
122
109
|
content: var(--lumo-icons-angle-left);
|
|
123
110
|
margin-left: calc(var(--lumo-space-m) * -1);
|
|
124
111
|
padding-right: var(--lumo-space-m);
|
|
@@ -18,28 +18,28 @@ registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay],
|
|
|
18
18
|
registerStyles(
|
|
19
19
|
'vaadin-context-menu-list-box',
|
|
20
20
|
css`
|
|
21
|
-
[part='items'] ::slotted(
|
|
21
|
+
[part='items'] ::slotted([role='menuitem']) {
|
|
22
22
|
min-height: 36px;
|
|
23
23
|
padding: 8px 32px 8px 10px;
|
|
24
24
|
font-size: var(--material-small-font-size);
|
|
25
25
|
line-height: 24px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
:host([dir='rtl']) [part='items'] ::slotted(
|
|
28
|
+
:host([dir='rtl']) [part='items'] ::slotted([role='menuitem']) {
|
|
29
29
|
padding: 8px 10px 8px 32px;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
[part='items'] ::slotted(
|
|
32
|
+
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])) {
|
|
33
33
|
background-color: var(--material-secondary-background-color);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
[part='items'] ::slotted(
|
|
36
|
+
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) {
|
|
37
37
|
background-color: var(--material-divider-color);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@media (pointer: coarse) {
|
|
41
|
-
[part='items'] ::slotted(
|
|
42
|
-
[part='items'] ::slotted(
|
|
41
|
+
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])),
|
|
42
|
+
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) {
|
|
43
43
|
background-color: transparent;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -50,28 +50,24 @@ registerStyles(
|
|
|
50
50
|
registerStyles(
|
|
51
51
|
'vaadin-context-menu-item',
|
|
52
52
|
css`
|
|
53
|
-
:host(
|
|
53
|
+
:host([aria-haspopup='true'])::after {
|
|
54
54
|
font-family: material-icons;
|
|
55
55
|
font-size: var(--material-icon-font-size);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
:host(:not([dir='rtl'])
|
|
58
|
+
:host(:not([dir='rtl'])[aria-haspopup='true'])::after {
|
|
59
59
|
content: var(--material-icons-chevron-right);
|
|
60
60
|
padding-left: 9px;
|
|
61
61
|
margin-right: -9px;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
:host([dir='rtl']
|
|
64
|
+
:host([dir='rtl'][aria-haspopup='true'])::after {
|
|
65
65
|
content: var(--material-icons-chevron-left);
|
|
66
66
|
padding-right: 9px;
|
|
67
67
|
margin-left: -9px;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
:host(
|
|
71
|
-
display: block;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
:host(.vaadin-menu-item[menu-item-checked]) [part='checkmark']::before {
|
|
70
|
+
:host([menu-item-checked]) [part='checkmark']::before {
|
|
75
71
|
content: var(--material-icons-check);
|
|
76
72
|
}
|
|
77
73
|
|
package/web-types.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/context-menu",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "24.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-context-menu",
|
|
11
|
-
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n\ncontextMenu.addEventListener('item-selected', e => {\n const item = e.detail.value;\n console.log(`${item.text} selected`);\n});\n```\n\n**NOTE:** when the `items` array is defined, the renderer cannot be used.\n\n### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### “vaadin-contextmenu” Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n\ncontextMenu.addEventListener('item-selected', e => {\n const item = e.detail.value;\n console.log(`${item.text} selected`);\n});\n```\n\n**NOTE:** when the `items` array is defined, the renderer cannot be used.\n\n### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### “vaadin-contextmenu” Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-overlay)\ndocumentation for `<vaadin-context-menu-overlay>` stylable parts.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nWhen using `items` API, in addition `<vaadin-context-menu-overlay>`, the following\ninternal components are themable:\n\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-list-box).\n\nNote: the `theme` attribute value set on `<vaadin-context-menu>` is\npropagated to the internal components listed above.",
|
|
12
12
|
"attributes": [
|
|
13
|
+
{
|
|
14
|
+
"name": "overlay-class",
|
|
15
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
16
|
+
"value": {
|
|
17
|
+
"type": [
|
|
18
|
+
"string",
|
|
19
|
+
"null",
|
|
20
|
+
"undefined"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
13
24
|
{
|
|
14
25
|
"name": "selector",
|
|
15
26
|
"description": "CSS selector that can be used to target any child element\nof the context menu to listen for `openOn` events.",
|
|
@@ -53,6 +64,17 @@
|
|
|
53
64
|
],
|
|
54
65
|
"js": {
|
|
55
66
|
"properties": [
|
|
67
|
+
{
|
|
68
|
+
"name": "overlayClass",
|
|
69
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
70
|
+
"value": {
|
|
71
|
+
"type": [
|
|
72
|
+
"string",
|
|
73
|
+
"null",
|
|
74
|
+
"undefined"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
56
78
|
{
|
|
57
79
|
"name": "items",
|
|
58
80
|
"description": "Defines a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nThe items API can't be used together with a renderer!\n\n#### Example\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n```",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/context-menu",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "24.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,9 +16,16 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-context-menu",
|
|
19
|
-
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n\ncontextMenu.addEventListener('item-selected', e => {\n const item = e.detail.value;\n console.log(`${item.text} selected`);\n});\n```\n\n**NOTE:** when the `items` array is defined, the renderer cannot be used.\n\n### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### “vaadin-contextmenu” Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
19
|
+
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n\ncontextMenu.addEventListener('item-selected', e => {\n const item = e.detail.value;\n console.log(`${item.text} selected`);\n});\n```\n\n**NOTE:** when the `items` array is defined, the renderer cannot be used.\n\n### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### “vaadin-contextmenu” Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-overlay)\ndocumentation for `<vaadin-context-menu-overlay>` stylable parts.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nWhen using `items` API, in addition `<vaadin-context-menu-overlay>`, the following\ninternal components are themable:\n\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-list-box).\n\nNote: the `theme` attribute value set on `<vaadin-context-menu>` is\npropagated to the internal components listed above.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": ".overlayClass",
|
|
24
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
25
|
+
"value": {
|
|
26
|
+
"kind": "expression"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
22
29
|
{
|
|
23
30
|
"name": ".items",
|
|
24
31
|
"description": "Defines a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nThe items API can't be used together with a renderer!\n\n#### Example\n\n```javascript\ncontextMenu.items = [\n {text: 'Menu Item 1', theme: 'primary', children:\n [\n {text: 'Menu Item 1-1', checked: true},\n {text: 'Menu Item 1-2'}\n ]\n },\n {component: 'hr'},\n {text: 'Menu Item 2', children:\n [\n {text: 'Menu Item 2-1'},\n {text: 'Menu Item 2-2', disabled: true}\n ]\n },\n {text: 'Menu Item 3', disabled: true}\n];\n```",
|