@opencx/widget 2.0.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.
Files changed (125) hide show
  1. package/README.md +105 -0
  2. package/dist/basic.cjs +259 -0
  3. package/dist/basic.cjs.map +1 -0
  4. package/dist/basic.d.ts +2 -0
  5. package/dist/basic.js +40507 -0
  6. package/dist/basic.js.map +1 -0
  7. package/dist/core/client/api.d.ts +15 -0
  8. package/dist/core/client/client.d.ts +39 -0
  9. package/dist/core/client/index.d.ts +1 -0
  10. package/dist/core/errors/index.d.ts +21 -0
  11. package/dist/core/index.d.ts +3 -0
  12. package/dist/core/managers/chathistory-manager.d.ts +61 -0
  13. package/dist/core/managers/session-manager.d.ts +35 -0
  14. package/dist/core/platform/index.d.ts +20 -0
  15. package/dist/core/transport/http.transport.d.ts +17 -0
  16. package/dist/core/transport/transport.d.ts +25 -0
  17. package/dist/core/types/helpers.d.ts +5 -0
  18. package/dist/core/types/index.d.ts +32 -0
  19. package/dist/core/types/messages.d.ts +43 -0
  20. package/dist/core/types/prelude.d.ts +14 -0
  21. package/dist/core/types/pub-sub.d.ts +94 -0
  22. package/dist/core/types/schemas.d.ts +489 -0
  23. package/dist/core/types/transport.d.ts +31 -0
  24. package/dist/core/utils/genId.d.ts +2 -0
  25. package/dist/core/utils/genId.test.d.ts +1 -0
  26. package/dist/core/utils/history-to-widget-messages.d.ts +4 -0
  27. package/dist/history-to-widget-messages-CP0hKjhv.js +195 -0
  28. package/dist/history-to-widget-messages-CP0hKjhv.js.map +1 -0
  29. package/dist/history-to-widget-messages-CdbZolRN.cjs +2 -0
  30. package/dist/history-to-widget-messages-CdbZolRN.cjs.map +1 -0
  31. package/dist/index-C11ivBh5.js +2604 -0
  32. package/dist/index-C11ivBh5.js.map +1 -0
  33. package/dist/index-DQmRZV3b.cjs +18 -0
  34. package/dist/index-DQmRZV3b.cjs.map +1 -0
  35. package/dist/index.cjs +2 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +445 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/react-lib/Root.d.ts +6 -0
  41. package/dist/react-lib/hooks/handle-socket-messages.d.ts +27 -0
  42. package/dist/react-lib/hooks/index.d.ts +6 -0
  43. package/dist/react-lib/hooks/socket.d.ts +11 -0
  44. package/dist/react-lib/hooks/socketState.d.ts +2 -0
  45. package/dist/react-lib/hooks/use-sound.d.ts +13 -0
  46. package/dist/react-lib/hooks/use-sound.test.d.ts +1 -0
  47. package/dist/react-lib/hooks/use-sync-state.test.d.ts +1 -0
  48. package/dist/react-lib/hooks/useAbstractChat.d.ts +159 -0
  49. package/dist/react-lib/hooks/useAxiosInstance.d.ts +121 -0
  50. package/dist/react-lib/hooks/useBaseClient.d.ts +2 -0
  51. package/dist/react-lib/hooks/useScrollTo.d.ts +2 -0
  52. package/dist/react-lib/hooks/useSyncState.d.ts +4 -0
  53. package/dist/react-lib/hooks/useTimeoutState.d.ts +3 -0
  54. package/dist/react-lib/hooks/useUploadFiles.d.ts +21 -0
  55. package/dist/react-lib/hooks/useVote.d.ts +2 -0
  56. package/dist/react-lib/hooks/useWidgetContentHeight.d.ts +9 -0
  57. package/dist/react-lib/index.d.ts +10 -0
  58. package/dist/react-lib/locales/ar.locale.d.ts +2 -0
  59. package/dist/react-lib/locales/de.locale.d.ts +2 -0
  60. package/dist/react-lib/locales/en.locale.d.ts +55 -0
  61. package/dist/react-lib/locales/fr.locale.d.ts +2 -0
  62. package/dist/react-lib/locales/helper.d.ts +65 -0
  63. package/dist/react-lib/locales/index.d.ts +3 -0
  64. package/dist/react-lib/locales/nl.locale.d.ts +2 -0
  65. package/dist/react-lib/locales/pt.locale.d.ts +2 -0
  66. package/dist/react-lib/providers/ChatProvider.d.ts +135 -0
  67. package/dist/react-lib/providers/ClientProvider.d.ts +7 -0
  68. package/dist/react-lib/providers/ConfigDataProvider.d.ts +62 -0
  69. package/dist/react-lib/providers/ContactProvider.d.ts +58 -0
  70. package/dist/react-lib/providers/LocalesProvider.d.ts +11 -0
  71. package/dist/react-lib/providers/componentRegistry.d.ts +13 -0
  72. package/dist/react-lib/providers/use-widget-sfx.d.ts +7 -0
  73. package/dist/react-lib/providers/usePreludeData.d.ts +2 -0
  74. package/dist/react-lib/types/components.d.ts +10 -0
  75. package/dist/react-lib/types/index.d.ts +6 -0
  76. package/dist/react-lib/types/options.d.ts +43 -0
  77. package/dist/react-lib/utils/create-safe-context.d.ts +1 -0
  78. package/dist/react-lib/utils/debug.d.ts +2 -0
  79. package/dist/react-lib/utils/getters.d.ts +24 -0
  80. package/dist/react-lib/utils/index.d.ts +1 -0
  81. package/dist/react.cjs +2 -0
  82. package/dist/react.cjs.map +1 -0
  83. package/dist/react.d.ts +2 -0
  84. package/dist/react.js +41 -0
  85. package/dist/react.js.map +1 -0
  86. package/dist/src/@components/BotMessage.d.ts +9 -0
  87. package/dist/src/@components/BotMessageWrapper.d.ts +7 -0
  88. package/dist/src/@components/ChatEvent.component.d.ts +9 -0
  89. package/dist/src/@components/Fallback.component.d.ts +8 -0
  90. package/dist/src/@components/Loading.component.d.ts +2 -0
  91. package/dist/src/@components/OpenLogoSvg.d.ts +4 -0
  92. package/dist/src/@components/Text.component.d.ts +3 -0
  93. package/dist/src/@components/index.d.ts +6 -0
  94. package/dist/src/@components/markdown.d.ts +3 -0
  95. package/dist/src/components/MotionDiv.d.ts +18 -0
  96. package/dist/src/components/RenderFile.d.ts +7 -0
  97. package/dist/src/components/avatar.d.ts +6 -0
  98. package/dist/src/components/button.d.ts +11 -0
  99. package/dist/src/components/dialog.d.ts +276 -0
  100. package/dist/src/components/dropdown-menu.d.ts +27 -0
  101. package/dist/src/components/input.d.ts +5 -0
  102. package/dist/src/components/keyboard.d.ts +7 -0
  103. package/dist/src/components/popover.d.ts +8 -0
  104. package/dist/src/components/skeleton.d.ts +3 -0
  105. package/dist/src/components/switch.d.ts +4 -0
  106. package/dist/src/components/tooltip.d.ts +10 -0
  107. package/dist/src/components/userMessage.d.ts +8 -0
  108. package/dist/src/components/wobble.d.ts +15 -0
  109. package/dist/src/designs/basic/WidgetPopoverTrigger.d.ts +5 -0
  110. package/dist/src/designs/basic/index.d.ts +5 -0
  111. package/dist/src/designs/basic/screens/chat-screen/ChatFooter.d.ts +2 -0
  112. package/dist/src/designs/basic/screens/chat-screen/ChatHeader.d.ts +2 -0
  113. package/dist/src/designs/basic/screens/chat-screen/ChatScreen.d.ts +2 -0
  114. package/dist/src/designs/basic/screens/chat-screen/SessionClosedDialog.d.ts +2 -0
  115. package/dist/src/designs/basic/screens/root-screen.d.ts +2 -0
  116. package/dist/src/designs/basic/screens/welcome-screen/WelcomeScreen.d.ts +2 -0
  117. package/dist/src/designs/constants.d.ts +15 -0
  118. package/dist/src/hooks/useShouldCollectData.d.ts +3 -0
  119. package/dist/src/index.d.ts +9 -0
  120. package/dist/src/render.d.ts +2 -0
  121. package/dist/src/utils.d.ts +2 -0
  122. package/dist/style.css +1 -0
  123. package/dist-embed/script.js +476 -0
  124. package/dist-embed/script.js.map +1 -0
  125. package/package.json +153 -0
