@vaadin/grid 23.2.0-alpha2 → 23.2.0-alpha3

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.
Files changed (31) hide show
  1. package/package.json +10 -10
  2. package/src/lit/column-renderer-directives.d.ts +6 -5
  3. package/src/lit/renderer-directives.d.ts +3 -3
  4. package/src/vaadin-grid-active-item-mixin.d.ts +1 -1
  5. package/src/vaadin-grid-array-data-provider-mixin.d.ts +1 -1
  6. package/src/vaadin-grid-column-group.d.ts +2 -2
  7. package/src/vaadin-grid-column-group.js +22 -7
  8. package/src/vaadin-grid-column-reordering-mixin.d.ts +1 -1
  9. package/src/vaadin-grid-column-reordering-mixin.js +9 -3
  10. package/src/vaadin-grid-column.d.ts +2 -2
  11. package/src/vaadin-grid-column.js +9 -3
  12. package/src/vaadin-grid-data-provider-mixin.d.ts +1 -1
  13. package/src/vaadin-grid-drag-and-drop-mixin.d.ts +2 -2
  14. package/src/vaadin-grid-drag-and-drop-mixin.js +3 -1
  15. package/src/vaadin-grid-event-context-mixin.d.ts +2 -2
  16. package/src/vaadin-grid-filter-column.d.ts +1 -1
  17. package/src/vaadin-grid-keyboard-navigation-mixin.js +10 -6
  18. package/src/vaadin-grid-row-details-mixin.d.ts +2 -2
  19. package/src/vaadin-grid-scroll-mixin.d.ts +1 -1
  20. package/src/vaadin-grid-scroll-mixin.js +3 -1
  21. package/src/vaadin-grid-selection-column.d.ts +1 -1
  22. package/src/vaadin-grid-selection-column.js +3 -1
  23. package/src/vaadin-grid-selection-mixin.d.ts +1 -1
  24. package/src/vaadin-grid-sort-column.d.ts +2 -2
  25. package/src/vaadin-grid-sort-mixin.d.ts +17 -1
  26. package/src/vaadin-grid-sort-mixin.js +47 -5
  27. package/src/vaadin-grid-sorter.js +4 -0
  28. package/src/vaadin-grid-styling-mixin.d.ts +3 -3
  29. package/src/vaadin-grid-tree-column.d.ts +1 -1
  30. package/src/vaadin-grid.d.ts +20 -20
  31. package/src/vaadin-grid.js +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid",
3
- "version": "23.2.0-alpha2",
3
+ "version": "23.2.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,20 +43,20 @@
43
43
  "dependencies": {
44
44
  "@open-wc/dedupe-mixin": "^1.3.0",
45
45
  "@polymer/polymer": "^3.0.0",
46
- "@vaadin/checkbox": "23.2.0-alpha2",
47
- "@vaadin/component-base": "23.2.0-alpha2",
48
- "@vaadin/lit-renderer": "23.2.0-alpha2",
49
- "@vaadin/text-field": "23.2.0-alpha2",
50
- "@vaadin/vaadin-lumo-styles": "23.2.0-alpha2",
51
- "@vaadin/vaadin-material-styles": "23.2.0-alpha2",
52
- "@vaadin/vaadin-themable-mixin": "23.2.0-alpha2"
46
+ "@vaadin/checkbox": "23.2.0-alpha3",
47
+ "@vaadin/component-base": "23.2.0-alpha3",
48
+ "@vaadin/lit-renderer": "23.2.0-alpha3",
49
+ "@vaadin/text-field": "23.2.0-alpha3",
50
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha3",
51
+ "@vaadin/vaadin-material-styles": "23.2.0-alpha3",
52
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha3"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@esm-bundle/chai": "^4.3.4",
56
- "@vaadin/polymer-legacy-adapter": "23.2.0-alpha2",
56
+ "@vaadin/polymer-legacy-adapter": "23.2.0-alpha3",
57
57
  "@vaadin/testing-helpers": "^0.3.2",
58
58
  "lit": "^2.0.0",
59
59
  "sinon": "^13.0.2"
60
60
  },
