@transferwise/components 46.4.0 → 46.6.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.
Files changed (69) hide show
  1. package/build/i18n/th.json +3 -3
  2. package/build/index.esm.js +177 -239
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +178 -240
  5. package/build/index.js.map +1 -1
  6. package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts +1 -1
  7. package/build/types/common/textFormat/formatWithPattern/formatWithPattern.d.ts.map +1 -1
  8. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts +2 -2
  9. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.d.ts.map +1 -1
  10. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts +5 -1
  11. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.d.ts.map +1 -1
  12. package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts +1 -1
  13. package/build/types/common/textFormat/unformatWithPattern/unformatWithPattern.d.ts.map +1 -1
  14. package/build/types/index.d.ts +3 -0
  15. package/build/types/index.d.ts.map +1 -1
  16. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +7 -11
  17. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
  18. package/build/types/inputWithDisplayFormat/index.d.ts +2 -1
  19. package/build/types/inputWithDisplayFormat/index.d.ts.map +1 -1
  20. package/build/types/inputs/SelectInput.d.ts +2 -2
  21. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  22. package/build/types/moneyInput/MoneyInput.d.ts +45 -31
  23. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  24. package/build/types/moneyInput/MoneyInput.messages.d.ts +6 -6
  25. package/build/types/moneyInput/MoneyInput.messages.d.ts.map +1 -1
  26. package/build/types/moneyInput/currencyFormatting.d.ts +2 -2
  27. package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
  28. package/build/types/moneyInput/index.d.ts +2 -1
  29. package/build/types/moneyInput/index.d.ts.map +1 -1
  30. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +7 -11
  31. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
  32. package/build/types/textareaWithDisplayFormat/index.d.ts +2 -1
  33. package/build/types/textareaWithDisplayFormat/index.d.ts.map +1 -1
  34. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +55 -83
  35. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  36. package/build/types/withDisplayFormat/index.d.ts +2 -1
  37. package/build/types/withDisplayFormat/index.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/common/textFormat/formatWithPattern/{formatWithPattern.js → formatWithPattern.ts} +8 -4
  40. package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.js → getCursorPositionAfterKeystroke.ts} +8 -8
  41. package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.js → getSymbolsInPatternWithPosition.ts} +7 -2
  42. package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.js → unformatWithPattern.ts} +3 -2
  43. package/src/flowNavigation/FlowNavigation.story.js +1 -1
  44. package/src/i18n/th.json +3 -3
  45. package/src/index.ts +8 -0
  46. package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +10 -0
  47. package/src/inputWithDisplayFormat/index.ts +2 -0
  48. package/src/inputs/SelectInput.tsx +2 -2
  49. package/src/moneyInput/{MoneyInput.rtl.spec.js → MoneyInput.rtl.spec.tsx} +4 -4
  50. package/src/moneyInput/MoneyInput.spec.js +109 -49
  51. package/src/moneyInput/MoneyInput.story.tsx +6 -14
  52. package/src/moneyInput/{MoneyInput.js → MoneyInput.tsx} +189 -173
  53. package/src/moneyInput/{currencyFormatting.spec.js → currencyFormatting.spec.ts} +2 -2
  54. package/src/moneyInput/{currencyFormatting.js → currencyFormatting.ts} +7 -10
  55. package/src/moneyInput/index.ts +7 -0
  56. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.spec.js +3 -1
  57. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +32 -0
  58. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +13 -0
  59. package/src/textareaWithDisplayFormat/index.ts +2 -0
  60. package/src/withDisplayFormat/WithDisplayFormat.spec.js +1 -1
  61. package/src/withDisplayFormat/{WithDisplayFormat.js → WithDisplayFormat.tsx} +127 -107
  62. package/src/withDisplayFormat/index.ts +2 -0
  63. package/src/inputWithDisplayFormat/InputWithDisplayFormat.js +0 -14
  64. package/src/inputWithDisplayFormat/index.js +0 -1
  65. package/src/moneyInput/index.js +0 -1
  66. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.js +0 -14
  67. package/src/textareaWithDisplayFormat/index.js +0 -1
  68. package/src/withDisplayFormat/index.js +0 -1
  69. /package/src/moneyInput/{MoneyInput.messages.js → MoneyInput.messages.ts} +0 -0
