UNPKG

4.33 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13var __rest = (this && this.__rest) || function (s, e) {
14 var t = {};
15 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16 t[p] = s[p];
17 if (s != null && typeof Object.getOwnPropertySymbols === "function")
18 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20 t[p[i]] = s[p[i]];
21 }
22 return t;
23};
24var __importStar = (this && this.__importStar) || function (mod) {
25 if (mod && mod.__esModule) return mod;
26 var result = {};
27 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
28 result["default"] = mod;
29 return result;
30};
31var __importDefault = (this && this.__importDefault) || function (mod) {
32 return (mod && mod.__esModule) ? mod : { "default": mod };
33};
34Object.defineProperty(exports, "__esModule", { value: true });
35var React = __importStar(require("react"));
36var clsx_1 = __importDefault(require("clsx"));
37var Button_1 = __importDefault(require("@material-ui/core/Button"));
38var DialogActions_1 = __importDefault(require("@material-ui/core/DialogActions"));
39var DialogContent_1 = __importDefault(require("@material-ui/core/DialogContent"));
40var Dialog_1 = __importDefault(require("@material-ui/core/Dialog"));
41var dimensions_1 = require("../constants/dimensions");
42var styles_1 = require("@material-ui/core/styles");
43exports.ModalDialog = function (_a) {
44 var _b, _c;
45 var children = _a.children, classes = _a.classes, onAccept = _a.onAccept, onDismiss = _a.onDismiss, onClear = _a.onClear, onSetToday = _a.onSetToday, okLabel = _a.okLabel, cancelLabel = _a.cancelLabel, clearLabel = _a.clearLabel, todayLabel = _a.todayLabel, clearable = _a.clearable, showTodayButton = _a.showTodayButton, showTabs = _a.showTabs, wider = _a.wider, other = __rest(_a, ["children", "classes", "onAccept", "onDismiss", "onClear", "onSetToday", "okLabel", "cancelLabel", "clearLabel", "todayLabel", "clearable", "showTodayButton", "showTabs", "wider"]);
46 return (React.createElement(Dialog_1.default, __assign({ role: "dialog", onClose: onDismiss, classes: {
47 paper: clsx_1.default(classes.dialogRoot, (_b = {},
48 _b[classes.dialogRootWider] = wider,
49 _b)),
50 } }, other),
51 React.createElement(DialogContent_1.default, { children: children, className: classes.dialog }),
52 React.createElement(DialogActions_1.default, { classes: {
53 root: clsx_1.default((_c = {},
54 _c[classes.withAdditionalAction] = clearable || showTodayButton,
55 _c)),
56 } },
57 clearable && (React.createElement(Button_1.default, { color: "primary", onClick: onClear }, clearLabel)),
58 showTodayButton && (React.createElement(Button_1.default, { color: "primary", onClick: onSetToday }, todayLabel)),
59 cancelLabel && (React.createElement(Button_1.default, { color: "primary", onClick: onDismiss }, cancelLabel)),
60 okLabel && (React.createElement(Button_1.default, { color: "primary", onClick: onAccept }, okLabel)))));
61};
62exports.ModalDialog.displayName = 'ModalDialog';
63exports.styles = styles_1.createStyles({
64 dialogRoot: {
65 minWidth: dimensions_1.DIALOG_WIDTH,
66 },
67 dialogRootWider: {
68 minWidth: dimensions_1.DIALOG_WIDTH_WIDER,
69 },
70 dialog: {
71 '&:first-child': {
72 padding: 0,
73 },
74 },
75 withAdditionalAction: {
76 // set justifyContent to default value to fix IE11 layout bug
77 // see https://github.com/dmtrKovalenko/material-ui-pickers/pull/267
78 justifyContent: 'flex-start',
79 '& > *:first-child': {
80 marginRight: 'auto',
81 },
82 },
83});
84exports.default = styles_1.withStyles(exports.styles, { name: 'MuiPickersModal' })(exports.ModalDialog);