@enjoys/react-chatbot-plugin 1.0.0 → 1.2.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/dist/index.d.ts CHANGED
@@ -1,10 +1,48 @@
1
+ import { ComponentType } from 'react';
1
2
  import { Context } from 'react';
2
3
  import { CSSProperties } from 'react';
3
4
  import { default as default_2 } from 'react';
4
5
  import { Property } from 'csstype';
5
6
  import { ReactNode } from 'react';
6
7
 
7
- declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle): {
8
+ /** Context object passed to async action handlers */
9
+ export declare interface ActionContext {
10
+ /** Update the loading/status message text in real-time */
11
+ updateMessage: (text: string) => void;
12
+ }
13
+
14
+ /**
15
+ * Analytics Plugin — tracks message counts, form completions, drop-offs
16
+ */
17
+ export declare function analyticsPlugin(options?: {
18
+ onTrack?: (event: string, data?: unknown) => void;
19
+ }): ChatPlugin;
20
+
21
+ export declare const AttachmentIcon: default_2.FC<IconProps>;
22
+
23
+ export declare const Branding: default_2.FC<BrandingProps>;
24
+
25
+ export declare interface BrandingConfig {
26
+ /** Company/product name shown in footer */
27
+ poweredBy?: string;
28
+ /** URL when clicking branding */
29
+ poweredByUrl?: string;
30
+ /** Logo URL for header or welcome screen */
31
+ logo?: string;
32
+ /** Logo width */
33
+ logoWidth?: string;
34
+ /** Show "Powered by" branding footer */
35
+ showBranding?: boolean;
36
+ }
37
+
38
+ declare interface BrandingProps {
39
+ config: BrandingConfig;
40
+ primaryColor: string;
41
+ }
42
+
43
+ export declare function buildCSSVariables(theme: Required<ChatTheme>): Record<string, string>;
44
+
45
+ export declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle): {
8
46
  root: {
9
47
  fontFamily: string;
10
48
  fontSize: string;
@@ -38,7 +76,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
38
76
  backgroundAttachment?: Property.BackgroundAttachment | undefined;
39
77
  backgroundBlendMode?: Property.BackgroundBlendMode | undefined;
40
78
  backgroundClip?: Property.BackgroundClip | undefined;
41
- backgroundColor: string;
79
+ backgroundColor?: Property.BackgroundColor | undefined;
42
80
  backgroundImage?: Property.BackgroundImage | undefined;
43
81
  backgroundOrigin?: Property.BackgroundOrigin | undefined;
44
82
  backgroundPositionX?: Property.BackgroundPositionX<string | number> | undefined;
@@ -88,7 +126,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
88
126
  borderTopWidth?: Property.BorderTopWidth<string | number> | undefined;
89
127
  bottom?: Property.Bottom<string | number> | undefined;
90
128
  boxDecorationBreak?: Property.BoxDecorationBreak | undefined;
91
- boxShadow: "0 4px 12px rgba(0,0,0,0.15)" | Property.BoxShadow;
129
+ boxShadow: "0 6px 24px rgba(108, 92, 231, 0.4), 0 2px 8px rgba(0,0,0,0.1)" | Property.BoxShadow;
92
130
  boxSizing?: Property.BoxSizing | undefined;
93
131
  breakAfter?: Property.BreakAfter | undefined;
94
132
  breakBefore?: Property.BreakBefore | undefined;
@@ -435,7 +473,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
435
473
  all?: Property.All | undefined;
436
474
  animation?: Property.Animation<string & {}> | undefined;
437
475
  animationRange?: Property.AnimationRange<string | number> | undefined;
438
- background?: Property.Background<string | number> | undefined;
476
+ background: Property.Background<string | number>;
439
477
  backgroundPosition?: Property.BackgroundPosition<string | number> | undefined;
440
478
  border: Property.Border<string | number>;
441
479
  borderBlock?: Property.BorderBlock<string | number> | undefined;
@@ -506,7 +544,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
506
544
  textDecoration?: Property.TextDecoration<string | number> | undefined;
507
545
  textEmphasis?: Property.TextEmphasis | undefined;
508
546
  textWrap?: Property.TextWrap | undefined;
509
- transition: "transform 0.2s ease" | Property.Transition<string & {}>;
547
+ transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)" | Property.Transition<string & {}>;
510
548
  viewTimeline?: Property.ViewTimeline | undefined;
511
549
  MozAnimationDelay?: Property.AnimationDelay<string & {}> | undefined;
512
550
  MozAnimationDirection?: Property.AnimationDirection | undefined;
@@ -892,12 +930,12 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
892
930
  animationTimingFunction?: Property.AnimationTimingFunction | undefined;
893
931
  appearance?: Property.Appearance | undefined;
894
932
  aspectRatio?: Property.AspectRatio | undefined;
895
- backdropFilter?: Property.BackdropFilter | undefined;
933
+ backdropFilter: Property.BackdropFilter | "blur(20px)";
896
934
  backfaceVisibility?: Property.BackfaceVisibility | undefined;
897
935
  backgroundAttachment?: Property.BackgroundAttachment | undefined;
898
936
  backgroundBlendMode?: Property.BackgroundBlendMode | undefined;
899
937
  backgroundClip?: Property.BackgroundClip | undefined;
900
- backgroundColor: "#FFFFFF" | Property.BackgroundColor;
938
+ backgroundColor: "rgba(22, 22, 40, 0.95)" | Property.BackgroundColor | "rgba(255, 255, 255, 0.95)";
901
939
  backgroundImage?: Property.BackgroundImage | undefined;
902
940
  backgroundOrigin?: Property.BackgroundOrigin | undefined;
903
941
  backgroundPositionX?: Property.BackgroundPositionX<string | number> | undefined;
@@ -947,7 +985,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
947
985
  borderTopWidth?: Property.BorderTopWidth<string | number> | undefined;
948
986
  bottom?: Property.Bottom<string | number> | undefined;
949
987
  boxDecorationBreak?: Property.BoxDecorationBreak | undefined;
950
- boxShadow: Property.BoxShadow | "0 8px 32px rgba(0,0,0,0.15)";
988
+ boxShadow: Property.BoxShadow | "0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05)" | "0 20px 60px rgba(108, 92, 231, 0.15), 0 8px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04)";
951
989
  boxSizing?: Property.BoxSizing | undefined;
952
990
  breakAfter?: Property.BreakAfter | undefined;
953
991
  breakBefore?: Property.BreakBefore | undefined;
@@ -1292,11 +1330,11 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
1292
1330
  zIndex: number | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "auto";
1293
1331
  zoom?: Property.Zoom | undefined;
1294
1332
  all?: Property.All | undefined;
1295
- animation?: Property.Animation<string & {}> | undefined;
1333
+ animation: Property.Animation<string & {}> | "cb-window-enter 0.35s cubic-bezier(0.4, 0, 0.2, 1)";
1296
1334
  animationRange?: Property.AnimationRange<string | number> | undefined;
1297
1335
  background?: Property.Background<string | number> | undefined;
1298
1336
  backgroundPosition?: Property.BackgroundPosition<string | number> | undefined;
1299
- border?: Property.Border<string | number> | undefined;
1337
+ border: Property.Border<string | number>;
1300
1338
  borderBlock?: Property.BorderBlock<string | number> | undefined;
1301
1339
  borderBlockColor?: Property.BorderBlockColor | undefined;
1302
1340
  borderBlockEnd?: Property.BorderBlockEnd<string | number> | undefined;
@@ -1492,7 +1530,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
1492
1530
  WebkitAnimationPlayState?: Property.AnimationPlayState | undefined;
1493
1531
  WebkitAnimationTimingFunction?: Property.AnimationTimingFunction | undefined;
1494
1532
  WebkitAppearance?: Property.WebkitAppearance | undefined;
1495
- WebkitBackdropFilter?: Property.BackdropFilter | undefined;
1533
+ WebkitBackdropFilter: Property.BackdropFilter | "blur(20px)";
1496
1534
  WebkitBackfaceVisibility?: Property.BackfaceVisibility | undefined;
1497
1535
  WebkitBackgroundClip?: Property.BackgroundClip | undefined;
1498
1536
  WebkitBackgroundOrigin?: Property.BackgroundOrigin | undefined;
@@ -1756,7 +1794,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
1756
1794
  backgroundAttachment?: Property.BackgroundAttachment | undefined;
1757
1795
  backgroundBlendMode?: Property.BackgroundBlendMode | undefined;
1758
1796
  backgroundClip?: Property.BackgroundClip | undefined;
1759
- backgroundColor: string;
1797
+ backgroundColor?: Property.BackgroundColor | undefined;
1760
1798
  backgroundImage?: Property.BackgroundImage | undefined;
1761
1799
  backgroundOrigin?: Property.BackgroundOrigin | undefined;
1762
1800
  backgroundPositionX?: Property.BackgroundPositionX<string | number> | undefined;
@@ -2016,7 +2054,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
2016
2054
  perspective?: Property.Perspective<string | number> | undefined;
2017
2055
  perspectiveOrigin?: Property.PerspectiveOrigin<string | number> | undefined;
2018
2056
  pointerEvents?: Property.PointerEvents | undefined;
2019
- position?: Property.Position | undefined;
2057
+ position: Property.Position;
2020
2058
  positionAnchor?: Property.PositionAnchor | undefined;
2021
2059
  positionArea?: Property.PositionArea | undefined;
2022
2060
  positionTryFallbacks?: Property.PositionTryFallbacks | undefined;
@@ -2153,7 +2191,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
2153
2191
  all?: Property.All | undefined;
2154
2192
  animation?: Property.Animation<string & {}> | undefined;
2155
2193
  animationRange?: Property.AnimationRange<string | number> | undefined;
2156
- background?: Property.Background<string | number> | undefined;
2194
+ background: Property.Background<string | number>;
2157
2195
  backgroundPosition?: Property.BackgroundPosition<string | number> | undefined;
2158
2196
  border?: Property.Border<string | number> | undefined;
2159
2197
  borderBlock?: Property.BorderBlock<string | number> | undefined;
@@ -2204,7 +2242,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
2204
2242
  motion?: Property.Offset<string | number> | undefined;
2205
2243
  offset?: Property.Offset<string | number> | undefined;
2206
2244
  outline?: Property.Outline<string | number> | undefined;
2207
- overflow?: Property.Overflow | undefined;
2245
+ overflow: Property.Overflow;
2208
2246
  overscrollBehavior?: Property.OverscrollBehavior | undefined;
2209
2247
  padding: Property.Padding<string | number>;
2210
2248
  paddingBlock?: Property.PaddingBlock<string | number> | undefined;
@@ -3012,7 +3050,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
3012
3050
  all?: Property.All | undefined;
3013
3051
  animation?: Property.Animation<string & {}> | undefined;
3014
3052
  animationRange?: Property.AnimationRange<string | number> | undefined;
3015
- background?: Property.Background<string | number> | undefined;
3053
+ background: Property.Background<string | number>;
3016
3054
  backgroundPosition?: Property.BackgroundPosition<string | number> | undefined;
3017
3055
  border?: Property.Border<string | number> | undefined;
3018
3056
  borderBlock?: Property.BorderBlock<string | number> | undefined;
@@ -3449,7 +3487,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
3449
3487
  inputArea: {
3450
3488
  accentColor?: Property.AccentColor | undefined;
3451
3489
  alignContent?: Property.AlignContent | undefined;
3452
- alignItems: Property.AlignItems;
3490
+ alignItems?: Property.AlignItems | undefined;
3453
3491
  alignSelf?: Property.AlignSelf | undefined;
3454
3492
  alignTracks?: Property.AlignTracks | undefined;
3455
3493
  alignmentBaseline?: Property.AlignmentBaseline | undefined;
@@ -3469,12 +3507,12 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
3469
3507
  animationTimingFunction?: Property.AnimationTimingFunction | undefined;
3470
3508
  appearance?: Property.Appearance | undefined;
3471
3509
  aspectRatio?: Property.AspectRatio | undefined;
3472
- backdropFilter?: Property.BackdropFilter | undefined;
3510
+ backdropFilter: Property.BackdropFilter | "blur(12px)";
3473
3511
  backfaceVisibility?: Property.BackfaceVisibility | undefined;
3474
3512
  backgroundAttachment?: Property.BackgroundAttachment | undefined;
3475
3513
  backgroundBlendMode?: Property.BackgroundBlendMode | undefined;
3476
3514
  backgroundClip?: Property.BackgroundClip | undefined;
3477
- backgroundColor?: Property.BackgroundColor | undefined;
3515
+ backgroundColor: Property.BackgroundColor | "rgba(255, 255, 255, 0.95)" | "rgba(20, 20, 38, 0.9)";
3478
3516
  backgroundImage?: Property.BackgroundImage | undefined;
3479
3517
  backgroundOrigin?: Property.BackgroundOrigin | undefined;
3480
3518
  backgroundPositionX?: Property.BackgroundPositionX<string | number> | undefined;
@@ -3564,7 +3602,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
3564
3602
  cy?: Property.Cy<string | number> | undefined;
3565
3603
  d?: Property.D | undefined;
3566
3604
  direction?: Property.Direction | undefined;
3567
- display: Property.Display;
3605
+ display?: Property.Display | undefined;
3568
3606
  dominantBaseline?: Property.DominantBaseline | undefined;
3569
3607
  emptyCells?: Property.EmptyCells | undefined;
3570
3608
  fieldSizing?: Property.FieldSizing | undefined;
@@ -3903,7 +3941,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
3903
3941
  flex?: Property.Flex<string | number> | undefined;
3904
3942
  flexFlow?: Property.FlexFlow | undefined;
3905
3943
  font?: Property.Font | undefined;
3906
- gap: Property.Gap<string | number>;
3944
+ gap?: Property.Gap<string | number> | undefined;
3907
3945
  grid?: Property.Grid | undefined;
3908
3946
  gridArea?: Property.GridArea | undefined;
3909
3947
  gridColumn?: Property.GridColumn | undefined;
@@ -4069,7 +4107,7 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
4069
4107
  WebkitAnimationPlayState?: Property.AnimationPlayState | undefined;
4070
4108
  WebkitAnimationTimingFunction?: Property.AnimationTimingFunction | undefined;
4071
4109
  WebkitAppearance?: Property.WebkitAppearance | undefined;
4072
- WebkitBackdropFilter?: Property.BackdropFilter | undefined;
4110
+ WebkitBackdropFilter: Property.BackdropFilter | "blur(12px)";
4073
4111
  WebkitBackfaceVisibility?: Property.BackfaceVisibility | undefined;
4074
4112
  WebkitBackgroundClip?: Property.BackgroundClip | undefined;
4075
4113
  WebkitBackgroundOrigin?: Property.BackgroundOrigin | undefined;
@@ -4306,17 +4344,24 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
4306
4344
  glyphOrientationVertical?: Property.GlyphOrientationVertical | undefined;
4307
4345
  };
4308
4346
  botBubble: {
4309
- backgroundColor: string;
4310
- color: string;
4347
+ background: string;
4348
+ color: "#2D3436" | "#E8E8F0";
4311
4349
  padding: string;
4312
4350
  borderRadius: string;
4313
4351
  maxWidth: string;
4314
4352
  alignSelf: "flex-start";
4315
4353
  wordBreak: "break-word";
4316
4354
  whiteSpace: "pre-wrap";
4355
+ backdropFilter: "blur(8px)";
4356
+ WebkitBackdropFilter: "blur(8px)";
4357
+ border: string;
4358
+ boxShadow: "0 2px 8px rgba(0,0,0,0.2)" | "0 2px 8px rgba(0,0,0,0.04)";
4359
+ fontSize: string;
4360
+ lineHeight: string;
4361
+ letterSpacing: string;
4317
4362
  };
4318
4363
  userBubble: {
4319
- backgroundColor: string;
4364
+ background: string;
4320
4365
  color: string;
4321
4366
  padding: string;
4322
4367
  borderRadius: string;
@@ -4324,6 +4369,10 @@ declare function buildStyles(theme: Required<ChatTheme>, overrides?: ChatStyle):
4324
4369
  alignSelf: "flex-end";
4325
4370
  wordBreak: "break-word";
4326
4371
  whiteSpace: "pre-wrap";
4372
+ boxShadow: "0 4px 14px rgba(108, 92, 231, 0.25)";
4373
+ fontSize: string;
4374
+ lineHeight: string;
4375
+ letterSpacing: string;
4327
4376
  };
4328
4377
  };
