@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.
@@ -14297,7 +14297,7 @@
14297
14297
  var _a2;
14298
14298
  const { isOpen, onToggle, onClose } = react.useDisclosure();
14299
14299
  const [inputValueState, setInputValueState] = React.useState(valueProp == null ? void 0 : valueProp.input);
14300
- const [selectOptionState, setselectOptionState] = React.useState((_a2 = valueProp == null ? void 0 : valueProp.option) != null ? _a2 : options[0]);
14300
+ const [selectOptionState, setselectOptionState] = React.useState(valueProp == null ? void 0 : valueProp.option);
14301
14301
  const [enableSelectInput, setEnableSelectInput] = React.useState(false);
14302
14302
  const isInputValueControlled = typeof (valueProp == null ? void 0 : valueProp.input) !== "undefined";
14303
14303
  const inputValue = isInputValueControlled ? valueProp.input : inputValueState;
@@ -14305,7 +14305,10 @@
14305
14305
  const selectOption = isOptionControlled ? valueProp.option : selectOptionState;
14306
14306
  const buttonRef = React.useRef();
14307
14307
  const selectRef = React.useRef();
14308
- const getNewValue = (option, input) => ramda.is(Number, input) ? { input: Number(input), option } : { option };
14308
+ const getNewValue = (option, input) => {
14309
+ const newValueOption = option != null ? option : options[0];
14310
+ return ramda.is(Number, input) ? { input: Number(input), option: newValueOption } : { option: newValueOption };
14311
+ };
14309
14312
  const handleInputChange = (newInputvalue) => {
14310
14313
  const newValue = getNewValue(selectOption, newInputvalue);
14311
14314
  setInputValueState(newValue.input);
@@ -14339,10 +14342,20 @@
14339
14342
  }
14340
14343
  }, [enableSelectInput]);
14341
14344
  React.useEffect(() => {
14342
- if (!ramda.is(Number, inputValue) && defaultToZeroIfEmpty) {
14343
- handleInputChange(clamp(min, max, 0));
14345
+ const needsToCorrectOption = !selectOption;
14346
+ const needsToCorrectInput = !ramda.is(Number, inputValue) && defaultToZeroIfEmpty;
14347
+ const option = needsToCorrectOption ? options[0] : selectOption;
14348
+ const input = needsToCorrectInput ? clamp(min, max, 0) : inputValue;
14349
+ if (needsToCorrectOption) {
14350
+ setselectOptionState(option);
14351
+ }
14352
+ if (needsToCorrectInput) {
14353
+ setInputValueState(input);
14354
+ }
14355
+ if (needsToCorrectOption || needsToCorrectInput) {
14356
+ onChange == null ? void 0 : onChange(getNewValue(option, input));
14344
14357
  }
14345
- }, [valueProp == null ? void 0 : valueProp.input, defaultToZeroIfEmpty]);
14358
+ }, [inputValue, defaultToZeroIfEmpty]);
14346
14359
  return /* @__PURE__ */ React.createElement(react.InputGroup, null, /* @__PURE__ */ React.createElement(
14347
14360
  FormattedNumberInput,
14348
14361
  __spreadValues$1({
@@ -14375,7 +14388,7 @@
14375
14388
  flexShrink: "0",
14376
14389
  height: "100%"
14377
14390
  },
14378
- selectOption.label
14391
+ (_a2 = selectOption == null ? void 0 : selectOption.label) != null ? _a2 : ""
14379
14392
  )
14380
14393
  ), /* @__PURE__ */ React.createElement(react.Box, { position: "absolute", width: "100%" }, /* @__PURE__ */ React.createElement(
14381
14394
  Select,