@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
71 lines • 3.82 kB
TypeScript
import { Tree, TreeNode } from './tree.js';
import { TreeSelection, SelectableTreeNode } from './tree-selection.js';
/**
* A tree selection that might contain additional information about the tree node that has the focus.
*/
export interface FocusableTreeSelection extends TreeSelection {
/**
* The tree node that has the focus in the tree selection. In case of a range selection,
* the `focus` differs from the `node`.
*/
readonly focus?: SelectableTreeNode;
}
export declare namespace FocusableTreeSelection {
/**
* `true` if the argument is a focusable tree selection. Otherwise, `false`.
*/
function is(arg: unknown): arg is FocusableTreeSelection;
/**
* Returns with the tree node that has the focus if the argument is a focusable tree selection.
* Otherwise, returns `undefined`.
*/
function focus(arg: TreeSelection | undefined): SelectableTreeNode | undefined;
}
/**
* Class for representing and managing the selection state and the focus of a tree.
*/
export declare class TreeSelectionState {
protected readonly tree: Tree;
/**
* The stack of selections, by the id of the nodes they refer to.
*
* Everything this state does with a selection resolves the node through the tree anyway, so keeping the nodes
* themselves would only pin a subtree that a refresh has since replaced, along with whatever its elements refer
* to. Keeping the ids also lets a selection outlive its nodes briefly leaving the tree, as happens when a tree
* updates itself by clearing its contents before filling them in again.
*/
protected readonly ids: ReadonlyArray<{
readonly node: string;
readonly focus?: string;
readonly type?: TreeSelection.SelectionType;
}>;
constructor(tree: Tree, selectionStack?: ReadonlyArray<FocusableTreeSelection>);
/**
* The selections of this state that refer to a node the tree currently has. Selections of nodes that are not in
* the tree are left out, but are kept by this state, so that they apply again if their nodes come back.
*/
get selectionStack(): ReadonlyArray<FocusableTreeSelection>;
/**
* Resolves a node id against the tree. Unlike {@link toSelectableTreeNode} this does not report an id that does
* not resolve, because the stack is expected to outlive the nodes it refers to.
*/
protected findSelectableTreeNode(id: string | undefined): SelectableTreeNode | undefined;
nextState(selection: FocusableTreeSelection): TreeSelectionState;
selection(): ReadonlyArray<SelectableTreeNode>;
get focus(): SelectableTreeNode | undefined;
get node(): SelectableTreeNode | undefined;
protected handleDefault(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
protected handleToggle(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
protected handleRange(state: TreeSelectionState, node: Readonly<SelectableTreeNode>): TreeSelectionState;
/**
* Returns with an array of items representing the selection range. The from node is the `focus` the to node
* is the selected node itself on the tree selection. Both the `from` node and the `to` node are inclusive.
*/
protected selectionRange(selection: FocusableTreeSelection): Readonly<SelectableTreeNode>[];
protected toSelectableTreeNode(node: TreeNode | undefined): SelectableTreeNode | undefined;
/**
* Checks whether the argument contains any `DEFAULT` tree selection type. If yes, throws an error, otherwise returns with a reference the argument.
*/
protected checkNoDefaultSelection<T extends TreeSelection>(selections: ReadonlyArray<T>): ReadonlyArray<T>;
}
//# sourceMappingURL=tree-selection-state.d.ts.map