@tecsinapse/cortex-react 1.15.0-beta.21 → 1.15.0-beta.23
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/cjs/components/Uploader/Manager.js +12 -2
- package/dist/cjs/hooks/useFileUpload.js +5 -2
- package/dist/cjs/hooks/useManagerHelpers.js +6 -1
- package/dist/esm/components/Uploader/Manager.js +12 -2
- package/dist/esm/hooks/useFileUpload.js +5 -2
- package/dist/esm/hooks/useManagerHelpers.js +6 -1
- package/dist/types/hooks/useFileUpload.d.ts +3 -1
- package/dist/types/hooks/useManagerHelpers.d.ts +1 -0
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ var clsx = require('clsx');
|
|
|
9
9
|
var io5 = require('react-icons/io5');
|
|
10
10
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
11
11
|
var useManagerHelpers = require('../../hooks/useManagerHelpers.js');
|
|
12
|
+
var Loading = require('../Loading.js');
|
|
12
13
|
|
|
13
14
|
const Manager = ({
|
|
14
15
|
open,
|
|
@@ -17,7 +18,15 @@ const Manager = ({
|
|
|
17
18
|
uploadProgressText = "Upload(s) in progress",
|
|
18
19
|
onClose
|
|
19
20
|
}) => {
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
min,
|
|
23
|
+
setMin,
|
|
24
|
+
regularFiles,
|
|
25
|
+
folderFiles,
|
|
26
|
+
totalLength,
|
|
27
|
+
setFolders,
|
|
28
|
+
isLoading
|
|
29
|
+
} = useManagerHelpers.useManagerHelpers({
|
|
21
30
|
files
|
|
22
31
|
});
|
|
23
32
|
return reactDom.createPortal(
|
|
@@ -44,7 +53,8 @@ const Manager = ({
|
|
|
44
53
|
{
|
|
45
54
|
variants: { variant: "filled", size: "square" },
|
|
46
55
|
onClick: onClose,
|
|
47
|
-
|
|
56
|
+
disabled: isLoading,
|
|
57
|
+
children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Loading.Loading, {}) : /* @__PURE__ */ jsxRuntime.jsx(io.IoMdClose, {})
|
|
48
58
|
}
|
|
49
59
|
)
|
|
50
60
|
] }),
|
|
@@ -27,6 +27,8 @@ const useFileUpload = ({
|
|
|
27
27
|
onDuplicate,
|
|
28
28
|
hasManager = true,
|
|
29
29
|
isFolder = false,
|
|
30
|
+
noClick = false,
|
|
31
|
+
ignoreRejections = false,
|
|
30
32
|
uploadProgressText
|
|
31
33
|
}) => {
|
|
32
34
|
const {
|
|
@@ -64,7 +66,7 @@ const useFileUpload = ({
|
|
|
64
66
|
[]
|
|
65
67
|
);
|
|
66
68
|
const onDrop = async (acceptedFiles, fileRejections) => {
|
|
67
|
-
if (fileRejections.length > 0) return;
|
|
69
|
+
if (fileRejections.length > 0 && !ignoreRejections) return;
|
|
68
70
|
if (hasManager) {
|
|
69
71
|
openManager();
|
|
70
72
|
onClose();
|
|
@@ -121,7 +123,8 @@ const useFileUpload = ({
|
|
|
121
123
|
accept: mappedAccept,
|
|
122
124
|
multiple: allowMultiple,
|
|
123
125
|
maxSize,
|
|
124
|
-
onDropRejected: onFileRejected
|
|
126
|
+
onDropRejected: onFileRejected,
|
|
127
|
+
noClick
|
|
125
128
|
});
|
|
126
129
|
const isFileLimitReached = !allowMultiple && files.length > 0;
|
|
127
130
|
return {
|
|
@@ -16,13 +16,18 @@ const useManagerHelpers = ({
|
|
|
16
16
|
[files]
|
|
17
17
|
);
|
|
18
18
|
const totalLength = (regularFiles ?? []).length + (folders ?? []).length;
|
|
19
|
+
const isLoading = React.useMemo(
|
|
20
|
+
() => files?.some((file) => file.status === "uploading"),
|
|
21
|
+
[files]
|
|
22
|
+
);
|
|
19
23
|
return {
|
|
20
24
|
min,
|
|
21
25
|
setMin,
|
|
22
26
|
folderFiles,
|
|
23
27
|
regularFiles,
|
|
24
28
|
totalLength,
|
|
25
|
-
setFolders
|
|
29
|
+
setFolders,
|
|
30
|
+
isLoading
|
|
26
31
|
};
|
|
27
32
|
};
|
|
28
33
|
|
|
@@ -7,6 +7,7 @@ import { clsx } from 'clsx';
|
|
|
7
7
|
import { IoChevronUp, IoChevronDown } from 'react-icons/io5';
|
|
8
8
|
import { manager } from '@tecsinapse/cortex-core';
|
|
9
9
|
import { useManagerHelpers } from '../../hooks/useManagerHelpers.js';
|
|
10
|
+
import { Loading } from '../Loading.js';
|
|
10
11
|
|
|
11
12
|
const Manager = ({
|
|
12
13
|
open,
|
|
@@ -15,7 +16,15 @@ const Manager = ({
|
|
|
15
16
|
uploadProgressText = "Upload(s) in progress",
|
|
16
17
|
onClose
|
|
17
18
|
}) => {
|
|
18
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
min,
|
|
21
|
+
setMin,
|
|
22
|
+
regularFiles,
|
|
23
|
+
folderFiles,
|
|
24
|
+
totalLength,
|
|
25
|
+
setFolders,
|
|
26
|
+
isLoading
|
|
27
|
+
} = useManagerHelpers({
|
|
19
28
|
files
|
|
20
29
|
});
|
|
21
30
|
return createPortal(
|
|
@@ -42,7 +51,8 @@ const Manager = ({
|
|
|
42
51
|
{
|
|
43
52
|
variants: { variant: "filled", size: "square" },
|
|
44
53
|
onClick: onClose,
|
|
45
|
-
|
|
54
|
+
disabled: isLoading,
|
|
55
|
+
children: isLoading ? /* @__PURE__ */ jsx(Loading, {}) : /* @__PURE__ */ jsx(IoMdClose, {})
|
|
46
56
|
}
|
|
47
57
|
)
|
|
48
58
|
] }),
|
|
@@ -25,6 +25,8 @@ const useFileUpload = ({
|
|
|
25
25
|
onDuplicate,
|
|
26
26
|
hasManager = true,
|
|
27
27
|
isFolder = false,
|
|
28
|
+
noClick = false,
|
|
29
|
+
ignoreRejections = false,
|
|
28
30
|
uploadProgressText
|
|
29
31
|
}) => {
|
|
30
32
|
const {
|
|
@@ -62,7 +64,7 @@ const useFileUpload = ({
|
|
|
62
64
|
[]
|
|
63
65
|
);
|
|
64
66
|
const onDrop = async (acceptedFiles, fileRejections) => {
|
|
65
|
-
if (fileRejections.length > 0) return;
|
|
67
|
+
if (fileRejections.length > 0 && !ignoreRejections) return;
|
|
66
68
|
if (hasManager) {
|
|
67
69
|
openManager();
|
|
68
70
|
onClose();
|
|
@@ -119,7 +121,8 @@ const useFileUpload = ({
|
|
|
119
121
|
accept: mappedAccept,
|
|
120
122
|
multiple: allowMultiple,
|
|
121
123
|
maxSize,
|
|
122
|
-
onDropRejected: onFileRejected
|
|
124
|
+
onDropRejected: onFileRejected,
|
|
125
|
+
noClick
|
|
123
126
|
});
|
|
124
127
|
const isFileLimitReached = !allowMultiple && files.length > 0;
|
|
125
128
|
return {
|
|
@@ -14,13 +14,18 @@ const useManagerHelpers = ({
|
|
|
14
14
|
[files]
|
|
15
15
|
);
|
|
16
16
|
const totalLength = (regularFiles ?? []).length + (folders ?? []).length;
|
|
17
|
+
const isLoading = useMemo(
|
|
18
|
+
() => files?.some((file) => file.status === "uploading"),
|
|
19
|
+
[files]
|
|
20
|
+
);
|
|
17
21
|
return {
|
|
18
22
|
min,
|
|
19
23
|
setMin,
|
|
20
24
|
folderFiles,
|
|
21
25
|
regularFiles,
|
|
22
26
|
totalLength,
|
|
23
|
-
setFolders
|
|
27
|
+
setFolders,
|
|
28
|
+
isLoading
|
|
24
29
|
};
|
|
25
30
|
};
|
|
26
31
|
|
|
@@ -18,8 +18,10 @@ interface UseFileUploadOptions {
|
|
|
18
18
|
hasManager?: boolean;
|
|
19
19
|
isFolder?: boolean;
|
|
20
20
|
uploadProgressText?: string;
|
|
21
|
+
noClick?: boolean;
|
|
22
|
+
ignoreRejections?: boolean;
|
|
21
23
|
}
|
|
22
|
-
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, uploadProgressText, }: UseFileUploadOptions) => {
|
|
24
|
+
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, noClick, ignoreRejections, uploadProgressText, }: UseFileUploadOptions) => {
|
|
23
25
|
onOpen: () => void;
|
|
24
26
|
onClose: () => void;
|
|
25
27
|
onDelete: (index: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.15.0-beta.
|
|
3
|
+
"version": "1.15.0-beta.23",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-icons": ">=5.2.0",
|
|
49
49
|
"tailwind": ">=3.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5b5bc581b96f7722478482421cf42e9fe1420a44"
|
|
52
52
|
}
|