|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; |
| 4 | +import React from 'react'; |
| 5 | +import { cn } from '@/shared/lib'; |
| 6 | + |
| 7 | +const DropdownMenu = DropdownMenuPrimitive.Root; |
| 8 | + |
| 9 | +const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; |
| 10 | + |
| 11 | +const DropdownMenuContent = React.forwardRef< |
| 12 | + React.ElementRef<typeof DropdownMenuPrimitive.Content>, |
| 13 | + React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> |
| 14 | +>(({ className, sideOffset = 4, ...props }, ref) => ( |
| 15 | + <DropdownMenuPrimitive.Portal> |
| 16 | + <DropdownMenuPrimitive.Content |
| 17 | + ref={ref} |
| 18 | + sideOffset={sideOffset} |
| 19 | + className={cn( |
| 20 | + 'z-50 min-w-[8rem] overflow-hidden rounded-[10px] border bg-popover p-1 text-popover-foreground shadow-md', |
| 21 | + '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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', |
| 22 | + className |
| 23 | + )} |
| 24 | + {...props} |
| 25 | + /> |
| 26 | + </DropdownMenuPrimitive.Portal> |
| 27 | +)); |
| 28 | +DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; |
| 29 | + |
| 30 | +const DropdownMenuItem = React.forwardRef< |
| 31 | + React.ElementRef<typeof DropdownMenuPrimitive.Item>, |
| 32 | + React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & { |
| 33 | + inset?: boolean; |
| 34 | + } |
| 35 | +>(({ className, inset, ...props }, ref) => ( |
| 36 | + <DropdownMenuPrimitive.Item |
| 37 | + ref={ref} |
| 38 | + className={cn( |
| 39 | + 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0', |
| 40 | + inset && 'pl-8', |
| 41 | + className |
| 42 | + )} |
| 43 | + {...props} |
| 44 | + /> |
| 45 | +)); |
| 46 | +DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; |
| 47 | + |
| 48 | +export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem }; |
0 commit comments