componentes-sinco 1.0.14 → 1.0.16
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/index.cjs +45 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -21,13 +21,13 @@ interface AdjuntarProps<T> {
|
|
|
21
21
|
compact?: boolean;
|
|
22
22
|
maxSize?: number;
|
|
23
23
|
fileAccepted?: string;
|
|
24
|
-
onChange?: (archivos:
|
|
24
|
+
onChange?: (archivos: File[]) => void;
|
|
25
25
|
onLoading?: boolean;
|
|
26
26
|
downloadAction?: () => void;
|
|
27
27
|
initialFiles?: UploadedFile[];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
declare const Attachment:
|
|
30
|
+
declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<any>) => React__default.JSX.Element;
|
|
31
31
|
|
|
32
32
|
type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
|
|
33
33
|
type ReplyTextPalette = "primary" | "secondary" | "disabled";
|
package/dist/index.d.ts
CHANGED
|
@@ -21,13 +21,13 @@ interface AdjuntarProps<T> {
|
|
|
21
21
|
compact?: boolean;
|
|
22
22
|
maxSize?: number;
|
|
23
23
|
fileAccepted?: string;
|
|
24
|
-
onChange?: (archivos:
|
|
24
|
+
onChange?: (archivos: File[]) => void;
|
|
25
25
|
onLoading?: boolean;
|
|
26
26
|
downloadAction?: () => void;
|
|
27
27
|
initialFiles?: UploadedFile[];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
declare const Attachment:
|
|
30
|
+
declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<any>) => React__default.JSX.Element;
|
|
31
31
|
|
|
32
32
|
type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
|
|
33
33
|
type ReplyTextPalette = "primary" | "secondary" | "disabled";
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/Components/Adjuntar/Adjuntar.tsx
|
|
34
34
|
import React4, { useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
35
|
-
import { Box as Box3, Button as Button3, CircularProgress, IconButton as IconButton3, Stack as Stack3, Tooltip, Typography as Typography3 } from "@mui/material";
|
|
35
|
+
import { Box as Box3, Button as Button3, CircularProgress, IconButton as IconButton3, LinearProgress as LinearProgress2, Stack as Stack3, Tooltip, Typography as Typography3 } from "@mui/material";
|
|
36
36
|
import { CloudUploadOutlined, AttachFileOutlined, DeleteOutline, UploadFileOutlined, FileDownload } from "@mui/icons-material";
|
|
37
37
|
|
|
38
38
|
// src/Components/ToastNotification/SCToastNotification.tsx
|
|
@@ -389,7 +389,7 @@ var Attachment = ({
|
|
|
389
389
|
}) => {
|
|
390
390
|
const [files, setFiles] = useState4([]);
|
|
391
391
|
const [fileToDelete, setFileToDelete] = useState4(null);
|
|
392
|
-
const [toast, setToast] =
|
|
392
|
+
const [toast, setToast] = useState4(null);
|
|
393
393
|
const [openModal, setOpenModal] = useState4(false);
|
|
394
394
|
const [isDragFile, setIsDragFile] = useState4(false);
|
|
395
395
|
const inputRef = useRef(null);
|
|
@@ -415,7 +415,6 @@ var Attachment = ({
|
|
|
415
415
|
useEffect4(() => {
|
|
416
416
|
if (initialFiles.length > 0) {
|
|
417
417
|
setFiles(initialFiles);
|
|
418
|
-
onChange == null ? void 0 : onChange(initialFiles);
|
|
419
418
|
}
|
|
420
419
|
}, [initialFiles]);
|
|
421
420
|
useEffect4(() => {
|
|
@@ -438,20 +437,18 @@ var Attachment = ({
|
|
|
438
437
|
const newFiles = event2.target.files;
|
|
439
438
|
if (!newFiles) return;
|
|
440
439
|
const nuevosArchivos = [];
|
|
440
|
+
const archivosValidos = [];
|
|
441
441
|
Array.from(newFiles).forEach((file) => {
|
|
442
442
|
const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
|
|
443
443
|
const sizeMB = file.size / (1024 * 1024);
|
|
444
444
|
if (isDuplicatedFile !== -1) {
|
|
445
|
-
setToast(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
time: 10
|
|
453
|
-
});
|
|
454
|
-
}, 10);
|
|
445
|
+
setToast({
|
|
446
|
+
type: "error",
|
|
447
|
+
title: "Archivo duplicado",
|
|
448
|
+
listITems: ["No se permiten archivos duplicados."],
|
|
449
|
+
seeMore: true,
|
|
450
|
+
time: 10
|
|
451
|
+
});
|
|
455
452
|
return;
|
|
456
453
|
}
|
|
457
454
|
if (sizeMB > maxSize) {
|
|
@@ -462,16 +459,13 @@ var Attachment = ({
|
|
|
462
459
|
progress: 0,
|
|
463
460
|
uploadError: true
|
|
464
461
|
});
|
|
465
|
-
setToast(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
time: 10
|
|
473
|
-
});
|
|
474
|
-
}, 10);
|
|
462
|
+
setToast({
|
|
463
|
+
type: "error",
|
|
464
|
+
title: "Carga fallida",
|
|
465
|
+
seeMore: true,
|
|
466
|
+
listITems: [`El archivo supera el l\xEDmite de ${maxSize}MB.`],
|
|
467
|
+
time: 10
|
|
468
|
+
});
|
|
475
469
|
return;
|
|
476
470
|
}
|
|
477
471
|
if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
|
|
@@ -489,14 +483,15 @@ var Attachment = ({
|
|
|
489
483
|
size: file.size,
|
|
490
484
|
type: file.type,
|
|
491
485
|
progress: 0,
|
|
492
|
-
// inicializa el progreso en 0
|
|
493
486
|
uploadError: false
|
|
494
487
|
});
|
|
488
|
+
archivosValidos.push(file);
|
|
495
489
|
});
|
|
496
490
|
if (nuevosArchivos.length > 0) {
|
|
497
491
|
setFiles((prev) => {
|
|
498
492
|
const actualizados = [...prev, ...nuevosArchivos];
|
|
499
|
-
|
|
493
|
+
const totalFiles = [...onChange ? archivosValidos : []];
|
|
494
|
+
onChange == null ? void 0 : onChange(totalFiles);
|
|
500
495
|
return actualizados;
|
|
501
496
|
});
|
|
502
497
|
}
|
|
@@ -505,7 +500,8 @@ var Attachment = ({
|
|
|
505
500
|
const deleteFiles = (nameFile) => {
|
|
506
501
|
const filtered = files.filter((e) => e.name !== nameFile);
|
|
507
502
|
setFiles(filtered);
|
|
508
|
-
|
|
503
|
+
const remainingFiles = filtered.map((f) => new File([], f.name, { type: f.type }));
|
|
504
|
+
onChange == null ? void 0 : onChange(remainingFiles);
|
|
509
505
|
};
|
|
510
506
|
return /* @__PURE__ */ React4.createElement(Stack3, { spacing: 2 }, toast && /* @__PURE__ */ React4.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ React4.createElement(
|
|
511
507
|
"input",
|
|
@@ -605,7 +601,25 @@ var Attachment = ({
|
|
|
605
601
|
}
|
|
606
602
|
}
|
|
607
603
|
},
|
|
608
|
-
/* @__PURE__ */ React4.createElement(Stack3, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(UploadFileOutlined, { color: file.uploadError ? "error" : "primary", fontSize: "small" }), /* @__PURE__ */ React4.createElement(Stack3, { width: "100%" }, /* @__PURE__ */ React4.createElement(
|
|
604
|
+
/* @__PURE__ */ React4.createElement(Stack3, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(UploadFileOutlined, { color: file.uploadError ? "error" : "primary", fontSize: "small" }), /* @__PURE__ */ React4.createElement(Stack3, { width: "100%" }, /* @__PURE__ */ React4.createElement(
|
|
605
|
+
Typography3,
|
|
606
|
+
{
|
|
607
|
+
variant: "body2",
|
|
608
|
+
color: "text.primary",
|
|
609
|
+
whiteSpace: "nowrap",
|
|
610
|
+
overflow: "hidden",
|
|
611
|
+
textOverflow: "ellipsis",
|
|
612
|
+
maxWidth: "210px"
|
|
613
|
+
},
|
|
614
|
+
file.name
|
|
615
|
+
), /* @__PURE__ */ React4.createElement(Typography3, { variant: "caption", color: file.uploadError ? "error" : "text.secondary" }, file.uploadError && file.size / (1024 * 1024) > maxSize ? "Archivo super\xF3 el l\xEDmite \u2022 Carga fallida" : file.uploadError ? "Archivo duplicado o inv\xE1lido \u2022 Carga fallida" : `${(file.size / (1024 * 1024)).toFixed(2)}MB \u2022 ${file.type}`), file.progress < 100 && !file.uploadError && /* @__PURE__ */ React4.createElement(
|
|
616
|
+
LinearProgress2,
|
|
617
|
+
{
|
|
618
|
+
variant: "determinate",
|
|
619
|
+
color: "primary",
|
|
620
|
+
value: file.progress
|
|
621
|
+
}
|
|
622
|
+
))),
|
|
609
623
|
/* @__PURE__ */ React4.createElement(Tooltip, { title: "Descargar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: downloadAction }, /* @__PURE__ */ React4.createElement(FileDownload, { fontSize: "small", color: "action" }))),
|
|
610
624
|
/* @__PURE__ */ React4.createElement(Tooltip, { title: "Eliminar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: () => {
|
|
611
625
|
setFileToDelete(file);
|
|
@@ -627,14 +641,11 @@ var Attachment = ({
|
|
|
627
641
|
if (fileToDelete) {
|
|
628
642
|
deleteFiles(fileToDelete.name);
|
|
629
643
|
setFileToDelete(null);
|
|
630
|
-
setToast(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
time: 2
|
|
636
|
-
});
|
|
637
|
-
}, 10);
|
|
644
|
+
setToast({
|
|
645
|
+
title: "Archivo eliminado",
|
|
646
|
+
type: "success",
|
|
647
|
+
time: 2
|
|
648
|
+
});
|
|
638
649
|
}
|
|
639
650
|
setOpenModal(false);
|
|
640
651
|
}
|