@aslaluroba/help-center-react 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.
- package/README.md +176 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/shared/Button/button.d.ts +11 -0
- package/dist/components/shared/Button/index.d.ts +1 -0
- package/dist/components/shared/Card/card.d.ts +11 -0
- package/dist/components/shared/Card/index.d.ts +1 -0
- package/dist/components/shared/index.d.ts +2 -0
- package/dist/components/ui/agent-response/agent-response.d.ts +9 -0
- package/dist/components/ui/header.d.ts +6 -0
- package/dist/core/ApiService.d.ts +16 -0
- package/dist/core/SignalRService.d.ts +11 -0
- package/dist/core/api.d.ts +4 -0
- package/dist/core/token-service.d.ts +10 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.esm.js +26076 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +26110 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +19 -0
- package/dist/lib/custom-hooks/useTypewriter.d.ts +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/types.d.ts +111 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +9 -0
- package/dist/ui/chatbot-popup/chat-window-screen/header.d.ts +11 -0
- package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +10 -0
- package/dist/ui/chatbot-popup/error-screen/index.d.ts +7 -0
- package/dist/ui/chatbot-popup/home-screen/card.d.ts +7 -0
- package/dist/ui/chatbot-popup/home-screen/chat-now-card.d.ts +6 -0
- package/dist/ui/chatbot-popup/home-screen/index.d.ts +7 -0
- package/dist/ui/chatbot-popup/loading-screen/index.d.ts +7 -0
- package/dist/ui/chatbot-popup/options-list-screen/expanded-option.d.ts +8 -0
- package/dist/ui/chatbot-popup/options-list-screen/header.d.ts +7 -0
- package/dist/ui/chatbot-popup/options-list-screen/index.d.ts +12 -0
- package/dist/ui/chatbot-popup/options-list-screen/option-card.d.ts +6 -0
- package/dist/ui/floating-message.d.ts +7 -0
- package/dist/ui/help-button.d.ts +6 -0
- package/dist/ui/help-center.d.ts +17 -0
- package/dist/ui/help-popup.d.ts +24 -0
- package/dist/useLocalTranslation.d.ts +5 -0
- package/package.json +86 -0
- package/src/assets/animatedLogo.gif +0 -0
- package/src/assets/icons/arrowRight.svg +3 -0
- package/src/assets/icons/chat.svg +4 -0
- package/src/assets/icons/close.svg +1 -0
- package/src/assets/icons/closeCircle.svg +3 -0
- package/src/assets/icons/closeCirclePrimary.svg +3 -0
- package/src/assets/icons/envelope.svg +3 -0
- package/src/assets/icons/seperator.svg +5 -0
- package/src/assets/icons/threeDots.svg +3 -0
- package/src/assets/icons/user.svg +3 -0
- package/src/assets/logo.svg +5 -0
- package/src/assets/logoColors.svg +5 -0
- package/src/assets/logo_ai.svg +14 -0
- package/src/assets/thinking-logo.svg +3 -0
- package/src/components/index.ts +1 -0
- package/src/components/shared/Button/button.tsx +46 -0
- package/src/components/shared/Button/index.ts +1 -0
- package/src/components/shared/Card/card.tsx +44 -0
- package/src/components/shared/Card/index.ts +1 -0
- package/src/components/shared/index.ts +2 -0
- package/src/components/ui/agent-response/agent-response.tsx +47 -0
- package/src/components/ui/agent-response/doc.md +88 -0
- package/src/components/ui/header.tsx +17 -0
- package/src/components/ui/index.ts +0 -0
- package/src/core/ApiService.ts +118 -0
- package/src/core/SignalRService.ts +83 -0
- package/src/core/api.ts +71 -0
- package/src/core/token-service.ts +35 -0
- package/src/globals.css +484 -0
- package/src/i18n.ts +17 -0
- package/src/index.ts +21 -0
- package/src/lib/config.ts +59 -0
- package/src/lib/custom-hooks/useTypewriter.ts +24 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/types.ts +120 -0
- package/src/lib/utils.ts +6 -0
- package/src/locales/ar.json +13 -0
- package/src/locales/en.json +15 -0
- package/src/styles/tailwind.css +4 -0
- package/src/types/svg.d.ts +5 -0
- package/src/types.d.ts +9 -0
- package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +42 -0
- package/src/ui/chatbot-popup/chat-window-screen/header.tsx +64 -0
- package/src/ui/chatbot-popup/chat-window-screen/index.tsx +103 -0
- package/src/ui/chatbot-popup/error-screen/index.tsx +22 -0
- package/src/ui/chatbot-popup/home-screen/card.tsx +34 -0
- package/src/ui/chatbot-popup/home-screen/chat-now-card.tsx +36 -0
- package/src/ui/chatbot-popup/home-screen/index.tsx +44 -0
- package/src/ui/chatbot-popup/loading-screen/index.tsx +33 -0
- package/src/ui/chatbot-popup/options-list-screen/expanded-option.tsx +38 -0
- package/src/ui/chatbot-popup/options-list-screen/header.tsx +38 -0
- package/src/ui/chatbot-popup/options-list-screen/index.tsx +59 -0
- package/src/ui/chatbot-popup/options-list-screen/option-card.tsx +20 -0
- package/src/ui/floating-message.tsx +25 -0
- package/src/ui/help-button.tsx +22 -0
- package/src/ui/help-center.tsx +303 -0
- package/src/ui/help-popup.tsx +264 -0
- package/src/useLocalTranslation.ts +14 -0
package/src/globals.css
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
.babylai-help-center-container {
|
|
6
|
+
position: fixed;
|
|
7
|
+
bottom: 12px;
|
|
8
|
+
right: 1%;
|
|
9
|
+
z-index: 9999;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@media (min-width: 1820px) {
|
|
14
|
+
|
|
15
|
+
.babylai-help-center-container {
|
|
16
|
+
bottom: 2%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/* Help-popup styles */
|
|
25
|
+
.babylai-help-center-loadingContainer,
|
|
26
|
+
.babylai-help-center-errorContainer {
|
|
27
|
+
position: fixed;
|
|
28
|
+
bottom: 90px;
|
|
29
|
+
right: 20px;
|
|
30
|
+
padding: 16px;
|
|
31
|
+
background: white;
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.babylai-help-center-popup {
|
|
37
|
+
position: fixed;
|
|
38
|
+
bottom: 80px;
|
|
39
|
+
right: 20px;
|
|
40
|
+
width: 360px;
|
|
41
|
+
max-height: 600px;
|
|
42
|
+
background: white;
|
|
43
|
+
border-radius: 12px;
|
|
44
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
z-index: 1000;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.babylai-help-center-header {
|
|
51
|
+
padding: 16px;
|
|
52
|
+
border-bottom: 1px solid #eee;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: space-between;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.babylai-help-center-title {
|
|
59
|
+
margin: 0;
|
|
60
|
+
font-size: 18px;
|
|
61
|
+
font-weight: 500;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.babylai-help-center-backButton {
|
|
65
|
+
background: none;
|
|
66
|
+
border: none;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
padding: 4px;
|
|
69
|
+
color: #666;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.babylai-help-center-content {
|
|
73
|
+
flex: 1;
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
padding: 16px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.babylai-help-center-optionsList {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: 8px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.babylai-help-center-optionButton {
|
|
85
|
+
padding: 12px;
|
|
86
|
+
background: #f5f5f5;
|
|
87
|
+
border: none;
|
|
88
|
+
border-radius: 8px;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
text-align: left;
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.babylai-help-center-optionButton:hover {
|
|
95
|
+
background: #eee;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.babylai-help-center-detailsContent {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 12px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.babylai-help-center-paragraph {
|
|
105
|
+
margin: 0;
|
|
106
|
+
line-height: 1.5;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.babylai-help-center-chatButton {
|
|
110
|
+
margin-top: 16px;
|
|
111
|
+
padding: 12px 24px;
|
|
112
|
+
color: white;
|
|
113
|
+
border: none;
|
|
114
|
+
border-radius: 12px;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
font-weight: 500;
|
|
117
|
+
transition: background-color 0.2s;
|
|
118
|
+
align-self: center;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.babylai-help-center-chatButton:hover {
|
|
122
|
+
opacity: 0.9;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.babylai-help-center-footer {
|
|
126
|
+
display: flex;
|
|
127
|
+
justify-content: space-between;
|
|
128
|
+
align-items: center;
|
|
129
|
+
padding: 10px 20px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.babylai-help-center-endChatButton {
|
|
133
|
+
background-color: #ff4444;
|
|
134
|
+
color: white;
|
|
135
|
+
border: none;
|
|
136
|
+
padding: 5px 15px;
|
|
137
|
+
border-radius: 4px;
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
font-size: 14px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.babylai-help-center-endChatButton:hover {
|
|
143
|
+
background-color: #cc0000;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.babylai-help-center-footerText {
|
|
147
|
+
margin: 0;
|
|
148
|
+
font-size: 12px;
|
|
149
|
+
color: #999;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Update the chat container to have a fixed height and prevent scrolling */
|
|
153
|
+
.babylai-help-center-chatContainer {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
height: 400px; /* Fixed height */
|
|
157
|
+
overflow: hidden; /* Prevent container from scrolling */
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Make only the messages area scrollable */
|
|
161
|
+
.babylai-help-center-chatMessages {
|
|
162
|
+
flex: 1;
|
|
163
|
+
overflow-y: auto; /* Enable scrolling only for messages */
|
|
164
|
+
padding: 16px;
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
gap: 8px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.babylai-help-center-message {
|
|
171
|
+
max-width: 80%;
|
|
172
|
+
padding: 8px 12px;
|
|
173
|
+
border-radius: 12px;
|
|
174
|
+
position: relative;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.babylai-help-center-userMessage {
|
|
178
|
+
align-self: flex-start;
|
|
179
|
+
background-color: rgb(122, 140, 233);
|
|
180
|
+
color: white;
|
|
181
|
+
direction: rtl;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.babylai-help-center-assistantMessage {
|
|
185
|
+
align-self: flex-end;
|
|
186
|
+
background-color: #f1f1f1;
|
|
187
|
+
color: black;
|
|
188
|
+
direction: rtl;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.babylai-help-center-seenIndicator {
|
|
192
|
+
position: absolute;
|
|
193
|
+
bottom: -4px;
|
|
194
|
+
right: 4px;
|
|
195
|
+
font-size: 10px;
|
|
196
|
+
color: #666;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Ensure chat input stays fixed at bottom */
|
|
200
|
+
.babylai-help-center-chatInput {
|
|
201
|
+
display: flex;
|
|
202
|
+
gap: 8px;
|
|
203
|
+
padding: 16px;
|
|
204
|
+
border-top: 1px solid #eee;
|
|
205
|
+
background: white; /* Add background to prevent messages showing through */
|
|
206
|
+
position: relative; /* Ensure it stays above scrolling content */
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.babylai-help-center-chatInput input {
|
|
210
|
+
flex: 1;
|
|
211
|
+
padding: 8px 12px;
|
|
212
|
+
border: 1px solid #ddd;
|
|
213
|
+
border-radius: 20px;
|
|
214
|
+
outline: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.babylai-help-center-chatInput input:focus {
|
|
218
|
+
border-color: rgb(122, 140, 233);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.babylai-help-center-sendButton {
|
|
222
|
+
width: 40px;
|
|
223
|
+
height: 40px;
|
|
224
|
+
border-radius: 50%;
|
|
225
|
+
background: rgb(122, 140, 233);
|
|
226
|
+
border: none;
|
|
227
|
+
color: white;
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
display: flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: center;
|
|
232
|
+
transition: background-color 0.2s;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.babylai-help-center-sendButton:hover {
|
|
236
|
+
background: rgb(122, 140, 233);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.babylai-help-center-sendButton:disabled {
|
|
240
|
+
background: #ccc;
|
|
241
|
+
cursor: not-allowed;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.babylai-help-center-typingIndicator {
|
|
245
|
+
display: flex;
|
|
246
|
+
gap: 4px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.babylai-help-center-typingIndicator span {
|
|
250
|
+
animation: bounce 1s infinite;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.babylai-help-center-typingIndicator span:nth-child(2) {
|
|
254
|
+
animation-delay: 0.2s;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.babylai-help-center-typingIndicator span:nth-child(3) {
|
|
258
|
+
animation-delay: 0.4s;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@keyframes bounce {
|
|
262
|
+
0%,
|
|
263
|
+
100% {
|
|
264
|
+
transform: translateY(0);
|
|
265
|
+
}
|
|
266
|
+
50% {
|
|
267
|
+
transform: translateY(-4px);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.babylai-help-center-errorContainer {
|
|
272
|
+
color: #ff3b30;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.babylai-help-center-dialogOverlay {
|
|
276
|
+
position: fixed;
|
|
277
|
+
top: 0;
|
|
278
|
+
left: 0;
|
|
279
|
+
right: 0;
|
|
280
|
+
bottom: 0;
|
|
281
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
282
|
+
display: flex;
|
|
283
|
+
justify-content: center;
|
|
284
|
+
align-items: center;
|
|
285
|
+
z-index: 1100;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.babylai-help-center-dialog {
|
|
289
|
+
background: white;
|
|
290
|
+
border-radius: 8px;
|
|
291
|
+
padding: 20px;
|
|
292
|
+
width: 90%;
|
|
293
|
+
max-width: 400px;
|
|
294
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.babylai-help-center-dialogHeader {
|
|
298
|
+
display: flex;
|
|
299
|
+
justify-content: space-between;
|
|
300
|
+
align-items: center;
|
|
301
|
+
margin-bottom: 16px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.babylai-help-center-dialogHeader h4 {
|
|
305
|
+
margin: 0;
|
|
306
|
+
font-size: 18px;
|
|
307
|
+
font-weight: 500;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.babylai-help-center-dialogContent {
|
|
311
|
+
margin-bottom: 20px;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.babylai-help-center-dialogContent p {
|
|
315
|
+
margin: 0;
|
|
316
|
+
color: #666;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.babylai-help-center-dialogActions {
|
|
320
|
+
display: flex;
|
|
321
|
+
justify-content: flex-end;
|
|
322
|
+
gap: 12px;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.babylai-help-center-cancelButton,
|
|
326
|
+
.babylai-help-center-confirmButton {
|
|
327
|
+
padding: 8px 16px;
|
|
328
|
+
border-radius: 4px;
|
|
329
|
+
border: none;
|
|
330
|
+
cursor: pointer;
|
|
331
|
+
font-weight: 500;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.babylai-help-center-cancelButton {
|
|
335
|
+
background-color: #f5f5f5;
|
|
336
|
+
color: #666;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.babylai-help-center-confirmButton {
|
|
340
|
+
background-color: rgb(122, 140, 233);
|
|
341
|
+
color: white;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.babylai-help-center-cancelButton:hover {
|
|
345
|
+
background-color: #eee;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.babylai-help-center-confirmButton:hover {
|
|
349
|
+
opacity: 0.9;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.babylai-help-center-spinner {
|
|
353
|
+
width: 24px;
|
|
354
|
+
height: 24px;
|
|
355
|
+
border: 3px solid #f3f3f3;
|
|
356
|
+
border-top: 3px solid #d49cee;
|
|
357
|
+
border-radius: 50%;
|
|
358
|
+
animation: spin 1s linear infinite;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@keyframes spin {
|
|
362
|
+
0% {
|
|
363
|
+
transform: rotate(0deg);
|
|
364
|
+
}
|
|
365
|
+
100% {
|
|
366
|
+
transform: rotate(360deg);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Floating-message styles */
|
|
371
|
+
@keyframes float {
|
|
372
|
+
0%,
|
|
373
|
+
100% {
|
|
374
|
+
transform: translateY(0);
|
|
375
|
+
}
|
|
376
|
+
50% {
|
|
377
|
+
transform: translateY(-10px);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@keyframes pulse {
|
|
382
|
+
0% {
|
|
383
|
+
transform: scale(1);
|
|
384
|
+
}
|
|
385
|
+
50% {
|
|
386
|
+
transform: scale(1.05);
|
|
387
|
+
}
|
|
388
|
+
100% {
|
|
389
|
+
transform: scale(1);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.babylai-help-center-messageBox {
|
|
394
|
+
background-color: rgb(122, 140, 233);
|
|
395
|
+
color: white;
|
|
396
|
+
padding: 12px 16px;
|
|
397
|
+
border-radius: 20px;
|
|
398
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
399
|
+
margin-bottom: 16px;
|
|
400
|
+
max-width: 200px;
|
|
401
|
+
position: relative;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.babylai-help-center-messageBox::after {
|
|
405
|
+
content: '';
|
|
406
|
+
position: absolute;
|
|
407
|
+
bottom: -10px;
|
|
408
|
+
right: 20px;
|
|
409
|
+
width: 0;
|
|
410
|
+
height: 0;
|
|
411
|
+
border-left: 10px solid transparent;
|
|
412
|
+
border-right: 10px solid transparent;
|
|
413
|
+
border-top: 10px solid rgb(122, 140, 233);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.babylai-help-center-text {
|
|
417
|
+
font-size: 12px;
|
|
418
|
+
font-weight: bold;
|
|
419
|
+
margin: 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.babylai-help-center-closeButton {
|
|
423
|
+
position: absolute;
|
|
424
|
+
top: -8px;
|
|
425
|
+
right: -8px;
|
|
426
|
+
width: 20px;
|
|
427
|
+
height: 20px;
|
|
428
|
+
border-radius: 50%;
|
|
429
|
+
background: white;
|
|
430
|
+
border: none;
|
|
431
|
+
cursor: pointer;
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: center;
|
|
434
|
+
justify-content: center;
|
|
435
|
+
color: #000;
|
|
436
|
+
padding: 3px;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.babylai-help-center-closeButton:hover {
|
|
440
|
+
background-color: rgb(102, 117, 195);
|
|
441
|
+
color: white;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.babylai-help-center-arrow {
|
|
445
|
+
height: 32px;
|
|
446
|
+
width: 32px;
|
|
447
|
+
animation: float 2s infinite ease-in-out;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.babylai-help-center-arrowSvg {
|
|
451
|
+
stroke: rgb(122, 140, 233);
|
|
452
|
+
fill: none;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/* Help-button styles */
|
|
456
|
+
.babylai-help-center-helpButton {
|
|
457
|
+
width: 56px;
|
|
458
|
+
height: 56px;
|
|
459
|
+
border-radius: 50%;
|
|
460
|
+
background-color: rgb(122, 140, 233);
|
|
461
|
+
color: white;
|
|
462
|
+
border: none;
|
|
463
|
+
cursor: pointer;
|
|
464
|
+
display: flex;
|
|
465
|
+
align-items: center;
|
|
466
|
+
justify-content: center;
|
|
467
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
468
|
+
transition:
|
|
469
|
+
transform 0.2s,
|
|
470
|
+
background-color 0.2s;
|
|
471
|
+
position: fixed;
|
|
472
|
+
bottom: 20px;
|
|
473
|
+
right: 20px;
|
|
474
|
+
z-index: 1000;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.babylai-help-center-helpButton:hover {
|
|
478
|
+
background-color: rgb(98, 112, 186);
|
|
479
|
+
transform: scale(1.05);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.babylai-help-center-helpButton:active {
|
|
483
|
+
transform: scale(0.95);
|
|
484
|
+
}
|
package/src/i18n.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import i18next, { i18n as I18nType } from 'i18next';
|
|
2
|
+
import en from './locales/en.json';
|
|
3
|
+
import ar from './locales/ar.json';
|
|
4
|
+
|
|
5
|
+
export const createHelpCenterI18n = (lng: string = 'en'): I18nType => {
|
|
6
|
+
const instance = i18next.createInstance();
|
|
7
|
+
instance.init({
|
|
8
|
+
resources: {
|
|
9
|
+
en: { translation: en },
|
|
10
|
+
ar: { translation: ar },
|
|
11
|
+
},
|
|
12
|
+
lng,
|
|
13
|
+
fallbackLng: 'en',
|
|
14
|
+
interpolation: { escapeValue: false },
|
|
15
|
+
});
|
|
16
|
+
return instance;
|
|
17
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { configService } from './lib/config'
|
|
2
|
+
import { HelpCenter } from './ui/help-center'
|
|
3
|
+
|
|
4
|
+
export type HelpCenterConfig = {
|
|
5
|
+
baseUrl: string
|
|
6
|
+
hubUrl?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function initializeHelpCenter(config: HelpCenterConfig) {
|
|
10
|
+
configService.initialize(config)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { HelpCenter }
|
|
14
|
+
|
|
15
|
+
export * from './lib/types'
|
|
16
|
+
export * from './core/ApiService'
|
|
17
|
+
export * from './core/SignalRService'
|
|
18
|
+
// export * from './globals.css'
|
|
19
|
+
|
|
20
|
+
export { TokenService } from './core/token-service'
|
|
21
|
+
export { initializeAPI } from './core/api'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ClientSignalRService } from '../core/SignalRService'
|
|
2
|
+
import { initializeAPI, getValidToken } from '../core/api'
|
|
3
|
+
import { TokenResponse } from './types'
|
|
4
|
+
|
|
5
|
+
type Config = {
|
|
6
|
+
baseUrl: string
|
|
7
|
+
hubUrl?: string
|
|
8
|
+
tenantId?: string
|
|
9
|
+
apiKey?: string
|
|
10
|
+
getToken?: () => Promise<TokenResponse>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ConfigService {
|
|
14
|
+
private static instance: ConfigService
|
|
15
|
+
private config: Config | null = null
|
|
16
|
+
|
|
17
|
+
private constructor() {}
|
|
18
|
+
|
|
19
|
+
static getInstance(): ConfigService {
|
|
20
|
+
if (!ConfigService.instance) {
|
|
21
|
+
ConfigService.instance = new ConfigService()
|
|
22
|
+
}
|
|
23
|
+
return ConfigService.instance
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(config: Config) {
|
|
27
|
+
this.config = {
|
|
28
|
+
baseUrl: config.baseUrl,
|
|
29
|
+
hubUrl: config.hubUrl || config.baseUrl,
|
|
30
|
+
tenantId: config.tenantId,
|
|
31
|
+
apiKey: config.apiKey,
|
|
32
|
+
getToken: config.getToken
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Initialize API with the getToken function directly
|
|
36
|
+
if (!this.config.getToken) {
|
|
37
|
+
throw new Error('getToken function is required in configuration')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
initializeAPI(this.config.baseUrl, this.config.getToken)
|
|
41
|
+
|
|
42
|
+
// Initialize SignalR
|
|
43
|
+
ClientSignalRService.initialize(this.config.hubUrl || this.config.baseUrl)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getConfig(): Config {
|
|
47
|
+
if (!this.config) {
|
|
48
|
+
throw new Error('Help Center not initialized. Call initialize() first with configuration.')
|
|
49
|
+
}
|
|
50
|
+
console.log('🚀 ~ ConfigService ~ getConfig ~ config:', this.config)
|
|
51
|
+
return this.config
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getToken(): Promise<string> {
|
|
55
|
+
return await getValidToken()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const configService = ConfigService.getInstance()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useTypewriter(text: string, speed: number = 20, onType?: () => void) {
|
|
4
|
+
const [displayedText, setDisplayedText] = useState('')
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
let index = 0
|
|
8
|
+
setDisplayedText('')
|
|
9
|
+
|
|
10
|
+
const interval = setInterval(() => {
|
|
11
|
+
setDisplayedText(() => {
|
|
12
|
+
const next = text.slice(0, index + 1)
|
|
13
|
+
index++
|
|
14
|
+
if (onType) onType()
|
|
15
|
+
if (index >= text.length) clearInterval(interval)
|
|
16
|
+
return next
|
|
17
|
+
})
|
|
18
|
+
}, speed)
|
|
19
|
+
|
|
20
|
+
return () => clearInterval(interval)
|
|
21
|
+
}, [text])
|
|
22
|
+
|
|
23
|
+
return displayedText
|
|
24
|
+
}
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils'
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export interface HelpCenterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
2
|
+
helpScreenId: string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface Theme {
|
|
6
|
+
primary: string
|
|
7
|
+
secondary: string
|
|
8
|
+
text: string
|
|
9
|
+
background: string
|
|
10
|
+
error: string
|
|
11
|
+
success: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UserData {
|
|
15
|
+
id: string
|
|
16
|
+
name: string
|
|
17
|
+
email: string
|
|
18
|
+
avatar?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Message {
|
|
22
|
+
id: number
|
|
23
|
+
senderType: number // 1: Customer, 2: Agent, 3: AI
|
|
24
|
+
messageContent: string
|
|
25
|
+
sentAt: Date
|
|
26
|
+
isSeen: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ChatSession {
|
|
30
|
+
id: string
|
|
31
|
+
messages: Message[]
|
|
32
|
+
participants: UserData[]
|
|
33
|
+
status: 'active' | 'closed'
|
|
34
|
+
createdAt: Date
|
|
35
|
+
updatedAt: Date
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ChatSessionData {
|
|
39
|
+
helpScreenId: string
|
|
40
|
+
user: UserData
|
|
41
|
+
initialMessage?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface HelpCenterConfig {
|
|
45
|
+
baseUrl: string
|
|
46
|
+
getToken: () => Promise<{ token: string; expiresIn: number }>
|
|
47
|
+
helpScreenId: string
|
|
48
|
+
user?: UserData
|
|
49
|
+
theme?: Partial<Theme>
|
|
50
|
+
onMessageReceived?: (message: Message) => void
|
|
51
|
+
onSessionClosed?: () => void
|
|
52
|
+
onError?: (error: Error) => void
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface HelpScreenOption {
|
|
56
|
+
id: string
|
|
57
|
+
title: string
|
|
58
|
+
paragraphs?: string[]
|
|
59
|
+
nestedOptions?: HelpScreenOption[]
|
|
60
|
+
chatWithUs?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface HelpScreen {
|
|
64
|
+
id: string
|
|
65
|
+
title: string
|
|
66
|
+
options: HelpScreenOption[]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ApiResponse<T> {
|
|
70
|
+
data: T
|
|
71
|
+
success: boolean
|
|
72
|
+
error?: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TokenResponse {
|
|
76
|
+
token: string
|
|
77
|
+
expiresIn: number
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface HelpScreenData {
|
|
81
|
+
id: string
|
|
82
|
+
tenantId: string
|
|
83
|
+
tenant: {
|
|
84
|
+
id: string
|
|
85
|
+
name: string
|
|
86
|
+
key: string
|
|
87
|
+
}
|
|
88
|
+
title: string
|
|
89
|
+
description: string
|
|
90
|
+
options: Option[]
|
|
91
|
+
chatWithUs: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface Option {
|
|
95
|
+
id: string
|
|
96
|
+
helpScreenId: string
|
|
97
|
+
parentOptionId: string | null
|
|
98
|
+
parentOption: Option | null
|
|
99
|
+
files: any[]
|
|
100
|
+
nestedOptions: Option[]
|
|
101
|
+
title: string
|
|
102
|
+
paragraphs: string[]
|
|
103
|
+
chatWithUs: boolean
|
|
104
|
+
assistantId?: string
|
|
105
|
+
assistant?: {
|
|
106
|
+
id: string
|
|
107
|
+
tenantId: string
|
|
108
|
+
tenant: {
|
|
109
|
+
id: string
|
|
110
|
+
name: string
|
|
111
|
+
key: string
|
|
112
|
+
}
|
|
113
|
+
name: string
|
|
114
|
+
openAIAssistantId: string
|
|
115
|
+
greeting: string
|
|
116
|
+
closing: string
|
|
117
|
+
}
|
|
118
|
+
hasNestedOptions: boolean
|
|
119
|
+
order: number
|
|
120
|
+
}
|