@assistant-ui/react-hook-form 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +3 -37
- package/package.json +15 -5
- package/src/useAssistantForm.tsx +2 -2
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
@@ -1,39 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# `@assistant-ui/react-hook-form`
|
2
2
|
|
3
|
-
|
3
|
+
React Hook Form integration for `@assistant-ui/react`.
|
4
4
|
|
5
|
-
|
6
|
-
- [Website](https://assistant-ui.com/)
|
7
|
-
- [Demo](https://assistant-ui-rsc-example.vercel.app/)
|
8
|
-
|
9
|
-
## Documentation
|
10
|
-
|
11
|
-
- [Documentation](https://www.assistant-ui.com/docs/getting-started)
|
12
|
-
|
13
|
-
## Minimal Example with Vercel AI SDK
|
14
|
-
|
15
|
-
```sh
|
16
|
-
npx assistant-ui@latest add modal
|
17
|
-
```
|
18
|
-
|
19
|
-
```tsx
|
20
|
-
"use client";
|
21
|
-
|
22
|
-
import { useChat } from "@ai-sdk/react";
|
23
|
-
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
24
|
-
import { useVercelUseChatRuntime } from "@assistant-ui/react-ai-sdk";
|
25
|
-
import { AssistantModal } from "@/components/ui/assistant-ui/assistant-modal";
|
26
|
-
|
27
|
-
export default const MyApp = () => {
|
28
|
-
const chat = useChat({
|
29
|
-
api: "/api/chat" // your backend route
|
30
|
-
});
|
31
|
-
const runtime = useVercelUseChatRuntime(chat);
|
32
|
-
|
33
|
-
return (
|
34
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
35
|
-
<AssistantModal />
|
36
|
-
</AssistantRuntimeProvider>
|
37
|
-
);
|
38
|
-
}
|
39
|
-
```
|
5
|
+
Simply replace `useForm` with `useAssistantForm` to give the chatbot the ability to interact with your form.
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@assistant-ui/react-hook-form",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.3",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"peerDependencies": {
|
7
|
-
"@assistant-ui/react": "^0.1",
|
7
|
+
"@assistant-ui/react": "^0.1.3",
|
8
8
|
"react-hook-form": "^7.x.x",
|
9
9
|
"@types/react": "*",
|
10
10
|
"react": "^18"
|
@@ -18,13 +18,23 @@
|
|
18
18
|
"zod": "^3.23.8"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"
|
21
|
+
"tsup": "^8.1.0",
|
22
|
+
"@assistant-ui/react": "0.1.3",
|
22
23
|
"@assistant-ui/tsconfig": "0.0.0"
|
23
24
|
},
|
24
25
|
"publishConfig": {
|
25
|
-
"access": "public"
|
26
|
+
"access": "public",
|
27
|
+
"provenance": true
|
28
|
+
},
|
29
|
+
"homepage": "https://assistant-ui.com/",
|
30
|
+
"repository": {
|
31
|
+
"type": "git",
|
32
|
+
"url": "git+https://github.com/Yonom/assistant-ui.git"
|
33
|
+
},
|
34
|
+
"bugs": {
|
35
|
+
"url": "https://github.com/Yonom/assistant-ui/issues"
|
26
36
|
},
|
27
37
|
"scripts": {
|
28
|
-
"
|
38
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --sourcemap"
|
29
39
|
}
|
30
40
|
}
|
package/src/useAssistantForm.tsx
CHANGED
@@ -33,7 +33,7 @@ export const useAssistantForm = <
|
|
33
33
|
tools: {
|
34
34
|
set_form_field: {
|
35
35
|
...formTools.set_form_field,
|
36
|
-
execute: (args) => {
|
36
|
+
execute: async (args) => {
|
37
37
|
// biome-ignore lint/suspicious/noExplicitAny: TODO
|
38
38
|
form.setValue(args.name as any, args.value as any);
|
39
39
|
|
@@ -42,7 +42,7 @@ export const useAssistantForm = <
|
|
42
42
|
},
|
43
43
|
submit_form: {
|
44
44
|
...formTools.submit_form,
|
45
|
-
execute: () => {
|
45
|
+
execute: async () => {
|
46
46
|
const { _names, _fields } = form.control;
|
47
47
|
for (const name of _names.mount) {
|
48
48
|
const field = _fields[name];
|