| 1 | "use client"; |
| 2 | |
| 3 | import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; |
| 4 | import type * as React from "react"; |
| 5 | |
| 6 | import { buttonVariants } from "@/components/plate/ui/button"; |
| 7 | import { cn } from "@/lib/utils"; |
| 8 | |
| 9 | function AlertDialog({ |
| 10 | ...props |
| 11 | }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) { |
| 12 | return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />; |
| 13 | } |
| 14 | |
| 15 | function AlertDialogTrigger({ |
| 16 | ...props |
| 17 | }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) { |
| 18 | return ( |
| 19 | <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} /> |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | function AlertDialogPortal({ |
| 24 | ...props |
| 25 | }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) { |
| 26 | return ( |
| 27 | <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} /> |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | function AlertDialogOverlay({ |
| 32 | className, |
| 33 | ...props |
| 34 | }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) { |
| 35 | return ( |
| 36 | <AlertDialogPrimitive.Overlay |
| 37 | data-slot="alert-dialog-overlay" |
| 38 | className={cn( |
| 39 | "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", |
| 40 | className, |
| 41 | )} |
| 42 | {...props} |
| 43 | /> |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | function AlertDialogContent({ |
| 48 | className, |
| 49 | ...props |
| 50 | }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) { |
| 51 | return ( |
| 52 | <AlertDialogPortal> |
| 53 | <AlertDialogOverlay /> |
| 54 | <AlertDialogPrimitive.Content |
| 55 | data-slot="alert-dialog-content" |
| 56 | className={cn( |
| 57 | "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", |
| 58 | className, |
| 59 | )} |
| 60 | {...props} |
| 61 | /> |
| 62 | </AlertDialogPortal> |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | function AlertDialogHeader({ |
| 67 | className, |
| 68 | ...props |
| 69 | }: React.ComponentProps<"div">) { |
| 70 | return ( |
| 71 | <div |
| 72 | data-slot="alert-dialog-header" |
| 73 | className={cn("flex flex-col gap-2 text-center sm:text-left", className)} |
| 74 | {...props} |
| 75 | /> |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | function AlertDialogFooter({ |
| 80 | className, |
| 81 | ...props |
| 82 | }: React.ComponentProps<"div">) { |
| 83 | return ( |
| 84 | <div |
| 85 | data-slot="alert-dialog-footer" |
| 86 | className={cn( |
| 87 | "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", |
| 88 | className, |
| 89 | )} |
| 90 | {...props} |
| 91 | /> |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | function AlertDialogTitle({ |
| 96 | className, |
| 97 | ...props |
| 98 | }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) { |
| 99 | return ( |
| 100 | <AlertDialogPrimitive.Title |
| 101 | data-slot="alert-dialog-title" |
| 102 | className={cn("text-lg font-semibold", className)} |
| 103 | {...props} |
| 104 | /> |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | function AlertDialogDescription({ |
| 109 | className, |
| 110 | ...props |
| 111 | }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) { |
| 112 | return ( |
| 113 | <AlertDialogPrimitive.Description |
| 114 | data-slot="alert-dialog-description" |
| 115 | className={cn("text-sm text-muted-foreground", className)} |
| 116 | {...props} |
| 117 | /> |
| 118 | ); |
| 119 | } |
| 120 | |
| 121 | function AlertDialogAction({ |
| 122 | className, |
| 123 | ...props |
| 124 | }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) { |
| 125 | return ( |
| 126 | <AlertDialogPrimitive.Action |
| 127 | className={cn(buttonVariants(), className)} |
| 128 | {...props} |
| 129 | /> |
| 130 | ); |
| 131 | } |
| 132 | |
| 133 | function AlertDialogCancel({ |
| 134 | className, |
| 135 | ...props |
| 136 | }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) { |
| 137 | return ( |
| 138 | <AlertDialogPrimitive.Cancel |
| 139 | className={cn(buttonVariants({ variant: "outline" }), className)} |
| 140 | {...props} |
| 141 | /> |
| 142 | ); |
| 143 | } |
| 144 | |
| 145 | export { |
| 146 | AlertDialog, |
| 147 | AlertDialogAction, |
| 148 | AlertDialogCancel, |
| 149 | AlertDialogContent, |
| 150 | AlertDialogDescription, |
| 151 | AlertDialogFooter, |
| 152 | AlertDialogHeader, |
| 153 | AlertDialogPortal, |
| 154 | AlertDialogTitle, |
| 155 | AlertDialogTrigger, |
| 156 | }; |
| 157 |