@vaadin/vaadin-grid 5.9.5 → 5.9.7
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-reordering-mixin.d.ts +6 -1
- package/src/vaadin-grid-column-reordering-mixin.js +35 -5
- package/src/vaadin-grid-column.js +0 -4
- package/src/vaadin-grid-scroller.js +21 -0
- package/src/vaadin-grid.js +1 -1
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(() => {
|
|
@@ -36,7 +36,12 @@ interface ColumnReorderingMixin {
|
|
|
36
36
|
*/
|
|
37
37
|
columnReorderingAllowed: boolean;
|
|
38
38
|
ready(): void;
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the columns (or column groups) on the specified header level in visual order.
|
|
42
|
+
* By default, the bottom level is used.
|
|
43
|
+
*/
|
|
44
|
+
_getColumnsInOrder(headerLevel: any): GridColumnElement[];
|
|
40
45
|
_cellFromPoint(x: number, y: number): HTMLElement|null|undefined;
|
|
41
46
|
_updateGhostPosition(eventClientX: number, eventClientY: number): void;
|
|
42
47
|
_getInnerText(e: Element): string;
|
|
@@ -165,7 +165,23 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
165
165
|
const targetColumn = this._getTargetColumn(targetCell, this._draggedColumn);
|
|
166
166
|
if (this._isSwapAllowed(this._draggedColumn, targetColumn) &&
|
|
167
167
|
this._isSwappableByPosition(targetColumn, e.detail.x)) {
|
|
168
|
-
|
|
168
|
+
// Get the header level of the target column (and the dragged column)
|
|
169
|
+
const columnTreeLevel = this.__getColumnTreeLevel(targetColumn);
|
|
170
|
+
// Get the columns on that level in visual order
|
|
171
|
+
const levelColumnsInOrder = this._getColumnsInOrder(columnTreeLevel);
|
|
172
|
+
|
|
173
|
+
// Index of the column being dragged
|
|
174
|
+
const startIndex = levelColumnsInOrder.indexOf(this._draggedColumn);
|
|
175
|
+
// Index of the column being dragged over
|
|
176
|
+
const endIndex = levelColumnsInOrder.indexOf(targetColumn);
|
|
177
|
+
|
|
178
|
+
// Direction of iteration
|
|
179
|
+
const direction = startIndex < endIndex ? 1 : -1;
|
|
180
|
+
|
|
181
|
+
// Iteratively swap all the columns from the dragged column to the target column
|
|
182
|
+
for (let i = startIndex; i !== endIndex; i += direction) {
|
|
183
|
+
this._swapColumnOrders(this._draggedColumn, levelColumnsInOrder[i + direction]);
|
|
184
|
+
}
|
|
169
185
|
}
|
|
170
186
|
|
|
171
187
|
this._updateGhostPosition(e.detail.x, this._touchDevice ? e.detail.y - 50 : e.detail.y);
|
|
@@ -192,13 +208,17 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
192
208
|
}
|
|
193
209
|
|
|
194
210
|
/**
|
|
211
|
+
* Returns the columns (or column groups) on the specified header level in visual order.
|
|
212
|
+
* By default, the bottom level is used.
|
|
213
|
+
*
|
|
195
214
|
* @return {!Array<!GridColumnElement>}
|
|
196
215
|
* @protected
|
|
197
216
|
*/
|
|
198
|
-
_getColumnsInOrder() {
|
|
199
|
-
|
|
200
|
-
.
|
|
201
|
-
|
|
217
|
+
_getColumnsInOrder(headerLevel) {
|
|
218
|
+
if (!headerLevel && headerLevel !== 0) {
|
|
219
|
+
headerLevel = this._columnTree.length - 1;
|
|
220
|
+
}
|
|
221
|
+
return this._columnTree[headerLevel].filter((c) => !c.hidden).sort((b, a) => b._order - a._order);
|
|
202
222
|
}
|
|
203
223
|
|
|
204
224
|
/**
|
|
@@ -401,6 +421,16 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
401
421
|
}
|
|
402
422
|
}
|
|
403
423
|
|
|
424
|
+
/** @private */
|
|
425
|
+
__getColumnTreeLevel(column) {
|
|
426
|
+
for (let level = 0; level < this._columnTree.length; level++) {
|
|
427
|
+
if (this._columnTree[level].indexOf(column) >= 0) {
|
|
428
|
+
return level;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return -1;
|
|
432
|
+
}
|
|
433
|
+
|
|
404
434
|
/**
|
|
405
435
|
* Fired when the columns in the grid are reordered.
|
|
406
436
|
*
|
|
@@ -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
|
}
|
|
@@ -277,6 +277,27 @@ class GridScrollerElement extends PolymerIronList {
|
|
|
277
277
|
_scrollHandler() {
|
|
278
278
|
const delta = this.$.table.scrollTop - this._scrollPosition;
|
|
279
279
|
this._accessIronListAPI(super._scrollHandler);
|
|
280
|
+
|
|
281
|
+
if (this._physicalCount !== 0) {
|
|
282
|
+
const isScrollingDown = delta >= 0;
|
|
283
|
+
const reusables = this._getReusables(!isScrollingDown);
|
|
284
|
+
|
|
285
|
+
if (reusables.indexes.length) {
|
|
286
|
+
// After running super._scrollHandler, fix internal properties to workaround an iron-list issue.
|
|
287
|
+
// See https://github.com/vaadin/web-components/issues/1691
|
|
288
|
+
this._physicalTop = reusables.physicalTop;
|
|
289
|
+
|
|
290
|
+
if (isScrollingDown) {
|
|
291
|
+
this._virtualStart -= reusables.indexes.length;
|
|
292
|
+
this._physicalStart -= reusables.indexes.length;
|
|
293
|
+
} else {
|
|
294
|
+
this._virtualStart += reusables.indexes.length;
|
|
295
|
+
this._physicalStart += reusables.indexes.length;
|
|
296
|
+
}
|
|
297
|
+
this._update(reusables.indexes, !isScrollingDown);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
280
301
|
const oldOffset = this._vidxOffset;
|
|
281
302
|
if (this._accessIronListAPI(() => this._maxScrollTop) && this._virtualCount < this._effectiveSize) {
|
|
282
303
|
this._adjustVirtualIndexOffset(delta);
|