@m4l/components 9.3.40 → 9.3.41

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 (21) hide show
  1. package/components/hook-form/RHFActionsGroup/RHFActionsGroup.js +2 -2
  2. package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +2 -2
  3. package/components/hook-form/RHFCheckbox/RHFCheckbox.js +2 -2
  4. package/components/hook-form/RHFColorPicker/RFHColorPicker.js +2 -2
  5. package/components/hook-form/RHFDatePicker/RHFDatePicker.js +2 -2
  6. package/components/hook-form/RHFDateTime/RHFDateTime.js +2 -2
  7. package/components/hook-form/RHFNumberInput/RHFNumberInput.js +2 -2
  8. package/components/hook-form/RHFPeriod/RHFPeriod.js +2 -2
  9. package/components/hook-form/RHFPeriod/subcomponents/Period/Period.js +1 -0
  10. package/components/hook-form/RHFSelect/RHFSelect.js +2 -2
  11. package/components/hook-form/RHFTextField/RHFTextField.js +2 -2
  12. package/components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.js +2 -2
  13. package/components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js +3 -1
  14. package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js +4 -3
  15. package/components/hook-form/RHFUpload/RHFUploadImage/types.d.ts +4 -0
  16. package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +6 -4
  17. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.js +3 -2
  18. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/types.d.ts +1 -1
  19. package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js +13 -4
  20. package/components/hook-form/RHFUpload/RHFUploadSingleFile/types.d.ts +4 -0
  21. package/package.json +1 -1
@@ -38,7 +38,7 @@ const RHFActionsGroup = (props) => {
38
38
  {
39
39
  name,
40
40
  control,
41
- render: ({ field: { value, onChange }, fieldState: { error } }) => {
41
+ render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => {
42
42
  const currentValue = value ?? null;
43
43
  return /* @__PURE__ */ jsxs(Fragment, { children: [
44
44
  label && /* @__PURE__ */ jsx(
@@ -60,7 +60,7 @@ const RHFActionsGroup = (props) => {
60
60
  actions,
61
61
  value: currentValue,
62
62
  onChange,
63
- disabled,
63
+ disabled: disabled || isSubmitting,
64
64
  ariaLabel,
65
65
  ariaLabelledBy,
66
66
  size,
@@ -73,7 +73,7 @@ function RHFAutocomplete(props) {
73
73
  {
74
74
  name: nameRHF,
75
75
  control,
76
- render: ({ field: { onChange, value }, fieldState: { error } }) => {
76
+ render: ({ field: { onChange, value }, fieldState: { error }, formState: { isSubmitting } }) => {
77
77
  const [inputValue, setInputValue] = useState(
78
78
  getOptionLabelLocal(value)
79
79
  );
@@ -113,7 +113,7 @@ function RHFAutocomplete(props) {
113
113
  },
114
114
  onChangeFilterParmsLocal,
115
115
  refresh,
116
- disabled,
116
+ disabled: disabled || isSubmitting,
117
117
  loading,
118
118
  onOpen: onOpenLocal,
119
119
  onClose: onCloseLocal,
@@ -38,7 +38,7 @@ const RHFCheckbox = forwardRef(function RHFCheckbox2(props, ref) {
38
38
  {
39
39
  name,
40
40
  control,
41
- render: ({ field: { onChange, value }, fieldState: { error } }) => {
41
+ render: ({ field: { onChange, value }, fieldState: { error }, formState: { isSubmitting } }) => {
42
42
  return /* @__PURE__ */ jsxs(Fragment, { children: [
43
43
  label && /* @__PURE__ */ jsx(
44
44
  LabelComponent,
@@ -59,7 +59,7 @@ const RHFCheckbox = forwardRef(function RHFCheckbox2(props, ref) {
59
59
  size: adjustedSize,
60
60
  onChange,
61
61
  checked: value,
62
- disabled: disabled ? true : false,
62
+ disabled: disabled || isSubmitting,
63
63
  disableRipple: true,
64
64
  inlineText,
65
65
  htmlFor: finalId,
@@ -45,7 +45,7 @@ const RHFColorPicker = (props) => {
45
45
  name,
46
46
  control,
47
47
  defaultValue: "",
48
- render: ({ field: { value, onChange }, fieldState: { error } }) => /* @__PURE__ */ jsx(
48
+ render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => /* @__PURE__ */ jsx(
49
49
  ColorPickerField,
50
50
  {
51
51
  value,
@@ -56,7 +56,7 @@ const RHFColorPicker = (props) => {
56
56
  mandatory,
57
57
  mandatoryMessage,
58
58
  helperMessage,
59
- disabled,
59
+ disabled: disabled || isSubmitting,
60
60
  isSkeleton,
61
61
  className,
62
62
  instaceDataTestId,
@@ -40,7 +40,7 @@ const RHFDatePicker = (props) => {
40
40
  name,
41
41
  control,
42
42
  defaultValue: null,
43
- render: ({ field: { value, onChange }, fieldState: { error } }) => /* @__PURE__ */ jsxs(Fragment, { children: [
43
+ render: ({ field: { value, onChange }, fieldState: { error }, formState: { isSubmitting } }) => /* @__PURE__ */ jsxs(Fragment, { children: [
44
44
  label && /* @__PURE__ */ jsx(
45
45
  Label,
46
46
  {
@@ -62,7 +62,7 @@ const RHFDatePicker = (props) => {
62
62
  readOnly,
63
63
  error,
64
64
  size: currentSize,
65
- disabled,
65
+ disabled: disabled || isSubmitting,
66
66
  className
67
67
  }
68
68
  ),
@@ -43,7 +43,7 @@ function RHFDateTime(props) {
43
43
  {
44
44
  name: nameRHF,
45
45
  control,
46
- render: ({ field: { value, onChange, ref }, fieldState: { error } }) => {
46
+ render: ({ field: { value, onChange, ref }, fieldState: { error }, formState: { isSubmitting } }) => {
47
47
  return /* @__PURE__ */ jsxs(Fragment, { children: [
48
48
  label && /* @__PURE__ */ jsx(
49
49
  Label,
@@ -62,7 +62,7 @@ function RHFDateTime(props) {
62
62
  {
63
63
  variant,
64
64
  size: adjustedSize,
65
- disabled,
65
+ disabled: disabled || isSubmitting,
66
66
  inputRef: ref,
67
67
  slotProps: {
68
68
  field: {
@@ -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
@@ -124,6 +124,7 @@ const Period = (props) => {
124
124
  variant: "outlined",
125
125
  value: singleValue,
126
126
  withDecimal: true,
127
+ disabled,
127
128
  onChange: (_event, newValue) => {
128
129
  onTotalChange(selPeriodTime, newValue);
129
130
  }
@@ -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,
@@ -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;
@@ -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 && !!file) {
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'> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.40",
3
+ "version": "9.3.41",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {