import * as _angular_core from '@angular/core'; import { TemplateRef } from '@angular/core'; import * as i1$1 from '@angular/common'; import * as i1 from '@daffodil/design'; /** * 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; } /** * 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; } /** * 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'; /** * 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 { 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. */ readonly renderMode: _angular_core.InputSignal; /** * A unique identifier for the tree instance. * Used as a prefix for all node IDs in the tree. * If not provided, an auto-incrementing number is used. */ readonly id: _angular_core.InputSignal; /** * The tree data you would like to render. */ readonly tree: _angular_core.InputSignal>; /** * The internal tree element. */ private _tree; /** * A revision counter incremented by notifications from tree items. * Used to trigger re-flattening when tree item state changes. */ readonly _revision: _angular_core.WritableSignal; /** * @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. */ readonly flatTree: _angular_core.Signal; /** * The template used to render tree-nodes that themselves have children. * * @docs-private */ readonly withChildrenTemplate: _angular_core.Signal>; /** * The template used to render tree-nodes that have no children. * * @docs-private */ readonly treeItemTemplate: _angular_core.Signal>; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵ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; /** * The {@link DaffTreeFlatNode} associated with this specific tree item. */ readonly node: _angular_core.InputSignal; /** * Whether or not the tree item is the currently active item. * Note that there is no requirement that there only be one active item at a time. * * When a tree item becomes selected, all of its ancestor nodes * will be automatically opened so that the selected item is visible. */ readonly selected: _angular_core.InputSignal; /** * The html `id` of the tree item. This is derived from the {@link DaffTreeData}. */ protected readonly id: _angular_core.Signal; /** * A property indicating the depth of the tree. */ protected readonly depth: _angular_core.Signal; /** * Whether or not this node has children. */ protected readonly isParent: _angular_core.Signal; /** * Indicates whether or not the tree is `open`. */ protected readonly open: _angular_core.Signal; /** * Accessibility property, notifying users about whether * or not the tree item is open. * * @docs-private */ protected readonly ariaExpanded: _angular_core.Signal<"true" | "false">; constructor(); /** * @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: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵ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: _angular_core.ɵɵFactoryDeclaration; static ɵmod: _angular_core.ɵɵNgModuleDeclaration; static ɵinj: _angular_core.ɵɵ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 };