@progress/kendo-angular-treeview 5.4.2-dev.202111011443 → 6.0.0-dev.202112021059
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/dist/cdn/js/kendo-angular-treeview.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/check.directive.js +30 -39
- package/dist/es/expand.directive.js +40 -41
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/selection/select.directive.js +22 -28
- package/dist/es/treeview.component.js +23 -10
- package/dist/es/utils.js +4 -6
- package/dist/es2015/check.directive.d.ts +8 -1
- package/dist/es2015/check.directive.js +30 -35
- package/dist/es2015/expand.directive.d.ts +12 -3
- package/dist/es2015/expand.directive.js +39 -36
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/selection/select.directive.d.ts +11 -3
- package/dist/es2015/selection/select.directive.js +22 -24
- package/dist/es2015/treeview-filter-settings.d.ts +2 -0
- package/dist/es2015/treeview.component.d.ts +20 -5
- package/dist/es2015/treeview.component.js +24 -11
- package/dist/es2015/utils.d.ts +2 -3
- package/dist/es2015/utils.js +4 -6
- package/dist/fesm2015/index.js +117 -113
- package/dist/fesm5/index.js +117 -125
- package/dist/npm/check.directive.js +30 -39
- package/dist/npm/expand.directive.js +40 -41
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/selection/select.directive.js +22 -28
- package/dist/npm/treeview.component.js +23 -10
- package/dist/npm/utils.js +4 -6
- package/dist/systemjs/kendo-angular-treeview.js +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { TreeViewComponent } from './treeview.component';
|
|
|
8
8
|
import { fetchLoadedDescendants, isBoolean, isPresent, noop } from './utils';
|
|
9
9
|
import { Subscription } from 'rxjs';
|
|
10
10
|
import { filter, take, switchMap, tap } from 'rxjs/operators';
|
|
11
|
+
import { isChanged } from '@progress/kendo-angular-common';
|
|
11
12
|
const indexChecked = (keys, index) => keys.filter(k => k === index).length > 0;
|
|
12
13
|
const ɵ0 = indexChecked;
|
|
13
14
|
const matchKey = index => k => {
|
|
@@ -44,7 +45,10 @@ let CheckDirective = class CheckDirective {
|
|
|
44
45
|
'multiple': (e) => this.checkMultiple(e),
|
|
45
46
|
'single': (e) => this.checkSingle(e)
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Reflectes the internal `checkedKeys` state.
|
|
50
|
+
*/
|
|
51
|
+
this.state = new Set();
|
|
48
52
|
this.subscriptions.add(this.treeView.checkedChange
|
|
49
53
|
.subscribe((e) => this.check(e)));
|
|
50
54
|
let expandedItems = [];
|
|
@@ -59,16 +63,6 @@ let CheckDirective = class CheckDirective {
|
|
|
59
63
|
set isChecked(value) {
|
|
60
64
|
this.treeView.isChecked = value;
|
|
61
65
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Defines the collection that will store the checked keys
|
|
64
|
-
* ([see example]({% slug checkboxes_treeview %})).
|
|
65
|
-
*/
|
|
66
|
-
get checkedKeys() {
|
|
67
|
-
return this._checkedKeys;
|
|
68
|
-
}
|
|
69
|
-
set checkedKeys(keys) {
|
|
70
|
-
this._checkedKeys = keys;
|
|
71
|
-
}
|
|
72
66
|
get options() {
|
|
73
67
|
const defaultOptions = {
|
|
74
68
|
checkChildren: true,
|
|
@@ -89,6 +83,9 @@ let CheckDirective = class CheckDirective {
|
|
|
89
83
|
this.treeView.checkboxes = this.options.enabled;
|
|
90
84
|
this.toggleCheckOnClick();
|
|
91
85
|
}
|
|
86
|
+
if (isChanged('checkedKeys', changes, false) && changes.checkedKeys.currentValue !== this.lastChange) {
|
|
87
|
+
this.state = new Set(changes.checkedKeys.currentValue);
|
|
88
|
+
}
|
|
92
89
|
}
|
|
93
90
|
ngOnDestroy() {
|
|
94
91
|
this.subscriptions.unsubscribe();
|
|
@@ -98,11 +95,11 @@ let CheckDirective = class CheckDirective {
|
|
|
98
95
|
if (!this.checkKey) {
|
|
99
96
|
return this.isIndexChecked(index);
|
|
100
97
|
}
|
|
101
|
-
const
|
|
102
|
-
return
|
|
98
|
+
const hasKey = this.state.has(this.itemKey({ dataItem, index }));
|
|
99
|
+
return hasKey ? 'checked' : 'none';
|
|
103
100
|
}
|
|
104
101
|
isIndexChecked(index) {
|
|
105
|
-
const checkedKeys = this.
|
|
102
|
+
const checkedKeys = Array.from(this.state).filter(matchKey(index));
|
|
106
103
|
if (indexChecked(checkedKeys, index)) {
|
|
107
104
|
return 'checked';
|
|
108
105
|
}
|
|
@@ -133,7 +130,11 @@ let CheckDirective = class CheckDirective {
|
|
|
133
130
|
}
|
|
134
131
|
checkSingle(node) {
|
|
135
132
|
const key = this.itemKey(node.item);
|
|
136
|
-
|
|
133
|
+
const hasKey = this.state.has(key);
|
|
134
|
+
this.state.clear();
|
|
135
|
+
if (!hasKey) {
|
|
136
|
+
this.state.add(key);
|
|
137
|
+
}
|
|
137
138
|
this.notify();
|
|
138
139
|
}
|
|
139
140
|
checkMultiple(node) {
|
|
@@ -168,7 +169,6 @@ let CheckDirective = class CheckDirective {
|
|
|
168
169
|
if (!isPresent(currentKey)) {
|
|
169
170
|
return;
|
|
170
171
|
}
|
|
171
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
172
172
|
const pendingCheck = [currentKey];
|
|
173
173
|
if (this.options.checkChildren) {
|
|
174
174
|
const descendants = fetchLoadedDescendants(node, ({ item }) => this.treeView.isVisible(item.dataItem, item.index) &&
|
|
@@ -176,61 +176,57 @@ let CheckDirective = class CheckDirective {
|
|
|
176
176
|
.map(({ item }) => this.itemKey(item));
|
|
177
177
|
pendingCheck.push(...descendants);
|
|
178
178
|
}
|
|
179
|
-
const shouldCheck = !
|
|
179
|
+
const shouldCheck = !this.state.has(currentKey);
|
|
180
180
|
pendingCheck.forEach(key => {
|
|
181
181
|
if (shouldCheck) {
|
|
182
|
-
|
|
182
|
+
this.state.add(key);
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
|
-
|
|
185
|
+
this.state.delete(key);
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
189
188
|
}
|
|
190
189
|
checkParents(parent) {
|
|
191
190
|
if (!isPresent(parent)) {
|
|
192
191
|
return;
|
|
193
192
|
}
|
|
194
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
195
193
|
let currentParent = parent;
|
|
196
194
|
while (currentParent) {
|
|
197
195
|
const parentKey = this.itemKey(currentParent.item);
|
|
198
|
-
const allChildrenSelected = currentParent.children.every(item =>
|
|
196
|
+
const allChildrenSelected = currentParent.children.every(item => this.state.has(this.itemKey(item)));
|
|
199
197
|
if (allChildrenSelected) {
|
|
200
|
-
|
|
198
|
+
this.state.add(parentKey);
|
|
201
199
|
}
|
|
202
200
|
else {
|
|
203
|
-
|
|
201
|
+
this.state.delete(parentKey);
|
|
204
202
|
}
|
|
205
203
|
currentParent = currentParent.parent;
|
|
206
204
|
}
|
|
207
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
208
205
|
}
|
|
209
206
|
notify() {
|
|
210
|
-
this.
|
|
207
|
+
this.lastChange = Array.from(this.state);
|
|
208
|
+
this.checkedKeysChange.emit(this.lastChange);
|
|
211
209
|
}
|
|
212
210
|
addCheckedItemsChildren(lookups) {
|
|
213
211
|
if (!isPresent(lookups) || lookups.length === 0) {
|
|
214
212
|
return;
|
|
215
213
|
}
|
|
216
|
-
const initiallyCheckedItemsCount = this.
|
|
217
|
-
const checkedKeys = new Set(this.checkedKeys);
|
|
214
|
+
const initiallyCheckedItemsCount = this.state.size;
|
|
218
215
|
lookups.forEach(lookup => {
|
|
219
216
|
const itemKey = this.itemKey(lookup.item);
|
|
220
|
-
if (!
|
|
217
|
+
if (!this.state.has(itemKey)) {
|
|
221
218
|
return;
|
|
222
219
|
}
|
|
223
220
|
lookup.children.forEach(item => {
|
|
224
221
|
// ensure both the parent item and each child node is enabled
|
|
225
222
|
if (!this.treeView.isDisabled(lookup.item.dataItem, lookup.item.index) &&
|
|
226
223
|
!this.treeView.isDisabled(item.dataItem, item.index)) {
|
|
227
|
-
|
|
224
|
+
this.state.add(this.itemKey(item));
|
|
228
225
|
}
|
|
229
226
|
});
|
|
230
227
|
});
|
|
231
|
-
const hasNewlyCheckedItems = initiallyCheckedItemsCount !==
|
|
228
|
+
const hasNewlyCheckedItems = initiallyCheckedItemsCount !== this.state.size;
|
|
232
229
|
if (hasNewlyCheckedItems) {
|
|
233
|
-
this.checkedKeys = Array.from(checkedKeys);
|
|
234
230
|
this.zone.run(() => this.notify());
|
|
235
231
|
}
|
|
236
232
|
}
|
|
@@ -246,9 +242,8 @@ tslib_1.__decorate([
|
|
|
246
242
|
], CheckDirective.prototype, "checkKey", void 0);
|
|
247
243
|
tslib_1.__decorate([
|
|
248
244
|
Input(),
|
|
249
|
-
tslib_1.__metadata("design:type", Array)
|
|
250
|
-
|
|
251
|
-
], CheckDirective.prototype, "checkedKeys", null);
|
|
245
|
+
tslib_1.__metadata("design:type", Array)
|
|
246
|
+
], CheckDirective.prototype, "checkedKeys", void 0);
|
|
252
247
|
tslib_1.__decorate([
|
|
253
248
|
Input('kendoTreeViewCheckable'),
|
|
254
249
|
tslib_1.__metadata("design:type", Object)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { EventEmitter, OnDestroy } from '@angular/core';
|
|
5
|
+
import { EventEmitter, OnDestroy, SimpleChanges, OnChanges } from '@angular/core';
|
|
6
6
|
import { ExpandableComponent } from './expandable-component';
|
|
7
7
|
import { Subscription } from 'rxjs';
|
|
8
8
|
import { TreeItem } from './treeitem.interface';
|
|
@@ -17,7 +17,7 @@ interface ExpandTreeItem extends TreeItem {
|
|
|
17
17
|
* A directive which manages the expanded state of the TreeView.
|
|
18
18
|
* ([see example]({% slug expandedstate_treeview %})).
|
|
19
19
|
*/
|
|
20
|
-
export declare class ExpandDirective implements OnDestroy {
|
|
20
|
+
export declare class ExpandDirective implements OnDestroy, OnChanges {
|
|
21
21
|
protected component: ExpandableComponent;
|
|
22
22
|
/**
|
|
23
23
|
* @hidden
|
|
@@ -43,10 +43,18 @@ export declare class ExpandDirective implements OnDestroy {
|
|
|
43
43
|
*/
|
|
44
44
|
expandedKeys: any[];
|
|
45
45
|
protected subscriptions: Subscription;
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Reflectes the internal `expandedKeys` state.
|
|
48
|
+
*/
|
|
49
|
+
private state;
|
|
47
50
|
private originalExpandedKeys;
|
|
48
51
|
private isFiltered;
|
|
52
|
+
/**
|
|
53
|
+
* Holds the last emitted `expandedKeys` collection.
|
|
54
|
+
*/
|
|
55
|
+
private lastChange;
|
|
49
56
|
constructor(component: ExpandableComponent);
|
|
57
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
50
58
|
ngOnDestroy(): void;
|
|
51
59
|
/**
|
|
52
60
|
* @hidden
|
|
@@ -62,5 +70,6 @@ export declare class ExpandDirective implements OnDestroy {
|
|
|
62
70
|
* Fills array with the expand key of every node.
|
|
63
71
|
*/
|
|
64
72
|
private getEveryExpandKey;
|
|
73
|
+
private notify;
|
|
65
74
|
}
|
|
66
75
|
export {};
|
|
@@ -8,6 +8,7 @@ import { ExpandableComponent } from './expandable-component';
|
|
|
8
8
|
import { Subscription, merge } from 'rxjs';
|
|
9
9
|
import { map } from 'rxjs/operators';
|
|
10
10
|
import { isArrayWithAtLeastOneItem, isBoolean, sameValues } from './utils';
|
|
11
|
+
import { isChanged } from '@progress/kendo-angular-common';
|
|
11
12
|
const DEFAULT_FILTER_EXPAND_SETTINGS = {
|
|
12
13
|
maxAutoExpandResults: -1,
|
|
13
14
|
expandMatches: false,
|
|
@@ -31,8 +32,11 @@ let ExpandDirective = class ExpandDirective {
|
|
|
31
32
|
*/
|
|
32
33
|
this.expandedKeysChange = new EventEmitter();
|
|
33
34
|
this.subscriptions = new Subscription();
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Reflectes the internal `expandedKeys` state.
|
|
37
|
+
*/
|
|
38
|
+
this.state = new Set();
|
|
39
|
+
this.originalExpandedKeys = new Set();
|
|
36
40
|
this.isFiltered = false;
|
|
37
41
|
/**
|
|
38
42
|
* Fills array with the correct expand keys according to wrapper metadata.
|
|
@@ -64,7 +68,7 @@ let ExpandDirective = class ExpandDirective {
|
|
|
64
68
|
if (this.component.filterStateChange) {
|
|
65
69
|
this.subscriptions.add(this.component.filterStateChange.subscribe(this.handleAutoExpand.bind(this)));
|
|
66
70
|
}
|
|
67
|
-
this.component.isExpanded = (dataItem, index) => this.
|
|
71
|
+
this.component.isExpanded = (dataItem, index) => this.state.has(this.itemKey({ dataItem, index }));
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
74
|
* @hidden
|
|
@@ -76,14 +80,10 @@ let ExpandDirective = class ExpandDirective {
|
|
|
76
80
|
const settings = isBoolean(this.expandOnFilter) ? { enabled: this.expandOnFilter } : Object.assign({}, this.expandOnFilter, { enabled: true });
|
|
77
81
|
return Object.assign({}, DEFAULT_FILTER_EXPAND_SETTINGS, settings);
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return this._expandedKeys;
|
|
84
|
-
}
|
|
85
|
-
set expandedKeys(keys) {
|
|
86
|
-
this._expandedKeys = keys;
|
|
83
|
+
ngOnChanges(changes) {
|
|
84
|
+
if (isChanged('expandedKeys', changes, false) && changes.expandedKeys.currentValue !== this.lastChange) {
|
|
85
|
+
this.state = new Set(changes.expandedKeys.currentValue);
|
|
86
|
+
}
|
|
87
87
|
}
|
|
88
88
|
ngOnDestroy() {
|
|
89
89
|
this.subscriptions.unsubscribe();
|
|
@@ -103,19 +103,19 @@ let ExpandDirective = class ExpandDirective {
|
|
|
103
103
|
return e.index;
|
|
104
104
|
}
|
|
105
105
|
toggleExpand({ index, dataItem, expand }) {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
106
|
+
const key = this.itemKey({ index, dataItem });
|
|
107
|
+
const isExpanded = this.state.has(key);
|
|
108
108
|
let notify = false;
|
|
109
|
-
if (
|
|
110
|
-
this.
|
|
109
|
+
if (isExpanded && !expand) {
|
|
110
|
+
this.state.delete(key);
|
|
111
111
|
notify = true;
|
|
112
112
|
}
|
|
113
|
-
else if (
|
|
114
|
-
this.
|
|
113
|
+
else if (!isExpanded && expand) {
|
|
114
|
+
this.state.add(key);
|
|
115
115
|
notify = true;
|
|
116
116
|
}
|
|
117
117
|
if (notify) {
|
|
118
|
-
this.
|
|
118
|
+
this.notify();
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
handleAutoExpand({ nodes, matchCount, term }) {
|
|
@@ -124,7 +124,7 @@ let ExpandDirective = class ExpandDirective {
|
|
|
124
124
|
}
|
|
125
125
|
const { maxAutoExpandResults, expandMatches: autoExpandMatches, expandedOnClear } = this.filterExpandSettings;
|
|
126
126
|
if (!this.isFiltered) {
|
|
127
|
-
this.originalExpandedKeys = this.
|
|
127
|
+
this.originalExpandedKeys = new Set(this.state);
|
|
128
128
|
}
|
|
129
129
|
const exitingFilteredState = this.isFiltered && !term;
|
|
130
130
|
const maxExceeded = maxAutoExpandResults !== -1 && matchCount > maxAutoExpandResults;
|
|
@@ -132,18 +132,18 @@ let ExpandDirective = class ExpandDirective {
|
|
|
132
132
|
if (exitAutoExpandedState) {
|
|
133
133
|
switch (expandedOnClear) {
|
|
134
134
|
case "initial": {
|
|
135
|
-
if (!sameValues(this.
|
|
136
|
-
this.
|
|
137
|
-
this.
|
|
135
|
+
if (!sameValues(this.state, this.originalExpandedKeys)) {
|
|
136
|
+
this.state = this.originalExpandedKeys;
|
|
137
|
+
this.notify();
|
|
138
138
|
}
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
case "all": {
|
|
142
|
-
this.
|
|
142
|
+
this.state = new Set(nodes.reduce((acc, rootNode) => {
|
|
143
143
|
this.getEveryExpandKey(acc, rootNode);
|
|
144
144
|
return acc;
|
|
145
|
-
}, []);
|
|
146
|
-
this.
|
|
145
|
+
}, []));
|
|
146
|
+
this.notify();
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
149
|
case "unchanged": {
|
|
@@ -151,9 +151,9 @@ let ExpandDirective = class ExpandDirective {
|
|
|
151
151
|
}
|
|
152
152
|
case "none":
|
|
153
153
|
default: {
|
|
154
|
-
if (this.
|
|
155
|
-
this.
|
|
156
|
-
this.
|
|
154
|
+
if (this.state.size !== 0) {
|
|
155
|
+
this.state.clear();
|
|
156
|
+
this.notify();
|
|
157
157
|
}
|
|
158
158
|
break;
|
|
159
159
|
}
|
|
@@ -161,16 +161,20 @@ let ExpandDirective = class ExpandDirective {
|
|
|
161
161
|
this.isFiltered = false;
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
|
-
const indicesToExpand = nodes.reduce((acc, rootNode) => {
|
|
164
|
+
const indicesToExpand = new Set(nodes.reduce((acc, rootNode) => {
|
|
165
165
|
this.updateExpandedNodes(acc, rootNode, autoExpandMatches);
|
|
166
166
|
return acc;
|
|
167
|
-
}, []);
|
|
168
|
-
if (!sameValues(this.
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
167
|
+
}, []));
|
|
168
|
+
if (!sameValues(this.state, indicesToExpand)) {
|
|
169
|
+
this.state = indicesToExpand;
|
|
170
|
+
this.notify();
|
|
171
171
|
}
|
|
172
172
|
this.isFiltered = true;
|
|
173
173
|
}
|
|
174
|
+
notify() {
|
|
175
|
+
this.lastChange = Array.from(this.state);
|
|
176
|
+
this.expandedKeysChange.emit(this.lastChange);
|
|
177
|
+
}
|
|
174
178
|
};
|
|
175
179
|
tslib_1.__decorate([
|
|
176
180
|
Input(),
|
|
@@ -191,9 +195,8 @@ tslib_1.__decorate([
|
|
|
191
195
|
], ExpandDirective.prototype, "expandedKeysChange", void 0);
|
|
192
196
|
tslib_1.__decorate([
|
|
193
197
|
Input(),
|
|
194
|
-
tslib_1.__metadata("design:type", Array)
|
|
195
|
-
|
|
196
|
-
], ExpandDirective.prototype, "expandedKeys", null);
|
|
198
|
+
tslib_1.__metadata("design:type", Array)
|
|
199
|
+
], ExpandDirective.prototype, "expandedKeys", void 0);
|
|
197
200
|
ExpandDirective = tslib_1.__decorate([
|
|
198
201
|
Directive({ selector: '[kendoTreeViewExpandable]' }),
|
|
199
202
|
tslib_1.__metadata("design:paramtypes", [ExpandableComponent])
|