@vaadin/grid 24.6.0-beta1 → 24.7.0-alpha1
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 +11 -11
- package/src/vaadin-grid-a11y-mixin.d.ts +16 -0
- package/src/vaadin-grid-a11y-mixin.js +11 -0
- package/src/vaadin-grid-mixin.d.ts +11 -1
- package/src/vaadin-grid-selection-column-base-mixin.d.ts +5 -0
- package/src/vaadin-grid-selection-column-base-mixin.js +95 -41
- package/src/vaadin-grid-selection-column-mixin.js +18 -15
- package/src/vaadin-grid-selection-mixin.js +10 -0
- package/src/vaadin-grid-styles.js +2 -4
- package/src/vaadin-grid-tree-toggle-mixin.js +2 -2
- package/src/vaadin-grid.d.ts +1 -0
- package/src/vaadin-grid.js +1 -1
- package/src/vaadin-lit-grid.js +8 -1
- package/theme/lumo/vaadin-grid-sorter-styles.js +0 -1
- package/theme/material/vaadin-grid-sorter-styles.js +0 -1
- package/web-types.json +30 -4
- package/web-types.lit.json +18 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
48
48
|
"@polymer/polymer": "^3.0.0",
|
|
49
|
-
"@vaadin/a11y-base": "24.
|
|
50
|
-
"@vaadin/checkbox": "24.
|
|
51
|
-
"@vaadin/component-base": "24.
|
|
52
|
-
"@vaadin/lit-renderer": "24.
|
|
53
|
-
"@vaadin/text-field": "24.
|
|
54
|
-
"@vaadin/vaadin-lumo-styles": "24.
|
|
55
|
-
"@vaadin/vaadin-material-styles": "24.
|
|
56
|
-
"@vaadin/vaadin-themable-mixin": "24.
|
|
49
|
+
"@vaadin/a11y-base": "24.7.0-alpha1",
|
|
50
|
+
"@vaadin/checkbox": "24.7.0-alpha1",
|
|
51
|
+
"@vaadin/component-base": "24.7.0-alpha1",
|
|
52
|
+
"@vaadin/lit-renderer": "24.7.0-alpha1",
|
|
53
|
+
"@vaadin/text-field": "24.7.0-alpha1",
|
|
54
|
+
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha1",
|
|
55
|
+
"@vaadin/vaadin-material-styles": "24.7.0-alpha1",
|
|
56
|
+
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha1",
|
|
57
57
|
"lit": "^3.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@vaadin/chai-plugins": "24.
|
|
60
|
+
"@vaadin/chai-plugins": "24.7.0-alpha1",
|
|
61
61
|
"@vaadin/testing-helpers": "^1.0.0",
|
|
62
62
|
"sinon": "^18.0.0"
|
|
63
63
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"web-types.json",
|
|
66
66
|
"web-types.lit.json"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "04be941c9a7b659871c97f31b9cc3ffd7528087b"
|
|
69
69
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2024 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
|
|
8
|
+
export declare function A11yMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<A11yMixinClass> & T;
|
|
9
|
+
|
|
10
|
+
export declare class A11yMixinClass {
|
|
11
|
+
/**
|
|
12
|
+
* String used to label the grid to screen reader users.
|
|
13
|
+
* @attr {string} accessible-name
|
|
14
|
+
*/
|
|
15
|
+
accessibleName: string;
|
|
16
|
+
}
|
|
@@ -10,6 +10,17 @@ import { iterateChildren, iterateRowCells } from './vaadin-grid-helpers.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export const A11yMixin = (superClass) =>
|
|
12
12
|
class A11yMixin extends superClass {
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
/**
|
|
16
|
+
* String used to label the grid to screen reader users.
|
|
17
|
+
* @attr {string} accessible-name
|
|
18
|
+
*/
|
|
19
|
+
accessibleName: {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
13
24
|
static get observers() {
|
|
14
25
|
return ['_a11yUpdateGridSize(size, _columnTree)'];
|
|
15
26
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
8
|
+
import type { A11yMixinClass } from './vaadin-grid-a11y-mixin.js';
|
|
8
9
|
import type { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
|
|
9
10
|
import type { ArrayDataProviderMixinClass } from './vaadin-grid-array-data-provider-mixin.js';
|
|
10
11
|
import type { GridBodyRenderer, GridColumn, GridHeaderFooterRenderer } from './vaadin-grid-column.js';
|
|
@@ -97,6 +98,11 @@ export type GridDataProviderChangedEvent<TItem> = CustomEvent<{ value: GridDataP
|
|
|
97
98
|
*/
|
|
98
99
|
export type GridExpandedItemsChangedEvent<TItem> = CustomEvent<{ value: TItem[] }>;
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Fired when the user selects or deselects an item through the selection column.
|
|
103
|
+
*/
|
|
104
|
+
export type GridItemToggleEvent<TItem> = CustomEvent<{ item: TItem; selected: boolean; shiftKey: boolean }>;
|
|
105
|
+
|
|
100
106
|
/**
|
|
101
107
|
* Fired when starting to drag grid rows.
|
|
102
108
|
*/
|
|
@@ -156,13 +162,16 @@ export interface GridCustomEventMap<TItem> {
|
|
|
156
162
|
'selected-items-changed': GridSelectedItemsChangedEvent<TItem>;
|
|
157
163
|
|
|
158
164
|
'size-changed': GridSizeChangedEvent;
|
|
165
|
+
|
|
166
|
+
'item-toggle': GridItemToggleEvent<TItem>;
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
export interface GridEventMap<TItem> extends HTMLElementEventMap, GridCustomEventMap<TItem> {}
|
|
162
170
|
|
|
163
171
|
export declare function GridMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
164
172
|
base: T,
|
|
165
|
-
): Constructor<
|
|
173
|
+
): Constructor<A11yMixinClass> &
|
|
174
|
+
Constructor<ActiveItemMixinClass<TItem>> &
|
|
166
175
|
Constructor<ArrayDataProviderMixinClass<TItem>> &
|
|
167
176
|
Constructor<ColumnReorderingMixinClass> &
|
|
168
177
|
Constructor<DataProviderMixinClass<TItem>> &
|
|
@@ -179,6 +188,7 @@ export declare function GridMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
|
179
188
|
|
|
180
189
|
export interface GridMixinClass<TItem>
|
|
181
190
|
extends DisabledMixinClass,
|
|
191
|
+
A11yMixinClass,
|
|
182
192
|
ActiveItemMixinClass<TItem>,
|
|
183
193
|
ArrayDataProviderMixinClass<TItem>,
|
|
184
194
|
DataProviderMixinClass<TItem>,
|
|
@@ -39,6 +39,11 @@ export declare class GridSelectionColumnBaseMixinClass<TItem> {
|
|
|
39
39
|
*/
|
|
40
40
|
dragSelect: boolean;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Indicates whether the shift key is currently pressed.
|
|
44
|
+
*/
|
|
45
|
+
protected _shiftKeyDown: boolean;
|
|
46
|
+
|
|
42
47
|
/**
|
|
43
48
|
* Override to handle the user selecting all items.
|
|
44
49
|
*/
|
|
@@ -92,6 +92,16 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
92
92
|
|
|
93
93
|
/** @protected */
|
|
94
94
|
_selectAllHidden: Boolean,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Indicates whether the shift key is currently pressed.
|
|
98
|
+
*
|
|
99
|
+
* @protected
|
|
100
|
+
*/
|
|
101
|
+
_shiftKeyDown: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
value: false,
|
|
104
|
+
},
|
|
95
105
|
};
|
|
96
106
|
}
|
|
97
107
|
|
|
@@ -101,6 +111,39 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
101
111
|
];
|
|
102
112
|
}
|
|
103
113
|
|
|
114
|
+
constructor() {
|
|
115
|
+
super();
|
|
116
|
+
this.__onCellTrack = this.__onCellTrack.bind(this);
|
|
117
|
+
this.__onCellClick = this.__onCellClick.bind(this);
|
|
118
|
+
this.__onCellMouseDown = this.__onCellMouseDown.bind(this);
|
|
119
|
+
this.__onGridInteraction = this.__onGridInteraction.bind(this);
|
|
120
|
+
this.__onActiveItemChanged = this.__onActiveItemChanged.bind(this);
|
|
121
|
+
this.__onSelectRowCheckboxChange = this.__onSelectRowCheckboxChange.bind(this);
|
|
122
|
+
this.__onSelectAllCheckboxChange = this.__onSelectAllCheckboxChange.bind(this);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @protected */
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
super.connectedCallback();
|
|
128
|
+
if (this._grid) {
|
|
129
|
+
this._grid.addEventListener('keyup', this.__onGridInteraction);
|
|
130
|
+
this._grid.addEventListener('keydown', this.__onGridInteraction, { capture: true });
|
|
131
|
+
this._grid.addEventListener('mousedown', this.__onGridInteraction);
|
|
132
|
+
this._grid.addEventListener('active-item-changed', this.__onActiveItemChanged);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** @protected */
|
|
137
|
+
disconnectedCallback() {
|
|
138
|
+
super.disconnectedCallback();
|
|
139
|
+
if (this._grid) {
|
|
140
|
+
this._grid.removeEventListener('keyup', this.__onGridInteraction);
|
|
141
|
+
this._grid.removeEventListener('keydown', this.__onGridInteraction, { capture: true });
|
|
142
|
+
this._grid.removeEventListener('mousedown', this.__onGridInteraction);
|
|
143
|
+
this._grid.removeEventListener('active-item-changed', this.__onActiveItemChanged);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
104
147
|
/**
|
|
105
148
|
* Renders the Select All checkbox to the header cell.
|
|
106
149
|
*
|
|
@@ -112,13 +155,11 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
112
155
|
checkbox = document.createElement('vaadin-checkbox');
|
|
113
156
|
checkbox.setAttribute('aria-label', 'Select All');
|
|
114
157
|
checkbox.classList.add('vaadin-grid-select-all-checkbox');
|
|
158
|
+
checkbox.addEventListener('change', this.__onSelectAllCheckboxChange);
|
|
115
159
|
root.appendChild(checkbox);
|
|
116
|
-
// Add listener after appending, so we can skip the initial change event
|
|
117
|
-
checkbox.addEventListener('checked-changed', this.__onSelectAllCheckedChanged.bind(this));
|
|
118
160
|
}
|
|
119
161
|
|
|
120
162
|
const checked = this.__isChecked(this.selectAll, this._indeterminate);
|
|
121
|
-
checkbox.__rendererChecked = checked;
|
|
122
163
|
checkbox.checked = checked;
|
|
123
164
|
checkbox.hidden = this._selectAllHidden;
|
|
124
165
|
checkbox.indeterminate = this._indeterminate;
|
|
@@ -134,16 +175,14 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
134
175
|
if (!checkbox) {
|
|
135
176
|
checkbox = document.createElement('vaadin-checkbox');
|
|
136
177
|
checkbox.setAttribute('aria-label', 'Select Row');
|
|
178
|
+
checkbox.addEventListener('change', this.__onSelectRowCheckboxChange);
|
|
137
179
|
root.appendChild(checkbox);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
root.addEventListener('mousedown', this.__onCellMouseDown.bind(this));
|
|
142
|
-
root.addEventListener('click', this.__onCellClick.bind(this));
|
|
180
|
+
addListener(root, 'track', this.__onCellTrack);
|
|
181
|
+
root.addEventListener('mousedown', this.__onCellMouseDown);
|
|
182
|
+
root.addEventListener('click', this.__onCellClick);
|
|
143
183
|
}
|
|
144
184
|
|
|
145
185
|
checkbox.__item = item;
|
|
146
|
-
checkbox.__rendererChecked = selected;
|
|
147
186
|
checkbox.checked = selected;
|
|
148
187
|
|
|
149
188
|
const isSelectable = this._grid.__isItemSelectable(item);
|
|
@@ -157,36 +196,36 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
157
196
|
*
|
|
158
197
|
* @private
|
|
159
198
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (e.target.checked === e.target.__rendererChecked) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (this._indeterminate || e.target.checked) {
|
|
199
|
+
__onSelectAllCheckboxChange(e) {
|
|
200
|
+
if (this._indeterminate || e.currentTarget.checked) {
|
|
167
201
|
this._selectAll();
|
|
168
202
|
} else {
|
|
169
203
|
this._deselectAll();
|
|
170
204
|
}
|
|
171
205
|
}
|
|
172
206
|
|
|
207
|
+
/** @private */
|
|
208
|
+
__onGridInteraction(e) {
|
|
209
|
+
if (e instanceof KeyboardEvent) {
|
|
210
|
+
this._shiftKeyDown = e.key !== 'Shift' && e.shiftKey;
|
|
211
|
+
} else {
|
|
212
|
+
this._shiftKeyDown = e.shiftKey;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (this.autoSelect) {
|
|
216
|
+
// Prevent text selection when shift-clicking to select a range of items.
|
|
217
|
+
this._grid.$.scroller.toggleAttribute('range-selecting', this._shiftKeyDown);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
173
221
|
/**
|
|
174
222
|
* Selects or deselects the row when the Select Row checkbox is switched.
|
|
175
223
|
* The listener handles only user-fired events.
|
|
176
224
|
*
|
|
177
225
|
* @private
|
|
178
226
|
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (e.target.checked === e.target.__rendererChecked) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (e.target.checked) {
|
|
186
|
-
this._selectItem(e.target.__item);
|
|
187
|
-
} else {
|
|
188
|
-
this._deselectItem(e.target.__item);
|
|
189
|
-
}
|
|
227
|
+
__onSelectRowCheckboxChange(e) {
|
|
228
|
+
this.__toggleItem(e.currentTarget.__item, e.currentTarget.checked);
|
|
190
229
|
}
|
|
191
230
|
|
|
192
231
|
/** @private */
|
|
@@ -211,11 +250,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
211
250
|
} else if (event.detail.state === 'end') {
|
|
212
251
|
// if drag start and end stays within the same item, then toggle its state
|
|
213
252
|
if (this.__dragStartItem) {
|
|
214
|
-
|
|
215
|
-
this._selectItem(this.__dragStartItem);
|
|
216
|
-
} else {
|
|
217
|
-
this._deselectItem(this.__dragStartItem);
|
|
218
|
-
}
|
|
253
|
+
this.__toggleItem(this.__dragStartItem, this.__selectOnDrag);
|
|
219
254
|
}
|
|
220
255
|
// clear drag state after timeout, which allows preventing the
|
|
221
256
|
// subsequent click event if drag started and ended on the same item
|
|
@@ -264,11 +299,24 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
264
299
|
}
|
|
265
300
|
}
|
|
266
301
|
|
|
302
|
+
/** @private */
|
|
303
|
+
__onActiveItemChanged(e) {
|
|
304
|
+
const activeItem = e.detail.value;
|
|
305
|
+
if (this.autoSelect) {
|
|
306
|
+
const item = activeItem || this.__previousActiveItem;
|
|
307
|
+
if (item) {
|
|
308
|
+
this.__toggleItem(item);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
this.__previousActiveItem = activeItem;
|
|
312
|
+
}
|
|
313
|
+
|
|
267
314
|
/** @private */
|
|
268
315
|
__dragAutoScroller() {
|
|
269
316
|
if (this.__dragStartIndex === undefined) {
|
|
270
317
|
return;
|
|
271
318
|
}
|
|
319
|
+
|
|
272
320
|
// Get the row being hovered over
|
|
273
321
|
const renderedRows = this._grid._getRenderedRows();
|
|
274
322
|
const hoveredRow = renderedRows.find((row) => {
|
|
@@ -293,11 +341,7 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
293
341
|
(hoveredIndex > this.__dragStartIndex && row.index >= this.__dragStartIndex && row.index <= hoveredIndex) ||
|
|
294
342
|
(hoveredIndex < this.__dragStartIndex && row.index <= this.__dragStartIndex && row.index >= hoveredIndex)
|
|
295
343
|
) {
|
|
296
|
-
|
|
297
|
-
this._selectItem(row._item);
|
|
298
|
-
} else {
|
|
299
|
-
this._deselectItem(row._item);
|
|
300
|
-
}
|
|
344
|
+
this.__toggleItem(row._item, this.__selectOnDrag);
|
|
301
345
|
this.__dragStartItem = undefined;
|
|
302
346
|
}
|
|
303
347
|
});
|
|
@@ -373,14 +417,24 @@ export const GridSelectionColumnBaseMixin = (superClass) =>
|
|
|
373
417
|
|
|
374
418
|
/**
|
|
375
419
|
* Toggles the selected state of the given item.
|
|
420
|
+
*
|
|
376
421
|
* @param item the item to toggle
|
|
422
|
+
* @param {boolean} [selected] whether to select or deselect the item
|
|
377
423
|
* @private
|
|
378
424
|
*/
|
|
379
|
-
__toggleItem(item) {
|
|
380
|
-
if (this._grid._isSelected(item)) {
|
|
381
|
-
|
|
382
|
-
|
|
425
|
+
__toggleItem(item, selected = !this._grid._isSelected(item)) {
|
|
426
|
+
if (selected === this._grid._isSelected(item)) {
|
|
427
|
+
// Skip selection if the item is already in the desired state.
|
|
428
|
+
// Note, _selectItem and _deselectItem may be overridden in custom
|
|
429
|
+
// selection column implementations, and calling them unnecessarily
|
|
430
|
+
// might affect performance (e.g. vaadin-grid-flow-selection-column).
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (selected) {
|
|
383
435
|
this._selectItem(item);
|
|
436
|
+
} else {
|
|
437
|
+
this._deselectItem(item);
|
|
384
438
|
}
|
|
385
439
|
}
|
|
386
440
|
|
|
@@ -29,14 +29,12 @@ export const GridSelectionColumnMixin = (superClass) =>
|
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
31
31
|
|
|
32
|
-
this.__boundOnActiveItemChanged = this.__onActiveItemChanged.bind(this);
|
|
33
32
|
this.__boundUpdateSelectAllVisibility = this.__updateSelectAllVisibility.bind(this);
|
|
34
33
|
this.__boundOnSelectedItemsChanged = this.__onSelectedItemsChanged.bind(this);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
/** @protected */
|
|
38
37
|
disconnectedCallback() {
|
|
39
|
-
this._grid.removeEventListener('active-item-changed', this.__boundOnActiveItemChanged);
|
|
40
38
|
this._grid.removeEventListener('data-provider-changed', this.__boundUpdateSelectAllVisibility);
|
|
41
39
|
this._grid.removeEventListener('is-item-selectable-changed', this.__boundUpdateSelectAllVisibility);
|
|
42
40
|
this._grid.removeEventListener('filter-changed', this.__boundOnSelectedItemsChanged);
|
|
@@ -49,7 +47,6 @@ export const GridSelectionColumnMixin = (superClass) =>
|
|
|
49
47
|
connectedCallback() {
|
|
50
48
|
super.connectedCallback();
|
|
51
49
|
if (this._grid) {
|
|
52
|
-
this._grid.addEventListener('active-item-changed', this.__boundOnActiveItemChanged);
|
|
53
50
|
this._grid.addEventListener('data-provider-changed', this.__boundUpdateSelectAllVisibility);
|
|
54
51
|
this._grid.addEventListener('is-item-selectable-changed', this.__boundUpdateSelectAllVisibility);
|
|
55
52
|
this._grid.addEventListener('filter-changed', this.__boundOnSelectedItemsChanged);
|
|
@@ -116,6 +113,15 @@ export const GridSelectionColumnMixin = (superClass) =>
|
|
|
116
113
|
_selectItem(item) {
|
|
117
114
|
if (this._grid.__isItemSelectable(item)) {
|
|
118
115
|
this._grid.selectItem(item);
|
|
116
|
+
this._grid.dispatchEvent(
|
|
117
|
+
new CustomEvent('item-toggle', {
|
|
118
|
+
detail: {
|
|
119
|
+
item,
|
|
120
|
+
selected: true,
|
|
121
|
+
shiftKey: this._shiftKeyDown,
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
|
|
@@ -130,21 +136,18 @@ export const GridSelectionColumnMixin = (superClass) =>
|
|
|
130
136
|
_deselectItem(item) {
|
|
131
137
|
if (this._grid.__isItemSelectable(item)) {
|
|
132
138
|
this._grid.deselectItem(item);
|
|
139
|
+
this._grid.dispatchEvent(
|
|
140
|
+
new CustomEvent('item-toggle', {
|
|
141
|
+
detail: {
|
|
142
|
+
item,
|
|
143
|
+
selected: false,
|
|
144
|
+
shiftKey: this._shiftKeyDown,
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
133
148
|
}
|
|
134
149
|
}
|
|
135
150
|
|
|
136
|
-
/** @private */
|
|
137
|
-
__onActiveItemChanged(e) {
|
|
138
|
-
const activeItem = e.detail.value;
|
|
139
|
-
if (this.autoSelect) {
|
|
140
|
-
const item = activeItem || this.__previousActiveItem;
|
|
141
|
-
if (item) {
|
|
142
|
-
this.__toggleItem(item);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this.__previousActiveItem = activeItem;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
151
|
/** @private */
|
|
149
152
|
__hasArrayDataProvider() {
|
|
150
153
|
return Array.isArray(this._grid.items) && !!this._grid.dataProvider;
|
|
@@ -130,4 +130,14 @@ export const SelectionMixin = (superClass) =>
|
|
|
130
130
|
*
|
|
131
131
|
* @event selected-items-changed
|
|
132
132
|
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Fired when the user selects or deselects an item through the selection column.
|
|
136
|
+
*
|
|
137
|
+
* @event item-toggle
|
|
138
|
+
* @param {Object} detail
|
|
139
|
+
* @param {GridItem} detail.item the item that was selected or deselected
|
|
140
|
+
* @param {boolean} detail.selected true if the item was selected
|
|
141
|
+
* @param {boolean} detail.shiftKey true if the shift key was pressed
|
|
142
|
+
*/
|
|
133
143
|
};
|
|
@@ -239,7 +239,6 @@ export const gridStyles = css`
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
:host([reordering]) {
|
|
242
|
-
-moz-user-select: none;
|
|
243
242
|
-webkit-user-select: none;
|
|
244
243
|
user-select: none;
|
|
245
244
|
}
|
|
@@ -293,9 +292,8 @@ export const gridStyles = css`
|
|
|
293
292
|
display: none;
|
|
294
293
|
}
|
|
295
294
|
|
|
296
|
-
#scroller[column-resizing]
|
|
297
|
-
|
|
298
|
-
-moz-user-select: none;
|
|
295
|
+
#scroller[column-resizing],
|
|
296
|
+
#scroller[range-selecting] {
|
|
299
297
|
-webkit-user-select: none;
|
|
300
298
|
user-select: none;
|
|
301
299
|
}
|
|
@@ -53,7 +53,7 @@ registerStyles(
|
|
|
53
53
|
|
|
54
54
|
#level-spacer {
|
|
55
55
|
display: inline-block;
|
|
56
|
-
width: calc(var(
|
|
56
|
+
width: calc(var(--_level, '0') * var(--vaadin-grid-tree-toggle-level-offset));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
[part='toggle']::before {
|
|
@@ -146,6 +146,6 @@ export const GridTreeToggleMixin = (superClass) =>
|
|
|
146
146
|
/** @private */
|
|
147
147
|
_levelChanged(level) {
|
|
148
148
|
const value = Number(level).toString();
|
|
149
|
-
this.style.setProperty('
|
|
149
|
+
this.style.setProperty('--_level', value);
|
|
150
150
|
}
|
|
151
151
|
};
|
package/src/vaadin-grid.d.ts
CHANGED
|
@@ -256,6 +256,7 @@ export type GridDefaultItem = any;
|
|
|
256
256
|
* @fires {CustomEvent} loading-changed - Fired when the `loading` property changes.
|
|
257
257
|
* @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
|
|
258
258
|
* @fires {CustomEvent} size-changed - Fired when the `size` property changes.
|
|
259
|
+
* @fires {CustomEvent} item-toggle - Fired when the user selects or deselects an item through the selection column.
|
|
259
260
|
*/
|
|
260
261
|
declare class Grid<TItem = GridDefaultItem> extends HTMLElement {
|
|
261
262
|
addEventListener<K extends keyof GridEventMap<TItem>>(
|
package/src/vaadin-grid.js
CHANGED
|
@@ -274,7 +274,7 @@ class Grid extends GridMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerE
|
|
|
274
274
|
column-reordering-allowed$="[[columnReorderingAllowed]]"
|
|
275
275
|
empty-state$="[[__emptyState]]"
|
|
276
276
|
>
|
|
277
|
-
<table id="table" role="treegrid" aria-multiselectable="true" tabindex="0">
|
|
277
|
+
<table id="table" role="treegrid" aria-multiselectable="true" tabindex="0" aria-label$="[[accessibleName]]">
|
|
278
278
|
<caption id="sizer" part="row"></caption>
|
|
279
279
|
<thead id="header" role="rowgroup"></thead>
|
|
280
280
|
<tbody id="items" role="rowgroup"></tbody>
|
package/src/vaadin-lit-grid.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-lit-grid-column.js';
|
|
7
7
|
import { html, LitElement } from 'lit';
|
|
8
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
8
9
|
import { isIOS, isSafari } from '@vaadin/component-base/src/browser-utils.js';
|
|
9
10
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
@@ -42,7 +43,13 @@ class Grid extends GridMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)
|
|
|
42
43
|
column-reordering-allowed="${this.columnReorderingAllowed}"
|
|
43
44
|
?empty-state="${this.__emptyState}"
|
|
44
45
|
>
|
|
45
|
-
<table
|
|
46
|
+
<table
|
|
47
|
+
id="table"
|
|
48
|
+
role="treegrid"
|
|
49
|
+
aria-multiselectable="true"
|
|
50
|
+
tabindex="0"
|
|
51
|
+
aria-label="${ifDefined(this.accessibleName)}"
|
|
52
|
+
>
|
|
46
53
|
<caption id="sizer" part="row"></caption>
|
|
47
54
|
<thead id="header" role="rowgroup"></thead>
|
|
48
55
|
<tbody id="items" role="rowgroup"></tbody>
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/grid",
|
|
4
|
-
"version": "24.
|
|
4
|
+
"version": "24.7.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
"name": "vaadin-grid-column",
|
|
241
|
-
"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.
|
|
241
|
+
"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.7.0-alpha1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
|
|
242
242
|
"attributes": [
|
|
243
243
|
{
|
|
244
244
|
"name": "resizable",
|
|
@@ -951,7 +951,7 @@
|
|
|
951
951
|
},
|
|
952
952
|
{
|
|
953
953
|
"name": "vaadin-grid-selection-column",
|
|
954
|
-
"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.
|
|
954
|
+
"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.7.0-alpha1/#/elements/vaadin-grid#property-items),\nthe column header gets an additional checkbox that can be used for toggling\nselection for all the items at once.\n\n__The default content can also be overridden__",
|
|
955
955
|
"attributes": [
|
|
956
956
|
{
|
|
957
957
|
"name": "resizable",
|
|
@@ -2152,8 +2152,19 @@
|
|
|
2152
2152
|
},
|
|
2153
2153
|
{
|
|
2154
2154
|
"name": "vaadin-grid",
|
|
2155
|
-
"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.6.0-beta1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/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.6.0-beta1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/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.6.0-beta1/#/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.6.0-beta1/#/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`body-row` | Body row in the internal table\n`collapsed-row` | Collapsed row\n`expanded-row` | Expanded row\n`selected-row` | Selected row\n`nonselectable-row` | Row that the user may not select or deselect\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`nonselectable-row-cell` | Cell in a row that the user may not select or deselect\n`collapsed-row-cell` | Cell in a collapsed 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 the ghost image row, but not in a source row\n`drag-source-row-cell` | Cell in a source row, but not in the ghost image\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`empty-state` | The container for the content to be displayed when there are no body rows to show\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/styling-components) documentation.",
|
|
2155
|
+
"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.7.0-alpha1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------------|----------------\n`row` | Row in the internal table\n`body-row` | Body row in the internal table\n`collapsed-row` | Collapsed row\n`expanded-row` | Expanded row\n`selected-row` | Selected row\n`nonselectable-row` | Row that the user may not select or deselect\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`nonselectable-row-cell` | Cell in a row that the user may not select or deselect\n`collapsed-row-cell` | Cell in a collapsed 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 the ghost image row, but not in a source row\n`drag-source-row-cell` | Cell in a source row, but not in the ghost image\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`empty-state` | The container for the content to be displayed when there are no body rows to show\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/styling-components) documentation.",
|
|
2156
2156
|
"attributes": [
|
|
2157
|
+
{
|
|
2158
|
+
"name": "accessible-name",
|
|
2159
|
+
"description": "String used to label the grid to screen reader users.",
|
|
2160
|
+
"value": {
|
|
2161
|
+
"type": [
|
|
2162
|
+
"string",
|
|
2163
|
+
"null",
|
|
2164
|
+
"undefined"
|
|
2165
|
+
]
|
|
2166
|
+
}
|
|
2167
|
+
},
|
|
2157
2168
|
{
|
|
2158
2169
|
"name": "size",
|
|
2159
2170
|
"description": "The number of root-level items in the grid.",
|
|
@@ -2286,6 +2297,17 @@
|
|
|
2286
2297
|
],
|
|
2287
2298
|
"js": {
|
|
2288
2299
|
"properties": [
|
|
2300
|
+
{
|
|
2301
|
+
"name": "accessibleName",
|
|
2302
|
+
"description": "String used to label the grid to screen reader users.",
|
|
2303
|
+
"value": {
|
|
2304
|
+
"type": [
|
|
2305
|
+
"string",
|
|
2306
|
+
"null",
|
|
2307
|
+
"undefined"
|
|
2308
|
+
]
|
|
2309
|
+
}
|
|
2310
|
+
},
|
|
2289
2311
|
{
|
|
2290
2312
|
"name": "activeItem",
|
|
2291
2313
|
"description": "The item user has last interacted with. Turns to `null` after user deactivates\nthe item by re-interacting with the currently active item.",
|
|
@@ -2549,6 +2571,10 @@
|
|
|
2549
2571
|
"name": "loading-changed",
|
|
2550
2572
|
"description": "Fired when the `loading` property changes."
|
|
2551
2573
|
},
|
|
2574
|
+
{
|
|
2575
|
+
"name": "item-toggle",
|
|
2576
|
+
"description": "Fired when the user selects or deselects an item through the selection column."
|
|
2577
|
+
},
|
|
2552
2578
|
{
|
|
2553
2579
|
"name": "selected-items-changed",
|
|
2554
2580
|
"description": "Fired when the `selectedItems` property changes."
|
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": "24.
|
|
4
|
+
"version": "24.7.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"name": "vaadin-grid-column",
|
|
103
|
-
"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.
|
|
103
|
+
"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.7.0-alpha1/#/elements/vaadin-grid) documentation for instructions on how\nto configure the `<vaadin-grid-column>`.",
|
|
104
104
|
"extension": true,
|
|
105
105
|
"attributes": [
|
|
106
106
|
{
|
|
@@ -366,7 +366,7 @@
|
|
|
366
366
|
},
|
|
367
367
|
{
|
|
368
368
|
"name": "vaadin-grid-selection-column",
|
|
369
|
-
"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.
|
|
369
|
+
"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.7.0-alpha1/#/elements/vaadin-grid#property-items),\nthe column header gets an additional checkbox that can be used for toggling\nselection for all the items at once.\n\n__The default content can also be overridden__",
|
|
370
370
|
"extension": true,
|
|
371
371
|
"attributes": [
|
|
372
372
|
{
|
|
@@ -828,7 +828,7 @@
|
|
|
828
828
|
},
|
|
829
829
|
{
|
|
830
830
|
"name": "vaadin-grid",
|
|
831
|
-
"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.6.0-beta1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/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.6.0-beta1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.6.0-beta1/#/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.6.0-beta1/#/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.6.0-beta1/#/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`body-row` | Body row in the internal table\n`collapsed-row` | Collapsed row\n`expanded-row` | Expanded row\n`selected-row` | Selected row\n`nonselectable-row` | Row that the user may not select or deselect\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`nonselectable-row-cell` | Cell in a row that the user may not select or deselect\n`collapsed-row-cell` | Cell in a collapsed 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 the ghost image row, but not in a source row\n`drag-source-row-cell` | Cell in a source row, but not in the ghost image\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`empty-state` | The container for the content to be displayed when there are no body rows to show\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/styling-components) documentation.",
|
|
831
|
+
"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.7.0-alpha1/#/elements/vaadin-grid#property-items) property to visualize your data.\n\nUse the [`<vaadin-grid-column>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-column) element to configure the grid columns. Set `path` and `header`\nshorthand properties for the columns to define what gets rendered in the cells of the column.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column path=\"name.first\" header=\"First name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"name.last\" header=\"Last name\"></vaadin-grid-column>\n <vaadin-grid-column path=\"email\"></vaadin-grid-column>\n</vaadin-grid>\n```\n\nFor custom content `vaadin-grid-column` element provides you with three types of `renderer` callback functions: `headerRenderer`,\n`renderer` and `footerRenderer`.\n\nEach of those renderer functions provides `root`, `column`, `model` arguments when applicable.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `column`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\nRenderers are called on initialization of new column cells and each time the\nrelated row model is updated. DOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n#### Example:\n```html\n<vaadin-grid>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n <vaadin-grid-column></vaadin-grid-column>\n</vaadin-grid>\n```\n```js\nconst grid = document.querySelector('vaadin-grid');\ngrid.items = [{'name': 'John', 'surname': 'Lennon', 'role': 'singer'},\n {'name': 'Ringo', 'surname': 'Starr', 'role': 'drums'}];\n\nconst columns = grid.querySelectorAll('vaadin-grid-column');\n\ncolumns[0].headerRenderer = function(root) {\n root.textContent = 'Name';\n};\ncolumns[0].renderer = function(root, column, model) {\n root.textContent = model.item.name;\n};\n\ncolumns[1].headerRenderer = function(root) {\n root.textContent = 'Surname';\n};\ncolumns[1].renderer = function(root, column, model) {\n root.textContent = model.item.surname;\n};\n\ncolumns[2].headerRenderer = function(root) {\n root.textContent = 'Role';\n};\ncolumns[2].renderer = function(root, column, model) {\n root.textContent = model.item.role;\n};\n```\n\nThe following properties are available in the `model` argument:\n\nProperty name | Type | Description\n--------------|------|------------\n`index`| Number | The index of the item.\n`item` | String or Object | The item.\n`level` | Number | Number of the item's tree sublevel, starts from 0.\n`expanded` | Boolean | True if the item's tree sublevel is expanded.\n`selected` | Boolean | True if the item is selected.\n`detailsOpened` | Boolean | True if the item's row details are open.\n\nThe following helper elements can be used for further customization:\n- [`<vaadin-grid-column-group>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-column-group)\n- [`<vaadin-grid-filter>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-filter)\n- [`<vaadin-grid-sorter>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-sorter)\n- [`<vaadin-grid-selection-column>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-selection-column)\n- [`<vaadin-grid-tree-toggle>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid-tree-toggle)\n\n__Note that the helper elements must be explicitly imported.__\nIf you want to import everything at once you can use the `all-imports.html` bundle.\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively\nprovide the `<vaadin-grid>` data through the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid#property-dataProvider) function property.\nThe `<vaadin-grid>` calls this function lazily, only when it needs more data\nto be displayed.\n\nSee the [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha1/#/elements/vaadin-grid#property-dataProvider) property\ndocumentation for the detailed data provider arguments description.\n\n__Note that expanding the tree grid's item will trigger a call to the `dataProvider`.__\n\n__Also, note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```javascript\ngrid.dataProvider = ({page, pageSize}, callback) => {\n // page: the requested page index\n // pageSize: number of items on one page\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then(({ employees, totalSize }) => {\n callback(employees, totalSize);\n });\n};\n```\n\n__Alternatively, you can use the `size` property to set the total number of items:__\n\n```javascript\ngrid.size = 200; // The total number of items\ngrid.dataProvider = ({page, pageSize}, callback) => {\n const url = `https://api.example/data?page=${page}&per_page=${pageSize}`;\n\n fetch(url)\n .then((res) => res.json())\n .then((resJson) => callback(resJson.employees));\n};\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------------|----------------\n`row` | Row in the internal table\n`body-row` | Body row in the internal table\n`collapsed-row` | Collapsed row\n`expanded-row` | Expanded row\n`selected-row` | Selected row\n`nonselectable-row` | Row that the user may not select or deselect\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`nonselectable-row-cell` | Cell in a row that the user may not select or deselect\n`collapsed-row-cell` | Cell in a collapsed 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 the ghost image row, but not in a source row\n`drag-source-row-cell` | Cell in a source row, but not in the ghost image\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`empty-state` | The container for the content to be displayed when there are no body rows to show\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/styling-components) documentation.",
|
|
832
832
|
"extension": true,
|
|
833
833
|
"attributes": [
|
|
834
834
|
{
|
|
@@ -866,6 +866,13 @@
|
|
|
866
866
|
"kind": "expression"
|
|
867
867
|
}
|
|
868
868
|
},
|
|
869
|
+
{
|
|
870
|
+
"name": ".accessibleName",
|
|
871
|
+
"description": "String used to label the grid to screen reader users.",
|
|
872
|
+
"value": {
|
|
873
|
+
"kind": "expression"
|
|
874
|
+
}
|
|
875
|
+
},
|
|
869
876
|
{
|
|
870
877
|
"name": ".activeItem",
|
|
871
878
|
"description": "The item user has last interacted with. Turns to `null` after user deactivates\nthe item by re-interacting with the currently active item.",
|
|
@@ -1034,6 +1041,13 @@
|
|
|
1034
1041
|
"kind": "expression"
|
|
1035
1042
|
}
|
|
1036
1043
|
},
|
|
1044
|
+
{
|
|
1045
|
+
"name": "@item-toggle",
|
|
1046
|
+
"description": "Fired when the user selects or deselects an item through the selection column.",
|
|
1047
|
+
"value": {
|
|
1048
|
+
"kind": "expression"
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1037
1051
|
{
|
|
1038
1052
|
"name": "@selected-items-changed",
|
|
1039
1053
|
"description": "Fired when the `selectedItems` property changes.",
|