1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
17 |
|
18 | var React = _interopRequireWildcard(require("react"));
|
19 |
|
20 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
21 |
|
22 | var _clsx = _interopRequireDefault(require("clsx"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
27 |
|
28 | var _deprecatedPropType = _interopRequireDefault(require("../utils/deprecatedPropType"));
|
29 |
|
30 | var _Modal = _interopRequireDefault(require("../Modal"));
|
31 |
|
32 | var _Backdrop = _interopRequireDefault(require("../Backdrop"));
|
33 |
|
34 | var _Fade = _interopRequireDefault(require("../Fade"));
|
35 |
|
36 | var _transitions = require("../styles/transitions");
|
37 |
|
38 | var _Paper = _interopRequireDefault(require("../Paper"));
|
39 |
|
40 | var styles = function styles(theme) {
|
41 | return {
|
42 |
|
43 | root: {
|
44 | '@media print': {
|
45 |
|
46 | position: 'absolute !important'
|
47 | }
|
48 | },
|
49 |
|
50 |
|
51 | scrollPaper: {
|
52 | display: 'flex',
|
53 | justifyContent: 'center',
|
54 | alignItems: 'center'
|
55 | },
|
56 |
|
57 |
|
58 | scrollBody: {
|
59 | overflowY: 'auto',
|
60 | overflowX: 'hidden',
|
61 | textAlign: 'center',
|
62 | '&:after': {
|
63 | content: '""',
|
64 | display: 'inline-block',
|
65 | verticalAlign: 'middle',
|
66 | height: '100%',
|
67 | width: '0'
|
68 | }
|
69 | },
|
70 |
|
71 |
|
72 | container: {
|
73 | height: '100%',
|
74 | '@media print': {
|
75 | height: 'auto'
|
76 | },
|
77 |
|
78 | outline: 0
|
79 | },
|
80 |
|
81 |
|
82 | paper: {
|
83 | margin: 32,
|
84 | position: 'relative',
|
85 | overflowY: 'auto',
|
86 |
|
87 | '@media print': {
|
88 | overflowY: 'visible',
|
89 | boxShadow: 'none'
|
90 | }
|
91 | },
|
92 |
|
93 |
|
94 | paperScrollPaper: {
|
95 | display: 'flex',
|
96 | flexDirection: 'column',
|
97 | maxHeight: 'calc(100% - 64px)'
|
98 | },
|
99 |
|
100 |
|
101 | paperScrollBody: {
|
102 | display: 'inline-block',
|
103 | verticalAlign: 'middle',
|
104 | textAlign: 'left'
|
105 |
|
106 | },
|
107 |
|
108 |
|
109 | paperWidthFalse: {
|
110 | maxWidth: 'calc(100% - 64px)'
|
111 | },
|
112 |
|
113 |
|
114 | paperWidthXs: {
|
115 | maxWidth: Math.max(theme.breakpoints.values.xs, 444),
|
116 | '&$paperScrollBody': (0, _defineProperty2.default)({}, theme.breakpoints.down(Math.max(theme.breakpoints.values.xs, 444) + 32 * 2), {
|
117 | maxWidth: 'calc(100% - 64px)'
|
118 | })
|
119 | },
|
120 |
|
121 |
|
122 | paperWidthSm: {
|
123 | maxWidth: theme.breakpoints.values.sm,
|
124 | '&$paperScrollBody': (0, _defineProperty2.default)({}, theme.breakpoints.down(theme.breakpoints.values.sm + 32 * 2), {
|
125 | maxWidth: 'calc(100% - 64px)'
|
126 | })
|
127 | },
|
128 |
|
129 |
|
130 | paperWidthMd: {
|
131 | maxWidth: theme.breakpoints.values.md,
|
132 | '&$paperScrollBody': (0, _defineProperty2.default)({}, theme.breakpoints.down(theme.breakpoints.values.md + 32 * 2), {
|
133 | maxWidth: 'calc(100% - 64px)'
|
134 | })
|
135 | },
|
136 |
|
137 |
|
138 | paperWidthLg: {
|
139 | maxWidth: theme.breakpoints.values.lg,
|
140 | '&$paperScrollBody': (0, _defineProperty2.default)({}, theme.breakpoints.down(theme.breakpoints.values.lg + 32 * 2), {
|
141 | maxWidth: 'calc(100% - 64px)'
|
142 | })
|
143 | },
|
144 |
|
145 |
|
146 | paperWidthXl: {
|
147 | maxWidth: theme.breakpoints.values.xl,
|
148 | '&$paperScrollBody': (0, _defineProperty2.default)({}, theme.breakpoints.down(theme.breakpoints.values.xl + 32 * 2), {
|
149 | maxWidth: 'calc(100% - 64px)'
|
150 | })
|
151 | },
|
152 |
|
153 |
|
154 | paperFullWidth: {
|
155 | width: 'calc(100% - 64px)'
|
156 | },
|
157 |
|
158 |
|
159 | paperFullScreen: {
|
160 | margin: 0,
|
161 | width: '100%',
|
162 | maxWidth: '100%',
|
163 | height: '100%',
|
164 | maxHeight: 'none',
|
165 | borderRadius: 0,
|
166 | '&$paperScrollBody': {
|
167 | margin: 0,
|
168 | maxWidth: '100%'
|
169 | }
|
170 | }
|
171 | };
|
172 | };
|
173 |
|
174 | exports.styles = styles;
|
175 | var defaultTransitionDuration = {
|
176 | enter: _transitions.duration.enteringScreen,
|
177 | exit: _transitions.duration.leavingScreen
|
178 | };
|
179 |
|
180 |
|
181 |
|
182 |
|
183 | var Dialog = React.forwardRef(function Dialog(props, ref) {
|
184 | var BackdropProps = props.BackdropProps,
|
185 | children = props.children,
|
186 | classes = props.classes,
|
187 | className = props.className,
|
188 | _props$disableBackdro = props.disableBackdropClick,
|
189 | disableBackdropClick = _props$disableBackdro === void 0 ? false : _props$disableBackdro,
|
190 | _props$disableEscapeK = props.disableEscapeKeyDown,
|
191 | disableEscapeKeyDown = _props$disableEscapeK === void 0 ? false : _props$disableEscapeK,
|
192 | _props$fullScreen = props.fullScreen,
|
193 | fullScreen = _props$fullScreen === void 0 ? false : _props$fullScreen,
|
194 | _props$fullWidth = props.fullWidth,
|
195 | fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
|
196 | _props$maxWidth = props.maxWidth,
|
197 | maxWidth = _props$maxWidth === void 0 ? 'sm' : _props$maxWidth,
|
198 | onBackdropClick = props.onBackdropClick,
|
199 | onClose = props.onClose,
|
200 | onEnter = props.onEnter,
|
201 | onEntered = props.onEntered,
|
202 | onEntering = props.onEntering,
|
203 | onEscapeKeyDown = props.onEscapeKeyDown,
|
204 | onExit = props.onExit,
|
205 | onExited = props.onExited,
|
206 | onExiting = props.onExiting,
|
207 | open = props.open,
|
208 | _props$PaperComponent = props.PaperComponent,
|
209 | PaperComponent = _props$PaperComponent === void 0 ? _Paper.default : _props$PaperComponent,
|
210 | _props$PaperProps = props.PaperProps,
|
211 | PaperProps = _props$PaperProps === void 0 ? {} : _props$PaperProps,
|
212 | _props$scroll = props.scroll,
|
213 | scroll = _props$scroll === void 0 ? 'paper' : _props$scroll,
|
214 | _props$TransitionComp = props.TransitionComponent,
|
215 | TransitionComponent = _props$TransitionComp === void 0 ? _Fade.default : _props$TransitionComp,
|
216 | _props$transitionDura = props.transitionDuration,
|
217 | transitionDuration = _props$transitionDura === void 0 ? defaultTransitionDuration : _props$transitionDura,
|
218 | TransitionProps = props.TransitionProps,
|
219 | ariaDescribedby = props['aria-describedby'],
|
220 | ariaLabelledby = props['aria-labelledby'],
|
221 | other = (0, _objectWithoutProperties2.default)(props, ["BackdropProps", "children", "classes", "className", "disableBackdropClick", "disableEscapeKeyDown", "fullScreen", "fullWidth", "maxWidth", "onBackdropClick", "onClose", "onEnter", "onEntered", "onEntering", "onEscapeKeyDown", "onExit", "onExited", "onExiting", "open", "PaperComponent", "PaperProps", "scroll", "TransitionComponent", "transitionDuration", "TransitionProps", "aria-describedby", "aria-labelledby"]);
|
222 | var mouseDownTarget = React.useRef();
|
223 |
|
224 | var handleMouseDown = function handleMouseDown(event) {
|
225 | mouseDownTarget.current = event.target;
|
226 | };
|
227 |
|
228 | var handleBackdropClick = function handleBackdropClick(event) {
|
229 |
|
230 |
|
231 | if (event.target !== event.currentTarget) {
|
232 | return;
|
233 | }
|
234 |
|
235 |
|
236 | if (event.target !== mouseDownTarget.current) {
|
237 | return;
|
238 | }
|
239 |
|
240 | mouseDownTarget.current = null;
|
241 |
|
242 | if (onBackdropClick) {
|
243 | onBackdropClick(event);
|
244 | }
|
245 |
|
246 | if (!disableBackdropClick && onClose) {
|
247 | onClose(event, 'backdropClick');
|
248 | }
|
249 | };
|
250 |
|
251 | return React.createElement(_Modal.default, (0, _extends2.default)({
|
252 | className: (0, _clsx.default)(classes.root, className),
|
253 | BackdropComponent: _Backdrop.default,
|
254 | BackdropProps: (0, _extends2.default)({
|
255 | transitionDuration: transitionDuration
|
256 | }, BackdropProps),
|
257 | closeAfterTransition: true
|
258 | }, disableBackdropClick ? {
|
259 | disableBackdropClick: disableBackdropClick
|
260 | } : {}, {
|
261 | disableEscapeKeyDown: disableEscapeKeyDown,
|
262 | onEscapeKeyDown: onEscapeKeyDown,
|
263 | onClose: onClose,
|
264 | open: open,
|
265 | ref: ref
|
266 | }, other), React.createElement(TransitionComponent, (0, _extends2.default)({
|
267 | appear: true,
|
268 | in: open,
|
269 | timeout: transitionDuration,
|
270 | onEnter: onEnter,
|
271 | onEntering: onEntering,
|
272 | onEntered: onEntered,
|
273 | onExit: onExit,
|
274 | onExiting: onExiting,
|
275 | onExited: onExited,
|
276 | role: "none presentation"
|
277 | }, TransitionProps), React.createElement("div", {
|
278 | className: (0, _clsx.default)(classes.container, classes["scroll".concat((0, _capitalize.default)(scroll))]),
|
279 | onMouseUp: handleBackdropClick,
|
280 | onMouseDown: handleMouseDown
|
281 | }, React.createElement(PaperComponent, (0, _extends2.default)({
|
282 | elevation: 24,
|
283 | role: "dialog",
|
284 | "aria-describedby": ariaDescribedby,
|
285 | "aria-labelledby": ariaLabelledby
|
286 | }, PaperProps, {
|
287 | className: (0, _clsx.default)(classes.paper, classes["paperScroll".concat((0, _capitalize.default)(scroll))], classes["paperWidth".concat((0, _capitalize.default)(String(maxWidth)))], PaperProps.className, fullScreen && classes.paperFullScreen, fullWidth && classes.paperFullWidth)
|
288 | }), children))));
|
289 | });
|
290 | process.env.NODE_ENV !== "production" ? Dialog.propTypes = {
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 | |
297 |
|
298 |
|
299 | 'aria-describedby': _propTypes.default.string,
|
300 |
|
301 | |
302 |
|
303 |
|
304 | 'aria-labelledby': _propTypes.default.string,
|
305 |
|
306 | |
307 |
|
308 |
|
309 | BackdropProps: _propTypes.default.object,
|
310 |
|
311 | |
312 |
|
313 |
|
314 | children: _propTypes.default.node,
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 | classes: _propTypes.default.object,
|
321 |
|
322 | |
323 |
|
324 |
|
325 | className: _propTypes.default.string,
|
326 |
|
327 | |
328 |
|
329 |
|
330 |
|
331 | disableBackdropClick: (0, _deprecatedPropType.default)(_propTypes.default.bool, 'Use the onClose prop with the `reason` argument to filter the `backdropClick` events.'),
|
332 |
|
333 | |
334 |
|
335 |
|
336 | disableEscapeKeyDown: _propTypes.default.bool,
|
337 |
|
338 | |
339 |
|
340 |
|
341 | fullScreen: _propTypes.default.bool,
|
342 |
|
343 | |
344 |
|
345 |
|
346 |
|
347 |
|
348 | fullWidth: _propTypes.default.bool,
|
349 |
|
350 | |
351 |
|
352 |
|
353 |
|
354 |
|
355 | maxWidth: _propTypes.default.oneOf(['lg', 'md', 'sm', 'xl', 'xs', false]),
|
356 |
|
357 | |
358 |
|
359 |
|
360 |
|
361 | onBackdropClick: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the onClose prop with the `reason` argument to handle the `backdropClick` events.'),
|
362 |
|
363 | |
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | onClose: _propTypes.default.func,
|
370 |
|
371 | |
372 |
|
373 |
|
374 |
|
375 | onEnter: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
376 |
|
377 | |
378 |
|
379 |
|
380 |
|
381 | onEntered: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
382 |
|
383 | |
384 |
|
385 |
|
386 |
|
387 | onEntering: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
388 |
|
389 | |
390 |
|
391 |
|
392 |
|
393 |
|
394 | onEscapeKeyDown: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the onClose prop with the `reason` argument to handle the `escapeKeyDown` events.'),
|
395 |
|
396 | |
397 |
|
398 |
|
399 |
|
400 | onExit: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
401 |
|
402 | |
403 |
|
404 |
|
405 |
|
406 | onExited: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
407 |
|
408 | |
409 |
|
410 |
|
411 |
|
412 | onExiting: (0, _deprecatedPropType.default)(_propTypes.default.func, 'Use the `TransitionProps` prop instead.'),
|
413 |
|
414 | |
415 |
|
416 |
|
417 | open: _propTypes.default.bool.isRequired,
|
418 |
|
419 | |
420 |
|
421 |
|
422 | PaperComponent: _propTypes.default.elementType,
|
423 |
|
424 | |
425 |
|
426 |
|
427 | PaperProps: _propTypes.default.object,
|
428 |
|
429 | |
430 |
|
431 |
|
432 | scroll: _propTypes.default.oneOf(['body', 'paper']),
|
433 |
|
434 | |
435 |
|
436 |
|
437 |
|
438 | TransitionComponent: _propTypes.default.elementType,
|
439 |
|
440 | |
441 |
|
442 |
|
443 |
|
444 | transitionDuration: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
445 | appear: _propTypes.default.number,
|
446 | enter: _propTypes.default.number,
|
447 | exit: _propTypes.default.number
|
448 | })]),
|
449 |
|
450 | |
451 |
|
452 |
|
453 | TransitionProps: _propTypes.default.object
|
454 | } : void 0;
|
455 |
|
456 | var _default = (0, _withStyles.default)(styles, {
|
457 | name: 'MuiDialog'
|
458 | })(Dialog);
|
459 |
|
460 | exports.default = _default; |
\ | No newline at end of file |