UNPKG

2.57 kBTypeScriptView Raw
1import { Tree, TreeNode } from './tree';
2import { TreeSelection, SelectableTreeNode } from './tree-selection';
3/**
4 * A tree selection that might contain additional information about the tree node that has the focus.
5 */
6export interface FocusableTreeSelection extends TreeSelection {
7 /**
8 * The tree node that has the focus in the tree selection. In case of a range selection,
9 * the `focus` differs from the `node`.
10 */
11 readonly focus?: SelectableTreeNode;
12}
13export declare namespace FocusableTreeSelection {
14 /**
15 * `true` if the argument is a focusable tree selection. Otherwise, `false`.
16 */
17 function is(arg: unknown): arg is FocusableTreeSelection;
18 /**
19 * Returns with the tree node that has the focus if the argument is a focusable tree selection.
20 * Otherwise, returns `undefined`.
21 */
22 function focus(arg: TreeSelection | undefined): SelectableTreeNode | undefined;
23}
24/**
25 * Class for representing and managing the selection state and the focus of a tree.
26 */
27export declare class TreeSelectionState {
28 protected readonly tree: Tree;
29 readonly selectionStack: ReadonlyArray<FocusableTreeSelection>;
30 constructor(tree: Tree, selectionStack?: ReadonlyArray<FocusableTreeSelection>);
31 nextState(selection: FocusableTreeSelection): TreeSelectionState;
32 selection(): ReadonlyArray<SelectableTreeNode>;
33 get focus(): SelectableTreeNode | undefined;
34 get node(): SelectableTreeNode | undefined;
35 protected handleDefault(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
36 protected handleToggle(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
37 protected handleRange(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
38 /**
39 * Returns with an array of items representing the selection range. The from node is the `focus` the to node
40 * is the selected node itself on the tree selection. Both the `from` node and the `to` node are inclusive.
41 */
42 protected selectionRange(selection: FocusableTreeSelection): Readonly<SelectableTreeNode>[];
43 protected toSelectableTreeNode(node: TreeNode | undefined): SelectableTreeNode | undefined;
44 /**
45 * Checks whether the argument contains any `DEFAULT` tree selection type. If yes, throws an error, otherwise returns with a reference the argument.
46 */
47 protected checkNoDefaultSelection<T extends TreeSelection>(selections: ReadonlyArray<T>): ReadonlyArray<T>;
48}
49//# sourceMappingURL=tree-selection-state.d.ts.map
\No newline at end of file