@ali-hm/angular-tree-component 12.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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/css/angular-tree-component.css +84 -0
  4. package/esm2020/ali-hm-angular-tree-component.mjs +5 -0
  5. package/esm2020/lib/angular-tree-component.module.mjs +100 -0
  6. package/esm2020/lib/components/loading.component.mjs +32 -0
  7. package/esm2020/lib/components/tree-node-checkbox.component.mjs +34 -0
  8. package/esm2020/lib/components/tree-node-collection.component.mjs +284 -0
  9. package/esm2020/lib/components/tree-node-content.component.mjs +32 -0
  10. package/esm2020/lib/components/tree-node-drop-slot.component.mjs +39 -0
  11. package/esm2020/lib/components/tree-node-expander.component.mjs +43 -0
  12. package/esm2020/lib/components/tree-node-wrapper.component.mjs +81 -0
  13. package/esm2020/lib/components/tree-viewport.component.mjs +66 -0
  14. package/esm2020/lib/components/tree.component.mjs +186 -0
  15. package/esm2020/lib/constants/events.mjs +20 -0
  16. package/esm2020/lib/constants/keys.mjs +10 -0
  17. package/esm2020/lib/defs/api.mjs +2 -0
  18. package/esm2020/lib/directives/tree-animate-open.directive.mjs +101 -0
  19. package/esm2020/lib/directives/tree-drag.directive.mjs +65 -0
  20. package/esm2020/lib/directives/tree-drop.directive.mjs +127 -0
  21. package/esm2020/lib/mobx-angular/mobx-proxy.mjs +17 -0
  22. package/esm2020/lib/mobx-angular/tree-mobx-autorun.directive.mjs +40 -0
  23. package/esm2020/lib/models/tree-dragged-element.model.mjs +25 -0
  24. package/esm2020/lib/models/tree-node.model.mjs +390 -0
  25. package/esm2020/lib/models/tree-options.model.mjs +150 -0
  26. package/esm2020/lib/models/tree-virtual-scroll.model.mjs +197 -0
  27. package/esm2020/lib/models/tree.model.mjs +546 -0
  28. package/esm2020/public-api.mjs +5 -0
  29. package/fesm2015/ali-hm-angular-tree-component.mjs +2511 -0
  30. package/fesm2015/ali-hm-angular-tree-component.mjs.map +1 -0
  31. package/fesm2020/ali-hm-angular-tree-component.mjs +2497 -0
  32. package/fesm2020/ali-hm-angular-tree-component.mjs.map +1 -0
  33. package/index.d.ts +5 -0
  34. package/lib/angular-tree-component.module.d.ts +43 -0
  35. package/lib/components/loading.component.d.ts +9 -0
  36. package/lib/components/tree-node-checkbox.component.d.ts +7 -0
  37. package/lib/components/tree-node-collection.component.d.ts +34 -0
  38. package/lib/components/tree-node-content.component.d.ts +10 -0
  39. package/lib/components/tree-node-drop-slot.component.d.ts +10 -0
  40. package/lib/components/tree-node-expander.component.d.ts +7 -0
  41. package/lib/components/tree-node-wrapper.component.d.ts +9 -0
  42. package/lib/components/tree-viewport.component.d.ts +17 -0
  43. package/lib/components/tree.component.d.ts +47 -0
  44. package/lib/constants/events.d.ts +19 -0
  45. package/lib/constants/keys.d.ts +9 -0
  46. package/lib/defs/api.d.ts +611 -0
  47. package/lib/directives/tree-animate-open.directive.d.ts +20 -0
  48. package/lib/directives/tree-drag.directive.d.ts +21 -0
  49. package/lib/directives/tree-drop.directive.d.ts +33 -0
  50. package/lib/mobx-angular/mobx-proxy.d.ts +7 -0
  51. package/lib/mobx-angular/tree-mobx-autorun.directive.d.ts +17 -0
  52. package/lib/models/tree-dragged-element.model.d.ts +9 -0
  53. package/lib/models/tree-node.model.d.ts +83 -0
  54. package/lib/models/tree-options.model.d.ts +77 -0
  55. package/lib/models/tree-virtual-scroll.model.d.ts +27 -0
  56. package/lib/models/tree.model.d.ts +91 -0
  57. package/package.json +66 -0
  58. package/public-api.d.ts +1 -0
  59. package/src/lib/angular-tree-component.css +84 -0
