1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ContentChildren, Directive, ElementRef, IterableDiffers, QueryList, } from '@angular/core';
|
---|
9 | import { isObservable } from 'rxjs';
|
---|
10 | import { takeUntil } from 'rxjs/operators';
|
---|
11 | import { CDK_TREE_NODE_OUTLET_NODE, CdkTreeNodeOutlet } from './outlet';
|
---|
12 | import { CdkTree, CdkTreeNode } from './tree';
|
---|
13 | import { getTreeControlFunctionsMissingError } from './tree-errors';
|
---|
14 | /**
|
---|
15 | * Nested node is a child of `<cdk-tree>`. It works with nested tree.
|
---|
16 | * By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
|
---|
17 | * be added in the `cdkTreeNodeOutlet` in tree node template.
|
---|
18 | * The children of node will be automatically added to `cdkTreeNodeOutlet`.
|
---|
19 | */
|
---|
20 | export class CdkNestedTreeNode extends CdkTreeNode {
|
---|
21 | constructor(elementRef, tree, _differs) {
|
---|
22 | super(elementRef, tree);
|
---|
23 | this._differs = _differs;
|
---|
24 | // The classes are directly added here instead of in the host property because classes on
|
---|
25 | // the host property are not inherited with View Engine. It is not set as a @HostBinding because
|
---|
26 | // it is not set by the time it's children nodes try to read the class from it.
|
---|
27 | // TODO: move to host after View Engine deprecation
|
---|
28 | elementRef.nativeElement.classList.add('cdk-nested-tree-node');
|
---|
29 | }
|
---|
30 | ngAfterContentInit() {
|
---|
31 | this._dataDiffer = this._differs.find([]).create(this._tree.trackBy);
|
---|
32 | if (!this._tree.treeControl.getChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
33 | throw getTreeControlFunctionsMissingError();
|
---|
34 | }
|
---|
35 | const childrenNodes = this._tree.treeControl.getChildren(this.data);
|
---|
36 | if (Array.isArray(childrenNodes)) {
|
---|
37 | this.updateChildrenNodes(childrenNodes);
|
---|
38 | }
|
---|
39 | else if (isObservable(childrenNodes)) {
|
---|
40 | childrenNodes.pipe(takeUntil(this._destroyed))
|
---|
41 | .subscribe(result => this.updateChildrenNodes(result));
|
---|
42 | }
|
---|
43 | this.nodeOutlet.changes.pipe(takeUntil(this._destroyed))
|
---|
44 | .subscribe(() => this.updateChildrenNodes());
|
---|
45 | }
|
---|
46 | // This is a workaround for https://github.com/angular/angular/issues/23091
|
---|
47 | // In aot mode, the lifecycle hooks from parent class are not called.
|
---|
48 | ngOnInit() {
|
---|
49 | super.ngOnInit();
|
---|
50 | }
|
---|
51 | ngDoCheck() {
|
---|
52 | super.ngDoCheck();
|
---|
53 | }
|
---|
54 | ngOnDestroy() {
|
---|
55 | this._clear();
|
---|
56 | super.ngOnDestroy();
|
---|
57 | }
|
---|
58 | /** Add children dataNodes to the NodeOutlet */
|
---|
59 | updateChildrenNodes(children) {
|
---|
60 | const outlet = this._getNodeOutlet();
|
---|
61 | if (children) {
|
---|
62 | this._children = children;
|
---|
63 | }
|
---|
64 | if (outlet && this._children) {
|
---|
65 | const viewContainer = outlet.viewContainer;
|
---|
66 | this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
|
---|
67 | }
|
---|
68 | else {
|
---|
69 | // Reset the data differ if there's no children nodes displayed
|
---|
70 | this._dataDiffer.diff([]);
|
---|
71 | }
|
---|
72 | }
|
---|
73 | /** Clear the children dataNodes. */
|
---|
74 | _clear() {
|
---|
75 | const outlet = this._getNodeOutlet();
|
---|
76 | if (outlet) {
|
---|
77 | outlet.viewContainer.clear();
|
---|
78 | this._dataDiffer.diff([]);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | /** Gets the outlet for the current node. */
|
---|
82 | _getNodeOutlet() {
|
---|
83 | const outlets = this.nodeOutlet;
|
---|
84 | // Note that since we use `descendants: true` on the query, we have to ensure
|
---|
85 | // that we don't pick up the outlet of a child node by accident.
|
---|
86 | return outlets && outlets.find(outlet => !outlet._node || outlet._node === this);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | CdkNestedTreeNode.decorators = [
|
---|
90 | { type: Directive, args: [{
|
---|
91 | selector: 'cdk-nested-tree-node',
|
---|
92 | exportAs: 'cdkNestedTreeNode',
|
---|
93 | inputs: ['role', 'disabled', 'tabIndex'],
|
---|
94 | providers: [
|
---|
95 | { provide: CdkTreeNode, useExisting: CdkNestedTreeNode },
|
---|
96 | { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode }
|
---|
97 | ]
|
---|
98 | },] }
|
---|
99 | ];
|
---|
100 | CdkNestedTreeNode.ctorParameters = () => [
|
---|
101 | { type: ElementRef },
|
---|
102 | { type: CdkTree },
|
---|
103 | { type: IterableDiffers }
|
---|
104 | ];
|
---|
105 | CdkNestedTreeNode.propDecorators = {
|
---|
106 | nodeOutlet: [{ type: ContentChildren, args: [CdkTreeNodeOutlet, {
|
---|
107 | // We need to use `descendants: true`, because Ivy will no longer match
|
---|
108 | // indirect descendants if it's left as false.
|
---|
109 | descendants: true
|
---|
110 | },] }]
|
---|
111 | };
|
---|
112 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdGVkLW5vZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3RyZWUvbmVzdGVkLW5vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBQ0gsT0FBTyxFQUVMLGVBQWUsRUFDZixTQUFTLEVBRVQsVUFBVSxFQUVWLGVBQWUsRUFHZixTQUFTLEdBQ1YsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLFlBQVksRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUNsQyxPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sZ0JBQWdCLENBQUM7QUFFekMsT0FBTyxFQUFDLHlCQUF5QixFQUFFLGlC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