@transferwise/components 46.0.6 → 46.0.8
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/i18n/de.json +2 -2
- package/build/i18n/hu.json +2 -2
- package/build/index.esm.js +22 -20
- package/build/index.esm.js.map +1 -1
- package/build/index.js +22 -20
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/inputs/SelectInput.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts +2 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/i18n/de.json +2 -2
- package/src/i18n/hu.json +2 -2
- package/src/inputs/SelectInput.css +1 -1
- package/src/inputs/SelectInput.tsx +1 -0
- package/src/inputs/_Popover.less +8 -1
- package/src/inputs/_Popover.tsx +8 -3
- package/src/main.css +1 -1
- package/src/moneyInput/MoneyInput.js +16 -21
- package/src/moneyInput/MoneyInput.spec.js +16 -3
- package/src/moneyInput/MoneyInput.story.tsx +1 -1
|
@@ -196,6 +196,7 @@ class MoneyInput extends Component {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
|
+
|
|
199
200
|
return formattedOptions;
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -252,35 +253,29 @@ class MoneyInput extends Component {
|
|
|
252
253
|
this.props;
|
|
253
254
|
const selectOptions = this.getSelectOptions();
|
|
254
255
|
|
|
255
|
-
const
|
|
256
|
+
const hasSingleCurrency = () => {
|
|
256
257
|
if (selectOptions.length !== 0) {
|
|
257
258
|
const firstItem = selectOptions[0];
|
|
258
259
|
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
currency: firstItem.options[0].value.currency,
|
|
270
|
-
};
|
|
260
|
+
if (selectOptions.length === 1) {
|
|
261
|
+
if (firstItem.type === 'option') {
|
|
262
|
+
return firstItem.value.currency === selectedCurrency.currency;
|
|
263
|
+
}
|
|
264
|
+
if (firstItem.type === 'group') {
|
|
265
|
+
return (
|
|
266
|
+
firstItem.options.length === 1 &&
|
|
267
|
+
!(this.props.onCustomAction && this.props.customActionLabel)
|
|
268
|
+
);
|
|
269
|
+
}
|
|
271
270
|
}
|
|
271
|
+
} else if (selectedCurrency?.currency) {
|
|
272
|
+
return true;
|
|
272
273
|
}
|
|
273
274
|
|
|
274
|
-
return
|
|
275
|
+
return false;
|
|
275
276
|
};
|
|
276
277
|
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const isFixedCurrency =
|
|
280
|
-
!this.state.searchQuery &&
|
|
281
|
-
((firstSelectItem?.hasOneCurrency &&
|
|
282
|
-
firstSelectItem?.currency === selectedCurrency.currency) ||
|
|
283
|
-
!onCurrencyChange);
|
|
278
|
+
const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;
|
|
284
279
|
|
|
285
280
|
const disabled = !this.props.onAmountChange;
|
|
286
281
|
return (
|
|
@@ -31,6 +31,8 @@ describe('Money Input', () => {
|
|
|
31
31
|
|
|
32
32
|
let currencies;
|
|
33
33
|
|
|
34
|
+
const EEK = { value: 'EEK', currency: 'EEK' };
|
|
35
|
+
|
|
34
36
|
beforeEach(() => {
|
|
35
37
|
currencies = [
|
|
36
38
|
{
|
|
@@ -526,14 +528,27 @@ describe('Money Input', () => {
|
|
|
526
528
|
expect(passedInAddon().type()).toBe('span');
|
|
527
529
|
});
|
|
528
530
|
|
|
531
|
+
it('shows fixed currency view if currencies array is empty but select currency exists', () => {
|
|
532
|
+
expect(fixedCurrencyDisplay()).toHaveLength(0);
|
|
533
|
+
|
|
534
|
+
component.setProps({
|
|
535
|
+
currencies: [],
|
|
536
|
+
selectedCurrency: EEK,
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
expect(currencySelect()).toHaveLength(0);
|
|
540
|
+
expect(fixedCurrencyDisplay()).toHaveLength(1);
|
|
541
|
+
expect(component.find(Title).props().children).toBe('EEK');
|
|
542
|
+
});
|
|
543
|
+
|
|
529
544
|
it('shows fixed currency view if only one currency available and selected', () => {
|
|
530
545
|
expect(fixedCurrencyDisplay()).toHaveLength(0);
|
|
531
546
|
|
|
532
|
-
const EEK = { value: 'EEK', currency: 'EEK' };
|
|
533
547
|
component.setProps({
|
|
534
548
|
currencies: [EEK],
|
|
535
549
|
selectedCurrency: EEK,
|
|
536
550
|
});
|
|
551
|
+
|
|
537
552
|
expect(currencySelect()).toHaveLength(0);
|
|
538
553
|
expect(fixedCurrencyDisplay()).toHaveLength(1);
|
|
539
554
|
expect(component.find(Title).props().children).toBe('EEK');
|
|
@@ -546,7 +561,6 @@ describe('Money Input', () => {
|
|
|
546
561
|
});
|
|
547
562
|
|
|
548
563
|
it('does not shows fixed currency keyline and flag if small input', () => {
|
|
549
|
-
const EEK = { value: 'EEK', currency: 'EEK' };
|
|
550
564
|
component.setProps({
|
|
551
565
|
currencies: [EEK],
|
|
552
566
|
selectedCurrency: EEK,
|
|
@@ -563,7 +577,6 @@ describe('Money Input', () => {
|
|
|
563
577
|
});
|
|
564
578
|
|
|
565
579
|
it('amount input will be disabled when there is no onAmountChange prop', () => {
|
|
566
|
-
const EEK = { value: 'EEK', currency: 'EEK' };
|
|
567
580
|
component.setProps({
|
|
568
581
|
currencies: [EEK],
|
|
569
582
|
selectedCurrency: EEK,
|