@openmrs/esm-form-engine-lib 3.0.0 → 3.0.1

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.
Files changed (38) hide show
  1. package/README.md +65 -30
  2. package/__mocks__/forms/rfe-forms/obs-group-test_form.json +188 -124
  3. package/dist/openmrs-esm-form-engine-lib.js +1 -1
  4. package/package.json +5 -4
  5. package/src/components/group/obs-group.component.tsx +5 -5
  6. package/src/components/inputs/content-switcher/content-switcher.component.tsx +6 -1
  7. package/src/components/inputs/date/date.component.tsx +1 -1
  8. package/src/components/inputs/multi-select/multi-select.component.tsx +4 -4
  9. package/src/components/inputs/number/number.component.tsx +2 -2
  10. package/src/components/inputs/radio/radio.component.tsx +1 -1
  11. package/src/components/inputs/select/dropdown.component.tsx +2 -2
  12. package/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +39 -18
  13. package/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +0 -1
  14. package/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +3 -1
  15. package/src/components/sidebar/sidebar.component.tsx +5 -6
  16. package/src/components/sidebar/sidebar.scss +5 -0
  17. package/src/components/value/value.component.tsx +4 -1
  18. package/src/form-engine.component.tsx +17 -13
  19. package/src/form-engine.scss +8 -0
  20. package/src/form-engine.test.tsx +44 -1
  21. package/src/hooks/{useConcepts.tsx → useConcepts.ts} +1 -2
  22. package/src/hooks/useDataSourceDependentValue.ts +1 -1
  23. package/src/hooks/{useEncounter.tsx → useEncounter.ts} +9 -1
  24. package/src/hooks/{useFormJson.tsx → useFormJson.ts} +12 -2
  25. package/src/hooks/{usePatientData.tsx → usePatientData.ts} +1 -1
  26. package/src/hooks/usePatientPrograms.ts +13 -3
  27. package/src/hooks/useProcessorDependencies.ts +14 -4
  28. package/src/types/schema.ts +5 -0
  29. package/src/utils/common-expression-helpers.test.ts +1 -1
  30. package/src/utils/common-expression-helpers.ts +10 -7
  31. package/translations/en.json +3 -3
  32. package/src/hooks/useClobData.tsx +0 -21
  33. package/src/hooks/useFieldValidationResults.ts +0 -18
  34. package/src/hooks/useFormsConfig.tsx +0 -27
  35. package/src/hooks/useRestMaxResultsCount.ts +0 -5
  36. package/src/hooks/useSystemSetting.ts +0 -36
  37. package/src/hooks/{useEncounterRole.tsx → useEncounterRole.ts} +1 -1
  38. package/src/hooks/{useFormCollapse.tsx → useFormCollapse.ts} +1 -1
@@ -2,6 +2,7 @@
2
2
  "add": "Add",
3
3
  "addCameraImage": "Add camera image",
4
4
  "addFile": "Add files",
5
+ "blank": "Blank",
5
6
  "cameraCapture": "Camera capture",
6
7
  "cancel": "Cancel",
7
8
  "chooseAnOption": "Choose an option",
@@ -17,7 +18,7 @@
17
18
  "fileUploadDescriptionAny": "Upload any file type",
18
19
  "invalidWorkspaceName": "Invalid workspace name.",
19
20
  "invalidWorkspaceNameSubtitle": "Please provide a valid workspace name.",
20
- "launchWorkspace": "",
21
+ "launchWorkspace": "Launch Workspace",
21
22
  "loading": "Loading",
22
23
  "notification": "Notification",
23
24
  "nullMandatoryField": "Please fill the required fields",
@@ -26,13 +27,12 @@
26
27
  "remove": "Remove",
27
28
  "required": "Required",
28
29
  "reuseValue": "Reuse value",
29
- "revert": "Revert",
30
30
  "save": "Save",
31
31
  "search": "Search",
32
+ "searching": "Searching",
32
33
  "submitting": "Submitting",
33
34
  "time": "Time",
34
35
  "unspecified": "Unspecified",
35
- "unspecifyAll": "Unspecify All",
36
36
  "upload": "Upload",
37
37
  "uploadedPhoto": "Uploaded photo",
38
38
  "uploadImage": "Upload image",
