@oliasoft-open-source/react-ui-library 4.17.0-beta-3 → 4.18.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.
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, flushSync as flushSync$1, unstable_batchedUpdates, render } from "react-dom";
18
18
  import { noop as noop$2, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$1, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$3, isObject as isObject$5, isEqual as isEqual$3 } from "lodash";
19
- import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, validateNumber, cleanNumStr, stripLeadingZeros, roundToFixed, roundByMagnitude, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue, 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, withUnit, convertSamePrecision, convertAndGetValue, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, withPrettyUnitLabel, 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;
@@ -14730,6 +14730,7 @@ const List = ({
14730
14730
  ),
14731
14731
  "data-testid": testId,
14732
14732
  style: { height: height2, marginBottom },
14733
+ id: "scrollableDiv",
14733
14734
  children: [
14734
14735
  !noHeader && /* @__PURE__ */ jsx(
14735
14736
  ListHeading,
@@ -66179,6 +66180,10 @@ const checkConversion = ({
66179
66180
  if (!availableUnits.includes(toUnit)) {
66180
66181
  return false;
66181
66182
  }
66183
+ const valueUnit = getUnit(String(value));
66184
+ if (valueUnit && !availableUnits.includes(valueUnit)) {
66185
+ return false;
66186
+ }
66182
66187
  return true;
66183
66188
  };
66184
66189
  const convertUnit = ({
@@ -66231,6 +66236,14 @@ const safeConvertValue = ({
66231
66236
  }) => {
66232
66237
  const rawValue = getValue(value);
66233
66238
  const isInvalidInput = isWrongValue(rawValue);
66239
+ const shouldConvert = checkConversion({
66240
+ value,
66241
+ unitkey,
66242
+ toUnit
66243
+ });
66244
+ if (!shouldConvert) {
66245
+ return { value: rawValue };
66246
+ }
66234
66247
  if (isValueWithUnknownUnit(value)) {
66235
66248
  return { value: rawValue };
66236
66249
  }
@@ -66452,6 +66465,22 @@ const UnitInput = ({
66452
66465
  const createPredefinedOption = (el2) => {
66453
66466
  const elementValue = (el2 == null ? void 0 : el2.value) ? el2.value : "";
66454
66467
  const [value2 = "", unit2 = ""] = isValueWithUnit(elementValue) ? split$1(elementValue) : [elementValue];
66468
+ let description2 = withPrettyUnitLabel(elementValue);
66469
+ const shouldConvert = checkConversion({
66470
+ value: elementValue,
66471
+ unitkey,
66472
+ toUnit: unit2
66473
+ });
66474
+ if (shouldConvert) {
66475
+ const { value: value3 = "" } = safeConvertValue({
66476
+ value: elementValue,
66477
+ toUnit: preferredUnit,
66478
+ unitkey,
66479
+ defaultFromUnit: unit2,
66480
+ doNotConvertValue: noConversion
66481
+ });
66482
+ description2 = withPrettyUnitLabel(withUnit(value3, preferredUnit));
66483
+ }
66455
66484
  return {
66456
66485
  type: MenuType.OPTION,
66457
66486
  inline: true,
@@ -66473,7 +66502,7 @@ const UnitInput = ({
66473
66502
  /* @__PURE__ */ jsx(Text, { children: el2.label }),
66474
66503
  /* @__PURE__ */ jsx(Spacer, { width: "20px", height: "0" })
66475
66504
  ] }),
66476
- description: isValueWithUnit(elementValue) ? `${value2} ${unit2}` : elementValue,
66505
+ description: description2,
66477
66506
  selected: foundPredefinedMenuOption === el2 && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
66478
66507
  };
66479
66508
  };