@senyao-design-system/magic-tree
Version:
A tree component implemented with Konva for handling large datasets.
28 lines (26 loc) • 1.54 kB
TypeScript
import { default as React } from 'react';
import { default as Konva } from 'konva';
import { FlattenedTreeNode, TreeNodeId, NodeContentRenderProps } from '../types';
interface TreeNodeProps<T extends Record<string, unknown>> {
readonly node: FlattenedTreeNode<T>;
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
readonly onToggleExpand: (nodeId: TreeNodeId) => void;
readonly renderNodeContent?: (props: NodeContentRenderProps<T>) => React.ReactNode;
readonly onNodeClick?: (node: FlattenedTreeNode<T>, event: Konva.KonvaEventObject<MouseEvent>) => void;
readonly onNodeHover: (node: FlattenedTreeNode<T> | null, event: Konva.KonvaEventObject<MouseEvent> | null) => void;
readonly isHovered: boolean;
readonly isLoading: boolean;
/** Optional: Callback when the mouse is pressed down on the node, initiating a potential drag. */
readonly onNodePress?: (node: FlattenedTreeNode<T>, event: Konva.KonvaEventObject<MouseEvent>) => void;
readonly icon?: (props: FlattenedTreeNode<T>) => React.ReactNode;
readonly iconSize?: number;
}
/**
* TreeNode component renders a single node in the Konva-based tree.
* @template T - The type of custom data associated with the node.
*/
export declare function TreeNode<T extends Record<string, unknown>>({ node, x, y, width, height, onToggleExpand, renderNodeContent, onNodeClick, onNodeHover, isHovered, isLoading, onNodePress, icon, iconSize, }: TreeNodeProps<T>): React.ReactElement;
export {};