From 960ddf2e57c14b5f247195ae51ff431ee313cd50 Mon Sep 17 00:00:00 2001 From: ycmj Date: Thu, 11 Jan 2024 17:50:26 +0100 Subject: [PATCH] STORY-7335: fix priority of pricefield helpertext --- build/Component/PriceInput/PriceInput.js | 13 +++++++------ package-lock.json | 4 ++-- package.json | 2 +- src/Component/PriceInput/PriceInput.tsx | 14 ++++++++------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/build/Component/PriceInput/PriceInput.js b/build/Component/PriceInput/PriceInput.js index f21965bc..ce66235d 100644 --- a/build/Component/PriceInput/PriceInput.js +++ b/build/Component/PriceInput/PriceInput.js @@ -52,11 +52,12 @@ var Number_1 = require("../../Utilities/Format/Number"); var Definition_1 = __importDefault(require("../App/Stateless/Style/Theme/Definition")); var PriceField = function (_a) { var _b; - var _c = _a.currency, currency = _c === void 0 ? 'eur' : _c, valueInCent = _a.valueInCent, _d = _a.language, language = _d === void 0 ? Language_1.LANGUAGE.GERMAN : _d, _e = _a.selectOnFocus, selectOnFocus = _e === void 0 ? false : _e, _f = _a.showDecimals, showDecimals = _f === void 0 ? false : _f, _g = _a.min, min = _g === void 0 ? Number.NEGATIVE_INFINITY : _g, _h = _a.max, max = _h === void 0 ? Number.POSITIVE_INFINITY : _h, textFieldProps = _a.textFieldProps, _j = _a.currencyPosition, currencyPosition = _j === void 0 ? usePriceFieldAdornment_1.AdornmentPosition.end : _j, disabled = _a.disabled, setValue = _a.setValue, required = _a.required, error = _a.error, _k = _a.autoCorrection, autoCorrection = _k === void 0 ? false : _k, getValidationState = _a.getValidationState; - var _l = (0, usePriceFieldAdornment_1.default)(currencyPosition), position = _l[0], at = _l[1]; - var _m = (0, react_intl_1.useIntl)(), formatNumber = _m.formatNumber, formatMessage = _m.formatMessage; + var _c; + var _d = _a.currency, currency = _d === void 0 ? 'eur' : _d, valueInCent = _a.valueInCent, _e = _a.language, language = _e === void 0 ? Language_1.LANGUAGE.GERMAN : _e, _f = _a.selectOnFocus, selectOnFocus = _f === void 0 ? false : _f, _g = _a.showDecimals, showDecimals = _g === void 0 ? false : _g, _h = _a.min, min = _h === void 0 ? Number.NEGATIVE_INFINITY : _h, _j = _a.max, max = _j === void 0 ? Number.POSITIVE_INFINITY : _j, textFieldProps = _a.textFieldProps, _k = _a.currencyPosition, currencyPosition = _k === void 0 ? usePriceFieldAdornment_1.AdornmentPosition.end : _k, disabled = _a.disabled, setValue = _a.setValue, required = _a.required, error = _a.error, _l = _a.autoCorrection, autoCorrection = _l === void 0 ? false : _l, getValidationState = _a.getValidationState; + var _m = (0, usePriceFieldAdornment_1.default)(currencyPosition), position = _m[0], at = _m[1]; + var _o = (0, react_intl_1.useIntl)(), formatNumber = _o.formatNumber, formatMessage = _o.formatMessage; var locale = (0, Locale_1.mapLanguageToLocale)(language); - var _o = react_1.default.useState((0, PriceInput_helper_1.getLocaleString)(locale, (0, Number_1.divideBy100)(valueInCent, showDecimals), true, showDecimals)), localValue = _o[0], setLocalValue = _o[1]; + var _p = react_1.default.useState((0, PriceInput_helper_1.getLocaleString)(locale, (0, Number_1.divideBy100)(valueInCent, showDecimals), true, showDecimals)), localValue = _p[0], setLocalValue = _p[1]; var decimalSeparator = (0, Number_1.getDecimalSeparator)(locale); var groupingSeparator = (0, Number_1.getGroupingSeparator)(locale); var outOfRange = (!!valueInCent) && ((min !== -Infinity && valueInCent < min) || (max !== Infinity && valueInCent > max)); @@ -112,11 +113,11 @@ var PriceField = function (_a) { (0, react_1.useEffect)(function () { getValidationState === null || getValidationState === void 0 ? void 0 : getValidationState(!hasErrors); }, [hasErrors]); - return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(TextField_1.default, __assign({}, textFieldProps, { helperText: hasErrors + return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(TextField_1.default, __assign({}, textFieldProps, { helperText: ((_c = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.helperText) !== null && _c !== void 0 ? _c : hasErrors) ? outOfRange ? "min: ".concat(formatNumber(min / 100, __assign({}, (0, PriceInput_helper_1.toLocaleStringFractionOptions)(showDecimals ? 2 : 0))), " max: ").concat(formatNumber(max / 100, __assign({}, (0, PriceInput_helper_1.toLocaleStringFractionOptions)(showDecimals ? 2 : 0)))) : formatMessage({ id: 'priceField.invalid' }) - : textFieldProps.helperText, value: localValue, selectOnFocus: selectOnFocus, error: hasErrors, required: required, onFocus: _onFocus, onBlur: _onBlur, onChange: _onChange, hideClearButton: disabled, InputProps: (_b = {}, + : '', value: localValue, selectOnFocus: selectOnFocus, error: hasErrors, required: required, onFocus: _onFocus, onBlur: _onBlur, onChange: _onChange, hideClearButton: disabled, InputProps: (_b = {}, _b[position] = (0, jsx_runtime_1.jsx)(material_1.InputAdornment, __assign({ position: at }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: disabled ? Definition_1.default.palette.text.disabled : 'inherit' }, { children: Format_1.Currency.getCurrencySign(currency) })) })), _b), disabled: disabled })) }); }; diff --git a/package-lock.json b/package-lock.json index 1d3f2acb..4bd72adb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@elumeo/jfs-core", - "version": "11.2.4", + "version": "11.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@elumeo/jfs-core", - "version": "11.2.4", + "version": "11.2.5", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index a5a85e51..901b9846 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@elumeo/jfs-core", - "version": "11.2.4", + "version": "11.2.5", "description": "Foundation for all JFS Apps", "main": "Main.js", "directories": { diff --git a/src/Component/PriceInput/PriceInput.tsx b/src/Component/PriceInput/PriceInput.tsx index a443491e..ccd79086 100644 --- a/src/Component/PriceInput/PriceInput.tsx +++ b/src/Component/PriceInput/PriceInput.tsx @@ -97,7 +97,7 @@ const PriceField: React.FC = ({ const localizedValue = getLocaleString(locale, divideBy100(parsedValue, showDecimals), true, showDecimals) setLocalValue(localizedValue); } else { - if(autoCorrection) { + if (autoCorrection) { setValue(valueInCent); setLocalValue(!divideBy100(valueInCent, showDecimals) ? null @@ -123,11 +123,13 @@ const PriceField: React.FC = ({ return <>