import { Group, Circle, Line, Rect, Text } from 'react-konva'; import type { ProjectedElectrical } from '../utils/projectionMapping'; import { projectionToPixel } from '../utils/projectionMapping'; interface ProjectionElectricalProps { readonly projected: ProjectedElectrical; readonly wallHeight: number; readonly scale: number; readonly padding: number; readonly isSelected: boolean; readonly isDragging?: boolean; readonly dragFromFloor?: number; readonly dragAlongWall?: number; readonly onClick: () => void; readonly onDragStart?: (itemId: string, evt: MouseEvent) => void; } const SYMBOL_SIZE = 12; /** Render a wall-mounted electrical item in wall elevation view. */ export function ProjectionElectrical({ projected, wallHeight, scale, padding, isSelected, isDragging = false, dragFromFloor, dragAlongWall, onClick, onDragStart, }: ProjectionElectricalProps) { const { position, item } = projected; const displayFromFloor = isDragging && dragFromFloor != null ? dragFromFloor : position.fromFloor; const displayAlongWall = isDragging && dragAlongWall != null ? dragAlongWall : position.alongWall; const center = projectionToPixel( displayAlongWall, displayFromFloor, wallHeight, scale, padding, ); const strokeColor = isSelected ? '#2563eb' : '#64748b'; const fillColor = isSelected ? '#dbeafe' : '#f1f5f9'; const half = SYMBOL_SIZE / 2; return ( { if (onDragStart && e.evt.button === 0) { onDragStart(item.id, e.evt); } }} style={{ cursor: onDragStart ? 'grab' : 'default' }} > {/* Drag ghost outline */} {isDragging && ( )} {item.type === 'OUTLET' && ( <> {/* IEC outlet symbol: circle with two horizontal lines */} )} {item.type === 'SWITCH' && ( <> {/* IEC switch symbol: circle with diagonal line */} )} {item.type === 'LIGHT_WALL' && ( <> {/* Wall light: semicircle shape */} )} {/* Fallback for other wall-mounted types */} {item.type !== 'OUTLET' && item.type !== 'SWITCH' && item.type !== 'LIGHT_WALL' && ( )} {/* Type label below symbol */} ); }