"use client" /** * Form previews for Design System docs — shadcn Field + RadioGroup patterns. * @see https://ui.shadcn.com/docs/components/radio-group */ import * as React from "react" import { useForm } from "react-hook-form" import { SettingsFormRow } from "@/components/settings-form-row" import { Button } from "@/components/ui/button" import { Checkbox, CheckboxLabel } from "@/components/ui/checkbox" import { DatePickerField } from "@/components/ui/date-picker-field" import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, FieldTitle, } from "@/components/ui/field" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" import { ToggleSwitch } from "@/components/ui/toggle-switch" import { ViewSegmentedControl } from "@/components/ui/view-segmented-control" import { cn } from "@/lib/utils" const PLAN_OPTIONS = [ { value: "monthly", label: "Monthly ($9.99/month)", id: "plan-monthly" }, { value: "yearly", label: "Yearly ($99.99/year)", id: "plan-yearly" }, { value: "lifetime", label: "Lifetime ($299.99)", id: "plan-lifetime" }, ] as const const SPACING_OPTIONS = [ { value: "default", label: "Default", description: "Standard spacing for most use cases.", id: "spacing-default", }, { value: "comfortable", label: "Comfortable", description: "More space between elements.", id: "spacing-comfortable", }, { value: "compact", label: "Compact", description: "Minimal spacing for dense layouts.", id: "spacing-compact", }, ] as const const CHOICE_OPTIONS = [ { value: "plus", title: "Plus", description: "For individuals and small teams.", id: "plus-plan" }, { value: "pro", title: "Pro", description: "For growing businesses.", id: "pro-plan" }, { value: "enterprise", title: "Enterprise", description: "For large teams and enterprises.", id: "enterprise-plan", }, ] as const /** shadcn default — RadioGroup + Field horizontal rows. */ export function RadioGroupDefaultPreview() { return ( {SPACING_OPTIONS.map((opt) => ( {opt.label} ))} ) } /** shadcn fieldset — FieldSet + FieldLegend + RadioGroup + Field per option. */ export function RadioGroupFieldsetPreview() { const [value, setValue] = React.useState("monthly") return (
Subscription plan Yearly and lifetime plans offer significant savings. {PLAN_OPTIONS.map((opt) => ( {opt.label} ))}
) } /** shadcn description — FieldContent with label + description per option. */ export function RadioGroupDescriptionPreview() { return ( {SPACING_OPTIONS.map((opt) => ( {opt.label} {opt.description} ))} ) } /** shadcn choice card — FieldLabel wraps the whole Field row. */ export function RadioGroupChoiceCardPreview() { return ( {CHOICE_OPTIONS.map((opt) => ( {opt.title} {opt.description} ))} ) } /** shadcn invalid — aria-invalid on items + data-invalid on Field. */ export function RadioGroupInvalidPreview() { return (
Notification preferences Choose how you want to receive notifications. {( [ { value: "email", label: "Email only", id: "invalid-email" }, { value: "sms", label: "SMS only", id: "invalid-sms" }, { value: "both", label: "Both email & SMS", id: "invalid-both" }, ] as const ).map((opt) => ( {opt.label} ))}
) } type FieldLayout = "top" | "left" const LAYOUT_OPTIONS = [ { value: "top", label: "Top label", icon: "fa-light fa-arrow-down" }, { value: "left", label: "Left label", icon: "fa-light fa-arrow-right" }, ] as const export function FieldLayoutsPreview({ className }: { className?: string }) { const [layout, setLayout] = React.useState("top") const [questionType, setQuestionType] = React.useState("monthly") const [notifications, setNotifications] = React.useState(true) const [date, setDate] = React.useState(new Date()) return (
setLayout(v as FieldLayout)} aria-label="Field label layout" options={[...LAYOUT_OPTIONS]} /> {layout === "top" ? ( Question stem