@runtypelabs/persona 3.2.1 → 3.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/persona",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Themeable, pluggable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -198,7 +198,7 @@ const applyDockStyles = (
198
198
  dockSlot.style.minWidth = "0";
199
199
  dockSlot.style.minHeight = "0";
200
200
  dockSlot.style.overflow = "hidden";
201
- dockSlot.style.zIndex = "9999";
201
+ dockSlot.style.zIndex = String(config?.launcher?.zIndex ?? 9999);
202
202
  dockSlot.style.transform = "none";
203
203
  dockSlot.style.transition = "none";
204
204
  dockSlot.style.pointerEvents = "auto";
package/src/types.ts CHANGED
@@ -790,6 +790,14 @@ export type AgentWidgetLauncherConfig = {
790
790
  * @default 640
791
791
  */
792
792
  mobileBreakpoint?: number;
793
+ /**
794
+ * CSS z-index applied to the widget wrapper when it is in a positioned mode
795
+ * (floating panel, mobile fullscreen, or sidebar). Increase this value if
796
+ * other elements on the host page appear on top of the widget.
797
+ *
798
+ * @default 9999 in overlay modes (mobile fullscreen / sidebar); 50 for the regular floating panel
799
+ */
800
+ zIndex?: number;
793
801
  callToActionIconText?: string;
794
802
  callToActionIconName?: string;
795
803
  callToActionIconColor?: string;
@@ -0,0 +1,62 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { afterEach, describe, expect, it } from "vitest";
4
+
5
+ import { createAgentExperience } from "./ui";
6
+
7
+ const originalInnerWidth = window.innerWidth;
8
+
9
+ const setInnerWidth = (value: number) => {
10
+ Object.defineProperty(window, "innerWidth", {
11
+ configurable: true,
12
+ writable: true,
13
+ value,
14
+ });
15
+ };
16
+
17
+ const createMount = () => {
18
+ const mount = document.createElement("div");
19
+ document.body.appendChild(mount);
20
+ return mount;
21
+ };
22
+
23
+ describe("createAgentExperience overlay z-index", () => {
24
+ afterEach(() => {
25
+ document.body.innerHTML = "";
26
+ setInnerWidth(originalInnerWidth);
27
+ });
28
+
29
+ it("defaults sidebar mode to the overlay z-index", () => {
30
+ const mount = createMount();
31
+ const controller = createAgentExperience(mount, {
32
+ apiUrl: "https://api.example.com/chat",
33
+ launcher: {
34
+ sidebarMode: true,
35
+ position: "bottom-right",
36
+ },
37
+ });
38
+
39
+ const wrapper = mount.firstElementChild as HTMLElement | null;
40
+
41
+ expect(wrapper).not.toBeNull();
42
+ expect(wrapper?.style.zIndex).toBe("9999");
43
+
44
+ controller.destroy();
45
+ });
46
+
47
+ it("defaults mobile fullscreen to the overlay z-index", () => {
48
+ setInnerWidth(480);
49
+
50
+ const mount = createMount();
51
+ const controller = createAgentExperience(mount, {
52
+ apiUrl: "https://api.example.com/chat",
53
+ });
54
+
55
+ const wrapper = mount.firstElementChild as HTMLElement | null;
56
+
57
+ expect(wrapper).not.toBeNull();
58
+ expect(wrapper?.style.zIndex).toBe("9999");
59
+
60
+ controller.destroy();
61
+ });
62
+ });
package/src/ui.ts CHANGED
@@ -1474,6 +1474,7 @@ export const createAgentExperience = (
1474
1474
  // Determine panel styling based on mode, with theme overrides
1475
1475
  const position = config.launcher?.position ?? 'bottom-left';
1476
1476
  const isLeftSidebar = position === 'bottom-left' || position === 'top-left';
1477
+ const overlayZIndex = config.launcher?.zIndex ?? 9999;
1477
1478
 
1478
1479
  // Default values based on mode
1479
1480
  let defaultPanelBorder = (sidebarMode || shouldGoFullscreen) ? 'none' : '1px solid var(--persona-border)';
@@ -1524,7 +1525,8 @@ export const createAgentExperience = (
1524
1525
  padding: 0 !important;
1525
1526
  display: flex !important;
1526
1527
  flex-direction: column !important;
1527
- z-index: inherit !important;
1528
+ z-index: ${overlayZIndex} !important;
1529
+ background-color: var(--persona-surface, #ffffff) !important;
1528
1530
  `;
1529
1531
 
1530
1532
  // Panel — fill wrapper, no radius/shadow
@@ -1690,6 +1692,7 @@ export const createAgentExperience = (
1690
1692
  padding: 0 !important;
1691
1693
  display: flex !important;
1692
1694
  flex-direction: column !important;
1695
+ z-index: ${overlayZIndex} !important;
1693
1696
  ${isLeftSidebar ? 'left: 0 !important; right: auto !important;' : 'left: auto !important; right: 0 !important;'}
1694
1697
  `;
1695
1698
 
@@ -1744,7 +1747,11 @@ export const createAgentExperience = (
1744
1747
  if (!isInlineEmbed && !dockedMode) {
1745
1748
  const maxHeightStyles = 'max-height: -moz-available !important; max-height: stretch !important;';
1746
1749
  const paddingStyles = sidebarMode ? '' : 'padding-top: 1.25em !important;';
1747
- wrapper.style.cssText += maxHeightStyles + paddingStyles;
1750
+ // Override z-index only when explicitly configured; otherwise the persona-z-50 class applies
1751
+ const zIndexStyles = !sidebarMode && config.launcher?.zIndex != null
1752
+ ? `z-index: ${config.launcher.zIndex} !important;`
1753
+ : '';
1754
+ wrapper.style.cssText += maxHeightStyles + paddingStyles + zIndexStyles;
1748
1755
  }
1749
1756
  };
1750
1757
  applyFullHeightStyles();