'use client'; import clsx from 'clsx'; import { motion } from 'framer-motion'; import { useRef } from 'react'; import useEscapeKey from '@/hooks/useEscapeKey'; import { HelpTopic } from '@/models/miscellaneous'; import { animateModal } from '@/styling/animations'; import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/labels'; import { IconClose } from '../Icons'; import BadgeHelp from '../info/BadgeHelp'; import { CProps } from '../props'; import Button from './Button'; import MiniButton from './MiniButton'; import Overlay from './Overlay'; export interface ModalProps extends CProps.Styling { header?: string; submitText?: string; submitInvalidTooltip?: string; readonly?: boolean; canSubmit?: boolean; overflowVisible?: boolean; hideWindow: () => void; beforeSubmit?: () => boolean; onSubmit?: () => void; onCancel?: () => void; helpTopic?: HelpTopic; hideHelpWhen?: () => boolean; } function Modal({ children, header, submitText = 'Продолжить', submitInvalidTooltip, readonly, canSubmit, overflowVisible, hideWindow, beforeSubmit, onSubmit, onCancel, className, helpTopic, hideHelpWhen, ...restProps }: React.PropsWithChildren) { const ref = useRef(null); useEscapeKey(hideWindow); const handleCancel = () => { hideWindow(); if (onCancel) onCancel(); }; const handleSubmit = () => { if (beforeSubmit && !beforeSubmit()) { return; } if (onSubmit) onSubmit(); hideWindow(); }; return (
} onClick={handleCancel} /> {helpTopic && !hideHelpWhen?.() ? ( ) : null} {header ?

{header}

: null}
{children}
{!readonly ? (
); } export default Modal;