@vaadin/context-menu 22.0.0-alpha7
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/LICENSE +190 -0
- package/README.md +85 -0
- package/package.json +52 -0
- package/src/interfaces.d.ts +43 -0
- package/src/vaadin-context-menu-overlay.js +113 -0
- package/src/vaadin-context-menu.d.ts +281 -0
- package/src/vaadin-context-menu.js +733 -0
- package/src/vaadin-contextmenu-event.js +103 -0
- package/src/vaadin-contextmenu-items-mixin.d.ts +74 -0
- package/src/vaadin-contextmenu-items-mixin.js +397 -0
- package/src/vaadin-device-detector.js +68 -0
- package/theme/lumo/vaadin-context-menu-styles.js +127 -0
- package/theme/lumo/vaadin-context-menu.js +4 -0
- package/theme/material/vaadin-context-menu-styles.js +82 -0
- package/theme/material/vaadin-context-menu.js +4 -0
- package/vaadin-context-menu.d.ts +2 -0
- package/vaadin-context-menu.js +2 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
|
+
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
3
|
+
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
4
|
+
import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
|
|
5
|
+
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
6
|
+
import '@vaadin/vaadin-lumo-styles/color.js';
|
|
7
|
+
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
8
|
+
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
9
|
+
|
|
10
|
+
const contextMenuOverlay = css`
|
|
11
|
+
:host([phone]) {
|
|
12
|
+
top: 0 !important;
|
|
13
|
+
right: 0 !important;
|
|
14
|
+
bottom: var(--vaadin-overlay-viewport-bottom) !important;
|
|
15
|
+
left: 0 !important;
|
|
16
|
+
align-items: stretch;
|
|
17
|
+
justify-content: flex-end;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* TODO These style overrides should not be needed.
|
|
21
|
+
We should instead offer a way to have non-selectable items inside the context menu. */
|
|
22
|
+
|
|
23
|
+
:host {
|
|
24
|
+
--_lumo-list-box-item-selected-icon-display: none;
|
|
25
|
+
--_lumo-list-box-item-padding-left: calc(var(--lumo-space-m) + var(--lumo-border-radius-m) / 4);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[part='overlay'] {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
|
|
34
|
+
moduleId: 'lumo-context-menu-overlay'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
registerStyles(
|
|
38
|
+
'vaadin-context-menu-list-box',
|
|
39
|
+
css`
|
|
40
|
+
:host(.vaadin-menu-list-box) {
|
|
41
|
+
--_lumo-list-box-item-selected-icon-display: block;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Normal item */
|
|
45
|
+
[part='items'] ::slotted(.vaadin-menu-item) {
|
|
46
|
+
-webkit-tap-highlight-color: var(--lumo-primary-color-10pct);
|
|
47
|
+
cursor: default;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[part='items'] ::slotted(.vaadin-menu-item) {
|
|
51
|
+
outline: none;
|
|
52
|
+
border-radius: var(--lumo-border-radius-m);
|
|
53
|
+
padding-left: var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
54
|
+
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host(.vaadin-menu-list-box) [part='items'] ::slotted(.vaadin-menu-item) {
|
|
58
|
+
padding-left: calc(var(--lumo-border-radius-m) / 4);
|
|
59
|
+
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Hovered item */
|
|
63
|
+
/* TODO a workaround until we have "focus-follows-mouse". After that, use the hover style for focus-ring as well */
|
|
64
|
+
[part='items'] ::slotted(.vaadin-menu-item:hover:not([disabled])),
|
|
65
|
+
[part='items'] ::slotted(.vaadin-menu-item[expanded]:not([disabled])) {
|
|
66
|
+
background-color: var(--lumo-primary-color-10pct);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* RTL styles */
|
|
70
|
+
:host([dir='rtl'])[part='items'] ::slotted(.vaadin-menu-item) {
|
|
71
|
+
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
72
|
+
padding-right: var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:host([dir='rtl'].vaadin-menu-list-box) [part='items'] ::slotted(.vaadin-menu-item) {
|
|
76
|
+
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
77
|
+
padding-right: calc(var(--lumo-border-radius-m) / 4);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Focused item */
|
|
81
|
+
@media (pointer: coarse) {
|
|
82
|
+
[part='items'] ::slotted(.vaadin-menu-item:hover:not([expanded]):not([disabled])) {
|
|
83
|
+
background-color: transparent;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`,
|
|
87
|
+
{ moduleId: 'lumo-context-menu-list-box' }
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
registerStyles(
|
|
91
|
+
'vaadin-context-menu-item',
|
|
92
|
+
css`
|
|
93
|
+
:host {
|
|
94
|
+
user-select: none;
|
|
95
|
+
-ms-user-select: none;
|
|
96
|
+
-webkit-user-select: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host(.vaadin-menu-item[menu-item-checked])::before {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host(.vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
104
|
+
font-family: lumo-icons;
|
|
105
|
+
font-size: var(--lumo-icon-size-xs);
|
|
106
|
+
content: var(--lumo-icons-angle-right);
|
|
107
|
+
color: var(--lumo-tertiary-text-color);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host(:not([dir='rtl']).vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
111
|
+
margin-right: calc(var(--lumo-space-m) * -1);
|
|
112
|
+
padding-left: var(--lumo-space-m);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host([expanded]) {
|
|
116
|
+
background-color: var(--lumo-primary-color-10pct);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* RTL styles */
|
|
120
|
+
:host([dir='rtl'].vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
121
|
+
content: var(--lumo-icons-angle-left);
|
|
122
|
+
margin-left: calc(var(--lumo-space-m) * -1);
|
|
123
|
+
padding-right: var(--lumo-space-m);
|
|
124
|
+
}
|
|
125
|
+
`,
|
|
126
|
+
{ moduleId: 'lumo-context-menu-item' }
|
|
127
|
+
);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
|
+
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
3
|
+
import '@vaadin/vaadin-material-styles/color.js';
|
|
4
|
+
import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
|
|
5
|
+
import '@vaadin/vaadin-material-styles/typography.js';
|
|
6
|
+
|
|
7
|
+
const contextMenuOverlay = css`
|
|
8
|
+
[part='overlay'] {
|
|
9
|
+
outline: none;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
|
|
14
|
+
moduleId: 'material-context-menu-overlay'
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
registerStyles(
|
|
18
|
+
'vaadin-context-menu-list-box',
|
|
19
|
+
css`
|
|
20
|
+
[part='items'] ::slotted(.vaadin-menu-item:not(hr)) {
|
|
21
|
+
min-height: 36px;
|
|
22
|
+
padding: 8px 32px 8px 10px;
|
|
23
|
+
font-size: var(--material-small-font-size);
|
|
24
|
+
line-height: 24px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([dir='rtl']) [part='items'] ::slotted(.vaadin-menu-item:not(hr)) {
|
|
28
|
+
padding: 8px 10px 8px 32px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part='items'] ::slotted(.vaadin-menu-item:hover:not([disabled])) {
|
|
32
|
+
background-color: var(--material-secondary-background-color);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[part='items'] ::slotted(.vaadin-menu-item[focused]:not([disabled])) {
|
|
36
|
+
background-color: var(--material-divider-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@media (pointer: coarse) {
|
|
40
|
+
[part='items'] ::slotted(.vaadin-menu-item:hover:not([disabled])),
|
|
41
|
+
[part='items'] ::slotted(.vaadin-menu-item[focused]:not([disabled])) {
|
|
42
|
+
background-color: transparent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`,
|
|
46
|
+
{ moduleId: 'material-context-menu-list-box' }
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
registerStyles(
|
|
50
|
+
'vaadin-context-menu-item',
|
|
51
|
+
css`
|
|
52
|
+
:host(.vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
53
|
+
font-family: material-icons;
|
|
54
|
+
font-size: var(--material-icon-font-size);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host(:not([dir='rtl']).vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
58
|
+
content: var(--material-icons-chevron-right);
|
|
59
|
+
padding-left: 9px;
|
|
60
|
+
margin-right: -9px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host([dir='rtl'].vaadin-menu-item.vaadin-context-menu-parent-item)::after {
|
|
64
|
+
content: var(--material-icons-chevron-left);
|
|
65
|
+
padding-right: 9px;
|
|
66
|
+
margin-left: -9px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:host(.vaadin-menu-item)::before {
|
|
70
|
+
display: block;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host(.vaadin-menu-item[menu-item-checked])::before {
|
|
74
|
+
content: var(--material-icons-check);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:host([expanded]) {
|
|
78
|
+
background-color: var(--material-secondary-background-color);
|
|
79
|
+
}
|
|
80
|
+
`,
|
|
81
|
+
{ moduleId: 'material-context-menu-item' }
|
|
82
|
+
);
|