import * as i0 from '@angular/core'; import { OnDestroy, OnInit, OnChanges, TemplateRef, SimpleChanges } from '@angular/core'; import * as i1$1 from '@angular/common'; import * as rxjs from 'rxjs'; import * as i1 from '@daffodil/design'; /** * This service is used by tree items to notify their parent * that the tree has to be recomputed. * * This service is a multiton associated with each tree instance. * It follows the same lifecycle as the tree it is associated with. */ declare class DaffTreeNotifierService implements OnDestroy { /** * @docs-private */ private _notice; /** * An observable that emits when the tree needs to be re-computed. */ notice$: rxjs.Observable; /** * `notify` can be called to trigger a re-computation of the tree * if data has changed unexpectedly and a re-render did not occur. * * This should be used sparingly. Instead, prefer updating `data` on the tree * itself for performance reasons. */ notify(): void; /** * Cleanup when the tree is destroyed. * * @docs-private */ ngOnDestroy(): void; } /** * A basic tree type supporting supplemental data on a tree node. * * Tree elements are often slightly more than just basic titles and child items. * There may be other important data that needs to be available at render time. */ interface DaffTreeData { /** * The label displayed for a tree node. */ title: string; /** * A URL associated with a tree node, which can be used for navigation or linking. */ url: string; /** * A unique ID for a tree node. */ id: string; /** * An array of child nodes, each of which is also a `DaffTreeData` item. */ items: DaffTreeData[]; /** * Additional data associated with a tree node. */ data: T; } /** * Represents the mode of rendering for nodes in a tree UI. * - `in-dom`: Closed nodes are present in the Document Object Model (DOM). * - `not-in-dom`: Closed nodes are not present in the Document Object Model (DOM). */ type DaffTreeRenderMode = 'in-dom' | 'not-in-dom'; /** * A DaffTreeUi is the internal data structure used during tree rendering. * * This is an internal implementation detail type that. */ interface DaffTreeUi extends DaffTreeData { open: boolean; items: DaffTreeUi[]; parent: DaffTreeUi; } /** * A flattened node of a tree. This is used when translating the tree data * structure into an array. */ interface DaffTreeFlatNode { id: number | string; title: string; url: string; level: number; hasChildren: boolean; data: unknown; visible: boolean; _treeRef: DaffTreeUi; } /** * The `DaffTreeComponent` allows you to render tree structures as interactable UI. * * @example Basic use of the tree component * ```html * * ``` * * where `tree` is a {@link DaffTreeData}. * */ declare class DaffTreeComponent implements OnInit, OnChanges { private notifier; /** * The rendering mode for nodes in the tree. * * Default value is `in-dom`, which means nodes are present in the DOM. * * Generally, `not-in-dom` is faster as there are less DOM elements to render, * but there may be use-cases (like SEO) where having the tree in the DOM * is relevant. */ renderMode: DaffTreeRenderMode; /** * The internal tree element. */ private _tree; /** * @docs-private * * The flattened tree data. For debugging purposes, you can iterate through this if you want to inspect * the resulting array structure we computed to render the tree. */ flatTree: DaffTreeFlatNode[]; /** * The tree data you would like to render. */ tree: DaffTreeData; /** * The template used to render tree-nodes that themselves have children. * * @docs-private */ withChildrenTemplate: TemplateRef; /** * The template used to render tree-nodes that have no children. * * @docs-private */ treeItemTemplate: TemplateRef; /** * @docs-private */ constructor(notifier: DaffTreeNotifierService); /** * @docs-private */ ngOnChanges(changes: SimpleChanges): void; /** * @docs-private */ ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * The `DaffTreeItemDirective` marks elements as tree child nodes that interact with the parent tree structure. * * @example Using a `[daffTreeItem]` * * `[tree]` is a {@link DaffTreeData} and `[daff-tree]` is a {@link DaffTreeComponent}. * * ```html * * ``` * */ declare class DaffTreeItemDirective { private document; private treeNotifier; private isParent; /** * The html `id` of the tree item. This is derived from the {@link DaffTreeData}. * */ private id; /** * Accessibility property, notifying users about whether * or not the tree item is open. */ private ariaExpanded; /** * A property indicating the depth of the tree. */ private depth; /** * Indicates whether or not the tree is `open`. */ private open; /** * The {@link DaffTreeFlatNode} associated with this specific tree item. */ private _node; /** * The {@link DaffTreeFlatNode} associated with this specific tree item. */ get node(): DaffTreeFlatNode; set node(val: DaffTreeFlatNode); /** * Whether or not the tree item is the currently active item. * Note that there is no requirement there there only be one active item at a time. */ selected: boolean; constructor(document: any, treeNotifier: DaffTreeNotifierService); /** * @docs-private */ onEscape(): void; /** * @docs-private */ onClick(): void; /** * Toggle the open state of the tree's parent. */ toggleParent(node: DaffTreeFlatNode): void; /** * Toggle the open state of this specific subtree tree. */ toggleTree(node: DaffTreeFlatNode): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * @deprecated in favor of {@link DAFF_TREE_COMPONENTS}. Deprecated in version 0.78.0. Will be removed in version 1.0.0. */ declare class DaffTreeModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } type RecursiveTreeKeyOfType = keyof { [P in keyof T as T[P] extends T[] ? P : never]: T[]; }; /** * Transform a tree-like structure into a {@link DaffTreeData}. * * @param tree - The data structure representing tree-like data. * @param transformFn - A user-supplied function that will transform the user * type into a {@link DaffTreeData} * @param key - The property of the your tree that indicates which * key contains the "children" of your tree structure. * */ declare const daffTransformTree: , V>(tree: T, transformFn: (type: T) => DaffTreeData, key: RecursiveTreeKeyOfType) => DaffTreeData; /** * @docs-private */ declare const DAFF_TREE_COMPONENTS: readonly [typeof DaffTreeComponent, typeof DaffTreeItemDirective]; export { DAFF_TREE_COMPONENTS, DaffTreeComponent, DaffTreeItemDirective, DaffTreeModule, daffTransformTree }; export type { DaffTreeData, DaffTreeRenderMode };