@channlize/react 0.1.1 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @channlize/react
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ad8f04d: Redesign `ContactForm` to match the chat widget: scoped styles, `theme` (light / dark / auto / system), `primaryColor`, labels and placeholders, inline validation with accessible errors, loading / success / error states, a honeypot spam guard, and optional company and topic fields (`fields`, `topics`, `defaultValues`). Existing props keep working; `onSuccess` now also receives the API response. Export `ContactFormProps`, `ContactFormLabels` and `defaultContactFormLabels`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [69f414f]
12
+ - @channlize/core@0.2.1
13
+
14
+ ## 0.2.0
15
+
16
+ ### Minor Changes
17
+
18
+ - db7da26: Redesign the live-chat widget (`ChannlizeChat` / `SupportChat`).
19
+
20
+ - Header: brand avatar slot, title, and a calm status line ("Online · Replies in a few minutes"). The close button no longer overlaps anything; "End conversation" moved into a menu with a confirmation step; a clear minimize button.
21
+ - Messages: grouped by author with agent name and avatar, day separators, one timestamp per group (full date on hover), better bubble shapes, wrapping of long words and URLs, safe link detection (http/https only, no HTML), image and file attachment cards, and optimistic sending with "Sending…" / "Not sent · Retry · Remove".
22
+ - Welcome screen with `greeting`, `welcomeMessage` and optional `suggestions`.
23
+ - Composer: auto-growing textarea (Enter sends, Shift+Enter new line), send icon button disabled when empty, attach button with `allowAttachments`, `maxLength` counter, "Write a message…" placeholder.
24
+ - Connection: status and "Reconnecting…" banner are debounced, so the routine SSE reconnect every ~50s never flickers; a lost connection shows a banner with Retry.
25
+ - Theming: light and dark (`theme`, follows `prefers-color-scheme` by default), `primaryColor` / `primaryTextColor` with automatic readable text color; the hard-coded blue-to-purple gradient is gone. Existing `styles`, `buttonColors`, `className` props keep working.
26
+ - Launcher: new icon, unread badge counting agent replies received while closed (or `showBadge` + `unreadCount`), open/close animation that respects `prefers-reduced-motion`.
27
+ - Mobile: full-screen panel under 640px, safe-area insets, 16px input to avoid iOS zoom.
28
+ - Accessibility: the panel is a labelled dialog, focus moves in on open and back to the launcher on close, Esc closes, the message list is a polite live region, all icon buttons are labelled.
29
+ - Isolation: a scoped stylesheet with a reset under `.channlize-widget`; `ChannlizeChat` renders through a portal into `document.body`. Default `zIndex` is now `2147483000`.
30
+ - New props: `ChannlizeChat` `primaryColor`, `theme`; `SupportChat` `avatarUrl`, `avatar`, `statusText`, `greeting`, `welcomeMessage`, `suggestions`, `theme`, `primaryColor`, `primaryTextColor`, `locale`, `maxLength`, `allowEndChat`, `onMinimize`, `labels`. `useChatSession` returns `reconnect()`. Exported types: `SupportChatProps`, `SupportChatLabels`, `ChatTheme`, `ChannlizeChatProps`, `UseChatSessionOptions`, `UseChatSessionReturn`, and `defaultSupportChatLabels`.
31
+
32
+ ## 0.1.2
33
+
34
+ ### Patch Changes
35
+
36
+ - c113208: Add Events: post a Slack message from your server when something happens.
37
+
38
+ - `@channlize/core`: `client.notify(event, data?, { idempotencyKey?, channel? })` and a standalone `createNotifier()` that reads `CHANNLIZE_SERVER_API_KEY` / `CHANNLIZE_API_KEY` and `CHANNLIZE_PROJECT_ID`. Both call `POST /v1/notify` with the server API key (write scope). Event keys and data can be typed with `createNotifier<AppEvents>()` or by augmenting `ChannlizeEvents`. `trackEvent` / `trackServerEvent` are unchanged and now documented as log tracking. Fix: an explicit `baseUrl: undefined` or `timeout: undefined` no longer overrides the defaults.
39
+ - `@channlize/mcp`: new `notify_event` tool, enabled with `--server-api-key` / `CHANNLIZE_SERVER_API_KEY`.
40
+ - `@channlize/react`: docs only. `useChannlizeAnalytics().track` is documented as log tracking.
41
+
42
+ - Updated dependencies [c113208]
43
+ - @channlize/core@0.2.0
44
+
3
45
  ## 0.1.1
