2019-01-12 03:33:27 +00:00
|
|
|
import Tooltip from '../tooltip';
|
|
|
|
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-01-19 08:58:38 +00:00
|
|
|
import { getOptionProps, getComponentFromProp, getListeners } from '../_util/props-util';
|
2019-04-10 01:23:53 +00:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2019-08-28 02:50:19 +00:00
|
|
|
import Base from '../base';
|
2018-03-19 02:16:27 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const props = abstractTooltipProps();
|
2018-09-19 05:21:57 +00:00
|
|
|
const Popover = {
|
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,
|
|
|
|
},
|
|
|
|
model: {
|
|
|
|
prop: 'visible',
|
2018-06-26 02:17:30 +00:00
|
|
|
event: 'visibleChange',
|
2018-01-12 08:10:41 +00:00
|
|
|
},
|
2019-04-10 01:23:53 +00:00
|
|
|
inject: {
|
2019-09-11 14:33:36 +00:00
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
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() {
|
|
|
|
return this.$refs.tooltip.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;
|
2019-09-11 14:35:25 +00:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
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 = {
|
|
|
|
props: {
|
|
|
|
...props,
|
2019-04-10 01:23:53 +00:00
|
|
|
prefixCls,
|
2018-01-12 08:10:41 +00:00
|
|
|
},
|
|
|
|
ref: 'tooltip',
|
2020-01-19 08:58:38 +00:00
|
|
|
on: getListeners(this),
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-01-12 08:10:41 +00:00
|
|
|
return (
|
2019-01-12 03:33:27 +00:00
|
|
|
<Tooltip {...tooltipProps}>
|
|
|
|
<template slot="title">
|
2018-01-12 11:04:42 +00:00
|
|
|
<div>
|
2019-01-12 03:33:27 +00:00
|
|
|
{(title || $slots.title) && (
|
|
|
|
<div class={`${prefixCls}-title`}>{getComponentFromProp(this, 'title')}</div>
|
|
|
|
)}
|
|
|
|
<div class={`${prefixCls}-inner-content`}>{getComponentFromProp(this, 'content')}</div>
|
2018-01-12 11:04:42 +00:00
|
|
|
</div>
|
2018-01-12 08:10:41 +00:00
|
|
|
</template>
|
|
|
|
{this.$slots.default}
|
|
|
|
</Tooltip>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-01-12 08:10:41 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-01-12 08:10:41 +00:00
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
/* istanbul ignore next */
|
2019-01-12 03:33:27 +00:00
|
|
|
Popover.install = function(Vue) {
|
2019-08-28 02:50:19 +00:00
|
|
|
Vue.use(Base);
|
2019-01-12 03:33:27 +00:00
|
|
|
Vue.component(Popover.name, Popover);
|
|
|
|
};
|
2018-09-19 05:21:57 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
export default Popover;
|