@oliasoft-open-source/react-ui-library 4.11.0-beta-2 → 4.11.0

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 (91) hide show
  1. package/dist/404.html +1 -0
  2. package/dist/index.js +105 -69
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-D_NCUJPU.js → Color-KGDBMAHA-C4DMqLTk.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-BCC2y5si.js → DocsRenderer-PKQXORMH-4sK5I5fh.js} +1 -1
  6. package/dist/storybook/assets/{accordion.stories-BLEGXECa.js → accordion.stories-BSRBp5Mg.js} +2 -2
  7. package/dist/storybook/assets/{afe.stories-DFQsvqIV.js → afe.stories-DM18uTAa.js} +2 -2
  8. package/dist/storybook/assets/{buttons-and-links-ArQ5RWpo.js → buttons-and-links-BAJT7RF7.js} +1 -1
  9. package/dist/storybook/assets/{casing-loads.stories-BCXgA6_-.js → casing-loads.stories-CE6GJ021.js} +2 -2
  10. package/dist/storybook/assets/{cell.stories-CrIM0y6t.js → cell.stories-BkZwSf40.js} +2 -2
  11. package/dist/storybook/assets/check-box.stories-BJ0ShmeC.js +97 -0
  12. package/dist/storybook/assets/check-box.test-case.stories-CzuYZkUh.js +30 -0
  13. package/dist/storybook/assets/{chunk-HLWAVYOI-BzRd0mjz.js → chunk-HLWAVYOI-wyESLsMA.js} +1 -1
  14. package/dist/storybook/assets/{color-B3CrjofM.js → color-CXm-Xks7.js} +1 -1
  15. package/dist/storybook/assets/enum-Bnn40S8Q.js +1 -0
  16. package/dist/storybook/assets/footer.stories-C1SojIiD.js +3 -0
  17. package/dist/storybook/assets/form.stories-BLcmnfy8.js +49 -0
  18. package/dist/storybook/assets/{formation.stories-DxVe8Zyc.js → formation.stories-DZ9-Ct5F.js} +2 -2
  19. package/dist/storybook/assets/helpers-JJxzGegQ.js +1 -0
  20. package/dist/storybook/assets/iframe-DGCZgYKU.js +2 -0
  21. package/dist/storybook/assets/{index-nyFwcT46.js → index-D-ApmKaY.js} +88 -88
  22. package/dist/storybook/assets/{index-Cjy_0_1e.js → index-DHATsyTR.js} +1 -1
  23. package/dist/storybook/assets/{input-group.stories-CElwRt3p.js → input-group.stories-EhmORqH9.js} +3 -3
  24. package/dist/storybook/assets/{input-validation-CFLVl6eG.js → input-validation-BdnKKR1J.js} +2 -2
  25. package/dist/storybook/assets/{inputs-BaoK3U4o.js → inputs-Cpi6xZLB.js} +2 -2
  26. package/dist/storybook/assets/{layout-forms-_Vn_gCYs.js → layout-forms-DxC0zO_Y.js} +5 -5
  27. package/dist/storybook/assets/{layout-general-C_WmY3IA.js → layout-general-Be4RMwPl.js} +1 -1
  28. package/dist/storybook/assets/menu.stories-DLJSzJa-.js +82 -0
  29. package/dist/storybook/assets/menu.test-case.stories-DyrNbGBs.js +3 -0
  30. package/dist/storybook/assets/modal.stories-DOgeTuHT.js +200 -0
  31. package/dist/storybook/assets/modal.test-case.stories-DQ1Izuq6.js +21 -0
  32. package/dist/storybook/assets/{number-input-B5ReSBSL.js → number-input-CJJvhIIv.js} +2 -2
  33. package/dist/storybook/assets/number-input.stories-CKVq60XH.js +89 -0
  34. package/dist/storybook/assets/number-input.test-case.stories-Dh1F7N8M.js +92 -0
  35. package/dist/storybook/assets/{padding-and-spacing-DaIt9nD2.js → padding-and-spacing-BZdh5XRo.js} +1 -1
  36. package/dist/storybook/assets/{pagination-CLt-kUlx.js → pagination-DWc8zp3k.js} +1 -1
  37. package/dist/storybook/assets/{pagination.stories-CTRM0Xou.js → pagination.stories-B5cOvzik.js} +2 -2
  38. package/dist/storybook/assets/popover.stories-p9_-pH_Q.js +10 -0
  39. package/dist/storybook/assets/{preview-DxrUSTYT.js → preview-B3bzTGOp.js} +2 -2
  40. package/dist/storybook/assets/{preview-Bhr6RB-I.js → preview-NGnahGuq.js} +1 -1
  41. package/dist/storybook/assets/{projects.stories-BQswWVCx.js → projects.stories-Co_WnKSx.js} +2 -2
  42. package/dist/storybook/assets/{radio-button-DmDuw4DA.js → radio-button-C4ljBRED.js} +1 -1
  43. package/dist/storybook/assets/radio-button.stories-D1rWr6ms.js +61 -0
  44. package/dist/storybook/assets/radio-button.test-case.stories-DglmHlWs.js +11 -0
  45. package/dist/storybook/assets/{reservoirs.stories-B12tIrmZ.js → reservoirs.stories-UW_8sofe.js} +2 -2
  46. package/dist/storybook/assets/{rich-text-input.stories-DkaOBgbE.js → rich-text-input.stories-CK_OTGiV.js} +3 -3
  47. package/dist/storybook/assets/{row.stories-C8rG1yoB.js → row.stories-D11wLSt6.js} +2 -2
  48. package/dist/storybook/assets/select-03uRbc4I.js +61 -0
  49. package/dist/storybook/assets/select.input-CJed_LLR.js +1 -0
  50. package/dist/storybook/assets/select.stories-Bpffz9TF.js +498 -0
  51. package/dist/storybook/assets/select.stories-data-DxgWKlU6.js +1 -0
  52. package/dist/storybook/assets/select.test-case.stories-DwDNDHax.js +82 -0
  53. package/dist/storybook/assets/{site.stories-umpPYjkq.js → site.stories-ZGohyW6Z.js} +2 -2
  54. package/dist/storybook/assets/{table-DdpQxqOc.js → table-DyOsClUv.js} +1 -1
  55. package/dist/storybook/assets/{table.stories-D4zMbjkS.js → table.stories-C1GgZCCR.js} +2 -2
  56. package/dist/storybook/assets/{tabs-C3NG6m9W.js → tabs-BoToLVEP.js} +1 -1
  57. package/dist/storybook/assets/tabs.stories-B52iEaHf.js +30 -0
  58. package/dist/storybook/assets/{title.stories-hThIUrWl.js → title.stories-jatDyjoM.js} +3 -3
  59. package/dist/storybook/assets/toaster.stories-G6nKp3uV.js +84 -0
  60. package/dist/storybook/assets/toaster.test-case.stories-CCHTh_U1.js +6 -0
  61. package/dist/storybook/assets/toggle.stories-BAislK3I.js +106 -0
  62. package/dist/storybook/assets/toggle.test-case.stories-CeUwdhGD.js +36 -0
  63. package/dist/storybook/assets/{tooltip.test-case.stories-CHibN8rC.js → tooltip.test-case.stories-C0wxGvKJ.js} +1 -1
  64. package/dist/storybook/assets/unit-input-CooRJQnF.js +10 -0
  65. package/dist/storybook/assets/unit-input.stories-zmSrl6iW.js +198 -0
  66. package/dist/storybook/assets/unit-input.test-case.stories-C1xRJ1EZ.js +220 -0
  67. package/dist/storybook/assets/unit-table.stories-Bl2gHPKG.js +152 -0
  68. package/dist/storybook/assets/unit-table.test-case.stories-DpSewGv4.js +1 -0
  69. package/dist/storybook/assets/use-previous-D775JrO6.js +1 -0
  70. package/dist/storybook/iframe.html +1 -1
  71. package/dist/storybook/index.json +1 -1
  72. package/dist/storybook/project.json +1 -1
  73. package/package.json +1 -1
  74. package/dist/storybook/assets/check-box.stories-DfbWw6mD.js +0 -126
  75. package/dist/storybook/assets/footer.stories-BU-TGwM2.js +0 -3
  76. package/dist/storybook/assets/form.stories-BrUnmw7R.js +0 -49
  77. package/dist/storybook/assets/iframe-4h-2QvBF.js +0 -2
  78. package/dist/storybook/assets/initialize-context-ScheoYVG.js +0 -1
  79. package/dist/storybook/assets/menu.stories-xWX80Eh2.js +0 -84
  80. package/dist/storybook/assets/modal.stories-LhoWfDE6.js +0 -220
  81. package/dist/storybook/assets/number-input.stories-DMAU21wG.js +0 -180
  82. package/dist/storybook/assets/popover.stories-CGm0M5fv.js +0 -10
  83. package/dist/storybook/assets/radio-button.stories-5gvV0LD0.js +0 -71
  84. package/dist/storybook/assets/select-DnRuRG_N.js +0 -61
  85. package/dist/storybook/assets/select.input-D0UkAPd9.js +0 -1
  86. package/dist/storybook/assets/select.stories-B9w9ONzj.js +0 -579
  87. package/dist/storybook/assets/tabs.stories-dsXjRHJy.js +0 -30
  88. package/dist/storybook/assets/toaster.stories-HO4VBTy-.js +0 -89
  89. package/dist/storybook/assets/toggle.stories-qTHFTXxI.js +0 -141
  90. package/dist/storybook/assets/unit-input.stories-D-520BU0.js +0 -421
  91. package/dist/storybook/assets/unit-table.stories-CI1eqBM4.js +0 -152
