@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,6 +3,8 @@
|
|
|
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
|
+
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
7
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
6
8
|
import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -170,3 +172,95 @@ export function updateCellState(cell, attribute, value, part, oldPart) {
|
|
|
170
172
|
// Add new part to the cell attribute
|
|
171
173
|
updatePart(cell, value, part || `${attribute}-cell`);
|
|
172
174
|
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A helper for observing flattened child column list of an element.
|
|
178
|
+
*/
|
|
179
|
+
export class ColumnObserver {
|
|
180
|
+
constructor(host, callback) {
|
|
181
|
+
this.__host = host;
|
|
182
|
+
this.__callback = callback;
|
|
183
|
+
this.__currentSlots = [];
|
|
184
|
+
|
|
185
|
+
this.__onMutation = this.__onMutation.bind(this);
|
|
186
|
+
this.__observer = new MutationObserver(this.__onMutation);
|
|
187
|
+
this.__observer.observe(host, {
|
|
188
|
+
childList: true,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// The observer callback is invoked once initially.
|
|
192
|
+
this.__initialCallDebouncer = Debouncer.debounce(this.__initialCallDebouncer, microTask, () => this.__onMutation());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
disconnect() {
|
|
196
|
+
this.__observer.disconnect();
|
|
197
|
+
this.__initialCallDebouncer.cancel();
|
|
198
|
+
this.__toggleSlotChangeListeners(false);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
flush() {
|
|
202
|
+
this.__onMutation();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
__toggleSlotChangeListeners(add) {
|
|
206
|
+
this.__currentSlots.forEach((slot) => {
|
|
207
|
+
if (add) {
|
|
208
|
+
slot.addEventListener('slotchange', this.__onMutation);
|
|
209
|
+
} else {
|
|
210
|
+
slot.removeEventListener('slotchange', this.__onMutation);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
__onMutation() {
|
|
216
|
+
// Detect if this is the initial call
|
|
217
|
+
const initialCall = !this.__currentColumns;
|
|
218
|
+
this.__currentColumns ||= [];
|
|
219
|
+
|
|
220
|
+
// Detect added and removed columns or if the columns order has changed
|
|
221
|
+
const columns = ColumnObserver.getColumns(this.__host);
|
|
222
|
+
const addedColumns = columns.filter((column) => !this.__currentColumns.includes(column));
|
|
223
|
+
const removedColumns = this.__currentColumns.filter((column) => !columns.includes(column));
|
|
224
|
+
const orderChanged = this.__currentColumns.some((column, index) => column !== columns[index]);
|
|
225
|
+
this.__currentColumns = columns;
|
|
226
|
+
|
|
227
|
+
// Update the list of child slots and toggle their slotchange listeners
|
|
228
|
+
this.__toggleSlotChangeListeners(false);
|
|
229
|
+
this.__currentSlots = [...this.__host.children].filter((child) => child instanceof HTMLSlotElement);
|
|
230
|
+
this.__toggleSlotChangeListeners(true);
|
|
231
|
+
|
|
232
|
+
// Invoke the callback if there are changes in the child columns or if this is the initial call
|
|
233
|
+
const invokeCallback = initialCall || addedColumns.length || removedColumns.length || orderChanged;
|
|
234
|
+
if (invokeCallback) {
|
|
235
|
+
this.__callback(addedColumns, removedColumns);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Default filter for column elements.
|
|
241
|
+
*/
|
|
242
|
+
static __isColumnElement(node) {
|
|
243
|
+
return node.nodeType === Node.ELEMENT_NODE && /\bcolumn\b/u.test(node.localName);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
static getColumns(host) {
|
|
247
|
+
const columns = [];
|
|
248
|
+
|
|
249
|
+
// A temporary workaround for backwards compatibility
|
|
250
|
+
const isColumnElement = host._isColumnElement || ColumnObserver.__isColumnElement;
|
|
251
|
+
|
|
252
|
+
[...host.children].forEach((child) => {
|
|
253
|
+
if (isColumnElement(child)) {
|
|
254
|
+
// The child is a column element, add it to the list
|
|
255
|
+
columns.push(child);
|
|
256
|
+
} else if (child instanceof HTMLSlotElement) {
|
|
257
|
+
// The child is a slot, add all assigned column elements to the list
|
|
258
|
+
[...child.assignedElements({ flatten: true })]
|
|
259
|
+
.filter((assignedElement) => isColumnElement(assignedElement))
|
|
260
|
+
.forEach((assignedElement) => columns.push(assignedElement));
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return columns;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -18,6 +18,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
18
18
|
_headerFocusable: {
|
|
19
19
|
type: Object,
|
|
20
20
|
observer: '_focusableChanged',
|
|
21
|
+
sync: true,
|
|
21
22
|
},
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -27,12 +28,14 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
27
28
|
_itemsFocusable: {
|
|
28
29
|
type: Object,
|
|
29
30
|
observer: '_focusableChanged',
|
|
31
|
+
sync: true,
|
|
30
32
|
},
|
|
31
33
|
|
|
32
34
|
/** @private */
|
|
33
35
|
_footerFocusable: {
|
|
34
36
|
type: Object,
|
|
35
37
|
observer: '_focusableChanged',
|
|
38
|
+
sync: true,
|
|
36
39
|
},
|
|
37
40
|
|
|
38
41
|
/** @private */
|
|
@@ -54,6 +57,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
54
57
|
_focusedCell: {
|
|
55
58
|
type: Object,
|
|
56
59
|
observer: '_focusedCellChanged',
|
|
60
|
+
sync: true,
|
|
57
61
|
},
|
|
58
62
|
|
|
59
63
|
/**
|
|
@@ -267,7 +271,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
267
271
|
__isRowExpandable(row) {
|
|
268
272
|
if (this.itemHasChildrenPath) {
|
|
269
273
|
const item = row._item;
|
|
270
|
-
return item && get(this.itemHasChildrenPath, item) && !this._isExpanded(item);
|
|
274
|
+
return !!(item && get(this.itemHasChildrenPath, item) && !this._isExpanded(item));
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
|
|
@@ -443,7 +447,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
443
447
|
__navigateRows(dy, activeRow, activeCell) {
|
|
444
448
|
const currentRowIndex = this.__getIndexInGroup(activeRow, this._focusedItemIndex);
|
|
445
449
|
const activeRowGroup = activeRow.parentNode;
|
|
446
|
-
const maxRowIndex = (activeRowGroup === this.$.items ? this.
|
|
450
|
+
const maxRowIndex = (activeRowGroup === this.$.items ? this._flatSize : activeRowGroup.children.length) - 1;
|
|
447
451
|
|
|
448
452
|
// Index of the destination row
|
|
449
453
|
let dstRowIndex = Math.max(0, Math.min(currentRowIndex + dy, maxRowIndex));
|
|
@@ -476,7 +480,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
476
480
|
// Row details navigation logic
|
|
477
481
|
if (activeRowGroup === this.$.items) {
|
|
478
482
|
const item = activeRow._item;
|
|
479
|
-
const dstItem = this.
|
|
483
|
+
const { item: dstItem } = this._dataProviderController.getFlatIndexContext(dstRowIndex);
|
|
480
484
|
// Should we navigate to row details?
|
|
481
485
|
if (isRowDetails) {
|
|
482
486
|
dstIsRowDetails = dy === 0;
|
|
@@ -967,6 +971,9 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
967
971
|
|
|
968
972
|
/** @protected */
|
|
969
973
|
_resetKeyboardNavigation() {
|
|
974
|
+
if (!this.$ && this.performUpdate) {
|
|
975
|
+
this.performUpdate();
|
|
976
|
+
}
|
|
970
977
|
// Header / footer
|
|
971
978
|
['header', 'footer'].forEach((section) => {
|
|
972
979
|
if (!this.__isValidFocusable(this[`_${section}Focusable`])) {
|
|
@@ -985,7 +992,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
985
992
|
|
|
986
993
|
if (firstVisibleCell && firstVisibleRow) {
|
|
987
994
|
// Reset memoized column
|
|
988
|
-
|
|
995
|
+
this._focusedColumnOrder = undefined;
|
|
989
996
|
this._itemsFocusable = this.__getFocusable(firstVisibleRow, firstVisibleCell);
|
|
990
997
|
}
|
|
991
998
|
} else {
|
package/src/vaadin-grid-mixin.js
CHANGED
|
@@ -58,8 +58,8 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
|
|
|
58
58
|
* @mixes DragAndDropMixin
|
|
59
59
|
*/
|
|
60
60
|
export const GridMixin = (superClass) =>
|
|
61
|
-
class extends
|
|
62
|
-
|
|
61
|
+
class extends ArrayDataProviderMixin(
|
|
62
|
+
DataProviderMixin(
|
|
63
63
|
DynamicColumnsMixin(
|
|
64
64
|
ActiveItemMixin(
|
|
65
65
|
ScrollMixin(
|
|
@@ -86,10 +86,7 @@ export const GridMixin = (superClass) =>
|
|
|
86
86
|
),
|
|
87
87
|
) {
|
|
88
88
|
static get observers() {
|
|
89
|
-
return [
|
|
90
|
-
'_columnTreeChanged(_columnTree, _columnTree.*)',
|
|
91
|
-
'_effectiveSizeChanged(_effectiveSize, __virtualizer, _hasData, _columnTree)',
|
|
92
|
-
];
|
|
89
|
+
return ['_columnTreeChanged(_columnTree)', '_flatSizeChanged(_flatSize, __virtualizer, _hasData, _columnTree)'];
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
static get properties() {
|
|
@@ -254,7 +251,6 @@ export const GridMixin = (superClass) =>
|
|
|
254
251
|
|
|
255
252
|
new ResizeObserver(() =>
|
|
256
253
|
setTimeout(() => {
|
|
257
|
-
this.__updateFooterPositioning();
|
|
258
254
|
this.__updateColumnsBodyContentHidden();
|
|
259
255
|
this.__tryToRecalculateColumnWidthsIfPending();
|
|
260
256
|
}),
|
|
@@ -294,20 +290,20 @@ export const GridMixin = (superClass) =>
|
|
|
294
290
|
}
|
|
295
291
|
|
|
296
292
|
/** @private */
|
|
297
|
-
|
|
293
|
+
_flatSizeChanged(flatSize, virtualizer, hasData, columnTree) {
|
|
298
294
|
if (virtualizer && hasData && columnTree) {
|
|
299
295
|
// Changing the virtualizer size may result in the row with focus getting hidden
|
|
300
296
|
const cell = this.shadowRoot.activeElement;
|
|
301
297
|
const cellCoordinates = this.__getBodyCellCoordinates(cell);
|
|
302
298
|
|
|
303
299
|
const previousSize = virtualizer.size || 0;
|
|
304
|
-
virtualizer.size =
|
|
300
|
+
virtualizer.size = flatSize;
|
|
305
301
|
|
|
306
302
|
// Request an update for the previous last row to have the "last" state removed
|
|
307
303
|
virtualizer.update(previousSize - 1, previousSize - 1);
|
|
308
|
-
if (
|
|
304
|
+
if (flatSize < previousSize) {
|
|
309
305
|
// Size was decreased, so the new last row requires an explicit update
|
|
310
|
-
virtualizer.update(
|
|
306
|
+
virtualizer.update(flatSize - 1, flatSize - 1);
|
|
311
307
|
}
|
|
312
308
|
|
|
313
309
|
// If the focused cell's parent row got hidden by the size change, focus the corresponding new cell
|
|
@@ -466,7 +462,7 @@ export const GridMixin = (superClass) =>
|
|
|
466
462
|
if (!this._columnTree) {
|
|
467
463
|
return; // No columns
|
|
468
464
|
}
|
|
469
|
-
if (isElementHidden(this) || this.
|
|
465
|
+
if (isElementHidden(this) || this._dataProviderController.isLoading()) {
|
|
470
466
|
this.__pendingRecalculateColumnWidths = true;
|
|
471
467
|
return;
|
|
472
468
|
}
|
|
@@ -479,7 +475,7 @@ export const GridMixin = (superClass) =>
|
|
|
479
475
|
if (
|
|
480
476
|
this.__pendingRecalculateColumnWidths &&
|
|
481
477
|
!isElementHidden(this) &&
|
|
482
|
-
!this.
|
|
478
|
+
!this._dataProviderController.isLoading() &&
|
|
483
479
|
this.__hasRowsWithClientHeight()
|
|
484
480
|
) {
|
|
485
481
|
this.__pendingRecalculateColumnWidths = false;
|
|
@@ -501,7 +497,7 @@ export const GridMixin = (superClass) =>
|
|
|
501
497
|
const rows = [];
|
|
502
498
|
for (let i = 0; i < count; i++) {
|
|
503
499
|
const row = document.createElement('tr');
|
|
504
|
-
row.setAttribute('part', 'row');
|
|
500
|
+
row.setAttribute('part', 'row body-row');
|
|
505
501
|
row.setAttribute('role', 'row');
|
|
506
502
|
row.setAttribute('tabindex', '-1');
|
|
507
503
|
if (this._columnTree) {
|
|
@@ -511,9 +507,11 @@ export const GridMixin = (superClass) =>
|
|
|
511
507
|
}
|
|
512
508
|
|
|
513
509
|
if (this._columnTree) {
|
|
514
|
-
this._columnTree[this._columnTree.length - 1].forEach(
|
|
515
|
-
(c
|
|
516
|
-
|
|
510
|
+
this._columnTree[this._columnTree.length - 1].forEach((c) => {
|
|
511
|
+
if (c.isConnected && c._cells) {
|
|
512
|
+
c._cells = [...c._cells];
|
|
513
|
+
}
|
|
514
|
+
});
|
|
517
515
|
}
|
|
518
516
|
|
|
519
517
|
this.__afterCreateScrollerRowsDebouncer = Debouncer.debounce(
|
|
@@ -678,8 +676,8 @@ export const GridMixin = (superClass) =>
|
|
|
678
676
|
detailsCell._vacant = false;
|
|
679
677
|
}
|
|
680
678
|
|
|
681
|
-
if (
|
|
682
|
-
column.
|
|
679
|
+
if (!noNotify) {
|
|
680
|
+
column._cells = [...column._cells];
|
|
683
681
|
}
|
|
684
682
|
} else {
|
|
685
683
|
// Header & footer
|
|
@@ -700,7 +698,7 @@ export const GridMixin = (superClass) =>
|
|
|
700
698
|
column._emptyCells.push(cell);
|
|
701
699
|
}
|
|
702
700
|
}
|
|
703
|
-
cell.
|
|
701
|
+
cell.part.add('cell', `${section}-cell`);
|
|
704
702
|
}
|
|
705
703
|
|
|
706
704
|
if (!cell._content.parentElement) {
|
|
@@ -804,7 +802,7 @@ export const GridMixin = (superClass) =>
|
|
|
804
802
|
_updateRowOrderParts(row, index = row.index) {
|
|
805
803
|
updateBooleanRowStates(row, {
|
|
806
804
|
first: index === 0,
|
|
807
|
-
last: index === this.
|
|
805
|
+
last: index === this._flatSize - 1,
|
|
808
806
|
odd: index % 2 !== 0,
|
|
809
807
|
even: index % 2 === 0,
|
|
810
808
|
});
|
|
@@ -814,6 +812,7 @@ export const GridMixin = (superClass) =>
|
|
|
814
812
|
_updateRowStateParts(row, { expanded, selected, detailsOpened }) {
|
|
815
813
|
updateBooleanRowStates(row, {
|
|
816
814
|
expanded,
|
|
815
|
+
collapsed: this.__isRowExpandable(row),
|
|
817
816
|
selected,
|
|
818
817
|
'details-opened': detailsOpened,
|
|
819
818
|
});
|
|
@@ -876,25 +875,11 @@ export const GridMixin = (superClass) =>
|
|
|
876
875
|
this._resetKeyboardNavigation();
|
|
877
876
|
this._a11yUpdateHeaderRows();
|
|
878
877
|
this._a11yUpdateFooterRows();
|
|
879
|
-
this.__updateFooterPositioning();
|
|
880
878
|
this.generateCellClassNames();
|
|
881
879
|
this.generateCellPartNames();
|
|
882
880
|
this.__updateHeaderAndFooter();
|
|
883
881
|
}
|
|
884
882
|
|
|
885
|
-
/** @private */
|
|
886
|
-
__updateFooterPositioning() {
|
|
887
|
-
// TODO: fixed in Firefox 99, remove when we can drop Firefox ESR 91 support
|
|
888
|
-
if (this._firefox && parseFloat(navigator.userAgent.match(/Firefox\/(\d{2,3}.\d)/u)[1]) < 99) {
|
|
889
|
-
// Sticky (or translated) footer in a flexbox host doesn't get included in
|
|
890
|
-
// the scroll height calculation on FF. This is a workaround for the issue.
|
|
891
|
-
this.$.items.style.paddingBottom = 0;
|
|
892
|
-
if (!this.allRowsVisible) {
|
|
893
|
-
this.$.items.style.paddingBottom = `${this.$.footer.offsetHeight}px`;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
883
|
/**
|
|
899
884
|
* @param {!HTMLElement} row
|
|
900
885
|
* @param {GridItem} item
|
|
@@ -930,7 +915,6 @@ export const GridMixin = (superClass) =>
|
|
|
930
915
|
/** @private */
|
|
931
916
|
_resizeHandler() {
|
|
932
917
|
this._updateDetailsCellHeights();
|
|
933
|
-
this.__updateFooterPositioning();
|
|
934
918
|
this.__updateHorizontalScrollPosition();
|
|
935
919
|
}
|
|
936
920
|
|
|
@@ -984,7 +968,7 @@ export const GridMixin = (superClass) =>
|
|
|
984
968
|
|
|
985
969
|
/** @protected */
|
|
986
970
|
_hideTooltip(immediate) {
|
|
987
|
-
const tooltip = this._tooltipController.node;
|
|
971
|
+
const tooltip = this._tooltipController && this._tooltipController.node;
|
|
988
972
|
if (tooltip) {
|
|
989
973
|
tooltip._stateController.close(immediate);
|
|
990
974
|
}
|
|
@@ -19,6 +19,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
19
19
|
detailsOpenedItems: {
|
|
20
20
|
type: Array,
|
|
21
21
|
value: () => [],
|
|
22
|
+
sync: true,
|
|
22
23
|
},
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -37,7 +38,10 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
37
38
|
*
|
|
38
39
|
* @type {GridRowDetailsRenderer | null | undefined}
|
|
39
40
|
*/
|
|
40
|
-
rowDetailsRenderer:
|
|
41
|
+
rowDetailsRenderer: {
|
|
42
|
+
type: Function,
|
|
43
|
+
sync: true,
|
|
44
|
+
},
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* @type {!Array<!HTMLElement> | undefined}
|
|
@@ -51,7 +55,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
51
55
|
|
|
52
56
|
static get observers() {
|
|
53
57
|
return [
|
|
54
|
-
'_detailsOpenedItemsChanged(detailsOpenedItems
|
|
58
|
+
'_detailsOpenedItemsChanged(detailsOpenedItems, rowDetailsRenderer)',
|
|
55
59
|
'_rowDetailsRendererChanged(rowDetailsRenderer)',
|
|
56
60
|
];
|
|
57
61
|
}
|
|
@@ -90,12 +94,7 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
/** @private */
|
|
93
|
-
_detailsOpenedItemsChanged(
|
|
94
|
-
// Skip to avoid duplicate work of both `.splices` and `.length` updates.
|
|
95
|
-
if (changeRecord.path === 'detailsOpenedItems.length' || !changeRecord.value) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
97
|
+
_detailsOpenedItemsChanged(detailsOpenedItems, rowDetailsRenderer) {
|
|
99
98
|
iterateChildren(this.$.items, (row) => {
|
|
100
99
|
// Re-renders the row to possibly close the previously opened details.
|
|
101
100
|
if (row.hasAttribute('details-opened')) {
|
|
@@ -61,6 +61,7 @@ export const ScrollMixin = (superClass) =>
|
|
|
61
61
|
columnRendering: {
|
|
62
62
|
type: String,
|
|
63
63
|
value: 'eager',
|
|
64
|
+
sync: true,
|
|
64
65
|
},
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -160,7 +161,7 @@ export const ScrollMixin = (superClass) =>
|
|
|
160
161
|
* @protected
|
|
161
162
|
*/
|
|
162
163
|
_scrollToFlatIndex(index) {
|
|
163
|
-
index = Math.min(this.
|
|
164
|
+
index = Math.min(this._flatSize - 1, Math.max(0, index));
|
|
164
165
|
this.__virtualizer.scrollToIndex(index);
|
|
165
166
|
this.__scrollIntoViewport(index);
|
|
166
167
|
}
|
|
@@ -28,6 +28,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
28
28
|
width: {
|
|
29
29
|
type: String,
|
|
30
30
|
value: '58px',
|
|
31
|
+
sync: true,
|
|
31
32
|
},
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -38,6 +39,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
38
39
|
flexGrow: {
|
|
39
40
|
type: Number,
|
|
40
41
|
value: 0,
|
|
42
|
+
sync: true,
|
|
41
43
|
},
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -49,6 +51,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
49
51
|
type: Boolean,
|
|
50
52
|
value: false,
|
|
51
53
|
notify: true,
|
|
54
|
+
sync: true,
|
|
52
55
|
},
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -59,6 +62,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
59
62
|
autoSelect: {
|
|
60
63
|
type: Boolean,
|
|
61
64
|
value: false,
|
|
65
|
+
sync: true,
|
|
62
66
|
},
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -69,10 +73,14 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
69
73
|
dragSelect: {
|
|
70
74
|
type: Boolean,
|
|
71
75
|
value: false,
|
|
76
|
+
sync: true,
|
|
72
77
|
},
|
|
73
78
|
|
|
74
79
|
/** @protected */
|
|
75
|
-
_indeterminate:
|
|
80
|
+
_indeterminate: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
sync: true,
|
|
83
|
+
},
|
|
76
84
|
|
|
77
85
|
/** @protected */
|
|
78
86
|
_selectAllHidden: Boolean,
|
|
@@ -181,7 +189,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
181
189
|
// Get the row where the drag started
|
|
182
190
|
const dragStartRow = renderedRows.find((row) => row.contains(event.currentTarget.assignedSlot));
|
|
183
191
|
// Whether to select or deselect the items on drag
|
|
184
|
-
this.
|
|
192
|
+
this.__selectOnDrag = !this._grid._isSelected(dragStartRow._item);
|
|
185
193
|
// Store the index of the row where the drag started
|
|
186
194
|
this.__dragStartIndex = dragStartRow.index;
|
|
187
195
|
// Store the item of the row where the drag started
|
|
@@ -191,7 +199,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
191
199
|
} else if (event.detail.state === 'end') {
|
|
192
200
|
// if drag start and end stays within the same item, then toggle its state
|
|
193
201
|
if (this.__dragStartItem) {
|
|
194
|
-
if (this.
|
|
202
|
+
if (this.__selectOnDrag) {
|
|
195
203
|
this._selectItem(this.__dragStartItem);
|
|
196
204
|
} else {
|
|
197
205
|
this._deselectItem(this.__dragStartItem);
|
|
@@ -254,7 +262,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
254
262
|
(hoveredIndex > this.__dragStartIndex && row.index >= this.__dragStartIndex && row.index <= hoveredIndex) ||
|
|
255
263
|
(hoveredIndex < this.__dragStartIndex && row.index <= this.__dragStartIndex && row.index >= hoveredIndex)
|
|
256
264
|
) {
|
|
257
|
-
if (this.
|
|
265
|
+
if (this.__selectOnDrag) {
|
|
258
266
|
this._selectItem(row._item);
|
|
259
267
|
} else {
|
|
260
268
|
this._deselectItem(row._item);
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { GridSelectionColumnBaseMixinClass } from './vaadin-grid-selection-column-base-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Fired when the `selectAll` property changes.
|
|
11
|
+
*/
|
|
12
|
+
export type GridSelectionColumnSelectAllChangedEvent = CustomEvent<{ value: boolean }>;
|
|
13
|
+
|
|
14
|
+
export interface GridSelectionColumnCustomEventMap {
|
|
15
|
+
'select-all-changed': GridSelectionColumnSelectAllChangedEvent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface GridSelectionColumnEventMap extends HTMLElementEventMap, GridSelectionColumnCustomEventMap {}
|
|
19
|
+
|
|
20
|
+
export declare function GridSelectionColumnMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
21
|
+
superclass: T,
|
|
22
|
+
): Constructor<GridSelectionColumnMixinClass<TItem>> & T;
|
|
23
|
+
|
|
24
|
+
export declare class GridSelectionColumnMixinClass<TItem> extends GridSelectionColumnBaseMixinClass<TItem> {}
|