From 86d4f7f70d40e67f57fa1574164cfd5660ac27d5 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Thu, 20 Jun 2024 11:51:10 -0700 Subject: [PATCH] feat: add UseAssistantFormProps type (#261) --- .changeset/ten-brooms-rhyme.md | 5 ++ apps/www/components/docs/ParametersTable.tsx | 59 +++++++++++-------- .../integrations/react-hook-form.mdx | 1 + packages/react-hook-form/src/index.ts | 5 +- .../react-hook-form/src/useAssistantForm.tsx | 2 +- 5 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 .changeset/ten-brooms-rhyme.md diff --git a/.changeset/ten-brooms-rhyme.md b/.changeset/ten-brooms-rhyme.md new file mode 100644 index 000000000..f1f3d6f5d --- /dev/null +++ b/.changeset/ten-brooms-rhyme.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react-hook-form": patch +--- + +feat: add UseAssistantFormProps type diff --git a/apps/www/components/docs/ParametersTable.tsx b/apps/www/components/docs/ParametersTable.tsx index 24240c92e..ff3080657 100644 --- a/apps/www/components/docs/ParametersTable.tsx +++ b/apps/www/components/docs/ParametersTable.tsx @@ -5,10 +5,7 @@ type ParameterDef = { type: string; description: string; required?: boolean; - children?: Array<{ - type: string; - parameters: Array; - }>; + children?: Array; }; type ParameterProps = { @@ -35,36 +32,52 @@ const Parameter: FC = ({ parameter, isLast }) => {

{parameter.description}

{parameter.children?.map((property) => ( -
- {!!property.type && ( -

- {property.type} -

- )} - -
+ ))} ); }; +const ParametersList = ({ + parameters, +}: { parameters: Array }) => { + return parameters.map((parameter, idx) => ( + + )); +}; +const ParametersBox: FC = ({ type, parameters }) => { + return ( +
+ {!!type && ( +

+ {type} +

+ )} + +
+ ); +}; + type ParametersTableProps = { + type?: string; parameters: Array; }; -export const ParametersTable: FC = ({ parameters }) => { +export const ParametersTable: FC = ({ + type, + parameters, +}) => { return (
- {parameters.map((parameter, idx) => ( - - ))} + {type ? ( + + ) : ( + + )}
); }; diff --git a/apps/www/pages/reference/integrations/react-hook-form.mdx b/apps/www/pages/reference/integrations/react-hook-form.mdx index d7188ccbc..4e5ca3504 100644 --- a/apps/www/pages/reference/integrations/react-hook-form.mdx +++ b/apps/www/pages/reference/integrations/react-hook-form.mdx @@ -24,6 +24,7 @@ Drop-in replacement hook for `useForm` that adds support for `@assistant-ui/reac #### Properties = UseFormProps & {