@m4l/components 9.2.28 → 9.2.29

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.
Files changed (47) hide show
  1. package/@types/types.d.ts +8 -0
  2. package/components/MFIsolationApp/MFIsolationApp.js +4 -4
  3. package/components/hook-form/RHFTimePicker/slots/RHFTimePickerEnum.d.ts +4 -1
  4. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.d.ts +7 -0
  5. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +74 -0
  6. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.styles.d.ts +2 -0
  7. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.styles.js +147 -0
  8. package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.d.ts +23 -0
  9. package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.js +34 -0
  10. package/components/hook-form/RHFUpload/RHFUploadSingleFile/dictionary.d.ts +15 -0
  11. package/components/hook-form/RHFUpload/RHFUploadSingleFile/dictionary.js +15 -0
  12. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/formatFileSize.d.ts +6 -0
  13. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/formatFileSize.js +16 -0
  14. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/getReadableFileType.d.ts +6 -0
  15. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/getReadableFileType.js +55 -0
  16. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/uploadReducer.d.ts +5 -0
  17. package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/uploadReducer.js +17 -0
  18. package/components/hook-form/RHFUpload/RHFUploadSingleFile/index.d.ts +1 -0
  19. package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileEnum.d.ts +22 -0
  20. package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileEnum.js +26 -0
  21. package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +60 -0
  22. package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.js +110 -0
  23. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/BlockContent.d.ts +5 -0
  24. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/BlockContent.js +77 -0
  25. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/types.d.ts +5 -0
  26. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.d.ts +5 -0
  27. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.js +36 -0
  28. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/types.d.ts +6 -0
  29. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.d.ts +5 -0
  30. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js +89 -0
  31. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/types.d.ts +38 -0
  32. package/components/hook-form/RHFUpload/RHFUploadSingleFile/test/RHFUploadsinglefile.test.d.ts +1 -0
  33. package/components/hook-form/RHFUpload/RHFUploadSingleFile/types.d.ts +42 -0
  34. package/components/hook-form/index.d.ts +1 -1
  35. package/components/mui_extended/Button/ButtonStyles.js +88 -59
  36. package/components/mui_extended/LinearProgress/index.js +1 -1
  37. package/index.js +2 -2
  38. package/package.json +1 -1
  39. package/storybook/hook-form/RHFUploadSingleFile/RHFUploadSingleFile.stories.d.ts +11 -0
  40. package/components/MFIsolationApp/constants.js +0 -4
  41. package/components/hook-form/RHFUpload/RHFUploadFile/components/UploadSingleFile/index.d.ts +0 -13
  42. package/components/hook-form/RHFUpload/RHFUploadFile/components/UploadSingleFile/index.js +0 -84
  43. package/components/hook-form/RHFUpload/RHFUploadFile/index.d.ts +0 -9
  44. package/components/hook-form/RHFUpload/RHFUploadFile/index.js +0 -31
  45. package/components/hook-form/RHFUpload/components/UploadComponents/BlockContent.js +0 -36
  46. package/components/hook-form/RHFUpload/components/UploadComponents/RejectionFiles.js +0 -31
  47. package/storybook/hook-form/RHFUploadImage/RHFUploadFile.stories.d.ts +0 -6
package/@types/types.d.ts CHANGED
@@ -141,6 +141,7 @@ import { AreasViewerOwnerState, AreasViewerType } from '../components/areas/comp
141
141
  import { TimePickerOwnerState,TimePickerSlotsType } from '../components/mui_extended/TimePicker/types';
142
142
  import { DataGridOwnerState, DataGridSlotsType } from '../components/DataGrid/types';
143
143
  import { DynamicFilterAndSortOwnerState, DynamicFilterAndSortSlotsType } from '../hooks/useDynamicFilterAndSort/types';
144
+ import { RHFUploadSingleFileOwnerState, RHFUploadSingleFileSlotsType } from '../components/hook-form/RHFUpload/RHFUploadSingleFile/types';
144
145
  import { ChipStatusFormatterSlotsType } from '../components/formatters/ChipStatusFormatter/types';
