@progress/kendo-angular-treeview 5.4.3 → 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 +1 -1
- 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/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/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/utils.d.ts +2 -3
- package/dist/es2015/utils.js +4 -6
- package/dist/fesm2015/index.js +93 -102
- package/dist/fesm5/index.js +94 -115
- 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/utils.js +4 -6
- package/dist/systemjs/kendo-angular-treeview.js +1 -1
- package/package.json +1 -1
|
@@ -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])
|