import React from 'react'; import cx from 'classnames'; import Button, { ButtonProps } from '../button/index'; import { IconX } from '../icon/index'; import bem from '../utils/bem'; const b = bem('rdf-dialog'); type DialogButtonType = 'default' | 'primary' | 'success' | 'warning' | 'error'; export interface DialogContentProps { header?: React.ReactNode; footer?: React.ReactNode; okType?: DialogButtonType; cancelType?: DialogButtonType; okText?: React.ReactNode; cancelText?: React.ReactNode; okProps?: ButtonProps; cancelProps?: ButtonProps; onOk?: () => void; onCancel?: () => void; onClose?: () => void; className?: string; style?: React.CSSProperties; } const DialogContent: React.FC = props => { const { okType, okText, okProps, cancelType, cancelText, cancelProps, onOk, onCancel, onClose, style, className, children, } = props; let { header, footer } = props; const actions: React.ReactNode[] = []; // render header if (['string', 'number'].includes(typeof header)) { header =
{header}
; } // render footer if (!footer) { if (onCancel) { actions.push( ); } if (onOk) { actions.push( ); } if (actions.length) { footer =
{actions}
; } } return (
{header}
{children}
{footer}
); }; DialogContent.defaultProps = { okType: 'primary', okText: '确认', cancelType: 'default', cancelText: '取消', }; export default DialogContent;