"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" import { InputGroup, InputGroupAddon, InputGroupText, InputGroupTextarea, } from "@/registry/new-york-v4/ui/input-group" const FormSchema = v.object({ title: v.pipe( v.string(), v.minLength(5, "Bug title must be at least 5 characters."), v.maxLength(32, "Bug title must be at most 32 characters.") ), description: v.pipe( v.string(), v.minLength(20, "Description must be at least 20 characters."), v.maxLength(100, "Description must be at most 100 characters.") ), }) export default function BugReportForm() { const form = useForm({ schema: FormSchema, initialInput: { title: "", description: "", }, }) 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 ( Bug Report Help us improve by reporting bugs you encounter.
{(field) => ( Bug Title {field.errors && ( ({ message }))} /> )} )} {(field) => ( Description {(field.input ?? "").length}/100 characters Include steps to reproduce, expected behavior, and what actually happened. {field.errors && ( ({ message }))} /> )} )}
) }