@transferwise/components 46.115.1 → 46.116.1

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 (77) hide show
  1. package/build/alert/Alert.js +2 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +2 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/criticalBanner/CriticalCommsBanner.js +1 -0
  6. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  7. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -0
  8. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  9. package/build/main.css +428 -44
  10. package/build/mocks.js +7 -0
  11. package/build/mocks.js.map +1 -1
  12. package/build/mocks.mjs +7 -1
  13. package/build/mocks.mjs.map +1 -1
  14. package/build/sentimentSurface/SentimentSurface.js +43 -0
  15. package/build/sentimentSurface/SentimentSurface.js.map +1 -0
  16. package/build/sentimentSurface/SentimentSurface.mjs +39 -0
  17. package/build/sentimentSurface/SentimentSurface.mjs.map +1 -0
  18. package/build/sentimentSurface/classMap.js +17 -0
  19. package/build/sentimentSurface/classMap.js.map +1 -0
  20. package/build/sentimentSurface/classMap.mjs +14 -0
  21. package/build/sentimentSurface/classMap.mjs.map +1 -0
  22. package/build/statusIcon/StatusIcon.js +10 -1
  23. package/build/statusIcon/StatusIcon.js.map +1 -1
  24. package/build/statusIcon/StatusIcon.mjs +10 -1
  25. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  26. package/build/styles/inputs/Input.css +2 -4
  27. package/build/styles/inputs/TextArea.css +2 -4
  28. package/build/styles/main.css +428 -44
  29. package/build/styles/popover/Popover.css +2 -4
  30. package/build/styles/sentimentSurface/SentimentSurface.css +420 -0
  31. package/build/styles/statusIcon/StatusIcon.css +4 -36
  32. package/build/types/alert/Alert.d.ts.map +1 -1
  33. package/build/types/criticalBanner/CriticalCommsBanner.d.ts +2 -1
  34. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  35. package/build/types/mocks.d.ts +1 -0
  36. package/build/types/mocks.d.ts.map +1 -1
  37. package/build/types/sentimentSurface/SentimentSurface.d.ts +30 -0
  38. package/build/types/sentimentSurface/SentimentSurface.d.ts.map +1 -0
  39. package/build/types/sentimentSurface/SentimentSurface.types.d.ts +80 -0
  40. package/build/types/sentimentSurface/SentimentSurface.types.d.ts.map +1 -0
  41. package/build/types/sentimentSurface/classMap.d.ts +4 -0
  42. package/build/types/sentimentSurface/classMap.d.ts.map +1 -0
  43. package/build/types/sentimentSurface/index.d.ts +3 -0
  44. package/build/types/sentimentSurface/index.d.ts.map +1 -0
  45. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  46. package/build/types/test-utils/window-mock.d.ts +1 -0
  47. package/build/types/test-utils/window-mock.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/src/alert/Alert.tsx +3 -1
  50. package/src/criticalBanner/CriticalCommsBanner.tsx +3 -2
  51. package/src/expressiveMoneyInput/ExpressiveMoneyInput.spec.tsx +229 -0
  52. package/src/expressiveMoneyInput/amountInput/AmountInput.spec.tsx +282 -0
  53. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.spec.tsx +160 -0
  54. package/src/inputs/Input.css +2 -4
  55. package/src/inputs/SelectInput.spec.tsx +7 -1
  56. package/src/inputs/TextArea.css +2 -4
  57. package/src/main.css +428 -44
  58. package/src/main.less +2 -0
  59. package/src/mocks.ts +7 -0
  60. package/src/moneyInput/MoneyInput.spec.tsx +9 -1
  61. package/src/popover/Popover.css +2 -4
  62. package/src/provider/theme/ThemeProvider.story.tsx +78 -11
  63. package/src/sentimentSurface/SentimentSurface.css +420 -0
  64. package/src/sentimentSurface/SentimentSurface.docs.mdx +549 -0
  65. package/src/sentimentSurface/SentimentSurface.less +293 -0
  66. package/src/sentimentSurface/SentimentSurface.spec.tsx +140 -0
  67. package/src/sentimentSurface/SentimentSurface.story.tsx +303 -0
  68. package/src/sentimentSurface/SentimentSurface.tests.story.tsx +72 -0
  69. package/src/sentimentSurface/SentimentSurface.tsx +72 -0
  70. package/src/sentimentSurface/SentimentSurface.types.ts +104 -0
  71. package/src/sentimentSurface/classMap.ts +15 -0
  72. package/src/sentimentSurface/index.ts +8 -0
  73. package/src/statusIcon/StatusIcon.css +4 -36
  74. package/src/statusIcon/StatusIcon.less +3 -41
  75. package/src/statusIcon/StatusIcon.tsx +14 -1
  76. package/src/test-utils/jest.setup.ts +0 -5
  77. package/src/test-utils/window-mock.ts +5 -0
