@vaadin/grid 23.2.0-alpha2 → 23.2.0-alpha5

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 (39) hide show
  1. package/package.json +17 -11
  2. package/src/array-data-provider.js +3 -5
  3. package/src/lit/column-renderer-directives.d.ts +7 -6
  4. package/src/lit/renderer-directives.d.ts +3 -3
  5. package/src/vaadin-grid-active-item-mixin.d.ts +2 -2
  6. package/src/vaadin-grid-array-data-provider-mixin.d.ts +2 -2
  7. package/src/vaadin-grid-column-group.d.ts +2 -2
  8. package/src/vaadin-grid-column-group.js +22 -7
  9. package/src/vaadin-grid-column-reordering-mixin.d.ts +2 -2
  10. package/src/vaadin-grid-column-reordering-mixin.js +9 -3
  11. package/src/vaadin-grid-column.d.ts +4 -4
  12. package/src/vaadin-grid-column.js +9 -3
  13. package/src/vaadin-grid-data-provider-mixin.d.ts +2 -2
  14. package/src/vaadin-grid-drag-and-drop-mixin.d.ts +5 -5
  15. package/src/vaadin-grid-drag-and-drop-mixin.js +3 -1
  16. package/src/vaadin-grid-event-context-mixin.d.ts +4 -4
  17. package/src/vaadin-grid-filter-column.d.ts +1 -1
  18. package/src/vaadin-grid-filter.d.ts +2 -2
  19. package/src/vaadin-grid-keyboard-navigation-mixin.js +10 -6
  20. package/src/vaadin-grid-row-details-mixin.d.ts +3 -3
  21. package/src/vaadin-grid-scroll-mixin.d.ts +2 -2
  22. package/src/vaadin-grid-scroll-mixin.js +3 -1
  23. package/src/vaadin-grid-selection-column.d.ts +3 -3
  24. package/src/vaadin-grid-selection-column.js +10 -3
  25. package/src/vaadin-grid-selection-mixin.d.ts +2 -2
  26. package/src/vaadin-grid-sort-column.d.ts +4 -4
  27. package/src/vaadin-grid-sort-mixin.d.ts +18 -2
  28. package/src/vaadin-grid-sort-mixin.js +47 -5
  29. package/src/vaadin-grid-sorter.d.ts +2 -2
  30. package/src/vaadin-grid-sorter.js +7 -3
  31. package/src/vaadin-grid-styling-mixin.d.ts +4 -4
  32. package/src/vaadin-grid-tree-column.d.ts +1 -1
  33. package/src/vaadin-grid-tree-toggle.d.ts +2 -2
  34. package/src/vaadin-grid-tree-toggle.js +3 -3
  35. package/src/vaadin-grid.d.ts +25 -23
  36. package/src/vaadin-grid.js +4 -2
  37. package/theme/lumo/vaadin-grid-styles.js +0 -10
  38. package/web-types.json +2152 -0
  39. package/web-types.lit.json +930 -0
@@ -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.
@@ -49,13 +49,13 @@ declare class GridSortColumn<TItem = GridDefaultItem> extends GridColumn<TItem>
49
49
  addEventListener<K extends keyof GridSortColumnEventMap>(
50
50
  type: K,
51
51
  listener: (this: GridSortColumn<TItem>, ev: GridSortColumnEventMap[K]) => void,
52
- options?: boolean | AddEventListenerOptions,
52
+ options?: AddEventListenerOptions | boolean,
53
53
  ): void;
54
54
 
55
55
  removeEventListener<K extends keyof GridSortColumnEventMap>(
56
56
  type: K,
57
57
  listener: (this: GridSortColumn<TItem>, ev: GridSortColumnEventMap[K]) => void,
58
- options?: boolean | EventListenerOptions,
58
+ options?: EventListenerOptions | boolean,
59
59
  ): void;
60
60
  }
61
61
 
@@ -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';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
- export declare function SortMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<SortMixinClass>;
8
+ export declare function SortMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<SortMixinClass> & T;
9
9
 
