componentes-sinco 1.0.17 → 1.0.19

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
@@ -25,9 +25,8 @@ interface AdjuntarProps<T> {
25
25
  onLoading?: boolean;
26
26
  downloadAction?: () => void;
27
27
  initialFiles?: UploadedFile[];
28
- }
29
-
30
- declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<any>) => React__default.JSX.Element;
28
+ }
29
+ declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles, }: AdjuntarProps<any>) => React__default.JSX.Element;
31
30
 
32
31
  type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
33
32
  type ReplyTextPalette = "primary" | "secondary" | "disabled";
@@ -550,4 +549,4 @@ declare const SincoTheme: _mui_material_styles.Theme;
550
549
  declare let AdproSincoTheme: _mui_material_styles.Theme;
551
550
  declare let ADCSincoTheme: _mui_material_styles.Theme;
552
551
 
553
- export { ADCSincoTheme, AdproSincoTheme, Attachment, Calendar, type CalendarEvent, type CalendarProps, type CalendarView, EmptyState, type EmptyStateProperties, type EmptyStateSize, type EmptyStateStates, FooterAction, type FooterActionsProperties, type ModalProps, type ModalStates, MultiSelect, type MultiSelectProps, PageHeader, type PageheaderProperties, type ReplyPalette$1 as ReplyPalette, type ReplyTextPalette, type ReplyVariants, type RepplyButtonVariants, SCAutocomplete, SCCalendarSwipeable, SCCard, SCDataGrid, SCDataGridInitial, SCDateRange, SCDialog, SCDrawer, SCMenu, SCModal, SCSelect, SCTabs, SCTextArea, type SCTextAreaProps, SCTextField, type SCTextFieldProps, SCTime, SCToastNotification, SincoTheme, type ToastBaseProperties, ToastProgress, type ToastType, capitalize, getButtonColor, getIcon, getIconComponent, getIconMultiSelect, getModalColor, modalStateConfig, useFilteredItems, useMultiSelectHandlers, useProgress };
552
+ export { ADCSincoTheme, type AdjuntarProps, AdproSincoTheme, Attachment, Calendar, type CalendarEvent, type CalendarProps, type CalendarView, EmptyState, type EmptyStateProperties, type EmptyStateSize, type EmptyStateStates, FooterAction, type FooterActionsProperties, type ModalProps, type ModalStates, MultiSelect, type MultiSelectProps, PageHeader, type PageheaderProperties, type ReplyPalette$1 as ReplyPalette, type ReplyTextPalette, type ReplyVariants, type RepplyButtonVariants, SCAutocomplete, SCCalendarSwipeable, SCCard, SCDataGrid, SCDataGridInitial, SCDateRange, SCDialog, SCDrawer, SCMenu, SCModal, SCSelect, SCTabs, SCTextArea, type SCTextAreaProps, SCTextField, type SCTextFieldProps, SCTime, SCToastNotification, SincoTheme, type ToastBaseProperties, ToastProgress, type ToastType, type UploadedFile, capitalize, getButtonColor, getIcon, getIconComponent, getIconMultiSelect, getModalColor, modalStateConfig, useFilteredItems, useMultiSelectHandlers, useProgress };
package/dist/index.d.ts CHANGED
@@ -25,9 +25,8 @@ interface AdjuntarProps<T> {
25
25
  onLoading?: boolean;
26
26
  downloadAction?: () => void;
27
27
  initialFiles?: UploadedFile[];
28
- }
29
-
30
- declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles }: AdjuntarProps<any>) => React__default.JSX.Element;
28
+ }
29
+ declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, initialFiles, }: AdjuntarProps<any>) => React__default.JSX.Element;
31
30
 
32
31
  type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
33
32
  type ReplyTextPalette = "primary" | "secondary" | "disabled";
@@ -550,4 +549,4 @@ declare const SincoTheme: _mui_material_styles.Theme;
550
549
  declare let AdproSincoTheme: _mui_material_styles.Theme;
551
550
  declare let ADCSincoTheme: _mui_material_styles.Theme;
552
551
 