@@ -0,0 +1,160 @@
1
+ import { mockMatchMedia, mockResizeObserver, render, screen, userEvent } from '../../test-utils';
2
+
3
+ import { CurrencySelector } from './CurrencySelector';
4
+
5
+ mockMatchMedia();
6
+ mockResizeObserver();
7
+
8
+ describe('CurrencySelector', () => {
9
+ it('can change currency', async () => {
10
+ const onChange = jest.fn();
11
+ render(
12
+ <CurrencySelector
13
+ options={mockCurrencies}
14
+ id="id"
15
+ currency="USD"
16
+ labelId="labelId"
17
+ onChange={onChange}
18
+ />,
19
+ );
20
+
21
+ await userEvent.click(screen.getByRole('combobox', { name: 'Select currency' }));
22
+
23
+ await userEvent.click(
24
+ screen.getByRole('option', {
25
+ name: /aed united arab emirates dirham/iu,
26
+ }),
27
+ );
28
+
29
+ expect(onChange).toHaveBeenCalledWith('AED');
30
+ });
31
+
32
+ it('locks the input when no onChange is provided', async () => {
33
+ render(<CurrencySelector options={mockCurrencies} id="id" currency="USD" labelId="labelId" />);
34
+
35
+ await userEvent.click(screen.getByRole('combobox', { name: 'Select currency' }));
36
+
37
+ expect(screen.getByRole('combobox')).toBeDisabled();
38
+ });
39
+
40
+ it('enables currency selection when just one group with multiple currencies', async () => {
41
+ render(
42
+ <CurrencySelector
43
+ options={[
44
+ {
45
+ title: 'Popular',
46
+ currencies: [
47
+ {
48
+ code: 'USD',
49
+ label: 'US Dollar',
50
+ keywords: ['USD', 'US Dollar'],
51
+ },
52
+ {
53
+ code: 'EUR',
54
+ label: 'Euro',
55
+ keywords: ['EUR', 'Euro'],
56
+ },
57
+ ],
58
+ },
59
+ ]}
60
+ id="id"
61
+ currency="USD"
62
+ labelId="labelId"
63
+ onChange={jest.fn()}
64
+ />,
65
+ );
66
+
67
+ expect(screen.getByRole('combobox')).toBeEnabled();
68
+ });
69
+
70
+ it('disables currency selection when just one currency', async () => {
71
+ render(
72
+ <CurrencySelector
73
+ options={[
74
+ {
75
+ title: 'Popular',
76
+ currencies: [
77
+ {
78
+ code: 'USD',
79
+ label: 'US Dollar',
80
+ keywords: ['USD', 'US Dollar'],
81
+ },
82
+ ],
83
+ },
84
+ ]}
85
+ id="id"
86
+ currency="USD"
87
+ labelId="labelId"
88
+ onChange={jest.fn()}
89
+ />,
90
+ );
91
+
92
+ expect(screen.getByRole('combobox')).toBeDisabled();
93
+ });
94
+
95
+ it('deduplicates currencies while searching', async () => {
96
+ render(
97
+ <CurrencySelector
98
+ options={mockCurrencies}
99
+ id="id"
100
+ currency="USD"
101
+ labelId="labelId"
102
+ onChange={jest.fn()}
103
+ />,
104
+ );
105
+
106
+ await userEvent.click(screen.getByRole('combobox', { name: 'Select currency' }));
107
+
108
+ await userEvent.type(
109
+ screen.getByRole('combobox', {
110
+ name: /type a currency \/ country/iu,
111
+ }),
112
+ 'EUR',
113
+ );
114
+
115
+ expect(screen.getAllByRole('option')).toHaveLength(1);
116
+ });
117
+ });
118
+
119
+ const mockCurrencies = [
120
+ {
121
+ title: 'Popular',
122
+ currencies: [
123
+ {
124
+ code: 'USD',
125
+ label: 'US Dollar',
126
+ keywords: ['USD'],
127
+ },
128
+ {
129
+ code: 'EUR',
130
+ label: 'Euro',
131
+ keywords: ['EUR'],
132
+ },
133
+ ],
134
+ },
135
+ {
136
+ title: 'All',
137
+ currencies: [
138
+ {
139
+ code: 'AED',
140
+ label: 'United Arab Emirates Dirham',
141
+ keywords: ['AED'],
142
+ },
143
+ {
144
+ code: 'AFN',
145
+ label: 'Afghan Afghani',
146
+ keywords: ['AFN'],
147
+ },
148
+ {
149
+ code: 'EUR',
150
+ label: 'Euro',
151
+ keywords: ['EUR', 'saudi arabia'],
152
+ },
153
+ {
154
+ code: 'AUD',
155
+ label: 'Australian Dollar',
156
+ keywords: ['AUD', 'australia'],
157
+ },
158
+ ],
159
+ },
160
+ ];
@@ -108,8 +108,7 @@
108
108
  }
