import classNames from 'classnames'; import React, { useRef } from 'react'; import useKey from 'react-use/lib/useKey'; import { SessionIconButton } from './icon'; import { SessionButton, SessionButtonColor, SessionButtonType } from './basic/SessionButton'; import { SessionFocusTrap } from './SessionFocusTrap'; export type SessionWrapperModalType = { title?: string; showHeader?: boolean; onConfirm?: () => void; onClose?: () => void; showClose?: boolean; confirmText?: string; cancelText?: string; showExitIcon?: boolean; headerIconButtons?: Array; children: React.ReactNode; headerReverse?: boolean; additionalClassName?: string; }; export const SessionWrapperModal = (props: SessionWrapperModalType) => { const { title, onConfirm, onClose, showHeader = true, showClose = false, confirmText, cancelText, showExitIcon, headerIconButtons, headerReverse, additionalClassName, } = props; useKey( 'Esc', () => { props.onClose?.(); }, undefined, [props.onClose] ); useKey( 'Escape', () => { props.onClose?.(); }, undefined, [props.onClose] ); const modalRef = useRef(null); const handleClick = (e: any) => { if (!modalRef.current?.contains(e.target)) { props.onClose?.(); } }; return (
{showHeader ? (
{showExitIcon ? ( ) : null}
{title}
{headerIconButtons ? headerIconButtons.map((iconItem: any) => { return ( ); }) : null}
) : null}
{props.children}
{onConfirm ? ( {confirmText || window.i18n('ok')} ) : null} {onClose && showClose ? ( {cancelText || window.i18n('close')} ) : null}
); };