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

@hecht-a/dropzone

v1.9.2

Published

This is a package to create file dropzone in html

Downloads

16

Readme

Quickstart

Install:

npm install --save @hecht-a/dropzone
# or with yarn
yarn add @hecht-a/dropzone
# or with pnpm
pnpm install @hecht-a/dropzone

Use as ES6 module:

import {Dropzone} from '@hecht-a/dropzone'

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {})

Or use as CommonJS module:

const {Dropzone} = require('@hecht-a/dropzone')

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {})

Documentation

Options

Options are defined in the second argument of the Dropzone constructor in an object.
For example:

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {
    id: 'id'
})

All these options are optionnal.

| name | description | type | default value | |:---------------------------------------:|:----------------------------------------------------------------------------------------:|:------------------------------------------------------------------------:|:--------------:| | id | Custom id to apply to the dropzone | string | "dropzone" | | label | Define the label shown on the dropzone | string | "Upload files" | | hoverLabel | Define the label shown on the dropzone when it's hovered | string | "hover" | | min | Define the minimum amount of file(s) to upload (see Dropzone#setMin) | number | 0 | | max | Define the maximum amount of file(s) to upload (see Dropzone#setMax) | number | 2 | | containerTemplate | Define the global template of the dropzone | (max: number, files?: FileList, label?: string, id?: string) => string | - | | fileTemplate | Define the template of the file container when a file is uploaded | (fileName: string) => string | - | | onHover | Define the event hover | () => void | - | | onLeave | Define the event onLeave | () => void | - | | onAddFile | Define the event addFile | (file: File) => void | - | | onAddFiles | Define the event addFiles | (file: FileList) => void | - | | onError | Define the event error | (error: Error) => void | - | | onDrop | Define the event drop | (files: FileList) => void | - | | onDragEnter | Define the event dragEnter | () => void | - | | onDragLeave | Define the event dragLeave | () => void | - | | onDragOver | Define the event dragOver | () => void | - | | onRefreshDropzone | Define the event refreshDropzone | () => void | - | | onRemoveFile | Define the event removeFile | (file: File) => void | - | | onClearDropzone | Define the event clearDropzone | (files: FileList) => void | - |

Events

Events are received with:

dropzone.on('event_name', callback)

where event_name is the name of the targeted event, callback is what you want to execute when the event is received.

hover

Event fired when the mouse is hovering the dropzone.

leave

Event fired when the mouse leave the dropzone area.

addFile

Event fired when a file is uploaded to the dropzone.

addFiles

Event fired when multiple files are uploaded to the dropzone.

onError

Event fired when an error is thrown.

onDrop

Event fired when a file is drop on the dropzone.

onDragEnter

Event fired when the mouse enter on the dropzone are with a file.

onDragLeave

Event fired when the mouse enter on the dropzone area with a file.

onDragOver

Event fired when the mouse is hovering the dropzone with a file.

onRefreshDropzone

Event fired when the dropzone is refreshed.
The dropzone is refresh when:

  • one or multiple file(s) is / are uploaded
  • a file is removed
  • the dropzone is cleared

onRemoveFile

Event fired when a file is removed.

onClearDropzone

Event fired when the dropzone is cleared. See Dropzone#clearDropzone.

Methods

Dropzone#clearDropzone

Remove all the files uploaded in the dropzone. Use:

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {})
dropzone.clearFiles()

Dropzone#setMin

Set the minimum amount of files. Use:

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {})
dropzone.setMin(2)

Dropzone#setMax

Set the maximum amount of files. Use:

const input = document.querySelector('input#id')
const dropzone = new Dropzone(input, {})
dropzone.setMax(5)