@@ -1,21 +0,0 @@
1
- import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
- import { useMemo } from 'react';
3
- import { type FormSchema, type OpenmrsForm } from '../types';
4
- import useSWRImmutable from 'swr/immutable';
5
-
6
- export function useClobData(form: OpenmrsForm) {
7
- const valueReferenceUuid = useMemo(
8
- () => form?.resources?.find(({ name }) => name === 'JSON schema').valueReference,
9
- [form],
10
- );
11
- const { data, error } = useSWRImmutable<{ data: FormSchema }, Error>(
12
- valueReferenceUuid ? `${restBaseUrl}/clobdata/${valueReferenceUuid}` : null,
13
- openmrsFetch,
14
- );
15
-
16
- return {
17
- clobdata: data?.data,
18
- clobdataError: error || null,
19
- isLoadingClobData: (!data && !error) || false,
20
- };
21
- }
@@ -1,18 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { type FormField } from '../types';
3
-
4
- export function useFieldValidationResults(field: FormField) {
5
- const [errors, setErrors] = useState([]);
6
- const [warnings, setWarnings] = useState([]);
7
-
8
- useEffect(() => {
9
- if (field.meta?.submission?.errors) {
10
- setErrors(field.meta.submission.errors);
11
- }
12
- if (field.meta?.submission?.warnings) {
13
- setWarnings(field.meta.submission.warnings);
14
- }
15
- }, [field.meta?.submission]);
16
-
17
- return { errors, warnings, setErrors, setWarnings };
18
- }
@@ -1,27 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import get from 'lodash-es/get';
3
- import { getConfig } from '@openmrs/esm-framework';
4
- import { ConceptTrue, ConceptFalse } from '../constants';
5
-
6
- export interface FormsConfig {
7
- conceptTrue: string;
8
- conceptFalse: string;
9
- }
10
- const defaultOptions: FormsConfig = {
11
- conceptTrue: ConceptTrue,
12
- conceptFalse: ConceptFalse,
13
- };
14
-
15
- export function useFormsConfig(moduleName: string, configPath: string) {
16
- const [config, setConfig] = useState<FormsConfig>(defaultOptions);
17
-
18
- useEffect(() => {
19
- if (moduleName && configPath) {
20
- getConfig(moduleName).then((c) => {
21
- setConfig({ config, ...get(c, configPath, config) });
22
- });
23
- }
24
- }, [moduleName, configPath, config]);
25
-
26
- return config;
27
- }
@@ -1,5 +0,0 @@
1
- import useSystemSetting from './useSystemSetting';
2
-
3
- export default function useRestMaxResultsCount() {
4
- return useSystemSetting('webservices.rest.maxResultsDefault');
5
- }
@@ -1,36 +0,0 @@
1
- import { openmrsFetch, restBaseUrl, showSnackbar } from '@openmrs/esm-framework';
2
- import { useEffect } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
- import useSWRImmutable from 'swr/immutable';
5
-
6
- export interface SystemSetting {
7
- uuid: string;
8
- property: string;
9
- value: string;
10
- }
11
-
12
- export default function useSystemSetting(setting: string) {
13
- const { t } = useTranslation();
14
- const apiUrl = `${restBaseUrl}/systemsetting/${setting}?v=custom:(value)`;
15
- const { data, error, isLoading } = useSWRImmutable<{ data: SystemSetting }, Error>(apiUrl, openmrsFetch);
16
-
17
- useEffect(() => {
18
- if (error) {
19
- showSnackbar({
20
- title: t('error', 'Error'),
21
- subtitle: error?.message,
22
- kind: 'error',
23
- isLowContrast: false,
24
- });
25
- }
26
- }, [error]);
27
-
28
- return {
29
- systemSetting: data?.data,
30
- error: error,
31
- isLoading: isLoading,
32
- isValueUuid:
33
- /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(data?.data?.value) ||
34
- /^[0-9a-f]{36}$/i.test(data?.data?.value),
35
- };
36
- }
@@ -1,5 +1,5 @@
1
- import { type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
1
  import useSWRImmutable from 'swr/immutable';
2
+ import { type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
3
3
 
4
4
  export function useEncounterRole() {
5
5
  const { data, error, isLoading } = useSWRImmutable<{ data: { results: Array<OpenmrsResource> } }, Error>(
@@ -1,5 +1,5 @@
1
- import type { FormExpanded, SessionMode } from '../types';
2
1
  import { useCallback, useEffect, useState } from 'react';
2
+ import type { FormExpanded, SessionMode } from '../types';
3
3
 
4
4
  export function useFormCollapse(sessionMode: SessionMode) {
5
5
  const [isFormExpanded, setIsFormExpanded] = useState<FormExpanded>(undefined);