import * as i1 from '@angular/cdk/tree'; import { CdkTreeNode, TreeControl, FlatTreeControl, CdkTree, CdkTreeNodeDef, CdkTreeNodeOutlet, CdkTreeNodeToggle } from '@angular/cdk/tree'; import * as i0 from '@angular/core'; import { ElementRef, OnDestroy, AfterViewInit, ViewContainerRef, Renderer2, OnInit, IterableDiffer } from '@angular/core'; import { DataSource, CollectionViewer } from '@angular/cdk/collections'; import { Observable, BehaviorSubject } from 'rxjs'; import { FocusMonitor, FocusableOption } from '@angular/cdk/a11y'; import { Directionality } from '@angular/cdk/bidi'; import { NumberInput } from '@angular/cdk/coercion'; import * as i2 from '@angular/common'; /** * Handles focussing of the tree action item and adds the necessary attributes for a11y */ declare class NxTreeNodeActionItem { private readonly _elementRef; private readonly _treeNode; constructor(_elementRef: ElementRef, _treeNode: CdkTreeNode); focus(): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[nxTreeNodeActionItem]", never, {}, {}, never, never, true, never>; } /** * This interface defines a single node of the trees data structure. */ interface NxTreeNode { children?: NxTreeNode[]; } /** * Flat node with level information. */ interface NxFlatTreeNode { expandable: boolean; level: number; } /** * Tree flattener to convert a normal type of node to node with children & level information. * Transform nested nodes of type `T extends NxTreeNode` to flattened nodes of type `F extends NxFlatTreeNode`. * * For example, the input data of type `T` is nested, and contains its children data: * SomeNode: { * key: 'Fruits', * children: [ * NodeOne: { * key: 'Apple', * }, * NodeTwo: { * key: 'Pear', * } * ] * } * After flattener flatten the tree, the structure will become * SomeNode: { * key: 'Fruits', * expandable: true, * level: 1 * }, * NodeOne: { * key: 'Apple', * expandable: false, * level: 2 * }, * NodeTwo: { * key: 'Pear', * expandable: false, * level: 2 * } * and the output flattened type is `F extends NxFlatTreeNode` with additional information. */ declare class NxTreeFlattener { transformFunction(node: NxTreeNode, level: number): F; getLevel(node: F): number; isExpandable(node: F): boolean; getChildren(node: T): Observable | T[]; _flattenNode(node: T, level: number, resultNodes: F[], parentMap: boolean[]): F[]; _flattenChildren(children: T[], level: number, resultNodes: F[], parentMap: boolean[]): void; /** * Flatten a list of node type T to flattened version of node F. * Please note that type T may be nested, and the length of `structuredData` may be different * from that of returned list `F[]`. */ flattenNodes(structuredData: T[]): F[]; /** * Expand flattened node with current expansion status. * The returned list may have different length. */ expandFlattenedNodes(nodes: F[], treeControl: TreeControl): F[]; } /** * Data source for flat tree. * The data source need to handle expansion/collapsion of the tree node and change the data feed * to `NxTree`. * The nested tree nodes of type `T extends NxTreeNode` are flattened through `NxTreeFlattener`, and converted * to type `F extends NxFlatTreeNode` for `NxTree` to consume. */ declare class NxTreeFlatDataSource extends DataSource { private readonly treeControl; _treeFlattener: NxTreeFlattener; readonly _flattenedData: BehaviorSubject; readonly _expandedData: BehaviorSubject; readonly _data: BehaviorSubject; set data(value: T[]); get data(): T[]; constructor(treeControl: FlatTreeControl, initialData?: T[]); connect(collectionViewer: CollectionViewer): Observable; disconnect(): void; } /** * Flat tree control, allows to expand/collapse a subtree recursively for flattened tree. */ declare class NxFlatTreeControl extends FlatTreeControl { constructor(); } /** * Wrapper for the CdkTree node with custom design styles. */ declare class NxTreeNodeComponent extends CdkTreeNode implements OnDestroy, AfterViewInit { protected readonly _focusMonitor: FocusMonitor; constructor(_elementRef: ElementRef, _tree: CdkTree, _focusMonitor: FocusMonitor); private actionItem; /** if NxTreeNodeActionItem is present, returns */ readonly ariaLevel: i0.Signal; readonly ariaPosInSet: i0.Signal; readonly ariaSetSize: i0.Signal; readonly ariaRole: i0.Signal<"treeitem" | null>; ngAfterViewInit(): void; ngOnDestroy(): void; /** Update the focused data in tree keyboard interaction */ _focus(): void; focus(): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "nx-tree-node", ["nxTreeNode"], { "disabled": { "alias": "disabled"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, ["actionItem"], ["*"], true, never>; } /** * Wrapper for the CdkTree node definition with custom design styles. */ declare class NxTreeNodeDefDirective extends CdkTreeNodeDef { data: T; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[nxTreeNodeDef]", never, { "when": { "alias": "nxTreeNodeDefWhen"; "required": false; }; "data": { "alias": "nxTreeNode"; "required": false; }; }, {}, never, never, true, never>; } /** * Outlet for nested CdkNode. Put `[nxTreeNodeOutlet]` on a tag to place children dataNodes * inside the outlet. */ declare class NxTreeNodeOutletDirective implements CdkTreeNodeOutlet { readonly viewContainer: ViewContainerRef; constructor(viewContainer: ViewContainerRef); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Indent for the children tree dataNodes. * This directive will add left-padding to the node to show hierarchy. */ declare class NxTreeNodePaddingDirective implements OnDestroy { private readonly _treeNode; private readonly _tree; private readonly _renderer; private readonly _element; private readonly _dir; /** Current padding value applied to the element. Used to avoid unnecessarily hitting the DOM. */ private _currentPadding; /** CSS units used for the indentation value. */ indentUnits: string; /** The level of depth of the tree node. The padding will be `level * indent` pixels. */ set level(value: NumberInput); get level(): number; _level: number; /** The offset is added once on top of each indent. Default number is 0. */ set offset(value: NumberInput); get offset(): number; _offset: number; /** * The indent for each level. Can be a number or a CSS string. * Default number 24px from material design menu sub-menu spec. */ set indent(indent: NumberInput); get indent(): number; _indent: number; private readonly _destroyed; constructor(_treeNode: CdkTreeNode, _tree: CdkTree, _renderer: Renderer2, _element: ElementRef, _dir: Directionality | null); ngOnDestroy(): void; /** The padding indent value for the tree node. Returns a string with px numbers if not null. */ _paddingIndent(): string | null; _setPadding(forceChange?: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration, [null, null, null, null, { optional: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[nxTreeNodePadding]", never, { "level": { "alias": "nxTreeNodePadding"; "required": false; }; "offset": { "alias": "nxTreeNodePaddingOffset"; "required": false; }; "indent": { "alias": "nxTreeNodePaddingIndent"; "required": false; }; }, {}, never, never, true, never>; } /** * Wrapper for the CdkTree's toggle with custom design styles. */ declare class NxTreeNodeToggleDirective extends CdkTreeNodeToggle { static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[nxTreeNodeToggle]", never, { "recursive": { "alias": "nxTreeNodeToggleRecursive"; "required": false; }; }, {}, never, never, true, never>; } /** * Wrapper for the CdkTree with custom design styles and keyboard nav mechanics. */ declare class NxTreeComponent extends CdkTree implements OnDestroy, OnInit { private readonly _cdr; private readonly dir; private readonly elementRef; private readonly _focusMonitor; _nodeOutlet: NxTreeNodeOutletDirective; /** The node map map data nodes to CdkTreeNodes */ protected nodeMap: Map; /** A map from parent node to a list of children. */ protected childrenMap: Map; /** A map from node data to its parent node data. */ protected parentMap: Map; /** Current focused node data. */ protected _focusedData: T; /** Tab index for the tree. */ _tabIndex: number; /** * User defined tab index. * When it is not null, use user defined tab index. Otherwise use _tabIndex. */ _userTabIndex: number | null; set tabIndex(value: number); /** Subject that emits when the component has been destroyed. */ private readonly _wrapperOnDestroy; ngOnInit(): void; ngOnDestroy(): void; /** Get current focused data */ get focusedData(): T; /** Add tree node to data list based on owner of parent view container. */ insertToA11yNodeTracking(index: number, data: T, node: FocusableOption, parentData?: T): void; /** Remove a node data from node list based on the owner of view container. */ removeFromA11yNodeTracking(index: number, parentData?: T): void; /** Update node's index information based on the owner of view container. */ moveInA11yNodeTracking(previousIndex: number, currentIndex: number, parentData?: T): void; /** When a tree node is focused, update the current focused data. */ updateFocusedData(newFocusedData: T): void; /** Focus first node when the tree is focused */ focus(): void; /** Change focus to first visible node in the tree. */ focusFirstVisibleNode(): void; /** Change focus to last visible node in the tree. */ focusLastVisibleNode(): void; /** Change focus to previous visible node. */ focusPreviousVisibleNode(): void; /** Change focus to next visible node. */ focusNextVisibleNode(): void; /** Collapse the current node if it's expanded. Otherwise move to parent. */ collapseCurrentFocusedNode(): void; /** Expand the current node if it's not expanded. Otherwise move to its first child. */ expandCurrentFocusedNode(): void; /** Expand all the nodes in the tree */ expandAllNodes(): void; /** Expand the current node if it's not expanded. Otherwise move to its first child. */ toggleCurrentFocusedNode(): void; _isRtl(): boolean; /** * Pass events to the keyboard manager. Available here for tests. */ _handleKeydown(event: KeyboardEvent): void; /** Focus the tree node component with new focused data. */ _changeFocusedData(newFocused: T | undefined): void; /** Returns the data of the first visible tree node in the tree. */ _getFirstVisibleNode(): T | undefined; /** Returns the data of the last visible tree node in the tree. */ _getLastVisibleNode(): T | undefined; /** Returns the previous visible tree node of current focused data. */ _getPreviousVisibleNode(): T | undefined; /** Returns the next visible tree node data of current focused data. */ _getNextVisibleNode(): T | undefined; /** Returns the parent of current focused node. */ _getParentNode(): T | undefined; /** Remove all nodes under collapsed tree */ _removeChildren(): void; /** Get all nest nodes under an expandable node. */ _getNestLevels(data: any[], fromIndex: number): any[]; /** * Returns the data of list of children in the current `parentData` node's view container. * If there's no parent, return the tree nodes in the tree's view container. */ _getChildrenList(parentData?: T): T[]; /** * Returns the data of last visible elements in the sub-tree rooted at `targetNode`. */ _getLastChild(targetNode: T): T; /** * Extended CdkTree method to track new nodes for a11y. */ insertNode(nodeData: T, index: number, viewContainer?: ViewContainerRef, parentData?: T): void; /** * ⚠️ Here we override the method from cdk tree ⚠️ * Adds some extra method calls to update the a11y node tracking. */ renderNodeChanges(data: T[], dataDiffer?: IterableDiffer, // accessing private super class member viewContainer?: ViewContainerRef, parentData?: T): void; /** * Monitor focus of the tree. When the tree is focused, change the tab index to -1 so TAB * can move the focus out of the tree. When the tree is blurred, change back the tab index. */ _monitorTreeFocus(): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "nx-tree", ["nxTree"], { "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, never, never, true, never>; } declare class NxTreeModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { NxFlatTreeControl, NxTreeComponent, NxTreeFlatDataSource, NxTreeModule, NxTreeNodeActionItem, NxTreeNodeComponent, NxTreeNodeDefDirective, NxTreeNodeOutletDirective, NxTreeNodePaddingDirective, NxTreeNodeToggleDirective }; export type { NxFlatTreeNode, NxTreeNode };