@activecollab/components 2.0.554 → 2.0.556

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/ModalRoot/ModalRoot.js +248 -25
  2. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  3. package/dist/cjs/components/ModalRoot/Styles.js +2 -1
  4. package/dist/cjs/components/ModalRoot/Styles.js.map +1 -1
  5. package/dist/cjs/components/ModalRoot/modalRootStack.js +92 -23
  6. package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
  7. package/dist/cjs/components/ModalRoot/useModalStackHost.js +8 -2
  8. package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -1
  9. package/dist/cjs/utils/layers.js +8 -3
  10. package/dist/cjs/utils/layers.js.map +1 -1
  11. package/dist/cjs/utils/layers.test.js +15 -0
  12. package/dist/cjs/utils/layers.test.js.map +1 -1
  13. package/dist/esm/components/ModalRoot/ModalRoot.d.ts +6 -2
  14. package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
  15. package/dist/esm/components/ModalRoot/ModalRoot.js +246 -27
  16. package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
  17. package/dist/esm/components/ModalRoot/Styles.d.ts.map +1 -1
  18. package/dist/esm/components/ModalRoot/Styles.js +2 -1
  19. package/dist/esm/components/ModalRoot/Styles.js.map +1 -1
  20. package/dist/esm/components/ModalRoot/modalRootStack.d.ts +12 -0
  21. package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
  22. package/dist/esm/components/ModalRoot/modalRootStack.js +66 -17
  23. package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
  24. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +3 -1
  25. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -1
  26. package/dist/esm/components/ModalRoot/useModalStackHost.js +8 -2
  27. package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -1
  28. package/dist/esm/utils/layers.d.ts +4 -1
  29. package/dist/esm/utils/layers.d.ts.map +1 -1
  30. package/dist/esm/utils/layers.js +6 -3
  31. package/dist/esm/utils/layers.js.map +1 -1
  32. package/dist/esm/utils/layers.test.js +15 -0
  33. package/dist/esm/utils/layers.test.js.map +1 -1
  34. package/dist/index.js +419 -122
  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
@@ -9,6 +9,7 @@ var _reactRemoveScroll = require("react-remove-scroll");
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _modalRootStack = require("./modalRootStack");
11
11
  var _Styles = require("./Styles");
12
+ var _useModalStackHost = require("./useModalStackHost");
12
13
  var _helpers = require("../../helpers");
13
14
  var _layers = require("../../utils/layers");
14
15
  var _useForkRef = _interopRequireDefault(require("../../utils/useForkRef"));
@@ -37,6 +38,82 @@ var focusFirstFocusable = function focusFirstFocusable(dialog, overlayRoot) {
37
38
  return document.activeElement === candidate;
38
39
  });
39
40
  };
41
+ var FOCUS_HISTORY_SIZE = 5;
42
+
43
+ // Neither removed, disabled nor hidden, so the element could take the focus back.
44
+ var isFocusable = function isFocusable(element) {
45
+ return element.isConnected && element.matches(FOCUSABLE) && (
46
+ // eslint-disable-next-line compat/compat
47
+ typeof element.checkVisibility !== "function" || element.checkVisibility());
48
+ };
49
+
50
+ // A focused element that a closed dialog hides, or that turned inert, keeps the focus until the browser renders again.
51
+ var isFocusLost = function isFocusLost() {
52
+ var focus = document.activeElement;
53
+ if (!focus || focus === document.body || !focus.isConnected || focus.closest("[inert]")) {
54
+ return true;
55
+ }
56
+ var layer = focus.closest("dialog, .c-window");
57
+ return layer instanceof HTMLDialogElement && !layer.open;
58
+ };
59
+
60
+ // A sheet is a window, not a dialog, so once the last dialog is closed nothing else takes a lost focus back.
61
+ var focusTopWindowIfLost = function focusTopWindowIfLost() {
62
+ var topLayer = (0, _layers.getTopLayer)();
63
+ if ((0, _modalRootStack.getTopModalRootId)() === undefined && isFocusLost() && topLayer !== null && topLayer !== void 0 && topLayer.matches(".c-window")) {
64
+ topLayer.focus({
65
+ preventScroll: true
66
+ });
67
+ }
68
+ };
69
+ var keepFocusOn = function keepFocusOn(element) {
70
+ if (element instanceof HTMLElement && element !== document.body && element.isConnected && document.activeElement !== element) {
71
+ element.focus({
72
+ preventScroll: true
73
+ });
74
+ }
75
+ };
76
+
77
+ // A closed dialog shown as a manual popover stays in the top layer without blocking the page. showPopover focuses a
78
+ // dialog, so the focus goes back to where close() left it.
79
+ var keepInTopLayer = function keepInTopLayer(node) {
80
+ if (typeof node.showPopover !== "function") {
81
+ return;
82
+ }
83
+ var focus = document.activeElement;
84
+ node.setAttribute("popover", "manual");
85
+ // eslint-disable-next-line compat/compat
86
+ node.showPopover();
87
+ keepFocusOn(focus);
88
+ if (document.activeElement !== focus && node.contains(document.activeElement)) {
89
+ document.activeElement.blur();
90
+ }
91
+ };
92
+ var leaveTopLayer = function leaveTopLayer(node) {
93
+ if (!node.hasAttribute("popover")) {
94
+ return;
95
+ }
96
+ if (node.matches(":popover-open")) {
97
+ // eslint-disable-next-line compat/compat
98
+ node.hidePopover();
99
+ }
100
+ node.removeAttribute("popover");
101
+ };
102
+ var isHeldStackHost = function isHeldStackHost(element, overlayRoot) {
103
+ var _element$closest;
104
+ return !!overlayRoot && (element === null || element === void 0 || (_element$closest = element.closest("[".concat(_useModalStackHost.MODAL_STACK_HOST_ATTRIBUTE, "]"))) === null || _element$closest === void 0 ? void 0 : _element$closest.parentElement) === overlayRoot;
105
+ };
106
+
107
+ // Popups of the content sit in the overlay root next to the stack hosts and leave with the content.
108
+ var setContentInert = function setContentInert(content, overlayRoot, inert) {
109
+ var _overlayRoot$children;
110
+ content === null || content === void 0 || content.toggleAttribute("inert", inert);
111
+ Array.from((_overlayRoot$children = overlayRoot === null || overlayRoot === void 0 ? void 0 : overlayRoot.children) !== null && _overlayRoot$children !== void 0 ? _overlayRoot$children : []).forEach(function (child) {
112
+ if (!child.hasAttribute(_useModalStackHost.MODAL_STACK_HOST_ATTRIBUTE)) {
113
+ child.toggleAttribute("inert", inert);
114
+ }
115
+ });
116
+ };
40
117
  var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
41
118
  var open = _ref.open,
42
119
  onRequestClose = _ref.onRequestClose,
@@ -85,6 +162,8 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
85
162
  var openRef = (0, _react.useRef)(open);
86
163
  var pressStartedOnBackdrop = (0, _react.useRef)(false);
87
164
  var stackIdRef = (0, _react.useRef)();
165
+ var exitingRef = (0, _react.useRef)(false);
166
+ var contentRef = (0, _react.useRef)(null);
88
167
  var overlayRootRef = (0, _react.useRef)(null);
89
168
  // Menus and pickers opened inside portal here, into the top layer with the dialog, not under it.
