@vaadin/grid 24.1.5 → 24.2.0-alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/vaadin-grid-column.d.ts +11 -0
- package/src/vaadin-grid-column.js +29 -1
- package/src/vaadin-grid-data-provider-mixin.js +6 -5
- package/src/vaadin-grid-keyboard-navigation-mixin.js +3 -2
- package/src/vaadin-grid-selection-column-base-mixin.d.ts +63 -0
- package/src/vaadin-grid-selection-column-base-mixin.js +342 -0
- package/src/vaadin-grid-selection-column.d.ts +3 -12
- package/src/vaadin-grid-selection-column.js +39 -122
- package/src/vaadin-grid-styles.js +2 -8
- package/src/vaadin-grid-tree-column.js +2 -1
- package/src/vaadin-grid.js +5 -5
- package/theme/lumo/vaadin-grid-styles.js +3 -12
- package/theme/material/vaadin-grid-styles.js +4 -16
- package/web-types.json +106 -195
- package/web-types.lit.json +41 -76
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/checkbox/src/vaadin-checkbox.js';
|
|
7
7
|
import { GridColumn } from './vaadin-grid-column.js';
|
|
8
|
+
import { GridSelectionColumnBaseMixin } from './vaadin-grid-selection-column-base-mixin.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* `<vaadin-grid-selection-column>` is a helper element for the `<vaadin-grid>`
|
|
@@ -28,74 +29,27 @@ import { GridColumn } from './vaadin-grid-column.js';
|
|
|
28
29
|
*
|
|
29
30
|
* __The default content can also be overridden__
|
|
30
31
|
*
|
|
32
|
+
* @mixes GridSelectionColumnBaseMixin
|
|
31
33
|
* @fires {CustomEvent} select-all-changed - Fired when the `selectAll` property changes.
|
|
32
34
|
*/
|
|
33
|
-
class GridSelectionColumn extends GridColumn {
|
|
35
|
+
class GridSelectionColumn extends GridSelectionColumnBaseMixin(GridColumn) {
|
|
34
36
|
static get is() {
|
|
35
37
|
return 'vaadin-grid-selection-column';
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
static get properties() {
|
|
39
41
|
return {
|
|
40
|
-
/**
|
|
41
|
-
* Width of the cells for this column.
|
|
42
|
-
*/
|
|
43
|
-
width: {
|
|
44
|
-
type: String,
|
|
45
|
-
value: '58px',
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Flex grow ratio for the cell widths. When set to 0, cell width is fixed.
|
|
50
|
-
* @attr {number} flex-grow
|
|
51
|
-
* @type {number}
|
|
52
|
-
*/
|
|
53
|
-
flexGrow: {
|
|
54
|
-
type: Number,
|
|
55
|
-
value: 0,
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* When true, all the items are selected.
|
|
60
|
-
* @attr {boolean} select-all
|
|
61
|
-
* @type {boolean}
|
|
62
|
-
*/
|
|
63
|
-
selectAll: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
value: false,
|
|
66
|
-
notify: true,
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* When true, the active gets automatically selected.
|
|
71
|
-
* @attr {boolean} auto-select
|
|
72
|
-
* @type {boolean}
|
|
73
|
-
*/
|
|
74
|
-
autoSelect: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
value: false,
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
/** @private */
|
|
80
|
-
__indeterminate: Boolean,
|
|
81
|
-
|
|
82
42
|
/**
|
|
83
43
|
* The previous state of activeItem. When activeItem turns to `null`,
|
|
84
44
|
* previousActiveItem will have an Object with just unselected activeItem
|
|
85
45
|
* @private
|
|
86
46
|
*/
|
|
87
47
|
__previousActiveItem: Object,
|
|
88
|
-
|
|
89
|
-
/** @private */
|
|
90
|
-
__selectAllHidden: Boolean,
|
|
91
48
|
};
|
|
92
49
|
}
|
|
93
50
|
|
|
94
51
|
static get observers() {
|
|
95
|
-
return [
|
|
96
|
-
'__onSelectAllChanged(selectAll)',
|
|
97
|
-
'_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header, selectAll, __indeterminate, __selectAllHidden)',
|
|
98
|
-
];
|
|
52
|
+
return ['__onSelectAllChanged(selectAll)'];
|
|
99
53
|
}
|
|
100
54
|
|
|
101
55
|
constructor() {
|
|
@@ -127,47 +81,6 @@ class GridSelectionColumn extends GridColumn {
|
|
|
127
81
|
}
|
|
128
82
|
}
|
|
129
83
|
|
|
130
|
-
/**
|
|
131
|
-
* Renders the Select All checkbox to the header cell.
|
|
132
|
-
*
|
|
133
|
-
* @override
|
|
134
|
-
*/
|
|
135
|
-
_defaultHeaderRenderer(root, _column) {
|
|
136
|
-
let checkbox = root.firstElementChild;
|
|
137
|
-
if (!checkbox) {
|
|
138
|
-
checkbox = document.createElement('vaadin-checkbox');
|
|
139
|
-
checkbox.setAttribute('aria-label', 'Select All');
|
|
140
|
-
checkbox.classList.add('vaadin-grid-select-all-checkbox');
|
|
141
|
-
checkbox.addEventListener('checked-changed', this.__onSelectAllCheckedChanged.bind(this));
|
|
142
|
-
root.appendChild(checkbox);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const checked = this.__isChecked(this.selectAll, this.__indeterminate);
|
|
146
|
-
checkbox.__rendererChecked = checked;
|
|
147
|
-
checkbox.checked = checked;
|
|
148
|
-
checkbox.hidden = this.__selectAllHidden;
|
|
149
|
-
checkbox.indeterminate = this.__indeterminate;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Renders the Select Row checkbox to the body cell.
|
|
154
|
-
*
|
|
155
|
-
* @override
|
|
156
|
-
*/
|
|
157
|
-
_defaultRenderer(root, _column, { item, selected }) {
|
|
158
|
-
let checkbox = root.firstElementChild;
|
|
159
|
-
if (!checkbox) {
|
|
160
|
-
checkbox = document.createElement('vaadin-checkbox');
|
|
161
|
-
checkbox.setAttribute('aria-label', 'Select Row');
|
|
162
|
-
checkbox.addEventListener('checked-changed', this.__onSelectRowCheckedChanged.bind(this));
|
|
163
|
-
root.appendChild(checkbox);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
checkbox.__item = item;
|
|
167
|
-
checkbox.__rendererChecked = selected;
|
|
168
|
-
checkbox.checked = selected;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
84
|
/** @private */
|
|
172
85
|
__onSelectAllChanged(selectAll) {
|
|
173
86
|
if (selectAll === undefined || !this._grid) {
|
|
@@ -203,45 +116,49 @@ class GridSelectionColumn extends GridColumn {
|
|
|
203
116
|
}
|
|
204
117
|
|
|
205
118
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
119
|
+
* Override a method from `GridSelectionColumnBaseMixin` to handle the user
|
|
120
|
+
* selecting all items.
|
|
208
121
|
*
|
|
209
|
-
* @
|
|
122
|
+
* @protected
|
|
123
|
+
* @override
|
|
210
124
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (e.target.checked === e.target.__rendererChecked) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
this.selectAll = this.__indeterminate || e.target.checked;
|
|
125
|
+
_selectAll() {
|
|
126
|
+
this.selectAll = true;
|
|
218
127
|
}
|
|
219
128
|
|
|
220
129
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
130
|
+
* Override a method from `GridSelectionColumnBaseMixin` to handle the user
|
|
131
|
+
* deselecting all items.
|
|
223
132
|
*
|
|
224
|
-
* @
|
|
133
|
+
* @protected
|
|
134
|
+
* @override
|
|
225
135
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
136
|
+
_deselectAll() {
|
|
137
|
+
this.selectAll = false;
|
|
138
|
+
}
|
|
231
139
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Override a method from `GridSelectionColumnBaseMixin` to handle the user
|
|
142
|
+
* selecting an item.
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} item the item to select
|
|
145
|
+
* @protected
|
|
146
|
+
* @override
|
|
147
|
+
*/
|
|
148
|
+
_selectItem(item) {
|
|
149
|
+
this._grid.selectItem(item);
|
|
237
150
|
}
|
|
238
151
|
|
|
239
152
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
153
|
+
* Override a method from `GridSelectionColumnBaseMixin` to handle the user
|
|
154
|
+
* deselecting an item.
|
|
155
|
+
*
|
|
156
|
+
* @param {Object} item the item to deselect
|
|
157
|
+
* @protected
|
|
158
|
+
* @override
|
|
242
159
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
160
|
+
_deselectItem(item) {
|
|
161
|
+
this._grid.deselectItem(item);
|
|
245
162
|
}
|
|
246
163
|
|
|
247
164
|
/** @private */
|
|
@@ -268,13 +185,13 @@ class GridSelectionColumn extends GridColumn {
|
|
|
268
185
|
this.__withFilteredItemsArray((items) => {
|
|
269
186
|
if (!this._grid.selectedItems.length) {
|
|
270
187
|
this.selectAll = false;
|
|
271
|
-
this.
|
|
188
|
+
this._indeterminate = false;
|
|
272
189
|
} else if (this.__arrayContains(this._grid.selectedItems, items)) {
|
|
273
190
|
this.selectAll = true;
|
|
274
|
-
this.
|
|
191
|
+
this._indeterminate = false;
|
|
275
192
|
} else {
|
|
276
193
|
this.selectAll = false;
|
|
277
|
-
this.
|
|
194
|
+
this._indeterminate = true;
|
|
278
195
|
}
|
|
279
196
|
});
|
|
280
197
|
}
|
|
@@ -283,7 +200,7 @@ class GridSelectionColumn extends GridColumn {
|
|
|
283
200
|
|
|
284
201
|
/** @private */
|
|
285
202
|
__onDataProviderChanged() {
|
|
286
|
-
this.
|
|
203
|
+
this._selectAllHidden = !Array.isArray(this._grid.items);
|
|
287
204
|
}
|
|
288
205
|
|
|
289
206
|
/**
|
|
@@ -40,10 +40,7 @@ registerStyles(
|
|
|
40
40
|
width: auto;
|
|
41
41
|
height: auto;
|
|
42
42
|
position: absolute;
|
|
43
|
-
|
|
44
|
-
right: 0;
|
|
45
|
-
bottom: 0;
|
|
46
|
-
left: 0;
|
|
43
|
+
inset: 0;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
:host([all-rows-visible]) {
|
|
@@ -154,10 +151,7 @@ registerStyles(
|
|
|
154
151
|
align-items: inherit;
|
|
155
152
|
outline: none;
|
|
156
153
|
position: absolute;
|
|
157
|
-
|
|
158
|
-
bottom: 0;
|
|
159
|
-
left: 0;
|
|
160
|
-
right: 0;
|
|
154
|
+
inset: 0;
|
|
161
155
|
}
|
|
162
156
|
|
|
163
157
|
[part~='details-cell'] {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-grid-tree-toggle.js';
|
|
7
|
+
import { get } from '@vaadin/component-base/src/path-utils.js';
|
|
7
8
|
import { GridColumn } from './vaadin-grid-column.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -101,7 +102,7 @@ class GridTreeColumn extends GridColumn {
|
|
|
101
102
|
|
|
102
103
|
/** @private */
|
|
103
104
|
__getToggleContent(path, item) {
|
|
104
|
-
return path &&
|
|
105
|
+
return path && get(path, item);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
package/src/vaadin-grid.js
CHANGED
|
@@ -470,12 +470,12 @@ class Grid extends ElementMixin(
|
|
|
470
470
|
|
|
471
471
|
/** @private */
|
|
472
472
|
__getFirstVisibleItem() {
|
|
473
|
-
return this.
|
|
473
|
+
return this._getRenderedRows().find((row) => this._isInViewport(row));
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
/** @private */
|
|
477
477
|
__getLastVisibleItem() {
|
|
478
|
-
return this.
|
|
478
|
+
return this._getRenderedRows()
|
|
479
479
|
.reverse()
|
|
480
480
|
.find((row) => this._isInViewport(row));
|
|
481
481
|
}
|
|
@@ -492,7 +492,7 @@ class Grid extends ElementMixin(
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
/** @private */
|
|
495
|
-
|
|
495
|
+
_getRenderedRows() {
|
|
496
496
|
return Array.from(this.$.items.children)
|
|
497
497
|
.filter((item) => !item.hidden)
|
|
498
498
|
.sort((a, b) => a.index - b.index);
|
|
@@ -554,7 +554,7 @@ class Grid extends ElementMixin(
|
|
|
554
554
|
|
|
555
555
|
/** @private */
|
|
556
556
|
__focusBodyCell({ item, column }) {
|
|
557
|
-
const row = this.
|
|
557
|
+
const row = this._getRenderedRows().find((row) => row._item === item);
|
|
558
558
|
const cell = row && [...row.children].find((cell) => cell._column === column);
|
|
559
559
|
if (cell) {
|
|
560
560
|
cell.focus();
|
|
@@ -666,7 +666,7 @@ class Grid extends ElementMixin(
|
|
|
666
666
|
// Cache the viewport rows to avoid unnecessary reflows while measuring the column widths
|
|
667
667
|
const fvi = this._firstVisibleIndex;
|
|
668
668
|
const lvi = this._lastVisibleIndex;
|
|
669
|
-
this.__viewportRowsCache = this.
|
|
669
|
+
this.__viewportRowsCache = this._getRenderedRows().filter((row) => row.index >= fvi && row.index <= lvi);
|
|
670
670
|
|
|
671
671
|
// Pre-cache the intrinsic width of each column
|
|
672
672
|
this.__calculateAndCacheIntrinsicWidths(cols);
|
|
@@ -77,10 +77,7 @@ registerStyles(
|
|
|
77
77
|
:host([navigating]) [part~='focused-cell']:focus::before {
|
|
78
78
|
content: '';
|
|
79
79
|
position: absolute;
|
|
80
|
-
|
|
81
|
-
right: 0;
|
|
82
|
-
bottom: 0;
|
|
83
|
-
left: 0;
|
|
80
|
+
inset: 0;
|
|
84
81
|
pointer-events: none;
|
|
85
82
|
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
86
83
|
}
|
|
@@ -95,10 +92,7 @@ registerStyles(
|
|
|
95
92
|
content: '';
|
|
96
93
|
position: absolute;
|
|
97
94
|
z-index: 100;
|
|
98
|
-
|
|
99
|
-
right: 0;
|
|
100
|
-
bottom: 0;
|
|
101
|
-
left: 0;
|
|
95
|
+
inset: 0;
|
|
102
96
|
pointer-events: none;
|
|
103
97
|
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
104
98
|
}
|
|
@@ -114,10 +108,7 @@ registerStyles(
|
|
|
114
108
|
[part~='row'][dragover] [part~='cell']::after {
|
|
115
109
|
content: '';
|
|
116
110
|
position: absolute;
|
|
117
|
-
|
|
118
|
-
right: 0;
|
|
119
|
-
bottom: 0;
|
|
120
|
-
left: 0;
|
|
111
|
+
inset: 0;
|
|
121
112
|
height: calc(var(--_lumo-grid-border-width) + 2px);
|
|
122
113
|
pointer-events: none;
|
|
123
114
|
background: var(--lumo-primary-color-50pct);
|
|
@@ -76,10 +76,7 @@ registerStyles(
|
|
|
76
76
|
content: '';
|
|
77
77
|
pointer-events: none;
|
|
78
78
|
position: absolute;
|
|
79
|
-
|
|
80
|
-
right: 0;
|
|
81
|
-
bottom: 0;
|
|
82
|
-
left: 0;
|
|
79
|
+
inset: 0;
|
|
83
80
|
background-color: var(--material-primary-color);
|
|
84
81
|
opacity: 0;
|
|
85
82
|
transition: opacity 0.1s cubic-bezier(0.4, 0, 0.2, 0.1);
|
|
@@ -143,10 +140,7 @@ registerStyles(
|
|
|
143
140
|
:host([navigating]) [part~='row']:focus::before {
|
|
144
141
|
content: '';
|
|
145
142
|
position: absolute;
|
|
146
|
-
|
|
147
|
-
right: 0;
|
|
148
|
-
bottom: 0;
|
|
149
|
-
left: 0;
|
|
143
|
+
inset: 0;
|
|
150
144
|
pointer-events: none;
|
|
151
145
|
transform: translateX(calc(-1 * var(--_grid-horizontal-scroll-position)));
|
|
152
146
|
z-index: 3;
|
|
@@ -157,10 +151,7 @@ registerStyles(
|
|
|
157
151
|
content: '';
|
|
158
152
|
position: absolute;
|
|
159
153
|
z-index: 100;
|
|
160
|
-
|
|
161
|
-
right: 0;
|
|
162
|
-
bottom: 0;
|
|
163
|
-
left: 0;
|
|
154
|
+
inset: 0;
|
|
164
155
|
pointer-events: none;
|
|
165
156
|
box-shadow: inset 0 0 0 2px var(--material-primary-color);
|
|
166
157
|
}
|
|
@@ -176,10 +167,7 @@ registerStyles(
|
|
|
176
167
|
[part~='row'][dragover] [part~='cell']::after {
|
|
177
168
|
content: '';
|
|
178
169
|
position: absolute;
|
|
179
|
-
|
|
180
|
-
right: 0;
|
|
181
|
-
bottom: 0;
|
|
182
|
-
left: 0;
|
|
170
|
+
inset: 0;
|
|
183
171
|
height: 3px;
|
|
184
172
|
pointer-events: none;
|
|
185
173
|
background: var(--material-primary-color);
|