Update AGENTS.md. Start fixing old weird errors
This commit is contained in:
+19
-16
@@ -15,12 +15,12 @@ import { cn, Label } from '@gib/ui';
|
||||
|
||||
const Form = FormProvider;
|
||||
|
||||
type FormFieldContextValue<
|
||||
interface FormFieldContextValue<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = {
|
||||
> {
|
||||
name: TName;
|
||||
};
|
||||
}
|
||||
|
||||
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
||||
{} as FormFieldContextValue,
|
||||
@@ -62,15 +62,15 @@ const useFormField = () => {
|
||||
};
|
||||
};
|
||||
|
||||
type FormItemContextValue = {
|
||||
interface FormItemContextValue {
|
||||
id: string;
|
||||
};
|
||||
}
|
||||
|
||||
const FormItemContext = React.createContext<FormItemContextValue>(
|
||||
{} as FormItemContextValue,
|
||||
);
|
||||
|
||||
function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
|
||||
const FormItem = ({ className, ...props }: React.ComponentProps<'div'>) => {
|
||||
const id = React.useId();
|
||||
|
||||
return (
|
||||
@@ -82,12 +82,12 @@ function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
|
||||
/>
|
||||
</FormItemContext.Provider>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function FormLabel({
|
||||
const FormLabel = ({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||
}: React.ComponentProps<typeof LabelPrimitive.Root>) => {
|
||||
const { error, formItemId } = useFormField();
|
||||
|
||||
return (
|
||||
@@ -99,9 +99,9 @@ function FormLabel({
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
||||
const FormControl = ({ ...props }: React.ComponentProps<typeof Slot>) => {
|
||||
const { error, formItemId, formDescriptionId, formMessageId } =
|
||||
useFormField();
|
||||
|
||||
@@ -118,9 +118,12 @@ function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function FormDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
||||
const FormDescription = ({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<'p'>) => {
|
||||
const { formDescriptionId } = useFormField();
|
||||
|
||||
return (
|
||||
@@ -131,9 +134,9 @@ function FormDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
|
||||
const FormMessage = ({ className, ...props }: React.ComponentProps<'p'>) => {
|
||||
const { error, formMessageId } = useFormField();
|
||||
const body = error ? String(error?.message ?? '') : props.children;
|
||||
|
||||
@@ -151,7 +154,7 @@ function FormMessage({ className, ...props }: React.ComponentProps<'p'>) {
|
||||
{body}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
useFormField,
|
||||
|
||||
Reference in New Issue
Block a user