mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
Fix implicit any error for Modal and Menu
This commit is contained in:
parent
d8f6c3bd8c
commit
b6c6ee8f3e
@ -43,6 +43,10 @@ export interface SiderProps {
|
|||||||
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SliderContext {
|
||||||
|
siderCollapsed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const generateId = (() => {
|
const generateId = (() => {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
return (prefix: string = '') => {
|
return (prefix: string = '') => {
|
||||||
|
@ -9,10 +9,10 @@ class MenuItem extends React.Component<any, any> {
|
|||||||
};
|
};
|
||||||
static isMenuItem = 1;
|
static isMenuItem = 1;
|
||||||
private menuItem: any;
|
private menuItem: any;
|
||||||
onKeyDown = (e) => {
|
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
|
||||||
this.menuItem.onKeyDown(e);
|
this.menuItem.onKeyDown(e);
|
||||||
}
|
}
|
||||||
saveMenuItem = (menuItem) => {
|
saveMenuItem = (menuItem: any) => {
|
||||||
this.menuItem = menuItem;
|
this.menuItem = menuItem;
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
@ -8,10 +8,10 @@ class SubMenu extends React.Component<any, any> {
|
|||||||
antdMenuTheme: PropTypes.string,
|
antdMenuTheme: PropTypes.string,
|
||||||
};
|
};
|
||||||
private subMenu: any;
|
private subMenu: any;
|
||||||
onKeyDown = (e) => {
|
onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
|
||||||
this.subMenu.onKeyDown(e);
|
this.subMenu.onKeyDown(e);
|
||||||
}
|
}
|
||||||
saveSubMenu = (subMenu) => {
|
saveSubMenu = (subMenu: any) => {
|
||||||
this.subMenu = subMenu;
|
this.subMenu = subMenu;
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
@ -6,6 +6,7 @@ import animation from '../_util/openAnimation';
|
|||||||
import warning from '../_util/warning';
|
import warning from '../_util/warning';
|
||||||
import SubMenu from './SubMenu';
|
import SubMenu from './SubMenu';
|
||||||
import Item from './MenuItem';
|
import Item from './MenuItem';
|
||||||
|
import { SliderContext } from '../layout/Sider';
|
||||||
|
|
||||||
export interface SelectParam {
|
export interface SelectParam {
|
||||||
key: string;
|
key: string;
|
||||||
@ -22,10 +23,12 @@ export interface ClickParam {
|
|||||||
domEvent: any;
|
domEvent: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MenuMode = 'vertical' | 'vertical-left' | 'vertical-right' | 'horizontal' | 'inline';
|
||||||
|
|
||||||
export interface MenuProps {
|
export interface MenuProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
theme?: 'light' | 'dark';
|
theme?: 'light' | 'dark';
|
||||||
mode?: 'vertical' | 'vertical-left' | 'vertical-right' | 'horizontal' | 'inline';
|
mode?: MenuMode;
|
||||||
selectable?: boolean;
|
selectable?: boolean;
|
||||||
selectedKeys?: Array<string>;
|
selectedKeys?: Array<string>;
|
||||||
defaultSelectedKeys?: Array<string>;
|
defaultSelectedKeys?: Array<string>;
|
||||||
@ -45,7 +48,11 @@ export interface MenuProps {
|
|||||||
inlineCollapsed?: boolean;
|
inlineCollapsed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Menu extends React.Component<MenuProps, any> {
|
export interface MenuState {
|
||||||
|
openKeys: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Menu extends React.Component<MenuProps, MenuState> {
|
||||||
static Divider = Divider;
|
static Divider = Divider;
|
||||||
static Item = Item;
|
static Item = Item;
|
||||||
static SubMenu = SubMenu;
|
static SubMenu = SubMenu;
|
||||||
@ -63,8 +70,8 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
siderCollapsed: PropTypes.bool,
|
siderCollapsed: PropTypes.bool,
|
||||||
};
|
};
|
||||||
switchModeFromInline: boolean;
|
switchModeFromInline: boolean;
|
||||||
inlineOpenKeys = [];
|
inlineOpenKeys: string[] = [];
|
||||||
constructor(props) {
|
constructor(props: MenuProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
warning(
|
warning(
|
||||||
@ -95,13 +102,13 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
antdMenuTheme: this.props.theme,
|
antdMenuTheme: this.props.theme,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
componentWillReceiveProps(nextProps, nextContext) {
|
componentWillReceiveProps(nextProps: MenuProps, nextContext: SliderContext) {
|
||||||
if (this.props.mode === 'inline' &&
|
if (this.props.mode === 'inline' &&
|
||||||
nextProps.mode !== 'inline') {
|
nextProps.mode !== 'inline') {
|
||||||
this.switchModeFromInline = true;
|
this.switchModeFromInline = true;
|
||||||
}
|
}
|
||||||
if ('openKeys' in nextProps) {
|
if ('openKeys' in nextProps) {
|
||||||
this.setState({ openKeys: nextProps.openKeys });
|
this.setState({ openKeys: nextProps.openKeys! });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) ||
|
if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) ||
|
||||||
@ -116,7 +123,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
this.inlineOpenKeys = [];
|
this.inlineOpenKeys = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleClick = (e) => {
|
handleClick = (e: ClickParam) => {
|
||||||
this.handleOpenChange([]);
|
this.handleOpenChange([]);
|
||||||
|
|
||||||
const { onClick } = this.props;
|
const { onClick } = this.props;
|
||||||
@ -132,7 +139,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
onOpenChange(openKeys);
|
onOpenChange(openKeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setOpenKeys(openKeys) {
|
setOpenKeys(openKeys: string[]) {
|
||||||
if (!('openKeys' in this.props)) {
|
if (!('openKeys' in this.props)) {
|
||||||
this.setState({ openKeys });
|
this.setState({ openKeys });
|
||||||
}
|
}
|
||||||
@ -152,7 +159,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
}
|
}
|
||||||
return inlineCollapsed;
|
return inlineCollapsed;
|
||||||
}
|
}
|
||||||
getMenuOpenAnimation(menuMode) {
|
getMenuOpenAnimation(menuMode: MenuMode) {
|
||||||
const { openAnimation, openTransitionName } = this.props;
|
const { openAnimation, openTransitionName } = this.props;
|
||||||
let menuOpenAnimation = openAnimation || openTransitionName;
|
let menuOpenAnimation = openAnimation || openTransitionName;
|
||||||
if (openAnimation === undefined && openTransitionName === undefined) {
|
if (openAnimation === undefined && openTransitionName === undefined) {
|
||||||
@ -175,7 +182,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
case 'inline':
|
case 'inline':
|
||||||
menuOpenAnimation = {
|
menuOpenAnimation = {
|
||||||
...animation,
|
...animation,
|
||||||
leave: (node, done) => animation.leave(node, () => {
|
leave: (node: HTMLElement, done: () => void) => animation.leave(node, () => {
|
||||||
// Make sure inline menu leave animation finished before mode is switched
|
// Make sure inline menu leave animation finished before mode is switched
|
||||||
this.switchModeFromInline = false;
|
this.switchModeFromInline = false;
|
||||||
this.setState({});
|
this.setState({});
|
||||||
@ -197,7 +204,7 @@ export default class Menu extends React.Component<MenuProps, any> {
|
|||||||
render() {
|
render() {
|
||||||
const { prefixCls, className, theme } = this.props;
|
const { prefixCls, className, theme } = this.props;
|
||||||
const menuMode = this.getRealMenuMode();
|
const menuMode = this.getRealMenuMode();
|
||||||
const menuOpenAnimation = this.getMenuOpenAnimation(menuMode);
|
const menuOpenAnimation = this.getMenuOpenAnimation(menuMode!);
|
||||||
|
|
||||||
const menuClassName = classNames(className, `${prefixCls}-${theme}`, {
|
const menuClassName = classNames(className, `${prefixCls}-${theme}`, {
|
||||||
[`${prefixCls}-inline-collapsed`]: this.getInlineCollapsed(),
|
[`${prefixCls}-inline-collapsed`]: this.getInlineCollapsed(),
|
||||||
|
Loading…
Reference in New Issue
Block a user