@openmrs/esm-form-engine-lib 2.1.0-pre.1443 → 2.1.0-pre.1464
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/{b7bbd285b8eaabe2/b7bbd285b8eaabe2.gz → 5948f6a2f7307d43/5948f6a2f7307d43.gz} +0 -0
- package/a5554c5d36ee0258/a5554c5d36ee0258.gz +0 -0
- package/package.json +1 -1
- package/src/components/inputs/multi-select/multi-select.test.tsx +9 -11
- package/src/components/renderer/form/form-renderer.component.tsx +6 -1
- package/src/components/renderer/page/page.renderer.component.tsx +32 -16
- package/src/components/renderer/page/page.renderer.scss +19 -3
- package/src/components/sidebar/sidebar.scss +1 -1
- package/f30893a11ee98562/f30893a11ee98562.gz +0 -0
- /package/{028fb0e475ee0bc4/028fb0e475ee0bc4.gz → cccd29dacee5e078/cccd29dacee5e078.gz} +0 -0
- /package/{be488ec37d96a45f/be488ec37d96a45f.gz → e8833b3751c12211/e8833b3751c12211.gz} +0 -0
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { act, render, screen } from '@testing-library/react';
|
3
|
-
import
|
3
|
+
import userEvent from '@testing-library/user-event'; // Correct import for userEvent
|
4
4
|
import { type FetchResponse, openmrsFetch, usePatient, useSession } from '@openmrs/esm-framework';
|
5
5
|
import { type FormSchema } from '../../../types';
|
6
6
|
import { mockPatient } from '__mocks__/patient.mock';
|
@@ -31,7 +31,7 @@ jest.mock('../../../api', () => {
|
|
31
31
|
});
|
32
32
|
|
33
33
|
const renderForm = async () => {
|
34
|
-
await act(() =>
|
34
|
+
await act(async () => {
|
35
35
|
render(
|
36
36
|
<FormEngine
|
37
37
|
formJson={multiSelectFormSchema as unknown as FormSchema}
|
@@ -40,11 +40,11 @@ const renderForm = async () => {
|
|
40
40
|
formSessionIntent={undefined}
|
41
41
|
visit={visit}
|
42
42
|
/>,
|
43
|
-
)
|
44
|
-
);
|
43
|
+
);
|
44
|
+
});
|
45
45
|
};
|
46
46
|
|
47
|
-
describe
|
47
|
+
describe('MultiSelect Component', () => {
|
48
48
|
beforeEach(() => {
|
49
49
|
mockOpenmrsFetch.mockResolvedValue({
|
50
50
|
data: { results: [{ ...multiSelectFormSchema }] },
|
@@ -69,22 +69,20 @@ describe.skip('MultiSelect Component', () => {
|
|
69
69
|
it('should disable checkbox option if the field value depends on evaluates the expression to true', async () => {
|
70
70
|
const user = userEvent.setup();
|
71
71
|
await renderForm();
|
72
|
-
|
73
72
|
await user.click(screen.getByRole('combobox', { name: /Patient covered by NHIF/i }));
|
74
73
|
await user.click(screen.getByRole('option', { name: /no/i }));
|
75
|
-
|
76
74
|
await user.click(screen.getByText('Was this visit scheduled?'));
|
77
|
-
|
75
|
+
const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i });
|
76
|
+
expect(unscheduledVisitOption).toHaveAttribute('disabled');
|
78
77
|
});
|
79
78
|
|
80
79
|
it('should enable checkbox option if the field value depends on evaluates the expression to false', async () => {
|
81
80
|
const user = userEvent.setup();
|
82
81
|
await renderForm();
|
83
|
-
|
84
82
|
await user.click(screen.getByRole('combobox', { name: /patient covered by nhif/i }));
|
85
83
|
await user.click(screen.getByRole('option', { name: /yes/i }));
|
86
|
-
|
87
84
|
await user.click(screen.getByText('Was this visit scheduled?'));
|
88
|
-
|
85
|
+
const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i });
|
86
|
+
expect(unscheduledVisitOption).not.toBeDisabled();
|
89
87
|
});
|
90
88
|
});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useMemo } from 'react';
|
1
|
+
import React, { useMemo, useState } from 'react';
|
2
2
|
import { type FormPage } from '../../../types';
|
3
3
|
import { isTrue } from '../../../utils/boolean-utils';
|
4
4
|
import { useTranslation } from 'react-i18next';
|
@@ -7,6 +7,7 @@ import { Waypoint } from 'react-waypoint';
|
|
7
7
|
import styles from './page.renderer.scss';
|
8
8
|
import { Accordion, AccordionItem } from '@carbon/react';
|
9
9
|
import { useFormFactory } from '../../../provider/form-factory-provider';
|
10
|
+
import { ChevronDownIcon, ChevronUpIcon } from '@openmrs/esm-framework';
|
10
11
|
|
11
12
|
interface PageRendererProps {
|
12
13
|
page: FormPage;
|
@@ -15,32 +16,47 @@ interface PageRendererProps {
|
|
15
16
|
function PageRenderer({ page }: PageRendererProps) {
|
16
17
|
const { t } = useTranslation();
|
17
18
|
const pageId = useMemo(() => page.label.replace(/\s/g, ''), [page.label]);
|
19
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
18
20
|
|
19
21
|
const { setCurrentPage } = useFormFactory();
|
20
22
|
const visibleSections = page.sections.filter((section) => {
|
21
23
|
const hasVisibleQuestions = section.questions.some((question) => !isTrue(question.isHidden));
|
22
24
|
return !isTrue(section.isHidden) && hasVisibleQuestions;
|
23
25
|
});
|
26
|
+
|
27
|
+
const toggleCollapse = () => setIsCollapsed(!isCollapsed);
|
28
|
+
|
24
29
|
return (
|
25
30
|
<div>
|
26
31
|
<Waypoint onEnter={() => setCurrentPage(pageId)} topOffset="50%" bottomOffset="60%">
|
27
32
|
<div className={styles.pageContent}>
|
28
|
-
<div className={styles.pageHeader}>
|
29
|
-
<p className={styles.pageTitle}>
|
33
|
+
<div className={styles.pageHeader} onClick={toggleCollapse}>
|
34
|
+
<p className={styles.pageTitle}>
|
35
|
+
{t(page.label)}
|
36
|
+
<span className={styles.collapseIconWrapper}>
|
37
|
+
{isCollapsed ? (
|
38
|
+
<ChevronDownIcon className={styles.collapseIcon} aria-label="Expand" />
|
39
|
+
) : (
|
40
|
+
<ChevronUpIcon className={styles.collapseIcon} aria-label="Collapse" />
|
41
|
+
)}
|
42
|
+
</span>
|
43
|
+
</p>
|
30
44
|
</div>
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
{!isCollapsed && (
|
46
|
+
<Accordion>
|
47
|
+
{visibleSections.map((section) => (
|
48
|
+
<AccordionItem
|
49
|
+
title={t(section.label)}
|
50
|
+
open={true}
|
51
|
+
className={styles.sectionContainer}
|
52
|
+
key={`section-${section.label}`}>
|
53
|
+
<div className={styles.formSection}>
|
54
|
+
<SectionRenderer section={section} />
|
55
|
+
</div>
|
56
|
+
</AccordionItem>
|
57
|
+
))}
|
58
|
+
</Accordion>
|
59
|
+
)}
|
44
60
|
</div>
|
45
61
|
</Waypoint>
|
46
62
|
</div>
|
@@ -1,13 +1,19 @@
|
|
1
1
|
@use '@carbon/colors';
|
2
|
+
@use '@carbon/type';
|
2
3
|
|
3
4
|
.pageContent:last-child > hr {
|
4
5
|
display: none;
|
5
6
|
}
|
6
7
|
|
7
8
|
.pageHeader {
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
cursor: pointer;
|
10
|
+
transition: background-color 0.1s;
|
11
|
+
border-radius: 1px;
|
12
|
+
padding: 0.5rem 1rem;
|
13
|
+
|
14
|
+
&:hover {
|
15
|
+
background-color: colors.$gray-20;
|
16
|
+
}
|
11
17
|
}
|
12
18
|
|
13
19
|
.pageTitle {
|
@@ -16,6 +22,16 @@
|
|
16
22
|
line-height: 1.4;
|
17
23
|
color: colors.$gray-100;
|
18
24
|
width: 100%;
|
25
|
+
display: flex;
|
26
|
+
align-items: center;
|
27
|
+
justify-content: space-between;
|
28
|
+
margin: 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
.collapseIcon {
|
32
|
+
fill: colors.$gray-70;
|
33
|
+
width: 1rem;
|
34
|
+
height: 1rem;
|
19
35
|
}
|
20
36
|
|
21
37
|
.sectionContainer > div {
|
Binary file
|
File without changes
|
File without changes
|