index.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. import { Observable, BehaviorSubject, Subject } from 'rxjs';
  2. import { S as SelectionModel } from '../selection-model.d-C_vvNGP-.js';
  3. import * as i0 from '@angular/core';
  4. import { InjectionToken, ViewContainerRef, TemplateRef, AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy, OnInit, TrackByFunction, QueryList, IterableDiffer, ElementRef, EventEmitter, IterableDiffers } from '@angular/core';
  5. import { T as TreeKeyManagerStrategy, a as TreeKeyManagerItem } from '../tree-key-manager-strategy.d-XB6M79l-.js';
  6. import { C as CollectionViewer, D as DataSource } from '../data-source.d-Bblv7Zvh.js';
  7. /**
  8. * Tree control interface. User can implement TreeControl to expand/collapse dataNodes in the tree.
  9. * The CDKTree will use this TreeControl to expand/collapse a node.
  10. * User can also use it outside the `<cdk-tree>` to control the expansion status of the tree.
  11. *
  12. * @deprecated Use one of levelAccessor or childrenAccessor instead. To be removed in a future version.
  13. * @breaking-change 21.0.0
  14. */
  15. interface TreeControl<T, K = T> {
  16. /** The saved tree nodes data for `expandAll` action. */
  17. dataNodes: T[];
  18. /** The expansion model */
  19. expansionModel: SelectionModel<K>;
  20. /** Whether the data node is expanded or collapsed. Return true if it's expanded. */
  21. isExpanded(dataNode: T): boolean;
  22. /** Get all descendants of a data node */
  23. getDescendants(dataNode: T): any[];
  24. /** Expand or collapse data node */
  25. toggle(dataNode: T): void;
  26. /** Expand one data node */
  27. expand(dataNode: T): void;
  28. /** Collapse one data node */
  29. collapse(dataNode: T): void;
  30. /** Expand all the dataNodes in the tree */
  31. expandAll(): void;
  32. /** Collapse all the dataNodes in the tree */
  33. collapseAll(): void;
  34. /** Toggle a data node by expand/collapse it and all its descendants */
  35. toggleDescendants(dataNode: T): void;
  36. /** Expand a data node and all its descendants */
  37. expandDescendants(dataNode: T): void;
  38. /** Collapse a data node and all its descendants */
  39. collapseDescendants(dataNode: T): void;
  40. /** Get depth of a given data node, return the level number. This is for flat tree node. */
  41. readonly getLevel: (dataNode: T) => number;
  42. /**
  43. * Whether the data node is expandable. Returns true if expandable.
  44. * This is for flat tree node.
  45. */
  46. readonly isExpandable: (dataNode: T) => boolean;
  47. /** Gets a stream that emits whenever the given data node's children change. */
  48. readonly getChildren: (dataNode: T) => Observable<T[]> | T[] | undefined | null;
  49. }
  50. /**
  51. * Base tree control. It has basic toggle/expand/collapse operations on a single data node.
  52. *
  53. * @deprecated Use one of levelAccessor or childrenAccessor. To be removed in a future version.
  54. * @breaking-change 21.0.0
  55. */
  56. declare abstract class BaseTreeControl<T, K = T> implements TreeControl<T, K> {
  57. /** Gets a list of descendent data nodes of a subtree rooted at given data node recursively. */
  58. abstract getDescendants(dataNode: T): T[];
  59. /** Expands all data nodes in the tree. */
  60. abstract expandAll(): void;
  61. /** Saved data node for `expandAll` action. */
  62. dataNodes: T[];
  63. /** A selection model with multi-selection to track expansion status. */
  64. expansionModel: SelectionModel<K>;
  65. /**
  66. * Returns the identifier by which a dataNode should be tracked, should its
  67. * reference change.
  68. *
  69. * Similar to trackBy for *ngFor
  70. */
  71. trackBy?: (dataNode: T) => K;
  72. /** Get depth of a given data node, return the level number. This is for flat tree node. */
  73. getLevel: (dataNode: T) => number;
  74. /**
  75. * Whether the data node is expandable. Returns true if expandable.
  76. * This is for flat tree node.
  77. */
  78. isExpandable: (dataNode: T) => boolean;
  79. /** Gets a stream that emits whenever the given data node's children change. */
  80. getChildren: (dataNode: T) => Observable<T[]> | T[] | undefined | null;
  81. /** Toggles one single data node's expanded/collapsed state. */
  82. toggle(dataNode: T): void;
  83. /** Expands one single data node. */
  84. expand(dataNode: T): void;
  85. /** Collapses one single data node. */
  86. collapse(dataNode: T): void;
  87. /** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
  88. isExpanded(dataNode: T): boolean;
  89. /** Toggles a subtree rooted at `node` recursively. */
  90. toggleDescendants(dataNode: T): void;
  91. /** Collapse all dataNodes in the tree. */
  92. collapseAll(): void;
  93. /** Expands a subtree rooted at given data node recursively. */
  94. expandDescendants(dataNode: T): void;
  95. /** Collapses a subtree rooted at given data node recursively. */
  96. collapseDescendants(dataNode: T): void;
  97. protected _trackByValue(value: T | K): K;
  98. }
  99. /** Optional set of configuration that can be provided to the FlatTreeControl. */
  100. interface FlatTreeControlOptions<T, K> {
  101. trackBy?: (dataNode: T) => K;
  102. }
  103. /**
  104. * Flat tree control. Able to expand/collapse a subtree recursively for flattened tree.
  105. *
  106. * @deprecated Use one of levelAccessor or childrenAccessor instead. To be removed in a future
  107. * version.
  108. * @breaking-change 21.0.0
  109. */
  110. declare class FlatTreeControl<T, K = T> extends BaseTreeControl<T, K> {
  111. getLevel: (dataNode: T) => number;
  112. isExpandable: (dataNode: T) => boolean;
  113. options?: FlatTreeControlOptions<T, K> | undefined;
  114. /** Construct with flat tree data node functions getLevel and isExpandable. */
  115. constructor(getLevel: (dataNode: T) => number, isExpandable: (dataNode: T) => boolean, options?: FlatTreeControlOptions<T, K> | undefined);
  116. /**
  117. * Gets a list of the data node's subtree of descendent data nodes.
  118. *
  119. * To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
  120. * with correct levels.
  121. */
  122. getDescendants(dataNode: T): T[];
  123. /**
  124. * Expands all data nodes in the tree.
  125. *
  126. * To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
  127. * data nodes of the tree.
  128. */
  129. expandAll(): void;
  130. }
  131. /** Optional set of configuration that can be provided to the NestedTreeControl. */
  132. interface NestedTreeControlOptions<T, K> {
  133. /** Function to determine if the provided node is expandable. */
  134. isExpandable?: (dataNode: T) => boolean;
  135. trackBy?: (dataNode: T) => K;
  136. }
  137. /**
  138. * Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type.
  139. *
  140. * @deprecated Use one of levelAccessor or childrenAccessor instead. To be removed in a future
  141. * version.
  142. * @breaking-change 21.0.0
  143. */
  144. declare class NestedTreeControl<T, K = T> extends BaseTreeControl<T, K> {
  145. getChildren: (dataNode: T) => Observable<T[]> | T[] | undefined | null;
  146. options?: NestedTreeControlOptions<T, K> | undefined;
  147. /** Construct with nested tree function getChildren. */
  148. constructor(getChildren: (dataNode: T) => Observable<T[]> | T[] | undefined | null, options?: NestedTreeControlOptions<T, K> | undefined);
  149. /**
  150. * Expands all dataNodes in the tree.
  151. *
  152. * To make this working, the `dataNodes` variable of the TreeControl must be set to all root level
  153. * data nodes of the tree.
  154. */
  155. expandAll(): void;
  156. /** Gets a list of descendant dataNodes of a subtree rooted at given data node recursively. */
  157. getDescendants(dataNode: T): T[];
  158. /** A helper function to get descendants recursively. */
  159. protected _getDescendants(descendants: T[], dataNode: T): void;
  160. }
  161. /**
  162. * Injection token used to provide a `CdkTreeNode` to its outlet.
  163. * Used primarily to avoid circular imports.
  164. * @docs-private
  165. */
  166. declare const CDK_TREE_NODE_OUTLET_NODE: InjectionToken<{}>;
  167. /**
  168. * Outlet for nested CdkNode. Put `[cdkTreeNodeOutlet]` on a tag to place children dataNodes
  169. * inside the outlet.
  170. */
  171. declare class CdkTreeNodeOutlet {
  172. viewContainer: ViewContainerRef;
  173. _node?: {} | null | undefined;
  174. constructor(...args: unknown[]);
  175. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeNodeOutlet, never>;
  176. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTreeNodeOutlet, "[cdkTreeNodeOutlet]", never, {}, {}, never, never, true, never>;
  177. }
  178. /** Context provided to the tree node component. */
  179. declare class CdkTreeNodeOutletContext<T> {
  180. /** Data for the node. */
  181. $implicit: T;
  182. /** Depth of the node. */
  183. level: number;
  184. /** Index location of the node. */
  185. index?: number;
  186. /** Length of the number of total dataNodes. */
  187. count?: number;
  188. constructor(data: T);
  189. }
  190. /**
  191. * Data node definition for the CdkTree.
  192. * Captures the node's template and a when predicate that describes when this node should be used.
  193. */
  194. declare class CdkTreeNodeDef<T> {
  195. /** @docs-private */
  196. template: TemplateRef<any>;
  197. /**
  198. * Function that should return true if this node template should be used for the provided node
  199. * data and index. If left undefined, this node will be considered the default node template to
  200. * use when no other when functions return true for the data.
  201. * For every node, there must be at least one when function that passes or an undefined to
  202. * default.
  203. */
  204. when: (index: number, nodeData: T) => boolean;
  205. constructor(...args: unknown[]);
  206. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeNodeDef<any>, never>;
  207. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTreeNodeDef<any>, "[cdkTreeNodeDef]", never, { "when": { "alias": "cdkTreeNodeDefWhen"; "required": false; }; }, {}, never, never, true, never>;
  208. }
  209. /**
  210. * CDK tree component that connects with a data source to retrieve data of type `T` and renders
  211. * dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
  212. */
  213. declare class CdkTree<T, K = T> implements AfterContentChecked, AfterContentInit, AfterViewInit, CollectionViewer, OnDestroy, OnInit {
  214. private _differs;
  215. private _changeDetectorRef;
  216. private _elementRef;
  217. private _dir;
  218. /** Subject that emits when the component has been destroyed. */
  219. private readonly _onDestroy;
  220. /** Differ used to find the changes in the data provided by the data source. */
  221. private _dataDiffer;
  222. /** Stores the node definition that does not have a when predicate. */
  223. private _defaultNodeDef;
  224. /** Data subscription */
  225. private _dataSubscription;
  226. /** Level of nodes */
  227. private _levels;
  228. /** The immediate parents for a node. This is `null` if there is no parent. */
  229. private _parents;
  230. /**
  231. * Nodes grouped into each set, which is a list of nodes displayed together in the DOM.
  232. *
  233. * Lookup key is the parent of a set. Root nodes have key of null.
  234. *
  235. * Values is a 'set' of tree nodes. Each tree node maps to a treeitem element. Sets are in the
  236. * order that it is rendered. Each set maps directly to aria-posinset and aria-setsize attributes.
  237. */
  238. private _ariaSets;
  239. /**
  240. * Provides a stream containing the latest data array to render. Influenced by the tree's
  241. * stream of view window (what dataNodes are currently on screen).
  242. * Data source can be an observable of data array, or a data array to render.
  243. */
  244. get dataSource(): DataSource<T> | Observable<T[]> | T[];
  245. set dataSource(dataSource: DataSource<T> | Observable<T[]> | T[]);
  246. private _dataSource;
  247. /**
  248. * The tree controller
  249. *
  250. * @deprecated Use one of `levelAccessor` or `childrenAccessor` instead. To be removed in a
  251. * future version.
  252. * @breaking-change 21.0.0
  253. */
  254. treeControl?: TreeControl<T, K>;
  255. /**
  256. * Given a data node, determines what tree level the node is at.
  257. *
  258. * One of levelAccessor or childrenAccessor must be specified, not both.
  259. * This is enforced at run-time.
  260. */
  261. levelAccessor?: (dataNode: T) => number;
  262. /**
  263. * Given a data node, determines what the children of that node are.
  264. *
  265. * One of levelAccessor or childrenAccessor must be specified, not both.
  266. * This is enforced at run-time.
  267. */
  268. childrenAccessor?: (dataNode: T) => T[] | Observable<T[]>;
  269. /**
  270. * Tracking function that will be used to check the differences in data changes. Used similarly
  271. * to `ngFor` `trackBy` function. Optimize node operations by identifying a node based on its data
  272. * relative to the function to know if a node should be added/removed/moved.
  273. * Accepts a function that takes two parameters, `index` and `item`.
  274. */
  275. trackBy: TrackByFunction<T>;
  276. /**
  277. * Given a data node, determines the key by which we determine whether or not this node is expanded.
  278. */
  279. expansionKey?: (dataNode: T) => K;
  280. _nodeOutlet: CdkTreeNodeOutlet;
  281. /** The tree node template for the tree */
  282. _nodeDefs: QueryList<CdkTreeNodeDef<T>>;
  283. /**
  284. * Stream containing the latest information on what rows are being displayed on screen.
  285. * Can be used by the data source to as a heuristic of what data should be provided.
  286. */
  287. readonly viewChange: BehaviorSubject<{
  288. start: number;
  289. end: number;
  290. }>;
  291. /** Keep track of which nodes are expanded. */
  292. private _expansionModel?;
  293. /**
  294. * Maintain a synchronous cache of flattened data nodes. This will only be
  295. * populated after initial render, and in certain cases, will be delayed due to
  296. * relying on Observable `getChildren` calls.
  297. */
  298. private _flattenedNodes;
  299. /** The automatically determined node type for the tree. */
  300. private _nodeType;
  301. /** The mapping between data and the node that is rendered. */
  302. private _nodes;
  303. /**
  304. * Synchronous cache of nodes for the `TreeKeyManager`. This is separate
  305. * from `_flattenedNodes` so they can be independently updated at different
  306. * times.
  307. */
  308. private _keyManagerNodes;
  309. private _keyManagerFactory;
  310. /** The key manager for this tree. Handles focus and activation based on user keyboard input. */
  311. _keyManager: TreeKeyManagerStrategy<CdkTreeNode<T, K>>;
  312. private _viewInit;
  313. constructor(...args: unknown[]);
  314. ngAfterContentInit(): void;
  315. ngAfterContentChecked(): void;
  316. ngOnDestroy(): void;
  317. ngOnInit(): void;
  318. ngAfterViewInit(): void;
  319. private _updateDefaultNodeDefinition;
  320. /**
  321. * Sets the node type for the tree, if it hasn't been set yet.
  322. *
  323. * This will be called by the first node that's rendered in order for the tree
  324. * to determine what data transformations are required.
  325. */
  326. _setNodeTypeIfUnset(newType: 'flat' | 'nested'): void;
  327. /**
  328. * Switch to the provided data source by resetting the data and unsubscribing from the current
  329. * render change subscription if one exists. If the data source is null, interpret this by
  330. * clearing the node outlet. Otherwise start listening for new data.
  331. */
  332. private _switchDataSource;
  333. _getExpansionModel(): SelectionModel<K>;
  334. /** Set up a subscription for the data provided by the data source. */
  335. private _subscribeToDataChanges;
  336. /** Given an Observable containing a stream of the raw data, returns an Observable containing the RenderingData */
  337. private _getRenderData;
  338. private _renderDataChanges;
  339. private _emitExpansionChanges;
  340. private _initializeKeyManager;
  341. private _initializeDataDiffer;
  342. private _checkTreeControlUsage;
  343. /** Check for changes made in the data and render each change (node added/removed/moved). */
  344. renderNodeChanges(data: readonly T[], dataDiffer?: IterableDiffer<T>, viewContainer?: ViewContainerRef, parentData?: T): void;
  345. /**
  346. * Finds the matching node definition that should be used for this node data. If there is only
  347. * one node definition, it is returned. Otherwise, find the node definition that has a when
  348. * predicate that returns true with the data. If none return true, return the default node
  349. * definition.
  350. */
  351. _getNodeDef(data: T, i: number): CdkTreeNodeDef<T>;
  352. /**
  353. * Create the embedded view for the data node template and place it in the correct index location
  354. * within the data node view container.
  355. */
  356. insertNode(nodeData: T, index: number, viewContainer?: ViewContainerRef, parentData?: T): void;
  357. /** Whether the data node is expanded or collapsed. Returns true if it's expanded. */
  358. isExpanded(dataNode: T): boolean;
  359. /** If the data node is currently expanded, collapse it. Otherwise, expand it. */
  360. toggle(dataNode: T): void;
  361. /** Expand the data node. If it is already expanded, does nothing. */
  362. expand(dataNode: T): void;
  363. /** Collapse the data node. If it is already collapsed, does nothing. */
  364. collapse(dataNode: T): void;
  365. /**
  366. * If the data node is currently expanded, collapse it and all its descendants.
  367. * Otherwise, expand it and all its descendants.
  368. */
  369. toggleDescendants(dataNode: T): void;
  370. /**
  371. * Expand the data node and all its descendants. If they are already expanded, does nothing.
  372. */
  373. expandDescendants(dataNode: T): void;
  374. /** Collapse the data node and all its descendants. If it is already collapsed, does nothing. */
  375. collapseDescendants(dataNode: T): void;
  376. /** Expands all data nodes in the tree. */
  377. expandAll(): void;
  378. /** Collapse all data nodes in the tree. */
  379. collapseAll(): void;
  380. /** Level accessor, used for compatibility between the old Tree and new Tree */
  381. _getLevelAccessor(): ((dataNode: T) => number) | undefined;
  382. /** Children accessor, used for compatibility between the old Tree and new Tree */
  383. _getChildrenAccessor(): ((dataNode: T) => T[] | Observable<T[]> | null | undefined) | undefined;
  384. /**
  385. * Gets the direct children of a node; used for compatibility between the old tree and the
  386. * new tree.
  387. */
  388. _getDirectChildren(dataNode: T): Observable<T[]>;
  389. /**
  390. * Given the list of flattened nodes, the level accessor, and the level range within
  391. * which to consider children, finds the children for a given node.
  392. *
  393. * For example, for direct children, `levelDelta` would be 1. For all descendants,
  394. * `levelDelta` would be Infinity.
  395. */
  396. private _findChildrenByLevel;
  397. /**
  398. * Adds the specified node component to the tree's internal registry.
  399. *
  400. * This primarily facilitates keyboard navigation.
  401. */
  402. _registerNode(node: CdkTreeNode<T, K>): void;
  403. /** Removes the specified node component from the tree's internal registry. */
  404. _unregisterNode(node: CdkTreeNode<T, K>): void;
  405. /**
  406. * For the given node, determine the level where this node appears in the tree.
  407. *
  408. * This is intended to be used for `aria-level` but is 0-indexed.
  409. */
  410. _getLevel(node: T): number | undefined;
  411. /**
  412. * For the given node, determine the size of the parent's child set.
  413. *
  414. * This is intended to be used for `aria-setsize`.
  415. */
  416. _getSetSize(dataNode: T): number;
  417. /**
  418. * For the given node, determine the index (starting from 1) of the node in its parent's child set.
  419. *
  420. * This is intended to be used for `aria-posinset`.
  421. */
  422. _getPositionInSet(dataNode: T): number;
  423. /** Given a CdkTreeNode, gets the node that renders that node's parent's data. */
  424. _getNodeParent(node: CdkTreeNode<T, K>): CdkTreeNode<T, K> | null | undefined;
  425. /** Given a CdkTreeNode, gets the nodes that renders that node's child data. */
  426. _getNodeChildren(node: CdkTreeNode<T, K>): Observable<CdkTreeNode<T, K>[]>;
  427. /** `keydown` event handler; this just passes the event to the `TreeKeyManager`. */
  428. protected _sendKeydownToKeyManager(event: KeyboardEvent): void;
  429. /** Gets all nested descendants of a given node. */
  430. private _getDescendants;
  431. /**
  432. * Gets all children and sub-children of the provided node.
  433. *
  434. * This will emit multiple times, in the order that the children will appear
  435. * in the tree, and can be combined with a `reduce` operator.
  436. */
  437. private _getAllChildrenRecursively;
  438. private _getExpansionKey;
  439. private _getAriaSet;
  440. /**
  441. * Finds the parent for the given node. If this is a root node, this
  442. * returns null. If we're unable to determine the parent, for example,
  443. * if we don't have cached node data, this returns undefined.
  444. */
  445. private _findParentForNode;
  446. /**
  447. * Given a set of root nodes and the current node level, flattens any nested
  448. * nodes into a single array.
  449. *
  450. * If any nodes are not expanded, then their children will not be added into the array.
  451. * This will still traverse all nested children in order to build up our internal data
  452. * models, but will not include them in the returned array.
  453. */
  454. private _flattenNestedNodesWithExpansion;
  455. /**
  456. * Converts children for certain tree configurations.
  457. *
  458. * This also computes parent, level, and group data.
  459. */
  460. private _computeRenderingData;
  461. private _updateCachedData;
  462. private _updateKeyManagerItems;
  463. /** Traverse the flattened node data and compute parents, levels, and group data. */
  464. private _calculateParents;
  465. /** Invokes a callback with all node expansion keys. */
  466. private _forEachExpansionKey;
  467. /** Clears the maps we use to store parents, level & aria-sets in. */
  468. private _clearPreviousCache;
  469. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTree<any, any>, never>;
  470. static ɵcmp: i0.ɵɵComponentDeclaration<CdkTree<any, any>, "cdk-tree", ["cdkTree"], { "dataSource": { "alias": "dataSource"; "required": false; }; "treeControl": { "alias": "treeControl"; "required": false; }; "levelAccessor": { "alias": "levelAccessor"; "required": false; }; "childrenAccessor": { "alias": "childrenAccessor"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "expansionKey": { "alias": "expansionKey"; "required": false; }; }, {}, ["_nodeDefs"], never, true, never>;
  471. }
  472. /**
  473. * Tree node for CdkTree. It contains the data in the tree node.
  474. */
  475. declare class CdkTreeNode<T, K = T> implements OnDestroy, OnInit, TreeKeyManagerItem {
  476. _elementRef: ElementRef<HTMLElement>;
  477. protected _tree: CdkTree<T, K>;
  478. protected _tabindex: number | null;
  479. protected readonly _type: 'flat' | 'nested';
  480. /**
  481. * The role of the tree node.
  482. *
  483. * @deprecated This will be ignored; the tree will automatically determine the appropriate role
  484. * for tree node. This input will be removed in a future version.
  485. * @breaking-change 21.0.0
  486. */
  487. get role(): 'treeitem' | 'group';
  488. set role(_role: 'treeitem' | 'group');
  489. /**
  490. * Whether or not this node is expandable.
  491. *
  492. * If not using `FlatTreeControl`, or if `isExpandable` is not provided to
  493. * `NestedTreeControl`, this should be provided for correct node a11y.
  494. */
  495. get isExpandable(): boolean;
  496. set isExpandable(isExpandable: boolean);
  497. get isExpanded(): boolean;
  498. set isExpanded(isExpanded: boolean);
  499. /**
  500. * Whether or not this node is disabled. If it's disabled, then the user won't be able to focus
  501. * or activate this node.
  502. */
  503. isDisabled: boolean;
  504. /**
  505. * The text used to locate this item during typeahead. If not specified, the `textContent` will
  506. * will be used.
  507. */
  508. typeaheadLabel: string | null;
  509. getLabel(): string;
  510. /** This emits when the node has been programatically activated or activated by keyboard. */
  511. readonly activation: EventEmitter<T>;
  512. /** This emits when the node's expansion status has been changed. */
  513. readonly expandedChange: EventEmitter<boolean>;
  514. /**
  515. * The most recently created `CdkTreeNode`. We save it in static variable so we can retrieve it
  516. * in `CdkTree` and set the data to it.
  517. */
  518. static mostRecentTreeNode: CdkTreeNode<any> | null;
  519. /** Subject that emits when the component has been destroyed. */
  520. protected readonly _destroyed: Subject<void>;
  521. /** Emits when the node's data has changed. */
  522. readonly _dataChanges: Subject<void>;
  523. private _inputIsExpandable;
  524. private _inputIsExpanded;
  525. /**
  526. * Flag used to determine whether or not we should be focusing the actual element based on
  527. * some user interaction (click or focus). On click, we don't forcibly focus the element
  528. * since the click could trigger some other component that wants to grab its own focus
  529. * (e.g. menu, dialog).
  530. */
  531. private _shouldFocus;
  532. private _parentNodeAriaLevel;
  533. /** The tree node's data. */
  534. get data(): T;
  535. set data(value: T);
  536. protected _data: T;
  537. get isLeafNode(): boolean;
  538. get level(): number;
  539. /** Determines if the tree node is expandable. */
  540. _isExpandable(): boolean;
  541. /**
  542. * Determines the value for `aria-expanded`.
  543. *
  544. * For non-expandable nodes, this is `null`.
  545. */
  546. _getAriaExpanded(): string | null;
  547. /**
  548. * Determines the size of this node's parent's child set.
  549. *
  550. * This is intended to be used for `aria-setsize`.
  551. */
  552. _getSetSize(): number;
  553. /**
  554. * Determines the index (starting from 1) of this node in its parent's child set.
  555. *
  556. * This is intended to be used for `aria-posinset`.
  557. */
  558. _getPositionInSet(): number;
  559. private _changeDetectorRef;
  560. constructor(...args: unknown[]);
  561. ngOnInit(): void;
  562. ngOnDestroy(): void;
  563. getParent(): CdkTreeNode<T, K> | null;
  564. getChildren(): CdkTreeNode<T, K>[] | Observable<CdkTreeNode<T, K>[]>;
  565. /** Focuses this data node. Implemented for TreeKeyManagerItem. */
  566. focus(): void;
  567. /** Defocus this data node. */
  568. unfocus(): void;
  569. /** Emits an activation event. Implemented for TreeKeyManagerItem. */
  570. activate(): void;
  571. /** Collapses this data node. Implemented for TreeKeyManagerItem. */
  572. collapse(): void;
  573. /** Expands this data node. Implemented for TreeKeyManagerItem. */
  574. expand(): void;
  575. /** Makes the node focusable. Implemented for TreeKeyManagerItem. */
  576. makeFocusable(): void;
  577. _focusItem(): void;
  578. _setActiveItem(): void;
  579. _emitExpansionState(expanded: boolean): void;
  580. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeNode<any, any>, never>;
  581. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTreeNode<any, any>, "cdk-tree-node", ["cdkTreeNode"], { "role": { "alias": "role"; "required": false; }; "isExpandable": { "alias": "isExpandable"; "required": false; }; "isExpanded": { "alias": "isExpanded"; "required": false; }; "isDisabled": { "alias": "isDisabled"; "required": false; }; "typeaheadLabel": { "alias": "cdkTreeNodeTypeaheadLabel"; "required": false; }; }, { "activation": "activation"; "expandedChange": "expandedChange"; }, never, never, true, never>;
  582. static ngAcceptInputType_isExpandable: unknown;
  583. static ngAcceptInputType_isDisabled: unknown;
  584. }
  585. /**
  586. * Nested node is a child of `<cdk-tree>`. It works with nested tree.
  587. * By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
  588. * be added in the `cdkTreeNodeOutlet` in tree node template.
  589. * The children of node will be automatically added to `cdkTreeNodeOutlet`.
  590. */
  591. declare class CdkNestedTreeNode<T, K = T> extends CdkTreeNode<T, K> implements AfterContentInit, OnDestroy {
  592. protected _type: 'flat' | 'nested';
  593. protected _differs: IterableDiffers;
  594. /** Differ used to find the changes in the data provided by the data source. */
  595. private _dataDiffer;
  596. /** The children data dataNodes of current node. They will be placed in `CdkTreeNodeOutlet`. */
  597. protected _children: T[];
  598. /** The children node placeholder. */
  599. nodeOutlet: QueryList<CdkTreeNodeOutlet>;
  600. constructor(...args: unknown[]);
  601. ngAfterContentInit(): void;
  602. ngOnDestroy(): void;
  603. /** Add children dataNodes to the NodeOutlet */
  604. protected updateChildrenNodes(children?: T[]): void;
  605. /** Clear the children dataNodes. */
  606. protected _clear(): void;
  607. /** Gets the outlet for the current node. */
  608. private _getNodeOutlet;
  609. static ɵfac: i0.ɵɵFactoryDeclaration<CdkNestedTreeNode<any, any>, never>;
  610. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkNestedTreeNode<any, any>, "cdk-nested-tree-node", ["cdkNestedTreeNode"], {}, {}, ["nodeOutlet"], never, true, never>;
  611. }
  612. /**
  613. * Indent for the children tree dataNodes.
  614. * This directive will add left-padding to the node to show hierarchy.
  615. */
  616. declare class CdkTreeNodePadding<T, K = T> implements OnDestroy {
  617. private _treeNode;
  618. private _tree;
  619. private _element;
  620. private _dir;
  621. /** Current padding value applied to the element. Used to avoid unnecessarily hitting the DOM. */
  622. private _currentPadding;
  623. /** Subject that emits when the component has been destroyed. */
  624. private readonly _destroyed;
  625. /** CSS units used for the indentation value. */
  626. indentUnits: string;
  627. /** The level of depth of the tree node. The padding will be `level * indent` pixels. */
  628. get level(): number;
  629. set level(value: number);
  630. _level: number;
  631. /**
  632. * The indent for each level. Can be a number or a CSS string.
  633. * Default number 40px from material design menu sub-menu spec.
  634. */
  635. get indent(): number | string;
  636. set indent(indent: number | string);
  637. _indent: number;
  638. constructor(...args: unknown[]);
  639. ngOnDestroy(): void;
  640. /** The padding indent value for the tree node. Returns a string with px numbers if not null. */
  641. _paddingIndent(): string | null;
  642. _setPadding(forceChange?: boolean): void;
  643. /**
  644. * This has been extracted to a util because of TS 4 and VE.
  645. * View Engine doesn't support property rename inheritance.
  646. * TS 4.0 doesn't allow properties to override accessors or vice-versa.
  647. * @docs-private
  648. */
  649. protected _setLevelInput(value: number): void;
  650. /**
  651. * This has been extracted to a util because of TS 4 and VE.
  652. * View Engine doesn't support property rename inheritance.
  653. * TS 4.0 doesn't allow properties to override accessors or vice-versa.
  654. * @docs-private
  655. */
  656. protected _setIndentInput(indent: number | string): void;
  657. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeNodePadding<any, any>, never>;
  658. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTreeNodePadding<any, any>, "[cdkTreeNodePadding]", never, { "level": { "alias": "cdkTreeNodePadding"; "required": false; }; "indent": { "alias": "cdkTreeNodePaddingIndent"; "required": false; }; }, {}, never, never, true, never>;
  659. static ngAcceptInputType_level: unknown;
  660. }
  661. /**
  662. * Returns an error to be thrown when there is no usable data.
  663. * @docs-private
  664. */
  665. declare function getTreeNoValidDataSourceError(): Error;
  666. /**
  667. * Returns an error to be thrown when there are multiple nodes that are missing a when function.
  668. * @docs-private
  669. */
  670. declare function getTreeMultipleDefaultNodeDefsError(): Error;
  671. /**
  672. * Returns an error to be thrown when there are no matching node defs for a particular set of data.
  673. * @docs-private
  674. */
  675. declare function getTreeMissingMatchingNodeDefError(): Error;
  676. /**
  677. * Returns an error to be thrown when there is no tree control.
  678. * @docs-private
  679. */
  680. declare function getTreeControlMissingError(): Error;
  681. /**
  682. * Returns an error to be thrown when there are multiple ways of specifying children or level
  683. * provided to the tree.
  684. * @docs-private
  685. */
  686. declare function getMultipleTreeControlsError(): Error;
  687. /**
  688. * Node toggle to expand and collapse the node.
  689. */
  690. declare class CdkTreeNodeToggle<T, K = T> {
  691. protected _tree: CdkTree<T, K>;
  692. protected _treeNode: CdkTreeNode<T, K>;
  693. /** Whether expand/collapse the node recursively. */
  694. recursive: boolean;
  695. constructor(...args: unknown[]);
  696. _toggle(): void;
  697. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeNodeToggle<any, any>, never>;
  698. static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTreeNodeToggle<any, any>, "[cdkTreeNodeToggle]", never, { "recursive": { "alias": "cdkTreeNodeToggleRecursive"; "required": false; }; }, {}, never, never, true, never>;
  699. static ngAcceptInputType_recursive: unknown;
  700. }
  701. declare class CdkTreeModule {
  702. static ɵfac: i0.ɵɵFactoryDeclaration<CdkTreeModule, never>;
  703. static ɵmod: i0.ɵɵNgModuleDeclaration<CdkTreeModule, never, [typeof CdkNestedTreeNode, typeof CdkTreeNodeDef, typeof CdkTreeNodePadding, typeof CdkTreeNodeToggle, typeof CdkTree, typeof CdkTreeNode, typeof CdkTreeNodeOutlet], [typeof CdkNestedTreeNode, typeof CdkTreeNodeDef, typeof CdkTreeNodePadding, typeof CdkTreeNodeToggle, typeof CdkTree, typeof CdkTreeNode, typeof CdkTreeNodeOutlet]>;
  704. static ɵinj: i0.ɵɵInjectorDeclaration<CdkTreeModule>;
  705. }
  706. export { BaseTreeControl, CDK_TREE_NODE_OUTLET_NODE, CdkNestedTreeNode, CdkTree, CdkTreeModule, CdkTreeNode, CdkTreeNodeDef, CdkTreeNodeOutlet, CdkTreeNodeOutletContext, CdkTreeNodePadding, CdkTreeNodeToggle, FlatTreeControl, NestedTreeControl, getMultipleTreeControlsError, getTreeControlMissingError, getTreeMissingMatchingNodeDefError, getTreeMultipleDefaultNodeDefsError, getTreeNoValidDataSourceError };
  707. export type { FlatTreeControlOptions, NestedTreeControlOptions, TreeControl };