import type { FC, MouseEventHandler, ReactNode } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faChevronDown, faArrowUpRightFromSquare } from "@fortawesome/pro-duotone-svg-icons"; import { Link as AriaLink } from "react-aria-components"; import { Badge } from "@/components/base/badges/badges"; import { cx, sortCx } from "@/utils/cx"; const styles = sortCx({ root: "group relative flex w-full cursor-pointer items-center rounded-md outline-focus-ring transition duration-100 ease-linear select-none focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2", rootSelected: "bg-sidebar-active hover:bg-sidebar-active border-l-2 border-l-brand-600", }); interface NavItemBaseProps { /** Whether the nav item shows only an icon. */ iconOnly?: boolean; /** Whether the collapsible nav item is open. */ open?: boolean; /** URL to navigate to when the nav item is clicked. */ href?: string; /** Type of the nav item. */ type: "link" | "collapsible" | "collapsible-child"; /** Icon component to display. */ icon?: FC>; /** Badge to display. */ badge?: ReactNode; /** Whether the nav item is currently active. */ current?: boolean; /** Whether to truncate the label text. */ truncate?: boolean; /** Handler for click events. */ onClick?: MouseEventHandler; /** Content to display. */ children?: ReactNode; } export const NavItemBase = ({ current, type, badge, href, icon: Icon, children, truncate = true, onClick }: NavItemBaseProps) => { const iconElement = Icon &&