11'use client'
22
33import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
4- import type * as React from 'react'
4+ import * as React from 'react'
55import { cn } from '../utils'
66import { buttonVariants } from './button'
77
88const AlertDialog = ( { ...props } : React . ComponentProps < typeof AlertDialogPrimitive . Root > ) => {
99 return < AlertDialogPrimitive . Root data-slot = "alert-dialog" { ...props } />
1010}
1111
12- const AlertDialogTrigger = ( {
13- ...props
14- } : React . ComponentProps < typeof AlertDialogPrimitive . Trigger > ) => {
15- return < AlertDialogPrimitive . Trigger data-slot = "alert-dialog-trigger" { ...props } />
16- }
12+ const AlertDialogTrigger = React . forwardRef <
13+ React . ElementRef < typeof AlertDialogPrimitive . Trigger > ,
14+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Trigger >
15+ > ( ( { ...props } , ref ) => {
16+ return < AlertDialogPrimitive . Trigger ref = { ref } data-slot = "alert-dialog-trigger" { ...props } />
17+ } )
18+
19+ AlertDialogTrigger . displayName = AlertDialogPrimitive . Trigger . displayName
1720
1821const AlertDialogPortal = ( {
1922 ...props
2023} : React . ComponentProps < typeof AlertDialogPrimitive . Portal > ) => {
2124 return < AlertDialogPrimitive . Portal data-slot = "alert-dialog-portal" { ...props } />
2225}
2326
24- const AlertDialogOverlay = ( {
25- className ,
26- ... props
27- } : React . ComponentProps < typeof AlertDialogPrimitive . Overlay > ) => {
27+ const AlertDialogOverlay = React . forwardRef <
28+ React . ElementRef < typeof AlertDialogPrimitive . Overlay > ,
29+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Overlay >
30+ > ( ( { className , ... props } , ref ) => {
2831 return (
2932 < AlertDialogPrimitive . Overlay
33+ ref = { ref }
3034 data-slot = "alert-dialog-overlay"
3135 className = { cn (
3236 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in' ,
@@ -35,16 +39,19 @@ const AlertDialogOverlay = ({
3539 { ...props }
3640 />
3741 )
38- }
42+ } )
3943
40- const AlertDialogContent = ( {
41- className,
42- ...props
43- } : React . ComponentProps < typeof AlertDialogPrimitive . Content > ) => {
44+ AlertDialogOverlay . displayName = AlertDialogPrimitive . Overlay . displayName
45+
46+ const AlertDialogContent = React . forwardRef <
47+ React . ElementRef < typeof AlertDialogPrimitive . Content > ,
48+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Content >
49+ > ( ( { className, ...props } , ref ) => {
4450 return (
4551 < AlertDialogPortal >
4652 < AlertDialogOverlay />
4753 < AlertDialogPrimitive . Content
54+ ref = { ref }
4855 data-slot = "alert-dialog-content"
4956 className = { cn (
5057 '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-default border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg' ,
@@ -54,7 +61,9 @@ const AlertDialogContent = ({
5461 />
5562 </ AlertDialogPortal >
5663 )
57- }
64+ } )
65+
66+ AlertDialogContent . displayName = AlertDialogPrimitive . Content . displayName
5867
5968const AlertDialogHeader = ( { className, ...props } : React . ComponentProps < 'div' > ) => {
6069 return (
@@ -76,50 +85,63 @@ const AlertDialogFooter = ({ className, ...props }: React.ComponentProps<'div'>)
7685 )
7786}
7887
79- const AlertDialogTitle = ( {
80- className ,
81- ... props
82- } : React . ComponentProps < typeof AlertDialogPrimitive . Title > ) => {
88+ const AlertDialogTitle = React . forwardRef <
89+ React . ElementRef < typeof AlertDialogPrimitive . Title > ,
90+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Title >
91+ > ( ( { className , ... props } , ref ) => {
8392 return (
8493 < AlertDialogPrimitive . Title
94+ ref = { ref }
8595 data-slot = "alert-dialog-title"
8696 className = { cn ( 'font-semibold text-lg' , className ) }
8797 { ...props }
8898 />
8999 )
90- }
100+ } )
91101
92- const AlertDialogDescription = ( {
93- className,
94- ...props
95- } : React . ComponentProps < typeof AlertDialogPrimitive . Description > ) => {
102+ AlertDialogTitle . displayName = AlertDialogPrimitive . Title . displayName
103+
104+ const AlertDialogDescription = React . forwardRef <
105+ React . ElementRef < typeof AlertDialogPrimitive . Description > ,
106+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Description >
107+ > ( ( { className, ...props } , ref ) => {
96108 return (
97109 < AlertDialogPrimitive . Description
110+ ref = { ref }
98111 data-slot = "alert-dialog-description"
99112 className = { cn ( 'text-muted-foreground text-sm' , className ) }
100113 { ...props }
101114 />
102115 )
103- }
116+ } )
104117
105- const AlertDialogAction = ( {
106- className,
107- ...props
108- } : React . ComponentProps < typeof AlertDialogPrimitive . Action > ) => {
109- return < AlertDialogPrimitive . Action className = { cn ( buttonVariants ( ) , className ) } { ...props } />
110- }
118+ AlertDialogDescription . displayName = AlertDialogPrimitive . Description . displayName
111119
112- const AlertDialogCancel = ( {
113- className,
114- ...props
115- } : React . ComponentProps < typeof AlertDialogPrimitive . Cancel > ) => {
120+ const AlertDialogAction = React . forwardRef <
121+ React . ElementRef < typeof AlertDialogPrimitive . Action > ,
122+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Action >
123+ > ( ( { className, ...props } , ref ) => {
124+ return (
125+ < AlertDialogPrimitive . Action ref = { ref } className = { cn ( buttonVariants ( ) , className ) } { ...props } />
126+ )
127+ } )
128+
129+ AlertDialogAction . displayName = AlertDialogPrimitive . Action . displayName
130+
131+ const AlertDialogCancel = React . forwardRef <
132+ React . ElementRef < typeof AlertDialogPrimitive . Cancel > ,
133+ React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Cancel >
134+ > ( ( { className, ...props } , ref ) => {
116135 return (
117136 < AlertDialogPrimitive . Cancel
137+ ref = { ref }
118138 className = { cn ( 'focus:outline-none' , buttonVariants ( { variant : 'ghost' } ) , className ) }
119139 { ...props }
120140 />
121141 )
122- }
142+ } )
143+
144+ AlertDialogCancel . displayName = AlertDialogPrimitive . Cancel . displayName
123145
124146export {
125147 AlertDialog ,
0 commit comments