@spark-ui/components 11.4.1 → 11.4.3

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.
@@ -23,9 +23,21 @@ interface FileUploadProps {
23
23
  */
24
24
  value?: File[];
25
25
  /**
26
- * Callback when files are selected
26
+ * Callback when files are accepted
27
+ * @param details - Details about the accepted files
27
28
  */
28
- onFilesChange?: (files: File[]) => void;
29
+ onFileAccept?: (details: FileAcceptDetails) => void;
30
+ /**
31
+ * Callback when files are rejected
32
+ * @param details - Details about the rejected files and their errors
33
+ */
34
+ onFileReject?: (details: FileRejectDetails) => void;
35
+ /**
36
+ * Callback when files change (both accepted and rejected)
37
+ * For controlled mode, use this to update the value prop by extracting details.acceptedFiles
38
+ * @param details - Details about both accepted and rejected files
39
+ */
40
+ onFileChange?: (details: FileChangeDetails) => void;
29
41
  /**
30
42
  * Whether multiple files can be selected
31
43
  * @default true
@@ -45,12 +57,6 @@ interface FileUploadProps {
45
57
  * Files beyond this limit will be rejected
46
58
  */
47
59
  maxFiles?: number;
48
- /**
49
- * Callback when the maximum number of files is reached
50
- * @param maxFiles - The maximum number of files allowed
51
- * @param rejectedCount - The number of files that were rejected
52
- */
53
- onMaxFilesReached?: (maxFiles: number, rejectedCount: number) => void;
54
60
  /**
55
61
  * Maximum file size in bytes
56
62
  * Files larger than this will be rejected
@@ -61,12 +67,6 @@ interface FileUploadProps {
61
67
  * Files smaller than this will be rejected
62
68
  */
63
69
  minFileSize?: number;
64
- /**
65
- * Callback when a file size validation error occurs
66
- * @param file - The file that failed validation
67
- * @param error - The error message
68
- */
69
- onFileSizeError?: (file: File, error: string) => void;
70
70
  /**
71
71
  * When `true`, prevents the user from interacting with the file upload
72
72
  */
@@ -87,8 +87,18 @@ interface RejectedFile$1 {
87
87
  file: File;
88
88
  errors: FileUploadFileError[];
89
89
  }
90
+ interface FileAcceptDetails {
91
+ files: File[];
92
+ }
93
+ interface FileRejectDetails {
94
+ files: RejectedFile$1[];
95
+ }
96
+ interface FileChangeDetails {
97
+ acceptedFiles: File[];
98
+ rejectedFiles: RejectedFile$1[];
99
+ }
90
100
  declare const FileUpload$1: {
91
- ({ asChild: _asChild, children, defaultValue, value: controlledValue, onFilesChange, multiple, accept, maxFiles, onMaxFilesReached, maxFileSize, minFileSize, onFileSizeError, disabled, readOnly, locale, }: FileUploadProps): react_jsx_runtime.JSX.Element;
101
+ ({ asChild: _asChild, children, defaultValue, value: controlledValue, onFileAccept, onFileReject, onFileChange, multiple, accept, maxFiles, maxFileSize, minFileSize, disabled, readOnly, locale, }: FileUploadProps): react_jsx_runtime.JSX.Element;
92
102
  displayName: string;
93
103
  };
94
104
 
@@ -102,18 +112,22 @@ interface FileUploadAcceptedFileProps extends ComponentPropsWithoutRef<'li'> {
102
112
  * The file to display
103
113
  */
104
114
  file: File;
105
- /**
106
- * The index of the file in the accepted files array
107
- */
108
- fileIndex: number;
109
115
  /**
110
116
  * Upload progress value (0-100). When provided, displays a progress bar at the bottom of the file item.
111
117
  */
112
118
  uploadProgress?: number;
119
+ /**
120
+ * Accessible label for the delete button
121
+ */
122
+ deleteButtonAriaLabel: string;
123
+ /**
124
+ * Accessible label for the progress bar. Required when uploadProgress is provided.
125
+ */
126
+ progressAriaLabel?: string;
113
127
  className?: string;
114
128
  }
115
129
  declare const AcceptedFile: {
116
- ({ asChild: _asChild, className, file, fileIndex, uploadProgress, ...props }: FileUploadAcceptedFileProps): react_jsx_runtime.JSX.Element;
130
+ ({ asChild: _asChild, className, file, uploadProgress, deleteButtonAriaLabel, progressAriaLabel, ...props }: FileUploadAcceptedFileProps): react_jsx_runtime.JSX.Element;
117
131
  displayName: string;
118
132
  };
119
133
 
@@ -133,9 +147,8 @@ declare const Context: {
133
147
  displayName: string;
134
148
  };
135
149
 
136
- declare function Dropzone({ children, onFiles, className, unstyled, }: {
150
+ declare function Dropzone({ children, className, unstyled, }: {
137
151
  children?: React.ReactNode;
138
- onFiles?: (files: FileList) => void;
139
152
  className?: string;
140
153
  unstyled?: boolean;
141
154
  }): react_jsx_runtime.JSX.Element;
@@ -143,56 +156,14 @@ declare namespace Dropzone {
143
156
  var displayName: string;
144
157
  }
145
158
 
146
- interface FileUploadItemProps extends ComponentPropsWithoutRef<'li'> {
147
- /**
148
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
149
- */
150
- asChild?: boolean;
151
- ref?: Ref<HTMLLIElement>;
152
- children: ReactNode;
153
- className?: string;
154
- }
155
- declare const Item: {
156
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemProps): react_jsx_runtime.JSX.Element;
157
- displayName: string;
158
- };
159
-
160
159
  interface FileUploadItemDeleteTriggerProps extends React.ComponentProps<typeof IconButton> {
161
160
  /**
162
- * Index of the file to delete
161
+ * The file to delete
163
162
  */
164
- fileIndex: number;
163
+ file: File;
165
164
  }
166
165
  declare const ItemDeleteTrigger: {
167
- ({ className, fileIndex, onClick, ...props }: FileUploadItemDeleteTriggerProps): react_jsx_runtime.JSX.Element;
168
- displayName: string;
169
- };
170
-
171
- interface FileUploadItemFileNameProps extends ComponentPropsWithoutRef<'p'> {
172
- /**
173
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
174
- */
175
- asChild?: boolean;
176
- ref?: Ref<HTMLParagraphElement>;
177
- className?: string;
178
- children?: ReactNode;
179
- }
180
- declare const ItemFileName: {
181
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemFileNameProps): react_jsx_runtime.JSX.Element;
182
- displayName: string;
183
- };
184
-
185
- interface FileUploadItemSizeTextProps extends ComponentPropsWithoutRef<'p'> {
186
- /**
187
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
188
- */
189
- asChild?: boolean;
190
- ref?: Ref<HTMLParagraphElement>;
191
- className?: string;
192
- children?: ReactNode;
193
- }
194
- declare const ItemSizeText: {
195
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemSizeTextProps): react_jsx_runtime.JSX.Element;
166
+ ({ className, file, onClick, ...props }: FileUploadItemDeleteTriggerProps): react_jsx_runtime.JSX.Element;
196
167
  displayName: string;
197
168
  };
