@vaadin/grid 25.3.0-alpha7 → 25.3.0-alpha9
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 +189 -161
- package/package.json +12 -12
- package/src/directives/cell-content-directive.js +2 -1
- package/src/vaadin-grid-a11y-mixin.js +6 -23
- package/src/vaadin-grid-column-auto-width-mixin.js +3 -8
- package/src/vaadin-grid-column-group-mixin.js +5 -20
- package/src/vaadin-grid-column-mixin.d.ts +3 -3
- package/src/vaadin-grid-column-mixin.js +35 -73
- package/src/vaadin-grid-column-reordering-mixin.js +4 -1
- package/src/vaadin-grid-column-resizing-mixin.js +4 -0
- package/src/vaadin-grid-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-drag-and-drop-mixin.js +2 -5
- package/src/vaadin-grid-dynamic-columns-mixin.js +0 -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-filter.js +1 -0
- package/src/vaadin-grid-header-footer-rendering-mixin.js +296 -0
- package/src/vaadin-grid-keyboard-navigation-mixin.js +3 -7
- package/src/vaadin-grid-mixin.js +5 -31
- package/src/vaadin-grid-row-details-mixin.js +1 -1
- package/src/vaadin-grid-scroll-mixin.js +2 -5
- package/src/vaadin-grid-selection-column-base-mixin.js +3 -3
- package/src/vaadin-grid-sorter-mixin.js +2 -5
- package/src/vaadin-grid-sorter.js +1 -0
- package/src/vaadin-grid-tree-toggle.js +1 -0
- package/src/vaadin-grid.js +1 -0
- package/web-types.json +20 -94
- package/web-types.lit.json +10 -10
- package/src/vaadin-grid-column-rendering-mixin.js +0 -195
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { html, nothing, render } from 'lit';
|
|
7
|
-
import { cache } from 'lit/directives/cache.js';
|
|
8
|
-
import { repeat } from 'lit/directives/repeat.js';
|
|
9
|
-
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
10
|
-
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
11
|
-
import { cellContent } from './directives/cell-content-directive.js';
|
|
12
|
-
|
|
13
|
-
function isEmptyCell(column, level, columnTree) {
|
|
14
|
-
const isColumnRow = level === columnTree.length - 1;
|
|
15
|
-
return !isColumnRow && column.localName !== 'vaadin-grid-column-group';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isHeaderRowVisible(columns, level, columnTree) {
|
|
19
|
-
return columns.some((column) => {
|
|
20
|
-
if (column.hidden || isEmptyCell(column, level, columnTree)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (column.headerRenderer) {
|
|
25
|
-
// The column has a header renderer -> row should be visible
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (column.header === null) {
|
|
30
|
-
// The column header is explicitly set to null -> doesn't block hiding the row
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return column.path || column.header !== undefined;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isFooterRowVisible(columns, level, columnTree) {
|
|
39
|
-
return columns.some((column) => {
|
|
40
|
-
if (column.hidden || isEmptyCell(column, level, columnTree)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return column.footerRenderer;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A mixin providing rendering of rows based on the column tree.
|
|
50
|
-
*/
|
|
51
|
-
export const ColumnRenderingMixin = (superClass) =>
|
|
52
|
-
class ColumnRenderingMixin extends superClass {
|
|
53
|
-
/** @private */
|
|
54
|
-
__scheduleRenderHeaderFooter() {
|
|
55
|
-
this.__renderHeaderFooterDebouncer = Debouncer.debounce(this.__renderHeaderFooterDebouncer, microTask, () => {
|
|
56
|
-
this.__renderHeaderFooter();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** @private */
|
|
61
|
-
__renderHeaderFooter() {
|
|
62
|
-
this.__renderHeaderFooterDebouncer?.cancel();
|
|
63
|
-
|
|
64
|
-
const sortedColumnTree = (this._columnTree ?? []).map((columns) => {
|
|
65
|
-
return columns.toSorted((a, b) => a._order - b._order);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
sortedColumnTree.flat().forEach((column) => {
|
|
69
|
-
column._emptyCells = [];
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
this.#renderHeader(sortedColumnTree);
|
|
73
|
-
this.#renderFooter(sortedColumnTree);
|
|
74
|
-
|
|
75
|
-
this._resetKeyboardNavigation();
|
|
76
|
-
this.__a11yUpdateGridSize(this.size, this._columnTree, this.__emptyState);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
#renderHeader(columnTree) {
|
|
80
|
-
render(columnTree.map(this.#renderHeaderRow), this.$.header, { host: this });
|
|
81
|
-
|
|
82
|
-
this.$.table.toggleAttribute('has-header', !!this.$.header.querySelector('tr:not([hidden])'));
|
|
83
|
-
this.__updateHeaderFooterRowParts('header');
|
|
84
|
-
|
|
85
|
-
this.$.header.querySelectorAll('.header-cell').forEach((cell) => {
|
|
86
|
-
const column = cell._column;
|
|
87
|
-
const isColumnRow = cell.parentElement === this.$.header.lastElementChild;
|
|
88
|
-
if (isColumnRow || column.localName === 'vaadin-grid-column-group') {
|
|
89
|
-
column._headerCell = cell;
|
|
90
|
-
} else {
|
|
91
|
-
column._emptyCells.push(cell);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
#renderHeaderRow = (columns, level, columnTree) => {
|
|
97
|
-
return html`
|
|
98
|
-
<tr
|
|
99
|
-
role="row"
|
|
100
|
-
part="row header-row"
|
|
101
|
-
class="row header-row"
|
|
102
|
-
tabindex="-1"
|
|
103
|
-
?hidden=${!isHeaderRowVisible(columns, level, columnTree)}
|
|
104
|
-
>
|
|
105
|
-
${repeat(
|
|
106
|
-
columns,
|
|
107
|
-
(column) => column._id,
|
|
108
|
-
(column) => {
|
|
109
|
-
// `cache` keeps the cell and its rendered content when the
|
|
110
|
-
// column gets hidden, so it can be restored as-is when the
|
|
111
|
-
// column is shown again.
|
|
112
|
-
if (column.hidden) {
|
|
113
|
-
return cache(nothing);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return cache(html`
|
|
117
|
-
<th
|
|
118
|
-
role="columnheader"
|
|
119
|
-
part="cell header-cell"
|
|
120
|
-
class="cell header-cell"
|
|
121
|
-
@keydown="${this.__onCellKeyDown}"
|
|
122
|
-
@mousedown=${this.__onCellMouseDown}
|
|
123
|
-
@mouseenter=${this.__onCellMouseEnter}
|
|
124
|
-
@mouseleave=${this.__onCellMouseLeave}
|
|
125
|
-
tabindex="-1"
|
|
126
|
-
._column=${column}
|
|
127
|
-
>
|
|
128
|
-
${cellContent(this, `vaadin-grid-header-cell-content-${level}-${column._id}`)}
|
|
129
|
-
${column.resizable ? html`<div part="resize-handle" class="resize-handle"></div>` : nothing}
|
|
130
|
-
</th>
|
|
131
|
-
`);
|
|
132
|
-
},
|
|
133
|
-
)}
|
|
134
|
-
</tr>
|
|
135
|
-
`;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
#renderFooter(columnTree) {
|
|
139
|
-
render(columnTree.map(this.#renderFooterRow).toReversed(), this.$.footer, { host: this });
|
|
140
|
-
|
|
141
|
-
this.$.table.toggleAttribute('has-footer', !!this.$.footer.querySelector('tr:not([hidden])'));
|
|
142
|
-
this.__updateHeaderFooterRowParts('footer');
|
|
143
|
-
|
|
144
|
-
this.$.footer.querySelectorAll('.footer-cell').forEach((cell) => {
|
|
145
|
-
const column = cell._column;
|
|
146
|
-
const isColumnRow = cell.parentElement === this.$.footer.firstElementChild;
|
|
147
|
-
if (isColumnRow || column.localName === 'vaadin-grid-column-group') {
|
|
148
|
-
column._footerCell = cell;
|
|
149
|
-
} else {
|
|
150
|
-
column._emptyCells.push(cell);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
#renderFooterRow = (columns, level, columnTree) => {
|
|
156
|
-
return html`
|
|
157
|
-
<tr
|
|
158
|
-
role="row"
|
|
159
|
-
part="row footer-row"
|
|
160
|
-
class="row footer-row"
|
|
161
|
-
tabindex="-1"
|
|
162
|
-
?hidden=${!isFooterRowVisible(columns, level, columnTree)}
|
|
163
|
-
>
|
|
164
|
-
${repeat(
|
|
165
|
-
columns,
|
|
166
|
-
(column) => column._id,
|
|
167
|
-
(column) => {
|
|
168
|
-
// `cache` keeps the cell and its rendered content when the
|
|
169
|
-
// column gets hidden, so it can be restored as-is when the
|
|
170
|
-
// column is shown again.
|
|
171
|
-
if (column.hidden) {
|
|
172
|
-
return cache(nothing);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return cache(html`
|
|
176
|
-
<td
|
|
177
|
-
role="gridcell"
|
|
178
|
-
part="cell footer-cell"
|
|
179
|
-
class="cell footer-cell"
|
|
180
|
-
@keydown="${this.__onCellKeyDown}"
|
|
181
|
-
@mousedown=${this.__onCellMouseDown}
|
|
182
|
-
@mouseenter=${this.__onCellMouseEnter}
|
|
183
|
-
@mouseleave=${this.__onCellMouseLeave}
|
|
184
|
-
tabindex="-1"
|
|
185
|
-
._column=${column}
|
|
186
|
-
>
|
|
187
|
-
${cellContent(this, `vaadin-grid-footer-cell-content-${level}-${column._id}`)}
|
|
188
|
-
</td>
|
|
189
|
-
`);
|
|
190
|
-
},
|
|
191
|
-
)}
|
|
192
|
-
</tr>
|
|
193
|
-
`;
|
|
194
|
-
};
|
|
195
|
-
};
|