@ikatec/nebula-react 1.6.0-beta.2 → 1.6.0-beta.3
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/dist/ikatec-nebula-react-1.6.0-beta.3.tgz +0 -0
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +18 -25
- package/dist/index.mjs +18 -25
- package/package.json +1 -1
- package/dist/ikatec-nebula-react-1.6.0-beta.2.tgz +0 -0
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -666,6 +666,11 @@ type FileWithPreview = {
|
|
|
666
666
|
id: string;
|
|
667
667
|
preview?: string;
|
|
668
668
|
};
|
|
669
|
+
declare enum FileUploadError {
|
|
670
|
+
MAX_FILES_EXCEEDED = "MAX_FILES_EXCEEDED",
|
|
671
|
+
MAXIMUM_FILE_SIZE_EXCEEDED = "MAXIMUM_FILE_SIZE_EXCEEDED",
|
|
672
|
+
INVALID_FORMAT = "INVALID_FORMAT"
|
|
673
|
+
}
|
|
669
674
|
type FileUploadOptions = {
|
|
670
675
|
maxFiles?: number;
|
|
671
676
|
maxSize?: number;
|
|
@@ -674,19 +679,14 @@ type FileUploadOptions = {
|
|
|
674
679
|
initialFiles?: FileMetadata[];
|
|
675
680
|
onFilesChange?: (files: FileWithPreview[]) => void;
|
|
676
681
|
onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
|
|
682
|
+
onError?: (errors: {
|
|
683
|
+
file?: File | FileMetadata;
|
|
684
|
+
error: FileUploadError;
|
|
685
|
+
}[]) => void;
|
|
677
686
|
};
|
|
678
|
-
declare enum FileUploadError {
|
|
679
|
-
MAX_FILES_EXCEEDED = "MAX_FILES_EXCEEDED",
|
|
680
|
-
MAXIMUM_FILE_SIZE_EXCEEDED = "MAXIMUM_FILE_SIZE_EXCEEDED",
|
|
681
|
-
INVALID_FORMAT = "INVALID_FORMAT"
|
|
682
|
-
}
|
|
683
687
|
type FileUploadState = {
|
|
684
688
|
files: FileWithPreview[];
|
|
685
689
|
isDragging: boolean;
|
|
686
|
-
errors: {
|
|
687
|
-
file?: File | FileMetadata;
|
|
688
|
-
error: FileUploadError;
|
|
689
|
-
}[];
|
|
690
690
|
};
|
|
691
691
|
type FileUploadActions = {
|
|
692
692
|
addFiles: (files: FileList | File[]) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -666,6 +666,11 @@ type FileWithPreview = {
|
|
|
666
666
|
id: string;
|
|
667
667
|
preview?: string;
|
|
668
668
|
};
|
|
669
|
+
declare enum FileUploadError {
|
|
670
|
+
MAX_FILES_EXCEEDED = "MAX_FILES_EXCEEDED",
|
|
671
|
+
MAXIMUM_FILE_SIZE_EXCEEDED = "MAXIMUM_FILE_SIZE_EXCEEDED",
|
|
672
|
+
INVALID_FORMAT = "INVALID_FORMAT"
|
|
673
|
+
}
|
|
669
674
|
type FileUploadOptions = {
|
|
670
675
|
maxFiles?: number;
|
|
671
676
|
maxSize?: number;
|
|
@@ -674,19 +679,14 @@ type FileUploadOptions = {
|
|
|
674
679
|
initialFiles?: FileMetadata[];
|
|
675
680
|
onFilesChange?: (files: FileWithPreview[]) => void;
|
|
676
681
|
onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
|
|
682
|
+
onError?: (errors: {
|
|
683
|
+
file?: File | FileMetadata;
|
|
684
|
+
error: FileUploadError;
|
|
685
|
+
}[]) => void;
|
|
677
686
|
};
|
|
678
|
-
declare enum FileUploadError {
|
|
679
|
-
MAX_FILES_EXCEEDED = "MAX_FILES_EXCEEDED",
|
|
680
|
-
MAXIMUM_FILE_SIZE_EXCEEDED = "MAXIMUM_FILE_SIZE_EXCEEDED",
|
|
681
|
-
INVALID_FORMAT = "INVALID_FORMAT"
|
|
682
|
-
}
|
|
683
687
|
type FileUploadState = {
|
|
684
688
|
files: FileWithPreview[];
|
|
685
689
|
isDragging: boolean;
|
|
686
|
-
errors: {
|
|
687
|
-
file?: File | FileMetadata;
|
|
688
|
-
error: FileUploadError;
|
|
689
|
-
}[];
|
|
690
690
|
};
|
|
691
691
|
type FileUploadActions = {
|
|
692
692
|
addFiles: (files: FileList | File[]) => void;
|
package/dist/index.js
CHANGED
|
@@ -4726,7 +4726,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4726
4726
|
multiple = false,
|
|
4727
4727
|
initialFiles = [],
|
|
4728
4728
|
onFilesChange,
|
|
4729
|
-
onFilesAdded
|
|
4729
|
+
onFilesAdded,
|
|
4730
|
+
onError
|
|
4730
4731
|
} = options;
|
|
4731
4732
|
const [state, setState] = React31.useState({
|
|
4732
4733
|
files: initialFiles.map((file) => ({
|
|
@@ -4734,8 +4735,7 @@ var useFileUpload = (options = {}) => {
|
|
|
4734
4735
|
id: file.id,
|
|
4735
4736
|
preview: file.url
|
|
4736
4737
|
})),
|
|
4737
|
-
isDragging: false
|
|
4738
|
-
errors: []
|
|
4738
|
+
isDragging: false
|
|
4739
4739
|
});
|
|
4740
4740
|
const inputRef = React31.useRef(null);
|
|
4741
4741
|
const validateFile = React31.useCallback(
|
|
@@ -4816,10 +4816,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4816
4816
|
if (!newFiles || newFiles.length === 0) return;
|
|
4817
4817
|
const newFilesArray = Array.from(newFiles);
|
|
4818
4818
|
const errors = [];
|
|
4819
|
-
setState((prev) => ({ ...prev, errors: [] }));
|
|
4820
4819
|
if (multiple && maxFiles !== Infinity && state.files.length + newFilesArray.length > maxFiles) {
|
|
4821
|
-
|
|
4822
|
-
setState((prev) => ({ ...prev, errors }));
|
|
4820
|
+
onError?.([{ error: "MAX_FILES_EXCEEDED" /* MAX_FILES_EXCEEDED */ }]);
|
|
4823
4821
|
return;
|
|
4824
4822
|
}
|
|
4825
4823
|
const validFiles = [];
|
|
@@ -4833,10 +4831,9 @@ var useFileUpload = (options = {}) => {
|
|
|
4833
4831
|
}
|
|
4834
4832
|
}
|
|
4835
4833
|
if (file.size > maxSize) {
|
|
4836
|
-
|
|
4837
|
-
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED
|
|
4838
|
-
|
|
4839
|
-
});
|
|
4834
|
+
onError?.([
|
|
4835
|
+
{ file, error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */ }
|
|
4836
|
+
]);
|
|
4840
4837
|
return;
|
|
4841
4838
|
}
|
|
4842
4839
|
const error2 = validateFile(file);
|
|
@@ -4860,16 +4857,15 @@ var useFileUpload = (options = {}) => {
|
|
|
4860
4857
|
onFilesChange?.(newFiles2);
|
|
4861
4858
|
return {
|
|
4862
4859
|
...prev,
|
|
4863
|
-
files: newFiles2
|
|
4864
|
-
errors
|
|
4860
|
+
files: newFiles2
|
|
4865
4861
|
};
|
|
4866
4862
|
});
|
|
4867
4863
|
} else if (errors.length > 0) {
|
|
4868
4864
|
setState((prev) => ({
|
|
4869
|
-
...prev
|
|
4870
|
-
errors
|
|
4865
|
+
...prev
|
|
4871
4866
|
}));
|
|
4872
4867
|
}
|
|
4868
|
+
onError?.(errors);
|
|
4873
4869
|
if (inputRef.current) {
|
|
4874
4870
|
inputRef.current.value = "";
|
|
4875
4871
|
}
|
|
@@ -4884,7 +4880,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4884
4880
|
generateUniqueId,
|
|
4885
4881
|
clearFiles,
|
|
4886
4882
|
onFilesChange,
|
|
4887
|
-
onFilesAdded
|
|
4883
|
+
onFilesAdded,
|
|
4884
|
+
onError
|
|
4888
4885
|
]
|
|
4889
4886
|
);
|
|
4890
4887
|
const removeFile = React31.useCallback(
|
|
@@ -5041,7 +5038,7 @@ function FileUpload({
|
|
|
5041
5038
|
const { fileUpload } = useNebulaI18n().messages;
|
|
5042
5039
|
const maxSize = maxSizeMB * 1024 * 1024;
|
|
5043
5040
|
const [
|
|
5044
|
-
{ files, isDragging
|
|
5041
|
+
{ files, isDragging },
|
|
5045
5042
|
{
|
|
5046
5043
|
handleDragEnter,
|
|
5047
5044
|
handleDragLeave,
|
|
@@ -5057,11 +5054,9 @@ function FileUpload({
|
|
|
5057
5054
|
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
5058
5055
|
accept: "*",
|
|
5059
5056
|
...rest,
|
|
5060
|
-
maxFiles
|
|
5057
|
+
maxFiles,
|
|
5058
|
+
onError
|
|
5061
5059
|
});
|
|
5062
|
-
React31.useEffect(() => {
|
|
5063
|
-
onError?.(errors);
|
|
5064
|
-
}, [errors, onError]);
|
|
5065
5060
|
const disabled = React31.useMemo(() => {
|
|
5066
5061
|
if (rest.disabled) return true;
|
|
5067
5062
|
if (rest.multiple) {
|
|
@@ -6312,7 +6307,7 @@ var ProfileImage = ({
|
|
|
6312
6307
|
onChange?.(fileLike);
|
|
6313
6308
|
};
|
|
6314
6309
|
const [
|
|
6315
|
-
{ files, isDragging
|
|
6310
|
+
{ files, isDragging },
|
|
6316
6311
|
{
|
|
6317
6312
|
handleDragEnter,
|
|
6318
6313
|
handleDragLeave,
|
|
@@ -6338,15 +6333,13 @@ var ProfileImage = ({
|
|
|
6338
6333
|
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
6339
6334
|
onFilesChange([file2]) {
|
|
6340
6335
|
handleFileChange(file2?.file);
|
|
6341
|
-
}
|
|
6336
|
+
},
|
|
6337
|
+
onError
|
|
6342
6338
|
});
|
|
6343
6339
|
const [finalImageUrl, setFinalImageUrl] = React31.useState(
|
|
6344
6340
|
image || null
|
|
6345
6341
|
);
|
|
6346
6342
|
const [isDialogOpen, setIsDialogOpen] = React31.useState(false);
|
|
6347
|
-
React31.useEffect(() => {
|
|
6348
|
-
onError?.(errors);
|
|
6349
|
-
}, [errors, onError]);
|
|
6350
6343
|
const [file] = files;
|
|
6351
6344
|
const fileId = file?.id;
|
|
6352
6345
|
const previousFileIdRef = React31.useRef(null);
|
package/dist/index.mjs
CHANGED
|
@@ -4683,7 +4683,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4683
4683
|
multiple = false,
|
|
4684
4684
|
initialFiles = [],
|
|
4685
4685
|
onFilesChange,
|
|
4686
|
-
onFilesAdded
|
|
4686
|
+
onFilesAdded,
|
|
4687
|
+
onError
|
|
4687
4688
|
} = options;
|
|
4688
4689
|
const [state, setState] = useState({
|
|
4689
4690
|
files: initialFiles.map((file) => ({
|
|
@@ -4691,8 +4692,7 @@ var useFileUpload = (options = {}) => {
|
|
|
4691
4692
|
id: file.id,
|
|
4692
4693
|
preview: file.url
|
|
4693
4694
|
})),
|
|
4694
|
-
isDragging: false
|
|
4695
|
-
errors: []
|
|
4695
|
+
isDragging: false
|
|
4696
4696
|
});
|
|
4697
4697
|
const inputRef = useRef(null);
|
|
4698
4698
|
const validateFile = useCallback(
|
|
@@ -4773,10 +4773,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4773
4773
|
if (!newFiles || newFiles.length === 0) return;
|
|
4774
4774
|
const newFilesArray = Array.from(newFiles);
|
|
4775
4775
|
const errors = [];
|
|
4776
|
-
setState((prev) => ({ ...prev, errors: [] }));
|
|
4777
4776
|
if (multiple && maxFiles !== Infinity && state.files.length + newFilesArray.length > maxFiles) {
|
|
4778
|
-
|
|
4779
|
-
setState((prev) => ({ ...prev, errors }));
|
|
4777
|
+
onError?.([{ error: "MAX_FILES_EXCEEDED" /* MAX_FILES_EXCEEDED */ }]);
|
|
4780
4778
|
return;
|
|
4781
4779
|
}
|
|
4782
4780
|
const validFiles = [];
|
|
@@ -4790,10 +4788,9 @@ var useFileUpload = (options = {}) => {
|
|
|
4790
4788
|
}
|
|
4791
4789
|
}
|
|
4792
4790
|
if (file.size > maxSize) {
|
|
4793
|
-
|
|
4794
|
-
error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED
|
|
4795
|
-
|
|
4796
|
-
});
|
|
4791
|
+
onError?.([
|
|
4792
|
+
{ file, error: "MAXIMUM_FILE_SIZE_EXCEEDED" /* MAXIMUM_FILE_SIZE_EXCEEDED */ }
|
|
4793
|
+
]);
|
|
4797
4794
|
return;
|
|
4798
4795
|
}
|
|
4799
4796
|
const error2 = validateFile(file);
|
|
@@ -4817,16 +4814,15 @@ var useFileUpload = (options = {}) => {
|
|
|
4817
4814
|
onFilesChange?.(newFiles2);
|
|
4818
4815
|
return {
|
|
4819
4816
|
...prev,
|
|
4820
|
-
files: newFiles2
|
|
4821
|
-
errors
|
|
4817
|
+
files: newFiles2
|
|
4822
4818
|
};
|
|
4823
4819
|
});
|
|
4824
4820
|
} else if (errors.length > 0) {
|
|
4825
4821
|
setState((prev) => ({
|
|
4826
|
-
...prev
|
|
4827
|
-
errors
|
|
4822
|
+
...prev
|
|
4828
4823
|
}));
|
|
4829
4824
|
}
|
|
4825
|
+
onError?.(errors);
|
|
4830
4826
|
if (inputRef.current) {
|
|
4831
4827
|
inputRef.current.value = "";
|
|
4832
4828
|
}
|
|
@@ -4841,7 +4837,8 @@ var useFileUpload = (options = {}) => {
|
|
|
4841
4837
|
generateUniqueId,
|
|
4842
4838
|
clearFiles,
|
|
4843
4839
|
onFilesChange,
|
|
4844
|
-
onFilesAdded
|
|
4840
|
+
onFilesAdded,
|
|
4841
|
+
onError
|
|
4845
4842
|
]
|
|
4846
4843
|
);
|
|
4847
4844
|
const removeFile = useCallback(
|
|
@@ -4998,7 +4995,7 @@ function FileUpload({
|
|
|
4998
4995
|
const { fileUpload } = useNebulaI18n().messages;
|
|
4999
4996
|
const maxSize = maxSizeMB * 1024 * 1024;
|
|
5000
4997
|
const [
|
|
5001
|
-
{ files, isDragging
|
|
4998
|
+
{ files, isDragging },
|
|
5002
4999
|
{
|
|
5003
5000
|
handleDragEnter,
|
|
5004
5001
|
handleDragLeave,
|
|
@@ -5014,11 +5011,9 @@ function FileUpload({
|
|
|
5014
5011
|
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
5015
5012
|
accept: "*",
|
|
5016
5013
|
...rest,
|
|
5017
|
-
maxFiles
|
|
5014
|
+
maxFiles,
|
|
5015
|
+
onError
|
|
5018
5016
|
});
|
|
5019
|
-
useEffect(() => {
|
|
5020
|
-
onError?.(errors);
|
|
5021
|
-
}, [errors, onError]);
|
|
5022
5017
|
const disabled = useMemo(() => {
|
|
5023
5018
|
if (rest.disabled) return true;
|
|
5024
5019
|
if (rest.multiple) {
|
|
@@ -6269,7 +6264,7 @@ var ProfileImage = ({
|
|
|
6269
6264
|
onChange?.(fileLike);
|
|
6270
6265
|
};
|
|
6271
6266
|
const [
|
|
6272
|
-
{ files, isDragging
|
|
6267
|
+
{ files, isDragging },
|
|
6273
6268
|
{
|
|
6274
6269
|
handleDragEnter,
|
|
6275
6270
|
handleDragLeave,
|
|
@@ -6295,15 +6290,13 @@ var ProfileImage = ({
|
|
|
6295
6290
|
maxSize: maxSize > 0 ? maxSize : void 0,
|
|
6296
6291
|
onFilesChange([file2]) {
|
|
6297
6292
|
handleFileChange(file2?.file);
|
|
6298
|
-
}
|
|
6293
|
+
},
|
|
6294
|
+
onError
|
|
6299
6295
|
});
|
|
6300
6296
|
const [finalImageUrl, setFinalImageUrl] = useState(
|
|
6301
6297
|
image || null
|
|
6302
6298
|
);
|
|
6303
6299
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
6304
|
-
useEffect(() => {
|
|
6305
|
-
onError?.(errors);
|
|
6306
|
-
}, [errors, onError]);
|
|
6307
6300
|
const [file] = files;
|
|
6308
6301
|
const fileId = file?.id;
|
|
6309
6302
|
const previousFileIdRef = useRef(null);
|
package/package.json
CHANGED
|
Binary file
|