import { type AnchorHTMLAttributes, type ReactNode } from "react";
import { Link } from "@remix-run/react";
import { motion } from "framer-motion";
import { usePathName } from "~/hooks/usePathName";
import { cn } from "~/utils/cn";
import { type RenderIcon, Icon } from "../primitives/Icon";
import { SimpleTooltip } from "../primitives/Tooltip";
export function SideMenuItem({
icon,
activeIconColor,
inactiveIconColor,
iconClassName,
trailingIcon,
trailingIconClassName,
name,
to,
badge,
target,
isCollapsed = false,
action,
disableIconHover = false,
indented = false,
"data-action": dataAction,
}: {
icon?: RenderIcon;
activeIconColor?: string;
inactiveIconColor?: string;
iconClassName?: string;
trailingIcon?: RenderIcon;
trailingIconClassName?: string;
name: string;
to: string;
badge?: ReactNode;
target?: AnchorHTMLAttributes["target"];
isCollapsed?: boolean;
action?: ReactNode;
disableIconHover?: boolean;
/**
* Visually indented variant — same item, just pushed further from
* the left edge so it reads as a child of the row above. Used for
* grouped sub-items like the Tasks > (Agents / Standard / Scheduled)
* cluster. The indent is only applied when the side menu is expanded.
*/
indented?: boolean;
"data-action"?: string;
}) {
const pathName = usePathName();
const isActive = pathName === to;
const isIndented = indented && !isCollapsed;
const linkElement = (
{name}
{badge && !isCollapsed && (
{badge}
)}
{trailingIcon && !isCollapsed && (
)}
);
const link = isIndented ? (
) : (
linkElement
);
if (action) {
return (
{!isCollapsed && (
{action}
)}
);
}
return (
);
}