{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "form-tanstack-select",
  "dependencies": [
    "@tanstack/react-form",
    "zod"
  ],
  "registryDependencies": [
    "https://taki-ui.com/r/field.json",
    "https://taki-ui.com/r/select.json",
    "https://taki-ui.com/r/button.json",
    "https://taki-ui.com/r/card.json"
  ],
  "files": [
    {
      "path": "registry/new-york/examples/form-tanstack-select.tsx",
      "content": "/* eslint-disable react/no-children-prop */\n\"use client\"\n\nimport { useForm } from \"@tanstack/react-form\"\nimport { toast } from \"sonner\"\nimport * as z from \"zod\"\n\nimport { Button } from \"@/registry/new-york/ui/button\"\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n  CardTitle,\n} from \"@/registry/new-york/ui/card\"\nimport {\n  Field,\n  FieldContent,\n  FieldDescription,\n  FieldError,\n  FieldGroup,\n  FieldLabel,\n} from \"@/registry/new-york/ui/field\"\nimport { Select, SelectItem } from \"@/registry/new-york/ui/select\"\nimport { Separator } from \"@/registry/new-york/ui/separator\"\n\nconst spokenLanguages = [\n  { label: \"English\", value: \"en\" },\n  { label: \"Spanish\", value: \"es\" },\n  { label: \"French\", value: \"fr\" },\n  { label: \"German\", value: \"de\" },\n  { label: \"Italian\", value: \"it\" },\n  { label: \"Chinese\", value: \"zh\" },\n  { label: \"Japanese\", value: \"ja\" },\n] as const\n\nconst formSchema = z.object({\n  language: z\n    .string()\n    .min(1, \"Please select your spoken language.\")\n    .refine((val) => val !== \"auto\", {\n      message:\n        \"Auto-detection is not allowed. Please select a specific language.\",\n    }),\n})\n\nexport default function FormTanstackSelect() {\n  const form = useForm({\n    defaultValues: {\n      language: \"\",\n    },\n    validators: {\n      onSubmit: formSchema,\n    },\n    onSubmit: async ({ value }) => {\n      toast(\"You submitted the following values:\", {\n        description: (\n          <pre className=\"bg-code text-code-foreground mt-2 w-[320px] overflow-x-auto rounded-md p-4\">\n            <code>{JSON.stringify(value, null, 2)}</code>\n          </pre>\n        ),\n        position: \"bottom-right\",\n        classNames: {\n          content: \"flex flex-col gap-2\",\n        },\n        style: {\n          \"--border-radius\": \"calc(var(--radius)  + 4px)\",\n        } as React.CSSProperties,\n      })\n    },\n  })\n\n  return (\n    <Card className=\"w-full sm:max-w-lg\">\n      <CardHeader>\n        <CardTitle>Language Preferences</CardTitle>\n        <CardDescription>\n          Select your preferred spoken language.\n        </CardDescription>\n      </CardHeader>\n      <CardContent>\n        <form\n          id=\"form-tanstack-select\"\n          onSubmit={(e) => {\n            e.preventDefault()\n            form.handleSubmit()\n          }}\n        >\n          <FieldGroup>\n            <form.Field\n              name=\"language\"\n              children={(field) => {\n                const isInvalid =\n                  field.state.meta.isTouched && !field.state.meta.isValid\n                return (\n                  <Field orientation=\"responsive\" data-invalid={isInvalid}>\n                    <FieldContent>\n                      <FieldLabel htmlFor=\"form-tanstack-select-language\">\n                        Spoken Language\n                      </FieldLabel>\n                      <FieldDescription>\n                        For best results, select the language you speak.\n                      </FieldDescription>\n                      {isInvalid && (\n                        <FieldError errors={field.state.meta.errors} />\n                      )}\n                    </FieldContent>\n                    <Select\n                      name={field.name}\n                      selectedKey={field.state.value}\n                      onSelectionChange={(key) =>\n                        field.handleChange(key as string)\n                      }\n                      className=\"min-w-[120px]\"\n                    >\n                      <SelectItem id=\"auto\">Auto</SelectItem>\n                      <Separator />\n                      {spokenLanguages.map((language) => (\n                        <SelectItem key={language.value} id={language.value}>\n                          {language.label}\n                        </SelectItem>\n                      ))}\n                    </Select>\n                  </Field>\n                )\n              }}\n            />\n          </FieldGroup>\n        </form>\n      </CardContent>\n      <CardFooter>\n        <Field orientation=\"horizontal\">\n          <Button type=\"button\" variant=\"outline\" onClick={() => form.reset()}>\n            Reset\n          </Button>\n          <Button type=\"submit\" form=\"form-tanstack-select\">\n            Save\n          </Button>\n        </Field>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}