@openmrs/esm-form-engine-lib 3.1.3-pre.1744 → 3.1.3-pre.1750

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/README.md CHANGED
@@ -146,6 +146,26 @@ You could also optionally proxy to a different backend where your forms are host
146
146
  yarn start --sources packages/esm-form-engine-app --backend https://link-to-my-backend.com
147
147
  ```
148
148
 
149
+ #### Troubleshooting linking issues
150
+
151
+ You might run into dependency version mismatches when attempting to link the library to the consuming frontend module. `@carbon/react` is a common culprit. If you see an error like this in your terminal after running `yarn link`:
152
+
153
+ ```sh
154
+ @carbon/react@npm:1.74.0 [5ffd1] conflicts with parent dependency @carbon/react@npm:1.60.3 [faad]
155
+ ```
156
+
157
+ That's because the consuming frontend module is using a different version of `@carbon/react` than the Form Engine Lib.
158
+
159
+ To resolve this, you set a `resolutions` field in your consuming frontend module's root `package.json` file to force the use of the same version of `@carbon/react` in the Form Engine Lib.
160
+
161
+ ```json
162
+ "resolutions": {
163
+ "@carbon/react": "1.60.3"
164
+ }
165
+ ```
166
+
167
+ Once you've added the `resolutions` field, you'll need to run `yarn` again to install the dependencies. After that, you should be able to link the library to the consuming frontend module and run the consuming frontend module without any issues.
168
+
149
169
  ### Production
150
170
 
151
171
  Note that in addition to this library, other form engine alternatives exist within the O3 ecosystem, including:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "3.1.3-pre.1744",
3
+ "version": "3.1.3-pre.1750",
4
4
  "description": "React Form Engine for O3",
5
5
  "browser": "dist/openmrs-esm-form-engine-lib.js",
6
6
  "main": "src/index.ts",
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { type FormFieldInputProps } from '../../types';
4
4
  import styles from './obs-group.scss';
5
- import { FormFieldRenderer, isGroupField } from '../renderer/field/form-field-renderer.component';
5
+ import { ErrorFallback, FormFieldRenderer, isGroupField } from '../renderer/field/form-field-renderer.component';
6
6
  import { useFormProviderContext } from '../../provider/form-provider';
7
7
  import { FormGroup } from '@carbon/react';
8
8
  import { useTranslation } from 'react-i18next';
@@ -18,6 +18,11 @@ export const ObsGroup: React.FC<FormFieldInputProps> = ({ field, ...restProps })
18
18
  .filter((child) => !child.isHidden)
19
19
  .map((child, index) => {
20
20
  const key = `${child.id}_${index}`;
21
+ if (child.id === field.id) {
22
+ return (
23
+ <ErrorFallback error={new Error('ObsGroup child has same id as parent question')}/>
24
+ );
25
+ }
21
26
 
22
27
  if (child.type === 'obsGroup' && isGroupField(child.questionOptions.rendering)) {
23
28
  return (
@@ -215,7 +215,7 @@ export const FormFieldRenderer = ({ fieldId, valueAdapter, repeatOptions }: Form
215
215
  );
216
216
  };
217
217
 
218
- function ErrorFallback({ error }) {
218
+ export function ErrorFallback({ error }) {
219
219
  const { t } = useTranslation();
220
220
  return (
221
221
  <ToastNotification