Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"build": "rollup -c",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
Expand Down
19 changes: 14 additions & 5 deletions src/components/Dropzone.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
export let containerStyles = "";
export let disableDefaultStyles = false;
export let name = "";
export let inputRef;
export let required = false;
const dispatch = createEventDispatcher();
//state
Expand All @@ -44,11 +46,10 @@
isDragReject: false,
draggedFiles: [],
acceptedFiles: [],
fileRejections: []
fileRejections: [],
};
let rootRef;
let inputRef;
function resetState() {
state.isFileDialogActive = false;
Expand Down Expand Up @@ -211,6 +212,11 @@
acceptedFiles.splice(0);
}
// Files dropped keep input in sync
if (event.dataTransfer) {
inputRef.files = event.dataTransfer?.files;
}
state.acceptedFiles = acceptedFiles;
state.fileRejections = fileRejections;
Expand Down Expand Up @@ -339,18 +345,21 @@
on:dragenter={composeDragHandler(onDragEnterCb)}
on:dragover={composeDragHandler(onDragOverCb)}
on:dragleave={composeDragHandler(onDragLeaveCb)}
on:drop={composeDragHandler(onDropCb)}>
on:drop={composeDragHandler(onDropCb)}
>
<input
{accept}
{multiple}
{required}
type="file"
name={name}
{name}
autocomplete="off"
tabindex="-1"
on:change={onDropCb}
on:click={onInputElementClick}
bind:this={inputRef}
style="display: none;" />
style="display: none;"
/>
<slot>
<p>Drag 'n' drop some files here, or click to select files</p>
</slot>
Expand Down