@vaadin/grid 24.2.0-beta3 → 24.2.0-beta4
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 +10 -10
- package/src/vaadin-grid-array-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-column-group.d.ts +14 -4
- package/src/vaadin-grid-column-group.js +355 -5
- package/src/vaadin-grid-column.d.ts +138 -11
- package/src/vaadin-grid-column.js +876 -3
- package/src/vaadin-grid-data-provider-mixin.d.ts +30 -6
- package/src/vaadin-grid-data-provider-mixin.js +241 -100
- package/src/vaadin-grid-drag-and-drop-mixin.js +1 -1
- package/src/vaadin-grid-filter.d.ts +21 -4
- package/src/vaadin-grid-filter.js +84 -5
- package/src/vaadin-grid-keyboard-navigation-mixin.js +2 -2
- package/src/vaadin-grid-mixin.js +10 -10
- package/src/vaadin-grid-scroll-mixin.js +1 -1
- package/src/vaadin-grid-sorter.d.ts +32 -3
- package/src/vaadin-grid-sorter.js +181 -5
- package/src/vaadin-grid-tree-column.d.ts +7 -9
- package/src/vaadin-grid-tree-column.js +82 -3
- package/src/vaadin-grid-tree-toggle.d.ts +27 -4
- package/src/vaadin-grid-tree-toggle.js +141 -9
- package/web-types.json +98 -98
- package/web-types.lit.json +42 -42
- package/src/vaadin-grid-column-group-mixin.d.ts +0 -20
- package/src/vaadin-grid-column-group-mixin.js +0 -369
- package/src/vaadin-grid-column-mixin.d.ts +0 -156
- package/src/vaadin-grid-column-mixin.js +0 -887
- package/src/vaadin-grid-filter-element-mixin.d.ts +0 -34
- package/src/vaadin-grid-filter-element-mixin.js +0 -99
- package/src/vaadin-grid-sorter-mixin.d.ts +0 -44
- package/src/vaadin-grid-sorter-mixin.js +0 -198
- package/src/vaadin-grid-tree-column-mixin.d.ts +0 -19
- package/src/vaadin-grid-tree-column-mixin.js +0 -92
- package/src/vaadin-grid-tree-toggle-mixin.d.ts +0 -39
- package/src/vaadin-grid-tree-toggle-mixin.js +0 -151
|
@@ -1,34 +0,0 @@
|
|
|
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 { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Fired when the `value` property changes.
|
|
11
|
-
*/
|
|
12
|
-
export type GridFilterValueChangedEvent = CustomEvent<{ value: string }>;
|
|
13
|
-
|
|
14
|
-
export interface GridFilterCustomEventMap {
|
|
15
|
-
'value-changed': GridFilterValueChangedEvent;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface GridFilterEventMap extends HTMLElementEventMap, GridFilterCustomEventMap {}
|
|
19
|
-
|
|
20
|
-
export declare function GridFilterElementMixin<T extends Constructor<HTMLElement>>(
|
|
21
|
-
base: T,
|
|
22
|
-
): Constructor<ControllerMixinClass> & Constructor<GridFilterElementMixinClass> & T;
|
|
23
|
-
|
|
24
|
-
declare class GridFilterElementMixinClass {
|
|
25
|
-
/**
|
|
26
|
-
* JS Path of the property in the item used for filtering the data.
|
|
27
|
-
*/
|
|
28
|
-
path: string | null | undefined;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Current filter value.
|
|
32
|
-
*/
|
|
33
|
-
value: string | null | undefined;
|
|
34
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
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 { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
-
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
|
-
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
10
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin';
|
|
11
|
-
|
|
12
|
-
registerStyles(
|
|
13
|
-
'vaadin-grid-filter',
|
|
14
|
-
css`
|
|
15
|
-
:host {
|
|
16
|
-
display: inline-flex;
|
|
17
|
-
max-width: 100%;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
::slotted(*) {
|
|
21
|
-
width: 100%;
|
|
22
|
-
box-sizing: border-box;
|
|
23
|
-
}
|
|
24
|
-
`,
|
|
25
|
-
{ moduleId: 'vaadin-grid-filter-styles' },
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @polymerMixin
|
|
30
|
-
*
|
|
31
|
-
* @mixes ControllerMixin
|
|
32
|
-
*/
|
|
33
|
-
export const GridFilterElementMixin = (superClass) =>
|
|
34
|
-
class extends ControllerMixin(superClass) {
|
|
35
|
-
static get properties() {
|
|
36
|
-
return {
|
|
37
|
-
/**
|
|
38
|
-
* JS Path of the property in the item used for filtering the data.
|
|
39
|
-
*/
|
|
40
|
-
path: String,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Current filter value.
|
|
44
|
-
*/
|
|
45
|
-
value: {
|
|
46
|
-
type: String,
|
|
47
|
-
notify: true,
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
/** @private */
|
|
51
|
-
_textField: {
|
|
52
|
-
type: Object,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static get observers() {
|
|
58
|
-
return ['_filterChanged(path, value, _textField)'];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** @protected */
|
|
62
|
-
ready() {
|
|
63
|
-
super.ready();
|
|
64
|
-
|
|
65
|
-
this._filterController = new SlotController(this, '', 'vaadin-text-field', {
|
|
66
|
-
initializer: (field) => {
|
|
67
|
-
field.addEventListener('value-changed', (e) => {
|
|
68
|
-
this.value = e.detail.value;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
this._textField = field;
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
this.addController(this._filterController);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** @private */
|
|
78
|
-
_filterChanged(path, value, textField) {
|
|
79
|
-
if (path === undefined || value === undefined || !textField) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (this._previousValue === undefined && value === '') {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
textField.value = value;
|
|
87
|
-
this._previousValue = value;
|
|
88
|
-
|
|
89
|
-
this._debouncerFilterChanged = Debouncer.debounce(this._debouncerFilterChanged, timeOut.after(200), () => {
|
|
90
|
-
this.dispatchEvent(new CustomEvent('filter-changed', { bubbles: true }));
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
focus() {
|
|
95
|
-
if (this._textField) {
|
|
96
|
-
this._textField.focus();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
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+mUdERUYAAAP4AAAAH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BqrFENH7t3qWtj0OuqHnXcW7b0HOTZFnKryRGW2hFX1m0O2vEM3opNMfTau+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
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @type {number | null}
|
|
96
|
-
* @protected
|
|
97
|
-
*/
|
|
98
|
-
_order: {
|
|
99
|
-
type: Number,
|
|
100
|
-
value: null,
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/** @private */
|
|
104
|
-
_isConnected: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
observer: '__isConnectedChanged',
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static get observers() {
|
|
112
|
-
return ['_pathOrDirectionChanged(path, direction)'];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** @protected */
|
|
116
|
-
ready() {
|
|
117
|
-
super.ready();
|
|
118
|
-
this.addEventListener('click', this._onClick.bind(this));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** @protected */
|
|
122
|
-
connectedCallback() {
|
|
123
|
-
super.connectedCallback();
|
|
124
|
-
this._isConnected = true;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** @protected */
|
|
128
|
-
disconnectedCallback() {
|
|
129
|
-
super.disconnectedCallback();
|
|
130
|
-
this._isConnected = false;
|
|
131
|
-
|
|
132
|
-
if (!this.parentNode && this._grid) {
|
|
133
|
-
this._grid.__removeSorters([this]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** @private */
|
|
138
|
-
_pathOrDirectionChanged() {
|
|
139
|
-
this.__dispatchSorterChangedEvenIfPossible();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** @private */
|
|
143
|
-
__isConnectedChanged(newValue, oldValue) {
|
|
144
|
-
if (oldValue === false) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
this.__dispatchSorterChangedEvenIfPossible();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/** @private */
|
|
152
|
-
__dispatchSorterChangedEvenIfPossible() {
|
|
153
|
-
if (this.path === undefined || this.direction === undefined || !this._isConnected) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.dispatchEvent(
|
|
158
|
-
new CustomEvent('sorter-changed', {
|
|
159
|
-
detail: { shiftClick: Boolean(this._shiftClick), fromSorterClick: Boolean(this._fromSorterClick) },
|
|
160
|
-
bubbles: true,
|
|
161
|
-
composed: true,
|
|
162
|
-
}),
|
|
163
|
-
);
|
|
164
|
-
// Cleaning up as a programatically sorting can be done after some user interaction
|
|
165
|
-
this._fromSorterClick = false;
|
|
166
|
-
this._shiftClick = false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** @private */
|
|
170
|
-
_getDisplayOrder(order) {
|
|
171
|
-
return order === null ? '' : order + 1;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/** @private */
|
|
175
|
-
_onClick(e) {
|
|
176
|
-
if (e.defaultPrevented) {
|
|
177
|
-
// Something else has already handled the click event, do nothing.
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const activeElement = this.getRootNode().activeElement;
|
|
182
|
-
if (this !== activeElement && this.contains(activeElement)) {
|
|
183
|
-
// Some focusable content inside the sorter was clicked, do nothing.
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
e.preventDefault();
|
|
188
|
-
this._shiftClick = e.shiftKey;
|
|
189
|
-
this._fromSorterClick = true;
|
|
190
|
-
if (this.direction === 'asc') {
|
|
191
|
-
this.direction = 'desc';
|
|
192
|
-
} else if (this.direction === 'desc') {
|
|
193
|
-
this.direction = null;
|
|
194
|
-
} else {
|
|
195
|
-
this.direction = 'asc';
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
/**
|
|
9
|
-
* Fired when the `expanded` property changes.
|
|
10
|
-
*/
|
|
11
|
-
export type GridTreeToggleExpandedChangedEvent = CustomEvent<{ value: boolean }>;
|
|
12
|
-
|
|
13
|
-
export interface GridTreeToggleCustomEventMap {
|
|
14
|
-
'expanded-changed': GridTreeToggleExpandedChangedEvent;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GridTreeToggleEventMap extends HTMLElementEventMap, GridTreeToggleCustomEventMap {}
|
|
18
|
-
|
|
19
|
-
export declare function GridTreeToggleMixin<T extends Constructor<HTMLElement>>(
|
|
20
|
-
base: T,
|
|
21
|
-
): Constructor<GridTreeToggleMixinClass> & T;
|
|
22
|
-
|
|
23
|
-
declare class GridTreeToggleMixinClass {
|
|
24
|
-
/**
|
|
25
|
-
* Current level of the tree represented with a horizontal offset
|
|
26
|
-
* of the toggle button.
|
|
27
|
-
*/
|
|
28
|
-
level: number;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Hides the toggle icon and disables toggling a tree sublevel.
|
|
32
|
-
*/
|
|
33
|
-
leaf: boolean;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Sublevel toggle state.
|
|
37
|
-
*/
|
|
38
|
-
expanded: boolean;
|
|
39
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
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
|
-
import { isFocusable } from './vaadin-grid-active-item-mixin.js';
|
|
8
|
-
|
|
9
|
-
const template = document.createElement('template');
|
|
10
|
-
|
|
11
|
-
template.innerHTML = `
|
|
12
|
-
<style>
|
|
13
|
-
@font-face {
|
|
14
|
-
font-family: "vaadin-grid-tree-icons";
|
|
15
|
-
src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQkAA0AAAAABrwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAECAAAABoAAAAcgHwa6EdERUYAAAPsAAAAHAAAAB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Bj0VQ8cRni2xjLWsHaM0jrjx3peYA0/vrdmUYqe9iy7bzrX6eNP7Jh1SijX+AaUVbB8AAHicY2BiwA84GBgYmRiYGJkZmBlZGFkZ2djScyoLMgzZS/MyDQwMwLSruZMzlHaB0q4A76kLlwAAAAEAAf//AA94nGNgZGBg4AFiMSBmYmAEQnYgZgHzGAAD6wA2eJxjYGBgZACCKxJigiD6mhFTNowGACmcA/8AAA==) format('woff');
|
|
16
|
-
font-weight: normal;
|
|
17
|
-
font-style: normal;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
document.head.appendChild(template.content);
|
|
23
|
-
|
|
24
|
-
registerStyles(
|
|
25
|
-
'vaadin-grid-tree-toggle',
|
|
26
|
-
css`
|
|
27
|
-
:host {
|
|
28
|
-
display: inline-flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
max-width: 100%;
|
|
31
|
-
|
|
32
|
-
/* CSS API for :host */
|
|
33
|
-
--vaadin-grid-tree-toggle-level-offset: 1em;
|
|
34
|
-
--_collapsed-icon: '\\e7be\\00a0';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
:host([dir='rtl']) {
|
|
38
|
-
--_collapsed-icon: '\\e7bd\\00a0';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:host([hidden]) {
|
|
42
|
-
display: none !important;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
:host(:not([leaf])) {
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
#level-spacer,
|
|
50
|
-
[part='toggle'] {
|
|
51
|
-
flex: none;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
#level-spacer {
|
|
55
|
-
display: inline-block;
|
|
56
|
-
width: calc(var(---level, '0') * var(--vaadin-grid-tree-toggle-level-offset));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
[part='toggle']::before {
|
|
60
|
-
font-family: 'vaadin-grid-tree-icons';
|
|
61
|
-
line-height: 1em; /* make icon font metrics not affect baseline */
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
:host(:not([expanded])) [part='toggle']::before {
|
|
65
|
-
content: var(--_collapsed-icon);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
:host([expanded]) [part='toggle']::before {
|
|
69
|
-
content: '\\e7bc\\00a0'; /* icon glyph + single non-breaking space */
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([leaf]) [part='toggle'] {
|
|
73
|
-
visibility: hidden;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
slot {
|
|
77
|
-
display: block;
|
|
78
|
-
overflow: hidden;
|
|
79
|
-
text-overflow: ellipsis;
|
|
80
|
-
}
|
|
81
|
-
`,
|
|
82
|
-
{ moduleId: 'vaadin-grid-tree-toggle-styles' },
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @polymerMixin
|
|
87
|
-
*/
|
|
88
|
-
export const GridTreeToggleMixin = (superClass) =>
|
|
89
|
-
class extends superClass {
|
|
90
|
-
static get properties() {
|
|
91
|
-
return {
|
|
92
|
-
/**
|
|
93
|
-
* Current level of the tree represented with a horizontal offset
|
|
94
|
-
* of the toggle button.
|
|
95
|
-
* @type {number}
|
|
96
|
-
*/
|
|
97
|
-
level: {
|
|
98
|
-
type: Number,
|
|
99
|
-
value: 0,
|
|
100
|
-
observer: '_levelChanged',
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Hides the toggle icon and disables toggling a tree sublevel.
|
|
105
|
-
* @type {boolean}
|
|
106
|
-
*/
|
|
107
|
-
leaf: {
|
|
108
|
-
type: Boolean,
|
|
109
|
-
value: false,
|
|
110
|
-
reflectToAttribute: true,
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Sublevel toggle state.
|
|
115
|
-
* @type {boolean}
|
|
116
|
-
*/
|
|
117
|
-
expanded: {
|
|
118
|
-
type: Boolean,
|
|
119
|
-
value: false,
|
|
120
|
-
reflectToAttribute: true,
|
|
121
|
-
notify: true,
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** @protected */
|
|
127
|
-
ready() {
|
|
128
|
-
super.ready();
|
|
129
|
-
|
|
130
|
-
this.addEventListener('click', (e) => this._onClick(e));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** @private */
|
|
134
|
-
_onClick(e) {
|
|
135
|
-
if (this.leaf) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (isFocusable(e.target) || e.target instanceof HTMLLabelElement) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
e.preventDefault();
|
|
143
|
-
this.expanded = !this.expanded;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** @private */
|
|
147
|
-
_levelChanged(level) {
|
|
148
|
-
const value = Number(level).toString();
|
|
149
|
-
this.style.setProperty('---level', value);
|
|
150
|
-
}
|
|
151
|
-
};
|