@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.
Files changed (38) hide show
  1. package/dist/cjs/components/GlobalPortal/GlobalPortal.js +2 -16
  2. package/dist/cjs/components/GlobalPortal/GlobalPortal.js.map +1 -1
  3. package/dist/cjs/components/ModalRoot/ModalRoot.js +21 -1
  4. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  5. package/dist/cjs/components/ModalRoot/modalRootStack.js +16 -1
  6. package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
  7. package/dist/cjs/components/ModalRoot/useModalStackHost.js +47 -0
  8. package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -0
  9. package/dist/cjs/components/Sheet/Sheet.js +19 -5
  10. package/dist/cjs/components/Sheet/Sheet.js.map +1 -1
  11. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +56 -0
  12. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -0
  13. package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts.map +1 -1
  14. package/dist/esm/components/GlobalPortal/GlobalPortal.js +3 -17
  15. package/dist/esm/components/GlobalPortal/GlobalPortal.js.map +1 -1
  16. package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
  17. package/dist/esm/components/ModalRoot/ModalRoot.js +21 -1
  18. package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
  19. package/dist/esm/components/ModalRoot/modalRootStack.d.ts +4 -0
  20. package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
  21. package/dist/esm/components/ModalRoot/modalRootStack.js +13 -0
  22. package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
  23. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +8 -0
  24. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -0
  25. package/dist/esm/components/ModalRoot/useModalStackHost.js +35 -0
  26. package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -0
  27. package/dist/esm/components/Sheet/Sheet.d.ts.map +1 -1
  28. package/dist/esm/components/Sheet/Sheet.js +19 -5
  29. package/dist/esm/components/Sheet/Sheet.js.map +1 -1
  30. package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts +13 -0
  31. package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -0
  32. package/dist/esm/components/Sheet/useHostAboveOpenModal.js +42 -0
  33. package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -0
  34. package/dist/index.js +128 -21
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.min.js +1 -1
  37. package/dist/index.min.js.map +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useHostAboveOpenModal = void 0;
