reachat 2.2.0 → 3.1.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 (46) hide show
  1. package/dist/{CSVFileRenderer-BOdL4Jte.js → CSVFileRenderer-C2E4Xnkz.js} +2 -2
  2. package/dist/{CSVFileRenderer-BOdL4Jte.js.map → CSVFileRenderer-C2E4Xnkz.js.map} +1 -1
  3. package/dist/Chat.d.ts +12 -0
  4. package/dist/{Markdown/charts/ChartError.d.ts → ComponentCatalog/ComponentError.d.ts} +2 -2
  5. package/dist/ComponentCatalog/ComponentPre.d.ts +18 -0
  6. package/dist/ComponentCatalog/ComponentRenderer.d.ts +17 -0
  7. package/dist/ComponentCatalog/chartComponentDef.d.ts +36 -0
  8. package/dist/ComponentCatalog/componentCatalog.d.ts +44 -0
  9. package/dist/ComponentCatalog/componentCatalog.spec.d.ts +1 -0
  10. package/dist/ComponentCatalog/generatePrompt.d.ts +9 -0
  11. package/dist/ComponentCatalog/generatePrompt.spec.d.ts +1 -0
  12. package/dist/ComponentCatalog/index.d.ts +9 -0
  13. package/dist/ComponentCatalog/types.d.ts +108 -0
  14. package/dist/ComponentCatalog/validateSpec.d.ts +17 -0
  15. package/dist/ComponentCatalog/validateSpec.spec.d.ts +1 -0
  16. package/dist/{DefaultFileRenderer-C2MsQ9wz.js → DefaultFileRenderer-Day12qYs.js} +2 -2
  17. package/dist/{DefaultFileRenderer-C2MsQ9wz.js.map → DefaultFileRenderer-Day12qYs.js.map} +1 -1
  18. package/dist/Markdown/charts/ChartRenderer.d.ts +1 -1
  19. package/dist/Markdown/charts/ComponentError.d.ts +1 -0
  20. package/dist/Markdown/charts/index.d.ts +2 -6
  21. package/dist/Markdown/charts/types.d.ts +21 -0
  22. package/dist/Markdown/plugins/index.d.ts +1 -1
  23. package/dist/Markdown/plugins/remarkComponent.d.ts +27 -0
  24. package/dist/docs.json +275 -93
  25. package/dist/{index-DdRyk11n.js → index-CZSBRZbI.js} +524 -230
  26. package/dist/index-CZSBRZbI.js.map +1 -0
  27. package/dist/index.css +101 -1077
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +22 -22
  30. package/dist/index.umd.cjs +509 -215
  31. package/dist/index.umd.cjs.map +1 -1
  32. package/dist/stories/Changelog.mdx +1 -1
  33. package/dist/stories/Charts.stories.tsx +118 -130
  34. package/dist/stories/ComponentCatalog.stories.tsx +509 -0
  35. package/dist/stories/{ChartError.stories.tsx → ComponentError.stories.tsx} +14 -11
  36. package/dist/stories/Intro.mdx +1 -1
  37. package/dist/theme.d.ts +3 -0
  38. package/dist/utils/getChildText.d.ts +10 -0
  39. package/dist/utils/getChildText.spec.d.ts +1 -0
  40. package/package.json +27 -30
  41. package/dist/Markdown/charts/ChartPre.d.ts +0 -6
  42. package/dist/Markdown/charts/chartHelpers.d.ts +0 -40
  43. package/dist/Markdown/plugins/remarkChart.d.ts +0 -59
  44. package/dist/index-DdRyk11n.js.map +0 -1
  45. package/dist/stories/Integration.stories.tsx +0 -312
  46. /package/dist/{Markdown/charts/chartHelpers.spec.d.ts → ComponentCatalog/chartComponentDef.spec.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { Meta, Markdown } from '@storybook/addon-docs';
1
+ import { Meta, Markdown } from '@storybook/addon-docs/blocks';
2
2
  import Readme from "../CHANGELOG.md?raw";
3
3
 
4
4
  <Meta title="Docs/Changelog" />
@@ -3,15 +3,15 @@ import { subHours } from 'date-fns';
3
3
  import {
4
4
  Chat,
5
5
  Session,
6
- remarkChart,
7
- chartComponents,
8
6
  SessionsList,
9
7
  SessionGroups,
10
8
  NewSessionButton,
11
9
  SessionMessages,
12
10
  ChatInput,
13
11
  SessionMessagePanel,
14
- SessionMessagesHeader
12
+ SessionMessagesHeader,
13
+ componentCatalog,
14
+ createChartComponentDef
15
15
  } from 'reachat';
16
16
 
17
17
  export default {
@@ -19,61 +19,78 @@ export default {
19
19
  component: Chat
20
20
  } as Meta;
21
21
 
22
+ // Register charts via the component catalog
23
+ const catalog = componentCatalog({
24
+ Chart: createChartComponentDef()
25
+ });
26
+
22
27
  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'
28
+ type: 'Chart',
29
+ props: {
30
+ type: 'bar',
31
+ data: [
32
+ { key: 'JavaScript', data: 35 },
33
+ { key: 'Python', data: 28 },
34
+ { key: 'TypeScript', data: 22 },
35
+ { key: 'Go', data: 15 },
36
+ { key: 'Rust', data: 10 }
37
+ ],
38
+ width: 450,
39
+ height: 300,
40
+ title: 'Programming Language Popularity'
41
+ }
34
42
  };
35
43
 
36
44
  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'
45
+ type: 'Chart',
46
+ props: {
47
+ type: 'line',
48
+ data: [
49
+ { key: 'Jan', data: 100 },
50
+ { key: 'Feb', data: 150 },
51
+ { key: 'Mar', data: 180 },
52
+ { key: 'Apr', data: 220 },
53
+ { key: 'May', data: 280 },
54
+ { key: 'Jun', data: 350 }
55
+ ],
56
+ width: 450,
57
+ height: 250,
58
+ title: 'Monthly Revenue Growth'
59
+ }
49
60
  };
