react-dropzone 11.2.0 → 11.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitpod.yml ADDED
@@ -0,0 +1,6 @@
1
+ tasks:
2
+ - init: yarn install && yarn run build
3
+ command: yarn run start
4
+ ports:
5
+ - port: 8080
6
+ onOpen: open-preview
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 12.18
package/README.md CHANGED
@@ -3,10 +3,11 @@
3
3
  # react-dropzone
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/react-dropzone.svg?style=flat-square)](https://www.npmjs.com/package/react-dropzone)
6
- ![Build Status](https://github.com/react-dropzone/react-dropzone/workflows/Test/badge.svg)
6
+ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/react-dropzone/react-dropzone/Test?label=tests&style=flat-square)](https://github.com/react-dropzone/react-dropzone/actions?query=workflow%3ATest)
7
7
  [![codecov](https://img.shields.io/codecov/c/gh/react-dropzone/react-dropzone/master.svg?style=flat-square)](https://codecov.io/gh/react-dropzone/react-dropzone)
8
8
  [![Open Collective](https://img.shields.io/opencollective/backers/react-dropzone.svg?style=flat-square)](#backers)
9
9
  [![Open Collective](https://img.shields.io/opencollective/sponsors/react-dropzone.svg?style=flat-square)](#sponsors)
10
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/react-dropzone/react-dropzone)
10
11
 
11
12
  Simple React hook to create a HTML5-compliant drag'n'drop zone for files.
12
13
 
@@ -231,16 +232,11 @@ dropzoneRef.open()
231
232
 
232
233
  ## Testing
233
234
 
234
- *Important*: `react-dropzone` makes some of its drag 'n' drop callbacks asynchronous to enable promise based `getFilesFromEvent()` functions. In order to properly test this, you may want to utilize a helper function to run all promises like this:
235
- ```js static
236
- const flushPromises = () => new Promise(resolve => setImmediate(resolve))
237
- ```
238
-
239
- Example with [react-testing-library](https://github.com/kentcdodds/react-testing-library):
235
+ *Important*: `react-dropzone` makes some of its drag 'n' drop callbacks asynchronous to enable promise based `getFilesFromEvent()` functions. In order to test components that use this library, you may want to use the [react-testing-library](https://github.com/testing-library/react-testing-library):
240
236
  ```js static
241
237
  import React from 'react'
242
238
  import Dropzone from 'react-dropzone'
243
- import { fireEvent, render } from 'react-testing-library'
239
+ import { act, fireEvent, render, waitFor } from '@testing-library/react'
244
240
 
245
241
  test('invoke onDragEnter when dragenter event occurs', async () => {
246
242
  const file = new File([
@@ -258,22 +254,17 @@ test('invoke onDragEnter when dragenter event occurs', async () => {
258
254
  )}
259
255
  </Dropzone>
260
256
  )
261
- const { container } = render(ui)
257
+ const { container, rerender } = render(ui)
262
258
  const dropzone = container.querySelector('div')
263
259
 
264
260
  dispatchEvt(dropzone, 'dragenter', data)
265
- await flushPromises(ui, container)
261
+ await flushPromises(rerender, ui)
266
262
 
267
263
  expect(onDragEnter).toHaveBeenCalled()
268
264
  })
269
265
 
270
- function flushPromises(ui, container) {
271
- return new Promise(resolve =>
272
- setImmediate(() => {
273
- render(ui, { container })
274
- resolve(container)
275
- })
276
- )
266
+ async function flushPromises(rerender, ui) {
267
+ await act(() => waitFor(() => rerender(ui)))
277
268
  }
278
269
 
279
270
  function dispatchEvt(node, type, data) {
@@ -301,6 +292,15 @@ function mockData(files) {
301
292
 
302
293
  More examples for this can be found in `react-dropzone`s own [test suites](https://github.com/react-dropzone/react-dropzone/blob/master/src/index.spec.js).
303
294
 
295
+ ## Need image editing?
296
+
297
+ React Dropzone integrates perfectly with [Doka Image Editor](https://pqina.nl/doka/?ref=react-dropzone), creating a modern image editing experience. Doka supports crop aspect ratios, resizing, rotating, cropping, annotating, filtering, and much more.
298
+
299
+ Checkout the [integration example](https://react-dropzone.js.org/#!/Doka).
300
+
301
+ ## Supported Browsers
302
+
303
+ We use [browserslist](https://github.com/browserslist/browserslist) config to state the browser support for this lib, so check it out on [browserslist.dev](https://browserslist.dev/?q=ZGVmYXVsdHM%3D).
304
304
 
305
305
  ## Support
306
306
 
package/dist/es/index.js CHANGED
@@ -1,22 +1,26 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
2
 
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
 
5
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
6
6
 
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
8
 
9
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
10
 
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
12
 
13
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
+
17
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
18
 
15
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
20
 
17
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
18
22
 
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
24
 
21
25
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
26
 
@@ -44,7 +48,7 @@ import { allFilesAccepted, composeEventHandlers, fileAccepted, fileMatchSize, is
44
48
  * ```
45
49
  */
46
50
 
47
- var Dropzone = forwardRef(function (_ref, ref) {
51
+ var Dropzone = /*#__PURE__*/forwardRef(function (_ref, ref) {
48
52
  var children = _ref.children,
49
53
  params = _objectWithoutProperties(_ref, ["children"]);
50
54
 
@@ -58,11 +62,26 @@ var Dropzone = forwardRef(function (_ref, ref) {
58
62
  };
59
63
  }, [open]); // TODO: Figure out why react-styleguidist cannot create docs if we don't return a jsx element
60
64
 
61
- return React.createElement(Fragment, null, children(_objectSpread({}, props, {
65
+ return /*#__PURE__*/React.createElement(Fragment, null, children(_objectSpread(_objectSpread({}, props), {}, {
62
66
  open: open
63
67
  })));
64
68
  });
65
- Dropzone.displayName = 'Dropzone';
69
+ Dropzone.displayName = 'Dropzone'; // Add default props for react-docgen
70
+
71
+ var defaultProps = {
72
+ disabled: false,
73
+ getFilesFromEvent: fromEvent,
74
+ maxSize: Infinity,
75
+ minSize: 0,
76
+ multiple: true,
77
+ maxFiles: 0,
78
+ preventDropOnDocument: true,
79
+ noClick: false,
80
+ noKeyboard: false,
81
+ noDrag: false,
82
+ noDragEventsBubbling: false
83
+ };
84
+ Dropzone.defaultProps = defaultProps;
66
85
  Dropzone.propTypes = {
67
86
  /**
68
87
  * Render function that exposes the dropzone state and prop getter fns
@@ -376,37 +395,28 @@ var initialState = {
376
395
  */
377
396
 
378
397
  export function useDropzone() {
379
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
380
- accept = _ref2.accept,
381
- _ref2$disabled = _ref2.disabled,
382
- disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
383
- _ref2$getFilesFromEve = _ref2.getFilesFromEvent,
384
- getFilesFromEvent = _ref2$getFilesFromEve === void 0 ? fromEvent : _ref2$getFilesFromEve,
385
- _ref2$maxSize = _ref2.maxSize,
386
- maxSize = _ref2$maxSize === void 0 ? Infinity : _ref2$maxSize,
387
- _ref2$minSize = _ref2.minSize,
388
- minSize = _ref2$minSize === void 0 ? 0 : _ref2$minSize,
389
- _ref2$multiple = _ref2.multiple,
390
- multiple = _ref2$multiple === void 0 ? true : _ref2$multiple,
391
- _ref2$maxFiles = _ref2.maxFiles,
392
- maxFiles = _ref2$maxFiles === void 0 ? 0 : _ref2$maxFiles,
393
- onDragEnter = _ref2.onDragEnter,
394
- onDragLeave = _ref2.onDragLeave,
395
- onDragOver = _ref2.onDragOver,
396
- onDrop = _ref2.onDrop,
397
- onDropAccepted = _ref2.onDropAccepted,
398
- onDropRejected = _ref2.onDropRejected,
399
- onFileDialogCancel = _ref2.onFileDialogCancel,
400
- _ref2$preventDropOnDo = _ref2.preventDropOnDocument,
401
- preventDropOnDocument = _ref2$preventDropOnDo === void 0 ? true : _ref2$preventDropOnDo,
402
- _ref2$noClick = _ref2.noClick,
403
- noClick = _ref2$noClick === void 0 ? false : _ref2$noClick,
404
- _ref2$noKeyboard = _ref2.noKeyboard,
405
- noKeyboard = _ref2$noKeyboard === void 0 ? false : _ref2$noKeyboard,
406
- _ref2$noDrag = _ref2.noDrag,
407
- noDrag = _ref2$noDrag === void 0 ? false : _ref2$noDrag,
408
- _ref2$noDragEventsBub = _ref2.noDragEventsBubbling,
409
- noDragEventsBubbling = _ref2$noDragEventsBub === void 0 ? false : _ref2$noDragEventsBub;
398
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
399
+
400
+ var _defaultProps$options = _objectSpread(_objectSpread({}, defaultProps), options),
401
+ accept = _defaultProps$options.accept,
402
+ disabled = _defaultProps$options.disabled,
403
+ getFilesFromEvent = _defaultProps$options.getFilesFromEvent,
404
+ maxSize = _defaultProps$options.maxSize,
405
+ minSize = _defaultProps$options.minSize,
406
+ multiple = _defaultProps$options.multiple,
407
+ maxFiles = _defaultProps$options.maxFiles,
408
+ onDragEnter = _defaultProps$options.onDragEnter,
409
+ onDragLeave = _defaultProps$options.onDragLeave,
410
+ onDragOver = _defaultProps$options.onDragOver,
411
+ onDrop = _defaultProps$options.onDrop,
412
+ onDropAccepted = _defaultProps$options.onDropAccepted,
413
+ onDropRejected = _defaultProps$options.onDropRejected,
414
+ onFileDialogCancel = _defaultProps$options.onFileDialogCancel,
415
+ preventDropOnDocument = _defaultProps$options.preventDropOnDocument,
416
+ noClick = _defaultProps$options.noClick,
417
+ noKeyboard = _defaultProps$options.noKeyboard,
418
+ noDrag = _defaultProps$options.noDrag,
419
+ noDragEventsBubbling = _defaultProps$options.noDragEventsBubbling;
410
420
 
411
421
  var rootRef = useRef(null);
412
422
  var inputRef = useRef(null);
@@ -669,7 +679,7 @@ export function useDropzone() {
669
679
  dispatch({
670
680
  type: 'reset'
671
681
  });
672
- }, [multiple, accept, minSize, maxSize, getFilesFromEvent, onDrop, onDropAccepted, onDropRejected, noDragEventsBubbling]);
682
+ }, [multiple, accept, minSize, maxSize, maxFiles, getFilesFromEvent, onDrop, onDropAccepted, onDropRejected, noDragEventsBubbling]);
673
683
 
674
684
  var composeHandler = function composeHandler(fn) {
675
685
  return disabled ? null : fn;
@@ -691,20 +701,20 @@ export function useDropzone() {
691
701
 
692
702
  var getRootProps = useMemo(function () {
693
703
  return function () {
694
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
695
- _ref3$refKey = _ref3.refKey,
696
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
697
- onKeyDown = _ref3.onKeyDown,
698
- onFocus = _ref3.onFocus,
699
- onBlur = _ref3.onBlur,
700
- onClick = _ref3.onClick,
701
- onDragEnter = _ref3.onDragEnter,
702
- onDragOver = _ref3.onDragOver,
703
- onDragLeave = _ref3.onDragLeave,
704
- onDrop = _ref3.onDrop,
705
- rest = _objectWithoutProperties(_ref3, ["refKey", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"]);
706
-
707
- return _objectSpread(_defineProperty({
704
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
705
+ _ref2$refKey = _ref2.refKey,
706
+ refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
707
+ onKeyDown = _ref2.onKeyDown,
708
+ onFocus = _ref2.onFocus,
709
+ onBlur = _ref2.onBlur,
710
+ onClick = _ref2.onClick,
711
+ onDragEnter = _ref2.onDragEnter,
712
+ onDragOver = _ref2.onDragOver,
713
+ onDragLeave = _ref2.onDragLeave,
714
+ onDrop = _ref2.onDrop,
715
+ rest = _objectWithoutProperties(_ref2, ["refKey", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"]);
716
+
717
+ return _objectSpread(_objectSpread(_defineProperty({
708
718
  onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
709
719
  onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
710
720
  onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
@@ -715,7 +725,7 @@ export function useDropzone() {
715
725
  onDrop: composeDragHandler(composeEventHandlers(onDrop, onDropCb))
716
726
  }, refKey, rootRef), !disabled && !noKeyboard ? {
717
727
  tabIndex: 0
718
- } : {}, {}, rest);
728
+ } : {}), rest);
719
729
  };
720
730
  }, [rootRef, onKeyDownCb, onFocusCb, onBlurCb, onClickCb, onDragEnterCb, onDragOverCb, onDragLeaveCb, onDropCb, noKeyboard, noDrag, disabled]);
721
731
  var onInputElementClick = useCallback(function (event) {
@@ -723,12 +733,12 @@ export function useDropzone() {
723
733
  }, []);
724
734
  var getInputProps = useMemo(function () {
725
735
  return function () {
726
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
727
- _ref4$refKey = _ref4.refKey,
728
- refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
729
- onChange = _ref4.onChange,
730
- onClick = _ref4.onClick,
731
- rest = _objectWithoutProperties(_ref4, ["refKey", "onChange", "onClick"]);
736
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
737
+ _ref3$refKey = _ref3.refKey,
738
+ refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
739
+ onChange = _ref3.onChange,
740
+ onClick = _ref3.onClick,
741
+ rest = _objectWithoutProperties(_ref3, ["refKey", "onChange", "onClick"]);
732
742
 
733
743
  var inputProps = _defineProperty({
734
744
  accept: accept,
@@ -743,7 +753,7 @@ export function useDropzone() {
743
753
  tabIndex: -1
744
754
  }, refKey, inputRef);
745
755
 
746
- return _objectSpread({}, inputProps, {}, rest);
756
+ return _objectSpread(_objectSpread({}, inputProps), rest);
747
757
  };
748
758
  }, [inputRef, accept, multiple, onDropCb, disabled]);
749
759
  var fileCount = draggedFiles.length;
@@ -752,10 +762,11 @@ export function useDropzone() {
752
762
  accept: accept,
753
763
  minSize: minSize,
754
764
  maxSize: maxSize,
755
- multiple: multiple
765
+ multiple: multiple,
766
+ maxFiles: maxFiles
756
767
  });
757
768
  var isDragReject = fileCount > 0 && !isDragAccept;
758
- return _objectSpread({}, state, {
769
+ return _objectSpread(_objectSpread({}, state), {}, {
759
770
  isDragAccept: isDragAccept,
760
771
  isDragReject: isDragReject,
761
772
  isFocused: isFocused && !disabled,
@@ -771,22 +782,22 @@ function reducer(state, action) {
771
782
  /* istanbul ignore next */
772
783
  switch (action.type) {
773
784
  case 'focus':
774
- return _objectSpread({}, state, {
785
+ return _objectSpread(_objectSpread({}, state), {}, {
775
786
  isFocused: true
776
787
  });
777
788
 
778
789
  case 'blur':
779
- return _objectSpread({}, state, {
790
+ return _objectSpread(_objectSpread({}, state), {}, {
780
791
  isFocused: false
781
792
  });
782
793
 
783
794
  case 'openDialog':
784
- return _objectSpread({}, state, {
795
+ return _objectSpread(_objectSpread({}, state), {}, {
785
796
  isFileDialogActive: true
786
797
  });
787
798
 
788
799
  case 'closeDialog':
789
- return _objectSpread({}, state, {
800
+ return _objectSpread(_objectSpread({}, state), {}, {
790
801
  isFileDialogActive: false
791
802
  });
792
803
 
@@ -794,19 +805,19 @@ function reducer(state, action) {
794
805
  /* eslint no-case-declarations: 0 */
795
806
  var isDragActive = action.isDragActive,
796
807
  draggedFiles = action.draggedFiles;
797
- return _objectSpread({}, state, {
808
+ return _objectSpread(_objectSpread({}, state), {}, {
798
809
  draggedFiles: draggedFiles,
799
810
  isDragActive: isDragActive
800
811
  });
801
812
 
802
813
  case 'setFiles':
803
- return _objectSpread({}, state, {
814
+ return _objectSpread(_objectSpread({}, state), {}, {
804
815
  acceptedFiles: action.acceptedFiles,
805
816
  fileRejections: action.fileRejections
806
817
  });
807
818
 
808
819
  case 'reset':
809
- return _objectSpread({}, state, {
820
+ return _objectSpread(_objectSpread({}, state), {}, {
810
821
  isFileDialogActive: false,
811
822
  isDragActive: false,
812
823
  draggedFiles: [],
@@ -1,10 +1,14 @@
1
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
 
5
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
6
 
7
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
+
11
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
8
12
 
9
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
14
 
@@ -65,9 +69,10 @@ export function allFilesAccepted(_ref) {
65
69
  accept = _ref.accept,
66
70
  minSize = _ref.minSize,
67
71
  maxSize = _ref.maxSize,
68
- multiple = _ref.multiple;
72
+ multiple = _ref.multiple,
73
+ maxFiles = _ref.maxFiles;
69
74
 
70
- if (!multiple && files.length > 1) {
75
+ if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
71
76
  return false;
72
77
  }
73
78