@assistant-ui/react-hook-form 0.11.11 → 0.12.0
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/dist/useAssistantForm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { tool,
|
|
2
|
+
import { tool, useAui, useAssistantToolUI, } from "@assistant-ui/react";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { useForm, } from "react-hook-form";
|
|
5
5
|
import { formTools } from "./formTools.js";
|
|
6
6
|
export const useAssistantForm = (props) => {
|
|
7
7
|
const form = useForm(props);
|
|
8
8
|
const { control, getValues, setValue, reset, formState: { isSubmitting }, } = form;
|
|
9
|
-
const
|
|
9
|
+
const aui = useAui();
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
const value = {
|
|
12
12
|
system: `Form State:\n${JSON.stringify(getValues())}`,
|
|
@@ -59,10 +59,10 @@ export const useAssistantForm = (props) => {
|
|
|
59
59
|
}),
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
|
-
return
|
|
62
|
+
return aui.modelContext().register({
|
|
63
63
|
getModelContext: () => value,
|
|
64
64
|
});
|
|
65
|
-
}, [control, setValue, getValues,
|
|
65
|
+
}, [control, setValue, getValues, aui, reset, isSubmitting]);
|
|
66
66
|
const renderFormFieldTool = props?.assistant?.tools?.set_form_field?.render;
|
|
67
67
|
useAssistantToolUI(renderFormFieldTool
|
|
68
68
|
? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantForm.js","sourceRoot":"","sources":["../src/useAssistantForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAEL,IAAI,EAEJ,
|
|
1
|
+
{"version":3,"file":"useAssistantForm.js","sourceRoot":"","sources":["../src/useAssistantForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAEL,IAAI,EAEJ,MAAM,EACN,kBAAkB,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AE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC;IAC5E,kBAAkB,CAChB,mBAAmB;QACjB,CAAC,CAAC;YACE,QAAQ,EAAE,gBAAgB;YAC1B,MAAM,EAAE,mBAAmB;SAC5B;QACH,CAAC,CAAC,IAAI,CACT,CAAC;IAEF,MAAM,oBAAoB,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC;IAC1E,kBAAkB,CAChB,oBAAoB;QAClB,CAAC,CAAC;YACE,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,oBAAoB;SAC7B;QACH,CAAC,CAAC,IAAI,CACT,CAAC;IAEF,MAAM,mBAAmB,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC;IACxE,kBAAkB,CAChB,mBAAmB;QACjB,CAAC,CAAC;YACE,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,mBAAmB;SAC5B;QACH,CAAC,CAAC,IAAI,CACT,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-hook-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "React Hook Form integration for assistant-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-hook-form",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
],
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"zod": "^4.
|
|
33
|
+
"zod": "^4.3.5"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@assistant-ui/react": "^0.
|
|
36
|
+
"@assistant-ui/react": "^0.12.0",
|
|
37
37
|
"@types/react": "*",
|
|
38
38
|
"react": "^18 || ^19",
|
|
39
39
|
"react-hook-form": "^7"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/react": "^19.2.
|
|
48
|
-
"react": "19.2.3",
|
|
49
|
-
"react-hook-form": "^7.
|
|
50
|
-
"@assistant-ui/react": "0.
|
|
47
|
+
"@types/react": "^19.2.9",
|
|
48
|
+
"react": "^19.2.3",
|
|
49
|
+
"react-hook-form": "^7.71.1",
|
|
50
|
+
"@assistant-ui/react": "0.12.0",
|
|
51
51
|
"@assistant-ui/x-buildutils": "0.0.1"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
package/src/useAssistantForm.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type ModelContext,
|
|
5
5
|
tool,
|
|
6
6
|
type ToolCallMessagePartComponent,
|
|
7
|
-
|
|
7
|
+
useAui,
|
|
8
8
|
useAssistantToolUI,
|
|
9
9
|
} from "@assistant-ui/react";
|
|
10
10
|
import { useEffect } from "react";
|
|
@@ -82,7 +82,7 @@ export const useAssistantForm = <
|
|
|
82
82
|
formState: { isSubmitting },
|
|
83
83
|
} = form;
|
|
84
84
|
|
|
85
|
-
const
|
|
85
|
+
const aui = useAui();
|
|
86
86
|
useEffect(() => {
|
|
87
87
|
const value: ModelContext = {
|
|
88
88
|
system: `Form State:\n${JSON.stringify(getValues())}`,
|
|
@@ -144,10 +144,10 @@ export const useAssistantForm = <
|
|
|
144
144
|
}),
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
|
-
return
|
|
147
|
+
return aui.modelContext().register({
|
|
148
148
|
getModelContext: () => value,
|
|
149
149
|
});
|
|
150
|
-
}, [control, setValue, getValues,
|
|
150
|
+
}, [control, setValue, getValues, aui, reset, isSubmitting]);
|
|
151
151
|
|
|
152
152
|
const renderFormFieldTool = props?.assistant?.tools?.set_form_field?.render;
|
|
153
153
|
useAssistantToolUI(
|