componentes-sinco 1.0.13 → 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 +42 -38
- 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 +42 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -345,7 +345,6 @@ var SCModal = ({
|
|
|
345
345
|
state = "info",
|
|
346
346
|
open,
|
|
347
347
|
setOpen,
|
|
348
|
-
// ✅ ahora también puedes pasar setOpen desde afuera
|
|
349
348
|
title,
|
|
350
349
|
description,
|
|
351
350
|
action
|
|
@@ -367,7 +366,7 @@ var SCModal = ({
|
|
|
367
366
|
[action, handleClose]
|
|
368
367
|
);
|
|
369
368
|
const { icon, defaultDescription } = modalStateConfig[state];
|
|
370
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(
|
|
369
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, buttonModal && /* @__PURE__ */ import_react4.default.createElement(
|
|
371
370
|
import_material2.Button,
|
|
372
371
|
{
|
|
373
372
|
"data-testid": "test-buttonModal",
|
|
@@ -458,7 +457,7 @@ var Attachment = ({
|
|
|
458
457
|
}) => {
|
|
459
458
|
const [files, setFiles] = (0, import_react5.useState)([]);
|
|
460
459
|
const [fileToDelete, setFileToDelete] = (0, import_react5.useState)(null);
|
|
461
|
-
const [toast, setToast] = import_react5.
|
|
460
|
+
const [toast, setToast] = (0, import_react5.useState)(null);
|
|
462
461
|
const [openModal, setOpenModal] = (0, import_react5.useState)(false);
|
|
463
462
|
const [isDragFile, setIsDragFile] = (0, import_react5.useState)(false);
|
|
464
463
|
const inputRef = (0, import_react5.useRef)(null);
|
|
@@ -484,7 +483,6 @@ var Attachment = ({
|
|
|
484
483
|
(0, import_react5.useEffect)(() => {
|
|
485
484
|
if (initialFiles.length > 0) {
|
|
486
485
|
setFiles(initialFiles);
|
|
487
|
-
onChange == null ? void 0 : onChange(initialFiles);
|
|
488
486
|
}
|
|
489
487
|
}, [initialFiles]);
|
|
490
488
|
(0, import_react5.useEffect)(() => {
|
|
@@ -507,20 +505,18 @@ var Attachment = ({
|
|
|
507
505
|
const newFiles = event2.target.files;
|
|
508
506
|
if (!newFiles) return;
|
|
509
507
|
const nuevosArchivos = [];
|
|
508
|
+
const archivosValidos = [];
|
|
510
509
|
Array.from(newFiles).forEach((file) => {
|
|
511
510
|
const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
|
|
512
511
|
const sizeMB = file.size / (1024 * 1024);
|
|
513
512
|
if (isDuplicatedFile !== -1) {
|
|
514
|
-
setToast(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
time: 10
|
|
522
|
-
});
|
|
523
|
-
}, 10);
|
|
513
|
+
setToast({
|
|
514
|
+
type: "error",
|
|
515
|
+
title: "Archivo duplicado",
|
|
516
|
+
listITems: ["No se permiten archivos duplicados."],
|
|
517
|
+
seeMore: true,
|
|
518
|
+
time: 10
|
|
519
|
+
});
|
|
524
520
|
return;
|
|
525
521
|
}
|
|
526
522
|
if (sizeMB > maxSize) {
|
|
@@ -531,16 +527,13 @@ var Attachment = ({
|
|
|
531
527
|
progress: 0,
|
|
532
528
|
uploadError: true
|
|
533
529
|
});
|
|
534
|
-
setToast(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
time: 10
|
|
542
|
-
});
|
|
543
|
-
}, 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
|
+
});
|
|
544
537
|
return;
|
|
545
538
|
}
|
|
546
539
|
if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
|
|
@@ -548,6 +541,7 @@ var Attachment = ({
|
|
|
548
541
|
type: "error",
|
|
549
542
|
title: "Tipo de archivo no permitido",
|
|
550
543
|
listITems: [`El archivo ${file.name} no es un tipo permitido.`],
|
|
544
|
+
seeMore: true,
|
|
551
545
|
time: 10
|
|
552
546
|
});
|
|
553
547
|
return;
|
|
@@ -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",
|
|
@@ -628,7 +624,7 @@ var Attachment = ({
|
|
|
628
624
|
whiteSpace: "nowrap",
|
|
629
625
|
overflow: "hidden",
|
|
630
626
|
textOverflow: "ellipsis",
|
|
631
|
-
maxWidth: "
|
|
627
|
+
maxWidth: "450px"
|
|
632
628
|
},
|
|
633
629
|
error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
|
|
634
630
|
)),
|
|
@@ -673,11 +669,22 @@ 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(
|
|
677
684
|
import_material3.LinearProgress,
|
|
678
685
|
{
|
|
679
686
|
variant: "determinate",
|
|
680
|
-
color:
|
|
687
|
+
color: "primary",
|
|
681
688
|
value: file.progress
|
|
682
689
|
}
|
|
683
690
|
))),
|
|
@@ -702,14 +709,11 @@ var Attachment = ({
|
|
|
702
709
|
if (fileToDelete) {
|
|
703
710
|
deleteFiles(fileToDelete.name);
|
|
704
711
|
setFileToDelete(null);
|
|
705
|
-
setToast(
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
time: 2
|
|
711
|
-
});
|
|
712
|
-
}, 10);
|
|
712
|
+
setToast({
|
|
713
|
+
title: "Archivo eliminado",
|
|
714
|
+
type: "success",
|
|
715
|
+
time: 2
|
|
716
|
+
});
|
|
713
717
|
}
|
|
714
718
|
setOpenModal(false);
|
|
715
719
|
}
|