@m4l/components 9.3.24 → 9.3.25-beta.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.
Files changed (50) hide show
  1. package/components/CommonActions/components/ActionFormCancel/ActionFormCancel.js +10 -7
  2. package/components/CommonActions/components/ActionFormCancel/types.d.ts +8 -0
  3. package/components/DataGrid/formatters/ColumnIconFormatter/index.d.ts +1 -0
  4. package/components/DataGrid/index.d.ts +1 -1
  5. package/components/DataGrid/types.d.ts +2 -0
  6. package/components/Label/Label.js +1 -1
  7. package/components/PaperForm/PaperForm.js +1 -1
  8. package/components/PaperForm/components/Header.js +9 -7
  9. package/components/PaperForm/styles.js +9 -4
  10. package/components/PaperForm/types.d.ts +3 -2
  11. package/components/Stepper/Stepper.styles.js +1 -0
  12. package/components/Stepper/dictionary.js +0 -1
  13. package/components/Stepper/subcomponents/StepArea/hooks/useStepArea.d.ts +13 -0
  14. package/components/Stepper/subcomponents/StepArea/hooks/useStepArea.js +111 -0
  15. package/components/Stepper/subcomponents/StepArea/hooks/useVisibileSteps.d.ts +8 -0
  16. package/components/Stepper/subcomponents/StepArea/hooks/useVisibileSteps.js +79 -0
  17. package/components/Stepper/subcomponents/StepArea/index.js +7 -115
  18. package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.d.ts +2 -2
  19. package/components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js +3 -53
  20. package/components/Stepper/subcomponents/StepperButtons/StepperNextButton/index.js +3 -2
  21. package/components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js +3 -2
  22. package/components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js +24 -5
  23. package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/hooks/useIsStepVisible.d.ts +8 -0
  24. package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/hooks/useIsStepVisible.js +93 -0
  25. package/components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js +2 -51
  26. package/components/Stepper/types.d.ts +4 -0
  27. package/components/ToastContainer/ToastContainer.js +1 -0
  28. package/components/ToastContainer/constants.d.ts +1 -1
  29. package/components/ToastContainer/constants.js +1 -1
  30. package/components/WindowBase/contexts/WindowToolsMFContext/WindowToolsMFContext.js +47 -3
  31. package/components/WindowBase/contexts/WindowToolsMFContext/types.d.ts +1 -1
  32. package/components/WindowBase/subcomponents/Component/index.d.ts +12 -1
  33. package/components/WindowBase/subcomponents/Component/index.js +56 -2
  34. package/components/WindowBase/subcomponents/Component/types.d.ts +1 -0
  35. package/components/WindowBase/types.d.ts +1 -1
  36. package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +1 -0
  37. package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.js +1 -1
  38. package/components/areas/contexts/AreasContext/store.js +7 -3
  39. package/components/areas/contexts/AreasContext/types.d.ts +1 -1
  40. package/components/hook-form/RHFormContext/index.d.ts +1 -1
  41. package/components/mui_extended/CircularProgress/types.d.ts +1 -1
  42. package/components/popups/components/PopupsProvider/contexts/PopupsContext/store.js +5 -1
  43. package/components/popups/components/PopupsProvider/contexts/PopupsContext/types.d.ts +1 -1
  44. package/components/popups/components/PopupsProvider/hooks/usePopups.d.ts +2 -4
  45. package/components/popups/components/PopupsProvider/hooks/usePopups.js +19 -7
  46. package/components/popups/components/PopupsViewer/PopupsViewer.js +1 -1
  47. package/components/popups/components/PopupsViewer/PopupsViewer.styles.js +1 -1
  48. package/components/popups/components/PopupsViewer/subcomponents/Popup/Popup.js +32 -21
  49. package/index.js +60 -58
  50. package/package.json +1 -1
@@ -10,17 +10,18 @@ import { D as DICTIONARY } from "../../dictionary.js";
10
10
  import { W as WindowConfirm } from "../../../WindowConfirm/WindowConfirm.js";
11
11
  import { B as ButtonRootStyled } from "./slots/ActionFormCancelSlots.js";