553
- export { ADCSincoTheme, AdproSincoTheme, Attachment, Calendar, type CalendarEvent, type CalendarProps, type CalendarView, EmptyState, type EmptyStateProperties, type EmptyStateSize, type EmptyStateStates, FooterAction, type FooterActionsProperties, type ModalProps, type ModalStates, MultiSelect, type MultiSelectProps, PageHeader, type PageheaderProperties, type ReplyPalette$1 as ReplyPalette, type ReplyTextPalette, type ReplyVariants, type RepplyButtonVariants, SCAutocomplete, SCCalendarSwipeable, SCCard, SCDataGrid, SCDataGridInitial, SCDateRange, SCDialog, SCDrawer, SCMenu, SCModal, SCSelect, SCTabs, SCTextArea, type SCTextAreaProps, SCTextField, type SCTextFieldProps, SCTime, SCToastNotification, SincoTheme, type ToastBaseProperties, ToastProgress, type ToastType, capitalize, getButtonColor, getIcon, getIconComponent, getIconMultiSelect, getModalColor, modalStateConfig, useFilteredItems, useMultiSelectHandlers, useProgress };
552
+ export { ADCSincoTheme, type AdjuntarProps, AdproSincoTheme, Attachment, Calendar, type CalendarEvent, type CalendarProps, type CalendarView, EmptyState, type EmptyStateProperties, type EmptyStateSize, type EmptyStateStates, FooterAction, type FooterActionsProperties, type ModalProps, type ModalStates, MultiSelect, type MultiSelectProps, PageHeader, type PageheaderProperties, type ReplyPalette$1 as ReplyPalette, type ReplyTextPalette, type ReplyVariants, type RepplyButtonVariants, SCAutocomplete, SCCalendarSwipeable, SCCard, SCDataGrid, SCDataGridInitial, SCDateRange, SCDialog, SCDrawer, SCMenu, SCModal, SCSelect, SCTabs, SCTextArea, type SCTextAreaProps, SCTextField, type SCTextFieldProps, SCTime, SCToastNotification, SincoTheme, type ToastBaseProperties, ToastProgress, type ToastType, type UploadedFile, capitalize, getButtonColor, getIcon, getIconComponent, getIconMultiSelect, getModalColor, modalStateConfig, useFilteredItems, useMultiSelectHandlers, useProgress };
package/dist/index.js CHANGED
@@ -393,6 +393,19 @@ var Attachment = ({
393
393
  const [openModal, setOpenModal] = useState4(false);
394
394
  const [isDragFile, setIsDragFile] = useState4(false);
395
395
  const inputRef = useRef(null);
396
+ useEffect4(() => {
397
+ if (initialFiles.length > 0) {
398
+ const initials = initialFiles.map((f) => {
399
+ var _a, _b;
400
+ return __spreadProps(__spreadValues({}, f), {
401
+ progress: (_a = f.progress) != null ? _a : 100,
402
+ uploadError: (_b = f.uploadError) != null ? _b : false
403
+ });
404
+ });
405
+ setFiles(initials);
406
+ onChange == null ? void 0 : onChange(initials.map((f) => new File([], f.name, { type: f.type })));
407
+ }
408
+ }, []);
396
409
  const handleDrop = (event2) => {
397
410
  event2.preventDefault();
398
411
  setIsDragFile(false);
@@ -412,34 +425,15 @@ var Attachment = ({
412
425
  event2.preventDefault();
413
426
  setIsDragFile(false);
414
427
  };
415
- useEffect4(() => {
416
- if (initialFiles.length > 0) {
417
- setFiles(initialFiles);
418
- }
419
- }, [initialFiles]);
420
- useEffect4(() => {
421
- const interval = setInterval(() => {
422
- setFiles((prevFiles) => {
423
- let updated = false;
424
- const nuevosArchivos = prevFiles.map((file) => {
425
- if (!file.uploadError && file.progress < 100) {
426
- updated = true;
427
- return __spreadProps(__spreadValues({}, file), { progress: Math.min(file.progress + 15, 100) });
428
- }
429
- return file;
430
- });
431
- return updated ? nuevosArchivos : prevFiles;
432
- });
433
- }, 1e3);
434
- return () => clearInterval(interval);
435
- }, [files]);
436
428
  const handleUpload = (event2) => {
437
429
  const newFiles = event2.target.files;
438
430
  if (!newFiles) return;
439
431
  const nuevosArchivos = [];
440
432
  const archivosValidos = [];
441
433
  Array.from(newFiles).forEach((file) => {
442
- const isDuplicatedFile = files.findIndex((e) => e.name === file.name && e.size === file.size);
434
+ const isDuplicatedFile = files.findIndex(
435
+ (e) => e.name === file.name && e.size === file.size
436
+ );
443
437
  const sizeMB = file.size / (1024 * 1024);
444
438
  if (isDuplicatedFile !== -1) {
445
439
  setToast({
@@ -468,7 +462,12 @@ var Attachment = ({
468
462
  });
469
463
  return;
470
464
  }
471
- if (fileAccepted && !file.name.match(new RegExp(`(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`, "i"))) {
465
+ if (fileAccepted && !file.name.match(
466
+ new RegExp(
467
+ `(${fileAccepted.replace(/\./g, "\\.").replace(/,/g, "|")})$`,
468
+ "i"
469
+ )
470
+ )) {
472
471
  setToast({
473
472
  type: "error",
474
473
  title: "Tipo de archivo no permitido",
@@ -490,18 +489,23 @@ var Attachment = ({
490
489
  if (nuevosArchivos.length > 0) {
491
490
  setFiles((prev) => {
492
491
  const actualizados = [...prev, ...nuevosArchivos];
493
- const totalFiles = [...onChange ? archivosValidos : []];
494
- onChange == null ? void 0 : onChange(totalFiles);
492
+ onChange == null ? void 0 : onChange([
493
+ ...archivosValidos,
494
+ ...prev.map((f) => new File([], f.name, { type: f.type }))
495
+ ]);
495
496
  return actualizados;
496
497
  });
497
498
  }
498
499
  event2.target.value = "";
499
500
  };
500
501
  const deleteFiles = (nameFile) => {
501
- const filtered = files.filter((e) => e.name !== nameFile);
502
- setFiles(filtered);
503
- const remainingFiles = filtered.map((f) => new File([], f.name, { type: f.type }));
504
- onChange == null ? void 0 : onChange(remainingFiles);
502
+ setFiles((prev) => {
503
+ const filtered = prev.filter((e) => e.name !== nameFile);
504
+ onChange == null ? void 0 : onChange(
505
+ filtered.map((f) => new File([], f.name, { type: f.type }))
506
+ );
507
+ return filtered;
508
+ });
505
509
  };
506
510
  return /* @__PURE__ */ React4.createElement(Stack3, { spacing: 2 }, toast && /* @__PURE__ */ React4.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ React4.createElement(
507
511
  "input",
@@ -539,7 +543,38 @@ var Attachment = ({
539
543
  }
540
544
  }, sx)
541
545
  },
542
- onLoading ? /* @__PURE__ */ React4.createElement(Box3, { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "450px" }, /* @__PURE__ */ React4.createElement(CircularProgress, { sx: { width: "60px", height: "60px" }, variant: "indeterminate" })) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Box3, { display: "flex", bgcolor: error ? "error.50" : "primary.50", borderRadius: "100%", p: 1 }, /* @__PURE__ */ React4.createElement(CloudUploadOutlined, { color: error ? "error" : "primary", fontSize: "medium" })), /* @__PURE__ */ React4.createElement(
546
+ onLoading ? /* @__PURE__ */ React4.createElement(
547
+ Box3,
548
+ {
549
+ display: "flex",
550
+ alignItems: "center",
551
+ justifyContent: "center",
552
+ width: "100%",
553
+ height: "450px"
554
+ },
555
+ /* @__PURE__ */ React4.createElement(
556
+ CircularProgress,
557
+ {
558
+ sx: { width: "60px", height: "60px" },
559
+ variant: "indeterminate"
560
+ }
561
+ )
562
+ ) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
563
+ Box3,
564
+ {
565
+ display: "flex",
566
+ bgcolor: error ? "error.50" : "primary.50",
567
+ borderRadius: "100%",
568
+ p: 1
569
+ },
570
+ /* @__PURE__ */ React4.createElement(
571
+ CloudUploadOutlined,
572
+ {
573
+ color: error ? "error" : "primary",
574
+ fontSize: "medium"
575
+ }
576
+ )
577
+ ), /* @__PURE__ */ React4.createElement(
543
578
  Stack3,
544
579
  {
545
580
  width: "100%",
@@ -548,18 +583,27 @@ var Attachment = ({
548
583
  justifyContent: compact ? "space-between" : "center",
549
584
  gap: 1
550
585
  },
551
- /* @__PURE__ */ React4.createElement(Stack3, { flexDirection: "column", alignItems: compact ? "start" : "center", gap: 0.5 }, /* @__PURE__ */ React4.createElement(Typography3, { variant: "body2", color: "text.primary" }, "Arrastrar o adjuntar archivos"), /* @__PURE__ */ React4.createElement(
552
- Typography3,
586
+ /* @__PURE__ */ React4.createElement(
587
+ Stack3,
553
588
  {
554
- variant: "caption",
555
- color: error ? "error" : "text.secondary",
556
- whiteSpace: "nowrap",
557
- overflow: "hidden",
558
- textOverflow: "ellipsis",
559
- maxWidth: "450px"
589
+ flexDirection: "column",
590
+ alignItems: compact ? "start" : "center",
591
+ gap: 0.5
560
592
  },
561
- error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
562
- )),
593
+ /* @__PURE__ */ React4.createElement(Typography3, { variant: "body2", color: "text.primary" }, "Arrastrar o adjuntar archivos"),
594
+ /* @__PURE__ */ React4.createElement(
595
+ Typography3,
596
+ {
597
+ variant: "caption",
598
+ color: error ? "error" : "text.secondary",
599
+ whiteSpace: "nowrap",
600
+ overflow: "hidden",
601
+ textOverflow: "ellipsis",
602
+ maxWidth: "450px"
603
+ },
604
+ error ? `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Archivo no soportado` : `${fileAccepted || "DOCX, XML, PNG, JPG"} \u2022 Max. ${maxSize}MB`
605
+ )
606
+ ),
563
607
  /* @__PURE__ */ React4.createElement(
564
608
  Button3,
565
609
  {
@@ -601,7 +645,13 @@ var Attachment = ({
601
645
  }
602
646
  }
603
647
  },
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(
648
+ /* @__PURE__ */ React4.createElement(Stack3, { direction: "row", alignItems: "center", gap: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(
649
+ UploadFileOutlined,
650
+ {
651
+ color: file.uploadError ? "error" : "primary",
652
+ fontSize: "small"
653
+ }
654
+ ), /* @__PURE__ */ React4.createElement(Stack3, { width: "100%" }, /* @__PURE__ */ React4.createElement(
605
655
  Typography3,
606
656
  {
607
657
  variant: "body2",
@@ -609,15 +659,29 @@ var Attachment = ({
609
659
  whiteSpace: "nowrap",
610
660
  overflow: "hidden",
611
661
  textOverflow: "ellipsis",
612
- maxWidth: "210px"
662
+ maxWidth: "310px"
613
663
  },
614
664
  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}`))),
665
+ ), /* @__PURE__ */ React4.createElement(
666
+ Typography3,
667
+ {
668
+ variant: "caption",
669
+ color: file.uploadError ? "error" : "text.secondary"
670
+ },
671
+ 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}`
672
+ ))),
616
673
  /* @__PURE__ */ React4.createElement(Tooltip, { title: "Descargar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: downloadAction }, /* @__PURE__ */ React4.createElement(FileDownload, { fontSize: "small", color: "action" }))),
617
- /* @__PURE__ */ React4.createElement(Tooltip, { title: "Eliminar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: () => {
618
- setFileToDelete(file);
619
- setOpenModal(true);
620
- } }, /* @__PURE__ */ React4.createElement(DeleteOutline, { fontSize: "small", color: "action" })))
674
+ /* @__PURE__ */ React4.createElement(Tooltip, { title: "Eliminar" }, /* @__PURE__ */ React4.createElement(
675
+ IconButton3,
676
+ {
677
+ size: "small",
678
+ onClick: () => {
679
+ setFileToDelete(file);
680
+ setOpenModal(true);
681
+ }
682
+ },
683
+ /* @__PURE__ */ React4.createElement(DeleteOutline, { fontSize: "small", color: "action" })
684
+ ))
621
685
  ))
622
686
  ), /* @__PURE__ */ React4.createElement(
623
687
  SCModal,