@transferwise/components 0.0.0-experimental-3759445 → 0.0.0-experimental-cc11279

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 (50) hide show
  1. package/build/index.js +20 -15
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +20 -15
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/alert/Alert.d.ts.map +1 -1
  6. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  7. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  8. package/build/types/loader/Loader.d.ts.map +1 -1
  9. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  10. package/build/types/popover/Popover.d.ts.map +1 -1
  11. package/build/types/select/Select.d.ts.map +1 -1
  12. package/build/types/stepper/deviceDetection.d.ts.map +1 -1
  13. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  14. package/package.json +3 -3
  15. package/src/accordion/Accordion.story.tsx +1 -1
  16. package/src/alert/Alert.tsx +2 -1
  17. package/src/avatar/colors/colors.ts +1 -1
  18. package/src/body/Body.spec.tsx +1 -1
  19. package/src/body/Body.story.tsx +8 -8
  20. package/src/checkbox/Checkbox.js +1 -1
  21. package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
  22. package/src/common/Option/Option.tsx +1 -1
  23. package/src/common/deviceDetection/deviceDetection.js +1 -1
  24. package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
  25. package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
  26. package/src/decision/Decision.spec.js +0 -1
  27. package/src/dimmer/Dimmer.tsx +6 -2
  28. package/src/inlineAlert/InlineAlert.story.tsx +8 -7
  29. package/src/inputs/SelectInput.tsx +1 -0
  30. package/src/link/Link.story.tsx +16 -16
  31. package/src/loader/Loader.tsx +0 -1
  32. package/src/logo/Logo.js +2 -2
  33. package/src/moneyInput/MoneyInput.story.tsx +3 -3
  34. package/src/nudge/Nudge.spec.tsx +5 -5
  35. package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
  36. package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
  37. package/src/popover/Popover.tsx +2 -1
  38. package/src/promoCard/PromoCard.tsx +1 -1
  39. package/src/radioGroup/RadioGroup.spec.js +1 -1
  40. package/src/section/Section.story.tsx +2 -1
  41. package/src/segmentedControl/SegmentedControl.spec.tsx +2 -2
  42. package/src/select/Select.js +2 -3
  43. package/src/stepper/deviceDetection.js +1 -2
  44. package/src/stepper/deviceDetection.spec.js +8 -3
  45. package/src/test-utils/index.js +1 -1
  46. package/src/test-utils/story-config.ts +1 -1
  47. package/src/title/Title.spec.tsx +1 -1
  48. package/src/typeahead/Typeahead.spec.js +4 -2
  49. package/src/upload/Upload.spec.js +8 -4
  50. package/src/uploadInput/uploadButton/UploadButton.tsx +1 -0
@@ -1,6 +1,5 @@
1
1
  function supportsTouchEvents() {
2
2
  const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
3
- // eslint-disable-next-line compat/compat
4
3
  const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
5
4
  const documentTouchIsDefined =
6
5
  typeof window !== 'undefined' &&
@@ -21,7 +20,7 @@ function userAgentSuggestsTouchDevice() {
21
20
  'bada',
22
21
  ];
23
22
  const matchString = sampleTouchDevices.map((device) => `(${device})`).join('|');
24
- const regex = new RegExp(matchString, 'ig');
23
+ const regex = new RegExp(matchString, 'gi');
25
24
  return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
26
25
  }
27
26
  // Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
@@ -2,12 +2,17 @@ import { isTouchDevice } from './deviceDetection';
2
2
 
