@happeouikit/form-elements 2.3.19 → 2.3.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.19
4
+
5
+ - [Improved] Typeahead component with `onClear` handler and other tweaks
6
+
3
7
  ## 2.3.18
4
8
 
5
9
  - [Renamed] Typeahead prop `afterSelect` to `onSelect`
@@ -18,6 +18,7 @@ var Typeahead = function Typeahead(_ref) {
18
18
  loading = _ref.loading,
19
19
  results = _ref.results,
20
20
  onSelect = _ref.onSelect,
21
+ onClear = _ref.onClear,
21
22
  keepResult = _ref.keepResult,
22
23
  placeholder = _ref.placeholder,
23
24
  errorMessage = _ref.errorMessage,
@@ -97,7 +98,7 @@ var Typeahead = function Typeahead(_ref) {
97
98
  }
98
99
 
99
100
  setSelectedResult(result);
100
- onSelect(result);
101
+ onSelect(result.data);
101
102
  setFocusedResultIndex(null);
102
103
  };
103
104
 
@@ -110,8 +111,8 @@ var Typeahead = function Typeahead(_ref) {
110
111
  setSelectedResult(null);
111
112
  setFocusedResultIndex(null); // notify parent that selection was erased
112
113
 
113
- if (selectedResult) {
114
- onSelect(null);
114
+ if (keepResult && selectedResult) {
115
+ onClear();
115
116
  }
116
117
  };
117
118
 
@@ -212,12 +213,14 @@ Typeahead.propTypes = {
212
213
  loading: PropTypes.bool.isRequired,
213
214
  results: PropTypes.arrayOf(PropTypes.shape({
214
215
  text: PropTypes.string,
215
- // This is used in association with keepResult
216
+ // If keepResult, this is showed when selecting a result
216
217
  component: PropTypes.element.isRequired,
217
- data: PropTypes.shape // You may add any data related to the result, so you can use it on onSelect
218
+ data: PropTypes.shape.isRequired // Data will be passed with onSelect
218
219
 
219
220
  })).isRequired,
220
221
  onSelect: PropTypes.func.isRequired,
222
+ onClear: PropTypes.func,
223
+ // If keepResult, this is called if user clears the result from input
221
224
  keepResult: PropTypes.bool,
222
225
  placeholder: PropTypes.string,
223
226
  errorMessage: PropTypes.string,
@@ -229,6 +232,7 @@ Typeahead.defaultProps = {
229
232
  placeholder: "",
230
233
  errorMessage: null,
231
234
  queryError: false,
232
- dropdownMaxHeight: "350px"
235
+ dropdownMaxHeight: "350px",
236
+ onClear: function onClear() {}
233
237
  };
234
238
  export default Typeahead;
@@ -33,5 +33,5 @@ var Container = styled.ul.withConfig({
33
33
  var Row = styled.li.withConfig({
34
34
  displayName: "TypeaheadList__Row",
35
35
  componentId: "sc-ce1llk-1"
36
- })(["padding:9px 15px 9px 15px;border:solid 1px transparent;list-style-type:none;&:hover{background:", ";}"], toBgLight(active));
36
+ })(["padding:9px 15px 9px 15px;border:solid 1px transparent;list-style-type:none;cursor:pointer;&:hover{background:", ";}"], toBgLight(active));
37
37
  export default TypeaheadList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happeouikit/form-elements",
3
- "version": "2.3.19",
3
+ "version": "2.3.20",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "2525dd4ccc5ece89512fe8900af51d19e7f0aa96"
48
+ "gitHead": "ea1698bfe17f6f7b4d53f641fdfcf060ece14ac2"
49
49
  }