@mezzanine-ui/react 0.7.1 → 0.7.2
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/Drawer/Drawer.d.ts +2 -7
- package/Drawer/Drawer.js +5 -21
- package/Icon/Icon.d.ts +4 -0
- package/Icon/Icon.js +3 -2
- package/Modal/Modal.d.ts +2 -7
- package/Modal/Modal.js +8 -57
- package/Modal/index.d.ts +1 -0
- package/Modal/index.js +1 -0
- package/Modal/useModalContainer.d.ts +6 -0
- package/Modal/useModalContainer.js +27 -0
- package/Transition/Transition.d.ts +1 -1
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +21 -0
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +66 -0
- package/_internal/SlideFadeOverlay/index.d.ts +1 -0
- package/_internal/SlideFadeOverlay/index.js +1 -0
- package/_internal/SlideFadeOverlay/useTopStack.d.ts +1 -0
- package/{Modal/useIsTopModal.js → _internal/SlideFadeOverlay/useTopStack.js} +3 -3
- package/index.d.ts +1 -1
- package/index.js +1 -0
- package/package.json +2 -2
- package/Modal/useIsTopModal.d.ts +0 -1
package/Drawer/Drawer.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DrawerPlacement } from '@mezzanine-ui/core/drawer';
|
|
3
|
-
import {
|
|
3
|
+
import { SlideFadeOverlayProps } from '../_internal/SlideFadeOverlay';
|
|
4
4
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
|
-
export interface DrawerProps extends
|
|
6
|
-
/**
|
|
7
|
-
* Controls whether to disable closing drawer while escape key down.
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
disableCloseOnEscapeKeyDown?: boolean;
|
|
5
|
+
export interface DrawerProps extends Omit<SlideFadeOverlayProps, 'children'>, Pick<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
11
6
|
/**
|
|
12
7
|
* Whether the drawer placement.
|
|
13
8
|
* @default 'left'
|
package/Drawer/Drawer.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef,
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
3
|
import { drawerClasses } from '@mezzanine-ui/core/drawer';
|
|
4
|
-
import
|
|
5
|
-
import Overlay from '../Overlay/Overlay.js';
|
|
6
|
-
import SlideFade from '../Transition/SlideFade.js';
|
|
4
|
+
import SlideFadeOverlay from '../_internal/SlideFadeOverlay/SlideFadeOverlay.js';
|
|
7
5
|
import cx from 'clsx';
|
|
8
6
|
|
|
9
7
|
const Drawer = forwardRef((props, ref) => {
|
|
10
8
|
const { className, children, container, disableCloseOnBackdropClick = false, disableCloseOnEscapeKeyDown = false, disablePortal, hideBackdrop, invisibleBackdrop, onBackdropClick, onClose, open, placement = 'left', ...rest } = props;
|
|
11
|
-
const
|
|
12
|
-
useDocumentEscapeKeyDown(() => {
|
|
13
|
-
if (!open || disableCloseOnEscapeKeyDown || !onClose) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
return onClose;
|
|
17
|
-
}, [
|
|
18
|
-
disableCloseOnEscapeKeyDown,
|
|
19
|
-
open,
|
|
20
|
-
onClose,
|
|
21
|
-
]);
|
|
22
|
-
if (!open && exited) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const slideFadeDirection = {
|
|
9
|
+
const slideFadeDirection = useMemo(() => ({
|
|
26
10
|
top: 'down',
|
|
27
11
|
left: 'right',
|
|
28
12
|
right: 'left',
|
|
29
13
|
bottom: 'up',
|
|
30
|
-
};
|
|
31
|
-
return (jsx(
|
|
14
|
+
}), []);
|
|
15
|
+
return (jsx(SlideFadeOverlay, Object.assign({ className: drawerClasses.overlay, container: container, direction: slideFadeDirection[placement], disableCloseOnBackdropClick: disableCloseOnBackdropClick, disableCloseOnEscapeKeyDown: disableCloseOnEscapeKeyDown, disablePortal: disablePortal, hideBackdrop: hideBackdrop, invisibleBackdrop: invisibleBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, ref: ref }, { children: jsx("div", Object.assign({}, rest, { className: cx(drawerClasses.host, drawerClasses[placement], className) }, { children: children }), void 0) }), void 0));
|
|
32
16
|
});
|
|
33
17
|
var Drawer$1 = Drawer;
|
|
34
18
|
|
package/Icon/Icon.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface IconProps extends NativeElementPropsWithoutKeyAndRef<'i'> {
|
|
|
11
11
|
* The icon provided by `@mezzanine-ui/icons` package.
|
|
12
12
|
*/
|
|
13
13
|
icon: IconDefinition;
|
|
14
|
+
/**
|
|
15
|
+
* Icon size in px
|
|
16
|
+
*/
|
|
17
|
+
size?: number;
|
|
14
18
|
/**
|
|
15
19
|
* Whether to spin the icon or not.
|
|
16
20
|
* @default false
|
package/Icon/Icon.js
CHANGED
|
@@ -7,9 +7,9 @@ import cx from 'clsx';
|
|
|
7
7
|
* The react component for `mezzanine` icon.
|
|
8
8
|
*/
|
|
9
9
|
const Icon = forwardRef(function Icon(props, ref) {
|
|
10
|
-
const { className, color, icon, spin = false, style: styleProp, ...rest } = props;
|
|
10
|
+
const { className, color, icon, size, spin = false, style: styleProp, ...rest } = props;
|
|
11
11
|
const { definition } = icon;
|
|
12
|
-
const cssVars = toIconCssVars({ color });
|
|
12
|
+
const cssVars = toIconCssVars({ color, size });
|
|
13
13
|
const style = {
|
|
14
14
|
...cssVars,
|
|
15
15
|
...styleProp,
|
|
@@ -17,6 +17,7 @@ const Icon = forwardRef(function Icon(props, ref) {
|
|
|
17
17
|
return (jsx("i", Object.assign({}, rest, { ref: ref, "aria-hidden": true, className: cx(iconClasses.host, {
|
|
18
18
|
[iconClasses.color]: color,
|
|
19
19
|
[iconClasses.spin]: spin,
|
|
20
|
+
[iconClasses.size]: size,
|
|
20
21
|
}, className), "data-icon-name": icon.name, style: style }, { children: jsx("svg", Object.assign({}, definition.svg, { focusable: false }, { children: jsx("path", Object.assign({}, definition.path), void 0) }), void 0) }), void 0));
|
|
21
22
|
});
|
|
22
23
|
var Icon$1 = Icon;
|
package/Modal/Modal.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModalSeverity, ModalSize } from '@mezzanine-ui/core/modal';
|
|
3
|
+
import { SlideFadeOverlayProps } from '../_internal/SlideFadeOverlay';
|
|
3
4
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
|
-
|
|
5
|
-
export interface ModalProps extends NativeElementPropsWithoutKeyAndRef<'div'>, Pick<OverlayProps, 'container' | 'disableCloseOnBackdropClick' | 'disablePortal' | 'hideBackdrop' | 'onBackdropClick' | 'onClose' | 'open'> {
|
|
6
|
-
/**
|
|
7
|
-
* Controls whether to disable closing modal while escape key down.
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
disableCloseOnEscapeKeyDown?: boolean;
|
|
5
|
+
export interface ModalProps extends Omit<SlideFadeOverlayProps, 'children'>, Pick<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
11
6
|
/**
|
|
12
7
|
* Whether to force full screen on any breakpoint.
|
|
13
8
|
* @default false
|
package/Modal/Modal.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { modalClasses } from '@mezzanine-ui/core/modal';
|
|
3
3
|
import { TimesIcon } from '@mezzanine-ui/icons';
|
|
4
|
-
import { forwardRef
|
|
5
|
-
import { useDocumentEscapeKeyDown } from '../hooks/useDocumentEscapeKeyDown.js';
|
|
6
|
-
import { lockBodyScroll, allowBodyScroll } from '../utils/scroll-lock.js';
|
|
7
|
-
import { useIsTopModal } from './useIsTopModal.js';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
8
5
|
import { ModalControlContext } from './ModalControl.js';
|
|
9
|
-
import
|
|
10
|
-
import SlideFade from '../Transition/SlideFade.js';
|
|
6
|
+
import useModalContainer from './useModalContainer.js';
|
|
11
7
|
import Icon from '../Icon/Icon.js';
|
|
12
8
|
import cx from 'clsx';
|
|
13
9
|
|
|
@@ -15,61 +11,16 @@ import cx from 'clsx';
|
|
|
15
11
|
* The react component for `mezzanine` modal.
|
|
16
12
|
*/
|
|
17
13
|
const Modal = forwardRef(function Modal(props, ref) {
|
|
18
|
-
const { children, className, container, disableCloseOnBackdropClick = false, disableCloseOnEscapeKeyDown = false, disablePortal, fullScreen = false, hideBackdrop, hideCloseIcon = false, loading = false, onBackdropClick, onClose, open, severity = 'info', size = 'medium', ...rest } = props;
|
|
14
|
+
const { children, className, container, disableCloseOnBackdropClick = false, disableCloseOnEscapeKeyDown = false, disablePortal = false, fullScreen = false, hideBackdrop = false, hideCloseIcon = false, invisibleBackdrop = false, loading = false, onBackdropClick, onClose, open, severity = 'info', size = 'medium', ...rest } = props;
|
|
19
15
|
const modalControl = {
|
|
20
16
|
loading,
|
|
21
17
|
severity,
|
|
22
18
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
useDocumentEscapeKeyDown(() => {
|
|
29
|
-
if (!open || disableCloseOnEscapeKeyDown || !onClose) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
return (event) => {
|
|
33
|
-
if (isTopModal()) {
|
|
34
|
-
event.stopPropagation();
|
|
35
|
-
onClose();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}, [
|
|
39
|
-
disableCloseOnEscapeKeyDown,
|
|
40
|
-
isTopModal,
|
|
41
|
-
open,
|
|
42
|
-
onClose,
|
|
43
|
-
]);
|
|
44
|
-
/** lock body scroll */
|
|
45
|
-
useLayoutEffect(() => {
|
|
46
|
-
if (open) {
|
|
47
|
-
lockBodyScroll();
|
|
48
|
-
}
|
|
49
|
-
}, [open]);
|
|
50
|
-
/** unlock body scroll */
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
function checkAndAllowScroll() {
|
|
53
|
-
// wait until dom element unmount, and check if other modal existed
|
|
54
|
-
const allModals = document.querySelectorAll('.mzn-modal');
|
|
55
|
-
if (!allModals.length) {
|
|
56
|
-
allowBodyScroll();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (!open && exited) {
|
|
60
|
-
checkAndAllowScroll();
|
|
61
|
-
}
|
|
62
|
-
return (() => {
|
|
63
|
-
requestAnimationFrame(checkAndAllowScroll);
|
|
64
|
-
});
|
|
65
|
-
}, [open, exited]);
|
|
66
|
-
if (!open && exited) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return (jsx(Overlay, Object.assign({ className: modalClasses.overlay, container: container, disableCloseOnBackdropClick: disableCloseOnBackdropClick, disablePortal: disablePortal, hideBackdrop: hideBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, role: "presentation" }, { children: jsx(ModalControlContext.Provider, Object.assign({ value: modalControl }, { children: jsx(SlideFade, Object.assign({ ref: ref, in: open, direction: "down", onEntered: () => setExited(false), onExited: () => setExited(true) }, { children: jsxs("div", Object.assign({}, rest, { className: cx(modalClasses.host, modalClasses.severity(severity), modalClasses.size(size), {
|
|
70
|
-
[modalClasses.fullScreen]: fullScreen,
|
|
71
|
-
[modalClasses.withCloseIcon]: !hideCloseIcon,
|
|
72
|
-
}, className), role: "dialog" }, { children: [children, !hideCloseIcon && (jsx(Icon, { className: modalClasses.closeIcon, icon: TimesIcon, onClick: onClose }, void 0))] }), void 0) }), void 0) }), void 0) }), void 0));
|
|
19
|
+
const { Container: ModalContainer } = useModalContainer();
|
|
20
|
+
return (jsx(ModalControlContext.Provider, Object.assign({ value: modalControl }, { children: jsx(ModalContainer, Object.assign({ className: modalClasses.overlay, container: container, direction: "down", disableCloseOnBackdropClick: disableCloseOnBackdropClick, disableCloseOnEscapeKeyDown: disableCloseOnEscapeKeyDown, disablePortal: disablePortal, hideBackdrop: hideBackdrop, invisibleBackdrop: invisibleBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, ref: ref }, { children: jsxs("div", Object.assign({}, rest, { className: cx(modalClasses.host, modalClasses.severity(severity), modalClasses.size(size), {
|
|
21
|
+
[modalClasses.fullScreen]: fullScreen,
|
|
22
|
+
[modalClasses.withCloseIcon]: !hideCloseIcon,
|
|
23
|
+
}, className), role: "dialog" }, { children: [children, !hideCloseIcon && (jsx(Icon, { className: modalClasses.closeIcon, icon: TimesIcon, onClick: onClose }, void 0))] }), void 0) }), void 0) }), void 0));
|
|
73
24
|
});
|
|
74
25
|
var Modal$1 = Modal;
|
|
75
26
|
|
package/Modal/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { ModalActionsProps, default as ModalActions, } from './ModalActions';
|
|
|
3
3
|
export { ModalBodyProps, default as ModalBody, } from './ModalBody';
|
|
4
4
|
export { ModalFooterProps, default as ModalFooter, } from './ModalFooter';
|
|
5
5
|
export { ModalHeaderProps, default as ModalHeader, } from './ModalHeader';
|
|
6
|
+
export { default as useModalContainer, } from './useModalContainer';
|
|
6
7
|
export { ModalProps, default, } from './Modal';
|
package/Modal/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { default as ModalActions } from './ModalActions.js';
|
|
|
2
2
|
export { default as ModalBody } from './ModalBody.js';
|
|
3
3
|
export { default as ModalFooter } from './ModalFooter.js';
|
|
4
4
|
export { default as ModalHeader } from './ModalHeader.js';
|
|
5
|
+
export { default as useModalContainer } from './useModalContainer.js';
|
|
5
6
|
export { default } from './Modal.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SlideFadeOverlayProps } from '../_internal/SlideFadeOverlay';
|
|
3
|
+
export default function useModalContainer(): {
|
|
4
|
+
Container: import("react").ForwardRefExoticComponent<SlideFadeOverlayProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
defaultOptions: Pick<SlideFadeOverlayProps, "className" | "direction" | "disableCloseOnBackdropClick" | "disableCloseOnEscapeKeyDown" | "disablePortal" | "hideBackdrop" | "invisibleBackdrop" | "open">;
|
|
6
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { modalClasses } from '@mezzanine-ui/core/modal';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import SlideFadeOverlay from '../_internal/SlideFadeOverlay/SlideFadeOverlay.js';
|
|
5
|
+
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
className: modalClasses.overlay,
|
|
8
|
+
direction: 'down',
|
|
9
|
+
disableCloseOnBackdropClick: false,
|
|
10
|
+
disableCloseOnEscapeKeyDown: false,
|
|
11
|
+
disablePortal: false,
|
|
12
|
+
hideBackdrop: false,
|
|
13
|
+
invisibleBackdrop: false,
|
|
14
|
+
open: false,
|
|
15
|
+
};
|
|
16
|
+
const ModalContainer = forwardRef((props, ref) => {
|
|
17
|
+
const { className = defaultOptions.className, children, container, direction = defaultOptions.direction, disableCloseOnBackdropClick = defaultOptions.disableCloseOnBackdropClick, disableCloseOnEscapeKeyDown = defaultOptions.disableCloseOnEscapeKeyDown, disablePortal = defaultOptions.disablePortal, hideBackdrop = defaultOptions.hideBackdrop, invisibleBackdrop = defaultOptions.invisibleBackdrop, onBackdropClick, onClose, open = defaultOptions.open, } = props;
|
|
18
|
+
return (jsx(SlideFadeOverlay, Object.assign({ className: className, container: container, direction: direction, disableCloseOnBackdropClick: disableCloseOnBackdropClick, disableCloseOnEscapeKeyDown: disableCloseOnEscapeKeyDown, disablePortal: disablePortal, hideBackdrop: hideBackdrop, invisibleBackdrop: invisibleBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, ref: ref }, { children: children }), void 0));
|
|
19
|
+
});
|
|
20
|
+
function useModalContainer() {
|
|
21
|
+
return {
|
|
22
|
+
Container: ModalContainer,
|
|
23
|
+
defaultOptions,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useModalContainer as default };
|
|
@@ -19,7 +19,7 @@ export interface TransitionImplementationChildProps {
|
|
|
19
19
|
style?: CSSProperties;
|
|
20
20
|
}
|
|
21
21
|
export interface TransitionImplementationProps extends Omit<TransitionProps, 'addEndListener' | 'children' | 'nodeRef'> {
|
|
22
|
-
children
|
|
22
|
+
children: ReactElement<TransitionImplementationChildProps, NativeElementTag | JSXElementConstructor<TransitionImplementationChildProps>>;
|
|
23
23
|
/**
|
|
24
24
|
* The delay of the transition, in milliseconds
|
|
25
25
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../../utils/jsx-types';
|
|
3
|
+
import { OverlayProps } from '../../Overlay';
|
|
4
|
+
import { SlideFadeProps, SlideFadeDirection } from '../../Transition';
|
|
5
|
+
export interface SlideFadeOverlayProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'>, Pick<OverlayProps, 'container' | 'disableCloseOnBackdropClick' | 'disablePortal' | 'invisibleBackdrop' | 'hideBackdrop' | 'onBackdropClick' | 'onClose' | 'open'>, Pick<SlideFadeProps, 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* Control slide fade in direction
|
|
8
|
+
* @default 'down'
|
|
9
|
+
*/
|
|
10
|
+
direction?: SlideFadeDirection;
|
|
11
|
+
/**
|
|
12
|
+
* Controls whether to disable closing modal while escape key down.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
disableCloseOnEscapeKeyDown?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The react component for slide fade + overlay compose
|
|
19
|
+
*/
|
|
20
|
+
declare const SlideFadeOverlay: import("react").ForwardRefExoticComponent<SlideFadeOverlayProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export default SlideFadeOverlay;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { overlayWithSlideFadeClasses } from '@mezzanine-ui/core/_internal/overlay-with-slide-fade';
|
|
3
|
+
import { forwardRef, useState, useLayoutEffect, useEffect } from 'react';
|
|
4
|
+
import { useDocumentEscapeKeyDown } from '../../hooks/useDocumentEscapeKeyDown.js';
|
|
5
|
+
import { lockBodyScroll, allowBodyScroll } from '../../utils/scroll-lock.js';
|
|
6
|
+
import useTopStack from './useTopStack.js';
|
|
7
|
+
import Overlay from '../../Overlay/Overlay.js';
|
|
8
|
+
import SlideFade from '../../Transition/SlideFade.js';
|
|
9
|
+
import cx from 'clsx';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The react component for slide fade + overlay compose
|
|
13
|
+
*/
|
|
14
|
+
const SlideFadeOverlay = forwardRef(function SlideFadeOverlay(props, ref) {
|
|
15
|
+
const { children, className, container, direction = 'down', disableCloseOnBackdropClick = false, disableCloseOnEscapeKeyDown = false, disablePortal = false, hideBackdrop = false, invisibleBackdrop = false, onBackdropClick, onClose, open, } = props;
|
|
16
|
+
const [exited, setExited] = useState(true);
|
|
17
|
+
/**
|
|
18
|
+
* Escape keydown close: escape will only close the top modal
|
|
19
|
+
*/
|
|
20
|
+
const checkIsOnTheTop = useTopStack(open);
|
|
21
|
+
useDocumentEscapeKeyDown(() => {
|
|
22
|
+
if (!open || disableCloseOnEscapeKeyDown || !onClose) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return (event) => {
|
|
26
|
+
if (checkIsOnTheTop()) {
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
onClose();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, [
|
|
32
|
+
disableCloseOnEscapeKeyDown,
|
|
33
|
+
checkIsOnTheTop,
|
|
34
|
+
open,
|
|
35
|
+
onClose,
|
|
36
|
+
]);
|
|
37
|
+
/** lock body scroll */
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (open) {
|
|
40
|
+
lockBodyScroll();
|
|
41
|
+
}
|
|
42
|
+
}, [open]);
|
|
43
|
+
/** unlock body scroll */
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
function checkAndAllowScroll() {
|
|
46
|
+
// wait until dom element unmount, and check if other modal existed
|
|
47
|
+
const allStacks = document.querySelectorAll('.mzn-overlay-with-slide-fade');
|
|
48
|
+
if (!allStacks.length) {
|
|
49
|
+
allowBodyScroll();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!open && exited) {
|
|
53
|
+
checkAndAllowScroll();
|
|
54
|
+
}
|
|
55
|
+
return (() => {
|
|
56
|
+
requestAnimationFrame(checkAndAllowScroll);
|
|
57
|
+
});
|
|
58
|
+
}, [open, exited]);
|
|
59
|
+
if (!open && exited) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return (jsx(Overlay, Object.assign({ className: cx(overlayWithSlideFadeClasses.host, className), container: container, disableCloseOnBackdropClick: disableCloseOnBackdropClick, disablePortal: disablePortal, hideBackdrop: hideBackdrop, invisibleBackdrop: invisibleBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, role: "presentation" }, { children: jsx(SlideFade, Object.assign({ ref: ref, in: open, direction: direction, onEntered: () => setExited(false), onExited: () => setExited(true) }, { children: children }), void 0) }), void 0));
|
|
63
|
+
});
|
|
64
|
+
var SlideFadeOverlay$1 = SlideFadeOverlay;
|
|
65
|
+
|
|
66
|
+
export { SlideFadeOverlay$1 as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SlideFadeOverlayProps, default, } from './SlideFadeOverlay';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SlideFadeOverlay.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useTopStack(open?: boolean): () => boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useEffect, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
let seedStack = [];
|
|
4
4
|
let seed = 1;
|
|
5
|
-
function
|
|
5
|
+
function useTopStack(open) {
|
|
6
6
|
const modalSeed = useMemo(() => {
|
|
7
7
|
seed += 1;
|
|
8
8
|
return seed;
|
|
@@ -19,4 +19,4 @@ function useIsTopModal(open) {
|
|
|
19
19
|
return useCallback(() => seedStack[seedStack.length - 1] === modalSeed, [modalSeed]);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { useTopStack as default };
|
package/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export { AlertSeverity, AlertProps, default as Alert, } from './Alert';
|
|
|
81
81
|
export { ConfirmActionsProps, default as ConfirmActions, } from './ConfirmActions';
|
|
82
82
|
export { LoadingProps, default as Loading, } from './Loading';
|
|
83
83
|
export { MessageData, MessageSeverity, MessageType, default as Message, } from './Message';
|
|
84
|
-
export { ModalSeverity, ModalSize, ModalHeaderProps, ModalHeader, ModalBodyProps, ModalBody, ModalFooterProps, ModalFooter, ModalActionsProps, ModalActions, ModalProps, default as Modal, } from './Modal';
|
|
84
|
+
export { ModalSeverity, ModalSize, ModalHeaderProps, ModalHeader, ModalBodyProps, ModalBody, ModalFooterProps, ModalFooter, ModalActionsProps, ModalActions, ModalProps, useModalContainer, default as Modal, } from './Modal';
|
|
85
85
|
export { PopconfirmProps, default as Popconfirm, } from './Popconfirm';
|
|
86
86
|
export { NotificationData, NotificationSeverity, default as Notification, } from './Notification';
|
|
87
87
|
export { ProgressProps, ProgressType, ProgressStatus, ProgressTypes, ProgressStatuses, default as Progress, } from './Progress';
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { useSelectValueControl } from './Form/useSelectValueControl.js';
|
|
|
23
23
|
export { useSwitchControlValue } from './Form/useSwitchControlValue.js';
|
|
24
24
|
export { IconButton } from './Button/index.js';
|
|
25
25
|
export { default as Typography } from './Typography/Typography.js';
|
|
26
|
+
export { default as useModalContainer } from './Modal/useModalContainer.js';
|
|
26
27
|
export { default as Transition } from './Transition/Transition.js';
|
|
27
28
|
export { default as Button } from './Button/Button.js';
|
|
28
29
|
export { default as ButtonGroup } from './Button/ButtonGroup.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezzanine-ui/react",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "React components for mezzanine-ui",
|
|
5
5
|
"author": "Mezzanine",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-dom": "^17.0.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@mezzanine-ui/core": "^0.7.
|
|
35
|
+
"@mezzanine-ui/core": "^0.7.2",
|
|
36
36
|
"@mezzanine-ui/icons": "^0.5.0",
|
|
37
37
|
"@mezzanine-ui/system": "^0.7.0",
|
|
38
38
|
"@popperjs/core": "^2.9.2",
|
package/Modal/useIsTopModal.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useIsTopModal(open?: boolean): () => boolean;
|