mirror of
https://github.com/supabase/supabase.git
synced 2026-07-07 00:34:33 +08:00
* init FormInput * fix imports * more clean up * Update FormLayout.tsx * Update FormLayout.tsx * adding size prop * more updates * moved things. added checkbox * check in * Update FormLayout.tsx * Select now has a SelectItem * layouts moved * fix type errors * add layout stories * update story * refactored layout to be easier to maintain. dropped the defaultTheme support * update Form * update Badge * remove old code * remove more * more * Update index.tsx * clean up * Update preview.css * fix type errors * Update index.tsx * Update InfoTooltip.tsx * fix issues * add seperator * Update FormLayout.tsx * match styles to old component
30 lines
938 B
TypeScript
30 lines
938 B
TypeScript
import React, { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react'
|
|
import { ControllerRenderProps, FieldPath, FieldValues } from 'react-hook-form'
|
|
import { FormControl_Shadcn_, FormField_Shadcn_, FormItem_Shadcn_ } from 'ui'
|
|
|
|
/**
|
|
* Handles react-hook-form field type for FormItem<name> components
|
|
*/
|
|
export interface FormItemProps<
|
|
TFieldValues extends FieldValues,
|
|
TName extends FieldPath<TFieldValues>,
|
|
> {
|
|
field?: ControllerRenderProps<TFieldValues, TName>
|
|
}
|
|
|
|
/**
|
|
* Repeatable wrapper for FormItem<name> components
|
|
*/
|
|
const FormItemWrapper = forwardRef<
|
|
ElementRef<typeof FormItem_Shadcn_>,
|
|
ComponentPropsWithoutRef<typeof FormItem_Shadcn_> // Use any as placeholder types
|
|
>(({ ...props }, ref) => (
|
|
<FormItem_Shadcn_ ref={ref} {...props}>
|
|
<FormControl_Shadcn_>{props.children}</FormControl_Shadcn_>
|
|
</FormItem_Shadcn_>
|
|
))
|
|
|
|
FormItemWrapper.displayName = 'FormItemWrapper'
|
|
|
|
export { FormItemWrapper }
|