@activecollab/components 2.0.542 → 2.0.544

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 (145) hide show
  1. package/dist/cjs/components/CommandPalette/CommandPalette.js +3 -1
  2. package/dist/cjs/components/CommandPalette/CommandPalette.js.map +1 -1
  3. package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js +4 -4
  4. package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
  5. package/dist/cjs/components/Dialog/Dialog.js +12 -9
  6. package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
  7. package/dist/cjs/components/Dialog/DialogContext.js.map +1 -1
  8. package/dist/cjs/components/Dialog/DialogFrame.js +24 -103
  9. package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -1
  10. package/dist/cjs/components/Dialog/usePropWarning.js +34 -0
  11. package/dist/cjs/components/Dialog/usePropWarning.js.map +1 -0
  12. package/dist/cjs/components/ModalRoot/ModalRoot.js +32 -8
  13. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  14. package/dist/cjs/components/ModalRoot/modalRootStack.js +18 -4
  15. package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
  16. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +13 -12
  17. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  18. package/dist/cjs/components/Sheet/Sheet.js +17 -5
  19. package/dist/cjs/components/Sheet/Sheet.js.map +1 -1
  20. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +7 -0
  21. package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -1
  22. package/dist/cjs/components/Wizard/Wizard.js +1 -0
  23. package/dist/cjs/components/Wizard/Wizard.js.map +1 -1
  24. package/dist/cjs/presentation/listView/columns.js +622 -184
  25. package/dist/cjs/presentation/listView/columns.js.map +1 -1
  26. package/dist/cjs/presentation/myWork/MyWorkListSettingsDialog.js +1 -1
  27. package/dist/cjs/presentation/myWork/MyWorkListSettingsDialog.js.map +1 -1
  28. package/dist/cjs/presentation/reports/availabilityExport.js +1 -1
  29. package/dist/cjs/presentation/reports/availabilityExport.js.map +1 -1
  30. package/dist/cjs/presentation/selfHostedRedesign/parts.js +6 -6
  31. package/dist/cjs/presentation/selfHostedRedesign/parts.js.map +1 -1
  32. package/dist/cjs/presentation/shared/LinkingCommandsButton.js +1 -1
  33. package/dist/cjs/presentation/shared/LinkingCommandsButton.js.map +1 -1
  34. package/dist/cjs/presentation/shared/MessageDialog.js +1 -1
  35. package/dist/cjs/presentation/shared/MessageDialog.js.map +1 -1
  36. package/dist/cjs/presentation/shared/MessageFeedback.js +1 -1
  37. package/dist/cjs/presentation/shared/MessageFeedback.js.map +1 -1
  38. package/dist/cjs/presentation/shared/ProjectOptionsMenu.js +1 -1
  39. package/dist/cjs/presentation/shared/ProjectOptionsMenu.js.map +1 -1
  40. package/dist/cjs/presentation/shared/SourceCodeSection.js +2 -2
  41. package/dist/cjs/presentation/shared/SourceCodeSection.js.map +1 -1
  42. package/dist/cjs/presentation/shared/UserDetailsDialog.js +1 -1
  43. package/dist/cjs/presentation/shared/UserDetailsDialog.js.map +1 -1
  44. package/dist/cjs/presentation/shared/WebhookLogsDialog.js +1 -1
  45. package/dist/cjs/presentation/shared/WebhookLogsDialog.js.map +1 -1
  46. package/dist/cjs/presentation/shared/selfHostedSettings.js +1 -1
  47. package/dist/cjs/presentation/shared/selfHostedSettings.js.map +1 -1
  48. package/dist/cjs/presentation/shared/selfHostedUpgrade.js +3 -3
  49. package/dist/cjs/presentation/shared/selfHostedUpgrade.js.map +1 -1
  50. package/dist/cjs/presentation/shared/systemSettingsDialog.js +1 -1
  51. package/dist/cjs/presentation/shared/systemSettingsDialog.js.map +1 -1
  52. package/dist/cjs/presentation/whiteboard/peopleMenu.js +1 -1
  53. package/dist/cjs/presentation/whiteboard/peopleMenu.js.map +1 -1
  54. package/dist/cjs/presentation/whiteboard/projectElements.js +1 -1
  55. package/dist/cjs/presentation/whiteboard/projectElements.js.map +1 -1
  56. package/dist/esm/components/CommandPalette/CommandPalette.d.ts +2 -2
  57. package/dist/esm/components/CommandPalette/CommandPalette.d.ts.map +1 -1
  58. package/dist/esm/components/CommandPalette/CommandPalette.js +3 -1
  59. package/dist/esm/components/CommandPalette/CommandPalette.js.map +1 -1
  60. package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +5 -2
  61. package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
  62. package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +4 -4
  63. package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
  64. package/dist/esm/components/DatePicker/Styles.d.ts +1 -1
  65. package/dist/esm/components/DatePicker/Styles.d.ts.map +1 -1
  66. package/dist/esm/components/Dialog/Dialog.d.ts +22 -4
  67. package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
  68. package/dist/esm/components/Dialog/Dialog.js +12 -9
  69. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  70. package/dist/esm/components/Dialog/DialogContext.d.ts +2 -2
  71. package/dist/esm/components/Dialog/DialogContext.d.ts.map +1 -1
  72. package/dist/esm/components/Dialog/DialogContext.js.map +1 -1
  73. package/dist/esm/components/Dialog/DialogFrame.d.ts +5 -6
  74. package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -1
  75. package/dist/esm/components/Dialog/DialogFrame.js +26 -103
  76. package/dist/esm/components/Dialog/DialogFrame.js.map +1 -1
  77. package/dist/esm/components/Dialog/usePropWarning.d.ts +13 -0
  78. package/dist/esm/components/Dialog/usePropWarning.d.ts.map +1 -0
  79. package/dist/esm/components/Dialog/usePropWarning.js +26 -0
  80. package/dist/esm/components/Dialog/usePropWarning.js.map +1 -0
  81. package/dist/esm/components/ModalRoot/ModalRoot.d.ts +10 -0
  82. package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
  83. package/dist/esm/components/ModalRoot/ModalRoot.js +32 -8
  84. package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
  85. package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -2
  86. package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
  87. package/dist/esm/components/ModalRoot/modalRootStack.js +18 -4
  88. package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
  89. package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts +9 -1
  90. package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
  91. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +13 -12
  92. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  93. package/dist/esm/components/SelectDate/Styles.d.ts +1 -1
  94. package/dist/esm/components/SelectDate/Styles.d.ts.map +1 -1
  95. package/dist/esm/components/Sheet/Sheet.d.ts +6 -1
  96. package/dist/esm/components/Sheet/Sheet.d.ts.map +1 -1
  97. package/dist/esm/components/Sheet/Sheet.js +17 -5
  98. package/dist/esm/components/Sheet/Sheet.js.map +1 -1
  99. package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -1
  100. package/dist/esm/components/Sheet/useHostAboveOpenModal.js +9 -2
  101. package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -1
  102. package/dist/esm/components/Wizard/Wizard.d.ts +1 -1
  103. package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
  104. package/dist/esm/components/Wizard/Wizard.js +1 -0
  105. package/dist/esm/components/Wizard/Wizard.js.map +1 -1
  106. package/dist/esm/presentation/listView/columns.d.ts +20 -7
  107. package/dist/esm/presentation/listView/columns.d.ts.map +1 -1
  108. package/dist/esm/presentation/listView/columns.js +538 -166
  109. package/dist/esm/presentation/listView/columns.js.map +1 -1
  110. package/dist/esm/presentation/myWork/MyWorkListSettingsDialog.js +1 -1
  111. package/dist/esm/presentation/myWork/MyWorkListSettingsDialog.js.map +1 -1
  112. package/dist/esm/presentation/reports/availabilityExport.js +1 -1
  113. package/dist/esm/presentation/reports/availabilityExport.js.map +1 -1
  114. package/dist/esm/presentation/selfHostedRedesign/parts.js +6 -6
  115. package/dist/esm/presentation/selfHostedRedesign/parts.js.map +1 -1
  116. package/dist/esm/presentation/shared/LinkingCommandsButton.js +1 -1
  117. package/dist/esm/presentation/shared/LinkingCommandsButton.js.map +1 -1
  118. package/dist/esm/presentation/shared/MessageDialog.js +1 -1
  119. package/dist/esm/presentation/shared/MessageDialog.js.map +1 -1
  120. package/dist/esm/presentation/shared/MessageFeedback.js +1 -1
  121. package/dist/esm/presentation/shared/MessageFeedback.js.map +1 -1
  122. package/dist/esm/presentation/shared/ProjectOptionsMenu.js +1 -1
  123. package/dist/esm/presentation/shared/ProjectOptionsMenu.js.map +1 -1
  124. package/dist/esm/presentation/shared/SourceCodeSection.js +2 -2
  125. package/dist/esm/presentation/shared/SourceCodeSection.js.map +1 -1
  126. package/dist/esm/presentation/shared/UserDetailsDialog.js +1 -1
  127. package/dist/esm/presentation/shared/UserDetailsDialog.js.map +1 -1
  128. package/dist/esm/presentation/shared/WebhookLogsDialog.js +1 -1
  129. package/dist/esm/presentation/shared/WebhookLogsDialog.js.map +1 -1
  130. package/dist/esm/presentation/shared/selfHostedSettings.js +1 -1
  131. package/dist/esm/presentation/shared/selfHostedSettings.js.map +1 -1
  132. package/dist/esm/presentation/shared/selfHostedUpgrade.js +3 -3
  133. package/dist/esm/presentation/shared/selfHostedUpgrade.js.map +1 -1
  134. package/dist/esm/presentation/shared/systemSettingsDialog.d.ts.map +1 -1
  135. package/dist/esm/presentation/shared/systemSettingsDialog.js +1 -1
  136. package/dist/esm/presentation/shared/systemSettingsDialog.js.map +1 -1
  137. package/dist/esm/presentation/whiteboard/peopleMenu.js +1 -1
  138. package/dist/esm/presentation/whiteboard/peopleMenu.js.map +1 -1
  139. package/dist/esm/presentation/whiteboard/projectElements.js +1 -1
  140. package/dist/esm/presentation/whiteboard/projectElements.js.map +1 -1
  141. package/dist/index.js +368 -364
  142. package/dist/index.js.map +1 -1
  143. package/dist/index.min.js +1 -1
  144. package/dist/index.min.js.map +1 -1
  145. package/package.json +1 -1