package/src/i18n/th.json CHANGED
@@ -9,16 +9,16 @@
9
9
  "neptune.DateInput.year.label": "ปี",
10
10
  "neptune.DateInput.year.placeholder": "YYYY",
11
11
  "neptune.DateLookup.day": "วัน",
12
- "neptune.DateLookup.goTo20YearView": "Go to 20 year view",
12
+ "neptune.DateLookup.goTo20YearView": "ไปที่มุมมอง 20 ปี",
13
13
  "neptune.DateLookup.month": "เดือน",
14
14
  "neptune.DateLookup.next": "ถัดไป",
15
15
  "neptune.DateLookup.previous": "ก่อนหน้า",
16
16
  "neptune.DateLookup.selected": "เลือกแล้ว",
17
17
  "neptune.DateLookup.twentyYears": "20 ปี",
18
18
  "neptune.DateLookup.year": "ปี",
19
- "neptune.FlowNavigation.back": "back to previous step",
19
+ "neptune.FlowNavigation.back": "กลับไปที่ขั้นก่อนหน้า",
20
20
  "neptune.Info.ariaLabel": "ข้อมูลเพิ่มเติม",
21
- "neptune.Link.opensInNewTab": "(opens in new tab)",
21
+ "neptune.Link.opensInNewTab": "(เปิดในแท็บใหม่)",
22
22
  "neptune.MoneyInput.Select.placeholder": "เลือกตัวเลือก...",
23
23
  "neptune.Select.searchPlaceholder": "ค้นหา...",
24
24
  "neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * Types
3
3
  */
4
4
  export type { InputProps } from './inputs/Input';
5
+ export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
5
6
  export type { InputGroupProps } from './inputs/InputGroup';
6
7
  export type { SearchInputProps } from './inputs/SearchInput';
