import Button from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ChevronLeft, ChevronRight, Home, LucideIcon } from "lucide-react"; import { Fragment } from "react/jsx-runtime"; type Props = { curPrefix: number; setCurPrefix: React.Dispatch>; prefixHistory: string[]; actions?: React.ReactNode; }; const ObjectListNavigator = ({ curPrefix, setCurPrefix, prefixHistory, actions, }: Props) => { const onGoBack = () => { if (curPrefix >= 0) setCurPrefix(curPrefix - 1); }; const onGoForward = () => { if (curPrefix < prefixHistory.length - 1) setCurPrefix(curPrefix + 1); }; return (
setCurPrefix(-1)} /> {prefixHistory.map((prefix, i) => ( setCurPrefix(i)} /> ))}
{actions}
); }; type HistoryItemProps = { icon?: LucideIcon; title?: string; isActive: boolean; onClick: () => void; }; const HistoryItem = ({ icon: Icon, title, isActive, onClick, }: HistoryItemProps) => { if (!title && !Icon) { return null; } return ( { e.preventDefault(); onClick(); }} className={cn( "px-2 rounded-md shrink-0 max-w-[150px] truncate", isActive && "bg-neutral", Icon ? "py-1" : null )} > {Icon ? : null} {title} ); }; export default ObjectListNavigator;