90
169
  var getOverlayRoot = (0, _react.useCallback)(function () {
@@ -94,15 +173,61 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
94
173
  var disableReturnFocusRef = (0, _react.useRef)(disableReturnFocus);
95
174
  disableReturnFocusRef.current = disableReturnFocus;
96
175
 
97
- // close() gives the focus back to the element that had it before showModal when the focus is in the dialog, so
98
- // a dialog that leaves it there takes it off again. A focus outside, as in a sheet that left the overlay root,
99
- // stays where it is.
176
+ // close() of a modal gives the focus back to the element that had it before showModal, so a dialog that leaves it
177
+ // there takes it off again. A focus outside, as in a sheet that left the overlay root, stays where it is, and so
178
+ // does a focus in a sheet the overlay root holds for the exit transition. When that element is gone, also when it
179
+ // goes with the same update right after, and the last dialog closes over a sheet, the sheet takes it.
100
180
  var closeDialog = (0, _react.useCallback)(function (node) {
101
- var focusInside = node.contains(document.activeElement);
181
+ var focus = document.activeElement;
182
+ var focusHeld = isHeldStackHost(focus, overlayRootRef.current);
183
+ var focusInside = node.contains(focus) && !focusHeld;
102
184
  node.close();
103
- if (disableReturnFocusRef.current && focusInside) {
185
+ if (!focusInside) {
186
+ keepFocusOn(focus);
187
+ return;
188
+ }
189
+ if (disableReturnFocusRef.current) {
104
190
  var _document$activeEleme;
105
191
  (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 || _document$activeEleme.blur();
192
+ return;
193
+ }
194
+ focusTopWindowIfLost();
195
+ requestAnimationFrame(focusTopWindowIfLost);
196
+ }, []);
197
+ var focusHistoryRef = (0, _react.useRef)([]);
198
+ var blurredRef = (0, _react.useRef)(null);
199
+
200
+ // The browser drops the focus to the body when the focused element goes, as a toast that closes or a button that
201
+ // another replaces, so the top dialog takes it back: on the newest element focused before that is still there, or
202
+ // on itself. A layer in front of it, such as a sheet in the overlay root, keeps its own focus. A field that blurs
203
+ // itself, as on Escape or Enter, can still take the focus, so it let it go on purpose and the dialog takes it.
204
+ var restoreLostFocus = (0, _react.useCallback)(function () {
205
+ var node = dialogRef.current;
206
+ var stackId = stackIdRef.current;
207
+ var blurred = blurredRef.current;
208
+ blurredRef.current = null;
209
+ if (!(node !== null && node !== void 0 && node.open) || stackId === undefined || !(0, _modalRootStack.isTopModalRoot)(stackId) || (0, _modalRootStack.areModalRootsSuspended)() || !isFocusLost() || (0, _layers.getTopLayer)() !== node) {
210
+ return;
211
+ }
212
+ if (blurred && node.contains(blurred) && isFocusable(blurred)) {
213
+ node.focus({
214
+ preventScroll: true
215
+ });
216
+ return;
217
+ }
218
+ var restored = focusHistoryRef.current.some(function (candidate) {
219
+ if (!candidate.isConnected || !node.contains(candidate)) {
220
+ return false;
221
+ }
222
+ candidate.focus({
223
+ preventScroll: true
224
+ });
225
+ return document.activeElement === candidate;
226
+ });
227
+ if (!restored) {
228
+ node.focus({
229
+ preventScroll: true
230
+ });
106
231
  }
107
232
  }, []);
108
233
  if (open && !mounted) {
@@ -143,26 +268,56 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
143
268
  preventScroll: true
144
269
  });
145
270
  }
271
+ restoreLostFocus();
146
272
  }
147
273
  });
148
- var finishClose = (0, _react.useCallback)(function () {
274
+ var leaveStack = (0, _react.useCallback)(function () {
275
+ if (stackIdRef.current !== undefined) {
276
+ (0, _modalRootStack.popModalRoot)(stackIdRef.current);
277
+ stackIdRef.current = undefined;
278
+ }
279
+ }, []);
280
+
281
+ // The closed dialog stays shown for its exit transition, and its content takes no input until it unmounts.
282
+ // Sheets in its overlay root stay there until the transition is done.
283
+ var releaseForExit = (0, _react.useCallback)(function () {
284
+ var node = dialogRef.current;
285
+ if (!node || exitingRef.current) {
286
+ return;
287
+ }
288
+ exitingRef.current = true;
149
289
  // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.
150
- if (dialogRef.current) {
151
- dialogRef.current.style.zIndex = "";
290
+ node.style.zIndex = "";
291
+ if (stackIdRef.current !== undefined) {
292
+ (0, _modalRootStack.releaseModalRoot)(stackIdRef.current);
293
+ }
294
+
295
+ // Inert before close(), so a focus lock in a popup cannot take back the focus close() gives the opener.
296
+ setContentInert(contentRef.current, overlayRootRef.current, true);
297
+ if (node.open) {
298
+ closeDialog(node);
299
+ }
300
+ keepInTopLayer(node);
301
+ }, [closeDialog]);
302
+ var finishClose = (0, _react.useCallback)(function () {
303
+ var node = dialogRef.current;
304
+ exitingRef.current = false;
305
+ if (node) {
306
+ node.style.zIndex = "";
152
307
  }
153
308
 
154
309
  // Content that sits in the overlay root moves out before the dialog hides it.
155
- if (stackIdRef.current !== undefined) {
156
- (0, _modalRootStack.popModalRoot)(stackIdRef.current);
157
- stackIdRef.current = undefined;
310
+ leaveStack();
311
+ if (node !== null && node !== void 0 && node.open) {
312
+ closeDialog(node);
158
313
  }
159
- if (dialogRef.current) {
160
- closeDialog(dialogRef.current);
314
+ if (node) {
315
+ leaveTopLayer(node);
161
316
  }
162
317
  setMounted(false);
163
318
  setShownDialog(null);
164
319
  onClose === null || onClose === void 0 || onClose();
165
- }, [closeDialog, onClose]);
320
+ }, [closeDialog, leaveStack, onClose]);
166
321
 
167
322
  // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the
168
323
  // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it
@@ -171,14 +326,26 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
171
326
  if (!open || !dialog) {
172
327
  return;
173
328
  }
329
+ var reopenedDuringExit = exitingRef.current;
330
+ if (reopenedDuringExit) {
331
+ exitingRef.current = false;
332
+ leaveTopLayer(dialog);
333
+ setContentInert(contentRef.current, overlayRootRef.current, false);
334
+ }
174
335
  if (!dialog.open) {
175
336
  dialog.showModal();
176
337
  }
338
+ if (reopenedDuringExit && stackIdRef.current !== undefined && !(0, _modalRootStack.reopenModalRoot)(stackIdRef.current)) {
339
+ leaveStack();
340
+ }
341
+ if (reopenedDuringExit && !(0, _modalRootStack.areModalRootsSuspended)() && !dialog.contains(document.activeElement)) {
342
+ focusFirstFocusable(dialog, overlayRootRef.current);
343
+ }
177
344
  if (stackIdRef.current === undefined) {
178
345
  stackIdRef.current = (0, _modalRootStack.pushModalRoot)(overlayRootRef.current, suspensionRef.current, belowOpenSheets);
179
346
  }
180
347
  setShownDialog(dialog);
181
- }, [open, dialog, belowOpenSheets]);
348
+ }, [open, dialog, belowOpenSheets, leaveStack]);
182
349
 
183
350
  // showModal found no content to focus, so the dialog moves the focus in once the content is there, unless an
184
351
  // autoFocus field took it. A dialog that opened suspended stays out of the way of the overlay above it.
@@ -198,20 +365,23 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
198
365
  // opener: a dialog removed while open would leave it on the body.
