orc-shared 5.7.0-dev.12 → 5.7.0-dev.13

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.
@@ -184,15 +184,13 @@ var SearchControl = function SearchControl(_ref) {
184
184
  searchOption = getSearchOptionValue(searchOptions, searchOption);
185
185
  var classes = useStyles();
186
186
  var inputRef = (0, _react.useRef)();
187
- var cleanUpSearchValue = function cleanUpSearchValue(value) {
188
- if (trimSearchvalue) {
189
- return value == null ? void 0 : value.trim();
190
- }
191
- return value;
187
+ var onSearchInternal = function onSearchInternal(newSearchOption, value) {
188
+ var searchValue = trimSearchvalue ? value == null ? void 0 : value.trim() : value;
189
+ onSearch(newSearchOption, searchValue);
192
190
  };
193
- var update = function update(value) {
191
+ var update = function update(newSearchOption) {
194
192
  if (focusSearchOnSearchOptionChange && inputRef.current) {
195
- onSearch(value, "");
193
+ onSearchInternal(newSearchOption, "");
196
194
  setTimeout(function () {
197
195
  /* istanbul ignore next */
198
196
  if (inputRef.current) {
@@ -202,7 +200,8 @@ var SearchControl = function SearchControl(_ref) {
202
200
  }
203
201
  }, 0);
204
202
  } else {
205
- onSearch(value, cleanUpSearchValue(defaultValue));
203
+ var _inputRef$current;
204
+ onSearchInternal(newSearchOption, (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.value);
206
205
  }
207
206
  };
208
207
  var selectProps = new _SelectProps.default();
@@ -235,9 +234,9 @@ var SearchControl = function SearchControl(_ref) {
235
234
  });
236
235
  };
237
236
  var onSubmit = function onSubmit(event) {
238
- var _inputRef$current;
237
+ var _inputRef$current2;
239
238
  // using form submit instead of a keydown (with key=enter) to allow the 'enter key' event to be canceled elsewhere to avoid the submit event
240
- onSearch(searchOption, cleanUpSearchValue((_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.value));
239
+ onSearchInternal(searchOption, (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.value);
241
240
  event.preventDefault();
242
241
  };
243
242
  var inputSection = /*#__PURE__*/_react.default.createElement("div", {
@@ -265,7 +264,7 @@ var SearchControl = function SearchControl(_ref) {
265
264
  disabled: disabled,
266
265
  onClick: function onClick() {
267
266
  inputRef.current.value = null;
268
- onSearch(searchOption);
267
+ onSearchInternal(searchOption);
269
268
  inputRef.current.focus();
270
269
  },
271
270
  className: classes.clearButton
@@ -281,7 +280,7 @@ var SearchControl = function SearchControl(_ref) {
281
280
  root: classes.searchButton
282
281
  },
283
282
  onClick: function onClick() {
284
- onSearch(searchOption, inputRef.current.value);
283
+ onSearchInternal(searchOption, inputRef.current.value);
285
284
  }
286
285
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
287
286
  id: "search"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.7.0-dev.12",
3
+ "version": "5.7.0-dev.13",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -162,16 +162,15 @@ const SearchControl = ({
162
162
 
163
163
  const inputRef = useRef();
164
164
 
165
- const cleanUpSearchValue = value => {
166
- if (trimSearchvalue) {
167
- return value?.trim();
168
- }
169
- return value;
165
+ const onSearchInternal = (newSearchOption, value) => {
166
+ const searchValue = trimSearchvalue ? value?.trim() : value;
167
+
168
+ onSearch(newSearchOption, searchValue);
170
169
  };
171
170
 
172
- const update = value => {
171
+ const update = newSearchOption => {
173
172
  if (focusSearchOnSearchOptionChange && inputRef.current) {
174
- onSearch(value, "");
173
+ onSearchInternal(newSearchOption, "");
175
174
  setTimeout(() => {
176
175
  /* istanbul ignore next */
177
176
  if (inputRef.current) {
@@ -181,7 +180,7 @@ const SearchControl = ({
181
180
  }
182
181
  }, 0);
183
182
  } else {
184
- onSearch(value, cleanUpSearchValue(defaultValue));
183
+ onSearchInternal(newSearchOption, inputRef.current?.value);
185
184
  }
186
185
  };
187
186
 
@@ -216,7 +215,7 @@ const SearchControl = ({
216
215
 
217
216
  const onSubmit = event => {
218
217
  // using form submit instead of a keydown (with key=enter) to allow the 'enter key' event to be canceled elsewhere to avoid the submit event
219
- onSearch(searchOption, cleanUpSearchValue(inputRef.current?.value));
218
+ onSearchInternal(searchOption, inputRef.current?.value);
220
219
  event.preventDefault();
221
220
  };
222
221
 
@@ -239,7 +238,7 @@ const SearchControl = ({
239
238
  disabled={disabled}
240
239
  onClick={() => {
241
240
  inputRef.current.value = null;
242
- onSearch(searchOption);
241
+ onSearchInternal(searchOption);
243
242
  inputRef.current.focus();
244
243
  }}
245
244
  className={classes.clearButton}
@@ -260,7 +259,7 @@ const SearchControl = ({
260
259
  disabled={disabled}
261
260
  classes={{ root: classes.searchButton }}
262
261
  onClick={() => {
263
- onSearch(searchOption, inputRef.current.value);
262
+ onSearchInternal(searchOption, inputRef.current.value);
264
263
  }}
265
264
  >
266
265
  <Icon id="search" />