3
3
  describe('Device detection', () => {
4
4
  function fakeUserAgent(userAgent) {
5
- navigator.__defineGetter__('userAgent', () => userAgent);
6
- // need to use this instead of defineProperty, as it's blocked from overriding
5
+ Object.defineProperty(navigator, 'userAgent', {
6
+ value: userAgent,
7
+ configurable: true,
8
+ });
7
9
  }
8
10
 
9
11
  function fakeMaxTouchPoints(maxTouchPoints) {
10
- navigator.__defineGetter__('maxTouchPoints', () => maxTouchPoints);
12
+ Object.defineProperty(navigator, 'maxTouchPoints', {
13
+ value: maxTouchPoints,
14
+ configurable: true,
15
+ });
11
16
  }
12
17
 
13
18
  // We don't test DocumentTouch api as it's basically impossible to test :(
@@ -13,7 +13,7 @@ import en from '../i18n/en.json';
13
13
  */
14
14
  function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {}) {
15
15
  // eslint-disable-next-line react/prop-types
16
- var Wrapper = ({ children }) => {
16
+ const Wrapper = ({ children }) => {
17
17
  return <Provider i18n={{ locale, messages }}>{children}</Provider>;
18
18
  };
19
19
  return render(ui, { wrapper: Wrapper, ...renderOptions });
@@ -30,7 +30,7 @@ interface StoryConfig {
30
30
 
31
31
  const getViewportWidth = (viewport: (typeof viewports)[keyof typeof viewports]) => {
32
32
  if (viewport.styles && typeof viewport.styles === 'object') {
33
- return parseInt(viewport.styles.width);
33
+ return Number.parseInt(viewport.styles.width, 10);
34
34
  }
35
35
  throw new Error('Unknown viewport styles');
36
36
  };
@@ -34,7 +34,7 @@ describe('Title', () => {
34
34
 
35
35
  it('handles unsupported typography type', () => {
36
36
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
- // @ts-ignore
37
+ // @ts-expect-error
38
38
  render(<Title type={Typography.BODY_LARGE_BOLD}>Test</Title>);
39
39
  const copy = screen.getByText('Test');
40
40
  expect(copy).toBeInTheDocument();
@@ -314,7 +314,9 @@ describe('Typeahead', () => {
314
314
  let selectedOption;
315
315
 
316
316
  component.setProps({
317
- onChange: (selections) => (selectedOption = selections[0]),
317
+ onChange: (selections) => {
318
+ selectedOption = selections[0];
319
+ },
318
320
  options: options,
319
321
  });
320
322
 
@@ -340,7 +342,7 @@ describe('Typeahead', () => {
340
342
  it('renders all options', () => {
341
343
  const options = option().map((optNode) => optNode.text());
342
344
  expect(options).toHaveLength(props.options.length);
343
- expect(options.every((label, i) => label === props.options[i].label));
345
+ expect(options.every((label, i) => label === props.options[i].label)).toBe(true);
344
346
  });
345
347
 
346
348
  it('does not render new option if showNewEntry is false', () => {
@@ -8,7 +8,7 @@ import Upload from '.';
8
8
 
9
9
  jest.useFakeTimers();
10
10
  jest.mock('./utils/postData', () => ({
11
- postData: () => new Promise((resolve) => resolve('ServerResponse')),
11
+ postData: async () => 'ServerResponse',
12
12
  }));
13
13
 
14
14
  jest.mock('./utils/asyncFileRead');
@@ -88,7 +88,7 @@ describe('Upload', () => {
88
88
  let component;
89
89
  beforeEach(() => {
90
90
  component = shallow(<Upload {...props} />).dive();
91
- asyncFileRead.mockImplementation(() => new Promise((resolve) => resolve('a value')));
91
+ asyncFileRead.mockImplementation(async () => 'a value');
92
92
  });
93
93
 
94
94
  afterEach(() => {
@@ -183,7 +183,9 @@ describe('Upload', () => {
183
183
  });
184
184
 
185
185
  it('step ProcessingStep is called with error props', async () => {
186
- asyncFileRead.mockImplementation(() => new Promise((resolve, reject) => reject('An error')));
186
+ asyncFileRead.mockImplementation(async () => {
187
+ throw 'An error';
188
+ });
187
189
 
188
190
  await component.instance().fileDropped(TEST_FILE);
189
191
  jest.advanceTimersByTime(props.animationDelay);
@@ -230,7 +232,9 @@ describe('Upload', () => {
230
232
  it('step CompleteStep is called with error props', async () => {
231
233
  component = mount(<Upload {...props} />);
232
234
  const upload = component.children();
233
- asyncFileRead.mockImplementation(() => new Promise((resolve, reject) => reject('An error')));
235
+ asyncFileRead.mockImplementation(async () => {
236
+ throw 'An error';
237
+ });
234
238
 
235
239
  await upload.instance().fileDropped(TEST_FILE);
236
240
  jest.advanceTimersByTime(props.animationDelay + ANIMATION_DELAY);
@@ -225,6 +225,7 @@ const UploadButton = ({
225
225
  data-testid={TEST_IDS.uploadInput}
226
226
  onChange={filesSelected}
227
227
  />
228
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
228
229
  <label
229
230
  htmlFor={id}
230
231
  className={classNames('btn', 'np-upload-accent', 'np-upload-button', {