import {IconDefinition} from "@fortawesome/fontawesome-svg-core"; import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; import React, {Dispatch, SetStateAction, useState} from "react"; export default function TextInputField( { label, inputValue, inputType, setInputValue, inputId, isRequired = false, hintMessage, isDisabled = false, icon }:{ label: string, inputValue: string, inputType: "text" | "password" | "email" | "url" | "date" | "number", setInputValue: Dispatch>, inputId: string, isRequired?: boolean, hintMessage?: string, isDisabled?: boolean, icon?: IconDefinition, } ){ const [hintShown, setHintShown] = useState(false); function showHint(){ if (hintMessage){ setHintShown(true); } } function hideHint(){ if (hintShown){ setHintShown(false); } } return (
{ icon && } setInputValue(e.target.value)} required={isRequired} placeholder={`${label}${isRequired ? ' *' : ''}`} onFocus={showHint} onBlur={hideHint} className={'w-full bg-transparent text-text-primary border-none outline-none placeholder:text-muted/60 disabled:opacity-50 disabled:cursor-not-allowed'} disabled={isDisabled} />
{ hintShown && hintMessage && {hintMessage} }
) }