@comicrelief/component-library 7.13.0 → 7.14.0
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/dist/components/Molecules/SchoolLookup/__snapshots__/SchoolLookup.test.js.snap +1 -1
- package/dist/components/Molecules/Typeahead/Typeahead.js +7 -14
- package/dist/components/Molecules/Typeahead/__snapshots__/Typeahead.test.js.snap +1 -1
- package/package.json +1 -1
- package/src/components/Molecules/SchoolLookup/__snapshots__/SchoolLookup.test.js.snap +1 -1
- package/src/components/Molecules/Typeahead/Typeahead.js +1 -5
- package/src/components/Molecules/Typeahead/__snapshots__/Typeahead.test.js.snap +1 -1
|
@@ -92,13 +92,13 @@ exports[`renders correctly 1`] = `
|
|
|
92
92
|
aria-describedby="school-lookup"
|
|
93
93
|
autoComplete="off"
|
|
94
94
|
className="c5"
|
|
95
|
+
defaultValue=""
|
|
95
96
|
id="school-lookup"
|
|
96
97
|
name="school-lookup"
|
|
97
98
|
onChange={[Function]}
|
|
98
99
|
placeholder="Type to start search"
|
|
99
100
|
required={false}
|
|
100
101
|
type="text"
|
|
101
|
-
value=""
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
|
|
@@ -43,20 +43,15 @@ var Typeahead = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
43
43
|
fetchErrorHandler = _ref.fetchErrorHandler,
|
|
44
44
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
45
45
|
|
|
46
|
-
var _useState = (0, _react.useState)(
|
|
46
|
+
var _useState = (0, _react.useState)([]),
|
|
47
47
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
options = _useState2[0],
|
|
49
|
+
setOptions = _useState2[1];
|
|
50
50
|
|
|
51
|
-
var _useState3 = (0, _react.useState)(
|
|
51
|
+
var _useState3 = (0, _react.useState)(''),
|
|
52
52
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _useState5 = (0, _react.useState)(''),
|
|
57
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
-
errorMsg = _useState6[0],
|
|
59
|
-
setErrorMsg = _useState6[1];
|
|
53
|
+
errorMsg = _useState4[0],
|
|
54
|
+
setErrorMsg = _useState4[1];
|
|
60
55
|
|
|
61
56
|
var handleChange = /*#__PURE__*/function () {
|
|
62
57
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query) {
|
|
@@ -119,12 +114,11 @@ var Typeahead = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
119
114
|
|
|
120
115
|
var debouncedHandleChange = (0, _react.useCallback)((0, _lodash.debounce)(handleChange, DELAY_DURATION), []);
|
|
121
116
|
return /*#__PURE__*/_react.default.createElement(_TextInputWithDropdown.default, Object.assign({
|
|
122
|
-
|
|
117
|
+
defaultValue: "",
|
|
123
118
|
options: optionParser ? options.map(optionParser) : options,
|
|
124
119
|
errorMsg: errorMsg,
|
|
125
120
|
onChange: function onChange(e) {
|
|
126
121
|
var newValue = e.currentTarget.value;
|
|
127
|
-
setValue(newValue);
|
|
128
122
|
debouncedHandleChange(newValue);
|
|
129
123
|
},
|
|
130
124
|
onSelect: function onSelect(parsedOption, optionIndex) {
|
|
@@ -136,7 +130,6 @@ var Typeahead = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
136
130
|
|
|
137
131
|
setOptions([]);
|
|
138
132
|
setErrorMsg('');
|
|
139
|
-
setValue('');
|
|
140
133
|
},
|
|
141
134
|
id: id,
|
|
142
135
|
label: label,
|
|
@@ -92,13 +92,13 @@ exports[`renders correctly 1`] = `
|
|
|
92
92
|
aria-describedby="typeahead-test"
|
|
93
93
|
autoComplete="off"
|
|
94
94
|
className="c5"
|
|
95
|
+
defaultValue=""
|
|
95
96
|
id="typeahead-test"
|
|
96
97
|
name="q"
|
|
97
98
|
onChange={[Function]}
|
|
98
99
|
placeholder="Type to start searching..."
|
|
99
100
|
required={false}
|
|
100
101
|
type="text"
|
|
101
|
-
value=""
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
|
package/package.json
CHANGED
|
@@ -92,13 +92,13 @@ exports[`renders correctly 1`] = `
|
|
|
92
92
|
aria-describedby="school-lookup"
|
|
93
93
|
autoComplete="off"
|
|
94
94
|
className="c5"
|
|
95
|
+
defaultValue=""
|
|
95
96
|
id="school-lookup"
|
|
96
97
|
name="school-lookup"
|
|
97
98
|
onChange={[Function]}
|
|
98
99
|
placeholder="Type to start search"
|
|
99
100
|
required={false}
|
|
100
101
|
type="text"
|
|
101
|
-
value=""
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
|
|
@@ -24,7 +24,6 @@ const Typeahead = React.forwardRef(
|
|
|
24
24
|
},
|
|
25
25
|
ref
|
|
26
26
|
) => {
|
|
27
|
-
const [value, setValue] = useState('');
|
|
28
27
|
const [options, setOptions] = useState([]);
|
|
29
28
|
const [errorMsg, setErrorMsg] = useState('');
|
|
30
29
|
|
|
@@ -62,13 +61,11 @@ const Typeahead = React.forwardRef(
|
|
|
62
61
|
|
|
63
62
|
return (
|
|
64
63
|
<TextInputWithDropdown
|
|
65
|
-
|
|
64
|
+
defaultValue=""
|
|
66
65
|
options={optionParser ? options.map(optionParser) : options}
|
|
67
66
|
errorMsg={errorMsg}
|
|
68
67
|
onChange={e => {
|
|
69
68
|
const newValue = e.currentTarget.value;
|
|
70
|
-
setValue(newValue);
|
|
71
|
-
|
|
72
69
|
debouncedHandleChange(newValue);
|
|
73
70
|
}}
|
|
74
71
|
onSelect={(parsedOption, optionIndex) => {
|
|
@@ -81,7 +78,6 @@ const Typeahead = React.forwardRef(
|
|
|
81
78
|
// reset
|
|
82
79
|
setOptions([]);
|
|
83
80
|
setErrorMsg('');
|
|
84
|
-
setValue('');
|
|
85
81
|
}}
|
|
86
82
|
id={id}
|
|
87
83
|
label={label}
|
|
@@ -92,13 +92,13 @@ exports[`renders correctly 1`] = `
|
|
|
92
92
|
aria-describedby="typeahead-test"
|
|
93
93
|
autoComplete="off"
|
|
94
94
|
className="c5"
|
|
95
|
+
defaultValue=""
|
|
95
96
|
id="typeahead-test"
|
|
96
97
|
name="q"
|
|
97
98
|
onChange={[Function]}
|
|
98
99
|
placeholder="Type to start searching..."
|
|
99
100
|
required={false}
|
|
100
101
|
type="text"
|
|
101
|
-
value=""
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
|