@vaadin/context-menu 25.3.0-alpha6 → 25.3.0-alpha8

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.
@@ -5,11 +5,11 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { ContextMenuRenderer } from './vaadin-context-menu.js';
8
- import type { ContextMenuItem, ItemsMixinClass } from './vaadin-contextmenu-items-mixin.js';
8
+ import type { ContextMenuItemData, ItemsMixinClass } from './vaadin-contextmenu-items-mixin.js';
9
9
 
10
10
  export declare function ContextMenuMixin<
11
11
  T extends Constructor<HTMLElement>,
12
- TItem extends ContextMenuItem = ContextMenuItem,
12
+ TItem extends ContextMenuItemData = ContextMenuItemData,
13
13
  >(base: T): Constructor<ContextMenuMixinClass> & Constructor<ItemsMixinClass<TItem>> & T;
14
14
 
15
15
  export declare class ContextMenuMixinClass {
@@ -52,6 +52,8 @@ export declare class ContextMenuMixinClass {
52
52
  * - `context` The object with the menu context, contains:
53
53
  * - `context.target` the target of the menu opening event,
54
54
  * - `context.detail` the menu opening event detail.
55
+ *
56
+ * @deprecated Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead
55
57
  */
56
58
  renderer: ContextMenuRenderer | null | undefined;
57
59
 
@@ -83,5 +85,5 @@ export declare class ContextMenuMixinClass {
83
85
 
84
86
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
85
87
  export declare interface ContextMenuMixinClass<
86
- TItem extends ContextMenuItem = ContextMenuItem,
88
+ TItem extends ContextMenuItemData = ContextMenuItemData,
87
89
  > extends ItemsMixinClass<TItem> {}
@@ -81,12 +81,22 @@ export const ContextMenuMixin = (superClass) =>
81
81
  * - `context.target` the target of the menu opening event,
82
82
  * - `context.detail` the menu opening event detail.
83
83
  * @type {ContextMenuRenderer | undefined}
84
+ * @deprecated Use a slotted `<vaadin-context-menu-list-box>` or the `items` property instead
84
85
  */
85
86
  renderer: {
86
87
  type: Function,
87
88
  sync: true,
88
89
  },
89
90
 
91
+ /**
92
+ * The `<vaadin-context-menu-list-box>` slotted directly into the overlay slot.
93
+ * @private
94
+ */
95
+ __slottedListBox: {
96
+ type: Object,
97
+ sync: true,
98
+ },
99
+
90
100
  /**
91
101
  * When true, the menu overlay is modeless.
92
102
  * @protected
@@ -119,11 +129,7 @@ export const ContextMenuMixin = (superClass) =>
119
129
  }
120
130
 
121
131
  static get observers() {
122
- return [
123
- '_targetOrOpenOnChanged(listenOn, openOn)',
124
- '_rendererChanged(renderer, items)',
125
- '_fullscreenChanged(_fullscreen)',
126
- ];
132
+ return ['_targetOrOpenOnChanged(listenOn, openOn)', '_fullscreenChanged(_fullscreen)'];
127
133
  }
128
134
 
129
135
  constructor() {
@@ -188,6 +194,25 @@ export const ContextMenuMixin = (superClass) =>
188
194
  }
189
195
  }
190
196
 
197
+ /** @protected */
198
+ updated(props) {
199
+ super.updated(props);
200
+
201
+ if (props.has('renderer') || props.has('items') || props.has('__slottedListBox')) {
202
+ const contentSources = [this.items, this.renderer, this.__slottedListBox].filter(Boolean);
203
+ if (contentSources.length > 1) {
204
+ throw new Error(
205
+ 'The "items", "renderer", and slotted "<vaadin-context-menu-list-box>" cannot be used together.',
206
+ );
207
+ }
208
+
209
+ // With items property, menu closes on item selection or items-outside-click.
210
+ if (this.items && this.closeOn === 'click') {
211
+ this.closeOn = '';
212
+ }
213
+ }
214
+ }
215
+
191
216
  /**
192
217
  * Runs before overlay is fully rendered
193
218
  * @private
@@ -319,19 +344,6 @@ export const ContextMenuMixin = (superClass) =>
319
344
  this.__restoreMenuState();
320
345
  }
321
346
 
322
- /** @private */
323
- _rendererChanged(renderer, items) {
324
- if (items) {
325
- if (renderer) {
326
- throw new Error('The items API cannot be used together with a renderer');
327
- }
328
-
329
- if (this.closeOn === 'click') {
330
- this.closeOn = '';
331
- }
332
- }
333
- }
334
-
335
347
  /**
336
348
  * Closes the overlay.
337
349
  */
@@ -401,7 +413,7 @@ export const ContextMenuMixin = (superClass) =>
401
413
 
402
414
  /** @private */
403
415
  __preserveMenuState() {
404
- const listBox = this.__getListBox();
416
+ const listBox = this._menuListBox;
405
417
  if (listBox) {
406
418
  this.__focusedIndex = listBox.items.indexOf(listBox.focused);
407
419
 
@@ -417,11 +429,11 @@ export const ContextMenuMixin = (superClass) =>
417
429
  const subMenuIndex = this.__subMenuIndex;
418
430
  const selectedIndex = this.__selectedIndex;
419
431
 
420
- const listBox = this.__getListBox();
432
+ const listBox = this._menuListBox;
421
433
 
422
434
  if (listBox) {
423
435
  // Initialize menu items synchronously
424
- listBox._observer.flush();
436
+ listBox._observer?.flush();
425
437
 
426
438
  if (subMenuIndex > -1) {
427
439
  const itemToOpen = listBox.items[subMenuIndex];
@@ -458,6 +470,17 @@ export const ContextMenuMixin = (superClass) =>
458
470
  }
459
471
  }
460
472
 
473
+ /**
474
+ * Detects a `<vaadin-context-menu-list-box>` slotted directly into the overlay
475
+ * slot (instead of the default one rendered into slotted `div` element).
476
+ *
477
+ * @param {!Event} e
478
+ * @private
479
+ */
480
+ __onOverlaySlotChange(e) {
481
+ this.__slottedListBox = e.target.assignedElements().find((el) => el._hasVaadinListMixin);
482
+ }
483
+
461
484
  /** @private */
462
485
  __onScroll() {
463
486
  if (!this.opened || this.position) {
@@ -16,6 +16,7 @@ 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
@@ -6,9 +6,9 @@
6
6
  import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
7
7
  import type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
8
8
  import type { ContextMenuMixinClass } from './vaadin-context-menu-mixin.js';
9
- import type { ContextMenuItem } from './vaadin-contextmenu-items-mixin.js';
9
+ import type { ContextMenuItem, ContextMenuItemData } from './vaadin-contextmenu-items-mixin.js';
10
10
 
11
- export { ContextMenuItem };
11
+ export { ContextMenuItem, ContextMenuItemData };
12
12
 
13
13
  export type ContextMenuPosition =
14
14
  | 'bottom-end'
@@ -43,7 +43,7 @@ export type ContextMenuOpenedChangedEvent = CustomEvent<{ value: boolean }>;
43
43
  /**
44
44
  * Fired when an item is selected when the context menu is populated using the `items` API.
45
45
  */
46
- export type ContextMenuItemSelectedEvent<TItem extends ContextMenuItem = ContextMenuItem> = CustomEvent<{
46
+ export type ContextMenuItemSelectedEvent<TItem extends ContextMenuItemData = ContextMenuItemData> = CustomEvent<{
47
47
  value: TItem;
48
48
  }>;
49
49
 
@@ -52,7 +52,7 @@ export type ContextMenuItemSelectedEvent<TItem extends ContextMenuItem = Context
52
52
  */
53
53
  export type ContextMenuClosedEvent = CustomEvent;
54
54
 
55
- export interface ContextMenuCustomEventMap<TItem extends ContextMenuItem = ContextMenuItem> {
55
+ export interface ContextMenuCustomEventMap<TItem extends ContextMenuItemData = ContextMenuItemData> {
56
56
  'opened-changed': ContextMenuOpenedChangedEvent;
57
57
 
58
58
  'item-selected': ContextMenuItemSelectedEvent<TItem>;
@@ -64,7 +64,7 @@ export interface ContextMenuCustomEventMap<TItem extends ContextMenuItem = Conte
64
64
  closed: ContextMenuClosedEvent;
65
65
  }
66
66
 
67
- export interface ContextMenuEventMap<TItem extends ContextMenuItem = ContextMenuItem>
67
+ export interface ContextMenuEventMap<TItem extends ContextMenuItemData = ContextMenuItemData>
68
68
  extends HTMLElementEventMap, ContextMenuCustomEventMap<TItem> {}
69
69
 
70
70
  /**
@@ -134,6 +134,23 @@ export interface ContextMenuEventMap<TItem extends ContextMenuItem = ContextMenu
134
134
  * </vaadin-context-menu>
135
135
  * ```
136
136
  *
137
+ * ### Slotted list-box
138
+ *
139
+ * The content of the menu can also be populated by providing a custom
140
+ * `<vaadin-context-menu-list-box>` with the `overlay` slot:
141
+ *
142
+ * ```html
143
+ * <vaadin-context-menu>
144
+ * <vaadin-context-menu-list-box slot="overlay">
145
+ * <vaadin-context-menu-item>Edit</vaadin-context-menu-item>
146
+ * <vaadin-context-menu-item>Delete</vaadin-context-menu-item>
147
+ * </vaadin-context-menu-list-box>
148
+ * </vaadin-context-menu>
149
+ * ```
150
+ *
151
+ * **Note:** slotted list-box supports a single root-level menu only and
152
+ * cannot be combined with the `items` or `renderer` API.
153
+ *
137
154
  * ### Rendering
138
155
  *
139
156
  * The content of the menu can be populated by using the renderer callback function.
@@ -276,19 +293,12 @@ export interface ContextMenuEventMap<TItem extends ContextMenuItem = ContextMenu
276
293
  *
277
294
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
278
295
  *
279
- * ### Internal components
280
- *
281
- * When using `items` API the following internal components are themable:
282
- *
283
- * - `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
284
- * - `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
296
+ * ### Related components
285
297
  *
286
- * The `<vaadin-context-menu-item>` sub-menu elements have the following additional state attributes
287
- * on top of the built-in `<vaadin-item>` state attributes:
298
+ * In addition to `<vaadin-context-menu>` itself, the following components are themable:
288
299
  *
289
- * Attribute | Description
290
- * ---------- |-------------
291
- * `expanded` | Expanded parent item.
300
+ * - [`<vaadin-context-menu-item>`](#/elements/vaadin-context-menu-item) - an item element.
301
+ * - [`<vaadin-context-menu-list-box>`](#/elements/vaadin-context-menu-list-box) - a list-box element.
292
302
  *
293
303
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
294
304
  * @fires {CustomEvent} item-selected - Fired when an item is selected when the context menu is populated using the `items` API.
@@ -296,7 +306,7 @@ export interface ContextMenuEventMap<TItem extends ContextMenuItem = ContextMenu
296
306
  * @fires {CustomEvent} close-all-menus - Fired when all menus should close, e.g., after pressing Tab or on submenu close.
297
307
  * @fires {CustomEvent} items-outside-click - Fired when a click happens outside any open sub-menus.
298
308
  */
299
- declare class ContextMenu<TItem extends ContextMenuItem = ContextMenuItem> extends HTMLElement {
309
+ declare class ContextMenu<TItem extends ContextMenuItemData = ContextMenuItemData> extends HTMLElement {
300
310
  /**
301
311
  * Position of the overlay with respect to the target.
302
312
  * Supported values: null, `top-start`, `top`, `top-end`,
@@ -318,7 +328,7 @@ declare class ContextMenu<TItem extends ContextMenuItem = ContextMenuItem> exten
318
328
  ): void;
319
329
  }
320
330
 
321
- interface ContextMenu<TItem extends ContextMenuItem = ContextMenuItem>
331
+ interface ContextMenu<TItem extends ContextMenuItemData = ContextMenuItemData>
322
332
  extends ContextMenuMixinClass<TItem>, ElementMixinClass, ThemePropertyMixinClass {}
323
333
 
324
334
  declare global {
@@ -82,6 +82,23 @@ import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
82
82
  * </vaadin-context-menu>
83
83
  * ```
84
84
  *
85
+ * ### Slotted list-box
86
+ *
87
+ * The content of the menu can also be populated by providing a custom
88
+ * `<vaadin-context-menu-list-box>` with the `overlay` slot:
89
+ *
90
+ * ```html
91
+ * <vaadin-context-menu>
92
+ * <vaadin-context-menu-list-box slot="overlay">
93
+ * <vaadin-context-menu-item>Edit</vaadin-context-menu-item>
94
+ * <vaadin-context-menu-item>Delete</vaadin-context-menu-item>
95
+ * </vaadin-context-menu-list-box>
96
+ * </vaadin-context-menu>
97
+ * ```
98
+ *
99
+ * **Note:** slotted list-box supports a single root-level menu only and
100
+ * cannot be combined with the `items` or `renderer` API.
101
+ *
85
102
  * ### Rendering
86
103
  *
87
104
  * The content of the menu can be populated by using the renderer callback function.
@@ -224,19 +241,12 @@ import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
224
241
  *
225
242
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
226
243
  *
227
- * ### Internal components
228
- *
229
- * When using `items` API the following internal components are themable:
230
- *
231
- * - `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
232
- * - `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
244
+ * ### Related components
233
245
  *
234
- * The `<vaadin-context-menu-item>` sub-menu elements have the following additional state attributes
235
- * on top of the built-in `<vaadin-item>` state attributes:
246
+ * In addition to `<vaadin-context-menu>` itself, the following components are themable:
236
247
  *
237
- * Attribute | Description
238
- * ---------- |-------------
239
- * `expanded` | Expanded parent item.
248
+ * - [`<vaadin-context-menu-item>`](#/elements/vaadin-context-menu-item) - an item element.
249
+ * - [`<vaadin-context-menu-list-box>`](#/elements/vaadin-context-menu-list-box) - a list-box element.
240
250
  *
241
251
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
242
252
  * @fires {CustomEvent} item-selected - Fired when an item is selected when the context menu is populated using the `items` API.
@@ -244,6 +254,7 @@ import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
244
254
  * @fires {CustomEvent} close-all-menus - Fired when all menus should close, e.g., after pressing Tab or on submenu close.
245
255
  * @fires {CustomEvent} items-outside-click - Fired when a click happens outside any open sub-menus.
246
256
  *
257
+ * @attr {string} theme - The theme variants to apply to the component.
247
258
  * @customElement vaadin-context-menu
248
259
  * @extends HTMLElement
249
260
  */
@@ -290,7 +301,7 @@ class ContextMenu extends ContextMenuMixin(ElementMixin(ThemePropertyMixin(Polyl
290
301
  .opened="${this.opened}"
291
302
  .model="${context}"
292
303
  .modeless="${this._modeless}"
293
- .renderer="${this.items ? this.__itemsRenderer : this.renderer}"
304
+ .renderer="${this.__slottedListBox ? undefined : this.items ? this.__itemsRenderer : this.renderer}"
294
305
  .position="${position}"
295
306
  .positionTarget="${position ? context?.target : this._positionTarget}"
296
307
  .horizontalAlign="${this.__computeHorizontalAlign(position)}"
@@ -305,7 +316,7 @@ class ContextMenu extends ContextMenuMixin(ElementMixin(ThemePropertyMixin(Polyl
305
316
  @vaadin-overlay-open="${this._onVaadinOverlayOpen}"
306
317
  @vaadin-overlay-closed="${this._onVaadinOverlayClosed}"
307
318
  >
308
- <slot name="overlay"></slot>
319
+ <slot name="overlay" @slotchange="${this.__onOverlaySlotChange}"></slot>
309
320
  <slot name="submenu" slot="submenu"></slot>
310
321
  </vaadin-context-menu-overlay>
311
322
 
@@ -7,7 +7,7 @@ import './vaadin-context-menu-item.js';
7
7
  import './vaadin-context-menu-list-box.js';
8
8
  import type { Constructor } from '@open-wc/dedupe-mixin';
9
9
 
10
- export type ContextMenuItem<TItemData extends object = object> = {
10
+ export type ContextMenuItemData<TItemData extends object = object> = {
11
11
  text?: string;
12
12
  /**
13
13
  * Text to be set as the menu item's tooltip.
@@ -28,12 +28,17 @@ export type ContextMenuItem<TItemData extends object = object> = {
28
28
  keepOpen?: boolean;
29
29
  theme?: string[] | string;
30
30
  className?: string;
31
- children?: Array<ContextMenuItem<TItemData>>;
31
+ children?: Array<ContextMenuItemData<TItemData>>;
32
32
  } & TItemData;
33
33
 
34
+ /**
35
+ * @deprecated Use `ContextMenuItemData` instead.
36
+ */
37
+ export type ContextMenuItem<TItemData extends object = object> = ContextMenuItemData<TItemData>;
38
+
34
39
  export declare function ItemsMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<ItemsMixinClass> & T;
35
40
 
36
- export declare class ItemsMixinClass<TItem extends ContextMenuItem = ContextMenuItem> {
41
+ export declare class ItemsMixinClass<TItem extends ContextMenuItemData = ContextMenuItemData> {
37
42
  /**
38
43
  * Defines a (hierarchical) menu structure for the component.
39
44
  * If a menu item has a non-empty `children` set, a sub-menu with the child items is opened
@@ -11,7 +11,7 @@ export const ItemsMixin = (superClass) =>
11
11
  static get properties() {
12
12
  return {
13
13
  /**
14
- * @typedef ContextMenuItem
14
+ * @typedef ContextMenuItemData
15
15
  * @type {object}
16
16
  * @property {string} text - Text to be set as the menu item component's textContent
17
17
  * @property {string} tooltip - Text to be set as the menu item's tooltip.
@@ -28,7 +28,7 @@ export const ItemsMixin = (superClass) =>
28
28
  * @property {boolean} keepOpen - If true, the menu will not be closed on item selection
29
29
  * @property {string} className - A space-delimited list of CSS class names to be set on the menu item component.
30
30
  * @property {string | string[]} theme - If set, sets the given theme(s) as an attribute to the menu item component, overriding any theme set on the context menu.
31
- * @property {ContextMenuItem[]} children - Array of child menu items
31
+ * @property {ContextMenuItemData[]} children - Array of child menu items
32
32
  */
33
33
 
34
34
  /**
@@ -71,7 +71,7 @@ export const ItemsMixin = (superClass) =>
71
71
  * </vaadin-context-menu>
72
72
  * ```
73
73
  *
74
- * @type {!Array<!ContextMenuItem> | undefined}
74
+ * @type {!Array<!ContextMenuItemData> | undefined}
75
75
  */
76
76
  items: {
77
77
  type: Array,
@@ -140,7 +140,7 @@ export const ItemsMixin = (superClass) =>
140
140
  /** @protected */
141
141
  __forwardFocus() {
142
142
  const overlay = this._overlayElement;
143
- const child = overlay._contentRoot.firstElementChild;
143
+ const child = this._menuListBox ?? overlay._contentRoot.firstElementChild;
144
144
  // If parent item is not focused, do not focus submenu
145
145
  if (overlay.parentOverlay) {
146
146
  const parent = overlay.parentOverlay._contentRoot.querySelector('[expanded]');
@@ -192,7 +192,7 @@ export const ItemsMixin = (superClass) =>
192
192
  }
193
193
 
194
194
  /**
195
- * @param {!ContextMenuItem} item
195
+ * @param {!ContextMenuItemData} item
196
196
  * @return {HTMLElement}
197
197
  * @private
198
198
  */
@@ -460,9 +460,17 @@ export const ItemsMixin = (superClass) =>
460
460
  }
461
461
  }
462
462
 
463
- /** @protected */
464
- __getListBox() {
465
- return this._overlayElement._contentRoot.querySelector(`${this._tagNamePrefix}-list-box`);
463
+ /**
464
+ * The list-box holding the menu items: either one slotted directly into the
465
+ * overlay slot, or the one created inside the renderer root by the `items`
466
+ * path.
467
+ * @protected
468
+ * @return {HTMLElement | null | undefined}
469
+ */
470
+ get _menuListBox() {
471
+ return (
472
+ this.__slottedListBox ?? this._overlayElement._contentRoot.querySelector(`${this._tagNamePrefix}-list-box`)
473
+ );
466
474
  }
467
475
 
468
476
  /**
@@ -67,7 +67,7 @@ export const MenuOverlayMixin = (superClass) =>
67
67
 
68
68
  this.addEventListener('keydown', (e) => {
69
69
  if (!e.defaultPrevented && e.composedPath()[0] === this.$.overlay && [38, 40].indexOf(e.keyCode) > -1) {
70
- const child = this._contentRoot.firstElementChild;
70
+ const child = this.owner._menuListBox ?? this._contentRoot.firstElementChild;
71
71
  if (child && Array.isArray(child.items) && child.items.length) {
72
72
  e.preventDefault();
73
73
  if (e.keyCode === 38) {
@@ -0,0 +1 @@
1
+ export * from './src/vaadin-context-menu-item.js';
@@ -0,0 +1,2 @@
1
+ import './src/vaadin-context-menu-item.js';
2
+ export * from './src/vaadin-context-menu-item.js';
@@ -0,0 +1 @@
1
+ export * from './src/vaadin-context-menu-list-box.js';
@@ -0,0 +1,2 @@
1
+ import './src/vaadin-context-menu-list-box.js';
2
+ export * from './src/vaadin-context-menu-list-box.js';
package/web-types.json CHANGED
@@ -1,14 +1,135 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/context-menu",
4
- "version": "25.3.0-alpha6",
4
+ "version": "25.3.0-alpha8",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
+ {
10
+ "name": "vaadin-context-menu-item",
11
+ "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.",
12
+ "attributes": [
13
+ {
14
+ "name": "disabled",
15
+ "description": "If true, the user cannot interact with this element.",
16
+ "value": {
17
+ "type": [
18
+ "boolean"
19
+ ]
20
+ }
21
+ },
22
+ {
23
+ "name": "selected",
24
+ "description": "If true, the item is in selected state.",
25
+ "value": {
26
+ "type": [
27
+ "boolean"
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "name": "theme",
33
+ "description": "The theme variants to apply to the component.",
34
+ "value": {
35
+ "type": [
36
+ "string"
37
+ ]
38
+ }
39
+ }
40
+ ],
41
+ "js": {
42
+ "properties": [
43
+ {
44
+ "name": "disabled",
45
+ "description": "If true, the user cannot interact with this element.",
46
+ "value": {
47
+ "type": [
48
+ "boolean"
49
+ ]
50
+ }
51
+ },
52
+ {
53
+ "name": "selected",
54
+ "description": "If true, the item is in selected state.",
55
+ "value": {
56
+ "type": [
57
+ "boolean"
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "name": "value",
63
+ "description": "Submittable string value. The default value is the trimmed text content of the element.",
64
+ "value": {
65
+ "type": [
66
+ "string"
67
+ ]
68
+ }
69
+ }
70
+ ],
71
+ "events": []
72
+ }
73
+ },
74
+ {
75
+ "name": "vaadin-context-menu-list-box",
76
+ "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.",
77
+ "attributes": [
78
+ {
79
+ "name": "disabled",
80
+ "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.",
81
+ "value": {
82
+ "type": [
83
+ "boolean"
84
+ ]
85
+ }
86
+ },
87
+ {
88
+ "name": "selected",
89
+ "description": "The index of the item selected in the items array.\nNote: Not updated when used in `multiple` selection mode.",
90
+ "value": {
91
+ "type": [
92
+ "number"
93
+ ]
94
+ }
95
+ },
96
+ {
97
+ "name": "theme",
98
+ "description": "The theme variants to apply to the component.",
99
+ "value": {
100
+ "type": [
101
+ "string"
102
+ ]
103
+ }
104
+ }
105
+ ],
106
+ "js": {
107
+ "properties": [
108
+ {
109
+ "name": "disabled",
110
+ "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.",
111
+ "value": {
112
+ "type": [
113
+ "boolean"
114
+ ]
115
+ }
116
+ },
117
+ {
118
+ "name": "selected",
119
+ "description": "The index of the item selected in the items array.\nNote: Not updated when used in `multiple` selection mode.",
120
+ "value": {
121
+ "type": [
122
+ "number"
123
+ ]
124
+ }
125
+ }
126
+ ],
127
+ "events": []
128
+ }
129
+ },
9
130
  {
10
131
  "name": "vaadin-context-menu",
11
- "description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\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>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha6/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha6/#/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.",
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-alpha8/#/elements/vaadin-context-menu-item) - an item element.\n- [`<vaadin-context-menu-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-alpha8/#/elements/vaadin-context-menu-list-box) - a list-box element.",
12
133
  "attributes": [
13
134
  {
14
135
  "name": "close-on",
@@ -51,9 +172,7 @@
51
172
  "description": "The theme variants to apply to the component.",
52
173
  "value": {
53
174
  "type": [
54
- "string",
55
- "null",
56
- "undefined"
175
+ "string"
57
176
  ]
58
177
  }
59
178
  }
@@ -74,7 +193,7 @@
74
193
  "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```",
75
194
  "value": {
76
195
  "type": [
77
- "Array<ContextMenuItem>",
196
+ "Array<ContextMenuItemData>",
78
197
  "undefined"
79
198
  ]
80
199
  }