ant-design/components/popover/index.jsx
afc163 977e2e32fc Add arrowPointAtCenter to Tooltip Popover Popconfirm
修正默认对齐方式为边缘对齐,增加属性用于箭头指向中心的行为
2016-08-31 13:54:16 +08:00

54 lines
1.2 KiB
JavaScript

import React from 'react';
import Tooltip from '../tooltip';
import getPlacements from './placements';
import warning from 'warning';
export default class Popover extends React.Component {
static defaultProps = {
prefixCls: 'ant-popover',
placement: 'top',
transitionName: 'zoom-big',
trigger: 'hover',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
arrowPointAtCenter: false,
}
render() {
const { arrowPointAtCenter } = this.props;
return (
<Tooltip
builtinPlacements={getPlacements({ arrowPointAtCenter })}
ref="tooltip"
{...this.props}
overlay={this.getOverlay()}
/>
);
}
getPopupDomNode() {
return this.refs.tooltip.getPopupDomNode();
}
componentDidMount() {
if ('overlay' in this.props) {
warning(false, '`overlay` prop of Popover is deprecated, use `content` instead.');
}
}
getOverlay() {
// use content replace overlay
// keep overlay for compatibility
const { title, prefixCls, overlay, content } = this.props;
return (
<div>
{title && <div className={`${prefixCls}-title`}>{title}</div>}
<div className={`${prefixCls}-inner-content`}>
{content || overlay}
</div>
</div>
);
}
}