+ "content": "import type { Component, ComponentProps } from \"solid-js\"\nimport { splitProps } from \"solid-js\"\n\nimport { Menubar as MenubarPrimitive } from \"@kobalte/core\"\nimport { TbCheck, TbChevronRight, TbCircle } from \"solid-icons/tb\"\n\nimport { cn } from \"~/lib/utils\"\n\nconst MenubarMenu: Component<MenubarPrimitive.MenubarMenuProps> = (props) => {\n return <MenubarPrimitive.Menu gutter={8} {...props} />\n}\n\nconst MenubarGroup = MenubarPrimitive.Group\n\nconst MenubarPortal = MenubarPrimitive.Portal\n\nconst MenubarSub = MenubarPrimitive.Sub\n\nconst MenubarRadioGroup = MenubarPrimitive.RadioGroup\n\nconst Menubar: Component<MenubarPrimitive.MenubarRootProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <MenubarPrimitive.Root\n class={cn(\n \"bg-background flex h-10 items-center space-x-1 rounded-md border p-1\",\n props.class\n )}\n {...rest}\n ></MenubarPrimitive.Root>\n )\n}\n\nconst MenubarTrigger: Component<MenubarPrimitive.MenubarTriggerProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <MenubarPrimitive.Trigger\n class={cn(\n \"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none\",\n props.class\n )}\n {...rest}\n />\n )\n}\n\nconst MenubarContent: Component<MenubarPrimitive.MenubarContentProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <MenubarPrimitive.Portal>\n <MenubarPrimitive.Content\n class={cn(\n \"bg-popover text-popover-foreground animate-content-hide data-[expanded]:animate-content-show z-50 min-w-[12rem] origin-[var(--kb-menu-content-transform-origin)] overflow-hidden rounded-md border p-1 shadow-md\",\n props.class\n )}\n {...rest}\n />\n </MenubarPrimitive.Portal>\n )\n}\n\nconst MenubarSubTrigger: Component<\n MenubarPrimitive.MenubarSubTriggerProps & { inset?: boolean }\n> = (props) => {\n const [, rest] = splitProps(props, [\"class\", \"children\", \"inset\"])\n return (\n <MenubarPrimitive.SubTrigger\n class={cn(\n \"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none\",\n props.inset && \"pl-8\",\n props.class\n )}\n {...rest}\n >\n {props.children}\n <TbChevronRight class=\"ml-auto h-4 w-4\" />\n </MenubarPrimitive.SubTrigger>\n )\n}\n\nconst MenubarSubContent: Component<MenubarPrimitive.MenubarSubContentProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <MenubarPrimitive.SubContent\n class={cn(\n \"bg-popover text-popover-foreground animate-in z-50 min-w-[8rem] origin-[var(--kb-menu-content-transform-origin)] overflow-hidden rounded-md border p-1 shadow-md\",\n props.class\n )}\n {...rest}\n />\n )\n}\n\nconst MenubarItem: Component<MenubarPrimitive.MenubarItemProps & { inset?: boolean }> = (props) => {\n const [, rest] = splitProps(props, [\"class\", \"inset\"])\n return (\n <MenubarPrimitive.Item\n class={cn(\n \"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n props.inset && \"pl-8\",\n props.class\n )}\n {...rest}\n />\n )\n}\n\nconst MenubarCheckboxItem: Component<MenubarPrimitive.MenubarCheckboxItemProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\", \"children\"])\n return (\n <MenubarPrimitive.CheckboxItem\n class={cn(\n \"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n props.class\n )}\n {...rest}\n >\n <span class=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <MenubarPrimitive.ItemIndicator>\n <TbCheck class=\"h-4 w-4\" />\n </MenubarPrimitive.ItemIndicator>\n </span>\n {props.children}\n </MenubarPrimitive.CheckboxItem>\n )\n}\n\nconst MenubarRadioItem: Component<MenubarPrimitive.MenubarRadioItemProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\", \"children\"])\n return (\n <MenubarPrimitive.RadioItem\n class={cn(\n \"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n props.class\n )}\n {...rest}\n >\n <span class=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <MenubarPrimitive.ItemIndicator>\n <TbCircle class=\"h-2 w-2 fill-current\" />\n </MenubarPrimitive.ItemIndicator>\n </span>\n {props.children}\n </MenubarPrimitive.RadioItem>\n )\n}\n\nconst MenubarItemLabel: Component<MenubarPrimitive.MenubarItemLabelProps & { inset?: boolean }> = (\n props\n) => {\n const [, rest] = splitProps(props, [\"class\", \"inset\"])\n return (\n <MenubarPrimitive.ItemLabel\n class={cn(\"px-2 py-1.5 text-sm font-semibold\", props.inset && \"pl-8\", props.class)}\n {...rest}\n />\n )\n}\n\nconst MenubarGroupLabel: Component<\n MenubarPrimitive.MenubarGroupLabelProps & { inset?: boolean }\n> = (props) => {\n const [, rest] = splitProps(props, [\"class\", \"inset\"])\n return (\n <MenubarPrimitive.GroupLabel\n class={cn(\"px-2 py-1.5 text-sm font-semibold\", props.inset && \"pl-8\", props.class)}\n {...rest}\n />\n )\n}\n\nconst MenubarSeparator: Component<MenubarPrimitive.MenubarSeparatorProps> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <MenubarPrimitive.Separator class={cn(\"bg-muted -mx-1 my-1 h-px\", props.class)} {...rest} />\n )\n}\n\nconst MenubarShortcut: Component<ComponentProps<\"span\">> = (props) => {\n const [, rest] = splitProps(props, [\"class\"])\n return (\n <span\n class={cn(\"text-muted-foreground ml-auto text-xs tracking-widest\", props.class)}\n {...rest}\n />\n )\n}\n\nexport {\n Menubar,\n MenubarMenu,\n MenubarTrigger,\n MenubarContent,\n MenubarItem,\n MenubarSeparator,\n MenubarItemLabel,\n MenubarGroupLabel,\n MenubarCheckboxItem,\n MenubarRadioGroup,\n MenubarRadioItem,\n MenubarPortal,\n MenubarSubContent,\n MenubarSubTrigger,\n MenubarGroup,\n MenubarSub,\n MenubarShortcut\n}\n"
0 commit comments