@oliasoft-open-source/react-ui-library 4.6.18 → 4.7.0-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/assets/{index-DdTheZoQ.css → index-dOfLgtRX.css} +4 -1
- package/dist/assets/{index-3CeHq3uM.js → index-ffnttoim.js} +6 -5
- package/dist/global.css +4 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.html +1 -1
- package/dist/index.js +119 -159
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-6VNJS4EI-xbGhw5Tj.js → Color-6VNJS4EI-9rJemzwR.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-NNNQARDV-sAPbui3t.js → DocsRenderer-NNNQARDV-DP7bJ7AB.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-V3YHNWJZ-gwFLosBp.js → WithTooltip-V3YHNWJZ-eL_Uxnix.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-488HeY9k.js → accordion.stories-Ytyr6tn2.js} +1 -1
- package/dist/storybook/assets/{afe.stories-Rsl77dCu.js → afe.stories-Ad1-l25x.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-kUTQnA6P.js → buttons-and-links-fv_xHVqw.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-LogF6TT6.js → casing-loads.stories-WfK3k-mh.js} +1 -1
- package/dist/storybook/assets/{cell.stories-BF9fKK_5.js → cell.stories-Xy61z8ka.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-IUW2ushY.js → chunk-HLWAVYOI-RXldIcZr.js} +1 -1
- package/dist/storybook/assets/{color-T7GIoOH6.js → color-5ySMclFt.js} +1 -1
- package/dist/storybook/assets/file-button.stories-XxMjOBfe.js +10 -0
- package/dist/storybook/assets/file-input-A0eGNEgX.js +1 -0
- package/dist/storybook/assets/{file-input.stories-2-2uTWvd.js → file-input.stories-dM7UFPVo.js} +1 -1
- package/dist/storybook/assets/{footer.stories-nvn3DsNw.js → footer.stories-4cSc0hBz.js} +1 -1
- package/dist/storybook/assets/{form.stories-TIQoYJwC.js → form.stories--Sgi1gUF.js} +1 -1
- package/dist/storybook/assets/{formation.stories-m_rHJhHE.js → formation.stories-VUtbgcsq.js} +1 -1
- package/dist/storybook/assets/{formatter-SWP5E3XI-GzRPFG7m.js → formatter-SWP5E3XI-qYj9Quey.js} +1 -1
- package/dist/storybook/assets/iframe-oMAlwWd9.js +7 -0
- package/dist/storybook/assets/{index-wKW2GPrE.js → index-RhTUHV_k.js} +5 -5
- package/dist/storybook/assets/{index-qZmQ7nA9.js → index-VSx05S_2.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-yF-PiFm1.js → input-group.stories-ZBffPltv.js} +1 -1
- package/dist/storybook/assets/{input-validation-U4HJ5Ucw.js → input-validation-bb_81fGi.js} +1 -1
- package/dist/storybook/assets/{inputs-S04nRGW2.js → inputs-MxyGbJ9Y.js} +4 -4
- package/dist/storybook/assets/{layout-forms-a8CnPDfT.js → layout-forms-_uf7qzAu.js} +1 -1
- package/dist/storybook/assets/{layout-general-Khl-lgRH.js → layout-general-rHEcWCrx.js} +1 -1
- package/dist/storybook/assets/{modal.stories-HOB4HNE4.js → modal.stories-rjCFe4Mn.js} +1 -1
- package/dist/storybook/assets/number-input-xqup0wHW.js +1 -0
- package/dist/storybook/assets/number-input.stories-Kzl7Diug.js +153 -0
- package/dist/storybook/assets/{padding-and-spacing-ckWSgL0y.js → padding-and-spacing-dUA1CCP8.js} +1 -1
- package/dist/storybook/assets/{pagination-lFdPlLPJ.js → pagination-er5fRdi2.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-etfovhze.js → pagination.stories-9_uskT8r.js} +1 -1
- package/dist/storybook/assets/{popover.stories-eItcO8iz.js → popover.stories-5aZN8AoC.js} +1 -1
- package/dist/storybook/assets/{preview-eOJx8ySI.js → preview-3kPhKzar.js} +1 -1
- package/dist/storybook/assets/{preview-YmO-dFt7.js → preview-64tDm6Er.js} +2 -2
- package/dist/storybook/assets/{reservoirs.stories-6dilTPJE.js → reservoirs.stories-XGU7s6pI.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-Vu2wd1uh.js → rich-text-input.stories-3Xaavdx_.js} +1 -1
- package/dist/storybook/assets/{row.stories-6wXvgyio.js → row.stories-Ph7Ckyfn.js} +1 -1
- package/dist/storybook/assets/{select-IxUsW-Xm.js → select-KWgree43.js} +1 -1
- package/dist/storybook/assets/{select.stories-Kbzpw3od.js → select.stories-3D2KkC3_.js} +1 -1
- package/dist/storybook/assets/{smart-upload-modal.stories-VCP3yghQ.js → smart-upload-modal.stories-hjd4L84J.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-B5GMVT5T-J83QFJ3_.js → syntaxhighlighter-B5GMVT5T-1rrvKZrw.js} +1 -1
- package/dist/storybook/assets/table-4SISWUSt.js +1 -0
- package/dist/storybook/assets/{table.stories-a5LZLQDT.js → table.stories-rKzdxDA4.js} +1 -1
- package/dist/storybook/assets/{title.stories-zxDbEh-U.js → title.stories-6AjYBLcL.js} +1 -1
- package/dist/storybook/assets/unit-input-OT-AqIIa.css +1 -0
- package/dist/storybook/assets/unit-input.stories--qvPjZnZ.js +349 -0
- package/dist/storybook/assets/unit-table.stories-4HlhxSjf.js +150 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/404.html +0 -1
- package/dist/storybook/assets/file-button.stories-z0vvWcvN.js +0 -10
- package/dist/storybook/assets/file-input-H1V5DMV-.js +0 -1
- package/dist/storybook/assets/iframe-NjfSsybe.js +0 -7
- package/dist/storybook/assets/number-input-ymd7m-s5.js +0 -1
- package/dist/storybook/assets/number-input.stories-0-jDCroI.js +0 -97
- package/dist/storybook/assets/table-fdcNapB-.js +0 -1
- package/dist/storybook/assets/unit-input-qBUtqoTb.css +0 -1
- package/dist/storybook/assets/unit-input.stories-QoJkzTRA.js +0 -273
- package/dist/storybook/assets/unit-table.stories-rHU8wR7Z.js +0 -150
|
@@ -11222,9 +11222,12 @@ tbody ._staticCell_u3xdj_116 ._staticCellContent_u3xdj_119 {
|
|
|
11222
11222
|
background-color: var(--color-background-primary);
|
|
11223
11223
|
transform: translate(-50%, -50%);
|
|
11224
11224
|
}
|
|
11225
|
-
.
|
|
11225
|
+
._predefinedMenuActive_ye9w9_1 input {
|
|
11226
11226
|
background: var(--color-background-disabled) !important;
|
|
11227
11227
|
}
|
|
11228
|
+
._inputWrapper_ye9w9_4 {
|
|
11229
|
+
flex: 1;
|
|
11230
|
+
}
|
|
11228
11231
|
._link_q42rz_1 a {
|
|
11229
11232
|
display: flex;
|
|
11230
11233
|
justify-content: center;
|
|
@@ -57242,7 +57242,7 @@ const inputDisabled$1 = "_inputDisabled_u3xdj_61";
|
|
|
57242
57242
|
const hideScrollbars$1 = "_hideScrollbars_u3xdj_67";
|
|
57243
57243
|
const cell = "_cell_u3xdj_77";
|
|
57244
57244
|
const disabledLink = "_disabledLink_u3xdj_87";
|
|
57245
|
-
const inputWrapper = "_inputWrapper_u3xdj_91";
|
|
57245
|
+
const inputWrapper$1 = "_inputWrapper_u3xdj_91";
|
|
57246
57246
|
const breakWord = "_breakWord_u3xdj_106";
|
|
57247
57247
|
const inputCell = "_inputCell_u3xdj_109";
|
|
57248
57248
|
const sliderCell = "_sliderCell_u3xdj_112";
|
|
@@ -57272,7 +57272,7 @@ const styles$9 = {
|
|
|
57272
57272
|
hideScrollbars: hideScrollbars$1,
|
|
57273
57273
|
cell,
|
|
57274
57274
|
disabledLink,
|
|
57275
|
-
inputWrapper,
|
|
57275
|
+
inputWrapper: inputWrapper$1,
|
|
57276
57276
|
breakWord,
|
|
57277
57277
|
inputCell,
|
|
57278
57278
|
sliderCell,
|
|
@@ -77649,10 +77649,11 @@ const styles$3 = {
|
|
|
77649
77649
|
placeholderContainer,
|
|
77650
77650
|
placeholder
|
|
77651
77651
|
};
|
|
77652
|
-
|
|
77653
|
-
const
|
|
77652
|
+
const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
|
|
77653
|
+
const inputWrapper = "_inputWrapper_ye9w9_4";
|
|
77654
77654
|
const styles$2 = {
|
|
77655
|
-
predefinedMenuActive
|
|
77655
|
+
predefinedMenuActive,
|
|
77656
|
+
inputWrapper
|
|
77656
77657
|
};
|
|
77657
77658
|
const Footer = () => {
|
|
77658
77659
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
package/dist/global.css
CHANGED
|
@@ -11222,6 +11222,9 @@ tbody ._staticCell_u3xdj_116 ._staticCellContent_u3xdj_119 {
|
|
|
11222
11222
|
background-color: var(--color-background-primary);
|
|
11223
11223
|
transform: translate(-50%, -50%);
|
|
11224
11224
|
}
|
|
11225
|
-
.
|
|
11225
|
+
._predefinedMenuActive_ye9w9_1 input {
|
|
11226
11226
|
background: var(--color-background-disabled) !important;
|
|
11227
11227
|
}
|
|
11228
|
+
._inputWrapper_ye9w9_4 {
|
|
11229
|
+
flex: 1;
|
|
11230
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -900,6 +900,7 @@ declare interface INumberInputCell extends TCommonCell {
|
|
|
900
900
|
left?: boolean;
|
|
901
901
|
validationCallback?: TEmpty;
|
|
902
902
|
allowEmpty?: boolean;
|
|
903
|
+
enableCosmeticRounding: boolean;
|
|
903
904
|
enableDisplayRounding: boolean;
|
|
904
905
|
roundDisplayValue: (value: TStringNumberNull) => TStringNumberNull;
|
|
905
906
|
}
|
|
@@ -928,6 +929,7 @@ export declare interface INumberInputProps {
|
|
|
928
929
|
allowEmpty?: boolean;
|
|
929
930
|
isInTable?: boolean;
|
|
930
931
|
groupOrder?: any;
|
|
932
|
+
enableCosmeticRounding?: boolean;
|
|
931
933
|
enableDisplayRounding?: boolean;
|
|
932
934
|
roundDisplayValue?: (args: TStringNumberNull) => TStringNumberNull;
|
|
933
935
|
}
|
|
@@ -1563,7 +1565,7 @@ export declare interface IUnitInputProps {
|
|
|
1563
1565
|
placeholder?: string;
|
|
1564
1566
|
disabled?: boolean;
|
|
1565
1567
|
disabledUnit?: boolean;
|
|
1566
|
-
error?: string |
|
|
1568
|
+
error?: string | boolean;
|
|
1567
1569
|
left?: boolean;
|
|
1568
1570
|
small?: boolean;
|
|
1569
1571
|
width?: string | number;
|
|
@@ -1573,15 +1575,12 @@ export declare interface IUnitInputProps {
|
|
|
1573
1575
|
noConversion?: boolean;
|
|
1574
1576
|
doNotConvertValue?: boolean;
|
|
1575
1577
|
testId?: string;
|
|
1576
|
-
warning?: string |
|
|
1578
|
+
warning?: string | boolean;
|
|
1577
1579
|
predefinedOptions?: IPredefinedOption[];
|
|
1578
1580
|
initialPredefinedOption?: boolean;
|
|
1579
1581
|
shouldLinkAutomaticly?: boolean;
|
|
1580
1582
|
selectedPredefinedOptionKey?: string;
|
|
1581
|
-
validationCallback?: (
|
|
1582
|
-
name: string;
|
|
1583
|
-
error: string | null;
|
|
1584
|
-
};
|
|
1583
|
+
validationCallback?: (params: IUnitInputValidationCallbackPayload) => void;
|
|
1585
1584
|
disabledValidation?: boolean;
|
|
1586
1585
|
allowEmpty?: boolean;
|
|
1587
1586
|
autoValue?: string;
|
|
@@ -1590,6 +1589,16 @@ export declare interface IUnitInputProps {
|
|
|
1590
1589
|
onClick?: MouseEventHandler<HTMLInputElement>;
|
|
1591
1590
|
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
1592
1591
|
unitTemplate?: Record<string, any>;
|
|
1592
|
+
convertBackToStorageUnit?: boolean;
|
|
1593
|
+
enableCosmeticRounding?: boolean;
|
|
1594
|
+
enableDisplayRounding?: boolean;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
declare interface IUnitInputValidationCallbackPayload {
|
|
1598
|
+
name: string | {
|
|
1599
|
+
fieldName: string;
|
|
1600
|
+
};
|
|
1601
|
+
error: string | null;
|
|
1593
1602
|
}
|
|
1594
1603
|
|
|
1595
1604
|
declare interface IUnitTable extends Omit<ITableProps['table'], 'rows'> {
|
|
@@ -1671,7 +1680,7 @@ export declare const Modal: ({ children, visible, centered, width, onEnter, onEs
|
|
|
1671
1680
|
|
|
1672
1681
|
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;
|
|
1673
1682
|
|
|
1674
|
-
export declare const NumberInput: ({ name, placeholder, disabled, error, left, small, width, value, onChange, onFocus, onBlur, tabIndex, testId, tooltip, warning, validationCallback, allowEmpty, isInTable, groupOrder, enableDisplayRounding, roundDisplayValue, }: INumberInputProps) => JSX_2.Element;
|
|
1683
|
+
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, }: INumberInputProps) => JSX_2.Element;
|
|
1675
1684
|
|
|
1676
1685
|
export declare const OptionDropdown: ({ name, label, options, onChange, showHeader, maxHeight, }: IOptionDropdownProps) => ReactElement;
|
|
1677
1686
|
|
|
@@ -1852,7 +1861,7 @@ export declare type TTriggerType = 'Text' | 'Button' | 'DropDownButton' | 'Compo
|
|
|
1852
1861
|
|
|
1853
1862
|
declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTableInputCell | IUnitTableNumberInputCell;
|
|
1854
1863
|
|
|
1855
|
-
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, }: IUnitInputProps) => JSX_2.Element;
|
|
1864
|
+
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;
|
|
1856
1865
|
|
|
1857
1866
|
export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
|
|
1858
1867
|
|
package/dist/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-
|
|
1
|
+
<!doctype html><head><title>React UI Library</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1" user-scalable="no"><meta name="apple-mobile-web-app-capable" content="yes"><script type="module" crossorigin src="/react-ui-library/assets/index-ffnttoim.js"></script><link rel="stylesheet" crossorigin href="/react-ui-library/assets/index-dOfLgtRX.css"></head><body><div id="content"></div></body>
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,8 @@ import React__default, { useContext, isValidElement, useState, useRef, useEffect
|
|
|
10
10
|
import * as PropTypes from "prop-types";
|
|
11
11
|
import PropTypes__default from "prop-types";
|
|
12
12
|
import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
|
|
13
|
-
import _$1, { 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,
|
|
14
|
-
import { roundToFixed, validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1,
|
|
15
|
-
import { isValueWithUnit as isValueWithUnit$1 } from "@oliasoft-open-source/units/dist/units";
|
|
13
|
+
import _$1, { 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";
|
|
14
|
+
import { isScientificStringNum, roundToPrecision, roundToFixed, validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, label as label$b, altUnitsList, convertAndGetValue, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
|
|
16
15
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
17
16
|
function getDefaultExportFromCjs(x2) {
|
|
18
17
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -55705,7 +55704,7 @@ const inputDisabled$1 = "_inputDisabled_u3xdj_61";
|
|
|
55705
55704
|
const hideScrollbars$1 = "_hideScrollbars_u3xdj_67";
|
|
55706
55705
|
const cell = "_cell_u3xdj_77";
|
|
55707
55706
|
const disabledLink = "_disabledLink_u3xdj_87";
|
|
55708
|
-
const inputWrapper = "_inputWrapper_u3xdj_91";
|
|
55707
|
+
const inputWrapper$1 = "_inputWrapper_u3xdj_91";
|
|
55709
55708
|
const breakWord = "_breakWord_u3xdj_106";
|
|
55710
55709
|
const inputCell = "_inputCell_u3xdj_109";
|
|
55711
55710
|
const sliderCell = "_sliderCell_u3xdj_112";
|
|
@@ -55735,7 +55734,7 @@ const styles$7 = {
|
|
|
55735
55734
|
hideScrollbars: hideScrollbars$1,
|
|
55736
55735
|
cell,
|
|
55737
55736
|
disabledLink,
|
|
55738
|
-
inputWrapper,
|
|
55737
|
+
inputWrapper: inputWrapper$1,
|
|
55739
55738
|
breakWord,
|
|
55740
55739
|
inputCell,
|
|
55741
55740
|
sliderCell,
|
|
@@ -55791,6 +55790,11 @@ const InputCell = ({
|
|
|
55791
55790
|
}
|
|
55792
55791
|
);
|
|
55793
55792
|
};
|
|
55793
|
+
const COSMETIC_ROUNDING_DEFAULT_PRECISION = 14;
|
|
55794
|
+
const roundNumberCosmetic = (value) => {
|
|
55795
|
+
const isScientific = isScientificStringNum(value);
|
|
55796
|
+
return !isScientific ? roundToPrecision(value, COSMETIC_ROUNDING_DEFAULT_PRECISION) : value;
|
|
55797
|
+
};
|
|
55794
55798
|
const getStringName$1 = (name2) => {
|
|
55795
55799
|
if (!name2)
|
|
55796
55800
|
return "";
|
|
@@ -55825,61 +55829,57 @@ const NumberInput = ({
|
|
|
55825
55829
|
allowEmpty = false,
|
|
55826
55830
|
isInTable: isInTable2,
|
|
55827
55831
|
groupOrder,
|
|
55832
|
+
enableCosmeticRounding = true,
|
|
55828
55833
|
enableDisplayRounding = false,
|
|
55829
55834
|
roundDisplayValue
|
|
55830
55835
|
}) => {
|
|
55831
55836
|
const inputRef = useRef(null);
|
|
55832
|
-
const [displayValue, setDisplayValue] = useState(value);
|
|
55833
|
-
const [validationError, setValidationError] = useState(null);
|
|
55837
|
+
const [displayValue, setDisplayValue] = useState(String(value));
|
|
55834
55838
|
const [focus2, setFocus] = useState(false);
|
|
55839
|
+
const [pristine, setPristine] = useState(true);
|
|
55835
55840
|
const stringName = getStringName$1(name2);
|
|
55836
55841
|
const validateInputValue = (value2) => {
|
|
55837
|
-
|
|
55842
|
+
const validation = validateNumber(value2);
|
|
55838
55843
|
if (allowEmpty && value2 === "" || validation.valid) {
|
|
55839
55844
|
return { ...validation, valid: true, errors: void 0 };
|
|
55840
55845
|
} else {
|
|
55841
55846
|
return validation;
|
|
55842
55847
|
}
|
|
55843
55848
|
};
|
|
55849
|
+
const { valid, errors: errors2 } = validateInputValue(displayValue);
|
|
55850
|
+
const firstError = errors2 && errors2.length ? errors2[0] : null;
|
|
55844
55851
|
useEffect(() => {
|
|
55845
|
-
|
|
55846
|
-
|
|
55847
|
-
|
|
55848
|
-
|
|
55849
|
-
validationCallback(stringName, null);
|
|
55850
|
-
} else {
|
|
55851
|
-
const firstError = errors2 && errors2.length ? errors2[0] : null;
|
|
55852
|
-
setValidationError(firstError);
|
|
55852
|
+
setDisplayValue(String(value));
|
|
55853
|
+
}, [value, enableCosmeticRounding, enableDisplayRounding]);
|
|
55854
|
+
useEffect(() => {
|
|
55855
|
+
if (!focus2 && !valid) {
|
|
55853
55856
|
validationCallback(stringName, firstError);
|
|
55857
|
+
} else {
|
|
55858
|
+
validationCallback(stringName, null);
|
|
55854
55859
|
}
|
|
55855
|
-
}, [
|
|
55856
|
-
const
|
|
55857
|
-
|
|
55858
|
-
|
|
55859
|
-
const inputValue = cleanNumStr(
|
|
55860
|
-
value2.replaceAll(" ", "").replaceAll("|", "")
|
|
55861
|
-
);
|
|
55862
|
-
const { valid, errors: errors2 } = validateInputValue(inputValue);
|
|
55863
|
-
if (valid) {
|
|
55864
|
-
const newEvent = {
|
|
55860
|
+
}, [focus2, valid, error2]);
|
|
55861
|
+
const onChangeValue = (evt) => {
|
|
55862
|
+
if (valid && !pristine) {
|
|
55863
|
+
const event = {
|
|
55865
55864
|
...evt,
|
|
55866
55865
|
target: {
|
|
55867
55866
|
...evt.target,
|
|
55868
|
-
value:
|
|
55867
|
+
value: String(displayValue),
|
|
55869
55868
|
name: stringName
|
|
55870
55869
|
}
|
|
55871
55870
|
};
|
|
55872
|
-
onChange(
|
|
55873
|
-
setDisplayValue(inputValue);
|
|
55874
|
-
setValidationError(null);
|
|
55875
|
-
validationCallback(stringName, null);
|
|
55876
|
-
} else {
|
|
55877
|
-
setDisplayValue(inputValue);
|
|
55878
|
-
const firstError = errors2 && errors2.length ? errors2[0] : null;
|
|
55879
|
-
setValidationError(firstError);
|
|
55880
|
-
validationCallback(stringName, firstError);
|
|
55871
|
+
onChange(event);
|
|
55881
55872
|
}
|
|
55882
55873
|
};
|
|
55874
|
+
const onSetValue = (evt) => {
|
|
55875
|
+
const input2 = evt.target;
|
|
55876
|
+
const { value: value2 } = input2;
|
|
55877
|
+
const inputValue = cleanNumStr(
|
|
55878
|
+
value2.replaceAll(" ", "").replaceAll("|", "")
|
|
55879
|
+
);
|
|
55880
|
+
setDisplayValue(inputValue);
|
|
55881
|
+
setPristine(false);
|
|
55882
|
+
};
|
|
55883
55883
|
useEffect(() => {
|
|
55884
55884
|
if (inputRef && (inputRef == null ? void 0 : inputRef.current) && enableDisplayRounding && focus2) {
|
|
55885
55885
|
const textInput = inputRef.current;
|
|
@@ -55897,33 +55897,48 @@ const NumberInput = ({
|
|
|
55897
55897
|
};
|
|
55898
55898
|
const onInputBlur = (evt) => {
|
|
55899
55899
|
setFocus(false);
|
|
55900
|
+
onChangeValue(evt);
|
|
55900
55901
|
onBlur(evt);
|
|
55901
55902
|
};
|
|
55902
|
-
const
|
|
55903
|
+
const shouldDisplayRound = enableDisplayRounding && !focus2;
|
|
55904
|
+
const valueWithDisplayRounding = shouldDisplayRound ? roundDisplayValue ? String(roundDisplayValue(displayValue)) : roundToFixed(displayValue, 2) : displayValue;
|
|
55905
|
+
const displayValueEndsWithZero = !!(valueWithDisplayRounding == null ? void 0 : valueWithDisplayRounding.endsWith("0"));
|
|
55906
|
+
const shouldCosmeticallyRound = enableCosmeticRounding && // only when prop is enabled
|
|
55907
|
+
valueWithDisplayRounding && // not when empty typed value
|
|
55908
|
+
!displayValueEndsWithZero && // not when intentionally trying to type trailing zeros as interim values (OW-17109)
|
|
55909
|
+
valid;
|
|
55910
|
+
const valueWithCosmeticRounding = shouldCosmeticallyRound ? roundNumberCosmetic(valueWithDisplayRounding) : valueWithDisplayRounding;
|
|
55903
55911
|
return /* @__PURE__ */ jsx(
|
|
55904
|
-
|
|
55912
|
+
KeyboardEventHandler,
|
|
55905
55913
|
{
|
|
55906
|
-
|
|
55907
|
-
|
|
55908
|
-
|
|
55909
|
-
|
|
55910
|
-
|
|
55911
|
-
|
|
55912
|
-
|
|
55913
|
-
|
|
55914
|
-
|
|
55915
|
-
|
|
55916
|
-
|
|
55917
|
-
|
|
55918
|
-
|
|
55919
|
-
|
|
55920
|
-
|
|
55921
|
-
|
|
55922
|
-
|
|
55923
|
-
|
|
55924
|
-
|
|
55925
|
-
|
|
55926
|
-
|
|
55914
|
+
handleKeys: [EventKey.ENTER],
|
|
55915
|
+
onKeyEvent: (_key, evt) => onChangeValue(evt),
|
|
55916
|
+
children: /* @__PURE__ */ jsx(
|
|
55917
|
+
Input$1,
|
|
55918
|
+
{
|
|
55919
|
+
type: "text",
|
|
55920
|
+
name: stringName,
|
|
55921
|
+
testId,
|
|
55922
|
+
disabled: disabled2,
|
|
55923
|
+
placeholder: placeholder3,
|
|
55924
|
+
value: valueWithCosmeticRounding,
|
|
55925
|
+
onChange: onSetValue,
|
|
55926
|
+
onFocus: onInputFocus,
|
|
55927
|
+
onBlur: onInputBlur,
|
|
55928
|
+
error: !focus2 && (firstError || error2),
|
|
55929
|
+
warning: warning2,
|
|
55930
|
+
right: !left2,
|
|
55931
|
+
small: small2,
|
|
55932
|
+
width: width2,
|
|
55933
|
+
isInTable: isInTable2,
|
|
55934
|
+
groupOrder,
|
|
55935
|
+
tabIndex,
|
|
55936
|
+
tooltip: tooltip2,
|
|
55937
|
+
ref: inputRef
|
|
55938
|
+
},
|
|
55939
|
+
stringName
|
|
55940
|
+
)
|
|
55941
|
+
}
|
|
55927
55942
|
);
|
|
55928
55943
|
};
|
|
55929
55944
|
const NumberInputCell = ({ cell: cell2, testId }) => {
|
|
@@ -55949,6 +55964,7 @@ const NumberInputCell = ({ cell: cell2, testId }) => {
|
|
|
55949
55964
|
tooltip: cell2.tooltip,
|
|
55950
55965
|
validationCallback: cell2.validationCallback,
|
|
55951
55966
|
allowEmpty: cell2.allowEmpty,
|
|
55967
|
+
enableCosmeticRounding: cell2.enableCosmeticRounding,
|
|
55952
55968
|
enableDisplayRounding: cell2.enableDisplayRounding,
|
|
55953
55969
|
roundDisplayValue: cell2.roundDisplayValue
|
|
55954
55970
|
}
|
|
@@ -70382,45 +70398,6 @@ const getStringName = (name2) => {
|
|
|
70382
70398
|
}
|
|
70383
70399
|
return typeof name2 === "string" ? name2 : "";
|
|
70384
70400
|
};
|
|
70385
|
-
const isErrorObject = (error2) => isObjectLike(error2) && has$1(error2, "message");
|
|
70386
|
-
const getErrorMessage = (error2) => {
|
|
70387
|
-
if (typeof error2 === "string") {
|
|
70388
|
-
return error2;
|
|
70389
|
-
} else if (isErrorObject(error2)) {
|
|
70390
|
-
return error2.message;
|
|
70391
|
-
} else {
|
|
70392
|
-
return null;
|
|
70393
|
-
}
|
|
70394
|
-
};
|
|
70395
|
-
const hasLeadingZeroes = (value) => {
|
|
70396
|
-
return value.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g)) === 0;
|
|
70397
|
-
};
|
|
70398
|
-
const validate = (value, options) => {
|
|
70399
|
-
var _a;
|
|
70400
|
-
const {
|
|
70401
|
-
allowEmpty = false,
|
|
70402
|
-
autoValue,
|
|
70403
|
-
placeholder: placeholder3,
|
|
70404
|
-
disabledValidation = false
|
|
70405
|
-
} = options || {};
|
|
70406
|
-
const stringValue = String(value);
|
|
70407
|
-
if (disabledValidation || autoValue || placeholder3) {
|
|
70408
|
-
return null;
|
|
70409
|
-
}
|
|
70410
|
-
const cleanValue = isValueWithUnit$1(stringValue) ? getValue$1(stringValue) : stringValue;
|
|
70411
|
-
if (allowEmpty && cleanValue === "") {
|
|
70412
|
-
return null;
|
|
70413
|
-
}
|
|
70414
|
-
if (hasLeadingZeroes(cleanValue)) {
|
|
70415
|
-
return "Invalid number format due to leading zeroes";
|
|
70416
|
-
}
|
|
70417
|
-
const validationErrors = validateNumber(cleanValue);
|
|
70418
|
-
if (!validationErrors.valid) {
|
|
70419
|
-
const firstError = ((_a = validationErrors == null ? void 0 : validationErrors.errors) == null ? void 0 : _a[0]) ?? null;
|
|
70420
|
-
return getErrorMessage(firstError);
|
|
70421
|
-
}
|
|
70422
|
-
return null;
|
|
70423
|
-
};
|
|
70424
70401
|
const isUnitKnown = (unit2 = "") => {
|
|
70425
70402
|
var _a;
|
|
70426
70403
|
return (_a = KNOWN_UNITS) == null ? void 0 : _a.includes(unit2);
|
|
@@ -70429,16 +70406,18 @@ const isKnownUnit = (valueWithUnit, defaultUnit) => {
|
|
|
70429
70406
|
const unitFromValue = getUnit(valueWithUnit || "");
|
|
70430
70407
|
return isUnitKnown(defaultUnit) && isUnitKnown(unitFromValue);
|
|
70431
70408
|
};
|
|
70432
|
-
const predefinedMenuActive = "
|
|
70409
|
+
const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
|
|
70410
|
+
const inputWrapper = "_inputWrapper_ye9w9_4";
|
|
70433
70411
|
const styles = {
|
|
70434
|
-
predefinedMenuActive
|
|
70412
|
+
predefinedMenuActive,
|
|
70413
|
+
inputWrapper
|
|
70435
70414
|
};
|
|
70436
70415
|
const UnitInput = ({
|
|
70437
70416
|
name: name2,
|
|
70438
70417
|
placeholder: placeholder3 = "",
|
|
70439
70418
|
disabled: disabled2 = false,
|
|
70440
70419
|
disabledUnit = false,
|
|
70441
|
-
error: error2 =
|
|
70420
|
+
error: error2 = false,
|
|
70442
70421
|
left: left2 = false,
|
|
70443
70422
|
small: small2 = false,
|
|
70444
70423
|
width: width2 = "100%",
|
|
@@ -70457,15 +70436,18 @@ const UnitInput = ({
|
|
|
70457
70436
|
unitTemplate,
|
|
70458
70437
|
doNotConvertValue = false,
|
|
70459
70438
|
testId,
|
|
70460
|
-
warning: warning2 =
|
|
70439
|
+
warning: warning2 = false,
|
|
70461
70440
|
predefinedOptions,
|
|
70462
70441
|
initialPredefinedOption = false,
|
|
70463
70442
|
shouldLinkAutomaticly = true,
|
|
70464
70443
|
selectedPredefinedOptionKey,
|
|
70465
|
-
validationCallback
|
|
70444
|
+
validationCallback,
|
|
70466
70445
|
disabledValidation = false,
|
|
70467
70446
|
allowEmpty = false,
|
|
70468
|
-
autoValue
|
|
70447
|
+
autoValue,
|
|
70448
|
+
convertBackToStorageUnit = false,
|
|
70449
|
+
enableCosmeticRounding = true,
|
|
70450
|
+
enableDisplayRounding = false
|
|
70469
70451
|
}) => {
|
|
70470
70452
|
if (typeof value === "number") {
|
|
70471
70453
|
value = `${value}`;
|
|
@@ -70494,7 +70476,6 @@ const UnitInput = ({
|
|
|
70494
70476
|
);
|
|
70495
70477
|
const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : convertedAutoValue !== "" ? { value: convertedAutoValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
|
|
70496
70478
|
const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
|
|
70497
|
-
const [validationError, setValidationError] = useState(null);
|
|
70498
70479
|
const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(
|
|
70499
70480
|
initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
|
|
70500
70481
|
);
|
|
@@ -70527,33 +70508,16 @@ const UnitInput = ({
|
|
|
70527
70508
|
const stringName2 = getStringName(name2);
|
|
70528
70509
|
const input2 = evt.target;
|
|
70529
70510
|
const { value: inputValue, selectionStart: currentCursorPosition } = input2;
|
|
70530
|
-
const
|
|
70531
|
-
|
|
70532
|
-
|
|
70533
|
-
|
|
70534
|
-
|
|
70535
|
-
|
|
70536
|
-
|
|
70537
|
-
autoValue,
|
|
70538
|
-
placeholder: placeholder3,
|
|
70539
|
-
disabledValidation
|
|
70511
|
+
const newValue = withUnit(inputValue, (displayLayer == null ? void 0 : displayLayer.unit) || "");
|
|
70512
|
+
const returnValue = convertBackToStorageUnit ? withUnit(convertAndGetValue(newValue, propUnit), propUnit) : newValue;
|
|
70513
|
+
onChange({
|
|
70514
|
+
target: {
|
|
70515
|
+
value: returnValue,
|
|
70516
|
+
name: stringName2
|
|
70517
|
+
}
|
|
70540
70518
|
});
|
|
70541
|
-
|
|
70542
|
-
|
|
70543
|
-
target: {
|
|
70544
|
-
value: newValue,
|
|
70545
|
-
name: stringName2
|
|
70546
|
-
}
|
|
70547
|
-
});
|
|
70548
|
-
const [val, u] = split$1(newValue);
|
|
70549
|
-
setDisplayLayer({ value: val, unit: u });
|
|
70550
|
-
setValidationError(null);
|
|
70551
|
-
validationCallback(stringName2, null);
|
|
70552
|
-
} else {
|
|
70553
|
-
setDisplayLayer({ value: cleanInputValue, unit: displayLayer.unit });
|
|
70554
|
-
setValidationError(validationResult);
|
|
70555
|
-
validationCallback(stringName2, validationResult);
|
|
70556
|
-
}
|
|
70519
|
+
const [val, u] = split$1(newValue);
|
|
70520
|
+
setDisplayLayer({ value: val, unit: u });
|
|
70557
70521
|
runAfterUpdate(() => {
|
|
70558
70522
|
input2.selectionStart = currentCursorPosition;
|
|
70559
70523
|
input2.selectionEnd = currentCursorPosition;
|
|
@@ -70599,14 +70563,6 @@ const UnitInput = ({
|
|
|
70599
70563
|
}
|
|
70600
70564
|
}
|
|
70601
70565
|
}
|
|
70602
|
-
const cleanValue = checkAndCleanDecimalComma(propValue);
|
|
70603
|
-
const errorMessage = validate(cleanValue, {
|
|
70604
|
-
allowEmpty,
|
|
70605
|
-
autoValue,
|
|
70606
|
-
placeholder: placeholder3,
|
|
70607
|
-
disabledValidation
|
|
70608
|
-
});
|
|
70609
|
-
setValidationError(errorMessage);
|
|
70610
70566
|
}, [initDisplayUnit, value, error2, shouldLinkAutomaticly]);
|
|
70611
70567
|
const alternativeUnits = getAlternativeUnits();
|
|
70612
70568
|
const displayUnitLabel = label$b(displayLayer.unit) || displayLayer.unit || "";
|
|
@@ -70640,6 +70596,14 @@ const UnitInput = ({
|
|
|
70640
70596
|
selected: foundPredefinedMenuOption === el2 && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
|
|
70641
70597
|
};
|
|
70642
70598
|
};
|
|
70599
|
+
const handleValidationCallback = (name22, error22) => {
|
|
70600
|
+
if (validationCallback) {
|
|
70601
|
+
validationCallback({
|
|
70602
|
+
name: name22,
|
|
70603
|
+
error: error22
|
|
70604
|
+
});
|
|
70605
|
+
}
|
|
70606
|
+
};
|
|
70643
70607
|
sectionsPredefinedMenu = [
|
|
70644
70608
|
{
|
|
70645
70609
|
type: MenuType.OPTION,
|
|
@@ -70696,10 +70660,9 @@ const UnitInput = ({
|
|
|
70696
70660
|
)
|
|
70697
70661
|
}
|
|
70698
70662
|
),
|
|
70699
|
-
/* @__PURE__ */ jsx(
|
|
70700
|
-
|
|
70663
|
+
/* @__PURE__ */ jsx("div", { className: styles.inputWrapper, children: /* @__PURE__ */ jsx(
|
|
70664
|
+
NumberInput,
|
|
70701
70665
|
{
|
|
70702
|
-
type: "text",
|
|
70703
70666
|
name: stringName,
|
|
70704
70667
|
testId,
|
|
70705
70668
|
disabled: disabled2,
|
|
@@ -70712,12 +70675,17 @@ const UnitInput = ({
|
|
|
70712
70675
|
value: displayLayer.value,
|
|
70713
70676
|
onChange: onSetValue,
|
|
70714
70677
|
onFocus,
|
|
70715
|
-
error: error2
|
|
70678
|
+
error: error2,
|
|
70716
70679
|
warning: warning2,
|
|
70717
|
-
|
|
70680
|
+
left: left2,
|
|
70681
|
+
allowEmpty,
|
|
70682
|
+
validationCallback: handleValidationCallback,
|
|
70683
|
+
enableCosmeticRounding,
|
|
70684
|
+
enableDisplayRounding,
|
|
70685
|
+
groupOrder: predefinedOptions ? "middle" : "first"
|
|
70718
70686
|
},
|
|
70719
70687
|
stringName
|
|
70720
|
-
),
|
|
70688
|
+
) }),
|
|
70721
70689
|
displayUnitLabel && (noConvert || !knownUnit ? /* @__PURE__ */ jsx(InputGroupAddon, { groupOrder: "last", children: displayUnitLabel }) : /* @__PURE__ */ jsx(
|
|
70722
70690
|
Menu,
|
|
70723
70691
|
{
|
|
@@ -70731,9 +70699,11 @@ const UnitInput = ({
|
|
|
70731
70699
|
small: small2,
|
|
70732
70700
|
sections: alternativeUnits.map(([value2, altUnit, label2]) => {
|
|
70733
70701
|
const displayUnit = label2 || altUnit || "";
|
|
70702
|
+
const safeValue = !isNaN(Number(value2)) ? value2 : "";
|
|
70703
|
+
const displayValue = enableCosmeticRounding ? roundNumberCosmetic(safeValue) : safeValue;
|
|
70734
70704
|
return {
|
|
70735
70705
|
type: "Option",
|
|
70736
|
-
label:
|
|
70706
|
+
label: displayValue,
|
|
70737
70707
|
inline: true,
|
|
70738
70708
|
onClick: (evt) => {
|
|
70739
70709
|
evt.stopPropagation();
|
|
@@ -70801,22 +70771,12 @@ const convertVisibleRows = ({
|
|
|
70801
70771
|
const storageUnit = storageUnits[unitKey];
|
|
70802
70772
|
const unitChanged = selectedUnit !== storageUnit;
|
|
70803
70773
|
const convertedValue = unitChanged ? convertAndGetValue(value, selectedUnit, storageUnit) : cell2.value;
|
|
70804
|
-
const
|
|
70805
|
-
const displayValue = enableCosmeticRounding && (unitChanged || !isScientific) ? (
|
|
70806
|
-
/*
|
|
70807
|
-
Optionally do Excel-style "cosmetic rounding" of display values (only if enableCosmeticRounding prop on)
|
|
70808
|
-
This means rounding to slightly less precision than the underlying floating-point number type, to
|
|
70809
|
-
resolve floating-point "rounding noise" associated with storing values in one unit but converting
|
|
70810
|
-
and displaying them in another unit. This solution was evaluated by Tools Team in relation to
|
|
70811
|
-
tickets OW-10614 and OW-15745.
|
|
70812
|
-
*/
|
|
70813
|
-
roundToPrecision(convertedValue, 14)
|
|
70814
|
-
) : convertedValue;
|
|
70815
|
-
const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(displayValue) : displayValue;
|
|
70774
|
+
const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(convertedValue) : convertedValue;
|
|
70816
70775
|
return {
|
|
70817
70776
|
...cell2,
|
|
70818
70777
|
value: formattedDisplayValue,
|
|
70819
|
-
enableCosmeticRounding,
|
|
70778
|
+
enableCosmeticRounding: enableCosmeticRounding && unitChanged,
|
|
70779
|
+
//todo: why did we need to check unitChanged here? (original rationale)
|
|
70820
70780
|
enableDisplayRounding,
|
|
70821
70781
|
roundDisplayValue,
|
|
70822
70782
|
onChange: (evt) => {
|