import React from 'react'; import * as ReactDOM from 'react-dom'; import './Modal.scss'; import { Button } from '../../core'; import { FontAwesomeIcon as Icon } from '@fortawesome/react-fontawesome'; import { faTimes } from '@fortawesome/free-solid-svg-icons'; export interface IModal { title: string; onClose: () => void; children: JSX.Element | JSX.Element[] | string; show: boolean; onSave?: () => void; showNewButton?: boolean; newButtonText?: string; onNewButtonClick?: () => void; autoFocus?: boolean; isSuccessButtonEnabled?: boolean; isNewButtonEnabled?: boolean; showButtons?: boolean; customClass?: string; successButtonText?: string; cancelButtonText?: string; hideCloseIcon?: boolean; disablePortal?: boolean; hideCancelButton?: boolean; left?: string; top?: string; height?: string; // valid css height value: ex- 100px width?: string; // valid css width value: ex- 100px references?: { modal?: any; modalHeader?: any; rightResizer?: any; bottomResizer?: any; }; isResizable?: boolean; isDragging?: boolean; extraModalButtons?: any[]; customWidth?: number; customMarginLeft?: number; } export const Modal = ({ title, onClose, children, show, onSave, showNewButton, newButtonText, onNewButtonClick, customClass = '', autoFocus = false, showButtons = true, isNewButtonEnabled = true, isSuccessButtonEnabled = true, successButtonText = 'Save', cancelButtonText = 'Cancel', hideCloseIcon = false, disablePortal = false, hideCancelButton = false, left, top, height, width, references, isResizable, extraModalButtons, customWidth, customMarginLeft }: IModal) => { const getModalStyle = () => { const styleObj: any = { left, top }; width && (styleObj.width = width); if (height) { styleObj.height = height; styleObj.maxHeight = height; } if (customWidth) { styleObj.width = customWidth; } if (customMarginLeft) { styleObj.marginLeft = customMarginLeft; } return styleObj; }; const getModalComponent = () => (
{title}
{extraModalButtons?.map((item, index) => (