acecoderz-chat-ui 1.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 (62) hide show
  1. package/README.md +309 -0
  2. package/browser/index.ts +15 -0
  3. package/dist/adapters/react/ChatUI.d.ts +32 -0
  4. package/dist/adapters/react/ChatUI.d.ts.map +1 -0
  5. package/dist/adapters/react/ChatUI.js +170 -0
  6. package/dist/adapters/react/index.d.ts +5 -0
  7. package/dist/adapters/react/index.d.ts.map +1 -0
  8. package/dist/adapters/react/index.js +2 -0
  9. package/dist/adapters/react/useChat.d.ts +14 -0
  10. package/dist/adapters/react/useChat.d.ts.map +1 -0
  11. package/dist/adapters/react/useChat.js +64 -0
  12. package/dist/adapters/solid/createChat.d.ts +13 -0
  13. package/dist/adapters/solid/createChat.d.ts.map +1 -0
  14. package/dist/adapters/solid/createChat.js +34 -0
  15. package/dist/adapters/solid/index.d.ts +3 -0
  16. package/dist/adapters/solid/index.d.ts.map +1 -0
  17. package/dist/adapters/solid/index.js +1 -0
  18. package/dist/adapters/vanilla/index.d.ts +31 -0
  19. package/dist/adapters/vanilla/index.d.ts.map +1 -0
  20. package/dist/adapters/vanilla/index.js +346 -0
  21. package/dist/browser/Archive.zip +0 -0
  22. package/dist/browser/cdn-example.html +177 -0
  23. package/dist/browser/chatbot-ui.css +508 -0
  24. package/dist/browser/chatbot-ui.js +878 -0
  25. package/dist/browser/chatbot-ui.js.map +7 -0
  26. package/dist/browser/chatbot-ui.min.js +71 -0
  27. package/dist/browser/chatbot.html +100 -0
  28. package/dist/core/src/ChatEngine.d.ts +30 -0
  29. package/dist/core/src/ChatEngine.d.ts.map +1 -0
  30. package/dist/core/src/ChatEngine.js +357 -0
  31. package/dist/core/src/apiLogger.d.ts +47 -0
  32. package/dist/core/src/apiLogger.d.ts.map +1 -0
  33. package/dist/core/src/apiLogger.js +199 -0
  34. package/dist/core/src/index.d.ts +7 -0
  35. package/dist/core/src/index.d.ts.map +1 -0
  36. package/dist/core/src/index.js +3 -0
  37. package/dist/core/src/types.d.ts +62 -0
  38. package/dist/core/src/types.d.ts.map +1 -0
  39. package/dist/core/src/types.js +1 -0
  40. package/dist/core/src/urlWhitelist.d.ts +19 -0
  41. package/dist/core/src/urlWhitelist.d.ts.map +1 -0
  42. package/dist/core/src/urlWhitelist.js +66 -0
  43. package/dist/src/ChatUI.stories.d.ts +37 -0
  44. package/dist/src/ChatUI.stories.d.ts.map +1 -0
  45. package/dist/src/ChatUI.stories.js +65 -0
  46. package/dist/src/ChatUIThemes.stories.d.ts +28 -0
  47. package/dist/src/ChatUIThemes.stories.d.ts.map +1 -0
  48. package/dist/src/ChatUIThemes.stories.js +109 -0
  49. package/dist/src/ThemeProperties.stories.d.ts +92 -0
  50. package/dist/src/ThemeProperties.stories.d.ts.map +1 -0
  51. package/dist/src/ThemeProperties.stories.js +195 -0
  52. package/dist/src/UseChat.stories.d.ts +21 -0
  53. package/dist/src/UseChat.stories.d.ts.map +1 -0
  54. package/dist/src/UseChat.stories.js +66 -0
  55. package/dist/src/VanillaAdapter.stories.d.ts +39 -0
  56. package/dist/src/VanillaAdapter.stories.d.ts.map +1 -0
  57. package/dist/src/VanillaAdapter.stories.js +78 -0
  58. package/dist/src/index.d.ts +9 -0
  59. package/dist/src/index.d.ts.map +1 -0
  60. package/dist/src/index.js +8 -0
  61. package/package.json +117 -0
  62. package/styles/chat.css +508 -0
