@ali-hm/angular-tree-component 16.0.1 → 17.0.1
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/esm2022/ali-hm-angular-tree-component.mjs +4 -4
- package/esm2022/lib/angular-tree-component.module.mjs +99 -99
- package/esm2022/lib/components/loading.component.mjs +20 -20
- package/esm2022/lib/components/tree-node-checkbox.component.mjs +14 -14
- package/esm2022/lib/components/tree-node-collection.component.mjs +119 -119
- package/esm2022/lib/components/tree-node-content.component.mjs +22 -22
- package/esm2022/lib/components/tree-node-drop-slot.component.mjs +25 -25
- package/esm2022/lib/components/tree-node-expander.component.mjs +15 -15
- package/esm2022/lib/components/tree-node-wrapper.component.mjs +23 -23
- package/esm2022/lib/components/tree-viewport.component.mjs +55 -55
- package/esm2022/lib/components/tree.component.mjs +137 -137
- package/esm2022/lib/constants/events.mjs +19 -19
- package/esm2022/lib/constants/keys.mjs +9 -9
- package/esm2022/lib/defs/api.mjs +1 -1
- package/esm2022/lib/directives/tree-animate-open.directive.mjs +101 -101
- package/esm2022/lib/directives/tree-drag.directive.mjs +65 -65
- package/esm2022/lib/directives/tree-drop.directive.mjs +127 -127
- package/esm2022/lib/mobx-angular/mobx-proxy.mjs +16 -16
- package/esm2022/lib/mobx-angular/tree-mobx-autorun.directive.mjs +40 -40
- package/esm2022/lib/models/tree-dragged-element.model.mjs +24 -24
- package/esm2022/lib/models/tree-node.model.mjs +389 -389
- package/esm2022/lib/models/tree-options.model.mjs +150 -150
- package/esm2022/lib/models/tree-virtual-scroll.model.mjs +197 -197
- package/esm2022/lib/models/tree.model.mjs +546 -546
- package/esm2022/public-api.mjs +4 -4
- package/fesm2022/ali-hm-angular-tree-component.mjs +2080 -2080
- package/fesm2022/ali-hm-angular-tree-component.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/angular-tree-component.module.d.ts +43 -43
- package/lib/components/loading.component.d.ts +9 -9
- package/lib/components/tree-node-checkbox.component.d.ts +7 -7
- package/lib/components/tree-node-collection.component.d.ts +34 -34
- package/lib/components/tree-node-content.component.d.ts +10 -10
- package/lib/components/tree-node-drop-slot.component.d.ts +10 -10
- package/lib/components/tree-node-expander.component.d.ts +7 -7
- package/lib/components/tree-node-wrapper.component.d.ts +9 -9
- package/lib/components/tree-viewport.component.d.ts +17 -17
- package/lib/components/tree.component.d.ts +47 -47
- package/lib/constants/events.d.ts +19 -19
- package/lib/constants/keys.d.ts +9 -9
- package/lib/defs/api.d.ts +611 -611
- package/lib/directives/tree-animate-open.directive.d.ts +20 -20
- package/lib/directives/tree-drag.directive.d.ts +21 -21
- package/lib/directives/tree-drop.directive.d.ts +33 -33
- package/lib/mobx-angular/mobx-proxy.d.ts +7 -7
- package/lib/mobx-angular/tree-mobx-autorun.directive.d.ts +17 -17
- package/lib/models/tree-dragged-element.model.d.ts +9 -9
- package/lib/models/tree-node.model.d.ts +83 -83
- package/lib/models/tree-options.model.d.ts +77 -77
- package/lib/models/tree-virtual-scroll.model.d.ts +27 -27
- package/lib/models/tree.model.d.ts +91 -91
- package/package.json +3 -3
- package/public-api.d.ts +1 -1
|
@@ -4,1540 +4,1540 @@ import * as i1 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { autorun, reaction, computed as computed$1, observable as observable$1, action as action$1 } from 'mobx';
|
|
6
6
|
|
|
7
|
-
class TreeMobxAutorunDirective {
|
|
8
|
-
constructor(templateRef, viewContainer) {
|
|
9
|
-
this.templateRef = templateRef;
|
|
10
|
-
this.viewContainer = viewContainer;
|
|
11
|
-
this.templateBindings = {};
|
|
12
|
-
}
|
|
13
|
-
ngOnInit() {
|
|
14
|
-
this.view = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
15
|
-
if (this.dispose) {
|
|
16
|
-
this.dispose();
|
|
17
|
-
}
|
|
18
|
-
if (this.shouldDetach()) {
|
|
19
|
-
this.view.detach();
|
|
20
|
-
}
|
|
21
|
-
this.autoDetect(this.view);
|
|
22
|
-
}
|
|
23
|
-
shouldDetach() {
|
|
24
|
-
return this.treeMobxAutorun && this.treeMobxAutorun.detach;
|
|
25
|
-
}
|
|
26
|
-
autoDetect(view) {
|
|
27
|
-
this.dispose = autorun(() => view.detectChanges());
|
|
28
|
-
}
|
|
29
|
-
ngOnDestroy() {
|
|
30
|
-
if (this.dispose) {
|
|
31
|
-
this.dispose();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
35
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
36
|
-
}
|
|
37
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
38
|
-
type: Directive,
|
|
39
|
-
args: [{ selector: '[treeMobxAutorun]' }]
|
|
40
|
-
}], ctorParameters:
|
|
41
|
-
type: Input
|
|
7
|
+
class TreeMobxAutorunDirective {
|
|
8
|
+
constructor(templateRef, viewContainer) {
|
|
9
|
+
this.templateRef = templateRef;
|
|
10
|
+
this.viewContainer = viewContainer;
|
|
11
|
+
this.templateBindings = {};
|
|
12
|
+
}
|
|
13
|
+
ngOnInit() {
|
|
14
|
+
this.view = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
15
|
+
if (this.dispose) {
|
|
16
|
+
this.dispose();
|
|
17
|
+
}
|
|
18
|
+
if (this.shouldDetach()) {
|
|
19
|
+
this.view.detach();
|
|
20
|
+
}
|
|
21
|
+
this.autoDetect(this.view);
|
|
22
|
+
}
|
|
23
|
+
shouldDetach() {
|
|
24
|
+
return this.treeMobxAutorun && this.treeMobxAutorun.detach;
|
|
25
|
+
}
|
|
26
|
+
autoDetect(view) {
|
|
27
|
+
this.dispose = autorun(() => view.detectChanges());
|
|
28
|
+
}
|
|
29
|
+
ngOnDestroy() {
|
|
30
|
+
if (this.dispose) {
|
|
31
|
+
this.dispose();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeMobxAutorunDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
35
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: { treeMobxAutorun: "treeMobxAutorun" }, ngImport: i0 }); }
|
|
36
|
+
}
|
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeMobxAutorunDirective, decorators: [{
|
|
38
|
+
type: Directive,
|
|
39
|
+
args: [{ selector: '[treeMobxAutorun]' }]
|
|
40
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }], propDecorators: { treeMobxAutorun: [{
|
|
41
|
+
type: Input
|
|
42
42
|
}] } });
|
|
43
43
|
|
|
44
|
-
const KEYS = {
|
|
45
|
-
LEFT: 37,
|
|
46
|
-
UP: 38,
|
|
47
|
-
RIGHT: 39,
|
|
48
|
-
DOWN: 40,
|
|
49
|
-
ENTER: 13,
|
|
50
|
-
SPACE: 32,
|
|
51
|
-
CONTEXT_MENU: 32
|
|
44
|
+
const KEYS = {
|
|
45
|
+
LEFT: 37,
|
|
46
|
+
UP: 38,
|
|
47
|
+
RIGHT: 39,
|
|
48
|
+
DOWN: 40,
|
|
49
|
+
ENTER: 13,
|
|
50
|
+
SPACE: 32,
|
|
51
|
+
CONTEXT_MENU: 32
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const TREE_ACTIONS = {
|
|
55
|
-
TOGGLE_ACTIVE: (tree, node, $event) => node && node.toggleActivated(),
|
|
56
|
-
TOGGLE_ACTIVE_MULTI: (tree, node, $event) => node && node.toggleActivated(true),
|
|
57
|
-
TOGGLE_SELECTED: (tree, node, $event) => node && node.toggleSelected(),
|
|
58
|
-
ACTIVATE: (tree, node, $event) => node.setIsActive(true),
|
|
59
|
-
DEACTIVATE: (tree, node, $event) => node.setIsActive(false),
|
|
60
|
-
SELECT: (tree, node, $event) => node.setIsSelected(true),
|
|
61
|
-
DESELECT: (tree, node, $event) => node.setIsSelected(false),
|
|
62
|
-
FOCUS: (tree, node, $event) => node.focus(),
|
|
63
|
-
TOGGLE_EXPANDED: (tree, node, $event) => node.hasChildren && node.toggleExpanded(),
|
|
64
|
-
EXPAND: (tree, node, $event) => node.expand(),
|
|
65
|
-
COLLAPSE: (tree, node, $event) => node.collapse(),
|
|
66
|
-
DRILL_DOWN: (tree, node, $event) => tree.focusDrillDown(),
|
|
67
|
-
DRILL_UP: (tree, node, $event) => tree.focusDrillUp(),
|
|
68
|
-
NEXT_NODE: (tree, node, $event) => tree.focusNextNode(),
|
|
69
|
-
PREVIOUS_NODE: (tree, node, $event) => tree.focusPreviousNode(),
|
|
70
|
-
MOVE_NODE: (tree, node, $event, { from, to }) => {
|
|
71
|
-
// default action assumes from = node, to = {parent, index}
|
|
72
|
-
if ($event.ctrlKey) {
|
|
73
|
-
tree.copyNode(from, to);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
tree.moveNode(from, to);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const defaultActionMapping = {
|
|
81
|
-
mouse: {
|
|
82
|
-
click: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
83
|
-
dblClick: null,
|
|
84
|
-
contextMenu: null,
|
|
85
|
-
expanderClick: TREE_ACTIONS.TOGGLE_EXPANDED,
|
|
86
|
-
checkboxClick: TREE_ACTIONS.TOGGLE_SELECTED,
|
|
87
|
-
drop: TREE_ACTIONS.MOVE_NODE
|
|
88
|
-
},
|
|
89
|
-
keys: {
|
|
90
|
-
[KEYS.RIGHT]: TREE_ACTIONS.DRILL_DOWN,
|
|
91
|
-
[KEYS.LEFT]: TREE_ACTIONS.DRILL_UP,
|
|
92
|
-
[KEYS.DOWN]: TREE_ACTIONS.NEXT_NODE,
|
|
93
|
-
[KEYS.UP]: TREE_ACTIONS.PREVIOUS_NODE,
|
|
94
|
-
[KEYS.SPACE]: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
95
|
-
[KEYS.ENTER]: TREE_ACTIONS.TOGGLE_ACTIVE
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
class TreeOptions {
|
|
99
|
-
get hasChildrenField() { return this.options.hasChildrenField || 'hasChildren'; }
|
|
100
|
-
get childrenField() { return this.options.childrenField || 'children'; }
|
|
101
|
-
get displayField() { return this.options.displayField || 'name'; }
|
|
102
|
-
get idField() { return this.options.idField || 'id'; }
|
|
103
|
-
get isExpandedField() { return this.options.isExpandedField || 'isExpanded'; }
|
|
104
|
-
get getChildren() { return this.options.getChildren; }
|
|
105
|
-
get levelPadding() { return this.options.levelPadding || 0; }
|
|
106
|
-
get useVirtualScroll() { return this.options.useVirtualScroll; }
|
|
107
|
-
get animateExpand() { return this.options.animateExpand; }
|
|
108
|
-
get animateSpeed() { return this.options.animateSpeed || 1; }
|
|
109
|
-
get animateAcceleration() { return this.options.animateAcceleration || 1.2; }
|
|
110
|
-
get scrollOnActivate() { return this.options.scrollOnActivate === undefined ? true : this.options.scrollOnActivate; }
|
|
111
|
-
get rtl() { return !!this.options.rtl; }
|
|
112
|
-
get rootId() { return this.options.rootId; }
|
|
113
|
-
get useCheckbox() { return this.options.useCheckbox; }
|
|
114
|
-
get useTriState() { return this.options.useTriState === undefined ? true : this.options.useTriState; }
|
|
115
|
-
get scrollContainer() { return this.options.scrollContainer; }
|
|
116
|
-
get allowDragoverStyling() { return this.options.allowDragoverStyling === undefined ? true : this.options.allowDragoverStyling; }
|
|
117
|
-
constructor(options = {}) {
|
|
118
|
-
this.options = options;
|
|
119
|
-
this.actionMapping = {
|
|
120
|
-
mouse: {
|
|
121
|
-
click: this.options?.actionMapping?.mouse?.click ?? defaultActionMapping.mouse.click,
|
|
122
|
-
dblClick: this.options?.actionMapping?.mouse?.dblClick ?? defaultActionMapping.mouse.dblClick,
|
|
123
|
-
contextMenu: this.options?.actionMapping?.mouse?.contextMenu ?? defaultActionMapping.mouse.contextMenu,
|
|
124
|
-
expanderClick: this.options?.actionMapping?.mouse?.expanderClick ?? defaultActionMapping.mouse.expanderClick,
|
|
125
|
-
checkboxClick: this.options?.actionMapping?.mouse?.checkboxClick ?? defaultActionMapping.mouse.checkboxClick,
|
|
126
|
-
drop: this.options?.actionMapping?.mouse?.drop ?? defaultActionMapping.mouse.drop,
|
|
127
|
-
dragStart: this.options?.actionMapping?.mouse?.dragStart ?? undefined,
|
|
128
|
-
drag: this.options?.actionMapping?.mouse?.drag ?? undefined,
|
|
129
|
-
dragEnd: this.options?.actionMapping?.mouse?.dragEnd ?? undefined,
|
|
130
|
-
dragOver: this.options?.actionMapping?.mouse?.dragOver ?? undefined,
|
|
131
|
-
dragLeave: this.options?.actionMapping?.mouse?.dragLeave ?? undefined,
|
|
132
|
-
dragEnter: this.options?.actionMapping?.mouse?.dragEnter ?? undefined,
|
|
133
|
-
mouseOver: this.options?.actionMapping?.mouse?.mouseOver ?? undefined,
|
|
134
|
-
mouseOut: this.options?.actionMapping?.mouse?.mouseOut ?? undefined,
|
|
135
|
-
},
|
|
136
|
-
keys: {
|
|
137
|
-
[KEYS.RIGHT]: TREE_ACTIONS.DRILL_DOWN,
|
|
138
|
-
[KEYS.LEFT]: TREE_ACTIONS.DRILL_UP,
|
|
139
|
-
[KEYS.DOWN]: TREE_ACTIONS.NEXT_NODE,
|
|
140
|
-
[KEYS.UP]: TREE_ACTIONS.PREVIOUS_NODE,
|
|
141
|
-
[KEYS.SPACE]: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
142
|
-
[KEYS.ENTER]: TREE_ACTIONS.TOGGLE_ACTIVE
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
if (this.options?.actionMapping?.keys) {
|
|
146
|
-
this.actionMapping.keys = {
|
|
147
|
-
...this.actionMapping.keys,
|
|
148
|
-
...this.options.actionMapping.keys
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
if (options.rtl) {
|
|
152
|
-
this.actionMapping.keys[KEYS.RIGHT] = options.actionMapping?.keys[KEYS.RIGHT] || TREE_ACTIONS.DRILL_UP;
|
|
153
|
-
this.actionMapping.keys[KEYS.LEFT] = options.actionMapping?.keys[KEYS.LEFT] || TREE_ACTIONS.DRILL_DOWN;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
getNodeClone(node) {
|
|
157
|
-
if (this.options.getNodeClone) {
|
|
158
|
-
return this.options.getNodeClone(node);
|
|
159
|
-
}
|
|
160
|
-
// remove id from clone
|
|
161
|
-
// keeping ie11 compatibility
|
|
162
|
-
const nodeClone = Object.assign({}, node.data);
|
|
163
|
-
if (nodeClone.id) {
|
|
164
|
-
delete nodeClone.id;
|
|
165
|
-
}
|
|
166
|
-
return nodeClone;
|
|
167
|
-
}
|
|
168
|
-
allowDrop(element, to, $event) {
|
|
169
|
-
if (this.options.allowDrop instanceof Function) {
|
|
170
|
-
return this.options.allowDrop(element, to, $event);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
return this.options.allowDrop === undefined ? true : this.options.allowDrop;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
allowDrag(node) {
|
|
177
|
-
if (this.options.allowDrag instanceof Function) {
|
|
178
|
-
return this.options.allowDrag(node);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return this.options.allowDrag;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
nodeClass(node) {
|
|
185
|
-
return this.options.nodeClass ? this.options.nodeClass(node) : '';
|
|
186
|
-
}
|
|
187
|
-
nodeHeight(node) {
|
|
188
|
-
if (node.data.virtual) {
|
|
189
|
-
return 0;
|
|
190
|
-
}
|
|
191
|
-
let nodeHeight = this.options.nodeHeight || 22;
|
|
192
|
-
if (typeof nodeHeight === 'function') {
|
|
193
|
-
nodeHeight = nodeHeight(node);
|
|
194
|
-
}
|
|
195
|
-
// account for drop slots:
|
|
196
|
-
return nodeHeight + (node.index === 0 ? 2 : 1) * this.dropSlotHeight;
|
|
197
|
-
}
|
|
198
|
-
get dropSlotHeight() {
|
|
199
|
-
return typeof this.options.dropSlotHeight === 'number' ? this.options.dropSlotHeight : 2;
|
|
200
|
-
}
|
|
54
|
+
const TREE_ACTIONS = {
|
|
55
|
+
TOGGLE_ACTIVE: (tree, node, $event) => node && node.toggleActivated(),
|
|
56
|
+
TOGGLE_ACTIVE_MULTI: (tree, node, $event) => node && node.toggleActivated(true),
|
|
57
|
+
TOGGLE_SELECTED: (tree, node, $event) => node && node.toggleSelected(),
|
|
58
|
+
ACTIVATE: (tree, node, $event) => node.setIsActive(true),
|
|
59
|
+
DEACTIVATE: (tree, node, $event) => node.setIsActive(false),
|
|
60
|
+
SELECT: (tree, node, $event) => node.setIsSelected(true),
|
|
61
|
+
DESELECT: (tree, node, $event) => node.setIsSelected(false),
|
|
62
|
+
FOCUS: (tree, node, $event) => node.focus(),
|
|
63
|
+
TOGGLE_EXPANDED: (tree, node, $event) => node.hasChildren && node.toggleExpanded(),
|
|
64
|
+
EXPAND: (tree, node, $event) => node.expand(),
|
|
65
|
+
COLLAPSE: (tree, node, $event) => node.collapse(),
|
|
66
|
+
DRILL_DOWN: (tree, node, $event) => tree.focusDrillDown(),
|
|
67
|
+
DRILL_UP: (tree, node, $event) => tree.focusDrillUp(),
|
|
68
|
+
NEXT_NODE: (tree, node, $event) => tree.focusNextNode(),
|
|
69
|
+
PREVIOUS_NODE: (tree, node, $event) => tree.focusPreviousNode(),
|
|
70
|
+
MOVE_NODE: (tree, node, $event, { from, to }) => {
|
|
71
|
+
// default action assumes from = node, to = {parent, index}
|
|
72
|
+
if ($event.ctrlKey) {
|
|
73
|
+
tree.copyNode(from, to);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
tree.moveNode(from, to);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const defaultActionMapping = {
|
|
81
|
+
mouse: {
|
|
82
|
+
click: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
83
|
+
dblClick: null,
|
|
84
|
+
contextMenu: null,
|
|
85
|
+
expanderClick: TREE_ACTIONS.TOGGLE_EXPANDED,
|
|
86
|
+
checkboxClick: TREE_ACTIONS.TOGGLE_SELECTED,
|
|
87
|
+
drop: TREE_ACTIONS.MOVE_NODE
|
|
88
|
+
},
|
|
89
|
+
keys: {
|
|
90
|
+
[KEYS.RIGHT]: TREE_ACTIONS.DRILL_DOWN,
|
|
91
|
+
[KEYS.LEFT]: TREE_ACTIONS.DRILL_UP,
|
|
92
|
+
[KEYS.DOWN]: TREE_ACTIONS.NEXT_NODE,
|
|
93
|
+
[KEYS.UP]: TREE_ACTIONS.PREVIOUS_NODE,
|
|
94
|
+
[KEYS.SPACE]: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
95
|
+
[KEYS.ENTER]: TREE_ACTIONS.TOGGLE_ACTIVE
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
class TreeOptions {
|
|
99
|
+
get hasChildrenField() { return this.options.hasChildrenField || 'hasChildren'; }
|
|
100
|
+
get childrenField() { return this.options.childrenField || 'children'; }
|
|
101
|
+
get displayField() { return this.options.displayField || 'name'; }
|
|
102
|
+
get idField() { return this.options.idField || 'id'; }
|
|
103
|
+
get isExpandedField() { return this.options.isExpandedField || 'isExpanded'; }
|
|
104
|
+
get getChildren() { return this.options.getChildren; }
|
|
105
|
+
get levelPadding() { return this.options.levelPadding || 0; }
|
|
106
|
+
get useVirtualScroll() { return this.options.useVirtualScroll; }
|
|
107
|
+
get animateExpand() { return this.options.animateExpand; }
|
|
108
|
+
get animateSpeed() { return this.options.animateSpeed || 1; }
|
|
109
|
+
get animateAcceleration() { return this.options.animateAcceleration || 1.2; }
|
|
110
|
+
get scrollOnActivate() { return this.options.scrollOnActivate === undefined ? true : this.options.scrollOnActivate; }
|
|
111
|
+
get rtl() { return !!this.options.rtl; }
|
|
112
|
+
get rootId() { return this.options.rootId; }
|
|
113
|
+
get useCheckbox() { return this.options.useCheckbox; }
|
|
114
|
+
get useTriState() { return this.options.useTriState === undefined ? true : this.options.useTriState; }
|
|
115
|
+
get scrollContainer() { return this.options.scrollContainer; }
|
|
116
|
+
get allowDragoverStyling() { return this.options.allowDragoverStyling === undefined ? true : this.options.allowDragoverStyling; }
|
|
117
|
+
constructor(options = {}) {
|
|
118
|
+
this.options = options;
|
|
119
|
+
this.actionMapping = {
|
|
120
|
+
mouse: {
|
|
121
|
+
click: this.options?.actionMapping?.mouse?.click ?? defaultActionMapping.mouse.click,
|
|
122
|
+
dblClick: this.options?.actionMapping?.mouse?.dblClick ?? defaultActionMapping.mouse.dblClick,
|
|
123
|
+
contextMenu: this.options?.actionMapping?.mouse?.contextMenu ?? defaultActionMapping.mouse.contextMenu,
|
|
124
|
+
expanderClick: this.options?.actionMapping?.mouse?.expanderClick ?? defaultActionMapping.mouse.expanderClick,
|
|
125
|
+
checkboxClick: this.options?.actionMapping?.mouse?.checkboxClick ?? defaultActionMapping.mouse.checkboxClick,
|
|
126
|
+
drop: this.options?.actionMapping?.mouse?.drop ?? defaultActionMapping.mouse.drop,
|
|
127
|
+
dragStart: this.options?.actionMapping?.mouse?.dragStart ?? undefined,
|
|
128
|
+
drag: this.options?.actionMapping?.mouse?.drag ?? undefined,
|
|
129
|
+
dragEnd: this.options?.actionMapping?.mouse?.dragEnd ?? undefined,
|
|
130
|
+
dragOver: this.options?.actionMapping?.mouse?.dragOver ?? undefined,
|
|
131
|
+
dragLeave: this.options?.actionMapping?.mouse?.dragLeave ?? undefined,
|
|
132
|
+
dragEnter: this.options?.actionMapping?.mouse?.dragEnter ?? undefined,
|
|
133
|
+
mouseOver: this.options?.actionMapping?.mouse?.mouseOver ?? undefined,
|
|
134
|
+
mouseOut: this.options?.actionMapping?.mouse?.mouseOut ?? undefined,
|
|
135
|
+
},
|
|
136
|
+
keys: {
|
|
137
|
+
[KEYS.RIGHT]: TREE_ACTIONS.DRILL_DOWN,
|
|
138
|
+
[KEYS.LEFT]: TREE_ACTIONS.DRILL_UP,
|
|
139
|
+
[KEYS.DOWN]: TREE_ACTIONS.NEXT_NODE,
|
|
140
|
+
[KEYS.UP]: TREE_ACTIONS.PREVIOUS_NODE,
|
|
141
|
+
[KEYS.SPACE]: TREE_ACTIONS.TOGGLE_ACTIVE,
|
|
142
|
+
[KEYS.ENTER]: TREE_ACTIONS.TOGGLE_ACTIVE
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (this.options?.actionMapping?.keys) {
|
|
146
|
+
this.actionMapping.keys = {
|
|
147
|
+
...this.actionMapping.keys,
|
|
148
|
+
...this.options.actionMapping.keys
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (options.rtl) {
|
|
152
|
+
this.actionMapping.keys[KEYS.RIGHT] = options.actionMapping?.keys[KEYS.RIGHT] || TREE_ACTIONS.DRILL_UP;
|
|
153
|
+
this.actionMapping.keys[KEYS.LEFT] = options.actionMapping?.keys[KEYS.LEFT] || TREE_ACTIONS.DRILL_DOWN;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
getNodeClone(node) {
|
|
157
|
+
if (this.options.getNodeClone) {
|
|
158
|
+
return this.options.getNodeClone(node);
|
|
159
|
+
}
|
|
160
|
+
// remove id from clone
|
|
161
|
+
// keeping ie11 compatibility
|
|
162
|
+
const nodeClone = Object.assign({}, node.data);
|
|
163
|
+
if (nodeClone.id) {
|
|
164
|
+
delete nodeClone.id;
|
|
165
|
+
}
|
|
166
|
+
return nodeClone;
|
|
167
|
+
}
|
|
168
|
+
allowDrop(element, to, $event) {
|
|
169
|
+
if (this.options.allowDrop instanceof Function) {
|
|
170
|
+
return this.options.allowDrop(element, to, $event);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return this.options.allowDrop === undefined ? true : this.options.allowDrop;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
allowDrag(node) {
|
|
177
|
+
if (this.options.allowDrag instanceof Function) {
|
|
178
|
+
return this.options.allowDrag(node);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return this.options.allowDrag;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
nodeClass(node) {
|
|
185
|
+
return this.options.nodeClass ? this.options.nodeClass(node) : '';
|
|
186
|
+
}
|
|
187
|
+
nodeHeight(node) {
|
|
188
|
+
if (node.data.virtual) {
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
let nodeHeight = this.options.nodeHeight || 22;
|
|
192
|
+
if (typeof nodeHeight === 'function') {
|
|
193
|
+
nodeHeight = nodeHeight(node);
|
|
194
|
+
}
|
|
195
|
+
// account for drop slots:
|
|
196
|
+
return nodeHeight + (node.index === 0 ? 2 : 1) * this.dropSlotHeight;
|
|
197
|
+
}
|
|
198
|
+
get dropSlotHeight() {
|
|
199
|
+
return typeof this.options.dropSlotHeight === 'number' ? this.options.dropSlotHeight : 2;
|
|
200
|
+
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
const TREE_EVENTS = {
|
|
204
|
-
toggleExpanded: 'toggleExpanded',
|
|
205
|
-
activate: 'activate',
|
|
206
|
-
deactivate: 'deactivate',
|
|
207
|
-
nodeActivate: 'nodeActivate',
|
|
208
|
-
nodeDeactivate: 'nodeDeactivate',
|
|
209
|
-
select: 'select',
|
|
210
|
-
deselect: 'deselect',
|
|
211
|
-
focus: 'focus',
|
|
212
|
-
blur: 'blur',
|
|
213
|
-
initialized: 'initialized',
|
|
214
|
-
updateData: 'updateData',
|
|
215
|
-
moveNode: 'moveNode',
|
|
216
|
-
copyNode: 'copyNode',
|
|
217
|
-
event: 'event',
|
|
218
|
-
loadNodeChildren: 'loadNodeChildren',
|
|
219
|
-
changeFilter: 'changeFilter',
|
|
220
|
-
stateChange: 'stateChange'
|
|
203
|
+
const TREE_EVENTS = {
|
|
204
|
+
toggleExpanded: 'toggleExpanded',
|
|
205
|
+
activate: 'activate',
|
|
206
|
+
deactivate: 'deactivate',
|
|
207
|
+
nodeActivate: 'nodeActivate',
|
|
208
|
+
nodeDeactivate: 'nodeDeactivate',
|
|
209
|
+
select: 'select',
|
|
210
|
+
deselect: 'deselect',
|
|
211
|
+
focus: 'focus',
|
|
212
|
+
blur: 'blur',
|
|
213
|
+
initialized: 'initialized',
|
|
214
|
+
updateData: 'updateData',
|
|
215
|
+
moveNode: 'moveNode',
|
|
216
|
+
copyNode: 'copyNode',
|
|
217
|
+
event: 'event',
|
|
218
|
+
loadNodeChildren: 'loadNodeChildren',
|
|
219
|
+
changeFilter: 'changeFilter',
|
|
220
|
+
stateChange: 'stateChange'
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
-
var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
224
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
225
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
226
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
227
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
228
|
-
};
|
|
229
|
-
class TreeNode {
|
|
230
|
-
get isHidden() { return this.treeModel.isHidden(this); }
|
|
231
|
-
;
|
|
232
|
-
get isExpanded() { return this.treeModel.isExpanded(this); }
|
|
233
|
-
;
|
|
234
|
-
get isActive() { return this.treeModel.isActive(this); }
|
|
235
|
-
;
|
|
236
|
-
get isFocused() { return this.treeModel.isNodeFocused(this); }
|
|
237
|
-
;
|
|
238
|
-
get isSelected() {
|
|
239
|
-
if (this.isSelectable()) {
|
|
240
|
-
return this.treeModel.isSelected(this);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
return this.children.some((node) => node.isSelected);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
;
|
|
247
|
-
get isAllSelected() {
|
|
248
|
-
if (this.isSelectable()) {
|
|
249
|
-
return this.treeModel.isSelected(this);
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
return this.children.every((node) => node.isAllSelected);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
;
|
|
256
|
-
get isPartiallySelected() {
|
|
257
|
-
return this.isSelected && !this.isAllSelected;
|
|
258
|
-
}
|
|
259
|
-
get level() {
|
|
260
|
-
return this.parent ? this.parent.level + 1 : 0;
|
|
261
|
-
}
|
|
262
|
-
get path() {
|
|
263
|
-
return this.parent ? [...this.parent.path, this.id] : [];
|
|
264
|
-
}
|
|
265
|
-
get elementRef() {
|
|
223
|
+
var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
224
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
225
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
226
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
227
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
228
|
+
};
|
|
229
|
+
class TreeNode {
|
|
230
|
+
get isHidden() { return this.treeModel.isHidden(this); }
|
|
231
|
+
;
|
|
232
|
+
get isExpanded() { return this.treeModel.isExpanded(this); }
|
|
233
|
+
;
|
|
234
|
+
get isActive() { return this.treeModel.isActive(this); }
|
|
235
|
+
;
|
|
236
|
+
get isFocused() { return this.treeModel.isNodeFocused(this); }
|
|
237
|
+
;
|
|
238
|
+
get isSelected() {
|
|
239
|
+
if (this.isSelectable()) {
|
|
240
|
+
return this.treeModel.isSelected(this);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
return this.children.some((node) => node.isSelected);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
;
|
|
247
|
+
get isAllSelected() {
|
|
248
|
+
if (this.isSelectable()) {
|
|
249
|
+
return this.treeModel.isSelected(this);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
return this.children.every((node) => node.isAllSelected);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
;
|
|
256
|
+
get isPartiallySelected() {
|
|
257
|
+
return this.isSelected && !this.isAllSelected;
|
|
258
|
+
}
|
|
259
|
+
get level() {
|
|
260
|
+
return this.parent ? this.parent.level + 1 : 0;
|
|
261
|
+
}
|
|
262
|
+
get path() {
|
|
263
|
+
return this.parent ? [...this.parent.path, this.id] : [];
|
|
264
|
+
}
|
|
265
|
+
get elementRef() {
|
|
266
266
|
throw `Element Ref is no longer supported since introducing virtual scroll\n
|
|
267
|
-
You may use a template to obtain a reference to the element`;
|
|
268
|
-
}
|
|
269
|
-
get originalNode() { return this._originalNode; }
|
|
270
|
-
;
|
|
271
|
-
constructor(data, parent, treeModel, index) {
|
|
272
|
-
this.data = data;
|
|
273
|
-
this.parent = parent;
|
|
274
|
-
this.treeModel = treeModel;
|
|
275
|
-
this.position = 0;
|
|
276
|
-
this.allowDrop = (element, $event) => {
|
|
277
|
-
return this.options.allowDrop(element, { parent: this, index: 0 }, $event);
|
|
278
|
-
};
|
|
279
|
-
this.allowDragoverStyling = () => {
|
|
280
|
-
return this.options.allowDragoverStyling;
|
|
281
|
-
};
|
|
282
|
-
if (this.id === undefined || this.id === null) {
|
|
283
|
-
this.id = uuid();
|
|
284
|
-
} // Make sure there's a unique id without overriding existing ids to work with immutable data structures
|
|
285
|
-
this.index = index;
|
|
286
|
-
if (this.getField('children')) {
|
|
287
|
-
this._initChildren();
|
|
288
|
-
}
|
|
289
|
-
this.autoLoadChildren();
|
|
290
|
-
}
|
|
291
|
-
// helper get functions:
|
|
292
|
-
get hasChildren() {
|
|
293
|
-
return !!(this.getField('hasChildren') || (this.children && this.children.length > 0));
|
|
294
|
-
}
|
|
295
|
-
get isCollapsed() { return !this.isExpanded; }
|
|
296
|
-
get isLeaf() { return !this.hasChildren; }
|
|
297
|
-
get isRoot() { return this.parent.data.virtual; }
|
|
298
|
-
get realParent() { return this.isRoot ? null : this.parent; }
|
|
299
|
-
// proxy functions:
|
|
300
|
-
get options() { return this.treeModel.options; }
|
|
301
|
-
fireEvent(event) { this.treeModel.fireEvent(event); }
|
|
302
|
-
// field accessors:
|
|
303
|
-
get displayField() {
|
|
304
|
-
return this.getField('display');
|
|
305
|
-
}
|
|
306
|
-
get id() {
|
|
307
|
-
return this.getField('id');
|
|
308
|
-
}
|
|
309
|
-
set id(value) {
|
|
310
|
-
this.setField('id', value);
|
|
311
|
-
}
|
|
312
|
-
getField(key) {
|
|
313
|
-
return this.data[this.options[`${key}Field`]];
|
|
314
|
-
}
|
|
315
|
-
setField(key, value) {
|
|
316
|
-
this.data[this.options[`${key}Field`]] = value;
|
|
317
|
-
}
|
|
318
|
-
// traversing:
|
|
319
|
-
_findAdjacentSibling(steps, skipHidden = false) {
|
|
320
|
-
const siblings = this._getParentsChildren(skipHidden);
|
|
321
|
-
const index = siblings.indexOf(this);
|
|
322
|
-
return siblings.length > index + steps ? siblings[index + steps] : null;
|
|
323
|
-
}
|
|
324
|
-
findNextSibling(skipHidden = false) {
|
|
325
|
-
return this._findAdjacentSibling(+1, skipHidden);
|
|
326
|
-
}
|
|
327
|
-
findPreviousSibling(skipHidden = false) {
|
|
328
|
-
return this._findAdjacentSibling(-1, skipHidden);
|
|
329
|
-
}
|
|
330
|
-
getVisibleChildren() {
|
|
331
|
-
return this.visibleChildren;
|
|
332
|
-
}
|
|
333
|
-
get visibleChildren() {
|
|
334
|
-
return (this.children || []).filter((node) => !node.isHidden);
|
|
335
|
-
}
|
|
336
|
-
getFirstChild(skipHidden = false) {
|
|
337
|
-
let children = skipHidden ? this.visibleChildren : this.children;
|
|
338
|
-
return children != null && children.length ? children[0] : null;
|
|
339
|
-
}
|
|
340
|
-
getLastChild(skipHidden = false) {
|
|
341
|
-
let children = skipHidden ? this.visibleChildren : this.children;
|
|
342
|
-
return children != null && children.length ? children[children.length - 1] : null;
|
|
343
|
-
}
|
|
344
|
-
findNextNode(goInside = true, skipHidden = false) {
|
|
345
|
-
return goInside && this.isExpanded && this.getFirstChild(skipHidden) ||
|
|
346
|
-
this.findNextSibling(skipHidden) ||
|
|
347
|
-
this.parent && this.parent.findNextNode(false, skipHidden);
|
|
348
|
-
}
|
|
349
|
-
findPreviousNode(skipHidden = false) {
|
|
350
|
-
let previousSibling = this.findPreviousSibling(skipHidden);
|
|
351
|
-
if (!previousSibling) {
|
|
352
|
-
return this.realParent;
|
|
353
|
-
}
|
|
354
|
-
return previousSibling._getLastOpenDescendant(skipHidden);
|
|
355
|
-
}
|
|
356
|
-
_getLastOpenDescendant(skipHidden = false) {
|
|
357
|
-
const lastChild = this.getLastChild(skipHidden);
|
|
358
|
-
return (this.isCollapsed || !lastChild)
|
|
359
|
-
? this
|
|
360
|
-
: lastChild._getLastOpenDescendant(skipHidden);
|
|
361
|
-
}
|
|
362
|
-
_getParentsChildren(skipHidden = false) {
|
|
363
|
-
const children = this.parent &&
|
|
364
|
-
(skipHidden ? this.parent.getVisibleChildren() : this.parent.children);
|
|
365
|
-
return children || [];
|
|
366
|
-
}
|
|
367
|
-
getIndexInParent(skipHidden = false) {
|
|
368
|
-
return this._getParentsChildren(skipHidden).indexOf(this);
|
|
369
|
-
}
|
|
370
|
-
isDescendantOf(node) {
|
|
371
|
-
if (this === node)
|
|
372
|
-
return true;
|
|
373
|
-
else
|
|
374
|
-
return this.parent && this.parent.isDescendantOf(node);
|
|
375
|
-
}
|
|
376
|
-
getNodePadding() {
|
|
377
|
-
return this.options.levelPadding * (this.level - 1) + 'px';
|
|
378
|
-
}
|
|
379
|
-
getClass() {
|
|
380
|
-
return [this.options.nodeClass(this), `tree-node-level-${this.level}`].join(' ');
|
|
381
|
-
}
|
|
382
|
-
onDrop($event) {
|
|
383
|
-
this.mouseAction('drop', $event.event, {
|
|
384
|
-
from: $event.element,
|
|
385
|
-
to: { parent: this, index: 0, dropOnNode: true }
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
allowDrag() {
|
|
389
|
-
return this.options.allowDrag(this);
|
|
390
|
-
}
|
|
391
|
-
// helper methods:
|
|
392
|
-
loadNodeChildren() {
|
|
393
|
-
if (!this.options.getChildren) {
|
|
394
|
-
return Promise.resolve(); // Not getChildren method - for using redux
|
|
395
|
-
}
|
|
396
|
-
return Promise.resolve(this.options.getChildren(this))
|
|
397
|
-
.then((children) => {
|
|
398
|
-
if (children) {
|
|
399
|
-
this.setField('children', children);
|
|
400
|
-
this._initChildren();
|
|
401
|
-
if (this.options.useTriState && this.treeModel.isSelected(this)) {
|
|
402
|
-
this.setIsSelected(true);
|
|
403
|
-
}
|
|
404
|
-
this.children.forEach((child) => {
|
|
405
|
-
if (child.getField('isExpanded') && child.hasChildren) {
|
|
406
|
-
child.expand();
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
}).then(() => {
|
|
411
|
-
this.fireEvent({
|
|
412
|
-
eventName: TREE_EVENTS.loadNodeChildren,
|
|
413
|
-
node: this
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
expand() {
|
|
418
|
-
if (!this.isExpanded) {
|
|
419
|
-
this.toggleExpanded();
|
|
420
|
-
}
|
|
421
|
-
return this;
|
|
422
|
-
}
|
|
423
|
-
collapse() {
|
|
424
|
-
if (this.isExpanded) {
|
|
425
|
-
this.toggleExpanded();
|
|
426
|
-
}
|
|
427
|
-
return this;
|
|
428
|
-
}
|
|
429
|
-
doForAll(fn) {
|
|
430
|
-
Promise.resolve(fn(this)).then(() => {
|
|
431
|
-
if (this.children) {
|
|
432
|
-
this.children.forEach((child) => child.doForAll(fn));
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
expandAll() {
|
|
437
|
-
this.doForAll((node) => node.expand());
|
|
438
|
-
}
|
|
439
|
-
collapseAll() {
|
|
440
|
-
this.doForAll((node) => node.collapse());
|
|
441
|
-
}
|
|
442
|
-
ensureVisible() {
|
|
443
|
-
if (this.realParent) {
|
|
444
|
-
this.realParent.expand();
|
|
445
|
-
this.realParent.ensureVisible();
|
|
446
|
-
}
|
|
447
|
-
return this;
|
|
448
|
-
}
|
|
449
|
-
toggleExpanded() {
|
|
450
|
-
this.setIsExpanded(!this.isExpanded);
|
|
451
|
-
return this;
|
|
452
|
-
}
|
|
453
|
-
setIsExpanded(value) {
|
|
454
|
-
if (this.hasChildren) {
|
|
455
|
-
this.treeModel.setExpandedNode(this, value);
|
|
456
|
-
}
|
|
457
|
-
return this;
|
|
458
|
-
}
|
|
459
|
-
;
|
|
460
|
-
autoLoadChildren() {
|
|
461
|
-
this.handler =
|
|
462
|
-
reaction(() => this.isExpanded, (isExpanded) => {
|
|
463
|
-
if (!this.children && this.hasChildren && isExpanded) {
|
|
464
|
-
this.loadNodeChildren();
|
|
465
|
-
}
|
|
466
|
-
}, { fireImmediately: true });
|
|
467
|
-
}
|
|
468
|
-
dispose() {
|
|
469
|
-
if (this.children) {
|
|
470
|
-
this.children.forEach((child) => child.dispose());
|
|
471
|
-
}
|
|
472
|
-
if (this.handler) {
|
|
473
|
-
this.handler();
|
|
474
|
-
}
|
|
475
|
-
this.parent = null;
|
|
476
|
-
this.children = null;
|
|
477
|
-
}
|
|
478
|
-
setIsActive(value, multi = false) {
|
|
479
|
-
this.treeModel.setActiveNode(this, value, multi);
|
|
480
|
-
if (value) {
|
|
481
|
-
this.focus(this.options.scrollOnActivate);
|
|
482
|
-
}
|
|
483
|
-
return this;
|
|
484
|
-
}
|
|
485
|
-
isSelectable() {
|
|
486
|
-
return this.isLeaf || !this.children || !this.options.useTriState;
|
|
487
|
-
}
|
|
488
|
-
setIsSelected(value) {
|
|
489
|
-
if (this.isSelectable()) {
|
|
490
|
-
this.treeModel.setSelectedNode(this, value);
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
this.visibleChildren.forEach((child) => child.setIsSelected(value));
|
|
494
|
-
}
|
|
495
|
-
return this;
|
|
496
|
-
}
|
|
497
|
-
toggleSelected() {
|
|
498
|
-
this.setIsSelected(!this.isSelected);
|
|
499
|
-
return this;
|
|
500
|
-
}
|
|
501
|
-
toggleActivated(multi = false) {
|
|
502
|
-
this.setIsActive(!this.isActive, multi);
|
|
503
|
-
return this;
|
|
504
|
-
}
|
|
505
|
-
setActiveAndVisible(multi = false) {
|
|
506
|
-
this.setIsActive(true, multi)
|
|
507
|
-
.ensureVisible();
|
|
508
|
-
setTimeout(this.scrollIntoView.bind(this));
|
|
509
|
-
return this;
|
|
510
|
-
}
|
|
511
|
-
scrollIntoView(force = false) {
|
|
512
|
-
this.treeModel.virtualScroll.scrollIntoView(this, force);
|
|
513
|
-
}
|
|
514
|
-
focus(scroll = true) {
|
|
515
|
-
let previousNode = this.treeModel.getFocusedNode();
|
|
516
|
-
this.treeModel.setFocusedNode(this);
|
|
517
|
-
if (scroll) {
|
|
518
|
-
this.scrollIntoView();
|
|
519
|
-
}
|
|
520
|
-
if (previousNode) {
|
|
521
|
-
this.fireEvent({ eventName: TREE_EVENTS.blur, node: previousNode });
|
|
522
|
-
}
|
|
523
|
-
this.fireEvent({ eventName: TREE_EVENTS.focus, node: this });
|
|
524
|
-
return this;
|
|
525
|
-
}
|
|
526
|
-
blur() {
|
|
527
|
-
let previousNode = this.treeModel.getFocusedNode();
|
|
528
|
-
this.treeModel.setFocusedNode(null);
|
|
529
|
-
if (previousNode) {
|
|
530
|
-
this.fireEvent({ eventName: TREE_EVENTS.blur, node: this });
|
|
531
|
-
}
|
|
532
|
-
return this;
|
|
533
|
-
}
|
|
534
|
-
setIsHidden(value) {
|
|
535
|
-
this.treeModel.setIsHidden(this, value);
|
|
536
|
-
}
|
|
537
|
-
hide() {
|
|
538
|
-
this.setIsHidden(true);
|
|
539
|
-
}
|
|
540
|
-
show() {
|
|
541
|
-
this.setIsHidden(false);
|
|
542
|
-
}
|
|
543
|
-
mouseAction(actionName, $event, data = null) {
|
|
544
|
-
this.treeModel.setFocus(true);
|
|
545
|
-
const actionMapping = this.options.actionMapping.mouse;
|
|
546
|
-
const mouseAction = actionMapping[actionName];
|
|
547
|
-
if (mouseAction) {
|
|
548
|
-
mouseAction(this.treeModel, this, $event, data);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
getSelfHeight() {
|
|
552
|
-
return this.options.nodeHeight(this);
|
|
553
|
-
}
|
|
554
|
-
_initChildren() {
|
|
555
|
-
this.children = this.getField('children')
|
|
556
|
-
.map((c, index) => new TreeNode(c, this, this.treeModel, index));
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
__decorate$3([
|
|
560
|
-
computed$1
|
|
561
|
-
], TreeNode.prototype, "isHidden", null);
|
|
562
|
-
__decorate$3([
|
|
563
|
-
computed$1
|
|
564
|
-
], TreeNode.prototype, "isExpanded", null);
|
|
565
|
-
__decorate$3([
|
|
566
|
-
computed$1
|
|
567
|
-
], TreeNode.prototype, "isActive", null);
|
|
568
|
-
__decorate$3([
|
|
569
|
-
computed$1
|
|
570
|
-
], TreeNode.prototype, "isFocused", null);
|
|
571
|
-
__decorate$3([
|
|
572
|
-
computed$1
|
|
573
|
-
], TreeNode.prototype, "isSelected", null);
|
|
574
|
-
__decorate$3([
|
|
575
|
-
computed$1
|
|
576
|
-
], TreeNode.prototype, "isAllSelected", null);
|
|
577
|
-
__decorate$3([
|
|
578
|
-
computed$1
|
|
579
|
-
], TreeNode.prototype, "isPartiallySelected", null);
|
|
580
|
-
__decorate$3([
|
|
581
|
-
observable$1
|
|
582
|
-
], TreeNode.prototype, "children", void 0);
|
|
583
|
-
__decorate$3([
|
|
584
|
-
observable$1
|
|
585
|
-
], TreeNode.prototype, "index", void 0);
|
|
586
|
-
__decorate$3([
|
|
587
|
-
observable$1
|
|
588
|
-
], TreeNode.prototype, "position", void 0);
|
|
589
|
-
__decorate$3([
|
|
590
|
-
observable$1
|
|
591
|
-
], TreeNode.prototype, "height", void 0);
|
|
592
|
-
__decorate$3([
|
|
593
|
-
computed$1
|
|
594
|
-
], TreeNode.prototype, "level", null);
|
|
595
|
-
__decorate$3([
|
|
596
|
-
computed$1
|
|
597
|
-
], TreeNode.prototype, "path", null);
|
|
598
|
-
__decorate$3([
|
|
599
|
-
computed$1
|
|
600
|
-
], TreeNode.prototype, "visibleChildren", null);
|
|
601
|
-
__decorate$3([
|
|
602
|
-
action$1
|
|
603
|
-
], TreeNode.prototype, "setIsSelected", null);
|
|
604
|
-
__decorate$3([
|
|
605
|
-
action$1
|
|
606
|
-
], TreeNode.prototype, "_initChildren", null);
|
|
607
|
-
function uuid() {
|
|
608
|
-
return Math.floor(Math.random() * 10000000000000);
|
|
267
|
+
You may use a template to obtain a reference to the element`;
|
|
268
|
+
}
|
|
269
|
+
get originalNode() { return this._originalNode; }
|
|
270
|
+
;
|
|
271
|
+
constructor(data, parent, treeModel, index) {
|
|
272
|
+
this.data = data;
|
|
273
|
+
this.parent = parent;
|
|
274
|
+
this.treeModel = treeModel;
|
|
275
|
+
this.position = 0;
|
|
276
|
+
this.allowDrop = (element, $event) => {
|
|
277
|
+
return this.options.allowDrop(element, { parent: this, index: 0 }, $event);
|
|
278
|
+
};
|
|
279
|
+
this.allowDragoverStyling = () => {
|
|
280
|
+
return this.options.allowDragoverStyling;
|
|
281
|
+
};
|
|
282
|
+
if (this.id === undefined || this.id === null) {
|
|
283
|
+
this.id = uuid();
|
|
284
|
+
} // Make sure there's a unique id without overriding existing ids to work with immutable data structures
|
|
285
|
+
this.index = index;
|
|
286
|
+
if (this.getField('children')) {
|
|
287
|
+
this._initChildren();
|
|
288
|
+
}
|
|
289
|
+
this.autoLoadChildren();
|
|
290
|
+
}
|
|
291
|
+
// helper get functions:
|
|
292
|
+
get hasChildren() {
|
|
293
|
+
return !!(this.getField('hasChildren') || (this.children && this.children.length > 0));
|
|
294
|
+
}
|
|
295
|
+
get isCollapsed() { return !this.isExpanded; }
|
|
296
|
+
get isLeaf() { return !this.hasChildren; }
|
|
297
|
+
get isRoot() { return this.parent.data.virtual; }
|
|
298
|
+
get realParent() { return this.isRoot ? null : this.parent; }
|
|
299
|
+
// proxy functions:
|
|
300
|
+
get options() { return this.treeModel.options; }
|
|
301
|
+
fireEvent(event) { this.treeModel.fireEvent(event); }
|
|
302
|
+
// field accessors:
|
|
303
|
+
get displayField() {
|
|
304
|
+
return this.getField('display');
|
|
305
|
+
}
|
|
306
|
+
get id() {
|
|
307
|
+
return this.getField('id');
|
|
308
|
+
}
|
|
309
|
+
set id(value) {
|
|
310
|
+
this.setField('id', value);
|
|
311
|
+
}
|
|
312
|
+
getField(key) {
|
|
313
|
+
return this.data[this.options[`${key}Field`]];
|
|
314
|
+
}
|
|
315
|
+
setField(key, value) {
|
|
316
|
+
this.data[this.options[`${key}Field`]] = value;
|
|
317
|
+
}
|
|
318
|
+
// traversing:
|
|
319
|
+
_findAdjacentSibling(steps, skipHidden = false) {
|
|
320
|
+
const siblings = this._getParentsChildren(skipHidden);
|
|
321
|
+
const index = siblings.indexOf(this);
|
|
322
|
+
return siblings.length > index + steps ? siblings[index + steps] : null;
|
|
323
|
+
}
|
|
324
|
+
findNextSibling(skipHidden = false) {
|
|
325
|
+
return this._findAdjacentSibling(+1, skipHidden);
|
|
326
|
+
}
|
|
327
|
+
findPreviousSibling(skipHidden = false) {
|
|
328
|
+
return this._findAdjacentSibling(-1, skipHidden);
|
|
329
|
+
}
|
|
330
|
+
getVisibleChildren() {
|
|
331
|
+
return this.visibleChildren;
|
|
332
|
+
}
|
|
333
|
+
get visibleChildren() {
|
|
334
|
+
return (this.children || []).filter((node) => !node.isHidden);
|
|
335
|
+
}
|
|
336
|
+
getFirstChild(skipHidden = false) {
|
|
337
|
+
let children = skipHidden ? this.visibleChildren : this.children;
|
|
338
|
+
return children != null && children.length ? children[0] : null;
|
|
339
|
+
}
|
|
340
|
+
getLastChild(skipHidden = false) {
|
|
341
|
+
let children = skipHidden ? this.visibleChildren : this.children;
|
|
342
|
+
return children != null && children.length ? children[children.length - 1] : null;
|
|
343
|
+
}
|
|
344
|
+
findNextNode(goInside = true, skipHidden = false) {
|
|
345
|
+
return goInside && this.isExpanded && this.getFirstChild(skipHidden) ||
|
|
346
|
+
this.findNextSibling(skipHidden) ||
|
|
347
|
+
this.parent && this.parent.findNextNode(false, skipHidden);
|
|
348
|
+
}
|
|
349
|
+
findPreviousNode(skipHidden = false) {
|
|
350
|
+
let previousSibling = this.findPreviousSibling(skipHidden);
|
|
351
|
+
if (!previousSibling) {
|
|
352
|
+
return this.realParent;
|
|
353
|
+
}
|
|
354
|
+
return previousSibling._getLastOpenDescendant(skipHidden);
|
|
355
|
+
}
|
|
356
|
+
_getLastOpenDescendant(skipHidden = false) {
|
|
357
|
+
const lastChild = this.getLastChild(skipHidden);
|
|
358
|
+
return (this.isCollapsed || !lastChild)
|
|
359
|
+
? this
|
|
360
|
+
: lastChild._getLastOpenDescendant(skipHidden);
|
|
361
|
+
}
|
|
362
|
+
_getParentsChildren(skipHidden = false) {
|
|
363
|
+
const children = this.parent &&
|
|
364
|
+
(skipHidden ? this.parent.getVisibleChildren() : this.parent.children);
|
|
365
|
+
return children || [];
|
|
366
|
+
}
|
|
367
|
+
getIndexInParent(skipHidden = false) {
|
|
368
|
+
return this._getParentsChildren(skipHidden).indexOf(this);
|
|
369
|
+
}
|
|
370
|
+
isDescendantOf(node) {
|
|
371
|
+
if (this === node)
|
|
372
|
+
return true;
|
|
373
|
+
else
|
|
374
|
+
return this.parent && this.parent.isDescendantOf(node);
|
|
375
|
+
}
|
|
376
|
+
getNodePadding() {
|
|
377
|
+
return this.options.levelPadding * (this.level - 1) + 'px';
|
|
378
|
+
}
|
|
379
|
+
getClass() {
|
|
380
|
+
return [this.options.nodeClass(this), `tree-node-level-${this.level}`].join(' ');
|
|
381
|
+
}
|
|
382
|
+
onDrop($event) {
|
|
383
|
+
this.mouseAction('drop', $event.event, {
|
|
384
|
+
from: $event.element,
|
|
385
|
+
to: { parent: this, index: 0, dropOnNode: true }
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
allowDrag() {
|
|
389
|
+
return this.options.allowDrag(this);
|
|
390
|
+
}
|
|
391
|
+
// helper methods:
|
|
392
|
+
loadNodeChildren() {
|
|
393
|
+
if (!this.options.getChildren) {
|
|
394
|
+
return Promise.resolve(); // Not getChildren method - for using redux
|
|
395
|
+
}
|
|
396
|
+
return Promise.resolve(this.options.getChildren(this))
|
|
397
|
+
.then((children) => {
|
|
398
|
+
if (children) {
|
|
399
|
+
this.setField('children', children);
|
|
400
|
+
this._initChildren();
|
|
401
|
+
if (this.options.useTriState && this.treeModel.isSelected(this)) {
|
|
402
|
+
this.setIsSelected(true);
|
|
403
|
+
}
|
|
404
|
+
this.children.forEach((child) => {
|
|
405
|
+
if (child.getField('isExpanded') && child.hasChildren) {
|
|
406
|
+
child.expand();
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}).then(() => {
|
|
411
|
+
this.fireEvent({
|
|
412
|
+
eventName: TREE_EVENTS.loadNodeChildren,
|
|
413
|
+
node: this
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
expand() {
|
|
418
|
+
if (!this.isExpanded) {
|
|
419
|
+
this.toggleExpanded();
|
|
420
|
+
}
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
collapse() {
|
|
424
|
+
if (this.isExpanded) {
|
|
425
|
+
this.toggleExpanded();
|
|
426
|
+
}
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
doForAll(fn) {
|
|
430
|
+
Promise.resolve(fn(this)).then(() => {
|
|
431
|
+
if (this.children) {
|
|
432
|
+
this.children.forEach((child) => child.doForAll(fn));
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
expandAll() {
|
|
437
|
+
this.doForAll((node) => node.expand());
|
|
438
|
+
}
|
|
439
|
+
collapseAll() {
|
|
440
|
+
this.doForAll((node) => node.collapse());
|
|
441
|
+
}
|
|
442
|
+
ensureVisible() {
|
|
443
|
+
if (this.realParent) {
|
|
444
|
+
this.realParent.expand();
|
|
445
|
+
this.realParent.ensureVisible();
|
|
446
|
+
}
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
toggleExpanded() {
|
|
450
|
+
this.setIsExpanded(!this.isExpanded);
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
setIsExpanded(value) {
|
|
454
|
+
if (this.hasChildren) {
|
|
455
|
+
this.treeModel.setExpandedNode(this, value);
|
|
456
|
+
}
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
;
|
|
460
|
+
autoLoadChildren() {
|
|
461
|
+
this.handler =
|
|
462
|
+
reaction(() => this.isExpanded, (isExpanded) => {
|
|
463
|
+
if (!this.children && this.hasChildren && isExpanded) {
|
|
464
|
+
this.loadNodeChildren();
|
|
465
|
+
}
|
|
466
|
+
}, { fireImmediately: true });
|
|
467
|
+
}
|
|
468
|
+
dispose() {
|
|
469
|
+
if (this.children) {
|
|
470
|
+
this.children.forEach((child) => child.dispose());
|
|
471
|
+
}
|
|
472
|
+
if (this.handler) {
|
|
473
|
+
this.handler();
|
|
474
|
+
}
|
|
475
|
+
this.parent = null;
|
|
476
|
+
this.children = null;
|
|
477
|
+
}
|
|
478
|
+
setIsActive(value, multi = false) {
|
|
479
|
+
this.treeModel.setActiveNode(this, value, multi);
|
|
480
|
+
if (value) {
|
|
481
|
+
this.focus(this.options.scrollOnActivate);
|
|
482
|
+
}
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
isSelectable() {
|
|
486
|
+
return this.isLeaf || !this.children || !this.options.useTriState;
|
|
487
|
+
}
|
|
488
|
+
setIsSelected(value) {
|
|
489
|
+
if (this.isSelectable()) {
|
|
490
|
+
this.treeModel.setSelectedNode(this, value);
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
this.visibleChildren.forEach((child) => child.setIsSelected(value));
|
|
494
|
+
}
|
|
495
|
+
return this;
|
|
496
|
+
}
|
|
497
|
+
toggleSelected() {
|
|
498
|
+
this.setIsSelected(!this.isSelected);
|
|
499
|
+
return this;
|
|
500
|
+
}
|
|
501
|
+
toggleActivated(multi = false) {
|
|
502
|
+
this.setIsActive(!this.isActive, multi);
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
setActiveAndVisible(multi = false) {
|
|
506
|
+
this.setIsActive(true, multi)
|
|
507
|
+
.ensureVisible();
|
|
508
|
+
setTimeout(this.scrollIntoView.bind(this));
|
|
509
|
+
return this;
|
|
510
|
+
}
|
|
511
|
+
scrollIntoView(force = false) {
|
|
512
|
+
this.treeModel.virtualScroll.scrollIntoView(this, force);
|
|
513
|
+
}
|
|
514
|
+
focus(scroll = true) {
|
|
515
|
+
let previousNode = this.treeModel.getFocusedNode();
|
|
516
|
+
this.treeModel.setFocusedNode(this);
|
|
517
|
+
if (scroll) {
|
|
518
|
+
this.scrollIntoView();
|
|
519
|
+
}
|
|
520
|
+
if (previousNode) {
|
|
521
|
+
this.fireEvent({ eventName: TREE_EVENTS.blur, node: previousNode });
|
|
522
|
+
}
|
|
523
|
+
this.fireEvent({ eventName: TREE_EVENTS.focus, node: this });
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
blur() {
|
|
527
|
+
let previousNode = this.treeModel.getFocusedNode();
|
|
528
|
+
this.treeModel.setFocusedNode(null);
|
|
529
|
+
if (previousNode) {
|
|
530
|
+
this.fireEvent({ eventName: TREE_EVENTS.blur, node: this });
|
|
531
|
+
}
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
setIsHidden(value) {
|
|
535
|
+
this.treeModel.setIsHidden(this, value);
|
|
536
|
+
}
|
|
537
|
+
hide() {
|
|
538
|
+
this.setIsHidden(true);
|
|
539
|
+
}
|
|
540
|
+
show() {
|
|
541
|
+
this.setIsHidden(false);
|
|
542
|
+
}
|
|
543
|
+
mouseAction(actionName, $event, data = null) {
|
|
544
|
+
this.treeModel.setFocus(true);
|
|
545
|
+
const actionMapping = this.options.actionMapping.mouse;
|
|
546
|
+
const mouseAction = actionMapping[actionName];
|
|
547
|
+
if (mouseAction) {
|
|
548
|
+
mouseAction(this.treeModel, this, $event, data);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
getSelfHeight() {
|
|
552
|
+
return this.options.nodeHeight(this);
|
|
553
|
+
}
|
|
554
|
+
_initChildren() {
|
|
555
|
+
this.children = this.getField('children')
|
|
556
|
+
.map((c, index) => new TreeNode(c, this, this.treeModel, index));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
__decorate$3([
|
|
560
|
+
computed$1
|
|
561
|
+
], TreeNode.prototype, "isHidden", null);
|
|
562
|
+
__decorate$3([
|
|
563
|
+
computed$1
|
|
564
|
+
], TreeNode.prototype, "isExpanded", null);
|
|
565
|
+
__decorate$3([
|
|
566
|
+
computed$1
|
|
567
|
+
], TreeNode.prototype, "isActive", null);
|
|
568
|
+
__decorate$3([
|
|
569
|
+
computed$1
|
|
570
|
+
], TreeNode.prototype, "isFocused", null);
|
|
571
|
+
__decorate$3([
|
|
572
|
+
computed$1
|
|
573
|
+
], TreeNode.prototype, "isSelected", null);
|
|
574
|
+
__decorate$3([
|
|
575
|
+
computed$1
|
|
576
|
+
], TreeNode.prototype, "isAllSelected", null);
|
|
577
|
+
__decorate$3([
|
|
578
|
+
computed$1
|
|
579
|
+
], TreeNode.prototype, "isPartiallySelected", null);
|
|
580
|
+
__decorate$3([
|
|
581
|
+
observable$1
|
|
582
|
+
], TreeNode.prototype, "children", void 0);
|
|
583
|
+
__decorate$3([
|
|
584
|
+
observable$1
|
|
585
|
+
], TreeNode.prototype, "index", void 0);
|
|
586
|
+
__decorate$3([
|
|
587
|
+
observable$1
|
|
588
|
+
], TreeNode.prototype, "position", void 0);
|
|
589
|
+
__decorate$3([
|
|
590
|
+
observable$1
|
|
591
|
+
], TreeNode.prototype, "height", void 0);
|
|
592
|
+
__decorate$3([
|
|
593
|
+
computed$1
|
|
594
|
+
], TreeNode.prototype, "level", null);
|
|
595
|
+
__decorate$3([
|
|
596
|
+
computed$1
|
|
597
|
+
], TreeNode.prototype, "path", null);
|
|
598
|
+
__decorate$3([
|
|
599
|
+
computed$1
|
|
600
|
+
], TreeNode.prototype, "visibleChildren", null);
|
|
601
|
+
__decorate$3([
|
|
602
|
+
action$1
|
|
603
|
+
], TreeNode.prototype, "setIsSelected", null);
|
|
604
|
+
__decorate$3([
|
|
605
|
+
action$1
|
|
606
|
+
], TreeNode.prototype, "_initChildren", null);
|
|
607
|
+
function uuid() {
|
|
608
|
+
return Math.floor(Math.random() * 10000000000000);
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
612
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
613
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
614
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
615
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
616
|
-
};
|
|
617
|
-
class TreeModel {
|
|
618
|
-
constructor() {
|
|
619
|
-
this.options = new TreeOptions();
|
|
620
|
-
this.eventNames = Object.keys(TREE_EVENTS);
|
|
621
|
-
this.expandedNodeIds = {};
|
|
622
|
-
this.selectedLeafNodeIds = {};
|
|
623
|
-
this.activeNodeIds = {};
|
|
624
|
-
this.hiddenNodeIds = {};
|
|
625
|
-
this.focusedNodeId = null;
|
|
626
|
-
this.firstUpdate = true;
|
|
627
|
-
this.subscriptions = [];
|
|
628
|
-
}
|
|
629
|
-
static { this.focusedTree = null; }
|
|
630
|
-
// events
|
|
631
|
-
fireEvent(event) {
|
|
632
|
-
event.treeModel = this;
|
|
633
|
-
this.events[event.eventName].emit(event);
|
|
634
|
-
this.events.event.emit(event);
|
|
635
|
-
}
|
|
636
|
-
subscribe(eventName, fn) {
|
|
637
|
-
const subscription = this.events[eventName].subscribe(fn);
|
|
638
|
-
this.subscriptions.push(subscription);
|
|
639
|
-
}
|
|
640
|
-
// getters
|
|
641
|
-
getFocusedNode() {
|
|
642
|
-
return this.focusedNode;
|
|
643
|
-
}
|
|
644
|
-
getActiveNode() {
|
|
645
|
-
return this.activeNodes[0];
|
|
646
|
-
}
|
|
647
|
-
getActiveNodes() {
|
|
648
|
-
return this.activeNodes;
|
|
649
|
-
}
|
|
650
|
-
getVisibleRoots() {
|
|
651
|
-
return this.virtualRoot.visibleChildren;
|
|
652
|
-
}
|
|
653
|
-
getFirstRoot(skipHidden = false) {
|
|
654
|
-
const root = skipHidden ? this.getVisibleRoots() : this.roots;
|
|
655
|
-
return root != null && root.length ? root[0] : null;
|
|
656
|
-
}
|
|
657
|
-
getLastRoot(skipHidden = false) {
|
|
658
|
-
const root = skipHidden ? this.getVisibleRoots() : this.roots;
|
|
659
|
-
return root != null && root.length ? root[root.length - 1] : null;
|
|
660
|
-
}
|
|
661
|
-
get isFocused() {
|
|
662
|
-
return TreeModel.focusedTree === this;
|
|
663
|
-
}
|
|
664
|
-
isNodeFocused(node) {
|
|
665
|
-
return this.focusedNode === node;
|
|
666
|
-
}
|
|
667
|
-
isEmptyTree() {
|
|
668
|
-
return this.roots && this.roots.length === 0;
|
|
669
|
-
}
|
|
670
|
-
get focusedNode() {
|
|
671
|
-
return this.focusedNodeId ? this.getNodeById(this.focusedNodeId) : null;
|
|
672
|
-
}
|
|
673
|
-
get expandedNodes() {
|
|
674
|
-
const nodes = Object.keys(this.expandedNodeIds)
|
|
675
|
-
.filter((id) => this.expandedNodeIds[id])
|
|
676
|
-
.map((id) => this.getNodeById(id));
|
|
677
|
-
return nodes.filter(Boolean);
|
|
678
|
-
}
|
|
679
|
-
get activeNodes() {
|
|
680
|
-
const nodes = Object.keys(this.activeNodeIds)
|
|
681
|
-
.filter((id) => this.activeNodeIds[id])
|
|
682
|
-
.map((id) => this.getNodeById(id));
|
|
683
|
-
return nodes.filter(Boolean);
|
|
684
|
-
}
|
|
685
|
-
get hiddenNodes() {
|
|
686
|
-
const nodes = Object.keys(this.hiddenNodeIds)
|
|
687
|
-
.filter((id) => this.hiddenNodeIds[id])
|
|
688
|
-
.map((id) => this.getNodeById(id));
|
|
689
|
-
return nodes.filter(Boolean);
|
|
690
|
-
}
|
|
691
|
-
get selectedLeafNodes() {
|
|
692
|
-
const nodes = Object.keys(this.selectedLeafNodeIds)
|
|
693
|
-
.filter((id) => this.selectedLeafNodeIds[id])
|
|
694
|
-
.map((id) => this.getNodeById(id));
|
|
695
|
-
return nodes.filter(Boolean);
|
|
696
|
-
}
|
|
697
|
-
// locating nodes
|
|
698
|
-
getNodeByPath(path, startNode = null) {
|
|
699
|
-
if (!path)
|
|
700
|
-
return null;
|
|
701
|
-
startNode = startNode || this.virtualRoot;
|
|
702
|
-
if (path.length === 0)
|
|
703
|
-
return startNode;
|
|
704
|
-
if (!startNode.children)
|
|
705
|
-
return null;
|
|
706
|
-
const childId = path.shift();
|
|
707
|
-
const childNode = startNode.children.find(c => c.id === childId);
|
|
708
|
-
if (!childNode)
|
|
709
|
-
return null;
|
|
710
|
-
return this.getNodeByPath(path, childNode);
|
|
711
|
-
}
|
|
712
|
-
getNodeById(id) {
|
|
713
|
-
const idStr = id.toString();
|
|
714
|
-
return this.getNodeBy((node) => node.id.toString() === idStr);
|
|
715
|
-
}
|
|
716
|
-
getNodeBy(predicate, startNode = null) {
|
|
717
|
-
startNode = startNode || this.virtualRoot;
|
|
718
|
-
if (!startNode.children)
|
|
719
|
-
return null;
|
|
720
|
-
const found = startNode.children.find(predicate);
|
|
721
|
-
if (found) { // found in children
|
|
722
|
-
return found;
|
|
723
|
-
}
|
|
724
|
-
else { // look in children's children
|
|
725
|
-
for (let child of startNode.children) {
|
|
726
|
-
const foundInChildren = this.getNodeBy(predicate, child);
|
|
727
|
-
if (foundInChildren)
|
|
728
|
-
return foundInChildren;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
isExpanded(node) {
|
|
733
|
-
return this.expandedNodeIds[node.id];
|
|
734
|
-
}
|
|
735
|
-
isHidden(node) {
|
|
736
|
-
return this.hiddenNodeIds[node.id];
|
|
737
|
-
}
|
|
738
|
-
isActive(node) {
|
|
739
|
-
return this.activeNodeIds[node.id];
|
|
740
|
-
}
|
|
741
|
-
isSelected(node) {
|
|
742
|
-
return this.selectedLeafNodeIds[node.id];
|
|
743
|
-
}
|
|
744
|
-
ngOnDestroy() {
|
|
745
|
-
this.dispose();
|
|
746
|
-
this.unsubscribeAll();
|
|
747
|
-
}
|
|
748
|
-
dispose() {
|
|
749
|
-
// Dispose reactions of the replaced nodes
|
|
750
|
-
if (this.virtualRoot) {
|
|
751
|
-
this.virtualRoot.dispose();
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
unsubscribeAll() {
|
|
755
|
-
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
756
|
-
this.subscriptions = [];
|
|
757
|
-
}
|
|
758
|
-
// actions
|
|
759
|
-
setData({ nodes, options = null, events = null }) {
|
|
760
|
-
if (options) {
|
|
761
|
-
this.options = new TreeOptions(options);
|
|
762
|
-
}
|
|
763
|
-
if (events) {
|
|
764
|
-
this.events = events;
|
|
765
|
-
}
|
|
766
|
-
if (nodes) {
|
|
767
|
-
this.nodes = nodes;
|
|
768
|
-
}
|
|
769
|
-
this.update();
|
|
770
|
-
}
|
|
771
|
-
update() {
|
|
772
|
-
// Rebuild tree:
|
|
773
|
-
let virtualRootConfig = {
|
|
774
|
-
id: this.options.rootId,
|
|
775
|
-
virtual: true,
|
|
776
|
-
[this.options.childrenField]: this.nodes
|
|
777
|
-
};
|
|
778
|
-
this.dispose();
|
|
779
|
-
this.virtualRoot = new TreeNode(virtualRootConfig, null, this, 0);
|
|
780
|
-
this.roots = this.virtualRoot.children;
|
|
781
|
-
// Fire event:
|
|
782
|
-
if (this.firstUpdate) {
|
|
783
|
-
if (this.roots) {
|
|
784
|
-
this.firstUpdate = false;
|
|
785
|
-
this._calculateExpandedNodes();
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
else {
|
|
789
|
-
this.fireEvent({ eventName: TREE_EVENTS.updateData });
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
setFocusedNode(node) {
|
|
793
|
-
this.focusedNodeId = node ? node.id : null;
|
|
794
|
-
}
|
|
795
|
-
setFocus(value) {
|
|
796
|
-
TreeModel.focusedTree = value ? this : null;
|
|
797
|
-
}
|
|
798
|
-
doForAll(fn) {
|
|
799
|
-
this.roots.forEach((root) => root.doForAll(fn));
|
|
800
|
-
}
|
|
801
|
-
focusNextNode() {
|
|
802
|
-
let previousNode = this.getFocusedNode();
|
|
803
|
-
let nextNode = previousNode ? previousNode.findNextNode(true, true) : this.getFirstRoot(true);
|
|
804
|
-
if (nextNode)
|
|
805
|
-
nextNode.focus();
|
|
806
|
-
}
|
|
807
|
-
focusPreviousNode() {
|
|
808
|
-
let previousNode = this.getFocusedNode();
|
|
809
|
-
let nextNode = previousNode ? previousNode.findPreviousNode(true) : this.getLastRoot(true);
|
|
810
|
-
if (nextNode)
|
|
811
|
-
nextNode.focus();
|
|
812
|
-
}
|
|
813
|
-
focusDrillDown() {
|
|
814
|
-
let previousNode = this.getFocusedNode();
|
|
815
|
-
if (previousNode && previousNode.isCollapsed && previousNode.hasChildren) {
|
|
816
|
-
previousNode.toggleExpanded();
|
|
817
|
-
}
|
|
818
|
-
else {
|
|
819
|
-
let nextNode = previousNode ? previousNode.getFirstChild(true) : this.getFirstRoot(true);
|
|
820
|
-
if (nextNode)
|
|
821
|
-
nextNode.focus();
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
focusDrillUp() {
|
|
825
|
-
let previousNode = this.getFocusedNode();
|
|
826
|
-
if (!previousNode)
|
|
827
|
-
return;
|
|
828
|
-
if (previousNode.isExpanded) {
|
|
829
|
-
previousNode.toggleExpanded();
|
|
830
|
-
}
|
|
831
|
-
else {
|
|
832
|
-
let nextNode = previousNode.realParent;
|
|
833
|
-
if (nextNode)
|
|
834
|
-
nextNode.focus();
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
setActiveNode(node, value, multi = false) {
|
|
838
|
-
if (multi) {
|
|
839
|
-
this._setActiveNodeMulti(node, value);
|
|
840
|
-
}
|
|
841
|
-
else {
|
|
842
|
-
this._setActiveNodeSingle(node, value);
|
|
843
|
-
}
|
|
844
|
-
if (value) {
|
|
845
|
-
node.focus(this.options.scrollOnActivate);
|
|
846
|
-
this.fireEvent({ eventName: TREE_EVENTS.activate, node });
|
|
847
|
-
this.fireEvent({ eventName: TREE_EVENTS.nodeActivate, node }); // For IE11
|
|
848
|
-
}
|
|
849
|
-
else {
|
|
850
|
-
this.fireEvent({ eventName: TREE_EVENTS.deactivate, node });
|
|
851
|
-
this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node }); // For IE11
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
setSelectedNode(node, value) {
|
|
855
|
-
this.selectedLeafNodeIds = Object.assign({}, this.selectedLeafNodeIds, { [node.id]: value });
|
|
856
|
-
if (value) {
|
|
857
|
-
node.focus();
|
|
858
|
-
this.fireEvent({ eventName: TREE_EVENTS.select, node });
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
this.fireEvent({ eventName: TREE_EVENTS.deselect, node });
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
setExpandedNode(node, value) {
|
|
865
|
-
this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [node.id]: value });
|
|
866
|
-
this.fireEvent({ eventName: TREE_EVENTS.toggleExpanded, node, isExpanded: value });
|
|
867
|
-
}
|
|
868
|
-
expandAll() {
|
|
869
|
-
this.roots.forEach((root) => root.expandAll());
|
|
870
|
-
}
|
|
871
|
-
collapseAll() {
|
|
872
|
-
this.roots.forEach((root) => root.collapseAll());
|
|
873
|
-
}
|
|
874
|
-
setIsHidden(node, value) {
|
|
875
|
-
this.hiddenNodeIds = Object.assign({}, this.hiddenNodeIds, { [node.id]: value });
|
|
876
|
-
}
|
|
877
|
-
setHiddenNodeIds(nodeIds) {
|
|
878
|
-
this.hiddenNodeIds = nodeIds.reduce((hiddenNodeIds, id) => Object.assign(hiddenNodeIds, {
|
|
879
|
-
[id]: true
|
|
880
|
-
}), {});
|
|
881
|
-
}
|
|
882
|
-
performKeyAction(node, $event) {
|
|
883
|
-
const keyAction = this.options.actionMapping.keys[$event.keyCode];
|
|
884
|
-
if (keyAction) {
|
|
885
|
-
$event.preventDefault();
|
|
886
|
-
keyAction(this, node, $event);
|
|
887
|
-
return true;
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
filterNodes(filter, autoShow = true) {
|
|
894
|
-
let filterFn;
|
|
895
|
-
if (!filter) {
|
|
896
|
-
return this.clearFilter();
|
|
897
|
-
}
|
|
898
|
-
// support function and string filter
|
|
899
|
-
if (filter && typeof filter.valueOf() === 'string') {
|
|
900
|
-
filterFn = (node) => node.displayField.toLowerCase().indexOf(filter.toLowerCase()) !== -1;
|
|
901
|
-
}
|
|
902
|
-
else if (filter && typeof filter === 'function') {
|
|
903
|
-
filterFn = filter;
|
|
904
|
-
}
|
|
905
|
-
else {
|
|
906
|
-
console.error('Don\'t know what to do with filter', filter);
|
|
907
|
-
console.error('Should be either a string or function');
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const ids = {};
|
|
911
|
-
this.roots.forEach((node) => this._filterNode(ids, node, filterFn, autoShow));
|
|
912
|
-
this.hiddenNodeIds = ids;
|
|
913
|
-
this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
|
|
914
|
-
}
|
|
915
|
-
clearFilter() {
|
|
916
|
-
this.hiddenNodeIds = {};
|
|
917
|
-
this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
|
|
918
|
-
}
|
|
919
|
-
moveNode(node, to) {
|
|
920
|
-
const fromIndex = node.getIndexInParent();
|
|
921
|
-
const fromParent = node.parent;
|
|
922
|
-
if (!this.canMoveNode(node, to, fromIndex))
|
|
923
|
-
return;
|
|
924
|
-
const fromChildren = fromParent.getField('children');
|
|
925
|
-
// If node doesn't have children - create children array
|
|
926
|
-
if (!to.parent.getField('children')) {
|
|
927
|
-
to.parent.setField('children', []);
|
|
928
|
-
}
|
|
929
|
-
const toChildren = to.parent.getField('children');
|
|
930
|
-
const originalNode = fromChildren.splice(fromIndex, 1)[0];
|
|
931
|
-
// Compensate for index if already removed from parent:
|
|
932
|
-
let toIndex = (fromParent === to.parent && to.index > fromIndex) ? to.index - 1 : to.index;
|
|
933
|
-
toChildren.splice(toIndex, 0, originalNode);
|
|
934
|
-
fromParent.treeModel.update();
|
|
935
|
-
if (to.parent.treeModel !== fromParent.treeModel) {
|
|
936
|
-
to.parent.treeModel.update();
|
|
937
|
-
}
|
|
938
|
-
this.fireEvent({
|
|
939
|
-
eventName: TREE_EVENTS.moveNode,
|
|
940
|
-
node: originalNode,
|
|
941
|
-
to: { parent: to.parent.data, index: toIndex },
|
|
942
|
-
from: { parent: fromParent.data, index: fromIndex }
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
copyNode(node, to) {
|
|
946
|
-
const fromIndex = node.getIndexInParent();
|
|
947
|
-
if (!this.canMoveNode(node, to, fromIndex))
|
|
948
|
-
return;
|
|
949
|
-
// If node doesn't have children - create children array
|
|
950
|
-
if (!to.parent.getField('children')) {
|
|
951
|
-
to.parent.setField('children', []);
|
|
952
|
-
}
|
|
953
|
-
const toChildren = to.parent.getField('children');
|
|
954
|
-
const nodeCopy = this.options.getNodeClone(node);
|
|
955
|
-
toChildren.splice(to.index, 0, nodeCopy);
|
|
956
|
-
node.treeModel.update();
|
|
957
|
-
if (to.parent.treeModel !== node.treeModel) {
|
|
958
|
-
to.parent.treeModel.update();
|
|
959
|
-
}
|
|
960
|
-
this.fireEvent({ eventName: TREE_EVENTS.copyNode, node: nodeCopy, to: { parent: to.parent.data, index: to.index } });
|
|
961
|
-
}
|
|
962
|
-
getState() {
|
|
963
|
-
return {
|
|
964
|
-
expandedNodeIds: this.expandedNodeIds,
|
|
965
|
-
selectedLeafNodeIds: this.selectedLeafNodeIds,
|
|
966
|
-
activeNodeIds: this.activeNodeIds,
|
|
967
|
-
hiddenNodeIds: this.hiddenNodeIds,
|
|
968
|
-
focusedNodeId: this.focusedNodeId
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
setState(state) {
|
|
972
|
-
if (!state)
|
|
973
|
-
return;
|
|
974
|
-
Object.assign(this, {
|
|
975
|
-
expandedNodeIds: state.expandedNodeIds || {},
|
|
976
|
-
selectedLeafNodeIds: state.selectedLeafNodeIds || {},
|
|
977
|
-
activeNodeIds: state.activeNodeIds || {},
|
|
978
|
-
hiddenNodeIds: state.hiddenNodeIds || {},
|
|
979
|
-
focusedNodeId: state.focusedNodeId
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
subscribeToState(fn) {
|
|
983
|
-
autorun(() => fn(this.getState()));
|
|
984
|
-
}
|
|
985
|
-
canMoveNode(node, to, fromIndex = undefined) {
|
|
986
|
-
const fromNodeIndex = fromIndex || node.getIndexInParent();
|
|
987
|
-
// same node:
|
|
988
|
-
if (node.parent === to.parent && fromIndex === to.index) {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
return !to.parent.isDescendantOf(node);
|
|
992
|
-
}
|
|
993
|
-
calculateExpandedNodes() {
|
|
994
|
-
this._calculateExpandedNodes();
|
|
995
|
-
}
|
|
996
|
-
// private methods
|
|
997
|
-
_filterNode(ids, node, filterFn, autoShow) {
|
|
998
|
-
// if node passes function then it's visible
|
|
999
|
-
let isVisible = filterFn(node);
|
|
1000
|
-
if (node.children) {
|
|
1001
|
-
// if one of node's children passes filter then this node is also visible
|
|
1002
|
-
node.children.forEach((child) => {
|
|
1003
|
-
if (this._filterNode(ids, child, filterFn, autoShow)) {
|
|
1004
|
-
isVisible = true;
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
// mark node as hidden
|
|
1009
|
-
if (!isVisible) {
|
|
1010
|
-
ids[node.id] = true;
|
|
1011
|
-
}
|
|
1012
|
-
// auto expand parents to make sure the filtered nodes are visible
|
|
1013
|
-
if (autoShow && isVisible) {
|
|
1014
|
-
node.ensureVisible();
|
|
1015
|
-
}
|
|
1016
|
-
return isVisible;
|
|
1017
|
-
}
|
|
1018
|
-
_calculateExpandedNodes(startNode = null) {
|
|
1019
|
-
startNode = startNode || this.virtualRoot;
|
|
1020
|
-
if (startNode.data[this.options.isExpandedField]) {
|
|
1021
|
-
this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [startNode.id]: true });
|
|
1022
|
-
}
|
|
1023
|
-
if (startNode.children) {
|
|
1024
|
-
startNode.children.forEach((child) => this._calculateExpandedNodes(child));
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
_setActiveNodeSingle(node, value) {
|
|
1028
|
-
// Deactivate all other nodes:
|
|
1029
|
-
this.activeNodes
|
|
1030
|
-
.filter((activeNode) => activeNode !== node)
|
|
1031
|
-
.forEach((activeNode) => {
|
|
1032
|
-
this.fireEvent({ eventName: TREE_EVENTS.deactivate, node: activeNode });
|
|
1033
|
-
this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node: activeNode }); // For IE11
|
|
1034
|
-
});
|
|
1035
|
-
if (value) {
|
|
1036
|
-
this.activeNodeIds = { [node.id]: true };
|
|
1037
|
-
}
|
|
1038
|
-
else {
|
|
1039
|
-
this.activeNodeIds = {};
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
_setActiveNodeMulti(node, value) {
|
|
1043
|
-
this.activeNodeIds = Object.assign({}, this.activeNodeIds, { [node.id]: value });
|
|
1044
|
-
}
|
|
1045
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1046
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1047
|
-
}
|
|
1048
|
-
__decorate$2([
|
|
1049
|
-
observable$1
|
|
1050
|
-
], TreeModel.prototype, "roots", void 0);
|
|
1051
|
-
__decorate$2([
|
|
1052
|
-
observable$1
|
|
1053
|
-
], TreeModel.prototype, "expandedNodeIds", void 0);
|
|
1054
|
-
__decorate$2([
|
|
1055
|
-
observable$1
|
|
1056
|
-
], TreeModel.prototype, "selectedLeafNodeIds", void 0);
|
|
1057
|
-
__decorate$2([
|
|
1058
|
-
observable$1
|
|
1059
|
-
], TreeModel.prototype, "activeNodeIds", void 0);
|
|
1060
|
-
__decorate$2([
|
|
1061
|
-
observable$1
|
|
1062
|
-
], TreeModel.prototype, "hiddenNodeIds", void 0);
|
|
1063
|
-
__decorate$2([
|
|
1064
|
-
observable$1
|
|
1065
|
-
], TreeModel.prototype, "focusedNodeId", void 0);
|
|
1066
|
-
__decorate$2([
|
|
1067
|
-
observable$1
|
|
1068
|
-
], TreeModel.prototype, "virtualRoot", void 0);
|
|
1069
|
-
__decorate$2([
|
|
1070
|
-
computed$1
|
|
1071
|
-
], TreeModel.prototype, "focusedNode", null);
|
|
1072
|
-
__decorate$2([
|
|
1073
|
-
computed$1
|
|
1074
|
-
], TreeModel.prototype, "expandedNodes", null);
|
|
1075
|
-
__decorate$2([
|
|
1076
|
-
computed$1
|
|
1077
|
-
], TreeModel.prototype, "activeNodes", null);
|
|
1078
|
-
__decorate$2([
|
|
1079
|
-
computed$1
|
|
1080
|
-
], TreeModel.prototype, "hiddenNodes", null);
|
|
1081
|
-
__decorate$2([
|
|
1082
|
-
computed$1
|
|
1083
|
-
], TreeModel.prototype, "selectedLeafNodes", null);
|
|
1084
|
-
__decorate$2([
|
|
1085
|
-
action$1
|
|
1086
|
-
], TreeModel.prototype, "setData", null);
|
|
1087
|
-
__decorate$2([
|
|
1088
|
-
action$1
|
|
1089
|
-
], TreeModel.prototype, "update", null);
|
|
1090
|
-
__decorate$2([
|
|
1091
|
-
action$1
|
|
1092
|
-
], TreeModel.prototype, "setFocusedNode", null);
|
|
1093
|
-
__decorate$2([
|
|
1094
|
-
action$1
|
|
1095
|
-
], TreeModel.prototype, "setFocus", null);
|
|
1096
|
-
__decorate$2([
|
|
1097
|
-
action$1
|
|
1098
|
-
], TreeModel.prototype, "doForAll", null);
|
|
1099
|
-
__decorate$2([
|
|
1100
|
-
action$1
|
|
1101
|
-
], TreeModel.prototype, "focusNextNode", null);
|
|
1102
|
-
__decorate$2([
|
|
1103
|
-
action$1
|
|
1104
|
-
], TreeModel.prototype, "focusPreviousNode", null);
|
|
1105
|
-
__decorate$2([
|
|
1106
|
-
action$1
|
|
1107
|
-
], TreeModel.prototype, "focusDrillDown", null);
|
|
1108
|
-
__decorate$2([
|
|
1109
|
-
action$1
|
|
1110
|
-
], TreeModel.prototype, "focusDrillUp", null);
|
|
1111
|
-
__decorate$2([
|
|
1112
|
-
action$1
|
|
1113
|
-
], TreeModel.prototype, "setActiveNode", null);
|
|
1114
|
-
__decorate$2([
|
|
1115
|
-
action$1
|
|
1116
|
-
], TreeModel.prototype, "setSelectedNode", null);
|
|
1117
|
-
__decorate$2([
|
|
1118
|
-
action$1
|
|
1119
|
-
], TreeModel.prototype, "setExpandedNode", null);
|
|
1120
|
-
__decorate$2([
|
|
1121
|
-
action$1
|
|
1122
|
-
], TreeModel.prototype, "expandAll", null);
|
|
1123
|
-
__decorate$2([
|
|
1124
|
-
action$1
|
|
1125
|
-
], TreeModel.prototype, "collapseAll", null);
|
|
1126
|
-
__decorate$2([
|
|
1127
|
-
action$1
|
|
1128
|
-
], TreeModel.prototype, "setIsHidden", null);
|
|
1129
|
-
__decorate$2([
|
|
1130
|
-
action$1
|
|
1131
|
-
], TreeModel.prototype, "setHiddenNodeIds", null);
|
|
1132
|
-
__decorate$2([
|
|
1133
|
-
action$1
|
|
1134
|
-
], TreeModel.prototype, "filterNodes", null);
|
|
1135
|
-
__decorate$2([
|
|
1136
|
-
action$1
|
|
1137
|
-
], TreeModel.prototype, "clearFilter", null);
|
|
1138
|
-
__decorate$2([
|
|
1139
|
-
action$1
|
|
1140
|
-
], TreeModel.prototype, "moveNode", null);
|
|
1141
|
-
__decorate$2([
|
|
1142
|
-
action$1
|
|
1143
|
-
], TreeModel.prototype, "copyNode", null);
|
|
1144
|
-
__decorate$2([
|
|
1145
|
-
action$1
|
|
1146
|
-
], TreeModel.prototype, "setState", null);
|
|
1147
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1148
|
-
type: Injectable
|
|
611
|
+
var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
612
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
613
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
614
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
615
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
616
|
+
};
|
|
617
|
+
class TreeModel {
|
|
618
|
+
constructor() {
|
|
619
|
+
this.options = new TreeOptions();
|
|
620
|
+
this.eventNames = Object.keys(TREE_EVENTS);
|
|
621
|
+
this.expandedNodeIds = {};
|
|
622
|
+
this.selectedLeafNodeIds = {};
|
|
623
|
+
this.activeNodeIds = {};
|
|
624
|
+
this.hiddenNodeIds = {};
|
|
625
|
+
this.focusedNodeId = null;
|
|
626
|
+
this.firstUpdate = true;
|
|
627
|
+
this.subscriptions = [];
|
|
628
|
+
}
|
|
629
|
+
static { this.focusedTree = null; }
|
|
630
|
+
// events
|
|
631
|
+
fireEvent(event) {
|
|
632
|
+
event.treeModel = this;
|
|
633
|
+
this.events[event.eventName].emit(event);
|
|
634
|
+
this.events.event.emit(event);
|
|
635
|
+
}
|
|
636
|
+
subscribe(eventName, fn) {
|
|
637
|
+
const subscription = this.events[eventName].subscribe(fn);
|
|
638
|
+
this.subscriptions.push(subscription);
|
|
639
|
+
}
|
|
640
|
+
// getters
|
|
641
|
+
getFocusedNode() {
|
|
642
|
+
return this.focusedNode;
|
|
643
|
+
}
|
|
644
|
+
getActiveNode() {
|
|
645
|
+
return this.activeNodes[0];
|
|
646
|
+
}
|
|
647
|
+
getActiveNodes() {
|
|
648
|
+
return this.activeNodes;
|
|
649
|
+
}
|
|
650
|
+
getVisibleRoots() {
|
|
651
|
+
return this.virtualRoot.visibleChildren;
|
|
652
|
+
}
|
|
653
|
+
getFirstRoot(skipHidden = false) {
|
|
654
|
+
const root = skipHidden ? this.getVisibleRoots() : this.roots;
|
|
655
|
+
return root != null && root.length ? root[0] : null;
|
|
656
|
+
}
|
|
657
|
+
getLastRoot(skipHidden = false) {
|
|
658
|
+
const root = skipHidden ? this.getVisibleRoots() : this.roots;
|
|
659
|
+
return root != null && root.length ? root[root.length - 1] : null;
|
|
660
|
+
}
|
|
661
|
+
get isFocused() {
|
|
662
|
+
return TreeModel.focusedTree === this;
|
|
663
|
+
}
|
|
664
|
+
isNodeFocused(node) {
|
|
665
|
+
return this.focusedNode === node;
|
|
666
|
+
}
|
|
667
|
+
isEmptyTree() {
|
|
668
|
+
return this.roots && this.roots.length === 0;
|
|
669
|
+
}
|
|
670
|
+
get focusedNode() {
|
|
671
|
+
return this.focusedNodeId ? this.getNodeById(this.focusedNodeId) : null;
|
|
672
|
+
}
|
|
673
|
+
get expandedNodes() {
|
|
674
|
+
const nodes = Object.keys(this.expandedNodeIds)
|
|
675
|
+
.filter((id) => this.expandedNodeIds[id])
|
|
676
|
+
.map((id) => this.getNodeById(id));
|
|
677
|
+
return nodes.filter(Boolean);
|
|
678
|
+
}
|
|
679
|
+
get activeNodes() {
|
|
680
|
+
const nodes = Object.keys(this.activeNodeIds)
|
|
681
|
+
.filter((id) => this.activeNodeIds[id])
|
|
682
|
+
.map((id) => this.getNodeById(id));
|
|
683
|
+
return nodes.filter(Boolean);
|
|
684
|
+
}
|
|
685
|
+
get hiddenNodes() {
|
|
686
|
+
const nodes = Object.keys(this.hiddenNodeIds)
|
|
687
|
+
.filter((id) => this.hiddenNodeIds[id])
|
|
688
|
+
.map((id) => this.getNodeById(id));
|
|
689
|
+
return nodes.filter(Boolean);
|
|
690
|
+
}
|
|
691
|
+
get selectedLeafNodes() {
|
|
692
|
+
const nodes = Object.keys(this.selectedLeafNodeIds)
|
|
693
|
+
.filter((id) => this.selectedLeafNodeIds[id])
|
|
694
|
+
.map((id) => this.getNodeById(id));
|
|
695
|
+
return nodes.filter(Boolean);
|
|
696
|
+
}
|
|
697
|
+
// locating nodes
|
|
698
|
+
getNodeByPath(path, startNode = null) {
|
|
699
|
+
if (!path)
|
|
700
|
+
return null;
|
|
701
|
+
startNode = startNode || this.virtualRoot;
|
|
702
|
+
if (path.length === 0)
|
|
703
|
+
return startNode;
|
|
704
|
+
if (!startNode.children)
|
|
705
|
+
return null;
|
|
706
|
+
const childId = path.shift();
|
|
707
|
+
const childNode = startNode.children.find(c => c.id === childId);
|
|
708
|
+
if (!childNode)
|
|
709
|
+
return null;
|
|
710
|
+
return this.getNodeByPath(path, childNode);
|
|
711
|
+
}
|
|
712
|
+
getNodeById(id) {
|
|
713
|
+
const idStr = id.toString();
|
|
714
|
+
return this.getNodeBy((node) => node.id.toString() === idStr);
|
|
715
|
+
}
|
|
716
|
+
getNodeBy(predicate, startNode = null) {
|
|
717
|
+
startNode = startNode || this.virtualRoot;
|
|
718
|
+
if (!startNode.children)
|
|
719
|
+
return null;
|
|
720
|
+
const found = startNode.children.find(predicate);
|
|
721
|
+
if (found) { // found in children
|
|
722
|
+
return found;
|
|
723
|
+
}
|
|
724
|
+
else { // look in children's children
|
|
725
|
+
for (let child of startNode.children) {
|
|
726
|
+
const foundInChildren = this.getNodeBy(predicate, child);
|
|
727
|
+
if (foundInChildren)
|
|
728
|
+
return foundInChildren;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
isExpanded(node) {
|
|
733
|
+
return this.expandedNodeIds[node.id];
|
|
734
|
+
}
|
|
735
|
+
isHidden(node) {
|
|
736
|
+
return this.hiddenNodeIds[node.id];
|
|
737
|
+
}
|
|
738
|
+
isActive(node) {
|
|
739
|
+
return this.activeNodeIds[node.id];
|
|
740
|
+
}
|
|
741
|
+
isSelected(node) {
|
|
742
|
+
return this.selectedLeafNodeIds[node.id];
|
|
743
|
+
}
|
|
744
|
+
ngOnDestroy() {
|
|
745
|
+
this.dispose();
|
|
746
|
+
this.unsubscribeAll();
|
|
747
|
+
}
|
|
748
|
+
dispose() {
|
|
749
|
+
// Dispose reactions of the replaced nodes
|
|
750
|
+
if (this.virtualRoot) {
|
|
751
|
+
this.virtualRoot.dispose();
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
unsubscribeAll() {
|
|
755
|
+
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
756
|
+
this.subscriptions = [];
|
|
757
|
+
}
|
|
758
|
+
// actions
|
|
759
|
+
setData({ nodes, options = null, events = null }) {
|
|
760
|
+
if (options) {
|
|
761
|
+
this.options = new TreeOptions(options);
|
|
762
|
+
}
|
|
763
|
+
if (events) {
|
|
764
|
+
this.events = events;
|
|
765
|
+
}
|
|
766
|
+
if (nodes) {
|
|
767
|
+
this.nodes = nodes;
|
|
768
|
+
}
|
|
769
|
+
this.update();
|
|
770
|
+
}
|
|
771
|
+
update() {
|
|
772
|
+
// Rebuild tree:
|
|
773
|
+
let virtualRootConfig = {
|
|
774
|
+
id: this.options.rootId,
|
|
775
|
+
virtual: true,
|
|
776
|
+
[this.options.childrenField]: this.nodes
|
|
777
|
+
};
|
|
778
|
+
this.dispose();
|
|
779
|
+
this.virtualRoot = new TreeNode(virtualRootConfig, null, this, 0);
|
|
780
|
+
this.roots = this.virtualRoot.children;
|
|
781
|
+
// Fire event:
|
|
782
|
+
if (this.firstUpdate) {
|
|
783
|
+
if (this.roots) {
|
|
784
|
+
this.firstUpdate = false;
|
|
785
|
+
this._calculateExpandedNodes();
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
this.fireEvent({ eventName: TREE_EVENTS.updateData });
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
setFocusedNode(node) {
|
|
793
|
+
this.focusedNodeId = node ? node.id : null;
|
|
794
|
+
}
|
|
795
|
+
setFocus(value) {
|
|
796
|
+
TreeModel.focusedTree = value ? this : null;
|
|
797
|
+
}
|
|
798
|
+
doForAll(fn) {
|
|
799
|
+
this.roots.forEach((root) => root.doForAll(fn));
|
|
800
|
+
}
|
|
801
|
+
focusNextNode() {
|
|
802
|
+
let previousNode = this.getFocusedNode();
|
|
803
|
+
let nextNode = previousNode ? previousNode.findNextNode(true, true) : this.getFirstRoot(true);
|
|
804
|
+
if (nextNode)
|
|
805
|
+
nextNode.focus();
|
|
806
|
+
}
|
|
807
|
+
focusPreviousNode() {
|
|
808
|
+
let previousNode = this.getFocusedNode();
|
|
809
|
+
let nextNode = previousNode ? previousNode.findPreviousNode(true) : this.getLastRoot(true);
|
|
810
|
+
if (nextNode)
|
|
811
|
+
nextNode.focus();
|
|
812
|
+
}
|
|
813
|
+
focusDrillDown() {
|
|
814
|
+
let previousNode = this.getFocusedNode();
|
|
815
|
+
if (previousNode && previousNode.isCollapsed && previousNode.hasChildren) {
|
|
816
|
+
previousNode.toggleExpanded();
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
let nextNode = previousNode ? previousNode.getFirstChild(true) : this.getFirstRoot(true);
|
|
820
|
+
if (nextNode)
|
|
821
|
+
nextNode.focus();
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
focusDrillUp() {
|
|
825
|
+
let previousNode = this.getFocusedNode();
|
|
826
|
+
if (!previousNode)
|
|
827
|
+
return;
|
|
828
|
+
if (previousNode.isExpanded) {
|
|
829
|
+
previousNode.toggleExpanded();
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
let nextNode = previousNode.realParent;
|
|
833
|
+
if (nextNode)
|
|
834
|
+
nextNode.focus();
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
setActiveNode(node, value, multi = false) {
|
|
838
|
+
if (multi) {
|
|
839
|
+
this._setActiveNodeMulti(node, value);
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
this._setActiveNodeSingle(node, value);
|
|
843
|
+
}
|
|
844
|
+
if (value) {
|
|
845
|
+
node.focus(this.options.scrollOnActivate);
|
|
846
|
+
this.fireEvent({ eventName: TREE_EVENTS.activate, node });
|
|
847
|
+
this.fireEvent({ eventName: TREE_EVENTS.nodeActivate, node }); // For IE11
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
this.fireEvent({ eventName: TREE_EVENTS.deactivate, node });
|
|
851
|
+
this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node }); // For IE11
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
setSelectedNode(node, value) {
|
|
855
|
+
this.selectedLeafNodeIds = Object.assign({}, this.selectedLeafNodeIds, { [node.id]: value });
|
|
856
|
+
if (value) {
|
|
857
|
+
node.focus();
|
|
858
|
+
this.fireEvent({ eventName: TREE_EVENTS.select, node });
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
this.fireEvent({ eventName: TREE_EVENTS.deselect, node });
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
setExpandedNode(node, value) {
|
|
865
|
+
this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [node.id]: value });
|
|
866
|
+
this.fireEvent({ eventName: TREE_EVENTS.toggleExpanded, node, isExpanded: value });
|
|
867
|
+
}
|
|
868
|
+
expandAll() {
|
|
869
|
+
this.roots.forEach((root) => root.expandAll());
|
|
870
|
+
}
|
|
871
|
+
collapseAll() {
|
|
872
|
+
this.roots.forEach((root) => root.collapseAll());
|
|
873
|
+
}
|
|
874
|
+
setIsHidden(node, value) {
|
|
875
|
+
this.hiddenNodeIds = Object.assign({}, this.hiddenNodeIds, { [node.id]: value });
|
|
876
|
+
}
|
|
877
|
+
setHiddenNodeIds(nodeIds) {
|
|
878
|
+
this.hiddenNodeIds = nodeIds.reduce((hiddenNodeIds, id) => Object.assign(hiddenNodeIds, {
|
|
879
|
+
[id]: true
|
|
880
|
+
}), {});
|
|
881
|
+
}
|
|
882
|
+
performKeyAction(node, $event) {
|
|
883
|
+
const keyAction = this.options.actionMapping.keys[$event.keyCode];
|
|
884
|
+
if (keyAction) {
|
|
885
|
+
$event.preventDefault();
|
|
886
|
+
keyAction(this, node, $event);
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
filterNodes(filter, autoShow = true) {
|
|
894
|
+
let filterFn;
|
|
895
|
+
if (!filter) {
|
|
896
|
+
return this.clearFilter();
|
|
897
|
+
}
|
|
898
|
+
// support function and string filter
|
|
899
|
+
if (filter && typeof filter.valueOf() === 'string') {
|
|
900
|
+
filterFn = (node) => node.displayField.toLowerCase().indexOf(filter.toLowerCase()) !== -1;
|
|
901
|
+
}
|
|
902
|
+
else if (filter && typeof filter === 'function') {
|
|
903
|
+
filterFn = filter;
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
console.error('Don\'t know what to do with filter', filter);
|
|
907
|
+
console.error('Should be either a string or function');
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const ids = {};
|
|
911
|
+
this.roots.forEach((node) => this._filterNode(ids, node, filterFn, autoShow));
|
|
912
|
+
this.hiddenNodeIds = ids;
|
|
913
|
+
this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
|
|
914
|
+
}
|
|
915
|
+
clearFilter() {
|
|
916
|
+
this.hiddenNodeIds = {};
|
|
917
|
+
this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
|
|
918
|
+
}
|
|
919
|
+
moveNode(node, to) {
|
|
920
|
+
const fromIndex = node.getIndexInParent();
|
|
921
|
+
const fromParent = node.parent;
|
|
922
|
+
if (!this.canMoveNode(node, to, fromIndex))
|
|
923
|
+
return;
|
|
924
|
+
const fromChildren = fromParent.getField('children');
|
|
925
|
+
// If node doesn't have children - create children array
|
|
926
|
+
if (!to.parent.getField('children')) {
|
|
927
|
+
to.parent.setField('children', []);
|
|
928
|
+
}
|
|
929
|
+
const toChildren = to.parent.getField('children');
|
|
930
|
+
const originalNode = fromChildren.splice(fromIndex, 1)[0];
|
|
931
|
+
// Compensate for index if already removed from parent:
|
|
932
|
+
let toIndex = (fromParent === to.parent && to.index > fromIndex) ? to.index - 1 : to.index;
|
|
933
|
+
toChildren.splice(toIndex, 0, originalNode);
|
|
934
|
+
fromParent.treeModel.update();
|
|
935
|
+
if (to.parent.treeModel !== fromParent.treeModel) {
|
|
936
|
+
to.parent.treeModel.update();
|
|
937
|
+
}
|
|
938
|
+
this.fireEvent({
|
|
939
|
+
eventName: TREE_EVENTS.moveNode,
|
|
940
|
+
node: originalNode,
|
|
941
|
+
to: { parent: to.parent.data, index: toIndex },
|
|
942
|
+
from: { parent: fromParent.data, index: fromIndex }
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
copyNode(node, to) {
|
|
946
|
+
const fromIndex = node.getIndexInParent();
|
|
947
|
+
if (!this.canMoveNode(node, to, fromIndex))
|
|
948
|
+
return;
|
|
949
|
+
// If node doesn't have children - create children array
|
|
950
|
+
if (!to.parent.getField('children')) {
|
|
951
|
+
to.parent.setField('children', []);
|
|
952
|
+
}
|
|
953
|
+
const toChildren = to.parent.getField('children');
|
|
954
|
+
const nodeCopy = this.options.getNodeClone(node);
|
|
955
|
+
toChildren.splice(to.index, 0, nodeCopy);
|
|
956
|
+
node.treeModel.update();
|
|
957
|
+
if (to.parent.treeModel !== node.treeModel) {
|
|
958
|
+
to.parent.treeModel.update();
|
|
959
|
+
}
|
|
960
|
+
this.fireEvent({ eventName: TREE_EVENTS.copyNode, node: nodeCopy, to: { parent: to.parent.data, index: to.index } });
|
|
961
|
+
}
|
|
962
|
+
getState() {
|
|
963
|
+
return {
|
|
964
|
+
expandedNodeIds: this.expandedNodeIds,
|
|
965
|
+
selectedLeafNodeIds: this.selectedLeafNodeIds,
|
|
966
|
+
activeNodeIds: this.activeNodeIds,
|
|
967
|
+
hiddenNodeIds: this.hiddenNodeIds,
|
|
968
|
+
focusedNodeId: this.focusedNodeId
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
setState(state) {
|
|
972
|
+
if (!state)
|
|
973
|
+
return;
|
|
974
|
+
Object.assign(this, {
|
|
975
|
+
expandedNodeIds: state.expandedNodeIds || {},
|
|
976
|
+
selectedLeafNodeIds: state.selectedLeafNodeIds || {},
|
|
977
|
+
activeNodeIds: state.activeNodeIds || {},
|
|
978
|
+
hiddenNodeIds: state.hiddenNodeIds || {},
|
|
979
|
+
focusedNodeId: state.focusedNodeId
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
subscribeToState(fn) {
|
|
983
|
+
autorun(() => fn(this.getState()));
|
|
984
|
+
}
|
|
985
|
+
canMoveNode(node, to, fromIndex = undefined) {
|
|
986
|
+
const fromNodeIndex = fromIndex || node.getIndexInParent();
|
|
987
|
+
// same node:
|
|
988
|
+
if (node.parent === to.parent && fromIndex === to.index) {
|
|
989
|
+
return false;
|
|
990
|
+
}
|
|
991
|
+
return !to.parent.isDescendantOf(node);
|
|
992
|
+
}
|
|
993
|
+
calculateExpandedNodes() {
|
|
994
|
+
this._calculateExpandedNodes();
|
|
995
|
+
}
|
|
996
|
+
// private methods
|
|
997
|
+
_filterNode(ids, node, filterFn, autoShow) {
|
|
998
|
+
// if node passes function then it's visible
|
|
999
|
+
let isVisible = filterFn(node);
|
|
1000
|
+
if (node.children) {
|
|
1001
|
+
// if one of node's children passes filter then this node is also visible
|
|
1002
|
+
node.children.forEach((child) => {
|
|
1003
|
+
if (this._filterNode(ids, child, filterFn, autoShow)) {
|
|
1004
|
+
isVisible = true;
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
// mark node as hidden
|
|
1009
|
+
if (!isVisible) {
|
|
1010
|
+
ids[node.id] = true;
|
|
1011
|
+
}
|
|
1012
|
+
// auto expand parents to make sure the filtered nodes are visible
|
|
1013
|
+
if (autoShow && isVisible) {
|
|
1014
|
+
node.ensureVisible();
|
|
1015
|
+
}
|
|
1016
|
+
return isVisible;
|
|
1017
|
+
}
|
|
1018
|
+
_calculateExpandedNodes(startNode = null) {
|
|
1019
|
+
startNode = startNode || this.virtualRoot;
|
|
1020
|
+
if (startNode.data[this.options.isExpandedField]) {
|
|
1021
|
+
this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [startNode.id]: true });
|
|
1022
|
+
}
|
|
1023
|
+
if (startNode.children) {
|
|
1024
|
+
startNode.children.forEach((child) => this._calculateExpandedNodes(child));
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
_setActiveNodeSingle(node, value) {
|
|
1028
|
+
// Deactivate all other nodes:
|
|
1029
|
+
this.activeNodes
|
|
1030
|
+
.filter((activeNode) => activeNode !== node)
|
|
1031
|
+
.forEach((activeNode) => {
|
|
1032
|
+
this.fireEvent({ eventName: TREE_EVENTS.deactivate, node: activeNode });
|
|
1033
|
+
this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node: activeNode }); // For IE11
|
|
1034
|
+
});
|
|
1035
|
+
if (value) {
|
|
1036
|
+
this.activeNodeIds = { [node.id]: true };
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
this.activeNodeIds = {};
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
_setActiveNodeMulti(node, value) {
|
|
1043
|
+
this.activeNodeIds = Object.assign({}, this.activeNodeIds, { [node.id]: value });
|
|
1044
|
+
}
|
|
1045
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModel, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1046
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModel }); }
|
|
1047
|
+
}
|
|
1048
|
+
__decorate$2([
|
|
1049
|
+
observable$1
|
|
1050
|
+
], TreeModel.prototype, "roots", void 0);
|
|
1051
|
+
__decorate$2([
|
|
1052
|
+
observable$1
|
|
1053
|
+
], TreeModel.prototype, "expandedNodeIds", void 0);
|
|
1054
|
+
__decorate$2([
|
|
1055
|
+
observable$1
|
|
1056
|
+
], TreeModel.prototype, "selectedLeafNodeIds", void 0);
|
|
1057
|
+
__decorate$2([
|
|
1058
|
+
observable$1
|
|
1059
|
+
], TreeModel.prototype, "activeNodeIds", void 0);
|
|
1060
|
+
__decorate$2([
|
|
1061
|
+
observable$1
|
|
1062
|
+
], TreeModel.prototype, "hiddenNodeIds", void 0);
|
|
1063
|
+
__decorate$2([
|
|
1064
|
+
observable$1
|
|
1065
|
+
], TreeModel.prototype, "focusedNodeId", void 0);
|
|
1066
|
+
__decorate$2([
|
|
1067
|
+
observable$1
|
|
1068
|
+
], TreeModel.prototype, "virtualRoot", void 0);
|
|
1069
|
+
__decorate$2([
|
|
1070
|
+
computed$1
|
|
1071
|
+
], TreeModel.prototype, "focusedNode", null);
|
|
1072
|
+
__decorate$2([
|
|
1073
|
+
computed$1
|
|
1074
|
+
], TreeModel.prototype, "expandedNodes", null);
|
|
1075
|
+
__decorate$2([
|
|
1076
|
+
computed$1
|
|
1077
|
+
], TreeModel.prototype, "activeNodes", null);
|
|
1078
|
+
__decorate$2([
|
|
1079
|
+
computed$1
|
|
1080
|
+
], TreeModel.prototype, "hiddenNodes", null);
|
|
1081
|
+
__decorate$2([
|
|
1082
|
+
computed$1
|
|
1083
|
+
], TreeModel.prototype, "selectedLeafNodes", null);
|
|
1084
|
+
__decorate$2([
|
|
1085
|
+
action$1
|
|
1086
|
+
], TreeModel.prototype, "setData", null);
|
|
1087
|
+
__decorate$2([
|
|
1088
|
+
action$1
|
|
1089
|
+
], TreeModel.prototype, "update", null);
|
|
1090
|
+
__decorate$2([
|
|
1091
|
+
action$1
|
|
1092
|
+
], TreeModel.prototype, "setFocusedNode", null);
|
|
1093
|
+
__decorate$2([
|
|
1094
|
+
action$1
|
|
1095
|
+
], TreeModel.prototype, "setFocus", null);
|
|
1096
|
+
__decorate$2([
|
|
1097
|
+
action$1
|
|
1098
|
+
], TreeModel.prototype, "doForAll", null);
|
|
1099
|
+
__decorate$2([
|
|
1100
|
+
action$1
|
|
1101
|
+
], TreeModel.prototype, "focusNextNode", null);
|
|
1102
|
+
__decorate$2([
|
|
1103
|
+
action$1
|
|
1104
|
+
], TreeModel.prototype, "focusPreviousNode", null);
|
|
1105
|
+
__decorate$2([
|
|
1106
|
+
action$1
|
|
1107
|
+
], TreeModel.prototype, "focusDrillDown", null);
|
|
1108
|
+
__decorate$2([
|
|
1109
|
+
action$1
|
|
1110
|
+
], TreeModel.prototype, "focusDrillUp", null);
|
|
1111
|
+
__decorate$2([
|
|
1112
|
+
action$1
|
|
1113
|
+
], TreeModel.prototype, "setActiveNode", null);
|
|
1114
|
+
__decorate$2([
|
|
1115
|
+
action$1
|
|
1116
|
+
], TreeModel.prototype, "setSelectedNode", null);
|
|
1117
|
+
__decorate$2([
|
|
1118
|
+
action$1
|
|
1119
|
+
], TreeModel.prototype, "setExpandedNode", null);
|
|
1120
|
+
__decorate$2([
|
|
1121
|
+
action$1
|
|
1122
|
+
], TreeModel.prototype, "expandAll", null);
|
|
1123
|
+
__decorate$2([
|
|
1124
|
+
action$1
|
|
1125
|
+
], TreeModel.prototype, "collapseAll", null);
|
|
1126
|
+
__decorate$2([
|
|
1127
|
+
action$1
|
|
1128
|
+
], TreeModel.prototype, "setIsHidden", null);
|
|
1129
|
+
__decorate$2([
|
|
1130
|
+
action$1
|
|
1131
|
+
], TreeModel.prototype, "setHiddenNodeIds", null);
|
|
1132
|
+
__decorate$2([
|
|
1133
|
+
action$1
|
|
1134
|
+
], TreeModel.prototype, "filterNodes", null);
|
|
1135
|
+
__decorate$2([
|
|
1136
|
+
action$1
|
|
1137
|
+
], TreeModel.prototype, "clearFilter", null);
|
|
1138
|
+
__decorate$2([
|
|
1139
|
+
action$1
|
|
1140
|
+
], TreeModel.prototype, "moveNode", null);
|
|
1141
|
+
__decorate$2([
|
|
1142
|
+
action$1
|
|
1143
|
+
], TreeModel.prototype, "copyNode", null);
|
|
1144
|
+
__decorate$2([
|
|
1145
|
+
action$1
|
|
1146
|
+
], TreeModel.prototype, "setState", null);
|
|
1147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModel, decorators: [{
|
|
1148
|
+
type: Injectable
|
|
1149
1149
|
}], propDecorators: { roots: [], expandedNodeIds: [], selectedLeafNodeIds: [], activeNodeIds: [], hiddenNodeIds: [], focusedNodeId: [], virtualRoot: [], focusedNode: [], expandedNodes: [], activeNodes: [], hiddenNodes: [], selectedLeafNodes: [], setData: [], update: [], setFocusedNode: [], setFocus: [], doForAll: [], focusNextNode: [], focusPreviousNode: [], focusDrillDown: [], focusDrillUp: [], setActiveNode: [], setSelectedNode: [], setExpandedNode: [], expandAll: [], collapseAll: [], setIsHidden: [], setHiddenNodeIds: [], filterNodes: [], clearFilter: [], moveNode: [], copyNode: [], setState: [] } });
|
|
1150
1150
|
|
|
1151
|
-
class TreeDraggedElement {
|
|
1152
|
-
constructor() {
|
|
1153
|
-
this._draggedElement = null;
|
|
1154
|
-
}
|
|
1155
|
-
set(draggedElement) {
|
|
1156
|
-
this._draggedElement = draggedElement;
|
|
1157
|
-
}
|
|
1158
|
-
get() {
|
|
1159
|
-
return this._draggedElement;
|
|
1160
|
-
}
|
|
1161
|
-
isDragging() {
|
|
1162
|
-
return !!this.get();
|
|
1163
|
-
}
|
|
1164
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1165
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1166
|
-
}
|
|
1167
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1168
|
-
type: Injectable,
|
|
1169
|
-
args: [{
|
|
1170
|
-
providedIn: 'root'
|
|
1171
|
-
}]
|
|
1151
|
+
class TreeDraggedElement {
|
|
1152
|
+
constructor() {
|
|
1153
|
+
this._draggedElement = null;
|
|
1154
|
+
}
|
|
1155
|
+
set(draggedElement) {
|
|
1156
|
+
this._draggedElement = draggedElement;
|
|
1157
|
+
}
|
|
1158
|
+
get() {
|
|
1159
|
+
return this._draggedElement;
|
|
1160
|
+
}
|
|
1161
|
+
isDragging() {
|
|
1162
|
+
return !!this.get();
|
|
1163
|
+
}
|
|
1164
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDraggedElement, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1165
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDraggedElement, providedIn: 'root' }); }
|
|
1166
|
+
}
|
|
1167
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDraggedElement, decorators: [{
|
|
1168
|
+
type: Injectable,
|
|
1169
|
+
args: [{
|
|
1170
|
+
providedIn: 'root'
|
|
1171
|
+
}]
|
|
1172
1172
|
}] });
|
|
1173
1173
|
|
|
1174
|
-
var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1175
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1176
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1177
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1178
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1179
|
-
};
|
|
1180
|
-
const Y_OFFSET = 500; // Extra pixels outside the viewport, in each direction, to render nodes in
|
|
1181
|
-
const Y_EPSILON = 150; // Minimum pixel change required to recalculate the rendered nodes
|
|
1182
|
-
class TreeVirtualScroll {
|
|
1183
|
-
get y() {
|
|
1184
|
-
return this.yBlocks * Y_EPSILON;
|
|
1185
|
-
}
|
|
1186
|
-
get totalHeight() {
|
|
1187
|
-
return this.treeModel.virtualRoot ? this.treeModel.virtualRoot.height : 0;
|
|
1188
|
-
}
|
|
1189
|
-
constructor(treeModel) {
|
|
1190
|
-
this.treeModel = treeModel;
|
|
1191
|
-
this.yBlocks = 0;
|
|
1192
|
-
this.x = 0;
|
|
1193
|
-
this.viewportHeight = null;
|
|
1194
|
-
this.viewport = null;
|
|
1195
|
-
treeModel.virtualScroll = this;
|
|
1196
|
-
this._dispose = [autorun(() => this.fixScroll())];
|
|
1197
|
-
}
|
|
1198
|
-
fireEvent(event) {
|
|
1199
|
-
this.treeModel.fireEvent(event);
|
|
1200
|
-
}
|
|
1201
|
-
init() {
|
|
1202
|
-
const fn = this.recalcPositions.bind(this);
|
|
1203
|
-
fn();
|
|
1204
|
-
this._dispose = [
|
|
1205
|
-
...this._dispose,
|
|
1206
|
-
reaction(() => this.treeModel.roots, fn),
|
|
1207
|
-
reaction(() => this.treeModel.expandedNodeIds, fn),
|
|
1208
|
-
reaction(() => this.treeModel.hiddenNodeIds, fn)
|
|
1209
|
-
];
|
|
1210
|
-
this.treeModel.subscribe(TREE_EVENTS.loadNodeChildren, fn);
|
|
1211
|
-
}
|
|
1212
|
-
isEnabled() {
|
|
1213
|
-
return this.treeModel.options.useVirtualScroll;
|
|
1214
|
-
}
|
|
1215
|
-
_setYBlocks(value) {
|
|
1216
|
-
this.yBlocks = value;
|
|
1217
|
-
}
|
|
1218
|
-
recalcPositions() {
|
|
1219
|
-
this.treeModel.virtualRoot.height = this._getPositionAfter(this.treeModel.getVisibleRoots(), 0);
|
|
1220
|
-
}
|
|
1221
|
-
_getPositionAfter(nodes, startPos) {
|
|
1222
|
-
let position = startPos;
|
|
1223
|
-
nodes.forEach((node) => {
|
|
1224
|
-
node.position = position;
|
|
1225
|
-
position = this._getPositionAfterNode(node, position);
|
|
1226
|
-
});
|
|
1227
|
-
return position;
|
|
1228
|
-
}
|
|
1229
|
-
_getPositionAfterNode(node, startPos) {
|
|
1230
|
-
let position = node.getSelfHeight() + startPos;
|
|
1231
|
-
if (node.children && node.isExpanded) { // TBD: consider loading component as well
|
|
1232
|
-
position = this._getPositionAfter(node.visibleChildren, position);
|
|
1233
|
-
}
|
|
1234
|
-
node.height = position - startPos;
|
|
1235
|
-
return position;
|
|
1236
|
-
}
|
|
1237
|
-
clear() {
|
|
1238
|
-
this._dispose.forEach((d) => d());
|
|
1239
|
-
}
|
|
1240
|
-
setViewport(viewport) {
|
|
1241
|
-
Object.assign(this, {
|
|
1242
|
-
viewport,
|
|
1243
|
-
x: viewport.scrollLeft,
|
|
1244
|
-
yBlocks: Math.round(viewport.scrollTop / Y_EPSILON),
|
|
1245
|
-
viewportHeight: viewport.getBoundingClientRect ? viewport.getBoundingClientRect().height : 0
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
scrollIntoView(node, force, scrollToMiddle = true) {
|
|
1249
|
-
if (node.options.scrollContainer) {
|
|
1250
|
-
const scrollContainer = node.options.scrollContainer;
|
|
1251
|
-
const scrollContainerHeight = scrollContainer.getBoundingClientRect().height;
|
|
1252
|
-
const scrollContainerTop = scrollContainer.getBoundingClientRect().top;
|
|
1253
|
-
const nodeTop = this.viewport.getBoundingClientRect().top + node.position - scrollContainerTop;
|
|
1254
|
-
if (force || // force scroll to node
|
|
1255
|
-
nodeTop < scrollContainer.scrollTop || // node is above scroll container
|
|
1256
|
-
nodeTop + node.getSelfHeight() > scrollContainer.scrollTop + scrollContainerHeight) { // node is below container
|
|
1257
|
-
scrollContainer.scrollTop = scrollToMiddle ?
|
|
1258
|
-
nodeTop - scrollContainerHeight / 2 : // scroll to middle
|
|
1259
|
-
nodeTop; // scroll to start
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
else {
|
|
1263
|
-
if (force || // force scroll to node
|
|
1264
|
-
node.position < this.y || // node is above viewport
|
|
1265
|
-
node.position + node.getSelfHeight() > this.y + this.viewportHeight) { // node is below viewport
|
|
1266
|
-
if (this.viewport) {
|
|
1267
|
-
this.viewport.scrollTop = scrollToMiddle ?
|
|
1268
|
-
node.position - this.viewportHeight / 2 : // scroll to middle
|
|
1269
|
-
node.position; // scroll to start
|
|
1270
|
-
this._setYBlocks(Math.floor(this.viewport.scrollTop / Y_EPSILON));
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
getViewportNodes(nodes) {
|
|
1276
|
-
if (!nodes)
|
|
1277
|
-
return [];
|
|
1278
|
-
const visibleNodes = nodes.filter((node) => !node.isHidden);
|
|
1279
|
-
if (!this.isEnabled())
|
|
1280
|
-
return visibleNodes;
|
|
1281
|
-
if (!this.viewportHeight || !visibleNodes.length)
|
|
1282
|
-
return [];
|
|
1283
|
-
// When loading children async this method is called before their height and position is calculated.
|
|
1284
|
-
// In that case firstIndex === 0 and lastIndex === visibleNodes.length - 1 (e.g. 1000),
|
|
1285
|
-
// which means that it loops through every visibleNodes item and push them into viewportNodes array.
|
|
1286
|
-
// We can prevent nodes from being pushed to the array and wait for the appropriate calculations to take place
|
|
1287
|
-
const lastVisibleNode = visibleNodes.slice(-1)[0];
|
|
1288
|
-
if (!lastVisibleNode.height && lastVisibleNode.position === 0)
|
|
1289
|
-
return [];
|
|
1290
|
-
// Search for first node in the viewport using binary search
|
|
1291
|
-
// Look for first node that starts after the beginning of the viewport (with buffer)
|
|
1292
|
-
// Or that ends after the beginning of the viewport
|
|
1293
|
-
const firstIndex = binarySearch(visibleNodes, (node) => {
|
|
1294
|
-
return (node.position + Y_OFFSET > this.y) ||
|
|
1295
|
-
(node.position + node.height > this.y);
|
|
1296
|
-
});
|
|
1297
|
-
// Search for last node in the viewport using binary search
|
|
1298
|
-
// Look for first node that starts after the end of the viewport (with buffer)
|
|
1299
|
-
const lastIndex = binarySearch(visibleNodes, (node) => {
|
|
1300
|
-
return node.position - Y_OFFSET > this.y + this.viewportHeight;
|
|
1301
|
-
}, firstIndex);
|
|
1302
|
-
const viewportNodes = [];
|
|
1303
|
-
for (let i = firstIndex; i <= lastIndex; i++) {
|
|
1304
|
-
viewportNodes.push(visibleNodes[i]);
|
|
1305
|
-
}
|
|
1306
|
-
return viewportNodes;
|
|
1307
|
-
}
|
|
1308
|
-
fixScroll() {
|
|
1309
|
-
const maxY = Math.max(0, this.totalHeight - this.viewportHeight);
|
|
1310
|
-
if (this.y < 0)
|
|
1311
|
-
this._setYBlocks(0);
|
|
1312
|
-
if (this.y > maxY)
|
|
1313
|
-
this._setYBlocks(maxY / Y_EPSILON);
|
|
1314
|
-
}
|
|
1315
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1316
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1317
|
-
}
|
|
1318
|
-
__decorate$1([
|
|
1319
|
-
observable$1
|
|
1320
|
-
], TreeVirtualScroll.prototype, "yBlocks", void 0);
|
|
1321
|
-
__decorate$1([
|
|
1322
|
-
observable$1
|
|
1323
|
-
], TreeVirtualScroll.prototype, "x", void 0);
|
|
1324
|
-
__decorate$1([
|
|
1325
|
-
observable$1
|
|
1326
|
-
], TreeVirtualScroll.prototype, "viewportHeight", void 0);
|
|
1327
|
-
__decorate$1([
|
|
1328
|
-
computed$1
|
|
1329
|
-
], TreeVirtualScroll.prototype, "y", null);
|
|
1330
|
-
__decorate$1([
|
|
1331
|
-
computed$1
|
|
1332
|
-
], TreeVirtualScroll.prototype, "totalHeight", null);
|
|
1333
|
-
__decorate$1([
|
|
1334
|
-
action$1
|
|
1335
|
-
], TreeVirtualScroll.prototype, "_setYBlocks", null);
|
|
1336
|
-
__decorate$1([
|
|
1337
|
-
action$1
|
|
1338
|
-
], TreeVirtualScroll.prototype, "recalcPositions", null);
|
|
1339
|
-
__decorate$1([
|
|
1340
|
-
action$1
|
|
1341
|
-
], TreeVirtualScroll.prototype, "setViewport", null);
|
|
1342
|
-
__decorate$1([
|
|
1343
|
-
action$1
|
|
1344
|
-
], TreeVirtualScroll.prototype, "scrollIntoView", null);
|
|
1345
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1346
|
-
type: Injectable
|
|
1347
|
-
}], ctorParameters:
|
|
1348
|
-
function binarySearch(nodes, condition, firstIndex = 0) {
|
|
1349
|
-
let index = firstIndex;
|
|
1350
|
-
let toIndex = nodes.length - 1;
|
|
1351
|
-
while (index !== toIndex) {
|
|
1352
|
-
let midIndex = Math.floor((index + toIndex) / 2);
|
|
1353
|
-
if (condition(nodes[midIndex])) {
|
|
1354
|
-
toIndex = midIndex;
|
|
1355
|
-
}
|
|
1356
|
-
else {
|
|
1357
|
-
if (index === midIndex)
|
|
1358
|
-
index = toIndex;
|
|
1359
|
-
else
|
|
1360
|
-
index = midIndex;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
return index;
|
|
1174
|
+
var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1175
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1176
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1177
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1178
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1179
|
+
};
|
|
1180
|
+
const Y_OFFSET = 500; // Extra pixels outside the viewport, in each direction, to render nodes in
|
|
1181
|
+
const Y_EPSILON = 150; // Minimum pixel change required to recalculate the rendered nodes
|
|
1182
|
+
class TreeVirtualScroll {
|
|
1183
|
+
get y() {
|
|
1184
|
+
return this.yBlocks * Y_EPSILON;
|
|
1185
|
+
}
|
|
1186
|
+
get totalHeight() {
|
|
1187
|
+
return this.treeModel.virtualRoot ? this.treeModel.virtualRoot.height : 0;
|
|
1188
|
+
}
|
|
1189
|
+
constructor(treeModel) {
|
|
1190
|
+
this.treeModel = treeModel;
|
|
1191
|
+
this.yBlocks = 0;
|
|
1192
|
+
this.x = 0;
|
|
1193
|
+
this.viewportHeight = null;
|
|
1194
|
+
this.viewport = null;
|
|
1195
|
+
treeModel.virtualScroll = this;
|
|
1196
|
+
this._dispose = [autorun(() => this.fixScroll())];
|
|
1197
|
+
}
|
|
1198
|
+
fireEvent(event) {
|
|
1199
|
+
this.treeModel.fireEvent(event);
|
|
1200
|
+
}
|
|
1201
|
+
init() {
|
|
1202
|
+
const fn = this.recalcPositions.bind(this);
|
|
1203
|
+
fn();
|
|
1204
|
+
this._dispose = [
|
|
1205
|
+
...this._dispose,
|
|
1206
|
+
reaction(() => this.treeModel.roots, fn),
|
|
1207
|
+
reaction(() => this.treeModel.expandedNodeIds, fn),
|
|
1208
|
+
reaction(() => this.treeModel.hiddenNodeIds, fn)
|
|
1209
|
+
];
|
|
1210
|
+
this.treeModel.subscribe(TREE_EVENTS.loadNodeChildren, fn);
|
|
1211
|
+
}
|
|
1212
|
+
isEnabled() {
|
|
1213
|
+
return this.treeModel.options.useVirtualScroll;
|
|
1214
|
+
}
|
|
1215
|
+
_setYBlocks(value) {
|
|
1216
|
+
this.yBlocks = value;
|
|
1217
|
+
}
|
|
1218
|
+
recalcPositions() {
|
|
1219
|
+
this.treeModel.virtualRoot.height = this._getPositionAfter(this.treeModel.getVisibleRoots(), 0);
|
|
1220
|
+
}
|
|
1221
|
+
_getPositionAfter(nodes, startPos) {
|
|
1222
|
+
let position = startPos;
|
|
1223
|
+
nodes.forEach((node) => {
|
|
1224
|
+
node.position = position;
|
|
1225
|
+
position = this._getPositionAfterNode(node, position);
|
|
1226
|
+
});
|
|
1227
|
+
return position;
|
|
1228
|
+
}
|
|
1229
|
+
_getPositionAfterNode(node, startPos) {
|
|
1230
|
+
let position = node.getSelfHeight() + startPos;
|
|
1231
|
+
if (node.children && node.isExpanded) { // TBD: consider loading component as well
|
|
1232
|
+
position = this._getPositionAfter(node.visibleChildren, position);
|
|
1233
|
+
}
|
|
1234
|
+
node.height = position - startPos;
|
|
1235
|
+
return position;
|
|
1236
|
+
}
|
|
1237
|
+
clear() {
|
|
1238
|
+
this._dispose.forEach((d) => d());
|
|
1239
|
+
}
|
|
1240
|
+
setViewport(viewport) {
|
|
1241
|
+
Object.assign(this, {
|
|
1242
|
+
viewport,
|
|
1243
|
+
x: viewport.scrollLeft,
|
|
1244
|
+
yBlocks: Math.round(viewport.scrollTop / Y_EPSILON),
|
|
1245
|
+
viewportHeight: viewport.getBoundingClientRect ? viewport.getBoundingClientRect().height : 0
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
scrollIntoView(node, force, scrollToMiddle = true) {
|
|
1249
|
+
if (node.options.scrollContainer) {
|
|
1250
|
+
const scrollContainer = node.options.scrollContainer;
|
|
1251
|
+
const scrollContainerHeight = scrollContainer.getBoundingClientRect().height;
|
|
1252
|
+
const scrollContainerTop = scrollContainer.getBoundingClientRect().top;
|
|
1253
|
+
const nodeTop = this.viewport.getBoundingClientRect().top + node.position - scrollContainerTop;
|
|
1254
|
+
if (force || // force scroll to node
|
|
1255
|
+
nodeTop < scrollContainer.scrollTop || // node is above scroll container
|
|
1256
|
+
nodeTop + node.getSelfHeight() > scrollContainer.scrollTop + scrollContainerHeight) { // node is below container
|
|
1257
|
+
scrollContainer.scrollTop = scrollToMiddle ?
|
|
1258
|
+
nodeTop - scrollContainerHeight / 2 : // scroll to middle
|
|
1259
|
+
nodeTop; // scroll to start
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
else {
|
|
1263
|
+
if (force || // force scroll to node
|
|
1264
|
+
node.position < this.y || // node is above viewport
|
|
1265
|
+
node.position + node.getSelfHeight() > this.y + this.viewportHeight) { // node is below viewport
|
|
1266
|
+
if (this.viewport) {
|
|
1267
|
+
this.viewport.scrollTop = scrollToMiddle ?
|
|
1268
|
+
node.position - this.viewportHeight / 2 : // scroll to middle
|
|
1269
|
+
node.position; // scroll to start
|
|
1270
|
+
this._setYBlocks(Math.floor(this.viewport.scrollTop / Y_EPSILON));
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
getViewportNodes(nodes) {
|
|
1276
|
+
if (!nodes)
|
|
1277
|
+
return [];
|
|
1278
|
+
const visibleNodes = nodes.filter((node) => !node.isHidden);
|
|
1279
|
+
if (!this.isEnabled())
|
|
1280
|
+
return visibleNodes;
|
|
1281
|
+
if (!this.viewportHeight || !visibleNodes.length)
|
|
1282
|
+
return [];
|
|
1283
|
+
// When loading children async this method is called before their height and position is calculated.
|
|
1284
|
+
// In that case firstIndex === 0 and lastIndex === visibleNodes.length - 1 (e.g. 1000),
|
|
1285
|
+
// which means that it loops through every visibleNodes item and push them into viewportNodes array.
|
|
1286
|
+
// We can prevent nodes from being pushed to the array and wait for the appropriate calculations to take place
|
|
1287
|
+
const lastVisibleNode = visibleNodes.slice(-1)[0];
|
|
1288
|
+
if (!lastVisibleNode.height && lastVisibleNode.position === 0)
|
|
1289
|
+
return [];
|
|
1290
|
+
// Search for first node in the viewport using binary search
|
|
1291
|
+
// Look for first node that starts after the beginning of the viewport (with buffer)
|
|
1292
|
+
// Or that ends after the beginning of the viewport
|
|
1293
|
+
const firstIndex = binarySearch(visibleNodes, (node) => {
|
|
1294
|
+
return (node.position + Y_OFFSET > this.y) ||
|
|
1295
|
+
(node.position + node.height > this.y);
|
|
1296
|
+
});
|
|
1297
|
+
// Search for last node in the viewport using binary search
|
|
1298
|
+
// Look for first node that starts after the end of the viewport (with buffer)
|
|
1299
|
+
const lastIndex = binarySearch(visibleNodes, (node) => {
|
|
1300
|
+
return node.position - Y_OFFSET > this.y + this.viewportHeight;
|
|
1301
|
+
}, firstIndex);
|
|
1302
|
+
const viewportNodes = [];
|
|
1303
|
+
for (let i = firstIndex; i <= lastIndex; i++) {
|
|
1304
|
+
viewportNodes.push(visibleNodes[i]);
|
|
1305
|
+
}
|
|
1306
|
+
return viewportNodes;
|
|
1307
|
+
}
|
|
1308
|
+
fixScroll() {
|
|
1309
|
+
const maxY = Math.max(0, this.totalHeight - this.viewportHeight);
|
|
1310
|
+
if (this.y < 0)
|
|
1311
|
+
this._setYBlocks(0);
|
|
1312
|
+
if (this.y > maxY)
|
|
1313
|
+
this._setYBlocks(maxY / Y_EPSILON);
|
|
1314
|
+
}
|
|
1315
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeVirtualScroll, deps: [{ token: TreeModel }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1316
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeVirtualScroll }); }
|
|
1317
|
+
}
|
|
1318
|
+
__decorate$1([
|
|
1319
|
+
observable$1
|
|
1320
|
+
], TreeVirtualScroll.prototype, "yBlocks", void 0);
|
|
1321
|
+
__decorate$1([
|
|
1322
|
+
observable$1
|
|
1323
|
+
], TreeVirtualScroll.prototype, "x", void 0);
|
|
1324
|
+
__decorate$1([
|
|
1325
|
+
observable$1
|
|
1326
|
+
], TreeVirtualScroll.prototype, "viewportHeight", void 0);
|
|
1327
|
+
__decorate$1([
|
|
1328
|
+
computed$1
|
|
1329
|
+
], TreeVirtualScroll.prototype, "y", null);
|
|
1330
|
+
__decorate$1([
|
|
1331
|
+
computed$1
|
|
1332
|
+
], TreeVirtualScroll.prototype, "totalHeight", null);
|
|
1333
|
+
__decorate$1([
|
|
1334
|
+
action$1
|
|
1335
|
+
], TreeVirtualScroll.prototype, "_setYBlocks", null);
|
|
1336
|
+
__decorate$1([
|
|
1337
|
+
action$1
|
|
1338
|
+
], TreeVirtualScroll.prototype, "recalcPositions", null);
|
|
1339
|
+
__decorate$1([
|
|
1340
|
+
action$1
|
|
1341
|
+
], TreeVirtualScroll.prototype, "setViewport", null);
|
|
1342
|
+
__decorate$1([
|
|
1343
|
+
action$1
|
|
1344
|
+
], TreeVirtualScroll.prototype, "scrollIntoView", null);
|
|
1345
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeVirtualScroll, decorators: [{
|
|
1346
|
+
type: Injectable
|
|
1347
|
+
}], ctorParameters: () => [{ type: TreeModel }], propDecorators: { yBlocks: [], x: [], viewportHeight: [], y: [], totalHeight: [], _setYBlocks: [], recalcPositions: [], setViewport: [], scrollIntoView: [] } });
|
|
1348
|
+
function binarySearch(nodes, condition, firstIndex = 0) {
|
|
1349
|
+
let index = firstIndex;
|
|
1350
|
+
let toIndex = nodes.length - 1;
|
|
1351
|
+
while (index !== toIndex) {
|
|
1352
|
+
let midIndex = Math.floor((index + toIndex) / 2);
|
|
1353
|
+
if (condition(nodes[midIndex])) {
|
|
1354
|
+
toIndex = midIndex;
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
if (index === midIndex)
|
|
1358
|
+
index = toIndex;
|
|
1359
|
+
else
|
|
1360
|
+
index = midIndex;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return index;
|
|
1364
1364
|
}
|
|
1365
1365
|
|
|
1366
|
-
class LoadingComponent {
|
|
1367
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1368
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1366
|
+
class LoadingComponent {
|
|
1367
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1368
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: LoadingComponent, selector: "tree-loading-component", inputs: { template: "template", node: "node" }, ngImport: i0, template: `
|
|
1369
1369
|
<span *ngIf="!template">loading...</span>
|
|
1370
1370
|
<ng-container
|
|
1371
1371
|
[ngTemplateOutlet]="template"
|
|
1372
1372
|
[ngTemplateOutletContext]="{ $implicit: node }">
|
|
1373
1373
|
</ng-container>
|
|
1374
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1375
|
-
}
|
|
1376
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1377
|
-
type: Component,
|
|
1378
|
-
args: [{
|
|
1379
|
-
encapsulation: ViewEncapsulation.None,
|
|
1380
|
-
selector: 'tree-loading-component',
|
|
1374
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1375
|
+
}
|
|
1376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoadingComponent, decorators: [{
|
|
1377
|
+
type: Component,
|
|
1378
|
+
args: [{
|
|
1379
|
+
encapsulation: ViewEncapsulation.None,
|
|
1380
|
+
selector: 'tree-loading-component',
|
|
1381
1381
|
template: `
|
|
1382
1382
|
<span *ngIf="!template">loading...</span>
|
|
1383
1383
|
<ng-container
|
|
1384
1384
|
[ngTemplateOutlet]="template"
|
|
1385
1385
|
[ngTemplateOutletContext]="{ $implicit: node }">
|
|
1386
1386
|
</ng-container>
|
|
1387
|
-
`,
|
|
1388
|
-
}]
|
|
1389
|
-
}], propDecorators: { template: [{
|
|
1390
|
-
type: Input
|
|
1391
|
-
}], node: [{
|
|
1392
|
-
type: Input
|
|
1387
|
+
`,
|
|
1388
|
+
}]
|
|
1389
|
+
}], propDecorators: { template: [{
|
|
1390
|
+
type: Input
|
|
1391
|
+
}], node: [{
|
|
1392
|
+
type: Input
|
|
1393
1393
|
}] } });
|
|
1394
1394
|
|
|
1395
|
-
const DRAG_OVER_CLASS$1 = 'is-dragging-over';
|
|
1396
|
-
const DRAG_DISABLED_CLASS = 'is-dragging-over-disabled';
|
|
1397
|
-
class TreeDropDirective {
|
|
1398
|
-
set treeAllowDrop(allowDrop) {
|
|
1399
|
-
if (allowDrop instanceof Function) {
|
|
1400
|
-
this._allowDrop = allowDrop;
|
|
1401
|
-
}
|
|
1402
|
-
else
|
|
1403
|
-
this._allowDrop = (element, $event) => allowDrop;
|
|
1404
|
-
}
|
|
1405
|
-
allowDrop($event) {
|
|
1406
|
-
return this._allowDrop(this.treeDraggedElement.get(), $event);
|
|
1407
|
-
}
|
|
1408
|
-
constructor(el, renderer, treeDraggedElement, ngZone) {
|
|
1409
|
-
this.el = el;
|
|
1410
|
-
this.renderer = renderer;
|
|
1411
|
-
this.treeDraggedElement = treeDraggedElement;
|
|
1412
|
-
this.ngZone = ngZone;
|
|
1413
|
-
this.allowDragoverStyling = true;
|
|
1414
|
-
this.onDropCallback = new EventEmitter();
|
|
1415
|
-
this.onDragOverCallback = new EventEmitter();
|
|
1416
|
-
this.onDragLeaveCallback = new EventEmitter();
|
|
1417
|
-
this.onDragEnterCallback = new EventEmitter();
|
|
1418
|
-
this._allowDrop = (element, $event) => true;
|
|
1419
|
-
this.dragOverEventHandler = this.onDragOver.bind(this);
|
|
1420
|
-
this.dragEnterEventHandler = this.onDragEnter.bind(this);
|
|
1421
|
-
this.dragLeaveEventHandler = this.onDragLeave.bind(this);
|
|
1422
|
-
}
|
|
1423
|
-
ngAfterViewInit() {
|
|
1424
|
-
let el = this.el.nativeElement;
|
|
1425
|
-
this.ngZone.runOutsideAngular(() => {
|
|
1426
|
-
el.addEventListener('dragover', this.dragOverEventHandler);
|
|
1427
|
-
el.addEventListener('dragenter', this.dragEnterEventHandler);
|
|
1428
|
-
el.addEventListener('dragleave', this.dragLeaveEventHandler);
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
ngOnDestroy() {
|
|
1432
|
-
let el = this.el.nativeElement;
|
|
1433
|
-
el.removeEventListener('dragover', this.dragOverEventHandler);
|
|
1434
|
-
el.removeEventListener('dragenter', this.dragEnterEventHandler);
|
|
1435
|
-
el.removeEventListener('dragleave', this.dragLeaveEventHandler);
|
|
1436
|
-
}
|
|
1437
|
-
onDragOver($event) {
|
|
1438
|
-
if (!this.allowDrop($event)) {
|
|
1439
|
-
if (this.allowDragoverStyling) {
|
|
1440
|
-
return this.addDisabledClass();
|
|
1441
|
-
}
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
this.onDragOverCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1445
|
-
$event.preventDefault();
|
|
1446
|
-
if (this.allowDragoverStyling) {
|
|
1447
|
-
this.addClass();
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
onDragEnter($event) {
|
|
1451
|
-
if (!this.allowDrop($event))
|
|
1452
|
-
return;
|
|
1453
|
-
$event.preventDefault();
|
|
1454
|
-
this.onDragEnterCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1455
|
-
}
|
|
1456
|
-
onDragLeave($event) {
|
|
1457
|
-
if (!this.allowDrop($event)) {
|
|
1458
|
-
if (this.allowDragoverStyling) {
|
|
1459
|
-
return this.removeDisabledClass();
|
|
1460
|
-
}
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
this.onDragLeaveCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1464
|
-
if (this.allowDragoverStyling) {
|
|
1465
|
-
this.removeClass();
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
onDrop($event) {
|
|
1469
|
-
if (!this.allowDrop($event))
|
|
1470
|
-
return;
|
|
1471
|
-
$event.preventDefault();
|
|
1472
|
-
this.onDropCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1473
|
-
if (this.allowDragoverStyling) {
|
|
1474
|
-
this.removeClass();
|
|
1475
|
-
}
|
|
1476
|
-
this.treeDraggedElement.set(null);
|
|
1477
|
-
}
|
|
1478
|
-
addClass() {
|
|
1479
|
-
this.renderer.addClass(this.el.nativeElement, DRAG_OVER_CLASS$1);
|
|
1480
|
-
}
|
|
1481
|
-
removeClass() {
|
|
1482
|
-
this.renderer.removeClass(this.el.nativeElement, DRAG_OVER_CLASS$1);
|
|
1483
|
-
}
|
|
1484
|
-
addDisabledClass() {
|
|
1485
|
-
this.renderer.addClass(this.el.nativeElement, DRAG_DISABLED_CLASS);
|
|
1486
|
-
}
|
|
1487
|
-
removeDisabledClass() {
|
|
1488
|
-
this.renderer.removeClass(this.el.nativeElement, DRAG_DISABLED_CLASS);
|
|
1489
|
-
}
|
|
1490
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1491
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1492
|
-
}
|
|
1493
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1494
|
-
type: Directive,
|
|
1495
|
-
args: [{
|
|
1496
|
-
selector: '[treeDrop]'
|
|
1497
|
-
}]
|
|
1498
|
-
}], ctorParameters:
|
|
1499
|
-
type: Input
|
|
1500
|
-
}], onDropCallback: [{
|
|
1501
|
-
type: Output,
|
|
1502
|
-
args: ['treeDrop']
|
|
1503
|
-
}], onDragOverCallback: [{
|
|
1504
|
-
type: Output,
|
|
1505
|
-
args: ['treeDropDragOver']
|
|
1506
|
-
}], onDragLeaveCallback: [{
|
|
1507
|
-
type: Output,
|
|
1508
|
-
args: ['treeDropDragLeave']
|
|
1509
|
-
}], onDragEnterCallback: [{
|
|
1510
|
-
type: Output,
|
|
1511
|
-
args: ['treeDropDragEnter']
|
|
1512
|
-
}], treeAllowDrop: [{
|
|
1513
|
-
type: Input
|
|
1514
|
-
}], onDrop: [{
|
|
1515
|
-
type: HostListener,
|
|
1516
|
-
args: ['drop', ['$event']]
|
|
1395
|
+
const DRAG_OVER_CLASS$1 = 'is-dragging-over';
|
|
1396
|
+
const DRAG_DISABLED_CLASS = 'is-dragging-over-disabled';
|
|
1397
|
+
class TreeDropDirective {
|
|
1398
|
+
set treeAllowDrop(allowDrop) {
|
|
1399
|
+
if (allowDrop instanceof Function) {
|
|
1400
|
+
this._allowDrop = allowDrop;
|
|
1401
|
+
}
|
|
1402
|
+
else
|
|
1403
|
+
this._allowDrop = (element, $event) => allowDrop;
|
|
1404
|
+
}
|
|
1405
|
+
allowDrop($event) {
|
|
1406
|
+
return this._allowDrop(this.treeDraggedElement.get(), $event);
|
|
1407
|
+
}
|
|
1408
|
+
constructor(el, renderer, treeDraggedElement, ngZone) {
|
|
1409
|
+
this.el = el;
|
|
1410
|
+
this.renderer = renderer;
|
|
1411
|
+
this.treeDraggedElement = treeDraggedElement;
|
|
1412
|
+
this.ngZone = ngZone;
|
|
1413
|
+
this.allowDragoverStyling = true;
|
|
1414
|
+
this.onDropCallback = new EventEmitter();
|
|
1415
|
+
this.onDragOverCallback = new EventEmitter();
|
|
1416
|
+
this.onDragLeaveCallback = new EventEmitter();
|
|
1417
|
+
this.onDragEnterCallback = new EventEmitter();
|
|
1418
|
+
this._allowDrop = (element, $event) => true;
|
|
1419
|
+
this.dragOverEventHandler = this.onDragOver.bind(this);
|
|
1420
|
+
this.dragEnterEventHandler = this.onDragEnter.bind(this);
|
|
1421
|
+
this.dragLeaveEventHandler = this.onDragLeave.bind(this);
|
|
1422
|
+
}
|
|
1423
|
+
ngAfterViewInit() {
|
|
1424
|
+
let el = this.el.nativeElement;
|
|
1425
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1426
|
+
el.addEventListener('dragover', this.dragOverEventHandler);
|
|
1427
|
+
el.addEventListener('dragenter', this.dragEnterEventHandler);
|
|
1428
|
+
el.addEventListener('dragleave', this.dragLeaveEventHandler);
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
ngOnDestroy() {
|
|
1432
|
+
let el = this.el.nativeElement;
|
|
1433
|
+
el.removeEventListener('dragover', this.dragOverEventHandler);
|
|
1434
|
+
el.removeEventListener('dragenter', this.dragEnterEventHandler);
|
|
1435
|
+
el.removeEventListener('dragleave', this.dragLeaveEventHandler);
|
|
1436
|
+
}
|
|
1437
|
+
onDragOver($event) {
|
|
1438
|
+
if (!this.allowDrop($event)) {
|
|
1439
|
+
if (this.allowDragoverStyling) {
|
|
1440
|
+
return this.addDisabledClass();
|
|
1441
|
+
}
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
this.onDragOverCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1445
|
+
$event.preventDefault();
|
|
1446
|
+
if (this.allowDragoverStyling) {
|
|
1447
|
+
this.addClass();
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
onDragEnter($event) {
|
|
1451
|
+
if (!this.allowDrop($event))
|
|
1452
|
+
return;
|
|
1453
|
+
$event.preventDefault();
|
|
1454
|
+
this.onDragEnterCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1455
|
+
}
|
|
1456
|
+
onDragLeave($event) {
|
|
1457
|
+
if (!this.allowDrop($event)) {
|
|
1458
|
+
if (this.allowDragoverStyling) {
|
|
1459
|
+
return this.removeDisabledClass();
|
|
1460
|
+
}
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
this.onDragLeaveCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1464
|
+
if (this.allowDragoverStyling) {
|
|
1465
|
+
this.removeClass();
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
onDrop($event) {
|
|
1469
|
+
if (!this.allowDrop($event))
|
|
1470
|
+
return;
|
|
1471
|
+
$event.preventDefault();
|
|
1472
|
+
this.onDropCallback.emit({ event: $event, element: this.treeDraggedElement.get() });
|
|
1473
|
+
if (this.allowDragoverStyling) {
|
|
1474
|
+
this.removeClass();
|
|
1475
|
+
}
|
|
1476
|
+
this.treeDraggedElement.set(null);
|
|
1477
|
+
}
|
|
1478
|
+
addClass() {
|
|
1479
|
+
this.renderer.addClass(this.el.nativeElement, DRAG_OVER_CLASS$1);
|
|
1480
|
+
}
|
|
1481
|
+
removeClass() {
|
|
1482
|
+
this.renderer.removeClass(this.el.nativeElement, DRAG_OVER_CLASS$1);
|
|
1483
|
+
}
|
|
1484
|
+
addDisabledClass() {
|
|
1485
|
+
this.renderer.addClass(this.el.nativeElement, DRAG_DISABLED_CLASS);
|
|
1486
|
+
}
|
|
1487
|
+
removeDisabledClass() {
|
|
1488
|
+
this.renderer.removeClass(this.el.nativeElement, DRAG_DISABLED_CLASS);
|
|
1489
|
+
}
|
|
1490
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDropDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: TreeDraggedElement }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1491
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: TreeDropDirective, selector: "[treeDrop]", inputs: { allowDragoverStyling: "allowDragoverStyling", treeAllowDrop: "treeAllowDrop" }, outputs: { onDropCallback: "treeDrop", onDragOverCallback: "treeDropDragOver", onDragLeaveCallback: "treeDropDragLeave", onDragEnterCallback: "treeDropDragEnter" }, host: { listeners: { "drop": "onDrop($event)" } }, ngImport: i0 }); }
|
|
1492
|
+
}
|
|
1493
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDropDirective, decorators: [{
|
|
1494
|
+
type: Directive,
|
|
1495
|
+
args: [{
|
|
1496
|
+
selector: '[treeDrop]'
|
|
1497
|
+
}]
|
|
1498
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: TreeDraggedElement }, { type: i0.NgZone }], propDecorators: { allowDragoverStyling: [{
|
|
1499
|
+
type: Input
|
|
1500
|
+
}], onDropCallback: [{
|
|
1501
|
+
type: Output,
|
|
1502
|
+
args: ['treeDrop']
|
|
1503
|
+
}], onDragOverCallback: [{
|
|
1504
|
+
type: Output,
|
|
1505
|
+
args: ['treeDropDragOver']
|
|
1506
|
+
}], onDragLeaveCallback: [{
|
|
1507
|
+
type: Output,
|
|
1508
|
+
args: ['treeDropDragLeave']
|
|
1509
|
+
}], onDragEnterCallback: [{
|
|
1510
|
+
type: Output,
|
|
1511
|
+
args: ['treeDropDragEnter']
|
|
1512
|
+
}], treeAllowDrop: [{
|
|
1513
|
+
type: Input
|
|
1514
|
+
}], onDrop: [{
|
|
1515
|
+
type: HostListener,
|
|
1516
|
+
args: ['drop', ['$event']]
|
|
1517
1517
|
}] } });
|
|
1518
1518
|
|
|
1519
|
-
class TreeNodeDropSlot {
|
|
1520
|
-
onDrop($event) {
|
|
1521
|
-
this.node.mouseAction('drop', $event.event, {
|
|
1522
|
-
from: $event.element,
|
|
1523
|
-
to: { parent: this.node, index: this.dropIndex }
|
|
1524
|
-
});
|
|
1525
|
-
}
|
|
1526
|
-
allowDrop(element, $event) {
|
|
1527
|
-
return this.node.options.allowDrop(element, { parent: this.node, index: this.dropIndex }, $event);
|
|
1528
|
-
}
|
|
1529
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1530
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1519
|
+
class TreeNodeDropSlot {
|
|
1520
|
+
onDrop($event) {
|
|
1521
|
+
this.node.mouseAction('drop', $event.event, {
|
|
1522
|
+
from: $event.element,
|
|
1523
|
+
to: { parent: this.node, index: this.dropIndex }
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
allowDrop(element, $event) {
|
|
1527
|
+
return this.node.options.allowDrop(element, { parent: this.node, index: this.dropIndex }, $event);
|
|
1528
|
+
}
|
|
1529
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeDropSlot, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1530
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: { node: "node", dropIndex: "dropIndex" }, ngImport: i0, template: `
|
|
1531
1531
|
<div
|
|
1532
1532
|
class="node-drop-slot"
|
|
1533
1533
|
(treeDrop)="onDrop($event)"
|
|
1534
1534
|
[treeAllowDrop]="allowDrop.bind(this)"
|
|
1535
1535
|
[allowDragoverStyling]="true">
|
|
1536
1536
|
</div>
|
|
1537
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: TreeDropDirective, selector: "[treeDrop]", inputs: ["allowDragoverStyling", "treeAllowDrop"], outputs: ["treeDrop", "treeDropDragOver", "treeDropDragLeave", "treeDropDragEnter"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1538
|
-
}
|
|
1539
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1540
|
-
type: Component,
|
|
1537
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: TreeDropDirective, selector: "[treeDrop]", inputs: ["allowDragoverStyling", "treeAllowDrop"], outputs: ["treeDrop", "treeDropDragOver", "treeDropDragLeave", "treeDropDragEnter"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1538
|
+
}
|
|
1539
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeDropSlot, decorators: [{
|
|
1540
|
+
type: Component,
|
|
1541
1541
|
args: [{ selector: 'TreeNodeDropSlot, tree-node-drop-slot', encapsulation: ViewEncapsulation.None, template: `
|
|
1542
1542
|
<div
|
|
1543
1543
|
class="node-drop-slot"
|
|
@@ -1545,220 +1545,220 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1545
1545
|
[treeAllowDrop]="allowDrop.bind(this)"
|
|
1546
1546
|
[allowDragoverStyling]="true">
|
|
1547
1547
|
</div>
|
|
1548
|
-
` }]
|
|
1549
|
-
}], propDecorators: { node: [{
|
|
1550
|
-
type: Input
|
|
1551
|
-
}], dropIndex: [{
|
|
1552
|
-
type: Input
|
|
1548
|
+
` }]
|
|
1549
|
+
}], propDecorators: { node: [{
|
|
1550
|
+
type: Input
|
|
1551
|
+
}], dropIndex: [{
|
|
1552
|
+
type: Input
|
|
1553
1553
|
}] } });
|
|
1554
1554
|
|
|
1555
|
-
// Re-export mobx operators to be able to use inside components with AOT:
|
|
1556
|
-
function actionInternal(...args) {
|
|
1557
|
-
return action$1(...args);
|
|
1558
|
-
}
|
|
1559
|
-
const action = Object.assign(actionInternal, action$1);
|
|
1560
|
-
function computedInternal(...args) {
|
|
1561
|
-
return computed$1(...args);
|
|
1562
|
-
}
|
|
1563
|
-
const computed = Object.assign(computedInternal, computed$1);
|
|
1564
|
-
function observableInternal(...args) {
|
|
1565
|
-
return observable$1(...args);
|
|
1566
|
-
}
|
|
1555
|
+
// Re-export mobx operators to be able to use inside components with AOT:
|
|
1556
|
+
function actionInternal(...args) {
|
|
1557
|
+
return action$1(...args);
|
|
1558
|
+
}
|
|
1559
|
+
const action = Object.assign(actionInternal, action$1);
|
|
1560
|
+
function computedInternal(...args) {
|
|
1561
|
+
return computed$1(...args);
|
|
1562
|
+
}
|
|
1563
|
+
const computed = Object.assign(computedInternal, computed$1);
|
|
1564
|
+
function observableInternal(...args) {
|
|
1565
|
+
return observable$1(...args);
|
|
1566
|
+
}
|
|
1567
1567
|
const observable = Object.assign(observableInternal, observable$1);
|
|
1568
1568
|
|
|
1569
|
-
const EASE_ACCELERATION = 1.005;
|
|
1570
|
-
class TreeAnimateOpenDirective {
|
|
1571
|
-
set isOpen(value) {
|
|
1572
|
-
if (value) {
|
|
1573
|
-
this._show();
|
|
1574
|
-
if (this.isEnabled && this._isOpen === false) {
|
|
1575
|
-
this._animateOpen();
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
else {
|
|
1579
|
-
this.isEnabled ? this._animateClose() : this._hide();
|
|
1580
|
-
}
|
|
1581
|
-
this._isOpen = !!value;
|
|
1582
|
-
}
|
|
1583
|
-
;
|
|
1584
|
-
constructor(renderer, templateRef, viewContainerRef) {
|
|
1585
|
-
this.renderer = renderer;
|
|
1586
|
-
this.templateRef = templateRef;
|
|
1587
|
-
this.viewContainerRef = viewContainerRef;
|
|
1588
|
-
}
|
|
1589
|
-
_show() {
|
|
1590
|
-
if (this.innerElement)
|
|
1591
|
-
return;
|
|
1592
|
-
// create child view
|
|
1593
|
-
this.innerElement = this.viewContainerRef.createEmbeddedView(this.templateRef).rootNodes[0];
|
|
1594
|
-
}
|
|
1595
|
-
_hide() {
|
|
1596
|
-
this.viewContainerRef.clear();
|
|
1597
|
-
this.innerElement = null;
|
|
1598
|
-
}
|
|
1599
|
-
_animateOpen() {
|
|
1600
|
-
let delta = this.animateSpeed;
|
|
1601
|
-
let ease = this.animateAcceleration;
|
|
1602
|
-
let maxHeight = 0;
|
|
1603
|
-
// set height to 0
|
|
1604
|
-
this.renderer.setStyle(this.innerElement, 'max-height', `0`);
|
|
1605
|
-
// increase maxHeight until height doesn't change
|
|
1606
|
-
setTimeout(() => {
|
|
1607
|
-
const i = setInterval(() => {
|
|
1608
|
-
if (!this._isOpen || !this.innerElement)
|
|
1609
|
-
return clearInterval(i);
|
|
1610
|
-
maxHeight += delta;
|
|
1611
|
-
const roundedMaxHeight = Math.round(maxHeight);
|
|
1612
|
-
this.renderer.setStyle(this.innerElement, 'max-height', `${roundedMaxHeight}px`);
|
|
1613
|
-
const height = this.innerElement.getBoundingClientRect ? this.innerElement.getBoundingClientRect().height : 0; // TBD use renderer
|
|
1614
|
-
delta *= ease;
|
|
1615
|
-
ease *= EASE_ACCELERATION;
|
|
1616
|
-
if (height < roundedMaxHeight) {
|
|
1617
|
-
// Make maxHeight auto because animation finished and container might change height later on
|
|
1618
|
-
this.renderer.setStyle(this.innerElement, 'max-height', null);
|
|
1619
|
-
clearInterval(i);
|
|
1620
|
-
}
|
|
1621
|
-
}, 17);
|
|
1622
|
-
});
|
|
1623
|
-
}
|
|
1624
|
-
_animateClose() {
|
|
1625
|
-
if (!this.innerElement)
|
|
1626
|
-
return;
|
|
1627
|
-
let delta = this.animateSpeed;
|
|
1628
|
-
let ease = this.animateAcceleration;
|
|
1629
|
-
let height = this.innerElement.getBoundingClientRect().height; // TBD use renderer
|
|
1630
|
-
// slowly decrease maxHeight to 0, starting from current height
|
|
1631
|
-
const i = setInterval(() => {
|
|
1632
|
-
if (this._isOpen || !this.innerElement)
|
|
1633
|
-
return clearInterval(i);
|
|
1634
|
-
height -= delta;
|
|
1635
|
-
this.renderer.setStyle(this.innerElement, 'max-height', `${height}px`);
|
|
1636
|
-
delta *= ease;
|
|
1637
|
-
ease *= EASE_ACCELERATION;
|
|
1638
|
-
if (height <= 0) {
|
|
1639
|
-
// after animation complete - remove child element
|
|
1640
|
-
this.viewContainerRef.clear();
|
|
1641
|
-
this.innerElement = null;
|
|
1642
|
-
clearInterval(i);
|
|
1643
|
-
}
|
|
1644
|
-
}, 17);
|
|
1645
|
-
}
|
|
1646
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1647
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1648
|
-
}
|
|
1649
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1650
|
-
type: Directive,
|
|
1651
|
-
args: [{
|
|
1652
|
-
selector: '[treeAnimateOpen]'
|
|
1653
|
-
}]
|
|
1654
|
-
}], ctorParameters:
|
|
1655
|
-
type: Input,
|
|
1656
|
-
args: ['treeAnimateOpenSpeed']
|
|
1657
|
-
}], animateAcceleration: [{
|
|
1658
|
-
type: Input,
|
|
1659
|
-
args: ['treeAnimateOpenAcceleration']
|
|
1660
|
-
}], isEnabled: [{
|
|
1661
|
-
type: Input,
|
|
1662
|
-
args: ['treeAnimateOpenEnabled']
|
|
1663
|
-
}], isOpen: [{
|
|
1664
|
-
type: Input,
|
|
1665
|
-
args: ['treeAnimateOpen']
|
|
1569
|
+
const EASE_ACCELERATION = 1.005;
|
|
1570
|
+
class TreeAnimateOpenDirective {
|
|
1571
|
+
set isOpen(value) {
|
|
1572
|
+
if (value) {
|
|
1573
|
+
this._show();
|
|
1574
|
+
if (this.isEnabled && this._isOpen === false) {
|
|
1575
|
+
this._animateOpen();
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
else {
|
|
1579
|
+
this.isEnabled ? this._animateClose() : this._hide();
|
|
1580
|
+
}
|
|
1581
|
+
this._isOpen = !!value;
|
|
1582
|
+
}
|
|
1583
|
+
;
|
|
1584
|
+
constructor(renderer, templateRef, viewContainerRef) {
|
|
1585
|
+
this.renderer = renderer;
|
|
1586
|
+
this.templateRef = templateRef;
|
|
1587
|
+
this.viewContainerRef = viewContainerRef;
|
|
1588
|
+
}
|
|
1589
|
+
_show() {
|
|
1590
|
+
if (this.innerElement)
|
|
1591
|
+
return;
|
|
1592
|
+
// create child view
|
|
1593
|
+
this.innerElement = this.viewContainerRef.createEmbeddedView(this.templateRef).rootNodes[0];
|
|
1594
|
+
}
|
|
1595
|
+
_hide() {
|
|
1596
|
+
this.viewContainerRef.clear();
|
|
1597
|
+
this.innerElement = null;
|
|
1598
|
+
}
|
|
1599
|
+
_animateOpen() {
|
|
1600
|
+
let delta = this.animateSpeed;
|
|
1601
|
+
let ease = this.animateAcceleration;
|
|
1602
|
+
let maxHeight = 0;
|
|
1603
|
+
// set height to 0
|
|
1604
|
+
this.renderer.setStyle(this.innerElement, 'max-height', `0`);
|
|
1605
|
+
// increase maxHeight until height doesn't change
|
|
1606
|
+
setTimeout(() => {
|
|
1607
|
+
const i = setInterval(() => {
|
|
1608
|
+
if (!this._isOpen || !this.innerElement)
|
|
1609
|
+
return clearInterval(i);
|
|
1610
|
+
maxHeight += delta;
|
|
1611
|
+
const roundedMaxHeight = Math.round(maxHeight);
|
|
1612
|
+
this.renderer.setStyle(this.innerElement, 'max-height', `${roundedMaxHeight}px`);
|
|
1613
|
+
const height = this.innerElement.getBoundingClientRect ? this.innerElement.getBoundingClientRect().height : 0; // TBD use renderer
|
|
1614
|
+
delta *= ease;
|
|
1615
|
+
ease *= EASE_ACCELERATION;
|
|
1616
|
+
if (height < roundedMaxHeight) {
|
|
1617
|
+
// Make maxHeight auto because animation finished and container might change height later on
|
|
1618
|
+
this.renderer.setStyle(this.innerElement, 'max-height', null);
|
|
1619
|
+
clearInterval(i);
|
|
1620
|
+
}
|
|
1621
|
+
}, 17);
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
_animateClose() {
|
|
1625
|
+
if (!this.innerElement)
|
|
1626
|
+
return;
|
|
1627
|
+
let delta = this.animateSpeed;
|
|
1628
|
+
let ease = this.animateAcceleration;
|
|
1629
|
+
let height = this.innerElement.getBoundingClientRect().height; // TBD use renderer
|
|
1630
|
+
// slowly decrease maxHeight to 0, starting from current height
|
|
1631
|
+
const i = setInterval(() => {
|
|
1632
|
+
if (this._isOpen || !this.innerElement)
|
|
1633
|
+
return clearInterval(i);
|
|
1634
|
+
height -= delta;
|
|
1635
|
+
this.renderer.setStyle(this.innerElement, 'max-height', `${height}px`);
|
|
1636
|
+
delta *= ease;
|
|
1637
|
+
ease *= EASE_ACCELERATION;
|
|
1638
|
+
if (height <= 0) {
|
|
1639
|
+
// after animation complete - remove child element
|
|
1640
|
+
this.viewContainerRef.clear();
|
|
1641
|
+
this.innerElement = null;
|
|
1642
|
+
clearInterval(i);
|
|
1643
|
+
}
|
|
1644
|
+
}, 17);
|
|
1645
|
+
}
|
|
1646
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeAnimateOpenDirective, deps: [{ token: i0.Renderer2 }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1647
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: TreeAnimateOpenDirective, selector: "[treeAnimateOpen]", inputs: { animateSpeed: ["treeAnimateOpenSpeed", "animateSpeed"], animateAcceleration: ["treeAnimateOpenAcceleration", "animateAcceleration"], isEnabled: ["treeAnimateOpenEnabled", "isEnabled"], isOpen: ["treeAnimateOpen", "isOpen"] }, ngImport: i0 }); }
|
|
1648
|
+
}
|
|
1649
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeAnimateOpenDirective, decorators: [{
|
|
1650
|
+
type: Directive,
|
|
1651
|
+
args: [{
|
|
1652
|
+
selector: '[treeAnimateOpen]'
|
|
1653
|
+
}]
|
|
1654
|
+
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }], propDecorators: { animateSpeed: [{
|
|
1655
|
+
type: Input,
|
|
1656
|
+
args: ['treeAnimateOpenSpeed']
|
|
1657
|
+
}], animateAcceleration: [{
|
|
1658
|
+
type: Input,
|
|
1659
|
+
args: ['treeAnimateOpenAcceleration']
|
|
1660
|
+
}], isEnabled: [{
|
|
1661
|
+
type: Input,
|
|
1662
|
+
args: ['treeAnimateOpenEnabled']
|
|
1663
|
+
}], isOpen: [{
|
|
1664
|
+
type: Input,
|
|
1665
|
+
args: ['treeAnimateOpen']
|
|
1666
1666
|
}] } });
|
|
1667
1667
|
|
|
1668
|
-
class TreeNodeContent {
|
|
1669
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1670
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1668
|
+
class TreeNodeContent {
|
|
1669
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeContent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1670
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeContent, selector: "tree-node-content", inputs: { node: "node", index: "index", template: "template" }, ngImport: i0, template: `
|
|
1671
1671
|
<span *ngIf="!template">{{ node.displayField }}</span>
|
|
1672
1672
|
<ng-container
|
|
1673
1673
|
[ngTemplateOutlet]="template"
|
|
1674
1674
|
[ngTemplateOutletContext]="{ $implicit: node, node: node, index: index }">
|
|
1675
|
-
</ng-container>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1676
|
-
}
|
|
1677
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1678
|
-
type: Component,
|
|
1679
|
-
args: [{
|
|
1680
|
-
selector: 'tree-node-content',
|
|
1681
|
-
encapsulation: ViewEncapsulation.None,
|
|
1675
|
+
</ng-container>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1676
|
+
}
|
|
1677
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeContent, decorators: [{
|
|
1678
|
+
type: Component,
|
|
1679
|
+
args: [{
|
|
1680
|
+
selector: 'tree-node-content',
|
|
1681
|
+
encapsulation: ViewEncapsulation.None,
|
|
1682
1682
|
template: `
|
|
1683
1683
|
<span *ngIf="!template">{{ node.displayField }}</span>
|
|
1684
1684
|
<ng-container
|
|
1685
1685
|
[ngTemplateOutlet]="template"
|
|
1686
1686
|
[ngTemplateOutletContext]="{ $implicit: node, node: node, index: index }">
|
|
1687
|
-
</ng-container>`,
|
|
1688
|
-
}]
|
|
1689
|
-
}], propDecorators: { node: [{
|
|
1690
|
-
type: Input
|
|
1691
|
-
}], index: [{
|
|
1692
|
-
type: Input
|
|
1693
|
-
}], template: [{
|
|
1694
|
-
type: Input
|
|
1687
|
+
</ng-container>`,
|
|
1688
|
+
}]
|
|
1689
|
+
}], propDecorators: { node: [{
|
|
1690
|
+
type: Input
|
|
1691
|
+
}], index: [{
|
|
1692
|
+
type: Input
|
|
1693
|
+
}], template: [{
|
|
1694
|
+
type: Input
|
|
1695
1695
|
}] } });
|
|
1696
1696
|
|
|
1697
|
-
const DRAG_OVER_CLASS = 'is-dragging-over';
|
|
1698
|
-
class TreeDragDirective {
|
|
1699
|
-
constructor(el, renderer, treeDraggedElement, ngZone) {
|
|
1700
|
-
this.el = el;
|
|
1701
|
-
this.renderer = renderer;
|
|
1702
|
-
this.treeDraggedElement = treeDraggedElement;
|
|
1703
|
-
this.ngZone = ngZone;
|
|
1704
|
-
this.dragEventHandler = this.onDrag.bind(this);
|
|
1705
|
-
}
|
|
1706
|
-
ngAfterViewInit() {
|
|
1707
|
-
let el = this.el.nativeElement;
|
|
1708
|
-
this.ngZone.runOutsideAngular(() => {
|
|
1709
|
-
el.addEventListener('drag', this.dragEventHandler);
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
ngDoCheck() {
|
|
1713
|
-
this.renderer.setAttribute(this.el.nativeElement, 'draggable', this.treeDragEnabled ? 'true' : 'false');
|
|
1714
|
-
}
|
|
1715
|
-
ngOnDestroy() {
|
|
1716
|
-
let el = this.el.nativeElement;
|
|
1717
|
-
el.removeEventListener('drag', this.dragEventHandler);
|
|
1718
|
-
}
|
|
1719
|
-
onDragStart(ev) {
|
|
1720
|
-
// setting the data is required by firefox
|
|
1721
|
-
ev.dataTransfer.setData('text', ev.target.id);
|
|
1722
|
-
this.treeDraggedElement.set(this.draggedElement);
|
|
1723
|
-
if (this.draggedElement.mouseAction) {
|
|
1724
|
-
this.draggedElement.mouseAction('dragStart', ev);
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
onDrag(ev) {
|
|
1728
|
-
if (this.draggedElement.mouseAction) {
|
|
1729
|
-
this.draggedElement.mouseAction('drag', ev);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
onDragEnd() {
|
|
1733
|
-
if (this.draggedElement.mouseAction) {
|
|
1734
|
-
this.draggedElement.mouseAction('dragEnd');
|
|
1735
|
-
}
|
|
1736
|
-
this.treeDraggedElement.set(null);
|
|
1737
|
-
}
|
|
1738
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1739
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1740
|
-
}
|
|
1741
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1742
|
-
type: Directive,
|
|
1743
|
-
args: [{
|
|
1744
|
-
selector: '[treeDrag]'
|
|
1745
|
-
}]
|
|
1746
|
-
}], ctorParameters:
|
|
1747
|
-
type: Input,
|
|
1748
|
-
args: ['treeDrag']
|
|
1749
|
-
}], treeDragEnabled: [{
|
|
1750
|
-
type: Input
|
|
1751
|
-
}], onDragStart: [{
|
|
1752
|
-
type: HostListener,
|
|
1753
|
-
args: ['dragstart', ['$event']]
|
|
1754
|
-
}], onDragEnd: [{
|
|
1755
|
-
type: HostListener,
|
|
1756
|
-
args: ['dragend']
|
|
1697
|
+
const DRAG_OVER_CLASS = 'is-dragging-over';
|
|
1698
|
+
class TreeDragDirective {
|
|
1699
|
+
constructor(el, renderer, treeDraggedElement, ngZone) {
|
|
1700
|
+
this.el = el;
|
|
1701
|
+
this.renderer = renderer;
|
|
1702
|
+
this.treeDraggedElement = treeDraggedElement;
|
|
1703
|
+
this.ngZone = ngZone;
|
|
1704
|
+
this.dragEventHandler = this.onDrag.bind(this);
|
|
1705
|
+
}
|
|
1706
|
+
ngAfterViewInit() {
|
|
1707
|
+
let el = this.el.nativeElement;
|
|
1708
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1709
|
+
el.addEventListener('drag', this.dragEventHandler);
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
ngDoCheck() {
|
|
1713
|
+
this.renderer.setAttribute(this.el.nativeElement, 'draggable', this.treeDragEnabled ? 'true' : 'false');
|
|
1714
|
+
}
|
|
1715
|
+
ngOnDestroy() {
|
|
1716
|
+
let el = this.el.nativeElement;
|
|
1717
|
+
el.removeEventListener('drag', this.dragEventHandler);
|
|
1718
|
+
}
|
|
1719
|
+
onDragStart(ev) {
|
|
1720
|
+
// setting the data is required by firefox
|
|
1721
|
+
ev.dataTransfer.setData('text', ev.target.id);
|
|
1722
|
+
this.treeDraggedElement.set(this.draggedElement);
|
|
1723
|
+
if (this.draggedElement.mouseAction) {
|
|
1724
|
+
this.draggedElement.mouseAction('dragStart', ev);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
onDrag(ev) {
|
|
1728
|
+
if (this.draggedElement.mouseAction) {
|
|
1729
|
+
this.draggedElement.mouseAction('drag', ev);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
onDragEnd() {
|
|
1733
|
+
if (this.draggedElement.mouseAction) {
|
|
1734
|
+
this.draggedElement.mouseAction('dragEnd');
|
|
1735
|
+
}
|
|
1736
|
+
this.treeDraggedElement.set(null);
|
|
1737
|
+
}
|
|
1738
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDragDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: TreeDraggedElement }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1739
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: TreeDragDirective, selector: "[treeDrag]", inputs: { draggedElement: ["treeDrag", "draggedElement"], treeDragEnabled: "treeDragEnabled" }, host: { listeners: { "dragstart": "onDragStart($event)", "dragend": "onDragEnd()" } }, ngImport: i0 }); }
|
|
1740
|
+
}
|
|
1741
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeDragDirective, decorators: [{
|
|
1742
|
+
type: Directive,
|
|
1743
|
+
args: [{
|
|
1744
|
+
selector: '[treeDrag]'
|
|
1745
|
+
}]
|
|
1746
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: TreeDraggedElement }, { type: i0.NgZone }], propDecorators: { draggedElement: [{
|
|
1747
|
+
type: Input,
|
|
1748
|
+
args: ['treeDrag']
|
|
1749
|
+
}], treeDragEnabled: [{
|
|
1750
|
+
type: Input
|
|
1751
|
+
}], onDragStart: [{
|
|
1752
|
+
type: HostListener,
|
|
1753
|
+
args: ['dragstart', ['$event']]
|
|
1754
|
+
}], onDragEnd: [{
|
|
1755
|
+
type: HostListener,
|
|
1756
|
+
args: ['dragend']
|
|
1757
1757
|
}] } });
|
|
1758
1758
|
|
|
1759
|
-
class TreeNodeExpanderComponent {
|
|
1760
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1761
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1759
|
+
class TreeNodeExpanderComponent {
|
|
1760
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeExpanderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1761
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeExpanderComponent, selector: "tree-node-expander", inputs: { node: "node" }, ngImport: i0, template: `
|
|
1762
1762
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1763
1763
|
<span
|
|
1764
1764
|
*ngIf="node.hasChildren"
|
|
@@ -1772,10 +1772,10 @@ class TreeNodeExpanderComponent {
|
|
|
1772
1772
|
<span *ngIf="!node.hasChildren" class="toggle-children-placeholder">
|
|
1773
1773
|
</span>
|
|
1774
1774
|
</ng-container>
|
|
1775
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1776
|
-
}
|
|
1777
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1778
|
-
type: Component,
|
|
1775
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1776
|
+
}
|
|
1777
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeExpanderComponent, decorators: [{
|
|
1778
|
+
type: Component,
|
|
1779
1779
|
args: [{ selector: 'tree-node-expander', encapsulation: ViewEncapsulation.None, template: `
|
|
1780
1780
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1781
1781
|
<span
|
|
@@ -1790,14 +1790,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1790
1790
|
<span *ngIf="!node.hasChildren" class="toggle-children-placeholder">
|
|
1791
1791
|
</span>
|
|
1792
1792
|
</ng-container>
|
|
1793
|
-
` }]
|
|
1794
|
-
}], propDecorators: { node: [{
|
|
1795
|
-
type: Input
|
|
1793
|
+
` }]
|
|
1794
|
+
}], propDecorators: { node: [{
|
|
1795
|
+
type: Input
|
|
1796
1796
|
}] } });
|
|
1797
1797
|
|
|
1798
|
-
class TreeNodeCheckboxComponent {
|
|
1799
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1800
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1798
|
+
class TreeNodeCheckboxComponent {
|
|
1799
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1800
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeCheckboxComponent, selector: "tree-node-checkbox", inputs: { node: "node" }, ngImport: i0, template: `
|
|
1801
1801
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1802
1802
|
<input
|
|
1803
1803
|
class="tree-node-checkbox"
|
|
@@ -1807,10 +1807,10 @@ class TreeNodeCheckboxComponent {
|
|
|
1807
1807
|
[indeterminate]="node.isPartiallySelected"
|
|
1808
1808
|
/>
|
|
1809
1809
|
</ng-container>
|
|
1810
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1811
|
-
}
|
|
1812
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1813
|
-
type: Component,
|
|
1810
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1811
|
+
}
|
|
1812
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeCheckboxComponent, decorators: [{
|
|
1813
|
+
type: Component,
|
|
1814
1814
|
args: [{ selector: 'tree-node-checkbox', encapsulation: ViewEncapsulation.None, template: `
|
|
1815
1815
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1816
1816
|
<input
|
|
@@ -1821,14 +1821,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1821
1821
|
[indeterminate]="node.isPartiallySelected"
|
|
1822
1822
|
/>
|
|
1823
1823
|
</ng-container>
|
|
1824
|
-
` }]
|
|
1825
|
-
}], propDecorators: { node: [{
|
|
1826
|
-
type: Input
|
|
1824
|
+
` }]
|
|
1825
|
+
}], propDecorators: { node: [{
|
|
1826
|
+
type: Input
|
|
1827
1827
|
}] } });
|
|
1828
1828
|
|
|
1829
|
-
class TreeNodeWrapperComponent {
|
|
1830
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1831
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1829
|
+
class TreeNodeWrapperComponent {
|
|
1830
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1831
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeWrapperComponent, selector: "tree-node-wrapper", inputs: { node: "node", index: "index", templates: "templates" }, ngImport: i0, template: `
|
|
1832
1832
|
<div *ngIf="!templates.treeNodeWrapperTemplate" class="node-wrapper" [style.padding-left]="node.getNodePadding()">
|
|
1833
1833
|
<tree-node-checkbox *ngIf="node.options.useCheckbox" [node]="node"></tree-node-checkbox>
|
|
1834
1834
|
<tree-node-expander [node]="node"></tree-node-expander>
|
|
@@ -1857,10 +1857,10 @@ class TreeNodeWrapperComponent {
|
|
|
1857
1857
|
[ngTemplateOutlet]="templates.treeNodeWrapperTemplate"
|
|
1858
1858
|
[ngTemplateOutletContext]="{ $implicit: node, node: node, index: index, templates: templates }">
|
|
1859
1859
|
</ng-container>
|
|
1860
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: TreeNodeContent, selector: "tree-node-content", inputs: ["node", "index", "template"] }, { kind: "directive", type: TreeDropDirective, selector: "[treeDrop]", inputs: ["allowDragoverStyling", "treeAllowDrop"], outputs: ["treeDrop", "treeDropDragOver", "treeDropDragLeave", "treeDropDragEnter"] }, { kind: "directive", type: TreeDragDirective, selector: "[treeDrag]", inputs: ["treeDrag", "treeDragEnabled"] }, { kind: "component", type: TreeNodeExpanderComponent, selector: "tree-node-expander", inputs: ["node"] }, { kind: "component", type: TreeNodeCheckboxComponent, selector: "tree-node-checkbox", inputs: ["node"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1861
|
-
}
|
|
1862
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1863
|
-
type: Component,
|
|
1860
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: TreeNodeContent, selector: "tree-node-content", inputs: ["node", "index", "template"] }, { kind: "directive", type: TreeDropDirective, selector: "[treeDrop]", inputs: ["allowDragoverStyling", "treeAllowDrop"], outputs: ["treeDrop", "treeDropDragOver", "treeDropDragLeave", "treeDropDragEnter"] }, { kind: "directive", type: TreeDragDirective, selector: "[treeDrag]", inputs: ["treeDrag", "treeDragEnabled"] }, { kind: "component", type: TreeNodeExpanderComponent, selector: "tree-node-expander", inputs: ["node"] }, { kind: "component", type: TreeNodeCheckboxComponent, selector: "tree-node-checkbox", inputs: ["node"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1861
|
+
}
|
|
1862
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeWrapperComponent, decorators: [{
|
|
1863
|
+
type: Component,
|
|
1864
1864
|
args: [{ selector: 'tree-node-wrapper', encapsulation: ViewEncapsulation.None, template: `
|
|
1865
1865
|
<div *ngIf="!templates.treeNodeWrapperTemplate" class="node-wrapper" [style.padding-left]="node.getNodePadding()">
|
|
1866
1866
|
<tree-node-checkbox *ngIf="node.options.useCheckbox" [node]="node"></tree-node-checkbox>
|
|
@@ -1890,24 +1890,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1890
1890
|
[ngTemplateOutlet]="templates.treeNodeWrapperTemplate"
|
|
1891
1891
|
[ngTemplateOutletContext]="{ $implicit: node, node: node, index: index, templates: templates }">
|
|
1892
1892
|
</ng-container>
|
|
1893
|
-
` }]
|
|
1894
|
-
}], propDecorators: { node: [{
|
|
1895
|
-
type: Input
|
|
1896
|
-
}], index: [{
|
|
1897
|
-
type: Input
|
|
1898
|
-
}], templates: [{
|
|
1899
|
-
type: Input
|
|
1893
|
+
` }]
|
|
1894
|
+
}], propDecorators: { node: [{
|
|
1895
|
+
type: Input
|
|
1896
|
+
}], index: [{
|
|
1897
|
+
type: Input
|
|
1898
|
+
}], templates: [{
|
|
1899
|
+
type: Input
|
|
1900
1900
|
}] } });
|
|
1901
1901
|
|
|
1902
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1903
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1904
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1905
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1906
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1907
|
-
};
|
|
1908
|
-
class TreeNodeChildrenComponent {
|
|
1909
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1910
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1902
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1903
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1904
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1905
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1906
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1907
|
+
};
|
|
1908
|
+
class TreeNodeChildrenComponent {
|
|
1909
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeChildrenComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1910
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeChildrenComponent, selector: "tree-node-children", inputs: { node: "node", templates: "templates" }, ngImport: i0, template: `
|
|
1911
1911
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1912
1912
|
<div
|
|
1913
1913
|
[class.tree-children]="true"
|
|
@@ -1935,10 +1935,10 @@ class TreeNodeChildrenComponent {
|
|
|
1935
1935
|
></tree-loading-component>
|
|
1936
1936
|
</div>
|
|
1937
1937
|
</ng-container>
|
|
1938
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(
|
|
1939
|
-
}
|
|
1940
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1941
|
-
type: Component,
|
|
1938
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i0.forwardRef(() => LoadingComponent), selector: "tree-loading-component", inputs: ["template", "node"] }, { kind: "component", type: i0.forwardRef(() => TreeNodeCollectionComponent), selector: "tree-node-collection", inputs: ["nodes", "treeModel", "templates"] }, { kind: "directive", type: i0.forwardRef(() => TreeAnimateOpenDirective), selector: "[treeAnimateOpen]", inputs: ["treeAnimateOpenSpeed", "treeAnimateOpenAcceleration", "treeAnimateOpenEnabled", "treeAnimateOpen"] }, { kind: "directive", type: i0.forwardRef(() => TreeMobxAutorunDirective), selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
1939
|
+
}
|
|
1940
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeChildrenComponent, decorators: [{
|
|
1941
|
+
type: Component,
|
|
1942
1942
|
args: [{ selector: 'tree-node-children', encapsulation: ViewEncapsulation.None, template: `
|
|
1943
1943
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
1944
1944
|
<div
|
|
@@ -1967,58 +1967,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1967
1967
|
></tree-loading-component>
|
|
1968
1968
|
</div>
|
|
1969
1969
|
</ng-container>
|
|
1970
|
-
` }]
|
|
1971
|
-
}], propDecorators: { node: [{
|
|
1972
|
-
type: Input
|
|
1973
|
-
}], templates: [{
|
|
1974
|
-
type: Input
|
|
1975
|
-
}] } });
|
|
1976
|
-
class TreeNodeCollectionComponent {
|
|
1977
|
-
constructor() {
|
|
1978
|
-
this._dispose = [];
|
|
1979
|
-
}
|
|
1980
|
-
get nodes() {
|
|
1981
|
-
return this._nodes;
|
|
1982
|
-
}
|
|
1983
|
-
set nodes(nodes) {
|
|
1984
|
-
this.setNodes(nodes);
|
|
1985
|
-
}
|
|
1986
|
-
get marginTop() {
|
|
1987
|
-
const firstNode = this.viewportNodes && this.viewportNodes.length && this.viewportNodes[0];
|
|
1988
|
-
const relativePosition = firstNode && firstNode.parent
|
|
1989
|
-
? firstNode.position -
|
|
1990
|
-
firstNode.parent.position -
|
|
1991
|
-
firstNode.parent.getSelfHeight()
|
|
1992
|
-
: 0;
|
|
1993
|
-
return `${relativePosition}px`;
|
|
1994
|
-
}
|
|
1995
|
-
setNodes(nodes) {
|
|
1996
|
-
this._nodes = nodes;
|
|
1997
|
-
}
|
|
1998
|
-
ngOnInit() {
|
|
1999
|
-
this.virtualScroll = this.treeModel.virtualScroll;
|
|
2000
|
-
this._dispose = [
|
|
2001
|
-
// return node indexes so we can compare structurally,
|
|
2002
|
-
reaction(() => {
|
|
2003
|
-
return this.virtualScroll
|
|
2004
|
-
.getViewportNodes(this.nodes)
|
|
2005
|
-
.map(n => n.index);
|
|
2006
|
-
}, nodeIndexes => {
|
|
2007
|
-
this.viewportNodes = nodeIndexes.map(i => this.nodes[i]);
|
|
2008
|
-
}, { compareStructural: true, fireImmediately: true }),
|
|
2009
|
-
reaction(() => this.nodes, nodes => {
|
|
2010
|
-
this.viewportNodes = this.virtualScroll.getViewportNodes(nodes);
|
|
2011
|
-
})
|
|
2012
|
-
];
|
|
2013
|
-
}
|
|
2014
|
-
ngOnDestroy() {
|
|
2015
|
-
this._dispose.forEach(d => d());
|
|
2016
|
-
}
|
|
2017
|
-
trackNode(index, node) {
|
|
2018
|
-
return node.id;
|
|
2019
|
-
}
|
|
2020
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2021
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1970
|
+
` }]
|
|
1971
|
+
}], propDecorators: { node: [{
|
|
1972
|
+
type: Input
|
|
1973
|
+
}], templates: [{
|
|
1974
|
+
type: Input
|
|
1975
|
+
}] } });
|
|
1976
|
+
class TreeNodeCollectionComponent {
|
|
1977
|
+
constructor() {
|
|
1978
|
+
this._dispose = [];
|
|
1979
|
+
}
|
|
1980
|
+
get nodes() {
|
|
1981
|
+
return this._nodes;
|
|
1982
|
+
}
|
|
1983
|
+
set nodes(nodes) {
|
|
1984
|
+
this.setNodes(nodes);
|
|
1985
|
+
}
|
|
1986
|
+
get marginTop() {
|
|
1987
|
+
const firstNode = this.viewportNodes && this.viewportNodes.length && this.viewportNodes[0];
|
|
1988
|
+
const relativePosition = firstNode && firstNode.parent
|
|
1989
|
+
? firstNode.position -
|
|
1990
|
+
firstNode.parent.position -
|
|
1991
|
+
firstNode.parent.getSelfHeight()
|
|
1992
|
+
: 0;
|
|
1993
|
+
return `${relativePosition}px`;
|
|
1994
|
+
}
|
|
1995
|
+
setNodes(nodes) {
|
|
1996
|
+
this._nodes = nodes;
|
|
1997
|
+
}
|
|
1998
|
+
ngOnInit() {
|
|
1999
|
+
this.virtualScroll = this.treeModel.virtualScroll;
|
|
2000
|
+
this._dispose = [
|
|
2001
|
+
// return node indexes so we can compare structurally,
|
|
2002
|
+
reaction(() => {
|
|
2003
|
+
return this.virtualScroll
|
|
2004
|
+
.getViewportNodes(this.nodes)
|
|
2005
|
+
.map(n => n.index);
|
|
2006
|
+
}, nodeIndexes => {
|
|
2007
|
+
this.viewportNodes = nodeIndexes.map(i => this.nodes[i]);
|
|
2008
|
+
}, { compareStructural: true, fireImmediately: true }),
|
|
2009
|
+
reaction(() => this.nodes, nodes => {
|
|
2010
|
+
this.viewportNodes = this.virtualScroll.getViewportNodes(nodes);
|
|
2011
|
+
})
|
|
2012
|
+
];
|
|
2013
|
+
}
|
|
2014
|
+
ngOnDestroy() {
|
|
2015
|
+
this._dispose.forEach(d => d());
|
|
2016
|
+
}
|
|
2017
|
+
trackNode(index, node) {
|
|
2018
|
+
return node.id;
|
|
2019
|
+
}
|
|
2020
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeCollectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2021
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeCollectionComponent, selector: "tree-node-collection", inputs: { nodes: "nodes", treeModel: "treeModel", templates: "templates" }, ngImport: i0, template: `
|
|
2022
2022
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2023
2023
|
<div [style.margin-top]="marginTop">
|
|
2024
2024
|
<tree-node
|
|
@@ -2030,25 +2030,25 @@ class TreeNodeCollectionComponent {
|
|
|
2030
2030
|
</tree-node>
|
|
2031
2031
|
</div>
|
|
2032
2032
|
</ng-container>
|
|
2033
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(
|
|
2034
|
-
}
|
|
2035
|
-
__decorate([
|
|
2036
|
-
observable
|
|
2037
|
-
], TreeNodeCollectionComponent.prototype, "_nodes", void 0);
|
|
2038
|
-
__decorate([
|
|
2039
|
-
observable
|
|
2040
|
-
], TreeNodeCollectionComponent.prototype, "viewportNodes", void 0);
|
|
2041
|
-
__decorate([
|
|
2042
|
-
computed
|
|
2043
|
-
], TreeNodeCollectionComponent.prototype, "marginTop", null);
|
|
2044
|
-
__decorate([
|
|
2045
|
-
action
|
|
2046
|
-
], TreeNodeCollectionComponent.prototype, "setNodes", null);
|
|
2047
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2048
|
-
type: Component,
|
|
2049
|
-
args: [{
|
|
2050
|
-
selector: 'tree-node-collection',
|
|
2051
|
-
encapsulation: ViewEncapsulation.None,
|
|
2033
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgForOf), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i0.forwardRef(() => TreeNodeComponent), selector: "TreeNode, tree-node", inputs: ["node", "index", "templates"] }, { kind: "directive", type: i0.forwardRef(() => TreeMobxAutorunDirective), selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
2034
|
+
}
|
|
2035
|
+
__decorate([
|
|
2036
|
+
observable
|
|
2037
|
+
], TreeNodeCollectionComponent.prototype, "_nodes", void 0);
|
|
2038
|
+
__decorate([
|
|
2039
|
+
observable
|
|
2040
|
+
], TreeNodeCollectionComponent.prototype, "viewportNodes", void 0);
|
|
2041
|
+
__decorate([
|
|
2042
|
+
computed
|
|
2043
|
+
], TreeNodeCollectionComponent.prototype, "marginTop", null);
|
|
2044
|
+
__decorate([
|
|
2045
|
+
action
|
|
2046
|
+
], TreeNodeCollectionComponent.prototype, "setNodes", null);
|
|
2047
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeCollectionComponent, decorators: [{
|
|
2048
|
+
type: Component,
|
|
2049
|
+
args: [{
|
|
2050
|
+
selector: 'tree-node-collection',
|
|
2051
|
+
encapsulation: ViewEncapsulation.None,
|
|
2052
2052
|
template: `
|
|
2053
2053
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2054
2054
|
<div [style.margin-top]="marginTop">
|
|
@@ -2061,18 +2061,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
2061
2061
|
</tree-node>
|
|
2062
2062
|
</div>
|
|
2063
2063
|
</ng-container>
|
|
2064
|
-
`
|
|
2065
|
-
}]
|
|
2066
|
-
}], propDecorators: { nodes: [{
|
|
2067
|
-
type: Input
|
|
2068
|
-
}], treeModel: [{
|
|
2069
|
-
type: Input
|
|
2070
|
-
}], _nodes: [], templates: [{
|
|
2071
|
-
type: Input
|
|
2072
|
-
}], viewportNodes: [], marginTop: [], setNodes: [] } });
|
|
2073
|
-
class TreeNodeComponent {
|
|
2074
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2075
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2064
|
+
`
|
|
2065
|
+
}]
|
|
2066
|
+
}], propDecorators: { nodes: [{
|
|
2067
|
+
type: Input
|
|
2068
|
+
}], treeModel: [{
|
|
2069
|
+
type: Input
|
|
2070
|
+
}], _nodes: [], templates: [{
|
|
2071
|
+
type: Input
|
|
2072
|
+
}], viewportNodes: [], marginTop: [], setNodes: [] } });
|
|
2073
|
+
class TreeNodeComponent {
|
|
2074
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2075
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeNodeComponent, selector: "TreeNode, tree-node", inputs: { node: "node", index: "index", templates: "templates" }, ngImport: i0, template: `
|
|
2076
2076
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2077
2077
|
<div
|
|
2078
2078
|
*ngIf="!templates.treeNodeFullTemplate"
|
|
@@ -2116,10 +2116,10 @@ class TreeNodeComponent {
|
|
|
2116
2116
|
>
|
|
2117
2117
|
</ng-container>
|
|
2118
2118
|
</ng-container>
|
|
2119
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: TreeNodeChildrenComponent, selector: "tree-node-children", inputs: ["node", "templates"] }, { kind: "component", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: ["node", "dropIndex"] }, { kind: "component", type: TreeNodeWrapperComponent, selector: "tree-node-wrapper", inputs: ["node", "index", "templates"] }, { kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
2120
|
-
}
|
|
2121
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2122
|
-
type: Component,
|
|
2119
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: TreeNodeChildrenComponent, selector: "tree-node-children", inputs: ["node", "templates"] }, { kind: "component", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: ["node", "dropIndex"] }, { kind: "component", type: TreeNodeWrapperComponent, selector: "tree-node-wrapper", inputs: ["node", "index", "templates"] }, { kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
2120
|
+
}
|
|
2121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeNodeComponent, decorators: [{
|
|
2122
|
+
type: Component,
|
|
2123
2123
|
args: [{ selector: 'TreeNode, tree-node', encapsulation: ViewEncapsulation.None, template: `
|
|
2124
2124
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2125
2125
|
<div
|
|
@@ -2164,133 +2164,133 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
2164
2164
|
>
|
|
2165
2165
|
</ng-container>
|
|
2166
2166
|
</ng-container>
|
|
2167
|
-
` }]
|
|
2168
|
-
}], propDecorators: { node: [{
|
|
2169
|
-
type: Input
|
|
2170
|
-
}], index: [{
|
|
2171
|
-
type: Input
|
|
2172
|
-
}], templates: [{
|
|
2173
|
-
type: Input
|
|
2167
|
+
` }]
|
|
2168
|
+
}], propDecorators: { node: [{
|
|
2169
|
+
type: Input
|
|
2170
|
+
}], index: [{
|
|
2171
|
+
type: Input
|
|
2172
|
+
}], templates: [{
|
|
2173
|
+
type: Input
|
|
2174
2174
|
}] } });
|
|
2175
2175
|
|
|
2176
|
-
class TreeViewportComponent {
|
|
2177
|
-
constructor(elementRef, virtualScroll) {
|
|
2178
|
-
this.elementRef = elementRef;
|
|
2179
|
-
this.virtualScroll = virtualScroll;
|
|
2180
|
-
this.setViewport = this.throttle(() => {
|
|
2181
|
-
this.virtualScroll.setViewport(this.elementRef.nativeElement);
|
|
2182
|
-
}, 17);
|
|
2183
|
-
this.scrollEventHandler = this.setViewport.bind(this);
|
|
2184
|
-
}
|
|
2185
|
-
ngOnInit() {
|
|
2186
|
-
this.virtualScroll.init();
|
|
2187
|
-
}
|
|
2188
|
-
ngAfterViewInit() {
|
|
2189
|
-
setTimeout(() => {
|
|
2190
|
-
this.setViewport();
|
|
2191
|
-
this.virtualScroll.fireEvent({ eventName: TREE_EVENTS.initialized });
|
|
2192
|
-
});
|
|
2193
|
-
let el = this.elementRef.nativeElement;
|
|
2194
|
-
el.addEventListener('scroll', this.scrollEventHandler);
|
|
2195
|
-
}
|
|
2196
|
-
ngOnDestroy() {
|
|
2197
|
-
this.virtualScroll.clear();
|
|
2198
|
-
let el = this.elementRef.nativeElement;
|
|
2199
|
-
el.removeEventListener('scroll', this.scrollEventHandler);
|
|
2200
|
-
}
|
|
2201
|
-
getTotalHeight() {
|
|
2202
|
-
return ((this.virtualScroll.isEnabled() &&
|
|
2203
|
-
this.virtualScroll.totalHeight + 'px') ||
|
|
2204
|
-
'auto');
|
|
2205
|
-
}
|
|
2206
|
-
throttle(func, timeFrame) {
|
|
2207
|
-
let lastTime = 0;
|
|
2208
|
-
return function () {
|
|
2209
|
-
let now = Date.now();
|
|
2210
|
-
if (now - lastTime >= timeFrame) {
|
|
2211
|
-
func();
|
|
2212
|
-
lastTime = now;
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
}
|
|
2216
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2217
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2176
|
+
class TreeViewportComponent {
|
|
2177
|
+
constructor(elementRef, virtualScroll) {
|
|
2178
|
+
this.elementRef = elementRef;
|
|
2179
|
+
this.virtualScroll = virtualScroll;
|
|
2180
|
+
this.setViewport = this.throttle(() => {
|
|
2181
|
+
this.virtualScroll.setViewport(this.elementRef.nativeElement);
|
|
2182
|
+
}, 17);
|
|
2183
|
+
this.scrollEventHandler = this.setViewport.bind(this);
|
|
2184
|
+
}
|
|
2185
|
+
ngOnInit() {
|
|
2186
|
+
this.virtualScroll.init();
|
|
2187
|
+
}
|
|
2188
|
+
ngAfterViewInit() {
|
|
2189
|
+
setTimeout(() => {
|
|
2190
|
+
this.setViewport();
|
|
2191
|
+
this.virtualScroll.fireEvent({ eventName: TREE_EVENTS.initialized });
|
|
2192
|
+
});
|
|
2193
|
+
let el = this.elementRef.nativeElement;
|
|
2194
|
+
el.addEventListener('scroll', this.scrollEventHandler);
|
|
2195
|
+
}
|
|
2196
|
+
ngOnDestroy() {
|
|
2197
|
+
this.virtualScroll.clear();
|
|
2198
|
+
let el = this.elementRef.nativeElement;
|
|
2199
|
+
el.removeEventListener('scroll', this.scrollEventHandler);
|
|
2200
|
+
}
|
|
2201
|
+
getTotalHeight() {
|
|
2202
|
+
return ((this.virtualScroll.isEnabled() &&
|
|
2203
|
+
this.virtualScroll.totalHeight + 'px') ||
|
|
2204
|
+
'auto');
|
|
2205
|
+
}
|
|
2206
|
+
throttle(func, timeFrame) {
|
|
2207
|
+
let lastTime = 0;
|
|
2208
|
+
return function () {
|
|
2209
|
+
let now = Date.now();
|
|
2210
|
+
if (now - lastTime >= timeFrame) {
|
|
2211
|
+
func();
|
|
2212
|
+
lastTime = now;
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeViewportComponent, deps: [{ token: i0.ElementRef }, { token: TreeVirtualScroll }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2217
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeViewportComponent, selector: "tree-viewport", providers: [TreeVirtualScroll], ngImport: i0, template: `
|
|
2218
2218
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2219
2219
|
<div [style.height]="getTotalHeight()">
|
|
2220
2220
|
<ng-content></ng-content>
|
|
2221
2221
|
</div>
|
|
2222
2222
|
</ng-container>
|
|
2223
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }] }); }
|
|
2224
|
-
}
|
|
2225
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2226
|
-
type: Component,
|
|
2223
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }] }); }
|
|
2224
|
+
}
|
|
2225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeViewportComponent, decorators: [{
|
|
2226
|
+
type: Component,
|
|
2227
2227
|
args: [{ selector: 'tree-viewport', providers: [TreeVirtualScroll], template: `
|
|
2228
2228
|
<ng-container *treeMobxAutorun="{ dontDetach: true }">
|
|
2229
2229
|
<div [style.height]="getTotalHeight()">
|
|
2230
2230
|
<ng-content></ng-content>
|
|
2231
2231
|
</div>
|
|
2232
2232
|
</ng-container>
|
|
2233
|
-
` }]
|
|
2234
|
-
}], ctorParameters:
|
|
2233
|
+
` }]
|
|
2234
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: TreeVirtualScroll }] });
|
|
2235
2235
|
|
|
2236
|
-
class TreeComponent {
|
|
2237
|
-
// Will be handled in ngOnChanges
|
|
2238
|
-
set nodes(nodes) {
|
|
2239
|
-
}
|
|
2240
|
-
;
|
|
2241
|
-
set options(options) {
|
|
2242
|
-
}
|
|
2243
|
-
;
|
|
2244
|
-
set focused(value) {
|
|
2245
|
-
this.treeModel.setFocus(value);
|
|
2246
|
-
}
|
|
2247
|
-
set state(state) {
|
|
2248
|
-
this.treeModel.setState(state);
|
|
2249
|
-
}
|
|
2250
|
-
constructor(treeModel, treeDraggedElement) {
|
|
2251
|
-
this.treeModel = treeModel;
|
|
2252
|
-
this.treeDraggedElement = treeDraggedElement;
|
|
2253
|
-
treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
|
|
2254
|
-
treeModel.subscribeToState((state) => this.stateChange.emit(state));
|
|
2255
|
-
}
|
|
2256
|
-
onKeydown($event) {
|
|
2257
|
-
if (!this.treeModel.isFocused)
|
|
2258
|
-
return;
|
|
2259
|
-
if (['input', 'textarea'].includes(document.activeElement.tagName.toLowerCase()))
|
|
2260
|
-
return;
|
|
2261
|
-
const focusedNode = this.treeModel.getFocusedNode();
|
|
2262
|
-
this.treeModel.performKeyAction(focusedNode, $event);
|
|
2263
|
-
}
|
|
2264
|
-
onMousedown($event) {
|
|
2265
|
-
function isOutsideClick(startElement, nodeName) {
|
|
2266
|
-
return !startElement ? true : startElement.localName === nodeName ? false : isOutsideClick(startElement.parentElement, nodeName);
|
|
2267
|
-
}
|
|
2268
|
-
if (isOutsideClick($event.target, 'tree-root')) {
|
|
2269
|
-
this.treeModel.setFocus(false);
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
ngOnChanges(changes) {
|
|
2273
|
-
if (changes.options || changes.nodes) {
|
|
2274
|
-
this.treeModel.setData({
|
|
2275
|
-
options: changes.options && changes.options.currentValue,
|
|
2276
|
-
nodes: changes.nodes && changes.nodes.currentValue,
|
|
2277
|
-
events: this.pick(this, this.treeModel.eventNames)
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
sizeChanged() {
|
|
2282
|
-
this.viewportComponent.setViewport();
|
|
2283
|
-
}
|
|
2284
|
-
pick(object, keys) {
|
|
2285
|
-
return keys.reduce((obj, key) => {
|
|
2286
|
-
if (object && object.hasOwnProperty(key)) {
|
|
2287
|
-
obj[key] = object[key];
|
|
2288
|
-
}
|
|
2289
|
-
return obj;
|
|
2290
|
-
}, {});
|
|
2291
|
-
}
|
|
2292
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2293
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2236
|
+
class TreeComponent {
|
|
2237
|
+
// Will be handled in ngOnChanges
|
|
2238
|
+
set nodes(nodes) {
|
|
2239
|
+
}
|
|
2240
|
+
;
|
|
2241
|
+
set options(options) {
|
|
2242
|
+
}
|
|
2243
|
+
;
|
|
2244
|
+
set focused(value) {
|
|
2245
|
+
this.treeModel.setFocus(value);
|
|
2246
|
+
}
|
|
2247
|
+
set state(state) {
|
|
2248
|
+
this.treeModel.setState(state);
|
|
2249
|
+
}
|
|
2250
|
+
constructor(treeModel, treeDraggedElement) {
|
|
2251
|
+
this.treeModel = treeModel;
|
|
2252
|
+
this.treeDraggedElement = treeDraggedElement;
|
|
2253
|
+
treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
|
|
2254
|
+
treeModel.subscribeToState((state) => this.stateChange.emit(state));
|
|
2255
|
+
}
|
|
2256
|
+
onKeydown($event) {
|
|
2257
|
+
if (!this.treeModel.isFocused)
|
|
2258
|
+
return;
|
|
2259
|
+
if (['input', 'textarea'].includes(document.activeElement.tagName.toLowerCase()))
|
|
2260
|
+
return;
|
|
2261
|
+
const focusedNode = this.treeModel.getFocusedNode();
|
|
2262
|
+
this.treeModel.performKeyAction(focusedNode, $event);
|
|
2263
|
+
}
|
|
2264
|
+
onMousedown($event) {
|
|
2265
|
+
function isOutsideClick(startElement, nodeName) {
|
|
2266
|
+
return !startElement ? true : startElement.localName === nodeName ? false : isOutsideClick(startElement.parentElement, nodeName);
|
|
2267
|
+
}
|
|
2268
|
+
if (isOutsideClick($event.target, 'tree-root')) {
|
|
2269
|
+
this.treeModel.setFocus(false);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
ngOnChanges(changes) {
|
|
2273
|
+
if (changes.options || changes.nodes) {
|
|
2274
|
+
this.treeModel.setData({
|
|
2275
|
+
options: changes.options && changes.options.currentValue,
|
|
2276
|
+
nodes: changes.nodes && changes.nodes.currentValue,
|
|
2277
|
+
events: this.pick(this, this.treeModel.eventNames)
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
sizeChanged() {
|
|
2282
|
+
this.viewportComponent.setViewport();
|
|
2283
|
+
}
|
|
2284
|
+
pick(object, keys) {
|
|
2285
|
+
return keys.reduce((obj, key) => {
|
|
2286
|
+
if (object && object.hasOwnProperty(key)) {
|
|
2287
|
+
obj[key] = object[key];
|
|
2288
|
+
}
|
|
2289
|
+
return obj;
|
|
2290
|
+
}, {});
|
|
2291
|
+
}
|
|
2292
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeComponent, deps: [{ token: TreeModel }, { token: TreeDraggedElement }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2293
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: TreeComponent, selector: "Tree, tree-root", inputs: { nodes: "nodes", options: "options", focused: "focused", state: "state" }, outputs: { toggleExpanded: "toggleExpanded", activate: "activate", deactivate: "deactivate", nodeActivate: "nodeActivate", nodeDeactivate: "nodeDeactivate", select: "select", deselect: "deselect", focus: "focus", blur: "blur", updateData: "updateData", initialized: "initialized", moveNode: "moveNode", copyNode: "copyNode", loadNodeChildren: "loadNodeChildren", changeFilter: "changeFilter", event: "event", stateChange: "stateChange" }, host: { listeners: { "body: keydown": "onKeydown($event)", "body: mousedown": "onMousedown($event)" } }, providers: [TreeModel], queries: [{ propertyName: "loadingTemplate", first: true, predicate: ["loadingTemplate"], descendants: true }, { propertyName: "treeNodeTemplate", first: true, predicate: ["treeNodeTemplate"], descendants: true }, { propertyName: "treeNodeWrapperTemplate", first: true, predicate: ["treeNodeWrapperTemplate"], descendants: true }, { propertyName: "treeNodeFullTemplate", first: true, predicate: ["treeNodeFullTemplate"], descendants: true }], viewQueries: [{ propertyName: "viewportComponent", first: true, predicate: ["viewport"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
2294
2294
|
<tree-viewport #viewport>
|
|
2295
2295
|
<div
|
|
2296
2296
|
class="angular-tree-component"
|
|
@@ -2315,10 +2315,10 @@ class TreeComponent {
|
|
|
2315
2315
|
</tree-node-drop-slot>
|
|
2316
2316
|
</div>
|
|
2317
2317
|
</tree-viewport>
|
|
2318
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: ["node", "dropIndex"] }, { kind: "component", type: TreeNodeCollectionComponent, selector: "tree-node-collection", inputs: ["nodes", "treeModel", "templates"] }, { kind: "component", type: TreeViewportComponent, selector: "tree-viewport" }] }); }
|
|
2319
|
-
}
|
|
2320
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2321
|
-
type: Component,
|
|
2318
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: ["node", "dropIndex"] }, { kind: "component", type: TreeNodeCollectionComponent, selector: "tree-node-collection", inputs: ["nodes", "treeModel", "templates"] }, { kind: "component", type: TreeViewportComponent, selector: "tree-viewport" }] }); }
|
|
2319
|
+
}
|
|
2320
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeComponent, decorators: [{
|
|
2321
|
+
type: Component,
|
|
2322
2322
|
args: [{ selector: 'Tree, tree-root', providers: [TreeModel], template: `
|
|
2323
2323
|
<tree-viewport #viewport>
|
|
2324
2324
|
<div
|
|
@@ -2344,153 +2344,153 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
2344
2344
|
</tree-node-drop-slot>
|
|
2345
2345
|
</div>
|
|
2346
2346
|
</tree-viewport>
|
|
2347
|
-
` }]
|
|
2348
|
-
}], ctorParameters:
|
|
2349
|
-
type: ContentChild,
|
|
2350
|
-
args: ['loadingTemplate', { static: false }]
|
|
2351
|
-
}], treeNodeTemplate: [{
|
|
2352
|
-
type: ContentChild,
|
|
2353
|
-
args: ['treeNodeTemplate', { static: false }]
|
|
2354
|
-
}], treeNodeWrapperTemplate: [{
|
|
2355
|
-
type: ContentChild,
|
|
2356
|
-
args: ['treeNodeWrapperTemplate', { static: false }]
|
|
2357
|
-
}], treeNodeFullTemplate: [{
|
|
2358
|
-
type: ContentChild,
|
|
2359
|
-
args: ['treeNodeFullTemplate', { static: false }]
|
|
2360
|
-
}], viewportComponent: [{
|
|
2361
|
-
type: ViewChild,
|
|
2362
|
-
args: ['viewport', { static: false }]
|
|
2363
|
-
}], nodes: [{
|
|
2364
|
-
type: Input
|
|
2365
|
-
}], options: [{
|
|
2366
|
-
type: Input
|
|
2367
|
-
}], focused: [{
|
|
2368
|
-
type: Input
|
|
2369
|
-
}], state: [{
|
|
2370
|
-
type: Input
|
|
2371
|
-
}], toggleExpanded: [{
|
|
2372
|
-
type: Output
|
|
2373
|
-
}], activate: [{
|
|
2374
|
-
type: Output
|
|
2375
|
-
}], deactivate: [{
|
|
2376
|
-
type: Output
|
|
2377
|
-
}], nodeActivate: [{
|
|
2378
|
-
type: Output
|
|
2379
|
-
}], nodeDeactivate: [{
|
|
2380
|
-
type: Output
|
|
2381
|
-
}], select: [{
|
|
2382
|
-
type: Output
|
|
2383
|
-
}], deselect: [{
|
|
2384
|
-
type: Output
|
|
2385
|
-
}], focus: [{
|
|
2386
|
-
type: Output
|
|
2387
|
-
}], blur: [{
|
|
2388
|
-
type: Output
|
|
2389
|
-
}], updateData: [{
|
|
2390
|
-
type: Output
|
|
2391
|
-
}], initialized: [{
|
|
2392
|
-
type: Output
|
|
2393
|
-
}], moveNode: [{
|
|
2394
|
-
type: Output
|
|
2395
|
-
}], copyNode: [{
|
|
2396
|
-
type: Output
|
|
2397
|
-
}], loadNodeChildren: [{
|
|
2398
|
-
type: Output
|
|
2399
|
-
}], changeFilter: [{
|
|
2400
|
-
type: Output
|
|
2401
|
-
}], event: [{
|
|
2402
|
-
type: Output
|
|
2403
|
-
}], stateChange: [{
|
|
2404
|
-
type: Output
|
|
2405
|
-
}], onKeydown: [{
|
|
2406
|
-
type: HostListener,
|
|
2407
|
-
args: ['body: keydown', ['$event']]
|
|
2408
|
-
}], onMousedown: [{
|
|
2409
|
-
type: HostListener,
|
|
2410
|
-
args: ['body: mousedown', ['$event']]
|
|
2347
|
+
` }]
|
|
2348
|
+
}], ctorParameters: () => [{ type: TreeModel }, { type: TreeDraggedElement }], propDecorators: { loadingTemplate: [{
|
|
2349
|
+
type: ContentChild,
|
|
2350
|
+
args: ['loadingTemplate', { static: false }]
|
|
2351
|
+
}], treeNodeTemplate: [{
|
|
2352
|
+
type: ContentChild,
|
|
2353
|
+
args: ['treeNodeTemplate', { static: false }]
|
|
2354
|
+
}], treeNodeWrapperTemplate: [{
|
|
2355
|
+
type: ContentChild,
|
|
2356
|
+
args: ['treeNodeWrapperTemplate', { static: false }]
|
|
2357
|
+
}], treeNodeFullTemplate: [{
|
|
2358
|
+
type: ContentChild,
|
|
2359
|
+
args: ['treeNodeFullTemplate', { static: false }]
|
|
2360
|
+
}], viewportComponent: [{
|
|
2361
|
+
type: ViewChild,
|
|
2362
|
+
args: ['viewport', { static: false }]
|
|
2363
|
+
}], nodes: [{
|
|
2364
|
+
type: Input
|
|
2365
|
+
}], options: [{
|
|
2366
|
+
type: Input
|
|
2367
|
+
}], focused: [{
|
|
2368
|
+
type: Input
|
|
2369
|
+
}], state: [{
|
|
2370
|
+
type: Input
|
|
2371
|
+
}], toggleExpanded: [{
|
|
2372
|
+
type: Output
|
|
2373
|
+
}], activate: [{
|
|
2374
|
+
type: Output
|
|
2375
|
+
}], deactivate: [{
|
|
2376
|
+
type: Output
|
|
2377
|
+
}], nodeActivate: [{
|
|
2378
|
+
type: Output
|
|
2379
|
+
}], nodeDeactivate: [{
|
|
2380
|
+
type: Output
|
|
2381
|
+
}], select: [{
|
|
2382
|
+
type: Output
|
|
2383
|
+
}], deselect: [{
|
|
2384
|
+
type: Output
|
|
2385
|
+
}], focus: [{
|
|
2386
|
+
type: Output
|
|
2387
|
+
}], blur: [{
|
|
2388
|
+
type: Output
|
|
2389
|
+
}], updateData: [{
|
|
2390
|
+
type: Output
|
|
2391
|
+
}], initialized: [{
|
|
2392
|
+
type: Output
|
|
2393
|
+
}], moveNode: [{
|
|
2394
|
+
type: Output
|
|
2395
|
+
}], copyNode: [{
|
|
2396
|
+
type: Output
|
|
2397
|
+
}], loadNodeChildren: [{
|
|
2398
|
+
type: Output
|
|
2399
|
+
}], changeFilter: [{
|
|
2400
|
+
type: Output
|
|
2401
|
+
}], event: [{
|
|
2402
|
+
type: Output
|
|
2403
|
+
}], stateChange: [{
|
|
2404
|
+
type: Output
|
|
2405
|
+
}], onKeydown: [{
|
|
2406
|
+
type: HostListener,
|
|
2407
|
+
args: ['body: keydown', ['$event']]
|
|
2408
|
+
}], onMousedown: [{
|
|
2409
|
+
type: HostListener,
|
|
2410
|
+
args: ['body: mousedown', ['$event']]
|
|
2411
2411
|
}] } });
|
|
2412
2412
|
|
|
2413
|
-
class TreeModule {
|
|
2414
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2415
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
2416
|
-
TreeNodeComponent,
|
|
2417
|
-
TreeNodeContent,
|
|
2418
|
-
LoadingComponent,
|
|
2419
|
-
TreeDropDirective,
|
|
2420
|
-
TreeDragDirective,
|
|
2421
|
-
TreeNodeExpanderComponent,
|
|
2422
|
-
TreeNodeChildrenComponent,
|
|
2423
|
-
TreeNodeDropSlot,
|
|
2424
|
-
TreeNodeCollectionComponent,
|
|
2425
|
-
TreeViewportComponent,
|
|
2426
|
-
TreeNodeWrapperComponent,
|
|
2427
|
-
TreeNodeCheckboxComponent,
|
|
2428
|
-
TreeAnimateOpenDirective,
|
|
2429
|
-
TreeMobxAutorunDirective], imports: [CommonModule], exports: [TreeComponent,
|
|
2430
|
-
TreeNodeComponent,
|
|
2431
|
-
TreeNodeContent,
|
|
2432
|
-
LoadingComponent,
|
|
2433
|
-
TreeDropDirective,
|
|
2434
|
-
TreeDragDirective,
|
|
2435
|
-
TreeNodeExpanderComponent,
|
|
2436
|
-
TreeNodeChildrenComponent,
|
|
2437
|
-
TreeNodeDropSlot,
|
|
2438
|
-
TreeNodeCollectionComponent,
|
|
2439
|
-
TreeViewportComponent,
|
|
2440
|
-
TreeNodeWrapperComponent,
|
|
2441
|
-
TreeNodeCheckboxComponent,
|
|
2442
|
-
TreeAnimateOpenDirective,
|
|
2443
|
-
TreeMobxAutorunDirective] }); }
|
|
2444
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
2445
|
-
}
|
|
2446
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2447
|
-
type: NgModule,
|
|
2448
|
-
args: [{
|
|
2449
|
-
declarations: [
|
|
2450
|
-
TreeComponent,
|
|
2451
|
-
TreeNodeComponent,
|
|
2452
|
-
TreeNodeContent,
|
|
2453
|
-
LoadingComponent,
|
|
2454
|
-
TreeDropDirective,
|
|
2455
|
-
TreeDragDirective,
|
|
2456
|
-
TreeNodeExpanderComponent,
|
|
2457
|
-
TreeNodeChildrenComponent,
|
|
2458
|
-
TreeNodeDropSlot,
|
|
2459
|
-
TreeNodeCollectionComponent,
|
|
2460
|
-
TreeViewportComponent,
|
|
2461
|
-
TreeNodeWrapperComponent,
|
|
2462
|
-
TreeNodeCheckboxComponent,
|
|
2463
|
-
TreeAnimateOpenDirective,
|
|
2464
|
-
TreeMobxAutorunDirective
|
|
2465
|
-
],
|
|
2466
|
-
exports: [
|
|
2467
|
-
TreeComponent,
|
|
2468
|
-
TreeNodeComponent,
|
|
2469
|
-
TreeNodeContent,
|
|
2470
|
-
LoadingComponent,
|
|
2471
|
-
TreeDropDirective,
|
|
2472
|
-
TreeDragDirective,
|
|
2473
|
-
TreeNodeExpanderComponent,
|
|
2474
|
-
TreeNodeChildrenComponent,
|
|
2475
|
-
TreeNodeDropSlot,
|
|
2476
|
-
TreeNodeCollectionComponent,
|
|
2477
|
-
TreeViewportComponent,
|
|
2478
|
-
TreeNodeWrapperComponent,
|
|
2479
|
-
TreeNodeCheckboxComponent,
|
|
2480
|
-
TreeAnimateOpenDirective,
|
|
2481
|
-
TreeMobxAutorunDirective
|
|
2482
|
-
],
|
|
2483
|
-
imports: [CommonModule],
|
|
2484
|
-
providers: []
|
|
2485
|
-
}]
|
|
2413
|
+
class TreeModule {
|
|
2414
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2415
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: TreeModule, declarations: [TreeComponent,
|
|
2416
|
+
TreeNodeComponent,
|
|
2417
|
+
TreeNodeContent,
|
|
2418
|
+
LoadingComponent,
|
|
2419
|
+
TreeDropDirective,
|
|
2420
|
+
TreeDragDirective,
|
|
2421
|
+
TreeNodeExpanderComponent,
|
|
2422
|
+
TreeNodeChildrenComponent,
|
|
2423
|
+
TreeNodeDropSlot,
|
|
2424
|
+
TreeNodeCollectionComponent,
|
|
2425
|
+
TreeViewportComponent,
|
|
2426
|
+
TreeNodeWrapperComponent,
|
|
2427
|
+
TreeNodeCheckboxComponent,
|
|
2428
|
+
TreeAnimateOpenDirective,
|
|
2429
|
+
TreeMobxAutorunDirective], imports: [CommonModule], exports: [TreeComponent,
|
|
2430
|
+
TreeNodeComponent,
|
|
2431
|
+
TreeNodeContent,
|
|
2432
|
+
LoadingComponent,
|
|
2433
|
+
TreeDropDirective,
|
|
2434
|
+
TreeDragDirective,
|
|
2435
|
+
TreeNodeExpanderComponent,
|
|
2436
|
+
TreeNodeChildrenComponent,
|
|
2437
|
+
TreeNodeDropSlot,
|
|
2438
|
+
TreeNodeCollectionComponent,
|
|
2439
|
+
TreeViewportComponent,
|
|
2440
|
+
TreeNodeWrapperComponent,
|
|
2441
|
+
TreeNodeCheckboxComponent,
|
|
2442
|
+
TreeAnimateOpenDirective,
|
|
2443
|
+
TreeMobxAutorunDirective] }); }
|
|
2444
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModule, imports: [CommonModule] }); }
|
|
2445
|
+
}
|
|
2446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TreeModule, decorators: [{
|
|
2447
|
+
type: NgModule,
|
|
2448
|
+
args: [{
|
|
2449
|
+
declarations: [
|
|
2450
|
+
TreeComponent,
|
|
2451
|
+
TreeNodeComponent,
|
|
2452
|
+
TreeNodeContent,
|
|
2453
|
+
LoadingComponent,
|
|
2454
|
+
TreeDropDirective,
|
|
2455
|
+
TreeDragDirective,
|
|
2456
|
+
TreeNodeExpanderComponent,
|
|
2457
|
+
TreeNodeChildrenComponent,
|
|
2458
|
+
TreeNodeDropSlot,
|
|
2459
|
+
TreeNodeCollectionComponent,
|
|
2460
|
+
TreeViewportComponent,
|
|
2461
|
+
TreeNodeWrapperComponent,
|
|
2462
|
+
TreeNodeCheckboxComponent,
|
|
2463
|
+
TreeAnimateOpenDirective,
|
|
2464
|
+
TreeMobxAutorunDirective
|
|
2465
|
+
],
|
|
2466
|
+
exports: [
|
|
2467
|
+
TreeComponent,
|
|
2468
|
+
TreeNodeComponent,
|
|
2469
|
+
TreeNodeContent,
|
|
2470
|
+
LoadingComponent,
|
|
2471
|
+
TreeDropDirective,
|
|
2472
|
+
TreeDragDirective,
|
|
2473
|
+
TreeNodeExpanderComponent,
|
|
2474
|
+
TreeNodeChildrenComponent,
|
|
2475
|
+
TreeNodeDropSlot,
|
|
2476
|
+
TreeNodeCollectionComponent,
|
|
2477
|
+
TreeViewportComponent,
|
|
2478
|
+
TreeNodeWrapperComponent,
|
|
2479
|
+
TreeNodeCheckboxComponent,
|
|
2480
|
+
TreeAnimateOpenDirective,
|
|
2481
|
+
TreeMobxAutorunDirective
|
|
2482
|
+
],
|
|
2483
|
+
imports: [CommonModule],
|
|
2484
|
+
providers: []
|
|
2485
|
+
}]
|
|
2486
2486
|
}] });
|
|
2487
2487
|
|
|
2488
|
-
/*
|
|
2489
|
-
* Public API Surface of angular-tree-component
|
|
2488
|
+
/*
|
|
2489
|
+
* Public API Surface of angular-tree-component
|
|
2490
2490
|
*/
|
|
2491
2491
|
|
|
2492
|
-
/**
|
|
2493
|
-
* Generated bundle index. Do not edit.
|
|
2492
|
+
/**
|
|
2493
|
+
* Generated bundle index. Do not edit.
|
|
2494
2494
|
*/
|
|
2495
2495
|
|
|
2496
2496
|
export { KEYS, LoadingComponent, TREE_ACTIONS, TreeAnimateOpenDirective, TreeComponent, TreeDragDirective, TreeDraggedElement, TreeDropDirective, TreeMobxAutorunDirective, TreeModel, TreeModule, TreeNode, TreeNodeCheckboxComponent, TreeNodeChildrenComponent, TreeNodeCollectionComponent, TreeNodeComponent, TreeNodeContent, TreeNodeDropSlot, TreeNodeExpanderComponent, TreeNodeWrapperComponent, TreeViewportComponent, TreeVirtualScroll };
|