@transferwise/components 45.15.0 → 45.15.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.
Files changed (82) hide show
  1. package/build/i18n/en.json +8 -0
  2. package/build/index.esm.js +322 -318
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +321 -317
  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/types/avatarWrapper/AvatarWrapper.d.ts +14 -5
  10. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  11. package/build/types/common/Option/Option.d.ts.map +1 -1
  12. package/build/types/common/focusBoundary/FocusBoundary.d.ts +2 -2
  13. package/build/types/common/focusBoundary/FocusBoundary.d.ts.map +1 -1
  14. package/build/types/dateInput/DateInput.d.ts +2 -0
  15. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  16. package/build/types/dateLookup/DateLookup.messages.d.ts +65 -0
  17. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
  18. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +3 -1
  19. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  20. package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -26
  21. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  22. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +4 -29
  23. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  24. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  25. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  26. package/build/types/tabs/Tabs.d.ts.map +1 -1
  27. package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
  28. package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
  29. package/package.json +2 -1
  30. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +6 -6
  31. package/src/avatarWrapper/AvatarWrapper.tsx +20 -8
  32. package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +1 -1
  33. package/src/card/Card.spec.js +2 -2
  34. package/src/common/Option/Option.tsx +1 -7
  35. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -1
  36. package/src/common/focusBoundary/FocusBoundary.tsx +9 -32
  37. package/src/dateInput/DateInput.js +6 -0
  38. package/src/dateInput/DateInput.story.tsx +2 -0
  39. package/src/dateLookup/DateLookup.css +1 -1
  40. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +3 -3
  41. package/src/dateLookup/DateLookup.less +4 -0
  42. package/src/dateLookup/DateLookup.messages.js +44 -0
  43. package/src/dateLookup/DateLookup.testingLibrary.spec.js +39 -0
  44. package/src/dateLookup/dateHeader/DateHeader.js +48 -26
  45. package/src/dateLookup/dateHeader/DateHeader.spec.js +37 -0
  46. package/src/dateLookup/dayCalendar/DayCalendar.js +3 -1
  47. package/src/dateLookup/dayCalendar/DayCalendar.spec.js +7 -1
  48. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +7 -3
  49. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +1 -0
  50. package/src/dateLookup/monthCalendar/MonthCalendar.js +3 -1
  51. package/src/dateLookup/monthCalendar/MonthCalendar.spec.js +7 -1
  52. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +4 -5
  53. package/src/dateLookup/tableLink/TableLink.js +24 -3
  54. package/src/dateLookup/tableLink/TableLink.spec.js +60 -4
  55. package/src/dateLookup/yearCalendar/YearCalendar.js +16 -3
  56. package/src/dateLookup/yearCalendar/YearCalendar.spec.js +14 -1
  57. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +4 -5
  58. package/src/i18n/en.json +8 -0
  59. package/src/inputs/SelectInput.story.tsx +14 -9
  60. package/src/main.css +1 -1
  61. package/src/phoneNumberInput/PhoneNumberInput.js +1 -0
  62. package/src/snackbar/Snackbar.js +6 -1
  63. package/src/snackbar/Snackbar.spec.js +1 -3
  64. package/src/tabs/Tabs.js +2 -1
  65. package/src/upload/Upload.js +1 -1
  66. package/src/upload/steps/completeStep/completeStep.js +4 -1
  67. package/src/upload/steps/processingStep/processingStep.js +1 -0
  68. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -1
  69. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +0 -2
  70. package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts.map +0 -1
  71. package/build/types/common/focusBoundary/utils/index.d.ts +0 -3
  72. package/build/types/common/focusBoundary/utils/index.d.ts.map +0 -1
  73. package/build/types/common/focusBoundary/utils/resetFocus.d.ts +0 -2
  74. package/build/types/common/focusBoundary/utils/resetFocus.d.ts.map +0 -1
  75. package/src/common/focusBoundary/FocusBoundary.spec.tsx +0 -66
  76. package/src/common/focusBoundary/__snapshots__/FocusBoundary.spec.tsx.snap +0 -16
  77. package/src/common/focusBoundary/utils/getFocusableElements.js +0 -25
  78. package/src/common/focusBoundary/utils/getFocusableElements.spec.js +0 -51
  79. package/src/common/focusBoundary/utils/index.js +0 -2
  80. package/src/common/focusBoundary/utils/resetFocus.js +0 -23
  81. package/src/common/focusBoundary/utils/resetFocus.spec.js +0 -103
  82. package/src/snackbar/__snapshots__/Snackbar.spec.js.snap +0 -5
