@activecollab/components 2.0.527 → 2.0.529
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/cjs/components/Dialog/Dialog.js +32 -187
- package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogFrame.js +209 -0
- package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -0
- package/dist/cjs/components/GlobalPortal/GlobalPortal.js +10 -4
- package/dist/cjs/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/cjs/components/Modal/Modal.js +17 -108
- package/dist/cjs/components/Modal/Modal.js.map +1 -1
- package/dist/cjs/components/Modal/ModalBase.js +125 -0
- package/dist/cjs/components/Modal/ModalBase.js.map +1 -0
- package/dist/cjs/components/ModalRoot/ModalRoot.js +5 -4
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +21 -13
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ModalRoot/useModalStackHost.js +43 -5
- package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -1
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +41 -64
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.d.ts +3 -3
- package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +34 -175
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.d.ts +14 -0
- package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -0
- package/dist/esm/components/Dialog/DialogFrame.js +180 -0
- package/dist/esm/components/Dialog/DialogFrame.js.map +1 -0
- package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts +6 -4
- package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts.map +1 -1
- package/dist/esm/components/GlobalPortal/GlobalPortal.js +9 -4
- package/dist/esm/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/esm/components/Modal/Modal.d.ts +8 -17
- package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal/Modal.js +18 -99
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Modal/ModalBase.d.ts +19 -0
- package/dist/esm/components/Modal/ModalBase.d.ts.map +1 -0
- package/dist/esm/components/Modal/ModalBase.js +108 -0
- package/dist/esm/components/Modal/ModalBase.js.map +1 -0
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +5 -4
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -4
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +15 -11
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +4 -2
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/useModalStackHost.js +36 -5
- package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +42 -65
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/index.js +989 -902
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/hooks/useDeprecation.js +0 -15
- package/dist/cjs/hooks/useDeprecation.js.map +0 -1
- package/dist/esm/hooks/useDeprecation.d.ts +0 -2
- package/dist/esm/hooks/useDeprecation.d.ts.map +0 -1
- package/dist/esm/hooks/useDeprecation.js +0 -9
- package/dist/esm/hooks/useDeprecation.js.map +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["children", "disableFocusLock", "disableScrollLock", "disableBackgroundClick", "disableBackgroundColor", "disableCloseOnEsc", "open", "overlayTimeout", "onClose", "onClickOutside"];
|
|
4
|
+
import React, { forwardRef, useRef, cloneElement, useMemo, useCallback, useState, useEffect } from "react";
|
|
5
|
+
import createChainedFunction from "../../utils/createChainedFunction";
|
|
6
|
+
import useForkRef from "../../utils/useForkRef";
|
|
7
|
+
import { Overlay } from "../Overlay";
|
|
8
|
+
import { Fade, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions";
|
|
9
|
+
import { Window } from "../Window";
|
|
10
|
+
const getHasTransition = children => {
|
|
11
|
+
return children.props ? Object.prototype.hasOwnProperty.call(children.props, "in") : false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// The modal behind Dialog and ObjectFormModal. It stays out of the package index, so only the design system renders it.
|
|
15
|
+
export const ModalBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
16
|
+
let children = _ref.children,
|
|
17
|
+
_ref$disableFocusLock = _ref.disableFocusLock,
|
|
18
|
+
disableFocusLock = _ref$disableFocusLock === void 0 ? false : _ref$disableFocusLock,
|
|
19
|
+
_ref$disableScrollLoc = _ref.disableScrollLock,
|
|
20
|
+
disableScrollLock = _ref$disableScrollLoc === void 0 ? false : _ref$disableScrollLoc,
|
|
21
|
+
_ref$disableBackgroun = _ref.disableBackgroundClick,
|
|
22
|
+
disableBackgroundClick = _ref$disableBackgroun === void 0 ? false : _ref$disableBackgroun,
|
|
23
|
+
_ref$disableBackgroun2 = _ref.disableBackgroundColor,
|
|
24
|
+
disableBackgroundColor = _ref$disableBackgroun2 === void 0 ? false : _ref$disableBackgroun2,
|
|
25
|
+
_ref$disableCloseOnEs = _ref.disableCloseOnEsc,
|
|
26
|
+
disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
|
|
27
|
+
_ref$open = _ref.open,
|
|
28
|
+
defaultOpen = _ref$open === void 0 ? false : _ref$open,
|
|
29
|
+
_ref$overlayTimeout = _ref.overlayTimeout,
|
|
30
|
+
overlayTimeout = _ref$overlayTimeout === void 0 ? {
|
|
31
|
+
enter: SLIDE_FROM_TOP_ENTER,
|
|
32
|
+
exit: SLIDE_FROM_TOP_EXIT
|
|
33
|
+
} : _ref$overlayTimeout,
|
|
34
|
+
onClose = _ref.onClose,
|
|
35
|
+
onClickOutside = _ref.onClickOutside,
|
|
36
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
37
|
+
const _useState = useState(defaultOpen),
|
|
38
|
+
open = _useState[0],
|
|
39
|
+
setOpen = _useState[1];
|
|
40
|
+
const _useState2 = useState(true),
|
|
41
|
+
exited = _useState2[0],
|
|
42
|
+
setExited = _useState2[1];
|
|
43
|
+
const innerRef = useRef(null);
|
|
44
|
+
const handleRef = useForkRef(innerRef, ref);
|
|
45
|
+
const hasTransition = useMemo(() => {
|
|
46
|
+
return getHasTransition(children);
|
|
47
|
+
}, [children]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setOpen(defaultOpen);
|
|
50
|
+
}, [defaultOpen]);
|
|
51
|
+
const handleClose = useCallback(() => {
|
|
52
|
+
setOpen(false);
|
|
53
|
+
if (!hasTransition) {
|
|
54
|
+
typeof onClose === "function" && onClose();
|
|
55
|
+
}
|
|
56
|
+
}, [hasTransition, onClose]);
|
|
57
|
+
const handleBackgroundClick = useCallback(event => {
|
|
58
|
+
if (!disableBackgroundClick) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
return handleClose();
|
|
61
|
+
}
|
|
62
|
+
if (onClickOutside) {
|
|
63
|
+
onClickOutside(event);
|
|
64
|
+
}
|
|
65
|
+
}, [disableBackgroundClick, onClickOutside, handleClose]);
|
|
66
|
+
const handleEnter = useCallback(() => {
|
|
67
|
+
setExited(false);
|
|
68
|
+
}, []);
|
|
69
|
+
const handleExited = useCallback(() => {
|
|
70
|
+
setExited(true);
|
|
71
|
+
typeof onClose === "function" && onClose();
|
|
72
|
+
}, [onClose]);
|
|
73
|
+
const childProps = useMemo(() => {
|
|
74
|
+
let props = {};
|
|
75
|
+
|
|
76
|
+
// It's a Transition like component
|
|
77
|
+
if (hasTransition && children) {
|
|
78
|
+
props = {
|
|
79
|
+
onEnter: createChainedFunction(handleEnter, children.props.onEnter),
|
|
80
|
+
onExited: createChainedFunction(handleExited, children.props.onExited),
|
|
81
|
+
in: open,
|
|
82
|
+
forceClose: handleClose
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return props;
|
|
86
|
+
}, [children, handleClose, handleEnter, handleExited, hasTransition, open]);
|
|
87
|
+
if (!open && (!hasTransition || exited)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return /*#__PURE__*/React.createElement(Window, _extends({}, rest, {
|
|
91
|
+
ref: handleRef,
|
|
92
|
+
onClose: handleClose,
|
|
93
|
+
disableFocusLock: disableFocusLock,
|
|
94
|
+
disableScrollLock: disableScrollLock,
|
|
95
|
+
disableCloseOnEsc: disableCloseOnEsc
|
|
96
|
+
}), /*#__PURE__*/React.createElement(Fade, {
|
|
97
|
+
in: open,
|
|
98
|
+
timeout: open ? overlayTimeout.enter : overlayTimeout.exit
|
|
99
|
+
}, /*#__PURE__*/React.createElement(Overlay, {
|
|
100
|
+
onClick: handleBackgroundClick,
|
|
101
|
+
disableBackgroundColor: disableBackgroundColor,
|
|
102
|
+
style: {
|
|
103
|
+
pointerEvents: open ? undefined : "none"
|
|
104
|
+
}
|
|
105
|
+
})), /*#__PURE__*/cloneElement(children, childProps));
|
|
106
|
+
});
|
|
107
|
+
ModalBase.displayName = "ModalBase";
|
|
108
|
+
//# sourceMappingURL=ModalBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalBase.js","names":["React","forwardRef","useRef","cloneElement","useMemo","useCallback","useState","useEffect","createChainedFunction","useForkRef","Overlay","Fade","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","Window","getHasTransition","children","props","Object","prototype","hasOwnProperty","call","ModalBase","_ref","ref","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundClick","_ref$disableBackgroun2","disableBackgroundColor","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$open","open","defaultOpen","_ref$overlayTimeout","overlayTimeout","enter","exit","onClose","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","innerRef","handleRef","hasTransition","handleClose","handleBackgroundClick","event","preventDefault","handleEnter","handleExited","childProps","onEnter","onExited","in","forceClose","createElement","_extends","timeout","onClick","style","pointerEvents","undefined","displayName"],"sources":["../../../../src/components/Modal/ModalBase.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n useRef,\n cloneElement,\n useMemo,\n useCallback,\n ReactElement,\n useState,\n useEffect,\n MouseEvent,\n} from \"react\";\n\nimport createChainedFunction from \"../../utils/createChainedFunction\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport {\n Fade,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions\";\nimport { Window } from \"../Window\";\n\nexport interface IModal {\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n open?: boolean;\n disableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n disableBackgroundColor?: boolean;\n onClose?: () => void;\n children: ReactElement;\n onClickOutside?: (event) => void;\n /** How long the overlay takes to arrive and to leave. Match it to the animation the child runs. */\n overlayTimeout?: { enter: number; exit: number };\n}\n\nconst getHasTransition = (children): boolean => {\n return children.props\n ? Object.prototype.hasOwnProperty.call(children.props, \"in\")\n : false;\n};\n\n// The modal behind Dialog and ObjectFormModal. It stays out of the package index, so only the design system renders it.\nexport const ModalBase = forwardRef<\n HTMLDivElement,\n IModal & HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n children,\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundClick = false,\n disableBackgroundColor = false,\n disableCloseOnEsc = false,\n open: defaultOpen = false,\n overlayTimeout = {\n enter: SLIDE_FROM_TOP_ENTER,\n exit: SLIDE_FROM_TOP_EXIT,\n },\n onClose,\n onClickOutside,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n const innerRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(innerRef, ref);\n\n const hasTransition = useMemo(() => {\n return getHasTransition(children);\n }, [children]);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n if (!hasTransition) {\n typeof onClose === \"function\" && onClose();\n }\n }, [hasTransition, onClose]);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n return handleClose();\n }\n\n if (onClickOutside) {\n onClickOutside(event);\n }\n },\n [disableBackgroundClick, onClickOutside, handleClose]\n );\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n typeof onClose === \"function\" && onClose();\n }, [onClose]);\n\n const childProps = useMemo(() => {\n let props = {};\n\n // It's a Transition like component\n if (hasTransition && children) {\n props = {\n onEnter: createChainedFunction(handleEnter, children.props.onEnter),\n onExited: createChainedFunction(\n handleExited,\n children.props.onExited\n ),\n in: open,\n forceClose: handleClose,\n };\n }\n\n return props;\n }, [children, handleClose, handleEnter, handleExited, hasTransition, open]);\n\n if (!open && (!hasTransition || exited)) {\n return null;\n }\n\n return (\n <Window\n {...rest}\n ref={handleRef}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n disableCloseOnEsc={disableCloseOnEsc}\n >\n <Fade\n in={open}\n timeout={open ? overlayTimeout.enter : overlayTimeout.exit}\n >\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n style={{ pointerEvents: open ? undefined : \"none\" }}\n />\n </Fade>\n {cloneElement(children, childProps)}\n </Window>\n );\n }\n);\n\nModalBase.displayName = \"ModalBase\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAEVC,MAAM,EACNC,YAAY,EACZC,OAAO,EACPC,WAAW,EAEXC,QAAQ,EACRC,SAAS,QAEJ,OAAO;AAEd,OAAOC,qBAAqB,MAAM,mCAAmC;AACrE,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SACEC,IAAI,EACJC,oBAAoB,EACpBC,mBAAmB,QACd,gBAAgB;AACvB,SAASC,MAAM,QAAQ,WAAW;AAgBlC,MAAMC,gBAAgB,GAAIC,QAAQ,IAAc;EAC9C,OAAOA,QAAQ,CAACC,KAAK,GACjBC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,QAAQ,CAACC,KAAK,EAAE,IAAI,CAAC,GAC1D,KAAK;AACX,CAAC;;AAED;AACA,OAAO,MAAMK,SAAS,gBAAGrB,UAAU,CAIjC,CAAAsB,IAAA,EAiBEC,GAAG,KACA;EAAA,IAhBDR,QAAQ,GAAAO,IAAA,CAARP,QAAQ;IAAAS,qBAAA,GAAAF,IAAA,CACRG,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAJ,IAAA,CACxBK,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAN,IAAA,CACzBO,sBAAsB;IAAtBA,sBAAsB,GAA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MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC1D,6HAA6H;IAC7H,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,sBAAsB,EAC9B,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAClC,IAAI,CAAC;IACV,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iHAAiH;IACjH,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,UAAU,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,SAAS,0FA0RrB,CAAC"}
|
|
@@ -63,17 +63,18 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
63
63
|
}, [onClose]);
|
|
64
64
|
|
|
65
65
|
// The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the
|
|
66
|
-
// same node, gets it back.
|
|
66
|
+
// same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it
|
|
67
|
+
// is rendered and can get its scroll positions back.
|
|
67
68
|
useLayoutEffect(() => {
|
|
68
69
|
if (!open || !dialog) {
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
if (stackIdRef.current === undefined) {
|
|
72
|
-
stackIdRef.current = pushModalRoot(overlayRootRef.current);
|
|
73
|
-
}
|
|
74
72
|
if (!dialog.open) {
|
|
75
73
|
dialog.showModal();
|
|
76
74
|
}
|
|
75
|
+
if (stackIdRef.current === undefined) {
|
|
76
|
+
stackIdRef.current = pushModalRoot(overlayRootRef.current);
|
|
77
|
+
}
|
|
77
78
|
}, [open, dialog]);
|
|
78
79
|
|
|
79
80
|
// A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalRoot.js","names":["React","forwardRef","useCallback","useEffect","useLayoutEffect","useRef","useState","RemoveScroll","classnames","isTopModalRoot","popModalRoot","pushModalRoot","StyledModalRoot","Portal","PortalContainerProvider","useForkRef","ModalRoot","_ref","ref","open","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","children","className","onPointerDown","onClick","onKeyDown","rest","_objectWithoutPropertiesLoose","_excluded","_useState","mounted","setMounted","_useState2","dialog","setDialog","dialogRef","setDialogNode","node","current","handleRef","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","finishClose","_dialogRef$current","undefined","close","showModal","dismissRef","reason","event","blocked","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","defaultPrevented","key","target","document","body","querySelector","preventDefault","contains","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","activeElement","handleNativeClose","handlePointerDown","currentTarget","handleClick","_overlayRootRef$curre4","stopPropagation","handleExited","createElement","forwardProps","enabled","noIsolation","_extends","value","in","onExited","displayName"],"sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport { isTopModalRoot, popModalRoot, pushModalRoot } from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nexport interface ModalRootTransition {\n in: boolean;\n onExited: () => void;\n}\n\nexport interface ModalRootProps\n extends Omit<\n HTMLAttributes<HTMLDialogElement>,\n \"children\" | \"open\" | \"onClose\" | \"onCancel\"\n > {\n open: boolean;\n /** Escape or a backdrop click asks the owner to set open to false */\n onRequestClose?: (reason: ModalRootDismissReason) => void;\n /** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked; a backdrop click passes its event */\n onDismissBlocked?: (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void;\n /** The exit transition is done and the dialog is closed */\n onClose?: () => void;\n disableCloseOnEsc?: boolean;\n disableBackgroundClick?: boolean;\n disableScrollLock?: boolean;\n /** A function gets the transition state, and the dialog closes when it calls onExited. A node closes at once. */\n children: ReactNode | ((transition: ModalRootTransition) => ReactNode);\n}\n\nexport const ModalRoot = forwardRef<HTMLDialogElement, ModalRootProps>(\n (\n {\n open,\n onRequestClose,\n onDismissBlocked,\n onClose,\n disableCloseOnEsc = false,\n disableBackgroundClick = false,\n disableScrollLock = false,\n children,\n className,\n onPointerDown,\n onClick,\n onKeyDown,\n ...rest\n },\n ref\n ) => {\n const [mounted, setMounted] = useState(open);\n // Inside another root the dialog mounts a render after its first one, once the outer overlay root exists,\n // so opening, the stack and the listeners wait for the node instead of the first commit.\n const [dialog, setDialog] = useState<HTMLDialogElement | null>(null);\n const dialogRef = useRef<HTMLDialogElement | null>(null);\n const setDialogNode = useCallback((node: HTMLDialogElement | null) => {\n dialogRef.current = node;\n setDialog(node);\n }, []);\n const handleRef = useForkRef(setDialogNode, ref);\n const hasTransition = typeof children === \"function\";\n const openRef = useRef(open);\n const pressStartedOnBackdrop = useRef(false);\n const stackIdRef = useRef<number>();\n const overlayRootRef = useRef<HTMLDivElement>(null);\n // Menus and pickers opened inside portal here, into the top layer with the dialog, not under it.\n const getOverlayRoot = useCallback(\n () => overlayRootRef.current as HTMLElement,\n []\n );\n\n openRef.current = open;\n\n if (open && !mounted) {\n setMounted(true);\n }\n\n const finishClose = useCallback(() => {\n // Content that sits in the overlay root moves out before the dialog hides it.\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n dialogRef.current?.close();\n setMounted(false);\n onClose?.();\n }, [onClose]);\n\n // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the\n // same node, gets it back.\n useLayoutEffect(() => {\n if (!open || !dialog) {\n return;\n }\n\n if (stackIdRef.current === undefined) {\n stackIdRef.current = pushModalRoot(overlayRootRef.current);\n }\n\n if (!dialog.open) {\n dialog.showModal();\n }\n }, [open, dialog]);\n\n // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.\n useLayoutEffect(\n () => () => {\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n },\n [dialog]\n );\n\n useLayoutEffect(() => {\n if (!open && mounted && !hasTransition) {\n finishClose();\n }\n }, [open, mounted, hasTransition, finishClose]);\n\n const dismissRef =\n useRef<\n (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void\n >();\n\n dismissRef.current = (reason, event) => {\n const blocked =\n reason === \"escape\" ? disableCloseOnEsc : disableBackgroundClick;\n\n if (blocked) {\n onDismissBlocked?.(reason, event);\n } else {\n onRequestClose?.(reason);\n }\n };\n\n // A prevented Escape keydown starts no close request, and the browser stops honouring a prevented cancel\n // after a while, so Escape is caught here and the cancel event only covers the other close requests.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const stackId = stackIdRef.current;\n\n if (\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\")\n ) {\n return;\n }\n\n // A menu inside closes on an Escape that reaches the body, from a listener that runs after this one.\n if (\n event.target === document.body &&\n overlayRootRef.current?.querySelector(\".c-window\")\n ) {\n return;\n }\n\n event.preventDefault();\n\n // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take\n // still belongs to it, so the dialog only stops the browser from closing itself.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [dialog]);\n\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n\n // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows\n // would close the dialog under the layer. While the focus is in that layer, the close request is its own.\n if (overlayRootRef.current?.contains(document.activeElement)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n const handleNativeClose = () => {\n if (openRef.current && !dialog.open) {\n dialog.showModal();\n }\n };\n\n dialog.addEventListener(\"cancel\", handleCancel);\n dialog.addEventListener(\"close\", handleNativeClose);\n\n return () => {\n dialog.removeEventListener(\"cancel\", handleCancel);\n dialog.removeEventListener(\"close\", handleNativeClose);\n };\n }, [dialog]);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLDialogElement>) => {\n pressStartedOnBackdrop.current = event.target === event.currentTarget;\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n // The dialog covers the viewport and its content sits inside it, so a click on the dialog itself is a\n // click on the backdrop. A press that started on the content and ended outside it is a text selection.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n if (\n event.target === event.currentTarget &&\n pressStartedOnBackdrop.current &&\n openRef.current\n ) {\n dismissRef.current?.(\"backdrop\", event);\n }\n pressStartedOnBackdrop.current = false;\n onClick?.(event);\n },\n [onClick]\n );\n\n // React events from a portal bubble through the React tree, so an Escape from the content would reach an\n // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDialogElement>) => {\n onKeyDown?.(event);\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\") ||\n stackIdRef.current === undefined ||\n !isTopModalRoot(stackIdRef.current)\n ) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that\n // opened this dialog, but it leaves the dialog open.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n },\n [onKeyDown]\n );\n\n const handleExited = useCallback(() => {\n if (!open) {\n finishClose();\n }\n }, [open, finishClose]);\n\n if (!mounted) {\n return null;\n }\n\n return (\n <Portal>\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation\n >\n <StyledModalRoot\n {...rest}\n className={classnames(\"c-modal-root\", className)}\n data-state={open ? \"open\" : \"closing\"}\n onPointerDown={handlePointerDown}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n <PortalContainerProvider value={getOverlayRoot}>\n {typeof children === \"function\"\n ? children({ in: open, onExited: handleExited })\n : children}\n </PortalContainerProvider>\n <div ref={overlayRootRef} className=\"c-modal-root__overlays\" />\n </StyledModalRoot>\n </RemoveScroll>\n </Portal>\n );\n }\n);\n\nModalRoot.displayName = \"ModalRoot\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAMVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,cAAc,EAAEC,YAAY,EAAEC,aAAa,QAAQ,kBAAkB;AAC9E,SAASC,eAAe,QAAQ,UAAU;AAC1C,SAASC,MAAM,EAAEC,uBAAuB,QAAQ,eAAe;AAC/D,OAAOC,UAAU,MAAM,wBAAwB;AA+B/C,OAAO,MAAMC,SAAS,gBAAGf,UAAU,CACjC,CAAAgB,IAAA,EAgBEC,GAAG,KACA;EAAA,IAfDC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,cAAc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AEgE,EAAE,EAAE1E,IAAI;IAAE2E,QAAQ,EAAER;EAAa,CAAC,CAAC,GAC9CzD,QACmB,CAAC,eAC1B7B,KAAA,CAAAuF,aAAA;IAAKrE,GAAG,EAAEkC,cAAe;IAACtB,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDd,SAAS,CAAC+E,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModalRoot.js","names":["React","forwardRef","useCallback","useEffect","useLayoutEffect","useRef","useState","RemoveScroll","classnames","isTopModalRoot","popModalRoot","pushModalRoot","StyledModalRoot","Portal","PortalContainerProvider","useForkRef","ModalRoot","_ref","ref","open","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","children","className","onPointerDown","onClick","onKeyDown","rest","_objectWithoutPropertiesLoose","_excluded","_useState","mounted","setMounted","_useState2","dialog","setDialog","dialogRef","setDialogNode","node","current","handleRef","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","finishClose","_dialogRef$current","undefined","close","showModal","dismissRef","reason","event","blocked","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","defaultPrevented","key","target","document","body","querySelector","preventDefault","contains","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","activeElement","handleNativeClose","handlePointerDown","currentTarget","handleClick","_overlayRootRef$curre4","stopPropagation","handleExited","createElement","forwardProps","enabled","noIsolation","_extends","value","in","onExited","displayName"],"sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport { isTopModalRoot, popModalRoot, pushModalRoot } from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nexport interface ModalRootTransition {\n in: boolean;\n onExited: () => void;\n}\n\nexport interface ModalRootProps\n extends Omit<\n HTMLAttributes<HTMLDialogElement>,\n \"children\" | \"open\" | \"onClose\" | \"onCancel\"\n > {\n open: boolean;\n /** Escape or a backdrop click asks the owner to set open to false */\n onRequestClose?: (reason: ModalRootDismissReason) => void;\n /** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked; a backdrop click passes its event */\n onDismissBlocked?: (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void;\n /** The exit transition is done and the dialog is closed */\n onClose?: () => void;\n disableCloseOnEsc?: boolean;\n disableBackgroundClick?: boolean;\n disableScrollLock?: boolean;\n /** A function gets the transition state, and the dialog closes when it calls onExited. A node closes at once. */\n children: ReactNode | ((transition: ModalRootTransition) => ReactNode);\n}\n\nexport const ModalRoot = forwardRef<HTMLDialogElement, ModalRootProps>(\n (\n {\n open,\n onRequestClose,\n onDismissBlocked,\n onClose,\n disableCloseOnEsc = false,\n disableBackgroundClick = false,\n disableScrollLock = false,\n children,\n className,\n onPointerDown,\n onClick,\n onKeyDown,\n ...rest\n },\n ref\n ) => {\n const [mounted, setMounted] = useState(open);\n // Inside another root the dialog mounts a render after its first one, once the outer overlay root exists,\n // so opening, the stack and the listeners wait for the node instead of the first commit.\n const [dialog, setDialog] = useState<HTMLDialogElement | null>(null);\n const dialogRef = useRef<HTMLDialogElement | null>(null);\n const setDialogNode = useCallback((node: HTMLDialogElement | null) => {\n dialogRef.current = node;\n setDialog(node);\n }, []);\n const handleRef = useForkRef(setDialogNode, ref);\n const hasTransition = typeof children === \"function\";\n const openRef = useRef(open);\n const pressStartedOnBackdrop = useRef(false);\n const stackIdRef = useRef<number>();\n const overlayRootRef = useRef<HTMLDivElement>(null);\n // Menus and pickers opened inside portal here, into the top layer with the dialog, not under it.\n const getOverlayRoot = useCallback(\n () => overlayRootRef.current as HTMLElement,\n []\n );\n\n openRef.current = open;\n\n if (open && !mounted) {\n setMounted(true);\n }\n\n const finishClose = useCallback(() => {\n // Content that sits in the overlay root moves out before the dialog hides it.\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n dialogRef.current?.close();\n setMounted(false);\n onClose?.();\n }, [onClose]);\n\n // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the\n // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it\n // is rendered and can get its scroll positions back.\n useLayoutEffect(() => {\n if (!open || !dialog) {\n return;\n }\n\n if (!dialog.open) {\n dialog.showModal();\n }\n\n if (stackIdRef.current === undefined) {\n stackIdRef.current = pushModalRoot(overlayRootRef.current);\n }\n }, [open, dialog]);\n\n // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.\n useLayoutEffect(\n () => () => {\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n },\n [dialog]\n );\n\n useLayoutEffect(() => {\n if (!open && mounted && !hasTransition) {\n finishClose();\n }\n }, [open, mounted, hasTransition, finishClose]);\n\n const dismissRef =\n useRef<\n (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void\n >();\n\n dismissRef.current = (reason, event) => {\n const blocked =\n reason === \"escape\" ? disableCloseOnEsc : disableBackgroundClick;\n\n if (blocked) {\n onDismissBlocked?.(reason, event);\n } else {\n onRequestClose?.(reason);\n }\n };\n\n // A prevented Escape keydown starts no close request, and the browser stops honouring a prevented cancel\n // after a while, so Escape is caught here and the cancel event only covers the other close requests.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const stackId = stackIdRef.current;\n\n if (\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\")\n ) {\n return;\n }\n\n // A menu inside closes on an Escape that reaches the body, from a listener that runs after this one.\n if (\n event.target === document.body &&\n overlayRootRef.current?.querySelector(\".c-window\")\n ) {\n return;\n }\n\n event.preventDefault();\n\n // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take\n // still belongs to it, so the dialog only stops the browser from closing itself.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [dialog]);\n\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n\n // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows\n // would close the dialog under the layer. While the focus is in that layer, the close request is its own.\n if (overlayRootRef.current?.contains(document.activeElement)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n const handleNativeClose = () => {\n if (openRef.current && !dialog.open) {\n dialog.showModal();\n }\n };\n\n dialog.addEventListener(\"cancel\", handleCancel);\n dialog.addEventListener(\"close\", handleNativeClose);\n\n return () => {\n dialog.removeEventListener(\"cancel\", handleCancel);\n dialog.removeEventListener(\"close\", handleNativeClose);\n };\n }, [dialog]);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLDialogElement>) => {\n pressStartedOnBackdrop.current = event.target === event.currentTarget;\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n // The dialog covers the viewport and its content sits inside it, so a click on the dialog itself is a\n // click on the backdrop. A press that started on the content and ended outside it is a text selection.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n if (\n event.target === event.currentTarget &&\n pressStartedOnBackdrop.current &&\n openRef.current\n ) {\n dismissRef.current?.(\"backdrop\", event);\n }\n pressStartedOnBackdrop.current = false;\n onClick?.(event);\n },\n [onClick]\n );\n\n // React events from a portal bubble through the React tree, so an Escape from the content would reach an\n // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDialogElement>) => {\n onKeyDown?.(event);\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\") ||\n stackIdRef.current === undefined ||\n !isTopModalRoot(stackIdRef.current)\n ) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that\n // opened this dialog, but it leaves the dialog open.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n },\n [onKeyDown]\n );\n\n const handleExited = useCallback(() => {\n if (!open) {\n finishClose();\n }\n }, [open, finishClose]);\n\n if (!mounted) {\n return null;\n }\n\n return (\n <Portal>\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation\n >\n <StyledModalRoot\n {...rest}\n className={classnames(\"c-modal-root\", className)}\n data-state={open ? \"open\" : \"closing\"}\n onPointerDown={handlePointerDown}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n <PortalContainerProvider value={getOverlayRoot}>\n {typeof children === \"function\"\n ? children({ in: open, onExited: handleExited })\n : children}\n </PortalContainerProvider>\n <div ref={overlayRootRef} className=\"c-modal-root__overlays\" />\n </StyledModalRoot>\n </RemoveScroll>\n </Portal>\n );\n }\n);\n\nModalRoot.displayName = \"ModalRoot\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAMVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OA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AAA,KACVzD,IAAI;IACRJ,SAAS,EAAEtB,UAAU,CAAC,cAAc,EAAEsB,SAAS,CAAE;IACjD,cAAYX,IAAI,GAAG,MAAM,GAAG,SAAU;IACtCY,aAAa,EAAEkD,iBAAkB;IACjCjD,OAAO,EAAEmD,WAAY;IACrBlD,SAAS,EAAE8B;EAAc,iBAEzB/D,KAAA,CAAAuF,aAAA,CAACzE,uBAAuB;IAAC8E,KAAK,EAAEvC;EAAe,GAC5C,OAAOxB,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC;IAAEgE,EAAE,EAAE1E,IAAI;IAAE2E,QAAQ,EAAER;EAAa,CAAC,CAAC,GAC9CzD,QACmB,CAAC,eAC1B7B,KAAA,CAAAuF,aAAA;IAAKrE,GAAG,EAAEkC,cAAe;IAACtB,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDd,SAAS,CAAC+E,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -2,12 +2,16 @@ type Listener = () => void;
|
|
|
2
2
|
export declare const pushModalRoot: (overlayRoot: HTMLElement | null) => number;
|
|
3
3
|
export declare const popModalRoot: (id: number) => void;
|
|
4
4
|
export declare const isTopModalRoot: (id: number) => boolean;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root
|
|
7
|
+
* whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into
|
|
8
|
+
* itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getTopModalOverlayRoot: (outside?: Node) => HTMLElement | null;
|
|
7
11
|
/** The id of the top open modal root, or undefined when none is open. */
|
|
8
12
|
export declare const getTopModalRootId: () => number | undefined;
|
|
9
|
-
/** The overlay root of the top modal root among those opened no later than the given one. */
|
|
10
|
-
export declare const getModalOverlayRootUpTo: (id: number) => HTMLElement | null;
|
|
13
|
+
/** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */
|
|
14
|
+
export declare const getModalOverlayRootUpTo: (id: number, outside?: Node) => HTMLElement | null;
|
|
11
15
|
export declare const subscribeToModalRoots: (listener: Listener) => (() => void);
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=modalRootStack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modalRootStack.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAc3B,eAAO,MAAM,aAAa,GAAI,aAAa,WAAW,GAAG,IAAI,KAAG,MAM/D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,IAOzC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,KAAG,OACR,CAAC;
|
|
1
|
+
{"version":3,"file":"modalRootStack.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAc3B,eAAO,MAAM,aAAa,GAAI,aAAa,WAAW,GAAG,IAAI,KAAG,MAM/D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,IAOzC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,KAAG,OACR,CAAC;AAKrC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,IAAI,KAAG,WAAW,GAAG,IACS,CAAC;AAEhF,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,QAAO,MAAM,GAAG,SACjB,CAAC;AAE9B,gHAAgH;AAChH,eAAO,MAAM,uBAAuB,GAClC,IAAI,MAAM,EACV,UAAU,IAAI,KACb,WAAW,GAAG,IAEQ,CAAC;AAE1B,eAAO,MAAM,qBAAqB,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAMrE,CAAC"}
|
|
@@ -22,24 +22,28 @@ export const isTopModalRoot = id => {
|
|
|
22
22
|
var _stack;
|
|
23
23
|
return ((_stack = stack[stack.length - 1]) == null ? void 0 : _stack.id) === id;
|
|
24
24
|
};
|
|
25
|
+
const isInside = (entry, outside) => !!outside && !!entry.overlayRoot && outside.contains(entry.overlayRoot);
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root
|
|
29
|
+
* whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into
|
|
30
|
+
* itself.
|
|
31
|
+
*/
|
|
32
|
+
export const getTopModalOverlayRoot = outside => {
|
|
33
|
+
var _stack$filter$pop$ove, _stack$filter$pop;
|
|
34
|
+
return (_stack$filter$pop$ove = (_stack$filter$pop = stack.filter(entry => !isInside(entry, outside)).pop()) == null ? void 0 : _stack$filter$pop.overlayRoot) != null ? _stack$filter$pop$ove : null;
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
/** The id of the top open modal root, or undefined when none is open. */
|
|
33
38
|
export const getTopModalRootId = () => {
|
|
34
|
-
var
|
|
35
|
-
return (
|
|
39
|
+
var _stack2;
|
|
40
|
+
return (_stack2 = stack[stack.length - 1]) == null ? void 0 : _stack2.id;
|
|
36
41
|
};
|
|
37
42
|
|
|
38
|
-
/** The overlay root of the top modal root among those opened no later than the given one. */
|
|
39
|
-
export const getModalOverlayRootUpTo = id => {
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
return (_entries$overlayRoot = (_entries = entries[entries.length - 1]) == null ? void 0 : _entries.overlayRoot) != null ? _entries$overlayRoot : null;
|
|
43
|
+
/** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */
|
|
44
|
+
export const getModalOverlayRootUpTo = (id, outside) => {
|
|
45
|
+
var _stack$filter$pop$ove2, _stack$filter$pop2;
|
|
46
|
+
return (_stack$filter$pop$ove2 = (_stack$filter$pop2 = stack.filter(entry => entry.id <= id && !isInside(entry, outside)).pop()) == null ? void 0 : _stack$filter$pop2.overlayRoot) != null ? _stack$filter$pop$ove2 : null;
|
|
43
47
|
};
|
|
44
48
|
export const subscribeToModalRoots = listener => {
|
|
45
49
|
listeners.add(listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","notify","forEach","listener","pushModalRoot","overlayRoot","id","popModalRoot","some","entry","filter","isTopModalRoot","_stack","length","getTopModalOverlayRoot","_stack$
|
|
1
|
+
{"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","notify","forEach","listener","pushModalRoot","overlayRoot","id","popModalRoot","some","entry","filter","isTopModalRoot","_stack","length","isInside","outside","contains","getTopModalOverlayRoot","_stack$filter$pop$ove","_stack$filter$pop","pop","getTopModalRootId","_stack2","getModalOverlayRootUpTo","_stack$filter$pop$ove2","_stack$filter$pop2","subscribeToModalRoots","add","delete"],"sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"sourcesContent":["type Listener = () => void;\n\ninterface Entry {\n id: number;\n overlayRoot: HTMLElement | null;\n}\n\nconst listeners = new Set<Listener>();\n\nlet stack: Entry[] = [];\nlet lastId = 0;\n\nconst notify = (): void => listeners.forEach((listener) => listener());\n\nexport const pushModalRoot = (overlayRoot: HTMLElement | null): number => {\n lastId += 1;\n stack = [...stack, { id: lastId, overlayRoot }];\n notify();\n\n return lastId;\n};\n\nexport const popModalRoot = (id: number): void => {\n if (!stack.some((entry) => entry.id === id)) {\n return;\n }\n\n stack = stack.filter((entry) => entry.id !== id);\n notify();\n};\n\nexport const isTopModalRoot = (id: number): boolean =>\n stack[stack.length - 1]?.id === id;\n\nconst isInside = (entry: Entry, outside?: Node) =>\n !!outside && !!entry.overlayRoot && outside.contains(entry.overlayRoot);\n\n/**\n * The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root\n * whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into\n * itself.\n */\nexport const getTopModalOverlayRoot = (outside?: Node): HTMLElement | null =>\n stack.filter((entry) => !isInside(entry, outside)).pop()?.overlayRoot ?? null;\n\n/** The id of the top open modal root, or undefined when none is open. */\nexport const getTopModalRootId = (): number | undefined =>\n stack[stack.length - 1]?.id;\n\n/** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */\nexport const getModalOverlayRootUpTo = (\n id: number,\n outside?: Node\n): HTMLElement | null =>\n stack.filter((entry) => entry.id <= id && !isInside(entry, outside)).pop()\n ?.overlayRoot ?? null;\n\nexport const subscribeToModalRoots = (listener: Listener): (() => void) => {\n listeners.add(listener);\n\n return (): void => {\n listeners.delete(listener);\n };\n};\n"],"mappings":"AAOA,MAAMA,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;AAErC,IAAIC,KAAc,GAAG,EAAE;AACvB,IAAIC,MAAM,GAAG,CAAC;AAEd,MAAMC,MAAM,GAAGA,CAAA,KAAYJ,SAAS,CAACK,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;AAEtE,OAAO,MAAMC,aAAa,GAAIC,WAA+B,IAAa;EACxEL,MAAM,IAAI,CAAC;EACXD,KAAK,GAAG,CAAC,GAAGA,KAAK,EAAE;IAAEO,EAAE,EAAEN,MAAM;IAAEK;EAAY,CAAC,CAAC;EAC/CJ,MAAM,CAAC,CAAC;EAER,OAAOD,MAAM;AACf,CAAC;AAED,OAAO,MAAMO,YAAY,GAAID,EAAU,IAAW;EAChD,IAAI,CAACP,KAAK,CAACS,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACH,EAAE,KAAKA,EAAE,CAAC,EAAE;IAC3C;EACF;EAEAP,KAAK,GAAGA,KAAK,CAACW,MAAM,CAAED,KAAK,IAAKA,KAAK,CAACH,EAAE,KAAKA,EAAE,CAAC;EAChDL,MAAM,CAAC,CAAC;AACV,CAAC;AAED,OAAO,MAAMU,cAAc,GAAIL,EAAU;EAAA,IAAAM,MAAA;EAAA,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C8B,GAAG,CAACxB,QAAQ,CAAC;EAEvB,OAAO,MAAY;IACjBN,SAAS,CAAC+B,MAAM,CAACzB,QAAQ,CAAC;EAC5B,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Keeps a host node in the overlay root of the top open modal, or of the top one opened no later than
|
|
3
|
-
* upToModalRootId, and in document.body while there is none.
|
|
4
|
-
*
|
|
3
|
+
* upToModalRootId, and in document.body while there is none. A modal opened from the content of the host is not
|
|
4
|
+
* counted, since its overlay root is inside the host. The node moves as modals open and close, so content
|
|
5
|
+
* portalled into it never remounts and keeps its scroll positions and focus, and it leaves the page on unmount or
|
|
6
|
+
* when the host changes. Returns whether the
|
|
5
7
|
* host is in the page, which it is from a layout effect after the first render with it.
|
|
6
8
|
*/
|
|
7
9
|
export declare const useModalStackHost: (host: HTMLElement | null, upToModalRootId?: number) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModalStackHost.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/useModalStackHost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useModalStackHost.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/useModalStackHost.ts"],"names":[],"mappings":"AA8CA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,WAAW,GAAG,IAAI,EACxB,kBAAkB,MAAM,KACvB,OA+BF,CAAC"}
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from "react";
|
|
2
2
|
import { getModalOverlayRootUpTo, getTopModalOverlayRoot, subscribeToModalRoots } from "./modalRootStack";
|
|
3
|
+
const getScrollPositions = host => Array.from(host.querySelectorAll("*")).filter(element => element.scrollTop || element.scrollLeft).map(element => ({
|
|
4
|
+
element,
|
|
5
|
+
top: element.scrollTop,
|
|
6
|
+
left: element.scrollLeft
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* moveBefore keeps the state of the moved content. appendChild resets the scroll positions inside the host and drops
|
|
11
|
+
* the focus, so without moveBefore they are put back after the move.
|
|
12
|
+
*/
|
|
13
|
+
const moveHost = (host, target) => {
|
|
14
|
+
if (host.isConnected && target.moveBefore) {
|
|
15
|
+
target.moveBefore(host, null);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const scrollPositions = host.isConnected ? getScrollPositions(host) : [];
|
|
19
|
+
const focused = host.contains(document.activeElement) ? document.activeElement : null;
|
|
20
|
+
target.appendChild(host);
|
|
21
|
+
scrollPositions.forEach(_ref => {
|
|
22
|
+
let element = _ref.element,
|
|
23
|
+
top = _ref.top,
|
|
24
|
+
left = _ref.left;
|
|
25
|
+
element.scrollTop = top;
|
|
26
|
+
element.scrollLeft = left;
|
|
27
|
+
});
|
|
28
|
+
focused == null || focused.focus({
|
|
29
|
+
preventScroll: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
3
32
|
|
|
4
33
|
/**
|
|
5
34
|
* Keeps a host node in the overlay root of the top open modal, or of the top one opened no later than
|
|
6
|
-
* upToModalRootId, and in document.body while there is none.
|
|
7
|
-
*
|
|
35
|
+
* upToModalRootId, and in document.body while there is none. A modal opened from the content of the host is not
|
|
36
|
+
* counted, since its overlay root is inside the host. The node moves as modals open and close, so content
|
|
37
|
+
* portalled into it never remounts and keeps its scroll positions and focus, and it leaves the page on unmount or
|
|
38
|
+
* when the host changes. Returns whether the
|
|
8
39
|
* host is in the page, which it is from a layout effect after the first render with it.
|
|
9
40
|
*/
|
|
10
41
|
export const useModalStackHost = (host, upToModalRootId) => {
|
|
@@ -16,10 +47,10 @@ export const useModalStackHost = (host, upToModalRootId) => {
|
|
|
16
47
|
return undefined;
|
|
17
48
|
}
|
|
18
49
|
const place = () => {
|
|
19
|
-
var
|
|
20
|
-
const target = (
|
|
50
|
+
var _ref2;
|
|
51
|
+
const target = (_ref2 = upToModalRootId === undefined ? getTopModalOverlayRoot(host) : getModalOverlayRootUpTo(upToModalRootId, host)) != null ? _ref2 : document.body;
|
|
21
52
|
if (host.parentElement !== target) {
|
|
22
|
-
|
|
53
|
+
moveHost(host, target);
|
|
23
54
|
}
|
|
24
55
|
};
|
|
25
56
|
place();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModalStackHost.js","names":["useLayoutEffect","useState","getModalOverlayRootUpTo","getTopModalOverlayRoot","subscribeToModalRoots","
|
|
1
|
+
{"version":3,"file":"useModalStackHost.js","names":["useLayoutEffect","useState","getModalOverlayRootUpTo","getTopModalOverlayRoot","subscribeToModalRoots","getScrollPositions","host","Array","from","querySelectorAll","filter","element","scrollTop","scrollLeft","map","top","left","moveHost","target","isConnected","moveBefore","scrollPositions","focused","contains","document","activeElement","appendChild","forEach","_ref","focus","preventScroll","useModalStackHost","upToModalRootId","_useState","placedHost","setPlacedHost","undefined","place","_ref2","body","parentElement","unsubscribe","remove"],"sources":["../../../../src/components/ModalRoot/useModalStackHost.ts"],"sourcesContent":["import { useLayoutEffect, useState } from \"react\";\n\nimport {\n getModalOverlayRootUpTo,\n getTopModalOverlayRoot,\n subscribeToModalRoots,\n} from \"./modalRootStack\";\n\ntype MovableParent = HTMLElement & {\n moveBefore?: (node: Node, child: Node | null) => void;\n};\n\nconst getScrollPositions = (host: HTMLElement) =>\n Array.from(host.querySelectorAll<HTMLElement>(\"*\"))\n .filter((element) => element.scrollTop || element.scrollLeft)\n .map((element) => ({\n element,\n top: element.scrollTop,\n left: element.scrollLeft,\n }));\n\n/**\n * moveBefore keeps the state of the moved content. appendChild resets the scroll positions inside the host and drops\n * the focus, so without moveBefore they are put back after the move.\n */\nconst moveHost = (host: HTMLElement, target: MovableParent) => {\n if (host.isConnected && target.moveBefore) {\n target.moveBefore(host, null);\n\n return;\n }\n\n const scrollPositions = host.isConnected ? getScrollPositions(host) : [];\n const focused = host.contains(document.activeElement)\n ? (document.activeElement as HTMLElement)\n : null;\n\n target.appendChild(host);\n\n scrollPositions.forEach(({ element, top, left }) => {\n element.scrollTop = top;\n element.scrollLeft = left;\n });\n focused?.focus({ preventScroll: true });\n};\n\n/**\n * Keeps a host node in the overlay root of the top open modal, or of the top one opened no later than\n * upToModalRootId, and in document.body while there is none. A modal opened from the content of the host is not\n * counted, since its overlay root is inside the host. The node moves as modals open and close, so content\n * portalled into it never remounts and keeps its scroll positions and focus, and it leaves the page on unmount or\n * when the host changes. Returns whether the\n * host is in the page, which it is from a layout effect after the first render with it.\n */\nexport const useModalStackHost = (\n host: HTMLElement | null,\n upToModalRootId?: number\n): boolean => {\n const [placedHost, setPlacedHost] = useState<HTMLElement | null>(null);\n\n useLayoutEffect(() => {\n if (!host) {\n return undefined;\n }\n\n const place = () => {\n const target =\n (upToModalRootId === undefined\n ? getTopModalOverlayRoot(host)\n : getModalOverlayRootUpTo(upToModalRootId, host)) ?? document.body;\n\n if (host.parentElement !== target) {\n moveHost(host, target);\n }\n };\n\n place();\n setPlacedHost(host);\n\n const unsubscribe = subscribeToModalRoots(place);\n\n return () => {\n unsubscribe();\n host.remove();\n };\n }, [host, upToModalRootId]);\n\n return host !== null && placedHost === host;\n};\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAEjD,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,qBAAqB,QAChB,kBAAkB;AAMzB,MAAMC,kBAAkB,GAAIC,IAAiB,IAC3CC,KAAK,CAACC,IAAI,CAACF,IAAI,CAACG,gBAAgB,CAAc,GAAG,CAAC,CAAC,CAChDC,MAAM,CAAEC,OAAO,IAAKA,OAAO,CAACC,SAAS,IAAID,OAAO,CAACE,UAAU,CAAC,CAC5DC,GAAG,CAAEH,OAAO,KAAM;EACjBA,OAAO;EACPI,GAAG,EAAEJ,OAAO,CAACC,SAAS;EACtBI,IAAI,EAAEL,OAAO,CAACE;AAChB,CAAC,CAAC,CAAC;;AAEP;AACA;AACA;AACA;AACA,MAAMI,QAAQ,GAAGA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G,IAAI,CAAC,GAC5BJ,uBAAuB,CAAC8B,eAAe,EAAE1B,IAAI,CAAC,YAAAgC,KAAA,GAAKd,QAAQ,CAACe,IAAI;MAEtE,IAAIjC,IAAI,CAACkC,aAAa,KAAKtB,MAAM,EAAE;QACjCD,QAAQ,CAACX,IAAI,EAAEY,MAAM,CAAC;MACxB;IACF,CAAC;IAEDmB,KAAK,CAAC,CAAC;IACPF,aAAa,CAAC7B,IAAI,CAAC;IAEnB,MAAMmC,WAAW,GAAGrC,qBAAqB,CAACiC,KAAK,CAAC;IAEhD,OAAO,MAAM;MACXI,WAAW,CAAC,CAAC;MACbnC,IAAI,CAACoC,MAAM,CAAC,CAAC;IACf,CAAC;EACH,CAAC,EAAE,CAACpC,IAAI,EAAE0B,eAAe,CAAC,CAAC;EAE3B,OAAO1B,IAAI,KAAK,IAAI,IAAI4B,UAAU,KAAK5B,IAAI;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectFormModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectFormModal/ObjectFormModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,
|
|
1
|
+
{"version":3,"file":"ObjectFormModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectFormModal/ObjectFormModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAI3D,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC1E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,2GAA2G;IAC3G,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iGAAiG;IACjG,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,eAAO,MAAM,eAAe;;wCA4E3B,CAAC"}
|
|
@@ -6,55 +6,37 @@ import classnames from "classnames";
|
|
|
6
6
|
import { StyledObjectFormModal, StyledObjectFormModalClose } from "./Styles";
|
|
7
7
|
import { LayerContextProvider } from "../../helpers";
|
|
8
8
|
import { layers } from "../../utils";
|
|
9
|
-
import {
|
|
9
|
+
import { DialogFrame } from "../Dialog/DialogFrame";
|
|
10
|
+
import { dialogSizes } from "../Dialog/Styles";
|
|
10
11
|
import { useFluidHeightAnimation } from "../Dialog/useFluidHeightAnimation";
|
|
11
12
|
import { CancelCrossIcon } from "../Icons";
|
|
12
|
-
import { Modal } from "../Modal";
|
|
13
|
-
import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
|
|
14
13
|
// A sheet puts its content on a lower layer. The form modal always covers the page, the menu and the sheet.
|
|
15
14
|
const MODAL_LAYER = {
|
|
16
15
|
zIndex: layers.skyscraper
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
// Modal only treats a child as a transition when its props already carry `in`.
|
|
20
|
-
const ObjectFormModalSurface = _ref => {
|
|
21
|
-
let _ref$in = _ref.in,
|
|
22
|
-
inProp = _ref$in === void 0 ? false : _ref$in,
|
|
23
|
-
onEnter = _ref.onEnter,
|
|
24
|
-
onExited = _ref.onExited,
|
|
25
|
-
children = _ref.children;
|
|
26
|
-
return /*#__PURE__*/React.createElement(StyledDialogViewport, {
|
|
27
|
-
className: "c-object-form-modal-viewport"
|
|
28
|
-
}, /*#__PURE__*/React.createElement(SlideFromTop, {
|
|
29
|
-
in: inProp,
|
|
30
|
-
onEnter: onEnter,
|
|
31
|
-
onExited: onExited
|
|
32
|
-
}, children));
|
|
33
|
-
};
|
|
34
|
-
ObjectFormModalSurface.displayName = "ObjectFormModalSurface";
|
|
35
|
-
export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
17
|
+
export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
36
18
|
var _dialogSizes$size;
|
|
37
|
-
let children =
|
|
38
|
-
|
|
39
|
-
open =
|
|
40
|
-
onClose =
|
|
41
|
-
label =
|
|
42
|
-
|
|
43
|
-
size =
|
|
44
|
-
|
|
45
|
-
enableBackgroundClick =
|
|
46
|
-
|
|
47
|
-
disableCloseOnEsc =
|
|
48
|
-
|
|
49
|
-
disableFocusLock =
|
|
50
|
-
|
|
51
|
-
fill =
|
|
52
|
-
|
|
53
|
-
closeButton =
|
|
54
|
-
|
|
55
|
-
closeLabel =
|
|
56
|
-
className =
|
|
57
|
-
rest = _objectWithoutPropertiesLoose(
|
|
19
|
+
let children = _ref.children,
|
|
20
|
+
_ref$open = _ref.open,
|
|
21
|
+
open = _ref$open === void 0 ? false : _ref$open,
|
|
22
|
+
onClose = _ref.onClose,
|
|
23
|
+
label = _ref.label,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? "s" : _ref$size,
|
|
26
|
+
_ref$enableBackground = _ref.enableBackgroundClick,
|
|
27
|
+
enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
|
|
28
|
+
_ref$disableCloseOnEs = _ref.disableCloseOnEsc,
|
|
29
|
+
disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
|
|
30
|
+
_ref$disableFocusLock = _ref.disableFocusLock,
|
|
31
|
+
disableFocusLock = _ref$disableFocusLock === void 0 ? false : _ref$disableFocusLock,
|
|
32
|
+
_ref$fill = _ref.fill,
|
|
33
|
+
fill = _ref$fill === void 0 ? false : _ref$fill,
|
|
34
|
+
_ref$closeButton = _ref.closeButton,
|
|
35
|
+
closeButton = _ref$closeButton === void 0 ? false : _ref$closeButton,
|
|
36
|
+
_ref$closeLabel = _ref.closeLabel,
|
|
37
|
+
closeLabel = _ref$closeLabel === void 0 ? "Close" : _ref$closeLabel,
|
|
38
|
+
className = _ref.className,
|
|
39
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
58
40
|
const _useState = useState(null),
|
|
59
41
|
surfaceNode = _useState[0],
|
|
60
42
|
setSurfaceNode = _useState[1];
|
|
@@ -69,33 +51,28 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
69
51
|
useFluidHeightAnimation(surfaceNode, true);
|
|
70
52
|
return /*#__PURE__*/React.createElement(LayerContextProvider, {
|
|
71
53
|
value: MODAL_LAYER
|
|
72
|
-
}, /*#__PURE__*/React.createElement(
|
|
54
|
+
}, /*#__PURE__*/React.createElement(DialogFrame, {
|
|
73
55
|
open: open,
|
|
74
56
|
onClose: onClose,
|
|
75
|
-
|
|
57
|
+
enableBackgroundClick: enableBackgroundClick,
|
|
76
58
|
disableCloseOnEsc: disableCloseOnEsc,
|
|
77
59
|
disableFocusLock: disableFocusLock,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
type: "button",
|
|
95
|
-
className: "c-object-form-modal-close",
|
|
96
|
-
"aria-label": closeLabel,
|
|
97
|
-
onClick: onClose
|
|
98
|
-
}, /*#__PURE__*/React.createElement(CancelCrossIcon, null)) : null, children))));
|
|
60
|
+
surface: /*#__PURE__*/React.createElement(StyledObjectFormModal, _extends({}, rest, {
|
|
61
|
+
ref: setSurface,
|
|
62
|
+
role: "dialog",
|
|
63
|
+
"aria-modal": "true",
|
|
64
|
+
"aria-label": label,
|
|
65
|
+
$maxWidth: (_dialogSizes$size = dialogSizes[size]) != null ? _dialogSizes$size : dialogSizes.s,
|
|
66
|
+
$fill: fill || closeButton,
|
|
67
|
+
$closeButton: closeButton,
|
|
68
|
+
className: classnames("c-object-form-modal", className)
|
|
69
|
+
}), closeButton ? /*#__PURE__*/React.createElement(StyledObjectFormModalClose, {
|
|
70
|
+
type: "button",
|
|
71
|
+
className: "c-object-form-modal-close",
|
|
72
|
+
"aria-label": closeLabel,
|
|
73
|
+
onClick: onClose
|
|
74
|
+
}, /*#__PURE__*/React.createElement(CancelCrossIcon, null)) : null, children)
|
|
75
|
+
}));
|
|
99
76
|
});
|
|
100
77
|
ObjectFormModal.displayName = "ObjectFormModal";
|
|
101
78
|
//# sourceMappingURL=ObjectFormModal.js.map
|