@vaadin/grid 24.0.5 → 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/README.md CHANGED
@@ -29,7 +29,7 @@ A web component for showing tabular data.
29
29
  </script>
30
30
  ```
31
31
 
32
- [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/grid/screenshot.png" alt="Screenshot of vaadin-grid">](https://vaadin.com/docs/latest/components/grid)
32
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/main/packages/grid/screenshot.png" alt="Screenshot of vaadin-grid">](https://vaadin.com/docs/latest/components/grid)
33
33
 
34
34
  ## Installation
35
35
 
@@ -53,7 +53,7 @@ import '@vaadin/grid/vaadin-grid-tree-column.js';
53
53
  ## Themes
54
54
 
55
55
  Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
56
- The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/grid/vaadin-grid.js) of the package uses the Lumo theme.
56
+ The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/grid/vaadin-grid.js) of the package uses the Lumo theme.
57
57
 
58
58
  To use the Material theme, import the components from the `theme/material` folder:
59
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid",
3
- "version": "24.0.5",
3
+ "version": "24.1.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,17 +46,17 @@
46
46
  "dependencies": {
47
47
  "@open-wc/dedupe-mixin": "^1.3.0",
48
48
  "@polymer/polymer": "^3.0.0",
49
- "@vaadin/checkbox": "~24.0.5",
50
- "@vaadin/component-base": "~24.0.5",
51
- "@vaadin/lit-renderer": "~24.0.5",
52
- "@vaadin/text-field": "~24.0.5",
53
- "@vaadin/vaadin-lumo-styles": "~24.0.5",
54
- "@vaadin/vaadin-material-styles": "~24.0.5",
55
- "@vaadin/vaadin-themable-mixin": "~24.0.5"
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"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@esm-bundle/chai": "^4.3.4",
59
- "@vaadin/polymer-legacy-adapter": "~24.0.5",
60
60
  "@vaadin/testing-helpers": "^0.4.0",
61
61
  "lit": "^2.0.0",
62
62
  "sinon": "^13.0.2"
@@ -65,5 +65,5 @@
65
65
  "web-types.json",
66
66
  "web-types.lit.json"
67
67
  ],
68
- "gitHead": "e384c1b5c02e01a4382a433f727d075de9a4ee97"
68
+ "gitHead": "12e39be7eb3b49c68708e8ca3de2fb22e91051a1"
69
69
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
7
7
  import { PolymerElement } from '@polymer/polymer/polymer-element.js';
8
- import { animationFrame, microTask } from '@vaadin/component-base/src/async.js';
8
+ import { animationFrame } from '@vaadin/component-base/src/async.js';
9
9
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
10
10
  import { ColumnBaseMixin } from './vaadin-grid-column.js';
11
11
  import { updateColumnOrders } from './vaadin-grid-helpers.js';
@@ -377,12 +377,10 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
377
377
  this._updateVisibleChildColumns(this._childColumns);
378
378
  this._preventHiddenSynchronization = false;
379
379
 
380
- // Update the column tree with microtask timing to avoid shady style scope issues
381
- microTask.run(() => {
382
- if (this._grid && this._grid._updateColumnTree) {
383
- this._grid._updateColumnTree();
384
- }
385
- });
380
+ // Update the column tree
381
+ if (this._grid && this._grid._debounceUpdateColumnTree) {
382
+ this._grid._debounceUpdateColumnTree();
383
+ }
386
384
  }
387
385
  });
388
386
  this._observer.flush();
@@ -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
  }
@@ -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,26 +397,33 @@ 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
427
 
406
428
  this._getVisibleRows().forEach((row) => {
407
429
  const cachedItem = this._cache.getItemForIndex(row.index);
@@ -410,13 +432,15 @@ export const DataProviderMixin = (superClass) =>
410
432
  }
411
433
  });
412
434
 
413
- this.__scrollToPendingIndex();
435
+ this.__scrollToPendingIndexes();
414
436
  });
415
437
 
438
+ // If the grid is not loading anything, flush the debouncer immediately
416
439
  if (!this._cache.isLoading()) {
417
440
  this._debouncerApplyCachedData.flush();
418
441
  }
419
442
 
443
+ // Notify that new data has been received
420
444
  this.__itemsReceived();
421
445
  });
422
446
  }
@@ -515,19 +539,65 @@ export const DataProviderMixin = (superClass) =>
515
539
  return result;
516
540
  }
517
541
 
518
- scrollToIndex(index) {
519
- super.scrollToIndex(index);
520
- if (!isNaN(index) && (this._cache.isLoading() || !this.clientHeight)) {
521
- 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);
522
591
  }
592
+ return flatIndex + flatIndexOnLevel;
523
593
  }
524
594
 
525
595
  /** @private */
526
- __scrollToPendingIndex() {
527
- if (this.__pendingScrollToIndex && this.$.items.children.length) {
528
- const index = this.__pendingScrollToIndex;
529
- delete this.__pendingScrollToIndex;
530
- 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);
531
601
  }
532
602
  }
533
603
 
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
7
7
  import { PolymerElement } from '@polymer/polymer/polymer-element.js';
8
- import { timeOut } from '@vaadin/component-base/src/async.js';
8
+ import { microTask, timeOut } from '@vaadin/component-base/src/async.js';
9
9
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
10
10
  import { updateCellState } from './vaadin-grid-helpers.js';
11
11
 
@@ -90,6 +90,13 @@ export const DynamicColumnsMixin = (superClass) =>
90
90
  return columnTree;
91
91
  }
92
92
 
93
+ /** @protected */
94
+ _debounceUpdateColumnTree() {
95
+ this.__updateColumnTreeDebouncer = Debouncer.debounce(this.__updateColumnTreeDebouncer, microTask, () =>
96
+ this._updateColumnTree(),
97
+ );
98
+ }
99
+
93
100
  /** @protected */
94
101
  _updateColumnTree() {
95
102
  const columnTree = this._getColumnTree();
@@ -109,7 +116,7 @@ export const DynamicColumnsMixin = (superClass) =>
109
116
 
110
117
  this.__removeSorters(this._sorters.filter(filterNotConnected));
111
118
  this.__removeFilters(this._filters.filter(filterNotConnected));
112
- this._updateColumnTree();
119
+ this._debounceUpdateColumnTree();
113
120
  }
114
121
 
115
122
  this._debouncerCheckImports = Debouncer.debounce(
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
6
7
  import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
7
- import { isKeyboardActive } from '@vaadin/component-base/src/focus-utils.js';
8
8
 
9
9
  /**
10
10
  * @polymerMixin
@@ -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
@@ -15,7 +15,8 @@ registerStyles(
15
15
  }
16
16
 
17
17
  :host {
18
- display: block;
18
+ display: flex;
19
+ flex-direction: column;
19
20
  animation: 1ms vaadin-grid-appear;
20
21
  height: 400px;
21
22
  flex: 1 1 auto;
@@ -32,7 +33,9 @@ registerStyles(
32
33
  }
33
34
 
34
35
  #scroller {
35
- display: block;
36
+ display: flex;
37
+ flex-direction: column;
38
+ min-height: 100%;
36
39
  transform: translateY(0);
37
40
  width: auto;
38
41
  height: auto;
@@ -119,7 +122,11 @@ registerStyles(
119
122
  }
120
123
 
121
124
  [part~='row'][loading] [part~='body-cell'] ::slotted(vaadin-grid-cell-content) {
122
- 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));
123
130
  }
124
131
 
125
132
  #items [part~='row'] {
@@ -335,6 +342,22 @@ registerStyles(
335
342
  right: 0;
336
343
  left: auto;
337
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
+ }
338
361
  `,
