react-dropzone 11.7.0 → 12.0.2

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/.eslintrc CHANGED
@@ -15,10 +15,8 @@
15
15
  "prettier"
16
16
  ],
17
17
  "extends": [
18
- // TODO: Fix this so we can use
19
- // "okonet/node"
20
18
  "eslint:recommended",
21
- "prettier"
19
+ "plugin:prettier/recommended"
22
20
  ],
23
21
  "rules": {
24
22
  "strict": 0,
package/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
  [![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)
7
7
  [![Open Collective Backers](https://img.shields.io/opencollective/backers/react-dropzone.svg?style=flat-square)](#backers)
8
8
  [![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/react-dropzone.svg?style=flat-square)](#sponsors)
9
- [![Gitpod](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)
9
+ [![Gitpod](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
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=flat-square)](https://github.com/react-dropzone/.github/blob/main/CODE_OF_CONDUCT.md)
10
11
 
11
12
  Simple React hook to create a HTML5-compliant drag'n'drop zone for files.
12
13
 
@@ -344,6 +345,10 @@ Fortunately, there's the [File System Access API](https://developer.mozilla.org/
344
345
 
345
346
  And this lib makes use of it if available. Though, there's a small catch: using file extensions for the `accept` property is not supported; you must use MIME types as described in [common MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types). Also check [accepting specific file types](https://react-dropzone.js.org/#section-accepting-specific-file-types) for more info on the subject of `accept` limitations.
346
347
 
348
+ Also keep in mind that the FS access API can only be used in [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).
349
+
350
+ **NOTE** You can disable using the FS access API with the `useFsAccessApi` property: `useDropzone({useFsAccessApi: false})`.
351
+
347
352
  ## Supported Browsers
348
353
  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).
349
354
 
@@ -1 +1 @@
1
- module.exports = { extends: ['@commitlint/config-angular'] }
1
+ module.exports = { extends: ["@commitlint/config-angular"] };
package/dist/es/index.js CHANGED
@@ -34,10 +34,10 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
34
34
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
35
35
 
36
36
  /* eslint prefer-template: 0 */
37
- import React, { forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef } from 'react';
38
- import PropTypes from 'prop-types';
39
- import { fromEvent } from 'file-selector';
40
- import { allFilesAccepted, composeEventHandlers, fileAccepted, fileMatchSize, filePickerOptionsTypes, canUseFileSystemAccessAPI, isEvtWithFiles, isIeOrEdge, isPropagationStopped, onDocumentDragOver, TOO_MANY_FILES_REJECTION } from './utils/index';
37
+ import React, { forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef } from "react";
38
+ import PropTypes from "prop-types";
39
+ import { fromEvent } from "file-selector";
40
+ import { allFilesAccepted, composeEventHandlers, fileAccepted, fileMatchSize, filePickerOptionsTypes, canUseFileSystemAccessAPI, isEvtWithFiles, isIeOrEdge, isPropagationStopped, onDocumentDragOver, TOO_MANY_FILES_REJECTION } from "./utils/index";
41
41
  /**
42
42
  * Convenience wrapper component for the `useDropzone` hook
43
43
  *
@@ -71,7 +71,7 @@ var Dropzone = /*#__PURE__*/forwardRef(function (_ref, ref) {
71
71
  open: open
72
72
  })));
73
73
  });
74
- Dropzone.displayName = 'Dropzone'; // Add default props for react-docgen
74
+ Dropzone.displayName = "Dropzone"; // Add default props for react-docgen
75
75
 
76
76
  var defaultProps = {
77
77
  disabled: false,
@@ -85,7 +85,8 @@ var defaultProps = {
85
85
  noKeyboard: false,
86
86
  noDrag: false,
87
87
  noDragEventsBubbling: false,
88
- validator: null
88
+ validator: null,
89
+ useFsAccessApi: true
89
90
  };
90
91
  Dropzone.defaultProps = defaultProps;
91
92
  Dropzone.propTypes = {
@@ -186,6 +187,12 @@ Dropzone.propTypes = {
186
187
  */
187
188
  onFileDialogOpen: PropTypes.func,
188
189
 
190
+ /**
191
+ * Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
192
+ * to open the file picker instead of using an `<input type="file">` click event.
193
+ */
194
+ useFsAccessApi: PropTypes.bool,
195
+
189
196
  /**
190
197
  * Cb for when the `dragenter` event occurs.
191
198
  *
@@ -379,6 +386,8 @@ var initialState = {
379
386
  * @param {boolean} [props.disabled=false] Enable/disable the dropzone
380
387
  * @param {getFilesFromEvent} [props.getFilesFromEvent] Use this to provide a custom file aggregator
381
388
  * @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
389
+ * @param {boolean} [props.useFsAccessApi] Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
390
+ * to open the file picker instead of using an `<input type="file">` click event.
382
391
  * @param {Function} [props.onFileDialogOpen] Cb for when opening the file dialog
383
392
  * @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.
384
393
  * @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs
@@ -432,6 +441,7 @@ export function useDropzone() {
432
441
  onDropRejected = _defaultProps$options.onDropRejected,
433
442
  onFileDialogCancel = _defaultProps$options.onFileDialogCancel,
434
443
  onFileDialogOpen = _defaultProps$options.onFileDialogOpen,
444
+ useFsAccessApi = _defaultProps$options.useFsAccessApi,
435
445
  preventDropOnDocument = _defaultProps$options.preventDropOnDocument,
436
446
  noClick = _defaultProps$options.noClick,
437
447
  noKeyboard = _defaultProps$options.noKeyboard,
@@ -440,10 +450,10 @@ export function useDropzone() {
440
450
  validator = _defaultProps$options.validator;
441
451
 
442
452
  var onFileDialogOpenCb = useMemo(function () {
443
- return typeof onFileDialogOpen === 'function' ? onFileDialogOpen : noop;
453
+ return typeof onFileDialogOpen === "function" ? onFileDialogOpen : noop;
444
454
  }, [onFileDialogOpen]);
445
455
  var onFileDialogCancelCb = useMemo(function () {
446
- return typeof onFileDialogCancel === 'function' ? onFileDialogCancel : noop;
456
+ return typeof onFileDialogCancel === "function" ? onFileDialogCancel : noop;
447
457
  }, [onFileDialogCancel]);
448
458
  var rootRef = useRef(null);
449
459
  var inputRef = useRef(null);
@@ -466,7 +476,7 @@ export function useDropzone() {
466
476
 
467
477
  if (!files.length) {
468
478
  dispatch({
469
- type: 'closeDialog'
479
+ type: "closeDialog"
470
480
  });
471
481
  onFileDialogCancelCb();
472
482
  }
@@ -476,15 +486,15 @@ export function useDropzone() {
476
486
  };
477
487
 
478
488
  useEffect(function () {
479
- if (canUseFileSystemAccessAPI()) {
489
+ if (window.isSecureContext && useFsAccessApi && canUseFileSystemAccessAPI()) {
480
490
  return function () {};
481
491
  }
482
492
 
483
- window.addEventListener('focus', onWindowFocus, false);
493
+ window.addEventListener("focus", onWindowFocus, false);
484
494
  return function () {
485
- window.removeEventListener('focus', onWindowFocus, false);
495
+ window.removeEventListener("focus", onWindowFocus, false);
486
496
  };
487
- }, [inputRef, isFileDialogActive, onFileDialogCancelCb]);
497
+ }, [inputRef, isFileDialogActive, onFileDialogCancelCb, useFsAccessApi]);
488
498
  var dragTargetsRef = useRef([]);
489
499
 
490
500
  var onDocumentDrop = function onDocumentDrop(event) {
@@ -499,14 +509,14 @@ export function useDropzone() {
499
509
 
500
510
  useEffect(function () {
501
511
  if (preventDropOnDocument) {
502
- document.addEventListener('dragover', onDocumentDragOver, false);
503
- document.addEventListener('drop', onDocumentDrop, false);
512
+ document.addEventListener("dragover", onDocumentDragOver, false);
513
+ document.addEventListener("drop", onDocumentDrop, false);
504
514
  }
505
515
 
506
516
  return function () {
507
517
  if (preventDropOnDocument) {
508
- document.removeEventListener('dragover', onDocumentDragOver);
509
- document.removeEventListener('drop', onDocumentDrop);
518
+ document.removeEventListener("dragover", onDocumentDragOver);
519
+ document.removeEventListener("drop", onDocumentDrop);
510
520
  }
511
521
  };
512
522
  }, [rootRef, preventDropOnDocument]);
@@ -526,7 +536,7 @@ export function useDropzone() {
526
536
  dispatch({
527
537
  draggedFiles: draggedFiles,
528
538
  isDragActive: true,
529
- type: 'setDraggedFiles'
539
+ type: "setDraggedFiles"
530
540
  });
531
541
 
532
542
  if (onDragEnter) {
@@ -543,7 +553,7 @@ export function useDropzone() {
543
553
 
544
554
  if (hasFiles && event.dataTransfer) {
545
555
  try {
546
- event.dataTransfer.dropEffect = 'copy';
556
+ event.dataTransfer.dropEffect = "copy";
547
557
  } catch (_unused) {}
548
558
  /* eslint-disable-line no-empty */
549
559
 
@@ -579,7 +589,7 @@ export function useDropzone() {
579
589
 
580
590
  dispatch({
581
591
  isDragActive: false,
582
- type: 'setDraggedFiles',
592
+ type: "setDraggedFiles",
583
593
  draggedFiles: []
584
594
  });
585
595
 
@@ -635,7 +645,7 @@ export function useDropzone() {
635
645
  dispatch({
636
646
  acceptedFiles: acceptedFiles,
637
647
  fileRejections: fileRejections,
638
- type: 'setFiles'
648
+ type: "setFiles"
639
649
  });
640
650
 
641
651
  if (onDrop) {
@@ -668,14 +678,16 @@ export function useDropzone() {
668
678
  }
669
679
 
670
680
  dispatch({
671
- type: 'reset'
681
+ type: "reset"
672
682
  });
673
683
  }, [getFilesFromEvent, setFiles, noDragEventsBubbling]); // Fn for opening the file dialog programmatically
674
684
 
675
685
  var openFileDialog = useCallback(function () {
676
- if (canUseFileSystemAccessAPI()) {
686
+ // No point to use FS access APIs if context is not secure
687
+ // https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#feature_detection
688
+ if (window.isSecureContext && useFsAccessApi && canUseFileSystemAccessAPI()) {
677
689
  dispatch({
678
- type: 'openDialog'
690
+ type: "openDialog"
679
691
  });
680
692
  onFileDialogOpenCb(); // https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
681
693
 
@@ -691,7 +703,7 @@ export function useDropzone() {
691
703
  return onFileDialogCancelCb(e);
692
704
  }).finally(function () {
693
705
  return dispatch({
694
- type: 'closeDialog'
706
+ type: "closeDialog"
695
707
  });
696
708
  });
697
709
  return;
@@ -699,13 +711,13 @@ export function useDropzone() {
699
711
 
700
712
  if (inputRef.current) {
701
713
  dispatch({
702
- type: 'openDialog'
714
+ type: "openDialog"
703
715
  });
704
716
  onFileDialogOpenCb();
705
717
  inputRef.current.value = null;
706
718
  inputRef.current.click();
707
719
  }
708
- }, [dispatch, onFileDialogOpenCb, onFileDialogCancelCb, setFiles, accept, multiple]); // Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
720
+ }, [dispatch, onFileDialogOpenCb, onFileDialogCancelCb, useFsAccessApi, setFiles, accept, multiple]); // Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
709
721
 
710
722
  var onKeyDownCb = useCallback(function (event) {
711
723
  // Ignore keyboard events bubbling up the DOM tree
@@ -721,12 +733,12 @@ export function useDropzone() {
721
733
 
722
734
  var onFocusCb = useCallback(function () {
723
735
  dispatch({
724
- type: 'focus'
736
+ type: "focus"
725
737
  });
726
738
  }, []);
727
739
  var onBlurCb = useCallback(function () {
728
740
  dispatch({
729
- type: 'blur'
741
+ type: "blur"
730
742
  });
731
743
  }, []); // Cb to open the file dialog when click occurs on the dropzone
732
744
 
@@ -767,7 +779,7 @@ export function useDropzone() {
767
779
  return function () {
768
780
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
769
781
  _ref2$refKey = _ref2.refKey,
770
- refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
782
+ refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey,
771
783
  role = _ref2.role,
772
784
  onKeyDown = _ref2.onKeyDown,
773
785
  onFocus = _ref2.onFocus,
@@ -788,7 +800,7 @@ export function useDropzone() {
788
800
  onDragOver: composeDragHandler(composeEventHandlers(onDragOver, onDragOverCb)),
789
801
  onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave, onDragLeaveCb)),
790
802
  onDrop: composeDragHandler(composeEventHandlers(onDrop, onDropCb)),
791
- role: typeof role === 'string' && role !== '' ? role : 'button'
803
+ role: typeof role === "string" && role !== "" ? role : "button"
792
804
  }, refKey, rootRef), !disabled && !noKeyboard ? {
793
805
  tabIndex: 0
794
806
  } : {}), rest);
@@ -801,7 +813,7 @@ export function useDropzone() {
801
813
  return function () {
802
814
  var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
803
815
  _ref3$refKey = _ref3.refKey,
804
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
816
+ refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey,
805
817
  onChange = _ref3.onChange,
806
818
  onClick = _ref3.onClick,
807
819
  rest = _objectWithoutProperties(_ref3, _excluded4);
@@ -809,13 +821,13 @@ export function useDropzone() {
809
821
  var inputProps = _defineProperty({
810
822
  accept: accept,
811
823
  multiple: multiple,
812
- type: 'file',
824
+ type: "file",
813
825
  style: {
814
- display: 'none'
826
+ display: "none"
815
827
  },
816
828
  onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
817
829
  onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
818
- autoComplete: 'off',
830
+ autoComplete: "off",
819
831
  tabIndex: -1
820
832
  }, refKey, inputRef);
821
833
 
@@ -847,27 +859,27 @@ export function useDropzone() {
847
859
  function reducer(state, action) {
848
860
  /* istanbul ignore next */
849
861
  switch (action.type) {
850
- case 'focus':
862
+ case "focus":
851
863
  return _objectSpread(_objectSpread({}, state), {}, {
852
864
  isFocused: true
853
865
  });
854
866
 
855
- case 'blur':
867
+ case "blur":
856
868
  return _objectSpread(_objectSpread({}, state), {}, {
857
869
  isFocused: false
858
870
  });
859
871
 
860
- case 'openDialog':
872
+ case "openDialog":
861
873
  return _objectSpread(_objectSpread({}, initialState), {}, {
862
874
  isFileDialogActive: true
863
875
  });
864
876
 
865
- case 'closeDialog':
877
+ case "closeDialog":
866
878
  return _objectSpread(_objectSpread({}, state), {}, {
867
879
  isFileDialogActive: false
868
880
  });
869
881
 
870
- case 'setDraggedFiles':
882
+ case "setDraggedFiles":
871
883
  /* eslint no-case-declarations: 0 */
872
884
  var isDragActive = action.isDragActive,
873
885
  draggedFiles = action.draggedFiles;
@@ -876,13 +888,13 @@ function reducer(state, action) {
876
888
  isDragActive: isDragActive
877
889
  });
878
890
 
879
- case 'setFiles':
891
+ case "setFiles":
880
892
  return _objectSpread(_objectSpread({}, state), {}, {
881
893
  acceptedFiles: action.acceptedFiles,
882
894
  fileRejections: action.fileRejections
883
895
  });
884
896
 
885
- case 'reset':
897
+ case "reset":
886
898
  return _objectSpread({}, initialState);
887
899
 
888
900
  default:
@@ -892,4 +904,4 @@ function reducer(state, action) {
892
904
 
893
905
  function noop() {}
894
906
 
895
- export { ErrorCode } from './utils';
907
+ export { ErrorCode } from "./utils";
@@ -18,12 +18,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
18
18
 
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
- import accepts from 'attr-accept'; // Error codes
21
+ import accepts from "attr-accept"; // Error codes
22
22
 
23
- export var FILE_INVALID_TYPE = 'file-invalid-type';
24
- export var FILE_TOO_LARGE = 'file-too-large';
25
- export var FILE_TOO_SMALL = 'file-too-small';
26
- export var TOO_MANY_FILES = 'too-many-files';
23
+ export var FILE_INVALID_TYPE = "file-invalid-type";
24
+ export var FILE_TOO_LARGE = "file-too-large";
25
+ export var FILE_TOO_SMALL = "file-too-small";
26
+ export var TOO_MANY_FILES = "too-many-files";
27
27
  export var ErrorCode = {
28
28
  FileInvalidType: FILE_INVALID_TYPE,
29
29
  FileTooLarge: FILE_TOO_LARGE,
@@ -33,7 +33,7 @@ export var ErrorCode = {
33
33
 
34
34
  export var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(accept) {
35
35
  accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
36
- var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(', ')) : accept;
36
+ var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(", ")) : accept;
37
37
  return {
38
38
  code: FILE_INVALID_TYPE,
39
39
  message: "File type must be ".concat(messageSuffix)
@@ -42,23 +42,23 @@ export var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(acce
42
42
  export var getTooLargeRejectionErr = function getTooLargeRejectionErr(maxSize) {
43
43
  return {
44
44
  code: FILE_TOO_LARGE,
45
- message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? 'byte' : 'bytes')
45
+ message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? "byte" : "bytes")
46
46
  };
47
47
  };
48
48
  export var getTooSmallRejectionErr = function getTooSmallRejectionErr(minSize) {
49
49
  return {
50
50
  code: FILE_TOO_SMALL,
51
- message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? 'byte' : 'bytes')
51
+ message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? "byte" : "bytes")
52
52
  };
53
53
  };
54
54
  export var TOO_MANY_FILES_REJECTION = {
55
55
  code: TOO_MANY_FILES,
56
- message: 'Too many files'
56
+ message: "Too many files"
57
57
  }; // Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
58
58
  // that MIME type will always be accepted
59
59
 
60
60
  export function fileAccepted(file, accept) {
61
- var isAcceptable = file.type === 'application/x-moz-file' || accepts(file, accept);
61
+ var isAcceptable = file.type === "application/x-moz-file" || accepts(file, accept);
62
62
  return [isAcceptable, isAcceptable ? null : getInvalidTypeRejectionErr(accept)];
63
63
  }
64
64
  export function fileMatchSize(file, minSize, maxSize) {
@@ -104,9 +104,9 @@ export function allFilesAccepted(_ref) {
104
104
  // to check event.cancelBubble
105
105
 
106
106
  export function isPropagationStopped(event) {
107
- if (typeof event.isPropagationStopped === 'function') {
107
+ if (typeof event.isPropagationStopped === "function") {
108
108
  return event.isPropagationStopped();
109
- } else if (typeof event.cancelBubble !== 'undefined') {
109
+ } else if (typeof event.cancelBubble !== "undefined") {
110
110
  return event.cancelBubble;
111
111
  }
112
112
 
@@ -120,11 +120,11 @@ export function isEvtWithFiles(event) {
120
120
 
121
121
 
122
122
  return Array.prototype.some.call(event.dataTransfer.types, function (type) {
123
- return type === 'Files' || type === 'application/x-moz-file';
123
+ return type === "Files" || type === "application/x-moz-file";
124
124
  });
125
125
  }
126
126
  export function isKindFile(item) {
127
- return _typeof(item) === 'object' && item !== null && item.kind === 'file';
127
+ return _typeof(item) === "object" && item !== null && item.kind === "file";
128
128
  } // allow the entire document to be a drag target
129
129
 
130
130
  export function onDocumentDragOver(event) {
@@ -132,11 +132,11 @@ export function onDocumentDragOver(event) {
132
132
  }
133
133
 
134
134
  function isIe(userAgent) {
135
- return userAgent.indexOf('MSIE') !== -1 || userAgent.indexOf('Trident/') !== -1;
135
+ return userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident/") !== -1;
136
136
  }
137
137
 
138
138
  function isEdge(userAgent) {
139
- return userAgent.indexOf('Edge/') !== -1;
139
+ return userAgent.indexOf("Edge/") !== -1;
140
140
  }
141
141
 
142
142
  export function isIeOrEdge() {
@@ -180,7 +180,7 @@ export function composeEventHandlers() {
180
180
  */
181
181
 
182
182
  export function canUseFileSystemAccessAPI() {
183
- return 'showOpenFilePicker' in window;
183
+ return "showOpenFilePicker" in window;
184
184
  }
185
185
  /**
186
186
  * filePickerOptionsTypes returns the {types} option for https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
@@ -190,14 +190,14 @@ export function canUseFileSystemAccessAPI() {
190
190
  */
191
191
 
192
192
  export function filePickerOptionsTypes(accept) {
193
- accept = typeof accept === 'string' ? accept.split(',') : accept;
193
+ accept = typeof accept === "string" ? accept.split(",") : accept;
194
194
  return [{
195
- description: 'everything',
195
+ description: "everything",
196
196
  // TODO: Need to handle filtering more elegantly than this!
197
- accept: Array.isArray(accept) // Accept just MIME types as per spec
197
+ accept: Array.isArray(accept) ? // Accept just MIME types as per spec
198
198
  // NOTE: accept can be https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers
199
- ? accept.filter(function (item) {
200
- return item === 'audio/*' || item === 'video/*' || item === 'image/*' || item === 'text/*' || /\w+\/[-+.\w]+/g.test(item);
199
+ accept.filter(function (item) {
200
+ return item === "audio/*" || item === "video/*" || item === "image/*" || item === "text/*" || /\w+\/[-+.\w]+/g.test(item);
201
201
  }).reduce(function (a, b) {
202
202
  return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, b, []));
203
203
  }, {}) : {}