61
- "gitHead": "c9b8113d0fa9a602f8b9cb915c1826355af2e8df"
61
+ "gitHead": "06e5875be93ca50da2846dafc65a8531010c0576"
62
62
  }
@@ -4,11 +4,12 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  /* eslint-disable max-classes-per-file */
7
- import { TemplateResult } from 'lit';
8
- import { DirectiveResult } from 'lit/directive';
9
- import { LitRenderer, LitRendererDirective } from '@vaadin/lit-renderer';
10
- import { GridItemModel } from '../vaadin-grid.js';
11
- import { GridColumn } from '../vaadin-grid-column.js';
7
+ import type { TemplateResult } from 'lit';
8
+ import type { DirectiveResult } from 'lit/directive';
9
+ import type { LitRenderer } from '@vaadin/lit-renderer';
10
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
11
+ import type { GridItemModel } from '../vaadin-grid.js';
12
+ import type { GridColumn } from '../vaadin-grid-column.js';
12
13
 
13
14
  export type GridColumnBodyLitRenderer<TItem> = (
14
15
  item: TItem,
@@ -3,10 +3,10 @@
3
3
  * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { TemplateResult } from 'lit';
7
- import { DirectiveResult } from 'lit/directive';
6
+ import type { TemplateResult } from 'lit';
7
+ import type { DirectiveResult } from 'lit/directive';
8
8
  import { LitRendererDirective } from '@vaadin/lit-renderer';
9
- import { Grid, GridItemModel } from '../vaadin-grid.js';
9
+ import type { Grid, GridItemModel } from '../vaadin-grid.js';
10
10
 
11
11
  export type GridRowDetailsLitRenderer<TItem> = (item: TItem, model: GridItemModel<TItem>, grid: Grid) => TemplateResult;
12
12
 
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ActiveItemMixin<TItem, T extends Constructor<HTMLElement>>(
9
9
  base: T,
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ArrayDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
9
9
  base: T,
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { GridDefaultItem } from './vaadin-grid.js';
7
- import { ColumnBaseMixinClass } from './vaadin-grid-column.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
+ import type { ColumnBaseMixinClass } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
10
10
  * A `<vaadin-grid-column-group>` is used to make groups of columns in `<vaadin-grid>` and
@@ -156,7 +156,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
156
156
  const _rootColumns = rootColumns.slice(0);
157
157
 
158
158
  if (!order) {
159
- _rootColumns.forEach((column) => (column._order = 0));
159
+ _rootColumns.forEach((column) => {
160
+ column._order = 0;
161
+ });
160
162
  return;
161
163
  }
162
164
  // The parent column order number cascades downwards to it's children
@@ -190,7 +192,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
190
192
  return;
191
193
  }
192
194
 
193
- rootColumns.forEach((column) => (column._reorderStatus = reorderStatus));
195
+ rootColumns.forEach((column) => {
196
+ column._reorderStatus = reorderStatus;
197
+ });
194
198
  }
195
199
 
196
200
  /** @private */
@@ -199,7 +203,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
199
203
  return;
200
204
  }
201
205
 
202
- rootColumns.forEach((column) => (column.resizable = resizable));
206
+ rootColumns.forEach((column) => {
207
+ column.resizable = resizable;
208
+ });
203
209
  }
204
210
 
205
211
  /** @private */
@@ -217,7 +223,10 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
217
223
 
218
224
  if (this._visibleChildColumns.length > 0) {
219
225
  const width = this._visibleChildColumns
220
- .reduce((prev, curr) => (prev += ` + ${(curr.width || '0px').replace('calc', '')}`), '')
226
+ .reduce((prev, curr) => {
227
+ prev += ` + ${(curr.width || '0px').replace('calc', '')}`;
228
+ return prev;
229
+ }, '')
221
230
  .substring(3);
222
231
  this._setWidth(`calc(${width})`);
223
232
  } else {
@@ -235,7 +244,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
235
244
 
236
245
  // Don’t propagate the default `false` value.
237
246
  if (frozen !== false) {
238
- Array.from(rootColumns).forEach((col) => (col.frozen = frozen));
247
+ Array.from(rootColumns).forEach((col) => {
248
+ col.frozen = frozen;
249
+ });
239
250
  }
240
251
  }
