@transferwise/components 45.15.0 → 45.16.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 (111) hide show
  1. package/build/i18n/en.json +8 -0
  2. package/build/index.esm.js +550 -488
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +549 -487
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +1 -1
  7. package/build/styles/dateLookup/DateLookup.css +1 -1
  8. package/build/styles/main.css +1 -1
  9. package/build/styles/popover/Popover.css +1 -1
  10. package/build/styles/promoCard/PromoCard.css +1 -1
  11. package/build/types/alert/Alert.d.ts.map +1 -1
  12. package/build/types/avatarWrapper/AvatarWrapper.d.ts +14 -5
  13. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  14. package/build/types/common/Option/Option.d.ts.map +1 -1
  15. package/build/types/common/card/Card.d.ts.map +1 -1
  16. package/build/types/common/card/index.d.ts +1 -0
  17. package/build/types/common/card/index.d.ts.map +1 -1
  18. package/build/types/common/focusBoundary/FocusBoundary.d.ts +2 -2
  19. package/build/types/common/focusBoundary/FocusBoundary.d.ts.map +1 -1
  20. package/build/types/dateInput/DateInput.d.ts +2 -0
  21. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  22. package/build/types/dateLookup/DateLookup.messages.d.ts +65 -0
  23. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
  24. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +3 -1
  25. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  26. package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -26
  27. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  28. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +4 -29
  29. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  30. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  31. package/build/types/inputs/_Popover.d.ts.map +1 -1
  32. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  33. package/build/types/promoCard/PromoCard.d.ts +9 -3
  34. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  35. package/build/types/promoCard/PromoCardIndicator.d.ts +5 -3
  36. package/build/types/promoCard/PromoCardIndicator.d.ts.map +1 -1
  37. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  38. package/build/types/tabs/Tabs.d.ts.map +1 -1
  39. package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
  40. package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
  41. package/package.json +4 -3
  42. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +6 -6
  43. package/src/alert/Alert.js +11 -9
  44. package/src/alert/Alert.spec.js +22 -13
  45. package/src/alert/withArrow/withArrow.spec.js +4 -4
  46. package/src/avatarWrapper/AvatarWrapper.tsx +20 -8
  47. package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +1 -1
  48. package/src/card/Card.spec.js +2 -2
  49. package/src/common/Option/Option.tsx +1 -7
  50. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -1
  51. package/src/common/card/Card.tsx +6 -2
  52. package/src/common/card/index.ts +1 -0
  53. package/src/common/focusBoundary/FocusBoundary.tsx +9 -32
  54. package/src/dateInput/DateInput.js +6 -0
  55. package/src/dateInput/DateInput.story.tsx +2 -0
  56. package/src/dateLookup/DateLookup.css +1 -1
  57. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +3 -3
  58. package/src/dateLookup/DateLookup.less +4 -0
  59. package/src/dateLookup/DateLookup.messages.js +44 -0
  60. package/src/dateLookup/DateLookup.testingLibrary.spec.js +39 -0
  61. package/src/dateLookup/dateHeader/DateHeader.js +48 -26
  62. package/src/dateLookup/dateHeader/DateHeader.spec.js +37 -0
  63. package/src/dateLookup/dayCalendar/DayCalendar.js +3 -1
  64. package/src/dateLookup/dayCalendar/DayCalendar.spec.js +7 -1
  65. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +7 -3
  66. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +1 -0
  67. package/src/dateLookup/monthCalendar/MonthCalendar.js +3 -1
  68. package/src/dateLookup/monthCalendar/MonthCalendar.spec.js +7 -1
  69. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +4 -5
  70. package/src/dateLookup/tableLink/TableLink.js +25 -3
  71. package/src/dateLookup/tableLink/TableLink.spec.js +66 -4
  72. package/src/dateLookup/yearCalendar/YearCalendar.js +16 -3
  73. package/src/dateLookup/yearCalendar/YearCalendar.spec.js +14 -1
  74. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +4 -5
  75. package/src/i18n/en.json +8 -0
  76. package/src/inputs/SelectInput.story.tsx +36 -9
  77. package/src/inputs/_BottomSheet.less +1 -1
  78. package/src/inputs/_BottomSheet.tsx +57 -52
  79. package/src/inputs/_Popover.less +1 -1
  80. package/src/inputs/_Popover.tsx +31 -24
  81. package/src/listItem/ListItem.story.tsx +1 -1
  82. package/src/main.css +1 -1
  83. package/src/phoneNumberInput/PhoneNumberInput.js +1 -0
  84. package/src/popover/Popover.css +1 -1
  85. package/src/promoCard/PromoCard.css +1 -1
  86. package/src/promoCard/PromoCard.less +9 -9
  87. package/src/promoCard/PromoCard.spec.tsx +1 -0
  88. package/src/promoCard/PromoCard.story.tsx +90 -30
  89. package/src/promoCard/PromoCard.tsx +69 -22
  90. package/src/promoCard/PromoCardIndicator.tsx +20 -8
  91. package/src/snackbar/Snackbar.js +6 -1
  92. package/src/snackbar/Snackbar.spec.js +1 -3
  93. package/src/tabs/Tabs.js +2 -1
  94. package/src/upload/Upload.js +1 -1
  95. package/src/upload/steps/completeStep/completeStep.js +4 -1
  96. package/src/upload/steps/processingStep/processingStep.js +1 -0
  97. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -1
  98. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +0 -2
  99. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts.map +0 -1
  100. package/build/types/common/focusBoundary/utils/index.d.ts +0 -3
  101. package/build/types/common/focusBoundary/utils/index.d.ts.map +0 -1
  102. package/build/types/common/focusBoundary/utils/resetFocus.d.ts +0 -2
  103. package/build/types/common/focusBoundary/utils/resetFocus.d.ts.map +0 -1
  104. package/src/common/focusBoundary/FocusBoundary.spec.tsx +0 -66
  105. package/src/common/focusBoundary/__snapshots__/FocusBoundary.spec.tsx.snap +0 -16
  106. package/src/common/focusBoundary/utils/getFocusableElements.js +0 -25
  107. package/src/common/focusBoundary/utils/getFocusableElements.spec.js +0 -51
  108. package/src/common/focusBoundary/utils/index.js +0 -2
  109. package/src/common/focusBoundary/utils/resetFocus.js +0 -23
  110. package/src/common/focusBoundary/utils/resetFocus.spec.js +0 -103
  111. package/src/snackbar/__snapshots__/Snackbar.spec.js.snap +0 -5
