You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/menu/MenuItem.jsx

53 lines
1.3 KiB

7 years ago
import { Item, itemProps } from '../vc-menu'
7 years ago
import { getClass, getStyle } from '../_util/props-util'
import { cloneVNodes } from '../_util/vnode'
7 years ago
import Tooltip from '../tooltip'
7 years ago
function noop () {}
7 years ago
export default {
props: itemProps,
7 years ago
name: 'MenuItem',
7 years ago
inject: {
7 years ago
getInlineCollapsed: { default: () => noop },
7 years ago
},
isMenuItem: 1,
methods: {
onKeyDown (e) {
this.$refs.menuItem.onKeyDown(e)
},
},
7 years ago
render (h) {
7 years ago
const { getInlineCollapsed, $props: props, $slots, $attrs: attrs, $listeners } = this
const inlineCollapsed = getInlineCollapsed()
7 years ago
const itemProps = {
props,
attrs,
7 years ago
on: $listeners,
7 years ago
class: getClass(this),
style: getStyle(this),
}
7 years ago
const toolTipProps = {
props: {
placement: 'right',
overlayClassName: `${props.rootPrefixCls}-inline-collapsed-tooltip`,
},
on: {},
}
7 years ago
return (
inlineCollapsed && props.level === 1
? <Tooltip {...toolTipProps}>
<template slot='title'>
{ cloneVNodes($slots.default, true) }
</template>
<Item {...itemProps} ref='menuItem'>
{$slots.default}
</Item>
</Tooltip>
: <Item {...itemProps} ref='menuItem'>
{$slots.default}
</Item>
)
7 years ago
},
}