@openmrs/esm-form-engine-lib 2.1.0-pre.1476 → 2.1.0-pre.1478
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/package.json +1 -1
- package/src/components/processor-factory/form-processor-factory.component.tsx +1 -0
- package/src/components/renderer/form/form-renderer.component.tsx +10 -9
- package/src/form-engine.component.tsx +0 -1
- package/src/provider/form-factory-provider.tsx +5 -5
- package/75e0dfeda364f646/75e0dfeda364f646.gz +0 -0
- package/b211b244de3a9350/b211b244de3a9350.gz +0 -0
- package/cacdacff9a5c84a8/cacdacff9a5c84a8.gz +0 -0
- package/cbf7151ea0b21ed7/cbf7151ea0b21ed7.gz +0 -0
package/package.json
CHANGED
@@ -13,10 +13,16 @@ import { useFormStateHelpers } from '../../../hooks/useFormStateHelpers';
|
|
13
13
|
export type FormRendererProps = {
|
14
14
|
processorContext: FormProcessorContextProps;
|
15
15
|
initialValues: Record<string, any>;
|
16
|
+
isSubForm: boolean;
|
16
17
|
setIsLoadingFormDependencies: (isLoading: boolean) => void;
|
17
18
|
};
|
18
19
|
|
19
|
-
export const FormRenderer = ({
|
20
|
+
export const FormRenderer = ({
|
21
|
+
processorContext,
|
22
|
+
initialValues,
|
23
|
+
isSubForm,
|
24
|
+
setIsLoadingFormDependencies,
|
25
|
+
}: FormRendererProps) => {
|
20
26
|
const { evaluatedFields, evaluatedFormJson } = useEvaluateFormFieldExpressions(initialValues, processorContext);
|
21
27
|
const { registerForm, setIsFormDirty, workspaceLayout } = useFormFactory();
|
22
28
|
const methods = useForm({
|
@@ -64,8 +70,8 @@ export const FormRenderer = ({ processorContext, initialValues, setIsLoadingForm
|
|
64
70
|
}, [processorContext, workspaceLayout, methods, formFields, formJson, invalidFields]);
|
65
71
|
|
66
72
|
useEffect(() => {
|
67
|
-
registerForm(formJson.name, context);
|
68
|
-
}, [formJson.name, context]);
|
73
|
+
registerForm(formJson.name, isSubForm, context);
|
74
|
+
}, [formJson.name, isSubForm, context]);
|
69
75
|
|
70
76
|
useEffect(() => {
|
71
77
|
setIsFormDirty(isDirty);
|
@@ -91,12 +97,7 @@ export const FormRenderer = ({ processorContext, initialValues, setIsLoadingForm
|
|
91
97
|
/>
|
92
98
|
);
|
93
99
|
}
|
94
|
-
return
|
95
|
-
<PageRenderer
|
96
|
-
key={page.label}
|
97
|
-
page={page}
|
98
|
-
/>
|
99
|
-
);
|
100
|
+
return <PageRenderer key={page.label} page={page} />;
|
100
101
|
})}
|
101
102
|
</FormProvider>
|
102
103
|
);
|
@@ -26,7 +26,7 @@ interface FormFactoryProviderContextProps {
|
|
26
26
|
visit: OpenmrsResource;
|
27
27
|
location: OpenmrsResource;
|
28
28
|
provider: OpenmrsResource;
|
29
|
-
registerForm: (formId: string, context: FormContextProps) => void;
|
29
|
+
registerForm: (formId: string, isSubForm: boolean, context: FormContextProps) => void;
|
30
30
|
setCurrentPage: (page: string) => void;
|
31
31
|
handleConfirmQuestionDeletion?: (question: Readonly<FormField>) => Promise<void>;
|
32
32
|
setIsFormDirty: (isFormDirty: boolean) => void;
|
@@ -80,11 +80,11 @@ export const FormFactoryProvider: React.FC<FormFactoryProviderProps> = ({
|
|
80
80
|
|
81
81
|
const abortController = new AbortController();
|
82
82
|
|
83
|
-
const registerForm = useCallback((formId: string, context: FormContextProps) => {
|
84
|
-
if (
|
85
|
-
rootForm.current = context;
|
86
|
-
} else if (rootForm.current.formJson.name !== formId) {
|
83
|
+
const registerForm = useCallback((formId: string, isSubForm: boolean, context: FormContextProps) => {
|
84
|
+
if (isSubForm) {
|
87
85
|
subForms.current[formId] = context;
|
86
|
+
} else {
|
87
|
+
rootForm.current = context;
|
88
88
|
}
|
89
89
|
}, []);
|
90
90
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|