@activecollab/components 2.0.541 → 2.0.543

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 (102) hide show
  1. package/dist/cjs/components/BlockingProgress/BlockingProgress.js +61 -0
  2. package/dist/cjs/components/BlockingProgress/BlockingProgress.js.map +1 -0
  3. package/dist/cjs/components/BlockingProgress/Styles.js +34 -0
  4. package/dist/cjs/components/BlockingProgress/Styles.js.map +1 -0
  5. package/dist/cjs/components/BlockingProgress/index.js +17 -0
  6. package/dist/cjs/components/BlockingProgress/index.js.map +1 -0
  7. package/dist/cjs/components/CommandPalette/CommandPalette.js +3 -1
  8. package/dist/cjs/components/CommandPalette/CommandPalette.js.map +1 -1
  9. package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js +4 -4
  10. package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
  11. package/dist/cjs/components/Dialog/Dialog.js +3 -3
  12. package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
  13. package/dist/cjs/components/Dialog/DialogContext.js.map +1 -1
  14. package/dist/cjs/components/Dialog/DialogFrame.js +21 -100
  15. package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -1
  16. package/dist/cjs/components/Dialog/useRemovedPropWarning.js +22 -0
  17. package/dist/cjs/components/Dialog/useRemovedPropWarning.js.map +1 -0
  18. package/dist/cjs/components/ModalRoot/ModalRoot.js +32 -8
  19. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  20. package/dist/cjs/components/ModalRoot/modalRootStack.js +18 -4
  21. package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
  22. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +5 -7
  23. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  24. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +7 -0
  25. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -1
  26. package/dist/cjs/components/Wizard/Wizard.js +1 -0
  27. package/dist/cjs/components/Wizard/Wizard.js.map +1 -1
  28. package/dist/cjs/components/index.js +12 -0
  29. package/dist/cjs/components/index.js.map +1 -1
  30. package/dist/cjs/presentation/listView/columns.js +622 -184
  31. package/dist/cjs/presentation/listView/columns.js.map +1 -1
  32. package/dist/esm/components/BlockingProgress/BlockingProgress.d.ts +16 -0
  33. package/dist/esm/components/BlockingProgress/BlockingProgress.d.ts.map +1 -0
  34. package/dist/esm/components/BlockingProgress/BlockingProgress.js +52 -0
  35. package/dist/esm/components/BlockingProgress/BlockingProgress.js.map +1 -0
  36. package/dist/esm/components/BlockingProgress/Styles.d.ts +6 -0
  37. package/dist/esm/components/BlockingProgress/Styles.d.ts.map +1 -0
  38. package/dist/esm/components/BlockingProgress/Styles.js +27 -0
  39. package/dist/esm/components/BlockingProgress/Styles.js.map +1 -0
  40. package/dist/esm/components/BlockingProgress/index.d.ts +2 -0
  41. package/dist/esm/components/BlockingProgress/index.d.ts.map +1 -0
  42. package/dist/esm/components/BlockingProgress/index.js +2 -0
  43. package/dist/esm/components/BlockingProgress/index.js.map +1 -0
  44. package/dist/esm/components/CommandPalette/CommandPalette.d.ts +2 -2
  45. package/dist/esm/components/CommandPalette/CommandPalette.d.ts.map +1 -1
  46. package/dist/esm/components/CommandPalette/CommandPalette.js +3 -1
  47. package/dist/esm/components/CommandPalette/CommandPalette.js.map +1 -1
  48. package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +5 -2
  49. package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
  50. package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +4 -4
  51. package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
  52. package/dist/esm/components/DatePicker/Styles.d.ts +1 -1
  53. package/dist/esm/components/DatePicker/Styles.d.ts.map +1 -1
  54. package/dist/esm/components/Dialog/Dialog.d.ts +15 -3
  55. package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
  56. package/dist/esm/components/Dialog/Dialog.js +3 -3
  57. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  58. package/dist/esm/components/Dialog/DialogContext.d.ts +2 -2
  59. package/dist/esm/components/Dialog/DialogContext.d.ts.map +1 -1
  60. package/dist/esm/components/Dialog/DialogContext.js.map +1 -1
  61. package/dist/esm/components/Dialog/DialogFrame.d.ts +5 -6
  62. package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -1
  63. package/dist/esm/components/Dialog/DialogFrame.js +23 -100
  64. package/dist/esm/components/Dialog/DialogFrame.js.map +1 -1
  65. package/dist/esm/components/Dialog/useRemovedPropWarning.d.ts +3 -0
  66. package/dist/esm/components/Dialog/useRemovedPropWarning.d.ts.map +1 -0
  67. package/dist/esm/components/Dialog/useRemovedPropWarning.js +16 -0
  68. package/dist/esm/components/Dialog/useRemovedPropWarning.js.map +1 -0
  69. package/dist/esm/components/ModalRoot/ModalRoot.d.ts +10 -0
  70. package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
  71. package/dist/esm/components/ModalRoot/ModalRoot.js +32 -8
  72. package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
  73. package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -2
  74. package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
  75. package/dist/esm/components/ModalRoot/modalRootStack.js +18 -4
  76. package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
  77. package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts +4 -0
  78. package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
  79. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +5 -7
  80. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  81. package/dist/esm/components/SelectDate/Styles.d.ts +1 -1
  82. package/dist/esm/components/SelectDate/Styles.d.ts.map +1 -1
  83. package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -1
  84. package/dist/esm/components/Sheet/useHostAboveOpenModal.js +9 -2
  85. package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -1
  86. package/dist/esm/components/Wizard/Wizard.d.ts +1 -1
  87. package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
  88. package/dist/esm/components/Wizard/Wizard.js +1 -0
  89. package/dist/esm/components/Wizard/Wizard.js.map +1 -1
  90. package/dist/esm/components/index.d.ts +1 -0
  91. package/dist/esm/components/index.d.ts.map +1 -1
  92. package/dist/esm/components/index.js +1 -0
  93. package/dist/esm/components/index.js.map +1 -1
  94. package/dist/esm/presentation/listView/columns.d.ts +20 -7
  95. package/dist/esm/presentation/listView/columns.d.ts.map +1 -1
  96. package/dist/esm/presentation/listView/columns.js +538 -166
  97. package/dist/esm/presentation/listView/columns.js.map +1 -1
  98. package/dist/index.js +1039 -990
  99. package/dist/index.js.map +1 -1
  100. package/dist/index.min.js +1 -1
  101. package/dist/index.min.js.map +1 -1
  102. package/package.json +1 -1
