import * as React from 'react'; import CloseOutlined from '@ant-design/icons/CloseOutlined'; import type { DrawerProps as RCDrawerProps } from 'rc-drawer'; import classNames from 'classnames'; export interface DrawerPanelProps { prefixCls: string; title?: React.ReactNode; footer?: React.ReactNode; extra?: React.ReactNode; closable?: boolean; closeIcon?: React.ReactNode; onClose?: RCDrawerProps['onClose']; /** Wrapper dom node style of header and body */ drawerStyle?: React.CSSProperties; headerStyle?: React.CSSProperties; bodyStyle?: React.CSSProperties; footerStyle?: React.CSSProperties; children?: React.ReactNode; } export default function DrawerPanel(props: DrawerPanelProps) { const { prefixCls, title, footer, extra, closable = true, closeIcon = , onClose, headerStyle, drawerStyle, bodyStyle, footerStyle, children, } = props; const closeIconNode = closable && ( ); function renderHeader() { if (!title && !closable) { return null; } return (
{closeIconNode} {title &&
{title}
}
{extra &&
{extra}
}
); } function renderFooter() { if (!footer) { return null; } const footerClassName = `${prefixCls}-footer`; return (
{footer}
); } return (
{renderHeader()}
{children}
{renderFooter()}
); }