UNPKG

2.77 kBTypeScriptView Raw
1import { Emitter, Event, Disposable } from '../../common';
2import { CompositeTreeNode, TreeNode, Tree } from './tree';
3export declare const TreeExpansionService: unique symbol;
4/**
5 * The tree expandable service.
6 */
7export interface TreeExpansionService extends Disposable {
8 /**
9 * Emit when the node is expanded or collapsed.
10 */
11 readonly onExpansionChanged: Event<Readonly<ExpandableTreeNode>>;
12 /**
13 * Expand a node for the given node id if it is valid and collapsed.
14 * Expanding a node refreshes all its children.
15 *
16 * Return a valid expanded refreshed node or `undefined` if such does not exist.
17 */
18 expandNode(node: Readonly<ExpandableTreeNode>): Promise<Readonly<ExpandableTreeNode> | undefined>;
19 /**
20 * If the given node is valid and expanded then collapse it.
21 *
22 * Return true if a node has been collapsed; otherwise false.
23 */
24 collapseNode(node: Readonly<ExpandableTreeNode>): Promise<boolean>;
25 /**
26 * If the given node is valid then collapse it recursively.
27 *
28 * Return true if a node has been collapsed; otherwise false.
29 */
30 collapseAll(node: Readonly<CompositeTreeNode>): Promise<boolean>;
31 /**
32 * If the given node is invalid then does nothing.
33 * If the given node is collapsed then expand it; otherwise collapse it.
34 */
35 toggleNodeExpansion(node: Readonly<ExpandableTreeNode>): Promise<void>;
36}
37/**
38 * The expandable tree node.
39 */
40export interface ExpandableTreeNode extends CompositeTreeNode {
41 /**
42 * Test whether this tree node is expanded.
43 */
44 expanded: boolean;
45}
46export declare namespace ExpandableTreeNode {
47 function is(node: unknown): node is ExpandableTreeNode;
48 function isExpanded(node: unknown): node is ExpandableTreeNode;
49 function isCollapsed(node: unknown): node is ExpandableTreeNode;
50}
51export declare class TreeExpansionServiceImpl implements TreeExpansionService {
52 protected readonly tree: Tree;
53 protected readonly onExpansionChangedEmitter: Emitter<ExpandableTreeNode>;
54 protected init(): void;
55 dispose(): void;
56 get onExpansionChanged(): Event<ExpandableTreeNode>;
57 protected fireExpansionChanged(node: ExpandableTreeNode): void;
58 expandNode(raw: ExpandableTreeNode): Promise<ExpandableTreeNode | undefined>;
59 protected doExpandNode(node: ExpandableTreeNode): Promise<ExpandableTreeNode | undefined>;
60 collapseNode(raw: ExpandableTreeNode): Promise<boolean>;
61 collapseAll(raw: CompositeTreeNode): Promise<boolean>;
62 protected doCollapseAll(node: TreeNode | undefined): boolean;
63 protected doCollapseNode(node: TreeNode | undefined): boolean;
64 toggleNodeExpansion(node: ExpandableTreeNode): Promise<void>;
65}
66//# sourceMappingURL=tree-expansion.d.ts.map
\No newline at end of file