@@ -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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AAGlG,WAAW,CAAC,MAAM;IACrC,IAAI,CAACmB,IAAI,EAAE;MACToD,WAAW,CAAC,CAAC;IACf;EACF,CAAC,EAAE,CAACpD,IAAI,EAAEoD,WAAW,CAAC,CAAC;EAEvB,IAAI,CAACjC,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,oBACExC,KAAA,CAAAqG,aAAA,CAACvF,MAAM,qBACLd,KAAA,CAAAqG,aAAA,CAAC9F,YAAY;IACX+F,YAAY;IACZlF,GAAG,EAAE6B,SAAU;IACfsD,OAAO,EAAE,CAACzE,iBAAkB;IAC5B0E,WAAW;EAAA,gBAEXxG,KAAA,CAAAqG,aAAA,CAACxF,eAAe,EAAA4F,QAAA,KACVrE,IAAI;IACRJ,SAAS,EAAExB,UAAU,CAAC,cAAc,EAAEwB,SAAS,CAAE;IACjD,cAAYX,IAAI,GAAG,MAAM,GAAG,SAAU;IACtCY,aAAa,EAAE8D,iBAAkB;IACjC7D,OAAO,EAAE+D,WAAY;IACrB9D,SAAS,EAAE6C;EAAc,iBAEzBhF,KAAA,CAAAqG,aAAA,CAACtF,uBAAuB;IAAC2F,KAAK,EAAEnD;EAAe,GAC5C,OAAOxB,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC;IAAE4E,EAAE,EAAEtF,IAAI;IAAEuF,QAAQ,EAAER;EAAa,CAAC,CAAC,GAC9CrE,QACmB,CAAC,eAC1B/B,KAAA,CAAAqG,aAAA;IAAKjF,GAAG,EAAEkC,cAAe;IAACtB,SAAS,EAAC;EAAwB,CAAE,CAC/C,CACL,CACR,CAAC;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 </Rem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AAY;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,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,QAAO,MAAM,GAAG,SACjB,CAAC;AAE9B,gHAAgH;AAChH,eAAO,MAAM,uBAAuB,GAClC,IAAI,MAAM,EACV,UAAU,IAAI,KACb,WAAW,GAAG,IAEQ,CAAC;AAE1B,eAAO,MAAM,qBAAqB,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"}
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;AAiBD,eAAO,MAAM,aAAa,GACxB,aAAa,WAAW,GAAG,IAAI,EAC/B,aAAa,mBAAmB,EAChC,yBAAuB,KACtB,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,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,QAAO,MAAM,GAAG,SACjB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,IAAI,MAAM,EACV,UAAU,IAAI,KACb,WAAW,GAAG,IAMc,CAAC;AAEhC,kGAAkG;AAClG,eAAO,MAAM,gCAAgC,QAAO,MAAM,GAAG,SACH,CAAC;AAE3D,eAAO,MAAM,qBAAqB,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,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,GAAGA,CAC3BC,WAA+B,EAC/BC,UAAgC,KACrB;EACXP,MAAM,IAAI,CAAC;EACXD,KAAK,GAAG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E;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,IAAW;EAChD,IAAI,CAACV,KAAK,CAACa,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACJ,EAAE,KAAKA,EAAE,CAAC,EAAE;IAC3C;EACF;EAEAV,KAAK,GAAGA,KAAK,CAACe,MAAM,CAAED,KAAK,IAAKA,KAAK,CAACJ,EAAE,KAAKA,EAAE,CAAC;EAChDP,MAAM,CAAC,CAAC;AACV,CAAC;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AC;IACtD;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import React, { HTMLAttributes } from "react";
1
+ import React, { HTMLAttributes, MouseEvent } from "react";
2
2
  import { DialogSize } from "../Dialog/Styles";
