This commit is contained in:
AllenFang 2018-09-29 14:31:10 +08:00
parent d4fa9a84e3
commit 0cdf086d56
2 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
search: PropTypes.oneOfType([ search: PropTypes.oneOfType([
PropTypes.bool, PropTypes.bool,
PropTypes.shape({ PropTypes.shape({
defaultSearch: PropTypes.string,
searchFormatted: PropTypes.bool searchFormatted: PropTypes.bool
}) })
]), ]),
@ -42,7 +43,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
searchText: '' searchText: typeof props.search === 'object' ? (props.search.defaultSearch || '') : ''
}; };
this._ = null; this._ = null;
this.onSearch = this.onSearch.bind(this); this.onSearch = this.onSearch.bind(this);
@ -85,6 +86,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
return ( return (
<ToolkitContext.Provider value={ { <ToolkitContext.Provider value={ {
searchProps: { searchProps: {
searchText: this.state.searchText,
onSearch: this.onSearch onSearch: this.onSearch
}, },
csvProps: { csvProps: {

View File

@ -47,6 +47,7 @@ const SearchBar = ({
style={ style } style={ style }
onKeyUp={ () => debounceCallback() } onKeyUp={ () => debounceCallback() }
className={ `form-control ${className}` } className={ `form-control ${className}` }
defaultValue={ searchText }
placeholder={ placeholder || SearchBar.defaultProps.placeholder } placeholder={ placeholder || SearchBar.defaultProps.placeholder }
{ ...rest } { ...rest }
/> />