@@ -1,56 +1,30 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["forwardedRef", "surface", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside"],
4
- _excluded2 = ["forwardedRef", "surface", "native", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "disableFocusLock"];
3
+ const _excluded = ["forwardedRef", "surface", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "disableReturnFocus"];
5
4
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
5
  import { DialogContext } from "./DialogContext";
7
6
  import { StyledDialogViewport } from "./Styles";
8
7
  import useStableId from "../../utils/useStableId";
9
- import { ModalBase } from "../Modal/ModalBase";
10
8
  import { ModalRoot } from "../ModalRoot";
11
- import { Fade, FADE_DURATION } from "../Transitions";
12
- import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
13
- // ModalBase only treats a child as a transition when its props already carry `in`, so this element
14
- // must declare it even though ModalBase overwrites it on clone.
15
- const DialogSurface = _ref => {
16
- let _ref$in = _ref.in,
17
- inProp = _ref$in === void 0 ? false : _ref$in,
18
- onEnter = _ref.onEnter,
19
- onExited = _ref.onExited,
20
- forceClose = _ref.forceClose,
9
+ import { Fade } from "../Transitions";
10
+ import { SlideFromTop } from "../Transitions/SlideFromTop";
11
+ // What Dialog and ObjectFormModal share: the native modal, the viewport and the animation around a surface each draws.
12
+ export const DialogFrame = _ref => {
13
+ let forwardedRef = _ref.forwardedRef,
14
+ surface = _ref.surface,
15
+ _ref$open = _ref.open,
16
+ open = _ref$open === void 0 ? false : _ref$open,
21
17
  onClose = _ref.onClose,
22
- animate = _ref.animate,
23
- children = _ref.children;
24
- const Animation = animate === "fade" ? Fade : SlideFromTop;
25
- const value = useMemo(() => ({
26
- requestClose: forceClose,
27
- onClose
28
- }), [forceClose, onClose]);
29
- return /*#__PURE__*/React.createElement(DialogContext.Provider, {
30
- value: value
31
- }, /*#__PURE__*/React.createElement(StyledDialogViewport, {
32
- className: "c-dialog-viewport"
33
- }, /*#__PURE__*/React.createElement(Animation, {
34
- in: inProp,
35
- onEnter: onEnter,
36
- onExited: onExited
37
- }, children)));
38
- };
39
- DialogSurface.displayName = "DialogSurface";
40
- const NativeDialog = _ref2 => {
41
- let forwardedRef = _ref2.forwardedRef,
42
- surface = _ref2.surface,
43
- _ref2$open = _ref2.open,
44
- open = _ref2$open === void 0 ? false : _ref2$open,
45
- onClose = _ref2.onClose,
46
- _ref2$enableBackgroun = _ref2.enableBackgroundClick,
47
- enableBackgroundClick = _ref2$enableBackgroun === void 0 ? false : _ref2$enableBackgroun,
48
- _ref2$disableCloseOnE = _ref2.disableCloseOnEsc,
49
- disableCloseOnEsc = _ref2$disableCloseOnE === void 0 ? false : _ref2$disableCloseOnE,
50
- _ref2$animate = _ref2.animate,
51
- animate = _ref2$animate === void 0 ? "slide" : _ref2$animate,
52
- onClickOutside = _ref2.onClickOutside,
53
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
18
+ _ref$enableBackground = _ref.enableBackgroundClick,
19
+ enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
20
+ _ref$disableCloseOnEs = _ref.disableCloseOnEsc,
21
+ disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
22
+ _ref$animate = _ref.animate,
23
+ animate = _ref$animate === void 0 ? "slide" : _ref$animate,
24
+ onClickOutside = _ref.onClickOutside,
25
+ _ref$disableReturnFoc = _ref.disableReturnFocus,
26
+ disableReturnFocus = _ref$disableReturnFoc === void 0 ? false : _ref$disableReturnFoc,
27
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
54
28
  const _useState = useState(open),
55
29
  innerOpen = _useState[0],
56
30
  setInnerOpen = _useState[1];
@@ -109,11 +83,12 @@ const NativeDialog = _ref2 => {
109
83
  onDismissBlocked: handleDismissBlocked,
110
84
  onClose: onClose,
111
85
  disableCloseOnEsc: disableCloseOnEsc,
86
+ disableReturnFocus: disableReturnFocus,
112
87
  disableBackgroundClick: !enableBackgroundClick,
113
88
  "aria-labelledby": ariaLabelledBy
114
- }), _ref3 => {
115
- let isIn = _ref3.in,
116
- onExited = _ref3.onExited;
89
+ }), _ref2 => {
90
+ let isIn = _ref2.in,
91
+ onExited = _ref2.onExited;
117
92
  return /*#__PURE__*/React.createElement(DialogContext.Provider, {
118
93
  value: contextValue
119
94
  }, /*#__PURE__*/React.createElement(StyledDialogViewport, {
@@ -124,57 +99,5 @@ const NativeDialog = _ref2 => {
124
99
  }, surface)));
125
100
  });
126
101
  };
127
- NativeDialog.displayName = "NativeDialog";
128
- // What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.
129
- export const DialogFrame = _ref4 => {
130
- let forwardedRef = _ref4.forwardedRef,
131
- surface = _ref4.surface,
132
- _ref4$native = _ref4.native,
133
- native = _ref4$native === void 0 ? false : _ref4$native,
134
- _ref4$open = _ref4.open,
135
- open = _ref4$open === void 0 ? false : _ref4$open,
136
- onClose = _ref4.onClose,
137
- _ref4$enableBackgroun = _ref4.enableBackgroundClick,
138
- enableBackgroundClick = _ref4$enableBackgroun === void 0 ? false : _ref4$enableBackgroun,
139
- _ref4$disableCloseOnE = _ref4.disableCloseOnEsc,
140
- disableCloseOnEsc = _ref4$disableCloseOnE === void 0 ? false : _ref4$disableCloseOnE,
141
- _ref4$animate = _ref4.animate,
142
- animate = _ref4$animate === void 0 ? "slide" : _ref4$animate,
143
- onClickOutside = _ref4.onClickOutside,
144
- disableFocusLock = _ref4.disableFocusLock,
145
- rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
146
- if (native) {
147
- return /*#__PURE__*/React.createElement(NativeDialog, _extends({}, rest, {
148
- forwardedRef: forwardedRef,
149
- open: open,
150
- onClose: onClose,
151
- enableBackgroundClick: enableBackgroundClick,
152
- disableCloseOnEsc: disableCloseOnEsc,
153
- animate: animate,
154
- onClickOutside: onClickOutside,
155
- surface: surface
156
- }));
157
- }
158
- return /*#__PURE__*/React.createElement(ModalBase, _extends({
159
- ref: forwardedRef,
160
- open: open,
161
- onClose: onClose,
162
- disableBackgroundClick: !enableBackgroundClick,
163
- disableCloseOnEsc: disableCloseOnEsc,
164
- disableFocusLock: disableFocusLock,
165
- onClickOutside: onClickOutside,
166
- overlayTimeout: animate === "fade" ? {
167
- enter: FADE_DURATION,
168
- exit: FADE_DURATION
169
- } : {
170
- enter: SLIDE_FROM_TOP_ENTER,
171
- exit: SLIDE_FROM_TOP_EXIT
172
- }
173
- }, rest), /*#__PURE__*/React.createElement(DialogSurface, {
174
- in: open,
175
- onClose: onClose,
176
- animate: animate
177
- }, surface));
178
- };
179
102
  DialogFrame.displayName = "DialogFrame";
