@uxland/primary-shell 7.38.0 → 7.38.2

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.
@@ -26,6 +26,13 @@ export declare class PrimariaRegion extends PrimariaRegion_base {
26
26
  * and to generate the container ID.
27
27
  */
28
28
  name: string;
29
+ /**
30
+ * Rendering mode for the region.
31
+ * - "multi" (default): all registered views are shown simultaneously (MultipleActiveAdapter).
32
+ * - "single": only one view is shown at a time (SelectableAdapter via primaria-content-switcher).
33
+ * Each plugin activates its own view; the adapter deactivates the rest automatically.
34
+ */
35
+ mode: "multi" | "single";
29
36
  /**
30
37
  * Render in light DOM instead of shadow DOM.
31
38
  * This allows the region content to be visible in the parent's DOM tree.
@@ -1,6 +1,6 @@
1
1
  export interface IEcapEvent {
2
2
  TipusEvent: string;
3
3
  Accio: string;
4
- diagnostics?: unknown[];
4
+ DIAGNOSTICS?: unknown[];
5
5
  [key: string]: unknown;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.38.0",
3
+ "version": "7.38.2",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -31,7 +31,14 @@ export class PrimariaRegion extends PrimariaRegionHost(LitElement) {
31
31
  */
32
32
  @property({ type: String })
33
33
  name = "";
34
-
34
+ /**
35
+ * Rendering mode for the region.
36
+ * - "multi" (default): all registered views are shown simultaneously (MultipleActiveAdapter).
37
+ * - "single": only one view is shown at a time (SelectableAdapter via primaria-content-switcher).
38
+ * Each plugin activates its own view; the adapter deactivates the rest automatically.
39
+ */
40
+ @property({ type: String })
41
+ mode: "multi" | "single" = "multi";
35
42
  /**
36
43
  * Render in light DOM instead of shadow DOM.
37
44
  * This allows the region content to be visible in the parent's DOM tree.
@@ -88,10 +95,16 @@ export class PrimariaRegion extends PrimariaRegionHost(LitElement) {
88
95
  if (this.name) {
89
96
  const targetId = `${this.name}-container`;
90
97
 
91
- // Create the container div immediately in the light DOM
92
- const container = document.createElement("div");
98
+ // Create the container element based on mode.
99
+ // "single" uses primaria-content-switcher so the region mixin picks up
100
+ // selectableAdapterFactory (already registered in UI bootstrapper), giving
101
+ // SingleActiveAdapter behaviour: activating one view auto-deactivates the rest.
102
+ const container =
103
+ this.mode === "single" ? document.createElement("primaria-content-switcher") : document.createElement("div");
93
104
  container.id = targetId;
94
- container.style.cssText = "width: 100%; height: 100%; min-height: 1px";
105
+ if (this.mode !== "single") {
106
+ (container as HTMLElement).style.cssText = "width: 100%; height: 100%; min-height: 1px";
107
+ }
95
108
  this.appendChild(container);
96
109
 
97
110
  // Set the region metadata directly on the instance constructor
@@ -30,7 +30,7 @@ class EcapEventManagerImpl implements EcapEventManager {
30
30
  const ecapEvent = this.createEcapEvent(eventType, accio, payload ?? {});
31
31
 
32
32
  if (EVENTS_WITH_DIAGNOSTICS.includes(eventType as (typeof EVENTS_WITH_DIAGNOSTICS)[number])) {
33
- ecapEvent.diagnostics = this.globalStateManager.getData<unknown[]>(LAST_WORKED_DIAGNOSTICS_KEY) ?? [];
33
+ ecapEvent.DIAGNOSTICS = this.globalStateManager.getData<unknown[]>(LAST_WORKED_DIAGNOSTICS_KEY) ?? [];
34
34
  }
35
35
 
36
36
  this.raiseEcapEvent(ecapEvent);
@@ -1,6 +1,6 @@
1
1
  export interface IEcapEvent {
2
2
  TipusEvent: string;
3
3
  Accio: string;
4
- diagnostics?: unknown[];
4
+ DIAGNOSTICS?: unknown[];
5
5
  [key: string]: unknown;
6
6
  }
@@ -39,7 +39,10 @@ class RegionManagerProxy implements PrimariaRegionManager {
39
39
  * @return {Promise<void>} A promise that resolves when the view is successfully registered.
40
40
  */
41
41
  registerView(regionName: string, view: HarmonixViewDefinition): Promise<void> {
42
- this.regionManager.registerViewWithRegion(regionName, `${this.pluginInfo.pluginId}::${view.id}`, view);
42
+ const key = `${this.pluginInfo.pluginId}::${view.id}`;
43
+
44
+ this.regionManager.registerViewWithRegion(regionName, key, view);
45
+ this.activateIfDefault(regionName, key, view);
43
46
  return Promise.resolve();
44
47
  }
45
48
  /**
@@ -131,6 +134,26 @@ class RegionManagerProxy implements PrimariaRegionManager {
131
134
  return mainView?.id;
132
135
  }
133
136
 
137
+ /**
138
+ * Activates a view if it is marked as default and the region currently has no active views.
139
+ *
140
+ * @param {string} regionName - The name of the region to activate the view in.
141
+ * @param {string} key - The key of the view to activate.
142
+ * @param {HarmonixViewDefinition} view - The view to activate.
143
+ * @return {void}
144
+ */
145
+ activateIfDefault(regionName: string, key: string, view: HarmonixViewDefinition) {
146
+ if (!(view as any).isDefault) return;
147
+
148
+ const region = this.regionManager.getRegion(regionName);
149
+ if (!region || typeof (region as any).activate !== "function") return;
150
+
151
+ const hasActiveView = region.currentActiveViews?.length > 0;
152
+ if (!hasActiveView) {
153
+ (region as any).activate(key);
154
+ }
155
+ }
156
+
134
157
  _notifyMainViewChanged(viewId: string) {
135
158
  this.broker.publish(BROKER_EVENTS.shell.mainViewChanged, { viewId });
136
159
  }