|
| 1 | +"use client" |
| 2 | + |
| 3 | +import * as React from "react" |
| 4 | +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" |
| 5 | + |
| 6 | +import { cn } from "@/lib/utils" |
| 7 | +import { buttonVariants } from "@/components/ui/button" |
| 8 | + |
| 9 | +function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) { |
| 10 | + return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} /> |
| 11 | +} |
| 12 | + |
| 13 | +function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) { |
| 14 | + return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} /> |
| 15 | +} |
| 16 | + |
| 17 | +function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) { |
| 18 | + return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} /> |
| 19 | +} |
| 20 | + |
| 21 | +function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) { |
| 22 | + return ( |
| 23 | + <AlertDialogPrimitive.Overlay |
| 24 | + data-slot="alert-dialog-overlay" |
| 25 | + className={cn( |
| 26 | + "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", |
| 27 | + className, |
| 28 | + )} |
| 29 | + {...props} |
| 30 | + /> |
| 31 | + ) |
| 32 | +} |
| 33 | + |
| 34 | +function AlertDialogContent({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) { |
| 35 | + return ( |
| 36 | + <AlertDialogPortal> |
| 37 | + <AlertDialogOverlay /> |
| 38 | + <AlertDialogPrimitive.Content |
| 39 | + data-slot="alert-dialog-content" |
| 40 | + className={cn( |
| 41 | + "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 p-6 shadow-lg duration-200 sm:max-w-lg", |
| 42 | + className, |
| 43 | + )} |
| 44 | + {...props} |
| 45 | + /> |
| 46 | + </AlertDialogPortal> |
| 47 | + ) |
| 48 | +} |
| 49 | + |
| 50 | +function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 51 | + return ( |
| 52 | + <div |
| 53 | + data-slot="alert-dialog-header" |
| 54 | + className={cn("flex flex-col gap-2 text-center sm:text-left", className)} |
| 55 | + {...props} |
| 56 | + /> |
| 57 | + ) |
| 58 | +} |
| 59 | + |
| 60 | +function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) { |
| 61 | + return ( |
| 62 | + <div |
| 63 | + data-slot="alert-dialog-footer" |
| 64 | + className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)} |
| 65 | + {...props} |
| 66 | + /> |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) { |
| 71 | + return ( |
| 72 | + <AlertDialogPrimitive.Title |
| 73 | + data-slot="alert-dialog-title" |
| 74 | + className={cn("text-lg font-semibold", className)} |
| 75 | + {...props} |
| 76 | + /> |
| 77 | + ) |
| 78 | +} |
| 79 | + |
| 80 | +function AlertDialogDescription({ |
| 81 | + className, |
| 82 | + ...props |
| 83 | +}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) { |
| 84 | + return ( |
| 85 | + <AlertDialogPrimitive.Description |
| 86 | + data-slot="alert-dialog-description" |
| 87 | + className={cn("text-muted-foreground text-sm", className)} |
| 88 | + {...props} |
| 89 | + /> |
| 90 | + ) |
| 91 | +} |
| 92 | + |
| 93 | +function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) { |
| 94 | + return <AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} /> |
| 95 | +} |
| 96 | + |
| 97 | +function AlertDialogCancel({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) { |
| 98 | + return <AlertDialogPrimitive.Cancel className={cn(buttonVariants({ variant: "outline" }), className)} {...props} /> |
| 99 | +} |
| 100 | + |
| 101 | +export { |
| 102 | + AlertDialog, |
| 103 | + AlertDialogPortal, |
| 104 | + AlertDialogOverlay, |
| 105 | + AlertDialogTrigger, |
| 106 | + AlertDialogContent, |
| 107 | + AlertDialogHeader, |
| 108 | + AlertDialogFooter, |
| 109 | + AlertDialogTitle, |
| 110 | + AlertDialogDescription, |
| 111 | + AlertDialogAction, |
| 112 | + AlertDialogCancel, |
| 113 | +} |
0 commit comments