Added several files to the AutoForm component for better form functionality including a file for each type of input field (checkbox, date, enum, file, number, radio-group, switch, etc). Managed the configurations in a separate file and handled dependencies to control form behaviours. This commit enhances form handling capabilities and simplifies the process for creating versatile forms.
28 lines
870 B
TypeScript
28 lines
870 B
TypeScript
import { FormControl, FormItem, FormMessage } from "@/components/ui/form";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import AutoFormLabel from "../common/label";
|
|
import AutoFormTooltip from "../common/tooltip";
|
|
import type { AutoFormInputComponentProps } from "../types";
|
|
|
|
export default function AutoFormTextarea({
|
|
label,
|
|
isRequired,
|
|
fieldConfigItem,
|
|
fieldProps,
|
|
}: AutoFormInputComponentProps) {
|
|
const { showLabel: _showLabel, ...fieldPropsWithoutShowLabel } = fieldProps;
|
|
const showLabel = _showLabel === undefined ? true : _showLabel;
|
|
return (
|
|
<FormItem>
|
|
{showLabel && (
|
|
<AutoFormLabel label={fieldConfigItem?.label || label} isRequired={isRequired} />
|
|
)}
|
|
<FormControl>
|
|
<Textarea {...fieldPropsWithoutShowLabel} />
|
|
</FormControl>
|
|
<AutoFormTooltip fieldConfigItem={fieldConfigItem} />
|
|
<FormMessage />
|
|
</FormItem>
|
|
);
|
|
}
|