@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.
- package/build/index.js +20 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +20 -15
- package/build/index.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/stepper/deviceDetection.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/alert/Alert.tsx +2 -1
- package/src/avatar/colors/colors.ts +1 -1
- package/src/body/Body.spec.tsx +1 -1
- package/src/body/Body.story.tsx +8 -8
- package/src/checkbox/Checkbox.js +1 -1
- package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
- package/src/common/Option/Option.tsx +1 -1
- package/src/common/deviceDetection/deviceDetection.js +1 -1
- package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
- package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
- package/src/decision/Decision.spec.js +0 -1
- package/src/dimmer/Dimmer.tsx +6 -2
- package/src/inlineAlert/InlineAlert.story.tsx +8 -7
- package/src/inputs/SelectInput.tsx +1 -0
- package/src/link/Link.story.tsx +16 -16
- package/src/loader/Loader.tsx +0 -1
- package/src/logo/Logo.js +2 -2
- package/src/moneyInput/MoneyInput.story.tsx +3 -3
- package/src/nudge/Nudge.spec.tsx +5 -5
- package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/promoCard/PromoCard.tsx +1 -1
- package/src/radioGroup/RadioGroup.spec.js +1 -1
- package/src/section/Section.story.tsx +2 -1
- package/src/segmentedControl/SegmentedControl.spec.tsx +2 -2
- package/src/select/Select.js +2 -3
- package/src/stepper/deviceDetection.js +1 -2
- package/src/stepper/deviceDetection.spec.js +8 -3
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/story-config.ts +1 -1
- package/src/title/Title.spec.tsx +1 -1
- package/src/typeahead/Typeahead.spec.js +4 -2
- package/src/upload/Upload.spec.js +8 -4
- 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, '
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(navigator, 'userAgent', {
|
|
6
|
+
value: userAgent,
|
|
7
|
+
configurable: true,
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
function fakeMaxTouchPoints(maxTouchPoints) {
|
|
10
|
-
|
|
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 :(
|
package/src/test-utils/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
};
|
package/src/title/Title.spec.tsx
CHANGED
|
@@ -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-
|
|
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) =>
|
|
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:
|
|
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(
|
|
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(
|
|
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(
|
|
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', {
|