40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
import { Label } from "@/components/ui/label";
|
||
|
|
import { Textarea } from "@/components/ui/textarea";
|
||
|
|
import { cn } from "@/lib/utils";
|
||
|
|
import { WidgetComponent } from "@/types/screen";
|
||
|
|
|
||
|
|
interface TextareaWidgetProps {
|
||
|
|
widget: WidgetComponent;
|
||
|
|
value?: string;
|
||
|
|
onChange?: (value: string) => void;
|
||
|
|
className?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default function TextareaWidget({ widget, value, onChange, className }: TextareaWidgetProps) {
|
||
|
|
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||
|
|
onChange?.(e.target.value);
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className={cn("space-y-2", className)}>
|
||
|
|
{widget.label && (
|
||
|
|
<Label htmlFor={widget.id} className="text-sm font-medium">
|
||
|
|
{widget.label}
|
||
|
|
{widget.required && <span className="ml-1 text-red-500">*</span>}
|
||
|
|
</Label>
|
||
|
|
)}
|
||
|
|
<Textarea
|
||
|
|
id={widget.id}
|
||
|
|
placeholder={widget.placeholder}
|
||
|
|
value={value || ""}
|
||
|
|
onChange={handleChange}
|
||
|
|
required={widget.required}
|
||
|
|
readOnly={widget.readonly}
|
||
|
|
className={cn("min-h-[100px] w-full", widget.readonly && "cursor-not-allowed bg-gray-50")}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|