@vaadin/grid 24.1.0-alpha1 → 24.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid",
3
- "version": "24.1.0-alpha1",
3
+ "version": "24.1.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,14 +46,14 @@
46
46
  "dependencies": {
47
47
  "@open-wc/dedupe-mixin": "^1.3.0",
48
48
  "@polymer/polymer": "^3.0.0",
49
- "@vaadin/a11y-base": "24.1.0-alpha1",
50
- "@vaadin/checkbox": "24.1.0-alpha1",
51
- "@vaadin/component-base": "24.1.0-alpha1",
52
- "@vaadin/lit-renderer": "24.1.0-alpha1",
53
- "@vaadin/text-field": "24.1.0-alpha1",
54
- "@vaadin/vaadin-lumo-styles": "24.1.0-alpha1",
55
- "@vaadin/vaadin-material-styles": "24.1.0-alpha1",
56
- "@vaadin/vaadin-themable-mixin": "24.1.0-alpha1"
49
+ "@vaadin/a11y-base": "24.1.0-alpha10",
50
+ "@vaadin/checkbox": "24.1.0-alpha10",
51
+ "@vaadin/component-base": "24.1.0-alpha10",
52
+ "@vaadin/lit-renderer": "24.1.0-alpha10",
53
+ "@vaadin/text-field": "24.1.0-alpha10",
54
+ "@vaadin/vaadin-lumo-styles": "24.1.0-alpha10",
55
+ "@vaadin/vaadin-material-styles": "24.1.0-alpha10",
56
+ "@vaadin/vaadin-themable-mixin": "24.1.0-alpha10"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@esm-bundle/chai": "^4.3.4",
@@ -65,5 +65,5 @@
65
65
  "web-types.json",
66
66
  "web-types.lit.json"
67
67
  ],
68
- "gitHead": "599a339181595923b9ad6373d6888d8a79540141"
68
+ "gitHead": "12e39be7eb3b49c68708e8ca3de2fb22e91051a1"
69
69
  }
@@ -95,6 +95,15 @@ export const ColumnBaseMixin = (superClass) =>
95
95
  value: false,
96
96
  },
97
97
 
98
+ /**
99
+ * @type {boolean}
100
+ * @protected
101
+ */
102
+ _bodyContentHidden: {
103
+ type: Boolean,
104
+ value: false,
105
+ },
106
+
98
107
  /**
99
108
  * @type {boolean}
100
109
  * @protected
@@ -207,7 +216,7 @@ export const ColumnBaseMixin = (superClass) =>
207
216
  '_orderChanged(_order, _headerCell, _footerCell, _cells.*)',
208
217
  '_lastFrozenChanged(_lastFrozen)',
209
218
  '_firstFrozenToEndChanged(_firstFrozenToEnd)',
210
- '_onRendererOrBindingChanged(_renderer, _cells, _cells.*, path)',
219
+ '_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)',
211
220
  '_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header)',
212
221
  '_onFooterRendererOrBindingChanged(_footerRenderer, _footerCell)',
213
222
  '_resizableChanged(resizable, _headerCell)',
@@ -54,6 +54,8 @@ export declare class ItemCache<TItem> {
54
54
  ensureSubCacheForScaledIndex(scaledIndex: number): void;
55
55
 
56
56
  getCacheAndIndex(index: number): { cache: ItemCache<TItem>; scaledIndex: number };
57
+
58
+ getFlatIndex(scaledIndex: number): number;
57
59
  }
58
60
 
59
61
  export declare function DataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
@@ -138,4 +140,19 @@ export declare class DataProviderMixinClass<TItem> {
138
140
  * Clears the cached pages and reloads data from dataprovider when needed.
139
141
  */
140
142
  clearCache(): void;
143
+
144
+ /**
145
+ * Scroll to a specific row index in the virtual list. Note that the row index is
146
+ * not always the same for any particular item. For example, sorting or filtering
147
+ * items can affect the row index related to an item.
148
+ *
149
+ * The `indexes` parameter can be either a single number or multiple numbers.
150
+ * The grid will first try to scroll to the item at the first index on the top level.
151
+ * In case the item at the first index is expanded, the grid will then try scroll to the
152
+ * item at the second index within the children of the expanded first item, and so on.
153
+ * Each given index points to a child of the item at the previous index.
154
+ *
155
+ * Using `Infinity` as an index will point to the last item on the level.
156
+ */
157
+ scrollToIndex(...indexes: number[]): void;
141
158
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { timeOut } from '@vaadin/component-base/src/async.js';
7
7
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
8
- import { getBodyRowCells, iterateChildren, updateCellsPart, updateState } from './vaadin-grid-helpers.js';
8
+ import { getBodyRowCells, updateCellsPart, updateState } from './vaadin-grid-helpers.js';
9
9
 
10
10
  /**
11
11
  * @private
@@ -96,6 +96,21 @@ export const ItemCache = class ItemCache {
96
96
  }
97
97
  return { cache: this, scaledIndex: thisLevelIndex };
98
98
  }
99
+
100
+ /**
101
+ * Gets the scaled index as flattened index on this cache level.
102
+ * In practice, this means that the effective size of any expanded
103
+ * subcaches preceding the index are added to the value.
104
+ * @param {number} scaledIndex
105
+ * @return {number} The flat index on this cache level.
106
+ */
107
+ getFlatIndex(scaledIndex) {
108
+ const clampedIndex = Math.max(0, Math.min(this.size - 1, scaledIndex));
109
+
110
+ return Object.entries(this.itemCaches).reduce((prev, [index, subCache]) => {
111
+ return clampedIndex > Number(index) ? prev + subCache.effectiveSize : prev;
112
+ }, clampedIndex);
113
+ }
99
114
  };