180
103
  //# sourceMappingURL=DialogFrame.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogFrame.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","DialogContext","StyledDialogViewport","useStableId","ModalBase","ModalRoot","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","NativeDialog","_ref2","forwardedRef","surface","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref3","isIn","DialogFrame","_ref4","_ref4$native","native","_ref4$open","_ref4$enableBackgroun","_ref4$disableCloseOnE","_ref4$animate","disableFocusLock","_excluded2","overlayTimeout","enter","exit"],"sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DialogProps } from \"./Dialog\";\nimport { DialogContext } from \"./DialogContext\";\nimport { StyledDialogViewport } from \"./Styles\";\nimport useStableId from \"../../utils/useStableId\";\nimport { ModalBase } from \"../Modal/ModalBase\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// ModalBase only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though ModalBase overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\ninterface NativeDialogProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n surface: ReactElement;\n children?: ReactNode;\n}\n\nconst NativeDialog = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n ...rest\n}: NativeDialogProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef as unknown as Ref<HTMLDialogElement>}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nNativeDialog.displayName = \"NativeDialog\";\n\nexport interface DialogFrameProps\n extends Omit<DialogProps, \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n /** The visible card. The frame places it in the viewport and runs its open and close animation. */\n surface: ReactElement;\n /** Only the modal path has a focus lock to turn off. */\n disableFocusLock?: boolean;\n}\n\n// What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.\nexport const DialogFrame = ({\n forwardedRef,\n surface,\n native = false,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n disableFocusLock,\n ...rest\n}: DialogFrameProps) => {\n if (native) {\n return (\n <NativeDialog\n {...rest}\n forwardedRef={forwardedRef}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n\n return (\n <ModalBase\n ref={forwardedRef}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n disableFocusLock={disableFocusLock}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n {surface}\n </DialogSurface>\n </ModalBase>\n );\n};\n\nDialogFrame.displayName = \"DialogFrame\";\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAMVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,UAAU;AAC/C,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACpD,SACEC,YAAY,EACZC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AAYpC;AACA;AACA,MAAMC,aAAa,GAAGC,IAAA,IAQI;EAAA,IAAAC,OAAA,GAAAD,IAAA,CAPxBE,EAA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WAAW,CAACnD,WAAW,GAAG,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"DialogFrame.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","DialogContext","StyledDialogViewport","useStableId","ModalRoot","Fade","SlideFromTop","DialogFrame","_ref","forwardedRef","surface","_ref$open","open","onClose","_ref$enableBackground","enableBackgroundClick","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$animate","animate","onClickOutside","_ref$disableReturnFoc","disableReturnFocus","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","Animation","requestClose","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","createElement","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref2","isIn","in","onExited","Provider","value","className","displayName"],"sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DialogProps } from \"./Dialog\";\nimport { DialogContext } from \"./DialogContext\";\nimport { StyledDialogViewport } from \"./Styles\";\nimport useStableId from \"../../utils/useStableId\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade } from \"../Transitions\";\nimport { SlideFromTop } from \"../Transitions/SlideFromTop\";\n\nexport interface DialogFrameProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDialogElement>;\n /** The visible card. The frame places it in the viewport and runs its open and close animation. */\n surface: ReactElement;\n children?: ReactNode;\n}\n\n// What Dialog and ObjectFormModal share: the native modal, the viewport and the animation around a surface each draws.\nexport const DialogFrame = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n disableReturnFocus = false,\n ...rest\n}: DialogFrameProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableReturnFocus={disableReturnFocus}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nDialogFrame.displayName = \"DialogFrame\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAMVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,UAAU;AAC/C,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,YAAY,QAAQ,6BAA6B;AAU1D;AACA,OAAO,MAAMC,WAAW,GAAGC,IAAA,IAWH;EAAA,IAVtBC,YAAY,GAAAD,IAAA,CAAZC,YAAY;IACZC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IAAAC,SAAA,GAAAH,IAAA,CACPI,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,KAAK,GAAAA,SAAA;IACZE,OAAO,GAAAL,IAAA,CAAPK,OAAO;IAAAC,qBAAA,GAAAN,IAAA,CACPO,qBAAqB;IAArBA,qBAAqB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAR,IAAA,CAC7BS,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,YAAA,GAAAV,IAAA,CACzBW,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAG,OAAO,GAAAA,YAAA;IACjBE,cAAc,GAAAZ,IAA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Q;IACjBI,iBAAiB,EAAEA,iBAAkB;IACrCK,kBAAkB,EAAEA,kBAAmB;IACvCuC,sBAAsB,EAAE,CAAC9C,qBAAsB;IAC/C,mBAAiB2B;EAAe,IAE/BoB,KAAA;IAAA,IAAOC,IAAI,GAAAD,KAAA,CAARE,EAAE;MAAQC,QAAQ,GAAAH,KAAA,CAARG,QAAQ;IAAA,oBACpBtE,KAAA,CAAA6D,aAAA,CAACvD,aAAa,CAACiE,QAAQ;MAACC,KAAK,EAAEZ;IAAa,gBAC1C5D,KAAA,CAAA6D,aAAA,CAACtD,oBAAoB;MAACkE,SAAS,EAAC;IAAmB,gBACjDzE,KAAA,CAAA6D,aAAA,CAAC3B,SAAS;MAACmC,EAAE,EAAED,IAAK;MAACE,QAAQ,EAAEA;IAAS,GACrCvD,OACQ,CACS,CACA,CAAC;EAAA,CAElB,CAAC;AAEhB,CAAC;AAEDH,WAAW,CAAC8D,WAAW,GAAG,aAAa","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ /** Warns once per component and prop in development while a caller still passes a prop that no longer does anything. */
2
+ export declare const useRemovedPropWarning: (component: string, prop: string, value: unknown, message: string) => void;
3
+ //# sourceMappingURL=useRemovedPropWarning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemovedPropWarning.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/useRemovedPropWarning.ts"],"names":[],"mappings":"AAIA,wHAAwH;AACxH,eAAO,MAAM,qBAAqB,GAChC,WAAW,MAAM,EACjB,MAAM,MAAM,EACZ,OAAO,OAAO,EACd,SAAS,MAAM,KACd,IAgBF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { useEffect } from "react";
2
+ const warned = new Set();
3
+
4
+ /** Warns once per component and prop in development while a caller still passes a prop that no longer does anything. */
5
+ export const useRemovedPropWarning = (component, prop, value, message) => {
6
+ useEffect(() => {
7
+ const key = component + "." + prop;
8
+ if (process.env.NODE_ENV === "production" || value === undefined || warned.has(key)) {
9
+ return;
10
+ }
11
+ warned.add(key);
12
+ // eslint-disable-next-line no-console
13
+ console.warn(component + ": the " + prop + " prop is gone. " + message);
14
+ }, [component, prop, value, message]);
15
+ };
16
+ //# sourceMappingURL=useRemovedPropWarning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemovedPropWarning.js","names":["useEffect","warned","Set","useRemovedPropWarning","component","prop","value","message","key","process","env","NODE_ENV","undefined","has","add","console","warn"],"sources":["../../../../src/components/Dialog/useRemovedPropWarning.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nconst warned = new Set<string>();\n\n/** Warns once per component and prop in development while a caller still passes a prop that no longer does anything. */\nexport const useRemovedPropWarning = (\n component: string,\n prop: string,\n value: unknown,\n message: string\n): void => {\n useEffect(() => {\n const key = `${component}.${prop}`;\n\n if (\n process.env.NODE_ENV === \"production\" ||\n value === undefined ||\n warned.has(key)\n ) {\n return;\n }\n\n warned.add(key);\n // eslint-disable-next-line no-console\n console.warn(`${component}: the ${prop} prop is gone. ${message}`);\n }, [component, prop, value, message]);\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;;AAEhC;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,SAAiB,EACjBC,IAAY,EACZC,KAAc,EACdC,OAAe,KACN;EACTP,SAAS,CAAC,MAAM;IACd,MAAMQ,GAAG,GAAMJ,SAAS,SAAIC,IAAM;IAElC,IACEI,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IACrCL,KAAK,KAAKM,SAAS,IACnBX,MAAM,CAACY,GAAG,CAACL,GAAG,CAAC,EACf;MACA;IACF;IAEAP,MAAM,CAACa,GAAG,CAACN,GAAG,CAAC;IACf;IACAO,OAAO,CAACC,IAAI,CAAIZ,SAAS,cAASC,IAAI,uBAAkBE,OAAS,CAAC;EACpE,CAAC,EAAE,CAACH,SAAS,EAAEC,IAAI,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AACvC,CAAC","ignoreList":[]}
@@ -15,6 +15,16 @@ export interface ModalRootProps extends Omit<HTMLAttributes<HTMLDialogElement>,
15
15
  disableCloseOnEsc?: boolean;
16
16
  disableBackgroundClick?: boolean;
17
17
  disableScrollLock?: boolean;
18
+ /** Closing leaves the focus off the element that had it before the dialog opened, also when the owner unmounts it */
19
+ disableReturnFocus?: boolean;
20
+ /**
21
+ * The dialog counts as opened before the sheets that are open, so they move into its overlay root and stay above
22
+ * it. For a page dialog that a sheet covers, such as an archive that opens a task, also when the dialog mounts after
23
+ * the sheet on a reload. A sheet that sits in the page mounts its content again in the overlay root; one that sits
24
+ * in another modal moves without remounting, also above a modal opened in between from outside the sheet. Read when
25
+ * the dialog opens; a later change does not move the stack entry.
26
+ */
27
+ belowOpenSheets?: boolean;
18
28
  /** A function gets the transition state, and the dialog closes when it calls onExited. A node closes at once. */
