@tecsinapse/cortex-react 1.15.0-beta.16 → 1.15.0-beta.17
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/Root.js +10 -14
- package/dist/cjs/components/Uploader/Upload.js +7 -4
- package/dist/esm/components/Uploader/Root.js +11 -15
- package/dist/esm/components/Uploader/Upload.js +8 -5
- 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 +0 -2
- package/dist/types/hooks/useFileUpload.d.ts +2 -2
- package/package.json +2 -2
|
@@ -3,24 +3,22 @@
|
|
|
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 Files = require('./Files.js');
|
|
7
7
|
|
|
8
8
|
const Root = ({
|
|
9
9
|
open,
|
|
10
10
|
onClose,
|
|
11
|
-
files,
|
|
12
|
-
onDelete,
|
|
13
11
|
dropzoneProps,
|
|
14
12
|
selectFileText,
|
|
15
13
|
dropText,
|
|
16
14
|
buttonText,
|
|
17
|
-
uploadProgressText,
|
|
18
15
|
titleModal,
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
onDelete,
|
|
17
|
+
uploadProgressText,
|
|
18
|
+
files
|
|
21
19
|
}) => {
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
23
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(Modal.Modal, { onClose, open, title: titleModal, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col w-full gap-deca md:flex-row", children: [
|
|
21
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
24
22
|
Dropzone.Dropzone,
|
|
25
23
|
{
|
|
26
24
|
dropzoneProps,
|
|
@@ -28,18 +26,16 @@ const Root = ({
|
|
|
28
26
|
dropText,
|
|
29
27
|
buttonText
|
|
30
28
|
}
|
|
31
|
-
)
|
|
29
|
+
),
|
|
32
30
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
-
|
|
31
|
+
Files.Files,
|
|
34
32
|
{
|
|
35
|
-
open: isManagerOpen,
|
|
36
33
|
files,
|
|
37
34
|
onDelete,
|
|
38
|
-
uploadProgressText
|
|
39
|
-
onClose: closeManager
|
|
35
|
+
uploadProgressText
|
|
40
36
|
}
|
|
41
37
|
)
|
|
42
|
-
] });
|
|
38
|
+
] }) }) });
|
|
43
39
|
};
|
|
44
40
|
|
|
45
41
|
exports.Root = Root;
|
|
@@ -86,9 +86,12 @@ const File = ({
|
|
|
86
86
|
] }, index);
|
|
87
87
|
};
|
|
88
88
|
const Folder = ({ name, subItems }) => {
|
|
89
|
-
const size =
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const size = React.useMemo(
|
|
90
|
+
() => countFolderElements(
|
|
91
|
+
subItems.map((it) => it.path),
|
|
92
|
+
name
|
|
93
|
+
),
|
|
94
|
+
[subItems, name]
|
|
92
95
|
);
|
|
93
96
|
const loading = React.useMemo(
|
|
94
97
|
() => subItems.some((it) => it.status === "uploading"),
|
|
@@ -127,7 +130,7 @@ const FolderList = ({ files, setFolders }) => {
|
|
|
127
130
|
});
|
|
128
131
|
return segments;
|
|
129
132
|
}, [files]);
|
|
130
|
-
setFolders(Object.entries(folders));
|
|
133
|
+
React.useEffect(() => setFolders(Object.entries(folders)), [folders, setFolders]);
|
|
131
134
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: Object.entries(folders).map(([name, children], index) => /* @__PURE__ */ jsxRuntime.jsx(Folder, { name, subItems: children }, index)) });
|
|
132
135
|
};
|
|
133
136
|
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Modal } from './Modal.js';
|
|
3
3
|
import { Dropzone } from './Dropzone.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Files } from './Files.js';
|
|
5
5
|
|
|
6
6
|
const Root = ({
|
|
7
7
|
open,
|
|
8
8
|
onClose,
|
|
9
|
-
files,
|
|
10
|
-
onDelete,
|
|
11
9
|
dropzoneProps,
|
|
12
10
|
selectFileText,
|
|
13
11
|
dropText,
|
|
14
12
|
buttonText,
|
|
15
|
-
uploadProgressText,
|
|
16
13
|
titleModal,
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
onDelete,
|
|
15
|
+
uploadProgressText,
|
|
16
|
+
files
|
|
19
17
|
}) => {
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
18
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Modal, { onClose, open, title: titleModal, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col w-full gap-deca md:flex-row", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
22
20
|
Dropzone,
|
|
23
21
|
{
|
|
24
22
|
dropzoneProps,
|
|
@@ -26,18 +24,16 @@ const Root = ({
|
|
|
26
24
|
dropText,
|
|
27
25
|
buttonText
|
|
28
26
|
}
|
|
29
|
-
)
|
|
27
|
+
),
|
|
30
28
|
/* @__PURE__ */ jsx(
|
|
31
|
-
|
|
29
|
+
Files,
|
|
32
30
|
{
|
|
33
|
-
open: isManagerOpen,
|
|
34
31
|
files,
|
|
35
32
|
onDelete,
|
|
36
|
-
uploadProgressText
|
|
37
|
-
onClose: closeManager
|
|
33
|
+
uploadProgressText
|
|
38
34
|
}
|
|
39
35
|
)
|
|
40
|
-
] });
|
|
36
|
+
] }) }) });
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
export { Root };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { button } from '@tecsinapse/cortex-core';
|
|
3
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { useMemo, useEffect } from 'react';
|
|
4
4
|
import { FaRegFileLines, FaRegFolder } from 'react-icons/fa6';
|
|
5
5
|
import { MdClose } from 'react-icons/md';
|
|
6
6
|
import { ProgressBar } from '../ProgressBar/ProgressBar.js';
|
|
@@ -84,9 +84,12 @@ const File = ({
|
|
|
84
84
|
] }, index);
|
|
85
85
|
};
|
|
86
86
|
const Folder = ({ name, subItems }) => {
|
|
87
|
-
const size =
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const size = useMemo(
|
|
88
|
+
() => countFolderElements(
|
|
89
|
+
subItems.map((it) => it.path),
|
|
90
|
+
name
|
|
91
|
+
),
|
|
92
|
+
[subItems, name]
|
|
90
93
|
);
|
|
91
94
|
const loading = useMemo(
|
|
92
95
|
() => subItems.some((it) => it.status === "uploading"),
|
|
@@ -125,7 +128,7 @@ const FolderList = ({ files, setFolders }) => {
|
|
|
125
128
|
});
|
|
126
129
|
return segments;
|
|
127
130
|
}, [files]);
|
|
128
|
-
setFolders(Object.entries(folders));
|
|
131
|
+
useEffect(() => setFolders(Object.entries(folders)), [folders, setFolders]);
|
|
129
132
|
return /* @__PURE__ */ jsx(Fragment, { children: Object.entries(folders).map(([name, children], index) => /* @__PURE__ */ jsx(Folder, { name, subItems: children }, index)) });
|
|
130
133
|
};
|
|
131
134
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RootUploaderProps } from './types';
|
|
2
|
-
export declare const Root: <T>({ open, onClose,
|
|
2
|
+
export declare const Root: <T>({ open, onClose, dropzoneProps, selectFileText, dropText, buttonText, titleModal, onDelete, uploadProgressText, files, }: RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,6 @@ 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,
|
|
7
|
+
Root: <T>({ open, onClose, dropzoneProps, selectFileText, dropText, buttonText, titleModal, onDelete, uploadProgressText, files, }: import("./types").RootUploaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
Manager: <T>({ open, files, onDelete, uploadProgressText, onClose, }: import("./types").ManagerProps<T>) => any;
|
|
9
9
|
};
|
|
@@ -71,8 +71,6 @@ export type FileUpload<T> = {
|
|
|
71
71
|
export interface RootUploaderProps<T> {
|
|
72
72
|
open: boolean;
|
|
73
73
|
onClose: () => void;
|
|
74
|
-
isManagerOpen: boolean;
|
|
75
|
-
closeManager: () => void;
|
|
76
74
|
files: FileUpload<T>[];
|
|
77
75
|
onDelete: (index: number) => void;
|
|
78
76
|
dropzoneProps: UseDropzoneProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DropEvent, type FileRejection } from 'react-dropzone';
|
|
2
2
|
import { AcceptSpecificMap, UseDropzoneProps, type FileUpload } from '../components/Uploader/types';
|
|
3
|
-
interface UseFileUploadOptions
|
|
3
|
+
interface UseFileUploadOptions {
|
|
4
4
|
accept?: {
|
|
5
5
|
IMAGE?: (typeof AcceptSpecificMap.IMAGE)[number][];
|
|
6
6
|
APPLICATION?: (typeof AcceptSpecificMap.APPLICATION)[number][];
|
|
@@ -19,7 +19,7 @@ interface UseFileUploadOptions<T> {
|
|
|
19
19
|
isFolder?: boolean;
|
|
20
20
|
uploadProgressText?: string;
|
|
21
21
|
}
|
|
22
|
-
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, uploadProgressText, }: UseFileUploadOptions
|
|
22
|
+
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, uploadProgressText, }: UseFileUploadOptions) => {
|
|
23
23
|
onOpen: () => void;
|
|
24
24
|
onClose: () => void;
|
|
25
25
|
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.17",
|
|
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": "ed21f3b6b622995b034091e9364ff1cc02069adb"
|
|
52
52
|
}
|