[6a3a178] | 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 { SelectionModel } from '@angular/cdk/collections';
|
---|
| 9 | import { Observable } from 'rxjs';
|
---|
| 10 | import { TreeControl } from './tree-control';
|
---|
| 11 | /** Base tree control. It has basic toggle/expand/collapse operations on a single data node. */
|
---|
| 12 | export declare abstract class BaseTreeControl<T, K = T> implements TreeControl<T, K> {
|
---|
| 13 | /** Gets a list of descendent data nodes of a subtree rooted at given data node recursively. */
|
---|
| 14 | abstract getDescendants(dataNode: T): T[];
|
---|
| 15 | /** Expands all data nodes in the tree. */
|
---|
| 16 | abstract expandAll(): void;
|
---|
| 17 | /** Saved data node for `expandAll` action. */
|
---|
| 18 | dataNodes: T[];
|
---|
| 19 | /** A selection model with multi-selection to track expansion status. */
|
---|
| 20 | expansionModel: SelectionModel<K>;
|
---|
| 21 | /**
|
---|
| 22 | * Returns the identifier by which a dataNode should be tracked, should its
|
---|
| 23 | * reference change.
|
---|
| 24 | *
|
---|
| 25 | * Similar to trackBy for *ngFor
|
---|
| 26 | */
|
---|
| 27 | trackBy?: (dataNode: T) => K;
|
---|
| 28 | /** Get depth of a given data node, return the level number. This is for flat tree node. */
|
---|
| 29 | getLevel: (dataNode: T) => number;
|
---|
| 30 | /**
|
---|
| 31 | * Whether the data node is expandable. Returns true if expandable.
|
---|
| 32 | * This is for flat tree node.
|
---|
| 33 | */
|
---|
| 34 | isExpandable: (dataNode: T) => boolean;
|
---|
| 35 | /** Gets a stream that emits whenever the given data node's children change. */
|
---|
| 36 | getChildren: (dataNode: T) => (Observable<T[]> | T[] | undefined | null);
|
---|
| 37 | /** Toggles one single data node's expanded/collapsed state. */
|
---|
| 38 | toggle(dataNode: T): void;
|
---|
| 39 | /** Expands one single data node. */
|
---|
| 40 | expand(dataNode: T): void;
|
---|
| 41 | /** Collapses one single data node. */
|
---|
| 42 | collapse(dataNode: T): void;
|
---|
| 43 | /** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
|
---|
| 44 | isExpanded(dataNode: T): boolean;
|
---|
| 45 | /** Toggles a subtree rooted at `node` recursively. */
|
---|
| 46 | toggleDescendants(dataNode: T): void;
|
---|
| 47 | /** Collapse all dataNodes in the tree. */
|
---|
| 48 | collapseAll(): void;
|
---|
| 49 | /** Expands a subtree rooted at given data node recursively. */
|
---|
| 50 | expandDescendants(dataNode: T): void;
|
---|
| 51 | /** Collapses a subtree rooted at given data node recursively. */
|
---|
| 52 | collapseDescendants(dataNode: T): void;
|
---|
| 53 | protected _trackByValue(value: T | K): K;
|
---|
| 54 | }
|
---|