@openedx/paragon 22.19.0 → 22.20.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/dist/Modal/ModalDialog.d.ts +0 -1
- package/dist/Modal/ModalDialog.js +6 -3
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Modal/messages.d.ts +8 -0
- package/dist/Modal/messages.js +10 -0
- package/dist/Modal/messages.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Modal/ModalDialog.tsx +6 -4
- package/src/Modal/messages.ts +11 -0
- package/src/Modal/tests/AlertModal.test.jsx +48 -39
- package/src/Modal/tests/ModalDialog.test.tsx +57 -50
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useMediaQuery } from 'react-responsive';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
5
6
|
import ModalLayer from './ModalLayer';
|
|
6
7
|
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
7
8
|
import ModalCloseButton from './ModalCloseButton';
|
|
@@ -17,7 +18,7 @@ import ModalDialogHero from './ModalDialogHero';
|
|
|
17
18
|
import Icon from '../Icon';
|
|
18
19
|
import IconButton from '../IconButton';
|
|
19
20
|
import { Close } from '../../icons';
|
|
20
|
-
|
|
21
|
+
import messages from './messages';
|
|
21
22
|
function ModalDialog(_ref) {
|
|
22
23
|
let {
|
|
23
24
|
children,
|
|
@@ -27,7 +28,7 @@ function ModalDialog(_ref) {
|
|
|
27
28
|
size = 'md',
|
|
28
29
|
variant = 'default',
|
|
29
30
|
hasCloseButton = true,
|
|
30
|
-
closeLabel
|
|
31
|
+
closeLabel,
|
|
31
32
|
isFullscreenScroll = false,
|
|
32
33
|
className,
|
|
33
34
|
isFullscreenOnMobile = false,
|
|
@@ -35,6 +36,8 @@ function ModalDialog(_ref) {
|
|
|
35
36
|
zIndex,
|
|
36
37
|
isOverflowVisible
|
|
37
38
|
} = _ref;
|
|
39
|
+
const intl = useIntl();
|
|
40
|
+
const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);
|
|
38
41
|
const isMobile = useMediaQuery({
|
|
39
42
|
query: '(max-width: 767.98px)'
|
|
40
43
|
});
|
|
@@ -60,7 +63,7 @@ function ModalDialog(_ref) {
|
|
|
60
63
|
iconAs: Icon,
|
|
61
64
|
invertColors: variant === 'dark',
|
|
62
65
|
src: Close,
|
|
63
|
-
alt:
|
|
66
|
+
alt: closeButtonText
|
|
64
67
|
})), children));
|
|
65
68
|
}
|
|
66
69
|
ModalDialog.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","
|
|
1
|
+
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","useIntl","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","messages","ModalDialog","_ref","children","title","isOpen","onClose","size","variant","hasCloseButton","closeLabel","isFullscreenScroll","className","isFullscreenOnMobile","isBlocking","zIndex","isOverflowVisible","intl","closeButtonText","formatMessage","isMobile","query","showFullScreen","createElement","role","as","iconAs","invertColors","src","alt","propTypes","node","isRequired","string","func","bool","oneOf","number","Header","Title","Footer","CloseButton","Body","Hero"],"sources":["../../src/Modal/ModalDialog.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useMediaQuery } from 'react-responsive';\nimport { useIntl } from 'react-intl';\nimport ModalLayer from './ModalLayer';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalCloseButton from './ModalCloseButton';\nimport ModalDialogHeader from './ModalDialogHeader';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogTitle from './ModalDialogTitle';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogFooter from './ModalDialogFooter';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogBody from './ModalDialogBody';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ModalDialogHero from './ModalDialogHero';\n\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\nimport { Close } from '../../icons';\nimport messages from './messages';\n\ninterface Props {\n /** Specifies the content of the dialog */\n children: React.ReactNode;\n /** The aria-label of the dialog */\n title: string;\n /** A callback to close the modal dialog, e.g. when Escape is pressed */\n onClose: () => void;\n /** Is the modal dialog open or closed? */\n isOpen?: boolean;\n /** The close 'x' icon button in the top right of the dialog box */\n hasCloseButton?: boolean;\n /** Size determines the maximum width of the dialog box */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'fullscreen';\n /** The visual style of the dialog box */\n variant?: 'default' | 'warning' | 'danger' | 'success' | 'dark';\n /** The label supplied to the close icon button if one is rendered */\n closeLabel?: string;\n /** Specifies class name to append to the base element */\n className?: string;\n /**\n * Determines where a scrollbar should appear if a modal is too large for the\n * viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true\n * the browser window itself receives the scrollbar.\n */\n isFullscreenScroll?: boolean;\n /** To show full screen view on mobile screens */\n isFullscreenOnMobile?: boolean;\n /** Prevent clicking on the backdrop or pressing Esc to close the modal */\n isBlocking?: boolean;\n /** Specifies the z-index of the modal */\n zIndex?: number;\n /** Specifies whether overflow is visible in the modal */\n isOverflowVisible: boolean;\n}\n\nfunction ModalDialog({\n children,\n title,\n isOpen = false,\n onClose,\n size = 'md',\n variant = 'default',\n hasCloseButton = true,\n closeLabel,\n isFullscreenScroll = false,\n className,\n isFullscreenOnMobile = false,\n isBlocking = false,\n zIndex,\n isOverflowVisible,\n}: Props) {\n const intl = useIntl();\n const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);\n const isMobile = useMediaQuery({ query: '(max-width: 767.98px)' });\n const showFullScreen = (isFullscreenOnMobile && isMobile);\n return (\n <ModalLayer isOpen={isOpen} onClose={onClose} isBlocking={isBlocking} zIndex={zIndex}>\n <div\n role=\"dialog\"\n aria-label={title}\n className={classNames(\n 'pgn__modal',\n {\n [`pgn__modal-${showFullScreen ? 'fullscreen' : size}`]: size,\n [`pgn__modal-${variant}`]: variant,\n 'pgn__modal-scroll-fullscreen': isFullscreenScroll,\n 'pgn__modal-visible-overflow': isOverflowVisible,\n },\n className,\n )}\n >\n {hasCloseButton && (\n <div className=\"pgn__modal-close-container\">\n <ModalCloseButton\n as={IconButton}\n iconAs={Icon}\n invertColors={variant === 'dark'}\n src={Close}\n alt={closeButtonText}\n />\n </div>\n )}\n {children}\n </div>\n </ModalLayer>\n );\n}\n\nModalDialog.propTypes = {\n /**\n * Specifies the content of the dialog\n */\n children: PropTypes.node.isRequired,\n /**\n * The aria-label of the dialog\n */\n title: PropTypes.string.isRequired,\n /**\n * A callback to close the modal dialog\n */\n onClose: PropTypes.func.isRequired,\n /**\n * Is the modal dialog open or closed\n */\n isOpen: PropTypes.bool,\n /**\n * The close 'x' icon button in the top right of the dialog box\n */\n hasCloseButton: PropTypes.bool,\n /**\n * Sizes determine the maximum width of the dialog box\n */\n size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl', 'fullscreen']),\n /**\n * The visual style of the dialog box\n */\n variant: PropTypes.oneOf(['default', 'warning', 'danger', 'success', 'dark']),\n /**\n * The label supplied to the close icon button if one is rendered\n */\n closeLabel: PropTypes.string,\n /**\n * Specifies class name to append to the base element\n */\n className: PropTypes.string,\n /**\n * Determines where a scrollbar should appear if a modal is too large for the\n * viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true\n * the browser window itself receives the scrollbar.\n */\n isFullscreenScroll: PropTypes.bool,\n /**\n * To show full screen view on mobile screens\n */\n isFullscreenOnMobile: PropTypes.bool,\n /**\n * Prevent clicking on the backdrop or pressing Esc to close the modal\n */\n isBlocking: PropTypes.bool,\n /**\n * Specifies the z-index of the modal\n */\n zIndex: PropTypes.number,\n /** Specifies whether overflow is visible in the modal */\n isOverflowVisible: PropTypes.bool.isRequired,\n};\n\nModalDialog.Header = ModalDialogHeader;\nModalDialog.Title = ModalDialogTitle;\nModalDialog.Footer = ModalDialogFooter;\nModalDialog.CloseButton = ModalCloseButton;\nModalDialog.Body = ModalDialogBody;\nModalDialog.Hero = ModalDialogHero;\n\nexport default ModalDialog;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,UAAU,MAAM,cAAc;AACrC;AACA,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD;AACA,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD;AACA,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD;AACA,OAAOC,eAAe,MAAM,mBAAmB;AAC/C;AACA,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,UAAU,MAAM,eAAe;AACtC,SAASC,KAAK,QAAQ,aAAa;AACnC,OAAOC,QAAQ,MAAM,YAAY;AAqCjC,SAASC,WAAWA,CAAAC,IAAA,EAeV;EAAA,IAfW;IACnBC,QAAQ;IACRC,KAAK;IACLC,MAAM,GAAG,KAAK;IACdC,OAAO;IACPC,IAAI,GAAG,IAAI;IACXC,OAAO,GAAG,SAAS;IACnBC,cAAc,GAAG,IAAI;IACrBC,UAAU;IACVC,kBAAkB,GAAG,KAAK;IAC1BC,SAAS;IACTC,oBAAoB,GAAG,KAAK;IAC5BC,UAAU,GAAG,KAAK;IAClBC,MAAM;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from 'react-intl';
|
|
2
|
+
const messages = defineMessages({
|
|
3
|
+
closeButtonText: {
|
|
4
|
+
id: 'pgn.Modal.closeButon',
|
|
5
|
+
defaultMessage: 'Close',
|
|
6
|
+
description: 'Accessible name for the close button in the modal dialog'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export default messages;
|
|
10
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":["defineMessages","messages","closeButtonText","id","defaultMessage","description"],"sources":["../../src/Modal/messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nconst messages = defineMessages({\n closeButtonText: {\n id: 'pgn.Modal.closeButon',\n defaultMessage: 'Close',\n description: 'Accessible name for the close button in the modal dialog',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAE3C,MAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9BE,eAAe,EAAE;IACfC,EAAE,EAAE,sBAAsB;IAC1BC,cAAc,EAAE,OAAO;IACvBC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { useMediaQuery } from 'react-responsive';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
5
6
|
import ModalLayer from './ModalLayer';
|
|
6
7
|
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
7
8
|
import ModalCloseButton from './ModalCloseButton';
|
|
@@ -18,8 +19,7 @@ import ModalDialogHero from './ModalDialogHero';
|
|
|
18
19
|
import Icon from '../Icon';
|
|
19
20
|
import IconButton from '../IconButton';
|
|
20
21
|
import { Close } from '../../icons';
|
|
21
|
-
|
|
22
|
-
export const MODAL_DIALOG_CLOSE_LABEL = 'Close';
|
|
22
|
+
import messages from './messages';
|
|
23
23
|
|
|
24
24
|
interface Props {
|
|
25
25
|
/** Specifies the content of the dialog */
|
|
@@ -64,7 +64,7 @@ function ModalDialog({
|
|
|
64
64
|
size = 'md',
|
|
65
65
|
variant = 'default',
|
|
66
66
|
hasCloseButton = true,
|
|
67
|
-
closeLabel
|
|
67
|
+
closeLabel,
|
|
68
68
|
isFullscreenScroll = false,
|
|
69
69
|
className,
|
|
70
70
|
isFullscreenOnMobile = false,
|
|
@@ -72,6 +72,8 @@ function ModalDialog({
|
|
|
72
72
|
zIndex,
|
|
73
73
|
isOverflowVisible,
|
|
74
74
|
}: Props) {
|
|
75
|
+
const intl = useIntl();
|
|
76
|
+
const closeButtonText = closeLabel || intl.formatMessage(messages.closeButtonText);
|
|
75
77
|
const isMobile = useMediaQuery({ query: '(max-width: 767.98px)' });
|
|
76
78
|
const showFullScreen = (isFullscreenOnMobile && isMobile);
|
|
77
79
|
return (
|
|
@@ -97,7 +99,7 @@ function ModalDialog({
|
|
|
97
99
|
iconAs={Icon}
|
|
98
100
|
invertColors={variant === 'dark'}
|
|
99
101
|
src={Close}
|
|
100
|
-
alt={
|
|
102
|
+
alt={closeButtonText}
|
|
101
103
|
/>
|
|
102
104
|
</div>
|
|
103
105
|
)}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
closeButtonText: {
|
|
5
|
+
id: 'pgn.Modal.closeButon',
|
|
6
|
+
defaultMessage: 'Close',
|
|
7
|
+
description: 'Accessible name for the close button in the modal dialog',
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default messages;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
+
import { IntlProvider } from 'react-intl';
|
|
4
5
|
import AlertModal from '../AlertModal';
|
|
5
6
|
import { Info } from '../../../icons';
|
|
6
7
|
|
|
@@ -37,15 +38,17 @@ describe('<AlertModal />', () => {
|
|
|
37
38
|
|
|
38
39
|
it('renders the body when isOpen', () => {
|
|
39
40
|
render(
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
<IntlProvider locale="en" messages={{}}>
|
|
42
|
+
<AlertModal
|
|
43
|
+
title="some title"
|
|
44
|
+
isOpen={isOpen}
|
|
45
|
+
onClose={closeFn}
|
|
46
|
+
footerNode={<p>footer</p>}
|
|
47
|
+
isOverflowVisible={false}
|
|
48
|
+
>
|
|
49
|
+
<Body />
|
|
50
|
+
</AlertModal>
|
|
51
|
+
</IntlProvider>,
|
|
49
52
|
);
|
|
50
53
|
|
|
51
54
|
const body = screen.getByText('The body of alert.');
|
|
@@ -55,16 +58,18 @@ describe('<AlertModal />', () => {
|
|
|
55
58
|
describe('with variant prop', () => {
|
|
56
59
|
it('renders warning variant', () => {
|
|
57
60
|
render(
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
<IntlProvider locale="en" messages={{}}>
|
|
62
|
+
<AlertModal
|
|
63
|
+
title="warning"
|
|
64
|
+
isOpen={isOpen}
|
|
65
|
+
onClose={closeFn}
|
|
66
|
+
icon={Info}
|
|
67
|
+
footerNode={<p>footer</p>}
|
|
68
|
+
isOverflowVisible={false}
|
|
69
|
+
>
|
|
70
|
+
<Body />
|
|
71
|
+
</AlertModal>
|
|
72
|
+
</IntlProvider>,
|
|
68
73
|
);
|
|
69
74
|
|
|
70
75
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -73,16 +78,18 @@ describe('<AlertModal />', () => {
|
|
|
73
78
|
|
|
74
79
|
it('renders success variant', () => {
|
|
75
80
|
render(
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
<IntlProvider locale="en" messages={{}}>
|
|
82
|
+
<AlertModal
|
|
83
|
+
title="success"
|
|
84
|
+
isOpen={isOpen}
|
|
85
|
+
onClose={closeFn}
|
|
86
|
+
icon={Info}
|
|
87
|
+
footerNode={<p>footer</p>}
|
|
88
|
+
isOverflowVisible={false}
|
|
89
|
+
>
|
|
90
|
+
<Body />
|
|
91
|
+
</AlertModal>
|
|
92
|
+
</IntlProvider>,
|
|
86
93
|
);
|
|
87
94
|
|
|
88
95
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -91,16 +98,18 @@ describe('<AlertModal />', () => {
|
|
|
91
98
|
|
|
92
99
|
it('renders danger variant', () => {
|
|
93
100
|
render(
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
<IntlProvider locale="en" messages={{}}>
|
|
102
|
+
<AlertModal
|
|
103
|
+
title="danger"
|
|
104
|
+
isOpen={isOpen}
|
|
105
|
+
onClose={closeFn}
|
|
106
|
+
icon={Info}
|
|
107
|
+
footerNode={<p>footer</p>}
|
|
108
|
+
isOverflowVisible={false}
|
|
109
|
+
>
|
|
110
|
+
<Body />
|
|
111
|
+
</AlertModal>
|
|
112
|
+
</IntlProvider>,
|
|
104
113
|
);
|
|
105
114
|
|
|
106
115
|
const modalTitle = screen.getByTestId('title-icon');
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
+
import { IntlProvider } from 'react-intl';
|
|
4
5
|
import ModalDialog from '../ModalDialog';
|
|
5
6
|
|
|
6
7
|
describe('ModalDialog', () => {
|
|
7
8
|
it('renders a dialog with aria-label and content', () => {
|
|
8
9
|
const onClose = jest.fn();
|
|
9
10
|
render(
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<ModalDialog.
|
|
21
|
-
|
|
11
|
+
<IntlProvider locale="en" messages={{}}>
|
|
12
|
+
<ModalDialog
|
|
13
|
+
title="My dialog"
|
|
14
|
+
isOpen
|
|
15
|
+
onClose={onClose}
|
|
16
|
+
size="md"
|
|
17
|
+
variant="default"
|
|
18
|
+
hasCloseButton
|
|
19
|
+
isOverflowVisible={false}
|
|
20
|
+
>
|
|
21
|
+
<ModalDialog.Header>
|
|
22
|
+
<ModalDialog.Title>The title</ModalDialog.Title>
|
|
23
|
+
</ModalDialog.Header>
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
<ModalDialog.Body>
|
|
26
|
+
<p>The content</p>
|
|
27
|
+
</ModalDialog.Body>
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<ModalDialog.Footer>
|
|
30
|
+
<ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
|
|
31
|
+
</ModalDialog.Footer>
|
|
32
|
+
</ModalDialog>
|
|
33
|
+
</IntlProvider>,
|
|
31
34
|
);
|
|
32
35
|
|
|
33
36
|
const dialogNode = screen.getByRole('dialog');
|
|
@@ -40,15 +43,17 @@ describe('ModalDialog', () => {
|
|
|
40
43
|
it('is hidden by default', () => {
|
|
41
44
|
const onClose = jest.fn();
|
|
42
45
|
render(
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
<IntlProvider locale="en" messages={{}}>
|
|
47
|
+
<ModalDialog
|
|
48
|
+
title="My dialog"
|
|
49
|
+
onClose={onClose}
|
|
50
|
+
isOverflowVisible={false}
|
|
51
|
+
>
|
|
52
|
+
<ModalDialog.Header><ModalDialog.Title>The title</ModalDialog.Title></ModalDialog.Header>
|
|
53
|
+
<ModalDialog.Body><p>The hidden content</p></ModalDialog.Body>
|
|
54
|
+
<ModalDialog.Footer><ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton></ModalDialog.Footer>
|
|
55
|
+
</ModalDialog>
|
|
56
|
+
</IntlProvider>,
|
|
52
57
|
);
|
|
53
58
|
|
|
54
59
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
@@ -59,30 +64,32 @@ describe('ModalDialog with Hero', () => {
|
|
|
59
64
|
it('renders a dialog with aria-label and hero with img', () => {
|
|
60
65
|
const onClose = jest.fn();
|
|
61
66
|
render(
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<ModalDialog.Hero
|
|
73
|
-
|
|
74
|
-
<ModalDialog.
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
<IntlProvider locale="en" messages={{}}>
|
|
68
|
+
<ModalDialog
|
|
69
|
+
title="My dialog"
|
|
70
|
+
isOpen
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
size="md"
|
|
73
|
+
variant="default"
|
|
74
|
+
hasCloseButton
|
|
75
|
+
isOverflowVisible={false}
|
|
76
|
+
>
|
|
77
|
+
<ModalDialog.Hero>
|
|
78
|
+
<ModalDialog.Hero.Background backgroundSrc="imageurl" />
|
|
79
|
+
<ModalDialog.Hero.Content data-testid="modal-hero-content">
|
|
80
|
+
<ModalDialog.Title>The title</ModalDialog.Title>
|
|
81
|
+
</ModalDialog.Hero.Content>
|
|
82
|
+
</ModalDialog.Hero>
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
<ModalDialog.Body>
|
|
85
|
+
<p>The content</p>
|
|
86
|
+
</ModalDialog.Body>
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
<ModalDialog.Footer>
|
|
89
|
+
<ModalDialog.CloseButton>Cancel</ModalDialog.CloseButton>
|
|
90
|
+
</ModalDialog.Footer>
|
|
91
|
+
</ModalDialog>
|
|
92
|
+
</IntlProvider>,
|
|
86
93
|
);
|
|
87
94
|
const dialogNode = screen.getByRole('dialog');
|
|
88
95
|
|
package/src/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { default as Hyperlink } from './Hyperlink';
|
|
|
35
35
|
export { default as Icon } from './Icon';
|
|
36
36
|
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
37
37
|
export { default as ModalContext } from './Modal/ModalContext';
|
|
38
|
-
export { default as ModalDialog
|
|
38
|
+
export { default as ModalDialog } from './Modal/ModalDialog';
|
|
39
39
|
export { default as ModalLayer } from './Modal/ModalLayer';
|
|
40
40
|
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
41
41
|
export { default as Portal } from './Modal/Portal';
|