"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, FieldDescription, FieldError, FieldGroup, FieldLabel, } from "@/registry/new-york-v4/ui/field" import { Input } from "@/registry/new-york-v4/ui/input" const FormSchema = v.object({ username: v.pipe( v.string(), v.minLength(3, "Username must be at least 3 characters."), v.maxLength(10, "Username must be at most 10 characters."), v.regex( /^[a-zA-Z0-9_]+$/, "Username can only contain letters, numbers, and underscores." ) ), }) export default function FormFormischInput() { const form = useForm({ schema: FormSchema, initialInput: { username: "", }, }) 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 ( Profile Settings Update your profile information below.
{(field) => ( Username This is your public display name. Must be between 3 and 10 characters. Must only contain letters, numbers, and underscores. {field.errors && ( ({ message }))} /> )} )}
) }