@northlight/ui 2.36.9 → 2.36.10
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.
package/dist/es/northlight.js
CHANGED
|
@@ -13485,10 +13485,8 @@ const FormattedNumberInput = (_a) => {
|
|
|
13485
13485
|
"inputRightElement",
|
|
13486
13486
|
"onBlur"
|
|
13487
13487
|
]);
|
|
13488
|
-
const [valueState, setValueState] = useState(valueProp);
|
|
13489
|
-
const isControlled = typeof valueProp !== "undefined";
|
|
13490
|
-
const value = isControlled ? valueProp : valueState;
|
|
13491
13488
|
const props = presetMap[preset];
|
|
13489
|
+
const value = valueProp != null ? valueProp : "";
|
|
13492
13490
|
const getNumberFormatValues = (number) => ({
|
|
13493
13491
|
floatValue: number,
|
|
13494
13492
|
formattedValue: numericFormatter(number.toString(), props),
|
|
@@ -13501,18 +13499,15 @@ const FormattedNumberInput = (_a) => {
|
|
|
13501
13499
|
const factor = isPercentage ? 100 : 1;
|
|
13502
13500
|
if (vNum * factor > max) {
|
|
13503
13501
|
const newValue = roundToPrecision(max / factor, numberOfDecimals);
|
|
13504
|
-
setValueState(newValue);
|
|
13505
13502
|
onChange(getNumberFormatValues(newValue));
|
|
13506
13503
|
}
|
|
13507
13504
|
if (vNum * factor < min) {
|
|
13508
13505
|
const newValue = roundToPrecision(min / factor, numberOfDecimals);
|
|
13509
|
-
setValueState(newValue);
|
|
13510
13506
|
onChange(getNumberFormatValues(newValue));
|
|
13511
13507
|
}
|
|
13512
13508
|
};
|
|
13513
13509
|
const onValueChangeHandler = (values, sourceInfo) => {
|
|
13514
13510
|
const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, numberOfDecimals) : values.floatValue;
|
|
13515
|
-
setValueState(newFloatValue);
|
|
13516
13511
|
onChange(
|
|
13517
13512
|
__spreadProps$3(__spreadValues$k({}, values), {
|
|
13518
13513
|
floatValue: newFloatValue
|
|
@@ -14748,13 +14743,9 @@ const ComboPicker = (_a) => {
|
|
|
14748
14743
|
]);
|
|
14749
14744
|
var _a2, _b2, _c;
|
|
14750
14745
|
const { isOpen, onToggle, onClose } = useDisclosure();
|
|
14751
|
-
const [
|
|
14752
|
-
const [
|
|
14746
|
+
const [inputValue, setInputValue] = useState(valueProp == null ? void 0 : valueProp.input);
|
|
14747
|
+
const [selectOption, setSelectOption] = useState(valueProp == null ? void 0 : valueProp.option);
|
|
14753
14748
|
const [enableSelectInput, setEnableSelectInput] = useState(false);
|
|
14754
|
-
const isInputValueControlled = typeof (valueProp == null ? void 0 : valueProp.input) !== "undefined";
|
|
14755
|
-
const inputValue = isInputValueControlled ? valueProp.input : inputValueState;
|
|
14756
|
-
const isOptionControlled = typeof (valueProp == null ? void 0 : valueProp.option) !== "undefined";
|
|
14757
|
-
const selectOption = isOptionControlled ? valueProp.option : selectOptionState;
|
|
14758
14749
|
const buttonRef = useRef();
|
|
14759
14750
|
const selectRef = useRef();
|
|
14760
14751
|
const getNewValue = (option, input) => {
|
|
@@ -14762,8 +14753,7 @@ const ComboPicker = (_a) => {
|
|
|
14762
14753
|
return is(Number, input) ? { input: Number(input), option: newValueOption } : { option: newValueOption };
|
|
14763
14754
|
};
|
|
14764
14755
|
const handleInputChange = (newInputvalue) => {
|
|
14765
|
-
const newValue = getNewValue(
|
|
14766
|
-
setInputValueState(newValue.input);
|
|
14756
|
+
const newValue = getNewValue(valueProp == null ? void 0 : valueProp.option, newInputvalue);
|
|
14767
14757
|
onChange == null ? void 0 : onChange(newValue);
|
|
14768
14758
|
};
|
|
14769
14759
|
const handleSelectClose = () => {
|
|
@@ -14775,8 +14765,7 @@ const ComboPicker = (_a) => {
|
|
|
14775
14765
|
};
|
|
14776
14766
|
const handleSelectChange = (selectedOption) => {
|
|
14777
14767
|
if (selectedOption) {
|
|
14778
|
-
|
|
14779
|
-
onChange == null ? void 0 : onChange(getNewValue(selectedOption, inputValue));
|
|
14768
|
+
onChange == null ? void 0 : onChange(getNewValue(selectedOption, valueProp == null ? void 0 : valueProp.input));
|
|
14780
14769
|
if (isOpen) {
|
|
14781
14770
|
handleSelectClose();
|
|
14782
14771
|
}
|
|
@@ -14794,20 +14783,13 @@ const ComboPicker = (_a) => {
|
|
|
14794
14783
|
}
|
|
14795
14784
|
}, [enableSelectInput]);
|
|
14796
14785
|
useEffect(() => {
|
|
14797
|
-
|
|
14798
|
-
const
|
|
14799
|
-
const
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
if (needsToCorrectInput) {
|
|
14805
|
-
setInputValueState(input);
|
|
14806
|
-
}
|
|
14807
|
-
if (needsToCorrectOption || needsToCorrectInput) {
|
|
14808
|
-
onChange == null ? void 0 : onChange(getNewValue(option, input));
|
|
14809
|
-
}
|
|
14810
|
-
}, [inputValue, defaultToZeroIfEmpty]);
|
|
14786
|
+
var _a3, _b3;
|
|
14787
|
+
const option = (_a3 = valueProp == null ? void 0 : valueProp.option) != null ? _a3 : options[0];
|
|
14788
|
+
const input = defaultToZeroIfEmpty ? (_b3 = valueProp == null ? void 0 : valueProp.input) != null ? _b3 : 0 : valueProp == null ? void 0 : valueProp.input;
|
|
14789
|
+
setSelectOption(option);
|
|
14790
|
+
setInputValue(input);
|
|
14791
|
+
onChange == null ? void 0 : onChange(getNewValue(option, input));
|
|
14792
|
+
}, [valueProp == null ? void 0 : valueProp.input, valueProp == null ? void 0 : valueProp.option, defaultToZeroIfEmpty, options]);
|
|
14811
14793
|
const buttonWidth = (_b2 = (_a2 = buttonRef.current) == null ? void 0 : _a2.offsetWidth) != null ? _b2 : 0;
|
|
14812
14794
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
14813
14795
|
FormattedNumberInput,
|