ant-design/components/menu/MenuItem.tsx

34 lines
882 B
TypeScript
Raw Normal View History

import * as React from 'react';
2017-06-30 21:07:01 +08:00
import { Item } from 'rc-menu';
2018-08-07 21:07:52 +08:00
import * as PropTypes from 'prop-types';
2017-06-30 21:07:01 +08:00
import Tooltip from '../tooltip';
class MenuItem extends React.Component<any, any> {
static contextTypes = {
inlineCollapsed: PropTypes.bool,
};
static isMenuItem = 1;
private menuItem: any;
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
this.menuItem.onKeyDown(e);
}
saveMenuItem = (menuItem: any) => {
this.menuItem = menuItem;
}
render() {
const { inlineCollapsed } = this.context;
const props = this.props;
2018-05-10 10:59:33 +08:00
return (
<Tooltip
title={inlineCollapsed && props.level === 1 ? props.children : ''}
placement="right"
overlayClassName={`${props.rootPrefixCls}-inline-collapsed-tooltip`}
>
<Item {...props} ref={this.saveMenuItem} />
</Tooltip>
);
}
}
2017-06-30 21:07:01 +08:00
export default MenuItem;