ant-design-vue/components/popover/index.jsx

67 lines
1.5 KiB
Vue
Raw Normal View History

2018-03-19 02:16:27 +00:00
2018-01-12 08:10:41 +00:00
import Tooltip from '../tooltip'
import abstractTooltipProps from '../tooltip/abstractTooltipProps'
import PropTypes from '../_util/vue-types'
2018-01-12 11:04:42 +00:00
import { getOptionProps, getComponentFromProp } from '../_util/props-util'
2018-01-12 08:10:41 +00:00
2018-01-15 10:54:26 +00:00
const props = abstractTooltipProps()
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,
2018-01-12 08:10:41 +00:00
prefixCls: PropTypes.string.def('ant-popover'),
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
},
methods: {
getPopupDomNode () {
return this.$refs.tooltip.getPopupDomNode()
},
},
render (h) {
2018-01-15 09:33:34 +00:00
const { title, prefixCls, $slots } = this
2018-01-12 08:10:41 +00:00
const props = getOptionProps(this)
delete props.title
delete props.content
const tooltipProps = {
props: {
...props,
},
ref: 'tooltip',
on: this.$listeners,
}
return (
<Tooltip
{...tooltipProps}
>
<template slot='title'>
2018-01-12 11:04:42 +00:00
<div>
{(title || $slots.title) &&
<div class={`${prefixCls}-title`}>
2018-01-18 02:43:39 +00:00
{getComponentFromProp(this, 'title')}
2018-01-12 11:04:42 +00:00
</div>
}
<div class={`${prefixCls}-inner-content`}>
2018-01-18 02:43:39 +00:00
{getComponentFromProp(this, 'content')}
2018-01-12 11:04:42 +00:00
</div>
</div>
2018-01-12 08:10:41 +00:00
</template>
{this.$slots.default}
</Tooltip>
)
},
}
/* istanbul ignore next */
Popover.install = function (Vue) {
Vue.component(Popover.name, Popover)
}
export default Popover