@rxap/tree 21.0.1-dev.1 → 22.0.0-dev.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 +39 -0
- package/compodoc/changelog.html +37 -0
- package/compodoc/dependencies.html +13 -13
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +232 -232
- package/docs/html/classes/DefaultTreeApplyFilterMethod.html +2 -2
- package/docs/html/classes/SearchForm.html +2 -2
- package/docs/html/classes/TreeComponent.html +2 -2
- package/docs/html/classes/TreeContentDirective.html +2 -2
- package/docs/html/classes/TreeDataSource.html +16 -16
- package/docs/html/functions/FormFactory.html +1 -1
- package/docs/html/functions/flatTree.html +1 -1
- package/docs/html/functions/isSelectionChange.html +1 -1
- package/docs/html/index.html +2 -2
- package/docs/html/interfaces/ISearchForm.html +2 -2
- package/docs/html/interfaces/TreeApplyFilterParameter.html +2 -2
- package/docs/html/interfaces/TreeDataSourceMetadata.html +3 -3
- package/docs/html/modules.html +1 -1
- package/docs/html/variables/RXAP_TREE_CONTENT_EDITABLE_METHOD.html +1 -1
- package/docs/html/variables/RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD.html +1 -1
- package/docs/html/variables/RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD.html +1 -1
- package/docs/html/variables/RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD.html +1 -1
- package/docs/html/variables/SearchFormProviders.html +1 -1
- package/docs/markdown/README.md +1 -1
- package/docs/markdown/classes/DefaultTreeApplyFilterMethod.md +5 -5
- package/docs/markdown/classes/SearchForm.md +5 -5
- package/docs/markdown/classes/TreeComponent.md +35 -35
- package/docs/markdown/classes/TreeContentDirective.md +3 -3
- package/docs/markdown/classes/TreeDataSource.md +87 -87
- package/docs/markdown/functions/FormFactory.md +2 -2
- package/docs/markdown/functions/flatTree.md +2 -2
- package/docs/markdown/functions/isSelectionChange.md +2 -2
- package/docs/markdown/globals.md +2 -2
- package/docs/markdown/interfaces/ISearchForm.md +4 -4
- package/docs/markdown/interfaces/TreeApplyFilterParameter.md +5 -5
- package/docs/markdown/interfaces/TreeDataSourceMetadata.md +8 -8
- package/docs/markdown/variables/RXAP_TREE_CONTENT_EDITABLE_METHOD.md +2 -2
- package/docs/markdown/variables/RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD.md +2 -2
- package/docs/markdown/variables/RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD.md +2 -2
- package/docs/markdown/variables/RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD.md +2 -2
- package/docs/markdown/variables/SearchFormProviders.md +2 -2
- package/docs/wiki/Class.DefaultTreeApplyFilterMethod.md +4 -4
- package/docs/wiki/Class.SearchForm.md +4 -4
- package/docs/wiki/Class.TreeComponent.md +34 -34
- package/docs/wiki/Class.TreeContentDirective.md +2 -2
- package/docs/wiki/Class.TreeDataSource.md +86 -86
- package/docs/wiki/Function.FormFactory.md +1 -1
- package/docs/wiki/Function.flatTree.md +1 -1
- package/docs/wiki/Function.isSelectionChange.md +1 -1
- package/docs/wiki/Interface.ISearchForm.md +3 -3
- package/docs/wiki/Interface.TreeApplyFilterParameter.md +4 -4
- package/docs/wiki/Interface.TreeDataSourceMetadata.md +7 -7
- package/docs/wiki/Variable.RXAP_TREE_CONTENT_EDITABLE_METHOD.md +1 -1
- package/docs/wiki/Variable.RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD.md +1 -1
- package/docs/wiki/Variable.RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD.md +1 -1
- package/docs/wiki/Variable.RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD.md +1 -1
- package/docs/wiki/Variable.SearchFormProviders.md +1 -1
- package/docs/wiki/globals.md +1 -1
- package/fesm2022/rxap-tree.mjs +1037 -762
- package/fesm2022/rxap-tree.mjs.map +1 -1
- package/package.json +37 -37
- package/types/rxap-tree.d.ts +235 -182
package/fesm2022/rxap-tree.mjs
CHANGED
|
@@ -1,775 +1,1050 @@
|
|
|
1
|
-
import { __decorate, __metadata } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import * as i8 from
|
|
6
|
-
import {
|
|
7
|
-
import { FlatTreeControl } from
|
|
8
|
-
import {
|
|
9
|
-
import * as i5 from
|
|
10
|
-
import { MatButtonModule } from
|
|
11
|
-
import * as i4 from
|
|
12
|
-
import { MatCheckboxModule } from
|
|
13
|
-
import * as i7 from
|
|
14
|
-
import { MatDividerModule } from
|
|
15
|
-
import * as i3 from
|
|
16
|
-
import { MatIconModule } from
|
|
17
|
-
import * as i1 from
|
|
18
|
-
import { MatProgressBarModule } from
|
|
19
|
-
import * as i6 from
|
|
20
|
-
import { MatProgressSpinnerModule } from
|
|
21
|
-
import * as i2 from
|
|
22
|
-
import { MatTreeModule } from
|
|
23
|
-
import { ContenteditableDirective } from
|
|
24
|
-
import { Node } from
|
|
25
|
-
import { IconDirective } from
|
|
26
|
-
import { DebounceCall, coerceArray, getIdentifierPropertyValue, joinPath
|
|
27
|
-
import { map, startWith,
|
|
28
|
-
import { SelectionModel } from
|
|
29
|
-
import { BaseDataSource, RXAP_DATA_SOURCE_METADATA, RxapDataSource } from
|
|
30
|
-
import { ToggleSubject } from
|
|
31
|
-
import { BehaviorSubject, Subject, combineLatest, debounceTime, from, merge } from
|
|
32
|
-
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, Directive, ElementRef, INJECTOR, Injectable, InjectionToken, Optional, SkipSelf, TemplateRef, ViewContainerRef, afterNextRender, computed, contentChild, effect, inject, input, isDevMode, linkedSignal, output, signal, untracked, viewChild } from "@angular/core";
|
|
4
|
+
import { RXAP_FORM_DEFINITION, RXAP_FORM_INITIAL_STATE, RxapForm, RxapFormBuilder, RxapFormControl, UseFormControl } from "@rxap/forms";
|
|
5
|
+
import * as i8 from "@angular/cdk/portal";
|
|
6
|
+
import { PortalModule, TemplatePortal } from "@angular/cdk/portal";
|
|
7
|
+
import { FlatTreeControl } from "@angular/cdk/tree";
|
|
8
|
+
import { AsyncPipe, NgClass, NgStyle } from "@angular/common";
|
|
9
|
+
import * as i5 from "@angular/material/button";
|
|
10
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
11
|
+
import * as i4 from "@angular/material/checkbox";
|
|
12
|
+
import { MatCheckboxModule } from "@angular/material/checkbox";
|
|
13
|
+
import * as i7 from "@angular/material/divider";
|
|
14
|
+
import { MatDividerModule } from "@angular/material/divider";
|
|
15
|
+
import * as i3 from "@angular/material/icon";
|
|
16
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
17
|
+
import * as i1 from "@angular/material/progress-bar";
|
|
18
|
+
import { MatProgressBarModule } from "@angular/material/progress-bar";
|
|
19
|
+
import * as i6 from "@angular/material/progress-spinner";
|
|
20
|
+
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
|
|
21
|
+
import * as i2 from "@angular/material/tree";
|
|
22
|
+
import { MatTreeModule } from "@angular/material/tree";
|
|
23
|
+
import { ContenteditableDirective } from "@rxap/contenteditable";
|
|
24
|
+
import { Node } from "@rxap/data-structure-tree";
|
|
25
|
+
import { IconDirective } from "@rxap/material-directives/icon";
|
|
26
|
+
import { DebounceCall, Required, coerceArray, getIdentifierPropertyValue, joinPath } from "@rxap/utilities";
|
|
27
|
+
import { map, startWith, switchMap, tap } from "rxjs/operators";
|
|
28
|
+
import { SelectionModel } from "@angular/cdk/collections";
|
|
29
|
+
import { BaseDataSource, RXAP_DATA_SOURCE_METADATA, RxapDataSource } from "@rxap/data-source";
|
|
30
|
+
import { ToggleSubject } from "@rxap/rxjs";
|
|
31
|
+
import { BehaviorSubject, Subject, combineLatest, debounceTime, from, merge } from "rxjs";
|
|
33
32
|
let SearchForm = class SearchForm {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
static {
|
|
34
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
35
|
+
minVersion: "12.0.0",
|
|
36
|
+
version: "22.3.0",
|
|
37
|
+
ngImport: i0,
|
|
38
|
+
type: SearchForm,
|
|
39
|
+
deps: [],
|
|
40
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
static {
|
|
44
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
45
|
+
minVersion: "12.0.0",
|
|
46
|
+
version: "22.3.0",
|
|
47
|
+
ngImport: i0,
|
|
48
|
+
type: SearchForm
|
|
49
|
+
});
|
|
50
|
+
}
|
|
36
51
|
};
|
|
37
|
-
__decorate([
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
__decorate([UseFormControl(), __metadata("design:type", RxapFormControl)], SearchForm.prototype, "search", void 0);
|
|
53
|
+
__decorate([UseFormControl(), __metadata("design:type", RxapFormControl)], SearchForm.prototype, "scope", void 0);
|
|
54
|
+
SearchForm = __decorate([RxapForm({
|
|
55
|
+
id: "search",
|
|
56
|
+
autoSubmit: 500
|
|
57
|
+
})], SearchForm);
|
|
58
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
59
|
+
minVersion: "12.0.0",
|
|
60
|
+
version: "22.3.0",
|
|
61
|
+
ngImport: i0,
|
|
62
|
+
type: SearchForm,
|
|
63
|
+
decorators: [{ type: Injectable }],
|
|
64
|
+
propDecorators: {
|
|
65
|
+
search: [],
|
|
66
|
+
scope: []
|
|
67
|
+
}
|
|
68
|
+
});
|
|
54
69
|
function FormFactory(injector, state, existingFormDefinition) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return new RxapFormBuilder(SearchForm, injector).build(state ?? {});
|
|
59
|
-
}
|
|
60
|
-
const SearchFormProviders = [
|
|
61
|
-
SearchForm,
|
|
62
|
-
{
|
|
63
|
-
provide: RXAP_FORM_DEFINITION,
|
|
64
|
-
useFactory: FormFactory,
|
|
65
|
-
deps: [
|
|
66
|
-
INJECTOR,
|
|
67
|
-
[new Optional(), RXAP_FORM_INITIAL_STATE],
|
|
68
|
-
[new SkipSelf(), new Optional(), RXAP_FORM_DEFINITION],
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
const RXAP_TREE_CONTENT_EDITABLE_METHOD = new InjectionToken('rxap/tree-content-editable-method');
|
|
74
|
-
|
|
75
|
-
class TreeContentDirective {
|
|
76
|
-
constructor() {
|
|
77
|
-
this.template = inject(TemplateRef);
|
|
78
|
-
}
|
|
79
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: TreeContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
80
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: TreeContentDirective, isStandalone: true, selector: "ng-template[rxapTreeContent]", ngImport: i0 }); }
|
|
81
|
-
}
|
|
82
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: TreeContentDirective, decorators: [{
|
|
83
|
-
type: Directive,
|
|
84
|
-
args: [{
|
|
85
|
-
selector: 'ng-template[rxapTreeContent]',
|
|
86
|
-
standalone: true,
|
|
87
|
-
}]
|
|
88
|
-
}] });
|
|
89
|
-
|
|
90
|
-
class TreeComponent {
|
|
91
|
-
constructor() {
|
|
92
|
-
this.viewContainerRef = inject(ViewContainerRef);
|
|
93
|
-
this.elementRef = inject(ElementRef);
|
|
94
|
-
this.searchForm = inject(RXAP_FORM_DEFINITION, { optional: true });
|
|
95
|
-
this.dataSource = input.required(...(ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []));
|
|
96
|
-
this.contentEditableMethodInput = input(null, { ...(ngDevMode ? { debugName: "contentEditableMethodInput" } : /* istanbul ignore next */ {}), alias: 'contentEditableMethod' });
|
|
97
|
-
this.injectedContentEditableMethod = inject(RXAP_TREE_CONTENT_EDITABLE_METHOD, { optional: true });
|
|
98
|
-
this.contentEditableMethod = computed(() => this.contentEditableMethodInput() ?? this.injectedContentEditableMethod, ...(ngDevMode ? [{ debugName: "contentEditableMethod" }] : /* istanbul ignore next */ []));
|
|
99
|
-
this.toDisplay = input(...(ngDevMode ? [undefined, { debugName: "toDisplay" }] : /* istanbul ignore next */ []));
|
|
100
|
-
this.getIcon = input(...(ngDevMode ? [undefined, { debugName: "getIcon" }] : /* istanbul ignore next */ []));
|
|
101
|
-
this.getType = input(...(ngDevMode ? [undefined, { debugName: "getType" }] : /* istanbul ignore next */ []));
|
|
102
|
-
this.getStyle = input(...(ngDevMode ? [undefined, { debugName: "getStyle" }] : /* istanbul ignore next */ []));
|
|
103
|
-
this.multipleInput = input(false, { ...(ngDevMode ? { debugName: "multipleInput" } : /* istanbul ignore next */ {}), alias: 'multiple' });
|
|
104
|
-
this.multiple = computed(() => this.dataSource().metadata?.selectMultiple ?? this.multipleInput(), ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
105
|
-
this.hasDetails = input(...(ngDevMode ? [undefined, { debugName: "hasDetails" }] : /* istanbul ignore next */ []));
|
|
106
|
-
this.content = contentChild(TreeContentDirective, ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
107
|
-
this.hideLeafIcon = input(false, ...(ngDevMode ? [{ debugName: "hideLeafIcon" }] : /* istanbul ignore next */ []));
|
|
108
|
-
this.id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : /* istanbul ignore next */ []));
|
|
109
|
-
this.details = output();
|
|
110
|
-
this.dividerOffsetInput = input('256px', { ...(ngDevMode ? { debugName: "dividerOffsetInput" } : /* istanbul ignore next */ {}), alias: 'dividerOffset' });
|
|
111
|
-
this.dividerOffset = linkedSignal(() => this.dividerOffsetInput(), ...(ngDevMode ? [{ debugName: "dividerOffset" }] : /* istanbul ignore next */ []));
|
|
112
|
-
this.portal = signal(null, ...(ngDevMode ? [{ debugName: "portal" }] : /* istanbul ignore next */ []));
|
|
113
|
-
this.treeContainer = viewChild.required('treeContainer');
|
|
114
|
-
this.showTreeNavigation = signal(true, ...(ngDevMode ? [{ debugName: "showTreeNavigation" }] : /* istanbul ignore next */ []));
|
|
115
|
-
/**
|
|
116
|
-
* Indicates that the divider is moved with mouse down
|
|
117
|
-
* @private
|
|
118
|
-
*/
|
|
119
|
-
this._moveDivider = false;
|
|
120
|
-
/**
|
|
121
|
-
* Holds the current tree container width.
|
|
122
|
-
* If null the move divider feature was not yet used and the initial
|
|
123
|
-
* container width is not calculated
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
this._treeContainerWidth = null;
|
|
127
|
-
this.getLevel = (node) => node.depth;
|
|
128
|
-
this.isExpandable = (node) => node.hasChildren;
|
|
129
|
-
this.hasChild = (_, nodeData) => nodeData.hasChildren;
|
|
130
|
-
this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
|
|
131
|
-
effect(() => {
|
|
132
|
-
const dataSource = this.dataSource();
|
|
133
|
-
const toDisplay = this.toDisplay();
|
|
134
|
-
const getIcon = this.getIcon();
|
|
135
|
-
const hasDetails = this.hasDetails();
|
|
136
|
-
const getStyle = this.getStyle();
|
|
137
|
-
const getType = this.getType();
|
|
138
|
-
untracked(() => {
|
|
139
|
-
dataSource.searchForm = this.searchForm;
|
|
140
|
-
dataSource.setTreeControl(this.treeControl);
|
|
141
|
-
dataSource.setToDisplay(toDisplay);
|
|
142
|
-
dataSource.setGetIcon(getIcon);
|
|
143
|
-
dataSource.setHasDetails(hasDetails);
|
|
144
|
-
dataSource.setGetStyle(getStyle);
|
|
145
|
-
dataSource.setGetType(getType);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
effect((onCleanup) => {
|
|
149
|
-
const selected = this.dataSource().selected;
|
|
150
|
-
const subscription = untracked(() => selected.changed
|
|
151
|
-
.pipe(map(($event) => $event.source.selected), startWith(selected.selected), tap((nodes) => nodes.forEach((node) => this.openDetails(node))))
|
|
152
|
-
.subscribe());
|
|
153
|
-
onCleanup(() => subscription.unsubscribe());
|
|
154
|
-
});
|
|
155
|
-
afterNextRender(() => {
|
|
156
|
-
const cachedOffset = localStorage.getItem(this.cacheId);
|
|
157
|
-
if (cachedOffset && cachedOffset.match(/^(\d+\.)?\d+px$/)) {
|
|
158
|
-
this.dividerOffset.set(cachedOffset);
|
|
159
|
-
}
|
|
160
|
-
else if (isDevMode()) {
|
|
161
|
-
console.log('Divider offset cache is not available or invalid: ' + cachedOffset);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
get nodeDisplayEditable() {
|
|
166
|
-
return !!this.contentEditableMethod();
|
|
167
|
-
}
|
|
168
|
-
get cacheId() {
|
|
169
|
-
return ['rxap', 'tree', this.id()].join('/');
|
|
170
|
-
}
|
|
171
|
-
openDetails(node) {
|
|
172
|
-
const content = this.content();
|
|
173
|
-
if (content) {
|
|
174
|
-
this.portal.set(new TemplatePortal(content.template, this.viewContainerRef, {
|
|
175
|
-
$implicit: node.item,
|
|
176
|
-
node,
|
|
177
|
-
}));
|
|
178
|
-
}
|
|
179
|
-
this.details.emit(node.item);
|
|
180
|
-
}
|
|
181
|
-
onContentEditableChange(value, node) {
|
|
182
|
-
return this.contentEditableMethod()?.call(value, node.item, node);
|
|
183
|
-
}
|
|
184
|
-
onMousedown() {
|
|
185
|
-
this._moveDivider = true;
|
|
186
|
-
}
|
|
187
|
-
onMouseup() {
|
|
188
|
-
this._moveDivider = false;
|
|
189
|
-
}
|
|
190
|
-
onMousemove($event) {
|
|
191
|
-
if (this._moveDivider) {
|
|
192
|
-
if (!this._treeContainerWidth) {
|
|
193
|
-
this._treeContainerWidth = this.treeContainer().nativeElement.clientWidth;
|
|
194
|
-
}
|
|
195
|
-
const rect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
196
|
-
this._treeContainerWidth = Math.min(Math.max($event.clientX - (rect.left + 12), 128), rect.right - rect.left - 128);
|
|
197
|
-
const offset = this._treeContainerWidth + 'px';
|
|
198
|
-
this.setDividerOffset(offset);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
toggleTreeNavigation() {
|
|
202
|
-
this.showTreeNavigation.update((value) => !value);
|
|
203
|
-
}
|
|
204
|
-
setDividerOffset(offset) {
|
|
205
|
-
this.dividerOffset.set(offset);
|
|
206
|
-
localStorage.setItem(this.cacheId, offset);
|
|
207
|
-
}
|
|
208
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: TreeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
209
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: TreeComponent, isStandalone: true, selector: "rxap-tree", inputs: { dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: true, transformFunction: null }, contentEditableMethodInput: { classPropertyName: "contentEditableMethodInput", publicName: "contentEditableMethod", isSignal: true, isRequired: false, transformFunction: null }, toDisplay: { classPropertyName: "toDisplay", publicName: "toDisplay", isSignal: true, isRequired: false, transformFunction: null }, getIcon: { classPropertyName: "getIcon", publicName: "getIcon", isSignal: true, isRequired: false, transformFunction: null }, getType: { classPropertyName: "getType", publicName: "getType", isSignal: true, isRequired: false, transformFunction: null }, getStyle: { classPropertyName: "getStyle", publicName: "getStyle", isSignal: true, isRequired: false, transformFunction: null }, multipleInput: { classPropertyName: "multipleInput", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, hasDetails: { classPropertyName: "hasDetails", publicName: "hasDetails", isSignal: true, isRequired: false, transformFunction: null }, hideLeafIcon: { classPropertyName: "hideLeafIcon", publicName: "hideLeafIcon", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, dividerOffsetInput: { classPropertyName: "dividerOffsetInput", publicName: "dividerOffset", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { details: "details" }, host: { listeners: { "mouseup": "onMouseup()", "mousemove": "onMousemove($event)" } }, queries: [{ propertyName: "content", first: true, predicate: TreeContentDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "treeContainer", first: true, predicate: ["treeContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"grow flex flex-col gap-2 justify-start items-start\">\n <button (click)=\"toggleTreeNavigation()\" class=\"!justify-start\" mat-button type=\"button\">\n <span class=\"flex flex-row justify-start items-center gap-6\">\n @if (showTreeNavigation()) {\n <mat-icon>arrow_back</mat-icon>\n <span i18n>Hide tree navigation</span>\n }\n @if (!showTreeNavigation()) {\n <mat-icon>arrow_forward</mat-icon>\n <span i18n>Show tree navigation</span>\n }\n </span>\n </button>\n <div class=\"flex flex-row grow w-full\">\n <div #treeContainer [ngClass]=\"{ 'hidden': !showTreeNavigation() }\"\n [ngStyle]=\"{ maxWidth: dividerOffset(), minWidth: dividerOffset(), flexBasis: dividerOffset() }\"\n class=\"w-fit grow-0 overflow-y-auto\">\n @if (!dataSource() || (dataSource().loading$ | async)) {\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n }\n <ng-content select=\"[searchHeader]\"></ng-content>\n @if (dataSource()) {\n <mat-tree [dataSource]=\"dataSource()\" [treeControl]=\"treeControl\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n }\n @if (multiple()) {\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\">\n {{ node.display }}\n </mat-checkbox>\n }\n @if (!multiple()) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n }\n </div>\n </mat-tree-node>\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 type=\"button\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n } @else {\n <div></div>\n }\n @if (node.hasDetails) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n } @else {\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n }\n @if (node.isLoading$ | async) {\n <mat-progress-spinner\n [diameter]=\"16\"\n class=\"grow-0 pl-4\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n }\n </div>\n </mat-tree-node>\n </mat-tree>\n } @else {\n Load data source\n }\n </div>\n\n @if (showTreeNavigation()) {\n <div (mousedown)=\"onMousedown()\"\n class=\"divider cursor-ew-resize px-3 grow-0\">\n <mat-divider [vertical]=\"true\" class=\"h-full\"></mat-divider>\n </div>\n }\n\n <div class=\"grow\">\n @if (portal(); as portal) {\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n }\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n\n", styles: [""], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { 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: ["tabIndex", "disabled"], outputs: ["activation", "expandedChange"], 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: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { 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: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
70
|
+
if (existingFormDefinition) return existingFormDefinition;
|
|
71
|
+
return new RxapFormBuilder(SearchForm, injector).build(state ?? {});
|
|
210
72
|
}
|
|
73
|
+
const SearchFormProviders = [SearchForm, {
|
|
74
|
+
provide: RXAP_FORM_DEFINITION,
|
|
75
|
+
useFactory: FormFactory,
|
|
76
|
+
deps: [
|
|
77
|
+
INJECTOR,
|
|
78
|
+
[new Optional(), RXAP_FORM_INITIAL_STATE],
|
|
79
|
+
[
|
|
80
|
+
new SkipSelf(),
|
|
81
|
+
new Optional(),
|
|
82
|
+
RXAP_FORM_DEFINITION
|
|
83
|
+
]
|
|
84
|
+
]
|
|
85
|
+
}];
|
|
86
|
+
const RXAP_TREE_CONTENT_EDITABLE_METHOD = new InjectionToken("rxap/tree-content-editable-method");
|
|
87
|
+
var TreeContentDirective = class TreeContentDirective {
|
|
88
|
+
constructor() {
|
|
89
|
+
this.template = inject(TemplateRef);
|
|
90
|
+
}
|
|
91
|
+
static {
|
|
92
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
93
|
+
minVersion: "12.0.0",
|
|
94
|
+
version: "22.3.0",
|
|
95
|
+
ngImport: i0,
|
|
96
|
+
type: TreeContentDirective,
|
|
97
|
+
deps: [],
|
|
98
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
static {
|
|
102
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
103
|
+
minVersion: "14.0.0",
|
|
104
|
+
version: "22.3.0",
|
|
105
|
+
type: TreeContentDirective,
|
|
106
|
+
isStandalone: true,
|
|
107
|
+
selector: "ng-template[rxapTreeContent]",
|
|
108
|
+
ngImport: i0
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
113
|
+
minVersion: "12.0.0",
|
|
114
|
+
version: "22.3.0",
|
|
115
|
+
ngImport: i0,
|
|
116
|
+
type: TreeContentDirective,
|
|
117
|
+
decorators: [{
|
|
118
|
+
type: Directive,
|
|
119
|
+
args: [{
|
|
120
|
+
selector: "ng-template[rxapTreeContent]",
|
|
121
|
+
standalone: true
|
|
122
|
+
}]
|
|
123
|
+
}]
|
|
124
|
+
});
|
|
125
|
+
var TreeComponent = class TreeComponent {
|
|
126
|
+
constructor() {
|
|
127
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
128
|
+
this.elementRef = inject(ElementRef);
|
|
129
|
+
this.searchForm = inject(RXAP_FORM_DEFINITION, { optional: true });
|
|
130
|
+
this.dataSource = input.required(...ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []);
|
|
131
|
+
this.contentEditableMethodInput = input(null, {
|
|
132
|
+
...ngDevMode ? { debugName: "contentEditableMethodInput" } : /* istanbul ignore next */ {},
|
|
133
|
+
alias: "contentEditableMethod"
|
|
134
|
+
});
|
|
135
|
+
this.injectedContentEditableMethod = inject(RXAP_TREE_CONTENT_EDITABLE_METHOD, { optional: true });
|
|
136
|
+
this.contentEditableMethod = computed(() => this.contentEditableMethodInput() ?? this.injectedContentEditableMethod, ...ngDevMode ? [{ debugName: "contentEditableMethod" }] : /* istanbul ignore next */ []);
|
|
137
|
+
this.toDisplay = input(...ngDevMode ? [void 0, { debugName: "toDisplay" }] : /* istanbul ignore next */ []);
|
|
138
|
+
this.getIcon = input(...ngDevMode ? [void 0, { debugName: "getIcon" }] : /* istanbul ignore next */ []);
|
|
139
|
+
this.getType = input(...ngDevMode ? [void 0, { debugName: "getType" }] : /* istanbul ignore next */ []);
|
|
140
|
+
this.getStyle = input(...ngDevMode ? [void 0, { debugName: "getStyle" }] : /* istanbul ignore next */ []);
|
|
141
|
+
this.multipleInput = input(false, {
|
|
142
|
+
...ngDevMode ? { debugName: "multipleInput" } : /* istanbul ignore next */ {},
|
|
143
|
+
alias: "multiple"
|
|
144
|
+
});
|
|
145
|
+
this.multiple = computed(() => this.dataSource().metadata?.selectMultiple ?? this.multipleInput(), ...ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []);
|
|
146
|
+
this.hasDetails = input(...ngDevMode ? [void 0, { debugName: "hasDetails" }] : /* istanbul ignore next */ []);
|
|
147
|
+
this.content = contentChild(TreeContentDirective, ...ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []);
|
|
148
|
+
this.hideLeafIcon = input(false, ...ngDevMode ? [{ debugName: "hideLeafIcon" }] : /* istanbul ignore next */ []);
|
|
149
|
+
this.id = input(...ngDevMode ? [void 0, { debugName: "id" }] : /* istanbul ignore next */ []);
|
|
150
|
+
this.details = output();
|
|
151
|
+
this.dividerOffsetInput = input("256px", {
|
|
152
|
+
...ngDevMode ? { debugName: "dividerOffsetInput" } : /* istanbul ignore next */ {},
|
|
153
|
+
alias: "dividerOffset"
|
|
154
|
+
});
|
|
155
|
+
this.dividerOffset = linkedSignal(() => this.dividerOffsetInput(), ...ngDevMode ? [{ debugName: "dividerOffset" }] : /* istanbul ignore next */ []);
|
|
156
|
+
this.portal = signal(null, ...ngDevMode ? [{ debugName: "portal" }] : /* istanbul ignore next */ []);
|
|
157
|
+
this.treeContainer = viewChild.required("treeContainer", ...ngDevMode ? [{ debugName: "treeContainer" }] : /* istanbul ignore next */ []);
|
|
158
|
+
this.showTreeNavigation = signal(true, ...ngDevMode ? [{ debugName: "showTreeNavigation" }] : /* istanbul ignore next */ []);
|
|
159
|
+
this._moveDivider = false;
|
|
160
|
+
this._treeContainerWidth = null;
|
|
161
|
+
this.getLevel = (node) => node.depth;
|
|
162
|
+
this.isExpandable = (node) => node.hasChildren;
|
|
163
|
+
this.hasChild = (_, nodeData) => nodeData.hasChildren;
|
|
164
|
+
this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
|
|
165
|
+
effect(() => {
|
|
166
|
+
const dataSource = this.dataSource();
|
|
167
|
+
const toDisplay = this.toDisplay();
|
|
168
|
+
const getIcon = this.getIcon();
|
|
169
|
+
const hasDetails = this.hasDetails();
|
|
170
|
+
const getStyle = this.getStyle();
|
|
171
|
+
const getType = this.getType();
|
|
172
|
+
untracked(() => {
|
|
173
|
+
dataSource.searchForm = this.searchForm;
|
|
174
|
+
dataSource.setTreeControl(this.treeControl);
|
|
175
|
+
dataSource.setToDisplay(toDisplay);
|
|
176
|
+
dataSource.setGetIcon(getIcon);
|
|
177
|
+
dataSource.setHasDetails(hasDetails);
|
|
178
|
+
dataSource.setGetStyle(getStyle);
|
|
179
|
+
dataSource.setGetType(getType);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
effect((onCleanup) => {
|
|
183
|
+
const selected = this.dataSource().selected;
|
|
184
|
+
const subscription = untracked(() => selected.changed.pipe(map(($event) => $event.source.selected), startWith(selected.selected), tap((nodes) => nodes.forEach((node) => this.openDetails(node)))).subscribe());
|
|
185
|
+
onCleanup(() => subscription.unsubscribe());
|
|
186
|
+
});
|
|
187
|
+
afterNextRender(() => {
|
|
188
|
+
const cachedOffset = localStorage.getItem(this.cacheId);
|
|
189
|
+
if (cachedOffset && cachedOffset.match(/^(\d+\.)?\d+px$/)) this.dividerOffset.set(cachedOffset);
|
|
190
|
+
else if (isDevMode()) console.log("Divider offset cache is not available or invalid: " + cachedOffset);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
get nodeDisplayEditable() {
|
|
194
|
+
return !!this.contentEditableMethod();
|
|
195
|
+
}
|
|
196
|
+
get cacheId() {
|
|
197
|
+
return [
|
|
198
|
+
"rxap",
|
|
199
|
+
"tree",
|
|
200
|
+
this.id()
|
|
201
|
+
].join("/");
|
|
202
|
+
}
|
|
203
|
+
openDetails(node) {
|
|
204
|
+
const content = this.content();
|
|
205
|
+
if (content) this.portal.set(new TemplatePortal(content.template, this.viewContainerRef, {
|
|
206
|
+
$implicit: node.item,
|
|
207
|
+
node
|
|
208
|
+
}));
|
|
209
|
+
this.details.emit(node.item);
|
|
210
|
+
}
|
|
211
|
+
onContentEditableChange(value, node) {
|
|
212
|
+
return this.contentEditableMethod()?.call(value, node.item, node);
|
|
213
|
+
}
|
|
214
|
+
onMousedown() {
|
|
215
|
+
this._moveDivider = true;
|
|
216
|
+
}
|
|
217
|
+
onMouseup() {
|
|
218
|
+
this._moveDivider = false;
|
|
219
|
+
}
|
|
220
|
+
onMousemove($event) {
|
|
221
|
+
if (this._moveDivider) {
|
|
222
|
+
if (!this._treeContainerWidth) this._treeContainerWidth = this.treeContainer().nativeElement.clientWidth;
|
|
223
|
+
const rect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
224
|
+
this._treeContainerWidth = Math.min(Math.max($event.clientX - (rect.left + 12), 128), rect.right - rect.left - 128);
|
|
225
|
+
const offset = this._treeContainerWidth + "px";
|
|
226
|
+
this.setDividerOffset(offset);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
toggleTreeNavigation() {
|
|
230
|
+
this.showTreeNavigation.update((value) => !value);
|
|
231
|
+
}
|
|
232
|
+
setDividerOffset(offset) {
|
|
233
|
+
this.dividerOffset.set(offset);
|
|
234
|
+
localStorage.setItem(this.cacheId, offset);
|
|
235
|
+
}
|
|
236
|
+
static {
|
|
237
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
238
|
+
minVersion: "12.0.0",
|
|
239
|
+
version: "22.3.0",
|
|
240
|
+
ngImport: i0,
|
|
241
|
+
type: TreeComponent,
|
|
242
|
+
deps: [],
|
|
243
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
static {
|
|
247
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
248
|
+
minVersion: "17.0.0",
|
|
249
|
+
version: "22.3.0",
|
|
250
|
+
type: TreeComponent,
|
|
251
|
+
isStandalone: true,
|
|
252
|
+
selector: "rxap-tree",
|
|
253
|
+
inputs: {
|
|
254
|
+
dataSource: {
|
|
255
|
+
classPropertyName: "dataSource",
|
|
256
|
+
publicName: "dataSource",
|
|
257
|
+
isSignal: true,
|
|
258
|
+
isRequired: true,
|
|
259
|
+
transformFunction: null
|
|
260
|
+
},
|
|
261
|
+
contentEditableMethodInput: {
|
|
262
|
+
classPropertyName: "contentEditableMethodInput",
|
|
263
|
+
publicName: "contentEditableMethod",
|
|
264
|
+
isSignal: true,
|
|
265
|
+
isRequired: false,
|
|
266
|
+
transformFunction: null
|
|
267
|
+
},
|
|
268
|
+
toDisplay: {
|
|
269
|
+
classPropertyName: "toDisplay",
|
|
270
|
+
publicName: "toDisplay",
|
|
271
|
+
isSignal: true,
|
|
272
|
+
isRequired: false,
|
|
273
|
+
transformFunction: null
|
|
274
|
+
},
|
|
275
|
+
getIcon: {
|
|
276
|
+
classPropertyName: "getIcon",
|
|
277
|
+
publicName: "getIcon",
|
|
278
|
+
isSignal: true,
|
|
279
|
+
isRequired: false,
|
|
280
|
+
transformFunction: null
|
|
281
|
+
},
|
|
282
|
+
getType: {
|
|
283
|
+
classPropertyName: "getType",
|
|
284
|
+
publicName: "getType",
|
|
285
|
+
isSignal: true,
|
|
286
|
+
isRequired: false,
|
|
287
|
+
transformFunction: null
|
|
288
|
+
},
|
|
289
|
+
getStyle: {
|
|
290
|
+
classPropertyName: "getStyle",
|
|
291
|
+
publicName: "getStyle",
|
|
292
|
+
isSignal: true,
|
|
293
|
+
isRequired: false,
|
|
294
|
+
transformFunction: null
|
|
295
|
+
},
|
|
296
|
+
multipleInput: {
|
|
297
|
+
classPropertyName: "multipleInput",
|
|
298
|
+
publicName: "multiple",
|
|
299
|
+
isSignal: true,
|
|
300
|
+
isRequired: false,
|
|
301
|
+
transformFunction: null
|
|
302
|
+
},
|
|
303
|
+
hasDetails: {
|
|
304
|
+
classPropertyName: "hasDetails",
|
|
305
|
+
publicName: "hasDetails",
|
|
306
|
+
isSignal: true,
|
|
307
|
+
isRequired: false,
|
|
308
|
+
transformFunction: null
|
|
309
|
+
},
|
|
310
|
+
hideLeafIcon: {
|
|
311
|
+
classPropertyName: "hideLeafIcon",
|
|
312
|
+
publicName: "hideLeafIcon",
|
|
313
|
+
isSignal: true,
|
|
314
|
+
isRequired: false,
|
|
315
|
+
transformFunction: null
|
|
316
|
+
},
|
|
317
|
+
id: {
|
|
318
|
+
classPropertyName: "id",
|
|
319
|
+
publicName: "id",
|
|
320
|
+
isSignal: true,
|
|
321
|
+
isRequired: false,
|
|
322
|
+
transformFunction: null
|
|
323
|
+
},
|
|
324
|
+
dividerOffsetInput: {
|
|
325
|
+
classPropertyName: "dividerOffsetInput",
|
|
326
|
+
publicName: "dividerOffset",
|
|
327
|
+
isSignal: true,
|
|
328
|
+
isRequired: false,
|
|
329
|
+
transformFunction: null
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
outputs: { details: "details" },
|
|
333
|
+
host: { listeners: {
|
|
334
|
+
"mouseup": "onMouseup()",
|
|
335
|
+
"mousemove": "onMousemove($event)"
|
|
336
|
+
} },
|
|
337
|
+
queries: [{
|
|
338
|
+
propertyName: "content",
|
|
339
|
+
first: true,
|
|
340
|
+
predicate: TreeContentDirective,
|
|
341
|
+
descendants: true,
|
|
342
|
+
isSignal: true
|
|
343
|
+
}],
|
|
344
|
+
viewQueries: [{
|
|
345
|
+
propertyName: "treeContainer",
|
|
346
|
+
first: true,
|
|
347
|
+
predicate: ["treeContainer"],
|
|
348
|
+
descendants: true,
|
|
349
|
+
isSignal: true
|
|
350
|
+
}],
|
|
351
|
+
ngImport: i0,
|
|
352
|
+
template: "<div class=\"grow flex flex-col gap-2 justify-start items-start\">\n <button (click)=\"toggleTreeNavigation()\" class=\"!justify-start\" mat-button type=\"button\">\n <span class=\"flex flex-row justify-start items-center gap-6\">\n @if (showTreeNavigation()) {\n <mat-icon>arrow_back</mat-icon>\n <span i18n>Hide tree navigation</span>\n }\n @if (!showTreeNavigation()) {\n <mat-icon>arrow_forward</mat-icon>\n <span i18n>Show tree navigation</span>\n }\n </span>\n </button>\n <div class=\"flex flex-row grow w-full\">\n <div #treeContainer [ngClass]=\"{ 'hidden': !showTreeNavigation() }\"\n [ngStyle]=\"{ maxWidth: dividerOffset(), minWidth: dividerOffset(), flexBasis: dividerOffset() }\"\n class=\"w-fit grow-0 overflow-y-auto\">\n @if (!dataSource() || (dataSource().loading$ | async)) {\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n }\n <ng-content select=\"[searchHeader]\"></ng-content>\n @if (dataSource()) {\n <mat-tree [dataSource]=\"dataSource()\" [treeControl]=\"treeControl\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n }\n @if (multiple()) {\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\">\n {{ node.display }}\n </mat-checkbox>\n }\n @if (!multiple()) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n }\n </div>\n </mat-tree-node>\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 type=\"button\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n } @else {\n <div></div>\n }\n @if (node.hasDetails) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n } @else {\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n }\n @if (node.isLoading$ | async) {\n <mat-progress-spinner\n [diameter]=\"16\"\n class=\"grow-0 pl-4\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n }\n </div>\n </mat-tree-node>\n </mat-tree>\n } @else {\n Load data source\n }\n </div>\n\n @if (showTreeNavigation()) {\n <div (mousedown)=\"onMousedown()\"\n class=\"divider cursor-ew-resize px-3 grow-0\">\n <mat-divider [vertical]=\"true\" class=\"h-full\"></mat-divider>\n </div>\n }\n\n <div class=\"grow\">\n @if (portal(); as portal) {\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n }\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n\n",
|
|
353
|
+
styles: [""],
|
|
354
|
+
dependencies: [
|
|
355
|
+
{
|
|
356
|
+
kind: "directive",
|
|
357
|
+
type: NgStyle,
|
|
358
|
+
selector: "[ngStyle]",
|
|
359
|
+
inputs: ["ngStyle"]
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
kind: "ngmodule",
|
|
363
|
+
type: MatProgressBarModule
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
kind: "component",
|
|
367
|
+
type: i1.MatProgressBar,
|
|
368
|
+
selector: "mat-progress-bar",
|
|
369
|
+
inputs: [
|
|
370
|
+
"color",
|
|
371
|
+
"value",
|
|
372
|
+
"bufferValue",
|
|
373
|
+
"mode"
|
|
374
|
+
],
|
|
375
|
+
outputs: ["animationEnd"],
|
|
376
|
+
exportAs: ["matProgressBar"]
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
kind: "ngmodule",
|
|
380
|
+
type: MatTreeModule
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
kind: "directive",
|
|
384
|
+
type: i2.MatTreeNodeDef,
|
|
385
|
+
selector: "[matTreeNodeDef]",
|
|
386
|
+
inputs: ["matTreeNodeDefWhen", "matTreeNode"]
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
kind: "directive",
|
|
390
|
+
type: i2.MatTreeNodePadding,
|
|
391
|
+
selector: "[matTreeNodePadding]",
|
|
392
|
+
inputs: ["matTreeNodePadding", "matTreeNodePaddingIndent"]
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
kind: "directive",
|
|
396
|
+
type: i2.MatTreeNodeToggle,
|
|
397
|
+
selector: "[matTreeNodeToggle]",
|
|
398
|
+
inputs: ["matTreeNodeToggleRecursive"]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
kind: "component",
|
|
402
|
+
type: i2.MatTree,
|
|
403
|
+
selector: "mat-tree",
|
|
404
|
+
exportAs: ["matTree"]
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
kind: "directive",
|
|
408
|
+
type: i2.MatTreeNode,
|
|
409
|
+
selector: "mat-tree-node",
|
|
410
|
+
inputs: ["tabIndex", "disabled"],
|
|
411
|
+
outputs: ["activation", "expandedChange"],
|
|
412
|
+
exportAs: ["matTreeNode"]
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
kind: "ngmodule",
|
|
416
|
+
type: MatIconModule
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
kind: "component",
|
|
420
|
+
type: i3.MatIcon,
|
|
421
|
+
selector: "mat-icon",
|
|
422
|
+
inputs: [
|
|
423
|
+
"color",
|
|
424
|
+
"inline",
|
|
425
|
+
"svgIcon",
|
|
426
|
+
"fontSet",
|
|
427
|
+
"fontIcon"
|
|
428
|
+
],
|
|
429
|
+
exportAs: ["matIcon"]
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
kind: "directive",
|
|
433
|
+
type: IconDirective,
|
|
434
|
+
selector: "mat-icon[rxapIcon]",
|
|
435
|
+
inputs: ["rxapIcon"]
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
kind: "ngmodule",
|
|
439
|
+
type: MatCheckboxModule
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
kind: "component",
|
|
443
|
+
type: i4.MatCheckbox,
|
|
444
|
+
selector: "mat-checkbox",
|
|
445
|
+
inputs: [
|
|
446
|
+
"aria-label",
|
|
447
|
+
"aria-labelledby",
|
|
448
|
+
"aria-describedby",
|
|
449
|
+
"aria-expanded",
|
|
450
|
+
"aria-controls",
|
|
451
|
+
"aria-owns",
|
|
452
|
+
"id",
|
|
453
|
+
"required",
|
|
454
|
+
"labelPosition",
|
|
455
|
+
"name",
|
|
456
|
+
"value",
|
|
457
|
+
"disableRipple",
|
|
458
|
+
"tabIndex",
|
|
459
|
+
"color",
|
|
460
|
+
"disabledInteractive",
|
|
461
|
+
"checked",
|
|
462
|
+
"disabled",
|
|
463
|
+
"indeterminate"
|
|
464
|
+
],
|
|
465
|
+
outputs: ["change", "indeterminateChange"],
|
|
466
|
+
exportAs: ["matCheckbox"]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
kind: "ngmodule",
|
|
470
|
+
type: MatButtonModule
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
kind: "component",
|
|
474
|
+
type: i5.MatButton,
|
|
475
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
476
|
+
inputs: ["matButton"],
|
|
477
|
+
exportAs: ["matButton", "matAnchor"]
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
kind: "component",
|
|
481
|
+
type: i5.MatIconButton,
|
|
482
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
483
|
+
exportAs: ["matButton", "matAnchor"]
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
kind: "directive",
|
|
487
|
+
type: ContenteditableDirective,
|
|
488
|
+
selector: "[rxapContenteditable]",
|
|
489
|
+
inputs: ["rxapContenteditable", "disabled"],
|
|
490
|
+
outputs: ["change"]
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
kind: "ngmodule",
|
|
494
|
+
type: MatProgressSpinnerModule
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
kind: "component",
|
|
498
|
+
type: i6.MatProgressSpinner,
|
|
499
|
+
selector: "mat-progress-spinner, mat-spinner",
|
|
500
|
+
inputs: [
|
|
501
|
+
"color",
|
|
502
|
+
"mode",
|
|
503
|
+
"value",
|
|
504
|
+
"diameter",
|
|
505
|
+
"strokeWidth"
|
|
506
|
+
],
|
|
507
|
+
exportAs: ["matProgressSpinner"]
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
kind: "ngmodule",
|
|
511
|
+
type: MatDividerModule
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
kind: "component",
|
|
515
|
+
type: i7.MatDivider,
|
|
516
|
+
selector: "mat-divider",
|
|
517
|
+
inputs: ["vertical", "inset"]
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
kind: "ngmodule",
|
|
521
|
+
type: PortalModule
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
kind: "directive",
|
|
525
|
+
type: i8.CdkPortalOutlet,
|
|
526
|
+
selector: "[cdkPortalOutlet]",
|
|
527
|
+
inputs: ["cdkPortalOutlet"],
|
|
528
|
+
outputs: ["attached"],
|
|
529
|
+
exportAs: ["cdkPortalOutlet"]
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
kind: "directive",
|
|
533
|
+
type: NgClass,
|
|
534
|
+
selector: "[ngClass]",
|
|
535
|
+
inputs: ["class", "ngClass"]
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
kind: "pipe",
|
|
539
|
+
type: AsyncPipe,
|
|
540
|
+
name: "async"
|
|
541
|
+
}
|
|
542
|
+
],
|
|
543
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
};
|
|
211
547
|
__decorate([
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
548
|
+
DebounceCall(100),
|
|
549
|
+
__metadata("design:type", Function),
|
|
550
|
+
__metadata("design:paramtypes", [Node]),
|
|
551
|
+
__metadata("design:returntype", void 0)
|
|
216
552
|
], TreeComponent.prototype, "openDetails", null);
|
|
217
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
553
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
554
|
+
minVersion: "12.0.0",
|
|
555
|
+
version: "22.3.0",
|
|
556
|
+
ngImport: i0,
|
|
557
|
+
type: TreeComponent,
|
|
558
|
+
decorators: [{
|
|
559
|
+
type: Component,
|
|
560
|
+
args: [{
|
|
561
|
+
selector: "rxap-tree",
|
|
562
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
563
|
+
imports: [
|
|
564
|
+
NgStyle,
|
|
565
|
+
MatProgressBarModule,
|
|
566
|
+
MatTreeModule,
|
|
567
|
+
MatIconModule,
|
|
568
|
+
IconDirective,
|
|
569
|
+
MatCheckboxModule,
|
|
570
|
+
MatButtonModule,
|
|
571
|
+
ContenteditableDirective,
|
|
572
|
+
MatProgressSpinnerModule,
|
|
573
|
+
MatDividerModule,
|
|
574
|
+
PortalModule,
|
|
575
|
+
AsyncPipe,
|
|
576
|
+
NgClass
|
|
577
|
+
],
|
|
578
|
+
host: {
|
|
579
|
+
"(mouseup)": "onMouseup()",
|
|
580
|
+
"(mousemove)": "onMousemove($event)"
|
|
581
|
+
},
|
|
582
|
+
template: "<div class=\"grow flex flex-col gap-2 justify-start items-start\">\n <button (click)=\"toggleTreeNavigation()\" class=\"!justify-start\" mat-button type=\"button\">\n <span class=\"flex flex-row justify-start items-center gap-6\">\n @if (showTreeNavigation()) {\n <mat-icon>arrow_back</mat-icon>\n <span i18n>Hide tree navigation</span>\n }\n @if (!showTreeNavigation()) {\n <mat-icon>arrow_forward</mat-icon>\n <span i18n>Show tree navigation</span>\n }\n </span>\n </button>\n <div class=\"flex flex-row grow w-full\">\n <div #treeContainer [ngClass]=\"{ 'hidden': !showTreeNavigation() }\"\n [ngStyle]=\"{ maxWidth: dividerOffset(), minWidth: dividerOffset(), flexBasis: dividerOffset() }\"\n class=\"w-fit grow-0 overflow-y-auto\">\n @if (!dataSource() || (dataSource().loading$ | async)) {\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n }\n <ng-content select=\"[searchHeader]\"></ng-content>\n @if (dataSource()) {\n <mat-tree [dataSource]=\"dataSource()\" [treeControl]=\"treeControl\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n }\n @if (multiple()) {\n <mat-checkbox\n (change)=\"node.toggleSelect()\"\n [checked]=\"node.selected\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\">\n {{ node.display }}\n </mat-checkbox>\n }\n @if (!multiple()) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [disabled]=\"!node.hasDetails\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n }\n </div>\n </mat-tree-node>\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 type=\"button\">\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 @if (node.icon?.length) {\n @for (icon of node.icon; track icon) {\n <mat-icon [rxapIcon]=\"$any(icon)\"></mat-icon>\n }\n } @else {\n <div></div>\n }\n @if (node.hasDetails) {\n <button\n (click)=\"node.select()\"\n [color]=\"node.selected ? 'primary' : undefined\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n mat-button\n type=\"button\"\n >\n {{ node.display }}\n </button>\n } @else {\n <span\n (change)=\"onContentEditableChange($event, node)\"\n [disabled]=\"!nodeDisplayEditable\"\n [ngStyle]=\"node.style\"\n class=\"grow-0 truncate\"\n rxapContenteditable>\n {{ node.display }}\n </span>\n }\n @if (node.isLoading$ | async) {\n <mat-progress-spinner\n [diameter]=\"16\"\n class=\"grow-0 pl-4\"\n mode=\"indeterminate\"\n ></mat-progress-spinner>\n }\n </div>\n </mat-tree-node>\n </mat-tree>\n } @else {\n Load data source\n }\n </div>\n\n @if (showTreeNavigation()) {\n <div (mousedown)=\"onMousedown()\"\n class=\"divider cursor-ew-resize px-3 grow-0\">\n <mat-divider [vertical]=\"true\" class=\"h-full\"></mat-divider>\n </div>\n }\n\n <div class=\"grow\">\n @if (portal(); as portal) {\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n }\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n\n"
|
|
583
|
+
}]
|
|
584
|
+
}],
|
|
585
|
+
ctorParameters: () => [],
|
|
586
|
+
propDecorators: {
|
|
587
|
+
dataSource: [{
|
|
588
|
+
type: i0.Input,
|
|
589
|
+
args: [{
|
|
590
|
+
isSignal: true,
|
|
591
|
+
alias: "dataSource",
|
|
592
|
+
required: true
|
|
593
|
+
}]
|
|
594
|
+
}],
|
|
595
|
+
contentEditableMethodInput: [{
|
|
596
|
+
type: i0.Input,
|
|
597
|
+
args: [{
|
|
598
|
+
isSignal: true,
|
|
599
|
+
alias: "contentEditableMethod",
|
|
600
|
+
required: false
|
|
601
|
+
}]
|
|
602
|
+
}],
|
|
603
|
+
toDisplay: [{
|
|
604
|
+
type: i0.Input,
|
|
605
|
+
args: [{
|
|
606
|
+
isSignal: true,
|
|
607
|
+
alias: "toDisplay",
|
|
608
|
+
required: false
|
|
609
|
+
}]
|
|
610
|
+
}],
|
|
611
|
+
getIcon: [{
|
|
612
|
+
type: i0.Input,
|
|
613
|
+
args: [{
|
|
614
|
+
isSignal: true,
|
|
615
|
+
alias: "getIcon",
|
|
616
|
+
required: false
|
|
617
|
+
}]
|
|
618
|
+
}],
|
|
619
|
+
getType: [{
|
|
620
|
+
type: i0.Input,
|
|
621
|
+
args: [{
|
|
622
|
+
isSignal: true,
|
|
623
|
+
alias: "getType",
|
|
624
|
+
required: false
|
|
625
|
+
}]
|
|
626
|
+
}],
|
|
627
|
+
getStyle: [{
|
|
628
|
+
type: i0.Input,
|
|
629
|
+
args: [{
|
|
630
|
+
isSignal: true,
|
|
631
|
+
alias: "getStyle",
|
|
632
|
+
required: false
|
|
633
|
+
}]
|
|
634
|
+
}],
|
|
635
|
+
multipleInput: [{
|
|
636
|
+
type: i0.Input,
|
|
637
|
+
args: [{
|
|
638
|
+
isSignal: true,
|
|
639
|
+
alias: "multiple",
|
|
640
|
+
required: false
|
|
641
|
+
}]
|
|
642
|
+
}],
|
|
643
|
+
hasDetails: [{
|
|
644
|
+
type: i0.Input,
|
|
645
|
+
args: [{
|
|
646
|
+
isSignal: true,
|
|
647
|
+
alias: "hasDetails",
|
|
648
|
+
required: false
|
|
649
|
+
}]
|
|
650
|
+
}],
|
|
651
|
+
content: [{
|
|
652
|
+
type: i0.ContentChild,
|
|
653
|
+
args: [i0.forwardRef(() => TreeContentDirective), { isSignal: true }]
|
|
654
|
+
}],
|
|
655
|
+
hideLeafIcon: [{
|
|
656
|
+
type: i0.Input,
|
|
657
|
+
args: [{
|
|
658
|
+
isSignal: true,
|
|
659
|
+
alias: "hideLeafIcon",
|
|
660
|
+
required: false
|
|
661
|
+
}]
|
|
662
|
+
}],
|
|
663
|
+
id: [{
|
|
664
|
+
type: i0.Input,
|
|
665
|
+
args: [{
|
|
666
|
+
isSignal: true,
|
|
667
|
+
alias: "id",
|
|
668
|
+
required: false
|
|
669
|
+
}]
|
|
670
|
+
}],
|
|
671
|
+
details: [{
|
|
672
|
+
type: i0.Output,
|
|
673
|
+
args: ["details"]
|
|
674
|
+
}],
|
|
675
|
+
dividerOffsetInput: [{
|
|
676
|
+
type: i0.Input,
|
|
677
|
+
args: [{
|
|
678
|
+
isSignal: true,
|
|
679
|
+
alias: "dividerOffset",
|
|
680
|
+
required: false
|
|
681
|
+
}]
|
|
682
|
+
}],
|
|
683
|
+
treeContainer: [{
|
|
684
|
+
type: i0.ViewChild,
|
|
685
|
+
args: ["treeContainer", { isSignal: true }]
|
|
686
|
+
}],
|
|
687
|
+
openDetails: []
|
|
688
|
+
}
|
|
689
|
+
});
|
|
239
690
|
function isSelectionChange(obj) {
|
|
240
|
-
|
|
691
|
+
return !!obj && obj["added"] !== void 0 && obj["removed"] !== void 0;
|
|
241
692
|
}
|
|
242
|
-
const RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD = new InjectionToken(
|
|
243
|
-
const RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD = new InjectionToken(
|
|
244
|
-
const RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD = new InjectionToken(
|
|
693
|
+
const RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD = new InjectionToken("rxap/tree/data-source/root-remote-method");
|
|
694
|
+
const RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD = new InjectionToken("rxap/tree/data-source/children-remote-method");
|
|
695
|
+
const RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD = new InjectionToken("rxap/tree/data-source/apply-filter-method");
|
|
245
696
|
function flatTree(tree, all = false) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
node,
|
|
260
|
-
...node.children.map((child) => _flatTree(child)).reduce(flat, []),
|
|
261
|
-
];
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
return [node];
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
return tree
|
|
268
|
-
.map((child) => _flatTree(child))
|
|
269
|
-
.reduce((acc, items) => [...acc, ...items], []);
|
|
270
|
-
}
|
|
271
|
-
class DefaultTreeApplyFilterMethod {
|
|
272
|
-
constructor() {
|
|
273
|
-
this.lastFilter = null;
|
|
274
|
-
}
|
|
275
|
-
call({ tree, filter, scopeTypes }) {
|
|
276
|
-
const nodes = flatTree(tree, true);
|
|
277
|
-
// if (this.isEqualToLastFilter(filter)) {
|
|
278
|
-
// return flatTree(tree, false).filter(node => node.isVisible);
|
|
279
|
-
// }
|
|
280
|
-
const hasScopeFilter = (filter.scope &&
|
|
281
|
-
Object.keys(filter.scope) &&
|
|
282
|
-
Object.values(filter.scope).some((list) => list.length > 0));
|
|
283
|
-
// if not scope and the search filter is an empty string, collapse all non-root nodes
|
|
284
|
-
if (!filter.search && filter.search !== this.lastFilter?.search) {
|
|
285
|
-
nodes
|
|
286
|
-
.filter(node => node.parent)
|
|
287
|
-
.forEach(node => node.collapse({ quite: true }));
|
|
288
|
-
}
|
|
289
|
-
if (filter.search || hasScopeFilter) {
|
|
290
|
-
nodes.forEach(node => node.hide());
|
|
291
|
-
for (const [type, list] of Object.entries(filter.scope ?? {})) {
|
|
292
|
-
for (const node of nodes) {
|
|
293
|
-
if (node.type === type) {
|
|
294
|
-
if (list.some(item => getIdentifierPropertyValue(item) === node.id)) {
|
|
295
|
-
node.show({ forEachChildren: true });
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (filter.search) {
|
|
301
|
-
for (const node of nodes) {
|
|
302
|
-
if (hasScopeFilter && node.hidden) {
|
|
303
|
-
// if the filter has a scope filter. Only check the search filter on nodes that are shown by the scope
|
|
304
|
-
// filter
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
const display = node.display?.toLowerCase();
|
|
308
|
-
if (display) {
|
|
309
|
-
if (display.includes(filter.search.toLowerCase())) {
|
|
310
|
-
node.show({ parents: true });
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
node.hide();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
// if node has no display, it is not shown
|
|
318
|
-
node.hide();
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
// hide each node that has no visible children
|
|
322
|
-
// there exists the edge case that a node has visible children, but the node.hide() function is called
|
|
323
|
-
// after the child.show({ parent:true })
|
|
324
|
-
for (const node of nodes.filter(n => n.hidden && n.hasChildren && n.children.some(child => child.isVisible))) {
|
|
325
|
-
if (node.hidden) {
|
|
326
|
-
console.warn('Edge case detected. Node has visible children but is hidden.');
|
|
327
|
-
node.show();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
// expand each node that has visible children
|
|
331
|
-
for (const node of nodes.filter(n => n.hasChildren)) {
|
|
332
|
-
if (node.children.some(child => child.isVisible)) {
|
|
333
|
-
// set quite to true to prevent the tree from reloading -> this would result in a infinite loop
|
|
334
|
-
node.expand({ quite: true });
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
nodes.forEach(node => node.show());
|
|
341
|
-
}
|
|
342
|
-
this.lastFilter = filter;
|
|
343
|
-
return flatTree(tree, false).filter(node => node.isVisible);
|
|
344
|
-
}
|
|
345
|
-
isEqualToLastFilter(filter) {
|
|
346
|
-
if (this.lastFilter) {
|
|
347
|
-
if (this.lastFilter.search === filter.search) {
|
|
348
|
-
if (this.lastFilter.scope && filter.scope) {
|
|
349
|
-
if (Object.keys(this.lastFilter.scope).every(key => Object.keys(filter.scope).includes(key))) {
|
|
350
|
-
if (Object.entries(this.lastFilter.scope)
|
|
351
|
-
.every(([key, scope]) => scope.some(item => filter.scope[key].includes(item)))) {
|
|
352
|
-
return true;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (filter.scope === this.lastFilter.scope) {
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DefaultTreeApplyFilterMethod, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
364
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DefaultTreeApplyFilterMethod }); }
|
|
697
|
+
tree = coerceArray(tree);
|
|
698
|
+
function flat(acc, list) {
|
|
699
|
+
return [...acc, ...list];
|
|
700
|
+
}
|
|
701
|
+
const _flatTree = (node) => {
|
|
702
|
+
if (!Array.isArray(node.children)) {
|
|
703
|
+
if (isDevMode()) console.log(node);
|
|
704
|
+
throw new Error("Node has not defined children");
|
|
705
|
+
}
|
|
706
|
+
if (all || node.expanded) return [node, ...node.children.map((child) => _flatTree(child)).reduce(flat, [])];
|
|
707
|
+
else return [node];
|
|
708
|
+
};
|
|
709
|
+
return tree.map((child) => _flatTree(child)).reduce((acc, items) => [...acc, ...items], []);
|
|
365
710
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
711
|
+
var DefaultTreeApplyFilterMethod = class DefaultTreeApplyFilterMethod {
|
|
712
|
+
constructor() {
|
|
713
|
+
this.lastFilter = null;
|
|
714
|
+
}
|
|
715
|
+
call({ tree, filter, scopeTypes }) {
|
|
716
|
+
const nodes = flatTree(tree, true);
|
|
717
|
+
const hasScopeFilter = filter.scope && Object.keys(filter.scope) && Object.values(filter.scope).some((list) => list.length > 0);
|
|
718
|
+
if (!filter.search && filter.search !== this.lastFilter?.search) nodes.filter((node) => node.parent).forEach((node) => node.collapse({ quite: true }));
|
|
719
|
+
if (filter.search || hasScopeFilter) {
|
|
720
|
+
nodes.forEach((node) => node.hide());
|
|
721
|
+
for (const [type, list] of Object.entries(filter.scope ?? {})) for (const node of nodes) if (node.type === type) {
|
|
722
|
+
if (list.some((item) => getIdentifierPropertyValue(item) === node.id)) node.show({ forEachChildren: true });
|
|
723
|
+
}
|
|
724
|
+
if (filter.search) {
|
|
725
|
+
for (const node of nodes) {
|
|
726
|
+
if (hasScopeFilter && node.hidden) continue;
|
|
727
|
+
const display = node.display?.toLowerCase();
|
|
728
|
+
if (display) {
|
|
729
|
+
if (display.includes(filter.search.toLowerCase())) node.show({ parents: true });
|
|
730
|
+
else node.hide();
|
|
731
|
+
} else node.hide();
|
|
732
|
+
}
|
|
733
|
+
for (const node of nodes.filter((n) => n.hidden && n.hasChildren && n.children.some((child) => child.isVisible))) if (node.hidden) {
|
|
734
|
+
console.warn("Edge case detected. Node has visible children but is hidden.");
|
|
735
|
+
node.show();
|
|
736
|
+
}
|
|
737
|
+
for (const node of nodes.filter((n) => n.hasChildren)) if (node.children.some((child) => child.isVisible)) node.expand({ quite: true });
|
|
738
|
+
}
|
|
739
|
+
} else nodes.forEach((node) => node.show());
|
|
740
|
+
this.lastFilter = filter;
|
|
741
|
+
return flatTree(tree, false).filter((node) => node.isVisible);
|
|
742
|
+
}
|
|
743
|
+
isEqualToLastFilter(filter) {
|
|
744
|
+
if (this.lastFilter) {
|
|
745
|
+
if (this.lastFilter.search === filter.search) {
|
|
746
|
+
if (this.lastFilter.scope && filter.scope) {
|
|
747
|
+
if (Object.keys(this.lastFilter.scope).every((key) => Object.keys(filter.scope).includes(key))) {
|
|
748
|
+
if (Object.entries(this.lastFilter.scope).every(([key, scope]) => scope.some((item) => filter.scope[key].includes(item)))) return true;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (filter.scope === this.lastFilter.scope) return true;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
static {
|
|
757
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
758
|
+
minVersion: "12.0.0",
|
|
759
|
+
version: "22.3.0",
|
|
760
|
+
ngImport: i0,
|
|
761
|
+
type: DefaultTreeApplyFilterMethod,
|
|
762
|
+
deps: [],
|
|
763
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
static {
|
|
767
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
768
|
+
minVersion: "12.0.0",
|
|
769
|
+
version: "22.3.0",
|
|
770
|
+
ngImport: i0,
|
|
771
|
+
type: DefaultTreeApplyFilterMethod
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
776
|
+
minVersion: "12.0.0",
|
|
777
|
+
version: "22.3.0",
|
|
778
|
+
ngImport: i0,
|
|
779
|
+
type: DefaultTreeApplyFilterMethod,
|
|
780
|
+
decorators: [{ type: Injectable }]
|
|
781
|
+
});
|
|
369
782
|
let TreeDataSource = class TreeDataSource extends BaseDataSource {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* recall the getStyle, getIcon and toDisplay methods
|
|
625
|
-
* and update the node objects
|
|
626
|
-
*/
|
|
627
|
-
updateNodes() {
|
|
628
|
-
this._data$.value.forEach(node => {
|
|
629
|
-
node.style = this.getStyle(node.item);
|
|
630
|
-
node.icon = coerceArray(this.getIcon(node.item));
|
|
631
|
-
node.display = this.toDisplay(node.item);
|
|
632
|
-
});
|
|
633
|
-
this._data$.next(this._data$.value);
|
|
634
|
-
}
|
|
635
|
-
_connect(collectionViewer) {
|
|
636
|
-
this.init();
|
|
637
|
-
this.treeControl.expansionModel.changed.pipe(tap(async (change) => {
|
|
638
|
-
if (isSelectionChange(change)) {
|
|
639
|
-
const promiseList = [];
|
|
640
|
-
if (change.added) {
|
|
641
|
-
promiseList.push(...change.added.map((node) => node.expand({ onlySelf: true, quite: true })));
|
|
642
|
-
}
|
|
643
|
-
if (change.removed) {
|
|
644
|
-
promiseList.push(...change.removed
|
|
645
|
-
.slice()
|
|
646
|
-
.reverse()
|
|
647
|
-
.map((node) => node.collapse({ onlySelf: true, quite: true })));
|
|
648
|
-
}
|
|
649
|
-
await Promise.all(promiseList);
|
|
650
|
-
this.tree$.next(this.tree$.value);
|
|
651
|
-
}
|
|
652
|
-
})).subscribe();
|
|
653
|
-
let loadRoot = Promise.resolve();
|
|
654
|
-
if (this.tree$.value.length === 0) {
|
|
655
|
-
loadRoot = this.getTreeRoot();
|
|
656
|
-
}
|
|
657
|
-
let autoRefreshExecuted = false;
|
|
658
|
-
return from(loadRoot).pipe(
|
|
659
|
-
// tap((rootNodes) => {
|
|
660
|
-
// if (rootNodes) {
|
|
661
|
-
// const promises: Promise<any>[] = [];
|
|
662
|
-
// if (this.metadata.selectMultiple) {
|
|
663
|
-
// // if (!this.selected.hasValue()) {
|
|
664
|
-
// // promises.push(
|
|
665
|
-
// // ...rootNodes
|
|
666
|
-
// // .filter((node) => node.hasDetails)
|
|
667
|
-
// // .map((node) => node.select()),
|
|
668
|
-
// // );
|
|
669
|
-
// // }
|
|
670
|
-
// if (!this.expanded.hasValue()) {
|
|
671
|
-
// promises.push(
|
|
672
|
-
// ...rootNodes
|
|
673
|
-
// .filter((node) => node.hasChildren)
|
|
674
|
-
// .map((node) => node.expand()),
|
|
675
|
-
// );
|
|
676
|
-
// }
|
|
677
|
-
// } else if (rootNodes.length) {
|
|
678
|
-
// const rootNode = rootNodes[0];
|
|
679
|
-
// // if (!this.selected.hasValue()) {
|
|
680
|
-
// // // TODO : rename hasDetails to isSelectable
|
|
681
|
-
// // if (rootNode.hasDetails) {
|
|
682
|
-
// // promises.push(rootNode.select());
|
|
683
|
-
// // }
|
|
684
|
-
// // }
|
|
685
|
-
// if (!this.expanded.hasValue()) {
|
|
686
|
-
// promises.push(rootNode.expand());
|
|
687
|
-
// }
|
|
688
|
-
// }
|
|
689
|
-
// return Promise.all(promises);
|
|
690
|
-
// }
|
|
691
|
-
// return Promise.resolve();
|
|
692
|
-
// }),
|
|
693
|
-
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))))), tap(() => {
|
|
694
|
-
if (this._preSelected.length) {
|
|
695
|
-
console.log('restore selected', this._preSelected);
|
|
696
|
-
this.selected.clear();
|
|
697
|
-
const nodes = this._preSelected.map((id) => this.getNodeById(id));
|
|
698
|
-
this._preSelected = [];
|
|
699
|
-
nodes.forEach(node => {
|
|
700
|
-
node?.select();
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
}), tap(() => {
|
|
704
|
-
if (this.metadata.autoRefreshWithoutCache) {
|
|
705
|
-
if (!autoRefreshExecuted) {
|
|
706
|
-
autoRefreshExecuted = true;
|
|
707
|
-
console.log('auto refresh');
|
|
708
|
-
this.refresh();
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}));
|
|
712
|
-
}
|
|
713
|
-
initSelected() {
|
|
714
|
-
const key = joinPath('rxap/tree', this.id, 'selected');
|
|
715
|
-
if (this.metadata['cacheSelected']) {
|
|
716
|
-
if (localStorage.getItem(key)) {
|
|
717
|
-
try {
|
|
718
|
-
this._preSelected = JSON.parse(localStorage.getItem(key));
|
|
719
|
-
}
|
|
720
|
-
catch (e) {
|
|
721
|
-
console.error('parse expanded tree data source nodes failed');
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
this.selected = new SelectionModel(!!this.metadata.selectMultiple, []);
|
|
726
|
-
if (this.metadata['cacheSelected']) {
|
|
727
|
-
this._selectedLocalStorageSubscription = this.selected.changed
|
|
728
|
-
.pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.selected.selected.map((s) => s.id)))))
|
|
729
|
-
.subscribe();
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
initExpanded() {
|
|
733
|
-
const key = joinPath('rxap/tree', this.id, 'expanded');
|
|
734
|
-
let expanded = [];
|
|
735
|
-
if (this.metadata['cacheExpanded']) {
|
|
736
|
-
if (localStorage.getItem(key)) {
|
|
737
|
-
try {
|
|
738
|
-
expanded = JSON.parse(localStorage.getItem(key));
|
|
739
|
-
}
|
|
740
|
-
catch (e) {
|
|
741
|
-
console.error('parse expanded tree data source nodes failed');
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
this.expanded = new SelectionModel(this.metadata.expandMultiple !== false, expanded);
|
|
746
|
-
if (this.metadata['cacheExpanded']) {
|
|
747
|
-
this._expandedLocalStorageSubscription = this.expanded.changed
|
|
748
|
-
.pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.expanded.selected))))
|
|
749
|
-
.subscribe();
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: TreeDataSource, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
753
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: TreeDataSource }); }
|
|
783
|
+
constructor() {
|
|
784
|
+
const applyFilterMethod = inject(RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD, { optional: true }) ?? null;
|
|
785
|
+
const metadata = inject(RXAP_DATA_SOURCE_METADATA, { optional: true }) ?? null;
|
|
786
|
+
super(metadata);
|
|
787
|
+
this.rootRemoteMethod = inject(RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD);
|
|
788
|
+
this.childrenRemoteMethod = inject(RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD, { optional: true }) ?? null;
|
|
789
|
+
this.tree$ = new BehaviorSubject([]);
|
|
790
|
+
this.loading$ = new ToggleSubject(true);
|
|
791
|
+
this.searchForm = null;
|
|
792
|
+
this._data$ = new BehaviorSubject([]);
|
|
793
|
+
this._expandedLocalStorageSubscription = null;
|
|
794
|
+
this._selectedLocalStorageSubscription = null;
|
|
795
|
+
this._preSelected = [];
|
|
796
|
+
this._refreshMatchFilter = new Subject();
|
|
797
|
+
this._nodeParameters = null;
|
|
798
|
+
this.toDisplay = () => "to display function not defined";
|
|
799
|
+
this.getIcon = () => null;
|
|
800
|
+
this.getType = () => null;
|
|
801
|
+
this.getStyle = () => ({});
|
|
802
|
+
this.hasDetails = () => true;
|
|
803
|
+
this.matchFilter = () => true;
|
|
804
|
+
this.applyFilterMethod = applyFilterMethod ?? new DefaultTreeApplyFilterMethod();
|
|
805
|
+
this.initSelected();
|
|
806
|
+
this.initExpanded();
|
|
807
|
+
}
|
|
808
|
+
get nodeParameters() {
|
|
809
|
+
return this._nodeParameters;
|
|
810
|
+
}
|
|
811
|
+
set nodeParameters(nodeParameters) {
|
|
812
|
+
this._nodeParameters = nodeParameters;
|
|
813
|
+
this.tree$.value.forEach((node) => node.parameters = nodeParameters);
|
|
814
|
+
}
|
|
815
|
+
ngOnInit() {
|
|
816
|
+
if (this.searchForm) combineLatest([this.tree$, this.searchForm.rxapFormGroup.value$.pipe(debounceTime(1e3))]).pipe(switchMap(async ([tree, filter]) => await this.applyFilterMethod.call({
|
|
817
|
+
tree,
|
|
818
|
+
filter,
|
|
819
|
+
scopeTypes: this.metadata?.scopeTypes
|
|
820
|
+
})), map((nodes) => coerceArray(nodes))).subscribe((data) => this._data$.next(data));
|
|
821
|
+
else this.tree$.pipe(map((tree) => flatTree(tree).filter((node) => node.isVisible)), tap((nodes) => nodes.forEach((node) => node.show()))).subscribe((data) => this._data$.next(data));
|
|
822
|
+
}
|
|
823
|
+
async getTreeRoot(options = {}) {
|
|
824
|
+
this.loading$.enable();
|
|
825
|
+
const root = await this.getRoot(options);
|
|
826
|
+
let rootNodes;
|
|
827
|
+
if (Array.isArray(root)) rootNodes = await Promise.all(root.map((node) => this.toNode(null, node)));
|
|
828
|
+
else rootNodes = [await this.toNode(null, root)];
|
|
829
|
+
const tmpSelectedNodes = [];
|
|
830
|
+
const restoreExpandAndSelectedState = (node) => {
|
|
831
|
+
if (this.expanded.isSelected(node.id)) node._expanded = true;
|
|
832
|
+
if (this.selected.selected.some((n) => n.id === node.id)) {
|
|
833
|
+
console.log("restore selected", node.display);
|
|
834
|
+
node._selected = true;
|
|
835
|
+
tmpSelectedNodes.push(node);
|
|
836
|
+
}
|
|
837
|
+
node.children.forEach(restoreExpandAndSelectedState);
|
|
838
|
+
};
|
|
839
|
+
rootNodes.forEach(restoreExpandAndSelectedState);
|
|
840
|
+
console.log("restore expand and selected state", tmpSelectedNodes);
|
|
841
|
+
this.selected.setSelection(...tmpSelectedNodes);
|
|
842
|
+
this.tree$.next(rootNodes);
|
|
843
|
+
this.loading$.disable();
|
|
844
|
+
return rootNodes;
|
|
845
|
+
}
|
|
846
|
+
selectNode(node) {
|
|
847
|
+
if (!this.selected.isMultipleSelection()) {
|
|
848
|
+
if (this.selected.hasValue()) this.selected.selected[0].deselect();
|
|
849
|
+
}
|
|
850
|
+
this.selected.select(node);
|
|
851
|
+
node.parent?.expand();
|
|
852
|
+
return Promise.resolve();
|
|
853
|
+
}
|
|
854
|
+
setTreeControl(treeControl) {
|
|
855
|
+
this.treeControl = treeControl;
|
|
856
|
+
}
|
|
857
|
+
setMatchFilter(matchFilter) {
|
|
858
|
+
this.matchFilter = matchFilter;
|
|
859
|
+
}
|
|
860
|
+
setToDisplay(toDisplay = this.toDisplay) {
|
|
861
|
+
this.toDisplay = toDisplay;
|
|
862
|
+
}
|
|
863
|
+
setGetIcon(getIcon = this.getIcon) {
|
|
864
|
+
this.getIcon = getIcon;
|
|
865
|
+
}
|
|
866
|
+
setHasDetails(hasDetails = this.hasDetails) {
|
|
867
|
+
this.hasDetails = hasDetails;
|
|
868
|
+
}
|
|
869
|
+
deselectNode(node) {
|
|
870
|
+
this.selected.deselect(node);
|
|
871
|
+
return Promise.resolve();
|
|
872
|
+
}
|
|
873
|
+
async expandNode(node, options) {
|
|
874
|
+
if (node.parent && !node.parent.expanded) {
|
|
875
|
+
console.log("expand parent", node.parent.display);
|
|
876
|
+
node.parent?.expand({ quite: true });
|
|
877
|
+
}
|
|
878
|
+
if (!options?.onlySelf) this.treeControl.expansionModel.select(node);
|
|
879
|
+
if (node.item.hasChildren && !node.item.children?.length) {
|
|
880
|
+
node.isLoading$.enable();
|
|
881
|
+
const children = await this.getChildren(node);
|
|
882
|
+
node.item.children = children;
|
|
883
|
+
node.addChildren(await Promise.all(children.map((child) => this.toNode(node, child, node.depth + 1, node.onExpand, node.onCollapse))));
|
|
884
|
+
node.isLoading$.disable();
|
|
885
|
+
}
|
|
886
|
+
console.log("expand node", node.display);
|
|
887
|
+
this.expanded.select(node.id);
|
|
888
|
+
if (!options?.quite) this.tree$.next(this.tree$.value);
|
|
889
|
+
}
|
|
890
|
+
async getChildren(node) {
|
|
891
|
+
if (!this.childrenRemoteMethod) throw new Error(`The node '${node.id}' has unloaded children but the RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD is not provided.`);
|
|
892
|
+
return this.childrenRemoteMethod.call(node);
|
|
893
|
+
}
|
|
894
|
+
async getRoot(options = {}) {
|
|
895
|
+
const rootParameters = await this.getRootParameters(options);
|
|
896
|
+
return this.rootRemoteMethod.call(rootParameters);
|
|
897
|
+
}
|
|
898
|
+
async getRootParameters(options = {}) {
|
|
899
|
+
return options;
|
|
900
|
+
}
|
|
901
|
+
getNodeById(id) {
|
|
902
|
+
function getNodeById(node, nodeId) {
|
|
903
|
+
if (node.id === nodeId) return node;
|
|
904
|
+
if (node.hasNode(nodeId)) return node.getNode(nodeId);
|
|
905
|
+
else return null;
|
|
906
|
+
}
|
|
907
|
+
return this.tree$.value.map((node) => getNodeById(node, id)).filter(Boolean)[0] || null;
|
|
908
|
+
}
|
|
909
|
+
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)) {
|
|
910
|
+
return Node.ToNode(parent, item, depth, onExpand, onCollapse, this.toDisplay, this.getIcon, this.getType, onSelect, onDeselect, this.hasDetails, this.getStyle, this.nodeParameters);
|
|
911
|
+
}
|
|
912
|
+
collapseNode(node, options) {
|
|
913
|
+
if (!options?.onlySelf) this.treeControl.expansionModel.deselect(node);
|
|
914
|
+
this.expanded.deselect(node.id);
|
|
915
|
+
if (!options?.quite) this.tree$.next(this.tree$.value);
|
|
916
|
+
return Promise.resolve();
|
|
917
|
+
}
|
|
918
|
+
flatTree(tree, all = false) {
|
|
919
|
+
return flatTree(tree, all);
|
|
920
|
+
}
|
|
921
|
+
destroy() {
|
|
922
|
+
super.destroy();
|
|
923
|
+
if (this._expandedLocalStorageSubscription) this._expandedLocalStorageSubscription.unsubscribe();
|
|
924
|
+
if (this._selectedLocalStorageSubscription) this._selectedLocalStorageSubscription.unsubscribe();
|
|
925
|
+
}
|
|
926
|
+
refreshMatchFilter() {
|
|
927
|
+
this._refreshMatchFilter.next();
|
|
928
|
+
}
|
|
929
|
+
async refresh() {
|
|
930
|
+
console.log("selected", this.selected.selected.map((node) => node.id));
|
|
931
|
+
console.log("expanded", this.expanded.selected.slice());
|
|
932
|
+
await this.getTreeRoot({ cache: false });
|
|
933
|
+
}
|
|
934
|
+
reset() {
|
|
935
|
+
this.selected.clear();
|
|
936
|
+
this.expanded.clear();
|
|
937
|
+
return this.getTreeRoot();
|
|
938
|
+
}
|
|
939
|
+
setGetStyle(getStyle = this.getStyle) {
|
|
940
|
+
this.getStyle = getStyle;
|
|
941
|
+
}
|
|
942
|
+
setGetType(getType = this.getType) {
|
|
943
|
+
this.getType = getType;
|
|
944
|
+
}
|
|
945
|
+
updateNodes() {
|
|
946
|
+
this._data$.value.forEach((node) => {
|
|
947
|
+
node.style = this.getStyle(node.item);
|
|
948
|
+
node.icon = coerceArray(this.getIcon(node.item));
|
|
949
|
+
node.display = this.toDisplay(node.item);
|
|
950
|
+
});
|
|
951
|
+
this._data$.next(this._data$.value);
|
|
952
|
+
}
|
|
953
|
+
_connect(collectionViewer) {
|
|
954
|
+
this.init();
|
|
955
|
+
this.treeControl.expansionModel.changed.pipe(tap(async (change) => {
|
|
956
|
+
if (isSelectionChange(change)) {
|
|
957
|
+
const promiseList = [];
|
|
958
|
+
if (change.added) promiseList.push(...change.added.map((node) => node.expand({
|
|
959
|
+
onlySelf: true,
|
|
960
|
+
quite: true
|
|
961
|
+
})));
|
|
962
|
+
if (change.removed) promiseList.push(...change.removed.slice().reverse().map((node) => node.collapse({
|
|
963
|
+
onlySelf: true,
|
|
964
|
+
quite: true
|
|
965
|
+
})));
|
|
966
|
+
await Promise.all(promiseList);
|
|
967
|
+
this.tree$.next(this.tree$.value);
|
|
968
|
+
}
|
|
969
|
+
})).subscribe();
|
|
970
|
+
let loadRoot = Promise.resolve();
|
|
971
|
+
if (this.tree$.value.length === 0) loadRoot = this.getTreeRoot();
|
|
972
|
+
let autoRefreshExecuted = false;
|
|
973
|
+
return from(loadRoot).pipe(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))))), tap(() => {
|
|
974
|
+
if (this._preSelected.length) {
|
|
975
|
+
console.log("restore selected", this._preSelected);
|
|
976
|
+
this.selected.clear();
|
|
977
|
+
const nodes = this._preSelected.map((id) => this.getNodeById(id));
|
|
978
|
+
this._preSelected = [];
|
|
979
|
+
nodes.forEach((node) => {
|
|
980
|
+
node?.select();
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}), tap(() => {
|
|
984
|
+
if (this.metadata.autoRefreshWithoutCache) {
|
|
985
|
+
if (!autoRefreshExecuted) {
|
|
986
|
+
autoRefreshExecuted = true;
|
|
987
|
+
console.log("auto refresh");
|
|
988
|
+
this.refresh();
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}));
|
|
992
|
+
}
|
|
993
|
+
initSelected() {
|
|
994
|
+
const key = joinPath("rxap/tree", this.id, "selected");
|
|
995
|
+
if (this.metadata["cacheSelected"]) {
|
|
996
|
+
if (localStorage.getItem(key)) try {
|
|
997
|
+
this._preSelected = JSON.parse(localStorage.getItem(key));
|
|
998
|
+
} catch (e) {
|
|
999
|
+
console.error("parse expanded tree data source nodes failed");
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
this.selected = new SelectionModel(!!this.metadata.selectMultiple, []);
|
|
1003
|
+
if (this.metadata["cacheSelected"]) this._selectedLocalStorageSubscription = this.selected.changed.pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.selected.selected.map((s) => s.id))))).subscribe();
|
|
1004
|
+
}
|
|
1005
|
+
initExpanded() {
|
|
1006
|
+
const key = joinPath("rxap/tree", this.id, "expanded");
|
|
1007
|
+
let expanded = [];
|
|
1008
|
+
if (this.metadata["cacheExpanded"]) {
|
|
1009
|
+
if (localStorage.getItem(key)) try {
|
|
1010
|
+
expanded = JSON.parse(localStorage.getItem(key));
|
|
1011
|
+
} catch (e) {
|
|
1012
|
+
console.error("parse expanded tree data source nodes failed");
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
this.expanded = new SelectionModel(this.metadata.expandMultiple !== false, expanded);
|
|
1016
|
+
if (this.metadata["cacheExpanded"]) this._expandedLocalStorageSubscription = this.expanded.changed.pipe(tap(() => localStorage.setItem(key, JSON.stringify(this.expanded.selected)))).subscribe();
|
|
1017
|
+
}
|
|
1018
|
+
static {
|
|
1019
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1020
|
+
minVersion: "12.0.0",
|
|
1021
|
+
version: "22.3.0",
|
|
1022
|
+
ngImport: i0,
|
|
1023
|
+
type: TreeDataSource,
|
|
1024
|
+
deps: [],
|
|
1025
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
static {
|
|
1029
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1030
|
+
minVersion: "12.0.0",
|
|
1031
|
+
version: "22.3.0",
|
|
1032
|
+
ngImport: i0,
|
|
1033
|
+
type: TreeDataSource
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
754
1036
|
};
|
|
755
|
-
__decorate([
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
],
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
// region
|
|
768
|
-
// endregion
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Generated bundle index. Do not edit.
|
|
772
|
-
*/
|
|
773
|
-
|
|
1037
|
+
__decorate([Required, __metadata("design:type", FlatTreeControl)], TreeDataSource.prototype, "treeControl", void 0);
|
|
1038
|
+
TreeDataSource = __decorate([RxapDataSource("tree"), __metadata("design:paramtypes", [])], TreeDataSource);
|
|
1039
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1040
|
+
minVersion: "12.0.0",
|
|
1041
|
+
version: "22.3.0",
|
|
1042
|
+
ngImport: i0,
|
|
1043
|
+
type: TreeDataSource,
|
|
1044
|
+
decorators: [{ type: Injectable }],
|
|
1045
|
+
ctorParameters: () => [],
|
|
1046
|
+
propDecorators: { treeControl: [] }
|
|
1047
|
+
});
|
|
774
1048
|
export { DefaultTreeApplyFilterMethod, FormFactory, 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, SearchForm, SearchFormProviders, TreeComponent, TreeContentDirective, TreeDataSource, flatTree, isSelectionChange };
|
|
775
|
-
|
|
1049
|
+
|
|
1050
|
+
//# sourceMappingURL=rxap-tree.mjs.map
|