4329
4378
 
@@ -4354,45 +4403,53 @@ declare type ChatAction = {
4354
4403
  payload: boolean;
4355
4404
  } | {
4356
4405
  type: 'CLEAR_QUICK_REPLIES';
4406
+ } | {
4407
+ type: 'RESET_CHAT';
4408
+ } | {
4409
+ type: 'UPDATE_MESSAGE';
4410
+ payload: {
4411
+ id: string;
4412
+ updates: Partial<ChatMessage>;
4413
+ };
4357
4414
  };
4358
4415
 
4359
4416
  export declare const ChatBot: default_2.FC<ChatBotProps>;
4360
4417
 
4361
4418
  export declare interface ChatBotProps {
4362
- /** Theme colors and sizing */
4363
4419
  theme?: ChatTheme;
4364
- /** CSS overrides per section */
4365
4420
  style?: ChatStyle;
4366
- /** Header configuration */
4367
4421
  header?: HeaderConfig;
4368
- /** Custom welcome screen — pass JSX or a React component */
4422
+ branding?: BrandingConfig;
4369
4423
  welcomeScreen?: ReactNode;
4370
- /** JSON-based conversation flow */
4371
4424
  flow?: FlowConfig;
4372
- /** Custom login form shown before chat */
4373
4425
  loginForm?: FormConfig;
4374
- /** All event callbacks */
4375
4426
  callbacks?: ChatCallbacks;
4376
- /** Initial messages to displays */
4427
+ plugins?: ChatPlugin[];
4377
4428
  initialMessages?: ChatMessage[];
4378
- /** Placeholder text for input */
4379
4429
  inputPlaceholder?: string;
4380
- /** Position of the launcher */
4381
4430
  position?: 'bottom-right' | 'bottom-left';
4382
- /** Whether to show the launcher bubble */
4383
4431
  showLauncher?: boolean;
4384
- /** Custom launcher icon */
4385
4432
  launcherIcon?: ReactNode;
4386
- /** Custom close icon */
4387
4433
  closeIcon?: ReactNode;
4388
- /** Open by default */
4389
4434
  defaultOpen?: boolean;
4390
- /** Custom CSS class for the root element */
4391
4435
  className?: string;
4392
- /** z-index */
4393
4436
  zIndex?: number;
4437
+ /** Enable emoji picker */
4438
+ enableEmoji?: boolean;
4439
+ /** File upload configuration */
4440
+ fileUpload?: FileUploadConfig;
4441
+ /** Custom header component — receives ChatRenderContext as props */
4442
+ renderHeader?: (ctx: ChatRenderContext, defaultHeader: ReactNode) => ReactNode;
4443
+ /** Custom input component — receives ChatRenderContext as props */
4444
+ renderInput?: (ctx: ChatRenderContext, defaultInput: ReactNode) => ReactNode;
4445
+ /** Map of custom components that can be rendered in flow steps (key = step.component) */
4446
+ components?: Record<string, ComponentType<StepComponentProps>>;
4447
+ /** Map of async action handlers (key = step.asyncAction.handler) */
4448
+ actionHandlers?: Record<string, (data: Record<string, unknown>, ctx: ActionContext) => Promise<FlowActionResult>>;
4394
4449
  }
