@transferwise/components 45.28.0 → 46.0.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.
- package/build/i18n/cs.json +2 -0
- package/build/i18n/de.json +2 -0
- package/build/i18n/es.json +2 -0
- package/build/i18n/fr.json +2 -0
- package/build/i18n/hu.json +2 -0
- package/build/i18n/id.json +2 -0
- package/build/i18n/it.json +2 -0
- package/build/i18n/ja.json +2 -0
- package/build/i18n/pl.json +2 -0
- package/build/i18n/pt.json +5 -3
- package/build/i18n/ro.json +5 -3
- package/build/i18n/ru.json +3 -1
- package/build/i18n/th.json +2 -0
- package/build/i18n/tr.json +2 -0
- package/build/i18n/uk.json +2 -0
- package/build/i18n/zh-CN.json +8 -6
- package/build/i18n/zh-HK.json +2 -0
- package/build/index.esm.js +86 -67
- package/build/index.esm.js.map +1 -1
- package/build/index.js +86 -66
- package/build/index.js.map +1 -1
- package/build/types/common/hooks/useLayout/useLayout.d.ts +9 -6
- package/build/types/common/hooks/useLayout/useLayout.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/hooks/useLayout/useLayout.ts +21 -49
- package/src/common/responsivePanel/ResponsivePanel.spec.js +3 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +1 -19
- package/src/dateLookup/dateHeader/DateHeader.spec.js +2 -0
- package/src/drawer/Drawer.rtl.spec.js +3 -1
- package/src/drawer/Drawer.spec.js +2 -0
- package/src/i18n/cs.json +2 -0
- package/src/i18n/de.json +2 -0
- package/src/i18n/es.json +2 -0
- package/src/i18n/fr.json +2 -0
- package/src/i18n/hu.json +2 -0
- package/src/i18n/id.json +2 -0
- package/src/i18n/it.json +2 -0
- package/src/i18n/ja.json +2 -0
- package/src/i18n/pl.json +2 -0
- package/src/i18n/pt.json +5 -3
- package/src/i18n/ro.json +5 -3
- package/src/i18n/ru.json +3 -1
- package/src/i18n/th.json +2 -0
- package/src/i18n/tr.json +2 -0
- package/src/i18n/uk.json +2 -0
- package/src/i18n/zh-CN.json +8 -6
- package/src/i18n/zh-HK.json +2 -0
- package/src/index.ts +1 -0
- package/src/info/Info.spec.js +7 -11
- package/src/inputs/SelectInput.spec.tsx +5 -5
- package/src/inputs/SelectInput.tsx +16 -3
- package/src/modal/Modal.rtl.spec.js +3 -1
- package/src/modal/Modal.spec.js +2 -0
- package/src/modal/Modal.tsx +2 -2
- package/src/ssr.spec.js +1 -0
- package/src/uploadInput/UploadInput.spec.tsx +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { act, screen, within } from '@testing-library/react';
|
|
2
|
-
import userEvent
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { render, mockMatchMedia, mockResizeObserver } from '../test-utils';
|
|
5
5
|
|
|
@@ -44,7 +44,7 @@ describe('SelectInput', () => {
|
|
|
44
44
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
45
45
|
await act(async () => {
|
|
46
46
|
userEvent.tab();
|
|
47
|
-
userEvent.keyboard(
|
|
47
|
+
userEvent.keyboard(' ');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
const footer = screen.getByText('All items shown');
|
|
@@ -59,7 +59,7 @@ describe('SelectInput', () => {
|
|
|
59
59
|
userEvent.keyboard('x');
|
|
60
60
|
expect(footer).toHaveTextContent(/‘urx’$/);
|
|
61
61
|
|
|
62
|
-
userEvent.keyboard(
|
|
62
|
+
userEvent.keyboard('{Backspace}');
|
|
63
63
|
expect(footer).toHaveTextContent(/‘ur’$/);
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -110,7 +110,7 @@ describe('SelectInput', () => {
|
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
111
111
|
await act(async () => {
|
|
112
112
|
userEvent.tab();
|
|
113
|
-
userEvent.keyboard(
|
|
113
|
+
userEvent.keyboard(' ');
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
const listbox = screen.getByRole('listbox');
|
|
@@ -125,7 +125,7 @@ describe('SelectInput', () => {
|
|
|
125
125
|
userEvent.keyboard('x');
|
|
126
126
|
expect(within(listbox).queryByRole('option')).not.toBeInTheDocument();
|
|
127
127
|
|
|
128
|
-
userEvent.keyboard(
|
|
128
|
+
userEvent.keyboard('{Backspace}');
|
|
129
129
|
expect(within(listbox).getByRole('option')).toBeInTheDocument();
|
|
130
130
|
|
|
131
131
|
const option = within(listbox).getAllByRole('option')[0];
|
|
@@ -42,7 +42,8 @@ function inferSearchableStrings(value: unknown) {
|
|
|
42
42
|
|
|
43
43
|
const SelectInputTriggerButtonPropsContext = createContext<{
|
|
44
44
|
ref?: React.ForwardedRef<HTMLButtonElement>;
|
|
45
|
-
onClick?: () => void;
|
|
45
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
46
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
46
47
|
[key: string]: unknown;
|
|
47
48
|
}>({});
|
|
48
49
|
const SelectInputOptionContentWithinTriggerContext = createContext(false);
|
|
@@ -266,6 +267,16 @@ export function SelectInput<T = string>({
|
|
|
266
267
|
onClick: () => {
|
|
267
268
|
setOpen((prev) => !prev);
|
|
268
269
|
},
|
|
270
|
+
onKeyDown: (event: React.KeyboardEvent) => {
|
|
271
|
+
if (
|
|
272
|
+
event.key === ' ' ||
|
|
273
|
+
event.key === 'Enter' ||
|
|
274
|
+
event.key === 'ArrowDown' ||
|
|
275
|
+
event.key === 'ArrowUp'
|
|
276
|
+
) {
|
|
277
|
+
setOpen((prev) => !prev);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
269
280
|
},
|
|
270
281
|
getInteractionProps(),
|
|
271
282
|
),
|
|
@@ -326,14 +337,16 @@ export function SelectInputTriggerButton<T extends SelectInputTriggerButtonEleme
|
|
|
326
337
|
as = 'button' as T,
|
|
327
338
|
...restProps
|
|
328
339
|
}: SelectInputTriggerButtonProps<T>) {
|
|
329
|
-
const { ref, onClick, ...interactionProps } = useContext(
|
|
340
|
+
const { ref, onClick, onKeyDown, ...interactionProps } = useContext(
|
|
341
|
+
SelectInputTriggerButtonPropsContext,
|
|
342
|
+
);
|
|
330
343
|
|
|
331
344
|
return (
|
|
332
345
|
<ListboxBase.Button
|
|
333
346
|
ref={ref}
|
|
334
347
|
as={PolymorphicWithOverrides}
|
|
335
348
|
__overrides={{ as, ...interactionProps }}
|
|
336
|
-
{...mergeProps({ onClick }, restProps)}
|
|
349
|
+
{...mergeProps({ onClick, onKeyDown }, restProps)}
|
|
337
350
|
/>
|
|
338
351
|
);
|
|
339
352
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Position } from '../common';
|
|
2
|
-
import { render, fireEvent, screen } from '../test-utils';
|
|
2
|
+
import { render, fireEvent, screen, mockMatchMedia } from '../test-utils';
|
|
3
3
|
|
|
4
4
|
import Modal from './Modal';
|
|
5
5
|
|
|
6
|
+
mockMatchMedia();
|
|
7
|
+
|
|
6
8
|
describe('Modal', () => {
|
|
7
9
|
const props = {
|
|
8
10
|
onClose: jest.fn(),
|
package/src/modal/Modal.spec.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { mount } from 'enzyme';
|
|
2
2
|
|
|
3
3
|
import { Title } from '..';
|
|
4
|
+
import { mockMatchMedia } from '../test-utils';
|
|
4
5
|
|
|
5
6
|
import Modal from './Modal';
|
|
6
7
|
|
|
7
8
|
jest.useFakeTimers();
|
|
9
|
+
mockMatchMedia();
|
|
8
10
|
jest.mock('../common');
|
|
9
11
|
|
|
10
12
|
const defaultLocale = 'en-GB';
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -52,7 +52,7 @@ const Modal = ({
|
|
|
52
52
|
}: ModalProps) => {
|
|
53
53
|
const checkSpecialClasses = (classToCheck: string) =>
|
|
54
54
|
className?.split(' ').includes(classToCheck);
|
|
55
|
-
const {
|
|
55
|
+
const { isMedium } = useLayout();
|
|
56
56
|
|
|
57
57
|
// These should be replaced with props in breaking change.
|
|
58
58
|
const isCompact = checkSpecialClasses('compact');
|
|
@@ -60,7 +60,7 @@ const Modal = ({
|
|
|
60
60
|
|
|
61
61
|
const contentReference = useRef<HTMLDivElement>(null);
|
|
62
62
|
|
|
63
|
-
return
|
|
63
|
+
return !isMedium ? (
|
|
64
64
|
<Drawer
|
|
65
65
|
open={open}
|
|
66
66
|
headerTitle={title}
|
package/src/ssr.spec.js
CHANGED
|
@@ -2,7 +2,7 @@ import { within } from '@testing-library/react';
|
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { Status } from '../common';
|
|
5
|
-
import { render, screen, waitFor, waitForElementToBeRemoved } from '../test-utils';
|
|
5
|
+
import { mockMatchMedia, render, screen, waitFor, waitForElementToBeRemoved } from '../test-utils';
|
|
6
6
|
|
|
7
7
|
import UploadInput, { UploadInputProps } from './UploadInput';
|
|
8
8
|
import { TEST_IDS as UPLOAD_BUTTON_TEST_IDS } from './uploadButton/UploadButton';
|
|
@@ -10,6 +10,8 @@ import { TEST_IDS as UPLOAD_ITEM_TEST_IDS } from './uploadItem/UploadItem';
|
|
|
10
10
|
|
|
11
11
|
const spiedDateObject = jest.spyOn(global, 'Date');
|
|
12
12
|
|
|
13
|
+
mockMatchMedia();
|
|
14
|
+
|
|
13
15
|
describe('UploadInput', () => {
|
|
14
16
|
const pngFile = new File(['foo'], 'foo.png', { type: 'image/png' });
|
|
15
17
|
const jpgFile = new File(['foo'], 'foo.jpg', { type: 'image/jpeg' });
|