"use client" import * as React from "react" import type { ComponentDocSpec } from "@/lib/design-system/component-doc-types" import { FieldLayoutsPreview, FormRhfPreview, RadioGroupChoiceCardPreview, RadioGroupDefaultPreview, } from "@/components/design-system/form-previews" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" function ex( section: Omit, children: React.ReactNode, description?: string, ) { return { ...section, description, children } } const fieldAnatomy: ComponentDocSpec["anatomy"] = [ { part: "Field", description: "Label + control + description — vertical or horizontal orientation." }, { part: "FieldSet / FieldLegend", description: "Grouped radios or checkboxes with shared legend." }, { part: "FieldDescription", description: "Help text below the control." }, ] const formGuidelines: ComponentDocSpec["guidelines"] = { do: [ "Prefer Field + native control for simple settings and hub filters.", "Use Form + FormField + react-hook-form for multi-field submit flows.", "Wire errors to FormMessage or Field invalid state — inline, not toast.", ], dont: [ "Do not use raw Label without Field in product forms.", "Do not skip visible labels on required fields.", ], } export const fieldComponentDoc: ComponentDocSpec = { slug: "field", summary: "Label + control + help text — top or left layout. Base building block for settings rows and hub filters.", sections: [ ex({ id: "layouts", title: "Top and left layouts" }, , "Toggle orientation; includes select, date, checkbox, and radio in context."), ], anatomy: fieldAnatomy, guidelines: formGuidelines, relatedSlugs: ["input", "select", "checkbox", "radio-group", "form"], } export const formComponentDoc: ComponentDocSpec = { slug: "form", summary: "react-hook-form shell — FormField, FormControl, FormMessage, and FormDescription.", sections: [ ex({ id: "rhf", title: "React Hook Form" }, , "Validation on blur; FormMessage for errors."), ], anatomy: [ { part: "Form", description: "Provider wrapper from react-hook-form." }, { part: "FormField", description: "Connects name to control + message." }, { part: "FormMessage", description: "Inline validation copy." }, ], guidelines: formGuidelines, relatedSlugs: ["field", "input"], } export const inputComponentDoc: ComponentDocSpec = { slug: "input", summary: "Text input, textarea, input group, label, and slider — one reference family.", sections: [ ex( { id: "text", title: "Input and textarea" },