feat(auto-form): add new fields and form files to AutoForm component
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.
This commit is contained in:
34
src/components/auto-form/fields/checkbox.tsx
Normal file
34
src/components/auto-form/fields/checkbox.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { FormControl, FormItem } from "@/components/ui/form";
|
||||
import AutoFormLabel from "../common/label";
|
||||
import AutoFormTooltip from "../common/tooltip";
|
||||
import type { AutoFormInputComponentProps } from "../types";
|
||||
|
||||
export default function AutoFormCheckbox({
|
||||
label,
|
||||
isRequired,
|
||||
field,
|
||||
fieldConfigItem,
|
||||
fieldProps,
|
||||
}: AutoFormInputComponentProps) {
|
||||
return (
|
||||
<div>
|
||||
<FormItem>
|
||||
<div className="mb-3 flex items-center gap-3">
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
{...fieldProps}
|
||||
/>
|
||||
</FormControl>
|
||||
<AutoFormLabel
|
||||
label={fieldConfigItem?.label || label}
|
||||
isRequired={isRequired}
|
||||
/>
|
||||
</div>
|
||||
</FormItem>
|
||||
<AutoFormTooltip fieldConfigItem={fieldConfigItem} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user