@uxland/primary-shell 1.0.14 → 1.0.16
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/README.md +231 -0
- package/dist/UI/components/clinical-monitoring/clinical-monitoring.d.ts +11 -0
- package/dist/UI/components/clinical-monitoring/template.d.ts +3 -0
- package/dist/UI/components/index.d.ts +1 -0
- package/dist/UI/components/primaria-breadcumbs/primaria-breadcumbs.d.ts +8 -0
- package/dist/UI/components/primaria-breadcumbs/template.d.ts +3 -0
- package/dist/UI/components/primaria-shell/primaria-shell.d.ts +14 -0
- package/dist/UI/components/primaria-shell/template.d.ts +3 -0
- package/dist/UI/components/title-view/template.d.ts +3 -0
- package/dist/UI/components/title-view/title-view.d.ts +9 -0
- package/dist/UI/index.d.ts +1 -0
- package/dist/UI/styles/theme/apply-theme.d.ts +1 -0
- package/dist/{api.d.ts → api/api.d.ts} +9 -16
- package/dist/api/broker/factory.d.ts +3 -0
- package/dist/api/broker/factory.test.d.ts +1 -0
- package/dist/api/broker/primaria-broker.d.ts +5 -0
- package/dist/api/global-state/global-state.d.ts +35 -0
- package/dist/api/global-state/global-state.test.d.ts +1 -0
- package/dist/api/interaction-manager/interaction.d.ts +8 -0
- package/dist/api/localization/localization.test.d.ts +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +16924 -326
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +8486 -45
- package/dist/index.umd.cjs.map +1 -1
- package/dist/initializer.d.ts +1 -1
- package/dist/locales.d.ts +15 -0
- package/dist/plugin.d.ts +4 -4
- package/dist/region-manager.d.ts +16 -1
- package/dist/regions.d.ts +10 -4
- package/dist/style.css +3 -0
- package/package.json +10 -6
- package/src/UI/components/clinical-monitoring/clinical-monitoring.ts +28 -0
- package/src/UI/components/clinical-monitoring/styles.scss +28 -0
- package/src/UI/components/clinical-monitoring/template.ts +12 -0
- package/src/UI/components/index.ts +5 -0
- package/src/UI/components/primaria-breadcumbs/primaria-breadcumbs.ts +23 -0
- package/src/UI/components/primaria-breadcumbs/styles.scss +25 -0
- package/src/UI/components/primaria-breadcumbs/template.ts +15 -0
- package/src/UI/components/primaria-shell/primaria-shell.ts +37 -0
- package/src/UI/components/primaria-shell/styles.scss +70 -0
- package/src/UI/components/primaria-shell/template.ts +96 -0
- package/src/UI/components/title-view/styles.scss +5 -0
- package/src/UI/components/title-view/template.ts +6 -0
- package/src/UI/components/title-view/title-view.ts +23 -0
- package/src/UI/images/Gencat_Logotip.svg +70 -0
- package/src/UI/images/Salut_Logotip.svg +8 -0
- package/src/UI/index.ts +1 -0
- package/src/UI/styles/_flex-layout.scss +203 -0
- package/src/UI/styles/_normalize.scss +3 -0
- package/src/UI/styles/_variables.scss +40 -0
- package/src/UI/styles/styles.scss +3 -0
- package/src/UI/styles/theme/apply-theme.ts +11 -0
- package/src/api/api.ts +63 -0
- package/src/api/broker/factory.test.ts +124 -0
- package/src/api/broker/factory.ts +122 -0
- package/src/api/broker/primaria-broker.ts +11 -0
- package/src/api/global-state/global-state.test.ts +53 -0
- package/src/api/global-state/global-state.ts +49 -0
- package/src/api/interaction-manager/interaction.ts +21 -0
- package/src/api/localization/localization.test.ts +61 -0
- package/src/api/localization/localization.ts +54 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +3 -1
- package/src/initializer.ts +36 -2
- package/src/locales.ts +24 -0
- package/src/plugin.ts +6 -5
- package/src/region-manager.ts +120 -3
- package/src/regions.ts +14 -5
- package/dist/primaria-shell.d.ts +0 -12
- package/src/api.ts +0 -102
- package/src/primaria-shell.ts +0 -77
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfirmOptions,
|
|
3
|
+
CustomConfirmOptions,
|
|
4
|
+
NotifyOptions,
|
|
5
|
+
doConfirm,
|
|
6
|
+
notify,
|
|
7
|
+
} from "@uxland/primaria-ui-components";
|
|
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
|
+
};
|
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
package/src/initializer.ts
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimariaMenuItem } from "@uxland/primaria-ui-components/src/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) => {
|
|
11
|
+
export const initializeShell = async (element: HTMLElement) => {
|
|
12
|
+
initializeLocalization(shellApi);
|
|
13
|
+
regionAdapterRegistry.registerAdapterFactory("primaria-content-switcher", factory);
|
|
4
14
|
const shell = new PrimariaShell();
|
|
5
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
|
+
});
|
|
6
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
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { bootstrapPlugins as pluginBootstrapper } from "@uxland/
|
|
2
|
-
import type { Plugin as PluginType } from "@uxland/
|
|
3
|
-
export type { PluginDefinition, PluginInfo } from "@uxland/
|
|
4
|
-
import { PrimariaApi, primariaApiFactory } from "./api";
|
|
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
5
|
|
|
6
|
-
export const bootstrapPlugins = (plugins) =>
|
|
6
|
+
export const bootstrapPlugins = (plugins: PluginDefinition[]) =>
|
|
7
|
+
pluginBootstrapper(plugins, primariaApiFactory);
|
|
7
8
|
|
|
8
9
|
export type Plugin = PluginType<PrimariaApi>;
|
package/src/region-manager.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { HarmonixRegionManager, IRegionManager, HarmonixViewDefinition } from "@uxland/
|
|
1
|
+
import { HarmonixRegionManager, IRegionManager, HarmonixViewDefinition } from "@uxland/harmonix";
|
|
2
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";
|
|
3
6
|
|
|
4
|
-
|
|
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 {
|
|
5
15
|
constructor(
|
|
6
16
|
private pluginInfo: PluginInfo,
|
|
7
17
|
private regionManager: IRegionManager,
|
|
@@ -21,18 +31,125 @@ class RegionaManagerProxy implements HarmonixRegionManager {
|
|
|
21
31
|
);
|
|
22
32
|
return Promise.resolve();
|
|
23
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
|
+
*/
|
|
24
41
|
removeView(regionName: string, viewId: string): Promise<void> {
|
|
42
|
+
this.regionManager.getRegion(regionName).removeView(`${this.pluginInfo.pluginId}::${viewId}`);
|
|
25
43
|
return Promise.resolve();
|
|
26
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
|
+
*/
|
|
27
52
|
activateView(regionName: string, viewId: string): Promise<void> {
|
|
53
|
+
this.regionManager.getRegion(regionName).activate(`${this.pluginInfo.pluginId}::${viewId}`);
|
|
28
54
|
return Promise.resolve();
|
|
29
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
|
+
*/
|
|
30
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}`);
|
|
31
136
|
return Promise.resolve();
|
|
32
137
|
}
|
|
33
138
|
}
|
|
34
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
|
+
*/
|
|
35
152
|
export const createRegionManagerProxy = (
|
|
36
153
|
pluginInfo: PluginInfo,
|
|
37
154
|
regionManager: IRegionManager,
|
|
38
|
-
):
|
|
155
|
+
): PrimariaRegionManager => new RegionManagerProxy(pluginInfo, regionManager);
|
package/src/regions.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const shellRegions = {
|
|
2
2
|
header: "header-region",
|
|
3
|
-
|
|
3
|
+
headerActions: "header-actions-region",
|
|
4
4
|
main: "main-region",
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
menu: "menu-region",
|
|
6
|
+
quickActions: "quick-actions-region",
|
|
7
|
+
floating: "floating-region",
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export
|
|
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];
|
package/dist/primaria-shell.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IRegion } from '@uxland/regions';
|
|
2
|
-
|
|
3
|
-
declare const PrimariaShell_base: any;
|
|
4
|
-
export declare class PrimariaShell extends PrimariaShell_base {
|
|
5
|
-
render(): import('../node_modules/lit').TemplateResult<1>;
|
|
6
|
-
static styles: import('../node_modules/lit').CSSResult;
|
|
7
|
-
headerRegion: IRegion | undefined;
|
|
8
|
-
actionsToolbarRegion: IRegion | undefined;
|
|
9
|
-
sidebarRegion: IRegion | undefined;
|
|
10
|
-
mainRegion: IRegion | undefined;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
package/src/api.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HarmonixApi,
|
|
3
|
-
PluginInfo,
|
|
4
|
-
IRegionManager,
|
|
5
|
-
createRegionManager,
|
|
6
|
-
createRegionHost,
|
|
7
|
-
ApiFactory,
|
|
8
|
-
} from "@uxland/fim-core";
|
|
9
|
-
import { createRegionManagerProxy } from "./region-manager";
|
|
10
|
-
|
|
11
|
-
interface PrimariaHttpClient {
|
|
12
|
-
get(url: string): Promise<any>;
|
|
13
|
-
post(url: string, data: any): Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface NotifyOptions {
|
|
17
|
-
message: string;
|
|
18
|
-
delay: number;
|
|
19
|
-
dissmissible: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface PrimariaInteractionManager {
|
|
23
|
-
notify(options: NotifyOptions): Promise<any>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface PrimariaMediator {
|
|
27
|
-
publish(event: string, data: any): Promise<any>;
|
|
28
|
-
subscribe(event: string, handler: any): Promise<any>;
|
|
29
|
-
sendCommand(command: string, data: any): Promise<any>;
|
|
30
|
-
registerCommand(command: string, handler: any): Promise<any>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface PrimariaApi extends HarmonixApi {
|
|
34
|
-
httpClient: PrimariaHttpClient;
|
|
35
|
-
interactionManager: PrimariaInteractionManager;
|
|
36
|
-
mediator: PrimariaMediator;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const regionManager: IRegionManager = createRegionManager("primaria");
|
|
40
|
-
export const PrimariaRegionHost: any = createRegionHost(regionManager as any);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Factory function that creates a Primaria API instance.
|
|
44
|
-
*
|
|
45
|
-
* @param {PluginInfo} pluginInfo - Information about the plugin
|
|
46
|
-
* @return {PrimariaApi} The created Primaria API instance
|
|
47
|
-
*/
|
|
48
|
-
export const primariaApiFactory: ApiFactory<PrimariaApi> = (
|
|
49
|
-
pluginInfo: PluginInfo,
|
|
50
|
-
): PrimariaApi => {
|
|
51
|
-
return {
|
|
52
|
-
pluginInfo: pluginInfo,
|
|
53
|
-
regionManager: createRegionManagerProxy(pluginInfo, regionManager),
|
|
54
|
-
httpClient: {
|
|
55
|
-
get: (url: string) => fetch(url).then((r) => r.json()),
|
|
56
|
-
post: (url: string, data: any) =>
|
|
57
|
-
fetch(url, {
|
|
58
|
-
method: "POST",
|
|
59
|
-
body: JSON.stringify(data),
|
|
60
|
-
}).then((r) => r.json()),
|
|
61
|
-
},
|
|
62
|
-
interactionManager: {
|
|
63
|
-
notify: (options: NotifyOptions) => {
|
|
64
|
-
return new Promise((resolve) => {
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
resolve(null);
|
|
67
|
-
}, options.delay);
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
mediator: {
|
|
72
|
-
publish: (event: string, data: any) => {
|
|
73
|
-
return new Promise((resolve) => {
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
resolve(null);
|
|
76
|
-
}, 100);
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
subscribe: (event: string, handler: any) => {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
resolve(null);
|
|
83
|
-
}, 100);
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
sendCommand: (command: string, data: any) => {
|
|
87
|
-
return new Promise((resolve) => {
|
|
88
|
-
setTimeout(() => {
|
|
89
|
-
resolve(null);
|
|
90
|
-
}, 100);
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
registerCommand: (command: string, handler: any) => {
|
|
94
|
-
return new Promise((resolve) => {
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
resolve(null);
|
|
97
|
-
}, 100);
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
};
|
package/src/primaria-shell.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { IRegion, region } from "@uxland/regions";
|
|
2
|
-
import { LitElement, css, html } from "lit";
|
|
3
|
-
import { PrimariaRegionHost } from "./api";
|
|
4
|
-
import { customElement } from "lit/decorators.js";
|
|
5
|
-
import { regions } from "./regions";
|
|
6
|
-
import "@uxland/primaria-ui-components";
|
|
7
|
-
|
|
8
|
-
//@ts-ignore
|
|
9
|
-
@customElement("primaria-shell")
|
|
10
|
-
export class PrimariaShell extends PrimariaRegionHost(LitElement) {
|
|
11
|
-
render() {
|
|
12
|
-
return html` <div class="container">
|
|
13
|
-
<div class="header">
|
|
14
|
-
<div id="header-region-container"></div>
|
|
15
|
-
<div id="actions-toolbar-region-container"></div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div class="main-container">
|
|
19
|
-
<div id="sidebar-region-region-container"></div>
|
|
20
|
-
<div id="main-region-region-container"></div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static styles = css`
|
|
26
|
-
:host {
|
|
27
|
-
width: 100%;
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
}
|
|
30
|
-
.container {
|
|
31
|
-
width: 100%;
|
|
32
|
-
height: 100%;
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
background: aliceblue;
|
|
36
|
-
}
|
|
37
|
-
.header {
|
|
38
|
-
display: flex;
|
|
39
|
-
flex-direction: row;
|
|
40
|
-
justify-content: space-between;
|
|
41
|
-
background-color: blue;
|
|
42
|
-
height: 60px;
|
|
43
|
-
background-color: white;
|
|
44
|
-
color: black;
|
|
45
|
-
box-shadow: rgba(0, 0, 0, 0.12) 0px 4px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
|
|
46
|
-
z-index: 1;
|
|
47
|
-
|
|
48
|
-
#actions-toolbar-region-container{
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-direction:row;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
.main-container {
|
|
54
|
-
min-height: 1px;
|
|
55
|
-
height: 100%;
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: row;
|
|
58
|
-
#sidebar-region-region-container {
|
|
59
|
-
background: white;
|
|
60
|
-
width: 15vw;
|
|
61
|
-
box-shadow: rgba(0, 0, 0, 0.12) 4px -1px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
@region({ targetId: "header-region-container", name: regions.header })
|
|
67
|
-
headerRegion: IRegion | undefined;
|
|
68
|
-
|
|
69
|
-
@region({ targetId: "actions-toolbar-region-container", name: regions.actionsToolbar })
|
|
70
|
-
actionsToolbarRegion: IRegion | undefined;
|
|
71
|
-
|
|
72
|
-
@region({ targetId: "sidebar-region-region-container", name: regions.sidebar })
|
|
73
|
-
sidebarRegion: IRegion | undefined;
|
|
74
|
-
|
|
75
|
-
@region({ targetId: "main-region-region-container", name: regions.main })
|
|
76
|
-
mainRegion: IRegion | undefined;
|
|
77
|
-
}
|