mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(file-uploader-drop-container): rework FileUploaderDropContainer
(#1125)
- convert `FileList` to `File[]` to be consistent with `FileUploader` and `FileUploaderButton` - add `files` prop for two-way binding - dispatch instead of forward the `change` event (detail signature: `File[]`)
This commit is contained in:
parent
7586b2a10f
commit
8d3ac75170
4 changed files with 60 additions and 32 deletions
|
@ -9,6 +9,12 @@ export interface FileUploaderDropContainerProps
|
|||
*/
|
||||
accept?: string[];
|
||||
|
||||
/**
|
||||
* Obtain a reference to the uploaded files
|
||||
* @default []
|
||||
*/
|
||||
files?: File[];
|
||||
|
||||
/**
|
||||
* Set to `true` to allow multiple files
|
||||
* @default false
|
||||
|
@ -20,7 +26,7 @@ export interface FileUploaderDropContainerProps
|
|||
* The default behavior does not validate files
|
||||
* @default (files) => files
|
||||
*/
|
||||
validateFiles?: (files: FileList) => FileList;
|
||||
validateFiles?: (files: File) => File;
|
||||
|
||||
/**
|
||||
* Specify the label text
|
||||
|
@ -68,12 +74,12 @@ export interface FileUploaderDropContainerProps
|
|||
export default class FileUploaderDropContainer extends SvelteComponentTyped<
|
||||
FileUploaderDropContainerProps,
|
||||
{
|
||||
add: CustomEvent<FileList>;
|
||||
add: CustomEvent<File[]>;
|
||||
change: CustomEvent<File[]>;
|
||||
dragover: WindowEventMap["dragover"];
|
||||
dragleave: WindowEventMap["dragleave"];
|
||||
drop: WindowEventMap["drop"];
|
||||
keydown: WindowEventMap["keydown"];
|
||||
change: WindowEventMap["change"];
|
||||
click: WindowEventMap["click"];
|
||||
},
|
||||
{ labelText: {} }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue