import React, { ReactNode } from "react"; import classNames from "classnames"; import { BlankSteps } from "./BlankSteps"; import { MediaObject } from "../mediaobject"; import { StyledProps } from "../_type/StyledProps"; import { useConfig } from "../_util/config-context"; import { H4 } from "../heading"; import { warn } from "../_util/warn"; import { forwardRefWithStatics } from "../_util/forward-ref-with-statics"; export interface BlankTheme { image: { background: string; gif: string }; } export interface BlankProps extends StyledProps { /** * 预置主题 * * **\[Deprecated\]** 新版空白页已不包含预置主题,请使用 `image` 属性进行定制 * * @deprecated */ theme?: "error" | "open" | "arrears" | "permission" | BlankTheme; /** * 图片 URL * @since 2.4.0 */ image?: { background: string; logo: string }; /** * 标题 */ title?: React.ReactNode; /** * 描述 * * **\[Deprecated\]** 新版空白页已不包含描述区域 * * @deprecated */ description?: React.ReactNode; /** * 操作区 */ operation?: React.ReactNode; /** * 操作区下方内容 */ extra?: React.ReactNode; /** * 描述与操作区间内容 */ children?: React.ReactNode; /** * 底部区域内容 */ bottom?: React.ReactNode | React.ReactNode[]; } export const Blank = forwardRefWithStatics( function Blank( { theme, image, title, description, operation, extra, children, bottom, className, ...props }: BlankProps, ref: React.Ref ) { const { classPrefix } = useConfig(); if (!theme || image) { if (bottom && !Array.isArray(bottom)) { // eslint-disable-next-line no-param-reassign bottom = [bottom]; } return (
{image.logo && (
logo
)}

{title}

{children}
{operation} {extra &&
{extra}
}
{bottom && (
{(bottom as ReactNode[]).map((item, index) => (

{item}

))}
)}
); } warn("当前 Blank 组件包含将废弃的属性,请尽快升级至最新用法"); const { image: themeImage } = getCustomTheme(theme); return (
{themeImage.background && ( )} {themeImage.gif && }
} >

{description}

{children} {(operation || extra) && (
{operation} {extra &&
{extra}
}
)}
); }, { Steps: BlankSteps, } ); Blank.displayName = "Blank"; function getCustomTheme(theme: BlankProps["theme"]): BlankTheme { if (typeof theme === "string") { return { image: { background: null, gif: null } }; } return { image: {}, ...theme, }; }