UNPKG

@porscheinformatik/clr-addons

Version:
56 lines (55 loc) 2.29 kB
import { ClrTreetableSelectedState } from '../enums/selection-type'; /** * Function type that returns the direct children of a data node. */ export type ClrTreetableChildrenFunction<T extends object> = (node: T) => Array<T>; /** * Represents a single tree node inside the treetable. * Maintains derived selection state (SELECTED / UNSELECTED / INDETERMINATE) based on: * - Manual selection of this node. * - Aggregated selection states of all descendants. * Selection propagation to descendants happens only on explicit setSelected calls. */ export declare class ClrTreetableTreeNode<T extends object> { readonly id: string; readonly value: T; parent: ClrTreetableTreeNode<T> | null; children: ClrTreetableTreeNode<T>[]; /** * If true, the node will stay INDETERMINATE even when all descendants are selected * unless it was manually selected. */ private readonly stickyIndeterminate; private readonly manuallySelected; selected: import("@angular/core").WritableSignal<ClrTreetableSelectedState>; constructor(value: T, parent?: ClrTreetableTreeNode<T> | null, children?: ClrTreetableTreeNode<T>[], stickyIndeterminate?: boolean); /** * Depth level in the tree (root = 0). */ get depth(): number; /** * True if this node has no children. */ get isLeaf(): boolean; /** * Sets the selection state for this node and propagates to all descendants (except INDETERMINATE). * @param state Desired selection state. */ setSelected(state: ClrTreetableSelectedState): void; /** * Returns all descendants as a flat generator. */ getFlatDescendants(): Generator<ClrTreetableTreeNode<T>>; /** * Recursively applies a selected/unselected state to all descendants. */ private propagateToChildren; } /** * Creates an internal tree node hierarchy from a raw data object. * * @param value Root raw data object. * @param getChildren Function returning direct children of a node. * @param stickyIndeterminate Whether to keep INDETERMINATE even if all descendants become selected. */ export declare function mapToInternalTree<T extends object>(value: T, getChildren: ClrTreetableChildrenFunction<T>, stickyIndeterminate: boolean): ClrTreetableTreeNode<T>;