@activecollab/components 2.0.527 → 2.0.528
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/Dialog/Dialog.js +32 -187
- package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogFrame.js +209 -0
- package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -0
- package/dist/cjs/components/Modal/Modal.js +17 -108
- package/dist/cjs/components/Modal/Modal.js.map +1 -1
- package/dist/cjs/components/Modal/ModalBase.js +125 -0
- package/dist/cjs/components/Modal/ModalBase.js.map +1 -0
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +41 -64
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.d.ts +3 -3
- package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +34 -175
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.d.ts +14 -0
- package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -0
- package/dist/esm/components/Dialog/DialogFrame.js +180 -0
- package/dist/esm/components/Dialog/DialogFrame.js.map +1 -0
- package/dist/esm/components/Modal/Modal.d.ts +8 -17
- package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal/Modal.js +18 -99
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Modal/ModalBase.d.ts +19 -0
- package/dist/esm/components/Modal/ModalBase.d.ts.map +1 -0
- package/dist/esm/components/Modal/ModalBase.js +108 -0
- package/dist/esm/components/Modal/ModalBase.js.map +1 -0
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +42 -65
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/index.js +925 -889
- 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
- package/dist/cjs/hooks/useDeprecation.js +0 -15
- package/dist/cjs/hooks/useDeprecation.js.map +0 -1
- package/dist/esm/hooks/useDeprecation.d.ts +0 -2
- package/dist/esm/hooks/useDeprecation.d.ts.map +0 -1
- package/dist/esm/hooks/useDeprecation.js +0 -9
- package/dist/esm/hooks/useDeprecation.js.map +0 -1
|
@@ -1,160 +1,39 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
4
|
-
|
|
5
|
-
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
const _excluded = ["children", "open", "onClose", "className", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "size", "height", "native"];
|
|
4
|
+
import React, { forwardRef, useState } from "react";
|
|
6
5
|
import classnames from "classnames";
|
|
7
6
|
import { DialogActions } from "./DialogActions";
|
|
8
7
|
import { DialogContent } from "./DialogContent";
|
|
9
8
|
import { DialogContentDivider } from "./DialogContentDivider";
|
|
10
|
-
import {
|
|
9
|
+
import { DialogFrame } from "./DialogFrame";
|
|
11
10
|
import { DialogTitle } from "./DialogTitle";
|
|
12
|
-
import { dialogSizes, StyledDialog
|
|
11
|
+
import { dialogSizes, StyledDialog } from "./Styles";
|
|
13
12
|
import { useFluidHeightAnimation } from "./useFluidHeightAnimation";
|
|
14
|
-
|
|
15
|
-
import { Modal } from "../Modal";
|
|
16
|
-
import { ModalRoot } from "../ModalRoot";
|
|
17
|
-
import { Fade, FADE_DURATION } from "../Transitions";
|
|
18
|
-
import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
|
|
19
|
-
// Modal only treats a child as a transition when its props already carry `in`, so this element
|
|
20
|
-
// must declare it even though Modal overwrites it on clone.
|
|
21
|
-
const DialogSurface = _ref => {
|
|
22
|
-
let _ref$in = _ref.in,
|
|
23
|
-
inProp = _ref$in === void 0 ? false : _ref$in,
|
|
24
|
-
onEnter = _ref.onEnter,
|
|
25
|
-
onExited = _ref.onExited,
|
|
26
|
-
forceClose = _ref.forceClose,
|
|
27
|
-
onClose = _ref.onClose,
|
|
28
|
-
animate = _ref.animate,
|
|
29
|
-
children = _ref.children;
|
|
30
|
-
const Animation = animate === "fade" ? Fade : SlideFromTop;
|
|
31
|
-
const value = useMemo(() => ({
|
|
32
|
-
requestClose: forceClose,
|
|
33
|
-
onClose
|
|
34
|
-
}), [forceClose, onClose]);
|
|
35
|
-
return /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
36
|
-
value: value
|
|
37
|
-
}, /*#__PURE__*/React.createElement(StyledDialogViewport, {
|
|
38
|
-
className: "c-dialog-viewport"
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Animation, {
|
|
40
|
-
in: inProp,
|
|
41
|
-
onEnter: onEnter,
|
|
42
|
-
onExited: onExited
|
|
43
|
-
}, children)));
|
|
44
|
-
};
|
|
45
|
-
DialogSurface.displayName = "DialogSurface";
|
|
46
|
-
const NativeDialog = _ref2 => {
|
|
47
|
-
let forwardedRef = _ref2.forwardedRef,
|
|
48
|
-
surface = _ref2.surface,
|
|
49
|
-
_ref2$open = _ref2.open,
|
|
50
|
-
open = _ref2$open === void 0 ? false : _ref2$open,
|
|
51
|
-
onClose = _ref2.onClose,
|
|
52
|
-
_ref2$enableBackgroun = _ref2.enableBackgroundClick,
|
|
53
|
-
enableBackgroundClick = _ref2$enableBackgroun === void 0 ? false : _ref2$enableBackgroun,
|
|
54
|
-
_ref2$disableCloseOnE = _ref2.disableCloseOnEsc,
|
|
55
|
-
disableCloseOnEsc = _ref2$disableCloseOnE === void 0 ? false : _ref2$disableCloseOnE,
|
|
56
|
-
_ref2$animate = _ref2.animate,
|
|
57
|
-
animate = _ref2$animate === void 0 ? "slide" : _ref2$animate,
|
|
58
|
-
onClickOutside = _ref2.onClickOutside,
|
|
59
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
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) => {
|
|
13
|
+
export const _Dialog = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
135
14
|
var _dialogSizes$size;
|
|
136
|
-
let children =
|
|
137
|
-
|
|
138
|
-
open =
|
|
139
|
-
onClose =
|
|
140
|
-
className =
|
|
141
|
-
|
|
142
|
-
enableBackgroundClick =
|
|
143
|
-
|
|
144
|
-
disableCloseOnEsc =
|
|
145
|
-
|
|
146
|
-
animate =
|
|
147
|
-
onClickOutside =
|
|
148
|
-
|
|
149
|
-
size =
|
|
150
|
-
|
|
151
|
-
height =
|
|
152
|
-
|
|
153
|
-
native =
|
|
154
|
-
rest = _objectWithoutPropertiesLoose(
|
|
155
|
-
const
|
|
156
|
-
dialogNode =
|
|
157
|
-
setDialogNode =
|
|
15
|
+
let children = _ref.children,
|
|
16
|
+
_ref$open = _ref.open,
|
|
17
|
+
open = _ref$open === void 0 ? false : _ref$open,
|
|
18
|
+
onClose = _ref.onClose,
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
_ref$enableBackground = _ref.enableBackgroundClick,
|
|
21
|
+
enableBackgroundClick = _ref$enableBackground === void 0 ? false : _ref$enableBackground,
|
|
22
|
+
_ref$disableCloseOnEs = _ref.disableCloseOnEsc,
|
|
23
|
+
disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
|
|
24
|
+
_ref$animate = _ref.animate,
|
|
25
|
+
animate = _ref$animate === void 0 ? "slide" : _ref$animate,
|
|
26
|
+
onClickOutside = _ref.onClickOutside,
|
|
27
|
+
_ref$size = _ref.size,
|
|
28
|
+
size = _ref$size === void 0 ? "m" : _ref$size,
|
|
29
|
+
_ref$height = _ref.height,
|
|
30
|
+
height = _ref$height === void 0 ? "fluid" : _ref$height,
|
|
31
|
+
_ref$native = _ref.native,
|
|
32
|
+
native = _ref$native === void 0 ? false : _ref$native,
|
|
33
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
34
|
+
const _useState = useState(null),
|
|
35
|
+
dialogNode = _useState[0],
|
|
36
|
+
setDialogNode = _useState[1];
|
|
158
37
|
useFluidHeightAnimation(dialogNode, height === "fluid");
|
|
159
38
|
const surface = /*#__PURE__*/React.createElement(StyledDialog, {
|
|
160
39
|
ref: setDialogNode,
|
|
@@ -162,37 +41,17 @@ export const _Dialog = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
|
162
41
|
$height: height === "fluid" ? undefined : height,
|
|
163
42
|
className: classnames("c-dialog", className)
|
|
164
43
|
}, children);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
open: open,
|
|
169
|
-
onClose: onClose,
|
|
170
|
-
enableBackgroundClick: enableBackgroundClick,
|
|
171
|
-
disableCloseOnEsc: disableCloseOnEsc,
|
|
172
|
-
animate: animate,
|
|
173
|
-
onClickOutside: onClickOutside,
|
|
174
|
-
surface: surface
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
178
|
-
ref: ref,
|
|
44
|
+
return /*#__PURE__*/React.createElement(DialogFrame, _extends({}, rest, {
|
|
45
|
+
forwardedRef: ref,
|
|
46
|
+
native: native,
|
|
179
47
|
open: open,
|
|
180
48
|
onClose: onClose,
|
|
181
|
-
|
|
49
|
+
enableBackgroundClick: enableBackgroundClick,
|
|
182
50
|
disableCloseOnEsc: disableCloseOnEsc,
|
|
51
|
+
animate: animate,
|
|
183
52
|
onClickOutside: onClickOutside,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
exit: FADE_DURATION
|
|
187
|
-
} : {
|
|
188
|
-
enter: SLIDE_FROM_TOP_ENTER,
|
|
189
|
-
exit: SLIDE_FROM_TOP_EXIT
|
|
190
|
-
}
|
|
191
|
-
}, rest), /*#__PURE__*/React.createElement(DialogSurface, {
|
|
192
|
-
in: open,
|
|
193
|
-
onClose: onClose,
|
|
194
|
-
animate: animate
|
|
195
|
-
}, surface));
|
|
53
|
+
surface: surface
|
|
54
|
+
}));
|
|
196
55
|
});
|
|
197
56
|
_Dialog.displayName = "Dialog";
|
|
198
57
|
|
|
@@ -1 +1 @@
|
|
|
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,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,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACpD,SACEC,YAAY,EACZC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AA4BpC;AACA;AACA,MAAMC,aAAa,GAAGC,IAAA,IAQI;EAAA,IAAAC,OAAA,GAAAD,IAAA,CAPxBE,EAAE;IAAEC,MAAM,GAAAF,OAAA,cAAG,KAAK,GAAAA,OAAA;IAClBG,OAAO,GAAAJ,IAAA,CAAPI,OAAO;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9C,KAAA,CAAAuC,aAAA,CAACrB,KAAK,EAAAoE,QAAA;IACJC,GAAG,EAAEA,GAAI;IACTvC,IAAI,EAAEA,IAAK;IACXf,OAAO,EAAEA,OAAQ;IACjByD,sBAAsB,EAAE,CAACxC,qBAAsB;IAC/CE,iBAAiB,EAAEA,iBAAkB;IACrCE,cAAc,EAAEA,cAAe;IAC/B2D,cAAc,EACZ/E,OAAO,KAAK,MAAM,GACd;MAAEgF,KAAK,EAAE7F,aAAa;MAAE8F,IAAI,EAAE9F;IAAc,CAAC,GAC7C;MAAE6F,KAAK,EAAE3F,oBAAoB;MAAE4F,IAAI,EAAE3F;IAAoB;EAC9D,GACG+B,IAAI,gBAERvD,KAAA,CAAAuC,aAAA,CAACd,aAAa;IAACG,EAAE,EAAEoB,IAAK;IAACf,OAAO,EAAEA,OAAQ;IAACC,OAAO,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":[]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["React","forwardRef","useState","classnames","DialogActions","DialogContent","DialogContentDivider","DialogFrame","DialogTitle","dialogSizes","StyledDialog","useFluidHeightAnimation","_Dialog","_ref","ref","_dialogSizes$size","children","_ref$open","open","onClose","className","_ref$enableBackground","enableBackgroundClick","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$animate","animate","onClickOutside","_ref$size","size","_ref$height","height","_ref$native","native","rest","_objectWithoutPropertiesLoose","_excluded","_useState","dialogNode","setDialogNode","surface","createElement","$maxWidth","m","$height","undefined","_extends","forwardedRef","displayName","Dialog","Object","assign","Title","Content","ContentDivider","Actions"],"sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n PropsWithChildren,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { DialogActions } from \"./DialogActions\";\nimport { DialogContent } from \"./DialogContent\";\nimport { DialogContentDivider } from \"./DialogContentDivider\";\nimport { DialogFrame } from \"./DialogFrame\";\nimport { DialogTitle } from \"./DialogTitle\";\nimport { DialogSize, dialogSizes, StyledDialog } from \"./Styles\";\nimport { useFluidHeightAnimation } from \"./useFluidHeightAnimation\";\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\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 return (\n <DialogFrame\n {...rest}\n forwardedRef={ref}\n native={native}\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\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,EAGVC,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,WAAW,QAAQ,eAAe;AAC3C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAAqBC,WAAW,EAAEC,YAAY,QAAQ,UAAU;AAChE,SAASC,uBAAuB,QAAQ,2BAA2B;AAkBnE,OAAO,MAAMC,OAAO,gBAAGX,UAAU,CAI/B,CAAAY,IAAA,EAeEC,GAAG,KACA;EAAA,IAAAC,iBAAA;EAAA,IAdDC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,SAAA,GAAAJ,IAAA,CACRK,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,KAAK,GAAAA,SAAA;IACZE,OAAO,GAAAN,IAAA,CAAPM,OAAO;IACPC,SAAS,GAAAP,IAAA,CAATO,SAAS;IAAAC,qBAAA,GAAAR,IAAA,CACTS,qBAAqB;IAArBA,qBAAqB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAV,IAAA,CAC7BW,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,YAAA,GAAAZ,IAAA,CACzBa,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAG,OAAO,GA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;AAEN,CACF,CAAC;AAED5B,OAAO,CAACoC,WAAW,GAAG,QAAQ;;AAE9B;AACA,OAAO,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEvC,OAAO,EAAE;EAC/CwC,KAAK,EAAE5C,WAAW;EAClB6C,OAAO,EAAEhD,aAAa;EACtBiD,cAAc,EAAEhD,oBAAoB;EACpCiD,OAAO,EAAEnD;AACX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ReactElement, Ref } from "react";
|
|
2
|
+
import type { DialogProps } from "./Dialog";
|
|
3
|
+
export interface DialogFrameProps extends Omit<DialogProps, "children" | "size" | "height"> {
|
|
4
|
+
forwardedRef?: Ref<HTMLDivElement>;
|
|
5
|
+
/** The visible card. The frame places it in the viewport and runs its open and close animation. */
|
|
6
|
+
surface: ReactElement;
|
|
7
|
+
/** Only the modal path has a focus lock to turn off. */
|
|
8
|
+
disableFocusLock?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const DialogFrame: {
|
|
11
|
+
({ forwardedRef, surface, native, open, onClose, enableBackgroundClick, disableCloseOnEsc, animate, onClickOutside, disableFocusLock, ...rest }: DialogFrameProps): React.JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=DialogFrame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogFrame.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,YAAY,EAEZ,GAAG,EAMJ,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAsK5C,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;IACzD,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,mGAAmG;IACnG,OAAO,EAAE,YAAY,CAAC;IACtB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAGD,eAAO,MAAM,WAAW;qJAYrB,gBAAgB;;CAsClB,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["forwardedRef", "surface", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside"],
|
|
4
|
+
_excluded2 = ["forwardedRef", "surface", "native", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "disableFocusLock"];
|
|
5
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { DialogContext } from "./DialogContext";
|
|
7
|
+
import { StyledDialogViewport } from "./Styles";
|
|
8
|
+
import useStableId from "../../utils/useStableId";
|
|
9
|
+
import { ModalBase } from "../Modal/ModalBase";
|
|
10
|
+
import { ModalRoot } from "../ModalRoot";
|
|
11
|
+
import { Fade, FADE_DURATION } from "../Transitions";
|
|
12
|
+
import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
|
|
13
|
+
// ModalBase only treats a child as a transition when its props already carry `in`, so this element
|
|
14
|
+
// must declare it even though ModalBase overwrites it on clone.
|
|
15
|
+
const DialogSurface = _ref => {
|
|
16
|
+
let _ref$in = _ref.in,
|
|
17
|
+
inProp = _ref$in === void 0 ? false : _ref$in,
|
|
18
|
+
onEnter = _ref.onEnter,
|
|
19
|
+
onExited = _ref.onExited,
|
|
20
|
+
forceClose = _ref.forceClose,
|
|
21
|
+
onClose = _ref.onClose,
|
|
22
|
+
animate = _ref.animate,
|
|
23
|
+
children = _ref.children;
|
|
24
|
+
const Animation = animate === "fade" ? Fade : SlideFromTop;
|
|
25
|
+
const value = useMemo(() => ({
|
|
26
|
+
requestClose: forceClose,
|
|
27
|
+
onClose
|
|
28
|
+
}), [forceClose, onClose]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
30
|
+
value: value
|
|
31
|
+
}, /*#__PURE__*/React.createElement(StyledDialogViewport, {
|
|
32
|
+
className: "c-dialog-viewport"
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Animation, {
|
|
34
|
+
in: inProp,
|
|
35
|
+
onEnter: onEnter,
|
|
36
|
+
onExited: onExited
|
|
37
|
+
}, children)));
|
|
38
|
+
};
|
|
39
|
+
DialogSurface.displayName = "DialogSurface";
|
|
40
|
+
const NativeDialog = _ref2 => {
|
|
41
|
+
let forwardedRef = _ref2.forwardedRef,
|
|
42
|
+
surface = _ref2.surface,
|
|
43
|
+
_ref2$open = _ref2.open,
|
|
44
|
+
open = _ref2$open === void 0 ? false : _ref2$open,
|
|
45
|
+
onClose = _ref2.onClose,
|
|
46
|
+
_ref2$enableBackgroun = _ref2.enableBackgroundClick,
|
|
47
|
+
enableBackgroundClick = _ref2$enableBackgroun === void 0 ? false : _ref2$enableBackgroun,
|
|
48
|
+
_ref2$disableCloseOnE = _ref2.disableCloseOnEsc,
|
|
49
|
+
disableCloseOnEsc = _ref2$disableCloseOnE === void 0 ? false : _ref2$disableCloseOnE,
|
|
50
|
+
_ref2$animate = _ref2.animate,
|
|
51
|
+
animate = _ref2$animate === void 0 ? "slide" : _ref2$animate,
|
|
52
|
+
onClickOutside = _ref2.onClickOutside,
|
|
53
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
54
|
+
const _useState = useState(open),
|
|
55
|
+
innerOpen = _useState[0],
|
|
56
|
+
setInnerOpen = _useState[1];
|
|
57
|
+
const Animation = animate === "fade" ? Fade : SlideFromTop;
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setInnerOpen(open);
|
|
60
|
+
}, [open]);
|
|
61
|
+
const requestClose = useCallback(() => setInnerOpen(false), []);
|
|
62
|
+
const titleId = useStableId();
|
|
63
|
+
const _useState2 = useState(0),
|
|
64
|
+
titleCount = _useState2[0],
|
|
65
|
+
setTitleCount = _useState2[1];
|
|
66
|
+
const titleCountRef = useRef(0);
|
|
67
|
+
const warnedAboutName = useRef(false);
|
|
68
|
+
const registerTitle = useCallback(() => {
|
|
69
|
+
titleCountRef.current += 1;
|
|
70
|
+
setTitleCount(count => count + 1);
|
|
71
|
+
return () => {
|
|
72
|
+
titleCountRef.current -= 1;
|
|
73
|
+
setTitleCount(count => count - 1);
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
const ariaLabel = rest["aria-label"];
|
|
77
|
+
const explicitLabelledBy = rest["aria-labelledby"];
|
|
78
|
+
const ariaLabelledBy = explicitLabelledBy != null ? explicitLabelledBy : ariaLabel || titleCount === 0 ? undefined : titleId;
|
|
79
|
+
|
|
80
|
+
// A dialog inside another one mounts its content a render later, so the check waits a tick for its title.
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (process.env.NODE_ENV === "production" || !innerOpen || warnedAboutName.current || ariaLabel || explicitLabelledBy) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const timeout = setTimeout(() => {
|
|
86
|
+
if (titleCountRef.current === 0) {
|
|
87
|
+
warnedAboutName.current = true;
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.warn("Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return () => clearTimeout(timeout);
|
|
93
|
+
}, [innerOpen, ariaLabel, explicitLabelledBy]);
|
|
94
|
+
const handleDismissBlocked = useCallback((reason, event) => {
|
|
95
|
+
if (reason === "backdrop") {
|
|
96
|
+
onClickOutside == null || onClickOutside(event);
|
|
97
|
+
}
|
|
98
|
+
}, [onClickOutside]);
|
|
99
|
+
const contextValue = useMemo(() => ({
|
|
100
|
+
requestClose,
|
|
101
|
+
onClose,
|
|
102
|
+
titleId,
|
|
103
|
+
registerTitle
|
|
104
|
+
}), [requestClose, onClose, titleId, registerTitle]);
|
|
105
|
+
return /*#__PURE__*/React.createElement(ModalRoot, _extends({}, rest, {
|
|
106
|
+
ref: forwardedRef,
|
|
107
|
+
open: innerOpen,
|
|
108
|
+
onRequestClose: requestClose,
|
|
109
|
+
onDismissBlocked: handleDismissBlocked,
|
|
110
|
+
onClose: onClose,
|
|
111
|
+
disableCloseOnEsc: disableCloseOnEsc,
|
|
112
|
+
disableBackgroundClick: !enableBackgroundClick,
|
|
113
|
+
"aria-labelledby": ariaLabelledBy
|
|
114
|
+
}), _ref3 => {
|
|
115
|
+
let isIn = _ref3.in,
|
|
116
|
+
onExited = _ref3.onExited;
|
|
117
|
+
return /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
118
|
+
value: contextValue
|
|
119
|
+
}, /*#__PURE__*/React.createElement(StyledDialogViewport, {
|
|
120
|
+
className: "c-dialog-viewport"
|
|
121
|
+
}, /*#__PURE__*/React.createElement(Animation, {
|
|
122
|
+
in: isIn,
|
|
123
|
+
onExited: onExited
|
|
124
|
+
}, surface)));
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
NativeDialog.displayName = "NativeDialog";
|
|
128
|
+
// What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.
|
|
129
|
+
export const DialogFrame = _ref4 => {
|
|
130
|
+
let forwardedRef = _ref4.forwardedRef,
|
|
131
|
+
surface = _ref4.surface,
|
|
132
|
+
_ref4$native = _ref4.native,
|
|
133
|
+
native = _ref4$native === void 0 ? false : _ref4$native,
|
|
134
|
+
_ref4$open = _ref4.open,
|
|
135
|
+
open = _ref4$open === void 0 ? false : _ref4$open,
|
|
136
|
+
onClose = _ref4.onClose,
|
|
137
|
+
_ref4$enableBackgroun = _ref4.enableBackgroundClick,
|
|
138
|
+
enableBackgroundClick = _ref4$enableBackgroun === void 0 ? false : _ref4$enableBackgroun,
|
|
139
|
+
_ref4$disableCloseOnE = _ref4.disableCloseOnEsc,
|
|
140
|
+
disableCloseOnEsc = _ref4$disableCloseOnE === void 0 ? false : _ref4$disableCloseOnE,
|
|
141
|
+
_ref4$animate = _ref4.animate,
|
|
142
|
+
animate = _ref4$animate === void 0 ? "slide" : _ref4$animate,
|
|
143
|
+
onClickOutside = _ref4.onClickOutside,
|
|
144
|
+
disableFocusLock = _ref4.disableFocusLock,
|
|
145
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
146
|
+
if (native) {
|
|
147
|
+
return /*#__PURE__*/React.createElement(NativeDialog, _extends({}, rest, {
|
|
148
|
+
forwardedRef: forwardedRef,
|
|
149
|
+
open: open,
|
|
150
|
+
onClose: onClose,
|
|
151
|
+
enableBackgroundClick: enableBackgroundClick,
|
|
152
|
+
disableCloseOnEsc: disableCloseOnEsc,
|
|
153
|
+
animate: animate,
|
|
154
|
+
onClickOutside: onClickOutside,
|
|
155
|
+
surface: surface
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
return /*#__PURE__*/React.createElement(ModalBase, _extends({
|
|
159
|
+
ref: forwardedRef,
|
|
160
|
+
open: open,
|
|
161
|
+
onClose: onClose,
|
|
162
|
+
disableBackgroundClick: !enableBackgroundClick,
|
|
163
|
+
disableCloseOnEsc: disableCloseOnEsc,
|
|
164
|
+
disableFocusLock: disableFocusLock,
|
|
165
|
+
onClickOutside: onClickOutside,
|
|
166
|
+
overlayTimeout: animate === "fade" ? {
|
|
167
|
+
enter: FADE_DURATION,
|
|
168
|
+
exit: FADE_DURATION
|
|
169
|
+
} : {
|
|
170
|
+
enter: SLIDE_FROM_TOP_ENTER,
|
|
171
|
+
exit: SLIDE_FROM_TOP_EXIT
|
|
172
|
+
}
|
|
173
|
+
}, rest), /*#__PURE__*/React.createElement(DialogSurface, {
|
|
174
|
+
in: open,
|
|
175
|
+
onClose: onClose,
|
|
176
|
+
animate: animate
|
|
177
|
+
}, surface));
|
|
178
|
+
};
|
|
179
|
+
DialogFrame.displayName = "DialogFrame";
|
|
180
|
+
//# sourceMappingURL=DialogFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogFrame.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","DialogContext","StyledDialogViewport","useStableId","ModalBase","ModalRoot","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","NativeDialog","_ref2","forwardedRef","surface","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref3","isIn","DialogFrame","_ref4","_ref4$native","native","_ref4$open","_ref4$enableBackgroun","_ref4$disableCloseOnE","_ref4$animate","disableFocusLock","_excluded2","overlayTimeout","enter","exit"],"sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DialogProps } from \"./Dialog\";\nimport { DialogContext } from \"./DialogContext\";\nimport { StyledDialogViewport } from \"./Styles\";\nimport useStableId from \"../../utils/useStableId\";\nimport { ModalBase } from \"../Modal/ModalBase\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// ModalBase only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though ModalBase overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\ninterface NativeDialogProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n surface: ReactElement;\n children?: ReactNode;\n}\n\nconst NativeDialog = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n ...rest\n}: NativeDialogProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef as unknown as Ref<HTMLDialogElement>}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nNativeDialog.displayName = \"NativeDialog\";\n\nexport interface DialogFrameProps\n extends Omit<DialogProps, \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n /** The visible card. The frame places it in the viewport and runs its open and close animation. */\n surface: ReactElement;\n /** Only the modal path has a focus lock to turn off. */\n disableFocusLock?: boolean;\n}\n\n// What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.\nexport const DialogFrame = ({\n forwardedRef,\n surface,\n native = false,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n disableFocusLock,\n ...rest\n}: DialogFrameProps) => {\n if (native) {\n return (\n <NativeDialog\n {...rest}\n forwardedRef={forwardedRef}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n\n return (\n <ModalBase\n ref={forwardedRef}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n disableFocusLock={disableFocusLock}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n {surface}\n </DialogSurface>\n </ModalBase>\n );\n};\n\nDialogFrame.displayName = \"DialogFrame\";\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAMVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,UAAU;AAC/C,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;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KAAA,CAAA8B,aAAA,CAACd,aAAa;IAACG,EAAE,EAAEoB,IAAK;IAACf,OAAO,EAAEA,OAAQ;IAACC,OAAO,EAAEA;EAAQ,GACzDY,OACY,CACN,CAAC;AAEhB,CAAC;AAED+C,WAAW,CAACnD,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import React
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onClose?: () => void;
|
|
10
|
-
children: ReactElement;
|
|
11
|
-
onClickOutside?: (event: any) => void;
|
|
12
|
-
/** How long the overlay takes to arrive and to leave. Match it to the animation the child runs. */
|
|
13
|
-
overlayTimeout?: {
|
|
14
|
-
enter: number;
|
|
15
|
-
exit: number;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IModal } from "./ModalBase";
|
|
3
|
+
export type { IModal } from "./ModalBase";
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated A modal that takes any child says nothing about what it shows. Use Dialog for a dialog, Sheet for
|
|
6
|
+
* a side or full panel, and Menu or Popper for an overlay that should not be modal. Modal is removed once nothing
|
|
7
|
+
* renders it.
|
|
8
|
+
*/
|
|
18
9
|
export declare const Modal: React.ForwardRefExoticComponent<IModal & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
19
10
|
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,MAAM,EAAa,MAAM,aAAa,CAAC;AAEhD,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C;;;;GAIG;AACH,eAAO,MAAM,KAAK,sHAiBhB,CAAC"}
|