2016-08-31 15:00:13 +08:00
|
|
|
import * as React from 'react';
|
2016-04-07 15:02:22 +08:00
|
|
|
import Tooltip from '../tooltip';
|
2016-03-09 17:23:10 +08:00
|
|
|
import getPlacements from './placements';
|
2016-04-01 14:28:35 +08:00
|
|
|
import warning from 'warning';
|
2016-08-31 15:00:13 +08:00
|
|
|
const placements = getPlacements();
|
2016-03-20 20:41:34 +08:00
|
|
|
export default class Popover extends React.Component {
|
2016-08-31 15:00:13 +08:00
|
|
|
render() {
|
|
|
|
return (<Tooltip transitionName={this.props.transitionName} builtinPlacements={placements} ref="tooltip" {...this.props} overlay={this.getOverlay()}>
|
|
|
|
{this.props.children}
|
|
|
|
</Tooltip>);
|
|
|
|
}
|
|
|
|
getPopupDomNode() {
|
|
|
|
return this.refs.tooltip.getPopupDomNode();
|
|
|
|
}
|
|
|
|
componentDidMount() {
|
|
|
|
if ('overlay' in this.props) {
|
|
|
|
warning(false, '`overlay` prop of Popover is deprecated, use `content` instead.');
|
|
|
|
}
|
2016-04-01 14:28:35 +08:00
|
|
|
}
|
2016-08-31 15:00:13 +08:00
|
|
|
getOverlay() {
|
|
|
|
// use content replace overlay
|
|
|
|
// keep overlay for compatibility
|
|
|
|
const { title, prefixCls, overlay, content } = this.props;
|
|
|
|
return (<div>
|
2016-04-01 01:36:42 +08:00
|
|
|
{title && <div className={`${prefixCls}-title`}>{title}</div>}
|
2016-03-17 15:10:49 +08:00
|
|
|
<div className={`${prefixCls}-inner-content`}>
|
2016-04-01 14:28:35 +08:00
|
|
|
{content || overlay}
|
2016-01-07 14:21:29 +08:00
|
|
|
</div>
|
2016-08-31 15:00:13 +08:00
|
|
|
</div>);
|
|
|
|
}
|
2016-03-20 20:41:34 +08:00
|
|
|
}
|
2016-08-31 15:00:13 +08:00
|
|
|
Popover.defaultProps = {
|
|
|
|
prefixCls: 'ant-popover',
|
|
|
|
placement: 'top',
|
|
|
|
transitionName: 'zoom-big',
|
|
|
|
trigger: 'hover',
|
|
|
|
mouseEnterDelay: 0.1,
|
|
|
|
mouseLeaveDelay: 0.1,
|
|
|
|
overlayStyle: {},
|
|
|
|
};
|