7
+ var _react = require("react");
8
+ var _modalRootStack = require("../ModalRoot/modalRootStack");
9
+ var _useModalStackHost = require("../ModalRoot/useModalStackHost");
10
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
+ var createHost = function createHost() {
17
+ var host = document.createElement("div");
18
+ host.className = "c-sheet-modal-host";
19
+ return host;
20
+ };
21
+
22
+ /**
23
+ * A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside
24
+ * the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation
25
+ * the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal
26
+ * closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without
27
+ * remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the
28
+ * sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.
29
+ */
30
+ var useHostAboveOpenModal = exports.useHostAboveOpenModal = function useHostAboveOpenModal(visible, enabled) {
31
+ var _captured$host, _captured$host2;
32
+ var _useState = (0, _react.useState)(false),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ wasVisible = _useState2[0],
35
+ setWasVisible = _useState2[1];
36
+ var _useState3 = (0, _react.useState)(null),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ captured = _useState4[0],
39
+ setCaptured = _useState4[1];
40
+
41
+ // The modal is picked only as the sheet opens, never on a later render while it stays open.
42
+ if (visible !== wasVisible) {
43
+ setWasVisible(visible);
44
+ var modalRootId = visible && enabled ? (0, _modalRootStack.getTopModalRootId)() : undefined;
45
+ setCaptured(modalRootId === undefined ? null : {
46
+ modalRootId,
47
+ host: createHost()
48
+ });
49
+ }
50
+ var placed = (0, _useModalStackHost.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);
51
+ return {
52
+ host: (_captured$host2 = captured === null || captured === void 0 ? void 0 : captured.host) !== null && _captured$host2 !== void 0 ? _captured$host2 : null,
53
+ pending: captured !== null && !placed
54
+ };
55
+ };
56
+ //# sourceMappingURL=useHostAboveOpenModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHostAboveOpenModal.js","names":["_react","require","_modalRootStack","_useModalStackHost","_slicedToArray","r","e","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","t","toString","call","slice","constructor","name","Array","from","test","length","n","l","Symbol","iterator","i","u","f","o","next","Object","done","push","value","return","isArray","createHost","host","document","createElement","className","useHostAboveOpenModal","exports","visible","enabled","_captured$host","_captured$host2","_useState","useState","_useState2","wasVisible","setWasVisible","_useState3","_useState4","captured","setCaptured","modalRootId","getTopModalRootId","undefined","placed","useModalStackHost","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,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAAmE,SAAAG,eAAAC,CAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,CAAA,KAAAG,qBAAA,CAAAH,CAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,CAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAJ,CAAA,EAAAO,CAAA,QAAAP,CAAA,2BAAAA,CAAA,SAAAQ,iBAAA,CAAAR,CAAA,EAAAO,CAAA,OAAAE,CAAA,MAAAC,QAAA,CAAAC,IAAA,CAAAX,CAAA,EAAAY,KAAA,6BAAAH,CAAA,IAAAT,CAAA,CAAAa,WAAA,KAAAJ,CAAA,GAAAT,CAAA,CAAAa,WAAA,CAAAC,IAAA,aAAAL,CAAA,cAAAA,CAAA,GAAAM,KAAA,CAAAC,IAAA,CAAAhB,CAAA,oBAAAS,CAAA,+CAAAQ,IAAA,CAAAR,CAAA,IAAAD,iBAAA,CAAAR,CAAA,EAAAO,CAAA;AAAA,SAAAC,kBAAAR,CAAA,EAAAO,CAAA,aAAAA,CAAA,IAAAA,CAAA,GAAAP,CAAA,CAAAkB,MAAA,MAAAX,CAAA,GAAAP,CAAA,CAAAkB,MAAA,YAAAjB,CAAA,M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ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalPortal.d.ts","sourceRoot":"","sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAerE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;mBAAkB,iBAAiB;;CAuB3D,CAAC"}
1
+ {"version":3,"file":"GlobalPortal.d.ts","sourceRoot":"","sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAYpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;mBAAkB,iBAAiB;;CAM3D,CAAC"}
@@ -1,6 +1,6 @@
1
- import { useLayoutEffect, useState } from "react";
1
+ import { useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
- import { getTopModalOverlayRoot, subscribeToModalRoots } from "../ModalRoot/modalRootStack";
3
+ import { useModalStackHost } from "../ModalRoot/useModalStackHost";
4
4
  const createHost = () => {
5
5
  const host = document.createElement("div");
6
6
  host.className = "c-global-portal";
@@ -18,21 +18,7 @@ export const GlobalPortal = _ref => {
18
18
  let children = _ref.children;
19
19
  const _useState = useState(createHost),
20
20
  host = _useState[0];
21
- useLayoutEffect(() => {
22
- const place = () => {
23
- var _getTopModalOverlayRo;
24
- const target = (_getTopModalOverlayRo = getTopModalOverlayRoot()) != null ? _getTopModalOverlayRo : document.body;
25
- if (host.parentElement !== target) {
26
- target.appendChild(host);
27
- }
28
- };
29
- place();
30
- const unsubscribe = subscribeToModalRoots(place);
31
- return () => {
32
- unsubscribe();
33
- host.remove();
34
- };
35
- }, [host]);
21
+ useModalStackHost(host);
36
22
  return /*#__PURE__*/ReactDOM.createPortal(children, host);
37
23
  };
38
24
  GlobalPortal.displayName = "GlobalPortal";
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalPortal.js","names":["useLayoutEffect","useState","ReactDOM","getTopModalOverlayRoot","subscribeToModalRoots","createHost","host","document","createElement","className","GlobalPortal","_ref","children","_useState","place","_getTopModalOverlayRo","target","body","parentElement","appendChild","unsubscribe","remove","createPortal","displayName"],"sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"sourcesContent":["import { PropsWithChildren, useLayoutEffect, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport {\n getTopModalOverlayRoot,\n subscribeToModalRoots,\n} from \"../ModalRoot/modalRootStack\";\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-global-portal\";\n\n return host;\n};\n\n/**\n * Renders content that must stay above every modal, such as toasts. Everything outside an open native modal is inert,\n * so the content follows the top open modal into its overlay root and comes back to document.body once none is open.\n * The host node moves instead of the content being portalled again, so the content never remounts on the way.\n * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads\n * no size there, and a transition that runs while the host moves restarts.\n */\nexport const GlobalPortal = ({ children }: PropsWithChildren) => {\n const [host] = useState(createHost);\n\n useLayoutEffect(() => {\n const place = () => {\n const target = getTopModalOverlayRoot() ?? document.body;\n\n if (host.parentElement !== target) {\n target.appendChild(host);\n }\n };\n\n place();\n\n const unsubscribe = subscribeToModalRoots(place);\n\n return () => {\n unsubscribe();\n host.remove();\n };\n }, [host]);\n\n return ReactDOM.createPortal(children, host);\n};\n\nGlobalPortal.displayName = \"GlobalPortal\";\n"],"mappings":"AAAA,SAA4BA,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AACpE,OAAOC,QAAQ,MAAM,WAAW;AAEhC,SACEC,sBAAsB,EACtBC,qBAAqB,QAChB,6BAA6B;AAEpC,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAG,iBAAiB;EAElC,OAAOH,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,GAAGC,IAAA,IAAqC;EAAA,IAAlCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACrC,MAAAC,SAAA,GAAeZ,QAAQ,CAACI,UAAU,CAAC;IAA5BC,IAAI,GAAAO,SAAA;EAEXb,eAAe,CAAC,MAAM;IACpB,MAAMc,KAAK,GAAGA,CAAA,KAAM;MAAA,IAAAC,qBAAA;MAClB,MAAMC,MAAM,IAAAD,qBAAA,GAAGZ,sBAAsB,CAAC,CAAC,YAAAY,qBAAA,GAAIR,QAAQ,CAACU,IAAI;MAExD,IAAIX,IAAI,CAACY,aAAa,KAAKF,MAAM,EAAE;QACjCA,MAAM,CAACG,WAAW,CAACb,IAAI,CAAC;MAC1B;IACF,CAAC;IAEDQ,KAAK,CAAC,CAAC;IAEP,MAAMM,WAAW,GAAGhB,qBAAqB,CAACU,KAAK,CAAC;IAEhD,OAAO,MAAM;MACXM,WAAW,CAAC,CAAC;MACbd,IAAI,CAACe,MAAM,CAAC,CAAC;IACf,CAAC;EACH,CAAC,EAAE,CAACf,IAAI,CAAC,CAAC;EAEV,oBAAOJ,QAAQ,CAACoB,YAAY,CAACV,QAAQ,EAAEN,IAAI,CAAC;AAC9C,CAAC;AAEDI,YAAY,CAACa,WAAW,GAAG,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"GlobalPortal.js","names":["useState","ReactDOM","useModalStackHost","createHost","host","document","createElement","className","GlobalPortal","_ref","children","_useState","createPortal","displayName"],"sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"sourcesContent":["import { PropsWithChildren, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport { useModalStackHost } from \"../ModalRoot/useModalStackHost\";\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-global-portal\";\n\n return host;\n};\n\n/**\n * Renders content that must stay above every modal, such as toasts. Everything outside an open native modal is inert,\n * so the content follows the top open modal into its overlay root and comes back to document.body once none is open.\n * The host node moves instead of the content being portalled again, so the content never remounts on the way.\n * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads\n * no size there, and a transition that runs while the host moves restarts.\n */\nexport const GlobalPortal = ({ children }: PropsWithChildren) => {\n const [host] = useState(createHost);\n\n useModalStackHost(host);\n\n return ReactDOM.createPortal(children, host);\n};\n\nGlobalPortal.displayName = \"GlobalPortal\";\n"],"mappings":"AAAA,SAA4BA,QAAQ,QAAQ,OAAO;AACnD,OAAOC,QAAQ,MAAM,WAAW;AAEhC,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAG,iBAAiB;EAElC,OAAOH,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,GAAGC,IAAA,IAAqC;EAAA,IAAlCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACrC,MAAAC,SAAA,GAAeX,QAAQ,CAACG,UAAU,CAAC;IAA5BC,IAAI,GAAAO,SAAA;EAEXT,iBAAiB,CAACE,IAAI,CAAC;EAEvB,oBAAOH,QAAQ,CAACW,YAAY,CAACF,QAAQ,EAAEN,IAAI,CAAC;AAC9C,CAAC;AAEDI,YAAY,CAACK,WAAW,GAAG,cAAc","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ModalRoot.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,EAEd,UAAU,EAEV,SAAS,EAMV,MAAM,OAAO,CAAC;AAUf,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,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AK,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,0FAyRrB,CAAC"}
@@ -105,7 +105,7 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
105
105
  return undefined;
106
106
  }
