@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
22 lines • 1.55 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React from 'react';
import { CloseSvg } from './CloseSvg';
import { CloseButtonContainerStyled, CloseButtonStyled, DescriptionStyled, FooterButtonStyled, FooterPageStyled, FooterStyled, ModalStyled, OverlayStyled, TitleStyled, } from './errorBoundaryModal.styled';
export const ErrorBoundaryModal = ({ errors, onClose, open = true }) => {
const [info, setInfo] = React.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 (_jsxs(_Fragment, { children: [_jsx(OverlayStyled, {}), _jsxs(ModalStyled, { children: [_jsx(CloseButtonContainerStyled, { children: _jsx(CloseButtonStyled, { "aria-label": "Close Icon", onClick: onClose, children: _jsx(CloseSvg, {}) }) }), _jsx(TitleStyled, { children: errors[info].error }), _jsx(DescriptionStyled, { children: errors[info].errorInfo }), _jsxs(FooterStyled, { children: [_jsx(FooterButtonStyled, { disabled: disableLeft, onClick: onClickPrev, children: "prev" }), _jsxs(FooterPageStyled, { children: [info + 1, "/", errors.length] }), _jsx(FooterButtonStyled, { disabled: disableRight, onClick: onClickNext, children: "next" })] })] })] }));
};
//# sourceMappingURL=errorBoundaryModal.js.map