@commercetools-uikit/localized-money-input 15.15.0 → 16.0.0

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.
@@ -1,2 +1,3 @@
1
1
  export * from "./declarations/src/index";
2
2
  export { default } from "./declarations/src/index";
3
+ //# sourceMappingURL=commercetools-uikit-localized-money-input.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commercetools-uikit-localized-money-input.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
@@ -10,10 +10,8 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
10
10
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
11
11
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
14
13
  var _pt = require('prop-types');
15
14
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
16
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
17
15
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
18
16
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
19
17
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -42,7 +40,6 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
42
40
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
43
41
  var _pt__default = /*#__PURE__*/_interopDefault(_pt);
44
42
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
45
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
46
43
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
47
44
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
48
45
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
@@ -72,21 +69,17 @@ var messages = reactIntl.defineMessages({
72
69
 
73
70
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
74
71
 
75
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
72
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
76
73
 
77
74
  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)."; }
78
- var sequentialId = utils.createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
75
+ const sequentialId = utils.createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
79
76
  // - The selected currency is placed first (e.g EUR)
80
77
  // - All other currencies follow, sorted alphabetically as well
81
78
 
82
- var sortCurrencies = function sortCurrencies(selectedCurrency, allCurrencies) {
83
- var _context;
84
-
85
- var remainingCurrencies = _filterInstanceProperty__default["default"](allCurrencies).call(allCurrencies, function (currency) {
86
- return currency !== selectedCurrency;
87
- });
79
+ const sortCurrencies = (selectedCurrency, allCurrencies) => {
80
+ const remainingCurrencies = _filterInstanceProperty__default["default"](allCurrencies).call(allCurrencies, currency => currency !== selectedCurrency);
88
81
 
89
- return _concatInstanceProperty__default["default"](_context = [selectedCurrency]).call(_context, _toConsumableArray(_sortInstanceProperty__default["default"](remainingCurrencies).call(remainingCurrencies)));
82
+ return [selectedCurrency, ..._sortInstanceProperty__default["default"](remainingCurrencies).call(remainingCurrencies)];
90
83
  };
91
84
 
92
85
  var _ref = process.env.NODE_ENV === "production" ? {
@@ -99,9 +92,9 @@ var _ref = process.env.NODE_ENV === "production" ? {
99
92
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
100
93
  };
101
94
 
102
- var LocalizedInput = function LocalizedInput(props) {
103
- var onChange = props.onChange;
104
- var handleChange = react.useCallback(function (event) {
95
+ const LocalizedInput = props => {
96
+ const onChange = props.onChange;
97
+ const handleChange = react.useCallback(event => {
105
98
  // We manipulate the event to add the currency to the target.
106
99
  // That way the users can read
107
100
  // event.target.currency and event.target.value to determine the next value.
@@ -155,22 +148,20 @@ LocalizedInput.propTypes = process.env.NODE_ENV !== "production" ? {
155
148
  } : {};
156
149
  LocalizedInput.displayName = 'LocalizedInput';
157
150
 
158
- var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
159
- var intl = reactIntl.useIntl();
160
- var defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
151
+ const LocalizedMoneyInput = props => {
152
+ const intl = reactIntl.useIntl();
153
+ const defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
161
154
  false;
162
155
 
163
- var _useToggleState = hooks.useToggleState(defaultExpansionState),
164
- _useToggleState2 = _slicedToArray(_useToggleState, 2),
165
- areCurrenciesExpanded = _useToggleState2[0],
166
- toggleCurrencies = _useToggleState2[1];
156
+ const _useToggleState = hooks.useToggleState(defaultExpansionState),
157
+ _useToggleState2 = _slicedToArray(_useToggleState, 2),
158
+ areCurrenciesExpanded = _useToggleState2[0],
159
+ toggleCurrencies = _useToggleState2[1];
167
160
 
168
- var onLocalizedMoneyInputToggle = react.useCallback(function () {
169
- return toggleCurrencies();
170
- }, [toggleCurrencies]);
171
- var id = hooks.useFieldId(props.id, sequentialId);
172
- var hasErrorInRemainingCurrencies = props.hasError || localizedUtils.getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
173
- var hasWarningInRemainingCurrencies = props.hasWarning || localizedUtils.getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
161
+ const onLocalizedMoneyInputToggle = react.useCallback(() => toggleCurrencies(), [toggleCurrencies]);
162
+ const id = hooks.useFieldId(props.id, sequentialId);
163
+ const hasErrorInRemainingCurrencies = props.hasError || localizedUtils.getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
164
+ const hasWarningInRemainingCurrencies = props.hasWarning || localizedUtils.getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
174
165
 
175
166
  if (hasErrorInRemainingCurrencies || hasWarningInRemainingCurrencies) {
176
167
  // this update within render replaces the old `getDerivedStateFromProps` functionality
@@ -180,8 +171,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
180
171
  }
181
172
  }
182
173
 
183
- var currencies = sortCurrencies(props.selectedCurrency, _Object$keys__default["default"](props.value));
184
- var shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
174
+ const currencies = sortCurrencies(props.selectedCurrency, _Object$keys__default["default"](props.value));
175
+ const shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
185
176
 
186
177
  if (props.hideCurrencyExpansionControls) {
187
178
  process.env.NODE_ENV !== "production" ? utils.warning(typeof props.defaultExpandCurrencies !== 'boolean', 'LocalizedMoneyInput: "defaultExpandCurrencies" does not have any effect when "hideCurrencyExpansionControls" is set.') : void 0;
@@ -193,8 +184,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
193
184
  scale: "xs",
194
185
  children: [jsxRuntime.jsx(Stack__default["default"], {
195
186
  scale: "s",
196
- children: _mapInstanceProperty__default["default"](currencies).call(currencies, function (currency, index) {
197
- var isFirstCurrency = index === 0;
187
+ children: _mapInstanceProperty__default["default"](currencies).call(currencies, (currency, index) => {
188
+ const isFirstCurrency = index === 0;
198
189
  if (!isFirstCurrency && !areCurrenciesExpanded) return null;
199
190
  return jsxRuntime.jsx(LocalizedInput, _objectSpread({
200
191
  id: LocalizedMoneyInput.getId(id, currency),
@@ -255,43 +246,41 @@ LocalizedMoneyInput.defaultProps = {
255
246
  horizontalConstraint: 'scale'
256
247
  };
257
248
 
258
- LocalizedMoneyInput.convertToMoneyValues = function (values, locale) {
259
- var _context2;
249
+ LocalizedMoneyInput.convertToMoneyValues = (values, locale) => {
250
+ var _context;
260
251
 
261
- return _mapInstanceProperty__default["default"](_context2 = _Object$values__default["default"](values)).call(_context2, function (value) {
252
+ return _mapInstanceProperty__default["default"](_context = _Object$values__default["default"](values)).call(_context, value => {
262
253
  return MoneyInput__default["default"].convertToMoneyValue(value, locale);
263
254
  });
264
255
  };
265
256
 
266
257
  LocalizedMoneyInput.parseMoneyValues = function () {
267
- var moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
268
- var locale = arguments.length > 1 ? arguments[1] : undefined;
269
- return _reduceInstanceProperty__default["default"](moneyValues).call(moneyValues, function (allValues, moneyValue) {
270
- var value = MoneyInput__default["default"].parseMoneyValue(moneyValue, locale);
271
- return _objectSpread(_objectSpread({}, allValues), {}, _defineProperty({}, value.currencyCode, value));
258
+ let moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
259
+ let locale = arguments.length > 1 ? arguments[1] : undefined;
260
+ return _reduceInstanceProperty__default["default"](moneyValues).call(moneyValues, (allValues, moneyValue) => {
261
+ const value = MoneyInput__default["default"].parseMoneyValue(moneyValue, locale);
262
+ return _objectSpread(_objectSpread({}, allValues), {}, {
263
+ [value.currencyCode]: value
264
+ });
272
265
  }, {});
273
266
  };
274
267
 
275
- LocalizedMoneyInput.getHighPrecisionCurrencies = function (values, locale) {
276
- var typedCurrencyCodes = _Object$keys__default["default"](values);
268
+ LocalizedMoneyInput.getHighPrecisionCurrencies = (values, locale) => {
269
+ const typedCurrencyCodes = _Object$keys__default["default"](values);
277
270
 
278
- return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
279
- return MoneyInput__default["default"].isHighPrecision(values[currencyCode], locale);
280
- });
271
+ return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput__default["default"].isHighPrecision(values[currencyCode], locale));
281
272
  };
282
273
 
283
- LocalizedMoneyInput.getEmptyCurrencies = function (values) {
284
- var typedCurrencyCodes = _Object$keys__default["default"](values);
274
+ LocalizedMoneyInput.getEmptyCurrencies = values => {
275
+ const typedCurrencyCodes = _Object$keys__default["default"](values);
285
276
 
286
- return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
287
- return MoneyInput__default["default"].isEmpty(values[currencyCode]);
288
- });
277
+ return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput__default["default"].isEmpty(values[currencyCode]));
289
278
  };
290
279
 
291
280
  var LocalizedMoneyInput$1 = LocalizedMoneyInput;
292
281
 
293
282
  // NOTE: This string will be replaced on build time with the package version.
294
- var version = "15.15.0";
283
+ var version = "16.0.0";
295
284
 
296
285
  exports["default"] = LocalizedMoneyInput$1;
297
286
  exports.version = version;
@@ -10,10 +10,8 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
10
10
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
11
11
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
14
13
  require('prop-types');
15
14
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
16
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
17
15
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
18
16
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
19
17
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -41,7 +39,6 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
41
39
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
42
40
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
43
41
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
44
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
45
42
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
46
43
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
47
44
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
@@ -71,19 +68,15 @@ var messages = reactIntl.defineMessages({
71
68
 
72
69
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
73
70
 
74
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
75
- var sequentialId = utils.createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
71
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
72
+ const sequentialId = utils.createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
76
73
  // - The selected currency is placed first (e.g EUR)
77
74
  // - All other currencies follow, sorted alphabetically as well
78
75
 
79
- var sortCurrencies = function sortCurrencies(selectedCurrency, allCurrencies) {
80
- var _context;
81
-
82
- var remainingCurrencies = _filterInstanceProperty__default["default"](allCurrencies).call(allCurrencies, function (currency) {
83
- return currency !== selectedCurrency;
84
- });
76
+ const sortCurrencies = (selectedCurrency, allCurrencies) => {
77
+ const remainingCurrencies = _filterInstanceProperty__default["default"](allCurrencies).call(allCurrencies, currency => currency !== selectedCurrency);
85
78
 
86
- return _concatInstanceProperty__default["default"](_context = [selectedCurrency]).call(_context, _toConsumableArray(_sortInstanceProperty__default["default"](remainingCurrencies).call(remainingCurrencies)));
79
+ return [selectedCurrency, ..._sortInstanceProperty__default["default"](remainingCurrencies).call(remainingCurrencies)];
87
80
  };
88
81
 
89
82
  var _ref = {
@@ -91,9 +84,9 @@ var _ref = {
91
84
  styles: "width:100%;position:relative;display:flex"
92
85
  } ;
93
86
 
94
- var LocalizedInput = function LocalizedInput(props) {
95
- var onChange = props.onChange;
96
- var handleChange = react.useCallback(function (event) {
87
+ const LocalizedInput = props => {
88
+ const onChange = props.onChange;
89
+ const handleChange = react.useCallback(event => {
97
90
  // We manipulate the event to add the currency to the target.
98
91
  // That way the users can read
99
92
  // event.target.currency and event.target.value to determine the next value.
@@ -132,22 +125,20 @@ var LocalizedInput = function LocalizedInput(props) {
132
125
  LocalizedInput.propTypes = {};
133
126
  LocalizedInput.displayName = 'LocalizedInput';
134
127
 
135
- var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
136
- var intl = reactIntl.useIntl();
137
- var defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
128
+ const LocalizedMoneyInput = props => {
129
+ const intl = reactIntl.useIntl();
130
+ const defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
138
131
  false;
139
132
 
140
- var _useToggleState = hooks.useToggleState(defaultExpansionState),
141
- _useToggleState2 = _slicedToArray(_useToggleState, 2),
142
- areCurrenciesExpanded = _useToggleState2[0],
143
- toggleCurrencies = _useToggleState2[1];
133
+ const _useToggleState = hooks.useToggleState(defaultExpansionState),
134
+ _useToggleState2 = _slicedToArray(_useToggleState, 2),
135
+ areCurrenciesExpanded = _useToggleState2[0],
136
+ toggleCurrencies = _useToggleState2[1];
144
137
 
145
- var onLocalizedMoneyInputToggle = react.useCallback(function () {
146
- return toggleCurrencies();
147
- }, [toggleCurrencies]);
148
- var id = hooks.useFieldId(props.id, sequentialId);
149
- var hasErrorInRemainingCurrencies = props.hasError || localizedUtils.getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
150
- var hasWarningInRemainingCurrencies = props.hasWarning || localizedUtils.getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
138
+ const onLocalizedMoneyInputToggle = react.useCallback(() => toggleCurrencies(), [toggleCurrencies]);
139
+ const id = hooks.useFieldId(props.id, sequentialId);
140
+ const hasErrorInRemainingCurrencies = props.hasError || localizedUtils.getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
141
+ const hasWarningInRemainingCurrencies = props.hasWarning || localizedUtils.getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
151
142
 
152
143
  if (hasErrorInRemainingCurrencies || hasWarningInRemainingCurrencies) {
153
144
  // this update within render replaces the old `getDerivedStateFromProps` functionality
@@ -157,8 +148,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
157
148
  }
158
149
  }
159
150
 
160
- var currencies = sortCurrencies(props.selectedCurrency, _Object$keys__default["default"](props.value));
161
- var shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
151
+ const currencies = sortCurrencies(props.selectedCurrency, _Object$keys__default["default"](props.value));
152
+ const shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
162
153
 
163
154
  if (props.hideCurrencyExpansionControls) ;
164
155
 
@@ -168,8 +159,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
168
159
  scale: "xs",
169
160
  children: [jsxRuntime.jsx(Stack__default["default"], {
170
161
  scale: "s",
171
- children: _mapInstanceProperty__default["default"](currencies).call(currencies, function (currency, index) {
172
- var isFirstCurrency = index === 0;
162
+ children: _mapInstanceProperty__default["default"](currencies).call(currencies, (currency, index) => {
163
+ const isFirstCurrency = index === 0;
173
164
  if (!isFirstCurrency && !areCurrenciesExpanded) return null;
174
165
  return jsxRuntime.jsx(LocalizedInput, _objectSpread({
175
166
  id: LocalizedMoneyInput.getId(id, currency),
@@ -212,43 +203,41 @@ LocalizedMoneyInput.defaultProps = {
212
203
  horizontalConstraint: 'scale'
213
204
  };
214
205
 
215
- LocalizedMoneyInput.convertToMoneyValues = function (values, locale) {
216
- var _context2;
206
+ LocalizedMoneyInput.convertToMoneyValues = (values, locale) => {
207
+ var _context;
217
208
 
218
- return _mapInstanceProperty__default["default"](_context2 = _Object$values__default["default"](values)).call(_context2, function (value) {
209
+ return _mapInstanceProperty__default["default"](_context = _Object$values__default["default"](values)).call(_context, value => {
219
210
  return MoneyInput__default["default"].convertToMoneyValue(value, locale);
220
211
  });
221
212
  };
222
213
 
223
214
  LocalizedMoneyInput.parseMoneyValues = function () {
224
- var moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
225
- var locale = arguments.length > 1 ? arguments[1] : undefined;
226
- return _reduceInstanceProperty__default["default"](moneyValues).call(moneyValues, function (allValues, moneyValue) {
227
- var value = MoneyInput__default["default"].parseMoneyValue(moneyValue, locale);
228
- return _objectSpread(_objectSpread({}, allValues), {}, _defineProperty({}, value.currencyCode, value));
215
+ let moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
216
+ let locale = arguments.length > 1 ? arguments[1] : undefined;
217
+ return _reduceInstanceProperty__default["default"](moneyValues).call(moneyValues, (allValues, moneyValue) => {
218
+ const value = MoneyInput__default["default"].parseMoneyValue(moneyValue, locale);
219
+ return _objectSpread(_objectSpread({}, allValues), {}, {
220
+ [value.currencyCode]: value
221
+ });
229
222
  }, {});
230
223
  };
231
224
 
232
- LocalizedMoneyInput.getHighPrecisionCurrencies = function (values, locale) {
233
- var typedCurrencyCodes = _Object$keys__default["default"](values);
225
+ LocalizedMoneyInput.getHighPrecisionCurrencies = (values, locale) => {
226
+ const typedCurrencyCodes = _Object$keys__default["default"](values);
234
227
 
235
- return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
236
- return MoneyInput__default["default"].isHighPrecision(values[currencyCode], locale);
237
- });
228
+ return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput__default["default"].isHighPrecision(values[currencyCode], locale));
238
229
  };
239
230
 
240
- LocalizedMoneyInput.getEmptyCurrencies = function (values) {
241
- var typedCurrencyCodes = _Object$keys__default["default"](values);
231
+ LocalizedMoneyInput.getEmptyCurrencies = values => {
232
+ const typedCurrencyCodes = _Object$keys__default["default"](values);
242
233
 
243
- return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
244
- return MoneyInput__default["default"].isEmpty(values[currencyCode]);
245
- });
234
+ return _filterInstanceProperty__default["default"](typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput__default["default"].isEmpty(values[currencyCode]));
246
235
  };
247
236
 
248
237
  var LocalizedMoneyInput$1 = LocalizedMoneyInput;
249
238
 
250
239
  // NOTE: This string will be replaced on build time with the package version.
251
- var version = "15.15.0";
240
+ var version = "16.0.0";
252
241
 
253
242
  exports["default"] = LocalizedMoneyInput$1;
254
243
  exports.version = version;
@@ -6,10 +6,8 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
6
6
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
7
7
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
8
8
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
9
- import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
10
9
  import _pt from 'prop-types';
11
10
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
12
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
13
11
  import _sortInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/sort';
14
12
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
15
13
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
@@ -48,21 +46,17 @@ var messages = defineMessages({
48
46
 
49
47
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
50
48
 
51
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
49
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
52
50
 
53
51
  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)."; }
54
- var sequentialId = createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
52
+ const sequentialId = createSequentialId('localized-money-input-'); // sorts the currencies with the following priority:
55
53
  // - The selected currency is placed first (e.g EUR)
56
54
  // - All other currencies follow, sorted alphabetically as well
57
55
 
58
- var sortCurrencies = function sortCurrencies(selectedCurrency, allCurrencies) {
59
- var _context;
60
-
61
- var remainingCurrencies = _filterInstanceProperty(allCurrencies).call(allCurrencies, function (currency) {
62
- return currency !== selectedCurrency;
63
- });
56
+ const sortCurrencies = (selectedCurrency, allCurrencies) => {
57
+ const remainingCurrencies = _filterInstanceProperty(allCurrencies).call(allCurrencies, currency => currency !== selectedCurrency);
64
58
 
65
- return _concatInstanceProperty(_context = [selectedCurrency]).call(_context, _toConsumableArray(_sortInstanceProperty(remainingCurrencies).call(remainingCurrencies)));
59
+ return [selectedCurrency, ..._sortInstanceProperty(remainingCurrencies).call(remainingCurrencies)];
66
60
  };
67
61
 
68
62
  var _ref = process.env.NODE_ENV === "production" ? {
@@ -75,9 +69,9 @@ var _ref = process.env.NODE_ENV === "production" ? {
75
69
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
76
70
  };
77
71
 
78
- var LocalizedInput = function LocalizedInput(props) {
79
- var onChange = props.onChange;
80
- var handleChange = useCallback(function (event) {
72
+ const LocalizedInput = props => {
73
+ const onChange = props.onChange;
74
+ const handleChange = useCallback(event => {
81
75
  // We manipulate the event to add the currency to the target.
82
76
  // That way the users can read
83
77
  // event.target.currency and event.target.value to determine the next value.
@@ -131,22 +125,20 @@ LocalizedInput.propTypes = process.env.NODE_ENV !== "production" ? {
131
125
  } : {};
132
126
  LocalizedInput.displayName = 'LocalizedInput';
133
127
 
134
- var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
135
- var intl = useIntl();
136
- var defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
128
+ const LocalizedMoneyInput = props => {
129
+ const intl = useIntl();
130
+ const defaultExpansionState = props.hideCurrencyExpansionControls || props.defaultExpandCurrencies || // default to `false`, because useToggleState defaults to `true`
137
131
  false;
138
132
 
139
- var _useToggleState = useToggleState(defaultExpansionState),
140
- _useToggleState2 = _slicedToArray(_useToggleState, 2),
141
- areCurrenciesExpanded = _useToggleState2[0],
142
- toggleCurrencies = _useToggleState2[1];
133
+ const _useToggleState = useToggleState(defaultExpansionState),
134
+ _useToggleState2 = _slicedToArray(_useToggleState, 2),
135
+ areCurrenciesExpanded = _useToggleState2[0],
136
+ toggleCurrencies = _useToggleState2[1];
143
137
 
144
- var onLocalizedMoneyInputToggle = useCallback(function () {
145
- return toggleCurrencies();
146
- }, [toggleCurrencies]);
147
- var id = useFieldId(props.id, sequentialId);
148
- var hasErrorInRemainingCurrencies = props.hasError || getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
149
- var hasWarningInRemainingCurrencies = props.hasWarning || getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
138
+ const onLocalizedMoneyInputToggle = useCallback(() => toggleCurrencies(), [toggleCurrencies]);
139
+ const id = useFieldId(props.id, sequentialId);
140
+ const hasErrorInRemainingCurrencies = props.hasError || getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
141
+ const hasWarningInRemainingCurrencies = props.hasWarning || getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
150
142
 
151
143
  if (hasErrorInRemainingCurrencies || hasWarningInRemainingCurrencies) {
152
144
  // this update within render replaces the old `getDerivedStateFromProps` functionality
@@ -156,8 +148,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
156
148
  }
157
149
  }
158
150
 
159
- var currencies = sortCurrencies(props.selectedCurrency, _Object$keys(props.value));
160
- var shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
151
+ const currencies = sortCurrencies(props.selectedCurrency, _Object$keys(props.value));
152
+ const shouldRenderCurrencyControl = currencies.length > 1 && !props.hideCurrencyExpansionControls;
161
153
 
162
154
  if (props.hideCurrencyExpansionControls) {
163
155
  process.env.NODE_ENV !== "production" ? warning(typeof props.defaultExpandCurrencies !== 'boolean', 'LocalizedMoneyInput: "defaultExpandCurrencies" does not have any effect when "hideCurrencyExpansionControls" is set.') : void 0;
@@ -169,8 +161,8 @@ var LocalizedMoneyInput = function LocalizedMoneyInput(props) {
169
161
  scale: "xs",
170
162
  children: [jsx(Stack, {
171
163
  scale: "s",
172
- children: _mapInstanceProperty(currencies).call(currencies, function (currency, index) {
173
- var isFirstCurrency = index === 0;
164
+ children: _mapInstanceProperty(currencies).call(currencies, (currency, index) => {
165
+ const isFirstCurrency = index === 0;
174
166
  if (!isFirstCurrency && !areCurrenciesExpanded) return null;
175
167
  return jsx(LocalizedInput, _objectSpread({
176
168
  id: LocalizedMoneyInput.getId(id, currency),
@@ -231,42 +223,40 @@ LocalizedMoneyInput.defaultProps = {
231
223
  horizontalConstraint: 'scale'
232
224
  };
233
225
 
234
- LocalizedMoneyInput.convertToMoneyValues = function (values, locale) {
235
- var _context2;
226
+ LocalizedMoneyInput.convertToMoneyValues = (values, locale) => {
227
+ var _context;
236
228
 
237
- return _mapInstanceProperty(_context2 = _Object$values(values)).call(_context2, function (value) {
229
+ return _mapInstanceProperty(_context = _Object$values(values)).call(_context, value => {
238
230
  return MoneyInput.convertToMoneyValue(value, locale);
239
231
  });
240
232
  };
241
233
 
242
234
  LocalizedMoneyInput.parseMoneyValues = function () {
243
- var moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
244
- var locale = arguments.length > 1 ? arguments[1] : undefined;
245
- return _reduceInstanceProperty(moneyValues).call(moneyValues, function (allValues, moneyValue) {
246
- var value = MoneyInput.parseMoneyValue(moneyValue, locale);
247
- return _objectSpread(_objectSpread({}, allValues), {}, _defineProperty({}, value.currencyCode, value));
235
+ let moneyValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
236
+ let locale = arguments.length > 1 ? arguments[1] : undefined;
237
+ return _reduceInstanceProperty(moneyValues).call(moneyValues, (allValues, moneyValue) => {
238
+ const value = MoneyInput.parseMoneyValue(moneyValue, locale);
239
+ return _objectSpread(_objectSpread({}, allValues), {}, {
240
+ [value.currencyCode]: value
241
+ });
248
242
  }, {});
249
243
  };
250
244
 
251
- LocalizedMoneyInput.getHighPrecisionCurrencies = function (values, locale) {
252
- var typedCurrencyCodes = _Object$keys(values);
245
+ LocalizedMoneyInput.getHighPrecisionCurrencies = (values, locale) => {
246
+ const typedCurrencyCodes = _Object$keys(values);
253
247
 
254
- return _filterInstanceProperty(typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
255
- return MoneyInput.isHighPrecision(values[currencyCode], locale);
256
- });
248
+ return _filterInstanceProperty(typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput.isHighPrecision(values[currencyCode], locale));
257
249
  };
258
250
 
259
- LocalizedMoneyInput.getEmptyCurrencies = function (values) {
260
- var typedCurrencyCodes = _Object$keys(values);
251
+ LocalizedMoneyInput.getEmptyCurrencies = values => {
252
+ const typedCurrencyCodes = _Object$keys(values);
261
253
 
262
- return _filterInstanceProperty(typedCurrencyCodes).call(typedCurrencyCodes, function (currencyCode) {
263
- return MoneyInput.isEmpty(values[currencyCode]);
264
- });
254
+ return _filterInstanceProperty(typedCurrencyCodes).call(typedCurrencyCodes, currencyCode => MoneyInput.isEmpty(values[currencyCode]));
265
255
  };
266
256
 
267
257
  var LocalizedMoneyInput$1 = LocalizedMoneyInput;
268
258
 
269
259
  // NOTE: This string will be replaced on build time with the package version.
270
- var version = "15.15.0";
260
+ var version = "16.0.0";
271
261
 
272
262
  export { LocalizedMoneyInput$1 as default, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/localized-money-input",
3
3
  "description": "A controlled input component for localized money values with validation states.",
4
- "version": "15.15.0",
4
+ "version": "16.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,31 +21,31 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/constraints": "15.15.0",
25
- "@commercetools-uikit/design-system": "15.15.0",
26
- "@commercetools-uikit/flat-button": "15.15.0",
27
- "@commercetools-uikit/hooks": "15.15.0",
28
- "@commercetools-uikit/icons": "15.15.0",
29
- "@commercetools-uikit/input-utils": "15.15.0",
30
- "@commercetools-uikit/localized-utils": "15.15.0",
31
- "@commercetools-uikit/money-input": "15.15.0",
32
- "@commercetools-uikit/select-utils": "15.15.0",
33
- "@commercetools-uikit/spacings-stack": "15.15.0",
34
- "@commercetools-uikit/tooltip": "15.15.0",
35
- "@commercetools-uikit/utils": "15.15.0",
24
+ "@commercetools-uikit/constraints": "16.0.0",
25
+ "@commercetools-uikit/design-system": "16.0.0",
26
+ "@commercetools-uikit/flat-button": "16.0.0",
27
+ "@commercetools-uikit/hooks": "16.0.0",
28
+ "@commercetools-uikit/icons": "16.0.0",
29
+ "@commercetools-uikit/input-utils": "16.0.0",
30
+ "@commercetools-uikit/localized-utils": "16.0.0",
31
+ "@commercetools-uikit/money-input": "16.0.0",
32
+ "@commercetools-uikit/select-utils": "16.0.0",
33
+ "@commercetools-uikit/spacings-stack": "16.0.0",
34
+ "@commercetools-uikit/tooltip": "16.0.0",
35
+ "@commercetools-uikit/utils": "16.0.0",
36
36
  "@emotion/react": "^11.10.5",
37
37
  "@emotion/styled": "^11.10.5",
38
38
  "prop-types": "15.8.1",
39
- "react-select": "5.7.1"
39
+ "react-select": "5.7.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "react": "17.0.2",
43
43
  "react-dom": "17.0.2",
44
- "react-intl": "^5.25.1"
44
+ "react-intl": "^6.3.2"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "17.x",
48
48
  "react-dom": "17.x",
49
- "react-intl": "5.x"
49
+ "react-intl": "6.x"
50
50
  }
51
51
  }