import type { TreeDataItem } from '../helpers/types'; import { CheckedState, TreeManager } from './tree-manager.js'; /** * `TreeNode` is expected to be used with `TreeManager` in tandem with Tree & Tree Select components. * Accordingly, only accessors for `TreeDataItem`'s properties are implemented. */ export declare class TreeNode { /** An item managed by Tree Node */ protected item: T; /** Tree Manager of the item to be managed */ protected manager: TreeManager; /** * Create a new Tree Node managing an item & its Tree Manager. * @param item item to be managed * @param manager `TreeManager` of the item to be managed * @hidden this constructor should be used internally & only by `TreeManager` */ constructor(item: T, manager: TreeManager); /** Icon to show, when rendering the item. */ get icon(): string | undefined; set icon(icon: string | undefined); /** Label to show, when rendering the item. */ get label(): string; set label(value: string); /** * Value of the data item. * This is usually the value which is returned, * when the item is selected. */ get value(): string; set value(value: string); /** * Sets the item to be readonly. * Read only items cannot be selected by a user. */ get readonly(): boolean; set readonly(value: boolean); /** * Sets the highlight state of the item. * This is usually used for navigating over items, * without affecting focus or multiple item selection. */ get highlighted(): boolean; set highlighted(value: boolean); /** * Sets the item to be disabled. * This completely prevents the item from being interacted with. */ get disabled(): boolean; set disabled(value: boolean); /** * Whether to show or hide the item from the renderer. * @readonly */ get hidden(): boolean; /** Expanded state of child items. If `true`, child items will be visible. */ get expanded(): boolean; set expanded(value: boolean); /** * Timestamp indicating the order of sequential selection. * @readonly */ get selectedAt(): number | undefined; /** * Selection state of the item. * If its `TreeManager` is in relationship mode, value would be get/set hierarchically. * For instance, items with children would be considered selected when all children are selected. * * For indeterminate state support, use `getCheckedState()` instead. */ get selected(): boolean; set selected(value: boolean); /** * Return checked state of the item. * Apart from checked & unchecked state of `selected` accessor, * this method supports indeterminate state for items that some but not all of their children are selected. * @returns item checked state: CHECKED (1), UNCHECKED (0), INDETERMINATE (-1) */ getCheckedState(): CheckedState; /** * Returns all ancestors of the item. * @returns An array of ancestors as Tree Node */ getAncestors(): TreeNode[]; /** * Returns the children of the item. * @returns An array of children as Tree Node */ getChildren(): TreeNode[]; /** * Returns all descendants of the item. * @param depth Depth of descendants to get. If it's `undefined`, get all descendants. * @returns An array of descendants as Tree Node */ getDescendants(depth?: number): TreeNode[]; /** * Returns the parent of the item, if it has one. * @returns Item parent as Tree Node or `null` */ getParent(): TreeNode | null; /** * Returns whether the selected state of the item can be changed or not. * @returns `True` if the item is not disabled or readonly */ isSelectable(): boolean; /** * Returns whether the item contains any children or not. * @returns `True` if the item has children */ isParent(): boolean; /** * Returns whether the item has a parent or not. * @returns `True` if the item has a parent */ isChild(): boolean; /** * Return the depth of the item starting from 0 for root items, * 1 for children of root items, 2 for grandchildren of root items and so on. * @returns depth of the item */ getDepth(): number; /** * Requests the item to be rerendered manually. * Typically, this is not required. The render is triggered automatically when item's properties are updated. * @returns {void} */ rerender(): void; /** * Retrieve a value of the specified property. * @param prop property key * @returns property value */ private getPropertyValue; /** * Set a value of the specified property. * @param prop property key * @param value property value * @returns {void} */ private setProperty; }