199
366
  (0, _react.useLayoutEffect)(function () {
200
367
  return function () {
201
- if (stackIdRef.current !== undefined) {
202
- (0, _modalRootStack.popModalRoot)(stackIdRef.current);
203
- stackIdRef.current = undefined;
204
- }
368
+ exitingRef.current = false;
369
+ leaveStack();
205
370
  if (dialog !== null && dialog !== void 0 && dialog.open) {
206
371
  closeDialog(dialog);
207
372
  }
208
373
  };
209
- }, [dialog, closeDialog]);
374
+ }, [dialog, closeDialog, leaveStack]);
210
375
  (0, _react.useLayoutEffect)(function () {
211
- if (!open && mounted && !hasTransition) {
376
+ if (open || !mounted) {
377
+ return;
378
+ }
379
+ if (hasTransition) {
380
+ releaseForExit();
381
+ } else {
212
382
  finishClose();
213
383
  }
214
- }, [open, mounted, hasTransition, finishClose]);
384
+ }, [open, mounted, hasTransition, releaseForExit, finishClose]);
215
385
  var dismissRef = (0, _react.useRef)();
216
386
  dismissRef.current = function (reason, event) {
217
387
  if ((0, _modalRootStack.areModalRootsSuspended)()) {
@@ -289,6 +459,54 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
289
459
  dialog.removeEventListener("close", handleNativeClose);
290
460
  };
291
461
  }, [dialog]);
