@oliasoft-open-source/react-ui-library 4.10.0-beta-1 → 4.10.1-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 +34 -31
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-Bn4yyV9u.js → Color-KGDBMAHA-BKjenJg6.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-BUBqlKwY.js → DocsRenderer-PKQXORMH-C2T7m4eo.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-kLk1OtZZ.js → accordion.stories-DYWwH-nb.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-a_IVrxwj.js → buttons-and-links-DvzJXTiI.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-B2lND_PU.js → casing-loads.stories-CS3UEFRb.js} +1 -1
- package/dist/storybook/assets/{cell.stories-BVDrv2SU.js → cell.stories-DC0iukzz.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-kpZZkSeH.js → chunk-HLWAVYOI-BjTw4qro.js} +1 -1
- package/dist/storybook/assets/{color-Cbf9UrQO.js → color-P_umYTX_.js} +1 -1
- package/dist/storybook/assets/{footer.stories-BVXSVjq1.js → footer.stories-BGebD8DA.js} +1 -1
- package/dist/storybook/assets/{formation.stories-DmecxRaM.js → formation.stories-CSRmoL6O.js} +1 -1
- package/dist/storybook/assets/{iframe-DO2I_nJe.js → iframe-D3Y4UHkr.js} +2 -2
- package/dist/storybook/assets/{index-Nykkb-Z-.js → index-D64MwP-f.js} +1 -1
- package/dist/storybook/assets/{index-CP-qN_yN.js → index-fzFtvz6M.js} +4 -4
- package/dist/storybook/assets/{input-validation-51gQ2ORg.js → input-validation-DRAbj6PG.js} +1 -1
- package/dist/storybook/assets/{inputs-CPKM4uZ6.js → inputs-Bsw0dZrv.js} +1 -1
- package/dist/storybook/assets/{layout-forms-C9pc1r5D.js → layout-forms-Crl8l1Fb.js} +1 -1
- package/dist/storybook/assets/{layout-general-Dks_ONKw.js → layout-general-CNSlTZ6G.js} +1 -1
- package/dist/storybook/assets/{number-input-DBZIl9dz.js → number-input-B25TXDQC.js} +2 -2
- package/dist/storybook/assets/{number-input.stories-CqTYNX8G.js → number-input.stories-rcGMdz-Y.js} +6 -6
- package/dist/storybook/assets/{padding-and-spacing-Bki_uuMD.js → padding-and-spacing-CL4N967X.js} +1 -1
- package/dist/storybook/assets/{preview-yquX1adV.js → preview-CqKyK4JL.js} +1 -1
- package/dist/storybook/assets/{preview-DGoeP-Zy.js → preview-DL9T_bF-.js} +2 -2
- package/dist/storybook/assets/{row.stories-BO2s7oph.js → row.stories-C6aRnuL5.js} +1 -1
- package/dist/storybook/assets/{table-CB6btQu9.js → table-Dh7Es_V6.js} +1 -1
- package/dist/storybook/assets/{table.stories-CvHvaYMC.js → table.stories-BsPbkctl.js} +1 -1
- package/dist/storybook/assets/{title.stories-DYXG2_x-.js → title.stories-wr63QEGT.js} +1 -1
- package/dist/storybook/assets/unit-input.stories-2K9MHmw_.js +394 -0
- package/dist/storybook/assets/{unit-table.stories-DiER-CMn.js → unit-table.stories-CbAekNaE.js} +1 -1
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/unit-input.stories-DRP-nDdh.js +0 -380
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 { isScientificStringNum, roundToPrecision,
|
|
19
|
+
import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, roundToFixed, validateNumber, cleanNumStr, stripLeadingZeros, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, isValidNum, altUnitsList, convertAndGetValue, 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;
|
|
@@ -55697,11 +55697,13 @@ const InputCell = ({
|
|
|
55697
55697
|
);
|
|
55698
55698
|
};
|
|
55699
55699
|
const COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;
|
|
55700
|
+
const safeToString = (value) => String(toString$1(value));
|
|
55700
55701
|
const roundNumberCosmetic = (value) => {
|
|
55701
55702
|
const isScientific = isScientificStringNum(value);
|
|
55702
|
-
return !isScientific ?
|
|
55703
|
+
return !isScientific ? safeToString(
|
|
55704
|
+
roundToPrecision(toNum(value), COSMETIC_ROUNDING_DEFAULT_PRECISION)
|
|
55705
|
+
) : value;
|
|
55703
55706
|
};
|
|
55704
|
-
const safeToString = (value) => String(toString$1(value));
|
|
55705
55707
|
const getStringName$1 = (name2) => {
|
|
55706
55708
|
if (!name2) return "";
|
|
55707
55709
|
if (typeof name2 === "string") {
|
|
@@ -55740,11 +55742,6 @@ const NumberInput = ({
|
|
|
55740
55742
|
roundDisplayValue,
|
|
55741
55743
|
disableInternalErrorValidationMessages = false
|
|
55742
55744
|
}) => {
|
|
55743
|
-
const inputRef = useRef(null);
|
|
55744
|
-
const [displayValue, setDisplayValue] = useState(safeToString(value));
|
|
55745
|
-
const [focus2, setFocus] = useState(false);
|
|
55746
|
-
const [pristine, setPristine] = useState(true);
|
|
55747
|
-
const stringName = getStringName$1(name2);
|
|
55748
55745
|
const validateInputValue = (value2) => {
|
|
55749
55746
|
const validation = validateNumber(value2);
|
|
55750
55747
|
if (allowEmpty && value2 === "" || validation.valid) {
|
|
@@ -55753,11 +55750,26 @@ const NumberInput = ({
|
|
|
55753
55750
|
return validation;
|
|
55754
55751
|
}
|
|
55755
55752
|
};
|
|
55753
|
+
const cosmeticRound = (value2) => {
|
|
55754
|
+
var _a2;
|
|
55755
|
+
const displayValueEndsWithZero = !!(value2 == null ? void 0 : value2.endsWith("0"));
|
|
55756
|
+
const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
|
|
55757
|
+
value2 && // not when empty typed value
|
|
55758
|
+
!displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
|
|
55759
|
+
((_a2 = validateInputValue(value2)) == null ? void 0 : _a2.valid);
|
|
55760
|
+
const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(value2) : value2;
|
|
55761
|
+
return safeToString(valueWithCosmeticRounding);
|
|
55762
|
+
};
|
|
55763
|
+
const inputRef = useRef(null);
|
|
55764
|
+
const [displayValue, setDisplayValue] = useState(
|
|
55765
|
+
cosmeticRound(safeToString(value))
|
|
55766
|
+
);
|
|
55767
|
+
const [focus2, setFocus] = useState(false);
|
|
55768
|
+
const stringName = getStringName$1(name2);
|
|
55756
55769
|
const { valid, errors: errors2 } = validateInputValue(displayValue);
|
|
55757
55770
|
const firstError = errors2 && errors2.length && !disableInternalErrorValidationMessages ? errors2[0] : null;
|
|
55758
55771
|
useEffect(() => {
|
|
55759
|
-
setDisplayValue(safeToString(value));
|
|
55760
|
-
setPristine(true);
|
|
55772
|
+
setDisplayValue(cosmeticRound(safeToString(value)));
|
|
55761
55773
|
}, [value, enableCosmeticRounding, enableDisplayRounding]);
|
|
55762
55774
|
useEffect(() => {
|
|
55763
55775
|
if (!focus2 && !valid) {
|
|
@@ -55767,27 +55779,24 @@ const NumberInput = ({
|
|
|
55767
55779
|
}
|
|
55768
55780
|
}, [focus2, valid, error2]);
|
|
55769
55781
|
const onChangeValue = (evt) => {
|
|
55770
|
-
|
|
55782
|
+
var _a2, _b;
|
|
55783
|
+
const value2 = evt instanceof KeyboardEvent ? displayValue : (_a2 = evt == null ? void 0 : evt.target) == null ? void 0 : _a2.value;
|
|
55784
|
+
const inputValue = cleanNumStr(
|
|
55785
|
+
value2.replaceAll(" ", "").replaceAll("|", "")
|
|
55786
|
+
);
|
|
55787
|
+
setDisplayValue(inputValue);
|
|
55788
|
+
if ((_b = validateInputValue(inputValue)) == null ? void 0 : _b.valid) {
|
|
55771
55789
|
const event = {
|
|
55772
55790
|
...evt,
|
|
55773
55791
|
target: {
|
|
55774
55792
|
...evt.target,
|
|
55775
|
-
value: stripLeadingZeros(safeToString(
|
|
55793
|
+
value: stripLeadingZeros(safeToString(inputValue)),
|
|
55776
55794
|
name: stringName
|
|
55777
55795
|
}
|
|
55778
55796
|
};
|
|
55779
55797
|
onChange(event);
|
|
55780
55798
|
}
|
|
55781
55799
|
};
|
|
55782
|
-
const onSetValue = (evt) => {
|
|
55783
|
-
const input2 = evt.target;
|
|
55784
|
-
const { value: value2 } = input2;
|
|
55785
|
-
const inputValue = cleanNumStr(
|
|
55786
|
-
value2.replaceAll(" ", "").replaceAll("|", "")
|
|
55787
|
-
);
|
|
55788
|
-
setDisplayValue(inputValue);
|
|
55789
|
-
setPristine(false);
|
|
55790
|
-
};
|
|
55791
55800
|
useEffect(() => {
|
|
55792
55801
|
if (inputRef && (inputRef == null ? void 0 : inputRef.current) && enableDisplayRounding && focus2) {
|
|
55793
55802
|
const textInput = inputRef.current;
|
|
@@ -55810,12 +55819,6 @@ const NumberInput = ({
|
|
|
55810
55819
|
};
|
|
55811
55820
|
const shouldDisplayRound = enableDisplayRounding && !focus2 && valid;
|
|
55812
55821
|
const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? safeToString(roundDisplayValue(displayValue)) : roundToFixed(displayValue, 2) : displayValue;
|
|
55813
|
-
const displayValueEndsWithZero = !!(valueWithDisplayRounding == null ? void 0 : valueWithDisplayRounding.endsWith("0"));
|
|
55814
|
-
const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
|
|
55815
|
-
valueWithDisplayRounding && // not when empty typed value
|
|
55816
|
-
!displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
|
|
55817
|
-
valid;
|
|
55818
|
-
const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(valueWithDisplayRounding) : valueWithDisplayRounding;
|
|
55819
55822
|
return /* @__PURE__ */ jsx(
|
|
55820
55823
|
KeyboardEventHandler,
|
|
55821
55824
|
{
|
|
@@ -55829,11 +55832,11 @@ const NumberInput = ({
|
|
|
55829
55832
|
testId,
|
|
55830
55833
|
disabled: disabled2,
|
|
55831
55834
|
placeholder: placeholder3,
|
|
55832
|
-
value:
|
|
55833
|
-
onChange:
|
|
55835
|
+
value: valueWithDisplayRounding,
|
|
55836
|
+
onChange: onChangeValue,
|
|
55834
55837
|
onFocus: onInputFocus,
|
|
55835
55838
|
onBlur: onInputBlur,
|
|
55836
|
-
error:
|
|
55839
|
+
error: firstError || error2,
|
|
55837
55840
|
warning: warning2,
|
|
55838
55841
|
right: !left2,
|
|
55839
55842
|
small: small2,
|
|
@@ -70554,7 +70557,7 @@ const UnitInput = ({
|
|
|
70554
70557
|
small: small2,
|
|
70555
70558
|
sections: alternativeUnits.map(([value2, altUnit, label2]) => {
|
|
70556
70559
|
const displayUnit = label2 || altUnit || "";
|
|
70557
|
-
const safeValue =
|
|
70560
|
+
const safeValue = isValidNum(value2) ? value2 : "";
|
|
70558
70561
|
const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
|
|
70559
70562
|
return {
|
|
70560
70563
|
type: "Option",
|