skillgrid 0.0.66 → 0.0.68
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/components/FileUpload/FileUpload.d.ts +2 -0
- package/dist/components/FileUpload/FileUpload.type.d.ts +201 -0
- package/dist/components/FileUpload/index.d.ts +2 -0
- package/dist/index.cjs.js +11 -11
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4400 -3587
- package/package.json +2 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type FileUploadStatus = 'idle' | 'uploading' | 'success' | 'error';
|
|
3
|
+
export type FileUploadRejectReason = 'accept' | 'maxFileSize';
|
|
4
|
+
export type FileUploadLayout = 'vertical' | 'horizontal' | 'button';
|
|
5
|
+
export type FileUploadSortOrder = 'newest-first' | 'provided';
|
|
6
|
+
export interface FileUploadAction {
|
|
7
|
+
/**
|
|
8
|
+
* Unique action identifier
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Action label
|
|
13
|
+
*/
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional action icon
|
|
17
|
+
*/
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Visual tone for action item
|
|
21
|
+
* @default 'default'
|
|
22
|
+
*/
|
|
23
|
+
tone?: 'default' | 'danger';
|
|
24
|
+
/**
|
|
25
|
+
* Disabled state for action item
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface FileUploadItem {
|
|
31
|
+
/**
|
|
32
|
+
* Unique file item identifier
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* File name
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* File size in bytes
|
|
41
|
+
*/
|
|
42
|
+
size: number;
|
|
43
|
+
/**
|
|
44
|
+
* MIME type
|
|
45
|
+
*/
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Upload or creation timestamp used for newest-first sorting
|
|
49
|
+
*/
|
|
50
|
+
createdAt?: string | number | Date;
|
|
51
|
+
/**
|
|
52
|
+
* Preview URL for images
|
|
53
|
+
*/
|
|
54
|
+
previewUrl?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Visual upload state
|
|
57
|
+
* @default 'idle'
|
|
58
|
+
*/
|
|
59
|
+
status?: FileUploadStatus;
|
|
60
|
+
/**
|
|
61
|
+
* Upload progress from 0 to 100
|
|
62
|
+
*/
|
|
63
|
+
progress?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Error text for failed uploads
|
|
66
|
+
*/
|
|
67
|
+
error?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Download URL
|
|
70
|
+
*/
|
|
71
|
+
downloadUrl?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Disabled state for this file row
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface FileUploadRejectedFile {
|
|
79
|
+
/**
|
|
80
|
+
* Original rejected file
|
|
81
|
+
*/
|
|
82
|
+
file: File;
|
|
83
|
+
/**
|
|
84
|
+
* Rejection reason
|
|
85
|
+
*/
|
|
86
|
+
reason: FileUploadRejectReason;
|
|
87
|
+
}
|
|
88
|
+
export interface FileUploadSelectionContext {
|
|
89
|
+
/**
|
|
90
|
+
* Existing items that should be removed when maxFiles limit is exceeded
|
|
91
|
+
*/
|
|
92
|
+
overflowedItems: FileUploadItem[];
|
|
93
|
+
/**
|
|
94
|
+
* Files from the current selection batch that were trimmed by maxFiles
|
|
95
|
+
*/
|
|
96
|
+
overflowedFiles: File[];
|
|
97
|
+
/**
|
|
98
|
+
* Applied max files limit
|
|
99
|
+
*/
|
|
100
|
+
maxFiles?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface FileUploadProps {
|
|
103
|
+
/**
|
|
104
|
+
* Controlled list of files
|
|
105
|
+
*/
|
|
106
|
+
items: FileUploadItem[];
|
|
107
|
+
/**
|
|
108
|
+
* Callback with accepted files from a single selection/drop batch
|
|
109
|
+
*/
|
|
110
|
+
onSelectFiles?: (files: File[], context: FileUploadSelectionContext) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Callback with rejected files from a single selection/drop batch
|
|
113
|
+
*/
|
|
114
|
+
onReject?: (rejections: FileUploadRejectedFile[]) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Remove callback for built-in remove action
|
|
117
|
+
*/
|
|
118
|
+
onRemoveFile?: (item: FileUploadItem) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Callback for custom action items
|
|
121
|
+
*/
|
|
122
|
+
onAction?: (actionId: string, item: FileUploadItem) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Retry callback for failed uploads
|
|
125
|
+
*/
|
|
126
|
+
onRetryFile?: (item: FileUploadItem) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Custom row actions or factory by item
|
|
129
|
+
*/
|
|
130
|
+
actions?: FileUploadAction[] | ((item: FileUploadItem) => FileUploadAction[]);
|
|
131
|
+
/**
|
|
132
|
+
* Additional actions for media preview card
|
|
133
|
+
*/
|
|
134
|
+
previewActions?: FileUploadAction[] | ((item: FileUploadItem) => FileUploadAction[]);
|
|
135
|
+
/**
|
|
136
|
+
* Accept attribute string
|
|
137
|
+
* @default '.jpg,.jpeg,.png,.doc,.pdf,image/jpeg,image/png,application/msword,application/pdf'
|
|
138
|
+
*/
|
|
139
|
+
accept?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Allow selecting multiple files
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
multiple?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Max file size in bytes
|
|
147
|
+
* @default 10485760
|
|
148
|
+
*/
|
|
149
|
+
maxFileSize?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Max amount of files preserved in the list.
|
|
152
|
+
* New selections keep the newest files and report overflow via onSelectFiles context.
|
|
153
|
+
*/
|
|
154
|
+
maxFiles?: number;
|
|
155
|
+
/**
|
|
156
|
+
* Disabled state
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Component layout variant
|
|
162
|
+
* @default 'vertical'
|
|
163
|
+
*/
|
|
164
|
+
layout?: FileUploadLayout;
|
|
165
|
+
/**
|
|
166
|
+
* Shows preview card for a single uploaded media file in vertical layout
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
showMediaPreview?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Order used for rendering controlled items
|
|
172
|
+
* @default 'newest-first'
|
|
173
|
+
*/
|
|
174
|
+
sortOrder?: FileUploadSortOrder;
|
|
175
|
+
/**
|
|
176
|
+
* Shows a built-in error snackbar for rejected files when SnackbarProvider is mounted
|
|
177
|
+
* @default true
|
|
178
|
+
*/
|
|
179
|
+
showRejectSnackbar?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Dropzone title
|
|
182
|
+
*/
|
|
183
|
+
title?: ReactNode;
|
|
184
|
+
/**
|
|
185
|
+
* Dropzone description
|
|
186
|
+
*/
|
|
187
|
+
description?: ReactNode;
|
|
188
|
+
/**
|
|
189
|
+
* Trigger button label
|
|
190
|
+
*/
|
|
191
|
+
buttonLabel?: ReactNode;
|
|
192
|
+
/**
|
|
193
|
+
* Additional root class name
|
|
194
|
+
*/
|
|
195
|
+
className?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Test id for the root element
|
|
198
|
+
* @default 'file-upload'
|
|
199
|
+
*/
|
|
200
|
+
'data-testid'?: string;
|
|
201
|
+
}
|