@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
@@ -1,3 +1,4 @@
1
+ import { g as getSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
1
2
  const buttonStyles = {
2
3
  /**
3
4
  * Styles for the root element of the button component.
@@ -79,26 +80,35 @@ const buttonStyles = {
79
80
  "& span": {
80
81
  margin: "0px"
81
82
  },
82
- // Estilos específicos para el tamaño small
83
- ...ownerState.size === "small" && {
84
- ...theme.generalSettings.isMobile ? {
85
- height: theme.vars.size.mobile.small.action,
86
- minHeight: theme.vars.size.mobile.small.action
87
- } : {
88
- height: theme.vars.size.desktop.small.action,
89
- minHeight: theme.vars.size.desktop.small.action
90
- }
91
- },
92
- // Estilos específicos para el tamaño medium
93
- ...ownerState.size === "medium" && {
94
- ...theme.generalSettings.isMobile ? {
95
- height: theme.vars.size.mobile.medium.action,
96
- minHeight: theme.vars.size.mobile.medium.action
97
- } : {
98
- height: theme.vars.size.desktop.medium.action,
99
- minHeight: theme.vars.size.desktop.medium.action
100
- }
101
- }
83
+ ...getSizeStyles(
84
+ theme,
85
+ ownerState.size || "medium",
86
+ "action"
87
+ )
88
+ // // Estilos específicos para el tamaño small
89
+ // ...(ownerState.size === 'small' && {
90
+ // ...(theme.generalSettings.isMobile
91
+ // ? {
92
+ // height: theme.vars.size.mobile.small.action,
93
+ // minHeight: theme.vars.size.mobile.small.action,
94
+ // }
95
+ // : {
96
+ // height: theme.vars.size.desktop.small.action,
97
+ // minHeight: theme.vars.size.desktop.small.action,
98
+ // }),
99
+ // }),
100
+ // // Estilos específicos para el tamaño medium
101
+ // ...(ownerState.size === 'medium' && {
102
+ // ...(theme.generalSettings.isMobile
103
+ // ? {
104
+ // height: theme.vars.size.mobile.medium.action,
105
+ // minHeight: theme.vars.size.mobile.medium.action,
106
+ // }
107
+ // : {
108
+ // height: theme.vars.size.desktop.medium.action,
109
+ // minHeight: theme.vars.size.desktop.medium.action,
110
+ // }),
111
+ // }),
102
112
  }),
103
113
  buttonIcon: {},
104
114
  /**
@@ -119,45 +129,64 @@ const buttonStyles = {
119
129
  * Styles for the skeleton button component.
120
130
  */
121
131
  skeletonButton: ({ theme, ownerState }) => ({
122
- width: "100%",
123
- background: theme.vars.palette.skeleton.transition,
124
- // Estilos específicos para el tamaño small
125
- ...ownerState.size === "small" && {
126
- ...theme.generalSettings.isMobile ? {
127
- height: theme.vars.size.mobile.small.action,
128
- minHeight: theme.vars.size.mobile.small.action
129
- } : {
130
- height: theme.vars.size.desktop.small.action,
131
- minHeight: theme.vars.size.desktop.small.action
132
- },
133
- [theme.breakpoints.up("sm")]: {
134
- ...theme.generalSettings.isMobile ? {
135
- height: theme.vars.size.mobile.small.action,
136
- minHeight: theme.vars.size.mobile.small.action
137
- } : {
138
- height: theme.vars.size.desktop.small.action,
139
- minHeight: theme.vars.size.desktop.small.action
140
- }
141
- }
142
- },
143
- // Estilos específicos para el tamaño medium
144
- ...ownerState.size === "medium" && {
145
- ...theme.generalSettings.isMobile ? {
146
- height: theme.vars.size.mobile.medium.action,
147
- minHeight: theme.vars.size.mobile.medium.action
148
- } : {
149
- height: theme.vars.size.desktop.medium.action,
150
- minHeight: theme.vars.size.desktop.medium.action
151
- },
152
- [theme.breakpoints.up("md")]: {
153
- ...theme.generalSettings.isMobile ? {
154
- height: theme.vars.size.mobile.small.action,
155
- minHeight: theme.vars.size.mobile.small.action
156
- } : {
157
- height: theme.vars.size.desktop.small.action,
158
- minHeight: theme.vars.size.desktop.small.action
159
- }
160
- }
132
+ "&&&": {
133
+ width: "100%",
134
+ background: theme.vars.palette.skeleton.transition,
135
+ ...getSizeStyles(
136
+ theme,
137
+ ownerState.size || "medium",
138
+ "action",
139
+ (sizeValue) => ({
140
+ height: sizeValue,
141
+ minHeight: sizeValue
142
+ })
143
+ )
144
+ // // Estilos específicos para el tamaño small
145
+ // ...(ownerState.size === 'small' && {
146
+ // ...(theme.generalSettings.isMobile
147
+ // ? {
148
+ // height: theme.vars.size.mobile.small.action,
149
+ // minHeight: theme.vars.size.mobile.small.action,
150
+ // }
151
+ // : {
152
+ // height: theme.vars.size.desktop.small.action,
153
+ // minHeight: theme.vars.size.desktop.small.action,
154
+ // }),
155
+ // [theme.breakpoints.up('sm')]: {
156
+ // ...(theme.generalSettings.isMobile
157
+ // ? {
158
+ // height: theme.vars.size.mobile.small.action,
159
+ // minHeight: theme.vars.size.mobile.small.action,
160
+ // }
161
+ // : {
162
+ // height: theme.vars.size.desktop.small.action,
163
+ // minHeight: theme.vars.size.desktop.small.action,
164
+ // }),
165
+ // },
166
+ // }),
167
+ // // Estilos específicos para el tamaño medium
168
+ // ...(ownerState.size === 'medium' && {
169
+ // ...(theme.generalSettings.isMobile
170
+ // ? {
171
+ // height: theme.vars.size.mobile.medium.action,
172
+ // minHeight: theme.vars.size.mobile.medium.action,
173
+ // }
174
+ // : {
175
+ // height: theme.vars.size.desktop.medium.action,
176
+ // minHeight: theme.vars.size.desktop.medium.action,
177
+ // }),
178
+ // [theme.breakpoints.up('md')]: {
179
+ // ...(theme.generalSettings.isMobile
180
+ // ? {
181
+ // height: theme.vars.size.mobile.small.action,
182
+ // minHeight: theme.vars.size.mobile.small.action,
183
+ // }
184
+ // : {
185
+ // height: theme.vars.size.desktop.small.action,
186
+ // minHeight: theme.vars.size.desktop.small.action,
187
+ // }),
188
+ // },
189
+ // }),
161
190
  }
162
191
  })
163
192
  };
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { LinearProgress as LinearProgress$1 } from "@mui/material";
3
3
  const LinearProgress = (props) => {
4
4
  const { ...other } = props;
5
- return /* @__PURE__ */ jsx(LinearProgress$1, { ...other });
5
+ return /* @__PURE__ */ jsx(LinearProgress$1, { sx: { width: "100%" }, ...other });
6
6
  };
7
7
  export {
8
8
  LinearProgress as L
package/index.js CHANGED
@@ -133,7 +133,7 @@ import { R as R8 } from "./components/hook-form/RHFSelect/RHFSelect.js";
133
133
  import { R as R9 } from "./components/hook-form/RHFHelperError/index.js";
134
134
  import { R as R10 } from "./components/hook-form/RHFRadioGroup/RHFRadioGroup.js";
135
135
  import { R as R11 } from "./components/hook-form/RHFNumberInput/RHFNumberInput.js";
136
- import { R as R12 } from "./components/hook-form/RHFUpload/RHFUploadFile/index.js";
136
+ import { R as R12 } from "./components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js";
137
137
  import { R as R13 } from "./components/hook-form/RHFColorPicker/RFHColorPicker.js";
138
138
  import { R as R14 } from "./components/hook-form/RHFCheckbox/RHFCheckbox.js";
139
139
  import { R as R15 } from "./components/hook-form/RHFTextField/RHFTextField.js";
@@ -329,8 +329,8 @@ export {
329
329
  R8 as RHFSelect,
330
330
  R15 as RHFTextField,
331
331
  R16 as RHFTextFieldPassword,
332
- R12 as RHFUploadFile,
333
332
  R21 as RHFUploadImage,
333
+ R12 as RHFUploadSingleFile,
334
334
  R18 as RHF_PERIOD_KEY_COMPONENT,
335
335
  R22 as RHFormProvider,
336
336
  R as Resizable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.2.28",
3
+ "version": "9.2.29",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0 --no-warn-ignored"
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { RHFUploadSingleFile } from '../../../src/components/hook-form/RHFUpload/RHFUploadSingleFile';
3
+ declare const meta: Meta<typeof RHFUploadSingleFile>;
4
+ type Story = StoryObj<typeof RHFUploadSingleFile>;
5
+ export declare const RHFUploadSingleFileDefault: Story;
6
+ export declare const RHFUploadSingleFileError: Story;
7
+ /**
8
+ * Skeleton State
9
+ */
10
+ export declare const RHFUploadSingleFileSkeleton: Story;
11
+ export default meta;
@@ -1,4 +0,0 @@
1
- const TOAST_CONTAINER_ID = "toast-host";
2
- export {
3
- TOAST_CONTAINER_ID as T
4
- };
@@ -1,13 +0,0 @@
1
- import { DropzoneProps } from 'react-dropzone';
2
- interface UploadProps extends DropzoneProps {
3
- error?: boolean;
4
- file: any;
5
- helperText?: React.ReactNode;
6
- sx?: any;
7
- onChange?: (...event: any[]) => void;
8
- }
9
- /**
10
- * todo: document this component
11
- */
12
- export default function UploadSingleFile({ error, file, helperText, sx, accept, onChange, ...other }: UploadProps): import("react/jsx-runtime").JSX.Element;
13
- export {};
@@ -1,84 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import isString from "lodash-es/isString";
3
- import { useDropzone } from "react-dropzone";
4
- import { useState, useEffect } from "react";
5
- import { styled } from "@mui/material/styles";
6
- import { Box } from "@mui/material";
7
- import { B as BlockContent } from "../../../components/UploadComponents/BlockContent.js";
8
- import { R as RejectionFiles } from "../../../components/UploadComponents/RejectionFiles.js";
9
- import { I as Image } from "../../../../../Image/Image.js";
10
- const DropZoneStyle = styled("div")(({ theme }) => ({
11
- outline: "none",
12
- overflow: "hidden",
13
- position: "relative",
14
- padding: theme.spacing(5, 1),
15
- borderRadius: theme.shape.borderRadius,
16
- transition: theme.transitions.create("padding"),
17
- backgroundColor: theme.vars.palette.background.neutral,
18
- border: `1px dashed ${theme.vars.palette.grey[50032]}`,
19
- "&:hover": { opacity: 0.72, cursor: "pointer" }
20
- }));
21
- function UploadSingleFile({
22
- error = false,
23
- file,
24
- helperText,
25
- sx,
26
- accept,
27
- onChange,
28
- ...other
29
- }) {
30
- const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections } = useDropzone({
31
- multiple: false,
32
- accept,
33
- /**
34
- * todo: document this component
35
- */
36
- onDrop: (acceptedFiles) => {
37
- if (acceptedFiles.length > 0) {
38
- onChange?.(acceptedFiles[0]);
39
- }
40
- },
41
- ...other
42
- });
43
- const [preview, setPreview] = useState(null);
44
- useEffect(() => {
45
- if (file instanceof File) {
46
- const objectUrl = URL.createObjectURL(file);
47
- setPreview(objectUrl);
48
- return () => URL.revokeObjectURL(objectUrl);
49
- } else if (isString(file)) {
50
- setPreview(file);
51
- } else {
52
- setPreview(null);
53
- }
54
- }, [file]);
55
- return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...sx }, children: [
56
- /* @__PURE__ */ jsxs(
57
- DropZoneStyle,
58
- {
59
- ...getRootProps(),
60
- sx: {
61
- ...isDragActive && { opacity: 0.72 },
62
- ...(isDragReject || error) && {
63
- color: "error.enabled",
64
- borderColor: "error.light",
65
- bgcolor: "error.lighter"
66
- },
67
- ...file && {
68
- padding: "12% 0"
69
- }
70
- },
71
- children: [
72
- !preview && /* @__PURE__ */ jsx(BlockContent, {}),
73
- /* @__PURE__ */ jsx("input", { ...getInputProps() }),
74
- preview && /* @__PURE__ */ jsx(Image, { alt: "file preview", src: preview })
75
- ]
76
- }
77
- ),
78
- fileRejections.length > 0 && /* @__PURE__ */ jsx(RejectionFiles, { fileRejections }),
79
- helperText && helperText
80
- ] });
81
- }
82
- export {
83
- UploadSingleFile as U
84
- };
@@ -1,9 +0,0 @@
1
- interface Props {
2
- name: string;
3
- [key: string]: any;
4
- }
5
- /**
6
- * todo: document this component
7
- */
8
- export declare function RHFUploadFile({ name, ...other }: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,31 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useFormContext, Controller } from "react-hook-form";
3
- import { U as UploadSingleFile } from "./components/UploadSingleFile/index.js";
4
- import { FormHelperText } from "@mui/material";
5
- function RHFUploadFile({ name, ...other }) {
6
- const { control } = useFormContext();
7
- return /* @__PURE__ */ jsx(
8
- Controller,
9
- {
10
- name,
11
- control,
12
- render: ({ field: { value, onChange }, fieldState: { error } }) => {
13
- const checkError = !!error && !value;
14
- return /* @__PURE__ */ jsx(
15
- UploadSingleFile,
16
- {
17
- accept: { "image/png": [".png"] },
18
- file: value,
19
- error: checkError,
20
- onChange,
21
- helperText: checkError && /* @__PURE__ */ jsx(FormHelperText, { error: true, sx: { px: 2 }, children: error.message }),
22
- ...other
23
- }
24
- );
25
- }
26
- }
27
- );
28
- }
29
- export {
30
- RHFUploadFile as R
31
- };
@@ -1,36 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Stack, Box, Typography } from "@mui/material";
3
- function BlockContent() {
4
- return /* @__PURE__ */ jsxs(
5
- Stack,
6
- {
7
- spacing: 2,
8
- alignItems: "center",
9
- justifyContent: "center",
10
- direction: { xs: "column", md: "row" },
11
- sx: { width: 1, textAlign: { xs: "center", md: "left" } },
12
- children: [
13
- /* @__PURE__ */ jsx("img", { src: "\nhttps://s3.amazonaws.com/static.made4labs/environments/d1/frontend/components/sidebar/assets/icons/arrow_right.svg", alt: "upload" }),
14
- /* @__PURE__ */ jsxs(Box, { sx: { p: 3 }, children: [
15
- /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h5", children: "Drop or Select file" }),
16
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", sx: { color: "text.secondary" }, children: [
17
- "Drop files here or click ",
18
- /* @__PURE__ */ jsx(
19
- Typography,
20
- {
21
- variant: "body2",
22
- component: "span",
23
- sx: { color: "primary.enabled", textDecoration: "underline" },
24
- children: "browse"
25
- }
26
- ),
27
- " thorough your machine"
28
- ] })
29
- ] })
30
- ]
31
- }
32
- );
33
- }
34
- export {
35
- BlockContent as B
36
- };
@@ -1,31 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { alpha } from "@mui/material/styles";
3
- import { Paper, Box, Typography } from "@mui/material";
4
- function RejectionFiles({ fileRejections }) {
5
- return /* @__PURE__ */ jsx(
6
- Paper,
7
- {
8
- variant: "outlined",
9
- sx: {
10
- py: 1,
11
- px: 2,
12
- mt: 3,
13
- borderColor: "error.light",
14
- bgcolor: (theme) => alpha(theme.colorSchemes.finalTheme.palette.error.enabled, 0.08)
15
- },
16
- children: fileRejections.map(({ file, errors }) => {
17
- const { path } = file;
18
- return /* @__PURE__ */ jsxs(Box, { sx: { my: 1 }, children: [
19
- /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", noWrap: true, children: path }),
20
- errors.map((error) => /* @__PURE__ */ jsxs(Typography, { variant: "caption", component: "p", children: [
21
- "- ",
22
- error.message
23
- ] }, error.code))
24
- ] }, path);
25
- })
26
- }
27
- );
28
- }
29
- export {
30
- RejectionFiles as R
31
- };
@@ -1,6 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { RHFUploadFile } from '../../../src/components/hook-form/RHFUpload/RHFUploadFile';
3
- declare const meta: Meta<typeof RHFUploadFile>;
4
- type Story = StoryObj<typeof RHFUploadFile>;
5
- export declare const RHFUploadFileDefault: Story;
6
- export default meta;