@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.
- package/.turbo/turbo-build.log +2 -2
- package/__mocks__/openmrs-esm-state.mock.ts +8 -20
- package/dist/openmrs-esm-react-utils.js.map +1 -1
- package/jest.config.js +9 -11
- package/package.json +7 -7
- package/src/ComponentContext.ts +2 -2
- package/src/ConfigurableLink.test.tsx +19 -23
- package/src/ConfigurableLink.tsx +5 -19
- package/src/Extension.tsx +36 -76
- package/src/ExtensionSlot.tsx +15 -24
- package/src/UserHasAccess.tsx +3 -7
- package/src/extensions.test.tsx +100 -179
- package/src/getLifecycle.ts +8 -18
- package/src/index.ts +31 -31
- package/src/openmrsComponentDecorator.test.tsx +12 -12
- package/src/openmrsComponentDecorator.tsx +12 -26
- package/src/public.ts +27 -27
- package/src/setup-tests.js +4 -4
- package/src/useAbortController.test.tsx +8 -8
- package/src/useAbortController.ts +1 -1
- package/src/useAssignedExtensionIds.ts +4 -5
- package/src/useAssignedExtensions.ts +3 -7
- package/src/useBodyScrollLock.ts +2 -2
- package/src/useConfig.test.tsx +96 -112
- package/src/useConfig.ts +15 -43
- package/src/useConnectedExtensions.ts +8 -17
- package/src/useConnectivity.ts +3 -6
- package/src/useDebounce.ts +1 -1
- package/src/useExtensionInternalStore.ts +3 -8
- package/src/useExtensionSlot.ts +5 -7
- package/src/useExtensionSlotMeta.ts +5 -11
- package/src/useExtensionStore.ts +3 -5
- package/src/useFeatureFlag.ts +4 -4
- package/src/useForceUpdate.ts +1 -1
- package/src/useLayoutType.ts +12 -13
- package/src/useLocations.tsx +3 -3
- package/src/useOnClickOutside.test.tsx +10 -10
- package/src/useOnClickOutside.ts +2 -5
- package/src/useOpenmrsSWR.ts +9 -9
- package/src/usePagination.ts +6 -18
- package/src/usePatient.ts +9 -13
- package/src/useSession.test.tsx +35 -43
- package/src/useSession.ts +9 -13
- package/src/useStore.test.ts +11 -13
- package/src/useStore.ts +10 -31
- package/src/useVisit.ts +14 -37
- package/src/useVisitTypes.ts +3 -3
- package/webpack.config.js +14 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[32m@openmrs/esm-react-utils:build[0m: cache hit, replaying output [
|
|
1
|
+
[32m@openmrs/esm-react-utils:build[0m: cache hit, replaying output [2m5c5fc6f101db4b6d[0m
|
|
2
2
|
[32m@openmrs/esm-react-utils:build: [0mBrowserslist: caniuse-lite is outdated. Please run:
|
|
3
3
|
[32m@openmrs/esm-react-utils:build: [0m npx update-browserslist-db@latest
|
|
4
4
|
[32m@openmrs/esm-react-utils:build: [0m Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
[32m@openmrs/esm-react-utils:build: [0m [1mexternal "@openmrs/esm-extensions"[39m[22m 42 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
15
15
|
[32m@openmrs/esm-react-utils:build: [0m + 2 modules
|
|
16
16
|
[32m@openmrs/esm-react-utils:build: [0m + 5 modules
|
|
17
|
-
[32m@openmrs/esm-react-utils:build: [0mwebpack 5.88.0 compiled [1m[32msuccessfully[39m[22m in
|
|
17
|
+
[32m@openmrs/esm-react-utils:build: [0mwebpack 5.88.0 compiled [1m[32msuccessfully[39m[22m in 4619 ms
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createStore, StoreApi } from
|
|
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,
|
|
85
|
-
setState: jest.spyOn(store,
|
|
86
|
-
subscribe: jest.spyOn(store,
|
|
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
|
}
|