import type { ReactNode, ReactElement } from 'react'; export type DragPosition = 'before' | 'after' | 'inside' | null; /** * Tree item structure * * Defines a hierarchical data structure where each item can have children, * supporting metadata needed for visual representation, state management, * and user interactions across the tree component */ export interface TreeViewItem { id: string; name: string; type: string; children?: TreeViewItem[]; checked?: boolean | 'indeterminate'; disabled?: boolean; /** * Whether this item is currently active (e.g., currently being viewed) */ isActive?: boolean; /** * URL to navigate to when the item is clicked */ href?: string; /** * Called when the item is clicked */ onSelect?: (item: TreeViewItem) => void; } /** * Icon mapping for different tree node types * * Allows for customized visual representation of different node types, * enhancing usability by providing visual cues about node content and purpose */ export interface TreeViewIconMap { file: ReactElement; folder: ReactElement; [key: string]: ReactElement; } /** * Menu item definition for context menus * * Defines items that appear in the context menu when right-clicking on tree nodes */ export interface TreeViewMenuItem { id: string; label: string; icon?: ReactNode; action: (items: TreeViewItem[]) => void; } /** * Props for the TreeView component * * Provides configuration options for the entire tree, enabling flexible usage * across different contexts while maintaining consistent behavior patterns */ export interface TreeViewProps { className?: string; /** * Data to display in the tree */ data: TreeViewItem[]; /** * Whether to show expand/collapse all buttons */ showExpandAll?: boolean; /** * Whether to show checkboxes for item selection * Enables multi-selection and hierarchical selection patterns */ showCheckboxes?: boolean; /** * Whether to show the search input * When false, search can still be performed via externalSearchQuery */ showSearch?: boolean; /** * External search query to filter the tree * Can be used when showSearch is false to control filtering from outside */ externalSearchQuery?: string; /** * Placeholder text for the search input */ searchPlaceholder?: string; /** * Text displayed next to selection count (e.g., "3 selected") */ selectionText?: string; /** * Labels for the check/uncheck all buttons */ checkboxLabels?: { check: string; uncheck: string; }; /** * Called when checkbox state changes * Provides granular control for handling checkbox interactions * Can receive indeterminate state for partial selections */ onCheckChange?: (item: TreeViewItem | TreeViewItem[], checked: boolean | 'indeterminate') => void; /** * Icon mapping for different node types */ iconMap?: TreeViewIconMap; /** * Menu items for the context menu */ menuItems?: TreeViewMenuItem[]; /** * Called when an item is moved via drag and drop * Enables parent components to update their data structure after drag-and-drop */ onItemMove?: (sourceId: string, targetId: string, position: 'before' | 'after' | 'inside') => void; /** * Whether to enable drag and drop functionality * Enables user-driven reorganization of the tree structure */ enableDragDrop?: boolean; /** * Content to render in the end slot of each tree node * This allows for custom actions, icons, or information display */ endSlot?: ReactNode | ((item: TreeViewItem) => ReactNode); /** * Called when the end slot content is clicked * Can be used for actions on specific tree nodes */ onEndSlotClick?: (item: TreeViewItem) => void; /** * Called when an item is clicked * This is a convenience prop that sets onSelect for all items */ onItemClick?: (item: TreeViewItem) => void; } /** * Props for individual tree nodes * * Extensive prop interface allows for fine-grained control of individual node appearance * and behavior, enabling components higher in the tree to manage complex interactions */ export interface TreeNodeProps { item: TreeViewItem; depth: number; selectedIds: Set; expandedIds: Set; /** * Called when a folder is toggled between expanded/collapsed states */ onToggleExpand: (id: string) => void; /** * Called when checkbox state changes */ onCheck?: (item: TreeViewItem, checked: boolean | 'indeterminate') => void; /** * Called when an item is selected (for internal use) */ onSelect?: (id: string, event: React.MouseEvent) => void; iconMap: TreeViewIconMap; itemMap: Map; menuItems?: TreeViewMenuItem[]; getSelectedItems: () => TreeViewItem[]; /** * Drag and drop event handlers */ onDragStart?: (id: string) => void; onDragOver?: (id: string, position: 'before' | 'after' | 'inside') => void; onDragEnd?: () => void; onDrop?: (targetId: string, position: 'before' | 'after' | 'inside') => void; draggedItem?: string | null; dragOverItem?: string | null; dragPosition?: DragPosition; enableDragDrop?: boolean; /** * Content to render in the end slot of each tree node */ endSlot?: ReactNode | ((item: TreeViewItem) => ReactNode); /** * Called when the end slot content is clicked */ onEndSlotClick?: (item: TreeViewItem) => void; /** * Called when an item is clicked * This is a convenience prop that sets onSelect for all items */ onItemClick?: (item: TreeViewItem) => void; } //# sourceMappingURL=types.d.ts.map