@oliasoft-open-source/react-ui-library 4.12.4 → 4.12.6
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 +2 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1579,6 +1579,7 @@ export declare interface IUnitInputProps {
|
|
|
1579
1579
|
convertBackToStorageUnit?: boolean;
|
|
1580
1580
|
enableCosmeticRounding?: boolean;
|
|
1581
1581
|
enableDisplayRounding?: boolean;
|
|
1582
|
+
roundDisplayValue?: (args: TStringOrNumber) => TStringOrNumber;
|
|
1582
1583
|
}
|
|
1583
1584
|
|
|
1584
1585
|
declare interface IUnitTable extends Omit<ITableProps['table'], 'rows'> {
|
|
@@ -1872,7 +1873,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
|
|
|
1872
1873
|
|
|
1873
1874
|
declare type UnitContextType = any;
|
|
1874
1875
|
|
|
1875
|
-
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitInputProps) => JSX_2.Element;
|
|
1876
|
+
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
|
|
1876
1877
|
|
|
1877
1878
|
export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
|
|
1878
1879
|
|
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,
|
|
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;
|
|
@@ -55742,8 +55742,9 @@ const NumberInput = ({
|
|
|
55742
55742
|
setFocus(false);
|
|
55743
55743
|
onBlur(evt);
|
|
55744
55744
|
};
|
|
55745
|
+
const defaultDisplayRound = (value2) => isInTable2 ? roundToFixed(value2, 2) : roundByMagnitude(value2, 4);
|
|
55745
55746
|
const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
|
|
55746
|
-
const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) :
|
|
55747
|
+
const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : defaultDisplayRound(value) : displayValue;
|
|
55747
55748
|
return /* @__PURE__ */ jsx(
|
|
55748
55749
|
KeyboardEventHandler,
|
|
55749
55750
|
{
|
|
@@ -55777,7 +55778,11 @@ const NumberInput = ({
|
|
|
55777
55778
|
}
|
|
55778
55779
|
);
|
|
55779
55780
|
};
|
|
55780
|
-
const NumberInputCell = ({
|
|
55781
|
+
const NumberInputCell = ({
|
|
55782
|
+
cell: cell2,
|
|
55783
|
+
columnAlignment,
|
|
55784
|
+
testId
|
|
55785
|
+
}) => {
|
|
55781
55786
|
return /* @__PURE__ */ jsx(
|
|
55782
55787
|
NumberInput,
|
|
55783
55788
|
{
|
|
@@ -55794,7 +55799,7 @@ const NumberInputCell = ({ cell: cell2, testId }) => {
|
|
|
55794
55799
|
warning: cell2.warning,
|
|
55795
55800
|
disabled: cell2.disabled,
|
|
55796
55801
|
isInTable: true,
|
|
55797
|
-
left: cell2.left,
|
|
55802
|
+
left: cell2.left ?? columnAlignment === Align.LEFT,
|
|
55798
55803
|
tabIndex: cell2.disabled ? -1 : 0,
|
|
55799
55804
|
testId,
|
|
55800
55805
|
tooltip: cell2.tooltip,
|
|
@@ -55861,7 +55866,14 @@ const InputCellWrapper = ({
|
|
|
55861
55866
|
columnAlignment,
|
|
55862
55867
|
testId
|
|
55863
55868
|
}
|
|
55864
|
-
) : cell2.type === "NumberInput" ? /* @__PURE__ */ jsx(
|
|
55869
|
+
) : cell2.type === "NumberInput" ? /* @__PURE__ */ jsx(
|
|
55870
|
+
NumberInputCell,
|
|
55871
|
+
{
|
|
55872
|
+
cell: cell2,
|
|
55873
|
+
columnAlignment,
|
|
55874
|
+
testId
|
|
55875
|
+
}
|
|
55876
|
+
) : cell2.type === "DateInput" ? /* @__PURE__ */ jsx(InputCell, { cell: cell2, testId, type: "date" }) : cell2.type === "Select" ? /* @__PURE__ */ jsx(
|
|
55865
55877
|
SelectCell,
|
|
55866
55878
|
{
|
|
55867
55879
|
cell: cell2,
|
|
@@ -70296,7 +70308,8 @@ const UnitInput = ({
|
|
|
70296
70308
|
autoValue,
|
|
70297
70309
|
convertBackToStorageUnit = false,
|
|
70298
70310
|
enableCosmeticRounding = true,
|
|
70299
|
-
enableDisplayRounding = false
|
|
70311
|
+
enableDisplayRounding = false,
|
|
70312
|
+
roundDisplayValue
|
|
70300
70313
|
}) => {
|
|
70301
70314
|
const context2 = useUnitContext();
|
|
70302
70315
|
const runAfterUpdate = useRunAfterUpdate();
|
|
@@ -70563,6 +70576,7 @@ const UnitInput = ({
|
|
|
70563
70576
|
validationCallback: (_name, error22) => validationCallback(stringName, error22),
|
|
70564
70577
|
enableCosmeticRounding,
|
|
70565
70578
|
enableDisplayRounding,
|
|
70579
|
+
roundDisplayValue,
|
|
70566
70580
|
groupOrder: predefinedOptions ? "middle" : "first",
|
|
70567
70581
|
disableInternalErrorValidationMessages,
|
|
70568
70582
|
small: small2
|