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.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: UploadedFile[] | File[]) => void;
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: <T>({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<T>) => React__default.JSX.Element;
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: UploadedFile[] | File[]) => void;
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: <T>({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<T>) => React__default.JSX.Element;
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
@@ -277,7 +277,6 @@ var SCModal = ({
277
277
  state = "info",
278
278
  open,
279
279
  setOpen,
280
- // ✅ ahora también puedes pasar setOpen desde afuera
281
280
  title,
282
281
  description,
283
282
  action
@@ -299,7 +298,7 @@ var SCModal = ({
299
298
  [action, handleClose]
300
299
  );
301
300
  const { icon, defaultDescription } = modalStateConfig[state];
302
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
301
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, buttonModal && /* @__PURE__ */ React3.createElement(
303
302
  Button2,
304
303
  {
305
304
  "data-testid": "test-buttonModal",
@@ -390,7 +389,7 @@ var Attachment = ({
390
389
  }) => {
391
390
  const [files, setFiles] = useState4([]);
392
391
  const [fileToDelete, setFileToDelete] = useState4(null);
393
- const [toast, setToast] = React4.useState(null);
392
+ const [toast, setToast] = useState4(null);
394
393
  const [openModal, setOpenModal] = useState4(false);
395
394
  const [isDragFile, setIsDragFile] = useState4(false);
396
395
  const inputRef = useRef(null);
@@ -416,7 +415,6 @@ var Attachment = ({
416
415
  useEffect4(() => {
417
416
  if (initialFiles.length > 0) {
418
417
  setFiles(initialFiles);
419
- onChange == null ? void 0 : onChange(initialFiles);
420
418
  }
421
419
  }, [initialFiles]);
422
420
  useEffect4(() => {
@@ -439,20 +437,18 @@ var Attachment = ({
439
437
  const newFiles = event2.target.files;
440
438
  if (!newFiles) return;
441
439
  const nuevosArchivos = [];
440
+ const archivosValidos = [];
442
441
  Array.from(newFiles).forEach((file) => {
443
442
  const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
444
443
  const sizeMB = file.size / (1024 * 1024);
445
444
  if (isDuplicatedFile !== -1) {
446
- setToast(null);
447
- setTimeout(() => {
448
- setToast({
449
- type: "error",
450
- title: "Archivo duplicado",
451
- seeMore: true,
452
- listITems: ["No se permiten archivos duplicados."],
453
- time: 10
454
- });
455
- }, 10);
445
+ setToast({
446
+ type: "error",
447
+ title: "Archivo duplicado",
448
+ listITems: ["No se permiten archivos duplicados."],
449
+ seeMore: true,
450
+ time: 10
451
+ });
456
452
  return;
457
453
  }
458
454
  if (sizeMB > maxSize) {
@@ -463,16 +459,13 @@ var Attachment = ({
463
459
  progress: 0,
464
460
  uploadError: true
465
461
  });
466
- setToast(null);
467
- setTimeout(() => {
468
- setToast({
469
- type: "error",
470
- title: "Carga fallida",
471
- seeMore: true,
472
- listITems: ["El archivo supera el l\xEDmite / 400MB."],
473
- time: 10
474
- });
475
- }, 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
+ });
476
469
  return;
477
470
  }
478
471
  if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
@@ -480,6 +473,7 @@ var Attachment = ({
480
473
  type: "error",
481
474
  title: "Tipo de archivo no permitido",
482
475
  listITems: [`El archivo ${file.name} no es un tipo permitido.`],
476
+ seeMore: true,
483
477
  time: 10
484
478
  });
485
479
  return;
@@ -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
- onChange == null ? void 0 : onChange(actualizados);
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
- onChange == null ? void 0 : onChange(filtered);
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",
@@ -560,7 +556,7 @@ var Attachment = ({
560
556
  whiteSpace: "nowrap",
561
557
  overflow: "hidden",
562
558
  textOverflow: "ellipsis",
563
- maxWidth: "210px"
559
+ maxWidth: "450px"
564
560
  },
565
561
  error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
566
562
  )),
@@ -605,11 +601,22 @@ 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(Typography3, { variant: "body2", color: "text.primary", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "210px" }, file.name), /* @__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} \u2022 carga ${file.progress}%`), file.progress === 100 && !file.uploadError ? null : /* @__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(
609
616
  LinearProgress2,
610
617
  {
611
618
  variant: "determinate",
612
- color: file.uploadError ? "error" : "primary",
619
+ color: "primary",
613
620
  value: file.progress
614
621
  }
615
622
  ))),
@@ -634,14 +641,11 @@ var Attachment = ({
634
641
  if (fileToDelete) {
635
642
  deleteFiles(fileToDelete.name);
636
643
  setFileToDelete(null);
637
- setToast(null);
638
- setTimeout(() => {
639
- setToast({
640
- title: "Archivo eliminado",
641
- type: "success",
642
- time: 2
643
- });
644
- }, 10);
644
+ setToast({
645
+ title: "Archivo eliminado",
646
+ type: "success",
647
+ time: 2
648
+ });
645
649
  }
646
650
  setOpenModal(false);
647
651
  }