|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import * as React from "react"; |
| 4 | +import * as DialogPrimitive from "@radix-ui/react-dialog"; |
| 5 | +import { cn } from "~~/utils/cn"; |
| 6 | + |
| 7 | +const Dialog = DialogPrimitive.Root; |
| 8 | + |
| 9 | +const DialogTrigger = DialogPrimitive.Trigger; |
| 10 | + |
| 11 | +const DialogPortal = DialogPrimitive.Portal; |
| 12 | + |
| 13 | +const DialogClose = DialogPrimitive.Close; |
| 14 | + |
| 15 | +const DialogOverlay = React.forwardRef< |
| 16 | + React.ElementRef<typeof DialogPrimitive.Overlay>, |
| 17 | + React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> |
| 18 | +>(({ className, ...props }, ref) => ( |
| 19 | + <DialogPrimitive.Overlay |
| 20 | + ref={ref} |
| 21 | + className={cn( |
| 22 | + "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", |
| 23 | + className, |
| 24 | + )} |
| 25 | + {...props} |
| 26 | + /> |
| 27 | +)); |
| 28 | +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; |
| 29 | + |
| 30 | +const DialogContent = React.forwardRef< |
| 31 | + React.ElementRef<typeof DialogPrimitive.Content>, |
| 32 | + React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> |
| 33 | +>(({ className, children, ...props }, ref) => ( |
| 34 | + <DialogPortal> |
| 35 | + <DialogOverlay /> |
| 36 | + <DialogPrimitive.Content |
| 37 | + ref={ref} |
| 38 | + className={cn( |
| 39 | + "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 bg-base-100 p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", |
| 40 | + className, |
| 41 | + )} |
| 42 | + {...props} |
| 43 | + > |
| 44 | + {children} |
| 45 | + </DialogPrimitive.Content> |
| 46 | + </DialogPortal> |
| 47 | +)); |
| 48 | +DialogContent.displayName = DialogPrimitive.Content.displayName; |
| 49 | + |
| 50 | +const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => ( |
| 51 | + <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} /> |
| 52 | +); |
| 53 | +DialogHeader.displayName = "DialogHeader"; |
| 54 | + |
| 55 | +const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => ( |
| 56 | + <div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} /> |
| 57 | +); |
| 58 | +DialogFooter.displayName = "DialogFooter"; |
| 59 | + |
| 60 | +const DialogTitle = React.forwardRef< |
| 61 | + React.ElementRef<typeof DialogPrimitive.Title>, |
| 62 | + React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> |
| 63 | +>(({ className, ...props }, ref) => ( |
| 64 | + <DialogPrimitive.Title |
| 65 | + ref={ref} |
| 66 | + className={cn("text-lg font-semibold leading-none tracking-tight", className)} |
| 67 | + {...props} |
| 68 | + /> |
| 69 | +)); |
| 70 | +DialogTitle.displayName = DialogPrimitive.Title.displayName; |
| 71 | + |
| 72 | +const DialogDescription = React.forwardRef< |
| 73 | + React.ElementRef<typeof DialogPrimitive.Description>, |
| 74 | + React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> |
| 75 | +>(({ className, ...props }, ref) => ( |
| 76 | + <DialogPrimitive.Description ref={ref} className={cn("text-sm", className)} {...props} /> |
| 77 | +)); |
| 78 | +DialogDescription.displayName = DialogPrimitive.Description.displayName; |
| 79 | + |
| 80 | +export { |
| 81 | + Dialog, |
| 82 | + DialogClose, |
| 83 | + DialogContent, |
| 84 | + DialogDescription, |
| 85 | + DialogFooter, |
| 86 | + DialogHeader, |
| 87 | + DialogOverlay, |
| 88 | + DialogPortal, |
| 89 | + DialogTitle, |
| 90 | + DialogTrigger, |
| 91 | +}; |
0 commit comments