/
dropdown-item.js
73 lines (71 loc) · 1.61 KB
/
dropdown-item.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import Vue from '../../utils/vue'
import { requestAF } from '../../utils/dom'
import attrsMixin from '../../mixins/attrs'
import normalizeSlotMixin from '../../mixins/normalize-slot'
import { BLink, propsFactory as linkPropsFactory } from '../link/link'
export const props = linkPropsFactory()
// @vue/component
export const BDropdownItem = /*#__PURE__*/ Vue.extend({
name: 'BDropdownItem',
mixins: [attrsMixin, normalizeSlotMixin],
inheritAttrs: false,
inject: {
bvDropdown: {
default: null
}
},
props: {
...props,
linkClass: {
type: [String, Array, Object],
default: null
},
variant: {
type: String,
default: null
}
},
computed: {
computedAttrs() {
return {
...this.bvAttrs,
role: 'menuitem'
}
}
},
methods: {
closeDropdown() {
// Close on next animation frame to allow <b-link> time to process
requestAF(() => {
if (this.bvDropdown) {
this.bvDropdown.hide(true)
}
})
},
onClick(evt) {
this.$emit('click', evt)
this.closeDropdown()
}
},
render(h) {
return h('li', { attrs: { role: 'presentation' } }, [
h(
BLink,
{
props: this.$props,
staticClass: 'dropdown-item',
class: [
this.linkClass,
{
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
}
],
attrs: this.computedAttrs,
on: { click: this.onClick },
ref: 'item'
},
this.normalizeSlot('default')
)
])
}
})