2025-05-05 17:11:44 +00:00
|
|
|
import * as React from "react"
|
2026-03-17 09:24:39 +00:00
|
|
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
2025-05-05 17:11:44 +00:00
|
|
|
|
|
|
|
|
import { cn } from "@repo/shadcn-ui/lib/utils"
|
2026-03-17 17:49:54 +00:00
|
|
|
import { CheckIcon, ChevronRightIcon } from "lucide-react"
|
2025-05-05 17:11:44 +00:00
|
|
|
|
|
|
|
|
function DropdownMenu({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
|
|
|
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuPortal({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuTrigger({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Trigger
|
|
|
|
|
data-slot="dropdown-menu-trigger"
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuContent({
|
|
|
|
|
className,
|
2026-03-17 17:49:54 +00:00
|
|
|
align = "start",
|
2025-05-05 17:11:44 +00:00
|
|
|
sideOffset = 4,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Portal>
|
|
|
|
|
<DropdownMenuPrimitive.Content
|
|
|
|
|
data-slot="dropdown-menu-content"
|
|
|
|
|
sideOffset={sideOffset}
|
2026-03-17 17:49:54 +00:00
|
|
|
align={align}
|
|
|
|
|
className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
2025-05-05 17:11:44 +00:00
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
</DropdownMenuPrimitive.Portal>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuGroup({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuItem({
|
|
|
|
|
className,
|
|
|
|
|
inset,
|
|
|
|
|
variant = "default",
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
|
|
|
inset?: boolean
|
|
|
|
|
variant?: "default" | "destructive"
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Item
|
|
|
|
|
data-slot="dropdown-menu-item"
|
|
|
|
|
data-inset={inset}
|
|
|
|
|
data-variant={variant}
|
|
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuCheckboxItem({
|
|
|
|
|
className,
|
|
|
|
|
children,
|
|
|
|
|
checked,
|
2026-03-17 17:49:54 +00:00
|
|
|
inset,
|
2025-05-05 17:11:44 +00:00
|
|
|
...props
|
2026-03-17 17:49:54 +00:00
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
|
|
|
|
|
inset?: boolean
|
|
|
|
|
}) {
|
2025-05-05 17:11:44 +00:00
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.CheckboxItem
|
|
|
|
|
data-slot="dropdown-menu-checkbox-item"
|
2026-03-17 17:49:54 +00:00
|
|
|
data-inset={inset}
|
2025-05-05 17:11:44 +00:00
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
checked={checked}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
2026-03-17 17:49:54 +00:00
|
|
|
<span
|
|
|
|
|
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
|
|
|
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
|
|
|
>
|
2025-05-05 17:11:44 +00:00
|
|
|
<DropdownMenuPrimitive.ItemIndicator>
|
2026-03-17 17:49:54 +00:00
|
|
|
<CheckIcon
|
|
|
|
|
/>
|
2025-05-05 17:11:44 +00:00
|
|
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
|
|
|
</span>
|
|
|
|
|
{children}
|
|
|
|
|
</DropdownMenuPrimitive.CheckboxItem>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuRadioGroup({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.RadioGroup
|
|
|
|
|
data-slot="dropdown-menu-radio-group"
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuRadioItem({
|
|
|
|
|
className,
|
|
|
|
|
children,
|
2026-03-17 17:49:54 +00:00
|
|
|
inset,
|
2025-05-05 17:11:44 +00:00
|
|
|
...props
|
2026-03-17 17:49:54 +00:00
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
|
|
|
|
|
inset?: boolean
|
|
|
|
|
}) {
|
2025-05-05 17:11:44 +00:00
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.RadioItem
|
|
|
|
|
data-slot="dropdown-menu-radio-item"
|
2026-03-17 17:49:54 +00:00
|
|
|
data-inset={inset}
|
2025-05-05 17:11:44 +00:00
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
2026-03-17 17:49:54 +00:00
|
|
|
<span
|
|
|
|
|
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
|
|
|
data-slot="dropdown-menu-radio-item-indicator"
|
|
|
|
|
>
|
2025-05-05 17:11:44 +00:00
|
|
|
<DropdownMenuPrimitive.ItemIndicator>
|
2026-03-17 17:49:54 +00:00
|
|
|
<CheckIcon
|
|
|
|
|
/>
|
2025-05-05 17:11:44 +00:00
|
|
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
|
|
|
</span>
|
|
|
|
|
{children}
|
|
|
|
|
</DropdownMenuPrimitive.RadioItem>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuLabel({
|
|
|
|
|
className,
|
|
|
|
|
inset,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
|
|
|
inset?: boolean
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Label
|
|
|
|
|
data-slot="dropdown-menu-label"
|
|
|
|
|
data-inset={inset}
|
|
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuSeparator({
|
|
|
|
|
className,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.Separator
|
|
|
|
|
data-slot="dropdown-menu-separator"
|
2026-03-17 17:49:54 +00:00
|
|
|
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
2025-05-05 17:11:44 +00:00
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuShortcut({
|
|
|
|
|
className,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<"span">) {
|
|
|
|
|
return (
|
|
|
|
|
<span
|
|
|
|
|
data-slot="dropdown-menu-shortcut"
|
|
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuSub({
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
|
|
|
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuSubTrigger({
|
|
|
|
|
className,
|
|
|
|
|
inset,
|
|
|
|
|
children,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
|
|
|
inset?: boolean
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.SubTrigger
|
|
|
|
|
data-slot="dropdown-menu-sub-trigger"
|
|
|
|
|
data-inset={inset}
|
|
|
|
|
className={cn(
|
2026-03-17 17:49:54 +00:00
|
|
|
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
2025-05-05 17:11:44 +00:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
2026-03-17 17:49:54 +00:00
|
|
|
<ChevronRightIcon className="ml-auto" />
|
2025-05-05 17:11:44 +00:00
|
|
|
</DropdownMenuPrimitive.SubTrigger>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DropdownMenuSubContent({
|
|
|
|
|
className,
|
|
|
|
|
...props
|
|
|
|
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenuPrimitive.SubContent
|
|
|
|
|
data-slot="dropdown-menu-sub-content"
|
2026-03-17 17:49:54 +00:00
|
|
|
className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
2025-05-05 17:11:44 +00:00
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export {
|
|
|
|
|
DropdownMenu,
|
|
|
|
|
DropdownMenuPortal,
|
|
|
|
|
DropdownMenuTrigger,
|
|
|
|
|
DropdownMenuContent,
|
|
|
|
|
DropdownMenuGroup,
|
|
|
|
|
DropdownMenuLabel,
|
|
|
|
|
DropdownMenuItem,
|
|
|
|
|
DropdownMenuCheckboxItem,
|
|
|
|
|
DropdownMenuRadioGroup,
|
|
|
|
|
DropdownMenuRadioItem,
|
|
|
|
|
DropdownMenuSeparator,
|
|
|
|
|
DropdownMenuShortcut,
|
|
|
|
|
DropdownMenuSub,
|
|
|
|
|
DropdownMenuSubTrigger,
|
|
|
|
|
DropdownMenuSubContent,
|
|
|
|
|
}
|