@openmrs/esm-form-engine-lib 2.1.0-pre.1393 → 2.1.0-pre.1401
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/8f75299d4c303e6e/8f75299d4c303e6e.gz +0 -0
- package/98a5f82581f0d1ed/98a5f82581f0d1ed.gz +0 -0
- package/afdf83d2ad7bbe00/afdf83d2ad7bbe00.gz +0 -0
- package/ca0db33c95d8679b/ca0db33c95d8679b.gz +0 -0
- package/package.json +1 -1
- package/src/components/group/obs-group.component.tsx +1 -1
- package/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +7 -5
- package/src/components/renderer/field/form-field-renderer.component.tsx +6 -4
- package/src/components/renderer/section/section-renderer.component.tsx +5 -1
- package/src/components/repeat/repeat.component.tsx +1 -1
- package/src/hooks/useFormStateHelpers.ts +1 -1
Binary file
|
Binary file
|
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -16,7 +16,7 @@ export const ObsGroup: React.FC<FormFieldInputProps> = ({ field }) => {
|
|
16
16
|
return (
|
17
17
|
<div className={classNames(styles.flexColumn)} key={keyId}>
|
18
18
|
<div className={styles.groupContainer}>
|
19
|
-
<FormFieldRenderer
|
19
|
+
<FormFieldRenderer fieldId={child.id} valueAdapter={formFieldAdapters[child.type]} />
|
20
20
|
</div>
|
21
21
|
</div>
|
22
22
|
);
|
@@ -23,12 +23,14 @@ const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
|
|
23
23
|
};
|
24
24
|
|
25
25
|
return (
|
26
|
-
|
27
|
-
<div
|
28
|
-
|
29
|
-
<
|
26
|
+
!field.isHidden && (
|
27
|
+
<div>
|
28
|
+
<div className={styles.label}>{t(field.label)}</div>
|
29
|
+
<div className={styles.workspaceButton}>
|
30
|
+
<Button onClick={handleLaunchWorkspace}>{field.questionOptions?.buttonLabel ?? t('launchWorkspace')}</Button>
|
31
|
+
</div>
|
30
32
|
</div>
|
31
|
-
|
33
|
+
)
|
32
34
|
);
|
33
35
|
};
|
34
36
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
2
2
|
import {
|
3
3
|
type FormField,
|
4
4
|
type RenderType,
|
@@ -24,14 +24,14 @@ import { getFieldControlWithFallback } from '../../../utils/form-helper';
|
|
24
24
|
import { handleFieldLogic } from './fieldLogic';
|
25
25
|
|
26
26
|
export interface FormFieldRendererProps {
|
27
|
-
|
27
|
+
fieldId: string;
|
28
28
|
valueAdapter: FormFieldValueAdapter;
|
29
29
|
repeatOptions?: {
|
30
30
|
targetRendering: RenderType;
|
31
31
|
};
|
32
32
|
}
|
33
33
|
|
34
|
-
export const FormFieldRenderer = ({
|
34
|
+
export const FormFieldRenderer = ({ fieldId, valueAdapter, repeatOptions }: FormFieldRendererProps) => {
|
35
35
|
const [inputComponentWrapper, setInputComponentWrapper] = useState<{
|
36
36
|
value: React.ComponentType<FormFieldInputProps>;
|
37
37
|
}>(null);
|
@@ -50,9 +50,11 @@ export const FormFieldRenderer = ({ field, valueAdapter, repeatOptions }: FormFi
|
|
50
50
|
removeInvalidField,
|
51
51
|
} = context;
|
52
52
|
|
53
|
-
const fieldValue = useWatch({ control, name:
|
53
|
+
const fieldValue = useWatch({ control, name: fieldId, exact: true });
|
54
54
|
const noop = () => {};
|
55
55
|
|
56
|
+
const field = useMemo(() => formFields.find((field) => field.id === fieldId), [fieldId, formFields]);
|
57
|
+
|
56
58
|
useEffect(() => {
|
57
59
|
if (hasRendering(field, 'repeating') && repeatOptions?.targetRendering) {
|
58
60
|
getRegisteredControl(repeatOptions.targetRendering).then((component) => {
|
@@ -12,7 +12,11 @@ export const SectionRenderer = ({ section }: { section: FormSection }) => {
|
|
12
12
|
{section.questions.map((question) =>
|
13
13
|
formFieldAdapters[question.type] ? (
|
14
14
|
<div key={`${sectionId}-${question.id}`} className={styles.sectionBody}>
|
15
|
-
<FormFieldRenderer
|
15
|
+
<FormFieldRenderer
|
16
|
+
key={question.id}
|
17
|
+
fieldId={question.id}
|
18
|
+
valueAdapter={formFieldAdapters[question.type]}
|
19
|
+
/>
|
16
20
|
</div>
|
17
21
|
) : null,
|
18
22
|
)}
|
@@ -129,7 +129,7 @@ const Repeat: React.FC<FormFieldInputProps> = ({ field }) => {
|
|
129
129
|
return rows.map((field, index) => {
|
130
130
|
const component = (
|
131
131
|
<FormFieldRenderer
|
132
|
-
|
132
|
+
fieldId={field.id}
|
133
133
|
valueAdapter={formFieldAdapters[field.type]}
|
134
134
|
repeatOptions={{ targetRendering: getQuestionWithSupportedRendering(field).questionOptions.rendering }}
|
135
135
|
/>
|
@@ -7,7 +7,7 @@ export function useFormStateHelpers(dispatch: Dispatch<Action>, formFields: Form
|
|
7
7
|
dispatch({ type: 'ADD_FORM_FIELD', value: field });
|
8
8
|
}, []);
|
9
9
|
const updateFormField = useCallback((field: FormField) => {
|
10
|
-
dispatch({ type: 'UPDATE_FORM_FIELD', value: field });
|
10
|
+
dispatch({ type: 'UPDATE_FORM_FIELD', value: structuredClone(field) });
|
11
11
|
}, []);
|
12
12
|
|
13
13
|
const getFormField = useCallback(
|