@oliasoft-open-source/react-ui-library 10.6.2 → 10.6.3

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -17
  2. 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
- useEffect(() => {
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,
@@ -5233,11 +5229,23 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
5233
5229
  });
5234
5230
  if (onSwitchUnit) onSwitchUnit(nextUnit);
5235
5231
  };
5236
- useEffect(() => {
5232
+ const [previousInputs, setPreviousInputs] = useState({
5233
+ initDisplayUnit,
5234
+ value,
5235
+ error,
5236
+ shouldLinkAutomaticly
5237
+ });
5238
+ if (previousInputs.initDisplayUnit !== initDisplayUnit || previousInputs.value !== value || previousInputs.error !== error || previousInputs.shouldLinkAutomaticly !== shouldLinkAutomaticly) {
5239
+ setPreviousInputs({
5240
+ initDisplayUnit,
5241
+ value,
5242
+ error,
5243
+ shouldLinkAutomaticly
5244
+ });
5237
5245
  let newValue;
5238
5246
  let newUnit = "";
5239
5247
  if (initDisplayUnit) {
5240
- if (previousInitUnit !== initDisplayUnit) {
5248
+ if (previousInputs.initDisplayUnit !== initDisplayUnit) {
5241
5249
  const { value: resultValue } = safeConvertValue({
5242
5250
  value,
5243
5251
  toUnit: initDisplayUnit,
@@ -5266,6 +5274,8 @@ var UnitInput = ({ name, placeholder = "", disabled = false, disabledUnit = fals
5266
5274
  value: newValue,
5267
5275
  unit: newUnit
5268
5276
  });
5277
+ }
5278
+ useEffect(() => {
5269
5279
  if (predefinedOptions && foundPredefinedMenuOption && shouldLinkAutomaticly) setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
5270
5280
  else setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
5271
5281
  }, [
@@ -10829,6 +10839,15 @@ var TreeTable = ({ allowParentReassignment, autoOpenActiveItems = false, canDrop
10829
10839
  });
10830
10840
  };
10831
10841
  //#endregion
10842
+ //#region src/components/unit-input/hooks/use-previous.ts
10843
+ var usePrevious = (value) => {
10844
+ const ref = useRef(void 0);
10845
+ useEffect(() => {
10846
+ ref.current = value;
10847
+ }, [value]);
10848
+ return ref.current;
10849
+ };
10850
+ //#endregion
10832
10851
  //#region src/translations/enums.ts
10833
10852
  var ConfigKeyType = Object.freeze({
10834
10853
  Translations: "translations",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "10.6.2",
3
+ "version": "10.6.3",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {