@transferwise/components 46.12.0 → 46.13.0
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.esm.js +18 -6
- package/build/index.esm.js.map +1 -1
- package/build/index.js +18 -6
- package/build/index.js.map +1 -1
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +1 -0
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/drawer/Drawer.js +13 -2
- package/src/drawer/__snapshots__/Drawer.rtl.spec.js.snap +1 -0
- package/src/modal/Modal.tsx +6 -3
- package/src/popover/Popover.js +7 -3
- package/src/popover/Popover.spec.js +16 -8
- package/src/popover/__snapshots__/Popover.spec.js.snap +0 -56
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.js"],"names":[],"mappings":";AAYA;;;;;;;;gCAoCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/modal/Modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/modal/Modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AAG1C,OAAO,EAGL,WAAW,EACX,cAAc,EAEd,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EAEf,MAAM,WAAW,CAAC;AASnB,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF,QAAA,MAAM,KAAK,wHAYR,UAAU,gCAmHZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/popover/Popover.js"],"names":[],"mappings":";AAUA
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/popover/Popover.js"],"names":[],"mappings":";AAUA;;;;;;;gCA8CC"}
|
package/package.json
CHANGED
package/src/drawer/Drawer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useId } from '@radix-ui/react-id';
|
|
1
2
|
import classNames from 'classnames';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
|
|
@@ -16,17 +17,27 @@ const Drawer = ({ children, className, footerContent, headerTitle, onClose, open
|
|
|
16
17
|
);
|
|
17
18
|
|
|
18
19
|
const { isMobile } = useLayout();
|
|
20
|
+
const titleId = useId();
|
|
19
21
|
|
|
20
22
|
return (
|
|
21
23
|
<Dimmer open={open} onClose={onClose}>
|
|
22
24
|
<SlidingPanel open={open} position={isMobile ? Position.BOTTOM : position}>
|
|
23
|
-
<div
|
|
25
|
+
<div
|
|
26
|
+
role="dialog"
|
|
27
|
+
aria-modal
|
|
28
|
+
aria-labelledby={headerTitle ? titleId : undefined}
|
|
29
|
+
className={classNames('np-drawer', className)}
|
|
30
|
+
>
|
|
24
31
|
<div
|
|
25
32
|
className={classNames('np-drawer-header', {
|
|
26
33
|
'np-drawer-header--withborder': headerTitle,
|
|
27
34
|
})}
|
|
28
35
|
>
|
|
29
|
-
{headerTitle &&
|
|
36
|
+
{headerTitle && (
|
|
37
|
+
<Title id={titleId} type={Typography.TITLE_BODY}>
|
|
38
|
+
{headerTitle}
|
|
39
|
+
</Title>
|
|
40
|
+
)}
|
|
30
41
|
<CloseButton onClick={onClose} />
|
|
31
42
|
</div>
|
|
32
43
|
{children && <div className={classNames('np-drawer-content')}>{children}</div>}
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useId } from '@radix-ui/react-id';
|
|
1
2
|
import classNames from 'classnames';
|
|
2
3
|
import { ReactNode, useRef } from 'react';
|
|
3
4
|
import { CSSTransition } from 'react-transition-group';
|
|
@@ -59,6 +60,7 @@ const Modal = ({
|
|
|
59
60
|
const noDivider = checkSpecialClasses('no-divider');
|
|
60
61
|
|
|
61
62
|
const contentReference = useRef<HTMLDivElement>(null);
|
|
63
|
+
const titleId = useId();
|
|
62
64
|
|
|
63
65
|
return !isMedium ? (
|
|
64
66
|
<Drawer
|
|
@@ -99,11 +101,12 @@ const Modal = ({
|
|
|
99
101
|
{...otherProps}
|
|
100
102
|
>
|
|
101
103
|
<div
|
|
104
|
+
role="dialog"
|
|
105
|
+
aria-modal
|
|
106
|
+
aria-labelledby={titleId}
|
|
102
107
|
className={classNames('tw-modal-dialog', 'd-flex', {
|
|
103
108
|
[`tw-modal-${size}`]: size,
|
|
104
109
|
})}
|
|
105
|
-
aria-modal
|
|
106
|
-
role="dialog"
|
|
107
110
|
>
|
|
108
111
|
<div
|
|
109
112
|
className={classNames(
|
|
@@ -129,7 +132,7 @@ const Modal = ({
|
|
|
129
132
|
},
|
|
130
133
|
)}
|
|
131
134
|
>
|
|
132
|
-
<Title type={Typography.TITLE_BODY} className="tw-modal-title">
|
|
135
|
+
<Title id={titleId} type={Typography.TITLE_BODY} className="tw-modal-title">
|
|
133
136
|
{title}
|
|
134
137
|
</Title>
|
|
135
138
|
<CloseButton onClick={onClose} />
|
package/src/popover/Popover.js
CHANGED
|
@@ -8,13 +8,16 @@ import ResponsivePanel from '../common/responsivePanel';
|
|
|
8
8
|
import Title from '../title';
|
|
9
9
|
import { logActionRequiredIf } from '../utilities';
|
|
10
10
|
|
|
11
|
-
const Popover = ({ children, className, content, preferredPlacement, title }) => {
|
|
11
|
+
const Popover = ({ children, className, content, preferredPlacement, title, onClose }) => {
|
|
12
12
|
logActionRequired({ preferredPlacement });
|
|
13
13
|
const anchorReference = useRef(null);
|
|
14
14
|
const [open, setOpen] = useState(false);
|
|
15
15
|
const { isModern } = useTheme();
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const handleOnClose = () => {
|
|
18
|
+
setOpen(false);
|
|
19
|
+
onClose?.();
|
|
20
|
+
};
|
|
18
21
|
|
|
19
22
|
return (
|
|
20
23
|
<span className={classnames('np-popover', className)}>
|
|
@@ -34,7 +37,7 @@ const Popover = ({ children, className, content, preferredPlacement, title }) =>
|
|
|
34
37
|
position={deprecatedPlacements[preferredPlacement] || preferredPlacement}
|
|
35
38
|
arrow
|
|
36
39
|
className="np-popover__container"
|
|
37
|
-
onClose={
|
|
40
|
+
onClose={handleOnClose}
|
|
38
41
|
>
|
|
39
42
|
<div
|
|
40
43
|
className={isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content'}
|
|
@@ -84,6 +87,7 @@ Popover.propTypes = {
|
|
|
84
87
|
'bottom-right',
|
|
85
88
|
'bottom-left',
|
|
86
89
|
]),
|
|
90
|
+
onClose: PropTypes.func,
|
|
87
91
|
title: PropTypes.node,
|
|
88
92
|
};
|
|
89
93
|
|
|
@@ -10,14 +10,6 @@ jest.mock('react-transition-group', () => ({
|
|
|
10
10
|
CSSTransition: (props) => (props.in ? props.children : null),
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
|
-
jest.mock(
|
|
14
|
-
'../dimmer',
|
|
15
|
-
() =>
|
|
16
|
-
function ({ open, children }) {
|
|
17
|
-
return open ? <div className="dimmer">{children}</div> : null;
|
|
18
|
-
},
|
|
19
|
-
);
|
|
20
|
-
|
|
21
13
|
describe('Popover', () => {
|
|
22
14
|
const props = {
|
|
23
15
|
arrow: true,
|
|
@@ -114,7 +106,23 @@ describe('Popover', () => {
|
|
|
114
106
|
});
|
|
115
107
|
});
|
|
116
108
|
|
|
109
|
+
it('onClose fires when close Popover', async () => {
|
|
110
|
+
const handleOnClose = jest.fn();
|
|
111
|
+
render(
|
|
112
|
+
<Popover {...props} onClose={handleOnClose}>
|
|
113
|
+
<button type="button">Open</button>
|
|
114
|
+
</Popover>,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(handleOnClose).not.toHaveBeenCalled();
|
|
118
|
+
userEvent.click(screen.getByText('Open'));
|
|
119
|
+
await waitForPanel();
|
|
120
|
+
userEvent.click(getDimmer());
|
|
121
|
+
expect(handleOnClose).toHaveBeenCalledTimes(1);
|
|
122
|
+
});
|
|
123
|
+
|
|
117
124
|
const waitForPanel = async () => screen.findByText('content');
|
|
125
|
+
const getDimmer = () => document.querySelector('.dimmer');
|
|
118
126
|
const getPanel = () => document.querySelector('.np-panel');
|
|
119
127
|
const getBottomSheet = () => document.querySelector('.np-bottom-sheet');
|
|
120
128
|
const getTitle = () => screen.queryByText('title');
|
|
@@ -45,62 +45,6 @@ exports[`Popover on mobile renders when is open 1`] = `
|
|
|
45
45
|
Open
|
|
46
46
|
</button>
|
|
47
47
|
</span>
|
|
48
|
-
<div
|
|
49
|
-
class="dimmer"
|
|
50
|
-
>
|
|
51
|
-
<div
|
|
52
|
-
class="sliding-panel sliding-panel--open-bottom np-bottom-sheet np-popover__container"
|
|
53
|
-
>
|
|
54
|
-
<div
|
|
55
|
-
class="np-bottom-sheet--top-bar"
|
|
56
|
-
>
|
|
57
|
-
<div
|
|
58
|
-
class="np-bottom-sheet--handler"
|
|
59
|
-
/>
|
|
60
|
-
<button
|
|
61
|
-
aria-label="Close"
|
|
62
|
-
class="np-close-button close btn-link text-no-decoration sr-only np-bottom-sheet--close-btn"
|
|
63
|
-
type="button"
|
|
64
|
-
>
|
|
65
|
-
<span
|
|
66
|
-
aria-hidden="true"
|
|
67
|
-
class="tw-icon tw-icon-cross "
|
|
68
|
-
data-testid="cross-icon"
|
|
69
|
-
role="presentation"
|
|
70
|
-
>
|
|
71
|
-
<svg
|
|
72
|
-
fill="currentColor"
|
|
73
|
-
focusable="false"
|
|
74
|
-
height="16"
|
|
75
|
-
viewBox="0 0 24 24"
|
|
76
|
-
width="16"
|
|
77
|
-
>
|
|
78
|
-
<path
|
|
79
|
-
d="m19.629 5.915-1.2-1.2-6.257 6.257-6.258-6.257-1.2 1.2 6.258 6.257-6.258 6.257 1.2 1.2 6.258-6.257 6.257 6.257 1.2-1.2-6.258-6.257 6.258-6.257Z"
|
|
80
|
-
/>
|
|
81
|
-
</svg>
|
|
82
|
-
</span>
|
|
83
|
-
</button>
|
|
84
|
-
</div>
|
|
85
|
-
<div
|
|
86
|
-
class="np-bottom-sheet--content"
|
|
87
|
-
style="max-height: calc(768px - 64px - 32px);"
|
|
88
|
-
>
|
|
89
|
-
<div
|
|
90
|
-
aria-hidden="false"
|
|
91
|
-
class="np-popover__content"
|
|
92
|
-
role="dialog"
|
|
93
|
-
>
|
|
94
|
-
<h4
|
|
95
|
-
class="np-text-title-body m-b-1"
|
|
96
|
-
>
|
|
97
|
-
title
|
|
98
|
-
</h4>
|
|
99
|
-
content
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
48
|
</span>
|
|
105
49
|
</div>
|
|
106
50
|
`;
|