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.
ant-design-vue/components/popover/index.jsx

60 lines
1.6 KiB

import { inject } from 'vue';
import Tooltip from '../tooltip';
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
import PropTypes from '../_util/vue-types';
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
const props = abstractTooltipProps();
const Popover = {
name: 'APopover',
7 years ago
props: {
7 years ago
...props,
prefixCls: PropTypes.string,
7 years ago
transitionName: PropTypes.string.def('zoom-big'),
content: PropTypes.any,
title: PropTypes.any,
},
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
7 years ago
methods: {
getPopupDomNode() {
return this.$refs.tooltip.getPopupDomNode();
7 years ago
},
},
render() {
const { title, prefixCls: customizePrefixCls, $slots } = this;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('popover', customizePrefixCls);
const props = getOptionProps(this);
delete props.title;
delete props.content;
7 years ago
const tooltipProps = {
...props,
prefixCls,
7 years ago
ref: 'tooltip',
title: (
<div>
{(title || $slots.title) && (
<div class={`${prefixCls}-title`}>{getComponent(this, 'title')}</div>
)}
<div class={`${prefixCls}-inner-content`}>{getComponent(this, 'content')}</div>
</div>
),
};
return <Tooltip {...tooltipProps}>{getSlot(this)}</Tooltip>;
7 years ago
},
};
7 years ago
/* istanbul ignore next */
Popover.install = function(app) {
app.component(Popover.name, Popover);
};
export default Popover;