@customerhero/js 2.1.1 → 2.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/README.md +19 -0
- package/dist/index.cjs +238 -5
- package/dist/index.d.cts +181 -2
- package/dist/index.d.ts +181 -2
- package/dist/index.js +232 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type";
|
|
1
|
+
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "incident_dismiss" | "incident_default_link_label";
|
|
2
2
|
type Translations = Record<TranslationKey, string>;
|
|
3
3
|
|
|
4
4
|
declare const SUPPORTED_LOCALES: readonly ["en", "es", "pt-BR", "pt-PT", "fr", "de", "it", "nl", "pl", "tr", "ar", "ja", "ko", "zh-CN", "zh-TW"];
|
|
@@ -35,6 +35,52 @@ interface CustomerHeroChatConfig {
|
|
|
35
35
|
locale?: string;
|
|
36
36
|
/** Predefined quick-reply options shown before the user sends a message */
|
|
37
37
|
suggestedMessages?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Color scheme. `auto` follows the visitor's OS preference; `light` and
|
|
40
|
+
* `dark` force a fixed palette. Defaults to `light` when unset.
|
|
41
|
+
*/
|
|
42
|
+
colorScheme?: "auto" | "light" | "dark";
|
|
43
|
+
/** Primary color used in dark mode. Only honoured when the effective
|
|
44
|
+
* scheme resolves to dark; never auto-derived from `primaryColor`. */
|
|
45
|
+
primaryColorDark?: string;
|
|
46
|
+
/** Background color used in dark mode. Only honoured when the effective
|
|
47
|
+
* scheme resolves to dark; never auto-derived from `backgroundColor`. */
|
|
48
|
+
backgroundColorDark?: string;
|
|
49
|
+
/** Text color used in dark mode. Only honoured when the effective scheme
|
|
50
|
+
* resolves to dark; never auto-derived from `textColor`. */
|
|
51
|
+
textColorDark?: string;
|
|
52
|
+
/** Widget size preset. Affects launcher diameter, panel dimensions, and
|
|
53
|
+
* base font size. Defaults to `default`. */
|
|
54
|
+
size?: "compact" | "default" | "large";
|
|
55
|
+
/** Corner radius preset for the chat panel. `soft` ~ small radius,
|
|
56
|
+
* `rounded` ~ medium (default), `square` ~ 0. */
|
|
57
|
+
cornerStyle?: "soft" | "rounded" | "square";
|
|
58
|
+
/** Launcher (floating bubble) customization. Each field is optional. */
|
|
59
|
+
launcher?: {
|
|
60
|
+
/** Custom launcher icon URL. Replaces the default chat-bubble glyph. */
|
|
61
|
+
iconUrl?: string;
|
|
62
|
+
/** Optional CTA label shown next to the launcher (turns the bubble into
|
|
63
|
+
* a pill). Max 60 characters. */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** When true, render a small green dot on the launcher to advertise
|
|
66
|
+
* agent availability. The host site is responsible for keeping
|
|
67
|
+
* business-hours state in sync; the SDK only renders the dot. */
|
|
68
|
+
showOnlineDot?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Pixel offsets so the widget can sit above sticky cookie bars or chat
|
|
71
|
+
* CTAs. Each axis defaults to 20 px when unset. Clamped to 0–1000. */
|
|
72
|
+
offset?: {
|
|
73
|
+
bottom?: number;
|
|
74
|
+
side?: number;
|
|
75
|
+
};
|
|
76
|
+
/** Z-index override for sites whose overlays clip the widget. Defaults
|
|
77
|
+
* to 99999. Capped at 2_000_000_000. */
|
|
78
|
+
zIndex?: number;
|
|
79
|
+
/** When false, the input's attach button is hidden so visitors can't
|
|
80
|
+
* even attempt an upload (the server enforces the same flag). Defaults
|
|
81
|
+
* to true. Per-chatbot, sourced from the public widget config endpoint
|
|
82
|
+
* but overrideable on the host. */
|
|
83
|
+
allowAttachments?: boolean;
|
|
38
84
|
}
|
|
39
85
|
|
|
40
86
|
interface ResolvedConfig {
|
|
@@ -51,6 +97,23 @@ interface ResolvedConfig {
|
|
|
51
97
|
suggestedMessages: string[];
|
|
52
98
|
/** Per-chatbot overrides for any translation key, optionally per-locale. */
|
|
53
99
|
stringOverrides?: StringOverrides;
|
|
100
|
+
colorScheme: "auto" | "light" | "dark";
|
|
101
|
+
primaryColorDark?: string;
|
|
102
|
+
backgroundColorDark?: string;
|
|
103
|
+
textColorDark?: string;
|
|
104
|
+
size: "compact" | "default" | "large";
|
|
105
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
106
|
+
launcher: {
|
|
107
|
+
iconUrl?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
showOnlineDot: boolean;
|
|
110
|
+
};
|
|
111
|
+
offset: {
|
|
112
|
+
bottom: number;
|
|
113
|
+
side: number;
|
|
114
|
+
};
|
|
115
|
+
zIndex: number;
|
|
116
|
+
allowAttachments: boolean;
|
|
54
117
|
}
|
|
55
118
|
interface MessageSource {
|
|
56
119
|
index: number;
|
|
@@ -244,6 +307,20 @@ interface PreChatSubmission {
|
|
|
244
307
|
/** Keyed answers from text/textarea/select/consent fields. */
|
|
245
308
|
properties?: Record<string, string | number | boolean>;
|
|
246
309
|
}
|
|
310
|
+
interface IncidentBanner {
|
|
311
|
+
severity: "info" | "warning" | "outage";
|
|
312
|
+
title: string;
|
|
313
|
+
body?: string;
|
|
314
|
+
/** Free-text human ETA, e.g. "Back online by 14:00 UTC". */
|
|
315
|
+
eta?: string;
|
|
316
|
+
/** Optional CTA — typically a status-page incident URL. */
|
|
317
|
+
link?: {
|
|
318
|
+
url: string;
|
|
319
|
+
label?: string;
|
|
320
|
+
};
|
|
321
|
+
/** ISO 8601 UTC. After this time the widget hides the banner. */
|
|
322
|
+
expiresAt?: string;
|
|
323
|
+
}
|
|
247
324
|
interface ConsentSettings {
|
|
248
325
|
/** When true, all condition kinds are evaluated. When false (default), only
|
|
249
326
|
* direct launcher clicks fire — URL/time/scroll/exit-intent/trait
|
|
@@ -284,6 +361,15 @@ interface ChatState {
|
|
|
284
361
|
/** When set, the host should preload this text into the input. Cleared
|
|
285
362
|
* once the host consumes it (or when the conversation starts). */
|
|
286
363
|
pendingPrefill: string | null;
|
|
364
|
+
/** Operator-controlled incident banner. `null` when none is active. */
|
|
365
|
+
incidentBanner: IncidentBanner | null;
|
|
366
|
+
/** True when the visitor has dismissed the active banner this session.
|
|
367
|
+
* Reset whenever a new banner (different content) lands. */
|
|
368
|
+
incidentBannerDismissed: boolean;
|
|
369
|
+
/** When true, the chat input is disabled and `sendMessage` is a no-op.
|
|
370
|
+
* Used by the dashboard preview (and any other host that wants a
|
|
371
|
+
* visual-only render). Public API consumers should not set this. */
|
|
372
|
+
readOnly: boolean;
|
|
287
373
|
}
|
|
288
374
|
|
|
289
375
|
type Listener = (state: ChatState) => void;
|
|
@@ -295,6 +381,21 @@ declare class CustomerHeroChat {
|
|
|
295
381
|
private identityData;
|
|
296
382
|
t: TranslateFn;
|
|
297
383
|
constructor(config: CustomerHeroChatConfig);
|
|
384
|
+
/**
|
|
385
|
+
* Mark the config as loaded and put the client into read-only preview
|
|
386
|
+
* mode without hitting the API. Used by `@customerhero/react/preview` to
|
|
387
|
+
* render the widget against a host-supplied config (the dashboard preview
|
|
388
|
+
* pane). Public API consumers should not call this.
|
|
389
|
+
*
|
|
390
|
+
* Pass a config to re-resolve and update the rendered colors/size/launcher
|
|
391
|
+
* in place. Callers should reuse the same client instance across config
|
|
392
|
+
* changes so the open animation only fires once.
|
|
393
|
+
*
|
|
394
|
+
* @internal
|
|
395
|
+
*/
|
|
396
|
+
__seedForPreview(config?: CustomerHeroChatConfig, extras?: {
|
|
397
|
+
banner?: IncidentBanner | null;
|
|
398
|
+
}): void;
|
|
298
399
|
private triggersRuntime;
|
|
299
400
|
private preChatFormSubmitted;
|
|
300
401
|
private readStoredConsent;
|
|
@@ -339,6 +440,13 @@ declare class CustomerHeroChat {
|
|
|
339
440
|
* values are kept in memory (not persisted) so the integrator decides
|
|
340
441
|
* the source of truth. */
|
|
341
442
|
setTraits(traits: Record<string, string | number | boolean>): void;
|
|
443
|
+
/** Hide the active incident banner for this visitor. Persisted in
|
|
444
|
+
* localStorage so a refresh keeps it dismissed; resets automatically
|
|
445
|
+
* when the operator changes the banner content. No-op when no banner
|
|
446
|
+
* is showing. */
|
|
447
|
+
dismissIncidentBanner(): void;
|
|
448
|
+
private readStoredBannerDismissal;
|
|
449
|
+
private writeStoredBannerDismissal;
|
|
342
450
|
/** Submit pre-chat form answers. Synthesizes a customer record server-side
|
|
343
451
|
* on the next sendMessage. Resumes any pending message that was deferred
|
|
344
452
|
* while the form was open. */
|
|
@@ -374,7 +482,78 @@ declare const DEFAULTS: {
|
|
|
374
482
|
placeholderText: string;
|
|
375
483
|
welcomeMessage: string;
|
|
376
484
|
title: string;
|
|
485
|
+
colorScheme: "auto" | "light" | "dark";
|
|
486
|
+
primaryColorDark: string;
|
|
487
|
+
backgroundColorDark: string;
|
|
488
|
+
textColorDark: string;
|
|
489
|
+
size: "compact" | "default" | "large";
|
|
490
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
491
|
+
offsetBottom: number;
|
|
492
|
+
offsetSide: number;
|
|
493
|
+
zIndex: number;
|
|
494
|
+
};
|
|
495
|
+
declare const SIZE_PRESETS: {
|
|
496
|
+
readonly compact: {
|
|
497
|
+
readonly bubble: 48;
|
|
498
|
+
readonly width: 320;
|
|
499
|
+
readonly height: 480;
|
|
500
|
+
readonly fontSize: 13;
|
|
501
|
+
};
|
|
502
|
+
readonly default: {
|
|
503
|
+
readonly bubble: 56;
|
|
504
|
+
readonly width: 380;
|
|
505
|
+
readonly height: 520;
|
|
506
|
+
readonly fontSize: 14;
|
|
507
|
+
};
|
|
508
|
+
readonly large: {
|
|
509
|
+
readonly bubble: 64;
|
|
510
|
+
readonly width: 440;
|
|
511
|
+
readonly height: 600;
|
|
512
|
+
readonly fontSize: 15;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
declare const CORNER_RADIUS: {
|
|
516
|
+
readonly soft: 8;
|
|
517
|
+
readonly rounded: 16;
|
|
518
|
+
readonly square: 0;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
type EffectiveScheme = "light" | "dark";
|
|
522
|
+
/**
|
|
523
|
+
* Resolve the configured `colorScheme` against the visitor's OS preference.
|
|
524
|
+
* `prefersDark` is the live value of `matchMedia("(prefers-color-scheme: dark)")`
|
|
525
|
+
* (or `false` when not running in a browser). Kept as a pure function so the
|
|
526
|
+
* caller subscribes once and re-renders.
|
|
527
|
+
*/
|
|
528
|
+
declare function resolveScheme(colorScheme: ResolvedConfig["colorScheme"], prefersDark: boolean): EffectiveScheme;
|
|
529
|
+
/**
|
|
530
|
+
* Pick the colors that should drive the widget render right now. When the
|
|
531
|
+
* effective scheme is dark and a dark color is configured, use it; otherwise
|
|
532
|
+
* fall back to the light color (so half-configured dark mode still ships
|
|
533
|
+
* something readable rather than a white panel with white text).
|
|
534
|
+
*/
|
|
535
|
+
declare function effectiveColors(config: ResolvedConfig, scheme: EffectiveScheme): {
|
|
536
|
+
primary: string;
|
|
537
|
+
background: string;
|
|
538
|
+
text: string;
|
|
539
|
+
};
|
|
540
|
+
declare function sizePreset(size: ResolvedConfig["size"]): {
|
|
541
|
+
readonly bubble: 48;
|
|
542
|
+
readonly width: 320;
|
|
543
|
+
readonly height: 480;
|
|
544
|
+
readonly fontSize: 13;
|
|
545
|
+
} | {
|
|
546
|
+
readonly bubble: 56;
|
|
547
|
+
readonly width: 380;
|
|
548
|
+
readonly height: 520;
|
|
549
|
+
readonly fontSize: 14;
|
|
550
|
+
} | {
|
|
551
|
+
readonly bubble: 64;
|
|
552
|
+
readonly width: 440;
|
|
553
|
+
readonly height: 600;
|
|
554
|
+
readonly fontSize: 15;
|
|
377
555
|
};
|
|
556
|
+
declare function panelRadius(cornerStyle: ResolvedConfig["cornerStyle"]): 0 | 8 | 16;
|
|
378
557
|
|
|
379
558
|
declare class ScreenshotCancelled extends Error {
|
|
380
559
|
constructor(message?: string);
|
|
@@ -438,4 +617,4 @@ interface StartTriggersRuntimeOptions {
|
|
|
438
617
|
}
|
|
439
618
|
declare function startTriggersRuntime(options: StartTriggersRuntimeOptions): TriggersRuntimeHandle;
|
|
440
619
|
|
|
441
|
-
export { type ActionConfirmationBlock, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type IdentifyPayload, type IdentityData, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, evaluate, isRtlLocale, pickFire, resolveLocale, startTriggersRuntime };
|
|
620
|
+
export { type ActionConfirmationBlock, CORNER_RADIUS, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type EffectiveScheme, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SIZE_PRESETS, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, effectiveColors, evaluate, isRtlLocale, panelRadius, pickFire, resolveLocale, resolveScheme, sizePreset, startTriggersRuntime };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type";
|
|
1
|
+
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "incident_dismiss" | "incident_default_link_label";
|
|
2
2
|
type Translations = Record<TranslationKey, string>;
|
|
3
3
|
|
|
4
4
|
declare const SUPPORTED_LOCALES: readonly ["en", "es", "pt-BR", "pt-PT", "fr", "de", "it", "nl", "pl", "tr", "ar", "ja", "ko", "zh-CN", "zh-TW"];
|
|
@@ -35,6 +35,52 @@ interface CustomerHeroChatConfig {
|
|
|
35
35
|
locale?: string;
|
|
36
36
|
/** Predefined quick-reply options shown before the user sends a message */
|
|
37
37
|
suggestedMessages?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Color scheme. `auto` follows the visitor's OS preference; `light` and
|
|
40
|
+
* `dark` force a fixed palette. Defaults to `light` when unset.
|
|
41
|
+
*/
|
|
42
|
+
colorScheme?: "auto" | "light" | "dark";
|
|
43
|
+
/** Primary color used in dark mode. Only honoured when the effective
|
|
44
|
+
* scheme resolves to dark; never auto-derived from `primaryColor`. */
|
|
45
|
+
primaryColorDark?: string;
|
|
46
|
+
/** Background color used in dark mode. Only honoured when the effective
|
|
47
|
+
* scheme resolves to dark; never auto-derived from `backgroundColor`. */
|
|
48
|
+
backgroundColorDark?: string;
|
|
49
|
+
/** Text color used in dark mode. Only honoured when the effective scheme
|
|
50
|
+
* resolves to dark; never auto-derived from `textColor`. */
|
|
51
|
+
textColorDark?: string;
|
|
52
|
+
/** Widget size preset. Affects launcher diameter, panel dimensions, and
|
|
53
|
+
* base font size. Defaults to `default`. */
|
|
54
|
+
size?: "compact" | "default" | "large";
|
|
55
|
+
/** Corner radius preset for the chat panel. `soft` ~ small radius,
|
|
56
|
+
* `rounded` ~ medium (default), `square` ~ 0. */
|
|
57
|
+
cornerStyle?: "soft" | "rounded" | "square";
|
|
58
|
+
/** Launcher (floating bubble) customization. Each field is optional. */
|
|
59
|
+
launcher?: {
|
|
60
|
+
/** Custom launcher icon URL. Replaces the default chat-bubble glyph. */
|
|
61
|
+
iconUrl?: string;
|
|
62
|
+
/** Optional CTA label shown next to the launcher (turns the bubble into
|
|
63
|
+
* a pill). Max 60 characters. */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** When true, render a small green dot on the launcher to advertise
|
|
66
|
+
* agent availability. The host site is responsible for keeping
|
|
67
|
+
* business-hours state in sync; the SDK only renders the dot. */
|
|
68
|
+
showOnlineDot?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Pixel offsets so the widget can sit above sticky cookie bars or chat
|
|
71
|
+
* CTAs. Each axis defaults to 20 px when unset. Clamped to 0–1000. */
|
|
72
|
+
offset?: {
|
|
73
|
+
bottom?: number;
|
|
74
|
+
side?: number;
|
|
75
|
+
};
|
|
76
|
+
/** Z-index override for sites whose overlays clip the widget. Defaults
|
|
77
|
+
* to 99999. Capped at 2_000_000_000. */
|
|
78
|
+
zIndex?: number;
|
|
79
|
+
/** When false, the input's attach button is hidden so visitors can't
|
|
80
|
+
* even attempt an upload (the server enforces the same flag). Defaults
|
|
81
|
+
* to true. Per-chatbot, sourced from the public widget config endpoint
|
|
82
|
+
* but overrideable on the host. */
|
|
83
|
+
allowAttachments?: boolean;
|
|
38
84
|
}
|
|
39
85
|
|
|
40
86
|
interface ResolvedConfig {
|
|
@@ -51,6 +97,23 @@ interface ResolvedConfig {
|
|
|
51
97
|
suggestedMessages: string[];
|
|
52
98
|
/** Per-chatbot overrides for any translation key, optionally per-locale. */
|
|
53
99
|
stringOverrides?: StringOverrides;
|
|
100
|
+
colorScheme: "auto" | "light" | "dark";
|
|
101
|
+
primaryColorDark?: string;
|
|
102
|
+
backgroundColorDark?: string;
|
|
103
|
+
textColorDark?: string;
|
|
104
|
+
size: "compact" | "default" | "large";
|
|
105
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
106
|
+
launcher: {
|
|
107
|
+
iconUrl?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
showOnlineDot: boolean;
|
|
110
|
+
};
|
|
111
|
+
offset: {
|
|
112
|
+
bottom: number;
|
|
113
|
+
side: number;
|
|
114
|
+
};
|
|
115
|
+
zIndex: number;
|
|
116
|
+
allowAttachments: boolean;
|
|
54
117
|
}
|
|
55
118
|
interface MessageSource {
|
|
56
119
|
index: number;
|
|
@@ -244,6 +307,20 @@ interface PreChatSubmission {
|
|
|
244
307
|
/** Keyed answers from text/textarea/select/consent fields. */
|
|
245
308
|
properties?: Record<string, string | number | boolean>;
|
|
246
309
|
}
|
|
310
|
+
interface IncidentBanner {
|
|
311
|
+
severity: "info" | "warning" | "outage";
|
|
312
|
+
title: string;
|
|
313
|
+
body?: string;
|
|
314
|
+
/** Free-text human ETA, e.g. "Back online by 14:00 UTC". */
|
|
315
|
+
eta?: string;
|
|
316
|
+
/** Optional CTA — typically a status-page incident URL. */
|
|
317
|
+
link?: {
|
|
318
|
+
url: string;
|
|
319
|
+
label?: string;
|
|
320
|
+
};
|
|
321
|
+
/** ISO 8601 UTC. After this time the widget hides the banner. */
|
|
322
|
+
expiresAt?: string;
|
|
323
|
+
}
|
|
247
324
|
interface ConsentSettings {
|
|
248
325
|
/** When true, all condition kinds are evaluated. When false (default), only
|
|
249
326
|
* direct launcher clicks fire — URL/time/scroll/exit-intent/trait
|
|
@@ -284,6 +361,15 @@ interface ChatState {
|
|
|
284
361
|
/** When set, the host should preload this text into the input. Cleared
|
|
285
362
|
* once the host consumes it (or when the conversation starts). */
|
|
286
363
|
pendingPrefill: string | null;
|
|
364
|
+
/** Operator-controlled incident banner. `null` when none is active. */
|
|
365
|
+
incidentBanner: IncidentBanner | null;
|
|
366
|
+
/** True when the visitor has dismissed the active banner this session.
|
|
367
|
+
* Reset whenever a new banner (different content) lands. */
|
|
368
|
+
incidentBannerDismissed: boolean;
|
|
369
|
+
/** When true, the chat input is disabled and `sendMessage` is a no-op.
|
|
370
|
+
* Used by the dashboard preview (and any other host that wants a
|
|
371
|
+
* visual-only render). Public API consumers should not set this. */
|
|
372
|
+
readOnly: boolean;
|
|
287
373
|
}
|
|
288
374
|
|
|
289
375
|
type Listener = (state: ChatState) => void;
|
|
@@ -295,6 +381,21 @@ declare class CustomerHeroChat {
|
|
|
295
381
|
private identityData;
|
|
296
382
|
t: TranslateFn;
|
|
297
383
|
constructor(config: CustomerHeroChatConfig);
|
|
384
|
+
/**
|
|
385
|
+
* Mark the config as loaded and put the client into read-only preview
|
|
386
|
+
* mode without hitting the API. Used by `@customerhero/react/preview` to
|
|
387
|
+
* render the widget against a host-supplied config (the dashboard preview
|
|
388
|
+
* pane). Public API consumers should not call this.
|
|
389
|
+
*
|
|
390
|
+
* Pass a config to re-resolve and update the rendered colors/size/launcher
|
|
391
|
+
* in place. Callers should reuse the same client instance across config
|
|
392
|
+
* changes so the open animation only fires once.
|
|
393
|
+
*
|
|
394
|
+
* @internal
|
|
395
|
+
*/
|
|
396
|
+
__seedForPreview(config?: CustomerHeroChatConfig, extras?: {
|
|
397
|
+
banner?: IncidentBanner | null;
|
|
398
|
+
}): void;
|
|
298
399
|
private triggersRuntime;
|
|
299
400
|
private preChatFormSubmitted;
|
|
300
401
|
private readStoredConsent;
|
|
@@ -339,6 +440,13 @@ declare class CustomerHeroChat {
|
|
|
339
440
|
* values are kept in memory (not persisted) so the integrator decides
|
|
340
441
|
* the source of truth. */
|
|
341
442
|
setTraits(traits: Record<string, string | number | boolean>): void;
|
|
443
|
+
/** Hide the active incident banner for this visitor. Persisted in
|
|
444
|
+
* localStorage so a refresh keeps it dismissed; resets automatically
|
|
445
|
+
* when the operator changes the banner content. No-op when no banner
|
|
446
|
+
* is showing. */
|
|
447
|
+
dismissIncidentBanner(): void;
|
|
448
|
+
private readStoredBannerDismissal;
|
|
449
|
+
private writeStoredBannerDismissal;
|
|
342
450
|
/** Submit pre-chat form answers. Synthesizes a customer record server-side
|
|
343
451
|
* on the next sendMessage. Resumes any pending message that was deferred
|
|
344
452
|
* while the form was open. */
|
|
@@ -374,7 +482,78 @@ declare const DEFAULTS: {
|
|
|
374
482
|
placeholderText: string;
|
|
375
483
|
welcomeMessage: string;
|
|
376
484
|
title: string;
|
|
485
|
+
colorScheme: "auto" | "light" | "dark";
|
|
486
|
+
primaryColorDark: string;
|
|
487
|
+
backgroundColorDark: string;
|
|
488
|
+
textColorDark: string;
|
|
489
|
+
size: "compact" | "default" | "large";
|
|
490
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
491
|
+
offsetBottom: number;
|
|
492
|
+
offsetSide: number;
|
|
493
|
+
zIndex: number;
|
|
494
|
+
};
|
|
495
|
+
declare const SIZE_PRESETS: {
|
|
496
|
+
readonly compact: {
|
|
497
|
+
readonly bubble: 48;
|
|
498
|
+
readonly width: 320;
|
|
499
|
+
readonly height: 480;
|
|
500
|
+
readonly fontSize: 13;
|
|
501
|
+
};
|
|
502
|
+
readonly default: {
|
|
503
|
+
readonly bubble: 56;
|
|
504
|
+
readonly width: 380;
|
|
505
|
+
readonly height: 520;
|
|
506
|
+
readonly fontSize: 14;
|
|
507
|
+
};
|
|
508
|
+
readonly large: {
|
|
509
|
+
readonly bubble: 64;
|
|
510
|
+
readonly width: 440;
|
|
511
|
+
readonly height: 600;
|
|
512
|
+
readonly fontSize: 15;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
declare const CORNER_RADIUS: {
|
|
516
|
+
readonly soft: 8;
|
|
517
|
+
readonly rounded: 16;
|
|
518
|
+
readonly square: 0;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
type EffectiveScheme = "light" | "dark";
|
|
522
|
+
/**
|
|
523
|
+
* Resolve the configured `colorScheme` against the visitor's OS preference.
|
|
524
|
+
* `prefersDark` is the live value of `matchMedia("(prefers-color-scheme: dark)")`
|
|
525
|
+
* (or `false` when not running in a browser). Kept as a pure function so the
|
|
526
|
+
* caller subscribes once and re-renders.
|
|
527
|
+
*/
|
|
528
|
+
declare function resolveScheme(colorScheme: ResolvedConfig["colorScheme"], prefersDark: boolean): EffectiveScheme;
|
|
529
|
+
/**
|
|
530
|
+
* Pick the colors that should drive the widget render right now. When the
|
|
531
|
+
* effective scheme is dark and a dark color is configured, use it; otherwise
|
|
532
|
+
* fall back to the light color (so half-configured dark mode still ships
|
|
533
|
+
* something readable rather than a white panel with white text).
|
|
534
|
+
*/
|
|
535
|
+
declare function effectiveColors(config: ResolvedConfig, scheme: EffectiveScheme): {
|
|
536
|
+
primary: string;
|
|
537
|
+
background: string;
|
|
538
|
+
text: string;
|
|
539
|
+
};
|
|
540
|
+
declare function sizePreset(size: ResolvedConfig["size"]): {
|
|
541
|
+
readonly bubble: 48;
|
|
542
|
+
readonly width: 320;
|
|
543
|
+
readonly height: 480;
|
|
544
|
+
readonly fontSize: 13;
|
|
545
|
+
} | {
|
|
546
|
+
readonly bubble: 56;
|
|
547
|
+
readonly width: 380;
|
|
548
|
+
readonly height: 520;
|
|
549
|
+
readonly fontSize: 14;
|
|
550
|
+
} | {
|
|
551
|
+
readonly bubble: 64;
|
|
552
|
+
readonly width: 440;
|
|
553
|
+
readonly height: 600;
|
|
554
|
+
readonly fontSize: 15;
|
|
377
555
|
};
|
|
556
|
+
declare function panelRadius(cornerStyle: ResolvedConfig["cornerStyle"]): 0 | 8 | 16;
|
|
378
557
|
|
|
379
558
|
declare class ScreenshotCancelled extends Error {
|
|
380
559
|
constructor(message?: string);
|
|
@@ -438,4 +617,4 @@ interface StartTriggersRuntimeOptions {
|
|
|
438
617
|
}
|
|
439
618
|
declare function startTriggersRuntime(options: StartTriggersRuntimeOptions): TriggersRuntimeHandle;
|
|
440
619
|
|
|
441
|
-
export { type ActionConfirmationBlock, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type IdentifyPayload, type IdentityData, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, evaluate, isRtlLocale, pickFire, resolveLocale, startTriggersRuntime };
|
|
620
|
+
export { type ActionConfirmationBlock, CORNER_RADIUS, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type EffectiveScheme, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SIZE_PRESETS, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, effectiveColors, evaluate, isRtlLocale, panelRadius, pickFire, resolveLocale, resolveScheme, sizePreset, startTriggersRuntime };
|