@m4l/components 9.3.19 → 9.3.21-JAEBeta.0
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 +1 -1
- package/components/Chip/Chip.js +9 -7
- package/components/Chip/ChipStyles.js +4 -31
- package/components/Chip/helpers.d.ts +10 -0
- package/components/Chip/helpers.js +34 -0
- package/components/Chip/types.d.ts +6 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettings/index.js +1 -1
- package/components/DragResizeWindowRND/DragResizeWindowRND.js +14 -10
- package/components/DragResizeWindowRND/helpers/expandingParentContainer.d.ts +1 -1
- package/components/DragResizeWindowRND/helpers/expandingParentContainer.js +24 -19
- package/components/DragResizeWindowRND/helpers/getInitialSize.d.ts +3 -3
- package/components/DragResizeWindowRND/helpers/getInitialSize.js +18 -15
- package/components/DragResizeWindowRND/helpers/shrinkingParentContainer.d.ts +1 -1
- package/components/DragResizeWindowRND/helpers/shrinkingParentContainer.js +17 -9
- package/components/DragResizeWindowRND/hooks/useRNDDimensionEffects.js +4 -1
- package/components/DragResizeWindowRND/index.d.ts +1 -0
- package/components/DragResizeWindowRND/types.d.ts +12 -2
- package/components/DynamicFilter/DynamicFilter.js +2 -1
- package/components/DynamicFilter/helpers/frontEndHelpers.d.ts +2 -2
- package/components/DynamicFilter/helpers/frontEndHelpers.js +31 -9
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.d.ts +2 -1
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +4 -2
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/types.d.ts +3 -0
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +1 -1
- package/components/DynamicFilter/types.d.ts +4 -0
- package/components/DynamicSort/DynamicSort.js +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.d.ts +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +4 -2
- package/components/DynamicSort/subcomponents/DynamicSortBase/types.d.ts +3 -0
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +1 -1
- package/components/DynamicSort/types.d.ts +4 -0
- package/components/Image/Image.js +4 -1
- package/components/MFLoader/MFLoader.js +3 -2
- package/components/MFLoader/types.d.ts +5 -0
- package/components/ObjectLogs/hooks/useDetailFormatter.js +1 -1
- package/components/Stepper/Stepper.styles.js +17 -14
- package/components/Stepper/helpers/getInitialFieldValues/index.d.ts +12 -0
- package/components/Stepper/helpers/getInitialFieldValues/index.js +14 -0
- package/components/Stepper/helpers/index.d.ts +2 -0
- package/components/Stepper/helpers/parseWatchedValues/index.d.ts +17 -0
- package/components/Stepper/helpers/parseWatchedValues/index.js +12 -0
- package/components/Stepper/hooks/useDynamicValidation/index.d.ts +11 -0
- package/components/Stepper/hooks/useDynamicValidation/index.js +69 -0
- package/components/Stepper/hooks/useStepperActions/index.js +19 -3
- package/components/Stepper/store/StepperStore/index.js +20 -1
- package/components/Stepper/subcomponents/StepArea/index.js +45 -25
- package/components/Stepper/subcomponents/StepArea/subcomponents/Inidicator/index.js +18 -10
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +38 -5
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.d.ts +2 -1
- package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +5 -3
- package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +30 -11
- package/components/Stepper/subcomponents/StepperFooter/subcomponents/StepperFooterRightActions/index.js +20 -10
- package/components/Stepper/types.d.ts +7 -0
- package/components/WindowBase/WindowBase.js +3 -3
- package/components/WindowBase/WindowBase.styles.js +36 -31
- package/components/WindowBase/constants.d.ts +1 -1
- package/components/WindowBase/constants.js +2 -2
- package/components/WindowBase/index.d.ts +1 -0
- package/components/WindowBase/subcomponents/Component/index.js +2 -2
- package/components/WindowBase/subcomponents/Component/types.d.ts +2 -0
- package/components/WindowBase/subcomponents/Header/HeaderWindowBase.js +7 -7
- package/components/WindowBase/subcomponents/Header/types.d.ts +1 -1
- package/components/WindowBase/subcomponents/MicroFrontend/types.d.ts +2 -0
- package/components/WindowBase/types.d.ts +3 -3
- package/components/WindowConfirm/WindowConfirm.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +3 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.js +17 -2
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/areas/index.d.ts +1 -1
- package/components/areas/types.d.ts +1 -1
- package/components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js +3 -34
- package/components/formatters/DistanceToNowFormatter/dictionary.d.ts +8 -0
- package/components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.d.ts +13 -0
- package/components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.js +65 -0
- package/components/formatters/DistanceToNowFormatter/index.d.ts +1 -0
- package/components/formatters/DistanceToNowFormatter/types.d.ts +4 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +5 -1
- package/components/hook-form/RHFAutocomplete/constants.d.ts +1 -0
- package/components/hook-form/RHFAutocomplete/constants.js +5 -1
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +3 -1
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +4 -0
- package/components/hook-form/RHFormContext/index.d.ts +1 -1
- package/components/hook-form/RHFormContext/index.js +29 -4
- package/components/mui_extended/ToggleIconButton/ToggleIconButton.js +6 -2
- package/components/mui_extended/ToggleIconButton/ToggleIconButton.styles.js +9 -0
- package/components/mui_extended/ToggleIconButton/types.d.ts +1 -0
- package/components/mui_extended/index.d.ts +1 -1
- package/components/popups/components/PopupsProvider/hooks/usePopups.d.ts +2 -2
- package/components/popups/components/PopupsProvider/hooks/usePopups.js +0 -1
- package/components/popups/components/PopupsViewer/PopupsViewer.js +2 -2
- package/components/popups/components/PopupsViewer/subcomponents/Popup/Popup.js +3 -1
- package/components/popups/components/PopupsViewer/types.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/useSizeContainer/index.d.ts +2 -1
- package/hooks/useSizeContainer/index.js +22 -13
- package/hooks/useSizeContainer/types.d.ts +6 -0
- package/hooks/useStateRef/index.js +4 -4
- package/index.js +45 -38
- package/package.json +1 -1
- package/utils/deepShallow.d.ts +17 -0
- package/utils/deepShallow.js +76 -0
- package/utils/formatDistanceToNow/formatDistanteToNow.d.ts +2 -2
- package/utils/formatDistanceToNow/formatDistanteToNow.js +18 -2
- package/utils/formatDistanceToNow/types.d.ts +13 -0
- package/utils/index.d.ts +1 -0
|
@@ -3,19 +3,21 @@ import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
|
3
3
|
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_KEY_COMPONENT } from "../../constants.js";
|
|
5
5
|
import { u as useDynamicFilterBase } from "./useDynamicFilterBase.js";
|
|
6
|
+
import clsx from "clsx";
|
|
6
7
|
import { R as RootStyled, I as InnerContainerStyled } from "../../slots/dynamicFilterSlots.js";
|
|
7
8
|
import { I as InputFilter } from "../InputFilter/InputFilter.js";
|
|
8
9
|
import { A as AppliedFilters } from "../AppliedFilters/AppliedFilters.js";
|
|
9
10
|
import { F as FilterActions } from "../FilterActions/FilterActions.js";
|
|
10
11
|
import { P as PopoverFilter } from "../PopoverFilter/PopoverFilter.js";
|
|
11
12
|
import { D as DynamicFilterSlots } from "../../slots/SlotsEnum.js";
|
|
12
|
-
function DynamicFilterBase() {
|
|
13
|
+
function DynamicFilterBase(props) {
|
|
14
|
+
const { className } = props;
|
|
13
15
|
const { ownerState, dataTestId } = useDynamicFilterBase();
|
|
14
16
|
const classRoot = getComponentSlotRoot(DYNAMIC_FILTER_KEY_COMPONENT);
|
|
15
17
|
return /* @__PURE__ */ jsx(
|
|
16
18
|
RootStyled,
|
|
17
19
|
{
|
|
18
|
-
className: classRoot,
|
|
20
|
+
className: clsx(classRoot, className),
|
|
19
21
|
ownerState: { ...ownerState },
|
|
20
22
|
...getPropDataTestId(DYNAMIC_FILTER_KEY_COMPONENT, DynamicFilterSlots.root, dataTestId),
|
|
21
23
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -273,6 +273,10 @@ rawFilters: Array<RawFilterFieldApply>) => void;
|
|
|
273
273
|
* Propiedades que recibe el componente DynamicFilter
|
|
274
274
|
*/
|
|
275
275
|
export interface DynamicFilterProps {
|
|
276
|
+
/**
|
|
277
|
+
* "className" clase css para el componente
|
|
278
|
+
*/
|
|
279
|
+
className?: string;
|
|
276
280
|
/**
|
|
277
281
|
* "storeId" identificador del store
|
|
278
282
|
*/
|
|
@@ -5,13 +5,14 @@ import { D as DynamicSortProvider } from "./store/DynamicSortContext.js";
|
|
|
5
5
|
import { D as DynamicSortBase } from "./subcomponents/DynamicSortBase/DynamicSortBase.js";
|
|
6
6
|
const DynamicSort = forwardRef(
|
|
7
7
|
(props, ref) => {
|
|
8
|
+
const { className, ...others } = props;
|
|
8
9
|
const hasPresentFlags = useFlagsPresent([
|
|
9
10
|
CommonFlags.FLAG_DICTIONARY_LOADED
|
|
10
11
|
]);
|
|
11
12
|
if (!hasPresentFlags) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
|
-
return /* @__PURE__ */ jsx(DynamicSortProvider, { ...
|
|
15
|
+
return /* @__PURE__ */ jsx(DynamicSortProvider, { ...others, ref, children: /* @__PURE__ */ jsx(DynamicSortBase, { className }) });
|
|
15
16
|
}
|
|
16
17
|
);
|
|
17
18
|
export {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { DynamicSortBaseProps } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* DynamicSortBase es un componente base que contiene los subcomponentes InputSort, AppliedSorts, SortActions y PopoverSort.
|
|
3
4
|
*/
|
|
4
|
-
declare function DynamicSortBase(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function DynamicSortBase(props: DynamicSortBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
export default DynamicSortBase;
|
|
@@ -3,19 +3,21 @@ import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
|
3
3
|
import { a as getComponentSlotRoot } from "../../../../utils/getComponentSlotRoot.js";
|
|
4
4
|
import { D as DYNAMIC_SORT_KEY_COMPONENT } from "../../constants.js";
|
|
5
5
|
import { u as useDynamicSortBase } from "./useDynamicSortBase.js";
|
|
6
|
+
import clsx from "clsx";
|
|
6
7
|
import { R as RootStyled, I as InnerContainerStyled } from "../../slots/DynamicSortSlots.js";
|
|
7
8
|
import { I as InputSort } from "../InputSort/InputSort.js";
|
|
8
9
|
import { A as AppliedSorts } from "../AppliedSorts/AppliedSorts.js";
|
|
9
10
|
import { S as SortActions } from "../SortActions/SortActions.js";
|
|
10
11
|
import { P as PopoverSort } from "../PopoverSort/PopoverSort.js";
|
|
11
12
|
import { D as DynamicSortSlots } from "../../slots/SlotsEnum.js";
|
|
12
|
-
function DynamicSortBase() {
|
|
13
|
+
function DynamicSortBase(props) {
|
|
14
|
+
const { className } = props;
|
|
13
15
|
const { ownerState, dataTestId } = useDynamicSortBase();
|
|
14
16
|
const classRoot = getComponentSlotRoot(DYNAMIC_SORT_KEY_COMPONENT);
|
|
15
17
|
return /* @__PURE__ */ jsx(
|
|
16
18
|
RootStyled,
|
|
17
19
|
{
|
|
18
|
-
className: classRoot,
|
|
20
|
+
className: clsx(classRoot, className),
|
|
19
21
|
ownerState: { ...ownerState },
|
|
20
22
|
...getPropDataTestId(DYNAMIC_SORT_KEY_COMPONENT, DynamicSortSlots.root, dataTestId),
|
|
21
23
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -106,6 +106,10 @@ rawSorts: Array<RawSortFieldApply>) => void;
|
|
|
106
106
|
* Propiedades que recibe el componente DynamicSort
|
|
107
107
|
*/
|
|
108
108
|
export interface DynamicSortProps {
|
|
109
|
+
/**
|
|
110
|
+
* "className" clase css para el componente
|
|
111
|
+
*/
|
|
112
|
+
className?: string;
|
|
109
113
|
/**
|
|
110
114
|
* "storeId" identificador del store
|
|
111
115
|
*/
|
|
@@ -14,6 +14,8 @@ function Image(props) {
|
|
|
14
14
|
dataTestId,
|
|
15
15
|
className,
|
|
16
16
|
cover,
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
17
19
|
...others
|
|
18
20
|
} = props;
|
|
19
21
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -31,6 +33,7 @@ function Image(props) {
|
|
|
31
33
|
ImgStyled,
|
|
32
34
|
{
|
|
33
35
|
ownerState: { ...ownerState },
|
|
36
|
+
style: { width, height },
|
|
34
37
|
...getPropDataTestId(IMAGE_KEY_COMPONENT, ImageSlots.root, dataTestId),
|
|
35
38
|
...others,
|
|
36
39
|
className: clsx(IMAGE_CLASSES.root, className)
|
|
@@ -38,7 +41,7 @@ function Image(props) {
|
|
|
38
41
|
) })
|
|
39
42
|
}
|
|
40
43
|
);
|
|
41
|
-
}, [
|
|
44
|
+
}, [enableIntersectionObserver, threshold, ownerState, width, height, dataTestId, others, className]);
|
|
42
45
|
return lazyLoadComponent;
|
|
43
46
|
}
|
|
44
47
|
export {
|
|
@@ -30,7 +30,7 @@ function getDivScritId(prefix, moduleId) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
function MFLoader(props) {
|
|
33
|
-
const { prefix, moduleId, cache = true, debugPort, dynamicMFStore, windowTools } = props;
|
|
33
|
+
const { prefix, moduleId, cache = true, debugPort, dynamicMFStore, windowTools, emergeType } = props;
|
|
34
34
|
const { hostThemeOptions, fnComponentsOverrides } = useHostTheme();
|
|
35
35
|
const { networkOperation } = useNetwork();
|
|
36
36
|
const environment = useEnvironment();
|
|
@@ -74,7 +74,8 @@ function MFLoader(props) {
|
|
|
74
74
|
axiosOperation,
|
|
75
75
|
formatter,
|
|
76
76
|
dynamicMFStore,
|
|
77
|
-
windowTools
|
|
77
|
+
windowTools,
|
|
78
|
+
emergeType
|
|
78
79
|
);
|
|
79
80
|
} catch (_e) {
|
|
80
81
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DynamicMFStore } from '../WindowBase/contexts/DynamicMFParmsContext/store';
|
|
2
2
|
import { WindowToolsMF } from '../WindowBase/contexts';
|
|
3
|
+
import { EmergeType } from '../areas/types';
|
|
3
4
|
/**
|
|
4
5
|
* Propiedades base de un microfrontend.
|
|
5
6
|
*/
|
|
@@ -33,4 +34,8 @@ export interface MFLoaderProps extends MFBaseProps {
|
|
|
33
34
|
* Herramientas de ventana para el microfrontend.
|
|
34
35
|
*/
|
|
35
36
|
windowTools: WindowToolsMF;
|
|
37
|
+
/**
|
|
38
|
+
* Tipo de lanzamiento de la ventana, popup, layout, modal
|
|
39
|
+
*/
|
|
40
|
+
emergeType?: EmergeType;
|
|
36
41
|
}
|
|
@@ -33,7 +33,7 @@ const useDetailFormatter = (type) => {
|
|
|
33
33
|
title: getLabel(`${DICTIONARY.LABEL_LOG_DETAIL}`),
|
|
34
34
|
onClose: closeModal,
|
|
35
35
|
variant: "outlined",
|
|
36
|
-
|
|
36
|
+
emergeType: "modal",
|
|
37
37
|
children: /* @__PURE__ */ jsx(StackStyled, { direction: "column", flexGrow: 1, children: /* @__PURE__ */ jsx(DetailDialogComponent, { logId, type }) })
|
|
38
38
|
}
|
|
39
39
|
),
|
|
@@ -24,8 +24,13 @@ 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
|
+
*/
|
|
27
30
|
stepContent: ({ ownerState }) => ({
|
|
28
|
-
|
|
31
|
+
height: "100%",
|
|
32
|
+
display: ownerState?.isStepVisible ? "flex" : "none",
|
|
33
|
+
flexDirection: "column"
|
|
29
34
|
}),
|
|
30
35
|
/**
|
|
31
36
|
* Estilos para la sección que contiene los botones de acción del Stepper.
|
|
@@ -71,8 +76,7 @@ const stepperStyles = {
|
|
|
71
76
|
const isLastStep = step === totalSteps - 1;
|
|
72
77
|
return {
|
|
73
78
|
cursor: "pointer",
|
|
74
|
-
display: "flex",
|
|
75
|
-
visibility: ownerState?.isStepVisible ? "visible" : "hidden",
|
|
79
|
+
display: ownerState?.isStepVisible ? "flex" : "none",
|
|
76
80
|
flexDirection: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "column" : "row",
|
|
77
81
|
alignItems: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "start",
|
|
78
82
|
justifyContent: ownerState?.visibleTitle ? "space-between" : "center",
|
|
@@ -126,7 +130,7 @@ const stepperStyles = {
|
|
|
126
130
|
whiteSpace: "normal",
|
|
127
131
|
order: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? 1 : 0,
|
|
128
132
|
"&.M4LTypography-root": {
|
|
129
|
-
color:
|
|
133
|
+
color: ownerState?.originalStepIndex !== void 0 && typeof ownerState.originalStepIndex === "number" ? (ownerState.currentStep ?? 0) > ownerState.originalStepIndex ? theme.vars.palette.primary.semanticText : (ownerState.currentStep ?? 0) === ownerState.originalStepIndex ? theme.vars.palette.text.primary : theme.vars.palette.text.secondary : theme.vars.palette.text.secondary,
|
|
130
134
|
textAlign: ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? "center" : "right"
|
|
131
135
|
}
|
|
132
136
|
}),
|
|
@@ -134,13 +138,12 @@ const stepperStyles = {
|
|
|
134
138
|
* Estilos para el indicador numérico de cada paso del Stepper.
|
|
135
139
|
*/
|
|
136
140
|
indicator: ({ theme, ownerState }) => {
|
|
137
|
-
const currentStep = ownerState?.currentStep ?? 0;
|
|
138
141
|
const step = ownerState?.step ?? 0;
|
|
139
142
|
const totalSteps = ownerState?.totalSteps ?? 0;
|
|
140
|
-
const isCompleted =
|
|
141
|
-
const isCurrent =
|
|
143
|
+
const isCompleted = ownerState?.isCompleted ?? false;
|
|
144
|
+
const isCurrent = ownerState?.isCurrent ?? false;
|
|
145
|
+
const isValidStep = ownerState?.isValidStep ?? true;
|
|
142
146
|
const isLastStep = step === totalSteps - 1;
|
|
143
|
-
const isValidStep = ownerState?.stepValidationStatus?.[step] ?? true;
|
|
144
147
|
return {
|
|
145
148
|
...ownerState?.orientation === "horizontal" ? {
|
|
146
149
|
marginTop: theme.generalSettings.isMobile ? "6px" : theme.vars.size.baseSpacings.sp1
|
|
@@ -150,7 +153,7 @@ const stepperStyles = {
|
|
|
150
153
|
justifyContent: "center",
|
|
151
154
|
flexShrink: 0,
|
|
152
155
|
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 :
|
|
156
|
+
background: !isValidStep && ownerState?.hasBeenValidated ? theme.vars.palette.error.enabled : isCompleted && isValidStep ? ownerState?.indicatorType === "dot" || theme.generalSettings.isMobile ? theme.vars.palette.background.default : theme.vars.palette.primary.toneOpacity : isCurrent ? ownerState?.indicatorType === "dot" || theme.generalSettings.isMobile ? theme.vars.palette.background.default : theme.vars.palette.primary.enabled : ownerState?.indicatorType === "dot" || theme.generalSettings.isMobile ? theme.vars.palette.background.default : theme.vars.palette.default.enabled,
|
|
154
157
|
borderRadius: theme.vars.size.borderRadius.r2,
|
|
155
158
|
...ownerState?.indicatorType === "number" && !theme.generalSettings.isMobile && {
|
|
156
159
|
boxShadow: isCurrent ? "0 2px 8px 0 rgb(0, 100, 255, 0.16)" : "none"
|
|
@@ -178,13 +181,13 @@ const stepperStyles = {
|
|
|
178
181
|
* Estilos para el número de texto dentro del indicador numérico del Stepper.
|
|
179
182
|
*/
|
|
180
183
|
textNumber: ({ theme, ownerState }) => {
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
const
|
|
184
|
+
const isCompleted = ownerState?.isCompleted ?? false;
|
|
185
|
+
const isCurrent = ownerState?.isCurrent ?? false;
|
|
186
|
+
const isValidStep = ownerState?.isValidStep ?? true;
|
|
187
|
+
const hasBeenValidated = ownerState?.hasBeenValidated ?? false;
|
|
185
188
|
return {
|
|
186
189
|
"&.M4LTypography-root": {
|
|
187
|
-
color: isCompleted || isCurrent ? theme.vars.palette.primary.contrastText : theme.vars.palette.text.primary
|
|
190
|
+
color: !isValidStep && hasBeenValidated ? theme.vars.palette.error.contrastText : isCompleted || isCurrent ? theme.vars.palette.primary.contrastText : theme.vars.palette.text.primary
|
|
188
191
|
}
|
|
189
192
|
};
|
|
190
193
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obtiene los valores iniciales de campos específicos del formulario.
|
|
3
|
+
* Se usa para inicializar el ref que trackea cambios en los campos.
|
|
4
|
+
* @param allValues - Todos los valores del formulario (de getValues())
|
|
5
|
+
* @param fields - Lista de nombres de campos de los que queremos obtener valores
|
|
6
|
+
* @returns Objeto con solo los valores de los campos especificados
|
|
7
|
+
* @example
|
|
8
|
+
* const formValues = { name: 'John', age: 25, city: 'NY', country: 'USA' };
|
|
9
|
+
* getInitialFieldValues(formValues, ['name', 'age'])
|
|
10
|
+
* // Retorna: { name: 'John', age: 25 }
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInitialFieldValues(allValues: Record<string, any>, fields?: string[]): Record<string, any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function getInitialFieldValues(allValues, fields = []) {
|
|
2
|
+
if (fields.length === 0) {
|
|
3
|
+
return {};
|
|
4
|
+
}
|
|
5
|
+
return fields.reduce((acc, field) => {
|
|
6
|
+
if (field in allValues) {
|
|
7
|
+
acc[field] = allValues[field];
|
|
8
|
+
}
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getInitialFieldValues as g
|
|
14
|
+
};
|
|
@@ -2,3 +2,5 @@ export { evaluateVisibilityStepCondition } from './evaluateVisibilityStepConditi
|
|
|
2
2
|
export { findNextVisibleValidStep } from './findNextVisibleValidStep';
|
|
3
3
|
export { findPrevVisibleValidStep } from './findPrevVisibleValidStep';
|
|
4
4
|
export { isLastVisibleValidStep } from './isLastVisibleValidStep';
|
|
5
|
+
export { parseWatchedValues } from './parseWatchedValues';
|
|
6
|
+
export { getInitialFieldValues } from './getInitialFieldValues';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convierte los valores observados de useWatch en un objeto estructurado con los nombres de campos como keys.
|
|
3
|
+
*
|
|
4
|
+
* useWatch de react-hook-form retorna diferentes estructuras según la cantidad de campos observados:
|
|
5
|
+
* - Un solo campo: retorna el valor directamente
|
|
6
|
+
* - Múltiples campos: retorna un array con los valores en el mismo orden de los campos
|
|
7
|
+
* @param watchValues - Valores observados de useWatch (puede ser un valor único o un array)
|
|
8
|
+
* @param fields - Lista de nombres de campos que se están observando
|
|
9
|
+
* @returns Objeto con los valores actuales mapeados a sus respectivos nombres de campo
|
|
10
|
+
* @example
|
|
11
|
+
* // Para un solo campo
|
|
12
|
+
* parseWatchedValues('John', ['name']) // { name: 'John' }
|
|
13
|
+
*
|
|
14
|
+
* // Para múltiples campos
|
|
15
|
+
* parseWatchedValues(['John', 25], ['name', 'age']) // { name: 'John', age: 25 }
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseWatchedValues(watchValues: any, fields: string[]): Record<string, any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function parseWatchedValues(watchValues, fields) {
|
|
2
|
+
if (fields.length === 1) {
|
|
3
|
+
return { [fields[0]]: watchValues };
|
|
4
|
+
}
|
|
5
|
+
return fields.reduce((acc, field, index) => {
|
|
6
|
+
acc[field] = Array.isArray(watchValues) ? watchValues[index] : watchValues;
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
parseWatchedValues as p
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook que simula validación onChange de campos específicos del Stepper, manteniendo el formulario en modo onSubmit para preservar el rendimiento.
|
|
3
|
+
* @returns Objeto con funciones para manejar la validación dinámica
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDynamicValidation(): {
|
|
6
|
+
activateFieldsValidation: (fields: string[], skipIfValidating?: boolean) => void;
|
|
7
|
+
clearAllValidation: () => void;
|
|
8
|
+
activeFields: string[];
|
|
9
|
+
startExternalValidation: () => void;
|
|
10
|
+
endExternalValidation: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
+
import { p as parseWatchedValues } from "../../helpers/parseWatchedValues/index.js";
|
|
4
|
+
import { g as getInitialFieldValues } from "../../helpers/getInitialFieldValues/index.js";
|
|
5
|
+
function useDynamicValidation() {
|
|
6
|
+
const { trigger, getValues } = useFormContext();
|
|
7
|
+
const [activeFields, setActiveFields] = useState([]);
|
|
8
|
+
const [isValidating, setIsValidating] = useState(false);
|
|
9
|
+
const statusLoad = useWatch({
|
|
10
|
+
name: "statusLoad"
|
|
11
|
+
});
|
|
12
|
+
const watchValues = useWatch({
|
|
13
|
+
name: activeFields.length > 0 ? activeFields : ["__dummy__"]
|
|
14
|
+
});
|
|
15
|
+
const lastValuesRef = useRef({});
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (activeFields.length === 0 || statusLoad !== "ready" || isValidating) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const currentValues = parseWatchedValues(watchValues, activeFields);
|
|
21
|
+
const changedFields = activeFields.filter((field) => {
|
|
22
|
+
const currentValue = currentValues[field];
|
|
23
|
+
const lastValue = lastValuesRef.current[field];
|
|
24
|
+
const hasChanged = JSON.stringify(currentValue) !== JSON.stringify(lastValue);
|
|
25
|
+
if (hasChanged) {
|
|
26
|
+
lastValuesRef.current[field] = currentValue;
|
|
27
|
+
}
|
|
28
|
+
return hasChanged;
|
|
29
|
+
});
|
|
30
|
+
if (changedFields.length > 0) {
|
|
31
|
+
const timeoutId = setTimeout(() => {
|
|
32
|
+
trigger(changedFields);
|
|
33
|
+
}, 100);
|
|
34
|
+
return () => clearTimeout(timeoutId);
|
|
35
|
+
}
|
|
36
|
+
}, [activeFields, trigger, watchValues, statusLoad, isValidating]);
|
|
37
|
+
const startExternalValidation = useCallback(() => {
|
|
38
|
+
setIsValidating(true);
|
|
39
|
+
}, []);
|
|
40
|
+
const endExternalValidation = useCallback(() => {
|
|
41
|
+
setIsValidating(false);
|
|
42
|
+
}, []);
|
|
43
|
+
const activateFieldsValidation = useCallback(
|
|
44
|
+
(fields, skipIfValidating = true) => {
|
|
45
|
+
if (skipIfValidating && isValidating) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const formValues = getValues();
|
|
49
|
+
setActiveFields(fields);
|
|
50
|
+
const initialValues = getInitialFieldValues(formValues, fields);
|
|
51
|
+
lastValuesRef.current = initialValues;
|
|
52
|
+
},
|
|
53
|
+
[getValues, isValidating]
|
|
54
|
+
);
|
|
55
|
+
const clearAllValidation = useCallback(() => {
|
|
56
|
+
setActiveFields([]);
|
|
57
|
+
lastValuesRef.current = {};
|
|
58
|
+
}, []);
|
|
59
|
+
return {
|
|
60
|
+
activateFieldsValidation,
|
|
61
|
+
clearAllValidation,
|
|
62
|
+
activeFields,
|
|
63
|
+
startExternalValidation,
|
|
64
|
+
endExternalValidation
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
useDynamicValidation as u
|
|
69
|
+
};
|
|
@@ -2,8 +2,10 @@ 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";
|
|
5
6
|
function useStepperActions() {
|
|
6
7
|
const { trigger, clearErrors, getValues, reset } = useFormContext();
|
|
8
|
+
const { activateFieldsValidation, clearAllValidation } = useDynamicValidation();
|
|
7
9
|
const {
|
|
8
10
|
nextStep,
|
|
9
11
|
prevStep,
|
|
@@ -41,9 +43,20 @@ function useStepperActions() {
|
|
|
41
43
|
if (fieldsToValidate.length === 0) {
|
|
42
44
|
return true;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
const result = await trigger(fieldsToValidate);
|
|
47
|
+
if (!result) {
|
|
48
|
+
activateFieldsValidation(fieldsToValidate);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
45
51
|
};
|
|
46
52
|
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
|
+
clearAllValidation();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
47
60
|
if (success && futureFields.length > 0) {
|
|
48
61
|
clearErrors(futureFields);
|
|
49
62
|
setTimeout(() => {
|
|
@@ -62,13 +75,16 @@ function useStepperActions() {
|
|
|
62
75
|
steps,
|
|
63
76
|
currentStep,
|
|
64
77
|
trigger,
|
|
65
|
-
getValues
|
|
78
|
+
getValues,
|
|
79
|
+
activateFieldsValidation,
|
|
80
|
+
clearAllValidation
|
|
66
81
|
]);
|
|
67
82
|
const cancelAction = useCallback(() => {
|
|
68
83
|
reset();
|
|
69
84
|
clearErrors();
|
|
85
|
+
clearAllValidation();
|
|
70
86
|
resetStepper();
|
|
71
|
-
}, [reset, clearErrors, resetStepper]);
|
|
87
|
+
}, [reset, clearErrors, clearAllValidation, resetStepper]);
|
|
72
88
|
return { prevStepAction, nextStepAction, cancelAction };
|
|
73
89
|
}
|
|
74
90
|
export {
|
|
@@ -35,6 +35,18 @@ const createStepperStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
35
35
|
if (!preserveStepValidationStatus) {
|
|
36
36
|
state.stepValidationStatus = {};
|
|
37
37
|
}
|
|
38
|
+
if (!preserveStepValidationStatus) {
|
|
39
|
+
const firstVisibleStepIndex = findNextVisibleValidStep(
|
|
40
|
+
-1,
|
|
41
|
+
// Comenzar desde -1 para encontrar el primer step visible
|
|
42
|
+
steps,
|
|
43
|
+
{},
|
|
44
|
+
state.visibilityData
|
|
45
|
+
);
|
|
46
|
+
if (firstVisibleStepIndex !== 0 && firstVisibleStepIndex < steps.length) {
|
|
47
|
+
state.currentStep = firstVisibleStepIndex;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
});
|
|
39
51
|
},
|
|
40
52
|
/**
|
|
@@ -114,9 +126,16 @@ const createStepperStore = (initProps, storeDevtoolsEnabled = false) => {
|
|
|
114
126
|
*/
|
|
115
127
|
resetStepper: () => {
|
|
116
128
|
set((state) => {
|
|
117
|
-
state.currentStep = 0;
|
|
118
129
|
state.stepValidationStatus = {};
|
|
119
130
|
state.isValidating = false;
|
|
131
|
+
const firstVisibleStepIndex = findNextVisibleValidStep(
|
|
132
|
+
-1,
|
|
133
|
+
// Comenzar desde -1 para encontrar el primer step visible
|
|
134
|
+
state.steps,
|
|
135
|
+
{},
|
|
136
|
+
state.visibilityData
|
|
137
|
+
);
|
|
138
|
+
state.currentStep = firstVisibleStepIndex < state.steps.length ? firstVisibleStepIndex : 0;
|
|
120
139
|
});
|
|
121
140
|
}
|
|
122
141
|
}
|