Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@pandemicode/material-ui-dropzone

jpinho3.4kMIT3.5.5TypeScript support: included

A Material-UI File Upload Dropzone

react, react-component, material design, material-ui, dropzone, upload, react upload

readme

material-ui-dropzone

License All Contributors Rebuild Dist Workflow Status Update Docs Workflow Status npm package npm downloads

@pandemicode/material-ui-dropzone a fork of Material-UI-Dropzone is a set of React components using Material-UI and is based on the excellent react-dropzone library.

These components provide:

  • File Upload Dropzone
  • File Upload Dropzone inside of a Dialog

Additionally, the File Upload Dropzone features some snazzy "File Allowed/Not Allowed" effects, previews and alerts.

Before proceeding with using this module, refer to the disclaimer section on the end of this README.

Installation

npm install --save @pandemicode/material-ui-dropzone

or

yarn add @pandemicode/material-ui-dropzone

Support

@pandemicode/material-ui-dropzone complies to the following support matrix.

version React Material-UI
3.x 16.8+ 4.x
2.x 15.x or 16.x 3.x or 4.x

Demo

Full documentation and samples are available here https://yuvaleros.github.io/material-ui-dropzone.

Preview: Dialog Component with drag'n'drop effects for accepted and rejected files.

drawing

Disclaimer: Drag'n'drop handling has some known limitations, see here for more details.

Components

DropzoneArea

This components creates the dropzone, previews and snackbar notifications without a dialog

`jsx static import React, {Component} from 'react' import {DropzoneArea} from 'material-ui-dropzone'

class DropzoneAreaExample extends Component{ constructor(props){ super(props); this.state = { files: [] }; } handleChange(files){ this.setState({ files: files }); } render(){ return ( <DropzoneArea onChange={this.handleChange.bind(this)} /> ) } }

export default DropzoneAreaExample;


### DropzoneDialog

This component provides the DropzoneArea inside of a MaterialUI Dialog.

```jsx static
import React, { Component } from 'react'
import {DropzoneDialog} from 'material-ui-dropzone'
import Button from '@material-ui/core/Button';

export default class DropzoneDialogExample extends Component {
    constructor(props) {
        super(props);
        this.state = {
            open: false,
            files: []
        };
    }

    handleClose() {
        this.setState({
            open: false
        });
    }

    handleSave(files) {
        //Saving files to state for further use and closing Modal.
        this.setState({
            files: files,
            open: false
        });
    }

    handleOpen() {
        this.setState({
            open: true,
        });
    }

    render() {
        return (
            <div>
                <Button onClick={this.handleOpen.bind(this)}>
                  Add Image
                </Button>
                <DropzoneDialog
                    open={this.state.open}
                    onSave={this.handleSave.bind(this)}
                    acceptedFiles={['image/jpeg', 'image/png', 'image/bmp']}
                    showPreviews={true}
                    maxFileSize={5000000}
                    onClose={this.handleClose.bind(this)}
                />
            </div>
        );
    }
}

License

MIT

Contributors

Thanks goes to these wonderful people (emoji key):


Yuvaleros

🤔 💻 🎨 📖 💬 👀 🚧

Mattia Panzeri

🤔 💻 🎨 📖 💡 🚇 🐛 💬 👀 🚧

Max Carroll

🤔 💻 🎨 💡 👀

Matthew Corner

🐛 🤔 💻

Barry Loong

🤔 💻

JF Blouin

🤔 💻

Anthony Raymond

💻 💡

isaacbuckman

🐛 💻 💡

MatthijsMud

🐛 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Disclaimer

Material UI Dropzone original repo is here https://github.com/Yuvaleros/material-ui-dropzone.

This fork is an independent build which may incorporate more features and bug fixes and is not dependent of the original repo maintainers review process or release cycle.

Furthermore, any features or bug fixes, that result from this independent build will always be contributed back to the original repo when possible.

This repo will also be maintained in sync with it's upstream, every time possible.

changelog

material-ui-dropzone

Thanks to all contributers who improved material-ui-dropzone by opening an issue/PR.

This changelog refers to master branch (currently v3.x), for v2.x-specific changelog see v2.x CHANGELOG.md.

v3.5.0

To be released

