@uxland/primary-shell 7.15.2 → 7.17.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.
@@ -0,0 +1 @@
1
+ export { PrimariaRegion } from './primaria-region';
@@ -0,0 +1,67 @@
1
+ import { IRegion } from '@uxland/regions';
2
+ declare const PrimariaRegion_base: any;
3
+ /**
4
+ * PrimariaRegion Web Component
5
+ *
6
+ * A plug-and-play region component that allows dynamic region creation without
7
+ * needing to extend PrimariaRegionHost or use the @region decorator manually.
8
+ *
9
+ * Renders in light DOM (no shadow-root) to allow region content to be properly
10
+ * displayed in the parent's DOM tree.
11
+ *
12
+ * @example
13
+ * ```html
14
+ * <primaria-region name="diagnostics-region"></primaria-region>
15
+ * ```
16
+ *
17
+ * This component internally handles:
18
+ * - Creating a container with the appropriate ID
19
+ * - Setting up the region definition
20
+ * - Managing the region lifecycle
21
+ */
22
+ export declare class PrimariaRegion extends PrimariaRegion_base {
23
+ /**
24
+ * The name of the region to create.
25
+ * This will be used both as the region name in the region manager
26
+ * and to generate the container ID.
27
+ */
28
+ name: string;
29
+ /**
30
+ * Render in light DOM instead of shadow DOM.
31
+ * This allows the region content to be visible in the parent's DOM tree.
32
+ */
33
+ createRenderRoot(): this;
34
+ /**
35
+ * Override shadowRoot getter to return this (light DOM) instead of null.
36
+ * The region mixin tries to find elements using shadowRoot.querySelector(),
37
+ * so we need to make it work with light DOM.
38
+ */
39
+ get shadowRoot(): ShadowRoot | null;
40
+ /**
41
+ * The region instance created by the region host mixin.
42
+ * Plugins can inject content into this region using the region manager.
43
+ */
44
+ region: IRegion | undefined;
45
+ /**
46
+ * Virtual constructor for this instance to hold its own region definition.
47
+ * This prevents conflicts when multiple primaria-region instances exist.
48
+ */
49
+ private _instanceConstructor;
50
+ constructor();
51
+ /**
52
+ * Called when the component is connected to the DOM.
53
+ * Sets up the region definition before the parent connectedCallback runs.
54
+ */
55
+ connectedCallback(): void;
56
+ /**
57
+ * Called before the component updates.
58
+ * Updates the region definition if the name changes.
59
+ */
60
+ protected willUpdate(changedProperties: Map<PropertyKey, unknown>): void;
61
+ /**
62
+ * Renders nothing because we create the container div manually in connectedCallback.
63
+ * This is necessary because the mixin needs the div to exist before it tries to create the region.
64
+ */
65
+ render(): import('lit').TemplateResult<1>;
66
+ }
67
+ export {};
@@ -6,6 +6,7 @@ export * from './api/api';
6
6
  export * from './api/broker/primaria-broker';
7
7
  export * from './UI/index';
8
8
  export { PrimariaNavItem } from './UI/shared-components/primaria-nav-item/primaria-nav-item';
9
+ export { PrimariaRegion } from './UI/shared-components/primaria-region';
9
10
  export { EcapEventManager, createEcapEventManager, } from './api/ecap-event-manager/ecap-event-manager';
10
11
  export type { IEcapEvent } from './api/ecap-event-manager/typings';
11
12
  export * from '@uxland/harmonix-adapters';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.15.2",
3
+ "version": "7.17.0",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -18,6 +18,7 @@ export const useComponents = () => {
18
18
  customElement("quick-actions-menu")(QuickActionsMenu);
19
19
  customElement("finalize-visit-button")(FinalizeVisitButton);
20
20
  customElement('header-divider')(HeaderDivider);
21
+ //@ts-ignore
21
22
  customElement("communication-action-menu")(CommunicationActionMenu);
22
23
  //@ts-ignore
23
24
  customElement("poc-events-ecap")(PocEventsEcap);
@@ -49,6 +49,13 @@
49
49
  .icon {
50
50
  margin-left: 8px;
51
51
  }
52
+
53
+ #menu-region{
54
+ width: 100%;
55
+ height: 100%;
56
+ min-height: 1px;
57
+ }
58
+
52
59
  #menu-region-container {
53
60
  padding-top: 24px;
54
61
  min-height: 1px;
@@ -64,16 +71,17 @@
64
71
  scrollbar-width: thin;
65
72
  }
66
73
 
