import React, { forwardRef } from "react"; import classNames from "classnames"; import { InferProps, StyledProps } from "../_type"; import { createRocket } from "../_util/create-rocket"; import { Icon } from "../icon"; import { Justify } from "../justify"; import { useConfig } from "../_util/config-context"; export interface LayoutContentHeaderProps extends StyledProps { /** * 是否展示返回按钮 * * @default false */ showBackButton?: boolean; /** * 返回按钮点击回调 */ onBackButtonClick?: (event: React.MouseEvent) => void; /** * 标题 */ title?: React.ReactNode; /** * 小标题(说明文字) */ subtitle?: React.ReactNode; /** * 标题后区域内容 */ children?: React.ReactNode; /** * 操作区内容 */ operation?: React.ReactNode; } export const LayoutContentHeader = forwardRef(function LayoutContentHeader( { showBackButton, onBackButtonClick = () => null, title, subtitle, children, operation, className, ...props }: LayoutContentHeaderProps, ref: React.Ref ) { const { classPrefix } = useConfig(); return (
{showBackButton && ( )}

{title}

{children} {subtitle && ( {subtitle} )} } right={operation} />
); }); LayoutContentHeader.displayName = "LayoutContentHeader"; export interface LayoutContentBodyProps extends StyledProps { /** * 是否为全屏 * * @default false */ full?: boolean; /** * 内容 */ children?: React.ReactNode; } export const LayoutContentBody = forwardRef(function LayoutContentBody( { full, children, className, ...props }: LayoutContentBodyProps, ref: React.Ref ) { const { classPrefix } = useConfig(); return (
{children}
); }); LayoutContentBody.displayName = "LayoutContentBody"; const LayoutContentFooter = createRocket( "LayoutContentFooter", "div.@{prefix}-layout__content-footer" ); export const LayoutContent = Object.assign( createRocket( "LayoutContent", "main.@{prefix}-layout__content", "div.@{prefix}-layout__content-inner" ), { Header: LayoutContentHeader, Body: LayoutContentBody, Footer: LayoutContentFooter, } ); export interface LayoutContentProps extends InferProps {}