@openmrs/esm-form-engine-lib 2.1.0-pre.1362
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/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +58 -0
- package/.husky/pre-commit +6 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +4 -0
- package/LICENSE.txt +401 -0
- package/README.md +136 -0
- package/__mocks__/concepts.mock.json +140 -0
- package/__mocks__/forms/afe-forms/component_art.json +38 -0
- package/__mocks__/forms/afe-forms/component_preclinic-review.json +38 -0
- package/__mocks__/forms/afe-forms/demo_hts-form.json +62 -0
- package/__mocks__/forms/afe-forms/form-component.json +38 -0
- package/__mocks__/forms/afe-forms/mini-form.json +31 -0
- package/__mocks__/forms/afe-forms/nested-form1.json +38 -0
- package/__mocks__/forms/afe-forms/nested-form2.json +38 -0
- package/__mocks__/forms/afe-forms/test-orders.json +72 -0
- package/__mocks__/forms/afe-forms/test-schema-transformer-form.json +88 -0
- package/__mocks__/forms/rfe-forms/age-validation-form.json +58 -0
- package/__mocks__/forms/rfe-forms/bmi-test-form.json +69 -0
- package/__mocks__/forms/rfe-forms/bsa-test-form.json +69 -0
- package/__mocks__/forms/rfe-forms/component_art.json +1705 -0
- package/__mocks__/forms/rfe-forms/component_preclinic-review.json +480 -0
- package/__mocks__/forms/rfe-forms/conditional-answered-form.json +97 -0
- package/__mocks__/forms/rfe-forms/conditional-required-form.json +281 -0
- package/__mocks__/forms/rfe-forms/demo_hts-form.json +346 -0
- package/__mocks__/forms/rfe-forms/edd-test-form.json +88 -0
- package/__mocks__/forms/rfe-forms/external_data_source_form.json +43 -0
- package/__mocks__/forms/rfe-forms/filter-answer-options-test-form.json +87 -0
- package/__mocks__/forms/rfe-forms/form-component.json +43 -0
- package/__mocks__/forms/rfe-forms/forms-loader.test.schema.ts +209 -0
- package/__mocks__/forms/rfe-forms/historical-expressions-form.json +170 -0
- package/__mocks__/forms/rfe-forms/labour_and_delivery_test_form.json +374 -0
- package/__mocks__/forms/rfe-forms/mini-form.json +29 -0
- package/__mocks__/forms/rfe-forms/mockHistoricalvisitsEncounter.json +89 -0
- package/__mocks__/forms/rfe-forms/months-on-art-form.json +90 -0
- package/__mocks__/forms/rfe-forms/multi-select-form.json +86 -0
- package/__mocks__/forms/rfe-forms/nested-form1.json +43 -0
- package/__mocks__/forms/rfe-forms/nested-form2.json +43 -0
- package/__mocks__/forms/rfe-forms/next-visit-test-form.json +78 -0
- package/__mocks__/forms/rfe-forms/obs-group-test_form.json +137 -0
- package/__mocks__/forms/rfe-forms/obs-list-data.ts +37 -0
- package/__mocks__/forms/rfe-forms/post-submission-test-form.json +116 -0
- package/__mocks__/forms/rfe-forms/reference-by-mapping-form.json +54 -0
- package/__mocks__/forms/rfe-forms/required-form.json +50 -0
- package/__mocks__/forms/rfe-forms/sample_fields.json +36 -0
- package/__mocks__/forms/rfe-forms/test-enrolment-form.json +241 -0
- package/__mocks__/forms/rfe-forms/treatment-end-date-test-form.json +121 -0
- package/__mocks__/forms/rfe-forms/viral-load-status-form.json +75 -0
- package/__mocks__/forms/rfe-forms/zscore-bmi-for-age-form.json +79 -0
- package/__mocks__/forms/rfe-forms/zscore-height-for-age-form.json +79 -0
- package/__mocks__/forms/rfe-forms/zscore-weight-height-form.json +77 -0
- package/__mocks__/packages/hiv/forms/hts_poc/1.0.json +8 -0
- package/__mocks__/packages/hiv/forms/hts_poc/1.1.json +91 -0
- package/__mocks__/packages/test-forms-registry.ts +12 -0
- package/__mocks__/patient.mock.ts +173 -0
- package/__mocks__/react-i18next.js +49 -0
- package/__mocks__/react-markdown.tsx +5 -0
- package/__mocks__/session.mock.ts +117 -0
- package/__mocks__/single-spa-react.js +11 -0
- package/__mocks__/use-initial-values/encounter.mock.json +963 -0
- package/__mocks__/use-initial-values/patient.mock.json +73 -0
- package/__mocks__/visit.mock.ts +19 -0
- package/dist/openmrs-esm-form-engine-lib.js +1 -0
- package/jest.config.js +30 -0
- package/package.json +104 -0
- package/prettier.config.js +8 -0
- package/readme/form-engine.jpeg +0 -0
- package/src/adapters/control-adapter.ts +29 -0
- package/src/adapters/encounter-datetime-adapter.ts +38 -0
- package/src/adapters/encounter-location-adapter.ts +39 -0
- package/src/adapters/encounter-provider-adapter.ts +48 -0
- package/src/adapters/encounter-role-adapter.ts +54 -0
- package/src/adapters/inline-date-adapter.ts +58 -0
- package/src/adapters/obs-adapter.ts +280 -0
- package/src/adapters/obs-comment-adapter.ts +60 -0
- package/src/adapters/orders-adapter.ts +75 -0
- package/src/adapters/patient-identifier-adapter.ts +40 -0
- package/src/adapters/program-state-adapter.ts +52 -0
- package/src/api/index.ts +178 -0
- package/src/components/error/error-modal.component.tsx +37 -0
- package/src/components/error/error.scss +4 -0
- package/src/components/extension/extension-parcel.component.tsx +32 -0
- package/src/components/field-label/field-label.component.tsx +32 -0
- package/src/components/field-label/field-label.scss +11 -0
- package/src/components/group/obs-group.component.tsx +29 -0
- package/src/components/group/obs-group.scss +12 -0
- package/src/components/inputs/content-switcher/content-switcher.component.tsx +71 -0
- package/src/components/inputs/content-switcher/content-switcher.scss +55 -0
- package/src/components/inputs/date/date.component.tsx +149 -0
- package/src/components/inputs/date/date.scss +36 -0
- package/src/components/inputs/file/camera/camera.component.tsx +34 -0
- package/src/components/inputs/file/camera/camera.scss +3 -0
- package/src/components/inputs/file/file.component.tsx +159 -0
- package/src/components/inputs/file/file.scss +101 -0
- package/src/components/inputs/fixed-value/fixed-value.component.tsx +19 -0
- package/src/components/inputs/markdown/markdown-wrapper.component.tsx +14 -0
- package/src/components/inputs/markdown/markdown.component.tsx +8 -0
- package/src/components/inputs/multi-select/multi-select.component.tsx +151 -0
- package/src/components/inputs/multi-select/multi-select.scss +25 -0
- package/src/components/inputs/multi-select/multi-select.test.tsx +90 -0
- package/src/components/inputs/number/number.component.tsx +69 -0
- package/src/components/inputs/number/number.scss +15 -0
- package/src/components/inputs/radio/radio.component.tsx +79 -0
- package/src/components/inputs/radio/radio.scss +36 -0
- package/src/components/inputs/select/dropdown.component.tsx +73 -0
- package/src/components/inputs/select/dropdown.scss +11 -0
- package/src/components/inputs/select/dropdown.test.tsx +120 -0
- package/src/components/inputs/text/text.component.tsx +65 -0
- package/src/components/inputs/text/text.scss +15 -0
- package/src/components/inputs/text/text.test.tsx +104 -0
- package/src/components/inputs/text-area/text-area.component.tsx +63 -0
- package/src/components/inputs/text-area/text-area.scss +11 -0
- package/src/components/inputs/toggle/toggle.component.tsx +66 -0
- package/src/components/inputs/toggle/toggle.scss +12 -0
- package/src/components/inputs/tooltip/tooltip.component.tsx +23 -0
- package/src/components/inputs/tooltip/tooltip.scss +8 -0
- package/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +187 -0
- package/src/components/inputs/ui-select-extended/ui-select-extended.scss +15 -0
- package/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +211 -0
- package/src/components/inputs/unspecified/unspecified.component.tsx +74 -0
- package/src/components/inputs/unspecified/unspecified.scss +7 -0
- package/src/components/inputs/unspecified/unspecified.test.tsx +95 -0
- package/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +35 -0
- package/src/components/inputs/workspace-launcher/workspace-launcher.scss +15 -0
- package/src/components/label/label.component.tsx +20 -0
- package/src/components/label/label.scss +11 -0
- package/src/components/loaders/loader.component.tsx +16 -0
- package/src/components/loaders/loader.scss +20 -0
- package/src/components/patient-banner/patient-banner.component.tsx +20 -0
- package/src/components/patient-banner/patient-banner.scss +12 -0
- package/src/components/previous-value-review/previous-value-review.component.tsx +49 -0
- package/src/components/previous-value-review/previous-value-review.scss +36 -0
- package/src/components/processor-factory/form-processor-factory.component.tsx +127 -0
- package/src/components/renderer/custom-hooks-renderer.component.tsx +30 -0
- package/src/components/renderer/field/fieldLogic.ts +214 -0
- package/src/components/renderer/field/form-field-renderer.component.tsx +281 -0
- package/src/components/renderer/field/form-field-renderer.scss +5 -0
- package/src/components/renderer/form/form-renderer.component.tsx +89 -0
- package/src/components/renderer/form/state.ts +54 -0
- package/src/components/renderer/page/page.renderer.component.tsx +50 -0
- package/src/components/renderer/page/page.renderer.scss +36 -0
- package/src/components/renderer/section/section-renderer.component.tsx +21 -0
- package/src/components/renderer/section/section-renderer.scss +19 -0
- package/src/components/repeat/helpers.test.ts +29 -0
- package/src/components/repeat/helpers.ts +68 -0
- package/src/components/repeat/repeat-controls.component.tsx +38 -0
- package/src/components/repeat/repeat-controls.scss +7 -0
- package/src/components/repeat/repeat.component.tsx +201 -0
- package/src/components/repeat/repeat.scss +30 -0
- package/src/components/repeat/repeat.test.ts +29 -0
- package/src/components/sidebar/sidebar.component.tsx +134 -0
- package/src/components/sidebar/sidebar.scss +121 -0
- package/src/components/value/value.component.tsx +27 -0
- package/src/components/value/value.scss +17 -0
- package/src/components/value/view/field-value-view.component.tsx +33 -0
- package/src/components/value/view/field-value-view.scss +31 -0
- package/src/constants.ts +12 -0
- package/src/datasources/concept-data-source.ts +42 -0
- package/src/datasources/data-source.ts +23 -0
- package/src/datasources/encounter-role-datasource.ts +15 -0
- package/src/datasources/historical-data-source.ts +11 -0
- package/src/datasources/location-data-source.ts +27 -0
- package/src/datasources/provider-datasource.ts +15 -0
- package/src/datasources/select-concept-answers-datasource.ts +15 -0
- package/src/declarations.d.ts +4 -0
- package/src/external-function-context.tsx +8 -0
- package/src/form-context.tsx +42 -0
- package/src/form-engine.component.tsx +178 -0
- package/src/form-engine.scss +140 -0
- package/src/form-engine.test.tsx +817 -0
- package/src/globals.ts +1 -0
- package/src/hooks/useClobData.tsx +21 -0
- package/src/hooks/useConcepts.tsx +55 -0
- package/src/hooks/useDatasourceDependentValue.ts +16 -0
- package/src/hooks/useEncounter.tsx +32 -0
- package/src/hooks/useEncounterRole.tsx +15 -0
- package/src/hooks/useEvaluateFormFieldExpressions.ts +138 -0
- package/src/hooks/useFieldValidationResults.ts +18 -0
- package/src/hooks/useFormCollapse.tsx +36 -0
- package/src/hooks/useFormFieldValidators.ts +22 -0
- package/src/hooks/useFormFieldValueAdapters.ts +24 -0
- package/src/hooks/useFormFields.ts +37 -0
- package/src/hooks/useFormFieldsMeta.ts +48 -0
- package/src/hooks/useFormJson.test.tsx +173 -0
- package/src/hooks/useFormJson.tsx +237 -0
- package/src/hooks/useFormStateHelpers.ts +50 -0
- package/src/hooks/useFormsConfig.tsx +27 -0
- package/src/hooks/useInitialValues.ts +38 -0
- package/src/hooks/usePatientData.tsx +32 -0
- package/src/hooks/usePatientPrograms.ts +32 -0
- package/src/hooks/usePostSubmissionActions.test.tsx +42 -0
- package/src/hooks/usePostSubmissionActions.ts +31 -0
- package/src/hooks/useProcessorDependencies.ts +30 -0
- package/src/hooks/useRestMaxResultsCount.ts +5 -0
- package/src/hooks/useSystemSetting.ts +36 -0
- package/src/hooks/useWorkspaceLayout.ts +29 -0
- package/src/index.ts +12 -0
- package/src/lifecycle.ts +33 -0
- package/src/post-submission-actions/program-enrollment-action.ts +138 -0
- package/src/processors/encounter/encounter-form-processor.ts +337 -0
- package/src/processors/encounter/encounter-processor-helper.ts +320 -0
- package/src/processors/form-processor.ts +41 -0
- package/src/provider/form-factory-helper.ts +100 -0
- package/src/provider/form-factory-provider.tsx +169 -0
- package/src/provider/form-provider.tsx +37 -0
- package/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts +9 -0
- package/src/registry/inbuilt-components/control-templates.ts +57 -0
- package/src/registry/inbuilt-components/inbuiltControls.ts +99 -0
- package/src/registry/inbuilt-components/inbuiltDataSources.ts +41 -0
- package/src/registry/inbuilt-components/inbuiltFieldValueAdapters.ts +64 -0
- package/src/registry/inbuilt-components/inbuiltTransformers.ts +10 -0
- package/src/registry/inbuilt-components/inbuiltValidators.ts +33 -0
- package/src/registry/inbuilt-components/template-component-map.ts +28 -0
- package/src/registry/registry.test.ts +20 -0
- package/src/registry/registry.ts +261 -0
- package/src/routes.json +1 -0
- package/src/setupI18n.ts +16 -0
- package/src/setupTests.ts +5 -0
- package/src/transformers/default-schema-transformer.test.ts +155 -0
- package/src/transformers/default-schema-transformer.ts +239 -0
- package/src/types/domain.ts +129 -0
- package/src/types/index.ts +130 -0
- package/src/types/schema.ts +238 -0
- package/src/typings.d.ts +9 -0
- package/src/utils/boolean-utils.ts +25 -0
- package/src/utils/common-expression-helpers.ts +503 -0
- package/src/utils/common-utils.test.ts +136 -0
- package/src/utils/common-utils.ts +55 -0
- package/src/utils/error-utils.ts +37 -0
- package/src/utils/expression-parser.test.ts +308 -0
- package/src/utils/expression-parser.ts +158 -0
- package/src/utils/expression-runner.test.ts +387 -0
- package/src/utils/expression-runner.ts +219 -0
- package/src/utils/form-helper.test.ts +482 -0
- package/src/utils/form-helper.ts +210 -0
- package/src/utils/form-page-utils.ts +13 -0
- package/src/utils/forms-loader.test.ts +323 -0
- package/src/utils/forms-loader.ts +306 -0
- package/src/utils/post-submission-action-helper.ts +71 -0
- package/src/utils/test-utils.ts +54 -0
- package/src/utils/zscore-service.ts +59 -0
- package/src/validators/conditional-answered-validator.test.ts +61 -0
- package/src/validators/conditional-answered-validator.ts +17 -0
- package/src/validators/date-validator.test.ts +46 -0
- package/src/validators/date-validator.ts +19 -0
- package/src/validators/default-value-validator.test.ts +90 -0
- package/src/validators/default-value-validator.ts +36 -0
- package/src/validators/form-validator.test.ts +188 -0
- package/src/validators/form-validator.ts +95 -0
- package/src/validators/js-expression-validator.test.ts +118 -0
- package/src/validators/js-expression-validator.ts +44 -0
- package/src/validators/schema.ts +34 -0
- package/src/zscore/bfa_boys_5_above.json +2522 -0
- package/src/zscore/bfa_girls_5_above.json +2522 -0
- package/src/zscore/hfa_boys_5_above.json +2186 -0
- package/src/zscore/hfa_boys_below5.json +22286 -0
- package/src/zscore/hfa_girls_5_above.json +2186 -0
- package/src/zscore/hfa_girls_below5.json +22286 -0
- package/src/zscore/wfl_boys_below5.json +7814 -0
- package/src/zscore/wfl_girls_below5.json +7814 -0
- package/src/zscore-tests/bmi-age.test.tsx +88 -0
- package/src/zscore-tests/height-age.test.tsx +96 -0
- package/src/zscore-tests/weight-height.test.tsx +87 -0
- package/tools/i18next-parser.config.js +93 -0
- package/translations/en.json +47 -0
- package/translations/es.json +38 -0
- package/translations/fr.json +38 -0
- package/translations/km.json +38 -0
- package/tsconfig.json +19 -0
- package/turbo.json +15 -0
- package/webpack.config.js +1 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
.label {
|
2
|
+
font-family: IBM Plex Sans;
|
3
|
+
font-size: 14px;
|
4
|
+
font-style: normal;
|
5
|
+
font-weight: 600;
|
6
|
+
line-height: 30px; /* 128.571% */
|
7
|
+
letter-spacing: 0.16px;
|
8
|
+
color: #000000;
|
9
|
+
}
|
10
|
+
|
11
|
+
.saveFile {
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.capturedImage {
|
16
|
+
width: 100%;
|
17
|
+
}
|
18
|
+
|
19
|
+
.caption {
|
20
|
+
display: flex;
|
21
|
+
}
|
22
|
+
|
23
|
+
.closeIcon {
|
24
|
+
margin: 0 1rem;
|
25
|
+
}
|
26
|
+
|
27
|
+
.uploadSelector {
|
28
|
+
display: flex;
|
29
|
+
align-items: center;
|
30
|
+
margin-bottom: 1rem;
|
31
|
+
}
|
32
|
+
|
33
|
+
.selectorButton {
|
34
|
+
margin-right: 1rem;
|
35
|
+
}
|
36
|
+
|
37
|
+
.caption {
|
38
|
+
display: flex;
|
39
|
+
margin-top: 5px;
|
40
|
+
}
|
41
|
+
|
42
|
+
.imageDescription {
|
43
|
+
margin-top: 5px;
|
44
|
+
}
|
45
|
+
|
46
|
+
.fileUploader {
|
47
|
+
background-color: rgb(255, 255, 255);
|
48
|
+
padding: 1rem;
|
49
|
+
}
|
50
|
+
|
51
|
+
.cameraUploader {
|
52
|
+
margin: 1rem 0;
|
53
|
+
background-color: white;
|
54
|
+
padding: 1rem;
|
55
|
+
}
|
56
|
+
|
57
|
+
.camButton {
|
58
|
+
margin-bottom: 1rem;
|
59
|
+
}
|
60
|
+
|
61
|
+
.cameraPreview {
|
62
|
+
margin-top: 1rem;
|
63
|
+
}
|
64
|
+
|
65
|
+
.imageContent {
|
66
|
+
padding: 0;
|
67
|
+
margin: 0;
|
68
|
+
}
|
69
|
+
|
70
|
+
.titleStyles {
|
71
|
+
color: #161616;
|
72
|
+
font-size: 0.875rem;
|
73
|
+
font-weight: 600;
|
74
|
+
letter-spacing: 0.16px;
|
75
|
+
line-height: 1.2857;
|
76
|
+
margin-bottom: 0.5rem;
|
77
|
+
}
|
78
|
+
|
79
|
+
.descriptionStyles {
|
80
|
+
color: #525252;
|
81
|
+
font-size: 0.875rem;
|
82
|
+
font-weight: 400;
|
83
|
+
letter-spacing: 0.16px;
|
84
|
+
line-height: 1.28572;
|
85
|
+
margin-bottom: 1rem;
|
86
|
+
}
|
87
|
+
|
88
|
+
.editModeImage {
|
89
|
+
background-color: white;
|
90
|
+
padding: 1rem;
|
91
|
+
}
|
92
|
+
|
93
|
+
.pdfThumbnail {
|
94
|
+
cursor: pointer;
|
95
|
+
background-color: gray;
|
96
|
+
display: flex;
|
97
|
+
justify-content: center;
|
98
|
+
align-items: center;
|
99
|
+
width: 5rem;
|
100
|
+
height: 5rem;
|
101
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import { isEmpty } from '../../../validators/form-validator';
|
3
|
+
import { type FormFieldInputProps } from '../../../types';
|
4
|
+
import { useFormProviderContext } from '../../../provider/form-provider';
|
5
|
+
|
6
|
+
const FixedValue: React.FC<FormFieldInputProps> = ({ field, setFieldValue }) => {
|
7
|
+
const context = useFormProviderContext();
|
8
|
+
|
9
|
+
useEffect(() => {
|
10
|
+
if (!field.meta?.previousValue && !isEmpty(field.meta.fixedValue)) {
|
11
|
+
setFieldValue(field.meta.fixedValue);
|
12
|
+
context.formFieldAdapters[field.type].transformFieldValue(field, field.meta.fixedValue, context);
|
13
|
+
}
|
14
|
+
}, []);
|
15
|
+
|
16
|
+
return <></>;
|
17
|
+
};
|
18
|
+
|
19
|
+
export default FixedValue;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import ReactMarkdown from 'react-markdown';
|
3
|
+
|
4
|
+
const MarkdownWrapper: React.FC<{ markdown: string | string[] }> = ({ markdown }) => {
|
5
|
+
return (
|
6
|
+
<ReactMarkdown
|
7
|
+
children={Array.isArray(markdown) ? markdown.join('\n') : markdown}
|
8
|
+
unwrapDisallowed={true}
|
9
|
+
allowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'strong', 'em']}
|
10
|
+
/>
|
11
|
+
);
|
12
|
+
};
|
13
|
+
|
14
|
+
export default MarkdownWrapper;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import MarkdownWrapper from './markdown-wrapper.component';
|
3
|
+
import { type FormFieldInputProps } from '../../../types';
|
4
|
+
|
5
|
+
const Markdown: React.FC<FormFieldInputProps> = ({ field }) => {
|
6
|
+
return !field.isHidden && <MarkdownWrapper markdown={field.value} />;
|
7
|
+
};
|
8
|
+
export default Markdown;
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
2
|
+
import { FilterableMultiSelect, Layer, Tag, CheckboxGroup, Checkbox } from '@carbon/react';
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
import { type FormFieldInputProps } from '../../../types';
|
5
|
+
import { ValueEmpty } from '../../value/value.component';
|
6
|
+
import { shouldUseInlineLayout } from '../../../utils/form-helper';
|
7
|
+
import { isTrue } from '../../../utils/boolean-utils';
|
8
|
+
import FieldValueView from '../../value/view/field-value-view.component';
|
9
|
+
import styles from './multi-select.scss';
|
10
|
+
import { useFormProviderContext } from '../../../provider/form-provider';
|
11
|
+
import FieldLabel from '../../field-label/field-label.component';
|
12
|
+
|
13
|
+
const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
|
14
|
+
const { t } = useTranslation();
|
15
|
+
const [counter, setCounter] = useState(0);
|
16
|
+
const [initiallyCheckedQuestionItems, setInitiallyCheckedQuestionItems] = useState([]);
|
17
|
+
const isFirstRender = useRef(true);
|
18
|
+
const { layoutType, sessionMode, workspaceLayout, formFieldAdapters } = useFormProviderContext();
|
19
|
+
|
20
|
+
const selectOptions = field.questionOptions.answers
|
21
|
+
.filter((answer) => !answer.isHidden)
|
22
|
+
.map((answer, index) => ({
|
23
|
+
id: `${field.id}-${answer.concept}`,
|
24
|
+
concept: answer.concept,
|
25
|
+
label: answer.label,
|
26
|
+
key: index,
|
27
|
+
disabled: answer.disable?.isDisabled,
|
28
|
+
}));
|
29
|
+
|
30
|
+
const initiallySelectedQuestionItems = useMemo(() => {
|
31
|
+
if (value?.length && counter < 1) {
|
32
|
+
setCounter(counter + 1);
|
33
|
+
return selectOptions.filter((item) => value?.includes(item.concept));
|
34
|
+
}
|
35
|
+
return [];
|
36
|
+
}, [value]);
|
37
|
+
|
38
|
+
const handleSelectItemsChange = ({ selectedItems }) => {
|
39
|
+
const value = selectedItems.map((selectedItem) => {
|
40
|
+
return selectedItem.concept;
|
41
|
+
});
|
42
|
+
setFieldValue(value);
|
43
|
+
};
|
44
|
+
|
45
|
+
useEffect(() => {
|
46
|
+
if (isFirstRender.current && counter === 1) {
|
47
|
+
setInitiallyCheckedQuestionItems(initiallySelectedQuestionItems.map((item) => item.concept));
|
48
|
+
isFirstRender.current = false;
|
49
|
+
}
|
50
|
+
}, [initiallySelectedQuestionItems, isFirstRender]);
|
51
|
+
|
52
|
+
const handleSelectCheckbox = (val) => {
|
53
|
+
const value = val.concept;
|
54
|
+
const isChecked = initiallyCheckedQuestionItems.some((item) => item === value);
|
55
|
+
let updatedItems;
|
56
|
+
if (isChecked) {
|
57
|
+
updatedItems = initiallyCheckedQuestionItems.filter((item) => item !== value);
|
58
|
+
} else {
|
59
|
+
updatedItems = initiallyCheckedQuestionItems.some((val) => val === value)
|
60
|
+
? initiallyCheckedQuestionItems.filter((item) => item !== value)
|
61
|
+
: [...initiallyCheckedQuestionItems, value];
|
62
|
+
}
|
63
|
+
setInitiallyCheckedQuestionItems(updatedItems);
|
64
|
+
setFieldValue(updatedItems);
|
65
|
+
};
|
66
|
+
|
67
|
+
const isInline = useMemo(() => {
|
68
|
+
if (['view', 'embedded-view'].includes(sessionMode) || isTrue(field.readonly)) {
|
69
|
+
return shouldUseInlineLayout(field.inlineRendering, layoutType, workspaceLayout, sessionMode);
|
70
|
+
}
|
71
|
+
return false;
|
72
|
+
}, [sessionMode, field.readonly, field.inlineRendering, layoutType, workspaceLayout]);
|
73
|
+
|
74
|
+
const label = useMemo(() => {
|
75
|
+
return field.isRequired ? <FieldLabel field={field} /> : <span>{t(field.label)}</span>;
|
76
|
+
}, [field.isRequired, field.label, t]);
|
77
|
+
|
78
|
+
return sessionMode == 'view' || sessionMode == 'embedded-view' ? (
|
79
|
+
<div className={styles.formField}>
|
80
|
+
<FieldValueView
|
81
|
+
label={t(field.label)}
|
82
|
+
value={value ? formFieldAdapters[field.type]?.getDisplayValue(field, value) : value}
|
83
|
+
conceptName={field.meta?.concept?.display}
|
84
|
+
isInline={isInline}
|
85
|
+
/>
|
86
|
+
</div>
|
87
|
+
) : (
|
88
|
+
!field.isHidden && (
|
89
|
+
<>
|
90
|
+
<div className={styles.boldedLabel}>
|
91
|
+
<Layer>
|
92
|
+
{field.inlineMultiCheckbox ? (
|
93
|
+
<CheckboxGroup legendText={label} name={field.id}>
|
94
|
+
{field.questionOptions.answers?.map((value, index) => {
|
95
|
+
return (
|
96
|
+
<Checkbox
|
97
|
+
key={value.concept}
|
98
|
+
className={styles.checkbox}
|
99
|
+
labelText={value.label}
|
100
|
+
id={value.concept}
|
101
|
+
onChange={() => {
|
102
|
+
handleSelectCheckbox(value);
|
103
|
+
}}
|
104
|
+
name={value.concept}
|
105
|
+
defaultChecked={initiallyCheckedQuestionItems.some((item) => item === value.concept)}
|
106
|
+
checked={initiallyCheckedQuestionItems.some((item) => item === value.concept)}
|
107
|
+
onBlur={onblur}
|
108
|
+
/>
|
109
|
+
);
|
110
|
+
})}
|
111
|
+
</CheckboxGroup>
|
112
|
+
) : (
|
113
|
+
<FilterableMultiSelect
|
114
|
+
placeholder={t('search', 'Search') + '...'}
|
115
|
+
onChange={handleSelectItemsChange}
|
116
|
+
id={t(field.label)}
|
117
|
+
items={selectOptions}
|
118
|
+
initialSelectedItems={initiallySelectedQuestionItems}
|
119
|
+
label={''}
|
120
|
+
titleText={label}
|
121
|
+
key={counter}
|
122
|
+
itemToString={(item) => (item ? item.label : ' ')}
|
123
|
+
disabled={field.isDisabled}
|
124
|
+
invalid={errors.length > 0}
|
125
|
+
invalidText={errors[0]?.message}
|
126
|
+
warn={warnings.length > 0}
|
127
|
+
warnText={warnings[0]?.message}
|
128
|
+
readOnly={field.readonly}
|
129
|
+
/>
|
130
|
+
)}
|
131
|
+
</Layer>
|
132
|
+
</div>
|
133
|
+
<div className={styles.selectionDisplay}>
|
134
|
+
{value?.length && field.questionOptions.answers?.length > 5 ? (
|
135
|
+
<div className={styles.tagContainer}>
|
136
|
+
{formFieldAdapters[field.type]?.getDisplayValue(field, value)?.map((displayValue, index) => (
|
137
|
+
<Tag key={index} type="cool-gray">
|
138
|
+
{displayValue}
|
139
|
+
</Tag>
|
140
|
+
))}
|
141
|
+
</div>
|
142
|
+
) : (
|
143
|
+
<ValueEmpty />
|
144
|
+
)}
|
145
|
+
</div>
|
146
|
+
</>
|
147
|
+
)
|
148
|
+
);
|
149
|
+
};
|
150
|
+
|
151
|
+
export default MultiSelect;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
@use '@carbon/colors';
|
2
|
+
|
3
|
+
.boldedLabel label,
|
4
|
+
legend > span {
|
5
|
+
font-weight: 600;
|
6
|
+
color: colors.$black-100;
|
7
|
+
}
|
8
|
+
|
9
|
+
.errorLabel label {
|
10
|
+
color: colors.$red-60;
|
11
|
+
font-weight: 600;
|
12
|
+
}
|
13
|
+
|
14
|
+
.selectionDisplay {
|
15
|
+
margin-top: 0.125rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
.tagContainer {
|
19
|
+
margin: 0.5rem 0;
|
20
|
+
}
|
21
|
+
|
22
|
+
.checkbox label {
|
23
|
+
color: colors.$black-100 !important;
|
24
|
+
font-weight: 500 !important;
|
25
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { act, render, screen } from '@testing-library/react';
|
3
|
+
import { userEvent } from '@testing-library/user-event';
|
4
|
+
import { type FetchResponse, openmrsFetch, usePatient, useSession } from '@openmrs/esm-framework';
|
5
|
+
import { type FormSchema } from '../../../types';
|
6
|
+
import { mockPatient } from '__mocks__/patient.mock';
|
7
|
+
import { mockSessionDataResponse } from '__mocks__/session.mock';
|
8
|
+
import { mockVisit } from '__mocks__/visit.mock';
|
9
|
+
import multiSelectFormSchema from '__mocks__/forms/rfe-forms/multi-select-form.json';
|
10
|
+
import FormEngine from '../../../form-engine.component';
|
11
|
+
global.ResizeObserver = require('resize-observer-polyfill');
|
12
|
+
|
13
|
+
const mockOpenmrsFetch = jest.mocked(openmrsFetch);
|
14
|
+
const mockUseSession = jest.mocked(useSession);
|
15
|
+
const mockUsePatient = jest.mocked(usePatient);
|
16
|
+
|
17
|
+
const visit = mockVisit;
|
18
|
+
const patientUUID = '8673ee4f-e2ab-4077-ba55-4980f408773e';
|
19
|
+
|
20
|
+
jest.mock('../../../api', () => {
|
21
|
+
const originalModule = jest.requireActual('../../../api');
|
22
|
+
|
23
|
+
return {
|
24
|
+
...originalModule,
|
25
|
+
getPreviousEncounter: jest.fn().mockImplementation(() => Promise.resolve(null)),
|
26
|
+
getConcept: jest.fn().mockImplementation(() => Promise.resolve(null)),
|
27
|
+
getLatestObs: jest.fn().mockImplementation(() => Promise.resolve({ valueNumeric: 60 })),
|
28
|
+
saveEncounter: jest.fn(),
|
29
|
+
createProgramEnrollment: jest.fn(),
|
30
|
+
};
|
31
|
+
});
|
32
|
+
|
33
|
+
const renderForm = async () => {
|
34
|
+
await act(() =>
|
35
|
+
render(
|
36
|
+
<FormEngine
|
37
|
+
formJson={multiSelectFormSchema as unknown as FormSchema}
|
38
|
+
formUUID={null}
|
39
|
+
patientUUID={patientUUID}
|
40
|
+
formSessionIntent={undefined}
|
41
|
+
visit={visit}
|
42
|
+
/>,
|
43
|
+
),
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
describe.skip('MultiSelect Component', () => {
|
48
|
+
beforeEach(() => {
|
49
|
+
mockOpenmrsFetch.mockResolvedValue({
|
50
|
+
data: { results: [{ ...multiSelectFormSchema }] },
|
51
|
+
} as unknown as FetchResponse);
|
52
|
+
|
53
|
+
mockUseSession.mockReturnValue(mockSessionDataResponse.data);
|
54
|
+
|
55
|
+
mockUsePatient.mockReturnValue({
|
56
|
+
isLoading: false,
|
57
|
+
patient: mockPatient,
|
58
|
+
patientUuid: mockPatient.id,
|
59
|
+
error: null,
|
60
|
+
});
|
61
|
+
});
|
62
|
+
|
63
|
+
it('renders correctly', async () => {
|
64
|
+
await renderForm();
|
65
|
+
expect(screen.getByRole('combobox', { name: /Patient covered by NHIF/i })).toBeInTheDocument();
|
66
|
+
expect(screen.getByText('Was this visit scheduled?')).toBeInTheDocument();
|
67
|
+
});
|
68
|
+
|
69
|
+
it('should disable checkbox option if the field value depends on evaluates the expression to true', async () => {
|
70
|
+
const user = userEvent.setup();
|
71
|
+
await renderForm();
|
72
|
+
|
73
|
+
await user.click(screen.getByRole('combobox', { name: /Patient covered by NHIF/i }));
|
74
|
+
await user.click(screen.getByRole('option', { name: /no/i }));
|
75
|
+
|
76
|
+
await user.click(screen.getByText('Was this visit scheduled?'));
|
77
|
+
expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).toHaveAttribute('disabled');
|
78
|
+
});
|
79
|
+
|
80
|
+
it('should enable checkbox option if the field value depends on evaluates the expression to false', async () => {
|
81
|
+
const user = userEvent.setup();
|
82
|
+
await renderForm();
|
83
|
+
|
84
|
+
await user.click(screen.getByRole('combobox', { name: /patient covered by nhif/i }));
|
85
|
+
await user.click(screen.getByRole('option', { name: /yes/i }));
|
86
|
+
|
87
|
+
await user.click(screen.getByText('Was this visit scheduled?'));
|
88
|
+
expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).not.toHaveAttribute('disabled');
|
89
|
+
});
|
90
|
+
});
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
2
|
+
import { Layer, NumberInput } from '@carbon/react';
|
3
|
+
import classNames from 'classnames';
|
4
|
+
import { isTrue } from '../../../utils/boolean-utils';
|
5
|
+
import { shouldUseInlineLayout } from '../../../utils/form-helper';
|
6
|
+
import FieldValueView from '../../value/view/field-value-view.component';
|
7
|
+
import { type FormFieldInputProps } from '../../../types';
|
8
|
+
import styles from './number.scss';
|
9
|
+
import { useTranslation } from 'react-i18next';
|
10
|
+
import { useFormProviderContext } from '../../../provider/form-provider';
|
11
|
+
import FieldLabel from '../../field-label/field-label.component';
|
12
|
+
|
13
|
+
const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
|
14
|
+
const { t } = useTranslation();
|
15
|
+
const [lastBlurredValue, setLastBlurredValue] = useState(value);
|
16
|
+
const { layoutType, sessionMode, workspaceLayout } = useFormProviderContext();
|
17
|
+
|
18
|
+
const onBlur = (event) => {
|
19
|
+
event.preventDefault();
|
20
|
+
if (lastBlurredValue != value) {
|
21
|
+
setLastBlurredValue(value);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
const isInline = useMemo(() => {
|
26
|
+
if (['view', 'embedded-view'].includes(sessionMode) || isTrue(field.readonly)) {
|
27
|
+
return shouldUseInlineLayout(field.inlineRendering, layoutType, workspaceLayout, sessionMode);
|
28
|
+
}
|
29
|
+
return false;
|
30
|
+
}, [sessionMode, field.readonly, field.inlineRendering, layoutType, workspaceLayout]);
|
31
|
+
|
32
|
+
return sessionMode == 'view' || sessionMode == 'embedded-view' ? (
|
33
|
+
<div className={styles.formField}>
|
34
|
+
<FieldValueView
|
35
|
+
label={t(field.label)}
|
36
|
+
value={value}
|
37
|
+
conceptName={field.meta?.concept?.display}
|
38
|
+
isInline={isInline}
|
39
|
+
/>
|
40
|
+
</div>
|
41
|
+
) : (
|
42
|
+
<Layer>
|
43
|
+
<NumberInput
|
44
|
+
id={field.id}
|
45
|
+
invalid={errors.length > 0}
|
46
|
+
invalidText={errors[0]?.message}
|
47
|
+
label={<FieldLabel field={field} />}
|
48
|
+
max={Number(field.questionOptions.max) || undefined}
|
49
|
+
min={Number(field.questionOptions.min) || undefined}
|
50
|
+
name={field.id}
|
51
|
+
value={field.value ?? ''}
|
52
|
+
onChange={setFieldValue}
|
53
|
+
onBlur={onBlur}
|
54
|
+
allowEmpty={true}
|
55
|
+
size="lg"
|
56
|
+
hideSteppers={true}
|
57
|
+
onWheel={(e) => e.target.blur()}
|
58
|
+
disabled={field.isDisabled}
|
59
|
+
readOnly={field.readonly}
|
60
|
+
className={classNames(styles.controlWidthConstrained, styles.boldedLabel)}
|
61
|
+
warn={warnings.length > 0}
|
62
|
+
warnText={warnings[0]?.message}
|
63
|
+
step={0.01}
|
64
|
+
/>
|
65
|
+
</Layer>
|
66
|
+
);
|
67
|
+
};
|
68
|
+
|
69
|
+
export default NumberField;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React, { useMemo } from 'react';
|
2
|
+
import { useTranslation } from 'react-i18next';
|
3
|
+
import { FormGroup, RadioButtonGroup, RadioButton } from '@carbon/react';
|
4
|
+
import { type FormFieldInputProps } from '../../../types';
|
5
|
+
import { isTrue } from '../../../utils/boolean-utils';
|
6
|
+
import { shouldUseInlineLayout } from '../../../utils/form-helper';
|
7
|
+
import FieldValueView from '../../value/view/field-value-view.component';
|
8
|
+
import styles from './radio.scss';
|
9
|
+
import { useFormProviderContext } from '../../../provider/form-provider';
|
10
|
+
import FieldLabel from '../../field-label/field-label.component';
|
11
|
+
|
12
|
+
const Radio: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
|
13
|
+
const { t } = useTranslation();
|
14
|
+
const { layoutType, sessionMode, workspaceLayout, formFieldAdapters } = useFormProviderContext();
|
15
|
+
|
16
|
+
const handleChange = (value) => {
|
17
|
+
setFieldValue(value);
|
18
|
+
};
|
19
|
+
|
20
|
+
const isInline = useMemo(() => {
|
21
|
+
if (['view', 'embedded-view'].includes(sessionMode) || isTrue(field.readonly)) {
|
22
|
+
return shouldUseInlineLayout(field.inlineRendering, layoutType, workspaceLayout, sessionMode);
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
}, [sessionMode, field.readonly, field.inlineRendering, layoutType, workspaceLayout]);
|
26
|
+
|
27
|
+
return sessionMode == 'view' || sessionMode == 'embedded-view' || isTrue(field.readonly) ? (
|
28
|
+
<FieldValueView
|
29
|
+
label={t(field.label)}
|
30
|
+
value={value ? formFieldAdapters[field.type].getDisplayValue(field, value) : value}
|
31
|
+
conceptName={field.meta?.concept?.display}
|
32
|
+
isInline={isInline}
|
33
|
+
/>
|
34
|
+
) : (
|
35
|
+
!field.isHidden && (
|
36
|
+
<FormGroup
|
37
|
+
legendText={<FieldLabel field={field} />}
|
38
|
+
className={styles.boldedLegend}
|
39
|
+
disabled={field.isDisabled}
|
40
|
+
invalid={errors.length > 0}>
|
41
|
+
<RadioButtonGroup
|
42
|
+
name={field.id}
|
43
|
+
valueSelected={value}
|
44
|
+
onChange={handleChange}
|
45
|
+
orientation={field.questionOptions?.orientation || 'vertical'}>
|
46
|
+
{field.questionOptions.answers
|
47
|
+
.filter((answer) => !answer.isHidden)
|
48
|
+
.map((answer, index) => {
|
49
|
+
return (
|
50
|
+
<RadioButton
|
51
|
+
id={`${field.id}-${answer.label}`}
|
52
|
+
labelText={answer.label ?? ''}
|
53
|
+
value={answer.concept}
|
54
|
+
key={index}
|
55
|
+
onClick={(e) => {
|
56
|
+
if (value && e.target.checked) {
|
57
|
+
e.target.checked = false;
|
58
|
+
handleChange(null);
|
59
|
+
} else {
|
60
|
+
handleChange(answer.concept);
|
61
|
+
}
|
62
|
+
}}
|
63
|
+
/>
|
64
|
+
);
|
65
|
+
})}
|
66
|
+
</RadioButtonGroup>
|
67
|
+
{(errors?.length > 0 || warnings?.length > 0) && (
|
68
|
+
<div>
|
69
|
+
<div className={styles.errorMessage}>
|
70
|
+
{errors.length > 0 ? errors[0].message : warnings.length > 0 ? warnings[0].message : null}
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
)}
|
74
|
+
</FormGroup>
|
75
|
+
)
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
export default Radio;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
@use '@carbon/colors';
|
2
|
+
|
3
|
+
.errorLegend legend {
|
4
|
+
color: colors.$red-60 !important;
|
5
|
+
font-weight: 600;
|
6
|
+
}
|
7
|
+
|
8
|
+
.boldedLegend legend {
|
9
|
+
color: colors.$black-100 !important;
|
10
|
+
font-weight: 600;
|
11
|
+
}
|
12
|
+
|
13
|
+
.warningLabel {
|
14
|
+
display: block;
|
15
|
+
max-height: 12.5rem;
|
16
|
+
overflow: visible;
|
17
|
+
font-weight: 400;
|
18
|
+
color: colors.$gray-70;
|
19
|
+
}
|
20
|
+
|
21
|
+
.errorLabel {
|
22
|
+
display: block;
|
23
|
+
max-height: 12.5rem;
|
24
|
+
overflow: visible;
|
25
|
+
font-weight: 400;
|
26
|
+
color: colors.$red-60;
|
27
|
+
}
|
28
|
+
|
29
|
+
.errorMessage {
|
30
|
+
display: block;
|
31
|
+
max-height: 12.5rem;
|
32
|
+
overflow: visible;
|
33
|
+
font-weight: 400;
|
34
|
+
color: colors.$red-60;
|
35
|
+
font-size: 0.8rem;
|
36
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, { useMemo, useCallback } from 'react';
|
2
|
+
import { useTranslation } from 'react-i18next';
|
3
|
+
import { Dropdown as DropdownInput, Layer } from '@carbon/react';
|
4
|
+
import { shouldUseInlineLayout } from '../../../utils/form-helper';
|
5
|
+
import { isTrue } from '../../../utils/boolean-utils';
|
6
|
+
import { type FormFieldInputProps } from '../../../types';
|
7
|
+
import FieldValueView from '../../value/view/field-value-view.component';
|
8
|
+
import FieldLabel from '../../field-label/field-label.component';
|
9
|
+
|
10
|
+
import styles from './dropdown.scss';
|
11
|
+
import { useFormProviderContext } from '../../../provider/form-provider';
|
12
|
+
|
13
|
+
const Dropdown: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
|
14
|
+
const { t } = useTranslation();
|
15
|
+
const { layoutType, sessionMode, workspaceLayout, formFieldAdapters } = useFormProviderContext();
|
16
|
+
|
17
|
+
const handleChange = useCallback(
|
18
|
+
(value) => {
|
19
|
+
setFieldValue(value);
|
20
|
+
},
|
21
|
+
[setFieldValue],
|
22
|
+
);
|
23
|
+
|
24
|
+
const itemToString = useCallback(
|
25
|
+
(item) => {
|
26
|
+
const answer = field.questionOptions.answers.find((opt) => (opt.value ? opt.value == item : opt.concept == item));
|
27
|
+
return answer?.label;
|
28
|
+
},
|
29
|
+
[field.questionOptions.answers],
|
30
|
+
);
|
31
|
+
|
32
|
+
const isInline = useMemo(() => {
|
33
|
+
if (['view', 'embedded-view'].includes(sessionMode) || isTrue(field.readonly)) {
|
34
|
+
return shouldUseInlineLayout(field.inlineRendering, layoutType, workspaceLayout, sessionMode);
|
35
|
+
}
|
36
|
+
return false;
|
37
|
+
}, [sessionMode, field.readonly, field.inlineRendering, layoutType, workspaceLayout]);
|
38
|
+
|
39
|
+
return sessionMode == 'view' || sessionMode == 'embedded-view' ? (
|
40
|
+
<FieldValueView
|
41
|
+
label={t(field.label)}
|
42
|
+
value={value ? formFieldAdapters[field.type].getDisplayValue(field, value) : value}
|
43
|
+
conceptName={field.meta?.concept?.display}
|
44
|
+
isInline={isInline}
|
45
|
+
/>
|
46
|
+
) : (
|
47
|
+
!field.isHidden && (
|
48
|
+
<div className={styles.boldedLabel}>
|
49
|
+
<Layer>
|
50
|
+
<DropdownInput
|
51
|
+
id={field.id}
|
52
|
+
titleText={<FieldLabel field={field} />}
|
53
|
+
label={t('chooseAnOption', 'Choose an option')}
|
54
|
+
items={field.questionOptions.answers
|
55
|
+
.filter((answer) => !answer.isHidden)
|
56
|
+
.map((item) => item.value || item.concept)}
|
57
|
+
itemToString={itemToString}
|
58
|
+
selectedItem={value}
|
59
|
+
onChange={({ selectedItem }) => handleChange(selectedItem)}
|
60
|
+
disabled={field.isDisabled}
|
61
|
+
readOnly={field.readonly}
|
62
|
+
invalid={errors.length > 0}
|
63
|
+
invalidText={errors[0]?.message}
|
64
|
+
warn={warnings.length > 0}
|
65
|
+
warnText={warnings[0]?.message}
|
66
|
+
/>
|
67
|
+
</Layer>
|
68
|
+
</div>
|
69
|
+
)
|
70
|
+
);
|
71
|
+
};
|
72
|
+
|
73
|
+
export default Dropdown;
|