@oliasoft-open-source/react-ui-library 4.8.0-beta-6 → 4.9.0-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.
Files changed (64) hide show
  1. package/dist/index.d.ts +9 -4
  2. package/dist/index.js +87 -72
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-7n9iRx7S.js → Color-KGDBMAHA-nHvSq78M.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-C57lSAQP.js → DocsRenderer-PKQXORMH-C1krXrOf.js} +1 -1
  6. package/dist/storybook/assets/{accordion.stories-DxcPNOgs.js → accordion.stories-kLk1OtZZ.js} +2 -2
  7. package/dist/storybook/assets/{afe.stories-Be4Zi8Qk.js → afe.stories-DFQsvqIV.js} +2 -2
  8. package/dist/storybook/assets/{buttons-and-links-CAoQC4F0.js → buttons-and-links-DC-E4soa.js} +1 -1
  9. package/dist/storybook/assets/{casing-loads.stories-C4UBI5Xe.js → casing-loads.stories-B2lND_PU.js} +2 -2
  10. package/dist/storybook/assets/{cell.stories-BSxt9Uy7.js → cell.stories-BVDrv2SU.js} +2 -2
  11. package/dist/storybook/assets/{chunk-HLWAVYOI-DrFFqdeg.js → chunk-HLWAVYOI-DX3eyNf5.js} +1 -1
  12. package/dist/storybook/assets/{color-Cj3Jrfqu.js → color-BgW0SkoL.js} +1 -1
  13. package/dist/storybook/assets/footer.stories-BVXSVjq1.js +3 -0
  14. package/dist/storybook/assets/form.stories-BrUnmw7R.js +49 -0
  15. package/dist/storybook/assets/{formation.stories-DdQ8gl9A.js → formation.stories-DmecxRaM.js} +2 -2
  16. package/dist/storybook/assets/iframe-DHWiHrZY.js +2 -0
  17. package/dist/storybook/assets/{index-C2sXcduN.js → index-B7q2KU2k.js} +1 -1
  18. package/dist/storybook/assets/{index-DugqEjCI.js → index-BRAKCNI8.js} +4 -4
  19. package/dist/storybook/assets/{input-group.stories-Bqx8op1f.js → input-group.stories-CElwRt3p.js} +2 -2
  20. package/dist/storybook/assets/{input-validation-f5uEIzl2.js → input-validation-CD_0XD31.js} +2 -2
  21. package/dist/storybook/assets/{inputs-CeRKE4Lz.js → inputs-DmKjdzn7.js} +2 -2
  22. package/dist/storybook/assets/{layout-forms-BxYHgSuN.js → layout-forms-BxdMnma9.js} +4 -4
  23. package/dist/storybook/assets/{layout-general-GRQFrkfR.js → layout-general-DTuKIl0f.js} +1 -1
  24. package/dist/storybook/assets/{modal.stories-BcqAhYEy.js → modal.stories-LhoWfDE6.js} +2 -2
  25. package/dist/storybook/assets/number-input-DBZIl9dz.js +16 -0
  26. package/dist/storybook/assets/number-input.stories-BRQWeYF6.js +166 -0
  27. package/dist/storybook/assets/{padding-and-spacing-D6XbiS3K.js → padding-and-spacing-pWMUN6u_.js} +1 -1
  28. package/dist/storybook/assets/{pagination-D6pYWeQM.js → pagination-CLt-kUlx.js} +1 -1
  29. package/dist/storybook/assets/{pagination.stories-ItfGvzb-.js → pagination.stories-CTRM0Xou.js} +2 -2
  30. package/dist/storybook/assets/popover.stories-CGm0M5fv.js +10 -0
  31. package/dist/storybook/assets/{preview-C0zm9b3L.js → preview-BCA8OXOK.js} +1 -1
  32. package/dist/storybook/assets/{preview-DGngQ_J0.js → preview-Ddw3AHiS.js} +2 -2
  33. package/dist/storybook/assets/{projects.stories-Co_WnKSx.js → projects.stories-BQswWVCx.js} +2 -2
  34. package/dist/storybook/assets/{radio-button-C4ljBRED.js → radio-button-DmDuw4DA.js} +1 -1
  35. package/dist/storybook/assets/{radio-button.stories-BzyW2CtK.js → radio-button.stories-5gvV0LD0.js} +2 -2
  36. package/dist/storybook/assets/{reservoirs.stories-FQuUA3DK.js → reservoirs.stories-B12tIrmZ.js} +2 -2
  37. package/dist/storybook/assets/{rich-text-input.stories-B5srzxDu.js → rich-text-input.stories-hAHCnDHk.js} +3 -3
  38. package/dist/storybook/assets/{row.stories-C1XgB_82.js → row.stories-BO2s7oph.js} +2 -2
  39. package/dist/storybook/assets/{select-V2ZNp3Pv.js → select-DnRuRG_N.js} +2 -2
  40. package/dist/storybook/assets/select.input-D0UkAPd9.js +1 -0
  41. package/dist/storybook/assets/{select.stories-CV9h5z0E.js → select.stories-B9w9ONzj.js} +2 -2
  42. package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-umpPYjkq.js} +2 -2
  43. package/dist/storybook/assets/{table-iMn5OU9-.js → table-CB6btQu9.js} +1 -1
  44. package/dist/storybook/assets/{table.stories-CIsR2u2M.js → table.stories-CvHvaYMC.js} +2 -2
  45. package/dist/storybook/assets/{tabs-BoToLVEP.js → tabs-C3NG6m9W.js} +1 -1
  46. package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +30 -0
  47. package/dist/storybook/assets/{title.stories-BhbnN3vD.js → title.stories-DYXG2_x-.js} +2 -2
  48. package/dist/storybook/assets/unit-input.stories-DRP-nDdh.js +380 -0
  49. package/dist/storybook/assets/unit-table.stories-DiER-CMn.js +152 -0
  50. package/dist/storybook/iframe.html +1 -1
  51. package/dist/storybook/index.json +1 -1
  52. package/dist/storybook/project.json +1 -1
  53. package/package.json +3 -3
  54. package/dist/storybook/assets/footer.stories-CMQkKB8p.js +0 -3
  55. package/dist/storybook/assets/form.stories-CX1WxUVL.js +0 -49
  56. package/dist/storybook/assets/helpers-JJxzGegQ.js +0 -1
  57. package/dist/storybook/assets/iframe-BGmrP0sW.js +0 -2
  58. package/dist/storybook/assets/number-input-CEoWDcRg.js +0 -16
  59. package/dist/storybook/assets/number-input.stories-UJVpFqsh.js +0 -110
  60. package/dist/storybook/assets/popover.stories-B4sQDryP.js +0 -10
  61. package/dist/storybook/assets/select.input-CJed_LLR.js +0 -1
  62. package/dist/storybook/assets/tabs.stories-B52iEaHf.js +0 -30
  63. package/dist/storybook/assets/unit-input.stories-DCAfSaYS.js +0 -316
  64. package/dist/storybook/assets/unit-table.stories-M7pzrM4S.js +0 -152
