refactor: Extend Input types from HTMLInputProps, #5970 (#5990)

This commit is contained in:
偏右 2017-05-15 10:28:13 +08:00 committed by Benjy Cui
parent ffc6cb3c14
commit 0fdc3799b6
2 changed files with 8 additions and 11 deletions

View File

@ -47,20 +47,18 @@ export interface InputProps {
addonBefore?: React.ReactNode; addonBefore?: React.ReactNode;
addonAfter?: React.ReactNode; addonAfter?: React.ReactNode;
onPressEnter?: React.FormEventHandler<any>; onPressEnter?: React.FormEventHandler<any>;
onKeyDown?: React.FormEventHandler<any>;
onChange?: React.FormEventHandler<any>;
onClick?: React.FormEventHandler<any>; onClick?: React.FormEventHandler<any>;
onFocus?: React.FormEventHandler<any>; onFocus?: React.FormEventHandler<any>;
onBlur?: React.FormEventHandler<any>; onBlur?: React.FormEventHandler<any>;
autosize?: boolean | AutoSizeType; autosize?: boolean | AutoSizeType;
autoComplete?: 'on' | 'off';
style?: React.CSSProperties; style?: React.CSSProperties;
prefix?: React.ReactNode; prefix?: React.ReactNode;
suffix?: React.ReactNode; suffix?: React.ReactNode;
spellCheck?: boolean;
} }
export default class Input extends Component<InputProps, any> { export type HTMLInputProps = React.HTMLProps<HTMLInputElement>;
export default class Input extends Component<InputProps & HTMLInputProps, any> {
static Group: any; static Group: any;
static Search: any; static Search: any;
static defaultProps = { static defaultProps = {

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import Input from './Input'; import Input, { HTMLInputProps } from './Input';
import Icon from '../icon'; import Icon from '../icon';
export interface SearchProps { export interface SearchProps {
@ -10,14 +10,13 @@ export interface SearchProps {
style?: React.CSSProperties; style?: React.CSSProperties;
defaultValue?: any; defaultValue?: any;
value?: any; value?: any;
onChange?: React.FormEventHandler<any>;
onSearch?: (value: string) => any; onSearch?: (value: string) => any;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
disabled?: boolean; disabled?: boolean;
readOnly?: boolean; readOnly?: boolean;
} }
export default class Search extends React.Component<SearchProps, any> { export default class Search extends React.Component<SearchProps & HTMLInputProps, any> {
static defaultProps = { static defaultProps = {
prefixCls: 'ant-input-search', prefixCls: 'ant-input-search',
onSearch() {}, onSearch() {},
@ -42,11 +41,11 @@ export default class Search extends React.Component<SearchProps, any> {
); );
return ( return (
<Input <Input
className={classNames(prefixCls, className)}
onPressEnter={this.onSearch} onPressEnter={this.onSearch}
ref={node => this.input = node}
suffix={searchSuffix}
{...others} {...others}
suffix={searchSuffix}
className={classNames(prefixCls, className)}
ref={node => this.input = node}
/> />
); );
} }