@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.
- package/build/alert/Alert.js +2 -1
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +2 -1
- package/build/alert/Alert.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -0
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -0
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/main.css +428 -44
- package/build/mocks.js +7 -0
- package/build/mocks.js.map +1 -1
- package/build/mocks.mjs +7 -1
- package/build/mocks.mjs.map +1 -1
- package/build/sentimentSurface/SentimentSurface.js +43 -0
- package/build/sentimentSurface/SentimentSurface.js.map +1 -0
- package/build/sentimentSurface/SentimentSurface.mjs +39 -0
- package/build/sentimentSurface/SentimentSurface.mjs.map +1 -0
- package/build/sentimentSurface/classMap.js +17 -0
- package/build/sentimentSurface/classMap.js.map +1 -0
- package/build/sentimentSurface/classMap.mjs +14 -0
- package/build/sentimentSurface/classMap.mjs.map +1 -0
- package/build/statusIcon/StatusIcon.js +10 -1
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +10 -1
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/inputs/Input.css +2 -4
- package/build/styles/inputs/TextArea.css +2 -4
- package/build/styles/main.css +428 -44
- package/build/styles/popover/Popover.css +2 -4
- package/build/styles/sentimentSurface/SentimentSurface.css +420 -0
- package/build/styles/statusIcon/StatusIcon.css +4 -36
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts +2 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/mocks.d.ts +1 -0
- package/build/types/mocks.d.ts.map +1 -1
- package/build/types/sentimentSurface/SentimentSurface.d.ts +30 -0
- package/build/types/sentimentSurface/SentimentSurface.d.ts.map +1 -0
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts +80 -0
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts.map +1 -0
- package/build/types/sentimentSurface/classMap.d.ts +4 -0
- package/build/types/sentimentSurface/classMap.d.ts.map +1 -0
- package/build/types/sentimentSurface/index.d.ts +3 -0
- package/build/types/sentimentSurface/index.d.ts.map +1 -0
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/test-utils/window-mock.d.ts +1 -0
- package/build/types/test-utils/window-mock.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/alert/Alert.tsx +3 -1
- package/src/criticalBanner/CriticalCommsBanner.tsx +3 -2
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.spec.tsx +229 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.spec.tsx +282 -0
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.spec.tsx +160 -0
- package/src/inputs/Input.css +2 -4
- package/src/inputs/SelectInput.spec.tsx +7 -1
- package/src/inputs/TextArea.css +2 -4
- package/src/main.css +428 -44
- package/src/main.less +2 -0
- package/src/mocks.ts +7 -0
- package/src/moneyInput/MoneyInput.spec.tsx +9 -1
- package/src/popover/Popover.css +2 -4
- package/src/provider/theme/ThemeProvider.story.tsx +78 -11
- package/src/sentimentSurface/SentimentSurface.css +420 -0
- package/src/sentimentSurface/SentimentSurface.docs.mdx +549 -0
- package/src/sentimentSurface/SentimentSurface.less +293 -0
- package/src/sentimentSurface/SentimentSurface.spec.tsx +140 -0
- package/src/sentimentSurface/SentimentSurface.story.tsx +303 -0
- package/src/sentimentSurface/SentimentSurface.tests.story.tsx +72 -0
- package/src/sentimentSurface/SentimentSurface.tsx +72 -0
- package/src/sentimentSurface/SentimentSurface.types.ts +104 -0
- package/src/sentimentSurface/classMap.ts +15 -0
- package/src/sentimentSurface/index.ts +8 -0
- package/src/statusIcon/StatusIcon.css +4 -36
- package/src/statusIcon/StatusIcon.less +3 -41
- package/src/statusIcon/StatusIcon.tsx +14 -1
- package/src/test-utils/jest.setup.ts +0 -5
- 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
|
+
];
|
package/src/inputs/Input.css
CHANGED
|
@@ -108,8 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
@supports (hyphenate-limit-chars: 1) {
|
|
110
110
|
.np-form-control--size-lg {
|
|
111
|
-
|
|
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
|
-
|
|
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 {
|
|
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', () => {
|
package/src/inputs/TextArea.css
CHANGED
|
@@ -108,8 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
@supports (hyphenate-limit-chars: 1) {
|
|
110
110
|
.np-form-control--size-lg {
|
|
111
|
-
|
|
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
|
-
|
|
129
|
-
hyphens: auto;
|
|
127
|
+
hyphens: auto;
|
|
130
128
|
-webkit-hyphenate-limit-before: 3;
|
|
131
129
|
-webkit-hyphenate-limit-after: 3;
|
|
132
130
|
}
|