@uxland/primary-shell 1.1.0 → 2.0.0

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 (109) hide show
  1. package/README.md +231 -0
  2. package/dist/UI/components/clinical-monitoring/clinical-monitoring.d.ts +11 -0
  3. package/dist/UI/components/clinical-monitoring/template.d.ts +3 -0
  4. package/dist/UI/components/index.d.ts +1 -0
  5. package/dist/UI/components/primaria-breadcumbs/primaria-breadcumbs.d.ts +9 -0
  6. package/dist/UI/components/primaria-breadcumbs/template.d.ts +3 -0
  7. package/dist/UI/components/primaria-shell/primaria-shell.d.ts +14 -0
  8. package/dist/UI/components/primaria-shell/template.d.ts +3 -0
  9. package/dist/UI/components/title-view/template.d.ts +3 -0
  10. package/dist/UI/components/title-view/title-view.d.ts +9 -0
  11. package/dist/UI/index.d.ts +2 -0
  12. package/dist/UI/shared-components/dss-container/dss-container.d.ts +7 -0
  13. package/dist/UI/shared-components/index.d.ts +2 -0
  14. package/dist/UI/shared-components/primaria-content-switcher/primaria-content-switcher.d.ts +14 -0
  15. package/dist/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +20 -0
  16. package/dist/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +12 -0
  17. package/dist/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +16 -0
  18. package/dist/UI/shared-components/primaria-interaction/confirm.d.ts +3 -0
  19. package/dist/UI/shared-components/primaria-interaction/index.d.ts +4 -0
  20. package/dist/UI/shared-components/primaria-interaction/notify.d.ts +4 -0
  21. package/dist/UI/shared-components/primaria-interaction/typings.d.ts +28 -0
  22. package/dist/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts +10 -0
  23. package/dist/UI/shared-components/primaria-menu-item/template.d.ts +3 -0
  24. package/dist/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.d.ts +57 -0
  25. package/dist/UI/shared-components/primaria-text-editor/template.d.ts +1 -0
  26. package/dist/UI/shared-components/primaria-text-editor/utils.d.ts +1 -0
  27. package/dist/UI/styles/theme/apply-theme.d.ts +1 -0
  28. package/dist/api/api.d.ts +27 -0
  29. package/dist/api/broker/factory.d.ts +3 -0
  30. package/dist/api/broker/factory.test.d.ts +1 -0
  31. package/dist/api/broker/primaria-broker.d.ts +5 -0
  32. package/dist/api/global-state/global-state.d.ts +35 -0
  33. package/dist/api/global-state/global-state.test.d.ts +1 -0
  34. package/dist/api/interaction-manager/interaction.d.ts +8 -0
  35. package/dist/api/localization/localization.test.d.ts +1 -0
  36. package/dist/constants.d.ts +2 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.js +26335 -239
  39. package/dist/index.js.map +1 -0
  40. package/dist/index.umd.cjs +8647 -0
  41. package/dist/index.umd.cjs.map +1 -0
  42. package/dist/initializer.d.ts +1 -0
  43. package/dist/locales.d.ts +15 -0
  44. package/dist/plugin.d.ts +6 -0
  45. package/dist/region-manager.d.ts +16 -0
  46. package/dist/regions.d.ts +14 -0
  47. package/dist/style.css +3 -0
  48. package/package.json +23 -15
  49. package/src/UI/components/clinical-monitoring/clinical-monitoring.ts +28 -0
  50. package/src/UI/components/clinical-monitoring/styles.scss +29 -0
  51. package/src/UI/components/clinical-monitoring/template.ts +12 -0
  52. package/src/UI/components/index.ts +5 -0
  53. package/src/UI/components/primaria-breadcumbs/primaria-breadcumbs.ts +27 -0
  54. package/src/UI/components/primaria-breadcumbs/styles.scss +25 -0
  55. package/src/UI/components/primaria-breadcumbs/template.ts +15 -0
  56. package/src/UI/components/primaria-shell/primaria-shell.ts +37 -0
  57. package/src/UI/components/primaria-shell/styles.scss +68 -0
  58. package/src/UI/components/primaria-shell/template.ts +94 -0
  59. package/src/UI/components/title-view/styles.scss +5 -0
  60. package/src/UI/components/title-view/template.ts +6 -0
  61. package/src/UI/components/title-view/title-view.ts +23 -0
  62. package/src/UI/images/Gencat_Logotip.svg +70 -0
  63. package/src/UI/images/Salut_Logotip.svg +8 -0
  64. package/src/UI/index.ts +2 -0
  65. package/src/UI/shared-components/design-system.css +1 -0
  66. package/src/UI/shared-components/dss-container/dss-container.ts +32 -0
  67. package/src/UI/shared-components/dss-container/styles.scss +23 -0
  68. package/src/UI/shared-components/index.ts +5 -0
  69. package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +79 -0
  70. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.scss +155 -0
  71. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +120 -0
  72. package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.scss +128 -0
  73. package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +73 -0
  74. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +39 -0
  75. package/src/UI/shared-components/primaria-interaction/confirm.ts +30 -0
  76. package/src/UI/shared-components/primaria-interaction/index.ts +4 -0
  77. package/src/UI/shared-components/primaria-interaction/notify.ts +153 -0
  78. package/src/UI/shared-components/primaria-interaction/typings.ts +32 -0
  79. package/src/UI/shared-components/primaria-menu-item/primaria-menu-item.ts +25 -0
  80. package/src/UI/shared-components/primaria-menu-item/styles.scss +10 -0
  81. package/src/UI/shared-components/primaria-menu-item/template.ts +8 -0
  82. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +230 -0
  83. package/src/UI/shared-components/primaria-text-editor/styles.scss +972 -0
  84. package/src/UI/shared-components/primaria-text-editor/template.ts +8 -0
  85. package/src/UI/shared-components/primaria-text-editor/utils.ts +39 -0
  86. package/src/UI/styles/_flex-layout.scss +203 -0
  87. package/src/UI/styles/_normalize.scss +3 -0
  88. package/src/UI/styles/_variables.scss +40 -0
  89. package/src/UI/styles/styles.scss +3 -0
  90. package/src/UI/styles/theme/apply-theme.ts +11 -0
  91. package/src/api/api.ts +63 -0
  92. package/src/api/broker/factory.test.ts +124 -0
  93. package/src/api/broker/factory.ts +122 -0
  94. package/src/api/broker/primaria-broker.ts +11 -0
  95. package/src/api/global-state/global-state.test.ts +53 -0
  96. package/src/api/global-state/global-state.ts +49 -0
  97. package/src/api/interaction-manager/interaction.ts +21 -0
  98. package/src/api/localization/localization.test.ts +61 -0
  99. package/src/api/localization/localization.ts +54 -0
  100. package/src/constants.ts +2 -0
  101. package/src/index.ts +12 -0
  102. package/src/initializer.ts +39 -4
  103. package/src/locales.ts +24 -0
  104. package/src/plugin.ts +9 -0
  105. package/src/region-manager.ts +155 -0
  106. package/src/regions.ts +17 -6
  107. package/dist/index.mjs +0 -3209
  108. package/index.ts +0 -3
  109. package/src/primary-shell.ts +0 -78
