@vaadin/vaadin-grid 5.9.2 → 5.9.5

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
@@ -15,7 +15,7 @@
15
15
  "repository": "vaadin/vaadin-grid",
16
16
  "homepage": "https://vaadin.com/components",
17
17
  "name": "@vaadin/vaadin-grid",
18
- "version": "5.9.2",
18
+ "version": "5.9.5",
19
19
  "main": "vaadin-grid.js",
20
20
  "author": "Vaadin Ltd",
21
21
  "license": "Apache-2.0",
@@ -44,16 +44,12 @@
44
44
  "@vaadin/vaadin-element-mixin": "^2.4.1"
45
45
  },
46
46
  "resolutions": {
47
- "@webcomponents/webcomponentsjs": "2.0.0",
47
+ "@webcomponents/webcomponentsjs": "2.0.0",
48
48
  "inherits": "2.0.3",
49
49
  "samsam": "1.1.3",
50
50
  "supports-color": "3.1.2",
51
51
  "type-detect": "1.0.0"
52
52
  },
53
- "scripts": {
54
- "generate-typings": "gen-typescript-declarations --outDir . --verify",
55
- "test": "wct --npm"
56
- },
57
53
  "devDependencies": {
58
54
  "@web-padawan/gen-typescript-declarations": "^1.6.2",
59
55
  "web-component-tester": "6.9.2",
@@ -73,5 +69,9 @@
73
69
  "@vaadin/vaadin-demo-helpers": "^3.1.0",
74
70
  "@webcomponents/webcomponentsjs": "^2.0.0",
75
71
  "wct-browser-legacy": "^1.0.1"
72
+ },
73
+ "scripts": {
74
+ "generate-typings": "gen-typescript-declarations --outDir . --verify",
75
+ "test": "wct --npm"
76
76
  }
77
77
  }
@@ -368,7 +368,9 @@ export const ColumnBaseMixin = superClass => class ColumnBaseMixin extends super
368
368
  _setFooterTemplateOrRenderer(footerTemplate, footerRenderer, footerCell) {
369
369
  if ((footerTemplate || footerRenderer) && footerCell) {
370
370
  this.__setColumnTemplateOrRenderer(footerTemplate, footerRenderer, [footerCell]);
371
- this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
371
+ if (this._grid) {
372
+ this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
373
+ }
372
374
  }
373
375
  }
374
376
 
@@ -482,7 +484,7 @@ export const ColumnBaseMixin = superClass => class ColumnBaseMixin extends super
482
484
  }
483
485
  }
484
486
 
