source: trip-planner-front/node_modules/@angular/material/tree/data-source/flat-data-source.d.ts@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
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 */
8import { CollectionViewer, DataSource } from '@angular/cdk/collections';
9import { FlatTreeControl, TreeControl } from '@angular/cdk/tree';
10import { Observable } from 'rxjs';
11/**
12 * Tree flattener to convert a normal type of node to node with children & level information.
13 * Transform nested nodes of type `T` to flattened nodes of type `F`.
14 *
15 * For example, the input data of type `T` is nested, and contains its children data:
16 * SomeNode: {
17 * key: 'Fruits',
18 * children: [
19 * NodeOne: {
20 * key: 'Apple',
21 * },
22 * NodeTwo: {
23 * key: 'Pear',
24 * }
25 * ]
26 * }
27 * After flattener flatten the tree, the structure will become
28 * SomeNode: {
29 * key: 'Fruits',
30 * expandable: true,
31 * level: 1
32 * },
33 * NodeOne: {
34 * key: 'Apple',
35 * expandable: false,
36 * level: 2
37 * },
38 * NodeTwo: {
39 * key: 'Pear',
40 * expandable: false,
41 * level: 2
42 * }
43 * and the output flattened type is `F` with additional information.
44 */
45export declare class MatTreeFlattener<T, F, K = F> {
46 transformFunction: (node: T, level: number) => F;
47 getLevel: (node: F) => number;
48 isExpandable: (node: F) => boolean;
49 getChildren: (node: T) => Observable<T[]> | T[] | undefined | null;
50 constructor(transformFunction: (node: T, level: number) => F, getLevel: (node: F) => number, isExpandable: (node: F) => boolean, getChildren: (node: T) => Observable<T[]> | T[] | undefined | null);
51 _flattenNode(node: T, level: number, resultNodes: F[], parentMap: boolean[]): F[];
52 _flattenChildren(children: T[], level: number, resultNodes: F[], parentMap: boolean[]): void;
53 /**
54 * Flatten a list of node type T to flattened version of node F.
55 * Please note that type T may be nested, and the length of `structuredData` may be different
56 * from that of returned list `F[]`.
57 */
58 flattenNodes(structuredData: T[]): F[];
59 /**
60 * Expand flattened node with current expansion status.
61 * The returned list may have different length.
62 */
63 expandFlattenedNodes(nodes: F[], treeControl: TreeControl<F, K>): F[];
64}
65/**
66 * Data source for flat tree.
67 * The data source need to handle expansion/collapsion of the tree node and change the data feed
68 * to `MatTree`.
69 * The nested tree nodes of type `T` are flattened through `MatTreeFlattener`, and converted
70 * to type `F` for `MatTree` to consume.
71 */
72export declare class MatTreeFlatDataSource<T, F, K = F> extends DataSource<F> {
73 private _treeControl;
74 private _treeFlattener;
75 private readonly _flattenedData;
76 private readonly _expandedData;
77 get data(): T[];
78 set data(value: T[]);
79 private readonly _data;
80 constructor(_treeControl: FlatTreeControl<F, K>, _treeFlattener: MatTreeFlattener<T, F, K>, initialData?: T[]);
81 connect(collectionViewer: CollectionViewer): Observable<F[]>;
82 disconnect(): void;
83}
Note: See TracBrowser for help on using the repository browser.