2026-01-23 17:23:52 +03:00
|
|
|
// Textarea Widget - maps to shadcn/ui Textarea
|
|
|
|
|
import type { WidgetProps } from "@rjsf/utils";
|
|
|
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
|
|
|
|
|
|
|
|
export function TextareaWidget(props: WidgetProps) {
|
|
|
|
|
const {
|
|
|
|
|
id,
|
|
|
|
|
value,
|
|
|
|
|
disabled,
|
|
|
|
|
readonly,
|
|
|
|
|
onChange,
|
|
|
|
|
onBlur,
|
|
|
|
|
onFocus,
|
|
|
|
|
placeholder,
|
|
|
|
|
schema,
|
|
|
|
|
options,
|
|
|
|
|
} = props;
|
|
|
|
|
|
2026-01-26 02:44:47 +03:00
|
|
|
const isNullable = Array.isArray(schema.type)
|
|
|
|
|
? schema.type.includes("null")
|
|
|
|
|
: false;
|
|
|
|
|
|
2026-01-23 17:23:52 +03:00
|
|
|
return (
|
|
|
|
|
<Textarea
|
|
|
|
|
id={id}
|
|
|
|
|
value={value ?? ""}
|
|
|
|
|
disabled={disabled || readonly}
|
|
|
|
|
placeholder={placeholder || (options.placeholder as string) || ""}
|
|
|
|
|
rows={(options.rows as number) || 3}
|
|
|
|
|
onChange={(e) =>
|
2026-01-26 02:44:47 +03:00
|
|
|
onChange(
|
|
|
|
|
e.target.value === ""
|
|
|
|
|
? isNullable
|
|
|
|
|
? null
|
|
|
|
|
: undefined
|
|
|
|
|
: e.target.value,
|
|
|
|
|
)
|
2026-01-23 17:23:52 +03:00
|
|
|
}
|
|
|
|
|
onBlur={(e) => onBlur(id, e.target.value)}
|
|
|
|
|
onFocus={(e) => onFocus(id, e.target.value)}
|
|
|
|
|
aria-label={schema.title}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|