@vaadin/context-menu 23.1.0-alpha1 → 23.1.0-alpha4

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.1.0-alpha1",
3
+ "version": "23.1.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,19 +35,19 @@
35
35
  "dependencies": {
36
36
  "@open-wc/dedupe-mixin": "^1.3.0",
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/component-base": "23.1.0-alpha1",
39
- "@vaadin/item": "23.1.0-alpha1",
40
- "@vaadin/list-box": "23.1.0-alpha1",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-alpha1",
42
- "@vaadin/vaadin-material-styles": "23.1.0-alpha1",
43
- "@vaadin/vaadin-overlay": "23.1.0-alpha1",
44
- "@vaadin/vaadin-themable-mixin": "23.1.0-alpha1"
38
+ "@vaadin/component-base": "23.1.0-alpha4",
39
+ "@vaadin/item": "23.1.0-alpha4",
40
+ "@vaadin/list-box": "23.1.0-alpha4",
41
+ "@vaadin/vaadin-lumo-styles": "23.1.0-alpha4",
42
+ "@vaadin/vaadin-material-styles": "23.1.0-alpha4",
43
+ "@vaadin/vaadin-overlay": "23.1.0-alpha4",
44
+ "@vaadin/vaadin-themable-mixin": "23.1.0-alpha4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/polymer-legacy-adapter": "23.1.0-alpha1",
48
+ "@vaadin/polymer-legacy-adapter": "23.1.0-alpha4",
49
49
  "@vaadin/testing-helpers": "^0.3.2",
50
- "sinon": "^9.2.1"
50
+ "sinon": "^13.0.2"
51
51
  },
52
- "gitHead": "5d0cdee069f866037c507265fafb4d0476795333"
52
+ "gitHead": "aacdb7fe09811894751f0378ff7fb66071892c71"
53
53
  }
@@ -28,7 +28,7 @@ registerStyles(
28
28
  background-color: #fff;
29
29
  }
