@monolith-forensics/monolith-ui 1.2.109 → 1.2.110

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.
@@ -206,7 +206,8 @@ DropDownProps = {}, debounceTime = 150, 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");
209
- const isControlled = value !== undefined;
209
+ // Determine controlled status only once at mount
210
+ const isControlled = useRef(value !== undefined);
210
211
  const resolvedOptions = data.map((item) => ({
211
212
  value: isObjectArray ? item.value : item,
212
213
  label: isObjectArray ? item.label : item,
@@ -231,7 +232,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
231
232
  * Get the correct value based on whether the component is controlled or not
232
233
  * if controlled, use the controlled value, otherwise use the resolved value
233
234
  */
234
- const _value = isControlled ? resolvedValue : valueState;
235
+ const _value = isControlled.current ? resolvedValue : valueState;
235
236
  const [inputValue, setInputValue] = useState(typeof _value === "object" ? (_value === null || _value === void 0 ? void 0 : _value.label) || "" : _value || "");
236
237
  const [isOpen, setIsOpen] = useState(false);
237
238
  const [searchValue, setSearchValue] = useState("");
@@ -342,7 +343,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
342
343
  setInputValue("");
343
344
  setIsOpen(false);
344
345
  handleChangeSelection(null);
345
- !isControlled && setValueState(null);
346
+ !isControlled.current && setValueState(null);
346
347
  setSearchValue("");
347
348
  searchFn === null || searchFn === void 0 ? void 0 : searchFn("");
348
349
  update();
@@ -356,7 +357,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
356
357
  setIsOpen(false);
357
358
  };
358
359
  const handleChangeSelection = useCallback((option) => {
359
- !isControlled && setValueState(option);
360
+ !isControlled.current && setValueState(option);
360
361
  onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value, option);
361
362
  }, [onChange]);
362
363
  const handleAddItem = useCallback((newItem) => {
@@ -396,7 +397,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
396
397
  else if (index < filteredItems.length - 1) {
397
398
  newItem = filteredItems[index + 1];
398
399
  }
399
- !isControlled && setValueState(newItem);
400
+ !isControlled.current && setValueState(newItem);
400
401
  onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
401
402
  return;
402
403
  }
@@ -417,7 +418,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
417
418
  else if (index > 0) {
418
419
  newItem = filteredItems[index - 1];
419
420
  }
420
- !isControlled && setValueState(newItem);
421
+ !isControlled.current && setValueState(newItem);
421
422
  onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
422
423
  return;
423
424
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.109",
3
+ "version": "1.2.110",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",