2020-11-01 07:03:33 +00:00
|
|
|
import { defineComponent, inject } from 'vue';
|
2019-01-12 03:33:27 +00:00
|
|
|
import Tooltip from '../tooltip';
|
|
|
|
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-06-14 13:41:29 +00:00
|
|
|
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
|
2020-09-30 02:47:18 +00:00
|
|
|
import { defaultConfigProvider } from '../config-provider';
|
2020-11-01 07:03:33 +00:00
|
|
|
import { withInstall } from '../_util/type';
|
2018-03-19 02:16:27 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const props = abstractTooltipProps();
|
2020-10-20 01:57:09 +00:00
|
|
|
const Popover = defineComponent({
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'APopover',
|
2018-01-12 08:10:41 +00:00
|
|
|
props: {
|
2018-01-15 10:54:26 +00:00
|
|
|
...props,
|
2019-09-11 14:33:36 +00:00
|
|
|
prefixCls: PropTypes.string,
|
2018-01-12 08:10:41 +00:00
|
|
|
transitionName: PropTypes.string.def('zoom-big'),
|
|
|
|
content: PropTypes.any,
|
|
|
|
title: PropTypes.any,
|
|
|
|
},
|
2020-06-14 13:41:29 +00:00
|
|
|
setup() {
|
|
|
|
return {
|
2020-09-30 02:47:18 +00:00
|
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
2020-06-14 13:41:29 +00:00
|
|
|
};
|
2019-04-10 01:23:53 +00:00
|
|
|
},
|
2018-01-12 08:10:41 +00:00
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
getPopupDomNode() {
|
2020-10-20 01:57:09 +00:00
|
|
|
return (this.$refs.tooltip as any).getPopupDomNode();
|
2018-01-12 08:10:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-02-01 09:23:00 +00:00
|
|
|
render() {
|
2019-04-10 01:23:53 +00:00
|
|
|
const { title, prefixCls: customizePrefixCls, $slots } = this;
|
2020-10-20 01:57:09 +00:00
|
|
|
const { getPrefixCls } = this.configProvider;
|
2019-04-10 01:23:53 +00:00
|
|
|
const prefixCls = getPrefixCls('popover', customizePrefixCls);
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const props = getOptionProps(this);
|
|
|
|
delete props.title;
|
|
|
|
delete props.content;
|
2018-01-12 08:10:41 +00:00
|
|
|
const tooltipProps = {
|
2020-06-14 13:41:29 +00:00
|
|
|
...props,
|
|
|
|
prefixCls,
|
2018-01-12 08:10:41 +00:00
|
|
|
ref: 'tooltip',
|
2020-06-14 13:41:29 +00:00
|
|
|
title: (
|
|
|
|
<div>
|
|
|
|
{(title || $slots.title) && (
|
|
|
|
<div class={`${prefixCls}-title`}>{getComponent(this, 'title')}</div>
|
|
|
|
)}
|
|
|
|
<div class={`${prefixCls}-inner-content`}>{getComponent(this, 'content')}</div>
|
|
|
|
</div>
|
|
|
|
),
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2020-06-14 13:41:29 +00:00
|
|
|
return <Tooltip {...tooltipProps}>{getSlot(this)}</Tooltip>;
|
2018-01-12 08:10:41 +00:00
|
|
|
},
|
2020-10-20 01:57:09 +00:00
|
|
|
});
|
2018-01-12 08:10:41 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
export default withInstall(Popover);
|