30
30
  `,
31
- { moduleId: 'vaadin-context-menu-overlay-styles' }
31
+ { moduleId: 'vaadin-context-menu-overlay-styles' },
32
32
  );
33
33
 
34
34
  /**
@@ -49,8 +49,8 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
49
49
  */
50
50
  parentOverlay: {
51
51
  type: Object,
52
- readOnly: true
53
- }
52
+ readOnly: true,
53
+ },
54
54
  };
55
55
  }
56
56
 
@@ -102,7 +102,7 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
102
102
  return {
103
103
  xMax: overlayRect.right - contentRect.width,
104
104
  xMin: overlayRect.left + contentRect.width,
105
- yMax
105
+ yMax,
106
106
  };
107
107
  }
108
108
 
@@ -118,17 +118,17 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
118
118
  // Horizontal adjustment
119
119
  const isLeftAligned = !!this.style.left;
120
120
  if (isLeftAligned) {
121
- this.style.left = parseFloat(this.style.left) + parseFloat(style.paddingLeft) + 'px';
121
+ this.style.left = `${parseFloat(this.style.left) + parseFloat(style.paddingLeft)}px`;
122
122
  } else {
123
- this.style.right = parseFloat(this.style.right) + parseFloat(style.paddingRight) + 'px';
123
+ this.style.right = `${parseFloat(this.style.right) + parseFloat(style.paddingRight)}px`;
124
124
  }
125
125
 
126
126
  // Vertical adjustment
127
127
  const isBottomAligned = !!this.style.bottom;
128
128
  if (isBottomAligned) {
129
- this.style.bottom = parseFloat(this.style.bottom) - parseFloat(style.paddingBottom) + 'px';
129
+ this.style.bottom = `${parseFloat(this.style.bottom) - parseFloat(style.paddingBottom)}px`;
130
130
  } else {
131
- this.style.top = parseFloat(this.style.top) - parseFloat(style.paddingTop) + 'px';
131
+ this.style.top = `${parseFloat(this.style.top) - parseFloat(style.paddingTop)}px`;
132
132
  }
133
133
  }
134
134
  }
@@ -17,7 +17,7 @@ export interface ContextMenuRendererContext {
17
17
  export type ContextMenuRenderer = (
18
18
  root: HTMLElement,
19
19
  contextMenu?: ContextMenu,
20
- context?: ContextMenuRendererContext
20
+ context?: ContextMenuRendererContext,
21
21
  ) => void;
22
22
 
23
23
  /**
@@ -289,13 +289,13 @@ declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(HTM
289
289
  addEventListener<K extends keyof ContextMenuEventMap>(
290
290
  type: K,
291
291
  listener: (this: ContextMenu, ev: ContextMenuEventMap[K]) => void,
292
- options?: boolean | AddEventListenerOptions
292
+ options?: boolean | AddEventListenerOptions,
293
293
  ): void;
294
294
 
295
295
  removeEventListener<K extends keyof ContextMenuEventMap>(
296
296
  type: K,
297
297
  listener: (this: ContextMenu, ev: ContextMenuEventMap[K]) => void,
298
- options?: boolean | EventListenerOptions
298
+ options?: boolean | EventListenerOptions,
299
299
  ): void;
300
300
  }
301
301
 
@@ -241,7 +241,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
241
241
  * of the context menu to listen for `openOn` events.
242
242
  */
243
243
  selector: {
244
- type: String
244
+ type: String,
245
245
  },
246
246
 
247
247
  /**
@@ -252,7 +252,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
252
252
  type: Boolean,
253
253
  value: false,
254
254
  notify: true,
255
- readOnly: true
255
+ readOnly: true,
256
256
  },
257
257
 
258
258
  /**
@@ -262,7 +262,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
262
262
  */
263
263
  openOn: {
264
264
  type: String,
265
- value: 'vaadin-contextmenu'
265
+ value: 'vaadin-contextmenu',
266
266
  },
267
267
 
268
268
  /**
@@ -276,7 +276,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
276
276
  type: Object,
277
277
  value: function () {
278
278
  return this;
279
- }
279
+ },
280
280
  },
281
281
 
282
282
  /**
@@ -287,7 +287,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
287
287
  closeOn: {
288
288
  type: String,
289
289
  value: 'click',
290
- observer: '_closeOnChanged'
290
+ observer: '_closeOnChanged',
291
291
  },
292
292
 
293
293
  /**
@@ -302,7 +302,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
302
302
  * @type {ContextMenuRenderer | undefined}
303
303
  */
304
304
  renderer: {
305
- type: Function
305
+ type: Function,
306
306
  },
307
307
 
308
308
  /** @private */
@@ -316,25 +316,25 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
316
316
 
317
317
  /** @private */
318
318
  _phone: {
319
- type: Boolean
319
+ type: Boolean,
320
320
  },
321
321
 
322
322
  /** @private */
323
323
  _touch: {
324
324
  type: Boolean,
325
- value: isTouch
325
+ value: isTouch,
326
326
  },
327
327
 
328
328
  /** @private */
329
329
  _wide: {
330
- type: Boolean
330
+ type: Boolean,
331
331
  },
332
332
 
333
333
  /** @private */
334
334
  _wideMediaQuery: {
335
335
  type: String,
336
- value: '(min-device-width: 750px)'
337
- }
336
+ value: '(min-device-width: 750px)',
337
+ },
338
338
  };
339
339
  }
340
340
 
@@ -343,7 +343,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
343
343
  '_openedChanged(opened)',
344
344
  '_targetOrOpenOnChanged(listenOn, openOn)',
345
345
  '_rendererChanged(renderer, items)',
346
- '_touchOrWideChanged(_touch, _wide)'
346
+ '_touchOrWideChanged(_touch, _wide)',
347
347
  ];
348
348
  }
349
349
 
@@ -377,7 +377,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
377
377
  this.addController(
378
378
  new MediaQueryController(this._wideMediaQuery, (matches) => {
379
379
  this._wide = matches;
380
- })
380
+ }),
381
381
  );
382
382
 
383
383
  processTemplates(this);
@@ -535,7 +535,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
535
535
  if (e && !this.opened) {
536
536
  this._context = {
537
537
  detail: e.detail,
538
- target: this._contextTarget(e)
538
+ target: this._contextTarget(e),
539
539
  };
540
540
 
541
541
  if (this._context.target) {
@@ -579,7 +579,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
579
579
  const overlay = this.$.overlay;
580
580
  const style = overlay.style;
581
581
 
582
- style[coord] = (parseInt(style[coord]) || 0) + diff + 'px';
582
+ style[coord] = `${(parseInt(style[coord]) || 0) + diff}px`;
583
583
  }
584
584
 
585
585
  /** @private */
@@ -618,25 +618,25 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
618
618
  if (!this.__isRTL) {
619
619
  if (x < wdthVport / 2 || x < xMax) {
620
620
  // Menu is displayed in the right side of the anchor
621
- style.left = x + 'px';
621
+ style.left = `${x}px`;
622
622
  } else {
623
623
  // Menu is displayed in the left side of the anchor
624
- style.right = Math.max(0, wdthVport - x) + 'px';
624
+ style.right = `${Math.max(0, wdthVport - x)}px`;
625
625
  this._setEndAligned(overlay);
626
626
  }
627
627
  } else if (x > wdthVport / 2 || x > xMin) {
628
628
  // Menu is displayed in the right side of the anchor
629
- style.right = Math.max(0, wdthVport - x) + 'px';
629
+ style.right = `${Math.max(0, wdthVport - x)}px`;
630
630
  } else {
631
631
  // Menu is displayed in the left side of the anchor
632
- style.left = x + 'px';
632
+ style.left = `${x}px`;
633
633
  this._setEndAligned(overlay);
634
634
  }
635
635
 
636
636
  if (y < hghtVport / 2 || y < yMax) {
637
- style.top = y + 'px';
637
+ style.top = `${y}px`;
638
638
  } else {
639
- style.bottom = Math.max(0, hghtVport - y) + 'px';
639
+ style.bottom = `${Math.max(0, hghtVport - y)}px`;
640
640
  overlay.setAttribute('bottom-aligned', '');
641
641
  }
642
642
  }
@@ -660,7 +660,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
660
660
  return this._getEventCoordinate(event.detail.sourceEvent, coord);
661
661
  }
662
662
  } else {
663
- const prop = 'client' + coord.toUpperCase();
663
+ const prop = `client${coord.toUpperCase()}`;
664
664
  const position = event.changedTouches ? event.changedTouches[0][prop] : event[prop];
665
665
 
666
666
  if (position === 0) {
@@ -11,13 +11,13 @@ register({
11
11
  deps: ['touchstart', 'touchmove', 'touchend', 'contextmenu'],
12
12
  flow: {
13
13
  start: ['touchstart', 'contextmenu'],
14
- end: ['contextmenu']
14
+ end: ['contextmenu'],
15
15
  },
16
16
 
17
17
  emits: ['vaadin-contextmenu'],
18
18
 
19
19
  info: {
20
- sourceEvent: null
20
+ sourceEvent: null,
21
21
  },
22
22
 
23
23
  reset: function () {
@@ -38,7 +38,7 @@ register({
38
38
  this.info.sourceEvent = e;
39
39
  this.info.touchStartCoords = {
40
40
  x: e.changedTouches[0].clientX,
41
- y: e.changedTouches[0].clientY
41
+ y: e.changedTouches[0].clientY,
42
42
  };
43
43
 
44
44
  // After timeout event is already retargeted to the parent element in case there is one.
@@ -97,5 +97,5 @@ register({
97
97
  if (ev.defaultPrevented && sourceEvent && sourceEvent.preventDefault) {
98
98
  sourceEvent.preventDefault();
99
99
  }
100
- }
100
+ },
101
101
  });
@@ -95,7 +95,7 @@ export const ItemsMixin = (superClass) =>
95
95
  * ----------------|----------------|----------------
96
96
  * `:host` | expanded | Expanded parent item
97
97
  */
98
- items: Array
98
+ items: Array,
99
99
  };
100
100
  }
101
101
 
@@ -178,9 +178,9 @@ export const ItemsMixin = (superClass) =>
178
178
  itemElement.dispatchEvent(
179
179
  new CustomEvent('opensubmenu', {
180
180
  detail: {
181
- children: itemElement._item.children
182
- }
183
- })
181
+ children: itemElement._item.children,
182
+ },
183
+ }),
184
184
  );
185
185
  }
186
186
 
@@ -263,10 +263,10 @@ export const ItemsMixin = (superClass) =>
263
263
  __toggleMenuComponentAttribute(component, attribute, on) {
264
264
  if (on) {
265
265
  component.setAttribute(attribute, '');
266
- component['__has-' + attribute] = true;
267
- } else if (component['__has-' + attribute]) {
266
+ component[`__has-${attribute}`] = true;
267
+ } else if (component[`__has-${attribute}`]) {
268
268
  component.removeAttribute(attribute);
269
- component['__has-' + attribute] = false;
269
+ component[`__has-${attribute}`] = false;
270
270
  }
271
271
  }
272
272
 
@@ -280,7 +280,9 @@ export const ItemsMixin = (superClass) =>
280
280
  `;
