@openmrs/esm-react-utils 5.0.3-pre.868 → 5.0.3-pre.873

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.0.3-pre.868",
3
+ "version": "5.0.3-pre.873",
4
4
  "license": "MPL-2.0",
5
5
  "description": "React utilities for OpenMRS.",
6
6
  "browser": "dist/openmrs-esm-react-utils.js",
@@ -56,11 +56,11 @@
56
56
  "react-i18next": "11.x"
57
57
  },
58
58
  "devDependencies": {
59
- "@openmrs/esm-api": "^5.0.3-pre.868",
60
- "@openmrs/esm-config": "^5.0.3-pre.868",
61
- "@openmrs/esm-error-handling": "^5.0.3-pre.868",
62
- "@openmrs/esm-extensions": "^5.0.3-pre.868",
63
- "@openmrs/esm-globals": "^5.0.3-pre.868",
59
+ "@openmrs/esm-api": "^5.0.3-pre.873",
60
+ "@openmrs/esm-config": "^5.0.3-pre.873",
61
+ "@openmrs/esm-error-handling": "^5.0.3-pre.873",
62
+ "@openmrs/esm-extensions": "^5.0.3-pre.873",
63
+ "@openmrs/esm-globals": "^5.0.3-pre.873",
64
64
  "dayjs": "^1.10.8",
65
65
  "i18next": "^19.6.0",
66
66
  "react": "^18.1.0",
@@ -69,5 +69,5 @@
69
69
  "rxjs": "^6.5.3",
70
70
  "webpack": "^5.88.0"
71
71
  },
72
- "gitHead": "ecf8f0ad00fcbf4e16965d5368311ef70585fa99"
72
+ "gitHead": "bbb193d3ded0e88c14054db8500d9073c6a87d08"
73
73
  }
@@ -1,13 +1,13 @@
1
1
  import React, { useEffect, useRef } from "react";
2
- import _i18n from "i18next";
3
2
  import { I18nextProvider } from "react-i18next";
3
+ import type {} from "@openmrs/esm-globals";
4
4
  import {
5
5
  ComponentConfig,
6
6
  ComponentContext,
7
7
  ExtensionData,
8
8
  } from "./ComponentContext";
9
9
 
10
- const i18n = (_i18n as any).default || _i18n;
10
+ let i18n: typeof window.i18next = window.i18next;
11
11
 
12
12
  const defaultOpts = {
13
13
  strictMode: true,
@@ -33,7 +33,8 @@ const I18nextLoadNamespace: React.FC<I18nextLoadNamespaceProps> = (props) => {
33
33
  throw loadNamespaceErrRef.current;
34
34
  }
35
35
 
36
- if (!i18n.hasLoadedNamespace(props.ns)) {
36
+ // FIXME hasLoadedNamespace() is part of the API but not the current types
37
+ if (!(i18n as any).hasLoadedNamespace(props.ns)) {
37
38
  const timeoutId = setTimeout(() => {
38
39
  console.warn(
39
40
  `openmrsComponentDecorator: the React suspense promise for i18next.loadNamespaces(['${props.ns}']) did not resolve nor reject after three seconds. This could mean you have multiple versions of i18next and haven't made i18next a webpack external in all projects.`
@@ -70,6 +71,10 @@ export interface OpenmrsReactComponentState {
70
71
  }
71
72
 
72
73
  export function openmrsComponentDecorator(userOpts: ComponentDecoratorOptions) {
74
+ if (typeof i18n === "undefined" && typeof window.i18next !== "undefined") {
75
+ i18n = window.i18next;
76
+ }
77
+
73
78
  if (
74
79
  typeof userOpts !== "object" ||
75
80
  typeof userOpts.featureName !== "string" ||