admesh-ui-sdk 0.5.0 → 0.6.1

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/README.md CHANGED
@@ -95,6 +95,20 @@ Customizable header with search, title, and collapse functionality.
95
95
  #### AdMeshSidebarContent
96
96
  Content area with tabs, filtering, and multiple display modes.
97
97
 
98
+ ### 💬 Chat Components
99
+
100
+ #### AdMeshFloatingChat
101
+ Floating chat widget that can be embedded on any website for AI-powered recommendations.
102
+
103
+ #### AdMeshChatInterface
104
+ Embeddable chat interface for integrating conversational AI into web applications.
105
+
106
+ #### AdMeshChatMessage
107
+ Individual chat message component with recommendation support.
108
+
109
+ #### AdMeshChatInput
110
+ Chat input component with suggestions and auto-resize functionality.
111
+
98
112
  ## 🎨 Theming
99
113
 
100
114
  ```tsx
@@ -371,6 +385,173 @@ function AppWithSidebar() {
371
385
  />
372
386
  ```
373
387
 
388
+ ## 💬 Chat Components
389
+
390
+ Perfect for websites and applications that want to provide AI-powered recommendations through chat interfaces.
391
+
392
+ ### Quick Start - Floating Chat Widget
393
+
394
+ ```tsx
395
+ import React, { useState } from 'react';
396
+ import { AdMeshFloatingChat } from 'admesh-ui-sdk';
397
+
398
+ function WebsiteWithChat() {
399
+ const [chatOpen, setChatOpen] = useState(false);
400
+
401
+ const handleSendMessage = async (message) => {
402
+ // Call your AI API to get response with recommendations
403
+ const response = await fetch('/api/chat', {
404
+ method: 'POST',
405
+ body: JSON.stringify({ message })
406
+ });
407
+
408
+ const data = await response.json();
409
+
410
+ return {
411
+ id: `assistant-${Date.now()}`,
412
+ role: 'assistant',
413
+ content: data.response,
414
+ timestamp: new Date(),
415
+ recommendations: data.recommendations
416
+ };
417
+ };
418
+
419
+ return (
420
+ <div>
421
+ {/* Your website content */}
422
+ <main>
423
+ <h1>Your Website</h1>
424
+ <p>The chat widget appears in the corner</p>
425
+ </main>
426
+
427
+ {/* AdMesh Floating Chat */}
428
+ <AdMeshFloatingChat
429
+ config={{
430
+ position: 'bottom-right', // 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
431
+ size: 'md', // 'sm' | 'md' | 'lg' | 'xl'
432
+ autoOpen: false, // Auto-open on page load
433
+ showWelcomeMessage: true,
434
+ welcomeMessage: "Hi! How can I help you find the perfect products?",
435
+ enableSuggestions: true,
436
+ suggestions: [
437
+ "I need software recommendations",
438
+ "What tools do you recommend?",
439
+ "Help me find the right solution"
440
+ ]
441
+ }}
442
+ theme={{ mode: 'light' }}
443
+ title="AI Assistant"
444
+ subtitle="Get personalized recommendations"
445
+ isOpen={chatOpen}
446
+ onToggle={() => setChatOpen(!chatOpen)}
447
+ onSendMessage={handleSendMessage}
448
+ onRecommendationClick={(adId, admeshLink) => {
449
+ window.open(admeshLink, '_blank');
450
+ }}
451
+ />
452
+ </div>
453
+ );
454
+ }
455
+ ```
456
+
457
+ ### Embedded Chat Interface
458
+
459
+ ```tsx
460
+ import React, { useState } from 'react';
461
+ import { AdMeshChatInterface } from 'admesh-ui-sdk';
462
+
463
+ function ChatPage() {
464
+ const [messages, setMessages] = useState([]);
465
+ const [isLoading, setIsLoading] = useState(false);
466
+
467
+ const handleSendMessage = async (messageContent) => {
468
+ // Add user message
469
+ const userMessage = {
470
+ id: `user-${Date.now()}`,
471
+ role: 'user',
472
+ content: messageContent,
473
+ timestamp: new Date(),
474
+ };
475
+ setMessages(prev => [...prev, userMessage]);
476
+ setIsLoading(true);
477
+
478
+ // Get AI response
479
+ const response = await getAIResponse(messageContent);
480
+ setMessages(prev => [...prev, response]);
481
+ setIsLoading(false);
482
+ };
483
+
484
+ return (
485
+ <div className="h-screen">
486
+ <AdMeshChatInterface
487
+ messages={messages}
488
+ config={{
489
+ placeholder: "Ask me about products...",
490
+ enableTypingIndicator: true,
491
+ maxMessages: 50
492
+ }}
493
+ theme={{ mode: 'light' }}
494
+ isLoading={isLoading}
495
+ onSendMessage={handleSendMessage}
496
+ onRecommendationClick={(adId, link) => window.open(link)}
497
+ />
498
+ </div>
499
+ );
500
+ }
501
+ ```
502
+
503
+ ### Chat Features
504
+
505
+ - **Floating Widget**: Non-intrusive chat button that expands to full chat
506
+ - **Multiple Positions**: Place in any corner of the screen
507
+ - **Responsive Sizes**: From compact mobile to large desktop
508
+ - **Auto-open**: Proactive engagement with visitors
509
+ - **Welcome Messages**: Customizable greeting messages
510
+ - **Quick Suggestions**: Pre-defined conversation starters
511
+ - **Typing Indicators**: Visual feedback during AI response generation
512
+ - **Message History**: Persistent conversation state
513
+ - **Recommendation Display**: Inline product recommendations with tracking
514
+ - **Theme Support**: Light/dark modes with custom branding
515
+
516
+ ### Configuration Examples
517
+
518
+ ```tsx
519
+ // Compact bottom-left widget
520
+ <AdMeshFloatingChat
521
+ config={{
522
+ position: 'bottom-left',
523
+ size: 'sm',
524
+ autoOpen: false,
525
+ showWelcomeMessage: true,
526
+ welcomeMessage: "Need help finding something?"
527
+ }}
528
+ />
529
+
530
+ // Large auto-opening widget with suggestions
531
+ <AdMeshFloatingChat
532
+ config={{
533
+ position: 'bottom-right',
534
+ size: 'lg',
535
+ autoOpen: true,
536
+ enableSuggestions: true,
537
+ suggestions: [
538
+ "Show me your best products",
539
+ "I need business software",
540
+ "Help me choose the right tool"
541
+ ]
542
+ }}
543
+ />
544
+
545
+ // Embedded chat with message limit
546
+ <AdMeshChatInterface
547
+ config={{
548
+ maxMessages: 20,
549
+ enableTypingIndicator: true,
550
+ placeholder: "What can I help you find today?"
551
+ }}
552
+ />
553
+ ```
554
+
374
555
  ## 📊 Tracking
