@vaadin/context-menu 23.0.0-alpha1 → 23.0.0-alpha5
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 +11 -10
- package/src/vaadin-context-menu-overlay.js +1 -1
- package/src/vaadin-context-menu.d.ts +2 -3
- package/src/vaadin-context-menu.js +12 -18
- package/src/vaadin-contextmenu-event.js +2 -2
- package/src/vaadin-contextmenu-items-mixin.d.ts +1 -1
- package/src/vaadin-contextmenu-items-mixin.js +1 -1
- package/src/vaadin-device-detector.js +1 -1
- package/theme/lumo/vaadin-context-menu-styles.js +2 -1
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-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"main": "vaadin-context-menu.js",
|
|
20
20
|
"module": "vaadin-context-menu.js",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"files": [
|
|
22
23
|
"src",
|
|
23
24
|
"theme",
|
|
@@ -35,19 +36,19 @@
|
|
|
35
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
37
|
"@polymer/iron-media-query": "^3.0.0",
|
|
37
38
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/component-base": "23.0.0-
|
|
39
|
-
"@vaadin/item": "23.0.0-
|
|
40
|
-
"@vaadin/list-box": "23.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
43
|
-
"@vaadin/vaadin-overlay": "23.0.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
39
|
+
"@vaadin/component-base": "23.0.0-alpha5",
|
|
40
|
+
"@vaadin/item": "23.0.0-alpha5",
|
|
41
|
+
"@vaadin/list-box": "23.0.0-alpha5",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha5",
|
|
43
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha5",
|
|
44
|
+
"@vaadin/vaadin-overlay": "23.0.0-alpha5",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha5"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/polymer-legacy-adapter": "23.0.0-
|
|
49
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha5",
|
|
49
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
51
|
"sinon": "^9.2.1"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "74f9294964eb8552d96578c14af6ad214f5257bc"
|
|
53
54
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
7
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
7
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
9
8
|
import { ContextMenuItem, ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
@@ -224,7 +223,7 @@ export interface ContextMenuEventMap extends HTMLElementEventMap, ContextMenuCus
|
|
|
224
223
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
225
224
|
* @fires {CustomEvent} item-selected - Fired when an item is selected when the context menu is populated using the `items` API.
|
|
226
225
|
*/
|
|
227
|
-
declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(
|
|
226
|
+
declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(HTMLElement))) {
|
|
228
227
|
/**
|
|
229
228
|
* CSS selector that can be used to target any child element
|
|
230
229
|
* of the context menu to listen for `openOn` events.
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
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
7
|
import './vaadin-device-detector.js';
|
|
8
8
|
import './vaadin-context-menu-overlay.js';
|
|
9
|
-
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
10
|
-
import { addListener, gestures, removeListener } from '@polymer/polymer/lib/utils/gestures.js';
|
|
11
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
+
import { addListener, gestures, removeListener } from '@vaadin/component-base/src/gestures.js';
|
|
13
12
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
14
13
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
15
14
|
import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
@@ -199,9 +198,8 @@ import { ItemsMixin } from './vaadin-contextmenu-items-mixin.js';
|
|
|
199
198
|
* @mixes ElementMixin
|
|
200
199
|
* @mixes ThemePropertyMixin
|
|
201
200
|
* @mixes ItemsMixin
|
|
202
|
-
* @mixes GestureEventListeners
|
|
203
201
|
*/
|
|
204
|
-
class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(
|
|
202
|
+
class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(PolymerElement))) {
|
|
205
203
|
static get template() {
|
|
206
204
|
return html`
|
|
207
205
|
<style>
|
|
@@ -489,9 +487,8 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(GestureEven
|
|
|
489
487
|
return Array.prototype.filter.call(targets, (el) => {
|
|
490
488
|
return e.composedPath().indexOf(el) > -1;
|
|
491
489
|
})[0];
|
|
492
|
-
} else {
|
|
493
|
-
return e.target;
|
|
494
490
|
}
|
|
491
|
+
return e.target;
|
|
495
492
|
}
|
|
496
493
|
|
|
497
494
|
/**
|
|
@@ -574,7 +571,7 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(GestureEven
|
|
|
574
571
|
// in the `vaadin-overlay-change` which guarantees that overlay is ready.
|
|
575
572
|
// The valus represent an anchor position on the page where the contextmenu
|
|
576
573
|
// event took place.
|
|
577
|
-
|
|
574
|
+
const x = this.__x;
|
|
578
575
|
const y = this.__y;
|
|
579
576
|
|
|
580
577
|
// Select one overlay corner and move to the event x/y position.
|
|
@@ -591,15 +588,13 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(GestureEven
|
|
|
591
588
|
style.right = Math.max(0, wdthVport - x) + 'px';
|
|
592
589
|
this._setEndAligned(overlay);
|
|
593
590
|
}
|
|
591
|
+
} else if (x > wdthVport / 2 || x > xMin) {
|
|
592
|
+
// Menu is displayed in the right side of the anchor
|
|
593
|
+
style.right = Math.max(0, wdthVport - x) + 'px';
|
|
594
594
|
} else {
|
|
595
595
|
// Menu is displayed in the left side of the anchor
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
} else {
|
|
599
|
-
// Menu is displayed in the left side of the anchor
|
|
600
|
-
style.left = x + 'px';
|
|
601
|
-
this._setEndAligned(overlay);
|
|
602
|
-
}
|
|
596
|
+
style.left = x + 'px';
|
|
597
|
+
this._setEndAligned(overlay);
|
|
603
598
|
}
|
|
604
599
|
|
|
605
600
|
if (y < hghtVport / 2 || y < yMax) {
|
|
@@ -636,10 +631,9 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(GestureEven
|
|
|
636
631
|
// Native keyboard event
|
|
637
632
|
const rect = event.target.getBoundingClientRect();
|
|
638
633
|
return coord === 'x' ? rect.left : rect.top + rect.height;
|
|
639
|
-
} else {
|
|
640
|
-
// Native mouse or touch event
|
|
641
|
-
return position;
|
|
642
634
|
}
|
|
635
|
+
// Native mouse or touch event
|
|
636
|
+
return position;
|
|
643
637
|
}
|
|
644
638
|
}
|
|
645
639
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { prevent, register } from '@polymer/polymer/lib/utils/gestures.js';
|
|
7
6
|
import { isIOS } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
|
+
import { prevent, register } from '@vaadin/component-base/src/gestures.js';
|
|
8
8
|
|
|
9
9
|
register({
|
|
10
10
|
name: 'vaadin-contextmenu',
|
|
@@ -90,7 +90,8 @@ registerStyles(
|
|
|
90
90
|
registerStyles(
|
|
91
91
|
'vaadin-context-menu-item',
|
|
92
92
|
css`
|
|
93
|
-
:
|
|
93
|
+
/* :hover needed to workaround https://github.com/vaadin/web-components/issues/3133 */
|
|
94
|
+
:host(:hover) {
|
|
94
95
|
user-select: none;
|
|
95
96
|
-ms-user-select: none;
|
|
96
97
|
-webkit-user-select: none;
|