@vaadin/grid 23.2.2 → 23.3.0-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/src/vaadin-grid-column-reordering-mixin.js +9 -11
- package/src/vaadin-grid-column-resizing-mixin.js +1 -1
- package/src/vaadin-grid-drag-and-drop-mixin.js +1 -1
- package/src/vaadin-grid-event-context-mixin.js +2 -2
- package/src/vaadin-grid-keyboard-navigation-mixin.js +10 -0
- package/src/vaadin-grid.js +48 -4
- package/web-types.json +4 -4
- package/web-types.lit.json +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.3.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
47
47
|
"@polymer/polymer": "^3.0.0",
|
|
48
|
-
"@vaadin/checkbox": "
|
|
49
|
-
"@vaadin/component-base": "
|
|
50
|
-
"@vaadin/lit-renderer": "
|
|
51
|
-
"@vaadin/text-field": "
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
53
|
-
"@vaadin/vaadin-material-styles": "
|
|
54
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
48
|
+
"@vaadin/checkbox": "23.3.0-alpha2",
|
|
49
|
+
"@vaadin/component-base": "23.3.0-alpha2",
|
|
50
|
+
"@vaadin/lit-renderer": "23.3.0-alpha2",
|
|
51
|
+
"@vaadin/text-field": "23.3.0-alpha2",
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha2",
|
|
53
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha2",
|
|
54
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@esm-bundle/chai": "^4.3.4",
|
|
58
|
-
"@vaadin/polymer-legacy-adapter": "
|
|
58
|
+
"@vaadin/polymer-legacy-adapter": "23.3.0-alpha2",
|
|
59
59
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
60
60
|
"lit": "^2.0.0",
|
|
61
61
|
"sinon": "^13.0.2"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"web-types.json",
|
|
65
65
|
"web-types.lit.json"
|
|
66
66
|
],
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
|
|
68
68
|
}
|
|
@@ -32,7 +32,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
static get observers() {
|
|
35
|
-
return ['_updateOrders(_columnTree
|
|
35
|
+
return ['_updateOrders(_columnTree)'];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** @protected */
|
|
@@ -120,12 +120,12 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
120
120
|
|
|
121
121
|
// Cancel reordering if there are draggable nodes on the event path
|
|
122
122
|
const path = e.composedPath && e.composedPath();
|
|
123
|
-
if (path && path.
|
|
123
|
+
if (path && path.some((node) => node.hasAttribute && node.hasAttribute('draggable'))) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const headerCell = this._cellFromPoint(e.detail.x, e.detail.y);
|
|
128
|
-
if (!headerCell || headerCell.getAttribute('part').
|
|
128
|
+
if (!headerCell || !headerCell.getAttribute('part').includes('header-cell')) {
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -161,7 +161,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
161
161
|
this._isSwapAllowed(this._draggedColumn, targetColumn) &&
|
|
162
162
|
this._isSwappableByPosition(targetColumn, e.detail.x)
|
|
163
163
|
) {
|
|
164
|
-
// Get the
|
|
164
|
+
// Get the header level of the target column (and the dragged column)
|
|
165
165
|
const columnTreeLevel = this._columnTree.findIndex((level) => level.includes(targetColumn));
|
|
166
166
|
// Get the columns on that level in visual order
|
|
167
167
|
const levelColumnsInOrder = this._getColumnsInOrder(columnTreeLevel);
|
|
@@ -285,8 +285,8 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
/** @private */
|
|
288
|
-
_updateOrders(columnTree
|
|
289
|
-
if (columnTree === undefined
|
|
288
|
+
_updateOrders(columnTree) {
|
|
289
|
+
if (columnTree === undefined) {
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -354,9 +354,9 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
354
354
|
* @protected
|
|
355
355
|
*/
|
|
356
356
|
_isSwappableByPosition(targetColumn, clientX) {
|
|
357
|
-
const targetCell = Array.from(this.$.header.querySelectorAll('tr:not([hidden]) [part~="cell"]')).
|
|
357
|
+
const targetCell = Array.from(this.$.header.querySelectorAll('tr:not([hidden]) [part~="cell"]')).find((cell) =>
|
|
358
358
|
targetColumn.contains(cell._column),
|
|
359
|
-
)
|
|
359
|
+
);
|
|
360
360
|
const sourceCellRect = this.$.header
|
|
361
361
|
.querySelector('tr:not([hidden]) [reorder-status=dragging]')
|
|
362
362
|
.getBoundingClientRect();
|
|
@@ -373,9 +373,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
373
373
|
* @protected
|
|
374
374
|
*/
|
|
375
375
|
_swapColumnOrders(column1, column2) {
|
|
376
|
-
|
|
377
|
-
column1._order = column2._order;
|
|
378
|
-
column2._order = _order;
|
|
376
|
+
[column1._order, column2._order] = [column2._order, column1._order];
|
|
379
377
|
this._updateFrozenColumn();
|
|
380
378
|
this._updateFirstAndLastColumn();
|
|
381
379
|
}
|
|
@@ -52,7 +52,7 @@ export const ColumnResizingMixin = (superClass) =>
|
|
|
52
52
|
|
|
53
53
|
const eventX = e.detail.x;
|
|
54
54
|
const columnRowCells = Array.from(this.$.header.querySelectorAll('[part~="row"]:last-child [part~="cell"]'));
|
|
55
|
-
const targetCell = columnRowCells.
|
|
55
|
+
const targetCell = columnRowCells.find((cell) => cell._column === column);
|
|
56
56
|
// Resize the target column
|
|
57
57
|
if (targetCell.offsetWidth) {
|
|
58
58
|
const style = getComputedStyle(targetCell._content);
|
|
@@ -201,7 +201,7 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
let row = e.composedPath().
|
|
204
|
+
let row = e.composedPath().find((node) => node.localName === 'tr');
|
|
205
205
|
|
|
206
206
|
if (!this._effectiveSize || this.dropMode === DropMode.ON_GRID) {
|
|
207
207
|
// The grid is empty or "on-grid" drop mode was used, always default to "empty"
|
|
@@ -42,9 +42,9 @@ export const EventContextMixin = (superClass) =>
|
|
|
42
42
|
return context;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
context.section = ['body', 'header', 'footer', 'details'].
|
|
45
|
+
context.section = ['body', 'header', 'footer', 'details'].find(
|
|
46
46
|
(section) => cell.getAttribute('part').indexOf(section) > -1,
|
|
47
|
-
)
|
|
47
|
+
);
|
|
48
48
|
|
|
49
49
|
if (cell._column) {
|
|
50
50
|
context.column = cell._column;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 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/component-base/src/focus-utils.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @polymerMixin
|
|
@@ -584,6 +585,10 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
584
585
|
this.toggleAttribute('navigating', true);
|
|
585
586
|
}
|
|
586
587
|
}
|
|
588
|
+
|
|
589
|
+
if (key === 'Escape') {
|
|
590
|
+
this._hideTooltip();
|
|
591
|
+
}
|
|
587
592
|
}
|
|
588
593
|
|
|
589
594
|
/** @private */
|
|
@@ -721,6 +726,7 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
721
726
|
_onFocusOut(e) {
|
|
722
727
|
this.toggleAttribute('navigating', false);
|
|
723
728
|
this._detectInteracting(e);
|
|
729
|
+
this._hideTooltip();
|
|
724
730
|
}
|
|
725
731
|
|
|
726
732
|
/** @private */
|
|
@@ -742,6 +748,10 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
742
748
|
// Fire a public event for cell.
|
|
743
749
|
const context = this.getEventContext(e);
|
|
744
750
|
cell.dispatchEvent(new CustomEvent('cell-focus', { bubbles: true, composed: true, detail: { context } }));
|
|
751
|
+
|
|
752
|
+
if (isKeyboardActive() && e.target === cell) {
|
|
753
|
+
this._showTooltip(e);
|
|
754
|
+
}
|
|
745
755
|
}
|
|
746
756
|
}
|
|
747
757
|
|
package/src/vaadin-grid.js
CHANGED
|
@@ -8,9 +8,11 @@ import './vaadin-grid-styles.js';
|
|
|
8
8
|
import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
9
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
10
10
|
import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
11
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
11
12
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
13
|
import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
|
|
13
14
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
15
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
14
16
|
import { Virtualizer } from '@vaadin/component-base/src/virtualizer.js';
|
|
15
17
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
18
|
import { A11yMixin } from './vaadin-grid-a11y-mixin.js';
|
|
@@ -258,7 +260,9 @@ class Grid extends ElementMixin(
|
|
|
258
260
|
FilterMixin(
|
|
259
261
|
ColumnReorderingMixin(
|
|
260
262
|
ColumnResizingMixin(
|
|
261
|
-
|
|
263
|
+
ControllerMixin(
|
|
264
|
+
EventContextMixin(DragAndDropMixin(StylingMixin(TabindexMixin(PolymerElement)))),
|
|
265
|
+
),
|
|
262
266
|
),
|
|
263
267
|
),
|
|
264
268
|
),
|
|
@@ -293,6 +297,8 @@ class Grid extends ElementMixin(
|
|
|
293
297
|
<div part="reorder-ghost"></div>
|
|
294
298
|
</div>
|
|
295
299
|
|
|
300
|
+
<slot name="tooltip"></slot>
|
|
301
|
+
|
|
296
302
|
<div id="focusexit" tabindex="0"></div>
|
|
297
303
|
`;
|
|
298
304
|
}
|
|
@@ -394,6 +400,7 @@ class Grid extends ElementMixin(
|
|
|
394
400
|
disconnectedCallback() {
|
|
395
401
|
super.disconnectedCallback();
|
|
396
402
|
this.isAttached = false;
|
|
403
|
+
this._hideTooltip();
|
|
397
404
|
}
|
|
398
405
|
|
|
399
406
|
/** @private */
|
|
@@ -453,6 +460,10 @@ class Grid extends ElementMixin(
|
|
|
453
460
|
new ResizeObserver(() => setTimeout(() => this.__updateFooterPositioning())).observe(this.$.footer);
|
|
454
461
|
|
|
455
462
|
processTemplates(this);
|
|
463
|
+
|
|
464
|
+
this._tooltipController = new TooltipController(this);
|
|
465
|
+
this.addController(this._tooltipController);
|
|
466
|
+
this._tooltipController.setManual(true);
|
|
456
467
|
}
|
|
457
468
|
|
|
458
469
|
/**
|
|
@@ -661,6 +672,21 @@ class Grid extends ElementMixin(
|
|
|
661
672
|
cell.setAttribute('tabindex', '-1');
|
|
662
673
|
cell.setAttribute('role', tagName === 'td' ? 'gridcell' : 'columnheader');
|
|
663
674
|
|
|
675
|
+
// For now we only support tooltip on desktop
|
|
676
|
+
if (!isAndroid && !isIOS) {
|
|
677
|
+
cell.addEventListener('mouseenter', (event) => {
|
|
678
|
+
this._showTooltip(event);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
cell.addEventListener('mouseleave', () => {
|
|
682
|
+
this._hideTooltip();
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
cell.addEventListener('mousedown', () => {
|
|
686
|
+
this._hideTooltip();
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
|
|
664
690
|
const slot = document.createElement('slot');
|
|
665
691
|
slot.setAttribute('name', slotName);
|
|
666
692
|
|
|
@@ -726,7 +752,7 @@ class Grid extends ElementMixin(
|
|
|
726
752
|
if (section === 'body') {
|
|
727
753
|
// Body
|
|
728
754
|
column._cells = column._cells || [];
|
|
729
|
-
cell = column._cells.
|
|
755
|
+
cell = column._cells.find((cell) => cell._vacant);
|
|
730
756
|
if (!cell) {
|
|
731
757
|
cell = this._createCell('td');
|
|
732
758
|
column._cells.push(cell);
|
|
@@ -737,7 +763,7 @@ class Grid extends ElementMixin(
|
|
|
737
763
|
if (index === cols.length - 1 && this.rowDetailsRenderer) {
|
|
738
764
|
// Add details cell as last cell to body rows
|
|
739
765
|
this._detailsCells = this._detailsCells || [];
|
|
740
|
-
const detailsCell = this._detailsCells.
|
|
766
|
+
const detailsCell = this._detailsCells.find((cell) => cell._vacant) || this._createCell('td');
|
|
741
767
|
if (this._detailsCells.indexOf(detailsCell) === -1) {
|
|
742
768
|
this._detailsCells.push(detailsCell);
|
|
743
769
|
}
|
|
@@ -763,7 +789,7 @@ class Grid extends ElementMixin(
|
|
|
763
789
|
column[`_${section}Cell`] = cell;
|
|
764
790
|
} else {
|
|
765
791
|
column._emptyCells = column._emptyCells || [];
|
|
766
|
-
cell = column._emptyCells.
|
|
792
|
+
cell = column._emptyCells.find((cell) => cell._vacant) || this._createCell(tagName);
|
|
767
793
|
cell._column = column;
|
|
768
794
|
row.appendChild(cell);
|
|
769
795
|
if (column._emptyCells.indexOf(cell) === -1) {
|
|
@@ -984,6 +1010,24 @@ class Grid extends ElementMixin(
|
|
|
984
1010
|
};
|
|
985
1011
|
}
|
|
986
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* @param {Event} event
|
|
1015
|
+
* @protected
|
|
1016
|
+
*/
|
|
1017
|
+
_showTooltip(event) {
|
|
1018
|
+
// Check if there is a slotted vaadin-tooltip element.
|
|
1019
|
+
if (this._tooltipController.node && this._tooltipController.node.isConnected) {
|
|
1020
|
+
this._tooltipController.setTarget(event.target);
|
|
1021
|
+
this._tooltipController.setContext(this.getEventContext(event));
|
|
1022
|
+
this._tooltipController.setOpened(true);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** @protected */
|
|
1027
|
+
_hideTooltip() {
|
|
1028
|
+
this._tooltipController.setOpened(false);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
987
1031
|
/**
|
|
988
1032
|
* Requests an update for the content of cells.
|
|
989
1033
|
*
|
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": "23.
|
|
4
|
+
"version": "23.3.0-alpha2",
|
|
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/23.
|
|
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/23.3.0-alpha2/#/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/23.
|
|
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/23.3.0-alpha2/#/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",
|
|
@@ -1780,7 +1780,7 @@
|
|
|
1780
1780
|
},
|
|
1781
1781
|
{
|
|
1782
1782
|
"name": "vaadin-grid",
|
|
1783
|
-
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.
|
|
1783
|
+
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`row` | Row in the internal table\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`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`last-frozen` | Last frozen cell | 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 drag of a row is starting. The value is a number when multiple rows are dragged | row\n`dragover` | Set when the row is dragged over | row\n`drag-disabled` | Set to a row that isn't available for dragging | row\n`drop-disabled` | Set to a row that can't be dropped on top of | row\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
1784
1784
|
"attributes": [
|
|
1785
1785
|
{
|
|
1786
1786
|
"name": "size",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/grid",
|
|
4
|
-
"version": "23.
|
|
4
|
+
"version": "23.3.0-alpha2",
|
|
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/23.
|
|
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/23.3.0-alpha2/#/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/23.
|
|
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/23.3.0-alpha2/#/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
|
{
|
|
@@ -702,7 +702,7 @@
|
|
|
702
702
|
},
|
|
703
703
|
{
|
|
704
704
|
"name": "vaadin-grid",
|
|
705
|
-
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.
|
|
705
|
+
"description": "`<vaadin-grid>` is a free, high quality data grid / data table Web Component. The content of the\nthe grid can be populated by using renderer callback function.\n\n### Quick Start\n\nStart with an assigning an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-grid#property-dataProvider) in\nthe API reference below for the detailed data provider arguments description,\nand the “Assigning Data” page in the demos.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`row` | Row in the internal table\n`cell` | Cell in the internal table\n`header-cell` | Header cell in the internal table\n`body-cell` | Body cell in the internal table\n`footer-cell` | Footer cell in the internal table\n`details-cell` | Row details cell in the internal table\n`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`last-frozen` | Last frozen cell | 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 drag of a row is starting. The value is a number when multiple rows are dragged | 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.",
|
|
706
706
|
"extension": true,
|
|
707
707
|
"attributes": [
|
|
708
708
|
{
|