This commit includes the creation of new react components and fields for auto-form functionality. The components include AutoFormLabel, AutoFormTooltip, and specific field components for data types such as AutoFormObject, AutoFormArray, AutoFormDate, AutoFormCheckbox, and others. Added tests to ensure the correct rendering of fields, labels generation, among other behaviors.
33 lines
826 B
TypeScript
33 lines
826 B
TypeScript
import { DatePicker } from "@/components/ui/date-picker";
|
|
import { FormControl, FormItem, FormMessage } from "@/components/ui/form";
|
|
import AutoFormLabel from "../common/label";
|
|
import AutoFormTooltip from "../common/tooltip";
|
|
import { AutoFormInputComponentProps } from "../types";
|
|
|
|
export default function AutoFormDate({
|
|
label,
|
|
isRequired,
|
|
field,
|
|
fieldConfigItem,
|
|
fieldProps,
|
|
}: AutoFormInputComponentProps) {
|
|
return (
|
|
<FormItem>
|
|
<AutoFormLabel
|
|
label={fieldConfigItem?.label || label}
|
|
isRequired={isRequired}
|
|
/>
|
|
<FormControl>
|
|
<DatePicker
|
|
date={field.value}
|
|
setDate={field.onChange}
|
|
{...fieldProps}
|
|
/>
|
|
</FormControl>
|
|
<AutoFormTooltip fieldConfigItem={fieldConfigItem} />
|
|
|
|
<FormMessage />
|
|
</FormItem>
|
|
);
|
|
}
|