@vaadin/vaadin-grid 5.9.3 → 5.9.6
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 +1 -1
- package/src/vaadin-grid-column-group.js +35 -32
- package/src/vaadin-grid-column.js +0 -4
- package/src/vaadin-grid-disabled-mixin.d.ts +34 -0
- package/src/vaadin-grid-disabled-mixin.js +43 -0
- package/src/vaadin-grid-styles.js +5 -0
- package/src/vaadin-grid.d.ts +2 -0
- package/src/vaadin-grid.js +17 -6
- package/theme/lumo/vaadin-grid-styles.js +4 -0
- package/theme/material/vaadin-grid-styles.js +4 -0
package/package.json
CHANGED
|
@@ -82,11 +82,8 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
|
|
|
82
82
|
|
|
83
83
|
static get observers() {
|
|
84
84
|
return [
|
|
85
|
-
'_updateVisibleChildColumns(_childColumns)',
|
|
86
|
-
'_childColumnsChanged(_childColumns)',
|
|
87
85
|
'_groupFrozenChanged(frozen, _rootColumns)',
|
|
88
|
-
'_groupHiddenChanged(hidden
|
|
89
|
-
'_visibleChildColumnsChanged(_visibleChildColumns)',
|
|
86
|
+
'_groupHiddenChanged(hidden)',
|
|
90
87
|
'_colSpanChanged(_colSpan, _headerCell, _footerCell)',
|
|
91
88
|
'_groupOrderChanged(_order, _rootColumns)',
|
|
92
89
|
'_groupReorderStatusChanged(_reorderStatus, _rootColumns)',
|
|
@@ -114,9 +111,12 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
|
|
|
114
111
|
*/
|
|
115
112
|
_columnPropChanged(path, value) {
|
|
116
113
|
if (path === 'hidden') {
|
|
117
|
-
|
|
114
|
+
// Prevent synchronization of the hidden state to child columns.
|
|
115
|
+
// If the group is currently auto-hidden, and one column is made visible,
|
|
116
|
+
// we don't want the other columns to become visible as well.
|
|
117
|
+
this._preventHiddenSynchronization = true;
|
|
118
118
|
this._updateVisibleChildColumns(this._childColumns);
|
|
119
|
-
this.
|
|
119
|
+
this._preventHiddenSynchronization = false;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if (/flexGrow|width|hidden|_childColumns/.test(path)) {
|
|
@@ -188,15 +188,9 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
|
|
|
188
188
|
|
|
189
189
|
/** @private */
|
|
190
190
|
_updateVisibleChildColumns(childColumns) {
|
|
191
|
-
this._visibleChildColumns = Array.prototype.filter.call(childColumns, col => !col.hidden);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
/** @private */
|
|
195
|
-
_childColumnsChanged(childColumns) {
|
|
196
|
-
if (!this._autoHidden && this.hidden) {
|
|
197
|
-
Array.prototype.forEach.call(childColumns, column => column.hidden = true);
|
|
198
|
-
this._updateVisibleChildColumns(childColumns);
|
|
199
|
-
}
|
|
191
|
+
this._visibleChildColumns = Array.prototype.filter.call(childColumns, (col) => !col.hidden);
|
|
192
|
+
this._colSpan = this._visibleChildColumns.length;
|
|
193
|
+
this._updateAutoHidden();
|
|
200
194
|
}
|
|
201
195
|
|
|
202
196
|
/** @protected */
|
|
@@ -230,26 +224,31 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
|
|
|
230
224
|
}
|
|
231
225
|
|
|
232
226
|
/** @private */
|
|
233
|
-
_groupHiddenChanged(hidden
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
227
|
+
_groupHiddenChanged(hidden) {
|
|
228
|
+
// When initializing the hidden property, only sync hidden state to columns
|
|
229
|
+
// if group is actually hidden. Otherwise, we could override a hidden column
|
|
230
|
+
// to be visible.
|
|
231
|
+
// We always want to run this though if the property is actually changed.
|
|
232
|
+
if (hidden || this.__groupHiddenInitialized) {
|
|
233
|
+
this._synchronizeHidden();
|
|
238
234
|
}
|
|
235
|
+
this.__groupHiddenInitialized = true;
|
|
236
|
+
}
|
|
239
237
|
|
|
240
|
-
|
|
238
|
+
/** @private */
|
|
239
|
+
_updateAutoHidden() {
|
|
240
|
+
const wasAutoHidden = this._autoHidden;
|
|
241
|
+
this._autoHidden = (this._visibleChildColumns || []).length === 0;
|
|
242
|
+
// Only modify hidden state if group was auto-hidden, or becomes auto-hidden
|
|
243
|
+
if (wasAutoHidden || this._autoHidden) {
|
|
244
|
+
this.hidden = this._autoHidden;
|
|
245
|
+
}
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
/** @private */
|
|
244
|
-
|
|
245
|
-
this.
|
|
246
|
-
|
|
247
|
-
if (!this._ignoreVisibleChildColumns) {
|
|
248
|
-
if (visibleChildColumns.length === 0) {
|
|
249
|
-
this._autoHidden = this.hidden = true;
|
|
250
|
-
} else if (this.hidden && this._autoHidden) {
|
|
251
|
-
this._autoHidden = this.hidden = false;
|
|
252
|
-
}
|
|
249
|
+
_synchronizeHidden() {
|
|
250
|
+
if (this._childColumns && !this._preventHiddenSynchronization) {
|
|
251
|
+
this._childColumns.forEach((column) => (column.hidden = this.hidden));
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
|
|
@@ -280,10 +279,14 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
|
|
|
280
279
|
if (info.addedNodes.filter(this._isColumnElement).length > 0 ||
|
|
281
280
|
info.removedNodes.filter(this._isColumnElement).length > 0) {
|
|
282
281
|
|
|
283
|
-
|
|
282
|
+
// Prevent synchronization of the hidden state to child columns.
|
|
283
|
+
// If the group is currently auto-hidden, and a visible column is added,
|
|
284
|
+
// we don't want the other columns to become visible as well.
|
|
285
|
+
this._preventHiddenSynchronization = true;
|
|
284
286
|
this._rootColumns = this._getChildColumns(this);
|
|
285
287
|
this._childColumns = this._rootColumns;
|
|
286
|
-
this.
|
|
288
|
+
this._updateVisibleChildColumns(this._childColumns);
|
|
289
|
+
this._preventHiddenSynchronization = false;
|
|
287
290
|
|
|
288
291
|
// Update the column tree with microtask timing to avoid shady style scope issues
|
|
289
292
|
microTask.run(() => {
|
|
@@ -310,10 +310,6 @@ export const ColumnBaseMixin = superClass => class ColumnBaseMixin extends super
|
|
|
310
310
|
|
|
311
311
|
/** @private */
|
|
312
312
|
__setColumnTemplateOrRenderer(template, renderer, cells) {
|
|
313
|
-
// no renderer or template needed in a hidden column
|
|
314
|
-
if (this.hidden) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
313
|
if (template && renderer) {
|
|
318
314
|
throw new Error('You should only use either a renderer or a template');
|
|
319
315
|
}
|
|
@@ -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
|
+
};
|
package/src/vaadin-grid.d.ts
CHANGED
|
@@ -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';
|
package/src/vaadin-grid.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
328
|
+
return '5.9.6';
|
|
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 (
|
|
610
|
+
if (this._chrome) {
|
|
603
611
|
// Chrome bug: focusing before mouseup prevents text selection, see http://crbug.com/771903
|
|
604
|
-
const mouseUpListener = () => {
|
|
605
|
-
|
|
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;
|