3
3
  export interface ObjectFormModalProps extends HTMLAttributes<HTMLDivElement> {
4
4
  open?: boolean;
@@ -8,8 +8,16 @@ export interface ObjectFormModalProps extends HTMLAttributes<HTMLDivElement> {
8
8
  /** Width step, the same scale as Dialog. Every step is a max-width. */
9
9
  size?: DialogSize;
10
10
  /** A click outside keeps the modal open by default, so a form with text in it never closes by accident. */
11
+ dismissOnBackdropClick?: boolean;
12
+ /** A click outside that did not close the modal, because dismissOnBackdropClick is off. */
13
+ onBackdropClickBlocked?: (event?: MouseEvent<HTMLDialogElement>) => void;
14
+ /** @deprecated Use dismissOnBackdropClick. Still works, with a warning in development, and will be removed. */
11
15
  enableBackgroundClick?: boolean;
12
16
  disableCloseOnEsc?: boolean;
17
+ /**
18
+ * @deprecated The modal is a native <dialog>, which keeps the focus inside without a focus lock. The prop is
19
+ * ignored, with a warning in development, and will be removed.
20
+ */
13
21
  disableFocusLock?: boolean;
14
22
  /** The surface becomes a column, so one part of the content can scroll in place of the modal. */
15
23
  fill?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectFormModal.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectFormModal/ObjectFormModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAI3D,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC1E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,UAAU,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UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,eAAO,MAAM,eAAe;;wCA8F3B,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 = ["children", "open", "onClose", "label", "size", "enableBackgroundClick", "disableCloseOnEsc", "disableFocusLock", "fill", "closeButton", "closeLabel", "className"];
3
+ const _excluded = ["children", "open", "onClose", "label", "size", "dismissOnBackdropClick", "onBackdropClickBlocked", "enableBackgroundClick", "disableCloseOnEsc", "disableFocusLock", "fill", "closeButton", "closeLabel", "className"];
4
4
  import React, { forwardRef, useCallback, useState } from "react";
5
5
  import classnames from "classnames";
6
6
  import { StyledObjectFormModal, StyledObjectFormModalClose } from "./Styles";
@@ -9,13 +9,14 @@ import { layers } from "../../utils";
9
9
  import { DialogFrame } from "../Dialog/DialogFrame";
10
10
  import { dialogSizes } from "../Dialog/Styles";
11
11
  import { useFluidHeightAnimation } from "../Dialog/useFluidHeightAnimation";
12
+ import { usePropWarning } from "../Dialog/usePropWarning";
12
13
  import { CancelCrossIcon } from "../Icons";
13
- // A sheet puts its content on a lower layer. The form modal always covers the page, the menu and the sheet.
14
+ // Menus and pickers opened from the form keep the layer they had before the form became a native modal.
14
15
  const MODAL_LAYER = {
15
16
  zIndex: layers.skyscraper
16
17
  };
17
18
  export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
18
- var _dialogSizes$size;
19
+ var _ref2, _dialogSizes$size;
19
20
  let children = _ref.children,
20
21
  _ref$open = _ref.open,
21
22
  open = _ref$open === void 0 ? false : _ref$open,
@@ -23,12 +24,12 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
23
24
  label = _ref.label,
24
25
  _ref$size = _ref.size,
25
26
  size = _ref$size === void 0 ? "s" : _ref$size,
26
- _ref$enableBackground = _ref.enableBackgroundClick,
27
- enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
27
+ dismissOnBackdropClick = _ref.dismissOnBackdropClick,
28
+ onBackdropClickBlocked = _ref.onBackdropClickBlocked,
29
+ enableBackgroundClick = _ref.enableBackgroundClick,
28
30
  _ref$disableCloseOnEs = _ref.disableCloseOnEsc,
29
31
  disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
30
- _ref$disableFocusLock = _ref.disableFocusLock,
31
- disableFocusLock = _ref$disableFocusLock === void 0 ? false : _ref$disableFocusLock,
32
+ disableFocusLock = _ref.disableFocusLock,
32
33
  _ref$fill = _ref.fill,
33
34
  fill = _ref$fill === void 0 ? false : _ref$fill,
34
35
  _ref$closeButton = _ref.closeButton,
@@ -49,19 +50,19 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
49
50
  }
50
51
  }, [ref]);
