@oliasoft-open-source/react-ui-library 10.6.2 → 10.6.4-beta-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.
- package/dist/index.js +38 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4833,14 +4833,20 @@ var NumberInput = ({ name, placeholder = "", disabled = false, error = false, le
|
|
|
4833
4833
|
const stringName = getStringName$1(name);
|
|
4834
4834
|
const { valid, errors } = validateInputValue(displayValue);
|
|
4835
4835
|
const firstError = errors && errors.length && !disableInternalErrorValidationMessages ? errors[0] : null;
|
|
4836
|
-
|
|
4837
|
-
const nextValue = cosmeticRound(toString(value));
|
|
4838
|
-
if (toNum(displayValue) !== toNum(nextValue)) setDisplayValue(nextValue);
|
|
4839
|
-
}, [
|
|
4836
|
+
const [previousInputs, setPreviousInputs] = useState({
|
|
4840
4837
|
value,
|
|
4841
4838
|
enableCosmeticRounding,
|
|
4842
4839
|
enableDisplayRounding
|
|
4843
|
-
|
|
4840
|
+
});
|
|
4841
|
+
if (!Object.is(previousInputs.value, value) || previousInputs.enableCosmeticRounding !== enableCosmeticRounding || previousInputs.enableDisplayRounding !== enableDisplayRounding) {
|
|
4842
|
+
setPreviousInputs({
|
|
4843
|
+
value,
|
|
4844
|
+
enableCosmeticRounding,
|
|
4845
|
+
enableDisplayRounding
|
|
4846
|
+
});
|
|
4847
|
+
const nextValue = cosmeticRound(toString(value));
|
|
4848
|
+
if (toNum(displayValue) !== toNum(nextValue)) setDisplayValue(nextValue);
|
|
4849
|
+
}
|
|
4844
4850
|
useEffect(() => {
|
|
4845
4851
|
if ((disableValidationOnFocus ? true : !focus) && !valid) validationCallback(stringName, firstError);
|
|
4846
4852
|
else validationCallback(stringName, null);
|
|
@@ -4958,15 +4964,6 @@ var useRunAfterUpdate = () => {
|
|
|
4958
4964
|
return runAfterUpdate;
|
|
4959
4965
|
};
|
|
4960
4966
|
//#endregion
|
|
4961
|
-
//#region src/components/unit-input/hooks/use-previous.ts
|
|
4962
|
-
var usePrevious = (value) => {
|
|
4963
|
-
const ref = useRef(void 0);
|
|
4964
|
-
useEffect(() => {
|
|
4965
|
-
ref.current = value;
|
|
4966
|
-
}, [value]);
|
|
4967
|
-
return ref.current;
|
|
4968
|
-
};
|
|
4969
|
-
//#endregion
|
|
4970
4967
|
//#region src/helpers/get-preferred-unit.ts
|
|
4971
4968
|
/**
|
|
4972
4969
|
* Retrieves the preferred unit for a given quantity from a specified unit template or defaults to a standard unit if not found.
|
|
@@ -5158,7 +5155,6 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
|
|
|
5158
5155
|
]);
|
|
5159
5156
|
const knownUnit = isKnownUnit(value, preferredUnit);
|
|
5160
5157
|
const initDisplayUnit = initUnit || preferredUnit || propUnit;
|
|
5161
|
-
const previousInitUnit = usePrevious(initDisplayUnit);
|
|
5162
5158
|
const { value: convertedValue } = safeConvertValue({
|
|
5163
5159
|
value,
|
|
5164
5160
|
toUnit: initDisplayUnit,
|
|
@@ -5166,12 +5162,9 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
|
|
|
5166
5162
|
defaultFromUnit: propUnit,
|
|
5167
5163
|
doNotConvertValue: noConversion
|
|
5168
5164
|
});
|
|
5169
|
-
const [displayLayer, setDisplayLayer] = useState(
|
|
5170
|
-
value: convertedValue,
|
|
5165
|
+
const [displayLayer, setDisplayLayer] = useState({
|
|
5166
|
+
value: convertedValue !== "" ? convertedValue : propValue,
|
|
5171
5167
|
unit: initDisplayUnit
|
|
5172
|
-
} : {
|
|
5173
|
-
value: propValue,
|
|
5174
|
-
unit: propUnit
|
|
5175
5168
|
});
|
|
5176
5169
|
const derivedAllowEmpty = allowEmpty || (displayLayer === null || displayLayer === void 0 ? void 0 : displayLayer.value) === void 0;
|
|
5177
5170
|
const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
|
|
@@ -5233,11 +5226,23 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
|
|
|
5233
5226
|
});
|
|
5234
5227
|
if (onSwitchUnit) onSwitchUnit(nextUnit);
|
|
5235
5228
|
};
|
|
5236
|
-
|
|
5229
|
+
const [previousInputs, setPreviousInputs] = useState({
|
|
5230
|
+
initDisplayUnit,
|
|
5231
|
+
value,
|
|
5232
|
+
error,
|
|
5233
|
+
shouldLinkAutomaticly
|
|
5234
|
+
});
|
|
5235
|
+
if (previousInputs.initDisplayUnit !== initDisplayUnit || previousInputs.value !== value || previousInputs.error !== error || previousInputs.shouldLinkAutomaticly !== shouldLinkAutomaticly) {
|
|
5236
|
+
setPreviousInputs({
|
|
5237
|
+
initDisplayUnit,
|
|
5238
|
+
value,
|
|
5239
|
+
error,
|
|
5240
|
+
shouldLinkAutomaticly
|
|
5241
|
+
});
|
|
5237
5242
|
let newValue;
|
|
5238
5243
|
let newUnit = "";
|
|
5239
5244
|
if (initDisplayUnit) {
|
|
5240
|
-
if (
|
|
5245
|
+
if (previousInputs.initDisplayUnit !== initDisplayUnit) {
|
|
5241
5246
|
const { value: resultValue } = safeConvertValue({
|
|
5242
5247
|
value,
|
|
5243
5248
|
toUnit: initDisplayUnit,
|
|
@@ -5266,6 +5271,8 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
|
|
|
5266
5271
|
value: newValue,
|
|
5267
5272
|
unit: newUnit
|
|
5268
5273
|
});
|
|
5274
|
+
}
|
|
5275
|
+
useEffect(() => {
|
|
5269
5276
|
if (predefinedOptions && foundPredefinedMenuOption && shouldLinkAutomaticly) setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
|
|
5270
5277
|
else setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
|
|
5271
5278
|
}, [
|
|
@@ -10829,6 +10836,15 @@ var TreeTable = ({ allowParentReassignment, autoOpenActiveItems = false, canDrop
|
|
|
10829
10836
|
});
|
|
10830
10837
|
};
|
|
10831
10838
|
//#endregion
|
|
10839
|
+
//#region src/components/unit-input/hooks/use-previous.ts
|
|
10840
|
+
var usePrevious = (value) => {
|
|
10841
|
+
const ref = useRef(void 0);
|
|
10842
|
+
useEffect(() => {
|
|
10843
|
+
ref.current = value;
|
|
10844
|
+
}, [value]);
|
|
10845
|
+
return ref.current;
|
|
10846
|
+
};
|
|
10847
|
+
//#endregion
|
|
10832
10848
|
//#region src/translations/enums.ts
|
|
10833
10849
|
var ConfigKeyType = Object.freeze({
|
|
10834
10850
|
Translations: "translations",
|
package/package.json
CHANGED