From 524aced04e8b9c2b9804d07bf518d7de85e2070e Mon Sep 17 00:00:00 2001 From: Bat-Zion Rotman Date: Mon, 25 Nov 2024 14:47:06 +0200 Subject: [PATCH] fix(orchestrator): pass also initial form data to custom decorator --- .../plugins/orchestrator-form-api/report.api.md | 2 +- .../plugins/orchestrator-form-api/src/api.ts | 1 + .../src/components/OrchestratorFormWrapper.tsx | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/workspaces/orchestrator/plugins/orchestrator-form-api/report.api.md b/workspaces/orchestrator/plugins/orchestrator-form-api/report.api.md index 398163223..6d3356726 100644 --- a/workspaces/orchestrator/plugins/orchestrator-form-api/report.api.md +++ b/workspaces/orchestrator/plugins/orchestrator-form-api/report.api.md @@ -20,7 +20,7 @@ export type FormDecoratorProps = Pick, 'formD // @public export interface OrchestratorFormApi { - getFormDecorator(schema: JSONSchema7, uiSchema: UiSchema): OrchestratorFormDecorator; + getFormDecorator(schema: JSONSchema7, uiSchema: UiSchema, initialFormData?: JsonObject): OrchestratorFormDecorator; } // @public diff --git a/workspaces/orchestrator/plugins/orchestrator-form-api/src/api.ts b/workspaces/orchestrator/plugins/orchestrator-form-api/src/api.ts index a50586220..10e557649 100644 --- a/workspaces/orchestrator/plugins/orchestrator-form-api/src/api.ts +++ b/workspaces/orchestrator/plugins/orchestrator-form-api/src/api.ts @@ -74,6 +74,7 @@ export interface OrchestratorFormApi { getFormDecorator( schema: JSONSchema7, uiSchema: UiSchema, + initialFormData?: JsonObject, ): OrchestratorFormDecorator; } diff --git a/workspaces/orchestrator/plugins/orchestrator-form-react/src/components/OrchestratorFormWrapper.tsx b/workspaces/orchestrator/plugins/orchestrator-form-react/src/components/OrchestratorFormWrapper.tsx index cf5cae954..cb23a5f5d 100644 --- a/workspaces/orchestrator/plugins/orchestrator-form-react/src/components/OrchestratorFormWrapper.tsx +++ b/workspaces/orchestrator/plugins/orchestrator-form-react/src/components/OrchestratorFormWrapper.tsx @@ -150,16 +150,19 @@ const FormComponent = (decoratorProps: FormDecoratorProps) => { const OrchestratorFormWrapper = ({ schema, uiSchema, + formData, ...props }: OrchestratorFormWrapperProps) => { const formApi = useApiHolder().get(orchestratorFormApiRef) || defaultFormExtensionsApi; const NewComponent = React.useMemo(() => { - const formDecorator = formApi.getFormDecorator(schema, uiSchema); + const formDecorator = formApi.getFormDecorator(schema, uiSchema, formData); return formDecorator(FormComponent); - }, [schema, formApi, uiSchema]); + }, [schema, formApi, uiSchema, formData]); return ( - + );