@northlight/ui 2.31.0 → 2.31.1

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.
@@ -14253,18 +14253,18 @@
14253
14253
  "isDisabled",
14254
14254
  "isReadOnly"
14255
14255
  ]);
14256
+ var _a2;
14256
14257
  const { isOpen, onToggle, onClose } = react.useDisclosure();
14257
- const [inputValue, setInputValue] = React.useState(value ? value.input : 0);
14258
- const [selectOption, setSelectOption] = React.useState(value ? value.option : options[0]);
14258
+ const [inputValue, setInputValue] = React.useState(value == null ? void 0 : value.input);
14259
+ const [selectOption, setSelectOption] = React.useState((_a2 = value == null ? void 0 : value.option) != null ? _a2 : options[0]);
14259
14260
  const [enableSelectInput, setEnableSelectInput] = React.useState(false);
14260
14261
  const buttonRef = React.useRef();
14261
14262
  const selectRef = React.useRef();
14263
+ const getNewValue = (option, input) => input ? { input: Number(input), option } : { option };
14262
14264
  const handleInputChange = (newInputvalue) => {
14263
- setInputValue(Number(newInputvalue.floatValue));
14264
- onChange == null ? void 0 : onChange({
14265
- input: Number(newInputvalue.floatValue),
14266
- option: selectOption
14267
- });
14265
+ const newValue = getNewValue(selectOption, newInputvalue.floatValue);
14266
+ setInputValue(newValue.input);
14267
+ onChange == null ? void 0 : onChange(newValue);
14268
14268
  };
14269
14269
  const handleSelectClose = () => {
14270
14270
  if (buttonRef.current) {
@@ -14276,10 +14276,7 @@
14276
14276
  const handleSelectChange = (selectedOption) => {
14277
14277
  if (selectedOption) {
14278
14278
  setSelectOption(selectedOption);
14279
- onChange == null ? void 0 : onChange({
14280
- input: inputValue,
14281
- option: selectedOption
14282
- });
14279
+ onChange == null ? void 0 : onChange(getNewValue(selectedOption, inputValue));
14283
14280
  handleSelectClose();
14284
14281
  }
14285
14282
  };