'use client' import { button } from './button' import { dropdownMenu } from './dropdown-menu' import * as MenubarPrimitive from '@radix-ui/react-menubar' import { IconCheck, IconChevronRight, IconPoint } from '@tabler/icons-react' import { forwardRef } from 'react' import type { VariantProps } from 'tailwind-variants' import { tv } from 'tailwind-variants' import type { Merge } from 'type-fest' const menubar = tv({ slots: { root: 'flex h-9 items-center gap-1 rounded-md border bg-white p-1 shadow-sm', trigger: button({ variant: 'ghost', size: 'xs' }).root({ className: ['text-sm font-medium px-3 rounded-sm', 'data-[state=open]:bg-bg--active'], }), }, }) const MenubarRoot = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >((props, ref) => { const { root } = menubar() return ( ) }) MenubarRoot.displayName = MenubarPrimitive.Root.displayName const MenubarTrigger = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >((props, ref) => { const { trigger } = menubar() return ( ) }) MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName const MenubarSubTrigger = forwardRef< React.ElementRef, Merge< Merge< React.ComponentPropsWithoutRef, VariantProps >, { iconProps?: React.ComponentProps } > >(({ iconProps, inset, children, ...props }, ref) => { const { subTrigger, subTriggerIcon } = dropdownMenu({ inset }) return ( {children} ) }) MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName const MenubarSubContent = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, { portalProps?: React.ComponentProps } > >(({ portalProps, ...props }, ref) => { const { subContent } = dropdownMenu() return ( ) }) MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName const MenubarContent = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, { portalProps?: React.ComponentProps } > >(({ portalProps, ...props }, ref) => { const { content } = dropdownMenu() return ( ) }) MenubarContent.displayName = MenubarPrimitive.Content.displayName const MenubarItem = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, VariantProps > >(({ inset, ...props }, ref) => { const { item } = dropdownMenu({ inset }) return ( ) }) MenubarItem.displayName = MenubarPrimitive.Item.displayName const MenubarCheckboxItem = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, { indicatorIconProps?: React.ComponentProps } > >(({ indicatorIconProps, children, ...props }, ref) => { const { checkboxItem, checkboxItemIndicatorIcon } = dropdownMenu() return ( {children} ) }) MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName const MenubarRadioItem = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, { indicatorIconProps?: React.ComponentProps } > >(({ indicatorIconProps, children, ...props }, ref) => { const { radioItem, radioItemIndicatorIcon } = dropdownMenu() return ( {children} ) }) MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName const MenubarLabel = forwardRef< React.ElementRef, Merge< React.ComponentPropsWithoutRef, VariantProps > >(({ inset, ...props }, ref) => { const { label } = dropdownMenu({ inset }) return ( ) }) MenubarLabel.displayName = MenubarPrimitive.Label.displayName const MenubarSeparator = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >((props, ref) => { const { separator } = dropdownMenu() return ( ) }) MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName function MenubarItemShortcut(props: React.ComponentProps<'span'>) { const { itemShortcut } = dropdownMenu() return } const Menubar = Object.assign(MenubarRoot, { Menu: MenubarPrimitive.Menu, Trigger: MenubarTrigger, Content: MenubarContent, Group: MenubarPrimitive.Group, Separator: MenubarSeparator, Label: MenubarLabel, Item: Object.assign(MenubarItem, { Shortcut: MenubarItemShortcut, }), Radio: Object.assign(MenubarPrimitive.RadioGroup, { Item: MenubarRadioItem, }), CheckboxItem: MenubarCheckboxItem, Sub: Object.assign(MenubarPrimitive.Sub, { Trigger: MenubarSubTrigger, Content: MenubarSubContent, }), }) export default Menubar export { menubar, MenubarPrimitive }