From 736f8cefd1909fb75fc28016137f63cb029a106d Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Wed, 19 Jun 2024 09:29:09 -0700 Subject: [PATCH] docs: Add reference docs for react hook form (#242) --- apps/www/pages/reference/_meta.tsx | 7 ++++ .../pages/reference/integrations/_meta.tsx | 3 ++ .../integrations/react-hook-form.mdx | 37 +++++++++++++++++++ .../reference/primitives/composition.mdx | 2 - 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 apps/www/pages/reference/integrations/_meta.tsx create mode 100644 apps/www/pages/reference/integrations/react-hook-form.mdx diff --git a/apps/www/pages/reference/_meta.tsx b/apps/www/pages/reference/_meta.tsx index 5c2a8927c..7da66d702 100644 --- a/apps/www/pages/reference/_meta.tsx +++ b/apps/www/pages/reference/_meta.tsx @@ -1,4 +1,11 @@ export default { + "-- integrations": { + title: "Integrations", + type: "separator", + }, + integrations: { + display: "children", + }, "-- primitives": { title: "Primitives", type: "separator", diff --git a/apps/www/pages/reference/integrations/_meta.tsx b/apps/www/pages/reference/integrations/_meta.tsx new file mode 100644 index 000000000..21cd132f8 --- /dev/null +++ b/apps/www/pages/reference/integrations/_meta.tsx @@ -0,0 +1,3 @@ +export default { + "react-hook-form": "React Hook Form", +}; diff --git a/apps/www/pages/reference/integrations/react-hook-form.mdx b/apps/www/pages/reference/integrations/react-hook-form.mdx new file mode 100644 index 000000000..076593bdd --- /dev/null +++ b/apps/www/pages/reference/integrations/react-hook-form.mdx @@ -0,0 +1,37 @@ +--- +title: "@assistant-ui/react-hook-form" +description: A React Hook Form integration for @assistant-ui. +--- + +## API Reference + +### `useAssistantForm` + +Drop-in replacement hook for `useForm` that adds support for `@assistant-ui/react`. + +```diff +- import { useForm } from "react-hook-form"; ++ import { useAssistantForm } from "@assistant-ui/react-hook-form"; + +- useForm({ ++ useAssistantForm({ + ... + }); +``` + +{/** TODO document assistant.tools property */} + +### `formTools` + +The set of tools to use with `useAssistantForm`, useful for runtimes that do not support client-side tool definitions (i.e. Vercel AI SDK). + +```tsx {1, 5-7} +import { formTools } from "@assistant-ui/react-hook-form"; + +const result = await streamText({ + ... + tools: { + ...formTools, + } +}); +``` diff --git a/apps/www/pages/reference/primitives/composition.mdx b/apps/www/pages/reference/primitives/composition.mdx index 2cac5b4db..f3f0d185a 100644 --- a/apps/www/pages/reference/primitives/composition.mdx +++ b/apps/www/pages/reference/primitives/composition.mdx @@ -2,8 +2,6 @@ title: Composition --- -{/** https://github.com/liveblocks/liveblocks/blob/main/LICENSE */} - import { Code } from "@radix-ui/themes"; `assistant-ui` primitives are composable. This means that all props are forwarded, classes are merged, and event handlers are chained.