UNPKG

@intuitionrobotics/thunderstorm

Version:
62 lines (61 loc) 2.35 kB
import * as React from 'react'; import { CSSProperties } from 'react'; import { Adapter } from "../adapter/Adapter"; export type NodeExpandCondition = (key: string, value: any, level: number, path: string) => boolean | undefined; export type BaseTreeProps = { id: string; onNodeFocused?: (path: string, item: any) => void; onNodeClicked?: (path: string, item: any) => void; expanded: TreeNodeExpandState; childrenContainerStyle?: (level: number, parentNodeRef: HTMLDivElement, containerRef: HTMLDivElement, parentRef?: HTMLDivElement) => CSSProperties; indentPx: number; checkExpanded: (expanded: TreeNodeExpandState, path: string) => boolean | undefined; keyEventHandler?: (node: HTMLDivElement, e: KeyboardEvent) => void; onFocus?: () => void; onBlur?: () => void; unMountFromOutside?: () => void; selectedItem?: any; adapter: Adapter; }; export type TreeNodeExpandState = { [path: string]: true | undefined; }; type TreeState = { expanded: TreeNodeExpandState; focused?: string; lastFocused?: string; adapter: Adapter; }; export declare class Tree<P extends BaseTreeProps = BaseTreeProps, S extends TreeState = TreeState> extends React.Component<P, TreeState> { static defaultProps: Partial<BaseTreeProps>; protected containerRefs: { [k: string]: HTMLDivElement; }; protected rendererRefs: { [k: string]: HTMLDivElement; }; protected renderedElements: string[]; constructor(props: P); static getDerivedStateFromProps(props: BaseTreeProps, state: TreeState): TreeState | null; componentDidMount(): void; renderedElementsInit: () => void; render(): React.JSX.Element; private renderNode; private nodeResolver; private resolveContainer; private renderChildren; private renderItem; private getChildrenContainerStyle; private setFocusedNode; protected keyEventHandler: (node: HTMLDivElement, e: KeyboardEvent) => void; getItemByPath(path: string): any; private ignoreToggler; private toggleExpandState; private expandOrCollapse; private onNodeFocused; private onNodeClicked; private onBlur; private onFocus; static recursivelyExpand(adapter: Adapter, expandCondition?: NodeExpandCondition, state?: TreeNodeExpandState): TreeNodeExpandState; } export {};