import type { Event, WaitUntilEvent, CancellationToken } from '@difizen/mana-common'; import { Emitter, DisposableCollection } from '@difizen/mana-common'; import type { SelectionProvider } from '@difizen/mana-core'; import type { TreeNode } from './tree'; import { Tree, CompositeTreeNode } from './tree'; import { TreeExpansionService, ExpandableTreeNode } from './tree-expansion'; import type { TreeIterator } from './tree-iterator'; import { TreeNavigationService } from './tree-navigation'; import { TreeSelectionService, SelectableTreeNode, TreeSelection } from './tree-selection'; /** * The tree model. */ export declare const TreeModel: unique symbol; export type TreeModel = { /** * Expands the given node. If the `node` argument is `undefined`, then expands the currently selected tree node. * If multiple tree nodes are selected, expands the most recently selected tree node. */ expandNode: (node?: Readonly) => Promise | undefined>; /** * Collapses the given node. If the `node` argument is `undefined`, then collapses the currently selected tree node. * If multiple tree nodes are selected, collapses the most recently selected tree node. */ collapseNode: (node?: Readonly) => Promise; /** * Collapses recursively. If the `node` argument is `undefined`, then collapses the currently selected tree node. * If multiple tree nodes are selected, collapses the most recently selected tree node. */ collapseAll: (node?: Readonly) => Promise; /** * Toggles the expansion state of the given node. If not give, then it toggles the expansion state of the currently selected node. * If multiple nodes are selected, then the most recently selected tree node's expansion state will be toggled. */ toggleNodeExpansion: (node?: Readonly) => Promise; /** * Opens the given node or the currently selected on if the argument is `undefined`. * If multiple nodes are selected, open the most recently selected node. */ openNode: (node?: Readonly | undefined) => void; /** * Event when a node should be opened. */ readonly onOpenNode: Event>; /** * Selects the parent node relatively to the selected taking into account node expansion. */ selectParent: () => void; /** * Navigates to the given node if it is defined. This method accepts both the tree node and its ID as an argument. * Navigation sets a node as a root node and expand it. Resolves to the node if the navigation was successful. Otherwise, * resolves to `undefined`. */ navigateTo: (nodeOrId: Readonly | string | undefined) => Promise; /** * Tests whether it is possible to navigate forward. */ canNavigateForward: () => boolean; /** * Tests whether it is possible to navigate backward. */ canNavigateBackward: () => boolean; /** * Navigates forward. */ navigateForward: () => Promise; /** * Navigates backward. */ navigateBackward: () => Promise; /** * Selects the previous node relatively to the currently selected one. This method takes the expansion state of the tree into consideration. */ selectPrevNode: (type?: TreeSelection.SelectionType) => void; /** * Returns the previous selectable tree node. */ getPrevSelectableNode: (node?: TreeNode) => SelectableTreeNode | undefined; /** * Selects the next node relatively to the currently selected one. This method takes the expansion state of the tree into consideration. */ selectNextNode: (type?: TreeSelection.SelectionType) => void; /** * Returns the next selectable tree node. */ getNextSelectableNode: (node?: TreeNode) => SelectableTreeNode | undefined; /** * Selects the given tree node. Has no effect when the node does not exist in the tree. Discards any previous selection state. */ selectNode: (node: Readonly) => void; /** * Selects the given node if it was not yet selected, or unselects it if it was. Keeps the previous selection state and updates it * with the current toggle selection. */ toggleNode: (node: Readonly) => void; /** * Selects a range of tree nodes. The target of the selection range is the argument, the from tree node is the previous selected node. * If no node was selected previously, invoking this method does nothing. */ selectRange: (node: Readonly) => void; } & Tree & TreeSelectionService & TreeExpansionService; export declare class TreeModelImpl implements TreeModel, SelectionProvider[]> { protected readonly tree: Tree; protected readonly selectionService: TreeSelectionService; protected readonly expansionService: TreeExpansionService; protected readonly navigationService: TreeNavigationService; constructor(tree: Tree, selectionService: TreeSelectionService, expansionService: TreeExpansionService, navigationService: TreeNavigationService); protected readonly onChangedEmitter: Emitter; protected readonly onOpenNodeEmitter: Emitter; protected readonly toDispose: DisposableCollection; protected init(): void; dispose(): void; protected handleExpansion(node: Readonly): void; /** * Select the given node if it is the ancestor of a selected node. */ protected selectIfAncestorOfSelected(node: Readonly): void; get root(): TreeNode | undefined; set root(root: TreeNode | undefined); get onChanged(): Event; get onOpenNode(): Event; protected fireChanged(): void; get onNodeRefreshed(): Event & WaitUntilEvent>; getNode(id: string | undefined): TreeNode | undefined; validateNode(node: TreeNode | undefined): TreeNode | undefined; refresh(parent?: Readonly): Promise; get selectedNodes(): readonly Readonly[]; get onSelectionChanged(): Event[]> & Event[] | undefined>; get onExpansionChanged(): Event>; expandNode(raw?: Readonly): Promise; collapseNode(raw?: Readonly): Promise; collapseAll(raw?: Readonly): Promise; toggleNodeExpansion: (raw?: Readonly) => Promise; selectPrevNode(type?: TreeSelection.SelectionType): void; getPrevSelectableNode(node?: TreeNode): SelectableTreeNode | undefined; selectNextNode(type?: TreeSelection.SelectionType): void; getNextSelectableNode(node?: TreeNode): SelectableTreeNode | undefined; protected doGetNextNode(iterator: TreeIterator): SelectableTreeNode | undefined; protected createBackwardIterator(_node: TreeNode | undefined): TreeIterator | undefined; protected createIterator(_node: TreeNode | undefined): TreeIterator | undefined; openNode(raw?: TreeNode | undefined): void; protected doOpenNode(node: TreeNode): void; selectParent(): void; navigateTo(nodeOrId: TreeNode | string | undefined): Promise; canNavigateForward(): boolean; canNavigateBackward(): boolean; navigateForward(): Promise; navigateBackward(): Promise; protected doNavigate(node: TreeNode): Promise; addSelection(selectionOrTreeNode: TreeSelection | Readonly): void; selectNode(node: Readonly): void; toggleNode(node: Readonly): void; selectRange(node: Readonly): void; storeState(): TreeModelImpl.State; restoreState(state: Record): void; get onDidChangeBusy(): Event; markAsBusy(node: Readonly, ms: number, token: CancellationToken): Promise; } export declare namespace TreeModelImpl { type State = { selection: object; }; } //# sourceMappingURL=tree-model.d.ts.map