reachat 2.1.0-alpha.9 → 2.1.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.
Files changed (82) hide show
  1. package/README.md +4 -2
  2. package/dist/AppBar/AppBar.d.ts +1 -1
  3. package/dist/{CSVFileRenderer-CkRKGiCl.js → CSVFileRenderer-DXI8PDqR.js} +14 -15
  4. package/dist/CSVFileRenderer-DXI8PDqR.js.map +1 -0
  5. package/dist/Chat.d.ts +9 -3
  6. package/dist/ChatBubble/ChatBubble.d.ts +1 -1
  7. package/dist/ChatContext.d.ts +4 -2
  8. package/dist/ChatInput/ChatInput.d.ts +23 -13
  9. package/dist/ChatInput/FileInput.d.ts +1 -1
  10. package/dist/ChatInput/MentionList.d.ts +32 -0
  11. package/dist/ChatInput/RichTextInput.d.ts +55 -0
  12. package/dist/ChatInput/index.d.ts +3 -0
  13. package/dist/ChatInput/types.d.ts +104 -0
  14. package/dist/ChatSuggestions/ChatSuggestion.d.ts +9 -0
  15. package/dist/ChatSuggestions/ChatSuggestions.d.ts +22 -0
  16. package/dist/ChatSuggestions/index.d.ts +2 -0
  17. package/dist/{DefaultFileRenderer-C1qZ57tG.js → DefaultFileRenderer-Bi8LNDio.js} +2 -2
  18. package/dist/DefaultFileRenderer-Bi8LNDio.js.map +1 -0
  19. package/dist/ImageFileRenderer-C8tVW3I8.js.map +1 -1
  20. package/dist/Markdown/Markdown.d.ts +4 -3
  21. package/dist/Markdown/Table.d.ts +1 -1
  22. package/dist/Markdown/charts/ChartError.d.ts +21 -0
  23. package/dist/Markdown/charts/ChartPre.d.ts +6 -0
  24. package/dist/Markdown/charts/ChartRenderer.d.ts +13 -0
  25. package/dist/Markdown/charts/chartHelpers.d.ts +40 -0
  26. package/dist/Markdown/charts/chartHelpers.spec.d.ts +1 -0
  27. package/dist/Markdown/charts/index.d.ts +7 -0
  28. package/dist/Markdown/index.d.ts +3 -2
  29. package/dist/Markdown/plugins/index.d.ts +1 -0
  30. package/dist/Markdown/plugins/remarkChart.d.ts +59 -0
  31. package/dist/Markdown/plugins/remarkCve.d.ts +1 -1
  32. package/dist/MessageStatus/MessageStatus.d.ts +44 -0
  33. package/dist/MessageStatus/MessageStatusItem.d.ts +9 -0
  34. package/dist/MessageStatus/StatusIcon.d.ts +17 -0
  35. package/dist/MessageStatus/index.d.ts +3 -0
  36. package/dist/PDFFileRenderer-DQdFS2l6.js +9 -0
  37. package/dist/PDFFileRenderer-DQdFS2l6.js.map +1 -0
  38. package/dist/SessionMessages/SessionEmpty.d.ts +4 -1
  39. package/dist/SessionMessages/SessionMessage/MessageFile/renderers/index.d.ts +1 -1
  40. package/dist/SessionMessages/SessionMessage/MessageFiles.d.ts +1 -1
  41. package/dist/SessionMessages/SessionMessage/MessageSources.d.ts +1 -1
  42. package/dist/SessionMessages/SessionMessage/SessionMessage.d.ts +0 -4
  43. package/dist/SessionMessages/SessionMessage/index.d.ts +2 -2
  44. package/dist/SessionMessages/SessionMessages.d.ts +3 -7
  45. package/dist/SessionMessages/index.d.ts +2 -2
  46. package/dist/SessionsList/index.d.ts +2 -2
  47. package/dist/docs.json +1037 -183
  48. package/dist/index-CBHNcMyR.js +4369 -0
  49. package/dist/index-CBHNcMyR.js.map +1 -0
  50. package/dist/index.css +2129 -6532
  51. package/dist/index.d.ts +8 -7
  52. package/dist/index.js +49 -34
  53. package/dist/index.umd.cjs +3414 -1320
  54. package/dist/index.umd.cjs.map +1 -1
  55. package/dist/stories/Changelog.mdx +1 -1
  56. package/dist/stories/ChartError.stories.tsx +85 -0
  57. package/dist/stories/Charts.stories.tsx +371 -0
  58. package/dist/stories/Chat.stories.tsx +5 -5
  59. package/dist/stories/ChatBubble.stories.tsx +3 -3
  60. package/dist/stories/ChatSuggestions.stories.tsx +541 -0
  61. package/dist/stories/Companion.stories.tsx +6 -6
  62. package/dist/stories/Console.stories.tsx +165 -25
  63. package/dist/stories/EnhancedInput.stories.tsx +322 -0
  64. package/dist/stories/Integration.stories.tsx +2 -2
  65. package/dist/stories/Intro.mdx +1 -1
  66. package/dist/stories/MessageStatus.stories.tsx +314 -0
  67. package/dist/stories/RichTextInput.stories.tsx +198 -0
  68. package/dist/stories/assets/logo.svg +19 -38
  69. package/dist/stories/assets/paperclip.svg +1 -4
  70. package/dist/stories/assets/search.svg +1 -5
  71. package/dist/stories/assets/sparkles.svg +7 -0
  72. package/dist/stories/examples.ts +47 -20
  73. package/dist/theme.d.ts +76 -13
  74. package/dist/types.d.ts +10 -0
  75. package/package.json +69 -66
  76. package/dist/CSVFileRenderer-CkRKGiCl.js.map +0 -1
  77. package/dist/DefaultFileRenderer-C1qZ57tG.js.map +0 -1
  78. package/dist/PDFFileRenderer-BBn2EVrV.js +0 -16
  79. package/dist/PDFFileRenderer-BBn2EVrV.js.map +0 -1
  80. package/dist/index-6CsqxEMx.js +0 -2257
  81. package/dist/index-6CsqxEMx.js.map +0 -1
  82. package/dist/utils/index.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import { Meta, Markdown } from '@storybook/addon-docs/blocks';