:sparkles: Features

  • Update DropzoneDialog to allow for a custom dialog title (PR #234 by @4-Eyes)

:bug: Bugfixes

  • Use binary system instead of decimal for size error (PR #245 by @AntoineGrandchamp)

:label: Typings

  • Add disableRejectionFeedback to DropzoneAreaBaseProps type (PR #247 by @Parya-Jafari, related to issue #141 by @PabloCanalSuarez)

v3.4.1

Unreleased

:bug: Bugfixes

  • Fix react-dropzone props not being passed properly (PR #239 by @panz3r, fixes #235 by @grahamlangford)

v3.4.0

August 18, 2020

:sparkles: New Features

  • Allow all filetypes by default (PR #226 by @panz3r, fixes #214 by @FilipeCosta06)
  • Allow passing a custom Icon to be displayed inside Dropzone area (PR #227 by @panz3r, closes #48 by @N4Design)

:lipstick: UI Changes

  • Fix Snackbar icons margins (PR #223 by @Armanio)

v3.3.1

July 24, 2020

:label: Typings

  • Update PropTypes for initialFiles to avoid issues with NextJS (Fixes #208)

v3.3.0

June 20, 2020

:sparkles: New Features

  • Make previewChips use the grid system as well (PR #173 by @anthonyraymond)
  • Set initialFiles with File or URL string (PR #194 by @isaacbuckman, reported as #192 by @isaacbuckman)
  • Add onAlert callback prop to hook into Snackbar messaging (PR #205 by @mattcorner, reported as #200 by @mattcorner)

v3.2.1

Unreleased

:bug: Bugfixes

  • Show remove buttons when they have focus (PR #191 by @MatthijsMud, reported as #190 by @MatthijsMud)
  • Change SnackbarContentWrapper class names for variants to avoid conflicts with Material UI internals (PR #198 by @panz3r, reported as #183 by @mattcorner)
  • Fix error message when dropping more than filesLimit files (PR #199 by @panz3r, reported as #196 by @edricwu)

:label: Typings

  • Update Typescript typings
    • Fixes issue #172 by @amirmishani
    • Fixes issue #184 by @zikaeroh

:arrow_up: Dependencies Update

  • Bump websocket-extensions from 0.1.3 to 0.1.4
  • Bump @babel/* devDeps to 7.10.x

v3.2.0

June 03, 2020

:sparkles: New Features

  • Add DropzoneAreaBase and DropzoneDialogBase controlled components (PR #175 by @panz3r)

v3.1.0

May 27, 2020

:sparkles: New Features

  • Add getPreviewIcon prop to DropzoneArea component to customize file preview (PR #154 by @max-carroll)
  • Add support for style with MUI Theme, see docs for more details (PR #158 by @panz3r):
    • Closes issue #73 by @sirsaeta
    • Closes issue #80 by @mikiasmohamed
    • Closes issue #125 by @suiaing
    • Closes issue #146 by @mattcorner
  • Add showAlerts property to show alerts only on error (PR #170 by @blouin):
    • showAlerts can be a boolean ("global" true or false for all alerts).
    • showAlerts can be an array, with values error, info, success:
      • showAlerts={['error']} for only errors
      • showAlerts={['error', 'info']} for both errors and info
      • showAlerts={['error', 'success', 'info']} is same as showAlerts={true}
      • showAlerts={[]} is same as showAlerts={false}

:bug: Bugfixes

  • Avoid appending extension if present when loading external files (PR #150 by @panz3r, reported as #135 by @mballeng91)
  • Prevent control focus rubber band (PR #156 by @max-carroll, reported as #145 by @topninja)

v3.0.0

April 25, 2020

:boom: BREAKING

  • Upgrade react-dropzone to version 10 (PR #120 by @panz3r)
  • Drop support for React <16.8 and Material-UI v3 (PR #120 by @panz3r)
  • After the code refactor of PR #121, the onChange handler is invoked also on component mount (with or without files depending on the value of the initialFiles prop) - see issue #153 for more details.

:sparkles: New Features

  • Addition of previewText prop to DropzoneArea component (PR #121 by @panz3r, same as #112 by @charlot567)
  • Add disableRejectionFeedback prop to DropzoneArea component (PR #142 by @panz3r, reported as #141 by @PabloCanalSuarez)
  • Add inputProps prop to DropzoneArea component (PR #134 by @panz3r), fixes:
    • set name for <input> element (#92 by @mnlbox)
    • Upload Directory/folder (#122 by @antares-va-tech)
  • Add dropzoneProps prop to DropzoneArea component (PR #134 by @panz3r), fixes:
    • Dropzone disable attribute not working (#103 by @stefanstankovic995)
  • Add alertSnackbarProps prop to DropzoneArea component (PR #134 by @panz3r), fixes:
    • Ability to override snackbard background colours (#45 by @IsabellaRey)
    • Allow the abillity of change anchorOrigin of snackbar (#64 by @widomin)

:bug: Bugfixes

  • Avoid appending extension if present when loading external files (PR #137 by @panz3r, reported as #135 by @mballeng91)
  • onDrop returns each file one at a time (PR #121 by @panz3r, reported as #65 by @AlanOrtega91)
  • Fully support setting acceptedFiles as .fileending (PR #121 by @panz3r, reported as #107 by @wirmar)

:lipstick: UI

  • Should be using Typography instead of <p></p> (PR #121 by @panz3r, reported as #31 by @PolGuixe and @IsabellaRey)

:recycle: Refactoring

  • Code refactor (#121 by @panz3r)

:pencil: Docs

  • Improved docs (#128 by @panz3r)

v2.5.0

April 15, 2020

:sparkles: New Features

  • Add previewGridClasses, previewGridProps props (PR #124 by @loongyh, reported as #85 by @zeckdude)
  • Add dialogProps prop to customize DropzoneDialog appearance (PR #105 by @chattling)

:bug: Bugfixes

  • ReferenceError: regeneratorRuntime is not defined (PR #111 by @panz3r, reported as #77 by @rooch84, @Tassfighter and @eluchsinger)

:zap: Improvements

  • Review dependencies (PR #111 by @panz3r)
  • Tooling upgrade (PR #115 by @panz3r)

:pencil: Docs

  • Added new dialogProps prop to README (PR #113 by @chattling)
  • Fix submit/cancel typo (PR #126 by @Maxim-Mazurok)

v2.4.9

March 10, 2020

:sparkles: New Features

  • Add dialogProps prop to customize DropzoneDialog appearance (PR #105 by @chattling)

:bug: Bugfixes

  • Move @material-ui/icons to peerDependencies (PR #104 by @panz3r, reported as #95 by @char0n)

v2.4.8

February 22, 2020

:bug: Bugfixes

  • initialFiles not shown up (PR #101 by @faupol3, reported as #87 by @ameenazeemiacmedocs)
  • Unable to preview png file (PR #101 by @faupol3, reported as #90 by @shailesh-padave)
  • remove console logs from Dropzone dialog (PR #102 by @chattling, reported as #96 by @Morteza-Jenabzadeh)

:recycle: Refactoring

  • Improved code quality (PR #94 by @GRcwolf)