@schandlergarcia/sf-web-components 2.3.12 โ†’ 2.3.13

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/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.3.13] - 2026-04-14
9
+
10
+ ### Changed
11
+ - **Rewrote AgentPanel demo script to Partner Upsell story** โ€” Replaced the penalties placeholder conversation with the full 3-prompt demo flow: (1) User asks about a canceled block booking at Summit Austin Convention Center, Eva surfaces cancellation details (TechCorp, 40 rooms, $24k lost revenue); (2) User asks what can be done, Eva pivots to SDR mode and presents a rich Engine Network Promotion offer card with $159/night rate, 8% commission, projected 70% fill / $12,287 net; (3) User accepts, Eva launches the promo and confirms with a PROMO-SUM-0519 confirmation. Increased typing delay cap to 5.5s for longer card-style messages.
12
+
8
13
  ## [2.3.12] - 2026-04-13
9
14
 
10
15
  ### Changed
@@ -0,0 +1,402 @@
1
+ import React, { useState, useRef, useEffect, useCallback } from "react";
2
+ import { createPortal } from "react-dom";
3
+ import { SparklesIcon } from "@heroicons/react/24/solid";
4
+ import {
5
+ PaperAirplaneIcon,
6
+ ChevronDownIcon,
7
+ } from "@heroicons/react/24/outline";
8
+
9
+ interface Message {
10
+ id: string;
11
+ role: "user" | "agent";
12
+ text: string;
13
+ timestamp: string;
14
+ }
15
+
16
+ interface ScriptStep {
17
+ role: "user" | "agent";
18
+ text: string;
19
+ }
20
+
21
+ const SCRIPT: ScriptStep[] = [
22
+ // --- Auto-play greeting ---
23
+ {
24
+ role: "agent",
25
+ text: "Hi Jamie! ๐Ÿ‘‹ I'm Eva, your Engine partner assistant. How can I help you today?",
26
+ },
27
+
28
+ // --- Prompt 1: Ask about the canceled booking ---
29
+ {
30
+ role: "user",
31
+ text: "I just got an alert that a block booking was canceled at our Austin Convention Center for next week. What happened?",
32
+ },
33
+ {
34
+ role: "agent",
35
+ text: "Let me pull up that reservation for you...",
36
+ },
37
+ {
38
+ role: "agent",
39
+ text: "๐Ÿ”ด CANCELED BOOKING\n\n๐Ÿจ Summit Austin Convention Center\n๐Ÿข Client: TechCorp Inc.\n\n๐Ÿ“‹ Details:\nโ€ข Original block: 40 rooms\nโ€ข Dates: May 19 โ€“ 21 (3 nights)\nโ€ข Room rate: $200/night\nโ€ข Lost revenue: $24,000\n\n๐Ÿ“… Canceled: Apr 11, 2026\nโš ๏ธ Status: Within penalty window",
40
+ },
41
+ {
42
+ role: "agent",
43
+ text: "TechCorp canceled their 40-room block for May 19โ€“21. The reason given was that their annual conference is moving to a virtual format this year. This was within the attrition penalty window, so a penalty may apply โ€” but that still leaves 40 rooms open for next week.",
44
+ },
45
+
46
+ // --- Prompt 2: What can be done ---
47
+ {
48
+ role: "user",
49
+ text: "That's a lot of empty rooms. Is there anything we can do to fill them on short notice?",
50
+ },
51
+ {
52
+ role: "agent",
53
+ text: "Actually, yes โ€” I have an idea. Let me put together an option for you.",
54
+ },
55
+ {
56
+ role: "agent",
57
+ text: "โšก ENGINE NETWORK PROMOTION\nFill your open rooms through Engine's network\n\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\nSummit Austin Convention Center\n40 rooms ยท May 19โ€“21 ยท 3 nights\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n\n๐Ÿ’ฐ YOUR RATE\n$159/night (20% off rack rate)\n\n๐Ÿ“ก ENGINE PROMOTES TO\n2,400+ corporate travel managers\n\n๐Ÿ“‰ COMMISSION\n12% standard โ†’ 8% promotional\nYou save $1,526 vs. standard bookings\n\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n๐Ÿ“ˆ PROJECTED OUTCOME\nโ€ข Est. fill: 28 rooms (70%)\nโ€ข Revenue: $13,356\nโ€ข Net after commission: $12,287\nโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”",
58
+ },
59
+ {
60
+ role: "agent",
61
+ text: "Here's the play: we run a targeted promotion across Engine's corporate travel network โ€” 2,400+ travel managers get notified about discounted rates at Summit Austin for May 19โ€“21.\n\nWe'd list the rooms at $159/night, and your commission drops from 12% to 8% for promo bookings. On a projected 70% fill, that's $12,287 net โ€” versus $0 if the rooms sit empty.\n\nWant to launch it?",
62
+ },
63
+
64
+ // --- Prompt 3: Accept the offer ---
65
+ {
66
+ role: "user",
67
+ text: "That makes sense โ€” empty rooms earn nothing. Let's launch it.",
68
+ },
69
+ {
70
+ role: "agent",
71
+ text: "Launching your promotion now...",
72
+ },
73
+ {
74
+ role: "agent",
75
+ text: "โœ… PROMOTION LIVE\n\n๐Ÿ†” PROMO-SUM-0519\n๐Ÿจ Summit Austin Convention Center\n๐Ÿ“… May 19โ€“21 (3 nights)\n๐Ÿ’ฐ Rate: $159/night\n๐Ÿ“‰ Commission: 8% (promotional)\n๐Ÿ“ก Distribution: Engine corporate travel network\n\nYour promotion is live and going out to 2,400+ travel managers now. I'll send you a fill-rate update in 48 hours.",
76
+ },
77
+ ];
78
+
79
+ function typingDelay(text: string): number {
80
+ const base = 900;
81
+ const perChar = 10;
82
+ const jitter = Math.random() * 500;
83
+ return Math.min(base + text.length * perChar + jitter, 5500);
84
+ }
85
+
86
+ function now() {
87
+ return new Date().toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
88
+ }
89
+
90
+ function TypingIndicator() {
91
+ return (
92
+ <div className="flex items-center gap-1 px-4 py-1.5">
93
+ <div className="flex items-end gap-3">
94
+ <div className="flex-shrink-0 h-7 w-7 rounded-full bg-[var(--color-dash-dark)] flex items-center justify-center">
95
+ <SparklesIcon className="h-3.5 w-3.5 text-white" />
96
+ </div>
97
+ <div className="bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/20 rounded-2xl rounded-bl-md px-4 py-3">
98
+ <div className="flex items-center gap-1.5">
99
+ <span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "0ms" }} />
100
+ <span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "150ms" }} />
101
+ <span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "300ms" }} />
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ );
107
+ }
108
+
109
+ function AgentMessage({ text, timestamp }: { text: string; timestamp: string }) {
110
+ return (
111
+ <div className="px-4 py-1.5">
112
+ <div className="flex items-end gap-3">
113
+ <div className="flex-shrink-0 h-7 w-7 rounded-full bg-[var(--color-dash-dark)] flex items-center justify-center">
114
+ <SparklesIcon className="h-3.5 w-3.5 text-white" />
115
+ </div>
116
+ <div className="max-w-[80%]">
117
+ <div className="bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/20 rounded-2xl rounded-bl-md px-4 py-3 border border-[var(--color-dash-border)]/30 dark:border-[var(--color-dash-muted)]/30">
118
+ <p className="text-sm text-[var(--color-dash-text)] dark:text-white leading-relaxed whitespace-pre-wrap">
119
+ {text}
120
+ </p>
121
+ </div>
122
+ <p className="text-[10px] text-[var(--color-dash-label)] mt-1 ml-1">{timestamp}</p>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ );
127
+ }
128
+
129
+ function UserMessage({ text, timestamp }: { text: string; timestamp: string }) {
130
+ return (
131
+ <div className="px-4 py-1.5">
132
+ <div className="flex items-end justify-end gap-3">
133
+ <div className="max-w-[80%]">
134
+ <div className="bg-[var(--color-dash-accent)] rounded-2xl rounded-br-md px-4 py-3">
135
+ <p className="text-sm text-white leading-relaxed">{text}</p>
136
+ </div>
137
+ <p className="text-[10px] text-[var(--color-dash-label)] mt-1 text-right mr-1">{timestamp}</p>
138
+ </div>
139
+ </div>
140
+ </div>
141
+ );
142
+ }
143
+
144
+ export default function AgentPanel() {
145
+ const [isOpen, setIsOpen] = useState(false);
146
+ const [messages, setMessages] = useState<Message[]>([]);
147
+ const [isTyping, setIsTyping] = useState(false);
148
+ const [inputValue, setInputValue] = useState("");
149
+ const [scriptIndex, setScriptIndex] = useState(0);
150
+ const [isAnimating, setIsAnimating] = useState(false);
151
+ const hasStartedRef = useRef(false);
152
+ const messagesEndRef = useRef<HTMLDivElement>(null);
153
+ const inputRef = useRef<HTMLInputElement>(null);
154
+
155
+ useEffect(() => {
156
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
157
+ }, [messages, isTyping]);
158
+
159
+ useEffect(() => {
160
+ if (isOpen) {
161
+ setTimeout(() => inputRef.current?.focus(), 300);
162
+ }
163
+ }, [isOpen]);
164
+
165
+ // Auto-play the first agent message when panel opens
166
+ useEffect(() => {
167
+ if (isOpen && !hasStartedRef.current && scriptIndex === 0) {
168
+ hasStartedRef.current = true;
169
+ playNextStep();
170
+ }
171
+ }, [isOpen]);
172
+
173
+ const playNextStep = useCallback(async () => {
174
+ if (scriptIndex >= SCRIPT.length || isAnimating) return;
175
+
176
+ const step = SCRIPT[scriptIndex];
177
+ setIsAnimating(true);
178
+
179
+ if (step.role === "agent") {
180
+ setIsTyping(true);
181
+ await delay(typingDelay(step.text));
182
+ setIsTyping(false);
183
+ }
184
+
185
+ const msg: Message = {
186
+ id: `msg-${Date.now()}`,
187
+ role: step.role,
188
+ text: step.text,
189
+ timestamp: now(),
190
+ };
191
+ setMessages((prev) => [...prev, msg]);
192
+ setScriptIndex((prev) => prev + 1);
193
+ setIsAnimating(false);
194
+
195
+ // If we just played a user message, auto-play all following agent messages
196
+ const nextIndex = scriptIndex + 1;
197
+ if (step.role === "user" && nextIndex < SCRIPT.length && SCRIPT[nextIndex].role === "agent") {
198
+ await delay(400);
199
+ await playAgentChain(nextIndex);
200
+ }
201
+ }, [scriptIndex, isAnimating]);
202
+
203
+ async function playAgentChain(startIndex: number) {
204
+ let idx = startIndex;
205
+ setIsAnimating(true);
206
+ while (idx < SCRIPT.length && SCRIPT[idx].role === "agent") {
207
+ const step = SCRIPT[idx];
208
+ setIsTyping(true);
209
+ await delay(typingDelay(step.text));
210
+ setIsTyping(false);
211
+
212
+ const msg: Message = {
213
+ id: `msg-${Date.now()}-${idx}`,
214
+ role: "agent",
215
+ text: step.text,
216
+ timestamp: now(),
217
+ };
218
+ setMessages((prev) => [...prev, msg]);
219
+ setScriptIndex(idx + 1);
220
+ idx++;
221
+ if (idx < SCRIPT.length && SCRIPT[idx].role === "agent") {
222
+ await delay(500);
223
+ }
224
+ }
225
+ setIsAnimating(false);
226
+ }
227
+
228
+ // Right arrow key stages the next user message into the input
229
+ useEffect(() => {
230
+ function onKey(e: KeyboardEvent) {
231
+ if (e.key === "ArrowRight" && isOpen && !isAnimating && scriptIndex < SCRIPT.length) {
232
+ e.preventDefault();
233
+ const next = SCRIPT[scriptIndex];
234
+ if (next.role === "user") {
235
+ setInputValue(next.text);
236
+ inputRef.current?.focus();
237
+ }
238
+ }
239
+ }
240
+ document.addEventListener("keydown", onKey);
241
+ return () => document.removeEventListener("keydown", onKey);
242
+ }, [isOpen, scriptIndex, isAnimating]);
243
+
244
+ function handleSend() {
245
+ const text = inputValue.trim();
246
+ if (!text) return;
247
+ setInputValue("");
248
+
249
+ // Check if this matches the next scripted user message
250
+ if (scriptIndex < SCRIPT.length && SCRIPT[scriptIndex].role === "user" && text === SCRIPT[scriptIndex].text) {
251
+ playNextStep();
252
+ return;
253
+ }
254
+
255
+ const userMsg: Message = {
256
+ id: `u-${Date.now()}`,
257
+ role: "user",
258
+ text,
259
+ timestamp: now(),
260
+ };
261
+ setMessages((prev) => [...prev, userMsg]);
262
+
263
+ setIsTyping(true);
264
+ setTimeout(() => {
265
+ setIsTyping(false);
266
+ const agentMsg: Message = {
267
+ id: `a-${Date.now()}`,
268
+ role: "agent",
269
+ text: "I'm looking into that for you โ€” one moment please.",
270
+ timestamp: now(),
271
+ };
272
+ setMessages((prev) => [...prev, agentMsg]);
273
+ }, 1500);
274
+ }
275
+
276
+ const scriptDone = scriptIndex >= SCRIPT.length;
277
+
278
+ const panel = isOpen
279
+ ? createPortal(
280
+ <>
281
+ <div
282
+ className="fixed inset-0 z-[9998] bg-black/20 backdrop-blur-sm lg:hidden"
283
+ onClick={() => setIsOpen(false)}
284
+ />
285
+ <div
286
+ className="fixed z-[9999] bottom-6 right-6 w-[380px] h-[520px] flex flex-col rounded-2xl shadow-2xl border border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 overflow-hidden"
287
+ style={{
288
+ animation: "agent-panel-in 0.25s cubic-bezier(0.16, 1, 0.3, 1)",
289
+ }}
290
+ >
291
+ {/* Header */}
292
+ <div className="bg-[var(--color-dash-dark)] px-5 py-4 flex items-center justify-between flex-shrink-0">
293
+ <div className="flex items-center gap-3">
294
+ <div className="h-8 w-8 rounded-full bg-white/10 flex items-center justify-center">
295
+ <SparklesIcon className="h-4 w-4 text-white" />
296
+ </div>
297
+ <div>
298
+ <h3 className="text-sm font-semibold text-white">
299
+ Engine Virtual Agent
300
+ </h3>
301
+ <p className="text-xs text-white/60">Eva ยท Online</p>
302
+ </div>
303
+ </div>
304
+ <button
305
+ onClick={() => setIsOpen(false)}
306
+ className="rounded-lg p-1.5 text-white/60 hover:text-white hover:bg-white/10 transition-colors"
307
+ >
308
+ <ChevronDownIcon className="h-5 w-5" />
309
+ </button>
310
+ </div>
311
+
312
+ {/* Messages */}
313
+ <div className="flex-1 overflow-y-auto bg-white dark:bg-[var(--color-dash-text)] py-4">
314
+ {messages.length === 0 && !isTyping && (
315
+ <div className="flex flex-col items-center justify-center h-full gap-3 px-6 text-center">
316
+ <div className="h-12 w-12 rounded-full bg-[var(--color-dash-accent)]/10 flex items-center justify-center">
317
+ <SparklesIcon className="h-6 w-6 text-[var(--color-dash-accent)]" />
318
+ </div>
319
+ <p className="text-sm text-[var(--color-dash-muted)] dark:text-[var(--color-dash-label)]">
320
+ Eva is connecting...
321
+ </p>
322
+ </div>
323
+ )}
324
+ {messages.map((msg) =>
325
+ msg.role === "agent" ? (
326
+ <AgentMessage key={msg.id} text={msg.text} timestamp={msg.timestamp} />
327
+ ) : (
328
+ <UserMessage key={msg.id} text={msg.text} timestamp={msg.timestamp} />
329
+ )
330
+ )}
331
+ {isTyping && <TypingIndicator />}
332
+ <div ref={messagesEndRef} />
333
+ </div>
334
+
335
+ {/* Input */}
336
+ <div className="flex-shrink-0 bg-white dark:bg-[var(--color-dash-text)] border-t border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 px-4 py-3">
337
+ <form
338
+ onSubmit={(e) => {
339
+ e.preventDefault();
340
+ handleSend();
341
+ }}
342
+ className="flex items-center gap-2"
343
+ >
344
+ <input
345
+ ref={inputRef}
346
+ type="text"
347
+ value={inputValue}
348
+ onChange={(e) => setInputValue(e.target.value)}
349
+ placeholder="Type your message..."
350
+ className="flex-1 bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/10 border border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 rounded-xl px-4 py-2.5 text-sm text-[var(--color-dash-text)] dark:text-white placeholder:text-[var(--color-dash-label)] focus:outline-none focus:ring-2 focus:ring-[var(--color-dash-accent)]/30 focus:border-[var(--color-dash-accent)] transition-all"
351
+ />
352
+ <button
353
+ type="submit"
354
+ disabled={!inputValue.trim()}
355
+ className="flex-shrink-0 h-10 w-10 rounded-xl bg-[var(--color-dash-accent)] hover:brightness-110 disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center transition-all"
356
+ >
357
+ <PaperAirplaneIcon className="h-4 w-4 text-white" />
358
+ </button>
359
+ </form>
360
+ <p className="text-[10px] text-[var(--color-dash-label)] text-center mt-2">
361
+ Powered by Agentforce
362
+ </p>
363
+ </div>
364
+ </div>
365
+ </>,
366
+ document.body
367
+ )
368
+ : null;
369
+
370
+ return (
371
+ <>
372
+ {panel}
373
+
374
+ {!isOpen && (
375
+ <button
376
+ onClick={() => setIsOpen(true)}
377
+ className="fixed z-[9999] bottom-6 right-6 h-14 w-14 rounded-full bg-[var(--color-dash-dark)] hover:scale-110 shadow-xl hover:shadow-2xl flex items-center justify-center transition-all duration-200"
378
+ style={{
379
+ animation: "agent-bubble-in 0.3s cubic-bezier(0.16, 1, 0.3, 1)",
380
+ }}
381
+ >
382
+ <SparklesIcon className="h-6 w-6 text-white" />
383
+ </button>
384
+ )}
385
+
386
+ <style>{`
387
+ @keyframes agent-panel-in {
388
+ from { opacity: 0; transform: translateY(20px) scale(0.95); }
389
+ to { opacity: 1; transform: translateY(0) scale(1); }
390
+ }
391
+ @keyframes agent-bubble-in {
392
+ from { opacity: 0; transform: scale(0.5); }
393
+ to { opacity: 1; transform: scale(1); }
394
+ }
395
+ `}</style>
396
+ </>
397
+ );
398
+ }
399
+
400
+ function delay(ms: number) {
401
+ return new Promise((resolve) => setTimeout(resolve, ms));
402
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "2.3.12",
3
+ "version": "2.3.13",
4
4
  "description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",