/** * Types for FileTree. * * @module @mks2508/mks-ui/react/ui/FileTree */ import type { VariantProps } from 'class-variance-authority'; import type { SlotOverrides } from '../../../core/types'; import type { FileIconResolver } from '../FileIcon/FileIcon.types'; import type { FileItemChangeStatus } from '../FileItem/FileItem.types'; import type { FileTreeSlot, fileTreeVariants } from './FileTree.styles'; /** What kind of filesystem entry a tree node represents. */ export type FileTreeNodeKind = 'file' | 'dir'; /** * A single node in a file tree. * * Nodes are identified by `id` (typically the relative path). Directories * may have `children` eagerly populated, or `null`/`undefined` to indicate * unloaded children that will be fetched lazily via `onToggle`. */ export interface IFileTreeNode { /** Stable identifier — usually the relpath. */ id: string; /** Display name (usually basename). */ name: string; /** Full path relative to root (shown in `FileItem`). */ path: string; /** File or directory. */ kind: FileTreeNodeKind; /** Last-modified timestamp (rendered as trailing chip on the row). */ modifiedAt?: Date; /** Whether this node is boosted (⭐ on the row). */ isBoosted?: boolean; /** Optional git change status — proxied to the underlying `FileItem`. */ changeStatus?: FileItemChangeStatus | null; /** * Children for directories. * - `undefined` → unloaded (will request on expand) * - `[]` → loaded, empty * - `IFileTreeNode[]` → loaded with entries */ children?: IFileTreeNode[]; } /** Visual density, proxied to `FileItem`. */ export type FileTreeDensity = NonNullable['density']>; /** * Props for FileTree. * * @see {@link FileTreeSlot} */ export interface IFileTreeProps extends Omit, 'density'> { /** Root nodes to render. */ nodes: IFileTreeNode[]; /** Fired when a file row is activated (Enter / click on file). */ onSelect?: (node: IFileTreeNode) => void; /** * Fired when a directory is expanded or collapsed. * * Called with the node and the next-expanded state. Useful for lazy-loading * children — consumers can fetch children and push them into `nodes`. */ onToggle?: (node: IFileTreeNode, expanded: boolean) => void; /** * Controlled expanded-ids. If provided, the tree is controlled and * `onToggle` is expected to update this set upstream. * If omitted, the tree manages its own expand state internally. */ expandedIds?: ReadonlySet | readonly string[]; /** Controlled selected id. Highlights the matching row. */ selectedId?: string; /** Row density (proxied to `FileItem`). Default `"compact"`. */ density?: FileTreeDensity; /** Icon base path passed to inner `FileItem` rows. */ iconBasePath?: string; /** Custom file-icon resolver passed to inner `FileItem` rows. */ iconResolve?: FileIconResolver; /** Indent width in px per depth level. Default `12`. */ indentPx?: number; /** Empty-state text shown when `nodes` is empty. Default `"No files"`. */ emptyLabel?: string; /** Optional CSS class merged onto the root. */ className?: string; /** * Override default Tailwind classes for specific visual regions. * * @example * ```tsx * * ``` */ slots?: SlotOverrides; } //# sourceMappingURL=FileTree.types.d.ts.map