mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-18 17:55:58 +02:00
fix ref type error
This commit is contained in:
parent
419e576a3e
commit
2398931cc1
28 changed files with 1764 additions and 2011 deletions
|
@ -72,15 +72,10 @@ const FormItemContext = React.createContext<FormItemContextValue>(
|
|||
{} as FormItemContextValue
|
||||
)
|
||||
|
||||
const FormItem = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement> & {
|
||||
ref: React.RefObject<HTMLDivElement>;
|
||||
}
|
||||
) => {
|
||||
const FormItem = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const id = React.useId()
|
||||
|
||||
return (
|
||||
|
@ -88,18 +83,13 @@ const FormItem = (
|
|||
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
||||
</FormItemContext.Provider>
|
||||
)
|
||||
}
|
||||
})
|
||||
FormItem.displayName = "FormItem"
|
||||
|
||||
const FormLabel = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
|
||||
ref: React.RefObject<React.ElementRef<typeof LabelPrimitive.Root>>;
|
||||
}
|
||||
) => {
|
||||
const FormLabel = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const { error, formItemId } = useFormField()
|
||||
|
||||
return (
|
||||
|
@ -110,17 +100,13 @@ const FormLabel = (
|
|||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
})
|
||||
FormLabel.displayName = "FormLabel"
|
||||
|
||||
const FormControl = (
|
||||
{
|
||||
ref,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof Slot> & {
|
||||
ref: React.RefObject<React.ElementRef<typeof Slot>>;
|
||||
}
|
||||
) => {
|
||||
const FormControl = React.forwardRef<
|
||||
React.ElementRef<typeof Slot>,
|
||||
React.ComponentPropsWithoutRef<typeof Slot>
|
||||
>(({ ...props }, ref) => {
|
||||
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
||||
|
||||
return (
|
||||
|
@ -136,18 +122,13 @@ const FormControl = (
|
|||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
})
|
||||
FormControl.displayName = "FormControl"
|
||||
|
||||
const FormDescription = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLParagraphElement> & {
|
||||
ref: React.RefObject<HTMLParagraphElement>;
|
||||
}
|
||||
) => {
|
||||
const FormDescription = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const { formDescriptionId } = useFormField()
|
||||
|
||||
return (
|
||||
|
@ -158,19 +139,13 @@ const FormDescription = (
|
|||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
})
|
||||
FormDescription.displayName = "FormDescription"
|
||||
|
||||
const FormMessage = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLParagraphElement> & {
|
||||
ref: React.RefObject<HTMLParagraphElement>;
|
||||
}
|
||||
) => {
|
||||
const FormMessage = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, children, ...props }, ref) => {
|
||||
const { error, formMessageId } = useFormField()
|
||||
const body = error ? String(error?.message) : children
|
||||
|
||||
|
@ -188,7 +163,7 @@ const FormMessage = (
|
|||
{body}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
})
|
||||
FormMessage.displayName = "FormMessage"
|
||||
|
||||
export {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue