@openedx/paragon 22.8.0 → 22.9.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/Card/index.scss +2 -0
- package/dist/Modal/ModalContext.d.ts +15 -0
- package/dist/Modal/ModalContext.js +7 -14
- package/dist/Modal/ModalContext.js.map +1 -1
- package/dist/Modal/ModalDialog.d.ts +105 -0
- package/dist/Modal/ModalDialog.js +23 -22
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Modal/ModalDialogHeader.d.ts +10 -0
- package/dist/Modal/ModalDialogHeader.js +6 -7
- package/dist/Modal/ModalDialogHeader.js.map +1 -1
- package/dist/Modal/ModalLayer.d.ts +53 -0
- package/dist/Modal/ModalLayer.js +5 -14
- package/dist/Modal/ModalLayer.js.map +1 -1
- package/dist/Modal/Portal.d.ts +11 -0
- package/dist/Modal/Portal.js +5 -6
- package/dist/Modal/Portal.js.map +1 -1
- package/dist/hooks/useArrowKeyNavigation.js +2 -3
- package/dist/hooks/useArrowKeyNavigation.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.js +19 -5
- package/dist/paragon.css +1 -1
- package/package.json +2 -2
- package/src/Card/index.scss +2 -0
- package/src/DataTable/selection/tests/ControlledSelectHeader.test.jsx +7 -7
- package/src/Modal/{ModalContext.jsx → ModalContext.tsx} +19 -16
- package/src/Modal/{ModalDialog.jsx → ModalDialog.tsx} +50 -24
- package/src/Modal/{ModalDialogHeader.jsx → ModalDialogHeader.tsx} +17 -11
- package/src/Modal/{ModalLayer.jsx → ModalLayer.tsx} +17 -17
- package/src/Modal/{Portal.jsx → Portal.tsx} +10 -7
- package/src/Modal/tests/{ModalDialog.test.jsx → ModalDialog.test.tsx} +16 -10
- package/src/Modal/tests/{ModalLayer.test.jsx → ModalLayer.test.tsx} +5 -5
- package/src/Modal/tests/{Portal.test.jsx → Portal.test.tsx} +3 -3
- package/src/hooks/useArrowKeyNavigation.jsx +1 -2
- package/src/index.d.ts +18 -4
- package/src/index.js +19 -5
- /package/src/Truncate/{Truncate.test.js → utils.test.js} +0 -0
package/dist/Card/index.scss
CHANGED
|
@@ -353,6 +353,8 @@ a.pgn__card {
|
|
|
353
353
|
bottom: #{-$card-logo-bottom-offset};
|
|
354
354
|
width: $card-logo-width;
|
|
355
355
|
height: $card-logo-height;
|
|
356
|
+
object-fit: scale-down;
|
|
357
|
+
object-position: center center;
|
|
356
358
|
border-radius: $card-logo-border-radius;
|
|
357
359
|
box-shadow: $level-1-box-shadow;
|
|
358
360
|
padding: map_get($spacers, 2);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ContextData {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
isBlocking: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const ModalContext: React.Context<ContextData>;
|
|
8
|
+
declare function ModalContextProvider({ onClose, isOpen, isBlocking, children, }: {
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
isBlocking?: boolean;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
export { ModalContextProvider };
|
|
15
|
+
export default ModalContext;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
var ModalContext = /*#__PURE__*/React.createContext({
|
|
4
|
-
onClose: function onClose() {}
|
|
3
|
+
onClose: function onClose() {},
|
|
4
|
+
isOpen: false,
|
|
5
|
+
isBlocking: false
|
|
5
6
|
});
|
|
6
7
|
function ModalContextProvider(_ref) {
|
|
7
8
|
var onClose = _ref.onClose,
|
|
8
9
|
isOpen = _ref.isOpen,
|
|
9
|
-
isBlocking = _ref.isBlocking,
|
|
10
|
-
|
|
10
|
+
_ref$isBlocking = _ref.isBlocking,
|
|
11
|
+
isBlocking = _ref$isBlocking === void 0 ? false : _ref$isBlocking,
|
|
12
|
+
_ref$children = _ref.children,
|
|
13
|
+
children = _ref$children === void 0 ? null : _ref$children;
|
|
11
14
|
var modalContextValue = useMemo(function () {
|
|
12
15
|
return {
|
|
13
16
|
onClose: onClose,
|
|
@@ -19,16 +22,6 @@ function ModalContextProvider(_ref) {
|
|
|
19
22
|
value: modalContextValue
|
|
20
23
|
}, children);
|
|
21
24
|
}
|
|
22
|
-
ModalContextProvider.propTypes = {
|
|
23
|
-
children: PropTypes.node,
|
|
24
|
-
onClose: PropTypes.func.isRequired,
|
|
25
|
-
isBlocking: PropTypes.bool,
|
|
26
|
-
isOpen: PropTypes.bool.isRequired
|
|
27
|
-
};
|
|
28
|
-
ModalContextProvider.defaultProps = {
|
|
29
|
-
children: null,
|
|
30
|
-
isBlocking: false
|
|
31
|
-
};
|
|
32
25
|
export { ModalContextProvider };
|
|
33
26
|
export default ModalContext;
|
|
34
27
|
//# sourceMappingURL=ModalContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.js","names":["React","useMemo","
|
|
1
|
+
{"version":3,"file":"ModalContext.js","names":["React","useMemo","ModalContext","createContext","onClose","isOpen","isBlocking","ModalContextProvider","_ref","_ref$isBlocking","_ref$children","children","modalContextValue","createElement","Provider","value"],"sources":["../../src/Modal/ModalContext.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\ninterface ContextData {\n onClose: () => void;\n isOpen: boolean;\n isBlocking: boolean;\n}\n\nconst ModalContext = React.createContext<ContextData>({\n onClose: () => {},\n isOpen: false,\n isBlocking: false,\n});\n\nfunction ModalContextProvider({\n onClose,\n isOpen,\n isBlocking = false,\n children = null,\n}: {\n onClose: () => void;\n isOpen: boolean;\n isBlocking?: boolean;\n children?: React.ReactNode;\n}) {\n const modalContextValue = useMemo<ContextData>(\n () => ({ onClose, isOpen, isBlocking }),\n [onClose, isOpen, isBlocking],\n );\n\n return (\n <ModalContext.Provider value={modalContextValue}>\n {children}\n </ModalContext.Provider>\n );\n}\n\nexport { ModalContextProvider };\nexport default ModalContext;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAQtC,IAAMC,YAAY,gBAAGF,KAAK,CAACG,aAAa,CAAc;EACpDC,OAAO,EAAE,SAAAA,QAAA,EAAM,CAAC,CAAC;EACjBC,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE;AACd,CAAC,CAAC;AAEF,SAASC,oBAAoBA,CAAAC,IAAA,EAU1B;EAAA,IATDJ,OAAO,GAAAI,IAAA,CAAPJ,OAAO;IACPC,MAAM,GAAAG,IAAA,CAANH,MAAM;IAAAI,eAAA,GAAAD,IAAA,CACNF,UAAU;IAAVA,UAAU,GAAAG,eAAA,cAAG,KAAK,GAAAA,eAAA;IAAAC,aAAA,GAAAF,IAAA,CAClBG,QAAQ;IAARA,QAAQ,GAAAD,aAAA,cAAG,IAAI,GAAAA,aAAA;EAOf,IAAME,iBAAiB,GAAGX,OAAO,CAC/B;IAAA,OAAO;MAAEG,OAAO,EAAPA,OAAO;MAAEC,MAAM,EAANA,MAAM;MAAEC,UAAU,EAAVA;IAAW,CAAC;EAAA,CAAC,EACvC,CAACF,OAAO,EAAEC,MAAM,EAAEC,UAAU,CAC9B,CAAC;EAED,oBACEN,KAAA,CAAAa,aAAA,CAACX,YAAY,CAACY,QAAQ;IAACC,KAAK,EAAEH;EAAkB,GAC7CD,QACoB,CAAC;AAE5B;AAEA,SAASJ,oBAAoB;AAC7B,eAAeL,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
export declare const MODAL_DIALOG_CLOSE_LABEL = "Close";
|
|
4
|
+
interface Props {
|
|
5
|
+
/** Specifies the content of the dialog */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** The aria-label of the dialog */
|
|
8
|
+
title: string;
|
|
9
|
+
/** A callback to close the modal dialog, e.g. when Escape is pressed */
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
/** Is the modal dialog open or closed? */
|
|
12
|
+
isOpen?: boolean;
|
|
13
|
+
/** The close 'x' icon button in the top right of the dialog box */
|
|
14
|
+
hasCloseButton?: boolean;
|
|
15
|
+
/** Size determines the maximum width of the dialog box */
|
|
16
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'fullscreen';
|
|
17
|
+
/** The visual style of the dialog box */
|
|
18
|
+
variant?: 'default' | 'warning' | 'danger' | 'success' | 'dark';
|
|
19
|
+
/** The label supplied to the close icon button if one is rendered */
|
|
20
|
+
closeLabel?: string;
|
|
21
|
+
/** Specifies class name to append to the base element */
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Determines where a scrollbar should appear if a modal is too large for the
|
|
25
|
+
* viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true
|
|
26
|
+
* the browser window itself receives the scrollbar.
|
|
27
|
+
*/
|
|
28
|
+
isFullscreenScroll?: boolean;
|
|
29
|
+
/** To show full screen view on mobile screens */
|
|
30
|
+
isFullscreenOnMobile?: boolean;
|
|
31
|
+
/** Prevent clicking on the backdrop or pressing Esc to close the modal */
|
|
32
|
+
isBlocking?: boolean;
|
|
33
|
+
/** Specifies the z-index of the modal */
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
/** Specifies whether overflow is visible in the modal */
|
|
36
|
+
isOverflowVisible?: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare function ModalDialog({ children, title, isOpen, onClose, size, variant, hasCloseButton, closeLabel, isFullscreenScroll, className, isFullscreenOnMobile, isBlocking, zIndex, isOverflowVisible, }: Props): React.JSX.Element;
|
|
39
|
+
declare namespace ModalDialog {
|
|
40
|
+
var propTypes: {
|
|
41
|
+
/**
|
|
42
|
+
* Specifies the content of the dialog
|
|
43
|
+
*/
|
|
44
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
45
|
+
/**
|
|
46
|
+
* The aria-label of the dialog
|
|
47
|
+
*/
|
|
48
|
+
title: PropTypes.Validator<string>;
|
|
49
|
+
/**
|
|
50
|
+
* A callback to close the modal dialog
|
|
51
|
+
*/
|
|
52
|
+
onClose: PropTypes.Validator<(...args: any[]) => any>;
|
|
53
|
+
/**
|
|
54
|
+
* Is the modal dialog open or closed
|
|
55
|
+
*/
|
|
56
|
+
isOpen: PropTypes.Requireable<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* The close 'x' icon button in the top right of the dialog box
|
|
59
|
+
*/
|
|
60
|
+
hasCloseButton: PropTypes.Requireable<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Sizes determine the maximum width of the dialog box
|
|
63
|
+
*/
|
|
64
|
+
size: PropTypes.Requireable<string>;
|
|
65
|
+
/**
|
|
66
|
+
* The visual style of the dialog box
|
|
67
|
+
*/
|
|
68
|
+
variant: PropTypes.Requireable<string>;
|
|
69
|
+
/**
|
|
70
|
+
* The label supplied to the close icon button if one is rendered
|
|
71
|
+
*/
|
|
72
|
+
closeLabel: PropTypes.Requireable<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Specifies class name to append to the base element
|
|
75
|
+
*/
|
|
76
|
+
className: PropTypes.Requireable<string>;
|
|
77
|
+
/**
|
|
78
|
+
* Determines where a scrollbar should appear if a modal is too large for the
|
|
79
|
+
* viewport. When false, the ``ModalDialog``. Body receives a scrollbar, when true
|
|
80
|
+
* the browser window itself receives the scrollbar.
|
|
81
|
+
*/
|
|
82
|
+
isFullscreenScroll: PropTypes.Requireable<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* To show full screen view on mobile screens
|
|
85
|
+
*/
|
|
86
|
+
isFullscreenOnMobile: PropTypes.Requireable<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Prevent clicking on the backdrop or pressing Esc to close the modal
|
|
89
|
+
*/
|
|
90
|
+
isBlocking: PropTypes.Requireable<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Specifies the z-index of the modal
|
|
93
|
+
*/
|
|
94
|
+
zIndex: PropTypes.Requireable<number>;
|
|
95
|
+
/** Specifies whether overflow is visible in the modal */
|
|
96
|
+
isOverflowVisible: PropTypes.Requireable<boolean>;
|
|
97
|
+
};
|
|
98
|
+
var Header: import("react-bootstrap/esm/helpers").BsPrefixRefForwardingComponent<"div", import("./ModalDialogHeader").Props>;
|
|
99
|
+
var Title: any;
|
|
100
|
+
var Footer: any;
|
|
101
|
+
var CloseButton: any;
|
|
102
|
+
var Body: any;
|
|
103
|
+
var Hero: any;
|
|
104
|
+
}
|
|
105
|
+
export default ModalDialog;
|
|
@@ -7,11 +7,16 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { useMediaQuery } from 'react-responsive';
|
|
9
9
|
import ModalLayer from './ModalLayer';
|
|
10
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
10
11
|
import ModalCloseButton from './ModalCloseButton';
|
|
11
12
|
import ModalDialogHeader from './ModalDialogHeader';
|
|
13
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
12
14
|
import ModalDialogTitle from './ModalDialogTitle';
|
|
15
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
13
16
|
import ModalDialogFooter from './ModalDialogFooter';
|
|
17
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
14
18
|
import ModalDialogBody from './ModalDialogBody';
|
|
19
|
+
// @ts-ignore for now - this needs to be converted to TypeScript
|
|
15
20
|
import ModalDialogHero from './ModalDialogHero';
|
|
16
21
|
import Icon from '../Icon';
|
|
17
22
|
import IconButton from '../IconButton';
|
|
@@ -21,18 +26,27 @@ function ModalDialog(_ref) {
|
|
|
21
26
|
var _classNames;
|
|
22
27
|
var children = _ref.children,
|
|
23
28
|
title = _ref.title,
|
|
24
|
-
isOpen = _ref.isOpen,
|
|
29
|
+
_ref$isOpen = _ref.isOpen,
|
|
30
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
25
31
|
onClose = _ref.onClose,
|
|
26
|
-
size = _ref.size,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
_ref$size = _ref.size,
|
|
33
|
+
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
34
|
+
_ref$variant = _ref.variant,
|
|
35
|
+
variant = _ref$variant === void 0 ? 'default' : _ref$variant,
|
|
36
|
+
_ref$hasCloseButton = _ref.hasCloseButton,
|
|
37
|
+
hasCloseButton = _ref$hasCloseButton === void 0 ? true : _ref$hasCloseButton,
|
|
38
|
+
_ref$closeLabel = _ref.closeLabel,
|
|
39
|
+
closeLabel = _ref$closeLabel === void 0 ? MODAL_DIALOG_CLOSE_LABEL : _ref$closeLabel,
|
|
40
|
+
_ref$isFullscreenScro = _ref.isFullscreenScroll,
|
|
41
|
+
isFullscreenScroll = _ref$isFullscreenScro === void 0 ? false : _ref$isFullscreenScro,
|
|
31
42
|
className = _ref.className,
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
_ref$isFullscreenOnMo = _ref.isFullscreenOnMobile,
|
|
44
|
+
isFullscreenOnMobile = _ref$isFullscreenOnMo === void 0 ? false : _ref$isFullscreenOnMo,
|
|
45
|
+
_ref$isBlocking = _ref.isBlocking,
|
|
46
|
+
isBlocking = _ref$isBlocking === void 0 ? false : _ref$isBlocking,
|
|
34
47
|
zIndex = _ref.zIndex,
|
|
35
|
-
|
|
48
|
+
_ref$isOverflowVisibl = _ref.isOverflowVisible,
|
|
49
|
+
isOverflowVisible = _ref$isOverflowVisibl === void 0 ? true : _ref$isOverflowVisibl;
|
|
36
50
|
var isMobile = useMediaQuery({
|
|
37
51
|
query: '(max-width: 767.98px)'
|
|
38
52
|
});
|
|
@@ -114,19 +128,6 @@ ModalDialog.propTypes = {
|
|
|
114
128
|
/** Specifies whether overflow is visible in the modal */
|
|
115
129
|
isOverflowVisible: PropTypes.bool
|
|
116
130
|
};
|
|
117
|
-
ModalDialog.defaultProps = {
|
|
118
|
-
isOpen: false,
|
|
119
|
-
hasCloseButton: true,
|
|
120
|
-
size: 'md',
|
|
121
|
-
variant: 'default',
|
|
122
|
-
closeLabel: MODAL_DIALOG_CLOSE_LABEL,
|
|
123
|
-
className: undefined,
|
|
124
|
-
isFullscreenScroll: false,
|
|
125
|
-
isFullscreenOnMobile: false,
|
|
126
|
-
isBlocking: false,
|
|
127
|
-
zIndex: undefined,
|
|
128
|
-
isOverflowVisible: true
|
|
129
|
-
};
|
|
130
131
|
ModalDialog.Header = ModalDialogHeader;
|
|
131
132
|
ModalDialog.Title = ModalDialogTitle;
|
|
132
133
|
ModalDialog.Footer = ModalDialogFooter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","MODAL_DIALOG_CLOSE_LABEL","ModalDialog","_ref","_classNames","children","title","isOpen","onClose","size","variant","hasCloseButton","closeLabel","isFullscreenScroll","className","isFullscreenOnMobile","isBlocking","zIndex","isOverflowVisible","isMobile","query","showFullScreen","createElement","role","_defineProperty","concat","as","iconAs","invertColors","src","alt","propTypes","node","isRequired","string","func","bool","oneOf","number","defaultProps","undefined","Header","Title","Footer","CloseButton","Body","Hero"],"sources":["../../src/Modal/ModalDialog.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useMediaQuery } from 'react-responsive';\nimport ModalLayer from './ModalLayer';\nimport ModalCloseButton from './ModalCloseButton';\nimport ModalDialogHeader from './ModalDialogHeader';\nimport ModalDialogTitle from './ModalDialogTitle';\nimport ModalDialogFooter from './ModalDialogFooter';\nimport ModalDialogBody from './ModalDialogBody';\nimport ModalDialogHero from './ModalDialogHero';\n\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\nimport { Close } from '../../icons';\n\nexport const MODAL_DIALOG_CLOSE_LABEL = 'Close';\n\nfunction ModalDialog({\n children,\n title,\n isOpen,\n onClose,\n size,\n variant,\n hasCloseButton,\n closeLabel,\n isFullscreenScroll,\n className,\n isFullscreenOnMobile,\n isBlocking,\n zIndex,\n isOverflowVisible,\n}) {\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={closeLabel}\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,\n};\n\nModalDialog.defaultProps = {\n isOpen: false,\n hasCloseButton: true,\n size: 'md',\n variant: 'default',\n closeLabel: MODAL_DIALOG_CLOSE_LABEL,\n className: undefined,\n isFullscreenScroll: false,\n isFullscreenOnMobile: false,\n isBlocking: false,\n zIndex: undefined,\n isOverflowVisible: true,\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,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,UAAU,MAAM,eAAe;AACtC,SAASC,KAAK,QAAQ,aAAa;AAEnC,OAAO,IAAMC,wBAAwB,GAAG,OAAO;AAE/C,SAASC,WAAWA,CAAAC,IAAA,EAejB;EA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B,SAAS,CAACgD,IAAI;EACpC;AACF;AACA;EACEpB,UAAU,EAAE5B,SAAS,CAACgD,IAAI;EAC1B;AACF;AACA;EACEnB,MAAM,EAAE7B,SAAS,CAACkD,MAAM;EACxB;EACApB,iBAAiB,EAAE9B,SAAS,CAACgD;AAC/B,CAAC;AAEDlC,WAAW,CAACqC,YAAY,GAAG;EACzBhC,MAAM,EAAE,KAAK;EACbI,cAAc,EAAE,IAAI;EACpBF,IAAI,EAAE,IAAI;EACVC,OAAO,EAAE,SAAS;EAClBE,UAAU,EAAEX,wBAAwB;EACpCa,SAAS,EAAE0B,SAAS;EACpB3B,kBAAkB,EAAE,KAAK;EACzBE,oBAAoB,EAAE,KAAK;EAC3BC,UAAU,EAAE,KAAK;EACjBC,MAAM,EAAEuB,SAAS;EACjBtB,iBAAiB,EAAE;AACrB,CAAC;AAEDhB,WAAW,CAACuC,MAAM,GAAGhD,iBAAiB;AACtCS,WAAW,CAACwC,KAAK,GAAGhD,gBAAgB;AACpCQ,WAAW,CAACyC,MAAM,GAAGhD,iBAAiB;AACtCO,WAAW,CAAC0C,WAAW,GAAGpD,gBAAgB;AAC1CU,WAAW,CAAC2C,IAAI,GAAGjD,eAAe;AAClCM,WAAW,CAAC4C,IAAI,GAAGjD,eAAe;AAElC,eAAeK,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModalDialog.js","names":["React","PropTypes","classNames","useMediaQuery","ModalLayer","ModalCloseButton","ModalDialogHeader","ModalDialogTitle","ModalDialogFooter","ModalDialogBody","ModalDialogHero","Icon","IconButton","Close","MODAL_DIALOG_CLOSE_LABEL","ModalDialog","_ref","_classNames","children","title","_ref$isOpen","isOpen","onClose","_ref$size","size","_ref$variant","variant","_ref$hasCloseButton","hasCloseButton","_ref$closeLabel","closeLabel","_ref$isFullscreenScro","isFullscreenScroll","className","_ref$isFullscreenOnMo","isFullscreenOnMobile","_ref$isBlocking","isBlocking","zIndex","_ref$isOverflowVisibl","isOverflowVisible","isMobile","query","showFullScreen","createElement","role","_defineProperty","concat","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 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';\n\nexport const MODAL_DIALOG_CLOSE_LABEL = 'Close';\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 = MODAL_DIALOG_CLOSE_LABEL,\n isFullscreenScroll = false,\n className,\n isFullscreenOnMobile = false,\n isBlocking = false,\n zIndex,\n isOverflowVisible = true,\n}: Props) {\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={closeLabel}\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,\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,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;AAEnC,OAAO,IAAMC,wBAAwB,GAAG,OAAO;AAqC/C,SAASC,WAAWA,CAAAC,IAAA,EAeV;EAAA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,IAAI;EAC9B;AACF;AACA;EACElC,IAAI,EAAEvB,SAAS,CAAC0D,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;EAC7D;AACF;AACA;EACEjC,OAAO,EAAEzB,SAAS,CAAC0D,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;EAC7E;AACF;AACA;EACE7B,UAAU,EAAE7B,SAAS,CAACuD,MAAM;EAC5B;AACF;AACA;EACEvB,SAAS,EAAEhC,SAAS,CAACuD,MAAM;EAC3B;AACF;AACA;AACA;AACA;EACExB,kBAAkB,EAAE/B,SAAS,CAACyD,IAAI;EAClC;AACF;AACA;EACEvB,oBAAoB,EAAElC,SAAS,CAACyD,IAAI;EACpC;AACF;AACA;EACErB,UAAU,EAAEpC,SAAS,CAACyD,IAAI;EAC1B;AACF;AACA;EACEpB,MAAM,EAAErC,SAAS,CAAC2D,MAAM;EACxB;EACApB,iBAAiB,EAAEvC,SAAS,CAACyD;AAC/B,CAAC;AAED3C,WAAW,CAAC8C,MAAM,GAAGvD,iBAAiB;AACtCS,WAAW,CAAC+C,KAAK,GAAGvD,gBAAgB;AACpCQ,WAAW,CAACgD,MAAM,GAAGvD,iBAAiB;AACtCO,WAAW,CAACiD,WAAW,GAAG3D,gBAAgB;AAC1CU,WAAW,CAACkD,IAAI,GAAGxD,eAAe;AAClCM,WAAW,CAACmD,IAAI,GAAGxD,eAAe;AAElC,eAAeK,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
3
|
+
export interface Props {
|
|
4
|
+
as?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
type HeaderType = ComponentWithAsProp<'div', Props>;
|
|
9
|
+
declare const ModalDialogHeader: HeaderType;
|
|
10
|
+
export default ModalDialogHeader;
|
|
@@ -7,17 +7,20 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
9
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
/* eslint-disable react/require-default-props */
|
|
10
11
|
import React from 'react';
|
|
11
12
|
import PropTypes from 'prop-types';
|
|
12
13
|
import classNames from 'classnames';
|
|
13
|
-
|
|
14
|
-
var as = _ref.as,
|
|
14
|
+
var ModalDialogHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
15
|
+
var _ref$as = _ref.as,
|
|
16
|
+
as = _ref$as === void 0 ? 'div' : _ref$as,
|
|
15
17
|
children = _ref.children,
|
|
16
18
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
17
19
|
return /*#__PURE__*/React.createElement(as, _objectSpread(_objectSpread({}, props), {}, {
|
|
20
|
+
ref: ref,
|
|
18
21
|
className: classNames('pgn__modal-header', props.className)
|
|
19
22
|
}), children);
|
|
20
|
-
}
|
|
23
|
+
});
|
|
21
24
|
ModalDialogHeader.propTypes = {
|
|
22
25
|
/** Specifies the base element */
|
|
23
26
|
as: PropTypes.elementType,
|
|
@@ -26,9 +29,5 @@ ModalDialogHeader.propTypes = {
|
|
|
26
29
|
/** Specifies class name to append to the base element */
|
|
27
30
|
className: PropTypes.string
|
|
28
31
|
};
|
|
29
|
-
ModalDialogHeader.defaultProps = {
|
|
30
|
-
as: 'div',
|
|
31
|
-
className: undefined
|
|
32
|
-
};
|
|
33
32
|
export default ModalDialogHeader;
|
|
34
33
|
//# sourceMappingURL=ModalDialogHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDialogHeader.js","names":["React","PropTypes","classNames","ModalDialogHeader","_ref","as","children","props","_objectWithoutProperties","_excluded","createElement","_objectSpread","className","propTypes","elementType","node","isRequired","string"
|
|
1
|
+
{"version":3,"file":"ModalDialogHeader.js","names":["React","PropTypes","classNames","ModalDialogHeader","forwardRef","_ref","ref","_ref$as","as","children","props","_objectWithoutProperties","_excluded","createElement","_objectSpread","className","propTypes","elementType","node","isRequired","string"],"sources":["../../src/Modal/ModalDialogHeader.tsx"],"sourcesContent":["/* eslint-disable react/require-default-props */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport type { ComponentWithAsProp } from '../utils/types/bootstrap';\n\nexport interface Props {\n as?: string;\n children: React.ReactNode;\n className?: string;\n}\n\ntype HeaderType = ComponentWithAsProp<'div', Props>;\n\nconst ModalDialogHeader: HeaderType = React.forwardRef<HTMLDivElement, Props>(({\n as = 'div',\n children,\n ...props\n}, ref) => (\n React.createElement(\n as,\n {\n ...props,\n ref,\n className: classNames('pgn__modal-header', props.className),\n },\n children,\n )\n));\n\nModalDialogHeader.propTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType,\n /** Specifies the contents of the header */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element */\n className: PropTypes.string,\n};\n\nexport default ModalDialogHeader;\n"],"mappings":";;;;;;;;;AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AAWnC,IAAMC,iBAA6B,gBAAGH,KAAK,CAACI,UAAU,CAAwB,UAAAC,IAAA,EAI3EC,GAAG;EAAA,IAAAC,OAAA,GAAAF,IAAA,CAHJG,EAAE;IAAFA,EAAE,GAAAD,OAAA,cAAG,KAAK,GAAAA,OAAA;IACVE,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACLC,KAAK,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA;EAAA,oBAERZ,KAAK,CAACa,aAAa,CACjBL,EAAE,EAAAM,aAAA,CAAAA,aAAA,KAEGJ,KAAK;IACRJ,GAAG,EAAHA,GAAG;IACHS,SAAS,EAAEb,UAAU,CAAC,mBAAmB,EAAEQ,KAAK,CAACK,SAAS;EAAC,IAE7DN,QACF,CAAC;AAAA,CACF,CAAC;AAEFN,iBAAiB,CAACa,SAAS,GAAG;EAC5B;EACAR,EAAE,EAAEP,SAAS,CAACgB,WAAW;EACzB;EACAR,QAAQ,EAAER,SAAS,CAACiB,IAAI,CAACC,UAAU;EACnC;EACAJ,SAAS,EAAEd,SAAS,CAACmB;AACvB,CAAC;AAED,eAAejB,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
declare function ModalBackdrop({ onClick }: {
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare namespace ModalBackdrop {
|
|
7
|
+
var propTypes: {
|
|
8
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
declare function ModalContentContainer({ children }: {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
declare namespace ModalContentContainer {
|
|
15
|
+
var propTypes: {
|
|
16
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface Props {
|
|
20
|
+
/** Specifies the contents of the modal */
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
/** A callback function for when the modal is dismissed */
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
/** Is the modal dialog open or closed */
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
/** Prevent clicking on the backdrop or pressing Esc to close the modal */
|
|
27
|
+
isBlocking?: boolean;
|
|
28
|
+
/** Specifies the z-index of the modal */
|
|
29
|
+
zIndex?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The ModalLayer should be used for any component that wishes to engage the user
|
|
33
|
+
* in a "mode" where a layer on top of the application is interactive while the
|
|
34
|
+
* rest of the application is made non-interactive. The assumption made by this
|
|
35
|
+
* component is that if a modal object is visible then it is "enabled"
|
|
36
|
+
*/
|
|
37
|
+
declare function ModalLayer({ children, onClose, isOpen, isBlocking, zIndex, }: Props): React.JSX.Element | null;
|
|
38
|
+
declare namespace ModalLayer {
|
|
39
|
+
var propTypes: {
|
|
40
|
+
/** Specifies the contents of the modal */
|
|
41
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
42
|
+
/** A callback function for when the modal is dismissed */
|
|
43
|
+
onClose: PropTypes.Validator<(...args: any[]) => any>;
|
|
44
|
+
/** Is the modal dialog open or closed */
|
|
45
|
+
isOpen: PropTypes.Validator<boolean>;
|
|
46
|
+
/** Prevent clicking on the backdrop or pressing Esc to close the modal */
|
|
47
|
+
isBlocking: PropTypes.Requireable<boolean>;
|
|
48
|
+
/** Specifies the z-index of the modal */
|
|
49
|
+
zIndex: PropTypes.Requireable<number>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export { ModalBackdrop, ModalContentContainer };
|
|
53
|
+
export default ModalLayer;
|
package/dist/Modal/ModalLayer.js
CHANGED
|
@@ -22,13 +22,11 @@ function ModalBackdrop(_ref) {
|
|
|
22
22
|
ModalBackdrop.propTypes = {
|
|
23
23
|
onClick: PropTypes.func
|
|
24
24
|
};
|
|
25
|
-
ModalBackdrop.defaultProps = {
|
|
26
|
-
onClick: undefined
|
|
27
|
-
};
|
|
28
25
|
|
|
29
26
|
// istanbul ignore next
|
|
30
27
|
function ModalContentContainer(_ref2) {
|
|
31
|
-
var children = _ref2.children
|
|
28
|
+
var _ref2$children = _ref2.children,
|
|
29
|
+
children = _ref2$children === void 0 ? null : _ref2$children;
|
|
32
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
31
|
className: "pgn__modal-content-container"
|
|
34
32
|
}, children);
|
|
@@ -36,10 +34,6 @@ function ModalContentContainer(_ref2) {
|
|
|
36
34
|
ModalContentContainer.propTypes = {
|
|
37
35
|
children: PropTypes.node
|
|
38
36
|
};
|
|
39
|
-
ModalContentContainer.defaultProps = {
|
|
40
|
-
children: null
|
|
41
|
-
};
|
|
42
|
-
|
|
43
37
|
/**
|
|
44
38
|
* The ModalLayer should be used for any component that wishes to engage the user
|
|
45
39
|
* in a "mode" where a layer on top of the application is interactive while the
|
|
@@ -50,7 +44,8 @@ function ModalLayer(_ref3) {
|
|
|
50
44
|
var children = _ref3.children,
|
|
51
45
|
onClose = _ref3.onClose,
|
|
52
46
|
isOpen = _ref3.isOpen,
|
|
53
|
-
isBlocking = _ref3.isBlocking,
|
|
47
|
+
_ref3$isBlocking = _ref3.isBlocking,
|
|
48
|
+
isBlocking = _ref3$isBlocking === void 0 ? false : _ref3$isBlocking,
|
|
54
49
|
zIndex = _ref3.zIndex;
|
|
55
50
|
useEffect(function () {
|
|
56
51
|
if (isOpen) {
|
|
@@ -65,7 +60,7 @@ function ModalLayer(_ref3) {
|
|
|
65
60
|
if (!isOpen) {
|
|
66
61
|
return null;
|
|
67
62
|
}
|
|
68
|
-
var handleClose = isBlocking ?
|
|
63
|
+
var handleClose = isBlocking ? undefined : onClose;
|
|
69
64
|
return /*#__PURE__*/React.createElement(ModalContextProvider, {
|
|
70
65
|
onClose: onClose,
|
|
71
66
|
isOpen: isOpen,
|
|
@@ -93,10 +88,6 @@ ModalLayer.propTypes = {
|
|
|
93
88
|
/** Specifies the z-index of the modal */
|
|
94
89
|
zIndex: PropTypes.number
|
|
95
90
|
};
|
|
96
|
-
ModalLayer.defaultProps = {
|
|
97
|
-
isBlocking: false,
|
|
98
|
-
zIndex: undefined
|
|
99
|
-
};
|
|
100
91
|
export { ModalBackdrop, ModalContentContainer };
|
|
101
92
|
export default ModalLayer;
|
|
102
93
|
//# sourceMappingURL=ModalLayer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalLayer.js","names":["React","useEffect","classNames","PropTypes","FocusOn","Portal","ModalContextProvider","ModalBackdrop","_ref","onClick","createElement","className","onKeyDown","propTypes","func","
|
|
1
|
+
{"version":3,"file":"ModalLayer.js","names":["React","useEffect","classNames","PropTypes","FocusOn","Portal","ModalContextProvider","ModalBackdrop","_ref","onClick","createElement","className","onKeyDown","propTypes","func","ModalContentContainer","_ref2","_ref2$children","children","node","ModalLayer","_ref3","onClose","isOpen","_ref3$isBlocking","isBlocking","zIndex","document","body","classList","add","remove","handleClose","undefined","allowPinchZoom","scrollLock","enabled","onEscapeKey","onClickOutside","concat","isRequired","bool","number"],"sources":["../../src/Modal/ModalLayer.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport { FocusOn } from 'react-focus-on';\nimport Portal from './Portal';\nimport { ModalContextProvider } from './ModalContext';\n\n// istanbul ignore next\nfunction ModalBackdrop({ onClick }: { onClick?: () => void }) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n className=\"pgn__modal-backdrop\"\n onClick={onClick}\n onKeyDown={onClick}\n data-testid=\"modal-backdrop\"\n />\n );\n}\n\nModalBackdrop.propTypes = {\n onClick: PropTypes.func,\n};\n\n// istanbul ignore next\nfunction ModalContentContainer({ children = null }: { children?: React.ReactNode }) {\n return <div className=\"pgn__modal-content-container\">{children}</div>;\n}\n\nModalContentContainer.propTypes = {\n children: PropTypes.node,\n};\n\ninterface Props {\n /** Specifies the contents of the modal */\n children: React.ReactNode;\n /** A callback function for when the modal is dismissed */\n onClose: () => void;\n /** Is the modal dialog open or closed */\n isOpen: 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}\n\n/**\n * The ModalLayer should be used for any component that wishes to engage the user\n * in a \"mode\" where a layer on top of the application is interactive while the\n * rest of the application is made non-interactive. The assumption made by this\n * component is that if a modal object is visible then it is \"enabled\"\n */\nfunction ModalLayer({\n children, onClose, isOpen, isBlocking = false, zIndex,\n}: Props) {\n useEffect(() => {\n if (isOpen) {\n document.body.classList.add('pgn__hidden-scroll-padding-right');\n } else {\n document.body.classList.remove('pgn__hidden-scroll-padding-right');\n }\n return () => {\n document.body.classList.remove('pgn__hidden-scroll-padding-right');\n };\n }, [isOpen]);\n\n if (!isOpen) {\n return null;\n }\n\n const handleClose = isBlocking ? undefined : onClose;\n\n return (\n <ModalContextProvider onClose={onClose} isOpen={isOpen} isBlocking={isBlocking}>\n <Portal>\n <FocusOn\n allowPinchZoom\n scrollLock\n enabled={isOpen}\n onEscapeKey={handleClose}\n onClickOutside={handleClose}\n className={classNames(\n 'pgn__modal-layer',\n zIndex ? `zindex-${zIndex}` : '',\n )}\n >\n <ModalContentContainer>\n <ModalBackdrop onClick={handleClose} />\n {children}\n </ModalContentContainer>\n </FocusOn>\n </Portal>\n </ModalContextProvider>\n );\n}\n\nModalLayer.propTypes = {\n /** Specifies the contents of the modal */\n children: PropTypes.node.isRequired,\n /** A callback function for when the modal is dismissed */\n onClose: PropTypes.func.isRequired,\n /** Is the modal dialog open or closed */\n isOpen: PropTypes.bool.isRequired,\n /** Prevent clicking on the backdrop or pressing Esc to close the modal */\n isBlocking: PropTypes.bool,\n /** Specifies the z-index of the modal */\n zIndex: PropTypes.number,\n};\n\nexport { ModalBackdrop, ModalContentContainer };\nexport default ModalLayer;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,oBAAoB,QAAQ,gBAAgB;;AAErD;AACA,SAASC,aAAaA,CAAAC,IAAA,EAAwC;EAAA,IAArCC,OAAO,GAAAD,IAAA,CAAPC,OAAO;EAC9B;IAAA;IACE;IACAT,KAAA,CAAAU,aAAA;MACEC,SAAS,EAAC,qBAAqB;MAC/BF,OAAO,EAAEA,OAAQ;MACjBG,SAAS,EAAEH,OAAQ;MACnB,eAAY;IAAgB,CAC7B;EAAC;AAEN;AAEAF,aAAa,CAACM,SAAS,GAAG;EACxBJ,OAAO,EAAEN,SAAS,CAACW;AACrB,CAAC;;AAED;AACA,SAASC,qBAAqBA,CAAAC,KAAA,EAAsD;EAAA,IAAAC,cAAA,GAAAD,KAAA,CAAnDE,QAAQ;IAARA,QAAQ,GAAAD,cAAA,cAAG,IAAI,GAAAA,cAAA;EAC9C,oBAAOjB,KAAA,CAAAU,aAAA;IAAKC,SAAS,EAAC;EAA8B,GAAEO,QAAc,CAAC;AACvE;AAEAH,qBAAqB,CAACF,SAAS,GAAG;EAChCK,QAAQ,EAAEf,SAAS,CAACgB;AACtB,CAAC;AAeD;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAAC,KAAA,EAET;EAAA,IADRH,QAAQ,GAAAG,KAAA,CAARH,QAAQ;IAAEI,OAAO,GAAAD,KAAA,CAAPC,OAAO;IAAEC,MAAM,GAAAF,KAAA,CAANE,MAAM;IAAAC,gBAAA,GAAAH,KAAA,CAAEI,UA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EACnC;EACAlB,OAAO,EAAEnB,SAAS,CAACW,IAAI,CAAC0B,UAAU;EAClC;EACAjB,MAAM,EAAEpB,SAAS,CAACsC,IAAI,CAACD,UAAU;EACjC;EACAf,UAAU,EAAEtB,SAAS,CAACsC,IAAI;EAC1B;EACAf,MAAM,EAAEvB,SAAS,CAACuC;AACpB,CAAC;AAED,SAASnC,aAAa,EAAEQ,qBAAqB;AAC7C,eAAeK,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
declare class Portal extends React.Component<Props> {
|
|
6
|
+
private rootName;
|
|
7
|
+
private rootElement;
|
|
8
|
+
constructor(props: Props);
|
|
9
|
+
render(): React.ReactPortal | null;
|
|
10
|
+
}
|
|
11
|
+
export default Portal;
|
package/dist/Modal/Portal.js
CHANGED
|
@@ -2,8 +2,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
5
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
6
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -11,9 +9,11 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
11
9
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
11
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
15
|
import React from 'react';
|
|
15
16
|
import ReactDOM from 'react-dom';
|
|
16
|
-
import PropTypes from 'prop-types';
|
|
17
17
|
var Portal = /*#__PURE__*/function (_React$Component) {
|
|
18
18
|
_inherits(Portal, _React$Component);
|
|
19
19
|
var _super = _createSuper(Portal);
|
|
@@ -21,6 +21,8 @@ var Portal = /*#__PURE__*/function (_React$Component) {
|
|
|
21
21
|
var _this;
|
|
22
22
|
_classCallCheck(this, Portal);
|
|
23
23
|
_this = _super.call(this, props);
|
|
24
|
+
_defineProperty(_assertThisInitialized(_this), "rootName", void 0);
|
|
25
|
+
_defineProperty(_assertThisInitialized(_this), "rootElement", void 0);
|
|
24
26
|
_this.rootName = 'paragon-portal-root';
|
|
25
27
|
// istanbul ignore if
|
|
26
28
|
if (typeof document === 'undefined') {
|
|
@@ -47,8 +49,5 @@ var Portal = /*#__PURE__*/function (_React$Component) {
|
|
|
47
49
|
}]);
|
|
48
50
|
return Portal;
|
|
49
51
|
}(React.Component);
|
|
50
|
-
Portal.propTypes = {
|
|
51
|
-
children: PropTypes.node.isRequired
|
|
52
|
-
};
|
|
53
52
|
export default Portal;
|
|
54
53
|
//# sourceMappingURL=Portal.js.map
|
package/dist/Modal/Portal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.js","names":["React","ReactDOM","
|
|
1
|
+
{"version":3,"file":"Portal.js","names":["React","ReactDOM","Portal","_React$Component","_inherits","_super","_createSuper","props","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","rootName","document","rootElement","getElementById","createElement","setAttribute","body","appendChild","_createClass","key","value","render","createPortal","children","Component"],"sources":["../../src/Modal/Portal.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\ninterface Props {\n children: React.ReactNode;\n}\n\nclass Portal extends React.Component<Props> {\n private rootName: string;\n\n private rootElement: HTMLElement | null;\n\n constructor(props: Props) {\n super(props);\n this.rootName = 'paragon-portal-root';\n // istanbul ignore if\n if (typeof document === 'undefined') {\n this.rootElement = null;\n } else if (document.getElementById(this.rootName)) {\n this.rootElement = document.getElementById(this.rootName);\n } else {\n const rootElement = document.createElement('div');\n rootElement.setAttribute('id', this.rootName);\n this.rootElement = document.body.appendChild(rootElement);\n }\n }\n\n render() {\n // istanbul ignore else\n if (this.rootElement) {\n return ReactDOM.createPortal(\n this.props.children,\n this.rootElement,\n );\n }\n // istanbul ignore next\n return null;\n }\n}\n\nexport default Portal;\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,MAAM,WAAW;AAAC,IAM3BC,MAAM,0BAAAC,gBAAA;EAAAC,SAAA,CAAAF,MAAA,EAAAC,gBAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,MAAA;EAKV,SAAAA,OAAYK,KAAY,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAP,MAAA;IACxBM,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAMH,KAAK;IAAEI,eAAA,CAAAC,sBAAA,CAAAJ,KAAA;IAAAG,eAAA,CAAAC,sBAAA,CAAAJ,KAAA;IACbA,KAAA,CAAKK,QAAQ,GAAG,qBAAqB;IACrC;IACA,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;MACnCN,KAAA,CAAKO,WAAW,GAAG,IAAI;IACzB,CAAC,MAAM,IAAID,QAAQ,CAACE,cAAc,CAACR,KAAA,CAAKK,QAAQ,CAAC,EAAE;MACjDL,KAAA,CAAKO,WAAW,GAAGD,QAAQ,CAACE,cAAc,CAACR,KAAA,CAAKK,QAAQ,CAAC;IAC3D,CAAC,MAAM;MACL,IAAME,WAAW,GAAGD,QAAQ,CAACG,aAAa,CAAC,KAAK,CAAC;MACjDF,WAAW,CAACG,YAAY,CAAC,IAAI,EAAEV,KAAA,CAAKK,QAAQ,CAAC;MAC7CL,KAAA,CAAKO,WAAW,GAAGD,QAAQ,CAACK,IAAI,CAACC,WAAW,CAACL,WAAW,CAAC;IAC3D;IAAC,OAAAP,KAAA;EACH;EAACa,YAAA,CAAAnB,MAAA;IAAAoB,GAAA;IAAAC,KAAA,EAED,SAAAC,OAAA,EAAS;MACP;MACA,IAAI,IAAI,CAACT,WAAW,EAAE;QACpB,oBAAOd,QAAQ,CAACwB,YAAY,CAC1B,IAAI,CAAClB,KAAK,CAACmB,QAAQ,EACnB,IAAI,CAACX,WACP,CAAC;MACH;MACA;MACA,OAAO,IAAI;IACb;EAAC;EAAA,OAAAb,MAAA;AAAA,EA9BkBF,KAAK,CAAC2B,SAAS;AAiCpC,eAAezB,MAAM","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ function handleEnter(_ref) {
|
|
|
21
21
|
event.preventDefault();
|
|
22
22
|
}
|
|
23
23
|
function handleArrowKey(_ref2) {
|
|
24
|
+
var _nextElement;
|
|
24
25
|
var event = _ref2.event,
|
|
25
26
|
currentIndex = _ref2.currentIndex,
|
|
26
27
|
availableElements = _ref2.availableElements;
|
|
@@ -44,9 +45,7 @@ function handleArrowKey(_ref2) {
|
|
|
44
45
|
var _availableElements = _slicedToArray(availableElements, 1);
|
|
45
46
|
nextElement = _availableElements[0];
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line no-unused-expressions
|
|
49
|
-
nextElement && nextElement.focus();
|
|
48
|
+
(_nextElement = nextElement) === null || _nextElement === void 0 ? void 0 : _nextElement.focus();
|
|
50
49
|
event.preventDefault();
|
|
51
50
|
}
|
|
52
51
|
|