2018-03-19 02:16:27 +00:00
|
|
|
|
2018-02-06 09:22:36 +00:00
|
|
|
import { Item, itemProps } from '../vc-menu'
|
2018-09-05 13:28:54 +00:00
|
|
|
import { getClass, getStyle, getOptionProps } from '../_util/props-util'
|
2018-02-24 10:12:24 +00:00
|
|
|
import { cloneVNodes } from '../_util/vnode'
|
2018-01-16 07:41:00 +00:00
|
|
|
import Tooltip from '../tooltip'
|
2018-01-18 02:43:39 +00:00
|
|
|
function noop () {}
|
2018-01-16 07:41:00 +00:00
|
|
|
export default {
|
|
|
|
props: itemProps,
|
2018-01-30 08:52:56 +00:00
|
|
|
name: 'MenuItem',
|
2018-01-16 07:41:00 +00:00
|
|
|
inject: {
|
2018-01-18 02:43:39 +00:00
|
|
|
getInlineCollapsed: { default: () => noop },
|
2018-01-16 07:41:00 +00:00
|
|
|
},
|
|
|
|
isMenuItem: 1,
|
|
|
|
methods: {
|
|
|
|
onKeyDown (e) {
|
|
|
|
this.$refs.menuItem.onKeyDown(e)
|
|
|
|
},
|
|
|
|
},
|
2018-01-17 08:12:53 +00:00
|
|
|
render (h) {
|
2018-09-05 13:28:54 +00:00
|
|
|
const props = getOptionProps(this)
|
|
|
|
const { getInlineCollapsed, $slots, $attrs: attrs, $listeners } = this
|
2018-01-17 11:15:18 +00:00
|
|
|
const inlineCollapsed = getInlineCollapsed()
|
2018-01-16 07:41:00 +00:00
|
|
|
const itemProps = {
|
|
|
|
props,
|
|
|
|
attrs,
|
2018-01-18 10:58:36 +00:00
|
|
|
on: $listeners,
|
2018-01-16 07:41:00 +00:00
|
|
|
}
|
2018-01-17 11:15:18 +00:00
|
|
|
const toolTipProps = {
|
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
title: inlineCollapsed && props.level === 1 ? $slots.default : '',
|
2018-01-17 11:15:18 +00:00
|
|
|
placement: 'right',
|
|
|
|
overlayClassName: `${props.rootPrefixCls}-inline-collapsed-tooltip`,
|
|
|
|
},
|
|
|
|
}
|
2018-02-03 11:48:03 +00:00
|
|
|
return (
|
2018-09-05 13:28:54 +00:00
|
|
|
<Tooltip {...toolTipProps}>
|
|
|
|
<Item {...itemProps} ref='menuItem'>
|
2018-02-03 11:48:03 +00:00
|
|
|
{$slots.default}
|
|
|
|
</Item>
|
2018-09-05 13:28:54 +00:00
|
|
|
</Tooltip>
|
2018-02-03 11:48:03 +00:00
|
|
|
)
|
2018-01-16 07:41:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|