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";var __rest=this&&this.__rest||function(e,t){var o={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&(o[i[r]]=e[i[r]])}return o};import*as React from"react";import Tooltip from"../tooltip";import Icon from"../icon";import Button from"../button";import LocaleReceiver from"../locale-provider/LocaleReceiver";import defaultLocale from"../locale-provider/default";var Popconfirm=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.onConfirm=function(e){o.setVisible(!1);var t=o.props.onConfirm;t&&t.call(o,e)},o.onCancel=function(e){o.setVisible(!1);var t=o.props.onCancel;t&&t.call(o,e)},o.onVisibleChange=function(e){o.setVisible(e)},o.saveTooltip=function(e){o.tooltip=e},o.renderOverlay=function(e){var t=o.props,i=t.prefixCls,r=t.title,n=t.cancelText,l=t.okText,a=t.okType;return React.createElement("div",null,React.createElement("div",{className:i+"-inner-content-sm"},React.createElement("div",{className:i+"-message"},React.createElement(Icon,{type:"question-circle"}),React.createElement("div",{className:i+"-message-title"},r)),React.createElement("div",{className:i+"-buttons"},React.createElement(Button,{onClick:o.onCancel,size:"mini"},n||e.cancelText),React.createElement(Button,{onClick:o.onConfirm,type:a,size:"mini"},l||e.okText))))},o.state={visible:e.visible},o}return _inherits(t,e),_createClass(t,[{key:"componentWillReceiveProps",value:function(e){"visible"in e&&this.setState({visible:e.visible})}},{key:"getPopupDomNode",value:function(){return this.tooltip.getPopupDomNode()}},{key:"setVisible",value:function(e){var t=this.props;"visible"in t||this.setState({visible:e});var o=t.onVisibleChange;o&&o(e)}},{key:"render",value:function(){var e=this.props,t=e.prefixCls,o=e.placement,i=__rest(e,["prefixCls","placement"]),r=React.createElement(LocaleReceiver,{componentName:"Popconfirm",defaultLocale:defaultLocale.Popconfirm},this.renderOverlay);return React.createElement(Tooltip,_extends({},i,{prefixCls:t,placement:o,onVisibleChange:this.onVisibleChange,visible:this.state.visible,overlay:r,ref:this.saveTooltip}))}}]),t}(React.Component);export default Popconfirm;Popconfirm.defaultProps={prefixCls:"dt-popover",transitionName:"zoom-big",placement:"top",trigger:"click",okType:"primary"};