@activecollab/components 2.0.532 → 2.0.533
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/ModalRoot/ModalRoot.js +48 -2
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +46 -3
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ModalRoot/useSuspendModalRoots.js +20 -0
- package/dist/cjs/components/ModalRoot/useSuspendModalRoots.js.map +1 -0
- package/dist/cjs/components/index.js +136 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +49 -3
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +15 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +43 -2
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ModalRoot/useSuspendModalRoots.d.ts +8 -0
- package/dist/esm/components/ModalRoot/useSuspendModalRoots.d.ts.map +1 -0
- package/dist/esm/components/ModalRoot/useSuspendModalRoots.js +13 -0
- package/dist/esm/components/ModalRoot/useSuspendModalRoots.js.map +1 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/index.js +106 -4
- 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
|
@@ -10,6 +10,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _modalRootStack = require("./modalRootStack");
|
|
11
11
|
var _Styles = require("./Styles");
|
|
12
12
|
var _helpers = require("../../helpers");
|
|
13
|
+
var _layers = require("../../utils/layers");
|
|
13
14
|
var _useForkRef = _interopRequireDefault(require("../../utils/useForkRef"));
|
|
14
15
|
var _excluded = ["open", "onRequestClose", "onDismissBlocked", "onClose", "disableCloseOnEsc", "disableBackgroundClick", "disableScrollLock", "children", "className", "onPointerDown", "onClick", "onKeyDown"];
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -69,8 +70,50 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
69
70
|
if (open && !mounted) {
|
|
70
71
|
setMounted(true);
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
// While suspended the dialog is open without being modal, in the page instead of the top layer, so it keeps a
|
|
75
|
+
// layer just under the overlay it was suspended for. A dismiss then would close it under that overlay.
|
|
76
|
+
// The stack calls suspend once for an entry and resume at most once, so the suspension is the stack's state.
|
|
77
|
+
var focusBeforeSuspendRef = (0, _react.useRef)(null);
|
|
78
|
+
var suspensionRef = (0, _react.useRef)({
|
|
79
|
+
suspend: function suspend() {
|
|
80
|
+
var node = dialogRef.current;
|
|
81
|
+
if (!node) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
focusBeforeSuspendRef.current = node.contains(document.activeElement) ? document.activeElement : null;
|
|
85
|
+
node.style.zIndex = String(_layers.layers.cloud - 1);
|
|
86
|
+
if (node.open) {
|
|
87
|
+
node.close();
|
|
88
|
+
node.show();
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
resume: function resume() {
|
|
92
|
+
var node = dialogRef.current;
|
|
93
|
+
if (!node) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
node.style.zIndex = "";
|
|
97
|
+
if (node.open) {
|
|
98
|
+
node.close();
|
|
99
|
+
node.showModal();
|
|
100
|
+
}
|
|
101
|
+
var focus = focusBeforeSuspendRef.current;
|
|
102
|
+
focusBeforeSuspendRef.current = null;
|
|
103
|
+
if (focus instanceof HTMLElement && node.contains(focus)) {
|
|
104
|
+
focus.focus({
|
|
105
|
+
preventScroll: true
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
72
110
|
var finishClose = (0, _react.useCallback)(function () {
|
|
73
111
|
var _dialogRef$current;
|
|
112
|
+
// A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.
|
|
113
|
+
if (dialogRef.current) {
|
|
114
|
+
dialogRef.current.style.zIndex = "";
|
|
115
|
+
}
|
|
116
|
+
|
|
74
117
|
// Content that sits in the overlay root moves out before the dialog hides it.
|
|
75
118
|
if (stackIdRef.current !== undefined) {
|
|
76
119
|
(0, _modalRootStack.popModalRoot)(stackIdRef.current);
|
|
@@ -92,7 +135,7 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
92
135
|
dialog.showModal();
|
|
93
136
|
}
|
|
94
137
|
if (stackIdRef.current === undefined) {
|
|
95
|
-
stackIdRef.current = (0, _modalRootStack.pushModalRoot)(overlayRootRef.current);
|
|
138
|
+
stackIdRef.current = (0, _modalRootStack.pushModalRoot)(overlayRootRef.current, suspensionRef.current);
|
|
96
139
|
}
|
|
97
140
|
}, [open, dialog]);
|
|
98
141
|
|
|
@@ -112,6 +155,9 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
112
155
|
}, [open, mounted, hasTransition, finishClose]);
|
|
113
156
|
var dismissRef = (0, _react.useRef)();
|
|
114
157
|
dismissRef.current = function (reason, event) {
|
|
158
|
+
if ((0, _modalRootStack.areModalRootsSuspended)()) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
115
161
|
var blocked = reason === "escape" ? disableCloseOnEsc : disableBackgroundClick;
|
|
116
162
|
if (blocked) {
|
|
117
163
|
onDismissBlocked === null || onDismissBlocked === void 0 || onDismissBlocked(reason, event);
|
|
@@ -173,7 +219,7 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
173
219
|
}
|
|
174
220
|
};
|
|
175
221
|
var handleNativeClose = function handleNativeClose() {
|
|
176
|
-
if (openRef.current && !dialog.open) {
|
|
222
|
+
if (openRef.current && !dialog.open && !(0, _modalRootStack.areModalRootsSuspended)()) {
|
|
177
223
|
dialog.showModal();
|
|
178
224
|
}
|
|
179
225
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalRoot.js","names":["_react","_interopRequireWildcard","require","_reactRemoveScroll","_classnames","_interopRequireDefault","_modalRootStack","_Styles","_helpers","_useForkRef","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","l","Symbol","iterator","u","next","done","push","value","return","isArray","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","ModalRoot","exports","forwardRef","_ref","ref","open","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","children","className","onPointerDown","onClick","onKeyDown","rest","_useState","useState","_useState2","mounted","setMounted","_useState3","_useState4","dialog","setDialog","dialogRef","useRef","setDialogNode","useCallback","node","current","handleRef","useForkRef","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","finishClose","_dialogRef$current","undefined","popModalRoot","close","useLayoutEffect","showModal","pushModalRoot","dismissRef","reason","event","blocked","useEffect","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","isTopModalRoot","defaultPrevented","key","target","document","body","querySelector","preventDefault","contains","_dismissRef$current","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","activeElement","_dismissRef$current2","handleNativeClose","handlePointerDown","currentTarget","handleClick","_dismissRef$current3","stopPropagation","_overlayRootRef$curre4","_dismissRef$current4","handleExited","createElement","Portal","RemoveScroll","forwardProps","enabled","noIsolation","StyledModalRoot","classnames","PortalContainerProvider","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 // A click does not bubble on through the React tree, as from a legacy window: a confirmation rendered in a\n // clickable row would otherwise click the row as well. React listens at the portal's container, so a click\n // listener on document or window does not see a click inside the dialog either, as with the window.\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 event.stopPropagation();\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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAAgD,IAAAQ,SAAA;AAAA,SAAAL,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,wBAAAU,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QA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SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDhB,SAAS,CAACiG,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModalRoot.js","names":["_react","_interopRequireWildcard","require","_reactRemoveScroll","_classnames","_interopRequireDefault","_modalRootStack","_Styles","_helpers","_layers","_useForkRef","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","l","Symbol","iterator","u","next","done","push","value","return","isArray","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","ModalRoot","exports","forwardRef","_ref","ref","open","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","children","className","onPointerDown","onClick","onKeyDown","rest","_useState","useState","_useState2","mounted","setMounted","_useState3","_useState4","dialog","setDialog","dialogRef","useRef","setDialogNode","useCallback","node","current","handleRef","useForkRef","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","focusBeforeSuspendRef","suspensionRef","suspend","contains","document","activeElement","style","zIndex","String","layers","cloud","close","show","resume","showModal","focus","HTMLElement","preventScroll","finishClose","_dialogRef$current","undefined","popModalRoot","useLayoutEffect","pushModalRoot","dismissRef","reason","event","areModalRootsSuspended","blocked","useEffect","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","isTopModalRoot","defaultPrevented","key","target","body","querySelector","preventDefault","_dismissRef$current","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","_dismissRef$current2","handleNativeClose","handlePointerDown","currentTarget","handleClick","_dismissRef$current3","stopPropagation","_overlayRootRef$curre4","_dismissRef$current4","handleExited","createElement","Portal","RemoveScroll","forwardProps","enabled","noIsolation","StyledModalRoot","classnames","PortalContainerProvider","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 {\n areModalRootsSuspended,\n isTopModalRoot,\n ModalRootSuspension,\n popModalRoot,\n pushModalRoot,\n} from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport { layers } from \"../../utils/layers\";\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 // While suspended the dialog is open without being modal, in the page instead of the top layer, so it keeps a\n // layer just under the overlay it was suspended for. A dismiss then would close it under that overlay.\n // The stack calls suspend once for an entry and resume at most once, so the suspension is the stack's state.\n const focusBeforeSuspendRef = useRef<Element | null>(null);\n const suspensionRef = useRef<ModalRootSuspension>({\n suspend: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n focusBeforeSuspendRef.current = node.contains(document.activeElement)\n ? document.activeElement\n : null;\n node.style.zIndex = String(layers.cloud - 1);\n\n if (node.open) {\n node.close();\n node.show();\n }\n },\n resume: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n node.style.zIndex = \"\";\n\n if (node.open) {\n node.close();\n node.showModal();\n }\n\n const focus = focusBeforeSuspendRef.current;\n focusBeforeSuspendRef.current = null;\n\n if (focus instanceof HTMLElement && node.contains(focus)) {\n focus.focus({ preventScroll: true });\n }\n },\n });\n\n const finishClose = useCallback(() => {\n // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.\n if (dialogRef.current) {\n dialogRef.current.style.zIndex = \"\";\n }\n\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(\n overlayRootRef.current,\n suspensionRef.current\n );\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 if (areModalRootsSuspended()) {\n return;\n }\n\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 && !areModalRootsSuspended()) {\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 // A click does not bubble on through the React tree, as from a legacy window: a confirmation rendered in a\n // clickable row would otherwise click the row as well. React listens at the portal's container, so a click\n // listener on document or window does not see a click inside the dialog either, as with the window.\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 event.stopPropagation();\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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IA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C,EAAE,CAACzD,IAAI,EAAEyD,WAAW,CAAC,CAAC;EAEvB,IAAI,CAACtC,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,oBACE5F,MAAA,CAAAc,OAAA,CAAA0J,aAAA,CAAChK,QAAA,CAAAiK,MAAM,qBACLzK,MAAA,CAAAc,OAAA,CAAA0J,aAAA,CAACrK,kBAAA,CAAAuK,YAAY;IACXC,YAAY;IACZnG,GAAG,EAAEgC,SAAU;IACfoE,OAAO,EAAE,CAAC1F,iBAAkB;IAC5B2F,WAAW;EAAA,gBAEX7K,MAAA,CAAAc,OAAA,CAAA0J,aAAA,CAACjK,OAAA,CAAAuK,eAAe,EAAA9I,QAAA,KACVwD,IAAI;IACRJ,SAAS,EAAE,IAAA2F,mBAAU,EAAC,cAAc,EAAE3F,SAAS,CAAE;IACjD,cAAYX,IAAI,GAAG,MAAM,GAAG,SAAU;IACtCY,aAAa,EAAE2E,iBAAkB;IACjC1E,OAAO,EAAE4E,WAAY;IACrB3E,SAAS,EAAEuD;EAAc,iBAEzB9I,MAAA,CAAAc,OAAA,CAAA0J,aAAA,CAAChK,QAAA,CAAAwK,uBAAuB;IAACpH,KAAK,EAAEmD;EAAe,GAC5C,OAAO5B,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC;IAAE8F,EAAE,EAAExG,IAAI;IAAEyG,QAAQ,EAAEX;EAAa,CAAC,CAAC,GAC9CpF,QACmB,CAAC,eAC1BnF,MAAA,CAAAc,OAAA,CAAA0J,aAAA;IAAKhG,GAAG,EAAEsC,cAAe;IAAC1B,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDhB,SAAS,CAAC+G,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -3,21 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.subscribeToModalRoots = exports.pushModalRoot = exports.popModalRoot = exports.isTopModalRoot = exports.getTopModalRootId = exports.getTopModalOverlayRoot = exports.getModalOverlayRootUpTo = void 0;
|
|
6
|
+
exports.suspendModalRoots = exports.subscribeToModalRoots = exports.pushModalRoot = exports.popModalRoot = exports.isTopModalRoot = exports.getTopModalRootId = exports.getTopModalOverlayRoot = exports.getModalOverlayRootUpTo = exports.areModalRootsSuspended = void 0;
|
|
7
7
|
var listeners = new Set();
|
|
8
8
|
var stack = [];
|
|
9
9
|
var lastId = 0;
|
|
10
|
+
var suspensions = 0;
|
|
10
11
|
var notify = function notify() {
|
|
11
12
|
return listeners.forEach(function (listener) {
|
|
12
13
|
return listener();
|
|
13
14
|
});
|
|
14
15
|
};
|
|
15
|
-
var pushModalRoot = exports.pushModalRoot = function pushModalRoot(overlayRoot) {
|
|
16
|
+
var pushModalRoot = exports.pushModalRoot = function pushModalRoot(overlayRoot, suspension) {
|
|
16
17
|
lastId += 1;
|
|
17
18
|
stack = [...stack, {
|
|
18
19
|
id: lastId,
|
|
19
|
-
overlayRoot
|
|
20
|
+
overlayRoot,
|
|
21
|
+
suspension
|
|
20
22
|
}];
|
|
23
|
+
|
|
24
|
+
// A modal root that opens while the others are suspended joins them, or it would leave the overlay inert.
|
|
25
|
+
if (suspensions > 0) {
|
|
26
|
+
suspension === null || suspension === void 0 || suspension.suspend();
|
|
27
|
+
}
|
|
21
28
|
notify();
|
|
22
29
|
return lastId;
|
|
23
30
|
};
|
|
@@ -71,4 +78,40 @@ var subscribeToModalRoots = exports.subscribeToModalRoots = function subscribeTo
|
|
|
71
78
|
listeners.delete(listener);
|
|
72
79
|
};
|
|
73
80
|
};
|
|
81
|
+
|
|
82
|
+
/** True while suspendModalRoots holds the open modal roots non-modal. */
|
|
83
|
+
var areModalRootsSuspended = exports.areModalRootsSuspended = function areModalRootsSuspended() {
|
|
84
|
+
return suspensions > 0;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Turns every open modal root into a non-modal dialog until the returned release is called, so an overlay that a
|
|
89
|
+
* third party renders into document.body, such as the Google Drive picker, can be used above them. The dialogs keep
|
|
90
|
+
* their place, look, content and order, and do not close. Calls nest: the modal roots come back, from the bottom up,
|
|
91
|
+
* with the last release. A suspended dialog sits at layers.cloud - 1, so the overlay must be at layers.cloud or above;
|
|
92
|
+
* the frontend raises the Google Drive picker there in its own CSS.
|
|
93
|
+
*/
|
|
94
|
+
var suspendModalRoots = exports.suspendModalRoots = function suspendModalRoots() {
|
|
95
|
+
suspensions += 1;
|
|
96
|
+
if (suspensions === 1) {
|
|
97
|
+
[...stack].reverse().forEach(function (entry) {
|
|
98
|
+
var _entry$suspension;
|
|
99
|
+
return (_entry$suspension = entry.suspension) === null || _entry$suspension === void 0 ? void 0 : _entry$suspension.suspend();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var released = false;
|
|
103
|
+
return function () {
|
|
104
|
+
if (released) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
released = true;
|
|
108
|
+
suspensions -= 1;
|
|
109
|
+
if (suspensions === 0) {
|
|
110
|
+
stack.forEach(function (entry) {
|
|
111
|
+
var _entry$suspension2;
|
|
112
|
+
return (_entry$suspension2 = entry.suspension) === null || _entry$suspension2 === void 0 ? void 0 : _entry$suspension2.resume();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
74
117
|
//# sourceMappingURL=modalRootStack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","notify","forEach","listener","pushModalRoot","exports","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":";;;;;;
|
|
1
|
+
{"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","suspensions","notify","forEach","listener","pushModalRoot","exports","overlayRoot","suspension","id","suspend","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","areModalRootsSuspended","suspendModalRoots","reverse","_entry$suspension","released","_entry$suspension2","resume"],"sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"sourcesContent":["type Listener = () => void;\n\nexport interface ModalRootSuspension {\n suspend: () => void;\n resume: () => void;\n}\n\ninterface Entry {\n id: number;\n overlayRoot: HTMLElement | null;\n suspension?: ModalRootSuspension;\n}\n\nconst listeners = new Set<Listener>();\n\nlet stack: Entry[] = [];\nlet lastId = 0;\nlet suspensions = 0;\n\nconst notify = (): void => listeners.forEach((listener) => listener());\n\nexport const pushModalRoot = (\n overlayRoot: HTMLElement | null,\n suspension?: ModalRootSuspension\n): number => {\n lastId += 1;\n stack = [...stack, { id: lastId, overlayRoot, suspension }];\n\n // A modal root that opens while the others are suspended joins them, or it would leave the overlay inert.\n if (suspensions > 0) {\n suspension?.suspend();\n }\n\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\n/** True while suspendModalRoots holds the open modal roots non-modal. */\nexport const areModalRootsSuspended = (): boolean => suspensions > 0;\n\n/**\n * Turns every open modal root into a non-modal dialog until the returned release is called, so an overlay that a\n * third party renders into document.body, such as the Google Drive picker, can be used above them. The dialogs keep\n * their place, look, content and order, and do not close. Calls nest: the modal roots come back, from the bottom up,\n * with the last release. A suspended dialog sits at layers.cloud - 1, so the overlay must be at layers.cloud or above;\n * the frontend raises the Google Drive picker there in its own CSS.\n */\nexport const suspendModalRoots = (): (() => void) => {\n suspensions += 1;\n\n if (suspensions === 1) {\n [...stack].reverse().forEach((entry) => entry.suspension?.suspend());\n }\n\n let released = false;\n\n return () => {\n if (released) {\n return;\n }\n\n released = true;\n suspensions -= 1;\n\n if (suspensions === 0) {\n stack.forEach((entry) => entry.suspension?.resume());\n }\n };\n};\n"],"mappings":";;;;;;AAaA,IAAMA,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;AAErC,IAAIC,KAAc,GAAG,EAAE;AACvB,IAAIC,MAAM,GAAG,CAAC;AACd,IAAIC,WAAW,GAAG,CAAC;AAEnB,IAAMC,MAAM,GAAG,SAATA,MAAMA,CAAA;EAAA,OAAeL,SAAS,CAACM,OAAO,CAAC,UAACC,QAAQ;IAAA,OAAKA,QAAQ,CAAC,CAAC;EAAA,EAAC;AAAA;AAE/D,IAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CACxBE,WAA+B,EAC/BC,UAAgC,EACrB;EACXR,MAAM,IAAI,CAAC;EACXD,KAAK,GAAG,CAAC,GAAGA,KAAK,EAAE;IAAEU,EAAE,EAAET,MAAM;IAAEO,WAAW;IAAEC;EAAW,CAAC,CAAC;;EAE3D;EACA,IAAIP,WAAW,GAAG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iB,GAAA5B,OAAA,CAAA4B,iBAAA,GAAG,SAApBA,iBAAiBA,CAAA,EAAuB;EACnDjC,WAAW,IAAI,CAAC;EAEhB,IAAIA,WAAW,KAAK,CAAC,EAAE;IACrB,CAAC,GAAGF,KAAK,CAAC,CAACoC,OAAO,CAAC,CAAC,CAAChC,OAAO,CAAC,UAACU,KAAK;MAAA,IAAAuB,iBAAA;MAAA,QAAAA,iBAAA,GAAKvB,KAAK,CAACL,UAAU,cAAA4B,iBAAA,uBAAhBA,iBAAA,CAAkB1B,OAAO,CAAC,CAAC;IAAA,EAAC;EACtE;EAEA,IAAI2B,QAAQ,GAAG,KAAK;EAEpB,OAAO,YAAM;IACX,IAAIA,QAAQ,EAAE;MACZ;IACF;IAEAA,QAAQ,GAAG,IAAI;IACfpC,WAAW,IAAI,CAAC;IAEhB,IAAIA,WAAW,KAAK,CAAC,EAAE;MACrBF,KAAK,CAACI,OAAO,CAAC,UAACU,KAAK;QAAA,IAAAyB,kBAAA;QAAA,QAAAA,kBAAA,GAAKzB,KAAK,CAACL,UAAU,cAAA8B,kBAAA,uBAAhBA,kBAAA,CAAkBC,MAAM,CAAC,CAAC;MAAA,EAAC;IACtD;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSuspendModalRoots = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _modalRootStack = require("./modalRootStack");
|
|
9
|
+
/**
|
|
10
|
+
* Keeps the open native modals non-modal while active is true, so an overlay a third party renders into
|
|
11
|
+
* document.body, such as the Google Drive picker, can be used above them. They come back when active turns false
|
|
12
|
+
* or the component unmounts. A layout effect, so the overlay is never painted under a modal and the order against
|
|
13
|
+
* ModalRoot's own layout effects is fixed.
|
|
14
|
+
*/
|
|
15
|
+
var useSuspendModalRoots = exports.useSuspendModalRoots = function useSuspendModalRoots(active) {
|
|
16
|
+
(0, _react.useLayoutEffect)(function () {
|
|
17
|
+
return active ? (0, _modalRootStack.suspendModalRoots)() : undefined;
|
|
18
|
+
}, [active]);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useSuspendModalRoots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspendModalRoots.js","names":["_react","require","_modalRootStack","useSuspendModalRoots","exports","active","useLayoutEffect","suspendModalRoots","undefined"],"sources":["../../../../src/components/ModalRoot/useSuspendModalRoots.ts"],"sourcesContent":["import { useLayoutEffect } from \"react\";\n\nimport { suspendModalRoots } from \"./modalRootStack\";\n\n/**\n * Keeps the open native modals non-modal while active is true, so an overlay a third party renders into\n * document.body, such as the Google Drive picker, can be used above them. They come back when active turns false\n * or the component unmounts. A layout effect, so the overlay is never painted under a modal and the order against\n * ModalRoot's own layout effects is fixed.\n */\nexport const useSuspendModalRoots = (active: boolean): void => {\n useLayoutEffect(() => (active ? suspendModalRoots() : undefined), [active]);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,IAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAAIE,MAAe,EAAW;EAC7D,IAAAC,sBAAe,EAAC;IAAA,OAAOD,MAAM,GAAG,IAAAE,iCAAiB,EAAC,CAAC,GAAGC,SAAS;EAAA,CAAC,EAAE,CAACH,MAAM,CAAC,CAAC;AAC7E,CAAC","ignoreList":[]}
|