2018-03-19 10:16:27 +08:00
|
|
|
|
2018-02-06 17:22:36 +08:00
|
|
|
import PropTypes from '../_util/vue-types'
|
|
|
|
import { getComponentFromProp } from '../_util/props-util'
|
2018-09-05 21:28:54 +08:00
|
|
|
// import { menuAllProps } from './util'
|
2017-12-12 13:49:02 +08:00
|
|
|
|
|
|
|
const MenuItemGroup = {
|
|
|
|
name: 'MenuItemGroup',
|
|
|
|
|
|
|
|
props: {
|
|
|
|
renderMenuItem: PropTypes.func,
|
|
|
|
index: PropTypes.number,
|
|
|
|
className: PropTypes.string,
|
2018-09-05 21:28:54 +08:00
|
|
|
subMenuKey: PropTypes.string,
|
2017-12-12 13:49:02 +08:00
|
|
|
rootPrefixCls: PropTypes.string,
|
|
|
|
disabled: PropTypes.bool.def(true),
|
2018-01-19 18:01:43 +08:00
|
|
|
title: PropTypes.any,
|
2017-12-12 13:49:02 +08:00
|
|
|
},
|
2018-01-04 19:06:54 +08:00
|
|
|
isMenuItemGroup: true,
|
2017-12-12 13:49:02 +08:00
|
|
|
methods: {
|
2018-09-05 21:28:54 +08:00
|
|
|
renderInnerMenuItem (item) {
|
|
|
|
const { renderMenuItem, index, subMenuKey } = this.$props
|
|
|
|
return renderMenuItem(item, index, subMenuKey)
|
2017-12-12 13:49:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
render () {
|
2018-09-05 21:28:54 +08:00
|
|
|
const props = { ...this.$props }
|
|
|
|
const { rootPrefixCls, title } = props
|
2017-12-12 13:49:02 +08:00
|
|
|
const titleClassName = `${rootPrefixCls}-item-group-title`
|
|
|
|
const listClassName = `${rootPrefixCls}-item-group-list`
|
2018-09-05 21:28:54 +08:00
|
|
|
// menuAllProps.props.forEach(key => delete props[key])
|
|
|
|
const listeners = { ...this.$listeners }
|
|
|
|
delete listeners.click
|
|
|
|
|
2017-12-12 13:49:02 +08:00
|
|
|
return (
|
2018-09-05 21:28:54 +08:00
|
|
|
<li {...{ on: listeners, class: `${rootPrefixCls}-item-group` }}>
|
2017-12-12 13:49:02 +08:00
|
|
|
<div
|
|
|
|
class={titleClassName}
|
2018-09-05 21:28:54 +08:00
|
|
|
title={typeof title === 'string' ? title : undefined}
|
2017-12-12 13:49:02 +08:00
|
|
|
>
|
2018-01-19 18:01:43 +08:00
|
|
|
{getComponentFromProp(this, 'title')}
|
2017-12-12 13:49:02 +08:00
|
|
|
</div>
|
|
|
|
<ul class={listClassName}>
|
2018-03-21 13:31:55 +08:00
|
|
|
{this.$slots.default && this.$slots.default.map(this.renderInnerMenuItem)}
|
2017-12-12 13:49:02 +08:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MenuItemGroup
|
2018-03-19 10:16:27 +08:00
|
|
|
|