@rxap/tree 12.4.0 → 13.0.0-next.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.
@@ -0,0 +1,567 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { BehaviorSubject, Subject, from, merge } from 'rxjs';
3
+ import { FlatTreeControl } from '@angular/cdk/tree';
4
+ import { SelectionModel } from '@angular/cdk/collections';
5
+ import { map, tap, switchMap, startWith } from 'rxjs/operators';
6
+ import { BaseDataSource, RXAP_DATA_SOURCE_METADATA } from '@rxap/data-source';
7
+ import { joinPath, Required, DebounceCall } from '@rxap/utilities';
8
+ import * as i0 from '@angular/core';
9
+ import { InjectionToken, Injectable, Inject, TemplateRef, Directive, EventEmitter, ViewContainerRef, ChangeDetectorRef, Component, ChangeDetectionStrategy, Optional, Input, ContentChild, Output, ViewChild, HostListener, NgModule } from '@angular/core';
10
+ import { ToggleSubject, Node } from '@rxap/utilities/rxjs';
11
+ import * as i13 from '@angular/cdk/portal';
12
+ import { TemplatePortal, PortalModule } from '@angular/cdk/portal';
13
+ import * as i1 from '@angular/material/progress-bar';
14
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
15
+ import * as i2 from '@angular/material/tree';
16
+ import { MatTreeModule } from '@angular/material/tree';
17
+ import * as i3 from '@angular/material/icon';
18
+ import { MatIconModule } from '@angular/material/icon';
19
+ import * as i4 from '@angular/material/checkbox';
20
+ import { MatCheckboxModule } from '@angular/material/checkbox';
21
+ import * as i5 from '@angular/material/button';
22
+ import { MatButtonModule } from '@angular/material/button';
23
+ import * as i6 from '@angular/material/progress-spinner';
24
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
25
+ import * as i7 from '@angular/material/divider';
26
+ import { MatDividerModule } from '@angular/material/divider';
27
+ import * as i8 from '@angular/flex-layout/flex';
28
+ import * as i9 from '@angular/common';
29
+ import { CommonModule } from '@angular/common';
30
+ import * as i10 from '@angular/flex-layout/extended';
31
+ import * as i11 from '@rxap/material-directives/icon';
32
+ import { IconDirectiveModule } from '@rxap/material-directives/icon';
33
+ import * as i12 from '@rxap/contenteditable';
34
+ import { ContenteditableDirectiveModule } from '@rxap/contenteditable';
35
+ import { FlexLayoutModule } from '@angular/flex-layout';
36
+
37
+ function isSelectionChange(obj) {
38
+ return !!obj && obj.hasOwnProperty('added') && obj.hasOwnProperty('removed');
39
+ }
40
+ const RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD = new InjectionToken('rxap/tree/data-source/root-remote-method');
41
+ const RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD = new InjectionToken('rxap/tree/data-source/children-remote-method');
42
+ class TreeDataSource extends BaseDataSource {
43
+ constructor(rootRemoteMethod, childrenRemoteMethod, metadata = null) {
44
+ super(metadata);
45
+ this.rootRemoteMethod = rootRemoteMethod;
46
+ this.childrenRemoteMethod = childrenRemoteMethod;
47
+ this.tree$ = new BehaviorSubject([]);
48
+ this._expandedLocalStorageSubscription = null;
49
+ this._selectedLocalStorageSubscription = null;
50
+ // TODO : änlich problem wie bei der redundaten expand SelectionModel.
51
+ // im localStorage wird nur die id gespeichert.
52
+ this._preSelected = [];
53
+ this._data$ = new BehaviorSubject([]);
54
+ this.loading$ = new ToggleSubject(true);
55
+ this.toDisplay = () => 'to display function not defined';
56
+ this.getIcon = () => null;
57
+ this.hasDetails = () => true;
58
+ this.matchFilter = () => true;
59
+ this._refreshMatchFilter = new Subject();
60
+ this.tree$
61
+ .pipe(map((tree) => tree
62
+ .map((child) => this.flatTree(child))
63
+ .reduce((acc, nodes) => [...acc, ...nodes], [])))
64
+ .subscribe(this._data$);
65
+ // TODO add new SelectModel class that saves the select model to the localStorage
66
+ this.initSelected();
67
+ this.initExpanded();
68
+ }
69
+ async getTreeRoot() {
70
+ this.loading$.enable();
71
+ const root = await this.getRoot();
72
+ let rootNodes;
73
+ if (Array.isArray(root)) {
74
+ rootNodes = await Promise.all(root.map((node) => this._toNode(node)));
75
+ }
76
+ else {
77
+ rootNodes = [await this._toNode(root)];
78
+ }
79
+ this.tree$.next(rootNodes);
80
+ this.loading$.disable();
81
+ return rootNodes;
82
+ }
83
+ selectNode(node) {
84
+ if (!this.selected.isMultipleSelection()) {
85
+ if (this.selected.hasValue()) {
86
+ const currentSelectedNode = this.selected.selected[0];
87
+ currentSelectedNode.deselect();
88
+ }
89
+ }
90
+ this.selected.select(node);
91
+ return Promise.resolve();
92
+ }
93
+ setTreeControl(treeControl) {
94
+ this.treeControl = treeControl;
95
+ }
96
+ setMatchFilter(matchFilter) {
97
+ this.matchFilter = matchFilter;
98
+ }
99
+ setToDisplay(toDisplay = this.toDisplay) {
100
+ this.toDisplay = toDisplay;
101
+ }
102
+ setGetIcon(getIcon = this.getIcon) {
103
+ this.getIcon = getIcon;
104
+ }
105
+ setHasDetails(hasDetails = this.hasDetails) {
106
+ this.hasDetails = hasDetails;
107
+ }
108
+ deselectNode(node) {
109
+ this.selected.deselect(node);
110
+ return Promise.resolve();
111
+ }
112
+ // - the SelectModel that stores the selection into the local storage?
113
+ 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)) {
114
+ const node = await this.toNode(item, depth, onExpand, onCollapse, onSelect, onDeselect);
115
+ if (this.expanded.isSelected(node.id)) {
116
+ node
117
+ .expand()
118
+ .then(() => {
119
+ // TODO : remove redundant this.expanded SelectionModel. Only store expanded nodes in this.treeControl.expansionModel
120
+ // das problem ist das ich beim speicher in localStorage nur die id speicher.
121
+ // Des wegen kann ich beim laden aus dem localStorage this.treeControl.expansionModel
122
+ // nicht einfach mit den expanend nodes fullen. Da dort das node object benötigt wird
123
+ // möglich lösungen:
124
+ // - das node object läde die entity mithilfe der id automatisch nach
125
+ this.treeControl.expansionModel.select(node);
126
+ console.debug(`Restore expand for node '${node.id}' SUCCESSFULLY`);
127
+ })
128
+ .catch(() => console.debug(`Restore expand for node '${node.id}' FAILED`));
129
+ }
130
+ if (this._preSelected.includes(node.id)) {
131
+ await node
132
+ .select()
133
+ .then(() => console.debug(`Restore select for node '${node.id}' SUCCESSFULLY`))
134
+ .catch(() => console.debug(`Restore select for node '${node.id}' FAILED`));
135
+ }
136
+ return node;
137
+ }
138
+ async expandNode(node) {
139
+ if (node.item.hasChildren && !node.item.children?.length) {
140
+ node.isLoading$.enable();
141
+ const children = await this.getChildren(node);
142
+ // add the loaded children to the item object
143
+ node.item.children = children;
144
+ node.addChildren(await Promise.all(children.map((child) => this._toNode(child, node.depth + 1, node.onExpand, node.onCollapse))));
145
+ node.isLoading$.disable();
146
+ }
147
+ this.expanded.select(node.id);
148
+ this.tree$.next(this.tree$.value);
149
+ }
150
+ async getChildren(node) {
151
+ return this.childrenRemoteMethod.call(node);
152
+ }
153
+ async getRoot() {
154
+ const rootParameters = await this.getRootParameters();
155
+ return this.rootRemoteMethod.call(rootParameters);
156
+ }
157
+ async getRootParameters() {
158
+ return undefined;
159
+ }
160
+ // TODO : find better solution to allow the overwrite of the toNode method
161
+ // without losing the custom preselect and preexpand function
162
+ getNodeById(id) {
163
+ function getNodeById(node, nodeId) {
164
+ if (node.id === nodeId) {
165
+ return node;
166
+ }
167
+ if (node.hasNode(nodeId)) {
168
+ return node.getNode(nodeId);
169
+ }
170
+ else {
171
+ return null;
172
+ }
173
+ }
174
+ return (this.tree$.value
175
+ .map((node) => getNodeById(node, id))
176
+ .filter(Boolean)[0] || null);
177
+ }
178
+ 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)) {
179
+ return Node.ToNode(item, depth, onExpand, onCollapse, this.toDisplay, this.getIcon, onSelect, onDeselect, this.hasDetails);
180
+ }
181
+ collapseNode(node) {
182
+ this.expanded.deselect(node.id);
183
+ this.tree$.next(this.tree$.value);
184
+ return Promise.resolve();
185
+ }
186
+ flatTree(tree) {
187
+ function flat(acc, list) {
188
+ return [...acc, ...list];
189
+ }
190
+ const flatTree = (node) => {
191
+ if (!Array.isArray(node.children)) {
192
+ console.log(node);
193
+ throw new Error('Node has not defined children');
194
+ }
195
+ if (node.expanded || this.expanded.isSelected(node.id)) {
196
+ return [
197
+ node,
198
+ ...node.children.map((child) => flatTree(child)).reduce(flat, []),
199
+ ];
200
+ }
201
+ else {
202
+ return [node];
203
+ }
204
+ };
205
+ return flatTree(tree);
206
+ }
207
+ destroy() {
208
+ super.destroy();
209
+ // TODO : add subscription handler to BaseDataSource
210
+ if (this._expandedLocalStorageSubscription) {
211
+ this._expandedLocalStorageSubscription.unsubscribe();
212
+ }
213
+ if (this._selectedLocalStorageSubscription) {
214
+ this._selectedLocalStorageSubscription.unsubscribe();
215
+ }
216
+ }
217
+ refreshMatchFilter() {
218
+ this._refreshMatchFilter.next();
219
+ }
220
+ _connect(collectionViewer) {
221
+ this.treeControl.expansionModel.changed.subscribe((change) => {
222
+ if (isSelectionChange(change)) {
223
+ if (change.added) {
224
+ change.added.forEach((node) => node.expand());
225
+ }
226
+ if (change.removed) {
227
+ change.removed
228
+ .slice()
229
+ .reverse()
230
+ .forEach((node) => node.collapse());
231
+ }
232
+ }
233
+ });
234
+ let loadRoot = Promise.resolve();
235
+ if (this.tree$.value.length === 0) {
236
+ loadRoot = this.getTreeRoot();
237
+ }
238
+ return from(loadRoot).pipe(tap((rootNodes) => {
239
+ if (rootNodes) {
240
+ const promises = [];
241
+ if (this.metadata.selectMultiple) {
242
+ if (!this.selected.hasValue()) {
243
+ promises.push(...rootNodes
244
+ .filter((node) => node.hasDetails)
245
+ .map((node) => node.select()));
246
+ }
247
+ if (!this.expanded.hasValue()) {
248
+ promises.push(...rootNodes
249
+ .filter((node) => node.hasChildren)
250
+ .map((node) => node.expand()));
251
+ }
252
+ }
253
+ else if (rootNodes.length) {
254
+ const rootNode = rootNodes[0];
255
+ if (!this.selected.hasValue()) {
256
+ // TODO : rename hasDetails to isSelectable
257
+ if (rootNode.hasDetails) {
258
+ promises.push(rootNode.select());
259
+ }
260
+ }
261
+ if (!this.expanded.hasValue()) {
262
+ promises.push(rootNode.expand());
263
+ }
264
+ }
265
+ return Promise.all(promises);
266
+ }
267
+ return Promise.resolve();
268
+ }), switchMap(() => merge(collectionViewer.viewChange, this._data$).pipe(map(() => this._data$.value))), switchMap(nodeList => this._refreshMatchFilter.pipe(startWith(null), map(() => nodeList.filter(node => this.matchFilter(node))))));
269
+ }
270
+ async refresh() {
271
+ const rootNodes = await this.getTreeRoot();
272
+ // refresh all expanded nodes;
273
+ const loadExpandedNodes = async (children) => {
274
+ for (const child of children) {
275
+ if (this.expanded.isSelected(child.id)) {
276
+ // call the node method to ensure that the expanded property of
277
+ // Node is set.
278
+ await child.expand();
279
+ }
280
+ if (child.hasChildren) {
281
+ await loadExpandedNodes(child.children);
282
+ }
283
+ }
284
+ };
285
+ await Promise.all(rootNodes
286
+ .filter((node) => node.hasChildren)
287
+ .map((node) => loadExpandedNodes(node.children)));
288
+ const selected = this.selected.selected
289
+ .map((node) => this.getNodeById(node.id))
290
+ .filter(Boolean);
291
+ this.selected.clear();
292
+ this.selected.select(...selected);
293
+ }
294
+ initSelected() {
295
+ const key = joinPath('rxap/tree', this.id, 'selected');
296
+ if (this.metadata.cacheSelected) {
297
+ if (localStorage.getItem(key)) {
298
+ try {
299
+ this._preSelected = JSON.parse(localStorage.getItem(key));
300
+ }
301
+ catch (e) {
302
+ console.debug('parse expanded tree data source nodes failed');
303
+ }
304
+ }
305
+ }
306
+ this.selected = new SelectionModel(!!this.metadata.selectMultiple, []);
307
+ if (this.metadata.cacheSelected) {
308
+ this._selectedLocalStorageSubscription = this.selected.changed
309
+ .pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.selected.selected.map((s) => s.id)))))
310
+ .subscribe();
311
+ }
312
+ }
313
+ reset() {
314
+ this.selected.clear();
315
+ this.expanded.clear();
316
+ return this.getTreeRoot();
317
+ }
318
+ initExpanded() {
319
+ const key = joinPath('rxap/tree', this.id, 'expanded');
320
+ let expanded = [];
321
+ if (this.metadata.cacheExpanded) {
322
+ if (localStorage.getItem(key)) {
323
+ try {
324
+ expanded = JSON.parse(localStorage.getItem(key));
325
+ }
326
+ catch (e) {
327
+ console.debug('parse expanded tree data source nodes failed');
328
+ }
329
+ }
330
+ }
331
+ this.expanded = new SelectionModel(this.metadata.expandMultiple !== false, expanded);
332
+ if (this.metadata.cacheExpanded) {
333
+ this._expandedLocalStorageSubscription = this.expanded.changed
334
+ .pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.expanded.selected))))
335
+ .subscribe();
336
+ }
337
+ }
338
+ }
339
+ TreeDataSource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", 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 });
340
+ TreeDataSource.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeDataSource });
341
+ __decorate([
342
+ Required,
343
+ __metadata("design:type", FlatTreeControl)
344
+ ], TreeDataSource.prototype, "treeControl", void 0);
345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeDataSource, decorators: [{
346
+ type: Injectable
347
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
348
+ type: Inject,
349
+ args: [RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD]
350
+ }] }, { type: undefined, decorators: [{
351
+ type: Inject,
352
+ args: [RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD]
353
+ }] }, { type: undefined, decorators: [{
354
+ type: Inject,
355
+ args: [RXAP_DATA_SOURCE_METADATA]
356
+ }] }]; }, propDecorators: { treeControl: [] } });
357
+
358
+ class TreeContentDirective {
359
+ constructor(template) {
360
+ this.template = template;
361
+ }
362
+ }
363
+ TreeContentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeContentDirective, deps: [{ token: TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
364
+ TreeContentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: TreeContentDirective, selector: "ng-template[rxapTreeContent]", ngImport: i0 });
365
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeContentDirective, decorators: [{
366
+ type: Directive,
367
+ args: [{
368
+ // tslint:disable-next-line:directive-selector
369
+ selector: 'ng-template[rxapTreeContent]',
370
+ }]
371
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
372
+ type: Inject,
373
+ args: [TemplateRef]
374
+ }] }]; } });
375
+
376
+ const RXAP_TREE_CONTENT_EDITABLE_METHOD = new InjectionToken('rxap/tree-content-editable-method');
377
+
378
+ class TreeComponent {
379
+ constructor(viewContainerRef, cdr, contentEditableMethod, renderer) {
380
+ this.viewContainerRef = viewContainerRef;
381
+ this.cdr = cdr;
382
+ this.renderer = renderer;
383
+ this.multiple = false;
384
+ this.hideLeafIcon = false;
385
+ this.details = new EventEmitter();
386
+ this.portal = null;
387
+ this.getLevel = (node) => node.depth;
388
+ this.isExpandable = (node) => node.hasChildren;
389
+ this.hasChild = (_, nodeData) => nodeData.hasChildren;
390
+ /**
391
+ * Indicates that the divider is moved with mouse down
392
+ * @private
393
+ */
394
+ this._moveDivider = false;
395
+ /**
396
+ * Holds the current tree container width.
397
+ * If null the move divider feature was not yet used and the initial
398
+ * container width is not calculated
399
+ * @private
400
+ */
401
+ this._treeContainerWidth = null;
402
+ this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
403
+ this.contentEditableMethod = contentEditableMethod;
404
+ }
405
+ get nodeDisplayEditable() {
406
+ return !!this.contentEditableMethod;
407
+ }
408
+ ngOnInit() {
409
+ this.dataSource.setTreeControl(this.treeControl);
410
+ this.dataSource.setToDisplay(this.toDisplay);
411
+ this.dataSource.setGetIcon(this.getIcon);
412
+ this.dataSource.setHasDetails(this.hasDetails);
413
+ this.multiple = this.dataSource.metadata.selectMultiple ?? this.multiple;
414
+ if (this.dataSource.selected.hasValue()) {
415
+ this.dataSource.selected.selected.forEach((node) => this.openDetails(node));
416
+ }
417
+ }
418
+ ngAfterContentInit() {
419
+ this.dataSource.selected.changed
420
+ .pipe(map(($event) => $event.source.selected), startWith(this.dataSource.selected.selected), tap((selected) => selected.forEach((node) => this.openDetails(node))))
421
+ .subscribe();
422
+ }
423
+ openDetails(node) {
424
+ if (this.content) {
425
+ this.portal = new TemplatePortal(this.content.template, this.viewContainerRef, {
426
+ $implicit: node.item,
427
+ node,
428
+ });
429
+ this.cdr.markForCheck();
430
+ }
431
+ this.details.emit(node.item);
432
+ }
433
+ onContentEditableChange(value, node) {
434
+ return this.contentEditableMethod?.call(value, node.item, node);
435
+ }
436
+ onMousedown() {
437
+ this._moveDivider = true;
438
+ }
439
+ onMouseup() {
440
+ this._moveDivider = false;
441
+ }
442
+ onMousemove($event) {
443
+ if (this._moveDivider) {
444
+ if (!this._treeContainerWidth) {
445
+ this._treeContainerWidth = this.treeContainer.nativeElement.clientWidth;
446
+ }
447
+ this._treeContainerWidth = $event.clientX - 75;
448
+ const width = this._treeContainerWidth + 'px';
449
+ this.renderer.setStyle(this.treeContainer.nativeElement, 'max-width', width);
450
+ this.renderer.setStyle(this.treeContainer.nativeElement, 'min-width', width);
451
+ this.renderer.setStyle(this.treeContainer.nativeElement, 'flex-basis', width);
452
+ }
453
+ }
454
+ }
455
+ TreeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponent, deps: [{ token: ViewContainerRef }, { token: ChangeDetectorRef }, { token: RXAP_TREE_CONTENT_EDITABLE_METHOD, optional: true }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
456
+ TreeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: TreeComponent, selector: "rxap-tree", inputs: { dataSource: "dataSource", contentEditableMethod: "contentEditableMethod", toDisplay: "toDisplay", getIcon: "getIcon", multiple: "multiple", hasDetails: "hasDetails", hideLeafIcon: "hideLeafIcon" }, 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 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\" 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 (change)=\"node.toggleSelect()\" [checked]=\"node.selected\" [disabled]=\"!node.hasDetails\" fxFlex=\"nogrow\">{{ node.display }}</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 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 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 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;min-width:256px;width:-moz-fit-content;width:fit-content}.divider{cursor:ew-resize;padding:12px}.divider ::ng-deep .mat-divider{height:100%}\n"], components: [{ type: i1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { type: i2.MatTree, selector: "mat-tree", exportAs: ["matTree"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i5.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i6.MatProgressSpinner, selector: "mat-progress-spinner", inputs: ["color", "diameter", "strokeWidth", "mode", "value"], exportAs: ["matProgressSpinner"] }, { type: i7.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }], directives: [{ type: i8.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"] }, { type: i8.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"] }, { type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.MatTreeNodeDef, selector: "[matTreeNodeDef]", inputs: ["matTreeNodeDefWhen", "matTreeNode"] }, { type: i2.MatTreeNode, selector: "mat-tree-node", inputs: ["role", "disabled", "tabIndex"], exportAs: ["matTreeNode"] }, { type: i2.MatTreeNodePadding, selector: "[matTreeNodePadding]", inputs: ["matTreeNodePadding", "matTreeNodePaddingIndent"] }, { type: i8.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"] }, { type: i10.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"] }, { type: i11.IconDirective, selector: "mat-icon[rxapIcon]", inputs: ["rxapIcon"] }, { type: i2.MatTreeNodeToggle, selector: "[matTreeNodeToggle]", inputs: ["matTreeNodeToggleRecursive"] }, { type: i12.ContenteditableDirective, selector: "[rxapContenteditable]", inputs: ["rxapContenteditable", "disabled"], outputs: ["change"] }, { type: i8.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"] }, { type: i13.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], pipes: { "async": i9.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
457
+ __decorate([
458
+ Required,
459
+ __metadata("design:type", TreeDataSource)
460
+ ], TreeComponent.prototype, "dataSource", void 0);
461
+ __decorate([
462
+ DebounceCall(100),
463
+ __metadata("design:type", Function),
464
+ __metadata("design:paramtypes", [Node]),
465
+ __metadata("design:returntype", void 0)
466
+ ], TreeComponent.prototype, "openDetails", null);
467
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponent, decorators: [{
468
+ type: Component,
469
+ args: [{ selector: 'rxap-tree', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"container\" fxLayout=\"row\">\n <div #treeContainer 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\" 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 (change)=\"node.toggleSelect()\" [checked]=\"node.selected\" [disabled]=\"!node.hasDetails\" fxFlex=\"nogrow\">{{ node.display }}</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 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 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 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;min-width:256px;width:-moz-fit-content;width:fit-content}.divider{cursor:ew-resize;padding:12px}.divider ::ng-deep .mat-divider{height:100%}\n"] }]
470
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef, decorators: [{
471
+ type: Inject,
472
+ args: [ViewContainerRef]
473
+ }] }, { type: i0.ChangeDetectorRef, decorators: [{
474
+ type: Inject,
475
+ args: [ChangeDetectorRef]
476
+ }] }, { type: undefined, decorators: [{
477
+ type: Optional
478
+ }, {
479
+ type: Inject,
480
+ args: [RXAP_TREE_CONTENT_EDITABLE_METHOD]
481
+ }] }, { type: i0.Renderer2 }]; }, propDecorators: { dataSource: [{
482
+ type: Input
483
+ }], contentEditableMethod: [{
484
+ type: Input
485
+ }], toDisplay: [{
486
+ type: Input
487
+ }], getIcon: [{
488
+ type: Input
489
+ }], multiple: [{
490
+ type: Input
491
+ }], hasDetails: [{
492
+ type: Input
493
+ }], content: [{
494
+ type: ContentChild,
495
+ args: [TreeContentDirective, { static: true }]
496
+ }], hideLeafIcon: [{
497
+ type: Input
498
+ }], details: [{
499
+ type: Output
500
+ }], treeContainer: [{
501
+ type: ViewChild,
502
+ args: ['treeContainer', { static: true }]
503
+ }], openDetails: [], onMouseup: [{
504
+ type: HostListener,
505
+ args: ['mouseup']
506
+ }], onMousemove: [{
507
+ type: HostListener,
508
+ args: ['mousemove', ['$event']]
509
+ }] } });
510
+
511
+ class TreeComponentModule {
512
+ }
513
+ TreeComponentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
514
+ TreeComponentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponentModule, declarations: [TreeComponent, TreeContentDirective], imports: [CommonModule,
515
+ MatTreeModule,
516
+ MatButtonModule,
517
+ MatIconModule,
518
+ FlexLayoutModule,
519
+ MatDividerModule,
520
+ MatProgressSpinnerModule,
521
+ PortalModule,
522
+ ContenteditableDirectiveModule,
523
+ IconDirectiveModule,
524
+ MatCheckboxModule,
525
+ MatProgressBarModule], exports: [TreeComponent, TreeContentDirective] });
526
+ TreeComponentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponentModule, imports: [[
527
+ CommonModule,
528
+ MatTreeModule,
529
+ MatButtonModule,
530
+ MatIconModule,
531
+ FlexLayoutModule,
532
+ MatDividerModule,
533
+ MatProgressSpinnerModule,
534
+ PortalModule,
535
+ ContenteditableDirectiveModule,
536
+ IconDirectiveModule,
537
+ MatCheckboxModule,
538
+ MatProgressBarModule
539
+ ]] });
540
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TreeComponentModule, decorators: [{
541
+ type: NgModule,
542
+ args: [{
543
+ imports: [
544
+ CommonModule,
545
+ MatTreeModule,
546
+ MatButtonModule,
547
+ MatIconModule,
548
+ FlexLayoutModule,
549
+ MatDividerModule,
550
+ MatProgressSpinnerModule,
551
+ PortalModule,
552
+ ContenteditableDirectiveModule,
553
+ IconDirectiveModule,
554
+ MatCheckboxModule,
555
+ MatProgressBarModule
556
+ ],
557
+ declarations: [TreeComponent, TreeContentDirective],
558
+ exports: [TreeComponent, TreeContentDirective]
559
+ }]
560
+ }] });
561
+
562
+ /**
563
+ * Generated bundle index. Do not edit.
564
+ */
565
+
566
+ export { RXAP_TREE_CONTENT_EDITABLE_METHOD, RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD, RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD, TreeComponent, TreeComponentModule, TreeContentDirective, TreeDataSource, isSelectionChange };
567
+ //# sourceMappingURL=rxap-tree.mjs.map