'use client'; import clsx from 'clsx'; import { motion } from 'framer-motion'; import { useRef } from 'react'; import { BiX } from 'react-icons/bi'; import useEscapeKey from '@/hooks/useEscapeKey'; import { animateModal } from '@/utils/animations'; 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; hideWindow: () => void; onSubmit?: () => void; onCancel?: () => void; children: React.ReactNode; } function Modal({ header, hideWindow, onSubmit, readonly, onCancel, canSubmit, submitInvalidTooltip, className, children, submitText = 'Продолжить', ...restProps }: ModalProps) { const ref = useRef(null); useEscapeKey(hideWindow); const handleCancel = () => { hideWindow(); if (onCancel) onCancel(); }; const handleSubmit = () => { hideWindow(); if (onSubmit) onSubmit(); }; return ( <>