339
362
  { moduleId: 'vaadin-grid-styles' },
340
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() {
@@ -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 type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
6
+ import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
7
7
  import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
8
8
  import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
9
  import type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
@@ -5,14 +5,13 @@
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
- import { microTask } from '@vaadin/component-base/src/async.js';
9
+ import { TabindexMixin } from '@vaadin/a11y-base/src/tabindex-mixin.js';
10
+ import { animationFrame, microTask } from '@vaadin/component-base/src/async.js';
11
11
  import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
12
12
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
13
13
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
14
14
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
15
- import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
16
15
  import { processTemplates } from '@vaadin/component-base/src/templates.js';
17
16
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
18
17
  import { Virtualizer } from '@vaadin/component-base/src/virtualizer.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
 
@@ -577,39 +581,10 @@ class Grid extends ElementMixin(
577
581
 
578
582
  /** @private */
579
583
  __getIntrinsicWidth(col) {
580
- if (this.__intrinsicWidthCache.has(col)) {
581
- return this.__intrinsicWidthCache.get(col);
584
+ if (!this.__intrinsicWidthCache.has(col)) {
585
+ this.__calculateAndCacheIntrinsicWidths([col]);
582
586
  }
583
-
584
- const width = this.__calculateIntrinsicWidth(col);
585
- this.__intrinsicWidthCache.set(col, width);
586
-
587
- return width;
588
- }
589
-
590
- /** @private */
591
- __calculateIntrinsicWidth(col) {
592
- const initialWidth = col.width;
593
- const initialFlexGrow = col.flexGrow;
594
-
595
- col.width = 'auto';
596
- col.flexGrow = 0;
597
-
598
- // Note: _allCells only contains cells which are currently rendered in DOM
599
- const width = col._allCells
600
- .filter((cell) => {
601
- // Exclude body cells that are out of the visible viewport
602
- return !this.$.items.contains(cell) || this._isInViewport(cell.parentElement);
603
- })
604
- .reduce((width, cell) => {
605
- // Add 1px buffer to the offset width to avoid too narrow columns (sub-pixel rendering)
606
- return Math.max(width, cell.offsetWidth + 1);
607
- }, 0);
608
-
609
- col.flexGrow = initialFlexGrow;
610
- col.width = initialWidth;
611
-
612
- return width;
587
+ return this.__intrinsicWidthCache.get(col);
613
588
  }
614
589
 
615
590
  /** @private */
@@ -667,12 +642,74 @@ class Grid extends ElementMixin(
667
642
  }
668
643
 
669
644
  this.__intrinsicWidthCache = new Map();
645
+ // Cache the viewport rows to avoid unnecessary reflows while measuring the column widths
646
+ const fvi = this._firstVisibleIndex;
647
+ const lvi = this._lastVisibleIndex;
648
+ this.__viewportRowsCache = this._getVisibleRows().filter((row) => row.index >= fvi && row.index <= lvi);
649
+
650
+ // Pre-cache the intrinsic width of each column
651
+ this.__calculateAndCacheIntrinsicWidths(cols);
670
652
 
671
653
  cols.forEach((col) => {
672
654
  col.width = `${this.__getDistributedWidth(col)}px`;
673
655
  });
674
656
  }
675
657
 
658
+ /**
659
+ * Toggles the cell content for the given column to use or not use auto width.
660
+ *
661
+ * While content for all the column cells uses auto width (instead of the default 100%),
662
+ * their offsetWidth can be used to calculate the collective intrinsic width of the column.
663
+ *
664
+ * @private
665
+ */
666
+ __setVisibleCellContentAutoWidth(col, autoWidth) {
667
+ col._allCells
668
+ .filter((cell) => {
669
+ if (this.$.items.contains(cell)) {
670
+ return this.__viewportRowsCache.includes(cell.parentElement);
671
+ }
672
+ return true;
673
+ })
674
+ .forEach((cell) => {
675
+ cell.__measuringAutoWidth = autoWidth;
676
+ cell._content.style.width = autoWidth ? 'auto' : '';
677
+ cell._content.style.position = autoWidth ? 'absolute' : '';
678
+ });
679
+ }
680
+
681
+ /**
682
+ * Returns the maximum intrinsic width of the cell content in the given column.
683
+ * Only cells which are marked for measuring auto width are considered.
684
+ *
685
+ * @private
686
+ */
687
+ __getAutoWidthCellsMaxWidth(col) {
688
+ // Note: _allCells only contains cells which are currently rendered in DOM
689
+ return col._allCells.reduce((width, cell) => {
690
+ // Add 1px buffer to the offset width to avoid too narrow columns (sub-pixel rendering)
691
+ return cell.__measuringAutoWidth ? Math.max(width, cell._content.offsetWidth + 1) : width;
692
+ }, 0);
693
+ }
694
+
695
+ /**
696
+ * Calculates and caches the intrinsic width of each given column.
697
+ *
698
+ * @private
699
+ */
700
+ __calculateAndCacheIntrinsicWidths(cols) {
701
+ // Make all the columns use auto width at once before measuring to
702
+ // avoid reflows in between the measurements
703
+ cols.forEach((col) => this.__setVisibleCellContentAutoWidth(col, true));
704
+ // Measure and cache
705
+ cols.forEach((col) => {
706
+ const width = this.__getAutoWidthCellsMaxWidth(col);
707
+ this.__intrinsicWidthCache.set(col, width);
708
+ });
709
+ // Reset the columns to use 100% width
710
+ cols.forEach((col) => this.__setVisibleCellContentAutoWidth(col, false));
711
+ }
712
+
676
713
  /**
677
714
  * Updates the `width` of all columns which have `autoWidth` set to `true`.
678
715
  */
@@ -708,12 +745,14 @@ class Grid extends ElementMixin(
708
745
  );
709
746
  }
710
747
 
711
- beforeNextRender(this, () => {
712
- this._updateFirstAndLastColumn();
713
- this._resetKeyboardNavigation();
714
- this._afterScroll();
715
- this.__itemsReceived();
716
- });
748
+ this.__afterCreateScrollerRowsDebouncer = Debouncer.debounce(
749
+ this.__afterCreateScrollerRowsDebouncer,
750
+ animationFrame,
751
+ () => {
752
+ this._afterScroll();
753
+ this.__itemsReceived();
754
+ },
755
+ );
717
756
  return rows;
718
757
  }