10
10
  export declare class SortMixinClass {
11
11
  /**
@@ -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: 'append' | 'prepend';
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];
@@ -76,13 +76,13 @@ declare class GridSorter extends ThemableMixin(DirMixin(HTMLElement)) {
76
76
  addEventListener<K extends keyof GridSorterEventMap>(
77
77
  type: K,
78
78
  listener: (this: GridSorter, ev: GridSorterEventMap[K]) => void,
79
- options?: boolean | AddEventListenerOptions,
79
+ options?: AddEventListenerOptions | boolean,
80
80
  ): void;
81
81
 
82
82
  removeEventListener<K extends keyof GridSorterEventMap>(
83
83
  type: K,
84
84
  listener: (this: GridSorter, ev: GridSorterEventMap[K]) => void,
85
- options?: boolean | EventListenerOptions,
85
+ options?: EventListenerOptions | boolean,
86
86
  ): void;
87
87
  }
88
88
 
@@ -7,9 +7,9 @@ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
7
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
9
 
10
- const $_documentContainer = document.createElement('template');
10
+ const template = document.createElement('template');
11
11
 
12
- $_documentContainer.innerHTML = `
12
+ template.innerHTML = `
13
13
  <style>
14
14
  @font-face {
15
15
  font-family: 'vaadin-grid-sorter-icons';
@@ -20,7 +20,7 @@ $_documentContainer.innerHTML = `
20
20
  </style>
21
21
  `;
22
22
 
23
- document.head.appendChild($_documentContainer.content);
23
+ document.head.appendChild(template.content);
24
24
 
25
25
  /**
26
26
  * `<vaadin-grid-sorter>` is a helper element for the `<vaadin-grid>` that provides out-of-the-box UI controls,
@@ -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,15 +3,15 @@
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
 
12
12
  export declare function StylingMixin<TItem, T extends Constructor<HTMLElement>>(
13
13
  base: T,
14
- ): T & Constructor<StylingMixinClass<TItem>>;
14
+ ): Constructor<StylingMixinClass<TItem>> & T;
15
15
 
16
16
  export declare class StylingMixinClass<TItem> {
17
17
  /**
@@ -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
  /**
@@ -85,13 +85,13 @@ declare class GridTreeToggle extends ThemableMixin(DirMixin(HTMLElement)) {
85
85
  addEventListener<K extends keyof GridTreeToggleEventMap>(
86
86
  type: K,
87
87
  listener: (this: GridTreeToggle, ev: GridTreeToggleEventMap[K]) => void,
88
- options?: boolean | AddEventListenerOptions,
88
+ options?: AddEventListenerOptions | boolean,
89
89
  ): void;
90
90
 
91
91
  removeEventListener<K extends keyof GridTreeToggleEventMap>(
92
92
  type: K,
93
93
  listener: (this: GridTreeToggle, ev: GridTreeToggleEventMap[K]) => void,
94
- options?: boolean | EventListenerOptions,
94
+ options?: EventListenerOptions | boolean,
95
95
  ): void;
96
96
  }
97
97
 
@@ -8,9 +8,9 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
9
  import { isFocusable } from './vaadin-grid-active-item-mixin.js';
10
10
 
11
- const $_documentContainer = document.createElement('template');
11
+ const template = document.createElement('template');
12
12
 
13
- $_documentContainer.innerHTML = `
13
+ template.innerHTML = `
14
14
  <style>
15
15
  @font-face {
16
16
  font-family: "vaadin-grid-tree-icons";
@@ -21,7 +21,7 @@ $_documentContainer.innerHTML = `
21
21
  </style>
22
22
  `;
23
23
 
24
- document.head.appendChild($_documentContainer.content);
24
+ document.head.appendChild(template.content);
25
25
 
26
26
  /**
27
27
  * `<vaadin-grid-tree-toggle>` is a helper element for the `<vaadin-grid>`
@@ -3,15 +3,17 @@
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 { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
10
+ import type { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
11
+ import type { ArrayDataProviderMixinClass } from './vaadin-grid-array-data-provider-mixin.js';
12
+ import type { GridColumn } from './vaadin-grid-column.js';
13
+ import { GridBodyRenderer, GridHeaderFooterRenderer } from './vaadin-grid-column.js';
14
+ import type { ColumnReorderingMixinClass } from './vaadin-grid-column-reordering-mixin.js';
15
+ import type { DataProviderMixinClass } from './vaadin-grid-data-provider-mixin.js';
13
16
  import {
14
- DataProviderMixinClass,
15
17
  GridDataProvider,
16
18
  GridDataProviderCallback,
17
19
  GridDataProviderParams,
@@ -19,18 +21,17 @@ import {
19
21
  GridSorterDefinition,
20
22
  GridSorterDirection,
21
23
  } 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';
24
+ import type { DragAndDropMixinClass } from './vaadin-grid-drag-and-drop-mixin.js';
25
+ import { GridDragAndDropFilter, GridDropLocation, GridDropMode } from './vaadin-grid-drag-and-drop-mixin.js';
26
+ import type { EventContextMixinClass } from './vaadin-grid-event-context-mixin.js';
27
+ import { GridEventContext } from './vaadin-grid-event-context-mixin.js';
28
+ import type { RowDetailsMixinClass } from './vaadin-grid-row-details-mixin.js';
29
+ import { GridRowDetailsRenderer } from './vaadin-grid-row-details-mixin.js';
30
+ import type { ScrollMixinClass } from './vaadin-grid-scroll-mixin.js';
31
+ import type { SelectionMixinClass } from './vaadin-grid-selection-mixin.js';
32
+ import type { SortMixinClass } from './vaadin-grid-sort-mixin.js';
33
+ import type { StylingMixinClass } from './vaadin-grid-styling-mixin.js';
34
+ import { GridCellClassNameGenerator } from './vaadin-grid-styling-mixin.js';
34
35
 
35
36
  export {
36
37
  GridBodyRenderer,
@@ -305,7 +306,7 @@ export interface GridEventMap<TItem> extends HTMLElementEventMap, GridCustomEven
305
306
  * `overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host
306
307
  * `reordering` | Set when the grid's columns are being reordered | :host
307
308
  * `dragover` | Set when the grid (not a specific row) is dragged over | :host
308
- * `dragging-rows` : Set when grid rows are dragged | :host
309
+ * `dragging-rows` | Set when grid rows are dragged | :host
309
310
  * `reorder-status` | Reflects the status of a cell while columns are being reordered | cell
310
311
  * `frozen` | Frozen cell | cell
311
312
  * `last-frozen` | Last frozen cell | cell
@@ -379,13 +380,13 @@ declare class Grid<TItem = GridDefaultItem> extends HTMLElement {
379
380
  addEventListener<K extends keyof GridEventMap<TItem>>(
380
381
  type: K,
381
382
  listener: (this: Grid<TItem>, ev: GridEventMap<TItem>[K]) => void,
382
- options?: boolean | AddEventListenerOptions,
383
+ options?: AddEventListenerOptions | boolean,
383
384
  ): void;
384
385
 
385
386
  removeEventListener<K extends keyof GridEventMap<TItem>>(
386
387
  type: K,
387
388
  listener: (this: Grid<TItem>, ev: GridEventMap<TItem>[K]) => void,
388
- options?: boolean | EventListenerOptions,
389
+ options?: EventListenerOptions | boolean,
389
390
  ): void;
390
391
  }
391
392
 
@@ -393,6 +394,7 @@ interface Grid<TItem = GridDefaultItem>
393
394
  extends DisabledMixinClass,
394
395
  ElementMixinClass,
395
396
  ThemableMixinClass,
397
+ ThemePropertyMixinClass,
396
398
  ActiveItemMixinClass<TItem>,
397
399
  ArrayDataProviderMixinClass<TItem>,
398
400
  DataProviderMixinClass<TItem>,
@@ -191,7 +191,7 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
191
191
  * `overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host
192
192
  * `reordering` | Set when the grid's columns are being reordered | :host
193
193
  * `dragover` | Set when the grid (not a specific row) is dragged over | :host
194
- * `dragging-rows` : Set when grid rows are dragged | :host
194
+ * `dragging-rows` | Set when grid rows are dragged | :host
195
195
  * `reorder-status` | Reflects the status of a cell while columns are being reordered | cell
196
196
  * `frozen` | Frozen cell | cell
197
197
  * `last-frozen` | Last frozen cell | cell
@@ -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
@@ -395,13 +395,3 @@ registerStyles(
395
395
  `,
396
396
  { moduleId: 'lumo-grid' },
397
397
  );
398
-
399
- registerStyles(
400
- 'vaadin-checkbox',
401
- css`
402
- :host(.vaadin-grid-select-all-checkbox) {
403
- font-size: var(--lumo-font-size-m);
404
- }
405
- `,
406
- { moduleId: 'vaadin-grid-select-all-checkbox-lumo' },
407
- );