···1111 }
1212</script>
1313<FileDrop {handleFiles} let:droppable>
1414- <div class="zone" class:droppable>
1515- Select or drop files here
1616- </div>
1414+ <div class="zone" class:droppable>Select or drop files here</div>
1715</FileDrop>
1816```
1717+1818+## Props
1919+| Prop | Type | Description |
2020+| :-------------- | :--------------- | :------------------------------------------- |
2121+| `acceptedMimes` | string[] \| null | List of allowed mime types, like `image/jpeg` or `image/*`. Invalid files are simply filtered out.<br>Null: all are allowed (default) |
2222+| `max` | number \| null | Max number of files allowed. Extra files are ignored. Defaults to 0 (no limit) |
2323+2424+## Slot props
2525+| Prop | Type | Description |
2626+| :----------- | :------- | :------------ |
2727+| `droppable` | boolean | True if the dropzone is currently hovered with valid files |
19282029## Dev instructions
2130
+16-3
src/lib/FileDrop.svelte
···44 }
5566 /**
77- * List of allowed mime types, like `image/jpeg` or `image/*`. Invalid files are simply filtered out.
77+ * List of allowed mime types, like `image/jpeg` or `image/*`. Invalid files are ignored.
88 *
99- * Null: all file extensions are allowed (default)
99+ * Null: all are allowed (default)
1010 */
1111 export let acceptedMimes: string[] | null = null
12121313+ /**
1414+ * Max number of files allowed. Extra files are ignored.
1515+ *
1616+ * Defaults to 0 (no limit)
1717+ */
1818+ export let max = 0
1919+1320 let droppable = false
1421 let input: HTMLInputElement
1522···1926 if (acceptedMimes === null || isAcceptedMime(files[i].type)) {
2027 acceptedFiles.push(files[i])
2128 }
2929+ }
3030+ if (max !== 0) {
3131+ acceptedFiles = acceptedFiles.slice(0, max)
2232 }
2333 return acceptedFiles
2434 }
···8191 on:dragover|preventDefault={dragOver}
8292 on:dragenter|preventDefault={dragOver}
8393 on:dragleave|preventDefault={dragLeave}
9494+ tabindex="0"
8495 on:click={() => input.click()}
8596>
8697 <slot {droppable}>Upload</slot>
···8899<input
89100 type="file"
90101 accept={acceptedMimes === null ? null : acceptedMimes.join(',')}
102102+ multiple={max !== 1}
91103 bind:files={inputFiles}
92104 on:change|preventDefault={handleChange}
93105 bind:this={input}
9494- multiple
95106/>
9610797108<style lang="sass">
109109+ div
110110+ cursor: pointer
98111 input
99112 display: none
100113</style>