You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
10 years ago
|
import React from 'react';
|
||
9 years ago
|
import Tooltip from '../tooltip';
|
||
9 years ago
|
import getPlacements from './placements';
|
||
9 years ago
|
import warning from 'warning';
|
||
9 years ago
|
|
||
9 years ago
|
const placements = getPlacements();
|
||
10 years ago
|
|
||
9 years ago
|
export default class Popover extends React.Component {
|
||
9 years ago
|
static defaultProps = {
|
||
9 years ago
|
prefixCls: 'ant-popover',
|
||
9 years ago
|
placement: 'top',
|
||
9 years ago
|
transitionName: 'zoom-big',
|
||
9 years ago
|
trigger: 'hover',
|
||
|
mouseEnterDelay: 0.1,
|
||
|
mouseLeaveDelay: 0.1,
|
||
9 years ago
|
overlayStyle: {},
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
render() {
|
||
10 years ago
|
return (
|
||
9 years ago
|
<Tooltip transitionName={this.props.transitionName}
|
||
9 years ago
|
builtinPlacements={placements}
|
||
9 years ago
|
ref="tooltip"
|
||
|
{...this.props}
|
||
9 years ago
|
overlay={this.getOverlay()}
|
||
|
>
|
||
10 years ago
|
{this.props.children}
|
||
|
</Tooltip>
|
||
|
);
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
9 years ago
|
getPopupDomNode() {
|
||
9 years ago
|
return this.refs.tooltip.getPopupDomNode();
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
9 years ago
|
componentDidMount() {
|
||
|
if ('overlay' in this.props) {
|
||
9 years ago
|
warning(false, '`overlay` prop of Popover is deprecated, use `content` instead.');
|
||
9 years ago
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
getOverlay() {
|
||
9 years ago
|
// use content replace overlay
|
||
|
// keep overlay for compatibility
|
||
|
const { title, prefixCls, overlay, content } = this.props;
|
||
|
|
||
9 years ago
|
return (
|
||
|
<div>
|
||
9 years ago
|
{title && <div className={`${prefixCls}-title`}>{title}</div>}
|
||
9 years ago
|
<div className={`${prefixCls}-inner-content`}>
|
||
9 years ago
|
{content || overlay}
|
||
9 years ago
|
</div>
|
||
9 years ago
|
</div>
|
||
9 years ago
|
);
|
||
9 years ago
|
}
|
||
|
}
|