@vaadin/grid 22.0.0-rc1 → 23.0.0-alpha2
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 +9 -9
- package/src/array-data-provider.js +2 -3
- package/src/vaadin-grid-column-group.js +1 -1
- package/src/vaadin-grid-column-reordering-mixin.js +4 -7
- package/src/vaadin-grid-column-resizing-mixin.js +2 -3
- package/src/vaadin-grid-column.js +20 -13
- package/src/vaadin-grid-data-provider-mixin.js +2 -4
- package/src/vaadin-grid-dynamic-columns-mixin.js +5 -8
- package/src/vaadin-grid-keyboard-navigation-mixin.js +73 -66
- package/src/vaadin-grid-row-details-mixin.js +0 -1
- package/src/vaadin-grid-scroll-mixin.js +5 -5
- package/src/vaadin-grid-sort-mixin.js +7 -9
- package/src/vaadin-grid.d.ts +16 -25
- package/src/vaadin-grid.js +25 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
42
42
|
"@polymer/polymer": "^3.0.0",
|
|
43
|
-
"@vaadin/checkbox": "
|
|
44
|
-
"@vaadin/component-base": "
|
|
45
|
-
"@vaadin/text-field": "
|
|
46
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
47
|
-
"@vaadin/vaadin-material-styles": "
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
43
|
+
"@vaadin/checkbox": "23.0.0-alpha2",
|
|
44
|
+
"@vaadin/component-base": "23.0.0-alpha2",
|
|
45
|
+
"@vaadin/text-field": "23.0.0-alpha2",
|
|
46
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
|
|
47
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha2",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@esm-bundle/chai": "^4.3.4",
|
|
52
|
-
"@vaadin/polymer-legacy-adapter": "
|
|
52
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha2",
|
|
53
53
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
54
54
|
"lit": "^2.0.0",
|
|
55
55
|
"sinon": "^9.2.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
|
|
58
58
|
}
|
|
@@ -22,7 +22,7 @@ function checkPaths(arrayToCheck, action, items) {
|
|
|
22
22
|
|
|
23
23
|
let result = true;
|
|
24
24
|
|
|
25
|
-
for (
|
|
25
|
+
for (const i in arrayToCheck) {
|
|
26
26
|
const path = arrayToCheck[i].path;
|
|
27
27
|
|
|
28
28
|
// skip simple paths
|
|
@@ -73,9 +73,8 @@ function normalizeEmptyValue(value) {
|
|
|
73
73
|
return '';
|
|
74
74
|
} else if (isNaN(value)) {
|
|
75
75
|
return value.toString();
|
|
76
|
-
} else {
|
|
77
|
-
return value;
|
|
78
76
|
}
|
|
77
|
+
return value;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
/**
|
|
@@ -162,7 +162,7 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
|
|
|
162
162
|
const childCountDigits = ~~(Math.log(rootColumns.length) / Math.LN10) + 1;
|
|
163
163
|
|
|
164
164
|
// Final scope for the child columns needs to mind both factors.
|
|
165
|
-
const scope =
|
|
165
|
+
const scope = 10 ** (trailingZeros - childCountDigits);
|
|
166
166
|
|
|
167
167
|
if (_rootColumns[0] && _rootColumns[0]._order) {
|
|
168
168
|
_rootColumns.sort((a, b) => a._order - b._order);
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { addListener } from '@polymer/polymer/lib/utils/gestures.js';
|
|
6
|
+
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
8
7
|
import { updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @polymerMixin
|
|
12
11
|
*/
|
|
13
12
|
export const ColumnReorderingMixin = (superClass) =>
|
|
14
|
-
class ColumnReorderingMixin extends
|
|
13
|
+
class ColumnReorderingMixin extends superClass {
|
|
15
14
|
static get properties() {
|
|
16
15
|
return {
|
|
17
16
|
/**
|
|
@@ -339,9 +338,8 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
339
338
|
const targetRect = targetCell.getBoundingClientRect();
|
|
340
339
|
if (targetRect.left > sourceCellRect.left) {
|
|
341
340
|
return clientX > targetRect.right - sourceCellRect.width;
|
|
342
|
-
} else {
|
|
343
|
-
return clientX < targetRect.left + sourceCellRect.width;
|
|
344
341
|
}
|
|
342
|
+
return clientX < targetRect.left + sourceCellRect.width;
|
|
345
343
|
}
|
|
346
344
|
|
|
347
345
|
/**
|
|
@@ -371,9 +369,8 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
371
369
|
}
|
|
372
370
|
if (candidate.parentElement === draggedColumn.parentElement) {
|
|
373
371
|
return candidate;
|
|
374
|
-
} else {
|
|
375
|
-
return targetCell._column;
|
|
376
372
|
}
|
|
373
|
+
return targetCell._column;
|
|
377
374
|
}
|
|
378
375
|
}
|
|
379
376
|
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { addListener } from '@polymer/polymer/lib/utils/gestures.js';
|
|
6
|
+
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @polymerMixin
|
|
11
10
|
*/
|
|
12
11
|
export const ColumnResizingMixin = (superClass) =>
|
|
13
|
-
class ColumnResizingMixin extends
|
|
12
|
+
class ColumnResizingMixin extends superClass {
|
|
14
13
|
ready() {
|
|
15
14
|
super.ready();
|
|
16
15
|
const scroller = this.$.scroller;
|
|
@@ -30,9 +30,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
30
30
|
const parent = this.parentNode;
|
|
31
31
|
if (parent && parent.localName === 'vaadin-grid-column-group') {
|
|
32
32
|
return parent.resizable || false;
|
|
33
|
-
} else {
|
|
34
|
-
return false;
|
|
35
33
|
}
|
|
34
|
+
return false;
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
|
|
@@ -197,7 +196,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
197
196
|
// Adds the column cells to the grid after the column is attached
|
|
198
197
|
requestAnimationFrame(() => {
|
|
199
198
|
// Skip if the column has been detached
|
|
200
|
-
if (!this._grid)
|
|
199
|
+
if (!this._grid) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
201
202
|
|
|
202
203
|
this._allCells.forEach((cell) => {
|
|
203
204
|
if (!cell._content.parentNode) {
|
|
@@ -214,7 +215,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
214
215
|
// Removes the column cells from the grid after the column is detached
|
|
215
216
|
requestAnimationFrame(() => {
|
|
216
217
|
// Skip if the column has been attached again
|
|
217
|
-
if (this._grid)
|
|
218
|
+
if (this._grid) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
218
221
|
|
|
219
222
|
this._allCells.forEach((cell) => {
|
|
220
223
|
if (cell._content.parentNode) {
|
|
@@ -380,12 +383,10 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
380
383
|
} else if (textAlign === 'end') {
|
|
381
384
|
textAlignFallback = 'right';
|
|
382
385
|
}
|
|
383
|
-
} else {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
textAlignFallback = 'left';
|
|
388
|
-
}
|
|
386
|
+
} else if (textAlign === 'start') {
|
|
387
|
+
textAlignFallback = 'right';
|
|
388
|
+
} else if (textAlign === 'end') {
|
|
389
|
+
textAlignFallback = 'left';
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
this._allCells.forEach((cell) => {
|
|
@@ -450,7 +451,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
450
451
|
cells.forEach((cell) => {
|
|
451
452
|
const model = this._grid.__getRowModel(cell.parentElement);
|
|
452
453
|
|
|
453
|
-
if (!renderer)
|
|
454
|
+
if (!renderer) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
454
457
|
|
|
455
458
|
if (cell._renderer !== renderer) {
|
|
456
459
|
this._clearCellContent(cell);
|
|
@@ -558,7 +561,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
558
561
|
* @protected
|
|
559
562
|
*/
|
|
560
563
|
_defaultHeaderRenderer() {
|
|
561
|
-
if (!this.path)
|
|
564
|
+
if (!this.path) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
562
567
|
|
|
563
568
|
this.__setTextContent(this._headerCell._content, this._generateHeader(this.path));
|
|
564
569
|
}
|
|
@@ -570,7 +575,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
570
575
|
* @protected
|
|
571
576
|
*/
|
|
572
577
|
_defaultRenderer(root, _owner, { item }) {
|
|
573
|
-
if (!this.path)
|
|
578
|
+
if (!this.path) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
574
581
|
|
|
575
582
|
this.__setTextContent(root, this.get(this.path, item));
|
|
576
583
|
}
|
|
@@ -350,10 +350,8 @@ export const DataProviderMixin = (superClass) =>
|
|
|
350
350
|
this.dataProvider(params, (items, size) => {
|
|
351
351
|
if (size !== undefined) {
|
|
352
352
|
cache.size = size;
|
|
353
|
-
} else {
|
|
354
|
-
|
|
355
|
-
cache.size = items.length;
|
|
356
|
-
}
|
|
353
|
+
} else if (params.parentItem) {
|
|
354
|
+
cache.size = items.length;
|
|
357
355
|
}
|
|
358
356
|
|
|
359
357
|
const currentItems = Array.from(this.$.items.children).map((row) => row._item);
|
|
@@ -54,9 +54,8 @@ export const DynamicColumnsMixin = (superClass) =>
|
|
|
54
54
|
.map((col) => {
|
|
55
55
|
if (col.localName === 'vaadin-grid-column-group') {
|
|
56
56
|
return this._getChildColumns(col);
|
|
57
|
-
} else {
|
|
58
|
-
return [col];
|
|
59
57
|
}
|
|
58
|
+
return [col];
|
|
60
59
|
})
|
|
61
60
|
.reduce((prev, curr) => {
|
|
62
61
|
return prev.concat(curr);
|
|
@@ -66,14 +65,12 @@ export const DynamicColumnsMixin = (superClass) =>
|
|
|
66
65
|
/** @private */
|
|
67
66
|
_getColumnTree() {
|
|
68
67
|
const rootColumns = FlattenedNodesObserver.getFlattenedNodes(this).filter(this._isColumnElement);
|
|
69
|
-
const columnTree = [];
|
|
68
|
+
const columnTree = [rootColumns];
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!this._hasColumnGroups(c)) {
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
70
|
+
let c = rootColumns;
|
|
71
|
+
while (this._hasColumnGroups(c)) {
|
|
76
72
|
c = this._flattenColumnGroups(c);
|
|
73
|
+
columnTree.push(c);
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
return columnTree;
|
|
@@ -160,6 +160,8 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
160
160
|
case ' ':
|
|
161
161
|
keyGroup = 'Space';
|
|
162
162
|
break;
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
this._detectInteracting(e);
|
|
@@ -240,28 +242,24 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
240
242
|
if (this.__rowFocusMode) {
|
|
241
243
|
// "If focus is on a row, moves focus to the first row. If focus is in the first row, focus does not move."
|
|
242
244
|
dy = -Infinity;
|
|
245
|
+
} else if (e.ctrlKey) {
|
|
246
|
+
// "If focus is on a cell, moves focus to the first cell in the column. If focus is in the first row, focus does not move."
|
|
247
|
+
dy = -Infinity;
|
|
243
248
|
} else {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
dy = -Infinity;
|
|
247
|
-
} else {
|
|
248
|
-
// "If focus is on a cell, moves focus to the first cell in the row. If focus is in the first cell of the row, focus does not move."
|
|
249
|
-
dx = -Infinity;
|
|
250
|
-
}
|
|
249
|
+
// "If focus is on a cell, moves focus to the first cell in the row. If focus is in the first cell of the row, focus does not move."
|
|
250
|
+
dx = -Infinity;
|
|
251
251
|
}
|
|
252
252
|
break;
|
|
253
253
|
case 'End':
|
|
254
254
|
if (this.__rowFocusMode) {
|
|
255
255
|
// "If focus is on a row, moves focus to the last row. If focus is in the last row, focus does not move."
|
|
256
256
|
dy = Infinity;
|
|
257
|
+
} else if (e.ctrlKey) {
|
|
258
|
+
// "If focus is on a cell, moves focus to the last cell in the column. If focus is in the last row, focus does not move."
|
|
259
|
+
dy = Infinity;
|
|
257
260
|
} else {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
dy = Infinity;
|
|
261
|
-
} else {
|
|
262
|
-
// "If focus is on a cell, moves focus to the last cell in the row. If focus is in the last cell of the row, focus does not move."
|
|
263
|
-
dx = Infinity;
|
|
264
|
-
}
|
|
261
|
+
// "If focus is on a cell, moves focus to the last cell in the row. If focus is in the last cell of the row, focus does not move."
|
|
262
|
+
dx = Infinity;
|
|
265
263
|
}
|
|
266
264
|
break;
|
|
267
265
|
case 'ArrowDown':
|
|
@@ -276,6 +274,8 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
276
274
|
case 'PageUp':
|
|
277
275
|
dy = -visibleItemsCount;
|
|
278
276
|
break;
|
|
277
|
+
default:
|
|
278
|
+
break;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
const activeRow = e.composedPath().find((el) => this.__isRow(el));
|
|
@@ -296,13 +296,12 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
296
296
|
// "If focus is on a collapsed row, expands the row."
|
|
297
297
|
this.expandItem(activeRow._item);
|
|
298
298
|
return;
|
|
299
|
-
} else {
|
|
300
|
-
// "If focus is on an expanded row or is on a row that does not have child rows,
|
|
301
|
-
// moves focus to the first cell in the row."
|
|
302
|
-
this.__rowFocusMode = false;
|
|
303
|
-
this._onCellNavigation(activeRow.firstElementChild, 0, 0);
|
|
304
|
-
return;
|
|
305
299
|
}
|
|
300
|
+
// "If focus is on an expanded row or is on a row that does not have child rows,
|
|
301
|
+
// moves focus to the first cell in the row."
|
|
302
|
+
this.__rowFocusMode = false;
|
|
303
|
+
this._onCellNavigation(activeRow.firstElementChild, 0, 0);
|
|
304
|
+
return;
|
|
306
305
|
}
|
|
307
306
|
} else if (key === backwardsKey) {
|
|
308
307
|
// "Left Arrow:"
|
|
@@ -354,9 +353,8 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
354
353
|
// Body rows have index property, otherwise DOM child index of the row is used.
|
|
355
354
|
if (rowGroup === this.$.items) {
|
|
356
355
|
return bodyFallbackIndex !== undefined ? bodyFallbackIndex : row.index;
|
|
357
|
-
} else {
|
|
358
|
-
return this.__getIndexOfChildElement(row);
|
|
359
356
|
}
|
|
357
|
+
return this.__getIndexOfChildElement(row);
|
|
360
358
|
}
|
|
361
359
|
|
|
362
360
|
/**
|
|
@@ -392,51 +390,47 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
392
390
|
this.toggleAttribute('navigating', true);
|
|
393
391
|
|
|
394
392
|
return { dstRow: activeRowGroup.children[dstRowIndex] };
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
((dy === 1 && dstIsRowDetails) || (dy === -1 && !dstIsRowDetails))
|
|
417
|
-
) {
|
|
418
|
-
dstRowIndex = currentRowIndex;
|
|
419
|
-
}
|
|
393
|
+
}
|
|
394
|
+
// Navigating body rows
|
|
395
|
+
|
|
396
|
+
let dstIsRowDetails = false;
|
|
397
|
+
if (activeCell) {
|
|
398
|
+
const isRowDetails = this.__isDetailsCell(activeCell);
|
|
399
|
+
// Row details navigation logic
|
|
400
|
+
if (activeRowGroup === this.$.items) {
|
|
401
|
+
const item = activeRow._item;
|
|
402
|
+
const dstItem = this._cache.getItemForIndex(dstRowIndex);
|
|
403
|
+
// Should we navigate to row details?
|
|
404
|
+
if (isRowDetails) {
|
|
405
|
+
dstIsRowDetails = dy === 0;
|
|
406
|
+
} else {
|
|
407
|
+
dstIsRowDetails =
|
|
408
|
+
(dy === 1 && this._isDetailsOpened(item)) ||
|
|
409
|
+
(dy === -1 && dstRowIndex !== currentRowIndex && this._isDetailsOpened(dstItem));
|
|
410
|
+
}
|
|
411
|
+
// Should we navigate between details and regular cells of the same row?
|
|
412
|
+
if (dstIsRowDetails !== isRowDetails && ((dy === 1 && dstIsRowDetails) || (dy === -1 && !dstIsRowDetails))) {
|
|
413
|
+
dstRowIndex = currentRowIndex;
|
|
420
414
|
}
|
|
421
415
|
}
|
|
416
|
+
}
|
|
422
417
|
|
|
423
|
-
|
|
424
|
-
|
|
418
|
+
// Ensure correct vertical scroll position, destination row is visible
|
|
419
|
+
this._ensureScrolledToIndex(dstRowIndex);
|
|
425
420
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
421
|
+
// When scrolling with repeated keydown, sometimes FocusEvent listeners
|
|
422
|
+
// are too late to update _focusedItemIndex. Ensure next keydown
|
|
423
|
+
// listener invocation gets updated _focusedItemIndex value.
|
|
424
|
+
this._focusedItemIndex = dstRowIndex;
|
|
430
425
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
426
|
+
// This has to be set after scrolling, otherwise it can be removed by
|
|
427
|
+
// `_preventScrollerRotatingCellFocus(row, index)` during scrolling.
|
|
428
|
+
this.toggleAttribute('navigating', true);
|
|
434
429
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
430
|
+
return {
|
|
431
|
+
dstRow: [...activeRowGroup.children].find((el) => !el.hidden && el.index === dstRowIndex),
|
|
432
|
+
dstIsRowDetails
|
|
433
|
+
};
|
|
440
434
|
}
|
|
441
435
|
|
|
442
436
|
/**
|
|
@@ -499,7 +493,10 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
499
493
|
this._focusedColumnOrder = undefined;
|
|
500
494
|
}
|
|
501
495
|
|
|
502
|
-
const columnIndexByOrder = dstColumns.reduce((acc, col, i) =>
|
|
496
|
+
const columnIndexByOrder = dstColumns.reduce((acc, col, i) => {
|
|
497
|
+
acc[col._order] = i;
|
|
498
|
+
return acc;
|
|
499
|
+
}, {});
|
|
503
500
|
const dstColumnIndex = columnIndexByOrder[dstSortedColumnOrders[dstOrderedColumnIndex]];
|
|
504
501
|
const dstCell = dstRow.children[dstColumnIndex];
|
|
505
502
|
|
|
@@ -526,6 +523,8 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
526
523
|
case 'F2':
|
|
527
524
|
wantInteracting = !this.interacting;
|
|
528
525
|
break;
|
|
526
|
+
default:
|
|
527
|
+
break;
|
|
529
528
|
}
|
|
530
529
|
|
|
531
530
|
const { cell } = this._getGridEventLocation(e);
|
|
@@ -730,7 +729,9 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
730
729
|
* @param {HTMLElement} focusTarget
|
|
731
730
|
*/
|
|
732
731
|
_updateGridSectionFocusTarget(focusTarget) {
|
|
733
|
-
if (!focusTarget)
|
|
732
|
+
if (!focusTarget) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
734
735
|
|
|
735
736
|
const section = this._getGridSectionFromFocusTarget(focusTarget);
|
|
736
737
|
const isInteractingWithinActiveSection = this.interacting && section === this._activeRowGroup;
|
|
@@ -888,9 +889,15 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
888
889
|
* @private
|
|
889
890
|
*/
|
|
890
891
|
_getGridSectionFromFocusTarget(focusTarget) {
|
|
891
|
-
if (focusTarget === this._headerFocusable)
|
|
892
|
-
|
|
893
|
-
|
|
892
|
+
if (focusTarget === this._headerFocusable) {
|
|
893
|
+
return this.$.header;
|
|
894
|
+
}
|
|
895
|
+
if (focusTarget === this._itemsFocusable) {
|
|
896
|
+
return this.$.items;
|
|
897
|
+
}
|
|
898
|
+
if (focusTarget === this._footerFocusable) {
|
|
899
|
+
return this.$.footer;
|
|
900
|
+
}
|
|
894
901
|
return null;
|
|
895
902
|
}
|
|
896
903
|
|
|
@@ -106,7 +106,6 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
106
106
|
// Re-renders the row to open the details when a row details renderer is provided.
|
|
107
107
|
if (rowDetailsRenderer && this._isDetailsOpened(row._item)) {
|
|
108
108
|
this._updateItem(row, row._item);
|
|
109
|
-
return;
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
}
|
|
@@ -31,6 +31,11 @@ export const ScrollMixin = (superClass) =>
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** @private */
|
|
35
|
+
get _scrollTop() {
|
|
36
|
+
return this.$.table.scrollTop;
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
/**
|
|
35
40
|
* Override (from iron-scroll-target-behavior) to avoid document scroll
|
|
36
41
|
* @private
|
|
@@ -39,11 +44,6 @@ export const ScrollMixin = (superClass) =>
|
|
|
39
44
|
this.$.table.scrollTop = top;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
/** @private */
|
|
43
|
-
get _scrollTop() {
|
|
44
|
-
return this.$.table.scrollTop;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
47
|
/** @private */
|
|
48
48
|
get _scrollLeft() {
|
|
49
49
|
return this.$.table.scrollLeft;
|
|
@@ -88,15 +88,13 @@ export const SortMixin = (superClass) =>
|
|
|
88
88
|
this._sorters.unshift(sorter);
|
|
89
89
|
}
|
|
90
90
|
this.__updateSortOrders();
|
|
91
|
-
} else {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
99
|
-
}
|
|
91
|
+
} else if (sorter.direction) {
|
|
92
|
+
const otherSorters = this._sorters.filter((s) => s != sorter);
|
|
93
|
+
this._sorters = [sorter];
|
|
94
|
+
otherSorters.forEach((sorter) => {
|
|
95
|
+
sorter._order = null;
|
|
96
|
+
sorter.direction = null;
|
|
97
|
+
});
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
|
package/src/vaadin-grid.d.ts
CHANGED
|
@@ -253,20 +253,16 @@ export interface GridEventMap<TItem> extends HTMLElementEventMap, GridCustomEven
|
|
|
253
253
|
* in the second argument of the data provider callback:__
|
|
254
254
|
*
|
|
255
255
|
* ```javascript
|
|
256
|
-
* grid.dataProvider =
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* );
|
|
267
|
-
* };
|
|
268
|
-
* xhr.open('GET', url, true);
|
|
269
|
-
* xhr.send();
|
|
256
|
+
* grid.dataProvider = ({page, pageSize}, callback) => {
|
|
257
|
+
* // page: the requested page index
|
|
258
|
+
* // pageSize: number of items on one page
|
|
259
|
+
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;
|
|
260
|
+
*
|
|
261
|
+
* fetch(url)
|
|
262
|
+
* .then((res) => res.json())
|
|
263
|
+
* .then(({ employees, totalSize }) => {
|
|
264
|
+
* callback(employees, totalSize);
|
|
265
|
+
* });
|
|
270
266
|
* };
|
|
271
267
|
* ```
|
|
272
268
|
*
|
|
@@ -274,17 +270,12 @@ export interface GridEventMap<TItem> extends HTMLElementEventMap, GridCustomEven
|
|
|
274
270
|
*
|
|
275
271
|
* ```javascript
|
|
276
272
|
* grid.size = 200; // The total number of items
|
|
277
|
-
* grid.dataProvider =
|
|
278
|
-
* const url =
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* const response = JSON.parse(xhr.responseText);
|
|
284
|
-
* callback(response.employees);
|
|
285
|
-
* };
|
|
286
|
-
* xhr.open('GET', url, true);
|
|
287
|
-
* xhr.send();
|
|
273
|
+
* grid.dataProvider = ({page, pageSize}, callback) => {
|
|
274
|
+
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;
|
|
275
|
+
*
|
|
276
|
+
* fetch(url)
|
|
277
|
+
* .then((res) => res.json())
|
|
278
|
+
* .then((resJson) => callback(resJson.employees));
|
|
288
279
|
* };
|
|
289
280
|
* ```
|
|
290
281
|
*
|
package/src/vaadin-grid.js
CHANGED
|
@@ -139,20 +139,16 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
|
|
|
139
139
|
* in the second argument of the data provider callback:__
|
|
140
140
|
*
|
|
141
141
|
* ```javascript
|
|
142
|
-
* grid.dataProvider =
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* );
|
|
153
|
-
* };
|
|
154
|
-
* xhr.open('GET', url, true);
|
|
155
|
-
* xhr.send();
|
|
142
|
+
* grid.dataProvider = ({page, pageSize}, callback) => {
|
|
143
|
+
* // page: the requested page index
|
|
144
|
+
* // pageSize: number of items on one page
|
|
145
|
+
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;
|
|
146
|
+
*
|
|
147
|
+
* fetch(url)
|
|
148
|
+
* .then((res) => res.json())
|
|
149
|
+
* .then(({ employees, totalSize }) => {
|
|
150
|
+
* callback(employees, totalSize);
|
|
151
|
+
* });
|
|
156
152
|
* };
|
|
157
153
|
* ```
|
|
158
154
|
*
|
|
@@ -160,17 +156,12 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
|
|
|
160
156
|
*
|
|
161
157
|
* ```javascript
|
|
162
158
|
* grid.size = 200; // The total number of items
|
|
163
|
-
* grid.dataProvider =
|
|
164
|
-
* const url =
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* const response = JSON.parse(xhr.responseText);
|
|
170
|
-
* callback(response.employees);
|
|
171
|
-
* };
|
|
172
|
-
* xhr.open('GET', url, true);
|
|
173
|
-
* xhr.send();
|
|
159
|
+
* grid.dataProvider = ({page, pageSize}, callback) => {
|
|
160
|
+
* const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;
|
|
161
|
+
*
|
|
162
|
+
* fetch(url)
|
|
163
|
+
* .then((res) => res.json())
|
|
164
|
+
* .then((resJson) => callback(resJson.employees));
|
|
174
165
|
* };
|
|
175
166
|
* ```
|
|
176
167
|
*
|
|
@@ -552,7 +543,9 @@ class Grid extends ElementMixin(
|
|
|
552
543
|
|
|
553
544
|
/** @private */
|
|
554
545
|
__getDistributedWidth(col, innerColumn) {
|
|
555
|
-
if (col == null || col === this)
|
|
546
|
+
if (col == null || col === this) {
|
|
547
|
+
return 0;
|
|
548
|
+
}
|
|
556
549
|
|
|
557
550
|
const columnWidth = Math.max(this.__getIntrinsicWidth(col), this.__getDistributedWidth(col.parentElement, col));
|
|
558
551
|
|
|
@@ -694,6 +687,7 @@ class Grid extends ElementMixin(
|
|
|
694
687
|
* @param {boolean} noNotify
|
|
695
688
|
* @protected
|
|
696
689
|
*/
|
|
690
|
+
// eslint-disable-next-line max-params
|
|
697
691
|
_updateRow(row, columns, section, isColumnRow, noNotify) {
|
|
698
692
|
section = section || 'body';
|
|
699
693
|
|
|
@@ -802,13 +796,12 @@ class Grid extends ElementMixin(
|
|
|
802
796
|
// -> row should be visible
|
|
803
797
|
return true;
|
|
804
798
|
}
|
|
805
|
-
} else {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
return true;
|
|
810
|
-
}
|
|
799
|
+
} else if (column.footerRenderer) {
|
|
800
|
+
// The cell is the footer cell of a column that has a footer renderer
|
|
801
|
+
// -> row should be visible
|
|
802
|
+
return true;
|
|
811
803
|
}
|
|
804
|
+
return false;
|
|
812
805
|
});
|
|
813
806
|
|
|
814
807
|
if (row.hidden !== !visibleRowCells.length) {
|