@vaadin/context-menu 25.3.0-alpha1 → 25.3.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.
@@ -17,6 +17,316 @@
17
17
  }
18
18
  ]
19
19
  },
20
+ {
21
+ "kind": "javascript-module",
22
+ "path": "vaadin-context-menu-list-box.js",
23
+ "declarations": [],
24
+ "exports": [
25
+ {
26
+ "kind": "js",
27
+ "name": "*",
28
+ "declaration": {
29
+ "name": "*",
30
+ "module": "src/vaadin-context-menu-list-box.js"
31
+ }
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "kind": "javascript-module",
37
+ "path": "vaadin-context-menu-item.js",
38
+ "declarations": [],
39
+ "exports": [
40
+ {
41
+ "kind": "js",
42
+ "name": "*",
43
+ "declaration": {
44
+ "name": "*",
45
+ "module": "src/vaadin-context-menu-item.js"
46
+ }
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "kind": "javascript-module",
52
+ "path": "src/vaadin-context-menu-item.js",
53
+ "declarations": [
54
+ {
55
+ "kind": "class",
56
+ "description": "`<vaadin-context-menu-item>` is a Web Component for creating `<vaadin-context-menu>` items.\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n-------------|----------------\n`checkmark` | The graphical checkmark shown for a checked item\n`content` | The element that wraps the slot\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`active` | Set when the item is pressed down, either with mouse, touch or the keyboard.\n`disabled` | Set when the item is disabled.\n`focus-ring` | Set when the item is focused using the keyboard.\n`focused` | Set when the item is focused.\n`expanded` | Set when the item has a sub-menu and it is opened.\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:----------------------------------|\n| `--vaadin-item-border-radius` |\n| `--vaadin-item-checkmark-color` |\n| `--vaadin-item-gap` |\n| `--vaadin-item-height` |\n| `--vaadin-item-padding` |\n| `--vaadin-item-text-align` |\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
57
+ "name": "ContextMenuItem",
58
+ "members": [
59
+ {
60
+ "kind": "field",
61
+ "name": "disabled",
62
+ "privacy": "public",
63
+ "type": {
64
+ "text": "boolean"
65
+ },
66
+ "description": "If true, the user cannot interact with this element.",
67
+ "attribute": "disabled",
68
+ "inheritedFrom": {
69
+ "name": "DisabledMixin",
70
+ "package": "@vaadin/a11y-base/src/disabled-mixin.js"
71
+ }
72
+ },
73
+ {
74
+ "kind": "field",
75
+ "name": "selected",
76
+ "privacy": "public",
77
+ "type": {
78
+ "text": "boolean"
79
+ },
80
+ "description": "If true, the item is in selected state.",
81
+ "attribute": "selected",
82
+ "inheritedFrom": {
83
+ "name": "ItemMixin",
84
+ "package": "@vaadin/item/src/vaadin-item-mixin.js"
85
+ }
86
+ },
87
+ {
88
+ "kind": "field",
89
+ "name": "value",
90
+ "description": "Submittable string value. The default value is the trimmed text content of the element.",
91
+ "type": {
92
+ "text": "string"
93
+ },
94
+ "inheritedFrom": {
95
+ "name": "ItemMixin",
96
+ "package": "@vaadin/item/src/vaadin-item-mixin.js"
97
+ }
98
+ }
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
+ ],
133
+ "mixins": [
134
+ {
135
+ "name": "ItemMixin",
136
+ "package": "@vaadin/item/src/vaadin-item-mixin.js"
137
+ },
138
+ {
139
+ "name": "ThemableMixin",
140
+ "package": "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js"
141
+ },
142
+ {
143
+ "name": "DirMixin",
144
+ "package": "@vaadin/component-base/src/dir-mixin.js"
145
+ },
146
+ {
147
+ "name": "PolylitMixin",
148
+ "package": "@vaadin/component-base/src/polylit-mixin.js"
149
+ },
150
+ {
151
+ "name": "LumoInjectionMixin",
152
+ "package": "@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js"
153
+ }
154
+ ],
155
+ "superclass": {
156
+ "name": "LitElement",
157
+ "package": "lit"
158
+ },
159
+ "tagName": "vaadin-context-menu-item",
160
+ "customElement": true,
161
+ "events": []
162
+ }
163
+ ],
164
+ "exports": [
165
+ {
166
+ "kind": "js",
167
+ "name": "ContextMenuItem",
168
+ "declaration": {
169
+ "name": "ContextMenuItem",
170
+ "module": "src/vaadin-context-menu-item.js"
171
+ }
172
+ }
173
+ ]
174
+ },
175
+ {
176
+ "kind": "javascript-module",
177
+ "path": "src/vaadin-context-menu-list-box.js",
178
+ "declarations": [
179
+ {
180
+ "kind": "class",
181
+ "description": "`<vaadin-context-menu-list-box>` is a Web Component for wrapping `<vaadin-context-menu>` items.\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### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n------------------|------------------------\n`items` | The items container\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
182
+ "name": "ContextMenuListBox",
183
+ "members": [
184
+ {
185
+ "kind": "field",
186
+ "name": "disabled",
187
+ "privacy": "public",
188
+ "type": {
189
+ "text": "boolean"
190
+ },
191
+ "description": "If true, the user cannot interact with this element.\nWhen the element is disabled, the selected item is\nnot updated when `selected` property is changed.",
192
+ "attribute": "disabled",
193
+ "inheritedFrom": {
194
+ "name": "ListMixin",
195
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
196
+ }
197
+ },
198
+ {
199
+ "kind": "field",
200
+ "name": "items",
201
+ "privacy": "public",
202
+ "type": {
203
+ "text": "!Array<!Element> | undefined"
204
+ },
205
+ "description": "A read-only list of items from which a selection can be made.\nIt is populated from the elements passed to the light DOM,\nand updated dynamically when adding or removing items.",
206
+ "attribute": "items",
207
+ "readonly": true,
208
+ "inheritedFrom": {
209
+ "name": "ListMixin",
210
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
211
+ }
212
+ },
213
+ {
214
+ "kind": "field",
215
+ "name": "orientation",
216
+ "privacy": "public",
217
+ "type": {
218
+ "text": "string"
219
+ },
220
+ "description": "Define how items are disposed in the dom.\nPossible values are: `horizontal|vertical`.\nIt also changes navigation keys from left/right to up/down.",
221
+ "attribute": "orientation",
222
+ "readonly": true,
223
+ "inheritedFrom": {
224
+ "name": "ListMixin",
225
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
226
+ }
227
+ },
228
+ {
229
+ "kind": "field",
230
+ "name": "selected",
231
+ "privacy": "public",
232
+ "type": {
233
+ "text": "number"
234
+ },
235
+ "description": "The index of the item selected in the items array.\nNote: Not updated when used in `multiple` selection mode.",
236
+ "attribute": "selected",
237
+ "inheritedFrom": {
238
+ "name": "ListMixin",
239
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
240
+ }
241
+ }
242
+ ],
243
+ "attributes": [
244
+ {
245
+ "name": "disabled",
246
+ "type": {
247
+ "text": "boolean"
248
+ },
249
+ "description": "If true, the user cannot interact with this element.\nWhen the element is disabled, the selected item is\nnot updated when `selected` property is changed.",
250
+ "fieldName": "disabled",
251
+ "inheritedFrom": {
252
+ "name": "ListMixin",
253
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
254
+ }
255
+ },
256
+ {
257
+ "name": "orientation",
258
+ "type": {
259
+ "text": "string"
260
+ },
261
+ "description": "Define how items are disposed in the dom.\nPossible values are: `horizontal|vertical`.\nIt also changes navigation keys from left/right to up/down.",
262
+ "fieldName": "orientation",
263
+ "inheritedFrom": {
264
+ "name": "ListMixin",
265
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
266
+ }
267
+ },
268
+ {
269
+ "name": "selected",
270
+ "type": {
271
+ "text": "number"
272
+ },
273
+ "description": "The index of the item selected in the items array.\nNote: Not updated when used in `multiple` selection mode.",
274
+ "fieldName": "selected",
275
+ "inheritedFrom": {
276
+ "name": "ListMixin",
277
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
278
+ }
279
+ },
280
+ {
281
+ "type": {
282
+ "text": "string"
283
+ },
284
+ "description": "The theme variants to apply to the component.",
285
+ "name": "theme"
286
+ }
287
+ ],
288
+ "mixins": [
289
+ {
290
+ "name": "ListMixin",
291
+ "package": "@vaadin/a11y-base/src/list-mixin.js"
292
+ },
293
+ {
294
+ "name": "ThemableMixin",
295
+ "package": "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js"
296
+ },
297
+ {
298
+ "name": "DirMixin",
299
+ "package": "@vaadin/component-base/src/dir-mixin.js"
300
+ },
301
+ {
302
+ "name": "PolylitMixin",
303
+ "package": "@vaadin/component-base/src/polylit-mixin.js"
304
+ },
305
+ {
306
+ "name": "LumoInjectionMixin",
307
+ "package": "@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js"
308
+ }
309
+ ],
310
+ "superclass": {
311
+ "name": "LitElement",
312
+ "package": "lit"
313
+ },
314
+ "tagName": "vaadin-context-menu-list-box",
315
+ "customElement": true,
316
+ "events": []
317
+ }
318
+ ],
319
+ "exports": [
320
+ {
321
+ "kind": "js",
322
+ "name": "ContextMenuListBox",
323
+ "declaration": {
324
+ "name": "ContextMenuListBox",
325
+ "module": "src/vaadin-context-menu-list-box.js"
326
+ }
327
+ }
328
+ ]
329
+ },
20
330
  {
21
331
  "kind": "javascript-module",
22
332
  "path": "src/vaadin-context-menu-mixin.js",
@@ -50,7 +360,7 @@
50
360
  "name": "items",
51
361
  "privacy": "public",
52
362
  "type": {
53
- "text": "!Array<!ContextMenuItem> | undefined"
363
+ "text": "!Array<!ContextMenuItemData> | undefined"
54
364
  },
55
365
  "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', 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```\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```",
56
366
  "attribute": "items",
@@ -113,6 +423,7 @@
113
423
  "text": "ContextMenuRenderer | undefined"
114
424
  },
115
425
  "description": "Custom function for rendering the content of the menu overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `contextMenu` The reference to the `<vaadin-context-menu>` element.\n- `context` The object with the menu context, contains:\n - `context.target` the target of the menu opening event,\n - `context.detail` the menu opening event detail.",
426
+ "deprecated": "Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead",
116
427
  "attribute": "renderer"
117
428
  },
118
429
  {
@@ -157,6 +468,16 @@
157
468
  "name": "ItemsMixin",
158
469
  "module": "src/vaadin-contextmenu-items-mixin.js"
159
470
  }
471
+ },
472
+ {
473
+ "name": "items-outside-click",
474
+ "type": {
475
+ "text": "CustomEvent"
476
+ },
477
+ "inheritedFrom": {
478
+ "name": "ItemsMixin",
479
+ "module": "src/vaadin-contextmenu-items-mixin.js"
480
+ }
160
481
  }
161
482
  ],
162
483
  "attributes": [
@@ -199,6 +520,7 @@
199
520
  "text": "ContextMenuRenderer | undefined"
200
521
  },
201
522
  "description": "Custom function for rendering the content of the menu overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `contextMenu` The reference to the `<vaadin-context-menu>` element.\n- `context` The object with the menu context, contains:\n - `context.target` the target of the menu opening event,\n - `context.detail` the menu opening event detail.",
523
+ "deprecated": "Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead",
202
524
  "fieldName": "renderer"
203
525
  },