107
107
  const handleKeyDown = event => {
108
- var _overlayRootRef$curre;
108
+ var _overlayRootRef$curre, _overlayRootRef$curre2;
109
109
  const stackId = stackIdRef.current;
110
110
  if (stackId === undefined || !isTopModalRoot(stackId) || event.defaultPrevented || event.key !== "Escape" && event.key !== "Esc") {
111
111
  return;
@@ -116,6 +116,12 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
116
116
  return;
117
117
  }
118
118
  event.preventDefault();
119
+
120
+ // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take
121
+ // still belongs to it, so the dialog only stops the browser from closing itself.
122
+ if ((_overlayRootRef$curre2 = overlayRootRef.current) != null && _overlayRootRef$curre2.contains(event.target)) {
123
+ return;
124
+ }
119
125
  if (openRef.current) {
120
126
  dismissRef.current == null || dismissRef.current("escape");
121
127
  }
@@ -128,7 +134,14 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
128
134
  return undefined;
129
135
  }
130
136
  const handleCancel = event => {
137
+ var _overlayRootRef$curre3;
131
138
  event.preventDefault();
139
+
140
+ // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows
141
+ // would close the dialog under the layer. While the focus is in that layer, the close request is its own.
142
+ if ((_overlayRootRef$curre3 = overlayRootRef.current) != null && _overlayRootRef$curre3.contains(document.activeElement)) {
143
+ return;
144
+ }
132
145
  if (openRef.current) {
133
146
  dismissRef.current == null || dismissRef.current("escape");
134
147
  }
@@ -163,12 +176,19 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
163
176
  // React events from a portal bubble through the React tree, so an Escape from the content would reach an
164
177
  // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.
165
178
  const handleKeyDown = useCallback(event => {
179
+ var _overlayRootRef$curre4;
166
180
  onKeyDown == null || onKeyDown(event);
167
181
  if (event.defaultPrevented || event.key !== "Escape" && event.key !== "Esc" || stackIdRef.current === undefined || !isTopModalRoot(stackIdRef.current)) {
168
182
  return;
169
183
  }
170
184
  event.preventDefault();
171
185
  event.stopPropagation();
186
+
187
+ // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that
188
+ // opened this dialog, but it leaves the dialog open.
189
+ if ((_overlayRootRef$curre4 = overlayRootRef.current) != null && _overlayRootRef$curre4.contains(event.target)) {
190
+ return;
191
+ }
172
192
  if (openRef.current) {
173
193
  dismissRef.current == null || dismissRef.current("escape");
174
194
  }
@@ -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","stackId","defaultPrevented","key","target","document","body","querySelector","preventDefault","addEventListener","removeEventListener","handleCancel","handleNativeClose","handlePointerDown","currentTarget","handleClick","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 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 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 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,EACX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AC,CAAC,GAC9CpD,QACmB,CAAC,eAC1B7B,KAAA,CAAAkF,aAAA;IAAKhE,GAAG,EAAEkC,cAAe;IAACtB,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDd,SAAS,CAAC0E,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.\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,UA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U;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":[]}
@@ -4,6 +4,10 @@ export declare const popModalRoot: (id: number) => void;
4
4
  export declare const isTopModalRoot: (id: number) => boolean;
5
5
  /** The overlay root of the top open modal root, where content that must stay above every modal goes. */
6
6
  export declare const getTopModalOverlayRoot: () => HTMLElement | null;
7
+ /** The id of the top open modal root, or undefined when none is open. */
8
+ 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;
7
11
  export declare const subscribeToModalRoots: (listener: Listener) => (() => void);
8
12
  export {};
9
13
  //# 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;AAErC,wGAAwG;AACxG,eAAO,MAAM,sBAAsB,QAAO,WAAW,GAAG,IACV,CAAC;AAE/C,eAAO,MAAM,qBAAqB,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAMrE,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;AAErC,wGAAwG;AACxG,eAAO,MAAM,sBAAsB,QAAO,WAAW,GAAG,IACV,CAAC;AAE/C,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,QAAO,MAAM,GAAG,SACjB,CAAC;AAE9B,6FAA6F;AAC7F,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,KAAG,WAAW,GAAG,IAIlE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAMrE,CAAC"}
@@ -28,6 +28,19 @@ export const getTopModalOverlayRoot = () => {
28
28
  var _stack$overlayRoot, _stack2;
29
29
  return (_stack$overlayRoot = (_stack2 = stack[stack.length - 1]) == null ? void 0 : _stack2.overlayRoot) != null ? _stack$overlayRoot : null;
30
30
  };
31
+
32
+ /** The id of the top open modal root, or undefined when none is open. */
33
+ export const getTopModalRootId = () => {
34
+ var _stack3;
35
+ return (_stack3 = stack[stack.length - 1]) == null ? void 0 : _stack3.id;
36
+ };
37
+
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 _entries$overlayRoot, _entries;
41
+ const entries = stack.filter(entry => entry.id <= id);
42
+ return (_entries$overlayRoot = (_entries = entries[entries.length - 1]) == null ? void 0 : _entries.overlayRoot) != null ? _entries$overlayRoot : null;
43
+ };
31
44
  export const subscribeToModalRoots = listener => {
32
45
  listeners.add(listener);
33
46
  return () => {
@@ -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$overlayRoot","_stack2","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\n/** The overlay root of the top open modal root, where content that must stay above every modal goes. */\nexport const getTopModalOverlayRoot = (): HTMLElement | null =>\n stack[stack.length - 1]?.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,OACvC,EAAAA,MAAA,GAAAb,KAAK,CAACA,KAAK,CAACc,MAAM,GAAG,CAAC,CAAC,qBAAvBD,MAAA,CAAyBN,EAAE,MAAKA,EAAE;AAAA;;AAEpC;AACA,OAAO,MAAMQ,sBAAsB,GAAGA,CAAA;EAAA,IAAAC,kBAAA,EAAAC,OAAA;EAAA,QAAAD,kBAAA,IAAAC,OAAA,GACpCjB,KAAK,CAACA,KAAK,CAACc,MAAM,GAAG,CAAC,CAAC,qBAAvBG,OAAA,CAAyBX,WAAW,YAAAU,kBAAA,GAAI,IAAI;AAAA;AAE9C,OAAO,MAAME,qBAAqB,GAAId,QAAkB,IAAmB;EACzEN,SAAS,CAACqB,GAAG,CAACf,QAAQ,CAAC;EAEvB,OAAO,MAAY;IACjBN,SAAS,CAACsB,MAAM,CAAChB,QAAQ,CAAC;EAC5B,CAAC;AACH,CAAC","ignoreList":[]}
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$overlayRoot","_stack2","getTopModalRootId","_stack3","getModalOverlayRootUpTo","_entries$overlayRoot","_entries","entries","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\n/** The overlay root of the top open modal root, where content that must stay above every modal goes. */\nexport const getTopModalOverlayRoot = (): HTMLElement | null =>\n stack[stack.length - 1]?.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. */\nexport const getModalOverlayRootUpTo = (id: number): HTMLElement | null => {\n const entries = stack.filter((entry) => entry.id <= id);\n\n return entries[entries.length - 1]?.overlayRoot ?? null;\n};\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,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KAAK,IAAKA,KAAK,CAACH,EAAE,IAAIA,EAAE,CAAC;EAEvD,QAAAc,oBAAA,IAAAC,QAAA,GAAOC,OAAO,CAACA,OAAO,CAACT,MAAM,GAAG,CAAC,CAAC,qBAA3BQ,QAAA,CAA6BhB,WAAW,YAAAe,oBAAA,GAAI,IAAI;AACzD,CAAC;AAED,OAAO,MAAMG,qBAAqB,GAAIpB,QAAkB,IAAmB;EACzEN,SAAS,CAAC2B,GAAG,CAACrB,QAAQ,CAAC;EAEvB,OAAO,MAAY;IACjBN,SAAS,CAAC4B,MAAM,CAACtB,QAAQ,CAAC;EAC5B,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ /**
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. The node moves as modals open and close, so content
4
+ * portalled into it never remounts, and it leaves the page on unmount or when the host changes. Returns whether the
5
+ * host is in the page, which it is from a layout effect after the first render with it.
6
+ */
7
+ export declare const useModalStackHost: (host: HTMLElement | null, upToModalRootId?: number) => boolean;
8
+ //# sourceMappingURL=useModalStackHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModalStackHost.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/useModalStackHost.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,WAAW,GAAG,IAAI,EACxB,kBAAkB,MAAM,KACvB,OA+BF,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { useLayoutEffect, useState } from "react";
2
+ import { getModalOverlayRootUpTo, getTopModalOverlayRoot, subscribeToModalRoots } from "./modalRootStack";
3
+
4
+ /**
5
+ * 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. The node moves as modals open and close, so content
7
+ * portalled into it never remounts, and it leaves the page on unmount or when the host changes. Returns whether the
8
+ * host is in the page, which it is from a layout effect after the first render with it.
9
+ */
10
+ export const useModalStackHost = (host, upToModalRootId) => {
11
+ const _useState = useState(null),
12
+ placedHost = _useState[0],
13
+ setPlacedHost = _useState[1];
14
+ useLayoutEffect(() => {
15
+ if (!host) {
16
+ return undefined;
17
+ }
18
+ const place = () => {
19
+ var _ref;
20
+ const target = (_ref = upToModalRootId === undefined ? getTopModalOverlayRoot() : getModalOverlayRootUpTo(upToModalRootId)) != null ? _ref : document.body;
21
+ if (host.parentElement !== target) {
22
+ target.appendChild(host);
23
+ }
24
+ };
25
+ place();
26
+ setPlacedHost(host);
27
+ const unsubscribe = subscribeToModalRoots(place);
28
+ return () => {
29
+ unsubscribe();
30
+ host.remove();
31
+ };
32
+ }, [host, upToModalRootId]);
33
+ return host !== null && placedHost === host;
34
+ };
35
+ //# sourceMappingURL=useModalStackHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModalStackHost.js","names":["useLayoutEffect","useState","getModalOverlayRootUpTo","getTopModalOverlayRoot","subscribeToModalRoots","useModalStackHost","host","upToModalRootId","_useState","placedHost","setPlacedHost","undefined","place","_ref","target","document","body","parentElement","appendChild","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\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. The node moves as modals open and close, so content\n * portalled into it never remounts, and it leaves the page on unmount or 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()\n : getModalOverlayRootUpTo(upToModalRootId)) ?? document.body;\n\n if (host.parentElement !== target) {\n target.appendChild(host);\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;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,IAAwB,EACxBC,eAAwB,KACZ;EACZ,MAAAC,SAAA,GAAoCP,QAAQ,CAAqB,IAAI,CAAC;IAA/DQ,UAAU,GAAAD,SAAA;IAAEE,aAAa,GAAAF,SAAA;EAEhCR,eAAe,CAAC,MAAM;IACpB,IAAI,CAACM,IAAI,EAAE;MACT,OAAOK,SAAS;IAClB;IAEA,MAAMC,KAAK,GAAGA,CAAA,KAAM;MAAA,IAAAC,IAAA;MAClB,MAAMC,MAAM,IAAAD,IAAA,GACTN,eAAe,KAAKI,SAAS,GAC1BR,sBAAsB,CAAC,CAAC,GACxBD,uBAAuB,CAACK,eAAe,CAAC,YAAAM,IAAA,GAAKE,QAAQ,CAACC,IAAI;MAEhE,IAAIV,IAAI,CAACW,aAAa,KAAKH,MAAM,EAAE;QACjCA,MAAM,CAACI,WAAW,CAACZ,IAAI,CAAC;MAC1B;IACF,CAAC;IAEDM,KAAK,CAAC,CAAC;IACPF,aAAa,CAACJ,IAAI,CAAC;IAEnB,MAAMa,WAAW,GAAGf,qBAAqB,CAACQ,KAAK,CAAC;IAEhD,OAAO,MAAM;MACXO,WAAW,CAAC,CAAC;MACbb,IAAI,CAACc,MAAM,CAAC,CAAC;IACf,CAAC;EACH,CAAC,EAAE,CAACd,IAAI,EAAEC,eAAe,CAAC,CAAC;EAE3B,OAAOD,IAAI,KAAK,IAAI,IAA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oot":"","sources":["../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,aAAa,EAId,MAAM,OAAO,CAAC;AA8Ff,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,KAAK,oHA+MjB,CAAC"}
@@ -4,11 +4,13 @@ const _excluded = ["children", "onClose", "controls", "open", "animation", "posi
4
4
  import React, { useCallback, useEffect, forwardRef, useState, useImperativeHandle, useRef } from "react";
5
5
  import classnames from "classnames";
6
6
  import { StyledAnimatedSpan, StyledCssTransition, StyledHeader, StyledIconsWrapperSmall, StyledListSeparator, StyledSheetIcons, StyledSheetWrapper, SHEET_ENTER_MS, SHEET_EXIT_MS, StyledSheetSurface, StyledSheetWrapperPaper } from "./Styles";
7
+ import { PortalContainerProvider, usePortalContainer } from "../../helpers";
7
8
  import { IconButton } from "../IconButton";
8
9
  import { Overlay } from "../Overlay";
9
10
  import { Tooltip } from "../Tooltip";
10
11
  import { Fade } from "../Transitions";
11
12
  import { Window } from "../Window";
13
+ import { useHostAboveOpenModal } from "./useHostAboveOpenModal";
12
14
  const INSET_VAR = "--c-sheet-inset-right";
13
15
  const INSET_DURATION_VAR = "--c-sheet-inset-duration";
14
16
  // The controls column stands 48px left of the sheet. With less room it is not there.
@@ -100,12 +102,12 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
100
102
  const _useState2 = useState(true),
101
103
  exited = _useState2[0],
102
104
  setExited = _useState2[1];
103
- // Clicks pass through the overlay until it has faded in, and again from the first moment it fades out.
105
+ // Clicks pass through the overlay until it has faded in, and again from the first moment it fades out. Over a
106
+ // native dialog it takes them all the time, since a click through it would hit the dialog's backdrop.
104
107
  const _useState3 = useState(false),
105
108
  overlayEntered = _useState3[0],
106
109
  setOverlayEntered = _useState3[1];
107
110
  const wrapperRef = useRef(null);
108
- useSheetInset(wrapperRef, open && position === "right");
109
111
  useEffect(() => {
110
112
  setOpen(defaultOpen);
111
113
  }, [defaultOpen]);
@@ -134,10 +136,17 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
134
136
  useImperativeHandle(ref, () => ({
135
137
  close: handleClose
136
138
  }));
137
- if (!open && exited) {
139
+ const portalContainer = usePortalContainer();
140
+ const _useHostAboveOpenModa = useHostAboveOpenModal(open || !exited, portalContainer === undefined),
141
+ modalHost = _useHostAboveOpenModa.host,
142
+ modalHostPending = _useHostAboveOpenModa.pending;
143
+
144
+ // A pending sheet renders no wrapper yet, so the inset starts once it does.
145
+ useSheetInset(wrapperRef, open && position === "right" && !modalHostPending);
146
+ if (!open && exited || modalHostPending) {
138
147
  return null;
139
148
  }
140
- return /*#__PURE__*/React.createElement(Window, _extends({}, rest, {
149
+ const sheetWindow = /*#__PURE__*/React.createElement(Window, _extends({}, rest, {
141
150
  // The overlay and the sheet take the clicks, so the window lets them through where the overlay does.
142
151
  style: _extends({}, rest.style, {
143
152
  pointerEvents: "none"
@@ -154,7 +163,7 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
154
163
  onClick: handleBackgroundClick,
155
164
  disableBackgroundColor: disableBackgroundColor,
156
165
  style: {
157
- pointerEvents: open && overlayEntered ? "auto" : "none"
166
+ pointerEvents: modalHost || open && overlayEntered ? "auto" : "none"
158
167
  }
159
168
  })), /*#__PURE__*/React.createElement(StyledSheetWrapper, {
160
169
  ref: wrapperRef,
@@ -206,6 +215,11 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
206
215
  variant: "text gray"
207
216
  }, IconComponent));
208
217
  })), /*#__PURE__*/React.createElement(StyledListSeparator, null)), children)))));
218
+
219
+ // The provider is always there, so the Window keeps its place in the tree when the sheet gets a host.
220
+ return /*#__PURE__*/React.createElement(PortalContainerProvider, {
221
+ value: modalHost != null ? modalHost : portalContainer
222
+ }, sheetWindow);
209
223
  });
