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:
metonym 2022-02-21 13:33:11 -08:00 committed by GitHub
commit 8d3ac75170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 32 deletions

View file

@ -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: {} }