react-dropzone 14.3.4 → 14.3.5

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/README.md CHANGED
@@ -339,6 +339,19 @@ Also keep in mind that the FS access API can only be used in [secure contexts](h
339
339
 
340
340
  **NOTE** You can enable using the FS access API with the `useFsAccessApi` property: `useDropzone({useFsAccessApi: true})`.
341
341
 
342
+ ### File System Access API
343
+
344
+ When setting `useFsAccessApi` to `true`, you're switching to the [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) (see the [file system access](https://wicg.github.io/file-system-access/) RFC).
345
+
346
+ What this essentially does is that it will use the [showOpenFilePicker](https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker) method to open the file picker window so that the user can select files.
347
+
348
+ In contrast, the traditional way (when the `useFsAccessApi` is not set to `true` or not specified) uses an `<input type="file">` (see [docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file)) on which a click event is triggered.
349
+
350
+ With the use of the file system access API enabled, there's a couple of caveats to keep in mind:
351
+ 1. The users will not be able to select directories
352
+ 2. It requires the app to run in a [secure context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts)
353
+ 3. In [Electron](https://www.electronjs.org/), the path may not be set (see [#1249](https://github.com/react-dropzone/react-dropzone/issues/1249))
354
+
342
355
  ## Supported Browsers
343
356
  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).
344
357
 
@@ -38,14 +38,19 @@ export var ErrorCode = {
38
38
  FileTooLarge: FILE_TOO_LARGE,
39
39
  FileTooSmall: FILE_TOO_SMALL,
40
40
  TooManyFiles: TOO_MANY_FILES
41
- }; // File Errors
41
+ };
42
+ /**
43
+ *
44
+ * @param {string} accept
45
+ */
42
46
 
43
- export var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(accept) {
44
- accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
45
- var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(", ")) : accept;
47
+ export var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr() {
48
+ var accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
49
+ var acceptArr = accept.split(",");
50
+ var msg = acceptArr.length > 1 ? "one of ".concat(acceptArr.join(", ")) : acceptArr[0];
46
51
  return {
47
52
  code: FILE_INVALID_TYPE,
48
- message: "File type must be ".concat(messageSuffix)
53
+ message: "File type must be ".concat(msg)
49
54
  };
50
55
  };
51
56
  export var getTooLargeRejectionErr = function getTooLargeRejectionErr(maxSize) {
@@ -63,8 +68,17 @@ export var getTooSmallRejectionErr = function getTooSmallRejectionErr(minSize) {
63
68
  export var TOO_MANY_FILES_REJECTION = {
64
69
  code: TOO_MANY_FILES,
65
70
  message: "Too many files"
66
- }; // Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
67
- // that MIME type will always be accepted
71
+ };
72
+ /**
73
+ * Check if file is accepted.
74
+ *
75
+ * Firefox versions prior to 53 return a bogus MIME type for every file drag,
76
+ * so dragovers with that MIME type will always be accepted.
77
+ *
78
+ * @param {File} file
79
+ * @param {string} accept
80
+ * @returns
81
+ */
68
82
 
69
83
  export function fileAccepted(file, accept) {
70
84
  var isAcceptable = file.type === "application/x-moz-file" || accepts(file, accept);
@@ -88,7 +102,7 @@ function isDefined(value) {
88
102
  *
89
103
  * @param {object} options
90
104
  * @param {File[]} options.files
91
- * @param {string|string[]} [options.accept]
105
+ * @param {string} [options.accept]
92
106
  * @param {number} [options.minSize]
93
107
  * @param {number} [options.maxSize]
94
108
  * @param {boolean} [options.multiple]