@oliasoft-open-source/react-ui-library 4.12.4 → 4.12.5

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.d.ts CHANGED
@@ -1579,6 +1579,7 @@ export declare interface IUnitInputProps {
1579
1579
  convertBackToStorageUnit?: boolean;
1580
1580
  enableCosmeticRounding?: boolean;
1581
1581
  enableDisplayRounding?: boolean;
1582
+ roundDisplayValue?: (args: TStringOrNumber) => TStringOrNumber;
1582
1583
  }
1583
1584
 
1584
1585
  declare interface IUnitTable extends Omit<ITableProps['table'], 'rows'> {
@@ -1872,7 +1873,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1872
1873
 
1873
1874
  declare type UnitContextType = any;
1874
1875
 
1875
- export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitInputProps) => JSX_2.Element;
1876
+ export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
1876
1877
 
1877
1878
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1878
1879
 
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import * as PropTypes from "prop-types";
16
16
  import PropTypes__default from "prop-types";
17
17
  import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
18
18
  import { noop as noop$3, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isEqual as isEqual$4 } from "lodash";
19
- import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, roundToFixed, validateNumber, cleanNumStr, stripLeadingZeros, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
19
+ import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, validateNumber, cleanNumStr, stripLeadingZeros, roundToFixed, roundByMagnitude, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
20
20
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
21
21
  function getDefaultExportFromCjs(x2) {
22
22
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -55742,8 +55742,9 @@ const NumberInput = ({
55742
55742
  setFocus(false);
55743
55743
  onBlur(evt);
55744
55744
  };
55745
+ const defaultDisplayRound = (value2) => isInTable2 ? roundToFixed(value2, 2) : roundByMagnitude(value2, 4);
55745
55746
  const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
55746
- const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : roundToFixed(displayValue, 2) : displayValue;
55747
+ const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : defaultDisplayRound(value) : displayValue;
55747
55748
  return /* @__PURE__ */ jsx(
55748
55749
  KeyboardEventHandler,
55749
55750
  {
@@ -70296,7 +70297,8 @@ const UnitInput = ({
70296
70297
  autoValue,
70297
70298
  convertBackToStorageUnit = false,
70298
70299
  enableCosmeticRounding = true,
70299
- enableDisplayRounding = false
70300
+ enableDisplayRounding = false,
70301
+ roundDisplayValue
70300
70302
  }) => {
70301
70303
  const context2 = useUnitContext();
70302
70304
  const runAfterUpdate = useRunAfterUpdate();
@@ -70563,6 +70565,7 @@ const UnitInput = ({
70563
70565
  validationCallback: (_name, error22) => validationCallback(stringName, error22),
70564
70566
  enableCosmeticRounding,
70565
70567
  enableDisplayRounding,
70568
+ roundDisplayValue,
70566
70569
  groupOrder: predefinedOptions ? "middle" : "first",
70567
70570
  disableInternalErrorValidationMessages,
70568
70571
  small: small2