2015-06-19 12:29:22 +08:00
|
|
|
import React from 'react';
|
|
|
|
import Tooltip from 'rc-tooltip';
|
2015-09-28 21:02:04 +08:00
|
|
|
|
2015-06-19 12:29:22 +08:00
|
|
|
const prefixCls = 'ant-popover';
|
2015-06-17 16:58:13 +08:00
|
|
|
|
2015-09-28 21:02:04 +08:00
|
|
|
const Popover = React.createClass({
|
2015-06-17 17:15:34 +08:00
|
|
|
getDefaultProps() {
|
2015-06-17 16:58:13 +08:00
|
|
|
return {
|
2015-09-24 18:38:31 +08:00
|
|
|
prefixCls: prefixCls,
|
2015-06-17 16:58:13 +08:00
|
|
|
placement: 'top',
|
2015-08-19 20:16:20 +08:00
|
|
|
trigger: 'hover',
|
2015-09-24 18:38:31 +08:00
|
|
|
mouseEnterDelay: 0.1,
|
|
|
|
mouseLeaveDelay: 0.1,
|
2015-08-19 20:16:20 +08:00
|
|
|
overlayStyle: {}
|
2015-06-17 16:58:13 +08:00
|
|
|
};
|
|
|
|
},
|
2015-06-17 17:10:10 +08:00
|
|
|
|
2015-09-28 21:02:04 +08:00
|
|
|
render() {
|
2015-06-19 12:29:22 +08:00
|
|
|
const transitionName = ({
|
2015-06-17 17:10:10 +08:00
|
|
|
top: 'zoom-down',
|
|
|
|
bottom: 'zoom-up',
|
|
|
|
left: 'zoom-right',
|
2015-09-28 21:02:04 +08:00
|
|
|
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',
|
2015-06-17 17:10:10 +08:00
|
|
|
})[this.props.placement];
|
|
|
|
|
2015-06-17 16:58:13 +08:00
|
|
|
return (
|
2015-09-24 18:38:31 +08:00
|
|
|
<Tooltip transitionName={transitionName}
|
2015-11-04 17:15:33 +08:00
|
|
|
ref="tooltip"
|
2015-09-28 21:02:04 +08:00
|
|
|
{...this.props}
|
|
|
|
overlay={this.getOverlay()}>
|
2015-06-17 16:58:13 +08:00
|
|
|
{this.props.children}
|
|
|
|
</Tooltip>
|
|
|
|
);
|
2015-09-28 21:02:04 +08:00
|
|
|
},
|
|
|
|
|
2015-11-04 17:15:33 +08:00
|
|
|
getPopupDomNode() {
|
|
|
|
return this.refs.tooltip.refs.trigger.popupDomNode;
|
|
|
|
},
|
|
|
|
|
2015-09-28 21:02:04 +08:00
|
|
|
getOverlay() {
|
|
|
|
return <div>
|
|
|
|
<div className={prefixCls + '-title'}>
|
|
|
|
{this.props.title}
|
|
|
|
</div>
|
|
|
|
<div className={prefixCls + '-content'}>
|
|
|
|
{this.props.overlay}
|
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
},
|
2015-06-17 16:58:13 +08:00
|
|
|
});
|
2015-09-28 21:02:04 +08:00
|
|
|
|
|
|
|
export default Popover;
|