@m4l/components 9.2.33 → 9.2.35
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/@types/export.d.ts +0 -3
- package/@types/types.d.ts +29 -21
- package/components/CommonActions/components/ActionFormCancel/ActionFormCancel.js +0 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.d.ts +18 -2
- package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js +66 -28
- package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.styles.d.ts +2 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.styles.js +117 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/constants.d.ts +1 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/constants.js +4 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageEnum.d.ts +13 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageEnum.js +17 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.d.ts +33 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.js +65 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js +113 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/dictionary.d.ts +10 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/dictionary.js +14 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/tests/UploadImage.test.d.ts +1 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/types.d.ts +24 -8
- package/components/hook-form/RHFUpload/RHFUploadImage/tests/RHFUploadImage.test.d.ts +1 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/types.d.ts +13 -11
- package/components/mui_extended/Divider/Divider.js +38 -0
- package/components/mui_extended/Divider/Divider.styles.js +51 -0
- package/components/mui_extended/Divider/constants.js +4 -0
- package/components/mui_extended/Divider/slots/DividerEnum.js +8 -0
- package/components/mui_extended/Divider/slots/DividerSlots.js +17 -0
- package/package.json +1 -1
- package/storybook/hook-form/RHFUploadImage/RHFUploadImage.stories.d.ts +8 -0
- package/components/hook-form/RHFUpload/RHFUploadImage/classes/constants.d.ts +0 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/classes/constants.js +0 -4
- package/components/hook-form/RHFUpload/RHFUploadImage/classes/index.d.ts +0 -22
- package/components/hook-form/RHFUpload/RHFUploadImage/classes/index.js +0 -57
- package/components/hook-form/RHFUpload/RHFUploadImage/classes/types.d.ts +0 -18
- package/components/hook-form/RHFUpload/RHFUploadImage/styles.d.ts +0 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/styles.js +0 -9
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/index.d.ts +0 -5
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/index.js +0 -146
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/styles.d.ts +0 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/styles.js +0 -7
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/subcomponents/Skeleton/index.d.ts +0 -5
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/subcomponents/Skeleton/index.js +0 -23
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/subcomponents/Skeleton/types.d.ts +0 -3
- package/components/hook-form/RHFUpload/RHFUploadImage/tests/constants.d.ts +0 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/tests/constants.js +0 -4
- package/components/hook-form/RHFUpload/RHFUploadImage/tests/utils.d.ts +0 -2
- package/components/hook-form/RHFUpload/RHFUploadImage/tests/utils.js +0 -7
package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useHostTools, useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
|
+
import isString from "lodash-es/isString";
|
|
4
|
+
import { useDropzone } from "react-dropzone";
|
|
5
|
+
import { g as getPropDataTestId } from "../../../../../../test/getNameDataTestId.js";
|
|
6
|
+
import { I as Image } from "../../../../../Image/Image.js";
|
|
7
|
+
import { R as RHF_UPLOAD_IMAGE_KEY_COMPONENT } from "../../constants.js";
|
|
8
|
+
import { U as UploadImageSlots } from "../../slots/RHFUploadImageEnum.js";
|
|
9
|
+
import { U as UploadImageRootStyled, C as ContentModuleLayoutStyled, a as ContainPreviewStyled, I as IconButtonRemoveStyled, b as ContentImageStyled, c as ContentImageTextStyled, T as TypographyStyled, d as ContentMessageStyled, D as DividerStyled, B as ButtonStyled } from "../../slots/RHFUploadImageSlots.js";
|
|
10
|
+
import { g as getUploadImageDictionary, C as COMPONENTS_DICTIONARY_KEYS } from "./dictionary.js";
|
|
11
|
+
import { u as useComponentSize } from "../../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
12
|
+
import { g as getComponentClasses } from "../../../../../../utils/getComponentSlotRoot.js";
|
|
13
|
+
import { T as Typography } from "../../../../../mui_extended/Typography/Typography.js";
|
|
14
|
+
const UploadImage = (props) => {
|
|
15
|
+
const { file, size, onDrop, onRemove, maxSize, dataTestId, error = false, multiple, ...other } = props;
|
|
16
|
+
const { currentSize } = useComponentSize(size);
|
|
17
|
+
const { toast } = useHostTools();
|
|
18
|
+
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
19
|
+
const { getInputProps, getRootProps, open, isDragReject, isDragAccept } = useDropzone({
|
|
20
|
+
multiple: false,
|
|
21
|
+
accept: { "image/png": [], "image/jpeg": [], "image/gif": [] },
|
|
22
|
+
onDrop,
|
|
23
|
+
/**
|
|
24
|
+
* onDropRejected es una función que se ejecuta cuando el archivo no es aceptado
|
|
25
|
+
*/
|
|
26
|
+
onDropRejected: (fileReject) => {
|
|
27
|
+
fileReject.forEach((rejection) => {
|
|
28
|
+
toast(
|
|
29
|
+
{ title: rejection.file.name, description: rejection.errors[0].message },
|
|
30
|
+
{ type: "error" }
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
noClick: true,
|
|
35
|
+
maxSize,
|
|
36
|
+
...other
|
|
37
|
+
});
|
|
38
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
39
|
+
const { getLabel } = useModuleDictionary();
|
|
40
|
+
const ownerState = {
|
|
41
|
+
isDragReject,
|
|
42
|
+
isDragAccept,
|
|
43
|
+
error
|
|
44
|
+
};
|
|
45
|
+
const classses = getComponentClasses(RHF_UPLOAD_IMAGE_KEY_COMPONENT, UploadImageSlots);
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
UploadImageRootStyled,
|
|
48
|
+
{
|
|
49
|
+
className: classses.uploadImageRoot,
|
|
50
|
+
ownerState: { ...ownerState },
|
|
51
|
+
...getPropDataTestId(RHF_UPLOAD_IMAGE_KEY_COMPONENT, UploadImageSlots.uploadImageRoot, dataTestId),
|
|
52
|
+
children: /* @__PURE__ */ jsxs(
|
|
53
|
+
ContentModuleLayoutStyled,
|
|
54
|
+
{
|
|
55
|
+
...getPropDataTestId(RHF_UPLOAD_IMAGE_KEY_COMPONENT, UploadImageSlots.contentModuleLayout, dataTestId),
|
|
56
|
+
...getRootProps(),
|
|
57
|
+
children: [
|
|
58
|
+
file ? /* @__PURE__ */ jsxs(ContainPreviewStyled, { ownerState: {}, children: [
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
IconButtonRemoveStyled,
|
|
61
|
+
{
|
|
62
|
+
ownerState: {},
|
|
63
|
+
variant: "contained",
|
|
64
|
+
icon: `${host_static_assets}/${environment_assets}/frontend/components/chip/assets/icons/closeSmall.svg`,
|
|
65
|
+
onClick: onRemove,
|
|
66
|
+
size: adjustedSize
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
Image,
|
|
71
|
+
{
|
|
72
|
+
src: isString(file) ? file : file.preview || "",
|
|
73
|
+
enableIntersectionObserver: false
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] }) : /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center" }, children: [
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
"input",
|
|
79
|
+
{
|
|
80
|
+
...getInputProps()
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsxs(ContentImageStyled, { ownerState: {}, children: [
|
|
84
|
+
/* @__PURE__ */ jsxs(ContentImageTextStyled, { ownerState: {}, children: [
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
Image,
|
|
87
|
+
{
|
|
88
|
+
height: 100,
|
|
89
|
+
width: 100,
|
|
90
|
+
sizes: size,
|
|
91
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFUploadImage/assets/icons/uploadImage.svg`
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx(Typography, { skeletonWidth: 100, variant: "bodyDens", size: adjustedSize, children: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.title_upload)) })
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ jsx(TypographyStyled, { skeletonWidth: 200, skeletonRows: 2, ownerState: {}, variant: "body", size: adjustedSize, children: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.description)) }),
|
|
97
|
+
/* @__PURE__ */ jsxs(ContentMessageStyled, { ownerState: {}, children: [
|
|
98
|
+
/* @__PURE__ */ jsx(DividerStyled, { ownerState: {}, orientation: "horizontal", customVariant: "solid", size: adjustedSize }),
|
|
99
|
+
/* @__PURE__ */ jsx(TypographyStyled, { skeletonWidth: 10, ownerState: {}, variant: "body", size: adjustedSize, children: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.divider_text)) }),
|
|
100
|
+
/* @__PURE__ */ jsx(DividerStyled, { ownerState: {}, orientation: "horizontal", customVariant: "solid", size: adjustedSize })
|
|
101
|
+
] })
|
|
102
|
+
] })
|
|
103
|
+
] }),
|
|
104
|
+
!file ? /* @__PURE__ */ jsx(ButtonStyled, { ownerState: {}, variant: "contained", color: "primary", onClick: open, label: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.click_button)), size: adjustedSize }) : null
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
UploadImage as U
|
|
113
|
+
};
|
package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/dictionary.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const UPLOAD_IMAGE_DICTIONARY_ID = "rhf_uploadimage";
|
|
2
|
+
export declare function getUploadImageComponentsDictionary(): string[];
|
|
3
|
+
export declare const COMPONENTS_DICTIONARY_KEYS: {
|
|
4
|
+
readonly click_button: "click_button";
|
|
5
|
+
readonly description: "description";
|
|
6
|
+
readonly title_upload: "title_upload";
|
|
7
|
+
readonly divider_text: "divider_text";
|
|
8
|
+
};
|
|
9
|
+
export type TypeDictionary = typeof COMPONENTS_DICTIONARY_KEYS;
|
|
10
|
+
export declare const getUploadImageDictionary: (key: keyof TypeDictionary) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const UPLOAD_IMAGE_DICTIONARY_ID = "rhf_uploadimage";
|
|
2
|
+
const COMPONENTS_DICTIONARY_KEYS = {
|
|
3
|
+
click_button: "click_button",
|
|
4
|
+
description: "description",
|
|
5
|
+
title_upload: "title_upload",
|
|
6
|
+
divider_text: "divider_text"
|
|
7
|
+
};
|
|
8
|
+
const getUploadImageDictionary = (key) => {
|
|
9
|
+
return `${UPLOAD_IMAGE_DICTIONARY_ID}.${key}`;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
COMPONENTS_DICTIONARY_KEYS as C,
|
|
13
|
+
getUploadImageDictionary as g
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DropzoneOptions } from 'react-dropzone';
|
|
1
|
+
import { Sizes } from '@m4l/styles';
|
|
3
2
|
import { SxProps } from '@mui/material';
|
|
4
3
|
import { Theme } from '@mui/material/styles';
|
|
4
|
+
import { DropzoneOptions } from 'react-dropzone';
|
|
5
5
|
import { CustomFile } from '../../../types';
|
|
6
6
|
export interface UploadImageProps extends DropzoneOptions {
|
|
7
7
|
error?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* file para mostrar la imagen
|
|
10
|
+
*/
|
|
8
11
|
file: CustomFile | string | null;
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* sx para el componente
|
|
14
|
+
*/
|
|
10
15
|
sx?: SxProps<Theme>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Tamaño del componente
|
|
18
|
+
*/
|
|
19
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
20
|
+
/**
|
|
21
|
+
* onRemove es una función que se ejecuta cuando se elimina la imagen
|
|
22
|
+
*/
|
|
23
|
+
onRemove: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* isDragActive es una propiedad booleana que indica si el componente está en estado de arrastre
|
|
26
|
+
*/
|
|
27
|
+
isDragAccept?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* dataTestId
|
|
30
|
+
*/
|
|
31
|
+
dataTestId?: string;
|
|
16
32
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { DropzoneOptions } from 'react-dropzone';
|
|
3
|
-
import { CustomFile } from '../types';
|
|
4
|
-
import { SxProps } from '@mui/material';
|
|
5
1
|
import { Theme } from '@mui/material/styles';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface RHFUploadImageProps extends Omit<UploadImageProps, 'file' | 'onDrop'> {
|
|
2
|
+
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
3
|
+
import { LabelProps } from 'src/components/Label';
|
|
4
|
+
import { RHF_UPLOAD_IMAGE_KEY_COMPONENT } from './constants';
|
|
5
|
+
import { UploadImageSlots as Slots } from './slots/RHFUploadImageEnum';
|
|
6
|
+
import { UploadImageProps } from './subcomponents/UploadImage/types';
|
|
7
|
+
export interface RHFUploadImageProps extends Omit<UploadImageProps, 'file' | 'onDrop' | 'onRemove'>, Omit<LabelProps, 'size' | 'error' | 'disabled' | 'children'> {
|
|
13
8
|
name: string;
|
|
14
9
|
}
|
|
10
|
+
export type RHFUploadImageSlotsType = keyof typeof Slots;
|
|
11
|
+
export type RHFUploadImageOwnerState = {
|
|
12
|
+
isDragAccept: boolean;
|
|
13
|
+
isDragReject: boolean;
|
|
14
|
+
error: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type RHFUploadImageStyles = OverridesStyleRules<RHFUploadImageSlotsType, typeof RHF_UPLOAD_IMAGE_KEY_COMPONENT, Theme>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { D as DividerRootStyled, a as DividerStyled } from "./slots/DividerSlots.js";
|
|
4
|
+
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
5
|
+
const Divider = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
className,
|
|
8
|
+
size = "medium",
|
|
9
|
+
orientation = "vertical",
|
|
10
|
+
customVariant = "dash",
|
|
11
|
+
...other
|
|
12
|
+
} = props;
|
|
13
|
+
const { currentSize } = useComponentSize(size);
|
|
14
|
+
const normalizedSize = currentSize === "large" ? "medium" : currentSize;
|
|
15
|
+
const ownerState = {
|
|
16
|
+
orientation,
|
|
17
|
+
customVariant,
|
|
18
|
+
size: normalizedSize
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
DividerRootStyled,
|
|
22
|
+
{
|
|
23
|
+
ownerState: { ...ownerState },
|
|
24
|
+
className: clsx(className),
|
|
25
|
+
children: /* @__PURE__ */ jsx(
|
|
26
|
+
DividerStyled,
|
|
27
|
+
{
|
|
28
|
+
ownerState: { ...ownerState },
|
|
29
|
+
orientation,
|
|
30
|
+
...other
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
Divider as D
|
|
38
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { a as getHeightSizeStyles } from "../../../utils/getSizeStyles/getSizeStyles.js";
|
|
2
|
+
const dividerStyles = {
|
|
3
|
+
/**
|
|
4
|
+
* 🧮 Estilos para el Root del componente `Divider`. 🧮
|
|
5
|
+
*/
|
|
6
|
+
root: ({ theme, ownerState }) => ({
|
|
7
|
+
display: "flex",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
position: "relative",
|
|
11
|
+
...getHeightSizeStyles(
|
|
12
|
+
theme.generalSettings.isMobile,
|
|
13
|
+
ownerState.size || "medium",
|
|
14
|
+
"action",
|
|
15
|
+
(dynamicSize) => ({
|
|
16
|
+
...ownerState.orientation === "horizontal" && {
|
|
17
|
+
height: dynamicSize,
|
|
18
|
+
width: "100%"
|
|
19
|
+
},
|
|
20
|
+
...ownerState.orientation === "vertical" && {
|
|
21
|
+
width: dynamicSize,
|
|
22
|
+
height: "100%"
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
}),
|
|
27
|
+
/**
|
|
28
|
+
* Divider Styles
|
|
29
|
+
*/
|
|
30
|
+
/*
|
|
31
|
+
* ➗ Estilos del Divider ➗ */
|
|
32
|
+
/**
|
|
33
|
+
* Styles for the Divider component.
|
|
34
|
+
* @param {object} ownerState - The state of the owner component.
|
|
35
|
+
* @param {object} theme - The theme object.
|
|
36
|
+
* @returns {object} The styles for the Divider component.
|
|
37
|
+
*/
|
|
38
|
+
divider: ({ ownerState, theme }) => ({
|
|
39
|
+
position: "absolute",
|
|
40
|
+
top: ownerState.orientation === "horizontal" ? "50%" : "0",
|
|
41
|
+
left: ownerState.orientation === "vertical" ? "50%" : "0",
|
|
42
|
+
transform: ownerState.orientation === "horizontal" ? "translateY(-50%)" : "translateX(0%)",
|
|
43
|
+
width: ownerState.orientation === "horizontal" ? "100%" : "1px",
|
|
44
|
+
height: ownerState.orientation === "vertical" ? "100%" : "1px",
|
|
45
|
+
borderColor: theme.vars.palette.border.secondary,
|
|
46
|
+
borderStyle: ownerState.customVariant === "dash" ? "dashed" : "solid"
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
dividerStyles as d
|
|
51
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { Divider } from "@mui/material";
|
|
3
|
+
import { D as DIVIDER_KEY_COMPONENT } from "../constants.js";
|
|
4
|
+
import { d as dividerStyles } from "../Divider.styles.js";
|
|
5
|
+
import { D as DividerSlots } from "./DividerEnum.js";
|
|
6
|
+
const DividerRootStyled = styled("div", {
|
|
7
|
+
name: DIVIDER_KEY_COMPONENT,
|
|
8
|
+
slot: DividerSlots.root
|
|
9
|
+
})(dividerStyles?.root);
|
|
10
|
+
const DividerStyled = styled(Divider, {
|
|
11
|
+
name: DIVIDER_KEY_COMPONENT,
|
|
12
|
+
slot: DividerSlots.divider
|
|
13
|
+
})(dividerStyles?.divider);
|
|
14
|
+
export {
|
|
15
|
+
DividerRootStyled as D,
|
|
16
|
+
DividerStyled as a
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { RHFUploadImage } from '../../../src/components/hook-form/RHFUpload/RHFUploadImage';
|
|
3
|
+
declare const meta: Meta<typeof RHFUploadImage>;
|
|
4
|
+
type Story = StoryObj<typeof RHFUploadImage>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const RHFUploadImageDefault: Story;
|
|
7
|
+
export declare const RHFUploadImageWithError: Story;
|
|
8
|
+
export declare const Skeleton: Story;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const componentName = "M4LRHFUploadImage";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { RHFUploadImageClassesType } from './types';
|
|
2
|
-
import { OwnerState } from '../subcomponents/UploadImage/types';
|
|
3
|
-
export declare const RHFUploadImageClasses: RHFUploadImageClassesType;
|
|
4
|
-
export declare function getRHFUploadImagebUtilityClass(slot: string): string;
|
|
5
|
-
/**
|
|
6
|
-
* TODO: Documentar
|
|
7
|
-
*/
|
|
8
|
-
export declare const RHFUploadImageUtilityClasses: (ownerState: OwnerState) => {
|
|
9
|
-
skeleton: string;
|
|
10
|
-
root: string;
|
|
11
|
-
dropZoneStyle: string;
|
|
12
|
-
containerFileImage: string;
|
|
13
|
-
placeHolder: string;
|
|
14
|
-
containerUploadBoddy: string;
|
|
15
|
-
containerBodyImage: string;
|
|
16
|
-
containerMessage: string;
|
|
17
|
-
containerTitle: string;
|
|
18
|
-
containerDescription: string;
|
|
19
|
-
containerConditions: string;
|
|
20
|
-
containerUploadImage: string;
|
|
21
|
-
inputDropZone: string;
|
|
22
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
2
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
3
|
-
import { c as componentName } from "./constants.js";
|
|
4
|
-
generateUtilityClasses(
|
|
5
|
-
componentName,
|
|
6
|
-
[
|
|
7
|
-
/* elements */
|
|
8
|
-
"root",
|
|
9
|
-
"dropZoneStyle",
|
|
10
|
-
"containerFileImage",
|
|
11
|
-
"placeHolder",
|
|
12
|
-
"containerUploadBoddy",
|
|
13
|
-
"containerBodyImage",
|
|
14
|
-
"containerMessage",
|
|
15
|
-
"containerTitle",
|
|
16
|
-
"containerDescription",
|
|
17
|
-
"containerConditions",
|
|
18
|
-
"containerUploadImage",
|
|
19
|
-
"string",
|
|
20
|
-
"skeleton",
|
|
21
|
-
"inputDropZone",
|
|
22
|
-
/* states or variants of elements */
|
|
23
|
-
"stateError"
|
|
24
|
-
]
|
|
25
|
-
);
|
|
26
|
-
function getRHFUploadImagebUtilityClass(slot) {
|
|
27
|
-
return generateUtilityClass(componentName, slot);
|
|
28
|
-
}
|
|
29
|
-
const RHFUploadImageUtilityClasses = (ownerState) => {
|
|
30
|
-
const slots = {
|
|
31
|
-
root: [
|
|
32
|
-
"root",
|
|
33
|
-
ownerState.isDragReject && "stateError",
|
|
34
|
-
ownerState.isDragActive && "stateActive",
|
|
35
|
-
ownerState.hasFile && "hasFile"
|
|
36
|
-
],
|
|
37
|
-
dropZoneStyle: ["dropZoneStyle"],
|
|
38
|
-
containerFileImage: ["containerFileImage"],
|
|
39
|
-
placeHolder: ["placeHolder"],
|
|
40
|
-
containerUploadBoddy: ["containerUploadBoddy"],
|
|
41
|
-
containerBodyImage: ["containerBodyImage"],
|
|
42
|
-
containerMessage: ["containerMessage"],
|
|
43
|
-
containerTitle: ["containerTitle"],
|
|
44
|
-
containerDescription: ["containerDescription"],
|
|
45
|
-
containerConditions: ["containerConditions"],
|
|
46
|
-
containerUploadImage: ["containerUploadImage"],
|
|
47
|
-
skeleton: ["skeleton"],
|
|
48
|
-
inputDropZone: ["inputDropZone"]
|
|
49
|
-
};
|
|
50
|
-
const composedClasses = unstable_composeClasses(slots, getRHFUploadImagebUtilityClass, {});
|
|
51
|
-
return {
|
|
52
|
-
...composedClasses
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export {
|
|
56
|
-
RHFUploadImageUtilityClasses as R
|
|
57
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { RHFUploadImageUtilityClasses } from '.';
|
|
2
|
-
export interface RHFUploadImageClassesType {
|
|
3
|
-
root: string;
|
|
4
|
-
dropZoneStyle: string;
|
|
5
|
-
containerFileImage: string;
|
|
6
|
-
placeHolder: string;
|
|
7
|
-
containerUploadBoddy: string;
|
|
8
|
-
containerBodyImage: string;
|
|
9
|
-
containerMessage: string;
|
|
10
|
-
containerTitle: string;
|
|
11
|
-
containerDescription: string;
|
|
12
|
-
containerConditions: string;
|
|
13
|
-
containerUploadImage: string;
|
|
14
|
-
skeleton: string;
|
|
15
|
-
inputDropZone: string;
|
|
16
|
-
}
|
|
17
|
-
export type RHFUploadImageClassesKey = keyof RHFUploadImageClassesType;
|
|
18
|
-
export type Classes = ReturnType<typeof RHFUploadImageUtilityClasses>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const WrapperRHFUploadImage: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import isString from "lodash-es/isString";
|
|
3
|
-
import { useDropzone } from "react-dropzone";
|
|
4
|
-
import { I as Image } from "../../../../../Image/Image.js";
|
|
5
|
-
import { useEnvironment, useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
6
|
-
import { U as UploadImageRoot } from "./styles.js";
|
|
7
|
-
import { S as SkeletonUploadImage } from "./subcomponents/Skeleton/index.js";
|
|
8
|
-
import { R as RHFUploadImageUtilityClasses } from "../../classes/index.js";
|
|
9
|
-
import { g as getNameRHFUploadImageDataTestId } from "../../tests/utils.js";
|
|
10
|
-
import { T as TEST_PROP_ID } from "../../../../../../test/constants_no_mock.js";
|
|
11
|
-
import { T as Typography } from "../../../../../mui_extended/Typography/Typography.js";
|
|
12
|
-
import { B as Button } from "../../../../../mui_extended/Button/Button.js";
|
|
13
|
-
function UploadImage({ error, file, helperText, sx, ...other }) {
|
|
14
|
-
const { getRootProps, getInputProps, isDragActive, isDragReject, open } = useDropzone({
|
|
15
|
-
multiple: false,
|
|
16
|
-
...other
|
|
17
|
-
});
|
|
18
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
19
|
-
const { getLabel } = useModuleDictionary();
|
|
20
|
-
const isSkeleton = useModuleSkeleton();
|
|
21
|
-
const ownerSate = {
|
|
22
|
-
isDragReject: isDragReject || error,
|
|
23
|
-
isDragActive,
|
|
24
|
-
hasFile: file
|
|
25
|
-
};
|
|
26
|
-
const classes = RHFUploadImageUtilityClasses(ownerSate);
|
|
27
|
-
return /* @__PURE__ */ jsx(
|
|
28
|
-
UploadImageRoot,
|
|
29
|
-
{
|
|
30
|
-
className: classes.root,
|
|
31
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameRHFUploadImageDataTestId("root") } : {},
|
|
32
|
-
children: !isSkeleton ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
|
-
"está sin skeleton",
|
|
34
|
-
/* @__PURE__ */ jsx(
|
|
35
|
-
"div",
|
|
36
|
-
{
|
|
37
|
-
className: classes.containerUploadImage,
|
|
38
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
39
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("containerUploadImage")
|
|
40
|
-
} : {},
|
|
41
|
-
children: /* @__PURE__ */ jsxs(
|
|
42
|
-
"div",
|
|
43
|
-
{
|
|
44
|
-
className: classes.dropZoneStyle,
|
|
45
|
-
...getRootProps(),
|
|
46
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
47
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("dropZoneStyle")
|
|
48
|
-
} : {},
|
|
49
|
-
children: [
|
|
50
|
-
/* @__PURE__ */ jsx(
|
|
51
|
-
"input",
|
|
52
|
-
{
|
|
53
|
-
...getInputProps(),
|
|
54
|
-
className: classes.inputDropZone,
|
|
55
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
56
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("inputDropZone")
|
|
57
|
-
} : {}
|
|
58
|
-
}
|
|
59
|
-
),
|
|
60
|
-
file && /* @__PURE__ */ jsx(
|
|
61
|
-
"div",
|
|
62
|
-
{
|
|
63
|
-
className: classes.containerFileImage,
|
|
64
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
65
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("containerFileImage")
|
|
66
|
-
} : {},
|
|
67
|
-
children: /* @__PURE__ */ jsx(
|
|
68
|
-
Image,
|
|
69
|
-
{
|
|
70
|
-
alt: "bgImageUploadImage",
|
|
71
|
-
src: isString(file) ? file : file.preview || ""
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
),
|
|
76
|
-
/* @__PURE__ */ jsx(
|
|
77
|
-
"div",
|
|
78
|
-
{
|
|
79
|
-
className: classes.placeHolder,
|
|
80
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
81
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("placeHolder")
|
|
82
|
-
} : {},
|
|
83
|
-
children: /* @__PURE__ */ jsxs(
|
|
84
|
-
"div",
|
|
85
|
-
{
|
|
86
|
-
className: classes.containerUploadBoddy,
|
|
87
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
88
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("containerUploadBoddy")
|
|
89
|
-
} : {},
|
|
90
|
-
children: [
|
|
91
|
-
/* @__PURE__ */ jsx(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
className: classes.containerBodyImage,
|
|
95
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
96
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("containerBodyImage")
|
|
97
|
-
} : {},
|
|
98
|
-
children: /* @__PURE__ */ jsx(
|
|
99
|
-
Image,
|
|
100
|
-
{
|
|
101
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/upload_image/assets/img/upload_image_illustration.svg`
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
/* @__PURE__ */ jsxs(
|
|
107
|
-
"div",
|
|
108
|
-
{
|
|
109
|
-
className: classes.containerMessage,
|
|
110
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
111
|
-
[TEST_PROP_ID]: getNameRHFUploadImageDataTestId("containerMessage")
|
|
112
|
-
} : {},
|
|
113
|
-
children: [
|
|
114
|
-
/* @__PURE__ */ jsx(
|
|
115
|
-
Typography,
|
|
116
|
-
{
|
|
117
|
-
className: classes.containerTitle,
|
|
118
|
-
variant: "subtitle",
|
|
119
|
-
skeletonWidth: "150px",
|
|
120
|
-
children: getLabel("upload_image.title_upload")
|
|
121
|
-
}
|
|
122
|
-
),
|
|
123
|
-
/* @__PURE__ */ jsx(Typography, { className: classes.containerDescription, variant: "body", children: getLabel("upload_image.description") }),
|
|
124
|
-
/* @__PURE__ */ jsx(Typography, { className: classes.containerConditions, variant: "body", children: getLabel("upload_image.conditions") }),
|
|
125
|
-
/* @__PURE__ */ jsx(Button, { onClick: open, label: getLabel("upload_image.label_button") })
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
),
|
|
139
|
-
helperText && helperText
|
|
140
|
-
] }) : /* @__PURE__ */ jsx(SkeletonUploadImage, { classes: classes.skeleton })
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
export {
|
|
145
|
-
UploadImage as U
|
|
146
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const UploadImageRoot: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|