@@ -0,0 +1,49 @@
1
+ import { PrimariaBroker } from "../broker/primaria-broker";
2
+
3
+ export abstract class PrimariaGlobalStateManager {
4
+ abstract setData(key: string, value: any): void;
5
+ abstract getData(key: string): any;
6
+ abstract clearData(): void;
7
+ }
8
+
9
+ class PrimariaGlobalStateManagerImpl implements PrimariaGlobalStateManager {
10
+ private state: { [key: string]: any } = {};
11
+ constructor(public broker: PrimariaBroker) {}
12
+
13
+ /**
14
+ * Sets the value of a key in the state object and publishes an event with the event bus.
15
+ *
16
+ * @param {string} key - The key to set the value for.
17
+ * @param {any} value - The value to set for the key.
18
+ * @return {void} This function does not return anything.
19
+ */
20
+ setData(key: string, value: any): void {
21
+ this.state[key] = value;
22
+ this.broker.publish("data-setted", {
23
+ key: key,
24
+ value: value,
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Retrieves the value associated with the specified key from the state object.
30
+ *
31
+ * @param {string} key - The key to retrieve the value for.
32
+ * @return {any} The value associated with the specified key, or undefined if the key does not exist in the state object.
33
+ */
34
+ getData(key: string): any {
35
+ return this.state[key];
36
+ }
37
+
38
+ /**
39
+ * Clears all data stored in the state object.
40
+ *
41
+ * @return {void} This function does not return anything.
42
+ */
43
+ public clearData(): void {
44
+ this.state = {};
45
+ }
46
+ }
47
+
48
+ export const createGlobalStateManager = (broker: PrimariaBroker) =>
49
+ new PrimariaGlobalStateManagerImpl(broker);
@@ -0,0 +1,21 @@
1
+ import {
2
+ ConfirmOptions,
3
+ CustomConfirmOptions,
4
+ NotifyOptions,
5
+ doConfirm,
6
+ notify,
7
+ } from "../../UI/shared-components/primaria-interaction";
8
+
9
+ export interface PrimariaInteractionManager {
10
+ notify(options: NotifyOptions): Promise<any>;
11
+ doConfirm(options: ConfirmOptions): Promise<boolean>;
12
+ doCustomConfirm(options: CustomConfirmOptions): Promise<boolean>;
13
+ }
14
+
15
+ export const createInteractionManager: () => PrimariaInteractionManager = () => {
16
+ return {
17
+ notify: (options: NotifyOptions) => notify(options),
18
+ doConfirm: (options: ConfirmOptions) => doConfirm(options),
19
+ doCustomConfirm: (options: CustomConfirmOptions) => doConfirm(options),
20
+ } as PrimariaInteractionManager;
21
+ };
@@ -0,0 +1,61 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { createLocaleManager } from "./localization";
3
+
4
+ const pluginInfo = { pluginId: "testPlugin" };
5
+
6
+ // Mock data
7
+ const translations = {
8
+ en: { testPlugin: { hello: "Hello" } },
9
+ es: { testPlugin: { hello: "Hola" } },
10
+ };
11
+
12
+ describe("createLocaleManager", () => {
13
+ it("should return an object with translate, getTranslations, and getCurrentLanguage functions", async () => {
14
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations as any);
15
+ expect(localeManager).toHaveProperty("translate");
16
+ expect(localeManager).toHaveProperty("getTranslations");
17
+ expect(localeManager).toHaveProperty("getCurrentLanguage");
18
+ });
19
+
20
+ it("should translate a given path using localizer", async () => {
21
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations as any);
22
+ const result = localeManager.translate("hello");
23
+ expect(result).toBe("Hello");
24
+ });
25
+
26
+ it("should return the full path if no exist translation for given path", async () => {
27
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations as any);
28
+ const result = localeManager.translate("hellaaa");
29
+ expect(result).toBe("testPlugin.hellaaa");
30
+ });
31
+
32
+ it("should return the path if there is an error translating", async () => {
33
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations as any);
34
+ const translateSpy = vi.spyOn(localeManager, "translate").mockImplementation(() => {
35
+ throw new Error("mocked error");
36
+ });
37
+
38
+ let result;
39
+ try {
40
+ result = localeManager.translate("hello");
41
+ } catch (error) {
42
+ result = "hello";
43
+ }
44
+
45
+ expect(result).toBe("hello");
46
+ // Restore the original implementation
47
+ translateSpy.mockRestore();
48
+ });
49
+
50
+ it("should get translations for the current language", async () => {
51
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations);
52
+ const result = localeManager.getTranslations();
53
+ expect(result).toEqual(translations.en.testPlugin);
54
+ });
55
+
56
+ it("should get the current language", async () => {
57
+ const localeManager = await createLocaleManager(pluginInfo.pluginId)(translations);
58
+ const result = localeManager.getCurrentLanguage();
59
+ expect(result).toBe("en");
60
+ });
61
+ });
@@ -0,0 +1,54 @@
1
+ import { getLanguage, getLocales, localizerFactory, setLocales } from "@uxland/localization";
2
+
3
+ /**
4
+ * Creates a locale manager for a given plugin ID and translations.
5
+ *
6
+ * @param {string} pluginId - The ID of the plugin.
7
+ * @param {Record<string, Record<string, string>>} translations - The translations for the plugin.
8
+ * @return {Promise<{
9
+ * translate: (path: string, variables?: Record<string, string>) => string,
10
+ * getTranslations: () => Record<string, string>,
11
+ * getCurrentLanguage: () => string,
12
+ * }>} A promise that resolves to an object with methods for translating strings and getting translations.
13
+ */
14
+ export const createLocaleManager =
15
+ (pluginId: string) => (translations: Record<string, Record<string, string>>) => {
16
+ const localizer = localizerFactory(getLanguage(), translations, "", true);
17
+ setLocales(translations);
18
+ return Promise.resolve({
19
+ /**
20
+ * Translates the given path using the provided variables and the plugin's ID.
21
+ *
22
+ * @param {string} path - The path to be translated.
23
+ * @param {Record<string, string>} [variables] - Optional variables to be used in the translation.
24
+ * @return {string} The translated string, or the original path if an error occurs.
25
+ */
26
+ translate: (path: string, variables?: Record<string, string>) => {
27
+ try {
28
+ return localizer(`${pluginId}.${path}`, variables);
29
+ } catch (e) {
30
+ console.error(e);
31
+ return path;
32
+ }
33
+ },
34
+ /**
35
+ * Retrieves the translations for the current language and plugin.
36
+ *
37
+ * @return {Record<string, string>} The translations for the current language and plugin.
38
+ */
39
+ getTranslations: () => {
40
+ const translations = getLocales();
41
+ const language = getLanguage();
42
+ return translations[language][pluginId] || {};
43
+ },
44
+
45
+ /**
46
+ * Retrieves the current language.
47
+ *
48
+ * @return {string} The current language.
49
+ */
50
+ getCurrentLanguage: () => {
51
+ return getLanguage();
52
+ },
53
+ });
54
+ };
@@ -0,0 +1,2 @@
1
+ export const primariaShellId = "primaria-shell";
2
+ export const clinicalMonitoringId = "clinical-monitoring";
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./initializer";
2
+ export * from "./regions";
3
+ export * from "./plugin";
4
+ export * from "./api/api";
5
+ export * from "./api/broker/primaria-broker";
6
+ import "./UI/index";
7
+ export { PrimariaMenuItem } from "./UI/shared-components/primaria-menu-item/primaria-menu-item";
8
+ export { confirmMixin } from "./UI/shared-components/primaria-interaction";
9
+ export type {
10
+ IConfirmMixin,
11
+ CustomConfirmOptions,
12
+ } from "./UI/shared-components/primaria-interaction";
@@ -1,5 +1,40 @@
1
- import { PrimaryShell } from "./primary-shell";
1
+ import { PrimariaMenuItem } from "./UI/shared-components/primaria-menu-item/primaria-menu-item";
2
+ import { selectableAdapterFactory as factory, regionAdapterRegistry } from "@uxland/regions";
3
+ import { ClinicalMonitoring } from "./UI/components/clinical-monitoring/clinical-monitoring";
4
+ import { PrimariaShell } from "./UI/components/primaria-shell/primaria-shell";
5
+ import { appendTheme } from "./UI/styles/theme/apply-theme";
6
+ import { shellApi } from "./api/api";
7
+ import { initializeLocalization } from "./locales";
8
+ import { shellRegions } from "./regions";
9
+ import { clinicalMonitoringId } from "./constants";
2
10
 
