@oliasoft-open-source/react-ui-library 4.15.7-beta-1 → 4.15.7-beta-3

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.d.ts CHANGED
@@ -502,6 +502,7 @@ declare interface IInputCell extends TCommonCell {
502
502
  warning?: string;
503
503
  disabled?: boolean;
504
504
  maxTooltipWidth?: TStringOrNumber;
505
+ selectOnFocus?: boolean;
505
506
  tooltip?: StringNumberOrNode;
506
507
  }
507
508
 
@@ -528,6 +529,7 @@ export declare interface IInputProps {
528
529
  onFocus?: (evt: FocusEvent_2<HTMLInputElement>) => void;
529
530
  onBlur?: (evt: FocusEvent_2<HTMLInputElement>) => void;
530
531
  onPaste?: default_2.ClipboardEventHandler<HTMLInputElement>;
532
+ selectOnFocus?: boolean;
531
533
  small?: boolean;
532
534
  placeholder?: string | null;
533
535
  tabIndex?: number;
@@ -907,6 +909,7 @@ declare interface INumberInputCell extends TCommonCell {
907
909
  enableCosmeticRounding: boolean;
908
910
  enableDisplayRounding: boolean;
909
911
  roundDisplayValue: (value: TStringOrNumber) => TStringOrNumber;
912
+ selectOnFocus?: boolean;
910
913
  }
911
914
 
912
915
  export declare interface INumberInputProps {
@@ -923,6 +926,7 @@ export declare interface INumberInputProps {
923
926
  onChange?: TChangeEventHandler;
924
927
  onFocus?: (evt: FocusEvent_2<HTMLInputElement>) => void;
925
928
  onBlur?: (evt: FocusEvent_2<HTMLInputElement>) => void;
929
+ selectOnFocus?: boolean;
926
930
  tabIndex?: number;
927
931
  testId?: string;
928
932
  tooltip?: TStringOrNumber | default_2.ReactNode;
@@ -1669,7 +1673,7 @@ export declare const Modal: ({ children, visible, centered, width, onEnter, onEs
1669
1673
 
1670
1674
  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;
1671
1675
 
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;
1676
+ export declare const NumberInput: ({ name, placeholder, disabled, error, left, small, width, value, onChange, onFocus, onBlur, selectOnFocus, tabIndex, testId, tooltip, warning, validationCallback, allowEmpty, isInTable, groupOrder, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, disableInternalErrorValidationMessages, }: INumberInputProps) => JSX_2.Element;
1673
1677
 
1674
1678
  export declare const OptionDropdown: ({ name, label, options, onChange, small, showHeader, maxHeight, }: IOptionDropdownProps) => ReactElement;
1675
1679
 
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;
@@ -9082,6 +9082,7 @@ const Input$1 = forwardRef(
9082
9082
  },
9083
9083
  onPaste = () => {
9084
9084
  },
9085
+ selectOnFocus = false,
9085
9086
  name: name2 = void 0,
9086
9087
  type = "text",
9087
9088
  tabIndex = 0,
@@ -9110,6 +9111,12 @@ const Input$1 = forwardRef(
9110
9111
  return "";
9111
9112
  })();
9112
9113
  const width2 = propWidth || (size2 ? "auto" : "100%");
9114
+ const handleFocus = (e2) => {
9115
+ onFocus(e2);
9116
+ if (selectOnFocus) {
9117
+ e2.target.select();
9118
+ }
9119
+ };
9113
9120
  return /* @__PURE__ */ jsx("div", { style: { width: width2 }, className: order2, children: /* @__PURE__ */ jsx(
9114
9121
  Tooltip,
9115
9122
  {
@@ -9130,7 +9137,7 @@ const Input$1 = forwardRef(
9130
9137
  value: value ?? "",
9131
9138
  onChange,
9132
9139
  onKeyPress,
9133
- onFocus,
9140
+ onFocus: handleFocus,
9134
9141
  onBlur,
9135
9142
  onPaste,
9136
9143
  name: name2,
@@ -55636,6 +55643,7 @@ const InputCell = ({
55636
55643
  isInTable: true,
55637
55644
  maxTooltipWidth: cell2.maxTooltipWidth,
55638
55645
  right: columnAlignment === Align.RIGHT,
55646
+ selectOnFocus: cell2.selectOnFocus,
55639
55647
  testId,
55640
55648
  tabIndex: cell2.disabled ? -1 : 0,
55641
55649
  tooltip: cell2.tooltip,
@@ -55675,6 +55683,7 @@ const NumberInput = ({
55675
55683
  },
55676
55684
  onBlur = () => {
55677
55685
  },
55686
+ selectOnFocus = false,
55678
55687
  tabIndex = 0,
55679
55688
  testId,
55680
55689
  tooltip: tooltip2 = null,
@@ -55760,6 +55769,10 @@ const NumberInput = ({
55760
55769
  if (inputRef && (inputRef == null ? void 0 : inputRef.current) && enableDisplayRounding && focus2) {
55761
55770
  const textInput = inputRef.current;
55762
55771
  if (textInput) {
55772
+ if (selectOnFocus) {
55773
+ textInput.select();
55774
+ return;
55775
+ }
55763
55776
  setTimeout(() => {
55764
55777
  const { length: length2 } = safeToString(displayValue);
55765
55778
  textInput.setSelectionRange(length2, length2);
@@ -55802,6 +55815,7 @@ const NumberInput = ({
55802
55815
  width: width2,
55803
55816
  isInTable: isInTable2,
55804
55817
  groupOrder,
55818
+ selectOnFocus,
55805
55819
  tabIndex,
55806
55820
  tooltip: tooltip2,
55807
55821
  ref: inputRef
@@ -55833,6 +55847,7 @@ const NumberInputCell = ({
55833
55847
  disabled: cell2.disabled,
55834
55848
  isInTable: true,
55835
55849
  left: cell2.left ?? columnAlignment === Align.LEFT,
55850
+ selectOnFocus: cell2.selectOnFocus,
55836
55851
  tabIndex: cell2.disabled ? -1 : 0,
55837
55852
  testId,
55838
55853
  tooltip: cell2.tooltip,
@@ -70308,10 +70323,6 @@ const initializeContext = (context2) => {
70308
70323
  UnitContext = context2;
70309
70324
  }
70310
70325
  };
70311
- const safeRoundNumbers = (value) => {
70312
- const isScientific = isScientificStringNum(value);
70313
- return !isScientific ? safeToString(round$1(toNum(value))) : value;
70314
- };
70315
70326
  const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
70316
70327
  const inputWrapper = "_inputWrapper_ye9w9_4";
70317
70328
  const styles = {
@@ -70618,7 +70629,7 @@ const UnitInput = ({
70618
70629
  sections: alternativeUnits.map(([value2, altUnit, label2]) => {
70619
70630
  const displayUnit = label2 || altUnit || "";
70620
70631
  const safeValue = isValidNum(value2) ? value2 : "";
70621
- const displayValue = enableCosmeticRounding ? safeRoundNumbers(safeValue) : safeValue;
70632
+ const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
70622
70633
  return {
70623
70634
  type: "Option",
70624
70635
  label: displayValue,
@@ -70703,6 +70714,7 @@ const convertVisibleRows = ({
70703
70714
  enableCosmeticRounding,
70704
70715
  enableDisplayRounding,
70705
70716
  roundDisplayValue,
70717
+ selectOnFocus: true,
70706
70718
  onChange: (evt) => {
70707
70719
  const { value: value2 } = evt.target;
70708
70720
  const storageUnit2 = storageUnits[unitKey];