| 44 | } |
| 45 | |
| 46 | function SheetContent({ |
| 47 | className, |
| 48 | children, |
| 49 | side = "right", |
| 50 | showCloseButton = true, |
| 51 | closeLabel = "Close", |
| 52 | ...props |
| 53 | }: React.ComponentProps<typeof SheetPrimitive.Content> & { |
| 54 | side?: "top" | "right" | "bottom" | "left"; |
| 55 | showCloseButton?: boolean; |
| 56 | /* |
| 57 | * Screen-reader label for the auto-rendered X close button. Defaults |
| 58 | * to English so the primitive is usable standalone; app callers pass |
| 59 | * `t("common.close")` to honour the user's language. |
| 60 | */ |
| 61 | closeLabel?: string; |
| 62 | }) { |
| 63 | return ( |
| 64 | <SheetPortal> |
| 65 | <SheetOverlay /> |
| 66 | <SheetPrimitive.Content |
| 67 | data-slot='sheet-content' |
| 68 | className={cn( |
| 69 | "bg-panel border-border-strong/40 data-[state=closed]:animate-out data-[state=open]:animate-in fixed z-50 flex flex-col gap-4 transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500", |
| 70 | side === "right" && |
| 71 | "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", |
| 72 | side === "left" && |
| 73 | "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", |
| 74 | side === "top" && |
| 75 | "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b", |
| 76 | side === "bottom" && |
| 77 | "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t", |
| 78 | className |
| 79 | )} |
| 80 | {...props} |
| 81 | > |
| 82 | {children} |
| 83 | {showCloseButton && ( |
| 84 | <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'> |
| 85 | <XIcon className='size-4' /> |
| 86 | <span className='sr-only'>{closeLabel}</span> |
| 87 | </SheetPrimitive.Close> |
| 88 | )} |
| 89 | </SheetPrimitive.Content> |
| 90 | </SheetPortal> |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | function SheetHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 95 | return ( |