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.d.cts
CHANGED
|
@@ -23,10 +23,12 @@ interface AdjuntarProps<T> {
|
|
|
23
23
|
fileAccepted?: string;
|
|
24
24
|
onChange?: (archivos: File[]) => void;
|
|
25
25
|
onLoading?: boolean;
|
|
26
|
-
downloadAction?: () => void;
|
|
26
|
+
downloadAction?: (name: string) => void;
|
|
27
|
+
deleteAction?: (name: string) => Promise<void> | void;
|
|
27
28
|
initialFiles?: UploadedFile[];
|
|
28
|
-
}
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, deleteAction, initialFiles, }: AdjuntarProps<any>) => React__default.JSX.Element;
|
|
30
32
|
|
|
31
33
|
type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
|
|
32
34
|
type ReplyTextPalette = "primary" | "secondary" | "disabled";
|
|
@@ -549,4 +551,4 @@ declare const SincoTheme: _mui_material_styles.Theme;
|
|
|
549
551
|
declare let AdproSincoTheme: _mui_material_styles.Theme;
|
|
550
552
|
declare let ADCSincoTheme: _mui_material_styles.Theme;
|
|
551
553
|
|
|
552
|
-
export { ADCSincoTheme,
|
|
554
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,10 +23,12 @@ interface AdjuntarProps<T> {
|
|
|
23
23
|
fileAccepted?: string;
|
|
24
24
|
onChange?: (archivos: File[]) => void;
|
|
25
25
|
onLoading?: boolean;
|
|
26
|
-
downloadAction?: () => void;
|
|
26
|
+
downloadAction?: (name: string) => void;
|
|
27
|
+
deleteAction?: (name: string) => Promise<void> | void;
|
|
27
28
|
initialFiles?: UploadedFile[];
|
|
28
|
-
}
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare const Attachment: ({ sx, compact, error, maxSize, fileAccepted, onLoading, onChange, downloadAction, deleteAction, initialFiles, }: AdjuntarProps<any>) => React__default.JSX.Element;
|
|
30
32
|
|
|
31
33
|
type ReplyPalette$1 = "primary" | "secondary" | "warning" | "info" | "success" | "error" | any;
|
|
32
34
|
type ReplyTextPalette = "primary" | "secondary" | "disabled";
|
|
@@ -549,4 +551,4 @@ declare const SincoTheme: _mui_material_styles.Theme;
|
|
|
549
551
|
declare let AdproSincoTheme: _mui_material_styles.Theme;
|
|
550
552
|
declare let ADCSincoTheme: _mui_material_styles.Theme;
|
|
551
553
|
|
|
552
|
-
export { ADCSincoTheme,
|
|
554
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,26 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
32
52
|
|
|
33
53
|
// src/Components/Adjuntar/Adjuntar.tsx
|
|
34
54
|
import React4, { useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
@@ -385,6 +405,7 @@ var Attachment = ({
|
|
|
385
405
|
onLoading,
|
|
386
406
|
onChange,
|
|
387
407
|
downloadAction,
|
|
408
|
+
deleteAction,
|
|
388
409
|
initialFiles = []
|
|
389
410
|
}) => {
|
|
390
411
|
const [files, setFiles] = useState4([]);
|
|
@@ -394,18 +415,21 @@ var Attachment = ({
|
|
|
394
415
|
const [isDragFile, setIsDragFile] = useState4(false);
|
|
395
416
|
const inputRef = useRef(null);
|
|
396
417
|
useEffect4(() => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
418
|
+
const interval = setInterval(() => {
|
|
419
|
+
setFiles((prevFiles) => {
|
|
420
|
+
let updated = false;
|
|
421
|
+
const nuevosArchivos = prevFiles.map((file) => {
|
|
422
|
+
if (!file.uploadError && file.progress < 100) {
|
|
423
|
+
updated = true;
|
|
424
|
+
return __spreadProps(__spreadValues({}, file), { progress: Math.min(file.progress + 15, 100) });
|
|
425
|
+
}
|
|
426
|
+
return file;
|
|
403
427
|
});
|
|
428
|
+
return updated ? nuevosArchivos : prevFiles;
|
|
404
429
|
});
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}, []);
|
|
430
|
+
}, 1e3);
|
|
431
|
+
return () => clearInterval(interval);
|
|
432
|
+
}, [files]);
|
|
409
433
|
const handleDrop = (event2) => {
|
|
410
434
|
event2.preventDefault();
|
|
411
435
|
setIsDragFile(false);
|
|
@@ -670,7 +694,7 @@ var Attachment = ({
|
|
|
670
694
|
},
|
|
671
695
|
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
696
|
))),
|
|
673
|
-
/* @__PURE__ */ React4.createElement(Tooltip, { title: "Descargar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: downloadAction }, /* @__PURE__ */ React4.createElement(FileDownload, { fontSize: "small", color: "action" }))),
|
|
697
|
+
/* @__PURE__ */ React4.createElement(Tooltip, { title: "Descargar" }, /* @__PURE__ */ React4.createElement(IconButton3, { size: "small", onClick: () => downloadAction == null ? void 0 : downloadAction(file.name) }, /* @__PURE__ */ React4.createElement(FileDownload, { fontSize: "small", color: "action" }))),
|
|
674
698
|
/* @__PURE__ */ React4.createElement(Tooltip, { title: "Eliminar" }, /* @__PURE__ */ React4.createElement(
|
|
675
699
|
IconButton3,
|
|
676
700
|
{
|
|
@@ -694,18 +718,30 @@ var Attachment = ({
|
|
|
694
718
|
action: [
|
|
695
719
|
{
|
|
696
720
|
text: "Eliminar",
|
|
697
|
-
fn: () => {
|
|
721
|
+
fn: () => __async(void 0, null, function* () {
|
|
698
722
|
if (fileToDelete) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
723
|
+
try {
|
|
724
|
+
if (deleteAction) {
|
|
725
|
+
yield deleteAction(fileToDelete.name);
|
|
726
|
+
}
|
|
727
|
+
deleteFiles(fileToDelete.name);
|
|
728
|
+
setToast({
|
|
729
|
+
title: "Archivo eliminado",
|
|
730
|
+
type: "success",
|
|
731
|
+
time: 2
|
|
732
|
+
});
|
|
733
|
+
} catch (error2) {
|
|
734
|
+
setToast({
|
|
735
|
+
title: "Error al eliminar archivo",
|
|
736
|
+
type: "error",
|
|
737
|
+
time: 4
|
|
738
|
+
});
|
|
739
|
+
} finally {
|
|
740
|
+
setFileToDelete(null);
|
|
741
|
+
setOpenModal(false);
|
|
742
|
+
}
|
|
706
743
|
}
|
|
707
|
-
|
|
708
|
-
}
|
|
744
|
+
})
|
|
709
745
|
}
|
|
710
746
|
]
|
|
711
747
|
}
|