@transferwise/components 0.0.0-experimental-3fa5a2b → 0.0.0-experimental-47ae02a
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 +170 -193
- package/build/index.js.map +1 -1
- package/build/index.mjs +163 -186
- package/build/index.mjs.map +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/common/hooks/useMedia.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +5 -6
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -11
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/drawer/Drawer.d.ts +4 -4
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +2 -1
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +2 -2
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +36 -19
- package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
- package/build/types/processIndicator/index.d.ts +2 -2
- package/build/types/processIndicator/index.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +2 -1
- package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +14 -14
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/package.json +7 -11
- package/src/accordion/AccordionItem/AccordionItem.tsx +2 -4
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -3
- package/src/button/Button.tsx +1 -1
- package/src/common/hooks/useConditionalListener/useConditionalListener.spec.js +1 -1
- package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +3 -3
- package/src/common/hooks/useMedia.spec.ts +1 -1
- package/src/common/hooks/useMedia.ts +1 -2
- package/src/common/panel/Panel.tsx +90 -92
- package/src/common/responsivePanel/ResponsivePanel.tsx +34 -38
- package/src/dateLookup/DateLookup.rtl.spec.tsx +181 -5
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +171 -124
- package/src/dateLookup/DateLookup.tsx +9 -14
- package/src/drawer/Drawer.js +3 -3
- package/src/field/Field.tsx +3 -3
- package/src/index.ts +3 -2
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +2 -1
- package/src/inputs/SelectInput.story.tsx +1 -0
- package/src/inputs/SelectInput.tsx +10 -2
- package/src/inputs/contexts.tsx +4 -4
- package/src/modal/Modal.tsx +1 -2
- package/src/processIndicator/ProcessIndicator.rtl.spec.tsx +45 -0
- package/src/processIndicator/ProcessIndicator.tsx +110 -0
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -1
- package/src/snackbar/Snackbar.spec.js +4 -1
- package/src/tabs/Tabs.spec.js +46 -27
- package/src/test-utils/index.js +5 -7
- package/src/test-utils/jest.setup.js +9 -3
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +2 -1
- package/src/tooltip/Tooltip.tsx +44 -46
- package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +2 -2
- package/src/upload/Upload.spec.js +34 -13
- package/src/uploadInput/UploadInput.spec.tsx +21 -23
- package/src/uploadInput/uploadItem/UploadItem.tsx +1 -3
- package/src/utilities/logActionRequired.js +1 -1
- package/src/withDisplayFormat/WithDisplayFormat.spec.js +63 -32
- package/src/withDisplayFormat/WithDisplayFormat.tsx +28 -28
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -180
- package/src/processIndicator/ProcessIndicator.js +0 -117
- package/src/processIndicator/ProcessIndicator.spec.js +0 -101
- /package/src/processIndicator/{index.js → index.ts} +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Component } from 'react';
|
|
4
|
-
|
|
5
|
-
import { Status, Size } from '../common';
|
|
6
|
-
|
|
7
|
-
const radius = { xxs: 6, xs: 11, sm: 22, xl: 61 };
|
|
8
|
-
export const ANIMATION_DURATION_IN_MS = 1500;
|
|
9
|
-
|
|
10
|
-
class ProcessIndicator extends Component {
|
|
11
|
-
constructor(props) {
|
|
12
|
-
super(props);
|
|
13
|
-
this.state = {
|
|
14
|
-
status: props.status,
|
|
15
|
-
size: props.size,
|
|
16
|
-
};
|
|
17
|
-
this.interval = null;
|
|
18
|
-
this.timeout = null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create interval for animation duration (1500ms)
|
|
23
|
-
* Update state only at the end of every interval
|
|
24
|
-
* (end of animation loop) if props changed before end of animation
|
|
25
|
-
*/
|
|
26
|
-
componentDidMount() {
|
|
27
|
-
this.interval = setInterval(() => {
|
|
28
|
-
const statusFromState = this.state.status;
|
|
29
|
-
const sizeFromState = this.state.size;
|
|
30
|
-
|
|
31
|
-
const statusFromProps = this.props.status;
|
|
32
|
-
const sizeFromProps = this.props.size;
|
|
33
|
-
|
|
34
|
-
if (statusFromState !== statusFromProps) {
|
|
35
|
-
this.setState({ status: statusFromProps }, this.runCallBack(statusFromProps));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (sizeFromState !== sizeFromProps) {
|
|
39
|
-
this.setState({ size: sizeFromProps });
|
|
40
|
-
}
|
|
41
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Only trigger render if comopnent's state got
|
|
46
|
-
* updated from interval callback
|
|
47
|
-
*
|
|
48
|
-
* @param nextProps
|
|
49
|
-
* @param nextState
|
|
50
|
-
*/
|
|
51
|
-
shouldComponentUpdate(nextProps, nextState) {
|
|
52
|
-
const isSameStatus = nextProps.status === nextState.status;
|
|
53
|
-
const isSameSize = nextProps.size === nextState.size;
|
|
54
|
-
|
|
55
|
-
return isSameStatus && isSameSize;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Clear interval before destroying component
|
|
59
|
-
componentWillUnmount() {
|
|
60
|
-
clearInterval(this.interval);
|
|
61
|
-
clearTimeout(this.timeout);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
runCallBack = (statusFromProps) => {
|
|
65
|
-
const { onAnimationCompleted } = this.props;
|
|
66
|
-
if (onAnimationCompleted) {
|
|
67
|
-
this.timeouts = setTimeout(() => {
|
|
68
|
-
onAnimationCompleted(statusFromProps);
|
|
69
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
render() {
|
|
74
|
-
const { className, 'data-testid': dataTestId } = this.props;
|
|
75
|
-
const { size, status } = this.state;
|
|
76
|
-
const classes = classNames(`process process-${size}`, className, {
|
|
77
|
-
[`process-danger`]: status === Status.FAILED,
|
|
78
|
-
[`process-stopped`]: status === Status.HIDDEN,
|
|
79
|
-
[`process-success`]: status === Status.SUCCEEDED,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<span className={classes} data-testid={dataTestId}>
|
|
84
|
-
<span className="process-icon-container">
|
|
85
|
-
<span className="process-icon-horizontal" />
|
|
86
|
-
<span className="process-icon-vertical" />
|
|
87
|
-
</span>
|
|
88
|
-
<svg xmlns="http://www.w3.org/2000/svg">
|
|
89
|
-
<circle
|
|
90
|
-
className="process-circle"
|
|
91
|
-
cx="50%"
|
|
92
|
-
cy="50%"
|
|
93
|
-
r={radius[this.state.size]}
|
|
94
|
-
fillOpacity="0.0"
|
|
95
|
-
/>
|
|
96
|
-
</svg>
|
|
97
|
-
</span>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
ProcessIndicator.propTypes = {
|
|
102
|
-
status: PropTypes.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
|
|
103
|
-
size: PropTypes.oneOf(['xxs', 'xs', 'sm', 'xl']),
|
|
104
|
-
onAnimationCompleted: PropTypes.func,
|
|
105
|
-
className: PropTypes.string,
|
|
106
|
-
'data-testid': PropTypes.string,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
ProcessIndicator.defaultProps = {
|
|
110
|
-
status: Status.PROCESSING,
|
|
111
|
-
size: Size.SMALL,
|
|
112
|
-
onAnimationCompleted: null,
|
|
113
|
-
className: undefined,
|
|
114
|
-
'data-testid': null,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export default ProcessIndicator;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { mount } from 'enzyme';
|
|
2
|
-
|
|
3
|
-
import { Status, Size } from '../common';
|
|
4
|
-
|
|
5
|
-
import ProcessIndicator from '.';
|
|
6
|
-
|
|
7
|
-
describe('processIndicator', () => {
|
|
8
|
-
let wrapper;
|
|
9
|
-
const ANIMATION_DURATION = 1500;
|
|
10
|
-
const props = {
|
|
11
|
-
status: Status.PROCESSING,
|
|
12
|
-
size: Size.Small,
|
|
13
|
-
onAnimationCompleted: jest.fn(),
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.useFakeTimers();
|
|
18
|
-
|
|
19
|
-
wrapper = mount(<ProcessIndicator {...props} />);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
jest.useRealTimers();
|
|
24
|
-
jest.clearAllMocks();
|
|
25
|
-
jest.clearAllTimers();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('has right classes when rendered with provided props', () => {
|
|
29
|
-
expect(wrapper.find('.process')).toHaveLength(1);
|
|
30
|
-
expect(wrapper.find('.process-sm')).toHaveLength(1);
|
|
31
|
-
|
|
32
|
-
expect(wrapper.find('.process-lg')).toHaveLength(0);
|
|
33
|
-
expect(wrapper.find('.process-xs')).toHaveLength(0);
|
|
34
|
-
expect(wrapper.find('.process-danger')).toHaveLength(0);
|
|
35
|
-
expect(wrapper.find('.process-stopped')).toHaveLength(0);
|
|
36
|
-
expect(wrapper.find('.process-success')).toHaveLength(0);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('updates component state with delay on props change to create smooth transition between CSS animations', () => {
|
|
40
|
-
expect(wrapper.state().status).toBe('processing');
|
|
41
|
-
|
|
42
|
-
wrapper.setProps({ status: 'succeeded' });
|
|
43
|
-
expect(wrapper.props().status).toBe('succeeded');
|
|
44
|
-
expect(wrapper.state().status).toBe('processing');
|
|
45
|
-
|
|
46
|
-
jest.advanceTimersByTime(ANIMATION_DURATION);
|
|
47
|
-
wrapper.update();
|
|
48
|
-
|
|
49
|
-
expect(wrapper.state().status).toBe('succeeded');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('updates size classes with delay', () => {
|
|
53
|
-
expect(wrapper.find('.process-sm')).toHaveLength(1);
|
|
54
|
-
wrapper.setProps({ size: 'xl' });
|
|
55
|
-
expect(wrapper.find('.process-xl')).toHaveLength(0);
|
|
56
|
-
|
|
57
|
-
jest.advanceTimersByTime(ANIMATION_DURATION);
|
|
58
|
-
wrapper.update();
|
|
59
|
-
|
|
60
|
-
expect(wrapper.find('.process-xs')).toHaveLength(0);
|
|
61
|
-
expect(wrapper.find('.process-sm')).toHaveLength(0);
|
|
62
|
-
expect(wrapper.find('.process-xl')).toHaveLength(1);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('properly updates status classes with delay', () => {
|
|
66
|
-
wrapper.setProps({ status: 'succeeded' });
|
|
67
|
-
expect(wrapper.find('.process-success')).toHaveLength(0);
|
|
68
|
-
jest.advanceTimersByTime(ANIMATION_DURATION);
|
|
69
|
-
wrapper.update();
|
|
70
|
-
expect(wrapper.find('.process-success')).toHaveLength(1);
|
|
71
|
-
expect(wrapper.find('.process-danger')).toHaveLength(0);
|
|
72
|
-
expect(wrapper.find('.process-stopped')).toHaveLength(0);
|
|
73
|
-
|
|
74
|
-
wrapper.setProps({ status: 'failed' });
|
|
75
|
-
expect(wrapper.find('.process-danger')).toHaveLength(0);
|
|
76
|
-
jest.advanceTimersByTime(ANIMATION_DURATION);
|
|
77
|
-
wrapper.update();
|
|
78
|
-
expect(wrapper.find('.process-success')).toHaveLength(0);
|
|
79
|
-
expect(wrapper.find('.process-danger')).toHaveLength(1);
|
|
80
|
-
expect(wrapper.find('.process-stopped')).toHaveLength(0);
|
|
81
|
-
|
|
82
|
-
wrapper.setProps({ status: 'hidden' });
|
|
83
|
-
expect(wrapper.find('.process-stopped')).toHaveLength(0);
|
|
84
|
-
jest.advanceTimersByTime(ANIMATION_DURATION);
|
|
85
|
-
wrapper.update();
|
|
86
|
-
expect(wrapper.find('.process-success')).toHaveLength(0);
|
|
87
|
-
expect(wrapper.find('.process-danger')).toHaveLength(0);
|
|
88
|
-
expect(wrapper.find('.process-stopped')).toHaveLength(1);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('calls onAnimationCompleted with Delay', () => {
|
|
92
|
-
expect(props.onAnimationCompleted).not.toHaveBeenCalled();
|
|
93
|
-
wrapper.setProps({ status: Status.FAILED });
|
|
94
|
-
expect(props.onAnimationCompleted).not.toHaveBeenCalled();
|
|
95
|
-
jest.advanceTimersByTime(ANIMATION_DURATION * 2);
|
|
96
|
-
expect(props.onAnimationCompleted).toHaveBeenCalledWith(Status.FAILED);
|
|
97
|
-
wrapper.setProps({ status: Status.SUCCEEDED });
|
|
98
|
-
jest.advanceTimersByTime(ANIMATION_DURATION * 2);
|
|
99
|
-
expect(props.onAnimationCompleted).toHaveBeenCalledWith(Status.SUCCEEDED);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
File without changes
|