@@ -20,55 +20,56 @@ function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Po
2020 return < SheetPrimitive . Portal data-slot = "sheet-portal" { ...props } />
2121}
2222
23- function SheetOverlay ( { className, ...props } : React . ComponentProps < typeof SheetPrimitive . Overlay > ) {
24- return (
25- < SheetPrimitive . Overlay
26- data-slot = "sheet-overlay"
23+ export const SheetOverlay = React . forwardRef <
24+ React . ElementRef < typeof SheetPrimitive . Overlay > ,
25+ React . ComponentPropsWithoutRef < typeof SheetPrimitive . Overlay >
26+ > ( ( { className, ...props } , ref ) => (
27+ < SheetPrimitive . Overlay
28+ ref = { ref }
29+ data-slot = "sheet-overlay"
30+ className = { cn (
31+ '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' ,
32+ className
33+ ) }
34+ { ...props }
35+ />
36+ ) )
37+ SheetOverlay . displayName = SheetPrimitive . Overlay . displayName
38+
39+ const SheetContent = React . forwardRef <
40+ React . ElementRef < typeof SheetPrimitive . Content > ,
41+ React . ComponentPropsWithoutRef < typeof SheetPrimitive . Content > & {
42+ side ?: 'top' | 'right' | 'bottom' | 'left'
43+ }
44+ > ( ( { className, children, side = 'right' , ...props } , ref ) => (
45+ < SheetPortal >
46+ < SheetOverlay />
47+ < SheetPrimitive . Content
48+ ref = { ref }
49+ data-slot = "sheet-content"
2750 className = { cn (
28- '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' ,
51+ 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500' ,
52+ side === 'right' &&
53+ 'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm' ,
54+ side === 'left' &&
55+ 'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm' ,
56+ side === 'top' &&
57+ 'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b' ,
58+ side === 'bottom' &&
59+ 'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t' ,
2960 className
3061 ) }
3162 { ...props }
32- />
33- )
34- }
35-
36- function SheetContent ( {
37- className,
38- children,
39- side = 'right' ,
40- ...props
41- } : React . ComponentProps < typeof SheetPrimitive . Content > & {
42- side ?: 'top' | 'right' | 'bottom' | 'left'
43- } ) {
44- return (
45- < SheetPortal >
46- < SheetOverlay />
47- < SheetPrimitive . Content
48- data-slot = "sheet-content"
49- className = { cn (
50- 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500' ,
51- side === 'right' &&
52- 'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm' ,
53- side === 'left' &&
54- 'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm' ,
55- side === 'top' &&
56- 'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b' ,
57- side === 'bottom' &&
58- 'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t' ,
59- className
60- ) }
61- { ...props }
62- >
63- { children }
64- < SheetPrimitive . Close className = "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary 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" >
65- < XIcon className = "size-4" />
66- < span className = "sr-only" > Close</ span >
67- </ SheetPrimitive . Close >
68- </ SheetPrimitive . Content >
69- </ SheetPortal >
70- )
71- }
63+ >
64+ { children }
65+ < SheetPrimitive . Close className = "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary 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" >
66+ < XIcon className = "size-4" />
67+ < span className = "sr-only" > Close</ span >
68+ </ SheetPrimitive . Close >
69+ </ SheetPrimitive . Content >
70+ </ SheetPortal >
71+ ) )
72+ SheetContent . displayName = SheetPrimitive . Content . displayName
7273
7374function SheetHeader ( { className, ...props } : React . ComponentProps < 'div' > ) {
7475 return < div data-slot = "sheet-header" className = { cn ( 'flex flex-col gap-1.5 p-4' , className ) } { ...props } />
0 commit comments