@tecsinapse/cortex-react 1.14.0 → 1.15.0-beta.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/dist/cjs/components/Uploader/Manager.js +63 -0
- package/dist/cjs/components/Uploader/Root.js +12 -8
- package/dist/cjs/components/Uploader/Upload.js +1 -1
- package/dist/cjs/hooks/useFileUpload.js +7 -0
- package/dist/esm/components/Uploader/Manager.js +61 -0
- package/dist/esm/components/Uploader/Root.js +13 -9
- package/dist/esm/components/Uploader/Upload.js +1 -1
- package/dist/esm/hooks/useFileUpload.js +7 -0
- package/dist/types/components/Uploader/Manager.d.ts +10 -0
- package/dist/types/components/Uploader/Root.d.ts +1 -1
- package/dist/types/components/Uploader/index.d.ts +1 -1
- package/dist/types/components/Uploader/types.d.ts +2 -0
- package/dist/types/hooks/useFileUpload.d.ts +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var tailwindVariants = require('tailwind-variants');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
var Upload = require('./Upload.js');
|
|
7
|
+
var Button = require('../Button.js');
|
|
8
|
+
var io = require('react-icons/io');
|
|
9
|
+
|
|
10
|
+
const foldermodal = tailwindVariants.tv({
|
|
11
|
+
base: "fixed rounded-micro p-kilo bg-white shadow-xl flex transition z-modal",
|
|
12
|
+
variants: {
|
|
13
|
+
open: {
|
|
14
|
+
true: "scale-100 visible",
|
|
15
|
+
false: "invisible"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const Manager = ({
|
|
20
|
+
open,
|
|
21
|
+
files,
|
|
22
|
+
onDelete,
|
|
23
|
+
uploadProgressText = "Upload(s) in progress",
|
|
24
|
+
onClose
|
|
25
|
+
}) => {
|
|
26
|
+
return reactDom.createPortal(
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: foldermodal({
|
|
31
|
+
className: "h-[350px] w-[400px] bg-white bottom-deca right-deca overflow-hidden",
|
|
32
|
+
open
|
|
33
|
+
}),
|
|
34
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col w-full h-full gap-mili items-center", children: [
|
|
35
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {}),
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "ml-mega", "data-testid": "upload-progress", children: uploadProgressText }),
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
+
Button.Button,
|
|
40
|
+
{
|
|
41
|
+
variants: { variant: "outline", size: "circle" },
|
|
42
|
+
onClick: onClose,
|
|
43
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(io.IoMdClose, {})
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col w-full overflow-scroll", children: files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
Upload.File,
|
|
49
|
+
{
|
|
50
|
+
file,
|
|
51
|
+
index,
|
|
52
|
+
onDelete
|
|
53
|
+
},
|
|
54
|
+
file.uid
|
|
55
|
+
)) })
|
|
56
|
+
] })
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
document.body
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.Manager = Manager;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var Modal = require('./Modal.js');
|
|
5
5
|
var Dropzone = require('./Dropzone.js');
|
|
6
|
-
var
|
|
6
|
+
var Manager = require('./Manager.js');
|
|
7
7
|
|
|
8
8
|
const Root = ({
|
|
9
9
|
open,
|
|
@@ -15,10 +15,12 @@ const Root = ({
|
|
|
15
15
|
dropText,
|
|
16
16
|
buttonText,
|
|
17
17
|
uploadProgressText,
|
|
18
|
-
titleModal
|
|
18
|
+
titleModal,
|
|
19
|
+
isManagerOpen,
|
|
20
|
+
closeManager
|
|
19
21
|
}) => {
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
21
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsx(Modal.Modal, { onClose, open, title: titleModal, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col w-full gap-deca md:flex-row", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22
24
|
Dropzone.Dropzone,
|
|
23
25
|
{
|
|
24
26
|
dropzoneProps,
|
|
@@ -26,16 +28,18 @@ const Root = ({
|
|
|
26
28
|
dropText,
|
|
27
29
|
buttonText
|
|
28
30
|
}
|
|
29
|
-
),
|
|
31
|
+
) }) }),
|
|
30
32
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
-
|
|
33
|
+
Manager.Manager,
|
|
32
34
|
{
|
|
35
|
+
open: isManagerOpen,
|
|
33
36
|
files,
|
|
34
37
|
onDelete,
|
|
35
|
-
uploadProgressText
|
|
38
|
+
uploadProgressText,
|
|
39
|
+
onClose: closeManager
|
|
36
40
|
}
|
|
37
41
|
)
|
|
38
|
-
] })
|
|
42
|
+
] });
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
exports.Root = Root;
|
|
@@ -45,7 +45,7 @@ const File = ({ file, index, onDelete }) => {
|
|
|
45
45
|
className: " bg-inherit border-2 border-primary-light text-primary-light",
|
|
46
46
|
size: "small"
|
|
47
47
|
}),
|
|
48
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(md.MdClose, { size:
|
|
48
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(md.MdClose, { size: 15 })
|
|
49
49
|
}
|
|
50
50
|
)
|
|
51
51
|
] }),
|
|
@@ -17,8 +17,11 @@ const useFileUpload = ({
|
|
|
17
17
|
const [files, setFiles] = React.useState([]);
|
|
18
18
|
const [duplicates, setDuplicates] = React.useState([]);
|
|
19
19
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
20
|
+
const [isManagerOpen, setIsManagerOpen] = React.useState(false);
|
|
20
21
|
const onOpen = React.useCallback(() => setIsOpen(true), []);
|
|
21
22
|
const onClose = React.useCallback(() => setIsOpen(false), []);
|
|
23
|
+
const openManager = React.useCallback(() => setIsManagerOpen(true), []);
|
|
24
|
+
const closeManager = React.useCallback(() => setIsManagerOpen(false), []);
|
|
22
25
|
const updateFiles = React.useCallback(
|
|
23
26
|
(prevFiles, newFiles) => {
|
|
24
27
|
const current = /* @__PURE__ */ new Map();
|
|
@@ -28,6 +31,8 @@ const useFileUpload = ({
|
|
|
28
31
|
[]
|
|
29
32
|
);
|
|
30
33
|
const onDrop = async (acceptedFiles) => {
|
|
34
|
+
openManager();
|
|
35
|
+
onClose();
|
|
31
36
|
let toProcess = acceptedFiles;
|
|
32
37
|
if (preventDuplicates) {
|
|
33
38
|
const found = (acceptedFiles ?? []).filter(
|
|
@@ -102,6 +107,8 @@ const useFileUpload = ({
|
|
|
102
107
|
isFileLimitReached
|
|
103
108
|
},
|
|
104
109
|
open: isOpen,
|
|
110
|
+
closeManager,
|
|
111
|
+
isManagerOpen,
|
|
105
112
|
files,
|
|
106
113
|
duplicates,
|
|
107
114
|
onClearFiles: handleClearFiles
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { tv } from 'tailwind-variants';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { File } from './Upload.js';
|
|
5
|
+
import { Button } from '../Button.js';
|
|
6
|
+
import { IoMdClose } from 'react-icons/io';
|
|
7
|
+
|
|
8
|
+
const foldermodal = tv({
|
|
9
|
+
base: "fixed rounded-micro p-kilo bg-white shadow-xl flex transition z-modal",
|
|
10
|
+
variants: {
|
|
11
|
+
open: {
|
|
12
|
+
true: "scale-100 visible",
|
|
13
|
+
false: "invisible"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const Manager = ({
|
|
18
|
+
open,
|
|
19
|
+
files,
|
|
20
|
+
onDelete,
|
|
21
|
+
uploadProgressText = "Upload(s) in progress",
|
|
22
|
+
onClose
|
|
23
|
+
}) => {
|
|
24
|
+
return createPortal(
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: foldermodal({
|
|
29
|
+
className: "h-[350px] w-[400px] bg-white bottom-deca right-deca overflow-hidden",
|
|
30
|
+
open
|
|
31
|
+
}),
|
|
32
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col w-full h-full gap-mili items-center", children: [
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full", children: [
|
|
34
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
35
|
+
/* @__PURE__ */ jsx("h3", { className: "ml-mega", "data-testid": "upload-progress", children: uploadProgressText }),
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
Button,
|
|
38
|
+
{
|
|
39
|
+
variants: { variant: "outline", size: "circle" },
|
|
40
|
+
onClick: onClose,
|
|
41
|
+
children: /* @__PURE__ */ jsx(IoMdClose, {})
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col w-full overflow-scroll", children: files.map((file, index) => /* @__PURE__ */ jsx(
|
|
46
|
+
File,
|
|
47
|
+
{
|
|
48
|
+
file,
|
|
49
|
+
index,
|
|
50
|
+
onDelete
|
|
51
|
+
},
|
|
52
|
+
file.uid
|
|
53
|
+
)) })
|
|
54
|
+
] })
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
document.body
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { Manager };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Modal } from './Modal.js';
|
|
3
3
|
import { Dropzone } from './Dropzone.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Manager } from './Manager.js';
|
|
5
5
|
|
|
6
6
|
const Root = ({
|
|
7
7
|
open,
|
|
@@ -13,10 +13,12 @@ const Root = ({
|
|
|
13
13
|
dropText,
|
|
14
14
|
buttonText,
|
|
15
15
|
uploadProgressText,
|
|
16
|
-
titleModal
|
|
16
|
+
titleModal,
|
|
17
|
+
isManagerOpen,
|
|
18
|
+
closeManager
|
|
17
19
|
}) => {
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
/* @__PURE__ */ jsx(
|
|
20
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(Modal, { onClose, open, title: titleModal, children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col w-full gap-deca md:flex-row", children: /* @__PURE__ */ jsx(
|
|
20
22
|
Dropzone,
|
|
21
23
|
{
|
|
22
24
|
dropzoneProps,
|
|
@@ -24,16 +26,18 @@ const Root = ({
|
|
|
24
26
|
dropText,
|
|
25
27
|
buttonText
|
|
26
28
|
}
|
|
27
|
-
),
|
|
29
|
+
) }) }),
|
|
28
30
|
/* @__PURE__ */ jsx(
|
|
29
|
-
|
|
31
|
+
Manager,
|
|
30
32
|
{
|
|
33
|
+
open: isManagerOpen,
|
|
31
34
|
files,
|
|
32
35
|
onDelete,
|
|
33
|
-
uploadProgressText
|
|
36
|
+
uploadProgressText,
|
|
37
|
+
onClose: closeManager
|
|
34
38
|
}
|
|
35
39
|
)
|
|
36
|
-
] })
|
|
40
|
+
] });
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export { Root };
|
|
@@ -43,7 +43,7 @@ const File = ({ file, index, onDelete }) => {
|
|
|
43
43
|
className: " bg-inherit border-2 border-primary-light text-primary-light",
|
|
44
44
|
size: "small"
|
|
45
45
|
}),
|
|
46
|
-
children: /* @__PURE__ */ jsx(MdClose, { size:
|
|
46
|
+
children: /* @__PURE__ */ jsx(MdClose, { size: 15 })
|
|
47
47
|
}
|
|
48
48
|
)
|
|
49
49
|
] }),
|
|
@@ -15,8 +15,11 @@ const useFileUpload = ({
|
|
|
15
15
|
const [files, setFiles] = useState([]);
|
|
16
16
|
const [duplicates, setDuplicates] = useState([]);
|
|
17
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
18
|
+
const [isManagerOpen, setIsManagerOpen] = useState(false);
|
|
18
19
|
const onOpen = useCallback(() => setIsOpen(true), []);
|
|
19
20
|
const onClose = useCallback(() => setIsOpen(false), []);
|
|
21
|
+
const openManager = useCallback(() => setIsManagerOpen(true), []);
|
|
22
|
+
const closeManager = useCallback(() => setIsManagerOpen(false), []);
|
|
20
23
|
const updateFiles = useCallback(
|
|
21
24
|
(prevFiles, newFiles) => {
|
|
22
25
|
const current = /* @__PURE__ */ new Map();
|
|
@@ -26,6 +29,8 @@ const useFileUpload = ({
|
|
|
26
29
|
[]
|
|
27
30
|
);
|
|
28
31
|
const onDrop = async (acceptedFiles) => {
|
|
32
|
+
openManager();
|
|
33
|
+
onClose();
|
|
29
34
|
let toProcess = acceptedFiles;
|
|
30
35
|
if (preventDuplicates) {
|
|
31
36
|
const found = (acceptedFiles ?? []).filter(
|
|
@@ -100,6 +105,8 @@ const useFileUpload = ({
|
|
|
100
105
|
isFileLimitReached
|
|
101
106
|
},
|
|
102
107
|
open: isOpen,
|
|
108
|
+
closeManager,
|
|
109
|
+
isManagerOpen,
|
|
103
110
|
files,
|
|
104
111
|
duplicates,
|
|
105
112
|
onClearFiles: handleClearFiles
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileUpload } from './types';
|
|
2
|
+
interface ManagerProps<T> {
|
|
3
|
+
open: boolean;
|
|
4
|
+
files: FileUpload<T>[];
|
|
5
|
+
onDelete: (index: number) => void;
|
|
6
|
+
uploadProgressText?: string;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, }: ManagerProps<T>) => any;
|
|
10
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RootUploaderProps } from './types';
|
|
2
|
-
export declare const Root: <T>({ open, onClose, files, onDelete, dropzoneProps, selectFileText, dropText, buttonText, uploadProgressText, titleModal, }: RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Root: <T>({ open, onClose, files, onDelete, dropzoneProps, selectFileText, dropText, buttonText, uploadProgressText, titleModal, isManagerOpen, closeManager, }: RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,5 +4,5 @@ export declare const Uploader: {
|
|
|
4
4
|
Dropzone: ({ dropzoneProps, selectFileText, dropText, buttonText, }: import("./types").DropzoneProps) => import("react/jsx-runtime").JSX.Element;
|
|
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
|
-
Root: <T>({ open, onClose, files, onDelete, dropzoneProps, selectFileText, dropText, buttonText, uploadProgressText, titleModal, }: import("./types").RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
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
8
|
};
|
|
@@ -46,6 +46,8 @@ export type FileUpload<T> = {
|
|
|
46
46
|
export interface RootUploaderProps<T> {
|
|
47
47
|
open: boolean;
|
|
48
48
|
onClose: () => void;
|
|
49
|
+
isManagerOpen: boolean;
|
|
50
|
+
closeManager: () => void;
|
|
49
51
|
files: FileUpload<T>[];
|
|
50
52
|
onDelete: (index: number) => void;
|
|
51
53
|
dropzoneProps: UseDropzoneProps;
|
|
@@ -21,6 +21,8 @@ export declare const useFileUpload: <T>({ accept, onAccept, onFileRejected, maxS
|
|
|
21
21
|
onDelete: (index: number) => void;
|
|
22
22
|
dropzoneProps: UseDropzoneProps;
|
|
23
23
|
open: boolean;
|
|
24
|
+
closeManager: () => void;
|
|
25
|
+
isManagerOpen: boolean;
|
|
24
26
|
files: FileUpload<T>[];
|
|
25
27
|
duplicates: File[];
|
|
26
28
|
onClearFiles: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0-beta.0",
|
|
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": "6d45cc9f4731040772e88399eee523d38457cd62"
|
|
52
52
|
}
|