UNPKG

3.05 kBTypeScriptView Raw
1import { TreeNode } from './tree';
2import { Event, Disposable, SelectionProvider } from '../../common';
3/**
4 * The tree selection service.
5 */
6export declare const TreeSelectionService: unique symbol;
7export interface TreeSelectionService extends Disposable, SelectionProvider<ReadonlyArray<Readonly<SelectableTreeNode>>> {
8 /**
9 * The tree selection, representing the selected nodes from the tree. If nothing is selected, the
10 * result will be empty.
11 */
12 readonly selectedNodes: ReadonlyArray<Readonly<SelectableTreeNode>>;
13 /**
14 * Emitted when the selection has changed in the tree.
15 */
16 readonly onSelectionChanged: Event<ReadonlyArray<Readonly<SelectableTreeNode>>>;
17 /**
18 * Registers the given selection into the tree selection service. If the selection state changes after adding the
19 * `selectionOrTreeNode` argument, a selection changed event will be fired. If the argument is a tree node,
20 * a it will be treated as a tree selection with the default selection type.
21 */
22 addSelection(selectionOrTreeNode: TreeSelection | Readonly<SelectableTreeNode>): void;
23 /**
24 * Clears all selected nodes
25 */
26 clearSelection(): void;
27 /**
28 * Store selection state.
29 */
30 storeState(): object;
31 /**
32 * Restore selection state.
33 */
34 restoreState(state: object): void;
35}
36/**
37 * Representation of a tree selection.
38 */
39export interface TreeSelection {
40 /**
41 * The actual item that has been selected.
42 */
43 readonly node: Readonly<SelectableTreeNode>;
44 /**
45 * The optional tree selection type. Defaults to `SelectionType.DEFAULT`;
46 */
47 readonly type?: TreeSelection.SelectionType;
48}
49export declare namespace TreeSelection {
50 /**
51 * Enumeration of selection types.
52 */
53 enum SelectionType {
54 DEFAULT = 0,
55 TOGGLE = 1,
56 RANGE = 2
57 }
58 function is(arg: unknown): arg is TreeSelection;
59 function isRange(arg: TreeSelection | SelectionType | undefined): boolean;
60 function isToggle(arg: TreeSelection | SelectionType | undefined): boolean;
61}
62/**
63 * A selectable tree node.
64 */
65export interface SelectableTreeNode extends TreeNode {
66 /**
67 * `true` if the tree node is selected. Otherwise, `false`.
68 */
69 selected: boolean;
70 /**
71 * @deprecated @since 1.27.0. Use TreeFocusService to track the focused node.
72 *
73 * `true` if the tree node has the focus. Otherwise, `false`. Defaults to `false`.
74 */
75 focus?: boolean;
76}
77export declare namespace SelectableTreeNode {
78 function is(node: unknown): node is SelectableTreeNode;
79 function isSelected(node: unknown): node is SelectableTreeNode;
80 /**
81 * @deprecated @since 1.27.0. Use TreeFocusService to track the focused node.
82 */
83 function hasFocus(node: TreeNode | undefined): boolean;
84 function isVisible(node: TreeNode | undefined): node is SelectableTreeNode;
85 function getVisibleParent(node: TreeNode | undefined): SelectableTreeNode | undefined;
86}
87//# sourceMappingURL=tree-selection.d.ts.map
\No newline at end of file