-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip, popover): overall code refactor for better reactivity a…
- Loading branch information
1 parent
5c4c89a
commit eebab43
Showing
26 changed files
with
2,675 additions
and
2,132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Vue from '../../../utils/vue' | ||
import { isFunction, isUndefinedOrNull } from '../../../utils/inspect' | ||
|
||
import { BVTooltipTemplate } from '../../tooltip/helpers/bv-tooltip-template' | ||
|
||
const NAME = 'BVPopoverTemplate' | ||
|
||
// @vue/component | ||
export const BVPopoverTemplate = /*#__PURE__*/ Vue.extend({ | ||
name: NAME, | ||
extends: BVTooltipTemplate, | ||
computed: { | ||
templateType() { | ||
return 'popover' | ||
} | ||
}, | ||
methods: { | ||
renderTemplate(h) { | ||
// Title and content could be a scoped slot function | ||
const $title = isFunction(this.title) ? this.title({}) : this.title | ||
const $content = isFunction(this.content) ? this.content({}) : this.content | ||
|
||
// Directive usage only | ||
const titleDomProps = this.html && !isFunction(this.title) ? { innerHTML: this.title } : {} | ||
const contentDomProps = | ||
this.html && !isFunction(this.content) ? { innerHTML: this.content } : {} | ||
|
||
return h( | ||
'div', | ||
{ | ||
staticClass: 'popover b-popover', | ||
class: this.templateClasses, | ||
attrs: this.templateAttributes, | ||
on: this.templateListeners | ||
}, | ||
[ | ||
h('div', { ref: 'arrow', staticClass: 'arrow' }), | ||
isUndefinedOrNull($title) | ||
? h() | ||
: h('h3', { staticClass: 'popover-header', domProps: titleDomProps }, [$title]), | ||
isUndefinedOrNull($content) | ||
? h() | ||
: h('div', { staticClass: 'popover-body', domProps: contentDomProps }, [$content]) | ||
] | ||
) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Popover "Class" (Built as a renderless Vue instance) | ||
// Inherits from BVTooltip | ||
// | ||
// Handles trigger events, etc. | ||
// Instantiates template on demand | ||
|
||
import Vue from '../../../utils/vue' | ||
import { BVTooltip } from '../../tooltip/helpers/bv-tooltip' | ||
import { BVPopoverTemplate } from './bv-popover-template' | ||
|
||
const NAME = 'BVPopover' | ||
|
||
// @vue/component | ||
export const BVPopover = /*#__PURE__*/ Vue.extend({ | ||
name: NAME, | ||
extends: BVTooltip, | ||
computed: { | ||
// Overwrites BVTooltip | ||
templateType() { | ||
return 'popover' | ||
} | ||
}, | ||
methods: { | ||
getTemplate() { | ||
// Overwrites BVTooltip | ||
return BVPopoverTemplate | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.