@tecsinapse/cortex-react 1.15.0 → 1.15.1

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.
@@ -9,13 +9,13 @@ 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');
13
12
 
14
13
  const Manager = ({
15
14
  open,
16
15
  files,
17
16
  onDelete,
18
17
  uploadProgressText = "Upload(s) in progress",
18
+ uploadSuccessText = "Upload(s) completed",
19
19
  onClose
20
20
  }) => {
21
21
  const {
@@ -47,14 +47,14 @@ const Manager = ({
47
47
  children: min ? /* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronDown, {})
48
48
  }
49
49
  ),
50
- /* @__PURE__ */ jsxRuntime.jsx("h3", { "data-testid": "upload-progress", children: uploadProgressText }),
50
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { "data-testid": "upload-progress", children: isLoading ? uploadProgressText : uploadSuccessText }),
51
51
  /* @__PURE__ */ jsxRuntime.jsx(
52
52
  Button.Button,
53
53
  {
54
54
  variants: { variant: "filled", size: "square" },
55
55
  onClick: onClose,
56
56
  disabled: isLoading,
57
- children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Loading.Loading, {}) : /* @__PURE__ */ jsxRuntime.jsx(io.IoMdClose, {})
57
+ children: /* @__PURE__ */ jsxRuntime.jsx(io.IoMdClose, {})
58
58
  }
59
59
  )
60
60
  ] }),
@@ -44,6 +44,15 @@ const File = ({
44
44
  return "info";
45
45
  }
46
46
  }
47
+ const formatFileSize = (size) => {
48
+ const units = ["B", "KB", "MB", "GB"];
49
+ let i = 0;
50
+ while (size >= 1024 && i < units.length - 1) {
51
+ size /= 1024;
52
+ i++;
53
+ }
54
+ return `${size.toFixed(2)} ${units[i]}`;
55
+ };
47
56
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col w-full", children: [
48
57
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border rounded-t-mili shadow p-mili", children: [
49
58
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-centi", children: [
@@ -57,10 +66,7 @@ const File = ({
57
66
  ) : /* @__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.FaRegFileLines, {}) }),
58
67
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-col", children: [
59
68
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold truncate max-w-[200px]", children: file.file.name }),
60
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500", children: [
61
- (file.file.size / 1024).toFixed(2),
62
- " KB"
63
- ] })
69
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500", children: formatFileSize(file.file.size) })
64
70
  ] })
65
71
  ] }),
66
72
  file.status === "success" && showDelete ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -7,13 +7,13 @@ 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';
11
10
 
12
11
  const Manager = ({
13
12
  open,
14
13
  files,
15
14
  onDelete,
16
15
  uploadProgressText = "Upload(s) in progress",
16
+ uploadSuccessText = "Upload(s) completed",
17
17
  onClose
18
18
  }) => {
19
19
  const {
@@ -45,14 +45,14 @@ const Manager = ({
45
45
  children: min ? /* @__PURE__ */ jsx(IoChevronUp, {}) : /* @__PURE__ */ jsx(IoChevronDown, {})
46
46
  }
47
47
  ),
48
- /* @__PURE__ */ jsx("h3", { "data-testid": "upload-progress", children: uploadProgressText }),
48
+ /* @__PURE__ */ jsx("h3", { "data-testid": "upload-progress", children: isLoading ? uploadProgressText : uploadSuccessText }),
49
49
  /* @__PURE__ */ jsx(
50
50
  Button,
51
51
  {
52
52
  variants: { variant: "filled", size: "square" },
53
53
  onClick: onClose,
54
54
  disabled: isLoading,
55
- children: isLoading ? /* @__PURE__ */ jsx(Loading, {}) : /* @__PURE__ */ jsx(IoMdClose, {})
55
+ children: /* @__PURE__ */ jsx(IoMdClose, {})
56
56
  }
57
57
  )
58
58
  ] }),
@@ -42,6 +42,15 @@ const File = ({
42
42
  return "info";
43
43
  }
44
44
  }
45
+ const formatFileSize = (size) => {
46
+ const units = ["B", "KB", "MB", "GB"];
47
+ let i = 0;
48
+ while (size >= 1024 && i < units.length - 1) {
49
+ size /= 1024;
50
+ i++;
51
+ }
52
+ return `${size.toFixed(2)} ${units[i]}`;
53
+ };
45
54
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col w-full", children: [
46
55
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border rounded-t-mili shadow p-mili", children: [
47
56
  /* @__PURE__ */ jsxs("div", { className: "flex gap-centi", children: [
@@ -55,10 +64,7 @@ const File = ({
55
64
  ) : /* @__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(FaRegFileLines, {}) }),
56
65
  /* @__PURE__ */ jsxs("div", { className: "flex-col", children: [
57
66
  /* @__PURE__ */ jsx("p", { className: "font-semibold truncate max-w-[200px]", children: file.file.name }),
58
- /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500", children: [
59
- (file.file.size / 1024).toFixed(2),
60
- " KB"
61
- ] })
67
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: formatFileSize(file.file.size) })
62
68
  ] })
63
69
  ] }),
64
70
  file.status === "success" && showDelete ? /* @__PURE__ */ jsx(
@@ -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, uploadSuccessText, 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, dropzoneProps, selectFileText, dropText, buttonText, titleModal, onDelete, uploadProgressText, files, }: 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, uploadSuccessText, onClose, }: import("./types").ManagerProps<T>) => any;
9
9
  };
@@ -87,6 +87,7 @@ export interface ManagerProps<T> {
87
87
  files?: FileUpload<T>[];
88
88
  onDelete?: (index: number) => void;
89
89
  uploadProgressText?: string;
90
+ uploadSuccessText?: string;
90
91
  onClose?: () => void;
91
92
  }
92
93
  export declare const AcceptSpecificMap: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
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": "877a756e55265fa6fef624c881b496ece5b2366b"
51
+ "gitHead": "d3f90898df0e766db23787a5bc5403294cffd5a4"
52
52
  }