mui-component
Version:
some custom mui components
66 lines (65 loc) • 2.42 kB
TypeScript
import { type ReactNode, type ComponentType } from "react";
import { type BoxProps } from "@mui/material";
import { type SpaceProps } from "@iimm/react-shared";
import { getFileInfo } from "../util";
import type { FileViewRenderProps } from "./FileViewRender";
import type { ModalProps } from "../../../feedback";
import type { PdfModalViewerProps } from "../../PdfModalViewer";
interface ObjectUrlItem {
url: string;
name?: string;
}
export type UrlItem = string | ObjectUrlItem;
export interface ItemBarProps {
extraAction?: ReactNode;
actionSpace?: SpaceProps;
file: UrlItem;
/** 文件类型svg图标的大小
* @default 24
*/
fileTypeIconSize?: number;
/** 显示文件类型图标 ?
* @default true
*/
showFileTypeIcon?: boolean;
/** 文件条目(每行)的外层Box的props */
itemBarBoxProps?: BoxProps;
/** 从url中获取文件名、文件类型、文件图标、是否可以直接预览、预览组件的函数 */
fileInfoParser?: typeof getFileInfo;
/** 传递给每行条目Box的className
* (默认拥有attachmentViewer-itemBar的className)
*/
itemBarClassName?: string;
/** 点击文件下载时的回调,可以用来传入消息条等
* (如果返回false则不会进行后续下载操作)
*/
onFileDownloadStart?: (file: UrlItem, fileName?: string) => void | boolean;
/** 点击文件下载后的回调 */
onFileDownload?: (file: UrlItem, fileName?: string) => void | Promise<void>;
/** 预览按钮Tooltip的title*/
previewTooltip?: ReactNode | ((fileUrl: string) => ReactNode);
/** 下载按钮Tooltip的title*/
downloadTooltip?: ReactNode | ((fileUrl: string) => ReactNode);
/** @default <PreviewOutlined /> */
previewIcon?: ReactNode;
/** @default <CloudDownloadOutlined /> */
downloadIcon?: ReactNode;
/** 显示下载?
* @default true
*/
showDownload?: boolean;
/** 显示预览?
* @default true
*/
showPreview?: boolean;
/** 文件名过长换行?
* @default false
*/
fileNameWrap?: boolean;
FilePreviewRender?: ComponentType<FileViewRenderProps>;
/** 点击预览按钮后的弹窗Modal的props */
previewModalProps?: ModalProps;
pdfViewerProps?: PdfModalViewerProps;
}
export declare const ItemBar: (props: ItemBarProps) => import("react/jsx-runtime").JSX.Element;
export {};