UNPKG

2.6 kBTypeScriptView Raw
1import * as React from "react";
2import { type Props } from "../../common";
3import type { TreeEventHandler, TreeNodeInfo } from "./treeTypes";
4export interface TreeProps<T = {}> extends Props {
5 /**
6 * Whether to use a compact appearance which reduces the visual padding around node content.
7 */
8 compact?: boolean;
9 /**
10 * The data specifying the contents and appearance of the tree.
11 */
12 contents: ReadonlyArray<TreeNodeInfo<T>>;
13 /**
14 * Invoked when a node is clicked anywhere other than the caret for expanding/collapsing the node.
15 */
16 onNodeClick?: TreeEventHandler<T>;
17 /**
18 * Invoked when caret of an expanded node is clicked.
19 */
20 onNodeCollapse?: TreeEventHandler<T>;
21 /**
22 * Invoked when a node is right-clicked or the context menu button is pressed on a focused node.
23 */
24 onNodeContextMenu?: TreeEventHandler<T>;
25 /**
26 * Invoked when a node is double-clicked. Be careful when using this in combination with
27 * an `onNodeClick` (single-click) handler, as the way this behaves can vary between browsers.
28 * See http://stackoverflow.com/q/5497073/3124288
29 */
30 onNodeDoubleClick?: TreeEventHandler<T>;
31 /**
32 * Invoked when the caret of a collapsed node is clicked.
33 */
34 onNodeExpand?: TreeEventHandler<T>;
35 /**
36 * Invoked when the mouse is moved over a node.
37 */
38 onNodeMouseEnter?: TreeEventHandler<T>;
39 /**
40 * Invoked when the mouse is moved out of a node.
41 */
42 onNodeMouseLeave?: TreeEventHandler<T>;
43}
44/**
45 * Tree component.
46 *
47 * @see https://blueprintjs.com/docs/#core/components/tree
48 */
49export declare class Tree<T = {}> extends React.Component<TreeProps<T>> {
50 static displayName: string;
51 static ofType<U>(): new (props: TreeProps<U>) => Tree<U>;
52 static nodeFromPath<U>(path: readonly number[], treeNodes?: ReadonlyArray<TreeNodeInfo<U>>): TreeNodeInfo<U>;
53 private nodeRefs;
54 render(): React.JSX.Element;
55 /**
56 * Returns the underlying HTML element of the `Tree` node with an id of `nodeId`.
57 * This element does not contain the children of the node, only its label and controls.
58 * If the node is not currently mounted, `undefined` is returned.
59 */
60 getNodeContentElement(nodeId: string | number): HTMLElement | undefined;
61 private renderNodes;
62 private handleContentRef;
63 private handleNodeCollapse;
64 private handleNodeClick;
65 private handleNodeContextMenu;
66 private handleNodeDoubleClick;
67 private handleNodeExpand;
68 private handleNodeMouseEnter;
69 private handleNodeMouseLeave;
70}