67
- #menu-region-container::-webkit-scrollbar {
68
- width: 6px;
69
- }
70
- #menu-region-container::-webkit-scrollbar-track {
71
- background: var(--color-primary-700);
72
- }
73
- #menu-region-container::-webkit-scrollbar-thumb {
74
- background-color: var(--color-primary-400);
75
- border-radius: 4px;
76
- }
74
+ #menu-region-container::-webkit-scrollbar {
75
+ width: 6px;
76
+ }
77
+ #menu-region-container::-webkit-scrollbar-track {
78
+ background: var(--color-primary-700);
79
+ }
80
+ #menu-region-container::-webkit-scrollbar-thumb {
81
+ background-color: var(--color-primary-400);
82
+ border-radius: 4px;
83
+ }
84
+
77
85
 
78
86
  .bottom-content {
79
87
  display: flex;
@@ -6,6 +6,7 @@ import gencatLogo from "../../../UI/images/Gencat_Logotip.svg";
6
6
  import { PrimariaShell } from "./primaria-shell";
7
7
  import { shellViews } from "./constants";
8
8
  import { translate } from "../../../locales";
9
+ import { shellApi } from "../../../api/api";
9
10
 
10
11
  export const template = (props: PrimariaShell) => html`
11
12
  <primaria-content-switcher id="main-switcher" attrForSelected="view" .selected=${props.viewSelected}>
@@ -13,7 +14,8 @@ export const template = (props: PrimariaShell) => html`
13
14
  <primaria-shell-header></primaria-shell-header>
14
15
  <div class="main-container">
15
16
  <div class="sidebar" ?expanded=${props.sidebarExpanded}>
16
- <div id="menu-region-container"></div>
17
+ <div id="menu-region-container"></div>
18
+ <!-- <primaria-region id="menu-region" name=${shellApi.regionManager.regions.shell.navigationMenu}></primaria-region> -->
17
19
  <div class="quick-actions-content">
18
20
  <quick-actions-menu>
19
21
  <div class="${props.sidebarExpanded ? "create-button-opened" : "create-button-closed"} " slot="anchor" id="usage-anchor">
@@ -4,6 +4,7 @@ import { PrimariaNavItem } from "./primaria-nav-item/primaria-nav-item";
4
4
  import { PrimariaNavTreeMenu } from "./primaria-nav-tree-menu/primaria-nav-tree-menu";
5
5
  import { PrimariaRichTextEditor } from "./primaria-text-editor/primaria-rich-text-editor";
6
6
  import { PrimariaCharacterLimitBadge } from "./primaria-character-limit-badge/primaria-character-limit-badge";
7
+ import { PrimariaRegion } from "./primaria-region";
7
8
 
8
9
  export const useSharedUI = () => {
9
10
  customElement("primaria-content-switcher")(PrimariaContentSwitcher);
@@ -11,4 +12,5 @@ export const useSharedUI = () => {
11
12
  customElement("primaria-rich-text-editor")(PrimariaRichTextEditor);
12
13
  customElement("primaria-nav-tree-menu")(PrimariaNavTreeMenu);
13
14
  customElement("primaria-character-limit-badge")(PrimariaCharacterLimitBadge);
15
+ customElement("primaria-region")(PrimariaRegion);
14
16
  };
@@ -0,0 +1 @@
1
+ export { PrimariaRegion } from "./primaria-region";
@@ -0,0 +1,145 @@
1
+ import { LitElement, html } from "lit";
2
+ import { property } from "lit/decorators.js";
3
+ import { IRegion } from "@uxland/regions";
4
+ import { PrimariaRegionHost } from "../../../api/api";
5
+ import { regionsProperty } from "@uxland/regions/region-decorator";
6
+
7
+ /**
8
+ * PrimariaRegion Web Component
9
+ *
10
+ * A plug-and-play region component that allows dynamic region creation without
11
+ * needing to extend PrimariaRegionHost or use the @region decorator manually.
12
+ *
13
+ * Renders in light DOM (no shadow-root) to allow region content to be properly
14
+ * displayed in the parent's DOM tree.
15
+ *
16
+ * @example
17
+ * ```html
18
+ * <primaria-region name="diagnostics-region"></primaria-region>
19
+ * ```
20
+ *
21
+ * This component internally handles:
22
+ * - Creating a container with the appropriate ID
23
+ * - Setting up the region definition
24
+ * - Managing the region lifecycle
25
+ */
26
+ export class PrimariaRegion extends PrimariaRegionHost(LitElement) {
27
+ /**
28
+ * The name of the region to create.
29
+ * This will be used both as the region name in the region manager
30
+ * and to generate the container ID.
31
+ */
32
+ @property({ type: String })
33
+ name = "";
34
+
35
+ /**
36
+ * Render in light DOM instead of shadow DOM.
37
+ * This allows the region content to be visible in the parent's DOM tree.
38
+ */
39
+ createRenderRoot() {
40
+ return this;
41
+ }
42
+
43
+ /**
44
+ * Override shadowRoot getter to return this (light DOM) instead of null.
45
+ * The region mixin tries to find elements using shadowRoot.querySelector(),
46
+ * so we need to make it work with light DOM.
47
+ */
48
+ get shadowRoot(): ShadowRoot | null {
49
+ return this as any;
50
+ }
51
+
52
+ /**
53
+ * The region instance created by the region host mixin.
54
+ * Plugins can inject content into this region using the region manager.
55
+ */
56
+ region: IRegion | undefined;
57
+
58
+ /**
59
+ * Virtual constructor for this instance to hold its own region definition.
60
+ * This prevents conflicts when multiple primaria-region instances exist.
61
+ */
62
+ private _instanceConstructor: any;
63
+
64
+ constructor() {
65
+ super();
66
+
67
+ // Create a unique constructor object for this instance
68
+ // This allows each instance to have its own region definition
69
+ // without affecting other instances of the same component
70
+ this._instanceConstructor = Object.create(this.constructor);
71
+
72
+ // Override the constructor property to return our instance constructor
73
+ Object.defineProperty(this, "constructor", {
74
+ get: () => this._instanceConstructor,
75
+ configurable: true,
76
+ });
77
+ }
78
+
79
+ /**
80
+ * Called when the component is connected to the DOM.
81
+ * Sets up the region definition before the parent connectedCallback runs.
82
+ */
83
+ connectedCallback(): void {
84
+ // First, call the base LitElement connectedCallback but NOT the mixin yet
85
+ // We need to do this in a special order
86
+ LitElement.prototype.connectedCallback.call(this);
87
+
88
+ if (this.name) {
89
+ const targetId = `${this.name}-container`;
90
+
91
+ // Create the container div immediately in the light DOM
92
+ const container = document.createElement("div");
93
+ container.id = targetId;
94
+ container.style.cssText = "width: 100%; height: 100%; min-height: 1px";
95
+ this.appendChild(container);
96
+
97
+ // Set the region metadata directly on the instance constructor
98
+ this._instanceConstructor[regionsProperty] = {
99
+ ...this._instanceConstructor[regionsProperty],
100
+ region: { targetId, name: this.name },
101
+ };
102
+
103
+ // The mixin creates regions in the `updated()` lifecycle, not in connectedCallback
104
+ // So we need to trigger the updated lifecycle or call createRegions directly
105
+ // Let's check if the component has the create method from the mixin
106
+ if ((this as any).create) {
107
+ (this as any).create();
108
+ }
109
+
110
+ // Also manually call the mixin's connectedCallback if it exists
111
+ const litProto = Object.getPrototypeOf(this);
112
+ const mixinProto = Object.getPrototypeOf(litProto);
113
+
114
+ if (mixinProto.connectedCallback) {
115
+ mixinProto.connectedCallback.call(this);
116
+ }
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Called before the component updates.
122
+ * Updates the region definition if the name changes.
123
+ */
124
+ protected willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
125
+ super.willUpdate(changedProperties);
126
+
127
+ // If the name changed after connection, update the region definition
128
+ if (this.name && changedProperties.has("name")) {
129
+ const targetId = `${this.name}-container`;
130
+ this._instanceConstructor[regionsProperty] = {
131
+ ...this._instanceConstructor[regionsProperty],
132
+ region: { targetId, name: this.name },
133
+ };
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Renders nothing because we create the container div manually in connectedCallback.
139
+ * This is necessary because the mixin needs the div to exist before it tries to create the region.
140
+ */
141
+ render() {
142
+ // Don't render anything - the container is created in connectedCallback
143
+ return html``;
144
+ }
145
+ }
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./api/api";
16
16
  export * from "./api/broker/primaria-broker";
17
17
  export * from "./UI/index";
18
18
  export { PrimariaNavItem } from "./UI/shared-components/primaria-nav-item/primaria-nav-item";
19
+ export { PrimariaRegion } from "./UI/shared-components/primaria-region";
19
20
  export {
20
21
  EcapEventManager,
21
22
  createEcapEventManager,