@vaadin/vaadin-grid 21.0.3 → 21.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/vaadin-grid",
3
- "version": "21.0.3",
3
+ "version": "21.0.4",
4
4
  "description": "A free, flexible and high-quality Web Component for showing large amounts of tabular data",
5
5
  "main": "vaadin-grid.js",
6
6
  "module": "vaadin-grid.js",
@@ -32,23 +32,23 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/vaadin-checkbox": "^21.0.3",
36
- "@vaadin/vaadin-element-mixin": "^21.0.3",
37
- "@vaadin/vaadin-lumo-styles": "^21.0.3",
38
- "@vaadin/vaadin-material-styles": "^21.0.3",
39
- "@vaadin/vaadin-text-field": "^21.0.3",
40
- "@vaadin/vaadin-themable-mixin": "^21.0.3",
41
- "@vaadin/vaadin-virtual-list": "^21.0.3"
35
+ "@vaadin/vaadin-checkbox": "^21.0.4",
36
+ "@vaadin/vaadin-element-mixin": "^21.0.4",
37
+ "@vaadin/vaadin-lumo-styles": "^21.0.4",
38
+ "@vaadin/vaadin-material-styles": "^21.0.4",
39
+ "@vaadin/vaadin-text-field": "^21.0.4",
40
+ "@vaadin/vaadin-themable-mixin": "^21.0.4",
41
+ "@vaadin/vaadin-virtual-list": "^21.0.4"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@esm-bundle/chai": "^4.1.5",
45
45
  "@vaadin/testing-helpers": "^0.2.1",
46
- "@vaadin/vaadin-template-renderer": "^21.0.3",
46
+ "@vaadin/vaadin-template-renderer": "^21.0.4",
47
47
  "lit": "^2.0.0",
48
48
  "sinon": "^9.2.0"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "f2b0583ef776e6c52a74da7540b06bfd2d9adf1b"
53
+ "gitHead": "5bcf4893e594a60701c723f5c9157ad6ac694baf"
54
54
  }
@@ -85,7 +85,7 @@ export const DragAndDropMixin = (superClass) =>
85
85
  }
86
86
 
87
87
  static get observers() {
88
- return ['_dragDropAccessChanged(rowsDraggable, dropMode, dragFilter, dropFilter)'];
88
+ return ['_dragDropAccessChanged(rowsDraggable, dropMode, dragFilter, dropFilter, loading)'];
89
89
  }
90
90
 
91
91
  /** @protected */
@@ -376,8 +376,9 @@ export const DragAndDropMixin = (superClass) =>
376
376
  * @protected
377
377
  */
378
378
  _filterDragAndDrop(row, model) {
379
- const dragDisabled = !this.rowsDraggable || (this.dragFilter && !this.dragFilter(model));
380
- const dropDisabled = !this.dropMode || (this.dropFilter && !this.dropFilter(model));
379
+ const loading = this.loading || row.hasAttribute('loading');
380
+ const dragDisabled = !this.rowsDraggable || loading || (this.dragFilter && !this.dragFilter(model));
381
+ const dropDisabled = !this.dropMode || loading || (this.dropFilter && !this.dropFilter(model));
381
382
 
382
383
  const draggableElements = Array.from(row.children).map((cell) => cell._content);
383
384
 
@@ -184,7 +184,11 @@ class GridSelectionColumnElement extends GridColumnElement {
184
184
  return;
185
185
  }
186
186
 
187
- this._grid.selectedItems = selectAll && Array.isArray(this._grid.items) ? this.__getRootLevelItems() : [];
187
+ if (selectAll && Array.isArray(this._grid.items)) {
188
+ this.__withFilteredItemsArray((items) => (this._grid.selectedItems = items));
189
+ } else {
190
+ this._grid.selectedItems = [];
191
+ }
188
192
  }
189
193
 
190
194
  /**
@@ -251,26 +255,22 @@ class GridSelectionColumnElement extends GridColumnElement {
251
255
  this.__previousActiveItem = activeItem;
252
256
  }
253
257
 
254
- /** @private */
255
- __getRootLevelItems() {
256
- const rootCache = this._grid._cache;
257
- return [...Array(rootCache.size)].map((_, idx) => rootCache.items[idx]);
258
- }
259
-
260
258
  /** @private */
261
259
  __onSelectedItemsChanged() {
262
260
  this._selectAllChangeLock = true;
263
261
  if (Array.isArray(this._grid.items)) {
264
- if (!this._grid.selectedItems.length) {
265
- this.selectAll = false;
266
- this.__indeterminate = false;
267
- } else if (this.__arrayContains(this._grid.selectedItems, this.__getRootLevelItems())) {
268
- this.selectAll = true;
269
- this.__indeterminate = false;
270
- } else {
271
- this.selectAll = false;
272
- this.__indeterminate = true;
273
- }
262
+ this.__withFilteredItemsArray((items) => {
263
+ if (!this._grid.selectedItems.length) {
264
+ this.selectAll = false;
265
+ this.__indeterminate = false;
266
+ } else if (this.__arrayContains(this._grid.selectedItems, items)) {
267
+ this.selectAll = true;
268
+ this.__indeterminate = false;
269
+ } else {
270
+ this.selectAll = false;
271
+ this.__indeterminate = true;
272
+ }
273
+ });
274
274
  }
275
275
  this._selectAllChangeLock = false;
276
276
  }
@@ -279,6 +279,22 @@ class GridSelectionColumnElement extends GridColumnElement {
279
279
  __onDataProviderChanged() {
280
280
  this.__selectAllHidden = !Array.isArray(this._grid.items);
281
281
  }
282
+
283
+ /**
284
+ * Assuming the grid uses an items array data provider, fetches all the filtered items
285
+ * from the data provider and invokes the callback with the resulting array.
286
+ *
287
+ * @private
288
+ */
289
+ __withFilteredItemsArray(callback) {
290
+ const params = {
291
+ page: 0,
292
+ pageSize: Infinity,
293
+ sortOrders: [],
294
+ filters: this._grid._mapFilters()
295
+ };
296
+ this._grid.dataProvider(params, (items) => callback(items));
297
+ }
282
298
  }
283
299
 
284
300
  customElements.define(GridSelectionColumnElement.is, GridSelectionColumnElement);
@@ -317,7 +317,7 @@ class GridElement extends ElementMixin(
317
317
  }
318
318
 
319
319
  static get version() {
320
- return '21.0.3';
320
+ return '21.0.4';
321
321
  }
322
322
 
323
323
  static get observers() {