import React, { useEffect } from 'react'; import classNames from 'classnames'; import { SessionIconButton, SessionIconSize, SessionIconType } from './icon/'; import { SessionButton, SessionButtonColor, SessionButtonType } from './SessionButton'; import { DefaultTheme, useTheme } from 'styled-components'; // tslint:disable-next-line: no-submodule-imports import useKey from 'react-use/lib/useKey'; type Props = { title: string; onClose: any; showExitIcon?: boolean; showHeader?: boolean; headerReverse?: boolean; //Maximum of two icons or buttons in header headerIconButtons?: Array<{ iconType: SessionIconType; iconRotation: number; onClick?: any; }>; headerButtons?: Array<{ buttonType: SessionButtonType; buttonColor: SessionButtonColor; text: string; onClick?: any; }>; theme: DefaultTheme; }; export type SessionWrapperModalType = { title?: string; showHeader?: boolean; onConfirm?: () => void; onClose?: () => void; showClose?: boolean; confirmText?: string; cancelText?: string; showExitIcon?: boolean; headerIconButtons?: Array; children: any; headerReverse?: boolean; additionalClassName?: string; }; export const SessionWrapperModal = (props: SessionWrapperModalType) => { const { title, onConfirm, onClose, showHeader = true, showClose = false, confirmText, cancelText, showExitIcon, headerIconButtons, headerReverse, additionalClassName, } = props; const theme = useTheme(); useKey( 'Esc', () => { props.onClose?.(); }, undefined, [props.onClose] ); useKey( 'Escape', () => { props.onClose?.(); }, undefined, [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}
); };