@openmrs/esm-form-engine-lib 2.1.0-pre.1443 → 2.1.0-pre.1462
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 → 5bad9d4a3f2bed27/5bad9d4a3f2bed27.gz} +0 -0
- package/cfeaf25d976dbd2e/cfeaf25d976dbd2e.gz +0 -0
- package/package.json +1 -1
- 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/{be488ec37d96a45f/be488ec37d96a45f.gz → 8f9d17c6bed90e8b/8f9d17c6bed90e8b.gz} +0 -0
- /package/{028fb0e475ee0bc4/028fb0e475ee0bc4.gz → 9b51d62ae699c65c/9b51d62ae699c65c.gz} +0 -0
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -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
|