@@ -0,0 +1,2497 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, Input, Injectable, Component, ViewEncapsulation, EventEmitter, Output, HostListener, ContentChild, ViewChild, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { autorun, reaction, computed as computed$1, observable as observable$1, action as action$1 } from 'mobx';
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
+ }
35
+ /** @nocollapse */ TreeMobxAutorunDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeMobxAutorunDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
36
+ /** @nocollapse */ TreeMobxAutorunDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: { treeMobxAutorun: "treeMobxAutorun" }, ngImport: i0 });
37
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeMobxAutorunDirective, decorators: [{
38
+ type: Directive,
39
+ args: [{ selector: '[treeMobxAutorun]' }]
40
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { treeMobxAutorun: [{
41
+ type: Input
42
+ }] } });
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
52
+ };
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
+ constructor(options = {}) {
100
+ this.options = options;
101
+ this.actionMapping = {
102
+ mouse: {
103
+ click: this.options?.actionMapping?.mouse?.click ?? defaultActionMapping.mouse.click,
104
+ dblClick: this.options?.actionMapping?.mouse?.dblClick ?? defaultActionMapping.mouse.dblClick,
105
+ contextMenu: this.options?.actionMapping?.mouse?.contextMenu ?? defaultActionMapping.mouse.contextMenu,
106
+ expanderClick: this.options?.actionMapping?.mouse?.expanderClick ?? defaultActionMapping.mouse.expanderClick,
107
+ checkboxClick: this.options?.actionMapping?.mouse?.checkboxClick ?? defaultActionMapping.mouse.checkboxClick,
108
+ drop: this.options?.actionMapping?.mouse?.drop ?? defaultActionMapping.mouse.drop,
109
+ dragStart: this.options?.actionMapping?.mouse?.dragStart ?? undefined,
110
+ drag: this.options?.actionMapping?.mouse?.drag ?? undefined,
111
+ dragEnd: this.options?.actionMapping?.mouse?.dragEnd ?? undefined,
112
+ dragOver: this.options?.actionMapping?.mouse?.dragOver ?? undefined,
113
+ dragLeave: this.options?.actionMapping?.mouse?.dragLeave ?? undefined,
114
+ dragEnter: this.options?.actionMapping?.mouse?.dragEnter ?? undefined,
115
+ mouseOver: this.options?.actionMapping?.mouse?.mouseOver ?? undefined,
116
+ mouseOut: this.options?.actionMapping?.mouse?.mouseOut ?? undefined,
117
+ },
118
+ keys: {
119
+ [KEYS.RIGHT]: TREE_ACTIONS.DRILL_DOWN,
120
+ [KEYS.LEFT]: TREE_ACTIONS.DRILL_UP,
121
+ [KEYS.DOWN]: TREE_ACTIONS.NEXT_NODE,
122
+ [KEYS.UP]: TREE_ACTIONS.PREVIOUS_NODE,
123
+ [KEYS.SPACE]: TREE_ACTIONS.TOGGLE_ACTIVE,
124
+ [KEYS.ENTER]: TREE_ACTIONS.TOGGLE_ACTIVE
125
+ }
126
+ };
127
+ if (this.options?.actionMapping?.keys) {
128
+ this.actionMapping.keys = {
129
+ ...this.actionMapping.keys,
130
+ ...this.options.actionMapping.keys
131
+ };
132
+ }
133
+ if (options.rtl) {
134
+ this.actionMapping.keys[KEYS.RIGHT] = options.actionMapping?.keys[KEYS.RIGHT] || TREE_ACTIONS.DRILL_UP;
135
+ this.actionMapping.keys[KEYS.LEFT] = options.actionMapping?.keys[KEYS.LEFT] || TREE_ACTIONS.DRILL_DOWN;
136
+ }
137
+ }
138
+ get hasChildrenField() { return this.options.hasChildrenField || 'hasChildren'; }
139
+ get childrenField() { return this.options.childrenField || 'children'; }
140
+ get displayField() { return this.options.displayField || 'name'; }
141
+ get idField() { return this.options.idField || 'id'; }
142
+ get isExpandedField() { return this.options.isExpandedField || 'isExpanded'; }
143
+ get getChildren() { return this.options.getChildren; }
144
+ get levelPadding() { return this.options.levelPadding || 0; }
145
+ get useVirtualScroll() { return this.options.useVirtualScroll; }
146
+ get animateExpand() { return this.options.animateExpand; }
147
+ get animateSpeed() { return this.options.animateSpeed || 1; }
148
+ get animateAcceleration() { return this.options.animateAcceleration || 1.2; }
149
+ get scrollOnActivate() { return this.options.scrollOnActivate === undefined ? true : this.options.scrollOnActivate; }
150
+ get rtl() { return !!this.options.rtl; }
151
+ get rootId() { return this.options.rootId; }
152
+ get useCheckbox() { return this.options.useCheckbox; }
153
+ get useTriState() { return this.options.useTriState === undefined ? true : this.options.useTriState; }
154
+ get scrollContainer() { return this.options.scrollContainer; }
155
+ get allowDragoverStyling() { return this.options.allowDragoverStyling === undefined ? true : this.options.allowDragoverStyling; }
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
+ }
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'
221
+ };
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
+ constructor(data, parent, treeModel, index) {
231
+ this.data = data;
232
+ this.parent = parent;
233
+ this.treeModel = treeModel;
234
+ this.position = 0;
235
+ this.allowDrop = (element, $event) => {
236
+ return this.options.allowDrop(element, { parent: this, index: 0 }, $event);
237
+ };
238
+ this.allowDragoverStyling = () => {
239
+ return this.options.allowDragoverStyling;
240
+ };
241
+ if (this.id === undefined || this.id === null) {
242
+ this.id = uuid();
243
+ } // Make sure there's a unique id without overriding existing ids to work with immutable data structures
244
+ this.index = index;
245
+ if (this.getField('children')) {
246
+ this._initChildren();
247
+ }
248
+ this.autoLoadChildren();
249
+ }
250
+ get isHidden() { return this.treeModel.isHidden(this); }
251
+ ;
252
+ get isExpanded() { return this.treeModel.isExpanded(this); }
253
+ ;
254
+ get isActive() { return this.treeModel.isActive(this); }
255
+ ;
256
+ get isFocused() { return this.treeModel.isNodeFocused(this); }
257
+ ;
258
+ get isSelected() {
259
+ if (this.isSelectable()) {
260
+ return this.treeModel.isSelected(this);
261
+ }
262
+ else {
263
+ return this.children.some((node) => node.isSelected);
264
+ }
265
+ }
266
+ ;
267
+ get isAllSelected() {
268
+ if (this.isSelectable()) {
269
+ return this.treeModel.isSelected(this);
270
+ }
271
+ else {
272
+ return this.children.every((node) => node.isAllSelected);
273
+ }
274
+ }
275
+ ;
276
+ get isPartiallySelected() {
277
+ return this.isSelected && !this.isAllSelected;
278
+ }
279
+ get level() {
280
+ return this.parent ? this.parent.level + 1 : 0;
281
+ }
282
+ get path() {
283
+ return this.parent ? [...this.parent.path, this.id] : [];
284
+ }
285
+ get elementRef() {
286
+ throw `Element Ref is no longer supported since introducing virtual scroll\n
287
+ You may use a template to obtain a reference to the element`;
288
+ }
289
+ get originalNode() { return this._originalNode; }
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
+ }
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
+ // events
630
+ fireEvent(event) {
631
+ event.treeModel = this;
632
+ this.events[event.eventName].emit(event);
633
+ this.events.event.emit(event);
634
+ }
635
+ subscribe(eventName, fn) {
636
+ const subscription = this.events[eventName].subscribe(fn);
637
+ this.subscriptions.push(subscription);
638
+ }
639
+ // getters
640
+ getFocusedNode() {
641
+ return this.focusedNode;
642
+ }
643
+ getActiveNode() {
644
+ return this.activeNodes[0];
645
+ }
646
+ getActiveNodes() {
647
+ return this.activeNodes;
648
+ }
649
+ getVisibleRoots() {
650
+ return this.virtualRoot.visibleChildren;
651
+ }
652
+ getFirstRoot(skipHidden = false) {
653
+ const root = skipHidden ? this.getVisibleRoots() : this.roots;
654
+ return root != null && root.length ? root[0] : null;
655
+ }
656
+ getLastRoot(skipHidden = false) {
657
+ const root = skipHidden ? this.getVisibleRoots() : this.roots;
658
+ return root != null && root.length ? root[root.length - 1] : null;
659
+ }
660
+ get isFocused() {
661
+ return TreeModel.focusedTree === this;
662
+ }
663
+ isNodeFocused(node) {
664
+ return this.focusedNode === node;
665
+ }
666
+ isEmptyTree() {
667
+ return this.roots && this.roots.length === 0;
668
+ }
669
+ get focusedNode() {
670
+ return this.focusedNodeId ? this.getNodeById(this.focusedNodeId) : null;
671
+ }
672
+ get expandedNodes() {
673
+ const nodes = Object.keys(this.expandedNodeIds)
674
+ .filter((id) => this.expandedNodeIds[id])
675
+ .map((id) => this.getNodeById(id));
676
+ return nodes.filter(Boolean);
677
+ }
678
+ get activeNodes() {
679
+ const nodes = Object.keys(this.activeNodeIds)
680
+ .filter((id) => this.activeNodeIds[id])
681
+ .map((id) => this.getNodeById(id));
682
+ return nodes.filter(Boolean);
683
+ }
684
+ get hiddenNodes() {
685
+ const nodes = Object.keys(this.hiddenNodeIds)
686
+ .filter((id) => this.hiddenNodeIds[id])
687
+ .map((id) => this.getNodeById(id));
688
+ return nodes.filter(Boolean);
689
+ }
690
+ get selectedLeafNodes() {
691
+ const nodes = Object.keys(this.selectedLeafNodeIds)
692
+ .filter((id) => this.selectedLeafNodeIds[id])
693
+ .map((id) => this.getNodeById(id));
694
+ return nodes.filter(Boolean);
695
+ }
696
+ // locating nodes
697
+ getNodeByPath(path, startNode = null) {
698
+ if (!path)
699
+ return null;
700
+ startNode = startNode || this.virtualRoot;
701
+ if (path.length === 0)
702
+ return startNode;
703
+ if (!startNode.children)
704
+ return null;
705
+ const childId = path.shift();
706
+ const childNode = startNode.children.find(c => c.id === childId);
707
+ if (!childNode)
708
+ return null;
709
+ return this.getNodeByPath(path, childNode);
710
+ }
711
+ getNodeById(id) {
712
+ const idStr = id.toString();
713
+ return this.getNodeBy((node) => node.id.toString() === idStr);
714
+ }
715
+ getNodeBy(predicate, startNode = null) {
716
+ startNode = startNode || this.virtualRoot;
717
+ if (!startNode.children)
718
+ return null;
719
+ const found = startNode.children.find(predicate);
720
+ if (found) { // found in children
721
+ return found;
722
+ }
723
+ else { // look in children's children
724
+ for (let child of startNode.children) {
725
+ const foundInChildren = this.getNodeBy(predicate, child);
726
+ if (foundInChildren)
727
+ return foundInChildren;
728
+ }
729
+ }
730
+ }
731
+ isExpanded(node) {
732
+ return this.expandedNodeIds[node.id];
733
+ }
734
+ isHidden(node) {
735
+ return this.hiddenNodeIds[node.id];
736
+ }
737
+ isActive(node) {
738
+ return this.activeNodeIds[node.id];
739
+ }
740
+ isSelected(node) {
741
+ return this.selectedLeafNodeIds[node.id];
742
+ }
743
+ ngOnDestroy() {
744
+ this.dispose();
745
+ this.unsubscribeAll();
746
+ }
747
+ dispose() {
748
+ // Dispose reactions of the replaced nodes
749
+ if (this.virtualRoot) {
750
+ this.virtualRoot.dispose();
751
+ }
752
+ }
753
+ unsubscribeAll() {
754
+ this.subscriptions.forEach(subscription => subscription.unsubscribe());
755
+ this.subscriptions = [];
756
+ }
757
+ // actions
758
+ setData({ nodes, options = null, events = null }) {
759
+ if (options) {
760
+ this.options = new TreeOptions(options);
761
+ }
762
+ if (events) {
763
+ this.events = events;
764
+ }
765
+ if (nodes) {
766
+ this.nodes = nodes;
767
+ }
768
+ this.update();
769
+ }
770
+ update() {
771
+ // Rebuild tree:
772
+ let virtualRootConfig = {
773
+ id: this.options.rootId,
774
+ virtual: true,
775
+ [this.options.childrenField]: this.nodes
776
+ };
777
+ this.dispose();
778
+ this.virtualRoot = new TreeNode(virtualRootConfig, null, this, 0);
779
+ this.roots = this.virtualRoot.children;
780
+ // Fire event:
781
+ if (this.firstUpdate) {
782
+ if (this.roots) {
783
+ this.firstUpdate = false;
784
+ this._calculateExpandedNodes();
785
+ }
786
+ }
787
+ else {
788
+ this.fireEvent({ eventName: TREE_EVENTS.updateData });
789
+ }
790
+ }
791
+ setFocusedNode(node) {
792
+ this.focusedNodeId = node ? node.id : null;
793
+ }
794
+ setFocus(value) {
795
+ TreeModel.focusedTree = value ? this : null;
796
+ }
797
+ doForAll(fn) {
798
+ this.roots.forEach((root) => root.doForAll(fn));
799
+ }
800
+ focusNextNode() {
801
+ let previousNode = this.getFocusedNode();
802
+ let nextNode = previousNode ? previousNode.findNextNode(true, true) : this.getFirstRoot(true);
803
+ if (nextNode)
804
+ nextNode.focus();
805
+ }
806
+ focusPreviousNode() {
807
+ let previousNode = this.getFocusedNode();
808
+ let nextNode = previousNode ? previousNode.findPreviousNode(true) : this.getLastRoot(true);
809
+ if (nextNode)
810
+ nextNode.focus();
811
+ }
812
+ focusDrillDown() {
813
+ let previousNode = this.getFocusedNode();
814
+ if (previousNode && previousNode.isCollapsed && previousNode.hasChildren) {
815
+ previousNode.toggleExpanded();
816
+ }
817
+ else {
818
+ let nextNode = previousNode ? previousNode.getFirstChild(true) : this.getFirstRoot(true);
819
+ if (nextNode)
820
+ nextNode.focus();
821
+ }
822
+ }
823
+ focusDrillUp() {
824
+ let previousNode = this.getFocusedNode();
825
+ if (!previousNode)
826
+ return;
827
+ if (previousNode.isExpanded) {
828
+ previousNode.toggleExpanded();
829
+ }
830
+ else {
831
+ let nextNode = previousNode.realParent;
832
+ if (nextNode)
833
+ nextNode.focus();
834
+ }
835
+ }
836
+ setActiveNode(node, value, multi = false) {
837
+ if (multi) {
838
+ this._setActiveNodeMulti(node, value);
839
+ }
840
+ else {
841
+ this._setActiveNodeSingle(node, value);
842
+ }
843
+ if (value) {
844
+ node.focus(this.options.scrollOnActivate);
845
+ this.fireEvent({ eventName: TREE_EVENTS.activate, node });
846
+ this.fireEvent({ eventName: TREE_EVENTS.nodeActivate, node }); // For IE11
847
+ }
848
+ else {
849
+ this.fireEvent({ eventName: TREE_EVENTS.deactivate, node });
850
+ this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node }); // For IE11
851
+ }
852
+ }
853
+ setSelectedNode(node, value) {
854
+ this.selectedLeafNodeIds = Object.assign({}, this.selectedLeafNodeIds, { [node.id]: value });
855
+ if (value) {
856
+ node.focus();
857
+ this.fireEvent({ eventName: TREE_EVENTS.select, node });
858
+ }
859
+ else {
860
+ this.fireEvent({ eventName: TREE_EVENTS.deselect, node });
861
+ }
862
+ }
863
+ setExpandedNode(node, value) {
864
+ this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [node.id]: value });
865
+ this.fireEvent({ eventName: TREE_EVENTS.toggleExpanded, node, isExpanded: value });
866
+ }
867
+ expandAll() {
868
+ this.roots.forEach((root) => root.expandAll());
869
+ }
870
+ collapseAll() {
871
+ this.roots.forEach((root) => root.collapseAll());
872
+ }
873
+ setIsHidden(node, value) {
874
+ this.hiddenNodeIds = Object.assign({}, this.hiddenNodeIds, { [node.id]: value });
875
+ }
876
+ setHiddenNodeIds(nodeIds) {
877
+ this.hiddenNodeIds = nodeIds.reduce((hiddenNodeIds, id) => Object.assign(hiddenNodeIds, {
878
+ [id]: true
879
+ }), {});
880
+ }
881
+ performKeyAction(node, $event) {
882
+ const keyAction = this.options.actionMapping.keys[$event.keyCode];
883
+ if (keyAction) {
884
+ $event.preventDefault();
885
+ keyAction(this, node, $event);
886
+ return true;
887
+ }
888
+ else {
889
+ return false;
890
+ }
891
+ }
892
+ filterNodes(filter, autoShow = true) {
893
+ let filterFn;
894
+ if (!filter) {
895
+ return this.clearFilter();
896
+ }
897
+ // support function and string filter
898
+ if (filter && typeof filter.valueOf() === 'string') {
899
+ filterFn = (node) => node.displayField.toLowerCase().indexOf(filter.toLowerCase()) !== -1;
900
+ }
901
+ else if (filter && typeof filter === 'function') {
902
+ filterFn = filter;
903
+ }
904
+ else {
905
+ console.error('Don\'t know what to do with filter', filter);
906
+ console.error('Should be either a string or function');
907
+ return;
908
+ }
909
+ const ids = {};
910
+ this.roots.forEach((node) => this._filterNode(ids, node, filterFn, autoShow));
911
+ this.hiddenNodeIds = ids;
912
+ this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
913
+ }
914
+ clearFilter() {
915
+ this.hiddenNodeIds = {};
916
+ this.fireEvent({ eventName: TREE_EVENTS.changeFilter });
917
+ }
918
+ moveNode(node, to) {
919
+ const fromIndex = node.getIndexInParent();
920
+ const fromParent = node.parent;
921
+ if (!this.canMoveNode(node, to, fromIndex))
922
+ return;
923
+ const fromChildren = fromParent.getField('children');
924
+ // If node doesn't have children - create children array
925
+ if (!to.parent.getField('children')) {
926
+ to.parent.setField('children', []);
927
+ }
928
+ const toChildren = to.parent.getField('children');
929
+ const originalNode = fromChildren.splice(fromIndex, 1)[0];
930
+ // Compensate for index if already removed from parent:
931
+ let toIndex = (fromParent === to.parent && to.index > fromIndex) ? to.index - 1 : to.index;
932
+ toChildren.splice(toIndex, 0, originalNode);
933
+ fromParent.treeModel.update();
934
+ if (to.parent.treeModel !== fromParent.treeModel) {
935
+ to.parent.treeModel.update();
936
+ }
937
+ this.fireEvent({
938
+ eventName: TREE_EVENTS.moveNode,
939
+ node: originalNode,
940
+ to: { parent: to.parent.data, index: toIndex },
941
+ from: { parent: fromParent.data, index: fromIndex }
942
+ });
943
+ }
944
+ copyNode(node, to) {
945
+ const fromIndex = node.getIndexInParent();
946
+ if (!this.canMoveNode(node, to, fromIndex))
947
+ return;
948
+ // If node doesn't have children - create children array
949
+ if (!to.parent.getField('children')) {
950
+ to.parent.setField('children', []);
951
+ }
952
+ const toChildren = to.parent.getField('children');
953
+ const nodeCopy = this.options.getNodeClone(node);
954
+ toChildren.splice(to.index, 0, nodeCopy);
955
+ node.treeModel.update();
956
+ if (to.parent.treeModel !== node.treeModel) {
957
+ to.parent.treeModel.update();
958
+ }
959
+ this.fireEvent({ eventName: TREE_EVENTS.copyNode, node: nodeCopy, to: { parent: to.parent.data, index: to.index } });
960
+ }
961
+ getState() {
962
+ return {
963
+ expandedNodeIds: this.expandedNodeIds,
964
+ selectedLeafNodeIds: this.selectedLeafNodeIds,
965
+ activeNodeIds: this.activeNodeIds,
966
+ hiddenNodeIds: this.hiddenNodeIds,
967
+ focusedNodeId: this.focusedNodeId
968
+ };
969
+ }
970
+ setState(state) {
971
+ if (!state)
972
+ return;
973
+ Object.assign(this, {
974
+ expandedNodeIds: state.expandedNodeIds || {},
975
+ selectedLeafNodeIds: state.selectedLeafNodeIds || {},
976
+ activeNodeIds: state.activeNodeIds || {},
977
+ hiddenNodeIds: state.hiddenNodeIds || {},
978
+ focusedNodeId: state.focusedNodeId
979
+ });
980
+ }
981
+ subscribeToState(fn) {
982
+ autorun(() => fn(this.getState()));
983
+ }
984
+ canMoveNode(node, to, fromIndex = undefined) {
985
+ const fromNodeIndex = fromIndex || node.getIndexInParent();
986
+ // same node:
987
+ if (node.parent === to.parent && fromIndex === to.index) {
988
+ return false;
989
+ }
990
+ return !to.parent.isDescendantOf(node);
991
+ }
992
+ calculateExpandedNodes() {
993
+ this._calculateExpandedNodes();
994
+ }
995
+ // private methods
996
+ _filterNode(ids, node, filterFn, autoShow) {
997
+ // if node passes function then it's visible
998
+ let isVisible = filterFn(node);
999
+ if (node.children) {
1000
+ // if one of node's children passes filter then this node is also visible
1001
+ node.children.forEach((child) => {
1002
+ if (this._filterNode(ids, child, filterFn, autoShow)) {
1003
+ isVisible = true;
1004
+ }
1005
+ });
1006
+ }
1007
+ // mark node as hidden
1008
+ if (!isVisible) {
1009
+ ids[node.id] = true;
1010
+ }
1011
+ // auto expand parents to make sure the filtered nodes are visible
1012
+ if (autoShow && isVisible) {
1013
+ node.ensureVisible();
1014
+ }
1015
+ return isVisible;
1016
+ }
1017
+ _calculateExpandedNodes(startNode = null) {
1018
+ startNode = startNode || this.virtualRoot;
1019
+ if (startNode.data[this.options.isExpandedField]) {
1020
+ this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [startNode.id]: true });
1021
+ }
1022
+ if (startNode.children) {
1023
+ startNode.children.forEach((child) => this._calculateExpandedNodes(child));
1024
+ }
1025
+ }
1026
+ _setActiveNodeSingle(node, value) {
1027
+ // Deactivate all other nodes:
1028
+ this.activeNodes
1029
+ .filter((activeNode) => activeNode !== node)
1030
+ .forEach((activeNode) => {
1031
+ this.fireEvent({ eventName: TREE_EVENTS.deactivate, node: activeNode });
1032
+ this.fireEvent({ eventName: TREE_EVENTS.nodeDeactivate, node: activeNode }); // For IE11
1033
+ });
1034
+ if (value) {
1035
+ this.activeNodeIds = { [node.id]: true };
1036
+ }
1037
+ else {
1038
+ this.activeNodeIds = {};
1039
+ }
1040
+ }
1041
+ _setActiveNodeMulti(node, value) {
1042
+ this.activeNodeIds = Object.assign({}, this.activeNodeIds, { [node.id]: value });
1043
+ }
1044
+ }
1045
+ TreeModel.focusedTree = null;
1046
+ /** @nocollapse */ TreeModel.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeModel, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1047
+ /** @nocollapse */ TreeModel.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeModel });
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: "14.3.0", ngImport: i0, type: TreeModel, decorators: [{
1148
+ type: Injectable
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
+
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
+ }
1165
+ /** @nocollapse */ TreeDraggedElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDraggedElement, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1166
+ /** @nocollapse */ TreeDraggedElement.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDraggedElement, providedIn: 'root' });
1167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDraggedElement, decorators: [{
1168
+ type: Injectable,
1169
+ args: [{
1170
+ providedIn: 'root'
1171
+ }]
1172
+ }] });
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
+ constructor(treeModel) {
1184
+ this.treeModel = treeModel;
1185
+ this.yBlocks = 0;
1186
+ this.x = 0;
1187
+ this.viewportHeight = null;
1188
+ this.viewport = null;
1189
+ treeModel.virtualScroll = this;
1190
+ this._dispose = [autorun(() => this.fixScroll())];
1191
+ }
1192
+ get y() {
1193
+ return this.yBlocks * Y_EPSILON;
1194
+ }
1195
+ get totalHeight() {
1196
+ return this.treeModel.virtualRoot ? this.treeModel.virtualRoot.height : 0;
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
+ }
1316
+ /** @nocollapse */ TreeVirtualScroll.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeVirtualScroll, deps: [{ token: TreeModel }], target: i0.ɵɵFactoryTarget.Injectable });
1317
+ /** @nocollapse */ TreeVirtualScroll.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeVirtualScroll });
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: "14.3.0", ngImport: i0, type: TreeVirtualScroll, decorators: [{
1346
+ type: Injectable
1347
+ }], ctorParameters: function () { return [{ 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
+ }
1365
+
1366
+ class LoadingComponent {
1367
+ }
1368
+ /** @nocollapse */ LoadingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1369
+ /** @nocollapse */ LoadingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LoadingComponent, selector: "tree-loading-component", inputs: { template: "template", node: "node" }, ngImport: i0, template: `
1370
+ <span *ngIf="!template">loading...</span>
1371
+ <ng-container
1372
+ [ngTemplateOutlet]="template"
1373
+ [ngTemplateOutletContext]="{ $implicit: node }">
1374
+ </ng-container>
1375
+ `, 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 });
1376
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoadingComponent, decorators: [{
1377
+ type: Component,
1378
+ args: [{
1379
+ encapsulation: ViewEncapsulation.None,
1380
+ selector: 'tree-loading-component',
1381
+ template: `
1382
+ <span *ngIf="!template">loading...</span>
1383
+ <ng-container
1384
+ [ngTemplateOutlet]="template"
1385
+ [ngTemplateOutletContext]="{ $implicit: node }">
1386
+ </ng-container>
1387
+ `,
1388
+ }]
1389
+ }], propDecorators: { template: [{
1390
+ type: Input
1391
+ }], node: [{
1392
+ type: Input
1393
+ }] } });
1394
+
1395
+ const DRAG_OVER_CLASS$1 = 'is-dragging-over';
1396
+ const DRAG_DISABLED_CLASS = 'is-dragging-over-disabled';
1397
+ class TreeDropDirective {
1398
+ constructor(el, renderer, treeDraggedElement, ngZone) {
1399
+ this.el = el;
1400
+ this.renderer = renderer;
1401
+ this.treeDraggedElement = treeDraggedElement;
1402
+ this.ngZone = ngZone;
1403
+ this.allowDragoverStyling = true;
1404
+ this.onDropCallback = new EventEmitter();
1405
+ this.onDragOverCallback = new EventEmitter();
1406
+ this.onDragLeaveCallback = new EventEmitter();
1407
+ this.onDragEnterCallback = new EventEmitter();
1408
+ this._allowDrop = (element, $event) => true;
1409
+ this.dragOverEventHandler = this.onDragOver.bind(this);
1410
+ this.dragEnterEventHandler = this.onDragEnter.bind(this);
1411
+ this.dragLeaveEventHandler = this.onDragLeave.bind(this);
1412
+ }
1413
+ set treeAllowDrop(allowDrop) {
1414
+ if (allowDrop instanceof Function) {
1415
+ this._allowDrop = allowDrop;
1416
+ }
1417
+ else
1418
+ this._allowDrop = (element, $event) => allowDrop;
1419
+ }
1420
+ allowDrop($event) {
1421
+ return this._allowDrop(this.treeDraggedElement.get(), $event);
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
+ }
1491
+ /** @nocollapse */ TreeDropDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDropDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: TreeDraggedElement }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1492
+ /** @nocollapse */ TreeDropDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", 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 });
1493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDropDirective, decorators: [{
1494
+ type: Directive,
1495
+ args: [{
1496
+ selector: '[treeDrop]'
1497
+ }]
1498
+ }], ctorParameters: function () { return [{ 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
+ }] } });
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
+ }
1530
+ /** @nocollapse */ TreeNodeDropSlot.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeDropSlot, deps: [], target: i0.ɵɵFactoryTarget.Component });
1531
+ /** @nocollapse */ TreeNodeDropSlot.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeDropSlot, selector: "TreeNodeDropSlot, tree-node-drop-slot", inputs: { node: "node", dropIndex: "dropIndex" }, ngImport: i0, template: `
1532
+ <div
1533
+ class="node-drop-slot"
1534
+ (treeDrop)="onDrop($event)"
1535
+ [treeAllowDrop]="allowDrop.bind(this)"
1536
+ [allowDragoverStyling]="true">
1537
+ </div>
1538
+ `, isInline: true, dependencies: [{ kind: "directive", type: TreeDropDirective, selector: "[treeDrop]", inputs: ["allowDragoverStyling", "treeAllowDrop"], outputs: ["treeDrop", "treeDropDragOver", "treeDropDragLeave", "treeDropDragEnter"] }], encapsulation: i0.ViewEncapsulation.None });
1539
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeDropSlot, decorators: [{
1540
+ type: Component,
1541
+ args: [{ selector: 'TreeNodeDropSlot, tree-node-drop-slot', encapsulation: ViewEncapsulation.None, template: `
1542
+ <div
1543
+ class="node-drop-slot"
1544
+ (treeDrop)="onDrop($event)"
1545
+ [treeAllowDrop]="allowDrop.bind(this)"
1546
+ [allowDragoverStyling]="true">
1547
+ </div>
1548
+ ` }]
1549
+ }], propDecorators: { node: [{
1550
+ type: Input
1551
+ }], dropIndex: [{
1552
+ type: Input
1553
+ }] } });
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
+ }
1567
+ const observable = Object.assign(observableInternal, observable$1);
1568
+
1569
+ const EASE_ACCELERATION = 1.005;
1570
+ class TreeAnimateOpenDirective {
1571
+ constructor(renderer, templateRef, viewContainerRef) {
1572
+ this.renderer = renderer;
1573
+ this.templateRef = templateRef;
1574
+ this.viewContainerRef = viewContainerRef;
1575
+ }
1576
+ set isOpen(value) {
1577
+ if (value) {
1578
+ this._show();
1579
+ if (this.isEnabled && this._isOpen === false) {
1580
+ this._animateOpen();
1581
+ }
1582
+ }
1583
+ else {
1584
+ this.isEnabled ? this._animateClose() : this._hide();
1585
+ }
1586
+ this._isOpen = !!value;
1587
+ }
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
+ }
1647
+ /** @nocollapse */ TreeAnimateOpenDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeAnimateOpenDirective, deps: [{ token: i0.Renderer2 }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
1648
+ /** @nocollapse */ TreeAnimateOpenDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: TreeAnimateOpenDirective, selector: "[treeAnimateOpen]", inputs: { animateSpeed: ["treeAnimateOpenSpeed", "animateSpeed"], animateAcceleration: ["treeAnimateOpenAcceleration", "animateAcceleration"], isEnabled: ["treeAnimateOpenEnabled", "isEnabled"], isOpen: ["treeAnimateOpen", "isOpen"] }, ngImport: i0 });
1649
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeAnimateOpenDirective, decorators: [{
1650
+ type: Directive,
1651
+ args: [{
1652
+ selector: '[treeAnimateOpen]'
1653
+ }]
1654
+ }], ctorParameters: function () { return [{ 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
+ }] } });
1667
+
1668
+ class TreeNodeContent {
1669
+ }
1670
+ /** @nocollapse */ TreeNodeContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeContent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1671
+ /** @nocollapse */ TreeNodeContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeContent, selector: "tree-node-content", inputs: { node: "node", index: "index", template: "template" }, ngImport: i0, template: `
1672
+ <span *ngIf="!template">{{ node.displayField }}</span>
1673
+ <ng-container
1674
+ [ngTemplateOutlet]="template"
1675
+ [ngTemplateOutletContext]="{ $implicit: node, node: node, index: index }">
1676
+ </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 });
1677
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeContent, decorators: [{
1678
+ type: Component,
1679
+ args: [{
1680
+ selector: 'tree-node-content',
1681
+ encapsulation: ViewEncapsulation.None,
1682
+ template: `
1683
+ <span *ngIf="!template">{{ node.displayField }}</span>
1684
+ <ng-container
1685
+ [ngTemplateOutlet]="template"
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
1695
+ }] } });
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
+ }
1739
+ /** @nocollapse */ TreeDragDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDragDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: TreeDraggedElement }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1740
+ /** @nocollapse */ TreeDragDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: TreeDragDirective, selector: "[treeDrag]", inputs: { draggedElement: ["treeDrag", "draggedElement"], treeDragEnabled: "treeDragEnabled" }, host: { listeners: { "dragstart": "onDragStart($event)", "dragend": "onDragEnd()" } }, ngImport: i0 });
1741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeDragDirective, decorators: [{
1742
+ type: Directive,
1743
+ args: [{
1744
+ selector: '[treeDrag]'
1745
+ }]
1746
+ }], ctorParameters: function () { return [{ 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
+ }] } });
1758
+
1759
+ class TreeNodeExpanderComponent {
1760
+ }
1761
+ /** @nocollapse */ TreeNodeExpanderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeExpanderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1762
+ /** @nocollapse */ TreeNodeExpanderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeExpanderComponent, selector: "tree-node-expander", inputs: { node: "node" }, ngImport: i0, template: `
1763
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1764
+ <span
1765
+ *ngIf="node.hasChildren"
1766
+ [class.toggle-children-wrapper-expanded]="node.isExpanded"
1767
+ [class.toggle-children-wrapper-collapsed]="node.isCollapsed"
1768
+ class="toggle-children-wrapper"
1769
+ (click)="node.mouseAction('expanderClick', $event)"
1770
+ >
1771
+ <span class="toggle-children"></span>
1772
+ </span>
1773
+ <span *ngIf="!node.hasChildren" class="toggle-children-placeholder">
1774
+ </span>
1775
+ </ng-container>
1776
+ `, 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 });
1777
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeExpanderComponent, decorators: [{
1778
+ type: Component,
1779
+ args: [{ selector: 'tree-node-expander', encapsulation: ViewEncapsulation.None, template: `
1780
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1781
+ <span
1782
+ *ngIf="node.hasChildren"
1783
+ [class.toggle-children-wrapper-expanded]="node.isExpanded"
1784
+ [class.toggle-children-wrapper-collapsed]="node.isCollapsed"
1785
+ class="toggle-children-wrapper"
1786
+ (click)="node.mouseAction('expanderClick', $event)"
1787
+ >
1788
+ <span class="toggle-children"></span>
1789
+ </span>
1790
+ <span *ngIf="!node.hasChildren" class="toggle-children-placeholder">
1791
+ </span>
1792
+ </ng-container>
1793
+ ` }]
1794
+ }], propDecorators: { node: [{
1795
+ type: Input
1796
+ }] } });
1797
+
1798
+ class TreeNodeCheckboxComponent {
1799
+ }
1800
+ /** @nocollapse */ TreeNodeCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1801
+ /** @nocollapse */ TreeNodeCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeCheckboxComponent, selector: "tree-node-checkbox", inputs: { node: "node" }, ngImport: i0, template: `
1802
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1803
+ <input
1804
+ class="tree-node-checkbox"
1805
+ type="checkbox"
1806
+ (click)="node.mouseAction('checkboxClick', $event)"
1807
+ [checked]="node.isSelected"
1808
+ [indeterminate]="node.isPartiallySelected"
1809
+ />
1810
+ </ng-container>
1811
+ `, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None });
1812
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeCheckboxComponent, decorators: [{
1813
+ type: Component,
1814
+ args: [{ selector: 'tree-node-checkbox', encapsulation: ViewEncapsulation.None, template: `
1815
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1816
+ <input
1817
+ class="tree-node-checkbox"
1818
+ type="checkbox"
1819
+ (click)="node.mouseAction('checkboxClick', $event)"
1820
+ [checked]="node.isSelected"
1821
+ [indeterminate]="node.isPartiallySelected"
1822
+ />
1823
+ </ng-container>
1824
+ ` }]
1825
+ }], propDecorators: { node: [{
1826
+ type: Input
1827
+ }] } });
1828
+
1829
+ class TreeNodeWrapperComponent {
1830
+ }
1831
+ /** @nocollapse */ TreeNodeWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1832
+ /** @nocollapse */ TreeNodeWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeWrapperComponent, selector: "tree-node-wrapper", inputs: { node: "node", index: "index", templates: "templates" }, ngImport: i0, template: `
1833
+ <div *ngIf="!templates.treeNodeWrapperTemplate" class="node-wrapper" [style.padding-left]="node.getNodePadding()">
1834
+ <tree-node-checkbox *ngIf="node.options.useCheckbox" [node]="node"></tree-node-checkbox>
1835
+ <tree-node-expander [node]="node"></tree-node-expander>
1836
+ <div class="node-content-wrapper"
1837
+ [class.node-content-wrapper-active]="node.isActive"
1838
+ [class.node-content-wrapper-focused]="node.isFocused"
1839
+ (click)="node.mouseAction('click', $event)"
1840
+ (dblclick)="node.mouseAction('dblClick', $event)"
1841
+ (mouseover)="node.mouseAction('mouseOver', $event)"
1842
+ (mouseout)="node.mouseAction('mouseOut', $event)"
1843
+ (contextmenu)="node.mouseAction('contextMenu', $event)"
1844
+ (treeDrop)="node.onDrop($event)"
1845
+ (treeDropDragOver)="node.mouseAction('dragOver', $event)"
1846
+ (treeDropDragLeave)="node.mouseAction('dragLeave', $event)"
1847
+ (treeDropDragEnter)="node.mouseAction('dragEnter', $event)"
1848
+ [treeAllowDrop]="node.allowDrop"
1849
+ [allowDragoverStyling]="node.allowDragoverStyling()"
1850
+ [treeDrag]="node"
1851
+ [treeDragEnabled]="node.allowDrag()">
1852
+
1853
+ <tree-node-content [node]="node" [index]="index" [template]="templates.treeNodeTemplate">
1854
+ </tree-node-content>
1855
+ </div>
1856
+ </div>
1857
+ <ng-container
1858
+ [ngTemplateOutlet]="templates.treeNodeWrapperTemplate"
1859
+ [ngTemplateOutletContext]="{ $implicit: node, node: node, index: index, templates: templates }">
1860
+ </ng-container>
1861
+ `, 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 });
1862
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeWrapperComponent, decorators: [{
1863
+ type: Component,
1864
+ args: [{ selector: 'tree-node-wrapper', encapsulation: ViewEncapsulation.None, template: `
1865
+ <div *ngIf="!templates.treeNodeWrapperTemplate" class="node-wrapper" [style.padding-left]="node.getNodePadding()">
1866
+ <tree-node-checkbox *ngIf="node.options.useCheckbox" [node]="node"></tree-node-checkbox>
1867
+ <tree-node-expander [node]="node"></tree-node-expander>
1868
+ <div class="node-content-wrapper"
1869
+ [class.node-content-wrapper-active]="node.isActive"
1870
+ [class.node-content-wrapper-focused]="node.isFocused"
1871
+ (click)="node.mouseAction('click', $event)"
1872
+ (dblclick)="node.mouseAction('dblClick', $event)"
1873
+ (mouseover)="node.mouseAction('mouseOver', $event)"
1874
+ (mouseout)="node.mouseAction('mouseOut', $event)"
1875
+ (contextmenu)="node.mouseAction('contextMenu', $event)"
1876
+ (treeDrop)="node.onDrop($event)"
1877
+ (treeDropDragOver)="node.mouseAction('dragOver', $event)"
1878
+ (treeDropDragLeave)="node.mouseAction('dragLeave', $event)"
1879
+ (treeDropDragEnter)="node.mouseAction('dragEnter', $event)"
1880
+ [treeAllowDrop]="node.allowDrop"
1881
+ [allowDragoverStyling]="node.allowDragoverStyling()"
1882
+ [treeDrag]="node"
1883
+ [treeDragEnabled]="node.allowDrag()">
1884
+
1885
+ <tree-node-content [node]="node" [index]="index" [template]="templates.treeNodeTemplate">
1886
+ </tree-node-content>
1887
+ </div>
1888
+ </div>
1889
+ <ng-container
1890
+ [ngTemplateOutlet]="templates.treeNodeWrapperTemplate"
1891
+ [ngTemplateOutletContext]="{ $implicit: node, node: node, index: index, templates: templates }">
1892
+ </ng-container>
1893
+ ` }]
1894
+ }], propDecorators: { node: [{
1895
+ type: Input
1896
+ }], index: [{
1897
+ type: Input
1898
+ }], templates: [{
1899
+ type: Input
1900
+ }] } });
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
+ }
1910
+ /** @nocollapse */ TreeNodeChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeChildrenComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1911
+ /** @nocollapse */ TreeNodeChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeChildrenComponent, selector: "tree-node-children", inputs: { node: "node", templates: "templates" }, ngImport: i0, template: `
1912
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1913
+ <div
1914
+ [class.tree-children]="true"
1915
+ [class.tree-children-no-padding]="node.options.levelPadding"
1916
+ *treeAnimateOpen="
1917
+ node.isExpanded;
1918
+ speed: node.options.animateSpeed;
1919
+ acceleration: node.options.animateAcceleration;
1920
+ enabled: node.options.animateExpand
1921
+ "
1922
+ >
1923
+ <tree-node-collection
1924
+ *ngIf="node.children"
1925
+ [nodes]="node.children"
1926
+ [templates]="templates"
1927
+ [treeModel]="node.treeModel"
1928
+ >
1929
+ </tree-node-collection>
1930
+ <tree-loading-component
1931
+ [style.padding-left]="node.getNodePadding()"
1932
+ class="tree-node-loading"
1933
+ *ngIf="!node.children"
1934
+ [template]="templates.loadingTemplate"
1935
+ [node]="node"
1936
+ ></tree-loading-component>
1937
+ </div>
1938
+ </ng-container>
1939
+ `, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(function () { return i1.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i0.forwardRef(function () { return LoadingComponent; }), selector: "tree-loading-component", inputs: ["template", "node"] }, { kind: "component", type: i0.forwardRef(function () { return TreeNodeCollectionComponent; }), selector: "tree-node-collection", inputs: ["nodes", "treeModel", "templates"] }, { kind: "directive", type: i0.forwardRef(function () { return TreeAnimateOpenDirective; }), selector: "[treeAnimateOpen]", inputs: ["treeAnimateOpenSpeed", "treeAnimateOpenAcceleration", "treeAnimateOpenEnabled", "treeAnimateOpen"] }, { kind: "directive", type: i0.forwardRef(function () { return TreeMobxAutorunDirective; }), selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None });
1940
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeChildrenComponent, decorators: [{
1941
+ type: Component,
1942
+ args: [{ selector: 'tree-node-children', encapsulation: ViewEncapsulation.None, template: `
1943
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
1944
+ <div
1945
+ [class.tree-children]="true"
1946
+ [class.tree-children-no-padding]="node.options.levelPadding"
1947
+ *treeAnimateOpen="
1948
+ node.isExpanded;
1949
+ speed: node.options.animateSpeed;
1950
+ acceleration: node.options.animateAcceleration;
1951
+ enabled: node.options.animateExpand
1952
+ "
1953
+ >
1954
+ <tree-node-collection
1955
+ *ngIf="node.children"
1956
+ [nodes]="node.children"
1957
+ [templates]="templates"
1958
+ [treeModel]="node.treeModel"
1959
+ >
1960
+ </tree-node-collection>
1961
+ <tree-loading-component
1962
+ [style.padding-left]="node.getNodePadding()"
1963
+ class="tree-node-loading"
1964
+ *ngIf="!node.children"
1965
+ [template]="templates.loadingTemplate"
1966
+ [node]="node"
1967
+ ></tree-loading-component>
1968
+ </div>
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
+ }
2021
+ /** @nocollapse */ TreeNodeCollectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeCollectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2022
+ /** @nocollapse */ TreeNodeCollectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeCollectionComponent, selector: "tree-node-collection", inputs: { nodes: "nodes", treeModel: "treeModel", templates: "templates" }, ngImport: i0, template: `
2023
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2024
+ <div [style.margin-top]="marginTop">
2025
+ <tree-node
2026
+ *ngFor="let node of viewportNodes; let i = index; trackBy: trackNode"
2027
+ [node]="node"
2028
+ [index]="i"
2029
+ [templates]="templates"
2030
+ >
2031
+ </tree-node>
2032
+ </div>
2033
+ </ng-container>
2034
+ `, isInline: true, dependencies: [{ kind: "directive", type: i0.forwardRef(function () { return i1.NgForOf; }), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i0.forwardRef(function () { return TreeNodeComponent; }), selector: "TreeNode, tree-node", inputs: ["node", "index", "templates"] }, { kind: "directive", type: i0.forwardRef(function () { return TreeMobxAutorunDirective; }), selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }], encapsulation: i0.ViewEncapsulation.None });
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: "14.3.0", ngImport: i0, type: TreeNodeCollectionComponent, decorators: [{
2048
+ type: Component,
2049
+ args: [{
2050
+ selector: 'tree-node-collection',
2051
+ encapsulation: ViewEncapsulation.None,
2052
+ template: `
2053
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2054
+ <div [style.margin-top]="marginTop">
2055
+ <tree-node
2056
+ *ngFor="let node of viewportNodes; let i = index; trackBy: trackNode"
2057
+ [node]="node"
2058
+ [index]="i"
2059
+ [templates]="templates"
2060
+ >
2061
+ </tree-node>
2062
+ </div>
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
+ }
2075
+ /** @nocollapse */ TreeNodeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2076
+ /** @nocollapse */ TreeNodeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeNodeComponent, selector: "TreeNode, tree-node", inputs: { node: "node", index: "index", templates: "templates" }, ngImport: i0, template: `
2077
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2078
+ <div
2079
+ *ngIf="!templates.treeNodeFullTemplate"
2080
+ [class]="node.getClass()"
2081
+ [class.tree-node]="true"
2082
+ [class.tree-node-expanded]="node.isExpanded && node.hasChildren"
2083
+ [class.tree-node-collapsed]="node.isCollapsed && node.hasChildren"
2084
+ [class.tree-node-leaf]="node.isLeaf"
2085
+ [class.tree-node-active]="node.isActive"
2086
+ [class.tree-node-focused]="node.isFocused"
2087
+ >
2088
+ <tree-node-drop-slot
2089
+ *ngIf="index === 0"
2090
+ [dropIndex]="node.index"
2091
+ [node]="node.parent"
2092
+ ></tree-node-drop-slot>
2093
+
2094
+ <tree-node-wrapper
2095
+ [node]="node"
2096
+ [index]="index"
2097
+ [templates]="templates"
2098
+ ></tree-node-wrapper>
2099
+
2100
+ <tree-node-children
2101
+ [node]="node"
2102
+ [templates]="templates"
2103
+ ></tree-node-children>
2104
+ <tree-node-drop-slot
2105
+ [dropIndex]="node.index + 1"
2106
+ [node]="node.parent"
2107
+ ></tree-node-drop-slot>
2108
+ </div>
2109
+ <ng-container
2110
+ [ngTemplateOutlet]="templates.treeNodeFullTemplate"
2111
+ [ngTemplateOutletContext]="{
2112
+ $implicit: node,
2113
+ node: node,
2114
+ index: index,
2115
+ templates: templates
2116
+ }"
2117
+ >
2118
+ </ng-container>
2119
+ </ng-container>
2120
+ `, 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 });
2121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeNodeComponent, decorators: [{
2122
+ type: Component,
2123
+ args: [{ selector: 'TreeNode, tree-node', encapsulation: ViewEncapsulation.None, template: `
2124
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2125
+ <div
2126
+ *ngIf="!templates.treeNodeFullTemplate"
2127
+ [class]="node.getClass()"
2128
+ [class.tree-node]="true"
2129
+ [class.tree-node-expanded]="node.isExpanded && node.hasChildren"
2130
+ [class.tree-node-collapsed]="node.isCollapsed && node.hasChildren"
2131
+ [class.tree-node-leaf]="node.isLeaf"
2132
+ [class.tree-node-active]="node.isActive"
2133
+ [class.tree-node-focused]="node.isFocused"
2134
+ >
2135
+ <tree-node-drop-slot
2136
+ *ngIf="index === 0"
2137
+ [dropIndex]="node.index"
2138
+ [node]="node.parent"
2139
+ ></tree-node-drop-slot>
2140
+
2141
+ <tree-node-wrapper
2142
+ [node]="node"
2143
+ [index]="index"
2144
+ [templates]="templates"
2145
+ ></tree-node-wrapper>
2146
+
2147
+ <tree-node-children
2148
+ [node]="node"
2149
+ [templates]="templates"
2150
+ ></tree-node-children>
2151
+ <tree-node-drop-slot
2152
+ [dropIndex]="node.index + 1"
2153
+ [node]="node.parent"
2154
+ ></tree-node-drop-slot>
2155
+ </div>
2156
+ <ng-container
2157
+ [ngTemplateOutlet]="templates.treeNodeFullTemplate"
2158
+ [ngTemplateOutletContext]="{
2159
+ $implicit: node,
2160
+ node: node,
2161
+ index: index,
2162
+ templates: templates
2163
+ }"
2164
+ >
2165
+ </ng-container>
2166
+ </ng-container>
2167
+ ` }]
2168
+ }], propDecorators: { node: [{
2169
+ type: Input
2170
+ }], index: [{
2171
+ type: Input
2172
+ }], templates: [{
2173
+ type: Input
2174
+ }] } });
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
+ }
2217
+ /** @nocollapse */ TreeViewportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeViewportComponent, deps: [{ token: i0.ElementRef }, { token: TreeVirtualScroll }], target: i0.ɵɵFactoryTarget.Component });
2218
+ /** @nocollapse */ TreeViewportComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TreeViewportComponent, selector: "tree-viewport", providers: [TreeVirtualScroll], ngImport: i0, template: `
2219
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2220
+ <div [style.height]="getTotalHeight()">
2221
+ <ng-content></ng-content>
2222
+ </div>
2223
+ </ng-container>
2224
+ `, isInline: true, dependencies: [{ kind: "directive", type: TreeMobxAutorunDirective, selector: "[treeMobxAutorun]", inputs: ["treeMobxAutorun"] }] });
2225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeViewportComponent, decorators: [{
2226
+ type: Component,
2227
+ args: [{ selector: 'tree-viewport', providers: [TreeVirtualScroll], template: `
2228
+ <ng-container *treeMobxAutorun="{ dontDetach: true }">
2229
+ <div [style.height]="getTotalHeight()">
2230
+ <ng-content></ng-content>
2231
+ </div>
2232
+ </ng-container>
2233
+ ` }]
2234
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: TreeVirtualScroll }]; } });
2235
+
2236
+ class TreeComponent {
2237
+ constructor(treeModel, treeDraggedElement) {
2238
+ this.treeModel = treeModel;
2239
+ this.treeDraggedElement = treeDraggedElement;
2240
+ treeModel.eventNames.forEach((name) => this[name] = new EventEmitter());
2241
+ treeModel.subscribeToState((state) => this.stateChange.emit(state));
2242
+ }
2243
+ // Will be handled in ngOnChanges
2244
+ set nodes(nodes) {
2245
+ }
2246
+ ;
2247
+ set options(options) {
2248
+ }
2249
+ ;
2250
+ set focused(value) {
2251
+ this.treeModel.setFocus(value);
2252
+ }
2253
+ set state(state) {
2254
+ this.treeModel.setState(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
+ }
2293
+ /** @nocollapse */ TreeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeComponent, deps: [{ token: TreeModel }, { token: TreeDraggedElement }], target: i0.ɵɵFactoryTarget.Component });
2294
+ /** @nocollapse */ TreeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", 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: `
2295
+ <tree-viewport #viewport>
2296
+ <div
2297
+ class="angular-tree-component"
2298
+ [class.node-dragging]="treeDraggedElement.isDragging()"
2299
+ [class.angular-tree-component-rtl]="treeModel.options.rtl">
2300
+ <tree-node-collection
2301
+ *ngIf="treeModel.roots"
2302
+ [nodes]="treeModel.roots"
2303
+ [treeModel]="treeModel"
2304
+ [templates]="{
2305
+ loadingTemplate: loadingTemplate,
2306
+ treeNodeTemplate: treeNodeTemplate,
2307
+ treeNodeWrapperTemplate: treeNodeWrapperTemplate,
2308
+ treeNodeFullTemplate: treeNodeFullTemplate
2309
+ }">
2310
+ </tree-node-collection>
2311
+ <tree-node-drop-slot
2312
+ class="empty-tree-drop-slot"
2313
+ *ngIf="treeModel.isEmptyTree()"
2314
+ [dropIndex]="0"
2315
+ [node]="treeModel.virtualRoot">
2316
+ </tree-node-drop-slot>
2317
+ </div>
2318
+ </tree-viewport>
2319
+ `, 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" }] });
2320
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeComponent, decorators: [{
2321
+ type: Component,
2322
+ args: [{ selector: 'Tree, tree-root', providers: [TreeModel], template: `
2323
+ <tree-viewport #viewport>
2324
+ <div
2325
+ class="angular-tree-component"
2326
+ [class.node-dragging]="treeDraggedElement.isDragging()"
2327
+ [class.angular-tree-component-rtl]="treeModel.options.rtl">
2328
+ <tree-node-collection
2329
+ *ngIf="treeModel.roots"
2330
+ [nodes]="treeModel.roots"
2331
+ [treeModel]="treeModel"
2332
+ [templates]="{
2333
+ loadingTemplate: loadingTemplate,
2334
+ treeNodeTemplate: treeNodeTemplate,
2335
+ treeNodeWrapperTemplate: treeNodeWrapperTemplate,
2336
+ treeNodeFullTemplate: treeNodeFullTemplate
2337
+ }">
2338
+ </tree-node-collection>
2339
+ <tree-node-drop-slot
2340
+ class="empty-tree-drop-slot"
2341
+ *ngIf="treeModel.isEmptyTree()"
2342
+ [dropIndex]="0"
2343
+ [node]="treeModel.virtualRoot">
2344
+ </tree-node-drop-slot>
2345
+ </div>
2346
+ </tree-viewport>
2347
+ ` }]
2348
+ }], ctorParameters: function () { return [{ 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
+ }] } });
2412
+
2413
+ class TreeModule {
2414
+ }
2415
+ /** @nocollapse */ TreeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2416
+ /** @nocollapse */ TreeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: TreeModule, declarations: [TreeComponent,
2417
+ TreeNodeComponent,
2418
+ TreeNodeContent,
2419
+ LoadingComponent,
2420
+ TreeDropDirective,
2421
+ TreeDragDirective,
2422
+ TreeNodeExpanderComponent,
2423
+ TreeNodeChildrenComponent,
2424
+ TreeNodeDropSlot,
2425
+ TreeNodeCollectionComponent,
2426
+ TreeViewportComponent,
2427
+ TreeNodeWrapperComponent,
2428
+ TreeNodeCheckboxComponent,
2429
+ TreeAnimateOpenDirective,
2430
+ TreeMobxAutorunDirective], imports: [CommonModule], exports: [TreeComponent,
2431
+ TreeNodeComponent,
2432
+ TreeNodeContent,
2433
+ LoadingComponent,
2434
+ TreeDropDirective,
2435
+ TreeDragDirective,
2436
+ TreeNodeExpanderComponent,
2437
+ TreeNodeChildrenComponent,
2438
+ TreeNodeDropSlot,
2439
+ TreeNodeCollectionComponent,
2440
+ TreeViewportComponent,
2441
+ TreeNodeWrapperComponent,
2442
+ TreeNodeCheckboxComponent,
2443
+ TreeAnimateOpenDirective,
2444
+ TreeMobxAutorunDirective] });
2445
+ /** @nocollapse */ TreeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TreeModule, imports: [CommonModule] });
2446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", 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
+ }] });
2487
+
2488
+ /*
2489
+ * Public API Surface of angular-tree-component
2490
+ */
2491
+
2492
+ /**
2493
+ * Generated bundle index. Do not edit.
2494
+ */
2495
+
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 };
2497
+ //# sourceMappingURL=ali-hm-angular-tree-component.mjs.map