'use client'; import clsx from 'clsx'; import { motion } from 'framer-motion'; import { useRef } from 'react'; import useEscapeKey from '@/hooks/useEscapeKey'; import { animateModal } from '@/styling/animations'; import { prepareTooltip } from '@/utils/labels'; import { IconClose } from '../Icons'; 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; } function Modal({ header, hideWindow, beforeSubmit, onSubmit, readonly, onCancel, canSubmit, submitInvalidTooltip, className, children, overflowVisible, submitText = 'Продолжить', ...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} /> {header ?

{header}

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