import React, { type ReactNode } from 'react'; import type { MarkdownEditorProps } from '../MarkdownEditor'; import type { BrowserItemInput } from './Browser'; import type { RealtimeFollowData } from './RealtimeFollow'; import type { TaskItem, TaskItemInput } from './Task'; export interface TabConfiguration { key?: string; icon?: ReactNode; title?: ReactNode; count?: number; } export interface TabItem { key: string; label: ReactNode; title?: ReactNode; icon?: ReactNode; content?: ReactNode; componentType?: string; } export interface WorkspaceProps { activeTabKey?: string; onTabChange?: (tabKey: string) => void; style?: React.CSSProperties; className?: string; title?: ReactNode; onClose?: () => void; children?: React.ReactNode; /** 纯净模式,关闭阴影和边框 */ pure?: boolean; } export interface BaseChildProps { tab?: TabConfiguration; } export interface RealtimeProps extends BaseChildProps { data?: RealtimeFollowData; } export interface BrowserProps extends BaseChildProps { data?: BrowserItemInput; } export interface TaskProps extends BaseChildProps { data?: TaskItemInput; /** 点击任务项时的回调 */ onItemClick?: (item: TaskItem) => void; } export declare enum FileCategory { Text = "text", Code = "code", Image = "image", Video = "video", Audio = "audio", PDF = "pdf", Word = "word", Excel = "excel", Archive = "archive", Other = "other" } export interface FileTypeDefinition { category: FileCategory; extensions: string[]; mimeTypes: string[]; name: string; } export declare const FILE_TYPES: Record; export type FileType = keyof typeof FILE_TYPES; export interface BaseNode { id?: string; name: string; icon?: ReactNode; } export interface FileNode extends BaseNode { displayType?: string; type?: FileType; size?: string | number; lastModified?: string | number | Date; url?: string; file?: File | Blob; previewUrl?: string; content?: string; metadata?: Record; canPreview?: boolean; canDownload?: boolean; /** 用户自定义是否可以分享(默认隐藏,设置为 true 显示) */ canShare?: boolean; /** 用户自定义是否可以定位(默认隐藏,设置为 true 显示) */ canLocate?: boolean; loading?: boolean; } export interface GroupNode extends BaseNode { collapsed?: boolean; children: FileNode[]; type: FileType; /** 用户自定义是否可以下载分组(默认显示,设置为 false 隐藏) */ canDownload?: boolean; } export interface FileActionRef { openPreview: (file: FileNode) => void; backToList: () => void; /** * 跨页更新预览标题区域的文件信息(仅影响标题展示,不改变实际预览内容) */ updatePreviewHeader?: (partial: Partial) => void; } export interface FileProps extends BaseChildProps { nodes: (GroupNode | FileNode)[]; onGroupDownload?: (files: FileNode[], groupType: FileType) => void; onDownload?: (file: FileNode) => void; onFileClick?: (file: FileNode) => void; onLocate?: (file: FileNode) => void; onToggleGroup?: (groupType: FileType, collapsed: boolean) => void; /** 重置标识,用于重置预览状态(内部使用) */ resetKey?: number; onPreview?: (file: FileNode) => void | false | FileNode | ReactNode | Promise; /** * 自定义预览页返回行为 * @description 返回 false 可阻止组件默认的返回列表行为 */ onBack?: (file: FileNode) => void | boolean | Promise; /** * 分享回调(文件列表与预览页均会调用) * @param file 当前文件 * @param ctx 上下文,包含 anchorEl(分享按钮元素)与来源 */ onShare?: (file: FileNode, ctx?: { anchorEl?: HTMLElement; origin: 'list' | 'preview'; }) => void; /** * MarkdownEditor 的配置项,用于自定义预览效果 * @description 这里的配置会覆盖默认的预览配置 */ markdownEditorProps?: Partial>; /** * 自定义预览页面右侧操作区域 * @description 可以是 ReactNode 或者根据文件返回 ReactNode 的函数 */ customActions?: React.ReactNode | ((file: FileNode) => React.ReactNode); /** * 对外暴露的操作引用,允许外部主动打开预览或返回列表 */ actionRef?: React.MutableRefObject; /** * @deprecated 请使用 isLoading 代替 * @description 已废弃,将在未来版本移除 */ loading?: boolean; /** * 是否显示加载状态 * @description 当为true时,显示加载动画,通常在文件列表数据加载过程中使用 */ isLoading?: boolean; /** * 自定义加载渲染函数 * @description 当isLoading为true时,如果提供了此函数则使用自定义渲染,否则使用默认的Spin组件 */ loadingRender?: () => React.ReactNode; /** * 自定义空状态渲染 * @description 当文件列表为空且非loading状态时,优先使用该渲染;未提供时使用默认的 Empty */ emptyRender?: React.ReactNode | (() => React.ReactNode); /** 搜索关键字(受控) */ keyword?: string; /** 搜索关键字变化回调(外部自行过滤) */ onChange?: (keyword: string) => void; /** 是否显示搜索框(默认不显示) */ showSearch?: boolean; /** 搜索框占位符 */ searchPlaceholder?: string; /** * 是否在文件项根元素上绑定 DOM id * @default false * @description 置为 false 时,不会向元素写入 id 属性(不影响 React key) */ bindDomId?: boolean; } export interface CustomProps extends BaseChildProps { children?: ReactNode; } export declare const getFileType: (filename: string) => FileType; export declare const getMimeType: (fileType: FileType) => string; export declare const getFileCategory: (fileType: FileType) => FileCategory;