@reykjavik/hanna-react 0.10.88 → 0.10.89
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/CHANGELOG.md +2 -2
- package/FileInput.js +7 -7
- package/esm/FileInput.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/FileInput.js
CHANGED
|
@@ -7,7 +7,7 @@ const react_dropzone_1 = require("react-dropzone"); // https://react-dropzone.js
|
|
|
7
7
|
const hooks_1 = require("@hugsmidjan/react/hooks");
|
|
8
8
|
const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
|
|
9
9
|
const i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
10
|
-
const
|
|
10
|
+
const _FileInput_utils_js_1 = require("./FileInput/_FileInput.utils.js");
|
|
11
11
|
const _FileInputFileList_js_1 = require("./FileInput/_FileInputFileList.js");
|
|
12
12
|
const FormField_js_1 = tslib_1.__importDefault(require("./FormField.js"));
|
|
13
13
|
const defaultRemoveFileText = {
|
|
@@ -40,7 +40,7 @@ const FileInput = (props) => {
|
|
|
40
40
|
const { getRootProps, getInputProps, isDragReject, inputRef } = (0, react_dropzone_1.useDropzone)({
|
|
41
41
|
onDrop: (acceptedFiles) => {
|
|
42
42
|
acceptedFiles = acceptedFiles.map((file) => {
|
|
43
|
-
(0,
|
|
43
|
+
(0, _FileInput_utils_js_1.addPreview)(file);
|
|
44
44
|
return file;
|
|
45
45
|
});
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -67,14 +67,14 @@ const FileInput = (props) => {
|
|
|
67
67
|
});
|
|
68
68
|
// Synchronoyusly add previews on incoming files
|
|
69
69
|
// (NOTE: `addPreview` ignores files that already have preview.)
|
|
70
|
-
files.forEach(
|
|
70
|
+
files.forEach(_FileInput_utils_js_1.addPreview);
|
|
71
71
|
(0, react_1.useEffect)(() => {
|
|
72
72
|
if (fileInput.current) {
|
|
73
73
|
fileInput.current.files = arrayToFileList(files);
|
|
74
74
|
}
|
|
75
75
|
return () => {
|
|
76
76
|
// Make sure to revoke the data uris on unmount to avoid memory leaks
|
|
77
|
-
files.forEach(
|
|
77
|
+
files.forEach(_FileInput_utils_js_1.releasePreview);
|
|
78
78
|
};
|
|
79
79
|
}, [files]);
|
|
80
80
|
const removeFile = (removeTarget) => {
|
|
@@ -85,7 +85,7 @@ const FileInput = (props) => {
|
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
deleted.push(file);
|
|
88
|
-
(0,
|
|
88
|
+
(0, _FileInput_utils_js_1.releasePreview)(file);
|
|
89
89
|
return false;
|
|
90
90
|
});
|
|
91
91
|
if (fileInput.current) {
|
|
@@ -94,7 +94,7 @@ const FileInput = (props) => {
|
|
|
94
94
|
onFilesUpdated(fileList, { deleted });
|
|
95
95
|
};
|
|
96
96
|
const addFiles = (added) => {
|
|
97
|
-
const { fileList, diff } = (0,
|
|
97
|
+
const { fileList, diff } = (0, _FileInput_utils_js_1.getFileListUpdate)(files, added, !multiple);
|
|
98
98
|
if (fileInput.current) {
|
|
99
99
|
fileInput.current.files = arrayToFileList(fileList);
|
|
100
100
|
}
|
|
@@ -126,7 +126,7 @@ const FileInput = (props) => {
|
|
|
126
126
|
showImagePreviews,
|
|
127
127
|
removeFileText,
|
|
128
128
|
removeFile,
|
|
129
|
-
formatBytes:
|
|
129
|
+
formatBytes: _FileInput_utils_js_1.formatBytes,
|
|
130
130
|
})))));
|
|
131
131
|
} }));
|
|
132
132
|
};
|
package/esm/FileInput.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useDropzone } from 'react-dropzone'; // https://react-dropzone.js.org/#
|
|
|
4
4
|
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
5
5
|
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
6
6
|
import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n';
|
|
7
|
-
import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils';
|
|
7
|
+
import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils.js';
|
|
8
8
|
import { DefaultFileList } from './FileInput/_FileInputFileList.js';
|
|
9
9
|
import FormField from './FormField.js';
|
|
10
10
|
const defaultRemoveFileText = {
|