485
- if (headerCell) {
487
+ if (headerCell && this._grid) {
486
488
  this._grid.__updateHeaderFooterRowVisibility(headerCell.parentElement);
487
489
  }
488
490
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * DO NOT EDIT
3
+ *
4
+ * This file was automatically generated by
5
+ * https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations
6
+ *
7
+ * To modify these typings, edit the source file(s):
8
+ * src/vaadin-grid-disabled-mixin.js
9
+ */
10
+
11
+
12
+ // tslint:disable:variable-name Describing an API that's defined elsewhere.
13
+ // tslint:disable:no-any describes the API as best we are able today
14
+
15
+ export {DisabledMixin};
16
+
17
+ declare function DisabledMixin<T extends new (...args: any[]) => {}>(base: T): T & DisabledMixinConstructor;
18
+
19
+ interface DisabledMixinConstructor {
20
+ new(...args: any[]): DisabledMixin;
21
+ }
22
+
23
+ export {DisabledMixinConstructor};
24
+
25
+ interface DisabledMixin {
26
+ disabled: boolean|null|undefined;
27
+ _disabledChanged(disabled: any): void;
28
+
29
+ /**
30
+ * Overrides the default element `click` method in order to prevent
31
+ * firing the `click` event when the element is disabled.
32
+ */
33
+ click(): void;
34
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ @license
3
+ Copyright (c) 2017 Vaadin Ltd.
4
+ This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ /**
7
+ * @polymerMixin
8
+ */
9
+ export const DisabledMixin = superClass => class DisabledMixin extends superClass {
10
+ static get properties() {
11
+ return {
12
+ disabled: {
13
+ type: Boolean,
14
+ value: false,
15
+ observer: '_disabledChanged',
16
+ reflectToAttribute: true
17
+ }
18
+ };
19
+ }
20
+
21
+ /** @protected */
22
+ _disabledChanged(disabled) {
23
+ if (disabled) {
24
+ this.setAttribute('tabindex', '-1');
25
+ this.setAttribute('aria-disabled', 'true');
26
+ } else {
27
+ this.removeAttribute('tabindex');
28
+ this.removeAttribute('aria-disabled');
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Overrides the default element `click` method in order to prevent
34
+ * firing the `click` event when the element is disabled.
35
+ * @protected
36
+ * @override
37
+ */
38
+ click() {
39
+ if (!this.disabled) {
40
+ super.click();
41
+ }
42
+ }
43
+ };
@@ -80,11 +80,7 @@ export const SelectionMixin = superClass => class SelectionMixin extends superCl
80
80
 
81
81
  /** @private */
82
82
  _selectedItemsChanged(e) {
83
- if (this.$.items.children.length && (e.path === 'selectedItems' || e.path === 'selectedItems.splices')) {
84
- Array.from(this.$.items.children).forEach(row => {
85
- this._updateItem(row, row._item);
86
- });
87
- }
83
+ this._assignModels();
88
84
  }
89
85
 
90
86
  /** @private */
@@ -31,6 +31,11 @@ VaadinGridStyles.appendChild(
31
31
  display: none !important;
32
32
  }
33
33
 
34
+ :host([disabled]) {
35
+ pointer-events: none;
36
+ animation: none;
37
+ }
38
+
34
39
  #scroller {
35
40
  display: block;
36
41
  transform: translateY(0);
@@ -13,6 +13,8 @@
13
13
 
14
14
  import {ThemableMixin} from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
15
15
 
16
+ import {DisabledMixin} from './vaadin-grid-disabled-mixin.js';
17
+
16
18
  import {ScrollerElement} from './vaadin-grid-scroller.js';
17
19
 
18
20
  import {A11yMixin} from './vaadin-grid-a11y-mixin.js';
@@ -6,6 +6,7 @@ This program is available under Apache License Version 2.0, available at https:/
6
6
  import '@polymer/polymer/polymer-legacy.js';
7
7
 
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import { DisabledMixin } from './vaadin-grid-disabled-mixin.js';
9
10
  import { ScrollerElement } from './vaadin-grid-scroller.js';
10
11
  import { A11yMixin } from './vaadin-grid-a11y-mixin.js';
11
12
  import { ActiveItemMixin } from './vaadin-grid-active-item-mixin.js';
@@ -294,7 +295,8 @@ class GridElement extends
294
295
  EventContextMixin(
295
296
  DragAndDropMixin(
296
297
  StylingMixin(
297
- ScrollerElement)))))))))))))))))) {
298
+ DisabledMixin(
299
+ ScrollerElement))))))))))))))))))) {
298
300
  static get template() {
299
301
  return html`
300
302
  <style include="vaadin-grid-styles"></style>
@@ -323,7 +325,7 @@ class GridElement extends
323
325
  }
324
326
 
325
327
  static get version() {
326
- return '5.9.2';
328
+ return '5.9.5';
327
329
  }
328
330
 
329
331
  static get observers() {
@@ -334,6 +336,12 @@ class GridElement extends
334
336
 
335
337
  static get properties() {
336
338
  return {
339
+ /** @private */
340
+ _chrome: {
341
+ type: Boolean,
342
+ value: /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)
343
+ },
344
+
337
345
  /** @private */
338
346
  _safari: {
339
347
  type: Boolean,
@@ -599,13 +607,16 @@ class GridElement extends
599
607
  // focusable slot wrapper, that is why cells are not focused with
600
608
  // mousedown. Workaround: listen for mousedown and focus manually.
601
609
  cellContent.addEventListener('mousedown', () => {
602
- if (window.chrome) {
610
+ if (this._chrome) {
603
611
  // Chrome bug: focusing before mouseup prevents text selection, see http://crbug.com/771903
604
- const mouseUpListener = () => {
605
- if (!cellContent.contains(this.getRootNode().activeElement)) {
612
+ const mouseUpListener = (event) => {
613
+ // If focus is on element within the cell content — respect it, do not change
614
+ const contentContainsFocusedElement = cellContent.contains(this.getRootNode().activeElement);
615
+ // Only focus if mouse is released on cell content itself
616
+ const mouseUpWithinCell = event.composedPath().indexOf(cellContent) >= 0;
617
+ if (!contentContainsFocusedElement && mouseUpWithinCell) {
606
618
  cell.focus();
607
619
  }
608
- // If focus is in the cell content — respect it, do not change.
609
620
  document.removeEventListener('mouseup', mouseUpListener, true);
610
621
  };
611
622
  document.addEventListener('mouseup', mouseUpListener, true);
@@ -29,6 +29,10 @@ const $_documentContainer = html`<dom-module id="lumo-grid" theme-for="vaadin-gr
29
29
  --_lumo-grid-selected-row-color: var(--lumo-primary-color-10pct);
30
30
  }
31
31
 
32
+ :host([disabled]) {
33
+ opacity: 0.7;
34
+ }
35
+
32
36
  /* No (outer) border */
33
37
 
34
38
  :host(:not([theme~="no-border"])) {
@@ -13,6 +13,10 @@ const $_documentContainer = html`<dom-module id="material-grid" theme-for="vaadi
13
13
  color: var(--material-body-text-color);
14
14
  }
15
15
 
16
+ :host([disabled]) {
17
+ opacity: 0.7;
18
+ }
19
+
16
20
  [part~="cell"] {
17
21
  min-height: 48px;
18
22
  -webkit-tap-highlight-color: transparent;