reachat 2.0.0 → 2.0.2

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 (31) hide show
  1. package/dist/{CSVFileRenderer-C95MrG0M.js → CSVFileRenderer-fklKR5lg.js} +2 -2
  2. package/dist/{CSVFileRenderer-C95MrG0M.js.map → CSVFileRenderer-fklKR5lg.js.map} +1 -1
  3. package/dist/ChatBubble/ChatBubble.d.ts +7 -11
  4. package/dist/{DefaultFileRenderer-Chpp-Qiu.js → DefaultFileRenderer-BQ9xzbrH.js} +2 -2
  5. package/dist/{DefaultFileRenderer-Chpp-Qiu.js.map → DefaultFileRenderer-BQ9xzbrH.js.map} +1 -1
  6. package/dist/docs.json +7 -26
  7. package/dist/{index-B1krf7tH.js → index-D7d92jbn.js} +36 -136
  8. package/dist/index-D7d92jbn.js.map +1 -0
  9. package/dist/index.css +28 -21
  10. package/dist/index.js +1 -1
  11. package/dist/index.umd.cjs +33 -133
  12. package/dist/index.umd.cjs.map +1 -1
  13. package/dist/stories/Changelog.mdx +8 -0
  14. package/dist/stories/Chat.stories.tsx +265 -0
  15. package/dist/stories/ChatBubble.stories.tsx +267 -0
  16. package/dist/stories/Companion.stories.tsx +435 -0
  17. package/dist/stories/Console.stories.tsx +1154 -0
  18. package/dist/stories/Integration.stories.tsx +312 -0
  19. package/dist/stories/Intro.mdx +41 -0
  20. package/dist/stories/Support.mdx +9 -0
  21. package/dist/stories/assets/chat-voice-fill.svg +5 -0
  22. package/dist/stories/assets/close-fill.svg +5 -0
  23. package/dist/stories/assets/logo.svg +21 -0
  24. package/dist/stories/assets/menu.svg +1 -0
  25. package/dist/stories/assets/paperclip.svg +1 -0
  26. package/dist/stories/assets/placeholder-dark.svg +500 -0
  27. package/dist/stories/assets/placeholder.svg +258 -0
  28. package/dist/stories/assets/search.svg +1 -0
  29. package/dist/stories/examples.ts +267 -0
  30. package/package.json +8 -3
  31. package/dist/index-B1krf7tH.js.map +0 -1
