mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-24 07:28:28 +08:00
674255bd14
* upgrade deps * autofix some tslint problems * Fix tslint problems manually
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import assign from 'object-assign';
|
|
import Tooltip from '../tooltip';
|
|
import { AbstractTooltipProps } from '../tooltip';
|
|
import warning from '../_util/warning';
|
|
|
|
export interface PopoverProps extends AbstractTooltipProps {
|
|
title?: React.ReactNode;
|
|
content?: React.ReactNode;
|
|
}
|
|
|
|
export default class Popover extends React.Component<PopoverProps, any> {
|
|
static defaultProps = {
|
|
prefixCls: 'ant-popover',
|
|
placement: 'top',
|
|
transitionName: 'zoom-big',
|
|
trigger: 'hover',
|
|
mouseEnterDelay: 0.1,
|
|
mouseLeaveDelay: 0.1,
|
|
overlayStyle: {},
|
|
};
|
|
|
|
refs: {
|
|
tooltip: Tooltip,
|
|
};
|
|
|
|
getPopupDomNode() {
|
|
return this.refs.tooltip.getPopupDomNode();
|
|
}
|
|
|
|
getOverlay() {
|
|
const { title, prefixCls, content } = this.props;
|
|
warning(
|
|
!('overlay' in this.props),
|
|
'Popover[overlay] is removed, please use Popover[content] instead, ' +
|
|
'see: http://u.ant.design/popover-content',
|
|
);
|
|
return (
|
|
<div>
|
|
{title && <div className={`${prefixCls}-title`}>{title}</div>}
|
|
<div className={`${prefixCls}-inner-content`}>
|
|
{content}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
render() {
|
|
const props = assign({}, this.props);
|
|
delete props.title;
|
|
return (
|
|
<Tooltip
|
|
{...props}
|
|
ref="tooltip"
|
|
overlay={this.getOverlay()}
|
|
/>
|
|
);
|
|
}
|
|
}
|