/* Copyright 2026 Marimo. All rights reserved. */ import type React from "react"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { useCellIds } from "@/core/cells/cells"; import type { CellId } from "@/core/cells/ids"; import { CellLink } from "./cell-link"; interface Props { maxCount: number; cellIds: CellId[]; skipScroll?: boolean; onClick?: (cellId: CellId) => void; } export const CellLinkList: React.FC = ({ maxCount, cellIds, onClick, skipScroll, }) => { const cellIndex = useCellIds(); const sortedCellIds = cellIds.toSorted((a, b) => { return cellIndex.inOrderIds.indexOf(a) - cellIndex.inOrderIds.indexOf(b); }); if (cellIds.length === 0) { return
--
; } return ( <> {sortedCellIds.slice(0, maxCount).map((cellId, idx) => ( onClick(cellId) : undefined} /> {idx < cellIds.length - 1 && ", "} ))} {cellIds.length > maxCount && ( +{cellIds.length - maxCount} more
{sortedCellIds.slice(maxCount).map((cellId) => ( onClick(cellId) : undefined} /> ))}
)} ); };