@openmrs/esm-react-utils 5.3.3-pre.1383 → 5.3.3-pre.1384
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-react-utils",
|
|
3
|
-
"version": "5.3.3-pre.
|
|
3
|
+
"version": "5.3.3-pre.1384",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "React utilities for OpenMRS.",
|
|
6
6
|
"browser": "dist/openmrs-esm-react-utils.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"lodash-es": "^4.17.21",
|
|
43
|
-
"single-spa-react": "
|
|
43
|
+
"single-spa-react": "^6.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@openmrs/esm-api": "5.x",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"swr": "2.x"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@openmrs/esm-api": "5.3.3-pre.
|
|
62
|
-
"@openmrs/esm-config": "5.3.3-pre.
|
|
63
|
-
"@openmrs/esm-error-handling": "5.3.3-pre.
|
|
64
|
-
"@openmrs/esm-extensions": "5.3.3-pre.
|
|
65
|
-
"@openmrs/esm-feature-flags": "5.3.3-pre.
|
|
66
|
-
"@openmrs/esm-globals": "5.3.3-pre.
|
|
67
|
-
"@openmrs/esm-navigation": "5.3.3-pre.
|
|
61
|
+
"@openmrs/esm-api": "5.3.3-pre.1384",
|
|
62
|
+
"@openmrs/esm-config": "5.3.3-pre.1384",
|
|
63
|
+
"@openmrs/esm-error-handling": "5.3.3-pre.1384",
|
|
64
|
+
"@openmrs/esm-extensions": "5.3.3-pre.1384",
|
|
65
|
+
"@openmrs/esm-feature-flags": "5.3.3-pre.1384",
|
|
66
|
+
"@openmrs/esm-globals": "5.3.3-pre.1384",
|
|
67
|
+
"@openmrs/esm-navigation": "5.3.3-pre.1384",
|
|
68
68
|
"dayjs": "^1.10.8",
|
|
69
69
|
"i18next": "^21.10.0",
|
|
70
70
|
"react": "^18.1.0",
|
package/src/getLifecycle.ts
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import ReactDOMClient from 'react-dom/client';
|
|
5
|
-
import
|
|
5
|
+
import type { AppProps } from 'single-spa';
|
|
6
|
+
import singleSpaReact, { type ReactAppOrParcel } from 'single-spa-react';
|
|
6
7
|
import type { ComponentDecoratorOptions } from './openmrsComponentDecorator';
|
|
7
8
|
import { openmrsComponentDecorator } from './openmrsComponentDecorator';
|
|
8
9
|
|
|
9
10
|
export function getLifecycle<T>(Component: ComponentType<T>, options: ComponentDecoratorOptions) {
|
|
10
|
-
return singleSpaReact({
|
|
11
|
+
return singleSpaReact<T>({
|
|
11
12
|
React,
|
|
12
13
|
ReactDOMClient,
|
|
13
|
-
rootComponent: openmrsComponentDecorator(options)(Component)
|
|
14
|
+
rootComponent: openmrsComponentDecorator<T>(options)(Component) as ComponentType<T & AppProps>,
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -27,7 +27,7 @@ export interface OpenmrsReactComponentState {
|
|
|
27
27
|
config: ComponentConfig;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function openmrsComponentDecorator(userOpts: ComponentDecoratorOptions) {
|
|
30
|
+
export function openmrsComponentDecorator<T>(userOpts: ComponentDecoratorOptions) {
|
|
31
31
|
if (
|
|
32
32
|
typeof userOpts !== 'object' ||
|
|
33
33
|
typeof userOpts.featureName !== 'string' ||
|
|
@@ -38,11 +38,14 @@ export function openmrsComponentDecorator(userOpts: ComponentDecoratorOptions) {
|
|
|
38
38
|
|
|
39
39
|
const opts = Object.assign({}, defaultOpts, userOpts);
|
|
40
40
|
|
|
41
|
-
return function decorateComponent(Comp: ComponentType<
|
|
42
|
-
return class OpenmrsReactComponent extends React.Component<
|
|
41
|
+
return function decorateComponent(Comp: ComponentType<T>): ComponentType<T> {
|
|
42
|
+
return class OpenmrsReactComponent extends React.Component<
|
|
43
|
+
OpenmrsReactComponentProps & T,
|
|
44
|
+
OpenmrsReactComponentState
|
|
45
|
+
> {
|
|
43
46
|
static displayName = `OpenmrsReactComponent(${opts.featureName})`;
|
|
44
47
|
|
|
45
|
-
constructor(props: OpenmrsReactComponentProps) {
|
|
48
|
+
constructor(props: OpenmrsReactComponentProps & T) {
|
|
46
49
|
super(props);
|
|
47
50
|
this.state = {
|
|
48
51
|
caughtError: null,
|