109
109
  @supports (hyphenate-limit-chars: 1) {
110
110
  .np-form-control--size-lg {
111
- -webkit-hyphens: auto;
112
- hyphens: auto;
111
+ hyphens: auto;
113
112
  hyphenate-limit-chars: 7 3;
114
113
  }
115
114
  @media (min-width: 768px) {
@@ -125,8 +124,7 @@
125
124
  }
126
125
  @supports (not (hyphenate-limit-chars: 1)) and (-webkit-hyphenate-limit-before: 1) {
127
126
  .np-form-control--size-lg {
128
- -webkit-hyphens: auto;
129
- hyphens: auto;
127
+ hyphens: auto;
130
128
  -webkit-hyphenate-limit-before: 3;
131
129
  -webkit-hyphenate-limit-after: 3;
132
130
  }
@@ -1,13 +1,19 @@
1
1
  import { screen, waitFor, within } from '@testing-library/react';
2
2
  import { userEvent } from '@testing-library/user-event';
3
3
 
4
- import { render, mockMatchMedia, mockResizeObserver } from '../test-utils';
4
+ import {
5
+ render,
6
+ mockMatchMedia,
7
+ mockResizeObserver,
8
+ mockRequestAnimationFrame,
9
+ } from '../test-utils';
5
10
 
6
11
  import { SelectInput, type SelectInputOptionItem, type SelectInputProps } from './SelectInput';
7
12
  import { Field } from '../field/Field';
8
13
 
9
14
  mockMatchMedia();
10
15
  mockResizeObserver();
16
+ mockRequestAnimationFrame();
11
17
 
12
18
  describe('SelectInput', () => {
13
19
  it('renders placeholder', () => {
@@ -108,8 +108,7 @@
108
108
  }
109
109
  @supports (hyphenate-limit-chars: 1) {
110
110
  .np-form-control--size-lg {
111
- -webkit-hyphens: auto;
112
- hyphens: auto;
111
+ hyphens: auto;
113
112
  hyphenate-limit-chars: 7 3;
114
113
  }
115
114
  @media (min-width: 768px) {
@@ -125,8 +124,7 @@
125
124
  }
126
125
  @supports (not (hyphenate-limit-chars: 1)) and (-webkit-hyphenate-limit-before: 1) {
127
126
  .np-form-control--size-lg {
128
- -webkit-hyphens: auto;
129
- hyphens: auto;
127
+ hyphens: auto;
130
128
  -webkit-hyphenate-limit-before: 3;
131
129
  -webkit-hyphenate-limit-after: 3;
132
130
  }