@usereq/widget 0.2.12 → 0.2.13
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/package.json
CHANGED
|
@@ -47,15 +47,6 @@ export class AgentWidgetElement extends HTMLElement {
|
|
|
47
47
|
private hostStyleElement: HTMLStyleElement;
|
|
48
48
|
private shadowStyleElement: HTMLStyleElement;
|
|
49
49
|
private mountElement: HTMLDivElement;
|
|
50
|
-
/**
|
|
51
|
-
* Dedicated container the fullscreen (mobile) chat panel portals into. It
|
|
52
|
-
* lives INSIDE the shadow root (so our styles apply) and is `fixed; inset:0`
|
|
53
|
-
* so the panel's `absolute inset-0` fills the viewport. Passing the raw
|
|
54
|
-
* shadow root instead would (a) be rejected as a non-Element portal target
|
|
55
|
-
* and (b) fall back to `document.body`, where our shadow-scoped CSS doesn't
|
|
56
|
-
* reach — which left the panel invisible on real sites.
|
|
57
|
-
*/
|
|
58
|
-
private portalElement: HTMLDivElement;
|
|
59
50
|
private root: Root;
|
|
60
51
|
private agentId = "";
|
|
61
52
|
private mode: "embed" | "preview" = "embed";
|
|
@@ -102,17 +93,10 @@ export class AgentWidgetElement extends HTMLElement {
|
|
|
102
93
|
this.mountElement.style.display = "block";
|
|
103
94
|
this.mountElement.style.width = "100%";
|
|
104
95
|
this.mountElement.style.height = "100%";
|
|
105
|
-
// Fullscreen portal target — viewport-sized + in the shadow root. Empty and
|
|
106
|
-
// click-through until the mobile panel mounts into it (the panel/overlay
|
|
107
|
-
// re-enable their own pointer events).
|
|
108
|
-
this.portalElement = document.createElement("div");
|
|
109
|
-
this.portalElement.style.cssText =
|
|
110
|
-
"position:fixed;inset:0;pointer-events:none;z-index:2147483647;";
|
|
111
96
|
this.shadowRootRef.append(
|
|
112
97
|
this.hostStyleElement,
|
|
113
98
|
this.shadowStyleElement,
|
|
114
99
|
this.mountElement,
|
|
115
|
-
this.portalElement,
|
|
116
100
|
);
|
|
117
101
|
this.root = createRoot(this.mountElement);
|
|
118
102
|
}
|
|
@@ -298,7 +282,12 @@ export class AgentWidgetElement extends HTMLElement {
|
|
|
298
282
|
onSendMessage: (content: string) => void this.sendMessage(content),
|
|
299
283
|
onConfirmationDecision: (confirmationId: string, accepted: boolean) =>
|
|
300
284
|
void this.handleConfirmationDecision(confirmationId, accepted),
|
|
301
|
-
|
|
285
|
+
// Portal directly into the shadow root — matches the legacy
|
|
286
|
+
// `agents-monorepo` widget exactly. ShadowRoot is a DocumentFragment,
|
|
287
|
+
// which Radix Dialog accepts as `container`. The earlier `portalElement`
|
|
288
|
+
// wrapper added a `pointer-events: none` ancestor that interfered with
|
|
289
|
+
// the Dialog overlay/content's own event handling.
|
|
290
|
+
portalContainer: this.shadowRootRef,
|
|
302
291
|
}),
|
|
303
292
|
);
|
|
304
293
|
}
|
|
@@ -178,7 +178,14 @@ export function WidgetRuntime({
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
const shellStyle = getWidgetShellStyle(mode, placement);
|
|
181
|
-
|
|
181
|
+
// Accept both HTMLElement (e.g. playground stage div) and DocumentFragment
|
|
182
|
+
// (e.g. the widget custom element's ShadowRoot). Radix Dialog handles both
|
|
183
|
+
// as portal containers.
|
|
184
|
+
const portalEl: HTMLElement | DocumentFragment | null =
|
|
185
|
+
portalContainer instanceof HTMLElement ||
|
|
186
|
+
portalContainer instanceof DocumentFragment
|
|
187
|
+
? portalContainer
|
|
188
|
+
: null;
|
|
182
189
|
|
|
183
190
|
return (
|
|
184
191
|
<>
|