import React, { useState } from 'react'; import classNames from 'classnames'; import { SessionIconButton } from './icon'; type Props = { label?: string; error?: string; type?: string; value?: string; placeholder: string; maxLength?: number; enableShowHide?: boolean; onValueChanged?: (value: string) => any; onEnterPressed?: any; autoFocus?: boolean; ref?: any; inputDataTestId?: string; }; const LabelItem = (props: { inputValue: string; label?: string }) => { return ( ); }; const ErrorItem = (props: { error: string | undefined }) => { return ( ); }; const ShowHideButton = (props: { toggleForceShow: () => void }) => { return ; }; export const SessionInput = (props: Props) => { const { autoFocus, placeholder, type, value, maxLength, enableShowHide, error, label, onValueChanged, inputDataTestId, } = props; const [inputValue, setInputValue] = useState(''); const [forceShow, setForceShow] = useState(false); const correctType = forceShow ? 'text' : type; const updateInputValue = (e: React.ChangeEvent) => { e.preventDefault(); const val = e.target.value; setInputValue(val); if (onValueChanged) { onValueChanged(val); } }; return (
{error ? ( ) : ( )} { if (event.key === 'Enter' && props.onEnterPressed) { props.onEnterPressed(); } }} /> {enableShowHide && ( { setForceShow(!forceShow); }} /> )}
); };