vpschatbotwidget 1.2.2 → 1.2.4
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 +45 -45
- package/dist-lib/vps-chatbot.js +1616 -1614
- package/package.json +1 -1
- package/src/chatbot/core/ChatMessageList.tsx +7 -1
- package/src/chatbot/core/ChatProvider.tsx +3 -1
- package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +11 -10
- package/src/index.css +49 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpschatbotwidget",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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",
|
|
@@ -10,12 +10,18 @@ import {
|
|
|
10
10
|
import { useChatbot } from "../hooks/useChatbot";
|
|
11
11
|
import { ChatEmptyState } from "./ChatEmptyState";
|
|
12
12
|
import { ChatMessageBubble } from "./ChatMessage";
|
|
13
|
+
import { ChatSuggestions } from "./ChatSuggestions";
|
|
14
|
+
import type { Suggestion } from "../api/chatbot-types";
|
|
13
15
|
|
|
14
16
|
export const ChatMessageList: React.FC<{ onEdit?: (text: string) => void }> = ({ onEdit }) => {
|
|
15
|
-
const { messages, status } = useChatbot();
|
|
17
|
+
const { messages, status, suggestions, showSuggestions, sendMessage } = useChatbot();
|
|
16
18
|
const isBusy = status === "awaiting" || status === "connecting";
|
|
17
19
|
const visibleMessages = messages.filter((message) => message.status !== "error");
|
|
18
20
|
|
|
21
|
+
// const handleSuggestionSelect = (suggestion: Suggestion) => {
|
|
22
|
+
// void sendMessage(suggestion.query);
|
|
23
|
+
// };
|
|
24
|
+
|
|
19
25
|
return (
|
|
20
26
|
<MessageScrollerProvider
|
|
21
27
|
autoScroll
|
|
@@ -403,8 +403,10 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
403
403
|
suggestions,
|
|
404
404
|
showSuggestions:
|
|
405
405
|
!disableSuggestions &&
|
|
406
|
+
status === "idle" &&
|
|
406
407
|
(messages.length === 0 ||
|
|
407
|
-
(messages.length === 1 && messages[0].id === "welcome-default")
|
|
408
|
+
(messages.length === 1 && messages[0].id === "welcome-default") ||
|
|
409
|
+
messages.some((m) => m.role === "assistant" && m.status === "complete" && !m.id.startsWith("welcome"))),
|
|
408
410
|
suggestionBadgesEnabled: !disableSuggestions,
|
|
409
411
|
userContext: effectiveUserContext,
|
|
410
412
|
apiBaseUrl: client.apiBaseUrl,
|
|
@@ -4,6 +4,7 @@ import { MessageSquare } from "lucide-react";
|
|
|
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
|
-
<MessageSquare size={
|
|
164
|
-
Assistant
|
|
164
|
+
<MessageSquare size={18} />
|
|
165
|
+
<span className="embedded-trigger-label">Assistant</span>
|
|
165
166
|
</button>
|
|
166
167
|
);
|
|
167
168
|
};
|
package/src/index.css
CHANGED
|
@@ -1637,6 +1637,32 @@ button {
|
|
|
1637
1637
|
justify-content: flex-start;
|
|
1638
1638
|
}
|
|
1639
1639
|
|
|
1640
|
+
/* Post-reply suggestion block shown after last assistant message */
|
|
1641
|
+
.chat-post-reply-suggestions {
|
|
1642
|
+
padding: 4px 0 8px;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
.chat-post-reply-suggestions .suggestions-list {
|
|
1646
|
+
margin-top: 4px;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
.chat-post-reply-suggestions .vps-ui-button {
|
|
1650
|
+
background-color: var(--card-bg);
|
|
1651
|
+
border-color: var(--border-light);
|
|
1652
|
+
color: var(--text-main);
|
|
1653
|
+
font-size: 12.5px;
|
|
1654
|
+
font-weight: 500;
|
|
1655
|
+
text-align: left;
|
|
1656
|
+
border-radius: 10px;
|
|
1657
|
+
transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
.chat-post-reply-suggestions .vps-ui-button:hover:not(:disabled) {
|
|
1661
|
+
border-color: var(--primary);
|
|
1662
|
+
background-color: var(--orange-50);
|
|
1663
|
+
box-shadow: 0 1px 4px rgba(255, 71, 23, 0.1);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1640
1666
|
/* ── Inline citations ─────────────────────────────────────────── */
|
|
1641
1667
|
.inline-citation {
|
|
1642
1668
|
display: inline-block;
|
|
@@ -1992,13 +2018,35 @@ button {
|
|
|
1992
2018
|
color: var(--text-on-action);
|
|
1993
2019
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
|
1994
2020
|
touch-action: none;
|
|
1995
|
-
transition: background 0.15s;
|
|
2021
|
+
transition: background 0.15s, max-width 0.22s ease, padding 0.22s ease;
|
|
2022
|
+
overflow: hidden;
|
|
2023
|
+
max-width: 44px; /* icon-only by default */
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/* label text — hidden when collapsed */
|
|
2027
|
+
.embedded-trigger-label {
|
|
2028
|
+
white-space: nowrap;
|
|
2029
|
+
overflow: hidden;
|
|
2030
|
+
opacity: 0;
|
|
2031
|
+
max-width: 0;
|
|
2032
|
+
transition: opacity 0.18s ease, max-width 0.22s ease;
|
|
2033
|
+
pointer-events: none;
|
|
1996
2034
|
}
|
|
1997
2035
|
|
|
2036
|
+
/* Hover: expand to show full label */
|
|
2037
|
+
.embedded-trigger-btn--expanded,
|
|
1998
2038
|
.embedded-trigger-btn:hover {
|
|
2039
|
+
max-width: 160px;
|
|
1999
2040
|
background-color: var(--action-hover);
|
|
2000
2041
|
}
|
|
2001
2042
|
|
|
2043
|
+
.embedded-trigger-btn--expanded .embedded-trigger-label,
|
|
2044
|
+
.embedded-trigger-btn:hover .embedded-trigger-label {
|
|
2045
|
+
opacity: 1;
|
|
2046
|
+
max-width: 120px;
|
|
2047
|
+
pointer-events: auto;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2002
2050
|
.embedded-trigger-btn:focus-visible {
|
|
2003
2051
|
outline: 2px solid var(--primary);
|
|
2004
2052
|
outline-offset: 0;
|