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 { FocusableOption } from '@angular/cdk/a11y';
|
---|
9 | import { CollectionViewer, DataSource } from '@angular/cdk/collections';
|
---|
10 | import { AfterContentChecked, ChangeDetectorRef, DoCheck, ElementRef, IterableDiffer, IterableDiffers, OnDestroy, OnInit, QueryList, TrackByFunction, ViewContainerRef } from '@angular/core';
|
---|
11 | import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
---|
12 | import { TreeControl } from './control/tree-control';
|
---|
13 | import { CdkTreeNodeDef } from './node';
|
---|
14 | import { CdkTreeNodeOutlet } from './outlet';
|
---|
15 | /**
|
---|
16 | * CDK tree component that connects with a data source to retrieve data of type `T` and renders
|
---|
17 | * dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
|
---|
18 | */
|
---|
19 | export declare class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer, OnDestroy, OnInit {
|
---|
20 | private _differs;
|
---|
21 | private _changeDetectorRef;
|
---|
22 | /** Subject that emits when the component has been destroyed. */
|
---|
23 | private readonly _onDestroy;
|
---|
24 | /** Differ used to find the changes in the data provided by the data source. */
|
---|
25 | private _dataDiffer;
|
---|
26 | /** Stores the node definition that does not have a when predicate. */
|
---|
27 | private _defaultNodeDef;
|
---|
28 | /** Data subscription */
|
---|
29 | private _dataSubscription;
|
---|
30 | /** Level of nodes */
|
---|
31 | private _levels;
|
---|
32 | /**
|
---|
33 | * Provides a stream containing the latest data array to render. Influenced by the tree's
|
---|
34 | * stream of view window (what dataNodes are currently on screen).
|
---|
35 | * Data source can be an observable of data array, or a data array to render.
|
---|
36 | */
|
---|
37 | get dataSource(): DataSource<T> | Observable<T[]> | T[];
|
---|
38 | set dataSource(dataSource: DataSource<T> | Observable<T[]> | T[]);
|
---|
39 | private _dataSource;
|
---|
40 | /** The tree controller */
|
---|
41 | treeControl: TreeControl<T, K>;
|
---|
42 | /**
|
---|
43 | * Tracking function that will be used to check the differences in data changes. Used similarly
|
---|
44 | * to `ngFor` `trackBy` function. Optimize node operations by identifying a node based on its data
|
---|
45 | * relative to the function to know if a node should be added/removed/moved.
|
---|
46 | * Accepts a function that takes two parameters, `index` and `item`.
|
---|
47 | */
|
---|
48 | trackBy: TrackByFunction<T>;
|
---|
49 | _nodeOutlet: CdkTreeNodeOutlet;
|
---|
50 | /** The tree node template for the tree */
|
---|
51 | _nodeDefs: QueryList<CdkTreeNodeDef<T>>;
|
---|
52 | /**
|
---|
53 | * Stream containing the latest information on what rows are being displayed on screen.
|
---|
54 | * Can be used by the data source to as a heuristic of what data should be provided.
|
---|
55 | */
|
---|
56 | readonly viewChange: BehaviorSubject<{
|
---|
57 | start: number;
|
---|
58 | end: number;
|
---|
59 | }>;
|
---|
60 | constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef);
|
---|
61 | ngOnInit(): void;
|
---|
62 | ngOnDestroy(): void;
|
---|
63 | ngAfterContentChecked(): void;
|
---|
64 | /**
|
---|
65 | * Switch to the provided data source by resetting the data and unsubscribing from the current
|
---|
66 | * render change subscription if one exists. If the data source is null, interpret this by
|
---|
67 | * clearing the node outlet. Otherwise start listening for new data.
|
---|
68 | */
|
---|
69 | private _switchDataSource;
|
---|
70 | /** Set up a subscription for the data provided by the data source. */
|
---|
71 | private _observeRenderChanges;
|
---|
72 | /** Check for changes made in the data and render each change (node added/removed/moved). */
|
---|
73 | renderNodeChanges(data: readonly T[], dataDiffer?: IterableDiffer<T>, viewContainer?: ViewContainerRef, parentData?: T): void;
|
---|
74 | /**
|
---|
75 | * Finds the matching node definition that should be used for this node data. If there is only
|
---|
76 | * one node definition, it is returned. Otherwise, find the node definition that has a when
|
---|
77 | * predicate that returns true with the data. If none return true, return the default node
|
---|
78 | * definition.
|
---|
79 | */
|
---|
80 | _getNodeDef(data: T, i: number): CdkTreeNodeDef<T>;
|
---|
81 | /**
|
---|
82 | * Create the embedded view for the data node template and place it in the correct index location
|
---|
83 | * within the data node view container.
|
---|
84 | */
|
---|
85 | insertNode(nodeData: T, index: number, viewContainer?: ViewContainerRef, parentData?: T): void;
|
---|
86 | }
|
---|
87 | /**
|
---|
88 | * Tree node for CdkTree. It contains the data in the tree node.
|
---|
89 | */
|
---|
90 | export declare class CdkTreeNode<T, K = T> implements DoCheck, FocusableOption, OnDestroy, OnInit {
|
---|
91 | protected _elementRef: ElementRef<HTMLElement>;
|
---|
92 | protected _tree: CdkTree<T, K>;
|
---|
93 | /**
|
---|
94 | * The role of the tree node.
|
---|
95 | * @deprecated The correct role is 'treeitem', 'group' should not be used. This input will be
|
---|
96 | * removed in a future version.
|
---|
97 | * @breaking-change 12.0.0 Remove this input
|
---|
98 | */
|
---|
99 | get role(): 'treeitem' | 'group';
|
---|
100 | set role(_role: 'treeitem' | 'group');
|
---|
101 | /**
|
---|
102 | * The most recently created `CdkTreeNode`. We save it in static variable so we can retrieve it
|
---|
103 | * in `CdkTree` and set the data to it.
|
---|
104 | */
|
---|
105 | static mostRecentTreeNode: CdkTreeNode<any> | null;
|
---|
106 | /** Subject that emits when the component has been destroyed. */
|
---|
107 | protected readonly _destroyed: Subject<void>;
|
---|
108 | /** Emits when the node's data has changed. */
|
---|
109 | readonly _dataChanges: Subject<void>;
|
---|
110 | private _parentNodeAriaLevel;
|
---|
111 | /** The tree node's data. */
|
---|
112 | get data(): T;
|
---|
113 | set data(value: T);
|
---|
114 | protected _data: T;
|
---|
115 | get isExpanded(): boolean;
|
---|
116 | private _setExpanded;
|
---|
117 | protected _isAriaExpanded: boolean;
|
---|
118 | get level(): number;
|
---|
119 | constructor(_elementRef: ElementRef<HTMLElement>, _tree: CdkTree<T, K>);
|
---|
120 | ngOnInit(): void;
|
---|
121 | ngDoCheck(): void;
|
---|
122 | ngOnDestroy(): void;
|
---|
123 | /** Focuses the menu item. Implements for FocusableOption. */
|
---|
124 | focus(): void;
|
---|
125 | protected _setRoleFromData(): void;
|
---|
126 | }
|
---|