55 行
1.8 KiB
TypeScript
55 行
1.8 KiB
TypeScript
import * as React from "react";
|
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
import { cn } from "../../lib/utils";
|
|
|
|
export const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
export const DropdownMenuContent = React.forwardRef<
|
|
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
>(({ className, sideOffset = 8, ...props }, ref) => (
|
|
<DropdownMenuPrimitive.Portal>
|
|
<DropdownMenuPrimitive.Content
|
|
ref={ref}
|
|
sideOffset={sideOffset}
|
|
className={cn(
|
|
"z-50 min-w-[12rem] overflow-hidden rounded-xl border border-zinc-200 bg-white p-1 text-zinc-900 shadow-md",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
</DropdownMenuPrimitive.Portal>
|
|
));
|
|
|
|
DropdownMenuContent.displayName = "DropdownMenuContent";
|
|
|
|
export const DropdownMenuItem = React.forwardRef<
|
|
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item>
|
|
>(({ className, ...props }, ref) => (
|
|
<DropdownMenuPrimitive.Item
|
|
ref={ref}
|
|
className={cn(
|
|
"flex cursor-default select-none items-center rounded-lg px-3 py-2 text-sm outline-none focus:bg-zinc-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
|
|
export const DropdownMenuSeparator = React.forwardRef<
|
|
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
>(({ className, ...props }, ref) => (
|
|
<DropdownMenuPrimitive.Separator
|
|
ref={ref}
|
|
className={cn("-mx-1 my-1 h-px bg-zinc-200", className)}
|
|
{...props}
|
|
/>
|
|
));
|
|
|
|
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
|
|
|