"use client"; import type { WidgetConfig } from "../../lib/config"; import type { SectionDef } from "../../lib/sections"; import { Check } from "../../components/WidgetFields"; import { SectionMini } from "./SectionMini"; // One strip on the floorplan, drawn roughly where it will render: its own // miniature, its name, the move controls, and — folded away until asked for — // the display options that belong to this section and nowhere else. // // The on/off control is a real checkbox rather than a close button: unchecking // it is what sends the section to the tray, and it keeps the section reachable // by name for both keyboard users and the e2e suite. const BTN = "flex h-6 w-6 items-center justify-center rounded border border-border text-xs font-medium text-muted-foreground hover:bg-muted disabled:opacity-40"; export function SectionCard({ def, config, row, cell, index, cellLength, cellCount, rowCount, dragging, onChange, onMove, onMoveCell, onMoveRow, onDragStart, onDragEnd, expanded, onToggleExpanded, }: { def: SectionDef; config: WidgetConfig; row: number; cell: number; index: number; cellLength: number; cellCount: number; rowCount: number; dragging: boolean; onChange: (patch: Partial) => void; onMove: (dir: -1 | 1) => void; onMoveCell: (dir: -1 | 1) => void; onMoveRow: (dir: -1 | 1) => void; onDragStart: () => void; onDragEnd: () => void; expanded: boolean; onToggleExpanded: () => void; }) { return (
  • { e.dataTransfer.effectAllowed = "move"; e.dataTransfer.setData("text/plain", def.id); onDragStart(); }} onDragEnd={onDragEnd} className={`cursor-grab rounded-md border border-border bg-card p-2 shadow-sm motion-safe:transition ${ dragging ? "opacity-60 shadow-lg motion-safe:scale-[1.02]" : "hover:border-border-strong" }`} > {/* Wraps rather than truncates: in a multi-track board there isn't room for the name and the move controls on one line, and the name is the part you can't do without. */}
    ⠿

    {def.hint}

    {cellCount > 1 && ( <> )} {/* Rows are the new dimension, so they need their own pair — every drag has to stay reachable from the keyboard, which is what the arrows on this card have always been for. */} {rowCount > 1 && ( <> )} {def.options.length > 0 && ( )}
    {expanded && def.options.length > 0 && (
    {def.options.map((o) => ( onChange({ [o.key]: v } as Partial)} /> ))}
    )}
  • ); }