@monolith-forensics/monolith-ui 1.2.113 → 1.2.114

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.
@@ -310,14 +310,15 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
310
310
  const value = e.target.value;
311
311
  setInputValue(value || "");
312
312
  debouncedHandleChange(value);
313
- setIsOpen(true);
313
+ if (!isOpen)
314
+ setIsOpen(true);
314
315
  };
315
316
  const debouncedHandleChange = useDebouncedCallback((value) => {
316
317
  if (searchFn) {
317
318
  searchFn(value);
318
319
  }
319
320
  else {
320
- setSearchValue(value);
321
+ handleSearch(value);
321
322
  }
322
323
  if (allowCustomValue && value) {
323
324
  const existingItem = resolvedOptions.find((item) => item.value.toLowerCase() === value.toLowerCase());
@@ -358,6 +359,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
358
359
  };
359
360
  const handleChangeSelection = useCallback((option) => {
360
361
  !isControlled.current && setValueState(option);
362
+ setInputValue((option === null || option === void 0 ? void 0 : option.label) || "");
361
363
  onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value, option);
362
364
  }, [onChange]);
363
365
  const handleAddItem = useCallback((newItem) => {
@@ -398,6 +400,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
398
400
  newItem = filteredItems[index + 1];
399
401
  }
400
402
  !isControlled.current && setValueState(newItem);
403
+ setInputValue(newItem.label || "");
401
404
  onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
402
405
  return;
403
406
  }
@@ -419,6 +422,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
419
422
  newItem = filteredItems[index - 1];
420
423
  }
421
424
  !isControlled.current && setValueState(newItem);
425
+ setInputValue(newItem.label || "");
422
426
  onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
423
427
  return;
424
428
  }
@@ -442,6 +446,13 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
442
446
  setIsOpen(true);
443
447
  }
444
448
  };
449
+ const handleSearch = (value) => {
450
+ if (searchable) {
451
+ setSearchValue(value);
452
+ update();
453
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
454
+ }
455
+ };
445
456
  const referenceEl = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
446
457
  const contentWidth = ((_e = (_d = (_c = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getClientRects) === null || _c === void 0 ? void 0 : _c.call(referenceEl)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.width) || "100%";
447
458
  const scrollEl = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
@@ -471,10 +482,6 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
471
482
  document.addEventListener("click", close);
472
483
  return () => document.removeEventListener("click", close);
473
484
  }, [refs.floating, refs.reference, handleBlur]);
474
- // handle input value change
475
- useEffect(() => {
476
- setInputValue((_value === null || _value === void 0 ? void 0 : _value.label) || "");
477
- }, [_value]);
478
485
  // handle scroll item into view
479
486
  useEffect(() => {
480
487
  var _a, _b;
@@ -483,13 +490,6 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
483
490
  item.scrollIntoView({ block: "nearest" });
484
491
  }
485
492
  }, [_value]);
486
- // make calls to onSearch callback
487
- useEffect(() => {
488
- if (searchable) {
489
- update();
490
- onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
491
- }
492
- }, [searchValue]);
493
493
  useEffect(() => {
494
494
  if (bottomHeight < 250) {
495
495
  setPlacement("top-start");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.113",
3
+ "version": "1.2.114",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",