@vaadin/grid 24.3.0-alpha1 → 24.3.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.
Files changed (61) hide show
  1. package/package.json +18 -13
  2. package/src/vaadin-grid-a11y-mixin.js +1 -1
  3. package/src/vaadin-grid-active-item-mixin.js +1 -0
  4. package/src/vaadin-grid-array-data-provider-mixin.js +14 -17
  5. package/src/vaadin-grid-column-group-mixin.d.ts +20 -0
  6. package/src/vaadin-grid-column-group-mixin.js +364 -0
  7. package/src/vaadin-grid-column-group.d.ts +4 -14
  8. package/src/vaadin-grid-column-group.js +5 -355
  9. package/src/vaadin-grid-column-mixin.d.ts +170 -0
  10. package/src/vaadin-grid-column-mixin.js +958 -0
  11. package/src/vaadin-grid-column.d.ts +11 -138
  12. package/src/vaadin-grid-column.js +5 -876
  13. package/src/vaadin-grid-data-provider-mixin.d.ts +6 -5
  14. package/src/vaadin-grid-data-provider-mixin.js +58 -11
  15. package/src/vaadin-grid-drag-and-drop-mixin.js +17 -5
  16. package/src/vaadin-grid-dynamic-columns-mixin.js +22 -17
  17. package/src/vaadin-grid-filter-column-mixin.d.ts +22 -0
  18. package/src/vaadin-grid-filter-column-mixin.js +106 -0
  19. package/src/vaadin-grid-filter-column.d.ts +9 -11
  20. package/src/vaadin-grid-filter-column.js +3 -90
  21. package/src/vaadin-grid-filter-element-mixin.d.ts +34 -0
  22. package/src/vaadin-grid-filter-element-mixin.js +108 -0
  23. package/src/vaadin-grid-filter-mixin.js +4 -4
  24. package/src/vaadin-grid-filter.d.ts +4 -21
  25. package/src/vaadin-grid-filter.js +5 -84
  26. package/src/vaadin-grid-helpers.js +94 -0
  27. package/src/vaadin-grid-keyboard-navigation-mixin.js +26 -6
  28. package/src/vaadin-grid-mixin.js +37 -46
  29. package/src/vaadin-grid-row-details-mixin.js +14 -8
  30. package/src/vaadin-grid-scroll-mixin.js +9 -3
  31. package/src/vaadin-grid-selection-column-base-mixin.js +12 -4
  32. package/src/vaadin-grid-selection-column-mixin.d.ts +24 -0
  33. package/src/vaadin-grid-selection-column-mixin.js +194 -0
  34. package/src/vaadin-grid-selection-column.d.ts +13 -17
  35. package/src/vaadin-grid-selection-column.js +4 -186
  36. package/src/vaadin-grid-selection-mixin.js +4 -3
  37. package/src/vaadin-grid-sort-column-mixin.d.ts +36 -0
  38. package/src/vaadin-grid-sort-column-mixin.js +101 -0
  39. package/src/vaadin-grid-sort-column.d.ts +8 -26
  40. package/src/vaadin-grid-sort-column.js +3 -87
  41. package/src/vaadin-grid-sorter-mixin.d.ts +44 -0
  42. package/src/vaadin-grid-sorter-mixin.js +200 -0
  43. package/src/vaadin-grid-sorter.d.ts +3 -32
  44. package/src/vaadin-grid-sorter.js +5 -181
  45. package/src/vaadin-grid-styles.js +341 -345
  46. package/src/vaadin-grid-styling-mixin.js +8 -2
  47. package/src/vaadin-grid-tree-column-mixin.d.ts +18 -0
  48. package/src/vaadin-grid-tree-column-mixin.js +99 -0
  49. package/src/vaadin-grid-tree-column.d.ts +9 -7
  50. package/src/vaadin-grid-tree-column.js +3 -82
  51. package/src/vaadin-grid-tree-toggle-mixin.d.ts +39 -0
  52. package/src/vaadin-grid-tree-toggle-mixin.js +153 -0
  53. package/src/vaadin-grid-tree-toggle.d.ts +4 -27
  54. package/src/vaadin-grid-tree-toggle.js +9 -141
  55. package/src/vaadin-grid.d.ts +3 -0
  56. package/src/vaadin-grid.js +7 -2
  57. package/theme/lumo/vaadin-grid-sorter-styles.js +1 -1
  58. package/theme/lumo/vaadin-grid-styles.js +15 -14
  59. package/theme/material/vaadin-grid-styles.js +15 -10
  60. package/web-types.json +331 -126
  61. package/web-types.lit.json +114 -58
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2023 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
+ import type { GridSorterDirection } from './vaadin-grid-sorter.js';
8
+
9
+ /**
10
+ * Fired when the `direction` property changes.
11
+ */
12
+ export type GridSortColumnDirectionChangedEvent = CustomEvent<{ value: GridSorterDirection }>;
13
+
14
+ export interface GridSortColumnCustomEventMap {
15
+ 'direction-changed': GridSortColumnDirectionChangedEvent;
16
+ }
17
+
18
+ export interface GridSortColumnEventMap extends HTMLElementEventMap, GridSortColumnCustomEventMap {}
19
+
20
+ export declare function GridSortColumnMixin<T extends Constructor<HTMLElement>>(
21
+ superclass: T,
22
+ ): Constructor<GridSortColumnMixinClass> & T;
23
+
24
+ export declare class GridSortColumnMixinClass {
25
+ /**
26
+ * JS Path of the property in the item used for sorting the data.
27
+ */
28
+ path: string | null | undefined;
29
+
30
+ /**
31
+ * How to sort the data.
32
+ * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
33
+ * descending direction, or `null` for not sorting the data.
34
+ */
35
+ direction: GridSorterDirection | null | undefined;
36
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * @polymerMixin
9
+ */
10
+ export const GridSortColumnMixin = (superClass) =>
11
+ class extends superClass {
12
+ static get properties() {
13
+ return {
14
+ /**
15
+ * JS Path of the property in the item used for sorting the data.
16
+ */
17
+ path: {
18
+ type: String,
19
+ sync: true,
20
+ },
21
+
22
+ /**
23
+ * How to sort the data.
24
+ * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
25
+ * descending direction, or `null` for not sorting the data.
26
+ * @type {GridSorterDirection | undefined}
27
+ */
28
+ direction: {
29
+ type: String,
30
+ notify: true,
31
+ sync: true,
32
+ },
33
+ };
34
+ }
35
+
36
+ static get observers() {
37
+ return ['_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header, direction)'];
38
+ }
39
+
40
+ constructor() {
41
+ super();
42
+
43
+ this.__boundOnDirectionChanged = this.__onDirectionChanged.bind(this);
44
+ }
45
+
46
+ /**
47
+ * Renders the grid sorter to the header cell.
48
+ *
49
+ * @override
50
+ */
51
+ _defaultHeaderRenderer(root, _column) {
52
+ let sorter = root.firstElementChild;
53
+ if (!sorter) {
54
+ sorter = document.createElement('vaadin-grid-sorter');
55
+ sorter.addEventListener('direction-changed', this.__boundOnDirectionChanged);
56
+ root.appendChild(sorter);
57
+ }
58
+
59
+ sorter.path = this.path;
60
+ sorter.__rendererDirection = this.direction;
61
+ sorter.direction = this.direction;
62
+ sorter.textContent = this.__getHeader(this.header, this.path);
63
+ }
64
+
65
+ /**
66
+ * The sort column doesn't allow to use a custom header renderer
67
+ * to override the header cell content.
68
+ * It always renders the grid sorter to the header cell.
69
+ *
70
+ * @override
71
+ */
72
+ _computeHeaderRenderer() {
73
+ return this._defaultHeaderRenderer;
74
+ }
75
+
76
+ /**
77
+ * Updates the sorting direction once the grid sorter's direction is changed.
78
+ * The listener handles only user-fired events.
79
+ *
80
+ * @private
81
+ */
82
+ __onDirectionChanged(e) {
83
+ // Skip if the direction is changed by the renderer.
84
+ if (e.detail.value === e.target.__rendererDirection) {
85
+ return;
86
+ }
87
+
88
+ this.direction = e.detail.value;
89
+ }
90
+
91
+ /** @private */
92
+ __getHeader(header, path) {
93
+ if (header) {
94
+ return header;
95
+ }
96
+
97
+ if (path) {
98
+ return this._generateHeader(path);
99
+ }
100
+ }
101
+ };
@@ -4,19 +4,10 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { GridDefaultItem } from './vaadin-grid.js';
7
- import { GridColumn } from './vaadin-grid-column.js';
8
- import type { GridSorterDirection } from './vaadin-grid-sorter.js';
7
+ import type { GridColumn, GridColumnMixin } from './vaadin-grid-column.js';
8
+ import type { GridSortColumnEventMap, GridSortColumnMixinClass } from './vaadin-grid-sort-column-mixin.js';
9
9
 
10
- /**
11
- * Fired when the `direction` property changes.
12
- */
13
- export type GridSortColumnDirectionChangedEvent = CustomEvent<{ value: GridSorterDirection }>;
14
-
15
- export interface GridSortColumnCustomEventMap {
16
- 'direction-changed': GridSortColumnDirectionChangedEvent;
17
- }
18
-
19
- export interface GridSortColumnEventMap extends HTMLElementEventMap, GridSortColumnCustomEventMap {}
10
+ export * from './vaadin-grid-sort-column-mixin.js';
20
11
 
21
12
  /**
22
13
  * `<vaadin-grid-sort-column>` is a helper element for the `<vaadin-grid>`
@@ -30,22 +21,13 @@ export interface GridSortColumnEventMap extends HTMLElementEventMap, GridSortCol
30
21
  * <vaadin-grid-column>
31
22
  * ...
32
23
  * ```
33
- *
34
- * @fires {CustomEvent} direction-changed - Fired when the `direction` property changes.
35
24
  */
36
- declare class GridSortColumn<TItem = GridDefaultItem> extends GridColumn<TItem> {
37
- /**
38
- * JS Path of the property in the item used for sorting the data.
39
- */
40
- path: string | null | undefined;
41
-
42
- /**
43
- * How to sort the data.
44
- * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
45
- * descending direction, or `null` for not sorting the data.
46
- */
47
- direction: GridSorterDirection | null | undefined;
25
+ declare class GridSortColumn<TItem = GridDefaultItem> extends HTMLElement {}
48
26
 
27
+ interface GridSortColumn<TItem = GridDefaultItem>
28
+ extends GridSortColumnMixinClass,
29
+ GridColumnMixin<TItem, GridColumn<TItem>>,
30
+ GridColumn<TItem> {
49
31
  addEventListener<K extends keyof GridSortColumnEventMap>(
50
32
  type: K,
51
33
  listener: (this: GridSortColumn<TItem>, ev: GridSortColumnEventMap[K]) => void,
@@ -6,6 +6,7 @@
6
6
  import './vaadin-grid-sorter.js';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { GridColumn } from './vaadin-grid-column.js';
9
+ import { GridSortColumnMixin } from './vaadin-grid-sort-column-mixin.js';
9
10
 
10
11
  /**
11
12
  * `<vaadin-grid-sort-column>` is a helper element for the `<vaadin-grid>`
@@ -24,97 +25,12 @@ import { GridColumn } from './vaadin-grid-column.js';
24
25
  *
25
26
  * @customElement
26
27
  * @extends GridColumn
28
+ * @mixes GridSortColumnMixin
27
29
  */
28
- class GridSortColumn extends GridColumn {
30
+ class GridSortColumn extends GridSortColumnMixin(GridColumn) {
29
31
  static get is() {
30
32
  return 'vaadin-grid-sort-column';
31
33
  }
32
-
33
- static get properties() {
34
- return {
35
- /**
36
- * JS Path of the property in the item used for sorting the data.
37
- */
38
- path: String,
39
-
40
- /**
41
- * How to sort the data.
42
- * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
43
- * descending direction, or `null` for not sorting the data.
44
- * @type {GridSorterDirection | undefined}
45
- */
46
- direction: {
47
- type: String,
48
- notify: true,
49
- },
50
- };
51
- }
52
-
53
- static get observers() {
54
- return ['_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header, direction)'];
55
- }
56
-
57
- constructor() {
58
- super();
59
-
60
- this.__boundOnDirectionChanged = this.__onDirectionChanged.bind(this);
61
- }
62
-
63
- /**
64
- * Renders the grid sorter to the header cell.
65
- *
66
- * @override
67
- */
68
- _defaultHeaderRenderer(root, _column) {
69
- let sorter = root.firstElementChild;
70
- if (!sorter) {
71
- sorter = document.createElement('vaadin-grid-sorter');
72
- sorter.addEventListener('direction-changed', this.__boundOnDirectionChanged);
73
- root.appendChild(sorter);
74
- }
75
-
76
- sorter.path = this.path;
77
- sorter.__rendererDirection = this.direction;
78
- sorter.direction = this.direction;
79
- sorter.textContent = this.__getHeader(this.header, this.path);
80
- }
81
-
82
- /**
83
- * The sort column doesn't allow to use a custom header renderer
84
- * to override the header cell content.
85
- * It always renders the grid sorter to the header cell.
86
- *
87
- * @override
88
- */
89
- _computeHeaderRenderer() {
90
- return this._defaultHeaderRenderer;
91
- }
92
-
93
- /**
94
- * Updates the sorting direction once the grid sorter's direction is changed.
95
- * The listener handles only user-fired events.
96
- *
97
- * @private
98
- */
99
- __onDirectionChanged(e) {
100
- // Skip if the direction is changed by the renderer.
101
- if (e.detail.value === e.target.__rendererDirection) {
102
- return;
103
- }
104
-
105
- this.direction = e.detail.value;
106
- }
107
-
108
- /** @private */
109
- __getHeader(header, path) {
110
- if (header) {
111
- return header;
112
- }
113
-
114
- if (path) {
115
- return this._generateHeader(path);
116
- }
117
- }
118
34
  }
119
35
 
120
36
  defineCustomElement(GridSortColumn);
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2023 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 type GridSorterDirection = 'asc' | 'desc' | null;
9
+
10
+ /**
11
+ * Fired when the `path` or `direction` property changes.
12
+ */
13
+ export type GridSorterChangedEvent = CustomEvent<{ shiftClick: boolean; fromSorterClick: boolean }>;
14
+
15
+ /**
16
+ * Fired when the `direction` property changes.
17
+ */
18
+ export type GridSorterDirectionChangedEvent = CustomEvent<{ value: GridSorterDirection }>;
19
+
20
+ export interface GridSorterCustomEventMap {
21
+ 'sorter-changed': GridSorterChangedEvent;
22
+
23
+ 'direction-changed': GridSorterDirectionChangedEvent;
24
+ }
25
+
26
+ export interface GridSorterEventMap extends HTMLElementEventMap, GridSorterCustomEventMap {}
27
+
28
+ export declare function GridSorterMixin<T extends Constructor<HTMLElement>>(
29
+ base: T,
30
+ ): Constructor<GridSorterMixinClass> & T;
31
+
32
+ declare class GridSorterMixinClass {
33
+ /**
34
+ * JS Path of the property in the item used for sorting the data.
35
+ */
36
+ path: string | null | undefined;
37
+
38
+ /**
39
+ * How to sort the data.
40
+ * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
41
+ * descending direction, or `null` for not sorting the data.
42
+ */
43
+ direction: GridSorterDirection | null | undefined;
44
+ }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
+
8
+ const template = document.createElement('template');
9
+
10
+ template.innerHTML = `
11
+ <style>
12
+ @font-face {
13
+ font-family: 'vaadin-grid-sorter-icons';
14
+ src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQwAA0AAAAABuwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAEFAAAABkAAAAcfep+mUdERUYAAAP4AAAAHAAAAB4AJwAOT1MvMgAAAZgAAAA/AAAAYA8TBPpjbWFwAAAB7AAAAFUAAAFeF1fZ4mdhc3AAAAPwAAAACAAAAAgAAAAQZ2x5ZgAAAlgAAABcAAAAnMvguMloZWFkAAABMAAAAC8AAAA2C5Ap72hoZWEAAAFgAAAAHQAAACQGbQPHaG10eAAAAdgAAAAUAAAAHAoAAABsb2NhAAACRAAAABIAAAASAIwAYG1heHAAAAGAAAAAFgAAACAACwAKbmFtZQAAArQAAAECAAACZxWCgKhwb3N0AAADuAAAADUAAABZCrApUXicY2BkYGAA4rDECVrx/DZfGbhZGEDgyqNPOxH0/wNMq5kPALkcDEwgUQBWRA0dAHicY2BkYGA+8P8AAwMLAwgwrWZgZEAFbABY4QM8AAAAeJxjYGRgYOAAQiYGEICQSAAAAi8AFgAAeJxjYGY6yziBgZWBgWkm0xkGBoZ+CM34msGYkZMBFTAKoAkwODAwvmRiPvD/AIMDMxCD1CDJKjAwAgBktQsXAHicY2GAAMZQCM0EwqshbAALxAEKeJxjYGBgZoBgGQZGBhCIAPIYwXwWBhsgzcXAwcAEhIwMCi+Z/v/9/x+sSuElA4T9/4k4K1gHFwMMMILMY2QDYmaoABOQYGJABUA7WBiGNwAAJd4NIQAAAAAAAAAACAAIABAAGAAmAEAATgAAeJyNjLENgDAMBP9tIURJwQCMQccSZgk2i5fIYBDAidJjycXr7x5EPwE2wY8si7jmyBNXGo/bNBerxJNrpxhbO3/fEFpx8ZICpV+ghxJ74fAMe+h7Ox14AbrsHB14nK2QQWrDMBRER4mTkhQK3ZRQKOgCNk7oGQqhhEIX2WSlWEI1BAlkJ5CDdNsj5Ey9Rncdi38ES+jzNJo/HwTgATcoDEthhY3wBHc4CE+pfwsX5F/hGe7Vo/AcK/UhvMSz+mGXKhZU6pww8ISz3oWn1BvhgnwTnuEJf8Jz1OpFeIlX9YULDLdFi4ASHolkSR0iuYdjLak1vAequBhj21D61Nqyi6l3qWybGPjySbPHGScGJl6dP58MYcQRI0bts7mjebBqrFENH7t3qWtj0OuqHnXcW7b0HOTZFnKryRGW2hFX1m0O2vEM3opNMfTau+CS6Z3Vx6veNnEXY6jwDxhsc2gAAHicY2BiwA84GBgYmRiYGJkZmBlZGFkZ2djScyoLMgzZS/MyDQwMwLSrpYEBlIbxjQDrzgsuAAAAAAEAAf//AA94nGNgZGBg4AFiMSBmYmAEQnYgZgHzGAAD6wA2eJxjYGBgZACCKyoz1cD0o087YTQATOcIewAAAA==) format('woff');
15
+ font-weight: normal;
16
+ font-style: normal;
17
+ }
18
+ </style>
19
+ `;
20
+
21
+ document.head.appendChild(template.content);
22
+
23
+ registerStyles(
24
+ 'vaadin-grid-sorter',
25
+ css`
26
+ :host {
27
+ display: inline-flex;
28
+ cursor: pointer;
29
+ max-width: 100%;
30
+ }
31
+
32
+ [part='content'] {
33
+ flex: 1 1 auto;
34
+ }
35
+
36
+ [part='indicators'] {
37
+ position: relative;
38
+ align-self: center;
39
+ flex: none;
40
+ }
41
+
42
+ [part='order'] {
43
+ display: inline;
44
+ vertical-align: super;
45
+ }
46
+
47
+ [part='indicators']::before {
48
+ font-family: 'vaadin-grid-sorter-icons';
49
+ display: inline-block;
50
+ }
51
+
52
+ :host(:not([direction])) [part='indicators']::before {
53
+ content: '\\e901';
54
+ }
55
+
56
+ :host([direction='asc']) [part='indicators']::before {
57
+ content: '\\e900';
58
+ }
59
+
60
+ :host([direction='desc']) [part='indicators']::before {
61
+ content: '\\e902';
62
+ }
63
+ `,
64
+ { moduleId: 'vaadin-grid-sorter-styles' },
65
+ );
66
+
67
+ /**
68
+ * A mixin providing common sorter functionality.
69
+ *
70
+ * @polymerMixin
71
+ */
72
+ export const GridSorterMixin = (superClass) =>
73
+ class GridSorterMixinClass extends superClass {
74
+ static get properties() {
75
+ return {
76
+ /**
77
+ * JS Path of the property in the item used for sorting the data.
78
+ */
79
+ path: String,
80
+
81
+ /**
82
+ * How to sort the data.
83
+ * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
84
+ * descending direction, or `null` for not sorting the data.
85
+ * @type {GridSorterDirection | undefined}
86
+ */
87
+ direction: {
88
+ type: String,
89
+ reflectToAttribute: true,
90
+ notify: true,
91
+ value: null,
92
+ sync: true,
93
+ },
94
+
95
+ /**
96
+ * @type {number | null}
97
+ * @protected
98
+ */
99
+ _order: {
100
+ type: Number,
101
+ value: null,
102
+ sync: true,
103
+ },
104
+
105
+ /** @private */
106
+ _isConnected: {
107
+ type: Boolean,
108
+ observer: '__isConnectedChanged',
109
+ },
110
+ };
111
+ }
112
+
113
+ static get observers() {
114
+ return ['_pathOrDirectionChanged(path, direction)'];
115
+ }
116
+
117
+ /** @protected */
118
+ ready() {
119
+ super.ready();
120
+ this.addEventListener('click', this._onClick.bind(this));
121
+ }
122
+
123
+ /** @protected */
124
+ connectedCallback() {
125
+ super.connectedCallback();
126
+ this._isConnected = true;
127
+ }
128
+
129
+ /** @protected */
130
+ disconnectedCallback() {
131
+ super.disconnectedCallback();
132
+ this._isConnected = false;
133
+
134
+ if (!this.parentNode && this._grid) {
135
+ this._grid.__removeSorters([this]);
136
+ }
137
+ }
138
+
139
+ /** @private */
140
+ _pathOrDirectionChanged() {
141
+ this.__dispatchSorterChangedEvenIfPossible();
142
+ }
143
+
144
+ /** @private */
145
+ __isConnectedChanged(newValue, oldValue) {
146
+ if (oldValue === false) {
147
+ return;
148
+ }
149
+
150
+ this.__dispatchSorterChangedEvenIfPossible();
151
+ }
152
+
153
+ /** @private */
154
+ __dispatchSorterChangedEvenIfPossible() {
155
+ if (this.path === undefined || this.direction === undefined || !this._isConnected) {
156
+ return;
157
+ }
158
+
159
+ this.dispatchEvent(
160
+ new CustomEvent('sorter-changed', {
161
+ detail: { shiftClick: Boolean(this._shiftClick), fromSorterClick: Boolean(this._fromSorterClick) },
162
+ bubbles: true,
163
+ composed: true,
164
+ }),
165
+ );
166
+ // Cleaning up as a programatically sorting can be done after some user interaction
167
+ this._fromSorterClick = false;
168
+ this._shiftClick = false;
169
+ }
170
+
171
+ /** @private */
172
+ _getDisplayOrder(order) {
173
+ return order === null ? '' : order + 1;
174
+ }
175
+
176
+ /** @private */
177
+ _onClick(e) {
178
+ if (e.defaultPrevented) {
179
+ // Something else has already handled the click event, do nothing.
180
+ return;
181
+ }
182
+
183
+ const activeElement = this.getRootNode().activeElement;
184
+ if (this !== activeElement && this.contains(activeElement)) {
185
+ // Some focusable content inside the sorter was clicked, do nothing.
186
+ return;
187
+ }
188
+
189
+ e.preventDefault();
190
+ this._shiftClick = e.shiftKey;
191
+ this._fromSorterClick = true;
192
+ if (this.direction === 'asc') {
193
+ this.direction = 'desc';
194
+ } else if (this.direction === 'desc') {
195
+ this.direction = null;
196
+ } else {
197
+ this.direction = 'asc';
198
+ }
199
+ }
200
+ };
@@ -5,26 +5,9 @@
5
5
  */
6
6
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
7
7
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
+ import { type GridSorterEventMap, GridSorterMixin } from './vaadin-grid-sorter-mixin.js';
8
9
 
9
- export type GridSorterDirection = 'asc' | 'desc' | null;
10
-
11
- /**
12
- * Fired when the `path` or `direction` property changes.
13
- */
14
- export type GridSorterChangedEvent = CustomEvent<{ shiftClick: boolean; fromSorterClick: boolean }>;
15
-
16
- /**
17
- * Fired when the `direction` property changes.
18
- */
19
- export type GridSorterDirectionChangedEvent = CustomEvent<{ value: GridSorterDirection }>;
20
-
21
- export interface GridSorterCustomEventMap {
22
- 'sorter-changed': GridSorterChangedEvent;
23
-
24
- 'direction-changed': GridSorterDirectionChangedEvent;
25
- }
26
-
27
- export interface GridSorterEventMap extends HTMLElementEventMap, GridSorterCustomEventMap {}
10
+ export * from './vaadin-grid-sorter-mixin.js';
28
11
 
29
12
  /**
30
13
  * `<vaadin-grid-sorter>` is a helper element for the `<vaadin-grid>` that provides out-of-the-box UI controls,
@@ -65,19 +48,7 @@ export interface GridSorterEventMap extends HTMLElementEventMap, GridSorterCusto
65
48
  * @fires {CustomEvent} direction-changed - Fired when the `direction` property changes.
66
49
  * @fires {CustomEvent} sorter-changed - Fired when the `path` or `direction` property changes.
67
50
  */
68
- declare class GridSorter extends ThemableMixin(DirMixin(HTMLElement)) {
69
- /**
70
- * JS Path of the property in the item used for sorting the data.
71
- */
72
- path: string | null | undefined;
73
-
74
- /**
75
- * How to sort the data.
76
- * Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
77
- * descending direction, or `null` for not sorting the data.
78
- */
79
- direction: GridSorterDirection | null | undefined;
80
-
51
+ declare class GridSorter extends GridSorterMixin(ThemableMixin(DirMixin(HTMLElement))) {
81
52
  addEventListener<K extends keyof GridSorterEventMap>(
82
53
  type: K,
83
54
  listener: (this: GridSorter, ev: GridSorterEventMap[K]) => void,