@openmrs/esm-react-utils 10.0.1-pre.5498 → 10.0.1-pre.5501
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 +1 -1
- package/dist/ExtensionSlot.d.ts.map +1 -1
- package/dist/ExtensionSlot.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/public.d.ts +1 -0
- package/dist/public.d.ts.map +1 -1
- package/dist/public.js +1 -0
- package/dist/useExtensionContext.d.ts +9 -0
- package/dist/useExtensionContext.d.ts.map +1 -0
- package/dist/useExtensionContext.js +11 -0
- package/dist/useRenderableExtensions.d.ts.map +1 -1
- package/dist/useRenderableExtensions.js +2 -1
- package/mock-jest.tsx +4 -1
- package/mock.tsx +4 -1
- package/package.json +23 -23
- package/src/ExtensionSlot.tsx +1 -0
- package/src/index.ts +1 -0
- package/src/public.ts +1 -0
- package/src/useExtensionContext.test.tsx +34 -0
- package/src/useExtensionContext.ts +14 -0
- package/src/useRenderableExtensions.tsx +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionSlot.d.ts","sourceRoot":"","sources":["../src/ExtensionSlot.tsx"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK/F,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC5E;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CA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,EAAE,UAAU,CAAC;IACxD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACnH;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EAAE,iBAAiB,EACvB,iBAAiB,EAAE,uBAAuB,EAC1C,MAAsB,EACtB,QAAQ,EACR,KAAK,EACL,KAAK,EACL,GAAG,QAAQ,EACZ,EAAE,kBAAkB,qBAiDpB"}
|
package/dist/ExtensionSlot.js
CHANGED
|
@@ -71,7 +71,8 @@ function defaultSelect(extensions) {
|
|
|
71
71
|
extension: {
|
|
72
72
|
extensionId: extension.id,
|
|
73
73
|
extensionSlotName: name,
|
|
74
|
-
extensionSlotModuleName
|
|
74
|
+
extensionSlotModuleName,
|
|
75
|
+
extensionMeta: extension.meta
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
}, extensionsFromChildrenFunction?.[i] ?? (typeof children !== 'function' ? children : null) ?? /*#__PURE__*/ React.createElement(Extension, {
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './useConnectivity';
|
|
|
20
20
|
export * from './useDebounce';
|
|
21
21
|
export * from './useDefineAppContext';
|
|
22
22
|
export * from './useEmrConfiguration';
|
|
23
|
+
export * from './useExtensionContext';
|
|
23
24
|
export * from './useExtensionInternalStore';
|
|
24
25
|
export * from './useExtensionSlot';
|
|
25
26
|
export * from './useExtensionSlotMeta';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC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AAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./useConnectivity.js";
|
|
|
20
20
|
export * from "./useDebounce.js";
|
|
21
21
|
export * from "./useDefineAppContext.js";
|
|
22
22
|
export * from "./useEmrConfiguration.js";
|
|
23
|
+
export * from "./useExtensionContext.js";
|
|
23
24
|
export * from "./useExtensionInternalStore.js";
|
|
24
25
|
export * from "./useExtensionSlot.js";
|
|
25
26
|
export * from "./useExtensionSlotMeta.js";
|
package/dist/public.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './useConnectivity';
|
|
|
16
16
|
export * from './useDebounce';
|
|
17
17
|
export * from './useDefineAppContext';
|
|
18
18
|
export * from './useEmrConfiguration';
|
|
19
|
+
export * from './useExtensionContext';
|
|
19
20
|
export * from './useExtensionSlotMeta';
|
|
20
21
|
export * from './useExtensionSlotStore';
|
|
21
22
|
export * from './useExtensionStore';
|
package/dist/public.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../src/public.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,cAAc,iBAAi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qB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/public.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./useConnectivity.js";
|
|
|
16
16
|
export * from "./useDebounce.js";
|
|
17
17
|
export * from "./useDefineAppContext.js";
|
|
18
18
|
export * from "./useEmrConfiguration.js";
|
|
19
|
+
export * from "./useExtensionContext.js";
|
|
19
20
|
export * from "./useExtensionSlotMeta.js";
|
|
20
21
|
export * from "./useExtensionSlotStore.js";
|
|
21
22
|
export * from "./useExtensionStore.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook for a component rendered as an extension to access its extension context: the slot and
|
|
3
|
+
* slot module it is rendered in, its extension ID, and its `meta` from the extension's registration.
|
|
4
|
+
*
|
|
5
|
+
* @returns The extension context, or `undefined` when the calling component is not being rendered
|
|
6
|
+
* as an extension (a page, modal or workspace, say).
|
|
7
|
+
*/
|
|
8
|
+
export declare function useExtensionContext(): import("@openmrs/esm-extensions").ExtensionData | undefined;
|
|
9
|
+
//# sourceMappingURL=useExtensionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExtensionContext.d.ts","sourceRoot":"","sources":["../src/useExtensionContext.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,gEAElC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @module @category Extension */ import { useContext } from "react";
|
|
2
|
+
import { ComponentContext } from "./ComponentContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* A hook for a component rendered as an extension to access its extension context: the slot and
|
|
5
|
+
* slot module it is rendered in, its extension ID, and its `meta` from the extension's registration.
|
|
6
|
+
*
|
|
7
|
+
* @returns The extension context, or `undefined` when the calling component is not being rendered
|
|
8
|
+
* as an extension (a page, modal or workspace, say).
|
|
9
|
+
*/ export function useExtensionContext() {
|
|
10
|
+
return useContext(ComponentContext).extension;
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderableExtensions.d.ts","sourceRoot":"","sources":["../src/useRenderableExtensions.tsx"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,KAAK,cAAc,EAAoB,MAAM,GAAG,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"useRenderableExtensions.d.ts","sourceRoot":"","sources":["../src/useRenderableExtensions.tsx"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,KAAK,cAAc,EAAoB,MAAM,GAAG,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAqBpG"}
|
|
@@ -34,7 +34,8 @@ import { ComponentContext, Extension, useExtensionSlot } from "./index.js";
|
|
|
34
34
|
extension: {
|
|
35
35
|
extensionId: extension.id,
|
|
36
36
|
extensionSlotName: name,
|
|
37
|
-
extensionSlotModuleName
|
|
37
|
+
extensionSlotModuleName,
|
|
38
|
+
extensionMeta: extension.meta
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
}, /*#__PURE__*/ React.createElement(Extension, {
|
package/mock-jest.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { openmrsFetch } from '@openmrs/esm-api/mock';
|
|
|
3
3
|
import { configSchema } from '@openmrs/esm-config/mock';
|
|
4
4
|
import { getExtensionInternalStore } from '@openmrs/esm-extensions/mock';
|
|
5
5
|
import { createGlobalStore } from '@openmrs/esm-state/mock';
|
|
6
|
+
import { ComponentContext as realComponentContext } from './src/ComponentContext';
|
|
6
7
|
import { isDesktop as realIsDesktop } from './src/useLayoutType';
|
|
7
8
|
import { useFhirFetchAll as realUseFhirFetchAll } from './src/useFhirFetchAll';
|
|
8
9
|
import { useFhirInfinite as realUseFhirInfinite } from './src/useFhirInfinite';
|
|
@@ -17,7 +18,7 @@ export { ConfigurableLink } from './src/ConfigurableLink';
|
|
|
17
18
|
export { useStore, useStoreWithActions, createUseStore } from './src/useStore';
|
|
18
19
|
import * as utils from '@openmrs/esm-utils';
|
|
19
20
|
|
|
20
|
-
export const ComponentContext =
|
|
21
|
+
export const ComponentContext = realComponentContext;
|
|
21
22
|
|
|
22
23
|
export const openmrsComponentDecorator = jest.fn().mockImplementation(() => (component) => component);
|
|
23
24
|
|
|
@@ -29,6 +30,8 @@ export const useAttachments = jest.fn(() => ({
|
|
|
29
30
|
isValidating: true,
|
|
30
31
|
}));
|
|
31
32
|
|
|
33
|
+
export const useExtensionContext = jest.fn(() => React.useContext(ComponentContext).extension);
|
|
34
|
+
|
|
32
35
|
export const useConfig = jest.fn().mockImplementation((options?: { externalModuleName?: string }) => {
|
|
33
36
|
if (options?.externalModuleName) {
|
|
34
37
|
console.warn(`Mock useConfig called with externalModuleName: ${options.externalModuleName}`);
|
package/mock.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { openmrsFetch } from '@openmrs/esm-api/mock';
|
|
|
4
4
|
import { configSchema } from '@openmrs/esm-config/mock';
|
|
5
5
|
import { getExtensionInternalStore } from '@openmrs/esm-extensions/mock';
|
|
6
6
|
import { createGlobalStore } from '@openmrs/esm-state/mock';
|
|
7
|
+
import { ComponentContext as realComponentContext } from './src/ComponentContext';
|
|
7
8
|
import { isDesktop as realIsDesktop } from './src/useLayoutType';
|
|
8
9
|
import { useFhirFetchAll as realUseFhirFetchAll } from './src/useFhirFetchAll';
|
|
9
10
|
import { useFhirInfinite as realUseFhirInfinite } from './src/useFhirInfinite';
|
|
@@ -19,7 +20,7 @@ export { RenderIfValueIsTruthy } from './src/RenderIfValueIsTruthy';
|
|
|
19
20
|
export { useStore, useStoreWithActions, createUseStore } from './src/useStore';
|
|
20
21
|
import * as utils from '@openmrs/esm-utils';
|
|
21
22
|
|
|
22
|
-
export const ComponentContext =
|
|
23
|
+
export const ComponentContext = realComponentContext;
|
|
23
24
|
|
|
24
25
|
export const openmrsComponentDecorator = vi.fn().mockImplementation(() => (component: React.ReactNode) => component);
|
|
25
26
|
|
|
@@ -31,6 +32,8 @@ export const useAttachments = vi.fn(() => ({
|
|
|
31
32
|
isValidating: true,
|
|
32
33
|
}));
|
|
33
34
|
|
|
35
|
+
export const useExtensionContext = vi.fn(() => React.useContext(ComponentContext).extension);
|
|
36
|
+
|
|
34
37
|
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
35
38
|
export const useConfig = vi.fn<typeof import('@openmrs/esm-react-utils').useConfig>(
|
|
36
39
|
(options?: { externalModuleName?: string }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-react-utils",
|
|
3
|
-
"version": "10.0.1-pre.
|
|
3
|
+
"version": "10.0.1-pre.5501",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "React utilities for OpenMRS.",
|
|
6
6
|
"type": "module",
|
|
@@ -60,17 +60,17 @@
|
|
|
60
60
|
"single-spa-react": "^6.0.2"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@openmrs/esm-api": "^10.0.1-pre.
|
|
64
|
-
"@openmrs/esm-config": "^10.0.1-pre.
|
|
65
|
-
"@openmrs/esm-context": "^10.0.1-pre.
|
|
66
|
-
"@openmrs/esm-emr-api": "^10.0.1-pre.
|
|
67
|
-
"@openmrs/esm-error-handling": "^10.0.1-pre.
|
|
68
|
-
"@openmrs/esm-extensions": "^10.0.1-pre.
|
|
69
|
-
"@openmrs/esm-feature-flags": "^10.0.1-pre.
|
|
70
|
-
"@openmrs/esm-globals": "^10.0.1-pre.
|
|
71
|
-
"@openmrs/esm-navigation": "^10.0.1-pre.
|
|
72
|
-
"@openmrs/esm-state": "^10.0.1-pre.
|
|
73
|
-
"@openmrs/esm-utils": "^10.0.1-pre.
|
|
63
|
+
"@openmrs/esm-api": "^10.0.1-pre.5501",
|
|
64
|
+
"@openmrs/esm-config": "^10.0.1-pre.5501",
|
|
65
|
+
"@openmrs/esm-context": "^10.0.1-pre.5501",
|
|
66
|
+
"@openmrs/esm-emr-api": "^10.0.1-pre.5501",
|
|
67
|
+
"@openmrs/esm-error-handling": "^10.0.1-pre.5501",
|
|
68
|
+
"@openmrs/esm-extensions": "^10.0.1-pre.5501",
|
|
69
|
+
"@openmrs/esm-feature-flags": "^10.0.1-pre.5501",
|
|
70
|
+
"@openmrs/esm-globals": "^10.0.1-pre.5501",
|
|
71
|
+
"@openmrs/esm-navigation": "^10.0.1-pre.5501",
|
|
72
|
+
"@openmrs/esm-state": "^10.0.1-pre.5501",
|
|
73
|
+
"@openmrs/esm-utils": "^10.0.1-pre.5501",
|
|
74
74
|
"dayjs": "1.x",
|
|
75
75
|
"i18next": "25.x",
|
|
76
76
|
"react": "18.x",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"swr": "2.x"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@openmrs/esm-api": "10.0.1-pre.
|
|
84
|
-
"@openmrs/esm-config": "10.0.1-pre.
|
|
85
|
-
"@openmrs/esm-context": "10.0.1-pre.
|
|
86
|
-
"@openmrs/esm-emr-api": "10.0.1-pre.
|
|
87
|
-
"@openmrs/esm-error-handling": "10.0.1-pre.
|
|
88
|
-
"@openmrs/esm-extensions": "10.0.1-pre.
|
|
89
|
-
"@openmrs/esm-feature-flags": "10.0.1-pre.
|
|
90
|
-
"@openmrs/esm-globals": "10.0.1-pre.
|
|
91
|
-
"@openmrs/esm-navigation": "10.0.1-pre.
|
|
92
|
-
"@openmrs/esm-state": "10.0.1-pre.
|
|
93
|
-
"@openmrs/esm-utils": "10.0.1-pre.
|
|
83
|
+
"@openmrs/esm-api": "10.0.1-pre.5501",
|
|
84
|
+
"@openmrs/esm-config": "10.0.1-pre.5501",
|
|
85
|
+
"@openmrs/esm-context": "10.0.1-pre.5501",
|
|
86
|
+
"@openmrs/esm-emr-api": "10.0.1-pre.5501",
|
|
87
|
+
"@openmrs/esm-error-handling": "10.0.1-pre.5501",
|
|
88
|
+
"@openmrs/esm-extensions": "10.0.1-pre.5501",
|
|
89
|
+
"@openmrs/esm-feature-flags": "10.0.1-pre.5501",
|
|
90
|
+
"@openmrs/esm-globals": "10.0.1-pre.5501",
|
|
91
|
+
"@openmrs/esm-navigation": "10.0.1-pre.5501",
|
|
92
|
+
"@openmrs/esm-state": "10.0.1-pre.5501",
|
|
93
|
+
"@openmrs/esm-utils": "10.0.1-pre.5501",
|
|
94
94
|
"@swc/cli": "0.8.1",
|
|
95
95
|
"@swc/core": "1.15.21",
|
|
96
96
|
"@vitest/coverage-v8": "^4.1.2",
|
package/src/ExtensionSlot.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './useConnectivity';
|
|
|
20
20
|
export * from './useDebounce';
|
|
21
21
|
export * from './useDefineAppContext';
|
|
22
22
|
export * from './useEmrConfiguration';
|
|
23
|
+
export * from './useExtensionContext';
|
|
23
24
|
export * from './useExtensionInternalStore';
|
|
24
25
|
export * from './useExtensionSlot';
|
|
25
26
|
export * from './useExtensionSlotMeta';
|
package/src/public.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './useConnectivity';
|
|
|
16
16
|
export * from './useDebounce';
|
|
17
17
|
export * from './useDefineAppContext';
|
|
18
18
|
export * from './useEmrConfiguration';
|
|
19
|
+
export * from './useExtensionContext';
|
|
19
20
|
export * from './useExtensionSlotMeta';
|
|
20
21
|
export * from './useExtensionSlotStore';
|
|
21
22
|
export * from './useExtensionStore';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { renderHook } from '@testing-library/react';
|
|
4
|
+
import { type ExtensionData } from '@openmrs/esm-extensions';
|
|
5
|
+
import { ComponentContext } from './ComponentContext';
|
|
6
|
+
import { useExtensionContext } from './useExtensionContext';
|
|
7
|
+
|
|
8
|
+
describe('useExtensionContext', () => {
|
|
9
|
+
it('returns the extension context when rendered as an extension', () => {
|
|
10
|
+
const extension: ExtensionData = {
|
|
11
|
+
extensionId: 'my-extension#instance',
|
|
12
|
+
extensionSlotName: 'my-slot',
|
|
13
|
+
extensionSlotModuleName: 'slot-module',
|
|
14
|
+
extensionMeta: { column: 2, title: 'My Extension' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
18
|
+
<ComponentContext.Provider value={{ moduleName: 'slot-module', featureName: '', extension }}>
|
|
19
|
+
{children}
|
|
20
|
+
</ComponentContext.Provider>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const { result } = renderHook(() => useExtensionContext(), { wrapper });
|
|
24
|
+
|
|
25
|
+
expect(result.current).toEqual(extension);
|
|
26
|
+
expect(result.current?.extensionMeta).toEqual({ column: 2, title: 'My Extension' });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns undefined when not rendered as an extension', () => {
|
|
30
|
+
const { result } = renderHook(() => useExtensionContext());
|
|
31
|
+
|
|
32
|
+
expect(result.current).toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @module @category Extension */
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { ComponentContext } from './ComponentContext';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A hook for a component rendered as an extension to access its extension context: the slot and
|
|
7
|
+
* slot module it is rendered in, its extension ID, and its `meta` from the extension's registration.
|
|
8
|
+
*
|
|
9
|
+
* @returns The extension context, or `undefined` when the calling component is not being rendered
|
|
10
|
+
* as an extension (a page, modal or workspace, say).
|
|
11
|
+
*/
|
|
12
|
+
export function useExtensionContext() {
|
|
13
|
+
return useContext(ComponentContext).extension;
|
|
14
|
+
}
|