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;
addonAfter?: React.ReactNode;
onPressEnter?: React.FormEventHandler<any>;
onKeyDown?: React.FormEventHandler<any>;
onChange?: React.FormEventHandler<any>;
onClick?: React.FormEventHandler<any>;
onFocus?: React.FormEventHandler<any>;
onBlur?: React.FormEventHandler<any>;
autosize?: boolean | AutoSizeType;
autoComplete?: 'on' | 'off';
style?: React.CSSProperties;
prefix?: 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 Search: any;
static defaultProps = {

View File

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