100
115
 
101
116
  /**
@@ -382,43 +397,50 @@ export const DataProviderMixin = (superClass) =>
382
397
  cache.size = items.length;
383
398
  }
384
399
 
385
- const currentItems = Array.from(this.$.items.children).map((row) => row._item);
386
-
387
400
  // Populate the cache with new items
388
401
  items.forEach((item, itemsIndex) => {
389
402
  const itemIndex = page * this.pageSize + itemsIndex;
390
403
  cache.items[itemIndex] = item;
391
- if (this._isExpanded(item) && currentItems.indexOf(item) > -1) {
392
- // Force synchronous data request for expanded item sub-cache
393
- cache.ensureSubCacheForScaledIndex(itemIndex);
404
+ });
405
+
406
+ // With the new items added, update the cache size and the grid's effective size
407
+ this._cache.updateSize();
408
+ this._effectiveSize = this._cache.effectiveSize;
409
+
410
+ // After updating the cache, check if some of the expanded items should have sub-caches loaded
411
+ this._getVisibleRows().forEach((row) => {
412
+ const { cache, scaledIndex } = this._cache.getCacheAndIndex(row.index);
413
+ const item = cache.items[scaledIndex];
414
+ if (item && this._isExpanded(item)) {
415
+ cache.ensureSubCacheForScaledIndex(scaledIndex);
394
416
  }
395
417
  });
396
418
 
397
419
  this._hasData = true;
398
420
 
421
+ // Remove the pending request
399
422
  delete cache.pendingRequests[page];
400
423
 
424
+ // Schedule a debouncer to update the visible rows
401
425
  this._debouncerApplyCachedData = Debouncer.debounce(this._debouncerApplyCachedData, timeOut.after(0), () => {
402
426
  this._setLoading(false);
403
- this._cache.updateSize();
404
- this._effectiveSize = this._cache.effectiveSize;
405
-
406
- iterateChildren(this.$.items, (row) => {
407
- if (!row.hidden) {
408
- const cachedItem = this._cache.getItemForIndex(row.index);
409
- if (cachedItem) {
410
- this._getItem(row.index, row);
411
- }
427
+
428
+ this._getVisibleRows().forEach((row) => {
429
+ const cachedItem = this._cache.getItemForIndex(row.index);
430
+ if (cachedItem) {
431
+ this._getItem(row.index, row);
412
432
  }
413
433
  });
414
434
 
415
- this.__scrollToPendingIndex();
435
+ this.__scrollToPendingIndexes();
416
436
  });
417
437
 
438
+ // If the grid is not loading anything, flush the debouncer immediately
418
439
  if (!this._cache.isLoading()) {
419
440
  this._debouncerApplyCachedData.flush();
420
441
  }
421
442
 
443
+ // Notify that new data has been received
422
444
  this.__itemsReceived();
423
445
  });
424
446
  }
@@ -517,19 +539,65 @@ export const DataProviderMixin = (superClass) =>
517
539
  return result;
518
540
  }
519
541
 
520
- scrollToIndex(index) {
521
- super.scrollToIndex(index);
522
- if (!isNaN(index) && (this._cache.isLoading() || !this.clientHeight)) {
523
- this.__pendingScrollToIndex = index;
542
+ /**
543
+ * Scroll to a specific row index in the virtual list. Note that the row index is
544
+ * not always the same for any particular item. For example, sorting or filtering
545
+ * items can affect the row index related to an item.
546
+ *
547
+ * The `indexes` parameter can be either a single number or multiple numbers.
548
+ * The grid will first try to scroll to the item at the first index on the top level.
549
+ * In case the item at the first index is expanded, the grid will then try scroll to the
550
+ * item at the second index within the children of the expanded first item, and so on.
551
+ * Each given index points to a child of the item at the previous index.
552
+ *
553
+ * Using `Infinity` as an index will point to the last item on the level.
554
+ *
555
+ * @param indexes {...number} Row indexes to scroll to
556
+ */
557
+ scrollToIndex(...indexes) {
558
+ // Synchronous data provider may cause changes to the cache on scroll without
559
+ // ending up in a loading state. Try scrolling to the index until the target
560
+ // index stabilizes.
561
+ let targetIndex;
562
+ while (targetIndex !== (targetIndex = this.__getGlobalFlatIndex(indexes))) {
563
+ this._scrollToFlatIndex(targetIndex);
564
+ }
565
+
566
+ if (this._cache.isLoading() || !this.clientHeight) {
567
+ this.__pendingScrollToIndexes = indexes;
568
+ }
569
+ }
570
+
571
+ /**
572
+ * Recursively returns the globally flat index of the item the given indexes point to.
573
+ * Each index in the array points to a sub-item of the previous index.
574
+ * Using `Infinity` as an index will point to the last item on the level.
575
+ *
576
+ * @param {!Array<number>} indexes
577
+ * @param {!ItemCache} cache
578
+ * @param {number} flatIndex
579
+ * @return {number}
580
+ * @private
581
+ */
582
+ __getGlobalFlatIndex([levelIndex, ...subIndexes], cache = this._cache, flatIndex = 0) {
583
+ if (levelIndex === Infinity) {
584
+ // Treat Infinity as the last index on the level
585
+ levelIndex = cache.size - 1;
586
+ }
587
+ const flatIndexOnLevel = cache.getFlatIndex(levelIndex);
588
+ const subCache = cache.itemCaches[levelIndex];
589
+ if (subCache && subCache.effectiveSize && subIndexes.length) {
590
+ return this.__getGlobalFlatIndex(subIndexes, subCache, flatIndex + flatIndexOnLevel + 1);
524
591
  }
592
+ return flatIndex + flatIndexOnLevel;
525
593
  }
