import type { Event, Disposable } from '@difizen/mana-common'; import { Emitter } from '@difizen/mana-common'; import type { TreeNode } from './tree'; import { CompositeTreeNode, Tree } from './tree'; export declare const TreeExpansionService: unique symbol; /** * The tree expandable service. */ export type TreeExpansionService = { /** * Emit when the node is expanded or collapsed. */ readonly onExpansionChanged: Event>; /** * Expand a node for the given node id if it is valid and collapsed. * Expanding a node refreshes all its children. * * Return a valid expanded refreshed node or `undefined` if such does not exist. */ expandNode: (node: Readonly) => Promise | undefined>; /** * If the given node is valid and expanded then collapse it. * * Return true if a node has been collapsed; otherwise false. */ collapseNode: (node: Readonly) => Promise; /** * If the given node is valid then collapse it recursively. * * Return true if a node has been collapsed; otherwise false. */ collapseAll: (node: Readonly) => Promise; /** * If the given node is invalid then does nothing. * If the given node is collapsed then expand it; otherwise collapse it. */ toggleNodeExpansion: (node: Readonly) => Promise; } & Disposable; /** * The expandable tree node. */ export type ExpandableTreeNode = { /** * Test whether this tree node is expanded. */ expanded: boolean; } & CompositeTreeNode; export declare namespace ExpandableTreeNode { function is(node: Record | undefined): node is ExpandableTreeNode; function isExpanded(node: Record | undefined): node is ExpandableTreeNode; function isCollapsed(node: Record | undefined): node is ExpandableTreeNode; } export declare class TreeExpansionServiceImpl implements TreeExpansionService { protected readonly onExpansionChangedEmitter: Emitter; protected readonly tree: Tree; constructor(tree: Tree); protected init(): void; dispose(): void; get onExpansionChanged(): Event; protected fireExpansionChanged(node: ExpandableTreeNode): void; expandNode(raw: ExpandableTreeNode): Promise; protected doExpandNode(node: ExpandableTreeNode): Promise; collapseNode(raw: ExpandableTreeNode): Promise; collapseAll(raw: CompositeTreeNode): Promise; protected doCollapseAll(node: TreeNode | undefined): boolean; protected doCollapseNode(node: TreeNode | undefined): boolean; toggleNodeExpansion(node: ExpandableTreeNode): Promise; } //# sourceMappingURL=tree-expansion.d.ts.map