"use client" import * as React from "react" import { Form, Field as FormischField, reset, useForm } from "@formisch/react" import type { SubmitHandler } from "@formisch/react" import { toast } from "sonner" import * as v from "valibot" import { Button } from "@/registry/new-york-v4/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york-v4/ui/card" import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, FieldTitle, } from "@/registry/new-york-v4/ui/field" import { RadioGroup, RadioGroupItem, } from "@/registry/new-york-v4/ui/radio-group" const plans = [ { id: "starter", title: "Starter (100K tokens/month)", description: "For everyday use with basic features.", }, { id: "pro", title: "Pro (1M tokens/month)", description: "For advanced AI usage with more features.", }, { id: "enterprise", title: "Enterprise (Unlimited tokens)", description: "For large teams and heavy usage.", }, ] as const const FormSchema = v.object({ plan: v.pipe( v.string(), v.minLength(1, "You must select a subscription plan to continue.") ), }) export default function FormFormischRadioGroup() { const form = useForm({ schema: FormSchema, initialInput: { plan: "", }, }) const handleSubmit: SubmitHandler = (output) => { toast("You submitted the following values:", { description: (
          {JSON.stringify(output, null, 2)}
        
), position: "bottom-right", classNames: { content: "flex flex-col gap-2", }, style: { "--border-radius": "calc(var(--radius) + 4px)", } as React.CSSProperties, }) } return ( Subscription Plan See pricing and features for each plan.
{(field) => (
Plan You can upgrade or downgrade your plan at any time. field.onChange(value)} aria-invalid={field.errors !== null} > {plans.map((plan) => ( {plan.title} {plan.description} ))} {field.errors && ( ({ message }))} /> )}
)}
) }