@blumessage/react-chat 1.0.0
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 +182 -0
- package/dist/components/ChatComponent.d.ts +61 -0
- package/dist/components/ChatComponent.d.ts.map +1 -0
- package/dist/index.esm.js +2289 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2291 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# @blumessage/react-chat
|
|
2
|
+
|
|
3
|
+
A beautiful, customizable React chat component with BlueMessage AI integration built with TypeScript and Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 💬 Real-time messaging interface with AI responses
|
|
8
|
+
- 👤 User avatars and names
|
|
9
|
+
- ⏰ Timestamps and message status
|
|
10
|
+
- 📱 Responsive design
|
|
11
|
+
- 🎨 Highly customizable styling
|
|
12
|
+
- 📝 TypeScript support
|
|
13
|
+
- ✨ Smooth animations and transitions
|
|
14
|
+
- 🤖 BlueMessage AI integration
|
|
15
|
+
- 🔧 Extensive customization options
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @blumessage/react-chat
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { BlumessageChat } from '@blumessage/react-chat';
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<div style={{ height: '500px' }}>
|
|
32
|
+
<BlumessageChat
|
|
33
|
+
apiKey="your-blumessage-api-key"
|
|
34
|
+
headerTitle="Support Chat"
|
|
35
|
+
primaryColor="#3b82f6"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default App;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API Key Setup
|
|
45
|
+
|
|
46
|
+
1. Sign up for a BlueMessage API key at [blumessage.com](https://blumessage.com)
|
|
47
|
+
2. Pass your API key to the `apiKey` prop
|
|
48
|
+
3. For testing purposes, you can use `apiKey="test"` to enable demo mode
|
|
49
|
+
|
|
50
|
+
**Note:** Without a valid API key, the chat component will be disabled and an error will be logged to the console.
|
|
51
|
+
|
|
52
|
+
## Props
|
|
53
|
+
|
|
54
|
+
### Core Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Default | Description |
|
|
57
|
+
|------|------|---------|-------------|
|
|
58
|
+
| `apiKey` | `string` | `undefined` | **Required** - BlueMessage API key for chat functionality. Use `"test"` for demo purposes |
|
|
59
|
+
| `messages` | `Message[]` | `[]` | Array of messages to display |
|
|
60
|
+
| `onSendMessage` | `(message: string) => void` | `undefined` | Callback when user sends a message |
|
|
61
|
+
| `currentUser` | `User` | `{ id: 'user1', name: 'You' }` | Current user information |
|
|
62
|
+
| `inputPlaceholder` | `string` | `'Type a message...'` | Input placeholder text |
|
|
63
|
+
| `className` | `string` | `''` | Additional CSS classes |
|
|
64
|
+
|
|
65
|
+
### Header Customization
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Description |
|
|
68
|
+
|------|------|---------|-------------|
|
|
69
|
+
| `headerTitle` | `string` | `'BlueMessage AI'` | Chat header title |
|
|
70
|
+
| `headerDescription` | `string` | `'Online • Instant responses'` | Subtitle text in header |
|
|
71
|
+
| `headerColor` | `string` | `undefined` | Header background color (uses primaryColor if not set) |
|
|
72
|
+
| `headerIcon` | `string` | `'mdi:message-text'` | Iconify icon name for header |
|
|
73
|
+
| `headerIconColor` | `string` | `'white'` | Header icon color |
|
|
74
|
+
| `headerIconHide` | `boolean` | `false` | Hide header icon |
|
|
75
|
+
| `headerAvatarColor` | `string` | `'rgba(255, 255, 255, 0.2)'` | Header avatar background color |
|
|
76
|
+
|
|
77
|
+
### Layout & Behavior
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Default | Description |
|
|
80
|
+
|------|------|---------|-------------|
|
|
81
|
+
| `size` | `'xsmall' \| 'small' \| 'medium' \| 'large' \| 'xlarge'` | `'medium'` | Chat window size |
|
|
82
|
+
| `floatingButtonPosition` | `'top-right' \| 'top-left' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Position of floating chat button |
|
|
83
|
+
| `autoOpen` | `boolean` | `false` | Auto-open chat on load |
|
|
84
|
+
| `forceOpen` | `boolean` | `false` | Force chat to stay open (removes close button) |
|
|
85
|
+
| `maximize` | `boolean` | `false` | Start maximized |
|
|
86
|
+
| `maximizeToggle` | `boolean` | `true` | Show maximize/minimize button |
|
|
87
|
+
|
|
88
|
+
### Colors & Styling
|
|
89
|
+
|
|
90
|
+
| Prop | Type | Default | Description |
|
|
91
|
+
|------|------|---------|-------------|
|
|
92
|
+
| `primaryColor` | `string` | `'#3b82f6'` | Main theme color |
|
|
93
|
+
| `secondaryColor` | `string` | `'#2563eb'` | Secondary theme color |
|
|
94
|
+
| `messageUserColor` | `string` | `undefined` | User message background (uses gradient if not set) |
|
|
95
|
+
| `messageAssistantColor` | `string` | `'#f3f4f6'` | Assistant message background |
|
|
96
|
+
| `sendButtonColor` | `string` | `undefined` | Send button color (uses gradient if not set) |
|
|
97
|
+
| `inputOutlineColor` | `string` | `'#3b82f6'` | Input focus border color |
|
|
98
|
+
| `floatingButtonBackgroundColor` | `string` | `undefined` | Floating button background |
|
|
99
|
+
| `floatingButtonIcon` | `string` | `undefined` | Floating button icon (uses headerIcon if not set) |
|
|
100
|
+
| `floatingButtonIconColor` | `string` | `'white'` | Floating button icon color |
|
|
101
|
+
|
|
102
|
+
### Message Customization
|
|
103
|
+
|
|
104
|
+
| Prop | Type | Default | Description |
|
|
105
|
+
|------|------|---------|-------------|
|
|
106
|
+
| `messageTimestamps` | `boolean` | `true` | Show message timestamps |
|
|
107
|
+
| `messageUserAvatarVisibility` | `boolean` | `false` | Show user avatars |
|
|
108
|
+
| `messageUserAvatarIcon` | `string` | `'mdi:account'` | User avatar icon |
|
|
109
|
+
| `messageUserAvatarColor` | `string` | `'#3b82f6'` | User avatar background color |
|
|
110
|
+
| `messageAssistantAvatarVisibility` | `boolean` | `false` | Show assistant avatars |
|
|
111
|
+
| `messageAssistantAvatarIcon` | `string` | `'mdi:robot'` | Assistant avatar icon |
|
|
112
|
+
| `messageAssistantAvatarColor` | `string` | `'#6b7280'` | Assistant avatar background color |
|
|
113
|
+
| `messageUserName` | `string \| null` | `null` | Display name for user messages |
|
|
114
|
+
| `messageAssistantName` | `string \| null` | `null` | Display name for assistant messages |
|
|
115
|
+
| `sendButtonIcon` | `string` | `'mdi:send'` | Send button icon |
|
|
116
|
+
|
|
117
|
+
## Types
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
interface User {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
avatar?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface Message {
|
|
127
|
+
id: string;
|
|
128
|
+
text: string;
|
|
129
|
+
sender: User;
|
|
130
|
+
timestamp: Date;
|
|
131
|
+
isOwn: boolean;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Advanced Usage
|
|
136
|
+
|
|
137
|
+
### Custom Styling
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
<BlumessageChat
|
|
141
|
+
apiKey="your-api-key"
|
|
142
|
+
primaryColor="#10b981"
|
|
143
|
+
secondaryColor="#059669"
|
|
144
|
+
headerTitle="Customer Support"
|
|
145
|
+
headerDescription="We're here to help!"
|
|
146
|
+
size="large"
|
|
147
|
+
messageTimestamps={true}
|
|
148
|
+
messageAssistantAvatarVisibility={true}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Event Handling
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const handleSendMessage = (message: string) => {
|
|
156
|
+
console.log('User sent:', message);
|
|
157
|
+
// Add your custom logic here
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
<BlumessageChat
|
|
161
|
+
apiKey="your-api-key"
|
|
162
|
+
onSendMessage={handleSendMessage}
|
|
163
|
+
currentUser={{
|
|
164
|
+
id: 'user123',
|
|
165
|
+
name: 'John Doe',
|
|
166
|
+
avatar: '👤'
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Requirements
|
|
172
|
+
|
|
173
|
+
- React 18+
|
|
174
|
+
- TypeScript (recommended)
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT © BlueMessage
|
|
179
|
+
|
|
180
|
+
## Support
|
|
181
|
+
|
|
182
|
+
For support and questions, visit [blumessage.com](https://blumessage.com) or create an issue on GitHub.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Message {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
sender: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
avatar?: string;
|
|
9
|
+
};
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
isOwn: boolean;
|
|
12
|
+
}
|
|
13
|
+
type ChatSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
14
|
+
type FloatingButtonPosition = 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right';
|
|
15
|
+
interface ChatComponentProps {
|
|
16
|
+
messages?: Message[];
|
|
17
|
+
onSendMessage?: (message: string) => void;
|
|
18
|
+
currentUser?: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
avatar?: string;
|
|
22
|
+
};
|
|
23
|
+
inputPlaceholder?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
headerTitle?: string;
|
|
26
|
+
headerDescription?: string;
|
|
27
|
+
headerColor?: string;
|
|
28
|
+
headerIcon?: string;
|
|
29
|
+
headerIconColor?: string;
|
|
30
|
+
headerIconHide?: boolean;
|
|
31
|
+
headerAvatarColor?: string;
|
|
32
|
+
primaryColor?: string;
|
|
33
|
+
secondaryColor?: string;
|
|
34
|
+
messageUserColor?: string;
|
|
35
|
+
messageAssistantColor?: string;
|
|
36
|
+
messageTimestamps?: boolean;
|
|
37
|
+
messageUserAvatarVisibility?: boolean;
|
|
38
|
+
messageUserAvatarIcon?: string;
|
|
39
|
+
messageUserAvatarColor?: string;
|
|
40
|
+
messageAssistantAvatarVisibility?: boolean;
|
|
41
|
+
messageAssistantAvatarIcon?: string;
|
|
42
|
+
messageAssistantAvatarColor?: string;
|
|
43
|
+
messageUserName?: string | null;
|
|
44
|
+
messageAssistantName?: string | null;
|
|
45
|
+
sendButtonIcon?: string;
|
|
46
|
+
sendButtonColor?: string;
|
|
47
|
+
inputOutlineColor?: string;
|
|
48
|
+
floatingButtonPosition?: FloatingButtonPosition;
|
|
49
|
+
floatingButtonIcon?: string;
|
|
50
|
+
floatingButtonIconColor?: string;
|
|
51
|
+
floatingButtonBackgroundColor?: string;
|
|
52
|
+
size?: ChatSize;
|
|
53
|
+
maximizeToggle?: boolean;
|
|
54
|
+
maximize?: boolean;
|
|
55
|
+
autoOpen?: boolean;
|
|
56
|
+
forceOpen?: boolean;
|
|
57
|
+
apiKey?: string;
|
|
58
|
+
}
|
|
59
|
+
declare const ChatComponent: React.FC<ChatComponentProps>;
|
|
60
|
+
export default ChatComponent;
|
|
61
|
+
//# sourceMappingURL=ChatComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatComponent.d.ts","sourceRoot":"","sources":["../../src/components/ChatComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,UAAU,OAAO;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MA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