@openmrs/esm-react-utils 5.3.3-pre.1296 → 5.3.3-pre.1301

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.1296",
3
+ "version": "5.3.3-pre.1301",
4
4
  "license": "MPL-2.0",
5
5
  "description": "React utilities for OpenMRS.",
6
6
  "browser": "dist/openmrs-esm-react-utils.js",
@@ -57,12 +57,12 @@
57
57
  "swr": "2.x"
58
58
  },
59
59
  "devDependencies": {
60
- "@openmrs/esm-api": "5.3.3-pre.1296",
61
- "@openmrs/esm-config": "5.3.3-pre.1296",
62
- "@openmrs/esm-error-handling": "5.3.3-pre.1296",
63
- "@openmrs/esm-extensions": "5.3.3-pre.1296",
64
- "@openmrs/esm-feature-flags": "5.3.3-pre.1296",
65
- "@openmrs/esm-globals": "5.3.3-pre.1296",
60
+ "@openmrs/esm-api": "5.3.3-pre.1301",
61
+ "@openmrs/esm-config": "5.3.3-pre.1301",
62
+ "@openmrs/esm-error-handling": "5.3.3-pre.1301",
63
+ "@openmrs/esm-extensions": "5.3.3-pre.1301",
64
+ "@openmrs/esm-feature-flags": "5.3.3-pre.1301",
65
+ "@openmrs/esm-globals": "5.3.3-pre.1301",
66
66
  "dayjs": "^1.10.8",
67
67
  "i18next": "^21.10.0",
68
68
  "react": "^18.1.0",
@@ -1,6 +1,7 @@
1
1
  /** @module @category Navigation */
2
2
  import React, { type MouseEvent, type AnchorHTMLAttributes, type PropsWithChildren } from 'react';
3
- import { navigate, interpolateUrl, TemplateParams } from '@openmrs/esm-config';
3
+ import type { TemplateParams } from '@openmrs/esm-config';
4
+ import { navigate, interpolateUrl } from '@openmrs/esm-config';
4
5
 
5
6
  function handleClick(event: MouseEvent, to: string, templateParams?: TemplateParams) {
6
7
  if (!event.metaKey && !event.ctrlKey && !event.shiftKey && event.button == 0) {
package/src/Extension.tsx CHANGED
@@ -37,7 +37,6 @@ export const Extension: React.FC<ExtensionProps> = ({ state, children, wrap, ...
37
37
  );
38
38
  }
39
39
  // we only warn when component mounts
40
- // eslint-disable-next-line react-hooks/exhaustive-deps
41
40
  }, []);
42
41
 
43
42
  const ref = useCallback(
@@ -98,7 +97,6 @@ export const Extension: React.FC<ExtensionProps> = ({ state, children, wrap, ...
98
97
 
99
98
  // we intentionally do not re-run this hook if state gets updated
100
99
  // state updates are handled in the next useEffect hook
101
- // eslint-disable-next-line react-hooks/exhaustive-deps
102
100
  }, [extension?.extensionSlotName, extension?.extensionId, extension?.extensionSlotModuleName, domElement]);
103
101
 
104
102
  useEffect(() => {
@@ -1,5 +1,6 @@
1
1
  /** @module @category API */
2
- import { getCurrentUser, LoggedInUser, userHasAccess } from '@openmrs/esm-api';
2
+ import type { LoggedInUser } from '@openmrs/esm-api';
3
+ import { getCurrentUser, userHasAccess } from '@openmrs/esm-api';
3
4
  import React, { useEffect, useState } from 'react';
4
5
 
5
6
  export interface UserHasAccessProps {
@@ -1,8 +1,10 @@
1
1
  /** @module @category Framework */
2
- import React, { ComponentType } from 'react';
2
+ import type { ComponentType } from 'react';
3
+ import React from 'react';
3
4
  import ReactDOMClient from 'react-dom/client';
4
5
  import singleSpaReact from 'single-spa-react';
5
- import { openmrsComponentDecorator, ComponentDecoratorOptions } from './openmrsComponentDecorator';
6
+ import type { ComponentDecoratorOptions } from './openmrsComponentDecorator';
7
+ import { openmrsComponentDecorator } from './openmrsComponentDecorator';
6
8
 
7
9
  export function getLifecycle<T>(Component: ComponentType<T>, options: ComponentDecoratorOptions) {
8
10
  return singleSpaReact({
@@ -1,7 +1,8 @@
1
1
  import React, { type ComponentType, Suspense } from 'react';
2
2
  import { I18nextProvider } from 'react-i18next';
3
3
  import type {} from '@openmrs/esm-globals';
4
- import { ComponentConfig, ComponentContext, ExtensionData } from './ComponentContext';
4
+ import type { ComponentConfig, ExtensionData } from './ComponentContext';
5
+ import { ComponentContext } from './ComponentContext';
5
6
 
6
7
  const defaultOpts = {
7
8
  strictMode: true,
@@ -1,5 +1,5 @@
1
1
  import '@testing-library/jest-dom';
2
2
 
3
- window.openmrsBase = '/openmrs';
4
- window.spaBase = '/spa';
5
- window.getOpenmrsSpaBase = () => '/openmrs/spa/';
3
+ global.window.openmrsBase = '/openmrs';
4
+ global.window.spaBase = '/spa';
5
+ global.window.getOpenmrsSpaBase = () => '/openmrs/spa/';
@@ -1,6 +1,7 @@
1
1
  /** @module @category Extension */
2
2
  import { useEffect, useState } from 'react';
3
- import { AssignedExtension, ExtensionStore, getExtensionStore } from '@openmrs/esm-extensions';
3
+ import type { AssignedExtension, ExtensionStore } from '@openmrs/esm-extensions';
4
+ import { getExtensionStore } from '@openmrs/esm-extensions';
4
5
  import isEqual from 'lodash-es/isEqual';
5
6
 
6
7
  /**
package/src/useConfig.ts CHANGED
@@ -1,16 +1,11 @@
1
1
  /** @module @category Config */
2
2
  import { useContext, useEffect, useMemo, useState } from 'react';
3
- import {
4
- getConfigStore,
5
- getExtensionsConfigStore,
6
- ConfigStore,
7
- ConfigObject,
8
- ExtensionsConfigStore,
9
- getExtensionConfigFromStore,
10
- } from '@openmrs/esm-config';
3
+ import type { ConfigStore, ConfigObject, ExtensionsConfigStore } from '@openmrs/esm-config';
4
+ import { getConfigStore, getExtensionsConfigStore, getExtensionConfigFromStore } from '@openmrs/esm-config';
11
5
  import type { StoreApi } from 'zustand';
12
6
  import isEqual from 'lodash-es/isEqual';
13
- import { ComponentContext, ExtensionData } from './ComponentContext';
7
+ import type { ExtensionData } from './ComponentContext';
8
+ import { ComponentContext } from './ComponentContext';
14
9
 
15
10
  const promises: Record<string, Promise<ConfigObject>> = {};
16
11
  const errorMessage = `No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
@@ -1,6 +1,7 @@
1
1
  /** @module @category Extension */
2
2
  import { useMemo } from 'react';
3
- import { ConnectedExtension, getConnectedExtensions } from '@openmrs/esm-extensions';
3
+ import type { ConnectedExtension } from '@openmrs/esm-extensions';
4
+ import { getConnectedExtensions } from '@openmrs/esm-extensions';
4
5
  import { useConnectivity } from './useConnectivity';
5
6
  import { useAssignedExtensions } from './useAssignedExtensions';
6
7
  import { useStore } from './useStore';
@@ -1,4 +1,5 @@
1
- import { ExtensionInternalStore, getExtensionInternalStore } from '@openmrs/esm-extensions';
1
+ import type { ExtensionInternalStore } from '@openmrs/esm-extensions';
2
+ import { getExtensionInternalStore } from '@openmrs/esm-extensions';
2
3
  import { createUseStore } from './useStore';
3
4
 
4
5
  /** @internal
@@ -1,5 +1,5 @@
1
1
  /** @module @category Extension */
2
- import { ExtensionMeta } from '@openmrs/esm-extensions';
2
+ import type { ExtensionMeta } from '@openmrs/esm-extensions';
3
3
  import { useMemo } from 'react';
4
4
  import { useConnectedExtensions } from './useConnectedExtensions';
5
5
 
@@ -1,5 +1,6 @@
1
1
  /** @module @category Extension */
2
- import { ExtensionStore, getExtensionStore } from '@openmrs/esm-extensions';
2
+ import type { ExtensionStore } from '@openmrs/esm-extensions';
3
+ import { getExtensionStore } from '@openmrs/esm-extensions';
3
4
  import { createUseStore } from './useStore';
4
5
 
5
6
  export const useExtensionStore = createUseStore<ExtensionStore>(getExtensionStore());
@@ -1,5 +1,6 @@
1
1
  /** @module @category API */
2
- import { getLocations, Location } from '@openmrs/esm-api';
2
+ import type { Location } from '@openmrs/esm-api';
3
+ import { getLocations } from '@openmrs/esm-api';
3
4
  import { useState, useEffect } from 'react';
4
5
 
5
6
  export function useLocations(tagUuidOrName: string | null = null) {
@@ -1,6 +1,7 @@
1
1
  /** @module @category Utility */
2
2
  import { useCallback, useMemo } from 'react';
3
- import useSWR, { SWRConfiguration } from 'swr';
3
+ import type { SWRConfiguration } from 'swr';
4
+ import useSWR from 'swr';
4
5
  import { type FetchConfig, openmrsFetch } from '@openmrs/esm-api';
5
6
  import useAbortController from './useAbortController';
6
7
 
package/src/usePatient.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /** @module @category API */
2
2
  import { useEffect, useReducer } from 'react';
3
- import { fetchCurrentPatient, PatientUuid } from '@openmrs/esm-api';
3
+ import type { PatientUuid } from '@openmrs/esm-api';
4
+ import { fetchCurrentPatient } from '@openmrs/esm-api';
4
5
 
5
6
  export type NullablePatient = fhir.Patient | null;
6
7
 
package/src/useSession.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** @module @category API */
2
- import { getSessionStore, Session } from '@openmrs/esm-api';
2
+ import type { Session } from '@openmrs/esm-api';
3
+ import { getSessionStore } from '@openmrs/esm-api';
3
4
  import { useState, useEffect, useRef } from 'react';
4
5
 
5
6
  let promise: undefined | Promise<Session>;
package/src/useStore.ts CHANGED
@@ -17,14 +17,9 @@ function bindActions<T>(store: StoreApi<T>, actions: Actions<T>): BoundActions {
17
17
  const bound = {};
18
18
 
19
19
  for (let i in actions) {
20
- bound[i] = function () {
21
- const args = arguments;
20
+ bound[i] = function (...args) {
22
21
  store.setState((state) => {
23
- let _args = [state];
24
- for (let i = 0; i < args.length; i++) {
25
- _args.push(args[i]);
26
- }
27
-
22
+ let _args = [state, ...args];
28
23
  return actions[i](..._args);
29
24
  });
30
25
  };
package/src/useVisit.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** @module @category API */
2
- import { defaultVisitCustomRepresentation, getVisitStore, openmrsFetch, Visit } from '@openmrs/esm-api';
2
+ import type { Visit } from '@openmrs/esm-api';
3
+ import { defaultVisitCustomRepresentation, getVisitStore, openmrsFetch } from '@openmrs/esm-api';
3
4
  import useSWR from 'swr';
4
5
  import dayjs from 'dayjs';
5
6
  import isToday from 'dayjs/plugin/isToday';
@@ -1,5 +1,6 @@
1
1
  /** @module @category API */
2
- import { getVisitTypes, VisitType } from '@openmrs/esm-api';
2
+ import type { VisitType } from '@openmrs/esm-api';
3
+ import { getVisitTypes } from '@openmrs/esm-api';
3
4
  import { useEffect, useState } from 'react';
4
5
 
5
6
  export function useVisitTypes() {