@vaadin/grid 24.2.0-dev.f254716fe → 24.3.0-alpha2
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-array-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-column-group-mixin.d.ts +20 -0
- package/src/vaadin-grid-column-group-mixin.js +369 -0
- package/src/vaadin-grid-column-group.d.ts +4 -14
- package/src/vaadin-grid-column-group.js +8 -356
- package/src/vaadin-grid-column-mixin.d.ts +156 -0
- package/src/vaadin-grid-column-mixin.js +887 -0
- package/src/vaadin-grid-column.d.ts +11 -138
- package/src/vaadin-grid-column.js +6 -876
- package/src/vaadin-grid-data-provider-mixin.d.ts +6 -5
- package/src/vaadin-grid-data-provider-mixin.js +51 -20
- package/src/vaadin-grid-drag-and-drop-mixin.js +1 -1
- package/src/vaadin-grid-dynamic-columns-mixin.js +1 -1
- package/src/vaadin-grid-filter-column.js +5 -1
- package/src/vaadin-grid-filter-element-mixin.d.ts +34 -0
- package/src/vaadin-grid-filter-element-mixin.js +99 -0
- package/src/vaadin-grid-filter.d.ts +4 -21
- package/src/vaadin-grid-filter.js +8 -85
- package/src/vaadin-grid-keyboard-navigation-mixin.js +24 -4
- package/src/vaadin-grid-mixin.d.ts +218 -0
- package/src/vaadin-grid-mixin.js +1022 -0
- package/src/vaadin-grid-scroll-mixin.js +1 -1
- package/src/vaadin-grid-selection-column-base-mixin.d.ts +6 -0
- package/src/vaadin-grid-selection-column-base-mixin.js +151 -0
- package/src/vaadin-grid-selection-column.js +4 -1
- package/src/vaadin-grid-sort-column.js +5 -1
- package/src/vaadin-grid-sorter-mixin.d.ts +44 -0
- package/src/vaadin-grid-sorter-mixin.js +198 -0
- package/src/vaadin-grid-sorter.d.ts +3 -32
- package/src/vaadin-grid-sorter.js +8 -182
- package/src/vaadin-grid-tree-column-mixin.d.ts +19 -0
- package/src/vaadin-grid-tree-column-mixin.js +92 -0
- package/src/vaadin-grid-tree-column.d.ts +9 -7
- package/src/vaadin-grid-tree-column.js +7 -82
- package/src/vaadin-grid-tree-toggle.js +3 -1
- package/src/vaadin-grid.d.ts +5 -190
- package/src/vaadin-grid.js +7 -1018
- package/web-types.json +2311 -0
- package/web-types.lit.json +1007 -0
|
@@ -4,23 +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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
7
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
8
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
-
|
|
10
|
-
const template = document.createElement('template');
|
|
11
|
-
|
|
12
|
-
template.innerHTML = `
|
|
13
|
-
<style>
|
|
14
|
-
@font-face {
|
|
15
|
-
font-family: 'vaadin-grid-sorter-icons';
|
|
16
|
-
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');
|
|
17
|
-
font-weight: normal;
|
|
18
|
-
font-style: normal;
|
|
19
|
-
}
|
|
20
|
-
</style>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
document.head.appendChild(template.content);
|
|
10
|
+
import { GridSorterMixin } from './vaadin-grid-sorter-mixin.js';
|
|
24
11
|
|
|
25
12
|
/**
|
|
26
13
|
* `<vaadin-grid-sorter>` is a helper element for the `<vaadin-grid>` that provides out-of-the-box UI controls,
|
|
@@ -61,51 +48,15 @@ document.head.appendChild(template.content);
|
|
|
61
48
|
* @fires {CustomEvent} direction-changed - Fired when the `direction` property changes.
|
|
62
49
|
* @fires {CustomEvent} sorter-changed - Fired when the `path` or `direction` property changes.
|
|
63
50
|
*
|
|
51
|
+
* @customElement
|
|
64
52
|
* @extends HTMLElement
|
|
53
|
+
* @mixes GridSorterMixin
|
|
54
|
+
* @mixes ThemableMixin
|
|
55
|
+
* @mixes DirMixin
|
|
65
56
|
*/
|
|
66
|
-
class GridSorter extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
57
|
+
class GridSorter extends GridSorterMixin(ThemableMixin(DirMixin(PolymerElement))) {
|
|
67
58
|
static get template() {
|
|
68
59
|
return html`
|
|
69
|
-
<style>
|
|
70
|
-
:host {
|
|
71
|
-
display: inline-flex;
|
|
72
|
-
cursor: pointer;
|
|
73
|
-
max-width: 100%;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
[part='content'] {
|
|
77
|
-
flex: 1 1 auto;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
[part='indicators'] {
|
|
81
|
-
position: relative;
|
|
82
|
-
align-self: center;
|
|
83
|
-
flex: none;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
[part='order'] {
|
|
87
|
-
display: inline;
|
|
88
|
-
vertical-align: super;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
[part='indicators']::before {
|
|
92
|
-
font-family: 'vaadin-grid-sorter-icons';
|
|
93
|
-
display: inline-block;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
:host(:not([direction])) [part='indicators']::before {
|
|
97
|
-
content: '\\e901';
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
:host([direction='asc']) [part='indicators']::before {
|
|
101
|
-
content: '\\e900';
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
:host([direction='desc']) [part='indicators']::before {
|
|
105
|
-
content: '\\e902';
|
|
106
|
-
}
|
|
107
|
-
</style>
|
|
108
|
-
|
|
109
60
|
<div part="content">
|
|
110
61
|
<slot></slot>
|
|
111
62
|
</div>
|
|
@@ -118,133 +69,8 @@ class GridSorter extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
118
69
|
static get is() {
|
|
119
70
|
return 'vaadin-grid-sorter';
|
|
120
71
|
}
|
|
121
|
-
|
|
122
|
-
static get properties() {
|
|
123
|
-
return {
|
|
124
|
-
/**
|
|
125
|
-
* JS Path of the property in the item used for sorting the data.
|
|
126
|
-
*/
|
|
127
|
-
path: String,
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* How to sort the data.
|
|
131
|
-
* Possible values are `asc` to use an ascending algorithm, `desc` to sort the data in
|
|
132
|
-
* descending direction, or `null` for not sorting the data.
|
|
133
|
-
* @type {GridSorterDirection | undefined}
|
|
134
|
-
*/
|
|
135
|
-
direction: {
|
|
136
|
-
type: String,
|
|
137
|
-
reflectToAttribute: true,
|
|
138
|
-
notify: true,
|
|
139
|
-
value: null,
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @type {number | null}
|
|
144
|
-
* @protected
|
|
145
|
-
*/
|
|
146
|
-
_order: {
|
|
147
|
-
type: Number,
|
|
148
|
-
value: null,
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/** @private */
|
|
152
|
-
_isConnected: {
|
|
153
|
-
type: Boolean,
|
|
154
|
-
observer: '__isConnectedChanged',
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
static get observers() {
|
|
160
|
-
return ['_pathOrDirectionChanged(path, direction)'];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** @protected */
|
|
164
|
-
ready() {
|
|
165
|
-
super.ready();
|
|
166
|
-
this.addEventListener('click', this._onClick.bind(this));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** @protected */
|
|
170
|
-
connectedCallback() {
|
|
171
|
-
super.connectedCallback();
|
|
172
|
-
this._isConnected = true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/** @protected */
|
|
176
|
-
disconnectedCallback() {
|
|
177
|
-
super.disconnectedCallback();
|
|
178
|
-
this._isConnected = false;
|
|
179
|
-
|
|
180
|
-
if (!this.parentNode && this._grid) {
|
|
181
|
-
this._grid.__removeSorters([this]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** @private */
|
|
186
|
-
_pathOrDirectionChanged() {
|
|
187
|
-
this.__dispatchSorterChangedEvenIfPossible();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** @private */
|
|
191
|
-
__isConnectedChanged(newValue, oldValue) {
|
|
192
|
-
if (oldValue === false) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
this.__dispatchSorterChangedEvenIfPossible();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** @private */
|
|
200
|
-
__dispatchSorterChangedEvenIfPossible() {
|
|
201
|
-
if (this.path === undefined || this.direction === undefined || !this._isConnected) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
this.dispatchEvent(
|
|
206
|
-
new CustomEvent('sorter-changed', {
|
|
207
|
-
detail: { shiftClick: Boolean(this._shiftClick), fromSorterClick: Boolean(this._fromSorterClick) },
|
|
208
|
-
bubbles: true,
|
|
209
|
-
composed: true,
|
|
210
|
-
}),
|
|
211
|
-
);
|
|
212
|
-
// Cleaning up as a programatically sorting can be done after some user interaction
|
|
213
|
-
this._fromSorterClick = false;
|
|
214
|
-
this._shiftClick = false;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** @private */
|
|
218
|
-
_getDisplayOrder(order) {
|
|
219
|
-
return order === null ? '' : order + 1;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/** @private */
|
|
223
|
-
_onClick(e) {
|
|
224
|
-
if (e.defaultPrevented) {
|
|
225
|
-
// Something else has already handled the click event, do nothing.
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const activeElement = this.getRootNode().activeElement;
|
|
230
|
-
if (this !== activeElement && this.contains(activeElement)) {
|
|
231
|
-
// Some focusable content inside the sorter was clicked, do nothing.
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
e.preventDefault();
|
|
236
|
-
this._shiftClick = e.shiftKey;
|
|
237
|
-
this._fromSorterClick = true;
|
|
238
|
-
if (this.direction === 'asc') {
|
|
239
|
-
this.direction = 'desc';
|
|
240
|
-
} else if (this.direction === 'desc') {
|
|
241
|
-
this.direction = null;
|
|
242
|
-
} else {
|
|
243
|
-
this.direction = 'asc';
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
72
|
}
|
|
247
73
|
|
|
248
|
-
|
|
74
|
+
defineCustomElement(GridSorter);
|
|
249
75
|
|
|
250
76
|
export { GridSorter };
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
8
|
+
import type { GridColumn } from './vaadin-grid-column.js';
|
|
9
|
+
|
|
10
|
+
export declare function GridTreeColumnMixin<TItem, T extends Constructor<GridColumn>>(
|
|
11
|
+
superclass: T,
|
|
12
|
+
): Constructor<GridTreeColumnMixinClass<TItem>> & T;
|
|
13
|
+
|
|
14
|
+
export declare class GridTreeColumnMixinClass<TItem> {
|
|
15
|
+
/**
|
|
16
|
+
* JS Path of the property in the item used as text content for the tree toggle.
|
|
17
|
+
*/
|
|
18
|
+
path: string | null | undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { get } from '@vaadin/component-base/src/path-utils.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @polymerMixin
|
|
10
|
+
*/
|
|
11
|
+
export const GridTreeColumnMixin = (superClass) =>
|
|
12
|
+
class extends superClass {
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
/**
|
|
16
|
+
* JS Path of the property in the item used as text content for the tree toggle.
|
|
17
|
+
*/
|
|
18
|
+
path: String,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static get observers() {
|
|
23
|
+
return ['_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
this.__boundOnExpandedChanged = this.__onExpandedChanged.bind(this);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Renders the grid tree toggle to the body cell
|
|
34
|
+
*
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
__defaultRenderer(root, _column, { item, expanded, level }) {
|
|
38
|
+
let toggle = root.firstElementChild;
|
|
39
|
+
if (!toggle) {
|
|
40
|
+
toggle = document.createElement('vaadin-grid-tree-toggle');
|
|
41
|
+
toggle.addEventListener('expanded-changed', this.__boundOnExpandedChanged);
|
|
42
|
+
root.appendChild(toggle);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toggle.__item = item;
|
|
46
|
+
toggle.__rendererExpanded = expanded;
|
|
47
|
+
toggle.expanded = expanded;
|
|
48
|
+
toggle.leaf = this.__isLeafItem(item, this._grid.itemHasChildrenPath);
|
|
49
|
+
toggle.textContent = this.__getToggleContent(this.path, item);
|
|
50
|
+
toggle.level = level;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The tree column doesn't allow to use a custom renderer
|
|
55
|
+
* to override the content of body cells.
|
|
56
|
+
* It always renders the grid tree toggle to body cells.
|
|
57
|
+
*
|
|
58
|
+
* @override
|
|
59
|
+
*/
|
|
60
|
+
_computeRenderer() {
|
|
61
|
+
return this.__defaultRenderer;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Expands or collapses the row once the tree toggle is switched.
|
|
66
|
+
* The listener handles only user-fired events.
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
__onExpandedChanged(e) {
|
|
71
|
+
// Skip if the state is changed by the renderer.
|
|
72
|
+
if (e.detail.value === e.target.__rendererExpanded) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (e.detail.value) {
|
|
77
|
+
this._grid.expandItem(e.target.__item);
|
|
78
|
+
} else {
|
|
79
|
+
this._grid.collapseItem(e.target.__item);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @private */
|
|
84
|
+
__isLeafItem(item, itemHasChildrenPath) {
|
|
85
|
+
return !item || !item[itemHasChildrenPath];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @private */
|
|
89
|
+
__getToggleContent(path, item) {
|
|
90
|
+
return path && get(path, item);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -4,7 +4,8 @@
|
|
|
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';
|
|
7
|
+
import type { GridColumn, GridColumnMixin } from './vaadin-grid-column.js';
|
|
8
|
+
import type { GridTreeColumnMixinClass } from './vaadin-grid-tree-column-mixin.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* `<vaadin-grid-tree-column>` is a helper element for the `<vaadin-grid>`
|
|
@@ -19,12 +20,13 @@ import { GridColumn } from './vaadin-grid-column.js';
|
|
|
19
20
|
* ...
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
|
|
24
|
+
declare class GridTreeColumn<TItem = GridDefaultItem> extends HTMLElement {}
|
|
25
|
+
|
|
26
|
+
interface GridTreeColumn<TItem = GridDefaultItem>
|
|
27
|
+
extends GridTreeColumnMixinClass<TItem>,
|
|
28
|
+
GridColumnMixin<TItem, GridTreeColumn<TItem>>,
|
|
29
|
+
GridColumn<TItem> {}
|
|
28
30
|
|
|
29
31
|
declare global {
|
|
30
32
|
interface HTMLElementTagNameMap {
|
|
@@ -4,7 +4,9 @@
|
|
|
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 { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
7
8
|
import { GridColumn } from './vaadin-grid-column.js';
|
|
9
|
+
import { GridTreeColumnMixin } from './vaadin-grid-tree-column-mixin.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* `<vaadin-grid-tree-column>` is a helper element for the `<vaadin-grid>`
|
|
@@ -18,93 +20,16 @@ import { GridColumn } from './vaadin-grid-column.js';
|
|
|
18
20
|
* <vaadin-grid-column>
|
|
19
21
|
* ...
|
|
20
22
|
* ```
|
|
23
|
+
* @customElement
|
|
24
|
+
* @extends GridColumn
|
|
25
|
+
* @mixes GridTreeColumnMixin
|
|
21
26
|
*/
|
|
22
|
-
class GridTreeColumn extends GridColumn {
|
|
27
|
+
class GridTreeColumn extends GridTreeColumnMixin(GridColumn) {
|
|
23
28
|
static get is() {
|
|
24
29
|
return 'vaadin-grid-tree-column';
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
static get properties() {
|
|
28
|
-
return {
|
|
29
|
-
/**
|
|
30
|
-
* JS Path of the property in the item used as text content for the tree toggle.
|
|
31
|
-
*/
|
|
32
|
-
path: String,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static get observers() {
|
|
37
|
-
return ['_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path)'];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
constructor() {
|
|
41
|
-
super();
|
|
42
|
-
|
|
43
|
-
this.__boundOnExpandedChanged = this.__onExpandedChanged.bind(this);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Renders the grid tree toggle to the body cell
|
|
48
|
-
*
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
__defaultRenderer(root, _column, { item, expanded, level }) {
|
|
52
|
-
let toggle = root.firstElementChild;
|
|
53
|
-
if (!toggle) {
|
|
54
|
-
toggle = document.createElement('vaadin-grid-tree-toggle');
|
|
55
|
-
toggle.addEventListener('expanded-changed', this.__boundOnExpandedChanged);
|
|
56
|
-
root.appendChild(toggle);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
toggle.__item = item;
|
|
60
|
-
toggle.__rendererExpanded = expanded;
|
|
61
|
-
toggle.expanded = expanded;
|
|
62
|
-
toggle.leaf = this.__isLeafItem(item, this._grid.itemHasChildrenPath);
|
|
63
|
-
toggle.textContent = this.__getToggleContent(this.path, item);
|
|
64
|
-
toggle.level = level;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The tree column doesn't allow to use a custom renderer
|
|
69
|
-
* to override the content of body cells.
|
|
70
|
-
* It always renders the grid tree toggle to body cells.
|
|
71
|
-
*
|
|
72
|
-
* @override
|
|
73
|
-
*/
|
|
74
|
-
_computeRenderer() {
|
|
75
|
-
return this.__defaultRenderer;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Expands or collapses the row once the tree toggle is switched.
|
|
80
|
-
* The listener handles only user-fired events.
|
|
81
|
-
*
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
__onExpandedChanged(e) {
|
|
85
|
-
// Skip if the state is changed by the renderer.
|
|
86
|
-
if (e.detail.value === e.target.__rendererExpanded) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (e.detail.value) {
|
|
91
|
-
this._grid.expandItem(e.target.__item);
|
|
92
|
-
} else {
|
|
93
|
-
this._grid.collapseItem(e.target.__item);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** @private */
|
|
98
|
-
__isLeafItem(item, itemHasChildrenPath) {
|
|
99
|
-
return !item || !item[itemHasChildrenPath];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** @private */
|
|
103
|
-
__getToggleContent(path, item) {
|
|
104
|
-
return path && this.get(path, item);
|
|
105
|
-
}
|
|
106
31
|
}
|
|
107
32
|
|
|
108
|
-
|
|
33
|
+
defineCustomElement(GridTreeColumn);
|
|
109
34
|
|
|
110
35
|
export { GridTreeColumn };
|
|
@@ -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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
7
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
8
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
10
|
import { isFocusable } from './vaadin-grid-active-item-mixin.js';
|
|
@@ -71,6 +72,7 @@ document.head.appendChild(template.content);
|
|
|
71
72
|
*
|
|
72
73
|
* @fires {CustomEvent} expanded-changed - Fired when the `expanded` property changes.
|
|
73
74
|
*
|
|
75
|
+
* @customElement
|
|
74
76
|
* @extends HTMLElement
|
|
75
77
|
* @mixes ThemableMixin
|
|
76
78
|
*/
|
|
@@ -207,6 +209,6 @@ class GridTreeToggle extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
|
|
210
|
-
|
|
212
|
+
defineCustomElement(GridTreeToggle);
|
|
211
213
|
|
|
212
214
|
export { GridTreeToggle };
|