import React from 'react'; import classNames from 'classnames'; import Input, { InputProps } from './Input'; import Icon from '../icon'; import Button from '../button'; export interface SearchProps extends InputProps { onSearch?: (value: string) => any; enterButton?: boolean | React.ReactNode; } export default class Search extends React.Component { static defaultProps = { prefixCls: 'ant-input-search', enterButton: false, }; input: Input; onSearch = () => { const { onSearch } = this.props; if (onSearch) { onSearch(this.input.input.value); } this.input.focus(); } saveInput = (node) => { this.input = node; } render() { const { className, prefixCls, size, enterButton, ...others } = this.props; delete (others as any).onSearch; const searchSuffix = enterButton ? ( ) : ; const inputClassName = classNames(prefixCls, className, { [`${prefixCls}-enter-button`]: !!enterButton, }); return ( ); } }