@@ -0,0 +1,6 @@
1
+ export * from './useSyncState';
2
+ export * from './useAxiosInstance';
3
+ export * from './useScrollTo';
4
+ export * from './useVote';
5
+ export * from './useUploadFiles';
6
+ export * from './useWidgetContentHeight';
@@ -0,0 +1,11 @@
1
+ import { DependencyList } from 'react';
2
+ import { ManagerOptions, Socket, SocketOptions } from 'socket.io-client';
3
+ export type SocketState = "connected" | "disconnected" | "connecting" | "reconnecting" | "reconnected" | "disconnecting" | "error";
4
+ type useSocketReturn = {
5
+ socket: Socket | null;
6
+ socketState: SocketState;
7
+ disconnect: () => void;
8
+ useListen: (event: string, callback: (data: any) => void, deps?: DependencyList) => void;
9
+ };
10
+ export declare function useSocket(url: string, opts: Partial<ManagerOptions & SocketOptions>, _deps?: DependencyList): useSocketReturn;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ import { SocketState } from './socket';
2
+ export declare function representSocketState(state: SocketState, getter: Function): any;
@@ -0,0 +1,13 @@
1
+ interface UseAudioOptions {
2
+ src: string;
3
+ soundEnabled?: boolean;
4
+ volume?: number;
5
+ }
6
+ declare function useSound(opts: UseAudioOptions): {
7
+ play: () => void;
8
+ stop: () => void;
9
+ pause: () => void;
10
+ isPlaying: () => boolean;
11
+ instance: HTMLAudioElement | null;
12
+ };
13
+ export { useSound };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,159 @@
1
+ import { UserObject } from '../types';
2
+ import { ReactNode } from 'react';
3
+ import { AIClosureType, ChatAttachmentType, MessageType, SessionStatus } from '../../core/types';
4
+ type HookState = {
5
+ state: "loading" | "error" | "idle";
6
+ error?: any;
7
+ };
8
+ type useChatOptions = {
9
+ onSessionDestroy?: () => void;
10
+ defaultHookSettings?: HookSettings;
11
+ };
12
+ type ChatState = {
13
+ lastUpdated: number | null;
14
+ messages: MessageType[];
15
+ /**
16
+ * Options that the AI provides to the user after a reply, such as "I need more help" or "This is helpful"
17
+ */
18
+ keyboard: {
19
+ options: string[];
20
+ } | null;
21
+ };
22
+ interface SendMessageInput extends Record<string, unknown> {
23
+ content: {
24
+ text: string;
25
+ };
26
+ attachments?: Array<ChatAttachmentType>;
27
+ id?: string;
28
+ language?: string;
29
+ user?: UserObject;
30
+ }
31
+ interface HookSettings {
32
+ persistSession?: boolean;
33
+ useSoundEffects?: boolean;
34
+ }
35
+ declare function useAbstractChat({ onSessionDestroy }: useChatOptions): {
36
+ version: string;
37
+ state: ChatState;
38
+ session: {
39
+ isSessionClosed: boolean;
40
+ isAssignedToAi: boolean;
41
+ isAssignedToHuman: boolean;
42
+ isPendingHuman: boolean;
43
+ id: string;
44
+ ai_closure_type: AIClosureType | null;
45
+ assignee_id: number | null;
46
+ channel: import('../../core/types').SessionChannel;
47
+ status: SessionStatus;
48
+ summary: string | null;
49
+ language: string | null;
50
+ last_message: string | null;
51
+ last_message_at: Date | null;
52
+ sentiment: import('../../core/types').SentimentEnum | null;
53
+ assignee?: {
54
+ email: string;
55
+ name: string;
56
+ avatar_url?: string | undefined;
57
+ } | null | undefined;
58
+ } | null;
59
+ unstable__canSend: {
60
+ canSend: boolean;
61
+ reason: string;
62
+ } | {
63
+ canSend: boolean;
64
+ reason?: undefined;
65
+ };
66
+ noMessages: boolean;
67
+ fetchHistoryState: {
68
+ loading: boolean;
69
+ error?: undefined;
70
+ value?: undefined;
71
+ } | {
72
+ loading: false;
73
+ error: Error;
74
+ value?: undefined;
75
+ } | {
76
+ loading: true;
77
+ error?: Error | undefined;
78
+ value?: MessageType[] | undefined;
79
+ } | {
80
+ loading: false;
81
+ error?: undefined;
82
+ value: MessageType[];
83
+ };
84
+ refreshSessionState: {
85
+ loading: boolean;
86
+ error?: undefined;
87
+ value?: undefined;
88
+ } | {
89
+ loading: false;
90
+ error: Error;
91
+ value?: undefined;
92
+ } | {
93
+ loading: true;
94
+ error?: Error | undefined;
95
+ value?: {
96
+ id: string;
97
+ ai_closure_type: AIClosureType | null;
98
+ assignee_id: number | null;
99
+ channel: import('../../core/types').SessionChannel;
100
+ status: SessionStatus;
101
+ summary: string | null;
102
+ language: string | null;
103
+ last_message: string | null;
104
+ last_message_at: Date | null;
105
+ sentiment: import('../../core/types').SentimentEnum | null;
106
+ assignee?: {
107
+ email: string;
108
+ name: string;
109
+ avatar_url?: string | undefined;
110
+ } | null | undefined;
111
+ } | undefined;
112
+ } | {
113
+ loading: false;
114
+ error?: undefined;
115
+ value: {
116
+ id: string;
117
+ ai_closure_type: AIClosureType | null;
118
+ assignee_id: number | null;
119
+ channel: import('../../core/types').SessionChannel;
120
+ status: SessionStatus;
121
+ summary: string | null;
122
+ language: string | null;
123
+ last_message: string | null;
124
+ last_message_at: Date | null;
125
+ sentiment: import('../../core/types').SentimentEnum | null;
126
+ assignee?: {
127
+ email: string;
128
+ name: string;
129
+ avatar_url?: string | undefined;
130
+ } | null | undefined;
131
+ };
132
+ };
133
+ recreateSession: () => void;
134
+ clearSession: () => void;
135
+ sendMessage: ({ content, user, ...data }: SendMessageInput) => Promise<{
136
+ attachments: Array<ChatAttachmentType>;
137
+ id: string;
138
+ language: string;
139
+ bot_token: string;
140
+ content: string;
141
+ session_id: string;
142
+ headers: Record<string, string>;
143
+ pathParams: Record<string, string>;
144
+ query_params: Record<string, string>;
145
+ queryParams: Record<string, string>;
146
+ user: {
147
+ external_id?: string;
148
+ name?: string;
149
+ email?: string;
150
+ phone?: string;
151
+ customData?: Record<string, string>;
152
+ avatarUrl?: string;
153
+ };
154
+ } | null>;
155
+ info: ReactNode;
156
+ handleKeyboard: (option: string) => void;
157
+ hookState: HookState;
158
+ };
159
+ export { useAbstractChat, type SendMessageInput, type HookState };
@@ -0,0 +1,121 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { PreludeData, WorkingHours } from '@core/types/prelude';
3
+ import { UserObject } from '../types';
4
+ type Options = {
5
+ apiUrl: string;
6
+ botToken: string;
7
+ };
8
+ export declare function useAxiosInstance(options: Options): {
9
+ apis: {
10
+ createSession: (botToken: string) => Promise<import('axios').AxiosResponse<{
11
+ id: string;
12
+ ai_closure_type: import('../../core/types').AIClosureType | null;
13
+ assignee_id: number | null;
14
+ channel: import('../../core/types').SessionChannel;
15
+ status: import('../../core/types').SessionStatus;
16
+ summary: string | null;
17
+ language: string | null;
18
+ last_message: string | null;
19
+ last_message_at: Date | null;
20
+ sentiment: import('../../core/types').SentimentEnum | null;
21
+ assignee?: {
22
+ email: string;
23
+ name: string;
24
+ avatar_url?: string | undefined;
25
+ } | null | undefined;
26
+ }, any>>;
27
+ /**
28
+ * get session data by id
29
+ * @param sessionId
30
+ */
31
+ fetchSession: (sessionId: string) => Promise<import('axios').AxiosResponse<{
32
+ id: string;
33
+ ai_closure_type: import('../../core/types').AIClosureType | null;
34
+ assignee_id: number | null;
35
+ channel: import('../../core/types').SessionChannel;
36
+ status: import('../../core/types').SessionStatus;
37
+ summary: string | null;
38
+ language: string | null;
39
+ last_message: string | null;
40
+ last_message_at: Date | null;
41
+ sentiment: import('../../core/types').SentimentEnum | null;
42
+ assignee?: {
43
+ email: string;
44
+ name: string;
45
+ avatar_url?: string | undefined;
46
+ } | null | undefined;
47
+ }, any>>;
48
+ fetchPreludeData: () => Promise<PreludeData | undefined>;
49
+ /**
50
+ * get the organization office working hours.
51
+ */
52
+ getOfficeHours: () => Promise<import('axios').AxiosResponse<WorkingHours, any>>;
53
+ fetchHistory: (sessionId: string) => Promise<import('axios').AxiosResponse<{
54
+ message: string | null;
55
+ type: string | null;
56
+ publicId: string;
57
+ agent_avatar: string | null;
58
+ agent_id: number | null;
59
+ agent_name: string | null;
60
+ created_at: string;
61
+ from_user: boolean | null;
62
+ handoff_happened_during_office_hours: boolean | null;
63
+ session_id: string;
64
+ updated_at: string | null;
65
+ attachments?: import('../../core/types').ChatAttachmentType[] | undefined;
66
+ }[] | undefined, any>>;
67
+ downvote: (id: string) => Promise<import('axios').AxiosResponse<{
68
+ message: string;
69
+ }, any>>;
70
+ upvote: (id: string) => Promise<import('axios').AxiosResponse<{
71
+ message: string;
72
+ }, any>>;
73
+ /**
74
+ * given the userData object we will create or update the contact + get the related conversations/tickets/sessions
75
+ */
76
+ dumpContact: (userData: UserObject) => Promise<import('axios').AxiosResponse<{
77
+ email: string | null;
78
+ id: string;
79
+ name: string | null;
80
+ avatar_url: string | null;
81
+ created_at: string;
82
+ }, any>>;
83
+ /**
84
+ * get the completions for the given input
85
+ */
86
+ getCompletions: (input: string) => Promise<import('axios').AxiosResponse<{
87
+ completions: string[];
88
+ }, any>>;
89
+ /**
90
+ * @param file
91
+ * @param options
92
+ */
93
+ uploadFile: (file: {
94
+ id: string;
95
+ file: File;
96
+ }, _options?: AxiosRequestConfig) => Promise<import('axios').AxiosResponse<{
97
+ fileName: string;
98
+ fileUrl: string;
99
+ clientFileId: string;
100
+ }, any>>;
101
+ getHistoryPooling: ({ lastMessageTimestamp, sessionId, }: {
102
+ lastMessageTimestamp: string;
103
+ sessionId: string;
104
+ }) => Promise<import('axios').AxiosResponse<{
105
+ message: string | null;
106
+ type: string | null;
107
+ publicId: string;
108
+ agent_avatar: string | null;
109
+ agent_id: number | null;
110
+ agent_name: string | null;
111
+ created_at: string;
112
+ from_user: boolean | null;
113
+ handoff_happened_during_office_hours: boolean | null;
114
+ session_id: string;
115
+ updated_at: string | null;
116
+ attachments?: import('../../core/types').ChatAttachmentType[] | undefined;
117
+ }[] | undefined, any>>;
118
+ };
119
+ options: Options;
120
+ };
121
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ApiClient, CoreOptions } from '../../core/index';
2
+ export declare const useBaseClient: (options: CoreOptions) => ApiClient | null;
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'react';
2
+ export declare const useScrollToPercentage: (elementRef: RefObject<HTMLElement>) => [(percentageX: number, percentageY: number) => void];
@@ -0,0 +1,4 @@
1
+ type StorageType = "memory" | "local" | "session";
2
+ type DefaultValue<T> = T | (() => T);
3
+ export declare function useSyncedState<TData>(key: string, defaultValue?: DefaultValue<TData>, storage?: StorageType): [TData | null, (newState: TData | null) => void, () => void];
4
+ export {};
@@ -0,0 +1,3 @@
1
+ type DefaultValue<T> = T | (() => T);
2
+ export declare function useTimeoutState<T>(initialValue: DefaultValue<T>, timeout: number): [T, (value: T) => void];
3
+ export {};
@@ -0,0 +1,21 @@
1
+ interface FileWithProgress {
2
+ status: "pending" | "uploading" | "success" | "error";
3
+ id: string;
4
+ file: File;
5
+ fileUrl?: string;
6
+ progress: number;
7
+ error?: string;
8
+ }
9
+ declare function useUploadFiles(): {
10
+ allFiles: FileWithProgress[];
11
+ appendFiles: (files: File[]) => void;
12
+ handleCancelUpload: (fileId: string) => void;
13
+ successFiles: FileWithProgress[];
14
+ emptyTheFiles: () => void;
15
+ getFileById: (id: string) => FileWithProgress | undefined;
16
+ getUploadProgress: (id: string) => number;
17
+ getUploadStatus: (id: string) => "error" | "pending" | "uploading" | "success" | undefined;
18
+ hasErrors: boolean;
19
+ isUploading: boolean;
20
+ };
21
+ export { useUploadFiles, type FileWithProgress };
@@ -0,0 +1,2 @@
1
+ export declare function useUpvote(id: string, onSuccess?: () => void): import('react-use/lib/useAsyncFn').AsyncFnReturn<() => Promise<void>>;
2
+ export declare function useDownvote(id: string, onSuccess?: () => void): import('react-use/lib/useAsyncFn').AsyncFnReturn<() => Promise<void>>;
@@ -0,0 +1,9 @@
1
+ export declare function useWidgetContentHeight({ fallbackHeight: minHeight, }: {
2
+ /**
3
+ * unrendered elements have an offset height of 0, this is causes a weird animation when opening the widget.
4
+ * So, a fallback value equal to the fixed height or min height of the screen's root div solves the issue.
5
+ */
6
+ fallbackHeight: number;
7
+ }): {
8
+ observedElementRef: import('react').RefObject<HTMLDivElement>;
9
+ };
@@ -0,0 +1,10 @@
1
+ export * from './types';
2
+ export * from './utils';
3
+ export { useUpvote, useDownvote, useUploadFiles, type FileWithProgress, } from './hooks';
4
+ export { WidgetRoot } from './Root';
5
+ export { useConfigData } from './providers/ConfigDataProvider';
6
+ export { useChat } from './providers/ChatProvider';
7
+ export { useLocale } from './providers/LocalesProvider';
8
+ export { useWidgetSoundEffects } from './providers/use-widget-sfx';
9
+ export { useContact } from './providers/ContactProvider';
10
+ export { usePreludeData } from './providers/usePreludeData';
@@ -0,0 +1,2 @@
1
+ import { TranslatableMessages } from '.';
2
+ export declare const arLocale: TranslatableMessages;
@@ -0,0 +1,2 @@
1
+ import { TranslatableMessages } from '.';
2
+ export declare const deLocale: TranslatableMessages;
@@ -0,0 +1,55 @@
1
+ export declare const enLocale: {
2
+ ok: string;
3
+ yes: string;
4
+ no: string;
5
+ agree: string;
6
+ cancel: string;
7
+ "yes-exit": string;
8
+ "yes-reset": string;
9
+ "no-cancel": string;
10
+ "are-you-sure": string;
11
+ recording: string;
12
+ "thank-you": string;
13
+ "sorry-try-again": string;
14
+ "error-occurred": string;
15
+ "please-try-again": string;
16
+ "write-a-message": string;
17
+ "send-message": string;
18
+ connected: string;
19
+ connecting: string;
20
+ reconnecting: string;
21
+ reconnected: string;
22
+ disconnecting: string;
23
+ disconnected: string;
24
+ error: string;
25
+ "persist-session": string;
26
+ settings: string;
27
+ close: string;
28
+ help: string;
29
+ chat: string;
30
+ send: string;
31
+ copy: string;
32
+ copied: string;
33
+ "sound-effects": string;
34
+ language: string;
35
+ select: string;
36
+ agent: string;
37
+ user: string;
38
+ bot: string;
39
+ "reset-conversation-confirm": string;
40
+ "close-widget": string;
41
+ "got-any-questions": string;
42
+ "typical-response-time": string;
43
+ "session-closed-lead": string;
44
+ "create-new-ticket": string;
45
+ exit: string;
46
+ "reset-conversation": string;
47
+ "welcome-title": string;
48
+ "welcome-description": string;
49
+ "your-name": string;
50
+ "your-email": string;
51
+ "start-chat": string;
52
+ "starting-chat": string;
53
+ "hello-greeting": string;
54
+ };
55
+ export type TranslationKeysType = keyof typeof enLocale;
@@ -0,0 +1,2 @@
1
+ import { TranslatableMessages } from '.';
2
+ export declare const frLocale: TranslatableMessages;
@@ -0,0 +1,65 @@
1
+ import { TranslationKeysType } from './en.locale';
2
+ declare const locales: {
3
+ readonly en: {
4
+ ok: string;
5
+ yes: string;
6
+ no: string;
7
+ agree: string;
8
+ cancel: string;
9
+ "yes-exit": string;
10
+ "yes-reset": string;
11
+ "no-cancel": string;
12
+ "are-you-sure": string;
13
+ recording: string;
14
+ "thank-you": string;
15
+ "sorry-try-again": string;
16
+ "error-occurred": string;
17
+ "please-try-again": string;
18
+ "write-a-message": string;
19
+ "send-message": string;
20
+ connected: string;
21
+ connecting: string;
22
+ reconnecting: string;
23
+ reconnected: string;
24
+ disconnecting: string;
25
+ disconnected: string;
26
+ error: string;
27
+ "persist-session": string;
28
+ settings: string;
29
+ close: string;
30
+ help: string;
31
+ chat: string;
32
+ send: string;
33
+ copy: string;
34
+ copied: string;
35
+ "sound-effects": string;
36
+ language: string;
37
+ select: string;
38
+ agent: string;
39
+ user: string;
40
+ bot: string;
41
+ "reset-conversation-confirm": string;
42
+ "close-widget": string;
43
+ "got-any-questions": string;
44
+ "typical-response-time": string;
45
+ "session-closed-lead": string;
46
+ "create-new-ticket": string;
47
+ exit: string;
48
+ "reset-conversation": string;
49
+ "welcome-title": string;
50
+ "welcome-description": string;
51
+ "your-name": string;
52
+ "your-email": string;
53
+ "start-chat": string;
54
+ "starting-chat": string;
55
+ "hello-greeting": string;
56
+ };
57
+ readonly ar: import('.').TranslatableMessages;
58
+ readonly nl: import('.').TranslatableMessages;
59
+ readonly fr: import('.').TranslatableMessages;
60
+ readonly de: import('.').TranslatableMessages;
61
+ readonly pt: import('.').TranslatableMessages;
62
+ };
63
+ export type LangType = keyof typeof locales;
64
+ export declare function getStr(key: TranslationKeysType, lang: LangType): string;
65
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TranslationKeysType } from './en.locale';
2
+ export * from './helper';
3
+ export type TranslatableMessages = Record<TranslationKeysType, string>;
@@ -0,0 +1,2 @@
1
+ import { TranslatableMessages } from '.';
2
+ export declare const nlLocale: TranslatableMessages;
@@ -0,0 +1,2 @@
1
+ import { TranslatableMessages } from '.';
2
+ export declare const ptLocale: TranslatableMessages;
@@ -0,0 +1,135 @@
1
+ import { default as React } from 'react';
2
+ declare const useChat: () => {
3
+ version: string;
4
+ state: {
5
+ lastUpdated: number | null;
6
+ messages: import('../../core/types').MessageType[];
7
+ keyboard: {
8
+ options: string[];
9
+ } | null;
10
+ };
11
+ session: {
12
+ isSessionClosed: boolean;
13
+ isAssignedToAi: boolean;
14
+ isAssignedToHuman: boolean;
15
+ isPendingHuman: boolean;
16
+ id: string;
17
+ ai_closure_type: import('../../core/types').AIClosureType | null;
18
+ assignee_id: number | null;
19
+ channel: import('../../core/types').SessionChannel;
20
+ status: import('../../core/types').SessionStatus;
21
+ summary: string | null;
22
+ language: string | null;
23
+ last_message: string | null;
24
+ last_message_at: Date | null;
25
+ sentiment: import('../../core/types').SentimentEnum | null;
26
+ assignee?: {
27
+ email: string;
28
+ name: string;
29
+ avatar_url?: string | undefined;
30
+ } | null | undefined;
31
+ } | null;
32
+ unstable__canSend: {
33
+ canSend: boolean;
34
+ reason: string;
35
+ } | {
36
+ canSend: boolean;
37
+ reason?: undefined;
38
+ };
39
+ noMessages: boolean;
40
+ fetchHistoryState: {
41
+ loading: boolean;
42
+ error?: undefined;
43
+ value?: undefined;
44
+ } | {
45
+ loading: false;
46
+ error: Error;
47
+ value?: undefined;
48
+ } | {
49
+ loading: true;
50
+ error?: Error | undefined;
51
+ value?: import('../../core/types').MessageType[] | undefined;
52
+ } | {
53
+ loading: false;
54
+ error?: undefined;
55
+ value: import('../../core/types').MessageType[];
56
+ };
57
+ refreshSessionState: {
58
+ loading: boolean;
59
+ error?: undefined;
60
+ value?: undefined;
61
+ } | {
62
+ loading: false;
63
+ error: Error;
64
+ value?: undefined;
65
+ } | {
66
+ loading: true;
67
+ error?: Error | undefined;
68
+ value?: {
69
+ id: string;
70
+ ai_closure_type: import('../../core/types').AIClosureType | null;
71
+ assignee_id: number | null;
72
+ channel: import('../../core/types').SessionChannel;
73
+ status: import('../../core/types').SessionStatus;
74
+ summary: string | null;
75
+ language: string | null;
76
+ last_message: string | null;
77
+ last_message_at: Date | null;
78
+ sentiment: import('../../core/types').SentimentEnum | null;
79
+ assignee?: {
80
+ email: string;
81
+ name: string;
82
+ avatar_url?: string | undefined;
83
+ } | null | undefined;
84
+ } | undefined;
85
+ } | {
86
+ loading: false;
87
+ error?: undefined;
88
+ value: {
89
+ id: string;
90
+ ai_closure_type: import('../../core/types').AIClosureType | null;
91
+ assignee_id: number | null;
92
+ channel: import('../../core/types').SessionChannel;
93
+ status: import('../../core/types').SessionStatus;
94
+ summary: string | null;
95
+ language: string | null;
96
+ last_message: string | null;
97
+ last_message_at: Date | null;
98
+ sentiment: import('../../core/types').SentimentEnum | null;
99
+ assignee?: {
100
+ email: string;
101
+ name: string;
102
+ avatar_url?: string | undefined;
103
+ } | null | undefined;
104
+ };
105
+ };
106
+ recreateSession: () => void;
107
+ clearSession: () => void;
108
+ sendMessage: ({ content, user, ...data }: import('../hooks/useAbstractChat').SendMessageInput) => Promise<{
109
+ attachments: Array<import('../../core/types').ChatAttachmentType>;
110
+ id: string;
111
+ language: string;
112
+ bot_token: string;
113
+ content: string;
114
+ session_id: string;
115
+ headers: Record<string, string>;
116
+ pathParams: Record<string, string>;
117
+ query_params: Record<string, string>;
118
+ queryParams: Record<string, string>;
119
+ user: {
120
+ external_id?: string;
121
+ name?: string;
122
+ email?: string;
123
+ phone?: string;
124
+ customData?: Record<string, string>;
125
+ avatarUrl?: string;
126
+ };
127
+ } | null>;
128
+ info: React.ReactNode;
129
+ handleKeyboard: (option: string) => void;
130
+ hookState: import('../hooks/useAbstractChat').HookState;
131
+ };
132
+ declare function ChatProvider({ children, }: {
133
+ children: React.ReactNode;
134
+ }): React.JSX.Element;
135
+ export { useChat, ChatProvider };