@openmrs/esm-form-engine-lib 3.1.0-pre.1697 → 3.1.0-pre.1699

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "3.1.0-pre.1697",
3
+ "version": "3.1.0-pre.1699",
4
4
  "description": "React Form Engine for O3",
5
5
  "browser": "dist/openmrs-esm-form-engine-lib.js",
6
6
  "main": "src/index.ts",
@@ -1,3 +1,5 @@
1
+ @use '@carbon/layout';
2
+
1
3
  .label {
2
4
  font-family: IBM Plex Sans;
3
5
  font-size: 14px;
@@ -28,10 +30,8 @@
28
30
  display: flex;
29
31
  align-items: center;
30
32
  margin-bottom: 1rem;
31
- }
32
-
33
- .selectorButton {
34
- margin-right: 1rem;
33
+ flex-wrap: wrap;
34
+ gap: layout.$spacing-05;
35
35
  }
36
36
 
37
37
  .caption {
@@ -1,5 +1,6 @@
1
1
  @use '@carbon/colors';
2
2
  @use '@carbon/type';
3
+ @use '@carbon/layout';
3
4
 
4
5
  .pageContent:last-child > hr {
5
6
  display: none;
@@ -39,6 +40,10 @@
39
40
  background-color: colors.$gray-10;
40
41
  }
41
42
 
43
+ .sectionContainer :global(.cds--accordion__content) {
44
+ padding-right: layout.$spacing-05;
45
+ }
46
+
42
47
  .accordionContainer {
43
48
  width: 95%;
44
49
  }
@@ -1,7 +1,8 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { Button, InlineLoading } from '@carbon/react';
5
+ import { useLayoutType } from '@openmrs/esm-framework';
5
6
  import { isPageContentVisible } from '../../utils/form-helper';
6
7
  import { useCurrentActivePage } from './useCurrentActivePage';
7
8
  import { usePageObserver } from './usePageObserver';
@@ -33,6 +34,11 @@ const Sidebar: React.FC<SidebarProps> = ({
33
34
  activePages,
34
35
  evaluatedPagesVisibility,
35
36
  });
37
+ const layout = useLayoutType();
38
+ const responsiveSize = useMemo(() => {
39
+ const isTablet = layout === 'tablet';
40
+ return isTablet ? 'lg' : 'sm';
41
+ }, [layout]);
36
42
 
37
43
  return (
38
44
  <div className={styles.sidebar}>
@@ -51,7 +57,7 @@ const Sidebar: React.FC<SidebarProps> = ({
51
57
 
52
58
  <div className={styles.sideNavActions}>
53
59
  {sessionMode !== 'view' && (
54
- <Button className={styles.saveButton} disabled={isFormSubmitting} type="submit">
60
+ <Button className={styles.saveButton} disabled={isFormSubmitting} type="submit" size={responsiveSize}>
55
61
  {isFormSubmitting ? (
56
62
  <InlineLoading description={t('submitting', 'Submitting') + '...'} />
57
63
  ) : (
@@ -68,7 +74,8 @@ const Sidebar: React.FC<SidebarProps> = ({
68
74
  onCancel?.();
69
75
  handleClose?.();
70
76
  hideFormCollapseToggle();
71
- }}>
77
+ }}
78
+ size={responsiveSize}>
72
79
  {sessionMode === 'view' ? t('close', 'Close') : t('cancel', 'Cancel')}
73
80
  </Button>
74
81
  </div>
@@ -87,12 +94,14 @@ function PageLink({ page, currentActivePage, pagesWithErrors, requestPage }: Pag
87
94
  const { t } = useTranslation();
88
95
  const isActive = page.id === currentActivePage;
89
96
  const hasError = pagesWithErrors.includes(page.id);
97
+ const isTablet = useLayoutType() === 'tablet';
90
98
  return (
91
99
  <div
92
100
  className={classNames(styles.pageLink, {
93
101
  [styles.activePage]: isActive && !hasError,
94
102
  [styles.errorPage]: hasError && !isActive,
95
103
  [styles.activeErrorPage]: hasError && isActive,
104
+ [styles.pageLinkTablet]: isTablet,
96
105
  })}>
97
106
  <button
98
107
  onClick={(e) => {
@@ -6,12 +6,16 @@
6
6
  border-left: 0.5rem solid colors.$teal-20;
7
7
  display: flex;
8
8
  align-items: center;
9
- height: 3rem;
9
+ height: layout.$spacing-07;
10
10
  padding: 0.25rem 0.5rem;
11
11
  background-color: colors.$white;
12
12
  margin: 0 0 0.063rem;
13
13
  }
14
14
 
15
+ .pageLinkTablet {
16
+ height: layout.$spacing-09;
17
+ }
18
+
15
19
  .pageLink button {
16
20
  @include type.type-style('body-01');
17
21
  font-family: inherit;
@@ -74,21 +74,23 @@ const FormEngine = ({
74
74
  return patient && workspaceSize === 'ultra-wide' && mode !== 'embedded-view';
75
75
  }, [patient, mode, workspaceSize]);
76
76
 
77
- const showButtonSet = useMemo(() => {
77
+ const isFormWorkspaceTooNarrow = useMemo(() => ['narrow'].includes(workspaceSize), [workspaceSize]);
78
+
79
+ const showBottomButtonSet = useMemo(() => {
78
80
  if (mode === 'embedded-view' || isLoadingDependencies || hasMultiplePages === null) {
79
81
  return false;
80
82
  }
81
83
 
82
- return ['narrow', 'wider'].includes(workspaceSize) || !hasMultiplePages;
83
- }, [mode, workspaceSize, isLoadingDependencies, hasMultiplePages]);
84
+ return isFormWorkspaceTooNarrow || !hasMultiplePages;
85
+ }, [mode, isFormWorkspaceTooNarrow, isLoadingDependencies, hasMultiplePages]);
84
86
 
85
87
  const showSidebar = useMemo(() => {
86
88
  if (mode === 'embedded-view' || isLoadingDependencies || hasMultiplePages === null) {
87
89
  return false;
88
90
  }
89
91
 
90
- return ['extra-wide', 'ultra-wide'].includes(workspaceSize) && hasMultiplePages;
91
- }, [workspaceSize, isLoadingDependencies, hasMultiplePages]);
92
+ return !isFormWorkspaceTooNarrow && hasMultiplePages;
93
+ }, [isFormWorkspaceTooNarrow, isLoadingDependencies, hasMultiplePages]);
92
94
 
93
95
  useEffect(() => {
94
96
  reportError(formError, t('errorLoadingFormSchema', 'Error loading form schema'));
@@ -165,7 +167,7 @@ const FormEngine = ({
165
167
  setIsLoadingFormDependencies={setIsLoadingDependencies}
166
168
  />
167
169
  </div>
168
- {showButtonSet && (
170
+ {showBottomButtonSet && (
169
171
  <ButtonSet className={styles.minifiedButtons}>
170
172
  <Button
171
173
  kind="secondary"