@m4l/components 9.4.0-JA-20251207-Beta.0 → 9.4.1
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/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/getStepsAndValidationSchema.d.ts +4 -4
- package/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/getStepsAndValidationSchema.js +6 -12
- package/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/types.d.ts +6 -3
- package/components/Stepper/hooks/useDynamicValidation/index.d.ts +2 -1
- package/components/Stepper/hooks/useDynamicValidation/index.js +31 -6
- package/components/Stepper/index.d.ts +1 -0
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/hook-form/RHFRadioGroup/types.d.ts +1 -1
- package/index.d.ts +0 -1
- package/index.js +24 -24
- package/package.json +1 -1
- package/helpers/index.d.ts +0 -1
- package/helpers/index.js +0 -1
- /package/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/index.d.ts +0 -0
- /package/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/index.js +0 -0
- /package/{helpers → components/Stepper/helpers}/getStepsAndValidationSchema/types.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Step } from '../../
|
|
1
|
+
import { Step } from '../../types';
|
|
2
2
|
import { GetStepsAndValidationSchemaProps } from './types';
|
|
3
|
-
import { RHFormValues } from '
|
|
3
|
+
import { RHFormValues } from '../../../hook-form/RHFormProvider/types';
|
|
4
4
|
/**
|
|
5
5
|
* Hook personalizado que recibe un array de steps con validaciones y regresa todo listo para el Stepper
|
|
6
6
|
* Una sola configuración genera: validationSchema + steps + validationFields automáticamente
|
|
7
7
|
*/
|
|
8
|
-
export declare function getStepsAndValidationSchema<T extends RHFormValues>({ steps,
|
|
9
|
-
validationSchema: import('
|
|
8
|
+
export declare function getStepsAndValidationSchema<T extends RHFormValues>({ steps, }: GetStepsAndValidationSchemaProps<T>): {
|
|
9
|
+
validationSchema: import('../../../hook-form/RHFormProvider/types').ValidationSchema<T>;
|
|
10
10
|
steps: Step[];
|
|
11
11
|
};
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import { b as createValidationPartialObject, c as createValidationSchema, a as createValidationFullObject } from "
|
|
2
|
-
import { e as evaluateVisibilityStepCondition } from "../../components/Stepper/helpers/evaluateVisibilityStepCondition/index.js";
|
|
1
|
+
import { b as createValidationPartialObject, c as createValidationSchema, a as createValidationFullObject } from "../../../hook-form/RHFormProvider/schema.js";
|
|
3
2
|
function getStepsAndValidationSchema({
|
|
4
|
-
steps
|
|
5
|
-
visibilityData
|
|
3
|
+
steps
|
|
6
4
|
}) {
|
|
7
5
|
const validationSchema = (() => {
|
|
8
6
|
const combinedValidations = createValidationPartialObject({});
|
|
9
|
-
|
|
10
|
-
if (!step.visibilityCondition) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return evaluateVisibilityStepCondition(step, void 0, visibilityData);
|
|
14
|
-
});
|
|
15
|
-
visibleSteps.forEach((step) => {
|
|
7
|
+
steps.forEach((step) => {
|
|
16
8
|
if (step.validationFunction) {
|
|
17
9
|
const validationResult = step.validationFunction();
|
|
18
10
|
Object.assign(combinedValidations, validationResult);
|
|
19
11
|
}
|
|
20
12
|
});
|
|
21
|
-
return createValidationSchema(
|
|
13
|
+
return createValidationSchema(
|
|
14
|
+
createValidationFullObject(combinedValidations)
|
|
15
|
+
);
|
|
22
16
|
})();
|
|
23
17
|
const processedSteps = steps.map((step) => {
|
|
24
18
|
let validationFields = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RHFormValues, ValidationPartialObject } from '
|
|
2
|
-
import { Step } from '../../
|
|
1
|
+
import { RHFormValues, ValidationPartialObject } from '../../../hook-form/RHFormProvider/types';
|
|
2
|
+
import { Step } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuración completa de un step con validaciones incluidas
|
|
5
5
|
*/
|
|
@@ -16,7 +16,10 @@ export interface GetStepsAndValidationSchemaProps<T extends RHFormValues> {
|
|
|
16
16
|
*/
|
|
17
17
|
steps: StepWithValidation<T>[];
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* @deprecated Esta propiedad ya no se utiliza en el helper.
|
|
20
|
+
* El schema ahora incluye validaciones de TODOS los steps, no solo los visibles.
|
|
21
|
+
* visibilityData se debe pasar directamente al componente Stepper para evaluar
|
|
22
|
+
* visibilityCondition en tiempo real. Se eliminará en futuras versiones.
|
|
20
23
|
*/
|
|
21
24
|
visibilityData?: any;
|
|
22
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook que simula validación onChange de campos específicos del Stepper,
|
|
2
|
+
* Hook que simula validación onChange de campos específicos del Stepper,
|
|
3
|
+
* manteniendo el formulario en modo onSubmit para preservar el rendimiento.
|
|
3
4
|
* @returns Objeto con funciones para manejar la validación dinámica
|
|
4
5
|
*/
|
|
5
6
|
export declare function useDynamicValidation(): {
|
|
@@ -3,7 +3,7 @@ import { useFormContext, useWatch } from "react-hook-form";
|
|
|
3
3
|
import { p as parseWatchedValues } from "../../helpers/parseWatchedValues/index.js";
|
|
4
4
|
import { g as getInitialFieldValues } from "../../helpers/getInitialFieldValues/index.js";
|
|
5
5
|
function useDynamicValidation() {
|
|
6
|
-
const { trigger, getValues } = useFormContext();
|
|
6
|
+
const { trigger, getValues, clearErrors } = useFormContext();
|
|
7
7
|
const [activeFields, setActiveFields] = useState([]);
|
|
8
8
|
const [isValidating, setIsValidating] = useState(false);
|
|
9
9
|
const statusLoad = useWatch({
|
|
@@ -13,6 +13,8 @@ function useDynamicValidation() {
|
|
|
13
13
|
name: activeFields.length > 0 ? activeFields : ["__dummy__"]
|
|
14
14
|
});
|
|
15
15
|
const lastValuesRef = useRef({});
|
|
16
|
+
const pendingFieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
17
|
+
const validationTimeoutRef = useRef(null);
|
|
16
18
|
useEffect(() => {
|
|
17
19
|
if (activeFields.length === 0 || statusLoad !== "ready" || isValidating) {
|
|
18
20
|
return;
|
|
@@ -28,12 +30,30 @@ function useDynamicValidation() {
|
|
|
28
30
|
return hasChanged;
|
|
29
31
|
});
|
|
30
32
|
if (changedFields.length > 0) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
changedFields.forEach((field) => pendingFieldsRef.current.add(field));
|
|
34
|
+
if (validationTimeoutRef.current) {
|
|
35
|
+
clearTimeout(validationTimeoutRef.current);
|
|
36
|
+
}
|
|
37
|
+
validationTimeoutRef.current = setTimeout(async () => {
|
|
38
|
+
const fieldsToValidate = Array.from(pendingFieldsRef.current);
|
|
39
|
+
pendingFieldsRef.current.clear();
|
|
40
|
+
validationTimeoutRef.current = null;
|
|
41
|
+
for (const field of fieldsToValidate) {
|
|
42
|
+
const isValid = await trigger(field);
|
|
43
|
+
if (isValid) {
|
|
44
|
+
clearErrors(field);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, 150);
|
|
35
48
|
}
|
|
36
|
-
}, [
|
|
49
|
+
}, [
|
|
50
|
+
activeFields,
|
|
51
|
+
trigger,
|
|
52
|
+
clearErrors,
|
|
53
|
+
watchValues,
|
|
54
|
+
statusLoad,
|
|
55
|
+
isValidating
|
|
56
|
+
]);
|
|
37
57
|
const startExternalValidation = useCallback(() => {
|
|
38
58
|
setIsValidating(true);
|
|
39
59
|
}, []);
|
|
@@ -55,6 +75,11 @@ function useDynamicValidation() {
|
|
|
55
75
|
const clearAllValidation = useCallback(() => {
|
|
56
76
|
setActiveFields([]);
|
|
57
77
|
lastValuesRef.current = {};
|
|
78
|
+
pendingFieldsRef.current.clear();
|
|
79
|
+
if (validationTimeoutRef.current) {
|
|
80
|
+
clearTimeout(validationTimeoutRef.current);
|
|
81
|
+
validationTimeoutRef.current = null;
|
|
82
|
+
}
|
|
58
83
|
}, []);
|
|
59
84
|
return {
|
|
60
85
|
activateFieldsValidation,
|
|
@@ -10,5 +10,6 @@ export { StepperPrevButton } from './subcomponents/StepperButtons/StepperPrevBut
|
|
|
10
10
|
export { StepperCancelButton } from './subcomponents/StepperButtons/StepperCancelButton';
|
|
11
11
|
export { StepperSubmitButton } from './subcomponents/StepperButtons/StepperSubmitButton';
|
|
12
12
|
export { evaluateVisibilityStepCondition } from './helpers/evaluateVisibilityStepCondition';
|
|
13
|
+
export { getStepsAndValidationSchema } from './helpers/getStepsAndValidationSchema';
|
|
13
14
|
export { type Step as TypeStep } from './types';
|
|
14
15
|
export { getStepperComponentsDictionary } from './dictionary';
|
|
@@ -441,8 +441,8 @@ const createAreasStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
441
441
|
bounds: {
|
|
442
442
|
left: MARGIN_GRIDLAYOUT,
|
|
443
443
|
top: MARGIN_GRIDLAYOUT,
|
|
444
|
-
right: -
|
|
445
|
-
bottom: -
|
|
444
|
+
right: -MARGIN_GRIDLAYOUT,
|
|
445
|
+
bottom: -MARGIN_GRIDLAYOUT
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
448
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RadioGroupProps, Theme } from '@mui/material';
|
|
2
|
-
import { M4LOverridesStyleRules } from '
|
|
2
|
+
import { M4LOverridesStyleRules } from '../../../@types/augmentations';
|
|
3
3
|
import { RHFRADIO_GROUP_KEY_COMPONENT } from './constants';
|
|
4
4
|
import { RHFRadioGroupSlots } from './slots/slots';
|
|
5
5
|
import { LabelProps } from '../../Label/types';
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -233,15 +233,16 @@ import { S as S18 } from "./components/Stepper/subcomponents/StepperButtons/Step
|
|
|
233
233
|
import { S as S19 } from "./components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js";
|
|
234
234
|
import { S as S20 } from "./components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js";
|
|
235
235
|
import { e as e2 } from "./components/Stepper/helpers/evaluateVisibilityStepCondition/index.js";
|
|
236
|
-
import { g as g31 } from "./components/Stepper/
|
|
237
|
-
import { g as g32 } from "./components/
|
|
236
|
+
import { g as g31 } from "./components/Stepper/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
|
|
237
|
+
import { g as g32 } from "./components/Stepper/dictionary.js";
|
|
238
|
+
import { g as g33 } from "./components/hook-form/RHFormProvider/dictionary.js";
|
|
238
239
|
import { u as u23 } from "./contexts/AppearanceComponentContext/useAppearanceComponentStore.js";
|
|
239
240
|
import { A as A17 } from "./contexts/AppearanceComponentContext/AppearanceComponentContext.js";
|
|
240
241
|
import { a as a17, M as M10 } from "./contexts/ModalContext/index.js";
|
|
241
242
|
import { u as u24 } from "./hooks/useFormAddEdit/useFormAddEdit.js";
|
|
242
243
|
import { u as u25 } from "./hooks/useModal/index.js";
|
|
243
244
|
import { u as u26 } from "./hooks/useTab/index.js";
|
|
244
|
-
import { g as
|
|
245
|
+
import { g as g34 } from "./hooks/useFormAddEdit/dictionary.js";
|
|
245
246
|
import { u as u27 } from "./hooks/useFormFocus/index.js";
|
|
246
247
|
import { u as u28 } from "./hooks/useInterval/index.js";
|
|
247
248
|
import { u as u29 } from "./hooks/useComponentSize/useComponentSize.js";
|
|
@@ -257,18 +258,17 @@ import { u as u37 } from "./hooks/useSizeContainer/index.js";
|
|
|
257
258
|
import { u as u38 } from "./hooks/useWatchTyped/useTypedWatch.js";
|
|
258
259
|
import { c as c5 } from "./utils/capitalizeFirstLetter.js";
|
|
259
260
|
import { i as i2 } from "./utils/isValidDate.js";
|
|
260
|
-
import { g as
|
|
261
|
-
import { g as
|
|
262
|
-
import { g as
|
|
263
|
-
import { g as
|
|
264
|
-
import { a as a18, g as
|
|
261
|
+
import { g as g35 } from "./utils/getComponentUtilityClass.js";
|
|
262
|
+
import { g as g36 } from "./utils/getPaletteColor.js";
|
|
263
|
+
import { g as g37 } from "./utils/getTypographyStyles.js";
|
|
264
|
+
import { g as g38 } from "./utils/getIconColor.js";
|
|
265
|
+
import { a as a18, g as g39 } from "./utils/getSizeStyles/getSizeStyles.js";
|
|
265
266
|
import { O as O2 } from "./utils/ObjectQueue.js";
|
|
266
|
-
import { g as
|
|
267
|
+
import { g as g40, a as a19 } from "./utils/getComponentSlotRoot.js";
|
|
267
268
|
import { f as f2 } from "./utils/formatDistanceToNow/formatDistanteToNow.js";
|
|
268
|
-
import { g as
|
|
269
|
-
import { g as
|
|
269
|
+
import { g as g41 } from "./utils/getValidDate.js";
|
|
270
|
+
import { g as g42 } from "./utils/getNullGuard.js";
|
|
270
271
|
import { c as c6, d as d5 } from "./utils/deepShallow.js";
|
|
271
|
-
import { g as g42 } from "./helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
|
|
272
272
|
export {
|
|
273
273
|
A8 as AREAS_DICCTIONARY,
|
|
274
274
|
a3 as AREAS_DICTIONARY_ID,
|
|
@@ -493,23 +493,23 @@ export {
|
|
|
493
493
|
g3 as getAreasDictionary,
|
|
494
494
|
g4 as getCheckableListComponentsDictionary,
|
|
495
495
|
g5 as getCommonActionsDictionary,
|
|
496
|
-
|
|
496
|
+
g40 as getComponentClasses,
|
|
497
497
|
a19 as getComponentSlotRoot,
|
|
498
|
-
|
|
498
|
+
g35 as getComponentUtilityClass,
|
|
499
499
|
g6 as getDataGridComponentsDictionary,
|
|
500
500
|
g7 as getDataGridRowsFromSet,
|
|
501
501
|
g18 as getDistanceToNowFormatterComponentsDictionary,
|
|
502
502
|
g8 as getDynamicFilterComponentsDictionary,
|
|
503
503
|
a6 as getDynamicSortComponentsDictionary,
|
|
504
504
|
a5 as getFilterGroupFieldsByName,
|
|
505
|
-
|
|
505
|
+
g33 as getFormComponentsDictionary,
|
|
506
506
|
g16 as getFormatConcatenated,
|
|
507
507
|
g13 as getFormatDate,
|
|
508
508
|
g15 as getFormatPoints,
|
|
509
509
|
g17 as getFormatPrice,
|
|
510
510
|
g19 as getFormattersComponentsDictionary,
|
|
511
511
|
a18 as getHeightSizeStyles,
|
|
512
|
-
|
|
512
|
+
g38 as getIconColor,
|
|
513
513
|
g9 as getIsIfInDynamicFilter,
|
|
514
514
|
g23 as getLoadingErrorComponentsDictionary,
|
|
515
515
|
g25 as getMFLoaderComponentsDictionary,
|
|
@@ -518,23 +518,23 @@ export {
|
|
|
518
518
|
g30 as getModalDictionary,
|
|
519
519
|
g27 as getNoItemPrivilegesComponentsDictionary,
|
|
520
520
|
g26 as getNoItemSelectedComponentsDictionary,
|
|
521
|
-
|
|
521
|
+
g42 as getNullGuard,
|
|
522
522
|
g28 as getObjectLogsComponentsDictionary,
|
|
523
523
|
g12 as getPagerComponentsDictionary,
|
|
524
|
-
|
|
524
|
+
g36 as getPaletteColor,
|
|
525
525
|
g22 as getPeriodComponetsDictionary,
|
|
526
526
|
g21 as getRHFAutocompleteAsyncComponentsDictionary,
|
|
527
527
|
g20 as getRHFAutocompleteComponentsDictionary,
|
|
528
528
|
g10 as getRawFiltersForNetwork,
|
|
529
529
|
g11 as getRawSortsForNetwork,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
g39 as getSizeStyles,
|
|
531
|
+
g32 as getStepperComponentsDictionary,
|
|
532
|
+
g31 as getStepsAndValidationSchema,
|
|
533
533
|
g29 as getTabsNavigatorComponentsDictionary,
|
|
534
|
-
|
|
534
|
+
g37 as getTypographyStyles,
|
|
535
535
|
g14 as getUncertaintyFormat,
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
g41 as getValidDate,
|
|
537
|
+
g34 as getformAddEditDictionary,
|
|
538
538
|
i as isEqualLayout,
|
|
539
539
|
k as isEqualLayouts,
|
|
540
540
|
i2 as isValidDate,
|
package/package.json
CHANGED
package/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './getStepsAndValidationSchema';
|
package/helpers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|