popover.tsx
1,157 bytes
| 1 | 'use client'; |
|---|---|
| 2 | |
| 3 | import * as PopoverPrimitive from '@radix-ui/react-popover'; |
| 4 | import * as React from 'react'; |
| 5 | import { cn } from '@/lib/utils'; |
| 6 | |
| 7 | const Popover = PopoverPrimitive.Root; |
| 8 | const PopoverTrigger = PopoverPrimitive.Trigger; |
| 9 | const PopoverAnchor = PopoverPrimitive.Anchor; |
| 10 | |
| 11 | const PopoverContent = React.forwardRef< |
| 12 | React.ElementRef<typeof PopoverPrimitive.Content>, |
| 13 | React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> |
| 14 | >(({ className, align = 'start', sideOffset = 4, ...props }, ref) => ( |
| 15 | <PopoverPrimitive.Portal> |
| 16 | <PopoverPrimitive.Content |
| 17 | ref={ref} |
| 18 | align={align} |
| 19 | sideOffset={sideOffset} |
| 20 | className={cn( |
| 21 | 'z-50 w-72 rounded-lg border bg-popover p-1 text-popover-foreground shadow-md outline-none 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', |
| 22 | className, |
| 23 | )} |
| 24 | {...props} |
| 25 | /> |
| 26 | </PopoverPrimitive.Portal> |
| 27 | )); |
| 28 | PopoverContent.displayName = PopoverPrimitive.Content.displayName; |
| 29 | |
| 30 | export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }; |
| 31 | |