Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dropzone

Package Overview
Dependencies
Maintainers
2
Versions
189
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 6.2.1 to 6.2.2

2

dist/es/index.js

@@ -295,3 +295,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

if (isIeOrEdge()) {
setTimeout(this.open.bind(this), 0);
setTimeout(this.open, 0);
} else {

@@ -298,0 +298,0 @@ this.open();

@@ -46,2 +46,5 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

export function isDragDataWithFiles(evt) {
if (!evt.dataTransfer) {
return true;
}
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types

@@ -55,3 +58,3 @@ // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file

export function isKindFile(item) {
return (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && item.kind === 'file';
return (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && item !== null && item.kind === 'file';
}

@@ -58,0 +61,0 @@

@@ -146,3 +146,3 @@ {

},
"version": "6.2.1",
"version": "6.2.2",
"engines": {

@@ -149,0 +149,0 @@ "node": ">= 6"

@@ -251,3 +251,3 @@ /* eslint prefer-template: 0 */

if (isIeOrEdge()) {
setTimeout(this.open.bind(this), 0)
setTimeout(this.open, 0)
} else {

@@ -254,0 +254,0 @@ this.open()

@@ -8,3 +8,3 @@ /* eslint jsx-a11y/click-events-have-key-events: 0 */

import styles from './utils/styles'
import { onDocumentDragOver } from './utils'
import * as utils from './utils'

@@ -174,3 +174,3 @@ const flushPromises = wrapper =>

onDocumentDragOver(event)
utils.onDocumentDragOver(event)
expect(event.preventDefault).toHaveBeenCalledTimes(1)

@@ -336,2 +336,16 @@ event.preventDefault.mockClear()

})
it('should schedule open() on next tick when Edge', () => {
const isIeOrEdgeSpy = jest.spyOn(utils, 'isIeOrEdge').mockReturnValueOnce(true)
const setTimeoutSpy = jest.spyOn(window, 'setTimeout').mockImplementationOnce(open => open())
const dropzone = mount(<Dropzone />)
const open = jest.spyOn(dropzone.instance(), 'open')
dropzone.simulate('click')
expect(setTimeoutSpy).toHaveBeenCalled()
expect(open).toHaveBeenCalled()
isIeOrEdgeSpy.mockClear()
setTimeoutSpy.mockClear()
})
})

@@ -769,2 +783,26 @@

it('invokes onDop cb when native file section occurs', async () => {
const props = {
onDrop: jest.fn(),
onDropAccepted: jest.fn(),
onDropRejected: jest.fn()
}
const component = mount(<Dropzone {...props} />)
const input = component.find('input')
const evt = {
target: { files },
preventDefault() {},
persist() {}
}
input.props().onChange(evt)
await flushPromises(component)
expect(props.onDrop).toHaveBeenCalledWith(evt.target.files, [], evt)
expect(props.onDropAccepted).toHaveBeenCalledWith(evt.target.files, evt)
expect(props.onDropRejected).not.toHaveBeenCalled()
})
describe('onDrop', () => {

@@ -771,0 +809,0 @@ const expectedEvent = expect.anything()

@@ -45,2 +45,5 @@ import accepts from 'attr-accept'

export function isDragDataWithFiles(evt) {
if (!evt.dataTransfer) {
return true
}
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types

@@ -55,3 +58,3 @@ // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file

export function isKindFile(item) {
return typeof item === 'object' && item.kind === 'file'
return typeof item === 'object' && item !== null && item.kind === 'file'
}

@@ -58,0 +61,0 @@

@@ -1,2 +0,2 @@

import { getDataTransferItems, isIeOrEdge, isDragDataWithFiles } from './'
import { getDataTransferItems, isIeOrEdge, isKindFile, isDragDataWithFiles } from './'

@@ -127,2 +127,11 @@ const files = [

describe('isKindFile()', () => {
it('should return true for DataTransferItem of kind "file"', () => {
expect(isKindFile({ kind: 'file' })).toBe(true)
expect(isKindFile({ kind: 'text/html' })).toBe(false)
expect(isKindFile({})).toBe(false)
expect(isKindFile(null)).toBe(false)
})
})
describe('isDragDataWithFiles()', () => {

@@ -146,2 +155,6 @@ it('should return true if every dragged type is a file', () => {

})
it('should return true if {dataTransfer} is not defined', () => {
expect(isDragDataWithFiles({})).toBe(true)
})
})

@@ -1,9 +0,2 @@

import React, {
CSSProperties,
Component,
InputHTMLAttributes,
HTMLProps,
ReactNode,
Ref
} from "react";
import * as React from "react";

@@ -38,3 +31,3 @@ export interface FileWithPreview extends File {

export type DropzoneProps = Omit<HTMLProps<HTMLDivElement>, "onDrop" | "ref"> & {
export type DropzoneProps = Omit<React.HTMLProps<HTMLDivElement>, "onDrop" | "ref"> & {
disableClick?: boolean;

@@ -44,3 +37,3 @@ disabled?: boolean;

preventDropOnDocument?: boolean;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
maxSize?: number;

@@ -52,6 +45,6 @@ minSize?: number;

disabledClassName?: string;
activeStyle?: CSSProperties;
acceptStyle?: CSSProperties;
rejectStyle?: CSSProperties;
disabledStyle?: CSSProperties;
activeStyle?: React.CSSProperties;
acceptStyle?: React.CSSProperties;
rejectStyle?: React.CSSProperties;
disabledStyle?: React.CSSProperties;
onDrop?: DropFilesEventHandler;

@@ -62,8 +55,8 @@ onDropAccepted?: DropFileEventHandler;

getDataTransferItems?(event: React.DragEvent<HTMLDivElement> | DragEvent): Promise<Array<File | DataTransferItem>>;
children?: ReactNode | DropzoneRenderFunction;
ref?: Ref<Dropzone>;
children?: React.ReactNode | DropzoneRenderFunction;
ref?: React.Ref<Dropzone>;
};
export default class Dropzone extends Component<DropzoneProps> {
export default class Dropzone extends React.Component<DropzoneProps> {
open: () => void;
}

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

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