281
281
  flush();
282
282
  const listBox = root.querySelector('vaadin-context-menu-list-box');
283
- this._theme && listBox.setAttribute('theme', this._theme);
283
+ if (this._theme) {
284
+ listBox.setAttribute('theme', this._theme);
285
+ }
284
286
  listBox.classList.add('vaadin-menu-list-box');
285
287
  requestAnimationFrame(() => listBox.setAttribute('role', 'menu'));
286
288
 
@@ -334,7 +336,7 @@ export const ItemsMixin = (superClass) =>
334
336
  requestAnimationFrame(() => (this.__openListenerActive = true));
335
337
  const openSubMenu = (
336
338
  e,
337
- itemElement = e.composedPath().filter((e) => e.localName === 'vaadin-context-menu-item')[0]
339
+ itemElement = e.composedPath().filter((e) => e.localName === 'vaadin-context-menu-item')[0],
338
340
  ) => {
339
341
  // Delay enabling the mouseover listener to avoid it from triggering on parent menu open
340
342
  if (!this.__openListenerActive) {
@@ -373,7 +375,9 @@ export const ItemsMixin = (superClass) =>
373
375
  const shouldOpenSubMenu =
374
376
  (!isRTL && e.keyCode === 39) || (isRTL && e.keyCode === 37) || e.keyCode === 13 || e.keyCode === 32;
375
377
 
376
- shouldOpenSubMenu && openSubMenu(e);
378
+ if (shouldOpenSubMenu) {
379
+ openSubMenu(e);
380
+ }
377
381
  });
