UNPKG

@gitlab/ui

Version:
46 lines (40 loc) 1.5 kB
import { extend } from '../../vue'; import { NAME_POPOVER } from '../../constants/components'; import { EVENT_NAME_CLICK } from '../../constants/events'; import { PROP_TYPE_STRING, PROP_TYPE_ARRAY_STRING } from '../../constants/props'; import { SLOT_NAME_TITLE } from '../../constants/slots'; import { makePropsConfigurable, makeProp } from '../../utils/props'; import { props as props$1, BTooltip } from '../tooltip/tooltip'; import { BVPopover } from './helpers/bv-popover'; import { sortKeys } from '../../utils/object'; // --- Props --- const props = makePropsConfigurable(sortKeys({ ...props$1, content: makeProp(PROP_TYPE_STRING), placement: makeProp(PROP_TYPE_STRING, 'right'), triggers: makeProp(PROP_TYPE_ARRAY_STRING, EVENT_NAME_CLICK) }), NAME_POPOVER); // --- Main component --- // @vue/component const BPopover = /*#__PURE__*/extend({ name: NAME_POPOVER, extends: BTooltip, inheritAttrs: false, props, methods: { getComponent() { // Overridden by BPopover return BVPopover; }, updateContent() { // Tooltip: Default slot is `title` // Popover: Default slot is `content`, `title` slot is title // We pass a scoped slot function references by default (Vue v2.6x) // And pass the title prop as a fallback this.setContent(this.normalizeSlot() || this.content); this.setTitle(this.normalizeSlot(SLOT_NAME_TITLE) || this.title); } } // Render function provided by BTooltip }); export { BPopover, props };