@@ -0,0 +1,435 @@
1
+ import { Meta } from '@storybook/react';
2
+ import {
3
+ Chat,
4
+ SessionsList,
5
+ NewSessionButton,
6
+ SessionMessages,
7
+ SessionGroups,
8
+ ChatInput,
9
+ SessionMessagePanel,
10
+ SessionMessagesHeader,
11
+ Session,
12
+ AppBar,
13
+ SessionListItem
14
+ } from 'reachat';
15
+ import {
16
+ fakeSessions,
17
+ sessionWithSources,
18
+ sessionsWithFiles,
19
+ chatTemplates
20
+ } from './examples';
21
+ import { useState, memo, useCallback } from 'react';
22
+ import { IconButton } from 'reablocks';
23
+
24
+ import Placeholder from './assets/placeholder.svg?react';
25
+ import PlaceholderDark from './assets/placeholder-dark.svg?react';
26
+ import ReachatLogo from './assets/logo.svg?react';
27
+ import IconSearch from './assets/search.svg?react';
28
+ import IconClose from './assets/close-fill.svg?react';
29
+
30
+ export default {
31
+ title: 'Demos/Companion',
32
+ component: Chat
33
+ } as Meta;
34
+
35
+ export const Basic = () => {
36
+ const [activeId, setActiveId] = useState<string>();
37
+ const [sessions, setSessions] = useState<Session[]>([
38
+ ...fakeSessions,
39
+ ...sessionsWithFiles,
40
+ ...sessionWithSources
41
+ ]);
42
+ return (
43
+ <div
44
+ className="dark:bg-gray-950 bg-white"
45
+ style={{
46
+ width: 350,
47
+ height: 500,
48
+ padding: 20,
49
+ borderRadius: 5
50
+ }}
51
+ >
52
+ <Chat
53
+ viewType="companion"
54
+ sessions={sessions}
55
+ activeSessionId={activeId}
56
+ onNewSession={() => {
57
+ const newId = (sessions.length + 1).toLocaleString();
58
+ setSessions([
59
+ ...sessions,
60
+ {
61
+ id: newId,
62
+ title: `New Session #${newId}`,
63
+ createdAt: new Date(),
64
+ updatedAt: new Date(),
65
+ conversations: []
66
+ }
67
+ ]);
68
+ setActiveId(newId);
69
+ }}
70
+ onSelectSession={setActiveId}
71
+ onDeleteSession={() => alert('delete!')}
72
+ >
73
+ <SessionsList>
74
+ <NewSessionButton />
75
+ <SessionGroups />
76
+ </SessionsList>
77
+ <SessionMessagePanel>
78
+ <SessionMessagesHeader />
79
+ <SessionMessages />
80
+ <ChatInput />
81
+ </SessionMessagePanel>
82
+ </Chat>
83
+ </div>
84
+ );
85
+ };
86
+
87
+ export const Empty = () => {
88
+ return (
89
+ <div
90
+ className="dark:bg-gray-950 bg-white"
91
+ style={{
92
+ width: 350,
93
+ height: 500,
94
+ padding: 20,
95
+ borderRadius: 5
96
+ }}
97
+ >
98
+ <Chat
99
+ sessions={[]}
100
+ viewType="companion"
101
+ onDeleteSession={() => alert('delete!')}
102
+ >
103
+ <SessionsList>
104
+ <NewSessionButton />
105
+ <SessionGroups />
106
+ </SessionsList>
107
+ <div className="flex-1 h-full flex flex-col">
108
+ <SessionMessages
109
+ newSessionContent={
110
+ <div className="flex flex-col gap-2 items-center justify-center h-full">
111
+ <Placeholder className="h-[50%] block dark:hidden" />
112
+ <PlaceholderDark className="h-[50%] hidden dark:block" />
113
+ <p className="text-gray-500 max-w-[400px] text-center">
114
+ Welcome to Reachat, a UI library for effortlessly building and
115
+ customizing chat experiences with Tailwind.
116
+ </p>
117
+ </div>
118
+ }
119
+ />
120
+ </div>
121
+ <ChatInput />
122
+ </Chat>
123
+ </div>
124
+ );
125
+ };
126
+
127
+ export const WithAppBar = () => {
128
+ const [activeId, setActiveId] = useState<string>();
129
+ const [sessions, setSessions] = useState<Session[]>([
130
+ ...fakeSessions,
131
+ ...sessionsWithFiles,
132
+ ...sessionWithSources
133
+ ]);
134
+ return (
135
+ <div
136
+ className="dark:bg-gray-950 bg-white"
137
+ style={{
138
+ width: 350,
139
+ height: 500,
140
+ padding: 20,
141
+ borderRadius: 5
142
+ }}
143
+ >
144
+ <Chat
145
+ viewType="companion"
146
+ sessions={sessions}
147
+ activeSessionId={activeId}
148
+ onNewSession={() => {
149
+ const newId = (sessions.length + 1).toLocaleString();
150
+ setSessions([
151
+ ...sessions,
152
+ {
153
+ id: newId,
154
+ title: `New Session #${newId}`,
155
+ createdAt: new Date(),
156
+ updatedAt: new Date(),
157
+ conversations: []
158
+ }
159
+ ]);
160
+ setActiveId(newId);
161
+ }}
162
+ onSelectSession={setActiveId}
163
+ onDeleteSession={() => alert('delete!')}
164
+ >
165
+ <AppBar
166
+ content={
167
+ <div className="flex items-center justify-between w-full">
168
+ <div className="flex-shrink-0">
169
+ <IconButton size="small" variant="outline" className='rounded-full p-3'>
170
+ <IconSearch className='w-4 h-4' />
171
+ </IconButton>
172
+ </div>
173
+ <div className="flex-grow flex justify-center items-center">
174
+ <ReachatLogo className="h-6 w-auto" />
175
+ </div>
176
+ <div className="flex-shrink-0">
177
+ <IconButton
178
+ variant="text"
179
+ size="small"
180
+ className='rounded-full p-3'
181
+ >
182
+ <IconClose className='w-4 h-4' />
183
+ </IconButton>
184
+ </div>
185
+ </div>
186
+ }
187
+ />
188
+ <SessionsList>
189
+ <NewSessionButton />
190
+ <SessionGroups />
191
+ </SessionsList>
192
+ <SessionMessagePanel>
193
+ <SessionMessagesHeader />
194
+ <SessionMessages />
195
+ <ChatInput />
196
+ </SessionMessagePanel>
197
+ </Chat>
198
+ </div>
199
+ );
200
+ };
201
+
202
+ const AppBarContent = memo(({ onClose }: { onClose?: () => void }) => (
203
+ <div className="flex items-center justify-between w-full">
204
+ <div className="flex-shrink-0">
205
+ <IconButton size="small" variant="outline" className='rounded-full p-3'>
206
+ <IconSearch className="size-4" />
207
+ </IconButton>
208
+ </div>
209
+ <div className="flex-grow flex justify-center items-center">
210
+ <ReachatLogo className="h-6 w-auto" />
211
+ </div>
212
+ <div className="flex-shrink-0">
213
+ <IconButton
214
+ variant="text"
215
+ size="small"
216
+ className='rounded-full p-3'
217
+ onClick={onClose}
218
+ >
219
+ <IconClose className='w-4 h-4' />
220
+ </IconButton>
221
+ </div>
222
+ </div>
223
+ ));
224
+
225
+ export const TemplatesView = () => {
226
+ const [activeId, setActiveId] = useState<string>();
227
+ const [sessions, setSessions] = useState<Session[]>(
228
+ chatTemplates.map(template => ({
229
+ id: template.id,
230
+ title: template.title,
231
+ createdAt: new Date(),
232
+ updatedAt: new Date(),
233
+ conversations: [
234
+ {
235
+ id: '1',
236
+ question: template.message,
237
+ createdAt: new Date()
238
+ }
239
+ ]
240
+ }))
241
+ );
242
+
243
+ return (
244
+ <div
245
+ className="dark:bg-gray-950 bg-white"
246
+ style={{
247
+ width: 350,
248
+ height: 500,
249
+ padding: 20,
250
+ borderRadius: 5
251
+ }}
252
+ >
253
+ <Chat
254
+ viewType="companion"
255
+ sessions={sessions}
256
+ activeSessionId={activeId}
257
+ onSelectSession={setActiveId}
258
+ onDeleteSession={() => alert('delete!')}
259
+ >
260
+ <div className="flex flex-col h-full">
261
+ <div className="flex-1 overflow-y-auto">
262
+ <SessionsList>
263
+ <SessionGroups>
264
+ {(groups) => (
265
+ <>
266
+ {groups.map(({ sessions }) => (
267
+ sessions.map(session => (
268
+ <SessionListItem key={session.id} session={session} deletable={false} />
269
+ ))
270
+ ))}
271
+ </>
272
+ )}
273
+ </SessionGroups>
274
+ </SessionsList>
275
+ </div>
276
+ {!activeId && <ChatInput />}
277
+ {activeId && (
278
+ <SessionMessagePanel>
279
+ <SessionMessagesHeader />
280
+ <SessionMessages />
281
+ <ChatInput />
282
+ </SessionMessagePanel>
283
+ )}
284
+ </div>
285
+ </Chat>
286
+ </div>
287
+ );
288
+ };
289
+
290
+ export const TemplatesViewWithTitle = () => {
291
+ const [activeId, setActiveId] = useState<string>();
292
+ const [sessions, setSessions] = useState<Session[]>(
293
+ chatTemplates.map(template => ({
294
+ id: template.id,
295
+ title: template.title,
296
+ createdAt: new Date(),
297
+ updatedAt: new Date(),
298
+ conversations: [
299
+ {
300
+ id: '1',
301
+ question: template.message,
302
+ createdAt: new Date()
303
+ }
304
+ ]
305
+ }))
306
+ );
307
+
308
+ return (
309
+ <div
310
+ className="dark:bg-gray-950 bg-white"
311
+ style={{
312
+ width: 350,
313
+ height: 500,
314
+ padding: 20,
315
+ borderRadius: 5
316
+ }}
317
+ >
318
+ <Chat
319
+ viewType="companion"
320
+ sessions={sessions}
321
+ activeSessionId={activeId}
322
+ onSelectSession={setActiveId}
323
+ onDeleteSession={() => alert('delete!')}
324
+ >
325
+ <div className="dark:text-white text-gray-500 w-full h-full overflow-hidden flex flex-col">
326
+ <div className="flex-1 overflow-y-auto">
327
+ <div className="flex flex-col gap-2 items-center justify-center py-8">
328
+ <p className="text-gray-500 max-w-[400px] text-center mb-4">
329
+ Welcome to Reachat, a UI library for effortlessly building and
330
+ customizing chat experiences with Tailwind.
331
+ </p>
332
+ </div>
333
+ <SessionsList>
334
+ <SessionGroups>
335
+ {(groups) => (
336
+ <>
337
+ {groups.map(({ sessions }) => (
338
+ sessions.map(session => (
339
+ <SessionListItem key={session.id} session={session} deletable={false} />
340
+ ))
341
+ ))}
342
+ </>
343
+ )}
344
+ </SessionGroups>
345
+ </SessionsList>
346
+ </div>
347
+ {!activeId && <ChatInput />}
348
+ {activeId && (
349
+ <SessionMessagePanel>
350
+ <SessionMessagesHeader />
351
+ <SessionMessages />
352
+ <ChatInput />
353
+ </SessionMessagePanel>
354
+ )}
355
+ </div>
356
+ </Chat>
357
+ </div>
358
+ );
359
+ };
360
+
361
+ export const TemplatesViewWithAppBar = () => {
362
+ const [activeId, setActiveId] = useState<string>();
363
+ const [sessions, setSessions] = useState<Session[]>(
364
+ chatTemplates.map(template => ({
365
+ id: template.id,
366
+ title: template.title,
367
+ createdAt: new Date(),
368
+ updatedAt: new Date(),
369
+ conversations: [
370
+ {
371
+ id: '1',
372
+ question: template.message,
373
+ createdAt: new Date()
374
+ }
375
+ ]
376
+ }))
377
+ );
378
+
379
+ const handleClose = useCallback(() => {
380
+ setActiveId(undefined);
381
+ }, []);
382
+
383
+ return (
384
+ <div
385
+ className="dark:bg-gray-950 bg-white flex flex-col"
386
+ style={{
387
+ width: 350,
388
+ height: 500,
389
+ borderRadius: 5,
390
+ overflow: 'hidden'
391
+ }}
392
+ >
393
+ <AppBar content={<AppBarContent onClose={handleClose} />} />
394
+ <div className="flex-1 p-5">
395
+ <Chat
396
+ viewType="companion"
397
+ sessions={sessions}
398
+ activeSessionId={activeId}
399
+ onSelectSession={setActiveId}
400
+ onDeleteSession={() => alert('delete!')}
401
+ >
402
+ <div className="dark:text-white text-gray-500 w-full h-full overflow-hidden flex flex-col">
403
+ <div className="flex-1 overflow-y-auto">
404
+ <div className="flex flex-col gap-2 items-center justify-center pb-2">
405
+ <p className="text-gray-500 max-w-[400px] text-center mb-4">
406
+ Welcome to Reachat, a UI library for effortlessly building and
407
+ customizing chat experiences with Tailwind.
408
+ </p>
409
+ </div>
410
+ <SessionsList>
411
+ <SessionGroups>
412
+ {(groups) => (
413
+ <>
414
+ {groups.map(({ sessions }) => (
415
+ sessions.map(session => (
416
+ <SessionListItem key={session.id} session={session} deletable={false} />
417
+ ))
418
+ ))}
419
+ </>
420
+ )}
421
+ </SessionGroups>
422
+ </SessionsList>
423
+ </div>
424
+ {!activeId && <ChatInput />}
425
+ <SessionMessagePanel allowBack={false}>
426
+ <SessionMessagesHeader />
427
+ <SessionMessages />
428
+ <ChatInput />
429
+ </SessionMessagePanel>
430
+ </div>
431
+ </Chat>
432
+ </div>
433
+ </div>
434
+ );
435
+ };