componentes-sinco 1.0.14 → 1.0.15
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.cjs
CHANGED
|
@@ -457,7 +457,7 @@ var Attachment = ({
|
|
|
457
457
|
}) => {
|
|
458
458
|
const [files, setFiles] = (0, import_react5.useState)([]);
|
|
459
459
|
const [fileToDelete, setFileToDelete] = (0, import_react5.useState)(null);
|
|
460
|
-
const [toast, setToast] = import_react5.
|
|
460
|
+
const [toast, setToast] = (0, import_react5.useState)(null);
|
|
461
461
|
const [openModal, setOpenModal] = (0, import_react5.useState)(false);
|
|
462
462
|
const [isDragFile, setIsDragFile] = (0, import_react5.useState)(false);
|
|
463
463
|
const inputRef = (0, import_react5.useRef)(null);
|
|
@@ -483,7 +483,6 @@ var Attachment = ({
|
|
|
483
483
|
(0, import_react5.useEffect)(() => {
|
|
484
484
|
if (initialFiles.length > 0) {
|
|
485
485
|
setFiles(initialFiles);
|
|
486
|
-
onChange == null ? void 0 : onChange(initialFiles);
|
|
487
486
|
}
|
|
488
487
|
}, [initialFiles]);
|
|
489
488
|
(0, import_react5.useEffect)(() => {
|
|
@@ -506,20 +505,18 @@ var Attachment = ({
|
|
|
506
505
|
const newFiles = event2.target.files;
|
|
507
506
|
if (!newFiles) return;
|
|
508
507
|
const nuevosArchivos = [];
|
|
508
|
+
const archivosValidos = [];
|
|
509
509
|
Array.from(newFiles).forEach((file) => {
|
|
510
510
|
const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
|
|
511
511
|
const sizeMB = file.size / (1024 * 1024);
|
|
512
512
|
if (isDuplicatedFile !== -1) {
|
|
513
|
-
setToast(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
time: 10
|
|
521
|
-
});
|
|
522
|
-
}, 10);
|
|
513
|
+
setToast({
|
|
514
|
+
type: "error",
|
|
515
|
+
title: "Archivo duplicado",
|
|
516
|
+
listITems: ["No se permiten archivos duplicados."],
|
|
517
|
+
seeMore: true,
|
|
518
|
+
time: 10
|
|
519
|
+
});
|
|
523
520
|
return;
|
|
524
521
|
}
|
|
525
522
|
if (sizeMB > maxSize) {
|
|
@@ -530,16 +527,13 @@ var Attachment = ({
|
|
|
530
527
|
progress: 0,
|
|
531
528
|
uploadError: true
|
|
532
529
|
});
|
|
533
|
-
setToast(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
time: 10
|
|
541
|
-
});
|
|
542
|
-
}, 10);
|
|
530
|
+
setToast({
|
|
531
|
+
type: "error",
|
|
532
|
+
title: "Carga fallida",
|
|
533
|
+
seeMore: true,
|
|
534
|
+
listITems: [`El archivo supera el l\xEDmite de ${maxSize}MB.`],
|
|
535
|
+
time: 10
|
|
536
|
+
});
|
|
543
537
|
return;
|
|
544
538
|
}
|
|
545
539
|
if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
|
|
@@ -557,14 +551,15 @@ var Attachment = ({
|
|
|
557
551
|
size: file.size,
|
|
558
552
|
type: file.type,
|
|
559
553
|
progress: 0,
|
|
560
|
-
// inicializa el progreso en 0
|
|
561
554
|
uploadError: false
|
|
562
555
|
});
|
|
556
|
+
archivosValidos.push(file);
|
|
563
557
|
});
|
|
564
558
|
if (nuevosArchivos.length > 0) {
|
|
565
559
|
setFiles((prev) => {
|
|
566
560
|
const actualizados = [...prev, ...nuevosArchivos];
|
|
567
|
-
|
|
561
|
+
const totalFiles = [...onChange ? archivosValidos : []];
|
|
562
|
+
onChange == null ? void 0 : onChange(totalFiles);
|
|
568
563
|
return actualizados;
|
|
569
564
|
});
|
|
570
565
|
}
|
|
@@ -573,7 +568,8 @@ var Attachment = ({
|
|
|
573
568
|
const deleteFiles = (nameFile) => {
|
|
574
569
|
const filtered = files.filter((e) => e.name !== nameFile);
|
|
575
570
|
setFiles(filtered);
|
|
576
|
-
|
|
571
|
+
const remainingFiles = filtered.map((f) => new File([], f.name, { type: f.type }));
|
|
572
|
+
onChange == null ? void 0 : onChange(remainingFiles);
|
|
577
573
|
};
|
|
578
574
|
return /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { spacing: 2 }, toast && /* @__PURE__ */ import_react5.default.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ import_react5.default.createElement(
|
|
579
575
|
"input",
|
|
@@ -673,7 +669,25 @@ var Attachment = ({
|
|
|
673
669
|
}
|
|
674
670
|
}
|
|
675
671
|
},
|
|
676
|
-
/* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.UploadFileOutlined, { color: file.uploadError ? "error" : "primary", fontSize: "small" }), /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(
|
|
672
|
+
/* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.UploadFileOutlined, { color: file.uploadError ? "error" : "primary", fontSize: "small" }), /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(
|
|
673
|
+
import_material3.Typography,
|
|
674
|
+
{
|
|
675
|
+
variant: "body2",
|
|
676
|
+
color: "text.primary",
|
|
677
|
+
whiteSpace: "nowrap",
|
|
678
|
+
overflow: "hidden",
|
|
679
|
+
textOverflow: "ellipsis",
|
|
680
|
+
maxWidth: "210px"
|
|
681
|
+
},
|
|
682
|
+
file.name
|
|
683
|
+
), /* @__PURE__ */ import_react5.default.createElement(import_material3.Typography, { 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__ */ import_react5.default.createElement(
|
|
684
|
+
import_material3.LinearProgress,
|
|
685
|
+
{
|
|
686
|
+
variant: "determinate",
|
|
687
|
+
color: "primary",
|
|
688
|
+
value: file.progress
|
|
689
|
+
}
|
|
690
|
+
))),
|
|
677
691
|
/* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Descargar" }, /* @__PURE__ */ import_react5.default.createElement(import_material3.IconButton, { size: "small", onClick: downloadAction }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.FileDownload, { fontSize: "small", color: "action" }))),
|
|
678
692
|
/* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(import_material3.IconButton, { size: "small", onClick: () => {
|
|
679
693
|
setFileToDelete(file);
|
|
@@ -695,14 +709,11 @@ var Attachment = ({
|
|
|
695
709
|
if (fileToDelete) {
|
|
696
710
|
deleteFiles(fileToDelete.name);
|
|
697
711
|
setFileToDelete(null);
|
|
698
|
-
setToast(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
time: 2
|
|
704
|
-
});
|
|
705
|
-
}, 10);
|
|
712
|
+
setToast({
|
|
713
|
+
title: "Archivo eliminado",
|
|
714
|
+
type: "success",
|
|
715
|
+
time: 2
|
|
716
|
+
});
|
|
706
717
|
}
|
|
707
718
|
setOpenModal(false);
|
|
708
719
|
}
|