ts popover (#2542)

This commit is contained in:
ddcat1115 2016-07-29 14:45:06 +08:00 committed by 偏右
parent 10a0709b3a
commit 89efcb903a
3 changed files with 42 additions and 3 deletions

View File

@ -34,6 +34,9 @@ export { Cascader };
import Popconfirm from './popconfirm';
export { Popconfirm };
import Popover from './popover';
export { Popover };
import Transfer from './transfer';
export { Transfer };

View File

@ -5,7 +5,37 @@ import warning from 'warning';
const placements = getPlacements();
export default class Popover extends React.Component {
export interface PopoverProps {
/** trigger type, options: `hover` `focus` `click` */
trigger?: 'hover' | 'focus' | 'click';
/** Position of popup-container,
* options: `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight`
* `leftTop` `leftBottom` `rightTop` `rightBottom`
*/
placement?: 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' |
'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
/** title of popup-container */
title?: React.ReactNode;
/** classname of popup-container */
overlayClassName?: string;
/** Style of overlay */
overlayStyle?: React.CSSProperties;
prefixCls?: string;
/** to control visibility of popup-container */
visible?: boolean;
/** callback when visible change */
onVisibleChange?: (visible: boolean) => void;
/** specify wrapper of popup-container */
getTooltipContainer?: (triggerNode: React.ReactNode) => React.ReactNode;
/** content of popup-container */
content?: React.ReactNode;
/** keep overlay for compatibility */
overlay?: React.ReactNode;
style?: React.CSSProperties;
transitionName?: string;
}
export default class Popover extends React.Component<PopoverProps, any> {
static defaultProps = {
prefixCls: 'ant-popover',
placement: 'top',
@ -30,7 +60,7 @@ export default class Popover extends React.Component {
}
getPopupDomNode() {
return this.refs.tooltip.getPopupDomNode();
return (this.refs as any).tooltip.getPopupDomNode();
}
componentDidMount() {

View File

@ -5,7 +5,13 @@ const autoAdjustOverflow = {
const targetOffset = [0, 0];
export default function getPlacements(config = {}) {
export interface GetPlacementsProps {
arrowWidth?: number;
horizontalArrowShift?: number;
verticalArrowShift?: number;
}
export default function getPlacements(config: GetPlacementsProps = {}) {
const { arrowWidth = 5, horizontalArrowShift = 16, verticalArrowShift = 12 } = config;
return {
left: {