@makebot.it/js 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,143 @@
1
+ import { InputBlock } from '@makebot.it/blocks-inputs/schema';
2
+ import { StartMakebot, StartFrom } from '@makebot.it/chat-api/schemas';
3
+ import { LogInSession } from '@makebot.it/logs/schemas';
4
+ import { Font } from '@makebot.it/theme/schemas';
5
+
6
+ type BubbleParams = {
7
+ theme?: BubbleTheme;
8
+ previewMessage?: PreviewMessageParams;
9
+ autoShowDelay?: number;
10
+ };
11
+ type BubbleTheme = {
12
+ chatWindow?: ChatWindowTheme;
13
+ button?: ButtonTheme;
14
+ previewMessage?: PreviewMessageTheme;
15
+ placement?: "left" | "right";
16
+ position?: "fixed" | "static";
17
+ };
18
+ type ChatWindowTheme = {
19
+ backgroundColor?: string;
20
+ maxWidth?: string;
21
+ maxHeight?: string;
22
+ };
23
+ type ButtonTheme = {
24
+ isHidden?: boolean;
25
+ size?: "medium" | "large" | `${number}px`;
26
+ backgroundColor?: string;
27
+ iconColor?: string;
28
+ customIconSrc?: string;
29
+ customCloseIconSrc?: string;
30
+ };
31
+ type PreviewMessageParams = {
32
+ avatarUrl?: string;
33
+ message: string;
34
+ autoShowDelay?: number;
35
+ };
36
+ type PreviewMessageTheme = {
37
+ backgroundColor?: string;
38
+ textColor?: string;
39
+ closeButtonBackgroundColor?: string;
40
+ closeButtonIconColor?: string;
41
+ };
42
+
43
+ type CommandArgs = {
44
+ id?: string;
45
+ };
46
+ type CommandData = CommandArgs & {
47
+ isFromMakebot: boolean;
48
+ } & ({
49
+ command: "open" | "toggle" | "close" | "hidePreviewMessage" | "unmount" | "reload";
50
+ } | ShowMessageCommandData | SetPrefilledVariablesCommandData | SetInputValueCommandData | SendCommandCommandData);
51
+ type ShowMessageCommandData = {
52
+ command: "showPreviewMessage";
53
+ message?: Pick<PreviewMessageParams, "avatarUrl" | "message">;
54
+ };
55
+ type SetPrefilledVariablesCommandData = {
56
+ command: "setPrefilledVariables";
57
+ variables: Record<string, string | number | boolean>;
58
+ };
59
+ type SetInputValueCommandData = {
60
+ command: "setInputValue";
61
+ value: string;
62
+ };
63
+ type SendCommandCommandData = {
64
+ command: "sendCommand";
65
+ text: string;
66
+ };
67
+
68
+ declare const close: ({ id }?: CommandArgs) => void;
69
+
70
+ declare const open: ({ id }?: CommandArgs) => void;
71
+
72
+ declare const showPreviewMessage: (proactiveMessage: ShowMessageCommandData["message"] | undefined, { id }?: CommandArgs) => void;
73
+
74
+ declare const toggle: ({ id }?: CommandArgs) => void;
75
+
76
+ declare const setInputValue: (value: string, { id }?: CommandArgs) => void;
77
+
78
+ declare const unmount: ({ id }?: CommandArgs) => void;
79
+
80
+ declare const setPrefilledVariables: (variables: Record<string, string | number | boolean>, { id }?: CommandArgs) => void;
81
+
82
+ declare const hidePreviewMessage: ({ id }?: CommandArgs) => void;
83
+
84
+ declare const sendCommand: (text: string, { id }?: CommandArgs) => void;
85
+
86
+ declare const reload: ({ id }?: CommandArgs) => void;
87
+
88
+ type BotProps = {
89
+ id?: string;
90
+ makebot: string | StartMakebot | undefined;
91
+ isPreview?: boolean;
92
+ resultId?: string;
93
+ prefilledVariables?: Record<string, unknown>;
94
+ apiHost?: string;
95
+ wsHost?: string;
96
+ font?: Font;
97
+ progressBarRef?: HTMLDivElement;
98
+ startFrom?: StartFrom;
99
+ sessionId?: string;
100
+ onNewInputBlock?: (inputBlock: InputBlock) => void;
101
+ onAnswer?: (answer: {
102
+ message: string;
103
+ blockId: string;
104
+ }) => void;
105
+ onInit?: () => void;
106
+ onEnd?: () => void;
107
+ onNewLogs?: (logs: LogInSession[]) => void;
108
+ onChatStatePersisted?: (isEnabled: boolean) => void;
109
+ onScriptExecutionSuccess?: (message: string) => void;
110
+ };
111
+
112
+ type PopupParams = {
113
+ autoShowDelay?: number;
114
+ theme?: {
115
+ width?: string;
116
+ backgroundColor?: string;
117
+ zIndex?: number;
118
+ };
119
+ };
120
+
121
+ type PopupProps = BotProps & PopupParams & {
122
+ defaultOpen?: boolean;
123
+ isOpen?: boolean;
124
+ onOpen?: () => void;
125
+ onClose?: () => void;
126
+ };
127
+
128
+ type BubbleProps = BotProps & BubbleParams & {
129
+ inlineStyle?: {
130
+ [key: string]: string;
131
+ };
132
+ isOpen?: boolean;
133
+ onOpen?: () => void;
134
+ onClose?: () => void;
135
+ onPreviewMessageClick?: () => void;
136
+ onPreviewMessageDismissed?: () => void;
137
+ };
138
+
139
+ declare const resolveButtonSize: (size: NonNullable<NonNullable<BubbleProps["theme"]>["button"]>["size"], { isHidden }?: {
140
+ isHidden?: boolean;
141
+ }) => `${number}px`;
142
+
143
+ export { type BotProps, type BubbleParams, type BubbleProps, type BubbleTheme, type ButtonTheme, type ChatWindowTheme, type CommandArgs, type CommandData, type PopupParams, type PopupProps, type PreviewMessageParams, type PreviewMessageTheme, type SendCommandCommandData, type SetInputValueCommandData, type SetPrefilledVariablesCommandData, type ShowMessageCommandData, close, hidePreviewMessage, open, reload, resolveButtonSize, sendCommand, setInputValue, setPrefilledVariables, showPreviewMessage, toggle, unmount };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var s=({id:o}={})=>{let e={isFromMakebot:!0,command:"close",id:o};window.postMessage(e)};var r=({id:o}={})=>{let e={isFromMakebot:!0,command:"open",id:o};window.postMessage(e)};var p=(o,{id:e}={})=>{let m={isFromMakebot:!0,command:"showPreviewMessage",message:o,id:e};window.postMessage(m)};var g=({id:o}={})=>{let e={isFromMakebot:!0,command:"toggle",id:o};window.postMessage(e)};var u=(o,{id:e}={})=>{let m={isFromMakebot:!0,command:"setInputValue",value:o,id:e};window.postMessage(m)};var f=({id:o}={})=>{let e={isFromMakebot:!0,command:"unmount",id:o};window.postMessage(e)};var c=(o,{id:e}={})=>{let m={isFromMakebot:!0,command:"setPrefilledVariables",variables:o,id:e};window.postMessage(m)};var l=({id:o}={})=>{let e={isFromMakebot:!0,command:"hidePreviewMessage",id:o};window.postMessage(e)};var y=(o,{id:e}={})=>{let m={isFromMakebot:!0,command:"sendCommand",text:o,id:e};window.postMessage(m)};var D=({id:o}={})=>{let e={isFromMakebot:!0,command:"reload",id:o};window.postMessage(e)};var t=(o,{isHidden:e=!1}={})=>e?"0px":o==="large"?"64px":o==="medium"||!o?"48px":typeof o=="string"&&/^\d+px$/.test(o.trim())?o.trim():(console.warn("[Makebot] Tamanho de bot\xE3o inv\xE1lido. Use 'm\xE9dio', 'grande' ou um valor em pixels expl\xEDcita (ex.: '52px')."),"48px");export{s as close,l as hidePreviewMessage,r as open,D as reload,t as resolveButtonSize,y as sendCommand,u as setInputValue,c as setPrefilledVariables,p as showPreviewMessage,g as toggle,f as unmount};