@rxap/tree 16.0.0-dev.9 → 16.0.0
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/CHANGELOG.md +93 -0
- package/README.md +1 -1
- package/esm2022/lib/search.form.mjs +44 -0
- package/esm2022/lib/tree.component.mjs +25 -26
- package/esm2022/lib/tree.data-source.mjs +248 -73
- package/fesm2022/rxap-tree.mjs +271 -99
- package/fesm2022/rxap-tree.mjs.map +1 -1
- package/lib/search.form.d.ts +20 -0
- package/lib/tree.component.d.ts +6 -3
- package/lib/tree.data-source.d.ts +43 -17
- package/package.json +50 -46
- package/theme.css +1 -1
package/fesm2022/rxap-tree.mjs
CHANGED
|
@@ -1,72 +1,207 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
3
|
-
import {
|
|
4
|
-
import { BaseDataSource, RXAP_DATA_SOURCE_METADATA } from '@rxap/data-source';
|
|
5
|
-
import { joinPath, DebounceCall } from '@rxap/utilities';
|
|
3
|
+
import { FlatTreeControl } from '@angular/cdk/tree';
|
|
6
4
|
import * as i0 from '@angular/core';
|
|
7
|
-
import { InjectionToken, isDevMode, Injectable, Inject, TemplateRef, Directive, EventEmitter, ViewContainerRef, ChangeDetectorRef, Component, ChangeDetectionStrategy,
|
|
5
|
+
import { InjectionToken, isDevMode, Injectable, Inject, Optional, TemplateRef, Directive, EventEmitter, signal, ViewContainerRef, ChangeDetectorRef, Component, ChangeDetectionStrategy, Input, ContentChild, Output, ViewChild, HostListener } from '@angular/core';
|
|
6
|
+
import { BaseDataSource, RXAP_DATA_SOURCE_METADATA, RxapDataSource } from '@rxap/data-source';
|
|
8
7
|
import { Node } from '@rxap/data-structure-tree';
|
|
9
8
|
import { ToggleSubject } from '@rxap/rxjs';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
9
|
+
import { coerceArray, joinPath, Required, DebounceCall } from '@rxap/utilities';
|
|
10
|
+
import { BehaviorSubject, Subject, combineLatest, from, merge } from 'rxjs';
|
|
11
|
+
import { switchMap, map, tap, startWith } from 'rxjs/operators';
|
|
12
|
+
import * as i8 from '@angular/cdk/portal';
|
|
12
13
|
import { TemplatePortal, PortalModule } from '@angular/cdk/portal';
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import * as i2 from '@angular/flex-layout/extended';
|
|
16
|
-
import { ExtendedModule } from '@angular/flex-layout/extended';
|
|
17
|
-
import * as i1 from '@angular/flex-layout/flex';
|
|
18
|
-
import { FlexModule } from '@angular/flex-layout/flex';
|
|
19
|
-
import * as i7 from '@angular/material/button';
|
|
14
|
+
import { NgStyle, NgIf, AsyncPipe, NgClass, NgForOf } from '@angular/common';
|
|
15
|
+
import * as i5 from '@angular/material/button';
|
|
20
16
|
import { MatButtonModule } from '@angular/material/button';
|
|
21
|
-
import * as
|
|
17
|
+
import * as i4 from '@angular/material/checkbox';
|
|
22
18
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
23
|
-
import * as
|
|
19
|
+
import * as i7 from '@angular/material/divider';
|
|
24
20
|
import { MatDividerModule } from '@angular/material/divider';
|
|
25
|
-
import * as
|
|
21
|
+
import * as i3 from '@angular/material/icon';
|
|
26
22
|
import { MatIconModule } from '@angular/material/icon';
|
|
27
|
-
import * as
|
|
23
|
+
import * as i1 from '@angular/material/progress-bar';
|
|
28
24
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
29
|
-
import * as
|
|
25
|
+
import * as i6 from '@angular/material/progress-spinner';
|
|
30
26
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
31
|
-
import * as
|
|
27
|
+
import * as i2 from '@angular/material/tree';
|
|
32
28
|
import { MatTreeModule } from '@angular/material/tree';
|
|
33
29
|
import { ContenteditableDirective } from '@rxap/contenteditable';
|
|
34
30
|
import { IconDirective } from '@rxap/material-directives/icon';
|
|
35
31
|
|
|
36
32
|
function isSelectionChange(obj) {
|
|
37
|
-
return !!obj &&
|
|
33
|
+
return !!obj && obj['added'] !== undefined && obj['removed'] !== undefined;
|
|
38
34
|
}
|
|
39
35
|
const RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD = new InjectionToken('rxap/tree/data-source/root-remote-method');
|
|
40
36
|
const RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD = new InjectionToken('rxap/tree/data-source/children-remote-method');
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD = new InjectionToken('rxap/tree/data-source/apply-filter-method');
|
|
38
|
+
function flatTree(tree, all = false) {
|
|
39
|
+
tree = coerceArray(tree);
|
|
40
|
+
function flat(acc, list) {
|
|
41
|
+
return [...acc, ...list];
|
|
42
|
+
}
|
|
43
|
+
const _flatTree = (node) => {
|
|
44
|
+
if (!Array.isArray(node.children)) {
|
|
45
|
+
if (isDevMode()) {
|
|
46
|
+
console.log(node);
|
|
47
|
+
}
|
|
48
|
+
throw new Error('Node has not defined children');
|
|
49
|
+
}
|
|
50
|
+
if (all || node.expanded) {
|
|
51
|
+
return [
|
|
52
|
+
node,
|
|
53
|
+
...node.children.map((child) => _flatTree(child)).reduce(flat, []),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return [node];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return tree
|
|
61
|
+
.map((child) => _flatTree(child))
|
|
62
|
+
.reduce((acc, items) => [...acc, ...items], []);
|
|
63
|
+
}
|
|
64
|
+
class DefaultTreeApplyFilterMethod {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.lastFilter = null;
|
|
67
|
+
}
|
|
68
|
+
call({ tree, filter, scopeTypes }) {
|
|
69
|
+
const nodes = flatTree(tree, true);
|
|
70
|
+
if (this.isEqualToLastFilter(filter)) {
|
|
71
|
+
return flatTree(tree, false).filter(node => node.isVisible);
|
|
72
|
+
}
|
|
73
|
+
const hasScopeFilter = (filter.scope &&
|
|
74
|
+
Object.keys(filter.scope) &&
|
|
75
|
+
Object.values(filter.scope).some(list => list.length > 0));
|
|
76
|
+
// if not scope and the search filter is an empty string, collapse all non-root nodes
|
|
77
|
+
if (!filter.search && filter.search !== this.lastFilter?.search) {
|
|
78
|
+
nodes
|
|
79
|
+
.filter(node => node.parent)
|
|
80
|
+
.forEach(node => node.collapse({ quite: true }));
|
|
81
|
+
}
|
|
82
|
+
if (filter.search || hasScopeFilter) {
|
|
83
|
+
nodes.forEach(node => node.hide());
|
|
84
|
+
for (const [type, list] of Object.entries(filter.scope ?? {})) {
|
|
85
|
+
for (const node of nodes) {
|
|
86
|
+
if (node.type === type) {
|
|
87
|
+
if (list.some(item => item.uuid === node.id)) {
|
|
88
|
+
node.show({ forEachChildren: true });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (filter.search) {
|
|
94
|
+
for (const node of nodes) {
|
|
95
|
+
if (hasScopeFilter && node.hidden) {
|
|
96
|
+
// if the filter has a scope filter. Only check the search filter on nodes that are shown by the scope
|
|
97
|
+
// filter
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const display = node.display?.toLowerCase();
|
|
101
|
+
if (display) {
|
|
102
|
+
if (display.includes(filter.search.toLowerCase())) {
|
|
103
|
+
node.show({ parents: true });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
node.hide();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// if node has no display, it is not shown
|
|
111
|
+
node.hide();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// hide each node that has no visible children
|
|
115
|
+
// there exists the edge case that a node has visible children, but the node.hide() function is called
|
|
116
|
+
// after the child.show({ parent:true })
|
|
117
|
+
for (const node of nodes.filter(n => n.hidden && n.hasChildren && n.children.some(child => child.isVisible))) {
|
|
118
|
+
if (node.hidden) {
|
|
119
|
+
console.warn('Edge case detected. Node has visible children but is hidden.');
|
|
120
|
+
node.show();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// expand each node that has visible children
|
|
124
|
+
for (const node of nodes.filter(n => n.hasChildren)) {
|
|
125
|
+
if (node.children.some(child => child.isVisible)) {
|
|
126
|
+
// set quite to true to prevent the tree from reloading -> this would result in a infinite loop
|
|
127
|
+
node.expand({ quite: true });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
nodes.forEach(node => node.show());
|
|
134
|
+
}
|
|
135
|
+
this.lastFilter = filter;
|
|
136
|
+
return flatTree(tree, false).filter(node => node.isVisible);
|
|
137
|
+
}
|
|
138
|
+
isEqualToLastFilter(filter) {
|
|
139
|
+
if (this.lastFilter) {
|
|
140
|
+
if (this.lastFilter.search === filter.search) {
|
|
141
|
+
if (this.lastFilter.scope && filter.scope) {
|
|
142
|
+
if (Object.keys(this.lastFilter.scope).every(key => Object.keys(filter.scope).includes(key))) {
|
|
143
|
+
if (Object.entries(this.lastFilter.scope)
|
|
144
|
+
.every(([key, scope]) => scope.some(item => filter.scope[key].includes(item)))) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (filter.scope === this.lastFilter.scope) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DefaultTreeApplyFilterMethod, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
157
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DefaultTreeApplyFilterMethod }); }
|
|
158
|
+
}
|
|
159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DefaultTreeApplyFilterMethod, decorators: [{
|
|
160
|
+
type: Injectable
|
|
161
|
+
}] });
|
|
162
|
+
let TreeDataSource = class TreeDataSource extends BaseDataSource {
|
|
163
|
+
constructor(rootRemoteMethod, childrenRemoteMethod = null, applyFilterMethod = null, metadata = null) {
|
|
43
164
|
super(metadata);
|
|
44
165
|
this.rootRemoteMethod = rootRemoteMethod;
|
|
45
166
|
this.childrenRemoteMethod = childrenRemoteMethod;
|
|
46
167
|
this.tree$ = new BehaviorSubject([]);
|
|
47
|
-
this.loading$ = new ToggleSubject(true);
|
|
48
|
-
// TODO : änlich problem wie bei der redundaten expand SelectionModel.
|
|
49
|
-
this._data$ = new BehaviorSubject([]);
|
|
50
168
|
this._expandedLocalStorageSubscription = null;
|
|
51
169
|
this._selectedLocalStorageSubscription = null;
|
|
170
|
+
// TODO : änlich problem wie bei der redundaten expand SelectionModel.
|
|
171
|
+
this.loading$ = new ToggleSubject(true);
|
|
172
|
+
this.searchForm = null;
|
|
52
173
|
// im localStorage wird nur die id gespeichert.
|
|
53
174
|
this._preSelected = [];
|
|
175
|
+
this._data$ = new BehaviorSubject([]);
|
|
54
176
|
this._refreshMatchFilter = new Subject();
|
|
55
177
|
this._nodeParameters = null;
|
|
56
178
|
this.toDisplay = () => 'to display function not defined';
|
|
57
179
|
this.getIcon = () => null;
|
|
180
|
+
this.getType = () => null;
|
|
58
181
|
this.getStyle = () => ({});
|
|
59
182
|
this.hasDetails = () => true;
|
|
60
183
|
this.matchFilter = () => true;
|
|
61
|
-
this.
|
|
62
|
-
.pipe(map((tree) => tree
|
|
63
|
-
.map((child) => this.flatTree(child))
|
|
64
|
-
.reduce((acc, nodes) => [...acc, ...nodes], [])))
|
|
65
|
-
.subscribe(this._data$);
|
|
184
|
+
this.applyFilterMethod = applyFilterMethod ?? new DefaultTreeApplyFilterMethod();
|
|
66
185
|
// TODO add new SelectModel class that saves the select model to the localStorage
|
|
67
186
|
this.initSelected();
|
|
68
187
|
this.initExpanded();
|
|
69
188
|
}
|
|
189
|
+
ngOnInit() {
|
|
190
|
+
if (this.searchForm) {
|
|
191
|
+
combineLatest([
|
|
192
|
+
this.tree$,
|
|
193
|
+
this.searchForm.rxapFormGroup.value$,
|
|
194
|
+
]).pipe(switchMap(async ([tree, filter]) => await this.applyFilterMethod.call({
|
|
195
|
+
tree,
|
|
196
|
+
filter,
|
|
197
|
+
scopeTypes: this.metadata?.scopeTypes,
|
|
198
|
+
})), map(nodes => coerceArray(nodes)))
|
|
199
|
+
.subscribe(data => this._data$.next(data));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.tree$.pipe(map(tree => flatTree(tree).filter(node => node.isVisible)), tap(nodes => nodes.forEach(node => node.show()))).subscribe(data => this._data$.next(data));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
70
205
|
get nodeParameters() {
|
|
71
206
|
return this._nodeParameters;
|
|
72
207
|
}
|
|
@@ -79,10 +214,10 @@ class TreeDataSource extends BaseDataSource {
|
|
|
79
214
|
const root = await this.getRoot();
|
|
80
215
|
let rootNodes;
|
|
81
216
|
if (Array.isArray(root)) {
|
|
82
|
-
rootNodes = await Promise.all(root.map((node) => this._toNode(node)));
|
|
217
|
+
rootNodes = await Promise.all(root.map((node) => this._toNode(null, node)));
|
|
83
218
|
}
|
|
84
219
|
else {
|
|
85
|
-
rootNodes = [await this._toNode(root)];
|
|
220
|
+
rootNodes = [await this._toNode(null, root)];
|
|
86
221
|
}
|
|
87
222
|
this.tree$.next(rootNodes);
|
|
88
223
|
this.loading$.disable();
|
|
@@ -118,44 +253,60 @@ class TreeDataSource extends BaseDataSource {
|
|
|
118
253
|
return Promise.resolve();
|
|
119
254
|
}
|
|
120
255
|
// - the SelectModel that stores the selection into the local storage?
|
|
121
|
-
async _toNode(item, depth = 0, onExpand = this.expandNode.bind(this), onCollapse = this.collapseNode.bind(this), onSelect = this.selectNode.bind(this), onDeselect = this.deselectNode.bind(this)) {
|
|
122
|
-
const node = await this.toNode(item, depth, onExpand, onCollapse, onSelect, onDeselect);
|
|
256
|
+
async _toNode(parent, item, depth = 0, onExpand = this.expandNode.bind(this), onCollapse = this.collapseNode.bind(this), onSelect = this.selectNode.bind(this), onDeselect = this.deselectNode.bind(this)) {
|
|
257
|
+
const node = await this.toNode(parent, item, depth, onExpand, onCollapse, onSelect, onDeselect);
|
|
123
258
|
if (this.expanded.isSelected(node.id)) {
|
|
124
259
|
node
|
|
125
260
|
.expand()
|
|
126
261
|
.then(() => {
|
|
127
|
-
// TODO : remove redundant this.expanded SelectionModel. Only store expanded nodes in
|
|
128
|
-
// das problem ist das ich beim speicher in localStorage nur die id speicher.
|
|
129
|
-
// Des wegen kann ich beim laden aus dem localStorage this.treeControl.expansionModel
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
// - das node object läde die entity mithilfe der id automatisch nach
|
|
262
|
+
// TODO : remove redundant this.expanded SelectionModel. Only store expanded nodes in
|
|
263
|
+
// this.treeControl.expansionModel das problem ist das ich beim speicher in localStorage nur die id speicher.
|
|
264
|
+
// Des wegen kann ich beim laden aus dem localStorage this.treeControl.expansionModel nicht einfach mit den
|
|
265
|
+
// expanend nodes fullen. Da dort das node object benötigt wird möglich lösungen: - das node object läde die
|
|
266
|
+
// entity mithilfe der id automatisch nach
|
|
133
267
|
this.treeControl.expansionModel.select(node);
|
|
134
|
-
console.debug(`Restore expand for node '${node.id}' SUCCESSFULLY`);
|
|
135
|
-
})
|
|
136
|
-
|
|
268
|
+
// console.debug(`Restore expand for node '${node.id}' SUCCESSFULLY`);
|
|
269
|
+
});
|
|
270
|
+
// .catch(() =>
|
|
271
|
+
// console.debug(`Restore expand for node '${node.id}' FAILED`)
|
|
272
|
+
// );
|
|
137
273
|
}
|
|
138
274
|
if (this._preSelected.includes(node.id)) {
|
|
139
275
|
await node
|
|
140
|
-
.select()
|
|
141
|
-
|
|
142
|
-
|
|
276
|
+
.select();
|
|
277
|
+
// .then(() =>
|
|
278
|
+
// console.debug(`Restore select for node '${node.id}' SUCCESSFULLY`)
|
|
279
|
+
// )
|
|
280
|
+
// .catch(() =>
|
|
281
|
+
// console.debug(`Restore select for node '${node.id}' FAILED`)
|
|
282
|
+
// );
|
|
143
283
|
}
|
|
144
284
|
return node;
|
|
145
285
|
}
|
|
146
|
-
async expandNode(node) {
|
|
286
|
+
async expandNode(node, options) {
|
|
287
|
+
if (!options?.onlySelf) {
|
|
288
|
+
// required to sync the expanstion state with the tree control
|
|
289
|
+
// if the collpase is trigged by node.expand this state is not
|
|
290
|
+
// sync with the tree control
|
|
291
|
+
this.treeControl.expansionModel.select(node);
|
|
292
|
+
}
|
|
147
293
|
if (node.item.hasChildren && !node.item.children?.length) {
|
|
148
294
|
node.isLoading$.enable();
|
|
149
295
|
const children = await this.getChildren(node);
|
|
150
296
|
// add the loaded children to the item object
|
|
151
297
|
node.item.children = children;
|
|
152
|
-
node.addChildren(await Promise.all(children.map((child) => this._toNode(child, node.depth + 1, node.onExpand, node.onCollapse))));
|
|
298
|
+
node.addChildren(await Promise.all(children.map((child) => this._toNode(node, child, node.depth + 1, node.onExpand, node.onCollapse))));
|
|
153
299
|
node.isLoading$.disable();
|
|
154
300
|
}
|
|
155
301
|
this.expanded.select(node.id);
|
|
156
|
-
|
|
302
|
+
if (!options?.quite) {
|
|
303
|
+
this.tree$.next(this.tree$.value);
|
|
304
|
+
}
|
|
157
305
|
}
|
|
158
306
|
async getChildren(node) {
|
|
307
|
+
if (!this.childrenRemoteMethod) {
|
|
308
|
+
throw new Error(`The node '${node.id}' has unloaded children but the RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD is not provided.`);
|
|
309
|
+
}
|
|
159
310
|
return this.childrenRemoteMethod.call(node);
|
|
160
311
|
}
|
|
161
312
|
async getRoot() {
|
|
@@ -183,36 +334,30 @@ class TreeDataSource extends BaseDataSource {
|
|
|
183
334
|
.map((node) => getNodeById(node, id))
|
|
184
335
|
.filter(Boolean)[0] || null);
|
|
185
336
|
}
|
|
186
|
-
async toNode(item, depth = 0, onExpand = this.expandNode.bind(this), onCollapse = this.collapseNode.bind(this), onSelect = this.selectNode.bind(this), onDeselect = this.deselectNode.bind(this)) {
|
|
187
|
-
return Node.ToNode(item, depth, onExpand, onCollapse, this.toDisplay, this.getIcon, onSelect, onDeselect, this.hasDetails, this.getStyle, this.nodeParameters);
|
|
337
|
+
async toNode(parent, item, depth = 0, onExpand = this.expandNode.bind(this), onCollapse = this.collapseNode.bind(this), onSelect = this.selectNode.bind(this), onDeselect = this.deselectNode.bind(this)) {
|
|
338
|
+
return Node.ToNode(parent, item, depth, onExpand, onCollapse, this.toDisplay, this.getIcon, this.getType, onSelect, onDeselect, this.hasDetails, this.getStyle, this.nodeParameters);
|
|
188
339
|
}
|
|
189
|
-
collapseNode(node) {
|
|
340
|
+
collapseNode(node, options) {
|
|
341
|
+
if (!options?.onlySelf) {
|
|
342
|
+
// required to sync the expanstion state with the tree control
|
|
343
|
+
// if the collpase is trigged by node.colapse this state is not
|
|
344
|
+
// sync with the tree control
|
|
345
|
+
this.treeControl.expansionModel.deselect(node);
|
|
346
|
+
}
|
|
190
347
|
this.expanded.deselect(node.id);
|
|
191
|
-
|
|
348
|
+
if (!options?.quite) {
|
|
349
|
+
this.tree$.next(this.tree$.value);
|
|
350
|
+
}
|
|
192
351
|
return Promise.resolve();
|
|
193
352
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
throw new Error('Node has not defined children');
|
|
204
|
-
}
|
|
205
|
-
if (node.expanded || this.expanded.isSelected(node.id)) {
|
|
206
|
-
return [
|
|
207
|
-
node,
|
|
208
|
-
...node.children.map((child) => flatTree(child)).reduce(flat, []),
|
|
209
|
-
];
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
return [node];
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
return flatTree(tree);
|
|
353
|
+
/**
|
|
354
|
+
* Converts the tree structure into a list.
|
|
355
|
+
*
|
|
356
|
+
* @param tree
|
|
357
|
+
* @param all true - include nodes children that are not expanded
|
|
358
|
+
*/
|
|
359
|
+
flatTree(tree, all = false) {
|
|
360
|
+
return flatTree(tree, all);
|
|
216
361
|
}
|
|
217
362
|
destroy() {
|
|
218
363
|
super.destroy();
|
|
@@ -259,6 +404,9 @@ class TreeDataSource extends BaseDataSource {
|
|
|
259
404
|
setGetStyle(getStyle = this.getStyle) {
|
|
260
405
|
this.getStyle = getStyle;
|
|
261
406
|
}
|
|
407
|
+
setGetType(getType = this.getType) {
|
|
408
|
+
this.getType = getType;
|
|
409
|
+
}
|
|
262
410
|
/**
|
|
263
411
|
* recall the getStyle, getIcon and toDisplay methods
|
|
264
412
|
* and update the node objects
|
|
@@ -266,25 +414,29 @@ class TreeDataSource extends BaseDataSource {
|
|
|
266
414
|
updateNodes() {
|
|
267
415
|
this._data$.value.forEach(node => {
|
|
268
416
|
node.style = this.getStyle(node.item);
|
|
269
|
-
node.icon = this.getIcon(node.item);
|
|
417
|
+
node.icon = coerceArray(this.getIcon(node.item));
|
|
270
418
|
node.display = this.toDisplay(node.item);
|
|
271
419
|
});
|
|
272
420
|
this._data$.next(this._data$.value);
|
|
273
421
|
}
|
|
274
422
|
_connect(collectionViewer) {
|
|
275
|
-
this.
|
|
423
|
+
this.init();
|
|
424
|
+
this.treeControl.expansionModel.changed.pipe(tap(async (change) => {
|
|
276
425
|
if (isSelectionChange(change)) {
|
|
426
|
+
const promiseList = [];
|
|
277
427
|
if (change.added) {
|
|
278
|
-
change.added.
|
|
428
|
+
promiseList.push(...change.added.map((node) => node.expand({ onlySelf: true, quite: true })));
|
|
279
429
|
}
|
|
280
430
|
if (change.removed) {
|
|
281
|
-
change.removed
|
|
431
|
+
promiseList.push(...change.removed
|
|
282
432
|
.slice()
|
|
283
433
|
.reverse()
|
|
284
|
-
.
|
|
434
|
+
.map((node) => node.collapse({ onlySelf: true, quite: true })));
|
|
285
435
|
}
|
|
436
|
+
await Promise.all(promiseList);
|
|
437
|
+
this.tree$.next(this.tree$.value);
|
|
286
438
|
}
|
|
287
|
-
});
|
|
439
|
+
})).subscribe();
|
|
288
440
|
let loadRoot = Promise.resolve();
|
|
289
441
|
if (this.tree$.value.length === 0) {
|
|
290
442
|
loadRoot = this.getTreeRoot();
|
|
@@ -329,7 +481,7 @@ class TreeDataSource extends BaseDataSource {
|
|
|
329
481
|
this._preSelected = JSON.parse(localStorage.getItem(key));
|
|
330
482
|
}
|
|
331
483
|
catch (e) {
|
|
332
|
-
console.
|
|
484
|
+
console.error('parse expanded tree data source nodes failed');
|
|
333
485
|
}
|
|
334
486
|
}
|
|
335
487
|
}
|
|
@@ -349,7 +501,7 @@ class TreeDataSource extends BaseDataSource {
|
|
|
349
501
|
expanded = JSON.parse(localStorage.getItem(key));
|
|
350
502
|
}
|
|
351
503
|
catch (e) {
|
|
352
|
-
console.
|
|
504
|
+
console.error('parse expanded tree data source nodes failed');
|
|
353
505
|
}
|
|
354
506
|
}
|
|
355
507
|
}
|
|
@@ -360,21 +512,38 @@ class TreeDataSource extends BaseDataSource {
|
|
|
360
512
|
.subscribe();
|
|
361
513
|
}
|
|
362
514
|
}
|
|
363
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeDataSource, deps: [{ token: RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD }, { token: RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD }, { token: RXAP_DATA_SOURCE_METADATA }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
515
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeDataSource, deps: [{ token: RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD }, { token: RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD, optional: true }, { token: RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD, optional: true }, { token: RXAP_DATA_SOURCE_METADATA, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
364
516
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeDataSource }); }
|
|
365
|
-
}
|
|
517
|
+
};
|
|
518
|
+
__decorate([
|
|
519
|
+
Required,
|
|
520
|
+
__metadata("design:type", FlatTreeControl)
|
|
521
|
+
], TreeDataSource.prototype, "treeControl", void 0);
|
|
522
|
+
TreeDataSource = __decorate([
|
|
523
|
+
RxapDataSource('tree'),
|
|
524
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
525
|
+
], TreeDataSource);
|
|
366
526
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeDataSource, decorators: [{
|
|
367
527
|
type: Injectable
|
|
368
528
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
369
529
|
type: Inject,
|
|
370
530
|
args: [RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD]
|
|
371
531
|
}] }, { type: undefined, decorators: [{
|
|
532
|
+
type: Optional
|
|
533
|
+
}, {
|
|
372
534
|
type: Inject,
|
|
373
535
|
args: [RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD]
|
|
374
536
|
}] }, { type: undefined, decorators: [{
|
|
537
|
+
type: Optional
|
|
538
|
+
}, {
|
|
539
|
+
type: Inject,
|
|
540
|
+
args: [RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD]
|
|
541
|
+
}] }, { type: undefined, decorators: [{
|
|
542
|
+
type: Optional
|
|
543
|
+
}, {
|
|
375
544
|
type: Inject,
|
|
376
545
|
args: [RXAP_DATA_SOURCE_METADATA]
|
|
377
|
-
}] }]; } });
|
|
546
|
+
}] }]; }, propDecorators: { treeControl: [] } });
|
|
378
547
|
|
|
379
548
|
class TreeContentDirective {
|
|
380
549
|
constructor(template) {
|
|
@@ -397,15 +566,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
|
|
|
397
566
|
const RXAP_TREE_CONTENT_EDITABLE_METHOD = new InjectionToken('rxap/tree-content-editable-method');
|
|
398
567
|
|
|
399
568
|
class TreeComponent {
|
|
400
|
-
constructor(viewContainerRef, cdr, contentEditableMethod, renderer) {
|
|
569
|
+
constructor(viewContainerRef, cdr, contentEditableMethod, renderer, elementRef) {
|
|
401
570
|
this.viewContainerRef = viewContainerRef;
|
|
402
571
|
this.cdr = cdr;
|
|
403
572
|
this.renderer = renderer;
|
|
573
|
+
this.elementRef = elementRef;
|
|
404
574
|
this.multiple = false;
|
|
405
575
|
this.hideLeafIcon = false;
|
|
406
576
|
this.details = new EventEmitter();
|
|
407
577
|
this.dividerOffset = '256px';
|
|
408
578
|
this.portal = null;
|
|
579
|
+
this.showTreeNavigation = signal(true);
|
|
409
580
|
/**
|
|
410
581
|
* Indicates that the divider is moved with mouse down
|
|
411
582
|
* @private
|
|
@@ -477,23 +648,24 @@ class TreeComponent {
|
|
|
477
648
|
if (!this._treeContainerWidth) {
|
|
478
649
|
this._treeContainerWidth = this.treeContainer.nativeElement.clientWidth;
|
|
479
650
|
}
|
|
480
|
-
|
|
651
|
+
const rect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
652
|
+
this._treeContainerWidth = Math.min(Math.max($event.clientX - (rect.left + 12), 128), rect.right - rect.left - 128);
|
|
481
653
|
const offset = this._treeContainerWidth + 'px';
|
|
482
654
|
this.setDividerOffset(offset);
|
|
483
655
|
}
|
|
484
656
|
}
|
|
485
657
|
setDividerOffset(offset) {
|
|
486
|
-
if (isDevMode()) {
|
|
487
|
-
console.log('set divider offset to: ' + offset);
|
|
488
|
-
}
|
|
489
658
|
this.dividerOffset = offset;
|
|
490
659
|
this.renderer.setStyle(this.treeContainer.nativeElement, 'max-width', offset);
|
|
491
660
|
this.renderer.setStyle(this.treeContainer.nativeElement, 'min-width', offset);
|
|
492
661
|
this.renderer.setStyle(this.treeContainer.nativeElement, 'flex-basis', offset);
|
|
493
662
|
localStorage.setItem(this.cacheId, offset);
|
|
494
663
|
}
|
|
495
|
-
|
|
496
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: TreeComponent, isStandalone: true, selector: "rxap-tree", inputs: { dataSource: "dataSource", contentEditableMethod: "contentEditableMethod", toDisplay: "toDisplay", getIcon: "getIcon", getStyle: "getStyle", multiple: "multiple", hasDetails: "hasDetails", hideLeafIcon: "hideLeafIcon", id: "id", dividerOffset: "dividerOffset" }, outputs: { details: "details" }, host: { listeners: { "mouseup": "onMouseup()", "mousemove": "onMousemove($event)" } }, queries: [{ propertyName: "content", first: true, predicate: TreeContentDirective, descendants: true, static: true }], viewQueries: [{ propertyName: "treeContainer", first: true, predicate: ["treeContainer"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"container\" fxLayout=\"row\">\n <div #treeContainer [ngStyle]=\"{ maxWidth: dividerOffset, minWidth: dividerOffset, flexBasis: dividerOffset }\"\n class=\"tree-container\" fxFlex=\"nogrow\">\n <mat-progress-bar *ngIf=\"!dataSource || (dataSource.loading$ | async)\" mode=\"indeterminate\"></mat-progress-bar>\n <mat-tree *ngIf=\"dataSource; else loading\" [dataSource]=\"dataSource\" [treeControl]=\"treeControl\"\n class=\"tree-view\">\n\n <!-- Node without children -->\n <mat-tree-node *matTreeNodeDef=\"let node\" matTreeNodePadding>\n <div fxLayout=\"row\" fxLayoutAlign=\"start center\">\n <mat-icon [fxHide]=\"hideLeafIcon\" fxFlex=\"40px\">subdirectory_arrow_right</mat-icon>\n <mat-icon *ngIf=\"node.icon\" [rxapIcon]=\"node.icon\" fxFlex=\"40px\"></mat-icon>\n <ng-template [ngIf]=\"multiple\">\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n fxFlex=\"nogrow\">\n {{ node.display }}\n </mat-checkbox>\n </ng-template>\n <ng-template [ngIf]=\"!multiple\">\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : null\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n fxFlex=\"nogrow\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n </div>\n </mat-tree-node>\n\n <!-- Node with children -->\n <mat-tree-node *matTreeNodeDef=\"let node; when: hasChild\" matTreeNodePadding>\n <button [attr.aria-label]=\"'toggle ' + node.filename\" mat-icon-button matTreeNodeToggle>\n <mat-icon class=\"mat-icon-rtl-mirror\">\n {{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}\n </mat-icon>\n </button>\n <div fxLayout=\"row\" fxLayoutAlign=\"start center\">\n <mat-icon *ngIf=\"node.icon; else withoutIcon\" [rxapIcon]=\"node.icon\" fxFlex=\"40px\"></mat-icon>\n <ng-template #withoutIcon>\n <div fxFlex=\"0\"></div>\n </ng-template>\n <ng-template [ngIfElse]=\"withoutDetails\" [ngIf]=\"node.hasDetails\">\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : null\"\n [ngStyle]=\"node.style\"\n fxFlex=\"nogrow\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n <ng-template #withoutDetails>\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n fxFlex=\"nogrow\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n </ng-template>\n <mat-progress-spinner\n *ngIf=\"node.isLoading$ | async\"\n [diameter]=\"16\"\n fxFlex=\"nogrow\"\n fxFlexOffset=\"16px\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n </div>\n </mat-tree-node>\n\n </mat-tree>\n </div>\n\n <div (mousedown)=\"onMousedown()\"\n class=\"divider\"\n fxFlex=\"nogrow\">\n <mat-divider\n [vertical]=\"true\"\n >\n </mat-divider>\n </div>\n\n <div class=\"details\" fxFlex=\"grow\">\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n <ng-content></ng-content>\n </div>\n</div>\n\n<ng-template #loading>Load data source</ng-template>\n", styles: [".container{height:100%}.tree-view{background-color:initial}.details{max-height:calc(100vh - 96px);overflow-y:auto}.tree-container{max-height:calc(100vh - 96px);overflow-y:auto;width:-moz-fit-content;width:fit-content}.divider{cursor:ew-resize;padding:12px}.divider ::ng-deep .mat-divider{height:100%}\n"], dependencies: [{ kind: "ngmodule", type: FlexModule }, { kind: "directive", type: i1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i1.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i1.DefaultFlexOffsetDirective, selector: " [fxFlexOffset], [fxFlexOffset.xs], [fxFlexOffset.sm], [fxFlexOffset.md], [fxFlexOffset.lg], [fxFlexOffset.xl], [fxFlexOffset.lt-sm], [fxFlexOffset.lt-md], [fxFlexOffset.lt-lg], [fxFlexOffset.lt-xl], [fxFlexOffset.gt-xs], [fxFlexOffset.gt-sm], [fxFlexOffset.gt-md], [fxFlexOffset.gt-lg]", inputs: ["fxFlexOffset", "fxFlexOffset.xs", "fxFlexOffset.sm", "fxFlexOffset.md", "fxFlexOffset.lg", "fxFlexOffset.xl", "fxFlexOffset.lt-sm", "fxFlexOffset.lt-md", "fxFlexOffset.lt-lg", "fxFlexOffset.lt-xl", "fxFlexOffset.gt-xs", "fxFlexOffset.gt-sm", "fxFlexOffset.gt-md", "fxFlexOffset.gt-lg"] }, { kind: "directive", type: i1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ExtendedModule }, { kind: "directive", type: i2.DefaultShowHideDirective, selector: " [fxShow], [fxShow.print], [fxShow.xs], [fxShow.sm], [fxShow.md], [fxShow.lg], [fxShow.xl], [fxShow.lt-sm], [fxShow.lt-md], [fxShow.lt-lg], [fxShow.lt-xl], [fxShow.gt-xs], [fxShow.gt-sm], [fxShow.gt-md], [fxShow.gt-lg], [fxHide], [fxHide.print], [fxHide.xs], [fxHide.sm], [fxHide.md], [fxHide.lg], [fxHide.xl], [fxHide.lt-sm], [fxHide.lt-md], [fxHide.lt-lg], [fxHide.lt-xl], [fxHide.gt-xs], [fxHide.gt-sm], [fxHide.gt-md], [fxHide.gt-lg]", inputs: ["fxShow", "fxShow.print", "fxShow.xs", "fxShow.sm", "fxShow.md", "fxShow.lg", "fxShow.xl", "fxShow.lt-sm", "fxShow.lt-md", "fxShow.lt-lg", "fxShow.lt-xl", "fxShow.gt-xs", "fxShow.gt-sm", "fxShow.gt-md", "fxShow.gt-lg", "fxHide", "fxHide.print", "fxHide.xs", "fxHide.sm", "fxHide.md", "fxHide.lg", "fxHide.xl", "fxHide.lt-sm", "fxHide.lt-md", "fxHide.lt-lg", "fxHide.lt-xl", "fxHide.gt-xs", "fxHide.gt-sm", "fxHide.gt-md", "fxHide.gt-lg"] }, { kind: "directive", type: i2.DefaultStyleDirective, selector: " [ngStyle], [ngStyle.xs], [ngStyle.sm], [ngStyle.md], [ngStyle.lg], [ngStyle.xl], [ngStyle.lt-sm], [ngStyle.lt-md], [ngStyle.lt-lg], [ngStyle.lt-xl], [ngStyle.gt-xs], [ngStyle.gt-sm], [ngStyle.gt-md], [ngStyle.gt-lg]", inputs: ["ngStyle", "ngStyle.xs", "ngStyle.sm", "ngStyle.md", "ngStyle.lg", "ngStyle.xl", "ngStyle.lt-sm", "ngStyle.lt-md", "ngStyle.lt-lg", "ngStyle.lt-xl", "ngStyle.gt-xs", "ngStyle.gt-sm", "ngStyle.gt-md", "ngStyle.gt-lg"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i3.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatTreeModule }, { kind: "directive", type: i4.MatTreeNodeDef, selector: "[matTreeNodeDef]", inputs: ["matTreeNodeDefWhen", "matTreeNode"] }, { kind: "directive", type: i4.MatTreeNodePadding, selector: "[matTreeNodePadding]", inputs: ["matTreeNodePadding", "matTreeNodePaddingIndent"] }, { kind: "directive", type: i4.MatTreeNodeToggle, selector: "[matTreeNodeToggle]", inputs: ["matTreeNodeToggleRecursive"] }, { kind: "component", type: i4.MatTree, selector: "mat-tree", exportAs: ["matTree"] }, { kind: "directive", type: i4.MatTreeNode, selector: "mat-tree-node", inputs: ["role", "disabled", "tabIndex"], exportAs: ["matTreeNode"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: IconDirective, selector: "mat-icon[rxapIcon]", inputs: ["rxapIcon"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i6.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i7.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: ContenteditableDirective, selector: "[rxapContenteditable]", inputs: ["rxapContenteditable", "disabled"], outputs: ["change"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i8.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatDividerModule }, { kind: "component", type: i9.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i10.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
664
|
+
toggleTreeNavigation() {
|
|
665
|
+
this.showTreeNavigation.update((value) => !value);
|
|
666
|
+
}
|
|
667
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeComponent, deps: [{ token: ViewContainerRef }, { token: ChangeDetectorRef }, { token: RXAP_TREE_CONTENT_EDITABLE_METHOD, optional: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
668
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: TreeComponent, isStandalone: true, selector: "rxap-tree", inputs: { dataSource: "dataSource", contentEditableMethod: "contentEditableMethod", toDisplay: "toDisplay", getIcon: "getIcon", getStyle: "getStyle", multiple: "multiple", hasDetails: "hasDetails", hideLeafIcon: "hideLeafIcon", id: "id", dividerOffset: "dividerOffset" }, outputs: { details: "details" }, host: { listeners: { "mouseup": "onMouseup()", "mousemove": "onMousemove($event)" } }, queries: [{ propertyName: "content", first: true, predicate: TreeContentDirective, descendants: true, static: true }], viewQueries: [{ propertyName: "treeContainer", first: true, predicate: ["treeContainer"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"grow flex flex-col gap-2\">\n <button type=\"button\" (click)=\"toggleTreeNavigation()\" class=\"!justify-start\" mat-button>\n <span class=\"flex flex-row justify-start items-center gap-6\">\n <ng-template [ngIf]=\"showTreeNavigation()\">\n <mat-icon>arrow_back</mat-icon>\n <span i18n>Hide tree navigation</span>\n </ng-template>\n <ng-template [ngIf]=\"!showTreeNavigation()\">\n <mat-icon>arrow_forward</mat-icon>\n <span i18n>Show tree navigation</span>\n </ng-template>\n </span>\n </button>\n <div class=\"flex flex-row grow\">\n <div #treeContainer [ngClass]=\"{ 'hidden': !showTreeNavigation() }\"\n [ngStyle]=\"{ maxWidth: dividerOffset, minWidth: dividerOffset, flexBasis: dividerOffset }\"\n class=\"w-fit grow-0 overflow-y-auto\">\n <mat-progress-bar *ngIf=\"!dataSource || (dataSource.loading$ | async)\" mode=\"indeterminate\"></mat-progress-bar>\n <ng-content select=\"[searchHeader]\"></ng-content>\n <mat-tree *ngIf=\"dataSource; else loading\" [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n\n <!-- Node without children -->\n <mat-tree-node *matTreeNodeDef=\"let node\" matTreeNodePadding>\n <div class=\"flex flex-row justify-start items-center gap-2\">\n <mat-icon [ngClass]=\"{ 'hidden': hideLeafIcon }\">subdirectory_arrow_right</mat-icon>\n <ng-container *ngIf=\"node.icon?.length\">\n <mat-icon *ngFor=\"let icon of node.icon\" [rxapIcon]=\"$any(icon)\"></mat-icon>\n </ng-container>\n <ng-template [ngIf]=\"multiple\">\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\">\n {{ node.display }}\n </mat-checkbox>\n </ng-template>\n <ng-template [ngIf]=\"!multiple\">\n <button\n type=\"button\"\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n </div>\n </mat-tree-node>\n\n <!-- Node with children -->\n <mat-tree-node *matTreeNodeDef=\"let node; when: hasChild\" matTreeNodePadding>\n <button type=\"button\" [attr.aria-label]=\"'toggle ' + node.filename\" mat-icon-button matTreeNodeToggle>\n <mat-icon class=\"mat-icon-rtl-mirror\">\n {{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}\n </mat-icon>\n </button>\n <div class=\"flex flex-row justify-start items-center gap-2\">\n <ng-container *ngIf=\"node.icon?.length else withoutIcon\">\n <mat-icon *ngFor=\"let icon of node.icon\" [rxapIcon]=\"$any(icon)\"></mat-icon>\n </ng-container>\n <ng-template #withoutIcon>\n <div></div>\n </ng-template>\n <ng-template [ngIfElse]=\"withoutDetails\" [ngIf]=\"node.hasDetails\">\n <button\n type=\"button\"\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n <ng-template #withoutDetails>\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n </ng-template>\n <mat-progress-spinner\n *ngIf=\"node.isLoading$ | async\"\n [diameter]=\"16\"\n class=\"grow-0 pl-4\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n </div>\n </mat-tree-node>\n\n </mat-tree>\n </div>\n\n <div (mousedown)=\"onMousedown()\" *ngIf=\"showTreeNavigation()\"\n class=\"divider cursor-ew-resize px-3 grow-0\">\n <mat-divider [vertical]=\"true\" class=\"h-full\"></mat-divider>\n </div>\n\n <div class=\"grow\">\n <ng-container *ngIf=\"portal\">\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n </ng-container>\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n\n<ng-template #loading>Load data source</ng-template>\n", styles: [""], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatTreeModule }, { kind: "directive", type: i2.MatTreeNodeDef, selector: "[matTreeNodeDef]", inputs: ["matTreeNodeDefWhen", "matTreeNode"] }, { kind: "directive", type: i2.MatTreeNodePadding, selector: "[matTreeNodePadding]", inputs: ["matTreeNodePadding", "matTreeNodePaddingIndent"] }, { kind: "directive", type: i2.MatTreeNodeToggle, selector: "[matTreeNodeToggle]", inputs: ["matTreeNodeToggleRecursive"] }, { kind: "component", type: i2.MatTree, selector: "mat-tree", exportAs: ["matTree"] }, { kind: "directive", type: i2.MatTreeNode, selector: "mat-tree-node", inputs: ["role", "disabled", "tabIndex"], exportAs: ["matTreeNode"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: IconDirective, selector: "mat-icon[rxapIcon]", inputs: ["rxapIcon"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i4.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: ContenteditableDirective, selector: "[rxapContenteditable]", inputs: ["rxapContenteditable", "disabled"], outputs: ["change"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i6.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatDividerModule }, { kind: "component", type: i7.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i8.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
497
669
|
}
|
|
498
670
|
__decorate([
|
|
499
671
|
DebounceCall(100),
|
|
@@ -504,9 +676,7 @@ __decorate([
|
|
|
504
676
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TreeComponent, decorators: [{
|
|
505
677
|
type: Component,
|
|
506
678
|
args: [{ selector: 'rxap-tree', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
|
|
507
|
-
FlexModule,
|
|
508
679
|
NgStyle,
|
|
509
|
-
ExtendedModule,
|
|
510
680
|
NgIf,
|
|
511
681
|
MatProgressBarModule,
|
|
512
682
|
MatTreeModule,
|
|
@@ -519,7 +689,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
|
|
|
519
689
|
MatDividerModule,
|
|
520
690
|
PortalModule,
|
|
521
691
|
AsyncPipe,
|
|
522
|
-
|
|
692
|
+
NgClass,
|
|
693
|
+
NgForOf,
|
|
694
|
+
], template: "<div class=\"grow flex flex-col gap-2\">\n <button type=\"button\" (click)=\"toggleTreeNavigation()\" class=\"!justify-start\" mat-button>\n <span class=\"flex flex-row justify-start items-center gap-6\">\n <ng-template [ngIf]=\"showTreeNavigation()\">\n <mat-icon>arrow_back</mat-icon>\n <span i18n>Hide tree navigation</span>\n </ng-template>\n <ng-template [ngIf]=\"!showTreeNavigation()\">\n <mat-icon>arrow_forward</mat-icon>\n <span i18n>Show tree navigation</span>\n </ng-template>\n </span>\n </button>\n <div class=\"flex flex-row grow\">\n <div #treeContainer [ngClass]=\"{ 'hidden': !showTreeNavigation() }\"\n [ngStyle]=\"{ maxWidth: dividerOffset, minWidth: dividerOffset, flexBasis: dividerOffset }\"\n class=\"w-fit grow-0 overflow-y-auto\">\n <mat-progress-bar *ngIf=\"!dataSource || (dataSource.loading$ | async)\" mode=\"indeterminate\"></mat-progress-bar>\n <ng-content select=\"[searchHeader]\"></ng-content>\n <mat-tree *ngIf=\"dataSource; else loading\" [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n\n <!-- Node without children -->\n <mat-tree-node *matTreeNodeDef=\"let node\" matTreeNodePadding>\n <div class=\"flex flex-row justify-start items-center gap-2\">\n <mat-icon [ngClass]=\"{ 'hidden': hideLeafIcon }\">subdirectory_arrow_right</mat-icon>\n <ng-container *ngIf=\"node.icon?.length\">\n <mat-icon *ngFor=\"let icon of node.icon\" [rxapIcon]=\"$any(icon)\"></mat-icon>\n </ng-container>\n <ng-template [ngIf]=\"multiple\">\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\">\n {{ node.display }}\n </mat-checkbox>\n </ng-template>\n <ng-template [ngIf]=\"!multiple\">\n <button\n type=\"button\"\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n </div>\n </mat-tree-node>\n\n <!-- Node with children -->\n <mat-tree-node *matTreeNodeDef=\"let node; when: hasChild\" matTreeNodePadding>\n <button type=\"button\" [attr.aria-label]=\"'toggle ' + node.filename\" mat-icon-button matTreeNodeToggle>\n <mat-icon class=\"mat-icon-rtl-mirror\">\n {{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}\n </mat-icon>\n </button>\n <div class=\"flex flex-row justify-start items-center gap-2\">\n <ng-container *ngIf=\"node.icon?.length else withoutIcon\">\n <mat-icon *ngFor=\"let icon of node.icon\" [rxapIcon]=\"$any(icon)\"></mat-icon>\n </ng-container>\n <ng-template #withoutIcon>\n <div></div>\n </ng-template>\n <ng-template [ngIfElse]=\"withoutDetails\" [ngIf]=\"node.hasDetails\">\n <button\n type=\"button\"\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n mat-button\n >\n {{ node.display }}\n </button>\n </ng-template>\n <ng-template #withoutDetails>\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n class=\"grow-0\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n </ng-template>\n <mat-progress-spinner\n *ngIf=\"node.isLoading$ | async\"\n [diameter]=\"16\"\n class=\"grow-0 pl-4\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n </div>\n </mat-tree-node>\n\n </mat-tree>\n </div>\n\n <div (mousedown)=\"onMousedown()\" *ngIf=\"showTreeNavigation()\"\n class=\"divider cursor-ew-resize px-3 grow-0\">\n <mat-divider [vertical]=\"true\" class=\"h-full\"></mat-divider>\n </div>\n\n <div class=\"grow\">\n <ng-container *ngIf=\"portal\">\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n </ng-container>\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n\n<ng-template #loading>Load data source</ng-template>\n" }]
|
|
523
695
|
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef, decorators: [{
|
|
524
696
|
type: Inject,
|
|
525
697
|
args: [ViewContainerRef]
|
|
@@ -531,7 +703,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
|
|
|
531
703
|
}, {
|
|
532
704
|
type: Inject,
|
|
533
705
|
args: [RXAP_TREE_CONTENT_EDITABLE_METHOD]
|
|
534
|
-
}] }, { type: i0.Renderer2 }]; }, propDecorators: { dataSource: [{
|
|
706
|
+
}] }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { dataSource: [{
|
|
535
707
|
type: Input,
|
|
536
708
|
args: [{ required: true }]
|
|
537
709
|
}], contentEditableMethod: [{
|
|
@@ -572,5 +744,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImpor
|
|
|
572
744
|
* Generated bundle index. Do not edit.
|
|
573
745
|
*/
|
|
574
746
|
|
|
575
|
-
export { RXAP_TREE_CONTENT_EDITABLE_METHOD, RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD, RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD, TreeComponent, TreeContentDirective, TreeDataSource, isSelectionChange };
|
|
747
|
+
export { DefaultTreeApplyFilterMethod, RXAP_TREE_CONTENT_EDITABLE_METHOD, RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD, RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD, RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD, TreeComponent, TreeContentDirective, TreeDataSource, flatTree, isSelectionChange };
|
|
576
748
|
//# sourceMappingURL=rxap-tree.mjs.map
|