@openmrs/esm-react-utils 5.3.3-pre.1240 → 5.3.3-pre.1247

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.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/__mocks__/openmrs-esm-state.mock.ts +8 -20
  3. package/dist/openmrs-esm-react-utils.js.map +1 -1
  4. package/jest.config.js +9 -11
  5. package/package.json +7 -7
  6. package/src/ComponentContext.ts +2 -2
  7. package/src/ConfigurableLink.test.tsx +19 -23
  8. package/src/ConfigurableLink.tsx +5 -19
  9. package/src/Extension.tsx +36 -76
  10. package/src/ExtensionSlot.tsx +15 -24
  11. package/src/UserHasAccess.tsx +3 -7
  12. package/src/extensions.test.tsx +100 -179
  13. package/src/getLifecycle.ts +8 -18
  14. package/src/index.ts +31 -31
  15. package/src/openmrsComponentDecorator.test.tsx +12 -12
  16. package/src/openmrsComponentDecorator.tsx +12 -26
  17. package/src/public.ts +27 -27
  18. package/src/setup-tests.js +4 -4
  19. package/src/useAbortController.test.tsx +8 -8
  20. package/src/useAbortController.ts +1 -1
  21. package/src/useAssignedExtensionIds.ts +4 -5
  22. package/src/useAssignedExtensions.ts +3 -7
  23. package/src/useBodyScrollLock.ts +2 -2
  24. package/src/useConfig.test.tsx +96 -112
  25. package/src/useConfig.ts +15 -43
  26. package/src/useConnectedExtensions.ts +8 -17
  27. package/src/useConnectivity.ts +3 -6
  28. package/src/useDebounce.ts +1 -1
  29. package/src/useExtensionInternalStore.ts +3 -8
  30. package/src/useExtensionSlot.ts +5 -7
  31. package/src/useExtensionSlotMeta.ts +5 -11
  32. package/src/useExtensionStore.ts +3 -5
  33. package/src/useFeatureFlag.ts +4 -4
  34. package/src/useForceUpdate.ts +1 -1
  35. package/src/useLayoutType.ts +12 -13
  36. package/src/useLocations.tsx +3 -3
  37. package/src/useOnClickOutside.test.tsx +10 -10
  38. package/src/useOnClickOutside.ts +2 -5
  39. package/src/useOpenmrsSWR.ts +9 -9
  40. package/src/usePagination.ts +6 -18
  41. package/src/usePatient.ts +9 -13
  42. package/src/useSession.test.tsx +35 -43
  43. package/src/useSession.ts +9 -13
  44. package/src/useStore.test.ts +11 -13
  45. package/src/useStore.ts +10 -31
  46. package/src/useVisit.ts +14 -37
  47. package/src/useVisitTypes.ts +3 -3
  48. package/webpack.config.js +14 -14
@@ -1,4 +1,4 @@
1
- @openmrs/esm-react-utils:build: cache hit, replaying output 3ec999ec0646404d
1
+ @openmrs/esm-react-utils:build: cache hit, replaying output 5c5fc6f101db4b6d
2
2
  @openmrs/esm-react-utils:build: Browserslist: caniuse-lite is outdated. Please run:
3
3
  @openmrs/esm-react-utils:build:  npx update-browserslist-db@latest
4
4
  @openmrs/esm-react-utils:build:  Why you should do it regularly: https://github.com/browserslist/update-db#readme
@@ -14,4 +14,4 @@
14
14
  @openmrs/esm-react-utils:build:  external "@openmrs/esm-extensions" 42 bytes [built] [code generated]
15
15
  @openmrs/esm-react-utils:build:  + 2 modules
16
16
  @openmrs/esm-react-utils:build:  + 5 modules
17
- @openmrs/esm-react-utils:build: webpack 5.88.0 compiled successfully in 4674 ms
17
+ @openmrs/esm-react-utils:build: webpack 5.88.0 compiled successfully in 4619 ms
@@ -1,4 +1,4 @@
1
- import { createStore, StoreApi } from "zustand";
1
+ import { createStore, StoreApi } from 'zustand';
2
2
 
3
3
  interface StoreEntity {
4
4
  value: StoreApi<any>;
@@ -13,17 +13,12 @@ const availableStores: Record<string, StoreEntity> = {};
13
13
 
14
14
  export const mockStores = availableStores;
15
15
 
16
- export function createGlobalStore<T>(
17
- name: string,
18
- initialState: T
19
- ): StoreApi<T> {
16
+ export function createGlobalStore<T>(name: string, initialState: T): StoreApi<T> {
20
17
  const available = availableStores[name];
21
18
 
22
19
  if (available) {
23
20
  if (available.active) {
24
- console.error(
25
- "Cannot override an existing store. Make sure that stores are only created once."
26
- );
21
+ console.error('Cannot override an existing store. Make sure that stores are only created once.');
27
22
  } else {
28
23
  available.value.setState(initialState, true);
29
24
  }
@@ -43,10 +38,7 @@ export function createGlobalStore<T>(
43
38
  }
44
39
  }
45
40
 
46
- export function getGlobalStore<T>(
47
- name: string,
48
- fallbackState?: T
49
- ): StoreApi<T> {
41
+ export function getGlobalStore<T>(name: string, fallbackState?: T): StoreApi<T> {
50
42
  const available = availableStores[name];
51
43
 
52
44
  if (!available) {
@@ -62,11 +54,7 @@ export function getGlobalStore<T>(
62
54
  return instrumentedStore(name, available.value);
63
55
  }
64
56
 
65
- export function subscribeTo<T, U>(
66
- store: StoreApi<T>,
67
- select: (state: T) => U,
68
- handle: (subState: U) => void
69
- ) {
57
+ export function subscribeTo<T, U>(store: StoreApi<T>, select: (state: T) => U, handle: (subState: U) => void) {
70
58
  let previous = select(store.getState());
71
59
 
72
60
  return store.subscribe((state) => {
@@ -81,9 +69,9 @@ export function subscribeTo<T, U>(
81
69
 
82
70
  function instrumentedStore<T>(name: string, store: StoreApi<T>) {
83
71
  return {
84
- getState: jest.spyOn(store, "getState"),
85
- setState: jest.spyOn(store, "setState"),
86
- subscribe: jest.spyOn(store, "subscribe"),
72
+ getState: jest.spyOn(store, 'getState'),
73
+ setState: jest.spyOn(store, 'setState'),
74
+ subscribe: jest.spyOn(store, 'subscribe'),
87
75
  resetMock: () => store.setState(initialStates[name]),
88
76
  } as any as MockedStore<T>;
89
77
  }