@commercetools-uikit/money-input 20.2.3 → 20.3.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.
|
@@ -22,6 +22,7 @@ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
|
22
22
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
23
23
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
24
24
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
25
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
25
26
|
var react$1 = require('react');
|
|
26
27
|
var ReactDOM = require('react-dom');
|
|
27
28
|
var has = require('lodash/has');
|
|
@@ -57,6 +58,7 @@ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
|
57
58
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
58
59
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
59
60
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
61
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
60
62
|
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
61
63
|
var has__default = /*#__PURE__*/_interopDefault(has);
|
|
62
64
|
var Select__default = /*#__PURE__*/_interopDefault(Select);
|
|
@@ -748,16 +750,18 @@ const getHighPrecisionWrapperStyles = _ref => {
|
|
|
748
750
|
|
|
749
751
|
var messages = reactIntl.defineMessages({
|
|
750
752
|
highPrecision: {
|
|
751
|
-
id:
|
|
752
|
-
|
|
753
|
-
|
|
753
|
+
id: "UIKit.MoneyInput.highPrecision",
|
|
754
|
+
defaultMessage: [{
|
|
755
|
+
"type": 0,
|
|
756
|
+
"value": "High Precision Price"
|
|
757
|
+
}]
|
|
754
758
|
}
|
|
755
759
|
});
|
|
756
760
|
|
|
757
761
|
const _excluded = ["id"],
|
|
758
762
|
_excluded2 = ["currencies", "horizontalConstraint", "menuPortalZIndex"];
|
|
759
763
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
760
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
764
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
761
765
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
762
766
|
const TooltipWrapper = /*#__PURE__*/_styled__default["default"]("div", process.env.NODE_ENV === "production" ? {
|
|
763
767
|
target: "e1u90zjc0"
|
|
@@ -773,8 +777,8 @@ const TooltipWrapper = /*#__PURE__*/_styled__default["default"]("div", process.e
|
|
|
773
777
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
774
778
|
});
|
|
775
779
|
const moneyInputSequentialId = utils.createSequentialId('money-input-');
|
|
776
|
-
const getPortalId = id =>
|
|
777
|
-
const getPortalNode = id => document.querySelector(
|
|
780
|
+
const getPortalId = id => "portal-".concat(id);
|
|
781
|
+
const getPortalNode = id => document.querySelector("#".concat(getPortalId(id)));
|
|
778
782
|
const Portal = props => {
|
|
779
783
|
const domNode = getPortalNode(props.id);
|
|
780
784
|
if (domNode) {
|
|
@@ -818,15 +822,15 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
818
822
|
});
|
|
819
823
|
return _objectSpread(_objectSpread({}, selectStyles), {}, {
|
|
820
824
|
control: (base, state) => _objectSpread(_objectSpread({}, selectStyles.control(base, state)), {}, {
|
|
821
|
-
padding:
|
|
825
|
+
padding: "0 ".concat(designSystem.designTokens.spacing25),
|
|
822
826
|
borderTopRightRadius: '0',
|
|
823
827
|
borderBottomRightRadius: '0',
|
|
824
828
|
borderRight: '0',
|
|
825
829
|
minWidth: '80px',
|
|
826
830
|
height: '100%',
|
|
827
831
|
borderColor: (() => {
|
|
828
|
-
if (isDisabled) return
|
|
829
|
-
if (isReadOnly) return
|
|
832
|
+
if (isDisabled) return "".concat(designSystem.designTokens.borderColorForInputWhenDisabled, " !important");
|
|
833
|
+
if (isReadOnly) return "".concat(designSystem.designTokens.borderColorForInputWhenReadonly, " !important");
|
|
830
834
|
if (hasError) return designSystem.designTokens.borderColorForInputWhenError;
|
|
831
835
|
if (hasWarning) return designSystem.designTokens.borderColorForInputWhenWarning;
|
|
832
836
|
if (currencyHasFocus) {
|
|
@@ -836,7 +840,7 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
836
840
|
})(),
|
|
837
841
|
cursor: (() => {
|
|
838
842
|
if (isDisabled) return 'not-allowed';
|
|
839
|
-
if (isReadOnly) return
|
|
843
|
+
if (isReadOnly) return "default";
|
|
840
844
|
return 'pointer';
|
|
841
845
|
})(),
|
|
842
846
|
backgroundColor: (() => {
|
|
@@ -949,7 +953,7 @@ const parseRawAmountToNumber = (rawAmount, locale) => {
|
|
|
949
953
|
}
|
|
950
954
|
fractionsSeparator = fractionsSeparator === '.' ? '\\.' : fractionsSeparator; // here we escape the '.' to use it as regex
|
|
951
955
|
// The raw amount with only one sparator
|
|
952
|
-
const normalizedAmount = String(rawAmount).replace(new RegExp(
|
|
956
|
+
const normalizedAmount = String(rawAmount).replace(new RegExp("[^-0-9".concat(fractionsSeparator, "]"), 'g'), '') // we just keep the numbers and the fraction symbol
|
|
953
957
|
.replace(fractionsSeparator, '.'); // then we change whatever `fractionsSeparator` was to `.` so we can parse it as float
|
|
954
958
|
|
|
955
959
|
return _parseFloat__default["default"](normalizedAmount);
|
|
@@ -974,7 +978,7 @@ const createMoneyValue = (rawAmount, locale, currencyCode) => {
|
|
|
974
978
|
if (!currency) return null;
|
|
975
979
|
// The user may enter a value with a comma, dot, or apostrophe as the decimal separator.
|
|
976
980
|
if (rawAmount.length === 0 || !utils.isNumberish(rawAmount)) return null;
|
|
977
|
-
process.env.NODE_ENV !== "production" ? utils.warning(locale || currency.fractionDigits !== 0,
|
|
981
|
+
process.env.NODE_ENV !== "production" ? utils.warning(locale || currency.fractionDigits !== 0, "MoneyInput: A locale must be provided when currency has no fraction digits (".concat(currencyCode, ")")) : void 0;
|
|
978
982
|
const amountAsNumber = parseRawAmountToNumber(rawAmount, locale);
|
|
979
983
|
if (isNaN(amountAsNumber)) return null;
|
|
980
984
|
|
|
@@ -1041,8 +1045,8 @@ const formatAmount = (rawAmount, locale, currencyCode) => {
|
|
|
1041
1045
|
minimumFractionDigits: fractionDigits
|
|
1042
1046
|
});
|
|
1043
1047
|
};
|
|
1044
|
-
const getAmountInputName = name => name ?
|
|
1045
|
-
const getCurrencyDropdownName = name => name ?
|
|
1048
|
+
const getAmountInputName = name => name ? "".concat(name, ".amount") : undefined;
|
|
1049
|
+
const getCurrencyDropdownName = name => name ? "".concat(name, ".currencyCode") : undefined;
|
|
1046
1050
|
var _ref = process.env.NODE_ENV === "production" ? {
|
|
1047
1051
|
name: "pw7jst",
|
|
1048
1052
|
styles: "position:relative;width:100%"
|
|
@@ -1060,6 +1064,7 @@ var _ref2 = process.env.NODE_ENV === "production" ? {
|
|
|
1060
1064
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
1061
1065
|
};
|
|
1062
1066
|
const MoneyInput = _ref5 => {
|
|
1067
|
+
var _context8, _context9;
|
|
1063
1068
|
let _ref5$currencies = _ref5.currencies,
|
|
1064
1069
|
currencies = _ref5$currencies === void 0 ? [] : _ref5$currencies,
|
|
1065
1070
|
_ref5$horizontalConst = _ref5.horizontalConstraint,
|
|
@@ -1119,18 +1124,20 @@ const MoneyInput = _ref5 => {
|
|
|
1119
1124
|
value: formattedAmount
|
|
1120
1125
|
}
|
|
1121
1126
|
};
|
|
1122
|
-
onChange
|
|
1127
|
+
onChange === null || onChange === void 0 || onChange(fakeEvent);
|
|
1123
1128
|
}
|
|
1124
1129
|
}
|
|
1125
1130
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode, toggleAmountHasFocus]);
|
|
1126
1131
|
const handleAmountChange = react$1.useCallback(event => {
|
|
1127
|
-
|
|
1128
|
-
|
|
1132
|
+
var _event$target;
|
|
1133
|
+
if (utils.isNumberish((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value)) {
|
|
1134
|
+
var _event$target2;
|
|
1135
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1129
1136
|
persist: () => {},
|
|
1130
1137
|
target: {
|
|
1131
1138
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1132
1139
|
name: getAmountInputName(props.name),
|
|
1133
|
-
value: event.target
|
|
1140
|
+
value: (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.value
|
|
1134
1141
|
}
|
|
1135
1142
|
});
|
|
1136
1143
|
}
|
|
@@ -1138,7 +1145,7 @@ const MoneyInput = _ref5 => {
|
|
|
1138
1145
|
const handleCurrencyChange = react$1.useCallback(option => {
|
|
1139
1146
|
const currencyCode = option.value;
|
|
1140
1147
|
if (props.value.currencyCode !== currencyCode) {
|
|
1141
|
-
var _context6;
|
|
1148
|
+
var _context6, _amountInputRef$curre;
|
|
1142
1149
|
// When the user changes from a currency with 3 fraction digits to
|
|
1143
1150
|
// a currency with 2 fraction digits, and when the input value was
|
|
1144
1151
|
// "9.000" (9), then it should change to "9.00" to reflect the new
|
|
@@ -1160,11 +1167,11 @@ const MoneyInput = _ref5 => {
|
|
|
1160
1167
|
value: currencyCode || ''
|
|
1161
1168
|
}
|
|
1162
1169
|
};
|
|
1163
|
-
onChange
|
|
1170
|
+
onChange === null || onChange === void 0 || onChange(fakeCurrencyEvent);
|
|
1164
1171
|
|
|
1165
1172
|
// change amount if necessary
|
|
1166
1173
|
if (props.value.amount !== nextAmount) {
|
|
1167
|
-
onChange
|
|
1174
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1168
1175
|
persist: () => {},
|
|
1169
1176
|
target: {
|
|
1170
1177
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
@@ -1173,7 +1180,7 @@ const MoneyInput = _ref5 => {
|
|
|
1173
1180
|
}
|
|
1174
1181
|
});
|
|
1175
1182
|
}
|
|
1176
|
-
amountInputRef.current
|
|
1183
|
+
(_amountInputRef$curre = amountInputRef.current) === null || _amountInputRef$curre === void 0 || _amountInputRef$curre.focus();
|
|
1177
1184
|
}
|
|
1178
1185
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode]);
|
|
1179
1186
|
const handleCurrencyFocus = react$1.useCallback(() => {
|
|
@@ -1217,9 +1224,10 @@ const MoneyInput = _ref5 => {
|
|
|
1217
1224
|
const isHighPrecision = !MoneyInput.isEmpty(props.value) && MoneyInput.isHighPrecision(props.value, intl.locale);
|
|
1218
1225
|
const onBlur = props.onBlur;
|
|
1219
1226
|
const handleContainerBlur = react$1.useCallback(event => {
|
|
1227
|
+
var _containerRef$current;
|
|
1220
1228
|
// ensures that both fields are marked as touched when one of them
|
|
1221
1229
|
// is blurred
|
|
1222
|
-
if (typeof onBlur === 'function' && !containerRef.current
|
|
1230
|
+
if (typeof onBlur === 'function' && !((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.relatedTarget))) {
|
|
1223
1231
|
onBlur({
|
|
1224
1232
|
target: {
|
|
1225
1233
|
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
@@ -1319,7 +1327,7 @@ const MoneyInput = _ref5 => {
|
|
|
1319
1327
|
,
|
|
1320
1328
|
styles: {
|
|
1321
1329
|
body: {
|
|
1322
|
-
margin:
|
|
1330
|
+
margin: _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "".concat(designSystem.designTokens.spacing20, " -")).call(_context9, designSystem.designTokens.spacing10, " ")).call(_context8, designSystem.designTokens.spacing20, " 0")
|
|
1323
1331
|
}
|
|
1324
1332
|
},
|
|
1325
1333
|
title: intl.formatMessage(messages.highPrecision),
|
|
@@ -1341,8 +1349,8 @@ MoneyInput.displayName = 'MoneyInput';
|
|
|
1341
1349
|
MoneyInput.getAmountInputId = getAmountInputName;
|
|
1342
1350
|
MoneyInput.getCurrencyDropdownId = getCurrencyDropdownName;
|
|
1343
1351
|
MoneyInput.convertToMoneyValue = (value, locale) => {
|
|
1344
|
-
var
|
|
1345
|
-
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty__default["default"](
|
|
1352
|
+
var _context0;
|
|
1353
|
+
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty__default["default"](_context0 = value.amount).call(_context0) : '', locale, value.currencyCode);
|
|
1346
1354
|
};
|
|
1347
1355
|
MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
1348
1356
|
if (!moneyValue) return {
|
|
@@ -1365,19 +1373,19 @@ MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
|
1365
1373
|
};
|
|
1366
1374
|
};
|
|
1367
1375
|
MoneyInput.isEmpty = formValue => {
|
|
1368
|
-
var
|
|
1369
|
-
return !formValue || _trimInstanceProperty__default["default"](
|
|
1376
|
+
var _context1, _context10;
|
|
1377
|
+
return !formValue || _trimInstanceProperty__default["default"](_context1 = formValue.amount).call(_context1) === '' || _trimInstanceProperty__default["default"](_context10 = formValue.currencyCode).call(_context10) === '';
|
|
1370
1378
|
};
|
|
1371
1379
|
MoneyInput.isHighPrecision = (formValue, locale) => {
|
|
1372
1380
|
process.env.NODE_ENV !== "production" ? utils.warning(!MoneyInput.isEmpty(formValue), 'MoneyValue.isHighPrecision may not be called with an empty money value.') : void 0;
|
|
1373
1381
|
const moneyValue = MoneyInput.convertToMoneyValue(formValue, locale);
|
|
1374
|
-
return moneyValue
|
|
1382
|
+
return (moneyValue === null || moneyValue === void 0 ? void 0 : moneyValue.type) === 'highPrecision';
|
|
1375
1383
|
};
|
|
1376
1384
|
MoneyInput.isTouched = touched => Boolean(touched && touched.currencyCode && touched.amount);
|
|
1377
1385
|
var MoneyInput$1 = MoneyInput;
|
|
1378
1386
|
|
|
1379
1387
|
// NOTE: This string will be replaced on build time with the package version.
|
|
1380
|
-
var version = "20.
|
|
1388
|
+
var version = "20.3.1";
|
|
1381
1389
|
|
|
1382
1390
|
exports["default"] = MoneyInput$1;
|
|
1383
1391
|
exports.version = version;
|
|
@@ -22,6 +22,7 @@ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
|
22
22
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
23
23
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
24
24
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
25
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
25
26
|
var react$1 = require('react');
|
|
26
27
|
var ReactDOM = require('react-dom');
|
|
27
28
|
require('lodash/has');
|
|
@@ -57,6 +58,7 @@ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
|
57
58
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
58
59
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
59
60
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
61
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
60
62
|
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
61
63
|
var Select__default = /*#__PURE__*/_interopDefault(Select);
|
|
62
64
|
var Tooltip__default = /*#__PURE__*/_interopDefault(Tooltip);
|
|
@@ -747,16 +749,18 @@ const getHighPrecisionWrapperStyles = _ref => {
|
|
|
747
749
|
|
|
748
750
|
var messages = reactIntl.defineMessages({
|
|
749
751
|
highPrecision: {
|
|
750
|
-
id:
|
|
751
|
-
|
|
752
|
-
|
|
752
|
+
id: "UIKit.MoneyInput.highPrecision",
|
|
753
|
+
defaultMessage: [{
|
|
754
|
+
"type": 0,
|
|
755
|
+
"value": "High Precision Price"
|
|
756
|
+
}]
|
|
753
757
|
}
|
|
754
758
|
});
|
|
755
759
|
|
|
756
760
|
const _excluded = ["id"],
|
|
757
761
|
_excluded2 = ["currencies", "horizontalConstraint", "menuPortalZIndex"];
|
|
758
762
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
759
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
763
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
760
764
|
const TooltipWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
761
765
|
target: "e1u90zjc0"
|
|
762
766
|
} )({
|
|
@@ -764,8 +768,8 @@ const TooltipWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
|
764
768
|
styles: "display:flex"
|
|
765
769
|
} );
|
|
766
770
|
const moneyInputSequentialId = utils.createSequentialId('money-input-');
|
|
767
|
-
const getPortalId = id =>
|
|
768
|
-
const getPortalNode = id => document.querySelector(
|
|
771
|
+
const getPortalId = id => "portal-".concat(id);
|
|
772
|
+
const getPortalNode = id => document.querySelector("#".concat(getPortalId(id)));
|
|
769
773
|
const Portal = props => {
|
|
770
774
|
const domNode = getPortalNode(props.id);
|
|
771
775
|
if (domNode) {
|
|
@@ -809,15 +813,15 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
809
813
|
});
|
|
810
814
|
return _objectSpread(_objectSpread({}, selectStyles), {}, {
|
|
811
815
|
control: (base, state) => _objectSpread(_objectSpread({}, selectStyles.control(base, state)), {}, {
|
|
812
|
-
padding:
|
|
816
|
+
padding: "0 ".concat(designSystem.designTokens.spacing25),
|
|
813
817
|
borderTopRightRadius: '0',
|
|
814
818
|
borderBottomRightRadius: '0',
|
|
815
819
|
borderRight: '0',
|
|
816
820
|
minWidth: '80px',
|
|
817
821
|
height: '100%',
|
|
818
822
|
borderColor: (() => {
|
|
819
|
-
if (isDisabled) return
|
|
820
|
-
if (isReadOnly) return
|
|
823
|
+
if (isDisabled) return "".concat(designSystem.designTokens.borderColorForInputWhenDisabled, " !important");
|
|
824
|
+
if (isReadOnly) return "".concat(designSystem.designTokens.borderColorForInputWhenReadonly, " !important");
|
|
821
825
|
if (hasError) return designSystem.designTokens.borderColorForInputWhenError;
|
|
822
826
|
if (hasWarning) return designSystem.designTokens.borderColorForInputWhenWarning;
|
|
823
827
|
if (currencyHasFocus) {
|
|
@@ -827,7 +831,7 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
827
831
|
})(),
|
|
828
832
|
cursor: (() => {
|
|
829
833
|
if (isDisabled) return 'not-allowed';
|
|
830
|
-
if (isReadOnly) return
|
|
834
|
+
if (isReadOnly) return "default";
|
|
831
835
|
return 'pointer';
|
|
832
836
|
})(),
|
|
833
837
|
backgroundColor: (() => {
|
|
@@ -940,7 +944,7 @@ const parseRawAmountToNumber = (rawAmount, locale) => {
|
|
|
940
944
|
}
|
|
941
945
|
fractionsSeparator = fractionsSeparator === '.' ? '\\.' : fractionsSeparator; // here we escape the '.' to use it as regex
|
|
942
946
|
// The raw amount with only one sparator
|
|
943
|
-
const normalizedAmount = String(rawAmount).replace(new RegExp(
|
|
947
|
+
const normalizedAmount = String(rawAmount).replace(new RegExp("[^-0-9".concat(fractionsSeparator, "]"), 'g'), '') // we just keep the numbers and the fraction symbol
|
|
944
948
|
.replace(fractionsSeparator, '.'); // then we change whatever `fractionsSeparator` was to `.` so we can parse it as float
|
|
945
949
|
|
|
946
950
|
return _parseFloat__default["default"](normalizedAmount);
|
|
@@ -1031,8 +1035,8 @@ const formatAmount = (rawAmount, locale, currencyCode) => {
|
|
|
1031
1035
|
minimumFractionDigits: fractionDigits
|
|
1032
1036
|
});
|
|
1033
1037
|
};
|
|
1034
|
-
const getAmountInputName = name => name ?
|
|
1035
|
-
const getCurrencyDropdownName = name => name ?
|
|
1038
|
+
const getAmountInputName = name => name ? "".concat(name, ".amount") : undefined;
|
|
1039
|
+
const getCurrencyDropdownName = name => name ? "".concat(name, ".currencyCode") : undefined;
|
|
1036
1040
|
var _ref = {
|
|
1037
1041
|
name: "pw7jst",
|
|
1038
1042
|
styles: "position:relative;width:100%"
|
|
@@ -1042,6 +1046,7 @@ var _ref2 = {
|
|
|
1042
1046
|
styles: "font-family:inherit;width:100%;position:relative;display:flex"
|
|
1043
1047
|
} ;
|
|
1044
1048
|
const MoneyInput = _ref5 => {
|
|
1049
|
+
var _context8, _context9;
|
|
1045
1050
|
let _ref5$currencies = _ref5.currencies,
|
|
1046
1051
|
currencies = _ref5$currencies === void 0 ? [] : _ref5$currencies,
|
|
1047
1052
|
_ref5$horizontalConst = _ref5.horizontalConstraint,
|
|
@@ -1099,18 +1104,20 @@ const MoneyInput = _ref5 => {
|
|
|
1099
1104
|
value: formattedAmount
|
|
1100
1105
|
}
|
|
1101
1106
|
};
|
|
1102
|
-
onChange
|
|
1107
|
+
onChange === null || onChange === void 0 || onChange(fakeEvent);
|
|
1103
1108
|
}
|
|
1104
1109
|
}
|
|
1105
1110
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode, toggleAmountHasFocus]);
|
|
1106
1111
|
const handleAmountChange = react$1.useCallback(event => {
|
|
1107
|
-
|
|
1108
|
-
|
|
1112
|
+
var _event$target;
|
|
1113
|
+
if (utils.isNumberish((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value)) {
|
|
1114
|
+
var _event$target2;
|
|
1115
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1109
1116
|
persist: () => {},
|
|
1110
1117
|
target: {
|
|
1111
1118
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1112
1119
|
name: getAmountInputName(props.name),
|
|
1113
|
-
value: event.target
|
|
1120
|
+
value: (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.value
|
|
1114
1121
|
}
|
|
1115
1122
|
});
|
|
1116
1123
|
}
|
|
@@ -1118,7 +1125,7 @@ const MoneyInput = _ref5 => {
|
|
|
1118
1125
|
const handleCurrencyChange = react$1.useCallback(option => {
|
|
1119
1126
|
const currencyCode = option.value;
|
|
1120
1127
|
if (props.value.currencyCode !== currencyCode) {
|
|
1121
|
-
var _context6;
|
|
1128
|
+
var _context6, _amountInputRef$curre;
|
|
1122
1129
|
// When the user changes from a currency with 3 fraction digits to
|
|
1123
1130
|
// a currency with 2 fraction digits, and when the input value was
|
|
1124
1131
|
// "9.000" (9), then it should change to "9.00" to reflect the new
|
|
@@ -1140,11 +1147,11 @@ const MoneyInput = _ref5 => {
|
|
|
1140
1147
|
value: currencyCode || ''
|
|
1141
1148
|
}
|
|
1142
1149
|
};
|
|
1143
|
-
onChange
|
|
1150
|
+
onChange === null || onChange === void 0 || onChange(fakeCurrencyEvent);
|
|
1144
1151
|
|
|
1145
1152
|
// change amount if necessary
|
|
1146
1153
|
if (props.value.amount !== nextAmount) {
|
|
1147
|
-
onChange
|
|
1154
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1148
1155
|
persist: () => {},
|
|
1149
1156
|
target: {
|
|
1150
1157
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
@@ -1153,7 +1160,7 @@ const MoneyInput = _ref5 => {
|
|
|
1153
1160
|
}
|
|
1154
1161
|
});
|
|
1155
1162
|
}
|
|
1156
|
-
amountInputRef.current
|
|
1163
|
+
(_amountInputRef$curre = amountInputRef.current) === null || _amountInputRef$curre === void 0 || _amountInputRef$curre.focus();
|
|
1157
1164
|
}
|
|
1158
1165
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode]);
|
|
1159
1166
|
const handleCurrencyFocus = react$1.useCallback(() => {
|
|
@@ -1197,9 +1204,10 @@ const MoneyInput = _ref5 => {
|
|
|
1197
1204
|
const isHighPrecision = !MoneyInput.isEmpty(props.value) && MoneyInput.isHighPrecision(props.value, intl.locale);
|
|
1198
1205
|
const onBlur = props.onBlur;
|
|
1199
1206
|
const handleContainerBlur = react$1.useCallback(event => {
|
|
1207
|
+
var _containerRef$current;
|
|
1200
1208
|
// ensures that both fields are marked as touched when one of them
|
|
1201
1209
|
// is blurred
|
|
1202
|
-
if (typeof onBlur === 'function' && !containerRef.current
|
|
1210
|
+
if (typeof onBlur === 'function' && !((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.relatedTarget))) {
|
|
1203
1211
|
onBlur({
|
|
1204
1212
|
target: {
|
|
1205
1213
|
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
@@ -1299,7 +1307,7 @@ const MoneyInput = _ref5 => {
|
|
|
1299
1307
|
,
|
|
1300
1308
|
styles: {
|
|
1301
1309
|
body: {
|
|
1302
|
-
margin:
|
|
1310
|
+
margin: _concatInstanceProperty__default["default"](_context8 = _concatInstanceProperty__default["default"](_context9 = "".concat(designSystem.designTokens.spacing20, " -")).call(_context9, designSystem.designTokens.spacing10, " ")).call(_context8, designSystem.designTokens.spacing20, " 0")
|
|
1303
1311
|
}
|
|
1304
1312
|
},
|
|
1305
1313
|
title: intl.formatMessage(messages.highPrecision),
|
|
@@ -1321,8 +1329,8 @@ MoneyInput.displayName = 'MoneyInput';
|
|
|
1321
1329
|
MoneyInput.getAmountInputId = getAmountInputName;
|
|
1322
1330
|
MoneyInput.getCurrencyDropdownId = getCurrencyDropdownName;
|
|
1323
1331
|
MoneyInput.convertToMoneyValue = (value, locale) => {
|
|
1324
|
-
var
|
|
1325
|
-
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty__default["default"](
|
|
1332
|
+
var _context0;
|
|
1333
|
+
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty__default["default"](_context0 = value.amount).call(_context0) : '', locale, value.currencyCode);
|
|
1326
1334
|
};
|
|
1327
1335
|
MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
1328
1336
|
if (!moneyValue) return {
|
|
@@ -1338,18 +1346,18 @@ MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
|
1338
1346
|
};
|
|
1339
1347
|
};
|
|
1340
1348
|
MoneyInput.isEmpty = formValue => {
|
|
1341
|
-
var
|
|
1342
|
-
return !formValue || _trimInstanceProperty__default["default"](
|
|
1349
|
+
var _context1, _context10;
|
|
1350
|
+
return !formValue || _trimInstanceProperty__default["default"](_context1 = formValue.amount).call(_context1) === '' || _trimInstanceProperty__default["default"](_context10 = formValue.currencyCode).call(_context10) === '';
|
|
1343
1351
|
};
|
|
1344
1352
|
MoneyInput.isHighPrecision = (formValue, locale) => {
|
|
1345
1353
|
const moneyValue = MoneyInput.convertToMoneyValue(formValue, locale);
|
|
1346
|
-
return moneyValue
|
|
1354
|
+
return (moneyValue === null || moneyValue === void 0 ? void 0 : moneyValue.type) === 'highPrecision';
|
|
1347
1355
|
};
|
|
1348
1356
|
MoneyInput.isTouched = touched => Boolean(touched && touched.currencyCode && touched.amount);
|
|
1349
1357
|
var MoneyInput$1 = MoneyInput;
|
|
1350
1358
|
|
|
1351
1359
|
// NOTE: This string will be replaced on build time with the package version.
|
|
1352
|
-
var version = "20.
|
|
1360
|
+
var version = "20.3.1";
|
|
1353
1361
|
|
|
1354
1362
|
exports["default"] = MoneyInput$1;
|
|
1355
1363
|
exports.version = version;
|
|
@@ -18,6 +18,7 @@ import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
|
|
|
18
18
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
19
19
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
20
20
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
21
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
21
22
|
import { useRef, useCallback } from 'react';
|
|
22
23
|
import ReactDOM from 'react-dom';
|
|
23
24
|
import has from 'lodash/has';
|
|
@@ -719,16 +720,18 @@ const getHighPrecisionWrapperStyles = _ref => {
|
|
|
719
720
|
|
|
720
721
|
var messages = defineMessages({
|
|
721
722
|
highPrecision: {
|
|
722
|
-
id:
|
|
723
|
-
|
|
724
|
-
|
|
723
|
+
id: "UIKit.MoneyInput.highPrecision",
|
|
724
|
+
defaultMessage: [{
|
|
725
|
+
"type": 0,
|
|
726
|
+
"value": "High Precision Price"
|
|
727
|
+
}]
|
|
725
728
|
}
|
|
726
729
|
});
|
|
727
730
|
|
|
728
731
|
const _excluded = ["id"],
|
|
729
732
|
_excluded2 = ["currencies", "horizontalConstraint", "menuPortalZIndex"];
|
|
730
733
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
731
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
734
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context11, _context12; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(t), !0)).call(_context11, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context12 = ownKeys(Object(t))).call(_context12, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
732
735
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
733
736
|
const TooltipWrapper = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
|
|
734
737
|
target: "e1u90zjc0"
|
|
@@ -744,8 +747,8 @@ const TooltipWrapper = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "pro
|
|
|
744
747
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
745
748
|
});
|
|
746
749
|
const moneyInputSequentialId = createSequentialId('money-input-');
|
|
747
|
-
const getPortalId = id =>
|
|
748
|
-
const getPortalNode = id => document.querySelector(
|
|
750
|
+
const getPortalId = id => "portal-".concat(id);
|
|
751
|
+
const getPortalNode = id => document.querySelector("#".concat(getPortalId(id)));
|
|
749
752
|
const Portal = props => {
|
|
750
753
|
const domNode = getPortalNode(props.id);
|
|
751
754
|
if (domNode) {
|
|
@@ -789,15 +792,15 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
789
792
|
});
|
|
790
793
|
return _objectSpread(_objectSpread({}, selectStyles), {}, {
|
|
791
794
|
control: (base, state) => _objectSpread(_objectSpread({}, selectStyles.control(base, state)), {}, {
|
|
792
|
-
padding:
|
|
795
|
+
padding: "0 ".concat(designTokens.spacing25),
|
|
793
796
|
borderTopRightRadius: '0',
|
|
794
797
|
borderBottomRightRadius: '0',
|
|
795
798
|
borderRight: '0',
|
|
796
799
|
minWidth: '80px',
|
|
797
800
|
height: '100%',
|
|
798
801
|
borderColor: (() => {
|
|
799
|
-
if (isDisabled) return
|
|
800
|
-
if (isReadOnly) return
|
|
802
|
+
if (isDisabled) return "".concat(designTokens.borderColorForInputWhenDisabled, " !important");
|
|
803
|
+
if (isReadOnly) return "".concat(designTokens.borderColorForInputWhenReadonly, " !important");
|
|
801
804
|
if (hasError) return designTokens.borderColorForInputWhenError;
|
|
802
805
|
if (hasWarning) return designTokens.borderColorForInputWhenWarning;
|
|
803
806
|
if (currencyHasFocus) {
|
|
@@ -807,7 +810,7 @@ const createCurrencySelectStyles = _ref4 => {
|
|
|
807
810
|
})(),
|
|
808
811
|
cursor: (() => {
|
|
809
812
|
if (isDisabled) return 'not-allowed';
|
|
810
|
-
if (isReadOnly) return
|
|
813
|
+
if (isReadOnly) return "default";
|
|
811
814
|
return 'pointer';
|
|
812
815
|
})(),
|
|
813
816
|
backgroundColor: (() => {
|
|
@@ -920,7 +923,7 @@ const parseRawAmountToNumber = (rawAmount, locale) => {
|
|
|
920
923
|
}
|
|
921
924
|
fractionsSeparator = fractionsSeparator === '.' ? '\\.' : fractionsSeparator; // here we escape the '.' to use it as regex
|
|
922
925
|
// The raw amount with only one sparator
|
|
923
|
-
const normalizedAmount = String(rawAmount).replace(new RegExp(
|
|
926
|
+
const normalizedAmount = String(rawAmount).replace(new RegExp("[^-0-9".concat(fractionsSeparator, "]"), 'g'), '') // we just keep the numbers and the fraction symbol
|
|
924
927
|
.replace(fractionsSeparator, '.'); // then we change whatever `fractionsSeparator` was to `.` so we can parse it as float
|
|
925
928
|
|
|
926
929
|
return _parseFloat(normalizedAmount);
|
|
@@ -945,7 +948,7 @@ const createMoneyValue = (rawAmount, locale, currencyCode) => {
|
|
|
945
948
|
if (!currency) return null;
|
|
946
949
|
// The user may enter a value with a comma, dot, or apostrophe as the decimal separator.
|
|
947
950
|
if (rawAmount.length === 0 || !isNumberish(rawAmount)) return null;
|
|
948
|
-
process.env.NODE_ENV !== "production" ? warning(locale || currency.fractionDigits !== 0,
|
|
951
|
+
process.env.NODE_ENV !== "production" ? warning(locale || currency.fractionDigits !== 0, "MoneyInput: A locale must be provided when currency has no fraction digits (".concat(currencyCode, ")")) : void 0;
|
|
949
952
|
const amountAsNumber = parseRawAmountToNumber(rawAmount, locale);
|
|
950
953
|
if (isNaN(amountAsNumber)) return null;
|
|
951
954
|
|
|
@@ -1012,8 +1015,8 @@ const formatAmount = (rawAmount, locale, currencyCode) => {
|
|
|
1012
1015
|
minimumFractionDigits: fractionDigits
|
|
1013
1016
|
});
|
|
1014
1017
|
};
|
|
1015
|
-
const getAmountInputName = name => name ?
|
|
1016
|
-
const getCurrencyDropdownName = name => name ?
|
|
1018
|
+
const getAmountInputName = name => name ? "".concat(name, ".amount") : undefined;
|
|
1019
|
+
const getCurrencyDropdownName = name => name ? "".concat(name, ".currencyCode") : undefined;
|
|
1017
1020
|
var _ref = process.env.NODE_ENV === "production" ? {
|
|
1018
1021
|
name: "pw7jst",
|
|
1019
1022
|
styles: "position:relative;width:100%"
|
|
@@ -1031,6 +1034,7 @@ var _ref2 = process.env.NODE_ENV === "production" ? {
|
|
|
1031
1034
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
1032
1035
|
};
|
|
1033
1036
|
const MoneyInput = _ref5 => {
|
|
1037
|
+
var _context8, _context9;
|
|
1034
1038
|
let _ref5$currencies = _ref5.currencies,
|
|
1035
1039
|
currencies = _ref5$currencies === void 0 ? [] : _ref5$currencies,
|
|
1036
1040
|
_ref5$horizontalConst = _ref5.horizontalConstraint,
|
|
@@ -1090,18 +1094,20 @@ const MoneyInput = _ref5 => {
|
|
|
1090
1094
|
value: formattedAmount
|
|
1091
1095
|
}
|
|
1092
1096
|
};
|
|
1093
|
-
onChange
|
|
1097
|
+
onChange === null || onChange === void 0 || onChange(fakeEvent);
|
|
1094
1098
|
}
|
|
1095
1099
|
}
|
|
1096
1100
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode, toggleAmountHasFocus]);
|
|
1097
1101
|
const handleAmountChange = useCallback(event => {
|
|
1098
|
-
|
|
1099
|
-
|
|
1102
|
+
var _event$target;
|
|
1103
|
+
if (isNumberish((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value)) {
|
|
1104
|
+
var _event$target2;
|
|
1105
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1100
1106
|
persist: () => {},
|
|
1101
1107
|
target: {
|
|
1102
1108
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1103
1109
|
name: getAmountInputName(props.name),
|
|
1104
|
-
value: event.target
|
|
1110
|
+
value: (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.value
|
|
1105
1111
|
}
|
|
1106
1112
|
});
|
|
1107
1113
|
}
|
|
@@ -1109,7 +1115,7 @@ const MoneyInput = _ref5 => {
|
|
|
1109
1115
|
const handleCurrencyChange = useCallback(option => {
|
|
1110
1116
|
const currencyCode = option.value;
|
|
1111
1117
|
if (props.value.currencyCode !== currencyCode) {
|
|
1112
|
-
var _context6;
|
|
1118
|
+
var _context6, _amountInputRef$curre;
|
|
1113
1119
|
// When the user changes from a currency with 3 fraction digits to
|
|
1114
1120
|
// a currency with 2 fraction digits, and when the input value was
|
|
1115
1121
|
// "9.000" (9), then it should change to "9.00" to reflect the new
|
|
@@ -1131,11 +1137,11 @@ const MoneyInput = _ref5 => {
|
|
|
1131
1137
|
value: currencyCode || ''
|
|
1132
1138
|
}
|
|
1133
1139
|
};
|
|
1134
|
-
onChange
|
|
1140
|
+
onChange === null || onChange === void 0 || onChange(fakeCurrencyEvent);
|
|
1135
1141
|
|
|
1136
1142
|
// change amount if necessary
|
|
1137
1143
|
if (props.value.amount !== nextAmount) {
|
|
1138
|
-
onChange
|
|
1144
|
+
onChange === null || onChange === void 0 || onChange({
|
|
1139
1145
|
persist: () => {},
|
|
1140
1146
|
target: {
|
|
1141
1147
|
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
@@ -1144,7 +1150,7 @@ const MoneyInput = _ref5 => {
|
|
|
1144
1150
|
}
|
|
1145
1151
|
});
|
|
1146
1152
|
}
|
|
1147
|
-
amountInputRef.current
|
|
1153
|
+
(_amountInputRef$curre = amountInputRef.current) === null || _amountInputRef$curre === void 0 || _amountInputRef$curre.focus();
|
|
1148
1154
|
}
|
|
1149
1155
|
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode]);
|
|
1150
1156
|
const handleCurrencyFocus = useCallback(() => {
|
|
@@ -1188,9 +1194,10 @@ const MoneyInput = _ref5 => {
|
|
|
1188
1194
|
const isHighPrecision = !MoneyInput.isEmpty(props.value) && MoneyInput.isHighPrecision(props.value, intl.locale);
|
|
1189
1195
|
const onBlur = props.onBlur;
|
|
1190
1196
|
const handleContainerBlur = useCallback(event => {
|
|
1197
|
+
var _containerRef$current;
|
|
1191
1198
|
// ensures that both fields are marked as touched when one of them
|
|
1192
1199
|
// is blurred
|
|
1193
|
-
if (typeof onBlur === 'function' && !containerRef.current
|
|
1200
|
+
if (typeof onBlur === 'function' && !((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.relatedTarget))) {
|
|
1194
1201
|
onBlur({
|
|
1195
1202
|
target: {
|
|
1196
1203
|
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
@@ -1290,7 +1297,7 @@ const MoneyInput = _ref5 => {
|
|
|
1290
1297
|
,
|
|
1291
1298
|
styles: {
|
|
1292
1299
|
body: {
|
|
1293
|
-
margin:
|
|
1300
|
+
margin: _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = "".concat(designTokens.spacing20, " -")).call(_context9, designTokens.spacing10, " ")).call(_context8, designTokens.spacing20, " 0")
|
|
1294
1301
|
}
|
|
1295
1302
|
},
|
|
1296
1303
|
title: intl.formatMessage(messages.highPrecision),
|
|
@@ -1312,8 +1319,8 @@ MoneyInput.displayName = 'MoneyInput';
|
|
|
1312
1319
|
MoneyInput.getAmountInputId = getAmountInputName;
|
|
1313
1320
|
MoneyInput.getCurrencyDropdownId = getCurrencyDropdownName;
|
|
1314
1321
|
MoneyInput.convertToMoneyValue = (value, locale) => {
|
|
1315
|
-
var
|
|
1316
|
-
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty(
|
|
1322
|
+
var _context0;
|
|
1323
|
+
return createMoneyValue(typeof value.amount === 'string' ? _trimInstanceProperty(_context0 = value.amount).call(_context0) : '', locale, value.currencyCode);
|
|
1317
1324
|
};
|
|
1318
1325
|
MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
1319
1326
|
if (!moneyValue) return {
|
|
@@ -1336,18 +1343,18 @@ MoneyInput.parseMoneyValue = (moneyValue, locale) => {
|
|
|
1336
1343
|
};
|
|
1337
1344
|
};
|
|
1338
1345
|
MoneyInput.isEmpty = formValue => {
|
|
1339
|
-
var
|
|
1340
|
-
return !formValue || _trimInstanceProperty(
|
|
1346
|
+
var _context1, _context10;
|
|
1347
|
+
return !formValue || _trimInstanceProperty(_context1 = formValue.amount).call(_context1) === '' || _trimInstanceProperty(_context10 = formValue.currencyCode).call(_context10) === '';
|
|
1341
1348
|
};
|
|
1342
1349
|
MoneyInput.isHighPrecision = (formValue, locale) => {
|
|
1343
1350
|
process.env.NODE_ENV !== "production" ? warning(!MoneyInput.isEmpty(formValue), 'MoneyValue.isHighPrecision may not be called with an empty money value.') : void 0;
|
|
1344
1351
|
const moneyValue = MoneyInput.convertToMoneyValue(formValue, locale);
|
|
1345
|
-
return moneyValue
|
|
1352
|
+
return (moneyValue === null || moneyValue === void 0 ? void 0 : moneyValue.type) === 'highPrecision';
|
|
1346
1353
|
};
|
|
1347
1354
|
MoneyInput.isTouched = touched => Boolean(touched && touched.currencyCode && touched.amount);
|
|
1348
1355
|
var MoneyInput$1 = MoneyInput;
|
|
1349
1356
|
|
|
1350
1357
|
// NOTE: This string will be replaced on build time with the package version.
|
|
1351
|
-
var version = "20.
|
|
1358
|
+
var version = "20.3.1";
|
|
1352
1359
|
|
|
1353
1360
|
export { MoneyInput$1 as default, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/money-input",
|
|
3
3
|
"description": "A controlled input component for money values with validation states.",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.3.1",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "20.
|
|
25
|
-
"@commercetools-uikit/design-system": "20.
|
|
26
|
-
"@commercetools-uikit/hooks": "20.
|
|
27
|
-
"@commercetools-uikit/icons": "20.
|
|
28
|
-
"@commercetools-uikit/input-utils": "20.
|
|
29
|
-
"@commercetools-uikit/select-utils": "20.
|
|
30
|
-
"@commercetools-uikit/tooltip": "20.
|
|
31
|
-
"@commercetools-uikit/utils": "20.
|
|
24
|
+
"@commercetools-uikit/constraints": "20.3.1",
|
|
25
|
+
"@commercetools-uikit/design-system": "20.3.1",
|
|
26
|
+
"@commercetools-uikit/hooks": "20.3.1",
|
|
27
|
+
"@commercetools-uikit/icons": "20.3.1",
|
|
28
|
+
"@commercetools-uikit/input-utils": "20.3.1",
|
|
29
|
+
"@commercetools-uikit/select-utils": "20.3.1",
|
|
30
|
+
"@commercetools-uikit/tooltip": "20.3.1",
|
|
31
|
+
"@commercetools-uikit/utils": "20.3.1",
|
|
32
32
|
"@emotion/react": "^11.10.5",
|
|
33
33
|
"@emotion/styled": "^11.10.5",
|
|
34
|
-
"lodash": "4.17.
|
|
34
|
+
"lodash": "4.17.23",
|
|
35
35
|
"react-select": "5.10.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"react": "19.
|
|
39
|
-
"react-dom": "19.
|
|
38
|
+
"react": "19.2.0",
|
|
39
|
+
"react-dom": "19.2.0",
|
|
40
40
|
"react-intl": "^7.1.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|