@vaadin/grid 23.3.3 → 24.0.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 +10 -10
- package/src/all-imports.js +1 -1
- package/src/array-data-provider.js +1 -1
- package/src/lit/column-renderer-directives.d.ts +1 -1
- package/src/lit/column-renderer-directives.js +1 -1
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-grid-a11y-mixin.js +12 -9
- package/src/vaadin-grid-active-item-mixin.d.ts +1 -1
- package/src/vaadin-grid-active-item-mixin.js +5 -3
- package/src/vaadin-grid-array-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-grid-array-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-column-group.d.ts +1 -1
- package/src/vaadin-grid-column-group.js +17 -17
- package/src/vaadin-grid-column-reordering-mixin.d.ts +1 -1
- package/src/vaadin-grid-column-reordering-mixin.js +7 -9
- package/src/vaadin-grid-column-resizing-mixin.js +6 -5
- package/src/vaadin-grid-column.d.ts +1 -1
- package/src/vaadin-grid-column.js +48 -34
- package/src/vaadin-grid-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-grid-data-provider-mixin.js +33 -7
- package/src/vaadin-grid-drag-and-drop-mixin.d.ts +1 -1
- package/src/vaadin-grid-drag-and-drop-mixin.js +23 -18
- package/src/vaadin-grid-dynamic-columns-mixin.js +5 -4
- package/src/vaadin-grid-event-context-mixin.d.ts +1 -1
- package/src/vaadin-grid-event-context-mixin.js +1 -1
- package/src/vaadin-grid-filter-column.d.ts +1 -1
- package/src/vaadin-grid-filter-column.js +1 -2
- package/src/vaadin-grid-filter-mixin.js +1 -1
- package/src/vaadin-grid-filter.d.ts +3 -2
- package/src/vaadin-grid-filter.js +27 -22
- package/src/vaadin-grid-helpers.js +104 -1
- package/src/vaadin-grid-keyboard-navigation-mixin.js +35 -34
- package/src/vaadin-grid-row-details-mixin.d.ts +1 -1
- package/src/vaadin-grid-row-details-mixin.js +5 -4
- package/src/vaadin-grid-scroll-mixin.d.ts +1 -1
- package/src/vaadin-grid-scroll-mixin.js +10 -9
- package/src/vaadin-grid-selection-column.d.ts +1 -1
- package/src/vaadin-grid-selection-column.js +1 -1
- package/src/vaadin-grid-selection-mixin.d.ts +1 -1
- package/src/vaadin-grid-selection-mixin.js +1 -1
- package/src/vaadin-grid-sort-column.d.ts +1 -1
- package/src/vaadin-grid-sort-column.js +1 -1
- package/src/vaadin-grid-sort-mixin.d.ts +1 -1
- package/src/vaadin-grid-sort-mixin.js +1 -1
- package/src/vaadin-grid-sorter.d.ts +1 -1
- package/src/vaadin-grid-sorter.js +1 -1
- package/src/vaadin-grid-styles.js +1 -1
- package/src/vaadin-grid-styling-mixin.d.ts +38 -2
- package/src/vaadin-grid-styling-mixin.js +77 -6
- package/src/vaadin-grid-tree-column.d.ts +1 -8
- package/src/vaadin-grid-tree-column.js +2 -25
- package/src/vaadin-grid-tree-toggle.d.ts +1 -1
- package/src/vaadin-grid-tree-toggle.js +1 -1
- package/src/vaadin-grid.d.ts +57 -25
- package/src/vaadin-grid.js +131 -79
- package/theme/lumo/vaadin-grid-styles.js +14 -14
- package/theme/material/vaadin-grid-styles.js +1 -1
- package/web-types.json +15 -26
- package/web-types.lit.json +11 -11
package/src/vaadin-grid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
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
|
import './vaadin-grid-column.js';
|
|
@@ -27,6 +27,7 @@ import { DragAndDropMixin } from './vaadin-grid-drag-and-drop-mixin.js';
|
|
|
27
27
|
import { DynamicColumnsMixin } from './vaadin-grid-dynamic-columns-mixin.js';
|
|
28
28
|
import { EventContextMixin } from './vaadin-grid-event-context-mixin.js';
|
|
29
29
|
import { FilterMixin } from './vaadin-grid-filter-mixin.js';
|
|
30
|
+
import { getBodyRowCells, iterateChildren, updateCellsPart, updateRowStates } from './vaadin-grid-helpers.js';
|
|
30
31
|
import { KeyboardNavigationMixin } from './vaadin-grid-keyboard-navigation-mixin.js';
|
|
31
32
|
import { RowDetailsMixin } from './vaadin-grid-row-details-mixin.js';
|
|
32
33
|
import { ScrollMixin } from './vaadin-grid-scroll-mixin.js';
|
|
@@ -174,17 +175,56 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
|
|
|
174
175
|
*
|
|
175
176
|
* The following shadow DOM parts are available for styling:
|
|
176
177
|
*
|
|
177
|
-
* Part name
|
|
178
|
-
*
|
|
179
|
-
* `row`
|
|
180
|
-
* `
|
|
181
|
-
* `
|
|
182
|
-
* `
|
|
183
|
-
* `
|
|
184
|
-
* `
|
|
185
|
-
* `
|
|
186
|
-
* `
|
|
187
|
-
* `
|
|
178
|
+
* Part name | Description
|
|
179
|
+
* ---------------------------|----------------
|
|
180
|
+
* `row` | Row in the internal table
|
|
181
|
+
* `expanded-row` | Expanded row
|
|
182
|
+
* `selected-row` | Selected row
|
|
183
|
+
* `details-opened-row` | Row with details open
|
|
184
|
+
* `odd-row` | Odd row
|
|
185
|
+
* `even-row` | Even row
|
|
186
|
+
* `first-row` | The first body row
|
|
187
|
+
* `last-row` | The last body row
|
|
188
|
+
* `dragstart-row` | Set on the row for one frame when drag is starting.
|
|
189
|
+
* `dragover-above-row` | Set on the row when the a row is dragged over above
|
|
190
|
+
* `dragover-below-row` | Set on the row when the a row is dragged over below
|
|
191
|
+
* `dragover-on-top-row` | Set on the row when the a row is dragged over on top
|
|
192
|
+
* `drag-disabled-row` | Set to a row that isn't available for dragging
|
|
193
|
+
* `drop-disabled-row` | Set to a row that can't be dropped on top of
|
|
194
|
+
* `cell` | Cell in the internal table
|
|
195
|
+
* `header-cell` | Header cell in the internal table
|
|
196
|
+
* `body-cell` | Body cell in the internal table
|
|
197
|
+
* `footer-cell` | Footer cell in the internal table
|
|
198
|
+
* `details-cell` | Row details cell in the internal table
|
|
199
|
+
* `focused-cell` | Focused cell in the internal table
|
|
200
|
+
* `odd-row-cell` | Cell in an odd row
|
|
201
|
+
* `even-row-cell` | Cell in an even row
|
|
202
|
+
* `first-row-cell` | Cell in the first body row
|
|
203
|
+
* `last-row-cell` | Cell in the last body row
|
|
204
|
+
* `first-header-row-cell` | Cell in the first header row
|
|
205
|
+
* `first-footer-row-cell` | Cell in the first footer row
|
|
206
|
+
* `last-header-row-cell` | Cell in the last header row
|
|
207
|
+
* `last-footer-row-cell` | Cell in the last footer row
|
|
208
|
+
* `loading-row-cell` | Cell in a row that is waiting for data from data provider
|
|
209
|
+
* `selected-row-cell` | Cell in a selected row
|
|
210
|
+
* `expanded-row-cell` | Cell in an expanded row
|
|
211
|
+
* `details-opened-row-cell` | Cell in an row with details open
|
|
212
|
+
* `dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)
|
|
213
|
+
* `dragover-above-row-cell` | Cell in a row that has another row dragged over above
|
|
214
|
+
* `dragover-below-row-cell` | Cell in a row that has another row dragged over below
|
|
215
|
+
* `dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top
|
|
216
|
+
* `drag-disabled-row-cell` | Cell in a row that isn't available for dragging
|
|
217
|
+
* `drop-disabled-row-cell` | Cell in a row that can't be dropped on top of
|
|
218
|
+
* `frozen-cell` | Frozen cell in the internal table
|
|
219
|
+
* `frozen-to-end-cell` | Frozen to end cell in the internal table
|
|
220
|
+
* `last-frozen-cell` | Last frozen cell
|
|
221
|
+
* `first-frozen-to-end-cell` | First cell frozen to end
|
|
222
|
+
* `first-column-cell` | First visible cell on a row
|
|
223
|
+
* `last-column-cell` | Last visible cell on a row
|
|
224
|
+
* `reorder-allowed-cell` | Cell in a column where another column can be reordered
|
|
225
|
+
* `reorder-dragging-cell` | Cell in a column currently being reordered
|
|
226
|
+
* `resize-handle` | Handle for resizing the columns
|
|
227
|
+
* `reorder-ghost` | Ghost element of the header cell being dragged
|
|
188
228
|
*
|
|
189
229
|
* The following state attributes are available for styling:
|
|
190
230
|
*
|
|
@@ -396,6 +436,18 @@ class Grid extends ElementMixin(
|
|
|
396
436
|
this.addEventListener('animationend', this._onAnimationEnd);
|
|
397
437
|
}
|
|
398
438
|
|
|
439
|
+
/** @private */
|
|
440
|
+
get _firstVisibleIndex() {
|
|
441
|
+
const firstVisibleItem = this.__getFirstVisibleItem();
|
|
442
|
+
return firstVisibleItem ? firstVisibleItem.index : undefined;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** @private */
|
|
446
|
+
get _lastVisibleIndex() {
|
|
447
|
+
const lastVisibleItem = this.__getLastVisibleItem();
|
|
448
|
+
return lastVisibleItem ? lastVisibleItem.index : undefined;
|
|
449
|
+
}
|
|
450
|
+
|
|
399
451
|
/** @protected */
|
|
400
452
|
connectedCallback() {
|
|
401
453
|
super.connectedCallback();
|
|
@@ -415,12 +467,6 @@ class Grid extends ElementMixin(
|
|
|
415
467
|
return this._getVisibleRows().find((row) => this._isInViewport(row));
|
|
416
468
|
}
|
|
417
469
|
|
|
418
|
-
/** @private */
|
|
419
|
-
get _firstVisibleIndex() {
|
|
420
|
-
const firstVisibleItem = this.__getFirstVisibleItem();
|
|
421
|
-
return firstVisibleItem ? firstVisibleItem.index : undefined;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
470
|
/** @private */
|
|
425
471
|
__getLastVisibleItem() {
|
|
426
472
|
return this._getVisibleRows()
|
|
@@ -428,12 +474,6 @@ class Grid extends ElementMixin(
|
|
|
428
474
|
.find((row) => this._isInViewport(row));
|
|
429
475
|
}
|
|
430
476
|
|
|
431
|
-
/** @private */
|
|
432
|
-
get _lastVisibleIndex() {
|
|
433
|
-
const lastVisibleItem = this.__getLastVisibleItem();
|
|
434
|
-
return lastVisibleItem ? lastVisibleItem.index : undefined;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
477
|
/** @private */
|
|
438
478
|
_isInViewport(item) {
|
|
439
479
|
const scrollTargetRect = this.$.table.getBoundingClientRect();
|
|
@@ -473,19 +513,6 @@ class Grid extends ElementMixin(
|
|
|
473
513
|
this._tooltipController.setManual(true);
|
|
474
514
|
}
|
|
475
515
|
|
|
476
|
-
/**
|
|
477
|
-
* @param {string} name
|
|
478
|
-
* @param {?string} oldValue
|
|
479
|
-
* @param {?string} newValue
|
|
480
|
-
* @protected
|
|
481
|
-
*/
|
|
482
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
483
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
484
|
-
if (name === 'dir') {
|
|
485
|
-
this.__isRTL = newValue === 'rtl';
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
516
|
/** @private */
|
|
490
517
|
__getBodyCellCoordinates(cell) {
|
|
491
518
|
if (this.$.items.contains(cell) && cell.localName === 'td') {
|
|
@@ -512,9 +539,15 @@ class Grid extends ElementMixin(
|
|
|
512
539
|
const cell = this.shadowRoot.activeElement;
|
|
513
540
|
const cellCoordinates = this.__getBodyCellCoordinates(cell);
|
|
514
541
|
|
|
542
|
+
const previousSize = virtualizer.size || 0;
|
|
515
543
|
virtualizer.size = effectiveSize;
|
|
516
|
-
|
|
517
|
-
|
|
544
|
+
|
|
545
|
+
// Request an update for the previous last row to have the "last" state removed
|
|
546
|
+
virtualizer.update(previousSize - 1, previousSize - 1);
|
|
547
|
+
if (effectiveSize < previousSize) {
|
|
548
|
+
// Size was decreased, so the new last row requires an explicit update
|
|
549
|
+
virtualizer.update(effectiveSize - 1, effectiveSize - 1);
|
|
550
|
+
}
|
|
518
551
|
|
|
519
552
|
// If the focused cell's parent row got hidden by the size change, focus the corresponding new cell
|
|
520
553
|
if (cellCoordinates && cell.parentElement.hidden) {
|
|
@@ -776,13 +809,10 @@ class Grid extends ElementMixin(
|
|
|
776
809
|
* @param {boolean} noNotify
|
|
777
810
|
* @protected
|
|
778
811
|
*/
|
|
779
|
-
|
|
780
|
-
_updateRow(row, columns, section, isColumnRow, noNotify) {
|
|
781
|
-
section = section || 'body';
|
|
782
|
-
|
|
812
|
+
_updateRow(row, columns, section = 'body', isColumnRow = false, noNotify = false) {
|
|
783
813
|
const contentsFragment = document.createDocumentFragment();
|
|
784
814
|
|
|
785
|
-
|
|
815
|
+
iterateChildren(row, (cell) => {
|
|
786
816
|
cell._vacant = true;
|
|
787
817
|
});
|
|
788
818
|
row.innerHTML = '';
|
|
@@ -794,7 +824,9 @@ class Grid extends ElementMixin(
|
|
|
794
824
|
|
|
795
825
|
if (section === 'body') {
|
|
796
826
|
// Body
|
|
797
|
-
|
|
827
|
+
if (!column._cells) {
|
|
828
|
+
column._cells = [];
|
|
829
|
+
}
|
|
798
830
|
cell = column._cells.find((cell) => cell._vacant);
|
|
799
831
|
if (!cell) {
|
|
800
832
|
cell = this._createCell('td', column);
|
|
@@ -805,7 +837,9 @@ class Grid extends ElementMixin(
|
|
|
805
837
|
|
|
806
838
|
if (index === cols.length - 1 && this.rowDetailsRenderer) {
|
|
807
839
|
// Add details cell as last cell to body rows
|
|
808
|
-
|
|
840
|
+
if (!this._detailsCells) {
|
|
841
|
+
this._detailsCells = [];
|
|
842
|
+
}
|
|
809
843
|
const detailsCell = this._detailsCells.find((cell) => cell._vacant) || this._createCell('td');
|
|
810
844
|
if (this._detailsCells.indexOf(detailsCell) === -1) {
|
|
811
845
|
this._detailsCells.push(detailsCell);
|
|
@@ -831,7 +865,9 @@ class Grid extends ElementMixin(
|
|
|
831
865
|
row.appendChild(cell);
|
|
832
866
|
column[`_${section}Cell`] = cell;
|
|
833
867
|
} else {
|
|
834
|
-
|
|
868
|
+
if (!column._emptyCells) {
|
|
869
|
+
column._emptyCells = [];
|
|
870
|
+
}
|
|
835
871
|
cell = column._emptyCells.find((cell) => cell._vacant) || this._createCell(tagName);
|
|
836
872
|
cell._column = column;
|
|
837
873
|
row.appendChild(cell);
|
|
@@ -926,9 +962,8 @@ class Grid extends ElementMixin(
|
|
|
926
962
|
return;
|
|
927
963
|
}
|
|
928
964
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
row.toggleAttribute('odd', index % 2);
|
|
965
|
+
this._updateRowOrderParts(row, index);
|
|
966
|
+
|
|
932
967
|
this._a11yUpdateRowRowindex(row, index);
|
|
933
968
|
this._getItem(index, row);
|
|
934
969
|
}
|
|
@@ -939,14 +974,38 @@ class Grid extends ElementMixin(
|
|
|
939
974
|
this.recalculateColumnWidths();
|
|
940
975
|
}
|
|
941
976
|
|
|
977
|
+
/** @private */
|
|
978
|
+
_updateRowOrderParts(row, index = row.index) {
|
|
979
|
+
updateRowStates(row, {
|
|
980
|
+
first: index === 0,
|
|
981
|
+
last: index === this._effectiveSize - 1,
|
|
982
|
+
odd: index % 2 !== 0,
|
|
983
|
+
even: index % 2 === 0,
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/** @private */
|
|
988
|
+
_updateRowStateParts(row, { expanded, selected, detailsOpened }) {
|
|
989
|
+
updateRowStates(row, {
|
|
990
|
+
expanded,
|
|
991
|
+
selected,
|
|
992
|
+
'details-opened': detailsOpened,
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
|
|
942
996
|
/**
|
|
943
997
|
* @param {!Array<!GridColumn>} columnTree
|
|
944
998
|
* @protected
|
|
945
999
|
*/
|
|
946
1000
|
_renderColumnTree(columnTree) {
|
|
947
|
-
|
|
948
|
-
this._updateRow(row, columnTree[columnTree.length - 1],
|
|
949
|
-
|
|
1001
|
+
iterateChildren(this.$.items, (row) => {
|
|
1002
|
+
this._updateRow(row, columnTree[columnTree.length - 1], 'body', false, true);
|
|
1003
|
+
|
|
1004
|
+
const model = this.__getRowModel(row);
|
|
1005
|
+
this._updateRowOrderParts(row);
|
|
1006
|
+
this._updateRowStateParts(row, model);
|
|
1007
|
+
this._filterDragAndDrop(row, model);
|
|
1008
|
+
});
|
|
950
1009
|
|
|
951
1010
|
while (this.$.header.children.length < columnTree.length) {
|
|
952
1011
|
const headerRow = document.createElement('tr');
|
|
@@ -966,13 +1025,21 @@ class Grid extends ElementMixin(
|
|
|
966
1025
|
this.$.footer.removeChild(this.$.footer.firstElementChild);
|
|
967
1026
|
}
|
|
968
1027
|
|
|
969
|
-
|
|
970
|
-
this._updateRow(headerRow, columnTree[index], 'header', index === columnTree.length - 1)
|
|
971
|
-
);
|
|
1028
|
+
iterateChildren(this.$.header, (headerRow, index, rows) => {
|
|
1029
|
+
this._updateRow(headerRow, columnTree[index], 'header', index === columnTree.length - 1);
|
|
972
1030
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1031
|
+
const cells = getBodyRowCells(headerRow);
|
|
1032
|
+
updateCellsPart(cells, 'first-header-row-cell', index === 0);
|
|
1033
|
+
updateCellsPart(cells, 'last-header-row-cell', index === rows.length - 1);
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
iterateChildren(this.$.footer, (footerRow, index, rows) => {
|
|
1037
|
+
this._updateRow(footerRow, columnTree[columnTree.length - 1 - index], 'footer', index === 0);
|
|
1038
|
+
|
|
1039
|
+
const cells = getBodyRowCells(footerRow);
|
|
1040
|
+
updateCellsPart(cells, 'first-footer-row-cell', index === 0);
|
|
1041
|
+
updateCellsPart(cells, 'last-footer-row-cell', index === rows.length - 1);
|
|
1042
|
+
});
|
|
976
1043
|
|
|
977
1044
|
// Sizer rows
|
|
978
1045
|
this._updateRow(this.$.sizer, columnTree[columnTree.length - 1]);
|
|
@@ -985,12 +1052,13 @@ class Grid extends ElementMixin(
|
|
|
985
1052
|
this._a11yUpdateFooterRows();
|
|
986
1053
|
this.__updateFooterPositioning();
|
|
987
1054
|
this.generateCellClassNames();
|
|
1055
|
+
this.generateCellPartNames();
|
|
988
1056
|
}
|
|
989
1057
|
|
|
990
1058
|
/** @private */
|
|
991
1059
|
__updateFooterPositioning() {
|
|
992
1060
|
// TODO: fixed in Firefox 99, remove when we can drop Firefox ESR 91 support
|
|
993
|
-
if (this._firefox && parseFloat(navigator.userAgent.match(/Firefox\/(\d{2,3}.\d)/)[1]) < 99) {
|
|
1061
|
+
if (this._firefox && parseFloat(navigator.userAgent.match(/Firefox\/(\d{2,3}.\d)/u)[1]) < 99) {
|
|
994
1062
|
// Sticky (or translated) footer in a flexbox host doesn't get included in
|
|
995
1063
|
// the scroll height calculation on FF. This is a workaround for the issue.
|
|
996
1064
|
this.$.items.style.paddingBottom = 0;
|
|
@@ -1014,14 +1082,13 @@ class Grid extends ElementMixin(
|
|
|
1014
1082
|
this._a11yUpdateRowLevel(row, model.level);
|
|
1015
1083
|
this._a11yUpdateRowSelected(row, model.selected);
|
|
1016
1084
|
|
|
1017
|
-
|
|
1018
|
-
row.toggleAttribute('selected', model.selected);
|
|
1019
|
-
row.toggleAttribute('details-opened', model.detailsOpened);
|
|
1085
|
+
this._updateRowStateParts(row, model);
|
|
1020
1086
|
|
|
1021
1087
|
this._generateCellClassNames(row, model);
|
|
1088
|
+
this._generateCellPartNames(row, model);
|
|
1022
1089
|
this._filterDragAndDrop(row, model);
|
|
1023
1090
|
|
|
1024
|
-
|
|
1091
|
+
iterateChildren(row, (cell) => {
|
|
1025
1092
|
if (cell._renderer) {
|
|
1026
1093
|
const owner = cell._column || this;
|
|
1027
1094
|
cell._renderer.call(owner, cell._content, owner, model);
|
|
@@ -1129,21 +1196,6 @@ class Grid extends ElementMixin(
|
|
|
1129
1196
|
this.__virtualizer.update(start, end);
|
|
1130
1197
|
}
|
|
1131
1198
|
}
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* Updates the computed metrics and positioning of internal grid parts
|
|
1135
|
-
* (row/details cell positioning etc). Needs to be invoked whenever the sizing of grid
|
|
1136
|
-
* content changes asynchronously to ensure consistent appearance (e.g. when a
|
|
1137
|
-
* contained image whose bounds aren't known beforehand finishes loading).
|
|
1138
|
-
*
|
|
1139
|
-
* @deprecated Since Vaadin 22, `notifyResize()` is deprecated. The component uses a
|
|
1140
|
-
* ResizeObserver internally and doesn't need to be explicitly notified of resizes.
|
|
1141
|
-
*/
|
|
1142
|
-
notifyResize() {
|
|
1143
|
-
console.warn(
|
|
1144
|
-
`WARNING: Since Vaadin 22, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.`,
|
|
1145
|
-
);
|
|
1146
|
-
}
|
|
1147
1199
|
}
|
|
1148
1200
|
|
|
1149
1201
|
customElements.define(Grid.is, Grid);
|
|
@@ -57,7 +57,7 @@ registerStyles(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/* Hide first body row top border */
|
|
60
|
-
:host(:not([theme~='no-row-borders'])) [part
|
|
60
|
+
:host(:not([theme~='no-row-borders'])) [part~='first-row'] [part~='cell']:not([part~='details-cell']) {
|
|
61
61
|
border-top: 0;
|
|
62
62
|
min-height: calc(var(--lumo-size-m) - var(--_lumo-grid-border-width));
|
|
63
63
|
}
|
|
@@ -137,7 +137,7 @@ registerStyles(
|
|
|
137
137
|
margin-top: -1px;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
:host([all-rows-visible]) [part~='row'][
|
|
140
|
+
:host([all-rows-visible]) [part~='last-row'][dragover='below'] [part~='cell']::after {
|
|
141
141
|
height: 1px;
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -207,42 +207,42 @@ registerStyles(
|
|
|
207
207
|
font-weight: 400;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
[part
|
|
210
|
+
[part~='row']:only-child [part~='header-cell'] {
|
|
211
211
|
min-height: var(--lumo-size-xl);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/* Header borders */
|
|
215
215
|
|
|
216
216
|
/* Hide first header row top border */
|
|
217
|
-
:host(:not([theme~='no-row-borders'])) [part
|
|
217
|
+
:host(:not([theme~='no-row-borders'])) [part~='row']:first-child [part~='header-cell'] {
|
|
218
218
|
border-top: 0;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
[part
|
|
221
|
+
[part~='row']:last-child [part~='header-cell'] {
|
|
222
222
|
border-bottom: var(--_lumo-grid-border-width) solid transparent;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
:host(:not([theme~='no-row-borders'])) [part
|
|
225
|
+
:host(:not([theme~='no-row-borders'])) [part~='row']:last-child [part~='header-cell'] {
|
|
226
226
|
border-bottom-color: var(--_lumo-grid-secondary-border-color);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/* Overflow uses a stronger border color */
|
|
230
|
-
:host([overflow~='top']) [part
|
|
230
|
+
:host([overflow~='top']) [part~='row']:last-child [part~='header-cell'] {
|
|
231
231
|
border-bottom-color: var(--_lumo-grid-border-color);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
/* Footer borders */
|
|
235
235
|
|
|
236
|
-
[part
|
|
236
|
+
[part~='row']:first-child [part~='footer-cell'] {
|
|
237
237
|
border-top: var(--_lumo-grid-border-width) solid transparent;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
:host(:not([theme~='no-row-borders'])) [part
|
|
240
|
+
:host(:not([theme~='no-row-borders'])) [part~='row']:first-child [part~='footer-cell'] {
|
|
241
241
|
border-top-color: var(--_lumo-grid-secondary-border-color);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/* Overflow uses a stronger border color */
|
|
245
|
-
:host([overflow~='bottom']) [part
|
|
245
|
+
:host([overflow~='bottom']) [part~='row']:first-child [part~='footer-cell'] {
|
|
246
246
|
border-top-color: var(--_lumo-grid-border-color);
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -309,8 +309,8 @@ registerStyles(
|
|
|
309
309
|
|
|
310
310
|
/* Row stripes */
|
|
311
311
|
|
|
312
|
-
:host([theme~='row-stripes']) [part~='row']
|
|
313
|
-
:host([theme~='row-stripes']) [part~='row']
|
|
312
|
+
:host([theme~='row-stripes']) [part~='even-row'] [part~='body-cell'],
|
|
313
|
+
:host([theme~='row-stripes']) [part~='even-row'] [part~='details-cell'] {
|
|
314
314
|
background-image: linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
|
|
315
315
|
background-repeat: repeat-x;
|
|
316
316
|
}
|
|
@@ -334,7 +334,7 @@ registerStyles(
|
|
|
334
334
|
|
|
335
335
|
/* Compact */
|
|
336
336
|
|
|
337
|
-
:host([theme~='compact']) [part
|
|
337
|
+
:host([theme~='compact']) [part~='row']:only-child [part~='header-cell'] {
|
|
338
338
|
min-height: var(--lumo-size-m);
|
|
339
339
|
}
|
|
340
340
|
|
|
@@ -342,7 +342,7 @@ registerStyles(
|
|
|
342
342
|
min-height: var(--lumo-size-s);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
:host([theme~='compact']) [part
|
|
345
|
+
:host([theme~='compact']) [part~='first-row'] [part~='cell']:not([part~='details-cell']) {
|
|
346
346
|
min-height: calc(var(--lumo-size-s) - var(--_lumo-grid-border-width));
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -191,7 +191,7 @@ registerStyles(
|
|
|
191
191
|
margin-top: -1px;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
:host([all-rows-visible]) [part~='row'][
|
|
194
|
+
:host([all-rows-visible]) [part~='last-row'][dragover='below'] [part~='cell']::after {
|
|
195
195
|
height: 1px;
|
|
196
196
|
}
|
|
197
197
|
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/grid",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "24.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-grid-column",
|
|
11
|
-
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "A `<vaadin-grid-column>` is used to configure how a column in `<vaadin-grid>`\nshould look like.\n\nSee [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "resizable",
|
|
@@ -765,7 +765,7 @@
|
|
|
765
765
|
},
|
|
766
766
|
{
|
|
767
767
|
"name": "vaadin-grid-selection-column",
|
|
768
|
-
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/
|
|
768
|
+
"description": "`<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`\nthat provides default renderers and functionality for item selection.\n\n#### Example:\n```html\n<vaadin-grid items=\"[[items]]\">\n <vaadin-grid-selection-column frozen auto-select></vaadin-grid-selection-column>\n\n <vaadin-grid-column>\n ...\n```\n\nBy default the selection column displays `<vaadin-checkbox>` elements in the\ncolumn cells. The checkboxes in the body rows toggle selection of the corresponding row items.\n\nWhen the grid data is provided as an array of [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid#property-items),\nthe column header gets an additional checkbox that can be used for toggling\nselection for all the items at once.\n\n__The default content can also be overridden__",
|
|
769
769
|
"attributes": [
|
|
770
770
|
{
|
|
771
771
|
"name": "resizable",
|
|
@@ -1603,17 +1603,6 @@
|
|
|
1603
1603
|
]
|
|
1604
1604
|
}
|
|
1605
1605
|
},
|
|
1606
|
-
{
|
|
1607
|
-
"name": "item-has-children-path",
|
|
1608
|
-
"description": "JS Path of the property in the item that indicates whether the item has child items.",
|
|
1609
|
-
"value": {
|
|
1610
|
-
"type": [
|
|
1611
|
-
"string",
|
|
1612
|
-
"null",
|
|
1613
|
-
"undefined"
|
|
1614
|
-
]
|
|
1615
|
-
}
|
|
1616
|
-
},
|
|
1617
1606
|
{
|
|
1618
1607
|
"name": "theme",
|
|
1619
1608
|
"description": "The theme variants to apply to the component.",
|
|
@@ -1762,17 +1751,6 @@
|
|
|
1762
1751
|
"boolean"
|
|
1763
1752
|
]
|
|
1764
1753
|
}
|
|
1765
|
-
},
|
|
1766
|
-
{
|
|
1767
|
-
"name": "itemHasChildrenPath",
|
|
1768
|
-
"description": "JS Path of the property in the item that indicates whether the item has child items.",
|
|
1769
|
-
"value": {
|
|
1770
|
-
"type": [
|
|
1771
|
-
"string",
|
|
1772
|
-
"null",
|
|
1773
|
-
"undefined"
|
|
1774
|
-
]
|
|
1775
|
-
}
|
|
1776
1754
|
}
|
|
1777
1755
|
],
|
|
1778
1756
|
"events": []
|
|
@@ -1780,7 +1758,7 @@
|
|
|
1780
1758
|
},
|
|
1781
1759
|
{
|
|
1782
1760
|
"name": "vaadin-grid",
|
|
1783
|
-
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`row` | Row in the internal table\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`focused-cell` | Focused cell in the internal table\n`resize-handle` | Handle for resizing the columns\n`reorder-ghost` | Ghost element of the header cell being dragged\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n----------------------|---------------------------------------------------------------------------------------------------|-----------\n`loading` | Set when the grid is loading data from data provider | :host\n`interacting` | Keyboard navigation in interaction mode | :host\n`navigating` | Keyboard navigation in navigation mode | :host\n`overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host\n`reordering` | Set when the grid's columns are being reordered | :host\n`dragover` | Set when the grid (not a specific row) is dragged over | :host\n`dragging-rows` | Set when grid rows are dragged | :host\n`reorder-status` | Reflects the status of a cell while columns are being reordered | cell\n`frozen` | Frozen cell | cell\n`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | cell\n`first-column` | First visible cell on a row | cell\n`last-column` | Last visible cell on a row | cell\n`selected` | Selected row | row\n`expanded` | Expanded row | row\n`details-opened` | Row with details open | row\n`loading` | Row that is waiting for data from data provider | row\n`odd` | Odd row | row\n`first` | The first body row | row\n`last` | The last body row | row\n`dragstart` | Set for one frame when starting to drag a row. The value is a number when dragging multiple rows | row\n`dragover` | Set when the row is dragged over | row\n`drag-disabled` | Set to a row that isn't available for dragging | row\n`drop-disabled` | Set to a row that can't be dropped on top of | row\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
1761
|
+
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------------|----------------\n`row` | Row in the internal table\n`expanded-row` | Expanded row\n`selected-row` | Selected row\n`details-opened-row` | Row with details open\n`odd-row` | Odd row\n`even-row` | Even row\n`first-row` | The first body row\n`last-row` | The last body row\n`dragstart-row` | Set on the row for one frame when drag is starting.\n`dragover-above-row` | Set on the row when the a row is dragged over above\n`dragover-below-row` | Set on the row when the a row is dragged over below\n`dragover-on-top-row` | Set on the row when the a row is dragged over on top\n`drag-disabled-row` | Set to a row that isn't available for dragging\n`drop-disabled-row` | Set to a row that can't be dropped on top of\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`focused-cell` | Focused cell in the internal table\n`odd-row-cell` | Cell in an odd row\n`even-row-cell` | Cell in an even row\n`first-row-cell` | Cell in the first body row\n`last-row-cell` | Cell in the last body row\n`first-header-row-cell` | Cell in the first header row\n`first-footer-row-cell` | Cell in the first footer row\n`last-header-row-cell` | Cell in the last header row\n`last-footer-row-cell` | Cell in the last footer row\n`loading-row-cell` | Cell in a row that is waiting for data from data provider\n`selected-row-cell` | Cell in a selected row\n`expanded-row-cell` | Cell in an expanded row\n`details-opened-row-cell` | Cell in an row with details open\n`dragstart-row-cell` | Cell in a row that user started to drag (set for one frame)\n`dragover-above-row-cell` | Cell in a row that has another row dragged over above\n`dragover-below-row-cell` | Cell in a row that has another row dragged over below\n`dragover-on-top-row-cell` | Cell in a row that has another row dragged over on top\n`drag-disabled-row-cell` | Cell in a row that isn't available for dragging\n`drop-disabled-row-cell` | Cell in a row that can't be dropped on top of\n`frozen-cell` | Frozen cell in the internal table\n`frozen-to-end-cell` | Frozen to end cell in the internal table\n`last-frozen-cell` | Last frozen cell\n`first-frozen-to-end-cell` | First cell frozen to end\n`first-column-cell` | First visible cell on a row\n`last-column-cell` | Last visible cell on a row\n`reorder-allowed-cell` | Cell in a column where another column can be reordered\n`reorder-dragging-cell` | Cell in a column currently being reordered\n`resize-handle` | Handle for resizing the columns\n`reorder-ghost` | Ghost element of the header cell being dragged\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n----------------------|---------------------------------------------------------------------------------------------------|-----------\n`loading` | Set when the grid is loading data from data provider | :host\n`interacting` | Keyboard navigation in interaction mode | :host\n`navigating` | Keyboard navigation in navigation mode | :host\n`overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host\n`reordering` | Set when the grid's columns are being reordered | :host\n`dragover` | Set when the grid (not a specific row) is dragged over | :host\n`dragging-rows` | Set when grid rows are dragged | :host\n`reorder-status` | Reflects the status of a cell while columns are being reordered | cell\n`frozen` | Frozen cell | cell\n`frozen-to-end` | Cell frozen to end | cell\n`last-frozen` | Last frozen cell | cell\n`first-frozen-to-end` | First cell frozen to end | cell\n`first-column` | First visible cell on a row | cell\n`last-column` | Last visible cell on a row | cell\n`selected` | Selected row | row\n`expanded` | Expanded row | row\n`details-opened` | Row with details open | row\n`loading` | Row that is waiting for data from data provider | row\n`odd` | Odd row | row\n`first` | The first body row | row\n`last` | The last body row | row\n`dragstart` | Set for one frame when starting to drag a row. The value is a number when dragging multiple rows | row\n`dragover` | Set when the row is dragged over | row\n`drag-disabled` | Set to a row that isn't available for dragging | row\n`drop-disabled` | Set to a row that can't be dropped on top of | row\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
1784
1762
|
"attributes": [
|
|
1785
1763
|
{
|
|
1786
1764
|
"name": "size",
|
|
@@ -2062,6 +2040,17 @@
|
|
|
2062
2040
|
]
|
|
2063
2041
|
}
|
|
2064
2042
|
},
|
|
2043
|
+
{
|
|
2044
|
+
"name": "cellPartNameGenerator",
|
|
2045
|
+
"description": "A function that allows generating CSS `part` names for grid cells in Shadow DOM based\non their row and column, for styling from outside using the `::part()` selector.\n\nThe return value should be the generated part name as a string, or multiple part names\nseparated by whitespace characters.\n\nReceives two arguments:\n- `column` The `<vaadin-grid-column>` element (`undefined` for details-cell).\n- `model` The object with the properties related with\n the rendered item, contains:\n - `model.index` The index of the item.\n - `model.item` The item.\n - `model.expanded` Sublevel toggle state.\n - `model.level` Level of the tree represented with a horizontal offset of the toggle button.\n - `model.selected` Selected state.",
|
|
2046
|
+
"value": {
|
|
2047
|
+
"type": [
|
|
2048
|
+
"GridCellPartNameGenerator",
|
|
2049
|
+
"null",
|
|
2050
|
+
"undefined"
|
|
2051
|
+
]
|
|
2052
|
+
}
|
|
2053
|
+
},
|
|
2065
2054
|
{
|
|
2066
2055
|
"name": "dropMode",
|
|
2067
2056
|
"description": "Defines the locations within the Grid row where an element can be dropped.\n\nPossible values are:\n- `between`: The drop event can happen between Grid rows.\n- `on-top`: The drop event can happen on top of Grid rows.\n- `on-top-or-between`: The drop event can happen either on top of or between Grid rows.\n- `on-grid`: The drop event will not happen on any specific row, it will show the drop target outline around the whole grid.",
|