|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | | -// Import the polyfill early |
4 | | -import '../../lib/utils/radix-utils'; |
5 | | - |
6 | 3 | import * as React from 'react'; |
7 | | -import * as DialogPrimitive from '@radix-ui/react-dialog'; |
8 | 4 | import { X } from 'lucide-react'; |
9 | 5 | import { cn } from '@/lib/utils'; |
10 | 6 |
|
11 | | -interface CustomDialogContentProps |
12 | | - extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> { |
| 7 | +// DISABLED FOR TESTING |
| 8 | +// import * as DialogPrimitive from '@radix-ui/react-dialog'; |
| 9 | +// interface CustomDialogContentProps |
| 10 | +// extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> { |
| 11 | +// headerTitle?: string; |
| 12 | +// } |
| 13 | + |
| 14 | +// Mock interfaces and components to replace Radix UI |
| 15 | +interface DialogProps { |
| 16 | + children?: React.ReactNode; |
| 17 | + open?: boolean; |
| 18 | + onOpenChange?: (open: boolean) => void; |
| 19 | +} |
| 20 | + |
| 21 | +interface DialogTriggerProps { |
| 22 | + children?: React.ReactNode; |
| 23 | + asChild?: boolean; |
| 24 | +} |
| 25 | + |
| 26 | +interface DialogPortalProps { |
| 27 | + children?: React.ReactNode; |
| 28 | +} |
| 29 | + |
| 30 | +interface DialogCloseProps { |
| 31 | + children?: React.ReactNode; |
| 32 | + asChild?: boolean; |
| 33 | + className?: string; |
| 34 | +} |
| 35 | + |
| 36 | +interface DialogOverlayProps { |
| 37 | + className?: string; |
| 38 | + [key: string]: any; |
| 39 | +} |
| 40 | + |
| 41 | +interface CustomDialogContentProps { |
| 42 | + className?: string; |
| 43 | + children?: React.ReactNode; |
13 | 44 | headerTitle?: string; |
| 45 | + onOpenAutoFocus?: (e: any) => void; |
| 46 | + onEscapeKeyDown?: () => void; |
| 47 | + onPointerDownOutside?: () => void; |
| 48 | + [key: string]: any; |
14 | 49 | } |
15 | 50 |
|
16 | | -const Dialog = DialogPrimitive.Root; |
17 | | -const DialogTrigger = DialogPrimitive.Trigger; |
18 | | -const DialogPortal = DialogPrimitive.Portal; |
19 | | -const DialogClose = DialogPrimitive.Close; |
20 | | - |
21 | | -const DialogOverlay = React.forwardRef< |
22 | | - React.ElementRef<typeof DialogPrimitive.Overlay>, |
23 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> |
24 | | ->(({ className, ...props }, ref) => ( |
25 | | - <DialogPrimitive.Overlay |
26 | | - ref={ref} |
27 | | - className={cn( |
28 | | - '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', |
29 | | - className |
30 | | - )} |
31 | | - {...props} |
32 | | - /> |
33 | | -)); |
34 | | -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; |
35 | | - |
36 | | -const DialogContent = React.forwardRef< |
37 | | - React.ElementRef<typeof DialogPrimitive.Content>, |
38 | | - CustomDialogContentProps |
39 | | ->(({ className, children, headerTitle, ...props }, ref) => ( |
40 | | - <DialogPortal> |
41 | | - <DialogOverlay /> |
42 | | - <DialogPrimitive.Content |
| 51 | +interface DialogTitleProps { |
| 52 | + className?: string; |
| 53 | + children?: React.ReactNode; |
| 54 | + [key: string]: any; |
| 55 | +} |
| 56 | + |
| 57 | +interface DialogDescriptionProps { |
| 58 | + className?: string; |
| 59 | + children?: React.ReactNode; |
| 60 | + [key: string]: any; |
| 61 | +} |
| 62 | + |
| 63 | +// Mock components |
| 64 | +const Dialog: React.FC<DialogProps> = ({ children }) => <div className="mock-dialog">{children}</div>; |
| 65 | +const DialogTrigger: React.FC<DialogTriggerProps> = ({ children }) => <>{children}</>; |
| 66 | +const DialogPortal: React.FC<DialogPortalProps> = ({ children }) => <>{children}</>; |
| 67 | +const DialogClose: React.FC<DialogCloseProps> = ({ children }) => <>{children}</>; |
| 68 | +const DialogOverlay = React.forwardRef<HTMLDivElement, DialogOverlayProps>( |
| 69 | + (props, ref) => <div ref={ref} className="hidden" {...props} /> |
| 70 | +); |
| 71 | +DialogOverlay.displayName = 'DialogOverlay'; |
| 72 | + |
| 73 | +const DialogContent = React.forwardRef<HTMLDivElement, CustomDialogContentProps>( |
| 74 | + ({ className, children, headerTitle, ...props }, ref) => ( |
| 75 | + <div |
43 | 76 | ref={ref} |
44 | | - className={cn( |
45 | | - 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border-0 bg-background p-0 shadow-lg duration-200', |
46 | | - headerTitle && 'sm:rounded-lg', |
47 | | - className |
48 | | - )} |
| 77 | + className={cn('fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2', className)} |
49 | 78 | {...props} |
50 | 79 | > |
51 | 80 | {headerTitle && ( |
52 | 81 | <div className='bg-brand-pink p-2 flex items-center justify-between sm:rounded-t-lg'> |
53 | | - <DialogPrimitive.Title className='text-xl font-semibold text-white'> |
| 82 | + <div className='text-xl font-semibold text-white'> |
54 | 83 | {headerTitle} |
55 | | - </DialogPrimitive.Title> |
56 | | - <DialogPrimitive.Close asChild> |
57 | | - <button className='text-white' aria-label='Close'> |
58 | | - <X size={24} /> |
59 | | - </button> |
60 | | - </DialogPrimitive.Close> |
| 84 | + </div> |
| 85 | + <button className='text-white' aria-label='Close'> |
| 86 | + <X size={24} /> |
| 87 | + </button> |
61 | 88 | </div> |
62 | 89 | )} |
63 | 90 | <div className={headerTitle ? 'p-4 bg-gray-50 sm:rounded-b-lg' : 'p-4'}> |
64 | 91 | {children} |
65 | 92 | </div> |
66 | | - </DialogPrimitive.Content> |
67 | | - </DialogPortal> |
68 | | -)); |
69 | | - |
70 | | -DialogContent.displayName = DialogPrimitive.Content.displayName; |
| 93 | + </div> |
| 94 | + ) |
| 95 | +); |
| 96 | +DialogContent.displayName = 'DialogContent'; |
71 | 97 |
|
72 | 98 | const DialogHeader = ({ |
73 | 99 | className, |
@@ -97,32 +123,31 @@ const DialogFooter = ({ |
97 | 123 | ); |
98 | 124 | DialogFooter.displayName = 'DialogFooter'; |
99 | 125 |
|
100 | | -const DialogTitle = React.forwardRef< |
101 | | - React.ElementRef<typeof DialogPrimitive.Title>, |
102 | | - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> |
103 | | ->(({ className, ...props }, ref) => ( |
104 | | - <DialogPrimitive.Title |
105 | | - ref={ref} |
106 | | - className={cn( |
107 | | - 'text-lg font-semibold leading-none tracking-tight', |
108 | | - className |
109 | | - )} |
110 | | - {...props} |
111 | | - /> |
112 | | -)); |
113 | | -DialogTitle.displayName = DialogPrimitive.Title.displayName; |
114 | | - |
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 | | - className={cn('text-sm text-muted-foreground', className)} |
122 | | - {...props} |
123 | | - /> |
124 | | -)); |
125 | | -DialogDescription.displayName = DialogPrimitive.Description.displayName; |
| 126 | +const DialogTitle = React.forwardRef<HTMLHeadingElement, DialogTitleProps>( |
| 127 | + ({ className, children, ...props }, ref) => ( |
| 128 | + <h2 |
| 129 | + ref={ref} |
| 130 | + className={cn('text-lg font-semibold leading-none tracking-tight', className)} |
| 131 | + {...props} |
| 132 | + > |
| 133 | + {children} |
| 134 | + </h2> |
| 135 | + ) |
| 136 | +); |
| 137 | +DialogTitle.displayName = 'DialogTitle'; |
| 138 | + |
| 139 | +const DialogDescription = React.forwardRef<HTMLParagraphElement, DialogDescriptionProps>( |
| 140 | + ({ className, children, ...props }, ref) => ( |
| 141 | + <p |
| 142 | + ref={ref} |
| 143 | + className={cn('text-sm text-muted-foreground', className)} |
| 144 | + {...props} |
| 145 | + > |
| 146 | + {children} |
| 147 | + </p> |
| 148 | + ) |
| 149 | +); |
| 150 | +DialogDescription.displayName = 'DialogDescription'; |
126 | 151 |
|
127 | 152 | export { |
128 | 153 | Dialog, |
|
0 commit comments