@toptal/picasso-modal 2.0.10 → 3.0.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-package/src/Modal/Modal.d.ts +5 -5
- package/dist-package/src/Modal/Modal.d.ts.map +1 -1
- package/dist-package/src/Modal/Modal.js +22 -21
- package/dist-package/src/Modal/Modal.js.map +1 -1
- package/dist-package/src/ModalActions/ModalActions.d.ts.map +1 -1
- package/dist-package/src/ModalActions/ModalActions.js +1 -7
- package/dist-package/src/ModalActions/ModalActions.js.map +1 -1
- package/dist-package/src/ModalCompound/index.d.ts +1 -1
- package/dist-package/src/ModalContent/ModalContent.d.ts.map +1 -1
- package/dist-package/src/ModalContent/ModalContent.js +6 -10
- package/dist-package/src/ModalContent/ModalContent.js.map +1 -1
- package/dist-package/src/ModalPaper/ModalPaper.d.ts +13 -0
- package/dist-package/src/ModalPaper/ModalPaper.d.ts.map +1 -0
- package/dist-package/src/ModalPaper/ModalPaper.js +43 -0
- package/dist-package/src/ModalPaper/ModalPaper.js.map +1 -0
- package/dist-package/src/ModalPaper/index.d.ts +2 -0
- package/dist-package/src/ModalPaper/index.d.ts.map +1 -0
- package/dist-package/src/ModalPaper/index.js +2 -0
- package/dist-package/src/ModalPaper/index.js.map +1 -0
- package/dist-package/src/ModalTitle/ModalTitle.d.ts.map +1 -1
- package/dist-package/src/ModalTitle/ModalTitle.js +1 -5
- package/dist-package/src/ModalTitle/ModalTitle.js.map +1 -1
- package/package.json +9 -5
- package/src/Modal/Modal.tsx +57 -48
- package/src/Modal/__snapshots__/test.tsx.snap +111 -134
- package/src/ModalActions/ModalActions.tsx +1 -10
- package/src/ModalContent/ModalContent.tsx +24 -13
- package/src/ModalPaper/ModalPaper.tsx +70 -0
- package/src/ModalPaper/index.ts +1 -0
- package/src/ModalTitle/ModalTitle.tsx +1 -9
- package/dist-package/src/Modal/styles.d.ts +0 -4
- package/dist-package/src/Modal/styles.d.ts.map +0 -1
- package/dist-package/src/Modal/styles.js +0 -67
- package/dist-package/src/Modal/styles.js.map +0 -1
- package/dist-package/src/ModalActions/styles.d.ts +0 -3
- package/dist-package/src/ModalActions/styles.d.ts.map +0 -1
- package/dist-package/src/ModalActions/styles.js +0 -8
- package/dist-package/src/ModalActions/styles.js.map +0 -1
- package/dist-package/src/ModalContent/styles.d.ts +0 -4
- package/dist-package/src/ModalContent/styles.d.ts.map +0 -1
- package/dist-package/src/ModalContent/styles.js +0 -31
- package/dist-package/src/ModalContent/styles.js.map +0 -1
- package/dist-package/src/ModalTitle/styles.d.ts +0 -3
- package/dist-package/src/ModalTitle/styles.d.ts.map +0 -1
- package/dist-package/src/ModalTitle/styles.js +0 -8
- package/dist-package/src/ModalTitle/styles.js.map +0 -1
- package/src/Modal/styles.ts +0 -75
- package/src/ModalActions/styles.ts +0 -9
- package/src/ModalContent/styles.ts +0 -43
- package/src/ModalTitle/styles.ts +0 -9
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
import type { StandardProps, SizeType, TransitionProps } from '@toptal/picasso-shared';
|
|
3
|
+
import type { BaseProps, SizeType, TransitionProps } from '@toptal/picasso-shared';
|
|
5
4
|
declare type ContainerValue = HTMLElement | (() => HTMLElement);
|
|
6
5
|
declare type Alignment = 'top' | 'centered';
|
|
7
|
-
export interface Props extends
|
|
6
|
+
export interface Props extends BaseProps, HTMLAttributes<HTMLDivElement> {
|
|
8
7
|
/** Content of Modal component */
|
|
9
8
|
children: ReactNode;
|
|
10
9
|
/** Whether modal should be displayed */
|
|
@@ -28,11 +27,12 @@ export interface Props extends StandardProps, HTMLAttributes<HTMLDivElement> {
|
|
|
28
27
|
/** Animation lifecycle callbacks. Backed by [react-transition-group/Transition](https://reactcommunity.org/react-transition-group/transition#Transition-props) */
|
|
29
28
|
transitionProps?: TransitionProps;
|
|
30
29
|
transitionDuration?: number;
|
|
31
|
-
|
|
30
|
+
/** used for specifying aria attributes, changing role, or customizing styles */
|
|
31
|
+
paperProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
32
32
|
testIds?: {
|
|
33
33
|
closeButton?: string;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
export declare const Modal: React.ForwardRefExoticComponent<Props & React.RefAttributes<
|
|
36
|
+
export declare const Modal: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
37
37
|
export default Modal;
|
|
38
38
|
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtD,OAAO,KAMN,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,eAAe,EAChB,MAAM,wBAAwB,CAAA;AAe/B,aAAK,cAAc,GAAG,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAA;AACvD,aAAK,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;AAEnC,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC;IACtE,iCAAiC;IACjC,QAAQ,EAAE,SAAS,CAAA;IACnB,wCAAwC;IACxC,IAAI,EAAE,OAAO,CAAA;IACb,qBAAqB;IACrB,IAAI,CAAC,EACD,QAAQ,CAAC,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC5D,aAAa,CAAA;IACjB,kDAAkD;IAClD,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;IAC5B,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,2GAA2G;IAC3G,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,8CAA8C;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,kKAAkK;IAClK,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;IACjD,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACF;AAuDD,eAAO,MAAM,KAAK,8EAuJhB,CAAA;AAYF,eAAe,KAAK,CAAA"}
|
|
@@ -9,19 +9,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
import { Modal as Dialog } from '@mui/base/Modal';
|
|
12
13
|
import React, { forwardRef, useEffect, useRef, useCallback, useContext, } from 'react';
|
|
13
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
14
|
-
import { Dialog } from '@material-ui/core';
|
|
15
14
|
import cx from 'classnames';
|
|
16
|
-
import { usePicassoRoot,
|
|
15
|
+
import { usePicassoRoot, RootContext } from '@toptal/picasso-provider';
|
|
17
16
|
import { CloseMinor16 } from '@toptal/picasso-icons';
|
|
18
17
|
import { useCombinedRefs, ModalManager, usePageScrollLock, } from '@toptal/picasso-utils';
|
|
19
18
|
import { ButtonCircular } from '@toptal/picasso-button';
|
|
19
|
+
import { Fade } from '@toptal/picasso-fade';
|
|
20
|
+
import { Backdrop } from '@toptal/picasso-backdrop';
|
|
20
21
|
import ModalContext from '@toptal/picasso-modal-context';
|
|
21
|
-
import
|
|
22
|
-
const useStyles = makeStyles(styles, {
|
|
23
|
-
name: 'PicassoModal',
|
|
24
|
-
});
|
|
22
|
+
import { ModalPaper } from '../ModalPaper';
|
|
25
23
|
const defaultManager = new ModalManager();
|
|
26
24
|
// https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution/modal.js#L25
|
|
27
25
|
// found in https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex
|
|
@@ -31,7 +29,9 @@ const focusFirstFocusableElement = (node) => {
|
|
|
31
29
|
const elements = node.querySelectorAll(focusableElementsString);
|
|
32
30
|
// Convert NodeList to Array
|
|
33
31
|
const focusableElements = Array.prototype.slice.call(elements);
|
|
34
|
-
focusableElements
|
|
32
|
+
if (focusableElements.length > 0) {
|
|
33
|
+
focusableElements[0].focus();
|
|
34
|
+
}
|
|
35
35
|
};
|
|
36
36
|
const isFocusInsideModal = (modalNode) => {
|
|
37
37
|
const modalContainsFocusedElement = modalNode.contains(document.activeElement);
|
|
@@ -58,7 +58,6 @@ const generateKey = (() => {
|
|
|
58
58
|
// eslint-disable-next-line react/display-name
|
|
59
59
|
export const Modal = forwardRef(function Modal(props, ref) {
|
|
60
60
|
const { children, open, size = 'medium', onBackdropClick, onClose, onOpen, className, style, container, hideBackdrop = false, transitionDuration = 300, paperProps, align = 'centered', testIds, transitionProps, disableBackdropClick = false } = props, rest = __rest(props, ["children", "open", "size", "onBackdropClick", "onClose", "onOpen", "className", "style", "container", "hideBackdrop", "transitionDuration", "paperProps", "align", "testIds", "transitionProps", "disableBackdropClick"]);
|
|
61
|
-
const classes = useStyles(props);
|
|
62
61
|
const picassoRootContainer = usePicassoRoot();
|
|
63
62
|
const modalRef = useCombinedRefs(ref, useRef(null));
|
|
64
63
|
const modalId = useRef(generateKey());
|
|
@@ -100,7 +99,6 @@ export const Modal = forwardRef(function Modal(props, ref) {
|
|
|
100
99
|
};
|
|
101
100
|
}, [open]);
|
|
102
101
|
usePageScrollLock(open);
|
|
103
|
-
const isExtraSmall = useBreakpoint('xs');
|
|
104
102
|
const handleClose = useCallback((_event, reason) => {
|
|
105
103
|
if (reason === 'escapeKeyDown' && onClose) {
|
|
106
104
|
onClose();
|
|
@@ -114,17 +112,20 @@ export const Modal = forwardRef(function Modal(props, ref) {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
}, [disableBackdropClick, onBackdropClick, onClose]);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
: true,
|
|
125
|
-
React.createElement(
|
|
126
|
-
|
|
127
|
-
|
|
115
|
+
const duration = (transitionProps === null || transitionProps === void 0 ? void 0 : transitionProps.timeout) || transitionDuration;
|
|
116
|
+
const backdropProps = { transitionDuration: duration };
|
|
117
|
+
return (React.createElement(Dialog, Object.assign({}, rest, { ref: modalRef, className: cx(className, 'fixed z-modal inset-0 flex flex-col text-lg leading-[normal] justify-center items-center'), style: style, slots: {
|
|
118
|
+
backdrop: Backdrop,
|
|
119
|
+
}, closeAfterTransition: true, slotProps: {
|
|
120
|
+
backdrop: backdropProps,
|
|
121
|
+
}, container: container || picassoRootContainer, hideBackdrop: hideBackdrop, onClose: handleClose, open: open, disableEnforceFocus // we need our own mechanism to keep focus inside the Modals
|
|
122
|
+
: true, disableScrollLock: true }),
|
|
123
|
+
React.createElement(Fade, { in: open, onEnter: onOpen, onExited: transitionProps === null || transitionProps === void 0 ? void 0 : transitionProps.onExited, timeout: transitionDuration },
|
|
124
|
+
React.createElement(ModalPaper, Object.assign({ size: size, align: align, tabIndex: -1 }, paperProps),
|
|
125
|
+
React.createElement(ModalContext.Provider, { value: true },
|
|
126
|
+
children,
|
|
127
|
+
onClose && (React.createElement(ButtonCircular, { "aria-label": 'Close', variant: 'flat', className: 'absolute top-8 right-8', onClick: onClose, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.closeButton },
|
|
128
|
+
React.createElement(CloseMinor16, null))))))));
|
|
128
129
|
});
|
|
129
130
|
Modal.defaultProps = {
|
|
130
131
|
hideBackdrop: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/Modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EACZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/Modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,EACZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,MAAM,YAAY,CAAA;AAM3B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,YAAY,MAAM,+BAA+B,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAsC1C,MAAM,cAAc,GAAG,IAAI,YAAY,EAAE,CAAA;AAEzC,kHAAkH;AAClH,6FAA6F;AAC7F,MAAM,uBAAuB,GAC3B,gLAAgL,CAAA;AAClL,MAAM,sBAAsB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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalActions.d.ts","sourceRoot":"","sources":["../../../src/ModalActions/ModalActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalActions.d.ts","sourceRoot":"","sources":["../../../src/ModalActions/ModalActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC;IACtE,oCAAoC;IACpC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,YAAY,8EAexB,CAAA;AAID,eAAe,YAAY,CAAA"}
|
|
@@ -10,16 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef } from 'react';
|
|
13
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
14
13
|
import cx from 'classnames';
|
|
15
|
-
import styles from './styles';
|
|
16
|
-
const useStyles = makeStyles(styles, {
|
|
17
|
-
name: 'PicassoModalAction',
|
|
18
|
-
});
|
|
19
14
|
export const ModalActions = forwardRef(function ModalActions(props, ref) {
|
|
20
15
|
const { children, className, style } = props, rest = __rest(props, ["children", "className", "style"]);
|
|
21
|
-
|
|
22
|
-
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cx(classes.root, className), style: style }), children));
|
|
16
|
+
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cx('mt-0 mx-8 mb-8 text-right', className), style: style }), children));
|
|
23
17
|
});
|
|
24
18
|
ModalActions.displayName = 'ModalActions';
|
|
25
19
|
export default ModalActions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalActions.js","sourceRoot":"","sources":["../../../src/ModalActions/ModalActions.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalActions.js","sourceRoot":"","sources":["../../../src/ModalActions/ModalActions.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,MAAM,YAAY,CAAA;AAQ3B,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG;IAC9B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA/C,kCAAuC,CAAQ,CAAA;IAErD,OAAO,CACL,6CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,EACrD,KAAK,EAAE,KAAK,KAEX,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAEzC,eAAe,YAAY,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const ModalCompound: import("react").ForwardRefExoticComponent<import("../Modal").Props & import("react").RefAttributes<
|
|
2
|
+
export declare const ModalCompound: import("react").ForwardRefExoticComponent<import("../Modal").Props & import("react").RefAttributes<HTMLDivElement>> & {
|
|
3
3
|
Content: import("react").ForwardRefExoticComponent<import("../ModalContent/ModalContent").Props & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
4
|
Actions: import("react").ForwardRefExoticComponent<import("../ModalActions/ModalActions").Props & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
5
|
Title: import("react").ForwardRefExoticComponent<import("../ModalTitle/ModalTitle").Props & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContent.d.ts","sourceRoot":"","sources":["../../../src/ModalContent/ModalContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalContent.d.ts","sourceRoot":"","sources":["../../../src/ModalContent/ModalContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAKvD,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC;IACtE,uBAAuB;IACvB,QAAQ,EAAE,SAAS,CAAA;CACpB;AACD,eAAO,MAAM,YAAY,8EAgDxB,CAAA;AAID,eAAe,YAAY,CAAA"}
|
|
@@ -10,14 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef } from 'react';
|
|
13
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
14
13
|
import cx from 'classnames';
|
|
15
14
|
import { useCombinedRefs } from '@toptal/picasso-utils';
|
|
16
|
-
import styles from './styles';
|
|
17
15
|
import useScrollableShades from './hooks/use-scrollable-shades';
|
|
18
|
-
const useStyles = makeStyles(styles, {
|
|
19
|
-
name: 'PicassoModalContent',
|
|
20
|
-
});
|
|
21
16
|
export const ModalContent = forwardRef(function ModalContent(props, ref) {
|
|
22
17
|
const { children, className, style } = props, rest = __rest(props
|
|
23
18
|
/**
|
|
@@ -31,11 +26,12 @@ export const ModalContent = forwardRef(function ModalContent(props, ref) {
|
|
|
31
26
|
*/
|
|
32
27
|
const modalContentRef = useCombinedRefs(ref);
|
|
33
28
|
const { top, bottom } = useScrollableShades(modalContentRef);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
React.createElement("div",
|
|
29
|
+
const shadeClasses = 'z-[1] absolute pointer-events-none right-8 left-8 h-[112px]';
|
|
30
|
+
const gradientClasses = 'from-white to-transparent to-100% from-0% via-[2rem] via-white';
|
|
31
|
+
return (React.createElement("div", { className: 'flex relative flex-auto overflow-y-hidden' },
|
|
32
|
+
top && (React.createElement("div", { className: cx(shadeClasses, gradientClasses, 'top-0 bg-gradient-to-b') })),
|
|
33
|
+
bottom && (React.createElement("div", { className: cx(shadeClasses, gradientClasses, 'bottom-0 bg-gradient-to-t') })),
|
|
34
|
+
React.createElement("div", Object.assign({}, rest, { style: style, ref: modalContentRef, className: cx('pt-6 px-8 pb-8 overflow-auto flex-auto', className) }), children)));
|
|
39
35
|
});
|
|
40
36
|
ModalContent.displayName = 'ModalContent';
|
|
41
37
|
export default ModalContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContent.js","sourceRoot":"","sources":["../../../src/ModalContent/ModalContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalContent.js","sourceRoot":"","sources":["../../../src/ModalContent/ModalContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,mBAAmB,MAAM,+BAA+B,CAAA;AAM/D,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG;IAC9B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK;IAErD;;;OAGG;MALG,kCAAuC,CAAQ,CAAA;IAErD;;;OAGG;IACH,MAAM,eAAe,GAAG,eAAe,CAAiB,GAAG,CAAC,CAAA;IAE5D,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAA;IAE5D,MAAM,YAAY,GAChB,6DAA6D,CAAA;IAC/D,MAAM,eAAe,GACnB,gEAAgE,CAAA;IAElE,OAAO,CACL,6BAAK,SAAS,EAAC,2CAA2C;QACvD,GAAG,IAAI,CACN,6BACE,SAAS,EAAE,EAAE,CACX,YAAY,EACZ,eAAe,EACf,wBAAwB,CACzB,GACD,CACH;QACA,MAAM,IAAI,CACT,6BACE,SAAS,EAAE,EAAE,CACX,YAAY,EACZ,eAAe,EACf,2BAA2B,CAC5B,GACD,CACH;QACD,6CACM,IAAI,IACR,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,EAAE,CAAC,wCAAwC,EAAE,SAAS,CAAC,KAEjE,QAAQ,CACL,CACF,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAEzC,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SizeType } from '@toptal/picasso-shared';
|
|
3
|
+
declare type PaperSize = SizeType<'xsmall' | 'small' | 'medium' | 'large' | 'xlarge'> | 'full-screen';
|
|
4
|
+
declare type Alignment = 'top' | 'centered';
|
|
5
|
+
interface Props extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
align: Alignment;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Width of modal */
|
|
9
|
+
size: PaperSize;
|
|
10
|
+
}
|
|
11
|
+
export declare const ModalPaper: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export default ModalPaper;
|
|
13
|
+
//# sourceMappingURL=ModalPaper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalPaper.d.ts","sourceRoot":"","sources":["../../../src/ModalPaper/ModalPaper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAGtD,aAAK,SAAS,GACV,QAAQ,CAAC,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC5D,aAAa,CAAA;AACjB,aAAK,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;AAEnC,UAAU,KAAM,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC1D,KAAK,EAAE,SAAS,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAA;CAChB;AA+BD,eAAO,MAAM,UAAU,8EAqBtB,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import cx from 'classnames';
|
|
14
|
+
import { Paper } from '@toptal/picasso-paper';
|
|
15
|
+
const fullscreenClasses = `h-full w-full max-h-full max-w-full`;
|
|
16
|
+
const defaultClasses = `m-4 sm:h-auto sm:m-8 max-w-[calc(100%_-_2rem)] sm:max-w-[calc(100%_-_6rem)] rounded-md`;
|
|
17
|
+
const sizeBasedClasses = {
|
|
18
|
+
xsmall: `${defaultClasses} w-[20.5rem]`,
|
|
19
|
+
small: `${defaultClasses} w-[32.5rem]`,
|
|
20
|
+
medium: `${defaultClasses} w-[40.625rem]`,
|
|
21
|
+
large: `${defaultClasses} w-[50rem]`,
|
|
22
|
+
xlarge: `${defaultClasses} w-[75rem]`,
|
|
23
|
+
'full-screen': fullscreenClasses,
|
|
24
|
+
};
|
|
25
|
+
const alignBasedClasses = {
|
|
26
|
+
centered: 'relative',
|
|
27
|
+
top: 'absolute top-0',
|
|
28
|
+
};
|
|
29
|
+
const getMaxHeightClass = (size, align) => {
|
|
30
|
+
if (size === 'full-screen') {
|
|
31
|
+
return 'max-h-full';
|
|
32
|
+
}
|
|
33
|
+
if (align === 'top') {
|
|
34
|
+
return `max-h-[calc(100%_-_2rem)] sm:max-h-[calc(100%_-_4rem)]`;
|
|
35
|
+
}
|
|
36
|
+
return `max-h-[calc(100%_-_2rem)] sm:max-h-[calc(100%_-_6rem)]`;
|
|
37
|
+
};
|
|
38
|
+
export const ModalPaper = React.forwardRef(function ModalPaper(_a, ref) {
|
|
39
|
+
var { children, size, align, className } = _a, props = __rest(_a, ["children", "size", "align", "className"]);
|
|
40
|
+
return (React.createElement(Paper, Object.assign({ ref: ref, role: 'dialog', elevation: 2, className: cx(className, 'outline-none overflow-y-auto', 'flex flex-col', sizeBasedClasses[size], alignBasedClasses[align], getMaxHeightClass(size, align)) }, props), children));
|
|
41
|
+
});
|
|
42
|
+
export default ModalPaper;
|
|
43
|
+
//# sourceMappingURL=ModalPaper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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eAAe,EACf,gBAAgB,CAAC,IAAI,CAAC,EACtB,iBAAiB,CAAC,KAAK,CAAC,EACxB,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAC/B,IACG,KAAK,GAER,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ModalPaper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ModalPaper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalTitle.d.ts","sourceRoot":"","sources":["../../../src/ModalTitle/ModalTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalTitle.d.ts","sourceRoot":"","sources":["../../../src/ModalTitle/ModalTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGvD,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC;IACtE,oBAAoB;IACpB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,UAAU,8EAkBrB,CAAA;AAIF,eAAe,UAAU,CAAA"}
|
|
@@ -10,15 +10,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef } from 'react';
|
|
13
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
14
13
|
import cx from 'classnames';
|
|
15
14
|
import { Typography } from '@toptal/picasso-typography';
|
|
16
|
-
import styles from './styles';
|
|
17
|
-
const useStyles = makeStyles(styles, { name: 'PicassoModalTitle' });
|
|
18
15
|
export const ModalTitle = forwardRef(function ModalTitle(props, ref) {
|
|
19
16
|
const { children, className, style } = props, rest = __rest(props, ["children", "className", "style"]);
|
|
20
|
-
|
|
21
|
-
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cx(classes.root, className), style: style }),
|
|
17
|
+
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cx('pr-6 mt-8 mx-8 mb-0', className), style: style }),
|
|
22
18
|
React.createElement(Typography, { variant: 'heading', size: 'large' }, children)));
|
|
23
19
|
});
|
|
24
20
|
ModalTitle.displayName = 'ModalTitle';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalTitle.js","sourceRoot":"","sources":["../../../src/ModalTitle/ModalTitle.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ModalTitle.js","sourceRoot":"","sources":["../../../src/ModalTitle/ModalTitle.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAOvD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAwB,SAAS,UAAU,CAC7E,KAAK,EACL,GAAG;IAEH,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA/C,kCAAuC,CAAQ,CAAA;IAErD,OAAO,CACL,6CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC/C,KAAK,EAAE,KAAK;QAEZ,oBAAC,UAAU,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,OAAO,IACvC,QAAQ,CACE,CACT,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAErC,eAAe,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-modal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Toptal UI components library - Modal",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,9 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@mui/base": "5.0.0-beta.40",
|
|
26
|
+
"@toptal/picasso-backdrop": "1.0.5",
|
|
27
|
+
"@toptal/picasso-fade": "1.0.5",
|
|
28
|
+
"@toptal/picasso-paper": "3.0.0",
|
|
29
|
+
"@toptal/picasso-shared": "15.0.0",
|
|
30
|
+
"@toptal/picasso-button": "3.0.0",
|
|
26
31
|
"@toptal/picasso-icons": "1.5.0",
|
|
27
|
-
"@toptal/picasso-typography": "
|
|
32
|
+
"@toptal/picasso-typography": "3.0.0",
|
|
28
33
|
"@toptal/picasso-utils": "1.0.3",
|
|
29
34
|
"@toptal/picasso-modal-context": "1.0.1",
|
|
30
35
|
"classnames": "^2.5.1",
|
|
@@ -35,7 +40,6 @@
|
|
|
35
40
|
"**/styles.js"
|
|
36
41
|
],
|
|
37
42
|
"peerDependencies": {
|
|
38
|
-
"@material-ui/core": "4.12.4",
|
|
39
43
|
"@toptal/picasso-provider": "*",
|
|
40
44
|
"react": ">=16.12.0 < 19.0.0",
|
|
41
45
|
"@toptal/picasso-tailwind": ">=2.5.0"
|
|
@@ -44,7 +48,7 @@
|
|
|
44
48
|
".": "./dist-package/src/index.js"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@toptal/picasso-provider": "
|
|
51
|
+
"@toptal/picasso-provider": "5.0.0",
|
|
48
52
|
"@toptal/picasso-test-utils": "1.1.1"
|
|
49
53
|
},
|
|
50
54
|
"files": [
|
package/src/Modal/Modal.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode, HTMLAttributes } from 'react'
|
|
2
|
+
import { Modal as Dialog } from '@mui/base/Modal'
|
|
2
3
|
import React, {
|
|
3
4
|
forwardRef,
|
|
4
5
|
useEffect,
|
|
@@ -6,21 +7,13 @@ import React, {
|
|
|
6
7
|
useCallback,
|
|
7
8
|
useContext,
|
|
8
9
|
} from 'react'
|
|
9
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
10
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
11
|
-
import { Dialog } from '@material-ui/core'
|
|
12
|
-
import type { PaperProps } from '@material-ui/core/Paper'
|
|
13
10
|
import cx from 'classnames'
|
|
14
11
|
import type {
|
|
15
|
-
|
|
12
|
+
BaseProps,
|
|
16
13
|
SizeType,
|
|
17
14
|
TransitionProps,
|
|
18
15
|
} from '@toptal/picasso-shared'
|
|
19
|
-
import {
|
|
20
|
-
usePicassoRoot,
|
|
21
|
-
useBreakpoint,
|
|
22
|
-
RootContext,
|
|
23
|
-
} from '@toptal/picasso-provider'
|
|
16
|
+
import { usePicassoRoot, RootContext } from '@toptal/picasso-provider'
|
|
24
17
|
import { CloseMinor16 } from '@toptal/picasso-icons'
|
|
25
18
|
import {
|
|
26
19
|
useCombinedRefs,
|
|
@@ -28,14 +21,16 @@ import {
|
|
|
28
21
|
usePageScrollLock,
|
|
29
22
|
} from '@toptal/picasso-utils'
|
|
30
23
|
import { ButtonCircular } from '@toptal/picasso-button'
|
|
24
|
+
import { Fade } from '@toptal/picasso-fade'
|
|
25
|
+
import { Backdrop } from '@toptal/picasso-backdrop'
|
|
31
26
|
import ModalContext from '@toptal/picasso-modal-context'
|
|
32
27
|
|
|
33
|
-
import
|
|
28
|
+
import { ModalPaper } from '../ModalPaper'
|
|
34
29
|
|
|
35
30
|
type ContainerValue = HTMLElement | (() => HTMLElement)
|
|
36
31
|
type Alignment = 'top' | 'centered'
|
|
37
32
|
|
|
38
|
-
export interface Props extends
|
|
33
|
+
export interface Props extends BaseProps, HTMLAttributes<HTMLDivElement> {
|
|
39
34
|
/** Content of Modal component */
|
|
40
35
|
children: ReactNode
|
|
41
36
|
/** Whether modal should be displayed */
|
|
@@ -61,15 +56,13 @@ export interface Props extends StandardProps, HTMLAttributes<HTMLDivElement> {
|
|
|
61
56
|
/** Animation lifecycle callbacks. Backed by [react-transition-group/Transition](https://reactcommunity.org/react-transition-group/transition#Transition-props) */
|
|
62
57
|
transitionProps?: TransitionProps
|
|
63
58
|
transitionDuration?: number
|
|
64
|
-
|
|
59
|
+
/** used for specifying aria attributes, changing role, or customizing styles */
|
|
60
|
+
paperProps?: React.HTMLAttributes<HTMLDivElement>
|
|
65
61
|
testIds?: {
|
|
66
62
|
closeButton?: string
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
const useStyles = makeStyles<Theme, Props>(styles, {
|
|
71
|
-
name: 'PicassoModal',
|
|
72
|
-
})
|
|
73
66
|
const defaultManager = new ModalManager()
|
|
74
67
|
|
|
75
68
|
// https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution/modal.js#L25
|
|
@@ -83,7 +76,9 @@ const focusFirstFocusableElement = (node: Element) => {
|
|
|
83
76
|
// Convert NodeList to Array
|
|
84
77
|
const focusableElements = Array.prototype.slice.call(elements)
|
|
85
78
|
|
|
86
|
-
focusableElements
|
|
79
|
+
if (focusableElements.length > 0) {
|
|
80
|
+
focusableElements[0].focus()
|
|
81
|
+
}
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
const isFocusInsideModal = (modalNode: Element) => {
|
|
@@ -121,7 +116,10 @@ const generateKey = (() => {
|
|
|
121
116
|
})()
|
|
122
117
|
|
|
123
118
|
// eslint-disable-next-line react/display-name
|
|
124
|
-
export const Modal = forwardRef<
|
|
119
|
+
export const Modal = forwardRef<HTMLDivElement, Props>(function Modal(
|
|
120
|
+
props,
|
|
121
|
+
ref
|
|
122
|
+
) {
|
|
125
123
|
const {
|
|
126
124
|
children,
|
|
127
125
|
open,
|
|
@@ -141,9 +139,11 @@ export const Modal = forwardRef<HTMLElement, Props>(function Modal(props, ref) {
|
|
|
141
139
|
disableBackdropClick = false,
|
|
142
140
|
...rest
|
|
143
141
|
} = props
|
|
144
|
-
const classes = useStyles(props)
|
|
145
142
|
const picassoRootContainer = usePicassoRoot()
|
|
146
|
-
const modalRef = useCombinedRefs<
|
|
143
|
+
const modalRef = useCombinedRefs<HTMLDivElement>(
|
|
144
|
+
ref,
|
|
145
|
+
useRef<HTMLDivElement>(null)
|
|
146
|
+
)
|
|
147
147
|
const modalId = useRef(generateKey())
|
|
148
148
|
const { rootRef } = useContext(RootContext)
|
|
149
149
|
|
|
@@ -199,8 +199,6 @@ export const Modal = forwardRef<HTMLElement, Props>(function Modal(props, ref) {
|
|
|
199
199
|
|
|
200
200
|
usePageScrollLock(open)
|
|
201
201
|
|
|
202
|
-
const isExtraSmall = useBreakpoint('xs')
|
|
203
|
-
|
|
204
202
|
const handleClose = useCallback(
|
|
205
203
|
(_event, reason: 'backdropClick' | 'escapeKeyDown') => {
|
|
206
204
|
if (reason === 'escapeKeyDown' && onClose) {
|
|
@@ -218,44 +216,55 @@ export const Modal = forwardRef<HTMLElement, Props>(function Modal(props, ref) {
|
|
|
218
216
|
[disableBackdropClick, onBackdropClick, onClose]
|
|
219
217
|
)
|
|
220
218
|
|
|
219
|
+
const duration = transitionProps?.timeout || transitionDuration
|
|
220
|
+
const backdropProps = { transitionDuration: duration }
|
|
221
|
+
|
|
221
222
|
return (
|
|
222
223
|
<Dialog
|
|
223
224
|
{...rest}
|
|
224
225
|
ref={modalRef}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
[classes.topAlignedDialog]: align === 'top',
|
|
230
|
-
}),
|
|
231
|
-
}}
|
|
232
|
-
className={className}
|
|
226
|
+
className={cx(
|
|
227
|
+
className,
|
|
228
|
+
'fixed z-modal inset-0 flex flex-col text-lg leading-[normal] justify-center items-center'
|
|
229
|
+
)}
|
|
233
230
|
style={style}
|
|
234
|
-
|
|
231
|
+
slots={{
|
|
232
|
+
backdrop: Backdrop,
|
|
233
|
+
}}
|
|
234
|
+
closeAfterTransition
|
|
235
|
+
slotProps={{
|
|
236
|
+
backdrop: backdropProps,
|
|
237
|
+
}}
|
|
235
238
|
container={container || picassoRootContainer}
|
|
236
|
-
PaperProps={{ ...paperProps, elevation: 2 }}
|
|
237
239
|
hideBackdrop={hideBackdrop}
|
|
238
240
|
onClose={handleClose}
|
|
239
|
-
onEnter={onOpen}
|
|
240
241
|
open={open}
|
|
241
|
-
transitionDuration={transitionDuration}
|
|
242
|
-
maxWidth={false}
|
|
243
242
|
disableEnforceFocus // we need our own mechanism to keep focus inside the Modals
|
|
244
|
-
TransitionProps={transitionProps}
|
|
245
243
|
disableScrollLock
|
|
246
244
|
>
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
<Fade
|
|
246
|
+
in={open}
|
|
247
|
+
onEnter={onOpen}
|
|
248
|
+
onExited={transitionProps?.onExited}
|
|
249
|
+
timeout={transitionDuration}
|
|
250
|
+
>
|
|
251
|
+
<ModalPaper size={size} align={align} tabIndex={-1} {...paperProps}>
|
|
252
|
+
<ModalContext.Provider value>
|
|
253
|
+
{children}
|
|
254
|
+
{onClose && (
|
|
255
|
+
<ButtonCircular
|
|
256
|
+
aria-label='Close'
|
|
257
|
+
variant='flat'
|
|
258
|
+
className='absolute top-8 right-8'
|
|
259
|
+
onClick={onClose}
|
|
260
|
+
data-testid={testIds?.closeButton}
|
|
261
|
+
>
|
|
262
|
+
<CloseMinor16 />
|
|
263
|
+
</ButtonCircular>
|
|
264
|
+
)}
|
|
265
|
+
</ModalContext.Provider>
|
|
266
|
+
</ModalPaper>
|
|
267
|
+
</Fade>
|
|
259
268
|
</Dialog>
|
|
260
269
|
)
|
|
261
270
|
})
|