package/dist/index.d.ts CHANGED
@@ -904,8 +904,9 @@ declare interface INumberInputCell extends TCommonCell {
904
904
  left?: boolean;
905
905
  validationCallback?: TEmpty;
906
906
  allowEmpty?: boolean;
907
+ enableCosmeticRounding: boolean;
907
908
  enableDisplayRounding: boolean;
908
- roundDisplayValue: (value: TStringNumberNull) => TStringNumberNull;
909
+ roundDisplayValue: (value: TStringOrNumber) => TStringOrNumber;
909
910
  }
910
911
 
911
912
  export declare interface INumberInputProps {
@@ -932,8 +933,9 @@ export declare interface INumberInputProps {
932
933
  allowEmpty?: boolean;
933
934
  isInTable?: boolean;
934
935
  groupOrder?: any;
936
+ enableCosmeticRounding?: boolean;
935
937
  enableDisplayRounding?: boolean;
936
- roundDisplayValue?: (args: TStringNumberNull) => TStringNumberNull;
938
+ roundDisplayValue?: (args: TStringOrNumber) => TStringOrNumber;
937
939
  disableInternalErrorValidationMessages?: boolean;
938
940
  }
939
941
 
@@ -1583,6 +1585,9 @@ export declare interface IUnitInputProps {
1583
1585
  onClick?: MouseEventHandler<HTMLInputElement>;
1584
1586
  onFocus?: FocusEventHandler<HTMLInputElement>;
1585
1587
  unitTemplate?: Record<string, any>;
1588
+ convertBackToStorageUnit?: boolean;
1589
+ enableCosmeticRounding?: boolean;
1590
+ enableDisplayRounding?: boolean;
1586
1591
  }
1587
1592
 
1588
1593
  declare interface IUnitTable extends Omit<ITableProps['table'], 'rows'> {
@@ -1664,7 +1669,7 @@ export declare const Modal: ({ children, visible, centered, width, onEnter, onEs
1664
1669
 
1665
1670
  export declare const NativeSelect: ({ disabled, error, warning, tooltip, options, onChange, onFocus, onBlur, right, small, tabIndex, selectedOption, width, groupOrder, testId, isInTable, clearable, placeholder, hasNonExistentValue, maxTooltipWidth, borderRadius, }: INativeSelectProps) => JSX_2.Element;
1666
1671
 
1667
- export declare const NumberInput: ({ name, placeholder, disabled, error, left, small, width, value, onChange, onFocus, onBlur, tabIndex, testId, tooltip, warning, validationCallback, allowEmpty, isInTable, groupOrder, enableDisplayRounding, roundDisplayValue, disableInternalErrorValidationMessages, }: INumberInputProps) => JSX_2.Element;
1672
+ export declare const NumberInput: ({ name, placeholder, disabled, error, left, small, width, value, onChange, onFocus, onBlur, tabIndex, testId, tooltip, warning, validationCallback, allowEmpty, isInTable, groupOrder, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, disableInternalErrorValidationMessages, }: INumberInputProps) => JSX_2.Element;
1668
1673
 
1669
1674
  export declare const OptionDropdown: ({ name, label, options, onChange, showHeader, maxHeight, }: IOptionDropdownProps) => ReactElement;
1670
1675
 
@@ -1860,7 +1865,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1860
1865
 
1861
1866
  declare type UnitContextType = any;
1862
1867
 
1863
- 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, }: IUnitInputProps) => JSX_2.Element;
1868
+ 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;
1864
1869
 
1865
1870
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1866
1871
 
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 { roundToFixed, validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, altUnitsList, getUnitsForQuantity, convertAndGetValue, isScientificStringNum, roundToPrecision, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
19
+ import { isScientificStringNum, roundToPrecision, roundToFixed, toString as toString$1, validateNumber, stripLeadingZeros, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, altUnitsList, convertAndGetValue, 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;
@@ -55696,6 +55696,12 @@ const InputCell = ({
55696
55696
  }
55697
55697
  );
55698
55698
  };
55699
+ const COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;
55700
+ const roundNumberCosmetic = (value) => {
55701
+ const isScientific = isScientificStringNum(value);
55702
+ return !isScientific ? roundToPrecision(value, COSMETIC_ROUNDING_DEFAULT_PRECISION) : value;
55703
+ };
55704
+ const safeToString = (value) => String(toString$1(value));
55699
55705
  const getStringName$1 = (name2) => {
55700
55706
  if (!name2) return "";
55701
55707
  if (typeof name2 === "string") {
@@ -55729,68 +55735,65 @@ const NumberInput = ({
55729
55735
  allowEmpty = false,
55730
55736
  isInTable: isInTable2,
55731
55737
  groupOrder,
55738
+ enableCosmeticRounding = true,
55732
55739
  enableDisplayRounding = false,
55733
55740
  roundDisplayValue,
55734
55741
  disableInternalErrorValidationMessages = false
55735
55742
  }) => {
55736
55743
  const inputRef = useRef(null);
55737
- const [displayValue, setDisplayValue] = useState(value);
55738
- const [validationError, setValidationError] = useState(null);
55744
+ const [displayValue, setDisplayValue] = useState(safeToString(value));
55739
55745
  const [focus2, setFocus] = useState(false);
55746
+ const [pristine, setPristine] = useState(true);
55740
55747
  const stringName = getStringName$1(name2);
55741
55748
  const validateInputValue = (value2) => {
55742
- let validation = validateNumber(value2);
55749
+ const validation = validateNumber(value2);
55743
55750
  if (allowEmpty && value2 === "" || validation.valid) {
55744
55751
  return { ...validation, valid: true, errors: void 0 };
55745
55752
  } else {
55746
55753
  return validation;
55747
55754
  }
55748
55755
  };
55756
+ const { valid, errors: errors2 } = validateInputValue(displayValue);
55757
+ const firstError = errors2 && errors2.length && !disableInternalErrorValidationMessages ? errors2[0] : null;
55749
55758
  useEffect(() => {
55750
- const { valid, errors: errors2 } = validateInputValue(value);
55751
- setDisplayValue(value);
55752
- if (valid) {
55753
- setValidationError(null);
55754
- validationCallback(stringName, null);
55755
- } else {
55756
- const firstError = errors2 && errors2.length ? errors2[0] : null;
55757
- setValidationError(firstError);
55759
+ setDisplayValue(safeToString(value));
55760
+ setPristine(true);
55761
+ }, [value, enableCosmeticRounding, enableDisplayRounding]);
55762
+ useEffect(() => {
55763
+ if (!focus2 && !valid) {
55758
55764
  validationCallback(stringName, firstError);
55765
+ } else {
55766
+ validationCallback(stringName, null);
55759
55767
  }
55760
- }, [value, error2]);
55761
- const onSetValue = (evt) => {
55762
- const input2 = evt.target;
55763
- const { value: value2 } = input2;
55764
- const inputValue = cleanNumStr(
55765
- value2.replaceAll(" ", "").replaceAll("|", "")
55766
- );
55767
- const { valid, errors: errors2 } = validateInputValue(inputValue);
55768
- if (valid) {
55769
- const newEvent = {
55768
+ }, [focus2, valid, error2]);
55769
+ const onChangeValue = (evt) => {
55770
+ if (valid && !pristine) {
55771
+ const event = {
55770
55772
  ...evt,
55771
55773
  target: {
55772
55774
  ...evt.target,
55773
- value: inputValue,
55775
+ value: stripLeadingZeros(safeToString(displayValue)),
55774
55776
  name: stringName
55775
55777
  }
55776
55778
  };
55777
- onChange(newEvent);
55778
- setDisplayValue(inputValue);
55779
- setValidationError(null);
55780
- validationCallback(stringName, null);
55781
- } else {
55782
- setDisplayValue(inputValue);
55783
- const firstError = errors2 && errors2.length ? errors2[0] : null;
55784
- setValidationError(firstError);
55785
- validationCallback(stringName, firstError);
55779
+ onChange(event);
55786
55780
  }
55787
55781
  };
55782
+ const onSetValue = (evt) => {
55783
+ const input2 = evt.target;
55784
+ const { value: value2 } = input2;
55785
+ const inputValue = cleanNumStr(
55786
+ value2.replaceAll(" ", "").replaceAll("|", "")
55787
+ );
55788
+ setDisplayValue(inputValue);
55789
+ setPristine(false);
55790
+ };
55788
55791
  useEffect(() => {
55789
55792
  if (inputRef && (inputRef == null ? void 0 : inputRef.current) && enableDisplayRounding && focus2) {
55790
55793
  const textInput = inputRef.current;
55791
55794
  if (textInput) {
55792
55795
  setTimeout(() => {
55793
- const { length: length2 } = String(displayValue);
55796
+ const { length: length2 } = safeToString(displayValue);
55794
55797
  textInput.setSelectionRange(length2, length2);
55795
55798
  }, 0);
55796
55799
  }
@@ -55802,33 +55805,48 @@ const NumberInput = ({
55802
55805
  };
55803
55806
  const onInputBlur = (evt) => {
55804
55807
  setFocus(false);
55808
+ onChangeValue(evt);
55805
55809
  onBlur(evt);
55806
55810
  };
55807
- const roundedDisplayValue = !focus2 && enableDisplayRounding ? roundDisplayValue ? roundDisplayValue(displayValue) : roundToFixed(displayValue, 2) : displayValue;
55811
+ const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
55812
+ const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : roundToFixed(displayValue, 2) : displayValue;
55813
+ const displayValueEndsWithZero = !!(valueWithDisplayRounding == null ? void 0 : valueWithDisplayRounding.endsWith("0"));
55814
+ const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
55815
+ valueWithDisplayRounding && // not when empty typed value
55816
+ !displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
55817
+ valid;
55818
+ const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(valueWithDisplayRounding) : valueWithDisplayRounding;
55808
55819
  return /* @__PURE__ */ jsx(
55809
- Input$1,
55820
+ KeyboardEventHandler,
55810
55821
  {
55811
- type: "text",
55812
- name: stringName,
55813
- testId,
55814
- disabled: disabled2,
55815
- placeholder: placeholder3,
55816
- value: roundedDisplayValue,
55817
- onChange: onSetValue,
55818
- onFocus: onInputFocus,
55819
- onBlur: onInputBlur,
55820
- error: error2 || validationError,
55821
- warning: warning2,
55822
- right: !left2,
55823
- small: small2,
55824
- width: width2,
55825
- isInTable: isInTable2,
55826
- groupOrder,
55827
- tabIndex,
55828
- tooltip: tooltip2,
55829
- ref: inputRef
55830
- },
55831
- stringName
55822
+ handleKeys: [EventKey.ENTER],
55823
+ onKeyEvent: (_key, evt) => onChangeValue(evt),
55824
+ children: /* @__PURE__ */ jsx(
55825
+ Input$1,
55826
+ {
55827
+ type: "text",
55828
+ name: stringName,
55829
+ testId,
55830
+ disabled: disabled2,
55831
+ placeholder: placeholder3,
55832
+ value: valueWithCosmeticRounding,
55833
+ onChange: onSetValue,
55834
+ onFocus: onInputFocus,
55835
+ onBlur: onInputBlur,
55836
+ error: !focus2 && (firstError || error2),
55837
+ warning: warning2,
55838
+ right: !left2,
55839
+ small: small2,
55840
+ width: width2,
55841
+ isInTable: isInTable2,
55842
+ groupOrder,
55843
+ tabIndex,
55844
+ tooltip: tooltip2,
55845
+ ref: inputRef
55846
+ },
55847
+ stringName
55848
+ )
55849
+ }
55832
55850
  );
55833
55851
  };
55834
55852
  const NumberInputCell = ({ cell: cell2, testId }) => {
@@ -55854,6 +55872,7 @@ const NumberInputCell = ({ cell: cell2, testId }) => {
55854
55872
  tooltip: cell2.tooltip,
55855
55873
  validationCallback: cell2.validationCallback,
55856
55874
  allowEmpty: cell2.allowEmpty,
55875
+ enableCosmeticRounding: cell2.enableCosmeticRounding,
55857
55876
  enableDisplayRounding: cell2.enableDisplayRounding,
55858
55877
  roundDisplayValue: cell2.roundDisplayValue
55859
55878
  }
@@ -70283,7 +70302,10 @@ const UnitInput = ({
70283
70302
  validationCallback = () => ({ name: "", error: null }),
70284
70303
  disabledValidation = false,
70285
70304
  allowEmpty = false,
70286
- autoValue
70305
+ autoValue,
70306
+ convertBackToStorageUnit = false,
70307
+ enableCosmeticRounding = true,
70308
+ enableDisplayRounding = false
70287
70309
  }) => {
70288
70310
  const context2 = useUnitContext();
70289
70311
  const runAfterUpdate = useRunAfterUpdate();
@@ -70348,9 +70370,10 @@ const UnitInput = ({
70348
70370
  const input2 = evt.target;
70349
70371
  const { value: inputValue, selectionStart: currentCursorPosition } = input2;
70350
70372
  const newValue = withUnit(inputValue, (displayLayer == null ? void 0 : displayLayer.unit) || "");
70373
+ const returnValue = convertBackToStorageUnit ? withUnit(convertAndGetValue(newValue, propUnit), propUnit) : newValue;
70351
70374
  onChange({
70352
70375
  target: {
70353
- value: newValue,
70376
+ value: returnValue,
70354
70377
  name: stringName2
70355
70378
  }
70356
70379
  });
@@ -70511,6 +70534,8 @@ const UnitInput = ({
70511
70534
  left: left2,
70512
70535
  allowEmpty,
70513
70536
  validationCallback: (_name, error22) => validationCallback(stringName, error22),
70537
+ enableCosmeticRounding,
70538
+ enableDisplayRounding,
70514
70539
  groupOrder: predefinedOptions ? "middle" : "first",
70515
70540
  disableInternalErrorValidationMessages
70516
70541
  },
@@ -70530,7 +70555,7 @@ const UnitInput = ({
70530
70555
  sections: alternativeUnits.map(([value2, altUnit, label2]) => {
70531
70556
  const displayUnit = label2 || altUnit || "";
70532
70557
  const safeValue = !isNaN(Number(value2)) ? value2 : "";
70533
- const displayValue = safeValue;
70558
+ const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
70534
70559
  return {
70535
70560
  type: "Option",
70536
70561
  label: displayValue,
@@ -70601,22 +70626,12 @@ const convertVisibleRows = ({
70601
70626
  const storageUnit = storageUnits[unitKey];
70602
70627
  const unitChanged = selectedUnit !== storageUnit;
70603
70628
  const convertedValue = unitChanged ? convertAndGetValue(value, selectedUnit, storageUnit) : cell2.value;
70604
- const isScientific = isScientificStringNum(value);
70605
- const displayValue = enableCosmeticRounding && (unitChanged || !isScientific) ? (
70606
- /*
70607
- Optionally do Excel-style "cosmetic rounding" of display values (only if enableCosmeticRounding prop on)
70608
- This means rounding to slightly less precision than the underlying floating-point number type, to
70609
- resolve floating-point "rounding noise" associated with storing values in one unit but converting
70610
- and displaying them in another unit. This solution was evaluated by Tools Team in relation to
70611
- tickets OW-10614 and OW-15745.
70612
- */
70613
- roundToPrecision(convertedValue, 14)
70614
- ) : convertedValue;
70615
- const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(displayValue) : displayValue;
70629
+ const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(convertedValue) : convertedValue;
70616
70630
  return {
70617
70631
  ...cell2,
70618
70632
  value: formattedDisplayValue,
70619
- enableCosmeticRounding,
70633
+ enableCosmeticRounding: enableCosmeticRounding && unitChanged,
70634
+ //todo: why did we need to check unitChanged here? (original rationale)
70620
70635
  enableDisplayRounding,
70621
70636
  roundDisplayValue,
70622
70637
  onChange: (evt) => {