198
169
 
@@ -227,31 +198,31 @@ interface FileUploadRejectedFileProps extends ComponentPropsWithoutRef<'li'> {
227
198
  * The rejected file to display
228
199
  */
229
200
  rejectedFile: RejectedFile$1;
230
- /**
231
- * The index of the rejected file in the rejectedFiles array
232
- */
233
- rejectedFileIndex: number;
234
201
  /**
235
202
  * Function to render the error message for each error code
236
203
  * @param error - The error code
237
204
  * @returns The error message to display
238
205
  */
239
206
  renderError: (error: FileUploadFileError) => string;
207
+ /**
208
+ * Accessible label for the delete button
209
+ */
210
+ deleteButtonAriaLabel: string;
240
211
  className?: string;
241
212
  }
242
213
  declare const RejectedFile: {
243
- ({ asChild: _asChild, className, rejectedFile, rejectedFileIndex, renderError, ...props }: FileUploadRejectedFileProps): react_jsx_runtime.JSX.Element;
214
+ ({ asChild: _asChild, className, rejectedFile, renderError, deleteButtonAriaLabel, ...props }: FileUploadRejectedFileProps): react_jsx_runtime.JSX.Element;
244
215
  displayName: string;
245
216
  };
246
217
 
247
218
  interface FileUploadRejectedFileDeleteTriggerProps extends React.ComponentProps<typeof IconButton> {
248
219
  /**
249
- * Index of the rejected file to remove
220
+ * The rejected file to remove
250
221
  */
251
- rejectedFileIndex: number;
222
+ rejectedFile: RejectedFile$1;
252
223
  }
