@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.
Files changed (59) hide show
  1. package/build/i18n/cs.json +2 -0
  2. package/build/i18n/de.json +2 -0
  3. package/build/i18n/es.json +2 -0
  4. package/build/i18n/fr.json +2 -0
  5. package/build/i18n/hu.json +2 -0
  6. package/build/i18n/id.json +2 -0
  7. package/build/i18n/it.json +2 -0
  8. package/build/i18n/ja.json +2 -0
  9. package/build/i18n/pl.json +2 -0
  10. package/build/i18n/pt.json +5 -3
  11. package/build/i18n/ro.json +5 -3
  12. package/build/i18n/ru.json +3 -1
  13. package/build/i18n/th.json +2 -0
  14. package/build/i18n/tr.json +2 -0
  15. package/build/i18n/uk.json +2 -0
  16. package/build/i18n/zh-CN.json +8 -6
  17. package/build/i18n/zh-HK.json +2 -0
  18. package/build/index.esm.js +86 -67
  19. package/build/index.esm.js.map +1 -1
  20. package/build/index.js +86 -66
  21. package/build/index.js.map +1 -1
  22. package/build/types/common/hooks/useLayout/useLayout.d.ts +9 -6
  23. package/build/types/common/hooks/useLayout/useLayout.d.ts.map +1 -1
  24. package/build/types/index.d.ts +1 -0
  25. package/build/types/index.d.ts.map +1 -1
  26. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/common/hooks/useLayout/useLayout.ts +21 -49
  29. package/src/common/responsivePanel/ResponsivePanel.spec.js +3 -1
  30. package/src/dateLookup/DateLookup.testingLibrary.spec.js +1 -19
  31. package/src/dateLookup/dateHeader/DateHeader.spec.js +2 -0
  32. package/src/drawer/Drawer.rtl.spec.js +3 -1
  33. package/src/drawer/Drawer.spec.js +2 -0
  34. package/src/i18n/cs.json +2 -0
  35. package/src/i18n/de.json +2 -0
  36. package/src/i18n/es.json +2 -0
  37. package/src/i18n/fr.json +2 -0
  38. package/src/i18n/hu.json +2 -0
  39. package/src/i18n/id.json +2 -0
  40. package/src/i18n/it.json +2 -0
  41. package/src/i18n/ja.json +2 -0
  42. package/src/i18n/pl.json +2 -0
  43. package/src/i18n/pt.json +5 -3
  44. package/src/i18n/ro.json +5 -3
  45. package/src/i18n/ru.json +3 -1
  46. package/src/i18n/th.json +2 -0
  47. package/src/i18n/tr.json +2 -0
  48. package/src/i18n/uk.json +2 -0
  49. package/src/i18n/zh-CN.json +8 -6
  50. package/src/i18n/zh-HK.json +2 -0
  51. package/src/index.ts +1 -0
  52. package/src/info/Info.spec.js +7 -11
  53. package/src/inputs/SelectInput.spec.tsx +5 -5
  54. package/src/inputs/SelectInput.tsx +16 -3
  55. package/src/modal/Modal.rtl.spec.js +3 -1
  56. package/src/modal/Modal.spec.js +2 -0
  57. package/src/modal/Modal.tsx +2 -2
  58. package/src/ssr.spec.js +1 -0
  59. 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, { specialChars } from '@testing-library/user-event';
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(specialChars.enter);
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(specialChars.backspace);
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(specialChars.enter);
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(specialChars.backspace);
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(SelectInputTriggerButtonPropsContext);
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(),
@@ -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';
@@ -52,7 +52,7 @@ const Modal = ({
52
52
  }: ModalProps) => {
53
53
  const checkSpecialClasses = (classToCheck: string) =>
54
54
  className?.split(' ').includes(classToCheck);
55
- const { isMobile, isMedium: isTablet } = useLayout();
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 isMobile || isTablet ? (
63
+ return !isMedium ? (
64
64
  <Drawer
65
65
  open={open}
66
66
  headerTitle={title}
package/src/ssr.spec.js CHANGED
@@ -12,6 +12,7 @@ const excluded = new Set([
12
12
  'useSnackbar',
13
13
  'useDirection',
14
14
  'useLayout',
15
+ 'useScreenSize',
15
16
 
16
17
  // specific components
17
18
  'Provider',
@@ -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' });