componentes-sinco 1.0.17 → 1.0.18

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 CHANGED
@@ -461,25 +461,6 @@ var Attachment = ({
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);
464
- const handleDrop = (event2) => {
465
- event2.preventDefault();
466
- setIsDragFile(false);
467
- const filesDropped = event2.dataTransfer.files;
468
- if (filesDropped && filesDropped.length > 0) {
469
- const fakeEvent = {
470
- target: { files: filesDropped }
471
- };
472
- handleUpload(fakeEvent);
473
- }
474
- };
475
- const handleDragOver = (event2) => {
476
- event2.preventDefault();
477
- setIsDragFile(true);
478
- };
479
- const handleDragLeave = (event2) => {
480
- event2.preventDefault();
481
- setIsDragFile(false);
482
- };
483
464
  (0, import_react5.useEffect)(() => {
484
465
  if (initialFiles.length > 0) {
485
466
  setFiles(initialFiles);
@@ -500,14 +481,35 @@ var Attachment = ({
500
481
  });
501
482
  }, 1e3);
502
483
  return () => clearInterval(interval);
503
- }, [files]);
484
+ }, []);
485
+ const handleDrop = (event2) => {
486
+ event2.preventDefault();
487
+ setIsDragFile(false);
488
+ const filesDropped = event2.dataTransfer.files;
489
+ if (filesDropped && filesDropped.length > 0) {
490
+ const fakeEvent = {
491
+ target: { files: filesDropped }
492
+ };
493
+ handleUpload(fakeEvent);
494
+ }
495
+ };
496
+ const handleDragOver = (event2) => {
497
+ event2.preventDefault();
498
+ setIsDragFile(true);
499
+ };
500
+ const handleDragLeave = (event2) => {
501
+ event2.preventDefault();
502
+ setIsDragFile(false);
503
+ };
504
504
  const handleUpload = (event2) => {
505
505
  const newFiles = event2.target.files;
506
506
  if (!newFiles) return;
507
507
  const nuevosArchivos = [];
508
508
  const archivosValidos = [];
509
509
  Array.from(newFiles).forEach((file) => {
510
- const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
510
+ const isDuplicatedFile = files.findIndex(
511
+ (e) => e.name === file.name && e.size === file.size
512
+ );
511
513
  const sizeMB = file.size / (1024 * 1024);
512
514
  if (isDuplicatedFile !== -1) {
513
515
  setToast({
@@ -536,7 +538,12 @@ var Attachment = ({
536
538
  });
537
539
  return;
538
540
  }
539
- if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
541
+ if (fileAccepted && !file.name.match(
542
+ new RegExp(
543
+ `(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`,
544
+ "i"
545
+ )
546
+ )) {
540
547
  setToast({
541
548
  type: "error",
542
549
  title: "Tipo de archivo no permitido",
@@ -558,18 +565,23 @@ var Attachment = ({
558
565
  if (nuevosArchivos.length > 0) {
559
566
  setFiles((prev) => {
560
567
  const actualizados = [...prev, ...nuevosArchivos];
561
- const totalFiles = [...onChange ? archivosValidos : []];
562
- onChange == null ? void 0 : onChange(totalFiles);
568
+ onChange == null ? void 0 : onChange([
569
+ ...archivosValidos,
570
+ ...prev.map((f) => new File([], f.name, { type: f.type }))
571
+ ]);
563
572
  return actualizados;
564
573
  });
565
574
  }
566
575
  event2.target.value = "";
567
576
  };
568
577
  const deleteFiles = (nameFile) => {
569
- const filtered = files.filter((e) => e.name !== nameFile);
570
- setFiles(filtered);
571
- const remainingFiles = filtered.map((f) => new File([], f.name, { type: f.type }));
572
- onChange == null ? void 0 : onChange(remainingFiles);
578
+ setFiles((prev) => {
579
+ const filtered = prev.filter((e) => e.name !== nameFile);
580
+ onChange == null ? void 0 : onChange(
581
+ filtered.map((f) => new File([], f.name, { type: f.type }))
582
+ );
583
+ return filtered;
584
+ });
573
585
  };
574
586
  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(
575
587
  "input",
@@ -607,7 +619,38 @@ var Attachment = ({
607
619
  }
608
620
  }, sx)
609
621
  },
610
- onLoading ? /* @__PURE__ */ import_react5.default.createElement(import_material3.Box, { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "450px" }, /* @__PURE__ */ import_react5.default.createElement(import_material3.CircularProgress, { sx: { width: "60px", height: "60px" }, variant: "indeterminate" })) : /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_material3.Box, { display: "flex", bgcolor: error ? "error.50" : "primary.50", borderRadius: "100%", p: 1 }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.CloudUploadOutlined, { color: error ? "error" : "primary", fontSize: "medium" })), /* @__PURE__ */ import_react5.default.createElement(
622
+ onLoading ? /* @__PURE__ */ import_react5.default.createElement(
623
+ import_material3.Box,
624
+ {
625
+ display: "flex",
626
+ alignItems: "center",
627
+ justifyContent: "center",
628
+ width: "100%",
629
+ height: "450px"
630
+ },
631
+ /* @__PURE__ */ import_react5.default.createElement(
632
+ import_material3.CircularProgress,
633
+ {
634
+ sx: { width: "60px", height: "60px" },
635
+ variant: "indeterminate"
636
+ }
637
+ )
638
+ ) : /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(
639
+ import_material3.Box,
640
+ {
641
+ display: "flex",
642
+ bgcolor: error ? "error.50" : "primary.50",
643
+ borderRadius: "100%",
644
+ p: 1
645
+ },
646
+ /* @__PURE__ */ import_react5.default.createElement(
647
+ import_icons_material5.CloudUploadOutlined,
648
+ {
649
+ color: error ? "error" : "primary",
650
+ fontSize: "medium"
651
+ }
652
+ )
653
+ ), /* @__PURE__ */ import_react5.default.createElement(
611
654
  import_material3.Stack,
612
655
  {
613
656
  width: "100%",
@@ -616,18 +659,27 @@ var Attachment = ({
616
659
  justifyContent: compact ? "space-between" : "center",
617
660
  gap: 1
618
661
  },
619
- /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { flexDirection: "column", alignItems: compact ? "start" : "center", gap: 0.5 }, /* @__PURE__ */ import_react5.default.createElement(import_material3.Typography, { variant: "body2", color: "text.primary" }, "Arrastrar o adjuntar archivos"), /* @__PURE__ */ import_react5.default.createElement(
620
- import_material3.Typography,
662
+ /* @__PURE__ */ import_react5.default.createElement(
663
+ import_material3.Stack,
621
664
  {
622
- variant: "caption",
623
- color: error ? "error" : "text.secondary",
624
- whiteSpace: "nowrap",
625
- overflow: "hidden",
626
- textOverflow: "ellipsis",
627
- maxWidth: "450px"
665
+ flexDirection: "column",
666
+ alignItems: compact ? "start" : "center",
667
+ gap: 0.5
628
668
  },
629
- error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
630
- )),
669
+ /* @__PURE__ */ import_react5.default.createElement(import_material3.Typography, { variant: "body2", color: "text.primary" }, "Arrastrar o adjuntar archivos"),
670
+ /* @__PURE__ */ import_react5.default.createElement(
671
+ import_material3.Typography,
672
+ {
673
+ variant: "caption",
674
+ color: error ? "error" : "text.secondary",
675
+ whiteSpace: "nowrap",
676
+ overflow: "hidden",
677
+ textOverflow: "ellipsis",
678
+ maxWidth: "450px"
679
+ },
680
+ error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
681
+ )
682
+ ),
631
683
  /* @__PURE__ */ import_react5.default.createElement(
632
684
  import_material3.Button,
633
685
  {
@@ -669,7 +721,13 @@ var Attachment = ({
669
721
  }
670
722
  }
671
723
  },
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(
724
+ /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(
725
+ import_icons_material5.UploadFileOutlined,
726
+ {
727
+ color: file.uploadError ? "error" : "primary",
728
+ fontSize: "small"
729
+ }
730
+ ), /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { width: "100%" }, /* @__PURE__ */ import_react5.default.createElement(
673
731
  import_material3.Typography,
674
732
  {
675
733
  variant: "body2",
@@ -677,15 +735,29 @@ var Attachment = ({
677
735
  whiteSpace: "nowrap",
678
736
  overflow: "hidden",
679
737
  textOverflow: "ellipsis",
680
- maxWidth: "210px"
738
+ maxWidth: "310px"
681
739
  },
682
740
  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}`))),
741
+ ), /* @__PURE__ */ import_react5.default.createElement(
742
+ import_material3.Typography,
743
+ {
744
+ variant: "caption",
745
+ color: file.uploadError ? "error" : "text.secondary"
746
+ },
747
+ 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}`
748
+ ))),
684
749
  /* @__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" }))),
685
- /* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(import_material3.IconButton, { size: "small", onClick: () => {
686
- setFileToDelete(file);
687
- setOpenModal(true);
688
- } }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.DeleteOutline, { fontSize: "small", color: "action" })))
750
+ /* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(
751
+ import_material3.IconButton,
752
+ {
753
+ size: "small",
754
+ onClick: () => {
755
+ setFileToDelete(file);
756
+ setOpenModal(true);
757
+ }
758
+ },
759
+ /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.DeleteOutline, { fontSize: "small", color: "action" })
760
+ ))
689
761
  ))
690
762
  ), /* @__PURE__ */ import_react5.default.createElement(
691
763
  SCModal,