@transferwise/components 46.0.3 → 46.0.5

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.
@@ -15,6 +15,21 @@ declare namespace _default {
15
15
  const defaultMessage_2: string;
16
16
  export { defaultMessage_2 as defaultMessage };
17
17
  }
18
+ namespace dayPlaceholder {
19
+ const id_3: string;
20
+ export { id_3 as id };
21
+ const defaultMessage_3: string;
22
+ export { defaultMessage_3 as defaultMessage };
23
+ export const description: string;
24
+ }
25
+ namespace yearPlaceholder {
26
+ const id_4: string;
27
+ export { id_4 as id };
28
+ const defaultMessage_4: string;
29
+ export { defaultMessage_4 as defaultMessage };
30
+ const description_1: string;
31
+ export { description_1 as description };
32
+ }
18
33
  }
19
34
  export default _default;
20
35
  //# sourceMappingURL=DateInput.messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.js"],"names":[],"mappings":";;;;AA+DA;IACE,wBAeC;IAZC,mBAAkD;IAClD;;;;;MAUC;IAGH,uDAaC;IAED,+CAWE;IAEF,oCAIE;IAEF,kCAyBE;IAEF,qCAgBE;IAEF,yBAGE;IAFA,mCAA0B;IAI5B,0BAEE;IAEF;;;;MAME;IAEF,0BAuBC;IAED,kBAsBC;IAED,yCAIE;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,0BAuBC;IAED,kBAsBC;IAED,yCAGE;IAEF,+BAKE;IAEF,+CAQE;IAEF,+BAAqE;IAErE,sCA6IC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.0.3",
3
+ "version": "46.0.5",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -64,9 +64,9 @@ const DateInput = ({
64
64
  monthLabel = monthLabel || formatMessage(messages.monthLabel);
65
65
  yearLabel = yearLabel || formatMessage(messages.yearLabel);
66
66
  placeholders = {
67
- day: placeholders?.day || 'DD',
67
+ day: placeholders?.day || formatMessage(messages.dayPlaceholder),
68
68
  month: placeholders?.month || formatMessage(messages.monthLabel),
69
- year: placeholders?.year || 'YYYY',
69
+ year: placeholders?.year || formatMessage(messages.yearPlaceholder),
70
70
  };
71
71
 
72
72
  const getDateAsString = (date) => {
@@ -13,4 +13,14 @@ export default defineMessages({
13
13
  id: 'neptune.DateInput.year.label',
14
14
  defaultMessage: 'Year',
15
15
  },
16
+ dayPlaceholder: {
17
+ id: 'neptune.DateInput.day.placeholder',
18
+ defaultMessage: 'DD',
19
+ description: 'Placeholder for 2-digit day values within an input.',
20
+ },
21
+ yearPlaceholder: {
22
+ id: 'neptune.DateInput.year.placeholder',
23
+ defaultMessage: 'YYYY',
24
+ description: 'Placeholder for 4-digit year values within an input.',
25
+ },
16
26
  });
@@ -60,6 +60,16 @@ jest.mock('./DateInput.messages', () => ({
60
60
  id: 'neptune.DateInput.year.label',
61
61
  defaultMessage: 'Year',
62
62
  },
63
+ dayPlaceholder: {
64
+ id: 'neptune.DateInput.day.placeholder',
65
+ defaultMessage: 'DD',
66
+ description: 'Placeholder for 2-digit day values within an input.',
67
+ },
68
+ yearPlaceholder: {
69
+ id: 'neptune.DateInput.year.placeholder',
70
+ defaultMessage: 'YYYY',
71
+ description: 'Placeholder for 4-digit year values within an input.',
72
+ },
63
73
  }));
64
74
 
65
75
  jest.mock('react-intl');
package/src/i18n/en.json CHANGED
@@ -4,8 +4,10 @@
4
4
  "neptune.ClearButton.ariaLabel": "Clear",
5
5
  "neptune.CloseButton.ariaLabel": "Close",
6
6
  "neptune.DateInput.day.label": "Day",
7
+ "neptune.DateInput.day.placeholder": "DD",
7
8
  "neptune.DateInput.month.label": "Month",
8
9
  "neptune.DateInput.year.label": "Year",
10
+ "neptune.DateInput.year.placeholder": "YYYY",
9
11
  "neptune.DateLookup.day": "day",
10
12
  "neptune.DateLookup.goTo20YearView": "Go to 20 year view",
11
13
  "neptune.DateLookup.month": "month",
@@ -68,7 +68,6 @@ class MoneyInput extends Component {
68
68
  this.formatMessage = this.props.intl.formatMessage;
69
69
  this.state = {
70
70
  searchQuery: '',
71
- selectedOption: this.props.selectedCurrency,
72
71
  formattedAmount: formatAmountIfSet(
73
72
  props.amount,
74
73
  props.selectedCurrency.currency,
@@ -226,7 +225,6 @@ class MoneyInput extends Component {
226
225
 
227
226
  handleSelectChange = (value) => {
228
227
  this.handleSearchChange('');
229
- this.setState({ selectedOption: value });
230
228
  this.props.onCurrencyChange(value);
231
229
  };
232
230
 
@@ -356,7 +354,7 @@ class MoneyInput extends Component {
356
354
  >
357
355
  <SelectInput
358
356
  items={selectOptions}
359
- value={this.state.selectedOption}
357
+ value={selectedCurrency}
360
358
  compareValues="currency"
361
359
  renderValue={(currency, withinTrigger) => {
362
360
  return (
@@ -1,19 +1,33 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { within, userEvent } from '@storybook/testing-library';
3
3
  import { Lock } from '@transferwise/icons';
4
- import React from 'react';
4
+ import React, { useState } from 'react';
5
5
 
6
6
  import MoneyInput from '.';
7
7
 
8
8
  export default {
9
9
  component: MoneyInput,
10
10
  title: 'Forms/MoneyInput',
11
- render: (args) => (
12
- <>
13
- <label htmlFor={args.id as string}>Editable money input label</label>
14
- <MoneyInput {...args} />
15
- </>
16
- ),
11
+ render: (args) => {
12
+ // eslint-disable-next-line react-hooks/rules-of-hooks
13
+ const [selectedCurrency, setSelectedCurrency] = useState(
14
+ args.selectedCurrency as SelectedOption,
15
+ );
16
+ const currencies = args.currencies as SelectedOption[];
17
+
18
+ const handleOnCurrencyChange = (value: SelectedOption) => setSelectedCurrency(value);
19
+
20
+ return (
21
+ <>
22
+ <label htmlFor={args.id as string}>Editable money input label</label>
23
+ <MoneyInput
24
+ {...args}
25
+ selectedCurrency={selectedCurrency}
26
+ onCurrencyChange={currencies.length > 1 ? handleOnCurrencyChange : undefined}
27
+ />
28
+ </>
29
+ );
30
+ },
17
31
  args: {
18
32
  id: 'money-input',
19
33
  amount: 1000,
@@ -28,6 +42,8 @@ export default {
28
42
 
29
43
  type Story = StoryObj<typeof MoneyInput>;
30
44
 
45
+ type SelectedOption = (typeof exampleCurrency)[keyof typeof exampleCurrency];
46
+
31
47
  const exampleCurrency = {
32
48
  eur: {
33
49
  value: 'EUR',