Socket
Socket
Sign inDemoInstall

react-dropzone

Package Overview
Dependencies
Maintainers
3
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dropzone - npm Package Compare versions

Comparing version 11.4.2 to 11.5.0

20

dist/es/index.js

@@ -185,2 +185,7 @@ var _excluded = ["children"],

/**
* Cb for when opening the file dialog
*/
onFileDialogOpen: PropTypes.func,
/**
* Cb for when the `dragenter` event occurs.

@@ -257,3 +262,3 @@ *

/**
* Custom validation function
* Custom validation function
* @param {File} file

@@ -379,2 +384,3 @@ * @returns {FileError|FileError[]}

* @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
* @param {Function} [props.onFileDialogOpen] Cb for when opening the file dialog
* @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.

@@ -431,2 +437,3 @@ * @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs

onFileDialogCancel = _defaultProps$options.onFileDialogCancel,
onFileDialogOpen = _defaultProps$options.onFileDialogOpen,
preventDropOnDocument = _defaultProps$options.preventDropOnDocument,

@@ -456,6 +463,11 @@ noClick = _defaultProps$options.noClick,

});
if (typeof onFileDialogOpen === 'function') {
onFileDialogOpen();
}
inputRef.current.value = null;
inputRef.current.click();
}
}, [dispatch]); // Update file dialog active state when the window is focused on
}, [dispatch, onFileDialogOpen]); // Update file dialog active state when the window is focused on

@@ -500,3 +512,3 @@ var onWindowFocus = function onWindowFocus() {

}
}, [rootRef, inputRef]); // Update focus state for the dropzone
}, [rootRef, inputRef, openFileDialog]); // Update focus state for the dropzone

@@ -527,3 +539,3 @@ var onFocusCb = useCallback(function () {

}
}, [inputRef, noClick]);
}, [inputRef, noClick, openFileDialog]);
var dragTargetsRef = useRef([]);

@@ -530,0 +542,0 @@

2

examples/validator/README.md
By providing `validator` prop you can specify custom validation for files.
The value must be a function that accepts File object and returns null if file should be accepted or error object/array of error objects if file should me rejected.
The value must be a function that accepts File object and returns null if file should be accepted or error object/array of error objects if file should be rejected.

@@ -5,0 +5,0 @@ ```jsx harmony

@@ -169,3 +169,3 @@ {

},
"version": "11.4.2",
"version": "11.5.0",
"engines": {

@@ -172,0 +172,0 @@ "node": ">= 10"

@@ -141,2 +141,3 @@ ![react-dropzone logo](https://raw.githubusercontent.com/react-dropzone/react-dropzone/master/logo/logo.png)

```
> ♿ this is also where you pass accessibility props like `role`, `aria-labelledby` ...etc.

@@ -143,0 +144,0 @@ In the example above, the provided `{onClick}` handler will be invoked before the internal one, therefore, internal callbacks can be prevented by simply using [stopPropagation](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation).

@@ -161,2 +161,7 @@ /* eslint prefer-template: 0 */

/**
* Cb for when opening the file dialog
*/
onFileDialogOpen: PropTypes.func,
/**

@@ -234,3 +239,3 @@ * Cb for when the `dragenter` event occurs.

/**
* Custom validation function
* Custom validation function
* @param {File} file

@@ -359,2 +364,3 @@ * @returns {FileError|FileError[]}

* @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
* @param {Function} [props.onFileDialogOpen] Cb for when opening the file dialog
* @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.

@@ -408,2 +414,3 @@ * @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs

onFileDialogCancel,
onFileDialogOpen,
preventDropOnDocument,

@@ -430,6 +437,9 @@ noClick,

dispatch({ type: 'openDialog' })
if (typeof onFileDialogOpen === 'function') {
onFileDialogOpen()
}
inputRef.current.value = null
inputRef.current.click()
}
}, [dispatch])
}, [dispatch, onFileDialogOpen])

@@ -475,3 +485,3 @@ // Update file dialog active state when the window is focused on

},
[rootRef, inputRef]
[rootRef, inputRef, openFileDialog]
)

@@ -501,3 +511,3 @@

}
}, [inputRef, noClick])
}, [inputRef, noClick, openFileDialog])

@@ -641,3 +651,3 @@ const dragTargetsRef = useRef([])

let errors = [acceptError, sizeError];
if (customErrors) {

@@ -658,3 +668,3 @@ errors = errors.concat(customErrors);

}
dispatch({

@@ -661,0 +671,0 @@ acceptedFiles,

@@ -44,2 +44,3 @@ import * as React from "react";

onFileDialogCancel?: () => void;
onFileDialogOpen?: ()=> void;
validator?: <T extends File>(file: T) => FileError | FileError[] | null;

@@ -46,0 +47,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc