UNPKG

@alpernative/tree

Version:

[`@alpernative/tree`](https://www.npmjs.com/package/@alpernative/tree) is a high-performance, customizable tree component for React. It provides a wide range of features, including virtualization, drag-and-drop, and nested drag-and-drop support.

35 lines (34 loc) 1.31 kB
import { ReactNode } from 'react'; import { DraggableProvided, DraggableStateSnapshot, DraggableProvidedDragHandleProps, DraggingStyle } from '@hello-pangea/dnd'; import { ItemId, Path, TreeItem, Any } from '../../types'; import { DraggableProvidedProps } from '.'; export type TreeDraggingStyle = DraggingStyle & { paddingLeft: number; transition: 'none' | string; }; export type DragActionType = null | 'mouse' | 'key' | 'touch'; export type RenderItemParams<TData = Any> = { item: TreeItem<TData>; depth: number; onExpand: (ItemId: ItemId) => void; onCollapse: (ItemId: ItemId) => void; provided: TreeDraggableProvided; snapshot: DraggableStateSnapshot; }; export type TreeDraggableProvided = { draggableProps: DraggableProvidedProps; dragHandleProps: DraggableProvidedDragHandleProps | null; innerRef: (el: HTMLElement | null) => void; }; export type Props = { item: TreeItem; path: Path; onExpand: (ItemId: ItemId, path: Path) => void; onCollapse: (ItemId: ItemId, path: Path) => void; renderItem: (item: RenderItemParams) => ReactNode; provided: DraggableProvided; snapshot: DraggableStateSnapshot; itemRef: (ItemId: ItemId, element: HTMLElement | null) => void; offsetPerLevel: number; style?: React.CSSProperties; };