210
224
  Sheet.displayName = "Sheet";
211
225
  //# sourceMappingURL=Sheet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sheet.js","names":["React","useCallback","useEffect","forwardRef","useState","useImperativeHandle","useRef","classnames","StyledAnimatedSpan","StyledCssTransition","StyledHeader","StyledIconsWrapperSmall","StyledListSeparator","StyledSheetIcons","StyledSheetWrapper","SHEET_ENTER_MS","SHEET_EXIT_MS","StyledSheetSurface","StyledSheetWrapperPaper","IconButton","Overlay","Tooltip","Fade","Window","INSET_VAR","INSET_DURATION_VAR","CONTROLS_ROOM","useSheetInset","wrapperRef","isOn","wrapper","current","undefined","root","document","documentElement","update","_wrapper$getBoundingC","getBoundingClientRect","left","style","setProperty","clientWidth","removeProperty","observer","ResizeObserver","isWidth","event","propertyName","startWidth","target","endWidth","observe","window","addEventListener","disconnect","removeEventListener","Sheet","_ref","ref","children","onClose","_ref$controls","controls","_ref$open","open","defaultOpen","_ref$animation","animation","_ref$position","position","_ref$mode","mode","maxWidth","_ref$surface","surface","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundColor","bodyStyle","bodyClassName","_ref$disableBackgroun2","disableBackgroundClick","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","_useState3","overlayEntered","setOverlayEntered","handleEnter","handleExited","handleClose","handleOverlayEntered","handleOverlayExit","handleBackgroundClick","preventDefault","close","createElement","_extends","pointerEvents","in","timeout","onEntered","onExit","onClick","className","$position","$mode","$maxWidth","appear","classNames","$direction","onEnter","onExited","length","map","_ref2","index","IconComponent","icon","tooltip","disabled","title","disable","key","$disabled","paperClass","$surface","_ref3","variant","displayName"],"sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n forwardRef,\n HTMLAttributes,\n useState,\n CSSProperties,\n MouseEvent,\n useImperativeHandle,\n useRef,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledAnimatedSpan,\n StyledCssTransition,\n StyledHeader,\n StyledIconsWrapperSmall,\n StyledListSeparator,\n StyledSheetIcons,\n StyledSheetWrapper,\n SHEET_ENTER_MS,\n SHEET_EXIT_MS,\n StyledSheetSurface,\n StyledSheetWrapperPaper,\n} from \"./Styles\";\nimport { IconButton } from \"../IconButton\";\nimport { Overlay } from \"../Overlay\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Fade } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\nconst INSET_VAR = \"--c-sheet-inset-right\";\nconst INSET_DURATION_VAR = \"--c-sheet-inset-duration\";\n// The controls column stands 48px left of the sheet. With less room it is not there.\nconst CONTROLS_ROOM = 64;\n\n// A right sheet tells the page, on the root, how far from the right edge it starts, so a floating part of the page\n// can move out of its way with the same timing.\nconst useSheetInset = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n isOn: boolean\n) => {\n useEffect(() => {\n const wrapper = wrapperRef.current;\n\n if (!isOn || !wrapper) {\n return undefined;\n }\n\n const root = document.documentElement;\n const update = () => {\n const { left } = wrapper.getBoundingClientRect();\n\n if (left >= CONTROLS_ROOM) {\n root.style.setProperty(INSET_VAR, `${root.clientWidth - left}px`);\n } else {\n root.style.removeProperty(INSET_VAR);\n }\n };\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? undefined\n : // eslint-disable-next-line compat/compat\n new ResizeObserver(update);\n\n // While the width moves, the edge moves on every frame, so the parts follow it with no timing of their own.\n const isWidth = (event: Event) =>\n (event as TransitionEvent).propertyName === \"max-width\";\n const startWidth = (event: Event) => {\n if (event.target === wrapper && isWidth(event)) {\n root.style.setProperty(INSET_DURATION_VAR, \"0ms\");\n }\n };\n const endWidth = (event: Event) => {\n if (event.target === wrapper && isWidth(event)) {\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_ENTER_MS}ms`);\n update();\n }\n };\n\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_ENTER_MS}ms`);\n update();\n observer?.observe(wrapper);\n window.addEventListener(\"resize\", update);\n wrapper.addEventListener(\"transitionrun\", startWidth);\n wrapper.addEventListener(\"transitionend\", endWidth);\n wrapper.addEventListener(\"transitioncancel\", endWidth);\n\n return () => {\n observer?.disconnect();\n window.removeEventListener(\"resize\", update);\n wrapper.removeEventListener(\"transitionrun\", startWidth);\n wrapper.removeEventListener(\"transitionend\", endWidth);\n wrapper.removeEventListener(\"transitioncancel\", endWidth);\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_EXIT_MS}ms`);\n root.style.removeProperty(INSET_VAR);\n };\n }, [wrapperRef, isOn]);\n};\n\ninterface ControlProps {\n onClick: () => void;\n icon: React.ReactElement;\n tooltip: string;\n disabled: boolean;\n className: string;\n}\n\ninterface ISheet {\n onClose?: () => void;\n controls?: ControlProps[];\n open?: boolean;\n animation?: \"top\" | \"bottom\" | \"left\" | \"right\";\n position?: \"center\" | \"left\" | \"right\";\n mode?: \"normal\" | \"stretch\";\n /** The widest the sheet gets in stretch mode. A number is in pixels. */\n maxWidth?: number | string;\n /** \"sheet\" draws the paper on the sheet surface with large corners. */\n surface?: \"paper\" | \"sheet\";\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableBackgroundColor?: boolean;\n bodyStyle?: CSSProperties;\n bodyClassName?: string;\n disableBackgroundClick?: boolean;\n}\n\nexport interface SheetMethods {\n close: () => void;\n}\n\ntype SheetProps = ISheet & HTMLAttributes<HTMLDivElement>;\n\nexport const Sheet = forwardRef<SheetMethods, SheetProps>(\n (\n {\n children,\n onClose,\n controls = [],\n open: defaultOpen = false,\n animation = \"top\",\n position = \"center\",\n mode = \"normal\",\n maxWidth,\n surface = \"paper\",\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundColor = false,\n bodyStyle,\n bodyClassName,\n disableBackgroundClick = false,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n // Clicks pass through the overlay until it has faded in, and again from the first moment it fades out.\n const [overlayEntered, setOverlayEntered] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useSheetInset(wrapperRef, open && position === \"right\");\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n onClose?.();\n }, [onClose]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, []);\n\n const handleOverlayEntered = useCallback(() => {\n setOverlayEntered(true);\n }, []);\n\n const handleOverlayExit = useCallback(() => {\n setOverlayEntered(false);\n }, []);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n handleClose();\n }\n },\n [disableBackgroundClick, handleClose]\n );\n\n useImperativeHandle(ref, () => ({\n close: handleClose,\n }));\n\n if (!open && exited) {\n return null;\n }\n\n return (\n <Window\n {...rest}\n // The overlay and the sheet take the clicks, so the window lets them through where the overlay does.\n style={{ ...rest.style, pointerEvents: \"none\" }}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n >\n <Fade\n in={open}\n timeout={open ? SHEET_ENTER_MS : SHEET_EXIT_MS}\n onEntered={handleOverlayEntered}\n onExit={handleOverlayExit}\n >\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n style={{\n pointerEvents: open && overlayEntered ? \"auto\" : \"none\",\n }}\n />\n </Fade>\n <StyledSheetWrapper\n ref={wrapperRef}\n className={classnames(\"c-sheet__wrapper\", bodyClassName)}\n style={bodyStyle}\n $position={position}\n $mode={mode}\n $maxWidth={maxWidth}\n >\n <StyledCssTransition\n appear\n in={open}\n timeout={SHEET_ENTER_MS}\n classNames=\"c-sheet__animation\"\n $direction={animation}\n onEnter={handleEnter}\n onExited={handleExited}\n >\n <StyledSheetSurface>\n {controls.length > 0 && (\n <StyledSheetIcons>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={`c-sheet-control-${index}`}\n >\n <StyledAnimatedSpan\n onClick={onClick}\n $disabled={disabled}\n className={className}\n >\n {IconComponent}\n </StyledAnimatedSpan>\n </Tooltip>\n )\n )}\n </StyledSheetIcons>\n )}\n <StyledSheetWrapperPaper\n paperClass=\"c-sheet__wrapper__paper\"\n $surface={surface}\n >\n {controls.length > 0 && (\n <StyledHeader>\n <StyledIconsWrapperSmall>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={index}\n >\n <IconButton\n onClick={onClick}\n disabled={disabled}\n className={className}\n variant=\"text gray\"\n >\n {IconComponent}\n </IconButton>\n </Tooltip>\n )\n )}\n </StyledIconsWrapperSmall>\n <StyledListSeparator />\n </StyledHeader>\n )}\n {children}\n </StyledSheetWrapperPaper>\n </StyledSheetSurface>\n </StyledCssTransition>\n </StyledSheetWrapper>\n </Window>\n );\n }\n);\n\nSheet.displayName = \"Sheet\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,UAAU,EAEVC,QAAQ,EAGRC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,uBAAuB,EACvBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,uBAAuB,QAClB,UAAU;AACjB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;AAElC,MAAMC,SAAS,GAAG,uBAAuB;AACzC,MAAMC,kBAAkB,GAAG,0BAA0B;AACrD;AACA,MAAMC,aAAa,GAAG,EAAE;;AAExB;AACA;AACA,MAAMC,aAAa,GAAGA,CACpBC,UAA2C,EAC3CC,IAAa,KACV;EACH3B,SAAS,CAAC,MAAM;IACd,MAAM4B,OAAO,GAAGF,UAAU,CAACG,OAAO;IAElC,IAAI,CAACF,IAAI,IAAI,CAACC,OAAO,EAAE;MACrB,OAAOE,SAAS;IAClB;IAEA,MAAMC,IAAI,GAAGC,QAAQ,CAACC,eAAe;IACrC,MAAMC,MAAM,GAAGA,CAAA,KAAM;MACnB,MAAAC,qBAAA,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ACjBiB,QAAQ,EAAEA,QAAS;MACnBhB,SAAS,EAAEA,SAAU;MACrBwB,OAAO,EAAC;IAAW,GAElBX,aACS,CACL,CAAC;EAAA,CAEd,CACuB,CAAC,eAC1B9H,KAAA,CAAAyG,aAAA,CAAC7F,mBAAmB,MAAE,CACV,CACf,EACAgD,QACsB,CACP,CACD,CACH,CACd,CAAC;AAEb,CACF,CAAC;AAEDH,KAAK,CAACiF,WAAW,GAAG,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Sheet.js","names":["React","useCallback","useEffect","forwardRef","useState","useImperativeHandle","useRef","classnames","StyledAnimatedSpan","StyledCssTransition","StyledHeader","StyledIconsWrapperSmall","StyledListSeparator","StyledSheetIcons","StyledSheetWrapper","SHEET_ENTER_MS","SHEET_EXIT_MS","StyledSheetSurface","StyledSheetWrapperPaper","PortalContainerProvider","usePortalContainer","IconButton","Overlay","Tooltip","Fade","Window","useHostAboveOpenModal","INSET_VAR","INSET_DURATION_VAR","CONTROLS_ROOM","useSheetInset","wrapperRef","isOn","wrapper","current","undefined","root","document","documentElement","update","_wrapper$getBoundingC","getBoundingClientRect","left","style","setProperty","clientWidth","removeProperty","observer","ResizeObserver","isWidth","event","propertyName","startWidth","target","endWidth","observe","window","addEventListener","disconnect","removeEventListener","Sheet","_ref","ref","children","onClose","_ref$controls","controls","_ref$open","open","defaultOpen","_ref$animation","animation","_ref$position","position","_ref$mode","mode","maxWidth","_ref$surface","surface","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundColor","bodyStyle","bodyClassName","_ref$disableBackgroun2","disableBackgroundClick","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","_useState3","overlayEntered","setOverlayEntered","handleEnter","handleExited","handleClose","handleOverlayEntered","handleOverlayExit","handleBackgroundClick","preventDefault","close","portalContainer","_useHostAboveOpenModa","modalHost","host","modalHostPending","pending","sheetWindow","createElement","_extends","pointerEvents","in","timeout","onEntered","onExit","onClick","className","$position","$mode","$maxWidth","appear","classNames","$direction","onEnter","onExited","length","map","_ref2","index","IconComponent","icon","tooltip","disabled","title","disable","key","$disabled","paperClass","$surface","_ref3","variant","value","displayName"],"sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n forwardRef,\n HTMLAttributes,\n useState,\n CSSProperties,\n MouseEvent,\n useImperativeHandle,\n useRef,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledAnimatedSpan,\n StyledCssTransition,\n StyledHeader,\n StyledIconsWrapperSmall,\n StyledListSeparator,\n StyledSheetIcons,\n StyledSheetWrapper,\n SHEET_ENTER_MS,\n SHEET_EXIT_MS,\n StyledSheetSurface,\n StyledSheetWrapperPaper,\n} from \"./Styles\";\nimport { PortalContainerProvider, usePortalContainer } from \"../../helpers\";\nimport { IconButton } from \"../IconButton\";\nimport { Overlay } from \"../Overlay\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Fade } from \"../Transitions\";\nimport { Window } from \"../Window\";\nimport { useHostAboveOpenModal } from \"./useHostAboveOpenModal\";\n\nconst INSET_VAR = \"--c-sheet-inset-right\";\nconst INSET_DURATION_VAR = \"--c-sheet-inset-duration\";\n// The controls column stands 48px left of the sheet. With less room it is not there.\nconst CONTROLS_ROOM = 64;\n\n// A right sheet tells the page, on the root, how far from the right edge it starts, so a floating part of the page\n// can move out of its way with the same timing.\nconst useSheetInset = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n isOn: boolean\n) => {\n useEffect(() => {\n const wrapper = wrapperRef.current;\n\n if (!isOn || !wrapper) {\n return undefined;\n }\n\n const root = document.documentElement;\n const update = () => {\n const { left } = wrapper.getBoundingClientRect();\n\n if (left >= CONTROLS_ROOM) {\n root.style.setProperty(INSET_VAR, `${root.clientWidth - left}px`);\n } else {\n root.style.removeProperty(INSET_VAR);\n }\n };\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? undefined\n : // eslint-disable-next-line compat/compat\n new ResizeObserver(update);\n\n // While the width moves, the edge moves on every frame, so the parts follow it with no timing of their own.\n const isWidth = (event: Event) =>\n (event as TransitionEvent).propertyName === \"max-width\";\n const startWidth = (event: Event) => {\n if (event.target === wrapper && isWidth(event)) {\n root.style.setProperty(INSET_DURATION_VAR, \"0ms\");\n }\n };\n const endWidth = (event: Event) => {\n if (event.target === wrapper && isWidth(event)) {\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_ENTER_MS}ms`);\n update();\n }\n };\n\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_ENTER_MS}ms`);\n update();\n observer?.observe(wrapper);\n window.addEventListener(\"resize\", update);\n wrapper.addEventListener(\"transitionrun\", startWidth);\n wrapper.addEventListener(\"transitionend\", endWidth);\n wrapper.addEventListener(\"transitioncancel\", endWidth);\n\n return () => {\n observer?.disconnect();\n window.removeEventListener(\"resize\", update);\n wrapper.removeEventListener(\"transitionrun\", startWidth);\n wrapper.removeEventListener(\"transitionend\", endWidth);\n wrapper.removeEventListener(\"transitioncancel\", endWidth);\n root.style.setProperty(INSET_DURATION_VAR, `${SHEET_EXIT_MS}ms`);\n root.style.removeProperty(INSET_VAR);\n };\n }, [wrapperRef, isOn]);\n};\n\ninterface ControlProps {\n onClick: () => void;\n icon: React.ReactElement;\n tooltip: string;\n disabled: boolean;\n className: string;\n}\n\ninterface ISheet {\n onClose?: () => void;\n controls?: ControlProps[];\n open?: boolean;\n animation?: \"top\" | \"bottom\" | \"left\" | \"right\";\n position?: \"center\" | \"left\" | \"right\";\n mode?: \"normal\" | \"stretch\";\n /** The widest the sheet gets in stretch mode. A number is in pixels. */\n maxWidth?: number | string;\n /** \"sheet\" draws the paper on the sheet surface with large corners. */\n surface?: \"paper\" | \"sheet\";\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableBackgroundColor?: boolean;\n bodyStyle?: CSSProperties;\n bodyClassName?: string;\n disableBackgroundClick?: boolean;\n}\n\nexport interface SheetMethods {\n close: () => void;\n}\n\ntype SheetProps = ISheet & HTMLAttributes<HTMLDivElement>;\n\nexport const Sheet = forwardRef<SheetMethods, SheetProps>(\n (\n {\n children,\n onClose,\n controls = [],\n open: defaultOpen = false,\n animation = \"top\",\n position = \"center\",\n mode = \"normal\",\n maxWidth,\n surface = \"paper\",\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundColor = false,\n bodyStyle,\n bodyClassName,\n disableBackgroundClick = false,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n // Clicks pass through the overlay until it has faded in, and again from the first moment it fades out. Over a\n // native dialog it takes them all the time, since a click through it would hit the dialog's backdrop.\n const [overlayEntered, setOverlayEntered] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n onClose?.();\n }, [onClose]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, []);\n\n const handleOverlayEntered = useCallback(() => {\n setOverlayEntered(true);\n }, []);\n\n const handleOverlayExit = useCallback(() => {\n setOverlayEntered(false);\n }, []);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n handleClose();\n }\n },\n [disableBackgroundClick, handleClose]\n );\n\n useImperativeHandle(ref, () => ({\n close: handleClose,\n }));\n\n const portalContainer = usePortalContainer();\n const { host: modalHost, pending: modalHostPending } =\n useHostAboveOpenModal(open || !exited, portalContainer === undefined);\n\n // A pending sheet renders no wrapper yet, so the inset starts once it does.\n useSheetInset(\n wrapperRef,\n open && position === \"right\" && !modalHostPending\n );\n\n if ((!open && exited) || modalHostPending) {\n return null;\n }\n\n const sheetWindow = (\n <Window\n {...rest}\n // The overlay and the sheet take the clicks, so the window lets them through where the overlay does.\n style={{ ...rest.style, pointerEvents: \"none\" }}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n >\n <Fade\n in={open}\n timeout={open ? SHEET_ENTER_MS : SHEET_EXIT_MS}\n onEntered={handleOverlayEntered}\n onExit={handleOverlayExit}\n >\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n style={{\n pointerEvents:\n modalHost || (open && overlayEntered) ? \"auto\" : \"none\",\n }}\n />\n </Fade>\n <StyledSheetWrapper\n ref={wrapperRef}\n className={classnames(\"c-sheet__wrapper\", bodyClassName)}\n style={bodyStyle}\n $position={position}\n $mode={mode}\n $maxWidth={maxWidth}\n >\n <StyledCssTransition\n appear\n in={open}\n timeout={SHEET_ENTER_MS}\n classNames=\"c-sheet__animation\"\n $direction={animation}\n onEnter={handleEnter}\n onExited={handleExited}\n >\n <StyledSheetSurface>\n {controls.length > 0 && (\n <StyledSheetIcons>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={`c-sheet-control-${index}`}\n >\n <StyledAnimatedSpan\n onClick={onClick}\n $disabled={disabled}\n className={className}\n >\n {IconComponent}\n </StyledAnimatedSpan>\n </Tooltip>\n )\n )}\n </StyledSheetIcons>\n )}\n <StyledSheetWrapperPaper\n paperClass=\"c-sheet__wrapper__paper\"\n $surface={surface}\n >\n {controls.length > 0 && (\n <StyledHeader>\n <StyledIconsWrapperSmall>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={index}\n >\n <IconButton\n onClick={onClick}\n disabled={disabled}\n className={className}\n variant=\"text gray\"\n >\n {IconComponent}\n </IconButton>\n </Tooltip>\n )\n )}\n </StyledIconsWrapperSmall>\n <StyledListSeparator />\n </StyledHeader>\n )}\n {children}\n </StyledSheetWrapperPaper>\n </StyledSheetSurface>\n </StyledCssTransition>\n </StyledSheetWrapper>\n </Window>\n );\n\n // The provider is always there, so the Window keeps its place in the tree when the sheet gets a host.\n return (\n <PortalContainerProvider value={modalHost ?? portalContainer}>\n {sheetWindow}\n </PortalContainerProvider>\n );\n }\n);\n\nSheet.displayName = \"Sheet\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,UAAU,EAEVC,QAAQ,EAGRC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,uBAAuB,EACvBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,uBAAuB,QAClB,UAAU;AACjB,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,eAAe;AAC3E,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D,MAAMC,SAAS,GAAG,uBAAuB;AACzC,MAAMC,kBAAkB,GAAG,0BAA0B;AACrD;AACA,MAAMC,aAAa,GAAG,EAAE;;AAExB;AACA;AACA,MAAMC,aAAa,GAAGA,CACpBC,UAA2C,EAC3CC,IAAa,KACV;EACH9B,SAAS,CAAC,MAAM;IACd,MAAM+B,OAAO,GAAGF,UAAU,CAACG,OAAO;IAElC,IAAI,CAACF,IAAI,IAAI,CAACC,OAAO,EAAE;MACrB,OAAOE,SAAS;IAClB;IAEA,MAAMC,IAAI,GAAGC,QAAQ,CAACC,eAAe;IACrC,MAAMC,MAAM,GAAGA,CAAA,KAAM;MACnB,MAAAC,qBAAA,GAAiBP,OA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