{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "form", "type": "registry:ui", "title": "Form", "description": "Field wrapper: label, description and error message context.", "registryDependencies": [ "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/utils.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/text.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/theme.json" ], "files": [ { "path": "registry/shared/ui/form.tsx", "type": "registry:ui", "target": "components/ui/form.tsx", "content": "import { useContext, useId, type ReactNode } from 'react';\nimport { View, type ViewProps } from 'react-native';\nimport { Text, type TextProps } from '@/components/ui/text';\nimport { cn, FormFieldContext, useThemeColor } from '@/lib/utils';\n\nexport interface FormFieldProps extends ViewProps {\n error?: string;\n className?: string;\n children?: ReactNode;\n}\n\nexport function FormField({\n error,\n className,\n children,\n ...props\n}: FormFieldProps) {\n const id = useId();\n return (\n \n \n {children}\n \n \n );\n}\n\nexport function useFormField() {\n const ctx = useContext(FormFieldContext);\n if (!ctx) {\n throw new Error('useFormField must be used inside ');\n }\n return ctx;\n}\n\nexport function FormLabel({ className, ...props }: TextProps) {\n const { error } = useFormField();\n const theme = useThemeColor();\n return (\n \n );\n}\n\nexport function FormDescription({ className, ...props }: TextProps) {\n return (\n \n );\n}\n\nexport function FormMessage({ className, ...props }: TextProps) {\n const { error } = useFormField();\n if (!error) return null;\n return (\n \n {error}\n \n );\n}\n" } ] }