@@ -1,66 +0,0 @@
1
- import { render, screen, userEvent } from '../../test-utils';
2
-
3
- import FocusBoundary from './FocusBoundary';
4
-
5
- const props = {
6
- onClose: jest.fn(),
7
- };
8
-
9
- describe('FocusBoundary', () => {
10
- beforeEach(() => {
11
- jest.clearAllMocks();
12
- });
13
- it('renders component', () => {
14
- const { container } = render(
15
- <FocusBoundary {...props}>
16
- <a href="test">Test</a>
17
- </FocusBoundary>,
18
- );
19
-
20
- expect(container).toMatchSnapshot();
21
- });
22
-
23
- it('focus on container by default', () => {
24
- render(
25
- <>
26
- <a href="test">not focusable</a>
27
- <FocusBoundary {...props}>
28
- <a href="test">Test</a>
29
- </FocusBoundary>
30
- </>,
31
- );
32
-
33
- expect(focusBoundary()).toHaveFocus();
34
- });
35
-
36
- it('traps the focus when user presses tab', () => {
37
- render(
38
- <>
39
- <a href="test">not focusable</a>
40
- <FocusBoundary {...props}>
41
- <a href="test">firstFocusable</a>
42
- <a href="test">lastFocusable</a>
43
- </FocusBoundary>
44
- </>,
45
- );
46
-
47
- userEvent.tab();
48
- expect(firstFocusableElement()).toHaveFocus();
49
-
50
- userEvent.tab();
51
- expect(lastFocusableElement()).toHaveFocus();
52
-
53
- userEvent.tab();
54
- expect(firstFocusableElement()).toHaveFocus();
55
-
56
- userEvent.tab({ shift: true });
57
- expect(lastFocusableElement()).toHaveFocus();
58
-
59
- userEvent.tab({ shift: true });
60
- expect(firstFocusableElement()).toHaveFocus();
61
- });
62
-
63
- const firstFocusableElement = () => screen.getByText('firstFocusable');
64
- const lastFocusableElement = () => screen.getByText('lastFocusable');
65
- const focusBoundary = () => document.querySelector('.np-focus-boundary');
66
- });
@@ -1,16 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`FocusBoundary renders component 1`] = `
4
- <div>
5
- <div
6
- class="np-focus-boundary outline-none"
7
- tabindex="-1"
8
- >
9
- <a
10
- href="test"
11
- >
12
- Test
13
- </a>
14
- </div>
15
- </div>
16
- `;
@@ -1,25 +0,0 @@
1
- /**
2
- * This function returns the first and the last focusable elements within a node.
3
- *
4
- * @param {Node} focusBoundaryContainer - the area that contains focused elements.
5
- * @returns {object} focusableEls - which contains the first focusable element and the last focusable element. First and last can be the same element if area contains one or none focusable element.
6
- */
7
-
8
- export const getFocusableElements = (focusBoundaryContainer) => {
9
- const focusableEls = { first: focusBoundaryContainer, last: focusBoundaryContainer };
10
-
11
- if (focusBoundaryContainer?.querySelectorAll) {
12
- const allEls = [
13
- ...focusBoundaryContainer.querySelectorAll(
14
- 'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])',
15
- ),
16
- ].filter((element) => !element.hasAttribute('disabled'));
17
-
18
- if (allEls.length > 0) {
19
- [focusableEls.first] = allEls;
20
- focusableEls.last = allEls[allEls.length - 1];
21
- }
22
- }
23
-
24
- return focusableEls;
25
- };
@@ -1,51 +0,0 @@
1
- import { cleanup, render, screen } from '../../../test-utils';
2
-
3
- import { getFocusableElements } from './getFocusableElements';
4
-
5
- describe('getFocusableElements', () => {
6
- afterEach(() => {
7
- cleanup();
8
- });
9
- it('returns first and last focusable element', () => {
10
- const { container } = render(
11
- <>
12
- <div>another element</div>
13
- <a href="test">first</a>
14
- <div>another element</div>
15
- <a href="test">middle</a>
16
- <div>another element</div>
17
- <a href="test">last</a>
18
- <div>another element</div>
19
- </>,
20
- );
21
- getFocusableElements(container);
22
- expect(getFocusableElements(container)).toStrictEqual({
23
- first: first(),
24
- last: last(),
25
- });
26
- });
27
-
28
- it('returns container if there are no focusable elements', () => {
29
- const { container } = render(
30
- <>
31
- <div>another element</div>
32
- </>,
33
- );
34
- getFocusableElements(container);
35
- expect(getFocusableElements(container)).toStrictEqual({
36
- first: container,
37
- last: container,
38
- });
39
- });
40
-
41
- it('returns undefined if container is not provided', () => {
42
- getFocusableElements();
43
- expect(getFocusableElements()).toStrictEqual({
44
- first: undefined,
45
- last: undefined,
46
- });
47
- });
48
-
49
- const first = () => screen.getByText('first');
50
- const last = () => screen.getByText('last');
51
- });
@@ -1,2 +0,0 @@
1
- export { getFocusableElements } from './getFocusableElements';
2
- export { resetFocus } from './resetFocus';
@@ -1,23 +0,0 @@
1
- /**
2
- * This function resets the focus to either last of first focusable elements within a node.
3
- *
4
- * @param {object} focusableEls - contains the first last of first focusable elements within a node.
5
- * @param {object} event - the triggered event
6
- */
7
-
8
- export const resetFocus = ({ focusableEls: { first, last }, event }) => {
9
- const { activeElement } = document;
10
- if (event.shiftKey && activeElement === first) {
11
- if (last) {
12
- last.focus();
13
- }
14
- event.preventDefault();
15
- }
16
-
17
- if (!event.shiftKey && activeElement === last) {
18
- if (first) {
19
- first.focus();
20
- }
21
- event.preventDefault();
22
- }
23
- };
@@ -1,103 +0,0 @@
1
- import { cleanup, render, screen, userEvent } from '../../../test-utils';
2
- import { fakeKeyDownEvent } from '../../fakeEvents';
3
-
4
- import { resetFocus } from './resetFocus';
5
-
6
- describe('resetFocus', () => {
7
- beforeEach(() => {
8
- render(
9
- <>
10
- <a href="test">first</a>
11
- <a href="test">middle</a>
12
- <a href="test">last</a>
13
- </>,
14
- );
15
- });
16
- afterEach(() => {
17
- cleanup();
18
- });
19
- it('set focus to first element when last element is focused and event is tab', () => {
20
- focusOnLast();
21
-
22
- resetFocus({
23
- focusableEls: { first: first(), last: last() },
24
- event: fakeKeyDownEvent({ shiftKey: false }),
25
- });
26
- expect(first()).toHaveFocus();
27
- });
28
-
29
- it('set focus to last element when first element is focused and event is shift + tab', () => {
30
- focusOnFirst();
31
-
32
- resetFocus({
33
- focusableEls: { first: first(), last: last() },
34
- event: fakeKeyDownEvent({ shiftKey: true }),
35
- });
36
- expect(last()).toHaveFocus();
37
- });
38
-
39
- it(`doesn't change focus when first element is focused and event is tab`, () => {
40
- focusOnFirst();
41
-
42
- resetFocus({
43
- focusableEls: { first: first(), last: last() },
44
- event: fakeKeyDownEvent(),
45
- });
46
- expect(first()).toHaveFocus();
47
- });
48
-
49
- it(`doesn't change focus when last element is focused and event is shift+tab`, () => {
50
- focusOnLast();
51
-
52
- resetFocus({
53
- focusableEls: { first: first(), last: last() },
54
- event: fakeKeyDownEvent({ shiftKey: true }),
55
- });
56
- expect(last()).toHaveFocus();
57
- });
58
-
59
- it(`doesn't change focus when middle element is focused and event is shift+tab or tab`, () => {
60
- focusOnMiddle();
61
-
62
- resetFocus({
63
- focusableEls: { first: first(), last: last() },
64
- event: fakeKeyDownEvent({ shiftKey: true }),
65
- });
66
- expect(middle()).toHaveFocus();
67
-
68
- resetFocus({
69
- focusableEls: { first: first(), last: last() },
70
- event: fakeKeyDownEvent(),
71
- });
72
- expect(middle()).toHaveFocus();
73
- });
74
-
75
- it(`doesn't change focus when first is the only element provided`, () => {
76
- focusOnFirst();
77
- resetFocus({
78
- focusableEls: { first: first(), last: undefined },
79
- event: fakeKeyDownEvent({ shiftKey: true }),
80
- });
81
- expect(first()).toHaveFocus();
82
- });
83
-
84
- it(`doesn't change focus when last is the only element provided`, () => {
85
- focusOnLast();
86
- resetFocus({
87
- focusableEls: { first: undefined, last: last() },
88
- event: fakeKeyDownEvent(),
89
- });
90
- expect(last()).toHaveFocus();
91
- });
92
-
93
- const first = () => screen.getByText('first');
94
- const last = () => screen.getByText('last');
95
- const middle = () => screen.getByText('middle');
96
-
97
- const focusOnFirst = () => userEvent.tab();
98
- const focusOnLast = () => userEvent.tab({ shift: true });
99
- const focusOnMiddle = () => {
100
- userEvent.tab();
101
- userEvent.tab();
102
- };
103
- });
@@ -1,5 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Snackbar accepts element as text 1`] = `"<div class=\\"snackbar\\"><span class=\\"np-text-body-default snackbar__text snackbar__text--light snackbar__text-container-enter snackbar__text-container-enter-active\\"><span>test</span></span></div>"`;
4
-
5
- exports[`Snackbar adjusts the theme if passed 1`] = `"<div class=\\"snackbar\\"><span class=\\"np-text-body-default snackbar__text snackbar__text--dark snackbar__text-container-enter snackbar__text-container-enter-active\\"><span>test</span></span></div>"`;