@droppii-org/chat-sdk 0.0.1 → 0.0.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBubble.d.ts","sourceRoot":"","sources":["../../src/components/ChatBubble.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatBubble.d.ts","sourceRoot":"","sources":["../../src/components/ChatBubble.tsx"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,gCA0GzB"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { MessageCircle, X } from "lucide-react";
|
|
4
|
-
import {
|
|
4
|
+
import { ChatHeader } from "./ChatHeader";
|
|
5
|
+
import { MessageList } from "./MessageList";
|
|
6
|
+
import { ChatInput } from "./ChatInput";
|
|
7
|
+
import { useMessages } from "../hooks/useMessages";
|
|
5
8
|
export function ChatBubble() {
|
|
6
9
|
const [isOpen, setIsOpen] = useState(false);
|
|
10
|
+
const [selectedConversationId, setSelectedConversationId] = useState('conv-1');
|
|
11
|
+
console.log("🚀 ~ ChatBubble ~ isOpen:", isOpen);
|
|
12
|
+
const messagesHook = useMessages(selectedConversationId || "");
|
|
7
13
|
return (<>
|
|
8
14
|
{/* Chat Bubble Button */}
|
|
9
15
|
<button onClick={() => setIsOpen(true)} className={`fixed bottom-6 right-6 w-14 h-14 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg transition-all duration-200 flex items-center justify-center z-40 ${isOpen ? "scale-0" : "scale-100"}`} aria-label="Open chat">
|
|
@@ -11,7 +17,7 @@ export function ChatBubble() {
|
|
|
11
17
|
</button>
|
|
12
18
|
|
|
13
19
|
{/* Chat Window */}
|
|
14
|
-
{isOpen && (<div className="fixed bottom-6 right-6 w-96 h-[
|
|
20
|
+
{isOpen && (<div className="fixed bottom-6 right-6 w-96 h-[700px] max-h-[80%] bg-white rounded-lg shadow-2xl border z-50 flex flex-col overflow-hidden">
|
|
15
21
|
{/* Header */}
|
|
16
22
|
<div className="flex items-center justify-between p-4 border-b bg-blue-600 text-white">
|
|
17
23
|
<h3 className="font-semibold">Chat Support</h3>
|
|
@@ -21,9 +27,51 @@ export function ChatBubble() {
|
|
|
21
27
|
</div>
|
|
22
28
|
|
|
23
29
|
{/* Chat Content */}
|
|
24
|
-
<div className=
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
<div className={`
|
|
31
|
+
flex-1 flex flex-col relative h-[calc(100%-50px)]
|
|
32
|
+
${selectedConversationId ? "flex" : "hidden md:flex"}
|
|
33
|
+
`}>
|
|
34
|
+
{selectedConversationId ? (<>
|
|
35
|
+
{/* Swipe indicator for mobile */}
|
|
36
|
+
<div className="md:hidden absolute top-2 left-2 z-10 pointer-events-none">
|
|
37
|
+
<div className="bg-black bg-opacity-20 text-white text-xs px-2 py-1 rounded-full opacity-0 transition-opacity duration-200 swipe-hint">
|
|
38
|
+
← Swipe to go back
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{/* Chat Header - Fixed */}
|
|
43
|
+
<div className="flex-shrink-0">
|
|
44
|
+
<ChatHeader conversationId={selectedConversationId} onBackClick={() => setIsOpen(false)} onMenuClick={() => setIsOpen(false)}/>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
{/* Message List - Scrollable */}
|
|
48
|
+
<div className="flex-1 min-h-0">
|
|
49
|
+
{" "}
|
|
50
|
+
{/* Added min-h-0 here */}
|
|
51
|
+
<MessageList messages={messagesHook.messages} currentUserId={"current-user"} conversationId={selectedConversationId} className="h-full"/>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
{/* Chat Input - Fixed */}
|
|
55
|
+
<div className="flex-shrink-0">
|
|
56
|
+
<ChatInput />
|
|
57
|
+
</div>
|
|
58
|
+
</>) : (<div className="flex-1 flex items-center justify-center text-gray-500 p-4">
|
|
59
|
+
<div className="text-center max-w-sm">
|
|
60
|
+
<div className="w-16 h-16 mx-auto mb-4 bg-gray-100 rounded-full flex items-center justify-center">
|
|
61
|
+
<svg className="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
62
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>
|
|
63
|
+
</svg>
|
|
64
|
+
</div>
|
|
65
|
+
<h3 className="text-lg font-medium text-gray-900 mb-2">Select a conversation</h3>
|
|
66
|
+
<p className="text-gray-500 text-sm sm:text-base">
|
|
67
|
+
Choose a conversation from the sidebar to start messaging
|
|
68
|
+
</p>
|
|
69
|
+
<button onClick={() => setIsOpen(false)} className="mt-4 md:hidden px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors">
|
|
70
|
+
View Conversations
|
|
71
|
+
</button>
|
|
72
|
+
</div>
|
|
73
|
+
</div>)}
|
|
74
|
+
</div>
|
|
27
75
|
</div>)}
|
|
28
76
|
|
|
29
77
|
{/* Backdrop */}
|
|
@@ -9,7 +9,7 @@ import { useSwipeGesture } from "../hooks/useSwipeGesture";
|
|
|
9
9
|
import { useMessages } from "../hooks/useMessages";
|
|
10
10
|
export function ChatLayout({ className = "" }) {
|
|
11
11
|
var _a;
|
|
12
|
-
const [selectedConversationId, setSelectedConversationId] = useState(
|
|
12
|
+
const [selectedConversationId, setSelectedConversationId] = useState('conv-1');
|
|
13
13
|
const [showSidebar, setShowSidebar] = useState(false);
|
|
14
14
|
const { state } = useChatContext();
|
|
15
15
|
const messagesHook = useMessages(selectedConversationId || "");
|
package/package.json
CHANGED