@@ -0,0 +1,508 @@
1
+ /* Chat UI Styles with CSS Variables for Theming */
2
+
3
+ .chat-container {
4
+ /* Colors */
5
+ --chat-primary-color: #3b82f6;
6
+ --chat-secondary-color: #64748b;
7
+ --chat-background-color: #ffffff;
8
+ --chat-text-color: #1e293b;
9
+ --chat-user-message-color: #3b82f6;
10
+ --chat-assistant-message-color: #f1f5f9;
11
+ --chat-input-background-color: #f8fafc;
12
+ --chat-input-text-color: #1e293b;
13
+ --chat-error-background-color: #fee2e2;
14
+ --chat-error-text-color: #dc2626;
15
+ --chat-border-color: color-mix(in srgb, var(--chat-secondary-color) 20%, transparent);
16
+
17
+ /* Typography */
18
+ --chat-font-family: system-ui, -apple-system, sans-serif;
19
+ --chat-font-size: 1rem;
20
+ --chat-font-weight: 400;
21
+ --chat-line-height: 1.5;
22
+
23
+ /* Spacing */
24
+ --chat-padding: 1rem;
25
+ --chat-message-gap: 1rem;
26
+ --chat-input-padding: 1rem;
27
+ --chat-message-padding: 0.75rem 1rem;
28
+
29
+ /* Borders & Radius */
30
+ --chat-border-radius: 0.5rem;
31
+ --chat-message-border-radius: var(--chat-border-radius);
32
+ --chat-input-border-radius: var(--chat-border-radius);
33
+ --chat-border-width: 1px;
34
+
35
+ /* Shadows */
36
+ --chat-box-shadow: none;
37
+ --chat-message-box-shadow: 0 1px 2px 0 color-mix(in srgb, var(--chat-secondary-color) 10%, transparent);
38
+ --chat-input-box-shadow: none;
39
+
40
+ /* Sizing */
41
+ --chat-max-height: 600px;
42
+ --chat-max-width: 100%;
43
+ --chat-message-max-width: 70%;
44
+ --chat-avatar-size: 32px;
45
+
46
+ /* Transitions & Animations */
47
+ --chat-transition-duration: 0.2s;
48
+ --chat-animation-duration: 0.3s;
49
+
50
+ /* Scrollbar */
51
+ --chat-scrollbar-width: 8px;
52
+ --chat-scrollbar-color: color-mix(in srgb, var(--chat-secondary-color) 40%, transparent);
53
+ --chat-scrollbar-track-color: color-mix(in srgb, var(--chat-secondary-color) 10%, transparent);
54
+
55
+ font-family: var(--chat-font-family);
56
+ font-size: var(--chat-font-size);
57
+ font-weight: var(--chat-font-weight);
58
+ line-height: var(--chat-line-height);
59
+ background-color: var(--chat-background-color);
60
+ color: var(--chat-text-color);
61
+ border-radius: var(--chat-border-radius);
62
+ border: var(--chat-border-width) solid var(--chat-border-color);
63
+ box-shadow: var(--chat-box-shadow);
64
+ display: flex;
65
+ flex-direction: column;
66
+ height: 100%;
67
+ max-height: var(--chat-max-height);
68
+ max-width: var(--chat-max-width);
69
+ overflow: hidden;
70
+ }
71
+
72
+ .chat-messages-container {
73
+ flex: 1;
74
+ overflow-y: auto;
75
+ padding: var(--chat-padding);
76
+ display: flex;
77
+ flex-direction: column;
78
+ gap: var(--chat-message-gap);
79
+ scroll-behavior: smooth;
80
+ transition: all var(--chat-transition-duration);
81
+ }
82
+
83
+ .chat-messages-container::-webkit-scrollbar {
84
+ width: var(--chat-scrollbar-width);
85
+ }
86
+
87
+ .chat-messages-container::-webkit-scrollbar-track {
88
+ background: var(--chat-scrollbar-track-color);
89
+ border-radius: 4px;
90
+ }
91
+
92
+ .chat-messages-container::-webkit-scrollbar-thumb {
93
+ background: var(--chat-scrollbar-color);
94
+ border-radius: 4px;
95
+ }
96
+
97
+ .chat-messages-container::-webkit-scrollbar-thumb:hover {
98
+ background: color-mix(in srgb, var(--chat-scrollbar-color) 120%, black);
99
+ }
100
+
101
+ .chat-empty-state {
102
+ text-align: center;
103
+ color: var(--chat-secondary-color);
104
+ padding: calc(var(--chat-padding) * 2);
105
+ font-style: italic;
106
+ opacity: 0.7;
107
+ }
108
+
109
+ .chat-message {
110
+ display: flex;
111
+ gap: 0.75rem;
112
+ align-items: flex-start;
113
+ animation: fadeIn var(--chat-animation-duration) ease-in;
114
+ transition: all var(--chat-transition-duration);
115
+ }
116
+
117
+ @keyframes fadeIn {
118
+ from {
119
+ opacity: 0;
120
+ transform: translateY(10px);
121
+ }
122
+ to {
123
+ opacity: 1;
124
+ transform: translateY(0);
125
+ }
126
+ }
127
+
128
+ /* Allow custom animations */
129
+ .chat-message[data-custom-animation] {
130
+ animation: none;
131
+ }
132
+
133
+ .chat-message-user {
134
+ flex-direction: row-reverse;
135
+ }
136
+
137
+ .chat-message-content {
138
+ max-width: var(--chat-message-max-width);
139
+ padding: var(--chat-message-padding);
140
+ border-radius: var(--chat-message-border-radius);
141
+ word-wrap: break-word;
142
+ box-shadow: var(--chat-message-box-shadow);
143
+ transition: all var(--chat-transition-duration);
144
+ }
145
+
146
+ .chat-message-content-user {
147
+ background-color: var(--chat-user-message-color);
148
+ color: #ffffff;
149
+ }
150
+
151
+ .chat-message-content-assistant {
152
+ background-color: var(--chat-assistant-message-color);
153
+ color: var(--chat-text-color);
154
+ }
155
+
156
+ .chat-message-system {
157
+ justify-content: center;
158
+ }
159
+
160
+ .chat-message-content-system {
161
+ background-color: color-mix(in srgb, var(--chat-secondary-color) 10%, transparent);
162
+ color: var(--chat-secondary-color);
163
+ font-style: italic;
164
+ text-align: center;
165
+ }
166
+
167
+ .chat-message-text {
168
+ line-height: 1.5;
169
+ white-space: pre-wrap;
170
+ }
171
+
172
+ .chat-message-timestamp {
173
+ font-size: 0.75rem;
174
+ color: var(--chat-secondary-color);
175
+ margin-top: 0.25rem;
176
+ opacity: 0.7;
177
+ }
178
+
179
+ .chat-message-content-user .chat-message-timestamp {
180
+ color: rgba(255, 255, 255, 0.8);
181
+ }
182
+
183
+ .chat-avatar {
184
+ width: var(--chat-avatar-size);
185
+ height: var(--chat-avatar-size);
186
+ min-width: var(--chat-avatar-size);
187
+ border-radius: 50%;
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: center;
191
+ background-color: var(--chat-secondary-color);
192
+ color: #ffffff;
193
+ font-weight: 600;
194
+ font-size: calc(var(--chat-font-size) * 0.875);
195
+ flex-shrink: 0;
196
+ transition: all var(--chat-transition-duration);
197
+ }
198
+
199
+ .chat-avatar img {
200
+ width: 100%;
201
+ height: 100%;
202
+ border-radius: 50%;
203
+ object-fit: cover;
204
+ }
205
+
206
+ .chat-error {
207
+ padding: var(--chat-message-padding);
208
+ background-color: var(--chat-error-background-color);
209
+ color: var(--chat-error-text-color);
210
+ border-radius: var(--chat-border-radius);
211
+ margin: 0 var(--chat-padding);
212
+ font-size: calc(var(--chat-font-size) * 0.875);
213
+ border: var(--chat-border-width) solid color-mix(in srgb, var(--chat-error-text-color) 30%, transparent);
214
+ display: flex;
215
+ flex-direction: column;
216
+ gap: 0.5rem;
217
+ }
218
+
219
+ .chat-error-message {
220
+ flex: 1;
221
+ }
222
+
223
+ .chat-retry-button {
224
+ padding: 0.375rem 0.75rem;
225
+ background-color: var(--chat-error-text-color);
226
+ color: #ffffff;
227
+ border: none;
228
+ border-radius: calc(var(--chat-border-radius) * 0.75);
229
+ cursor: pointer;
230
+ font-size: calc(var(--chat-font-size) * 0.875);
231
+ font-weight: 500;
232
+ transition: opacity var(--chat-transition-duration);
233
+ align-self: flex-start;
234
+ }
235
+
236
+ .chat-retry-button:hover {
237
+ opacity: 0.9;
238
+ }
239
+
240
+ .chat-actions {
241
+ padding: 0.5rem var(--chat-padding);
242
+ border-top: var(--chat-border-width) solid var(--chat-border-color);
243
+ display: flex;
244
+ justify-content: flex-end;
245
+ background-color: var(--chat-input-background-color);
246
+ }
247
+
248
+ .chat-clear-button {
249
+ padding: 0.375rem 0.75rem;
250
+ background-color: transparent;
251
+ color: var(--chat-secondary-color);
252
+ border: var(--chat-border-width) solid var(--chat-border-color);
253
+ border-radius: calc(var(--chat-border-radius) * 0.75);
254
+ cursor: pointer;
255
+ font-size: calc(var(--chat-font-size) * 0.875);
256
+ font-weight: 500;
257
+ transition: all var(--chat-transition-duration);
258
+ }
259
+
260
+ .chat-clear-button:hover {
261
+ background-color: var(--chat-border-color);
262
+ color: var(--chat-text-color);
263
+ }
264
+
265
+ .chat-message-loading {
266
+ opacity: 0.7;
267
+ }
268
+
269
+ .chat-message-loading .chat-message-text {
270
+ position: relative;
271
+ }
272
+
273
+ .chat-message-loading .chat-message-text::after {
274
+ content: '...';
275
+ animation: dots 1.5s steps(4, end) infinite;
276
+ }
277
+
278
+ @keyframes dots {
279
+ 0%, 20% {
280
+ content: '.';
281
+ }
282
+ 40% {
283
+ content: '..';
284
+ }
285
+ 60%, 100% {
286
+ content: '...';
287
+ }
288
+ }
289
+
290
+ .chat-input-container {
291
+ padding: var(--chat-input-padding);
292
+ border-top: var(--chat-border-width) solid var(--chat-border-color);
293
+ background-color: var(--chat-input-background-color);
294
+ transition: all var(--chat-transition-duration);
295
+ }
296
+
297
+ .chat-input-form {
298
+ display: flex;
299
+ gap: 0.5rem;
300
+ align-items: center;
301
+ }
302
+
303
+ .chat-input {
304
+ flex: 1;
305
+ padding: var(--chat-message-padding);
306
+ border-radius: var(--chat-input-border-radius);
307
+ border: var(--chat-border-width) solid color-mix(in srgb, var(--chat-secondary-color) 30%, transparent);
308
+ background-color: var(--chat-background-color);
309
+ color: var(--chat-input-text-color);
310
+ font-size: var(--chat-font-size);
311
+ font-family: var(--chat-font-family);
312
+ font-weight: var(--chat-font-weight);
313
+ line-height: var(--chat-line-height);
314
+ outline: none;
315
+ box-shadow: var(--chat-input-box-shadow);
316
+ transition: border-color var(--chat-transition-duration), box-shadow var(--chat-transition-duration);
317
+ }
318
+
319
+ .chat-input:focus {
320
+ border-color: var(--chat-primary-color);
321
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-primary-color) 20%, transparent);
322
+ }
323
+
324
+ .chat-input:disabled {
325
+ opacity: 0.6;
326
+ cursor: not-allowed;
327
+ }
328
+
329
+ .chat-send-button {
330
+ padding: 0.625rem 1.25rem;
331
+ border-radius: var(--chat-input-border-radius);
332
+ background-color: var(--chat-primary-color);
333
+ color: #ffffff;
334
+ border: none;
335
+ cursor: pointer;
336
+ font-size: var(--chat-font-size);
337
+ font-family: var(--chat-font-family);
338
+ font-weight: 500;
339
+ transition: background-color var(--chat-transition-duration), transform calc(var(--chat-transition-duration) * 0.5);
340
+ white-space: nowrap;
341
+ min-height: 2.5rem;
342
+ }
343
+
344
+ .chat-send-button:hover:not(:disabled) {
345
+ background-color: color-mix(in srgb, var(--chat-primary-color) 90%, black);
346
+ transform: translateY(-1px);
347
+ }
348
+
349
+ .chat-send-button:active:not(:disabled) {
350
+ transform: translateY(0);
351
+ }
352
+
353
+ .chat-send-button:disabled {
354
+ opacity: 0.6;
355
+ cursor: not-allowed;
356
+ transform: none;
357
+ }
358
+
359
+ /* Responsive design */
360
+ @media (max-width: 640px) {
361
+ .chat-message-content {
362
+ max-width: 85%;
363
+ }
364
+
365
+ .chat-input-form {
366
+ flex-direction: column;
367
+ }
368
+
369
+ .chat-send-button {
370
+ width: 100%;
371
+ }
372
+ }
373
+
374
+ /* Markdown styles */
375
+ .chat-markdown {
376
+ line-height: 1.6;
377
+ }
378
+
379
+ .chat-markdown p {
380
+ margin: 0.5em 0;
381
+ }
382
+
383
+ .chat-markdown p:first-child {
384
+ margin-top: 0;
385
+ }
386
+
387
+ .chat-markdown p:last-child {
388
+ margin-bottom: 0;
389
+ }
390
+
391
+ .chat-markdown h1,
392
+ .chat-markdown h2,
393
+ .chat-markdown h3,
394
+ .chat-markdown h4,
395
+ .chat-markdown h5,
396
+ .chat-markdown h6 {
397
+ margin: 0.75em 0 0.5em 0;
398
+ font-weight: 600;
399
+ line-height: 1.25;
400
+ }
401
+
402
+ .chat-markdown h1:first-child,
403
+ .chat-markdown h2:first-child,
404
+ .chat-markdown h3:first-child,
405
+ .chat-markdown h4:first-child,
406
+ .chat-markdown h5:first-child,
407
+ .chat-markdown h6:first-child {
408
+ margin-top: 0;
409
+ }
410
+
411
+ .chat-markdown h1 {
412
+ font-size: 1.5em;
413
+ }
414
+
415
+ .chat-markdown h2 {
416
+ font-size: 1.3em;
417
+ }
418
+
419
+ .chat-markdown h3 {
420
+ font-size: 1.1em;
421
+ }
422
+
423
+ .chat-markdown ul,
424
+ .chat-markdown ol {
425
+ margin: 0.5em 0;
426
+ padding-left: 1.5em;
427
+ }
428
+
429
+ .chat-markdown li {
430
+ margin: 0.25em 0;
431
+ }
432
+
433
+ .chat-markdown code {
434
+ background-color: color-mix(in srgb, currentColor 10%, transparent);
435
+ padding: 0.125em 0.375em;
436
+ border-radius: 0.25em;
437
+ font-size: 0.9em;
438
+ font-family: 'Courier New', monospace;
439
+ }
440
+
441
+ .chat-markdown pre {
442
+ background-color: color-mix(in srgb, currentColor 8%, transparent);
443
+ padding: 0.75em;
444
+ border-radius: 0.5em;
445
+ overflow-x: auto;
446
+ margin: 0.75em 0;
447
+ }
448
+
449
+ .chat-markdown pre code {
450
+ background-color: transparent;
451
+ padding: 0;
452
+ }
453
+
454
+ .chat-markdown blockquote {
455
+ border-left: 3px solid color-mix(in srgb, currentColor 30%, transparent);
456
+ padding-left: 1em;
457
+ margin: 0.75em 0;
458
+ font-style: italic;
459
+ color: color-mix(in srgb, currentColor 80%, transparent);
460
+ }
461
+
462
+ .chat-markdown a {
463
+ color: var(--chat-primary-color, #007bff);
464
+ text-decoration: underline;
465
+ }
466
+
467
+ .chat-markdown a:hover {
468
+ text-decoration: none;
469
+ }
470
+
471
+ .chat-markdown strong {
472
+ font-weight: 600;
473
+ }
474
+
475
+ .chat-markdown em {
476
+ font-style: italic;
477
+ }
478
+
479
+ .chat-markdown hr {
480
+ border: none;
481
+ border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent);
482
+ margin: 1em 0;
483
+ }
484
+
485
+ .chat-markdown table {
486
+ border-collapse: collapse;
487
+ width: 100%;
488
+ margin: 0.75em 0;
489
+ }
490
+
491
+ .chat-markdown th,
492
+ .chat-markdown td {
493
+ border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
494
+ padding: 0.5em;
495
+ text-align: left;
496
+ }
497
+
498
+ .chat-markdown th {
499
+ background-color: color-mix(in srgb, currentColor 10%, transparent);
500
+ font-weight: 600;
501
+ }
502
+
503
+ /* Allow complete CSS override via data attributes */
504
+ .chat-container[data-chat-ui] {
505
+ /* Users can override everything via CSS specificity */
506
+ /* This selector allows for custom styling via data attributes */
507
+ }
508
+