@app-studio/web 0.9.41 → 0.9.43
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/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,426 +1,280 @@
|
|
|
1
1
|
# Uploader
|
|
2
2
|
|
|
3
|
-
A versatile file upload component with support for
|
|
3
|
+
A versatile file upload component with support for images, videos, and files, featuring drag-and-drop, preview, progress tracking, and validation.
|
|
4
4
|
|
|
5
5
|
### **Import**
|
|
6
|
-
```tsx
|
|
7
|
-
import { Uploader } from '@app-studio/web';
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
### **Basic Usage**
|
|
11
6
|
```tsx
|
|
12
|
-
import React from 'react';
|
|
13
7
|
import { Uploader } from '@app-studio/web';
|
|
14
|
-
import { UploadIcon } from '@app-studio/web';
|
|
15
|
-
|
|
16
|
-
export const BasicUploader = () => {
|
|
17
|
-
const handleFileSelect = (file: File) => {
|
|
18
|
-
console.log('Selected file:', file);
|
|
19
|
-
// Handle the uploaded file
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Uploader
|
|
24
|
-
icon={<UploadIcon widthHeight={32} />}
|
|
25
|
-
text="Click to upload a file"
|
|
26
|
-
onFileSelect={handleFileSelect}
|
|
27
|
-
maxSize={10 * 1024 * 1024} // 10MB limit
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
8
|
```
|
|
32
9
|
|
|
33
|
-
### **
|
|
10
|
+
### **Default**
|
|
34
11
|
```tsx
|
|
35
|
-
import React
|
|
12
|
+
import React from 'react';
|
|
36
13
|
import { Uploader } from '@app-studio/web';
|
|
37
|
-
import { UploadIcon } from '@app-studio/web';
|
|
38
14
|
|
|
39
|
-
export const
|
|
40
|
-
|
|
15
|
+
export const DefaultUploader = () => (
|
|
16
|
+
<Uploader
|
|
17
|
+
onFileSelect={(file) => console.log('Selected:', file)}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
```
|
|
41
21
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
setSelectedFiles(files);
|
|
45
|
-
};
|
|
22
|
+
### **accept**
|
|
23
|
+
Specifies which file types are accepted for upload.
|
|
46
24
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
icon={<UploadIcon widthHeight={32} />}
|
|
50
|
-
text="Click to upload multiple files"
|
|
51
|
-
multiple={true}
|
|
52
|
-
onMultipleFileSelect={handleMultipleFileSelect}
|
|
53
|
-
maxSize={50 * 1024 * 1024} // 50MB limit per file
|
|
54
|
-
accept="image/*,video/*,.pdf,.doc,.docx"
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
```
|
|
25
|
+
- **Type:** `string`
|
|
26
|
+
- **Default:** `'*/*'`
|
|
59
27
|
|
|
60
|
-
### **Image Upload with Preview**
|
|
61
28
|
```tsx
|
|
62
|
-
import React
|
|
29
|
+
import React from 'react';
|
|
63
30
|
import { Uploader } from '@app-studio/web';
|
|
64
|
-
import {
|
|
65
|
-
|
|
66
|
-
export const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Simulate upload progress
|
|
74
|
-
setIsLoading(true);
|
|
75
|
-
setProgress(0);
|
|
76
|
-
|
|
77
|
-
const interval = setInterval(() => {
|
|
78
|
-
setProgress((prev) => {
|
|
79
|
-
if (prev >= 100) {
|
|
80
|
-
clearInterval(interval);
|
|
81
|
-
setIsLoading(false);
|
|
82
|
-
return 100;
|
|
83
|
-
}
|
|
84
|
-
return prev + 10;
|
|
85
|
-
});
|
|
86
|
-
}, 200);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Uploader
|
|
91
|
-
accept="image/*"
|
|
92
|
-
icon={<ImageIcon widthHeight={32} />}
|
|
93
|
-
text="Upload Image"
|
|
94
|
-
onFileSelect={handleImageSelect}
|
|
95
|
-
isLoading={isLoading}
|
|
96
|
-
progress={progress}
|
|
97
|
-
fileType="image"
|
|
98
|
-
maxSize={5 * 1024 * 1024} // 5MB limit
|
|
99
|
-
containerProps={{
|
|
100
|
-
height: progress === 100 ? '200px' : 'auto',
|
|
101
|
-
minHeight: '120px'
|
|
102
|
-
}}
|
|
31
|
+
import { Vertical } from 'app-studio';
|
|
32
|
+
|
|
33
|
+
export const FileTypeUploader = () => (
|
|
34
|
+
<Vertical gap={15}>
|
|
35
|
+
<Uploader
|
|
36
|
+
accept="image/*"
|
|
37
|
+
onFileSelect={(file) => console.log(file)}
|
|
38
|
+
text="Upload Images"
|
|
103
39
|
/>
|
|
104
|
-
|
|
105
|
-
|
|
40
|
+
<Uploader
|
|
41
|
+
accept="video/*"
|
|
42
|
+
onFileSelect={(file) => console.log(file)}
|
|
43
|
+
text="Upload Videos"
|
|
44
|
+
/>
|
|
45
|
+
<Uploader
|
|
46
|
+
accept=".pdf,.doc,.docx"
|
|
47
|
+
onFileSelect={(file) => console.log(file)}
|
|
48
|
+
text="Upload Documents"
|
|
49
|
+
/>
|
|
50
|
+
</Vertical>
|
|
51
|
+
);
|
|
106
52
|
```
|
|
107
53
|
|
|
108
|
-
### **
|
|
54
|
+
### **multiple**
|
|
55
|
+
Allow multiple file selection.
|
|
56
|
+
|
|
57
|
+
- **Type:** `boolean`
|
|
58
|
+
- **Default:** `false`
|
|
59
|
+
|
|
109
60
|
```tsx
|
|
110
|
-
import React
|
|
61
|
+
import React from 'react';
|
|
111
62
|
import { Uploader } from '@app-studio/web';
|
|
112
|
-
import { VideoIcon } from '@app-studio/web';
|
|
113
63
|
|
|
114
|
-
export const
|
|
115
|
-
|
|
116
|
-
|
|
64
|
+
export const MultipleUploader = () => (
|
|
65
|
+
<Uploader
|
|
66
|
+
multiple
|
|
67
|
+
onMultipleFileSelect={(files) => {
|
|
68
|
+
console.log(`Selected ${files.length} files`);
|
|
69
|
+
}}
|
|
70
|
+
text="Upload Multiple Files"
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
```
|
|
117
74
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// Simulate upload progress
|
|
122
|
-
setIsLoading(true);
|
|
123
|
-
setProgress(0);
|
|
124
|
-
|
|
125
|
-
const interval = setInterval(() => {
|
|
126
|
-
setProgress((prev) => {
|
|
127
|
-
if (prev >= 100) {
|
|
128
|
-
clearInterval(interval);
|
|
129
|
-
setIsLoading(false);
|
|
130
|
-
return 100;
|
|
131
|
-
}
|
|
132
|
-
return prev + 5;
|
|
133
|
-
});
|
|
134
|
-
}, 300);
|
|
135
|
-
};
|
|
75
|
+
### **maxSize**
|
|
76
|
+
Maximum file size in bytes.
|
|
136
77
|
|
|
137
|
-
|
|
138
|
-
<Uploader
|
|
139
|
-
accept="video/*"
|
|
140
|
-
icon={<VideoIcon widthHeight={32} />}
|
|
141
|
-
text="Upload Video"
|
|
142
|
-
onFileSelect={handleVideoSelect}
|
|
143
|
-
isLoading={isLoading}
|
|
144
|
-
progress={progress}
|
|
145
|
-
fileType="video"
|
|
146
|
-
maxSize={100 * 1024 * 1024} // 100MB limit
|
|
147
|
-
containerProps={{
|
|
148
|
-
height: progress === 100 ? '200px' : 'auto',
|
|
149
|
-
minHeight: '120px'
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
};
|
|
154
|
-
```
|
|
78
|
+
- **Type:** `number`
|
|
155
79
|
|
|
156
|
-
### **File Validation**
|
|
157
80
|
```tsx
|
|
158
81
|
import React from 'react';
|
|
159
82
|
import { Uploader } from '@app-studio/web';
|
|
160
|
-
import { UploadIcon } from '@app-studio/web';
|
|
161
83
|
|
|
162
|
-
export const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
84
|
+
export const SizeLimitUploader = () => (
|
|
85
|
+
<Uploader
|
|
86
|
+
maxSize={5 * 1024 * 1024} // 5MB
|
|
87
|
+
onFileSelect={(file) => console.log(file)}
|
|
88
|
+
text="Max 5MB"
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
```
|
|
168
92
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
93
|
+
### **validateFile**
|
|
94
|
+
Custom validation function for uploaded files.
|
|
172
95
|
|
|
173
|
-
|
|
174
|
-
return 'File name must be less than 50 characters';
|
|
175
|
-
}
|
|
96
|
+
- **Type:** `(file: File) => string | null`
|
|
176
97
|
|
|
177
|
-
|
|
178
|
-
|
|
98
|
+
```tsx
|
|
99
|
+
import React from 'react';
|
|
100
|
+
import { Uploader } from '@app-studio/web';
|
|
179
101
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
102
|
+
export const ValidatedUploader = () => (
|
|
103
|
+
<Uploader
|
|
104
|
+
validateFile={(file) => {
|
|
105
|
+
if (file.size > 10 * 1024 * 1024) {
|
|
106
|
+
return 'File must be less than 10MB';
|
|
107
|
+
}
|
|
108
|
+
if (!file.type.startsWith('image/')) {
|
|
109
|
+
return 'Only images are allowed';
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}}
|
|
113
|
+
onFileSelect={(file) => console.log(file)}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
```
|
|
183
117
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
// Show error message to user
|
|
187
|
-
};
|
|
118
|
+
### **isLoading**
|
|
119
|
+
Show loading state during upload.
|
|
188
120
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
icon={<UploadIcon widthHeight={32} />}
|
|
192
|
-
text="Upload Image (Max 10MB)"
|
|
193
|
-
accept="image/*"
|
|
194
|
-
onFileSelect={handleFileSelect}
|
|
195
|
-
validateFile={validateFile}
|
|
196
|
-
onError={handleError}
|
|
197
|
-
maxSize={10 * 1024 * 1024}
|
|
198
|
-
/>
|
|
199
|
-
);
|
|
200
|
-
};
|
|
201
|
-
```
|
|
121
|
+
- **Type:** `boolean`
|
|
122
|
+
- **Default:** `false`
|
|
202
123
|
|
|
203
|
-
### **Custom Rendering**
|
|
204
124
|
```tsx
|
|
205
|
-
import React from 'react';
|
|
125
|
+
import React, { useState } from 'react';
|
|
206
126
|
import { Uploader } from '@app-studio/web';
|
|
207
|
-
import { View, Text } from '@app-studio/web';
|
|
208
|
-
import { CheckIcon, ErrorIcon } from '@app-studio/web';
|
|
209
|
-
|
|
210
|
-
export const CustomUploader = () => {
|
|
211
|
-
const handleFileSelect = (file: File) => {
|
|
212
|
-
console.log('File selected:', file);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const customErrorRenderer = ({ errorMessage }: any) => (
|
|
216
|
-
<View
|
|
217
|
-
padding={8}
|
|
218
|
-
backgroundColor="color.red.50"
|
|
219
|
-
borderRadius={4}
|
|
220
|
-
marginTop={8}
|
|
221
|
-
>
|
|
222
|
-
<Text color="color.red.600" fontSize={12}>
|
|
223
|
-
<ErrorIcon widthHeight={16} /> {errorMessage}
|
|
224
|
-
</Text>
|
|
225
|
-
</View>
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
const customFileRenderer = ({ selectedFile }: any) => (
|
|
229
|
-
<View
|
|
230
|
-
padding={12}
|
|
231
|
-
backgroundColor="color.green.50"
|
|
232
|
-
borderRadius={4}
|
|
233
|
-
marginTop={8}
|
|
234
|
-
>
|
|
235
|
-
<Text color="color.green.700" fontSize={14}>
|
|
236
|
-
<CheckIcon widthHeight={16} /> {selectedFile.name}
|
|
237
|
-
</Text>
|
|
238
|
-
<Text color="color.green.600" fontSize={12}>
|
|
239
|
-
Size: {Math.round(selectedFile.size / 1024)} KB
|
|
240
|
-
</Text>
|
|
241
|
-
</View>
|
|
242
|
-
);
|
|
243
127
|
|
|
128
|
+
export const LoadingUploader = () => {
|
|
129
|
+
const [loading, setLoading] = useState(false);
|
|
130
|
+
|
|
244
131
|
return (
|
|
245
|
-
<Uploader
|
|
246
|
-
|
|
247
|
-
onFileSelect={
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
container: {
|
|
252
|
-
border: '2px dashed',
|
|
253
|
-
borderColor: 'color.blue.300',
|
|
254
|
-
backgroundColor: 'color.blue.50',
|
|
255
|
-
borderRadius: 12,
|
|
256
|
-
padding: 24,
|
|
257
|
-
},
|
|
258
|
-
text: {
|
|
259
|
-
color: 'color.blue.700',
|
|
260
|
-
fontWeight: 'medium',
|
|
261
|
-
},
|
|
132
|
+
<Uploader
|
|
133
|
+
isLoading={loading}
|
|
134
|
+
onFileSelect={(file) => {
|
|
135
|
+
setLoading(true);
|
|
136
|
+
// Simulate upload
|
|
137
|
+
setTimeout(() => setLoading(false), 2000);
|
|
262
138
|
}}
|
|
263
139
|
/>
|
|
264
140
|
);
|
|
265
141
|
};
|
|
266
142
|
```
|
|
267
143
|
|
|
268
|
-
### **
|
|
269
|
-
|
|
144
|
+
### **progress**
|
|
145
|
+
Upload progress percentage (0-100).
|
|
146
|
+
|
|
147
|
+
- **Type:** `number`
|
|
148
|
+
- **Default:** `0`
|
|
270
149
|
|
|
271
150
|
```tsx
|
|
272
151
|
import React, { useState } from 'react';
|
|
273
|
-
import {
|
|
274
|
-
import { View } from '@app-studio/web';
|
|
275
|
-
|
|
276
|
-
export const ChatWithFileUpload = () => {
|
|
277
|
-
const [inputValue, setInputValue] = useState('');
|
|
278
|
-
|
|
279
|
-
const handleSubmit = (message: string, options?: any) => {
|
|
280
|
-
console.log('Message with files:', message);
|
|
281
|
-
console.log('Upload options:', options);
|
|
282
|
-
setInputValue('');
|
|
283
|
-
};
|
|
152
|
+
import { Uploader } from '@app-studio/web';
|
|
284
153
|
|
|
154
|
+
export const ProgressUploader = () => {
|
|
155
|
+
const [progress, setProgress] = useState(0);
|
|
156
|
+
|
|
285
157
|
return (
|
|
286
|
-
<
|
|
287
|
-
<
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
158
|
+
<Uploader
|
|
159
|
+
isLoading={progress > 0 && progress < 100}
|
|
160
|
+
progress={progress}
|
|
161
|
+
onFileSelect={(file) => {
|
|
162
|
+
// Simulate upload progress
|
|
163
|
+
let current = 0;
|
|
164
|
+
const interval = setInterval(() => {
|
|
165
|
+
current += 10;
|
|
166
|
+
setProgress(current);
|
|
167
|
+
if (current >= 100) clearInterval(interval);
|
|
168
|
+
}, 200);
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
295
171
|
);
|
|
296
172
|
};
|
|
297
173
|
```
|
|
298
174
|
|
|
299
|
-
### **
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
| accept | string | '*/*' | File types to accept (MIME types) |
|
|
304
|
-
| icon | React.ReactNode | undefined | Icon to display in the upload area |
|
|
305
|
-
| text | string | undefined | Text to display in the upload area |
|
|
306
|
-
| maxSize | number | 100MB | Maximum file size in bytes |
|
|
307
|
-
| onFileSelect | `(file: File) => void` | undefined | Callback when a single file is selected |
|
|
308
|
-
| onMultipleFileSelect | `(files: File[]) => void` | undefined | Callback when multiple files are selected |
|
|
309
|
-
| validateFile | `(file: File) => string \| null` | undefined | Custom validation function |
|
|
310
|
-
| isLoading | boolean | false | Whether the uploader is in loading state |
|
|
311
|
-
| progress | number | 0 | Upload progress (0-100) |
|
|
312
|
-
| fileType | `'video' \| 'image' \| 'file'` | undefined | Type of file for preview rendering |
|
|
313
|
-
| multiple | boolean | false | Allow multiple file selection |
|
|
314
|
-
| onError | `(error: string) => void` | undefined | Error callback function |
|
|
315
|
-
| thumbnail | string | undefined | Thumbnail URL for preview |
|
|
316
|
-
|
|
317
|
-
### **Custom Rendering Props**
|
|
318
|
-
|
|
319
|
-
| Prop | Type | Description |
|
|
320
|
-
| ---- | ---- | ----------- |
|
|
321
|
-
| renderVideo | `(props: any) => React.ReactNode` | Custom video preview renderer |
|
|
322
|
-
| renderText | `(props: any) => React.ReactNode` | Custom text renderer |
|
|
323
|
-
| renderImage | `(props: any) => React.ReactNode` | Custom image preview renderer |
|
|
324
|
-
| renderError | `(props: any) => React.ReactNode` | Custom error message renderer |
|
|
325
|
-
| renderFile | `(props: any) => React.ReactNode` | Custom file info renderer |
|
|
326
|
-
| renderProgress | `(props: any) => React.ReactNode` | Custom progress indicator renderer |
|
|
327
|
-
|
|
328
|
-
### **View Customization**
|
|
329
|
-
|
|
330
|
-
The `views` prop allows you to customize different parts of the component:
|
|
175
|
+
### **fileType**
|
|
176
|
+
Explicitly set the file type for rendering.
|
|
177
|
+
|
|
178
|
+
- **Type:** `'image' | 'video' | 'file'`
|
|
331
179
|
|
|
332
180
|
```tsx
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
181
|
+
import React from 'react';
|
|
182
|
+
import { Uploader } from '@app-studio/web';
|
|
183
|
+
import { Horizontal } from 'app-studio';
|
|
184
|
+
|
|
185
|
+
export const TypedUploaders = () => (
|
|
186
|
+
<Horizontal gap={15}>
|
|
187
|
+
<Uploader fileType="image" text="Image" />
|
|
188
|
+
<Uploader fileType="video" text="Video" />
|
|
189
|
+
<Uploader fileType="file" text="File" />
|
|
190
|
+
</Horizontal>
|
|
191
|
+
);
|
|
343
192
|
```
|
|
344
193
|
|
|
345
|
-
### **
|
|
346
|
-
|
|
347
|
-
The Uploader automatically detects file types and renders appropriate previews:
|
|
348
|
-
|
|
349
|
-
- **Images**: Shows image preview with proper scaling
|
|
350
|
-
- **Videos**: Generates thumbnail and shows video preview
|
|
351
|
-
- **Files**: Displays file name and size information
|
|
352
|
-
|
|
353
|
-
### **Error Handling**
|
|
354
|
-
|
|
355
|
-
The component provides comprehensive error handling:
|
|
356
|
-
|
|
357
|
-
- **File size validation**: Automatic validation against `maxSize` prop
|
|
358
|
-
- **Custom validation**: Use `validateFile` prop for custom rules
|
|
359
|
-
- **Error callbacks**: Handle errors with `onError` callback
|
|
360
|
-
- **Visual feedback**: Error messages displayed in the UI
|
|
194
|
+
### **icon**
|
|
195
|
+
Custom icon to display in the uploader.
|
|
361
196
|
|
|
362
|
-
|
|
197
|
+
- **Type:** `React.ReactNode`
|
|
363
198
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
199
|
+
```tsx
|
|
200
|
+
import React from 'react';
|
|
201
|
+
import { Uploader } from '@app-studio/web';
|
|
202
|
+
import { UploadIcon } from '@app-studio/web';
|
|
368
203
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
204
|
+
export const CustomIconUploader = () => (
|
|
205
|
+
<Uploader
|
|
206
|
+
icon={<UploadIcon widthHeight={32} />}
|
|
207
|
+
text="Click to upload"
|
|
208
|
+
onFileSelect={(file) => console.log(file)}
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
```
|
|
373
212
|
|
|
374
|
-
**
|
|
375
|
-
|
|
376
|
-
- Use appropriate icons to indicate file types
|
|
377
|
-
- Show progress feedback for large uploads
|
|
378
|
-
- Handle errors gracefully with user-friendly messages
|
|
213
|
+
### **text**
|
|
214
|
+
Text to display in the uploader.
|
|
379
215
|
|
|
380
|
-
**
|
|
381
|
-
- Consider lazy loading for large file previews
|
|
382
|
-
- Implement proper cleanup for object URLs
|
|
383
|
-
- Use appropriate file size limits to prevent memory issues
|
|
216
|
+
- **Type:** `string`
|
|
384
217
|
|
|
385
|
-
|
|
218
|
+
```tsx
|
|
219
|
+
import React from 'react';
|
|
220
|
+
import { Uploader } from '@app-studio/web';
|
|
386
221
|
|
|
387
|
-
|
|
222
|
+
export const CustomTextUploader = () => (
|
|
223
|
+
<Uploader
|
|
224
|
+
text="Drag & drop your files here"
|
|
225
|
+
onFileSelect={(file) => console.log(file)}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
```
|
|
388
229
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
- Focus management
|
|
392
|
-
- Proper contrast for visual elements
|
|
230
|
+
### **views**
|
|
231
|
+
Custom styles for different parts of the uploader.
|
|
393
232
|
|
|
394
|
-
|
|
233
|
+
- **Type:** `{ container?: ViewProps; view?: ViewProps; image?: ImageProps; horizontal?: ViewProps; text?: ViewProps }`
|
|
395
234
|
|
|
396
|
-
**With Form Libraries:**
|
|
397
235
|
```tsx
|
|
398
|
-
|
|
399
|
-
import {
|
|
400
|
-
|
|
401
|
-
const FormikUploader = ({ name, ...props }) => {
|
|
402
|
-
const { setFieldValue } = useFormikContext();
|
|
236
|
+
import React from 'react';
|
|
237
|
+
import { Uploader } from '@app-studio/web';
|
|
403
238
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
239
|
+
export const StyledUploader = () => (
|
|
240
|
+
<Uploader
|
|
241
|
+
onFileSelect={(file) => console.log(file)}
|
|
242
|
+
views={{
|
|
243
|
+
container: {
|
|
244
|
+
borderRadius: 12,
|
|
245
|
+
borderColor: '#3b82f6',
|
|
246
|
+
borderWidth: 2,
|
|
247
|
+
},
|
|
248
|
+
text: {
|
|
249
|
+
color: '#3b82f6',
|
|
250
|
+
fontSize: 16,
|
|
251
|
+
}
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
);
|
|
411
255
|
```
|
|
412
256
|
|
|
413
|
-
**
|
|
414
|
-
|
|
415
|
-
// Integration with Redux or other state management
|
|
416
|
-
const ConnectedUploader = () => {
|
|
417
|
-
const dispatch = useDispatch();
|
|
257
|
+
### **Custom Render Functions**
|
|
258
|
+
Override default rendering for different file types.
|
|
418
259
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
260
|
+
```tsx
|
|
261
|
+
import React from 'react';
|
|
262
|
+
import { Uploader } from '@app-studio/web';
|
|
263
|
+
import { Text, View } from 'app-studio';
|
|
264
|
+
|
|
265
|
+
export const CustomRenderUploader = () => (
|
|
266
|
+
<Uploader
|
|
267
|
+
onFileSelect={(file) => console.log(file)}
|
|
268
|
+
renderImage={(props) => (
|
|
269
|
+
<View>
|
|
270
|
+
<Text>Custom Image Preview</Text>
|
|
271
|
+
{/* Custom image rendering */}
|
|
272
|
+
</View>
|
|
273
|
+
)}
|
|
274
|
+
renderError={(props) => (
|
|
275
|
+
<Text color="error">{props.errorMessage}</Text>
|
|
276
|
+
)}
|
|
277
|
+
/>
|
|
278
|
+
);
|
|
426
279
|
```
|
|
280
|
+
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Authentication guard props
|
|
4
|
-
*/
|
|
5
|
-
interface AuthGuardProps {
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
fallback?: ReactNode;
|
|
8
|
-
requireAuth?: boolean;
|
|
9
|
-
autoLogin?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Authentication guard component
|
|
13
|
-
*
|
|
14
|
-
* Protects routes by checking authentication status and auto-logging in for ADK pages
|
|
15
|
-
*/
|
|
16
|
-
export declare const AuthGuard: React.FC<AuthGuardProps>;
|
|
17
|
-
/**
|
|
18
|
-
* HOC for protecting components with authentication
|
|
19
|
-
*/
|
|
20
|
-
export declare const withAuthGuard: <P extends object>(Component: React.ComponentType<P>, options?: {
|
|
21
|
-
requireAuth?: boolean | undefined;
|
|
22
|
-
fallback?: ReactNode;
|
|
23
|
-
} | undefined) => React.FC<P>;
|
|
24
|
-
/**
|
|
25
|
-
* Route-based authentication guard
|
|
26
|
-
* Automatically determines if auth is required based on the current path
|
|
27
|
-
*/
|
|
28
|
-
export declare const RouteAuthGuard: React.FC<{
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Authentication status indicator component
|
|
33
|
-
*/
|
|
34
|
-
export declare const AuthStatus: React.FC;
|
|
35
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AuthGuard, withAuthGuard, RouteAuthGuard, AuthStatus, } from './AuthGuard';
|