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.
- package/dist/{CSVFileRenderer-BOdL4Jte.js → CSVFileRenderer-C2E4Xnkz.js} +2 -2
- package/dist/{CSVFileRenderer-BOdL4Jte.js.map → CSVFileRenderer-C2E4Xnkz.js.map} +1 -1
- package/dist/Chat.d.ts +12 -0
- package/dist/{Markdown/charts/ChartError.d.ts → ComponentCatalog/ComponentError.d.ts} +2 -2
- package/dist/ComponentCatalog/ComponentPre.d.ts +18 -0
- package/dist/ComponentCatalog/ComponentRenderer.d.ts +17 -0
- package/dist/ComponentCatalog/chartComponentDef.d.ts +36 -0
- package/dist/ComponentCatalog/componentCatalog.d.ts +44 -0
- package/dist/ComponentCatalog/componentCatalog.spec.d.ts +1 -0
- package/dist/ComponentCatalog/generatePrompt.d.ts +9 -0
- package/dist/ComponentCatalog/generatePrompt.spec.d.ts +1 -0
- package/dist/ComponentCatalog/index.d.ts +9 -0
- package/dist/ComponentCatalog/types.d.ts +108 -0
- package/dist/ComponentCatalog/validateSpec.d.ts +17 -0
- package/dist/ComponentCatalog/validateSpec.spec.d.ts +1 -0
- package/dist/{DefaultFileRenderer-C2MsQ9wz.js → DefaultFileRenderer-Day12qYs.js} +2 -2
- package/dist/{DefaultFileRenderer-C2MsQ9wz.js.map → DefaultFileRenderer-Day12qYs.js.map} +1 -1
- package/dist/Markdown/charts/ChartRenderer.d.ts +1 -1
- package/dist/Markdown/charts/ComponentError.d.ts +1 -0
- package/dist/Markdown/charts/index.d.ts +2 -6
- package/dist/Markdown/charts/types.d.ts +21 -0
- package/dist/Markdown/plugins/index.d.ts +1 -1
- package/dist/Markdown/plugins/remarkComponent.d.ts +27 -0
- package/dist/docs.json +275 -93
- package/dist/{index-DdRyk11n.js → index-CZSBRZbI.js} +524 -230
- package/dist/index-CZSBRZbI.js.map +1 -0
- package/dist/index.css +101 -1077
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -22
- package/dist/index.umd.cjs +509 -215
- package/dist/index.umd.cjs.map +1 -1
- package/dist/stories/Changelog.mdx +1 -1
- package/dist/stories/Charts.stories.tsx +118 -130
- package/dist/stories/ComponentCatalog.stories.tsx +509 -0
- package/dist/stories/{ChartError.stories.tsx → ComponentError.stories.tsx} +14 -11
- package/dist/stories/Intro.mdx +1 -1
- package/dist/theme.d.ts +3 -0
- package/dist/utils/getChildText.d.ts +10 -0
- package/dist/utils/getChildText.spec.d.ts +1 -0
- package/package.json +27 -30
- package/dist/Markdown/charts/ChartPre.d.ts +0 -6
- package/dist/Markdown/charts/chartHelpers.d.ts +0 -40
- package/dist/Markdown/plugins/remarkChart.d.ts +0 -59
- package/dist/index-DdRyk11n.js.map +0 -1
- package/dist/stories/Integration.stories.tsx +0 -312
- /package/dist/{Markdown/charts/chartHelpers.spec.d.ts → ComponentCatalog/chartComponentDef.spec.d.ts} +0 -0
|
@@ -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: '
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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: '
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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: '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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: '
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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:
|
|
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
|
-
\`\`\`
|
|
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:
|
|
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
|
-
\`\`\`
|
|
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:
|
|
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
|
-
\`\`\`
|
|
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:
|
|
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
|
-
\`\`\`
|
|
161
|
+
\`\`\`component
|
|
141
162
|
${JSON.stringify(lineChartData, null, 2)}
|
|
142
163
|
\`\`\`
|
|
143
164
|
|
|
144
165
|
## User Engagement
|
|
145
166
|
|
|
146
|
-
\`\`\`
|
|
167
|
+
\`\`\`component
|
|
147
168
|
${JSON.stringify(areaChartData, null, 2)}
|
|
148
169
|
\`\`\`
|
|
149
170
|
|
|
150
171
|
## Market Share by Device
|
|
151
172
|
|
|
152
|
-
\`\`\`
|
|
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
|
-
|
|
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
|
-
|
|
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: '
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
\`\`\`
|
|
276
|
+
\`\`\`component
|
|
268
277
|
${JSON.stringify(barChartData, null, 2)}
|
|
269
278
|
\`\`\`
|
|
270
279
|
|
|
271
280
|
## Line Chart
|
|
272
|
-
\`\`\`
|
|
281
|
+
\`\`\`component
|
|
273
282
|
${JSON.stringify(lineChartData, null, 2)}
|
|
274
283
|
\`\`\`
|
|
275
284
|
|
|
276
285
|
## Area Chart
|
|
277
|
-
\`\`\`
|
|
286
|
+
\`\`\`component
|
|
278
287
|
${JSON.stringify(areaChartData, null, 2)}
|
|
279
288
|
\`\`\`
|
|
280
289
|
|
|
281
290
|
## Pie Chart
|
|
282
|
-
\`\`\`
|
|
291
|
+
\`\`\`component
|
|
283
292
|
${JSON.stringify(pieChartData, null, 2)}
|
|
284
293
|
\`\`\`
|
|
285
294
|
|
|
286
295
|
## Sparkline (inline mini-chart)
|
|
287
|
-
\`\`\`
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
361
|
-
markdownComponents={chartComponents}
|
|
349
|
+
components={catalog}
|
|
362
350
|
>
|
|
363
351
|
<SessionMessagePanel>
|
|
364
352
|
<SessionMessagesHeader />
|