1 | import { __rest } from "tslib";
|
2 | import * as React from 'react';
|
3 | import { FocusTrap } from '../../helpers';
|
4 | import modalStyles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
5 | import bullsEyeStyles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
|
6 | import { css } from '@patternfly/react-styles';
|
7 | import { getOUIAProps } from '../../helpers';
|
8 | import { Backdrop } from '../Backdrop/Backdrop';
|
9 | import { ModalBoxBody } from './ModalBoxBody';
|
10 | import { ModalBoxCloseButton } from './ModalBoxCloseButton';
|
11 | import { ModalBox } from './ModalBox';
|
12 | import { ModalBoxFooter } from './ModalBoxFooter';
|
13 | import { ModalBoxDescription } from './ModalBoxDescription';
|
14 | import { ModalBoxHeader } from './ModalBoxHeader';
|
15 | import { ModalBoxTitle, isVariantIcon } from './ModalBoxTitle';
|
16 | export const ModalContent = (_a) => {
|
17 | var { children, className = '', isOpen = false, header = null, help = null, description = null, title = '', titleIconVariant = null, titleLabel = '', 'aria-label': ariaLabel = '', 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby, bodyAriaLabel, bodyAriaRole, showClose = true, footer = null, actions = [], onClose = () => undefined, variant = 'default', position, positionOffset, width = -1, boxId, labelId, descriptorId, disableFocusTrap = false, hasNoBodyWrapper = false, ouiaId, ouiaSafe = true } = _a, props = __rest(_a, ["children", "className", "isOpen", "header", "help", "description", "title", "titleIconVariant", "titleLabel", 'aria-label', 'aria-describedby', 'aria-labelledby', "bodyAriaLabel", "bodyAriaRole", "showClose", "footer", "actions", "onClose", "variant", "position", "positionOffset", "width", "boxId", "labelId", "descriptorId", "disableFocusTrap", "hasNoBodyWrapper", "ouiaId", "ouiaSafe"]);
|
18 | if (!isOpen) {
|
19 | return null;
|
20 | }
|
21 | const modalBoxHeader = header ? (React.createElement(ModalBoxHeader, { help: help }, header)) : (title && (React.createElement(ModalBoxHeader, { help: help },
|
22 | React.createElement(ModalBoxTitle, { title: title, titleIconVariant: titleIconVariant, titleLabel: titleLabel, id: labelId }),
|
23 | description && React.createElement(ModalBoxDescription, { id: descriptorId }, description))));
|
24 | const modalBoxFooter = footer ? (React.createElement(ModalBoxFooter, null, footer)) : (actions.length > 0 && React.createElement(ModalBoxFooter, null, actions));
|
25 | const defaultModalBodyAriaRole = bodyAriaLabel ? 'region' : undefined;
|
26 | const modalBody = hasNoBodyWrapper ? (children) : (React.createElement(ModalBoxBody, Object.assign({ "aria-label": bodyAriaLabel, role: bodyAriaRole || defaultModalBodyAriaRole }, props, (!description && !ariaDescribedby && { id: descriptorId })), children));
|
27 | const boxStyle = width === -1 ? {} : { width };
|
28 | const ariaLabelledbyFormatted = () => {
|
29 | if (ariaLabelledby === null) {
|
30 | return null;
|
31 | }
|
32 | const idRefList = [];
|
33 | if ((ariaLabel && boxId) !== '') {
|
34 | idRefList.push(ariaLabel && boxId);
|
35 | }
|
36 | if (ariaLabelledby) {
|
37 | idRefList.push(ariaLabelledby);
|
38 | }
|
39 | if (title) {
|
40 | idRefList.push(labelId);
|
41 | }
|
42 | return idRefList.join(' ');
|
43 | };
|
44 | const modalBox = (React.createElement(ModalBox, Object.assign({ id: boxId, style: boxStyle, className: css(className, isVariantIcon(titleIconVariant) &&
|
45 | modalStyles.modifiers[titleIconVariant]), variant: variant, position: position, positionOffset: positionOffset, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledbyFormatted(), "aria-describedby": ariaDescribedby || (hasNoBodyWrapper ? null : descriptorId) }, getOUIAProps(ModalContent.displayName, ouiaId, ouiaSafe)),
|
46 | showClose && React.createElement(ModalBoxCloseButton, { onClose: onClose, ouiaId: ouiaId }),
|
47 | modalBoxHeader,
|
48 | modalBody,
|
49 | modalBoxFooter));
|
50 | return (React.createElement(Backdrop, null,
|
51 | React.createElement(FocusTrap, { active: !disableFocusTrap, focusTrapOptions: { clickOutsideDeactivates: true }, className: css(bullsEyeStyles.bullseye) }, modalBox)));
|
52 | };
|
53 | ModalContent.displayName = 'ModalContent';
|
54 |
|
\ | No newline at end of file |