import CloseOutlined from '@ant-design/icons/CloseOutlined'; import classNames from 'classnames'; import type { DrawerProps as RCDrawerProps } from 'rc-drawer'; import * as React from 'react'; 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; } const DrawerPanel: React.FC = (props) => { const { prefixCls, title, footer, extra, closable = true, closeIcon = , onClose, headerStyle, drawerStyle, bodyStyle, footerStyle, children, } = props; const closeIconNode = closable && ( ); const headerNode = React.useMemo(() => { if (!title && !closable) { return null; } return (
{closeIconNode} {title &&
{title}
}
{extra &&
{extra}
}
); }, [closable, closeIconNode, extra, headerStyle, prefixCls, title]); const footerNode = React.useMemo(() => { if (!footer) { return null; } const footerClassName = `${prefixCls}-footer`; return (
{footer}
); }, [footer, footerStyle, prefixCls]); return (
{headerNode}
{children}
{footerNode}
); }; export default DrawerPanel;