@vaadin/grid 25.4.0-alpha6 → 25.4.0-alpha7
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 +12 -12
- package/src/directives/body-cell-directive.js +43 -0
- package/src/directives/body-row-directive.js +36 -0
- package/src/directives/cell-content-directive.js +11 -2
- package/src/directives/details-cell-directive.js +32 -0
- package/src/directives/sizer-cell-directive.js +33 -0
- package/src/vaadin-grid-a11y-mixin.js +0 -22
- package/src/vaadin-grid-body-rendering-mixin.js +189 -5
- package/src/vaadin-grid-column-mixin.js +4 -44
- package/src/vaadin-grid-column-reordering-mixin.js +5 -17
- package/src/vaadin-grid-dynamic-columns-mixin.js +1 -12
- package/src/vaadin-grid-header-footer-rendering-mixin.js +3 -16
- package/src/vaadin-grid-mixin.js +41 -204
- package/src/vaadin-grid-row-details-mixin.js +15 -56
- package/src/vaadin-grid-scroll-mixin.js +12 -20
- package/src/vaadin-grid-selection-column-base-mixin.js +2 -1
- package/src/vaadin-grid-styling-mixin.js +2 -24
- package/web-types.json +4 -4
- package/web-types.lit.json +4 -4
|
@@ -11,7 +11,7 @@ import { repeat } from 'lit/directives/repeat.js';
|
|
|
11
11
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
12
|
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
13
13
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
14
|
-
import { partMap } from '@vaadin/component-base/src/directives/part-map.js';
|
|
14
|
+
import { parsePartNames, partMap } from '@vaadin/component-base/src/directives/part-map.js';
|
|
15
15
|
import { cellContent } from './directives/cell-content-directive.js';
|
|
16
16
|
|
|
17
17
|
function isContentCell(column, level, columnTree) {
|
|
@@ -49,19 +49,6 @@ function isFooterRowVisible(columns, level, columnTree) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Converts a whitespace separated list of custom part names
|
|
54
|
-
* into an object accepted by the `partMap` directive.
|
|
55
|
-
*/
|
|
56
|
-
function getCustomParts(partName) {
|
|
57
|
-
return Object.fromEntries(
|
|
58
|
-
(partName ?? '')
|
|
59
|
-
.split(' ')
|
|
60
|
-
.filter((name) => name !== '')
|
|
61
|
-
.map((name) => [name, true]),
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
52
|
/**
|
|
66
53
|
* A mixin providing rendering of header and footer rows based on the column tree.
|
|
67
54
|
*/
|
|
@@ -142,7 +129,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
142
129
|
'last-column-cell': isLastCell,
|
|
143
130
|
};
|
|
144
131
|
|
|
145
|
-
const customCellParts = isContentCell ?
|
|
132
|
+
const customCellParts = isContentCell ? parsePartNames(column.headerPartName) : {};
|
|
146
133
|
|
|
147
134
|
return cache(html`
|
|
148
135
|
<th
|
|
@@ -225,7 +212,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
225
212
|
'last-column-cell': isLastCell,
|
|
226
213
|
};
|
|
227
214
|
|
|
228
|
-
const customCellParts = isContentCell ?
|
|
215
|
+
const customCellParts = isContentCell ? parsePartNames(column.footerPartName) : {};
|
|
229
216
|
|
|
230
217
|
return cache(html`
|
|
231
218
|
<td
|
package/src/vaadin-grid-mixin.js
CHANGED
|
@@ -22,15 +22,7 @@ import { DynamicColumnsMixin } from './vaadin-grid-dynamic-columns-mixin.js';
|
|
|
22
22
|
import { EventContextMixin } from './vaadin-grid-event-context-mixin.js';
|
|
23
23
|
import { FilterMixin } from './vaadin-grid-filter-mixin.js';
|
|
24
24
|
import { HeaderFooterRenderingMixin } from './vaadin-grid-header-footer-rendering-mixin.js';
|
|
25
|
-
import {
|
|
26
|
-
getBodyRowCells,
|
|
27
|
-
getClosestCell,
|
|
28
|
-
iterateChildren,
|
|
29
|
-
iterateRowCells,
|
|
30
|
-
updateBooleanRowStates,
|
|
31
|
-
updateCellsPart,
|
|
32
|
-
updatePart,
|
|
33
|
-
} from './vaadin-grid-helpers.js';
|
|
25
|
+
import { getClosestCell, iterateChildren, updateBooleanRowStates } from './vaadin-grid-helpers.js';
|
|
34
26
|
import { KeyboardNavigationMixin } from './vaadin-grid-keyboard-navigation-mixin.js';
|
|
35
27
|
import { ResizeMixin } from './vaadin-grid-resize-mixin.js';
|
|
36
28
|
import { RowDetailsMixin } from './vaadin-grid-row-details-mixin.js';
|
|
@@ -78,6 +70,8 @@ export const GridMixin = (superClass) =>
|
|
|
78
70
|
),
|
|
79
71
|
),
|
|
80
72
|
) {
|
|
73
|
+
#renderedColumns = [];
|
|
74
|
+
|
|
81
75
|
static get observers() {
|
|
82
76
|
return ['_columnTreeChanged(_columnTree)', '_flatSizeChanged(_flatSize, __virtualizer, _hasData, _columnTree)'];
|
|
83
77
|
}
|
|
@@ -332,18 +326,14 @@ export const GridMixin = (superClass) =>
|
|
|
332
326
|
for (let i = 0; i < count; i++) {
|
|
333
327
|
const row = this.__createBodyRow();
|
|
334
328
|
if (this._columnTree) {
|
|
335
|
-
this.
|
|
329
|
+
this.__renderBodyRow(row);
|
|
336
330
|
}
|
|
337
331
|
rows.push(row);
|
|
338
332
|
}
|
|
339
333
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
c._cells = [...c._cells];
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
334
|
+
this._columnTree?.at(-1).forEach((column) => {
|
|
335
|
+
column.performUpdate?.();
|
|
336
|
+
});
|
|
347
337
|
|
|
348
338
|
return rows;
|
|
349
339
|
}
|
|
@@ -378,142 +368,6 @@ export const GridMixin = (superClass) =>
|
|
|
378
368
|
}
|
|
379
369
|
}
|
|
380
370
|
|
|
381
|
-
/** @private */
|
|
382
|
-
_createCell(tagName, column) {
|
|
383
|
-
const contentId = (this._contentIndex = this._contentIndex + 1 || 0);
|
|
384
|
-
const slotName = `vaadin-grid-cell-content-${contentId}`;
|
|
385
|
-
|
|
386
|
-
const cellContent = document.createElement('vaadin-grid-cell-content');
|
|
387
|
-
cellContent.setAttribute('slot', slotName);
|
|
388
|
-
|
|
389
|
-
const cell = document.createElement(tagName);
|
|
390
|
-
cell.id = slotName.replace('-content-', '-');
|
|
391
|
-
cell.setAttribute('role', tagName === 'td' ? 'gridcell' : 'columnheader');
|
|
392
|
-
|
|
393
|
-
cell.addEventListener('mouseenter', this.__onCellMouseEnter);
|
|
394
|
-
cell.addEventListener('mouseleave', this.__onCellMouseLeave);
|
|
395
|
-
cell.addEventListener('mousedown', this.__onCellMouseDown);
|
|
396
|
-
cell.addEventListener('keydown', this.__onCellKeyDown);
|
|
397
|
-
|
|
398
|
-
const slot = document.createElement('slot');
|
|
399
|
-
slot.setAttribute('name', slotName);
|
|
400
|
-
|
|
401
|
-
if (column?._focusButtonMode) {
|
|
402
|
-
const div = document.createElement('div');
|
|
403
|
-
div.setAttribute('role', 'button');
|
|
404
|
-
div.setAttribute('tabindex', '-1');
|
|
405
|
-
cell.appendChild(div);
|
|
406
|
-
|
|
407
|
-
// Patch `focus()` to use the button
|
|
408
|
-
cell._focusButton = div;
|
|
409
|
-
cell.focus = function (options) {
|
|
410
|
-
cell._focusButton.focus(options);
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
div.appendChild(slot);
|
|
414
|
-
} else {
|
|
415
|
-
cell.setAttribute('tabindex', '-1');
|
|
416
|
-
cell.appendChild(slot);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
cell._content = cellContent;
|
|
420
|
-
|
|
421
|
-
return cell;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* @param {!HTMLTableRowElement} row
|
|
426
|
-
* @param {!Array<!GridColumn>} columns
|
|
427
|
-
* @param {?string} section
|
|
428
|
-
* @param {boolean} noNotify
|
|
429
|
-
* @private
|
|
430
|
-
*/
|
|
431
|
-
__initRow(row, columns, section = 'body', noNotify = false) {
|
|
432
|
-
const contentsFragment = document.createDocumentFragment();
|
|
433
|
-
|
|
434
|
-
iterateRowCells(row, (cell) => {
|
|
435
|
-
cell._vacant = true;
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
const detailsCell = row.querySelector('.details-cell');
|
|
439
|
-
if (detailsCell) {
|
|
440
|
-
this.__teardownDetailsCell(detailsCell);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
row.innerHTML = '';
|
|
444
|
-
if (section === 'body') {
|
|
445
|
-
// Clear the cached cell references
|
|
446
|
-
row.__cells = [];
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
columns
|
|
450
|
-
.filter((column) => !column.hidden)
|
|
451
|
-
.toSorted((a, b) => a._order - b._order)
|
|
452
|
-
.forEach((column, index, cols) => {
|
|
453
|
-
let cell;
|
|
454
|
-
|
|
455
|
-
if (section === 'body') {
|
|
456
|
-
// Body
|
|
457
|
-
if (!column._cells) {
|
|
458
|
-
column._cells = [];
|
|
459
|
-
}
|
|
460
|
-
cell = column._cells.find((cell) => cell._vacant);
|
|
461
|
-
if (!cell) {
|
|
462
|
-
cell = this._createCell('td', column);
|
|
463
|
-
column._cells.push(cell);
|
|
464
|
-
}
|
|
465
|
-
updatePart(cell, 'cell', true);
|
|
466
|
-
updatePart(cell, 'body-cell', true);
|
|
467
|
-
cell.__parentRow = row;
|
|
468
|
-
// Cache the cell reference
|
|
469
|
-
row.__cells.push(cell);
|
|
470
|
-
|
|
471
|
-
const isSizerRow = row === this.$.sizer;
|
|
472
|
-
if (!column._bodyContentHidden || isSizerRow) {
|
|
473
|
-
row.appendChild(cell);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if (isSizerRow) {
|
|
477
|
-
column._sizerCell = cell;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (index === cols.length - 1 && this.rowDetailsRenderer) {
|
|
481
|
-
// Add details cell as last cell to body rows
|
|
482
|
-
if (!this._detailsCells) {
|
|
483
|
-
this._detailsCells = [];
|
|
484
|
-
}
|
|
485
|
-
const detailsCell = this._detailsCells.find((cell) => cell._vacant) || this._createCell('td');
|
|
486
|
-
if (this._detailsCells.indexOf(detailsCell) === -1) {
|
|
487
|
-
this._detailsCells.push(detailsCell);
|
|
488
|
-
}
|
|
489
|
-
if (!detailsCell._content.parentElement) {
|
|
490
|
-
contentsFragment.appendChild(detailsCell._content);
|
|
491
|
-
}
|
|
492
|
-
this._configureDetailsCell(detailsCell);
|
|
493
|
-
detailsCell.__parentRow = row;
|
|
494
|
-
row.appendChild(detailsCell);
|
|
495
|
-
this.__a11ySetRowDetailsCell(row, detailsCell);
|
|
496
|
-
detailsCell._vacant = false;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
if (!noNotify) {
|
|
500
|
-
column._cells = [...column._cells];
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (!cell._content.parentElement) {
|
|
505
|
-
contentsFragment.appendChild(cell._content);
|
|
506
|
-
}
|
|
507
|
-
cell._vacant = false;
|
|
508
|
-
cell._column = column;
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// Might be empty if only cache was used
|
|
512
|
-
this.appendChild(contentsFragment);
|
|
513
|
-
|
|
514
|
-
this._updateFirstAndLastColumnForRow(row);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
371
|
/** @private */
|
|
518
372
|
__updateVirtualizerElement(row, index) {
|
|
519
373
|
this._preventScrollerRotatingCellFocus(row, index);
|
|
@@ -530,18 +384,16 @@ export const GridMixin = (superClass) =>
|
|
|
530
384
|
|
|
531
385
|
/** @private */
|
|
532
386
|
_columnTreeChanged(columnTree) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
387
|
+
const columns = columnTree.at(-1);
|
|
388
|
+
columns
|
|
389
|
+
.filter((column) => !this.#renderedColumns.includes(column))
|
|
390
|
+
.forEach((column) => {
|
|
391
|
+
column._cells = [];
|
|
392
|
+
});
|
|
393
|
+
this.#renderedColumns = columns;
|
|
536
394
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
updateBooleanRowStates(row, {
|
|
540
|
-
first: row.index === 0,
|
|
541
|
-
last: row.index === this._flatSize - 1,
|
|
542
|
-
odd: row.index % 2 !== 0,
|
|
543
|
-
even: row.index % 2 === 0,
|
|
544
|
-
});
|
|
395
|
+
this._renderColumnTree();
|
|
396
|
+
this.__updateColumnsBodyContentHidden();
|
|
545
397
|
}
|
|
546
398
|
|
|
547
399
|
/** @private */
|
|
@@ -561,23 +413,25 @@ export const GridMixin = (superClass) =>
|
|
|
561
413
|
}
|
|
562
414
|
|
|
563
415
|
/**
|
|
564
|
-
* @param {!Array<!GridColumn>} columnTree
|
|
565
416
|
* @protected
|
|
566
417
|
*/
|
|
567
|
-
_renderColumnTree(
|
|
418
|
+
_renderColumnTree() {
|
|
568
419
|
// This render uses the current hidden state of all columns,
|
|
569
420
|
// so a pending render from a hidden change is not needed
|
|
570
421
|
this._debouncerHiddenChanged?.cancel();
|
|
422
|
+
this.__renderBodyDebouncer?.cancel();
|
|
571
423
|
|
|
572
424
|
iterateChildren(this.$.items, (row) => {
|
|
573
|
-
this.__initRow(row, columnTree.at(-1), 'body', true);
|
|
574
425
|
this.__updateRow(row);
|
|
575
426
|
});
|
|
576
427
|
|
|
577
428
|
this.__renderHeaderFooter();
|
|
429
|
+
this.__renderSizer();
|
|
578
430
|
|
|
579
|
-
|
|
580
|
-
|
|
431
|
+
this._columnTree.at(-1).forEach((column) => {
|
|
432
|
+
column._cells = [...(column._cells ?? [])];
|
|
433
|
+
column.performUpdate?.();
|
|
434
|
+
});
|
|
581
435
|
|
|
582
436
|
this.__updateHorizontalScrollPosition();
|
|
583
437
|
this.__a11yUpdateHeaderRows();
|
|
@@ -587,40 +441,22 @@ export const GridMixin = (superClass) =>
|
|
|
587
441
|
|
|
588
442
|
/**
|
|
589
443
|
* @param {!HTMLElement} row
|
|
590
|
-
* @param {boolean}
|
|
444
|
+
* @param {{ skipRenderers?: boolean }} options
|
|
591
445
|
* @private
|
|
592
446
|
*/
|
|
593
|
-
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
if (loading) {
|
|
600
|
-
// Run style generators for the loading row to have custom names cleared
|
|
601
|
-
this._generateCellPartNames(row);
|
|
447
|
+
__updateRow(row, { skipRenderers = false } = {}) {
|
|
448
|
+
const item = this.__getRowItem(row);
|
|
449
|
+
if (item) {
|
|
450
|
+
// Set the item before rendering, the row template reads the row model
|
|
451
|
+
row._item = item;
|
|
602
452
|
}
|
|
603
|
-
}
|
|
604
453
|
|
|
605
|
-
/**
|
|
606
|
-
* @param {!HTMLElement} row
|
|
607
|
-
* @private
|
|
608
|
-
*/
|
|
609
|
-
__updateRow(row) {
|
|
610
454
|
this.__renderBodyRow(row);
|
|
611
455
|
|
|
612
|
-
|
|
613
|
-
this.__updateRowOrderParts(row);
|
|
614
|
-
|
|
615
|
-
const item = this.__getRowItem(row);
|
|
616
|
-
if (item) {
|
|
617
|
-
this.__updateRowCellsLoading(row, false);
|
|
618
|
-
} else {
|
|
619
|
-
this.__updateRowCellsLoading(row, true);
|
|
456
|
+
if (!item) {
|
|
620
457
|
return;
|
|
621
458
|
}
|
|
622
459
|
|
|
623
|
-
row._item = item;
|
|
624
460
|
const model = this.__getRowModel(row);
|
|
625
461
|
|
|
626
462
|
this._toggleDetailsCell(row, model.detailsOpened);
|
|
@@ -630,19 +466,20 @@ export const GridMixin = (superClass) =>
|
|
|
630
466
|
|
|
631
467
|
this.__updateRowStateParts(row, model);
|
|
632
468
|
|
|
633
|
-
this._generateCellPartNames(row, model);
|
|
634
469
|
this._filterDragAndDrop(row, model);
|
|
635
470
|
this.__updateDragSourceParts(row, model);
|
|
636
471
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
472
|
+
if (!skipRenderers) {
|
|
473
|
+
iterateChildren(row, (cell) => {
|
|
474
|
+
if (cell._column && !cell._column.isConnected) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (cell._renderer) {
|
|
478
|
+
const owner = cell._column || this;
|
|
479
|
+
cell._renderer.call(owner, cell._content, owner, model);
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
646
483
|
|
|
647
484
|
this._updateDetailsCellHeight(row);
|
|
648
485
|
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { updatePart } from './vaadin-grid-helpers.js';
|
|
7
|
-
|
|
8
6
|
export const RowDetailsMixin = (superClass) =>
|
|
9
7
|
class RowDetailsMixin extends superClass {
|
|
10
8
|
static get properties() {
|
|
@@ -40,14 +38,6 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
40
38
|
sync: true,
|
|
41
39
|
},
|
|
42
40
|
|
|
43
|
-
/**
|
|
44
|
-
* @type {!Array<!HTMLElement> | undefined}
|
|
45
|
-
* @protected
|
|
46
|
-
*/
|
|
47
|
-
_detailsCells: {
|
|
48
|
-
type: Array,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
41
|
/**
|
|
52
42
|
* Set of opened details item ids
|
|
53
43
|
* @private
|
|
@@ -79,27 +69,19 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
79
69
|
|
|
80
70
|
/** @private */
|
|
81
71
|
_rowDetailsRendererChanged(rowDetailsRenderer) {
|
|
82
|
-
if (!
|
|
72
|
+
if (!this._columnTree) {
|
|
73
|
+
// Only update the rows if the column tree has already been initialized
|
|
83
74
|
return;
|
|
84
75
|
}
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (row.hasAttribute('details-opened')) {
|
|
96
|
-
this.__updateRow(row);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Details cells are frozen, so the frozen cells cache needs to include them
|
|
101
|
-
this._frozenCellsChanged();
|
|
102
|
-
}
|
|
77
|
+
this._getRenderedRows().forEach((row) => {
|
|
78
|
+
// Update the rows that need the details cell added or removed,
|
|
79
|
+
// and the rows with opened details to apply the new renderer.
|
|
80
|
+
const hasDetailsCell = !!row.querySelector('.details-cell');
|
|
81
|
+
if (hasDetailsCell !== !!rowDetailsRenderer || row.hasAttribute('details-opened')) {
|
|
82
|
+
this.__updateRow(row);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
103
85
|
}
|
|
104
86
|
|
|
105
87
|
/** @private */
|
|
@@ -111,25 +93,6 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
111
93
|
});
|
|
112
94
|
}
|
|
113
95
|
|
|
114
|
-
/**
|
|
115
|
-
* @param {!HTMLElement} cell
|
|
116
|
-
* @protected
|
|
117
|
-
*/
|
|
118
|
-
_configureDetailsCell(cell) {
|
|
119
|
-
updatePart(cell, 'cell', true);
|
|
120
|
-
updatePart(cell, 'details-cell', true);
|
|
121
|
-
// Freeze the details cell, so that it does not scroll horizontally
|
|
122
|
-
// with the normal cells. This way it looks less weird.
|
|
123
|
-
cell.toggleAttribute('frozen', true);
|
|
124
|
-
|
|
125
|
-
this._detailsCellResizeObserver.observe(cell);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** @private */
|
|
129
|
-
__teardownDetailsCell(cell) {
|
|
130
|
-
this._detailsCellResizeObserver.unobserve(cell);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
96
|
/**
|
|
134
97
|
* @param {!HTMLElement} row
|
|
135
98
|
* @param {boolean} detailsOpened
|
|
@@ -156,19 +119,15 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
156
119
|
|
|
157
120
|
/** @protected */
|
|
158
121
|
_updateDetailsCellHeight(row) {
|
|
159
|
-
|
|
160
|
-
if (!cell) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this.__updateDetailsRowPadding(row, cell);
|
|
122
|
+
this.__updateDetailsRowPadding(row);
|
|
165
123
|
// Ensure the row has correct padding after frame (the resize observer might miss it)
|
|
166
|
-
requestAnimationFrame(() => this.__updateDetailsRowPadding(row
|
|
124
|
+
requestAnimationFrame(() => this.__updateDetailsRowPadding(row));
|
|
167
125
|
}
|
|
168
126
|
|
|
169
127
|
/** @private */
|
|
170
|
-
__updateDetailsRowPadding(row
|
|
171
|
-
|
|
128
|
+
__updateDetailsRowPadding(row) {
|
|
129
|
+
const cell = row.querySelector('.details-cell');
|
|
130
|
+
if (!cell || cell.hidden) {
|
|
172
131
|
row.style.removeProperty('padding-bottom');
|
|
173
132
|
} else {
|
|
174
133
|
row.style.setProperty('padding-bottom', `${cell.offsetHeight}px`);
|
|
@@ -328,37 +328,29 @@ export const ScrollMixin = (superClass) =>
|
|
|
328
328
|
this.__scrollToPendingColumn();
|
|
329
329
|
|
|
330
330
|
const columnsInOrder = this._getColumnsInOrder();
|
|
331
|
-
|
|
331
|
+
const changedColumns = [];
|
|
332
332
|
|
|
333
|
-
// Remove the column cells from the DOM if the column is outside the viewport.
|
|
334
|
-
// Add the column cells to the DOM if the column is inside the viewport.
|
|
335
|
-
//
|
|
336
333
|
// Update the _bodyContentHidden property of the column to reflect the current
|
|
337
|
-
// visibility state
|
|
334
|
+
// visibility state.
|
|
338
335
|
columnsInOrder.forEach((column) => {
|
|
339
336
|
const bodyContentHidden = this._lazyColumns && !this.__isColumnInViewport(column);
|
|
340
337
|
|
|
341
338
|
if (column._bodyContentHidden !== bodyContentHidden) {
|
|
342
|
-
|
|
343
|
-
column._cells.forEach((cell) => {
|
|
344
|
-
if (cell !== column._sizerCell) {
|
|
345
|
-
if (bodyContentHidden) {
|
|
346
|
-
cell.remove();
|
|
347
|
-
} else if (cell.__parentRow) {
|
|
348
|
-
// Add the cell to the correct DOM position in the row
|
|
349
|
-
const followingColumnCell = [...cell.__parentRow.children].find(
|
|
350
|
-
(child) => columnsInOrder.indexOf(child._column) > columnsInOrder.indexOf(column),
|
|
351
|
-
);
|
|
352
|
-
cell.__parentRow.insertBefore(cell, followingColumnCell);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
});
|
|
339
|
+
changedColumns.push(column);
|
|
356
340
|
}
|
|
357
341
|
|
|
358
342
|
column._bodyContentHidden = bodyContentHidden;
|
|
359
343
|
});
|
|
360
344
|
|
|
361
|
-
if (
|
|
345
|
+
if (changedColumns.length > 0) {
|
|
346
|
+
[...this.$.items.children].forEach((row) => {
|
|
347
|
+
this.__updateRow(row, { skipRenderers: true });
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
changedColumns.forEach((column) => {
|
|
351
|
+
column.performUpdate?.();
|
|
352
|
+
});
|
|
353
|
+
|
|
362
354
|
// Frozen columns may have changed their visibility
|
|
363
355
|
this._frozenCellsChanged();
|
|
364
356
|
}
|
|
@@ -232,7 +232,8 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
232
232
|
if (!checkbox.isConnected || !row) {
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
const
|
|
235
|
+
const rowHeaderColumn = this._grid._getColumnsInOrder().find((column) => column.rowHeader);
|
|
236
|
+
const rowHeaderCell = rowHeaderColumn?._cells?.find((cell) => cell.__parentRow === row);
|
|
236
237
|
const value = rowHeaderCell?._content?.textContent.trim() || String(row.index + 1);
|
|
237
238
|
checkbox.accessibleName = ariaLabel.replace('{rowHeader}', value);
|
|
238
239
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2026 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
|
|
6
|
+
import { iterateChildren } from './vaadin-grid-helpers.js';
|
|
7
7
|
|
|
8
8
|
export const StylingMixin = (superClass) =>
|
|
9
9
|
class StylingMixin extends superClass {
|
|
@@ -53,29 +53,7 @@ export const StylingMixin = (superClass) =>
|
|
|
53
53
|
generateCellPartNames() {
|
|
54
54
|
iterateChildren(this.$.items, (row) => {
|
|
55
55
|
if (!row.hidden) {
|
|
56
|
-
this.
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** @private */
|
|
62
|
-
_generateCellPartNames(row, model) {
|
|
63
|
-
iterateRowCells(row, (cell) => {
|
|
64
|
-
if (cell.__generatedParts) {
|
|
65
|
-
cell.__generatedParts.forEach((partName) => {
|
|
66
|
-
// Remove previously generated part names
|
|
67
|
-
updatePart(cell, partName, null);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (this.cellPartNameGenerator && !row.hasAttribute('loading')) {
|
|
71
|
-
const result = this.cellPartNameGenerator(cell._column, model);
|
|
72
|
-
cell.__generatedParts = result && result.split(' ').filter((partName) => partName.length > 0);
|
|
73
|
-
if (cell.__generatedParts) {
|
|
74
|
-
cell.__generatedParts.forEach((partName) => {
|
|
75
|
-
// Add the newly generated names to part
|
|
76
|
-
updatePart(cell, partName, true);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
56
|
+
this.__renderBodyRow(row);
|
|
79
57
|
}
|
|
80
58
|
});
|
|
81
59
|
}
|