Skip to content

Feature/$$rest props #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 39 additions & 0 deletions demo/src/routes/custom-props/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import Dropzone from '../../../../src/lib/components/Dropzone.svelte';

let files = {
accepted: [] as any[],
rejected: [] as any[]
};

function handleFilesSelect(e: any) {
const { acceptedFiles, fileRejections } = e.detail;
files.accepted = [...files.accepted, ...acceptedFiles];
files.rejected = [...files.rejected, ...fileRejections];
}

function clickToUpload() {
document.getElementById('xyz')!.click();
}
</script>

<section>
<button on:click={clickToUpload}>Click to upload</button>
<Dropzone on:drop={handleFilesSelect} id="xyz" />

<ol>
{#each files.accepted as item}
<li>{item.name}</li>
{/each}
</ol>
</section>

<style>
section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 1;
}
</style>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-file-dropzone",
"version": "2.0.7",
"version": "2.0.8",
"description": "Svelte component for fileupload and file dropzone",
"scripts": {
"package": "svelte-kit sync && svelte-package && publint",
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/Dropzone.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
on:dragover={composeDragHandler(onDragOverCb)}
on:dragleave={composeDragHandler(onDragLeaveCb)}
on:drop={composeDragHandler(onDropCb)}
{...$$restProps}
>
<input
accept={accept?.toString()}
Expand Down