4
46
 
5
47
  ### Patch Changes
package/README.md CHANGED
@@ -254,16 +254,18 @@ function CustomChat() {
254
254
  | `buttonElement` | `ReactNode` | - | Custom button (overrides default) |
255
255
  | `buttonIcon` | `ReactNode` | - | Custom icon (used if buttonElement not provided) |
256
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 |
257
+ | `buttonColors` | `{ background?: string; hover?: string; text?: string }` | `primaryColor` | Launcher colors |
258
+ | `primaryColor` | `string` | `'#2563eb'` | Accent color for the launcher, header, customer bubbles and send button (hex recommended; text on it is picked for contrast) |
259
+ | `theme` | `'auto' \| 'light' \| 'dark'` | `'auto'` | Color scheme; `auto` follows `prefers-color-scheme` |
260
+ | `chatProps` | `SupportChatProps` | `{}` | Props passed to internal SupportChat component (title, greeting, suggestions...) |
259
261
  | `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 |
262
+ | `showBadge` | `boolean` | `false` | Show `unreadCount` instead of the built-in count of agent replies received while closed |
263
+ | `unreadCount` | `number` | `0` | Unread message count (with `showBadge`) |
264
+ | `zIndex` | `number` | `2147483000` | CSS z-index |
265
+ | `showOnMobile` | `boolean` | `true` | Whether to show the launcher on screens under 640px |
264
266
  | `onOpen` | `() => void` | - | Callback when chat opens |
265
267
  | `onClose` | `() => void` | - | Callback when chat closes |
266
- | `enableAnimations` | `boolean` | `true` | Enable smooth animations |
268
+ | `enableAnimations` | `boolean` | `true` | Enable animations (always reduced with `prefers-reduced-motion`) |
267
269
  | `buttonClassName` | `string` | `''` | Custom class for button container |
268
270
  | `chatClassName` | `string` | `''` | Custom class for chat container |
269
271
 
@@ -290,13 +292,25 @@ function CustomChat() {
290
292
  }}
291
293
  />
292
294
 
293
- // With custom chat options
295
+ // Branding, greeting and quick suggestions
296
+ <ChannlizeChat
297
+ config={{ apiKey: 'key', projectId: 'id' }}
298
+ primaryColor="#0f766e"
299
+ chatProps={{
300
+ title: 'Acme',
301
+ avatarUrl: 'https://acme.com/logo.png',
302
+ statusText: 'Replies in a few minutes',
303
+ greeting: 'Hi there!',
304
+ welcomeMessage: 'Ask us anything. We are here to help.',
305
+ suggestions: ['How does pricing work?', 'Talk to sales'],
306
+ allowAttachments: true,
307
+ }}
308
+ />
309
+
310
+ // Inline style overrides still apply on top of the theme
294
311
  <ChannlizeChat
295
312
  config={{ apiKey: 'key', projectId: 'id' }}
296
313
  chatProps={{
297
- title: "24/7 Support",
298
- placeholder: "Ask us anything...",
299
- showTimestamps: true,
300
314
  styles: {
301
315
  header: {
302
316
  background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
@@ -332,31 +346,76 @@ function CustomChat() {
332
346
 
333
347
  ### ContactForm
334
348
 
335
- A complete contact form component with validation and submission handling.
349
+ A themed, accessible contact form that posts to Channlize (and from there to
350
+ your Slack). Styles are scoped to `.channlize-contact`, so it looks the same on
351
+ any page and never leaks into it. It has inline validation, a focus move to the
352
+ first invalid field, errors linked to their fields with `aria-describedby`,
353
+ loading, success and error states, and a hidden honeypot field against simple
354
+ bots.
355
+
356
+ ```tsx
357
+ <ContactForm
358
+ theme="auto"
359
+ primaryColor="#2563eb"
360
+ fields={{ company: 'optional' }}
361
+ topics={['Sales', 'Support', 'Billing']}
362
+ defaultValues={{ topic: searchParams.get('topic') ?? undefined }}
363
+ labels={{ footnote: 'We usually reply within one business day.' }}
364
+ onSuccess={({ conversationId }) => console.log('Sent', conversationId)}
365
+ />
366
+ ```
336
367
 
337
368
  **Props:**
338
- - `customFields?: Array<CustomField>` - Additional form fields
339
- - `onSuccess?: () => void` - Success callback
369
+ - `customFields?: ContactFormCustomField[]` - Extra fields (`text`, `email`, `textarea`, `select`), sent as `customFields`
370
+ - `onSuccess?: (response: CreateContactResponse) => void` - Success callback
340
371
  - `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
372
+ - `className?: string` - CSS class name on the root
373
+ - `styles?` - Inline style overrides: `form`, `field`, `label`, `input`, `textarea`, `button`, `error`, `success`
374
+ - `submitText?: string` / `successMessage?: string` - Shortcuts for `labels.submit` / `labels.successMessage`
375
+ - `theme?: 'light' | 'dark' | 'auto' | 'system'` - Colour scheme (default `'light'`; `auto` and `system` follow `prefers-color-scheme`)
376
+ - `primaryColor?: string`, `primaryTextColor?: string` - Accent colour (button, focus ring) and the text on it
377
+ - `variant?: 'card' | 'plain'` - `card` (default) draws a themed surface; `plain` inherits the host's background
378
+ - `unstyled?: boolean` - Skip the built-in stylesheet (class names stay)
379
+ - `fields?: { name?, company?, subject?, topic? }` - Each `'required' | 'optional' | 'hidden'` (defaults: name required, subject optional, company hidden, topic optional when `topics` is set). Email and message are always required.
380
+ - `topics?: Array<string | { value: string; label?: string }>` - Shows a topic select. The chosen label is sent as `customFields.topic` and used as the subject when that is blank; `value` identifies the option for `defaultValues`
381
+ - `defaultValues?: Partial<{ name, email, company, subject, topic, message }>` - Prefill; `topic` matches an option's value or label case-insensitively (e.g. `?topic=sales`)
382
+ - `labels?: Partial<ContactFormLabels>` - Override any label, placeholder or message (see `defaultContactFormLabels`)
383
+ - `minMessageLength?: number` (default `10`, what the API accepts), `maxMessageLength?: number` (default `5000`)
384
+ - `honeypot?: boolean` - Hidden spam-trap field; a filled trap gets a fake success and nothing is sent (default `true`)
385
+ - `showSuccessState?: boolean` - Show the built-in success screen (default `true`); when `false` the form clears and announces success
386
+ - `idPrefix?: string` - Prefix of field ids (default `channlize`, e.g. `channlize-email`)
345
387
 
346
388
  ### SupportChat
347
389
 
348
- A real-time chat widget with message history and file attachments.
390
+ A real-time chat panel with grouped messages, day separators, safe link
391
+ detection, attachments, optimistic sending with retry, and a debounced
392
+ connection status (routine stream reconnects never flash in the UI). It fills
393
+ its parent, so give the parent a height.
349
394
 
350
395
  **Props:**
351
- - `autoStart?: boolean` - Auto-start chat session
396
+ - `autoConnect?: boolean` - Start (or resume) the session on mount (default `true`)
352
397
  - `metadata?: Record<string, unknown>` - Session metadata
353
398
  - `onMessage?: (message: ChatMessage) => void` - New message callback
354
399
  - `onError?: (error: Error) => void` - Error callback
355
400
  - `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
401
+ - `styles?` - Inline style overrides: `container`, `header`, `messagesContainer`, `message`, `userMessage`, `agentMessage`, `inputContainer`, `input`, `button`, `error`, `timestamp`
402
+ - `title?: string` - Team or brand name in the header (default `'Support'`)
403
+ - `avatarUrl?: string` / `avatar?: ReactNode` - Logo in the header and welcome screen (initials otherwise)
404
+ - `statusText?: string` - Shown after "Online" (default `'Replies in a few minutes'`; `''` hides it)
405
+ - `greeting?: string` / `welcomeMessage?: string` - Welcome screen copy
406
+ - `suggestions?: string[]` - Quick replies on the welcome screen
407
+ - `placeholder?: string` - Input placeholder (default `'Write a message…'`)
408
+ - `sendButtonText?: string` - Accessible label of the send icon button
409
+ - `showTimestamps?: boolean` - One time per message group, full date on hover (default `true`)
410
+ - `allowAttachments?: boolean` - Show the attach button (default `false`)
411
+ - `theme?: 'auto' | 'light' | 'dark'`, `primaryColor?: string`, `primaryTextColor?: string` - Theming
412
+ - `locale?: string` - Locale for dates and times (default: browser)
413
+ - `maxLength?: number` - Maximum message length (default `5000`)
414
+ - `allowEndChat?: boolean` - "End conversation" in the header menu, with confirmation (default `true`)
415
+ - `onMinimize?: () => void` - Shows a minimize button; Esc calls it
416
+ - `labels?: Partial<SupportChatLabels>` - Override any UI string (see `defaultSupportChatLabels`)
417
+
418
+ Keyboard: Enter sends, Shift+Enter adds a new line (on touch-only devices Enter adds a new line and the button sends).
360
419
 
361
420
  ## Hooks
362
421
 
@@ -394,11 +453,25 @@ Hook for managing chat sessions with real-time messaging.
394
453
  - `sendMessage: (content: string, attachments?: File[]) => Promise<void>`
395
454
  - `startSession: () => Promise<void>`
396
455
  - `endSession: () => Promise<void>`
456
+ - `reconnect: () => void` - Reopen the real-time stream after it failed (`error.code === 'SSE_ERROR'`)
457
+
458
+ ### useChannlizeAnalytics (log tracking)
459
+
460
+ Records logs from the browser with the widget key; they show up under **Log tracking** in the dashboard.
461
+
462
+ ```tsx
463
+ const { track } = useChannlizeAnalytics();
464
+ track('cta_clicked', { properties: { section: 'hero' } });
465
+ ```
466
+
467
+ To post a Slack message when something happens (a signup, a payment), use **Events** from your server — `createNotifier` / `client.notify` in [`@channlize/core`](../core/README.md#events-notify-slack-from-your-server). Events need a server API key, so they are never sent from the browser.
397
468
 
398
469
  ## Styling
399
470
 
400
471
  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
472
 
473
+ The chat widget ships its own small stylesheet, scoped under `.channlize-widget`, with a reset so host-page element styles (`button`, `h2`, `textarea`...) don't leak in, and nothing leaks out. `ChannlizeChat` renders into `document.body` through a portal so host transforms and `overflow` can't clip it. Theme tokens are CSS custom properties on `.channlize-widget` (`--chz-primary`, `--chz-on-primary`, `--chz-bg`, `--chz-text`, `--chz-muted`, `--chz-border`, `--chz-bubble`...) and can be overridden from your CSS.
474
+
402
475
  ### CSS Classes
403
476
 
404
477
  - `.channlize-contact-form`
@@ -408,7 +481,8 @@ All components accept a `styles` prop for custom styling. You can also use CSS c
408
481
  - `.channlize-chat-container`
409
482
  - `.channlize-chat-header`
410
483
  - `.channlize-chat-messages`
411
- - `.channlize-message`
484
+ - `.channlize-chat-status` (`data-status="online|connecting|offline"`)
485
+ - `.channlize-message` (`data-pos`, `data-status="sent|sending|failed"`)
412
486
  - `.channlize-message-user`
413
487
  - `.channlize-message-agent`
414
488
  - `.channlize-chat-input-container`
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
3
  import { ChannlizeConfig, ChannlizeClient, CreateContactResponse, ChannlizeError, ContactFormData, ChatMessage, ChatSession, TrackEventOptions } from '@channlize/core';
4
4
  export { AuthenticationError, ChannlizeConfig, ChannlizeError, ChatMessage, ChatSession, ContactFormData, CreateChatSessionResponse, CreateContactResponse, EventSeverity, FileAttachment, RateLimitError, SendMessageResponse, TrackEventOptions, ValidationError } from '@channlize/core';
5
5
 
@@ -54,6 +54,11 @@ interface UseChatSessionReturn {
54
54
  sendMessage: (content: string, attachments?: File[]) => Promise<void>;
55
55
  startSession: () => Promise<void>;
56
56
  endSession: () => Promise<void>;
57
+ /**
58
+ * Reopen the real-time stream for the current session after it failed
59
+ * (`error.code === 'SSE_ERROR'`). Routine reconnects are automatic.
60
+ */
61
+ reconnect: () => void;
57
62
  }
58
63
  /**
59
64
  * Hook for managing chat sessions with real-time messaging
@@ -61,7 +66,10 @@ interface UseChatSessionReturn {
61
66
  declare function useChatSession(options?: UseChatSessionOptions): UseChatSessionReturn;
62
67
 
63
68
  /**
64
- * Returns a stable `track` function bound to the provider client for event tracking (browser / widget key).
69
+ * Returns a stable `track` function bound to the provider client for log
70
+ * tracking (browser / widget key; shown under Log tracking in the
71
+ * dashboard). To post a Slack message when something happens, use Events
72
+ * (`notify` from `@channlize/core`) on your server instead.
65
73
  */
66
74
  declare function useChannlizeAnalytics(): {
67
75
  track: (name: string, options?: TrackEventOptions) => Promise<{
@@ -70,48 +78,186 @@ declare function useChannlizeAnalytics(): {
70
78
  }>;
71
79
  };
72
80
 
81
+ /** `auto` and `system` both follow `prefers-color-scheme`. */
82
+ type ContactFormTheme = 'auto' | 'system' | 'light' | 'dark';
83
+ /** Whether a built-in field is shown, and whether it must be filled in. */
84
+ type ContactFieldMode = 'required' | 'optional' | 'hidden';
85
+ interface ContactFormTopic {
86
+ /** Identifies the option, e.g. for `defaultValues.topic` from a URL */
87
+ value: string;
88
+ /**
89
+ * Shown in the select, sent as `customFields.topic`, and used as the
90
+ * subject when that is blank. Defaults to `value`.
91
+ */
92
+ label?: string;
93
+ }
94
+ /** The built-in fields' values (also what `defaultValues` takes). */
95
+ interface ContactFormValues {
96
+ name: string;
97
+ email: string;
98
+ company: string;
99
+ subject: string;
100
+ topic: string;
101
+ message: string;
102
+ }
103
+ interface ContactFormCustomField {
104
+ name: string;
105
+ label: string;
106
+ type: 'text' | 'email' | 'textarea' | 'select';
107
+ required?: boolean;
108
+ options?: string[];
109
+ placeholder?: string;
110
+ }
111
+ /** Every user-facing string in the form, for copy changes or translation. */
112
+ interface ContactFormLabels {
113
+ name: string;
114
+ email: string;
115
+ company: string;
116
+ subject: string;
117
+ topic: string;
118
+ message: string;
119
+ namePlaceholder: string;
120
+ emailPlaceholder: string;
121
+ companyPlaceholder: string;
122
+ subjectPlaceholder: string;
123
+ topicPlaceholder: string;
124
+ messagePlaceholder: string;
125
+ optional: string;
126
+ submit: string;
127
+ submitting: string;
128
+ successTitle: string;
129
+ successMessage: string;
130
+ sendAnother: string;
131
+ /** Shown under a required field left empty */
132
+ errorRequired: string;
133
+ /** Shown under a required select left on the placeholder */
134
+ errorSelect: string;
135
+ errorEmail: string;
136
+ /** `{min}` is replaced with the minimum length */
137
+ errorTooShort: string;
138
+ /** `{max}` is replaced with the maximum length */
139
+ errorTooLong: string;
140
+ /** Announced when a submit is blocked by invalid fields */
141
+ errorSummary: string;
142
+ /** Shown when sending fails */
143
+ errorGeneric: string;
144
+ /** Shown when the API rate limit is hit */
145
+ errorRateLimit: string;
146
+ /** Small print under the submit button; '' hides it */
147
+ footnote: string;
148
+ }
149
+ declare const defaultContactFormLabels: ContactFormLabels;
73
150
  interface FormProps {
74
- /** Custom fields to include in the form */
75
- customFields?: Array<{
76
- name: string;
77
- label: string;
78
- type: 'text' | 'email' | 'textarea' | 'select';
79
- required?: boolean;
80
- options?: string[];
81
- }>;
151
+ /** Custom fields to include in the form (sent as `customFields`) */
152
+ customFields?: ContactFormCustomField[];
82
153
  /** Callback when form is successfully submitted */
83
- onSuccess?: () => void;
154
+ onSuccess?: (response: CreateContactResponse) => void;
84
155
  /** Callback when form submission fails */
85
156
  onError?: (error: Error) => void;
86
157
  /** Custom CSS classes */
87
158
  className?: string;
88
- /** Custom styles for form elements */
159
+ /** Custom styles for form elements (applied inline, so they win over the theme) */
89
160
  styles?: {
90
- form?: React.CSSProperties;
91
- field?: React.CSSProperties;
92
- label?: React.CSSProperties;
93
- input?: React.CSSProperties;
94
- textarea?: React.CSSProperties;
95
- button?: React.CSSProperties;
96
- error?: React.CSSProperties;
97
- success?: React.CSSProperties;
161
+ form?: CSSProperties;
162
+ field?: CSSProperties;
163
+ label?: CSSProperties;
164
+ input?: CSSProperties;
165
+ textarea?: CSSProperties;
166
+ button?: CSSProperties;
167
+ error?: CSSProperties;
168
+ success?: CSSProperties;
98
169
  };
99
- /** Button text */
170
+ /** Button text (same as `labels.submit`) */
100
171
  submitText?: string;
101
- /** Success message */
172
+ /** Success message (same as `labels.successMessage`) */
102
173
  successMessage?: string;
174
+ /** Colour scheme (default `light`). `auto` / `system` follow `prefers-color-scheme`. */
175
+ theme?: ContactFormTheme;
176
+ /** Accent colour (button, focus ring). Hex recommended. */
177
+ primaryColor?: string;
178
+ /** Text colour on the accent colour. Defaults to white or near-black, whichever is readable. */
179
+ primaryTextColor?: string;
180
+ /** `card` (default) draws a themed surface with padding; `plain` inherits the host's. */
181
+ variant?: 'card' | 'plain';
182
+ /** Skip the built-in stylesheet entirely (class names stay for your own CSS) */
183
+ unstyled?: boolean;
184
+ /**
185
+ * Built-in fields. Email and message are always required.
186
+ * Defaults: name `required`, subject `optional`, company `hidden`,
187
+ * topic `optional` when `topics` is set.
188
+ */
189
+ fields?: {
190
+ name?: ContactFieldMode;
191
+ company?: ContactFieldMode;
192
+ subject?: ContactFieldMode;
193
+ topic?: ContactFieldMode;
194
+ };
195
+ /** Options of the topic select; it is shown only when this is set */
196
+ topics?: Array<string | ContactFormTopic>;
197
+ /**
198
+ * Initial values, e.g. a topic from the URL (`?topic=sales`). A topic
199
+ * matches an option's value or label, case-insensitively.
200
+ */
201
+ defaultValues?: Partial<ContactFormValues>;
202
+ /** Override any user-facing string */
203
+ labels?: Partial<ContactFormLabels>;
204
+ /** Minimum message length (default `10`, what the Channlize API accepts) */
205
+ minMessageLength?: number;
206
+ /** Maximum message length (default `5000`) */
207
+ maxMessageLength?: number;
208
+ /** Add a hidden honeypot field; bots that fill it get a fake success (default `true`) */
209
+ honeypot?: boolean;
210
+ /** Show the built-in success state after sending (default `true`) */
211
+ showSuccessState?: boolean;
212
+ /** Prefix of the fields' ids (default `channlize`, e.g. `channlize-email`) */
213
+ idPrefix?: string;
103
214
  }
104
215
 
105
216
  /**
106
- * ContactForm component - Alias for Form component
107
- * Provides a form for collecting contact information and messages
217
+ * ContactForm component
218
+ *
219
+ * A themed, accessible contact form that posts to Channlize (and from there
220
+ * to your Slack). Inline validation, loading / success / error states, an
221
+ * optional topic select and company field, and a honeypot spam guard.
222
+ * Must be rendered inside `<ChannlizeProvider>`.
108
223
  */
109
224
  declare function ContactForm(props: FormProps): react.JSX.Element;
225
+ type ContactFormProps = FormProps;
110
226
 
227
+ type ChatTheme = 'auto' | 'light' | 'dark';
228
+ /** Every user-facing string in the chat, for copy changes or translation. */
229
+ interface SupportChatLabels {
230
+ online: string;
231
+ connecting: string;
232
+ reconnecting: string;
233
+ offline: string;
234
+ connectionLost: string;
235
+ startFailed: string;
236
+ retry: string;
237
+ today: string;
238
+ yesterday: string;
239
+ you: string;
240
+ sending: string;
241
+ failed: string;
242
+ remove: string;
243
+ moreOptions: string;
244
+ minimize: string;
245
+ endChat: string;
246
+ endChatTitle: string;
247
+ endChatDescription: string;
248
+ endChatConfirm: string;
249
+ cancel: string;
250
+ attach: string;
251
+ removeAttachment: string;
252
+ messages: string;
253
+ conversationEnded: string;
254
+ charactersLeft: string;
255
+ }
256
+ declare const defaultSupportChatLabels: SupportChatLabels;
111
257
  interface SupportChatProps extends UseChatSessionOptions {
112
258
  /** Custom CSS classes */
113
259
  className?: string;
114
- /** Custom styles for chat elements */
260
+ /** Custom styles for chat elements (applied inline, so they win over the theme) */
115
261
  styles?: {
116
262
  container?: React.CSSProperties;
117
263
  header?: React.CSSProperties;
@@ -127,20 +273,48 @@ interface SupportChatProps extends UseChatSessionOptions {
127
273
  };
128
274
  /** Placeholder text for message input */
129
275
  placeholder?: string;
130
- /** Header title */
276
+ /** Header title: your team or brand name */
131
277
  title?: string;
132
- /** Button text */
278
+ /** Accessible label (and tooltip) of the send button */
133
279
  sendButtonText?: string;
134
280
  /** Show timestamps on messages */
135
281
  showTimestamps?: boolean;
136
282
  /** Allow file attachments */
137
283
  allowAttachments?: boolean;
284
+ /** Logo or team avatar URL, shown in the header and on the welcome screen */
285
+ avatarUrl?: string;
286
+ /** Custom avatar element (overrides `avatarUrl`) */
287
+ avatar?: ReactNode;
288
+ /** Text after "Online" in the header, e.g. "Replies in a few minutes". Set to '' to hide. */
289
+ statusText?: string;
290
+ /** Welcome heading shown before the first message */
291
+ greeting?: string;
292
+ /** Welcome text shown under the greeting */
293
+ welcomeMessage?: string;
294
+ /** Quick replies shown on the welcome screen; clicking one sends it */
295
+ suggestions?: string[];
296
+ /** Colour scheme. `auto` follows `prefers-color-scheme`. */
297
+ theme?: ChatTheme;
298
+ /** Accent colour (header, customer bubbles, send button). Hex recommended. */
299
+ primaryColor?: string;
300
+ /** Text colour on the accent colour. Defaults to white or near-black, whichever is readable. */
301
+ primaryTextColor?: string;
302
+ /** Locale for dates and times (defaults to the browser locale) */
303
+ locale?: string;
304
+ /** Maximum message length */
305
+ maxLength?: number;
306
+ /** Show "End conversation" in the header menu */
307
+ allowEndChat?: boolean;
308
+ /** When set, a minimize button is shown in the header and Esc calls it */
309
+ onMinimize?: () => void;
310
+ /** Override any user-facing string */
311
+ labels?: Partial<SupportChatLabels>;
138
312
  }
139
313
  /**
140
314
  * SupportChat component - Real-time chat interface
141
315
  * Provides a complete chat UI with message history and real-time updates
142
316
  */
143
- declare function SupportChat({ autoConnect, metadata, onMessage, onError, sessionId, persistSession, storageKey, className, styles, placeholder, title, sendButtonText, showTimestamps, allowAttachments, }: SupportChatProps): react.JSX.Element;
317
+ declare function SupportChat({ autoConnect, metadata, onMessage, onError, sessionId, persistSession, storageKey, className, styles, placeholder, title, sendButtonText, showTimestamps, allowAttachments, avatarUrl, avatar, statusText, greeting, welcomeMessage, suggestions, theme, primaryColor, primaryTextColor, locale, maxLength, allowEndChat, onMinimize, labels: labelOverrides, }: SupportChatProps): react.JSX.Element;
144
318
 
145
319
  interface ChannlizeChatProps {
146
320
  /** Channlize configuration */
@@ -158,29 +332,36 @@ interface ChannlizeChatProps {
158
332
  buttonIcon?: ReactNode;
159
333
  /** Button size in pixels */
160
334
  buttonSize?: number;
161
- /** Button colors */
335
+ /** Launcher colours. Default to `primaryColor`. */
162
336
  buttonColors?: {
163
337
  background?: string;
164
338
  hover?: string;
165
339
  text?: string;
166
340
  };
167
341
  /** Chat window props (passed to SupportChat) */
168
- chatProps?: Omit<SupportChatProps, 'autoConnect'>;
342
+ chatProps?: Omit<SupportChatProps, 'autoConnect' | 'onMinimize'>;
343
+ /** Accent colour for the launcher and chat window (hex recommended) */
344
+ primaryColor?: string;
345
+ /** Colour scheme. `auto` (default) follows `prefers-color-scheme`. */
346
+ theme?: ChatTheme;
169
347
  /** Whether to start closed or open */
170
348
  defaultOpen?: boolean;
171
- /** Whether to show badge with unread count */
349
+ /**
350
+ * Show `unreadCount` on the launcher instead of the built-in count. Without
351
+ * it, the launcher counts agent replies received while the chat is closed.
352
+ */
172
353
  showBadge?: boolean;
173
- /** Unread count (for badge) */
354
+ /** Unread count (for badge, used with `showBadge`) */
174
355
  unreadCount?: number;
175
356
  /** Custom z-index */
176
357
  zIndex?: number;
177
- /** Whether to show on mobile */
358
+ /** Whether to show the launcher on small screens (< 640px) */
178
359
  showOnMobile?: boolean;
179
360
  /** Callback when chat opens */
180
361
  onOpen?: () => void;
181
362
  /** Callback when chat closes */
182
363
  onClose?: () => void;
183
- /** Whether to enable animations */
364
+ /** Whether to enable animations (always reduced with `prefers-reduced-motion`) */
184
365
  enableAnimations?: boolean;
185
366
  /** Custom class for button container */
186
367
  buttonClassName?: string;
@@ -201,13 +382,16 @@ interface ChannlizeChatProps {
201
382
  * projectId: "your-project-id",
202
383
  * }}
203
384
  * position="bottom-right"
385
+ * primaryColor="#2563eb"
204
386
  * chatProps={{
205
- * title: "Customer Support",
206
- * placeholder: "How can we help?"
387
+ * title: "Acme Support",
388
+ * greeting: "Hi there!",
389
+ * welcomeMessage: "Ask us anything.",
207
390
  * }}
208
391
  * />
209
392
  * ```
210
393
  */
211
- declare function ChannlizeChat({ config, position, offset, buttonElement, buttonIcon, buttonSize, buttonColors, chatProps, defaultOpen, showBadge, unreadCount, zIndex, showOnMobile, onOpen, onClose, enableAnimations, buttonClassName, chatClassName, }: ChannlizeChatProps): react.JSX.Element | null;
394
+ declare function ChannlizeChat({ config, position, offset, buttonElement, buttonIcon, buttonSize, buttonColors, chatProps, primaryColor, theme, defaultOpen, showBadge, unreadCount, zIndex, showOnMobile, onOpen, onClose, enableAnimations, buttonClassName, chatClassName, }: ChannlizeChatProps): react.JSX.Element | null;
212
395
 
213
- export { ChannlizeChat, ChannlizeProvider, ContactForm, SupportChat, useChannlize, useChannlizeAnalytics, useChatSession, useContactForm };
396
+ export { ChannlizeChat, ChannlizeProvider, ContactForm, SupportChat, defaultContactFormLabels, defaultSupportChatLabels, useChannlize, useChannlizeAnalytics, useChatSession, useContactForm };
397
+ export type { ChannlizeChatProps, ChatTheme, ContactFieldMode, ContactFormCustomField, ContactFormLabels, ContactFormProps, ContactFormTheme, ContactFormTopic, ContactFormValues, SupportChatLabels, SupportChatProps, UseChatSessionOptions, UseChatSessionReturn };