19
29
  children: ReactNode | ((transition: ModalRootTransition) => ReactNode);
20
30
  }
@@ -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;AAiBf,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,cACf,SAAQ,IAAI,CACV,cAAc,CAAC,iBAAiB,CAAC,EACjC,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAC7C;IACD,IAAI,EAAE,OAAO,CAAC;IACd,qEAAqE;IACrE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC1D,6HAA6H;IAC7H,gBAAg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,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,qHAAqH;IACrH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iHAAiH;IACjH,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,UAAU,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,SAAS,0FAqXrB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["open", "onRequestClose", "onDismissBlocked", "onClose", "disableCloseOnEsc", "disableBackgroundClick", "disableScrollLock", "children", "className", "onPointerDown", "onClick", "onKeyDown"];
3
+ const _excluded = ["open", "onRequestClose", "onDismissBlocked", "onClose", "disableCloseOnEsc", "disableBackgroundClick", "disableScrollLock", "disableReturnFocus", "belowOpenSheets", "children", "className", "onPointerDown", "onClick", "onKeyDown"];
4
4
  import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
5
5
  import { RemoveScroll } from "react-remove-scroll";
6
6
  import classnames from "classnames";
@@ -20,6 +20,10 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
20
20
  disableBackgroundClick = _ref$disableBackgroun === void 0 ? false : _ref$disableBackgroun,
21
21
  _ref$disableScrollLoc = _ref.disableScrollLock,
22
22
  disableScrollLock = _ref$disableScrollLoc === void 0 ? false : _ref$disableScrollLoc,
23
+ _ref$disableReturnFoc = _ref.disableReturnFocus,
24
+ disableReturnFocus = _ref$disableReturnFoc === void 0 ? false : _ref$disableReturnFoc,
25
+ _ref$belowOpenSheets = _ref.belowOpenSheets,
26
+ belowOpenSheets = _ref$belowOpenSheets === void 0 ? false : _ref$belowOpenSheets,
23
27
  children = _ref.children,
24
28
  className = _ref.className,
25
29
  onPointerDown = _ref.onPointerDown,
@@ -48,6 +52,20 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
48
52
  // Menus and pickers opened inside portal here, into the top layer with the dialog, not under it.
49
53
  const getOverlayRoot = useCallback(() => overlayRootRef.current, []);
50
54
  openRef.current = open;
55
+ const disableReturnFocusRef = useRef(disableReturnFocus);
56
+ disableReturnFocusRef.current = disableReturnFocus;
57
+
58
+ // close() gives the focus back to the element that had it before showModal when the focus is in the dialog, so
59
+ // a dialog that leaves it there takes it off again. A focus outside, as in a sheet that left the overlay root,
60
+ // stays where it is.
61
+ const closeDialog = useCallback(node => {
62
+ const focusInside = node.contains(document.activeElement);
63
+ node.close();
64
+ if (disableReturnFocusRef.current && focusInside) {
65
+ var _document$activeEleme;
66
+ (_document$activeEleme = document.activeElement) == null || _document$activeEleme.blur();
67
+ }
68
+ }, []);
51
69
  if (open && !mounted) {
52
70
  setMounted(true);
53
71
  }
@@ -89,7 +107,6 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
89
107
  }
90
108
  });
91
109
  const finishClose = useCallback(() => {
92
- var _dialogRef$current;
93
110
  // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.
94
111
  if (dialogRef.current) {
95
112
  dialogRef.current.style.zIndex = "";
@@ -100,10 +117,12 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
100
117
  popModalRoot(stackIdRef.current);
101
118
  stackIdRef.current = undefined;
102
119
  }
103
- (_dialogRef$current = dialogRef.current) == null || _dialogRef$current.close();
120
+ if (dialogRef.current) {
121
+ closeDialog(dialogRef.current);
122
+ }
104
123
  setMounted(false);
105
124
  onClose == null || onClose();
106
- }, [onClose]);
125
+ }, [closeDialog, onClose]);
107
126
 
108
127
  // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the
109
128
  // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it
@@ -116,17 +135,22 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
116
135
  dialog.showModal();
117
136
  }
118
137
  if (stackIdRef.current === undefined) {
119
- stackIdRef.current = pushModalRoot(overlayRootRef.current, suspensionRef.current);
138
+ stackIdRef.current = pushModalRoot(overlayRootRef.current, suspensionRef.current, belowOpenSheets);
120
139
  }
121
- }, [open, dialog]);
140
+ }, [open, dialog, belowOpenSheets]);
122
141
 
123
142
  // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.