4395
4450
 
4451
+ export declare const ChatBubbleIcon: default_2.FC<IconProps>;
4452
+
4396
4453
  export declare interface ChatCallbacks {
4397
4454
  onOpen?: () => void;
4398
4455
  onClose?: () => void;
@@ -4402,9 +4459,10 @@ export declare interface ChatCallbacks {
4402
4459
  onLogin?: (data: Record<string, unknown>) => void | Promise<void>;
4403
4460
  onFormSubmit?: (formId: string, data: Record<string, unknown>) => void | Promise<void>;
4404
4461
  onQuickReply?: (value: string, label: string) => void;
4405
- onFileUpload?: (files: FileList) => void | Promise<void>;
4462
+ onFileUpload?: (files: File[]) => void | Promise<void>;
4406
4463
  onFlowEnd?: (collectedData: Record<string, unknown>) => void;
4407
4464
  onError?: (error: Error) => void;
4465
+ onEvent?: (event: string, payload?: unknown) => void;
4408
4466
  }
4409
4467
 
4410
4468
  export declare const ChatContext: Context<ChatContextValue | null>;
@@ -4421,16 +4479,23 @@ declare interface ChatHeaderProps {
4421
4479
  config: HeaderConfig;
4422
4480
  styles: ChatStyles;
4423
4481
  onClose: () => void;
4482
+ onRestart?: () => void;
4483
+ logo?: string;
4484
+ logoWidth?: string;
4424
4485
  }
4425
4486
 
4426
4487
  export declare const ChatInput: default_2.FC<ChatInputProps>;
4427
4488
 
4428
4489
  declare interface ChatInputProps {
4429
- onSend: (text: string) => void;
4490
+ onSend: (text: string, files?: File[]) => void;
4430
4491
  placeholder?: string;
4431
4492
  primaryColor: string;
4493
+ isDark?: boolean;
4432
4494
  disabled?: boolean;
4433
4495
  styleOverride?: CSSProperties;
4496
+ enableEmoji?: boolean;
4497
+ fileUpload?: FileUploadConfig;
4498
+ onFileUpload?: (files: File[]) => void;
4434
4499
  }
4435
4500
 
4436
4501
  export declare interface ChatMessage {
@@ -4441,11 +4506,48 @@ export declare interface ChatMessage {
4441
4506
  quickReplies?: FlowQuickReply[];
4442
4507
  form?: FormConfig;
4443
4508
  formData?: Record<string, unknown>;
4444
- attachment?: {
4445
- name: string;
4446
- url: string;
4447
- type: string;
4448
- };
4509
+ attachments?: MessageAttachment[];
4510
+ metadata?: Record<string, unknown>;
4511
+ /** Key into components map — renders a custom component for this message */
4512
+ component?: string;
4513
+ }
4514
+
4515
+ export declare interface ChatPlugin {
4516
+ /** Unique plugin name */
4517
+ name: string;
4518
+ /** Called when chatbot initializes */
4519
+ onInit?: (ctx: PluginContext) => void | Promise<void>;
4520
+ /** Called when a message is sent or received */
4521
+ onMessage?: (message: ChatMessage, ctx: PluginContext) => void | ChatMessage | Promise<void | ChatMessage>;
4522
+ /** Called when form or data is submitted */
4523
+ onSubmit?: (data: Record<string, unknown>, ctx: PluginContext) => void | Promise<void>;
4524
+ /** Called before chatbot unmounts */
4525
+ onDestroy?: (ctx: PluginContext) => void | Promise<void>;
4526
+ /** Called on any event */
4527
+ onEvent?: (event: ChatPluginEvent, ctx: PluginContext) => void;
4528
+ }
4529
+
4530
+ export declare interface ChatPluginEvent {
4531
+ type: string;
4532
+ payload?: unknown;
4533
+ timestamp: number;
4534
+ }
4535
+
4536
+ export declare interface ChatRenderContext {
4537
+ /** Current step ID in the flow (null if no active step) */
4538
+ currentStepId: string | null;
4539
+ /** Whether the chat is open */
4540
+ isOpen: boolean;
4541
+ /** All current messages */
4542
+ messages: ChatMessage[];
4543
+ /** Collected form/flow data */
4544
+ collectedData: Record<string, unknown>;
4545
+ /** Toggle/close the chat window */
4546
+ toggleChat: () => void;
4547
+ /** Restart the conversation */
4548
+ restartSession: () => void;
4549
+ /** Send a message programmatically */
4550
+ sendMessage: (text: string) => void;
4449
4551
  }
4450
4552
 
4451
4553
  declare interface ChatState {
@@ -4481,6 +4583,7 @@ export declare interface ChatTheme {
4481
4583
  borderRadius?: string;
4482
4584
  windowWidth?: string;
4483
4585
  windowHeight?: string;
4586
+ mode?: 'light' | 'dark';
4484
4587
  }
4485
4588
 
4486
4589
  export declare const ChatWindow: default_2.FC<ChatWindowProps>;
@@ -4489,6 +4592,7 @@ declare interface ChatWindowProps {
4489
4592
  styles: ChatStyles;
4490
4593
  position: 'bottom-right' | 'bottom-left';
4491
4594
  zIndex?: number;
4595
+ hidden?: boolean;
4492
4596
  }
4493
4597
 
4494
4598
  export declare const CheckboxField: default_2.FC<CheckboxFieldProps>;
@@ -4500,6 +4604,8 @@ declare interface CheckboxFieldProps {
4500
4604
  error?: string;
4501
4605
  }
4502
4606
 
4607
+ export declare const CloseIcon: default_2.FC<IconProps>;
4608
+
4503
4609
  export declare const DynamicForm: default_2.FC<DynamicFormProps>;
4504
4610
 
4505
4611
  declare interface DynamicFormProps {
@@ -4508,6 +4614,49 @@ declare interface DynamicFormProps {
4508
4614
  primaryColor: string;
4509
4615
  }
4510
4616
 
4617
+ export declare const EmojiIcon: default_2.FC<IconProps>;
4618
+
4619
+ export declare const EmojiPicker: default_2.FC<EmojiPickerProps>;
4620
+
4621
+ declare interface EmojiPickerProps {
4622
+ onSelect: (emoji: string) => void;
4623
+ onClose: () => void;
4624
+ primaryColor: string;
4625
+ }
4626
+
4627
+ export declare const FileIcon: default_2.FC<IconProps>;
4628
+
4629
+ export declare const FilePreviewList: default_2.FC<FilePreviewListProps>;
4630
+
4631
+ declare interface FilePreviewListProps {
4632
+ files: File[];
4633
+ onRemove: (index: number) => void;
4634
+ primaryColor: string;
4635
+ }
4636
+
4637
+ export declare const FileUploadButton: default_2.FC<FileUploadButtonProps>;
4638
+
4639
+ declare interface FileUploadButtonProps {
4640
+ config: FileUploadConfig;
4641
+ onFiles: (files: File[]) => void;
4642
+ selectedFiles: File[];
4643
+ onRemoveFile: (index: number) => void;
4644
+ primaryColor: string;
4645
+ }
4646
+
4647
+ export declare interface FileUploadConfig {
4648
+ /** Enable file upload in chat input */
4649
+ enabled?: boolean;
4650
+ /** Accepted mime types */
4651
+ accept?: string;
4652
+ /** Allow multiple files */
4653
+ multiple?: boolean;
4654
+ /** Max file size in bytes */
4655
+ maxSize?: number;
4656
+ /** Max number of files */
4657
+ maxFiles?: number;
4658
+ }
4659
+
4511
4660
  export declare const FileUploadField: default_2.FC<FileUploadFieldProps>;
4512
4661
 
4513
4662
  declare interface FileUploadFieldProps {
@@ -4518,6 +4667,44 @@ declare interface FileUploadFieldProps {
4518
4667
  primaryColor: string;
4519
4668
  }
4520
4669
 
4670
+ /** Result returned by an async action handler */
4671
+ export declare interface FlowActionResult {
4672
+ /** Status key — 'success', 'error', or any custom string for route matching */
4673
+ status: string;
4674
+ /** Additional data to merge into collected data */
4675
+ data?: Record<string, unknown>;
4676
+ /** Optional message to display (overrides successMessage/errorMessage) */
4677
+ message?: string;
4678
+ /** Optional explicit next step ID (overrides all routing) */
4679
+ next?: string;
4680
+ }
4681
+
4682
+ /** Configuration for an async action that runs when a step is entered */
4683
+ export declare interface FlowAsyncAction {
4684
+ /** Key into ChatBotProps.actionHandlers */
4685
+ handler: string;
4686
+ /** Message shown while the action is running (default: "Processing...") */
4687
+ loadingMessage?: string;
4688
+ /** Message shown on success */
4689
+ successMessage?: string;
4690
+ /** Message shown on error */
4691
+ errorMessage?: string;
4692
+ /** Next step ID on success */
4693
+ onSuccess?: string;
4694
+ /** Next step ID on error */
4695
+ onError?: string;
4696
+ /** Custom routes: maps result.status string to step IDs */
4697
+ routes?: Record<string, string>;
4698
+ }
4699
+
4700
+ export declare interface FlowCondition {
4701
+ field: string;
4702
+ operator: 'eq' | 'neq' | 'contains' | 'gt' | 'lt';
4703
+ value: string | number;
4704
+ then: string;
4705
+ else: string;
4706
+ }
4707
+
4521
4708
  export declare interface FlowConfig {
4522
4709
  startStep: string;
4523
4710
  steps: FlowStep[];
@@ -4527,13 +4714,30 @@ export declare class FlowEngine {
4527
4714
  private steps;
4528
4715
  private startStep;
4529
4716
  private collectedData;
4717
+ private idCounter;
4718
+ private uid;
4719
+ private stepHistory;
4530
4720
  constructor(flow: FlowConfig);
4531
4721
  getStartStepId(): string;
4532
4722
  getStep(id: string): FlowStep | undefined;
4533
4723
  getData(): Record<string, unknown>;
4534
4724
  setData(key: string, value: unknown): void;
4535
4725
  mergeData(data: Record<string, unknown>): void;
4726
+ /** Push a step onto the history stack (called when entering a step) */
4727
+ pushHistory(stepId: string): void;
4728
+ /** Pop and return the previous step (go back) */
4729
+ popHistory(): string | undefined;
4730
+ /** Check if there's a previous step to go back to */
4731
+ canGoBack(): boolean;
4732
+ /** Reset the engine to initial state */
4733
+ reset(): void;
4536
4734
  resolveNext(step: FlowStep, userValue?: string): string | undefined;
4735
+ /** Returns true if the step expects a quick reply (not free text) */
4736
+ stepExpectsQuickReply(step: FlowStep): boolean;
4737
+ /** Returns true if the step expects a form submission */
4738
+ stepExpectsForm(step: FlowStep): boolean;
4739
+ /** Try to fuzzy-match user text against quick reply labels */
4740
+ matchQuickReply(step: FlowStep, text: string): FlowQuickReply | undefined;
4537
4741
  buildMessages(step: FlowStep): ChatMessage[];
4538
4742
  private evaluate;
4539
4743
  }
@@ -4542,6 +4746,7 @@ export declare interface FlowQuickReply {
4542
4746
  label: string;
4543
4747
  value: string;
4544
4748
  next?: string;
4749
+ icon?: string;
4545
4750
  }
4546
4751
 
4547
4752
  export declare interface FlowStep {
@@ -4553,13 +4758,11 @@ export declare interface FlowStep {
4553
4758
  form?: FormConfig;
4554
4759
  next?: string;
4555
4760
  action?: string;
4556
- condition?: {
4557
- field: string;
4558
- operator: 'eq' | 'neq' | 'contains' | 'gt' | 'lt';
4559
- value: string | number;
4560
- then: string;
4561
- else: string;
4562
- };
4761
+ condition?: FlowCondition;
4762
+ /** Key into ChatBotProps.components — renders a custom React component in this step */
4763
+ component?: string;
4764
+ /** Async action to run when this step is entered (API calls, verification, etc.) */
4765
+ asyncAction?: FlowAsyncAction;
4563
4766
  }
4564
4767
 
4565
4768
  export declare interface FormConfig {
@@ -4580,14 +4783,7 @@ export declare interface FormFieldConfig {
4580
4783
  accept?: string;
4581
4784
  multiple?: boolean;
4582
4785
  defaultValue?: string | string[];
4583
- validation?: {
4584
- pattern?: string;
4585
- minLength?: number;
4586
- maxLength?: number;
4587
- min?: number;
4588
- max?: number;
4589
- message?: string;
4590
- };
4786
+ validation?: FormFieldValidation;
4591
4787
  }
4592
4788
 
4593
4789
  export declare interface FormFieldOption {
@@ -4597,13 +4793,33 @@ export declare interface FormFieldOption {
4597
4793
 
4598
4794
  export declare type FormFieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'file' | 'date' | 'time' | 'hidden';
4599
4795
 
4796
+ export declare interface FormFieldValidation {
4797
+ pattern?: string;
4798
+ minLength?: number;
4799
+ maxLength?: number;
4800
+ min?: number;
4801
+ max?: number;
4802
+ message?: string;
4803
+ }
4804
+
4600
4805
  export declare interface HeaderConfig {
4601
4806
  title?: string;
4602
4807
  subtitle?: string;
4603
4808
  avatar?: string;
4604
4809
  showClose?: boolean;
4810
+ showMinimize?: boolean;
4811
+ /** Show a restart button in the header */
4812
+ showRestart?: boolean;
4813
+ }
4814
+
4815
+ declare interface IconProps {
4816
+ size?: number;
4817
+ color?: string;
4818
+ className?: string;
4605
4819
  }
4606
4820
 
4821
+ export declare const ImageIcon: default_2.FC<IconProps>;
4822
+
4607
4823
  export declare const Launcher: default_2.FC<LauncherProps>;
4608
4824
 
4609
4825
  declare interface LauncherProps {
@@ -4624,6 +4840,14 @@ declare interface LoginScreenProps {
4624
4840
  primaryColor: string;
4625
4841
  }
4626
4842
 
4843
+ export declare interface MessageAttachment {
4844
+ name: string;
4845
+ url: string;
4846
+ type: string;
4847
+ size?: number;
4848
+ preview?: string;
4849
+ }
4850
+
4627
4851
  export declare const MessageBubble: default_2.FC<MessageBubbleProps>;
4628
4852
 
4629
4853
  declare interface MessageBubbleProps {
@@ -4640,9 +4864,63 @@ declare interface MessageListProps {
4640
4864
  primaryColor: string;
4641
4865
  onQuickReply: (value: string, label: string) => void;
4642
4866
  onFormSubmit: (formId: string, data: Record<string, unknown>) => void;
4867
+ /** Map of custom step components */
4868
+ components?: Record<string, ComponentType<StepComponentProps>>;
4869
+ /** Called when a custom component completes */
4870
+ onComponentComplete?: (result?: FlowActionResult) => void;
4871
+ /** Collected flow data — passed to custom components */
4872
+ collectedData?: Record<string, unknown>;
4873
+ /** Current step ID */
4874
+ currentStepId?: string | null;
4643
4875
  }
4644
4876
 
4645
- export declare type MessageSender = 'bot' | 'user';
4877
+ export declare type MessageSender = 'bot' | 'user' | 'system';
4878
+
4879
+ export declare const MinimizeIcon: default_2.FC<IconProps>;
4880
+
4881
+ /**
4882
+ * Persistence Plugin — saves/restores chat history via localStorage
4883
+ */
4884
+ export declare function persistencePlugin(options?: {
4885
+ storageKey?: string;
4886
+ storage?: 'local' | 'session';
4887
+ }): ChatPlugin;
4888
+
4889
+ export declare interface PluginContext {
4890
+ /** Send a message programmatically */
4891
+ sendMessage: (text: string) => void;
4892
+ /** Add a bot message */
4893
+ addBotMessage: (text: string) => void;
4894
+ /** Get all messages */
4895
+ getMessages: () => ChatMessage[];
4896
+ /** Get collected data */
4897
+ getData: () => Record<string, unknown>;
4898
+ /** Set data */
4899
+ setData: (key: string, value: unknown) => void;
4900
+ /** Subscribe to events */
4901
+ on: (event: string, handler: (...args: unknown[]) => void) => void;
4902
+ /** Emit events */
4903
+ emit: (event: string, ...args: unknown[]) => void;
4904
+ }
4905
+
4906
+ /**
4907
+ * PluginManager — Manages plugin lifecycle (Open/Closed Principle)
4908
+ * Core is closed for modification, open for extension via plugins.
4909
+ */
4910
+ export declare class PluginManager {
4911
+ private plugins;
4912
+ private context;
4913
+ private eventHandlers;
4914
+ register(plugins: ChatPlugin[]): void;
4915
+ setContext(ctx: Omit<PluginContext, 'on' | 'emit'>): void;
4916
+ private on;
4917
+ private emit;
4918
+ init(): Promise<void>;
4919
+ onMessage(message: ChatMessage): Promise<ChatMessage>;
4920
+ onSubmit(data: Record<string, unknown>): Promise<void>;
4921
+ destroy(): Promise<void>;
4922
+ private dispatchEvent;
4923
+ }
4646
4924
 
4647
4925
  export declare const QuickReplies: default_2.FC<QuickRepliesProps>;
4648
4926
 
@@ -4661,6 +4939,12 @@ declare interface RadioFieldProps {
4661
4939
  error?: string;
4662
4940
  }
4663
4941
 
4942
+ export declare const RemoveIcon: default_2.FC<IconProps>;
4943
+
4944
+ export declare function resolveTheme(theme?: ChatTheme): Required<ChatTheme>;
4945
+
4946
+ export declare const RestartIcon: default_2.FC<IconProps>;
4947
+
4664
4948
  export declare const SelectField: default_2.FC<SelectFieldProps>;
4665
4949
 
4666
4950
  declare interface SelectFieldProps {
@@ -4670,6 +4954,18 @@ declare interface SelectFieldProps {
4670
4954
  error?: string;
4671
4955
  }
4672
4956
 
4957
+ export declare const SendIcon: default_2.FC<IconProps>;
4958
+
4959
+ /** Props passed to custom components rendered in flow steps */
4960
+ export declare interface StepComponentProps {
4961
+ /** The step ID that owns this component */
4962
+ stepId: string;
4963
+ /** All collected flow/form data */
4964
+ data: Record<string, unknown>;
4965
+ /** Call when the component interaction is complete — routes to next step */
4966
+ onComplete: (result?: FlowActionResult) => void;
4967
+ }
4968
+
4673
4969
  export declare const TextField: default_2.FC<TextFieldProps>;
4674
4970
 
4675
4971
  declare interface TextFieldProps {
@@ -4696,10 +4992,22 @@ export declare function useChat(): {
4696
4992
  dismissWelcome: () => void;
4697
4993
  startFlow: () => void;
4698
4994
  processFlowStep: (stepId: string) => Promise<void>;
4995
+ goBack: () => void;
4996
+ restartSession: () => void;
4997
+ handleComponentComplete: (result?: FlowActionResult) => void;
4699
4998
  };
4700
4999
 
4701
5000
  export declare function useChatContext(): ChatContextValue;
4702
5001
 
5002
+ /**
5003
+ * Webhook Plugin — sends messages/submissions to an external endpoint
5004
+ */
5005
+ export declare function webhookPlugin(options: {
5006
+ url: string;
5007
+ headers?: Record<string, string>;
5008
+ events?: ('message' | 'submit' | 'init' | 'destroy')[];
5009
+ }): ChatPlugin;
5010
+
4703
5011
  export declare const WelcomeScreen: default_2.FC<WelcomeScreenProps>;
4704
5012
 
4705
5013
  declare interface WelcomeScreenProps {