@vaadin/context-menu 23.0.0-alpha5 → 23.0.0-beta4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/context-menu",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-beta4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,21 +34,20 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
|
-
"@polymer/iron-media-query": "^3.0.0",
|
|
38
37
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "23.0.0-
|
|
40
|
-
"@vaadin/item": "23.0.0-
|
|
41
|
-
"@vaadin/list-box": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
43
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
44
|
-
"@vaadin/vaadin-overlay": "23.0.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
38
|
+
"@vaadin/component-base": "23.0.0-beta4",
|
|
39
|
+
"@vaadin/item": "23.0.0-beta4",
|
|
40
|
+
"@vaadin/list-box": "23.0.0-beta4",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-beta4",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.0.0-beta4",
|
|
43
|
+
"@vaadin/vaadin-overlay": "23.0.0-beta4",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-beta4"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "23.0.0-
|
|
48
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-beta4",
|
|
50
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
50
|
"sinon": "^9.2.1"
|
|
52
51
|
},
|
|
53
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d0b447f1c31ca4256a5e26f2dcd27784447ff79b"
|
|
54
53
|
}
|
|
@@ -4,11 +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 './vaadin-contextmenu-event.js';
|
|
7
|
-
import './vaadin-device-detector.js';
|
|
8
7
|
import './vaadin-context-menu-overlay.js';
|
|
9
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
|
+
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
10
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
12
|
import { addListener, gestures, removeListener } from '@vaadin/component-base/src/gestures.js';
|
|
13
|
+
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
12
14
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
13
15
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
14
16
|
import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
@@ -196,10 +198,11 @@ import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
|
196
198
|
*
|
|
197
199
|
* @extends HTMLElement
|
|
198
200
|
* @mixes ElementMixin
|
|
201
|
+
* @mixes ControllerMixin
|
|
199
202
|
* @mixes ThemePropertyMixin
|
|
200
203
|
* @mixes ItemsMixin
|
|
201
204
|
*/
|
|
202
|
-
class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElement))) {
|
|
205
|
+
class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElement)))) {
|
|
203
206
|
static get template() {
|
|
204
207
|
return html`
|
|
205
208
|
<style>
|
|
@@ -214,8 +217,6 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElem
|
|
|
214
217
|
|
|
215
218
|
<slot id="slot"></slot>
|
|
216
219
|
|
|
217
|
-
<vaadin-device-detector phone="{{_phone}}" touch="{{_touch}}"></vaadin-device-detector>
|
|
218
|
-
|
|
219
220
|
<vaadin-context-menu-overlay
|
|
220
221
|
id="overlay"
|
|
221
222
|
on-opened-changed="_onOverlayOpened"
|
|
@@ -314,12 +315,36 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElem
|
|
|
314
315
|
_boundOpen: Object,
|
|
315
316
|
|
|
316
317
|
/** @private */
|
|
317
|
-
|
|
318
|
+
_phone: {
|
|
319
|
+
type: Boolean
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
/** @private */
|
|
323
|
+
_touch: {
|
|
324
|
+
type: Boolean,
|
|
325
|
+
value: isTouch
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
/** @private */
|
|
329
|
+
_wide: {
|
|
330
|
+
type: Boolean
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/** @private */
|
|
334
|
+
_wideMediaQuery: {
|
|
335
|
+
type: String,
|
|
336
|
+
value: '(min-device-width: 750px)'
|
|
337
|
+
}
|
|
318
338
|
};
|
|
319
339
|
}
|
|
320
340
|
|
|
321
341
|
static get observers() {
|
|
322
|
-
return [
|
|
342
|
+
return [
|
|
343
|
+
'_openedChanged(opened)',
|
|
344
|
+
'_targetOrOpenOnChanged(listenOn, openOn)',
|
|
345
|
+
'_rendererChanged(renderer, items)',
|
|
346
|
+
'_touchOrWideChanged(_touch, _wide)'
|
|
347
|
+
];
|
|
323
348
|
}
|
|
324
349
|
|
|
325
350
|
constructor() {
|
|
@@ -349,6 +374,12 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElem
|
|
|
349
374
|
ready() {
|
|
350
375
|
super.ready();
|
|
351
376
|
|
|
377
|
+
this.addController(
|
|
378
|
+
new MediaQueryController(this._wideMediaQuery, (matches) => {
|
|
379
|
+
this._wide = matches;
|
|
380
|
+
})
|
|
381
|
+
);
|
|
382
|
+
|
|
352
383
|
processTemplates(this);
|
|
353
384
|
}
|
|
354
385
|
|
|
@@ -392,6 +423,11 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElem
|
|
|
392
423
|
}
|
|
393
424
|
}
|
|
394
425
|
|
|
426
|
+
/** @private */
|
|
427
|
+
_touchOrWideChanged(touch, wide) {
|
|
428
|
+
this._phone = !wide && touch;
|
|
429
|
+
}
|
|
430
|
+
|
|
395
431
|
/** @private */
|
|
396
432
|
_setListenOnUserSelect(value) {
|
|
397
433
|
// note: these styles don't seem to work in Firefox on iOS.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { flush } from '@polymer/polymer/lib/utils/flush.js';
|
|
7
|
+
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
8
|
import { Item } from '@vaadin/item/src/vaadin-item.js';
|
|
8
9
|
import { ListBox } from '@vaadin/list-box/src/vaadin-list-box.js';
|
|
9
10
|
|
|
@@ -242,9 +243,11 @@ export const ItemsMixin = (superClass) =>
|
|
|
242
243
|
|
|
243
244
|
/** @protected */
|
|
244
245
|
_setMenuItemTheme(component, item, hostTheme) {
|
|
245
|
-
|
|
246
|
+
// Use existing component theme when it is provided
|
|
247
|
+
let theme = component.getAttribute('theme') || hostTheme;
|
|
246
248
|
|
|
247
|
-
//
|
|
249
|
+
// Item theme takes precedence over host theme / component theme
|
|
250
|
+
// even if it's empty, as long as it's not undefined or null
|
|
248
251
|
if (item.theme != null) {
|
|
249
252
|
theme = Array.isArray(item.theme) ? item.theme.join(' ') : item.theme;
|
|
250
253
|
}
|
|
@@ -361,7 +364,10 @@ export const ItemsMixin = (superClass) =>
|
|
|
361
364
|
}
|
|
362
365
|
};
|
|
363
366
|
|
|
364
|
-
|
|
367
|
+
// Open a submenu on click event when a touch device is used.
|
|
368
|
+
// On desktop, a submenu opens on hover.
|
|
369
|
+
menu.$.overlay.addEventListener(isTouch ? 'click' : 'mouseover', openSubMenu);
|
|
370
|
+
|
|
365
371
|
menu.$.overlay.addEventListener('keydown', (e) => {
|
|
366
372
|
const isRTL = this.__isRTL;
|
|
367
373
|
const shouldOpenSubMenu =
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import '@polymer/iron-media-query/iron-media-query.js';
|
|
7
|
-
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
|
-
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Element for internal use only.
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
class DeviceDetector extends PolymerElement {
|
|
16
|
-
static get template() {
|
|
17
|
-
return html`<iron-media-query query="min-device-width: 750px" query-matches="{{wide}}"></iron-media-query>`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static get is() {
|
|
21
|
-
return 'vaadin-device-detector';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get properties() {
|
|
25
|
-
return {
|
|
26
|
-
/**
|
|
27
|
-
* `true`, when running in a phone.
|
|
28
|
-
*/
|
|
29
|
-
phone: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
computed: '_phone(wide, touch)',
|
|
32
|
-
notify: true
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* `true`, when running in a touch device.
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
touch: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
notify: true,
|
|
42
|
-
value: isTouch
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* `true`, when running in a tablet/desktop device.
|
|
47
|
-
*/
|
|
48
|
-
wide: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
notify: true
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_phone(wide, touch) {
|
|
56
|
-
return !wide && touch;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
customElements.define(DeviceDetector.is, DeviceDetector);
|