@runtypelabs/persona 3.2.0 → 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/dist/index.cjs +25 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.global.js +45 -43
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/runtime/host-layout.ts +1 -1
- package/src/types.ts +8 -0
- package/src/ui.overlay-z-index.test.ts +62 -0
- package/src/ui.ts +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/persona",
|
|
3
|
-
"version": "3.2.
|
|
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",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
|
-
"build": "rimraf dist &&
|
|
73
|
+
"build": "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer",
|
|
74
74
|
"build:styles": "node -e \"const fs=require('fs');fs.mkdirSync('dist',{recursive:true});fs.copyFileSync('src/styles/widget.css','dist/widget.css');\"",
|
|
75
75
|
"build:client": "tsup src/index.ts --format esm,cjs,iife --global-name AgentWidget --minify --sourcemap --splitting false --dts --loader \".css=text\"",
|
|
76
76
|
"build:installer": "tsup src/install.ts --format iife --global-name SiteAgentInstaller --out-dir dist --minify --sourcemap --no-splitting",
|
|
@@ -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 =
|
|
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:
|
|
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
|
-
|
|
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();
|