| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; |
| 3 |
import { FocusTrap } from '../../helpers'; |
| 4 |
import bullsEyeStyles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye.mjs'; |
| 5 |
import { css } from '@patternfly/react-styles'; |
| 6 |
import { getOUIAProps } from '../../helpers'; |
| 7 |
import { Backdrop } from '../Backdrop'; |
| 8 |
import { ModalBoxCloseButton } from './ModalBoxCloseButton'; |
| 9 |
import { ModalBox } from './ModalBox'; |
| 10 |
export const ModalContent = (_a) => { |
| 11 |
var { backdropClassName, children, className, isOpen = false, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby, onClose, variant = 'default', position, positionOffset, width, maxWidth, boxId, backdropId, disableFocusTrap = false, ouiaId, ouiaSafe = true, elementToFocus, focusTrapId } = _a, props = __rest(_a, ["backdropClassName", "children", "className", "isOpen", 'aria-label', 'aria-describedby', 'aria-labelledby', "onClose", "variant", "position", "positionOffset", "width", "maxWidth", "boxId", "backdropId", "disableFocusTrap", "ouiaId", "ouiaSafe", "elementToFocus", "focusTrapId"]); |
| 12 |
if (!isOpen) { |
| 13 |
return null; |
| 14 |
} |
| 15 |
const getAriaLabelledBy = () => { |
| 16 |
if (ariaLabelledby) { |
| 17 |
return ariaLabelledby; |
| 18 |
} |
| 19 |
if (ariaLabel) { |
| 20 |
return undefined; |
| 21 |
} |
| 22 |
return boxId; |
| 23 |
}; |
| 24 |
const modalBox = (_jsxs(ModalBox, Object.assign({ className: css(className), variant: variant, position: position, positionOffset: positionOffset, "aria-label": ariaLabel, "aria-labelledby": getAriaLabelledBy(), "aria-describedby": ariaDescribedby }, getOUIAProps(ModalContent.displayName, ouiaId, ouiaSafe), { style: Object.assign(Object.assign({}, (width && { '--pf-v6-c-modal-box--Width': typeof width !== 'number' ? width : `${width}px` })), (maxWidth && { |
| 25 |
'--pf-v6-c-modal-box--MaxWidth': typeof maxWidth !== 'number' ? maxWidth : `${maxWidth}px` |
| 26 |
})) }, props, { id: boxId, children: [onClose && _jsx(ModalBoxCloseButton, { onClose: (event) => onClose(event), ouiaId: ouiaId }), children] }))); |
| 27 |
return (_jsx(Backdrop, { className: css(backdropClassName), id: backdropId, children: _jsx(FocusTrap, { active: !disableFocusTrap, focusTrapOptions: { |
| 28 |
clickOutsideDeactivates: true, |
| 29 |
tabbableOptions: { displayCheck: 'none' }, |
| 30 |
// FocusTrap's initialFocus can accept false as a value to prevent initial focus. |
| 31 |
// We want to prevent this in case false is ever passed in. |
| 32 |
initialFocus: elementToFocus || undefined |
| 33 |
}, className: css(bullsEyeStyles.bullseye), id: focusTrapId, children: modalBox }) })); |
| 34 |
}; |
| 35 |
ModalContent.displayName = 'ModalContent'; |
| 36 |
//# sourceMappingURL=ModalContent.js.map |