sendou.ink/app/form/fields/TextareaFormField.tsx
Kalle c1cc82c807
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Migrate /u/:identifier/edit to SendouForm, fix bad IGN (#2849)
2026-03-03 07:12:04 +02:00

51 lines
966 B
TypeScript

import * as React from "react";
import type { FormFieldProps } from "../types";
import { ariaAttributes } from "../utils";
import { FormFieldWrapper } from "./FormFieldWrapper";
type TextareaFormFieldProps = FormFieldProps<"text-area"> & {
disabled?: boolean;
value: string;
onChange: (value: string) => void;
};
export function TextareaFormField({
name,
label,
bottomText,
maxLength,
error,
onBlur,
disabled,
value,
onChange,
}: TextareaFormFieldProps) {
const id = React.useId();
return (
<FormFieldWrapper
id={id}
name={name}
label={label}
error={error}
bottomText={bottomText}
valueLimits={
maxLength ? { current: value?.length ?? 0, max: maxLength } : undefined
}
>
<textarea
id={id}
value={value}
onChange={(e) => onChange(e.target.value)}
onBlur={() => onBlur?.()}
disabled={disabled}
{...ariaAttributes({
id,
bottomText,
error,
})}
/>
</FormFieldWrapper>
);
}