"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, } from "@/registry/new-york-v4/ui/field" import { Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue, } from "@/registry/new-york-v4/ui/select" const spokenLanguages = [ { label: "English", value: "en" }, { label: "Spanish", value: "es" }, { label: "French", value: "fr" }, { label: "German", value: "de" }, { label: "Italian", value: "it" }, { label: "Chinese", value: "zh" }, { label: "Japanese", value: "ja" }, ] as const const FormSchema = v.object({ language: v.pipe( v.string(), v.minLength(1, "Please select your spoken language."), v.check( (value) => value !== "auto", "Auto-detection is not allowed. Please select a specific language." ) ), }) export default function FormFormischSelect() { const form = useForm({ schema: FormSchema, initialInput: { language: "", }, }) 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 ( Language Preferences Select your preferred spoken language.
{(field) => ( Spoken Language For best results, select the language you speak. {field.errors && ( ({ message }))} /> )} )}
) }