@limble/limble-tree 1.0.0-alpha.2 → 1.0.0-beta.2

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 (76) hide show
  1. package/README.md +4 -0
  2. package/esm2020/lib/components/branch/branch.component.mjs +1 -1
  3. package/esm2020/lib/components/dropzone/dropzone.component.mjs +2 -2
  4. package/esm2020/lib/core/configuration/configuration.mjs +1 -1
  5. package/esm2020/lib/core/configuration/tree-options.interface.mjs +1 -1
  6. package/esm2020/lib/core/index.mjs +1 -2
  7. package/esm2020/lib/core/tree-branch/tree-branch.mjs +210 -9
  8. package/esm2020/lib/core/tree-node-base.mjs +13 -1
  9. package/esm2020/lib/core/tree-root/tree-root.mjs +111 -3
  10. package/esm2020/lib/core/tree-service/tree.service.mjs +7 -1
  11. package/esm2020/lib/events/drag/drag-end-event.mjs +9 -7
  12. package/esm2020/lib/events/drag/drag-start-event.mjs +2 -4
  13. package/esm2020/lib/events/drag/drop-event.mjs +2 -4
  14. package/esm2020/lib/events/general/destruction-event.mjs +2 -4
  15. package/esm2020/lib/events/relational/graft-event.mjs +2 -4
  16. package/esm2020/lib/events/relational/prune-event.mjs +2 -4
  17. package/esm2020/lib/events/relational/relational-tree-event.interface.mjs +1 -1
  18. package/esm2020/lib/extras/collapse/collapse.module.mjs +2 -1
  19. package/esm2020/lib/extras/collapse/collapse.service.mjs +26 -1
  20. package/esm2020/lib/extras/drag-and-drop/drag-and-drop.module.mjs +5 -1
  21. package/esm2020/lib/extras/drag-and-drop/drag-and-drop.service.mjs +21 -5
  22. package/esm2020/lib/extras/drag-and-drop/draggable.directive.mjs +7 -7
  23. package/esm2020/lib/extras/drag-and-drop/dragover-no-change-detect.mjs +10 -11
  24. package/esm2020/lib/legacy/legacy-component-obj.interface.mjs +1 -1
  25. package/esm2020/lib/legacy/legacy-tree-data.interface.mjs +1 -1
  26. package/esm2020/lib/legacy/legacy-tree-options.interface.mjs +1 -1
  27. package/esm2020/lib/legacy/legacy-tree.mjs +3 -2
  28. package/esm2020/lib/legacy/limble-tree-root/limble-tree-root.component.mjs +1 -1
  29. package/esm2020/lib/limble-tree.module.mjs +6 -2
  30. package/esm2020/lib/structure/component-container.interface.mjs +1 -1
  31. package/esm2020/lib/structure/index.mjs +1 -2
  32. package/esm2020/lib/structure/tree-branch-node.interface.mjs +1 -1
  33. package/esm2020/lib/structure/tree-event.interface.mjs +1 -1
  34. package/esm2020/lib/structure/tree-node.interface.mjs +1 -1
  35. package/esm2020/lib/structure/tree-relationship.interface.mjs +1 -1
  36. package/esm2020/shared/has-property.mjs +4 -0
  37. package/fesm2015/limble-limble-tree.mjs +569 -195
  38. package/fesm2015/limble-limble-tree.mjs.map +1 -1
  39. package/fesm2020/limble-limble-tree.mjs +568 -194
  40. package/fesm2020/limble-limble-tree.mjs.map +1 -1
  41. package/lib/core/configuration/configuration.d.ts +2 -2
  42. package/lib/core/configuration/tree-options.interface.d.ts +38 -16
  43. package/lib/core/index.d.ts +0 -1
  44. package/lib/core/tree-branch/tree-branch.d.ts +185 -8
  45. package/lib/core/tree-node-base.d.ts +1 -0
  46. package/lib/core/tree-root/tree-root.d.ts +101 -7
  47. package/lib/core/tree-service/tree.service.d.ts +8 -2
  48. package/lib/events/drag/drag-end-event.d.ts +11 -8
  49. package/lib/events/drag/drag-start-event.d.ts +6 -5
  50. package/lib/events/drag/drop-event.d.ts +6 -6
  51. package/lib/events/general/destruction-event.d.ts +5 -5
  52. package/lib/events/relational/graft-event.d.ts +5 -6
  53. package/lib/events/relational/prune-event.d.ts +5 -6
  54. package/lib/events/relational/relational-tree-event.interface.d.ts +5 -1
  55. package/lib/extras/collapse/collapse.module.d.ts +1 -0
  56. package/lib/extras/collapse/collapse.service.d.ts +25 -0
  57. package/lib/extras/drag-and-drop/drag-and-drop.module.d.ts +4 -0
  58. package/lib/extras/drag-and-drop/drag-and-drop.service.d.ts +22 -3
  59. package/lib/extras/drag-and-drop/draggable.directive.d.ts +3 -4
  60. package/lib/extras/drag-and-drop/dragover-no-change-detect.d.ts +7 -3
  61. package/lib/legacy/legacy-component-obj.interface.d.ts +1 -1
  62. package/lib/legacy/legacy-tree-data.interface.d.ts +1 -1
  63. package/lib/legacy/legacy-tree-options.interface.d.ts +2 -2
  64. package/lib/legacy/legacy-tree.d.ts +4 -4
  65. package/lib/legacy/limble-tree-root/limble-tree-root.component.d.ts +4 -4
  66. package/lib/limble-tree.module.d.ts +4 -0
  67. package/lib/structure/component-container.interface.d.ts +1 -1
  68. package/lib/structure/index.d.ts +0 -1
  69. package/lib/structure/tree-branch-node.interface.d.ts +2 -2
  70. package/lib/structure/tree-event.interface.d.ts +3 -3
  71. package/lib/structure/tree-node.interface.d.ts +12 -8
  72. package/lib/structure/tree-relationship.interface.d.ts +2 -2
  73. package/package.json +1 -1
  74. package/shared/has-property.d.ts +3 -0
  75. package/esm2020/lib/structure/event-conduit.interface.mjs +0 -2
  76. package/lib/structure/event-conduit.interface.d.ts +0 -6
