"use client"; import type { DragEvent, MouseEvent } from "react"; import { FileTree } from "@/components/sidebar/file-tree"; import { PrivateTree } from "@/components/sidebar/private-tree"; import type { SidebarTreeNode } from "@/lib/kernel-sidebar"; import type { FileTreeRow } from "@/lib/file-tree/types"; import type { PageTreeProjectionItem } from "@/lib/tree-projection"; import { cn } from "@/lib/utils"; type SidebarPageTreeSurfaceProps = { mode: "page"; rows: PageTreeProjectionItem[]; expanded: Set; activeId: string; className?: string; onToggleExpand: (id: string) => void; onMove: (nodeId: string, parentId: string | null, index: number) => void; onCreateChild: (parentId: string | null) => void; onContextMenu: (event: MouseEvent, node: SidebarTreeNode) => void; }; type SidebarFileTreeSurfaceProps = { mode: "filetree"; rows: FileTreeRow[]; activeId: string; selectedRowIds: Set; className?: string; onRowClick: (row: FileTreeRow, event: MouseEvent) => void; onRowDoubleClick: (row: FileTreeRow, event: MouseEvent) => void; onRowContextMenu: (row: FileTreeRow, event: MouseEvent) => void; onRowDragStart?: (row: FileTreeRow, event: DragEvent) => void; onToggleExpand: (docId: string) => void; onToggleAssetFolderExpand?: (assetId: string) => void; onCreateChild: (parentId: string | null) => void; onBlankMouseDown?: (event: MouseEvent) => void; onDropFiles?: (docId: string, files: FileList, targetRow?: FileTreeRow) => void; onInternalDrop?: (args: { targetRow: FileTreeRow; rowIds: string[]; copy: boolean }) => void; }; export type SidebarTreeSurfaceProps = | SidebarPageTreeSurfaceProps | SidebarFileTreeSurfaceProps; export type TreePickerSurfaceItem = | { kind: "root"; id: null; title: string; subtitle?: string } | { kind: "doc"; id: string; title: string; subtitle?: string; depth?: number }; type TreePickerSurfaceProps = { items: TreePickerSurfaceItem[]; highlighted: number; className?: string; emptyText?: string; onHighlight: (index: number) => void; onPick: (targetId: string | null) => void; }; export function SidebarTreeSurface(props: SidebarTreeSurfaceProps) { const surfaceTestId = props.mode === "page" ? "sidebar-page-tree-shell" : "sidebar-file-tree-shell"; return (
{props.mode === "page" ? ( ) : ( )}
); } export function TreePickerSurface({ items, highlighted, className, emptyText = "没有匹配结果", onHighlight, onPick, }: TreePickerSurfaceProps) { if (items.length === 0) { return
{emptyText}
; } return (
{items.map((item, index) => { const isRoot = item.kind === "root"; return ( ); })}
); }