"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface ChatMessage { id: string; author: string; initials: string; body: string; time?: string; direction: "incoming" | "outgoing"; } export interface ChatWindowProps { messages?: ChatMessage[]; onSend?: (body: string) => void; typing?: boolean; autoFocus?: boolean; } type LocalBubbleProps = { direction: "incoming" | "outgoing"; className?: string; children: React.ReactNode }; function LocalBubble({ direction, className, children }: LocalBubbleProps) { return (
{children}
); } function LocalTyping() { return (
{[0, 1, 2].map((i) => ( ))}
); } const ChatWindow: React.FC = ({ messages = [], onSend, typing, autoFocus = false }) => { const [input, setInput] = React.useState(""); const handleSend = () => { const trimmed = input.trim(); if (trimmed && onSend) { onSend(trimmed); setInput(""); } }; return (
{messages.map((msg) => (
<>{msg.body}
{msg.initials} ยท {msg.time || ""}
))} {typing && (
)}
setInput(e.target.value)} placeholder="Message..." className="flex-1 rounded-border border-input px-3 py-2 text-sm" autoFocus={autoFocus} />
); }; export { ChatWindow };