@commercetools-uikit/money-input 13.0.1 → 13.0.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.
|
@@ -763,6 +763,8 @@ var TooltipWrapper = _styled__default["default"]("div", {
|
|
|
763
763
|
styles: "display:flex"
|
|
764
764
|
} );
|
|
765
765
|
|
|
766
|
+
var moneyInputSequentialId = utils.createSequentialId('money-input-');
|
|
767
|
+
|
|
766
768
|
var getPortalId = function getPortalId(id) {
|
|
767
769
|
return "portal-".concat(id);
|
|
768
770
|
};
|
|
@@ -1087,6 +1089,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1087
1089
|
|
|
1088
1090
|
var containerRef = react$1.useRef(null);
|
|
1089
1091
|
var amountInputRef = react$1.useRef(null);
|
|
1092
|
+
var moneyInputId = hooks.useFieldId(props.id, moneyInputSequentialId);
|
|
1090
1093
|
|
|
1091
1094
|
if (!props.isReadOnly) ;
|
|
1092
1095
|
|
|
@@ -1094,12 +1097,12 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1094
1097
|
var handleAmountFocus = react$1.useCallback(function () {
|
|
1095
1098
|
if (onFocus) onFocus({
|
|
1096
1099
|
target: {
|
|
1097
|
-
id: MoneyInput.getAmountInputId(
|
|
1100
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1098
1101
|
name: getAmountInputName(props.name)
|
|
1099
1102
|
}
|
|
1100
1103
|
});
|
|
1101
1104
|
toggleAmountHasFocus(true);
|
|
1102
|
-
}, [toggleAmountHasFocus, onFocus,
|
|
1105
|
+
}, [toggleAmountHasFocus, onFocus, moneyInputId, props.name]);
|
|
1103
1106
|
var onChange = props.onChange;
|
|
1104
1107
|
var handleAmountBlur = react$1.useCallback(function () {
|
|
1105
1108
|
var _context5;
|
|
@@ -1118,7 +1121,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1118
1121
|
var fakeEvent = {
|
|
1119
1122
|
persist: function persist() {},
|
|
1120
1123
|
target: {
|
|
1121
|
-
id: MoneyInput.getAmountInputId(
|
|
1124
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1122
1125
|
name: getAmountInputName(props.name),
|
|
1123
1126
|
value: formattedAmount
|
|
1124
1127
|
}
|
|
@@ -1126,19 +1129,19 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1126
1129
|
onChange(fakeEvent);
|
|
1127
1130
|
}
|
|
1128
1131
|
}
|
|
1129
|
-
}, [intl.locale, onChange,
|
|
1132
|
+
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode, toggleAmountHasFocus]);
|
|
1130
1133
|
var handleAmountChange = react$1.useCallback(function (event) {
|
|
1131
1134
|
if (utils.isNumberish(event.target.value)) {
|
|
1132
1135
|
onChange({
|
|
1133
1136
|
persist: function persist() {},
|
|
1134
1137
|
target: {
|
|
1135
|
-
id: MoneyInput.getAmountInputId(
|
|
1138
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1136
1139
|
name: getAmountInputName(props.name),
|
|
1137
1140
|
value: event.target.value
|
|
1138
1141
|
}
|
|
1139
1142
|
});
|
|
1140
1143
|
}
|
|
1141
|
-
}, [onChange,
|
|
1144
|
+
}, [onChange, moneyInputId, props.name]);
|
|
1142
1145
|
var handleCurrencyChange = react$1.useCallback(function (option) {
|
|
1143
1146
|
var currencyCode = option.value;
|
|
1144
1147
|
|
|
@@ -1160,7 +1163,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1160
1163
|
var fakeCurrencyEvent = {
|
|
1161
1164
|
persist: function persist() {},
|
|
1162
1165
|
target: {
|
|
1163
|
-
id: MoneyInput.getCurrencyDropdownId(
|
|
1166
|
+
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
1164
1167
|
name: getCurrencyDropdownName(props.name),
|
|
1165
1168
|
value: currencyCode || ''
|
|
1166
1169
|
}
|
|
@@ -1171,7 +1174,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1171
1174
|
onChange({
|
|
1172
1175
|
persist: function persist() {},
|
|
1173
1176
|
target: {
|
|
1174
|
-
id: MoneyInput.getAmountInputId(
|
|
1177
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1175
1178
|
name: getAmountInputName(props.name),
|
|
1176
1179
|
value: nextAmount
|
|
1177
1180
|
}
|
|
@@ -1180,16 +1183,16 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1180
1183
|
|
|
1181
1184
|
(_amountInputRef$curre = amountInputRef.current) === null || _amountInputRef$curre === void 0 ? void 0 : _amountInputRef$curre.focus();
|
|
1182
1185
|
}
|
|
1183
|
-
}, [intl.locale, onChange,
|
|
1186
|
+
}, [intl.locale, onChange, moneyInputId, props.name, props.value.amount, props.value.currencyCode]);
|
|
1184
1187
|
var handleCurrencyFocus = react$1.useCallback(function () {
|
|
1185
1188
|
if (onFocus) onFocus({
|
|
1186
1189
|
target: {
|
|
1187
|
-
id: MoneyInput.getCurrencyDropdownId(
|
|
1190
|
+
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
1188
1191
|
name: getCurrencyDropdownName(props.name)
|
|
1189
1192
|
}
|
|
1190
1193
|
});
|
|
1191
1194
|
toggleCurrencyHasFocus(true);
|
|
1192
|
-
}, [onFocus, toggleCurrencyHasFocus, props.name,
|
|
1195
|
+
}, [onFocus, toggleCurrencyHasFocus, props.name, moneyInputId]);
|
|
1193
1196
|
var handleCurrencyBlur = react$1.useCallback(function () {
|
|
1194
1197
|
toggleCurrencyHasFocus(false);
|
|
1195
1198
|
}, [toggleCurrencyHasFocus]);
|
|
@@ -1229,7 +1232,6 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1229
1232
|
return null;
|
|
1230
1233
|
}();
|
|
1231
1234
|
|
|
1232
|
-
var id = MoneyInput.getCurrencyDropdownId(props.id);
|
|
1233
1235
|
var isHighPrecision = !MoneyInput.isEmpty(props.value) && MoneyInput.isHighPrecision(props.value, intl.locale);
|
|
1234
1236
|
var onBlur = props.onBlur;
|
|
1235
1237
|
var handleContainerBlur = react$1.useCallback(function (event) {
|
|
@@ -1240,18 +1242,18 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1240
1242
|
if (typeof onBlur === 'function' && !((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.relatedTarget))) {
|
|
1241
1243
|
onBlur({
|
|
1242
1244
|
target: {
|
|
1243
|
-
id: MoneyInput.getCurrencyDropdownId(
|
|
1245
|
+
id: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
1244
1246
|
name: getCurrencyDropdownName(props.name)
|
|
1245
1247
|
}
|
|
1246
1248
|
});
|
|
1247
1249
|
onBlur({
|
|
1248
1250
|
target: {
|
|
1249
|
-
id: MoneyInput.getAmountInputId(
|
|
1251
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1250
1252
|
name: getAmountInputName(props.name)
|
|
1251
1253
|
}
|
|
1252
1254
|
});
|
|
1253
1255
|
}
|
|
1254
|
-
}, [onBlur,
|
|
1256
|
+
}, [onBlur, moneyInputId, props.name]);
|
|
1255
1257
|
var TooltipPortal = react$1.useCallback(function (remainingProps) {
|
|
1256
1258
|
return jsxRuntime.jsx(Portal, _objectSpread(_objectSpread({}, remainingProps), {}, {
|
|
1257
1259
|
id: props.id
|
|
@@ -1265,11 +1267,11 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1265
1267
|
"data-testid": "money-input-container",
|
|
1266
1268
|
onBlur: handleContainerBlur,
|
|
1267
1269
|
children: [hasNoCurrencies ? jsxRuntime.jsx(CurrencyLabel, {
|
|
1268
|
-
id: MoneyInput.getAmountInputId(
|
|
1270
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1269
1271
|
isDisabled: props.isDisabled,
|
|
1270
1272
|
children: option && option.label
|
|
1271
1273
|
}) : jsxRuntime.jsx(Select__default["default"], {
|
|
1272
|
-
inputId:
|
|
1274
|
+
inputId: MoneyInput.getCurrencyDropdownId(moneyInputId),
|
|
1273
1275
|
name: getCurrencyDropdownName(props.name),
|
|
1274
1276
|
value: option,
|
|
1275
1277
|
isDisabled: props.isDisabled,
|
|
@@ -1277,7 +1279,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1277
1279
|
components: {
|
|
1278
1280
|
SingleValue: function SingleValue(innerProps) {
|
|
1279
1281
|
return jsxRuntime.jsx(_SingleValue, _objectSpread(_objectSpread({}, innerProps), {}, {
|
|
1280
|
-
id:
|
|
1282
|
+
id: MoneyInput.getCurrencyDropdownId(moneyInputId)
|
|
1281
1283
|
}));
|
|
1282
1284
|
},
|
|
1283
1285
|
Input: function Input(ownProps) {
|
|
@@ -1301,7 +1303,7 @@ var MoneyInput = function MoneyInput(props) {
|
|
|
1301
1303
|
css: _ref,
|
|
1302
1304
|
children: [jsxRuntime.jsx("input", _objectSpread({
|
|
1303
1305
|
ref: amountInputRef,
|
|
1304
|
-
id: MoneyInput.getAmountInputId(
|
|
1306
|
+
id: MoneyInput.getAmountInputId(moneyInputId),
|
|
1305
1307
|
autoComplete: props.autoComplete,
|
|
1306
1308
|
name: getAmountInputName(props.name),
|
|
1307
1309
|
type: "text",
|
|
@@ -1396,7 +1398,7 @@ MoneyInput.defaultProps = defaultProps;
|
|
|
1396
1398
|
var MoneyInput$1 = MoneyInput;
|
|
1397
1399
|
|
|
1398
1400
|
// NOTE: This string will be replaced on build time with the package version.
|
|
1399
|
-
var version = "13.0.
|
|
1401
|
+
var version = "13.0.2";
|
|
1400
1402
|
|
|
1401
1403
|
exports["default"] = MoneyInput$1;
|
|
1402
1404
|
exports.version = version;
|