145
146
  import { PrintingSystemOwnerState, PrintingSystemSlotsType } from '../components/PrintingSystem/types';
146
147
 
@@ -216,6 +217,7 @@ declare module '@mui/material/styles' {
216
217
  M4LTimePicker: TimePickerSlotsType
217
218
  M4LDataGrid: DataGridSlotsType;
218
219
  M4LDynamicFilterAndSort: DynamicFilterAndSortSlotsType;
220
+ M4LRHFUploadSingleFile: RHFUploadSingleFileSlotsType;
219
221
  M4LChipStatusFormatter: ChipStatusFormatterSlotsType;
220
222
  M4LPrintingSystem: PrintingSystemSlotsType;
221
223
  }
@@ -290,6 +292,7 @@ declare module '@mui/material/styles' {
290
292
  M4LTimePicker: Partial<TimePickerOwnerState>;
291
293
  M4LDataGrid: Partial<DataGridOwnerState>;
292
294
  M4LDynamicFilterAndSort: Partial<DynamicFilterAndSortOwnerState>;
295
+ M4LRHFUploadSingleFile: Partial<RHFUploadSingleFileOwnerState>;
293
296
  M4LChipStatusFormatter: Partial<ChipStatusFormatterOwnerState>;
294
297
  M4LPrintingSystem: Partial<PrintingSystemOwnerState>;
295
298
  }
@@ -649,6 +652,11 @@ declare module '@mui/material/styles' {
649
652
  styleOverrides?: ComponentsOverrides<Theme>['M4LDynamicFilterAndSort'];
650
653
  variants?: ComponentsVariants['M4LDynamicFilterAndSort'];
651
654
  };
655
+ M4LRHFUploadSingleFile?: {
656
+ defaultProps?: ComponentsPropsList['M4LRHFUploadSingleFile'];
657
+ styleOverrides?: ComponentsOverrides<Theme>['M4LRHFUploadSingleFile'];
658
+ variants?: ComponentsVariants['M4LRHFUploadSingleFile'];
659
+ }
652
660
  M4LChipStatusFormatter?: {
653
661
  defaultProps?: ComponentsPropsList['M4LChipStatusFormatter'];
654
662
  styleOverrides?: ComponentsOverrides<Theme>['M4LChipStatusFormatter'];
@@ -1,12 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo, useCallback } from "react";
2
+ import { useMemo, useCallback, useId } from "react";
3
3
  import { unstable_HistoryRouter } from "react-router-dom";
4
4
  import { createBrowserHistory } from "history";
5
5
  import EventEmitter from "eventemitter3";
6
6
  import NProgress from "nprogress";
7
7
  import { LocalesProvider, getLocaleFromNetwork, DeviceTypeProvider } from "@m4l/graphics";
8
8
  import { EnvironmentProvider, HostToolsProvider, NetworkProvider, axiosOperation, AuthProvider } from "@m4l/core";
9
- import { T as TOAST_CONTAINER_ID } from "./constants.js";
10
9
  import { A as AppearanceComponentProvider } from "../../contexts/AppearanceComponentContext/AppearanceComponentContext.js";
11
10
  import { c as createToaster } from "../ToastContainer/helpers/toaster.js";
12
11
  import { M as MFAuthApp } from "./subcomponents/MFAuthApp/MFAuthApp.js";
@@ -89,7 +88,8 @@ function MFIsolationApp(props) {
89
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
90
89
  []
91
90
  );
