@channlize/react 0.1.0-alpha.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 +422 -0
- package/dist/index.d.mts +203 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.js +1032 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +999 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# @channlize/react
|
|
2
|
+
|
|
3
|
+
React components and hooks for the Channlize platform. Build customer support experiences that route directly to Slack.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @channlize/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Note: This package has peer dependencies on `react` and `react-dom` (>=16.8.0).
|
|
12
|
+
|
|
13
|
+
## Quick Start (Plug & Play)
|
|
14
|
+
|
|
15
|
+
The easiest way to add live chat to your React app:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { ChannlizeChat } from '@channlize/react';
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<YourAppContent />
|
|
24
|
+
|
|
25
|
+
{/* That's it! Floating chat widget with everything included */}
|
|
26
|
+
<ChannlizeChat
|
|
27
|
+
config={{
|
|
28
|
+
apiKey: 'your-widget-key',
|
|
29
|
+
projectId: 'your-project-id',
|
|
30
|
+
}}
|
|
31
|
+
position="bottom-right"
|
|
32
|
+
chatProps={{
|
|
33
|
+
title: "Customer Support",
|
|
34
|
+
placeholder: "How can we help you today?"
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The `ChannlizeChat` component includes:
|
|
43
|
+
- ✅ Provider (no need to wrap your app)
|
|
44
|
+
- ✅ Floating button with customizable position
|
|
45
|
+
- ✅ Chat window with real-time messaging
|
|
46
|
+
- ✅ Animations and responsive design
|
|
47
|
+
- ✅ Extensive styling options
|
|
48
|
+
|
|
49
|
+
## Advanced Usage
|
|
50
|
+
|
|
51
|
+
For more control, use the individual components:
|
|
52
|
+
|
|
53
|
+
### Manual Setup
|
|
54
|
+
|
|
55
|
+
Wrap your app with the `ChannlizeProvider`:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { ChannlizeProvider } from '@channlize/react';
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<ChannlizeProvider
|
|
63
|
+
config={{
|
|
64
|
+
apiKey: 'your-api-key',
|
|
65
|
+
projectId: 'your-project-id',
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<YourAppContent />
|
|
69
|
+
</ChannlizeProvider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Contact Form Component
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { ContactForm } from '@channlize/react';
|
|
78
|
+
|
|
79
|
+
function ContactPage() {
|
|
80
|
+
return (
|
|
81
|
+
<ContactForm
|
|
82
|
+
onSuccess={() => alert('Message sent!')}
|
|
83
|
+
onError={(error) => console.error(error)}
|
|
84
|
+
customFields={[
|
|
85
|
+
{
|
|
86
|
+
name: 'department',
|
|
87
|
+
label: 'Department',
|
|
88
|
+
type: 'select',
|
|
89
|
+
required: true,
|
|
90
|
+
options: ['Sales', 'Support', 'Billing'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'priority',
|
|
94
|
+
label: 'Priority',
|
|
95
|
+
type: 'select',
|
|
96
|
+
options: ['Low', 'Medium', 'High'],
|
|
97
|
+
},
|
|
98
|
+
]}
|
|
99
|
+
styles={{
|
|
100
|
+
form: { maxWidth: '500px' },
|
|
101
|
+
button: { background: '#007bff', color: 'white' },
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Support Chat Component
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { SupportChat } from '@channlize/react';
|
|
112
|
+
|
|
113
|
+
function SupportPage() {
|
|
114
|
+
return (
|
|
115
|
+
<SupportChat
|
|
116
|
+
autoStart={true}
|
|
117
|
+
title="Customer Support"
|
|
118
|
+
placeholder="How can we help you?"
|
|
119
|
+
onMessage={(message) => {
|
|
120
|
+
console.log('New message:', message);
|
|
121
|
+
}}
|
|
122
|
+
styles={{
|
|
123
|
+
container: {
|
|
124
|
+
width: '400px',
|
|
125
|
+
height: '500px',
|
|
126
|
+
border: '1px solid #ccc',
|
|
127
|
+
borderRadius: '8px',
|
|
128
|
+
},
|
|
129
|
+
header: {
|
|
130
|
+
background: '#007bff',
|
|
131
|
+
color: 'white'
|
|
132
|
+
},
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Custom Hook Usage
|
|
140
|
+
|
|
141
|
+
#### useContactForm
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { useContactForm } from '@channlize/react';
|
|
145
|
+
|
|
146
|
+
function CustomContactForm() {
|
|
147
|
+
const { submit, isSubmitting, isSuccess, error, reset } = useContactForm({
|
|
148
|
+
onSuccess: (response) => {
|
|
149
|
+
console.log('Form submitted:', response);
|
|
150
|
+
},
|
|
151
|
+
onError: (error) => {
|
|
152
|
+
console.error('Submission failed:', error);
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const handleSubmit = async (e) => {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
await submit({
|
|
159
|
+
name: 'John Doe',
|
|
160
|
+
email: 'john@example.com',
|
|
161
|
+
message: 'Hello!',
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (isSuccess) {
|
|
166
|
+
return (
|
|
167
|
+
<div>
|
|
168
|
+
<p>Thank you! Your message has been sent.</p>
|
|
169
|
+
<button onClick={reset}>Send another message</button>
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<form onSubmit={handleSubmit}>
|
|
176
|
+
{/* Your form fields */}
|
|
177
|
+
<button type="submit" disabled={isSubmitting}>
|
|
178
|
+
{isSubmitting ? 'Sending...' : 'Send'}
|
|
179
|
+
</button>
|
|
180
|
+
{error && <p>Error: {error.message}</p>}
|
|
181
|
+
</form>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### useChatSession
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { useChatSession } from '@channlize/react';
|
|
190
|
+
|
|
191
|
+
function CustomChat() {
|
|
192
|
+
const {
|
|
193
|
+
session,
|
|
194
|
+
messages,
|
|
195
|
+
isConnecting,
|
|
196
|
+
isConnected,
|
|
197
|
+
error,
|
|
198
|
+
sendMessage,
|
|
199
|
+
startSession,
|
|
200
|
+
endSession,
|
|
201
|
+
} = useChatSession({
|
|
202
|
+
autoConnect: false,
|
|
203
|
+
metadata: { page: 'support' },
|
|
204
|
+
onMessage: (message) => {
|
|
205
|
+
console.log('New message:', message);
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const handleSendMessage = async () => {
|
|
210
|
+
await sendMessage('Hello from custom chat!');
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
if (!session) {
|
|
214
|
+
return (
|
|
215
|
+
<div>
|
|
216
|
+
<button onClick={startSession} disabled={isConnecting}>
|
|
217
|
+
{isConnecting ? 'Connecting...' : 'Start Chat'}
|
|
218
|
+
</button>
|
|
219
|
+
</div>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<div>
|
|
225
|
+
<div>Status: {isConnected ? 'Connected' : 'Disconnected'}</div>
|
|
226
|
+
<div>
|
|
227
|
+
{messages.map((message) => (
|
|
228
|
+
<div key={message.id}>
|
|
229
|
+
<strong>{message.author}:</strong> {message.content}
|
|
230
|
+
</div>
|
|
231
|
+
))}
|
|
232
|
+
</div>
|
|
233
|
+
<button onClick={handleSendMessage}>Send Message</button>
|
|
234
|
+
<button onClick={endSession}>End Chat</button>
|
|
235
|
+
{error && <div>Error: {error.message}</div>}
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Components
|
|
242
|
+
|
|
243
|
+
### ChannlizeChat (Recommended)
|
|
244
|
+
|
|
245
|
+
**All-in-one floating chat widget** - The easiest way to add live chat to any React app. Includes provider, button, and chat window.
|
|
246
|
+
|
|
247
|
+
**Props:**
|
|
248
|
+
|
|
249
|
+
| Prop | Type | Default | Description |
|
|
250
|
+
|------|------|---------|-------------|
|
|
251
|
+
| `config` | `ChannlizeConfig` | required | API configuration (apiKey, projectId, baseUrl) |
|
|
252
|
+
| `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | `'bottom-right'` | Position of the floating button |
|
|
253
|
+
| `offset` | `{ x?: number; y?: number }` | `{ x: 24, y: 24 }` | Offset from edges in pixels |
|
|
254
|
+
| `buttonElement` | `ReactNode` | - | Custom button (overrides default) |
|
|
255
|
+
| `buttonIcon` | `ReactNode` | - | Custom icon (used if buttonElement not provided) |
|
|
256
|
+
| `buttonSize` | `number` | `56` | Button size in pixels |
|
|
257
|
+
| `buttonColors` | `{ background?: string; hover?: string; text?: string }` | Blue gradient | Button colors |
|
|
258
|
+
| `chatProps` | `SupportChatProps` | `{}` | Props passed to internal SupportChat component |
|
|
259
|
+
| `defaultOpen` | `boolean` | `false` | Whether to start open |
|
|
260
|
+
| `showBadge` | `boolean` | `false` | Whether to show unread count badge |
|
|
261
|
+
| `unreadCount` | `number` | `0` | Unread message count |
|
|
262
|
+
| `zIndex` | `number` | `1000` | CSS z-index |
|
|
263
|
+
| `showOnMobile` | `boolean` | `true` | Whether to show on mobile devices |
|
|
264
|
+
| `onOpen` | `() => void` | - | Callback when chat opens |
|
|
265
|
+
| `onClose` | `() => void` | - | Callback when chat closes |
|
|
266
|
+
| `enableAnimations` | `boolean` | `true` | Enable smooth animations |
|
|
267
|
+
| `buttonClassName` | `string` | `''` | Custom class for button container |
|
|
268
|
+
| `chatClassName` | `string` | `''` | Custom class for chat container |
|
|
269
|
+
|
|
270
|
+
**Examples:**
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
// Minimal setup
|
|
274
|
+
<ChannlizeChat
|
|
275
|
+
config={{
|
|
276
|
+
apiKey: 'your-widget-key',
|
|
277
|
+
projectId: 'your-project-id',
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
|
|
281
|
+
// Custom positioning and colors
|
|
282
|
+
<ChannlizeChat
|
|
283
|
+
config={{ apiKey: 'key', projectId: 'id' }}
|
|
284
|
+
position="bottom-left"
|
|
285
|
+
offset={{ x: 16, y: 80 }}
|
|
286
|
+
buttonColors={{
|
|
287
|
+
background: '#10b981',
|
|
288
|
+
hover: '#059669',
|
|
289
|
+
text: '#ffffff',
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
|
|
293
|
+
// With custom chat options
|
|
294
|
+
<ChannlizeChat
|
|
295
|
+
config={{ apiKey: 'key', projectId: 'id' }}
|
|
296
|
+
chatProps={{
|
|
297
|
+
title: "24/7 Support",
|
|
298
|
+
placeholder: "Ask us anything...",
|
|
299
|
+
showTimestamps: true,
|
|
300
|
+
styles: {
|
|
301
|
+
header: {
|
|
302
|
+
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
|
|
308
|
+
// With unread badge
|
|
309
|
+
<ChannlizeChat
|
|
310
|
+
config={{ apiKey: 'key', projectId: 'id' }}
|
|
311
|
+
showBadge={true}
|
|
312
|
+
unreadCount={3}
|
|
313
|
+
onOpen={() => console.log('Chat opened')}
|
|
314
|
+
/>
|
|
315
|
+
|
|
316
|
+
// Custom button
|
|
317
|
+
<ChannlizeChat
|
|
318
|
+
config={{ apiKey: 'key', projectId: 'id' }}
|
|
319
|
+
buttonElement={
|
|
320
|
+
<div style={{
|
|
321
|
+
padding: '12px 24px',
|
|
322
|
+
background: '#000',
|
|
323
|
+
color: '#fff',
|
|
324
|
+
borderRadius: '8px',
|
|
325
|
+
cursor: 'pointer',
|
|
326
|
+
}}>
|
|
327
|
+
Need Help? 💬
|
|
328
|
+
</div>
|
|
329
|
+
}
|
|
330
|
+
/>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### ContactForm
|
|
334
|
+
|
|
335
|
+
A complete contact form component with validation and submission handling.
|
|
336
|
+
|
|
337
|
+
**Props:**
|
|
338
|
+
- `customFields?: Array<CustomField>` - Additional form fields
|
|
339
|
+
- `onSuccess?: () => void` - Success callback
|
|
340
|
+
- `onError?: (error: Error) => void` - Error callback
|
|
341
|
+
- `className?: string` - CSS class name
|
|
342
|
+
- `styles?: ContactFormStyles` - Custom styles object
|
|
343
|
+
- `submitText?: string` - Submit button text
|
|
344
|
+
- `successMessage?: string` - Success message text
|
|
345
|
+
|
|
346
|
+
### SupportChat
|
|
347
|
+
|
|
348
|
+
A real-time chat widget with message history and file attachments.
|
|
349
|
+
|
|
350
|
+
**Props:**
|
|
351
|
+
- `autoStart?: boolean` - Auto-start chat session
|
|
352
|
+
- `metadata?: Record<string, unknown>` - Session metadata
|
|
353
|
+
- `onMessage?: (message: ChatMessage) => void` - New message callback
|
|
354
|
+
- `onError?: (error: Error) => void` - Error callback
|
|
355
|
+
- `className?: string` - CSS class name
|
|
356
|
+
- `styles?: SupportChatStyles` - Custom styles object
|
|
357
|
+
- `title?: string` - Chat header title
|
|
358
|
+
- `placeholder?: string` - Input placeholder text
|
|
359
|
+
- `maxHeight?: string` - Maximum container height
|
|
360
|
+
|
|
361
|
+
## Hooks
|
|
362
|
+
|
|
363
|
+
### useContactForm
|
|
364
|
+
|
|
365
|
+
Hook for managing contact form submission state.
|
|
366
|
+
|
|
367
|
+
**Options:**
|
|
368
|
+
- `onSuccess?: (response: CreateContactResponse) => void`
|
|
369
|
+
- `onError?: (error: ChannlizeError) => void`
|
|
370
|
+
|
|
371
|
+
**Returns:**
|
|
372
|
+
- `submit: (data: ContactFormData) => Promise<void>`
|
|
373
|
+
- `isSubmitting: boolean`
|
|
374
|
+
- `isSuccess: boolean`
|
|
375
|
+
- `error: ChannlizeError | null`
|
|
376
|
+
- `reset: () => void`
|
|
377
|
+
|
|
378
|
+
### useChatSession
|
|
379
|
+
|
|
380
|
+
Hook for managing chat sessions with real-time messaging.
|
|
381
|
+
|
|
382
|
+
**Options:**
|
|
383
|
+
- `autoConnect?: boolean`
|
|
384
|
+
- `metadata?: Record<string, unknown>`
|
|
385
|
+
- `onMessage?: (message: ChatMessage) => void`
|
|
386
|
+
- `onError?: (error: ChannlizeError) => void`
|
|
387
|
+
|
|
388
|
+
**Returns:**
|
|
389
|
+
- `session: ChatSession | null`
|
|
390
|
+
- `messages: ChatMessage[]`
|
|
391
|
+
- `isConnecting: boolean`
|
|
392
|
+
- `isConnected: boolean`
|
|
393
|
+
- `error: ChannlizeError | null`
|
|
394
|
+
- `sendMessage: (content: string, attachments?: File[]) => Promise<void>`
|
|
395
|
+
- `startSession: () => Promise<void>`
|
|
396
|
+
- `endSession: () => Promise<void>`
|
|
397
|
+
|
|
398
|
+
## Styling
|
|
399
|
+
|
|
400
|
+
All components accept a `styles` prop for custom styling. You can also use CSS classes with the `className` prop. Components use semantic class names prefixed with `channlize-`.
|
|
401
|
+
|
|
402
|
+
### CSS Classes
|
|
403
|
+
|
|
404
|
+
- `.channlize-contact-form`
|
|
405
|
+
- `.channlize-contact-form-success`
|
|
406
|
+
- `.channlize-field`
|
|
407
|
+
- `.channlize-error`
|
|
408
|
+
- `.channlize-chat-container`
|
|
409
|
+
- `.channlize-chat-header`
|
|
410
|
+
- `.channlize-chat-messages`
|
|
411
|
+
- `.channlize-message`
|
|
412
|
+
- `.channlize-message-user`
|
|
413
|
+
- `.channlize-message-agent`
|
|
414
|
+
- `.channlize-chat-input-container`
|
|
415
|
+
|
|
416
|
+
## TypeScript
|
|
417
|
+
|
|
418
|
+
This package is written in TypeScript and includes full type definitions. All components, hooks, and utilities are fully typed.
|
|
419
|
+
|
|
420
|
+
## License
|
|
421
|
+
|
|
422
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ChannlizeConfig, ChannlizeClient, CreateContactResponse, ChannlizeError, ContactFormData, ChatMessage, ChatSession } from '@channlize/core';
|
|
4
|
+
export { AuthenticationError, ChannlizeConfig, ChannlizeError, ChatMessage, ChatSession, ContactFormData, CreateChatSessionResponse, CreateContactResponse, FileAttachment, RateLimitError, SendMessageResponse, ValidationError } from '@channlize/core';
|
|
5
|
+
|
|
6
|
+
interface ChannlizeContextValue {
|
|
7
|
+
client: ChannlizeClient;
|
|
8
|
+
config: ChannlizeConfig;
|
|
9
|
+
}
|
|
10
|
+
interface ChannlizeProviderProps {
|
|
11
|
+
config: ChannlizeConfig;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provider component that makes Channlize client available to all child components
|
|
16
|
+
*/
|
|
17
|
+
declare function ChannlizeProvider({ config, children }: ChannlizeProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Hook to access the Channlize client and configuration
|
|
20
|
+
*/
|
|
21
|
+
declare function useChannlize(): ChannlizeContextValue;
|
|
22
|
+
|
|
23
|
+
interface UseContactFormOptions {
|
|
24
|
+
onSuccess?: (response: CreateContactResponse) => void;
|
|
25
|
+
onError?: (error: ChannlizeError) => void;
|
|
26
|
+
}
|
|
27
|
+
interface UseContactFormReturn {
|
|
28
|
+
submit: (data: ContactFormData) => Promise<void>;
|
|
29
|
+
isSubmitting: boolean;
|
|
30
|
+
isSuccess: boolean;
|
|
31
|
+
error: ChannlizeError | null;
|
|
32
|
+
reset: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook for handling contact form submissions
|
|
36
|
+
*/
|
|
37
|
+
declare function useContactForm(options?: UseContactFormOptions): UseContactFormReturn;
|
|
38
|
+
|
|
39
|
+
interface UseChatSessionOptions {
|
|
40
|
+
autoConnect?: boolean;
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
42
|
+
onMessage?: (message: ChatMessage) => void;
|
|
43
|
+
onError?: (error: ChannlizeError) => void;
|
|
44
|
+
sessionId?: string;
|
|
45
|
+
persistSession?: boolean;
|
|
46
|
+
storageKey?: string;
|
|
47
|
+
}
|
|
48
|
+
interface UseChatSessionReturn {
|
|
49
|
+
session: ChatSession | null;
|
|
50
|
+
messages: ChatMessage[];
|
|
51
|
+
isConnecting: boolean;
|
|
52
|
+
isConnected: boolean;
|
|
53
|
+
error: ChannlizeError | null;
|
|
54
|
+
sendMessage: (content: string, attachments?: File[]) => Promise<void>;
|
|
55
|
+
startSession: () => Promise<void>;
|
|
56
|
+
endSession: () => Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Hook for managing chat sessions with real-time messaging
|
|
60
|
+
*/
|
|
61
|
+
declare function useChatSession(options?: UseChatSessionOptions): UseChatSessionReturn;
|
|
62
|
+
|
|
63
|
+
interface FormProps {
|
|
64
|
+
/** Custom fields to include in the form */
|
|
65
|
+
customFields?: Array<{
|
|
66
|
+
name: string;
|
|
67
|
+
label: string;
|
|
68
|
+
type: 'text' | 'email' | 'textarea' | 'select';
|
|
69
|
+
required?: boolean;
|
|
70
|
+
options?: string[];
|
|
71
|
+
}>;
|
|
72
|
+
/** Callback when form is successfully submitted */
|
|
73
|
+
onSuccess?: () => void;
|
|
74
|
+
/** Callback when form submission fails */
|
|
75
|
+
onError?: (error: Error) => void;
|
|
76
|
+
/** Custom CSS classes */
|
|
77
|
+
className?: string;
|
|
78
|
+
/** Custom styles for form elements */
|
|
79
|
+
styles?: {
|
|
80
|
+
form?: React.CSSProperties;
|
|
81
|
+
field?: React.CSSProperties;
|
|
82
|
+
label?: React.CSSProperties;
|
|
83
|
+
input?: React.CSSProperties;
|
|
84
|
+
textarea?: React.CSSProperties;
|
|
85
|
+
button?: React.CSSProperties;
|
|
86
|
+
error?: React.CSSProperties;
|
|
87
|
+
success?: React.CSSProperties;
|
|
88
|
+
};
|
|
89
|
+
/** Button text */
|
|
90
|
+
submitText?: string;
|
|
91
|
+
/** Success message */
|
|
92
|
+
successMessage?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* ContactForm component - Alias for Form component
|
|
97
|
+
* Provides a form for collecting contact information and messages
|
|
98
|
+
*/
|
|
99
|
+
declare function ContactForm(props: FormProps): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface SupportChatProps extends UseChatSessionOptions {
|
|
102
|
+
/** Custom CSS classes */
|
|
103
|
+
className?: string;
|
|
104
|
+
/** Custom styles for chat elements */
|
|
105
|
+
styles?: {
|
|
106
|
+
container?: React.CSSProperties;
|
|
107
|
+
header?: React.CSSProperties;
|
|
108
|
+
messagesContainer?: React.CSSProperties;
|
|
109
|
+
message?: React.CSSProperties;
|
|
110
|
+
userMessage?: React.CSSProperties;
|
|
111
|
+
agentMessage?: React.CSSProperties;
|
|
112
|
+
inputContainer?: React.CSSProperties;
|
|
113
|
+
input?: React.CSSProperties;
|
|
114
|
+
button?: React.CSSProperties;
|
|
115
|
+
error?: React.CSSProperties;
|
|
116
|
+
timestamp?: React.CSSProperties;
|
|
117
|
+
};
|
|
118
|
+
/** Placeholder text for message input */
|
|
119
|
+
placeholder?: string;
|
|
120
|
+
/** Header title */
|
|
121
|
+
title?: string;
|
|
122
|
+
/** Button text */
|
|
123
|
+
sendButtonText?: string;
|
|
124
|
+
/** Show timestamps on messages */
|
|
125
|
+
showTimestamps?: boolean;
|
|
126
|
+
/** Allow file attachments */
|
|
127
|
+
allowAttachments?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* SupportChat component - Real-time chat interface
|
|
131
|
+
* Provides a complete chat UI with message history and real-time updates
|
|
132
|
+
*/
|
|
133
|
+
declare function SupportChat({ autoConnect, metadata, onMessage, onError, sessionId, persistSession, storageKey, className, styles, placeholder, title, sendButtonText, showTimestamps, allowAttachments, }: SupportChatProps): react_jsx_runtime.JSX.Element;
|
|
134
|
+
|
|
135
|
+
interface ChannlizeChatProps {
|
|
136
|
+
/** Channlize configuration */
|
|
137
|
+
config: ChannlizeConfig;
|
|
138
|
+
/** Position of the floating button */
|
|
139
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
140
|
+
/** Offset from edges in pixels */
|
|
141
|
+
offset?: {
|
|
142
|
+
x?: number;
|
|
143
|
+
y?: number;
|
|
144
|
+
};
|
|
145
|
+
/** Custom button element (overrides default button) */
|
|
146
|
+
buttonElement?: ReactNode;
|
|
147
|
+
/** Custom button icon (only used if buttonElement is not provided) */
|
|
148
|
+
buttonIcon?: ReactNode;
|
|
149
|
+
/** Button size in pixels */
|
|
150
|
+
buttonSize?: number;
|
|
151
|
+
/** Button colors */
|
|
152
|
+
buttonColors?: {
|
|
153
|
+
background?: string;
|
|
154
|
+
hover?: string;
|
|
155
|
+
text?: string;
|
|
156
|
+
};
|
|
157
|
+
/** Chat window props (passed to SupportChat) */
|
|
158
|
+
chatProps?: Omit<SupportChatProps, 'autoConnect'>;
|
|
159
|
+
/** Whether to start closed or open */
|
|
160
|
+
defaultOpen?: boolean;
|
|
161
|
+
/** Whether to show badge with unread count */
|
|
162
|
+
showBadge?: boolean;
|
|
163
|
+
/** Unread count (for badge) */
|
|
164
|
+
unreadCount?: number;
|
|
165
|
+
/** Custom z-index */
|
|
166
|
+
zIndex?: number;
|
|
167
|
+
/** Whether to show on mobile */
|
|
168
|
+
showOnMobile?: boolean;
|
|
169
|
+
/** Callback when chat opens */
|
|
170
|
+
onOpen?: () => void;
|
|
171
|
+
/** Callback when chat closes */
|
|
172
|
+
onClose?: () => void;
|
|
173
|
+
/** Whether to enable animations */
|
|
174
|
+
enableAnimations?: boolean;
|
|
175
|
+
/** Custom class for button container */
|
|
176
|
+
buttonClassName?: string;
|
|
177
|
+
/** Custom class for chat container */
|
|
178
|
+
chatClassName?: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* ChannlizeChat - All-in-one floating chat widget with provider
|
|
182
|
+
*
|
|
183
|
+
* Drop this component anywhere in your React app for instant live chat support.
|
|
184
|
+
* Includes the provider, floating button, and chat window.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* <ChannlizeChat
|
|
189
|
+
* config={{
|
|
190
|
+
* apiKey: "your-widget-key",
|
|
191
|
+
* projectId: "your-project-id",
|
|
192
|
+
* }}
|
|
193
|
+
* position="bottom-right"
|
|
194
|
+
* chatProps={{
|
|
195
|
+
* title: "Customer Support",
|
|
196
|
+
* placeholder: "How can we help?"
|
|
197
|
+
* }}
|
|
198
|
+
* />
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function ChannlizeChat({ config, position, offset, buttonElement, buttonIcon, buttonSize, buttonColors, chatProps, defaultOpen, showBadge, unreadCount, zIndex, showOnMobile, onOpen, onClose, enableAnimations, buttonClassName, chatClassName, }: ChannlizeChatProps): react_jsx_runtime.JSX.Element | null;
|
|
202
|
+
|
|
203
|
+
export { ChannlizeChat, ChannlizeProvider, ContactForm, SupportChat, useChannlize, useChatSession, useContactForm };
|