3
- export const initializeShell = (element : HTMLElement) => {
4
- element.appendChild(new PrimaryShell());
5
- }
11
+ export const initializeShell = async (element: HTMLElement) => {
12
+ initializeLocalization(shellApi);
13
+ regionAdapterRegistry.registerAdapterFactory("primaria-content-switcher", factory);
14
+ const shell = new PrimariaShell();
15
+ element.appendChild(shell as any);
16
+ appendTheme();
17
+ registerViews();
18
+ };
19
+
20
+ const registerViews = () => {
21
+ shellApi.regionManager.registerMainView(
22
+ {
23
+ id: clinicalMonitoringId,
24
+ factory: () => {
25
+ const mainItem = new ClinicalMonitoring();
26
+ return Promise.resolve(mainItem as unknown as HTMLElement);
27
+ },
28
+ },
29
+ "Seguiment Clínic",
30
+ );
31
+ shellApi.regionManager.registerMenu({
32
+ id: clinicalMonitoringId,
33
+ factory: () => {
34
+ const menuItem = new PrimariaMenuItem("add_box", "Seguiment clínic", () => {
35
+ shellApi.regionManager.activateView(shellRegions.main, "clinical-monitoring");
36
+ });
37
+ return Promise.resolve(menuItem);
38
+ },
39
+ });
40
+ };
package/src/locales.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { setLanguage } from "@uxland/localization";
2
+ import { PrimariaApi } from "./api/api";
3
+ import { clinicalMonitoringId, primariaShellId } from "./constants";
4
+
5
+ let shellLocaleManager;
6
+
7
+ export const initializeLocalization = async (api: PrimariaApi) => {
8
+ setLanguage("ca");
9
+ const localeManager = await api.createLocaleManager(locales);
10
+ shellLocaleManager = localeManager;
11
+ };
12
+
13
+ export { shellLocaleManager };
14
+
15
+ export const locales = {
16
+ ca: {
17
+ [primariaShellId]: {
18
+ title: "Estació de Treball Clínica",
19
+ },
20
+ [clinicalMonitoringId]: {
21
+ title: "Seguiment Clínic",
22
+ },
23
+ },
24
+ };
package/src/plugin.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { bootstrapPlugins as pluginBootstrapper } from "@uxland/harmonix";
2
+ import type { PluginDefinition, Plugin as PluginType } from "@uxland/harmonix";
3
+ export type { PluginDefinition, PluginInfo } from "@uxland/harmonix";
4
+ import { PrimariaApi, primariaApiFactory } from "./api/api";
5
+
6
+ export const bootstrapPlugins = (plugins: PluginDefinition[]) =>
7
+ pluginBootstrapper(plugins, primariaApiFactory);
8
+
9
+ export type Plugin = PluginType<PrimariaApi>;
@@ -0,0 +1,155 @@
1
+ import { HarmonixRegionManager, IRegionManager, HarmonixViewDefinition } from "@uxland/harmonix";
2
+ import { PluginInfo } from "./plugin";
3
+ import { IRegion } from "@uxland/regions";
4
+ import { shellRegions } from "./regions";
5
+ import { TitleView } from "./UI/components/title-view/title-view";
6
+
7
+ export interface PrimariaRegionManager extends HarmonixRegionManager {
8
+ registerMenu(view: HarmonixViewDefinition): Promise<void>;
9
+ registerQuickAction(view: HarmonixViewDefinition): Promise<void>;
10
+ registerMainView(view: HarmonixViewDefinition, title: string): Promise<void>;
11
+ activateMainView(viewId: string): Promise<void>;
12
+ }
13
+
14
+ class RegionManagerProxy implements PrimariaRegionManager {
15
+ constructor(
16
+ private pluginInfo: PluginInfo,
17
+ private regionManager: IRegionManager,
18
+ ) {}
19
+ /**
20
+ * Register a view in a specific region.
21
+ *
22
+ * @param {string} regionName - The name of the region to register the view with.
23
+ * @param {HarmonixViewDefinition} view - The view definition to be registered.
24
+ * @return {Promise<void>} A promise that resolves when the view is successfully registered.
25
+ */
26
+ registerView(regionName: string, view: HarmonixViewDefinition): Promise<void> {
27
+ this.regionManager.registerViewWithRegion(
28
+ regionName,
29
+ `${this.pluginInfo.pluginId}::${view.id}`,
30
+ view,
31
+ );
32
+ return Promise.resolve();
33
+ }
34
+ /**
35
+ * Removes a view from a specific region.
36
+ *
37
+ * @param {string} regionName - The name of the region to remove the view from.
38
+ * @param {string} viewId - The ID of the view to be removed.
39
+ * @return {Promise<void>} A promise that resolves when the view is successfully removed.
40
+ */
41
+ removeView(regionName: string, viewId: string): Promise<void> {
42
+ this.regionManager.getRegion(regionName).removeView(`${this.pluginInfo.pluginId}::${viewId}`);
43
+ return Promise.resolve();
44
+ }
45
+ /**
46
+ * Activates a view in a specific region.
47
+ *
48
+ * @param {string} regionName - The name of the region where the view is located.
49
+ * @param {string} viewId - The ID of the view to be activated.
50
+ * @return {Promise<void>} A promise that resolves when the view is successfully activated.
51
+ */
52
+ activateView(regionName: string, viewId: string): Promise<void> {
53
+ this.regionManager.getRegion(regionName).activate(`${this.pluginInfo.pluginId}::${viewId}`);
54
+ return Promise.resolve();
55
+ }
56
+ /**
57
+ * Deactivates a view in a specific region.
58
+ *
59
+ * @param {string} regionName - The name of the region where the view is located.
60
+ * @param {string} viewId - The ID of the view to be deactivated.
61
+ * @return {Promise<void>} A promise that resolves when the view is successfully deactivated.
62
+ */
63
+ deactivateView(regionName: string, viewId: string): Promise<void> {
64
+ this.regionManager.getRegion(regionName).deactivate(`${this.pluginInfo.pluginId}::${viewId}`);
65
+ return Promise.resolve();
66
+ }
67
+ /**
68
+ * Retrieves a region by its name.
69
+ *
70
+ * @param {string} regionName - The name of the region to retrieve.
71
+ * @return {Promise<IRegion>} A promise that resolves to the retrieved region.
72
+ */
73
+ getRegion(regionName: string): Promise<IRegion> {
74
+ return Promise.resolve(this.regionManager.getRegion(regionName));
75
+ }
76
+ /**
77
+ * Checks if a view with the given ID exists in a specific region.
78
+ *
79
+ * @param {string} regionName - The name of the region to check.
80
+ * @param {string} viewId - The ID of the view to check for.
81
+ * @return {Promise<boolean>} A promise that resolves to true if the view exists, false otherwise.
82
+ */
83
+ containsView(regionName: string, viewId: string) {
84
+ const region = this.regionManager.getRegion(regionName);
85
+ return Promise.resolve(region?.containsView(`${this.pluginInfo.pluginId}::${viewId}`));
86
+ }
87
+ /**
88
+ * Checks if a view with the given ID is active in a specific region.
89
+ *
90
+ * @param {string} regionName - The name of the region to check.
91
+ * @param {string} viewId - The ID of the view to check for.
92
+ * @return {Promise<boolean>} A promise that resolves to true if the view is active, false otherwise.
93
+ */
94
+ isViewActive(regionName: string, viewId: string) {
95
+ const region = this.regionManager.getRegion(regionName);
96
+ return Promise.resolve(region?.isViewActive(`${this.pluginInfo.pluginId}::${viewId}`));
97
+ }
98
+
99
+ registerMenu(view: HarmonixViewDefinition): Promise<void> {
100
+ this.regionManager.registerViewWithRegion(
101
+ shellRegions.menu,
102
+ `${this.pluginInfo.pluginId}::${view.id}`,
103
+ view,
104
+ );
105
+ return Promise.resolve();
106
+ }
107
+ registerQuickAction(view: HarmonixViewDefinition): Promise<void> {
108
+ this.regionManager.registerViewWithRegion(
109
+ shellRegions.quickActions,
110
+ `${this.pluginInfo.pluginId}::${view.id}`,
111
+ view,
112
+ );
113
+ return Promise.resolve();
114
+ }
115
+ registerMainView(view: HarmonixViewDefinition, title: string): Promise<void> {
116
+ this.regionManager.registerViewWithRegion(
117
+ shellRegions.main,
118
+ `${this.pluginInfo.pluginId}::${view.id}`,
119
+ view,
120
+ );
121
+ const titleView = createTitleView(view.id, title);
122
+ this.regionManager.registerViewWithRegion(
123
+ shellRegions.header,
124
+ `${this.pluginInfo.pluginId}::${view.id}`,
125
+ titleView,
126
+ );
127
+ return Promise.resolve();
128
+ }
129
+ activateMainView(viewId: string): Promise<void> {
130
+ this.regionManager
131
+ .getRegion(shellRegions.main)
132
+ .activate(`${this.pluginInfo.pluginId}::${viewId}`);
133
+ this.regionManager
134
+ .getRegion(shellRegions.header)
135
+ .activate(`${this.pluginInfo.pluginId}::${viewId}`);
136
+ return Promise.resolve();
137
+ }
138
+ }
139
+
140
+ const createTitleView = (id: string, title: string): HarmonixViewDefinition => ({
141
+ id: id,
142
+ factory: () => Promise.resolve(new TitleView(title)),
143
+ });
144
+
145
+ /**
146
+ * Creates a proxy for the region manager with the given plugin info and region manager instance.
147
+ *
148
+ * @param {PluginInfo} pluginInfo - The plugin information.
149
+ * @param {IRegionManager} regionManager - The region manager instance.
150
+ * @return {HarmonixRegionManager} The created region manager proxy.
151
+ */
152
+ export const createRegionManagerProxy = (
153
+ pluginInfo: PluginInfo,
154
+ regionManager: IRegionManager,
155
+ ): PrimariaRegionManager => new RegionManagerProxy(pluginInfo, regionManager);
package/src/regions.ts CHANGED
@@ -1,7 +1,18 @@
1
- export const regions = {
2
- header: 'header-region',
3
- actionsToolbar: 'actions-toolbar-region',
4
- main: 'main-region',
5
- sidebar: 'asidebar-region',
6
- footer: 'footer-region'
1
+ export const shellRegions = {
2
+ header: "header-region",
3
+ headerActions: "header-actions-region",
4
+ main: "main-region",
5
+ menu: "menu-region",
6
+ quickActions: "quick-actions-region",
7
+ floating: "floating-region",
7
8
  };
9
+
10
+ export const clinicalMonitoringRegions = {
11
+ sidebar: "widgets-sidebar-region",
12
+ header: "header-widgets-region",
13
+ content: "content-widgets-region",
14
+ };
15
+
16
+ export type PrimariaRegionNames =
17
+ | (typeof shellRegions)[keyof typeof shellRegions]
18
+ | (typeof clinicalMonitoringRegions)[keyof typeof clinicalMonitoringRegions];