@activecollab/components 2.0.526 → 2.0.527
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/GlobalPortal/GlobalPortal.js +2 -16
- package/dist/cjs/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/cjs/components/ModalRoot/ModalRoot.js +21 -1
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +16 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ModalRoot/useModalStackHost.js +47 -0
- package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -0
- package/dist/cjs/components/Sheet/Sheet.js +19 -5
- package/dist/cjs/components/Sheet/Sheet.js.map +1 -1
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +56 -0
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -0
- package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts.map +1 -1
- package/dist/esm/components/GlobalPortal/GlobalPortal.js +3 -17
- package/dist/esm/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +21 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +4 -0
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +13 -0
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +8 -0
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -0
- package/dist/esm/components/ModalRoot/useModalStackHost.js +35 -0
- package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -0
- package/dist/esm/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/esm/components/Sheet/Sheet.js +19 -5
- package/dist/esm/components/Sheet/Sheet.js.map +1 -1
- package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts +13 -0
- package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -0
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js +42 -0
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -0
- package/dist/index.js +128 -21
- 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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside
|
|
3
|
+
* the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation
|
|
4
|
+
* the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal
|
|
5
|
+
* closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without
|
|
6
|
+
* remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the
|
|
7
|
+
* sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useHostAboveOpenModal: (visible: boolean, enabled: boolean) => {
|
|
10
|
+
host: HTMLElement | null;
|
|
11
|
+
pending: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useHostAboveOpenModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostAboveOpenModal.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,OAAO,EAChB,SAAS,OAAO,KACf;IAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAwB9C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { getTopModalRootId } from "../ModalRoot/modalRootStack";
|
|
3
|
+
import { useModalStackHost } from "../ModalRoot/useModalStackHost";
|
|
4
|
+
const createHost = () => {
|
|
5
|
+
const host = document.createElement("div");
|
|
6
|
+
host.className = "c-sheet-modal-host";
|
|
7
|
+
return host;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside
|
|
12
|
+
* the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation
|
|
13
|
+
* the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal
|
|
14
|
+
* closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without
|
|
15
|
+
* remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the
|
|
16
|
+
* sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.
|
|
17
|
+
*/
|
|
18
|
+
export const useHostAboveOpenModal = (visible, enabled) => {
|
|
19
|
+
var _captured$host, _captured$host2;
|
|
20
|
+
const _useState = useState(false),
|
|
21
|
+
wasVisible = _useState[0],
|
|
22
|
+
setWasVisible = _useState[1];
|
|
23
|
+
const _useState2 = useState(null),
|
|
24
|
+
captured = _useState2[0],
|
|
25
|
+
setCaptured = _useState2[1];
|
|
26
|
+
|
|
27
|
+
// The modal is picked only as the sheet opens, never on a later render while it stays open.
|
|
28
|
+
if (visible !== wasVisible) {
|
|
29
|
+
setWasVisible(visible);
|
|
30
|
+
const modalRootId = visible && enabled ? getTopModalRootId() : undefined;
|
|
31
|
+
setCaptured(modalRootId === undefined ? null : {
|
|
32
|
+
modalRootId,
|
|
33
|
+
host: createHost()
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const placed = useModalStackHost((_captured$host = captured == null ? void 0 : captured.host) != null ? _captured$host : null, captured == null ? void 0 : captured.modalRootId);
|
|
37
|
+
return {
|
|
38
|
+
host: (_captured$host2 = captured == null ? void 0 : captured.host) != null ? _captured$host2 : null,
|
|
39
|
+
pending: captured !== null && !placed
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useHostAboveOpenModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostAboveOpenModal.js","names":["useState","getTopModalRootId","useModalStackHost","createHost","host","document","createElement","className","useHostAboveOpenModal","visible","enabled","_captured$host","_captured$host2","_useState","wasVisible","setWasVisible","_useState2","captured","setCaptured","modalRootId","undefined","placed","pending"],"sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"sourcesContent":["import { useState } from \"react\";\n\nimport { getTopModalRootId } from \"../ModalRoot/modalRootStack\";\nimport { useModalStackHost } from \"../ModalRoot/useModalStackHost\";\n\ninterface Captured {\n modalRootId: number;\n host: HTMLElement;\n}\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-sheet-modal-host\";\n\n return host;\n};\n\n/**\n * A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside\n * the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation\n * the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal\n * closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without\n * remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the\n * sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.\n */\nexport const useHostAboveOpenModal = (\n visible: boolean,\n enabled: boolean\n): { host: HTMLElement | null; pending: boolean } => {\n const [wasVisible, setWasVisible] = useState(false);\n const [captured, setCaptured] = useState<Captured | null>(null);\n\n // The modal is picked only as the sheet opens, never on a later render while it stays open.\n if (visible !== wasVisible) {\n setWasVisible(visible);\n\n const modalRootId = visible && enabled ? getTopModalRootId() : undefined;\n\n setCaptured(\n modalRootId === undefined ? null : { modalRootId, host: createHost() }\n );\n }\n\n const placed = useModalStackHost(\n captured?.host ?? null,\n captured?.modalRootId\n );\n\n return {\n host: captured?.host ?? null,\n pending: captured !== null && !placed,\n };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAEhC,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,iBAAiB,QAAQ,gCAAgC;AAOlE,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAG,oBAAoB;EAErC,OAAOH,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,qBAAqB,GAAGA,CACnCC,OAAgB,EAChBC,OAAgB,KACmC;EAAA,IAAAC,cAAA,EAAAC,eAAA;EACnD,MAAAC,SAAA,GAAoCb,QAAQ,CAAC,KAAK,CAAC;IAA5Cc,UAAU,GAAAD,SAAA;IAAEE,aAAa,GAAAF,SAAA;EAChC,MAAAG,UAAA,GAAgChB,QAAQ,CAAkB,IAAI,CAAC;IAAxDiB,QAAQ,GAAAD,UAAA;IAAEE,WAAW,GAAAF,UAAA;;EAE5B;EACA,IAAIP,OAAO,KAAKK,UAAU,EAAE;IAC1BC,aAAa,CAACN,OAAO,CAAC;IAEtB,MAAMU,WAAW,GAAGV,OAAO,IAAIC,OAAO,GAAGT,iBAAiB,CAAC,CAAC,GAAGmB,SAAS;IAExEF,WAAW,CACTC,WAAW,KAAKC,SAAS,GAAG,IAAI,GAAG;MAAED,WAAW;MAAEf,IAAI,EAAED,UAAU,CAAC;IAAE,CACvE,CAAC;EACH;EAEA,MAAMkB,MAAM,GAAGnB,iBAAiB,EAAAS,cAAA,GAC9BM,QAAQ,oBAARA,QAAQ,CAAEb,IAAI,YAAAO,cAAA,GAAI,IAAI,EACtBM,QAAQ,oBAARA,QAAQ,CAAEE,WACZ,CAAC;EAED,OAAO;IACLf,IAAI,GAAAQ,eAAA,GAAEK,QAAQ,oBAARA,QAAQ,CAAEb,IAAI,YAAAQ,eAAA,GAAI,IAAI;IAC5BU,OAAO,EAAEL,QAAQ,KAAK,IAAI,IAAI,CAACI;EACjC,CAAC;AACH,CAAC","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -19265,6 +19265,21 @@
|
|
|
19265
19265
|
var _stack$overlayRoot, _stack2;
|
|
19266
19266
|
return (_stack$overlayRoot = (_stack2 = stack[stack.length - 1]) === null || _stack2 === void 0 ? void 0 : _stack2.overlayRoot) !== null && _stack$overlayRoot !== void 0 ? _stack$overlayRoot : null;
|
|
19267
19267
|
};
|
|
19268
|
+
|
|
19269
|
+
/** The id of the top open modal root, or undefined when none is open. */
|
|
19270
|
+
var getTopModalRootId = function getTopModalRootId() {
|
|
19271
|
+
var _stack3;
|
|
19272
|
+
return (_stack3 = stack[stack.length - 1]) === null || _stack3 === void 0 ? void 0 : _stack3.id;
|
|
19273
|
+
};
|
|
19274
|
+
|
|
19275
|
+
/** The overlay root of the top modal root among those opened no later than the given one. */
|
|
19276
|
+
var getModalOverlayRootUpTo = function getModalOverlayRootUpTo(id) {
|
|
19277
|
+
var _entries$overlayRoot, _entries;
|
|
19278
|
+
var entries = stack.filter(function (entry) {
|
|
19279
|
+
return entry.id <= id;
|
|
19280
|
+
});
|
|
19281
|
+
return (_entries$overlayRoot = (_entries = entries[entries.length - 1]) === null || _entries === void 0 ? void 0 : _entries.overlayRoot) !== null && _entries$overlayRoot !== void 0 ? _entries$overlayRoot : null;
|
|
19282
|
+
};
|
|
19268
19283
|
var subscribeToModalRoots = function subscribeToModalRoots(listener) {
|
|
19269
19284
|
listeners.add(listener);
|
|
19270
19285
|
return function () {
|
|
@@ -19384,7 +19399,7 @@
|
|
|
19384
19399
|
return undefined;
|
|
19385
19400
|
}
|
|
19386
19401
|
var handleKeyDown = function handleKeyDown(event) {
|
|
19387
|
-
var _overlayRootRef$curre;
|
|
19402
|
+
var _overlayRootRef$curre, _overlayRootRef$curre2;
|
|
19388
19403
|
var stackId = stackIdRef.current;
|
|
19389
19404
|
if (stackId === undefined || !isTopModalRoot(stackId) || event.defaultPrevented || event.key !== "Escape" && event.key !== "Esc") {
|
|
19390
19405
|
return;
|
|
@@ -19395,6 +19410,12 @@
|
|
|
19395
19410
|
return;
|
|
19396
19411
|
}
|
|
19397
19412
|
event.preventDefault();
|
|
19413
|
+
|
|
19414
|
+
// A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take
|
|
19415
|
+
// still belongs to it, so the dialog only stops the browser from closing itself.
|
|
19416
|
+
if ((_overlayRootRef$curre2 = overlayRootRef.current) !== null && _overlayRootRef$curre2 !== void 0 && _overlayRootRef$curre2.contains(event.target)) {
|
|
19417
|
+
return;
|
|
19418
|
+
}
|
|
19398
19419
|
if (openRef.current) {
|
|
19399
19420
|
var _dismissRef$current;
|
|
19400
19421
|
(_dismissRef$current = dismissRef.current) === null || _dismissRef$current === void 0 || _dismissRef$current.call(dismissRef, "escape");
|
|
@@ -19410,7 +19431,14 @@
|
|
|
19410
19431
|
return undefined;
|
|
19411
19432
|
}
|
|
19412
19433
|
var handleCancel = function handleCancel(event) {
|
|
19434
|
+
var _overlayRootRef$curre3;
|
|
19413
19435
|
event.preventDefault();
|
|
19436
|
+
|
|
19437
|
+
// A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows
|
|
19438
|
+
// would close the dialog under the layer. While the focus is in that layer, the close request is its own.
|
|
19439
|
+
if ((_overlayRootRef$curre3 = overlayRootRef.current) !== null && _overlayRootRef$curre3 !== void 0 && _overlayRootRef$curre3.contains(document.activeElement)) {
|
|
19440
|
+
return;
|
|
19441
|
+
}
|
|
19414
19442
|
if (openRef.current) {
|
|
19415
19443
|
var _dismissRef$current2;
|
|
19416
19444
|
(_dismissRef$current2 = dismissRef.current) === null || _dismissRef$current2 === void 0 || _dismissRef$current2.call(dismissRef, "escape");
|
|
@@ -19447,12 +19475,19 @@
|
|
|
19447
19475
|
// React events from a portal bubble through the React tree, so an Escape from the content would reach an
|
|
19448
19476
|
// ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.
|
|
19449
19477
|
var handleKeyDown = React.useCallback(function (event) {
|
|
19478
|
+
var _overlayRootRef$curre4;
|
|
19450
19479
|
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
19451
19480
|
if (event.defaultPrevented || event.key !== "Escape" && event.key !== "Esc" || stackIdRef.current === undefined || !isTopModalRoot(stackIdRef.current)) {
|
|
19452
19481
|
return;
|
|
19453
19482
|
}
|
|
19454
19483
|
event.preventDefault();
|
|
19455
19484
|
event.stopPropagation();
|
|
19485
|
+
|
|
19486
|
+
// An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that
|
|
19487
|
+
// opened this dialog, but it leaves the dialog open.
|
|
19488
|
+
if ((_overlayRootRef$curre4 = overlayRootRef.current) !== null && _overlayRootRef$curre4 !== void 0 && _overlayRootRef$curre4.contains(event.target)) {
|
|
19489
|
+
return;
|
|
19490
|
+
}
|
|
19456
19491
|
if (openRef.current) {
|
|
19457
19492
|
var _dismissRef$current4;
|
|
19458
19493
|
(_dismissRef$current4 = dismissRef.current) === null || _dismissRef$current4 === void 0 || _dismissRef$current4.call(dismissRef, "escape");
|
|
@@ -28493,6 +28528,80 @@
|
|
|
28493
28528
|
})(["@media (min-width:640px){display:none;}"]);
|
|
28494
28529
|
StyledHeader$2.displayName = "StyledHeader";
|
|
28495
28530
|
|
|
28531
|
+
/**
|
|
28532
|
+
* Keeps a host node in the overlay root of the top open modal, or of the top one opened no later than
|
|
28533
|
+
* upToModalRootId, and in document.body while there is none. The node moves as modals open and close, so content
|
|
28534
|
+
* portalled into it never remounts, and it leaves the page on unmount or when the host changes. Returns whether the
|
|
28535
|
+
* host is in the page, which it is from a layout effect after the first render with it.
|
|
28536
|
+
*/
|
|
28537
|
+
var useModalStackHost = function useModalStackHost(host, upToModalRootId) {
|
|
28538
|
+
var _useState = React.useState(null),
|
|
28539
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28540
|
+
placedHost = _useState2[0],
|
|
28541
|
+
setPlacedHost = _useState2[1];
|
|
28542
|
+
React.useLayoutEffect(function () {
|
|
28543
|
+
if (!host) {
|
|
28544
|
+
return undefined;
|
|
28545
|
+
}
|
|
28546
|
+
var place = function place() {
|
|
28547
|
+
var _ref;
|
|
28548
|
+
var target = (_ref = upToModalRootId === undefined ? getTopModalOverlayRoot() : getModalOverlayRootUpTo(upToModalRootId)) !== null && _ref !== void 0 ? _ref : document.body;
|
|
28549
|
+
if (host.parentElement !== target) {
|
|
28550
|
+
target.appendChild(host);
|
|
28551
|
+
}
|
|
28552
|
+
};
|
|
28553
|
+
place();
|
|
28554
|
+
setPlacedHost(host);
|
|
28555
|
+
var unsubscribe = subscribeToModalRoots(place);
|
|
28556
|
+
return function () {
|
|
28557
|
+
unsubscribe();
|
|
28558
|
+
host.remove();
|
|
28559
|
+
};
|
|
28560
|
+
}, [host, upToModalRootId]);
|
|
28561
|
+
return host !== null && placedHost === host;
|
|
28562
|
+
};
|
|
28563
|
+
|
|
28564
|
+
var createHost$1 = function createHost() {
|
|
28565
|
+
var host = document.createElement("div");
|
|
28566
|
+
host.className = "c-sheet-modal-host";
|
|
28567
|
+
return host;
|
|
28568
|
+
};
|
|
28569
|
+
|
|
28570
|
+
/**
|
|
28571
|
+
* A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside
|
|
28572
|
+
* the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation
|
|
28573
|
+
* the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal
|
|
28574
|
+
* closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without
|
|
28575
|
+
* remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the
|
|
28576
|
+
* sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.
|
|
28577
|
+
*/
|
|
28578
|
+
var useHostAboveOpenModal = function useHostAboveOpenModal(visible, enabled) {
|
|
28579
|
+
var _captured$host, _captured$host2;
|
|
28580
|
+
var _useState = React.useState(false),
|
|
28581
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28582
|
+
wasVisible = _useState2[0],
|
|
28583
|
+
setWasVisible = _useState2[1];
|
|
28584
|
+
var _useState3 = React.useState(null),
|
|
28585
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
28586
|
+
captured = _useState4[0],
|
|
28587
|
+
setCaptured = _useState4[1];
|
|
28588
|
+
|
|
28589
|
+
// The modal is picked only as the sheet opens, never on a later render while it stays open.
|
|
28590
|
+
if (visible !== wasVisible) {
|
|
28591
|
+
setWasVisible(visible);
|
|
28592
|
+
var modalRootId = visible && enabled ? getTopModalRootId() : undefined;
|
|
28593
|
+
setCaptured(modalRootId === undefined ? null : {
|
|
28594
|
+
modalRootId,
|
|
28595
|
+
host: createHost$1()
|
|
28596
|
+
});
|
|
28597
|
+
}
|
|
28598
|
+
var placed = useModalStackHost((_captured$host = captured === null || captured === void 0 ? void 0 : captured.host) !== null && _captured$host !== void 0 ? _captured$host : null, captured === null || captured === void 0 ? void 0 : captured.modalRootId);
|
|
28599
|
+
return {
|
|
28600
|
+
host: (_captured$host2 = captured === null || captured === void 0 ? void 0 : captured.host) !== null && _captured$host2 !== void 0 ? _captured$host2 : null,
|
|
28601
|
+
pending: captured !== null && !placed
|
|
28602
|
+
};
|
|
28603
|
+
};
|
|
28604
|
+
|
|
28496
28605
|
var _excluded$Y = ["children", "onClose", "controls", "open", "animation", "position", "mode", "maxWidth", "surface", "disableFocusLock", "disableScrollLock", "disableBackgroundColor", "bodyStyle", "bodyClassName", "disableBackgroundClick"];
|
|
28497
28606
|
var INSET_VAR = "--c-sheet-inset-right";
|
|
28498
28607
|
var INSET_DURATION_VAR = "--c-sheet-inset-duration";
|
|
@@ -28589,13 +28698,13 @@
|
|
|
28589
28698
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
28590
28699
|
exited = _useState4[0],
|
|
28591
28700
|
setExited = _useState4[1];
|
|
28592
|
-
// Clicks pass through the overlay until it has faded in, and again from the first moment it fades out.
|
|
28701
|
+
// Clicks pass through the overlay until it has faded in, and again from the first moment it fades out. Over a
|
|
28702
|
+
// native dialog it takes them all the time, since a click through it would hit the dialog's backdrop.
|
|
28593
28703
|
var _useState5 = React.useState(false),
|
|
28594
28704
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
28595
28705
|
overlayEntered = _useState6[0],
|
|
28596
28706
|
setOverlayEntered = _useState6[1];
|
|
28597
28707
|
var wrapperRef = React.useRef(null);
|
|
28598
|
-
useSheetInset(wrapperRef, open && position === "right");
|
|
28599
28708
|
React.useEffect(function () {
|
|
28600
28709
|
setOpen(defaultOpen);
|
|
28601
28710
|
}, [defaultOpen]);
|
|
@@ -28626,10 +28735,17 @@
|
|
|
28626
28735
|
close: handleClose
|
|
28627
28736
|
};
|
|
28628
28737
|
});
|
|
28629
|
-
|
|
28738
|
+
var portalContainer = usePortalContainer();
|
|
28739
|
+
var _useHostAboveOpenModa = useHostAboveOpenModal(open || !exited, portalContainer === undefined),
|
|
28740
|
+
modalHost = _useHostAboveOpenModa.host,
|
|
28741
|
+
modalHostPending = _useHostAboveOpenModa.pending;
|
|
28742
|
+
|
|
28743
|
+
// A pending sheet renders no wrapper yet, so the inset starts once it does.
|
|
28744
|
+
useSheetInset(wrapperRef, open && position === "right" && !modalHostPending);
|
|
28745
|
+
if (!open && exited || modalHostPending) {
|
|
28630
28746
|
return null;
|
|
28631
28747
|
}
|
|
28632
|
-
|
|
28748
|
+
var sheetWindow = /*#__PURE__*/React__default["default"].createElement(Window, _extends({}, rest, {
|
|
28633
28749
|
// The overlay and the sheet take the clicks, so the window lets them through where the overlay does.
|
|
28634
28750
|
style: _objectSpread2(_objectSpread2({}, rest.style), {}, {
|
|
28635
28751
|
pointerEvents: "none"
|
|
@@ -28646,7 +28762,7 @@
|
|
|
28646
28762
|
onClick: handleBackgroundClick,
|
|
28647
28763
|
disableBackgroundColor: disableBackgroundColor,
|
|
28648
28764
|
style: {
|
|
28649
|
-
pointerEvents: open && overlayEntered ? "auto" : "none"
|
|
28765
|
+
pointerEvents: modalHost || open && overlayEntered ? "auto" : "none"
|
|
28650
28766
|
}
|
|
28651
28767
|
})), /*#__PURE__*/React__default["default"].createElement(StyledSheetWrapper, {
|
|
28652
28768
|
ref: wrapperRef,
|
|
@@ -28698,6 +28814,11 @@
|
|
|
28698
28814
|
variant: "text gray"
|
|
28699
28815
|
}, IconComponent));
|
|
28700
28816
|
})), /*#__PURE__*/React__default["default"].createElement(StyledListSeparator, null)), children)))));
|
|
28817
|
+
|
|
28818
|
+
// The provider is always there, so the Window keeps its place in the tree when the sheet gets a host.
|
|
28819
|
+
return /*#__PURE__*/React__default["default"].createElement(PortalContainerProvider, {
|
|
28820
|
+
value: modalHost !== null && modalHost !== void 0 ? modalHost : portalContainer
|
|
28821
|
+
}, sheetWindow);
|
|
28701
28822
|
});
|
|
28702
28823
|
Sheet.displayName = "Sheet";
|
|
28703
28824
|
|
|
@@ -32150,21 +32271,7 @@
|
|
|
32150
32271
|
var _useState = React.useState(createHost),
|
|
32151
32272
|
_useState2 = _slicedToArray(_useState, 1),
|
|
32152
32273
|
host = _useState2[0];
|
|
32153
|
-
|
|
32154
|
-
var place = function place() {
|
|
32155
|
-
var _getTopModalOverlayRo;
|
|
32156
|
-
var target = (_getTopModalOverlayRo = getTopModalOverlayRoot()) !== null && _getTopModalOverlayRo !== void 0 ? _getTopModalOverlayRo : document.body;
|
|
32157
|
-
if (host.parentElement !== target) {
|
|
32158
|
-
target.appendChild(host);
|
|
32159
|
-
}
|
|
32160
|
-
};
|
|
32161
|
-
place();
|
|
32162
|
-
var unsubscribe = subscribeToModalRoots(place);
|
|
32163
|
-
return function () {
|
|
32164
|
-
unsubscribe();
|
|
32165
|
-
host.remove();
|
|
32166
|
-
};
|
|
32167
|
-
}, [host]);
|
|
32274
|
+
useModalStackHost(host);
|
|
32168
32275
|
return /*#__PURE__*/ReactDOM__default["default"].createPortal(children, host);
|
|
32169
32276
|
};
|
|
32170
32277
|
GlobalPortal.displayName = "GlobalPortal";
|