import { useState } from 'react'; import './PinSelector.css'; interface PinSelectorProps { componentId: string; componentType: string; currentPin?: number; onPinSelect: (componentId: string, pin: number) => void; onClose: () => void; position: { x: number; y: number }; } // Arduino Uno pin groups const PIN_GROUPS = [ { label: 'Digital Pins', pins: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], }, { label: 'Analog Pins', pins: [14, 15, 16, 17, 18, 19], // A0-A5 }, ]; export const PinSelector = ({ componentId, componentType, currentPin, onPinSelect, onClose, position, }: PinSelectorProps) => { const [selectedPin, setSelectedPin] = useState(currentPin); const handlePinClick = (pin: number) => { setSelectedPin(pin); }; const handleConfirm = () => { if (selectedPin !== undefined) { onPinSelect(componentId, selectedPin); onClose(); } }; const formatPinLabel = (pin: number): string => { if (pin >= 14 && pin <= 19) { return `A${pin - 14}`; } return `D${pin}`; }; return (
e.stopPropagation()} >

Select Pin

{componentType}
{PIN_GROUPS.map((group) => (
{group.label}
{group.pins.map((pin) => ( ))}
))}
); };