All Projects → Etheryte → vue-auto-dropzone

Etheryte / vue-auto-dropzone

Licence: MIT license
A Dropzone component for Vue. Typescript support, native slots, and more.

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects
typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to vue-auto-dropzone

ngx-dropzone
A highly configurable dropzone component for Angular.
Stars: ✭ 123 (+434.78%)
Mutual labels:  dropzone
react-drop-n-crop
An opinionated implementation of react-dropzone and react-cropper
Stars: ✭ 17 (-26.09%)
Mutual labels:  dropzone
ngx-fire-uploader
Angular Fire Uploader
Stars: ✭ 18 (-21.74%)
Mutual labels:  dropzone
react-magic-dropzone
✨Magically drag and drop files/links for uploading
Stars: ✭ 11 (-52.17%)
Mutual labels:  dropzone
acf-dropzone
Drop file uploads directly on ACF file fields
Stars: ✭ 31 (+34.78%)
Mutual labels:  dropzone
Fine Uploader
Multiple file upload plugin with image previews, drag and drop, progress bars. S3 and Azure support, image scaling, form support, chunking, resume, pause, and tons of other features.
Stars: ✭ 8,158 (+35369.57%)
Mutual labels:  dropzone
Dropzone
Dropzone is an easy to use drag'n'drop library. It supports image previews and shows nice progress bars.
Stars: ✭ 16,097 (+69886.96%)
Mutual labels:  dropzone
yii2-dropzone
This extension provides the Dropzone integration for the Yii2 framework.
Stars: ✭ 11 (-52.17%)
Mutual labels:  dropzone
react-isomorphic-bundle
React Redux Universal (isomorphic) bundle
Stars: ✭ 53 (+130.43%)
Mutual labels:  dropzone
angular-file-dropzone
A simple file dropzone for Angular
Stars: ✭ 13 (-43.48%)
Mutual labels:  dropzone
dropzoner
Laravel package for image upload using DropzoneJS
Stars: ✭ 46 (+100%)
Mutual labels:  dropzone

vue-auto-dropzone

NB! This repository is archived and will receive no further updates. I recommend using Filepond via vue-filepond for new projects.


A Dropzone.js component for Vue.
Typescript support, native slots, and more.

Installation

yarn install vue-auto-dropzone

Basic usage

<template>
    <vue-auto-dropzone ref="dz" :options="options" />
</template>
<script lang="ts">
    import Vue from 'vue';

    import VueAutoDropzone from 'vue-auto-dropzone';

    export default Vue.extend({
        components: {
            VueAutoDropzone,
        },
        data() {
            return {
                options: {
                    url: 'https://httpbin.org/anything',
                },
            };
        },
        mounted() {
            // The Dropzone instance is available after mounting
            const dz = this.$refs.dz;
        }
    });
</script>

Slots

All content is configurable by slots.
Slots receive the instance itself as their scope, meaning all relevant fields are directly accessible.
To omit default styling on the slot, also specify :include-styling="false".

<vue-auto-dropzone :options="options" :include-styling="false" v-slot="{ files, removeFile }">
    <p v-if="!files.length">Give me fuel, give me files</p>

    <figure v-for="file in files" :key="file.upload.uuid" @click="removeFile(file)">
        <img v-if="file.dataURL" :src="file.dataURL" :alt="file.name" />
        <figcaption>
            {{file.name}}
            <span v-if="file.upload.progress !== 100">{{ file.upload.progress.toFixed(0) }}%</span>
        </figcaption>
    </figure>
</vue-auto-dropzone>

Props

Name Type Default Description Required
options Object undefined an object containing Dropzone configuration options true
includeStyling Boolean true whether to include default Dropzone styles on the component false
destroyDropzone Boolean true whether to destroy the Dropzone instance on component unmount false

Events

All Dropzone events are emitted on the component with identical names and parameters.
Use standard Vue event handling to listen for events and respond to them.

<vue-auto-dropzone
    :options="options"
    @drop="onDrop"
    @success="onSuccess"
/>

Properties

Properties are exposed directly on the component.

mounted() {
    const dz = this.$refs.dz;
    const files = dz.files;
}

Property list

Name Description
files Array of all files
acceptedFiles Array of all accepted files
rejectedFiles Array of all rejected files
queuedFiles Array of all files queued for upload
uploadingFiles Array of all files currently uploading
addedFiles Array of all added files
activeFiles Array of all queued or currently uploading files
defaultOptions Object containing default Dropzone configuration values
events Array of all event names the instance supports
hiddenFileInput A reference to the input element used by Dropzone
listeners Array of all elements with relevant listeners used by Dropzone
version Bundled Dropzone version

Methods

Methods are exposed directly on the component.
The instance is available once the component is mounted.

mounted() {
    const dz = this.$refs.dz;
    // Manually add a file
    dz.addFile('data:image/png;...', 'image.png');
}

Method list

Method Description
getOptions() Get all currently set Dropzone configuration values
setOptions(value: Partial<IDropzoneOptions>) Set multiple configuration options at a time
getOption(key: keyof IDropzoneOptions) Get the value of a single configuration option by key
setOption(key: keyof IDropzoneOptions, value: any) Set a single configuration option
addFile(file: File | string, fileName?: string, mimeType?: string) Manually add a new file without triggering upload hooks. Input is either a File or a data string ("data:image/...") with a file name and optional mime type
addAndUploadFile(file: File | string, fileName?: string, mimeType?: string) Manually add a new file and trigger all regular upload hooks. Input is either a File or a data string ("data:image/...") with a file name and optional mime type
removeFile(file: File) Remove the given file
removeAllFiles(includeUploading = false) Remove all currently not uploading files, call removeAllFiles(true) to also remove actively uploading files
processQueue() Process the upload queue when autoProcessQueue is disabled
disable() Disable the instance, also removes event listeners etc
enable() Reenable the instance
createThumbnailFromUrl(file: File, sourceUrl: string, callback?: () => any, crossOrigin?: boolean) Create a thumbnail to display files already stored on the server
setParams() Override the params() function
setAccept() Override the accept() function
setChunksUploaded() Override the chunksUploaded() function
setFallback() Override the fallback() function
setResize() Override the resize() function
setTransformFile() Override the transformFile() function

Additional methods on the instance expose the internal Dropzone instance, but those are officially unsupported as they may change with a new Dropzone release.
All exposed internals come with corresponding setters similar to those shown above.

Contributing

Pull requests are welcome, same for issue reports and feature requests.
For issues, please include a clear repro sample.

For development, most of the logic resides in src/component/ComponentBase.vue.
VueAutoDropzone.vue is a generated file, do not make your modifications there.

To run the dev build, run yarn build:component:watch and yarn serve in separate sessions.
Before making a PR, be sure to run yarn test and yarn build.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].