241
252
 
@@ -247,7 +258,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
247
258
 
248
259
  // Don’t propagate the default `false` value.
249
260
  if (frozenToEnd !== false) {
250
- Array.from(rootColumns).forEach((col) => (col.frozenToEnd = frozenToEnd));
261
+ Array.from(rootColumns).forEach((col) => {
262
+ col.frozenToEnd = frozenToEnd;
263
+ });
251
264
  }
252
265
  }
253
266
 
@@ -276,7 +289,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
276
289
  /** @private */
277
290
  _synchronizeHidden() {
278
291
  if (this._childColumns && !this._preventHiddenSynchronization) {
279
- this._childColumns.forEach((column) => (column.hidden = this.hidden));
292
+ this._childColumns.forEach((column) => {
293
+ column.hidden = this.hidden;
294
+ });
280
295
  }
281
296
  }
282
297
 
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ColumnReorderingMixin<T extends Constructor<HTMLElement>>(
9
9
  base: T,
@@ -263,7 +263,9 @@ export const ColumnReorderingMixin = (superClass) =>
263
263
  'border',
264
264
  'flex-direction',
265
265
  'overflow',
266
- ].forEach((propertyName) => (ghost.style[propertyName] = style[propertyName]));
266
+ ].forEach((propertyName) => {
267
+ ghost.style[propertyName] = style[propertyName];
268
+ });
267
269
  return ghost;
268
270
  }
269
271
 
@@ -274,7 +276,9 @@ export const ColumnReorderingMixin = (superClass) =>
274
276
  }
275
277
 
276
278
  // Reset all column orders
277
- columnTree[0].forEach((column) => (column._order = 0));
279
+ columnTree[0].forEach((column) => {
280
+ column._order = 0;
281
+ });
278
282
  // Set order numbers to top-level columns
279
283
  updateColumnOrders(columnTree[0], this._orderBaseScope, 0);
280
284
  }
@@ -287,7 +291,9 @@ export const ColumnReorderingMixin = (superClass) =>
287
291
  _setSiblingsReorderStatus(column, status) {
288
292
  Array.from(column.parentNode.children)
289
293
  .filter((child) => /column/.test(child.localName) && this._isSwapAllowed(child, column))
290
- .forEach((sibling) => (sibling._reorderStatus = status));
294
+ .forEach((sibling) => {
295
+ sibling._reorderStatus = status;
296
+ });
291
297
  }
292
298
 
293
299
  /** @protected */
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridDefaultItem, GridItemModel } from './vaadin-grid.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridDefaultItem, GridItemModel } from './vaadin-grid.js';
8
8
 
9
9
  export type GridBodyRenderer<TItem> = (
10
10
  root: HTMLElement,
@@ -312,12 +312,16 @@ export const ColumnBaseMixin = (superClass) =>
312
312
  this.parentElement._columnPropChanged('flexGrow');
313
313
  }
314
314
 
315
- this._allCells.forEach((cell) => (cell.style.flexGrow = flexGrow));
315
+ this._allCells.forEach((cell) => {
316
+ cell.style.flexGrow = flexGrow;
317
+ });
316
318
  }
317
319
 
318
320
  /** @private */
319
321
  _orderChanged(order) {
320
- this._allCells.forEach((cell) => (cell.style.order = order));
322
+ this._allCells.forEach((cell) => {
323
+ cell.style.order = order;
324
+ });
321
325
  }
322
326
 
323
327
  /** @private */
@@ -326,7 +330,9 @@ export const ColumnBaseMixin = (superClass) =>
326
330
  this.parentElement._columnPropChanged('width');
