import type { ReactNode, Ref } from 'react' import { useMemo } from 'react' import { AnimatePresence, motion } from 'motion/react' import { cn } from '@/client/lib/cn' import { packItems } from '@/client/features/widgets/grid' import type { GridItem } from '@/client/features/widgets/grid' import { BottomPanel } from '@/client/components/shared/BottomPanel' import { WidgetFrame } from './WidgetFrame' // Static maps so Tailwind includes these classes (dynamic strings get purged) const COL_START: Record = { 0: 'col-start-1', 1: 'col-start-2', 2: 'col-start-3', 3: 'col-start-4' } const ROW_START: Record = { 0: 'row-start-1', 1: 'row-start-2', 2: 'row-start-3', 3: 'row-start-4', 4: 'row-start-5', 5: 'row-start-6', 6: 'row-start-7', 7: 'row-start-8' } const COL_SPAN: Record = { 1: 'col-span-1', 2: 'col-span-2', 3: 'col-span-3', 4: 'col-span-4' } const ROW_SPAN: Record = { 1: 'row-span-1', 2: 'row-span-2', 3: 'row-span-3', 4: 'row-span-4' } type HiddenPanelProps = { items: GridItem[] renderItem: (id: string) => ReactNode onClose: () => void onRestore: (id: string) => void ref?: Ref } export function HiddenPanel({ items, renderItem, onClose, onRestore, ref }: HiddenPanelProps) { const layout = useMemo(() => packItems(items), [items]) return ( {/* gap-2 + grid-cols-4 + [grid-auto-rows:160px] matches RGL's margin/rowHeight exactly */}
{layout.map(item => ( onRestore(item.i)} hidden> {renderItem(item.i)} ))}
) }