@activecollab/components 2.0.542 → 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.
- package/dist/cjs/components/CommandPalette/CommandPalette.js +3 -1
- package/dist/cjs/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js +4 -4
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.js +3 -3
- package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogContext.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogFrame.js +21 -100
- package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -1
- package/dist/cjs/components/Dialog/useRemovedPropWarning.js +22 -0
- package/dist/cjs/components/Dialog/useRemovedPropWarning.js.map +1 -0
- package/dist/cjs/components/ModalRoot/ModalRoot.js +32 -8
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +18 -4
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +5 -7
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +7 -0
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -1
- package/dist/cjs/components/Wizard/Wizard.js +1 -0
- package/dist/cjs/components/Wizard/Wizard.js.map +1 -1
- package/dist/cjs/presentation/listView/columns.js +622 -184
- package/dist/cjs/presentation/listView/columns.js.map +1 -1
- package/dist/esm/components/CommandPalette/CommandPalette.d.ts +2 -2
- package/dist/esm/components/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/esm/components/CommandPalette/CommandPalette.js +3 -1
- package/dist/esm/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +5 -2
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +4 -4
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/esm/components/DatePicker/Styles.d.ts +1 -1
- package/dist/esm/components/DatePicker/Styles.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.d.ts +15 -3
- package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +3 -3
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/DialogContext.d.ts +2 -2
- package/dist/esm/components/Dialog/DialogContext.d.ts.map +1 -1
- package/dist/esm/components/Dialog/DialogContext.js.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.d.ts +5 -6
- package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.js +23 -100
- package/dist/esm/components/Dialog/DialogFrame.js.map +1 -1
- package/dist/esm/components/Dialog/useRemovedPropWarning.d.ts +3 -0
- package/dist/esm/components/Dialog/useRemovedPropWarning.d.ts.map +1 -0
- package/dist/esm/components/Dialog/useRemovedPropWarning.js +16 -0
- package/dist/esm/components/Dialog/useRemovedPropWarning.js.map +1 -0
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts +10 -0
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +32 -8
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -2
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +18 -4
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts +4 -0
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +5 -7
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/esm/components/SelectDate/Styles.d.ts +1 -1
- package/dist/esm/components/SelectDate/Styles.d.ts.map +1 -1
- package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -1
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js +9 -2
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/components/Wizard/Wizard.js +1 -0
- package/dist/esm/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/presentation/listView/columns.d.ts +20 -7
- package/dist/esm/presentation/listView/columns.d.ts.map +1 -1
- package/dist/esm/presentation/listView/columns.js +538 -166
- package/dist/esm/presentation/listView/columns.js.map +1 -1
- package/dist/index.js +326 -346
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
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,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,sBAAsB,EAC9B,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAClC,IAAI,CAAC;IACV,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iHAAiH;IACjH,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,UAAU,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,SAAS,
|
|
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,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,sBAAsB,EAC9B,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAClC,IAAI,CAAC;IACV,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,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
|
-
(
|
|
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
|
-
|
|
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,iBAA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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 </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,c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CAACb,SAAS,CACZ,CAAC;EAED,MAAMsE,YAAY,GAAG3G,WAAW,CAAC,MAAM;IACrC,IAAI,CAACmB,IAAI,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
|
-
/**
|
|
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;
|
|
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
|
-
/**
|
|
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
|
|
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;AAED,OAAO,MAAMa,cAAc,GAAIN,EAAU;EAAA,IAAAO,MAAA;EAAA,OACvC,EAAAA,MAAA,GAAAjB,KAAK,CAACA,KAAK,CAACkB,MAAM,GAAG,CAAC,CAAC,qBAAv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CAACe,MAAM,CAAED,KAAK,IAAKA,KAAK,CAACL,eAAe,CAAC,CAACgB,GAAG,CAAC,CAAC,qBAApDO,kBAAA,CAAsDtB,EAAE;AAAA;AAE1D,OAAO,MAAMuB,qBAAqB,GAAI5B,QAAkB,IAAmB;EACzEP,SAAS,CAACoC,GAAG,CAAC7B,QAAQ,CAAC;EAEvB,OAAO,MAAY;IACjBP,SAAS,CAACqC,MAAM,CAAC9B,QAAQ,CAAC;EAC5B,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAM+B,sBAAsB,GAAGA,CAAA,KAAelC,WAAW,GAAG,CAAC;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMmC,iBAAiB,GAAGA,CAAA,KAAoB;EACnDnC,WAAW,IAAI,CAAC;EAEhB,IAAIA,WAAW,KAAK,CAAC,EAAE;IACrB,CAAC,GAAGF,KAAK,CAAC,CAACsC,OAAO,CAAC,CAAC,CAAClC,OAAO,CAAEU,KAAK;MAAA,IAAAyB,iBAAA;MAAA,QAAAA,iBAAA,GAAKzB,KAAK,CAACN,UAAU,qBAAhB+B,iBAAA,CAAkB5B,OAAO,CAAC,CAAC;IAAA,EAAC;EACtE;EAEA,IAAI6B,QAAQ,GAAG,KAAK;EAEpB,OAAO,MAAM;IACX,IAAIA,QAAQ,EAAE;MACZ;IACF;IAEAA,QAAQ,GAAG,IAAI;IACftC,WAAW,IAAI,CAAC;IAEhB,IAAIA,WAAW,KAAK,CAAC,EAAE;MACrBF,KAAK,CAACI,OAAO,CAAEU,KAAK;QAAA,IAAA2B,kBAAA;QAAA,QAAAA,kBAAA,GAAK3B,KAAK,CAACN,UAAU,qBAAhBiC,kBAAA,CAAkBC,MAAM,CAAC,CAAC;MAAA,EAAC;IACtD;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,10 @@ export interface ObjectFormModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
/** A click outside keeps the modal open by default, so a form with text in it never closes by accident. */
|
|
11
11
|
enableBackgroundClick?: boolean;
|
|
12
12
|
disableCloseOnEsc?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated The modal is a native <dialog>, which keeps the focus inside without a focus lock. The prop is
|
|
15
|
+
* ignored, with a warning in development, and will be removed.
|
|
16
|
+
*/
|
|
13
17
|
disableFocusLock?: boolean;
|
|
14
18
|
/** The surface becomes a column, so one part of the content can scroll in place of the modal. */
|
|
15
19
|
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;
|
|
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;AAK3D,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,CAAC;IAClB,2GAA2G;IAC3G,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iGAAiG;IACjG,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,eAAO,MAAM,eAAe;;wCAgF3B,CAAC"}
|
|
@@ -9,8 +9,9 @@ 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 { useRemovedPropWarning } from "../Dialog/useRemovedPropWarning";
|
|
12
13
|
import { CancelCrossIcon } from "../Icons";
|
|
13
|
-
//
|
|
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
|
};
|
|
@@ -27,8 +28,7 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
27
28
|
enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
|
|
28
29
|
_ref$disableCloseOnEs = _ref.disableCloseOnEsc,
|
|
29
30
|
disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
|
|
30
|
-
|
|
31
|
-
disableFocusLock = _ref$disableFocusLock === void 0 ? false : _ref$disableFocusLock,
|
|
31
|
+
disableFocusLock = _ref.disableFocusLock,
|
|
32
32
|
_ref$fill = _ref.fill,
|
|
33
33
|
fill = _ref$fill === void 0 ? false : _ref$fill,
|
|
34
34
|
_ref$closeButton = _ref.closeButton,
|
|
@@ -49,6 +49,7 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
49
49
|
}
|
|
50
50
|
}, [ref]);
|
|
51
51
|
useFluidHeightAnimation(surfaceNode, true);
|
|
52
|
+
useRemovedPropWarning("ObjectFormModal", "disableFocusLock", disableFocusLock, "The modal is a native dialog now, so remove it.");
|
|
52
53
|
return /*#__PURE__*/React.createElement(LayerContextProvider, {
|
|
53
54
|
value: MODAL_LAYER
|
|
54
55
|
}, /*#__PURE__*/React.createElement(DialogFrame, {
|
|
@@ -56,12 +57,9 @@ export const ObjectFormModal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
56
57
|
onClose: onClose,
|
|
57
58
|
enableBackgroundClick: enableBackgroundClick,
|
|
58
59
|
disableCloseOnEsc: disableCloseOnEsc,
|
|
59
|
-
|
|
60
|
+
"aria-label": label,
|
|
60
61
|
surface: /*#__PURE__*/React.createElement(StyledObjectFormModal, _extends({}, rest, {
|
|
61
62
|
ref: setSurface,
|
|
62
|
-
role: "dialog",
|
|
63
|
-
"aria-modal": "true",
|
|
64
|
-
"aria-label": label,
|
|
65
63
|
$maxWidth: (_dialogSizes$size = dialogSizes[size]) != null ? _dialogSizes$size : dialogSizes.s,
|
|
66
64
|
$fill: fill || closeButton,
|
|
67
65
|
$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","
|
|
1
|
+
{"version":3,"file":"ObjectFormModal.js","names":["React","forwardRef","useCallback","useState","classnames","StyledObjectFormModal","StyledObjectFormModalClose","LayerContextProvider","layers","DialogFrame","dialogSizes","useFluidHeightAnimation","useRemovedPropWarning","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","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 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 { useRemovedPropWarning } from \"../Dialog/useRemovedPropWarning\";\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 /**\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 enableBackgroundClick = false,\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 useRemovedPropWarning(\n \"ObjectFormModal\",\n \"disableFocusLock\",\n disableFocusLock,\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 enableBackgroundClick={enableBackgroundClick}\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,EAGVC,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,uB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,cAAYD,UAAW;MACvBoB,OAAO,EAAElC;IAAQ,gBAEjBxB,KAAA,CAAAiD,aAAA,CAACpC,eAAe,MAAE,CACQ,CAAC,GAC3B,IAAI,EACPQ,QACoB;EACxB,CACF,CACmB,CAAC;AAE3B,CACF,CAAC;AAEDJ,eAAe,CAAC0C,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<
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHostAboveOpenModal.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useHostAboveOpenModal.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,OAAO,EAChB,SAAS,OAAO,KACf;IAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAqC9C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { getTopModalRootId } from "../ModalRoot/modalRootStack";
|
|
1
|
+
import { useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { getTopModalRootId, getTopModalRootIdBelowOpenSheets, subscribeToModalRoots } from "../ModalRoot/modalRootStack";
|
|
3
3
|
import { useModalStackHost } from "../ModalRoot/useModalStackHost";
|
|
4
4
|
const createHost = () => {
|
|
5
5
|
const host = document.createElement("div");
|
|
@@ -23,6 +23,7 @@ export const useHostAboveOpenModal = (visible, enabled) => {
|
|
|
23
23
|
const _useState2 = useState(null),
|
|
24
24
|
captured = _useState2[0],
|
|
25
25
|
setCaptured = _useState2[1];
|
|
26
|
+
const belowOpenSheetsId = useSyncExternalStore(subscribeToModalRoots, getTopModalRootIdBelowOpenSheets);
|
|
26
27
|
|
|
27
28
|
// The modal is picked only as the sheet opens, never on a later render while it stays open.
|
|
28
29
|
if (visible !== wasVisible) {
|
|
@@ -32,6 +33,12 @@ export const useHostAboveOpenModal = (visible, enabled) => {
|
|
|
32
33
|
modalRootId,
|
|
33
34
|
host: createHost()
|
|
34
35
|
});
|
|
36
|
+
} else if (visible && enabled && captured === null && belowOpenSheetsId !== undefined) {
|
|
37
|
+
// A sheet in the page moves into a modal that opens below open sheets. A sheet in a modal already follows it.
|
|
38
|
+
setCaptured({
|
|
39
|
+
modalRootId: belowOpenSheetsId,
|
|
40
|
+
host: createHost()
|
|
41
|
+
});
|
|
35
42
|
}
|
|
36
43
|
const placed = useModalStackHost((_captured$host = captured == null ? void 0 : captured.host) != null ? _captured$host : null, captured == null ? void 0 : captured.modalRootId);
|
|
37
44
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHostAboveOpenModal.js","names":["useState","getTopModalRootId","useModalStackHost","createHost","host","document","createElement","className","useHostAboveOpenModal","visible","enabled","_captured$host","_captured$host2","_useState","wasVisible","setWasVisible","_useState2","captured","setCaptured","modalRootId","undefined","placed","pending"],"sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"sourcesContent":["import { useState } from \"react\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"useHostAboveOpenModal.js","names":["useState","useSyncExternalStore","getTopModalRootId","getTopModalRootIdBelowOpenSheets","subscribeToModalRoots","useModalStackHost","createHost","host","document","createElement","className","useHostAboveOpenModal","visible","enabled","_captured$host","_captured$host2","_useState","wasVisible","setWasVisible","_useState2","captured","setCaptured","belowOpenSheetsId","modalRootId","undefined","placed","pending"],"sources":["../../../../src/components/Sheet/useHostAboveOpenModal.ts"],"sourcesContent":["import { useState, useSyncExternalStore } from \"react\";\n\nimport {\n getTopModalRootId,\n getTopModalRootIdBelowOpenSheets,\n subscribeToModalRoots,\n} from \"../ModalRoot/modalRootStack\";\nimport { useModalStackHost } from \"../ModalRoot/useModalStackHost\";\n\ninterface Captured {\n modalRootId: number;\n host: HTMLElement;\n}\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-sheet-modal-host\";\n\n return host;\n};\n\n/**\n * A sheet that opens while a native modal is open renders into that modal's overlay root, since everything outside\n * the modal is inert. The modal is the one on top as the sheet opens: a modal opened later, such as a confirmation\n * the sheet opens itself, stays above the sheet, also when the sheet renders again while it is open. When that modal\n * closes underneath, the host moves down to the next one opened before the sheet, or to document.body, without\n * remounting the sheet. The host is null when no modal was open, so the sheet renders as it always has, and the\n * sheet waits while pending, until the host is in the page, so its content mounts in the modal and can take focus.\n */\nexport const useHostAboveOpenModal = (\n visible: boolean,\n enabled: boolean\n): { host: HTMLElement | null; pending: boolean } => {\n const [wasVisible, setWasVisible] = useState(false);\n const [captured, setCaptured] = useState<Captured | null>(null);\n\n const belowOpenSheetsId = useSyncExternalStore(\n subscribeToModalRoots,\n getTopModalRootIdBelowOpenSheets\n );\n\n // The modal is picked only as the sheet opens, never on a later render while it stays open.\n if (visible !== wasVisible) {\n setWasVisible(visible);\n\n const modalRootId = visible && enabled ? getTopModalRootId() : undefined;\n\n setCaptured(\n modalRootId === undefined ? null : { modalRootId, host: createHost() }\n );\n } else if (\n visible &&\n enabled &&\n captured === null &&\n belowOpenSheetsId !== undefined\n ) {\n // A sheet in the page moves into a modal that opens below open sheets. A sheet in a modal already follows it.\n setCaptured({ modalRootId: belowOpenSheetsId, host: createHost() });\n }\n\n const placed = useModalStackHost(\n captured?.host ?? null,\n captured?.modalRootId\n );\n\n return {\n host: captured?.host ?? null,\n pending: captured !== null && !placed,\n };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,oBAAoB,QAAQ,OAAO;AAEtD,SACEC,iBAAiB,EACjBC,gCAAgC,EAChCC,qBAAqB,QAChB,6BAA6B;AACpC,SAASC,iBAAiB,QAAQ,gCAAgC;AAOlE,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ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eAAA,GAAEK,QAAQ,oBAARA,QAAQ,CAAEb,IAAI,YAAAQ,eAAA,GAAI,IAAI;IAC5BW,OAAO,EAAEN,QAAQ,KAAK,IAAI,IAAI,CAACK;EACjC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -10,5 +10,5 @@ export interface IWizard {
|
|
|
10
10
|
size?: DialogSize;
|
|
11
11
|
height?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare const Wizard: React.ForwardRefExoticComponent<IWizard & React.RefAttributes<
|
|
13
|
+
export declare const Wizard: React.ForwardRefExoticComponent<IWizard & React.RefAttributes<HTMLDialogElement>>;
|
|
14
14
|
//# sourceMappingURL=Wizard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/components/Wizard/Wizard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/components/Wizard/Wizard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAKZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,mFA2GlB,CAAC"}
|
|
@@ -80,6 +80,7 @@ export const Wizard = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
80
80
|
ref: ref,
|
|
81
81
|
open: open,
|
|
82
82
|
onClose: onClose,
|
|
83
|
+
"aria-label": title,
|
|
83
84
|
disableCloseOnEsc: disableCloseOnEsc,
|
|
84
85
|
className: dialogClassName,
|
|
85
86
|
size: (_activeStepProps$size = activeStepProps.size) != null ? _activeStepProps$size : size,
|