@openmrs/esm-extensions 6.3.1-pre.3012 → 6.3.1-pre.3014

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 8 files with swc (176.17ms)
1
+ [0] Successfully compiled: 10 files with swc (153.61ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -1,6 +1,5 @@
1
1
  /** @module @category Extension */
2
- import { type AssignedExtension } from '.';
3
- import { type ExtensionRegistration, type ExtensionInternalStore } from './store';
2
+ import { type AssignedExtension, type ExtensionRegistration, type ExtensionInternalStore } from './store';
4
3
  /**
5
4
  * Given an extension ID, which is a string uniquely identifying
6
5
  * an instance of an extension within an extension slot, this
@@ -12,8 +12,8 @@ import { featureFlagsStore } from "@openmrs/esm-feature-flags";
12
12
  import { subscribeConnectivityChanged } from "@openmrs/esm-globals";
13
13
  import { isOnline as isOnlineFn } from "@openmrs/esm-utils";
14
14
  import { isEqual } from "lodash-es";
15
- import { checkStatusFor, getExtensionInternalStore } from "./index.js";
16
- import { getExtensionStore, updateInternalExtensionStore } from "./store.js";
15
+ import { checkStatusFor } from "./helpers.js";
16
+ import { getExtensionStore, getExtensionInternalStore, updateInternalExtensionStore } from "./store.js";
17
17
  const extensionInternalStore = getExtensionInternalStore();
18
18
  const extensionStore = getExtensionStore();
19
19
  const slotsConfigStore = getExtensionSlotsConfigStore();
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export * from './store';
2
1
  export * from './extensions';
2
+ export * from './helpers';
3
+ export * from './left-nav';
3
4
  export * from './modals';
4
5
  export * from './workspaces';
5
- export * from './helpers';
6
6
  export * from './render';
7
- /** @deprecated Use `getExtensionStore`. The structure of this store has also changed. */
8
- declare const internalStore: import("zustand").StoreApi<import("./store").ExtensionInternalStore>;
9
- export { internalStore as extensionStore };
7
+ export * from './store';
8
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,12 +1,8 @@
1
- export * from "./store.js";
2
1
  export * from "./extensions.js";
2
+ export * from "./helpers.js";
3
+ export * from "./left-nav.js";
3
4
  export * from "./modals.js";
4
5
  export * from "./workspaces.js";
5
- export * from "./helpers.js";
6
6
  export * from "./render.js";
7
- // Temporary compatibility hack
8
- // What is now `extensionInternalStore` used to be exposed
9
- // and used as `extensionStore`.
10
- import { getExtensionInternalStore } from "./store.js";
11
- /** @deprecated Use `getExtensionStore`. The structure of this store has also changed. */ const internalStore = getExtensionInternalStore();
12
- export { internalStore as extensionStore };
7
+ export * from "./store.js";
8
+ export * from "./types.js";
@@ -0,0 +1,31 @@
1
+ import { type ComponentConfig } from './types';
2
+ export interface LeftNavStore {
3
+ slotName: string | null;
4
+ basePath: string;
5
+ mode: 'normal' | 'collapsed';
6
+ componentContext?: ComponentConfig;
7
+ }
8
+ /** @internal */
9
+ export declare const leftNavStore: import("zustand").StoreApi<LeftNavStore>;
10
+ export interface SetLeftNavParams {
11
+ name: string;
12
+ basePath: string;
13
+ /**
14
+ * In normal mode, the left nav is shown in desktop mode, and collapse into hamburger menu button in tablet mode
15
+ * In collapsed mode, the left nav is always collapsed, regardless of desktop / tablet mode
16
+ */
17
+ mode?: 'normal' | 'collapsed';
18
+ componentContext?: ComponentConfig;
19
+ }
20
+ /**
21
+ * Sets the current left nav context. Must be paired with {@link unsetLeftNav}.
22
+ *
23
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
24
+ */
25
+ export declare function setLeftNav({ name, basePath, mode, componentContext }: SetLeftNavParams): void;
26
+ /**
27
+ * Unsets the left nav context if the current context is for the supplied name.
28
+ *
29
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
30
+ */
31
+ export declare function unsetLeftNav(name: string): void;
@@ -0,0 +1,27 @@
1
+ import { createGlobalStore } from "@openmrs/esm-state";
2
+ /** @internal */ export const leftNavStore = createGlobalStore('left-nav', {
3
+ slotName: null,
4
+ basePath: window.spaBase,
5
+ mode: 'normal'
6
+ });
7
+ /**
8
+ * Sets the current left nav context. Must be paired with {@link unsetLeftNav}.
9
+ *
10
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
11
+ */ export function setLeftNav({ name, basePath, mode, componentContext }) {
12
+ leftNavStore.setState({
13
+ slotName: name,
14
+ basePath,
15
+ mode: mode ?? 'normal',
16
+ componentContext
17
+ });
18
+ }
19
+ /**
20
+ * Unsets the left nav context if the current context is for the supplied name.
21
+ *
22
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
23
+ */ export function unsetLeftNav(name) {
24
+ if (leftNavStore.getState().slotName === name) {
25
+ leftNavStore.setState(leftNavStore.getInitialState(), true);
26
+ }
27
+ }
package/dist/public.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { getExtensionNameFromId, registerExtension, attach, detach, detachAll, getAssignedExtensions, registerExtensionSlot, } from './extensions';
2
+ export { type LeftNavStore, setLeftNav, unsetLeftNav, type SetLeftNavParams } from './left-nav';
2
3
  export { type CancelLoading, renderExtension } from './render';
3
4
  export { type ExtensionMeta, type ExtensionRegistration, type ExtensionStore, type AssignedExtension, type ConnectedExtension, type ExtensionSlotState, getExtensionStore, } from './store';
4
5
  export { type WorkspaceRegistration } from './workspaces';
6
+ export { type ExtensionData, type ComponentConfig } from './types';
package/dist/public.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { getExtensionNameFromId, registerExtension, attach, detach, detachAll, getAssignedExtensions, registerExtensionSlot } from "./extensions.js";
2
+ export { setLeftNav, unsetLeftNav } from "./left-nav.js";
2
3
  export { renderExtension } from "./render.js";
3
4
  export { getExtensionStore } from "./store.js";
@@ -0,0 +1,10 @@
1
+ export interface ExtensionData {
2
+ extensionSlotName: string;
3
+ extensionSlotModuleName: string;
4
+ extensionId: string;
5
+ }
6
+ export interface ComponentConfig {
7
+ moduleName: string;
8
+ featureName: string;
9
+ extension?: ExtensionData;
10
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-extensions",
3
- "version": "6.3.1-pre.3012",
3
+ "version": "6.3.1-pre.3014",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Coordinates extensions and extension points in the OpenMRS Frontend",
6
6
  "type": "module",
@@ -64,12 +64,12 @@
64
64
  "single-spa": "6.x"
65
65
  },
66
66
  "devDependencies": {
67
- "@openmrs/esm-api": "6.3.1-pre.3012",
68
- "@openmrs/esm-config": "6.3.1-pre.3012",
69
- "@openmrs/esm-expression-evaluator": "6.3.1-pre.3012",
70
- "@openmrs/esm-feature-flags": "6.3.1-pre.3012",
71
- "@openmrs/esm-state": "6.3.1-pre.3012",
72
- "@openmrs/esm-utils": "6.3.1-pre.3012",
67
+ "@openmrs/esm-api": "6.3.1-pre.3014",
68
+ "@openmrs/esm-config": "6.3.1-pre.3014",
69
+ "@openmrs/esm-expression-evaluator": "6.3.1-pre.3014",
70
+ "@openmrs/esm-feature-flags": "6.3.1-pre.3014",
71
+ "@openmrs/esm-state": "6.3.1-pre.3014",
72
+ "@openmrs/esm-utils": "6.3.1-pre.3014",
73
73
  "@swc/cli": "^0.7.7",
74
74
  "@swc/core": "^1.11.29",
75
75
  "concurrently": "^9.1.2",
package/src/extensions.ts CHANGED
@@ -24,12 +24,15 @@ import { type FeatureFlagsStore, featureFlagsStore } from '@openmrs/esm-feature-
24
24
  import { subscribeConnectivityChanged } from '@openmrs/esm-globals';
25
25
  import { isOnline as isOnlineFn } from '@openmrs/esm-utils';
26
26
  import { isEqual } from 'lodash-es';
27
- import { type AssignedExtension, checkStatusFor, type ExtensionSlotState, getExtensionInternalStore } from '.';
27
+ import { checkStatusFor } from './helpers';
28
28
  import {
29
+ type AssignedExtension,
29
30
  type ExtensionRegistration,
30
31
  type ExtensionSlotInfo,
31
32
  type ExtensionInternalStore,
33
+ type ExtensionSlotState,
32
34
  getExtensionStore,
35
+ getExtensionInternalStore,
33
36
  updateInternalExtensionStore,
34
37
  } from './store';
35
38
 
package/src/index.ts CHANGED
@@ -1,14 +1,8 @@
1
- export * from './store';
2
1
  export * from './extensions';
2
+ export * from './helpers';
3
+ export * from './left-nav';
3
4
  export * from './modals';
4
5
  export * from './workspaces';
5
- export * from './helpers';
6
6
  export * from './render';
7
-
8
- // Temporary compatibility hack
9
- // What is now `extensionInternalStore` used to be exposed
10
- // and used as `extensionStore`.
11
- import { getExtensionInternalStore } from './store';
12
- /** @deprecated Use `getExtensionStore`. The structure of this store has also changed. */
13
- const internalStore = getExtensionInternalStore();
14
- export { internalStore as extensionStore };
7
+ export * from './store';
8
+ export * from './types';
@@ -0,0 +1,48 @@
1
+ import type {} from '@openmrs/esm-globals';
2
+ import { createGlobalStore } from '@openmrs/esm-state';
3
+ import { type ComponentConfig } from './types';
4
+
5
+ export interface LeftNavStore {
6
+ slotName: string | null;
7
+ basePath: string;
8
+ mode: 'normal' | 'collapsed';
9
+ componentContext?: ComponentConfig;
10
+ }
11
+
12
+ /** @internal */
13
+ export const leftNavStore = createGlobalStore<LeftNavStore>('left-nav', {
14
+ slotName: null,
15
+ basePath: window.spaBase,
16
+ mode: 'normal',
17
+ });
18
+
19
+ export interface SetLeftNavParams {
20
+ name: string;
21
+ basePath: string;
22
+ /**
23
+ * In normal mode, the left nav is shown in desktop mode, and collapse into hamburger menu button in tablet mode
24
+ * In collapsed mode, the left nav is always collapsed, regardless of desktop / tablet mode
25
+ */
26
+ mode?: 'normal' | 'collapsed';
27
+ componentContext?: ComponentConfig;
28
+ }
29
+
30
+ /**
31
+ * Sets the current left nav context. Must be paired with {@link unsetLeftNav}.
32
+ *
33
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
34
+ */
35
+ export function setLeftNav({ name, basePath, mode, componentContext }: SetLeftNavParams) {
36
+ leftNavStore.setState({ slotName: name, basePath, mode: mode ?? 'normal', componentContext });
37
+ }
38
+
39
+ /**
40
+ * Unsets the left nav context if the current context is for the supplied name.
41
+ *
42
+ * @deprecated Please use {@link useLeftNav} instead. This function will be made internal in a future release.
43
+ */
44
+ export function unsetLeftNav(name: string) {
45
+ if (leftNavStore.getState().slotName === name) {
46
+ leftNavStore.setState(leftNavStore.getInitialState(), true);
47
+ }
48
+ }
package/src/public.ts CHANGED
@@ -7,6 +7,7 @@ export {
7
7
  getAssignedExtensions,
8
8
  registerExtensionSlot,
9
9
  } from './extensions';
10
+ export { type LeftNavStore, setLeftNav, unsetLeftNav, type SetLeftNavParams } from './left-nav';
10
11
  export { type CancelLoading, renderExtension } from './render';
11
12
  export {
12
13
  type ExtensionMeta,
@@ -18,3 +19,4 @@ export {
18
19
  getExtensionStore,
19
20
  } from './store';
20
21
  export { type WorkspaceRegistration } from './workspaces';
22
+ export { type ExtensionData, type ComponentConfig } from './types';
package/src/types.ts ADDED
@@ -0,0 +1,11 @@
1
+ export interface ExtensionData {
2
+ extensionSlotName: string;
3
+ extensionSlotModuleName: string;
4
+ extensionId: string;
5
+ }
6
+
7
+ export interface ComponentConfig {
8
+ moduleName: string;
9
+ featureName: string;
10
+ extension?: ExtensionData;
11
+ }