2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2017-11-11 00:07:03 +08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { SubMenu as RcSubMenu } from 'rc-menu';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
class SubMenu extends React.Component<any, any> {
|
|
|
|
static contextTypes = {
|
|
|
|
antdMenuTheme: PropTypes.string,
|
|
|
|
};
|
2017-11-16 16:08:30 +08:00
|
|
|
private subMenu: any;
|
2017-11-21 17:38:51 +08:00
|
|
|
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.subMenu.onKeyDown(e);
|
|
|
|
}
|
2017-11-21 17:38:51 +08:00
|
|
|
saveSubMenu = (subMenu: any) => {
|
2017-11-16 16:08:30 +08:00
|
|
|
this.subMenu = subMenu;
|
|
|
|
}
|
2017-11-11 00:07:03 +08:00
|
|
|
render() {
|
|
|
|
const { rootPrefixCls, className } = this.props;
|
|
|
|
const theme = this.context.antdMenuTheme;
|
|
|
|
return (
|
|
|
|
<RcSubMenu
|
|
|
|
{...this.props}
|
2017-11-16 16:08:30 +08:00
|
|
|
ref={this.saveSubMenu}
|
2017-11-11 00:07:03 +08:00
|
|
|
popupClassName={classNames(`${rootPrefixCls}-${theme}`, className)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SubMenu;
|