@app-studio/web 0.9.41 → 0.9.44
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/bot/Bot.d.ts +15 -0
- package/dist/bot/Cache.d.ts +13 -0
- package/dist/bot/Config.d.ts +13 -0
- package/dist/bot/ContentFetcher.d.ts +9 -0
- package/dist/bot/DocuCode.d.ts +19 -0
- package/dist/bot/FileHandler.d.ts +39 -0
- package/dist/bot/ai/AnthropicConnector.d.ts +6 -0
- package/dist/bot/ai/GeminiConnector.d.ts +7 -0
- package/dist/bot/ai/GroqConnector.d.ts +7 -0
- package/dist/bot/ai/HuggingFaceConnector.d.ts +6 -0
- package/dist/bot/ai/OpenAIConnector.d.ts +11 -0
- package/dist/bot/ai/ReplicateConnector.d.ts +7 -0
- package/dist/bot/ai/SambaNovaConnector.d.ts +6 -0
- package/dist/bot/ai/ai.config.d.ts +12 -0
- package/dist/bot/ai/ai.service.d.ts +36 -0
- package/dist/bot/data.d.ts +19 -0
- package/dist/bot/extractors.d.ts +8 -0
- package/dist/bot/index.d.ts +1 -0
- package/dist/bot/prompt/1-project.d.ts +1 -0
- package/dist/bot/prompt/2-response.d.ts +1 -0
- package/dist/bot/prompt/3-comment.d.ts +1 -0
- package/dist/components/Title/Title/SlideEffect.d.ts +14 -0
- package/dist/components/Title/Title/Title.props.d.ts +20 -0
- package/dist/components/Title/Title/Title.state.d.ts +4 -0
- package/dist/web.cjs.development.js +265 -78
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +265 -78
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +265 -78
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/components/Accordion.mdx +74 -121
- package/docs/components/Alert.mdx +19 -70
- package/docs/components/AspectRatio.mdx +13 -11
- package/docs/components/AudioInput.mdx +43 -0
- package/docs/components/Avatar.mdx +18 -43
- package/docs/components/Background.mdx +100 -492
- package/docs/components/Badge.mdx +45 -130
- package/docs/components/Button.mdx +76 -128
- package/docs/components/Calendar.mdx +7 -7
- package/docs/components/Card.mdx +247 -290
- package/docs/components/Carousel.mdx +94 -321
- package/docs/components/Chart.mdx +171 -26
- package/docs/components/ChatInput.mdx +327 -275
- package/docs/components/Checkbox.mdx +3 -5
- package/docs/components/ColorInput.mdx +6 -6
- package/docs/components/ColorPicker.mdx +452 -0
- package/docs/components/ComboBox.mdx +13 -13
- package/docs/components/Command.mdx +140 -188
- package/docs/components/ContextMenu.mdx +47 -171
- package/docs/components/CookieConsent.mdx +53 -0
- package/docs/components/CountryPicker.mdx +8 -8
- package/docs/components/DatePicker.mdx +3 -3
- package/docs/components/DragAndDrop.mdx +279 -463
- package/docs/components/Drawer.mdx +392 -231
- package/docs/components/DropdownMenu.mdx +37 -155
- package/docs/components/EmojiPicker.mdx +84 -0
- package/docs/components/File.mdx +130 -4
- package/docs/components/Formik.mdx +39 -39
- package/docs/components/Gradient.mdx +359 -182
- package/docs/components/Horizontal.mdx +1 -2
- package/docs/components/HoverCard.mdx +57 -125
- package/docs/components/KanbanBoard.mdx +9 -9
- package/docs/components/Link.mdx +22 -30
- package/docs/components/Loader.mdx +230 -413
- package/docs/components/Menubar.mdx +73 -69
- package/docs/components/Message.mdx +210 -525
- package/docs/components/Modal.mdx +351 -475
- package/docs/components/NavigationMenu.mdx +8 -8
- package/docs/components/OTPInput.mdx +194 -0
- package/docs/components/Pagination.mdx +451 -107
- package/docs/components/Password.mdx +8 -8
- package/docs/components/ProgressBar.mdx +460 -0
- package/docs/components/Resizable.mdx +103 -102
- package/docs/components/Select.mdx +5 -5
- package/docs/components/Separator.mdx +11 -98
- package/docs/components/ShareButton.mdx +29 -0
- package/docs/components/Sidebar.mdx +70 -131
- package/docs/components/Slider.mdx +99 -185
- package/docs/components/StatusIndicator.mdx +373 -0
- package/docs/components/Switch.mdx +3 -3
- package/docs/components/Table.mdx +25 -105
- package/docs/components/Tabs.mdx +40 -143
- package/docs/components/TagInput.mdx +17 -17
- package/docs/components/Text.mdx +3 -3
- package/docs/components/TextArea.mdx +6 -6
- package/docs/components/TextField.mdx +12 -12
- package/docs/components/Title.mdx +267 -525
- package/docs/components/Toast.mdx +65 -142
- package/docs/components/Toggle.mdx +37 -49
- package/docs/components/ToggleGroup.mdx +36 -57
- package/docs/components/Tooltip.mdx +501 -138
- package/docs/components/Uploader.mdx +205 -351
- package/package.json +1 -1
- package/dist/components/AuthGuard/AuthGuard.d.ts +0 -35
- package/dist/components/AuthGuard/index.d.ts +0 -1
- package/docs/adk-components.md +0 -319
- package/docs/adk-quick-start.md +0 -268
|
@@ -1,373 +1,425 @@
|
|
|
1
1
|
# ChatInput
|
|
2
2
|
|
|
3
|
+
A customizable chat input component with file upload support, mentions, suggestions, audio recording, and model selection.
|
|
3
4
|
|
|
4
5
|
### **Import**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
```tsx
|
|
7
|
+
import { ChatInput } from '@app-studio/web';
|
|
8
|
+
```
|
|
8
9
|
|
|
9
|
-
### **
|
|
10
|
+
### **Default**
|
|
10
11
|
```tsx
|
|
11
12
|
import React, { useState } from 'react';
|
|
12
13
|
import { ChatInput } from '@app-studio/web';
|
|
13
|
-
import { View } from '@app-studio/web';
|
|
14
14
|
|
|
15
|
-
export const
|
|
16
|
-
const [
|
|
15
|
+
export const DefaultChatInput = () => {
|
|
16
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ChatInput
|
|
20
|
+
onSubmit={(message) => console.log('Message:', message)}
|
|
21
|
+
getPendingFiles={() => files}
|
|
22
|
+
clearPendingFiles={() => setFiles([])}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### **onSubmit**
|
|
29
|
+
Callback function when the form is submitted.
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
setInputValue('');
|
|
21
|
-
};
|
|
31
|
+
- **Type:** `(message: string, options?: { model_name?: string; enable_thinking?: boolean }) => void`
|
|
32
|
+
- **Required:** `true`
|
|
22
33
|
|
|
34
|
+
```tsx
|
|
35
|
+
import React, { useState } from 'react';
|
|
36
|
+
import { ChatInput } from '@app-studio/web';
|
|
37
|
+
|
|
38
|
+
export const SubmitChatInput = () => {
|
|
39
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
40
|
+
|
|
23
41
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
<ChatInput
|
|
43
|
+
onSubmit={(message, options) => {
|
|
44
|
+
console.log('Message:', message);
|
|
45
|
+
console.log('Model:', options?.model_name);
|
|
46
|
+
console.log('Thinking:', options?.enable_thinking);
|
|
47
|
+
}}
|
|
48
|
+
getPendingFiles={() => files}
|
|
49
|
+
clearPendingFiles={() => setFiles([])}
|
|
50
|
+
/>
|
|
32
51
|
);
|
|
33
52
|
};
|
|
34
53
|
```
|
|
35
54
|
|
|
36
|
-
### **
|
|
55
|
+
### **placeholder**
|
|
56
|
+
Placeholder text for the input.
|
|
37
57
|
|
|
38
|
-
|
|
58
|
+
- **Type:** `string`
|
|
59
|
+
- **Default:** `'Type a message...'`
|
|
39
60
|
|
|
40
61
|
```tsx
|
|
41
62
|
import React, { useState } from 'react';
|
|
42
63
|
import { ChatInput } from '@app-studio/web';
|
|
43
|
-
import { View } from '@app-studio/web';
|
|
44
64
|
|
|
45
|
-
export const
|
|
46
|
-
const [
|
|
65
|
+
export const PlaceholderChatInput = () => {
|
|
66
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ChatInput
|
|
70
|
+
placeholder="Ask me anything..."
|
|
71
|
+
onSubmit={(message) => console.log(message)}
|
|
72
|
+
getPendingFiles={() => files}
|
|
73
|
+
clearPendingFiles={() => setFiles([])}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### **loading**
|
|
80
|
+
Whether the input is in a loading state.
|
|
81
|
+
|
|
82
|
+
- **Type:** `boolean`
|
|
83
|
+
- **Default:** `false`
|
|
47
84
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Message will include file information automatically
|
|
52
|
-
};
|
|
85
|
+
```tsx
|
|
86
|
+
import React, { useState } from 'react';
|
|
87
|
+
import { ChatInput } from '@app-studio/web';
|
|
53
88
|
|
|
89
|
+
export const LoadingChatInput = () => {
|
|
90
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
91
|
+
const [loading, setLoading] = useState(false);
|
|
92
|
+
|
|
54
93
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
<ChatInput
|
|
95
|
+
loading={loading}
|
|
96
|
+
onSubmit={(message) => {
|
|
97
|
+
setLoading(true);
|
|
98
|
+
setTimeout(() => setLoading(false), 2000);
|
|
99
|
+
}}
|
|
100
|
+
getPendingFiles={() => files}
|
|
101
|
+
clearPendingFiles={() => setFiles([])}
|
|
102
|
+
/>
|
|
64
103
|
);
|
|
65
104
|
};
|
|
66
105
|
```
|
|
67
106
|
|
|
68
|
-
**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- **
|
|
72
|
-
- **
|
|
73
|
-
|
|
74
|
-
### **With Prompt Examples**
|
|
107
|
+
### **disabled**
|
|
108
|
+
Whether the input is disabled.
|
|
109
|
+
|
|
110
|
+
- **Type:** `boolean`
|
|
111
|
+
- **Default:** `false`
|
|
112
|
+
|
|
75
113
|
```tsx
|
|
76
114
|
import React, { useState } from 'react';
|
|
77
115
|
import { ChatInput } from '@app-studio/web';
|
|
78
|
-
import { View } from '@app-studio/web';
|
|
79
|
-
import { PromptExample } from '@app-studio/web';
|
|
80
|
-
|
|
81
|
-
export const ChatInputWithPromptExamples = () => {
|
|
82
|
-
const [inputValue, setInputValue] = useState('');
|
|
83
|
-
|
|
84
|
-
// Example prompt suggestions
|
|
85
|
-
const promptExamples: PromptExample[] = [
|
|
86
|
-
{ id: '1', text: 'Tell me a joke' },
|
|
87
|
-
{ id: '2', text: 'What is the weather today?' },
|
|
88
|
-
{ id: '3', text: 'How do I create a React component?' },
|
|
89
|
-
{ id: '4', text: 'Write a poem about coding' },
|
|
90
|
-
];
|
|
91
116
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
export const DisabledChatInput = () => {
|
|
118
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<ChatInput
|
|
122
|
+
disabled
|
|
123
|
+
onSubmit={(message) => console.log(message)}
|
|
124
|
+
getPendingFiles={() => files}
|
|
125
|
+
clearPendingFiles={() => setFiles([])}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### **value & onChange**
|
|
132
|
+
Controlled input value.
|
|
96
133
|
|
|
97
|
-
|
|
98
|
-
console.log('Prompt selected:', example);
|
|
99
|
-
};
|
|
134
|
+
- **Type:** `string` & `(value: string) => void`
|
|
100
135
|
|
|
136
|
+
```tsx
|
|
137
|
+
import React, { useState } from 'react';
|
|
138
|
+
import { ChatInput } from '@app-studio/web';
|
|
139
|
+
|
|
140
|
+
export const ControlledChatInput = () => {
|
|
141
|
+
const [value, setValue] = useState('');
|
|
142
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
143
|
+
|
|
101
144
|
return (
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
<ChatInput
|
|
146
|
+
value={value}
|
|
147
|
+
onChange={setValue}
|
|
148
|
+
onSubmit={(message) => {
|
|
149
|
+
console.log(message);
|
|
150
|
+
setValue('');
|
|
151
|
+
}}
|
|
152
|
+
getPendingFiles={() => files}
|
|
153
|
+
clearPendingFiles={() => setFiles([])}
|
|
154
|
+
/>
|
|
111
155
|
);
|
|
112
156
|
};
|
|
113
157
|
```
|
|
114
158
|
|
|
115
|
-
### **
|
|
159
|
+
### **hideAttachments**
|
|
160
|
+
Whether to hide the attachment button.
|
|
116
161
|
|
|
117
|
-
|
|
162
|
+
- **Type:** `boolean`
|
|
163
|
+
- **Default:** `false`
|
|
118
164
|
|
|
119
165
|
```tsx
|
|
120
166
|
import React, { useState } from 'react';
|
|
121
167
|
import { ChatInput } from '@app-studio/web';
|
|
122
|
-
import { View } from '@app-studio/web';
|
|
123
168
|
|
|
124
|
-
export const
|
|
125
|
-
const [
|
|
169
|
+
export const NoAttachmentsChatInput = () => {
|
|
170
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<ChatInput
|
|
174
|
+
hideAttachments
|
|
175
|
+
onSubmit={(message) => console.log(message)}
|
|
176
|
+
getPendingFiles={() => files}
|
|
177
|
+
clearPendingFiles={() => setFiles([])}
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### **enableAudioRecording**
|
|
184
|
+
Enable audio recording button.
|
|
185
|
+
|
|
186
|
+
- **Type:** `boolean`
|
|
187
|
+
- **Default:** `false`
|
|
126
188
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
189
|
+
```tsx
|
|
190
|
+
import React, { useState } from 'react';
|
|
191
|
+
import { ChatInput } from '@app-studio/web';
|
|
131
192
|
|
|
193
|
+
export const AudioChatInput = () => {
|
|
194
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
195
|
+
|
|
132
196
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
197
|
+
<ChatInput
|
|
198
|
+
enableAudioRecording
|
|
199
|
+
onAudioRecordingStart={() => console.log('Recording started')}
|
|
200
|
+
onAudioRecordingStop={(audio) => console.log('Audio blob:', audio)}
|
|
201
|
+
onSubmit={(message) => console.log(message)}
|
|
202
|
+
getPendingFiles={() => files}
|
|
203
|
+
clearPendingFiles={() => setFiles([])}
|
|
204
|
+
/>
|
|
141
205
|
);
|
|
142
206
|
};
|
|
143
207
|
```
|
|
144
208
|
|
|
145
|
-
**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- **
|
|
149
|
-
- **Error Handling**: Clear feedback for invalid files or size limits
|
|
209
|
+
### **suggestions**
|
|
210
|
+
List of suggestions for auto-completion.
|
|
211
|
+
|
|
212
|
+
- **Type:** `Suggestion[]`
|
|
150
213
|
|
|
151
|
-
### **Custom Styling**
|
|
152
214
|
```tsx
|
|
153
|
-
import React from 'react';
|
|
215
|
+
import React, { useState } from 'react';
|
|
154
216
|
import { ChatInput } from '@app-studio/web';
|
|
155
|
-
import { View } from '@app-studio/web';
|
|
156
|
-
|
|
157
|
-
export const StyledChatInput = () => {
|
|
158
|
-
const handleSubmit = (message) => {
|
|
159
|
-
console.log('Message submitted:', message);
|
|
160
|
-
};
|
|
161
217
|
|
|
218
|
+
export const SuggestionsChatInput = () => {
|
|
219
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
220
|
+
|
|
221
|
+
const suggestions = [
|
|
222
|
+
{ text: 'How do I...', value: 'how-to' },
|
|
223
|
+
{ text: 'What is...', value: 'what-is' },
|
|
224
|
+
{ text: 'Can you help me...', value: 'help' },
|
|
225
|
+
];
|
|
226
|
+
|
|
162
227
|
return (
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
views={{
|
|
170
|
-
container: {
|
|
171
|
-
backgroundColor: 'color.purple.50',
|
|
172
|
-
},
|
|
173
|
-
content: {
|
|
174
|
-
borderColor: 'color.purple.200',
|
|
175
|
-
},
|
|
176
|
-
submitButton: {
|
|
177
|
-
backgroundColor: 'color.purple.500',
|
|
178
|
-
},
|
|
179
|
-
}}
|
|
180
|
-
/>
|
|
181
|
-
</View>
|
|
228
|
+
<ChatInput
|
|
229
|
+
suggestions={suggestions}
|
|
230
|
+
onSubmit={(message) => console.log(message)}
|
|
231
|
+
getPendingFiles={() => files}
|
|
232
|
+
clearPendingFiles={() => setFiles([])}
|
|
233
|
+
/>
|
|
182
234
|
);
|
|
183
235
|
};
|
|
184
236
|
```
|
|
185
237
|
|
|
186
|
-
### **
|
|
238
|
+
### **mentionData**
|
|
239
|
+
Data for mention auto-completion.
|
|
240
|
+
|
|
241
|
+
- **Type:** `Array<{ id: string; name: string; avatar?: string; description?: string }>`
|
|
242
|
+
|
|
187
243
|
```tsx
|
|
188
244
|
import React, { useState } from 'react';
|
|
189
245
|
import { ChatInput } from '@app-studio/web';
|
|
190
|
-
import { View } from '@app-studio/web';
|
|
191
|
-
|
|
192
|
-
export const ChatInputWithAgent = () => {
|
|
193
|
-
const [isAgentRunning, setIsAgentRunning] = useState(false);
|
|
194
246
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
247
|
+
export const MentionsChatInput = () => {
|
|
248
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
249
|
+
|
|
250
|
+
const mentionData = [
|
|
251
|
+
{ id: '1', name: 'John Doe', avatar: '/avatars/john.jpg' },
|
|
252
|
+
{ id: '2', name: 'Jane Smith', avatar: '/avatars/jane.jpg' },
|
|
253
|
+
{ id: '3', name: 'Bob Johnson', description: 'Developer' },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<ChatInput
|
|
258
|
+
mentionData={mentionData}
|
|
259
|
+
mentionTrigger="@"
|
|
260
|
+
onMentionSelect={(mention) => console.log('Mentioned:', mention)}
|
|
261
|
+
onSubmit={(message) => console.log(message)}
|
|
262
|
+
getPendingFiles={() => files}
|
|
263
|
+
clearPendingFiles={() => setFiles([])}
|
|
264
|
+
/>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
```
|
|
198
268
|
|
|
199
|
-
|
|
200
|
-
|
|
269
|
+
### **promptExamples**
|
|
270
|
+
List of prompt examples to display.
|
|
201
271
|
|
|
202
|
-
|
|
203
|
-
setTimeout(() => {
|
|
204
|
-
setIsAgentRunning(false);
|
|
205
|
-
}, 5000);
|
|
206
|
-
};
|
|
272
|
+
- **Type:** `PromptExample[]`
|
|
207
273
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
274
|
+
```tsx
|
|
275
|
+
import React, { useState } from 'react';
|
|
276
|
+
import { ChatInput } from '@app-studio/web';
|
|
212
277
|
|
|
278
|
+
export const PromptExamplesChatInput = () => {
|
|
279
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
280
|
+
|
|
281
|
+
const promptExamples = [
|
|
282
|
+
{ title: 'Write a story', prompt: 'Write a short story about...' },
|
|
283
|
+
{ title: 'Explain a concept', prompt: 'Explain quantum physics in simple terms' },
|
|
284
|
+
{ title: 'Code help', prompt: 'Help me debug this code...' },
|
|
285
|
+
];
|
|
286
|
+
|
|
213
287
|
return (
|
|
214
|
-
<
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
288
|
+
<ChatInput
|
|
289
|
+
promptExamples={promptExamples}
|
|
290
|
+
onPromptExampleSelect={(example) => console.log('Selected:', example)}
|
|
291
|
+
onSubmit={(message) => console.log(message)}
|
|
292
|
+
getPendingFiles={() => files}
|
|
293
|
+
clearPendingFiles={() => setFiles([])}
|
|
294
|
+
/>
|
|
221
295
|
);
|
|
222
296
|
};
|
|
223
297
|
```
|
|
224
298
|
|
|
225
|
-
### **
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
| onSubmit | `(message: string, options?: { model_name?: string; enable_thinking?: boolean }) => void` | required | Callback function when the form is submitted |
|
|
230
|
-
| placeholder | string | 'Say what you want and Kimmy will surprise you' | Placeholder text for the input |
|
|
231
|
-
| loading | boolean | false | Whether the input is in a loading state |
|
|
232
|
-
| disabled | boolean | false | Whether the input is disabled |
|
|
233
|
-
| isAgentRunning | boolean | false | Whether an agent is currently running |
|
|
234
|
-
| onStopAgent | `() => void` | undefined | Callback function to stop the agent |
|
|
235
|
-
| autoFocus | boolean | true | Whether to auto focus the input |
|
|
236
|
-
| value | string | undefined | Controlled value for the input |
|
|
237
|
-
| onChange | `(value: string) => void` | undefined | Callback function when the input value changes |
|
|
238
|
-
| onFileBrowse | `() => void` | undefined | Callback function when the file browser is opened |
|
|
239
|
-
| sandboxId | string | undefined | ID of the sandbox |
|
|
240
|
-
| hideAttachments | boolean | false | Whether to hide the attachment button |
|
|
241
|
-
| title | string | undefined | Title for the chat input |
|
|
242
|
-
| showGuideTip | boolean | false | Whether to show the guide tip |
|
|
243
|
-
| guideVideoUrl | string | undefined | URL for the guide video |
|
|
244
|
-
| onGuideClose | `() => void` | undefined | Callback function when the guide tip is closed |
|
|
245
|
-
| promptExamples | `PromptExample[]` | [] | List of prompt examples |
|
|
246
|
-
| onPromptExampleSelect | `(example: PromptExample) => void` | undefined | Callback function when a prompt example is selected |
|
|
247
|
-
| size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | 'md' | Size of the chat input |
|
|
248
|
-
| shape | `'default' \| 'sharp' \| 'rounded' \| 'pillShaped'` | 'rounded' | Shape of the chat input |
|
|
249
|
-
| variant | `'default' \| 'outline' \| 'none'` | 'default' | Visual variant of the chat input |
|
|
250
|
-
| views | object | {} | Custom styling for different parts of the component |
|
|
251
|
-
|
|
252
|
-
### **File Upload Integration**
|
|
253
|
-
|
|
254
|
-
The ChatInput component integrates seamlessly with the Uploader component:
|
|
255
|
-
|
|
256
|
-
- **Automatic File Processing**: Files are automatically processed and added to the message
|
|
257
|
-
- **File Size Validation**: 50MB maximum file size with clear error messages
|
|
258
|
-
- **Multiple File Support**: Upload multiple files simultaneously
|
|
259
|
-
- **Drag & Drop Integration**: Full drag and drop support with visual feedback
|
|
260
|
-
|
|
261
|
-
### **Customization**
|
|
262
|
-
|
|
263
|
-
The ChatInput component can be customized using the `views` prop:
|
|
299
|
+
### **isAgentRunning & onStopAgent**
|
|
300
|
+
Agent running state and stop callback.
|
|
301
|
+
|
|
302
|
+
- **Type:** `boolean` & `() => void`
|
|
264
303
|
|
|
265
304
|
```tsx
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
305
|
+
import React, { useState } from 'react';
|
|
306
|
+
import { ChatInput } from '@app-studio/web';
|
|
307
|
+
|
|
308
|
+
export const AgentChatInput = () => {
|
|
309
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
310
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
311
|
+
|
|
312
|
+
return (
|
|
313
|
+
<ChatInput
|
|
314
|
+
isAgentRunning={isRunning}
|
|
315
|
+
onStopAgent={() => {
|
|
316
|
+
console.log('Stopping agent');
|
|
317
|
+
setIsRunning(false);
|
|
318
|
+
}}
|
|
319
|
+
onSubmit={(message) => {
|
|
320
|
+
console.log(message);
|
|
321
|
+
setIsRunning(true);
|
|
322
|
+
}}
|
|
323
|
+
getPendingFiles={() => files}
|
|
324
|
+
clearPendingFiles={() => setFiles([])}
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
};
|
|
286
328
|
```
|
|
287
329
|
|
|
288
|
-
### **
|
|
330
|
+
### **size**
|
|
331
|
+
Size of the input.
|
|
289
332
|
|
|
290
|
-
|
|
333
|
+
- **Type:** `Size`
|
|
334
|
+
- **Default:** `'md'`
|
|
335
|
+
- **Possible Values:** `'xs' | 'sm' | 'md' | 'lg' | 'xl'`
|
|
291
336
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
337
|
+
```tsx
|
|
338
|
+
import React, { useState } from 'react';
|
|
339
|
+
import { ChatInput } from '@app-studio/web';
|
|
340
|
+
import { Vertical } from 'app-studio';
|
|
296
341
|
|
|
297
|
-
|
|
342
|
+
export const SizedChatInputs = () => {
|
|
343
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
344
|
+
|
|
345
|
+
return (
|
|
346
|
+
<Vertical gap={15}>
|
|
347
|
+
{['sm', 'md', 'lg'].map((size) => (
|
|
348
|
+
<ChatInput
|
|
349
|
+
key={size}
|
|
350
|
+
size={size as any}
|
|
351
|
+
onSubmit={(message) => console.log(message)}
|
|
352
|
+
getPendingFiles={() => files}
|
|
353
|
+
clearPendingFiles={() => setFiles([])}
|
|
354
|
+
/>
|
|
355
|
+
))}
|
|
356
|
+
</Vertical>
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
```
|
|
298
360
|
|
|
299
|
-
**
|
|
300
|
-
|
|
301
|
-
- Use the `loading` state to indicate when a message is being processed
|
|
302
|
-
- Implement proper error handling for message submission
|
|
303
|
-
- Provide feedback to users when messages are sent successfully
|
|
361
|
+
### **variant**
|
|
362
|
+
Variant of the input.
|
|
304
363
|
|
|
305
|
-
**
|
|
306
|
-
-
|
|
307
|
-
- Validate file types and sizes on both client and server
|
|
308
|
-
- Provide clear feedback for file upload errors
|
|
309
|
-
- Consider implementing file preview functionality
|
|
364
|
+
- **Type:** `Variant`
|
|
365
|
+
- **Possible Values:** `'default' | 'outlined' | 'filled'`
|
|
310
366
|
|
|
367
|
+
```tsx
|
|
368
|
+
import React, { useState } from 'react';
|
|
369
|
+
import { ChatInput } from '@app-studio/web';
|
|
370
|
+
import { Vertical } from 'app-studio';
|
|
311
371
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
372
|
+
export const VariantChatInputs = () => {
|
|
373
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
374
|
+
|
|
375
|
+
return (
|
|
376
|
+
<Vertical gap={15}>
|
|
377
|
+
{['default', 'outlined', 'filled'].map((variant) => (
|
|
378
|
+
<ChatInput
|
|
379
|
+
key={variant}
|
|
380
|
+
variant={variant as any}
|
|
381
|
+
onSubmit={(message) => console.log(message)}
|
|
382
|
+
getPendingFiles={() => files}
|
|
383
|
+
clearPendingFiles={() => setFiles([])}
|
|
384
|
+
/>
|
|
385
|
+
))}
|
|
386
|
+
</Vertical>
|
|
387
|
+
);
|
|
388
|
+
};
|
|
389
|
+
```
|
|
316
390
|
|
|
317
|
-
### **
|
|
391
|
+
### **views**
|
|
392
|
+
Custom styles for different parts of the chat input.
|
|
318
393
|
|
|
319
|
-
|
|
394
|
+
- **Type:** `ChatInputStyles`
|
|
320
395
|
|
|
321
396
|
```tsx
|
|
322
|
-
// Available in src/pages/chat.page.tsx
|
|
323
397
|
import React, { useState } from 'react';
|
|
324
398
|
import { ChatInput } from '@app-studio/web';
|
|
325
|
-
import { Button } from '@app-studio/web';
|
|
326
|
-
|
|
327
|
-
export const ChatInputDemo = () => {
|
|
328
|
-
const [isSimulatingUpload, setIsSimulatingUpload] = useState(false);
|
|
329
|
-
const [simulationProgress, setSimulationProgress] = useState(0);
|
|
330
|
-
|
|
331
|
-
const simulateUpload = () => {
|
|
332
|
-
// Creates mock files for testing
|
|
333
|
-
const mockFiles = [
|
|
334
|
-
new File(['content'], 'document.pdf', { type: 'application/pdf' }),
|
|
335
|
-
new File(['content'], 'image.jpg', { type: 'image/jpeg' }),
|
|
336
|
-
new File(['content'], 'spreadsheet.xlsx', { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }),
|
|
337
|
-
];
|
|
338
|
-
|
|
339
|
-
setIsSimulatingUpload(true);
|
|
340
|
-
setSimulationProgress(0);
|
|
341
|
-
|
|
342
|
-
const interval = setInterval(() => {
|
|
343
|
-
setSimulationProgress((prev) => {
|
|
344
|
-
if (prev >= 100) {
|
|
345
|
-
clearInterval(interval);
|
|
346
|
-
setIsSimulatingUpload(false);
|
|
347
|
-
console.log('Upload simulation completed!');
|
|
348
|
-
return 100;
|
|
349
|
-
}
|
|
350
|
-
return prev + 10;
|
|
351
|
-
});
|
|
352
|
-
}, 300);
|
|
353
|
-
};
|
|
354
399
|
|
|
400
|
+
export const StyledChatInput = () => {
|
|
401
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
402
|
+
|
|
355
403
|
return (
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
404
|
+
<ChatInput
|
|
405
|
+
onSubmit={(message) => console.log(message)}
|
|
406
|
+
getPendingFiles={() => files}
|
|
407
|
+
clearPendingFiles={() => setFiles([])}
|
|
408
|
+
views={{
|
|
409
|
+
container: {
|
|
410
|
+
borderRadius: 16,
|
|
411
|
+
borderColor: '#3b82f6',
|
|
412
|
+
},
|
|
413
|
+
input: {
|
|
414
|
+
fontSize: 16,
|
|
415
|
+
padding: 12,
|
|
416
|
+
},
|
|
417
|
+
button: {
|
|
418
|
+
backgroundColor: '#3b82f6',
|
|
419
|
+
}
|
|
420
|
+
}}
|
|
421
|
+
/>
|
|
365
422
|
);
|
|
366
423
|
};
|
|
367
424
|
```
|
|
368
425
|
|
|
369
|
-
**Demo Features:**
|
|
370
|
-
- **Simulate Upload**: Test file upload functionality without real files
|
|
371
|
-
- **Progress Tracking**: Visual progress indication during simulation
|
|
372
|
-
- **Mock File Generation**: Creates realistic test files with proper MIME types
|
|
373
|
-
- **Console Logging**: Detailed logging for debugging and testing
|