@m4l/components 9.3.16-JT19092025.beta.1 → 9.3.17
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/Stepper/Stepper.styles.js +1 -6
- package/components/Stepper/hooks/useStepperActions/index.js +3 -21
- package/components/Stepper/subcomponents/StepArea/index.js +0 -4
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +1 -2
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +6 -39
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.d.ts +1 -2
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +3 -5
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.d.ts +1 -2
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +3 -5
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.d.ts +1 -2
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +3 -5
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +9 -17
- package/components/Stepper/types.d.ts +0 -7
- package/components/areas/icons.js +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +3 -35
- package/components/hook-form/RHFAutocomplete/types.d.ts +1 -6
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/components/hook-form/RHFormContext/index.js +4 -29
- package/components/index.d.ts +1 -0
- package/components/mui_extended/Autocomplete/Autocomplete.js +12 -6
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +48 -5
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.d.ts +1 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +4 -3
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +4 -4
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +39 -4
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.d.ts +3 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.js +2 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +6 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +11 -1
- package/components/mui_extended/Autocomplete/types.d.ts +1 -1
- package/components/mui_extended/Button/ButtonStyles.js +3 -6
- package/components/mui_extended/Popper/Popper.js +9 -2
- package/components/mui_extended/Popper/types.d.ts +1 -0
- package/components/mui_extended/Select/Select.js +17 -10
- package/components/mui_extended/Select/Select.styles.js +17 -10
- package/components/mui_extended/Select/types.d.ts +1 -1
- package/components/mui_extended/TextField/TextField.d.ts +2 -1
- package/components/mui_extended/TextField/TextField.js +25 -4
- package/components/mui_extended/TextField/TextField.styles.js +132 -125
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +3 -9
- package/components/mui_extended/TextField/slots/TextFieldSlots.js +2 -1
- package/components/mui_extended/Typography/Typography.js +1 -1
- package/package.json +1 -1
- package/test/mocks/dictionary-mock.d.ts +433 -0
- package/components/Stepper/hooks/useDynamicValidation/index.d.ts +0 -9
- package/components/Stepper/hooks/useDynamicValidation/index.js +0 -57
|
@@ -24,13 +24,8 @@ const stepperStyles = {
|
|
|
24
24
|
flexDirection: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "column" : "row",
|
|
25
25
|
gap: theme.vars.size.baseSpacings.sp8
|
|
26
26
|
}),
|
|
27
|
-
/**
|
|
28
|
-
* Estilos para el contenido del paso dentro del Stepper.
|
|
29
|
-
*/
|
|
30
27
|
stepContent: ({ ownerState }) => ({
|
|
31
|
-
|
|
32
|
-
display: ownerState?.isStepVisible ? "flex" : "none",
|
|
33
|
-
flexDirection: "column"
|
|
28
|
+
display: ownerState?.isStepVisible ? "block" : "none"
|
|
34
29
|
}),
|
|
35
30
|
/**
|
|
36
31
|
* Estilos para la sección que contiene los botones de acción del Stepper.
|
|
@@ -2,10 +2,8 @@ import { useCallback } from "react";
|
|
|
2
2
|
import { u as useStepper } from "../useStepper/index.js";
|
|
3
3
|
import { useFormContext } from "react-hook-form";
|
|
4
4
|
import { shallow } from "zustand/shallow";
|
|
5
|
-
import { u as useDynamicValidation } from "../useDynamicValidation/index.js";
|
|
6
5
|
function useStepperActions() {
|
|
7
6
|
const { trigger, clearErrors, getValues, reset } = useFormContext();
|
|
8
|
-
const { activateFieldsValidation, clearAllValidation } = useDynamicValidation();
|
|
9
7
|
const {
|
|
10
8
|
nextStep,
|
|
11
9
|
prevStep,
|
|
@@ -43,22 +41,9 @@ function useStepperActions() {
|
|
|
43
41
|
if (fieldsToValidate.length === 0) {
|
|
44
42
|
return true;
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
if (!result) {
|
|
48
|
-
activateFieldsValidation(fieldsToValidate);
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
44
|
+
return await trigger(fieldsToValidate);
|
|
51
45
|
};
|
|
52
46
|
const success = await nextStep(validateFn, formData);
|
|
53
|
-
if (success) {
|
|
54
|
-
const currentStepData = steps[currentStep - 1];
|
|
55
|
-
const fieldsJustValidated = currentStepData?.validationFields || [];
|
|
56
|
-
if (fieldsJustValidated.length > 0) {
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
clearAllValidation();
|
|
59
|
-
}, 100);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
47
|
if (success && futureFields.length > 0) {
|
|
63
48
|
clearErrors(futureFields);
|
|
64
49
|
setTimeout(() => {
|
|
@@ -77,16 +62,13 @@ function useStepperActions() {
|
|
|
77
62
|
steps,
|
|
78
63
|
currentStep,
|
|
79
64
|
trigger,
|
|
80
|
-
getValues
|
|
81
|
-
activateFieldsValidation,
|
|
82
|
-
clearAllValidation
|
|
65
|
+
getValues
|
|
83
66
|
]);
|
|
84
67
|
const cancelAction = useCallback(() => {
|
|
85
68
|
reset();
|
|
86
69
|
clearErrors();
|
|
87
|
-
clearAllValidation();
|
|
88
70
|
resetStepper();
|
|
89
|
-
}, [reset, clearErrors,
|
|
71
|
+
}, [reset, clearErrors, resetStepper]);
|
|
90
72
|
return { prevStepAction, nextStepAction, cancelAction };
|
|
91
73
|
}
|
|
92
74
|
export {
|
|
@@ -5,12 +5,10 @@ import { u as useStepper } from "../../hooks/useStepper/index.js";
|
|
|
5
5
|
import { e as StepAreaStyled, f as StepStyled, g as StepNameStyled } from "../../slots/StepperSlot.js";
|
|
6
6
|
import { I as Indicator } from "./subcomponents/Inidicator/index.js";
|
|
7
7
|
import { shallow } from "zustand/shallow";
|
|
8
|
-
import { u as useDynamicValidation } from "../../hooks/useDynamicValidation/index.js";
|
|
9
8
|
import { e as evaluateVisibilityStepCondition } from "../../helpers/evaluateVisibilityStepCondition/index.js";
|
|
10
9
|
function StepArea() {
|
|
11
10
|
const { trigger, clearErrors } = useFormContext();
|
|
12
11
|
const formValues = useWatch();
|
|
13
|
-
const { activateFieldsValidation } = useDynamicValidation();
|
|
14
12
|
const {
|
|
15
13
|
currentStep,
|
|
16
14
|
steps,
|
|
@@ -66,7 +64,6 @@ function StepArea() {
|
|
|
66
64
|
if (!isValid) {
|
|
67
65
|
setCurrentStep(stepOriginalIndex);
|
|
68
66
|
setStepValidationStatus(stepOriginalIndex, false);
|
|
69
|
-
activateFieldsValidation(step.validationFields || []);
|
|
70
67
|
return;
|
|
71
68
|
}
|
|
72
69
|
setStepValidationStatus(stepOriginalIndex, true);
|
|
@@ -79,7 +76,6 @@ function StepArea() {
|
|
|
79
76
|
const isCurrentValid = await trigger(currentStepData.validationFields);
|
|
80
77
|
if (!isCurrentValid) {
|
|
81
78
|
setStepValidationStatus(currentStepOriginalIndex, false);
|
|
82
|
-
activateFieldsValidation(currentStepData.validationFields || []);
|
|
83
79
|
return;
|
|
84
80
|
}
|
|
85
81
|
setStepValidationStatus(currentStepOriginalIndex, true);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StepperButtonProps } from '../../../types';
|
|
2
1
|
/**
|
|
3
2
|
* Botón modular para cancelar el proceso del Stepper
|
|
4
3
|
*/
|
|
5
|
-
export declare function StepperCancelButton(
|
|
4
|
+
export declare function StepperCancelButton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,55 +1,22 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
import { useFormContext, useFormState } from "react-hook-form";
|
|
4
2
|
import { u as useStepperActions } from "../../../hooks/useStepperActions/index.js";
|
|
5
|
-
import { D as DICTIONARY
|
|
6
|
-
import { D as DICTIONARY } from "../../../../CommonActions/dictionary.js";
|
|
3
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
7
4
|
import { useModuleDictionary } from "@m4l/core";
|
|
8
|
-
import { u as useModal } from "../../../../../hooks/useModal/index.js";
|
|
9
|
-
import { u as useWindowToolsMF } from "../../../../WindowBase/hooks/useWindowToolsMF/index.js";
|
|
10
|
-
import { W as WindowConfirm } from "../../../../WindowConfirm/WindowConfirm.js";
|
|
11
5
|
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
12
|
-
function StepperCancelButton(
|
|
13
|
-
const { label, ...rest } = props;
|
|
6
|
+
function StepperCancelButton() {
|
|
14
7
|
const { getLabel } = useModuleDictionary();
|
|
15
8
|
const { cancelAction } = useStepperActions();
|
|
16
|
-
const
|
|
17
|
-
const { close: closeWindow } = useWindowToolsMF();
|
|
18
|
-
const { control } = useFormContext();
|
|
19
|
-
const { isDirty } = useFormState({
|
|
20
|
-
control
|
|
21
|
-
});
|
|
22
|
-
const onConfirmQuit = useCallback(() => {
|
|
9
|
+
const handleCancel = () => {
|
|
23
10
|
cancelAction();
|
|
24
|
-
|
|
25
|
-
}, [cancelAction, closeWindow]);
|
|
26
|
-
const handleCancel = useCallback(() => {
|
|
27
|
-
if (isDirty) {
|
|
28
|
-
openModal({
|
|
29
|
-
window: /* @__PURE__ */ jsx(
|
|
30
|
-
WindowConfirm,
|
|
31
|
-
{
|
|
32
|
-
variant: "warning",
|
|
33
|
-
title: getLabel(DICTIONARY.CONFIRM_QUIT_TITLE),
|
|
34
|
-
msg: getLabel(DICTIONARY.CONFIRM_QUIT_MSG),
|
|
35
|
-
onClickIntro: onConfirmQuit
|
|
36
|
-
}
|
|
37
|
-
),
|
|
38
|
-
variant: "warning"
|
|
39
|
-
});
|
|
40
|
-
} else {
|
|
41
|
-
onConfirmQuit();
|
|
42
|
-
}
|
|
43
|
-
}, [getLabel, isDirty, openModal, onConfirmQuit]);
|
|
11
|
+
};
|
|
44
12
|
return /* @__PURE__ */ jsx(
|
|
45
13
|
Button,
|
|
46
14
|
{
|
|
47
15
|
type: "button",
|
|
48
|
-
label:
|
|
16
|
+
label: getLabel(DICTIONARY.LABEL_CANCEL_BUTTON),
|
|
49
17
|
variant: "outlined",
|
|
50
18
|
color: "default",
|
|
51
|
-
onClick: handleCancel
|
|
52
|
-
...rest
|
|
19
|
+
onClick: handleCancel
|
|
53
20
|
}
|
|
54
21
|
);
|
|
55
22
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StepperButtonProps } from '../../../types';
|
|
2
1
|
/**
|
|
3
2
|
* Botón modular para avanzar al siguiente step del Stepper
|
|
4
3
|
*/
|
|
5
|
-
export declare function StepperNextButton(
|
|
4
|
+
export declare function StepperNextButton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,8 +6,7 @@ import { D as DICTIONARY } from "../../../dictionary.js";
|
|
|
6
6
|
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
7
7
|
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
8
8
|
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
9
|
-
function StepperNextButton(
|
|
10
|
-
const { label, ...rest } = props;
|
|
9
|
+
function StepperNextButton() {
|
|
11
10
|
const { nextStepAction } = useStepperActions();
|
|
12
11
|
const isMobile = useIsMobile();
|
|
13
12
|
const { getLabel } = useModuleDictionary();
|
|
@@ -29,13 +28,12 @@ function StepperNextButton(props) {
|
|
|
29
28
|
Button,
|
|
30
29
|
{
|
|
31
30
|
type: "button",
|
|
32
|
-
label:
|
|
31
|
+
label: getLabel(DICTIONARY.LABEL_NEXT_BUTTON),
|
|
33
32
|
variant: "contained",
|
|
34
33
|
color: "primary",
|
|
35
34
|
onClick: handleNext,
|
|
36
35
|
endIcon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowRight}`,
|
|
37
|
-
"data-testid": "stepper-next-button"
|
|
38
|
-
...rest
|
|
36
|
+
"data-testid": "stepper-next-button"
|
|
39
37
|
}
|
|
40
38
|
);
|
|
41
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StepperButtonProps } from '../../../types';
|
|
2
1
|
/**
|
|
3
2
|
* Botón modular para ir al step anterior del Stepper
|
|
4
3
|
*/
|
|
5
|
-
export declare function StepperPrevButton(
|
|
4
|
+
export declare function StepperPrevButton(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -7,8 +7,7 @@ import { useIsMobile } from "@m4l/graphics";
|
|
|
7
7
|
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
8
8
|
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
9
9
|
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
10
|
-
function StepperPrevButton(
|
|
11
|
-
const { label, ...rest } = props;
|
|
10
|
+
function StepperPrevButton() {
|
|
12
11
|
const { currentStep } = useStepper((state) => ({
|
|
13
12
|
currentStep: state.currentStep
|
|
14
13
|
}));
|
|
@@ -36,13 +35,12 @@ function StepperPrevButton(props) {
|
|
|
36
35
|
Button,
|
|
37
36
|
{
|
|
38
37
|
type: "button",
|
|
39
|
-
label:
|
|
38
|
+
label: !isMobile ? getLabel(DICTIONARY.LABEL_PREV_BUTTON) : "",
|
|
40
39
|
variant: "outlined",
|
|
41
40
|
color: "default",
|
|
42
41
|
onClick: handlePrev,
|
|
43
42
|
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowLeft}`,
|
|
44
|
-
"data-testid": "stepper-prev-button"
|
|
45
|
-
...rest
|
|
43
|
+
"data-testid": "stepper-prev-button"
|
|
46
44
|
}
|
|
47
45
|
);
|
|
48
46
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StepperButtonProps } from '../../../types';
|
|
2
1
|
/**
|
|
3
2
|
* Botón modular para finalizar el Stepper y ejecutar onFinalSubmit
|
|
4
3
|
*/
|
|
5
|
-
export declare function StepperSubmitButton(
|
|
4
|
+
export declare function StepperSubmitButton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,18 +2,16 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
3
3
|
import { useModuleDictionary } from "@m4l/core";
|
|
4
4
|
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
5
|
-
function StepperSubmitButton(
|
|
6
|
-
const { label, ...rest } = props;
|
|
5
|
+
function StepperSubmitButton() {
|
|
7
6
|
const { getLabel } = useModuleDictionary();
|
|
8
7
|
return /* @__PURE__ */ jsx(
|
|
9
8
|
Button,
|
|
10
9
|
{
|
|
11
10
|
type: "submit",
|
|
12
|
-
label:
|
|
11
|
+
label: getLabel(DICTIONARY.LABEL_SUBMIT_BUTTON),
|
|
13
12
|
variant: "contained",
|
|
14
13
|
color: "primary",
|
|
15
|
-
"data-testid": "stepper-submit-button"
|
|
16
|
-
...rest
|
|
14
|
+
"data-testid": "stepper-submit-button"
|
|
17
15
|
}
|
|
18
16
|
);
|
|
19
17
|
}
|
|
@@ -2,26 +2,18 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
3
|
import { u as useIsLastVisibleValidStep } from "../../../../hooks/useIsLastVisibleValidStep/index.js";
|
|
4
4
|
import { m as StepperFooterRightActionsStyled } from "../../../../slots/StepperSlot.js";
|
|
5
|
-
import { S as StepperSubmitButton } from "../../../StepperButtons/StepperSubmitButton/index.js";
|
|
6
5
|
import { S as StepperNextButton } from "../../../StepperButtons/StepperNextButton/index.js";
|
|
6
|
+
import { S as StepperSubmitButton } from "../../../StepperButtons/StepperSubmitButton/index.js";
|
|
7
7
|
function StepperFooterRightActions(props) {
|
|
8
8
|
const { children } = props;
|
|
9
9
|
const isLastVisibleValidStep = useIsLastVisibleValidStep();
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
});
|
|
17
|
-
}, [children]);
|
|
18
|
-
const filteredChildren = useMemo(() => {
|
|
10
|
+
const childrenWithoutNextButton = useMemo(() => {
|
|
11
|
+
if (!isLastVisibleValidStep) {
|
|
12
|
+
return children;
|
|
13
|
+
}
|
|
19
14
|
return React.Children.toArray(children).filter((child) => {
|
|
20
15
|
if (React.isValidElement(child)) {
|
|
21
|
-
if (
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (isLastVisibleValidStep && child.type === StepperNextButton) {
|
|
16
|
+
if (child.type === StepperNextButton) {
|
|
25
17
|
return false;
|
|
26
18
|
}
|
|
27
19
|
}
|
|
@@ -29,10 +21,10 @@ function StepperFooterRightActions(props) {
|
|
|
29
21
|
});
|
|
30
22
|
}, [children, isLastVisibleValidStep]);
|
|
31
23
|
const submitButton = useMemo(() => {
|
|
32
|
-
return isLastVisibleValidStep
|
|
33
|
-
}, [isLastVisibleValidStep
|
|
24
|
+
return isLastVisibleValidStep ? /* @__PURE__ */ jsx(StepperSubmitButton, {}) : null;
|
|
25
|
+
}, [isLastVisibleValidStep]);
|
|
34
26
|
return /* @__PURE__ */ jsxs(StepperFooterRightActionsStyled, { children: [
|
|
35
|
-
|
|
27
|
+
childrenWithoutNextButton,
|
|
36
28
|
submitButton
|
|
37
29
|
] });
|
|
38
30
|
}
|
|
@@ -5,7 +5,6 @@ import { ContentAreaSlots, ContentSlots, StepperFooterSlots, StepperSlots } from
|
|
|
5
5
|
import { STEPPER_PREFIX_NAME } from './constants';
|
|
6
6
|
import { M4LOverridesStyleRules } from '../../@types/augmentations';
|
|
7
7
|
import { Step as StepComponent } from './subcomponents/StepperContent/subcomponents/Step';
|
|
8
|
-
import { ButtonProps } from '../mui_extended/Button';
|
|
9
8
|
export type Orientation = 'horizontal' | 'vertical';
|
|
10
9
|
export type IndicatorType = 'number' | 'dot';
|
|
11
10
|
export type FormData = Record<string, string | number | boolean | null | undefined>;
|
|
@@ -146,12 +145,6 @@ export interface StepperFooterProps {
|
|
|
146
145
|
export interface StepperFooterLeftActionsProps {
|
|
147
146
|
children?: ReactNode;
|
|
148
147
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Props para los botones del Stepper que extienden las props de Button de mui_extended
|
|
151
|
-
*/
|
|
152
|
-
export interface StepperButtonProps extends Omit<ButtonProps, 'label'> {
|
|
153
|
-
label?: string;
|
|
154
|
-
}
|
|
155
148
|
/**
|
|
156
149
|
* Props del StepperFooterRightActions
|
|
157
150
|
*/
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { getPropertyByString } from "@m4l/core";
|
|
3
|
-
import { useIsMobile } from "@m4l/graphics";
|
|
4
|
-
import { useTheme } from "@mui/material";
|
|
5
2
|
import { useId, useState, useCallback, useEffect } from "react";
|
|
6
3
|
import { useFormContext, Controller } from "react-hook-form";
|
|
7
4
|
import { A as AutocompleteRootStyled, L as LabelStyled } from "./slots/RHFAutocompleteSlots.js";
|
|
@@ -13,28 +10,22 @@ function RHFAutocomplete(props) {
|
|
|
13
10
|
getOptionLabel,
|
|
14
11
|
isOptionEqualToValue,
|
|
15
12
|
label,
|
|
16
|
-
color,
|
|
17
13
|
options,
|
|
18
14
|
disabled,
|
|
19
15
|
onOpen,
|
|
20
16
|
onClose,
|
|
21
17
|
loading,
|
|
22
|
-
variant,
|
|
23
18
|
helperMessage,
|
|
24
19
|
size,
|
|
25
20
|
onChangeFilterParmsLocal,
|
|
26
21
|
mandatory,
|
|
27
22
|
mandatoryMessage,
|
|
28
23
|
multiple,
|
|
29
|
-
imageScale = true,
|
|
30
|
-
imageRepeat,
|
|
31
24
|
refresh
|
|
32
25
|
// onChange: onChangeRHF,
|
|
33
26
|
} = props;
|
|
34
27
|
const htmlForId = useId();
|
|
35
|
-
const theme = useTheme();
|
|
36
28
|
const [open, setOpen] = useState(false);
|
|
37
|
-
const isDesktop = !useIsMobile();
|
|
38
29
|
const onCloseLocal = useCallback((event, reason) => {
|
|
39
30
|
setOpen(false);
|
|
40
31
|
if (onClose) {
|
|
@@ -59,34 +50,11 @@ function RHFAutocomplete(props) {
|
|
|
59
50
|
},
|
|
60
51
|
[getOptionLabel]
|
|
61
52
|
);
|
|
62
|
-
const paletteColor = getPropertyByString(
|
|
63
|
-
theme.vars.palette,
|
|
64
|
-
disabled ? "default" : color || "default",
|
|
65
|
-
theme.vars.palette.default
|
|
66
|
-
);
|
|
67
53
|
const {
|
|
68
|
-
control
|
|
69
|
-
formState: { errors }
|
|
54
|
+
control
|
|
70
55
|
} = useFormContext();
|
|
71
|
-
const [currentVariant, setCurrentVariant] = useState(null);
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const hasError = errors[nameRHF];
|
|
74
|
-
if (hasError) {
|
|
75
|
-
setCurrentVariant("error");
|
|
76
|
-
} else if (variant) {
|
|
77
|
-
setCurrentVariant(variant);
|
|
78
|
-
} else {
|
|
79
|
-
setCurrentVariant(null);
|
|
80
|
-
}
|
|
81
|
-
}, [errors, nameRHF, variant, control]);
|
|
82
56
|
const ownerState = {
|
|
83
|
-
|
|
84
|
-
semantics: currentVariant,
|
|
85
|
-
disabled,
|
|
86
|
-
multiple: Boolean(multiple),
|
|
87
|
-
imageScale: Boolean(imageScale),
|
|
88
|
-
imageRepeat: Boolean(imageRepeat),
|
|
89
|
-
paletteColor
|
|
57
|
+
disabled
|
|
90
58
|
};
|
|
91
59
|
return /* @__PURE__ */ jsx(
|
|
92
60
|
AutocompleteRootStyled,
|
|
@@ -147,7 +115,7 @@ function RHFAutocomplete(props) {
|
|
|
147
115
|
htmlFor: htmlForId
|
|
148
116
|
}
|
|
149
117
|
),
|
|
150
|
-
|
|
118
|
+
error?.message ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
|
|
151
119
|
] });
|
|
152
120
|
}
|
|
153
121
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme,
|
|
1
|
+
import { AutocompleteCloseReason, AutocompleteFreeSoloValueMapping, AutocompleteInputChangeReason, AutocompleteProps as MUIAutocompleteProps, Theme, PopperProps } from '@mui/material';
|
|
2
2
|
import { ComponentPalletColor, Sizes } from '@m4l/styles';
|
|
3
3
|
import { TextFieldProps } from '../../mui_extended/TextField/types';
|
|
4
4
|
import { RFHAUTOCOMPLETE_KEY_COMPONENT } from './constants';
|
|
@@ -52,11 +52,6 @@ export interface RHFAutocompleteProps<T = any, Multiple extends boolean | undefi
|
|
|
52
52
|
*/
|
|
53
53
|
export interface RHFAutocompleteOwnerState extends Pick<RHFAutocompleteProps<any>, 'size' | 'disabled' | 'variant'> {
|
|
54
54
|
disabled?: boolean;
|
|
55
|
-
semantics: RHFAutocompleteVariants | 'error' | null;
|
|
56
|
-
multiple: boolean;
|
|
57
|
-
imageScale?: boolean;
|
|
58
|
-
imageRepeat?: boolean;
|
|
59
|
-
paletteColor: PaletteColor;
|
|
60
55
|
}
|
|
61
56
|
/**
|
|
62
57
|
* Defines the types of Slots available for the Autocomplete.
|
|
@@ -3,7 +3,7 @@ import { CustomFormArguments, FormProviderCustomProps, FormProviderProps } from
|
|
|
3
3
|
/**
|
|
4
4
|
* TODO: Documentar
|
|
5
5
|
*/
|
|
6
|
-
export declare function useCustomForm({ validationSchema, values, statusLoad, mode
|
|
6
|
+
export declare function useCustomForm({ validationSchema, values, statusLoad, mode }: CustomFormArguments): import('react-hook-form').UseFormReturn<FieldValues, any, FieldValues>;
|
|
7
7
|
/**
|
|
8
8
|
* TODO: Documentar
|
|
9
9
|
*/
|
|
@@ -6,12 +6,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
|
|
6
6
|
import { F as FormProviderRoot } from "./styles.js";
|
|
7
7
|
import { R as RHFormProviderUtilityClasses } from "./classes/index.js";
|
|
8
8
|
const classes = RHFormProviderUtilityClasses();
|
|
9
|
-
function useCustomForm({
|
|
10
|
-
validationSchema,
|
|
11
|
-
values,
|
|
12
|
-
statusLoad,
|
|
13
|
-
mode
|
|
14
|
-
}) {
|
|
9
|
+
function useCustomForm({ validationSchema, values, statusLoad, mode }) {
|
|
15
10
|
const formMethods = useForm({
|
|
16
11
|
resolver: yupResolver(validationSchema),
|
|
17
12
|
defaultValues: values,
|
|
@@ -44,31 +39,11 @@ function useCustomForm({
|
|
|
44
39
|
}
|
|
45
40
|
function FormProviderCustom(props) {
|
|
46
41
|
const { children, onSubmit, className, handleSubmit } = props;
|
|
47
|
-
return /* @__PURE__ */ jsx(FormProvider, { ...props, children: /* @__PURE__ */ jsx(
|
|
48
|
-
FormProviderRoot,
|
|
49
|
-
{
|
|
50
|
-
className: clsx(classes.root, className),
|
|
51
|
-
onSubmit: handleSubmit(onSubmit),
|
|
52
|
-
children
|
|
53
|
-
}
|
|
54
|
-
) });
|
|
42
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...props, children: /* @__PURE__ */ jsx(FormProviderRoot, { className: clsx(classes.root, className), onSubmit: handleSubmit(onSubmit), children }) });
|
|
55
43
|
}
|
|
56
44
|
function RHFormProvider(props) {
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
onSubmit,
|
|
60
|
-
values,
|
|
61
|
-
validationSchema,
|
|
62
|
-
statusLoad = "ready",
|
|
63
|
-
className,
|
|
64
|
-
mode
|
|
65
|
-
} = props;
|
|
66
|
-
const formMethods = useCustomForm({
|
|
67
|
-
validationSchema,
|
|
68
|
-
statusLoad,
|
|
69
|
-
values,
|
|
70
|
-
mode
|
|
71
|
-
});
|
|
45
|
+
const { children, onSubmit, values, validationSchema, statusLoad = "ready", className, mode } = props;
|
|
46
|
+
const formMethods = useCustomForm({ validationSchema, statusLoad, values, mode });
|
|
72
47
|
return /* @__PURE__ */ jsx(
|
|
73
48
|
FormProviderCustom,
|
|
74
49
|
{
|
package/components/index.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
21
21
|
// Diferencia
|
|
22
22
|
refresh,
|
|
23
23
|
error = false,
|
|
24
|
-
htmlFor
|
|
24
|
+
htmlFor,
|
|
25
|
+
readOnly = false,
|
|
26
|
+
placeholder
|
|
25
27
|
} = props;
|
|
26
28
|
const { getLabel } = useModuleDictionary();
|
|
27
29
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -47,8 +49,9 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
47
49
|
variant,
|
|
48
50
|
disabled,
|
|
49
51
|
multiple: Boolean(multiple),
|
|
50
|
-
error
|
|
51
|
-
|
|
52
|
+
error,
|
|
53
|
+
readOnly
|
|
54
|
+
}), [adjustedSize, disabled, error, multiple, variant, readOnly]);
|
|
52
55
|
const startAdornments = useStartAdornments({
|
|
53
56
|
selectedValue,
|
|
54
57
|
multiple,
|
|
@@ -66,7 +69,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
66
69
|
handleRefresh,
|
|
67
70
|
disabled,
|
|
68
71
|
onOpenLocal,
|
|
69
|
-
open
|
|
72
|
+
open,
|
|
73
|
+
readOnly
|
|
70
74
|
});
|
|
71
75
|
if (isSkeleton) {
|
|
72
76
|
return /* @__PURE__ */ jsx(
|
|
@@ -158,12 +162,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
158
162
|
InputProps: {
|
|
159
163
|
...otherInputProps,
|
|
160
164
|
startAdornment: startAdornments,
|
|
161
|
-
endAdornment: endAdornments
|
|
165
|
+
endAdornment: endAdornments,
|
|
166
|
+
readOnly
|
|
162
167
|
},
|
|
163
168
|
SelectProps: { native: true },
|
|
164
169
|
size: adjustedSize,
|
|
165
170
|
fullWidth: true,
|
|
166
|
-
disabled
|
|
171
|
+
disabled,
|
|
172
|
+
placeholder
|
|
167
173
|
}
|
|
168
174
|
);
|
|
169
175
|
}
|
|
@@ -10,7 +10,20 @@ const autocompleteSyles = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Styles for the icon button component.
|
|
12
12
|
*/
|
|
13
|
-
iconButton: {}
|
|
13
|
+
iconButton: ({ ownerState }) => ({
|
|
14
|
+
...ownerState?.readOnly && {
|
|
15
|
+
"&:hover": {
|
|
16
|
+
backgroundColor: "unset!important"
|
|
17
|
+
},
|
|
18
|
+
"&:active": {
|
|
19
|
+
backgroundColor: "unset!important"
|
|
20
|
+
},
|
|
21
|
+
"&:focus-visible": {
|
|
22
|
+
backgroundColor: "unset!important",
|
|
23
|
+
outline: "none!important"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
14
27
|
/**
|
|
15
28
|
* Styles for the input component.
|
|
16
29
|
*/
|
|
@@ -79,10 +92,22 @@ const autocompleteSyles = {
|
|
|
79
92
|
/**
|
|
80
93
|
* Styles for the popper component.
|
|
81
94
|
*/
|
|
82
|
-
popper: (
|
|
83
|
-
|
|
95
|
+
popper: () => ({
|
|
96
|
+
width: "fit-content!important",
|
|
97
|
+
maxWidth: "calc(100vw - 20px)",
|
|
84
98
|
"& .MuiPaper-root": {
|
|
85
|
-
|
|
99
|
+
minWidth: "100%",
|
|
100
|
+
maxHeight: "200px",
|
|
101
|
+
"& .MuiAutocomplete-listbox": {
|
|
102
|
+
height: "100%",
|
|
103
|
+
"& .M4LMenuItem-root ": {
|
|
104
|
+
width: "fit-content",
|
|
105
|
+
"& .M4LTypography-root": {
|
|
106
|
+
width: "fit-content",
|
|
107
|
+
overflow: "unset"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
86
111
|
}
|
|
87
112
|
}),
|
|
88
113
|
/**
|
|
@@ -106,7 +131,25 @@ const autocompleteSyles = {
|
|
|
106
131
|
)
|
|
107
132
|
};
|
|
108
133
|
},
|
|
109
|
-
renderInputText: {}
|
|
134
|
+
renderInputText: {},
|
|
135
|
+
/**
|
|
136
|
+
* Styles for the container multiple values component.
|
|
137
|
+
*/
|
|
138
|
+
containerMultipleValues: () => ({
|
|
139
|
+
display: "flex",
|
|
140
|
+
overflow: "auto",
|
|
141
|
+
width: "100%",
|
|
142
|
+
flex: 1,
|
|
143
|
+
maxHeight: "80px"
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Styles for the container wrapper component.
|
|
147
|
+
*/
|
|
148
|
+
containerWrapper: ({ theme }) => ({
|
|
149
|
+
display: "flex",
|
|
150
|
+
flexWrap: "wrap",
|
|
151
|
+
gap: theme.vars.size.baseSpacings.sp1
|
|
152
|
+
})
|
|
110
153
|
};
|
|
111
154
|
export {
|
|
112
155
|
autocompleteSyles as a
|