204
526
  {
@@ -319,7 +641,7 @@
319
641
  "declarations": [
320
642
  {
321
643
  "kind": "class",
322
- "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### 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### Internal components\n\nWhen using `items` API the following internal components are themable:\n\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).\n\nThe `<vaadin-context-menu-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.",
644
+ "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>`](#/elements/vaadin-context-menu-item) - an item element.\n- [`<vaadin-context-menu-list-box>`](#/elements/vaadin-context-menu-list-box) - a list-box element.",
323
645
  "name": "ContextMenu",
324
646
  "members": [
325
647
  {
@@ -350,7 +672,7 @@
350
672
  "name": "items",
351
673
  "privacy": "public",
352
674
  "type": {
353
- "text": "!Array<!ContextMenuItem> | undefined"
675
+ "text": "!Array<!ContextMenuItemData> | undefined"
354
676
  },
355
677
  "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', 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```\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```",
356
678
  "attribute": "items",
@@ -439,6 +761,7 @@
439
761
  "text": "ContextMenuRenderer | undefined"
440
762
  },
441
763
  "description": "Custom function for rendering the content of the menu overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `contextMenu` The reference to the `<vaadin-context-menu>` element.\n- `context` The object with the menu context, contains:\n - `context.target` the target of the menu opening event,\n - `context.detail` the menu opening event detail.",
764
+ "deprecated": "Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead",
442
765
  "attribute": "renderer",
443
766
  "inheritedFrom": {
444
767
  "name": "ContextMenuMixin",
@@ -475,7 +798,7 @@
475
798
  "type": {
476
799
  "text": "CustomEvent"
477
800
  },
478
- "description": "Fired when all menus should close, e.g., after pressing Tab or on submenu close.",
801
+ "description": "Fired when all menus should close, e.g., after pressing Tab or on submenu close. This event is deprecated and will be removed in Vaadin 26. Use `closed` instead.",
479
802
  "inheritedFrom": {
480
803
  "name": "ItemsMixin",
481
804
  "module": "src/vaadin-contextmenu-items-mixin.js"
@@ -504,11 +827,15 @@
504
827
  }
505
828
  },
506
829
  {
830
+ "name": "items-outside-click",
507
831
  "type": {
508
832
  "text": "CustomEvent"
509
833
  },
510
- "description": "Fired when a click happens outside any open sub-menus.",
511
- "name": "items-outside-click"
834
+ "description": "Fired when a click happens outside any open sub-menus. This event is deprecated and will be removed in Vaadin 26. Use `closed` instead.",
835
+ "inheritedFrom": {
836
+ "name": "ItemsMixin",
837
+ "module": "src/vaadin-contextmenu-items-mixin.js"
838
+ }
512
839
  },
513
840
  {
514
841
  "type": {
@@ -582,6 +909,7 @@
582
909
  "text": "ContextMenuRenderer | undefined"
583
910
  },
584
911
  "description": "Custom function for rendering the content of the menu overlay.\nReceives three arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `contextMenu` The reference to the `<vaadin-context-menu>` element.\n- `context` The object with the menu context, contains:\n - `context.target` the target of the menu opening event,\n - `context.detail` the menu opening event detail.",
912
+ "deprecated": "Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead",
585
913
  "fieldName": "renderer",
586
914
  "inheritedFrom": {
587
915
  "name": "ContextMenuMixin",
@@ -599,6 +927,13 @@
599
927
  "name": "ContextMenuMixin",
600
928
  "module": "src/vaadin-context-menu-mixin.js"
601
929
  }
930
+ },
931
+ {
932
+ "type": {
933
+ "text": "string"
934
+ },
935
+ "description": "The theme variants to apply to the component.",
936
+ "name": "theme"
602
937
  }
603
938
  ],
604
939
  "mixins": [
@@ -656,7 +991,7 @@
656
991
  "name": "items",
657
992
  "privacy": "public",
658
993
  "type": {
659
- "text": "!Array<!ContextMenuItem> | undefined"
994
+ "text": "!Array<!ContextMenuItemData> | undefined"
660
995
  },
661
996
  "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', 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```\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```",
662
997
  "attribute": "items"
@@ -674,6 +1009,12 @@
674
1009
  "type": {
675
1010
  "text": "CustomEvent"
676
1011
  }
1012
+ },
1013
+ {
1014
+ "name": "items-outside-click",
1015
+ "type": {
1016
+ "text": "CustomEvent"
1017
+ }
677
1018
  }
678
1019
  ],
679
1020
  "attributes": [],
@@ -704,6 +1045,20 @@
704
1045
  "description": "",
705
1046
  "name": "MenuOverlayMixin",
706
1047
  "members": [
1048
+ {
1049
+ "kind": "field",
1050
+ "name": "autofocus",
1051
+ "privacy": "public",
1052
+ "type": {
1053
+ "text": "boolean"
1054
+ },
1055
+ "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.",
1056
+ "attribute": "autofocus",
1057
+ "inheritedFrom": {
1058
+ "name": "OverlayFocusMixin",
1059
+ "package": "@vaadin/overlay/src/vaadin-overlay-focus-mixin.js"
1060
+ }
1061
+ },
707
1062
  {
708
1063
  "kind": "field",
709
1064
  "name": "focusTrap",
@@ -711,7 +1066,7 @@
711
1066
  "type": {
712
1067
  "text": "boolean"
713
1068
  },
714
- "description": "When true, opening the overlay moves focus to the first focusable child,\nor to the overlay part with tabindex if there are no focusable children.",
1069
+ "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.",
715
1070
  "attribute": "focus-trap",
716
1071
  "inheritedFrom": {
717
1072
  "name": "OverlayFocusMixin",
@@ -842,12 +1197,24 @@
842
1197
  }
843
1198
  ],
844
1199
  "attributes": [
1200
+ {
1201
+ "name": "autofocus",
1202
+ "type": {
1203
+ "text": "boolean"
1204
+ },
1205
+ "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.",
1206
+ "fieldName": "autofocus",
1207
+ "inheritedFrom": {
1208
+ "name": "OverlayFocusMixin",
1209
+ "package": "@vaadin/overlay/src/vaadin-overlay-focus-mixin.js"
1210
+ }
1211
+ },
845
1212
  {
846
1213
  "name": "focus-trap",
847
1214
  "type": {
848
1215
  "text": "boolean"
849
1216
  },
850
- "description": "When true, opening the overlay moves focus to the first focusable child,\nor to the overlay part with tabindex if there are no focusable children.",
1217
+ "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.",
851
1218
  "fieldName": "focusTrap",
852
1219
  "inheritedFrom": {
853
1220
  "name": "OverlayFocusMixin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/context-menu",
3
- "version": "25.3.0-alpha1",
3
+ "version": "25.3.0-alpha10",
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-alpha1",
41
- "@vaadin/component-base": "25.3.0-alpha1",
42
- "@vaadin/item": "25.3.0-alpha1",
43
- "@vaadin/list-box": "25.3.0-alpha1",
44
- "@vaadin/lit-renderer": "25.3.0-alpha1",
45
- "@vaadin/overlay": "25.3.0-alpha1",
46
- "@vaadin/vaadin-themable-mixin": "25.3.0-alpha1",
40
+ "@vaadin/a11y-base": "25.3.0-alpha10",
41
+ "@vaadin/component-base": "25.3.0-alpha10",
42
+ "@vaadin/item": "25.3.0-alpha10",
43
+ "@vaadin/list-box": "25.3.0-alpha10",
44
+ "@vaadin/lit-renderer": "25.3.0-alpha10",
45
+ "@vaadin/overlay": "25.3.0-alpha10",
46
+ "@vaadin/vaadin-themable-mixin": "25.3.0-alpha10",
47
47
  "lit": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@vaadin/aura": "25.3.0-alpha1",
51
- "@vaadin/chai-plugins": "25.3.0-alpha1",
52
- "@vaadin/test-runner-commands": "25.3.0-alpha1",
50
+ "@vaadin/aura": "25.3.0-alpha10",
51
+ "@vaadin/chai-plugins": "25.3.0-alpha10",
52
+ "@vaadin/test-runner-commands": "25.3.0-alpha10",
53
53
  "@vaadin/testing-helpers": "^2.0.0",
54
- "@vaadin/vaadin-lumo-styles": "25.3.0-alpha1",
54
+ "@vaadin/vaadin-lumo-styles": "25.3.0-alpha10",
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": "5824d54c995945aafd50d30edc2cb763a58a18b6"
62
+ "gitHead": "f2833abdf9b613fa0d0ed216830e3f4de87b7dac"
63
63
  }
@@ -52,6 +52,7 @@ export class ContextMenuRendererDirective extends LitRendererDirective<ContextMe
52
52
  * @param renderer the renderer callback that returns a Lit template.
53
53
  * @param dependencies a single dependency or an array of dependencies
54
54
  * which trigger a re-render when changed.
55
+ * @deprecated Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead
55
56
  */
56
57
  export declare function contextMenuRenderer(
57
58
  renderer: ContextMenuLitRenderer,
@@ -56,5 +56,6 @@ export class ContextMenuRendererDirective extends LitRendererDirective {
56
56
  * @param renderer the renderer callback that returns a Lit template.
57
57
  * @param dependencies a single dependency or an array of dependencies
58
58
  * which trigger a re-render when changed.
59
+ * @deprecated Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead
59
60
  */
60
61
  export const contextMenuRenderer = directive(ContextMenuRendererDirective);
@@ -8,7 +8,39 @@ import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
9
 
10
10
  /**
11
- * An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
11
+ * `<vaadin-context-menu-item>` is a Web Component for creating `<vaadin-context-menu>` items.
12
+ *
13
+ * ### Styling
14
+ *
15
+ * The following shadow DOM parts are available for styling:
16
+ *
17
+ * Part name | Description
18
+ * -------------|----------------
19
+ * `checkmark` | The graphical checkmark shown for a checked item
20
+ * `content` | The element that wraps the slot
21
+ *
22
+ * The following state attributes are available for styling:
23
+ *
24
+ * Attribute | Description
25
+ * -------------|-------------
26
+ * `active` | Set when the item is pressed down, either with mouse, touch or the keyboard.
27
+ * `disabled` | Set when the item is disabled.
28
+ * `focus-ring` | Set when the item is focused using the keyboard.
29
+ * `focused` | Set when the item is focused.
30
+ * `expanded` | Set when the item has a sub-menu and it is opened.
31
+ *
32
+ * The following custom CSS properties are available for styling:
33
+ *
34
+ * Custom CSS property |
35
+ * :----------------------------------|
36
+ * | `--vaadin-item-border-radius` |
37
+ * | `--vaadin-item-checkmark-color` |
38
+ * | `--vaadin-item-gap` |
39
+ * | `--vaadin-item-height` |
40
+ * | `--vaadin-item-padding` |
41
+ * | `--vaadin-item-text-align` |
42
+ *
43
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
12
44
  */
13
45
  declare class ContextMenuItem extends ItemMixin(DirMixin(ThemableMixin(HTMLElement))) {}
14
46