import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { type VariantProps, cva } from "class-variance-authority";
import { cn } from "@/lib/utils";
import {
AlertDialog as ShadcnAlertDialog,
AlertDialogTrigger as ShadcnAlertDialogTrigger,
AlertDialogContent as ShadcnAlertDialogContent,
AlertDialogDescription as ShadcnAlertDialogDescription,
AlertDialogFooter as ShadcnAlertDialogFooter,
AlertDialogHeader as ShadcnAlertDialogHeader,
AlertDialogOverlay as ShadcnAlertDialogOverlay,
AlertDialogPortal as ShadcnAlertDialogPortal,
AlertDialogTitle as ShadcnAlertDialogTitle,
} from "@/components/ui/alert-dialog";
import "@/components/ui/pixelact-ui/styles/styles.css";
export const alertDialogVariants = cva("", {
variants: {
font: {
normal: "",
pixel: "pixel-font",
},
},
defaultVariants: {
font: "pixel",
},
});
export interface AlertDialogProps
extends React.ComponentProps<typeof AlertDialogPrimitive.Root>,
VariantProps<typeof alertDialogVariants> {}
function AlertDialog({ ...props }: AlertDialogProps) {
return <ShadcnAlertDialog {...props} />;
}
function AlertDialogTrigger({
className,
asChild = true,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
return (
<ShadcnAlertDialogTrigger
className={cn(className)}
asChild={asChild}
{...props}
/>
);
}
function AlertDialogPortal({
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
return <ShadcnAlertDialogPortal {...props} />;
}
function AlertDialogOverlay({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
return <ShadcnAlertDialogOverlay className={cn(className)} {...props} />;
}
interface AlertDialogContentProps
extends React.ComponentProps<typeof AlertDialogPrimitive.Content>,
VariantProps<typeof alertDialogVariants> {}
function AlertDialogContent({
className,
children,
font,
...props
}: AlertDialogContentProps) {
return (
<AlertDialogPortal>
<AlertDialogOverlay />
<>
<ShadcnAlertDialogContent
className={cn(
"rounded-none shadow-(--pixel-box-shadow) box-shadow-margin",
alertDialogVariants({ font }),
className
)}
{...props}
>
{children}
</ShadcnAlertDialogContent>
</>
</AlertDialogPortal>
);
}
function AlertDialogHeader({
className,
...props
}: React.ComponentProps<"div">) {
return <ShadcnAlertDialogHeader className={cn(className)} {...props} />;
}
function AlertDialogFooter({
className,
...props
}: React.ComponentProps<"div">) {
return (
<ShadcnAlertDialogFooter
className={cn(
"flex flex-col-reverse sm:flex-row gap-4 sm:items-center sm:justify-end",
className
)}
{...props}
/>
);
}
function AlertDialogTitle({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
return (
<ShadcnAlertDialogTitle
className={cn("font-normal text-foreground", className)}
{...props}
/>
);
}
function AlertDialogDescription({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
return <ShadcnAlertDialogDescription className={cn(className)} {...props} />;
}
function AlertDialogAction({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
return (
<ShadcnAlertDialogTrigger
className={cn("w-full md:w-auto", className)}
{...props}
/>
);
}
function AlertDialogCancel({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
return (
<ShadcnAlertDialogTrigger
className={cn("w-full md:w-auto", className)}
{...props}
/>
);
}
export {
AlertDialog,
AlertDialogPortal,
AlertDialogOverlay,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
};