92
- const toaster = createToaster(TOAST_CONTAINER_ID);
91
+ const toastContainerId = useId();
92
+ const toaster = createToaster(toastContainerId);
93
93
  const hostTools = useMemo(
94
94
  () => ({
95
95
  history,
@@ -113,7 +113,7 @@ function MFIsolationApp(props) {
113
113
  moduleNameField,
114
114
  moduleDictionaryLoaded,
115
115
  children: /* @__PURE__ */ jsxs(AppearanceComponentProvider, { children: [
116
- /* @__PURE__ */ jsx(ToastContainer, { containerId: TOAST_CONTAINER_ID }),
116
+ /* @__PURE__ */ jsx(ToastContainer, { containerId: toastContainerId }),
117
117
  " ",
118
118
  /* @__PURE__ */ jsx(
119
119
  PopupsProvider,
@@ -1,3 +1,6 @@
1
1
  export declare enum RHFTimePickerSlots {
2
- root = "root"
2
+ root = "root",
3
+ label = "label",
4
+ helperError = "helperError",
5
+ illustration = "illustration"
3
6
  }
@@ -0,0 +1,7 @@
1
+ import { RHFUploadSingleFileProps } from './types';
2
+ /**
3
+ * This component is used to upload a single file.
4
+ * @param {RHFUploadSingleFileProps} props - The props for the RHFUploadSingleFile component.
5
+ * @returns {React.ReactNode} The RHFUploadSingleFile component.
6
+ */
7
+ export declare function RHFUploadSingleFile(props: RHFUploadSingleFileProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,74 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useFormContext, Controller } from "react-hook-form";
3
+ import { U as UploadSingleFile } from "./subcomponents/UploadSingleFile/index.js";
4
+ import { R as RHFUploadSingleFileRootStyled, L as LabelStyled, H as HelperErrorStyled } from "./slots/RHFUploadSingleFileSlots.js";
5
+ import clsx from "clsx";
6
+ import { R as RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT, D as DEFAULT_MAX_FILE_SIZE } from "./constants.js";
7
+ import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
8
+ import { R as RHFUploadSingleFileSlots } from "./slots/RHFUploadSingleFileEnum.js";
9
+ import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
10
+ function RHFUploadSingleFile(props) {
11
+ const { control } = useFormContext();
12
+ const { name, label, skeletonWidth, size, className, helperMessage, mandatory, mandatoryMessage, maxFileSize = DEFAULT_MAX_FILE_SIZE, dataTestId, accept = "*/*" } = props;
13
+ const { currentSize } = useComponentSize(size);
14
+ const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
15
+ const acceptObj = {
16
+ [accept]: []
17
+ };
18
+ return /* @__PURE__ */ jsx(
19
+ RHFUploadSingleFileRootStyled,
20
+ {
21
+ role: "textbox",
22
+ "aria-label": "upload-single-file",
23
+ ownerState: {},
24
+ className: clsx(className),
25
+ ...getPropDataTestId(RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT, RHFUploadSingleFileSlots.root, dataTestId),
26
+ children: /* @__PURE__ */ jsx(
27
+ Controller,
28
+ {
29
+ name,
30
+ control,
31
+ render: ({ field: { value, onChange }, fieldState: { error } }) => {
32
+ const errorUpload = !!error;
33
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
34
+ label && /* @__PURE__ */ jsx(
35
+ LabelStyled,
36
+ {
37
+ ownerState: {},
38
+ error: errorUpload,
39
+ label,
40
+ mandatory,
41
+ mandatoryMessage,
42
+ helperMessage,
43
+ size: adjustedSize,
44
+ skeletonWidth
45
+ }
46
+ ),
47
+ /* @__PURE__ */ jsx(
48
+ UploadSingleFile,
49
+ {
50
+ maxFileSize,
51
+ accept: acceptObj,
52
+ file: value,
53
+ onChange,
54
+ size: adjustedSize
55
+ }
56
+ ),
57
+ errorUpload && /* @__PURE__ */ jsx(
58
+ HelperErrorStyled,
59
+ {
60
+ message: error?.message,
61
+ size: adjustedSize,
62
+ ownerState: {}
63
+ }
64
+ )
65
+ ] });
66
+ }
67
+ }
68
+ )
69
+ }
70
+ );
71
+ }
72
+ export {
73
+ RHFUploadSingleFile as R
74
+ };
@@ -0,0 +1,2 @@
1
+ import { RHFUploadSingleFileStyles } from './types';
2
+ export declare const rhfUploadSingleFileStyles: RHFUploadSingleFileStyles;
@@ -0,0 +1,147 @@
1
+ const rhfUploadSingleFileStyles = {
2
+ /**
3
+ * estilos root
4
+ */
5
+ root: ({ theme }) => ({
6
+ display: "flex",
7
+ flexDirection: "column",
8
+ gap: theme.vars.size.baseSpacings.sp1,
9
+ height: "300px"
10
+ }),
11
+ /**
12
+ * estilos containerDropZone
13
+ */
14
+ containerDropZone: ({ theme }) => ({
15
+ display: "flex",
16
+ width: "100%",
17
+ height: "100%",
18
+ border: theme.vars.size.borderStroke.container,
19
+ borderColor: theme.vars.palette.border.default,
20
+ borderRadius: theme.vars.size.borderRadius.r1,
21
+ paddingTop: theme.vars.size.baseSpacings.sp2,
22
+ paddingBottom: theme.vars.size.baseSpacings.sp2,
23
+ paddingLeft: theme.vars.size.baseSpacings["sp2-5"],
24
+ paddingRight: theme.vars.size.baseSpacings["sp2-5"]
25
+ }),
26
+ /**
27
+ * estilos dropZone
28
+ */
29
+ dropZone: ({ theme, ownerState }) => ({
30
+ display: "flex",
31
+ width: "100%",
32
+ height: "100%",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ backgroundColor: theme.vars.palette.background.neutral,
36
+ borderRadius: theme.vars.size.borderRadius["r0-5"],
37
+ padding: theme.vars.size.baseSpacings.sp4,
38
+ cursor: ownerState.isSkeleton ? "default" : "pointer"
39
+ }),
40
+ /**
41
+ * estilos containerBlockContent
42
+ */
43
+ containerBlockContent: ({ theme, ownerState }) => ({
44
+ flexDirection: "column",
45
+ justifyContent: "center",
46
+ alignItems: "center",
47
+ width: "100%",
48
+ height: "100%",
49
+ display: ownerState.hidden ? "none" : "flex",
50
+ gap: theme.vars.size.baseSpacings.sp4
51
+ }),
52
+ label: () => ({
53
+ display: "flex"
54
+ }),
55
+ helperError: () => ({
56
+ display: "flex"
57
+ }),
58
+ image: () => ({
59
+ display: "flex"
60
+ }),
61
+ /**
62
+ * estilos blockContentGroup
63
+ */
64
+ blockContentGroup: ({ theme }) => ({
65
+ display: "flex",
66
+ width: "auto",
67
+ height: "auto",
68
+ alignItems: "center",
69
+ flexDirection: "column",
70
+ gap: theme.vars.size.baseSpacings.sp2
71
+ }),
72
+ illustrationUpload: {},
73
+ title: {},
74
+ description: {},
75
+ /**
76
+ * estilos divider
77
+ */
78
+ divider: ({ theme }) => ({
79
+ display: "flex",
80
+ overflow: "visible",
81
+ width: "100%",
82
+ height: theme.vars.size.borderStroke.container,
83
+ border: theme.vars.size.borderStroke.container,
84
+ borderColor: theme.vars.palette.border.secondary,
85
+ position: "relative",
86
+ justifyContent: "center",
87
+ alignItems: "center",
88
+ margin: theme.vars.size.baseSpacings.sp3
89
+ }),
90
+ /**
91
+ * estilos dividerText
92
+ */
93
+ dividerText: ({ theme }) => ({
94
+ position: "absolute",
95
+ backgroundColor: theme.vars.palette.background.neutral,
96
+ padding: theme.vars.size.baseSpacings.sp2
97
+ }),
98
+ button: {},
99
+ /**
100
+ * estilos containerPreview
101
+ */
102
+ containerPreview: ({ theme }) => ({
103
+ display: "flex",
104
+ width: "100%",
105
+ height: "fit-content",
106
+ gap: theme.vars.size.baseSpacings.sp3,
107
+ alignContent: "center",
108
+ padding: theme.vars.size.baseSpacings["sp2-5"],
109
+ borderRadius: theme.vars.size.borderRadius.r1,
110
+ border: theme.vars.size.borderStroke.container,
111
+ borderColor: theme.vars.palette.border.default,
112
+ backgroundColor: theme.vars.palette.background.default
113
+ }),
114
+ /**
115
+ * estilos containerNameSize
116
+ */
117
+ containerNameSize: ({ theme }) => ({
118
+ display: "flex",
119
+ flexDirection: "column",
120
+ flex: 1,
121
+ gap: theme.vars.size.baseSpacings.sp2,
122
+ justifyContent: "center"
123
+ }),
124
+ /**
125
+ * estilos imagePreview
126
+ */
127
+ imagePreview: ({ theme }) => ({
128
+ display: "flex",
129
+ width: theme.vars.size.baseSpacings.sp10,
130
+ height: theme.vars.size.baseSpacings.sp10,
131
+ alignItems: "center"
132
+ }),
133
+ namePreview: {},
134
+ sizePreview: {},
135
+ /**
136
+ * estilos closePreview
137
+ */
138
+ closePreview: () => ({
139
+ display: "flex",
140
+ alignItems: "center",
141
+ justifyContent: "center",
142
+ margin: "auto"
143
+ })
144
+ };
145
+ export {
146
+ rhfUploadSingleFileStyles as r
147
+ };
@@ -0,0 +1,23 @@
1
+ export declare const RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT = "M4LRHFUploadSingleFile";
2
+ export declare const RHF_UPLOAD_SINGLE_FILE_CLASSES: Record<string, string>;
3
+ export declare const DEFAULT_MAX_FILE_SIZE: number;
4
+ export declare const FILES_ICONS: {
5
+ readonly 'application/pdf': "frontend/components/RHF_upload_single_file/assets/icons/application_pdf.svg";
6
+ readonly 'image/jpeg': "frontend/components/RHF_upload_single_file/assets/icons/image_jpeg.svg";
7
+ readonly 'image/png': "frontend/components/RHF_upload_single_file/assets/icons/image_png.svg";
8
+ readonly 'image/gif': "frontend/components/RHF_upload_single_file/assets/icons/image_gif.svg";
9
+ readonly 'image/svg+xml': "frontend/components/RHF_upload_single_file/assets/icons/image_svg%2Bxml.svg";
10
+ readonly 'audio/mpeg': "frontend/components/RHF_upload_single_file/assets/icons/audio_mpeg.svg";
11
+ readonly 'video/mp4': "frontend/components/RHF_upload_single_file/assets/icons/video_mp4.svg";
12
+ readonly 'application/zip': "frontend/components/RHF_upload_single_file/assets/icons/application_zip.svg";
13
+ readonly 'application/msword': "frontend/components/RHF_upload_single_file/assets/icons/application_msword.svg";
14
+ readonly 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': "frontend/components/RHF_upload_single_file/assets/icons/application_vnd.openxmlformats_officedocument.wordprocessingml.document.svg";
15
+ readonly 'application/vnd.ms-excel': "frontend/components/RHF_upload_single_file/assets/icons/application_vnd.ms_excel.svg";
16
+ readonly 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': "frontend/components/RHF_upload_single_file/assets/icons/application_vnd.openxmlformats_officedocument.spreadsheetml.sheet.svg";
17
+ readonly 'application/vnd.ms-powerpoint': "frontend/components/RHF_upload_single_file/assets/icons/application_vnd.ms-powerpoint.svg";
18
+ readonly 'application/vnd.openxmlformats-officedocument.presentationml.presentation': "frontend/components/RHF_upload_single_file/assets/icons/application_vnd.openxmlformats-officedocument.presentationml.presentation.svg";
19
+ readonly 'text/plain': "frontend/components/RHF_upload_single_file/assets/icons/text_plain.svg";
20
+ readonly 'application/octet-stream': "frontend/components/RHF_upload_single_file/assets/icons/application_octet_stream.svg";
21
+ };
22
+ export declare const CLOSE_PREVIEW_ICON = "frontend/components/RHF_upload_single_file/assets/icons/close.svg";
23
+ export declare const ILLUSTRATION_UPLOAD = "frontend/components/RHF_upload_single_file/assets/icons/RHFuploadSingleFile.svg";
@@ -0,0 +1,34 @@
1
+ import { g as getComponentClasses } from "../../../../utils/getComponentSlotRoot.js";
2
+ import { R as RHFUploadSingleFileSlots } from "./slots/RHFUploadSingleFileEnum.js";
3
+ const RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT = "M4LRHFUploadSingleFile";
4
+ const RHF_UPLOAD_SINGLE_FILE_CLASSES = getComponentClasses(RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT, RHFUploadSingleFileSlots);
5
+ const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024;
6
+ const PATH_ICONS = "frontend/components/RHF_upload_single_file/assets/icons";
7
+ const FILES_ICONS = {
8
+ "application/pdf": `${PATH_ICONS}/application_pdf.svg`,
9
+ "image/jpeg": `${PATH_ICONS}/image_jpeg.svg`,
10
+ "image/png": `${PATH_ICONS}/image_png.svg`,
11
+ "image/gif": `${PATH_ICONS}/image_gif.svg`,
12
+ "image/svg+xml": `${PATH_ICONS}/image_svg%2Bxml.svg`,
13
+ "audio/mpeg": `${PATH_ICONS}/audio_mpeg.svg`,
14
+ "video/mp4": `${PATH_ICONS}/video_mp4.svg`,
15
+ "application/zip": `${PATH_ICONS}/application_zip.svg`,
16
+ "application/msword": `${PATH_ICONS}/application_msword.svg`,
17
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": `${PATH_ICONS}/application_vnd.openxmlformats_officedocument.wordprocessingml.document.svg`,
18
+ "application/vnd.ms-excel": `${PATH_ICONS}/application_vnd.ms_excel.svg`,
19
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": `${PATH_ICONS}/application_vnd.openxmlformats_officedocument.spreadsheetml.sheet.svg`,
20
+ "application/vnd.ms-powerpoint": `${PATH_ICONS}/application_vnd.ms-powerpoint.svg`,
21
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": `${PATH_ICONS}/application_vnd.openxmlformats-officedocument.presentationml.presentation.svg`,
22
+ "text/plain": `${PATH_ICONS}/text_plain.svg`,
23
+ "application/octet-stream": `${PATH_ICONS}/application_octet_stream.svg`
24
+ };
25
+ const CLOSE_PREVIEW_ICON = `${PATH_ICONS}/close.svg`;
26
+ const ILLUSTRATION_UPLOAD = "frontend/components/RHF_upload_single_file/assets/icons/RHFuploadSingleFile.svg";
27
+ export {
28
+ CLOSE_PREVIEW_ICON as C,
29
+ DEFAULT_MAX_FILE_SIZE as D,
30
+ FILES_ICONS as F,
31
+ ILLUSTRATION_UPLOAD as I,
32
+ RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT as R,
33
+ RHF_UPLOAD_SINGLE_FILE_CLASSES as a
34
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Get the dictionary for the RHFUploadSingleFile component
3
+ */
4
+ export declare const getRHFuploadSingleFileComponentsDictionary: () => string[];
5
+ export declare const COMPONENTS_DICTIONARY_KEYS: {
6
+ errorMaxSize: string;
7
+ errorFileRejected: string;
8
+ title: string;
9
+ description: string;
10
+ blockContent: string;
11
+ buttonText: string;
12
+ dividerText: string;
13
+ acceptFile: string;
14
+ acceptSize: string;
15
+ };
@@ -0,0 +1,15 @@
1
+ const COMPONENT_KEY = "rhfuploadsinglefile";
2
+ const COMPONENTS_DICTIONARY_KEYS = {
3
+ errorMaxSize: `${COMPONENT_KEY}.error_max_size`,
4
+ errorFileRejected: `${COMPONENT_KEY}.error_file_rejected`,
5
+ title: `${COMPONENT_KEY}.title`,
6
+ description: `${COMPONENT_KEY}.description`,
7
+ blockContent: `${COMPONENT_KEY}.block_content`,
8
+ buttonText: `${COMPONENT_KEY}.button_text`,
9
+ dividerText: `${COMPONENT_KEY}.divider_text`,
10
+ acceptFile: `${COMPONENT_KEY}.accept_file`,
11
+ acceptSize: `${COMPONENT_KEY}.accept_size`
12
+ };
13
+ export {
14
+ COMPONENTS_DICTIONARY_KEYS as C
15
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Formatea el tamaño del archivo.
3
+ * @param bytes - Tamaño del archivo en bytes.
4
+ * @returns Tamaño del archivo formateado.
5
+ */
6
+ export declare const formatFileSize: (bytes: number) => string;
@@ -0,0 +1,16 @@
1
+ const formatFileSize = (bytes) => {
2
+ if (!bytes) {
3
+ return "";
4
+ }
5
+ const units = ["bytes", "KB", "MB", "GB"];
6
+ let size = bytes;
7
+ let unitIndex = 0;
8
+ while (size >= 1024 && unitIndex < units.length - 1) {
9
+ size /= 1024;
10
+ unitIndex++;
11
+ }
12
+ return `${size.toFixed(2)} ${units[unitIndex]}`;
13
+ };
14
+ export {
15
+ formatFileSize as f
16
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Obtiene el tipo de archivo legible para el usuario.
3
+ * @param mimeType - El tipo de archivo en formato MIME.
4
+ * @returns El tipo de archivo legible para el usuario.
5
+ */
6
+ export declare const getReadableFileType: (mimeType: string) => string;
@@ -0,0 +1,55 @@
1
+ const commonFileTypes = {
2
+ // Imágenes
3
+ "image/jpeg": "JPEG",
4
+ "image/jpg": "JPG",
5
+ "image/png": "PNG",
6
+ "image/gif": "GIF",
7
+ "image/webp": "WEBP",
8
+ "image/svg+xml": "SVG",
9
+ // Documentos
10
+ "application/pdf": "PDF",
11
+ "application/msword": "DOC",
12
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "DOCX",
13
+ "application/vnd.ms-excel": "XLS",
14
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "XLSX",
15
+ "application/vnd.ms-powerpoint": "PPT",
16
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "PPTX",
17
+ // Texto
18
+ "text/plain": "TXT",
19
+ "text/html": "HTML",
20
+ "text/css": "CSS",
21
+ "text/javascript": "JS",
22
+ // Comprimidos
23
+ "application/zip": "ZIP",
24
+ "application/x-rar-compressed": "RAR",
25
+ "application/x-7z-compressed": "7Z",
26
+ // Audio
27
+ "audio/mpeg": "MP3",
28
+ "audio/wav": "WAV",
29
+ "audio/ogg": "OGG",
30
+ // Video
31
+ "video/mp4": "MP4",
32
+ "video/mpeg": "MPEG",
33
+ "video/webm": "WEBM",
34
+ "video/quicktime": "MOV"
35
+ };
36
+ const getReadableFileType = (mimeType) => {
37
+ if (mimeType in commonFileTypes) {
38
+ return commonFileTypes[mimeType];
39
+ }
40
+ const [category, subtype] = mimeType.split("/");
41
+ if (subtype === "*") {
42
+ const categoryMap = {
43
+ image: "Imagen",
44
+ audio: "Audio",
45
+ video: "Video",
46
+ text: "Texto",
47
+ application: "Aplicación"
48
+ };
49
+ return categoryMap[category] || mimeType;
50
+ }
51
+ return subtype.toUpperCase() || mimeType;
52
+ };
53
+ export {
54
+ getReadableFileType as g
55
+ };
@@ -0,0 +1,5 @@
1
+ import { UploadAction, UploadState } from '../subcomponents/UploadSingleFile/types';
2
+ /**
3
+ * Reducer para el estado de la carga de un solo archivo
4
+ */
5
+ export declare function uploadReducer(state: UploadState, action: UploadAction): UploadState;
@@ -0,0 +1,17 @@
1
+ function uploadReducer(state, action) {
2
+ switch (action.type) {
3
+ case "SET_PROGRESS":
4
+ return { ...state, progress: action.payload };
5
+ case "SET_PREVIEW":
6
+ return { ...state, preview: action.payload };
7
+ case "SET_VALID_FILE":
8
+ return { ...state, validFile: action.payload };
9
+ case "RESET":
10
+ return { progress: null, preview: false, validFile: false };
11
+ default:
12
+ return state;
13
+ }
14
+ }
15
+ export {
16
+ uploadReducer as u
17
+ };
@@ -0,0 +1 @@
1
+ export { RHFUploadSingleFile } from './RHFUploadSingleFile';
@@ -0,0 +1,22 @@
1
+ export declare enum RHFUploadSingleFileSlots {
2
+ root = "root",
3
+ label = "label",
4
+ helperError = "helperError",
5
+ containerDropZone = "containerDropZone",
6
+ dropZone = "dropZone",
7
+ image = "image",
8
+ containerBlockContent = "containerBlockContent",
9
+ blockContentGroup = "blockContentGroup",
10
+ illustrationUpload = "illustrationUpload",
11
+ title = "title",
12
+ description = "description",
13
+ divider = "divider",
14
+ dividerText = "dividerText",
15
+ button = "button",
16
+ containerPreview = "containerPreview",
17
+ containerNameSize = "containerNameSize",
18
+ imagePreview = "imagePreview",
19
+ namePreview = "namePreview",
20
+ sizePreview = "sizePreview",
21
+ closePreview = "closePreview"
22
+ }
@@ -0,0 +1,26 @@
1
+ var RHFUploadSingleFileSlots = /* @__PURE__ */ ((RHFUploadSingleFileSlots2) => {
2
+ RHFUploadSingleFileSlots2["root"] = "root";
3
+ RHFUploadSingleFileSlots2["label"] = "label";
4
+ RHFUploadSingleFileSlots2["helperError"] = "helperError";
5
+ RHFUploadSingleFileSlots2["containerDropZone"] = "containerDropZone";
6
+ RHFUploadSingleFileSlots2["dropZone"] = "dropZone";
7
+ RHFUploadSingleFileSlots2["image"] = "image";
8
+ RHFUploadSingleFileSlots2["containerBlockContent"] = "containerBlockContent";
9
+ RHFUploadSingleFileSlots2["blockContentGroup"] = "blockContentGroup";
10
+ RHFUploadSingleFileSlots2["illustrationUpload"] = "illustrationUpload";
11
+ RHFUploadSingleFileSlots2["title"] = "title";
12
+ RHFUploadSingleFileSlots2["description"] = "description";
13
+ RHFUploadSingleFileSlots2["divider"] = "divider";
14
+ RHFUploadSingleFileSlots2["dividerText"] = "dividerText";
15
+ RHFUploadSingleFileSlots2["button"] = "button";
16
+ RHFUploadSingleFileSlots2["containerPreview"] = "containerPreview";
17
+ RHFUploadSingleFileSlots2["containerNameSize"] = "containerNameSize";
18
+ RHFUploadSingleFileSlots2["imagePreview"] = "imagePreview";
19
+ RHFUploadSingleFileSlots2["namePreview"] = "namePreview";
20
+ RHFUploadSingleFileSlots2["sizePreview"] = "sizePreview";
21
+ RHFUploadSingleFileSlots2["closePreview"] = "closePreview";
22
+ return RHFUploadSingleFileSlots2;
23
+ })(RHFUploadSingleFileSlots || {});
24
+ export {
25
+ RHFUploadSingleFileSlots as R
26
+ };