@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,298 @@
|
|
|
1
|
+
import { g as getSizeStyles } from "../../utils/getSizeStyles/getSizeStyles.js";
|
|
2
|
+
const stepperStyles = {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Estilos para el contenedor principal del Stepper.
|
|
6
|
+
*/
|
|
7
|
+
stepperRoot: ({ theme }) => ({
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "column",
|
|
10
|
+
justifyContent: "flex-start",
|
|
11
|
+
background: theme.vars.palette.background.default,
|
|
12
|
+
width: "100%",
|
|
13
|
+
height: "100%",
|
|
14
|
+
borderRadius: theme.vars.size.borderRadius.r1
|
|
15
|
+
}),
|
|
16
|
+
/**
|
|
17
|
+
* Estilos para la sección que contiene los pasos del Stepper.
|
|
18
|
+
*/
|
|
19
|
+
contentSection: ({ theme, ownerState }) => ({
|
|
20
|
+
display: "flex",
|
|
21
|
+
flex: 1,
|
|
22
|
+
height: "100%",
|
|
23
|
+
overflow: "hidden",
|
|
24
|
+
flexDirection: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "column" : "row",
|
|
25
|
+
gap: theme.vars.size.baseSpacings.sp8
|
|
26
|
+
}),
|
|
27
|
+
stepContent: ({ ownerState }) => ({
|
|
28
|
+
display: ownerState?.isStepVisible ? "block" : "none"
|
|
29
|
+
}),
|
|
30
|
+
/**
|
|
31
|
+
* Estilos para la sección que contiene los botones de acción del Stepper.
|
|
32
|
+
*/
|
|
33
|
+
stepArea: ({ theme, ownerState }) => ({
|
|
34
|
+
...ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? {
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "start",
|
|
37
|
+
width: "100%",
|
|
38
|
+
minWidth: "350px",
|
|
39
|
+
overflowX: "auto",
|
|
40
|
+
overflowY: "hidden"
|
|
41
|
+
} : {
|
|
42
|
+
maxWidth: "116px",
|
|
43
|
+
overflowY: "auto"
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
/**
|
|
47
|
+
* Estilos para el área de contenido del Stepper.
|
|
48
|
+
*/
|
|
49
|
+
contentArea: ({ theme, ownerState }) => ({
|
|
50
|
+
flex: 1,
|
|
51
|
+
display: "flex",
|
|
52
|
+
flexDirection: "column",
|
|
53
|
+
gap: theme.vars.size.baseSpacings.sp6,
|
|
54
|
+
...ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? {
|
|
55
|
+
borderTop: "1px solid",
|
|
56
|
+
paddingTop: theme.vars.size.baseSpacings.sp8
|
|
57
|
+
} : {
|
|
58
|
+
borderLeft: "1px solid",
|
|
59
|
+
paddingLeft: theme.vars.size.baseSpacings.sp8
|
|
60
|
+
},
|
|
61
|
+
borderColor: theme.vars.palette?.border.disabled
|
|
62
|
+
}),
|
|
63
|
+
/**
|
|
64
|
+
* Estilos para cada paso del Stepper.
|
|
65
|
+
*/
|
|
66
|
+
step: ({ theme, ownerState }) => {
|
|
67
|
+
const currentStep = ownerState?.currentStep ?? 0;
|
|
68
|
+
const step = ownerState?.step ?? 0;
|
|
69
|
+
const totalSteps = ownerState?.totalSteps ?? 0;
|
|
70
|
+
const isCompleted = currentStep > step;
|
|
71
|
+
const isLastStep = step === totalSteps - 1;
|
|
72
|
+
return {
|
|
73
|
+
cursor: "pointer",
|
|
74
|
+
display: "flex",
|
|
75
|
+
visibility: ownerState?.isStepVisible ? "visible" : "hidden",
|
|
76
|
+
flexDirection: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "column" : "row",
|
|
77
|
+
alignItems: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "start",
|
|
78
|
+
justifyContent: ownerState?.visibleTitle ? "space-between" : "center",
|
|
79
|
+
gap: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? theme.vars.size.baseSpacings.sp1 : theme.vars.size.baseSpacings.sp4,
|
|
80
|
+
width: "100%",
|
|
81
|
+
...(ownerState?.orientation === "vertical" || theme.generalSettings.isMobile) && {
|
|
82
|
+
minWidth: theme.vars.size.baseSpacings.sp10
|
|
83
|
+
},
|
|
84
|
+
height: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "auto" : theme.vars.size.baseSpacings.sp13,
|
|
85
|
+
position: "relative",
|
|
86
|
+
...!isLastStep && (ownerState?.orientation === "vertical" || theme.generalSettings.isMobile) && {
|
|
87
|
+
"&::after": {
|
|
88
|
+
content: '""',
|
|
89
|
+
position: "absolute",
|
|
90
|
+
top: ownerState?.orientation === "horizontal" && theme.generalSettings.isMobile ? "16px" : "10px",
|
|
91
|
+
// Ajustado para coincidir con el centro del indicador cuando alignItems es start
|
|
92
|
+
height: "1px",
|
|
93
|
+
borderTop: `1px ${isCompleted ? "solid" : "dashed"} ${isCompleted ? theme.vars.palette.primary.enabled : theme.vars.palette.border.default}`,
|
|
94
|
+
left: "50%",
|
|
95
|
+
width: "100%"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Estilos para el nombre del paso dentro del Stepper.
|
|
102
|
+
*/
|
|
103
|
+
stepName: ({ theme, ownerState }) => ({
|
|
104
|
+
...ownerState?.orientation === "horizontal" && {
|
|
105
|
+
height: theme.generalSettings.isMobile ? theme.vars.size.mobile.medium.action : theme.vars.size.desktop.large.action
|
|
106
|
+
},
|
|
107
|
+
...(ownerState?.orientation === "vertical" || theme.generalSettings.isMobile) && {
|
|
108
|
+
maxWidth: "120px",
|
|
109
|
+
width: "100%",
|
|
110
|
+
lineHeight: "1.2",
|
|
111
|
+
marginTop: theme.vars.size.baseSpacings.sp1
|
|
112
|
+
},
|
|
113
|
+
alignContent: "center",
|
|
114
|
+
cursor: "pointer",
|
|
115
|
+
overflow: "hidden",
|
|
116
|
+
...theme.generalSettings.isMobile ? {
|
|
117
|
+
display: "none"
|
|
118
|
+
} : {
|
|
119
|
+
display: ownerState?.visibleTitle ? "-webkit-box" : "none"
|
|
120
|
+
},
|
|
121
|
+
WebkitBoxOrient: "vertical",
|
|
122
|
+
WebkitLineClamp: 2,
|
|
123
|
+
textOverflow: "ellipsis",
|
|
124
|
+
flex: 1,
|
|
125
|
+
minWidth: 0,
|
|
126
|
+
whiteSpace: "normal",
|
|
127
|
+
order: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? 1 : 0,
|
|
128
|
+
"&.M4LTypography-root": {
|
|
129
|
+
color: (ownerState?.currentStep ?? 0) > (ownerState?.step ?? 0) ? theme.vars.palette.primary.semanticText : (ownerState?.currentStep ?? 0) === (ownerState?.step ?? 0) ? theme.vars.palette.text.primary : theme.vars.palette.text.secondary,
|
|
130
|
+
textAlign: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "right"
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
/**
|
|
134
|
+
* Estilos para el indicador numérico de cada paso del Stepper.
|
|
135
|
+
*/
|
|
136
|
+
indicator: ({ theme, ownerState }) => {
|
|
137
|
+
const currentStep = ownerState?.currentStep ?? 0;
|
|
138
|
+
const step = ownerState?.step ?? 0;
|
|
139
|
+
const totalSteps = ownerState?.totalSteps ?? 0;
|
|
140
|
+
const isCompleted = currentStep > step;
|
|
141
|
+
const isCurrent = currentStep === step;
|
|
142
|
+
const isLastStep = step === totalSteps - 1;
|
|
143
|
+
const isValidStep = ownerState?.stepValidationStatus?.[step] ?? true;
|
|
144
|
+
return {
|
|
145
|
+
...ownerState?.orientation === "horizontal" ? {
|
|
146
|
+
marginTop: theme.generalSettings.isMobile ? "6px" : theme.vars.size.baseSpacings.sp1
|
|
147
|
+
} : {},
|
|
148
|
+
display: "flex",
|
|
149
|
+
alignItems: "center",
|
|
150
|
+
justifyContent: "center",
|
|
151
|
+
flexShrink: 0,
|
|
152
|
+
order: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? 0 : 1,
|
|
153
|
+
background: isCompleted ? ownerState?.indicatorType === "dot" || theme.generalSettings.isMobile ? theme.vars.palette.background.default : theme.vars.palette.primary.toneOpacity : !isValidStep ? theme.vars.palette.error.enabled : ownerState?.indicatorType === "dot" || theme.generalSettings.isMobile ? theme.vars.palette.background.default : isCurrent ? theme.vars.palette.primary.enabled : theme.vars.palette.default.enabled,
|
|
154
|
+
borderRadius: theme.vars.size.borderRadius.r2,
|
|
155
|
+
...ownerState?.indicatorType === "number" && !theme.generalSettings.isMobile && {
|
|
156
|
+
boxShadow: isCurrent ? "0 2px 8px 0 rgb(0, 100, 255, 0.16)" : "none"
|
|
157
|
+
},
|
|
158
|
+
position: "relative",
|
|
159
|
+
...!isLastStep && ownerState?.orientation === "horizontal" && !theme.generalSettings.isMobile && {
|
|
160
|
+
"&::after": {
|
|
161
|
+
content: '""',
|
|
162
|
+
position: "absolute",
|
|
163
|
+
top: "100%",
|
|
164
|
+
left: "50%",
|
|
165
|
+
transform: "translateX(-50%)",
|
|
166
|
+
width: "1px",
|
|
167
|
+
height: theme.vars.size.baseSpacings.sp12,
|
|
168
|
+
borderLeft: `1px ${isCompleted ? "solid" : "dashed"} ${isCompleted ? theme.vars.palette.primary.enabled : theme.vars.palette.border.default}`
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
...getSizeStyles(theme, ownerState?.size || "medium", "case", (size) => ({
|
|
172
|
+
width: size,
|
|
173
|
+
height: size
|
|
174
|
+
}))
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Estilos para el número de texto dentro del indicador numérico del Stepper.
|
|
179
|
+
*/
|
|
180
|
+
textNumber: ({ theme, ownerState }) => {
|
|
181
|
+
const currentStep = ownerState?.currentStep ?? 0;
|
|
182
|
+
const step = ownerState?.step ?? 0;
|
|
183
|
+
const isCompleted = currentStep > step;
|
|
184
|
+
const isCurrent = currentStep === step;
|
|
185
|
+
return {
|
|
186
|
+
"&.M4LTypography-root": {
|
|
187
|
+
color: isCompleted || isCurrent ? theme.vars.palette.primary.contrastText : theme.vars.palette.text.primary
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* Estilos para el área de contenido del Stepper.
|
|
193
|
+
*/
|
|
194
|
+
contentAreaHeader: ({ theme }) => ({
|
|
195
|
+
display: "flex",
|
|
196
|
+
alignItems: "center",
|
|
197
|
+
gap: theme.size.baseSpacings.sp3,
|
|
198
|
+
position: "sticky",
|
|
199
|
+
top: 0,
|
|
200
|
+
backgroundColor: theme.vars.palette.background.default,
|
|
201
|
+
zIndex: 10,
|
|
202
|
+
paddingBottom: theme.vars.size.baseSpacings.sp2
|
|
203
|
+
}),
|
|
204
|
+
/**
|
|
205
|
+
* Estilos para el cuerpo del área de contenido del Stepper
|
|
206
|
+
*/
|
|
207
|
+
contentAreaBody: ({ theme }) => ({
|
|
208
|
+
flex: 1,
|
|
209
|
+
overflowY: "auto",
|
|
210
|
+
display: "flex",
|
|
211
|
+
flexDirection: "column",
|
|
212
|
+
gap: theme.vars.size.baseSpacings.sp6
|
|
213
|
+
}),
|
|
214
|
+
/**
|
|
215
|
+
* Estilos para el contenedor del icono del titulo del Stepper.
|
|
216
|
+
*/
|
|
217
|
+
wrapperIcon: ({ theme, ownerState }) => ({
|
|
218
|
+
display: "flex",
|
|
219
|
+
alignItems: "center",
|
|
220
|
+
justifyContent: "center",
|
|
221
|
+
background: theme.vars.palette.primary.enabledOpacity,
|
|
222
|
+
borderRadius: theme.vars.size.borderRadius["r1-5"],
|
|
223
|
+
...getSizeStyles(theme, ownerState?.size || "medium", "box", (size) => ({
|
|
224
|
+
width: size,
|
|
225
|
+
height: size
|
|
226
|
+
}))
|
|
227
|
+
}),
|
|
228
|
+
/**
|
|
229
|
+
* Estilos para el título del Stepper.
|
|
230
|
+
*/
|
|
231
|
+
wrapperTitle: ({ theme }) => ({
|
|
232
|
+
color: theme.vars.palette.text.primary,
|
|
233
|
+
display: "flex",
|
|
234
|
+
flexDirection: "column",
|
|
235
|
+
gap: theme.vars.size.baseSpacings["sp0-5"]
|
|
236
|
+
}),
|
|
237
|
+
/**
|
|
238
|
+
* Estilos para el icono del Stepper.
|
|
239
|
+
*/
|
|
240
|
+
icon: ({ theme, ownerState }) => ({
|
|
241
|
+
...getSizeStyles(theme, ownerState?.size || "medium", "case", (size) => ({
|
|
242
|
+
width: size,
|
|
243
|
+
height: size
|
|
244
|
+
}))
|
|
245
|
+
}),
|
|
246
|
+
/**
|
|
247
|
+
* Estilos para el título del Stepper.
|
|
248
|
+
*/
|
|
249
|
+
title: () => ({}),
|
|
250
|
+
/**
|
|
251
|
+
* Estilos para la descripción del Stepper.
|
|
252
|
+
*/
|
|
253
|
+
description: ({ theme }) => ({
|
|
254
|
+
"&.M4LTypography-root": {
|
|
255
|
+
color: theme.vars.palette.text.secondary
|
|
256
|
+
}
|
|
257
|
+
}),
|
|
258
|
+
/**
|
|
259
|
+
* Estilos para la sección de botones de acción del Stepper.
|
|
260
|
+
*/
|
|
261
|
+
stepperFooterSection: ({ theme }) => ({
|
|
262
|
+
display: "flex",
|
|
263
|
+
alignItems: "center",
|
|
264
|
+
justifyContent: "space-between",
|
|
265
|
+
paddingTop: theme.vars.size.baseSpacings.sp4,
|
|
266
|
+
position: "sticky",
|
|
267
|
+
bottom: 0,
|
|
268
|
+
backgroundColor: theme.vars.palette.background.default,
|
|
269
|
+
marginTop: "auto",
|
|
270
|
+
zIndex: 10
|
|
271
|
+
}),
|
|
272
|
+
/**
|
|
273
|
+
* Estilos para las acciones del lado izquierdo del StepperFooter.
|
|
274
|
+
*/
|
|
275
|
+
stepperFooterLeftActions: ({ theme }) => ({
|
|
276
|
+
display: "flex",
|
|
277
|
+
alignItems: "center",
|
|
278
|
+
gap: theme.vars.size.baseSpacings.sp3
|
|
279
|
+
}),
|
|
280
|
+
/**
|
|
281
|
+
* Estilos para las acciones del lado derecho del StepperFooter.
|
|
282
|
+
*/
|
|
283
|
+
stepperFooterRightActions: ({ theme }) => ({
|
|
284
|
+
display: "flex",
|
|
285
|
+
alignItems: "center",
|
|
286
|
+
gap: theme.vars.size.baseSpacings.sp3
|
|
287
|
+
}),
|
|
288
|
+
/**
|
|
289
|
+
* Estilos para el contenedor de los botones del Stepper.
|
|
290
|
+
*/
|
|
291
|
+
wrapperButtons: ({ theme }) => ({
|
|
292
|
+
display: "flex",
|
|
293
|
+
gap: theme.size.baseSpacings.sp3
|
|
294
|
+
})
|
|
295
|
+
};
|
|
296
|
+
export {
|
|
297
|
+
stepperStyles as s
|
|
298
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const STEPPER_DICTIONARY_ID = "stepper";
|
|
2
|
+
export declare function getStepperComponentsDictionary(): string[];
|
|
3
|
+
export declare const DICTIONARY: {
|
|
4
|
+
LABEL_PREV_BUTTON: string;
|
|
5
|
+
LABEL_NEXT_BUTTON: string;
|
|
6
|
+
LABEL_CANCEL_BUTTON: string;
|
|
7
|
+
LABEL_SUBMIT_BUTTON: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const STEPPER_DICTIONARY_ID = "stepper";
|
|
2
|
+
function getStepperComponentsDictionary() {
|
|
3
|
+
return [STEPPER_DICTIONARY_ID];
|
|
4
|
+
}
|
|
5
|
+
const DICTIONARY = {
|
|
6
|
+
LABEL_PREV_BUTTON: `${STEPPER_DICTIONARY_ID}.label_prev_button`,
|
|
7
|
+
LABEL_NEXT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_next_button`,
|
|
8
|
+
LABEL_CANCEL_BUTTON: `${STEPPER_DICTIONARY_ID}.label_cancel_button`,
|
|
9
|
+
LABEL_SUBMIT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_submit_button`
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
DICTIONARY as D,
|
|
13
|
+
getStepperComponentsDictionary as g
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormData, Step, VisibilityData } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* evaluateVisibilityStepCondition - Función helper que evalúa si un step debe ser visible según su condition
|
|
4
|
+
* @param step - El step a evaluar
|
|
5
|
+
* @param formData - Datos del formulario actual para evaluar la condition
|
|
6
|
+
* @param visibilityData - Datos adicionales para evaluar la condition (ej: objectId)
|
|
7
|
+
* @returns boolean - Retorna true si el step debe ser visible, false en caso contrario
|
|
8
|
+
*/
|
|
9
|
+
export declare const evaluateVisibilityStepCondition: (step: Step, formData?: FormData, visibilityData?: VisibilityData) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const evaluateVisibilityStepCondition = (step, formData, visibilityData) => {
|
|
2
|
+
if (!step.visibilityCondition) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
return step.visibilityCondition(formData || {}, visibilityData);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(
|
|
9
|
+
`Error evualuando la condición del step "${step.key}":`,
|
|
10
|
+
error
|
|
11
|
+
);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
evaluateVisibilityStepCondition as e
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormData, Step, VisibilityData } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* findNextVisibleValidStep - Función helper que busca el siguiente step válido según su visibilityCondition.
|
|
4
|
+
* @param currentStepIndex - Índice del step actual
|
|
5
|
+
* @param steps - Lista de todos los steps del Stepper
|
|
6
|
+
* @param formData - Datos del formulario actual para evaluar las conditions
|
|
7
|
+
* @param visibilityData - Datos adicionales para evaluar las conditions (ej: objectId)
|
|
8
|
+
* @returns number - Retorna el índice del siguiente step válido, o steps.length si no hay más steps válidos
|
|
9
|
+
*/
|
|
10
|
+
export declare const findNextVisibleValidStep: (currentStepIndex: number, steps: Step[], formData?: FormData, visibilityData?: VisibilityData) => number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { e as evaluateVisibilityStepCondition } from "../evaluateVisibilityStepCondition/index.js";
|
|
2
|
+
const findNextVisibleValidStep = (currentStepIndex, steps, formData, visibilityData) => {
|
|
3
|
+
for (let i = currentStepIndex + 1; i < steps.length; i++) {
|
|
4
|
+
const step = steps[i];
|
|
5
|
+
if (evaluateVisibilityStepCondition(step, formData || {}, visibilityData)) {
|
|
6
|
+
return i;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return steps.length;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
findNextVisibleValidStep as f
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormData, Step, VisibilityData } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* findPrevVisibleValidStep - Función helper que busca el paso anterior válido según su condition
|
|
4
|
+
* @param currentStepIndex - Índice del step actual
|
|
5
|
+
* @param steps - Lista de todos los steps del Stepper
|
|
6
|
+
* @param formData - Datos del formulario actual para evaluar las conditions
|
|
7
|
+
* @param visibilityData - Datos adicionales para evaluar las conditions (ej: objectId)
|
|
8
|
+
* @returns number - Retorna el índice del step anterior válido, o -1 si no hay steps anteriores válidos
|
|
9
|
+
*/
|
|
10
|
+
export declare const findPrevVisibleValidStep: (currentStepIndex: number, steps: Step[], formData?: FormData, visibilityData?: VisibilityData) => number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { e as evaluateVisibilityStepCondition } from "../evaluateVisibilityStepCondition/index.js";
|
|
2
|
+
const findPrevVisibleValidStep = (currentStepIndex, steps, formData, visibilityData) => {
|
|
3
|
+
for (let i = currentStepIndex - 1; i >= 0; i--) {
|
|
4
|
+
const step = steps[i];
|
|
5
|
+
if (evaluateVisibilityStepCondition(step, formData || {}, visibilityData)) {
|
|
6
|
+
return i;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return -1;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
findPrevVisibleValidStep as f
|
|
13
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { evaluateVisibilityStepCondition } from './evaluateVisibilityStepCondition';
|
|
2
|
+
export { findNextVisibleValidStep } from './findNextVisibleValidStep';
|
|
3
|
+
export { findPrevVisibleValidStep } from './findPrevVisibleValidStep';
|
|
4
|
+
export { isLastVisibleValidStep } from './isLastVisibleValidStep';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormData, Step, VisibilityData } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* isLastVisibleValidStep - Función helper que determina si el paso actual es el último paso válido
|
|
4
|
+
* @param currentStepIndex - Índice del step actual
|
|
5
|
+
* @param steps - Lista de todos los steps del Stepper
|
|
6
|
+
* @param formData - Datos del formulario actual para evaluar las conditions
|
|
7
|
+
* @param visibilityData - Datos adicionales para evaluar las conditions (ej: objectId)
|
|
8
|
+
* @returns boolean - Retorna true si el paso actual es el último paso válido
|
|
9
|
+
*/
|
|
10
|
+
export declare const isLastVisibleValidStep: (currentStepIndex: number, steps: Step[], formData?: FormData, visibilityData?: VisibilityData) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { e as evaluateVisibilityStepCondition } from "../evaluateVisibilityStepCondition/index.js";
|
|
2
|
+
const isLastVisibleValidStep = (currentStepIndex, steps, formData, visibilityData) => {
|
|
3
|
+
if (!steps || currentStepIndex >= steps.length || currentStepIndex < 0) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
for (let i = currentStepIndex + 1; i < steps.length; i++) {
|
|
7
|
+
const step = steps[i];
|
|
8
|
+
if (evaluateVisibilityStepCondition(step, formData || {}, visibilityData)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
isLastVisibleValidStep as i
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useIsLastVisibleValidStep - Hook que determina si el paso actual es el último paso válido
|
|
3
|
+
* considerando la "visibilityCondition" de cada step y los datos actuales del formulario
|
|
4
|
+
* @returns boolean - true si estamos en el último paso válido
|
|
5
|
+
*/
|
|
6
|
+
export declare const useIsLastVisibleValidStep: () => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useFormContext } from "react-hook-form";
|
|
2
|
+
import { u as useStepper } from "../useStepper/index.js";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
4
|
+
import { i as isLastVisibleValidStep } from "../../helpers/isLastVisibleValidStep/index.js";
|
|
5
|
+
const useIsLastVisibleValidStep = () => {
|
|
6
|
+
const { getValues } = useFormContext();
|
|
7
|
+
const { currentStep, steps, visibilityData } = useStepper(
|
|
8
|
+
(state) => ({
|
|
9
|
+
currentStep: state.currentStep,
|
|
10
|
+
steps: state.steps,
|
|
11
|
+
visibilityData: state.visibilityData
|
|
12
|
+
}),
|
|
13
|
+
shallow
|
|
14
|
+
);
|
|
15
|
+
const formData = getValues();
|
|
16
|
+
return isLastVisibleValidStep(
|
|
17
|
+
currentStep,
|
|
18
|
+
steps || [],
|
|
19
|
+
formData,
|
|
20
|
+
visibilityData
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
useIsLastVisibleValidStep as u
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { useStore } from "zustand";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
4
|
+
import { a as StepperContext } from "../../store/StepperContext/index.js";
|
|
5
|
+
function useStepper(selector, equalityFn) {
|
|
6
|
+
const store = useContext(StepperContext);
|
|
7
|
+
if (!store) {
|
|
8
|
+
throw new Error("useStepper context must be use inside StepperContext");
|
|
9
|
+
}
|
|
10
|
+
return useStore(store, selector, equalityFn ?? shallow);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useStepper as u
|
|
14
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { u as useStepper } from "../useStepper/index.js";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
|
+
import { shallow } from "zustand/shallow";
|
|
5
|
+
function useStepperActions() {
|
|
6
|
+
const { trigger, clearErrors, getValues, reset } = useFormContext();
|
|
7
|
+
const {
|
|
8
|
+
nextStep,
|
|
9
|
+
prevStep,
|
|
10
|
+
currentStep,
|
|
11
|
+
steps,
|
|
12
|
+
setStepValidationStatus,
|
|
13
|
+
resetStepper
|
|
14
|
+
} = useStepper(
|
|
15
|
+
(state) => ({
|
|
16
|
+
nextStep: state.actions.nextStep,
|
|
17
|
+
prevStep: state.actions.prevStep,
|
|
18
|
+
currentStep: state.currentStep,
|
|
19
|
+
steps: state.steps,
|
|
20
|
+
setStepValidationStatus: state.actions.setStepValidationStatus,
|
|
21
|
+
resetStepper: state.actions.resetStepper
|
|
22
|
+
}),
|
|
23
|
+
shallow
|
|
24
|
+
);
|
|
25
|
+
const prevStepAction = useCallback(() => {
|
|
26
|
+
const formData = getValues();
|
|
27
|
+
prevStep(formData);
|
|
28
|
+
}, [prevStep, getValues]);
|
|
29
|
+
const nextStepAction = useCallback(async () => {
|
|
30
|
+
const formData = getValues();
|
|
31
|
+
const futureSteps = steps.slice(currentStep + 1);
|
|
32
|
+
const futureFields = [];
|
|
33
|
+
futureSteps.forEach((step) => {
|
|
34
|
+
if (step.validationFields) {
|
|
35
|
+
futureFields.push(...step.validationFields);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const validateFn = async () => {
|
|
39
|
+
const currentStepData = steps[currentStep];
|
|
40
|
+
const fieldsToValidate = currentStepData?.validationFields || [];
|
|
41
|
+
if (fieldsToValidate.length === 0) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return await trigger(fieldsToValidate);
|
|
45
|
+
};
|
|
46
|
+
const success = await nextStep(validateFn, formData);
|
|
47
|
+
if (success && futureFields.length > 0) {
|
|
48
|
+
clearErrors(futureFields);
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
clearErrors(futureFields);
|
|
51
|
+
futureSteps.forEach((_, index) => {
|
|
52
|
+
const stepIndex = currentStep + 1 + index;
|
|
53
|
+
setStepValidationStatus(stepIndex, true);
|
|
54
|
+
});
|
|
55
|
+
}, 100);
|
|
56
|
+
}
|
|
57
|
+
return success;
|
|
58
|
+
}, [
|
|
59
|
+
nextStep,
|
|
60
|
+
clearErrors,
|
|
61
|
+
setStepValidationStatus,
|
|
62
|
+
steps,
|
|
63
|
+
currentStep,
|
|
64
|
+
trigger,
|
|
65
|
+
getValues
|
|
66
|
+
]);
|
|
67
|
+
const cancelAction = useCallback(() => {
|
|
68
|
+
reset();
|
|
69
|
+
clearErrors();
|
|
70
|
+
resetStepper();
|
|
71
|
+
}, [reset, clearErrors, resetStepper]);
|
|
72
|
+
return { prevStepAction, nextStepAction, cancelAction };
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
useStepperActions as u
|
|
76
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const pathIcons = {
|
|
2
|
+
patronum: "frontend/components/step/assets/icons/patronum_fill.svg",
|
|
3
|
+
arrowLeft: "frontend/components/step/assets/icons/arrow_left.svg",
|
|
4
|
+
arrowRight: "frontend/components/step/assets/icons/arrow_right.svg",
|
|
5
|
+
circleCheck: "frontend/components/step/assets/icons/circle_check.svg",
|
|
6
|
+
circleError: "frontend/components/step/assets/icons/circle_error.svg",
|
|
7
|
+
dotOutline: "frontend/components/step/assets/icons/dot_outline.svg",
|
|
8
|
+
dotSelected: "frontend/components/step/assets/icons/dot_selected.svg"
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
pathIcons as p
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { useStepper } from './hooks/useStepper/index';
|
|
2
|
+
export { Stepper } from './Stepper';
|
|
3
|
+
export { StepperContent } from './subcomponents/StepperContent';
|
|
4
|
+
export { Step } from './subcomponents/StepperContent/subcomponents/Step';
|
|
5
|
+
export { StepperFooter } from './subcomponents/StepperFooter';
|
|
6
|
+
export { StepperFooterLeftActions } from './subcomponents/StepperFooter/subcomponents/StepperFooterLeftActions';
|
|
7
|
+
export { StepperFooterRightActions } from './subcomponents/StepperFooter/subcomponents/StepperFooterRightActions';
|
|
8
|
+
export { StepperNextButton } from './subcomponents/StepperButtons/StepperNextButton';
|
|
9
|
+
export { StepperPrevButton } from './subcomponents/StepperButtons/StepperPrevButton';
|
|
10
|
+
export { StepperCancelButton } from './subcomponents/StepperButtons/StepperCancelButton';
|
|
11
|
+
export { StepperSubmitButton } from './subcomponents/StepperButtons/StepperSubmitButton';
|
|
12
|
+
export { evaluateVisibilityStepCondition } from './helpers/evaluateVisibilityStepCondition';
|
|
13
|
+
export { type Step as TypeStep } from './types';
|
|
14
|
+
export { getStepperComponentsDictionary } from './dictionary';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|