-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuItemGroup.jsx
45 lines (40 loc) · 1.19 KB
/
MenuItemGroup.jsx
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
import PropTypes from '../_util/vue-types'
import { getComponentFromProp } from '../_util/props-util'
const MenuItemGroup = {
name: 'MenuItemGroup',
props: {
renderMenuItem: PropTypes.func,
index: PropTypes.number,
className: PropTypes.string,
rootPrefixCls: PropTypes.string,
disabled: PropTypes.bool.def(true),
title: PropTypes.any,
},
isMenuItemGroup: true,
methods: {
renderInnerMenuItem (item, subIndex) {
const { renderMenuItem, index } = this.$props
return renderMenuItem(item, index, subIndex)
},
},
render () {
const props = this.$props
const { rootPrefixCls } = props
const titleClassName = `${rootPrefixCls}-item-group-title`
const listClassName = `${rootPrefixCls}-item-group-list`
return (
<li class={`${rootPrefixCls}-item-group`}>
<div
class={titleClassName}
title={typeof props.title === 'string' ? props.title : undefined}
>
{getComponentFromProp(this, 'title')}
</div>
<ul class={listClassName}>
{this.$slots.default && this.$slots.default.map(this.renderInnerMenuItem)}
</ul>
</li>
)
},
}
export default MenuItemGroup