componentes-sinco 1.0.20 → 1.0.22
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 +57 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +57 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,6 +55,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
55
55
|
mod
|
|
56
56
|
));
|
|
57
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
58
78
|
|
|
59
79
|
// src/index.ts
|
|
60
80
|
var src_exports = {};
|
|
@@ -453,6 +473,7 @@ var Attachment = ({
|
|
|
453
473
|
onLoading,
|
|
454
474
|
onChange,
|
|
455
475
|
downloadAction,
|
|
476
|
+
deleteAction,
|
|
456
477
|
initialFiles = []
|
|
457
478
|
}) => {
|
|
458
479
|
const [files, setFiles] = (0, import_react5.useState)([]);
|
|
@@ -462,18 +483,21 @@ var Attachment = ({
|
|
|
462
483
|
const [isDragFile, setIsDragFile] = (0, import_react5.useState)(false);
|
|
463
484
|
const inputRef = (0, import_react5.useRef)(null);
|
|
464
485
|
(0, import_react5.useEffect)(() => {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
486
|
+
const interval = setInterval(() => {
|
|
487
|
+
setFiles((prevFiles) => {
|
|
488
|
+
let updated = false;
|
|
489
|
+
const nuevosArchivos = prevFiles.map((file) => {
|
|
490
|
+
if (!file.uploadError && file.progress < 100) {
|
|
491
|
+
updated = true;
|
|
492
|
+
return __spreadProps(__spreadValues({}, file), { progress: Math.min(file.progress + 15, 100) });
|
|
493
|
+
}
|
|
494
|
+
return file;
|
|
471
495
|
});
|
|
496
|
+
return updated ? nuevosArchivos : prevFiles;
|
|
472
497
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}, []);
|
|
498
|
+
}, 1e3);
|
|
499
|
+
return () => clearInterval(interval);
|
|
500
|
+
}, [files]);
|
|
477
501
|
const handleDrop = (event2) => {
|
|
478
502
|
event2.preventDefault();
|
|
479
503
|
setIsDragFile(false);
|
|
@@ -738,7 +762,7 @@ var Attachment = ({
|
|
|
738
762
|
},
|
|
739
763
|
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}`
|
|
740
764
|
))),
|
|
741
|
-
/* @__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" }))),
|
|
765
|
+
/* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Descargar" }, /* @__PURE__ */ import_react5.default.createElement(import_material3.IconButton, { size: "small", onClick: () => downloadAction == null ? void 0 : downloadAction(file.name) }, /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.FileDownload, { fontSize: "small", color: "action" }))),
|
|
742
766
|
/* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(
|
|
743
767
|
import_material3.IconButton,
|
|
744
768
|
{
|
|
@@ -762,18 +786,30 @@ var Attachment = ({
|
|
|
762
786
|
action: [
|
|
763
787
|
{
|
|
764
788
|
text: "Eliminar",
|
|
765
|
-
fn: () => {
|
|
789
|
+
fn: () => __async(void 0, null, function* () {
|
|
766
790
|
if (fileToDelete) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
791
|
+
try {
|
|
792
|
+
if (deleteAction) {
|
|
793
|
+
yield deleteAction(fileToDelete.name);
|
|
794
|
+
}
|
|
795
|
+
deleteFiles(fileToDelete.name);
|
|
796
|
+
setToast({
|
|
797
|
+
title: "Archivo eliminado",
|
|
798
|
+
type: "success",
|
|
799
|
+
time: 2
|
|
800
|
+
});
|
|
801
|
+
} catch (error2) {
|
|
802
|
+
setToast({
|
|
803
|
+
title: "Error al eliminar archivo",
|
|
804
|
+
type: "error",
|
|
805
|
+
time: 4
|
|
806
|
+
});
|
|
807
|
+
} finally {
|
|
808
|
+
setFileToDelete(null);
|
|
809
|
+
setOpenModal(false);
|
|
810
|
+
}
|
|
774
811
|
}
|
|
775
|
-
|
|
776
|
-
}
|
|
812
|
+
})
|
|
777
813
|
}
|
|
778
814
|
]
|
|
779
815
|
}
|