// SysML block / actor / constraint rendered as a React Flow custom node. // Drives the softened look from the prototype: stereotype label, divider, property compartment. "use client"; import { Handle, Position, type NodeProps } from "@xyflow/react"; import type { BlockKind } from "../../../lib/fixtures/aristotle"; export interface BlockNodeData extends Record { label: string; kind: BlockKind | "system"; properties: string[]; /** For constraint kinds, optional one-line expression. */ expression?: string; /** Highest severity of any validation issue anchored to this block. */ issueSeverity?: "error" | "warning" | "soft"; } const STEREO: Record = { block: "block", actor: "actor", constraint: "constraint", system: "system", }; export function BlockNode({ data, selected }: NodeProps) { const d = data as BlockNodeData; const kind = d.kind ?? "block"; const isConstraint = kind === "constraint"; const cls = [ "sysml-node", `sysml-node-${kind}`, selected ? "sysml-node-selected" : "", d.issueSeverity ? `sysml-node-issue-${d.issueSeverity}` : "", ] .filter(Boolean) .join(" "); return (
«{STEREO[kind] ?? "block"}»
{d.label}
{!isConstraint &&
} {!isConstraint ? (
{d.properties.length === 0 ? ( no properties ) : ( d.properties.slice(0, 6).map((p, i) => ( · {p} )) )}
) : (
{d.expression ?? "{ }"}
)}
); }