|
|
@@ -1,4 +1,5 @@
|
|
|
import React, { PureComponent } from 'react';
|
|
|
+import PropTypes from 'prop-types';
|
|
|
import { Input, Icon, AutoComplete } from 'antd';
|
|
|
import classNames from 'classnames';
|
|
|
import styles from './index.less';
|
|
|
@@ -6,6 +7,21 @@ import styles from './index.less';
|
|
|
export default class HeaderSearch extends PureComponent {
|
|
|
static defaultProps = {
|
|
|
defaultActiveFirstOption: false,
|
|
|
+ onPressEnter: () => {},
|
|
|
+ onChange: () => {},
|
|
|
+ onSearch: () => {},
|
|
|
+ className: '',
|
|
|
+ placeholder: '',
|
|
|
+ dataSource: [],
|
|
|
+ };
|
|
|
+ static propTypes = {
|
|
|
+ className: PropTypes.string,
|
|
|
+ placeholder: PropTypes.string,
|
|
|
+ onSearch: PropTypes.func,
|
|
|
+ onPressEnter: PropTypes.func,
|
|
|
+ onChange: PropTypes.func,
|
|
|
+ defaultActiveFirstOption: PropTypes.bool,
|
|
|
+ dataSource: PropTypes.array,
|
|
|
};
|
|
|
state = {
|
|
|
searchMode: false,
|
|
|
@@ -23,6 +39,7 @@ export default class HeaderSearch extends PureComponent {
|
|
|
}
|
|
|
onChange = (value) => {
|
|
|
this.setState({ value });
|
|
|
+ this.props.onChange();
|
|
|
}
|
|
|
enterSearchMode = () => {
|
|
|
this.setState({ searchMode: true }, () => {
|
|
|
@@ -49,7 +66,6 @@ export default class HeaderSearch extends PureComponent {
|
|
|
className={inputClass}
|
|
|
value={this.state.value}
|
|
|
onChange={this.onChange}
|
|
|
- onSelect={this.onSelect}
|
|
|
{...restProps}
|
|
|
>
|
|
|
<Input
|