@app-studio/web 0.9.31 → 0.9.33
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/docs/components/Accordion.mdx +158 -0
- package/docs/components/Alert.mdx +123 -0
- package/docs/components/AspectRatio.mdx +55 -0
- package/docs/components/Avatar.mdx +85 -0
- package/docs/components/Background.mdx +522 -0
- package/docs/components/Badge.mdx +220 -0
- package/docs/components/Button.mdx +272 -0
- package/docs/components/Calendar.mdx +274 -0
- package/docs/components/Card.mdx +341 -0
- package/docs/components/Carousel.mdx +411 -0
- package/docs/components/Center.mdx +474 -0
- package/docs/components/Chart.mdx +232 -0
- package/docs/components/ChatInput.mdx +373 -0
- package/docs/components/Checkbox.mdx +66 -0
- package/docs/components/ColorInput.mdx +209 -0
- package/docs/components/ComboBox.mdx +364 -0
- package/docs/components/Command.mdx +252 -0
- package/docs/components/ContextMenu.mdx +219 -0
- package/docs/components/CountryPicker.mdx +123 -0
- package/docs/components/DatePicker.mdx +77 -0
- package/docs/components/DragAndDrop.mdx +539 -0
- package/docs/components/DropdownMenu.mdx +205 -0
- package/docs/components/File.mdx +8 -0
- package/docs/components/Flow.mdx +257 -0
- package/docs/components/Form.mdx +681 -0
- package/docs/components/Formik.mdx +621 -0
- package/docs/components/Gradient.mdx +271 -0
- package/docs/components/Horizontal.mdx +40 -0
- package/docs/components/HoverCard.mdx +140 -0
- package/docs/components/Icon.mdx +438 -0
- package/docs/components/Label.mdx +438 -0
- package/docs/components/Link.mdx +83 -0
- package/docs/components/Loader.mdx +527 -0
- package/docs/components/Menubar.mdx +124 -0
- package/docs/components/Message.mdx +571 -0
- package/docs/components/Modal.mdx +533 -0
- package/docs/components/NavigationMenu.mdx +165 -0
- package/docs/components/Pagination.mdx +150 -0
- package/docs/components/Password.mdx +121 -0
- package/docs/components/Resizable.mdx +148 -0
- package/docs/components/Select.mdx +126 -0
- package/docs/components/Separator.mdx +121 -0
- package/docs/components/Sidebar.mdx +147 -0
- package/docs/components/Slider.mdx +232 -0
- package/docs/components/Switch.mdx +62 -0
- package/docs/components/Table.mdx +409 -0
- package/docs/components/Tabs.mdx +215 -0
- package/docs/components/TagInput.mdx +528 -0
- package/docs/components/Text.mdx +163 -0
- package/docs/components/TextArea.mdx +136 -0
- package/docs/components/TextField.mdx +225 -0
- package/docs/components/Title.mdx +535 -0
- package/docs/components/Toast.mdx +165 -0
- package/docs/components/Toggle.mdx +141 -0
- package/docs/components/ToggleGroup.mdx +165 -0
- package/docs/components/Tooltip.mdx +191 -0
- package/docs/components/Tree.mdx +340 -0
- package/docs/components/Uploader.mdx +426 -0
- package/docs/components/Vertical.mdx +566 -0
- package/docs/components.md +285 -0
- package/package.json +1 -1
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# ChatInput
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### **Import**
|
|
5
|
+
```tsx
|
|
6
|
+
import { ChatInput } from '@app-studio/web';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### **Basic Usage**
|
|
10
|
+
```tsx
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
import { ChatInput } from '@app-studio/web';
|
|
13
|
+
import { View } from 'app-studio';
|
|
14
|
+
|
|
15
|
+
export const BasicChatInput = () => {
|
|
16
|
+
const [inputValue, setInputValue] = useState('');
|
|
17
|
+
|
|
18
|
+
const handleSubmit = (message) => {
|
|
19
|
+
console.log('Message submitted:', message);
|
|
20
|
+
setInputValue('');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<View width="100%">
|
|
25
|
+
<ChatInput
|
|
26
|
+
onSubmit={handleSubmit}
|
|
27
|
+
value={inputValue}
|
|
28
|
+
onChange={setInputValue}
|
|
29
|
+
placeholder="Type your message here..."
|
|
30
|
+
/>
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### **File Upload & Attachments**
|
|
37
|
+
|
|
38
|
+
The ChatInput component uses the integrated Uploader component for seamless file handling:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import React, { useState } from 'react';
|
|
42
|
+
import { ChatInput } from '@app-studio/web';
|
|
43
|
+
import { View } from 'app-studio';
|
|
44
|
+
|
|
45
|
+
export const ChatInputWithFileUploads = () => {
|
|
46
|
+
const [inputValue, setInputValue] = useState('');
|
|
47
|
+
|
|
48
|
+
const handleSubmit = (message, options) => {
|
|
49
|
+
console.log('Message submitted:', message);
|
|
50
|
+
console.log('Options:', options);
|
|
51
|
+
// Message will include file information automatically
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View width="100%">
|
|
56
|
+
<ChatInput
|
|
57
|
+
onSubmit={handleSubmit}
|
|
58
|
+
value={inputValue}
|
|
59
|
+
onChange={setInputValue}
|
|
60
|
+
placeholder="Upload files and send a message..."
|
|
61
|
+
hideAttachments={false} // Show attachment button
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**File Upload Features:**
|
|
69
|
+
- **Multiple File Selection**: Select multiple files at once using Ctrl/Cmd + click
|
|
70
|
+
- **Drag & Drop Support**: Drop files directly into the chat input area
|
|
71
|
+
- **File Size Validation**: 50MB maximum file size with automatic validation
|
|
72
|
+
- **File Type Support**: All file types supported (images, documents, videos, etc.)
|
|
73
|
+
- **Preview & Management**: View uploaded files and remove them before sending
|
|
74
|
+
### **With Prompt Examples**
|
|
75
|
+
```tsx
|
|
76
|
+
import React, { useState } from 'react';
|
|
77
|
+
import { ChatInput } from '@app-studio/web';
|
|
78
|
+
import { View } from 'app-studio';
|
|
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
|
+
|
|
92
|
+
const handleSubmit = (message) => {
|
|
93
|
+
console.log('Message submitted:', message);
|
|
94
|
+
setInputValue('');
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const handlePromptSelect = (example) => {
|
|
98
|
+
console.log('Prompt selected:', example);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<View width="100%">
|
|
103
|
+
<ChatInput
|
|
104
|
+
onSubmit={handleSubmit}
|
|
105
|
+
value={inputValue}
|
|
106
|
+
onChange={setInputValue}
|
|
107
|
+
promptExamples={promptExamples}
|
|
108
|
+
onPromptExampleSelect={handlePromptSelect}
|
|
109
|
+
/>
|
|
110
|
+
</View>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### **Drag & Drop File Upload**
|
|
116
|
+
|
|
117
|
+
The ChatInput supports drag & drop functionality for easy file uploads:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import React, { useState } from 'react';
|
|
121
|
+
import { ChatInput } from '@app-studio/web';
|
|
122
|
+
import { View } from 'app-studio';
|
|
123
|
+
|
|
124
|
+
export const ChatInputWithDragDrop = () => {
|
|
125
|
+
const [inputValue, setInputValue] = useState('');
|
|
126
|
+
|
|
127
|
+
const handleSubmit = (message, options) => {
|
|
128
|
+
console.log('Message with files:', message);
|
|
129
|
+
// Files are automatically processed and included
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View width="100%">
|
|
134
|
+
<ChatInput
|
|
135
|
+
onSubmit={handleSubmit}
|
|
136
|
+
value={inputValue}
|
|
137
|
+
onChange={setInputValue}
|
|
138
|
+
placeholder="Drag files here or click the attachment button..."
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Drag & Drop Features:**
|
|
146
|
+
- **Visual Feedback**: Input area highlights when files are dragged over
|
|
147
|
+
- **Multiple Files**: Drop multiple files at once for batch upload
|
|
148
|
+
- **File Validation**: Automatic size and type validation during drop
|
|
149
|
+
- **Error Handling**: Clear feedback for invalid files or size limits
|
|
150
|
+
|
|
151
|
+
### **Custom Styling**
|
|
152
|
+
```tsx
|
|
153
|
+
import React from 'react';
|
|
154
|
+
import { ChatInput } from '@app-studio/web';
|
|
155
|
+
import { View } from 'app-studio';
|
|
156
|
+
|
|
157
|
+
export const StyledChatInput = () => {
|
|
158
|
+
const handleSubmit = (message) => {
|
|
159
|
+
console.log('Message submitted:', message);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<View width="100%">
|
|
164
|
+
<ChatInput
|
|
165
|
+
onSubmit={handleSubmit}
|
|
166
|
+
placeholder="Type a message..."
|
|
167
|
+
shape="pillShaped"
|
|
168
|
+
variant="outline"
|
|
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>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### **With Agent Controls**
|
|
187
|
+
```tsx
|
|
188
|
+
import React, { useState } from 'react';
|
|
189
|
+
import { ChatInput } from '@app-studio/web';
|
|
190
|
+
import { View } from 'app-studio';
|
|
191
|
+
|
|
192
|
+
export const ChatInputWithAgent = () => {
|
|
193
|
+
const [isAgentRunning, setIsAgentRunning] = useState(false);
|
|
194
|
+
|
|
195
|
+
const handleSubmit = (message, options) => {
|
|
196
|
+
console.log('Message submitted:', message);
|
|
197
|
+
console.log('Options:', options);
|
|
198
|
+
|
|
199
|
+
// Start the agent
|
|
200
|
+
setIsAgentRunning(true);
|
|
201
|
+
|
|
202
|
+
// Simulate agent running for 5 seconds
|
|
203
|
+
setTimeout(() => {
|
|
204
|
+
setIsAgentRunning(false);
|
|
205
|
+
}, 5000);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const handleStopAgent = () => {
|
|
209
|
+
console.log('Agent stopped');
|
|
210
|
+
setIsAgentRunning(false);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<View width="100%">
|
|
215
|
+
<ChatInput
|
|
216
|
+
onSubmit={handleSubmit}
|
|
217
|
+
isAgentRunning={isAgentRunning}
|
|
218
|
+
onStopAgent={handleStopAgent}
|
|
219
|
+
/>
|
|
220
|
+
</View>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### **Props**
|
|
226
|
+
|
|
227
|
+
| Prop | Type | Default | Description |
|
|
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:
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
<ChatInput
|
|
267
|
+
// ...other props
|
|
268
|
+
views={{
|
|
269
|
+
container: { /* styles for the main container */ },
|
|
270
|
+
content: { /* styles for the content wrapper */ },
|
|
271
|
+
editableInput: { /* styles for the editable input */ },
|
|
272
|
+
header: { /* styles for the header */ },
|
|
273
|
+
title: { /* styles for the title */ },
|
|
274
|
+
guideTip: { /* styles for the guide tip */ },
|
|
275
|
+
promptExamples: { /* styles for the prompt examples container */ },
|
|
276
|
+
promptExampleItem: { /* styles for each prompt example item */ },
|
|
277
|
+
attachments: { /* styles for the attachments container */ },
|
|
278
|
+
attachmentItem: { /* styles for each attachment item */ },
|
|
279
|
+
attachmentName: { /* styles for attachment file names */ },
|
|
280
|
+
attachmentSize: { /* styles for attachment file sizes */ },
|
|
281
|
+
attachmentRemove: { /* styles for attachment remove buttons */ },
|
|
282
|
+
submitButton: { /* styles for the submit button */ },
|
|
283
|
+
fileButton: { /* styles for the file upload button */ },
|
|
284
|
+
}}
|
|
285
|
+
/>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### **Accessibility**
|
|
289
|
+
|
|
290
|
+
The ChatInput component implements the following accessibility features:
|
|
291
|
+
|
|
292
|
+
- Keyboard navigation for submitting messages (Enter key)
|
|
293
|
+
- ARIA attributes for interactive elements
|
|
294
|
+
- Focus management for the input field
|
|
295
|
+
- Proper contrast for text and buttons
|
|
296
|
+
|
|
297
|
+
### **Best Practices**
|
|
298
|
+
|
|
299
|
+
**General Usage:**
|
|
300
|
+
- Provide clear placeholder text to guide users
|
|
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
|
|
304
|
+
|
|
305
|
+
**File Upload Best Practices:**
|
|
306
|
+
- Handle file uploads appropriately on the server side
|
|
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
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
**Accessibility Considerations:**
|
|
313
|
+
- Ensure file upload buttons are keyboard accessible
|
|
314
|
+
- Use proper ARIA labels for interactive elements
|
|
315
|
+
- Test with screen readers for file upload functionality
|
|
316
|
+
|
|
317
|
+
### **Demo & Testing**
|
|
318
|
+
|
|
319
|
+
The ChatInput component includes a demo page with simulate upload functionality for testing:
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
// Available in src/pages/chat.page.tsx
|
|
323
|
+
import React, { useState } from 'react';
|
|
324
|
+
import { ChatInput } from '@app-studio/web';
|
|
325
|
+
import { Button } from 'app-studio';
|
|
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
|
+
|
|
355
|
+
return (
|
|
356
|
+
<>
|
|
357
|
+
<Button onClick={simulateUpload} disabled={isSimulatingUpload}>
|
|
358
|
+
{isSimulatingUpload ? `Uploading... ${simulationProgress}%` : 'Simulate Upload'}
|
|
359
|
+
</Button>
|
|
360
|
+
|
|
361
|
+
<ChatInput
|
|
362
|
+
onSubmit={(message) => console.log('Message:', message)}
|
|
363
|
+
/>
|
|
364
|
+
</>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
```
|
|
368
|
+
|
|
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
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
A customizable checkbox form element with optional label and various views.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { Checkbox } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Default**
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
|
|
14
|
+
import { Checkbox } from '../Checkbox';
|
|
15
|
+
|
|
16
|
+
export const DefaultCheckbox = () => <Checkbox label="option" />;
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### **colorScheme**
|
|
21
|
+
Optional color scheme string that might allow customization of the checkbox's appearance.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { Vertical } from 'app-studio';
|
|
26
|
+
|
|
27
|
+
import { Checkbox } from '../Checkbox';
|
|
28
|
+
|
|
29
|
+
export const ColorCheckbox = () => (
|
|
30
|
+
<Vertical gap={15}>
|
|
31
|
+
{[
|
|
32
|
+
'theme.primary',
|
|
33
|
+
'theme.secondary',
|
|
34
|
+
'theme.error',
|
|
35
|
+
'theme.success',
|
|
36
|
+
'theme.warning',
|
|
37
|
+
].map((color) => (
|
|
38
|
+
<Checkbox
|
|
39
|
+
key={color}
|
|
40
|
+
colorScheme={color}
|
|
41
|
+
label={color}
|
|
42
|
+
defaultIsSelected
|
|
43
|
+
/>
|
|
44
|
+
))}
|
|
45
|
+
</Vertical>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### **shadow**
|
|
51
|
+
An optional shadow or elevation effect that can be applied to the Checkbox component, accepting either a Shadow, Elevation, or generic CSSProperties object.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import React from 'react';
|
|
55
|
+
import { Checkbox } from '../../../Form/Checkbox/Checkbox';
|
|
56
|
+
|
|
57
|
+
export const ShadowCheckbox = () => (
|
|
58
|
+
<Checkbox
|
|
59
|
+
id="shadowCheckbox"
|
|
60
|
+
shadow={{ boxShadow: 'rgb(249, 115, 22) 0px 4px 14px 0px' }}
|
|
61
|
+
defaultIsSelected
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# ColorInput
|
|
2
|
+
|
|
3
|
+
A form-integrated color picker component that allows users to select colors from a predefined palette or enter custom color values.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
```tsx
|
|
7
|
+
import { ColorInput } from '@app-studio/web';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **Basic Usage**
|
|
11
|
+
A simple color input with default settings.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import React, { useState } from 'react';
|
|
15
|
+
import { ColorInput } from '../ColorInput';
|
|
16
|
+
|
|
17
|
+
export const BasicColorInput = () => {
|
|
18
|
+
const [color, setColor] = useState('color.blue.500');
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<ColorInput
|
|
22
|
+
label="Background Color"
|
|
23
|
+
value={color}
|
|
24
|
+
onChange={setColor}
|
|
25
|
+
placeholder="Select a color"
|
|
26
|
+
helperText="Choose a background color for your theme"
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### **Variants**
|
|
33
|
+
Different visual styles for the color input.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import React from 'react';
|
|
37
|
+
import { Vertical } from 'app-studio';
|
|
38
|
+
import { ColorInput } from '../ColorInput';
|
|
39
|
+
|
|
40
|
+
export const ColorInputVariants = () => {
|
|
41
|
+
return (
|
|
42
|
+
<Vertical gap={16} width="300px">
|
|
43
|
+
<ColorInput
|
|
44
|
+
label="Default Variant"
|
|
45
|
+
variant="default"
|
|
46
|
+
defaultValue="color.blue.500"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<ColorInput
|
|
50
|
+
label="Outline Variant"
|
|
51
|
+
variant="outline"
|
|
52
|
+
defaultValue="color.green.500"
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<ColorInput
|
|
56
|
+
label="None Variant"
|
|
57
|
+
variant="none"
|
|
58
|
+
defaultValue="color.purple.500"
|
|
59
|
+
/>
|
|
60
|
+
</Vertical>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### **Sizes**
|
|
66
|
+
Different sizes for the color input.
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import React from 'react';
|
|
70
|
+
import { Vertical } from 'app-studio';
|
|
71
|
+
import { ColorInput } from '../ColorInput';
|
|
72
|
+
|
|
73
|
+
export const ColorInputSizes = () => {
|
|
74
|
+
return (
|
|
75
|
+
<Vertical gap={16} width="300px">
|
|
76
|
+
<ColorInput label="Extra Small" size="xs" defaultValue="color.red.500" />
|
|
77
|
+
<ColorInput label="Small" size="sm" defaultValue="color.orange.500" />
|
|
78
|
+
<ColorInput label="Medium" size="md" defaultValue="color.yellow.500" />
|
|
79
|
+
<ColorInput label="Large" size="lg" defaultValue="color.green.500" />
|
|
80
|
+
<ColorInput label="Extra Large" size="xl" defaultValue="color.blue.500" />
|
|
81
|
+
</Vertical>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### **Custom Colors**
|
|
87
|
+
Color input with custom color palette and options.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import React, { useState } from 'react';
|
|
91
|
+
import { ColorInput } from '../ColorInput';
|
|
92
|
+
|
|
93
|
+
export const CustomColorInput = () => {
|
|
94
|
+
const [color, setColor] = useState('');
|
|
95
|
+
|
|
96
|
+
const customColors = [
|
|
97
|
+
{ name: 'Brand Primary', value: '#3B82F6' },
|
|
98
|
+
{ name: 'Brand Secondary', value: '#10B981' },
|
|
99
|
+
{ name: 'Brand Accent', value: '#F59E0B' },
|
|
100
|
+
{ name: 'Brand Dark', value: '#1F2937' },
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<ColorInput
|
|
105
|
+
label="Brand Color"
|
|
106
|
+
value={color}
|
|
107
|
+
onChange={setColor}
|
|
108
|
+
predefinedColors={customColors}
|
|
109
|
+
showCustomInput={true}
|
|
110
|
+
showRecentColors={true}
|
|
111
|
+
helperText="Choose from brand colors or enter a custom color"
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### **Form Integration**
|
|
118
|
+
Color input integrated with form handling.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import React, { useState } from 'react';
|
|
122
|
+
import { Vertical, Horizontal } from 'app-studio';
|
|
123
|
+
import { ColorInput } from '../ColorInput';
|
|
124
|
+
import { Button } from '../../Button/Button';
|
|
125
|
+
import { Text } from '../../Text/Text';
|
|
126
|
+
|
|
127
|
+
export const ColorInputForm = () => {
|
|
128
|
+
const [backgroundColor, setBackgroundColor] = useState('color.blue.500');
|
|
129
|
+
const [textColor, setTextColor] = useState('color.white');
|
|
130
|
+
|
|
131
|
+
const handleSubmit = (e) => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
alert(`Background: ${backgroundColor}, Text: ${textColor}`);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<form onSubmit={handleSubmit}>
|
|
138
|
+
<Vertical gap={16} width="400px">
|
|
139
|
+
<ColorInput
|
|
140
|
+
label="Background Color"
|
|
141
|
+
value={backgroundColor}
|
|
142
|
+
onChange={setBackgroundColor}
|
|
143
|
+
helperText="Choose the background color"
|
|
144
|
+
/>
|
|
145
|
+
|
|
146
|
+
<ColorInput
|
|
147
|
+
label="Text Color"
|
|
148
|
+
value={textColor}
|
|
149
|
+
onChange={setTextColor}
|
|
150
|
+
helperText="Choose the text color"
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
{/* Preview */}
|
|
154
|
+
<div
|
|
155
|
+
style={{
|
|
156
|
+
padding: '16px',
|
|
157
|
+
borderRadius: '8px',
|
|
158
|
+
backgroundColor: backgroundColor,
|
|
159
|
+
color: textColor,
|
|
160
|
+
border: '1px solid #e5e7eb'
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<Text fontWeight="bold">Preview</Text>
|
|
164
|
+
<Text>This is how your theme will look</Text>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<Horizontal gap={8}>
|
|
168
|
+
<Button type="submit" variant="filled">
|
|
169
|
+
Apply Theme
|
|
170
|
+
</Button>
|
|
171
|
+
<Button
|
|
172
|
+
type="button"
|
|
173
|
+
variant="outline"
|
|
174
|
+
onClick={() => {
|
|
175
|
+
setBackgroundColor('color.blue.500');
|
|
176
|
+
setTextColor('color.white');
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
Reset
|
|
180
|
+
</Button>
|
|
181
|
+
</Horizontal>
|
|
182
|
+
</Vertical>
|
|
183
|
+
</form>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### **Props**
|
|
189
|
+
|
|
190
|
+
| Prop | Type | Default | Description |
|
|
191
|
+
|------|------|---------|-------------|
|
|
192
|
+
| `label` | `string` | - | Label text for the color input |
|
|
193
|
+
| `value` | `string` | - | Controlled value of the color input |
|
|
194
|
+
| `defaultValue` | `string` | `''` | Default value for uncontrolled usage |
|
|
195
|
+
| `onChange` | `(color: string) => void` | - | Callback when color changes |
|
|
196
|
+
| `placeholder` | `string` | `'Select a color'` | Placeholder text |
|
|
197
|
+
| `helperText` | `string` | - | Helper text below the input |
|
|
198
|
+
| `error` | `boolean \| string` | `false` | Error state or message |
|
|
199
|
+
| `isDisabled` | `boolean` | `false` | Whether the input is disabled |
|
|
200
|
+
| `isReadOnly` | `boolean` | `false` | Whether the input is read-only |
|
|
201
|
+
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Size of the input |
|
|
202
|
+
| `variant` | `'default' \| 'outline' \| 'none'` | `'default'` | Visual variant |
|
|
203
|
+
| `shape` | `'default' \| 'sharp' \| 'rounded' \| 'pillShaped'` | `'default'` | Border radius style |
|
|
204
|
+
| `predefinedColors` | `PredefinedColor[]` | Default palette | Array of predefined colors |
|
|
205
|
+
| `showCustomInput` | `boolean` | `true` | Whether to show custom color input |
|
|
206
|
+
| `showRecentColors` | `boolean` | `true` | Whether to show recent colors |
|
|
207
|
+
| `maxRecentColors` | `number` | `8` | Maximum number of recent colors |
|
|
208
|
+
| `closeOnSelect` | `boolean` | `true` | Whether to close dropdown on selection |
|
|
209
|
+
| `views` | `ColorInputStyles` | `{}` | Custom styling object |
|