@vaadin/grid 24.0.0-alpha4 → 24.0.0-alpha5
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 +10 -10
- package/src/vaadin-grid-a11y-mixin.js +11 -8
- package/src/vaadin-grid-active-item-mixin.js +4 -1
- package/src/vaadin-grid-column-reordering-mixin.js +5 -5
- package/src/vaadin-grid-column.js +19 -5
- package/src/vaadin-grid-data-provider-mixin.js +23 -6
- package/src/vaadin-grid-drag-and-drop-mixin.js +18 -16
- package/src/vaadin-grid-dynamic-columns-mixin.js +3 -2
- package/src/vaadin-grid-helpers.js +103 -0
- package/src/vaadin-grid-keyboard-navigation-mixin.js +5 -0
- package/src/vaadin-grid-row-details-mixin.js +4 -3
- package/src/vaadin-grid-styles.js +4 -0
- package/src/vaadin-grid-styling-mixin.d.ts +37 -1
- package/src/vaadin-grid-styling-mixin.js +77 -5
- package/src/vaadin-grid.d.ts +83 -50
- package/src/vaadin-grid.js +127 -95
- package/web-types.json +15 -4
- package/web-types.lit.json +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
48
48
|
"@polymer/polymer": "^3.0.0",
|
|
49
|
-
"@vaadin/checkbox": "24.0.0-
|
|
50
|
-
"@vaadin/component-base": "24.0.0-
|
|
51
|
-
"@vaadin/lit-renderer": "24.0.0-
|
|
52
|
-
"@vaadin/text-field": "24.0.0-
|
|
53
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
54
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
55
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
49
|
+
"@vaadin/checkbox": "24.0.0-alpha5",
|
|
50
|
+
"@vaadin/component-base": "24.0.0-alpha5",
|
|
51
|
+
"@vaadin/lit-renderer": "24.0.0-alpha5",
|
|
52
|
+
"@vaadin/text-field": "24.0.0-alpha5",
|
|
53
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha5",
|
|
54
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha5",
|
|
55
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@esm-bundle/chai": "^4.3.4",
|
|
59
|
-
"@vaadin/polymer-legacy-adapter": "24.0.0-
|
|
59
|
+
"@vaadin/polymer-legacy-adapter": "24.0.0-alpha5",
|
|
60
60
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
61
61
|
"lit": "^2.0.0",
|
|
62
62
|
"sinon": "^13.0.2"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"web-types.json",
|
|
66
66
|
"web-types.lit.json"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "fc0b1721eda9e39cb289b239e440fc9e29573a31"
|
|
69
69
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { iterateChildren } from './vaadin-grid-helpers.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @polymerMixin
|
|
@@ -42,16 +43,16 @@ export const A11yMixin = (superClass) =>
|
|
|
42
43
|
|
|
43
44
|
/** @protected */
|
|
44
45
|
_a11yUpdateHeaderRows() {
|
|
45
|
-
|
|
46
|
-
headerRow.setAttribute('aria-rowindex', index + 1)
|
|
47
|
-
);
|
|
46
|
+
iterateChildren(this.$.header, (headerRow, index) => {
|
|
47
|
+
headerRow.setAttribute('aria-rowindex', index + 1);
|
|
48
|
+
});
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/** @protected */
|
|
51
52
|
_a11yUpdateFooterRows() {
|
|
52
|
-
|
|
53
|
-
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1)
|
|
54
|
-
);
|
|
53
|
+
iterateChildren(this.$.footer, (footerRow, index) => {
|
|
54
|
+
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1);
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -71,7 +72,9 @@ export const A11yMixin = (superClass) =>
|
|
|
71
72
|
_a11yUpdateRowSelected(row, selected) {
|
|
72
73
|
// Jaws reads selection only for rows, NVDA only for cells
|
|
73
74
|
row.setAttribute('aria-selected', Boolean(selected));
|
|
74
|
-
|
|
75
|
+
iterateChildren(row, (cell) => {
|
|
76
|
+
cell.setAttribute('aria-selected', Boolean(selected));
|
|
77
|
+
});
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
/**
|
|
@@ -108,7 +111,7 @@ export const A11yMixin = (superClass) =>
|
|
|
108
111
|
* @protected
|
|
109
112
|
*/
|
|
110
113
|
_a11ySetRowDetailsCell(row, detailsCell) {
|
|
111
|
-
|
|
114
|
+
iterateChildren(row, (cell) => {
|
|
112
115
|
if (cell !== detailsCell) {
|
|
113
116
|
cell.setAttribute('aria-controls', detailsCell.id);
|
|
114
117
|
}
|
|
@@ -111,7 +111,10 @@ export const isFocusable = (target) => {
|
|
|
111
111
|
target.parentNode.querySelectorAll(
|
|
112
112
|
'[tabindex], button, input, select, textarea, object, iframe, label, a[href], area[href]',
|
|
113
113
|
),
|
|
114
|
-
).filter((element) =>
|
|
114
|
+
).filter((element) => {
|
|
115
|
+
const part = element.getAttribute('part');
|
|
116
|
+
return !(part && part.includes('body-cell'));
|
|
117
|
+
});
|
|
115
118
|
|
|
116
119
|
const isFocusableElement = focusables.includes(target);
|
|
117
120
|
return !target.disabled && isFocusableElement;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
7
|
-
import { updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
7
|
+
import { iterateChildren, updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @polymerMixin
|
|
@@ -304,11 +304,11 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
304
304
|
* @protected
|
|
305
305
|
*/
|
|
306
306
|
_setSiblingsReorderStatus(column, status) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
.forEach((sibling) => {
|
|
307
|
+
iterateChildren(column.parentNode, (sibling) => {
|
|
308
|
+
if (/column/.test(sibling.localName) && this._isSwapAllowed(sibling, column)) {
|
|
310
309
|
sibling._reorderStatus = status;
|
|
311
|
-
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
/** @protected */
|
|
@@ -8,6 +8,7 @@ import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
|
8
8
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
9
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
10
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
11
|
+
import { updateCellState } from './vaadin-grid-helpers.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @polymerMixin
|
|
@@ -341,7 +342,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
341
342
|
this.parentElement._columnPropChanged('frozen', frozen);
|
|
342
343
|
}
|
|
343
344
|
|
|
344
|
-
this._allCells.forEach((cell) =>
|
|
345
|
+
this._allCells.forEach((cell) => {
|
|
346
|
+
updateCellState(cell, 'frozen', frozen);
|
|
347
|
+
});
|
|
345
348
|
|
|
346
349
|
if (this._grid && this._grid._frozenCellsChanged) {
|
|
347
350
|
this._grid._frozenCellsChanged();
|
|
@@ -359,7 +362,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
359
362
|
if (this._grid && cell.parentElement === this._grid.$.sizer) {
|
|
360
363
|
return;
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
|
|
366
|
+
updateCellState(cell, 'frozen-to-end', frozenToEnd);
|
|
363
367
|
});
|
|
364
368
|
|
|
365
369
|
if (this._grid && this._grid._frozenCellsChanged) {
|
|
@@ -369,7 +373,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
369
373
|
|
|
370
374
|
/** @private */
|
|
371
375
|
_lastFrozenChanged(lastFrozen) {
|
|
372
|
-
this._allCells.forEach((cell) =>
|
|
376
|
+
this._allCells.forEach((cell) => {
|
|
377
|
+
updateCellState(cell, 'last-frozen', lastFrozen);
|
|
378
|
+
});
|
|
373
379
|
|
|
374
380
|
if (this.parentElement && this.parentElement._columnPropChanged) {
|
|
375
381
|
this.parentElement._lastFrozen = lastFrozen;
|
|
@@ -384,7 +390,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
384
390
|
return;
|
|
385
391
|
}
|
|
386
392
|
|
|
387
|
-
cell
|
|
393
|
+
updateCellState(cell, 'first-frozen-to-end', firstFrozenToEnd);
|
|
388
394
|
});
|
|
389
395
|
|
|
390
396
|
if (this.parentElement && this.parentElement._columnPropChanged) {
|
|
@@ -408,7 +414,15 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
408
414
|
|
|
409
415
|
/** @private */
|
|
410
416
|
_reorderStatusChanged(reorderStatus) {
|
|
411
|
-
|
|
417
|
+
const prevStatus = this.__previousReorderStatus;
|
|
418
|
+
const oldPart = prevStatus ? `reorder-${prevStatus}-cell` : '';
|
|
419
|
+
const newPart = `reorder-${reorderStatus}-cell`;
|
|
420
|
+
|
|
421
|
+
this._allCells.forEach((cell) => {
|
|
422
|
+
updateCellState(cell, 'reorder-status', reorderStatus, newPart, oldPart);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
this.__previousReorderStatus = reorderStatus;
|
|
412
426
|
}
|
|
413
427
|
|
|
414
428
|
/** @private */
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
7
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
8
|
+
import { getBodyRowCells, iterateChildren, updateCellsPart, updateState } from './vaadin-grid-helpers.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @private
|
|
@@ -260,17 +261,32 @@ export const DataProviderMixin = (superClass) =>
|
|
|
260
261
|
const { cache, scaledIndex } = this._cache.getCacheAndIndex(index);
|
|
261
262
|
const item = cache.items[scaledIndex];
|
|
262
263
|
if (item) {
|
|
263
|
-
|
|
264
|
+
this.__updateLoading(el, false);
|
|
264
265
|
this._updateItem(el, item);
|
|
265
266
|
if (this._isExpanded(item)) {
|
|
266
267
|
cache.ensureSubCacheForScaledIndex(scaledIndex);
|
|
267
268
|
}
|
|
268
269
|
} else {
|
|
269
|
-
|
|
270
|
+
this.__updateLoading(el, true);
|
|
270
271
|
this._loadPage(this._getPageForIndex(scaledIndex), cache);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
/**
|
|
276
|
+
* @param {!HTMLElement} row
|
|
277
|
+
* @param {boolean} loading
|
|
278
|
+
* @private
|
|
279
|
+
*/
|
|
280
|
+
__updateLoading(row, loading) {
|
|
281
|
+
const cells = getBodyRowCells(row);
|
|
282
|
+
|
|
283
|
+
// Row state attribute
|
|
284
|
+
updateState(row, 'loading', loading);
|
|
285
|
+
|
|
286
|
+
// Cells part attribute
|
|
287
|
+
updateCellsPart(cells, 'loading-row-cell', loading);
|
|
288
|
+
}
|
|
289
|
+
|
|
274
290
|
/**
|
|
275
291
|
* Returns a value that identifies the item. Uses `itemIdPath` if available.
|
|
276
292
|
* Can be customized by overriding.
|
|
@@ -389,14 +405,14 @@ export const DataProviderMixin = (superClass) =>
|
|
|
389
405
|
this._cache.updateSize();
|
|
390
406
|
this._effectiveSize = this._cache.effectiveSize;
|
|
391
407
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
.forEach((row) => {
|
|
408
|
+
iterateChildren(this.$.items, (row) => {
|
|
409
|
+
if (!row.hidden) {
|
|
395
410
|
const cachedItem = this._cache.getItemForIndex(row.index);
|
|
396
411
|
if (cachedItem) {
|
|
397
412
|
this._getItem(row.index, row);
|
|
398
413
|
}
|
|
399
|
-
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
400
416
|
|
|
401
417
|
this.__scrollToPendingIndex();
|
|
402
418
|
});
|
|
@@ -510,6 +526,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
510
526
|
}
|
|
511
527
|
}
|
|
512
528
|
|
|
529
|
+
/** @private */
|
|
513
530
|
__scrollToPendingIndex() {
|
|
514
531
|
if (this.__pendingScrollToIndex && this.$.items.children.length) {
|
|
515
532
|
const index = this.__pendingScrollToIndex;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { iterateChildren, updateRowStates } from './vaadin-grid-helpers.js';
|
|
7
|
+
|
|
6
8
|
const DropMode = {
|
|
7
9
|
BETWEEN: 'between',
|
|
8
10
|
ON_TOP: 'on-top',
|
|
@@ -154,12 +156,12 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
154
156
|
// Set the default transfer data
|
|
155
157
|
e.dataTransfer.setData('text', this.__formatDefaultTransferData(rows));
|
|
156
158
|
|
|
157
|
-
|
|
159
|
+
updateRowStates(row, { dragstart: rows.length > 1 ? `${rows.length}` : '' });
|
|
158
160
|
this.style.setProperty('--_grid-drag-start-x', `${e.clientX - rowRect.left + 20}px`);
|
|
159
161
|
this.style.setProperty('--_grid-drag-start-y', `${e.clientY - rowRect.top + 10}px`);
|
|
160
162
|
|
|
161
163
|
requestAnimationFrame(() => {
|
|
162
|
-
|
|
164
|
+
updateRowStates(row, { dragstart: null });
|
|
163
165
|
this.style.setProperty('--_grid-drag-start-x', '');
|
|
164
166
|
this.style.setProperty('--_grid-drag-start-y', '');
|
|
165
167
|
});
|
|
@@ -253,7 +255,7 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
253
255
|
} else if (row) {
|
|
254
256
|
this._dragOverItem = row._item;
|
|
255
257
|
if (row.getAttribute('dragover') !== this._dropLocation) {
|
|
256
|
-
|
|
258
|
+
updateRowStates(row, { dragover: this._dropLocation }, true);
|
|
257
259
|
}
|
|
258
260
|
} else {
|
|
259
261
|
this._clearDragStyles();
|
|
@@ -307,8 +309,8 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
307
309
|
/** @protected */
|
|
308
310
|
_clearDragStyles() {
|
|
309
311
|
this.removeAttribute('dragover');
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
iterateChildren(this.$.items, (row) => {
|
|
313
|
+
updateRowStates(row, { dragover: null }, true);
|
|
312
314
|
});
|
|
313
315
|
}
|
|
314
316
|
|
|
@@ -371,11 +373,11 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
371
373
|
* the conditions change.
|
|
372
374
|
*/
|
|
373
375
|
filterDragAndDrop() {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
.forEach((row) => {
|
|
376
|
+
iterateChildren(this.$.items, (row) => {
|
|
377
|
+
if (!row.hidden) {
|
|
377
378
|
this._filterDragAndDrop(row, this.__getRowModel(row));
|
|
378
|
-
}
|
|
379
|
+
}
|
|
380
|
+
});
|
|
379
381
|
}
|
|
380
382
|
|
|
381
383
|
/**
|
|
@@ -388,18 +390,18 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
388
390
|
const dragDisabled = !this.rowsDraggable || loading || (this.dragFilter && !this.dragFilter(model));
|
|
389
391
|
const dropDisabled = !this.dropMode || loading || (this.dropFilter && !this.dropFilter(model));
|
|
390
392
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
draggableElements.forEach((e) => {
|
|
393
|
+
iterateChildren(row, (cell) => {
|
|
394
394
|
if (dragDisabled) {
|
|
395
|
-
|
|
395
|
+
cell._content.removeAttribute('draggable');
|
|
396
396
|
} else {
|
|
397
|
-
|
|
397
|
+
cell._content.setAttribute('draggable', true);
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
401
|
+
updateRowStates(row, {
|
|
402
|
+
'drag-disabled': !!dragDisabled,
|
|
403
|
+
'drop-disabled': !!dropDisabled,
|
|
404
|
+
});
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
/**
|
|
@@ -7,6 +7,7 @@ import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nod
|
|
|
7
7
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
8
|
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
9
9
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
10
|
+
import { updateCellState } from './vaadin-grid-helpers.js';
|
|
10
11
|
|
|
11
12
|
function arrayEquals(arr1, arr2) {
|
|
12
13
|
if (!arr1 || !arr2 || arr1.length !== arr2.length) {
|
|
@@ -160,8 +161,8 @@ export const DynamicColumnsMixin = (superClass) =>
|
|
|
160
161
|
return a._column._order - b._column._order;
|
|
161
162
|
})
|
|
162
163
|
.forEach((cell, cellIndex, children) => {
|
|
163
|
-
cell
|
|
164
|
-
cell
|
|
164
|
+
updateCellState(cell, 'first-column', cellIndex === 0);
|
|
165
|
+
updateCellState(cell, 'last-column', cellIndex === children.length - 1);
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {HTMLTableRowElement} row the table row
|
|
10
|
+
* @return {HTMLTableCellElement[]} array of cells
|
|
11
|
+
*/
|
|
12
|
+
export function getBodyRowCells(row) {
|
|
13
|
+
return Array.from(row.querySelectorAll('[part~="cell"]:not([part~="details-cell"])'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {HTMLElement} container the DOM element with children
|
|
18
|
+
* @param {Function} callback function to call on each child
|
|
19
|
+
*/
|
|
20
|
+
export function iterateChildren(container, callback) {
|
|
21
|
+
[...container.children].forEach(callback);
|
|
22
|
+
}
|
|
6
23
|
|
|
7
24
|
/**
|
|
8
25
|
* @param {Array<Object>} columns array of columns to be modified
|
|
@@ -21,3 +38,89 @@ export function updateColumnOrders(columns, scope, baseOrder) {
|
|
|
21
38
|
c += 1;
|
|
22
39
|
});
|
|
23
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {!HTMLElement} element
|
|
44
|
+
* @param {string} attribute
|
|
45
|
+
* @param {boolean | string | null | undefined} value
|
|
46
|
+
*/
|
|
47
|
+
export function updateState(element, attribute, value) {
|
|
48
|
+
switch (typeof value) {
|
|
49
|
+
case 'boolean':
|
|
50
|
+
element.toggleAttribute(attribute, value);
|
|
51
|
+
break;
|
|
52
|
+
case 'string':
|
|
53
|
+
element.setAttribute(attribute, value);
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
// Value set to null / undefined
|
|
57
|
+
element.removeAttribute(attribute);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {!HTMLElement} element
|
|
64
|
+
* @param {boolean | string | null | undefined} value
|
|
65
|
+
* @param {string} part
|
|
66
|
+
*/
|
|
67
|
+
export function updatePart(element, value, part) {
|
|
68
|
+
if (value || value === '') {
|
|
69
|
+
addValueToAttribute(element, 'part', part);
|
|
70
|
+
} else {
|
|
71
|
+
removeValueFromAttribute(element, 'part', part);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {HTMLTableCellElement[]} cells
|
|
77
|
+
* @param {string} part
|
|
78
|
+
* @param {boolean | string | null | undefined} value
|
|
79
|
+
*/
|
|
80
|
+
export function updateCellsPart(cells, part, value) {
|
|
81
|
+
cells.forEach((cell) => {
|
|
82
|
+
updatePart(cell, value, part);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {!HTMLElement} row
|
|
88
|
+
* @param {Object} states
|
|
89
|
+
* @param {boolean} appendValue
|
|
90
|
+
*/
|
|
91
|
+
export function updateRowStates(row, states, appendValue) {
|
|
92
|
+
const cells = getBodyRowCells(row);
|
|
93
|
+
|
|
94
|
+
Object.entries(states).forEach(([state, value]) => {
|
|
95
|
+
// Row state attribute
|
|
96
|
+
updateState(row, state, value);
|
|
97
|
+
|
|
98
|
+
const rowPart = appendValue ? `${state}-${value}-row` : `${state}-row`;
|
|
99
|
+
|
|
100
|
+
// Row part attribute
|
|
101
|
+
updatePart(row, value, rowPart);
|
|
102
|
+
|
|
103
|
+
// Cells part attribute
|
|
104
|
+
updateCellsPart(cells, `${rowPart}-cell`, value);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {!HTMLElement} cell
|
|
110
|
+
* @param {string} attribute
|
|
111
|
+
* @param {boolean | string | null | undefined} value
|
|
112
|
+
* @param {string} part
|
|
113
|
+
* @param {?string} oldPart
|
|
114
|
+
*/
|
|
115
|
+
export function updateCellState(cell, attribute, value, part, oldPart) {
|
|
116
|
+
// Toggle state attribute on the cell
|
|
117
|
+
updateState(cell, attribute, value);
|
|
118
|
+
|
|
119
|
+
// Remove old part from the attribute
|
|
120
|
+
if (oldPart) {
|
|
121
|
+
updatePart(cell, false, oldPart);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Add new part to the cell attribute
|
|
125
|
+
updatePart(cell, value, part || `${attribute}-cell`);
|
|
126
|
+
}
|
|
@@ -781,6 +781,11 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
781
781
|
/** @private */
|
|
782
782
|
_onContentFocusIn(e) {
|
|
783
783
|
const { section, cell, row } = this._getGridEventLocation(e);
|
|
784
|
+
|
|
785
|
+
if (!cell && !this.__rowFocusMode) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
|
|
784
789
|
this._detectInteracting(e);
|
|
785
790
|
|
|
786
791
|
if (section && (cell || row)) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { iterateChildren } from './vaadin-grid-helpers.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @polymerMixin
|
|
@@ -78,7 +79,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
78
79
|
|
|
79
80
|
if (this._columnTree) {
|
|
80
81
|
// Only update the rows if the column tree has already been initialized
|
|
81
|
-
|
|
82
|
+
iterateChildren(this.$.items, (row) => {
|
|
82
83
|
if (!row.querySelector('[part~=details-cell]')) {
|
|
83
84
|
this._updateRow(row, this._columnTree[this._columnTree.length - 1]);
|
|
84
85
|
const isDetailsOpened = this._isDetailsOpened(row._item);
|
|
@@ -95,7 +96,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
iterateChildren(this.$.items, (row) => {
|
|
99
100
|
// Re-renders the row to possibly close the previously opened details.
|
|
100
101
|
if (row.hasAttribute('details-opened')) {
|
|
101
102
|
this._updateItem(row, row._item);
|
|
@@ -162,7 +163,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
162
163
|
|
|
163
164
|
/** @protected */
|
|
164
165
|
_updateDetailsCellHeights() {
|
|
165
|
-
|
|
166
|
+
iterateChildren(this.$.items, (row) => {
|
|
166
167
|
this._updateDetailsCellHeight(row);
|
|
167
168
|
});
|
|
168
169
|
}
|
|
@@ -248,6 +248,10 @@ registerStyles(
|
|
|
248
248
|
transform: none;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
[first-frozen-to-end] {
|
|
252
|
+
margin-inline-start: auto;
|
|
253
|
+
}
|
|
254
|
+
|
|
251
255
|
/* Hide resize handle if scrolled to end */
|
|
252
256
|
:host(:not([overflow~='end'])) [first-frozen-to-end] [part~='resize-handle'] {
|
|
253
257
|
display: none;
|
|
@@ -7,7 +7,12 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
|
7
7
|
import type { GridItemModel } from './vaadin-grid.js';
|
|
8
8
|
import type { GridColumn } from './vaadin-grid-column.js';
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type GridCellPartNameGenerator<TItem> = (column: GridColumn<TItem>, model: GridItemModel<TItem>) => string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `GridPartCellGenerator` type and `cellPartNameGenerator` API instead.
|
|
14
|
+
*/
|
|
15
|
+
export type GridCellClassNameGenerator<TItem> = GridCellPartNameGenerator<TItem>;
|
|
11
16
|
|
|
12
17
|
export declare function StylingMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
13
18
|
base: T,
|
|
@@ -29,14 +34,45 @@ export declare class StylingMixinClass<TItem> {
|
|
|
29
34
|
* - `model.expanded` Sublevel toggle state.
|
|
30
35
|
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
31
36
|
* - `model.selected` Selected state.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use `cellPartNameGenerator` instead.
|
|
32
39
|
*/
|
|
33
40
|
cellClassNameGenerator: GridCellClassNameGenerator<TItem> | null | undefined;
|
|
34
41
|
|
|
42
|
+
/**
|
|
43
|
+
* A function that allows generating CSS `part` names for grid cells in Shadow DOM based
|
|
44
|
+
* on their row and column, for styling from outside using the `::part()` selector.
|
|
45
|
+
*
|
|
46
|
+
* The return value should be the generated part name as a string, or multiple part names
|
|
47
|
+
* separated by whitespace characters.
|
|
48
|
+
*
|
|
49
|
+
* Receives two arguments:
|
|
50
|
+
* - `column` The `<vaadin-grid-column>` element (`undefined` for details-cell).
|
|
51
|
+
* - `model` The object with the properties related with
|
|
52
|
+
* the rendered item, contains:
|
|
53
|
+
* - `model.index` The index of the item.
|
|
54
|
+
* - `model.item` The item.
|
|
55
|
+
* - `model.expanded` Sublevel toggle state.
|
|
56
|
+
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
57
|
+
* - `model.selected` Selected state.
|
|
58
|
+
*/
|
|
59
|
+
cellPartNameGenerator: GridCellPartNameGenerator<TItem> | null | undefined;
|
|
60
|
+
|
|
35
61
|
/**
|
|
36
62
|
* Runs the `cellClassNameGenerator` for the visible cells.
|
|
37
63
|
* If the generator depends on varying conditions, you need to
|
|
38
64
|
* call this function manually in order to update the styles when
|
|
39
65
|
* the conditions change.
|
|
66
|
+
*
|
|
67
|
+
* @deprecated Use `cellPartNameGenerator` and `generateCellPartNames()` instead.
|
|
40
68
|
*/
|
|
41
69
|
generateCellClassNames(): void;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Runs the `cellPastNameGenerator` for the visible cells.
|
|
73
|
+
* If the generator depends on varying conditions, you need to
|
|
74
|
+
* call this function manually in order to update the styles when
|
|
75
|
+
* the conditions change.
|
|
76
|
+
*/
|
|
77
|
+
generateCellPartNames(): void;
|
|
42
78
|
}
|