TerminalInput.jsx
1 import PropTypes from 'prop-types'; 2 3 const TerminalInput = ({ inputRef, inputValue, setInputValue, handleCommandInput, handleKeyDown }) => ( 4 <input 5 ref={inputRef} 6 type="text" 7 className="command-input" 8 value={inputValue} 9 autoFocus 10 onChange={(e) => setInputValue(e.target.value)} 11 onKeyDown={(e) => { 12 if (e.key === 'Enter') { 13 handleCommandInput(inputValue); 14 } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') { 15 handleKeyDown(e); 16 } 17 }} 18 /> 19 ); 20 21 TerminalInput.propTypes = { 22 inputRef: PropTypes.object.isRequired, 23 inputValue: PropTypes.string.isRequired, 24 setInputValue: PropTypes.func.isRequired, 25 handleCommandInput: PropTypes.func.isRequired, 26 handleKeyDown: PropTypes.func.isRequired 27 }; 28 29 export default TerminalInput;