@novin-dev/formalite
Version:
Generate MUI form with few line of code
40 lines (37 loc) • 1.82 kB
JavaScript
import { useI18nContext } from './I18nProvider.js';
import { styled, Box, alpha, Button, Typography } from '@mui/material';
import React from 'react';
import { ErrorBoundary } from 'react-error-boundary';
var FallBackContainer = styled(Box)(function (_a) {
var theme = _a.theme;
var isLight = theme.palette.mode === "light";
return {
backgroundColor: isLight
? alpha(theme.palette.error.main, 0.08)
: alpha(theme.palette.error.main, 0.16),
color: theme.palette.error.main,
minHeight: "18.75rem",
};
});
var FallBackButton = styled(Button)(function (_a) {
var theme = _a.theme;
return ({
textDecoration: "underline",
fontWeight: theme.typography.fontWeightRegular,
});
});
var FallBack = function (_a) {
_a.error; var resetErrorBoundary = _a.resetErrorBoundary;
var t = useI18nContext().t;
return (React.createElement(FallBackContainer, { display: "flex", justifyContent: "center", alignItems: "center", width: "100%", height: "100%" },
React.createElement(Box, { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center" },
React.createElement(Typography, { variant: "h4", sx: { marginBottom: "1rem" } }, t("error_boundary_title")),
React.createElement(Typography, { variant: "body1" }, t("error_boundary_body")),
React.createElement(FallBackButton, { color: "error", onClick: function () { return resetErrorBoundary(); } }, t("error_boundary_btn")))));
};
var ErrorBoundaryWrapper = function (_a) {
var children = _a.children;
return React.createElement(ErrorBoundary, { FallbackComponent: FallBack }, children);
};
export { ErrorBoundaryWrapper as default };
//# sourceMappingURL=ErrorBoundary.js.map