| 1 | "use client"; |
| 2 | |
| 3 | import * as React from |
| 4 | import { cn } |
| 5 | import { Dialog as |
| 6 | |
| 7 | import { Button } |
| 8 | import { XIcon } |
| 9 | |
| 10 | function Dialog({ |
| 11 | ...props |
| 12 | }: React. |
| 13 | return <DialogPrimitive.Root data-slot |
| 14 | } |
| 15 | |
| 16 | function DialogTrigger({ |
| 17 | ...props |
| 18 | }: React. |
| 19 | return <DialogPrimitive.Trigger data-slot |
| 20 | } |
| 21 | |
| 22 | function DialogPortal({ |
| 23 | ...props |
| 24 | }: React. |
| 25 | return <DialogPrimitive.Portal data-slot |
| 26 | } |
| 27 | |
| 28 | function DialogClose({ |
| 29 | ...props |
| 30 | }: React. |
| 31 | return <DialogPrimitive.Close data-slot |
| 32 | } |
| 33 | |
| 34 | function DialogOverlay({ |
| 35 | className, |
| 36 | ...props |
| 37 | }: React. |
| 38 | return ( |
| 39 | <DialogPrimitive.Overlay |
| 40 | data-slot="dialog-overlay" |
| 41 | className={cn( |
| 42 | "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", |
| 43 | className, |
| 44 | )} |
| 45 | {...props} |
| 46 | /> |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | function DialogContent({ |
| 51 | className, |
| 52 | children, |
| 53 | showCloseButton = true, |
| 54 | ...props |
| 55 | }: React. |
| 56 | showCloseButton?: boolean |
| 57 | }) { |
| 58 | return ( |
| 59 | <DialogPortal> |
| 60 | <DialogOverlay /> |
| 61 | <DialogPrimitive.Content |
| 62 | data-slot="dialog-content" |
| 63 | className={cn( |
| 64 | "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", |
| 65 | className, |
| 66 | )} |
| 67 | {...props} |
| 68 | > |
| 69 | {children} |
| 70 | {showCloseButton && ( |
| 71 | <DialogPrimitive.Close data-slot=" |
| 72 | <Button |
| 73 | variant="ghost" |
| 74 | className="absolute top-2 right-2" |
| 75 | size="icon-sm" |
| 76 | > |
| 77 | <XIcon /> |
| 78 | <span className="sr-only |
| 79 | </Button> |
| 80 | </DialogPrimitive.Close> |
| 81 | )} |
| 82 | </DialogPrimitive.Content> |
| 83 | </DialogPortal> |
| 84 | ); |
| 85 | } |
| 86 | |
| 87 | function DialogHeader({ className |
| 88 | return ( |
| 89 | <div |
| 90 | data-slot="dialog-header" |
| 91 | className={cn(" |
| 92 | {...props} |
| 93 | /> |
| 94 | ); |
| 95 | } |
| 96 | |
| 97 | function DialogFooter({ |
| 98 | className, |
| 99 | showCloseButton = false, |
| 100 | children, |
| 101 | ...props |
| 102 | }: React. |
| 103 | showCloseButton?: boolean |
| 104 | }) { |
| 105 | return ( |
| 106 | <div |
| 107 | data-slot="dialog-footer" |
| 108 | className={cn( |
| 109 | "-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end", |
| 110 | className, |
| 111 | )} |
| 112 | {...props} |
| 113 | > |
| 114 | {children} |
| 115 | {showCloseButton && ( |
| 116 | <DialogPrimitive.Close asChild> |
| 117 | <Button variant=" |
| 118 | </DialogPrimitive.Close> |
| 119 | )} |
| 120 | </div> |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | function DialogTitle({ |
| 125 | className, |
| 126 | ...props |
| 127 | }: React. |
| 128 | return ( |
| 129 | <DialogPrimitive.Title |
| 130 | data-slot="dialog-title" |
| 131 | className={cn( |
| 132 | "font-heading text-base leading-none font-medium", |
| 133 | className, |
| 134 | )} |
| 135 | {...props} |
| 136 | /> |
| 137 | ); |
| 138 | } |
| 139 | |
| 140 | function DialogDescription({ |
| 141 | className, |
| 142 | ...props |
| 143 | }: React. |
| 144 | return ( |
| 145 | <DialogPrimitive.Description |
| 146 | data-slot="dialog-description" |
| 147 | className={cn( |
| 148 | "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", |
| 149 | className, |
| 150 | )} |
| 151 | {...props} |
| 152 | /> |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | export { |
| 157 | Dialog, |
| 158 | DialogClose, |
| 159 | DialogContent, |
| 160 | DialogDescription, |
| 161 | DialogFooter, |
| 162 | DialogHeader, |
| 163 | DialogOverlay, |
| 164 | DialogPortal, |
| 165 | DialogTitle, |
| 166 | DialogTrigger, |
| 167 | }; |