UNPKG

zarm-web

Version:
76 lines (69 loc) 1.67 kB
import React, { Component } from 'react'; import Modal from '../modal'; import Button from '../button'; import Icon from '../icon'; const Style = { hide: { display: 'none' } }; class Confirm extends Component { constructor(...args) { super(...args); this.ButtonRef = React.createRef(); this.onCancel = () => { if (this.props.onCancel) { this.props.onCancel(); } }; this.onOk = e => { if (this.props.onOk) { this.props.onOk(e); } }; this.onKeyPress = e => { if (e.keyCode === 13) { if (this.props.onOk) { this.props.onOk(e); } } }; } render() { const { prefixCls, message, okText, cancelText, width, visible, animationDuration } = this.props; return React.createElement(Modal, { width: width, visible: visible, animationDuration: animationDuration, onKeyPress: this.onKeyPress }, React.createElement(Modal.Header, { onClose: this.onCancel, style: Style.hide }), React.createElement(Modal.Body, null, React.createElement("div", { className: prefixCls }, React.createElement(Icon, { type: "question-round" }), React.createElement("span", null, message))), React.createElement(Modal.Footer, null, React.createElement(Button, { onClick: this.onCancel }, cancelText), React.createElement(Button, { theme: "primary", onClick: this.onOk }, okText))); } } Confirm.defaultProps = { prefixCls: 'ui-confirm', message: '', width: 270, okText: '确定', cancelText: '取消' }; export default Confirm;