@transferwise/components 46.52.1 → 46.52.3
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/card/Card.js +20 -13
- package/build/card/Card.js.map +1 -1
- package/build/card/Card.mjs +21 -14
- package/build/card/Card.mjs.map +1 -1
- package/build/common/Option/Option.js.map +1 -1
- package/build/common/Option/Option.mjs.map +1 -1
- package/build/inputs/SelectInput.js +4 -0
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +4 -0
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/main.css +1 -0
- package/build/styles/inputs/InputGroup.css +1 -0
- package/build/styles/main.css +1 -0
- package/build/types/card/Card.d.ts.map +1 -1
- package/build/types/common/Option/Option.d.ts +2 -0
- package/build/types/common/Option/Option.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/card/Card.spec.tsx +35 -3
- package/src/card/Card.story.tsx +56 -40
- package/src/card/Card.tsx +32 -14
- package/src/common/Option/Option.tsx +2 -0
- package/src/dateInput/DateInput.spec.tsx +9 -9
- package/src/dateInput/DateInput.tests.story.tsx +1 -1
- package/src/inputs/InputGroup.css +1 -0
- package/src/inputs/InputGroup.less +1 -0
- package/src/inputs/SelectInput.spec.tsx +5 -5
- package/src/inputs/SelectInput.story.tsx +19 -7
- package/src/inputs/SelectInput.tsx +4 -0
- package/src/main.css +1 -0
- package/src/moneyInput/MoneyInput.story.tsx +1 -1
|
@@ -24,7 +24,7 @@ describe('Date Input Component', () => {
|
|
|
24
24
|
|
|
25
25
|
it('sets month field to empty', () => {
|
|
26
26
|
render(<DateInput {...props} />);
|
|
27
|
-
const monthSelect = screen.getByRole('
|
|
27
|
+
const monthSelect = screen.getByRole('combobox', { name: /month/i });
|
|
28
28
|
expect(monthSelect).toHaveValue('');
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -39,42 +39,42 @@ describe('Date Input Component', () => {
|
|
|
39
39
|
it('sets values correctly with a valid Date instance', () => {
|
|
40
40
|
render(<DateInput {...props} value="1971-08-01" />);
|
|
41
41
|
expect(screen.getByRole('textbox', { name: /day/i })).toHaveValue('1');
|
|
42
|
-
expect(screen.getByRole('
|
|
42
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toHaveTextContent('August');
|
|
43
43
|
expect(screen.getByRole('textbox', { name: /year/i })).toHaveValue('1971');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('sets values correctly with a valid short ISO8601 string', () => {
|
|
47
47
|
render(<DateInput {...props} value="1990-08-22" />);
|
|
48
48
|
expect(screen.getByRole('textbox', { name: /day/i })).toHaveValue('22');
|
|
49
|
-
expect(screen.getByRole('
|
|
49
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toHaveTextContent('August');
|
|
50
50
|
expect(screen.getByRole('textbox', { name: /year/i })).toHaveValue('1990');
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
it('sets values correctly with a valid short ISO8601 string with year and month only', () => {
|
|
54
54
|
render(<DateInput {...props} value="1990-08" />);
|
|
55
55
|
expect(screen.getByRole('textbox', { name: /day/i })).toHaveValue('');
|
|
56
|
-
expect(screen.getByRole('
|
|
56
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toHaveTextContent('August');
|
|
57
57
|
expect(screen.getByRole('textbox', { name: /year/i })).toHaveValue('1990');
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it('sets values correctly with a valid long ISO8601 string', () => {
|
|
61
61
|
render(<DateInput {...props} value="1990-02-28T00:00:00.000Z" />);
|
|
62
62
|
expect(screen.getByRole('textbox', { name: /day/i })).toHaveValue('28');
|
|
63
|
-
expect(screen.getByRole('
|
|
63
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toHaveTextContent('February');
|
|
64
64
|
expect(screen.getByRole('textbox', { name: /year/i })).toHaveValue('1990');
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it('sets values to disabled when disabled is set to true', () => {
|
|
68
68
|
render(<DateInput {...props} disabled />);
|
|
69
69
|
expect(screen.getByRole('textbox', { name: /day/i })).toBeDisabled();
|
|
70
|
-
expect(screen.getByRole('
|
|
70
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toBeDisabled();
|
|
71
71
|
expect(screen.getByRole('textbox', { name: /year/i })).toBeDisabled();
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
it("doesn't set values to disabled when disabled is set to false", () => {
|
|
75
75
|
render(<DateInput {...props} />);
|
|
76
76
|
expect(screen.getByRole('textbox', { name: /day/i })).toBeEnabled();
|
|
77
|
-
expect(screen.getByRole('
|
|
77
|
+
expect(screen.getByRole('combobox', { name: /month/i })).toBeEnabled();
|
|
78
78
|
expect(screen.getByRole('textbox', { name: /year/i })).toBeEnabled();
|
|
79
79
|
});
|
|
80
80
|
});
|
|
@@ -122,7 +122,7 @@ describe('Date Input Component', () => {
|
|
|
122
122
|
|
|
123
123
|
it('calls the onChange callback with the correct value when changing the month', async () => {
|
|
124
124
|
render(<DateInput {...props} value="2022-12-1" />);
|
|
125
|
-
const monthSelect = screen.getByRole('
|
|
125
|
+
const monthSelect = screen.getByRole('combobox', { name: /month/i });
|
|
126
126
|
await userEvent.click(monthSelect);
|
|
127
127
|
await userEvent.click(screen.getByRole('option', { name: /January/ }));
|
|
128
128
|
expect(props.onChange).toHaveBeenCalledWith('2022-01-01');
|
|
@@ -204,7 +204,7 @@ describe('Date Input Component', () => {
|
|
|
204
204
|
{...props}
|
|
205
205
|
/>,
|
|
206
206
|
);
|
|
207
|
-
const monthSelect = screen.getByRole('
|
|
207
|
+
const monthSelect = screen.getByRole('combobox', { name: /month/i });
|
|
208
208
|
expect(monthSelect).toHaveAttribute('id', 'mock-id');
|
|
209
209
|
});
|
|
210
210
|
});
|
|
@@ -76,7 +76,7 @@ describe('SelectInput', () => {
|
|
|
76
76
|
|
|
77
77
|
expect(screen.queryByText('EUR')).not.toBeInTheDocument();
|
|
78
78
|
|
|
79
|
-
const trigger = screen.
|
|
79
|
+
const trigger = screen.getByRole('combobox');
|
|
80
80
|
await userEvent.click(trigger);
|
|
81
81
|
|
|
82
82
|
expect(handleClose).not.toHaveBeenCalled();
|
|
@@ -110,7 +110,7 @@ describe('SelectInput', () => {
|
|
|
110
110
|
/>,
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
const trigger = screen.
|
|
113
|
+
const trigger = screen.getByRole('combobox');
|
|
114
114
|
await userEvent.tab();
|
|
115
115
|
await userEvent.keyboard(' ');
|
|
116
116
|
|
|
@@ -152,7 +152,7 @@ describe('SelectInput', () => {
|
|
|
152
152
|
/>,
|
|
153
153
|
);
|
|
154
154
|
|
|
155
|
-
const trigger = screen.
|
|
155
|
+
const trigger = screen.getByRole('combobox');
|
|
156
156
|
await userEvent.tab();
|
|
157
157
|
await userEvent.keyboard(' ');
|
|
158
158
|
|
|
@@ -189,7 +189,7 @@ describe('SelectInput', () => {
|
|
|
189
189
|
/>,
|
|
190
190
|
);
|
|
191
191
|
|
|
192
|
-
const trigger = screen.
|
|
192
|
+
const trigger = screen.getByRole('combobox');
|
|
193
193
|
await userEvent.click(trigger);
|
|
194
194
|
|
|
195
195
|
const listbox = screen.getByRole('listbox');
|
|
@@ -204,7 +204,7 @@ describe('SelectInput', () => {
|
|
|
204
204
|
it('supports custom `id` attribute', () => {
|
|
205
205
|
render(<SelectInput id="custom" items={[]} />);
|
|
206
206
|
|
|
207
|
-
const trigger = screen.
|
|
207
|
+
const trigger = screen.getByRole('combobox');
|
|
208
208
|
expect(trigger).toHaveAttribute('id', 'custom');
|
|
209
209
|
});
|
|
210
210
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { expect, fn, screen, userEvent, within
|
|
2
|
+
import { expect, fn, type Mock, screen, userEvent, within } from '@storybook/test';
|
|
3
3
|
import { Calendar, ChevronDown } from '@transferwise/icons';
|
|
4
4
|
import { Flag } from '@wise/art';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -8,6 +8,7 @@ import { useState } from 'react';
|
|
|
8
8
|
import Button from '../button/Button';
|
|
9
9
|
import { getMonthNames } from '../common/dateUtils';
|
|
10
10
|
import Drawer from '../drawer';
|
|
11
|
+
import { Field } from '../field/Field';
|
|
11
12
|
import Modal from '../modal';
|
|
12
13
|
import { wait } from '../test-utils/wait';
|
|
13
14
|
import {
|
|
@@ -73,12 +74,12 @@ export const Months: Story<Month | null> = {
|
|
|
73
74
|
const canvas = within(canvasElement);
|
|
74
75
|
|
|
75
76
|
await step('renders placeholder', async () => {
|
|
76
|
-
const triggerButton = canvas.getByRole('
|
|
77
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
77
78
|
await expect(triggerButton).toHaveTextContent('Month');
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
await step('selects option via mouse', async () => {
|
|
81
|
-
const triggerButton = canvas.getByRole('
|
|
82
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
82
83
|
|
|
83
84
|
await userEvent.click(triggerButton);
|
|
84
85
|
await userEvent.unhover(triggerButton);
|
|
@@ -195,7 +196,7 @@ export const Currencies: Story<Currency> = {
|
|
|
195
196
|
await expect(within(screen.getByRole('listbox')).queryAllByRole('option')).toHaveLength(8);
|
|
196
197
|
await expect(screen.getByText(/^Can’t find it?/u)).toBeInTheDocument();
|
|
197
198
|
|
|
198
|
-
const input = screen.getByRole('
|
|
199
|
+
const input = screen.getByRole('combobox');
|
|
199
200
|
|
|
200
201
|
await wait(0); // TODO: Remove
|
|
201
202
|
await userEvent.type(input, 'huf');
|
|
@@ -234,7 +235,7 @@ export const MultipleCurrencies: Story<Currency, true> = {
|
|
|
234
235
|
const canvas = within(canvasElement);
|
|
235
236
|
|
|
236
237
|
await step('selects multiple options via mouse', async () => {
|
|
237
|
-
const triggerButton = canvas.getByRole('
|
|
238
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
238
239
|
|
|
239
240
|
await userEvent.click(triggerButton);
|
|
240
241
|
await userEvent.unhover(triggerButton);
|
|
@@ -272,7 +273,7 @@ export const CustomTrigger: Story<Month> = {
|
|
|
272
273
|
play: async ({ canvasElement }) => {
|
|
273
274
|
const canvas = within(canvasElement);
|
|
274
275
|
|
|
275
|
-
const triggerButton = canvas.getByRole('
|
|
276
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
276
277
|
await userEvent.click(triggerButton);
|
|
277
278
|
},
|
|
278
279
|
};
|
|
@@ -317,7 +318,7 @@ export const Advanced: Story<Month> = {
|
|
|
317
318
|
play: async ({ canvasElement }) => {
|
|
318
319
|
const canvas = within(canvasElement);
|
|
319
320
|
|
|
320
|
-
const triggerButton = canvas.getByRole('
|
|
321
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
321
322
|
await userEvent.click(triggerButton);
|
|
322
323
|
},
|
|
323
324
|
};
|
|
@@ -342,6 +343,17 @@ export const ManyItems: Story<string, true> = {
|
|
|
342
343
|
},
|
|
343
344
|
};
|
|
344
345
|
|
|
346
|
+
export const WithinField = {
|
|
347
|
+
args: Months.args,
|
|
348
|
+
decorators: [
|
|
349
|
+
(Story) => (
|
|
350
|
+
<Field message="Something went wrong" sentiment="negative">
|
|
351
|
+
<Story />
|
|
352
|
+
</Field>
|
|
353
|
+
),
|
|
354
|
+
],
|
|
355
|
+
} satisfies Story<Month | null>;
|
|
356
|
+
|
|
345
357
|
export const WithinDrawer: Story<Currency> = {
|
|
346
358
|
args: CurrenciesArgs,
|
|
347
359
|
decorators: [
|
|
@@ -430,6 +430,7 @@ export function SelectInputTriggerButton<T extends SelectInputTriggerButtonEleme
|
|
|
430
430
|
<ListboxBase.Button
|
|
431
431
|
ref={ref}
|
|
432
432
|
as={PolymorphicWithOverrides}
|
|
433
|
+
role="combobox"
|
|
433
434
|
__overrides={{ as, ...interactionProps }}
|
|
434
435
|
{...mergeProps({ onClick, onKeyDown }, restProps)}
|
|
435
436
|
/>
|
|
@@ -608,9 +609,12 @@ function SelectInputOptions<T = string>({
|
|
|
608
609
|
<div className="np-select-input-query-container">
|
|
609
610
|
<SearchInput
|
|
610
611
|
ref={searchInputRef}
|
|
612
|
+
role="combobox"
|
|
611
613
|
shape="rectangle"
|
|
612
614
|
placeholder={filterPlaceholder}
|
|
613
615
|
defaultValue={filterQuery}
|
|
616
|
+
aria-autocomplete="list"
|
|
617
|
+
aria-expanded
|
|
614
618
|
aria-controls={listboxId}
|
|
615
619
|
aria-describedby={showStatus ? statusId : undefined}
|
|
616
620
|
onKeyDown={(event) => {
|
package/src/main.css
CHANGED
|
@@ -2387,6 +2387,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
.np-input-group {
|
|
2389
2389
|
display: inline-grid;
|
|
2390
|
+
width: 100%;
|
|
2390
2391
|
grid-auto-columns: minmax(0, 1fr);
|
|
2391
2392
|
/* Prevent unwanted `group-hover/input` triggers */
|
|
2392
2393
|
border-radius: 9999px;
|
|
@@ -153,7 +153,7 @@ export const OpenedInput: Story = {
|
|
|
153
153
|
...MultipleCurrencies,
|
|
154
154
|
play: async ({ canvasElement }) => {
|
|
155
155
|
const canvas = within(canvasElement);
|
|
156
|
-
await userEvent.click(canvas.getByRole('
|
|
156
|
+
await userEvent.click(canvas.getByRole('combobox'));
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
159
|
|