@activecollab/components 2.0.519 → 2.0.520
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/ConfirmDialog/ConfirmDialog.js +6 -2
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.js +136 -18
- 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/DialogTitle.js +24 -2
- package/dist/cjs/components/Dialog/DialogTitle.js.map +1 -1
- package/dist/cjs/components/Dialog/Styles.js +1 -1
- package/dist/cjs/components/Dialog/Styles.js.map +1 -1
- package/dist/cjs/components/DockedCard/useDockedCard.js +3 -2
- package/dist/cjs/components/DockedCard/useDockedCard.js.map +1 -1
- package/dist/cjs/components/ModalRoot/ModalRoot.js +30 -5
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/Window/Window.js +2 -2
- package/dist/cjs/components/Window/Window.js.map +1 -1
- package/dist/cjs/utils/layers.js +12 -4
- package/dist/cjs/utils/layers.js.map +1 -1
- package/dist/cjs/utils/layers.test.js +30 -0
- package/dist/cjs/utils/layers.test.js.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +2 -0
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +6 -2
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.d.ts +5 -3
- package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +125 -19
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/DialogContext.d.ts +4 -0
- 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/DialogTitle.d.ts.map +1 -1
- package/dist/esm/components/Dialog/DialogTitle.js +21 -2
- package/dist/esm/components/Dialog/DialogTitle.js.map +1 -1
- package/dist/esm/components/Dialog/Styles.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Styles.js +1 -1
- package/dist/esm/components/Dialog/Styles.js.map +1 -1
- package/dist/esm/components/DockedCard/useDockedCard.d.ts.map +1 -1
- package/dist/esm/components/DockedCard/useDockedCard.js +2 -1
- package/dist/esm/components/DockedCard/useDockedCard.js.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts +3 -3
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +29 -5
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/Window/Window.js +3 -3
- package/dist/esm/components/Window/Window.js.map +1 -1
- package/dist/esm/utils/layers.d.ts +3 -1
- package/dist/esm/utils/layers.d.ts.map +1 -1
- package/dist/esm/utils/layers.js +11 -3
- package/dist/esm/utils/layers.js.map +1 -1
- package/dist/esm/utils/layers.test.js +30 -0
- package/dist/esm/utils/layers.test.js.map +1 -1
- package/dist/index.js +1071 -711
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { HTMLAttributes, PropsWithChildren } from "react";
|
|
1
|
+
import React, { HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
import { DialogSize } from "./Styles";
|
|
3
3
|
export interface DialogProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
open?: boolean;
|
|
@@ -12,12 +12,14 @@ export interface DialogProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
size?: DialogSize;
|
|
13
13
|
/** "fluid" follows the content. A CSS length ("95%", "600px") pins the height instead. */
|
|
14
14
|
height?: string;
|
|
15
|
+
/** Opens as a native modal <dialog>: the page behind is inert and the dialog sits in the top layer. Temporary opt-in. */
|
|
16
|
+
native?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare const _Dialog: React.ForwardRefExoticComponent<DialogProps & {
|
|
17
|
-
children?:
|
|
19
|
+
children?: ReactNode | undefined;
|
|
18
20
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
19
21
|
export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & {
|
|
20
|
-
children?:
|
|
22
|
+
children?: ReactNode | undefined;
|
|
21
23
|
} & React.RefAttributes<HTMLDivElement>> & {
|
|
22
24
|
Title: {
|
|
23
25
|
({ children, className, disableDefaultHeading, onClose, closeLabel, ...rest }: PropsWithChildren<import("./DialogTitle").DialogTitleProps>): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,EAEd,iBAAiB,EAEjB,SAAS,EAOV,MAAM,OAAO,CAAC;AASf,OAAO,EACL,UAAU,EAIX,MAAM,UAAU,CAAC;AAYlB,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,cAAc,CAAC;IACjE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,CAAC;IACjC,4FAA4F;IAC5F,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yHAAyH;IACzH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA2JD,eAAO,MAAM,OAAO;;wCAyEnB,CAAC;AAKF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;CAKjB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
4
|
-
|
|
3
|
+
const _excluded = ["forwardedRef", "surface", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside"],
|
|
4
|
+
_excluded2 = ["children", "open", "onClose", "className", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "size", "height", "native"];
|
|
5
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
6
|
import classnames from "classnames";
|
|
6
7
|
import { DialogActions } from "./DialogActions";
|
|
7
8
|
import { DialogContent } from "./DialogContent";
|
|
@@ -10,7 +11,9 @@ import { DialogContext } from "./DialogContext";
|
|
|
10
11
|
import { DialogTitle } from "./DialogTitle";
|
|
11
12
|
import { dialogSizes, StyledDialog, StyledDialogViewport } from "./Styles";
|
|
12
13
|
import { useFluidHeightAnimation } from "./useFluidHeightAnimation";
|
|
14
|
+
import useStableId from "../../utils/useStableId";
|
|
13
15
|
import { Modal } from "../Modal";
|
|
16
|
+
import { ModalRoot } from "../ModalRoot";
|
|
14
17
|
import { Fade, FADE_DURATION } from "../Transitions";
|
|
15
18
|
import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
|
|
16
19
|
// Modal only treats a child as a transition when its props already carry `in`, so this element
|
|
@@ -40,13 +43,12 @@ const DialogSurface = _ref => {
|
|
|
40
43
|
}, children)));
|
|
41
44
|
};
|
|
42
45
|
DialogSurface.displayName = "DialogSurface";
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const NativeDialog = _ref2 => {
|
|
47
|
+
let forwardedRef = _ref2.forwardedRef,
|
|
48
|
+
surface = _ref2.surface,
|
|
46
49
|
_ref2$open = _ref2.open,
|
|
47
50
|
open = _ref2$open === void 0 ? false : _ref2$open,
|
|
48
51
|
onClose = _ref2.onClose,
|
|
49
|
-
className = _ref2.className,
|
|
50
52
|
_ref2$enableBackgroun = _ref2.enableBackgroundClick,
|
|
51
53
|
enableBackgroundClick = _ref2$enableBackgroun === void 0 ? false : _ref2$enableBackgroun,
|
|
52
54
|
_ref2$disableCloseOnE = _ref2.disableCloseOnEsc,
|
|
@@ -54,15 +56,124 @@ export const _Dialog = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
54
56
|
_ref2$animate = _ref2.animate,
|
|
55
57
|
animate = _ref2$animate === void 0 ? "slide" : _ref2$animate,
|
|
56
58
|
onClickOutside = _ref2.onClickOutside,
|
|
57
|
-
_ref2$size = _ref2.size,
|
|
58
|
-
size = _ref2$size === void 0 ? "m" : _ref2$size,
|
|
59
|
-
_ref2$height = _ref2.height,
|
|
60
|
-
height = _ref2$height === void 0 ? "fluid" : _ref2$height,
|
|
61
59
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
62
|
-
const _useState = useState(
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
const _useState = useState(open),
|
|
61
|
+
innerOpen = _useState[0],
|
|
62
|
+
setInnerOpen = _useState[1];
|
|
63
|
+
const Animation = animate === "fade" ? Fade : SlideFromTop;
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setInnerOpen(open);
|
|
66
|
+
}, [open]);
|
|
67
|
+
const requestClose = useCallback(() => setInnerOpen(false), []);
|
|
68
|
+
const titleId = useStableId();
|
|
69
|
+
const _useState2 = useState(0),
|
|
70
|
+
titleCount = _useState2[0],
|
|
71
|
+
setTitleCount = _useState2[1];
|
|
72
|
+
const titleCountRef = useRef(0);
|
|
73
|
+
const warnedAboutName = useRef(false);
|
|
74
|
+
const registerTitle = useCallback(() => {
|
|
75
|
+
titleCountRef.current += 1;
|
|
76
|
+
setTitleCount(count => count + 1);
|
|
77
|
+
return () => {
|
|
78
|
+
titleCountRef.current -= 1;
|
|
79
|
+
setTitleCount(count => count - 1);
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
const ariaLabel = rest["aria-label"];
|
|
83
|
+
const explicitLabelledBy = rest["aria-labelledby"];
|
|
84
|
+
const ariaLabelledBy = explicitLabelledBy != null ? explicitLabelledBy : ariaLabel || titleCount === 0 ? undefined : titleId;
|
|
85
|
+
|
|
86
|
+
// A dialog inside another one mounts its content a render later, so the check waits a tick for its title.
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (process.env.NODE_ENV === "production" || !innerOpen || warnedAboutName.current || ariaLabel || explicitLabelledBy) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const timeout = setTimeout(() => {
|
|
92
|
+
if (titleCountRef.current === 0) {
|
|
93
|
+
warnedAboutName.current = true;
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.warn("Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.");
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return () => clearTimeout(timeout);
|
|
99
|
+
}, [innerOpen, ariaLabel, explicitLabelledBy]);
|
|
100
|
+
const handleDismissBlocked = useCallback((reason, event) => {
|
|
101
|
+
if (reason === "backdrop") {
|
|
102
|
+
onClickOutside == null || onClickOutside(event);
|
|
103
|
+
}
|
|
104
|
+
}, [onClickOutside]);
|
|
105
|
+
const contextValue = useMemo(() => ({
|
|
106
|
+
requestClose,
|
|
107
|
+
onClose,
|
|
108
|
+
titleId,
|
|
109
|
+
registerTitle
|
|
110
|
+
}), [requestClose, onClose, titleId, registerTitle]);
|
|
111
|
+
return /*#__PURE__*/React.createElement(ModalRoot, _extends({}, rest, {
|
|
112
|
+
ref: forwardedRef,
|
|
113
|
+
open: innerOpen,
|
|
114
|
+
onRequestClose: requestClose,
|
|
115
|
+
onDismissBlocked: handleDismissBlocked,
|
|
116
|
+
onClose: onClose,
|
|
117
|
+
disableCloseOnEsc: disableCloseOnEsc,
|
|
118
|
+
disableBackgroundClick: !enableBackgroundClick,
|
|
119
|
+
"aria-labelledby": ariaLabelledBy
|
|
120
|
+
}), _ref3 => {
|
|
121
|
+
let isIn = _ref3.in,
|
|
122
|
+
onExited = _ref3.onExited;
|
|
123
|
+
return /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
124
|
+
value: contextValue
|
|
125
|
+
}, /*#__PURE__*/React.createElement(StyledDialogViewport, {
|
|
126
|
+
className: "c-dialog-viewport"
|
|
127
|
+
}, /*#__PURE__*/React.createElement(Animation, {
|
|
128
|
+
in: isIn,
|
|
129
|
+
onExited: onExited
|
|
130
|
+
}, surface)));
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
NativeDialog.displayName = "NativeDialog";
|
|
134
|
+
export const _Dialog = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
135
|
+
var _dialogSizes$size;
|
|
136
|
+
let children = _ref4.children,
|
|
137
|
+
_ref4$open = _ref4.open,
|
|
138
|
+
open = _ref4$open === void 0 ? false : _ref4$open,
|
|
139
|
+
onClose = _ref4.onClose,
|
|
140
|
+
className = _ref4.className,
|
|
141
|
+
_ref4$enableBackgroun = _ref4.enableBackgroundClick,
|
|
142
|
+
enableBackgroundClick = _ref4$enableBackgroun === void 0 ? false : _ref4$enableBackgroun,
|
|
143
|
+
_ref4$disableCloseOnE = _ref4.disableCloseOnEsc,
|
|
144
|
+
disableCloseOnEsc = _ref4$disableCloseOnE === void 0 ? false : _ref4$disableCloseOnE,
|
|
145
|
+
_ref4$animate = _ref4.animate,
|
|
146
|
+
animate = _ref4$animate === void 0 ? "slide" : _ref4$animate,
|
|
147
|
+
onClickOutside = _ref4.onClickOutside,
|
|
148
|
+
_ref4$size = _ref4.size,
|
|
149
|
+
size = _ref4$size === void 0 ? "m" : _ref4$size,
|
|
150
|
+
_ref4$height = _ref4.height,
|
|
151
|
+
height = _ref4$height === void 0 ? "fluid" : _ref4$height,
|
|
152
|
+
_ref4$native = _ref4.native,
|
|
153
|
+
native = _ref4$native === void 0 ? false : _ref4$native,
|
|
154
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
155
|
+
const _useState3 = useState(null),
|
|
156
|
+
dialogNode = _useState3[0],
|
|
157
|
+
setDialogNode = _useState3[1];
|
|
65
158
|
useFluidHeightAnimation(dialogNode, height === "fluid");
|
|
159
|
+
const surface = /*#__PURE__*/React.createElement(StyledDialog, {
|
|
160
|
+
ref: setDialogNode,
|
|
161
|
+
$maxWidth: (_dialogSizes$size = dialogSizes[size]) != null ? _dialogSizes$size : dialogSizes.m,
|
|
162
|
+
$height: height === "fluid" ? undefined : height,
|
|
163
|
+
className: classnames("c-dialog", className)
|
|
164
|
+
}, children);
|
|
165
|
+
if (native) {
|
|
166
|
+
return /*#__PURE__*/React.createElement(NativeDialog, _extends({}, rest, {
|
|
167
|
+
forwardedRef: ref,
|
|
168
|
+
open: open,
|
|
169
|
+
onClose: onClose,
|
|
170
|
+
enableBackgroundClick: enableBackgroundClick,
|
|
171
|
+
disableCloseOnEsc: disableCloseOnEsc,
|
|
172
|
+
animate: animate,
|
|
173
|
+
onClickOutside: onClickOutside,
|
|
174
|
+
surface: surface
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
66
177
|
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
67
178
|
ref: ref,
|
|
68
179
|
open: open,
|
|
@@ -81,12 +192,7 @@ export const _Dialog = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
81
192
|
in: open,
|
|
82
193
|
onClose: onClose,
|
|
83
194
|
animate: animate
|
|
84
|
-
},
|
|
85
|
-
ref: setDialogNode,
|
|
86
|
-
$maxWidth: (_dialogSizes$size = dialogSizes[size]) != null ? _dialogSizes$size : dialogSizes.m,
|
|
87
|
-
$height: height === "fluid" ? undefined : height,
|
|
88
|
-
className: classnames("c-dialog", className)
|
|
89
|
-
}, children)));
|
|
195
|
+
}, surface));
|
|
90
196
|
});
|
|
91
197
|
_Dialog.displayName = "Dialog";
|
|
92
198
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["React","forwardRef","useMemo","useState","classnames","DialogActions","DialogContent","DialogContentDivider","DialogContext","DialogTitle","dialogSizes","StyledDialog","StyledDialogViewport","useFluidHeightAnimation","Modal","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","_Dialog","_ref2","ref","_dialogSizes$size","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","_ref2$size","size","_ref2$height","height","rest","_objectWithoutPropertiesLoose","_excluded","_useState","dialogNode","setDialogNode","_extends","disableBackgroundClick","overlayTimeout","enter","exit","$maxWidth","m","$height","undefined","Dialog","Object","assign","Title","Content","ContentDivider","Actions"],"sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n PropsWithChildren,\n ReactElement,\n useMemo,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { DialogActions } from \"./DialogActions\";\nimport { DialogContent } from \"./DialogContent\";\nimport { DialogContentDivider } from \"./DialogContentDivider\";\nimport { DialogContext } from \"./DialogContext\";\nimport { DialogTitle } from \"./DialogTitle\";\nimport {\n DialogSize,\n dialogSizes,\n StyledDialog,\n StyledDialogViewport,\n} from \"./Styles\";\nimport { useFluidHeightAnimation } from \"./useFluidHeightAnimation\";\nimport { Modal } from \"../Modal\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\nexport interface DialogProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n className?: string;\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n animate?: \"fade\" | \"slide\";\n onClickOutside?: (event) => void;\n /** Width step. Every step is a max-width; the dialog always fills it when there is room. */\n size?: DialogSize;\n /** \"fluid\" follows the content. A CSS length (\"95%\", \"600px\") pins the height instead. */\n height?: string;\n}\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// Modal only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though Modal overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\nexport const _Dialog = forwardRef<\n HTMLDivElement,\n PropsWithChildren<DialogProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n className,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n size = \"m\",\n height = \"fluid\",\n ...rest\n },\n ref\n ) => {\n const [dialogNode, setDialogNode] = useState<HTMLDivElement | null>(null);\n\n useFluidHeightAnimation(dialogNode, height === \"fluid\");\n\n return (\n <Modal\n ref={ref}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n <StyledDialog\n ref={setDialogNode}\n $maxWidth={dialogSizes[size] ?? dialogSizes.m}\n $height={height === \"fluid\" ? undefined : height}\n className={classnames(\"c-dialog\", className)}\n >\n {children}\n </StyledDialog>\n </DialogSurface>\n </Modal>\n );\n }\n);\n\n_Dialog.displayName = \"Dialog\";\n\n// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757\nexport const Dialog = Object.assign({}, _Dialog, {\n Title: DialogTitle,\n Content: DialogContent,\n ContentDivider: DialogContentDivider,\n Actions: DialogActions,\n});\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAIVC,OAAO,EACPC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAEEC,WAAW,EACXC,YAAY,EACZC,oBAAoB,QACf,UAAU;AACjB,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACpD,SACEC,YAAY,EACZC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AA0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KAAA,CAAAkC,aAAA,CAACd,aAAa;IAACG,EAAE,EAAEoB,IAAK;IAACf,OAAO,EAAEA,OAAQ;IAACC,OAAO,EAAEA;EAAQ,gBAC1D7B,KAAA,CAAAkC,aAAA,CAACvB,YAAY;IACX6B,GAAG,EAAEmB,aAAc;IACnBM,SAAS,GAAAxB,iBAAA,GAAE/B,WAAW,CAACyC,IAAI,CAAC,YAAAV,iBAAA,GAAI/B,WAAW,CAACwD,CAAE;IAC9CC,OAAO,EAAEd,MAAM,KAAK,OAAO,GAAGe,SAAS,GAAGf,MAAO;IACjDjB,SAAS,EAAEhC,UAAU,CAAC,UAAU,EAAEgC,SAAS;EAAE,GAE5CN,QACW,CACD,CACV,CAAC;AAEZ,CACF,CAAC;AAEDQ,OAAO,CAACD,WAAW,GAAG,QAAQ;;AAE9B;AACA,OAAO,MAAMgC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEjC,OAAO,EAAE;EAC/CkC,KAAK,EAAE/D,WAAW;EAClBgE,OAAO,EAAEnE,aAAa;EACtBoE,cAAc,EAAEnE,oBAAoB;EACpCoE,OAAO,EAAEtE;AACX,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["React","forwardRef","useCallback","useEffect","useMemo","useRef","useState","classnames","DialogActions","DialogContent","DialogContentDivider","DialogContext","DialogTitle","dialogSizes","StyledDialog","StyledDialogViewport","useFluidHeightAnimation","useStableId","Modal","ModalRoot","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","NativeDialog","_ref2","forwardedRef","surface","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref3","isIn","_Dialog","_ref4","_dialogSizes$size","_ref4$open","_ref4$enableBackgroun","_ref4$disableCloseOnE","_ref4$animate","_ref4$size","size","_ref4$height","height","_ref4$native","native","_excluded2","_useState3","dialogNode","setDialogNode","$maxWidth","m","$height","overlayTimeout","enter","exit","Dialog","Object","assign","Title","Content","ContentDivider","Actions"],"sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n MouseEvent,\n PropsWithChildren,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { DialogActions } from \"./DialogActions\";\nimport { DialogContent } from \"./DialogContent\";\nimport { DialogContentDivider } from \"./DialogContentDivider\";\nimport { DialogContext } from \"./DialogContext\";\nimport { DialogTitle } from \"./DialogTitle\";\nimport {\n DialogSize,\n dialogSizes,\n StyledDialog,\n StyledDialogViewport,\n} from \"./Styles\";\nimport { useFluidHeightAnimation } from \"./useFluidHeightAnimation\";\nimport useStableId from \"../../utils/useStableId\";\nimport { Modal } from \"../Modal\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\nexport interface DialogProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n className?: string;\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n animate?: \"fade\" | \"slide\";\n onClickOutside?: (event) => void;\n /** Width step. Every step is a max-width; the dialog always fills it when there is room. */\n size?: DialogSize;\n /** \"fluid\" follows the content. A CSS length (\"95%\", \"600px\") pins the height instead. */\n height?: string;\n /** Opens as a native modal <dialog>: the page behind is inert and the dialog sits in the top layer. Temporary opt-in. */\n native?: boolean;\n}\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// Modal only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though Modal overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\ninterface NativeDialogProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef: Ref<HTMLDivElement>;\n surface: ReactElement;\n children?: ReactNode;\n}\n\nconst NativeDialog = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n ...rest\n}: NativeDialogProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef as unknown as Ref<HTMLDialogElement>}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nNativeDialog.displayName = \"NativeDialog\";\n\nexport const _Dialog = forwardRef<\n HTMLDivElement,\n PropsWithChildren<DialogProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n className,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n size = \"m\",\n height = \"fluid\",\n native = false,\n ...rest\n },\n ref\n ) => {\n const [dialogNode, setDialogNode] = useState<HTMLDivElement | null>(null);\n\n useFluidHeightAnimation(dialogNode, height === \"fluid\");\n\n const surface = (\n <StyledDialog\n ref={setDialogNode}\n $maxWidth={dialogSizes[size] ?? dialogSizes.m}\n $height={height === \"fluid\" ? undefined : height}\n className={classnames(\"c-dialog\", className)}\n >\n {children}\n </StyledDialog>\n );\n\n if (native) {\n return (\n <NativeDialog\n {...rest}\n forwardedRef={ref}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n\n return (\n <Modal\n ref={ref}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n {surface}\n </DialogSurface>\n </Modal>\n );\n }\n);\n\n_Dialog.displayName = \"Dialog\";\n\n// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757\nexport const Dialog = Object.assign({}, _Dialog, {\n Title: DialogTitle,\n Content: DialogContent,\n ContentDivider: DialogContentDivider,\n Actions: DialogActions,\n});\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAOVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAC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O,EAAEA;EAAQ,GACzDY,OACY,CACV,CAAC;AAEZ,CACF,CAAC;AAED+C,OAAO,CAACnD,WAAW,GAAG,QAAQ;;AAE9B;AACA,OAAO,MAAM0E,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEzB,OAAO,EAAE;EAC/C0B,KAAK,EAAE3G,WAAW;EAClB4G,OAAO,EAAE/G,aAAa;EACtBgH,cAAc,EAAE/G,oBAAoB;EACpCgH,OAAO,EAAElH;AACX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,10 @@ export interface DialogContextProps {
|
|
|
3
3
|
requestClose?: () => void;
|
|
4
4
|
/** The handler the dialog was given, used to recognise a button that only closes. */
|
|
5
5
|
onClose?: () => void;
|
|
6
|
+
/** A native dialog's id for its title, which names the dialog. Absent on the legacy path. */
|
|
7
|
+
titleId?: string;
|
|
8
|
+
/** A native dialog's title reports that it is there. Returns the call that takes it back. */
|
|
9
|
+
registerTitle?: () => () => void;
|
|
6
10
|
}
|
|
7
11
|
export declare const DialogContext: import("react").Context<DialogContextProps | null>;
|
|
8
12
|
export declare const useDialogContext: () => DialogContextProps | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogContext.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogContext.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogContext.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogContext.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,aAAa,CAAC,EAAE,MAAM,MAAM,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,aAAa,oDAAiD,CAAC;AAE5E,eAAO,MAAM,gBAAgB,iCAAkC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,IAAI,WAlB7B,IAsBtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogContext.js","names":["createContext","useContext","DialogContext","useDialogContext","useDialogClose","fallback","_ref","_context$requestClose","context","requestClose","undefined"],"sources":["../../../../src/components/Dialog/DialogContext.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface DialogContextProps {\n /** Starts the closing transition. The dialog's own onClose runs once it finishes. */\n requestClose?: () => void;\n /** The handler the dialog was given, used to recognise a button that only closes. */\n onClose?: () => void;\n}\n\nexport const DialogContext = createContext<DialogContextProps | null>(null);\n\nexport const useDialogContext = () => useContext(DialogContext);\n\n/**\n * Closes the dialog the way clicking the overlay does: the exit transition runs first, and the\n * dialog's own onClose fires once it finishes. Use it for a Cancel button instead of calling the\n * parent's close handler, which would unmount the dialog before it can animate out.\n */\nexport const useDialogClose = (fallback?: () => void) => {\n const context = useContext(DialogContext);\n\n return context?.requestClose ?? fallback ?? (() => undefined);\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"file":"DialogContext.js","names":["createContext","useContext","DialogContext","useDialogContext","useDialogClose","fallback","_ref","_context$requestClose","context","requestClose","undefined"],"sources":["../../../../src/components/Dialog/DialogContext.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface DialogContextProps {\n /** Starts the closing transition. The dialog's own onClose runs once it finishes. */\n requestClose?: () => void;\n /** The handler the dialog was given, used to recognise a button that only closes. */\n onClose?: () => void;\n /** A native dialog's id for its title, which names the dialog. Absent on the legacy path. */\n titleId?: string;\n /** A native dialog's title reports that it is there. Returns the call that takes it back. */\n registerTitle?: () => () => void;\n}\n\nexport const DialogContext = createContext<DialogContextProps | null>(null);\n\nexport const useDialogContext = () => useContext(DialogContext);\n\n/**\n * Closes the dialog the way clicking the overlay does: the exit transition runs first, and the\n * dialog's own onClose fires once it finishes. Use it for a Cancel button instead of calling the\n * parent's close handler, which would unmount the dialog before it can animate out.\n */\nexport const useDialogClose = (fallback?: () => void) => {\n const context = useContext(DialogContext);\n\n return context?.requestClose ?? fallback ?? (() => undefined);\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAajD,OAAO,MAAMC,aAAa,gBAAGF,aAAa,CAA4B,IAAI,CAAC;AAE3E,OAAO,MAAMG,gBAAgB,GAAGA,CAAA,KAAMF,UAAU,CAACC,aAAa,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,cAAc,GAAIC,QAAqB,IAAK;EAAA,IAAAC,IAAA,EAAAC,qBAAA;EACvD,MAAMC,OAAO,GAAGP,UAAU,CAACC,aAAa,CAAC;EAEzC,QAAAI,IAAA,IAAAC,qBAAA,GAAOC,OAAO,oBAAPA,OAAO,CAAEC,YAAY,YAAAF,qBAAA,GAAIF,QAAQ,YAAAC,IAAA,GAAK,MAAMI,SAAS;AAC9D,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTitle.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DialogTitle.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAe5D,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW;mFAOrB,iBAAiB,CAAC,gBAAgB,CAAC;;CAuDrC,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["children", "className", "disableDefaultHeading", "onClose", "closeLabel"];
|
|
4
|
-
import React from "react";
|
|
4
|
+
import React, { useEffect } from "react";
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import { useDialogContext } from "./DialogContext";
|
|
7
7
|
import { StyledDialogTitle, StyledDialogTitleBar, StyledDialogTitleClose } from "./Styles";
|
|
8
8
|
import { IconButton } from "../IconButton";
|
|
9
9
|
import { CancelCrossIcon } from "../Icons";
|
|
10
|
+
import { Typography } from "../Typography/Typography";
|
|
10
11
|
import { Header3 } from "../Typography/Variants/Header3";
|
|
11
12
|
export const DialogTitle = _ref => {
|
|
12
13
|
var _dialog$requestClose;
|
|
@@ -19,7 +20,25 @@ export const DialogTitle = _ref => {
|
|
|
19
20
|
closeLabel = _ref$closeLabel === void 0 ? "Close" : _ref$closeLabel,
|
|
20
21
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
22
|
const dialog = useDialogContext();
|
|
22
|
-
const
|
|
23
|
+
const titleId = dialog == null ? void 0 : dialog.titleId;
|
|
24
|
+
const registerTitle = dialog == null ? void 0 : dialog.registerTitle;
|
|
25
|
+
useEffect(() => registerTitle == null ? void 0 : registerTitle(), [registerTitle]);
|
|
26
|
+
let heading;
|
|
27
|
+
if (disableDefaultHeading) {
|
|
28
|
+
heading = titleId ? /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
id: titleId
|
|
30
|
+
}, children) : children;
|
|
31
|
+
} else if (titleId) {
|
|
32
|
+
heading = /*#__PURE__*/React.createElement(Typography, {
|
|
33
|
+
as: "h2",
|
|
34
|
+
variant: "Header 3",
|
|
35
|
+
weight: "bold",
|
|
36
|
+
id: titleId,
|
|
37
|
+
className: "c-dialog-title"
|
|
38
|
+
}, children);
|
|
39
|
+
} else {
|
|
40
|
+
heading = /*#__PURE__*/React.createElement(Header3, null, children);
|
|
41
|
+
}
|
|
23
42
|
|
|
24
43
|
// Closing through the dialog lets the exit transition run; the caller's onClose fires once it
|
|
25
44
|
// finishes. Falling back keeps a title used outside a dialog working.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTitle.js","names":["React","classnames","useDialogContext","StyledDialogTitle","StyledDialogTitleBar","StyledDialogTitleClose","IconButton","CancelCrossIcon","Header3","DialogTitle","_ref","_dialog$requestClose","children","className","_ref$disableDefaultHe","disableDefaultHeading","onClose","_ref$closeLabel","closeLabel","rest","_objectWithoutPropertiesLoose","_excluded","dialog","heading","createElement","handleClose","requestClose","_extends","type","
|
|
1
|
+
{"version":3,"file":"DialogTitle.js","names":["React","useEffect","classnames","useDialogContext","StyledDialogTitle","StyledDialogTitleBar","StyledDialogTitleClose","IconButton","CancelCrossIcon","Typography","Header3","DialogTitle","_ref","_dialog$requestClose","children","className","_ref$disableDefaultHe","disableDefaultHeading","onClose","_ref$closeLabel","closeLabel","rest","_objectWithoutPropertiesLoose","_excluded","dialog","titleId","registerTitle","heading","createElement","id","as","variant","weight","handleClose","requestClose","_extends","type","onClick","displayName"],"sources":["../../../../src/components/Dialog/DialogTitle.tsx"],"sourcesContent":["import React, { PropsWithChildren, useEffect } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { useDialogContext } from \"./DialogContext\";\nimport {\n StyledDialogTitle,\n StyledDialogTitleBar,\n StyledDialogTitleClose,\n} from \"./Styles\";\nimport { IconButton } from \"../IconButton\";\nimport { CancelCrossIcon } from \"../Icons\";\nimport { Typography } from \"../Typography/Typography\";\nimport { Header3 } from \"../Typography/Variants/Header3\";\n\nexport interface DialogTitleProps {\n className?: string;\n disableDefaultHeading?: boolean;\n /** Draws a close button next to the heading. */\n onClose?: () => void;\n closeLabel?: string;\n}\n\nexport const DialogTitle = ({\n children,\n className,\n disableDefaultHeading = false,\n onClose,\n closeLabel = \"Close\",\n ...rest\n}: PropsWithChildren<DialogTitleProps>) => {\n const dialog = useDialogContext();\n const titleId = dialog?.titleId;\n const registerTitle = dialog?.registerTitle;\n\n useEffect(() => registerTitle?.(), [registerTitle]);\n\n let heading: React.ReactNode;\n\n if (disableDefaultHeading) {\n heading = titleId ? <div id={titleId}>{children}</div> : children;\n } else if (titleId) {\n heading = (\n <Typography\n as=\"h2\"\n variant=\"Header 3\"\n weight=\"bold\"\n id={titleId}\n className=\"c-dialog-title\"\n >\n {children}\n </Typography>\n );\n } else {\n heading = <Header3>{children}</Header3>;\n }\n\n // Closing through the dialog lets the exit transition run; the caller's onClose fires once it\n // finishes. Falling back keeps a title used outside a dialog working.\n const handleClose = dialog?.requestClose ?? onClose;\n\n return (\n <StyledDialogTitle\n className={classnames(\"c-dialog-title-wrapper\", className)}\n {...rest}\n >\n {onClose ? (\n <StyledDialogTitleBar>\n {heading}\n <StyledDialogTitleClose>\n <IconButton\n type=\"button\"\n variant=\"text gray\"\n aria-label={closeLabel}\n onClick={handleClose}\n >\n <CancelCrossIcon />\n </IconButton>\n </StyledDialogTitleClose>\n </StyledDialogTitleBar>\n ) : (\n heading\n )}\n </StyledDialogTitle>\n );\n};\n\nDialogTitle.displayName = \"DialogTitle\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAuBC,SAAS,QAAQ,OAAO;AAE3D,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,sBAAsB,QACjB,UAAU;AACjB,SAASC,UAAU,Q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AAM;IACLa,OAAO,gBAAG3B,KAAA,CAAA4B,aAAA,CAAClB,OAAO,QAAEI,QAAkB,CAAC;EACzC;;EAEA;EACA;EACA,MAAMmB,WAAW,IAAApB,oBAAA,GAAGW,MAAM,oBAANA,MAAM,CAAEU,YAAY,YAAArB,oBAAA,GAAIK,OAAO;EAEnD,oBACElB,KAAA,CAAA4B,aAAA,CAACxB,iBAAiB,EAAA+B,QAAA;IAChBpB,SAAS,EAAEb,UAAU,CAAC,wBAAwB,EAAEa,SAAS;EAAE,GACvDM,IAAI,GAEPH,OAAO,gBACNlB,KAAA,CAAA4B,aAAA,CAACvB,oBAAoB,QAClBsB,OAAO,eACR3B,KAAA,CAAA4B,aAAA,CAACtB,sBAAsB,qBACrBN,KAAA,CAAA4B,aAAA,CAACrB,UAAU;IACT6B,IAAI,EAAC,QAAQ;IACbL,OAAO,EAAC,WAAW;IACnB,cAAYX,UAAW;IACvBiB,OAAO,EAAEJ;EAAY,gBAErBjC,KAAA,CAAA4B,aAAA,CAACpB,eAAe,MAAE,CACR,CACU,CACJ,CAAC,GAEvBmB,OAEe,CAAC;AAExB,CAAC;AAEDhB,WAAW,CAAC2B,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/Styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW;;;;;;;CAOd,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAQlD,eAAO,MAAM,oBAAoB,oEAoChC,CAAC;AAIF,eAAO,MAAM,YAAY;eACZ,MAAM;cACP,MAAM;SAiCjB,CAAC;AAIF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/Styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW;;;;;;;CAOd,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAQlD,eAAO,MAAM,oBAAoB,oEAoChC,CAAC;AAIF,eAAO,MAAM,YAAY;eACZ,MAAM;cACP,MAAM;SAiCjB,CAAC;AAIF,eAAO,MAAM,iBAAiB,oEAU7B,CAAC;AASF,eAAO,MAAM,oBAAoB,oEAKhC,CAAC;AAGF,eAAO,MAAM,sBAAsB,oEAMlC,CAAC;AAGF,eAAO,MAAM,mBAAmB;aAAyB,OAAO;SAS/D,CAAC;AAGF,eAAO,MAAM,0BAA0B,oEAItC,CAAC;AAGF,eAAO,MAAM,mBAAmB,oEAS/B,CAAC"}
|
|
@@ -29,7 +29,7 @@ StyledDialog.displayName = "StyledDialog";
|
|
|
29
29
|
export const StyledDialogTitle = styled.div.withConfig({
|
|
30
30
|
displayName: "Styles__StyledDialogTitle",
|
|
31
31
|
componentId: "sc-jwpvgm-2"
|
|
32
|
-
})(["padding:20px 30px;flex:0 0 auto;", " ", ""], FontStyle, BoxSizingStyle);
|
|
32
|
+
})(["padding:20px 30px;flex:0 0 auto;& h2.c-dialog-title{margin:0;}", " ", ""], FontStyle, BoxSizingStyle);
|
|
33
33
|
StyledDialogTitle.displayName = "StyledDialogTitle";
|
|
34
34
|
|
|
35
35
|
// The close button hangs 8px into the title padding, so it sits nearer the dialog edge than the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","screen","FontStyle","dialogSizes","s","m","l","xl","xxl","xxxl","MIN_GAP","MAX_DIALOG_HEIGHT","StyledDialogViewport","div","withConfig","displayName","componentId","sm","StyledDialog","props","$maxWidth","$height","StyledDialogTitle","CLOSE_OFFSET","CLOSE_RESERVE","StyledDialogTitleBar","StyledDialogTitleClose","StyledDialogContent","$scroll","StyledDialogContentDivider","StyledDialogActions"],"sources":["../../../../src/components/Dialog/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { screen } from \"../BreakPoints\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const dialogSizes = {\n s: 440,\n m: 540,\n l: 700,\n xl: 840,\n xxl: 1000,\n xxxl: 1120,\n} as const;\n\nexport type DialogSize = keyof typeof dialogSizes;\n\nconst MIN_GAP = \"2.5vh\";\nconst MAX_DIALOG_HEIGHT = \"95vh\";\n\n// The dialog hangs at a fixed offset while there is room below it, then grows in both directions at\n// once. Two shrinkable spacers express that: only the lower one grows, and past the crossover both\n// shrink from the same basis, so the gaps stay equal down to MIN_GAP.\nexport const StyledDialogViewport = styled.div`\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n padding-left: 16px;\n padding-right: 16px;\n pointer-events: none;\n\n --ac-dialog-offset: 60px;\n\n ${screen.sm} {\n --ac-dialog-offset: 126px;\n }\n\n &::before,\n &::after {\n content: \"\";\n flex-shrink: 1;\n flex-basis: var(--ac-dialog-offset);\n min-height: ${MIN_GAP};\n }\n\n &::before {\n flex-grow: 0;\n }\n\n &::after {\n flex-grow: 1;\n }\n\n ${BoxSizingStyle}\n`;\n\nStyledDialogViewport.displayName = \"StyledDialogViewport\";\n\nexport const StyledDialog = styled.div<{\n $maxWidth: number;\n $height?: string;\n}>`\n display: flex;\n flex-direction: column;\n flex: 0 0 auto;\n pointer-events: auto;\n width: 100%;\n max-width: ${(props) => props.$maxWidth}px;\n max-height: ${MAX_DIALOG_HEIGHT};\n background-color: var(--page-paper-main);\n color: var(--color-theme-900);\n box-shadow: var(--shadow-primary);\n border-radius: 8px;\n position: relative;\n transition: max-width 0.2s ease, height 0.2s ease;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &[data-resizing],\n &[data-resizing] .c-dialog-content {\n overflow: hidden;\n }\n\n ${(props) =>\n props.$height &&\n css`\n height: ${props.$height};\n `}\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\n\nStyledDialog.displayName = \"StyledDialog\";\n\nexport const StyledDialogTitle = styled.div`\n padding: 20px 30px;\n flex: 0 0 auto;\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogTitle.displayName = \"StyledDialogTitle\";\n\n// The close button hangs 8px into the title padding, so it sits nearer the dialog edge than the\n// heading does. The bar reserves the rest, which keeps the gap to the heading unchanged.\nconst CLOSE_OFFSET = 8;\nconst CLOSE_RESERVE = 44 - CLOSE_OFFSET;\n\n// The header is as tall as its heading, with or without a close button.\nexport const StyledDialogTitleBar = styled.div`\n position: relative;\n display: flex;\n align-items: center;\n padding-right: ${CLOSE_RESERVE}px;\n`;\nStyledDialogTitleBar.displayName = \"StyledDialogTitleBar\";\n\nexport const StyledDialogTitleClose = styled.div`\n position: absolute;\n right: -${CLOSE_OFFSET}px;\n top: 50%;\n transform: translateY(-50%);\n line-height: 0;\n`;\nStyledDialogTitleClose.displayName = \"StyledDialogTitleClose\";\n\nexport const StyledDialogContent = styled.div<{ $scroll: boolean }>`\n padding: 20px 30px;\n flex: 1 1 auto;\n min-height: 0;\n overscroll-behavior: contain;\n overflow-y: ${(props) => (props.$scroll ? \"auto\" : \"visible\")};\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogContent.displayName = \"StyledDialogContent\";\n\nexport const StyledDialogContentDivider = styled.div`\n border-top: 1px solid var(--border-primary);\n height: 1px;\n flex: 0 0 auto;\n`;\nStyledDialogContentDivider.displayName = \"StyledDialogContentDivider\";\n\nexport const StyledDialogActions = styled.div`\n padding: 20px 30px;\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n gap: 12px;\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogActions.displayName = \"StyledDialogActions\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,MAAMC,WAAW,GAAG;EACzBC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,GAAG;EACNC,EAAE,EAAE,GAAG;EACPC,GAAG,EAAE,IAAI;EACTC,IAAI,EAAE;AACR,CAAU;AAIV,MAAMC,OAAO,GAAG,OAAO;AACvB,MAAMC,iBAAiB,GAAG,MAAM;;AAEhC;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGd,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,kXAe1Cf,MAAM,CAACgB,EAAE,EASKP,OAAO,EAWrBV,cAAc,CACjB;AAEDY,oBAAoB,CAACG,WAAW,GAAG,sBAAsB;AAEzD,OAAO,MAAMG,YAAY,GAAGpB,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,+bAStBG,KAAK,IAAKA,KAAK,CAACC,SAAS,EACzBT,iBAAiB,EAiB5BQ,KAAK,IACNA,KAAK,CAACE,OAAO,IACbtB,GAAG,mBACSoB,KAAK,CAACE,OAAO,CACxB,EAEDnB,SAAS,EACTF,cAAc,CACjB;AAEDkB,YAAY,CAACH,WAAW,GAAG,cAAc;AAEzC,OAAO,MAAMO,iBAAiB,GAAGxB,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","screen","FontStyle","dialogSizes","s","m","l","xl","xxl","xxxl","MIN_GAP","MAX_DIALOG_HEIGHT","StyledDialogViewport","div","withConfig","displayName","componentId","sm","StyledDialog","props","$maxWidth","$height","StyledDialogTitle","CLOSE_OFFSET","CLOSE_RESERVE","StyledDialogTitleBar","StyledDialogTitleClose","StyledDialogContent","$scroll","StyledDialogContentDivider","StyledDialogActions"],"sources":["../../../../src/components/Dialog/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { screen } from \"../BreakPoints\";\nimport { FontStyle } from \"../FontStyle\";\n\nexport const dialogSizes = {\n s: 440,\n m: 540,\n l: 700,\n xl: 840,\n xxl: 1000,\n xxxl: 1120,\n} as const;\n\nexport type DialogSize = keyof typeof dialogSizes;\n\nconst MIN_GAP = \"2.5vh\";\nconst MAX_DIALOG_HEIGHT = \"95vh\";\n\n// The dialog hangs at a fixed offset while there is room below it, then grows in both directions at\n// once. Two shrinkable spacers express that: only the lower one grows, and past the crossover both\n// shrink from the same basis, so the gaps stay equal down to MIN_GAP.\nexport const StyledDialogViewport = styled.div`\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n padding-left: 16px;\n padding-right: 16px;\n pointer-events: none;\n\n --ac-dialog-offset: 60px;\n\n ${screen.sm} {\n --ac-dialog-offset: 126px;\n }\n\n &::before,\n &::after {\n content: \"\";\n flex-shrink: 1;\n flex-basis: var(--ac-dialog-offset);\n min-height: ${MIN_GAP};\n }\n\n &::before {\n flex-grow: 0;\n }\n\n &::after {\n flex-grow: 1;\n }\n\n ${BoxSizingStyle}\n`;\n\nStyledDialogViewport.displayName = \"StyledDialogViewport\";\n\nexport const StyledDialog = styled.div<{\n $maxWidth: number;\n $height?: string;\n}>`\n display: flex;\n flex-direction: column;\n flex: 0 0 auto;\n pointer-events: auto;\n width: 100%;\n max-width: ${(props) => props.$maxWidth}px;\n max-height: ${MAX_DIALOG_HEIGHT};\n background-color: var(--page-paper-main);\n color: var(--color-theme-900);\n box-shadow: var(--shadow-primary);\n border-radius: 8px;\n position: relative;\n transition: max-width 0.2s ease, height 0.2s ease;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &[data-resizing],\n &[data-resizing] .c-dialog-content {\n overflow: hidden;\n }\n\n ${(props) =>\n props.$height &&\n css`\n height: ${props.$height};\n `}\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\n\nStyledDialog.displayName = \"StyledDialog\";\n\nexport const StyledDialogTitle = styled.div`\n padding: 20px 30px;\n flex: 0 0 auto;\n\n & h2.c-dialog-title {\n margin: 0;\n }\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogTitle.displayName = \"StyledDialogTitle\";\n\n// The close button hangs 8px into the title padding, so it sits nearer the dialog edge than the\n// heading does. The bar reserves the rest, which keeps the gap to the heading unchanged.\nconst CLOSE_OFFSET = 8;\nconst CLOSE_RESERVE = 44 - CLOSE_OFFSET;\n\n// The header is as tall as its heading, with or without a close button.\nexport const StyledDialogTitleBar = styled.div`\n position: relative;\n display: flex;\n align-items: center;\n padding-right: ${CLOSE_RESERVE}px;\n`;\nStyledDialogTitleBar.displayName = \"StyledDialogTitleBar\";\n\nexport const StyledDialogTitleClose = styled.div`\n position: absolute;\n right: -${CLOSE_OFFSET}px;\n top: 50%;\n transform: translateY(-50%);\n line-height: 0;\n`;\nStyledDialogTitleClose.displayName = \"StyledDialogTitleClose\";\n\nexport const StyledDialogContent = styled.div<{ $scroll: boolean }>`\n padding: 20px 30px;\n flex: 1 1 auto;\n min-height: 0;\n overscroll-behavior: contain;\n overflow-y: ${(props) => (props.$scroll ? \"auto\" : \"visible\")};\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogContent.displayName = \"StyledDialogContent\";\n\nexport const StyledDialogContentDivider = styled.div`\n border-top: 1px solid var(--border-primary);\n height: 1px;\n flex: 0 0 auto;\n`;\nStyledDialogContentDivider.displayName = \"StyledDialogContentDivider\";\n\nexport const StyledDialogActions = styled.div`\n padding: 20px 30px;\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n gap: 12px;\n\n ${FontStyle}\n ${BoxSizingStyle}\n`;\nStyledDialogActions.displayName = \"StyledDialogActions\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC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C,oBAAoB,CAACV,WAAW,GAAG,sBAAsB;AAEzD,OAAO,MAAMW,sBAAsB,GAAG5B,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,0FAEpCO,YAAY,CAIvB;AACDG,sBAAsB,CAACX,WAAW,GAAG,wBAAwB;AAE7D,OAAO,MAAMY,mBAAmB,GAAG7B,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,2GAK5BG,KAAK,IAAMA,KAAK,CAACS,OAAO,GAAG,MAAM,GAAG,SAAU,EAE3D1B,SAAS,EACTF,cAAc,CACjB;AACD2B,mBAAmB,CAACZ,WAAW,GAAG,qBAAqB;AAEvD,OAAO,MAAMc,0BAA0B,GAAG/B,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4EAInD;AACDa,0BAA0B,CAACd,WAAW,GAAG,4BAA4B;AAErE,OAAO,MAAMe,mBAAmB,GAAGhC,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,2FAOzCd,SAAS,EACTF,cAAc,CACjB;AACD8B,mBAAmB,CAACf,WAAW,GAAG,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDockedCard.d.ts","sourceRoot":"","sources":["../../../../src/components/DockedCard/useDockedCard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useDockedCard.d.ts","sourceRoot":"","sources":["../../../../src/components/DockedCard/useDockedCard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAQf,6EAA6E;AAC7E,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,GAAG,IAAI,KAAG,WAcvD,CAAC;AAKF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,uFAAuF;IACvF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;CACzC;AAED,6GAA6G;AAC7G,eAAO,MAAM,aAAa,GAAI,0FAU3B,oBAAoB;oBA4BZ,OAAO;;IAkKd,gFAAgF;;IAEhF,0CAA0C;;IAE1C,sGAAsG;;;IAGtG,qDAAqD;;mBA1D9C,WAAW,GAAG,IAAI;;CA+D5B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import { flushSync } from "react-dom";
|
|
3
|
+
import { getLayerOf, isInTopLayer } from "../../utils/layers";
|
|
3
4
|
const getDocumentScroller = () => document.scrollingElement || document.documentElement;
|
|
4
5
|
|
|
5
6
|
/** The closest ancestor that scrolls. The full page scrolls the document. */
|
|
@@ -137,7 +138,7 @@ export const useDockedCard = _ref => {
|
|
|
137
138
|
var _latest$current$isBus;
|
|
138
139
|
const card = cardRef.current;
|
|
139
140
|
const target = event.target;
|
|
140
|
-
const isOwn = target === document.body
|
|
141
|
+
const isOwn = target === document.body ? isInTopLayer(card) : getLayerOf(target) === getLayerOf(card);
|
|
141
142
|
const busy = card ? (_latest$current$isBus = latest.current.isBusy == null ? void 0 : latest.current.isBusy(card)) != null ? _latest$current$isBus : false : false;
|
|
142
143
|
if (event.key === "Escape" && !event.defaultPrevented && isOwn && !busy) {
|
|
143
144
|
var _latest$current$onEsc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDockedCard.js","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","flushSync","getDocumentScroller","document","scrollingElement","documentElement","getScrollParent","node","element","parentElement","body","_window$getComputedSt","window","getComputedStyle","overflowY","isDocumentScroller","useDockedCard","_ref","cardRef","open","onOpenChange","_ref$enabled","enabled","_ref$duration","duration","_ref$peek","peek","getTopLimit","onEscape","isBusy","scrollerRef","dimNodeRef","timerRef","_useState","viewHeight","setViewHeight","_useState2","cardHeight","setCardHeight","_useState3","topLimit","setTopLimit","_useState4","moving","setMoving","latest","current","findScroller","_scrollerRef$current","setOpen","next","_dimNodeRef$current","animate","opacity","fill","clearTimeout","setTimeout","scroller","isDocument","measure","innerHeight","clientHeight","ResizeObserver","undefined","observer","observe","disconnect","measureTopLimit","limit","scrollerTop","getBoundingClientRect","top","Math","max","round","bottom","handleKeyDown","event","_latest$current$isBus","card","target","isOwn","closest","busy","key","defaultPrevented","_latest$current$onEsc","preventDefault","stopPropagation","addEventListener","removeEventListener","dimRef","_cardRef$current$offs","_cardRef$current","offsetHeight","frozen","previous","style","overflow","lifted","offset"],"sources":["../../../../src/components/DockedCard/useDockedCard.ts"],"sourcesContent":["import {\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\nconst getDocumentScroller = () =>\n (document.scrollingElement || document.documentElement) as HTMLElement;\n\n/** The closest ancestor that scrolls. The full page scrolls the document. */\nexport const getScrollParent = (node?: Element | null): HTMLElement => {\n let element = node?.parentElement;\n\n while (element && element !== document.body) {\n const { overflowY } = window.getComputedStyle(element);\n\n if (overflowY === \"auto\" || overflowY === \"scroll\") {\n return element;\n }\n\n element = element.parentElement;\n }\n\n return getDocumentScroller();\n};\n\nconst isDocumentScroller = (element: HTMLElement) =>\n element === document.scrollingElement || element === document.documentElement;\n\nexport interface UseDockedCardOptions {\n cardRef: RefObject<HTMLElement>;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Set to false where the card is not docked. It then never opens and has no top limit. */\n enabled?: boolean;\n /** The time of the move, in milliseconds. */\n duration?: number;\n /** The height of the closed card that stays above the edge, in pixels. */\n peek?: number;\n /** The element whose bottom edge the open card must not pass. */\n getTopLimit?: () => Element | null | undefined;\n /** Called on Escape while the card is open. Without it Escape closes the card. */\n onEscape?: () => void;\n /** True while something in the card, such as an open menu, must take Escape itself. */\n isBusy?: (card: HTMLElement) => boolean;\n}\n\n/** The moves of a docked card: its offset, its open state, the dim, the Escape key and the frozen scroll. */\nexport const useDockedCard = ({\n cardRef,\n open,\n onOpenChange,\n enabled = true,\n duration = 200,\n peek = 0,\n getTopLimit,\n onEscape,\n isBusy,\n}: UseDockedCardOptions) => {\n const scrollerRef = useRef<HTMLElement | null>(null);\n const dimNodeRef = useRef<HTMLElement | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout>>();\n const [viewHeight, setViewHeight] = useState(0);\n const [cardHeight, setCardHeight] = useState(0);\n const [topLimit, setTopLimit] = useState(0);\n const [moving, setMoving] = useState(false);\n const latest = useRef({\n enabled,\n onOpenChange,\n onEscape,\n isBusy,\n getTopLimit,\n });\n\n latest.current = { enabled, onOpenChange, onEscape, isBusy, getTopLimit };\n\n // Found once: a frozen scroller has no scroll in its style, so a later search would miss it.\n const findScroller = useCallback(() => {\n scrollerRef.current =\n scrollerRef.current ?? getScrollParent(cardRef.current);\n\n return scrollerRef.current;\n }, [cardRef]);\n\n // The card moves with a transition only when it opens or closes, not when its content changes its height.\n const setOpen = useCallback(\n (next: boolean) => {\n if (!latest.current.enabled) {\n return;\n }\n\n if (!next) {\n dimNodeRef.current?.animate?.([{ opacity: 1 }, { opacity: 0 }], {\n duration,\n fill: \"forwards\",\n });\n }\n\n clearTimeout(timerRef.current);\n setMoving(true);\n latest.current.onOpenChange(next);\n timerRef.current = setTimeout(() => setMoving(false), duration + 50);\n },\n [duration]\n );\n\n useEffect(() => () => clearTimeout(timerRef.current), []);\n\n useEffect(() => {\n const scroller = findScroller();\n const isDocument = isDocumentScroller(scroller);\n const measure = () =>\n setViewHeight(isDocument ? window.innerHeight : scroller.clientHeight);\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(measure);\n\n observer.observe(isDocument ? document.documentElement : scroller);\n\n return () => observer.disconnect();\n }, [findScroller]);\n\n const measureTopLimit = useCallback(() => {\n const scroller = findScroller();\n const limit = latest.current.getTopLimit?.();\n\n if (!enabled || !scroller || !limit) {\n setTopLimit(0);\n\n return;\n }\n\n const scrollerTop =\n scroller === getDocumentScroller()\n ? 0\n : scroller.getBoundingClientRect().top;\n\n setTopLimit(\n Math.max(\n 0,\n Math.round(limit.getBoundingClientRect().bottom - scrollerTop)\n )\n );\n }, [enabled, findScroller]);\n\n useLayoutEffect(measureTopLimit, [open, viewHeight, measureTopLimit]);\n\n // The limit element can grow after the first measure, such as a title that wraps to a second line.\n useEffect(() => {\n const limit = enabled ? latest.current.getTopLimit?.() : null;\n\n if (!limit || typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(measureTopLimit);\n\n observer.observe(limit);\n\n return () => observer.disconnect();\n }, [enabled, open, measureTopLimit]);\n\n // A menu, a list or a dialog above the card takes its own Escape.\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const card = cardRef.current;\n const target = event.target as Element;\n const isOwn =\n target === document.body ||\n target.closest?.(\".c-window\") === card?.closest(\".c-window\");\n const busy = card ? latest.current.isBusy?.(card) ?? false : false;\n\n if (event.key === \"Escape\" && !event.defaultPrevented && isOwn && !busy) {\n event.preventDefault();\n event.stopPropagation();\n (latest.current.onEscape ?? (() => setOpen(false)))();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown, true);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown, true);\n }, [open, cardRef, setOpen]);\n\n const dimRef = useCallback(\n (node: HTMLElement | null) => {\n dimNodeRef.current = node;\n node?.animate?.([{ opacity: 0 }, { opacity: 1 }], duration);\n },\n [duration]\n );\n\n // The height places the card, so each render reads it before the paint. The observer covers what comes in later.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n setCardHeight(cardRef.current?.offsetHeight ?? 0);\n });\n\n useLayoutEffect(() => {\n const card = cardRef.current;\n\n if (!card || typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(() =>\n flushSync(() => setCardHeight(card.offsetHeight))\n );\n\n observer.observe(card);\n\n return () => observer.disconnect();\n }, [cardRef]);\n\n // The page does not scroll under the open card.\n const frozen = open || moving;\n\n useEffect(() => {\n if (!frozen) {\n return undefined;\n }\n\n const scroller = findScroller();\n const previous = scroller.style.overflow;\n\n scroller.style.overflow = \"hidden\";\n\n return () => {\n scroller.style.overflow = previous;\n };\n }, [frozen, findScroller]);\n\n return {\n setOpen,\n moving,\n /** The card and its dim cover the page while the card is open or on its way. */\n lifted: frozen,\n /** The height of the scroll container. */\n viewHeight,\n /** The bottom edge of the limit element, from the top of the scroll container. Zero with no limit. */\n topLimit,\n cardHeight,\n /** How far the closed card stands under the edge. */\n offset: Math.max(0, cardHeight - peek),\n dimRef,\n findScroller,\n };\n};\n"],"mappings":"AAAA,SAEEA,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,SAAS,QAAQ,WAAW;AAErC,MAAMC,mBAAmB,GAAGA,CAAA,KACzBC,QAAQ,CAACC,gBAAgB,IAAID,QAAQ,CAACE,eAA+B;;AAExE;AACA,OAAO,MAAMC,eAAe,GAAIC,IAAqB,I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C,QAAQ,CAACwC,KAAK,CAACC,QAAQ,GAAGF,QAAQ;IACpC,CAAC;EACH,CAAC,EAAE,CAACD,MAAM,EAAEhD,YAAY,CAAC,CAAC;EAE1B,OAAO;IACLE,OAAO;IACPN,MAAM;IACN;IACAwD,MAAM,EAAEJ,MAAM;IACd;IACA7D,UAAU;IACV;IACAM,QAAQ;IACRH,UAAU;IACV;IACA+D,MAAM,EAAE5B,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEpC,UAAU,GAAGX,IAAI,CAAC;IACtCiE,MAAM;IACN5C;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useDockedCard.js","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","flushSync","getLayerOf","isInTopLayer","getDocumentScroller","document","scrollingElement","documentElement","getScrollParent","node","element","parentElement","body","_window$getComputedSt","window","getComputedStyle","overflowY","isDocumentScroller","useDockedCard","_ref","cardRef","open","onOpenChange","_ref$enabled","enabled","_ref$duration","duration","_ref$peek","peek","getTopLimit","onEscape","isBusy","scrollerRef","dimNodeRef","timerRef","_useState","viewHeight","setViewHeight","_useState2","cardHeight","setCardHeight","_useState3","topLimit","setTopLimit","_useState4","moving","setMoving","latest","current","findScroller","_scrollerRef$current","setOpen","next","_dimNodeRef$current","animate","opacity","fill","clearTimeout","setTimeout","scroller","isDocument","measure","innerHeight","clientHeight","ResizeObserver","undefined","observer","observe","disconnect","measureTopLimit","limit","scrollerTop","getBoundingClientRect","top","Math","max","round","bottom","handleKeyDown","event","_latest$current$isBus","card","target","isOwn","busy","key","defaultPrevented","_latest$current$onEsc","preventDefault","stopPropagation","addEventListener","removeEventListener","dimRef","_cardRef$current$offs","_cardRef$current","offsetHeight","frozen","previous","style","overflow","lifted","offset"],"sources":["../../../../src/components/DockedCard/useDockedCard.ts"],"sourcesContent":["import {\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\nimport { getLayerOf, isInTopLayer } from \"../../utils/layers\";\n\nconst getDocumentScroller = () =>\n (document.scrollingElement || document.documentElement) as HTMLElement;\n\n/** The closest ancestor that scrolls. The full page scrolls the document. */\nexport const getScrollParent = (node?: Element | null): HTMLElement => {\n let element = node?.parentElement;\n\n while (element && element !== document.body) {\n const { overflowY } = window.getComputedStyle(element);\n\n if (overflowY === \"auto\" || overflowY === \"scroll\") {\n return element;\n }\n\n element = element.parentElement;\n }\n\n return getDocumentScroller();\n};\n\nconst isDocumentScroller = (element: HTMLElement) =>\n element === document.scrollingElement || element === document.documentElement;\n\nexport interface UseDockedCardOptions {\n cardRef: RefObject<HTMLElement>;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Set to false where the card is not docked. It then never opens and has no top limit. */\n enabled?: boolean;\n /** The time of the move, in milliseconds. */\n duration?: number;\n /** The height of the closed card that stays above the edge, in pixels. */\n peek?: number;\n /** The element whose bottom edge the open card must not pass. */\n getTopLimit?: () => Element | null | undefined;\n /** Called on Escape while the card is open. Without it Escape closes the card. */\n onEscape?: () => void;\n /** True while something in the card, such as an open menu, must take Escape itself. */\n isBusy?: (card: HTMLElement) => boolean;\n}\n\n/** The moves of a docked card: its offset, its open state, the dim, the Escape key and the frozen scroll. */\nexport const useDockedCard = ({\n cardRef,\n open,\n onOpenChange,\n enabled = true,\n duration = 200,\n peek = 0,\n getTopLimit,\n onEscape,\n isBusy,\n}: UseDockedCardOptions) => {\n const scrollerRef = useRef<HTMLElement | null>(null);\n const dimNodeRef = useRef<HTMLElement | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout>>();\n const [viewHeight, setViewHeight] = useState(0);\n const [cardHeight, setCardHeight] = useState(0);\n const [topLimit, setTopLimit] = useState(0);\n const [moving, setMoving] = useState(false);\n const latest = useRef({\n enabled,\n onOpenChange,\n onEscape,\n isBusy,\n getTopLimit,\n });\n\n latest.current = { enabled, onOpenChange, onEscape, isBusy, getTopLimit };\n\n // Found once: a frozen scroller has no scroll in its style, so a later search would miss it.\n const findScroller = useCallback(() => {\n scrollerRef.current =\n scrollerRef.current ?? getScrollParent(cardRef.current);\n\n return scrollerRef.current;\n }, [cardRef]);\n\n // The card moves with a transition only when it opens or closes, not when its content changes its height.\n const setOpen = useCallback(\n (next: boolean) => {\n if (!latest.current.enabled) {\n return;\n }\n\n if (!next) {\n dimNodeRef.current?.animate?.([{ opacity: 1 }, { opacity: 0 }], {\n duration,\n fill: \"forwards\",\n });\n }\n\n clearTimeout(timerRef.current);\n setMoving(true);\n latest.current.onOpenChange(next);\n timerRef.current = setTimeout(() => setMoving(false), duration + 50);\n },\n [duration]\n );\n\n useEffect(() => () => clearTimeout(timerRef.current), []);\n\n useEffect(() => {\n const scroller = findScroller();\n const isDocument = isDocumentScroller(scroller);\n const measure = () =>\n setViewHeight(isDocument ? window.innerHeight : scroller.clientHeight);\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(measure);\n\n observer.observe(isDocument ? document.documentElement : scroller);\n\n return () => observer.disconnect();\n }, [findScroller]);\n\n const measureTopLimit = useCallback(() => {\n const scroller = findScroller();\n const limit = latest.current.getTopLimit?.();\n\n if (!enabled || !scroller || !limit) {\n setTopLimit(0);\n\n return;\n }\n\n const scrollerTop =\n scroller === getDocumentScroller()\n ? 0\n : scroller.getBoundingClientRect().top;\n\n setTopLimit(\n Math.max(\n 0,\n Math.round(limit.getBoundingClientRect().bottom - scrollerTop)\n )\n );\n }, [enabled, findScroller]);\n\n useLayoutEffect(measureTopLimit, [open, viewHeight, measureTopLimit]);\n\n // The limit element can grow after the first measure, such as a title that wraps to a second line.\n useEffect(() => {\n const limit = enabled ? latest.current.getTopLimit?.() : null;\n\n if (!limit || typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(measureTopLimit);\n\n observer.observe(limit);\n\n return () => observer.disconnect();\n }, [enabled, open, measureTopLimit]);\n\n // A menu, a list or a dialog above the card takes its own Escape.\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const card = cardRef.current;\n const target = event.target as Element;\n const isOwn =\n target === document.body\n ? isInTopLayer(card)\n : getLayerOf(target) === getLayerOf(card);\n const busy = card ? latest.current.isBusy?.(card) ?? false : false;\n\n if (event.key === \"Escape\" && !event.defaultPrevented && isOwn && !busy) {\n event.preventDefault();\n event.stopPropagation();\n (latest.current.onEscape ?? (() => setOpen(false)))();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown, true);\n\n return () => document.removeEventListener(\"keydown\", handleKeyDown, true);\n }, [open, cardRef, setOpen]);\n\n const dimRef = useCallback(\n (node: HTMLElement | null) => {\n dimNodeRef.current = node;\n node?.animate?.([{ opacity: 0 }, { opacity: 1 }], duration);\n },\n [duration]\n );\n\n // The height places the card, so each render reads it before the paint. The observer covers what comes in later.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n setCardHeight(cardRef.current?.offsetHeight ?? 0);\n });\n\n useLayoutEffect(() => {\n const card = cardRef.current;\n\n if (!card || typeof ResizeObserver === \"undefined\") {\n return undefined;\n }\n\n // eslint-disable-next-line compat/compat\n const observer = new ResizeObserver(() =>\n flushSync(() => setCardHeight(card.offsetHeight))\n );\n\n observer.observe(card);\n\n return () => observer.disconnect();\n }, [cardRef]);\n\n // The page does not scroll under the open card.\n const frozen = open || moving;\n\n useEffect(() => {\n if (!frozen) {\n return undefined;\n }\n\n const scroller = findScroller();\n const previous = scroller.style.overflow;\n\n scroller.style.overflow = \"hidden\";\n\n return () => {\n scroller.style.overflow = previous;\n };\n }, [frozen, findScroller]);\n\n return {\n setOpen,\n moving,\n /** The card and its dim cover the page while the card is open or on its way. */\n lifted: frozen,\n /** The height of the scroll container. */\n viewHeight,\n /** The bottom edge of the limit element, from the top of the scroll container. Zero with no limit. */\n topLimit,\n cardHeight,\n /** How far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CAAC;;EAEb;EACA,MAAM4E,MAAM,GAAG3E,IAAI,IAAIwB,MAAM;EAE7BhD,SAAS,CAAC,MAAM;IACd,IAAI,CAACmG,MAAM,EAAE;MACX,OAAO/B,SAAS;IAClB;IAEA,MAAMN,QAAQ,GAAGV,YAAY,CAAC,CAAC;IAC/B,MAAMgD,QAAQ,GAAGtC,QAAQ,CAACuC,KAAK,CAACC,QAAQ;IAExCxC,QAAQ,CAACuC,KAAK,CAACC,QAAQ,GAAG,QAAQ;IAElC,OAAO,MAAM;MACXxC,QAAQ,CAACuC,KAAK,CAACC,QAAQ,GAAGF,QAAQ;IACpC,CAAC;EACH,CAAC,EAAE,CAACD,MAAM,EAAE/C,YAAY,CAAC,CAAC;EAE1B,OAAO;IACLE,OAAO;IACPN,MAAM;IACN;IACAuD,MAAM,EAAEJ,MAAM;IACd;IACA5D,UAAU;IACV;IACAM,QAAQ;IACRH,UAAU;IACV;IACA8D,MAAM,EAAE3B,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEpC,UAAU,GAAGX,IAAI,CAAC;IACtCgE,MAAM;IACN3C;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { HTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import React, { HTMLAttributes, MouseEvent, ReactNode } from "react";
|
|
2
2
|
export type ModalRootDismissReason = "escape" | "backdrop";
|
|
3
3
|
export interface ModalRootTransition {
|
|
4
4
|
in: boolean;
|
|
@@ -8,8 +8,8 @@ export interface ModalRootProps extends Omit<HTMLAttributes<HTMLDialogElement>,
|
|
|
8
8
|
open: boolean;
|
|
9
9
|
/** Escape or a backdrop click asks the owner to set open to false */
|
|
10
10
|
onRequestClose?: (reason: ModalRootDismissReason) => void;
|
|
11
|
-
/** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked */
|
|
12
|
-
onDismissBlocked?: (reason: ModalRootDismissReason) => void;
|
|
11
|
+
/** Escape or a backdrop click that disableCloseOnEsc or disableBackgroundClick blocked; a backdrop click passes its event */
|
|
12
|
+
onDismissBlocked?: (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => void;
|
|
13
13
|
/** The exit transition is done and the dialog is closed */
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
disableCloseOnEsc?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalRoot.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,
|
|
1
|
+
{"version":3,"file":"ModalRoot.d.ts","sourceRoot":"","sources":["../../../../src/components/ModalRoot/ModalRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,cAAc,EAEd,UAAU,EAEV,SAAS,EAMV,MAAM,OAAO,CAAC;AAUf,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,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,0FAiPrB,CAAC"}
|