option to make textarea input required or optional

This commit is contained in:
Anton Tranelis 2024-11-29 18:05:26 +01:00
parent af639c7224
commit 3014cf682f
2 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ type TextAreaProps = {
inputStyle?: string inputStyle?: string
defaultValue: string defaultValue: string
placeholder?: string placeholder?: string
required?: boolean
updateFormValue?: (value: string) => void updateFormValue?: (value: string) => void
} }
@ -30,6 +31,7 @@ export function TextAreaInput({
inputStyle, inputStyle,
defaultValue, defaultValue,
placeholder, placeholder,
required = true,
updateFormValue, updateFormValue,
}: TextAreaProps) { }: TextAreaProps) {
const ref = useRef<HTMLTextAreaElement>(null) const ref = useRef<HTMLTextAreaElement>(null)
@ -90,7 +92,7 @@ export function TextAreaInput({
</label> </label>
) : null} ) : null}
<textarea <textarea
required required={required}
ref={ref} ref={ref}
value={inputValue} value={inputValue}
name={dataField} name={dataField}

View File

@ -18,6 +18,7 @@ export const ProfileTextForm = ({
heading, heading,
size, size,
hideInputLabel, hideInputLabel,
required,
}: { }: {
state: FormState state: FormState
setState: React.Dispatch<React.SetStateAction<any>> setState: React.Dispatch<React.SetStateAction<any>>
@ -25,6 +26,7 @@ export const ProfileTextForm = ({
heading: string heading: string
size: string size: string
hideInputLabel: boolean hideInputLabel: boolean
required?: boolean
}) => { }) => {
const [field, setField] = useState<string>(dataField || 'text') const [field, setField] = useState<string>(dataField || 'text')
@ -57,6 +59,7 @@ export const ProfileTextForm = ({
labelStyle={hideInputLabel ? 'tw-hidden' : ''} labelStyle={hideInputLabel ? 'tw-hidden' : ''}
containerStyle={size === 'full' ? 'tw-grow tw-h-full' : ''} containerStyle={size === 'full' ? 'tw-grow tw-h-full' : ''}
inputStyle={size === 'full' ? 'tw-h-full' : 'tw-h-24'} inputStyle={size === 'full' ? 'tw-h-full' : 'tw-h-24'}
required={required}
/> />
</div> </div>
) )