@@ -157,6 +157,7 @@ const PhoneNumberInput = (props) => {
157
157
  <div className={`input-group input-group-${size}`}>
158
158
  <input
159
159
  id={id}
160
+ autoComplete="tel-national"
160
161
  name="phoneNumber"
161
162
  inputMode="numeric"
162
163
  value={internalValue.suffix}
@@ -91,7 +91,12 @@ export class Snackbar extends Component {
91
91
  }}
92
92
  unmountOnExit
93
93
  >
94
- <Body ref={this.bodyRef} as="span" className={`snackbar__text snackbar__text--${theme}`}>
94
+ <Body
95
+ ref={this.bodyRef}
96
+ as="span"
97
+ className={`snackbar__text snackbar__text--${theme}`}
98
+ aria-live="polite"
99
+ >
95
100
  {text}
96
101
  {action ? (
97
102
  <ActionButton className="snackbar__text__action" onClick={action.onClick}>
@@ -71,8 +71,6 @@ describe('Snackbar', () => {
71
71
  const snackbarWithNode = () => componentWithNode.find(Snackbar);
72
72
  componentWithNode.find('.button-trigger').simulate('click');
73
73
  expect(snackbarWithNode().text()).toContain('test');
74
-
75
- expect(snackbarWithNode().html()).toMatchSnapshot();
76
74
  });
77
75
 
78
76
  it('displays a single snack for the given duration with the given text', async () => {
@@ -107,6 +105,6 @@ describe('Snackbar', () => {
107
105
  );
108
106
  const snackbarWithNode = () => componentWithNode.find(Snackbar);
109
107
  componentWithNode.find('.button-trigger').simulate('click');
110
- expect(snackbarWithNode().html()).toMatchSnapshot();
108
+ expect(snackbarWithNode().prop('theme')).toBe('dark');
111
109
  });
112
110
  });
package/src/tabs/Tabs.js CHANGED
@@ -488,7 +488,8 @@ class Tabs extends Component {
488
488
  })}
489
489
  {translateLineX ? (
490
490
  <li
491
- className={classNames('tabs__line')}
491
+ role="none"
492
+ className="tabs__line"
492
493
  style={{
493
494
  width: this.getTabLineWidth(),
494
495
  transform: isRTL
@@ -344,7 +344,7 @@ class Upload extends Component {
344
344
  />
345
345
  )}
346
346
  {!isProcessing && (
347
- <div className="droppable-dropping-card droppable-card">
347
+ <div className="droppable-dropping-card droppable-card" aria-live="polite">
348
348
  <div className="droppable-card-content">
349
349
  <div className="circle circle-sm text-primary">
350
350
  <PlusIcon size="16" />
@@ -26,7 +26,10 @@ const CompleteStep = (props) => {
26
26
  return (
27
27
  <div className="droppable-complete-card droppable-card" aria-hidden={!isComplete}>
28
28
  <div className="droppable-card-content">
29
- <div className="droppable-card-content d-flex flex-column align-items-center">
29
+ <div
30
+ className="droppable-card-content d-flex flex-column align-items-center"
31
+ aria-live="polite"
32
+ >
30
33
  {isError ? (
31
34
  <>
32
35
  {isModern ? (
@@ -45,6 +45,7 @@ const ProcessingStep = (props) => {
45
45
  'm-b-2': isModern,
46
46
  })}
47
47
  type={Typography.TITLE_BODY}
48
+ aria-live="polite"
48
49
  >
49
50
  {psProcessingText}
50
51
  </Title>
@@ -134,7 +134,7 @@ const UploadItem = ({
134
134
  singleFileUpload={singleFileUpload}
135
135
  onDownload={onDownloadFile}
136
136
  >
137
- <div className="np-upload-button">
137
+ <div className="np-upload-button" aria-live="polite">
138
138
  <div className="media">
139
139
  <div className="np-upload-icon media-left">{getIcon()}</div>
140
140
  <div className="media-body text-xs-left" data-testid={TEST_IDS.mediaBody}>
@@ -1,2 +0,0 @@
1
- export function getFocusableElements(focusBoundaryContainer: Node): object;
2
- //# sourceMappingURL=getFocusableElements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFocusableElements.d.ts","sourceRoot":"","sources":["../../../../../src/common/focusBoundary/utils/getFocusableElements.js"],"names":[],"mappings":"AAOO,6DAJI,IAAI,GACF,MAAM,CAoBlB"}
@@ -1,3 +0,0 @@
1
- export { getFocusableElements } from "./getFocusableElements";
2
- export { resetFocus } from "./resetFocus";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/focusBoundary/utils/index.js"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export function resetFocus({ focusableEls: { first, last }, event }: object): void;
2
- //# sourceMappingURL=resetFocus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resetFocus.d.ts","sourceRoot":"","sources":["../../../../../src/common/focusBoundary/utils/resetFocus.js"],"names":[],"mappings":"AAOO,qEAJI,MAAM,QAmBhB"}
@@ -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>"`;