///
import type { Event, Disposable, CancellationToken, WaitUntilEvent } from '@difizen/mana-common';
import type { NodeProps, TreeProps } from './tree-protocol';
export declare const Tree: unique symbol;
/**
* The tree - an abstract data type.
*/
export type Tree = {
/**
* A root node of this tree.
* Undefined if there is no root node.
* Setting a root node refreshes the tree.
*/
root: TreeNode | undefined;
/**
* Emit when the tree is changed.
*/
readonly onChanged: Event;
/**
* Return a node for the given identifier or undefined if such does not exist.
*/
getNode: (id: string | undefined) => TreeNode | undefined;
/**
* Return a valid node in this tree matching to the given; otherwise undefined.
*/
validateNode: (node: TreeNode | undefined) => TreeNode | undefined;
/**
* Refresh children of the r../../../../examples/application-react/utils.
*
* Return a valid refreshed composite root or `undefined` if such does not exist.
*/
refresh: (() => Promise | undefined>) & ((parent: Readonly) => Promise | undefined>);
/**
* Emit when the children of the given node are refreshed.
*/
readonly onNodeRefreshed: Event & WaitUntilEvent>;
/**
* Emits when the busy state of the given node is changed.
*/
readonly onDidChangeBusy: Event;
/**
* Marks the give node as busy after a specified number of milliseconds.
* A token source of the given token should be canceled to unmark.
*/
markAsBusy: (node: Readonly, ms: number, token: CancellationToken) => Promise;
} & Disposable;
/**
* The tree node.
*/
export type TreeNode = {
/**
* An unique id of this node.
*/
readonly id: string;
readonly icon?: string;
readonly description?: string;
/**
* Test whether this node should be rendered.
* If undefined then node will be rendered.
*/
readonly visible?: boolean;
/**
* A parent node of this tree node.
* Undefined if this node is root.
*/
readonly parent: Readonly | undefined;
/**
* A previous sibling of this tree node.
*/
readonly previousSibling?: TreeNode;
/**
* A next sibling of this tree node.
*/
readonly nextSibling?: TreeNode;
/**
* Whether this node is busy. Greater than 0 then busy; otherwise not.
*/
readonly busy?: number;
readonly name?: string;
};
export declare namespace TreeNode {
function is(node: Record | undefined): node is TreeNode;
function equals(left: TreeNode | undefined, right: TreeNode | undefined): boolean;
function isVisible(node: TreeNode | undefined): boolean;
}
/**
* The composite tree node.
*/
export type CompositeTreeNode = {
/**
* Child nodes of this tree node.
*/
children: readonly TreeNode[];
} & TreeNode;
export declare namespace CompositeTreeNode {
function is(node: Record | undefined): node is CompositeTreeNode;
function getFirstChild(parent: CompositeTreeNode): TreeNode | undefined;
function getLastChild(parent: CompositeTreeNode): TreeNode | undefined;
function isAncestor(parent: CompositeTreeNode, child: TreeNode | undefined): boolean;
function indexOf(parent: CompositeTreeNode, node: TreeNode | undefined): number;
function addChildren(parent: CompositeTreeNode, children: TreeNode[]): CompositeTreeNode;
function addChild(parent: CompositeTreeNode, child: TreeNode): CompositeTreeNode;
function removeChild(parent: CompositeTreeNode, child: TreeNode): void;
function setParent(child: TreeNode, index: number, parent: CompositeTreeNode): void;
}
/**
* Representation of a tree node row.
*/
export type NodeRow = {
/**
* The node row index.
*/
index: number;
/**
* The actual node.
*/
node: TreeNode;
/**
* A root relative number representing the hierarchical depth of the actual node. Root is `0`, its children have `1` and so on.
*/
depth: number;
};
export interface TreeNodeProps {
node: TreeNode;
nodeProps: NodeProps;
}
export interface TreeNodeCaptionAffixesProps extends TreeNodeProps {
affixKey: 'captionPrefixes' | 'captionSuffixes';
}
export interface TreeNodeIconDecoratorProps extends TreeNodeProps {
icon: React.ReactNode;
}
export interface TreeNodeComponents {
TreeNodeExpansion: React.FC;
TreeNode: React.FC;
TreeNodeIcon: React.FC;
TreeNodeCaption: React.FC;
TreeNodeCaptionAffixes: React.FC;
TreeNodeTailDecorations: React.FC;
TreeNodeIconDecorator: React.FC;
TreeIdent: React.FC;
TreeSwitchIcon: React.FC;
}
export declare const TreeNodeComponents: unique symbol;
/**
* Bare minimum common interface of the keyboard and the mouse event with respect to the key maskings.
*/
export type ModifierAwareEvent = {
/**
* Determines if the modifier aware event has the `meta` key masking.
*/
readonly metaKey: boolean;
/**
* Determines if the modifier aware event has the `ctrl` key masking.
*/
readonly ctrlKey: boolean;
/**
* Determines if the modifier aware event has the `shift` key masking.
*/
readonly shiftKey: boolean;
};
/**
* The default tree properties.
*/
export declare const DefaultTreeProps: TreeProps;
//# sourceMappingURL=tree.d.ts.map