@transferwise/components 46.0.0 → 46.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.
- package/build/index.esm.js +15 -9
- package/build/index.esm.js.map +1 -1
- package/build/index.js +15 -9
- package/build/index.js.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/moneyInput/MoneyInput.js +19 -9
- package/src/moneyInput/MoneyInput.story.tsx +25 -2
package/build/index.esm.js
CHANGED
|
@@ -8014,20 +8014,26 @@ class MoneyInput extends Component {
|
|
|
8014
8014
|
maxLengthOverride
|
|
8015
8015
|
} = this.props;
|
|
8016
8016
|
const selectOptions = this.getSelectOptions();
|
|
8017
|
-
const
|
|
8017
|
+
const getFirstSelectItem = () => {
|
|
8018
8018
|
if (selectOptions.length !== 0) {
|
|
8019
|
-
const
|
|
8020
|
-
if (
|
|
8021
|
-
return
|
|
8019
|
+
const firstItem = selectOptions[0];
|
|
8020
|
+
if (firstItem.type === 'option') {
|
|
8021
|
+
return {
|
|
8022
|
+
hasOneCurrency: selectOptions.length === 1,
|
|
8023
|
+
currency: firstItem.value.currency
|
|
8024
|
+
};
|
|
8022
8025
|
}
|
|
8023
|
-
if (
|
|
8024
|
-
return
|
|
8026
|
+
if (firstItem.type === 'group') {
|
|
8027
|
+
return {
|
|
8028
|
+
hasOneCurrency: firstItem.options.length === 1,
|
|
8029
|
+
currency: firstItem.options[0].value.currency
|
|
8030
|
+
};
|
|
8025
8031
|
}
|
|
8026
8032
|
}
|
|
8027
8033
|
return null;
|
|
8028
8034
|
};
|
|
8029
|
-
const
|
|
8030
|
-
const isFixedCurrency = !this.state.searchQuery && (
|
|
8035
|
+
const firstSelectItem = getFirstSelectItem();
|
|
8036
|
+
const isFixedCurrency = !this.state.searchQuery && (firstSelectItem?.hasOneCurrency && firstSelectItem?.currency === selectedCurrency.currency || !onCurrencyChange);
|
|
8031
8037
|
const disabled = !this.props.onAmountChange;
|
|
8032
8038
|
return /*#__PURE__*/jsxs("div", {
|
|
8033
8039
|
className: classNames(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
@@ -8069,7 +8075,7 @@ class MoneyInput extends Component {
|
|
|
8069
8075
|
compareValues: "currency",
|
|
8070
8076
|
renderValue: (currency, withinTrigger) => {
|
|
8071
8077
|
return /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
8072
|
-
title: currency.label,
|
|
8078
|
+
title: withinTrigger ? currency.currency.toUpperCase() : currency.label,
|
|
8073
8079
|
note: withinTrigger ? undefined : currency.note,
|
|
8074
8080
|
icon: /*#__PURE__*/jsx(Flag, {
|
|
8075
8081
|
code: currency.currency,
|