Skip to content

Commit

Permalink
Feature/$$rest props (#165)
Browse files Browse the repository at this point in the history
* implement

* bump version
  • Loading branch information
arackaf authored Sep 1, 2024
1 parent b3dc30b commit c30e6cc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
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

0 comments on commit c30e6cc

Please sign in to comment.