@limble/limble-tree 6.1.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/fesm2022/limble-limble-tree.mjs +43 -43
  2. package/fesm2022/limble-limble-tree.mjs.map +1 -1
  3. package/index.d.ts +823 -3
  4. package/package.json +3 -3
  5. package/lib/components/branch/branch.component.d.ts +0 -26
  6. package/lib/components/branch/index.d.ts +0 -1
  7. package/lib/components/dragover-no-change-detect.d.ts +0 -18
  8. package/lib/components/dropzone/dropzone.component.d.ts +0 -13
  9. package/lib/components/dropzone/index.d.ts +0 -1
  10. package/lib/components/host-component.interface.d.ts +0 -6
  11. package/lib/components/index.d.ts +0 -6
  12. package/lib/components/node-component.interface.d.ts +0 -5
  13. package/lib/components/root/index.d.ts +0 -1
  14. package/lib/components/root/root.component.d.ts +0 -14
  15. package/lib/core/branch-options.interface.d.ts +0 -14
  16. package/lib/core/branchable.interface.d.ts +0 -8
  17. package/lib/core/component-container.interface.d.ts +0 -8
  18. package/lib/core/configuration/configuration.d.ts +0 -11
  19. package/lib/core/configuration/index.d.ts +0 -2
  20. package/lib/core/configuration/tree-options.interface.d.ts +0 -54
  21. package/lib/core/index.d.ts +0 -10
  22. package/lib/core/tree-branch/branch-controller.d.ts +0 -25
  23. package/lib/core/tree-branch/graftable.interface.d.ts +0 -7
  24. package/lib/core/tree-branch/index.d.ts +0 -3
  25. package/lib/core/tree-branch/tree-branch.d.ts +0 -223
  26. package/lib/core/tree-node-base.d.ts +0 -26
  27. package/lib/core/tree-node.interface.d.ts +0 -16
  28. package/lib/core/tree-plot.interface.d.ts +0 -1
  29. package/lib/core/tree-root/index.d.ts +0 -2
  30. package/lib/core/tree-root/root-controller.d.ts +0 -19
  31. package/lib/core/tree-root/tree-root.d.ts +0 -125
  32. package/lib/core/tree-service/index.d.ts +0 -1
  33. package/lib/core/tree-service/tree.service.d.ts +0 -15
  34. package/lib/errors/index.d.ts +0 -1
  35. package/lib/errors/tree-error.d.ts +0 -2
  36. package/lib/events/drag/drag-end-event.d.ts +0 -25
  37. package/lib/events/drag/drag-start-event.d.ts +0 -8
  38. package/lib/events/drag/drop-event.d.ts +0 -12
  39. package/lib/events/drag/index.d.ts +0 -3
  40. package/lib/events/general/destruction-event.d.ts +0 -8
  41. package/lib/events/general/index.d.ts +0 -1
  42. package/lib/events/index.d.ts +0 -4
  43. package/lib/events/relational/graft-event.d.ts +0 -15
  44. package/lib/events/relational/index.d.ts +0 -4
  45. package/lib/events/relational/prune-event.d.ts +0 -15
  46. package/lib/events/relational/relational-tree-event.interface.d.ts +0 -11
  47. package/lib/events/relational/tree-relationship.interface.d.ts +0 -6
  48. package/lib/events/tree-event.interface.d.ts +0 -5
  49. package/lib/extras/collapse/collapse.d.ts +0 -11
  50. package/lib/extras/collapse/collapse.module.d.ts +0 -7
  51. package/lib/extras/collapse/collapse.service.d.ts +0 -34
  52. package/lib/extras/collapse/index.d.ts +0 -3
  53. package/lib/extras/drag-and-drop/drag-and-drop.d.ts +0 -14
  54. package/lib/extras/drag-and-drop/drag-and-drop.module.d.ts +0 -11
  55. package/lib/extras/drag-and-drop/drag-and-drop.service.d.ts +0 -35
  56. package/lib/extras/drag-and-drop/drag-state.d.ts +0 -23
  57. package/lib/extras/drag-and-drop/draggable.directive.d.ts +0 -11
  58. package/lib/extras/drag-and-drop/dropzone-renderer.d.ts +0 -27
  59. package/lib/extras/drag-and-drop/index.d.ts +0 -6
  60. package/lib/legacy/index.d.ts +0 -6
  61. package/lib/legacy/legacy-component-obj.interface.d.ts +0 -13
  62. package/lib/legacy/legacy-tree-data.interface.d.ts +0 -18
  63. package/lib/legacy/legacy-tree-options.interface.d.ts +0 -34
  64. package/lib/legacy/legacy-tree.d.ts +0 -14
  65. package/lib/legacy/limble-tree-legacy.module.d.ts +0 -8
  66. package/lib/legacy/limble-tree-root/limble-tree-root.component.d.ts +0 -28
  67. package/lib/limble-tree.module.d.ts +0 -13
  68. package/public-api.d.ts +0 -8
  69. package/shared/assert.d.ts +0 -1
  70. package/shared/has-property.d.ts +0 -3
  71. package/shared/index.d.ts +0 -2
package/index.d.ts CHANGED
@@ -1,5 +1,825 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Type, EventEmitter, ComponentRef, ViewContainerRef, AfterViewInit, OnDestroy, QueryList, ApplicationRef, OnInit, NgZone, ElementRef, ViewRef, OnChanges, Renderer2 } from '@angular/core';
3
+ import { Observable } from 'rxjs';
4
+
1
5
  /**
2
- * Generated bundle index. Do not edit.
6
+ * An object that references the component to be rendered and its bindings
7
+ * @deprecated
3
8
  */