378
382
  } else {
379
383
  const listBox = root.querySelector('vaadin-context-menu-list-box');
@@ -31,7 +31,7 @@ const contextMenuOverlay = css`
31
31
  `;
32
32
 
33
33
  registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
34
- moduleId: 'lumo-context-menu-overlay'
34
+ moduleId: 'lumo-context-menu-overlay',
35
35
  });
36
36
 
37
37
  registerStyles(
@@ -84,7 +84,7 @@ registerStyles(
84
84
  }
85
85
  }
86
86
  `,
87
- { moduleId: 'lumo-context-menu-list-box' }
87
+ { moduleId: 'lumo-context-menu-list-box' },
88
88
  );
89
89
 
90
90
  registerStyles(
@@ -124,5 +124,5 @@ registerStyles(
124
124
  padding-right: var(--lumo-space-m);
125
125
  }
126
126
  `,
127
- { moduleId: 'lumo-context-menu-item' }
127
+ { moduleId: 'lumo-context-menu-item' },
128
128
  );
@@ -12,7 +12,7 @@ const contextMenuOverlay = css`
12
12
  `;
13
13
 
14
14
  registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
15
- moduleId: 'material-context-menu-overlay'
15
+ moduleId: 'material-context-menu-overlay',
16
16
  });
17
17
 
18
18
  registerStyles(
@@ -44,7 +44,7 @@ registerStyles(
44
44
  }
45
45
  }
46
46
  `,
47
- { moduleId: 'material-context-menu-list-box' }
47
+ { moduleId: 'material-context-menu-list-box' },
48
48
  );
49
49
 
50
50
  registerStyles(
@@ -79,5 +79,5 @@ registerStyles(
79
79
  background-color: var(--material-secondary-background-color);
80
80
  }
81
81
  `,
82
- { moduleId: 'material-context-menu-item' }
82
+ { moduleId: 'material-context-menu-item' },
83
83
  );