UNPKG

bootstrap-vue

Version:

BootstrapVue, with more than 85 custom components, over 45 plugins, several custom directives, and over 300 icons, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated W

98 lines (94 loc) 2.56 kB
import Vue from '../../utils/vue' import { props as BDropdownProps } from '../dropdown/dropdown' import idMixin from '../../mixins/id' import dropdownMixin from '../../mixins/dropdown' import normalizeSlotMixin from '../../mixins/normalize-slot' import pluckProps from '../../utils/pluck-props' import { htmlOrText } from '../../utils/html' import { BLink } from '../link/link' // -- Constants -- export const props = pluckProps( ['text', 'html', 'menuClass', 'toggleClass', 'noCaret', 'role', 'lazy'], BDropdownProps ) // @vue/component export const BNavItemDropdown = /*#__PURE__*/ Vue.extend({ name: 'BNavItemDropdown', mixins: [idMixin, dropdownMixin, normalizeSlotMixin], props, computed: { isNav() { // Signal to dropdown mixin that we are in a navbar return true }, dropdownClasses() { return [this.directionClass, { show: this.visible }] }, menuClasses() { return [ this.menuClass, { 'dropdown-menu-right': this.right, show: this.visible } ] }, toggleClasses() { return [this.toggleClass, { 'dropdown-toggle-no-caret': this.noCaret }] } }, render(h) { const button = h( BLink, { ref: 'toggle', staticClass: 'nav-link dropdown-toggle', class: this.toggleClasses, props: { href: '#', disabled: this.disabled }, attrs: { id: this.safeId('_BV_button_'), 'aria-haspopup': 'true', 'aria-expanded': this.visible ? 'true' : 'false' }, on: { mousedown: this.onMousedown, click: this.toggle, keydown: this.toggle // Handle ENTER, SPACE and DOWN } }, [ this.$slots['button-content'] || this.$slots.text || h('span', { domProps: htmlOrText(this.html, this.text) }) ] ) const menu = h( 'ul', { staticClass: 'dropdown-menu', class: this.menuClasses, ref: 'menu', attrs: { tabindex: '-1', 'aria-labelledby': this.safeId('_BV_button_') }, on: { keydown: this.onKeydown // Handle UP, DOWN and ESC } }, !this.lazy || this.visible ? this.normalizeSlot('default', { hide: this.hide }) : [h()] ) return h( 'li', { staticClass: 'nav-item b-nav-dropdown dropdown', class: this.dropdownClasses, attrs: { id: this.safeId() } }, [button, menu] ) } })