npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-auto-dropzone

v0.2.0

Published

Vue 2 Dropzone.js component

Downloads

2,322

Readme

vue-auto-dropzone

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 | the url field is mandatory | | 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

Currently, this repo is iterating reasonably fast and the style is subject to change over time.
Pull requests are discouraged, but issue reports and feature requests are very welcome.