vpschatbotwidget 1.2.3 → 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 +1706 -1704
- package/package.json +1 -1
- package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +11 -10
- package/src/index.css +23 -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",
|
|
@@ -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
|
@@ -2018,13 +2018,35 @@ button {
|
|
|
2018
2018
|
color: var(--text-on-action);
|
|
2019
2019
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
|
2020
2020
|
touch-action: none;
|
|
2021
|
-
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;
|
|
2022
2034
|
}
|
|
2023
2035
|
|
|
2036
|
+
/* Hover: expand to show full label */
|
|
2037
|
+
.embedded-trigger-btn--expanded,
|
|
2024
2038
|
.embedded-trigger-btn:hover {
|
|
2039
|
+
max-width: 160px;
|
|
2025
2040
|
background-color: var(--action-hover);
|
|
2026
2041
|
}
|
|
2027
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
|
+
|
|
2028
2050
|
.embedded-trigger-btn:focus-visible {
|
|
2029
2051
|
outline: 2px solid var(--primary);
|
|
2030
2052
|
outline-offset: 0;
|