/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ContentChildren, Directive, ElementRef, IterableDiffers, QueryList, } from '@angular/core'; import { isObservable } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { CDK_TREE_NODE_OUTLET_NODE, CdkTreeNodeOutlet } from './outlet'; import { CdkTree, CdkTreeNode } from './tree'; import { getTreeControlFunctionsMissingError } from './tree-errors'; /** * Nested node is a child of ``. It works with nested tree. * By using `cdk-nested-tree-node` component in tree node template, children of the parent node will * be added in the `cdkTreeNodeOutlet` in tree node template. * The children of node will be automatically added to `cdkTreeNodeOutlet`. */ export class CdkNestedTreeNode extends CdkTreeNode { constructor(elementRef, tree, _differs) { super(elementRef, tree); this._differs = _differs; // The classes are directly added here instead of in the host property because classes on // the host property are not inherited with View Engine. It is not set as a @HostBinding because // it is not set by the time it's children nodes try to read the class from it. // TODO: move to host after View Engine deprecation elementRef.nativeElement.classList.add('cdk-nested-tree-node'); } ngAfterContentInit() { this._dataDiffer = this._differs.find([]).create(this._tree.trackBy); if (!this._tree.treeControl.getChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw getTreeControlFunctionsMissingError(); } const childrenNodes = this._tree.treeControl.getChildren(this.data); if (Array.isArray(childrenNodes)) { this.updateChildrenNodes(childrenNodes); } else if (isObservable(childrenNodes)) { childrenNodes.pipe(takeUntil(this._destroyed)) .subscribe(result => this.updateChildrenNodes(result)); } this.nodeOutlet.changes.pipe(takeUntil(this._destroyed)) .subscribe(() => this.updateChildrenNodes()); } // This is a workaround for https://github.com/angular/angular/issues/23091 // In aot mode, the lifecycle hooks from parent class are not called. ngOnInit() { super.ngOnInit(); } ngDoCheck() { super.ngDoCheck(); } ngOnDestroy() { this._clear(); super.ngOnDestroy(); } /** Add children dataNodes to the NodeOutlet */ updateChildrenNodes(children) { const outlet = this._getNodeOutlet(); if (children) { this._children = children; } if (outlet && this._children) { const viewContainer = outlet.viewContainer; this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data); } else { // Reset the data differ if there's no children nodes displayed this._dataDiffer.diff([]); } } /** Clear the children dataNodes. */ _clear() { const outlet = this._getNodeOutlet(); if (outlet) { outlet.viewContainer.clear(); this._dataDiffer.diff([]); } } /** Gets the outlet for the current node. */ _getNodeOutlet() { const outlets = this.nodeOutlet; // Note that since we use `descendants: true` on the query, we have to ensure // that we don't pick up the outlet of a child node by accident. return outlets && outlets.find(outlet => !outlet._node || outlet._node === this); } } CdkNestedTreeNode.decorators = [ { type: Directive, args: [{ selector: 'cdk-nested-tree-node', exportAs: 'cdkNestedTreeNode', inputs: ['role', 'disabled', 'tabIndex'], providers: [ { provide: CdkTreeNode, useExisting: CdkNestedTreeNode }, { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode } ] },] } ]; CdkNestedTreeNode.ctorParameters = () => [ { type: ElementRef }, { type: CdkTree }, { type: IterableDiffers } ]; CdkNestedTreeNode.propDecorators = { nodeOutlet: [{ type: ContentChildren, args: [CdkTreeNodeOutlet, { // We need to use `descendants: true`, because Ivy will no longer match // indirect descendants if it's left as false. descendants: true },] }] }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdGVkLW5vZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3RyZWUvbmVzdGVkLW5vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBQ0gsT0FBTyxFQUVMLGVBQWUsRUFDZixTQUFTLEVBRVQsVUFBVSxFQUVWLGVBQWUsRUFHZixTQUFTLEdBQ1YsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLFlBQVksRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUNsQyxPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sZ0JB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