2017-11-17 14:38:54 +08:00
|
|
|
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';
|
|
|
|
|
2017-10-27 20:21:34 +08:00
|
|
|
class MenuItem extends React.Component<any, any> {
|
|
|
|
static contextTypes = {
|
|
|
|
inlineCollapsed: PropTypes.bool,
|
|
|
|
};
|
|
|
|
static isMenuItem = 1;
|
2017-11-16 16:08:30 +08:00
|
|
|
private menuItem: any;
|
2017-11-21 17:38:51 +08:00
|
|
|
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.menuItem.onKeyDown(e);
|
|
|
|
}
|
2017-11-21 17:38:51 +08:00
|
|
|
saveMenuItem = (menuItem: any) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.menuItem = menuItem;
|
|
|
|
}
|
2017-10-27 20:21:34 +08:00
|
|
|
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-10-27 20:21:34 +08:00
|
|
|
}
|
|
|
|
}
|
2017-08-04 21:24:59 +08:00
|
|
|
|
2017-06-30 21:07:01 +08:00
|
|
|
export default MenuItem;
|