import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import Dialog from"rc-dialog";import*as PropTypes from"prop-types";import addEventListener from"rc-util/es/Dom/addEventListener";import Button from"../button";import LocaleReceiver from"../locale-provider/LocaleReceiver";import{getConfirmLocale}from"./locale";var mousePosition=void 0,mousePositionEventBinded=void 0,Modal=function(e){function o(){_classCallCheck(this,o);var e=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).apply(this,arguments));return e.handleCancel=function(o){var t=e.props.onCancel;t&&t(o)},e.handleOk=function(o){var t=e.props.onOk;t&&t(o)},e.renderFooter=function(o){var t=e.props,r=t.okText,n=t.okType,i=t.cancelText,s=t.confirmLoading;return React.createElement("div",null,React.createElement(Button,{type:"secondary",onClick:e.handleCancel},i||o.cancelText),React.createElement(Button,{type:n,loading:s,onClick:e.handleOk},r||o.okText))},e}return _inherits(o,e),_createClass(o,[{key:"componentDidMount",value:function(){mousePositionEventBinded||(addEventListener(document.documentElement,"click",function(e){mousePosition={x:e.pageX,y:e.pageY},setTimeout(function(){return mousePosition=null},100)}),mousePositionEventBinded=!0)}},{key:"render",value:function(){var e=this.props,o=e.footer,t=e.visible,r=React.createElement(LocaleReceiver,{componentName:"Modal",defaultLocale:getConfirmLocale()},this.renderFooter);return React.createElement(Dialog,_extends({},this.props,{footer:void 0===o?r:o,visible:t,mousePosition:mousePosition,onClose:this.handleCancel}))}}]),o}(React.Component);export default Modal;Modal.defaultProps={prefixCls:"dt-modal",width:550,transitionName:"zoom",maskTransitionName:"fade",confirmLoading:!1,visible:!1,okType:"primary"},Modal.propTypes={prefixCls:PropTypes.string,onOk:PropTypes.func,onCancel:PropTypes.func,okText:PropTypes.node,cancelText:PropTypes.node,width:PropTypes.oneOfType([PropTypes.number,PropTypes.string]),confirmLoading:PropTypes.bool,visible:PropTypes.bool,align:PropTypes.object,footer:PropTypes.node,title:PropTypes.node,closable:PropTypes.bool};