@enjoys/react-chatbot-plugin 1.2.0 → 1.4.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 +84 -436
- package/dist/index.cjs +5 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +116 -1
- package/dist/index.mjs +5 -2684
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -3
package/dist/index.d.ts
CHANGED
|
@@ -4446,6 +4446,16 @@ export declare interface ChatBotProps {
|
|
|
4446
4446
|
components?: Record<string, ComponentType<StepComponentProps>>;
|
|
4447
4447
|
/** Map of async action handlers (key = step.asyncAction.handler) */
|
|
4448
4448
|
actionHandlers?: Record<string, (data: Record<string, unknown>, ctx: ActionContext) => Promise<FlowActionResult>>;
|
|
4449
|
+
/** Override built-in form field renderers per field type. Each renderer receives strongly-typed props + the default element. */
|
|
4450
|
+
renderFormField?: FormFieldRenderMap;
|
|
4451
|
+
/** Fallback message when user types text with no active flow or unmatched input */
|
|
4452
|
+
fallbackMessage?: string | ((text: string) => string | null);
|
|
4453
|
+
/** Keyword routes — match user text to responses or flow steps */
|
|
4454
|
+
keywords?: KeywordRoute[];
|
|
4455
|
+
/** Convenience: auto-respond to common greetings (hello, hi, hey, etc.) */
|
|
4456
|
+
greetingResponse?: string;
|
|
4457
|
+
/** Typing delay in ms before bot sends keyword/fallback replies (default: 0) */
|
|
4458
|
+
typingDelay?: number;
|
|
4449
4459
|
}
|
|
4450
4460
|
|
|
4451
4461
|
export declare const ChatBubbleIcon: default_2.FC<IconProps>;
|
|
@@ -4463,6 +4473,10 @@ export declare interface ChatCallbacks {
|
|
|
4463
4473
|
onFlowEnd?: (collectedData: Record<string, unknown>) => void;
|
|
4464
4474
|
onError?: (error: Error) => void;
|
|
4465
4475
|
onEvent?: (event: string, payload?: unknown) => void;
|
|
4476
|
+
/** Called when user types text the bot couldn't handle */
|
|
4477
|
+
onUnhandledMessage?: (text: string, context: {
|
|
4478
|
+
currentStepId: string | null;
|
|
4479
|
+
}) => void;
|
|
4466
4480
|
}
|
|
4467
4481
|
|
|
4468
4482
|
export declare const ChatContext: Context<ChatContextValue | null>;
|
|
@@ -4471,6 +4485,7 @@ declare interface ChatContextValue {
|
|
|
4471
4485
|
state: ChatState;
|
|
4472
4486
|
dispatch: React.Dispatch<ChatAction>;
|
|
4473
4487
|
props: ChatBotProps;
|
|
4488
|
+
pluginManager?: PluginManager | null;
|
|
4474
4489
|
}
|
|
4475
4490
|
|
|
4476
4491
|
export declare const ChatHeader: default_2.FC<ChatHeaderProps>;
|
|
@@ -4604,6 +4619,15 @@ declare interface CheckboxFieldProps {
|
|
|
4604
4619
|
error?: string;
|
|
4605
4620
|
}
|
|
4606
4621
|
|
|
4622
|
+
/** Props passed to checkbox custom field renderers */
|
|
4623
|
+
export declare interface CheckboxFieldRenderProps {
|
|
4624
|
+
type: 'checkbox';
|
|
4625
|
+
field: FormFieldConfig;
|
|
4626
|
+
value: string[];
|
|
4627
|
+
onChange: (value: string[]) => void;
|
|
4628
|
+
error?: string;
|
|
4629
|
+
}
|
|
4630
|
+
|
|
4607
4631
|
export declare const CloseIcon: default_2.FC<IconProps>;
|
|
4608
4632
|
|
|
4609
4633
|
export declare const DynamicForm: default_2.FC<DynamicFormProps>;
|
|
@@ -4612,6 +4636,7 @@ declare interface DynamicFormProps {
|
|
|
4612
4636
|
config: FormConfig;
|
|
4613
4637
|
onSubmit: (data: Record<string, unknown>) => void;
|
|
4614
4638
|
primaryColor: string;
|
|
4639
|
+
renderFormField?: FormFieldRenderMap;
|
|
4615
4640
|
}
|
|
4616
4641
|
|
|
4617
4642
|
export declare const EmojiIcon: default_2.FC<IconProps>;
|
|
@@ -4624,6 +4649,16 @@ declare interface EmojiPickerProps {
|
|
|
4624
4649
|
primaryColor: string;
|
|
4625
4650
|
}
|
|
4626
4651
|
|
|
4652
|
+
/** Props passed to file custom field renderers */
|
|
4653
|
+
export declare interface FileFieldRenderProps {
|
|
4654
|
+
type: 'file';
|
|
4655
|
+
field: FormFieldConfig;
|
|
4656
|
+
value: FileList | null;
|
|
4657
|
+
onChange: (value: FileList | null) => void;
|
|
4658
|
+
error?: string;
|
|
4659
|
+
primaryColor: string;
|
|
4660
|
+
}
|
|
4661
|
+
|
|
4627
4662
|
export declare const FileIcon: default_2.FC<IconProps>;
|
|
4628
4663
|
|
|
4629
4664
|
export declare const FilePreviewList: default_2.FC<FilePreviewListProps>;
|
|
@@ -4761,10 +4796,22 @@ export declare interface FlowStep {
|
|
|
4761
4796
|
condition?: FlowCondition;
|
|
4762
4797
|
/** Key into ChatBotProps.components — renders a custom React component in this step */
|
|
4763
4798
|
component?: string;
|
|
4799
|
+
/** Free-text input configuration — validates user input before advancing */
|
|
4800
|
+
input?: FlowStepInput;
|
|
4764
4801
|
/** Async action to run when this step is entered (API calls, verification, etc.) */
|
|
4765
4802
|
asyncAction?: FlowAsyncAction;
|
|
4766
4803
|
}
|
|
4767
4804
|
|
|
4805
|
+
/** Configuration for a free-text input step with optional validation */
|
|
4806
|
+
export declare interface FlowStepInput {
|
|
4807
|
+
/** Placeholder text for the input */
|
|
4808
|
+
placeholder?: string;
|
|
4809
|
+
/** Validation rules (reuses form validation) */
|
|
4810
|
+
validation?: FormFieldValidation;
|
|
4811
|
+
/** Transform user input before storing */
|
|
4812
|
+
transform?: 'lowercase' | 'uppercase' | 'trim' | 'email';
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4768
4815
|
export declare interface FormConfig {
|
|
4769
4816
|
id: string;
|
|
4770
4817
|
title?: string;
|
|
@@ -4791,9 +4838,31 @@ export declare interface FormFieldOption {
|
|
|
4791
4838
|
value: string;
|
|
4792
4839
|
}
|
|
4793
4840
|
|
|
4841
|
+
/** Map of field type → custom renderer. The renderer receives strongly-typed props + the default element. */
|
|
4842
|
+
export declare type FormFieldRenderMap = Partial<{
|
|
4843
|
+
text: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4844
|
+
email: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4845
|
+
password: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4846
|
+
number: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4847
|
+
tel: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4848
|
+
url: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4849
|
+
textarea: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4850
|
+
date: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4851
|
+
time: (props: TextFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4852
|
+
select: (props: SelectFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4853
|
+
multiselect: (props: SelectFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4854
|
+
radio: (props: RadioFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4855
|
+
checkbox: (props: CheckboxFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4856
|
+
file: (props: FileFieldRenderProps, defaultElement: React.ReactNode) => React.ReactNode;
|
|
4857
|
+
}>;
|
|
4858
|
+
|
|
4859
|
+
/** Union of all field render props — discriminated by `type` */
|
|
4860
|
+
export declare type FormFieldRenderProps = TextFieldRenderProps | SelectFieldRenderProps | RadioFieldRenderProps | CheckboxFieldRenderProps | FileFieldRenderProps;
|
|
4861
|
+
|
|
4794
4862
|
export declare type FormFieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'file' | 'date' | 'time' | 'hidden';
|
|
4795
4863
|
|
|
4796
4864
|
export declare interface FormFieldValidation {
|
|
4865
|
+
required?: boolean;
|
|
4797
4866
|
pattern?: string;
|
|
4798
4867
|
minLength?: number;
|
|
4799
4868
|
maxLength?: number;
|
|
@@ -4820,6 +4889,22 @@ declare interface IconProps {
|
|
|
4820
4889
|
|
|
4821
4890
|
export declare const ImageIcon: default_2.FC<IconProps>;
|
|
4822
4891
|
|
|
4892
|
+
/** Route configuration for keyword-based text matching */
|
|
4893
|
+
export declare interface KeywordRoute {
|
|
4894
|
+
/** Patterns to match against user text */
|
|
4895
|
+
patterns: string[];
|
|
4896
|
+
/** Bot response message when matched */
|
|
4897
|
+
response?: string;
|
|
4898
|
+
/** Jump to this flow step when matched */
|
|
4899
|
+
next?: string;
|
|
4900
|
+
/** Case-sensitive matching (default: false) */
|
|
4901
|
+
caseSensitive?: boolean;
|
|
4902
|
+
/** Matching strategy (default: 'contains') */
|
|
4903
|
+
matchType?: 'exact' | 'contains' | 'startsWith' | 'regex';
|
|
4904
|
+
/** Priority — higher wins when multiple routes match (default: 0) */
|
|
4905
|
+
priority?: number;
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4823
4908
|
export declare const Launcher: default_2.FC<LauncherProps>;
|
|
4824
4909
|
|
|
4825
4910
|
declare interface LauncherProps {
|
|
@@ -4838,6 +4923,7 @@ declare interface LoginScreenProps {
|
|
|
4838
4923
|
config: FormConfig;
|
|
4839
4924
|
onLogin: (data: Record<string, unknown>) => void;
|
|
4840
4925
|
primaryColor: string;
|
|
4926
|
+
renderFormField?: FormFieldRenderMap;
|
|
4841
4927
|
}
|
|
4842
4928
|
|
|
4843
4929
|
export declare interface MessageAttachment {
|
|
@@ -4872,6 +4958,8 @@ declare interface MessageListProps {
|
|
|
4872
4958
|
collectedData?: Record<string, unknown>;
|
|
4873
4959
|
/** Current step ID */
|
|
4874
4960
|
currentStepId?: string | null;
|
|
4961
|
+
/** Custom form field renderers per field type */
|
|
4962
|
+
renderFormField?: FormFieldRenderMap;
|
|
4875
4963
|
}
|
|
4876
4964
|
|
|
4877
4965
|
export declare type MessageSender = 'bot' | 'user' | 'system';
|
|
@@ -4939,6 +5027,15 @@ declare interface RadioFieldProps {
|
|
|
4939
5027
|
error?: string;
|
|
4940
5028
|
}
|
|
4941
5029
|
|
|
5030
|
+
/** Props passed to radio custom field renderers */
|
|
5031
|
+
export declare interface RadioFieldRenderProps {
|
|
5032
|
+
type: 'radio';
|
|
5033
|
+
field: FormFieldConfig;
|
|
5034
|
+
value: string;
|
|
5035
|
+
onChange: (value: string) => void;
|
|
5036
|
+
error?: string;
|
|
5037
|
+
}
|
|
5038
|
+
|
|
4942
5039
|
export declare const RemoveIcon: default_2.FC<IconProps>;
|
|
4943
5040
|
|
|
4944
5041
|
export declare function resolveTheme(theme?: ChatTheme): Required<ChatTheme>;
|
|
@@ -4954,6 +5051,15 @@ declare interface SelectFieldProps {
|
|
|
4954
5051
|
error?: string;
|
|
4955
5052
|
}
|
|
4956
5053
|
|
|
5054
|
+
/** Props passed to select/multiselect custom field renderers */
|
|
5055
|
+
export declare interface SelectFieldRenderProps {
|
|
5056
|
+
type: 'select' | 'multiselect';
|
|
5057
|
+
field: FormFieldConfig;
|
|
5058
|
+
value: string | string[];
|
|
5059
|
+
onChange: (value: string | string[]) => void;
|
|
5060
|
+
error?: string;
|
|
5061
|
+
}
|
|
5062
|
+
|
|
4957
5063
|
export declare const SendIcon: default_2.FC<IconProps>;
|
|
4958
5064
|
|
|
4959
5065
|
/** Props passed to custom components rendered in flow steps */
|
|
@@ -4975,6 +5081,15 @@ declare interface TextFieldProps {
|
|
|
4975
5081
|
error?: string;
|
|
4976
5082
|
}
|
|
4977
5083
|
|
|
5084
|
+
/** Props passed to text-like custom field renderers */
|
|
5085
|
+
export declare interface TextFieldRenderProps {
|
|
5086
|
+
type: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'date' | 'time';
|
|
5087
|
+
field: FormFieldConfig;
|
|
5088
|
+
value: string;
|
|
5089
|
+
onChange: (value: string) => void;
|
|
5090
|
+
error?: string;
|
|
5091
|
+
}
|
|
5092
|
+
|
|
4978
5093
|
export declare const TypingIndicator: default_2.FC<TypingIndicatorProps>;
|
|
4979
5094
|
|
|
4980
5095
|
declare interface TypingIndicatorProps {
|
|
@@ -4983,7 +5098,7 @@ declare interface TypingIndicatorProps {
|
|
|
4983
5098
|
|
|
4984
5099
|
export declare function useChat(): {
|
|
4985
5100
|
state: ChatState;
|
|
4986
|
-
sendMessage: (text: string) => void
|
|
5101
|
+
sendMessage: (text: string) => Promise<void>;
|
|
4987
5102
|
addBotMessage: (text: string, extras?: Partial<ChatMessage>) => Promise<void>;
|
|
4988
5103
|
handleQuickReply: (value: string, label: string) => void;
|
|
4989
5104
|
handleFormSubmit: (formId: string, data: Record<string, unknown>) => Promise<void>;
|