719
758
 
@@ -832,7 +871,14 @@ class Grid extends ElementMixin(
832
871
  column._cells.push(cell);
833
872
  }
834
873
  cell.setAttribute('part', 'cell body-cell');
835
- 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
+ }
836
882
 
837
883
  if (index === cols.length - 1 && this.rowDetailsRenderer) {
838
884
  // Add details cell as last cell to body rows
@@ -971,6 +1017,7 @@ class Grid extends ElementMixin(
971
1017
  _columnTreeChanged(columnTree) {
972
1018
  this._renderColumnTree(columnTree);
973
1019
  this.recalculateColumnWidths();
1020
+ this.__updateColumnsBodyContentHidden();
974
1021
  }
975
1022
 
976
1023
  /** @private */
@@ -1114,7 +1161,7 @@ class Grid extends ElementMixin(
1114
1161
  this.__itemsReceived();
1115
1162
 
1116
1163
  requestAnimationFrame(() => {
1117
- this.__scrollToPendingIndex();
1164
+ this.__scrollToPendingIndexes();
1118
1165
  });
1119
1166
  }
1120
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.0.5",
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.0.5/#/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.0.5/#/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.0.5/#/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.5/#/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.5/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/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.5/#/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.5/#/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.0.5",
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.0.5/#/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.0.5/#/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.0.5/#/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.5/#/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.5/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.0.5/#/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.5/#/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.5/#/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.",