From b7d17383bf3c734c9100eb44b2a42a5bf61c8a7e Mon Sep 17 00:00:00 2001 From: kurihada Date: Thu, 19 Mar 2026 17:50:34 +0800 Subject: [PATCH] feat: add form primitives and rhf integration --- apps/docs/package.json | 3 +- apps/docs/src/components/form.stories.tsx | 187 +++++++++++++++++++ packages/ui/package.json | 1 + packages/ui/src/components/form.test.tsx | 196 ++++++++++++++++++++ packages/ui/src/components/form.tsx | 210 ++++++++++++++++++++++ packages/ui/src/index.ts | 16 +- pnpm-lock.yaml | 16 ++ 7 files changed, 627 insertions(+), 2 deletions(-) create mode 100644 apps/docs/src/components/form.stories.tsx create mode 100644 packages/ui/src/components/form.test.tsx create mode 100644 packages/ui/src/components/form.tsx diff --git a/apps/docs/package.json b/apps/docs/package.json index 310b5d0..fbf0d5f 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -12,6 +12,7 @@ "@ai-ui/tokens": "workspace:*", "@ai-ui/ui": "workspace:*", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "react-hook-form": "^7.71.2" } } diff --git a/apps/docs/src/components/form.stories.tsx b/apps/docs/src/components/form.stories.tsx new file mode 100644 index 0000000..21272da --- /dev/null +++ b/apps/docs/src/components/form.stories.tsx @@ -0,0 +1,187 @@ +import { + Button, + Form, + FormControl, + FormDescription, + FormItem, + FormLabel, + FormMessage, + Input, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, + Switch, + Textarea +} from "@ai-ui/ui"; +import type { Meta, StoryObj } from "@storybook/react"; +import { Controller, useForm } from "react-hook-form"; +import { useState } from "react"; + +type LaunchFormValues = { + email: string; + notifications: boolean; + role: string; + summary: string; +}; + +function LaunchSettingsForm() { + const [submitted, setSubmitted] = useState(null); + const form = useForm({ + defaultValues: { + email: "", + notifications: true, + role: "design", + summary: "" + } + }); + + return ( +
+ { + setSubmitted(values); + })} + > +
+

+ Launch settings +

+

+ This story uses react-hook-form with the new form primitives. +

+
+ + + Email address + + + + Release notes and alerts will be sent here. + + + + ( + + Review lane + + + + + The selected team becomes the primary reviewer for this launch. + + + + )} + /> + + + Launch summary + +