@northlight/ui 2.32.2 → 2.32.4

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.
@@ -14335,7 +14335,7 @@ const ComboPicker = (_a) => {
14335
14335
  var _a2;
14336
14336
  const { isOpen, onToggle, onClose } = useDisclosure();
14337
14337
  const [inputValueState, setInputValueState] = useState(valueProp == null ? void 0 : valueProp.input);
14338
- const [selectOptionState, setselectOptionState] = useState((_a2 = valueProp == null ? void 0 : valueProp.option) != null ? _a2 : options[0]);
14338
+ const [selectOptionState, setselectOptionState] = useState(valueProp == null ? void 0 : valueProp.option);
14339
14339
  const [enableSelectInput, setEnableSelectInput] = useState(false);
14340
14340
  const isInputValueControlled = typeof (valueProp == null ? void 0 : valueProp.input) !== "undefined";
14341
14341
  const inputValue = isInputValueControlled ? valueProp.input : inputValueState;
@@ -14343,7 +14343,10 @@ const ComboPicker = (_a) => {
14343
14343
  const selectOption = isOptionControlled ? valueProp.option : selectOptionState;
14344
14344
  const buttonRef = useRef();
14345
14345
  const selectRef = useRef();
14346
- const getNewValue = (option, input) => is(Number, input) ? { input: Number(input), option } : { option };
14346
+ const getNewValue = (option, input) => {
14347
+ const newValueOption = option != null ? option : options[0];
14348
+ return is(Number, input) ? { input: Number(input), option: newValueOption } : { option: newValueOption };
14349
+ };
14347
14350
  const handleInputChange = (newInputvalue) => {
14348
14351
  const newValue = getNewValue(selectOption, newInputvalue);
14349
14352
  setInputValueState(newValue.input);
@@ -14377,10 +14380,20 @@ const ComboPicker = (_a) => {
14377
14380
  }
14378
14381
  }, [enableSelectInput]);
14379
14382
  useEffect(() => {
14380
- if (!is(Number, inputValue) && defaultToZeroIfEmpty) {
14381
- handleInputChange(clamp(min, max, 0));
14383
+ const needsToCorrectOption = !selectOption;
14384
+ const needsToCorrectInput = !is(Number, inputValue) && defaultToZeroIfEmpty;
14385
+ const option = needsToCorrectOption ? options[0] : selectOption;
14386
+ const input = needsToCorrectInput ? clamp(min, max, 0) : inputValue;
14387
+ if (needsToCorrectOption) {
14388
+ setselectOptionState(option);
14389
+ }
14390
+ if (needsToCorrectInput) {
14391
+ setInputValueState(input);
14392
+ }
14393
+ if (needsToCorrectOption || needsToCorrectInput) {
14394
+ onChange == null ? void 0 : onChange(getNewValue(option, input));
14382
14395
  }
14383
- }, [valueProp == null ? void 0 : valueProp.input, defaultToZeroIfEmpty]);
14396
+ }, [inputValue, defaultToZeroIfEmpty]);
14384
14397
  return /* @__PURE__ */ React.createElement(InputGroup, null, /* @__PURE__ */ React.createElement(
14385
14398
  FormattedNumberInput,
14386
14399
  __spreadValues$1({
@@ -14413,7 +14426,7 @@ const ComboPicker = (_a) => {
14413
14426
  flexShrink: "0",
14414
14427
  height: "100%"
14415
14428
  },
14416
- selectOption.label
14429
+ (_a2 = selectOption == null ? void 0 : selectOption.label) != null ? _a2 : ""
14417
14430
  )
14418
14431
  ), /* @__PURE__ */ React.createElement(Box, { position: "absolute", width: "100%" }, /* @__PURE__ */ React.createElement(
14419
14432
  Select,