@m4l/components 9.3.40 → 9.3.41-JT04122025.beta.2
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/components/DataGrid/DataGrid.js +7 -1
- package/components/DataGrid/contexts/DataGridContext/index.js +56 -275
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +24 -23
- package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.d.ts +19 -0
- package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.js +6 -0
- package/components/DataGrid/helpers/getAllViewModes/getAllViewModes.test.d.ts +1 -0
- package/components/DataGrid/helpers/getAllViewModes/index.d.ts +1 -0
- package/components/DataGrid/helpers/getAllViewModes/index.js +1 -0
- package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.d.ts +47 -0
- package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.js +32 -0
- package/components/DataGrid/helpers/getColumnsWidth/getColumnsWidth.test.d.ts +1 -0
- package/components/DataGrid/helpers/getColumnsWidth/index.d.ts +1 -0
- package/components/DataGrid/helpers/getColumnsWidth/index.js +1 -0
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.d.ts +24 -0
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.js +12 -0
- package/components/DataGrid/helpers/getIndexRowHeightVariant/getIndexRowHeightVariant.test.d.ts +1 -0
- package/components/DataGrid/helpers/getIndexRowHeightVariant/index.d.ts +1 -0
- package/components/DataGrid/helpers/getIndexRowHeightVariant/index.js +1 -0
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.d.ts +48 -0
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.js +35 -0
- package/components/DataGrid/helpers/getInitialColumnsConfig/getInitialColumnsConfig.test.d.ts +1 -0
- package/components/DataGrid/helpers/getInitialColumnsConfig/index.d.ts +1 -0
- package/components/DataGrid/helpers/getInitialColumnsConfig/index.js +1 -0
- package/components/DataGrid/helpers/getViewMode/getViewMode.d.ts +41 -0
- package/components/DataGrid/helpers/getViewMode/getViewMode.js +19 -0
- package/components/DataGrid/helpers/getViewMode/getViewMode.test.d.ts +1 -0
- package/components/DataGrid/helpers/getViewMode/index.d.ts +1 -0
- package/components/DataGrid/helpers/getViewMode/index.js +1 -0
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.d.ts +28 -0
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.js +22 -0
- package/components/DataGrid/helpers/getViewSpecificConfig/getViewSpecificConfig.test.d.ts +1 -0
- package/components/DataGrid/helpers/getViewSpecificConfig/index.d.ts +1 -0
- package/components/DataGrid/helpers/getViewSpecificConfig/index.js +1 -0
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.d.ts +24 -0
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.js +9 -0
- package/components/DataGrid/helpers/getViewSuffix/getViewSuffix.test.d.ts +1 -0
- package/components/DataGrid/helpers/getViewSuffix/index.d.ts +1 -0
- package/components/DataGrid/helpers/getViewSuffix/index.js +1 -0
- package/components/DataGrid/helpers/index.d.ts +13 -0
- package/components/DataGrid/helpers/index.js +1 -0
- package/components/DataGrid/helpers/loadViewConfig/index.d.ts +1 -0
- package/components/DataGrid/helpers/loadViewConfig/index.js +1 -0
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.d.ts +23 -0
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.js +12 -0
- package/components/DataGrid/helpers/loadViewConfig/loadViewConfig.test.d.ts +1 -0
- package/components/DataGrid/helpers/saveColumnsWidth/index.d.ts +1 -0
- package/components/DataGrid/helpers/saveColumnsWidth/index.js +1 -0
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.d.ts +52 -0
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.js +18 -0
- package/components/DataGrid/helpers/saveColumnsWidth/saveColumnsWidth.test.d.ts +1 -0
- package/components/DataGrid/helpers/saveViewConfig/index.d.ts +1 -0
- package/components/DataGrid/helpers/saveViewConfig/index.js +1 -0
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.d.ts +35 -0
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.js +15 -0
- package/components/DataGrid/helpers/saveViewConfig/saveViewConfig.test.d.ts +1 -0
- package/components/DataGrid/helpers/saveViewMode/index.d.ts +1 -0
- package/components/DataGrid/helpers/saveViewMode/index.js +1 -0
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.d.ts +33 -0
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.js +13 -0
- package/components/DataGrid/helpers/saveViewMode/saveViewMode.test.d.ts +1 -0
- package/components/DataGrid/hooks/index.d.ts +6 -0
- package/components/DataGrid/hooks/index.js +1 -0
- package/components/DataGrid/hooks/useChangeColumnsConfig/index.d.ts +1 -0
- package/components/DataGrid/hooks/useChangeColumnsConfig/index.js +1 -0
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.d.ts +9 -0
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.js +27 -0
- package/components/DataGrid/hooks/useChangeColumnsConfig/useChangeColumnsConfig.test.d.ts +1 -0
- package/components/DataGrid/hooks/useChangeColumnsOrder/index.d.ts +1 -0
- package/components/DataGrid/hooks/useChangeColumnsOrder/index.js +1 -0
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.d.ts +10 -0
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.js +34 -0
- package/components/DataGrid/hooks/useChangeColumnsOrder/useChangeColumnsOrder.test.d.ts +1 -0
- package/components/DataGrid/hooks/useColumnsWidth/index.d.ts +1 -0
- package/components/DataGrid/hooks/useColumnsWidth/index.js +1 -0
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.d.ts +11 -0
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.js +29 -0
- package/components/DataGrid/hooks/useColumnsWidth/useColumnsWidth.test.d.ts +1 -0
- package/components/DataGrid/hooks/useRowHeight/index.d.ts +1 -0
- package/components/DataGrid/hooks/useRowHeight/index.js +1 -0
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.d.ts +28 -0
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.js +51 -0
- package/components/DataGrid/hooks/useRowHeight/useRowHeight.test.d.ts +1 -0
- package/components/DataGrid/hooks/useViewConfig/index.d.ts +1 -0
- package/components/DataGrid/hooks/useViewConfig/index.js +1 -0
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.d.ts +9 -0
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.js +30 -0
- package/components/DataGrid/hooks/useViewConfig/useViewConfig.test.d.ts +1 -0
- package/components/DataGrid/hooks/useViewMode/index.d.ts +1 -0
- package/components/DataGrid/hooks/useViewMode/index.js +1 -0
- package/components/DataGrid/hooks/useViewMode/useViewMode.d.ts +31 -0
- package/components/DataGrid/hooks/useViewMode/useViewMode.js +44 -0
- package/components/DataGrid/hooks/useViewMode/useViewMode.test.d.ts +1 -0
- package/components/DataGrid/index.d.ts +5 -4
- package/components/DataGrid/types.d.ts +30 -6
- package/components/DataGrid/types.helpers.d.ts +55 -0
- package/components/DataGrid/types.helpers.js +1 -0
- package/components/DataGrid/types.hooks.d.ts +81 -0
- package/components/hook-form/RHFActionsGroup/RHFActionsGroup.js +2 -2
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +2 -2
- package/components/hook-form/RHFCheckbox/RHFCheckbox.js +2 -2
- package/components/hook-form/RHFColorPicker/RFHColorPicker.js +2 -2
- package/components/hook-form/RHFDatePicker/RHFDatePicker.js +2 -2
- package/components/hook-form/RHFDateTime/RHFDateTime.js +2 -2
- package/components/hook-form/RHFNumberInput/RHFNumberInput.js +2 -2
- package/components/hook-form/RHFPeriod/RHFPeriod.js +2 -2
- package/components/hook-form/RHFPeriod/subcomponents/Period/Period.js +1 -0
- package/components/hook-form/RHFSelect/RHFSelect.js +2 -2
- package/components/hook-form/RHFTextField/RHFTextField.js +2 -2
- package/components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.js +2 -2
- package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js +3 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js +4 -3
- package/components/hook-form/RHFUpload/RHFUploadImage/types.d.ts +4 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +6 -4
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.js +3 -2
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/types.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js +13 -4
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/types.d.ts +4 -0
- package/hooks/useDataGridPersistence/constants.d.ts +1 -0
- package/hooks/useDataGridPersistence/constants.js +4 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts +11 -3
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +13 -6
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ const RHFNumberInput = (props) => {
|
|
|
42
42
|
{
|
|
43
43
|
name,
|
|
44
44
|
control,
|
|
45
|
-
render: ({ field: { value, onChange }, fieldState: { error } }) => {
|
|
45
|
+
render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
46
46
|
const onChangeLocal = (_event, newValue) => {
|
|
47
47
|
onChange(newValue);
|
|
48
48
|
};
|
|
@@ -69,7 +69,7 @@ const RHFNumberInput = (props) => {
|
|
|
69
69
|
value,
|
|
70
70
|
onChange: onChangeLocal,
|
|
71
71
|
variant,
|
|
72
|
-
disabled,
|
|
72
|
+
disabled: disabled || isSubmitting,
|
|
73
73
|
startAdornment,
|
|
74
74
|
endAdornment,
|
|
75
75
|
error: !!error,
|
|
@@ -47,7 +47,7 @@ const RHFPeriod = (props) => {
|
|
|
47
47
|
name: name || "",
|
|
48
48
|
control,
|
|
49
49
|
defaultValue: { selPeriodTime: "", singleValue: "" },
|
|
50
|
-
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
50
|
+
render: ({ field: { onChange, value }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
51
51
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52
52
|
label && /* @__PURE__ */ jsx(
|
|
53
53
|
Label,
|
|
@@ -64,7 +64,7 @@ const RHFPeriod = (props) => {
|
|
|
64
64
|
{
|
|
65
65
|
name,
|
|
66
66
|
control,
|
|
67
|
-
disabled,
|
|
67
|
+
disabled: disabled || isSubmitting,
|
|
68
68
|
value,
|
|
69
69
|
onChange,
|
|
70
70
|
size
|
|
@@ -36,7 +36,7 @@ const RHFSelect = (props) => {
|
|
|
36
36
|
{
|
|
37
37
|
name,
|
|
38
38
|
control,
|
|
39
|
-
render: ({ field: { value, onChange, ref }, fieldState: { error } }) => {
|
|
39
|
+
render: ({ field: { value, onChange, ref }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
40
40
|
const onChangeLocal = (opt) => {
|
|
41
41
|
if (!opt) {
|
|
42
42
|
onChange(null);
|
|
@@ -75,7 +75,7 @@ const RHFSelect = (props) => {
|
|
|
75
75
|
variant,
|
|
76
76
|
value,
|
|
77
77
|
onChange: onChangeLocal,
|
|
78
|
-
disabled,
|
|
78
|
+
disabled: disabled || isSubmitting,
|
|
79
79
|
className: RHFSELECT_CLASSES.select,
|
|
80
80
|
error: Boolean(error),
|
|
81
81
|
placeholder,
|
|
@@ -60,7 +60,7 @@ const RHFTextField = forwardRef((props, ref) => {
|
|
|
60
60
|
{
|
|
61
61
|
name,
|
|
62
62
|
control,
|
|
63
|
-
render: ({ field: { onChange, value, ref: inputRef }, fieldState: { error } }) => {
|
|
63
|
+
render: ({ field: { onChange, value, ref: inputRef }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
64
64
|
const onInternalChange = (event) => {
|
|
65
65
|
const finalValue = other.maxLength ? getLimitCharacters({ limitCharacters: other.maxLength, value: event.target.value }) : event.target.value;
|
|
66
66
|
const stringValue = String(finalValue || "");
|
|
@@ -83,7 +83,7 @@ const RHFTextField = forwardRef((props, ref) => {
|
|
|
83
83
|
TextFieldStyled,
|
|
84
84
|
{
|
|
85
85
|
ownerState: { ...ownerState, error: !!error },
|
|
86
|
-
disabled,
|
|
86
|
+
disabled: disabled || isSubmitting,
|
|
87
87
|
inputRef,
|
|
88
88
|
ref,
|
|
89
89
|
InputLabelProps: { shrink: true },
|
|
@@ -28,7 +28,7 @@ const RHFTextFieldPassword = (props) => {
|
|
|
28
28
|
{
|
|
29
29
|
name,
|
|
30
30
|
control,
|
|
31
|
-
render: ({ field: { onChange, value, ref }, fieldState: { error } }) => {
|
|
31
|
+
render: ({ field: { onChange, value, ref }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
32
32
|
const onInternalChange = (event) => {
|
|
33
33
|
const finalValue = other.maxLength ? getLimitCharacters({ limitCharacters: other.maxLength, value: event.target.value }) : event.target.value;
|
|
34
34
|
const stringValue = String(finalValue || "");
|
|
@@ -56,7 +56,7 @@ const RHFTextFieldPassword = (props) => {
|
|
|
56
56
|
type: showPassword ? "text" : "password",
|
|
57
57
|
size,
|
|
58
58
|
error: !!error,
|
|
59
|
-
disabled,
|
|
59
|
+
disabled: disabled || isSubmitting,
|
|
60
60
|
inputProps: {
|
|
61
61
|
role: "textbox",
|
|
62
62
|
"aria-label": name,
|
|
@@ -15,6 +15,7 @@ function RHFUploadImage(props) {
|
|
|
15
15
|
mandatoryMessage,
|
|
16
16
|
maxSize,
|
|
17
17
|
helperMessage,
|
|
18
|
+
disabled,
|
|
18
19
|
...other
|
|
19
20
|
} = props;
|
|
20
21
|
const { currentSize } = useComponentSize(size);
|
|
@@ -25,7 +26,7 @@ function RHFUploadImage(props) {
|
|
|
25
26
|
{
|
|
26
27
|
name,
|
|
27
28
|
control,
|
|
28
|
-
render: ({ field: { value, onChange }, fieldState: { error } }) => {
|
|
29
|
+
render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
29
30
|
const checkError = !!error && !value;
|
|
30
31
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
32
|
label && /* @__PURE__ */ jsx(
|
|
@@ -56,6 +57,7 @@ function RHFUploadImage(props) {
|
|
|
56
57
|
onChange(null);
|
|
57
58
|
},
|
|
58
59
|
error: checkError,
|
|
60
|
+
disabled: disabled || isSubmitting,
|
|
59
61
|
...other,
|
|
60
62
|
file: value,
|
|
61
63
|
size: adjustedSize,
|
package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js
CHANGED
|
@@ -12,7 +12,7 @@ import { u as useComponentSize } from "../../../../../../hooks/useComponentSize/
|
|
|
12
12
|
import { g as getComponentClasses } from "../../../../../../utils/getComponentSlotRoot.js";
|
|
13
13
|
import { T as Typography } from "../../../../../mui_extended/Typography/Typography.js";
|
|
14
14
|
const UploadImage = (props) => {
|
|
15
|
-
const { file, size, onDrop, onRemove, maxSize, dataTestId, error = false, multiple, ...other } = props;
|
|
15
|
+
const { file, size, onDrop, onRemove, maxSize, dataTestId, error = false, multiple, disabled, ...other } = props;
|
|
16
16
|
const { currentSize } = useComponentSize(size);
|
|
17
17
|
const { toast } = useHostTools();
|
|
18
18
|
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
@@ -62,7 +62,8 @@ const UploadImage = (props) => {
|
|
|
62
62
|
variant: "contained",
|
|
63
63
|
icon: `${host_static_assets}/${environment_assets}/frontend/components/chip/assets/icons/closeSmall.svg`,
|
|
64
64
|
onClick: onRemove,
|
|
65
|
-
size: adjustedSize
|
|
65
|
+
size: adjustedSize,
|
|
66
|
+
disabled
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
69
|
/* @__PURE__ */ jsx(
|
|
@@ -100,7 +101,7 @@ const UploadImage = (props) => {
|
|
|
100
101
|
] })
|
|
101
102
|
] })
|
|
102
103
|
] }),
|
|
103
|
-
!file ? /* @__PURE__ */ jsx(ButtonStyled, { variant: "contained", color: "primary", onClick: open, label: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.click_button)), size: adjustedSize }) : null
|
|
104
|
+
!file ? /* @__PURE__ */ jsx(ButtonStyled, { variant: "contained", color: "primary", onClick: open, label: getLabel(getUploadImageDictionary(COMPONENTS_DICTIONARY_KEYS.click_button)), size: adjustedSize, disabled }) : null
|
|
104
105
|
]
|
|
105
106
|
}
|
|
106
107
|
)
|
|
@@ -6,6 +6,10 @@ import { UploadImageProps } from './subcomponents/UploadImage/types';
|
|
|
6
6
|
import { M4LOverridesStyleRules } from '../../../../@types/augmentations';
|
|
7
7
|
export interface RHFUploadImageProps extends Omit<UploadImageProps, 'file' | 'onDrop' | 'onRemove'>, Omit<LabelProps, 'size' | 'error' | 'disabled' | 'children'> {
|
|
8
8
|
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Si es true, el componente estará deshabilitado.
|
|
11
|
+
*/
|
|
12
|
+
disabled?: boolean;
|
|
9
13
|
}
|
|
10
14
|
export type RHFUploadImageSlotsType = keyof typeof Slots;
|
|
11
15
|
export type RHFUploadImageOwnerState = {
|
|
@@ -9,7 +9,7 @@ import { R as RHFUploadSingleFileSlots } from "./slots/RHFUploadSingleFileEnum.j
|
|
|
9
9
|
import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
|
|
10
10
|
function RHFUploadSingleFile(props) {
|
|
11
11
|
const { control } = useFormContext();
|
|
12
|
-
const { name, label, skeletonWidth, size, className, helperMessage, mandatory, mandatoryMessage, maxFileSize = DEFAULT_MAX_FILE_SIZE, dataTestId, accept = "*/*" } = props;
|
|
12
|
+
const { name, label, skeletonWidth, size, className, helperMessage, mandatory, mandatoryMessage, maxFileSize = DEFAULT_MAX_FILE_SIZE, dataTestId, accept = "*/*", disabled } = props;
|
|
13
13
|
const { currentSize } = useComponentSize(size);
|
|
14
14
|
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
15
15
|
const acceptObj = {
|
|
@@ -28,7 +28,7 @@ function RHFUploadSingleFile(props) {
|
|
|
28
28
|
{
|
|
29
29
|
name,
|
|
30
30
|
control,
|
|
31
|
-
render: ({ field: { value, onChange }, fieldState: { error } }) => {
|
|
31
|
+
render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => {
|
|
32
32
|
const errorUpload = !!error;
|
|
33
33
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34
34
|
label && /* @__PURE__ */ jsx(
|
|
@@ -41,7 +41,8 @@ function RHFUploadSingleFile(props) {
|
|
|
41
41
|
mandatoryMessage,
|
|
42
42
|
helperMessage,
|
|
43
43
|
size: adjustedSize,
|
|
44
|
-
skeletonWidth
|
|
44
|
+
skeletonWidth,
|
|
45
|
+
disabled
|
|
45
46
|
}
|
|
46
47
|
),
|
|
47
48
|
/* @__PURE__ */ jsx(
|
|
@@ -51,7 +52,8 @@ function RHFUploadSingleFile(props) {
|
|
|
51
52
|
accept: acceptObj,
|
|
52
53
|
file: value,
|
|
53
54
|
onChange,
|
|
54
|
-
size: adjustedSize
|
|
55
|
+
size: adjustedSize,
|
|
56
|
+
disabled: disabled || isSubmitting
|
|
55
57
|
}
|
|
56
58
|
),
|
|
57
59
|
errorUpload && /* @__PURE__ */ jsx(
|
|
@@ -4,7 +4,7 @@ import { d as ContainerPreviewStyled, e as ImagePreviewStyled, f as ContainerNam
|
|
|
4
4
|
import { useEnvironment } from "@m4l/core";
|
|
5
5
|
import { f as formatFileSize } from "../../helpers/formatFileSize.js";
|
|
6
6
|
const Preview = (props) => {
|
|
7
|
-
const { file, onChange, onClose } = props;
|
|
7
|
+
const { file, onChange, onClose, disabled } = props;
|
|
8
8
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
9
9
|
const icon = `${host_static_assets}/${environment_assets}/${FILES_ICONS[file.type] || FILES_ICONS["application/octet-stream"]}`;
|
|
10
10
|
const closePreviewIcon = `${host_static_assets}/${environment_assets}/${CLOSE_PREVIEW_ICON}`;
|
|
@@ -25,7 +25,8 @@ const Preview = (props) => {
|
|
|
25
25
|
e.stopPropagation();
|
|
26
26
|
onChange && onChange(null);
|
|
27
27
|
onClose();
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
disabled
|
|
29
30
|
}
|
|
30
31
|
)
|
|
31
32
|
] });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UploadSingleFileProps } from '../UploadSingleFile/types';
|
|
2
|
-
export interface PreviewProps extends Pick<UploadSingleFileProps, 'onChange' | 'size'> {
|
|
2
|
+
export interface PreviewProps extends Pick<UploadSingleFileProps, 'onChange' | 'size' | 'disabled'> {
|
|
3
3
|
uploadProgress: number | null;
|
|
4
4
|
file: File;
|
|
5
5
|
onClose: () => void;
|
package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { u as uploadReducer } from "../../helpers/uploadReducer.js";
|
|
|
11
11
|
import { f as formatFileSize } from "../../helpers/formatFileSize.js";
|
|
12
12
|
import { g as getReadableFileType } from "../../helpers/getReadableFileType.js";
|
|
13
13
|
function UploadSingleFile(props) {
|
|
14
|
-
const { file, accept, onChange, maxFileSize, size } = props;
|
|
14
|
+
const { file, accept, onChange, maxFileSize, size, disabled } = props;
|
|
15
15
|
const { toast } = useHostTools();
|
|
16
16
|
const { getLabel } = useModuleDictionary();
|
|
17
17
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -22,6 +22,7 @@ function UploadSingleFile(props) {
|
|
|
22
22
|
});
|
|
23
23
|
const { getRootProps, getInputProps } = useDropzone({
|
|
24
24
|
multiple: false,
|
|
25
|
+
disabled,
|
|
25
26
|
/**
|
|
26
27
|
* Maneja el evento de drop del archivo
|
|
27
28
|
*/
|
|
@@ -60,9 +61,17 @@ function UploadSingleFile(props) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
});
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!!file && !uploadState.validFile) {
|
|
66
|
+
dispatch({ type: "SET_VALID_FILE", payload: true });
|
|
67
|
+
dispatch({ type: "SET_PREVIEW", payload: true });
|
|
68
|
+
} else if (!file && uploadState.validFile) {
|
|
69
|
+
dispatch({ type: "RESET" });
|
|
70
|
+
}
|
|
71
|
+
}, [file, uploadState.validFile]);
|
|
63
72
|
useEffect(() => {
|
|
64
73
|
let interval;
|
|
65
|
-
if (uploadState.validFile &&
|
|
74
|
+
if (!!file && uploadState.validFile && !uploadState.preview) {
|
|
66
75
|
interval = setInterval(() => {
|
|
67
76
|
dispatch({ type: "SET_PROGRESS", payload: (uploadState.progress ?? 0) + 10 });
|
|
68
77
|
if (uploadState.progress !== null && uploadState.progress >= 100) {
|
|
@@ -77,10 +86,10 @@ function UploadSingleFile(props) {
|
|
|
77
86
|
clearInterval(interval);
|
|
78
87
|
}
|
|
79
88
|
};
|
|
80
|
-
}, [file, uploadState.progress, uploadState.validFile]);
|
|
89
|
+
}, [file, uploadState.progress, uploadState.validFile, uploadState.preview]);
|
|
81
90
|
return /* @__PURE__ */ jsx(ContainerDropZoneStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.containerDropZone, children: /* @__PURE__ */ jsxs(DropZoneStyled, { ...getRootProps(), ownerState: { isSkeleton }, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.dropZone, children: [
|
|
82
91
|
/* @__PURE__ */ jsx(BlockContent, { value: uploadState.progress, hidden: uploadState.preview, size }),
|
|
83
|
-
uploadState.preview && !!file && /* @__PURE__ */ jsx(Preview, { uploadProgress: uploadState.progress, file, onChange, onClose: () => dispatch({ type: "RESET" }), size }),
|
|
92
|
+
uploadState.preview && !!file && /* @__PURE__ */ jsx(Preview, { uploadProgress: uploadState.progress, file, onChange, onClose: () => dispatch({ type: "RESET" }), size, disabled }),
|
|
84
93
|
!isSkeleton && /* @__PURE__ */ jsx("input", { role: "button", "aria-label": "button-upload-single-file", ...getInputProps() })
|
|
85
94
|
] }) });
|
|
86
95
|
}
|
|
@@ -33,6 +33,10 @@ export interface RHFUploadSingleFileProps extends Omit<LabelProps, 'size' | 'err
|
|
|
33
33
|
* Tipos de archivos aceptados.
|
|
34
34
|
*/
|
|
35
35
|
accept?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Si es true, el componente estará deshabilitado.
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
36
40
|
}
|
|
37
41
|
export type RHFUploadSingleFileSlotsType = keyof typeof RHFUploadSingleFileSlots;
|
|
38
42
|
export type RHFUploadSingleFileOwnerState = Pick<RHFUploadSingleFileProps, 'size' | 'variant'> & {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const COOKIE_COLUMNS_WIDTHS = "columns_widths";
|
|
2
2
|
const COOKIE_COLUMNS_CONFIG = "columns_config";
|
|
3
|
+
const COOKIE_VIEW_MODE = "view_mode";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
COOKIE_VIEW_MODE as C,
|
|
6
|
+
COOKIE_COLUMNS_CONFIG as a,
|
|
7
|
+
COOKIE_COLUMNS_WIDTHS as b
|
|
6
8
|
};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { UseDataGridPersistenceProps } from './types';
|
|
2
|
-
import {
|
|
2
|
+
import { ChangeConfig, IGridConfigExtended } from '../../components/DataGrid';
|
|
3
3
|
/**
|
|
4
|
-
* Hook para manejar
|
|
4
|
+
* Hook para manejar la persistencia de configuración del DataGrid en cookies de red.
|
|
5
|
+
*
|
|
6
|
+
* Retorna:
|
|
7
|
+
* - `defaultConfig`: Configuración inicial cargada desde cookies
|
|
8
|
+
* - `onChangeConfig`: Callback para persistir cambios en cookies
|
|
9
|
+
* - `defaultUserColumns`: @deprecated Alias de defaultConfig
|
|
10
|
+
* - `onChangeUserColumns`: @deprecated Alias de onChangeConfig
|
|
5
11
|
*/
|
|
6
12
|
export declare const useDataGridPersistence: (props: UseDataGridPersistenceProps) => {
|
|
7
|
-
|
|
13
|
+
defaultConfig: IGridConfigExtended;
|
|
14
|
+
onChangeConfig: (newProps: ChangeConfig) => void;
|
|
8
15
|
defaultUserColumns: IGridConfigExtended;
|
|
16
|
+
onChangeUserColumns: (newProps: ChangeConfig) => void;
|
|
9
17
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useState, useCallback } from "react";
|
|
2
2
|
import { g as getColumnsConfigCookie } from "./helpers.js";
|
|
3
|
-
import { C as
|
|
3
|
+
import { C as COOKIE_VIEW_MODE, a as COOKIE_COLUMNS_CONFIG, b as COOKIE_COLUMNS_WIDTHS } from "./constants.js";
|
|
4
4
|
import { u as useWindowToolsMF } from "../../components/WindowBase/hooks/useWindowToolsMF/index.js";
|
|
5
5
|
const useDataGridPersistence = (props) => {
|
|
6
6
|
const { prefixCookie } = props;
|
|
7
7
|
const { setCookie, getCookie } = useWindowToolsMF();
|
|
8
|
-
const [
|
|
8
|
+
const [defaultConfig] = useState(() => {
|
|
9
9
|
return {
|
|
10
10
|
columnsWidths: getCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_WIDTHS}` : COOKIE_COLUMNS_WIDTHS) || {},
|
|
11
|
-
columnsConfig: getColumnsConfigCookie(getCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_CONFIG}` : COOKIE_COLUMNS_CONFIG)) || []
|
|
11
|
+
columnsConfig: getColumnsConfigCookie(getCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_CONFIG}` : COOKIE_COLUMNS_CONFIG)) || [],
|
|
12
|
+
viewMode: getCookie(prefixCookie ? `${prefixCookie}_${COOKIE_VIEW_MODE}` : COOKIE_VIEW_MODE) || "table"
|
|
12
13
|
};
|
|
13
14
|
});
|
|
14
|
-
const
|
|
15
|
+
const onChangeConfig = useCallback((newProps) => {
|
|
15
16
|
const { reason, userConfig } = newProps;
|
|
16
17
|
if (userConfig === void 0) {
|
|
17
18
|
return;
|
|
@@ -20,13 +21,19 @@ const useDataGridPersistence = (props) => {
|
|
|
20
21
|
setCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_CONFIG}` : COOKIE_COLUMNS_CONFIG, "window", userConfig);
|
|
21
22
|
} else if (reason === "columnsWidths") {
|
|
22
23
|
setCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_WIDTHS}` : COOKIE_COLUMNS_WIDTHS, "window", userConfig);
|
|
24
|
+
} else if (reason === "viewMode") {
|
|
25
|
+
setCookie(prefixCookie ? `${prefixCookie}_${COOKIE_VIEW_MODE}` : COOKIE_VIEW_MODE, "window", userConfig);
|
|
23
26
|
} else {
|
|
24
27
|
setCookie(prefixCookie ? `${prefixCookie}_${reason}` : reason, "window", userConfig);
|
|
25
28
|
}
|
|
26
29
|
}, [setCookie, prefixCookie]);
|
|
27
30
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
// Nuevos nombres
|
|
32
|
+
defaultConfig,
|
|
33
|
+
onChangeConfig,
|
|
34
|
+
// Deprecated aliases para backward compatibility
|
|
35
|
+
defaultUserColumns: defaultConfig,
|
|
36
|
+
onChangeUserColumns: onChangeConfig
|
|
30
37
|
};
|
|
31
38
|
};
|
|
32
39
|
export {
|