import React from 'react'; import Tooltip from 'rc-tooltip'; import Icon from '../icon'; import Button from '../button'; import getPlacements from '../popover/placements'; const placements = getPlacements(); const prefixCls = 'ant-popover'; const noop = function () {}; const transitionNames = { top: 'zoom-down', bottom: 'zoom-up', left: 'zoom-right', right: 'zoom-left', topLeft: 'zoom-down', bottomLeft: 'zoom-up', leftTop: 'zoom-right', rightTop: 'zoom-left', topRight: 'zoom-down', bottomRight: 'zoom-up', leftBottom: 'zoom-right', rightBottom: 'zoom-left', }; export default React.createClass({ getInitialState() { return { visible: false }; }, getDefaultProps() { return { transitionName: '', placement: 'top', trigger: 'click', overlayStyle: {}, onConfirm: noop, onCancel: noop, onVisibleChange() {}, }; }, contextTypes: { antLocale: React.PropTypes.object, }, componentWillReceiveProps(nextProps) { if ('visible' in nextProps) { this.setState({ visible: nextProps.visible }); } }, confirm() { this.setVisible(false); this.props.onConfirm.call(this); }, cancel() { this.setVisible(false); this.props.onCancel.call(this); }, onVisibleChange(visible) { this.setVisible(visible); }, setVisible(visible) { if (!('visible' in this.props)) { this.setState({ visible }); } this.props.onVisibleChange(visible); }, render() { const { title, placement, overlayStyle, trigger, ...restProps } = this.props; let { okText, cancelText } = this.props; if (this.context.antLocale && this.context.antLocale.Popconfirm) { okText = okText || this.context.antLocale.Popconfirm.okText; cancelText = cancelText || this.context.antLocale.Popconfirm.cancelText; } const overlay = (