@vaadin/grid 24.2.3 → 24.3.0-alpha10
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 +18 -13
- package/src/vaadin-grid-a11y-mixin.js +1 -1
- package/src/vaadin-grid-active-item-mixin.js +1 -0
- package/src/vaadin-grid-array-data-provider-mixin.js +14 -17
- package/src/vaadin-grid-column-group-mixin.d.ts +20 -0
- package/src/vaadin-grid-column-group-mixin.js +364 -0
- package/src/vaadin-grid-column-group.d.ts +4 -14
- package/src/vaadin-grid-column-group.js +5 -355
- package/src/vaadin-grid-column-mixin.d.ts +170 -0
- package/src/vaadin-grid-column-mixin.js +958 -0
- package/src/vaadin-grid-column.d.ts +11 -138
- package/src/vaadin-grid-column.js +5 -876
- package/src/vaadin-grid-data-provider-mixin.d.ts +6 -30
- package/src/vaadin-grid-data-provider-mixin.js +122 -246
- package/src/vaadin-grid-drag-and-drop-mixin.js +17 -5
- package/src/vaadin-grid-dynamic-columns-mixin.js +22 -17
- package/src/vaadin-grid-filter-column-mixin.d.ts +22 -0
- package/src/vaadin-grid-filter-column-mixin.js +106 -0
- package/src/vaadin-grid-filter-column.d.ts +9 -11
- package/src/vaadin-grid-filter-column.js +3 -90
- package/src/vaadin-grid-filter-element-mixin.d.ts +34 -0
- package/src/vaadin-grid-filter-element-mixin.js +108 -0
- package/src/vaadin-grid-filter-mixin.js +4 -4
- package/src/vaadin-grid-filter.d.ts +4 -21
- package/src/vaadin-grid-filter.js +5 -84
- package/src/vaadin-grid-helpers.js +94 -0
- package/src/vaadin-grid-keyboard-navigation-mixin.js +11 -4
- package/src/vaadin-grid-mixin.js +21 -37
- package/src/vaadin-grid-row-details-mixin.js +7 -8
- package/src/vaadin-grid-scroll-mixin.js +2 -1
- package/src/vaadin-grid-selection-column-base-mixin.js +12 -4
- package/src/vaadin-grid-selection-column-mixin.d.ts +24 -0
- package/src/vaadin-grid-selection-column-mixin.js +194 -0
- package/src/vaadin-grid-selection-column.d.ts +13 -17
- package/src/vaadin-grid-selection-column.js +4 -186
- package/src/vaadin-grid-selection-mixin.js +4 -3
- package/src/vaadin-grid-sort-column-mixin.d.ts +36 -0
- package/src/vaadin-grid-sort-column-mixin.js +101 -0
- package/src/vaadin-grid-sort-column.d.ts +8 -26
- package/src/vaadin-grid-sort-column.js +3 -87
- package/src/vaadin-grid-sorter-mixin.d.ts +44 -0
- package/src/vaadin-grid-sorter-mixin.js +200 -0
- package/src/vaadin-grid-sorter.d.ts +3 -32
- package/src/vaadin-grid-sorter.js +5 -181
- package/src/vaadin-grid-styles.js +341 -345
- package/src/vaadin-grid-styling-mixin.js +8 -2
- package/src/vaadin-grid-tree-column-mixin.d.ts +18 -0
- package/src/vaadin-grid-tree-column-mixin.js +99 -0
- package/src/vaadin-grid-tree-column.d.ts +9 -7
- package/src/vaadin-grid-tree-column.js +3 -82
- package/src/vaadin-grid-tree-toggle-mixin.d.ts +39 -0
- package/src/vaadin-grid-tree-toggle-mixin.js +153 -0
- package/src/vaadin-grid-tree-toggle.d.ts +4 -27
- package/src/vaadin-grid-tree-toggle.js +9 -141
- package/src/vaadin-grid.d.ts +3 -0
- package/src/vaadin-grid.js +7 -2
- package/theme/lumo/vaadin-grid-sorter-styles.js +1 -1
- package/theme/lumo/vaadin-grid-styles.js +15 -14
- package/theme/material/vaadin-grid-styles.js +15 -10
- package/web-types.json +331 -126
- package/web-types.lit.json +114 -58
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
|
-
import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
9
|
-
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
10
8
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
11
|
-
import {
|
|
12
|
-
|
|
9
|
+
import { GridColumnGroupMixin } from './vaadin-grid-column-group-mixin.js';
|
|
10
|
+
export * from './vaadin-grid-column-group-mixin.js';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* A `<vaadin-grid-column-group>` is used to make groups of columns in `<vaadin-grid>` and
|
|
@@ -42,360 +40,12 @@ import { updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
|
42
40
|
*
|
|
43
41
|
* @customElement
|
|
44
42
|
* @extends HTMLElement
|
|
45
|
-
* @mixes
|
|
43
|
+
* @mixes GridColumnGroupMixin
|
|
46
44
|
*/
|
|
47
|
-
class GridColumnGroup extends
|
|
45
|
+
class GridColumnGroup extends GridColumnGroupMixin(PolymerElement) {
|
|
48
46
|
static get is() {
|
|
49
47
|
return 'vaadin-grid-column-group';
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
static get properties() {
|
|
53
|
-
return {
|
|
54
|
-
/** @private */
|
|
55
|
-
_childColumns: {
|
|
56
|
-
value() {
|
|
57
|
-
return this._getChildColumns(this);
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Flex grow ratio for the column group as the sum of the ratios of its child columns.
|
|
63
|
-
* @attr {number} flex-grow
|
|
64
|
-
*/
|
|
65
|
-
flexGrow: {
|
|
66
|
-
type: Number,
|
|
67
|
-
readOnly: true,
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Width of the column group as the sum of the widths of its child columns.
|
|
72
|
-
*/
|
|
73
|
-
width: {
|
|
74
|
-
type: String,
|
|
75
|
-
readOnly: true,
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/** @private */
|
|
79
|
-
_visibleChildColumns: Array,
|
|
80
|
-
|
|
81
|
-
/** @private */
|
|
82
|
-
_colSpan: Number,
|
|
83
|
-
|
|
84
|
-
/** @private */
|
|
85
|
-
_rootColumns: Array,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static get observers() {
|
|
90
|
-
return [
|
|
91
|
-
'_groupFrozenChanged(frozen, _rootColumns)',
|
|
92
|
-
'_groupFrozenToEndChanged(frozenToEnd, _rootColumns)',
|
|
93
|
-
'_groupHiddenChanged(hidden)',
|
|
94
|
-
'_colSpanChanged(_colSpan, _headerCell, _footerCell)',
|
|
95
|
-
'_groupOrderChanged(_order, _rootColumns)',
|
|
96
|
-
'_groupReorderStatusChanged(_reorderStatus, _rootColumns)',
|
|
97
|
-
'_groupResizableChanged(resizable, _rootColumns)',
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** @protected */
|
|
102
|
-
connectedCallback() {
|
|
103
|
-
super.connectedCallback();
|
|
104
|
-
this._addNodeObserver();
|
|
105
|
-
this._updateFlexAndWidth();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** @protected */
|
|
109
|
-
disconnectedCallback() {
|
|
110
|
-
super.disconnectedCallback();
|
|
111
|
-
if (this._observer) {
|
|
112
|
-
this._observer.disconnect();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @param {string} path
|
|
118
|
-
* @param {unknown=} value
|
|
119
|
-
* @protected
|
|
120
|
-
*/
|
|
121
|
-
_columnPropChanged(path, value) {
|
|
122
|
-
if (path === 'hidden') {
|
|
123
|
-
// Prevent synchronization of the hidden state to child columns.
|
|
124
|
-
// If the group is currently auto-hidden, and one column is made visible,
|
|
125
|
-
// we don't want the other columns to become visible as well.
|
|
126
|
-
this._preventHiddenSynchronization = true;
|
|
127
|
-
this._updateVisibleChildColumns(this._childColumns);
|
|
128
|
-
this._preventHiddenSynchronization = false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (/flexGrow|width|hidden|_childColumns/u.test(path)) {
|
|
132
|
-
this._updateFlexAndWidth();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Don't unfreeze the frozen group because of a non-frozen child
|
|
136
|
-
if (path === 'frozen' && !this.frozen) {
|
|
137
|
-
this.frozen = value;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Don't unfreeze the frozen group because of a non-frozen child
|
|
141
|
-
if (path === 'lastFrozen' && !this._lastFrozen) {
|
|
142
|
-
this._lastFrozen = value;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Don't unfreeze the frozen group because of a non-frozen child
|
|
146
|
-
if (path === 'frozenToEnd' && !this.frozenToEnd) {
|
|
147
|
-
this.frozenToEnd = value;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Don't unfreeze the frozen group because of a non-frozen child
|
|
151
|
-
if (path === 'firstFrozenToEnd' && !this._firstFrozenToEnd) {
|
|
152
|
-
this._firstFrozenToEnd = value;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** @private */
|
|
157
|
-
_groupOrderChanged(order, rootColumns) {
|
|
158
|
-
if (rootColumns) {
|
|
159
|
-
const _rootColumns = rootColumns.slice(0);
|
|
160
|
-
|
|
161
|
-
if (!order) {
|
|
162
|
-
_rootColumns.forEach((column) => {
|
|
163
|
-
column._order = 0;
|
|
164
|
-
});
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
// The parent column order number cascades downwards to it's children
|
|
168
|
-
// so that the resulting order numbering constructs as follows:
|
|
169
|
-
// [ 1000 ]
|
|
170
|
-
// [ 1100 ] | [ 1200 ]
|
|
171
|
-
// [1110] | [1120] | [1210] | [1220]
|
|
172
|
-
|
|
173
|
-
// Trailing zeros are counted so we know the level on which we're working on.
|
|
174
|
-
const trailingZeros = /(0+)$/u.exec(order).pop().length;
|
|
175
|
-
|
|
176
|
-
// In an unlikely situation where a group has more than 9 child columns,
|
|
177
|
-
// the child scope must have 1 digit less...
|
|
178
|
-
// Log^a_b = Ln(a)/Ln(b)
|
|
179
|
-
// Number of digits of a number is equal to floor(Log(number)_10) + 1
|
|
180
|
-
const childCountDigits = ~~(Math.log(rootColumns.length) / Math.LN10) + 1;
|
|
181
|
-
|
|
182
|
-
// Final scope for the child columns needs to mind both factors.
|
|
183
|
-
const scope = 10 ** (trailingZeros - childCountDigits);
|
|
184
|
-
|
|
185
|
-
if (_rootColumns[0] && _rootColumns[0]._order) {
|
|
186
|
-
_rootColumns.sort((a, b) => a._order - b._order);
|
|
187
|
-
}
|
|
188
|
-
updateColumnOrders(_rootColumns, scope, order);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** @private */
|
|
193
|
-
_groupReorderStatusChanged(reorderStatus, rootColumns) {
|
|
194
|
-
if (reorderStatus === undefined || rootColumns === undefined) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
rootColumns.forEach((column) => {
|
|
199
|
-
column._reorderStatus = reorderStatus;
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/** @private */
|
|
204
|
-
_groupResizableChanged(resizable, rootColumns) {
|
|
205
|
-
if (resizable === undefined || rootColumns === undefined) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
rootColumns.forEach((column) => {
|
|
210
|
-
column.resizable = resizable;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/** @private */
|
|
215
|
-
_updateVisibleChildColumns(childColumns) {
|
|
216
|
-
this._visibleChildColumns = Array.prototype.filter.call(childColumns, (col) => !col.hidden);
|
|
217
|
-
this._colSpan = this._visibleChildColumns.length;
|
|
218
|
-
this._updateAutoHidden();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** @protected */
|
|
222
|
-
_updateFlexAndWidth() {
|
|
223
|
-
if (!this._visibleChildColumns) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (this._visibleChildColumns.length > 0) {
|
|
228
|
-
const width = this._visibleChildColumns
|
|
229
|
-
.reduce((prev, curr) => {
|
|
230
|
-
prev += ` + ${(curr.width || '0px').replace('calc', '')}`;
|
|
231
|
-
return prev;
|
|
232
|
-
}, '')
|
|
233
|
-
.substring(3);
|
|
234
|
-
this._setWidth(`calc(${width})`);
|
|
235
|
-
} else {
|
|
236
|
-
this._setWidth('0px');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
this._setFlexGrow(Array.prototype.reduce.call(this._visibleChildColumns, (prev, curr) => prev + curr.flexGrow, 0));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* This method is called before the group's frozen value is being propagated to the child columns.
|
|
244
|
-
* In case some of the child columns are frozen, while others are not, the non-frozen ones
|
|
245
|
-
* will get automatically frozen as well. As this may sometimes be unintended, this method
|
|
246
|
-
* shows a warning in the console in such cases.
|
|
247
|
-
* @private
|
|
248
|
-
*/
|
|
249
|
-
__scheduleAutoFreezeWarning(columns, frozenProp) {
|
|
250
|
-
if (this._grid) {
|
|
251
|
-
// Derive the attribute name from the property name
|
|
252
|
-
const frozenAttr = frozenProp.replace(/([A-Z])/gu, '-$1').toLowerCase();
|
|
253
|
-
|
|
254
|
-
// Check if all the columns have the same frozen value
|
|
255
|
-
const firstColumnFrozen = columns[0][frozenProp] || columns[0].hasAttribute(frozenAttr);
|
|
256
|
-
const allSameFrozen = columns.every((column) => {
|
|
257
|
-
return (column[frozenProp] || column.hasAttribute(frozenAttr)) === firstColumnFrozen;
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
if (!allSameFrozen) {
|
|
261
|
-
// Some of the child columns are frozen, some are not. Show a warning.
|
|
262
|
-
this._grid.__autoFreezeWarningDebouncer = Debouncer.debounce(
|
|
263
|
-
this._grid.__autoFreezeWarningDebouncer,
|
|
264
|
-
animationFrame,
|
|
265
|
-
() => {
|
|
266
|
-
console.warn(
|
|
267
|
-
`WARNING: Joining ${frozenProp} and non-${frozenProp} Grid columns inside the same column group! ` +
|
|
268
|
-
`This will automatically freeze all the joined columns to avoid rendering issues. ` +
|
|
269
|
-
`If this was intentional, consider marking each joined column explicitly as ${frozenProp}. ` +
|
|
270
|
-
`Otherwise, exclude the ${frozenProp} columns from the joined group.`,
|
|
271
|
-
);
|
|
272
|
-
},
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** @private */
|
|
279
|
-
_groupFrozenChanged(frozen, rootColumns) {
|
|
280
|
-
if (rootColumns === undefined || frozen === undefined) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Don't propagate the default `false` value.
|
|
285
|
-
if (frozen !== false) {
|
|
286
|
-
this.__scheduleAutoFreezeWarning(rootColumns, 'frozen');
|
|
287
|
-
|
|
288
|
-
Array.from(rootColumns).forEach((col) => {
|
|
289
|
-
col.frozen = frozen;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/** @private */
|
|
295
|
-
_groupFrozenToEndChanged(frozenToEnd, rootColumns) {
|
|
296
|
-
if (rootColumns === undefined || frozenToEnd === undefined) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Don't propagate the default `false` value.
|
|
301
|
-
if (frozenToEnd !== false) {
|
|
302
|
-
this.__scheduleAutoFreezeWarning(rootColumns, 'frozenToEnd');
|
|
303
|
-
|
|
304
|
-
Array.from(rootColumns).forEach((col) => {
|
|
305
|
-
col.frozenToEnd = frozenToEnd;
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/** @private */
|
|
311
|
-
_groupHiddenChanged(hidden) {
|
|
312
|
-
// When initializing the hidden property, only sync hidden state to columns
|
|
313
|
-
// if group is actually hidden. Otherwise, we could override a hidden column
|
|
314
|
-
// to be visible.
|
|
315
|
-
// We always want to run this though if the property is actually changed.
|
|
316
|
-
if (hidden || this.__groupHiddenInitialized) {
|
|
317
|
-
this._synchronizeHidden();
|
|
318
|
-
}
|
|
319
|
-
this.__groupHiddenInitialized = true;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/** @private */
|
|
323
|
-
_updateAutoHidden() {
|
|
324
|
-
const wasAutoHidden = this._autoHidden;
|
|
325
|
-
this._autoHidden = (this._visibleChildColumns || []).length === 0;
|
|
326
|
-
// Only modify hidden state if group was auto-hidden, or becomes auto-hidden
|
|
327
|
-
if (wasAutoHidden || this._autoHidden) {
|
|
328
|
-
this.hidden = this._autoHidden;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/** @private */
|
|
333
|
-
_synchronizeHidden() {
|
|
334
|
-
if (this._childColumns && !this._preventHiddenSynchronization) {
|
|
335
|
-
this._childColumns.forEach((column) => {
|
|
336
|
-
column.hidden = this.hidden;
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** @private */
|
|
342
|
-
_colSpanChanged(colSpan, headerCell, footerCell) {
|
|
343
|
-
if (headerCell) {
|
|
344
|
-
headerCell.setAttribute('colspan', colSpan);
|
|
345
|
-
if (this._grid) {
|
|
346
|
-
this._grid._a11yUpdateCellColspan(headerCell, colSpan);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
if (footerCell) {
|
|
350
|
-
footerCell.setAttribute('colspan', colSpan);
|
|
351
|
-
if (this._grid) {
|
|
352
|
-
this._grid._a11yUpdateCellColspan(footerCell, colSpan);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* @param {!GridColumnGroup} el
|
|
359
|
-
* @return {!Array<!GridColumn>}
|
|
360
|
-
* @protected
|
|
361
|
-
*/
|
|
362
|
-
_getChildColumns(el) {
|
|
363
|
-
return FlattenedNodesObserver.getFlattenedNodes(el).filter(this._isColumnElement);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** @private */
|
|
367
|
-
_addNodeObserver() {
|
|
368
|
-
this._observer = new FlattenedNodesObserver(this, (info) => {
|
|
369
|
-
if (
|
|
370
|
-
info.addedNodes.filter(this._isColumnElement).length > 0 ||
|
|
371
|
-
info.removedNodes.filter(this._isColumnElement).length > 0
|
|
372
|
-
) {
|
|
373
|
-
// Prevent synchronization of the hidden state to child columns.
|
|
374
|
-
// If the group is currently auto-hidden, and a visible column is added,
|
|
375
|
-
// we don't want the other columns to become visible as well.
|
|
376
|
-
this._preventHiddenSynchronization = true;
|
|
377
|
-
this._rootColumns = this._getChildColumns(this);
|
|
378
|
-
this._childColumns = this._rootColumns;
|
|
379
|
-
this._updateVisibleChildColumns(this._childColumns);
|
|
380
|
-
this._preventHiddenSynchronization = false;
|
|
381
|
-
|
|
382
|
-
// Update the column tree
|
|
383
|
-
if (this._grid && this._grid._debounceUpdateColumnTree) {
|
|
384
|
-
this._grid._debounceUpdateColumnTree();
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
this._observer.flush();
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* @param {!Node} node
|
|
393
|
-
* @return {boolean}
|
|
394
|
-
* @protected
|
|
395
|
-
*/
|
|
396
|
-
_isColumnElement(node) {
|
|
397
|
-
return node.nodeType === Node.ELEMENT_NODE && /\bcolumn\b/u.test(node.localName);
|
|
398
|
-
}
|
|
399
49
|
}
|
|
400
50
|
|
|
401
51
|
defineCustomElement(GridColumnGroup);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { GridItemModel } from './vaadin-grid.js';
|
|
8
|
+
|
|
9
|
+
export type GridBodyRenderer<TItem, Column extends GridColumnMixin<TItem, Column>> = (
|
|
10
|
+
root: HTMLElement,
|
|
11
|
+
column: Column,
|
|
12
|
+
model: GridItemModel<TItem>,
|
|
13
|
+
) => void;
|
|
14
|
+
|
|
15
|
+
export type GridColumnTextAlign = 'center' | 'end' | 'start' | null;
|
|
16
|
+
|
|
17
|
+
export type GridHeaderFooterRenderer<TItem, Column extends ColumnBaseMixinClass<TItem, Column>> = (
|
|
18
|
+
root: HTMLElement,
|
|
19
|
+
column: Column,
|
|
20
|
+
) => void;
|
|
21
|
+
|
|
22
|
+
export declare function ColumnBaseMixin<
|
|
23
|
+
TItem,
|
|
24
|
+
Column extends GridColumnMixin<TItem, Column>,
|
|
25
|
+
T extends Constructor<HTMLElement>,
|
|
26
|
+
>(base: T): Constructor<ColumnBaseMixinClass<TItem, Column>> & T;
|
|
27
|
+
|
|
28
|
+
export declare class ColumnBaseMixinClass<TItem, Column extends ColumnBaseMixinClass<TItem, Column>> {
|
|
29
|
+
/**
|
|
30
|
+
* When set to true, the column is user-resizable.
|
|
31
|
+
*/
|
|
32
|
+
resizable: boolean | null | undefined;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* When true, the column is frozen. When a column inside of a column group is frozen,
|
|
36
|
+
* all of the sibling columns inside the group will get frozen also.
|
|
37
|
+
*/
|
|
38
|
+
frozen: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* When true, the column is frozen to end of grid.
|
|
42
|
+
*
|
|
43
|
+
* When a column inside of a column group is frozen to end, all of the sibling columns
|
|
44
|
+
* inside the group will get frozen to end also.
|
|
45
|
+
*
|
|
46
|
+
* Column can not be set as `frozen` and `frozenToEnd` at the same time.
|
|
47
|
+
* @attr {boolean} frozen-to-end
|
|
48
|
+
*/
|
|
49
|
+
frozenToEnd: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* When true, the cells for this column will be rendered with the `role` attribute
|
|
53
|
+
* set as `rowheader`, instead of the `gridcell` role value used by default.
|
|
54
|
+
*
|
|
55
|
+
* When a column is set as row header, its cells will be announced by screen readers
|
|
56
|
+
* while navigating to help user identify the current row as uniquely as possible.
|
|
57
|
+
*
|
|
58
|
+
* @attr {boolean} row-header
|
|
59
|
+
*/
|
|
60
|
+
rowHeader: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* When set to true, the cells for this column are hidden.
|
|
64
|
+
*/
|
|
65
|
+
hidden: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Text content to display in the header cell of the column.
|
|
69
|
+
*/
|
|
70
|
+
header: string | null | undefined;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Aligns the columns cell content horizontally.
|
|
74
|
+
* Supported values: "start", "center" and "end".
|
|
75
|
+
* @attr {start|center|end} text-align
|
|
76
|
+
*/
|
|
77
|
+
textAlign: GridColumnTextAlign | null | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Custom function for rendering the header content.
|
|
81
|
+
* Receives two arguments:
|
|
82
|
+
*
|
|
83
|
+
* - `root` The header cell content DOM element. Append your content to it.
|
|
84
|
+
* - `column` The `<vaadin-grid-column>` element.
|
|
85
|
+
*/
|
|
86
|
+
headerRenderer: GridHeaderFooterRenderer<TItem, Column> | null | undefined;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Custom function for rendering the footer content.
|
|
90
|
+
* Receives two arguments:
|
|
91
|
+
*
|
|
92
|
+
* - `root` The footer cell content DOM element. Append your content to it.
|
|
93
|
+
* - `column` The `<vaadin-grid-column>` element.
|
|
94
|
+
*/
|
|
95
|
+
footerRenderer: GridHeaderFooterRenderer<TItem, Column> | null | undefined;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Custom part name for the header cell.
|
|
99
|
+
*
|
|
100
|
+
* @attr {string} header-part-name
|
|
101
|
+
*/
|
|
102
|
+
headerPartName: string | null | undefined;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Custom part name for the footer cell.
|
|
106
|
+
*
|
|
107
|
+
* @attr {string} footer-part-name
|
|
108
|
+
*/
|
|
109
|
+
footerPartName: string | null | undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface GridColumnMixin<TItem, Column extends GridColumnMixinClass<TItem, Column>>
|
|
113
|
+
extends GridColumnMixinClass<TItem, Column> {}
|
|
114
|
+
|
|
115
|
+
export declare class GridColumnMixinClass<
|
|
116
|
+
TItem,
|
|
117
|
+
Column extends GridColumnMixinClass<TItem, Column>,
|
|
118
|
+
> extends ColumnBaseMixinClass<TItem, Column> {
|
|
119
|
+
/**
|
|
120
|
+
* Width of the cells for this column.
|
|
121
|
+
*/
|
|
122
|
+
width: string | null | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Flex grow ratio for the cell widths. When set to 0, cell width is fixed.
|
|
126
|
+
* @attr {number} flex-grow
|
|
127
|
+
*/
|
|
128
|
+
flexGrow: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Custom function for rendering the cell content.
|
|
132
|
+
* Receives three arguments:
|
|
133
|
+
*
|
|
134
|
+
* - `root` The cell content DOM element. Append your content to it.
|
|
135
|
+
* - `column` The `<vaadin-grid-column>` element.
|
|
136
|
+
* - `model` The object with the properties related with
|
|
137
|
+
* the rendered item, contains:
|
|
138
|
+
* - `model.index` The index of the item.
|
|
139
|
+
* - `model.item` The item.
|
|
140
|
+
* - `model.expanded` Sublevel toggle state.
|
|
141
|
+
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
142
|
+
* - `model.selected` Selected state.
|
|
143
|
+
* - `model.detailsOpened` Details opened state.
|
|
144
|
+
*/
|
|
145
|
+
renderer: GridBodyRenderer<TItem, Column> | null | undefined;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Path to an item sub-property whose value gets displayed in the column body cells.
|
|
149
|
+
* The property name is also shown in the column header if an explicit header or renderer isn't defined.
|
|
150
|
+
*/
|
|
151
|
+
path: string | null | undefined;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Automatically sets the width of the column based on the column contents when this is set to `true`.
|
|
155
|
+
*
|
|
156
|
+
* For performance reasons the column width is calculated automatically only once when the grid items
|
|
157
|
+
* are rendered for the first time and the calculation only considers the rows which are currently
|
|
158
|
+
* rendered in DOM (a bit more than what is currently visible). If the grid is scrolled, or the cell
|
|
159
|
+
* content changes, the column width might not match the contents anymore.
|
|
160
|
+
*
|
|
161
|
+
* Hidden columns are ignored in the calculation and their widths are not automatically updated when
|
|
162
|
+
* you show a column that was initially hidden.
|
|
163
|
+
*
|
|
164
|
+
* You can manually trigger the auto sizing behavior again by calling `grid.recalculateColumnWidths()`.
|
|
165
|
+
*
|
|
166
|
+
* The column width may still grow larger when `flexGrow` is not 0.
|
|
167
|
+
* @attr {boolean} auto-width
|
|
168
|
+
*/
|
|
169
|
+
autoWidth: boolean;
|
|
170
|
+
}
|