@vendorflow/components 2.0.72 → 2.0.73
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.
|
@@ -35,16 +35,22 @@ var react_1 = require("@emotion/react");
|
|
|
35
35
|
var material_1 = require("@mui/material");
|
|
36
36
|
var Button_1 = __importDefault(require("../Button"));
|
|
37
37
|
function Modal(props) {
|
|
38
|
-
var children = props.children, classes = props.classes, cancelButton = props.cancelButton, okayButton = props.okayButton, onClose = props.onClose, submitting = props.submitting, open = props.open, title = props.title, restOfProps = __rest(props, ["children", "classes", "cancelButton", "okayButton", "onClose", "submitting", "open", "title"]);
|
|
38
|
+
var children = props.children, classes = props.classes, cancelButton = props.cancelButton, okayButton = props.okayButton, onClose = props.onClose, submitting = props.submitting, open = props.open, title = props.title, progressValue = props.progressValue, restOfProps = __rest(props, ["children", "classes", "cancelButton", "okayButton", "onClose", "submitting", "open", "title", "progressValue"]);
|
|
39
|
+
var showProgressBar = typeof progressValue !== 'undefined' && submitting;
|
|
39
40
|
return ((0, react_1.jsx)(material_1.Dialog, __assign({}, restOfProps, { classes: classes, open: open, onClose: onClose }),
|
|
40
41
|
(0, react_1.jsx)(material_1.DialogTitle, null, title),
|
|
41
42
|
(0, react_1.jsx)(material_1.DialogContent, null, typeof children === 'string' ? (0, react_1.jsx)(material_1.DialogContentText, null, children) : children),
|
|
42
|
-
(0, react_1.jsx)(
|
|
43
|
-
|
|
44
|
-
okayButton && ((0, react_1.jsx)(Button_1.default, { css: function (theme) {
|
|
43
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-items: center;\n "], ["\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-items: center;\n "]))) },
|
|
44
|
+
showProgressBar && ((0, react_1.jsx)(material_1.LinearProgress, { css: function (theme) {
|
|
45
45
|
var _a, _b;
|
|
46
|
-
return (0, react_1.css)(
|
|
47
|
-
},
|
|
46
|
+
return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: 20px;\n width: -webkit-fill-available;\n border-radius: 5px;\n color: ", ";\n\n & .MuiLinearProgress-bar {\n border-radius: 5px;\n }\n "], ["\n margin-left: 20px;\n width: -webkit-fill-available;\n border-radius: 5px;\n color: ", ";\n\n & .MuiLinearProgress-bar {\n border-radius: 5px;\n }\n "])), ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) || 'hsl(321, 53%, 31%)');
|
|
47
|
+
}, variant: "determinate", value: progressValue })),
|
|
48
|
+
(0, react_1.jsx)(material_1.DialogActions, null,
|
|
49
|
+
cancelButton && !showProgressBar && ((0, react_1.jsx)(Button_1.default, { variant: "text", disabled: cancelButton.disabled || submitting, onClick: cancelButton.onClick }, cancelButton.text)),
|
|
50
|
+
okayButton && ((0, react_1.jsx)(Button_1.default, { css: function (theme) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &&.MuiButton-root .MuiCircularProgress-root {\n color: ", ";\n }\n "], ["\n &&.MuiButton-root .MuiCircularProgress-root {\n color: ", ";\n }\n "])), ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) || 'hsl(321, 53%, 31%)');
|
|
53
|
+
}, color: "primary", variant: "text", disabled: okayButton.disabled, onClick: okayButton.onClick, loading: submitting }, okayButton.text))))));
|
|
48
54
|
}
|
|
49
55
|
exports.default = Modal;
|
|
50
|
-
var templateObject_1;
|
|
56
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -44,14 +44,41 @@ var Button_1 = __importDefault(require("../Button"));
|
|
|
44
44
|
var Modal_1 = __importDefault(require("./Modal"));
|
|
45
45
|
var Modal = function () {
|
|
46
46
|
var _a = __read((0, react_1.useState)(false), 2), open = _a[0], setOpen = _a[1];
|
|
47
|
+
var _b = __read((0, react_1.useState)(0), 2), progressValue = _b[0], setProgressValue = _b[1];
|
|
48
|
+
var _c = __read((0, react_1.useState)(false), 2), isSubmitting = _c[0], setIsSubmitting = _c[1];
|
|
49
|
+
react_1.default.useEffect(function () {
|
|
50
|
+
var timer = setInterval(function () {
|
|
51
|
+
if (isSubmitting) {
|
|
52
|
+
setProgressValue(function (progressValue) {
|
|
53
|
+
if (progressValue === 100) {
|
|
54
|
+
alert('Have a great day!!');
|
|
55
|
+
handleOnClose();
|
|
56
|
+
}
|
|
57
|
+
var diff = Math.random() * 15;
|
|
58
|
+
return Math.min(progressValue + diff, 100);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, 500);
|
|
62
|
+
return function () {
|
|
63
|
+
clearInterval(timer);
|
|
64
|
+
};
|
|
65
|
+
}, [isSubmitting]);
|
|
66
|
+
function handleOnClose() {
|
|
67
|
+
setOpen(false);
|
|
68
|
+
setIsSubmitting(false);
|
|
69
|
+
setProgressValue(0);
|
|
70
|
+
}
|
|
47
71
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
48
72
|
react_1.default.createElement(Button_1.default, { color: "primary", onClick: function () { return setOpen(true); } }, "Open"),
|
|
49
|
-
react_1.default.createElement(Modal_1.default, { open: open, submitting:
|
|
73
|
+
react_1.default.createElement(Modal_1.default, { open: open, submitting: isSubmitting, title: "My Modal", onClose: handleOnClose, cancelButton: {
|
|
50
74
|
text: 'Cancel',
|
|
51
75
|
onClick: function () { return alert('You canceled it!'); },
|
|
52
76
|
}, okayButton: {
|
|
53
77
|
text: 'Okay',
|
|
54
|
-
onClick: function () {
|
|
55
|
-
|
|
78
|
+
onClick: function () {
|
|
79
|
+
alert('Okay!');
|
|
80
|
+
setIsSubmitting(true);
|
|
81
|
+
},
|
|
82
|
+
}, progressValue: progressValue }, "Hello there! How are you today?")));
|
|
56
83
|
};
|
|
57
84
|
exports.Modal = Modal;
|