UNPKG

@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

27 lines 3.53 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ModalStandAlone = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const useId_1 = require("../../hooks/useId/useId"); const role_1 = require("../../types/role/role"); const footer_1 = require("../footer/footer"); const popoverControlled_1 = require("../popover/popoverControlled"); const component_1 = require("../popover/types/component"); const positionVariant_1 = require("../popover/types/positionVariant"); const modalHeader_1 = require("./fragments/modalHeader"); const modal_styled_1 = require("./modal.styled"); const onlyDesktopSize_1 = require("./utils/onlyDesktopSize"); const ModalStandAloneComponent = ({ dataTestId = 'modal', customHeightAllDevices = false, customWidthAllDevices = false, ...props }, ref) => { const uniqueModalId = (0, useId_1.useId)('modal'); const modalId = props.id ?? uniqueModalId; const uniqueTitleId = (0, useId_1.useId)('modal-title'); const titleIdFinal = props.title?.id ?? uniqueTitleId; const modalFooterVariant = props.footer?.variant ?? props.styles.footerVariant; return ((0, jsx_runtime_1.jsx)(popoverControlled_1.PopoverControlled, { "aria-labelledby": titleIdFinal, "aria-modal": props.open, clickOverlayClose: !props.blocked, component: component_1.PopoverComponentType.DIV, hasBackDrop: true, id: modalId, open: props.open, positionVariant: positionVariant_1.PopoverPositionVariantType.FIXED, role: role_1.ROLES.DIALOG, trapFocusInsideModal: true, variant: props.styles.popoverVariant, onCloseInternally: props.onPopoverCloseInternally, ...props.popover, children: (0, jsx_runtime_1.jsxs)(modal_styled_1.ModalStyled, { ref: ref, "$maxHeight": props.maxHeight, "$maxWidth": props.maxWidth, "$minHeight": customHeightAllDevices ? props.minHeight : (0, onlyDesktopSize_1.onlyDesktopSize)(props.device, props.minHeight), "$minWidth": customWidthAllDevices ? props.minWidth : (0, onlyDesktopSize_1.onlyDesktopSize)(props.device, props.minWidth), "$styles": props.styles, "data-testid": dataTestId, hasFooter: !!props.footer?.content, onKeyDown: props.onKeyDown, children: [(0, jsx_runtime_1.jsx)(modalHeader_1.ModalHeader, { blocked: props.blocked, closeButton: props.closeButton, closeIcon: props.closeIcon, device: props.device, dragIcon: props.dragIcon, styles: props.styles, title: props.title, titleIdFinal: titleIdFinal }), (0, jsx_runtime_1.jsx)(modal_styled_1.ModalContentStyled, { "data-modal-content": true, "$minContentHeight": props.minContentHeight, "$styles": props.styles, "aria-label": props.contentHasScroll ? props.contentScrollArias?.['aria-label'] : undefined, "aria-labelledby": props.contentHasScroll ? props.contentScrollArias?.['aria-labelledby'] : undefined, "data-testid": `${dataTestId}-content`, role: props.contentHasScroll ? role_1.ROLES.REGION : undefined, tabIndex: props.contentHasScroll ? 0 : undefined, children: props.content }), modalFooterVariant && props.footer?.content && ((0, jsx_runtime_1.jsx)(modal_styled_1.ModalFooterStyled, { "$styles": props.styles, children: (0, jsx_runtime_1.jsx)(footer_1.Footer, { variant: modalFooterVariant, ...props.footer, children: props.footer?.content }) }))] }) })); }; exports.ModalStandAlone = react_1.default.forwardRef(ModalStandAloneComponent); //# sourceMappingURL=modalStandAlone.js.map