51
52
  useFluidHeightAnimation(surfaceNode, true);
53
+ usePropWarning("ObjectFormModal", "enableBackgroundClick", enableBackgroundClick, "deprecated", "Use dismissOnBackdropClick.");
54
+ usePropWarning("ObjectFormModal", "disableFocusLock", disableFocusLock, "removed", "The modal is a native dialog now, so remove it.");
52
55
  return /*#__PURE__*/React.createElement(LayerContextProvider, {
53
56
  value: MODAL_LAYER
54
57
  }, /*#__PURE__*/React.createElement(DialogFrame, {
55
58
  open: open,
56
59
  onClose: onClose,
57
- enableBackgroundClick: enableBackgroundClick,
60
+ dismissOnBackdropClick: (_ref2 = dismissOnBackdropClick != null ? dismissOnBackdropClick : enableBackgroundClick) != null ? _ref2 : false,
61
+ onBackdropClickBlocked: onBackdropClickBlocked,
58
62
  disableCloseOnEsc: disableCloseOnEsc,
59
- disableFocusLock: disableFocusLock,
63
+ "aria-label": label,
60
64
  surface: /*#__PURE__*/React.createElement(StyledObjectFormModal, _extends({}, rest, {
61
65
  ref: setSurface,
62
- role: "dialog",
63
- "aria-modal": "true",
64
- "aria-label": label,
65
66
  $maxWidth: (_dialogSizes$size = dialogSizes[size]) != null ? _dialogSizes$size : dialogSizes.s,
66
67
  $fill: fill || closeButton,
67
68
  $closeButton: closeButton,
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectFormModal.js","names":["React","forwardRef","useCallback","useState","classnames","StyledObjectFormModal","StyledObjectFormModalClose","LayerContextProvider","layers","DialogFrame","dialogSizes","useFluidHeightAnimation","CancelCrossIcon","MODAL_LAYER","zIndex","skyscraper","ObjectFormModal","_ref","ref","_dialogSizes$size","children","_ref$open","open","onClose","label","_ref$size","size","_ref$enableBackground","enableBackgroundClick","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableFocusLock","disableFocusLock","_ref$fill","fill","_ref$closeButton","closeButton","_ref$closeLabel","closeLabel","className","rest","_objectWithoutPropertiesLoose","_excluded","_useState","surfaceNode","setSurfaceNode","setSurface","node","current","createElement","value","surface","_extends","role","$maxWidth","s","$fill","$closeButton","type","onClick","displayName"],"sources":["../../../../src/components/ObjectFormModal/ObjectFormModal.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n PropsWithChildren,\n useCallback,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { StyledObjectFormModal, StyledObjectFormModalClose } from \"./Styles\";\nimport { LayerContextProvider } from \"../../helpers\";\nimport { layers } from \"../../utils\";\nimport { DialogFrame } from \"../Dialog/DialogFrame\";\nimport { DialogSize, dialogSizes } from \"../Dialog/Styles\";\nimport { useFluidHeightAnimation } from \"../Dialog/useFluidHeightAnimation\";\nimport { CancelCrossIcon } from \"../Icons\";\n\nexport interface ObjectFormModalProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n /** Accessible name of the modal, for example \"New Event\". The modal draws no title. */\n label: string;\n /** Width step, the same scale as Dialog. Every step is a max-width. */\n size?: DialogSize;\n /** A click outside keeps the modal open by default, so a form with text in it never closes by accident. */\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n disableFocusLock?: boolean;\n /** The surface becomes a column, so one part of the content can scroll in place of the modal. */\n fill?: boolean;\n /** A close button beside the top right corner. It turns `fill` on. */\n closeButton?: boolean;\n closeLabel?: string;\n className?: string;\n}\n\n// A sheet puts its content on a lower layer. The form modal always covers the page, the menu and the sheet.\nconst MODAL_LAYER = { zIndex: layers.skyscraper };\n\nexport const ObjectFormModal = forwardRef<\n HTMLDivElement,\n PropsWithChildren<ObjectFormModalProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n label,\n size = \"s\",\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n disableFocusLock = false,\n fill = false,\n closeButton = false,\n closeLabel = \"Close\",\n className,\n ...rest\n },\n ref\n ) => {\n const [surfaceNode, setSurfaceNode] = useState<HTMLDivElement | null>(null);\n\n const setSurface = useCallback(\n (node: HTMLDivElement | null) => {\n setSurfaceNode(node);\n\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n },\n [ref]\n );\n\n useFluidHeightAnimation(surfaceNode, true);\n\n return (\n <LayerContextProvider value={MODAL_LAYER}>\n <DialogFrame\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n disableFocusLock={disableFocusLock}\n surface={\n <StyledObjectFormModal\n {...rest}\n ref={setSurface}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={label}\n $maxWidth={dialogSizes[size] ?? dialogSizes.s}\n $fill={fill || closeButton}\n $closeButton={closeButton}\n className={classnames(\"c-object-form-modal\", className)}\n >\n {closeButton ? (\n <StyledObjectFormModalClose\n type=\"button\"\n className=\"c-object-form-modal-close\"\n aria-label={closeLabel}\n onClick={onClose}\n >\n <CancelCrossIcon />\n </StyledObjectFormModalClose>\n ) : null}\n {children}\n </StyledObjectFormModal>\n }\n />\n </LayerContextProvider>\n );\n }\n);\n\nObjectFormModal.displayName = \"ObjectFormModal\";\n"],"mappings":";;;AAAA,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,IAAI,CAAC,YAAAP,iBAAA,GAAIT,WAAW,CAAC6C,CAAE;MAC9CC,KAAK,EAAEtB,IAAI,IAAIE,WAAY;MAC3BqB,YAAY,EAAErB,WAAY;MAC1BG,SAAS,EAAEnC,UAAU,CAAC,qBAAqB,EAAEmC,SAAS;IAAE,IAEvDH,WAAW,gBACVpC,KAAA,CAAAiD,aAAA,CAAC3C,0BAA0B;MACzBoD,IAAI,EAAC,QAAQ;MACbnB,SAAS,EAAC,2BAA2B;MACrC,cAAYD,UAAW;MACvBqB,OAAO,EAAEpC;IAAQ,gBAEjBvB,KAAA,CAAAiD,aAAA,CAACrC,eAAe,MAAE,CACQ,CAAC,GAC3B,IAAI,EACPQ,QACoB;EACxB,CACF,CACmB,CAAC;AAE3B,CACF,CAAC;AAEDJ,eAAe,CAAC4C,WAAW,GAAG,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"ObjectFormModal.js","names":["React","forwardRef","useCallback","useState","classnames","StyledObjectFormModal","StyledObjectFormModalClose","LayerContextProvider","layers","DialogFrame","dialogSizes","useFluidHeightAnimation","usePropWarning","CancelCrossIcon","MODAL_LAYER","zIndex","skyscraper","ObjectFormModal","_ref","ref","_ref2","_dialogSizes$size","children","_ref$open","open","onClose","label","_ref$size","size","dismissOnBackdropClick","onBackdropClickBlocked","enableBackgroundClick","_ref$disableCloseOnEs","disableCloseOnEsc","disableFocusLock","_ref$fill","fill","_ref$closeButton","closeButton","_ref$closeLabel","closeLabel","className","rest","_objectWithoutPropertiesLoose","_excluded","_useState","surfaceNode","setSurfaceNode","setSurface","node","current","createElement","value","surface","_extends","$maxWidth","s","$fill","$closeButton","type","onClick","displayName"],"sources":["../../../../src/components/ObjectFormModal/ObjectFormModal.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n MouseEvent,\n PropsWithChildren,\n useCallback,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { StyledObjectFormModal, StyledObjectFormModalClose } from \"./Styles\";\nimport { LayerContextProvider } from \"../../helpers\";\nimport { layers } from \"../../utils\";\nimport { DialogFrame } from \"../Dialog/DialogFrame\";\nimport { DialogSize, dialogSizes } from \"../Dialog/Styles\";\nimport { useFluidHeightAnimation } from \"../Dialog/useFluidHeightAnimation\";\nimport { usePropWarning } from \"../Dialog/usePropWarning\";\nimport { CancelCrossIcon } from \"../Icons\";\n\nexport interface ObjectFormModalProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n /** Accessible name of the modal, for example \"New Event\". The modal draws no title. */\n label: string;\n /** Width step, the same scale as Dialog. Every step is a max-width. */\n size?: DialogSize;\n /** A click outside keeps the modal open by default, so a form with text in it never closes by accident. */\n dismissOnBackdropClick?: boolean;\n /** A click outside that did not close the modal, because dismissOnBackdropClick is off. */\n onBackdropClickBlocked?: (event?: MouseEvent<HTMLDialogElement>) => void;\n /** @deprecated Use dismissOnBackdropClick. Still works, with a warning in development, and will be removed. */\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n /**\n * @deprecated The modal is a native <dialog>, which keeps the focus inside without a focus lock. The prop is\n * ignored, with a warning in development, and will be removed.\n */\n disableFocusLock?: boolean;\n /** The surface becomes a column, so one part of the content can scroll in place of the modal. */\n fill?: boolean;\n /** A close button beside the top right corner. It turns `fill` on. */\n closeButton?: boolean;\n closeLabel?: string;\n className?: string;\n}\n\n// Menus and pickers opened from the form keep the layer they had before the form became a native modal.\nconst MODAL_LAYER = { zIndex: layers.skyscraper };\n\nexport const ObjectFormModal = forwardRef<\n HTMLDivElement,\n PropsWithChildren<ObjectFormModalProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n label,\n size = \"s\",\n dismissOnBackdropClick,\n onBackdropClickBlocked,\n enableBackgroundClick,\n disableCloseOnEsc = false,\n disableFocusLock,\n fill = false,\n closeButton = false,\n closeLabel = \"Close\",\n className,\n ...rest\n },\n ref\n ) => {\n const [surfaceNode, setSurfaceNode] = useState<HTMLDivElement | null>(null);\n\n const setSurface = useCallback(\n (node: HTMLDivElement | null) => {\n setSurfaceNode(node);\n\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n },\n [ref]\n );\n\n useFluidHeightAnimation(surfaceNode, true);\n\n usePropWarning(\n \"ObjectFormModal\",\n \"enableBackgroundClick\",\n enableBackgroundClick,\n \"deprecated\",\n \"Use dismissOnBackdropClick.\"\n );\n\n usePropWarning(\n \"ObjectFormModal\",\n \"disableFocusLock\",\n disableFocusLock,\n \"removed\",\n \"The modal is a native dialog now, so remove it.\"\n );\n\n return (\n <LayerContextProvider value={MODAL_LAYER}>\n <DialogFrame\n open={open}\n onClose={onClose}\n dismissOnBackdropClick={\n dismissOnBackdropClick ?? enableBackgroundClick ?? false\n }\n onBackdropClickBlocked={onBackdropClickBlocked}\n disableCloseOnEsc={disableCloseOnEsc}\n aria-label={label}\n surface={\n <StyledObjectFormModal\n {...rest}\n ref={setSurface}\n $maxWidth={dialogSizes[size] ?? dialogSizes.s}\n $fill={fill || closeButton}\n $closeButton={closeButton}\n className={classnames(\"c-object-form-modal\", className)}\n >\n {closeButton ? (\n <StyledObjectFormModalClose\n type=\"button\"\n className=\"c-object-form-modal-close\"\n aria-label={closeLabel}\n onClick={onClose}\n >\n <CancelCrossIcon />\n </StyledObjectFormModalClose>\n ) : null}\n {children}\n </StyledObjectFormModal>\n }\n />\n </LayerContextProvider>\n );\n }\n);\n\nObjectFormModal.displayName = \"ObjectFormModal\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAIVC,WAAW,EACXC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,UAAU;AAC5E,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAAqBC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,uBA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CC,KAAK,EAAErB,IAAI,IAAIE,WAAY;MAC3BoB,YAAY,EAAEpB,WAAY;MAC1BG,SAAS,EAAErC,UAAU,CAAC,qBAAqB,EAAEqC,SAAS;IAAE,IAEvDH,WAAW,gBACVtC,KAAA,CAAAmD,aAAA,CAAC7C,0BAA0B;MACzBqD,IAAI,EAAC,QAAQ;MACblB,SAAS,EAAC,2BAA2B;MACrC,cAAYD,UAAW;MACvBoB,OAAO,EAAEnC;IAAQ,gBAEjBzB,KAAA,CAAAmD,aAAA,CAACtC,eAAe,MAAE,CACQ,CAAC,GAC3B,IAAI,EACPS,QACoB;EACxB,CACF,CACmB,CAAC;AAE3B,CACF,CAAC;AAEDL,eAAe,CAAC4C,WAAW,GAAG,iBAAiB","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  export declare const StyledSelectDate: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export declare const StyledSelectDateButton: import("styled-components").StyledComponent<"button", any, {}, never>;
3
- export declare const StyledConfirmDialog: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("..").ConfirmDialogProps & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
3
+ export declare const StyledConfirmDialog: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("..").ConfirmDialogProps & import("react").RefAttributes<HTMLDialogElement>>, any, {}, never>;
4
4
  export declare const StyledSelectDateDatePicker: import("styled-components").StyledComponent<"div", any, {}, never>;
5
5
  export declare const StyledSelectDateFooter: import("styled-components").StyledComponent<"div", any, {
6
6
  $mode?: "atomic" | "instant";
@@ -1 +1 @@
1
- {"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectDate/Styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB,oEAG5B,CAAC;AAIF,eAAO,MAAM,sBAAsB,uEAmBlC,CAAC;AAIF,eAAO,MAAM,mBAAmB,yLAkB/B,CAAC;AAIF,eAAO,MAAM,0BAA0B,oEAGtC,CAAC;AAIF,eAAO,MAAM,sBAAsB;YACzB,QAAQ,GAAG,SAAS;SAU7B,CAAC;AAIF,eAAO,MAAM,uBAAuB,oEAEnC,CAAC;AAIF,eAAO,MAAM,gBAAgB;;sEAE5B,CAAC;AAIF,eAAO,MAAM,iBAAiB;;sEAE7B,CAAC;AAIF,eAAO,MAAM,wBAAwB;;sEAEpC,CAAC;AAIF,eAAO,MAAM,mBAAmB,oEAW/B,CAAC"}
1
+ {"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectDate/Styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB,oEAG5B,CAAC;AAIF,eAAO,MAAM,sBAAsB,uEAmBlC,CAAC;AAIF,eAAO,MAAM,mBAAmB,4LAkB/B,CAAC;AAIF,eAAO,MAAM,0BAA0B,oEAGtC,CAAC;AAIF,eAAO,MAAM,sBAAsB;YACzB,QAAQ,GAAG,SAAS;SAU7B,CAAC;AAIF,eAAO,MAAM,uBAAuB,oEAEnC,CAAC;AAIF,eAAO,MAAM,gBAAgB;;sEAE5B,CAAC;AAIF,eAAO,MAAM,iBAAiB;;sEAE7B,CAAC;AAIF,eAAO,MAAM,wBAAwB;;sEAEpC,CAAC;AAIF,eAAO,MAAM,mBAAmB,oEAW/B,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { CSSProperties } from "react";
1
+ import React, { CSSProperties, MouseEvent } from "react";
2
2
  interface ControlProps {
3
3
  onClick: () => void;
4
4
  icon: React.ReactElement;
@@ -22,6 +22,11 @@ interface ISheet {
22
22
  disableBackgroundColor?: boolean;
23
23
  bodyStyle?: CSSProperties;
24
24
  bodyClassName?: string;
25
+ /** A click on the backdrop closes the sheet. On by default. */
26
+ dismissOnBackdropClick?: boolean;
27
+ /** A click on the backdrop that did not close the sheet, because dismissOnBackdropClick is off. */
28
+ onBackdropClickBlocked?: (event: MouseEvent<HTMLDivElement>) => void;
29
+ /** @deprecated Use dismissOnBackdropClick={false}. Still works, with a warning in development, and will be removed. */
25
30
  disableBackgroundClick?: boolean;
26
31
  }
27
32
  export interface SheetMethods {
@@ -1 +1 @@
1
- {"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,aAAa,EAId,MAAM,OAAO,CAAC;AA8Ff,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,KAAK,oHA+MjB,CAAC"}
1
+ {"version":3,"file":"Sheet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MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,KAAK,oHAoOjB,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "onClose", "controls", "open", "animation", "position", "mode", "maxWidth", "surface", "disableFocusLock", "disableScrollLock", "disableBackgroundColor", "bodyStyle", "bodyClassName", "disableBackgroundClick"];
3
+ const _excluded = ["children", "onClose", "controls", "open", "animation", "position", "mode", "maxWidth", "surface", "disableFocusLock", "disableScrollLock", "disableBackgroundColor", "bodyStyle", "bodyClassName", "dismissOnBackdropClick", "onBackdropClickBlocked", "disableBackgroundClick"];
4
4
  import React, { useCallback, useEffect, forwardRef, useState, useImperativeHandle, useRef } from "react";
5
5
  import classnames from "classnames";
6
6
  import { StyledAnimatedSpan, StyledCssTransition, StyledHeader, StyledIconsWrapperSmall, StyledListSeparator, StyledSheetIcons, StyledSheetWrapper, SHEET_ENTER_MS, SHEET_EXIT_MS, StyledSheetSurface, StyledSheetWrapperPaper } from "./Styles";
7
7
  import { PortalContainerProvider, usePortalContainer } from "../../helpers";
8
+ import { usePropWarning } from "../Dialog/usePropWarning";
8
9
  import { IconButton } from "../IconButton";
9
10
  import { Overlay } from "../Overlay";
10
11
  import { Tooltip } from "../Tooltip";
@@ -93,8 +94,9 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
93
94
  disableBackgroundColor = _ref$disableBackgroun === void 0 ? false : _ref$disableBackgroun,
94
95
  bodyStyle = _ref.bodyStyle,
95
96
  bodyClassName = _ref.bodyClassName,
96
- _ref$disableBackgroun2 = _ref.disableBackgroundClick,
97
- disableBackgroundClick = _ref$disableBackgroun2 === void 0 ? false : _ref$disableBackgroun2,
97
+ dismissOnBackdropClick = _ref.dismissOnBackdropClick,
98
+ onBackdropClickBlocked = _ref.onBackdropClickBlocked,
99
+ disableBackgroundClick = _ref.disableBackgroundClick,
98
100
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
99
101
  const _useState = useState(defaultOpen),
100
102
  open = _useState[0],
@@ -127,12 +129,22 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
127
129
  const handleOverlayExit = useCallback(() => {
128
130
  setOverlayEntered(false);
129
131
  }, []);
132
+ usePropWarning("Sheet", "disableBackgroundClick", disableBackgroundClick, "deprecated", "Use dismissOnBackdropClick={false}.");
133
+ const closesOnBackdropClick = dismissOnBackdropClick != null ? dismissOnBackdropClick : !disableBackgroundClick;
134
+
135
+ // Over a native dialog the overlay takes clicks while it fades out too, and a sheet that is closing has nothing
136
+ // left to block.
130
137
  const handleBackgroundClick = useCallback(event => {
131
- if (!disableBackgroundClick) {
138
+ if (!open) {
139
+ return;
140
+ }
141
+ if (closesOnBackdropClick) {
132
142
  event.preventDefault();
133
143
  handleClose();
144
+ } else {
145
+ onBackdropClickBlocked == null || onBackdropClickBlocked(event);
134
146
  }
135
- }, [disableBackgroundClick, handleClose]);
147
+ }, [open, closesOnBackdropClick, handleClose, onBackdropClickBlocked]);
136
148
  useImperativeHandle(ref, () => ({
137
149
  close: handleClose
138
150
  }));