@monolith-forensics/monolith-ui 1.2.114 → 1.2.116

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.
@@ -202,7 +202,7 @@ const resolveValue = (value, data) => {
202
202
  return value;
203
203
  };
204
204
  const SelectBox = styled(({ className, data = [], placeholder = "Select...", arrow = true, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, label, description, required = false, error, openOnFocus = true, renderOption, actionComponent, focused, grouped, OptionTooltip, // Custom tooltip component for search menu items
205
- DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
205
+ DropDownProps = {}, debounceTime = 175, sort = false, disabled = false, }) => {
206
206
  var _a, _b, _c, _d, _e, _f, _g;
207
207
  const theme = useTheme();
208
208
  const isObjectArray = (_a = Object.keys((data === null || data === void 0 ? void 0 : data[0]) || {})) === null || _a === void 0 ? void 0 : _a.includes("label");
@@ -320,24 +320,25 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
320
320
  else {
321
321
  handleSearch(value);
322
322
  }
323
- if (allowCustomValue && value) {
324
- const existingItem = resolvedOptions.find((item) => item.value.toLowerCase() === value.toLowerCase());
323
+ if (!!allowCustomValue && !!value) {
324
+ const existingItem = resolvedOptions.find((item) => { var _a, _b, _c; return ((_b = (_a = item === null || item === void 0 ? void 0 : item.value) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === ((_c = value === null || value === void 0 ? void 0 : value.toLowerCase) === null || _c === void 0 ? void 0 : _c.call(value)); });
325
325
  if (existingItem)
326
326
  handleChangeSelection(existingItem);
327
- else
328
- handleChangeSelection(null);
327
+ else {
328
+ handleChangeSelection({
329
+ value: value,
330
+ label: value,
331
+ });
332
+ }
329
333
  }
330
334
  update();
331
335
  }, debounceTime);
332
336
  const handleBlur = () => {
333
- // add custom value if prop is set
334
- // and input value is not empty
335
- // and no item is selected
336
- if (allowCustomValue && !_value && !!inputValue) {
337
- handleAddItem(inputValue);
338
- }
339
337
  setIsOpen(false);
340
338
  setSearchValue("");
339
+ if (!allowCustomValue && !_value) {
340
+ setInputValue("");
341
+ }
341
342
  };
342
343
  const handleClear = (e) => {
343
344
  e.preventDefault();
@@ -363,10 +364,8 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
363
364
  onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value, option);
364
365
  }, [onChange]);
365
366
  const handleAddItem = useCallback((newItem) => {
366
- const newValue = { label: newItem, value: newItem };
367
- setCustomItems((prev) => [...prev, newValue]);
368
- handleChangeSelection(newValue);
369
- onItemAdded === null || onItemAdded === void 0 ? void 0 : onItemAdded(newValue);
367
+ setCustomItems((prev) => [...prev, newItem]);
368
+ onItemAdded === null || onItemAdded === void 0 ? void 0 : onItemAdded(newItem);
370
369
  }, [onItemAdded, isObjectArray, handleChangeSelection]);
371
370
  const handleKeyDown = (e) => {
372
371
  var _a;
@@ -428,14 +427,8 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
428
427
  }
429
428
  // Tab key
430
429
  if (e.key === "Tab") {
431
- if (allowCustomValue && !_value && !!currentInputValue) {
432
- handleAddItem(currentInputValue);
433
- setSearchValue("");
434
- }
435
- else if (!_value) {
436
- // clear input
430
+ if (!_value)
437
431
  setInputValue("");
438
- }
439
432
  setSearchValue("");
440
433
  setIsOpen(false);
441
434
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.114",
3
+ "version": "1.2.116",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",