import { useMemo } from 'react'; import { Reorder } from 'motion/react'; import { Check, Eye, EyeOff, GripVertical, Lock, RotateCcw } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { cn } from '@/lib/utils'; import type { UiLayoutItem } from '@/types'; // Edit panel for the overview's "编辑布局" mode. Overview-card POSITION/SIZE is // edited in place on the gridstack grid below; this panel only toggles which // cards are shown, and (re)orders the sidebar nav (a 1-D list, so it keeps the // motion Reorder drag from phase 3). Pinned nav items can't be hidden. // ── widget visibility (no drag — grid owns position) ── function VisibilityList({ items, labelFor, onToggle, }: { items: UiLayoutItem[]; labelFor: (id: string) => string; onToggle: (id: string) => void }) { return (
{items.map((item) => (
{labelFor(item.id)}
))}
); } // ── nav reorder + visibility (1-D list, motion drag) ── function NavReorderList({ items, labelFor, pinned, onChange, }: { items: UiLayoutItem[]; labelFor: (id: string) => string; pinned: readonly string[]; onChange: (items: UiLayoutItem[]) => void }) { const ids = useMemo(() => items.map((i) => i.id), [items]); const byId = useMemo(() => new Map(items.map((i) => [i.id, i])), [items]); const reorder = (newIds: string[]) => onChange(newIds.map((id) => byId.get(id)).filter((x): x is UiLayoutItem => !!x)); const toggle = (id: string) => onChange(items.map((i) => (i.id === id ? { ...i, visible: !i.visible } : i))); return ( {ids.map((id) => { const item = byId.get(id); if (!item) return null; const isPinned = pinned.includes(id); return ( {labelFor(id)} {isPinned ? ( ) : ( )} ); })} ); } export interface LayoutEditorProps { blocks: UiLayoutItem[]; blockLabelFor: (id: string) => string; navItems: UiLayoutItem[]; navLabelFor: (id: string) => string; navPinned: readonly string[]; onToggleBlock: (id: string) => void; onNav: (items: UiLayoutItem[]) => void; onReset: () => void; onDone: () => void; } export function LayoutEditor({ blocks, blockLabelFor, navItems, navLabelFor, navPinned, onToggleBlock, onNav, onReset, onDone, }: LayoutEditorProps) { return (
编辑布局 在下方网格直接拖动卡片、拖角缩放;这里控制卡片显隐与导航。改动自动保存。

总览卡片(显隐)

导航栏(拖动排序)

); }