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

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, 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, validateNumber, cleanNumStr, stripLeadingZeros, roundToFixed, roundByMagnitude, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, round as round$1, 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;
@@ -9096,6 +9096,17 @@ const Input$1 = forwardRef(
9096
9096
  //use width instead
9097
9097
  }, ref2) => {
9098
9098
  const disabledContext = useContext(DisabledContext);
9099
+ const inputRef = useRef(null);
9100
+ const handleChange = (e2) => {
9101
+ const cursorPosition = e2.target.selectionStart;
9102
+ onChange(e2);
9103
+ setTimeout(() => {
9104
+ if (inputRef.current && cursorPosition !== null) {
9105
+ inputRef.current.selectionStart = cursorPosition;
9106
+ inputRef.current.selectionEnd = cursorPosition;
9107
+ }
9108
+ }, 0);
9109
+ };
9099
9110
  const order2 = (() => {
9100
9111
  if (groupOrder) {
9101
9112
  switch (groupOrder) {
@@ -9123,12 +9134,12 @@ const Input$1 = forwardRef(
9123
9134
  children: /* @__PURE__ */ jsx(
9124
9135
  "input",
9125
9136
  {
9126
- ref: ref2,
9137
+ ref: ref2 || inputRef,
9127
9138
  type: type || "text",
9128
9139
  size: size2 || 20,
9129
9140
  placeholder: placeholder3 ?? "",
9130
9141
  value: value ?? "",
9131
- onChange,
9142
+ onChange: handleChange,
9132
9143
  onKeyPress,
9133
9144
  onFocus,
9134
9145
  onBlur,
@@ -56787,9 +56798,21 @@ const TextArea = ({
56787
56798
  testId
56788
56799
  }) => {
56789
56800
  const disabledContext = useContext(DisabledContext);
56801
+ const textareaRef = useRef(null);
56802
+ const handleChange = (e2) => {
56803
+ const cursorPosition = e2.target.selectionStart;
56804
+ onChange(e2);
56805
+ setTimeout(() => {
56806
+ if (textareaRef.current && cursorPosition !== null) {
56807
+ textareaRef.current.selectionStart = cursorPosition;
56808
+ textareaRef.current.selectionEnd = cursorPosition;
56809
+ }
56810
+ }, 0);
56811
+ };
56790
56812
  const textarea2 = /* @__PURE__ */ jsx(
56791
56813
  "textarea",
56792
56814
  {
56815
+ ref: textareaRef,
56793
56816
  className: cx$2(
56794
56817
  styles$5.textarea,
56795
56818
  error2 ? styles$5.error : "",
@@ -56801,7 +56824,7 @@ const TextArea = ({
56801
56824
  placeholder: placeholder3,
56802
56825
  cols,
56803
56826
  rows,
56804
- onChange,
56827
+ onChange: handleChange,
56805
56828
  disabled: disabled2 || disabledContext,
56806
56829
  onKeyPress,
56807
56830
  onFocus,
@@ -70306,10 +70329,6 @@ const initializeContext = (context2) => {
70306
70329
  UnitContext = context2;
70307
70330
  }
70308
70331
  };
70309
- const safeRoundNumbers = (value) => {
70310
- const isScientific = isScientificStringNum(value);
70311
- return !isScientific ? safeToString(round$1(toNum(value))) : value;
70312
- };
70313
70332
  const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
70314
70333
  const inputWrapper = "_inputWrapper_ye9w9_4";
70315
70334
  const styles = {
@@ -70616,7 +70635,7 @@ const UnitInput = ({
70616
70635
  sections: alternativeUnits.map(([value2, altUnit, label2]) => {
70617
70636
  const displayUnit = label2 || altUnit || "";
70618
70637
  const safeValue = isValidNum(value2) ? value2 : "";
70619
- const displayValue = enableCosmeticRounding ? safeRoundNumbers(safeValue) : safeValue;
70638
+ const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
70620
70639
  return {
70621
70640
  type: "Option",
70622
70641
  label: displayValue,