@northlight/ui 2.39.1 → 2.39.2
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
|
@@ -13822,7 +13822,7 @@ const FormattedNumberInput = (_a) => {
|
|
|
13822
13822
|
isPercentage = false,
|
|
13823
13823
|
onChange = identity,
|
|
13824
13824
|
value: valueProp,
|
|
13825
|
-
numberOfDecimals
|
|
13825
|
+
numberOfDecimals,
|
|
13826
13826
|
max = Infinity,
|
|
13827
13827
|
min = -Infinity,
|
|
13828
13828
|
inputLeftElement,
|
|
@@ -13842,6 +13842,7 @@ const FormattedNumberInput = (_a) => {
|
|
|
13842
13842
|
]);
|
|
13843
13843
|
const props = presetMap[preset];
|
|
13844
13844
|
const value = valueProp != null ? valueProp : "";
|
|
13845
|
+
const defaultNumberOfDecimals = defaultTo(2, numberOfDecimals);
|
|
13845
13846
|
const getNumberFormatValues = (number) => ({
|
|
13846
13847
|
floatValue: number,
|
|
13847
13848
|
formattedValue: numericFormatter(number.toString(), props),
|
|
@@ -13851,18 +13852,22 @@ const FormattedNumberInput = (_a) => {
|
|
|
13851
13852
|
if (isNil(value))
|
|
13852
13853
|
return;
|
|
13853
13854
|
const vNum = typeof value === "string" ? parseFloat(value) : value;
|
|
13855
|
+
if (isNil(numberOfDecimals) && !isPercentage) {
|
|
13856
|
+
onChange(getNumberFormatValues(vNum));
|
|
13857
|
+
return;
|
|
13858
|
+
}
|
|
13854
13859
|
const factor = isPercentage ? 100 : 1;
|
|
13855
13860
|
if (vNum * factor > max) {
|
|
13856
|
-
const newValue = roundToPrecision(max / factor,
|
|
13861
|
+
const newValue = roundToPrecision(max / factor, defaultNumberOfDecimals);
|
|
13857
13862
|
onChange(getNumberFormatValues(newValue));
|
|
13858
13863
|
}
|
|
13859
13864
|
if (vNum * factor < min) {
|
|
13860
|
-
const newValue = roundToPrecision(min / factor,
|
|
13865
|
+
const newValue = roundToPrecision(min / factor, defaultNumberOfDecimals);
|
|
13861
13866
|
onChange(getNumberFormatValues(newValue));
|
|
13862
13867
|
}
|
|
13863
13868
|
};
|
|
13864
13869
|
const onValueChangeHandler = (values, sourceInfo) => {
|
|
13865
|
-
const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100,
|
|
13870
|
+
const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, defaultNumberOfDecimals) : values.floatValue;
|
|
13866
13871
|
onChange(
|
|
13867
13872
|
__spreadProps$3(__spreadValues$k({}, values), {
|
|
13868
13873
|
floatValue: newFloatValue
|
|
@@ -13890,7 +13895,7 @@ const FormattedNumberInput = (_a) => {
|
|
|
13890
13895
|
},
|
|
13891
13896
|
onValueChange: onValueChangeHandler,
|
|
13892
13897
|
decimalScale: numberOfDecimals,
|
|
13893
|
-
value: isPercentage ? roundToPrecision(parseFloat(`${value != null ? value : 0}`) * 100,
|
|
13898
|
+
value: isPercentage ? roundToPrecision(parseFloat(`${value != null ? value : 0}`) * 100, defaultNumberOfDecimals) : value,
|
|
13894
13899
|
suffix: isPercentage ? "%" : ""
|
|
13895
13900
|
}, props), rest)
|
|
13896
13901
|
)
|