@vaadin/context-menu 25.3.0-alpha7 → 25.3.0-alpha9
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/custom-elements.json +75 -28
- package/package.json +13 -13
- package/src/vaadin-context-menu-item.js +1 -0
- package/src/vaadin-context-menu-list-box.js +1 -0
- package/src/vaadin-context-menu-overlay.js +4 -1
- package/src/vaadin-context-menu.js +2 -0
- package/src/vaadin-contextmenu-event.js +23 -0
- package/src/vaadin-contextmenu-items-mixin.js +3 -10
- package/web-types.json +5 -11
- package/web-types.lit.json +2 -2
package/custom-elements.json
CHANGED
|
@@ -97,6 +97,39 @@
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
],
|
|
100
|
+
"attributes": [
|
|
101
|
+
{
|
|
102
|
+
"name": "disabled",
|
|
103
|
+
"type": {
|
|
104
|
+
"text": "boolean"
|
|
105
|
+
},
|
|
106
|
+
"description": "If true, the user cannot interact with this element.",
|
|
107
|
+
"fieldName": "disabled",
|
|
108
|
+
"inheritedFrom": {
|
|
109
|
+
"name": "DisabledMixin",
|
|
110
|
+
"package": "@vaadin/a11y-base/src/disabled-mixin.js"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "selected",
|
|
115
|
+
"type": {
|
|
116
|
+
"text": "boolean"
|
|
117
|
+
},
|
|
118
|
+
"description": "If true, the item is in selected state.",
|
|
119
|
+
"fieldName": "selected",
|
|
120
|
+
"inheritedFrom": {
|
|
121
|
+
"name": "ItemMixin",
|
|
122
|
+
"package": "@vaadin/item/src/vaadin-item-mixin.js"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"type": {
|
|
127
|
+
"text": "string"
|
|
128
|
+
},
|
|
129
|
+
"description": "The theme variants to apply to the component.",
|
|
130
|
+
"name": "theme"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
100
133
|
"mixins": [
|
|
101
134
|
{
|
|
102
135
|
"name": "ItemMixin",
|
|
@@ -125,32 +158,6 @@
|
|
|
125
158
|
},
|
|
126
159
|
"tagName": "vaadin-context-menu-item",
|
|
127
160
|
"customElement": true,
|
|
128
|
-
"attributes": [
|
|
129
|
-
{
|
|
130
|
-
"name": "disabled",
|
|
131
|
-
"type": {
|
|
132
|
-
"text": "boolean"
|
|
133
|
-
},
|
|
134
|
-
"description": "If true, the user cannot interact with this element.",
|
|
135
|
-
"fieldName": "disabled",
|
|
136
|
-
"inheritedFrom": {
|
|
137
|
-
"name": "DisabledMixin",
|
|
138
|
-
"package": "@vaadin/a11y-base/src/disabled-mixin.js"
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"name": "selected",
|
|
143
|
-
"type": {
|
|
144
|
-
"text": "boolean"
|
|
145
|
-
},
|
|
146
|
-
"description": "If true, the item is in selected state.",
|
|
147
|
-
"fieldName": "selected",
|
|
148
|
-
"inheritedFrom": {
|
|
149
|
-
"name": "ItemMixin",
|
|
150
|
-
"package": "@vaadin/item/src/vaadin-item-mixin.js"
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
161
|
"events": []
|
|
155
162
|
}
|
|
156
163
|
],
|
|
@@ -269,6 +276,13 @@
|
|
|
269
276
|
"name": "ListMixin",
|
|
270
277
|
"package": "@vaadin/a11y-base/src/list-mixin.js"
|
|
271
278
|
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"type": {
|
|
282
|
+
"text": "string"
|
|
283
|
+
},
|
|
284
|
+
"description": "The theme variants to apply to the component.",
|
|
285
|
+
"name": "theme"
|
|
272
286
|
}
|
|
273
287
|
],
|
|
274
288
|
"mixins": [
|
|
@@ -899,6 +913,13 @@
|
|
|
899
913
|
"name": "ContextMenuMixin",
|
|
900
914
|
"module": "src/vaadin-context-menu-mixin.js"
|
|
901
915
|
}
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"type": {
|
|
919
|
+
"text": "string"
|
|
920
|
+
},
|
|
921
|
+
"description": "The theme variants to apply to the component.",
|
|
922
|
+
"name": "theme"
|
|
902
923
|
}
|
|
903
924
|
],
|
|
904
925
|
"mixins": [
|
|
@@ -1004,6 +1025,20 @@
|
|
|
1004
1025
|
"description": "",
|
|
1005
1026
|
"name": "MenuOverlayMixin",
|
|
1006
1027
|
"members": [
|
|
1028
|
+
{
|
|
1029
|
+
"kind": "field",
|
|
1030
|
+
"name": "autofocus",
|
|
1031
|
+
"privacy": "public",
|
|
1032
|
+
"type": {
|
|
1033
|
+
"text": "boolean"
|
|
1034
|
+
},
|
|
1035
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
1036
|
+
"attribute": "autofocus",
|
|
1037
|
+
"inheritedFrom": {
|
|
1038
|
+
"name": "OverlayFocusMixin",
|
|
1039
|
+
"package": "@vaadin/overlay/src/vaadin-overlay-focus-mixin.js"
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1007
1042
|
{
|
|
1008
1043
|
"kind": "field",
|
|
1009
1044
|
"name": "focusTrap",
|
|
@@ -1011,7 +1046,7 @@
|
|
|
1011
1046
|
"type": {
|
|
1012
1047
|
"text": "boolean"
|
|
1013
1048
|
},
|
|
1014
|
-
"description": "
|
|
1049
|
+
"description": "Set to true to move focus into the overlay automatically on open\nand keep it inside: Tab and Shift+Tab cycle through the overlay's\ncontent until the overlay is closed.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
1015
1050
|
"attribute": "focus-trap",
|
|
1016
1051
|
"inheritedFrom": {
|
|
1017
1052
|
"name": "OverlayFocusMixin",
|
|
@@ -1142,12 +1177,24 @@
|
|
|
1142
1177
|
}
|
|
1143
1178
|
],
|
|
1144
1179
|
"attributes": [
|
|
1180
|
+
{
|
|
1181
|
+
"name": "autofocus",
|
|
1182
|
+
"type": {
|
|
1183
|
+
"text": "boolean"
|
|
1184
|
+
},
|
|
1185
|
+
"description": "Set to true to move focus into the overlay automatically on open.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
1186
|
+
"fieldName": "autofocus",
|
|
1187
|
+
"inheritedFrom": {
|
|
1188
|
+
"name": "OverlayFocusMixin",
|
|
1189
|
+
"package": "@vaadin/overlay/src/vaadin-overlay-focus-mixin.js"
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1145
1192
|
{
|
|
1146
1193
|
"name": "focus-trap",
|
|
1147
1194
|
"type": {
|
|
1148
1195
|
"text": "boolean"
|
|
1149
1196
|
},
|
|
1150
|
-
"description": "
|
|
1197
|
+
"description": "Set to true to move focus into the overlay automatically on open\nand keep it inside: Tab and Shift+Tab cycle through the overlay's\ncontent until the overlay is closed.\n\nFocus moves to the first tabbable element in the tab order. This\ncan be the overlay itself if it has `tabindex` attribute set to `0`\non the host element or the `overlay` shadow DOM part.",
|
|
1151
1198
|
"fieldName": "focusTrap",
|
|
1152
1199
|
"inheritedFrom": {
|
|
1153
1200
|
"name": "OverlayFocusMixin",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/context-menu",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/a11y-base": "25.3.0-
|
|
41
|
-
"@vaadin/component-base": "25.3.0-
|
|
42
|
-
"@vaadin/item": "25.3.0-
|
|
43
|
-
"@vaadin/list-box": "25.3.0-
|
|
44
|
-
"@vaadin/lit-renderer": "25.3.0-
|
|
45
|
-
"@vaadin/overlay": "25.3.0-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.3.0-alpha9",
|
|
41
|
+
"@vaadin/component-base": "25.3.0-alpha9",
|
|
42
|
+
"@vaadin/item": "25.3.0-alpha9",
|
|
43
|
+
"@vaadin/list-box": "25.3.0-alpha9",
|
|
44
|
+
"@vaadin/lit-renderer": "25.3.0-alpha9",
|
|
45
|
+
"@vaadin/overlay": "25.3.0-alpha9",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-alpha9",
|
|
47
47
|
"lit": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@vaadin/aura": "25.3.0-
|
|
51
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
52
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
50
|
+
"@vaadin/aura": "25.3.0-alpha9",
|
|
51
|
+
"@vaadin/chai-plugins": "25.3.0-alpha9",
|
|
52
|
+
"@vaadin/test-runner-commands": "25.3.0-alpha9",
|
|
53
53
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
54
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
54
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-alpha9",
|
|
55
55
|
"sinon": "^22.0.0"
|
|
56
56
|
},
|
|
57
57
|
"customElements": "custom-elements.json",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"web-types.json",
|
|
60
60
|
"web-types.lit.json"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cb915ebde095ec5b94a87af93dd4530f51984c52"
|
|
63
63
|
}
|
|
@@ -47,6 +47,7 @@ import { contextMenuItemStyles } from './styles/vaadin-context-menu-item-base-st
|
|
|
47
47
|
*
|
|
48
48
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
49
49
|
*
|
|
50
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
50
51
|
* @customElement vaadin-context-menu-item
|
|
51
52
|
* @extends HTMLElement
|
|
52
53
|
*/
|
|
@@ -34,6 +34,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
34
34
|
*
|
|
35
35
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
36
36
|
*
|
|
37
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
37
38
|
* @customElement vaadin-context-menu-list-box
|
|
38
39
|
* @extends HTMLElement
|
|
39
40
|
*/
|
|
@@ -16,11 +16,12 @@ import { MenuOverlayMixin } from './vaadin-menu-overlay-mixin.js';
|
|
|
16
16
|
/**
|
|
17
17
|
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
18
18
|
*
|
|
19
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
19
20
|
* @customElement vaadin-context-menu-overlay
|
|
20
21
|
* @extends HTMLElement
|
|
21
22
|
* @protected
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
class ContextMenuOverlay extends MenuOverlayMixin(
|
|
24
25
|
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
25
26
|
) {
|
|
26
27
|
static get is() {
|
|
@@ -104,3 +105,5 @@ export class ContextMenuOverlay extends MenuOverlayMixin(
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
defineCustomElement(ContextMenuOverlay);
|
|
108
|
+
|
|
109
|
+
export { ContextMenuOverlay };
|
|
@@ -254,6 +254,7 @@ import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
|
|
|
254
254
|
* @fires {CustomEvent} close-all-menus - Fired when all menus should close, e.g., after pressing Tab or on submenu close.
|
|
255
255
|
* @fires {CustomEvent} items-outside-click - Fired when a click happens outside any open sub-menus.
|
|
256
256
|
*
|
|
257
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
257
258
|
* @customElement vaadin-context-menu
|
|
258
259
|
* @extends HTMLElement
|
|
259
260
|
*/
|
|
@@ -361,4 +362,5 @@ class ContextMenu extends ContextMenuMixin(ElementMixin(ThemePropertyMixin(Polyl
|
|
|
361
362
|
}
|
|
362
363
|
|
|
363
364
|
defineCustomElement(ContextMenu);
|
|
365
|
+
|
|
364
366
|
export { ContextMenu };
|
|
@@ -7,6 +7,11 @@ import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
|
|
|
7
7
|
import { isFirefox, isIOS } from '@vaadin/component-base/src/browser-utils.js';
|
|
8
8
|
import { prevent, register } from '@vaadin/component-base/src/gestures.js';
|
|
9
9
|
|
|
10
|
+
// A `contextmenu` caused by a selection change on touch focus (e.g. with `autoselect`) is
|
|
11
|
+
// dispatched in the same input turn as the tap, measured at ~80 ms after `touchstart`. A long
|
|
12
|
+
// press needs the finger held for 500 ms or more, which platform settings can shorten.
|
|
13
|
+
const SELECTION_CONTEXTMENU_MAX_DELAY = 200;
|
|
14
|
+
|
|
10
15
|
register({
|
|
11
16
|
name: 'vaadin-contextmenu',
|
|
12
17
|
deps: ['touchstart', 'touchmove', 'touchend', 'contextmenu'],
|
|
@@ -21,6 +26,10 @@ register({
|
|
|
21
26
|
sourceEvent: null,
|
|
22
27
|
},
|
|
23
28
|
|
|
29
|
+
// Deliberately not cleared in `reset()`: it runs when the `contextmenu` handling starts,
|
|
30
|
+
// which is exactly when this value is needed.
|
|
31
|
+
_touchStartTime: null,
|
|
32
|
+
|
|
24
33
|
reset() {
|
|
25
34
|
this.info.sourceEvent = null;
|
|
26
35
|
this._cancelTimer();
|
|
@@ -49,6 +58,8 @@ register({
|
|
|
49
58
|
touchstart(e) {
|
|
50
59
|
this._setSourceEvent(e);
|
|
51
60
|
|
|
61
|
+
this._touchStartTime = performance.now();
|
|
62
|
+
|
|
52
63
|
this.info.touchStartCoords = {
|
|
53
64
|
x: e.changedTouches[0].clientX,
|
|
54
65
|
y: e.changedTouches[0].clientY,
|
|
@@ -92,6 +103,18 @@ register({
|
|
|
92
103
|
},
|
|
93
104
|
|
|
94
105
|
contextmenu(e) {
|
|
106
|
+
// Ignore a `contextmenu` that fires too soon after `touchstart` to be a long press. On
|
|
107
|
+
// touch, changing the text selection on focus (e.g. with `autoselect`) makes the browser
|
|
108
|
+
// fire `contextmenu` as a side effect of the tap itself. Mouse and keyboard events do
|
|
109
|
+
// not follow a touch this closely in practice.
|
|
110
|
+
//
|
|
111
|
+
// Uses `performance.now()` rather than `e.timeStamp`: on Android, the `contextmenu` of a
|
|
112
|
+
// long press carries the timestamp of the touch that started it, so `e.timeStamp` would
|
|
113
|
+
// report no elapsed time and suppress every long press.
|
|
114
|
+
if (this._touchStartTime !== null && performance.now() - this._touchStartTime < SELECTION_CONTEXTMENU_MAX_DELAY) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
95
118
|
if (!e.shiftKey) {
|
|
96
119
|
this._setSourceEvent(e);
|
|
97
120
|
if (isFirefox && isKeyboardActive()) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
|
|
7
7
|
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
8
|
+
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
8
9
|
|
|
9
10
|
export const ItemsMixin = (superClass) =>
|
|
10
11
|
class ItemsMixin extends superClass {
|
|
@@ -165,11 +166,7 @@ export const ItemsMixin = (superClass) =>
|
|
|
165
166
|
subMenuOverlay._setParentOverlay(parent);
|
|
166
167
|
|
|
167
168
|
// Set theme attribute from parent element
|
|
168
|
-
|
|
169
|
-
subMenu.setAttribute('theme', parent.getAttribute('theme'));
|
|
170
|
-
} else {
|
|
171
|
-
subMenu.removeAttribute('theme');
|
|
172
|
-
}
|
|
169
|
+
setOrRemoveAttribute(subMenu, 'theme', parent.getAttribute('theme'));
|
|
173
170
|
|
|
174
171
|
const content = subMenuOverlay.$.content;
|
|
175
172
|
content.style.minWidth = '';
|
|
@@ -547,11 +544,7 @@ export const ItemsMixin = (superClass) =>
|
|
|
547
544
|
|
|
548
545
|
/** @private */
|
|
549
546
|
__updateTheme(component, theme) {
|
|
550
|
-
|
|
551
|
-
component.setAttribute('theme', theme);
|
|
552
|
-
} else {
|
|
553
|
-
component.removeAttribute('theme');
|
|
554
|
-
}
|
|
547
|
+
setOrRemoveAttribute(component, 'theme', theme);
|
|
555
548
|
}
|
|
556
549
|
|
|
557
550
|
close() {
|
package/web-types.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": "25.3.0-
|
|
4
|
+
"version": "25.3.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -33,9 +33,7 @@
|
|
|
33
33
|
"description": "The theme variants to apply to the component.",
|
|
34
34
|
"value": {
|
|
35
35
|
"type": [
|
|
36
|
-
"string"
|
|
37
|
-
"null",
|
|
38
|
-
"undefined"
|
|
36
|
+
"string"
|
|
39
37
|
]
|
|
40
38
|
}
|
|
41
39
|
}
|
|
@@ -100,9 +98,7 @@
|
|
|
100
98
|
"description": "The theme variants to apply to the component.",
|
|
101
99
|
"value": {
|
|
102
100
|
"type": [
|
|
103
|
-
"string"
|
|
104
|
-
"null",
|
|
105
|
-
"undefined"
|
|
101
|
+
"string"
|
|
106
102
|
]
|
|
107
103
|
}
|
|
108
104
|
}
|
|
@@ -133,7 +129,7 @@
|
|
|
133
129
|
},
|
|
134
130
|
{
|
|
135
131
|
"name": "vaadin-context-menu",
|
|
136
|
-
"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.\nIf item does not have `keepOpen` property the menu will be closed.\n\n```javascript\ncontextMenu.items = [\n { text: 'Menu Item 1', theme: 'primary', className: 'first', children:\n [\n { text: 'Menu Item 1-1', checked: true, keepOpen: 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, className: 'last' }\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#### Disabled menu items\n\nWhen disabled, menu items are rendered as \"dimmed\".\n\nBy default, disabled items are not focusable and don't react to hover.\nAs a result, they are hidden from assistive technologies, and it's not\npossible to show a tooltip to explain why they are disabled. This can\nbe addressed by enabling the feature flag `accessibleDisabledMenuItems`,\nwhich makes disabled items focusable and hoverable, while still\npreventing them from being activated:\n\n```js\n// Set before any context menu is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledMenuItems = true;\n```\n\n#### Item tooltips\n\nMenu items can have tooltips that are shown on hover and keyboard\nfocus. To enable them, add a slotted `<vaadin-tooltip>` element\nand set the `tooltip` property on each item that should have one:\n\n```html\n<vaadin-context-menu>\n <vaadin-tooltip slot=\"tooltip\"></vaadin-tooltip>\n</vaadin-context-menu>\n```\n\n### Slotted list-box\n\nThe content of the menu can also be populated by providing a custom\n`<vaadin-context-menu-list-box>` with the `overlay` slot:\n\n```html\n<vaadin-context-menu>\n <vaadin-context-menu-list-box slot=\"overlay\">\n <vaadin-context-menu-item>Edit</vaadin-context-menu-item>\n <vaadin-context-menu-item>Delete</vaadin-context-menu-item>\n </vaadin-context-menu-list-box>\n</vaadin-context-menu>\n```\n\n**Note:** slotted list-box supports a single root-level menu only and\ncannot be combined with the `items` or `renderer` API.\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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property | Description\n--------------------------------------|-------------\n`--vaadin-context-menu-offset-top` | Used as an offset when using `position` and the context menu is aligned vertically below the target\n`--vaadin-context-menu-offset-bottom` | Used as an offset when using `position` and the context menu is aligned vertically above the target\n`--vaadin-context-menu-offset-start` | Used as an offset when using `position` and the context menu is aligned horizontally after the target\n`--vaadin-context-menu-offset-end` | Used as an offset when using `position` and the context menu is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Related components\n\nIn addition to `<vaadin-context-menu>` itself, the following components are themable:\n\n- [`<vaadin-context-menu-item>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-
|
|
132
|
+
"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.\nIf item does not have `keepOpen` property the menu will be closed.\n\n```javascript\ncontextMenu.items = [\n { text: 'Menu Item 1', theme: 'primary', className: 'first', children:\n [\n { text: 'Menu Item 1-1', checked: true, keepOpen: 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, className: 'last' }\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#### Disabled menu items\n\nWhen disabled, menu items are rendered as \"dimmed\".\n\nBy default, disabled items are not focusable and don't react to hover.\nAs a result, they are hidden from assistive technologies, and it's not\npossible to show a tooltip to explain why they are disabled. This can\nbe addressed by enabling the feature flag `accessibleDisabledMenuItems`,\nwhich makes disabled items focusable and hoverable, while still\npreventing them from being activated:\n\n```js\n// Set before any context menu is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledMenuItems = true;\n```\n\n#### Item tooltips\n\nMenu items can have tooltips that are shown on hover and keyboard\nfocus. To enable them, add a slotted `<vaadin-tooltip>` element\nand set the `tooltip` property on each item that should have one:\n\n```html\n<vaadin-context-menu>\n <vaadin-tooltip slot=\"tooltip\"></vaadin-tooltip>\n</vaadin-context-menu>\n```\n\n### Slotted list-box\n\nThe content of the menu can also be populated by providing a custom\n`<vaadin-context-menu-list-box>` with the `overlay` slot:\n\n```html\n<vaadin-context-menu>\n <vaadin-context-menu-list-box slot=\"overlay\">\n <vaadin-context-menu-item>Edit</vaadin-context-menu-item>\n <vaadin-context-menu-item>Delete</vaadin-context-menu-item>\n </vaadin-context-menu-list-box>\n</vaadin-context-menu>\n```\n\n**Note:** slotted list-box supports a single root-level menu only and\ncannot be combined with the `items` or `renderer` API.\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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property | Description\n--------------------------------------|-------------\n`--vaadin-context-menu-offset-top` | Used as an offset when using `position` and the context menu is aligned vertically below the target\n`--vaadin-context-menu-offset-bottom` | Used as an offset when using `position` and the context menu is aligned vertically above the target\n`--vaadin-context-menu-offset-start` | Used as an offset when using `position` and the context menu is aligned horizontally after the target\n`--vaadin-context-menu-offset-end` | Used as an offset when using `position` and the context menu is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Related components\n\nIn addition to `<vaadin-context-menu>` itself, the following components are themable:\n\n- [`<vaadin-context-menu-item>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha9/#/elements/vaadin-context-menu-item) - an item element.\n- [`<vaadin-context-menu-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha9/#/elements/vaadin-context-menu-list-box) - a list-box element.",
|
|
137
133
|
"attributes": [
|
|
138
134
|
{
|
|
139
135
|
"name": "close-on",
|
|
@@ -176,9 +172,7 @@
|
|
|
176
172
|
"description": "The theme variants to apply to the component.",
|
|
177
173
|
"value": {
|
|
178
174
|
"type": [
|
|
179
|
-
"string"
|
|
180
|
-
"null",
|
|
181
|
-
"undefined"
|
|
175
|
+
"string"
|
|
182
176
|
]
|
|
183
177
|
}
|
|
184
178
|
}
|
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": "25.3.0-
|
|
4
|
+
"version": "25.3.0-alpha9",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"name": "vaadin-context-menu",
|
|
68
|
-
"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.\nIf item does not have `keepOpen` property the menu will be closed.\n\n```javascript\ncontextMenu.items = [\n { text: 'Menu Item 1', theme: 'primary', className: 'first', children:\n [\n { text: 'Menu Item 1-1', checked: true, keepOpen: 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, className: 'last' }\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#### Disabled menu items\n\nWhen disabled, menu items are rendered as \"dimmed\".\n\nBy default, disabled items are not focusable and don't react to hover.\nAs a result, they are hidden from assistive technologies, and it's not\npossible to show a tooltip to explain why they are disabled. This can\nbe addressed by enabling the feature flag `accessibleDisabledMenuItems`,\nwhich makes disabled items focusable and hoverable, while still\npreventing them from being activated:\n\n```js\n// Set before any context menu is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledMenuItems = true;\n```\n\n#### Item tooltips\n\nMenu items can have tooltips that are shown on hover and keyboard\nfocus. To enable them, add a slotted `<vaadin-tooltip>` element\nand set the `tooltip` property on each item that should have one:\n\n```html\n<vaadin-context-menu>\n <vaadin-tooltip slot=\"tooltip\"></vaadin-tooltip>\n</vaadin-context-menu>\n```\n\n### Slotted list-box\n\nThe content of the menu can also be populated by providing a custom\n`<vaadin-context-menu-list-box>` with the `overlay` slot:\n\n```html\n<vaadin-context-menu>\n <vaadin-context-menu-list-box slot=\"overlay\">\n <vaadin-context-menu-item>Edit</vaadin-context-menu-item>\n <vaadin-context-menu-item>Delete</vaadin-context-menu-item>\n </vaadin-context-menu-list-box>\n</vaadin-context-menu>\n```\n\n**Note:** slotted list-box supports a single root-level menu only and\ncannot be combined with the `items` or `renderer` API.\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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property | Description\n--------------------------------------|-------------\n`--vaadin-context-menu-offset-top` | Used as an offset when using `position` and the context menu is aligned vertically below the target\n`--vaadin-context-menu-offset-bottom` | Used as an offset when using `position` and the context menu is aligned vertically above the target\n`--vaadin-context-menu-offset-start` | Used as an offset when using `position` and the context menu is aligned horizontally after the target\n`--vaadin-context-menu-offset-end` | Used as an offset when using `position` and the context menu is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Related components\n\nIn addition to `<vaadin-context-menu>` itself, the following components are themable:\n\n- [`<vaadin-context-menu-item>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-
|
|
68
|
+
"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.\nIf item does not have `keepOpen` property the menu will be closed.\n\n```javascript\ncontextMenu.items = [\n { text: 'Menu Item 1', theme: 'primary', className: 'first', children:\n [\n { text: 'Menu Item 1-1', checked: true, keepOpen: 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, className: 'last' }\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#### Disabled menu items\n\nWhen disabled, menu items are rendered as \"dimmed\".\n\nBy default, disabled items are not focusable and don't react to hover.\nAs a result, they are hidden from assistive technologies, and it's not\npossible to show a tooltip to explain why they are disabled. This can\nbe addressed by enabling the feature flag `accessibleDisabledMenuItems`,\nwhich makes disabled items focusable and hoverable, while still\npreventing them from being activated:\n\n```js\n// Set before any context menu is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledMenuItems = true;\n```\n\n#### Item tooltips\n\nMenu items can have tooltips that are shown on hover and keyboard\nfocus. To enable them, add a slotted `<vaadin-tooltip>` element\nand set the `tooltip` property on each item that should have one:\n\n```html\n<vaadin-context-menu>\n <vaadin-tooltip slot=\"tooltip\"></vaadin-tooltip>\n</vaadin-context-menu>\n```\n\n### Slotted list-box\n\nThe content of the menu can also be populated by providing a custom\n`<vaadin-context-menu-list-box>` with the `overlay` slot:\n\n```html\n<vaadin-context-menu>\n <vaadin-context-menu-list-box slot=\"overlay\">\n <vaadin-context-menu-item>Edit</vaadin-context-menu-item>\n <vaadin-context-menu-item>Delete</vaadin-context-menu-item>\n </vaadin-context-menu-list-box>\n</vaadin-context-menu>\n```\n\n**Note:** slotted list-box supports a single root-level menu only and\ncannot be combined with the `items` or `renderer` API.\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\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\n### Custom CSS Properties\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property | Description\n--------------------------------------|-------------\n`--vaadin-context-menu-offset-top` | Used as an offset when using `position` and the context menu is aligned vertically below the target\n`--vaadin-context-menu-offset-bottom` | Used as an offset when using `position` and the context menu is aligned vertically above the target\n`--vaadin-context-menu-offset-start` | Used as an offset when using `position` and the context menu is aligned horizontally after the target\n`--vaadin-context-menu-offset-end` | Used as an offset when using `position` and the context menu is aligned horizontally before the target\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Related components\n\nIn addition to `<vaadin-context-menu>` itself, the following components are themable:\n\n- [`<vaadin-context-menu-item>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha9/#/elements/vaadin-context-menu-item) - an item element.\n- [`<vaadin-context-menu-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha9/#/elements/vaadin-context-menu-list-box) - a list-box element.",
|
|
69
69
|
"extension": true,
|
|
70
70
|
"attributes": [
|
|
71
71
|
{
|