@uxf/ui 11.3.0 → 11.4.0
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/dropzone/dropzone-input.js +12 -0
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const react_dropzone_1 = require("react-dropzone");
|
|
32
32
|
const icon_1 = require("../icon");
|
|
33
|
+
const validator_exceptions_1 = require("../utils/validator/validator-exceptions");
|
|
33
34
|
function fileToFileResponse(file) {
|
|
34
35
|
return {
|
|
35
36
|
id: -Math.round(Math.random() * 100000000),
|
|
@@ -67,6 +68,16 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
67
68
|
const refValue = (0, react_1.useRef)();
|
|
68
69
|
refValue.current = props.value;
|
|
69
70
|
const inputRef = (0, react_1.useRef)(null);
|
|
71
|
+
const handleFileRejected = async (fileRejections) => {
|
|
72
|
+
fileRejections.forEach((fileRejection) => {
|
|
73
|
+
if (props.maxFileSize && fileRejection.file.size > props.maxFileSize) {
|
|
74
|
+
if (props.onUploadError) {
|
|
75
|
+
props.onUploadError(validator_exceptions_1.ValidatorExceptions.MaxFileSize);
|
|
76
|
+
}
|
|
77
|
+
throw validator_exceptions_1.ValidatorExceptions.MaxFileSize;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
70
81
|
const handleFileDrop = async (acceptedFiles) => {
|
|
71
82
|
const files = acceptedFiles.map((file) => ({
|
|
72
83
|
...fileToFileResponse(file),
|
|
@@ -109,6 +120,7 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
109
120
|
noDrag: props.noDrag,
|
|
110
121
|
onDrop: handleFileDrop,
|
|
111
122
|
preventDropOnDocument: props.noDrag,
|
|
123
|
+
onDropRejected: handleFileRejected,
|
|
112
124
|
});
|
|
113
125
|
const labelOnCLick = (e) => {
|
|
114
126
|
e.stopPropagation();
|