|
1 | | -import * as React from "react" |
2 | | -import * as DialogPrimitive from "@radix-ui/react-dialog" |
3 | | -import { XIcon } from "lucide-react" |
| 1 | +// import * as React from "react" |
| 2 | +// import { XIcon } from "lucide-react" |
| 3 | +// import { cn } from "@/lib/utils" |
4 | 4 |
|
5 | | -import { cn } from "@/lib/utils" |
| 5 | +// interface DialogProps { |
| 6 | +// open?: boolean; |
| 7 | +// onOpenChange?: (open: boolean) => void; |
| 8 | +// children: React.ReactNode; |
| 9 | +// } |
6 | 10 |
|
7 | | -function Dialog({ |
8 | | - ...props |
9 | | -}: React.ComponentProps<typeof DialogPrimitive.Root>) { |
10 | | - return <DialogPrimitive.Root data-slot="dialog" {...props} /> |
11 | | -} |
| 11 | +// function Dialog({ open, onOpenChange, children }: DialogProps) { |
| 12 | +// React.useEffect(() => { |
| 13 | +// if (open) { |
| 14 | +// document.body.style.overflow = 'hidden'; |
| 15 | +// } else { |
| 16 | +// document.body.style.overflow = 'unset'; |
| 17 | +// } |
| 18 | +// return () => { |
| 19 | +// document.body.style.overflow = 'unset'; |
| 20 | +// }; |
| 21 | +// }, [open]); |
12 | 22 |
|
13 | | -function DialogTrigger({ |
14 | | - ...props |
15 | | -}: React.ComponentProps<typeof DialogPrimitive.Trigger>) { |
16 | | - return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} /> |
17 | | -} |
| 23 | +// if (!open) return null; |
18 | 24 |
|
19 | | -function DialogPortal({ |
20 | | - ...props |
21 | | -}: React.ComponentProps<typeof DialogPrimitive.Portal>) { |
22 | | - return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} /> |
23 | | -} |
| 25 | +// return ( |
| 26 | +// <div |
| 27 | +// data-slot="dialog" |
| 28 | +// onClick={(e) => { |
| 29 | +// if (e.target === e.currentTarget) { |
| 30 | +// onOpenChange?.(false); |
| 31 | +// } |
| 32 | +// }} |
| 33 | +// > |
| 34 | +// {children} |
| 35 | +// </div> |
| 36 | +// ); |
| 37 | +// } |
24 | 38 |
|
25 | | -function DialogClose({ |
26 | | - ...props |
27 | | -}: React.ComponentProps<typeof DialogPrimitive.Close>) { |
28 | | - return <DialogPrimitive.Close data-slot="dialog-close" {...props} /> |
29 | | -} |
| 39 | +// const DialogOverlay = React.forwardRef< |
| 40 | +// HTMLDivElement, |
| 41 | +// React.HTMLAttributes<HTMLDivElement> |
| 42 | +// >(({ className, ...props }, ref) => ( |
| 43 | +// <div |
| 44 | +// ref={ref} |
| 45 | +// data-slot="dialog-overlay" |
| 46 | +// className={cn( |
| 47 | +// "fixed inset-0 z-50 bg-black/50", |
| 48 | +// className |
| 49 | +// )} |
| 50 | +// {...props} |
| 51 | +// /> |
| 52 | +// )); |
| 53 | +// DialogOverlay.displayName = "DialogOverlay"; |
30 | 54 |
|
31 | | -const DialogOverlay = React.forwardRef< |
32 | | - React.ElementRef<typeof DialogPrimitive.Overlay>, |
33 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> |
34 | | ->(({ className, ...props }, ref) => ( |
35 | | - <DialogPrimitive.Overlay |
36 | | - ref={ref} |
37 | | - data-slot="dialog-overlay" |
38 | | - className={cn( |
39 | | - "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", |
40 | | - className |
41 | | - )} |
42 | | - {...props} |
43 | | - /> |
44 | | -)) |
45 | | -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName |
| 55 | +// const DialogContent = React.forwardRef< |
| 56 | +// HTMLDivElement, |
| 57 | +// React.HTMLAttributes<HTMLDivElement> & { |
| 58 | +// showCloseButton?: boolean; |
| 59 | +// onClose?: () => void; |
| 60 | +// } |
| 61 | +// >(({ className, children, showCloseButton = true, onClose, ...props }, ref) => ( |
| 62 | +// <div className="fixed inset-0 z-50 flex items-center justify-center" onClick={onClose}> |
| 63 | +// <DialogOverlay /> |
| 64 | +// <div |
| 65 | +// ref={ref} |
| 66 | +// data-slot="dialog-content" |
| 67 | +// className={cn( |
| 68 | +// "bg-background relative z-50 grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg", |
| 69 | +// className |
| 70 | +// )} |
| 71 | +// onClick={(e) => e.stopPropagation()} |
| 72 | +// {...props} |
| 73 | +// > |
| 74 | +// {children} |
| 75 | +// {showCloseButton && onClose && ( |
| 76 | +// <button |
| 77 | +// onClick={onClose} |
| 78 | +// data-slot="dialog-close" |
| 79 | +// className="ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4" |
| 80 | +// > |
| 81 | +// <XIcon /> |
| 82 | +// <span className="sr-only">Close</span> |
| 83 | +// </button> |
| 84 | +// )} |
| 85 | +// </div> |
| 86 | +// </div> |
| 87 | +// )); |
| 88 | +// DialogContent.displayName = "DialogContent"; |
46 | 89 |
|
47 | | -const DialogContent = React.forwardRef< |
48 | | - React.ElementRef<typeof DialogPrimitive.Content>, |
49 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & { |
50 | | - showCloseButton?: boolean |
51 | | - } |
52 | | ->(({ className, children, showCloseButton = true, ...props }, ref) => ( |
53 | | - <DialogPortal data-slot="dialog-portal"> |
54 | | - <DialogOverlay /> |
55 | | - <DialogPrimitive.Content |
56 | | - ref={ref} |
57 | | - data-slot="dialog-content" |
58 | | - className={cn( |
59 | | - "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", |
60 | | - className |
61 | | - )} |
62 | | - {...props} |
63 | | - > |
64 | | - {children} |
65 | | - {showCloseButton && ( |
66 | | - <DialogPrimitive.Close |
67 | | - data-slot="dialog-close" |
68 | | - className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4" |
69 | | - > |
70 | | - <XIcon /> |
71 | | - <span className="sr-only">Close</span> |
72 | | - </DialogPrimitive.Close> |
73 | | - )} |
74 | | - </DialogPrimitive.Content> |
75 | | - </DialogPortal> |
76 | | -)) |
77 | | -DialogContent.displayName = DialogPrimitive.Content.displayName |
| 90 | +// function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 91 | +// return ( |
| 92 | +// <div |
| 93 | +// data-slot="dialog-header" |
| 94 | +// className={cn("flex flex-col gap-2 text-center sm:text-left", className)} |
| 95 | +// {...props} |
| 96 | +// /> |
| 97 | +// ); |
| 98 | +// } |
78 | 99 |
|
79 | | -function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { |
80 | | - return ( |
81 | | - <div |
82 | | - data-slot="dialog-header" |
83 | | - className={cn("flex flex-col gap-2 text-center sm:text-left", className)} |
84 | | - {...props} |
85 | | - /> |
86 | | - ) |
87 | | -} |
| 100 | +// function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { |
| 101 | +// return ( |
| 102 | +// <div |
| 103 | +// data-slot="dialog-footer" |
| 104 | +// className={cn( |
| 105 | +// "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", |
| 106 | +// className |
| 107 | +// )} |
| 108 | +// {...props} |
| 109 | +// /> |
| 110 | +// ); |
| 111 | +// } |
88 | 112 |
|
89 | | -function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { |
90 | | - return ( |
91 | | - <div |
92 | | - data-slot="dialog-footer" |
93 | | - className={cn( |
94 | | - "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", |
95 | | - className |
96 | | - )} |
97 | | - {...props} |
98 | | - /> |
99 | | - ) |
100 | | -} |
| 113 | +// const DialogTitle = React.forwardRef< |
| 114 | +// HTMLHeadingElement, |
| 115 | +// React.HTMLAttributes<HTMLHeadingElement> |
| 116 | +// >(({ className, ...props }, ref) => ( |
| 117 | +// <h2 |
| 118 | +// ref={ref} |
| 119 | +// data-slot="dialog-title" |
| 120 | +// className={cn("text-lg leading-none font-semibold", className)} |
| 121 | +// {...props} |
| 122 | +// /> |
| 123 | +// )); |
| 124 | +// DialogTitle.displayName = "DialogTitle"; |
101 | 125 |
|
102 | | -const DialogTitle = React.forwardRef< |
103 | | - React.ElementRef<typeof DialogPrimitive.Title>, |
104 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> |
105 | | ->(({ className, ...props }, ref) => ( |
106 | | - <DialogPrimitive.Title |
107 | | - ref={ref} |
108 | | - data-slot="dialog-title" |
109 | | - className={cn("text-lg leading-none font-semibold", className)} |
110 | | - {...props} |
111 | | - /> |
112 | | -)) |
113 | | -DialogTitle.displayName = DialogPrimitive.Title.displayName |
| 126 | +// const DialogDescription = React.forwardRef< |
| 127 | +// HTMLParagraphElement, |
| 128 | +// React.HTMLAttributes<HTMLParagraphElement> |
| 129 | +// >(({ className, ...props }, ref) => ( |
| 130 | +// <p |
| 131 | +// ref={ref} |
| 132 | +// data-slot="dialog-description" |
| 133 | +// className={cn("text-muted-foreground text-sm", className)} |
| 134 | +// {...props} |
| 135 | +// /> |
| 136 | +// )); |
| 137 | +// DialogDescription.displayName = "DialogDescription"; |
114 | 138 |
|
115 | | -const DialogDescription = React.forwardRef< |
116 | | - React.ElementRef<typeof DialogPrimitive.Description>, |
117 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> |
118 | | ->(({ className, ...props }, ref) => ( |
119 | | - <DialogPrimitive.Description |
120 | | - ref={ref} |
121 | | - data-slot="dialog-description" |
122 | | - className={cn("text-muted-foreground text-sm", className)} |
123 | | - {...props} |
124 | | - /> |
125 | | -)) |
126 | | -DialogDescription.displayName = DialogPrimitive.Description.displayName |
| 139 | +// function DialogTrigger({ ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) { |
| 140 | +// return <button data-slot="dialog-trigger" {...props} />; |
| 141 | +// } |
127 | 142 |
|
128 | | -export { |
129 | | - Dialog, |
130 | | - DialogClose, |
131 | | - DialogContent, |
132 | | - DialogDescription, |
133 | | - DialogFooter, |
134 | | - DialogHeader, |
135 | | - DialogOverlay, |
136 | | - DialogPortal, |
137 | | - DialogTitle, |
138 | | - DialogTrigger, |
139 | | -} |
| 143 | +// function DialogClose({ ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) { |
| 144 | +// return <button data-slot="dialog-close" {...props} />; |
| 145 | +// } |
| 146 | + |
| 147 | +// function DialogPortal({ children }: { children: React.ReactNode }) { |
| 148 | +// return <>{children}</>; |
| 149 | +// } |
| 150 | + |
| 151 | +// export { |
| 152 | +// Dialog, |
| 153 | +// DialogClose, |
| 154 | +// DialogContent, |
| 155 | +// DialogDescription, |
| 156 | +// DialogFooter, |
| 157 | +// DialogHeader, |
| 158 | +// DialogOverlay, |
| 159 | +// DialogPortal, |
| 160 | +// DialogTitle, |
| 161 | +// DialogTrigger, |
| 162 | +// }; |
0 commit comments