| 1 | "use client"; |
| 2 | |
| 3 | import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; |
| 4 | import * as React from "react"; |
| 5 | |
| 6 | import { buttonVariants } from "@/components/ui/button"; |
| 7 | import { cn } from "@/lib/utils"; |
| 8 | |
| 9 | const AlertDialog = AlertDialogPrimitive.Root; |
| 10 | |
| 11 | const AlertDialogTrigger = AlertDialogPrimitive.Trigger; |
| 12 | |
| 13 | const AlertDialogPortal = AlertDialogPrimitive.Portal; |
| 14 | |
| 15 | const AlertDialogOverlay = React.forwardRef< |
| 16 | React.ElementRef<typeof AlertDialogPrimitive.Overlay>, |
| 17 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay> |
| 18 | >(({ className, ...props }, ref) => ( |
| 19 | <AlertDialogPrimitive.Overlay |
| 20 | className={cn( |
| 21 | "fixed inset-0 z-50 bg-black/80 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", |
| 22 | className, |
| 23 | )} |
| 24 | {...props} |
| 25 | ref={ref} |
| 26 | /> |
| 27 | )); |
| 28 | AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; |
| 29 | |
| 30 | const AlertDialogContent = React.forwardRef< |
| 31 | React.ElementRef<typeof AlertDialogPrimitive.Content>, |
| 32 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> |
| 33 | >(({ className, ...props }, ref) => ( |
| 34 | <AlertDialogPortal> |
| 35 | <AlertDialogOverlay /> |
| 36 | <AlertDialogPrimitive.Content |
| 37 | ref={ref} |
| 38 | className={cn( |
| 39 | "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg", |
| 40 | className, |
| 41 | )} |
| 42 | {...props} |
| 43 | /> |
| 44 | </AlertDialogPortal> |
| 45 | )); |
| 46 | AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; |
| 47 | |
| 48 | const AlertDialogHeader = ({ |
| 49 | className, |
| 50 | ...props |
| 51 | }: React.HTMLAttributes<HTMLDivElement>) => ( |
| 52 | <div |
| 53 | className={cn( |
| 54 | "flex flex-col space-y-2 text-center sm:text-left", |
| 55 | className, |
| 56 | )} |
| 57 | {...props} |
| 58 | /> |
| 59 | ); |
| 60 | AlertDialogHeader.displayName = "AlertDialogHeader"; |
| 61 | |
| 62 | const AlertDialogFooter = ({ |
| 63 | className, |
| 64 | ...props |
| 65 | }: React.HTMLAttributes<HTMLDivElement>) => ( |
| 66 | <div |
| 67 | className={cn( |
| 68 | "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", |
| 69 | className, |
| 70 | )} |
| 71 | {...props} |
| 72 | /> |
| 73 | ); |
| 74 | AlertDialogFooter.displayName = "AlertDialogFooter"; |
| 75 | |
| 76 | const AlertDialogTitle = React.forwardRef< |
| 77 | React.ElementRef<typeof AlertDialogPrimitive.Title>, |
| 78 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title> |
| 79 | >(({ className, ...props }, ref) => ( |
| 80 | <AlertDialogPrimitive.Title |
| 81 | ref={ref} |
| 82 | className={cn("text-lg font-semibold", className)} |
| 83 | {...props} |
| 84 | /> |
| 85 | )); |
| 86 | AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; |
| 87 | |
| 88 | const AlertDialogDescription = React.forwardRef< |
| 89 | React.ElementRef<typeof AlertDialogPrimitive.Description>, |
| 90 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description> |
| 91 | >(({ className, ...props }, ref) => ( |
| 92 | <AlertDialogPrimitive.Description |
| 93 | ref={ref} |
| 94 | className={cn("text-sm text-muted-foreground", className)} |
| 95 | {...props} |
| 96 | /> |
| 97 | )); |
| 98 | AlertDialogDescription.displayName = |
| 99 | AlertDialogPrimitive.Description.displayName; |
| 100 | |
| 101 | const AlertDialogAction = React.forwardRef< |
| 102 | React.ElementRef<typeof AlertDialogPrimitive.Action>, |
| 103 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> |
| 104 | >(({ className, ...props }, ref) => ( |
| 105 | <AlertDialogPrimitive.Action |
| 106 | ref={ref} |
| 107 | className={cn(buttonVariants(), className)} |
| 108 | {...props} |
| 109 | /> |
| 110 | )); |
| 111 | AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; |
| 112 | |
| 113 | const AlertDialogCancel = React.forwardRef< |
| 114 | React.ElementRef<typeof AlertDialogPrimitive.Cancel>, |
| 115 | React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> |
| 116 | >(({ className, ...props }, ref) => ( |
| 117 | <AlertDialogPrimitive.Cancel |
| 118 | ref={ref} |
| 119 | className={cn( |
| 120 | buttonVariants({ variant: "outline" }), |
| 121 | "mt-2 sm:mt-0", |
| 122 | className, |
| 123 | )} |
| 124 | {...props} |
| 125 | /> |
| 126 | )); |
| 127 | AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; |
| 128 | |
| 129 | export { |
| 130 | AlertDialog, |
| 131 | AlertDialogAction, |
| 132 | AlertDialogCancel, |
| 133 | AlertDialogContent, |
| 134 | AlertDialogDescription, |
| 135 | AlertDialogFooter, |
| 136 | AlertDialogHeader, |
| 137 | AlertDialogOverlay, |
| 138 | AlertDialogPortal, |
| 139 | AlertDialogTitle, |
| 140 | AlertDialogTrigger, |
| 141 | }; |
| 142 |