@oliasoft-open-source/react-ui-library 4.9.0 → 4.10.1-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 (66) hide show
  1. package/dist/index.js +26 -18
  2. package/dist/index.js.map +1 -1
  3. package/dist/storybook/assets/{Color-KGDBMAHA-BnHaqcsT.js → Color-KGDBMAHA-BKjenJg6.js} +1 -1
  4. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DcoD1y-5.js → DocsRenderer-PKQXORMH-C2T7m4eo.js} +1 -1
  5. package/dist/storybook/assets/{accordion.stories-D0wb2n-9.js → accordion.stories-DYWwH-nb.js} +2 -2
  6. package/dist/storybook/assets/{afe.stories-DM18uTAa.js → afe.stories-DFQsvqIV.js} +2 -2
  7. package/dist/storybook/assets/{buttons-and-links-jPZ2UUsp.js → buttons-and-links-DvzJXTiI.js} +1 -1
  8. package/dist/storybook/assets/{casing-loads.stories-Dga1QkGC.js → casing-loads.stories-CS3UEFRb.js} +2 -2
  9. package/dist/storybook/assets/{cell.stories-DfyQwzEH.js → cell.stories-DC0iukzz.js} +2 -2
  10. package/dist/storybook/assets/{chunk-HLWAVYOI-D2AwGCE9.js → chunk-HLWAVYOI-BjTw4qro.js} +1 -1
  11. package/dist/storybook/assets/{color-CLf9xt55.js → color-P_umYTX_.js} +1 -1
  12. package/dist/storybook/assets/footer.stories-BGebD8DA.js +3 -0
  13. package/dist/storybook/assets/form.stories-BrUnmw7R.js +49 -0
  14. package/dist/storybook/assets/{formation.stories-CZGQhWyA.js → formation.stories-CSRmoL6O.js} +2 -2
  15. package/dist/storybook/assets/iframe-D3Y4UHkr.js +2 -0
  16. package/dist/storybook/assets/{index-BQ_6rM6u.js → index-D64MwP-f.js} +1 -1
  17. package/dist/storybook/assets/{index-Sr04i8ct.js → index-fzFtvz6M.js} +88 -88
  18. package/dist/storybook/assets/{input-group.stories-EhmORqH9.js → input-group.stories-CElwRt3p.js} +3 -3
  19. package/dist/storybook/assets/{input-validation-Tr-aD1VJ.js → input-validation-DRAbj6PG.js} +2 -2
  20. package/dist/storybook/assets/{inputs-BGIgggtv.js → inputs-Bsw0dZrv.js} +1 -1
  21. package/dist/storybook/assets/{layout-forms-n-mRkolR.js → layout-forms-Crl8l1Fb.js} +5 -5
  22. package/dist/storybook/assets/{layout-general-CNsKoPG6.js → layout-general-CNSlTZ6G.js} +1 -1
  23. package/dist/storybook/assets/{modal.stories-C6Bh0Oda.js → modal.stories-LhoWfDE6.js} +2 -2
  24. package/dist/storybook/assets/number-input-B25TXDQC.js +16 -0
  25. package/dist/storybook/assets/number-input.stories-rcGMdz-Y.js +166 -0
  26. package/dist/storybook/assets/{padding-and-spacing-B10oZ-Ww.js → padding-and-spacing-CL4N967X.js} +1 -1
  27. package/dist/storybook/assets/{pagination-DWc8zp3k.js → pagination-CLt-kUlx.js} +1 -1
  28. package/dist/storybook/assets/{pagination.stories-B5cOvzik.js → pagination.stories-CTRM0Xou.js} +2 -2
  29. package/dist/storybook/assets/popover.stories-CGm0M5fv.js +10 -0
  30. package/dist/storybook/assets/{preview-pQMX-q5x.js → preview-CqKyK4JL.js} +1 -1
  31. package/dist/storybook/assets/{preview-Cym3ID9p.js → preview-DL9T_bF-.js} +2 -2
  32. package/dist/storybook/assets/{projects.stories-Co_WnKSx.js → projects.stories-BQswWVCx.js} +2 -2
  33. package/dist/storybook/assets/{radio-button-C4ljBRED.js → radio-button-DmDuw4DA.js} +1 -1
  34. package/dist/storybook/assets/{radio-button.stories-BzyW2CtK.js → radio-button.stories-5gvV0LD0.js} +2 -2
  35. package/dist/storybook/assets/{reservoirs.stories-UW_8sofe.js → reservoirs.stories-B12tIrmZ.js} +2 -2
  36. package/dist/storybook/assets/{rich-text-input.stories-0pm7-gTq.js → rich-text-input.stories-hAHCnDHk.js} +3 -3
  37. package/dist/storybook/assets/{row.stories-B8OWE9yd.js → row.stories-C6aRnuL5.js} +2 -2
  38. package/dist/storybook/assets/select-DnRuRG_N.js +61 -0
  39. package/dist/storybook/assets/select.input-D0UkAPd9.js +1 -0
  40. package/dist/storybook/assets/{select.stories-B0KIHiMX.js → select.stories-B9w9ONzj.js} +2 -2
  41. package/dist/storybook/assets/{site.stories-ZGohyW6Z.js → site.stories-umpPYjkq.js} +2 -2
  42. package/dist/storybook/assets/{table-qmf29AIJ.js → table-Dh7Es_V6.js} +1 -1
  43. package/dist/storybook/assets/{table.stories-DzHGqXth.js → table.stories-BsPbkctl.js} +2 -2
  44. package/dist/storybook/assets/{tabs-BoToLVEP.js → tabs-C3NG6m9W.js} +1 -1
  45. package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +30 -0
  46. package/dist/storybook/assets/{title.stories-B8l1sfdo.js → title.stories-wr63QEGT.js} +3 -3
  47. package/dist/storybook/assets/unit-input.stories-2K9MHmw_.js +394 -0
  48. package/dist/storybook/assets/unit-table.stories-CbAekNaE.js +152 -0
  49. package/dist/storybook/iframe.html +1 -1
  50. package/dist/storybook/index.json +1 -1
  51. package/dist/storybook/project.json +1 -1
  52. package/package.json +1 -1
  53. package/dist/404.html +0 -1
  54. package/dist/storybook/assets/enum-Bnn40S8Q.js +0 -1
  55. package/dist/storybook/assets/footer.stories-DYBxUtZh.js +0 -3
  56. package/dist/storybook/assets/form.stories-BLcmnfy8.js +0 -49
  57. package/dist/storybook/assets/helpers-JJxzGegQ.js +0 -1
  58. package/dist/storybook/assets/iframe-BnDar59m.js +0 -2
  59. package/dist/storybook/assets/number-input-DZ9ERbK_.js +0 -16
  60. package/dist/storybook/assets/number-input.stories-CmVUHT2d.js +0 -124
  61. package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +0 -10
  62. package/dist/storybook/assets/select-03uRbc4I.js +0 -61
  63. package/dist/storybook/assets/select.input-CJed_LLR.js +0 -1
  64. package/dist/storybook/assets/tabs.stories-B52iEaHf.js +0 -30
  65. package/dist/storybook/assets/unit-input.stories-BnLB_Avl.js +0 -316
  66. package/dist/storybook/assets/unit-table.stories-DquyyMbD.js +0 -152
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 { isScientificStringNum, roundToPrecision, roundToFixed, toString as toString$1, validateNumber, cleanNumStr, stripLeadingZeros, 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";
19
+ import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, roundToFixed, validateNumber, cleanNumStr, stripLeadingZeros, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, isValidNum, 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;
@@ -55697,11 +55697,13 @@ const InputCell = ({
55697
55697
  );
55698
55698
  };
55699
55699
  const COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;
55700
+ const safeToString = (value) => String(toString$1(value));
55700
55701
  const roundNumberCosmetic = (value) => {
55701
55702
  const isScientific = isScientificStringNum(value);
55702
- return !isScientific ? roundToPrecision(value, COSMETIC_ROUNDING_DEFAULT_PRECISION) : value;
55703
+ return !isScientific ? safeToString(
55704
+ roundToPrecision(toNum(value), COSMETIC_ROUNDING_DEFAULT_PRECISION)
55705
+ ) : value;
55703
55706
  };
55704
- const safeToString = (value) => String(toString$1(value));
55705
55707
  const getStringName$1 = (name2) => {
55706
55708
  if (!name2) return "";
55707
55709
  if (typeof name2 === "string") {
@@ -55735,15 +55737,11 @@ const NumberInput = ({
55735
55737
  allowEmpty = false,
55736
55738
  isInTable: isInTable2,
55737
55739
  groupOrder,
55738
- enableCosmeticRounding = false,
55740
+ enableCosmeticRounding = true,
55739
55741
  enableDisplayRounding = false,
55740
55742
  roundDisplayValue,
55741
55743
  disableInternalErrorValidationMessages = false
55742
55744
  }) => {
55743
- const inputRef = useRef(null);
55744
- const [displayValue, setDisplayValue] = useState(safeToString(value));
55745
- const [focus2, setFocus] = useState(false);
55746
- const stringName = getStringName$1(name2);
55747
55745
  const validateInputValue = (value2) => {
55748
55746
  const validation = validateNumber(value2);
55749
55747
  if (allowEmpty && value2 === "" || validation.valid) {
@@ -55752,10 +55750,26 @@ const NumberInput = ({
55752
55750
  return validation;
55753
55751
  }
55754
55752
  };
55753
+ const cosmeticRound = (value2) => {
55754
+ var _a2;
55755
+ const displayValueEndsWithZero = !!(value2 == null ? void 0 : value2.endsWith("0"));
55756
+ const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
55757
+ value2 && // not when empty typed value
55758
+ !displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
55759
+ ((_a2 = validateInputValue(value2)) == null ? void 0 : _a2.valid);
55760
+ const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(value2) : value2;
55761
+ return safeToString(valueWithCosmeticRounding);
55762
+ };
55763
+ const inputRef = useRef(null);
55764
+ const [displayValue, setDisplayValue] = useState(
55765
+ cosmeticRound(safeToString(value))
55766
+ );
55767
+ const [focus2, setFocus] = useState(false);
55768
+ const stringName = getStringName$1(name2);
55755
55769
  const { valid, errors: errors2 } = validateInputValue(displayValue);
55756
55770
  const firstError = errors2 && errors2.length && !disableInternalErrorValidationMessages ? errors2[0] : null;
55757
55771
  useEffect(() => {
55758
- setDisplayValue(safeToString(value));
55772
+ setDisplayValue(cosmeticRound(safeToString(value)));
55759
55773
  }, [value, enableCosmeticRounding, enableDisplayRounding]);
55760
55774
  useEffect(() => {
55761
55775
  if (!focus2 && !valid) {
@@ -55805,12 +55819,6 @@ const NumberInput = ({
55805
55819
  };
55806
55820
  const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
55807
55821
  const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : roundToFixed(displayValue, 2) : displayValue;
55808
- const displayValueEndsWithZero = !!(valueWithDisplayRounding == null ? void 0 : valueWithDisplayRounding.endsWith("0"));
55809
- const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
55810
- valueWithDisplayRounding && // not when empty typed value
55811
- !displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
55812
- valid;
55813
- const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(valueWithDisplayRounding) : valueWithDisplayRounding;
55814
55822
  return /* @__PURE__ */ jsx(
55815
55823
  KeyboardEventHandler,
55816
55824
  {
@@ -55824,7 +55832,7 @@ const NumberInput = ({
55824
55832
  testId,
55825
55833
  disabled: disabled2,
55826
55834
  placeholder: placeholder3,
55827
- value: valueWithCosmeticRounding,
55835
+ value: valueWithDisplayRounding,
55828
55836
  onChange: onChangeValue,
55829
55837
  onFocus: onInputFocus,
55830
55838
  onBlur: onInputBlur,
@@ -70299,7 +70307,7 @@ const UnitInput = ({
70299
70307
  allowEmpty = false,
70300
70308
  autoValue,
70301
70309
  convertBackToStorageUnit = false,
70302
- enableCosmeticRounding = false,
70310
+ enableCosmeticRounding = true,
70303
70311
  enableDisplayRounding = false
70304
70312
  }) => {
70305
70313
  const context2 = useUnitContext();
@@ -70549,7 +70557,7 @@ const UnitInput = ({
70549
70557
  small: small2,
70550
70558
  sections: alternativeUnits.map(([value2, altUnit, label2]) => {
70551
70559
  const displayUnit = label2 || altUnit || "";
70552
- const safeValue = !isNaN(Number(value2)) ? value2 : "";
70560
+ const safeValue = isValidNum(value2) ? value2 : "";
70553
70561
  const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
70554
70562
  return {
70555
70563
  type: "Option",