375
556
 
376
557
  All components include built-in view and click tracking:
package/dist/index.d.ts CHANGED
@@ -9,6 +9,52 @@ export declare interface AdMeshBadgeProps {
9
9
  className?: string;
10
10
  }
11
11
 
12
+ export declare interface AdMeshChatConfig {
13
+ position: ChatPosition;
14
+ size: ChatSize;
15
+ displayMode: ChatDisplayMode;
16
+ autoOpen?: boolean;
17
+ showWelcomeMessage?: boolean;
18
+ welcomeMessage?: string;
19
+ placeholder?: string;
20
+ maxMessages?: number;
21
+ enableTypingIndicator?: boolean;
22
+ enableSuggestions?: boolean;
23
+ suggestions?: string[];
24
+ }
25
+
26
+ export declare const AdMeshChatInput: default_2.FC<AdMeshChatInputProps>;
27
+
28
+ export declare interface AdMeshChatInputProps {
29
+ placeholder?: string;
30
+ disabled?: boolean;
31
+ suggestions?: string[];
32
+ theme?: AdMeshTheme;
33
+ onSendMessage?: (message: string) => void;
34
+ className?: string;
35
+ }
36
+
37
+ export declare const AdMeshChatInterface: default_2.FC<AdMeshChatInterfaceProps>;
38
+
39
+ export declare interface AdMeshChatInterfaceProps {
40
+ messages: ChatMessage[];
41
+ config: Partial<AdMeshChatConfig>;
42
+ theme?: AdMeshTheme;
43
+ isLoading?: boolean;
44
+ onSendMessage?: (message: string) => void;
45
+ onRecommendationClick?: (adId: string, admeshLink: string) => void;
46
+ className?: string;
47
+ }
48
+
49
+ export declare const AdMeshChatMessage: default_2.FC<AdMeshChatMessageProps>;
50
+
51
+ export declare interface AdMeshChatMessageProps {
52
+ message: ChatMessage;
53
+ theme?: AdMeshTheme;
54
+ onRecommendationClick?: (adId: string, admeshLink: string) => void;
55
+ className?: string;
56
+ }
57
+
12
58
  export declare const AdMeshCompareTable: default_2.FC<AdMeshCompareTableProps>;
13
59
 
14
60
  export declare interface AdMeshCompareTableProps {
@@ -54,6 +100,20 @@ export declare interface AdMeshConversationSummaryProps {
54
100
  className?: string;
55
101
  }
56
102
 
103
+ export declare const AdMeshFloatingChat: default_2.FC<AdMeshFloatingChatProps>;
104
+
105
+ export declare interface AdMeshFloatingChatProps {
106
+ config: AdMeshChatConfig;
107
+ theme?: AdMeshTheme;
108
+ title?: string;
109
+ subtitle?: string;
110
+ isOpen?: boolean;
111
+ onToggle?: () => void;
112
+ onSendMessage?: (message: string) => Promise<ChatMessage>;
113
+ onRecommendationClick?: (adId: string, admeshLink: string) => void;
114
+ className?: string;
115
+ }
116
+
57
117
  export declare const AdMeshInlineRecommendation: default_2.FC<AdMeshInlineRecommendationProps>;
58
118
 
59
119
  export declare interface AdMeshInlineRecommendationProps {
@@ -231,6 +291,23 @@ export declare type BadgeVariant = 'primary' | 'secondary' | 'success' | 'warnin
231
291
 
232
292
  export declare const buildAdMeshLink: (baseLink: string, adId: string, additionalParams?: Record<string, string>) => string;
233
293
 
294
+ export declare type ChatDisplayMode = 'widget' | 'fullscreen' | 'embedded';
295
+
296
+ export declare interface ChatMessage {
297
+ id: string;
298
+ role: ChatMessageRole;
299
+ content: string;
300
+ timestamp: Date;
301
+ recommendations?: AdMeshRecommendation[];
302
+ isTyping?: boolean;
303
+ }
304
+
305
+ export declare type ChatMessageRole = 'user' | 'assistant' | 'system';
306
+
307
+ export declare type ChatPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
308
+
309
+ export declare type ChatSize = 'sm' | 'md' | 'lg' | 'xl';
310
+
234
311
  export declare interface ConversationalAdConfig {
235
312
  displayMode: ConversationalDisplayMode;
236
313
  context: ConversationContext;