526
594
 
527
595
  /** @private */
528
- __scrollToPendingIndex() {
529
- if (this.__pendingScrollToIndex && this.$.items.children.length) {
530
- const index = this.__pendingScrollToIndex;
531
- delete this.__pendingScrollToIndex;
532
- this.scrollToIndex(index);
596
+ __scrollToPendingIndexes() {
597
+ if (this.__pendingScrollToIndexes && this.$.items.children.length) {
598
+ const indexes = this.__pendingScrollToIndexes;
599
+ delete this.__pendingScrollToIndexes;
600
+ this.scrollToIndex(...indexes);
533
601
  }
534
602
  }
535
603
 
@@ -3,7 +3,7 @@
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 { iterateChildren, updateRowStates } from './vaadin-grid-helpers.js';
6
+ import { iterateChildren, updateBooleanRowStates, updateStringRowStates } from './vaadin-grid-helpers.js';
7
7
 
8
8
  const DropMode = {
9
9
  BETWEEN: 'between',
@@ -156,12 +156,12 @@ export const DragAndDropMixin = (superClass) =>
156
156
  // Set the default transfer data
157
157
  e.dataTransfer.setData('text', this.__formatDefaultTransferData(rows));
158
158
 
159
- updateRowStates(row, { dragstart: rows.length > 1 ? `${rows.length}` : '' });
159
+ updateBooleanRowStates(row, { dragstart: rows.length > 1 ? `${rows.length}` : '' });
160
160
  this.style.setProperty('--_grid-drag-start-x', `${e.clientX - rowRect.left + 20}px`);
161
161
  this.style.setProperty('--_grid-drag-start-y', `${e.clientY - rowRect.top + 10}px`);
162
162
 
163
163
  requestAnimationFrame(() => {
164
- updateRowStates(row, { dragstart: null });
164
+ updateBooleanRowStates(row, { dragstart: false });
165
165
  this.style.setProperty('--_grid-drag-start-x', '');
166
166
  this.style.setProperty('--_grid-drag-start-y', '');
167
167
  });
@@ -255,7 +255,7 @@ export const DragAndDropMixin = (superClass) =>
255
255
  } else if (row) {
256
256
  this._dragOverItem = row._item;
257
257
  if (row.getAttribute('dragover') !== this._dropLocation) {
258
- updateRowStates(row, { dragover: this._dropLocation }, true);
258
+ updateStringRowStates(row, { dragover: this._dropLocation });
259
259
  }
260
260
  } else {
261
261
  this._clearDragStyles();
@@ -310,7 +310,7 @@ export const DragAndDropMixin = (superClass) =>
310
310
  _clearDragStyles() {
311
311
  this.removeAttribute('dragover');
312
312
  iterateChildren(this.$.items, (row) => {
313
- updateRowStates(row, { dragover: null }, true);
313
+ updateStringRowStates(row, { dragover: null });
314
314
  });
315
315
  }
316
316
 
@@ -398,7 +398,7 @@ export const DragAndDropMixin = (superClass) =>
398
398
  }
399
399
  });
400
400
 
