import * as Nerv from 'nervjs' import { CSSTransition } from 'react-transition-group' import Component from '@lib/component' interface AlertProps { type?: string message?: string description?: string closable?: boolean showIcon?: boolean icon?: string closeText?: string } interface AlertState { isShow: boolean isExited: boolean } class Alert extends Component { static defaultProps = { type: 'info', message: '', closable: false, showIcon: false, icon: 'info' } constructor (...args) { super(...args) this.state = { isShow: true, isExited: false } } onCloseHandle = () => { const { onClose } = this.props this.setState({ isShow: false }) if (onClose) { onClose() } } render () { const { closable, icon, type, description, showIcon, message, closeText } = this.props const { isShow, isExited } = this.state const classArr = { success: 'icon-check-circle', error: 'icon-x-circle', warning: 'icon-alert-circle', info: 'icon-info' } const iconClass = classArr[type as string] || (icon as string) return ( { this.setState({ isExited: true }) }}>
{showIcon ? : ''}
{message ?

{message}

: ''} {description ?

{description}

: ''}
{closeText}
) } } export default Alert