bv-popover-template.js
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { extend } from '../../../vue'
import { NAME_POPOVER_TEMPLATE } from '../../../constants/components'
import { isFunction, isUndefinedOrNull } from '../../../utils/inspect'
import { BVTooltipTemplate } from '../../tooltip/helpers/bv-tooltip-template'
// @vue/component
export const BVPopoverTemplate = /*#__PURE__*/ extend({
name: NAME_POPOVER_TEMPLATE,
extends: BVTooltipTemplate,
computed: {
templateType() {
return 'popover'
}
},
methods: {
renderTemplate(h) {
const { title, content } = this
// Title and content could be a scoped slot function
const $title = isFunction(title) ? title({}) : title
const $content = isFunction(content) ? content({}) : content
// Directive usage only
const titleDomProps = this.html && !isFunction(title) ? { innerHTML: title } : {}
const contentDomProps = this.html && !isFunction(content) ? { innerHTML: content } : {}
return h(
'div',
{
staticClass: 'popover b-popover',
class: this.templateClasses,
attrs: this.templateAttributes,
on: this.templateListeners
},
[
h('div', {
staticClass: 'arrow',
ref: 'arrow'
}),
isUndefinedOrNull($title) || $title === ''
? /* istanbul ignore next */ h()
: h('h3', { staticClass: 'popover-header', domProps: titleDomProps }, [$title]),
isUndefinedOrNull($content) || $content === ''
? /* istanbul ignore next */ h()
: h('div', { staticClass: 'popover-body', domProps: contentDomProps }, [$content])
]
)
}
}
})