homeflowjs 0.12.20 → 0.12.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.12.20",
3
+ "version": "0.12.21",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -93,9 +93,20 @@ class LocationInput extends Component {
93
93
  return suggestion.label;
94
94
  }
95
95
 
96
+ onClearButtonClick() {
97
+ const { setSuggestions, setSearchField } = this.props;
98
+ setSuggestions([]);
99
+ setSearchField({ q: '' });
100
+ }
101
+
96
102
  render() {
97
103
  const {
98
- suggestions, search: { q = '' }, className, placeholder,
104
+ suggestions,
105
+ search: { q = '' },
106
+ className,
107
+ placeholder,
108
+ clearButton,
109
+ clearButtonClassName,
99
110
  } = this.props;
100
111
 
101
112
  const inputProps = {
@@ -105,23 +116,34 @@ class LocationInput extends Component {
105
116
  };
106
117
 
107
118
  return (
108
- <Autosuggest
109
- value={q}
110
- suggestions={suggestions}
111
- onSuggestionsFetchRequested={this.onSuggestionsFetchRequested.bind(this)}
112
- onSuggestionsClearRequested={this.onSuggestionsClearRequested.bind(this)}
113
- getSuggestionValue={this.getSuggestionValue.bind(this)}
114
- renderSuggestion={this.renderSuggestion.bind(this)}
115
- inputProps={{
116
- ...inputProps,
117
- className,
118
- 'data-testid': 'location-input',
119
- id: 'search-location-input',
120
- name: 'Location search',
121
- }}
122
- containerProps={{ 'data-testid': 'suggestions' }}
123
- theme={autosuggestTheme}
124
- />
119
+ <div>
120
+ <Autosuggest
121
+ value={q}
122
+ suggestions={suggestions}
123
+ onSuggestionsFetchRequested={this.onSuggestionsFetchRequested.bind(this)}
124
+ onSuggestionsClearRequested={this.onSuggestionsClearRequested.bind(this)}
125
+ getSuggestionValue={this.getSuggestionValue.bind(this)}
126
+ renderSuggestion={this.renderSuggestion.bind(this)}
127
+ inputProps={{
128
+ ...inputProps,
129
+ className,
130
+ 'data-testid': 'location-input',
131
+ id: 'search-location-input',
132
+ name: 'Location search',
133
+ }}
134
+ containerProps={{ 'data-testid': 'suggestions' }}
135
+ theme={autosuggestTheme}
136
+ />
137
+ {(clearButton && q) && (
138
+ <button
139
+ className={clearButtonClassName}
140
+ type="reset"
141
+ onClick={this.onClearButtonClick.bind(this)}
142
+ >
143
+ &times;
144
+ </button>
145
+ )}
146
+ </div>
125
147
  );
126
148
  }
127
149
  }
@@ -134,6 +156,8 @@ LocationInput.propTypes = {
134
156
  className: PropTypes.string,
135
157
  search: PropTypes.object.isRequired,
136
158
  searchOnSelection: PropTypes.bool,
159
+ clearButton: PropTypes.bool,
160
+ clearButtonClassName: PropTypes.string,
137
161
  };
138
162
 
139
163
  LocationInput.defaultProps = {
@@ -141,6 +165,8 @@ LocationInput.defaultProps = {
141
165
  className: '',
142
166
  suggestions: [],
143
167
  searchOnSelection: false,
168
+ clearButton: false,
169
+ clearButtonClassName: '',
144
170
  };
145
171
 
146
172
  const mapStateToProps = (state) => ({