2025-07-09 17:56:15 +00:00
|
|
|
// DatePickerField.tsx
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
FormControl,
|
2025-09-24 11:49:17 +00:00
|
|
|
FormDescription,
|
2025-07-09 17:56:15 +00:00
|
|
|
FormField,
|
|
|
|
|
FormItem,
|
|
|
|
|
FormLabel,
|
|
|
|
|
FormMessage,
|
|
|
|
|
Textarea,
|
|
|
|
|
} from "@repo/shadcn-ui/components";
|
|
|
|
|
|
|
|
|
|
import { cn } from "@repo/shadcn-ui/lib/utils";
|
|
|
|
|
import { Control, FieldPath, FieldValues } from "react-hook-form";
|
|
|
|
|
import { useTranslation } from "../../locales/i18n.ts";
|
|
|
|
|
|
|
|
|
|
type TextAreaFieldProps<TFormValues extends FieldValues> = {
|
|
|
|
|
control: Control<TFormValues>;
|
|
|
|
|
name: FieldPath<TFormValues>;
|
|
|
|
|
label?: string;
|
|
|
|
|
placeholder?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
required?: boolean;
|
|
|
|
|
readOnly?: boolean;
|
|
|
|
|
className?: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function TextAreaField<TFormValues extends FieldValues>({
|
|
|
|
|
control,
|
|
|
|
|
name,
|
|
|
|
|
label,
|
|
|
|
|
placeholder,
|
|
|
|
|
description,
|
|
|
|
|
disabled = false,
|
|
|
|
|
required = false,
|
|
|
|
|
readOnly = false,
|
|
|
|
|
className,
|
|
|
|
|
}: TextAreaFieldProps<TFormValues>) {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const isDisabled = disabled || readOnly;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<FormField
|
|
|
|
|
control={control}
|
|
|
|
|
name={name}
|
|
|
|
|
render={({ field }) => (
|
2025-07-17 08:50:28 +00:00
|
|
|
<FormItem className={cn("space-y-0", className)}>
|
2025-07-09 17:56:15 +00:00
|
|
|
{label && (
|
2025-09-21 19:46:51 +00:00
|
|
|
<div className='mb-1 flex justify-between gap-2'>
|
|
|
|
|
<div className='flex items-center gap-2'>
|
|
|
|
|
<FormLabel htmlFor={name} className='m-0'>
|
|
|
|
|
{label}
|
|
|
|
|
</FormLabel>
|
|
|
|
|
{required && (
|
|
|
|
|
<span className='text-xs text-destructive'>{t("common.required")}</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-07-09 17:56:15 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<FormControl>
|
2025-09-24 11:49:17 +00:00
|
|
|
<Textarea
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
className={"bg-background"}
|
|
|
|
|
{...field}
|
|
|
|
|
/>
|
2025-07-09 17:56:15 +00:00
|
|
|
</FormControl>
|
|
|
|
|
|
2025-09-24 11:49:17 +00:00
|
|
|
<FormDescription className={cn("text-xs truncate", !description && "invisible")}>
|
2025-07-09 17:56:15 +00:00
|
|
|
{description || "\u00A0"}
|
2025-09-24 11:49:17 +00:00
|
|
|
</FormDescription>
|
2025-07-09 17:56:15 +00:00
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|