form.tsx — ui Source File
Architecture documentation for form.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7d8d565b_677a_b1ee_05eb_401ffef201c2["form.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 8b55cc60_1010_8be1_ff88_b2b7f1a553f7["react-label"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> 8b55cc60_1010_8be1_ff88_b2b7f1a553f7 45bdba50_501d_4bbb_e6ef_5f033d29cffe["react-slot"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> 45bdba50_501d_4bbb_e6ef_5f033d29cffe 6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4 79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81 f826d306_7d63_5ba3_6a53_387904d37a9f["label"] 7d8d565b_677a_b1ee_05eb_401ffef201c2 --> f826d306_7d63_5ba3_6a53_387904d37a9f style 7d8d565b_677a_b1ee_05eb_401ffef201c2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { Slot } from "@radix-ui/react-slot"
import {
Controller,
FormProvider,
useFormContext,
type ControllerProps,
type FieldPath,
type FieldValues,
} from "react-hook-form"
import { cn } from "@/lib/utils"
import { Label } from "@/registry/default/ui/label"
const Form = FormProvider
type FormFieldContextValue<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> = {
name: TName
}
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null)
const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
return (
<FormFieldContext.Provider value={{ name: props.name }}>
<Controller {...props} />
</FormFieldContext.Provider>
)
}
const useFormField = () => {
const fieldContext = React.useContext(FormFieldContext)
const itemContext = React.useContext(FormItemContext)
const { getFieldState, formState } = useFormContext()
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
if (!itemContext) {
throw new Error("useFormField should be used within <FormItem>")
}
const fieldState = getFieldState(fieldContext.name, formState)
const { id } = itemContext
return {
id,
// ... (119 more lines)
Domain
Subdomains
Dependencies
- label
- react
- react-hook-form
- react-label
- react-slot
- utils
Source
Frequently Asked Questions
What does form.tsx do?
form.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in form.tsx?
form.tsx defines 7 function(s): FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField.
What does form.tsx depend on?
form.tsx imports 6 module(s): label, react, react-hook-form, react-label, react-slot, utils.
Where is form.tsx in the architecture?
form.tsx is located at deprecated/www/registry/default/ui/form.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/default/ui).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free