@uxland/primary-shell 7.41.3 → 7.41.5

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.
@@ -60,6 +60,31 @@ export declare class PrimariaRegion extends PrimariaRegion_base {
60
60
  * Sets up the region definition before the parent connectedCallback runs.
61
61
  */
62
62
  connectedCallback(): void;
63
+ /**
64
+ * Mixin hook fired after `createRegions` finishes.
65
+ *
66
+ * Hydrates the freshly-created region with every view that has already been
67
+ * registered for this region name via `regionManager.registerViewWithRegion`.
68
+ * `registerViewWithRegion` only forwards to regions that exist at the moment
69
+ * of the call, so a plugin that registers once at `initialize` would lose
70
+ * its view every time the region is destroyed and re-created (e.g. when a
71
+ * drawer that hosts the region is closed and reopened). Pulling from the
72
+ * registry here makes injection transparent: any plugin can register once
73
+ * and any region with that name auto-populates.
74
+ */
75
+ regionsCreated(_regions: unknown): void;
76
+ /**
77
+ * Called when the component is removed from the DOM.
78
+ *
79
+ * The base mixin's `disconnectedCallback` removes the region from the manager
80
+ * but does NOT clear `this.region`, so on a later reconnect the mixin's
81
+ * `createRegions` sees `isNil(this.region) === false` and skips re-creating
82
+ * the region. That breaks the "drawer opens, closes, opens again" flow:
83
+ * the second open would render the host but never receive the plugin's
84
+ * view. Clear the reference (and drop the orphan container) so the next
85
+ * connect rebuilds everything from scratch.
86
+ */
87
+ disconnectedCallback(): void;
63
88
  /**
64
89
  * Called before the component updates.
65
90
  * Updates the region definition if the name changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.41.3",
3
+ "version": "7.41.5",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -1,6 +1,6 @@
1
1
  import { LitElement, html } from "lit";
2
2
  import { property } from "lit/decorators.js";
3
- import { IRegion } from "@uxland/regions";
3
+ import { IRegion, regionManager } from "@uxland/regions";
4
4
  import { PrimariaRegionHost } from "../../../api/api";
5
5
  import { regionsProperty } from "@uxland/regions/region-decorator";
6
6
 
@@ -130,6 +130,47 @@ export class PrimariaRegion extends PrimariaRegionHost(LitElement) {
130
130
  }
131
131
  }
132
132
 
133
+ /**
134
+ * Mixin hook fired after `createRegions` finishes.
135
+ *
136
+ * Hydrates the freshly-created region with every view that has already been
137
+ * registered for this region name via `regionManager.registerViewWithRegion`.
138
+ * `registerViewWithRegion` only forwards to regions that exist at the moment
139
+ * of the call, so a plugin that registers once at `initialize` would lose
140
+ * its view every time the region is destroyed and re-created (e.g. when a
141
+ * drawer that hosts the region is closed and reopened). Pulling from the
142
+ * registry here makes injection transparent: any plugin can register once
143
+ * and any region with that name auto-populates.
144
+ */
145
+ regionsCreated(_regions: unknown): void {
146
+ if (!this.region || !this.name) return;
147
+ const registered = regionManager.getRegisteredViews(this.name) ?? [];
148
+ for (const { key, view } of registered) {
149
+ if (this.region.containsView(key)) continue;
150
+ this.region.addView(key, view).catch((e) => {
151
+ console.warn(`primaria-region(${this.name}): failed to addView "${key}"`, e);
152
+ });
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Called when the component is removed from the DOM.
158
+ *
159
+ * The base mixin's `disconnectedCallback` removes the region from the manager
160
+ * but does NOT clear `this.region`, so on a later reconnect the mixin's
161
+ * `createRegions` sees `isNil(this.region) === false` and skips re-creating
162
+ * the region. That breaks the "drawer opens, closes, opens again" flow:
163
+ * the second open would render the host but never receive the plugin's
164
+ * view. Clear the reference (and drop the orphan container) so the next
165
+ * connect rebuilds everything from scratch.
166
+ */
167
+ disconnectedCallback(): void {
168
+ super.disconnectedCallback();
169
+ this.region = undefined;
170
+ const targetId = `${this.name}-container`;
171
+ this.querySelector(`#${targetId}`)?.remove();
172
+ }
173
+
133
174
  /**
134
175
  * Called before the component updates.
135
176
  * Updates the region definition if the name changes.