@m4l/components 9.3.13 → 9.3.15
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/types.d.ts +207 -61
- package/components/MenuActions/MenuActions.js +3 -2
- package/components/MenuActions/MenuActions.styles.js +1 -1
- package/components/MenuActions/constants.d.ts +1 -0
- package/components/MenuActions/constants.js +12 -1
- package/components/MenuActions/slots/MenuActionsSlots.js +1 -1
- package/components/Stepper/Stepper.d.ts +8 -0
- package/components/Stepper/Stepper.js +70 -0
- package/components/Stepper/Stepper.styles.d.ts +2 -0
- package/components/Stepper/Stepper.styles.js +298 -0
- package/components/Stepper/constants.d.ts +2 -0
- package/components/Stepper/constants.js +6 -0
- package/components/Stepper/dictionary.d.ts +8 -0
- package/components/Stepper/dictionary.js +14 -0
- package/components/Stepper/helpers/evaluateVisibilityStepCondition/index.d.ts +9 -0
- package/components/Stepper/helpers/evaluateVisibilityStepCondition/index.js +17 -0
- package/components/Stepper/helpers/findNextVisibleValidStep/index.d.ts +10 -0
- package/components/Stepper/helpers/findNextVisibleValidStep/index.js +13 -0
- package/components/Stepper/helpers/findPrevVisibleValidStep/index.d.ts +10 -0
- package/components/Stepper/helpers/findPrevVisibleValidStep/index.js +13 -0
- package/components/Stepper/helpers/index.d.ts +4 -0
- package/components/Stepper/helpers/index.js +1 -0
- package/components/Stepper/helpers/isLastVisibleValidStep/index.d.ts +10 -0
- package/components/Stepper/helpers/isLastVisibleValidStep/index.js +16 -0
- package/components/Stepper/hooks/useIsLastVisibleValidStep/index.d.ts +6 -0
- package/components/Stepper/hooks/useIsLastVisibleValidStep/index.js +25 -0
- package/components/Stepper/hooks/useStepper/index.d.ts +5 -0
- package/components/Stepper/hooks/useStepper/index.js +14 -0
- package/components/Stepper/hooks/useStepperActions/index.d.ts +8 -0
- package/components/Stepper/hooks/useStepperActions/index.js +76 -0
- package/components/Stepper/icons.d.ts +9 -0
- package/components/Stepper/icons.js +12 -0
- package/components/Stepper/index.d.ts +14 -0
- package/components/Stepper/index.js +1 -0
- package/components/Stepper/slots/StepperEnum.d.ts +28 -0
- package/components/Stepper/slots/StepperEnum.js +38 -0
- package/components/Stepper/slots/StepperSlot.d.ts +63 -0
- package/components/Stepper/slots/StepperSlot.js +107 -0
- package/components/Stepper/store/StepperContext/index.d.ts +17 -0
- package/components/Stepper/store/StepperContext/index.js +91 -0
- package/components/Stepper/store/StepperStore/index.d.ts +16 -0
- package/components/Stepper/store/StepperStore/index.js +133 -0
- package/components/Stepper/store/types.d.ts +63 -0
- package/components/Stepper/subcomponents/ContentArea/index.d.ts +6 -0
- package/components/Stepper/subcomponents/ContentArea/index.js +24 -0
- package/components/Stepper/subcomponents/ContentArea/subcomponents/WrapperIcon/index.d.ts +4 -0
- package/components/Stepper/subcomponents/ContentArea/subcomponents/WrapperIcon/index.js +26 -0
- package/components/Stepper/subcomponents/ContentArea/subcomponents/WrapperTitle/index.d.ts +4 -0
- package/components/Stepper/subcomponents/ContentArea/subcomponents/WrapperTitle/index.js +23 -0
- package/components/Stepper/subcomponents/StepArea/index.d.ts +6 -0
- package/components/Stepper/subcomponents/StepArea/index.js +149 -0
- package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.d.ts +5 -0
- package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.js +82 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +4 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +25 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.d.ts +4 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +42 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.d.ts +4 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +49 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.d.ts +4 -0
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +20 -0
- package/components/Stepper/subcomponents/StepperButtons/index.d.ts +4 -0
- package/components/Stepper/subcomponents/StepperButtons/index.js +1 -0
- package/components/Stepper/subcomponents/StepperContent/index.d.ts +7 -0
- package/components/Stepper/subcomponents/StepperContent/index.js +23 -0
- package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.d.ts +6 -0
- package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +41 -0
- package/components/Stepper/subcomponents/StepperFooter/index.d.ts +6 -0
- package/components/Stepper/subcomponents/StepperFooter/index.js +48 -0
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterLeftActions/index.d.ts +6 -0
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterLeftActions/index.js +9 -0
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.d.ts +6 -0
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +33 -0
- package/components/Stepper/types.d.ts +165 -0
- package/components/WindowBase/WindowBase.styles.js +1 -1
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/components/hook-form/RHFormContext/index.js +5 -4
- package/components/hook-form/RHFormContext/types.d.ts +3 -1
- package/components/index.d.ts +1 -0
- package/components/mui_extended/Autocomplete/types.d.ts +45 -2
- package/components/mui_extended/Badge/Badge.styles.js +4 -2
- package/components/mui_extended/IconButton/IconButton.js +12 -2
- package/components/mui_extended/IconButton/IconButton.styles.js +7 -7
- package/components/mui_extended/IconButton/constants.js +8 -1
- package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.d.ts +11 -0
- package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js +44 -0
- package/helpers/getStepsAndValidationSchema/index.d.ts +2 -0
- package/helpers/getStepsAndValidationSchema/index.js +1 -0
- package/helpers/getStepsAndValidationSchema/types.d.ts +21 -0
- package/helpers/getStepsAndValidationSchema/types.js +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +80 -52
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { u as useStepper } from "../../../../hooks/useStepper/index.js";
|
|
4
|
+
import { d as WrapperTitleStyled, T as TitleStyled, D as DescriptionStyled } from "../../../../slots/StepperSlot.js";
|
|
5
|
+
function WrapperTitle() {
|
|
6
|
+
const { steps, currentStep } = useStepper((state) => ({
|
|
7
|
+
steps: state.steps,
|
|
8
|
+
currentStep: state.currentStep
|
|
9
|
+
}));
|
|
10
|
+
const currentStepConfig = useMemo(() => {
|
|
11
|
+
return steps[currentStep];
|
|
12
|
+
}, [steps, currentStep]);
|
|
13
|
+
if (!currentStepConfig) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsxs(WrapperTitleStyled, { children: [
|
|
17
|
+
/* @__PURE__ */ jsx(TitleStyled, { variant: "paragraphDens", children: currentStepConfig.title }),
|
|
18
|
+
currentStepConfig.description && /* @__PURE__ */ jsx(DescriptionStyled, { variant: "body", children: currentStepConfig.description })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
WrapperTitle as W
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* El componente StepArea renderiza el área de pasos del Stepper.
|
|
3
|
+
* Muestra solo los pasos que cumplen su condition según los datos del formulario.
|
|
4
|
+
* Utiliza el hook useStepper para obtener el estado actual y los pasos definidos.
|
|
5
|
+
*/
|
|
6
|
+
export declare function StepArea(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
4
|
+
import { u as useStepper } from "../../hooks/useStepper/index.js";
|
|
5
|
+
import { e as StepAreaStyled, f as StepStyled, g as StepNameStyled } from "../../slots/StepperSlot.js";
|
|
6
|
+
import { I as Indicator } from "./subcomponents/Inidicator/index.js";
|
|
7
|
+
import { shallow } from "zustand/shallow";
|
|
8
|
+
import { e as evaluateVisibilityStepCondition } from "../../helpers/evaluateVisibilityStepCondition/index.js";
|
|
9
|
+
function StepArea() {
|
|
10
|
+
const { trigger, clearErrors } = useFormContext();
|
|
11
|
+
const formValues = useWatch();
|
|
12
|
+
const {
|
|
13
|
+
currentStep,
|
|
14
|
+
steps,
|
|
15
|
+
visibleTitle,
|
|
16
|
+
setCurrentStep,
|
|
17
|
+
orientation,
|
|
18
|
+
setStepValidationStatus,
|
|
19
|
+
stepValidationStatus,
|
|
20
|
+
visibilityData
|
|
21
|
+
} = useStepper(
|
|
22
|
+
(state) => ({
|
|
23
|
+
currentStep: state.currentStep,
|
|
24
|
+
steps: state.steps,
|
|
25
|
+
visibleTitle: state.visibleTitle,
|
|
26
|
+
setCurrentStep: state.actions.setCurrentStep,
|
|
27
|
+
indicatorType: state.indicatorType,
|
|
28
|
+
orientation: state.orientation,
|
|
29
|
+
setStepValidationStatus: state.actions.setStepValidationStatus,
|
|
30
|
+
stepValidationStatus: state.stepValidationStatus,
|
|
31
|
+
visibilityData: state.visibilityData
|
|
32
|
+
}),
|
|
33
|
+
shallow
|
|
34
|
+
);
|
|
35
|
+
const validSteps = useMemo(() => {
|
|
36
|
+
return steps;
|
|
37
|
+
}, [steps]);
|
|
38
|
+
const ownerState = {
|
|
39
|
+
visibleTitle,
|
|
40
|
+
orientation,
|
|
41
|
+
totalSteps: validSteps.length
|
|
42
|
+
};
|
|
43
|
+
const handleStepClick = async (targetIndex) => {
|
|
44
|
+
const currentIndex = validSteps.findIndex(
|
|
45
|
+
(step) => step.key === steps[currentStep].key
|
|
46
|
+
);
|
|
47
|
+
if (targetIndex === currentIndex) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const isNavigatingForward = targetIndex > currentIndex;
|
|
51
|
+
const targetOriginalIndex = steps.findIndex(
|
|
52
|
+
(s) => s.key === validSteps[targetIndex].key
|
|
53
|
+
);
|
|
54
|
+
if (!isNavigatingForward) {
|
|
55
|
+
setCurrentStep(targetOriginalIndex);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const isSkippingSteps = targetIndex > currentIndex + 1;
|
|
59
|
+
if (isSkippingSteps) {
|
|
60
|
+
for (let i = currentIndex; i < targetIndex; i++) {
|
|
61
|
+
const step = validSteps[i];
|
|
62
|
+
const stepOriginalIndex = steps.findIndex((s) => s.key === step.key);
|
|
63
|
+
const isValid = await trigger(step.validationFields);
|
|
64
|
+
if (!isValid) {
|
|
65
|
+
setCurrentStep(stepOriginalIndex);
|
|
66
|
+
setStepValidationStatus(stepOriginalIndex, false);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setStepValidationStatus(stepOriginalIndex, true);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
const currentStepData = validSteps[currentIndex];
|
|
73
|
+
const currentStepOriginalIndex = steps.findIndex(
|
|
74
|
+
(s) => s.key === currentStepData.key
|
|
75
|
+
);
|
|
76
|
+
const isCurrentValid = await trigger(currentStepData.validationFields);
|
|
77
|
+
if (!isCurrentValid) {
|
|
78
|
+
setStepValidationStatus(currentStepOriginalIndex, false);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setStepValidationStatus(currentStepOriginalIndex, true);
|
|
82
|
+
}
|
|
83
|
+
setCurrentStep(targetOriginalIndex);
|
|
84
|
+
if (isNavigatingForward) {
|
|
85
|
+
const currentStepData = validSteps[currentIndex];
|
|
86
|
+
const currentStepOriginalIndex = steps.findIndex(
|
|
87
|
+
(s) => s.key === currentStepData.key
|
|
88
|
+
);
|
|
89
|
+
const isCurrentStepValid = stepValidationStatus[currentStepOriginalIndex] !== false;
|
|
90
|
+
if (isCurrentStepValid) {
|
|
91
|
+
const targetStep = validSteps[targetIndex];
|
|
92
|
+
const targetStepFields = targetStep.validationFields || [];
|
|
93
|
+
if (targetStepFields.length > 0) {
|
|
94
|
+
clearErrors(targetStepFields);
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
clearErrors(targetStepFields);
|
|
97
|
+
setStepValidationStatus(targetOriginalIndex, true);
|
|
98
|
+
}, 100);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ jsx(StepAreaStyled, { ownerState, children: validSteps.map((step, validIndex) => {
|
|
104
|
+
const originalIndex = steps.findIndex((s) => s.key === step.key);
|
|
105
|
+
const totalVisibleSteps = validSteps.filter(
|
|
106
|
+
(s) => evaluateVisibilityStepCondition(s, formValues || {}, visibilityData)
|
|
107
|
+
).length;
|
|
108
|
+
return /* @__PURE__ */ jsxs(
|
|
109
|
+
StepStyled,
|
|
110
|
+
{
|
|
111
|
+
role: "button",
|
|
112
|
+
onClick: () => handleStepClick(validIndex),
|
|
113
|
+
ownerState: {
|
|
114
|
+
...ownerState,
|
|
115
|
+
currentStep,
|
|
116
|
+
step: validIndex,
|
|
117
|
+
isStepVisible: evaluateVisibilityStepCondition(
|
|
118
|
+
step,
|
|
119
|
+
formValues || {},
|
|
120
|
+
visibilityData
|
|
121
|
+
)
|
|
122
|
+
},
|
|
123
|
+
children: [
|
|
124
|
+
visibleTitle && /* @__PURE__ */ jsx(
|
|
125
|
+
StepNameStyled,
|
|
126
|
+
{
|
|
127
|
+
variant: "body",
|
|
128
|
+
ownerState: { ...ownerState, currentStep, step: validIndex },
|
|
129
|
+
children: step.title
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
Indicator,
|
|
134
|
+
{
|
|
135
|
+
currentStep,
|
|
136
|
+
step: validIndex,
|
|
137
|
+
totalSteps: totalVisibleSteps,
|
|
138
|
+
originalStepIndex: originalIndex
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
step.key
|
|
144
|
+
);
|
|
145
|
+
}) });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
StepArea as S
|
|
149
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { h as IndicatorStyled, i as TextNumberStyled } from "../../../../slots/StepperSlot.js";
|
|
4
|
+
import { u as useStepper } from "../../../../hooks/useStepper/index.js";
|
|
5
|
+
import { p as pathIcons } from "../../../../icons.js";
|
|
6
|
+
import { useIsMobile } from "@m4l/graphics";
|
|
7
|
+
import { useEnvironment } from "@m4l/core";
|
|
8
|
+
import { shallow } from "zustand/shallow";
|
|
9
|
+
import { u as useComponentSize } from "../../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
10
|
+
import { I as Icon } from "../../../../../Icon/Icon.js";
|
|
11
|
+
function Indicator(props) {
|
|
12
|
+
const { step, currentStep, totalSteps, originalStepIndex } = props;
|
|
13
|
+
const { orientation, size, indicatorType, stepValidationStatus } = useStepper(
|
|
14
|
+
(state) => ({
|
|
15
|
+
orientation: state.orientation,
|
|
16
|
+
size: state.size,
|
|
17
|
+
indicatorType: state.indicatorType,
|
|
18
|
+
stepValidationStatus: state.stepValidationStatus
|
|
19
|
+
}),
|
|
20
|
+
shallow
|
|
21
|
+
);
|
|
22
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
23
|
+
const { currentSize } = useComponentSize(size);
|
|
24
|
+
const ownerState = {
|
|
25
|
+
size: currentSize,
|
|
26
|
+
currentStep,
|
|
27
|
+
step,
|
|
28
|
+
totalSteps,
|
|
29
|
+
orientation,
|
|
30
|
+
indicatorType,
|
|
31
|
+
stepValidationStatus
|
|
32
|
+
};
|
|
33
|
+
const isMobile = useIsMobile();
|
|
34
|
+
const effectiveIndicatorType = useMemo(() => {
|
|
35
|
+
return isMobile ? "dot" : indicatorType;
|
|
36
|
+
}, [isMobile, indicatorType]);
|
|
37
|
+
const { isCompleted, isValidStep, hasBeenValidated } = useMemo(() => {
|
|
38
|
+
const completed = currentStep > originalStepIndex;
|
|
39
|
+
const validationStatus = stepValidationStatus[originalStepIndex];
|
|
40
|
+
const validated = validationStatus !== void 0;
|
|
41
|
+
const valid = validationStatus === true;
|
|
42
|
+
return {
|
|
43
|
+
isCompleted: completed,
|
|
44
|
+
isValidStep: valid,
|
|
45
|
+
hasBeenValidated: validated
|
|
46
|
+
};
|
|
47
|
+
}, [currentStep, originalStepIndex, stepValidationStatus]);
|
|
48
|
+
return /* @__PURE__ */ jsx(IndicatorStyled, { ownerState, children: hasBeenValidated && !isValidStep ? (
|
|
49
|
+
// Mostrar error solo si ha sido validado y es inválido
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
Icon,
|
|
52
|
+
{
|
|
53
|
+
src: `${host_static_assets}/${environment_assets}/${pathIcons.circleError}`,
|
|
54
|
+
size: "small",
|
|
55
|
+
color: "error.contrastText"
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
) : isCompleted && isValidStep ? (
|
|
59
|
+
// Mostrar completado solo si está completado Y es válido
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Icon,
|
|
62
|
+
{
|
|
63
|
+
src: `${host_static_assets}/${environment_assets}/${effectiveIndicatorType === "number" ? pathIcons.circleCheck : pathIcons.dotOutline}`,
|
|
64
|
+
size: "small",
|
|
65
|
+
color: "primary.semanticText"
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
) : (
|
|
69
|
+
// Mostrar estado normal (número o dot) para pasos no validados o actuales
|
|
70
|
+
/* @__PURE__ */ jsx(TextNumberStyled, { variant: "body", ownerState: { currentStep, step }, children: effectiveIndicatorType === "number" ? step + 1 : /* @__PURE__ */ jsx(
|
|
71
|
+
Icon,
|
|
72
|
+
{
|
|
73
|
+
src: `${host_static_assets}/${environment_assets}/${currentStep === originalStepIndex ? pathIcons.dotSelected : pathIcons.dotOutline}`,
|
|
74
|
+
size: "small",
|
|
75
|
+
color: currentStep === originalStepIndex ? "primary.semanticText" : "text.disabled"
|
|
76
|
+
}
|
|
77
|
+
) })
|
|
78
|
+
) });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
Indicator as I
|
|
82
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { u as useStepperActions } from "../../../hooks/useStepperActions/index.js";
|
|
3
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
4
|
+
import { useModuleDictionary } from "@m4l/core";
|
|
5
|
+
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
6
|
+
function StepperCancelButton() {
|
|
7
|
+
const { getLabel } = useModuleDictionary();
|
|
8
|
+
const { cancelAction } = useStepperActions();
|
|
9
|
+
const handleCancel = () => {
|
|
10
|
+
cancelAction();
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Button,
|
|
14
|
+
{
|
|
15
|
+
type: "button",
|
|
16
|
+
label: getLabel(DICTIONARY.LABEL_CANCEL_BUTTON),
|
|
17
|
+
variant: "outlined",
|
|
18
|
+
color: "default",
|
|
19
|
+
onClick: handleCancel
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
StepperCancelButton as S
|
|
25
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { u as useStepperActions } from "../../../hooks/useStepperActions/index.js";
|
|
3
|
+
import { p as pathIcons } from "../../../icons.js";
|
|
4
|
+
import { useIsMobile } from "@m4l/graphics";
|
|
5
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
6
|
+
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
7
|
+
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
8
|
+
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
9
|
+
function StepperNextButton() {
|
|
10
|
+
const { nextStepAction } = useStepperActions();
|
|
11
|
+
const isMobile = useIsMobile();
|
|
12
|
+
const { getLabel } = useModuleDictionary();
|
|
13
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
14
|
+
const handleNext = async () => {
|
|
15
|
+
await nextStepAction();
|
|
16
|
+
};
|
|
17
|
+
return isMobile ? /* @__PURE__ */ jsx(
|
|
18
|
+
IconButton,
|
|
19
|
+
{
|
|
20
|
+
type: "button",
|
|
21
|
+
onClick: handleNext,
|
|
22
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowRight}`,
|
|
23
|
+
"data-testid": "stepper-next-button",
|
|
24
|
+
variant: "contained",
|
|
25
|
+
color: "primary"
|
|
26
|
+
}
|
|
27
|
+
) : /* @__PURE__ */ jsx(
|
|
28
|
+
Button,
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
label: getLabel(DICTIONARY.LABEL_NEXT_BUTTON),
|
|
32
|
+
variant: "contained",
|
|
33
|
+
color: "primary",
|
|
34
|
+
onClick: handleNext,
|
|
35
|
+
endIcon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowRight}`,
|
|
36
|
+
"data-testid": "stepper-next-button"
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
StepperNextButton as S
|
|
42
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
3
|
+
import { u as useStepper } from "../../../hooks/useStepper/index.js";
|
|
4
|
+
import { u as useStepperActions } from "../../../hooks/useStepperActions/index.js";
|
|
5
|
+
import { p as pathIcons } from "../../../icons.js";
|
|
6
|
+
import { useIsMobile } from "@m4l/graphics";
|
|
7
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
8
|
+
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
9
|
+
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
10
|
+
function StepperPrevButton() {
|
|
11
|
+
const { currentStep } = useStepper((state) => ({
|
|
12
|
+
currentStep: state.currentStep
|
|
13
|
+
}));
|
|
14
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
15
|
+
const isMobile = useIsMobile();
|
|
16
|
+
const { getLabel } = useModuleDictionary();
|
|
17
|
+
const { prevStepAction } = useStepperActions();
|
|
18
|
+
const handlePrev = () => {
|
|
19
|
+
prevStepAction();
|
|
20
|
+
};
|
|
21
|
+
if (currentStep === 0) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return isMobile ? /* @__PURE__ */ jsx(
|
|
25
|
+
IconButton,
|
|
26
|
+
{
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: handlePrev,
|
|
29
|
+
icon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowLeft}`,
|
|
30
|
+
"data-testid": "stepper-prev-button",
|
|
31
|
+
variant: "outline",
|
|
32
|
+
color: "default"
|
|
33
|
+
}
|
|
34
|
+
) : /* @__PURE__ */ jsx(
|
|
35
|
+
Button,
|
|
36
|
+
{
|
|
37
|
+
type: "button",
|
|
38
|
+
label: !isMobile ? getLabel(DICTIONARY.LABEL_PREV_BUTTON) : "",
|
|
39
|
+
variant: "outlined",
|
|
40
|
+
color: "default",
|
|
41
|
+
onClick: handlePrev,
|
|
42
|
+
startIcon: `${host_static_assets}/${environment_assets}/${pathIcons.arrowLeft}`,
|
|
43
|
+
"data-testid": "stepper-prev-button"
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
StepperPrevButton as S
|
|
49
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { D as DICTIONARY } from "../../../dictionary.js";
|
|
3
|
+
import { useModuleDictionary } from "@m4l/core";
|
|
4
|
+
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
5
|
+
function StepperSubmitButton() {
|
|
6
|
+
const { getLabel } = useModuleDictionary();
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Button,
|
|
9
|
+
{
|
|
10
|
+
type: "submit",
|
|
11
|
+
label: getLabel(DICTIONARY.LABEL_SUBMIT_BUTTON),
|
|
12
|
+
variant: "contained",
|
|
13
|
+
color: "primary",
|
|
14
|
+
"data-testid": "stepper-submit-button"
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
StepperSubmitButton as S
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StepperContentProps } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente StepperContent - Contenedor que renderiza todos los Steps
|
|
4
|
+
* Cada Step maneja su propia lógica de renderizado condicional
|
|
5
|
+
* SOLO acepta componentes Step como hijos.
|
|
6
|
+
*/
|
|
7
|
+
export declare function StepperContent(props: StepperContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, Children, isValidElement } from "react";
|
|
3
|
+
import { S as Step } from "./subcomponents/Step/index.js";
|
|
4
|
+
function StepperContent(props) {
|
|
5
|
+
const { children } = props;
|
|
6
|
+
const validSteps = useMemo(() => {
|
|
7
|
+
const steps = [];
|
|
8
|
+
Children.forEach(children, (child) => {
|
|
9
|
+
if (isValidElement(child) && child.type === Step) {
|
|
10
|
+
steps.push(child);
|
|
11
|
+
} else {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"StepperContent: Solo se permiten componentes Step como hijos."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return steps;
|
|
18
|
+
}, [children]);
|
|
19
|
+
return /* @__PURE__ */ jsx(Fragment, { children: validSteps });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
StepperContent as S
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepProps } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente Step - Representa un paso individual en el Stepper
|
|
4
|
+
* Solo se renderiza cuando el step actual coincide con stepKey Y la condition es true
|
|
5
|
+
*/
|
|
6
|
+
export declare function Step(props: StepProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { u as useStepper } from "../../../../hooks/useStepper/index.js";
|
|
4
|
+
import { useWatch } from "react-hook-form";
|
|
5
|
+
import { j as StepContentStyled } from "../../../../slots/StepperSlot.js";
|
|
6
|
+
import { e as evaluateVisibilityStepCondition } from "../../../../helpers/evaluateVisibilityStepCondition/index.js";
|
|
7
|
+
function Step(props) {
|
|
8
|
+
const { stepKey, children } = props;
|
|
9
|
+
const formValues = useWatch();
|
|
10
|
+
const { currentStep, steps, visibilityData } = useStepper((state) => ({
|
|
11
|
+
currentStep: state.currentStep,
|
|
12
|
+
steps: state.steps,
|
|
13
|
+
visibilityData: state.visibilityData
|
|
14
|
+
}));
|
|
15
|
+
const currentStepConfig = useMemo(() => {
|
|
16
|
+
return steps[currentStep];
|
|
17
|
+
}, [steps, currentStep]);
|
|
18
|
+
const stepConfig = useMemo(() => {
|
|
19
|
+
return steps.find((step) => step.key === stepKey);
|
|
20
|
+
}, [steps, stepKey]);
|
|
21
|
+
const isStepVisible = useMemo(() => {
|
|
22
|
+
if (!currentStepConfig) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (stepKey !== currentStepConfig.key) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (stepConfig && !evaluateVisibilityStepCondition(
|
|
29
|
+
stepConfig,
|
|
30
|
+
formValues || {},
|
|
31
|
+
visibilityData
|
|
32
|
+
)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}, [currentStepConfig, stepKey, stepConfig, formValues, visibilityData]);
|
|
37
|
+
return /* @__PURE__ */ jsx(StepContentStyled, { ownerState: { isStepVisible }, children });
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
Step as S
|
|
41
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepperFooterProps } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* StepperFooter es el componente footer del Stepper que contiene las acciones de navegación.
|
|
4
|
+
* Puede incluir LeftActions y RightActions como children.
|
|
5
|
+
*/
|
|
6
|
+
export declare function StepperFooter(props: StepperFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, Children, isValidElement } from "react";
|
|
3
|
+
import { k as StepperFooterSectionStyled } from "../../slots/StepperSlot.js";
|
|
4
|
+
import { S as StepperFooterLeftActions } from "./subcomponents/StepperFooterLeftActions/index.js";
|
|
5
|
+
import { S as StepperFooterRightActions } from "./subcomponents/StepperFooterRightActions/index.js";
|
|
6
|
+
function StepperFooter(props) {
|
|
7
|
+
const { children } = props;
|
|
8
|
+
const { stepperFooterLeftActions, stepperFooterRightActions } = useMemo(() => {
|
|
9
|
+
let parsedLeftActions = null;
|
|
10
|
+
let parsedRightActions = null;
|
|
11
|
+
let leftActionsCount = 0;
|
|
12
|
+
let rightActionsCount = 0;
|
|
13
|
+
if (children) {
|
|
14
|
+
Children.forEach(children, (child) => {
|
|
15
|
+
if (isValidElement(child)) {
|
|
16
|
+
if (child.type === StepperFooterLeftActions) {
|
|
17
|
+
leftActionsCount++;
|
|
18
|
+
if (leftActionsCount > 1) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"StepperFooter: Solo se permite un componente StepperFooterLeftActions. Se encontraron múltiples StepperFooterLeftActions."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
parsedLeftActions = child;
|
|
24
|
+
} else if (child.type === StepperFooterRightActions) {
|
|
25
|
+
rightActionsCount++;
|
|
26
|
+
if (rightActionsCount > 1) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"StepperFooter: Solo se permite un componente StepperFooterRightActions. Se encontraron múltiples StepperFooterRightActions."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
parsedRightActions = child;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
stepperFooterLeftActions: parsedLeftActions,
|
|
38
|
+
stepperFooterRightActions: parsedRightActions
|
|
39
|
+
};
|
|
40
|
+
}, [children]);
|
|
41
|
+
return /* @__PURE__ */ jsxs(StepperFooterSectionStyled, { children: [
|
|
42
|
+
stepperFooterLeftActions,
|
|
43
|
+
stepperFooterRightActions
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
StepperFooter as S
|
|
48
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepperFooterLeftActionsProps } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* StepperFooterLeftActions es un componente de guía de estilos para acciones del lado izquierdo del footer del Stepper.
|
|
4
|
+
* Puede recibir children para renderizar contenido personalizado.
|
|
5
|
+
*/
|
|
6
|
+
export declare function StepperFooterLeftActions(props: StepperFooterLeftActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { l as StepperFooterLeftActionsStyled } from "../../../../slots/StepperSlot.js";
|
|
3
|
+
function StepperFooterLeftActions(props) {
|
|
4
|
+
const { children } = props;
|
|
5
|
+
return /* @__PURE__ */ jsx(StepperFooterLeftActionsStyled, { children });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
StepperFooterLeftActions as S
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepperFooterRightActionsProps } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* StepperFooterRightActions es un componente de guía de estilos para acciones del lado derecho del footer del Stepper.
|
|
4
|
+
* Puede recibir children para renderizar contenido personalizado.
|
|
5
|
+
*/
|
|
6
|
+
export declare function StepperFooterRightActions(props: StepperFooterRightActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { u as useIsLastVisibleValidStep } from "../../../../hooks/useIsLastVisibleValidStep/index.js";
|
|
4
|
+
import { m as StepperFooterRightActionsStyled } from "../../../../slots/StepperSlot.js";
|
|
5
|
+
import { S as StepperNextButton } from "../../../StepperButtons/StepperNextButton/index.js";
|
|
6
|
+
import { S as StepperSubmitButton } from "../../../StepperButtons/StepperSubmitButton/index.js";
|
|
7
|
+
function StepperFooterRightActions(props) {
|
|
8
|
+
const { children } = props;
|
|
9
|
+
const isLastVisibleValidStep = useIsLastVisibleValidStep();
|
|
10
|
+
const childrenWithoutNextButton = useMemo(() => {
|
|
11
|
+
if (!isLastVisibleValidStep) {
|
|
12
|
+
return children;
|
|
13
|
+
}
|
|
14
|
+
return React.Children.toArray(children).filter((child) => {
|
|
15
|
+
if (React.isValidElement(child)) {
|
|
16
|
+
if (child.type === StepperNextButton) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
});
|
|
22
|
+
}, [children, isLastVisibleValidStep]);
|
|
23
|
+
const submitButton = useMemo(() => {
|
|
24
|
+
return isLastVisibleValidStep ? /* @__PURE__ */ jsx(StepperSubmitButton, {}) : null;
|
|
25
|
+
}, [isLastVisibleValidStep]);
|
|
26
|
+
return /* @__PURE__ */ jsxs(StepperFooterRightActionsStyled, { children: [
|
|
27
|
+
childrenWithoutNextButton,
|
|
28
|
+
submitButton
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
StepperFooterRightActions as S
|
|
33
|
+
};
|