1 | /// <reference types="react" />
|
2 | import type { MaybeElement } from "../../common/props";
|
3 | import type { IconName } from "../icon/icon";
|
4 | export interface TreeNodeInfo<T = {}> {
|
5 | /**
|
6 | * A space-delimited list of class names for this tree node element.
|
7 | */
|
8 | className?: string;
|
9 | /**
|
10 | * Child tree nodes of this node.
|
11 | */
|
12 | childNodes?: Array<TreeNodeInfo<T>>;
|
13 | /**
|
14 | * Whether this tree node is non-interactive. Enabling this prop will ignore
|
15 | * mouse event handlers (in particular click, down, enter, leave).
|
16 | */
|
17 | disabled?: boolean;
|
18 | /**
|
19 | * Whether the caret to expand/collapse a node should be shown.
|
20 | * If not specified, this will be true if the node has children and false otherwise.
|
21 | */
|
22 | hasCaret?: boolean;
|
23 | /**
|
24 | * The name of a Blueprint icon (or an icon element) to render next to the node's label.
|
25 | */
|
26 | icon?: IconName | MaybeElement;
|
27 | /**
|
28 | * A unique identifier for the node.
|
29 | */
|
30 | id: string | number;
|
31 | /**
|
32 | */
|
33 | isExpanded?: boolean;
|
34 | /**
|
35 | * Whether this node is selected.
|
36 | *
|
37 | * @default false
|
38 | */
|
39 | isSelected?: boolean;
|
40 | /**
|
41 | * The main label for the node.
|
42 | */
|
43 | label: string | React.JSX.Element;
|
44 | /**
|
45 | * A secondary label/component that is displayed at the right side of the node.
|
46 | */
|
47 | secondaryLabel?: string | MaybeElement;
|
48 | /**
|
49 | * An optional custom user object to associate with the node.
|
50 | * This property can then be used in the `onClick`, `onContextMenu` and `onDoubleClick`
|
51 | * event handlers for doing custom logic per node.
|
52 | */
|
53 | nodeData?: T;
|
54 | }
|
55 | export type TreeEventHandler<T = {}> = (node: TreeNodeInfo<T>, nodePath: number[], e: React.MouseEvent<HTMLElement>) => void;
|