4
- /// <amd-module name="@limble/limble-tree" />
5
- export * from './public-api';
9
+ interface ComponentObj {
10
+ /** The component class */
11
+ class: Type<unknown>;
12
+ /** The bindings (inputs and outputs) of the class */
13
+ bindings?: {
14
+ [index: string]: unknown;
15
+ };
16
+ }
17
+
18
+ /**
19
+ * An object describing a node of the tree
20
+ * @deprecated
21
+ */
22
+ interface LimbleTreeNode {
23
+ /** A list of nodes to be rendered "under" this one, one level deeper in the tree. */
24
+ nodes?: LimbleTreeData;
25
+ /** An object that describes the component which will represent this node in the visual tree */
26
+ component?: ComponentObj;
27
+ collapsed?: boolean;
28
+ [index: string]: unknown;
29
+ }
30
+ /**
31
+ * An object that the limble-tree-root component uses to build the tree
32
+ * @deprecated
33
+ */
34
+ type LimbleTreeData = Array<LimbleTreeNode>;
35
+
36
+ interface HostComponent<UserlandComponent> {
37
+ contentCreated: EventEmitter<UserlandComponent>;
38
+ contentToHost?: Type<UserlandComponent>;
39
+ getHostedContent: () => ComponentRef<UserlandComponent> | undefined;
40
+ }
41
+
42
+ interface NodeComponent {
43
+ branchesContainer: ViewContainerRef | undefined;
44
+ showInnerDropzone: boolean;
45
+ }
46
+
47
+ declare class DropzoneComponent {
48
+ placement?: "inner" | "lateral";
49
+ readonly dropped: EventEmitter<DragEvent>;
50
+ protected active: boolean;
51
+ dragenterHandler(): void;
52
+ dragleaveHandler(): void;
53
+ dragoverHandler(event: DragEvent): void;
54
+ dropHandler(event: DragEvent): void;
55
+ static ɵfac: i0.ɵɵFactoryDeclaration<DropzoneComponent, never>;
56
+ static ɵcmp: i0.ɵɵComponentDeclaration<DropzoneComponent, "dropzone", never, { "placement": { "alias": "placement"; "required": false; }; }, { "dropped": "dropped"; }, never, never, true, never>;
57
+ }
58
+
59
+ declare class BranchComponent<T> implements NodeComponent, HostComponent<T>, AfterViewInit, OnDestroy {
60
+ private readonly appRef;
61
+ branchesContainer: ViewContainerRef | undefined;
62
+ contentContainer: ViewContainerRef | undefined;
63
+ dropzones: QueryList<DropzoneComponent> | undefined;
64
+ contentToHost?: Type<T>;
65
+ readonly contentCreated: EventEmitter<T>;
66
+ readonly showDropzones: EventEmitter<"upper" | "lower">;
67
+ readonly dropped: EventEmitter<"inner" | "lateral">;
68
+ showInnerDropzone: boolean;
69
+ showLateralDropzone: boolean;
70
+ private hostedContent?;
71
+ constructor(appRef: ApplicationRef);
72
+ ngAfterViewInit(): void;
73
+ getHostedContent(): ComponentRef<T> | undefined;
74
+ triggerChangeDetection(): void;
75
+ protected dragoverHandler(event: DragEvent): void;
76
+ ngOnDestroy(): void;
77
+ static ɵfac: i0.ɵɵFactoryDeclaration<BranchComponent<any>, never>;
78
+ static ɵcmp: i0.ɵɵComponentDeclaration<BranchComponent<any>, "branch", never, { "contentToHost": { "alias": "contentToHost"; "required": false; }; }, { "contentCreated": "contentCreated"; "showDropzones": "showDropzones"; "dropped": "dropped"; }, never, never, true, never>;
79
+ }
80
+
81
+ declare class RootComponent implements NodeComponent, AfterViewInit {
82
+ branchesContainer: ViewContainerRef | undefined;
83
+ dropzone: DropzoneComponent | undefined;
84
+ readonly afterViewInit: EventEmitter<void>;
85
+ readonly dropped: EventEmitter<void>;
86
+ showInnerDropzone: boolean;
87
+ ngAfterViewInit(): void;
88
+ static ɵfac: i0.ɵɵFactoryDeclaration<RootComponent, never>;
89
+ static ɵcmp: i0.ɵɵComponentDeclaration<RootComponent, "root", never, {}, { "afterViewInit": "afterViewInit"; "dropped": "dropped"; }, never, never, true, never>;
90
+ }
91
+
92
+ /**
93
+ * Works just like Angular's built-in `(dragover)` event binding, but is much
94
+ * more performant. It throttles the event to a configurable rate (default once
95
+ * every 25ms) and runs outside of Angular's change detection.
96
+ */
97
+ declare class DragoverNoChangeDetectDirective implements OnInit, OnDestroy {
98
+ private readonly ngZone;
99
+ private readonly el;
100
+ readonly dragoverNoChangeDetect: EventEmitter<DragEvent>;
101
+ private eventSubscription;
102
+ constructor(ngZone: NgZone, el: ElementRef<Element>);
103
+ ngOnInit(): void;
104
+ ngOnDestroy(): void;
105
+ static ɵfac: i0.ɵɵFactoryDeclaration<DragoverNoChangeDetectDirective, never>;
106
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DragoverNoChangeDetectDirective, "[dragoverNoChangeDetect]", never, {}, { "dragoverNoChangeDetect": "dragoverNoChangeDetect"; }, never, never, true, never>;
107
+ }
108
+
109
+ interface ComponentContainer<Component> {
110
+ detectChanges: () => void;
111
+ getBranchesContainer: () => ViewContainerRef | undefined;
112
+ getComponentInstance: () => Component;
113
+ getHostView: () => ViewRef;
114
+ getNativeElement: () => HTMLElement;
115
+ }
116
+
117
+ type TreePlot = Map<number, TreePlot>;
118
+
119
+ interface BranchOptions<Component> {
120
+ inputBindings?: {
121
+ [K in keyof Component]?: Component[K];
122
+ };
123
+ outputBindings?: {
124
+ [K in keyof Component]?: Component[K] extends EventEmitter<infer T> ? (value: T) => void : never;
125
+ };
126
+ defaultCollapsed?: boolean;
127
+ meta?: Record<string, any>;
128
+ }
129
+ interface FullBranchOptions<Component> extends BranchOptions<Component> {
130
+ component: Type<Component>;
131
+ }
132
+
133
+ interface Branchable<UserlandComponent> {
134
+ branches: () => Array<TreeBranch<UserlandComponent>>;
135
+ getBranch: (index: number) => TreeBranch<UserlandComponent> | undefined;
136
+ grow: (component: Type<UserlandComponent>, options?: BranchOptions<UserlandComponent>) => TreeBranch<UserlandComponent>;
137
+ }
138
+
139
+ /** Emitted when a drag-and-drop operation has completed */
140
+ declare class DragEndEvent<T> implements TreeEvent<T> {
141
+ private readonly _source;
142
+ private readonly _newParent;
143
+ private readonly _newIndex;
144
+ private readonly _oldParent;
145
+ private readonly _oldIndex;
146
+ constructor(source: TreeNode<T>, endpoints: {
147
+ oldParent: TreeNode<T>;
148
+ oldIndex: number;
149
+ newParent: TreeNode<T>;
150
+ newIndex: number;
151
+ });
152
+ /** @returns The new index of the dropped branch */
153
+ newIndex(): number;
154
+ /** @returns The new parent of the dropped branch */
155
+ newParent(): TreeNode<T>;
156
+ /** @returns The index of the dropped branch before it was dragged */
157
+ oldIndex(): number;
158
+ /** @returns The parent of the dropped branch before it was dragged */
159
+ oldParent(): TreeNode<T>;
160
+ source(): TreeNode<T>;
161
+ }
162
+
163
+ /** Emitted when a TreeBranch begins being dragged */
164
+ declare class DragStartEvent<T> implements TreeEvent<T> {
165
+ private readonly _source;
166
+ constructor(source: TreeNode<T>);
167
+ source(): TreeNode<T>;
168
+ }
169
+
170
+ /** Emitted when a TreeBranch is dropped into a valid Dropzone */
171
+ declare class DropEvent<T> implements TreeEvent<T> {
172
+ private readonly _source;
173
+ private readonly _parent;
174
+ private readonly _index;
175
+ constructor(source: TreeNode<T>, parent: TreeNode<T>, index: number);
176
+ source(): TreeNode<T>;
177
+ index(): number;
178
+ parent(): TreeNode<T>;
179
+ }
180
+
181
+ /** Emitted when a node is destroyed */
182
+ declare class DestructionEvent<T> implements TreeEvent<T> {
183
+ private readonly _source;
184
+ constructor(source: TreeNode<T>);
185
+ source(): TreeNode<T>;
186
+ }
187
+
188
+ /** An event emitted by a node in the tree */
189
+ interface TreeEvent<UserlandComponent> {
190
+ source: () => TreeNode<UserlandComponent>;
191
+ }
192
+
193
+ /** A TreeEvent which involves a parent/child relationship */
194
+ interface RelationalTreeEvent<UserlandComponent> extends TreeEvent<UserlandComponent> {
195
+ /** @returns The parent branch of the relationship */
196
+ parent: () => TreeNode<UserlandComponent>;
197
+ /** @returns The child branch of the relationship */
198
+ child: () => TreeBranch<UserlandComponent>;
199
+ /** @returns The index location of the child */
200
+ index: () => number;
201
+ }
202
+
203
+ interface TreeRelationship<UserlandComponent> {
204
+ parent: TreeNode<UserlandComponent>;
205
+ child: TreeBranch<UserlandComponent>;
206
+ index: number;
207
+ }
208
+
209
+ /** Emits when a branch is grafted to another tree node */
210
+ declare class GraftEvent<UserlandComponent> implements RelationalTreeEvent<UserlandComponent> {
211
+ private readonly _source;
212
+ private readonly _parent;
213
+ private readonly _child;
214
+ private readonly _index;
215
+ constructor(source: TreeBranch<UserlandComponent>, relationship: TreeRelationship<UserlandComponent>);
216
+ child(): TreeBranch<UserlandComponent>;
217
+ index(): number;
218
+ parent(): TreeNode<UserlandComponent>;
219
+ source(): TreeBranch<UserlandComponent>;
220
+ }
221
+
222
+ /** Emitted when a branch is pruned from its parent branch */
223
+ declare class PruneEvent<UserlandComponent> implements RelationalTreeEvent<UserlandComponent> {
224
+ private readonly _source;
225
+ private readonly _parent;
226
+ private readonly _child;
227
+ private readonly _index;
228
+ constructor(source: TreeBranch<UserlandComponent>, relationship: TreeRelationship<UserlandComponent>);
229
+ child(): TreeBranch<UserlandComponent>;
230
+ index(): number;
231
+ parent(): TreeNode<UserlandComponent>;
232
+ source(): TreeBranch<UserlandComponent>;
233
+ }
234
+
235
+ interface TreeNode<UserlandComponent> extends Branchable<UserlandComponent>, ComponentContainer<NodeComponent> {
236
+ destroy: () => void;
237
+ dispatch: (event: TreeEvent<UserlandComponent>) => void;
238
+ events: () => Observable<TreeEvent<UserlandComponent>>;
239
+ isDestroyed: () => boolean;
240
+ plot: () => TreePlot;
241
+ root: () => TreeRoot<any> | undefined;
242
+ traverse: (callback: (node: TreeNode<UserlandComponent>) => void) => void;
243
+ }
244
+
245
+ interface Graftable<UserlandComponent> {
246
+ graftTo: (newParent: TreeNode<UserlandComponent>, index?: number) => number;
247
+ index: () => number | undefined;
248
+ parent: () => TreeNode<UserlandComponent> | undefined;
249
+ prune: () => void;
250
+ }
251
+
252
+ /** Represents a standard node in a tree. Renders a BranchComponent.
253
+ *
254
+ * @remarks
255
+ * This class renders a branch component, which does the following:
256
+ * 1. Renders a component provided by the user
257
+ * 2. Provides a container in which child branches may be rendered
258
+ * 3. Contains two Dropzones: one for dropping branches below this branch (as a
259
+ * sibling), and one for dropping branches as a first child of this branch.
260
+ */
261
+ declare class TreeBranch<UserlandComponent> implements TreeNode<UserlandComponent>, Graftable<UserlandComponent> {
262
+ readonly branchOptions: FullBranchOptions<UserlandComponent>;
263
+ private readonly branchController;
264
+ private detachedView;
265
+ private _parent;
266
+ private readonly treeNodeBase;
267
+ constructor(parent: TreeNode<UserlandComponent>, branchOptions: FullBranchOptions<UserlandComponent>);
268
+ /** @returns All child branches as an array of TreeBranch instances, in order. */
269
+ branches(): Array<TreeBranch<UserlandComponent>>;
270
+ /**
271
+ * Recursively destroys all descendant branches, as well as itself. This
272
+ * releases all resources held or consumed by this branch and its descendants.
273
+ *
274
+ * @remarks
275
+ * It is important to call this method when a branch is discarded, otherwise
276
+ * the branch will remain in memory and continue to consume resources.
277
+ */
278
+ destroy(): void;
279
+ /** Run Angular change detection on this branch */
280
+ detectChanges(): void;
281
+ /**
282
+ * Emits the specified TreeEvent.
283
+ *
284
+ * @remarks
285
+ * Caution: It is not recommended to manually emit TreeEvents that are already
286
+ * provided by the library. For example, it is not recommended to emit a
287
+ * `GraftEvent`, `DestructionEvent`, etc. These events may be used by the tree,
288
+ * and emitting them manually may cause unexpected behavior. Instead, we
289
+ * recommend implementing the TreeEvent interface with your own custom events
290
+ * and dispatching those.
291
+ *
292
+ * @param event - The TreeEvent that will be emitted.
293
+ */
294
+ dispatch(event: TreeEvent<UserlandComponent>): void;
295
+ /**
296
+ * @returns
297
+ * An observable that emits TreeEvents whenever an event is dispatched
298
+ * in this branch or any of its descendant branches.
299
+ */
300
+ events(): Observable<TreeEvent<UserlandComponent>>;
301
+ /**
302
+ * @param index - The index of the child branch to retrieve.
303
+ *
304
+ * @returns
305
+ * The child branch at the specified index, or undefined if there is
306
+ * no child branch at the specified index.
307
+ */
308
+ getBranch(index: number): TreeBranch<UserlandComponent> | undefined;
309
+ /** @returns The ViewContainerRef in which child branches are rendered */
310
+ getBranchesContainer(): ViewContainerRef | undefined;
311
+ /** @returns The instance of BranchComponent that is rendered by this class. */
312
+ getComponentInstance(): BranchComponent<UserlandComponent>;
313
+ /** @returns The Host View in which the BranchComponent is rendered */
314
+ getHostView(): ViewRef;
315
+ /** @returns The BranchComponent as a native HTML Element */
316
+ getNativeElement(): HTMLElement;
317
+ /**
318
+ * @returns
319
+ * A ComponentRef containing the instance of the user-provided
320
+ * component which is rendered by this branch.
321
+ */
322
+ getUserlandComponentRef(): ComponentRef<UserlandComponent> | undefined;
323
+ /**
324
+ * Attaches a branch to a new parent node.
325
+ *
326
+ * @remarks
327
+ * If not already pruned, this method prunes (removes) this branch from its
328
+ * current position in the tree; then grafts (reattaches) it as a child of the
329
+ * specified parent branch at the specified index. If no index is specified,
330
+ * the branch is appended as the last child of the parent. This causes this
331
+ * branch's associated BranchComponent to be re-rendered in the DOM at the
332
+ * new location.
333
+ *
334
+ * @param newParent - The new parent branch unto which this branch will be grafted.
335
+ * @param index - The index at which this branch will be grafted. If not specified,
336
+ * this branch will be appended as the last child of the new parent.
337
+ *
338
+ * @returns The index at which this branch was grafted.
339
+ */
340
+ graftTo(newParent: TreeNode<UserlandComponent>, index?: number): number;
341
+ /**
342
+ * Appends a new child branch to this branch. The child branch will render
343
+ * the specified component according to the (optional) configuration parameter.
344
+ *
345
+ * @param component - The component to render in the new child branch.
346
+ * @param options - Configuration options for the new child branch.
347
+ *
348
+ * @returns
349
+ * The newly-created child branch.
350
+ */
351
+ grow(component: Type<UserlandComponent>, options?: BranchOptions<UserlandComponent>): TreeBranch<UserlandComponent>;
352
+ /**
353
+ * Determines this branch's index in relation to its sibling branches.
354
+ *
355
+ * @remarks
356
+ * For example, if it is the first child of its parent, this method will return
357
+ * 0. If it is the second child of its parent, this method will return 1.
358
+ *
359
+ * If this branch has no parent, (eg, if this branch has been pruned) this
360
+ * method will return undefined.
361
+ *
362
+ * @returns
363
+ * The index of this branch in relation to its sibling branches, or undefined.
364
+ */
365
+ index(): number | undefined;
366
+ /** @returns `true` if the branch is destroyed, `false` otherwise */
367
+ isDestroyed(): boolean;
368
+ /**
369
+ * @returns
370
+ * The data that was passed into the `branchOptions`' `meta` property
371
+ * at construction.
372
+ */
373
+ meta(): Record<string, any>;
374
+ /**
375
+ * @returns
376
+ * This branch's parent node (which may be a TreeBranch or TreeRoot).
377
+ * If this branch has no parent, (eg, if this branch has been pruned) this
378
+ * method will return undefined.
379
+ */
380
+ parent(): TreeNode<UserlandComponent> | undefined;
381
+ /**
382
+ * Provides a model describing this branch's descendants.
383
+ *
384
+ * @returns
385
+ * A multi-dimensional Map which describes the shape of this branch's
386
+ * descendants.
387
+ *
388
+ * @example
389
+ * A branch with no children will return an empty Map. A branch with
390
+ * a single child will return a Map with a single entry, where the key is the index
391
+ * of the branch (zero) and the value is an empty Map. A Tree like this:
392
+ *
393
+ * ```
394
+ * ---Branch-------Branch
395
+ * /
396
+ * Branch-------Branch
397
+ * \
398
+ * ---Branch
399
+ * ```
400
+ * Will return a Map of matching shape:
401
+ * ```
402
+ * Map {
403
+ * 0: Map { 0: Map {}},
404
+ * 1: Map {},
405
+ * 2: Map {}
406
+ * }
407
+ * ```
408
+ */
409
+ plot(): TreePlot;
410
+ /**
411
+ * Calculates the branch's position in the tree relative to the Root.
412
+ *
413
+ * @remarks
414
+ * The position is described as an array of numbers, where each number
415
+ * represents the index of the branch at that level of the tree.
416
+ *
417
+ * For example, if this branch is the first child of the Root, this method
418
+ * will return [0]. If this branch is the second child of the first child
419
+ * of the Root, this method will return [0, 1].
420
+ *
421
+ * If the branch is not related to a TreeRoot, (such as when it has been
422
+ * pruned,) this method will throw an error.
423
+ *
424
+ * @returns
425
+ * An array of numbers which describe the branch's position in the tree
426
+ * relative to the Root.
427
+ */
428
+ position(): Array<number>;
429
+ /**
430
+ * Removes a branch from its tree without destroying it.
431
+ *
432
+ * @remarks
433
+ * Removes this branch from its parent and detaches its associated
434
+ * BranchComponent from the DOM. This puts the branch in a "pruned" state,
435
+ * which may affect the behavior of other methods.
436
+ *
437
+ * A pruned branch can be reattached to any other node using the `graftTo` method.
438
+ *
439
+ * @returns
440
+ * Itself, or undefined if it is already in a pruned state.
441
+ */
442
+ prune(): this | undefined;
443
+ /**
444
+ * Get the root of the tree to which this Branch is attached.
445
+ *
446
+ * @returns
447
+ * The TreeRoot of the tree this branch is in. If this branch is
448
+ * does not have a root (such as when it has been pruned) this method will
449
+ * return undefined.
450
+ */
451
+ root(): TreeRoot<UserlandComponent> | undefined;
452
+ /**
453
+ * Traverses this branch's descendants in depth-first pre-order, executing
454
+ * the provided callback function on each node. Traversal includes this branch.
455
+ *
456
+ * @param callback - A function to execute on each node.
457
+ */
458
+ traverse(callback: (node: TreeBranch<UserlandComponent>) => void): void;
459
+ private checkGraftLocationValidity;
460
+ private handleUserlandError;
461
+ private indexIsOutOfRange;
462
+ private furthestAncestor;
463
+ private reattachView;
464
+ private setIndentation;
465
+ }
466
+
467
+ /**
468
+ * Represents the base of the tree. It renders a very simple container for child
469
+ * branches. It has methods for creating and accessing those branches. It emits
470
+ * events when things happen in the tree.
471
+ */
472
+ declare class TreeRoot<UserlandComponent> implements TreeNode<UserlandComponent> {
473
+ private readonly viewContainerRef;
474
+ private readonly rootController;
475
+ private readonly treeNodeBase;
476
+ constructor(viewContainerRef: ViewContainerRef);
477
+ /** @returns All child branches as an array of TreeBranch instances */
478
+ branches(): Array<TreeBranch<UserlandComponent>>;
479
+ /**
480
+ * Recursively destroys all branches of the tree, as well as itself.
481
+ *
482
+ * @remarks
483
+ * This releases all resources held or consumed by the tree.
484
+ *
485
+ * It is important to call this method when a tree is discarded, otherwise
486
+ * the tree will remain in memory and continue to consume resources.
487
+ */
488
+ destroy(): void;
489
+ /** Run Angular change detection on the root of the tree */
490
+ detectChanges(): void;
491
+ /**
492
+ * Emits the specified TreeEvent.
493
+ *
494
+ * @remarks
495
+ * Caution: It is not recommended to manually emit TreeEvents that are already
496
+ * provided by the library. For example, it is not recommended to emit a
497
+ * `GraftEvent`, `DestructionEvent`, etc. These events may be used by the tree,
498
+ * and emitting them manually may cause unexpected behavior. Instead, we
499
+ * recommend implementing the TreeEvent interface with your own custom events
500
+ * and dispatching those.
501
+ *
502
+ * @param event - The TreeEvent that will be emitted.
503
+ */
504
+ dispatch(event: TreeEvent<UserlandComponent>): void;
505
+ /**
506
+ * @returns
507
+ * An observable that emits TreeEvents whenever an event is dispatched
508
+ * in the root or any of its descendant branches.
509
+ */
510
+ events(): Observable<TreeEvent<UserlandComponent>>;
511
+ /**
512
+ * @returns
513
+ * The child branch at the specified index, or undefined if there is
514
+ * no child branch at the specified index.
515
+ */
516
+ getBranch(index: number): TreeBranch<UserlandComponent> | undefined;
517
+ /** @returns The ViewContainerRef in which child branches are rendered */
518
+ getBranchesContainer(): ViewContainerRef | undefined;
519
+ /**
520
+ * Retrieves the RootComponent.
521
+ *
522
+ * @remarks
523
+ * The RootComponent holds the BranchesContainer, as well as a single Dropzone
524
+ * for drag-and-drop operations.
525
+ *
526
+ * @returns The instance of RootComponent that is rendered by this class.
527
+ */
528
+ getComponentInstance(): RootComponent;
529
+ /** @returns The Host View in which the RootComponent is rendered */
530
+ getHostView(): ViewRef;
531
+ /** @returns The RootComponent as a native HTML Element */
532
+ getNativeElement(): HTMLElement;
533
+ /**
534
+ * Appends a new child branch to this branch. The child branch will render
535
+ * the specified component according to the (optional) configuration parameter.
536
+ *
537
+ * @param component - The component to render in the new child branch.
538
+ * @param options - Configuration options for the new child branch.
539
+ *
540
+ * @returns
541
+ * The newly-created child branch.
542
+ */
543
+ grow(component: Type<UserlandComponent>, options?: BranchOptions<UserlandComponent>): TreeBranch<UserlandComponent>;
544
+ /** @returns `true` if the tree is destroyed, `false` otherwise */
545
+ isDestroyed(): boolean;
546
+ /**
547
+ * Provides a model describing the shape of the tree.
548
+ *
549
+ * @returns A multi-dimensional Map which describes the shape of the tree.
550
+ *
551
+ * @example
552
+ * For example, an empty tree will return an empty Map. A tree with a single
553
+ * branch will return a Map with a single entry, where the key is the index
554
+ * of the branch (zero) and the value is an empty Map. A Tree like this:
555
+ *
556
+ * ```
557
+ * ---Branch-------Branch
558
+ * /
559
+ * Root-------Branch
560
+ * \
561
+ * ---Branch
562
+ * ```
563
+ * Will return a Map of matching shape:
564
+ * ```
565
+ * Map {
566
+ * 0: Map { 0: Map {}},
567
+ * 1: Map {},
568
+ * 2: Map {}
569
+ * }
570
+ * ```
571
+ */
572
+ plot(): TreePlot;
573
+ /** @returns Itself */
574
+ root(): this;
575
+ /**
576
+ * Traverses the tree in depth-first pre-order, executing the provided
577
+ * callback function on each node. Traversal includes the Root.
578
+ *
579
+ * @param callback - A function to execute on each node.
580
+ */
581
+ traverse(callback: (node: TreeNode<UserlandComponent>) => void): void;
582
+ private handleUserlandError;
583
+ }
584
+
585
+ /** The configuration options for a tree, as identified by a TreeRoot */
586
+ interface TreeOptions {
587
+ dragAndDrop?: {
588
+ /**
589
+ * A function that determines whether to allow a node to be dragged.
590
+ *
591
+ * @remarks
592
+ * Runs when a drag begins, but before the branch is pruned from the tree.
593
+ *
594
+ * @param treeBranch - The node of the tree that is about to be dragged.
595
+ *
596
+ * @defaultValue A function that always returns true.
597
+ *
598
+ * @returns `true` if the node can be dragged; `false` if it cannot.
599
+ */
600
+ allowDragging?: <T>(treeBranch: TreeBranch<T>) => boolean;
601
+ /**
602
+ * A function to determine whether a sourceNode can be dropped at a
603
+ * particular location.
604
+ *
605
+ * @remarks
606
+ * This function runs just before displaying a family of dropzones.
607
+ *
608
+ * @param sourceBranch - The branch that is being dragged.
609
+ * @param proposedParent - The proposed new parent of the sourceBranch.
610
+ * @param proposedIndex - The proposed new index of the sourceBranch.
611
+ *
612
+ * @defaultValue A function that always returns true.
613
+ */
614
+ allowDrop?: <T>(sourceBranch: TreeBranch<T>, proposedParent: TreeBranch<T> | TreeRoot<T>, proposedIndex: number) => boolean;
615
+ /**
616
+ * A function to indicate whether to allow "nesting" (placing a branch as
617
+ * a child) of a particular branch.
618
+ *
619
+ * @remarks
620
+ * This function runs just before displaying a family of dropzones.
621
+ *
622
+ * @param treeBranch - The node of the tree whose nesting capability is being
623
+ * checked.
624
+ *
625
+ * @defaultValue A function that always returns true.
626
+ */
627
+ allowNesting?: <T>(treeBranch: TreeBranch<T>) => boolean;
628
+ };
629
+ /**
630
+ * The number of pixels each level of the tree will be indented relative to
631
+ * its parent.
632
+ *
633
+ * @defaultValue 16
634
+ */
635
+ indentation?: number;
636
+ }
637
+
638
+ /** Responsible for the creation of new trees. */
639
+ declare class TreeService {
640
+ /**
641
+ * Creates a new, empty tree structure inside the provided container.
642
+ *
643
+ * @returns A `TreeRoot` representing the base of the new tree.
644
+ */
645
+ createEmptyTree<Component>(container: ViewContainerRef, options?: TreeOptions): TreeRoot<Component>;
646
+ static ɵfac: i0.ɵɵFactoryDeclaration<TreeService, never>;
647
+ static ɵprov: i0.ɵɵInjectableDeclaration<TreeService>;
648
+ }
649
+
650
+ declare class TreeError extends Error {
651
+ }
652
+
653
+ /**
654
+ * A group of settings for changing the functionality of the tree
655
+ * @deprecated
656
+ */
657
+ interface LimbleTreeOptions {
658
+ /** The component object to use if one is not specified for a particular node */
659
+ defaultComponent?: ComponentObj;
660
+ /** The number of pixels to indent each level of the tree. Defaults to 45 */
661
+ indent?: number;
662
+ /**
663
+ * Whether to allow "nesting" (placing a node one level deeper than currently exists on the branch).
664
+ * When this is a boolean, it applies to all nodes. When this is a function, the node in question
665
+ * is passed in. Defaults to true.
666
+ */
667
+ allowNesting?: boolean | (<T>(treeBranch: TreeBranch<T>) => boolean);
668
+ /**
669
+ * Whether to allow a node to be dragged. When this is a boolean, it applies to all nodes. When this
670
+ * is a function, the node in question is passed in. Defaults to true.
671
+ */
672
+ allowDragging?: boolean | (<T>(treeBranch: TreeBranch<T>) => boolean);
673
+ /** A callback to determine whether a sourceNode can be dropped at a particular location. */
674
+ allowDrop?: <T>(sourceNode: TreeBranch<T>, proposedParent: TreeBranch<T> | TreeRoot<T>, proposedIndex: number) => boolean;
675
+ /**
676
+ * When set to true, list mode will enforce a flat tree structure, meaning there
677
+ * can only be one level of the tree. `allowNesting` is automatically set to `false`.
678
+ *
679
+ * This mode can be used when the same dynamic drag and drop functionality of
680
+ * the tree is desired, but the tree structure itself is not necessary. This
681
+ * also opens up the pagination API on the limble-tree-root component.
682
+ */
683
+ listMode?: boolean;
684
+ }
685
+
686
+ /** @deprecated */
687
+ declare class LimbleTreeRootComponent implements AfterViewInit, OnChanges, OnDestroy {
688
+ data?: LimbleTreeData;
689
+ options?: LimbleTreeOptions | undefined;
690
+ itemsPerPage: number;
691
+ page: number;
692
+ host?: ViewContainerRef;
693
+ readonly treeChange: EventEmitter<TreeRoot<any>>;
694
+ readonly treeDrop: EventEmitter<DragEndEvent<any>>;
695
+ private dropSubscription?;
696
+ private readonly legacyTree;
697
+ private root?;
698
+ constructor();
699
+ ngOnChanges(): void;
700
+ ngAfterViewInit(): void;
701
+ ngOnDestroy(): void;
702
+ getRoot(): TreeRoot<any> | undefined;
703
+ update(): void;
704
+ private paginatedData;
705
+ static ɵfac: i0.ɵɵFactoryDeclaration<LimbleTreeRootComponent, never>;
706
+ static ɵcmp: i0.ɵɵComponentDeclaration<LimbleTreeRootComponent, "limble-tree-root", never, { "data": { "alias": "data"; "required": false; }; "options": { "alias": "options"; "required": false; }; "itemsPerPage": { "alias": "itemsPerPage"; "required": false; }; "page": { "alias": "page"; "required": false; }; }, { "treeChange": "treeChange"; "treeDrop": "treeDrop"; }, never, never, true, never>;
707
+ }
708
+
709
+ /** @deprecated */
710
+ declare class LimbleTreeLegacyModule {
711
+ static ɵfac: i0.ɵɵFactoryDeclaration<LimbleTreeLegacyModule, never>;
712
+ static ɵmod: i0.ɵɵNgModuleDeclaration<LimbleTreeLegacyModule, never, [typeof LimbleTreeRootComponent], [typeof LimbleTreeRootComponent]>;
713
+ static ɵinj: i0.ɵɵInjectorDeclaration<LimbleTreeLegacyModule>;
714
+ }
715
+
716
+ /** A module containing the entities which provide collapse functionality */
717
+ declare class TreeCollapseModule {
718
+ static ɵfac: i0.ɵɵFactoryDeclaration<TreeCollapseModule, never>;
719
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TreeCollapseModule, never, never, never>;
720
+ static ɵinj: i0.ɵɵInjectorDeclaration<TreeCollapseModule>;
721
+ }
722
+
723
+ /** Makes an TreeBranch draggable when the host element is dragged */
724
+ declare class DraggableDirective {
725
+ limbleTreeDraggable?: TreeBranch<any> | undefined;
726
+ constructor(renderer: Renderer2, hostElement: ElementRef<HTMLElement>);
727
+ onDragstart(event: DragEvent): void;
728
+ static ɵfac: i0.ɵɵFactoryDeclaration<DraggableDirective, never>;
729
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DraggableDirective, "[limbleTreeDraggable]", never, { "limbleTreeDraggable": { "alias": "limbleTreeDraggable"; "required": false; }; }, {}, never, never, true, never>;
730
+ }
731
+
732
+ /**
733
+ * An Angular module containing all of the entities which provide Drag-And-Drop
734
+ * functionality.
735
+ */
736
+ declare class TreeDragAndDropModule {
737
+ static ɵfac: i0.ɵɵFactoryDeclaration<TreeDragAndDropModule, never>;
738
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TreeDragAndDropModule, never, [typeof DraggableDirective], [typeof DraggableDirective]>;
739
+ static ɵinj: i0.ɵɵInjectorDeclaration<TreeDragAndDropModule>;
740
+ }
741
+
742
+ /**
743
+ * Import this Angular module into your application to gain access to the
744
+ * components, directives, and services provided by Limble Tree.
745
+ */
746
+ declare class LimbleTreeModule {
747
+ static ɵfac: i0.ɵɵFactoryDeclaration<LimbleTreeModule, never>;
748
+ static ɵmod: i0.ɵɵNgModuleDeclaration<LimbleTreeModule, never, [typeof LimbleTreeLegacyModule, typeof TreeCollapseModule, typeof TreeDragAndDropModule], [typeof LimbleTreeLegacyModule, typeof TreeCollapseModule, typeof TreeDragAndDropModule]>;
749
+ static ɵinj: i0.ɵɵInjectorDeclaration<LimbleTreeModule>;
750
+ }
751
+
752
+ /** A service that collapses and expands tree branches */
753
+ declare class TreeCollapseService {
754
+ /**
755
+ * Causes a TreeBranch to collapse, temporarily pruning all of its children
756
+ * from the tree.
757
+ *
758
+ * @param treeBranch - The branch to collapse.
759
+ */
760
+ collapse<T>(treeBranch: TreeBranch<T>): void;
761
+ /**
762
+ * Causes a TreeBranch to expand, restoring all of its children which were
763
+ * previously pruned by a call to `collapse()`.
764
+ *
765
+ * @param treeBranch - The branch to expand.
766
+ */
767
+ expand<T>(treeBranch: TreeBranch<T>): void;
768
+ /**
769
+ * Determines whether a TreeBranch currently has any children which are
770
+ * pruned from the tree due to a call to the `collapse()` method.
771
+ *
772
+ * @remarks
773
+ * Child branches which are pruned manually from the tree, rather than
774
+ * through the `collapse()` method, will not be considered.
775
+ *
776
+ * @param treeBranch - The branch to check.
777
+ *
778
+ * @returns `true` if the branch is currently collapsed; `false` if it is not.
779
+ */
780
+ isCollapsed<T>(treeBranch: TreeBranch<T>): boolean;
781
+ static ɵfac: i0.ɵɵFactoryDeclaration<TreeCollapseService, never>;
782
+ static ɵprov: i0.ɵɵInjectableDeclaration<TreeCollapseService>;
783
+ }
784
+
785
+ declare enum DragStates {
786
+ Idle = 0,
787
+ Starting = 1,
788
+ Dragging = 2,
789
+ Dropped = 3
790
+ }
791
+
792
+ declare class TreeDragAndDropService {
793
+ /** Hides all Dropzones */
794
+ clearDropzones(): void;
795
+ /**
796
+ * @returns An object that indicates which dropzones are currently being displayed.
797
+ * If no dropzones are being displayed, then null is returned.
798
+ */
799
+ getCurrentlyDisplayedDropzoneFamily(): {
800
+ treeBranch: TreeNode<any>;
801
+ direction: "upper" | "lower";
802
+ } | null;
803
+ /**
804
+ * Causes the dropzone of the TreeRoot to be displayed.
805
+ *
806
+ * @remarks
807
+ * This is a useful function when you want to show the dropzone of a TreeRoot
808
+ * that has no child branches.
809
+ *
810
+ * @param root - The TreeRoot whose dropzone you want to show.
811
+ */
812
+ showRootDropzone<T>(root: TreeRoot<T>): void;
813
+ /**
814
+ * @returns An observable that emits a number whenever the drag state changes.
815
+ *
816
+ * @remarks
817
+ * See the `DragStates` enum for a list of possible states.
818
+ */
819
+ state(): Observable<DragStates>;
820
+ static ɵfac: i0.ɵɵFactoryDeclaration<TreeDragAndDropService, never>;
821
+ static ɵprov: i0.ɵɵInjectableDeclaration<TreeDragAndDropService>;
822
+ }
823
+
824
+ export { BranchComponent, DestructionEvent, DragEndEvent, DragStartEvent, DraggableDirective, DragoverNoChangeDetectDirective, DropEvent, GraftEvent, LimbleTreeLegacyModule, LimbleTreeModule, LimbleTreeRootComponent, PruneEvent, RootComponent, TreeBranch, TreeCollapseModule, TreeCollapseService, TreeDragAndDropModule, TreeDragAndDropService, TreeError, TreeRoot, TreeService };
825
+ export type { ComponentObj, HostComponent, LimbleTreeData, LimbleTreeNode, LimbleTreeOptions, NodeComponent, TreeEvent, TreeNode, TreeOptions, TreePlot };