7
8
  export type {
@@ -14,8 +15,15 @@ export type {
14
15
  SelectInputTriggerButtonProps,
15
16
  } from './inputs/SelectInput';
16
17
  export type { TextAreaProps } from './inputs/TextArea';
18
+ export type { TextareaWithDisplayFormatProps } from './textareaWithDisplayFormat';
17
19
  export type { UploadedFile, UploadError, UploadResponse } from './uploadInput/types';
18
20
  export type { ModalProps } from './modal';
21
+ export type {
22
+ CurrencyHeaderItem,
23
+ CurrencyItem,
24
+ CurrencyOptionItem,
25
+ MoneyInputProps,
26
+ } from './moneyInput';
19
27
  export type {
20
28
  LayoutDirection,
21
29
  TypographyTypes,
@@ -0,0 +1,10 @@
1
+ import { Input, type InputProps } from '../inputs/Input';
2
+ import WithDisplayFormat, { type WithDisplayFormatProps } from '../withDisplayFormat';
3
+
4
+ export interface InputWithDisplayFormatProps extends Omit<WithDisplayFormatProps, 'render'> {}
5
+
6
+ const InputWithDisplayFormat = (props: InputWithDisplayFormatProps) => (
7
+ <WithDisplayFormat<InputProps> {...props} render={(renderProps) => <Input {...renderProps} />} />
8
+ );
9
+
10
+ export default InputWithDisplayFormat;
@@ -0,0 +1,2 @@
1
+ export { default } from './InputWithDisplayFormat';
2
+ export type { InputWithDisplayFormatProps } from './InputWithDisplayFormat';
@@ -145,13 +145,13 @@ export interface SelectInputProps<T = string> {
145
145
  placeholderShown: boolean;
146
146
  clear: (() => void) | undefined;
147
147
  disabled: boolean;
148
- size: 'md' | 'lg';
148
+ size: 'sm' | 'md' | 'lg';
149
149
  className: string | undefined;
150
150
  }) => React.ReactNode;
151
151
  filterable?: boolean;
152
152
  filterPlaceholder?: string;
153
153
  disabled?: boolean;
154
- size?: 'md' | 'lg';
154
+ size?: 'sm' | 'md' | 'lg';
155
155
  className?: string;
156
156
  onFilterChange?: (args: { query: string; queryNormalized: string | null }) => void;
157
157
  onChange?: (value: T) => void;
@@ -1,4 +1,4 @@
1
- import { mockMatchMedia, mockResizeObserver, render, userEvent } from '../test-utils';
1
+ import { mockMatchMedia, mockResizeObserver, render, screen, userEvent } from '../test-utils';
2
2
 
3
3
  import MoneyInput from './MoneyInput';
4
4
 
@@ -46,7 +46,7 @@ describe('MoneyInput', () => {
46
46
  note: 'Australian dollar',
47
47
  currency: 'aud',
48
48
  },
49
- ];
49
+ ] as const;
50
50
  const props = {
51
51
  currencies,
52
52
  selectedCurrency: currencies[1],
@@ -62,9 +62,9 @@ describe('MoneyInput', () => {
62
62
  ['12,3', '12,3'],
63
63
  ['12.3', '12.3'],
64
64
  ])("ignores the letters when typed '%s' and shows '%s'", (testValue, expectedValue) => {
65
- const { container } = render(<MoneyInput {...props} amount={null} />);
65
+ render(<MoneyInput {...props} amount={null} />);
66
66
 
67
- const input = container.querySelector('input');
67
+ const input = screen.getByRole('textbox');
68
68
  userEvent.type(input, testValue);
69
69
  expect(input).toHaveValue(expectedValue);
70
70
  });
@@ -31,7 +31,7 @@ describe('Money Input', () => {
31
31
 
32
32
  let currencies;
33
33
 
34
- const EEK = { value: 'EEK', currency: 'EEK' };
34
+ const EEK = { value: 'EEK', label: 'EEK', currency: 'eek' };
35
35
 
36
36
  beforeEach(() => {
37
37
  currencies = [
@@ -185,7 +185,7 @@ describe('Money Input', () => {
185
185
  note: 'Canadian dollar',
186
186
  currency: 'cad',
187
187
  },
188
- filterMatchers: ['CAD', 'CAD', 'Canadian dollar', undefined],
188
+ filterMatchers: ['CAD', 'CAD', 'Canadian dollar', ''],
189
189
  },
190
190
  {
191
191
  type: 'option',
@@ -195,7 +195,7 @@ describe('Money Input', () => {
195
195
  note: 'Australian dollar',
196
196
  currency: 'aud',
197
197
  },
198
- filterMatchers: ['AUD', 'AUD', 'Australian dollar', undefined],
198
+ filterMatchers: ['AUD', 'AUD', 'Australian dollar', ''],
199
199
  },
200
200
  ],
201
201
  },
@@ -240,9 +240,9 @@ describe('Money Input', () => {
240
240
  it('hides headers', () => {
241
241
  currencies = [
242
242
  { header: 'A currency' },
243
- { value: 'GBP', label: 'British pound' },
243
+ { value: 'GBP', label: 'British pound', currency: 'gbp' },
244
244
  { header: 'Another currency' },
245
- { value: 'EUR', label: 'Euro' },
245
+ { value: 'EUR', label: 'Euro', currency: 'eur' },
246
246
  ];
247
247
  component.setProps({ currencies });
248
248
  expect(displayedCurrencies()).toStrictEqual([
@@ -252,8 +252,8 @@ describe('Money Input', () => {
252
252
  options: [
253
253
  {
254
254
  type: 'option',
255
- value: { value: 'GBP', label: 'British pound' },
256
- filterMatchers: ['GBP', 'British pound', undefined, undefined],
255
+ value: { value: 'GBP', label: 'British pound', currency: 'gbp' },
256
+ filterMatchers: ['GBP', 'British pound', '', ''],
257
257
  },
258
258
  ],
259
259
  },
@@ -263,8 +263,8 @@ describe('Money Input', () => {
263
263
  options: [
264
264
  {
265
265
  type: 'option',
266
- value: { value: 'EUR', label: 'Euro' },
267
- filterMatchers: ['EUR', 'Euro', undefined, undefined],
266
+ value: { value: 'EUR', label: 'Euro', currency: 'eur' },
267
+ filterMatchers: ['EUR', 'Euro', '', ''],
268
268
  },
269
269
  ],
270
270
  },
@@ -274,33 +274,33 @@ describe('Money Input', () => {
274
274
  expect(displayedCurrencies()).toStrictEqual([
275
275
  {
276
276
  type: 'option',
277
- value: { value: 'GBP', label: 'British pound' },
278
- filterMatchers: ['GBP', 'British pound', undefined, undefined],
277
+ value: { value: 'GBP', label: 'British pound', currency: 'gbp' },
278
+ filterMatchers: ['GBP', 'British pound', '', ''],
279
279
  },
280
280
  {
281
281
  type: 'option',
282
- value: { value: 'EUR', label: 'Euro' },
283
- filterMatchers: ['EUR', 'Euro', undefined, undefined],
282
+ value: { value: 'EUR', label: 'Euro', currency: 'eur' },
283
+ filterMatchers: ['EUR', 'Euro', '', ''],
284
284
  },
285
285
  ]);
286
286
  });
287
287
 
288
288
  it('searches by label', () => {
289
289
  currencies = [
290
- { value: 'GBP', label: 'British pound' },
291
- { value: 'EUR', label: 'Euro' },
290
+ { value: 'GBP', label: 'British pound', currency: 'gbp' },
291
+ { value: 'EUR', label: 'Euro', currency: 'eur' },
292
292
  ];
293
293
  component.setProps({ currencies });
294
294
  expect(displayedCurrencies()).toStrictEqual([
295
295
  {
296
296
  type: 'option',
297
- value: { value: 'GBP', label: 'British pound' },
298
- filterMatchers: ['GBP', 'British pound', undefined, undefined],
297
+ value: { value: 'GBP', label: 'British pound', currency: 'gbp' },
298
+ filterMatchers: ['GBP', 'British pound', '', ''],
299
299
  },
300
300
  {
301
301
  type: 'option',
302
- value: { value: 'EUR', label: 'Euro' },
303
- filterMatchers: ['EUR', 'Euro', undefined, undefined],
302
+ value: { value: 'EUR', label: 'Euro', currency: 'eur' },
303
+ filterMatchers: ['EUR', 'Euro', '', ''],
304
304
  },
305
305
  ]);
306
306
 
@@ -308,28 +308,28 @@ describe('Money Input', () => {
308
308
  expect(displayedCurrencies()).toStrictEqual([
309
309
  {
310
310
  type: 'option',
311
- value: { value: 'GBP', label: 'British pound' },
312
- filterMatchers: ['GBP', 'British pound', undefined, undefined],
311
+ value: { value: 'GBP', label: 'British pound', currency: 'gbp' },
312
+ filterMatchers: ['GBP', 'British pound', '', ''],
313
313
  },
314
314
  ]);
315
315
  });
316
316
 
317
317
  it('searches by note', () => {
318
318
  currencies = [
319
- { value: 'GBP', note: 'Queen money' },
320
- { value: 'EUR', note: 'Other money' },
319
+ { value: 'GBP', label: 'British pound', currency: 'gbp', note: 'Queen money' },
320
+ { value: 'EUR', label: 'Euro', currency: 'eur', note: 'Other money' },
321
321
  ];
322
322
  component.setProps({ currencies });
323
323
  expect(displayedCurrencies()).toStrictEqual([
324
324
  {
325
325
  type: 'option',
326
- value: { value: 'GBP', note: 'Queen money' },
327
- filterMatchers: ['GBP', undefined, 'Queen money', undefined],
326
+ value: { value: 'GBP', label: 'British pound', currency: 'gbp', note: 'Queen money' },
327
+ filterMatchers: ['GBP', 'British pound', 'Queen money', ''],
328
328
  },
329
329
  {
330
330
  type: 'option',
331
- value: { value: 'EUR', note: 'Other money' },
332
- filterMatchers: ['EUR', undefined, 'Other money', undefined],
331
+ value: { value: 'EUR', label: 'Euro', currency: 'eur', note: 'Other money' },
332
+ filterMatchers: ['EUR', 'Euro', 'Other money', ''],
333
333
  },
334
334
  ]);
335
335
 
@@ -337,28 +337,48 @@ describe('Money Input', () => {
337
337
  expect(displayedCurrencies()).toStrictEqual([
338
338
  {
339
339
  type: 'option',
340
- value: { value: 'EUR', note: 'Other money' },
341
- filterMatchers: ['EUR', undefined, 'Other money', undefined],
340
+ value: { value: 'EUR', label: 'Euro', currency: 'eur', note: 'Other money' },
341
+ filterMatchers: ['EUR', 'Euro', 'Other money', ''],
342
342
  },
343
343
  ]);
344
344
  });
345
345
 
346
346
  it('searches by searchable string', () => {
347
347
  currencies = [
348
- { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
349
- { value: 'EUR', searchable: 'Europe' },
348
+ {
349
+ value: 'GBP',
350
+ label: 'British pound',
351
+ currency: 'gbp',
352
+ searchable: 'Great Britain, United Kingdom',
353
+ },
354
+ {
355
+ value: 'EUR',
356
+ label: 'Euro',
357
+ currency: 'eur',
358
+ searchable: 'Europe',
359
+ },
350
360
  ];
351
361
  component.setProps({ currencies });
352
362
  expect(displayedCurrencies()).toStrictEqual([
353
363
  {
354
364
  type: 'option',
355
- value: { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
356
- filterMatchers: ['GBP', undefined, undefined, 'Great Britain, United Kingdom'],
365
+ value: {
366
+ value: 'GBP',
367
+ label: 'British pound',
368
+ currency: 'gbp',
369
+ searchable: 'Great Britain, United Kingdom',
370
+ },
371
+ filterMatchers: ['GBP', 'British pound', '', 'Great Britain, United Kingdom'],
357
372
  },
358
373
  {
359
374
  type: 'option',
360
- value: { value: 'EUR', searchable: 'Europe' },
361
- filterMatchers: ['EUR', undefined, undefined, 'Europe'],
375
+ value: {
376
+ value: 'EUR',
377
+ label: 'Euro',
378
+ currency: 'eur',
379
+ searchable: 'Europe',
380
+ },
381
+ filterMatchers: ['EUR', 'Euro', '', 'Europe'],
362
382
  },
363
383
  ]);
364
384
 
@@ -366,16 +386,31 @@ describe('Money Input', () => {
366
386
  expect(displayedCurrencies()).toStrictEqual([
367
387
  {
368
388
  type: 'option',
369
- value: { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
370
- filterMatchers: ['GBP', undefined, undefined, 'Great Britain, United Kingdom'],
389
+ value: {
390
+ value: 'GBP',
391
+ label: 'British pound',
392
+ currency: 'gbp',
393
+ searchable: 'Great Britain, United Kingdom',
394
+ },
395
+ filterMatchers: ['GBP', 'British pound', '', 'Great Britain, United Kingdom'],
371
396
  },
372
397
  ]);
373
398
  });
374
399
 
375
400
  it('shows custom action option on every search when onCustomAction is passed to MoneyInput', () => {
376
401
  currencies = [
377
- { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
378
- { value: 'EUR', searchable: 'Europe' },
402
+ {
403
+ value: 'GBP',
404
+ label: 'British pound',
405
+ currency: 'gbp',
406
+ searchable: 'Great Britain, United Kingdom',
407
+ },
408
+ {
409
+ value: 'EUR',
410
+ label: 'Euro',
411
+ currency: 'eur',
412
+ searchable: 'Europe',
413
+ },
379
414
  ];
380
415
  component.setProps({
381
416
  currencies,
@@ -385,13 +420,23 @@ describe('Money Input', () => {
385
420
  expect(displayedCurrencies()).toStrictEqual([
386
421
  {
387
422
  type: 'option',
388
- value: { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
389
- filterMatchers: ['GBP', undefined, undefined, 'Great Britain, United Kingdom'],
423
+ value: {
424
+ value: 'GBP',
425
+ label: 'British pound',
426
+ currency: 'gbp',
427
+ searchable: 'Great Britain, United Kingdom',
428
+ },
429
+ filterMatchers: ['GBP', 'British pound', '', 'Great Britain, United Kingdom'],
390
430
  },
391
431
  {
392
432
  type: 'option',
393
- value: { value: 'EUR', searchable: 'Europe' },
394
- filterMatchers: ['EUR', undefined, undefined, 'Europe'],
433
+ value: {
434
+ value: 'EUR',
435
+ label: 'Euro',
436
+ currency: 'eur',
437
+ searchable: 'Europe',
438
+ },
439
+ filterMatchers: ['EUR', 'Euro', '', 'Europe'],
395
440
  },
396
441
  ]);
397
442
 
@@ -399,8 +444,13 @@ describe('Money Input', () => {
399
444
  expect(displayedCurrencies()).toStrictEqual([
400
445
  {
401
446
  type: 'option',
402
- value: { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
403
- filterMatchers: ['GBP', undefined, undefined, 'Great Britain, United Kingdom'],
447
+ value: {
448
+ value: 'GBP',
449
+ label: 'British pound',
450
+ currency: 'gbp',
451
+ searchable: 'Great Britain, United Kingdom',
452
+ },
453
+ filterMatchers: ['GBP', 'British pound', '', 'Great Britain, United Kingdom'],
404
454
  },
405
455
  ]);
406
456
 
@@ -421,7 +471,7 @@ describe('Money Input', () => {
421
471
  note: 'Australian dollar',
422
472
  currency: 'aud',
423
473
  },
424
- filterMatchers: ['AUD', 'AUD', 'Australian dollar', undefined],
474
+ filterMatchers: ['AUD', 'AUD', 'Australian dollar', ''],
425
475
  },
426
476
  {
427
477
  type: 'option',
@@ -515,7 +565,7 @@ describe('Money Input', () => {
515
565
  );
516
566
 
517
567
  it('passes the id given to the input element', () => {
518
- expect(amountInput().prop('id')).toBeNull();
568
+ expect(amountInput().prop('id')).not.toBeDefined();
519
569
  component.setProps({ id: 'some-id' });
520
570
 
521
571
  expect(amountInput().prop('id')).toBe('some-id');
@@ -617,8 +667,18 @@ describe('Money Input', () => {
617
667
 
618
668
  it('shows custom action last when onCustomAction prop is passed to MoneyInput', () => {
619
669
  currencies = [
620
- { value: 'GBP', searchable: 'Great Britain, United Kingdom' },
621
- { value: 'EUR', searchable: 'Europe' },
670
+ {
671
+ value: 'GBP',
672
+ label: 'British pound',
673
+ currency: 'gbp',
674
+ searchable: 'Great Britain, United Kingdom',
675
+ },
676
+ {
677
+ value: 'EUR',
678
+ label: 'EUR',
679
+ currency: 'eur',
680
+ searchable: 'Europe',
681
+ },
622
682
  ];
623
683
  const onCustomActionMock = jest.fn();
624
684
  component.setProps({
@@ -3,19 +3,16 @@ import { within, userEvent } from '@storybook/testing-library';
3
3
  import { Lock } from '@transferwise/icons';
4
4
  import React, { useState } from 'react';
5
5
 
6
- import MoneyInput from '.';
6
+ import MoneyInput, { CurrencyOptionItem } from '.';
7
7
 
8
8
  export default {
9
9
  component: MoneyInput,
10
10
  title: 'Forms/MoneyInput',
11
11
  render: (args) => {
12
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[];
13
+ const [selectedCurrency, setSelectedCurrency] = useState(args.selectedCurrency);
17
14
 
18
- const handleOnCurrencyChange = (value: SelectedOption) => setSelectedCurrency(value);
15
+ const handleOnCurrencyChange = (value: CurrencyOptionItem) => setSelectedCurrency(value);
19
16
 
20
17
  return (
21
18
  <>
@@ -31,19 +28,14 @@ export default {
31
28
  args: {
32
29
  id: 'money-input',
33
30
  amount: 1000,
34
- selectProps: {
35
- buttonProps: {
36
- 'aria-label': 'Select currency',
37
- },
38
- },
31
+ onAmountChange: () => {},
32
+ onCurrencyChange: () => {},
39
33
  },
40
34
  tags: ['autodocs'],
41
35
  } satisfies Meta<typeof MoneyInput>;
42
36
 
43
37
  type Story = StoryObj<typeof MoneyInput>;
44
38
 
45
- type SelectedOption = (typeof exampleCurrency)[keyof typeof exampleCurrency];
46
-
47
39
  const exampleCurrency = {
48
40
  eur: {
49
41
  value: 'EUR',
@@ -111,7 +103,7 @@ export const SingleCurrency: Story = {
111
103
  args: {
112
104
  currencies: [],
113
105
  selectedCurrency: exampleCurrency.eur,
114
- onCurrencyChange: null,
106
+ onCurrencyChange: undefined,
115
107
  },
116
108
  };
117
109