@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
29 lines • 2.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorBoundaryModal = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const CloseSvg_1 = require("./CloseSvg");
const errorBoundaryModal_styled_1 = require("./errorBoundaryModal.styled");
const ErrorBoundaryModal = ({ errors, onClose, open = true }) => {
const [info, setInfo] = react_1.default.useState(0);
const onClickPrev = () => {
const to = Math.max(0, info - 1);
setInfo(to);
};
const onClickNext = () => {
const to = Math.min(errors.length - 1, info + 1);
setInfo(to);
};
if (!open) {
return null;
}
const disableLeft = info <= 0;
const disableRight = info >= errors.length - 1;
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.OverlayStyled, {}), (0, jsx_runtime_1.jsxs)(errorBoundaryModal_styled_1.ModalStyled, { children: [(0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.CloseButtonContainerStyled, { children: (0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.CloseButtonStyled, { "aria-label": "Close Icon", onClick: onClose, children: (0, jsx_runtime_1.jsx)(CloseSvg_1.CloseSvg, {}) }) }), (0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.TitleStyled, { children: errors[info].error }), (0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.DescriptionStyled, { children: errors[info].errorInfo }), (0, jsx_runtime_1.jsxs)(errorBoundaryModal_styled_1.FooterStyled, { children: [(0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.FooterButtonStyled, { disabled: disableLeft, onClick: onClickPrev, children: "prev" }), (0, jsx_runtime_1.jsxs)(errorBoundaryModal_styled_1.FooterPageStyled, { children: [info + 1, "/", errors.length] }), (0, jsx_runtime_1.jsx)(errorBoundaryModal_styled_1.FooterButtonStyled, { disabled: disableRight, onClick: onClickNext, children: "next" })] })] })] }));
};
exports.ErrorBoundaryModal = ErrorBoundaryModal;
//# sourceMappingURL=errorBoundaryModal.js.map