@@ -1,5 +1,5 @@
1
- import { TreeRoot } from "../tree-root/tree-root";
2
- import { TreeOptions } from "./tree-options.interface";
1
+ import type { TreeRoot } from "../tree-root/tree-root";
2
+ import type { TreeOptions } from "./tree-options.interface";
3
3
  declare class Configuration {
4
4
  private readonly configStorage;
5
5
  constructor();
@@ -1,32 +1,54 @@
1
- import { TreeBranch } from "../tree-branch/tree-branch";
2
- import { TreeRoot } from "../tree-root/tree-root";
1
+ import type { TreeBranch } from "../tree-branch/tree-branch";
2
+ import type { TreeRoot } from "../tree-root/tree-root";
3
+ /** The configuration options for a tree, as identified by a TreeRoot */
3
4
  export interface TreeOptions {
4
5
  dragAndDrop?: {
5
6
  /**
6
- * A function to indicate whether to allow a node to be dragged. The node in
7
- * question is passed in. Defaults to a function that always returns true. This
8
- * function runs when DragAndDropService.dragStart runs, and before the branch
9
- * is pruned from the tree.
7
+ * A function that determines whether to allow a node to be dragged.
8
+ *
9
+ * @remarks
10
+ * Runs when a drag begins, but before the branch is pruned from the tree.
11
+ *
12
+ * @param treeBranch - The node of the tree that is about to be dragged.
13
+ *
14
+ * @defaultValue A function that always returns true.
15
+ *
16
+ * @returns `true` if the node can be dragged; `false` if it cannot.
10
17
  */
11
18
  allowDragging?: <T>(treeBranch: TreeBranch<T>) => boolean;
12
19
  /**
13
- * A function to determine whether a sourceNode can be dropped at a particular location.
14
- * The sourceNode, the new proposedParent for the sourceNode, and the new proposedIndex
15
- * for the source node are passed in. This function runs just before displaying a
16
- * family of dropzones.
20
+ * A function to determine whether a sourceNode can be dropped at a
21
+ * particular location.
22
+ *
23
+ * @remarks
24
+ * This function runs just before displaying a family of dropzones.
25
+ *
26
+ * @param sourceBranch - The branch that is being dragged.
27
+ * @param proposedParent - The proposed new parent of the sourceBranch.
28
+ * @param proposedIndex - The proposed new index of the sourceBranch.
29
+ *
30
+ * @defaultValue A function that always returns true.
17
31
  */
18
- allowDrop?: <T>(sourceNode: TreeBranch<T>, proposedParent: TreeBranch<T> | TreeRoot<T>, proposedIndex: number) => boolean;
32
+ allowDrop?: <T>(sourceBranch: TreeBranch<T>, proposedParent: TreeBranch<T> | TreeRoot<T>, proposedIndex: number) => boolean;
19
33
  /**
20
- * A function to indicate whether to allow "nesting" (placing a branch one level
21
- * deeper than its parent). The node in question is passed in. Defaults to a function
22
- * that always returns true. This function runs just before displaying a family of
23
- * dropzones.
34
+ * A function to indicate whether to allow "nesting" (placing a branch as
35
+ * a child) of a particular branch.
36
+ *
37
+ * @remarks
38
+ * This function runs just before displaying a family of dropzones.
39
+ *
40
+ * @param treeBranch - The node of the tree whose nesting capability is being
41
+ * checked.
42
+ *
43
+ * @defaultValue A function that always returns true.
24
44
  */
25
45
  allowNesting?: <T>(treeBranch: TreeBranch<T>) => boolean;
26
46
  };
27
47
  /**
28
48
  * The number of pixels each level of the tree will be indented relative to
29
- * its parent. Defaults to 16.
49
+ * its parent.
50
+ *
51
+ * @defaultValue 16
30
52
  */
31
53
  indentation?: number;
32
54
  }
@@ -2,4 +2,3 @@ export * from "./tree-service/tree.service";
2
2
  export * from "./tree-root/tree-root";
3
3
  export * from "./tree-branch/tree-branch";
4
4
  export * from "./configuration/tree-options.interface";
5
- export * from "./configuration/configuration";
@@ -1,13 +1,19 @@
1
- import { TreePlot } from "../../structure/tree-plot";
2
- import { Observable } from "rxjs";
3
- import { TreeEvent } from "../../structure/tree-event.interface";
4
- import { TreeBranchNode } from "../../structure/tree-branch-node.interface";
5
- import { ComponentRef, Type, ViewContainerRef, ViewRef } from "@angular/core";
1
+ import type { Observable } from "rxjs";
2
+ import type { ComponentRef, Type, ViewContainerRef, ViewRef } from "@angular/core";
6
3
  import { BranchComponent } from "../../components/branch/branch.component";
7
- import { NodeComponent } from "../../components/node-component.interface";
8
- import { BranchOptions, FullBranchOptions } from "../branch-options.interface";
4
+ import type { NodeComponent } from "../../components/node-component.interface";
5
+ import type { BranchOptions, FullBranchOptions } from "../branch-options.interface";
9
6
  import { TreeRoot } from "..";
10
- import { TreeNode } from "../../structure";
7
+ import type { TreeNode, TreePlot, TreeEvent, TreeBranchNode } from "../../structure";
8
+ /** Represents a standard node in a tree. Renders a BranchComponent.
9
+ *
10
+ * @remarks
11
+ * This class renders a branch component, which does the following:
12
+ * 1. Renders a component provided by the user
13
+ * 2. Provides a container in which child branches may be rendered
14
+ * 3. Contains two Dropzones: one for dropping branches below this branch (as a
15
+ * sibling), and one for dropping branches as a first child of this branch.
16
+ */
11
17
  export declare class TreeBranch<UserlandComponent> implements TreeBranchNode<BranchComponent<UserlandComponent>, TreeBranch<UserlandComponent>, NodeComponent> {
12
18
  readonly branchOptions: FullBranchOptions<UserlandComponent>;
13
19
  private readonly branchController;
@@ -15,30 +21,201 @@ export declare class TreeBranch<UserlandComponent> implements TreeBranchNode<Bra
15
21
  private _parent;
16
22
  private readonly treeNodeBase;
17
23
  constructor(parent: TreeNode<TreeBranch<UserlandComponent>, NodeComponent>, branchOptions: FullBranchOptions<UserlandComponent>);
24
+ /** @returns All child branches as an array of TreeBranch instances, in order. */
18
25
  branches(): Array<TreeBranch<UserlandComponent>>;
26
+ /**
27
+ * Recursively destroys all descendant branches, as well as itself. This
28
+ * releases all resources held or consumed by this branch and its descendants.
29
+ *
30
+ * @remarks
31
+ * It is important to call this method when a branch is discarded, otherwise
32
+ * the branch will remain in memory and continue to consume resources.
33
+ */
19
34
  destroy(): void;
35
+ /** Run Angular change detection on this branch */
20
36
  detectChanges(): void;
37
+ /**
38
+ * Emits the specified TreeEvent.
39
+ *
40
+ * @remarks
41
+ * Caution: It is not recommended to manually emit TreeEvents that are already
42
+ * provided by the library. For example, it is not recommended to emit a
43
+ * `GraftEvent`, `DestructionEvent`, etc. These events may be used by the tree,
44
+ * and emitting them manually may cause unexpected behavior. Instead, we
45
+ * recommend implementing the TreeEvent interface with your own custom events
46
+ * and dispatching those.
47
+ *
48
+ * @param event - The TreeEvent that will be emitted.
49
+ */
21
50
  dispatch(event: TreeEvent): void;
51
+ /**
52
+ * @returns
53
+ * An observable that emits TreeEvents whenever an event is dispatched
54
+ * in this branch or any of its descendant branches.
55
+ */
22
56
  events(): Observable<TreeEvent>;
57
+ /**
58
+ * @param index - The index of the child branch to retrieve.
59
+ *
60
+ * @returns
61
+ * The child branch at the specified index, or undefined if there is
62
+ * no child branch at the specified index.
63
+ */
23
64
  getBranch(index: number): TreeBranch<UserlandComponent> | undefined;
65
+ /** @returns The ViewContainerRef in which child branches are rendered */
24
66
  getBranchesContainer(): ViewContainerRef | undefined;
67
+ /** @returns The instance of BranchComponent that is rendered by this class. */
25
68
  getComponentInstance(): BranchComponent<UserlandComponent>;
69
+ /** @returns The Host View in which the BranchComponent is rendered */
26
70
  getHostView(): ViewRef;
71
+ /** @returns The BranchComponent as a native HTML Element */
27
72
  getNativeElement(): HTMLElement;
73
+ /**
74
+ * @returns
75
+ * A ComponentRef containing the instance of the user-provided
76
+ * component which is rendered by this branch.
77
+ */
28
78
  getUserlandComponentRef(): ComponentRef<UserlandComponent> | undefined;
79
+ /**
80
+ * Attaches a branch to a new parent node.
81
+ *
82
+ * @remarks
83
+ * If not already pruned, this method prunes (removes) this branch from its
84
+ * current position in the tree; then grafts (reattaches) it as a child of the
85
+ * specified parent branch at the specified index. If no index is specified,
86
+ * the branch is appended as the last child of the parent. This causes this
87
+ * branch's associated BranchComponent to be re-rendered in the DOM at the
88
+ * new location.
89
+ *
90
+ * @param newParent - The new parent branch unto which this branch will be grafted.
91
+ * @param index - The index at which this branch will be grafted. If not specified,
92
+ * this branch will be appended as the last child of the new parent.
93
+ *
94
+ * @returns The index at which this branch was grafted.
95
+ */
29
96
  graftTo(newParent: TreeNode<TreeBranch<UserlandComponent>, NodeComponent>, index?: number): number;
97
+ /**
98
+ * Appends a new child branch to this branch. The child branch will render
99
+ * the specified component according to the (optional) configuration parameter.
100
+ *
101
+ * @param component - The component to render in the new child branch.
102
+ * @param options - Configuration options for the new child branch.
103
+ *
104
+ * @returns
105
+ * The newly-created child branch.
106
+ */
30
107
  grow(component: Type<UserlandComponent>, options?: BranchOptions<UserlandComponent>): TreeBranch<UserlandComponent>;
108
+ /**
109
+ * Determines this branch's index in relation to its sibling branches.
110
+ *
111
+ * @remarks
112
+ * For example, if it is the first child of its parent, this method will return
113
+ * 0. If it is the second child of its parent, this method will return 1.
114
+ *
115
+ * If this branch has no parent, (eg, if this branch has been pruned) this
116
+ * method will return undefined.
117
+ *
118
+ * @returns
119
+ * The index of this branch in relation to its sibling branches, or undefined.
120
+ */
31
121
  index(): number | undefined;
122
+ /** @returns `true` if the branch is destroyed, `false` otherwise */
32
123
  isDestroyed(): boolean;
124
+ /**
125
+ * @returns
126
+ * The data that was passed into the `branchOptions`' `meta` property
127
+ * at construction.
128
+ */
33
129
  meta(): Record<string, any>;
130
+ /**
131
+ * @returns
132
+ * This branch's parent node (which may be a TreeBranch or TreeRoot).
133
+ * If this branch has no parent, (eg, if this branch has been pruned) this
134
+ * method will return undefined.
135
+ */
34
136
  parent(): TreeNode<TreeBranch<UserlandComponent>, NodeComponent> | undefined;
137
+ /**
138
+ * Provides a model describing this branch's descendants.
139
+ *
140
+ * @returns
141
+ * A multi-dimensional Map which describes the shape of this branch's
142
+ * descendants.
143
+ *
144
+ * @example
145
+ * A branch with no children will return an empty Map. A branch with
146
+ * a single child will return a Map with a single entry, where the key is the index
147
+ * of the branch (zero) and the value is an empty Map. A Tree like this:
148
+ *
149
+ * ```
150
+ * ---Branch-------Branch
151
+ * /
152
+ * Branch-------Branch
153
+ * \
154
+ * ---Branch
155
+ * ```
156
+ * Will return a Map of matching shape:
157
+ * ```
158
+ * Map {
159
+ * 0: Map { 0: Map {}},
160
+ * 1: Map {},
161
+ * 2: Map {}
162
+ * }
163
+ * ```
164
+ */
35
165
  plot(): TreePlot;
166
+ /**
167
+ * Calculates the branch's position in the tree relative to the Root.
168
+ *
169
+ * @remarks
170
+ * The position is described as an array of numbers, where each number
171
+ * represents the index of the branch at that level of the tree.
172
+ *
173
+ * For example, if this branch is the first child of the Root, this method
174
+ * will return [0]. If this branch is the second child of the first child
175
+ * of the Root, this method will return [0, 1].
176
+ *
177
+ * If the branch is not related to a TreeRoot, (such as when it has been
178
+ * pruned,) this method will throw an error.
179
+ *
180
+ * @returns
181
+ * An array of numbers which describe the branch's position in the tree
182
+ * relative to the Root.
183
+ */
36
184
  position(): Array<number>;
185
+ /**
186
+ * Removes a branch from its tree without destroying it.
187
+ *
188
+ * @remarks
189
+ * Removes this branch from its parent and detaches its associated
190
+ * BranchComponent from the DOM. This puts the branch in a "pruned" state,
191
+ * which may affect the behavior of other methods.
192
+ *
193
+ * A pruned branch can be reattached to any other node using the `graftTo` method.
194
+ *
195
+ * @returns
196
+ * Itself, or undefined if it is already in a pruned state.
197
+ */
37
198
  prune(): this | undefined;
199
+ /**
200
+ * Get the root of the tree to which this Branch is attached.
201
+ *
202
+ * @returns
203
+ * The TreeRoot of the tree this branch is in. If this branch is
204
+ * does not have a root (such as when it has been pruned) this method will
205
+ * return undefined.
206
+ */
38
207
  root(): TreeRoot<UserlandComponent> | undefined;
208
+ /**
209
+ * Traverses this branch's descendants in depth-first pre-order, executing
210
+ * the provided callback function on each node. Traversal includes this branch.
211
+ *
212
+ * @param callback - A function to execute on each node.
213
+ */
39
214
  traverse(callback: (node: TreeNode<TreeBranch<UserlandComponent>, NodeComponent>) => void): void;
40
215
  private checkGraftLocationValidity;
216
+ private handleUserlandError;
41
217
  private indexIsOutOfRange;
218
+ private furthestAncestor;
42
219
  private reattachView;
43
220
  private setIndentation;
44
221
  }
@@ -15,6 +15,7 @@ export declare class TreeNodeBase<UserlandComponent> implements Partial<TreeNode
15
15
  dispatch(event: TreeEvent): void;
16
16
  events(): Observable<TreeEvent>;
17
17
  getBranch(index: number): TreeBranch<UserlandComponent> | undefined;
18
+ handleUserlandError(error: unknown): never;
18
19
  isDestroyed(): boolean;
19
20
  plot(): TreePlot;
20
21
  traverse(callback: (node: TreeNode<TreeBranch<UserlandComponent>, NodeComponent>) => void): void;
@@ -1,30 +1,124 @@
1
- import { TreePlot } from "../../structure/tree-plot";
2
- import { Observable } from "rxjs";
3
- import { TreeEvent } from "../../structure/tree-event.interface";
1
+ import type { Observable } from "rxjs";
4
2
  import { TreeBranch } from "../tree-branch/tree-branch";
5
- import { Type, ViewContainerRef, ViewRef } from "@angular/core";
3
+ import type { Type, ViewContainerRef, ViewRef } from "@angular/core";
6
4
  import { RootComponent } from "../../components/root/root.component";
7
- import { NodeComponent } from "../../components/node-component.interface";
8
- import { BranchOptions } from "../branch-options.interface";
9
- import { TreeNode } from "../../structure";
5
+ import type { NodeComponent } from "../../components/node-component.interface";
6
+ import type { BranchOptions } from "../branch-options.interface";
7
+ import type { TreeNode, TreePlot, TreeEvent } from "../../structure";
8
+ /**
9
+ * Represents the base of the tree. It renders a very simple container for child
10
+ * branches. It has methods for creating and accessing those branches. It emits
11
+ * events when things happen in the tree.
12
+ */
10
13
  export declare class TreeRoot<UserlandComponent> implements TreeNode<TreeBranch<UserlandComponent>, RootComponent> {
11
14
  private readonly viewContainerRef;
12
15
  private readonly rootController;
13
16
  private readonly treeNodeBase;
14
17
  constructor(viewContainerRef: ViewContainerRef);
18
+ /** @returns All child branches as an array of TreeBranch instances */
15
19
  branches(): Array<TreeBranch<UserlandComponent>>;
20
+ /**
21
+ * Recursively destroys all branches of the tree, as well as itself.
22
+ *
23
+ * @remarks
24
+ * This releases all resources held or consumed by the tree.
25
+ *
26
+ * It is important to call this method when a tree is discarded, otherwise
27
+ * the tree will remain in memory and continue to consume resources.
28
+ */
16
29
  destroy(): void;
30
+ /** Run Angular change detection on the root of the tree */
17
31
  detectChanges(): void;
32
+ /**
33
+ * Emits the specified TreeEvent.
34
+ *
35
+ * @remarks
36
+ * Caution: It is not recommended to manually emit TreeEvents that are already
37
+ * provided by the library. For example, it is not recommended to emit a
38
+ * `GraftEvent`, `DestructionEvent`, etc. These events may be used by the tree,
39
+ * and emitting them manually may cause unexpected behavior. Instead, we
40
+ * recommend implementing the TreeEvent interface with your own custom events
41
+ * and dispatching those.
42
+ *
43
+ * @param event - The TreeEvent that will be emitted.
44
+ */
18
45
  dispatch(event: TreeEvent): void;
46
+ /**
47
+ * @returns
48
+ * An observable that emits TreeEvents whenever an event is dispatched
49
+ * in the root or any of its descendant branches.
50
+ */
19
51
  events(): Observable<TreeEvent>;
52
+ /**
53
+ * @returns
54
+ * The child branch at the specified index, or undefined if there is
55
+ * no child branch at the specified index.
56
+ */
20
57
  getBranch(index: number): TreeBranch<UserlandComponent> | undefined;
58
+ /** @returns The ViewContainerRef in which child branches are rendered */
21
59
  getBranchesContainer(): ViewContainerRef | undefined;
60
+ /**
61
+ * Retrieves the RootComponent.
62
+ *
63
+ * @remarks
64
+ * The RootComponent holds the BranchesContainer, as well as a single Dropzone
65
+ * for drag-and-drop operations.
66
+ *
67
+ * @returns The instance of RootComponent that is rendered by this class.
68
+ */
22
69
  getComponentInstance(): RootComponent;
70
+ /** @returns The Host View in which the RootComponent is rendered */
23
71
  getHostView(): ViewRef;
72
+ /** @returns The RootComponent as a native HTML Element */
24
73
  getNativeElement(): HTMLElement;
74
+ /**
75
+ * Appends a new child branch to this branch. The child branch will render
76
+ * the specified component according to the (optional) configuration parameter.
77
+ *
78
+ * @param component - The component to render in the new child branch.
79
+ * @param options - Configuration options for the new child branch.
80
+ *
81
+ * @returns
82
+ * The newly-created child branch.
83
+ */
25
84
  grow(component: Type<UserlandComponent>, options?: BranchOptions<UserlandComponent>): TreeBranch<UserlandComponent>;
85
+ /** @returns `true` if the tree is destroyed, `false` otherwise */
26
86
  isDestroyed(): boolean;
87
+ /**
88
+ * Provides a model describing the shape of the tree.
89
+ *
90
+ * @returns A multi-dimensional Map which describes the shape of the tree.
91
+ *
92
+ * @example
93
+ * For example, an empty tree will return an empty Map. A tree with a single
94
+ * branch will return a Map with a single entry, where the key is the index
95
+ * of the branch (zero) and the value is an empty Map. A Tree like this:
96
+ *
97
+ * ```
98
+ * ---Branch-------Branch
99
+ * /
100
+ * Root-------Branch
101
+ * \
102
+ * ---Branch
103
+ * ```
104
+ * Will return a Map of matching shape:
105
+ * ```
106
+ * Map {
107
+ * 0: Map { 0: Map {}},
108
+ * 1: Map {},
109
+ * 2: Map {}
110
+ * }
111
+ * ```
112
+ */
27
113
  plot(): TreePlot;
114
+ /** @returns Itself */
28
115
  root(): this;
116
+ /**
117
+ * Traverses the tree in depth-first pre-order, executing the provided
118
+ * callback function on each node. Traversal includes the Root.
119
+ *
120
+ * @param callback - A function to execute on each node.
121
+ */
29
122
  traverse(callback: (node: TreeNode<TreeBranch<UserlandComponent>, NodeComponent>) => void): void;
123
+ private handleUserlandError;
30
124
  }
@@ -1,8 +1,14 @@
1
- import { ViewContainerRef } from "@angular/core";
2
- import { TreeOptions } from "../configuration/tree-options.interface";
1
+ import { type ViewContainerRef } from "@angular/core";
2
+ import type { TreeOptions } from "../configuration/tree-options.interface";
3
3
  import { TreeRoot } from "../tree-root/tree-root";
4
4
  import * as i0 from "@angular/core";
5
+ /** Responsible for the creation of new trees. */
5
6
  export declare class TreeService {
7
+ /**
8
+ * Creates a new, empty tree structure inside the provided container.
9
+ *
10
+ * @returns A `TreeRoot` representing the base of the new tree.
11
+ */
6
12
  createEmptyTree<Component>(container: ViewContainerRef, options?: TreeOptions): TreeRoot<Component>;
7
13
  static ɵfac: i0.ɵɵFactoryDeclaration<TreeService, never>;
8
14
  static ɵprov: i0.ɵɵInjectableDeclaration<TreeService>;
@@ -1,24 +1,27 @@
1
- import { NodeComponent } from "../../components/node-component.interface";
2
- import { TreeBranch } from "../../core";
3
- import { TreeNode } from "../../structure";
4
- import { EventConduit } from "../../structure/event-conduit.interface";
5
- import { TreeEvent } from "../../structure/tree-event.interface";
1
+ import type { NodeComponent } from "../../components/node-component.interface";
2
+ import type { TreeBranch } from "../../core";
3
+ import type { TreeNode } from "../../structure";
4
+ import type { TreeEvent } from "../../structure/tree-event.interface";
5
+ /** Emitted when a drag-and-drop operation has completed */
6
6
  export declare class DragEndEvent<T> implements TreeEvent {
7
7
  private readonly _source;
8
8
  private readonly _newParent;
9
9
  private readonly _newIndex;
10
10
  private readonly _oldParent;
11
11
  private readonly _oldIndex;
12
- constructor(source: EventConduit, endpoints: {
12
+ constructor(source: TreeNode<TreeBranch<T>, NodeComponent>, endpoints: {
13
13
  oldParent: TreeNode<TreeBranch<T>, NodeComponent>;
14
14
  oldIndex: number;
15
15
  newParent: TreeNode<TreeBranch<T>, NodeComponent>;
16
16
  newIndex: number;
17
17
  });
18
- type(): "drag end";
19
- source(): EventConduit;
18
+ /** @returns The new index of the dropped branch */
20
19
  newIndex(): number;
20
+ /** @returns The new parent of the dropped branch */
21
21
  newParent(): TreeNode<TreeBranch<T>, NodeComponent>;
22
+ /** @returns The index of the dropped branch before it was dragged */
22
23
  oldIndex(): number;
24
+ /** @returns The parent of the dropped branch before it was dragged */
23
25
  oldParent(): TreeNode<TreeBranch<T>, NodeComponent>;
26
+ source(): TreeNode<TreeBranch<T>, NodeComponent>;
24
27
  }
@@ -1,8 +1,9 @@
1
- import { EventConduit } from "../../structure/event-conduit.interface";
2
- import { TreeEvent } from "../../structure/tree-event.interface";
1
+ import type { NodeComponent } from "../../components/node-component.interface";
2
+ import type { TreeNode } from "../../structure";
3
+ import type { TreeEvent } from "../../structure/tree-event.interface";
4
+ /** Emitted when a TreeBranch begins being dragged */
3
5
  export declare class DragStartEvent implements TreeEvent {
4
6
  private readonly _source;
5
- constructor(source: EventConduit);
6
- type(): "drag start";
7
- source(): EventConduit;
7
+ constructor(source: TreeNode<unknown, NodeComponent>);
8
+ source(): TreeNode<unknown, NodeComponent>;
8
9
  }
@@ -1,13 +1,13 @@
1
- import { NodeComponent } from "../../components/node-component.interface";
2
- import { TreeBranch } from "../../core";
3
- import { TreeNode, EventConduit, TreeEvent } from "../../structure";
1
+ import type { NodeComponent } from "../../components/node-component.interface";
2
+ import type { TreeBranch } from "../../core";
3
+ import type { TreeNode, TreeEvent } from "../../structure";
4
+ /** Emitted when a TreeBranch is dropped into a valid Dropzone */
4
5
  export declare class DropEvent<T> implements TreeEvent {
5
6
  private readonly _source;
6
7
  private readonly _parent;
7
8
  private readonly _index;
8
- constructor(source: EventConduit, parent: TreeNode<TreeBranch<T>, NodeComponent>, index: number);
9
- type(): "drag end";
10
- source(): EventConduit;
9
+ constructor(source: TreeNode<TreeBranch<T>, NodeComponent>, parent: TreeNode<TreeBranch<T>, NodeComponent>, index: number);
10
+ source(): TreeNode<TreeBranch<T>, NodeComponent>;
11
11
  index(): number;
12
12
  parent(): TreeNode<TreeBranch<T>, NodeComponent>;
13
13
  }
@@ -1,8 +1,8 @@
1
- import { EventConduit } from "../../structure/event-conduit.interface";
2
- import { TreeEvent } from "../../structure/tree-event.interface";
1
+ import type { NodeComponent } from "../../components/node-component.interface";
2
+ import type { TreeNode, TreeEvent } from "../../structure";
3
+ /** Emitted when a node is destroyed */
3
4
  export declare class DestructionEvent implements TreeEvent {
4
5
  private readonly _source;
5
- constructor(source: EventConduit);
6
- type(): "destruction";
7
- source(): EventConduit;
6
+ constructor(source: TreeNode<unknown, NodeComponent>);
7
+ source(): TreeNode<unknown, NodeComponent>;
8
8
  }
@@ -1,15 +1,14 @@
1
- import { EventConduit } from "../../structure/event-conduit.interface";
2
- import { RelationalTreeEvent } from "./relational-tree-event.interface";
3
- import { TreeRelationship } from "../../structure/tree-relationship.interface";
1
+ import type { RelationalTreeEvent } from "./relational-tree-event.interface";
2
+ import type { TreeRelationship } from "../../structure/tree-relationship.interface";
3
+ /** Emits when a branch is grafted to another tree node */
4
4
  export declare class GraftEvent<T extends TreeRelationship<any, any>> implements RelationalTreeEvent<T["parent"], T["child"]> {
5
5
  private readonly _source;
6
6
  private readonly _parent;
7
7
  private readonly _child;
8
8
  private readonly _index;
9
- constructor(source: EventConduit, relationship: T);
9
+ constructor(source: T["child"], relationship: T);
10
10
  child(): T["child"];
11
- type(): "graft";
12
11
  index(): number;
13
12
  parent(): T["parent"];
14
- source(): EventConduit;
13
+ source(): T["child"];
15
14
  }
@@ -1,15 +1,14 @@
1
- import { EventConduit } from "../../structure/event-conduit.interface";
2
- import { RelationalTreeEvent } from "./relational-tree-event.interface";
3
- import { TreeRelationship } from "../../structure/tree-relationship.interface";
1
+ import type { RelationalTreeEvent } from "./relational-tree-event.interface";
2
+ import type { TreeRelationship } from "../../structure/tree-relationship.interface";
3
+ /** Emitted when a branch is pruned from its parent branch */
4
4
  export declare class PruneEvent<T extends TreeRelationship<any, any>> implements RelationalTreeEvent<T["parent"], T["child"]> {
5
5
  private readonly _source;
6
6
  private readonly _parent;
7
7
  private readonly _child;
8
8
  private readonly _index;
9
- constructor(source: EventConduit, relationship: T);
9
+ constructor(source: T["child"], relationship: T);
10
10
  child(): T["child"];
11
- type(): "prune";
12
11
  index(): number;
13
12
  parent(): T["parent"];
14
- source(): EventConduit;
13
+ source(): T["child"];
15
14
  }
@@ -1,6 +1,10 @@
1
- import { TreeEvent } from "../../structure/tree-event.interface";
1
+ import type { TreeEvent } from "../../structure/tree-event.interface";
2
+ /** A TreeEvent which involves a parent/child relationship */
2
3
  export interface RelationalTreeEvent<Parent, Child> extends TreeEvent {
4
+ /** @returns The parent branch of the relationship */
3
5
  parent: () => Parent;
6
+ /** @returns The child branch of the relationship */
4
7
  child: () => Child;
8
+ /** @returns The index location of the child */
5
9
  index: () => number;
6
10
  }
@@ -1,4 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
+ /** A module containing the entities which provide collapse functionality */
2
3
  export declare class TreeCollapseModule {
3
4
  static ɵfac: i0.ɵɵFactoryDeclaration<TreeCollapseModule, never>;
4
5
  static ɵmod: i0.ɵɵNgModuleDeclaration<TreeCollapseModule, never, never, never>;