vpschatbotwidget 1.2.3 → 1.2.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.
- package/dist-lib/vps-chatbot.cjs +44 -44
- package/dist-lib/vps-chatbot.js +2319 -2319
- package/package.json +1 -1
- package/src/chatbot/core/ChatHeader.tsx +5 -2
- package/src/chatbot/core/ChatMessage.tsx +3 -1
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +18 -1
- package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +12 -11
- package/src/index.css +32 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpschatbotwidget",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is an Package for the chatbot widget ui for our customer portel . ",
|
|
6
6
|
"homepage": "https://github.com/dhineshkumar-natobotics/VPS-Chatbot-Widget#readme",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { ArrowLeft, Minus, RefreshCw, Volume2, VolumeX } from "lucide-react";
|
|
3
3
|
import { EnvBadge, type EnvStage } from "../../components/EnvBadge";
|
|
4
|
+
import vpsIconUrl from '../../vps-v.svg';
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
interface ChatHeaderProps {
|
|
6
8
|
title?: string;
|
|
@@ -17,7 +19,7 @@ interface ChatHeaderProps {
|
|
|
17
19
|
envPulse?: boolean;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
const SVGComponent = (props: React.SVGProps<SVGSVGElement> & { width?: string; height?: string
|
|
22
|
+
const SVGComponent = (props: React.SVGProps<SVGSVGElement> & { width?: string; height?: string, Color?: string }) => (
|
|
21
23
|
<svg
|
|
22
24
|
width={props.width || "24px"}
|
|
23
25
|
height={props.height || "24px"}
|
|
@@ -61,7 +63,8 @@ export const ChatHeader: React.FC<ChatHeaderProps> = ({
|
|
|
61
63
|
className="avatar-circle"
|
|
62
64
|
aria-hidden="true"
|
|
63
65
|
>
|
|
64
|
-
<SVGComponent width="16px" height="16px" color="white" />
|
|
66
|
+
{/* <SVGComponent width="16px" height="16px" color="white" /> */}
|
|
67
|
+
<img src={vpsIconUrl} alt="VPS Logo" style={{ width: '16px', height: '16px' }} />
|
|
65
68
|
</div>
|
|
66
69
|
<div>
|
|
67
70
|
<div className="chat-header-title-row">
|
|
@@ -15,6 +15,7 @@ import { AgentReasoning } from "./AgentReasoning";
|
|
|
15
15
|
import { GroundedSources } from "./GroundedSources";
|
|
16
16
|
|
|
17
17
|
import { useOptionalChatContext } from "./ChatContext";
|
|
18
|
+
import VPSIcon from '../../vps-v.svg'
|
|
18
19
|
|
|
19
20
|
interface ChatMessageProps {
|
|
20
21
|
message: ChatMessage;
|
|
@@ -42,7 +43,8 @@ export const ChatMessageBubble: React.FC<ChatMessageProps> = ({ message, onEdit
|
|
|
42
43
|
<Message align={isUser ? "end" : "start"}>
|
|
43
44
|
{message.role === "assistant" && (
|
|
44
45
|
<MessageAvatar className="avatar-circle" aria-hidden="true">
|
|
45
|
-
<BotMessageSquare size={15} />
|
|
46
|
+
{/* <BotMessageSquare size={15} /> */}
|
|
47
|
+
<img src={VPSIcon} alt="VPS Logo" style={{ width: '16px', height: '16px' }} />
|
|
46
48
|
</MessageAvatar>
|
|
47
49
|
)}
|
|
48
50
|
<MessageContent>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { EmbeddedChatbotPanel } from "./EmbeddedChatbotPanel";
|
|
3
3
|
import { EmbeddedChatbotTrigger } from "./EmbeddedChatbotTrigger";
|
|
4
4
|
import { type EnvStage } from "../../components/EnvBadge";
|
|
@@ -65,6 +65,23 @@ const EmbeddedChatbotView: React.FC<Omit<
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
// Push a history entry when the panel opens so the back button closes it.
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (isOpen) {
|
|
71
|
+
window.history.pushState({ vpsChatOpen: true }, "");
|
|
72
|
+
|
|
73
|
+
const handlePopState = () => {
|
|
74
|
+
setOpen(false);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
window.addEventListener("popstate", handlePopState);
|
|
78
|
+
return () => {
|
|
79
|
+
window.removeEventListener("popstate", handlePopState);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
}, [isOpen]);
|
|
84
|
+
|
|
68
85
|
return (
|
|
69
86
|
<>
|
|
70
87
|
{showTrigger && !isOpen && (
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import
|
|
2
|
+
import vpsIconUrl from "../../vps-v.svg";
|
|
3
3
|
|
|
4
4
|
const DRAG_THRESHOLD_PX = 5;
|
|
5
5
|
const EDGE_PADDING_PX = 8;
|
|
6
6
|
const POSITION_STORAGE_KEY = "vps-embedded-assistant-top";
|
|
7
|
+
const DEFAULT_TOP_PX = 16;
|
|
7
8
|
|
|
8
9
|
function clamp(value: number, min: number, max: number) {
|
|
9
10
|
return Math.min(max, Math.max(min, value));
|
|
@@ -56,6 +57,7 @@ export const EmbeddedChatbotTrigger: React.FC<EmbeddedChatbotTriggerProps> = ({
|
|
|
56
57
|
const topRef = useRef(top);
|
|
57
58
|
const suppressClickRef = useRef(false);
|
|
58
59
|
const [dragging, setDragging] = useState(false);
|
|
60
|
+
const [hovered, setHovered] = useState(false);
|
|
59
61
|
|
|
60
62
|
useEffect(() => {
|
|
61
63
|
topRef.current = top;
|
|
@@ -67,9 +69,7 @@ export const EmbeddedChatbotTrigger: React.FC<EmbeddedChatbotTriggerProps> = ({
|
|
|
67
69
|
|
|
68
70
|
const applyBounds = () => {
|
|
69
71
|
setTop((current) => {
|
|
70
|
-
const fallback =
|
|
71
|
-
current ??
|
|
72
|
-
Math.round(window.innerHeight / 2 - button.offsetHeight / 2);
|
|
72
|
+
const fallback = current ?? DEFAULT_TOP_PX;
|
|
73
73
|
const next = clampToViewport(fallback, button.offsetHeight);
|
|
74
74
|
topRef.current = next;
|
|
75
75
|
return next;
|
|
@@ -142,6 +142,8 @@ export const EmbeddedChatbotTrigger: React.FC<EmbeddedChatbotTriggerProps> = ({
|
|
|
142
142
|
onPointerMove={handlePointerMove}
|
|
143
143
|
onPointerUp={finishPointer}
|
|
144
144
|
onPointerCancel={finishPointer}
|
|
145
|
+
onMouseEnter={() => setHovered(true)}
|
|
146
|
+
onMouseLeave={() => setHovered(false)}
|
|
145
147
|
onClick={() => {
|
|
146
148
|
if (suppressClickRef.current) {
|
|
147
149
|
suppressClickRef.current = false;
|
|
@@ -152,16 +154,15 @@ export const EmbeddedChatbotTrigger: React.FC<EmbeddedChatbotTriggerProps> = ({
|
|
|
152
154
|
aria-expanded={false}
|
|
153
155
|
aria-controls="vps-embedded-chat-panel"
|
|
154
156
|
aria-label="Assistant"
|
|
155
|
-
className={`embedded-trigger-btn ${
|
|
156
|
-
|
|
157
|
-
}`}
|
|
157
|
+
className={`embedded-trigger-btn ${dragging ? "embedded-trigger-btn--grabbing" : "embedded-trigger-btn--grab"
|
|
158
|
+
}${hovered ? " embedded-trigger-btn--expanded" : " embedded-trigger-btn--collapsed"}`}
|
|
158
159
|
style={{
|
|
159
|
-
top: top ??
|
|
160
|
-
transform:
|
|
160
|
+
top: top ?? DEFAULT_TOP_PX,
|
|
161
|
+
transform: undefined,
|
|
161
162
|
}}
|
|
162
163
|
>
|
|
163
|
-
<
|
|
164
|
-
Assistant
|
|
164
|
+
<img src={vpsIconUrl} alt="" className="embedded-trigger-icon" aria-hidden="true" />
|
|
165
|
+
<span className="embedded-trigger-label">Assistant</span>
|
|
165
166
|
</button>
|
|
166
167
|
);
|
|
167
168
|
};
|
package/src/index.css
CHANGED
|
@@ -784,7 +784,7 @@ button {
|
|
|
784
784
|
align-items: center;
|
|
785
785
|
justify-content: center;
|
|
786
786
|
border-radius: 50%;
|
|
787
|
-
background-color: var(--
|
|
787
|
+
background-color: var(--action);
|
|
788
788
|
color: var(--text-on-action);
|
|
789
789
|
flex-shrink: 0;
|
|
790
790
|
}
|
|
@@ -1959,9 +1959,10 @@ button {
|
|
|
1959
1959
|
pointer-events: none;
|
|
1960
1960
|
}
|
|
1961
1961
|
|
|
1962
|
+
/* On desktop: keep overlay for outside-click detection but hide the dim */
|
|
1962
1963
|
@media (min-width: 640px) {
|
|
1963
1964
|
.embedded-overlay {
|
|
1964
|
-
|
|
1965
|
+
background-color: transparent;
|
|
1965
1966
|
}
|
|
1966
1967
|
}
|
|
1967
1968
|
|
|
@@ -2018,13 +2019,35 @@ button {
|
|
|
2018
2019
|
color: var(--text-on-action);
|
|
2019
2020
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
|
2020
2021
|
touch-action: none;
|
|
2021
|
-
transition: background 0.15s;
|
|
2022
|
+
transition: background 0.15s, max-width 0.22s ease, padding 0.22s ease;
|
|
2023
|
+
overflow: hidden;
|
|
2024
|
+
max-width: 44px; /* icon-only by default */
|
|
2022
2025
|
}
|
|
2023
2026
|
|
|
2027
|
+
/* label text — hidden when collapsed */
|
|
2028
|
+
.embedded-trigger-label {
|
|
2029
|
+
white-space: nowrap;
|
|
2030
|
+
overflow: hidden;
|
|
2031
|
+
opacity: 0;
|
|
2032
|
+
max-width: 0;
|
|
2033
|
+
transition: opacity 0.18s ease, max-width 0.22s ease;
|
|
2034
|
+
pointer-events: none;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
/* Hover: expand to show full label */
|
|
2038
|
+
.embedded-trigger-btn--expanded,
|
|
2024
2039
|
.embedded-trigger-btn:hover {
|
|
2040
|
+
max-width: 160px;
|
|
2025
2041
|
background-color: var(--action-hover);
|
|
2026
2042
|
}
|
|
2027
2043
|
|
|
2044
|
+
.embedded-trigger-btn--expanded .embedded-trigger-label,
|
|
2045
|
+
.embedded-trigger-btn:hover .embedded-trigger-label {
|
|
2046
|
+
opacity: 1;
|
|
2047
|
+
max-width: 120px;
|
|
2048
|
+
pointer-events: auto;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2028
2051
|
.embedded-trigger-btn:focus-visible {
|
|
2029
2052
|
outline: 2px solid var(--primary);
|
|
2030
2053
|
outline-offset: 0;
|
|
@@ -2038,6 +2061,12 @@ button {
|
|
|
2038
2061
|
cursor: grabbing;
|
|
2039
2062
|
}
|
|
2040
2063
|
|
|
2064
|
+
.embedded-trigger-icon {
|
|
2065
|
+
width: 22px;
|
|
2066
|
+
height: 24px;
|
|
2067
|
+
flex-shrink: 0;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2041
2070
|
/* ── MessageScroller ─────────────────────────────────────────── */
|
|
2042
2071
|
.msg-scroller-root {
|
|
2043
2072
|
position: relative;
|