@openmrs/esm-form-engine-lib 3.1.3-pre.1729 → 3.1.3-pre.1738

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/.eslintrc CHANGED
@@ -8,9 +8,10 @@
8
8
  "project": true,
9
9
  "tsconfigRootDir": "__dirname"
10
10
  },
11
- "plugins": ["@typescript-eslint", "react-hooks"],
11
+ "plugins": ["@typescript-eslint", "import", "react-hooks"],
12
12
  "root": true,
13
13
  "rules": {
14
+ "import/no-duplicates": "error",
14
15
  "react-hooks/rules-of-hooks": "error",
15
16
  "@typescript-eslint/ban-types": "off",
16
17
  "@typescript-eslint/no-explicit-any": "off",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "3.1.3-pre.1729",
3
+ "version": "3.1.3-pre.1738",
4
4
  "description": "React Form Engine for O3",
5
5
  "browser": "dist/openmrs-esm-form-engine-lib.js",
6
6
  "main": "src/index.ts",
@@ -70,6 +70,7 @@
70
70
  "css-loader": "^6.11.0",
71
71
  "dayjs": "^1.11.11",
72
72
  "eslint": "^8.57.0",
73
+ "eslint-plugin-import": "^2.31.0",
73
74
  "eslint-plugin-jsx-a11y": "^6.8.0",
74
75
  "eslint-plugin-react-hooks": "^4.6.2",
75
76
  "fork-ts-checker-webpack-plugin": "^6.5.3",
@@ -1,7 +1,12 @@
1
1
  import { type OpenmrsResource } from '@openmrs/esm-framework';
2
- import { type OpenmrsObs, type FormFieldValueAdapter, type FormProcessorContextProps } from '../types';
2
+ import {
3
+ type OpenmrsObs,
4
+ type FormFieldValueAdapter,
5
+ type FormProcessorContextProps,
6
+ type OpenmrsEncounter,
7
+ type FormField,
8
+ } from '../types';
3
9
  import { type FormContextProps } from '../provider/form-provider';
4
- import { type OpenmrsEncounter, type FormField } from '../types';
5
10
  import { gracefullySetSubmission } from '../utils/common-utils';
6
11
  import { isEmpty } from '../validators/form-validator';
7
12
  import { isTrue } from '../utils/boolean-utils';
@@ -1,15 +1,25 @@
1
- import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
1
+ import { openmrsFetch, OpenmrsResource, restBaseUrl } from '@openmrs/esm-framework';
2
2
  import { BaseOpenMRSDataSource } from './data-source';
3
3
 
4
4
  export class SelectConceptAnswersDatasource extends BaseOpenMRSDataSource {
5
5
  constructor() {
6
- super(`${restBaseUrl}/concept/conceptUuid?v=custom:(uuid,setMembers:(uuid,display),answers:(uuid,display))`);
6
+ super(
7
+ `${restBaseUrl}/concept/:conceptUuid?v=custom:(uuid,display,setMembers:(uuid,display),answers:(uuid,display))`,
8
+ );
9
+ }
10
+
11
+ fetchSingleItem(uuid: string): Promise<OpenmrsResource | null> {
12
+ return openmrsFetch(this.buildUrl(uuid)).then(({ data }) => data);
7
13
  }
8
14
 
9
15
  fetchData(searchTerm: string, config?: Record<string, any>): Promise<any[]> {
10
- const apiUrl = this.url.replace('conceptUuid', config.referencedValue || config.concept);
16
+ const apiUrl = this.buildUrl(config.referencedValue || config.concept);
11
17
  return openmrsFetch(apiUrl).then(({ data }) => {
12
18
  return data['setMembers'].length ? data['setMembers'] : data['answers'];
13
19
  });
14
20
  }
21
+
22
+ private buildUrl(conceptUuid: string): string {
23
+ return this.url.replace(':conceptUuid', conceptUuid);
24
+ }
15
25
  }
@@ -1,6 +1,5 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { type FormField } from '../types';
3
- import { type FormFieldValueAdapter } from '../types';
2
+ import { type FormField, type FormFieldValueAdapter } from '../types';
4
3
  import { getRegisteredFieldValueAdapter } from '../registry/registry';
5
4
 
6
5
  export const useFormFieldValueAdapters = (fields: FormField[]) => {
@@ -1,7 +1,6 @@
1
1
  import { type OpenmrsResource } from '@openmrs/esm-framework';
2
2
  import { type FormContextProps } from '../provider/form-provider';
3
- import { type ValueAndDisplay, type FormField, type FormSchema } from '../types';
4
- import { type FormProcessorContextProps } from '../types';
3
+ import { type ValueAndDisplay, type FormField, type FormSchema, type FormProcessorContextProps } from '../types';
5
4
 
6
5
  export type FormProcessorConstructor = new (...args: ConstructorParameters<typeof FormProcessor>) => FormProcessor;
7
6