mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
ts popover (#2542)
This commit is contained in:
parent
10a0709b3a
commit
89efcb903a
@ -34,6 +34,9 @@ export { Cascader };
|
||||
import Popconfirm from './popconfirm';
|
||||
export { Popconfirm };
|
||||
|
||||
import Popover from './popover';
|
||||
export { Popover };
|
||||
|
||||
import Transfer from './transfer';
|
||||
export { Transfer };
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user