462
+
463
+ // The check waits a frame, so a close() that gives the focus back to an opener runs first. A modal root above
464
+ // leaves the stack before its close(), and may sit outside this dialog, so the stack starts the check too.
465
+ (0, _react.useEffect)(function () {
466
+ if (!dialog) {
467
+ return undefined;
468
+ }
469
+ var frame;
470
+ var scheduleRestore = function scheduleRestore() {
471
+ if (frame === undefined) {
472
+ frame = requestAnimationFrame(function () {
473
+ frame = undefined;
474
+ restoreLostFocus();
475
+ });
476
+ }
477
+ };
478
+ var handleFocusIn = function handleFocusIn(event) {
479
+ var target = event.target;
480
+ if (target instanceof HTMLElement && target !== dialog) {
481
+ focusHistoryRef.current = [target, ...focusHistoryRef.current.filter(function (element) {
482
+ return element !== target;
483
+ })].slice(0, FOCUS_HISTORY_SIZE);
484
+ }
485
+ };
486
+ var handleFocusOut = function handleFocusOut(event) {
487
+ if (!event.relatedTarget) {
488
+ blurredRef.current = event.target instanceof HTMLElement ? event.target : null;
489
+ scheduleRestore();
490
+ }
491
+ };
492
+ var observer = new MutationObserver(scheduleRestore);
493
+ observer.observe(dialog, {
494
+ childList: true,
495
+ subtree: true
496
+ });
497
+ dialog.addEventListener("focusin", handleFocusIn);
498
+ dialog.addEventListener("focusout", handleFocusOut);
499
+ var unsubscribe = (0, _modalRootStack.subscribeToModalRoots)(scheduleRestore);
500
+ return function () {
501
+ unsubscribe();
502
+ observer.disconnect();
503
+ dialog.removeEventListener("focusin", handleFocusIn);
504
+ dialog.removeEventListener("focusout", handleFocusOut);
505
+ if (frame !== undefined) {
506
+ cancelAnimationFrame(frame);
507
+ }
508
+ };
509
+ }, [dialog, restoreLostFocus]);
292
510
  var handlePointerDown = (0, _react.useCallback)(function (event) {
293
511
  pressStartedOnBackdrop.current = event.target === event.currentTarget;
294
512
  onPointerDown === null || onPointerDown === void 0 || onPointerDown(event);
@@ -350,15 +568,20 @@ var ModalRoot = exports.ModalRoot = /*#__PURE__*/(0, _react.forwardRef)(function
350
568
  ref: handleRef,
351
569
  enabled: !disableScrollLock,
352
570
  noIsolation: true
353
- }, /*#__PURE__*/_react.default.createElement(_Styles.StyledModalRoot, _extends({}, rest, {
571
+ }, /*#__PURE__*/_react.default.createElement(_Styles.StyledModalRoot, _extends({
572
+ tabIndex: -1
573
+ }, rest, {
354
574
  className: (0, _classnames.default)("c-modal-root", className),
355
575
  "data-state": open ? "open" : "closing",
356
576
  onPointerDown: handlePointerDown,
357
577
  onClick: handleClick,
358
578
  onKeyDown: handleKeyDown
359
- }), /*#__PURE__*/_react.default.createElement(_helpers.PortalContainerProvider, {
579
+ }), /*#__PURE__*/_react.default.createElement("div", {
580
+ ref: contentRef,
581
+ className: "c-modal-root__content"
582
+ }, /*#__PURE__*/_react.default.createElement(_helpers.PortalContainerProvider, {
360
583
  value: getOverlayRoot
361
- }, content), /*#__PURE__*/_react.default.createElement("div", {
584
+ }, content)), /*#__PURE__*/_react.default.createElement("div", {
362
585
  ref: overlayRootRef,
363
586
  className: "c-modal-root__overlays"
364
587
  }))));
@@ -1 +1 @@
1
- {"version":3,"file":"ModalRoot.js","names":["_react","_interopRequireWildcard","require","_reactRemoveScroll","_classnames","_interopRequireDefault","_modalRootStack","_Styles","_helpers","_layers","_useForkRef","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","l","Symbol","iterator","u","next","done","push","value","return","isArray","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","FOCUSABLE","focusFirstFocusable","dialog","overlayRoot","querySelectorAll","some","candidate","contains","focus","document","activeElement","ModalRoot","exports","forwardRef","_ref","ref","open","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","_ref$disableReturnFoc","disableReturnFocus","_ref$belowOpenSheets","belowOpenSheets","children","className","onPointerDown","onClick","onKeyDown","rest","_useState","useState","_useState2","mounted","setMounted","_useState3","_useState4","setDialog","dialogRef","useRef","setDialogNode","useCallback","node","current","handleRef","useForkRef","_useState5","_useState6","shownDialog","setShownDialog","contentShown","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","disableReturnFocusRef","closeDialog","focusInside","close","_document$activeEleme","blur","focusBeforeSuspendRef","suspensionRef","suspend","style","zIndex","String","layers","cloud","show","resume","showModal","HTMLElement","preventScroll","finishClose","undefined","popModalRoot","useLayoutEffect","pushModalRoot","areModalRootsSuspended","dismissRef","reason","event","blocked","useEffect","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","isTopModalRoot","defaultPrevented","key","target","body","querySelector","preventDefault","_dismissRef$current","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","_dismissRef$current2","handleNativeClose","isConnected","handlePointerDown","currentTarget","handleClick","_dismissRef$current3","stopPropagation","_overlayRootRef$curre4","_dismissRef$current4","handleExited","content","in","onExited","createElement","Portal","RemoveScroll","forwardProps","enabled","noIsolation","StyledModalRoot","classnames","PortalContainerProvider","displayName"],"sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport {\n areModalRootsSuspended,\n isTopModalRoot,\n ModalRootSuspension,\n popModalRoot,\n pushModalRoot,\n} from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport { layers } from \"../../utils/layers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nconst FOCUSABLE =\n \"button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, iframe, audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), [tabindex]\";\n\n// What showModal does for content that was not there yet: the first node that takes the focus gets it, so a\n// disabled or hidden one is skipped as the browser skips it.\nconst focusFirstFocusable = (\n dialog: HTMLDialogElement,\n overlayRoot: HTMLElement | null\n) => {\n Array.from(dialog.querySelectorAll<HTMLElement>(FOCUSABLE)).some(\n (candidate) => {\n if (overlayRoot?.contains(candidate)) {\n return false;\n }\n\n candidate.focus();\n\n return document.activeElement === candidate;\n }\n );\n};\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 /** Closing leaves the focus off the element that had it before the dialog opened, also when the owner unmounts it */\n disableReturnFocus?: boolean;\n /**\n * The dialog counts as opened before the sheets that are open, so they move into its overlay root and stay above\n * it. For a page dialog that a sheet covers, such as an archive that opens a task, also when the dialog mounts after\n * the sheet on a reload. A sheet that sits in the page mounts its content again in the overlay root; one that sits\n * in another modal moves without remounting, also above a modal opened in between from outside the sheet. Read when\n * the dialog opens; a later change does not move the stack entry.\n */\n belowOpenSheets?: boolean;\n /**\n * A function gets the transition state, and the dialog closes when it calls onExited. A node closes at once.\n * The content mounts once the dialog is open, a render after the dialog node, so an autoFocus field takes the focus;\n * an owner effect in the opening commit sees no content. It mounts again on every open, also when the owner reopens\n * the dialog from onClose, and loses its local state.\n */\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 disableReturnFocus = false,\n belowOpenSheets = 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 // A closed dialog hides its content, and React focuses an autoFocus field while it mounts, so the content mounts\n // only once showModal ran on this node.\n const [shownDialog, setShownDialog] = useState<HTMLDialogElement | null>(\n null\n );\n const contentShown = dialog !== null && shownDialog === dialog;\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 const disableReturnFocusRef = useRef(disableReturnFocus);\n disableReturnFocusRef.current = disableReturnFocus;\n\n // close() gives the focus back to the element that had it before showModal when the focus is in the dialog, so\n // a dialog that leaves it there takes it off again. A focus outside, as in a sheet that left the overlay root,\n // stays where it is.\n const closeDialog = useCallback((node: HTMLDialogElement) => {\n const focusInside = node.contains(document.activeElement);\n node.close();\n\n if (disableReturnFocusRef.current && focusInside) {\n (document.activeElement as HTMLElement | null)?.blur();\n }\n }, []);\n\n if (open && !mounted) {\n setMounted(true);\n }\n\n // While suspended the dialog is open without being modal, in the page instead of the top layer, so it keeps a\n // layer just under the overlay it was suspended for. A dismiss then would close it under that overlay.\n // The stack calls suspend once for an entry and resume at most once, so the suspension is the stack's state.\n const focusBeforeSuspendRef = useRef<Element | null>(null);\n const suspensionRef = useRef<ModalRootSuspension>({\n suspend: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n focusBeforeSuspendRef.current = node.contains(document.activeElement)\n ? document.activeElement\n : null;\n node.style.zIndex = String(layers.cloud - 1);\n\n if (node.open) {\n node.close();\n node.show();\n }\n },\n resume: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n node.style.zIndex = \"\";\n\n if (node.open) {\n node.close();\n node.showModal();\n }\n\n const focus = focusBeforeSuspendRef.current;\n focusBeforeSuspendRef.current = null;\n\n if (focus instanceof HTMLElement && node.contains(focus)) {\n focus.focus({ preventScroll: true });\n }\n },\n });\n\n const finishClose = useCallback(() => {\n // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.\n if (dialogRef.current) {\n dialogRef.current.style.zIndex = \"\";\n }\n\n // Content that sits in the overlay root moves out before the dialog hides it.\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n if (dialogRef.current) {\n closeDialog(dialogRef.current);\n }\n setMounted(false);\n setShownDialog(null);\n onClose?.();\n }, [closeDialog, onClose]);\n\n // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the\n // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it\n // is rendered and can get its scroll positions back.\n useLayoutEffect(() => {\n if (!open || !dialog) {\n return;\n }\n\n if (!dialog.open) {\n dialog.showModal();\n }\n\n if (stackIdRef.current === undefined) {\n stackIdRef.current = pushModalRoot(\n overlayRootRef.current,\n suspensionRef.current,\n belowOpenSheets\n );\n }\n\n setShownDialog(dialog);\n }, [open, dialog, belowOpenSheets]);\n\n // showModal found no content to focus, so the dialog moves the focus in once the content is there, unless an\n // autoFocus field took it. A dialog that opened suspended stays out of the way of the overlay above it.\n useLayoutEffect(() => {\n if (!contentShown || !dialog || areModalRootsSuspended()) {\n return;\n }\n\n const focus = document.activeElement;\n\n if (focus !== dialog && dialog.contains(focus)) {\n return;\n }\n\n focusFirstFocusable(dialog, overlayRootRef.current);\n }, [contentShown, dialog]);\n\n // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.\n // An owner that unmounts the dialog while it is open, as a form does on submit, gets the focus back on the\n // opener: a dialog removed while open would leave it on the body.\n useLayoutEffect(\n () => () => {\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n\n if (dialog?.open) {\n closeDialog(dialog);\n }\n },\n [dialog, closeDialog]\n );\n\n useLayoutEffect(() => {\n if (!open && mounted && !hasTransition) {\n finishClose();\n }\n }, [open, mounted, hasTransition, finishClose]);\n\n const dismissRef =\n useRef<\n (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void\n >();\n\n dismissRef.current = (reason, event) => {\n if (areModalRootsSuspended()) {\n return;\n }\n\n const blocked =\n reason === \"escape\" ? disableCloseOnEsc : disableBackgroundClick;\n\n if (blocked) {\n onDismissBlocked?.(reason, event);\n } else {\n onRequestClose?.(reason);\n }\n };\n\n // A prevented Escape keydown starts no close request, and the browser stops honouring a prevented cancel\n // after a while, so Escape is caught here and the cancel event only covers the other close requests.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const stackId = stackIdRef.current;\n\n if (\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\")\n ) {\n return;\n }\n\n // A menu inside closes on an Escape that reaches the body, from a listener that runs after this one.\n if (\n event.target === document.body &&\n overlayRootRef.current?.querySelector(\".c-window\")\n ) {\n return;\n }\n\n event.preventDefault();\n\n // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take\n // still belongs to it, so the dialog only stops the browser from closing itself.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [dialog]);\n\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n\n // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows\n // would close the dialog under the layer. While the focus is in that layer, the close request is its own.\n if (overlayRootRef.current?.contains(document.activeElement)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n const handleNativeClose = () => {\n if (\n openRef.current &&\n dialog.isConnected &&\n !dialog.open &&\n !areModalRootsSuspended()\n ) {\n dialog.showModal();\n }\n };\n\n dialog.addEventListener(\"cancel\", handleCancel);\n dialog.addEventListener(\"close\", handleNativeClose);\n\n return () => {\n dialog.removeEventListener(\"cancel\", handleCancel);\n dialog.removeEventListener(\"close\", handleNativeClose);\n };\n }, [dialog]);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLDialogElement>) => {\n pressStartedOnBackdrop.current = event.target === event.currentTarget;\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n // The dialog covers the viewport and its content sits inside it, so a click on the dialog itself is a\n // click on the backdrop. A press that started on the content and ended outside it is a text selection.\n // A click does not bubble on through the React tree, as from a legacy window: a confirmation rendered in a\n // clickable row would otherwise click the row as well. React listens at the portal's container, so a click\n // listener on document or window does not see a click inside the dialog either, as with the window.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n if (\n event.target === event.currentTarget &&\n pressStartedOnBackdrop.current &&\n openRef.current\n ) {\n dismissRef.current?.(\"backdrop\", event);\n }\n pressStartedOnBackdrop.current = false;\n onClick?.(event);\n event.stopPropagation();\n },\n [onClick]\n );\n\n // React events from a portal bubble through the React tree, so an Escape from the content would reach an\n // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDialogElement>) => {\n onKeyDown?.(event);\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\") ||\n stackIdRef.current === undefined ||\n !isTopModalRoot(stackIdRef.current)\n ) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that\n // opened this dialog, but it leaves the dialog open.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n },\n [onKeyDown]\n );\n\n const handleExited = useCallback(() => {\n if (!open) {\n finishClose();\n }\n }, [open, finishClose]);\n\n if (!mounted) {\n return null;\n }\n\n let content: ReactNode = null;\n\n if (contentShown) {\n content =\n typeof children === \"function\"\n ? children({ in: open, onExited: handleExited })\n : children;\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 {content}\n </PortalContainerProvider>\n <div ref={overlayRootRef} className=\"c-modal-root__overlays\" />\n </StyledModalRoot>\n </RemoveScroll>\n </Portal>\n );\n }\n);\n\nModalRoot.displayName = \"ModalRoot\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AAOA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAL,sBAAA,CAAAH,OAAA;AAAgD,IAAAS,SAAA;AAAA,SAAAN,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAf,uBAAA,YAAAA,wBAAAW,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,G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ACR,CAAC;AAEb,CACF,CAAC;AAEDpB,SAAS,CAACyH,WAAW,GAAG,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"ModalRoot.js","names":["_react","_interopRequireWildcard","require","_reactRemoveScroll","_classnames","_interopRequireDefault","_modalRootStack","_Styles","_useModalStackHost","_helpers","_layers","_useForkRef","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","l","Symbol","iterator","u","next","done","push","value","return","isArray","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","FOCUSABLE","focusFirstFocusable","dialog","overlayRoot","querySelectorAll","some","candidate","contains","focus","document","activeElement","FOCUS_HISTORY_SIZE","isFocusable","element","isConnected","matches","checkVisibility","isFocusLost","body","closest","layer","HTMLDialogElement","open","focusTopWindowIfLost","topLayer","getTopLayer","getTopModalRootId","undefined","preventScroll","keepFocusOn","HTMLElement","keepInTopLayer","node","showPopover","setAttribute","blur","leaveTopLayer","hasAttribute","hidePopover","removeAttribute","isHeldStackHost","_element$closest","concat","MODAL_STACK_HOST_ATTRIBUTE","parentElement","setContentInert","content","inert","_overlayRoot$children","toggleAttribute","children","forEach","child","ModalRoot","exports","forwardRef","_ref","ref","onRequestClose","onDismissBlocked","onClose","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableBackgroun","disableBackgroundClick","_ref$disableScrollLoc","disableScrollLock","_ref$disableReturnFoc","disableReturnFocus","_ref$belowOpenSheets","belowOpenSheets","className","onPointerDown","onClick","onKeyDown","rest","_useState","useState","_useState2","mounted","setMounted","_useState3","_useState4","setDialog","dialogRef","useRef","setDialogNode","useCallback","current","handleRef","useForkRef","_useState5","_useState6","shownDialog","setShownDialog","contentShown","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","exitingRef","contentRef","overlayRootRef","getOverlayRoot","disableReturnFocusRef","closeDialog","focusHeld","focusInside","close","_document$activeEleme","requestAnimationFrame","focusHistoryRef","blurredRef","restoreLostFocus","stackId","blurred","isTopModalRoot","areModalRootsSuspended","restored","focusBeforeSuspendRef","suspensionRef","suspend","style","zIndex","String","layers","cloud","show","resume","showModal","leaveStack","popModalRoot","releaseForExit","releaseModalRoot","finishClose","useLayoutEffect","reopenedDuringExit","reopenModalRoot","pushModalRoot","dismissRef","reason","event","blocked","useEffect","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","defaultPrevented","key","target","querySelector","preventDefault","_dismissRef$current","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","_dismissRef$current2","handleNativeClose","frame","scheduleRestore","handleFocusIn","filter","handleFocusOut","relatedTarget","observer","MutationObserver","observe","childList","subtree","unsubscribe","subscribeToModalRoots","disconnect","cancelAnimationFrame","handlePointerDown","currentTarget","handleClick","_dismissRef$current3","stopPropagation","_overlayRootRef$curre4","_dismissRef$current4","handleExited","in","onExited","createElement","Portal","RemoveScroll","forwardProps","enabled","noIsolation","StyledModalRoot","tabIndex","classnames","PortalContainerProvider","displayName"],"sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport {\n areModalRootsSuspended,\n getTopModalRootId,\n isTopModalRoot,\n ModalRootSuspension,\n popModalRoot,\n pushModalRoot,\n releaseModalRoot,\n reopenModalRoot,\n subscribeToModalRoots,\n} from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { MODAL_STACK_HOST_ATTRIBUTE } from \"./useModalStackHost\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport { getTopLayer, layers } from \"../../utils/layers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nconst FOCUSABLE =\n \"button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, iframe, audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), [tabindex]\";\n\n// What showModal does for content that was not there yet: the first node that takes the focus gets it, so a\n// disabled or hidden one is skipped as the browser skips it.\nconst focusFirstFocusable = (\n dialog: HTMLDialogElement,\n overlayRoot: HTMLElement | null\n) => {\n Array.from(dialog.querySelectorAll<HTMLElement>(FOCUSABLE)).some(\n (candidate) => {\n if (overlayRoot?.contains(candidate)) {\n return false;\n }\n\n candidate.focus();\n\n return document.activeElement === candidate;\n }\n );\n};\n\nconst FOCUS_HISTORY_SIZE = 5;\n\n// Neither removed, disabled nor hidden, so the element could take the focus back.\nconst isFocusable = (element: HTMLElement) =>\n element.isConnected &&\n element.matches(FOCUSABLE) &&\n // eslint-disable-next-line compat/compat\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility());\n\n// A focused element that a closed dialog hides, or that turned inert, keeps the focus until the browser renders again.\nconst isFocusLost = () => {\n const focus = document.activeElement;\n\n if (\n !focus ||\n focus === document.body ||\n !focus.isConnected ||\n focus.closest(\"[inert]\")\n ) {\n return true;\n }\n\n const layer = focus.closest(\"dialog, .c-window\");\n\n return layer instanceof HTMLDialogElement && !layer.open;\n};\n\n// A sheet is a window, not a dialog, so once the last dialog is closed nothing else takes a lost focus back.\nconst focusTopWindowIfLost = () => {\n const topLayer = getTopLayer();\n\n if (\n getTopModalRootId() === undefined &&\n isFocusLost() &&\n topLayer?.matches(\".c-window\")\n ) {\n topLayer.focus({ preventScroll: true });\n }\n};\n\nconst keepFocusOn = (element: Element | null) => {\n if (\n element instanceof HTMLElement &&\n element !== document.body &&\n element.isConnected &&\n document.activeElement !== element\n ) {\n element.focus({ preventScroll: true });\n }\n};\n\n// A closed dialog shown as a manual popover stays in the top layer without blocking the page. showPopover focuses a\n// dialog, so the focus goes back to where close() left it.\nconst keepInTopLayer = (node: HTMLDialogElement) => {\n if (typeof node.showPopover !== \"function\") {\n return;\n }\n\n const focus = document.activeElement;\n node.setAttribute(\"popover\", \"manual\");\n // eslint-disable-next-line compat/compat\n node.showPopover();\n\n keepFocusOn(focus);\n\n if (\n document.activeElement !== focus &&\n node.contains(document.activeElement)\n ) {\n (document.activeElement as HTMLElement).blur();\n }\n};\n\nconst leaveTopLayer = (node: HTMLDialogElement) => {\n if (!node.hasAttribute(\"popover\")) {\n return;\n }\n\n if (node.matches(\":popover-open\")) {\n // eslint-disable-next-line compat/compat\n node.hidePopover();\n }\n node.removeAttribute(\"popover\");\n};\n\nconst isHeldStackHost = (\n element: Element | null,\n overlayRoot: Element | null\n) =>\n !!overlayRoot &&\n element?.closest(`[${MODAL_STACK_HOST_ATTRIBUTE}]`)?.parentElement ===\n overlayRoot;\n\n// Popups of the content sit in the overlay root next to the stack hosts and leave with the content.\nconst setContentInert = (\n content: Element | null,\n overlayRoot: Element | null,\n inert: boolean\n) => {\n content?.toggleAttribute(\"inert\", inert);\n Array.from(overlayRoot?.children ?? []).forEach((child) => {\n if (!child.hasAttribute(MODAL_STACK_HOST_ATTRIBUTE)) {\n child.toggleAttribute(\"inert\", inert);\n }\n });\n};\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 /**\n * Closing leaves the focus off the element that had it before the dialog opened, also when the owner unmounts it.\n * An open dialog under it takes the focus itself.\n */\n disableReturnFocus?: boolean;\n /**\n * The dialog counts as opened before the sheets that are open, so they move into its overlay root and stay above\n * it. For a page dialog that a sheet covers, such as an archive that opens a task, also when the dialog mounts after\n * the sheet on a reload. A sheet that sits in the page mounts its content again in the overlay root; one that sits\n * in another modal moves without remounting, also above a modal opened in between from outside the sheet. Read when\n * the dialog opens; a later change does not move the stack entry.\n */\n belowOpenSheets?: boolean;\n /**\n * A function gets the transition state. The dialog closes, gives the focus back and turns inert as the exit\n * starts, stays shown for the transition, and unmounts when it calls onExited. A node closes at once.\n * The content mounts once the dialog is open, a render after the dialog node, so an autoFocus field takes the focus;\n * an owner effect in the opening commit sees no content. It mounts again on every open, also when the owner reopens\n * the dialog from onClose, and loses its local state.\n */\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 disableReturnFocus = false,\n belowOpenSheets = 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 // A closed dialog hides its content, and React focuses an autoFocus field while it mounts, so the content mounts\n // only once showModal ran on this node.\n const [shownDialog, setShownDialog] = useState<HTMLDialogElement | null>(\n null\n );\n const contentShown = dialog !== null && shownDialog === dialog;\n const hasTransition = typeof children === \"function\";\n const openRef = useRef(open);\n const pressStartedOnBackdrop = useRef(false);\n const stackIdRef = useRef<number>();\n const exitingRef = useRef(false);\n const contentRef = useRef<HTMLDivElement>(null);\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 const disableReturnFocusRef = useRef(disableReturnFocus);\n disableReturnFocusRef.current = disableReturnFocus;\n\n // close() of a modal gives the focus back to the element that had it before showModal, so a dialog that leaves it\n // there takes it off again. A focus outside, as in a sheet that left the overlay root, stays where it is, and so\n // does a focus in a sheet the overlay root holds for the exit transition. When that element is gone, also when it\n // goes with the same update right after, and the last dialog closes over a sheet, the sheet takes it.\n const closeDialog = useCallback((node: HTMLDialogElement) => {\n const focus = document.activeElement;\n const focusHeld = isHeldStackHost(focus, overlayRootRef.current);\n const focusInside = node.contains(focus) && !focusHeld;\n node.close();\n\n if (!focusInside) {\n keepFocusOn(focus);\n\n return;\n }\n\n if (disableReturnFocusRef.current) {\n (document.activeElement as HTMLElement | null)?.blur();\n\n return;\n }\n\n focusTopWindowIfLost();\n requestAnimationFrame(focusTopWindowIfLost);\n }, []);\n\n const focusHistoryRef = useRef<HTMLElement[]>([]);\n const blurredRef = useRef<HTMLElement | null>(null);\n\n // The browser drops the focus to the body when the focused element goes, as a toast that closes or a button that\n // another replaces, so the top dialog takes it back: on the newest element focused before that is still there, or\n // on itself. A layer in front of it, such as a sheet in the overlay root, keeps its own focus. A field that blurs\n // itself, as on Escape or Enter, can still take the focus, so it let it go on purpose and the dialog takes it.\n const restoreLostFocus = useCallback(() => {\n const node = dialogRef.current;\n const stackId = stackIdRef.current;\n const blurred = blurredRef.current;\n blurredRef.current = null;\n\n if (\n !node?.open ||\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n areModalRootsSuspended() ||\n !isFocusLost() ||\n getTopLayer() !== node\n ) {\n return;\n }\n\n if (blurred && node.contains(blurred) && isFocusable(blurred)) {\n node.focus({ preventScroll: true });\n\n return;\n }\n\n const restored = focusHistoryRef.current.some((candidate) => {\n if (!candidate.isConnected || !node.contains(candidate)) {\n return false;\n }\n\n candidate.focus({ preventScroll: true });\n\n return document.activeElement === candidate;\n });\n\n if (!restored) {\n node.focus({ preventScroll: true });\n }\n }, []);\n\n if (open && !mounted) {\n setMounted(true);\n }\n\n // While suspended the dialog is open without being modal, in the page instead of the top layer, so it keeps a\n // layer just under the overlay it was suspended for. A dismiss then would close it under that overlay.\n // The stack calls suspend once for an entry and resume at most once, so the suspension is the stack's state.\n const focusBeforeSuspendRef = useRef<Element | null>(null);\n const suspensionRef = useRef<ModalRootSuspension>({\n suspend: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n focusBeforeSuspendRef.current = node.contains(document.activeElement)\n ? document.activeElement\n : null;\n node.style.zIndex = String(layers.cloud - 1);\n\n if (node.open) {\n node.close();\n node.show();\n }\n },\n resume: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n node.style.zIndex = \"\";\n\n if (node.open) {\n node.close();\n node.showModal();\n }\n\n const focus = focusBeforeSuspendRef.current;\n focusBeforeSuspendRef.current = null;\n\n if (focus instanceof HTMLElement && node.contains(focus)) {\n focus.focus({ preventScroll: true });\n }\n\n restoreLostFocus();\n },\n });\n\n const leaveStack = useCallback(() => {\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n }, []);\n\n // The closed dialog stays shown for its exit transition, and its content takes no input until it unmounts.\n // Sheets in its overlay root stay there until the transition is done.\n const releaseForExit = useCallback(() => {\n const node = dialogRef.current;\n\n if (!node || exitingRef.current) {\n return;\n }\n\n exitingRef.current = true;\n // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.\n node.style.zIndex = \"\";\n\n if (stackIdRef.current !== undefined) {\n releaseModalRoot(stackIdRef.current);\n }\n\n // Inert before close(), so a focus lock in a popup cannot take back the focus close() gives the opener.\n setContentInert(contentRef.current, overlayRootRef.current, true);\n\n if (node.open) {\n closeDialog(node);\n }\n\n keepInTopLayer(node);\n }, [closeDialog]);\n\n const finishClose = useCallback(() => {\n const node = dialogRef.current;\n\n exitingRef.current = false;\n\n if (node) {\n node.style.zIndex = \"\";\n }\n\n // Content that sits in the overlay root moves out before the dialog hides it.\n leaveStack();\n\n if (node?.open) {\n closeDialog(node);\n }\n\n if (node) {\n leaveTopLayer(node);\n }\n setMounted(false);\n setShownDialog(null);\n onClose?.();\n }, [closeDialog, leaveStack, onClose]);\n\n // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the\n // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it\n // is rendered and can get its scroll positions back.\n useLayoutEffect(() => {\n if (!open || !dialog) {\n return;\n }\n\n const reopenedDuringExit = exitingRef.current;\n\n if (reopenedDuringExit) {\n exitingRef.current = false;\n leaveTopLayer(dialog);\n setContentInert(contentRef.current, overlayRootRef.current, false);\n }\n\n if (!dialog.open) {\n dialog.showModal();\n }\n\n if (\n reopenedDuringExit &&\n stackIdRef.current !== undefined &&\n !reopenModalRoot(stackIdRef.current)\n ) {\n leaveStack();\n }\n\n if (\n reopenedDuringExit &&\n !areModalRootsSuspended() &&\n !dialog.contains(document.activeElement)\n ) {\n focusFirstFocusable(dialog, overlayRootRef.current);\n }\n\n if (stackIdRef.current === undefined) {\n stackIdRef.current = pushModalRoot(\n overlayRootRef.current,\n suspensionRef.current,\n belowOpenSheets\n );\n }\n\n setShownDialog(dialog);\n }, [open, dialog, belowOpenSheets, leaveStack]);\n\n // showModal found no content to focus, so the dialog moves the focus in once the content is there, unless an\n // autoFocus field took it. A dialog that opened suspended stays out of the way of the overlay above it.\n useLayoutEffect(() => {\n if (!contentShown || !dialog || areModalRootsSuspended()) {\n return;\n }\n\n const focus = document.activeElement;\n\n if (focus !== dialog && dialog.contains(focus)) {\n return;\n }\n\n focusFirstFocusable(dialog, overlayRootRef.current);\n }, [contentShown, dialog]);\n\n // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.\n // An owner that unmounts the dialog while it is open, as a form does on submit, gets the focus back on the\n // opener: a dialog removed while open would leave it on the body.\n useLayoutEffect(\n () => () => {\n exitingRef.current = false;\n leaveStack();\n\n if (dialog?.open) {\n closeDialog(dialog);\n }\n },\n [dialog, closeDialog, leaveStack]\n );\n\n useLayoutEffect(() => {\n if (open || !mounted) {\n return;\n }\n\n if (hasTransition) {\n releaseForExit();\n } else {\n finishClose();\n }\n }, [open, mounted, hasTransition, releaseForExit, finishClose]);\n\n const dismissRef =\n useRef<\n (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void\n >();\n\n dismissRef.current = (reason, event) => {\n if (areModalRootsSuspended()) {\n return;\n }\n\n const blocked =\n reason === \"escape\" ? disableCloseOnEsc : disableBackgroundClick;\n\n if (blocked) {\n onDismissBlocked?.(reason, event);\n } else {\n onRequestClose?.(reason);\n }\n };\n\n // A prevented Escape keydown starts no close request, and the browser stops honouring a prevented cancel\n // after a while, so Escape is caught here and the cancel event only covers the other close requests.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const stackId = stackIdRef.current;\n\n if (\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\")\n ) {\n return;\n }\n\n // A menu inside closes on an Escape that reaches the body, from a listener that runs after this one.\n if (\n event.target === document.body &&\n overlayRootRef.current?.querySelector(\".c-window\")\n ) {\n return;\n }\n\n event.preventDefault();\n\n // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take\n // still belongs to it, so the dialog only stops the browser from closing itself.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [dialog]);\n\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n\n // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows\n // would close the dialog under the layer. While the focus is in that layer, the close request is its own.\n if (overlayRootRef.current?.contains(document.activeElement)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n const handleNativeClose = () => {\n if (\n openRef.current &&\n dialog.isConnected &&\n !dialog.open &&\n !areModalRootsSuspended()\n ) {\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 // The check waits a frame, so a close() that gives the focus back to an opener runs first. A modal root above\n // leaves the stack before its close(), and may sit outside this dialog, so the stack starts the check too.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n let frame: number | undefined;\n\n const scheduleRestore = () => {\n if (frame === undefined) {\n frame = requestAnimationFrame(() => {\n frame = undefined;\n restoreLostFocus();\n });\n }\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const target = event.target;\n\n if (target instanceof HTMLElement && target !== dialog) {\n focusHistoryRef.current = [\n target,\n ...focusHistoryRef.current.filter((element) => element !== target),\n ].slice(0, FOCUS_HISTORY_SIZE);\n }\n };\n\n const handleFocusOut = (event: FocusEvent) => {\n if (!event.relatedTarget) {\n blurredRef.current =\n event.target instanceof HTMLElement ? event.target : null;\n scheduleRestore();\n }\n };\n\n const observer = new MutationObserver(scheduleRestore);\n\n observer.observe(dialog, { childList: true, subtree: true });\n dialog.addEventListener(\"focusin\", handleFocusIn);\n dialog.addEventListener(\"focusout\", handleFocusOut);\n const unsubscribe = subscribeToModalRoots(scheduleRestore);\n\n return () => {\n unsubscribe();\n observer.disconnect();\n dialog.removeEventListener(\"focusin\", handleFocusIn);\n dialog.removeEventListener(\"focusout\", handleFocusOut);\n\n if (frame !== undefined) {\n cancelAnimationFrame(frame);\n }\n };\n }, [dialog, restoreLostFocus]);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLDialogElement>) => {\n pressStartedOnBackdrop.current = event.target === event.currentTarget;\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n // The dialog covers the viewport and its content sits inside it, so a click on the dialog itself is a\n // click on the backdrop. A press that started on the content and ended outside it is a text selection.\n // A click does not bubble on through the React tree, as from a legacy window: a confirmation rendered in a\n // clickable row would otherwise click the row as well. React listens at the portal's container, so a click\n // listener on document or window does not see a click inside the dialog either, as with the window.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n if (\n event.target === event.currentTarget &&\n pressStartedOnBackdrop.current &&\n openRef.current\n ) {\n dismissRef.current?.(\"backdrop\", event);\n }\n pressStartedOnBackdrop.current = false;\n onClick?.(event);\n event.stopPropagation();\n },\n [onClick]\n );\n\n // React events from a portal bubble through the React tree, so an Escape from the content would reach an\n // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDialogElement>) => {\n onKeyDown?.(event);\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\") ||\n stackIdRef.current === undefined ||\n !isTopModalRoot(stackIdRef.current)\n ) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that\n // opened this dialog, but it leaves the dialog open.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n },\n [onKeyDown]\n );\n\n const handleExited = useCallback(() => {\n if (!open) {\n finishClose();\n }\n }, [open, finishClose]);\n\n if (!mounted) {\n return null;\n }\n\n let content: ReactNode = null;\n\n if (contentShown) {\n content =\n typeof children === \"function\"\n ? children({ in: open, onExited: handleExited })\n : children;\n }\n\n return (\n <Portal>\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation\n >\n <StyledModalRoot\n tabIndex={-1}\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 <div ref={contentRef} className=\"c-modal-root__content\">\n <PortalContainerProvider value={getOverlayRoot}>\n {content}\n </PortalContainerProvider>\n </div>\n <div ref={overlayRootRef} className=\"c-modal-root__overlays\" />\n </StyledModalRoot>\n </RemoveScroll>\n </Portal>\n );\n }\n);\n\nModalRoot.displayName = \"ModalRoot\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAaA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AAWA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAN,sBAAA,CAAAH,OAAA;AAAgD,IAAAU,SAAA;AAAA,SAAAP,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAhB,uBAAA,YAAAA,wBAAAY,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,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IAAa,CAAC,CAAC,GAC9CnI,QAAQ;EAChB;EAEA,oBACEvH,MAAA,CAAAe,OAAA,CAAA8O,aAAA,CAACpP,QAAA,CAAAqP,MAAM,qBACL9P,MAAA,CAAAe,OAAA,CAAA8O,aAAA,CAAC1P,kBAAA,CAAA4P,YAAY;IACXC,YAAY;IACZlI,GAAG,EAAEgC,SAAU;IACfmG,OAAO,EAAE,CAAC1H,iBAAkB;IAC5B2H,WAAW;EAAA,gBAEXlQ,MAAA,CAAAe,OAAA,CAAA8O,aAAA,CAACtP,OAAA,CAAA4P,eAAe,EAAAlO,QAAA;IACdmO,QAAQ,EAAE,CAAC;EAAE,GACTpH,IAAI;IACRJ,SAAS,EAAE,IAAAyH,mBAAU,EAAC,cAAc,EAAEzH,SAAS,CAAE;IACjD,cAAYjD,IAAI,GAAG,MAAM,GAAG,SAAU;IACtCkD,aAAa,EAAEsG,iBAAkB;IACjCrG,OAAO,EAAEuG,WAAY;IACrBtG,SAAS,EAAEsE;EAAc,iBAEzBrN,MAAA,CAAAe,OAAA,CAAA8O,aAAA;IAAK/H,GAAG,EAAE4C,UAAW;IAAC9B,SAAS,EAAC;EAAuB,gBACrD5I,MAAA,CAAAe,OAAA,CAAA8O,aAAA,CAACpP,QAAA,CAAA6P,uBAAuB;IAACzM,KAAK,EAAE+G;EAAe,GAC5CzD,OACsB,CACtB,CAAC,eACNnH,MAAA,CAAAe,OAAA,CAAA8O,aAAA;IAAK/H,GAAG,EAAE6C,cAAe;IAAC/B,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDlB,SAAS,CAAC6I,WAAW,GAAG,WAAW","ignoreList":[]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.StyledModalRoot = exports.MODAL_ROOT_BACKDROP_MS = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
+ var _layers = require("../../utils/layers");
8
9
  var _BoxSizingStyle = require("../BoxSizingStyle");
9
10
  var _FontStyle = require("../FontStyle");
10
11
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -13,6 +14,6 @@ var backdropIn = (0, _styledComponents.keyframes)(["from{background-color:transp
13
14
  var StyledModalRoot = exports.StyledModalRoot = _styledComponents.default.dialog.withConfig({
14
15
  displayName: "Styles__StyledModalRoot",
15
16
  componentId: "sc-48b5xq-0"
16
- })(["", " ", " position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:var(--modal-background);color:inherit;overflow:visible;animation:", " ", "ms ease;transition:background-color ", "ms ease;&[data-state=\"closing\"]{background-color:transparent;}&:focus-visible{outline:none;}&::backdrop{background:transparent;}"], _FontStyle.FontStyle, _BoxSizingStyle.BoxSizingStyle, backdropIn, MODAL_ROOT_BACKDROP_MS, MODAL_ROOT_BACKDROP_MS);
17
+ })(["", " ", " position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:var(--modal-background);color:inherit;overflow:visible;animation:", " ", "ms ease;transition:background-color ", "ms ease;&[data-state=\"closing\"]{background-color:transparent;}&[data-state=\"closing\"]:not([open]){display:block;z-index:", ";pointer-events:none;}&[data-state=\"closing\"]:not([open]) > .c-modal-root__overlays{pointer-events:auto;}&[data-state=\"closing\"]::backdrop{pointer-events:none;}> .c-modal-root__content{display:contents;}&:focus{outline:none;}&::backdrop{background:transparent;}"], _FontStyle.FontStyle, _BoxSizingStyle.BoxSizingStyle, backdropIn, MODAL_ROOT_BACKDROP_MS, MODAL_ROOT_BACKDROP_MS, _layers.layers.cloud - 1);
17
18
  StyledModalRoot.displayName = "StyledModalRoot";
18
19
  //# sourceMappingURL=Styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_BoxSizingStyle","_FontStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MODAL_ROOT_BACKDROP_MS","exports","backdropIn","keyframes","StyledModalRoot","styled","dialog","withConfig","displayName","componentId","FontStyle","BoxSizingStyle"],"sources":["../../../../src/components/ModalRoot/Styles.ts"],"sourcesContent":["import styled, { keyframes } from \"styled-components\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const MODAL_ROOT_BACKDROP_MS = 200;\n\nconst backdropIn = keyframes`\n from {\n background-color: transparent;\n }\n`;\n\nexport const StyledModalRoot = styled.dialog`\n ${FontStyle}\n ${BoxSizingStyle}\n\n position: fixed;\n inset: 0;\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n margin: 0;\n padding: 0;\n border: 0;\n // The dialog covers the viewport, so it carries the backdrop colour itself. ::backdrop only inherits the\n // custom properties from Chrome 122 and Safari 17.4 on, and would be transparent before that.\n background: var(--modal-background);\n color: inherit;\n overflow: visible;\n animation: ${backdropIn} ${MODAL_ROOT_BACKDROP_MS}ms ease;\n transition: background-color ${MODAL_ROOT_BACKDROP_MS}ms ease;\n\n &[data-state=\"closing\"] {\n background-color: transparent;\n }\n\n &:focus-visible {\n outline: none;\n }\n\n &::backdrop {\n background: transparent;\n }\n`;\n\nStyledModalRoot.displayName = \"StyledModalRoot\";\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,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S,EACTC,8BAAc,EAgBHT,UAAU,EAAIF,sBAAsB,EAClBA,sBAAsB,CAatD;AAEDI,eAAe,CAACI,WAAW,GAAG,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_layers","_BoxSizingStyle","_FontStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MODAL_ROOT_BACKDROP_MS","exports","backdropIn","keyframes","StyledModalRoot","styled","dialog","withConfig","displayName","componentId","FontStyle","BoxSizingStyle","layers","cloud"],"sources":["../../../../src/components/ModalRoot/Styles.ts"],"sourcesContent":["import styled, { keyframes } from \"styled-components\";\n\nimport { layers } from \"../../utils/layers\";\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const MODAL_ROOT_BACKDROP_MS = 200;\n\nconst backdropIn = keyframes`\n from {\n background-color: transparent;\n }\n`;\n\nexport const StyledModalRoot = styled.dialog`\n ${FontStyle}\n ${BoxSizingStyle}\n\n position: fixed;\n inset: 0;\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n margin: 0;\n padding: 0;\n border: 0;\n // The dialog covers the viewport, so it carries the backdrop colour itself. ::backdrop only inherits the\n // custom properties from Chrome 122 and Safari 17.4 on, and would be transparent before that.\n background: var(--modal-background);\n color: inherit;\n overflow: visible;\n animation: ${backdropIn} ${MODAL_ROOT_BACKDROP_MS}ms ease;\n transition: background-color ${MODAL_ROOT_BACKDROP_MS}ms ease;\n\n &[data-state=\"closing\"] {\n background-color: transparent;\n }\n\n // Closed as its exit starts, the dialog stays shown until it unmounts, and clicks pass through it to the page. Where\n // popovers are missing it leaves the top layer and stays above the page only.\n &[data-state=\"closing\"]:not([open]) {\n display: block;\n z-index: ${layers.cloud - 1};\n pointer-events: none;\n }\n\n &[data-state=\"closing\"]:not([open]) > .c-modal-root__overlays {\n pointer-events: auto;\n }\n\n &[data-state=\"closing\"]::backdrop {\n pointer-events: none;\n }\n\n > .c-modal-root__content {\n display: contents;\n }\n\n &:focus {\n outline: none;\n }\n\n &::backdrop {\n background: transparent;\n }\n`;\n\nStyledModalRoot.displayName = \"StyledModalRoot\";\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAyC,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,C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