327
331
  }
328
332
 
329
- this._allCells.forEach((cell) => (cell.style.width = width));
333
+ this._allCells.forEach((cell) => {
334
+ cell.style.width = width;
335
+ });
330
336
  }
331
337
 
332
338
  /** @private */
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import { GridSorterDirection } from './vaadin-grid-sorter.js';
8
8
 
9
9
  export { GridSorterDirection };
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridItemModel } from './vaadin-grid.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridItemModel } from './vaadin-grid.js';
8
8
 
9
9
  export type GridDragAndDropFilter<TItem> = (model: GridItemModel<TItem>) => boolean;
10
10
 
@@ -280,7 +280,9 @@ export const DragAndDropMixin = (superClass) =>
280
280
  if (scrollTopChanged) {
281
281
  this.__dndAutoScrolling = true;
282
282
  // Disallow more auto-scrolls within 20ms
283
- setTimeout(() => (this.__dndAutoScrolling = false), 20);
283
+ setTimeout(() => {
284
+ this.__dndAutoScrolling = false;
285
+ }, 20);
284
286
  return true;
285
287
  }
286
288
  }
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridColumn } from './vaadin-grid-column.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  export interface GridEventContext<TItem> {
10
10
  section?: 'body' | 'header' | 'footer' | 'details';
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { GridDefaultItem } from './vaadin-grid.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
7
  import { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
@@ -95,7 +95,9 @@ export const KeyboardNavigationMixin = (superClass) =>
95
95
  // Reset stored order when moving focus with mouse.
96
96
  this._focusedColumnOrder = undefined;
97
97
  });
98
- this.addEventListener('mouseup', () => (this._isMousedown = false));
98
+ this.addEventListener('mouseup', () => {
99
+ this._isMousedown = false;
100
+ });
99
101
  }
100
102
 
101
103
  /** @private */
@@ -370,7 +372,7 @@ export const KeyboardNavigationMixin = (superClass) =>
370
372
  * Focuses the target row after navigating by the given dy offset.
371
373
  * If the row is not in the viewport, it is first scrolled to.
372
374
  * @private