143
+ // An owner that unmounts the dialog while it is open, as a form does on submit, gets the focus back on the
144
+ // opener: a dialog removed while open would leave it on the body.
124
145
  useLayoutEffect(() => () => {
125
146
  if (stackIdRef.current !== undefined) {
126
147
  popModalRoot(stackIdRef.current);
127
148
  stackIdRef.current = undefined;
128
149
  }
129
- }, [dialog]);
150
+ if (dialog != null && dialog.open) {
151
+ closeDialog(dialog);
152
+ }
153
+ }, [dialog, closeDialog]);
130
154
  useLayoutEffect(() => {
131
155
  if (!open && mounted && !hasTransition) {
132
156
  finishClose();
@@ -194,7 +218,7 @@ export const ModalRoot = /*#__PURE__*/forwardRef((_ref, ref) => {
194
218
  }
195
219
  };
196
220
  const handleNativeClose = () => {
197
- if (openRef.current && !dialog.open && !areModalRootsSuspended()) {
221
+ if (openRef.current && dialog.isConnected && !dialog.open && !areModalRootsSuspended()) {
198
222
  dialog.showModal();
199
223
  }
200
224
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ModalRoot.js","names":["React","forwardRef","useCallback","useEffect","useLayoutEffect","useRef","useState","RemoveScroll","classnames","areModalRootsSuspended","isTopModalRoot","popModalRoot","pushModalRoot","StyledModalRoot","Portal","PortalContainerProvider","layers","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","focusBeforeSuspendRef","suspensionRef","suspend","contains","document","activeElement","style","zIndex","String","cloud","close","show","resume","showModal","focus","HTMLElement","preventScroll","finishClose","_dialogRef$current","undefined","dismissRef","reason","event","blocked","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","defaultPrevented","key","target","body","querySelector","preventDefault","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","handleNativeClose","handlePointerDown","currentTarget","handleClick","stopPropagation","_overlayRootRef$curre4","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 {\n areModalRootsSuspended,\n isTopModalRoot,\n ModalRootSuspension,\n popModalRoot,\n pushModalRoot,\n} from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport { layers } from \"../../utils/layers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nexport interface ModalRootTransition {\n in: boolean;\n onExited: () => void;\n}\n\nexport interface ModalRootProps\n extends Omit<\n HTMLAttributes<HTMLDialogElement>,\n \"children\" | \"open\" | \"onClose\" | \"onCancel\"\n > {\n open: boolean;\n /** Escape or a backdrop click asks the owner to set open to false */\n onRequestClose?: (reason: ModalRootDismissReason) => void;\n /** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked; a backdrop click passes its event */\n onDismissBlocked?: (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void;\n /** The exit transition is done and the dialog is closed */\n onClose?: () => void;\n disableCloseOnEsc?: boolean;\n disableBackgroundClick?: boolean;\n disableScrollLock?: boolean;\n /** A function gets the transition state, and the dialog closes when it calls onExited. A node closes at once. */\n children: ReactNode | ((transition: ModalRootTransition) => ReactNode);\n}\n\nexport const ModalRoot = forwardRef<HTMLDialogElement, ModalRootProps>(\n (\n {\n open,\n onRequestClose,\n onDismissBlocked,\n onClose,\n disableCloseOnEsc = false,\n disableBackgroundClick = false,\n disableScrollLock = false,\n children,\n className,\n onPointerDown,\n onClick,\n onKeyDown,\n ...rest\n },\n ref\n ) => {\n const [mounted, setMounted] = useState(open);\n // Inside another root the dialog mounts a render after its first one, once the outer overlay root exists,\n // so opening, the stack and the listeners wait for the node instead of the first commit.\n const [dialog, setDialog] = useState<HTMLDialogElement | null>(null);\n const dialogRef = useRef<HTMLDialogElement | null>(null);\n const setDialogNode = useCallback((node: HTMLDialogElement | null) => {\n dialogRef.current = node;\n setDialog(node);\n }, []);\n const handleRef = useForkRef(setDialogNode, ref);\n const hasTransition = typeof children === \"function\";\n const openRef = useRef(open);\n const pressStartedOnBackdrop = useRef(false);\n const stackIdRef = useRef<number>();\n const overlayRootRef = useRef<HTMLDivElement>(null);\n // Menus and pickers opened inside portal here, into the top layer with the dialog, not under it.\n const getOverlayRoot = useCallback(\n () => overlayRootRef.current as HTMLElement,\n []\n );\n\n openRef.current = open;\n\n if (open && !mounted) {\n setMounted(true);\n }\n\n // While suspended the dialog is open without being modal, in the page instead of the top layer, so it keeps a\n // layer just under the overlay it was suspended for. A dismiss then would close it under that overlay.\n // The stack calls suspend once for an entry and resume at most once, so the suspension is the stack's state.\n const focusBeforeSuspendRef = useRef<Element | null>(null);\n const suspensionRef = useRef<ModalRootSuspension>({\n suspend: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n focusBeforeSuspendRef.current = node.contains(document.activeElement)\n ? document.activeElement\n : null;\n node.style.zIndex = String(layers.cloud - 1);\n\n if (node.open) {\n node.close();\n node.show();\n }\n },\n resume: () => {\n const node = dialogRef.current;\n\n if (!node) {\n return;\n }\n\n node.style.zIndex = \"\";\n\n if (node.open) {\n node.close();\n node.showModal();\n }\n\n const focus = focusBeforeSuspendRef.current;\n focusBeforeSuspendRef.current = null;\n\n if (focus instanceof HTMLElement && node.contains(focus)) {\n focus.focus({ preventScroll: true });\n }\n },\n });\n\n const finishClose = useCallback(() => {\n // A dialog that closes while suspended leaves the stack before the resume, so it drops its layer here.\n if (dialogRef.current) {\n dialogRef.current.style.zIndex = \"\";\n }\n\n // Content that sits in the overlay root moves out before the dialog hides it.\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n dialogRef.current?.close();\n setMounted(false);\n onClose?.();\n }, [onClose]);\n\n // The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the\n // same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it\n // is rendered and can get its scroll positions back.\n useLayoutEffect(() => {\n if (!open || !dialog) {\n return;\n }\n\n if (!dialog.open) {\n dialog.showModal();\n }\n\n if (stackIdRef.current === undefined) {\n stackIdRef.current = pushModalRoot(\n overlayRootRef.current,\n suspensionRef.current\n );\n }\n }, [open, dialog]);\n\n // A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.\n useLayoutEffect(\n () => () => {\n if (stackIdRef.current !== undefined) {\n popModalRoot(stackIdRef.current);\n stackIdRef.current = undefined;\n }\n },\n [dialog]\n );\n\n useLayoutEffect(() => {\n if (!open && mounted && !hasTransition) {\n finishClose();\n }\n }, [open, mounted, hasTransition, finishClose]);\n\n const dismissRef =\n useRef<\n (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void\n >();\n\n dismissRef.current = (reason, event) => {\n if (areModalRootsSuspended()) {\n return;\n }\n\n const blocked =\n reason === \"escape\" ? disableCloseOnEsc : disableBackgroundClick;\n\n if (blocked) {\n onDismissBlocked?.(reason, event);\n } else {\n onRequestClose?.(reason);\n }\n };\n\n // A prevented Escape keydown starts no close request, and the browser stops honouring a prevented cancel\n // after a while, so Escape is caught here and the cancel event only covers the other close requests.\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const stackId = stackIdRef.current;\n\n if (\n stackId === undefined ||\n !isTopModalRoot(stackId) ||\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\")\n ) {\n return;\n }\n\n // A menu inside closes on an Escape that reaches the body, from a listener that runs after this one.\n if (\n event.target === document.body &&\n overlayRootRef.current?.querySelector(\".c-window\")\n ) {\n return;\n }\n\n event.preventDefault();\n\n // A sheet, a menu or the chat in the overlay root is a layer above the dialog. An Escape it did not take\n // still belongs to it, so the dialog only stops the browser from closing itself.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [dialog]);\n\n useEffect(() => {\n if (!dialog) {\n return undefined;\n }\n\n const handleCancel = (event: Event) => {\n event.preventDefault();\n\n // A layer in the overlay root may stop its Escape before the document sees it, so the cancel that follows\n // would close the dialog under the layer. While the focus is in that layer, the close request is its own.\n if (overlayRootRef.current?.contains(document.activeElement)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n };\n\n const handleNativeClose = () => {\n if (openRef.current && !dialog.open && !areModalRootsSuspended()) {\n dialog.showModal();\n }\n };\n\n dialog.addEventListener(\"cancel\", handleCancel);\n dialog.addEventListener(\"close\", handleNativeClose);\n\n return () => {\n dialog.removeEventListener(\"cancel\", handleCancel);\n dialog.removeEventListener(\"close\", handleNativeClose);\n };\n }, [dialog]);\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLDialogElement>) => {\n pressStartedOnBackdrop.current = event.target === event.currentTarget;\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n // The dialog covers the viewport and its content sits inside it, so a click on the dialog itself is a\n // click on the backdrop. A press that started on the content and ended outside it is a text selection.\n // A click does not bubble on through the React tree, as from a legacy window: a confirmation rendered in a\n // clickable row would otherwise click the row as well. React listens at the portal's container, so a click\n // listener on document or window does not see a click inside the dialog either, as with the window.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDialogElement>) => {\n if (\n event.target === event.currentTarget &&\n pressStartedOnBackdrop.current &&\n openRef.current\n ) {\n dismissRef.current?.(\"backdrop\", event);\n }\n pressStartedOnBackdrop.current = false;\n onClick?.(event);\n event.stopPropagation();\n },\n [onClick]\n );\n\n // React events from a portal bubble through the React tree, so an Escape from the content would reach an\n // ancestor's handler, like an older Sheet's, before the document listener. The dialog takes it here first.\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDialogElement>) => {\n onKeyDown?.(event);\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Escape\" && event.key !== \"Esc\") ||\n stackIdRef.current === undefined ||\n !isTopModalRoot(stackIdRef.current)\n ) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // An Escape a layer in the overlay root did not take stops here too, so it does not close the sheet that\n // opened this dialog, but it leaves the dialog open.\n if (overlayRootRef.current?.contains(event.target as Node)) {\n return;\n }\n\n if (openRef.current) {\n dismissRef.current?.(\"escape\");\n }\n },\n [onKeyDown]\n );\n\n const handleExited = useCallback(() => {\n if (!open) {\n finishClose();\n }\n }, [open, finishClose]);\n\n if (!mounted) {\n return null;\n }\n\n return (\n <Portal>\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation\n >\n <StyledModalRoot\n {...rest}\n className={classnames(\"c-modal-root\", className)}\n data-state={open ? \"open\" : \"closing\"}\n onPointerDown={handlePointerDown}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n <PortalContainerProvider value={getOverlayRoot}>\n {typeof children === \"function\"\n ? children({ in: open, onExited: handleExited })\n : children}\n </PortalContainerProvider>\n <div ref={overlayRootRef} className=\"c-modal-root__overlays\" />\n </StyledModalRoot>\n </RemoveScroll>\n </Portal>\n );\n }\n);\n\nModalRoot.displayName = \"ModalRoot\";\n"],"mappings":";;;AAAA,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,SACEC,sBAAsB,EACtBC,cAAc,EAEdC,YAAY,EACZC,aAAa,QACR,kBAAkB;AACzB,SAASC,eAAe,QAAQ,UAAU;AAC1C,SAASC,MAAM,EAAEC,uBAAuB,QAAQ,eAAe;AAC/D,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,OAAOC,UAAU,MAAM,wBAAwB;AA+B/C,OAAO,MAAMC,SAAS,gBAAGjB,UAAU,CACjC,CAAAkB,IAAA,EAgBEC,GAAG,KACA;EAAA,IAfDC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,cAAc,GAAAH,IAAA,CAAdG,cAAc;IACdC,gBAAgB,GAAAJ,IAAA,CAAhBI,gBAAgB;IAChBC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IAAAC,qBAAA,GAAAN,IAAA,CACPO,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAR,IAAA,CACzBS,sBAAsB;IAAtBA,sBAAsB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAV,IAAA,CAC9BW,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IACzBE,QAAQ,GAAAZ,IAAA,CAARY,QAA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;AAEb,CACF,CAAC;AAEDd,SAAS,CAAC2F,WAAW,GAAG,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"ModalRoot.js","names":["React","forwardRef","useCallback","useEffect","useLayoutEffect","useRef","useState","RemoveScroll","classnames","areModalRootsSuspended","isTopModalRoot","popModalRoot","pushModalRoot","StyledModalRoot","Portal","PortalContainerProvider","layers","useForkRef","ModalRoot","_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","_objectWithoutPropertiesLoose","_excluded","_useState","mounted","setMounted","_useState2","dialog","setDialog","dialogRef","setDialogNode","node","current","handleRef","hasTransition","openRef","pressStartedOnBackdrop","stackIdRef","overlayRootRef","getOverlayRoot","disableReturnFocusRef","closeDialog","focusInside","contains","document","activeElement","close","_document$activeEleme","blur","focusBeforeSuspendRef","suspensionRef","suspend","style","zIndex","String","cloud","show","resume","showModal","focus","HTMLElement","preventScroll","finishClose","undefined","dismissRef","reason","event","blocked","handleKeyDown","_overlayRootRef$curre","_overlayRootRef$curre2","stackId","defaultPrevented","key","target","body","querySelector","preventDefault","addEventListener","removeEventListener","handleCancel","_overlayRootRef$curre3","handleNativeClose","isConnected","handlePointerDown","currentTarget","handleClick","stopPropagation","_overlayRootRef$curre4","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 {\n areModalRootsSuspended,\n isTopModalRoot,\n ModalRootSuspension,\n popModalRoot,\n pushModalRoot,\n} from \"./modalRootStack\";\nimport { StyledModalRoot } from \"./Styles\";\nimport { Portal, PortalContainerProvider } from \"../../helpers\";\nimport { layers } from \"../../utils/layers\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport type ModalRootDismissReason = \"escape\" | \"backdrop\";\n\nexport interface ModalRootTransition {\n in: boolean;\n onExited: () => void;\n}\n\nexport interface ModalRootProps\n extends Omit<\n HTMLAttributes<HTMLDialogElement>,\n \"children\" | \"open\" | \"onClose\" | \"onCancel\"\n > {\n open: boolean;\n /** Escape or a backdrop click asks the owner to set open to false */\n onRequestClose?: (reason: ModalRootDismissReason) => void;\n /** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked; a backdrop click passes its event */\n onDismissBlocked?: (\n reason: ModalRootDismissReason,\n event?: MouseEvent<HTMLDialogElement>\n ) => void;\n /** The exit transition is done and the dialog is closed */\n onClose?: () => void;\n disableCloseOnEsc?: boolean;\n disableBackgroundClick?: boolean;\n disableScrollLock?: boolean;\n /** 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 /** 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 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 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 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 }, [open, dialog, belowOpenSheets]);\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 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,SACEC,sBAAsB,EACtBC,cAAc,EAEdC,YAAY,EACZC,aAAa,QACR,kBAAkB;AACzB,SAASC,eAAe,QAAQ,UAAU;AAC1C,SAASC,MAAM,EAAEC,uBAAuB,QAAQ,eAAe;AAC/D,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,OAAOC,UAAU,MAAM,wBAAwB;AAyC/C,OAAO,MAAMC,SAAS,gBAAGjB,UAAU,CACjC,CAAAkB,IAAA,EAkBEC,GAAG,KACA;EAAA,IAjBDC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,cAAc,GAAAH,IAAA,CAAdG,cAAc;IACdC,gBAAgB,GAAAJ,IAAA,CAAhBI,gBAAgB;IAChBC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IAAAC,qBAAA,GAAAN,IAAA,CACPO,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAR,IAAA,CACzBS,sBAAsB;IAAtBA,sBAAsB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAV,IAAA,CAC9BW,iBAAiB;IAAjBA,iBAAiB,GAA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AAI,EAAE;MACT6D,WAAW,CAAC,CAAC;IACf;EACF,CAAC,EAAE,CAAC7D,IAAI,EAAE6D,WAAW,CAAC,CAAC;EAEvB,IAAI,CAACtC,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,oBACE5C,KAAA,CAAA8G,aAAA,CAAChG,MAAM,qBACLd,KAAA,CAAA8G,aAAA,CAACvG,YAAY;IACXwG,YAAY;IACZ3F,GAAG,EAAEiC,SAAU;IACf2D,OAAO,EAAE,CAAClF,iBAAkB;IAC5BmF,WAAW;EAAA,gBAEXjH,KAAA,CAAA8G,aAAA,CAACjG,eAAe,EAAAqG,QAAA,KACV1E,IAAI;IACRJ,SAAS,EAAE5B,UAAU,CAAC,cAAc,EAAE4B,SAAS,CAAE;IACjD,cAAYf,IAAI,GAAG,MAAM,GAAG,SAAU;IACtCgB,aAAa,EAAEmE,iBAAkB;IACjClE,OAAO,EAAEoE,WAAY;IACrBnE,SAAS,EAAEiD;EAAc,iBAEzBxF,KAAA,CAAA8G,aAAA,CAAC/F,uBAAuB;IAACoG,KAAK,EAAExD;EAAe,GAC5C,OAAOxB,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC;IAAEiF,EAAE,EAAE/F,IAAI;IAAEgG,QAAQ,EAAER;EAAa,CAAC,CAAC,GAC9C1E,QACmB,CAAC,eAC1BnC,KAAA,CAAA8G,aAAA;IAAK1F,GAAG,EAAEsC,cAAe;IAACtB,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;AAEb,CACF,CAAC;AAEDlB,SAAS,CAACoG,WAAW,GAAG,WAAW","ignoreList":[]}
@@ -3,7 +3,7 @@ export interface ModalRootSuspension {
3
3
  suspend: () => void;
4
4
  resume: () => void;
5
5
  }
6
- export declare const pushModalRoot: (overlayRoot: HTMLElement | null, suspension?: ModalRootSuspension) => number;
6
+ export declare const pushModalRoot: (overlayRoot: HTMLElement | null, suspension?: ModalRootSuspension, belowOpenSheets?: boolean) => number;
7
7
  export declare const popModalRoot: (id: number) => void;
8
8
  export declare const isTopModalRoot: (id: number) => boolean;
9
9
  /**
@@ -14,8 +14,14 @@ export declare const isTopModalRoot: (id: number) => boolean;
14
14
  export declare const getTopModalOverlayRoot: (outside?: Node) => HTMLElement | null;
15
15
  /** The id of the top open modal root, or undefined when none is open. */
16
16
  export declare const getTopModalRootId: () => number | undefined;
17
- /** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */
17
+ /**
18
+ * The overlay root of the top modal root among those opened no later than the given one, or opened below open
19
+ * sheets, skipping as above. A modal opened below open sheets counts whatever its id, so a sheet moves into it also
20
+ * when another modal opened in between from outside the sheet.
21
+ */
18
22
  export declare const getModalOverlayRootUpTo: (id: number, outside?: Node) => HTMLElement | null;
23
+ /** The id of the top modal root that opened below open sheets, or undefined when none is open. */
24
+ export declare const getTopModalRootIdBelowOpenSheets: () => number | undefined;
19
25
  export declare const subscribeToModalRoots: (listener: Listener) => (() => void);
20
26
  /** True while suspendModalRoots holds the open modal roots non-modal. */
21
27
  export declare const areModalRootsSuspended: () => boolean;
@@ -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;AAE3B,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAgBD,eAAO,MAAM,aAAa,GACxB,aAAa,WAAW,GAAG,IAAI,EAC/B,aAAa,mBAAmB,KAC/B,MAYF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,IAOzC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,KAAG,OACR,CAAC;AAKrC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,IAAI,KAAG,WAAW,GAAG,IACS,CAAC;AAEhF,yEA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,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAMrE,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,QAAO,OAA0B,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAO,CAAC,MAAM,IAAI,CAqB/C,CAAC"}
@@ -3,12 +3,16 @@ let stack = [];
3
3
  let lastId = 0;
4
4
  let suspensions = 0;
5
5
  const notify = () => listeners.forEach(listener => listener());
6
- export const pushModalRoot = (overlayRoot, suspension) => {
6
+ export const pushModalRoot = function (overlayRoot, suspension, belowOpenSheets) {
7
+ if (belowOpenSheets === void 0) {
8
+ belowOpenSheets = false;
9
+ }
7
10
  lastId += 1;
8
11
  stack = [...stack, {
9
12
  id: lastId,
10
13
  overlayRoot,
11
- suspension
14
+ suspension,
15
+ belowOpenSheets
12
16
  }];
13
17
 
14
18
  // A modal root that opens while the others are suspended joins them, or it would leave the overlay inert.
@@ -47,10 +51,20 @@ export const getTopModalRootId = () => {
47
51
  return (_stack2 = stack[stack.length - 1]) == null ? void 0 : _stack2.id;
48
52
  };
49
53
 
50
- /** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */
54
+ /**
55
+ * The overlay root of the top modal root among those opened no later than the given one, or opened below open
56
+ * sheets, skipping as above. A modal opened below open sheets counts whatever its id, so a sheet moves into it also
57
+ * when another modal opened in between from outside the sheet.
58
+ */
51
59
  export const getModalOverlayRootUpTo = (id, outside) => {
52
60
  var _stack$filter$pop$ove2, _stack$filter$pop2;
53
- return (_stack$filter$pop$ove2 = (_stack$filter$pop2 = stack.filter(entry => entry.id <= id && !isInside(entry, outside)).pop()) == null ? void 0 : _stack$filter$pop2.overlayRoot) != null ? _stack$filter$pop$ove2 : null;
61
+ return (_stack$filter$pop$ove2 = (_stack$filter$pop2 = stack.filter(entry => (entry.id <= id || entry.belowOpenSheets) && !isInside(entry, outside)).pop()) == null ? void 0 : _stack$filter$pop2.overlayRoot) != null ? _stack$filter$pop$ove2 : null;
62
+ };
63
+
64
+ /** The id of the top modal root that opened below open sheets, or undefined when none is open. */
65
+ export const getTopModalRootIdBelowOpenSheets = () => {
66
+ var _stack$filter$pop3;
67
+ return (_stack$filter$pop3 = stack.filter(entry => entry.belowOpenSheets).pop()) == null ? void 0 : _stack$filter$pop3.id;
54
68
  };
55
69
  export const subscribeToModalRoots = listener => {
56
70
  listeners.add(listener);
@@ -1 +1 @@
1
- {"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","suspensions","notify","forEach","listener","pushModalRoot","overlayRoot","suspension","id","suspend","popModalRoot","some","entry","filter","isTopModalRoot","_stack","length","isInside","outside","contains","getTopModalOverlayRoot","_stack$filter$pop$ove","_stack$filter$pop","pop","getTopModalRootId","_stack2","getModalOverlayRootUpTo","_stack$filter$pop$ove2","_stack$filter$pop2","subscribeToModalRoots","add","delete","areModalRootsSuspended","suspendModalRoots","reverse","_entry$suspension","released","_entry$suspension2","resume"],"sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"sourcesContent":["type Listener = () => void;\n\nexport interface ModalRootSuspension {\n suspend: () => void;\n resume: () => void;\n}\n\ninterface Entry {\n id: number;\n overlayRoot: HTMLElement | null;\n suspension?: ModalRootSuspension;\n}\n\nconst listeners = new Set<Listener>();\n\nlet stack: Entry[] = [];\nlet lastId = 0;\nlet suspensions = 0;\n\nconst notify = (): void => listeners.forEach((listener) => listener());\n\nexport const pushModalRoot = (\n overlayRoot: HTMLElement | null,\n suspension?: ModalRootSuspension\n): number => {\n lastId += 1;\n stack = [...stack, { id: lastId, overlayRoot, suspension }];\n\n // A modal root that opens while the others are suspended joins them, or it would leave the overlay inert.\n if (suspensions > 0) {\n suspension?.suspend();\n }\n\n notify();\n\n return lastId;\n};\n\nexport const popModalRoot = (id: number): void => {\n if (!stack.some((entry) => entry.id === id)) {\n return;\n }\n\n stack = stack.filter((entry) => entry.id !== id);\n notify();\n};\n\nexport const isTopModalRoot = (id: number): boolean =>\n stack[stack.length - 1]?.id === id;\n\nconst isInside = (entry: Entry, outside?: Node) =>\n !!outside && !!entry.overlayRoot && outside.contains(entry.overlayRoot);\n\n/**\n * The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root\n * whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into\n * itself.\n */\nexport const getTopModalOverlayRoot = (outside?: Node): HTMLElement | null =>\n stack.filter((entry) => !isInside(entry, outside)).pop()?.overlayRoot ?? null;\n\n/** The id of the top open modal root, or undefined when none is open. */\nexport const getTopModalRootId = (): number | undefined =>\n stack[stack.length - 1]?.id;\n\n/** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */\nexport const getModalOverlayRootUpTo = (\n id: number,\n outside?: Node\n): HTMLElement | null =>\n stack.filter((entry) => entry.id <= id && !isInside(entry, outside)).pop()\n ?.overlayRoot ?? null;\n\nexport const subscribeToModalRoots = (listener: Listener): (() => void) => {\n listeners.add(listener);\n\n return (): void => {\n listeners.delete(listener);\n };\n};\n\n/** True while suspendModalRoots holds the open modal roots non-modal. */\nexport const areModalRootsSuspended = (): boolean => suspensions > 0;\n\n/**\n * Turns every open modal root into a non-modal dialog until the returned release is called, so an overlay that a\n * third party renders into document.body, such as the Google Drive picker, can be used above them. The dialogs keep\n * their place, look, content and order, and do not close. Calls nest: the modal roots come back, from the bottom up,\n * with the last release. A suspended dialog sits at layers.cloud - 1, so the overlay must be at layers.cloud or above;\n * the frontend raises the Google Drive picker there in its own CSS.\n */\nexport const suspendModalRoots = (): (() => void) => {\n suspensions += 1;\n\n if (suspensions === 1) {\n [...stack].reverse().forEach((entry) => entry.suspension?.suspend());\n }\n\n let released = false;\n\n return () => {\n if (released) {\n return;\n }\n\n released = true;\n suspensions -= 1;\n\n if (suspensions === 0) {\n stack.forEach((entry) => entry.suspension?.resume());\n }\n };\n};\n"],"mappings":"AAaA,MAAMA,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;AAErC,IAAIC,KAAc,GAAG,EAAE;AACvB,IAAIC,MAAM,GAAG,CA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AAO,CAAC,CAAC,CAAC/B,OAAO,CAAES,KAAK;MAAA,IAAAuB,iBAAA;MAAA,QAAAA,iBAAA,GAAKvB,KAAK,CAACL,UAAU,qBAAhB4B,iBAAA,CAAkB1B,OAAO,CAAC,CAAC;IAAA,EAAC;EACtE;EAEA,IAAI2B,QAAQ,GAAG,KAAK;EAEpB,OAAO,MAAM;IACX,IAAIA,QAAQ,EAAE;MACZ;IACF;IAEAA,QAAQ,GAAG,IAAI;IACfnC,WAAW,IAAI,CAAC;IAEhB,IAAIA,WAAW,KAAK,CAAC,EAAE;MACrBF,KAAK,CAACI,OAAO,CAAES,KAAK;QAAA,IAAAyB,kBAAA;QAAA,QAAAA,kBAAA,GAAKzB,KAAK,CAACL,UAAU,qBAAhB8B,kBAAA,CAAkBC,MAAM,CAAC,CAAC;MAAA,EAAC;IACtD;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"modalRootStack.js","names":["listeners","Set","stack","lastId","suspensions","notify","forEach","listener","pushModalRoot","overlayRoot","suspension","belowOpenSheets","id","suspend","popModalRoot","some","entry","filter","isTopModalRoot","_stack","length","isInside","outside","contains","getTopModalOverlayRoot","_stack$filter$pop$ove","_stack$filter$pop","pop","getTopModalRootId","_stack2","getModalOverlayRootUpTo","_stack$filter$pop$ove2","_stack$filter$pop2","getTopModalRootIdBelowOpenSheets","_stack$filter$pop3","subscribeToModalRoots","add","delete","areModalRootsSuspended","suspendModalRoots","reverse","_entry$suspension","released","_entry$suspension2","resume"],"sources":["../../../../src/components/ModalRoot/modalRootStack.ts"],"sourcesContent":["type Listener = () => void;\n\nexport interface ModalRootSuspension {\n suspend: () => void;\n resume: () => void;\n}\n\ninterface Entry {\n id: number;\n overlayRoot: HTMLElement | null;\n suspension?: ModalRootSuspension;\n belowOpenSheets: boolean;\n}\n\nconst listeners = new Set<Listener>();\n\nlet stack: Entry[] = [];\nlet lastId = 0;\nlet suspensions = 0;\n\nconst notify = (): void => listeners.forEach((listener) => listener());\n\nexport const pushModalRoot = (\n overlayRoot: HTMLElement | null,\n suspension?: ModalRootSuspension,\n belowOpenSheets = false\n): number => {\n lastId += 1;\n stack = [...stack, { id: lastId, overlayRoot, suspension, belowOpenSheets }];\n\n // A modal root that opens while the others are suspended joins them, or it would leave the overlay inert.\n if (suspensions > 0) {\n suspension?.suspend();\n }\n\n notify();\n\n return lastId;\n};\n\nexport const popModalRoot = (id: number): void => {\n if (!stack.some((entry) => entry.id === id)) {\n return;\n }\n\n stack = stack.filter((entry) => entry.id !== id);\n notify();\n};\n\nexport const isTopModalRoot = (id: number): boolean =>\n stack[stack.length - 1]?.id === id;\n\nconst isInside = (entry: Entry, outside?: Node) =>\n !!outside && !!entry.overlayRoot && outside.contains(entry.overlayRoot);\n\n/**\n * The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root\n * whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into\n * itself.\n */\nexport const getTopModalOverlayRoot = (outside?: Node): HTMLElement | null =>\n stack.filter((entry) => !isInside(entry, outside)).pop()?.overlayRoot ?? null;\n\n/** The id of the top open modal root, or undefined when none is open. */\nexport const getTopModalRootId = (): number | undefined =>\n stack[stack.length - 1]?.id;\n\n/**\n * The overlay root of the top modal root among those opened no later than the given one, or opened below open\n * sheets, skipping as above. A modal opened below open sheets counts whatever its id, so a sheet moves into it also\n * when another modal opened in between from outside the sheet.\n */\nexport const getModalOverlayRootUpTo = (\n id: number,\n outside?: Node\n): HTMLElement | null =>\n stack\n .filter(\n (entry) =>\n (entry.id <= id || entry.belowOpenSheets) && !isInside(entry, outside)\n )\n .pop()?.overlayRoot ?? null;\n\n/** The id of the top modal root that opened below open sheets, or undefined when none is open. */\nexport const getTopModalRootIdBelowOpenSheets = (): number | undefined =>\n stack.filter((entry) => entry.belowOpenSheets).pop()?.id;\n\nexport const subscribeToModalRoots = (listener: Listener): (() => void) => {\n listeners.add(listener);\n\n return (): void => {\n listeners.delete(listener);\n };\n};\n\n/** True while suspendModalRoots holds the open modal roots non-modal. */\nexport const areModalRootsSuspended = (): boolean => suspensions > 0;\n\n/**\n * Turns every open modal root into a non-modal dialog until the returned release is called, so an overlay that a\n * third party renders into document.body, such as the Google Drive picker, can be used above them. The dialogs keep\n * their place, look, content and order, and do not close. Calls nest: the modal roots come back, from the bottom up,\n * with the last release. A suspended dialog sits at layers.cloud - 1, so the overlay must be at layers.cloud or above;\n * the frontend raises the Google Drive picker there in its own CSS.\n */\nexport const suspendModalRoots = (): (() => void) => {\n suspensions += 1;\n\n if (suspensions === 1) {\n [...stack].reverse().forEach((entry) => entry.suspension?.suspend());\n }\n\n let released = false;\n\n return () => {\n if (released) {\n return;\n }\n\n released = true;\n suspensions -= 1;\n\n if (suspensions === 0) {\n stack.forEach((entry) => entry.suspension?.resume());\n }\n };\n};\n"],"mappings":"AAcA,MAAMA,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;AAErC,IAAIC,KAAc,GAAG,EAAE;AACvB,IAAIC,MAAM,GAAG,CAAC;AACd,IAAIC,WAAW,GAAG,CAAC;AAEnB,MAAMC,MAAM,GAAGA,CAAA,KAAYL,SAAS,CAACM,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;AAEtE,OAAO,MAAMC,aAAa,GAAG,SAAAA,CAC3BC,WAA+B,EAC/BC,UAAgC,EAChCC,eAAe,EACJ;EAAA,IADXA,eAAe;IAAfA,eAAe,GAAG,KAAK;EAAA;EAEvBR,MAAM,IAAI,CAAC;EACXD,KAAK,GAAG,CAAC,GAAGA,KAAK,EAAE;IAAEU,EAAE,EAAET,MAAM;IAAEM,WAAW;IAAEC,UAAU;IAAEC;EAAgB,CAAC,CAAC;;EAE5E;EACA,IAAIP,WAAW,GAAG,CAAC,EAAE;IACnBM,UAAU,YAAVA,UAAU,CAAEG,OAAO,CAAC,CAAC;EACvB;EAEAR,MAAM,CAAC,CAAC;EAER,OAAOF,MAAM;AACf,CAAC;AAED,OAAO,MAAMW,YAAY,GAAIF,EAAU,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