50
61
 
51
62
  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'
63
+ type: 'Chart',
64
+ props: {
65
+ type: 'pie',
66
+ data: [
67
+ { key: 'Desktop', data: 45 },
68
+ { key: 'Mobile', data: 35 },
69
+ { key: 'Tablet', data: 15 },
70
+ { key: 'Other', data: 5 }
71
+ ],
72
+ width: 350,
73
+ height: 300,
74
+ title: 'Device Usage Distribution'
75
+ }
62
76
  };
63
77
 
64
78
  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'
79
+ type: 'Chart',
80
+ props: {
81
+ type: 'area',
82
+ data: [
83
+ { key: 'Week 1', data: 50 },
84
+ { key: 'Week 2', data: 80 },
85
+ { key: 'Week 3', data: 65 },
86
+ { key: 'Week 4', data: 95 },
87
+ { key: 'Week 5', data: 120 },
88
+ { key: 'Week 6', data: 140 }
89
+ ],
90
+ width: 450,
91
+ height: 250,
92
+ title: 'Weekly User Engagement'
93
+ }
77
94
  };
78
95
 
79
96
  const sessionWithCharts: Session[] = [
@@ -85,10 +102,11 @@ const sessionWithCharts: Session[] = [
85
102
  conversations: [
86
103
  {
87
104
  id: 'conversation-1',
88
- question: 'Can you show me the programming language popularity data as a bar chart?',
105
+ question:
106
+ 'Can you show me the programming language popularity data as a bar chart?',
89
107
  response: `Sure! Here's a bar chart showing the popularity of programming languages based on recent survey data:
90
108
 
91
- \`\`\`chart
109
+ \`\`\`component
92
110
  ${JSON.stringify(barChartData, null, 2)}
93
111
  \`\`\`
94
112
 
@@ -97,10 +115,11 @@ As you can see, JavaScript leads the pack with 35% popularity, followed by Pytho
97
115
  },
98
116
  {
99
117
  id: 'conversation-2',
100
- question: 'What about the monthly revenue growth? Can you visualize that?',
118
+ question:
119
+ 'What about the monthly revenue growth? Can you visualize that?',
101
120
  response: `Absolutely! Here's a line chart showing the monthly revenue growth for the first half of the year:
102
121
 
103
- \`\`\`chart
122
+ \`\`\`component
104
123
  ${JSON.stringify(lineChartData, null, 2)}
105
124
  \`\`\`
106
125
 
@@ -109,10 +128,11 @@ The trend shows consistent growth, with revenue increasing from $100K in January
109
128
  },
110
129
  {
111
130
  id: 'conversation-3',
112
- question: 'How about device usage? A pie chart would be great for that.',
131
+ question:
132
+ 'How about device usage? A pie chart would be great for that.',
113
133
  response: `Great choice! Pie charts are perfect for showing distribution. Here's the device usage breakdown:
114
134
 
115
- \`\`\`chart
135
+ \`\`\`component
116
136
  ${JSON.stringify(pieChartData, null, 2)}
117
137
  \`\`\`
118
138
 
@@ -132,24 +152,25 @@ const sessionWithMultipleCharts: Session[] = [
132
152
  conversations: [
133
153
  {
134
154
  id: 'conversation-1',
135
- question: 'Can you give me a comprehensive analysis with multiple charts?',
155
+ question:
156
+ 'Can you give me a comprehensive analysis with multiple charts?',
136
157
  response: `Of course! Let me present the quarterly analysis with multiple visualizations.
137
158
 
138
159
  ## Revenue Trend
139
160
 
140
- \`\`\`chart
161
+ \`\`\`component
141
162
  ${JSON.stringify(lineChartData, null, 2)}
142
163
  \`\`\`
143
164
 
144
165
  ## User Engagement
145
166
 
146
- \`\`\`chart
167
+ \`\`\`component
147
168
  ${JSON.stringify(areaChartData, null, 2)}
148
169
  \`\`\`
149
170
 
150
171
  ## Market Share by Device
151
172
 
152
- \`\`\`chart
173
+ \`\`\`component
153
174
  ${JSON.stringify(pieChartData, null, 2)}
154
175
  \`\`\`
155
176
 
@@ -163,27 +184,25 @@ ${JSON.stringify(pieChartData, null, 2)}
163
184
  }
164
185
  ];
165
186
 
187
+ const storyStyle = {
188
+ position: 'absolute' as const,
189
+ top: 0,
190
+ left: 0,
191
+ right: 0,
192
+ bottom: 0,
193
+ padding: 20,
194
+ margin: 20,
195
+ borderRadius: 5
196
+ };
197
+
166
198
  export const BarChartExample = () => {
167
199
  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
- >
200
+ <div className="dark:bg-gray-950 bg-white" style={storyStyle}>
181
201
  <Chat
182
202
  viewType="console"
183
203
  sessions={sessionWithCharts}
184
204
  activeSessionId="session-charts"
185
- remarkPlugins={[remarkChart]}
186
- markdownComponents={chartComponents}
205
+ components={catalog}
187
206
  >
188
207
  <SessionsList>
189
208
  <NewSessionButton />
@@ -201,25 +220,12 @@ export const BarChartExample = () => {
201
220
 
202
221
  export const MultipleCharts = () => {
203
222
  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
- >
223
+ <div className="dark:bg-gray-950 bg-white" style={storyStyle}>
217
224
  <Chat
218
225
  viewType="console"
219
226
  sessions={sessionWithMultipleCharts}
220
227
  activeSessionId="session-multi-charts"
221
- remarkPlugins={[remarkChart]}
222
- markdownComponents={chartComponents}
228
+ components={catalog}
223
229
  >
224
230
  <SessionsList>
225
231
  <NewSessionButton />
@@ -237,18 +243,21 @@ export const MultipleCharts = () => {
237
243
 
238
244
  export const AllChartTypes = () => {
239
245
  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
246
+ type: 'Chart',
247
+ props: {
248
+ type: 'sparkline',
249
+ data: [
250
+ { key: '1', data: 10 },
251
+ { key: '2', data: 25 },
252
+ { key: '3', data: 15 },
253
+ { key: '4', data: 35 },
254
+ { key: '5', data: 30 },
255
+ { key: '6', data: 45 },
256
+ { key: '7', data: 40 }
257
+ ],
258
+ width: 200,
259
+ height: 50
260
+ }
252
261
  };
253
262
 
254
263
  const sessionAllCharts: Session[] = [
@@ -264,27 +273,27 @@ export const AllChartTypes = () => {
264
273
  response: `Here's a showcase of all available chart types:
265
274
 
266
275
  ## Bar Chart
267
- \`\`\`chart
276
+ \`\`\`component
268
277
  ${JSON.stringify(barChartData, null, 2)}
269
278
  \`\`\`
270
279
 
271
280
  ## Line Chart
272
- \`\`\`chart
281
+ \`\`\`component
273
282
  ${JSON.stringify(lineChartData, null, 2)}
274
283
  \`\`\`
275
284
 
276
285
  ## Area Chart
277
- \`\`\`chart
286
+ \`\`\`component
278
287
  ${JSON.stringify(areaChartData, null, 2)}
279
288
  \`\`\`
280
289
 
281
290
  ## Pie Chart
282
- \`\`\`chart
291
+ \`\`\`component
283
292
  ${JSON.stringify(pieChartData, null, 2)}
284
293
  \`\`\`
285
294
 
286
295
  ## Sparkline (inline mini-chart)
287
- \`\`\`chart
296
+ \`\`\`component
288
297
  ${JSON.stringify(sparklineData, null, 2)}
289
298
  \`\`\`
290
299
 
@@ -301,25 +310,12 @@ Each chart type is optimized for different use cases:
301
310
  ];
302
311
 
303
312
  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
- >
313
+ <div className="dark:bg-gray-950 bg-white" style={storyStyle}>
317
314
  <Chat
318
315
  viewType="console"
319
316
  sessions={sessionAllCharts}
320
317
  activeSessionId="session-all-charts"
321
- remarkPlugins={[remarkChart]}
322
- markdownComponents={chartComponents}
318
+ components={catalog}
323
319
  >
324
320
  <SessionsList>
325
321
  <NewSessionButton />
@@ -340,14 +336,7 @@ export const ChatViewWithCharts = () => {
340
336
  <div
341
337
  className="dark:bg-gray-950 bg-white"
342
338
  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,
339
+ ...storyStyle,
351
340
  maxWidth: 800,
352
341
  marginLeft: 'auto',
353
342
  marginRight: 'auto'
@@ -357,8 +346,7 @@ export const ChatViewWithCharts = () => {
357
346
  viewType="chat"
358
347
  sessions={sessionWithCharts}
359
348
  activeSessionId="session-charts"
360
- remarkPlugins={[remarkChart]}
361
- markdownComponents={chartComponents}
349
+ components={catalog}
362
350
  >
363
351
  <SessionMessagePanel>
364
352
  <SessionMessagesHeader />