373
- **/
375
+ */
374
376
  _onRowNavigation(activeRow, dy) {
375
377
  const { dstRow } = this.__navigateRows(dy, activeRow);
376
378
 
@@ -394,7 +396,7 @@ export const KeyboardNavigationMixin = (superClass) =>
394
396
  * Also returns information whether the details cell should be the target on the target row.
395
397
  * If the row is not in the viewport, it is first scrolled to.
396
398
  * @private
397
- **/
399
+ */
398
400
  __navigateRows(dy, activeRow, activeCell) {
399
401
  const currentRowIndex = this.__getIndexInGroup(activeRow, this._focusedItemIndex);
400
402
  const activeRowGroup = activeRow.parentNode;
@@ -469,7 +471,7 @@ export const KeyboardNavigationMixin = (superClass) =>
469
471
  * Focuses the target cell after navigating by the given dx and dy offset.
470
472
  * If the cell is not in the viewport, it is first scrolled to.
471
473
  * @private
472
- **/
474
+ */
473
475
  _onCellNavigation(activeCell, dx, dy) {
474
476
  const activeRow = activeCell.parentNode;
475
477
  const { dstRow, dstIsRowDetails } = this.__navigateRows(dy, activeRow, activeCell);
@@ -746,10 +748,11 @@ export const KeyboardNavigationMixin = (superClass) =>
746
748
  this._detectFocusedItemIndex(e);
747
749
  }
748
750
 
749
- /** @private
751
+ /**
750
752
  * Enables interaction mode if a cells descendant receives focus or keyboard
751
753
  * input. Disables it if the event is not related to cell content.
752
754
  * @param {!KeyboardEvent|!FocusEvent} e
755
+ * @private
753
756
  */
754
757
  _detectInteracting(e) {
755
758
  const isInteracting = e.composedPath().some((el) => el.localName === 'vaadin-grid-cell-content');
@@ -765,11 +768,12 @@ export const KeyboardNavigationMixin = (superClass) =>
765
768
  }
766
769
  }
767
770
 
768
- /** @private
771
+ /**
769
772
  * Enables or disables the focus target of the containing section of the
770
773
  * grid from receiving focus, based on whether the user is interacting with
771
774
  * that section of the grid.
772
775
  * @param {HTMLElement} focusTarget
776
+ * @private
773
777
  */
774
778
  _updateGridSectionFocusTarget(focusTarget) {
775
779
  if (!focusTarget) {
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
7
- import { Grid, GridItemModel } from './vaadin-grid.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { Grid, GridItemModel } from './vaadin-grid.js';
8
8
 
9
9
  export type GridRowDetailsRenderer<TItem> = (
10
10
  root: HTMLElement,
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ScrollMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<ScrollMixinClass>;
9
9
 
@@ -69,7 +69,9 @@ export const ScrollMixin = (superClass) =>
69
69
  const itemsIndex = e.composedPath().indexOf(this.$.items);
70
70
  this._rowWithFocusedElement = e.composedPath()[itemsIndex - 1];
71
71
  });
72
- this.$.items.addEventListener('focusout', () => (this._rowWithFocusedElement = undefined));
72
+ this.$.items.addEventListener('focusout', () => {
73
+ this._rowWithFocusedElement = undefined;
74
+ });
73
75
 
74
76
  this.$.table.addEventListener('scroll', () => this._afterScroll());
75
77
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { GridDefaultItem } from './vaadin-grid.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
7
  import { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
@@ -185,7 +185,9 @@ class GridSelectionColumn extends GridColumn {
185
185
  }
186
186
 
187
187
  if (selectAll && Array.isArray(this._grid.items)) {
188
- this.__withFilteredItemsArray((items) => (this._grid.selectedItems = items));
188
+ this.__withFilteredItemsArray((items) => {
189
+ this._grid.selectedItems = items;
190
+ });
189
191
  } else {
190
192
  this._grid.selectedItems = [];
191
193
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function SelectionMixin<TItem, T extends Constructor<HTMLElement>>(
9
9
  base: T,
@@ -3,9 +3,9 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { GridDefaultItem } from './vaadin-grid.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
7
  import { GridColumn } from './vaadin-grid-column.js';
8
- import { GridSorterDirection } from './vaadin-grid-sorter.js';
8
+ import type { GridSorterDirection } from './vaadin-grid-sorter.js';
9
9
 
10
10
  /**
11
11
  * Fired when the `direction` property changes.
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function SortMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<SortMixinClass>;
9
9
 
@@ -13,4 +13,20 @@ export declare class SortMixinClass {
13
13
  * @attr {boolean} multi-sort
14
14
  */
15
15
  multiSort: boolean;
16
+
17
+ /**
18
+ * Controls how columns are added to the sort order when using multi-sort.
19
+ * The sort order is visually indicated by numbers in grid sorters placed in column headers.
20
+ *
21
+ * By default, whenever an unsorted column is sorted, or the sort-direction of a column is
22
+ * changed, that column gets sort priority 1, thus affecting the priority for all the other
23
+ * sorted columns. This is identical to using `multi-sort-priority="prepend"`.
24
+ *
25
+ * Using this property allows to change this behavior so that sorting an unsorted column
26
+ * would add it to the "end" of the sort, and changing column's sort direction would retain
27
+ * it's previous priority. To set this, use `multi-sort-priority="append"`.
28
+ *
29
+ * @attr {string} multi-sort-priority
30
+ */
31
+ multiSortPriority: 'prepend' | 'append';
16
32
  }
@@ -21,6 +21,25 @@ export const SortMixin = (superClass) =>
21
21
  value: false,
22
22
  },
23
23
 
24
+ /**
25
+ * Controls how columns are added to the sort order when using multi-sort.
26
+ * The sort order is visually indicated by numbers in grid sorters placed in column headers.
27
+ *
28
+ * By default, whenever an unsorted column is sorted, or the sort-direction of a column is
29
+ * changed, that column gets sort priority 1, thus affecting the priority for all the other
30
+ * sorted columns. This is identical to using `multi-sort-priority="prepend"`.
31
+ *
32
+ * Using this property allows to change this behavior so that sorting an unsorted column
33
+ * would add it to the "end" of the sort, and changing column's sort direction would retain
34
+ * it's previous priority. To set this, use `multi-sort-priority="append"`.
35
+ *
36
+ * @attr {string} multi-sort-priority
37
+ */
38
+ multiSortPriority: {
39
+ type: String,
40
+ value: 'prepend',
41
+ },
42
+
24
43
  /**
25
44
  * @type {!Array<!GridSorterDefinition>}
26
45
  * @protected
@@ -48,6 +67,7 @@ export const SortMixin = (superClass) =>
48
67
  _onSorterChanged(e) {
49
68
  const sorter = e.target;
50
69
  e.stopPropagation();
70
+ sorter._grid = this;
51
71
  this.__updateSorter(sorter);
52
72
  this.__applySorters();
53
73
  }
@@ -67,7 +87,29 @@ export const SortMixin = (superClass) =>
67
87
 
68
88
  /** @private */
69
89
  __updateSortOrders() {
70
- this._sorters.forEach((sorter, index) => (sorter._order = this._sorters.length > 1 ? index : null), this);
90
+ this._sorters.forEach((sorter, index) => {
91
+ sorter._order = this._sorters.length > 1 ? index : null;
92
+ });
93
+ }
94
+
95
+ /** @private */
96
+ __appendSorter(sorter) {
97
+ if (!sorter.direction) {
98
+ this._removeArrayItem(this._sorters, sorter);
99
+ } else if (!this._sorters.includes(sorter)) {
100
+ this._sorters.push(sorter);
101
+ }
102
+
103
+ this.__updateSortOrders();
104
+ }
105
+
106
+ /** @private */
107
+ __prependSorter(sorter) {
108
+ this._removeArrayItem(this._sorters, sorter);
109
+ if (sorter.direction) {
110
+ this._sorters.unshift(sorter);
111
+ }
112
+ this.__updateSortOrders();
71
113
  }
72
114
 
73
115
  /** @private */
@@ -79,11 +121,11 @@ export const SortMixin = (superClass) =>
79
121
  sorter._order = null;
80
122
 
81
123
  if (this.multiSort) {
82
- this._removeArrayItem(this._sorters, sorter);
83
- if (sorter.direction) {
84
- this._sorters.unshift(sorter);
124
+ if (this.multiSortPriority === 'append') {
125
+ this.__appendSorter(sorter);
126
+ } else {
127
+ this.__prependSorter(sorter);
85
128
  }
86
- this.__updateSortOrders();
87
129
  } else if (sorter.direction) {
88
130
  const otherSorters = this._sorters.filter((s) => s !== sorter);
89
131
  this._sorters = [sorter];
@@ -176,6 +176,10 @@ class GridSorter extends ThemableMixin(DirMixin(PolymerElement)) {
176
176
  disconnectedCallback() {
177
177
  super.disconnectedCallback();
178
178
  this._isConnected = false;
179
+
180
+ if (!this.parentNode && this._grid) {
181
+ this._grid.__removeSorters([this]);
182
+ }
179
183
  }
180
184
 
181
185
  /** @private */
@@ -3,9 +3,9 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridItemModel } from './vaadin-grid.js';
8
- import { GridColumn } from './vaadin-grid-column.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridItemModel } from './vaadin-grid.js';
8
+ import type { GridColumn } from './vaadin-grid-column.js';
9
9
 
10
10
  export type GridCellClassNameGenerator<TItem> = (column: GridColumn<TItem>, model: GridItemModel<TItem>) => string;
11
11
 
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { GridDefaultItem } from './vaadin-grid.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
7
  import { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
@@ -3,15 +3,16 @@
3
3
  * Copyright (c) 2016 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
7
- import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
8
- import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
- import { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
10
- import { ArrayDataProviderMixinClass } from './vaadin-grid-array-data-provider-mixin.js';
11
- import { GridBodyRenderer, GridColumn, GridHeaderFooterRenderer } from './vaadin-grid-column.js';
12
- import { ColumnReorderingMixinClass } from './vaadin-grid-column-reordering-mixin.js';
6
+ import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
7
+ import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
8
+ import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import type { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
10
+ import type { ArrayDataProviderMixinClass } from './vaadin-grid-array-data-provider-mixin.js';
11
+ import type { GridColumn } from './vaadin-grid-column.js';
12
+ import { GridBodyRenderer, GridHeaderFooterRenderer } from './vaadin-grid-column.js';
13
+ import type { ColumnReorderingMixinClass } from './vaadin-grid-column-reordering-mixin.js';
14
+ import type { DataProviderMixinClass } from './vaadin-grid-data-provider-mixin.js';
13
15
  import {
14
- DataProviderMixinClass,
15
16
  GridDataProvider,
16
17
  GridDataProviderCallback,
17
18
  GridDataProviderParams,
@@ -19,18 +20,17 @@ import {
19
20
  GridSorterDefinition,
20
21
  GridSorterDirection,
21
22
  } from './vaadin-grid-data-provider-mixin.js';
22
- import {
23
- DragAndDropMixinClass,
24
- GridDragAndDropFilter,
25
- GridDropLocation,
26
- GridDropMode,
27
- } from './vaadin-grid-drag-and-drop-mixin.js';
28
- import { EventContextMixinClass, GridEventContext } from './vaadin-grid-event-context-mixin.js';
29
- import { GridRowDetailsRenderer, RowDetailsMixinClass } from './vaadin-grid-row-details-mixin.js';
30
- import { ScrollMixinClass } from './vaadin-grid-scroll-mixin.js';
31
- import { SelectionMixinClass } from './vaadin-grid-selection-mixin.js';
32
- import { SortMixinClass } from './vaadin-grid-sort-mixin.js';
33
- import { GridCellClassNameGenerator, StylingMixinClass } from './vaadin-grid-styling-mixin.js';
23
+ import type { DragAndDropMixinClass } from './vaadin-grid-drag-and-drop-mixin.js';
24
+ import { GridDragAndDropFilter, GridDropLocation, GridDropMode } from './vaadin-grid-drag-and-drop-mixin.js';
25
+ import type { EventContextMixinClass } from './vaadin-grid-event-context-mixin.js';
26
+ import { GridEventContext } from './vaadin-grid-event-context-mixin.js';
27
+ import type { RowDetailsMixinClass } from './vaadin-grid-row-details-mixin.js';
28
+ import { GridRowDetailsRenderer } from './vaadin-grid-row-details-mixin.js';
29
+ import type { ScrollMixinClass } from './vaadin-grid-scroll-mixin.js';
30
+ import type { SelectionMixinClass } from './vaadin-grid-selection-mixin.js';
31
+ import type { SortMixinClass } from './vaadin-grid-sort-mixin.js';
32
+ import type { StylingMixinClass } from './vaadin-grid-styling-mixin.js';
33
+ import { GridCellClassNameGenerator } from './vaadin-grid-styling-mixin.js';
34
34
 
35
35
  export {
36
36
  GridBodyRenderer,
@@ -708,7 +708,9 @@ class Grid extends ElementMixin(
708
708
 
709
709
  const contentsFragment = document.createDocumentFragment();
710
710
 
711
- Array.from(row.children).forEach((cell) => (cell._vacant = true));
711
+ Array.from(row.children).forEach((cell) => {
712
+ cell._vacant = true;
713
+ });
712
714
  row.innerHTML = '';
713
715
 
714
716
  columns