package/dist/404.html ADDED
@@ -0,0 +1 @@
1
+ <!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-DoFa61ar.js"></script><link rel="stylesheet" crossorigin href="/react-ui-library/assets/index-BpSdrNXy.css"></head><body><div id="content"></div></body>
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, ALT_UNITS, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, convertAndGetValue, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
19
+ import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, roundToFixed, validateNumber, cleanNumStr, stripLeadingZeros, unitFromQuantity, getUnit, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, KNOWN_UNITS, 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;
@@ -55688,6 +55688,10 @@ const NumberInput = ({
55688
55688
  }) => {
55689
55689
  const validateInputValue = (value2) => {
55690
55690
  const validation = validateNumber(value2);
55691
+ const isPlaceholder = placeholder3 && isEmptyNullOrUndefined(value2);
55692
+ if (isPlaceholder) {
55693
+ return { valid: true, errors: [] };
55694
+ }
55691
55695
  if (allowEmpty && value2 === "" || validation.valid) {
55692
55696
  return { ...validation, valid: true, errors: void 0 };
55693
55697
  } else {
@@ -55733,7 +55737,7 @@ const NumberInput = ({
55733
55737
  value2.replaceAll(" ", "").replaceAll("|", "")
55734
55738
  );
55735
55739
  setDisplayValue(inputValue);
55736
- if ((_b = validateInputValue(inputValue)) == null ? void 0 : _b.valid) {
55740
+ if (((_b = validateInputValue(inputValue)) == null ? void 0 : _b.valid) || placeholder3 && isEmptyNullOrUndefined(value2)) {
55737
55741
  const event = {
55738
55742
  ...evt,
55739
55743
  target: {
@@ -55762,7 +55766,6 @@ const NumberInput = ({
55762
55766
  };
55763
55767
  const onInputBlur = (evt) => {
55764
55768
  setFocus(false);
55765
- onChangeValue(evt);
55766
55769
  onBlur(evt);
55767
55770
  };
55768
55771
  const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
@@ -70172,6 +70175,10 @@ var PredefinedOptionsMenuState = /* @__PURE__ */ ((PredefinedOptionsMenuState2)
70172
70175
  const isWrongValue = (val) => {
70173
70176
  return val === "undefined" || val === void 0 || val === "" || val === "null" || val === null || val === "NaN" || isNaN(val);
70174
70177
  };
70178
+ const isValueWithUnknownUnit = (value) => {
70179
+ if (!value) return false;
70180
+ return Boolean(getUnit(value));
70181
+ };
70175
70182
  const checkConversion = ({
70176
70183
  value,
70177
70184
  unitkey,
@@ -70190,31 +70197,43 @@ const checkConversion = ({
70190
70197
  }
70191
70198
  return true;
70192
70199
  };
70193
- const convertUnit = (stringValue = "", toUnit, unitkey, defaultFromUnit = "", doNotConvertValue = false) => {
70200
+ const convertUnit = ({
70201
+ value: inputValue,
70202
+ unitkey,
70203
+ toUnit,
70204
+ fromUnit,
70205
+ doNotConvertValue = false,
70206
+ exactPrecision = false
70207
+ }) => {
70194
70208
  var _a2;
70195
- if (doNotConvertValue) return stringValue;
70196
- if (!((_a2 = validateNumber(stringValue)) == null ? void 0 : _a2.valid)) return;
70197
- if (toUnit && !isWrongValue(stringValue)) {
70198
- try {
70199
- const valueWithUnit = isValueWithUnit(stringValue) ? stringValue : withUnit(stringValue, defaultFromUnit);
70200
- const shouldConvert = checkConversion({
70201
- value: valueWithUnit,
70202
- toUnit,
70203
- unitkey
70204
- });
70205
- if (shouldConvert) {
70206
- const result = convertSamePrecision(valueWithUnit, toUnit);
70207
- return getValue$1(result);
70208
- }
70209
- return getValue$1(valueWithUnit);
70210
- } catch (e2) {
70209
+ const value = isValueWithUnit(inputValue) ? getValue$1(inputValue) : inputValue;
70210
+ if (doNotConvertValue) {
70211
+ return { value, error: null };
70212
+ }
70213
+ const defaultFromUnit = fromUnit || (isValueWithUnit(inputValue) ? getUnit(inputValue) : unitFromQuantity(unitkey));
70214
+ if (!((_a2 = validateNumber(value)) == null ? void 0 : _a2.valid)) {
70215
+ return { value: void 0, error: "Invalid number format" };
70216
+ }
70217
+ if (!toUnit) {
70218
+ return { value: void 0, error: "Target unit is missing" };
70219
+ }
70220
+ if (!defaultFromUnit) {
70221
+ return { value: void 0, error: "Source unit is missing" };
70222
+ }
70223
+ if (isWrongValue(value)) {
70224
+ return { value: void 0, error: "Value is invalid for conversion" };
70225
+ }
70226
+ try {
70227
+ const valueWithUnit = withUnit(value, defaultFromUnit);
70228
+ if (checkConversion({ value: valueWithUnit, toUnit, unitkey })) {
70229
+ const result = exactPrecision ? convertSamePrecision(valueWithUnit, toUnit) : convertAndGetValue(valueWithUnit, toUnit);
70230
+ return { value: getValue$1(safeToString(result)), error: null };
70211
70231
  }
70232
+ return { value: getValue$1(valueWithUnit), error: null };
70233
+ } catch (e2) {
70234
+ return { value: void 0, error: "Conversion not possible" };
70212
70235
  }
70213
70236
  };
70214
- const isValueWithUnknownUnit = (value) => {
70215
- if (!value) return false;
70216
- return Boolean(getUnit(value));
70217
- };
70218
70237
  const safeConvertValue = ({
70219
70238
  value = "",
70220
70239
  toUnit,
@@ -70226,18 +70245,19 @@ const safeConvertValue = ({
70226
70245
  const rawValue = getValue$1(value);
70227
70246
  const isInvalidInput = isWrongValue(rawValue);
70228
70247
  if (isInvalidInput) {
70229
- return rawValue;
70248
+ return { value: rawValue };
70230
70249
  }
70231
70250
  if (!isWithUnit) {
70232
- return value;
70251
+ return { value };
70233
70252
  }
70234
- return convertUnit(
70235
- rawValue,
70236
- toUnit,
70253
+ return convertUnit({
70254
+ value,
70237
70255
  unitkey,
70238
- defaultFromUnit,
70239
- doNotConvertValue
70240
- );
70256
+ toUnit,
70257
+ fromUnit: defaultFromUnit,
70258
+ doNotConvertValue,
70259
+ exactPrecision: true
70260
+ });
70241
70261
  };
70242
70262
  const getStringName = (name2) => {
70243
70263
  if (isObject$5(name2) && !isArray$1(name2) && !isFunction$3(name2)) {
@@ -70317,14 +70337,14 @@ const UnitInput = ({
70317
70337
  const knownUnit = isKnownUnit(value, preferredUnit);
70318
70338
  const initDisplayUnit = initUnit || preferredUnit || propUnit;
70319
70339
  const previousInitUnit = usePrevious(initDisplayUnit);
70320
- const convertedValue = safeConvertValue({
70340
+ const { value: convertedValue } = safeConvertValue({
70321
70341
  value,
70322
70342
  toUnit: initDisplayUnit,
70323
70343
  unitkey,
70324
70344
  defaultFromUnit: propUnit,
70325
70345
  doNotConvertValue
70326
70346
  });
70327
- const convertedAutoValue = safeConvertValue({
70347
+ const { value: convertedAutoValue } = safeConvertValue({
70328
70348
  value: autoValue,
70329
70349
  toUnit: initDisplayUnit,
70330
70350
  unitkey,
@@ -70333,22 +70353,24 @@ const UnitInput = ({
70333
70353
  });
70334
70354
  const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : convertedAutoValue !== "" ? { value: convertedAutoValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70335
70355
  const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
70336
- const derivedAllowEmpty = (displayLayer == null ? void 0 : displayLayer.value) === void 0;
70356
+ const derivedAllowEmpty = allowEmpty || (displayLayer == null ? void 0 : displayLayer.value) === void 0;
70337
70357
  const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(
70338
70358
  initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
70339
70359
  );
70340
70360
  const isAutoValue = propValue === "" && autoValue;
70341
- const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue || placeholder3 && isEmptyNullOrUndefined(value));
70361
+ const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue);
70342
70362
  const foundPredefinedMenuOption = predefinedOptions && predefinedOptions.find((el2) => {
70343
70363
  if (!(el2 == null ? void 0 : el2.value)) return;
70344
70364
  if (selectedPredefinedOptionKey) {
70345
70365
  return selectedPredefinedOptionKey === el2.valueKey;
70346
70366
  }
70347
70367
  const predefinedMenuItemUnit = isValueWithUnit(el2.value) ? getUnit(el2.value) : "";
70348
- return withUnit(
70349
- convertUnit(value, predefinedMenuItemUnit, unitkey),
70350
- predefinedMenuItemUnit
70351
- ) === el2.value;
70368
+ const { value: resultValue = value } = convertUnit({
70369
+ value: String(value),
70370
+ unitkey,
70371
+ toUnit: predefinedMenuItemUnit
70372
+ });
70373
+ return withUnit(resultValue, predefinedMenuItemUnit) === el2.value;
70352
70374
  });
70353
70375
  const getAlternativeUnits = () => {
70354
70376
  const valueToList = isAutoValue ? autoValue : value ?? "";
@@ -70405,22 +70427,24 @@ const UnitInput = ({
70405
70427
  if (initDisplayUnit) {
70406
70428
  let newValue, newUnit = "";
70407
70429
  if (previousInitUnit !== initDisplayUnit) {
70408
- newValue = safeConvertValue({
70430
+ const { value: resultValue } = safeConvertValue({
70409
70431
  value,
70410
70432
  toUnit: initDisplayUnit,
70411
70433
  unitkey,
70412
70434
  defaultFromUnit: propUnit,
70413
70435
  doNotConvertValue
70414
70436
  });
70437
+ newValue = resultValue;
70415
70438
  newUnit = initDisplayUnit;
70416
70439
  } else if (withUnit(displayLayer.value, displayLayer.unit) !== value) {
70417
- newValue = safeConvertValue({
70440
+ const { value: resultValue } = safeConvertValue({
70418
70441
  value,
70419
70442
  toUnit: displayLayer.unit,
70420
70443
  unitkey,
70421
70444
  defaultFromUnit: propUnit,
70422
70445
  doNotConvertValue
70423
70446
  });
70447
+ newValue = resultValue;
70424
70448
  newUnit = displayLayer.unit;
70425
70449
  }
70426
70450
  if (newValue !== void 0) {
@@ -70490,6 +70514,29 @@ const UnitInput = ({
70490
70514
  const dynamicOptions = predefinedOptions.map(createPredefinedOption);
70491
70515
  sectionsPredefinedMenu = [...sectionsPredefinedMenu, ...dynamicOptions];
70492
70516
  }
70517
+ const getPlaceholder = (placeholder22) => {
70518
+ if (isAutoValue) {
70519
+ const { value: resultValue } = safeConvertValue({
70520
+ value: autoValue,
70521
+ toUnit: displayLayer.unit,
70522
+ unitkey,
70523
+ defaultFromUnit: propAutoUnit,
70524
+ doNotConvertValue
70525
+ });
70526
+ return resultValue;
70527
+ } else if (isValueWithUnit(placeholder22)) {
70528
+ const placeholderUnit = getUnit(placeholder22);
70529
+ const { value: resultValue } = safeConvertValue({
70530
+ value: placeholder22,
70531
+ toUnit: displayLayer.unit,
70532
+ unitkey,
70533
+ defaultFromUnit: placeholderUnit,
70534
+ doNotConvertValue
70535
+ });
70536
+ return resultValue;
70537
+ }
70538
+ return placeholder22;
70539
+ };
70493
70540
  return /* @__PURE__ */ jsx(
70494
70541
  "div",
70495
70542
  {
@@ -70530,13 +70577,7 @@ const UnitInput = ({
70530
70577
  name: stringName,
70531
70578
  testId,
70532
70579
  disabled: disabled2,
70533
- placeholder: isAutoValue ? safeConvertValue({
70534
- value: autoValue,
70535
- toUnit: displayLayer.unit,
70536
- unitkey,
70537
- defaultFromUnit: propAutoUnit,
70538
- doNotConvertValue
70539
- }) : placeholder3,
70580
+ placeholder: getPlaceholder(placeholder3),
70540
70581
  value: displayLayer.value,
70541
70582
  onChange: onSetValue,
70542
70583
  onFocus,
@@ -70591,29 +70632,12 @@ const UnitInput = ({
70591
70632
  const normalizeUnits = (unitConfig) => unitConfig.reduce(
70592
70633
  ({ preferredUnits, storageUnits }, { unitKey, preferredUnit, storageUnit }) => {
70593
70634
  const { unitTemplate = null } = useUnitContext() ?? {};
70594
- console.log("unitTemplate", unitTemplate);
70595
- console.log("unitTemplate?.[unitKey]", unitTemplate == null ? void 0 : unitTemplate[unitKey]);
70596
- preferredUnits[unitKey] = preferredUnit ?? (unitTemplate == null ? void 0 : unitTemplate[unitKey]);
70635
+ preferredUnits[unitKey] = preferredUnit ?? getPreferredUnit(unitKey, unitTemplate);
70597
70636
  storageUnits[unitKey] = storageUnit;
70598
- console.log("preferredUnits", preferredUnits);
70599
70637
  return { preferredUnits, storageUnits };
70600
70638
  },
70601
70639
  { preferredUnits: {}, storageUnits: {} }
70602
70640
  );
70603
- const tryConvertValue = (value, unitKey, selectedUnit, storageUnit) => {
70604
- if (checkConversion({
70605
- value,
70606
- unitkey: unitKey,
70607
- toUnit: selectedUnit
70608
- })) {
70609
- try {
70610
- return convertAndGetValue(value, selectedUnit, storageUnit);
70611
- } catch {
70612
- return value;
70613
- }
70614
- }
70615
- return value;
70616
- };
70617
70641
  const convertVisibleRows = ({
70618
70642
  headers,
70619
70643
  rows,
@@ -70655,7 +70679,13 @@ const convertVisibleRows = ({
70655
70679
  const selectedUnit = selectedUnits[unitKey];
70656
70680
  const storageUnit = storageUnits[unitKey];
70657
70681
  const unitChanged = selectedUnit !== storageUnit;
70658
- const convertedValue = unitChanged ? tryConvertValue(value, unitKey, selectedUnit, storageUnit) : cell2.value;
70682
+ const { value: resultValue = value } = convertUnit({
70683
+ value: safeToString(value),
70684
+ unitkey: unitKey,
70685
+ toUnit: selectedUnit,
70686
+ fromUnit: storageUnit
70687
+ });
70688
+ const convertedValue = unitChanged ? resultValue : cell2.value;
70659
70689
  const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(convertedValue) : convertedValue;
70660
70690
  return {
70661
70691
  ...cell2,
@@ -70670,7 +70700,13 @@ const convertVisibleRows = ({
70670
70700
  const selectedUnit2 = selectedUnits[unitKey];
70671
70701
  const unitChanged2 = selectedUnit2 !== storageUnit2;
70672
70702
  const nextUnit = convertBackToStorageUnit ? storageUnit2 : selectedUnit2;
70673
- const nextValueConverted = unitChanged2 ? tryConvertValue(value2, unitKey, nextUnit, selectedUnit2) : value2;
70703
+ const { value: resultValue2 = value2 } = convertUnit({
70704
+ value: String(value2),
70705
+ unitkey: unitKey,
70706
+ toUnit: nextUnit,
70707
+ fromUnit: selectedUnit2
70708
+ });
70709
+ const nextValueConverted = unitChanged2 ? resultValue2 : value2;
70674
70710
  if ("onChange" in cell2) {
70675
70711
  const { onChange } = cell2;
70676
70712
  const event = {