@skippr/live-agent-sdk 0.73.0 → 0.74.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.
- package/dist/esm/lib-exports.js +26 -11
- package/dist/skippr-sdk.js +113 -113
- package/dist/types/components/LiveAgent.d.ts +2 -0
- package/dist/types/lib/launcher.d.ts +2 -0
- package/package.json +1 -1
package/dist/esm/lib-exports.js
CHANGED
|
@@ -851,6 +851,15 @@ function clampLauncherBottom(px) {
|
|
|
851
851
|
const maxBottom = window.innerHeight - LAUNCHER_HEIGHT_PX - VIEWPORT_MARGIN_PX;
|
|
852
852
|
return Math.round(Math.min(Math.max(px, VIEWPORT_MARGIN_PX), maxBottom));
|
|
853
853
|
}
|
|
854
|
+
function verticalAlignToBottomPx(align) {
|
|
855
|
+
if (align === "top") {
|
|
856
|
+
return clampLauncherBottom(window.innerHeight - LAUNCHER_HEIGHT_PX - DEFAULT_LAUNCHER_BOTTOM_PX);
|
|
857
|
+
}
|
|
858
|
+
if (align === "middle") {
|
|
859
|
+
return clampLauncherBottom(window.innerHeight / 2 - LAUNCHER_HEIGHT_PX / 2);
|
|
860
|
+
}
|
|
861
|
+
return clampLauncherBottom(DEFAULT_LAUNCHER_BOTTOM_PX);
|
|
862
|
+
}
|
|
854
863
|
function launcherPopsDown(bottomPx) {
|
|
855
864
|
return bottomPx + LAUNCHER_HEIGHT_PX / 2 > window.innerHeight / 2;
|
|
856
865
|
}
|
|
@@ -5587,6 +5596,14 @@ function SidebarTrigger() {
|
|
|
5587
5596
|
|
|
5588
5597
|
// src/components/LiveAgent.tsx
|
|
5589
5598
|
import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5599
|
+
function readSavedLauncherBottom() {
|
|
5600
|
+
try {
|
|
5601
|
+
const saved = Number.parseInt(localStorage.getItem("skippr_widget_bottom") ?? "", 10);
|
|
5602
|
+
return Number.isFinite(saved) && saved > 0 ? saved : null;
|
|
5603
|
+
} catch {
|
|
5604
|
+
return null;
|
|
5605
|
+
}
|
|
5606
|
+
}
|
|
5590
5607
|
function AgentCursorMount({ animated }) {
|
|
5591
5608
|
return /* @__PURE__ */ jsx22(AgentCursor, {
|
|
5592
5609
|
target: useAgentCursor(),
|
|
@@ -5613,6 +5630,7 @@ function LiveAgent(props) {
|
|
|
5613
5630
|
getUserToken,
|
|
5614
5631
|
userToken,
|
|
5615
5632
|
position = "right",
|
|
5633
|
+
verticalAlign = "bottom",
|
|
5616
5634
|
variant = "floating",
|
|
5617
5635
|
minimizable = true,
|
|
5618
5636
|
defaultOpen = false,
|
|
@@ -5779,16 +5797,13 @@ function LiveAgent(props) {
|
|
|
5779
5797
|
localStorage.setItem("skippr_widget_position", pos);
|
|
5780
5798
|
} catch {}
|
|
5781
5799
|
}, []);
|
|
5782
|
-
const
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
return clampLauncherBottom(saved);
|
|
5787
|
-
} catch {}
|
|
5788
|
-
return DEFAULT_LAUNCHER_BOTTOM_PX;
|
|
5789
|
-
});
|
|
5800
|
+
const savedLauncherBottom = readSavedLauncherBottom();
|
|
5801
|
+
const hasDraggedRef = useRef17(savedLauncherBottom !== null);
|
|
5802
|
+
const verticalAlignRef = useRef17(verticalAlign);
|
|
5803
|
+
const [launcherBottomPx, setLauncherBottomPxState] = useState18(() => savedLauncherBottom !== null ? clampLauncherBottom(savedLauncherBottom) : verticalAlignToBottomPx(verticalAlign));
|
|
5790
5804
|
const [popsDown, setPopsDown] = useState18(() => launcherPopsDown(launcherBottomPx));
|
|
5791
5805
|
const setLauncherBottomPx = useCallback15((px) => {
|
|
5806
|
+
hasDraggedRef.current = true;
|
|
5792
5807
|
setLauncherBottomPxState(px);
|
|
5793
5808
|
setPopsDown(launcherPopsDown(px));
|
|
5794
5809
|
try {
|
|
@@ -5803,9 +5818,9 @@ function LiveAgent(props) {
|
|
|
5803
5818
|
}, [setPositionWithPersist, setLauncherBottomPx]);
|
|
5804
5819
|
useEffect25(() => {
|
|
5805
5820
|
const syncToViewport = () => {
|
|
5806
|
-
const
|
|
5807
|
-
setLauncherBottomPxState(
|
|
5808
|
-
setPopsDown(launcherPopsDown(
|
|
5821
|
+
const next = hasDraggedRef.current ? clampLauncherBottom(launcherBottomPxRef.current) : verticalAlignToBottomPx(verticalAlignRef.current);
|
|
5822
|
+
setLauncherBottomPxState(next);
|
|
5823
|
+
setPopsDown(launcherPopsDown(next));
|
|
5809
5824
|
};
|
|
5810
5825
|
syncToViewport();
|
|
5811
5826
|
window.addEventListener("resize", syncToViewport);
|