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.
32 lines
935 B
TypeScript
32 lines
935 B
TypeScript
import { FormControl, FormItem, FormMessage } from "@/components/ui/form";
|
|
import { Input } from "@/components/ui/input";
|
|
import AutoFormLabel from "../common/label";
|
|
import AutoFormTooltip from "../common/tooltip";
|
|
import { AutoFormInputComponentProps } from "../types";
|
|
|
|
export default function AutoFormNumber({
|
|
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>
|
|
<Input type="number" {...fieldPropsWithoutShowLabel} />
|
|
</FormControl>
|
|
<AutoFormTooltip fieldConfigItem={fieldConfigItem} />
|
|
<FormMessage />
|
|
</FormItem>
|
|
);
|
|
}
|