import React, { useEffect, useRef } from 'react'; interface ConfirmModalProps { open: boolean; onClose: () => void; onConfirm: () => void; title: string; message: string; confirmLabel?: string; danger?: boolean; } export default function ConfirmModal({ open, onClose, onConfirm, title, message, confirmLabel = 'Bestätigen', danger = false, }: ConfirmModalProps) { const cancelRef = useRef(null); const confirmRef = useRef(null); useEffect(() => { if (!open) return; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } if (e.key === 'Tab') { if (e.shiftKey) { if (document.activeElement === cancelRef.current) { e.preventDefault(); confirmRef.current?.focus(); } } else { if (document.activeElement === confirmRef.current) { e.preventDefault(); cancelRef.current?.focus(); } } } }; window.addEventListener('keydown', handleKeyDown); cancelRef.current?.focus(); return () => window.removeEventListener('keydown', handleKeyDown); }, [open, onClose]); if (!open) return null; return (
e.stopPropagation()} >

{message}

); }