@transferwise/components 0.0.0-experimental-c9cdfe3 → 0.0.0-experimental-79c0fba
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/README.md +1 -1
- package/build/index.esm.js +49 -75
- package/build/index.esm.js.map +1 -1
- package/build/index.js +50 -76
- package/build/index.js.map +1 -1
- package/build/mocks.esm.js +33 -27
- package/build/mocks.esm.js.map +1 -1
- package/build/mocks.js +33 -27
- package/build/mocks.js.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts +2 -2
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/slidingPanel/SlidingPanel.d.ts +12 -17
- package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
- package/build/types/slidingPanel/index.d.ts +2 -1
- package/build/types/slidingPanel/index.d.ts.map +1 -1
- package/build/types/sticky/Sticky.d.ts +9 -14
- package/build/types/sticky/Sticky.d.ts.map +1 -1
- package/build/types/sticky/index.d.ts +2 -1
- package/build/types/sticky/index.d.ts.map +1 -1
- package/package.json +17 -1
- package/src/circularButton/CircularButton.tsx +2 -2
- package/src/common/bottomSheet/BottomSheet.tsx +47 -41
- package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +37 -33
- package/src/index.ts +2 -0
- package/src/select/Select.spec.js +1 -1
- package/src/slidingPanel/SlidingPanel.spec.js +9 -19
- package/src/slidingPanel/SlidingPanel.tsx +62 -0
- package/src/slidingPanel/index.ts +2 -0
- package/src/sticky/Sticky.spec.js +0 -1
- package/src/sticky/{Sticky.story.js → Sticky.story.tsx} +2 -3
- package/src/sticky/Sticky.tsx +16 -0
- package/src/sticky/index.ts +2 -0
- package/build/mocks.d.ts +0 -9
- package/build/mocks.d.ts.map +0 -1
- package/src/slidingPanel/SlidingPanel.js +0 -73
- package/src/slidingPanel/index.js +0 -1
- package/src/sticky/Sticky.js +0 -23
- package/src/sticky/index.js +0 -1
- /package/src/slidingPanel/{SlidingPanel.story.js → SlidingPanel.story.tsx} +0 -0
|
@@ -24,17 +24,7 @@ describe('SlidingPanel', () => {
|
|
|
24
24
|
|
|
25
25
|
expect(cssTransition()).toHaveLength(1);
|
|
26
26
|
|
|
27
|
-
expect(cssTransition().props()).
|
|
28
|
-
in: true,
|
|
29
|
-
appear: true,
|
|
30
|
-
timeout: {
|
|
31
|
-
enter: 0,
|
|
32
|
-
exit: EXIT_ANIMATION,
|
|
33
|
-
},
|
|
34
|
-
classNames: 'sliding-panel--open-left sliding-panel',
|
|
35
|
-
unmountOnExit: true,
|
|
36
|
-
});
|
|
37
|
-
expect(cssTransition().props().children.props).toStrictEqual({
|
|
27
|
+
expect(cssTransition().props()).toStrictEqual({
|
|
38
28
|
className: 'sliding-panel sliding-panel--open-left',
|
|
39
29
|
children: null,
|
|
40
30
|
});
|
|
@@ -42,24 +32,24 @@ describe('SlidingPanel', () => {
|
|
|
42
32
|
|
|
43
33
|
it('adds fixed class', () => {
|
|
44
34
|
component = shallow(<SlidingPanel {...props} slidingPanelPositionFixed />);
|
|
45
|
-
expect(cssTransition().prop('
|
|
46
|
-
'sliding-panel--open-left sliding-panel--fixed
|
|
35
|
+
expect(cssTransition().prop('className')).toBe(
|
|
36
|
+
'sliding-panel sliding-panel--open-left sliding-panel--fixed',
|
|
47
37
|
);
|
|
48
38
|
});
|
|
49
39
|
|
|
50
40
|
it('adds border classes if showSlidingPanelBorder is set to true', () => {
|
|
51
41
|
component = shallow(<SlidingPanel {...props} showSlidingPanelBorder />);
|
|
52
|
-
expect(cssTransition().prop('
|
|
53
|
-
'sliding-panel--open-left sliding-panel--border-left
|
|
42
|
+
expect(cssTransition().prop('className')).toBe(
|
|
43
|
+
'sliding-panel sliding-panel--open-left sliding-panel--border-left',
|
|
54
44
|
);
|
|
55
45
|
component = shallow(<SlidingPanel {...props} showSlidingPanelBorder={false} position="left" />);
|
|
56
|
-
expect(cssTransition().prop('
|
|
46
|
+
expect(cssTransition().prop('className')).toBe('sliding-panel sliding-panel--open-left');
|
|
57
47
|
|
|
58
48
|
component = shallow(<SlidingPanel {...props} showSlidingPanelBorder position="top" />);
|
|
59
|
-
expect(cssTransition().prop('
|
|
60
|
-
'sliding-panel--open-top sliding-panel--border-top
|
|
49
|
+
expect(cssTransition().prop('className')).toBe(
|
|
50
|
+
'sliding-panel sliding-panel--open-top sliding-panel--border-top',
|
|
61
51
|
);
|
|
62
52
|
});
|
|
63
53
|
|
|
64
|
-
const cssTransition = () => component.find('
|
|
54
|
+
const cssTransition = () => component.find('div');
|
|
65
55
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { forwardRef, useRef } from 'react';
|
|
3
|
+
import mergeRefs from 'react-merge-refs';
|
|
4
|
+
import { CSSTransition } from 'react-transition-group';
|
|
5
|
+
|
|
6
|
+
import { Position } from '../common';
|
|
7
|
+
|
|
8
|
+
export const EXIT_ANIMATION = 350;
|
|
9
|
+
|
|
10
|
+
export interface SlidingPanelProps
|
|
11
|
+
extends Pick<React.ComponentPropsWithRef<'div'>, 'ref' | 'className' | 'children'> {
|
|
12
|
+
position?: `${Position.TOP | Position.RIGHT | Position.BOTTOM | Position.LEFT}`;
|
|
13
|
+
open: boolean;
|
|
14
|
+
showSlidingPanelBorder?: boolean;
|
|
15
|
+
slidingPanelPositionFixed?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const SlidingPanel = forwardRef(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
position = 'left',
|
|
22
|
+
open,
|
|
23
|
+
showSlidingPanelBorder,
|
|
24
|
+
slidingPanelPositionFixed,
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
...rest
|
|
28
|
+
}: Omit<SlidingPanelProps, 'ref'>,
|
|
29
|
+
reference: React.ForwardedRef<HTMLDivElement>,
|
|
30
|
+
) => {
|
|
31
|
+
const localReference = useRef<HTMLDivElement>(null);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<CSSTransition
|
|
35
|
+
{...rest}
|
|
36
|
+
key={`sliding-panel--open-${position}`}
|
|
37
|
+
nodeRef={localReference}
|
|
38
|
+
in={open}
|
|
39
|
+
// Wait for animation to finish before unmount.
|
|
40
|
+
timeout={{ enter: 0, exit: EXIT_ANIMATION }}
|
|
41
|
+
classNames="sliding-panel"
|
|
42
|
+
appear
|
|
43
|
+
unmountOnExit
|
|
44
|
+
>
|
|
45
|
+
<div
|
|
46
|
+
ref={mergeRefs([reference, localReference])}
|
|
47
|
+
className={classNames(
|
|
48
|
+
'sliding-panel',
|
|
49
|
+
`sliding-panel--open-${position}`,
|
|
50
|
+
showSlidingPanelBorder && `sliding-panel--border-${position}`,
|
|
51
|
+
slidingPanelPositionFixed && 'sliding-panel--fixed',
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
</CSSTransition>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default SlidingPanel;
|
|
@@ -9,10 +9,9 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
export const Basic = () => {
|
|
11
11
|
const open = boolean('open', false);
|
|
12
|
-
const position = select('position', ['top', '
|
|
13
|
-
const fullParentWidth = boolean('fullParentWidth', true);
|
|
12
|
+
const position = select('position', ['top', 'bottom'], 'bottom');
|
|
14
13
|
return (
|
|
15
|
-
<Sticky open={open} position={position}
|
|
14
|
+
<Sticky open={open} position={position}>
|
|
16
15
|
<div className="d-flex justify-content-start align-items-start flex-wrap p-x-4 p-y-4">
|
|
17
16
|
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
|
|
18
17
|
been the industry standard dummy text ever since the 1500s, when an unknown printer took a
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Position } from '../common';
|
|
2
|
+
import SlidingPanel from '../slidingPanel';
|
|
3
|
+
|
|
4
|
+
export interface StickyProps {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
position?: `${Position.TOP | Position.BOTTOM}`;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function Sticky({ open = true, position = 'bottom', children }: StickyProps) {
|
|
11
|
+
return (
|
|
12
|
+
<SlidingPanel open={open} position={position} slidingPanelPositionFixed showSlidingPanelBorder>
|
|
13
|
+
{children}
|
|
14
|
+
</SlidingPanel>
|
|
15
|
+
);
|
|
16
|
+
}
|
package/build/mocks.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type StubGlobal = (name: PropertyKey, value: unknown) => void;
|
|
2
|
-
interface GlobalMockParams {
|
|
3
|
-
fn: <T extends (...args: never[]) => unknown>(implementation?: T) => T;
|
|
4
|
-
stubGlobal?: StubGlobal;
|
|
5
|
-
}
|
|
6
|
-
export declare function mockMatchMedia({ fn, stubGlobal }: GlobalMockParams): void;
|
|
7
|
-
export declare function mockResizeObserver({ fn, stubGlobal }: GlobalMockParams): void;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=mocks.d.ts.map
|
package/build/mocks.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../src/mocks.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,UAAU,gBAAgB;IACxB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACvE,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAWD,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,UAA8B,EAAE,EAAE,gBAAgB,QAkBtF;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,UAA8B,EAAE,EAAE,gBAAgB,QAW1F"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { forwardRef, RefObject, useRef } from 'react';
|
|
4
|
-
import mergeRefs from 'react-merge-refs';
|
|
5
|
-
import { CSSTransition } from 'react-transition-group';
|
|
6
|
-
|
|
7
|
-
export const EXIT_ANIMATION = 350;
|
|
8
|
-
|
|
9
|
-
const SlidingPanel = forwardRef(
|
|
10
|
-
(
|
|
11
|
-
{
|
|
12
|
-
children,
|
|
13
|
-
className,
|
|
14
|
-
open,
|
|
15
|
-
position,
|
|
16
|
-
showSlidingPanelBorder,
|
|
17
|
-
slidingPanelPositionFixed,
|
|
18
|
-
...rest
|
|
19
|
-
},
|
|
20
|
-
reference,
|
|
21
|
-
) => {
|
|
22
|
-
/** @type {RefObject<HTMLDivElement>} */
|
|
23
|
-
const localReference = useRef(null);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<CSSTransition
|
|
27
|
-
{...rest}
|
|
28
|
-
key={`sliding-panel--open-${position}`}
|
|
29
|
-
nodeRef={localReference}
|
|
30
|
-
in={open}
|
|
31
|
-
// Wait for animation to finish before unmount.
|
|
32
|
-
timeout={{ enter: 0, exit: EXIT_ANIMATION }}
|
|
33
|
-
classNames={classNames(
|
|
34
|
-
`sliding-panel--open-${position}`,
|
|
35
|
-
showSlidingPanelBorder && `sliding-panel--border-${position}`,
|
|
36
|
-
{
|
|
37
|
-
'sliding-panel--fixed': slidingPanelPositionFixed,
|
|
38
|
-
},
|
|
39
|
-
'sliding-panel',
|
|
40
|
-
)}
|
|
41
|
-
appear
|
|
42
|
-
unmountOnExit
|
|
43
|
-
>
|
|
44
|
-
<div
|
|
45
|
-
ref={mergeRefs([reference, localReference])}
|
|
46
|
-
className={classNames('sliding-panel', `sliding-panel--open-${position}`, className)}
|
|
47
|
-
>
|
|
48
|
-
{children}
|
|
49
|
-
</div>
|
|
50
|
-
</CSSTransition>
|
|
51
|
-
);
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
SlidingPanel.propTypes = {
|
|
56
|
-
children: PropTypes.node,
|
|
57
|
-
className: PropTypes.string,
|
|
58
|
-
open: PropTypes.bool,
|
|
59
|
-
position: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
60
|
-
showSlidingPanelBorder: PropTypes.bool,
|
|
61
|
-
slidingPanelPositionFixed: PropTypes.bool,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
SlidingPanel.defaultProps = {
|
|
65
|
-
children: null,
|
|
66
|
-
className: undefined,
|
|
67
|
-
open: false,
|
|
68
|
-
position: 'left',
|
|
69
|
-
showSlidingPanelBorder: false,
|
|
70
|
-
slidingPanelPositionFixed: false,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export default SlidingPanel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './SlidingPanel';
|
package/src/sticky/Sticky.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
|
|
3
|
-
import SlidingPanel from '../slidingPanel';
|
|
4
|
-
|
|
5
|
-
const Sticky = ({ open, position, children }) => (
|
|
6
|
-
<SlidingPanel open={open} position={position} slidingPanelPositionFixed showSlidingPanelBorder>
|
|
7
|
-
{children}
|
|
8
|
-
</SlidingPanel>
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
Sticky.propTypes = {
|
|
12
|
-
open: PropTypes.bool,
|
|
13
|
-
position: PropTypes.oneOf(['top', 'bottom']),
|
|
14
|
-
children: PropTypes.node,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
Sticky.defaultProps = {
|
|
18
|
-
open: true,
|
|
19
|
-
position: 'bottom',
|
|
20
|
-
children: null,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default Sticky;
|
package/src/sticky/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Sticky';
|
|
File without changes
|