/** * @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'; import * as i0 from "@angular/core"; import * as i1 from "./tree"; /** * 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; } 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(); } 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); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkNestedTreeNode, deps: [{ token: i0.ElementRef }, { token: i1.CdkTree }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: CdkNestedTreeNode, selector: "cdk-nested-tree-node", inputs: { role: "role", disabled: "disabled", tabIndex: "tabIndex" }, host: { classAttribute: "cdk-nested-tree-node" }, providers: [ { provide: CdkTreeNode, useExisting: CdkNestedTreeNode }, { provide: CDK_TREE_NODE_OUTLET_NODE, useExisting: CdkNestedTreeNode }, ], queries: [{ propertyName: "nodeOutlet", predicate: CdkTreeNodeOutlet, descendants: true }], exportAs: ["cdkNestedTreeNode"], usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: 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 }, ], host: { 'class': 'cdk-nested-tree-node', }, }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.CdkTree }, { type: i0.IterableDiffers }]; }, 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;base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