import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
import { cva } from 'class-variance-authority';
import { cn } from '@/lib/utils';
import { AlertDialogTrigger, AlertDialogPortal } from '@/components/ui/Rocket/shadcn/alert-dialog';
// ── AlertDialog (root pass-through) ─────────────────────────────────────────
const AlertDialog = AlertDialogPrimitive.Root;
// ── AlertDialogOverlay ──────────────────────────────────────────────────────
const AlertDialogOverlay = forwardRef(function AlertDialogOverlay({ className, ...props }, ref) {
return (
);
});
AlertDialogOverlay.displayName = 'AlertDialogOverlay';
// ── AlertDialogContent ──────────────────────────────────────────────────────
const alertDialogContentVariants = cva(
[
'tw-bg-background-surface-layer-01',
'tw-shadow-elevation-400',
'tw-rounded-lg',
'tw-border-solid tw-border tw-border-border-weak',
'tw-flex tw-flex-col tw-gap-6',
'tw-p-6',
],
{
variants: {
size: {
default: 'tw-max-w-[460px]',
small: 'tw-max-w-[320px]',
},
},
defaultVariants: { size: 'default' },
}
);
const AlertDialogContent = forwardRef(function AlertDialogContent(
{ className, children, size, preventClose = true, ...props },
ref
) {
const handleInteractOutside = (e) => {
if (preventClose) e.preventDefault();
props.onInteractOutside?.(e);
};
const handleEscapeKeyDown = (e) => {
if (preventClose) e.preventDefault();
props.onEscapeKeyDown?.(e);
};
return (
{children}
);
});
AlertDialogContent.displayName = 'AlertDialogContent';
AlertDialogContent.propTypes = {
size: PropTypes.oneOf(['default', 'small']),
preventClose: PropTypes.bool,
className: PropTypes.string,
children: PropTypes.node,
};
// ── AlertDialogMedia ────────────────────────────────────────────────────────
// Icon or image slot. Placed inside AlertDialogHeader.
// Default size: uses media beside title on default, stacked on small.
function AlertDialogMedia({ className, children, ...props }) {
return (
{children}
);
}
AlertDialogMedia.displayName = 'AlertDialogMedia';
AlertDialogMedia.propTypes = {
className: PropTypes.string,
children: PropTypes.node,
};
// ── AlertDialogHeader ───────────────────────────────────────────────────────
// Groups media + title + description.
// Layout adapts based on size (via group-data) and media presence (via has-[]).
function AlertDialogHeader({ className, children, ...props }) {
return (
[data-slot=alert-dialog-media]]:tw-mb-1.5',
// When small: center text
'group-data-[size=small]/alert-dialog-content:tw-items-center group-data-[size=small]/alert-dialog-content:tw-text-center',
className
)}
{...props}
>
{children}
);
}
AlertDialogHeader.displayName = 'AlertDialogHeader';
// ── AlertDialogTitle ────────────────────────────────────────────────────────
const AlertDialogTitle = forwardRef(function AlertDialogTitle({ className, ...props }, ref) {
return (
);
});
AlertDialogTitle.displayName = 'AlertDialogTitle';
// ── AlertDialogDescription ──────────────────────────────────────────────────
const AlertDialogDescription = forwardRef(function AlertDialogDescription({ className, ...props }, ref) {
return (
);
});
AlertDialogDescription.displayName = 'AlertDialogDescription';
// ── AlertDialogFooter ───────────────────────────────────────────────────────
function AlertDialogFooter({ className, ...props }) {
return (
);
}
AlertDialogFooter.displayName = 'AlertDialogFooter';
// ── AlertDialogAction ───────────────────────────────────────────────────────
const AlertDialogAction = forwardRef(function AlertDialogAction({ className, ...props }, ref) {
return ;
});
AlertDialogAction.displayName = 'AlertDialogAction';
// ── AlertDialogCancel ───────────────────────────────────────────────────────
const AlertDialogCancel = forwardRef(function AlertDialogCancel({ className, ...props }, ref) {
return ;
});
AlertDialogCancel.displayName = 'AlertDialogCancel';
// ── Exports ─────────────────────────────────────────────────────────────────
export {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
alertDialogContentVariants,
AlertDialogOverlay,
AlertDialogMedia,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogAction,
AlertDialogCancel,
};