@transferwise/components 46.0.6 → 46.0.7

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 +1 @@
1
- {"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.js"],"names":[],"mappings":";;;;AA+DA;IACE,wBAcC;IAXC,mBAAkD;IAClD;;;;MASC;IAGH,uDAaC;IAED,+CAWE;IAEF,oCAIE;IAEF,kCAyBE;IAEF,qCAgBE;IAEF,yBAGE;IAFA,mCAA0B;IAI5B,0BAEE;IAEF;;;;MAME;IAEF,0BAuBC;IAED,kBAsBC;IAED,yCAGE;IAEF,+BAKE;IAEF,+CAQE;IAEF,+BAAqE;IAErE,sCA6IC;CACF"}
1
+ {"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.js"],"names":[],"mappings":";;;;AA+DA;IACE,wBAcC;IAXC,mBAAkD;IAClD;;;;MASC;IAGH,uDAaC;IAED,+CAWE;IAEF,oCAIE;IAEF,kCAyBE;IAEF,qCAgBE;IAEF,yBAGE;IAFA,mCAA0B;IAI5B,0BAEE;IAEF;;;;MAME;IAEF,0BAwBC;IAED,kBAsBC;IAED,yCAGE;IAEF,+BAKE;IAEF,+CAQE;IAEF,+BAAqE;IAErE,sCAuIC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.0.6",
3
+ "version": "46.0.7",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/i18n/de.json CHANGED
@@ -4,10 +4,10 @@
4
4
  "neptune.ClearButton.ariaLabel": "Zurücksetzen",
5
5
  "neptune.CloseButton.ariaLabel": "Schließen",
6
6
  "neptune.DateInput.day.label": "Tag",
7
- "neptune.DateInput.day.placeholder": "DD",
7
+ "neptune.DateInput.day.placeholder": "TT",
8
8
  "neptune.DateInput.month.label": "Monat",
9
9
  "neptune.DateInput.year.label": "Jahr",
10
- "neptune.DateInput.year.placeholder": "YYYY",
10
+ "neptune.DateInput.year.placeholder": "JJJJ",
11
11
  "neptune.DateLookup.day": "Tag",
12
12
  "neptune.DateLookup.goTo20YearView": "Zur 20-Jahres-Ansicht",
13
13
  "neptune.DateLookup.month": "Monat",
package/src/i18n/hu.json CHANGED
@@ -4,10 +4,10 @@
4
4
  "neptune.ClearButton.ariaLabel": "Törlés",
5
5
  "neptune.CloseButton.ariaLabel": "Bezárás",
6
6
  "neptune.DateInput.day.label": "Nap",
7
- "neptune.DateInput.day.placeholder": "Nap",
7
+ "neptune.DateInput.day.placeholder": "NN",
8
8
  "neptune.DateInput.month.label": "Hónap",
9
9
  "neptune.DateInput.year.label": "Év",
10
- "neptune.DateInput.year.placeholder": "Év",
10
+ "neptune.DateInput.year.placeholder": "ÉÉÉÉ",
11
11
  "neptune.DateLookup.day": "nap",
12
12
  "neptune.DateLookup.goTo20YearView": "Ugrás a 20 éves nézetre",
13
13
  "neptune.DateLookup.month": "hónap",
@@ -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 getFirstSelectItem = () => {
256
+ const hasSingleCurrency = () => {
256
257
  if (selectOptions.length !== 0) {
257
258
  const firstItem = selectOptions[0];
258
259
 
259
- if (firstItem.type === 'option') {
260
- return {
261
- hasOneCurrency: selectOptions.length === 1,
262
- currency: firstItem.value.currency,
263
- };
264
- }
265
-
266
- if (firstItem.type === 'group') {
267
- return {
268
- hasOneCurrency: firstItem.options.length === 1,
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 null;
275
+ return false;
275
276
  };
276
277
 
277
- const firstSelectItem = getFirstSelectItem();
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,
@@ -23,7 +23,7 @@ export default {
23
23
  <MoneyInput
24
24
  {...args}
25
25
  selectedCurrency={selectedCurrency}
26
- onCurrencyChange={currencies.length > 1 ? handleOnCurrencyChange : undefined}
26
+ onCurrencyChange={handleOnCurrencyChange}
27
27
  />
28
28
  </>
29
29
  );