@vaadin/grid 25.3.0-dev.1fa5a51482 → 25.3.0-rc1
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/custom-elements.json +20 -20
- package/package.json +12 -12
- package/src/directives/cell-content-directive.js +2 -1
- package/src/vaadin-grid-a11y-mixin.js +15 -19
- package/src/vaadin-grid-active-item-mixin.js +1 -1
- package/src/vaadin-grid-column-auto-width-mixin.js +3 -8
- package/src/vaadin-grid-column-group-mixin.js +2 -6
- package/src/vaadin-grid-column-mixin.d.ts +3 -3
- package/src/vaadin-grid-column-mixin.js +35 -84
- package/src/vaadin-grid-column-reordering-mixin.js +1 -1
- package/src/vaadin-grid-column-resizing-mixin.js +4 -0
- package/src/vaadin-grid-data-provider-mixin.js +2 -2
- package/src/vaadin-grid-drag-and-drop-mixin.js +2 -5
- package/src/vaadin-grid-filter-column-mixin.js +1 -1
- package/src/vaadin-grid-filter-element-mixin.js +1 -3
- package/src/vaadin-grid-header-footer-rendering-mixin.js +43 -12
- package/src/vaadin-grid-keyboard-navigation-mixin.js +3 -7
- package/src/vaadin-grid-mixin.js +3 -27
- package/src/vaadin-grid-row-details-mixin.js +1 -1
- package/src/vaadin-grid-scroll-mixin.js +7 -32
- package/src/vaadin-grid-selection-column-base-mixin.js +3 -3
- package/src/vaadin-grid-sorter-mixin.js +3 -7
- package/src/vaadin-grid-tree-toggle.d.ts +5 -3
- package/src/vaadin-grid-tree-toggle.js +5 -3
- package/src/vaadin-grid.d.ts +23 -0
- package/src/vaadin-grid.js +23 -0
- package/web-types.json +17 -17
- package/web-types.lit.json +11 -11
|
@@ -93,8 +93,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Aligns the columns cell content horizontally.
|
|
96
|
-
*
|
|
97
|
-
* @attr {start|center|end} text-align
|
|
96
|
+
*
|
|
97
|
+
* @attr {start|center|end|left|right} text-align
|
|
98
98
|
*/
|
|
99
99
|
textAlign: {
|
|
100
100
|
type: String,
|
|
@@ -245,27 +245,16 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
245
245
|
type: Function,
|
|
246
246
|
computed: '_computeFooterRenderer(footerRenderer, __initialized)',
|
|
247
247
|
},
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* An internal property that is mainly used by `vaadin-template-renderer`
|
|
251
|
-
* to identify grid column elements.
|
|
252
|
-
*
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
__gridColumnElement: {
|
|
256
|
-
type: Boolean,
|
|
257
|
-
value: true,
|
|
258
|
-
},
|
|
259
248
|
};
|
|
260
249
|
}
|
|
261
250
|
|
|
262
251
|
static get observers() {
|
|
263
252
|
return [
|
|
264
|
-
'_widthChanged(width,
|
|
253
|
+
'_widthChanged(width, _cells)',
|
|
265
254
|
'_frozenChanged(frozen, _headerCell, _footerCell, _cells)',
|
|
266
255
|
'_frozenToEndChanged(frozenToEnd, _headerCell, _footerCell, _cells)',
|
|
267
|
-
'_flexGrowChanged(flexGrow,
|
|
268
|
-
'_textAlignChanged(textAlign, _cells
|
|
256
|
+
'_flexGrowChanged(flexGrow, _cells)',
|
|
257
|
+
'_textAlignChanged(textAlign, _cells)',
|
|
269
258
|
'_lastFrozenChanged(_lastFrozen)',
|
|
270
259
|
'_firstFrozenToEndChanged(_firstFrozenToEnd)',
|
|
271
260
|
'_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, path)',
|
|
@@ -275,7 +264,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
275
264
|
'_reorderStatusChanged(_reorderStatus, _headerCell, _footerCell, _cells)',
|
|
276
265
|
'_hiddenChanged(hidden, _headerCell, _footerCell, _cells)',
|
|
277
266
|
'_rowHeaderChanged(rowHeader, _cells)',
|
|
278
|
-
'__headerFooterPartNameChanged(
|
|
267
|
+
'__headerFooterPartNameChanged(headerPartName, footerPartName)',
|
|
279
268
|
];
|
|
280
269
|
}
|
|
281
270
|
|
|
@@ -347,9 +336,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
347
336
|
}
|
|
348
337
|
|
|
349
338
|
this._cells?.forEach((cell) => {
|
|
350
|
-
|
|
351
|
-
cell._content.parentNode.removeChild(cell._content);
|
|
352
|
-
}
|
|
339
|
+
cell._content.parentNode?.removeChild(cell._content);
|
|
353
340
|
});
|
|
354
341
|
});
|
|
355
342
|
|
|
@@ -378,46 +365,40 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
378
365
|
|
|
379
366
|
/** @private */
|
|
380
367
|
_flexGrowChanged(flexGrow) {
|
|
381
|
-
|
|
382
|
-
this.parentElement._columnPropChanged('flexGrow');
|
|
383
|
-
}
|
|
368
|
+
this.parentElement?._columnPropChanged?.('flexGrow');
|
|
384
369
|
|
|
385
|
-
this.
|
|
370
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
371
|
+
|
|
372
|
+
this._cells?.forEach((cell) => {
|
|
386
373
|
cell.style.flexGrow = flexGrow;
|
|
387
374
|
});
|
|
388
375
|
}
|
|
389
376
|
|
|
390
377
|
/** @private */
|
|
391
378
|
_widthChanged(width) {
|
|
392
|
-
|
|
393
|
-
this.parentElement._columnPropChanged('width');
|
|
394
|
-
}
|
|
379
|
+
this.parentElement?._columnPropChanged?.('width');
|
|
395
380
|
|
|
396
|
-
this.
|
|
381
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
382
|
+
|
|
383
|
+
this._cells?.forEach((cell) => {
|
|
397
384
|
cell.style.width = width;
|
|
398
385
|
});
|
|
399
386
|
}
|
|
400
387
|
|
|
401
388
|
/** @private */
|
|
402
389
|
_frozenChanged(frozen) {
|
|
403
|
-
|
|
404
|
-
this.parentElement._columnPropChanged('frozen', frozen);
|
|
405
|
-
}
|
|
390
|
+
this.parentElement?._columnPropChanged?.('frozen', frozen);
|
|
406
391
|
|
|
407
392
|
this._allCells.forEach((cell) => {
|
|
408
393
|
updateCellState(cell, 'frozen', frozen);
|
|
409
394
|
});
|
|
410
395
|
|
|
411
|
-
|
|
412
|
-
this._grid._frozenCellsChanged();
|
|
413
|
-
}
|
|
396
|
+
this._grid?._frozenCellsChanged?.();
|
|
414
397
|
}
|
|
415
398
|
|
|
416
399
|
/** @private */
|
|
417
400
|
_frozenToEndChanged(frozenToEnd) {
|
|
418
|
-
|
|
419
|
-
this.parentElement._columnPropChanged('frozenToEnd', frozenToEnd);
|
|
420
|
-
}
|
|
401
|
+
this.parentElement?._columnPropChanged?.('frozenToEnd', frozenToEnd);
|
|
421
402
|
|
|
422
403
|
this._allCells.forEach((cell) => {
|
|
423
404
|
// Skip sizer cells to keep correct scrollWidth.
|
|
@@ -428,9 +409,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
428
409
|
updateCellState(cell, 'frozen-to-end', frozenToEnd);
|
|
429
410
|
});
|
|
430
411
|
|
|
431
|
-
|
|
432
|
-
this._grid._frozenCellsChanged();
|
|
433
|
-
}
|
|
412
|
+
this._grid?._frozenCellsChanged?.();
|
|
434
413
|
}
|
|
435
414
|
|
|
436
415
|
/** @private */
|
|
@@ -462,11 +441,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
462
441
|
|
|
463
442
|
/** @private */
|
|
464
443
|
_rowHeaderChanged(rowHeader, cells) {
|
|
465
|
-
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
cells.forEach((cell) => {
|
|
444
|
+
cells?.forEach((cell) => {
|
|
470
445
|
cell.setAttribute('role', rowHeader ? 'rowheader' : 'gridcell');
|
|
471
446
|
});
|
|
472
447
|
}
|
|
@@ -500,59 +475,46 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
500
475
|
|
|
501
476
|
/** @private */
|
|
502
477
|
_resizableChanged(resizable) {
|
|
503
|
-
if (resizable === undefined
|
|
478
|
+
if (resizable === undefined) {
|
|
504
479
|
return;
|
|
505
480
|
}
|
|
506
481
|
|
|
507
|
-
this._grid
|
|
482
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
508
483
|
}
|
|
509
484
|
|
|
510
485
|
/** @private */
|
|
511
486
|
_textAlignChanged(textAlign) {
|
|
512
|
-
if (textAlign === undefined
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
if (['start', 'end', 'center'].indexOf(textAlign) === -1) {
|
|
516
|
-
console.warn('textAlign can only be set as "start", "end" or "center"');
|
|
487
|
+
if (textAlign === undefined) {
|
|
517
488
|
return;
|
|
518
489
|
}
|
|
519
490
|
|
|
520
|
-
this.
|
|
491
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
492
|
+
|
|
493
|
+
this._cells?.forEach((cell) => {
|
|
521
494
|
cell._content.style.textAlign = textAlign;
|
|
522
495
|
});
|
|
523
496
|
}
|
|
524
497
|
|
|
525
498
|
/** @private */
|
|
526
499
|
_hiddenChanged(hidden) {
|
|
527
|
-
|
|
528
|
-
this.parentElement._columnPropChanged('hidden', hidden);
|
|
529
|
-
}
|
|
500
|
+
this.parentElement?._columnPropChanged?.('hidden', hidden);
|
|
530
501
|
|
|
531
502
|
if (!!hidden !== !!this._previousHidden && this._grid) {
|
|
532
503
|
if (hidden === true) {
|
|
533
504
|
this._cells?.forEach((cell) => {
|
|
534
|
-
|
|
535
|
-
cell._content.parentNode.removeChild(cell._content);
|
|
536
|
-
}
|
|
505
|
+
cell._content.parentNode?.removeChild(cell._content);
|
|
537
506
|
});
|
|
538
507
|
}
|
|
539
508
|
this._grid._debouncerHiddenChanged = Debouncer.debounce(
|
|
540
509
|
this._grid._debouncerHiddenChanged,
|
|
541
510
|
animationFrame,
|
|
542
511
|
() => {
|
|
543
|
-
|
|
544
|
-
this._grid._renderColumnTree(this._grid._columnTree);
|
|
545
|
-
}
|
|
512
|
+
this._grid?._renderColumnTree?.(this._grid._columnTree);
|
|
546
513
|
},
|
|
547
514
|
);
|
|
548
515
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
if (this._grid._resetKeyboardNavigation) {
|
|
554
|
-
this._grid._resetKeyboardNavigation();
|
|
555
|
-
}
|
|
516
|
+
this._grid._debounceUpdateFrozenColumn?.();
|
|
517
|
+
this._grid._resetKeyboardNavigation?.();
|
|
556
518
|
}
|
|
557
519
|
this._previousHidden = hidden;
|
|
558
520
|
}
|
|
@@ -632,7 +594,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
632
594
|
|
|
633
595
|
this.__renderCellsContent(headerRenderer, [headerCell]);
|
|
634
596
|
|
|
635
|
-
this._grid?.__scheduleRenderHeaderFooter();
|
|
597
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
636
598
|
}
|
|
637
599
|
|
|
638
600
|
/** @protected */
|
|
@@ -641,19 +603,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
641
603
|
}
|
|
642
604
|
|
|
643
605
|
/** @private */
|
|
644
|
-
__headerFooterPartNameChanged(
|
|
645
|
-
|
|
646
|
-
{ cell: headerCell, partName: headerPartName },
|
|
647
|
-
{ cell: footerCell, partName: footerPartName },
|
|
648
|
-
].forEach(({ cell, partName }) => {
|
|
649
|
-
if (cell) {
|
|
650
|
-
const customParts = cell.__customParts || [];
|
|
651
|
-
cell.part.remove(...customParts);
|
|
652
|
-
|
|
653
|
-
cell.__customParts = partName ? partName.trim().split(' ') : [];
|
|
654
|
-
cell.part.add(...cell.__customParts);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
606
|
+
__headerFooterPartNameChanged() {
|
|
607
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
657
608
|
}
|
|
658
609
|
|
|
659
610
|
/**
|
|
@@ -688,7 +639,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
688
639
|
|
|
689
640
|
this.__renderCellsContent(footerRenderer, [footerCell]);
|
|
690
641
|
|
|
691
|
-
this._grid?.__scheduleRenderHeaderFooter();
|
|
642
|
+
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
692
643
|
}
|
|
693
644
|
|
|
694
645
|
/** @protected */
|
|
@@ -116,7 +116,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
if (headerCell._content.
|
|
119
|
+
if (headerCell._content.matches(':focus-within')) {
|
|
120
120
|
// Something was focused inside the cell
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -98,6 +98,10 @@ export const ColumnResizingMixin = (superClass) =>
|
|
|
98
98
|
cell._column.flexGrow = 0;
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
// Flush the scheduled header/footer render to apply the new widths
|
|
102
|
+
// to the cells before measuring the layout below
|
|
103
|
+
this.__renderHeaderFooterDebouncer?.flush();
|
|
104
|
+
|
|
101
105
|
const cellFrozenToEnd = this._frozenToEndCells[0];
|
|
102
106
|
|
|
103
107
|
// When handle moves below the cell frozen to end, scroll into view.
|
|
@@ -214,7 +214,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
214
214
|
* @protected
|
|
215
215
|
*/
|
|
216
216
|
_isExpanded(item) {
|
|
217
|
-
return this.__expandedKeys
|
|
217
|
+
return this.__expandedKeys?.has(this.getItemId(item));
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/**
|
|
@@ -429,7 +429,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
429
429
|
|
|
430
430
|
/** @private */
|
|
431
431
|
__scrollToPendingIndexes() {
|
|
432
|
-
if (this.__pendingScrollToIndexes
|
|
432
|
+
if (this.__pendingScrollToIndexes) {
|
|
433
433
|
const indexes = this.__pendingScrollToIndexes;
|
|
434
434
|
delete this.__pendingScrollToIndexes;
|
|
435
435
|
this.scrollToIndex(...indexes);
|
|
@@ -4,6 +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 { isChrome, isSafari } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
|
+
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
8
|
import {
|
|
8
9
|
getBodyRowCells,
|
|
9
10
|
iterateChildren,
|
|
@@ -494,11 +495,7 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
494
495
|
const draggableAttribute = isChrome ? 'draggable-source' : 'draggable';
|
|
495
496
|
|
|
496
497
|
iterateRowCells(row, (cell) => {
|
|
497
|
-
|
|
498
|
-
cell._content.removeAttribute(draggableAttribute);
|
|
499
|
-
} else {
|
|
500
|
-
cell._content.setAttribute(draggableAttribute, true);
|
|
501
|
-
}
|
|
498
|
+
setOrRemoveAttribute(cell._content, draggableAttribute, !dragDisabled);
|
|
502
499
|
});
|
|
503
500
|
|
|
504
501
|
updateBooleanRowStates(row, {
|
|
@@ -37,7 +37,7 @@ export const GridFilterColumnMixin = (superClass) =>
|
|
|
37
37
|
*/
|
|
38
38
|
_defaultHeaderRenderer(root, _column) {
|
|
39
39
|
let filter = root.firstElementChild;
|
|
40
|
-
let textField = filter
|
|
40
|
+
let textField = filter?.firstElementChild;
|
|
41
41
|
|
|
42
42
|
if (!filter) {
|
|
43
43
|
filter = document.createElement('vaadin-grid-filter');
|
|
@@ -8,19 +8,20 @@ import { cache } from 'lit/directives/cache.js';
|
|
|
8
8
|
import { classMap } from 'lit/directives/class-map.js';
|
|
9
9
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
10
|
import { repeat } from 'lit/directives/repeat.js';
|
|
11
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
11
12
|
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
12
13
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
13
14
|
import { partMap } from '@vaadin/component-base/src/directives/part-map.js';
|
|
14
15
|
import { cellContent } from './directives/cell-content-directive.js';
|
|
15
16
|
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return
|
|
17
|
+
function isContentCell(column, level, columnTree) {
|
|
18
|
+
const isLastRow = level === columnTree.length - 1;
|
|
19
|
+
return isLastRow || column.localName === 'vaadin-grid-column-group';
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function isHeaderRowVisible(columns, level, columnTree) {
|
|
22
23
|
return columns.some((column) => {
|
|
23
|
-
if (column.hidden ||
|
|
24
|
+
if (column.hidden || !isContentCell(column, level, columnTree)) {
|
|
24
25
|
return false;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -40,7 +41,7 @@ function isHeaderRowVisible(columns, level, columnTree) {
|
|
|
40
41
|
|
|
41
42
|
function isFooterRowVisible(columns, level, columnTree) {
|
|
42
43
|
return columns.some((column) => {
|
|
43
|
-
if (column.hidden ||
|
|
44
|
+
if (column.hidden || !isContentCell(column, level, columnTree)) {
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -48,6 +49,19 @@ function isFooterRowVisible(columns, level, columnTree) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
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
|
+
|
|
51
65
|
/**
|
|
52
66
|
* A mixin providing rendering of header and footer rows based on the column tree.
|
|
53
67
|
*/
|
|
@@ -76,7 +90,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
76
90
|
this.#renderFooter(sortedColumnTree);
|
|
77
91
|
|
|
78
92
|
this._resetKeyboardNavigation();
|
|
79
|
-
this.__a11yUpdateGridSize(this.
|
|
93
|
+
this.__a11yUpdateGridSize(this._flatSize, this._columnTree, this.__emptyState);
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
#renderHeader(columnTree) {
|
|
@@ -113,7 +127,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
113
127
|
${repeat(
|
|
114
128
|
cells,
|
|
115
129
|
({ column }) => column._id,
|
|
116
|
-
({ column, isFirstCell, isLastCell }) => {
|
|
130
|
+
({ column, isFirstCell, isLastCell, isContentCell }) => {
|
|
117
131
|
// `cache` keeps the cell and its rendered content when the
|
|
118
132
|
// column gets hidden, so it can be restored as-is when the
|
|
119
133
|
// column is shown again.
|
|
@@ -128,11 +142,17 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
128
142
|
'last-column-cell': isLastCell,
|
|
129
143
|
};
|
|
130
144
|
|
|
145
|
+
const customCellParts = isContentCell ? getCustomParts(column.headerPartName) : {};
|
|
146
|
+
|
|
131
147
|
return cache(html`
|
|
132
148
|
<th
|
|
133
149
|
role="columnheader"
|
|
134
|
-
part="cell header-cell${partMap(cellParts)}"
|
|
150
|
+
part="cell header-cell${partMap({ ...cellParts, ...customCellParts })}"
|
|
135
151
|
class="cell header-cell${classMap(cellParts)}"
|
|
152
|
+
style="${styleMap({
|
|
153
|
+
width: column.width,
|
|
154
|
+
'flex-grow': column.flexGrow,
|
|
155
|
+
})}"
|
|
136
156
|
?first-column="${isFirstCell}"
|
|
137
157
|
?last-column="${isLastCell}"
|
|
138
158
|
@keydown="${this.__onCellKeyDown}"
|
|
@@ -144,7 +164,9 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
144
164
|
tabindex="-1"
|
|
145
165
|
._column=${column}
|
|
146
166
|
>
|
|
147
|
-
${cellContent(this, `vaadin-grid-header-cell-content-${level}-${column._id}
|
|
167
|
+
${cellContent(this, `vaadin-grid-header-cell-content-${level}-${column._id}`, {
|
|
168
|
+
textAlign: column.textAlign,
|
|
169
|
+
})}
|
|
148
170
|
${column.resizable ? html`<div part="resize-handle" class="resize-handle"></div>` : nothing}
|
|
149
171
|
</th>
|
|
150
172
|
`);
|
|
@@ -188,7 +210,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
188
210
|
${repeat(
|
|
189
211
|
cells,
|
|
190
212
|
({ column }) => column._id,
|
|
191
|
-
({ column, isFirstCell, isLastCell }) => {
|
|
213
|
+
({ column, isFirstCell, isLastCell, isContentCell }) => {
|
|
192
214
|
// `cache` keeps the cell and its rendered content when the
|
|
193
215
|
// column gets hidden, so it can be restored as-is when the
|
|
194
216
|
// column is shown again.
|
|
@@ -203,11 +225,17 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
203
225
|
'last-column-cell': isLastCell,
|
|
204
226
|
};
|
|
205
227
|
|
|
228
|
+
const customCellParts = isContentCell ? getCustomParts(column.footerPartName) : {};
|
|
229
|
+
|
|
206
230
|
return cache(html`
|
|
207
231
|
<td
|
|
208
232
|
role="gridcell"
|
|
209
|
-
part="cell footer-cell${partMap(cellParts)}"
|
|
233
|
+
part="cell footer-cell${partMap({ ...cellParts, ...customCellParts })}"
|
|
210
234
|
class="cell footer-cell${classMap(cellParts)}"
|
|
235
|
+
style="${styleMap({
|
|
236
|
+
width: column.width,
|
|
237
|
+
'flex-grow': column.flexGrow,
|
|
238
|
+
})}"
|
|
211
239
|
?first-column="${isFirstCell}"
|
|
212
240
|
?last-column="${isLastCell}"
|
|
213
241
|
@keydown="${this.__onCellKeyDown}"
|
|
@@ -219,7 +247,9 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
219
247
|
tabindex="-1"
|
|
220
248
|
._column=${column}
|
|
221
249
|
>
|
|
222
|
-
${cellContent(this, `vaadin-grid-footer-cell-content-${level}-${column._id}
|
|
250
|
+
${cellContent(this, `vaadin-grid-footer-cell-content-${level}-${column._id}`, {
|
|
251
|
+
textAlign: column.textAlign,
|
|
252
|
+
})}
|
|
223
253
|
</td>
|
|
224
254
|
`);
|
|
225
255
|
},
|
|
@@ -239,6 +269,7 @@ export const HeaderFooterRenderingMixin = (superClass) =>
|
|
|
239
269
|
column,
|
|
240
270
|
isFirstCell: column === visibleColumns.at(0),
|
|
241
271
|
isLastCell: column === visibleColumns.at(-1),
|
|
272
|
+
isContentCell: isContentCell(column, level, columnTree),
|
|
242
273
|
};
|
|
243
274
|
}),
|
|
244
275
|
isRowVisible:
|
|
@@ -154,9 +154,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
154
154
|
|
|
155
155
|
/** @private */
|
|
156
156
|
_focusableChanged(focusable, oldFocusable) {
|
|
157
|
-
|
|
158
|
-
oldFocusable.setAttribute('tabindex', '-1');
|
|
159
|
-
}
|
|
157
|
+
oldFocusable?.setAttribute('tabindex', '-1');
|
|
160
158
|
if (focusable) {
|
|
161
159
|
this._updateGridSectionFocusTarget(focusable);
|
|
162
160
|
}
|
|
@@ -415,9 +413,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
415
413
|
_onRowNavigation(activeRow, dy) {
|
|
416
414
|
const { dstRow } = this.__navigateRows(dy, activeRow);
|
|
417
415
|
|
|
418
|
-
|
|
419
|
-
dstRow.focus();
|
|
420
|
-
}
|
|
416
|
+
dstRow?.focus();
|
|
421
417
|
}
|
|
422
418
|
|
|
423
419
|
/** @private */
|
|
@@ -765,7 +761,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
765
761
|
// When clicking a cell with only text nodes, skip activating the cell
|
|
766
762
|
// on click, since that is already handled on keydown.
|
|
767
763
|
const cell = e.composedPath()[0];
|
|
768
|
-
const target =
|
|
764
|
+
const target = cell._content?.firstElementChild || cell;
|
|
769
765
|
const wasNavigating = this.hasAttribute('navigating');
|
|
770
766
|
const clickEvent = new MouseEvent('click', {
|
|
771
767
|
shiftKey: e.shiftKey,
|
package/src/vaadin-grid-mixin.js
CHANGED
|
@@ -124,17 +124,6 @@ export const GridMixin = (superClass) =>
|
|
|
124
124
|
value: false,
|
|
125
125
|
},
|
|
126
126
|
|
|
127
|
-
/**
|
|
128
|
-
* An internal property that is mainly used by `vaadin-template-renderer`
|
|
129
|
-
* to identify grid elements.
|
|
130
|
-
*
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
__gridElement: {
|
|
134
|
-
type: Boolean,
|
|
135
|
-
value: true,
|
|
136
|
-
},
|
|
137
|
-
|
|
138
127
|
/** @private */
|
|
139
128
|
__hasEmptyStateContent: {
|
|
140
129
|
type: Boolean,
|
|
@@ -152,13 +141,13 @@ export const GridMixin = (superClass) =>
|
|
|
152
141
|
/** @private */
|
|
153
142
|
get _firstVisibleIndex() {
|
|
154
143
|
const firstVisibleItem = this.__getFirstVisibleItem();
|
|
155
|
-
return firstVisibleItem
|
|
144
|
+
return firstVisibleItem?.index;
|
|
156
145
|
}
|
|
157
146
|
|
|
158
147
|
/** @private */
|
|
159
148
|
get _lastVisibleIndex() {
|
|
160
149
|
const lastVisibleItem = this.__getLastVisibleItem();
|
|
161
|
-
return lastVisibleItem
|
|
150
|
+
return lastVisibleItem?.index;
|
|
162
151
|
}
|
|
163
152
|
|
|
164
153
|
constructor() {
|
|
@@ -247,13 +236,6 @@ export const GridMixin = (superClass) =>
|
|
|
247
236
|
// otherwise be triggered by this logic because it reads the row height
|
|
248
237
|
// right after updating the rows' content.
|
|
249
238
|
__disableHeightPlaceholder: true,
|
|
250
|
-
// The virtualizer amortizes scroller height updates to avoid reflows while
|
|
251
|
-
// scrolling. In `allRowsVisible` mode the grid has no scrolling and its
|
|
252
|
-
// height must track the content exactly, so tell the virtualizer to always
|
|
253
|
-
// apply the scroller height. Otherwise the items container can be left at a
|
|
254
|
-
// stale, too-small height and clip rows when the grid grows (e.g. when
|
|
255
|
-
// expanding a tree grid from a small size).
|
|
256
|
-
__alwaysUpdateScrollerSize: () => this.allRowsVisible,
|
|
257
239
|
});
|
|
258
240
|
|
|
259
241
|
this._tooltipController = new TooltipController(this);
|
|
@@ -305,9 +287,7 @@ export const GridMixin = (superClass) =>
|
|
|
305
287
|
__focusBodyCell({ item, column }) {
|
|
306
288
|
const row = this._getRenderedRows().find((row) => row._item === item);
|
|
307
289
|
const cell = row && [...row.children].find((cell) => cell._column === column);
|
|
308
|
-
|
|
309
|
-
cell.focus();
|
|
310
|
-
}
|
|
290
|
+
cell?.focus();
|
|
311
291
|
}
|
|
312
292
|
|
|
313
293
|
/** @protected */
|
|
@@ -530,7 +510,6 @@ export const GridMixin = (superClass) =>
|
|
|
530
510
|
// Might be empty if only cache was used
|
|
531
511
|
this.appendChild(contentsFragment);
|
|
532
512
|
|
|
533
|
-
this._frozenCellsChanged();
|
|
534
513
|
this._updateFirstAndLastColumnForRow(row);
|
|
535
514
|
}
|
|
536
515
|
|
|
@@ -596,11 +575,8 @@ export const GridMixin = (superClass) =>
|
|
|
596
575
|
this.__initRow(this.$.sizer, columnTree[columnTree.length - 1]);
|
|
597
576
|
|
|
598
577
|
this._resizeHandler();
|
|
599
|
-
this._frozenCellsChanged();
|
|
600
|
-
this._resetKeyboardNavigation();
|
|
601
578
|
this.__a11yUpdateHeaderRows();
|
|
602
579
|
this.__a11yUpdateFooterRows();
|
|
603
|
-
this.generateCellPartNames();
|
|
604
580
|
this.__updateHeaderAndFooter();
|
|
605
581
|
}
|
|
606
582
|
|
|
@@ -180,7 +180,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
180
180
|
* @protected
|
|
181
181
|
*/
|
|
182
182
|
_isDetailsOpened(item) {
|
|
183
|
-
return this.__detailsOpenedKeys
|
|
183
|
+
return this.__detailsOpenedKeys?.has(this.getItemId(item));
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/** @private */
|