@tecsinapse/cortex-react 1.15.0-beta.4 → 1.15.0-beta.6
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 +4 -3
- package/dist/cjs/components/Uploader/Upload.js +28 -0
- package/dist/cjs/hooks/useFileUpload.js +6 -3
- package/dist/esm/components/Uploader/Manager.js +5 -4
- package/dist/esm/components/Uploader/Upload.js +29 -2
- package/dist/esm/hooks/useFileUpload.js +6 -3
- package/dist/types/components/Uploader/Manager.d.ts +1 -1
- package/dist/types/components/Uploader/Upload.d.ts +2 -1
- package/dist/types/components/Uploader/index.d.ts +1 -1
- package/dist/types/components/Uploader/types.d.ts +4 -0
- package/dist/types/hooks/useFileUpload.d.ts +2 -1
- package/package.json +3 -3
|
@@ -15,7 +15,8 @@ const Manager = ({
|
|
|
15
15
|
files,
|
|
16
16
|
onDelete,
|
|
17
17
|
uploadProgressText = "Upload(s) in progress",
|
|
18
|
-
onClose
|
|
18
|
+
onClose,
|
|
19
|
+
type = "file"
|
|
19
20
|
}) => {
|
|
20
21
|
const [min, setMin] = React.useState(false);
|
|
21
22
|
return reactDom.createPortal(
|
|
@@ -54,7 +55,7 @@ const Manager = ({
|
|
|
54
55
|
"flex flex-col": !min,
|
|
55
56
|
"pb-kilo overflow-scroll pr-deca": files.length > 3
|
|
56
57
|
}),
|
|
57
|
-
children: files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
|
+
children: type === "file" ? files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
59
|
Upload.File,
|
|
59
60
|
{
|
|
60
61
|
file,
|
|
@@ -63,7 +64,7 @@ const Manager = ({
|
|
|
63
64
|
showDelete: false
|
|
64
65
|
},
|
|
65
66
|
file.uid
|
|
66
|
-
))
|
|
67
|
+
)) : /* @__PURE__ */ jsxRuntime.jsx(Upload.Folder, { items: files })
|
|
67
68
|
}
|
|
68
69
|
)
|
|
69
70
|
] })
|
|
@@ -63,5 +63,33 @@ const File = ({
|
|
|
63
63
|
)
|
|
64
64
|
] }, index);
|
|
65
65
|
};
|
|
66
|
+
const Folder = ({ items }) => {
|
|
67
|
+
const paths = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const file in items) {
|
|
69
|
+
const path = items[file].file.relativePath.slice(1).split("/");
|
|
70
|
+
path.map((item) => paths.add(item));
|
|
71
|
+
}
|
|
72
|
+
const intent = (items ?? []).some((item) => item.status === "success") ? "success" : (items ?? []).some((item) => item.status === "error") ? "error" : "info";
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col w-full", children: [
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between border rounded-t-mili shadow p-mili", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-centi", children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "border-2 text-kilo text-primary-medium w-tera h-tera flex items-center justify-center rounded-mili", children: /* @__PURE__ */ jsxRuntime.jsx(fa6.FaRegFolder, {}) }),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-col", children: [
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold truncate max-w-[200px]", children: Array.from(paths)[0] }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500", children: [
|
|
79
|
+
paths.size - 1,
|
|
80
|
+
" itens"
|
|
81
|
+
] })
|
|
82
|
+
] })
|
|
83
|
+
] }) }),
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
ProgressBar.ProgressBar,
|
|
86
|
+
{
|
|
87
|
+
intent,
|
|
88
|
+
infinite: (items ?? []).some((item) => item.status === "uploading")
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] });
|
|
92
|
+
};
|
|
66
93
|
|
|
67
94
|
exports.File = File;
|
|
95
|
+
exports.Folder = Folder;
|
|
@@ -12,7 +12,8 @@ const useFileUpload = ({
|
|
|
12
12
|
maxSize,
|
|
13
13
|
allowMultiple = true,
|
|
14
14
|
preventDuplicates = false,
|
|
15
|
-
onDuplicate
|
|
15
|
+
onDuplicate,
|
|
16
|
+
hasManager = true
|
|
16
17
|
}) => {
|
|
17
18
|
const [files, setFiles] = React.useState([]);
|
|
18
19
|
const [duplicates, setDuplicates] = React.useState([]);
|
|
@@ -40,8 +41,10 @@ const useFileUpload = ({
|
|
|
40
41
|
[]
|
|
41
42
|
);
|
|
42
43
|
const onDrop = async (acceptedFiles) => {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (hasManager) {
|
|
45
|
+
openManager();
|
|
46
|
+
onClose();
|
|
47
|
+
}
|
|
45
48
|
let toProcess = acceptedFiles;
|
|
46
49
|
if (preventDuplicates) {
|
|
47
50
|
const found = (acceptedFiles ?? []).filter(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { File } from './Upload.js';
|
|
3
|
+
import { File, Folder } from './Upload.js';
|
|
4
4
|
import { Button } from '../Button.js';
|
|
5
5
|
import { IoMdClose } from 'react-icons/io';
|
|
6
6
|
import { useState } from 'react';
|
|
@@ -13,7 +13,8 @@ const Manager = ({
|
|
|
13
13
|
files,
|
|
14
14
|
onDelete,
|
|
15
15
|
uploadProgressText = "Upload(s) in progress",
|
|
16
|
-
onClose
|
|
16
|
+
onClose,
|
|
17
|
+
type = "file"
|
|
17
18
|
}) => {
|
|
18
19
|
const [min, setMin] = useState(false);
|
|
19
20
|
return createPortal(
|
|
@@ -52,7 +53,7 @@ const Manager = ({
|
|
|
52
53
|
"flex flex-col": !min,
|
|
53
54
|
"pb-kilo overflow-scroll pr-deca": files.length > 3
|
|
54
55
|
}),
|
|
55
|
-
children: files.map((file, index) => /* @__PURE__ */ jsx(
|
|
56
|
+
children: type === "file" ? files.map((file, index) => /* @__PURE__ */ jsx(
|
|
56
57
|
File,
|
|
57
58
|
{
|
|
58
59
|
file,
|
|
@@ -61,7 +62,7 @@ const Manager = ({
|
|
|
61
62
|
showDelete: false
|
|
62
63
|
},
|
|
63
64
|
file.uid
|
|
64
|
-
))
|
|
65
|
+
)) : /* @__PURE__ */ jsx(Folder, { items: files })
|
|
65
66
|
}
|
|
66
67
|
)
|
|
67
68
|
] })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { button } from '@tecsinapse/cortex-core';
|
|
3
|
-
import { FaRegFileLines } from 'react-icons/fa6';
|
|
3
|
+
import { FaRegFileLines, FaRegFolder } from 'react-icons/fa6';
|
|
4
4
|
import { MdClose } from 'react-icons/md';
|
|
5
5
|
import { ProgressBar } from '../ProgressBar/ProgressBar.js';
|
|
6
6
|
|
|
@@ -61,5 +61,32 @@ const File = ({
|
|
|
61
61
|
)
|
|
62
62
|
] }, index);
|
|
63
63
|
};
|
|
64
|
+
const Folder = ({ items }) => {
|
|
65
|
+
const paths = /* @__PURE__ */ new Set();
|
|
66
|
+
for (const file in items) {
|
|
67
|
+
const path = items[file].file.relativePath.slice(1).split("/");
|
|
68
|
+
path.map((item) => paths.add(item));
|
|
69
|
+
}
|
|
70
|
+
const intent = (items ?? []).some((item) => item.status === "success") ? "success" : (items ?? []).some((item) => item.status === "error") ? "error" : "info";
|
|
71
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col w-full", children: [
|
|
72
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border rounded-t-mili shadow p-mili", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-centi", children: [
|
|
73
|
+
/* @__PURE__ */ jsx("span", { className: "border-2 text-kilo text-primary-medium w-tera h-tera flex items-center justify-center rounded-mili", children: /* @__PURE__ */ jsx(FaRegFolder, {}) }),
|
|
74
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-col", children: [
|
|
75
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold truncate max-w-[200px]", children: Array.from(paths)[0] }),
|
|
76
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500", children: [
|
|
77
|
+
paths.size - 1,
|
|
78
|
+
" itens"
|
|
79
|
+
] })
|
|
80
|
+
] })
|
|
81
|
+
] }) }),
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
ProgressBar,
|
|
84
|
+
{
|
|
85
|
+
intent,
|
|
86
|
+
infinite: (items ?? []).some((item) => item.status === "uploading")
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] });
|
|
90
|
+
};
|
|
64
91
|
|
|
65
|
-
export { File };
|
|
92
|
+
export { File, Folder };
|
|
@@ -10,7 +10,8 @@ const useFileUpload = ({
|
|
|
10
10
|
maxSize,
|
|
11
11
|
allowMultiple = true,
|
|
12
12
|
preventDuplicates = false,
|
|
13
|
-
onDuplicate
|
|
13
|
+
onDuplicate,
|
|
14
|
+
hasManager = true
|
|
14
15
|
}) => {
|
|
15
16
|
const [files, setFiles] = useState([]);
|
|
16
17
|
const [duplicates, setDuplicates] = useState([]);
|
|
@@ -38,8 +39,10 @@ const useFileUpload = ({
|
|
|
38
39
|
[]
|
|
39
40
|
);
|
|
40
41
|
const onDrop = async (acceptedFiles) => {
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (hasManager) {
|
|
43
|
+
openManager();
|
|
44
|
+
onClose();
|
|
45
|
+
}
|
|
43
46
|
let toProcess = acceptedFiles;
|
|
44
47
|
if (preventDuplicates) {
|
|
45
48
|
const found = (acceptedFiles ?? []).filter(
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ManagerProps } from './types';
|
|
2
|
-
export declare const Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, }: ManagerProps<T>) => any;
|
|
2
|
+
export declare const Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, type, }: ManagerProps<T>) => any;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { FileProps } from './types';
|
|
1
|
+
import { FileProps, FolderProps } from './types';
|
|
2
2
|
export declare const File: <T>({ file, index, onDelete, showDelete, }: FileProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const Folder: <T>({ items }: FolderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -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, }: import("./types").ManagerProps<T>) => any;
|
|
8
|
+
Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, type, }: import("./types").ManagerProps<T>) => any;
|
|
9
9
|
};
|
|
@@ -9,6 +9,9 @@ export interface FileProps<T> {
|
|
|
9
9
|
onDelete: (index: number) => void;
|
|
10
10
|
showDelete?: boolean;
|
|
11
11
|
}
|
|
12
|
+
export interface FolderProps<T> {
|
|
13
|
+
items: FileUpload<T>[];
|
|
14
|
+
}
|
|
12
15
|
export interface FilesProps<T> {
|
|
13
16
|
files: FileUpload<T>[];
|
|
14
17
|
onDelete: (index: number) => void;
|
|
@@ -64,6 +67,7 @@ export interface ManagerProps<T> {
|
|
|
64
67
|
onDelete: (index: number) => void;
|
|
65
68
|
uploadProgressText?: string;
|
|
66
69
|
onClose: () => void;
|
|
70
|
+
type?: 'file' | 'folder';
|
|
67
71
|
}
|
|
68
72
|
export declare const AcceptSpecificMap: {
|
|
69
73
|
readonly APPLICATION: readonly ["application/pdf", "application/zip", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/x-rar-compressed", "application/x-7z-compressed", "application/json", "application/xml", "application/rtf", "application/x-tar", "application/x-httpd-php", "application/octet-stream"];
|
|
@@ -14,8 +14,9 @@ interface UseFileUploadOptions<T> {
|
|
|
14
14
|
allowMultiple?: boolean;
|
|
15
15
|
preventDuplicates?: boolean;
|
|
16
16
|
onDuplicate?: (duplicates: File[]) => void;
|
|
17
|
+
hasManager?: boolean;
|
|
17
18
|
}
|
|
18
|
-
export declare const useFileUpload: <T>({ accept, onAccept, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, }: UseFileUploadOptions<T>) => {
|
|
19
|
+
export declare const useFileUpload: <T>({ accept, onAccept, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, }: UseFileUploadOptions<T>) => {
|
|
19
20
|
onOpen: () => void;
|
|
20
21
|
onClose: () => void;
|
|
21
22
|
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.6",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@floating-ui/react": "^0.26.18",
|
|
22
22
|
"@internationalized/date": "3.7.0",
|
|
23
|
-
"@tecsinapse/cortex-core": "1.2.0-beta.
|
|
23
|
+
"@tecsinapse/cortex-core": "1.2.0-beta.4",
|
|
24
24
|
"clsx": "2.1.1",
|
|
25
25
|
"currency.js": "2.0.4",
|
|
26
26
|
"embla-carousel-autoplay": "^8.0.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-icons": ">=5.2.0",
|
|
49
49
|
"tailwind": ">=3.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4b3f865fef0e94a662c300ccd5173c9aecdd4fd7"
|
|
52
52
|
}
|