@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/dist/index.d.ts
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 };
|