@vaadin/context-menu 24.8.0-alpha8 → 25.0.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -23
- package/package.json +13 -16
- package/src/vaadin-context-menu-item.js +17 -12
- package/src/vaadin-context-menu-list-box.d.ts +1 -2
- package/src/vaadin-context-menu-list-box.js +27 -23
- package/src/vaadin-context-menu-overlay.js +13 -9
- package/src/vaadin-context-menu.js +18 -29
- package/src/vaadin-contextmenu-items-mixin.js +3 -2
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
- package/src/vaadin-lit-context-menu-item.js +0 -60
- package/src/vaadin-lit-context-menu-list-box.js +0 -87
- package/src/vaadin-lit-context-menu-overlay.js +0 -51
- package/src/vaadin-lit-context-menu.js +0 -79
- package/theme/lumo/vaadin-lit-context-menu.d.ts +0 -4
- package/theme/lumo/vaadin-lit-context-menu.js +0 -4
- package/theme/material/vaadin-context-menu-item-styles.d.ts +0 -5
- package/theme/material/vaadin-context-menu-item-styles.js +0 -36
- package/theme/material/vaadin-context-menu-list-box-styles.d.ts +0 -4
- package/theme/material/vaadin-context-menu-list-box-styles.js +0 -38
- package/theme/material/vaadin-context-menu-overlay-styles.d.ts +0 -2
- package/theme/material/vaadin-context-menu-overlay-styles.js +0 -15
- package/theme/material/vaadin-context-menu.d.ts +0 -4
- package/theme/material/vaadin-context-menu.js +0 -4
- package/theme/material/vaadin-lit-context-menu.d.ts +0 -4
- package/theme/material/vaadin-lit-context-menu.js +0 -4
- package/vaadin-lit-context-menu.d.ts +0 -1
- package/vaadin-lit-context-menu.js +0 -2
package/README.md
CHANGED
|
@@ -50,29 +50,6 @@ Once installed, import the component in your application:
|
|
|
50
50
|
import '@vaadin/context-menu';
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
## Themes
|
|
54
|
-
|
|
55
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
56
|
-
The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/context-menu/vaadin-context-menu.js) of the package uses the Lumo theme.
|
|
57
|
-
|
|
58
|
-
To use the Material theme, import the component from the `theme/material` folder:
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
import '@vaadin/context-menu/theme/material/vaadin-context-menu.js';
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
You can also import the Lumo version of the component explicitly:
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
import '@vaadin/context-menu/theme/lumo/vaadin-context-menu.js';
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
71
|
-
|
|
72
|
-
```js
|
|
73
|
-
import '@vaadin/context-menu/src/vaadin-context-menu.js';
|
|
74
|
-
```
|
|
75
|
-
|
|
76
53
|
## License
|
|
77
54
|
|
|
78
55
|
Apache License 2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/context-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,26 +33,23 @@
|
|
|
33
33
|
"Vaadin",
|
|
34
34
|
"context menu",
|
|
35
35
|
"web-components",
|
|
36
|
-
"web-component"
|
|
37
|
-
"polymer"
|
|
36
|
+
"web-component"
|
|
38
37
|
],
|
|
39
38
|
"dependencies": {
|
|
40
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
41
|
-
"@
|
|
42
|
-
"@vaadin/
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/
|
|
45
|
-
"@vaadin/
|
|
46
|
-
"@vaadin/
|
|
47
|
-
"@vaadin/
|
|
48
|
-
"@vaadin/vaadin-
|
|
49
|
-
"@vaadin/vaadin-material-styles": "24.8.0-alpha8",
|
|
50
|
-
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha8",
|
|
40
|
+
"@vaadin/a11y-base": "25.0.0-alpha1",
|
|
41
|
+
"@vaadin/component-base": "25.0.0-alpha1",
|
|
42
|
+
"@vaadin/item": "25.0.0-alpha1",
|
|
43
|
+
"@vaadin/list-box": "25.0.0-alpha1",
|
|
44
|
+
"@vaadin/lit-renderer": "25.0.0-alpha1",
|
|
45
|
+
"@vaadin/overlay": "25.0.0-alpha1",
|
|
46
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha1",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha1",
|
|
51
48
|
"lit": "^3.0.0"
|
|
52
49
|
},
|
|
53
50
|
"devDependencies": {
|
|
54
|
-
"@vaadin/chai-plugins": "
|
|
55
|
-
"@vaadin/test-runner-commands": "
|
|
51
|
+
"@vaadin/chai-plugins": "25.0.0-alpha1",
|
|
52
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha1",
|
|
56
53
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
57
54
|
"sinon": "^18.0.0"
|
|
58
55
|
},
|
|
@@ -60,5 +57,5 @@
|
|
|
60
57
|
"web-types.json",
|
|
61
58
|
"web-types.lit.json"
|
|
62
59
|
],
|
|
63
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "b8c22a4a0c64156210d0daac96b43ae4e5526d49"
|
|
64
61
|
}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
10
|
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
10
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
12
|
|
|
@@ -19,22 +20,26 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
19
20
|
* @mixes ThemableMixin
|
|
20
21
|
* @protected
|
|
21
22
|
*/
|
|
22
|
-
class ContextMenuItem extends ItemMixin(ThemableMixin(DirMixin(
|
|
23
|
+
class ContextMenuItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
23
24
|
static get is() {
|
|
24
25
|
return 'vaadin-context-menu-item';
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
static get
|
|
28
|
+
static get styles() {
|
|
29
|
+
return css`
|
|
30
|
+
:host {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([hidden]) {
|
|
35
|
+
display: none !important;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @protected */
|
|
41
|
+
render() {
|
|
28
42
|
return html`
|
|
29
|
-
<style>
|
|
30
|
-
:host {
|
|
31
|
-
display: inline-block;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host([hidden]) {
|
|
35
|
-
display: none !important;
|
|
36
|
-
}
|
|
37
|
-
</style>
|
|
38
43
|
<span part="checkmark" aria-hidden="true"></span>
|
|
39
44
|
<div part="content">
|
|
40
45
|
<slot></slot>
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
7
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
7
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
13
12
|
*/
|
|
14
|
-
declare class ContextMenuListBox extends ListMixin(DirMixin(ThemableMixin(
|
|
13
|
+
declare class ContextMenuListBox extends ListMixin(DirMixin(ThemableMixin(HTMLElement))) {}
|
|
15
14
|
|
|
16
15
|
declare global {
|
|
17
16
|
interface HTMLElementTagNameMap {
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
7
|
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
8
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
8
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
9
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,38 +15,32 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
15
15
|
*
|
|
16
16
|
* @customElement
|
|
17
17
|
* @extends HTMLElement
|
|
18
|
-
* @mixes ControllerMixin
|
|
19
18
|
* @mixes DirMixin
|
|
20
19
|
* @mixes ListMixin
|
|
21
20
|
* @mixes ThemableMixin
|
|
22
21
|
* @protected
|
|
23
22
|
*/
|
|
24
|
-
class ContextMenuListBox extends ListMixin(ThemableMixin(DirMixin(
|
|
23
|
+
class ContextMenuListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
25
24
|
static get is() {
|
|
26
25
|
return 'vaadin-context-menu-list-box';
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
static get
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
}
|
|
28
|
+
static get styles() {
|
|
29
|
+
return css`
|
|
30
|
+
:host {
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
:host([hidden]) {
|
|
35
|
+
display: none !important;
|
|
36
|
+
}
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</style>
|
|
47
|
-
<div part="items">
|
|
48
|
-
<slot></slot>
|
|
49
|
-
</div>
|
|
38
|
+
[part='items'] {
|
|
39
|
+
height: 100%;
|
|
40
|
+
width: 100%;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
-webkit-overflow-scrolling: touch;
|
|
43
|
+
}
|
|
50
44
|
`;
|
|
51
45
|
}
|
|
52
46
|
|
|
@@ -56,6 +50,7 @@ class ContextMenuListBox extends ListMixin(ThemableMixin(DirMixin(ControllerMixi
|
|
|
56
50
|
// but we don't want it to be modified, or be shown in the API docs.
|
|
57
51
|
/** @private */
|
|
58
52
|
orientation: {
|
|
53
|
+
type: String,
|
|
59
54
|
readOnly: true,
|
|
60
55
|
},
|
|
61
56
|
};
|
|
@@ -70,6 +65,15 @@ class ContextMenuListBox extends ListMixin(ThemableMixin(DirMixin(ControllerMixi
|
|
|
70
65
|
return this.shadowRoot.querySelector('[part="items"]');
|
|
71
66
|
}
|
|
72
67
|
|
|
68
|
+
/** @protected */
|
|
69
|
+
render() {
|
|
70
|
+
return html`
|
|
71
|
+
<div part="items">
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
|
|
73
77
|
/** @protected */
|
|
74
78
|
ready() {
|
|
75
79
|
super.ready();
|
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
10
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
10
11
|
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
11
|
-
import {
|
|
12
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
13
|
import { MenuOverlayMixin } from './vaadin-menu-overlay-mixin.js';
|
|
13
14
|
import { styles } from './vaadin-menu-overlay-styles.js';
|
|
14
15
|
|
|
15
|
-
registerStyles('vaadin-context-menu-overlay', [overlayStyles, styles], {
|
|
16
|
-
moduleId: 'vaadin-context-menu-overlay-styles',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
16
|
/**
|
|
20
17
|
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
21
18
|
*
|
|
@@ -27,14 +24,21 @@ registerStyles('vaadin-context-menu-overlay', [overlayStyles, styles], {
|
|
|
27
24
|
* @mixes ThemableMixin
|
|
28
25
|
* @protected
|
|
29
26
|
*/
|
|
30
|
-
export class ContextMenuOverlay extends MenuOverlayMixin(
|
|
27
|
+
export class ContextMenuOverlay extends MenuOverlayMixin(
|
|
28
|
+
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
29
|
+
) {
|
|
31
30
|
static get is() {
|
|
32
31
|
return 'vaadin-context-menu-overlay';
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
static get
|
|
34
|
+
static get styles() {
|
|
35
|
+
return [overlayStyles, styles];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @protected */
|
|
39
|
+
render() {
|
|
36
40
|
return html`
|
|
37
|
-
<div id="backdrop" part="backdrop" hidden
|
|
41
|
+
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
38
42
|
<div part="overlay" id="overlay" tabindex="0">
|
|
39
43
|
<div part="content" id="content">
|
|
40
44
|
<slot></slot>
|
|
@@ -7,12 +7,11 @@ import './vaadin-contextmenu-event.js';
|
|
|
7
7
|
import './vaadin-context-menu-item.js';
|
|
8
8
|
import './vaadin-context-menu-list-box.js';
|
|
9
9
|
import './vaadin-context-menu-overlay.js';
|
|
10
|
-
import { html,
|
|
11
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
|
+
import { css, html, LitElement } from 'lit';
|
|
12
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
12
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
13
|
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
15
|
-
import {
|
|
14
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
16
15
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
17
16
|
import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
|
|
18
17
|
|
|
@@ -209,49 +208,39 @@ import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
|
|
|
209
208
|
* @extends HTMLElement
|
|
210
209
|
* @mixes ElementMixin
|
|
211
210
|
* @mixes ContextMenuMixin
|
|
212
|
-
* @mixes ControllerMixin
|
|
213
211
|
* @mixes OverlayClassMixin
|
|
214
212
|
* @mixes ThemePropertyMixin
|
|
215
213
|
*/
|
|
216
214
|
class ContextMenu extends ContextMenuMixin(
|
|
217
|
-
OverlayClassMixin(
|
|
215
|
+
OverlayClassMixin(ElementMixin(ThemePropertyMixin(PolylitMixin(LitElement)))),
|
|
218
216
|
) {
|
|
219
|
-
static get
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
:host {
|
|
223
|
-
display: block;
|
|
224
|
-
}
|
|
217
|
+
static get is() {
|
|
218
|
+
return 'vaadin-context-menu';
|
|
219
|
+
}
|
|
225
220
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
static get styles() {
|
|
222
|
+
return css`
|
|
223
|
+
:host {
|
|
224
|
+
display: block;
|
|
225
|
+
}
|
|
230
226
|
|
|
231
|
-
|
|
227
|
+
:host([hidden]) {
|
|
228
|
+
display: none !important;
|
|
229
|
+
}
|
|
232
230
|
`;
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
static get is() {
|
|
236
|
-
return 'vaadin-context-menu';
|
|
237
|
-
}
|
|
238
|
-
|
|
239
233
|
/** @protected */
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
processTemplates(this);
|
|
234
|
+
render() {
|
|
235
|
+
return html`<slot id="slot"></slot>`;
|
|
244
236
|
}
|
|
245
237
|
|
|
246
238
|
/**
|
|
247
|
-
* @param {DocumentFragment} dom
|
|
248
|
-
* @return {null}
|
|
249
239
|
* @protected
|
|
250
240
|
* @override
|
|
251
241
|
*/
|
|
252
|
-
|
|
253
|
-
const root =
|
|
254
|
-
root.appendChild(dom);
|
|
242
|
+
createRenderRoot() {
|
|
243
|
+
const root = super.createRenderRoot();
|
|
255
244
|
root.appendChild(this._overlayElement);
|
|
256
245
|
return root;
|
|
257
246
|
}
|
|
@@ -268,8 +268,9 @@ export const ItemsMixin = (superClass) =>
|
|
|
268
268
|
// Close the menu
|
|
269
269
|
this.close();
|
|
270
270
|
this.listenOn.focus();
|
|
271
|
-
} else if (key === 'Tab') {
|
|
272
|
-
// Close all menus
|
|
271
|
+
} else if (key === 'Tab' && !event.defaultPrevented) {
|
|
272
|
+
// Close all menus unless the Tab key was handled separately
|
|
273
|
+
// which is the case e.g. in menu-bar with Tab navigation.
|
|
273
274
|
this.dispatchEvent(new CustomEvent('close-all-menus'));
|
|
274
275
|
}
|
|
275
276
|
});
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/context-menu",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-context-menu",
|
|
11
|
-
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\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### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### `vaadin-contextmenu` Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\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### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### `vaadin-contextmenu` Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay)\ndocumentation for `<vaadin-context-menu-overlay>` stylable parts.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nWhen using `items` API, in addition `<vaadin-context-menu-overlay>`, the following\ninternal components are themable:\n\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/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.0.0-alpha1/#/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.\n\nNote: the `theme` attribute value set on `<vaadin-context-menu>` is\npropagated to the internal components listed above.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "selector",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/context-menu",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-context-menu",
|
|
19
|
-
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\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### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### `vaadin-contextmenu` Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
19
|
+
"description": "`<vaadin-context-menu>` is a Web Component for creating context menus.\n\n### Items\n\nItems is a higher level convenience API for defining a (hierarchical) menu structure for the component.\nIf a menu item has a non-empty `children` set, a sub-menu with the child items is opened\nnext to the parent menu on mouseover, tap or a right arrow keypress.\n\nWhen an item is selected, `<vaadin-context-menu>` dispatches an \"item-selected\" event\nwith the selected item as `event.detail.value` property.\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### Rendering\n\nThe content of the menu can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `contextMenu`, `model` arguments when applicable.\nGenerate DOM content by using `model` object properties if needed, append it to the `root`\nelement and control the state of the host element by accessing `contextMenu`. Before generating\nnew content, the renderer function should check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-context-menu id=\"contextMenu\">\n <p>This paragraph has a context menu.</p>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'Content of the selector: ' + context.target.textContent;\n};\n```\n\nYou can access the menu context inside the renderer using\n`context.target` and `context.detail`.\n\nRenderer is called on the opening of the context-menu and each time the related context is updated.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### `vaadin-contextmenu` Gesture Event\n\n`vaadin-contextmenu` is a gesture event (a custom event),\nwhich is dispatched after either `contextmenu` or long touch events.\nThis enables support for both mouse and touch environments in a uniform way.\n\n`<vaadin-context-menu>` opens the menu overlay on the `vaadin-contextmenu`\nevent by default.\n\n### Menu Listener\n\nBy default, the `<vaadin-context-menu>` element listens for the menu opening\nevent on itself. In case if you do not want to wrap the target, you can listen for\nevents on an element outside the `<vaadin-context-menu>` by setting the\n`listenOn` property:\n\n```html\n<vaadin-context-menu id=\"contextMenu\"></vaadin-context-menu>\n\n<div id=\"menuListener\">The element that listens for the contextmenu event.</div>\n```\n```javascript\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.listenOn = document.querySelector('#menuListener');\n```\n\n### Filtering Menu Targets\n\nBy default, the listener element and all its descendants open the context\nmenu. You can filter the menu targets to a smaller set of elements inside\nthe listener element by setting the `selector` property.\n\nIn the following example, only the elements matching `.has-menu` will open the context menu:\n\n```html\n<vaadin-context-menu selector=\".has-menu\">\n <p class=\"has-menu\">This paragraph opens the context menu</p>\n <p>This paragraph does not open the context menu</p>\n</vaadin-context-menu>\n```\n\n### Menu Context\n\nThe following properties are available in the `context` argument:\n\n- `target` is the menu opening event target, which is the element that\nthe user has called the context menu for\n- `detail` is the menu opening event detail\n\nIn the following example, the menu item text is composed with the contents\nof the element that opened the menu:\n\n```html\n<vaadin-context-menu selector=\"li\" id=\"contextMenu\">\n <ul>\n <li>Foo</li>\n <li>Bar</li>\n <li>Baz</li>\n </ul>\n</vaadin-context-menu>\n```\n```js\nconst contextMenu = document.querySelector('#contextMenu');\ncontextMenu.renderer = (root, contextMenu, context) => {\n let listBox = root.firstElementChild;\n if (!listBox) {\n listBox = document.createElement('vaadin-list-box');\n root.appendChild(listBox);\n }\n\n let item = listBox.querySelector('vaadin-item');\n if (!item) {\n item = document.createElement('vaadin-item');\n listBox.appendChild(item);\n }\n item.textContent = 'The menu target: ' + context.target.textContent;\n};\n```\n\n### Styling\n\n`<vaadin-context-menu>` uses `<vaadin-context-menu-overlay>` internal\nthemable component as the actual visible context menu overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay)\ndocumentation for `<vaadin-context-menu-overlay>` stylable parts.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nWhen using `items` API, in addition `<vaadin-context-menu-overlay>`, the following\ninternal components are themable:\n\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/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.0.0-alpha1/#/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.\n\nNote: the `theme` attribute value set on `<vaadin-context-menu>` is\npropagated to the internal components listed above.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { css, html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
11
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @customElement
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes DirMixin
|
|
19
|
-
* @mixes ItemMixin
|
|
20
|
-
* @mixes ThemableMixin
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
class ContextMenuItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
-
static get is() {
|
|
25
|
-
return 'vaadin-context-menu-item';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return css`
|
|
30
|
-
:host {
|
|
31
|
-
display: inline-block;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host([hidden]) {
|
|
35
|
-
display: none !important;
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** @protected */
|
|
41
|
-
render() {
|
|
42
|
-
return html`
|
|
43
|
-
<span part="checkmark" aria-hidden="true"></span>
|
|
44
|
-
<div part="content">
|
|
45
|
-
<slot></slot>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @protected */
|
|
51
|
-
ready() {
|
|
52
|
-
super.ready();
|
|
53
|
-
|
|
54
|
-
this.setAttribute('role', 'menuitem');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
defineCustomElement(ContextMenuItem);
|
|
59
|
-
|
|
60
|
-
export { ContextMenuItem };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { css, html, LitElement } from 'lit';
|
|
7
|
-
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
8
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @customElement
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes DirMixin
|
|
19
|
-
* @mixes ListMixin
|
|
20
|
-
* @mixes ThemableMixin
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
class ContextMenuListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
-
static get is() {
|
|
25
|
-
return 'vaadin-context-menu-list-box';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return css`
|
|
30
|
-
:host {
|
|
31
|
-
display: flex;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host([hidden]) {
|
|
35
|
-
display: none !important;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
[part='items'] {
|
|
39
|
-
height: 100%;
|
|
40
|
-
width: 100%;
|
|
41
|
-
overflow-y: auto;
|
|
42
|
-
-webkit-overflow-scrolling: touch;
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static get properties() {
|
|
48
|
-
return {
|
|
49
|
-
// We don't need to define this property since super default is vertical,
|
|
50
|
-
// but we don't want it to be modified, or be shown in the API docs.
|
|
51
|
-
/** @private */
|
|
52
|
-
orientation: {
|
|
53
|
-
type: String,
|
|
54
|
-
readOnly: true,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @return {!HTMLElement}
|
|
61
|
-
* @protected
|
|
62
|
-
* @override
|
|
63
|
-
*/
|
|
64
|
-
get _scrollerElement() {
|
|
65
|
-
return this.shadowRoot.querySelector('[part="items"]');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** @protected */
|
|
69
|
-
render() {
|
|
70
|
-
return html`
|
|
71
|
-
<div part="items">
|
|
72
|
-
<slot></slot>
|
|
73
|
-
</div>
|
|
74
|
-
`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** @protected */
|
|
78
|
-
ready() {
|
|
79
|
-
super.ready();
|
|
80
|
-
|
|
81
|
-
this.setAttribute('role', 'menu');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
defineCustomElement(ContextMenuListBox);
|
|
86
|
-
|
|
87
|
-
export { ContextMenuListBox };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
11
|
-
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
12
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
-
import { MenuOverlayMixin } from './vaadin-menu-overlay-mixin.js';
|
|
14
|
-
import { styles } from './vaadin-menu-overlay-styles.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* An element used internally by `<vaadin-context-menu>`. Not intended to be used separately.
|
|
18
|
-
*
|
|
19
|
-
* @customElement
|
|
20
|
-
* @extends HTMLElement
|
|
21
|
-
* @mixes DirMixin
|
|
22
|
-
* @mixes MenuOverlayMixin
|
|
23
|
-
* @mixes OverlayMixin
|
|
24
|
-
* @mixes ThemableMixin
|
|
25
|
-
* @protected
|
|
26
|
-
*/
|
|
27
|
-
export class ContextMenuOverlay extends MenuOverlayMixin(
|
|
28
|
-
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
|
|
29
|
-
) {
|
|
30
|
-
static get is() {
|
|
31
|
-
return 'vaadin-context-menu-overlay';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static get styles() {
|
|
35
|
-
return [overlayStyles, styles];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @protected */
|
|
39
|
-
render() {
|
|
40
|
-
return html`
|
|
41
|
-
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
42
|
-
<div part="overlay" id="overlay" tabindex="0">
|
|
43
|
-
<div part="content" id="content">
|
|
44
|
-
<slot></slot>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
defineCustomElement(ContextMenuOverlay);
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import './vaadin-contextmenu-event.js';
|
|
7
|
-
import './vaadin-lit-context-menu-item.js';
|
|
8
|
-
import './vaadin-lit-context-menu-list-box.js';
|
|
9
|
-
import './vaadin-lit-context-menu-overlay.js';
|
|
10
|
-
import { css, html, LitElement } from 'lit';
|
|
11
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
13
|
-
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
14
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
15
|
-
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
16
|
-
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
17
|
-
import { ContextMenuMixin } from './vaadin-context-menu-mixin.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* LitElement based version of `<vaadin-context-menu>` web component.
|
|
21
|
-
*
|
|
22
|
-
* ## Disclaimer
|
|
23
|
-
*
|
|
24
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
25
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
26
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
27
|
-
*/
|
|
28
|
-
class ContextMenu extends ContextMenuMixin(
|
|
29
|
-
OverlayClassMixin(ElementMixin(ThemePropertyMixin(PolylitMixin(LitElement)))),
|
|
30
|
-
) {
|
|
31
|
-
static get is() {
|
|
32
|
-
return 'vaadin-context-menu';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static get styles() {
|
|
36
|
-
return css`
|
|
37
|
-
:host {
|
|
38
|
-
display: block;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:host([hidden]) {
|
|
42
|
-
display: none !important;
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** @protected */
|
|
48
|
-
render() {
|
|
49
|
-
return html`<slot id="slot"></slot>`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @protected */
|
|
53
|
-
ready() {
|
|
54
|
-
super.ready();
|
|
55
|
-
|
|
56
|
-
processTemplates(this);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @protected
|
|
61
|
-
* @override
|
|
62
|
-
*/
|
|
63
|
-
createRenderRoot() {
|
|
64
|
-
const root = super.createRenderRoot();
|
|
65
|
-
root.appendChild(this._overlayElement);
|
|
66
|
-
return root;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Fired when an item is selected when the context menu is populated using the `items` API.
|
|
71
|
-
*
|
|
72
|
-
* @event item-selected
|
|
73
|
-
* @param {Object} detail
|
|
74
|
-
* @param {Object} detail.value the selected menu item
|
|
75
|
-
*/
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
defineCustomElement(ContextMenu);
|
|
79
|
-
export { ContextMenu };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
2
|
-
import '@vaadin/vaadin-material-styles/color.js';
|
|
3
|
-
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
|
-
import { item } from '@vaadin/item/theme/material/vaadin-item-styles.js';
|
|
5
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
6
|
-
|
|
7
|
-
const contextMenuItem = css`
|
|
8
|
-
:host([aria-haspopup='true'])::after {
|
|
9
|
-
font-family: material-icons;
|
|
10
|
-
font-size: var(--material-icon-font-size);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
:host(:not([dir='rtl'])[aria-haspopup='true'])::after {
|
|
14
|
-
content: var(--material-icons-chevron-right);
|
|
15
|
-
padding-left: 9px;
|
|
16
|
-
margin-right: -9px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:host([dir='rtl'][aria-haspopup='true'])::after {
|
|
20
|
-
content: var(--material-icons-chevron-left);
|
|
21
|
-
padding-right: 9px;
|
|
22
|
-
margin-left: -9px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host([menu-item-checked]) [part='checkmark']::before {
|
|
26
|
-
content: var(--material-icons-check);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
:host([expanded]) {
|
|
30
|
-
background-color: var(--material-secondary-background-color);
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
registerStyles('vaadin-context-menu-item', [item, contextMenuItem], { moduleId: 'material-context-menu-item' });
|
|
35
|
-
|
|
36
|
-
export { contextMenuItem };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import '@vaadin/vaadin-material-styles/color.js';
|
|
2
|
-
import '@vaadin/vaadin-material-styles/typography.js';
|
|
3
|
-
import { listBox } from '@vaadin/list-box/theme/material/vaadin-list-box-styles.js';
|
|
4
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
|
-
|
|
6
|
-
const contextMenuListBox = css`
|
|
7
|
-
[part='items'] ::slotted([role='menuitem']) {
|
|
8
|
-
min-height: 36px;
|
|
9
|
-
padding: 8px 32px 8px 10px;
|
|
10
|
-
font-size: var(--material-small-font-size);
|
|
11
|
-
line-height: 24px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:host([dir='rtl']) [part='items'] ::slotted([role='menuitem']) {
|
|
15
|
-
padding: 8px 10px 8px 32px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])) {
|
|
19
|
-
background-color: var(--material-secondary-background-color);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) {
|
|
23
|
-
background-color: var(--material-divider-color);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media (pointer: coarse) {
|
|
27
|
-
[part='items'] ::slotted([role='menuitem']:hover:not([disabled])),
|
|
28
|
-
[part='items'] ::slotted([role='menuitem'][focused]:not([disabled])) {
|
|
29
|
-
background-color: transparent;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
registerStyles('vaadin-context-menu-list-box', [listBox, contextMenuListBox], {
|
|
35
|
-
moduleId: 'material-context-menu-list-box',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export { contextMenuListBox };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
|
|
2
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
3
|
-
|
|
4
|
-
const contextMenuOverlay = css`
|
|
5
|
-
[part='overlay'] {
|
|
6
|
-
outline: none;
|
|
7
|
-
will-change: transform, opacity;
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
|
|
12
|
-
moduleId: 'material-context-menu-overlay',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export { contextMenuOverlay };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/vaadin-context-menu.js';
|