import { IconAlertTriangle } from '@tabler/icons-react';
/**
* ConfirmDialog - упрощённая версия для быстрых подтверждений
* Простой подход со встроенным backdrop (как в HistoryModal)
*/
export default function ConfirmDialog({
open,
title = 'Подтверждение',
message,
confirmText = 'Подтвердить',
cancelText = 'Отмена',
onConfirm,
onCancel,
destructive = false,
size = 'sm',
loading = false
}) {
if (!open) return null;
const handleBackdropClick = (e) => {
if (e.target === e.currentTarget) {
onCancel?.();
}
};
return (
<>
{/* Modal Backdrop */}
{/* Modal */}
{ if (e.key === 'Escape') onCancel?.(); }}
>
{
if (e.key === 'Tab') {
const c = e.currentTarget;
const focusable = c.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
if (!focusable || focusable.length === 0) return;
const first = focusable[0];
const last = focusable[focusable.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
}
}}
>
{title}
>
);
}