1
+ import { Meta, Markdown } from '@storybook/addon-docs';
2
2
  import Readme from "../CHANGELOG.md?raw";
3
3
 
4
4
  <Meta title="Docs/Changelog" />
@@ -0,0 +1,85 @@
1
+ import React from 'react';
2
+ import { Meta } from '@storybook/react';
3
+ import {
4
+ Chat,
5
+ remarkChart,
6
+ chartComponents,
7
+ ChartError
8
+ } from 'reachat';
9
+
10
+ export default {
11
+ title: 'Components/ChartError',
12
+ component: ChartError
13
+ } as Meta;
14
+
15
+ const Wrapper = ({ children }: { children: React.ReactNode }) => (
16
+ <div
17
+ className="dark:bg-gray-950 bg-white"
18
+ style={{
19
+ position: 'absolute',
20
+ top: 0,
21
+ left: 0,
22
+ right: 0,
23
+ bottom: 0,
24
+ padding: 20
25
+ }}
26
+ >
27
+ <Chat
28
+ viewType="chat"
29
+ sessions={[]}
30
+ activeSessionId=""
31
+ remarkPlugins={[remarkChart]}
32
+ markdownComponents={chartComponents}
33
+ >
34
+ <div style={{ maxWidth: 500 }}>{children}</div>
35
+ </Chat>
36
+ </div>
37
+ );
38
+
39
+ export const Default = () => (
40
+ <Wrapper>
41
+ <ChartError
42
+ title="Failed to render chart"
43
+ message="The chart data could not be parsed. Please check the JSON format."
44
+ />
45
+ </Wrapper>
46
+ );
47
+
48
+ export const WithCode = () => (
49
+ <Wrapper>
50
+ <ChartError
51
+ title="Invalid chart configuration"
52
+ message="The 'type' field is missing from the chart configuration."
53
+ code={`{
54
+ "data": [
55
+ { "key": "A", "data": 10 },
56
+ { "key": "B", "data": 20 }
57
+ ]
58
+ }`}
59
+ />
60
+ </Wrapper>
61
+ );
62
+
63
+ export const Warning = () => (
64
+ <Wrapper>
65
+ <ChartError
66
+ variant="warning"
67
+ title="Chart data incomplete"
68
+ message="Some data points are missing values. The chart may not display correctly."
69
+ />
70
+ </Wrapper>
71
+ );
72
+
73
+ export const WarningWithCode = () => (
74
+ <Wrapper>
75
+ <ChartError
76
+ variant="warning"
77
+ title="Unsupported chart type"
78
+ message="The chart type 'scatter' is not supported. Falling back to bar chart."
79
+ code={`{
80
+ "type": "scatter",
81
+ "data": [{ "key": "X", "data": 50 }]
82
+ }`}
83
+ />
84
+ </Wrapper>
85
+ );
@@ -0,0 +1,371 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { subHours } from 'date-fns';
3
+ import {
4
+ Chat,
5
+ Session,
6
+ remarkChart,
7
+ chartComponents,
8
+ SessionsList,
9
+ SessionGroups,
10
+ NewSessionButton,
11
+ SessionMessages,
12
+ ChatInput,
13
+ SessionMessagePanel,
14
+ SessionMessagesHeader
15
+ } from 'reachat';
16
+
17
+ export default {
18
+ title: 'Demos/Charts',
19
+ component: Chat
20
+ } as Meta;
21
+
22
+ const barChartData = {
23
+ type: 'bar',
24
+ data: [
25
+ { key: 'JavaScript', data: 35 },
26
+ { key: 'Python', data: 28 },
27
+ { key: 'TypeScript', data: 22 },
28
+ { key: 'Go', data: 15 },
29
+ { key: 'Rust', data: 10 }
30
+ ],
31
+ width: 450,
32
+ height: 300,
33
+ title: 'Programming Language Popularity'
34
+ };
35
+
36
+ const lineChartData = {
37
+ type: 'line',
38
+ data: [
39
+ { key: 'Jan', data: 100 },
40
+ { key: 'Feb', data: 150 },
41
+ { key: 'Mar', data: 180 },
42
+ { key: 'Apr', data: 220 },
43
+ { key: 'May', data: 280 },
44
+ { key: 'Jun', data: 350 }
45
+ ],
46
+ width: 450,
47
+ height: 250,
48
+ title: 'Monthly Revenue Growth'
49
+ };
50
+
51
+ const pieChartData = {
52
+ type: 'pie',
53
+ data: [
54
+ { key: 'Desktop', data: 45 },
55
+ { key: 'Mobile', data: 35 },
56
+ { key: 'Tablet', data: 15 },
57
+ { key: 'Other', data: 5 }
58
+ ],
59
+ width: 350,
60
+ height: 300,
61
+ title: 'Device Usage Distribution'
62
+ };
63
+
64
+ const areaChartData = {
65
+ type: 'area',
66
+ data: [
67
+ { key: 'Week 1', data: 50 },
68
+ { key: 'Week 2', data: 80 },
69
+ { key: 'Week 3', data: 65 },
70
+ { key: 'Week 4', data: 95 },
71
+ { key: 'Week 5', data: 120 },
72
+ { key: 'Week 6', data: 140 }
73
+ ],
74
+ width: 450,
75
+ height: 250,
76
+ title: 'Weekly User Engagement'
77
+ };
78
+
79
+ const sessionWithCharts: Session[] = [
80
+ {
81
+ id: 'session-charts',
82
+ title: 'Data Analysis with Charts',
83
+ createdAt: subHours(new Date(), 1),
84
+ updatedAt: new Date(),
85
+ conversations: [
86
+ {
87
+ id: 'conversation-1',
88
+ question: 'Can you show me the programming language popularity data as a bar chart?',
89
+ response: `Sure! Here's a bar chart showing the popularity of programming languages based on recent survey data:
90
+
91
+ \`\`\`chart
92
+ ${JSON.stringify(barChartData, null, 2)}
93
+ \`\`\`
94
+
95
+ As you can see, JavaScript leads the pack with 35% popularity, followed by Python at 28%. TypeScript has been growing rapidly and now sits at 22%.`,
96
+ createdAt: subHours(new Date(), 1)
97
+ },
98
+ {
99
+ id: 'conversation-2',
100
+ question: 'What about the monthly revenue growth? Can you visualize that?',
101
+ response: `Absolutely! Here's a line chart showing the monthly revenue growth for the first half of the year:
102
+
103
+ \`\`\`chart
104
+ ${JSON.stringify(lineChartData, null, 2)}
105
+ \`\`\`
106
+
107
+ The trend shows consistent growth, with revenue increasing from $100K in January to $350K in June - a 250% increase over 6 months!`,
108
+ createdAt: subHours(new Date(), 0.5)
109
+ },
110
+ {
111
+ id: 'conversation-3',
112
+ question: 'How about device usage? A pie chart would be great for that.',
113
+ response: `Great choice! Pie charts are perfect for showing distribution. Here's the device usage breakdown:
114
+
115
+ \`\`\`chart
116
+ ${JSON.stringify(pieChartData, null, 2)}
117
+ \`\`\`
118
+
119
+ Desktop still dominates at 45%, but mobile is catching up fast at 35%. Tablet usage is at 15%.`,
120
+ createdAt: new Date()
121
+ }
122
+ ]
123
+ }
124
+ ];
125
+
126
+ const sessionWithMultipleCharts: Session[] = [
127
+ {
128
+ id: 'session-multi-charts',
129
+ title: 'Quarterly Report',
130
+ createdAt: subHours(new Date(), 2),
131
+ updatedAt: new Date(),
132
+ conversations: [
133
+ {
134
+ id: 'conversation-1',
135
+ question: 'Can you give me a comprehensive analysis with multiple charts?',
136
+ response: `Of course! Let me present the quarterly analysis with multiple visualizations.
137
+
138
+ ## Revenue Trend
139
+
140
+ \`\`\`chart
141
+ ${JSON.stringify(lineChartData, null, 2)}
142
+ \`\`\`
143
+
144
+ ## User Engagement
145
+
146
+ \`\`\`chart
147
+ ${JSON.stringify(areaChartData, null, 2)}
148
+ \`\`\`
149
+
150
+ ## Market Share by Device
151
+
152
+ \`\`\`chart
153
+ ${JSON.stringify(pieChartData, null, 2)}
154
+ \`\`\`
155
+
156
+ ### Key Takeaways:
157
+ 1. **Revenue** has grown 250% over 6 months
158
+ 2. **User engagement** shows steady weekly increases
159
+ 3. **Mobile adoption** is approaching desktop usage levels`,
160
+ createdAt: new Date()
161
+ }
162
+ ]
163
+ }
164
+ ];
165
+
166
+ export const BarChartExample = () => {
167
+ return (
168
+ <div
169
+ className="dark:bg-gray-950 bg-white"
170
+ style={{
171
+ position: 'absolute',
172
+ top: 0,
173
+ left: 0,
174
+ right: 0,
175
+ bottom: 0,
176
+ padding: 20,
177
+ margin: 20,
178
+ borderRadius: 5
179
+ }}
180
+ >
181
+ <Chat
182
+ viewType="console"
183
+ sessions={sessionWithCharts}
184
+ activeSessionId="session-charts"
185
+ remarkPlugins={[remarkChart]}
186
+ markdownComponents={chartComponents}
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
+ export const MultipleCharts = () => {
203
+ return (
204
+ <div
205
+ className="dark:bg-gray-950 bg-white"
206
+ style={{
207
+ position: 'absolute',
208
+ top: 0,
209
+ left: 0,
210
+ right: 0,
211
+ bottom: 0,
212
+ padding: 20,
213
+ margin: 20,
214
+ borderRadius: 5
215
+ }}
216
+ >
217
+ <Chat
218
+ viewType="console"
219
+ sessions={sessionWithMultipleCharts}
220
+ activeSessionId="session-multi-charts"
221
+ remarkPlugins={[remarkChart]}
222
+ markdownComponents={chartComponents}
223
+ >
224
+ <SessionsList>
225
+ <NewSessionButton />
226
+ <SessionGroups />
227
+ </SessionsList>
228
+ <SessionMessagePanel>
229
+ <SessionMessagesHeader />
230
+ <SessionMessages />
231
+ <ChatInput />
232
+ </SessionMessagePanel>
233
+ </Chat>
234
+ </div>
235
+ );
236
+ };
237
+
238
+ export const AllChartTypes = () => {
239
+ const sparklineData = {
240
+ type: 'sparkline',
241
+ data: [
242
+ { key: '1', data: 10 },
243
+ { key: '2', data: 25 },
244
+ { key: '3', data: 15 },
245
+ { key: '4', data: 35 },
246
+ { key: '5', data: 30 },
247
+ { key: '6', data: 45 },
248
+ { key: '7', data: 40 }
249
+ ],
250
+ width: 200,
251
+ height: 50
252
+ };
253
+
254
+ const sessionAllCharts: Session[] = [
255
+ {
256
+ id: 'session-all-charts',
257
+ title: 'Chart Types Showcase',
258
+ createdAt: subHours(new Date(), 1),
259
+ updatedAt: new Date(),
260
+ conversations: [
261
+ {
262
+ id: 'conversation-1',
263
+ question: 'Show me all the different chart types available.',
264
+ response: `Here's a showcase of all available chart types:
265
+
266
+ ## Bar Chart
267
+ \`\`\`chart
268
+ ${JSON.stringify(barChartData, null, 2)}
269
+ \`\`\`
270
+
271
+ ## Line Chart
272
+ \`\`\`chart
273
+ ${JSON.stringify(lineChartData, null, 2)}
274
+ \`\`\`
275
+
276
+ ## Area Chart
277
+ \`\`\`chart
278
+ ${JSON.stringify(areaChartData, null, 2)}
279
+ \`\`\`
280
+
281
+ ## Pie Chart
282
+ \`\`\`chart
283
+ ${JSON.stringify(pieChartData, null, 2)}
284
+ \`\`\`
285
+
286
+ ## Sparkline (inline mini-chart)
287
+ \`\`\`chart
288
+ ${JSON.stringify(sparklineData, null, 2)}
289
+ \`\`\`
290
+
291
+ Each chart type is optimized for different use cases:
292
+ - **Bar charts** for comparisons
293
+ - **Line charts** for trends over time
294
+ - **Area charts** for cumulative data
295
+ - **Pie charts** for proportions
296
+ - **Sparklines** for compact inline visualizations`,
297
+ createdAt: new Date()
298
+ }
299
+ ]
300
+ }
301
+ ];
302
+
303
+ return (
304
+ <div
305
+ className="dark:bg-gray-950 bg-white"
306
+ style={{
307
+ position: 'absolute',
308
+ top: 0,
309
+ left: 0,
310
+ right: 0,
311
+ bottom: 0,
312
+ padding: 20,
313
+ margin: 20,
314
+ borderRadius: 5
315
+ }}
316
+ >
317
+ <Chat
318
+ viewType="console"
319
+ sessions={sessionAllCharts}
320
+ activeSessionId="session-all-charts"
321
+ remarkPlugins={[remarkChart]}
322
+ markdownComponents={chartComponents}
323
+ >
324
+ <SessionsList>
325
+ <NewSessionButton />
326
+ <SessionGroups />
327
+ </SessionsList>
328
+ <SessionMessagePanel>
329
+ <SessionMessagesHeader />
330
+ <SessionMessages />
331
+ <ChatInput />
332
+ </SessionMessagePanel>
333
+ </Chat>
334
+ </div>
335
+ );
336
+ };
337
+
338
+ export const ChatViewWithCharts = () => {
339
+ return (
340
+ <div
341
+ className="dark:bg-gray-950 bg-white"
342
+ style={{
343
+ position: 'absolute',
344
+ top: 0,
345
+ left: 0,
346
+ right: 0,
347
+ bottom: 0,
348
+ padding: 20,
349
+ margin: 20,
350
+ borderRadius: 5,
351
+ maxWidth: 800,
352
+ marginLeft: 'auto',
353
+ marginRight: 'auto'
354
+ }}
355
+ >
356
+ <Chat
357
+ viewType="chat"
358
+ sessions={sessionWithCharts}
359
+ activeSessionId="session-charts"
360
+ remarkPlugins={[remarkChart]}
361
+ markdownComponents={chartComponents}
362
+ >
363
+ <SessionMessagePanel>
364
+ <SessionMessagesHeader />
365
+ <SessionMessages />
366
+ <ChatInput />
367
+ </SessionMessagePanel>
368
+ </Chat>
369
+ </div>
370
+ );
371
+ };
@@ -36,7 +36,7 @@ export const Compact = () => {
36
36
 
37
37
  return (
38
38
  <div
39
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
39
+ className="dark:bg-gray-950 bg-white"
40
40
  style={{
41
41
  width: 350,
42
42
  height: 500,
@@ -84,7 +84,7 @@ export const FullScreen = () => {
84
84
 
85
85
  return (
86
86
  <div
87
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
87
+ className="dark:bg-gray-950 bg-white"
88
88
  style={{
89
89
  position: 'absolute',
90
90
  top: 0,
@@ -132,7 +132,7 @@ export const Empty = () => {
132
132
 
133
133
  return (
134
134
  <div
135
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
135
+ className="dark:bg-gray-950 bg-white"
136
136
  style={{
137
137
  width: 350,
138
138
  height: 500,
@@ -167,7 +167,7 @@ export const Empty = () => {
167
167
  <div className="flex flex-col gap-2 items-center justify-center h-full">
168
168
  <Placeholder className="h-[50%] block dark:hidden max-w-[100%]" />
169
169
  <PlaceholderDark className="h-[50%] hidden dark:block max-w-[100%]" />
170
- <p className="text-(--content-text-neutral-2) max-w-[400px] text-center">
170
+ <p className="text-gray-500 max-w-[400px] text-center">
171
171
  Welcome to Reachat, a UI library for effortlessly building and
172
172
  customizing chat experiences with Tailwind.
173
173
  </p>
@@ -201,7 +201,7 @@ export const WithAppBar = () => {
201
201
 
202
202
  return (
203
203
  <div
204
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
204
+ className="dark:bg-gray-950 bg-white"
205
205
  style={{
206
206
  width: 800,
207
207
  height: 600,
@@ -81,7 +81,7 @@ const ChatSample: FC = () => {
81
81
 
82
82
  return (
83
83
  <div
84
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
84
+ className="dark:bg-gray-950 bg-white"
85
85
  style={{
86
86
  width: 350,
87
87
  height: 500,
@@ -158,7 +158,7 @@ export const WithChildren: Story = {
158
158
  <div className="fixed left-5 bottom-5">
159
159
  <ChatBubble {...args}>
160
160
  <div
161
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
161
+ className="dark:bg-gray-950 bg-white"
162
162
  style={{
163
163
  width: 350,
164
164
  height: 500,
@@ -219,7 +219,7 @@ export const WithChildrenPortal: Story = {
219
219
  <p className="text-gray-600">The ChatBubble will portal here!</p>
220
220
  <ChatBubble {...args} className="absolute left-5 bottom-5">
221
221
  <div
222
- className="dark:bg-(--color-background-basic-black) bg-(--color-background-basic-white)"
222
+ className="dark:bg-gray-950 bg-white"
223
223
  style={{
224
224
  width: 350,
225
225
  height: 500,