@tecsinapse/cortex-react 1.15.0-beta.8 → 1.15.0-beta.9
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 +17 -15
- package/dist/cjs/hooks/useFileUpload.js +4 -2
- package/dist/cjs/hooks/useManager.js +23 -0
- package/dist/esm/components/Uploader/Manager.js +17 -15
- package/dist/esm/hooks/useFileUpload.js +4 -2
- package/dist/esm/hooks/useManager.js +21 -0
- package/dist/types/components/Uploader/Manager.d.ts +1 -1
- package/dist/types/components/Uploader/index.d.ts +1 -1
- package/dist/types/components/Uploader/types.d.ts +1 -0
- package/dist/types/hooks/useFileUpload.d.ts +2 -1
- package/dist/types/hooks/useManager.d.ts +9 -0
- package/package.json +2 -2
|
@@ -5,20 +5,19 @@ var reactDom = require('react-dom');
|
|
|
5
5
|
var Upload = require('./Upload.js');
|
|
6
6
|
var Button = require('../Button.js');
|
|
7
7
|
var io = require('react-icons/io');
|
|
8
|
-
var React = require('react');
|
|
9
8
|
var clsx = require('clsx');
|
|
10
9
|
var io5 = require('react-icons/io5');
|
|
11
10
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
11
|
+
var useManager = require('../../hooks/useManager.js');
|
|
12
12
|
|
|
13
13
|
const Manager = ({
|
|
14
14
|
open,
|
|
15
15
|
files,
|
|
16
16
|
onDelete,
|
|
17
17
|
uploadProgressText = "Upload(s) in progress",
|
|
18
|
-
onClose
|
|
19
|
-
type = "file"
|
|
18
|
+
onClose
|
|
20
19
|
}) => {
|
|
21
|
-
const
|
|
20
|
+
const { min, setMin, regularFiles, folderFiles } = useManager.useManager({ files });
|
|
22
21
|
return reactDom.createPortal(
|
|
23
22
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
24
23
|
"div",
|
|
@@ -47,7 +46,7 @@ const Manager = ({
|
|
|
47
46
|
}
|
|
48
47
|
)
|
|
49
48
|
] }),
|
|
50
|
-
/* @__PURE__ */ jsxRuntime.
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
51
50
|
"div",
|
|
52
51
|
{
|
|
53
52
|
className: clsx.clsx("w-full h-auto max-h-[300px] gap-mili", {
|
|
@@ -55,16 +54,19 @@ const Manager = ({
|
|
|
55
54
|
"flex flex-col": !min,
|
|
56
55
|
"pb-kilo overflow-scroll pr-deca": files.length > 3
|
|
57
56
|
}),
|
|
58
|
-
children:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
children: [
|
|
58
|
+
regularFiles.length > 0 ? regularFiles.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
Upload.File,
|
|
60
|
+
{
|
|
61
|
+
file,
|
|
62
|
+
index,
|
|
63
|
+
onDelete,
|
|
64
|
+
showDelete: false
|
|
65
|
+
},
|
|
66
|
+
file.uid
|
|
67
|
+
)) : null,
|
|
68
|
+
folderFiles.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Upload.FolderList, { files: folderFiles }) : null
|
|
69
|
+
]
|
|
68
70
|
}
|
|
69
71
|
)
|
|
70
72
|
] })
|
|
@@ -13,7 +13,8 @@ const useFileUpload = ({
|
|
|
13
13
|
allowMultiple = true,
|
|
14
14
|
preventDuplicates = false,
|
|
15
15
|
onDuplicate,
|
|
16
|
-
hasManager = true
|
|
16
|
+
hasManager = true,
|
|
17
|
+
isFolder = false
|
|
17
18
|
}) => {
|
|
18
19
|
const [files, setFiles] = React.useState([]);
|
|
19
20
|
const [duplicates, setDuplicates] = React.useState([]);
|
|
@@ -62,7 +63,8 @@ const useFileUpload = ({
|
|
|
62
63
|
const newFiles = toProcess.map((file) => ({
|
|
63
64
|
file,
|
|
64
65
|
status: onAccept ? types.FileStatus.UPLOADING : types.FileStatus.SUCCESS,
|
|
65
|
-
uid: uuid.v4()
|
|
66
|
+
uid: uuid.v4(),
|
|
67
|
+
isFolder
|
|
66
68
|
}));
|
|
67
69
|
try {
|
|
68
70
|
setFiles((prevFiles) => [...prevFiles, ...newFiles]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const useManager = ({ files }) => {
|
|
6
|
+
const [min, setMin] = React.useState(false);
|
|
7
|
+
const folderFiles = React.useMemo(
|
|
8
|
+
() => files.filter((file) => file.isFolder),
|
|
9
|
+
[files]
|
|
10
|
+
);
|
|
11
|
+
const regularFiles = React.useMemo(
|
|
12
|
+
() => files.filter((file) => !file.isFolder),
|
|
13
|
+
[files]
|
|
14
|
+
);
|
|
15
|
+
return {
|
|
16
|
+
min,
|
|
17
|
+
setMin,
|
|
18
|
+
folderFiles,
|
|
19
|
+
regularFiles
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.useManager = useManager;
|
|
@@ -3,20 +3,19 @@ import { createPortal } from 'react-dom';
|
|
|
3
3
|
import { File, FolderList } from './Upload.js';
|
|
4
4
|
import { Button } from '../Button.js';
|
|
5
5
|
import { IoMdClose } from 'react-icons/io';
|
|
6
|
-
import { useState } from 'react';
|
|
7
6
|
import { clsx } from 'clsx';
|
|
8
7
|
import { IoChevronUp, IoChevronDown } from 'react-icons/io5';
|
|
9
8
|
import { manager } from '@tecsinapse/cortex-core';
|
|
9
|
+
import { useManager } from '../../hooks/useManager.js';
|
|
10
10
|
|
|
11
11
|
const Manager = ({
|
|
12
12
|
open,
|
|
13
13
|
files,
|
|
14
14
|
onDelete,
|
|
15
15
|
uploadProgressText = "Upload(s) in progress",
|
|
16
|
-
onClose
|
|
17
|
-
type = "file"
|
|
16
|
+
onClose
|
|
18
17
|
}) => {
|
|
19
|
-
const
|
|
18
|
+
const { min, setMin, regularFiles, folderFiles } = useManager({ files });
|
|
20
19
|
return createPortal(
|
|
21
20
|
/* @__PURE__ */ jsx(
|
|
22
21
|
"div",
|
|
@@ -45,7 +44,7 @@ const Manager = ({
|
|
|
45
44
|
}
|
|
46
45
|
)
|
|
47
46
|
] }),
|
|
48
|
-
/* @__PURE__ */
|
|
47
|
+
/* @__PURE__ */ jsxs(
|
|
49
48
|
"div",
|
|
50
49
|
{
|
|
51
50
|
className: clsx("w-full h-auto max-h-[300px] gap-mili", {
|
|
@@ -53,16 +52,19 @@ const Manager = ({
|
|
|
53
52
|
"flex flex-col": !min,
|
|
54
53
|
"pb-kilo overflow-scroll pr-deca": files.length > 3
|
|
55
54
|
}),
|
|
56
|
-
children:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
children: [
|
|
56
|
+
regularFiles.length > 0 ? regularFiles.map((file, index) => /* @__PURE__ */ jsx(
|
|
57
|
+
File,
|
|
58
|
+
{
|
|
59
|
+
file,
|
|
60
|
+
index,
|
|
61
|
+
onDelete,
|
|
62
|
+
showDelete: false
|
|
63
|
+
},
|
|
64
|
+
file.uid
|
|
65
|
+
)) : null,
|
|
66
|
+
folderFiles.length > 0 ? /* @__PURE__ */ jsx(FolderList, { files: folderFiles }) : null
|
|
67
|
+
]
|
|
66
68
|
}
|
|
67
69
|
)
|
|
68
70
|
] })
|
|
@@ -11,7 +11,8 @@ const useFileUpload = ({
|
|
|
11
11
|
allowMultiple = true,
|
|
12
12
|
preventDuplicates = false,
|
|
13
13
|
onDuplicate,
|
|
14
|
-
hasManager = true
|
|
14
|
+
hasManager = true,
|
|
15
|
+
isFolder = false
|
|
15
16
|
}) => {
|
|
16
17
|
const [files, setFiles] = useState([]);
|
|
17
18
|
const [duplicates, setDuplicates] = useState([]);
|
|
@@ -60,7 +61,8 @@ const useFileUpload = ({
|
|
|
60
61
|
const newFiles = toProcess.map((file) => ({
|
|
61
62
|
file,
|
|
62
63
|
status: onAccept ? FileStatus.UPLOADING : FileStatus.SUCCESS,
|
|
63
|
-
uid: v4()
|
|
64
|
+
uid: v4(),
|
|
65
|
+
isFolder
|
|
64
66
|
}));
|
|
65
67
|
try {
|
|
66
68
|
setFiles((prevFiles) => [...prevFiles, ...newFiles]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const useManager = ({ files }) => {
|
|
4
|
+
const [min, setMin] = useState(false);
|
|
5
|
+
const folderFiles = useMemo(
|
|
6
|
+
() => files.filter((file) => file.isFolder),
|
|
7
|
+
[files]
|
|
8
|
+
);
|
|
9
|
+
const regularFiles = useMemo(
|
|
10
|
+
() => files.filter((file) => !file.isFolder),
|
|
11
|
+
[files]
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
min,
|
|
15
|
+
setMin,
|
|
16
|
+
folderFiles,
|
|
17
|
+
regularFiles
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useManager };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ManagerProps } from './types';
|
|
2
|
-
export declare const Manager: <T>({ open, files, onDelete, uploadProgressText, onClose,
|
|
2
|
+
export declare const Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, }: ManagerProps<T>) => any;
|
|
@@ -5,5 +5,5 @@ export declare const Uploader: {
|
|
|
5
5
|
Files: <T>({ files, onDelete, uploadProgressText, }: import("./types").FilesProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
Modal: ({ open, onClose, children, title, }: import("./types").ModalProps) => any;
|
|
7
7
|
Root: <T>({ open, onClose, files, onDelete, dropzoneProps, selectFileText, dropText, buttonText, uploadProgressText, titleModal, isManagerOpen, closeManager, }: import("./types").RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
Manager: <T>({ open, files, onDelete, uploadProgressText, onClose,
|
|
8
|
+
Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, }: import("./types").ManagerProps<T>) => any;
|
|
9
9
|
};
|
|
@@ -15,8 +15,9 @@ interface UseFileUploadOptions<T> {
|
|
|
15
15
|
preventDuplicates?: boolean;
|
|
16
16
|
onDuplicate?: (duplicates: File[]) => void;
|
|
17
17
|
hasManager?: boolean;
|
|
18
|
+
isFolder?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare const useFileUpload: <T>({ accept, onAccept, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, }: UseFileUploadOptions<T>) => {
|
|
20
|
+
export declare const useFileUpload: <T>({ accept, onAccept, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, }: UseFileUploadOptions<T>) => {
|
|
20
21
|
onOpen: () => void;
|
|
21
22
|
onClose: () => void;
|
|
22
23
|
onDelete: (index: number) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FileUpload } from '../components';
|
|
2
|
+
export declare const useManager: <T>({ files }: {
|
|
3
|
+
files: FileUpload<T>[];
|
|
4
|
+
}) => {
|
|
5
|
+
min: boolean;
|
|
6
|
+
setMin: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
7
|
+
folderFiles: FileUpload<T>[];
|
|
8
|
+
regularFiles: FileUpload<T>[];
|
|
9
|
+
};
|
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.9",
|
|
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": "7ddfc6577ee756d2a3c4906fc41cbc2e5c0418bb"
|
|
52
52
|
}
|