401
- updateRowStates(row, {
401
+ updateBooleanRowStates(row, {
402
402
  'drag-disabled': !!dragDisabled,
403
403
  'drop-disabled': !!dropDisabled,
404
404
  });
@@ -86,16 +86,15 @@ export function updateCellsPart(cells, part, value) {
86
86
  /**
87
87
  * @param {!HTMLElement} row
88
88
  * @param {Object} states
89
- * @param {boolean} appendValue
90
89
  */
91
- export function updateRowStates(row, states, appendValue) {
90
+ export function updateBooleanRowStates(row, states) {
92
91
  const cells = getBodyRowCells(row);
93
92
 
94
93
  Object.entries(states).forEach(([state, value]) => {
95
94
  // Row state attribute
96
95
  updateState(row, state, value);
97
96
 
98
- const rowPart = appendValue ? `${state}-${value}-row` : `${state}-row`;
97
+ const rowPart = `${state}-row`;
99
98
 
100
99
  // Row part attribute
101
100
  updatePart(row, value, rowPart);
@@ -105,6 +104,35 @@ export function updateRowStates(row, states, appendValue) {
105
104
  });
106
105
  }
107
106
 
107
+ /**
108
+ * @param {!HTMLElement} row
109
+ * @param {Object} states
110
+ */
111
+ export function updateStringRowStates(row, states) {
112
+ const cells = getBodyRowCells(row);
113
+
114
+ Object.entries(states).forEach(([state, value]) => {
115
+ const prevValue = row.getAttribute(state);
116
+
117
+ // Row state attribute
118
+ updateState(row, state, value);
119
+
120
+ // remove previous part from row and cells if there was any
121
+ if (prevValue) {
122
+ const prevRowPart = `${state}-${prevValue}-row`;
123
+ updatePart(row, false, prevRowPart);
124
+ updateCellsPart(cells, `${prevRowPart}-cell`, false);
125
+ }
126
+
127
+ // set new part to rows and cells if there is a value
128
+ if (value) {
129
+ const rowPart = `${state}-${value}-row`;
130
+ updatePart(row, value, rowPart);
131
+ updateCellsPart(cells, `${rowPart}-cell`, value);
132
+ }
133
+ });
134
+ }
135
+
108
136
  /**
109
137
  * @param {!HTMLElement} cell
110
138
  * @param {string} attribute
@@ -521,7 +521,12 @@ export const KeyboardNavigationMixin = (superClass) =>
521
521
  return;
522
522
  }
523
523
 
524
- const columnIndex = this.__getIndexOfChildElement(activeCell);
524
+ let columnIndex = this.__getIndexOfChildElement(activeCell);
525
+ if (this.$.items.contains(activeCell)) {
526
+ // lazy column rendering may be enabled, so we need use the always visible sizer cells to find the column index
527
+ columnIndex = [...this.$.sizer.children].findIndex((sizerCell) => sizerCell._column === activeCell._column);
528
+ }
529
+
525
530
  const isCurrentCellRowDetails = this.__isDetailsCell(activeCell);
526
531
  const activeRowGroup = activeRow.parentNode;
527
532
  const currentRowIndex = this.__getIndexInGroup(activeRow, this._focusedItemIndex);
@@ -574,9 +579,27 @@ export const KeyboardNavigationMixin = (superClass) =>
574
579
  return acc;
575
580
  }, {});
576
581
  const dstColumnIndex = columnIndexByOrder[dstSortedColumnOrders[dstOrderedColumnIndex]];
577
- const dstCell = dstRow.children[dstColumnIndex];
578
582
 
579
- this._scrollHorizontallyToCell(dstCell);
583
+ let dstCell;
584
+ if (this.$.items.contains(activeCell)) {
585
+ const dstSizerCell = this.$.sizer.children[dstColumnIndex];
586
+ if (this._lazyColumns) {
587
+ // If the column is not in the viewport, scroll it into view.
588
+ if (!this.__isColumnInViewport(dstSizerCell._column)) {
589
+ dstSizerCell.scrollIntoView();
590
+ }
591
+ this.__updateColumnsBodyContentHidden();
592
+ this.__updateHorizontalScrollPosition();
593
+ }
594
+
595
+ dstCell = [...dstRow.children].find((cell) => cell._column === dstSizerCell._column);
596
+ // Ensure correct horizontal scroll position once the destination cell is available.
597
+ this._scrollHorizontallyToCell(dstCell);
598
+ } else {
599
+ dstCell = dstRow.children[dstColumnIndex];
600
+ this._scrollHorizontallyToCell(dstCell);
601
+ }
602
+
580
603
  dstCell.focus();
581
604
  }
582
605
  }
@@ -7,13 +7,48 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ScrollMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<ScrollMixinClass> & T;
9
9
 
10
+ export type ColumnRendering = 'eager' | 'lazy';
11
+
10
12
  export declare class ScrollMixinClass {
11
13
  /**
12
- * Scroll to a specific row index in the virtual list. Note that the row index is
13
- * not always the same for any particular item. For example, sorting/filtering/expanding
14
- * or collapsing hierarchical items can affect the row index related to an item.
14
+ * Allows you to choose between modes for rendering columns in the grid:
15
+ *
16
+ * "eager" (default): All columns are rendered upfront, regardless of their visibility within the viewport.
17
+ * This mode should generally be preferred, as it avoids the limitations imposed by the "lazy" mode.
18
+ * Use this mode unless the grid has a large number of columns and performance outweighs the limitations
19
+ * in priority.
20
+ *
21
+ * "lazy": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing
22
+ * horizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are
23
+ * inside the visible viewport.
24
+ *
25
+ * Using "lazy" rendering should be used only if you're dealing with a large number of columns and performance
26
+ * is your highest priority. For most use cases, the default "eager" mode is recommended due to the
27
+ * limitations imposed by the "lazy" mode.
28
+ *
29
+ * When using the "lazy" mode, keep the following limitations in mind:
30
+ *
31
+ * - Row Height: When only a number of columns are visible at once, the height of a row can only be that of
32
+ * the highest cell currently visible on that row. Make sure each cell on a single row has the same height
33
+ * as all other cells on that row. If row cells have different heights, users may experience jumpiness when
34
+ * scrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.
15
35
  *
16
- * @param index Row index to scroll to
36
+ * - Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,
37
+ * only the header content is taken into account when calculating the column width because the body cells
38
+ * of the columns outside the viewport are not initially rendered.
39
+ *
40
+ * - Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct
41
+ * headers when only a subset of the body cells on a row is rendered.
42
+ *
43
+ * - Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because
44
+ * some of the columns that would include focusable elements in the body cells may be outside the visible viewport
45
+ * and thus not rendered.
46
+ */
47
+ columnRendering: ColumnRendering;
48
+
49
+ /**
50
+ * Scroll to a flat index in the grid. The method doesn't take into account
51
+ * the hierarchy of the items.
17
52
  */
18
- scrollToIndex(index: number): void;
53
+ protected _scrollToFlatIndex(index: number): void;
19
54
  }
@@ -10,6 +10,7 @@ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
10
10
 
11
11
  const timeouts = {
12
12
  SCROLLING: 500,
13
+ UPDATE_CONTENT_VISIBILITY: 100,
13
14
  };
14
15
 
15
16
  /**
@@ -19,6 +20,48 @@ export const ScrollMixin = (superClass) =>
19
20
  class ScrollMixin extends ResizeMixin(superClass) {
20
21
  static get properties() {
21
22
  return {
23
+ /**
24
+ * Allows you to choose between modes for rendering columns in the grid:
25
+ *
26
+ * "eager" (default): All columns are rendered upfront, regardless of their visibility within the viewport.
27
+ * This mode should generally be preferred, as it avoids the limitations imposed by the "lazy" mode.
28
+ * Use this mode unless the grid has a large number of columns and performance outweighs the limitations
29
+ * in priority.
30
+ *
31
+ * "lazy": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing
32
+ * horizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are
33
+ * inside the visible viewport.
34
+ *
35
+ * Using "lazy" rendering should be used only if you're dealing with a large number of columns and performance
36
+ * is your highest priority. For most use cases, the default "eager" mode is recommended due to the
37
+ * limitations imposed by the "lazy" mode.
38
+ *
39
+ * When using the "lazy" mode, keep the following limitations in mind:
40
+ *
41
+ * - Row Height: When only a number of columns are visible at once, the height of a row can only be that of
42
+ * the highest cell currently visible on that row. Make sure each cell on a single row has the same height
43
+ * as all other cells on that row. If row cells have different heights, users may experience jumpiness when
44
+ * scrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.
45
+ *
46
+ * - Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,
47
+ * only the header content is taken into account when calculating the column width because the body cells
48
+ * of the columns outside the viewport are not initially rendered.
49
+ *
50
+ * - Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct
51
+ * headers when only a subset of the body cells on a row is rendered.
52
+ *
53
+ * - Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because
54
+ * some of the columns that would include focusable elements in the body cells may be outside the visible viewport
55
+ * and thus not rendered.
56
+ *
57
+ * @attr {eager|lazy} column-rendering
58
+ * @type {!ColumnRendering}
59
+ */
60
+ columnRendering: {
61
+ type: String,
62
+ value: 'eager',
63
+ },
64
+
22
65
  /**
23
66
  * Cached array of frozen cells
24
67
  * @private
@@ -42,6 +85,10 @@ export const ScrollMixin = (superClass) =>
42
85
  };
43
86
  }
44
87
 
88
+ static get observers() {
89
+ return ['__columnRenderingChanged(_columnTree, columnRendering)'];
90
+ }
91
+
45
92
  /** @private */
46
93
  get _scrollLeft() {
47
94
  return this.$.table.scrollLeft;
@@ -60,6 +107,11 @@ export const ScrollMixin = (superClass) =>
60
107
  this.$.table.scrollTop = top;
61
108
  }
62
109
 
110
+ /** @protected */
111
+ get _lazyColumns() {
112
+ return this.columnRendering === 'lazy';
113
+ }
114
+
63
115
  /** @protected */
64
116
  ready() {
65
117
  super.ready();
@@ -87,13 +139,13 @@ export const ScrollMixin = (superClass) =>
87
139
  }
88
140
 
89
141
  /**
90
- * Scroll to a specific row index in the virtual list. Note that the row index is
91
- * not always the same for any particular item. For example, sorting/filtering/expanding
92
- * or collapsing hierarchical items can affect the row index related to an item.
142
+ * Scroll to a flat index in the grid. The method doesn't take into account
143
+ * the hierarchy of the items.
93
144
  *
94
145
  * @param {number} index Row index to scroll to
146
+ * @protected
95
147
  */
96
- scrollToIndex(index) {
148
+ _scrollToFlatIndex(index) {
97
149
  index = Math.min(this._effectiveSize - 1, Math.max(0, index));
98
150
  this.__virtualizer.scrollToIndex(index);
99
151
  this.__scrollIntoViewport(index);
@@ -143,6 +195,124 @@ export const ScrollMixin = (superClass) =>
143
195
  }
144
196
 
145
197
  this._updateOverflow();
198
+
199
+ this._debounceColumnContentVisibility = Debouncer.debounce(
200
+ this._debounceColumnContentVisibility,
201
+ timeOut.after(timeouts.UPDATE_CONTENT_VISIBILITY),
202
+ () => {
203
+ // If horizontal scroll position changed and lazy column rendering is enabled,
204
+ // update the visible columns.
205
+ if (this._lazyColumns && this.__cachedScrollLeft !== this._scrollLeft) {
206
+ this.__cachedScrollLeft = this._scrollLeft;
207
+ this.__updateColumnsBodyContentHidden();
208
+ }
209
+ },
210
+ );
211
+ }
212
+
213
+ /** @private */
214
+ __updateColumnsBodyContentHidden() {
215
+ if (!this._columnTree) {
216
+ return;
217
+ }
218
+
219
+ const columnsInOrder = this._getColumnsInOrder();
220
+
221
+ // Return if sizer cells are not yet assigned to columns
222
+ if (!columnsInOrder[0] || !columnsInOrder[0]._sizerCell) {
223
+ return;
224
+ }
225
+
226
+ let bodyContentHiddenChanged = false;
227
+
228
+ // Remove the column cells from the DOM if the column is outside the viewport.
229
+ // Add the column cells to the DOM if the column is inside the viewport.
230
+ //
231
+ // Update the _bodyContentHidden property of the column to reflect the current
232
+ // visibility state and make it run renderers for the cells if necessary.
233
+ columnsInOrder.forEach((column) => {
234
+ const bodyContentHidden = this._lazyColumns && !this.__isColumnInViewport(column);
235
+
236
+ if (column._bodyContentHidden !== bodyContentHidden) {
237
+ bodyContentHiddenChanged = true;
238
+ column._cells.forEach((cell) => {
239
+ if (cell !== column._sizerCell) {
240
+ if (bodyContentHidden) {
241
+ cell.remove();
242
+ } else if (cell.__parentRow) {
243
+ // Add the cell to the correct DOM position in the row
244
+ const followingColumnCell = [...cell.__parentRow.children].find(
245
+ (child) => columnsInOrder.indexOf(child._column) > columnsInOrder.indexOf(column),
246
+ );
247
+ cell.__parentRow.insertBefore(cell, followingColumnCell);
248
+ }
249
+ }
250
+ });
251
+ }
252
+
253
+ column._bodyContentHidden = bodyContentHidden;
254
+ });
255
+
256
+ if (bodyContentHiddenChanged) {
257
+ // Frozen columns may have changed their visibility
258
+ this._frozenCellsChanged();
259
+ }
260
+
261
+ if (this._lazyColumns) {
262
+ // Calculate the offset to apply to the body cells
263
+ const lastFrozenColumn = [...columnsInOrder].reverse().find((column) => column.frozen);
264
+ const lastFrozenColumnEnd = this.__getColumnEnd(lastFrozenColumn);
265
+ const firstVisibleColumn = columnsInOrder.find((column) => !column.frozen && !column._bodyContentHidden);
266
+ this.__lazyColumnsStart = this.__getColumnStart(firstVisibleColumn) - lastFrozenColumnEnd;
267
+ this.$.items.style.setProperty('--_grid-lazy-columns-start', `${this.__lazyColumnsStart}px`);
268
+
269
+ // Make sure the body has a focusable element in lazy columns mode
270
+ this._resetKeyboardNavigation();
271
+ }
272
+ }
273
+
274
+ /** @private */
275
+ __getColumnEnd(column) {
276
+ if (!column) {
277
+ return this.__isRTL ? this.$.table.clientWidth : 0;
278
+ }
279
+ return column._sizerCell.offsetLeft + (this.__isRTL ? 0 : column._sizerCell.offsetWidth);
280
+ }
281
+
282
+ /** @private */
283
+ __getColumnStart(column) {
284
+ if (!column) {
285
+ return this.__isRTL ? this.$.table.clientWidth : 0;
286
+ }
287
+ return column._sizerCell.offsetLeft + (this.__isRTL ? column._sizerCell.offsetWidth : 0);
288
+ }
289
+
290
+ /**
291
+ * Returns true if the given column is horizontally inside the viewport.
292
+ * @private
293
+ */
294
+ __isColumnInViewport(column) {
295
+ if (column.frozen || column.frozenToEnd) {
296
+ // Assume frozen columns to always be inside the viewport
297
+ return true;
298
+ }
299
+
300
+ // Check if the column's sizer cell is inside the viewport
301
+ return (
302
+ column._sizerCell.offsetLeft + column._sizerCell.offsetWidth >= this._scrollLeft &&
303
+ column._sizerCell.offsetLeft <= this._scrollLeft + this.clientWidth
304
+ );
305
+ }
306
+
307
+ /** @private */
308
+ __columnRenderingChanged(_columnTree, columnRendering) {
309
+ if (columnRendering === 'eager') {
310
+ this.$.scroller.removeAttribute('column-rendering');
311
+ } else {
312
+ this.$.scroller.setAttribute('column-rendering', columnRendering);
313
+ }
314
+
315
+ this.__updateColumnsBodyContentHidden();
146
316
  }
147
317
 
148
318
  /** @private */
@@ -254,10 +424,15 @@ export const ScrollMixin = (superClass) =>
254
424
  if (firstFrozenToEnd !== undefined) {
255
425
  columnsRow[firstFrozenToEnd]._firstFrozenToEnd = true;
256
426
  }
427
+
428
+ this.__updateColumnsBodyContentHidden();
257
429
  }
258
430
 
259
431
  /** @private */
260
432
  __updateHorizontalScrollPosition() {
433
+ if (!this._columnTree) {
434
+ return;
435
+ }
261
436
  const scrollWidth = this.$.table.scrollWidth;
262
437
  const clientWidth = this.$.table.clientWidth;
263
438
  const scrollLeft = Math.max(0, this.$.table.scrollLeft);
@@ -279,8 +454,31 @@ export const ScrollMixin = (superClass) =>
279
454
  // Position cells frozen to end
280
455
  const remaining = this.__isRTL ? normalizedScrollLeft : scrollLeft + clientWidth - scrollWidth;
281
456
  const transformFrozenToEnd = `translate(${remaining}px, 0)`;
457
+
458
+ let transformFrozenToEndBody = transformFrozenToEnd;
459
+
460
+ if (this._lazyColumns) {
461
+ // Lazy column rendering is used, calculate the offset to apply to the frozen to end cells
462
+ const columnsInOrder = this._getColumnsInOrder();
463
+
464
+ const lastVisibleColumn = [...columnsInOrder]
465
+ .reverse()
466
+ .find((column) => !column.frozenToEnd && !column._bodyContentHidden);
467
+ const lastVisibleColumnEnd = this.__getColumnEnd(lastVisibleColumn);
468
+
469
+ const firstFrozenToEndColumn = columnsInOrder.find((column) => column.frozenToEnd);
470
+ const firstFrozenToEndColumnStart = this.__getColumnStart(firstFrozenToEndColumn);
471
+
472
+ const translateX = remaining + (firstFrozenToEndColumnStart - lastVisibleColumnEnd) + this.__lazyColumnsStart;
473
+ transformFrozenToEndBody = `translate(${translateX}px, 0)`;
474
+ }
475
+
282
476
  this._frozenToEndCells.forEach((cell) => {
283
- cell.style.transform = transformFrozenToEnd;
477
+ if (this.$.items.contains(cell)) {
478
+ cell.style.transform = transformFrozenToEndBody;
479
+ } else {
480
+ cell.style.transform = transformFrozenToEnd;
481
+ }
284
482
  });
285
483
 
286
484
  // Only update the --_grid-horizontal-scroll-position custom property when navigating
@@ -122,7 +122,11 @@ registerStyles(
122
122
  }
123
123
 
124
124
  [part~='row'][loading] [part~='body-cell'] ::slotted(vaadin-grid-cell-content) {
125
- opacity: 0;
125
+ visibility: hidden;
126
+ }
127
+
128
+ [column-rendering='lazy'] [part~='body-cell']:not([frozen]):not([frozen-to-end]) {
129
+ transform: translateX(var(--_grid-lazy-columns-start));
126
130
  }
127
131
 
128
132
  #items [part~='row'] {
@@ -338,6 +342,22 @@ registerStyles(
338
342
  right: 0;
339
343
  left: auto;
340
344
  }
345
+
346
+ @media (forced-colors: active) {
347
+ [part~='selected-row'] [part~='first-column-cell']::after {
348
+ content: '';
349
+ position: absolute;
350
+ top: 0;
351
+ left: 0;
352
+ bottom: 0;
353
+ border: 2px solid;
354
+ }
355
+
356
+ [part~='focused-cell']::before {
357
+ outline: 2px solid !important;
358
+ outline-offset: -1px;
359
+ }
360
+ }
341
361
  `,
342
362
  { moduleId: 'vaadin-grid-styles' },
343
363
  );
@@ -34,7 +34,7 @@ class GridTreeColumn extends GridColumn {
34
34
  }
35
35
 
36
36
  static get observers() {
37
- return ['_onRendererOrBindingChanged(_renderer, _cells, _cells.*, path)'];
37
+ return ['_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)'];
38
38
  }
39
39
 
40
40
  constructor() {
@@ -5,10 +5,9 @@
5
5
  */
6
6
  import './vaadin-grid-column.js';
7
7
  import './vaadin-grid-styles.js';
8
- import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
9
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
10
9
  import { TabindexMixin } from '@vaadin/a11y-base/src/tabindex-mixin.js';
11
- import { microTask } from '@vaadin/component-base/src/async.js';
10
+ import { animationFrame, microTask } from '@vaadin/component-base/src/async.js';
12
11
  import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
13
12
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
14
13
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
@@ -27,7 +26,7 @@ import { DragAndDropMixin } from './vaadin-grid-drag-and-drop-mixin.js';
27
26
  import { DynamicColumnsMixin } from './vaadin-grid-dynamic-columns-mixin.js';
28
27
  import { EventContextMixin } from './vaadin-grid-event-context-mixin.js';
29
28
  import { FilterMixin } from './vaadin-grid-filter-mixin.js';
30
- import { getBodyRowCells, iterateChildren, updateCellsPart, updateRowStates } from './vaadin-grid-helpers.js';
29
+ import { getBodyRowCells, iterateChildren, updateBooleanRowStates, updateCellsPart } from './vaadin-grid-helpers.js';
31
30
  import { KeyboardNavigationMixin } from './vaadin-grid-keyboard-navigation-mixin.js';
32
31
  import { RowDetailsMixin } from './vaadin-grid-row-details-mixin.js';
33
32
  import { ScrollMixin } from './vaadin-grid-scroll-mixin.js';
@@ -503,7 +502,12 @@ class Grid extends ElementMixin(
503
502
  reorderElements: true,
504
503
  });
505
504
 
506
- new ResizeObserver(() => setTimeout(() => this.__updateFooterPositioning())).observe(this.$.footer);
505
+ new ResizeObserver(() =>
506
+ setTimeout(() => {
507
+ this.__updateFooterPositioning();
508
+ this.__updateColumnsBodyContentHidden();
509
+ }),
510
+ ).observe(this.$.table);
507
511
 
508
512
  processTemplates(this);
509
513
 
@@ -741,12 +745,14 @@ class Grid extends ElementMixin(
741
745
  );
742
746
  }
743
747
 
744
- beforeNextRender(this, () => {
745
- this._updateFirstAndLastColumn();
746
- this._resetKeyboardNavigation();
747
- this._afterScroll();
748
- this.__itemsReceived();
749
- });
748
+ this.__afterCreateScrollerRowsDebouncer = Debouncer.debounce(
749
+ this.__afterCreateScrollerRowsDebouncer,
750
+ animationFrame,
751
+ () => {
752
+ this._afterScroll();
753
+ this.__itemsReceived();
754
+ },
755
+ );
750
756
  return rows;
751
757
  }
752
758
 
@@ -865,7 +871,14 @@ class Grid extends ElementMixin(
865
871
  column._cells.push(cell);
866
872
  }
867
873
  cell.setAttribute('part', 'cell body-cell');
868
- row.appendChild(cell);
874
+ cell.__parentRow = row;
875
+ if (!column._bodyContentHidden) {
876
+ row.appendChild(cell);
877
+ }
878
+
879
+ if (row === this.$.sizer) {
880
+ column._sizerCell = cell;
881
+ }
869
882
 
870
883
  if (index === cols.length - 1 && this.rowDetailsRenderer) {
871
884
  // Add details cell as last cell to body rows
@@ -1004,11 +1017,12 @@ class Grid extends ElementMixin(
1004
1017
  _columnTreeChanged(columnTree) {
1005
1018
  this._renderColumnTree(columnTree);
1006
1019
  this.recalculateColumnWidths();
1020
+ this.__updateColumnsBodyContentHidden();
1007
1021
  }
1008
1022
 
1009
1023
  /** @private */
1010
1024
  _updateRowOrderParts(row, index = row.index) {
1011
- updateRowStates(row, {
1025
+ updateBooleanRowStates(row, {
1012
1026
  first: index === 0,
1013
1027
  last: index === this._effectiveSize - 1,
1014
1028
  odd: index % 2 !== 0,
@@ -1018,7 +1032,7 @@ class Grid extends ElementMixin(
1018
1032
 
1019
1033
  /** @private */
1020
1034
  _updateRowStateParts(row, { expanded, selected, detailsOpened }) {
1021
- updateRowStates(row, {
1035
+ updateBooleanRowStates(row, {
1022
1036
  expanded,
1023
1037
  selected,
1024
1038
  'details-opened': detailsOpened,
@@ -1147,7 +1161,7 @@ class Grid extends ElementMixin(
1147
1161
  this.__itemsReceived();
1148
1162
 
1149
1163
  requestAnimationFrame(() => {
1150
- this.__scrollToPendingIndex();
1164
+ this.__scrollToPendingIndexes();
1151
1165
  });
1152
1166
  }
1153
1167
  }
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": "24.1.0-alpha1",
4
+ "version": "24.1.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/24.1.0-alpha1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<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/24.1.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/24.1.0-alpha1/#/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__",
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.1.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",
@@ -1758,7 +1758,7 @@
1758
1758
  },
1759
1759
  {
1760
1760
  "name": "vaadin-grid",
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.1.0-alpha1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/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.1.0-alpha1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/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.1.0-alpha1/#/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.1.0-alpha1/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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.",
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.1.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.1.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.1.0-alpha10/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.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.1.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.1.0-alpha10/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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.",
1762
1762
  "attributes": [
1763
1763
  {
1764
1764
  "name": "size",
@@ -1800,6 +1800,15 @@
1800
1800
  ]
1801
1801
  }
1802
1802
  },
1803
+ {
1804
+ "name": "column-rendering",
1805
+ "description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
1806
+ "value": {
1807
+ "type": [
1808
+ "ColumnRendering"
1809
+ ]
1810
+ }
1811
+ },
1803
1812
  {
1804
1813
  "name": "multi-sort",
1805
1814
  "description": "When `true`, all `<vaadin-grid-sorter>` are applied for sorting.",
@@ -1982,6 +1991,15 @@
1982
1991
  ]
1983
1992
  }
1984
1993
  },
1994
+ {
1995
+ "name": "columnRendering",
1996
+ "description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
1997
+ "value": {
1998
+ "type": [
1999
+ "ColumnRendering"
2000
+ ]
2001
+ }
2002
+ },
1985
2003
  {
1986
2004
  "name": "selectedItems",
1987
2005
  "description": "An array that contains the selected items.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/grid",
4
- "version": "24.1.0-alpha1",
4
+ "version": "24.1.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-grid-column",
19
- "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.1.0-alpha1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
19
+ "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.1.0-alpha10/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -303,7 +303,7 @@
303
303
  },
304
304
  {
305
305
  "name": "vaadin-grid-selection-column",
306
- "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.1.0-alpha1/#/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__",
306
+ "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.1.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__",
307
307
  "extension": true,
308
308
  "attributes": [
309
309
  {
@@ -695,7 +695,7 @@
695
695
  },
696
696
  {
697
697
  "name": "vaadin-grid",
698
- "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.1.0-alpha1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/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.1.0-alpha1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha1/#/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.1.0-alpha1/#/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.1.0-alpha1/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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.",
698
+ "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.1.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.1.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.1.0-alpha10/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.1.0-alpha10/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.1.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.1.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.1.0-alpha10/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\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.",
699
699
  "extension": true,
700
700
  "attributes": [
701
701
  {
@@ -803,6 +803,13 @@
803
803
  "kind": "expression"
804
804
  }
805
805
  },
806
+ {
807
+ "name": ".columnRendering",
808
+ "description": "Allows you to choose between modes for rendering columns in the grid:\n\n\"eager\" (default): All columns are rendered upfront, regardless of their visibility within the viewport.\nThis mode should generally be preferred, as it avoids the limitations imposed by the \"lazy\" mode.\nUse this mode unless the grid has a large number of columns and performance outweighs the limitations\nin priority.\n\n\"lazy\": Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing\nhorizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are\ninside the visible viewport.\n\nUsing \"lazy\" rendering should be used only if you're dealing with a large number of columns and performance\nis your highest priority. For most use cases, the default \"eager\" mode is recommended due to the\nlimitations imposed by the \"lazy\" mode.\n\nWhen using the \"lazy\" mode, keep the following limitations in mind:\n\n- Row Height: When only a number of columns are visible at once, the height of a row can only be that of\nthe highest cell currently visible on that row. Make sure each cell on a single row has the same height\nas all other cells on that row. If row cells have different heights, users may experience jumpiness when\nscrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.\n\n- Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width,\nonly the header content is taken into account when calculating the column width because the body cells\nof the columns outside the viewport are not initially rendered.\n\n- Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct\nheaders when only a subset of the body cells on a row is rendered.\n\n- Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because\nsome of the columns that would include focusable elements in the body cells may be outside the visible viewport\nand thus not rendered.",
809
+ "value": {
810
+ "kind": "expression"
811
+ }
812
+ },
806
813
  {
807
814
  "name": ".selectedItems",
808
815
  "description": "An array that contains the selected items.",