12
12
  function ActionFormCancel(props) {
13
- const { className } = props;
13
+ const { className, onClose, linkToCloseWindow } = props;
14
14
  const { getLabel } = useModuleDictionary();
15
15
  const { openModal } = useModal();
16
- const { close: closeWindow, setFnQueryClose: setQueryClose } = useWindowToolsMF();
16
+ const { close, setFnQueryClose } = useWindowToolsMF();
17
17
  const { control } = useFormContext();
18
18
  const { isDirty } = useFormState({
19
19
  control
20
20
  });
21
21
  const onConfirmQuit = useCallback(() => {
22
- closeWindow();
23
- }, []);
22
+ close(false);
23
+ onClose?.();
24
+ }, [close, onClose]);
24
25
  const onClickCancel = useCallback(() => {
25
26
  if (isDirty) {
26
27
  openModal({
@@ -38,10 +39,12 @@ function ActionFormCancel(props) {
38
39
  } else {
39
40
  onConfirmQuit();
40
41
  }
41
- }, [getLabel, isDirty, openModal]);
42
+ }, [isDirty, openModal, getLabel, onConfirmQuit]);
42
43
  useEffect(() => {
43
- setQueryClose(onClickCancel);
44
- }, []);
44
+ if (linkToCloseWindow) {
45
+ setFnQueryClose(onClickCancel);
46
+ }
47
+ }, [onClickCancel, setFnQueryClose, linkToCloseWindow]);
45
48
  return /* @__PURE__ */ jsx(
46
49
  ButtonRootStyled,
47
50
  {
@@ -10,6 +10,14 @@ export interface ActionFormCancelProps extends ButtonProps {
10
10
  size?: Extract<Sizes, 'small' | 'medium'>;
11
11
  dictionaryId?: string;
12
12
  className?: string;
13
+ /**
14
+ * Cuando efectivamente se cierrar la ventana se ejecuta esta función.
15
+ */
16
+ onClose?: () => void;
17
+ /**
18
+ * Vicular la funcion de cierre de consulta con la funcion de cierre de la ventana.
19
+ */
20
+ linkToCloseWindow: boolean;
13
21
  }
14
22
  export interface ActionFormCancelOwnerState {
15
23
  size?: Extract<Sizes, 'small' | 'medium'>;
@@ -1,2 +1,3 @@
1
1
  export { ColumnIconFormatter } from './formatter';
2
2
  export type { ColumnIconFormatterProps } from './types';
3
+ export { useColumnIcon } from './useColumnIcon';
@@ -1,7 +1,7 @@
1
1
  export { DataGrid } from './DataGrid';
2
2
  export * from './formatters';
3
3
  export type { Column, RenderEditCellProps, RenderCellProps } from 'react-data-grid';
4
- export type { RowKey, ChangeUserColumn } from './types';
4
+ export type { RowKey, ChangeUserColumn, RowActionsGetter, RowKeyGetter } from './types';
5
5
  export { getDataGridComponentsDictionary } from './dictionary';
6
6
  export { TextEditor, NumberEditor } from './subcomponents/editors/TextEditor';
7
7
  export { getDataGridRowsFromSet } from './utils/getDataGridRowsFromSet';
@@ -112,6 +112,8 @@ export interface FilterSettings {
112
112
  filtersApplied: FilterApplied[];
113
113
  onChange: (event: FilterChangeEvent) => void;
114
114
  }
115
+ export type RowActionsGetter<TRow> = (row: TRow) => MenuAction[];
116
+ export type RowKeyGetter<TRow, TKey extends RowKey = RowKey> = (row: TRow) => TKey;
115
117
  /**--------------------Termina tipado de filtros-------------------------------------------- */
116
118
  export interface GridProps<TRow, TSummaryRow, TKey extends RowKey = RowKey> extends Omit<NativeDataGridProps<TRow, TSummaryRow>, 'rowKeyGetter' | 'rows' | 'columns' | 'onRowsChange' | 'selectedRows' | 'onSelectedRowsChange' | 'renderers'> {
117
119
  id: string;
@@ -9,7 +9,7 @@ const Label = (props) => {
9
9
  const { host_static_assets, environment_assets } = useEnvironment();
10
10
  const isSkeleton = useModuleSkeleton();
11
11
  const { currentSize } = useComponentSize(size);
12
- const hasHelperIcon = typeof helperMessage === "string" ? true : false;
12
+ const hasHelperIcon = typeof helperMessage === "string" && helperMessage.length > 0 ? true : false;
13
13
  const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
14
14
  const ownerState = {
15
15
  disabled,
@@ -45,7 +45,7 @@ function PaperForm(props) {
45
45
  ownerState: { ...ownerState },
46
46
  ...process.env.NODE_ENV !== "production" ? { "data-testid": dataTestId } : {},
47
47
  children: [
48
- variant !== "text" && /* @__PURE__ */ jsx(Header, { urlIcon, title, color, size }),
48
+ variant !== "onlyContainer" && /* @__PURE__ */ jsx(Header, { urlIcon, title, color, size, variant }),
49
49
  /* @__PURE__ */ jsx(ContentStyled, { ownerState: { ...ownerState }, children: renderChildren(children) })
50
50
  ]
51
51
  }
@@ -1,17 +1,19 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { H as HeaderStyled, I as IconStyled, T as TitleStyled } from "../slots/PaperFormSlots.js";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { I as IconStyled, T as TitleStyled, H as HeaderStyled } from "../slots/PaperFormSlots.js";
3
+ import { useMemo } from "react";
3
4
  const Header = (props) => {
4
- const { urlIcon, title, size, dataTestId, color } = props;
5
+ const { urlIcon, title, size, dataTestId, color, variant } = props;
5
6
  const ownerState = {
6
- color
7
+ color,
8
+ variant
7
9
  };
8
- const renderContentHeader = () => {
10
+ const contentHeader = useMemo(() => {
9
11
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10
12
  urlIcon ? /* @__PURE__ */ jsx(IconStyled, { src: urlIcon, size }) : null,
11
13
  /* @__PURE__ */ jsx(TitleStyled, { variant: "bodyDens", size, children: title })
12
14
  ] });
13
- };
14
- return /* @__PURE__ */ jsx(HeaderStyled, { role: "heading", ownerState, ...process.env.NODE_ENV !== "production" ? { "data-testid": dataTestId } : {}, children: renderContentHeader() });
15
+ }, [urlIcon, title, size]);
16
+ return /* @__PURE__ */ jsx(HeaderStyled, { role: "heading", ownerState, ...process.env.NODE_ENV !== "production" ? { "data-testid": dataTestId } : {}, children: contentHeader });
15
17
  };
16
18
  export {
17
19
  Header as H
@@ -8,11 +8,14 @@ const paperFormStyles = {
8
8
  */
9
9
  paperFormRoot: ({ theme, ownerState }) => ({
10
10
  background: theme.vars.palette.background.default,
11
- ...ownerState?.paperFormVariant !== "text" && {
11
+ ...ownerState?.paperFormVariant === "standard" && {
12
12
  borderRadius: theme.size.borderRadius.r1,
13
13
  border: `${theme.size.borderStroke.container}`,
14
14
  borderColor: theme.vars.palette.border.default
15
15
  },
16
+ // ...(ownerState?.paperFormVariant === 'text' && {
17
+ // borderRadius: theme.size.borderRadius.r1,
18
+ // }),
16
19
  width: "100%",
17
20
  overflow: "auto",
18
21
  ...ownerState?.height === "full" && {
@@ -41,8 +44,10 @@ const paperFormStyles = {
41
44
  gap: theme.vars.size.baseSpacings.sp1,
42
45
  overflow: "hidden",
43
46
  padding: `${theme.vars.size.baseSpacings.sp1} ${theme.vars.size.baseSpacings.sp2}`,
44
- borderRadius: `${theme.vars.size.borderRadius.r1} ${theme.vars.size.borderRadius.r1} 0 0`,
45
- background: theme.vars.palette[ownerState?.color ?? "default"].hoverOpacity,
47
+ ...ownerState?.paperFormVariant === "standard" && {
48
+ borderRadius: `${theme.vars.size.borderRadius.r1} ${theme.vars.size.borderRadius.r1} 0 0`,
49
+ background: theme.vars.palette[ownerState?.color ?? "default"].hoverOpacity
50
+ },
46
51
  alignSelf: "stretch",
47
52
  ...getSizeStyles(
48
53
  theme,
@@ -90,7 +95,7 @@ const paperFormStyles = {
90
95
  justifyContent: ownerState?.isForm ? "flex-start" : "center",
91
96
  gap: ownerState?.isForm ? theme.vars.size.baseSpacings.sp3 : theme.vars.size.baseSpacings.sp0,
92
97
  flexWrap: ownerState?.isForm ? "wrap" : "nowrap",
93
- padding: ownerState?.paperFormVariant === "text" ? "0px" : theme.vars.size.baseSpacings.sp3,
98
+ padding: ownerState?.paperFormVariant === "onlyContainer" ? "0px" : theme.vars.size.baseSpacings.sp3,
94
99
  background: theme.vars.palette.background.default,
95
100
  flex: 1,
96
101
  overflow: "auto"
@@ -9,11 +9,12 @@ export interface PaperFormProps {
9
9
  urlIcon?: string;
10
10
  title: string;
11
11
  children?: ReactNode | PropertyValueProps[];
12
- variant?: 'standard' | 'text';
12
+ variant?: 'standard' | 'text' | 'onlyContainer';
13
13
  color?: Extract<ComponentPalletColor, 'default'>;
14
14
  size?: Extract<Sizes, 'small' | 'medium'>;
15
15
  isForm?: boolean;
16
16
  dataTestId?: string;
17
+ border?: boolean;
17
18
  height?: 'auto' | 'full';
18
19
  }
19
20
  /**
@@ -25,7 +26,7 @@ export interface PaperFormProps {
25
26
  interface CommonsProps {
26
27
  paperFormVariant?: PaperFormProps['variant'];
27
28
  }
28
- export type HeaderProps = Omit<PaperFormProps, 'children' | 'isForm' | 'variant'> & CommonsProps;
29
+ export type HeaderProps = Omit<PaperFormProps, 'children' | 'isForm'> & CommonsProps;
29
30
  export type PaperFormOwnerState = Pick<PaperFormProps, 'isForm' | 'color' | 'size' | 'height'> & CommonsProps;
30
31
  /**
31
32
  * ***********************************
@@ -56,6 +56,7 @@ const stepperStyles = {
56
56
  display: "flex",
57
57
  flexDirection: "column",
58
58
  gap: theme.vars.size.baseSpacings.sp6,
59
+ overflowY: "auto",
59
60
  ...ownerState?.orientation === "vertical" || theme.generalSettings.isMobile ? {
60
61
  borderTop: "1px solid",
61
62
  paddingTop: theme.vars.size.baseSpacings.sp8
@@ -5,7 +5,6 @@ function getStepperComponentsDictionary() {
5
5
  const DICTIONARY = {
6
6
  LABEL_PREV_BUTTON: `${STEPPER_DICTIONARY_ID}.label_prev_button`,
7
7
  LABEL_NEXT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_next_button`,
8
- LABEL_CANCEL_BUTTON: `${STEPPER_DICTIONARY_ID}.label_cancel_button`,
9
8
  LABEL_SUBMIT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_submit_button`
10
9
  };
11
10
  export {
@@ -0,0 +1,13 @@
1
+ import { Step } from '../../../types';
2
+ /**
3
+ * useStepArea hook is responsible for managing the step area of the stepper
4
+ */
5
+ export declare function useStepArea(props: {
6
+ visibleSteps: Step[];
7
+ }): {
8
+ visibleTitle: boolean | undefined;
9
+ orientation: import('../../../types').Orientation | undefined;
10
+ handleStepClick: (targetIndex: number) => Promise<void>;
11
+ steps: Step[];
12
+ currentStep: number;
13
+ };
@@ -0,0 +1,111 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import { useFormContext } from "react-hook-form";
3
+ import { u as useStepper } from "../../../hooks/useStepper/index.js";
4
+ import { u as useDynamicValidation } from "../../../hooks/useDynamicValidation/index.js";
5
+ import { d as deepShallow } from "../../../../../utils/deepShallow.js";
6
+ function useStepArea(props) {
7
+ const { visibleSteps } = props;
8
+ const { trigger, clearErrors } = useFormContext();
9
+ const {
10
+ activateFieldsValidation,
11
+ startExternalValidation,
12
+ endExternalValidation
13
+ } = useDynamicValidation();
14
+ const {
15
+ currentStep,
16
+ steps,
17
+ visibleTitle,
18
+ setCurrentStep,
19
+ orientation,
20
+ setStepValidationStatus,
21
+ stepValidationStatus
22
+ } = useStepper(
23
+ (state) => ({
24
+ currentStep: state.currentStep,
25
+ steps: state.steps,
26
+ visibleTitle: state.visibleTitle,
27
+ setCurrentStep: state.actions.setCurrentStep,
28
+ indicatorType: state.indicatorType,
29
+ orientation: state.orientation,
30
+ setStepValidationStatus: state.actions.setStepValidationStatus,
31
+ stepValidationStatus: state.stepValidationStatus
32
+ }),
33
+ deepShallow
34
+ );
35
+ const handleStepClick = useCallback(async (targetIndex) => {
36
+ const currentIndex = visibleSteps.findIndex(
37
+ (step) => step.key === steps[currentStep].key
38
+ );
39
+ if (targetIndex === currentIndex) {
40
+ return;
41
+ }
42
+ const isNavigatingForward = targetIndex > currentIndex;
43
+ const targetOriginalIndex = steps.findIndex(
44
+ (s) => s.key === visibleSteps[targetIndex].key
45
+ );
46
+ if (!isNavigatingForward) {
47
+ setCurrentStep(targetOriginalIndex);
48
+ return;
49
+ }
50
+ const isSkippingSteps = targetIndex > currentIndex + 1;
51
+ if (isSkippingSteps) {
52
+ for (let i = currentIndex; i < targetIndex; i++) {
53
+ const step = visibleSteps[i];
54
+ const stepOriginalIndex = steps.findIndex((s) => s.key === step.key);
55
+ startExternalValidation();
56
+ const isValid = await trigger(step.validationFields);
57
+ endExternalValidation();
58
+ if (!isValid) {
59
+ setCurrentStep(stepOriginalIndex);
60
+ setStepValidationStatus(stepOriginalIndex, false);
61
+ activateFieldsValidation(step.validationFields || []);
62
+ return;
63
+ }
64
+ setStepValidationStatus(stepOriginalIndex, true);
65
+ }
66
+ } else {
67
+ const currentStepData = visibleSteps[currentIndex];
68
+ const currentStepOriginalIndex = steps.findIndex(
69
+ (s) => s.key === currentStepData.key
70
+ );
71
+ startExternalValidation();
72
+ const isCurrentValid = await trigger(currentStepData.validationFields);
73
+ endExternalValidation();
74
+ if (!isCurrentValid) {
75
+ setStepValidationStatus(currentStepOriginalIndex, false);
76
+ activateFieldsValidation(currentStepData.validationFields || []);
77
+ return;
78
+ }
79
+ setStepValidationStatus(currentStepOriginalIndex, true);
80
+ }
81
+ setCurrentStep(targetOriginalIndex);
82
+ if (isNavigatingForward) {
83
+ const currentStepData = visibleSteps[currentIndex];
84
+ const currentStepOriginalIndex = steps.findIndex(
85
+ (s) => s.key === currentStepData.key
86
+ );
87
+ const isCurrentStepValid = stepValidationStatus[currentStepOriginalIndex] !== false;
88
+ if (isCurrentStepValid) {
89
+ const targetStep = visibleSteps[targetIndex];
90
+ const targetStepFields = targetStep.validationFields || [];
91
+ if (targetStepFields.length > 0) {
92
+ clearErrors(targetStepFields);
93
+ setTimeout(() => {
94
+ clearErrors(targetStepFields);
95
+ setStepValidationStatus(targetOriginalIndex, true);
96
+ }, 100);
97
+ }
98
+ }
99
+ }
100
+ }, [visibleSteps, steps, setCurrentStep, currentStep, startExternalValidation, trigger, endExternalValidation, setStepValidationStatus, activateFieldsValidation, stepValidationStatus, clearErrors]);
101
+ return useMemo(() => ({
102
+ visibleTitle,
103
+ orientation,
104
+ handleStepClick,
105
+ steps,
106
+ currentStep
107
+ }), [visibleTitle, orientation, handleStepClick, steps, currentStep]);
108
+ }
109
+ export {
110
+ useStepArea as u
111
+ };
@@ -0,0 +1,8 @@
1
+ import { Step as StepType } from '../../../types';
2
+ /**
3
+ * useVisibileSteps hook is responsible for calculating the visible steps based on the form values and the visibility data
4
+ * Optimizado con useSyncExternalStore para evitar re-renders innecesarios
5
+ */
6
+ export declare function useVisibileSteps(): {
7
+ visibleSteps: StepType[];
8
+ };
@@ -0,0 +1,79 @@
1
+ import { useRef, useCallback, useSyncExternalStore, useMemo } from "react";
2
+ import { useFormContext } from "react-hook-form";
3
+ import { u as useStepper } from "../../../hooks/useStepper/index.js";
4
+ import { e as evaluateVisibilityStepCondition } from "../../../helpers/evaluateVisibilityStepCondition/index.js";
5
+ import { d as deepShallow } from "../../../../../utils/deepShallow.js";
6
+ function calculateVisibleSteps(steps, formValues, visibilityData) {
7
+ return steps.filter(
8
+ (step) => evaluateVisibilityStepCondition(step, formValues || {}, visibilityData || {})
9
+ );
10
+ }
11
+ function generateStepsKey(steps) {
12
+ return steps.map((step) => step.key).join(",");
13
+ }
14
+ function useVisibileSteps() {
15
+ const formContext = useFormContext();
16
+ const {
17
+ steps,
18
+ visibilityData
19
+ } = useStepper(
20
+ (state) => ({
21
+ steps: state.steps,
22
+ visibilityData: state.visibilityData
23
+ }),
24
+ deepShallow
25
+ );
26
+ const previousStepsKeyRef = useRef(null);
27
+ const cachedVisibleStepsRef = useRef([]);
28
+ const listenersRef = useRef(/* @__PURE__ */ new Set());
29
+ const subscribe = useCallback((callback) => {
30
+ listenersRef.current.add(callback);
31
+ const { unsubscribe } = formContext.watch((formValues) => {
32
+ const newVisibleSteps = calculateVisibleSteps(
33
+ steps,
34
+ formValues,
35
+ visibilityData
36
+ );
37
+ const newStepsKey = generateStepsKey(newVisibleSteps);
38
+ if (newStepsKey !== previousStepsKeyRef.current) {
39
+ previousStepsKeyRef.current = newStepsKey;
40
+ cachedVisibleStepsRef.current = newVisibleSteps;
41
+ listenersRef.current.forEach((listener) => listener());
42
+ }
43
+ });
44
+ return () => {
45
+ listenersRef.current.delete(callback);
46
+ unsubscribe();
47
+ };
48
+ }, [formContext, steps, visibilityData]);
49
+ const getSnapshot = useCallback(() => {
50
+ const formValues = formContext.getValues();
51
+ const currentVisibleSteps = calculateVisibleSteps(
52
+ steps,
53
+ formValues,
54
+ visibilityData
55
+ );
56
+ const stepsKey = generateStepsKey(currentVisibleSteps);
57
+ if (previousStepsKeyRef.current === null) {
58
+ previousStepsKeyRef.current = stepsKey;
59
+ cachedVisibleStepsRef.current = currentVisibleSteps;
60
+ }
61
+ if (stepsKey === previousStepsKeyRef.current) {
62
+ return cachedVisibleStepsRef.current;
63
+ }
64
+ previousStepsKeyRef.current = stepsKey;
65
+ cachedVisibleStepsRef.current = currentVisibleSteps;
66
+ return currentVisibleSteps;
67
+ }, [formContext, steps, visibilityData]);
68
+ const visibleSteps = useSyncExternalStore(
69
+ subscribe,
70
+ getSnapshot,
71
+ getSnapshot
72
+ );
73
+ return useMemo(() => ({
74
+ visibleSteps
75
+ }), [visibleSteps]);
76
+ }
77
+ export {
78
+ useVisibileSteps as u
79
+ };
@@ -1,127 +1,19 @@
1
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
2
  import { e as StepAreaStyled, f as StepStyled, g as StepNameStyled } from "../../slots/StepperSlot.js";
6
3
  import { I as Indicator } from "./subcomponents/Inidicator/index.js";
7
- import { shallow } from "zustand/shallow";
8
- import { u as useDynamicValidation } from "../../hooks/useDynamicValidation/index.js";
9
- import { e as evaluateVisibilityStepCondition } from "../../helpers/evaluateVisibilityStepCondition/index.js";
4
+ import { u as useStepArea } from "./hooks/useStepArea.js";
5
+ import { u as useVisibileSteps } from "./hooks/useVisibileSteps.js";
10
6
  function StepArea() {
11
- const { trigger, clearErrors } = useFormContext();
12
- const formValues = useWatch();
13
- const {
14
- activateFieldsValidation,
15
- startExternalValidation,
16
- endExternalValidation
17
- } = useDynamicValidation();
18
- const {
19
- currentStep,
20
- steps,
21
- visibleTitle,
22
- setCurrentStep,
23
- orientation,
24
- setStepValidationStatus,
25
- stepValidationStatus,
26
- visibilityData
27
- } = useStepper(
28
- (state) => ({
29
- currentStep: state.currentStep,
30
- steps: state.steps,
31
- visibleTitle: state.visibleTitle,
32
- setCurrentStep: state.actions.setCurrentStep,
33
- indicatorType: state.indicatorType,
34
- orientation: state.orientation,
35
- setStepValidationStatus: state.actions.setStepValidationStatus,
36
- stepValidationStatus: state.stepValidationStatus,
37
- visibilityData: state.visibilityData
38
- }),
39
- shallow
40
- );
41
- const allSteps = steps;
42
- const visibleSteps = useMemo(() => {
43
- return steps.filter(
44
- (step) => evaluateVisibilityStepCondition(step, formValues || {}, visibilityData)
45
- );
46
- }, [steps, formValues, visibilityData]);
7
+ const { visibleSteps } = useVisibileSteps();
8
+ const { handleStepClick, visibleTitle, orientation, steps, currentStep } = useStepArea({ visibleSteps });
47
9
  const ownerState = {
48
10
  visibleTitle,
49
11
  orientation,
50
12
  totalSteps: visibleSteps.length
51
13
  };
52
- const handleStepClick = async (targetIndex) => {
53
- const currentIndex = visibleSteps.findIndex(
54
- (step) => step.key === steps[currentStep].key
55
- );
56
- if (targetIndex === currentIndex) {
57
- return;
58
- }
59
- const isNavigatingForward = targetIndex > currentIndex;
60
- const targetOriginalIndex = steps.findIndex(
61
- (s) => s.key === visibleSteps[targetIndex].key
62
- );
63
- if (!isNavigatingForward) {
64
- setCurrentStep(targetOriginalIndex);
65
- return;
66
- }
67
- const isSkippingSteps = targetIndex > currentIndex + 1;
68
- if (isSkippingSteps) {
69
- for (let i = currentIndex; i < targetIndex; i++) {
70
- const step = visibleSteps[i];
71
- const stepOriginalIndex = steps.findIndex((s) => s.key === step.key);
72
- startExternalValidation();
73
- const isValid = await trigger(step.validationFields);
74
- endExternalValidation();
75
- if (!isValid) {
76
- setCurrentStep(stepOriginalIndex);
77
- setStepValidationStatus(stepOriginalIndex, false);
78
- activateFieldsValidation(step.validationFields || []);
79
- return;
80
- }
81
- setStepValidationStatus(stepOriginalIndex, true);
82
- }
83
- } else {
84
- const currentStepData = visibleSteps[currentIndex];
85
- const currentStepOriginalIndex = steps.findIndex(
86
- (s) => s.key === currentStepData.key
87
- );
88
- startExternalValidation();
89
- const isCurrentValid = await trigger(currentStepData.validationFields);
90
- endExternalValidation();
91
- if (!isCurrentValid) {
92
- setStepValidationStatus(currentStepOriginalIndex, false);
93
- activateFieldsValidation(currentStepData.validationFields || []);
94
- return;
95
- }
96
- setStepValidationStatus(currentStepOriginalIndex, true);
97
- }
98
- setCurrentStep(targetOriginalIndex);
99
- if (isNavigatingForward) {
100
- const currentStepData = visibleSteps[currentIndex];
101
- const currentStepOriginalIndex = steps.findIndex(
102
- (s) => s.key === currentStepData.key
103
- );
104
- const isCurrentStepValid = stepValidationStatus[currentStepOriginalIndex] !== false;
105
- if (isCurrentStepValid) {
106
- const targetStep = visibleSteps[targetIndex];
107
- const targetStepFields = targetStep.validationFields || [];
108
- if (targetStepFields.length > 0) {
109
- clearErrors(targetStepFields);
110
- setTimeout(() => {
111
- clearErrors(targetStepFields);
112
- setStepValidationStatus(targetOriginalIndex, true);
113
- }, 100);
114
- }
115
- }
116
- }
117
- };
118
- return /* @__PURE__ */ jsx(StepAreaStyled, { ownerState, children: allSteps.map((step, originalIndex) => {
119
- const isStepVisible = evaluateVisibilityStepCondition(
120
- step,
121
- formValues || {},
122
- visibilityData
123
- );
124
- const visibleStepIndex = isStepVisible ? visibleSteps.findIndex((visStep) => visStep.key === step.key) : -1;
14
+ return /* @__PURE__ */ jsx(StepAreaStyled, { ownerState, children: steps.map((step, originalIndex) => {
15
+ const visibleStepIndex = visibleSteps.findIndex((visibleStep) => visibleStep.key === step.key);
16
+ const isStepVisible = visibleStepIndex !== -1;
125
17
  return /* @__PURE__ */ jsxs(
126
18
  StepStyled,
127
19
  {
@@ -1,5 +1,5 @@
1
- import { StepperButtonProps } from '../../../types';
1
+ import { ActionFormCancelProps } from '../../../../CommonActions/components/ActionFormCancel/types';
2
2
  /**
3
3
  * Botón modular para cancelar el proceso del Stepper
4
4
  */
5
- export declare function StepperCancelButton(props: StepperButtonProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function StepperCancelButton(props: ActionFormCancelProps): import("react/jsx-runtime").JSX.Element;
@@ -1,58 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useCallback } from "react";
3
- import { useFormContext, useFormState } from "react-hook-form";
4
- import { u as useStepperActions } from "../../../hooks/useStepperActions/index.js";
5
- import { D as DICTIONARY$1 } from "../../../dictionary.js";
6
- import { D as DICTIONARY } from "../../../../CommonActions/dictionary.js";
7
- import { useModuleDictionary } from "@m4l/core";
8
- import { u as useModal } from "../../../../../hooks/useModal/index.js";
9
- import { u as useWindowToolsMF } from "../../../../WindowBase/hooks/useWindowToolsMF/index.js";
10
- import { W as WindowConfirm } from "../../../../WindowConfirm/WindowConfirm.js";
11
- import { B as Button } from "../../../../mui_extended/Button/Button.js";
2
+ import { A as ActionFormCancel } from "../../../../CommonActions/components/ActionFormCancel/ActionFormCancel.js";
12
3
  function StepperCancelButton(props) {
13
- const { label, ...rest } = props;
14
- const { getLabel } = useModuleDictionary();
15
- const { cancelAction } = useStepperActions();
16
- const { openModal } = useModal();
17
- const { close: closeWindow } = useWindowToolsMF();
18
- const { control } = useFormContext();
19
- const { isDirty } = useFormState({
20
- control
21
- });
22
- const onConfirmQuit = useCallback(() => {
23
- cancelAction();
24
- closeWindow();
25
- }, [cancelAction, closeWindow]);
26
- const handleCancel = useCallback(() => {
27
- if (isDirty) {
28
- openModal({
29
- window: /* @__PURE__ */ jsx(
30
- WindowConfirm,
31
- {
32
- variant: "warning",
33
- title: getLabel(DICTIONARY.CONFIRM_QUIT_TITLE),
34
- msg: getLabel(DICTIONARY.CONFIRM_QUIT_MSG),
35
- onClickIntro: onConfirmQuit
36
- }
37
- ),
38
- variant: "warning"
39
- });
40
- } else {
41
- onConfirmQuit();
42
- }
43
- }, [getLabel, isDirty, openModal, onConfirmQuit]);
44
- return /* @__PURE__ */ jsx(
45
- Button,
46
- {
47
- type: "button",
48
- label: label || getLabel(DICTIONARY$1.LABEL_CANCEL_BUTTON),
49
- variant: "outlined",
50
- color: "default",
51
- onClick: handleCancel,
52
- ...rest,
53
- "data-testid": "stepper-cancel-button"
54
- }
55
- );
4
+ const { ...rest } = props;
5
+ return /* @__PURE__ */ jsx(ActionFormCancel, { ...rest });
56
6
  }
57
7
  export {
58
8
  StepperCancelButton as S
@@ -7,15 +7,16 @@ import { useModuleDictionary, useEnvironment } from "@m4l/core";
7
7
  import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
8
8
  import { B as Button } from "../../../../mui_extended/Button/Button.js";
9
9
  function StepperNextButton(props) {
10
- const { label, ...rest } = props;
10
+ const { label, forceIsMobile, ...rest } = props;
11
11
  const { nextStepAction } = useStepperActions();
12
12
  const isMobile = useIsMobile();
13
+ const isMobileForce = forceIsMobile !== void 0 ? forceIsMobile : isMobile;
13
14
  const { getLabel } = useModuleDictionary();
14
15
  const { host_static_assets, environment_assets } = useEnvironment();
15
16
  const handleNext = async () => {
16
17
  await nextStepAction();
17
18
  };
18
- return isMobile ? /* @__PURE__ */ jsx(
19
+ return isMobileForce ? /* @__PURE__ */ jsx(
19
20
  IconButton,
20
21
  {
21
22
  type: "button",