253
224
  declare const RejectedFileDeleteTrigger: {
254
- ({ className, rejectedFileIndex, onClick, ...props }: FileUploadRejectedFileDeleteTriggerProps): react_jsx_runtime.JSX.Element;
225
+ ({ className, rejectedFile, onClick, ...props }: FileUploadRejectedFileDeleteTriggerProps): react_jsx_runtime.JSX.Element;
255
226
  displayName: string;
256
227
  };
257
228
 
@@ -270,9 +241,6 @@ declare const FileUpload: typeof FileUpload$1 & {
270
241
  Trigger: typeof Trigger;
271
242
  Dropzone: typeof Dropzone;
272
243
  Context: typeof Context;
273
- Item: typeof Item;
274
- ItemFileName: typeof ItemFileName;
275
- ItemSizeText: typeof ItemSizeText;
276
244
  ItemDeleteTrigger: typeof ItemDeleteTrigger;
277
245
  PreviewImage: typeof PreviewImage;
278
246
  AcceptedFile: typeof AcceptedFile;
@@ -280,4 +248,4 @@ declare const FileUpload: typeof FileUpload$1 & {
280
248
  RejectedFileDeleteTrigger: typeof RejectedFileDeleteTrigger;
281
249
  };
282
250
 
283
- export { FileUpload, type FileUploadFileError, type RejectedFile$1 as RejectedFile };
251
+ export { type FileAcceptDetails, type FileChangeDetails, type FileRejectDetails, FileUpload, type FileUploadFileError, type RejectedFile$1 as RejectedFile };
@@ -23,9 +23,21 @@ interface FileUploadProps {
23
23
  */
24
24
  value?: File[];
25
25
  /**
26
- * Callback when files are selected
26
+ * Callback when files are accepted
27
+ * @param details - Details about the accepted files
27
28
  */
28
- onFilesChange?: (files: File[]) => void;
29
+ onFileAccept?: (details: FileAcceptDetails) => void;
30
+ /**
31
+ * Callback when files are rejected
32
+ * @param details - Details about the rejected files and their errors
33
+ */
34
+ onFileReject?: (details: FileRejectDetails) => void;
35
+ /**
36
+ * Callback when files change (both accepted and rejected)
37
+ * For controlled mode, use this to update the value prop by extracting details.acceptedFiles
38
+ * @param details - Details about both accepted and rejected files
39
+ */
40
+ onFileChange?: (details: FileChangeDetails) => void;
29
41
  /**
30
42
  * Whether multiple files can be selected
31
43
  * @default true
@@ -45,12 +57,6 @@ interface FileUploadProps {
45
57
  * Files beyond this limit will be rejected
46
58
  */
47
59
  maxFiles?: number;
48
- /**
49
- * Callback when the maximum number of files is reached
50
- * @param maxFiles - The maximum number of files allowed
51
- * @param rejectedCount - The number of files that were rejected
52
- */
53
- onMaxFilesReached?: (maxFiles: number, rejectedCount: number) => void;
54
60
  /**
55
61
  * Maximum file size in bytes
56
62
  * Files larger than this will be rejected
@@ -61,12 +67,6 @@ interface FileUploadProps {
61
67
  * Files smaller than this will be rejected
62
68
  */
63
69
  minFileSize?: number;
64
- /**
65
- * Callback when a file size validation error occurs
66
- * @param file - The file that failed validation
67
- * @param error - The error message
68
- */
69
- onFileSizeError?: (file: File, error: string) => void;
70
70
  /**
71
71
  * When `true`, prevents the user from interacting with the file upload
72
72
  */
@@ -87,8 +87,18 @@ interface RejectedFile$1 {
87
87
  file: File;
88
88
  errors: FileUploadFileError[];
89
89
  }
90
+ interface FileAcceptDetails {
91
+ files: File[];
92
+ }
93
+ interface FileRejectDetails {
94
+ files: RejectedFile$1[];
95
+ }
96
+ interface FileChangeDetails {
97
+ acceptedFiles: File[];
98
+ rejectedFiles: RejectedFile$1[];
99
+ }
90
100
  declare const FileUpload$1: {
91
- ({ asChild: _asChild, children, defaultValue, value: controlledValue, onFilesChange, multiple, accept, maxFiles, onMaxFilesReached, maxFileSize, minFileSize, onFileSizeError, disabled, readOnly, locale, }: FileUploadProps): react_jsx_runtime.JSX.Element;
101
+ ({ asChild: _asChild, children, defaultValue, value: controlledValue, onFileAccept, onFileReject, onFileChange, multiple, accept, maxFiles, maxFileSize, minFileSize, disabled, readOnly, locale, }: FileUploadProps): react_jsx_runtime.JSX.Element;
92
102
  displayName: string;
93
103
  };
94
104
 
@@ -102,18 +112,22 @@ interface FileUploadAcceptedFileProps extends ComponentPropsWithoutRef<'li'> {
102
112
  * The file to display
103
113
  */
104
114
  file: File;
105
- /**
106
- * The index of the file in the accepted files array
107
- */
108
- fileIndex: number;
109
115
  /**
110
116
  * Upload progress value (0-100). When provided, displays a progress bar at the bottom of the file item.
111
117
  */
112
118
  uploadProgress?: number;
119
+ /**
120
+ * Accessible label for the delete button
121
+ */
122
+ deleteButtonAriaLabel: string;
123
+ /**
124
+ * Accessible label for the progress bar. Required when uploadProgress is provided.
125
+ */
126
+ progressAriaLabel?: string;
113
127
  className?: string;
114
128
  }
115
129
  declare const AcceptedFile: {
116
- ({ asChild: _asChild, className, file, fileIndex, uploadProgress, ...props }: FileUploadAcceptedFileProps): react_jsx_runtime.JSX.Element;
130
+ ({ asChild: _asChild, className, file, uploadProgress, deleteButtonAriaLabel, progressAriaLabel, ...props }: FileUploadAcceptedFileProps): react_jsx_runtime.JSX.Element;
117
131
  displayName: string;
118
132
  };
119
133
 
@@ -133,9 +147,8 @@ declare const Context: {
133
147
  displayName: string;
134
148
  };
135
149
 
136
- declare function Dropzone({ children, onFiles, className, unstyled, }: {
150
+ declare function Dropzone({ children, className, unstyled, }: {
137
151
  children?: React.ReactNode;
138
- onFiles?: (files: FileList) => void;
139
152
  className?: string;
140
153
  unstyled?: boolean;
141
154
  }): react_jsx_runtime.JSX.Element;
@@ -143,56 +156,14 @@ declare namespace Dropzone {
143
156
  var displayName: string;
144
157
  }
145
158
 
146
- interface FileUploadItemProps extends ComponentPropsWithoutRef<'li'> {
147
- /**
148
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
149
- */
150
- asChild?: boolean;
151
- ref?: Ref<HTMLLIElement>;
152
- children: ReactNode;
153
- className?: string;
154
- }
155
- declare const Item: {
156
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemProps): react_jsx_runtime.JSX.Element;
157
- displayName: string;
158
- };
159
-
160
159
  interface FileUploadItemDeleteTriggerProps extends React.ComponentProps<typeof IconButton> {
161
160
  /**
162
- * Index of the file to delete
161
+ * The file to delete
163
162
  */
164
- fileIndex: number;
163
+ file: File;
165
164
  }
166
165
  declare const ItemDeleteTrigger: {
167
- ({ className, fileIndex, onClick, ...props }: FileUploadItemDeleteTriggerProps): react_jsx_runtime.JSX.Element;
168
- displayName: string;
169
- };
170
-
171
- interface FileUploadItemFileNameProps extends ComponentPropsWithoutRef<'p'> {
172
- /**
173
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
174
- */
175
- asChild?: boolean;
176
- ref?: Ref<HTMLParagraphElement>;
177
- className?: string;
178
- children?: ReactNode;
179
- }
180
- declare const ItemFileName: {
181
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemFileNameProps): react_jsx_runtime.JSX.Element;
182
- displayName: string;
183
- };
184
-
185
- interface FileUploadItemSizeTextProps extends ComponentPropsWithoutRef<'p'> {
186
- /**
187
- * Change the default rendered element for the one passed as a child, merging their props and behavior.
188
- */
189
- asChild?: boolean;
190
- ref?: Ref<HTMLParagraphElement>;
191
- className?: string;
192
- children?: ReactNode;
193
- }
194
- declare const ItemSizeText: {
195
- ({ asChild: _asChild, className, children, ...props }: FileUploadItemSizeTextProps): react_jsx_runtime.JSX.Element;
166
+ ({ className, file, onClick, ...props }: FileUploadItemDeleteTriggerProps): react_jsx_runtime.JSX.Element;
196
167
  displayName: string;
197
168
  };
198
169
 
@@ -227,31 +198,31 @@ interface FileUploadRejectedFileProps extends ComponentPropsWithoutRef<'li'> {
227
198
  * The rejected file to display
228
199
  */
229
200
  rejectedFile: RejectedFile$1;
230
- /**
231
- * The index of the rejected file in the rejectedFiles array
232
- */
233
- rejectedFileIndex: number;
234
201
  /**
235
202
  * Function to render the error message for each error code
236
203
  * @param error - The error code
237
204
  * @returns The error message to display
238
205
  */
239
206
  renderError: (error: FileUploadFileError) => string;
207
+ /**
208
+ * Accessible label for the delete button
209
+ */
210
+ deleteButtonAriaLabel: string;
240
211
  className?: string;
241
212
  }
242
213
  declare const RejectedFile: {
243
- ({ asChild: _asChild, className, rejectedFile, rejectedFileIndex, renderError, ...props }: FileUploadRejectedFileProps): react_jsx_runtime.JSX.Element;
214
+ ({ asChild: _asChild, className, rejectedFile, renderError, deleteButtonAriaLabel, ...props }: FileUploadRejectedFileProps): react_jsx_runtime.JSX.Element;
244
215
  displayName: string;
245
216
  };
246
217
 
247
218
  interface FileUploadRejectedFileDeleteTriggerProps extends React.ComponentProps<typeof IconButton> {
248
219
  /**
249
- * Index of the rejected file to remove
220
+ * The rejected file to remove
250
221
  */
251
- rejectedFileIndex: number;
222
+ rejectedFile: RejectedFile$1;
252
223
  }
253
224
  declare const RejectedFileDeleteTrigger: {
254
- ({ className, rejectedFileIndex, onClick, ...props }: FileUploadRejectedFileDeleteTriggerProps): react_jsx_runtime.JSX.Element;
225
+ ({ className, rejectedFile, onClick, ...props }: FileUploadRejectedFileDeleteTriggerProps): react_jsx_runtime.JSX.Element;
255
226
  displayName: string;
256
227
  };
257
228
 
@@ -270,9 +241,6 @@ declare const FileUpload: typeof FileUpload$1 & {
270
241
  Trigger: typeof Trigger;
271
242
  Dropzone: typeof Dropzone;
272
243
  Context: typeof Context;
273
- Item: typeof Item;
274
- ItemFileName: typeof ItemFileName;
275
- ItemSizeText: typeof ItemSizeText;
276
244
  ItemDeleteTrigger: typeof ItemDeleteTrigger;
277
245
  PreviewImage: typeof PreviewImage;
278
246
  AcceptedFile: typeof AcceptedFile;
@@ -280,4 +248,4 @@ declare const FileUpload: typeof FileUpload$1 & {
280
248
  RejectedFileDeleteTrigger: typeof RejectedFileDeleteTrigger;
281
249
  };
282
250
 
283
- export { FileUpload, type FileUploadFileError, type RejectedFile$1 as RejectedFile };
251
+ export { type FileAcceptDetails, type FileChangeDetails, type FileRejectDetails, FileUpload, type FileUploadFileError, type RejectedFile$1 as RejectedFile };