@m4l/components 9.3.12-JT270825.beta.2 → 9.3.12-JT290825.beta.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.
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo, Children, isValidElement } from "react";
2
+ import { useRef, useMemo, Children, isValidElement, cloneElement } from "react";
3
3
  import { useFlagsPresent, CommonFlags } from "@m4l/core";
4
4
  import { S as StepperRootStyled, C as ContentSectionStyled } from "./slots/StepperSlot.js";
5
5
  import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
@@ -9,13 +9,21 @@ import { C as ContentArea } from "./subcomponents/ContentArea/index.js";
9
9
  import { S as StepperProvider } from "./store/StepperContext/index.js";
10
10
  import { S as StepperFooter } from "./subcomponents/StepperFooter/index.js";
11
11
  import { S as StepperContent } from "./subcomponents/StepperContent/index.js";
12
+ import { u as useStickyStepperFooter } from "./hooks/useStickyStepperFooter/index.js";
12
13
  import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
13
14
  function Stepper(props) {
14
15
  const { orientation, size, children } = props;
15
16
  const { currentSize } = useComponentSize(size);
17
+ const containerRef = useRef(null);
18
+ const contentSectionRef = useRef(null);
19
+ const stepperFooterSticky = useStickyStepperFooter(
20
+ containerRef,
21
+ contentSectionRef
22
+ );
16
23
  const ownerState = {
17
24
  size: currentSize,
18
- orientation
25
+ orientation,
26
+ stepperFooterSticky
19
27
  };
20
28
  const classRoot = getComponentSlotRoot(STEPPER_PREFIX_NAME);
21
29
  const { stepperFooter, stepperContent } = useMemo(() => {
@@ -61,7 +69,7 @@ function Stepper(props) {
61
69
  /* @__PURE__ */ jsx(StepArea, {}),
62
70
  /* @__PURE__ */ jsx(ContentArea, { children: stepperContent })
63
71
  ] }),
64
- stepperFooter
72
+ stepperFooter && cloneElement(stepperFooter, { ownerState })
65
73
  ] }) });
66
74
  }
67
75
  export {
@@ -4,11 +4,13 @@ const stepperStyles = {
4
4
  *
5
5
  * Estilos para el contenedor principal del Stepper.
6
6
  */
7
- stepperRoot: ({ theme }) => ({
7
+ stepperRoot: ({ theme, ownerState }) => ({
8
8
  display: "flex",
9
9
  flexDirection: "column",
10
+ justifyContent: ownerState?.stepperFooterSticky ? "flex-start" : "space-between",
10
11
  background: theme.vars.palette.background.default,
11
12
  width: "100%",
13
+ height: "100%",
12
14
  borderRadius: theme.vars.size.borderRadius.r1
13
15
  }),
14
16
  /**
@@ -245,11 +247,18 @@ const stepperStyles = {
245
247
  /**
246
248
  * Estilos para la sección de botones de acción del Stepper.
247
249
  */
248
- stepperFooterSection: ({ theme }) => ({
250
+ stepperFooterSection: ({ theme, ownerState }) => ({
249
251
  display: "flex",
250
252
  alignItems: "center",
251
253
  justifyContent: "space-between",
252
- paddingTop: theme.vars.size.baseSpacings.sp4
254
+ paddingTop: theme.vars.size.baseSpacings.sp4,
255
+ ...ownerState?.stepperFooterSticky && {
256
+ position: "sticky",
257
+ bottom: 0,
258
+ backgroundColor: theme.vars.palette.background.default,
259
+ marginTop: "auto",
260
+ zIndex: 10
261
+ }
253
262
  }),
254
263
  /**
255
264
  * Estilos para las acciones del lado izquierdo del StepperFooter.
@@ -1,4 +1,7 @@
1
1
  const STEPPER_DICTIONARY_ID = "stepper";
2
+ function getStepperComponentsDictionary() {
3
+ return [STEPPER_DICTIONARY_ID];
4
+ }
2
5
  const DICTIONARY = {
3
6
  LABEL_PREV_BUTTON: `${STEPPER_DICTIONARY_ID}.label_prev_button`,
4
7
  LABEL_NEXT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_next_button`,
@@ -6,5 +9,6 @@ const DICTIONARY = {
6
9
  LABEL_SUBMIT_BUTTON: `${STEPPER_DICTIONARY_ID}.label_submit_button`
7
10
  };
8
11
  export {
9
- DICTIONARY as D
12
+ DICTIONARY as D,
13
+ getStepperComponentsDictionary as g
10
14
  };
@@ -2,7 +2,14 @@ import { u as useStepper } from "../useStepper/index.js";
2
2
  import { useFormContext } from "react-hook-form";
3
3
  function useStepperActions() {
4
4
  const { trigger, clearErrors, getValues, reset } = useFormContext();
5
- const { nextStep, prevStep, currentStep, steps, setStepValidationStatus, resetStepper } = useStepper((state) => ({
5
+ const {
6
+ nextStep,
7
+ prevStep,
8
+ currentStep,
9
+ steps,
10
+ setStepValidationStatus,
11
+ resetStepper
12
+ } = useStepper((state) => ({
6
13
  nextStep: state.actions.nextStep,
7
14
  prevStep: state.actions.prevStep,
8
15
  currentStep: state.currentStep,
@@ -27,7 +34,7 @@ function useStepperActions() {
27
34
  const currentStepData = steps[currentStep];
28
35
  const fieldsToValidate = currentStepData?.validationFields || [];
29
36
  if (fieldsToValidate.length === 0) {
30
- return await trigger();
37
+ return true;
31
38
  }
32
39
  return await trigger(fieldsToValidate);
33
40
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook para determinar cuando el footer del Stepper debe usar posición sticky.
3
+ * @param containerRef - Referencia al contenedor del Stepper
4
+ * @param contentRef - Referencia al área de contenido del Stepper
5
+ * @returns boolean - true si el footer debe ser sticky, false en caso contrario
6
+ */
7
+ export declare function useStickyStepperFooter(containerRef: React.RefObject<HTMLDivElement>, contentRef: React.RefObject<HTMLElement>): boolean;
@@ -0,0 +1,20 @@
1
+ import { useMemo } from "react";
2
+ import { u as useSizeContainer } from "../../../../hooks/useSizeContainer/index.js";
3
+ function useStickyStepperFooter(containerRef, contentRef) {
4
+ const containerSize = useSizeContainer(containerRef.current);
5
+ const shouldBeSticky = useMemo(() => {
6
+ if (!containerRef.current || !contentRef.current) {
7
+ return false;
8
+ }
9
+ const containerHeight = containerRef.current.clientHeight;
10
+ const contentHeight = contentRef.current.clientHeight;
11
+ const totalContentHeight = contentHeight + 80;
12
+ const exceedsContainer = totalContentHeight > containerHeight;
13
+ const hasMinimumSpace = containerHeight > 120;
14
+ return exceedsContainer && hasMinimumSpace;
15
+ }, [containerSize, containerRef, contentRef]);
16
+ return shouldBeSticky;
17
+ }
18
+ export {
19
+ useStickyStepperFooter as u
20
+ };
@@ -11,3 +11,4 @@ export { StepperCancelButton } from './subcomponents/StepperButtons/StepperCance
11
11
  export { StepperSubmitButton } from './subcomponents/StepperButtons/StepperSubmitButton';
12
12
  export { evaluateVisibilityStepCondition } from './helpers/evaluateVisibilityStepCondition';
13
13
  export { type Step as TypeStep } from './types';
14
+ export { getStepperComponentsDictionary } from './dictionary';
@@ -1,17 +1,23 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
2
3
  import { W as WrapperIconStyled, I as IconStyled } from "../../../../slots/StepperSlot.js";
3
4
  import { p as pathIcons } from "../../../../icons.js";
4
5
  import { u as useStepper } from "../../../../hooks/useStepper/index.js";
5
6
  function WrapperIcon() {
6
- const { host_static_assets, environment_assets } = useStepper((state) => ({
7
+ const { steps, currentStep, host_static_assets, environment_assets } = useStepper((state) => ({
7
8
  host_static_assets: state.host_static_assets,
8
- environment_assets: state.environment_assets
9
+ environment_assets: state.environment_assets,
10
+ steps: state.steps,
11
+ currentStep: state.currentStep
9
12
  }));
13
+ const currentStepConfig = useMemo(() => {
14
+ return steps[currentStep];
15
+ }, [steps, currentStep]);
10
16
  return /* @__PURE__ */ jsx(WrapperIconStyled, { children: /* @__PURE__ */ jsx(
11
17
  IconStyled,
12
18
  {
13
19
  color: "primary.enabled",
14
- src: `${host_static_assets}/${environment_assets}/${pathIcons.patronum}`
20
+ src: currentStepConfig.icon ? currentStepConfig.icon : `${host_static_assets}/${environment_assets}/${pathIcons.patronum}`
15
21
  }
16
22
  ) });
17
23
  }
@@ -4,7 +4,7 @@ import { i as StepperFooterSectionStyled } from "../../slots/StepperSlot.js";
4
4
  import { S as StepperFooterLeftActions } from "./subcomponents/StepperFooterLeftActions/index.js";
5
5
  import { S as StepperFooterRightActions } from "./subcomponents/StepperFooterRightActions/index.js";
6
6
  function StepperFooter(props) {
7
- const { children } = props;
7
+ const { children, ownerState } = props;
8
8
  const { stepperFooterLeftActions, stepperFooterRightActions } = useMemo(() => {
9
9
  let parsedLeftActions = null;
10
10
  let parsedRightActions = null;
@@ -38,7 +38,7 @@ function StepperFooter(props) {
38
38
  stepperFooterRightActions: parsedRightActions
39
39
  };
40
40
  }, [children]);
41
- return /* @__PURE__ */ jsxs(StepperFooterSectionStyled, { children: [
41
+ return /* @__PURE__ */ jsxs(StepperFooterSectionStyled, { ownerState, children: [
42
42
  stepperFooterLeftActions,
43
43
  stepperFooterRightActions
44
44
  ] });
@@ -22,6 +22,10 @@ export type Step = {
22
22
  * Descripción del step.
23
23
  */
24
24
  description?: string;
25
+ /**
26
+ * Icono del step.
27
+ */
28
+ icon?: string;
25
29
  /**
26
30
  * Array con los campos que se deben validar en el step.
27
31
  */
@@ -130,6 +134,7 @@ export interface IndicatorProps {
130
134
  */
131
135
  export interface StepperFooterProps {
132
136
  children?: ReactNode;
137
+ ownerState?: StepperOwnerState;
133
138
  }
134
139
  /**
135
140
  * Props del StepperFooterLeftActions
@@ -143,7 +148,7 @@ export interface StepperFooterLeftActionsProps {
143
148
  export interface StepperFooterRightActionsProps {
144
149
  children?: ReactNode;
145
150
  }
146
- export interface StepperOwnerState extends Pick<StepperProps, 'visibleTitle'> {
151
+ export interface StepperOwnerState extends Pick<StepperProps, 'visibleTitle'>, Record<string, unknown> {
147
152
  step?: number;
148
153
  currentStep?: number;
149
154
  totalSteps?: number;
@@ -151,6 +156,7 @@ export interface StepperOwnerState extends Pick<StepperProps, 'visibleTitle'> {
151
156
  indicatorType?: IndicatorType;
152
157
  size?: Extract<Sizes, 'small' | 'medium'>;
153
158
  stepValidationStatus?: Record<number, boolean>;
159
+ stepperFooterSticky?: boolean;
154
160
  }
155
161
  export type StepperSlotsType = StepperSlots | ContentSlots | ContentAreaSlots | StepperFooterSlots;
156
162
  export type StepperStyles = M4LOverridesStyleRules<StepperSlotsType, typeof STEPPER_PREFIX_NAME, Theme>;
package/index.js CHANGED
@@ -206,15 +206,16 @@ import { S as S18 } from "./components/Stepper/subcomponents/StepperButtons/Step
206
206
  import { S as S19 } from "./components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js";
207
207
  import { S as S20 } from "./components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js";
208
208
  import { e as e3 } from "./components/Stepper/helpers/evaluateVisibilityStepCondition/index.js";
209
+ import { g as g29 } from "./components/Stepper/dictionary.js";
209
210
  import { F as F3, R as R23, u as u17 } from "./components/hook-form/RHFormContext/index.js";
210
- import { g as g29 } from "./components/hook-form/RHFormContext/dictionary.js";
211
+ import { g as g30 } from "./components/hook-form/RHFormContext/dictionary.js";
211
212
  import { u as u18 } from "./contexts/AppearanceComponentContext/useAppearanceComponentStore.js";
212
213
  import { A as A16 } from "./contexts/AppearanceComponentContext/AppearanceComponentContext.js";
213
214
  import { a as a15, M as M9 } from "./contexts/ModalContext/index.js";
214
215
  import { u as u19 } from "./hooks/useFormAddEdit/index.js";
215
216
  import { u as u20 } from "./hooks/useModal/index.js";
216
217
  import { u as u21 } from "./hooks/useTab/index.js";
217
- import { g as g30 } from "./hooks/useFormAddEdit/dictionary.js";
218
+ import { g as g31 } from "./hooks/useFormAddEdit/dictionary.js";
218
219
  import { u as u22 } from "./hooks/useFormFocus/index.js";
219
220
  import { u as u23 } from "./hooks/useInterval/index.js";
220
221
  import { u as u24 } from "./hooks/useComponentSize/useComponentSize.js";
@@ -228,17 +229,17 @@ import { u as u30 } from "./hooks/usePopoverContainer/usePopoverContainer.js";
228
229
  import { u as u31 } from "./hooks/useIsVisible/useIsVisible.js";
229
230
  import { c as c4 } from "./utils/capitalizeFirstLetter.js";
230
231
  import { i as i2 } from "./utils/isValidDate.js";
231
- import { g as g31 } from "./utils/getComponentUtilityClass.js";
232
- import { g as g32 } from "./utils/getPaletteColor.js";
233
- import { g as g33 } from "./utils/getTypographyStyles.js";
234
- import { g as g34 } from "./utils/getIconColor.js";
235
- import { a as a16, g as g35 } from "./utils/getSizeStyles/getSizeStyles.js";
232
+ import { g as g32 } from "./utils/getComponentUtilityClass.js";
233
+ import { g as g33 } from "./utils/getPaletteColor.js";
234
+ import { g as g34 } from "./utils/getTypographyStyles.js";
235
+ import { g as g35 } from "./utils/getIconColor.js";
236
+ import { a as a16, g as g36 } from "./utils/getSizeStyles/getSizeStyles.js";
236
237
  import { O as O2 } from "./utils/ObjectQueue.js";
237
- import { g as g36, a as a17 } from "./utils/getComponentSlotRoot.js";
238
+ import { g as g37, a as a17 } from "./utils/getComponentSlotRoot.js";
238
239
  import { f } from "./utils/formatDistanceToNow/formatDistanteToNow.js";
239
- import { g as g37 } from "./utils/getValidDate.js";
240
- import { g as g38 } from "./utils/getNullGuard.js";
241
- import { g as g39 } from "./helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
240
+ import { g as g38 } from "./utils/getValidDate.js";
241
+ import { g as g39 } from "./utils/getNullGuard.js";
242
+ import { g as g40 } from "./helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
242
243
  export {
243
244
  A7 as AREAS_DICCTIONARY,
244
245
  a3 as AREAS_DICTIONARY_ID,
@@ -436,23 +437,23 @@ export {
436
437
  b2 as getAreasComponentsDictionary,
437
438
  g3 as getAreasDictionary,
438
439
  g4 as getCommonActionsDictionary,
439
- g36 as getComponentClasses,
440
+ g37 as getComponentClasses,
440
441
  a17 as getComponentSlotRoot,
441
- g31 as getComponentUtilityClass,
442
+ g32 as getComponentUtilityClass,
442
443
  g5 as getDataGridComponentsDictionary,
443
444
  g6 as getDataGridRowsFromSet,
444
445
  g17 as getDistanceToNowFormatterComponentsDictionary,
445
446
  g7 as getDynamicFilterComponentsDictionary,
446
447
  a6 as getDynamicSortComponentsDictionary,
447
448
  a5 as getFilterGroupFieldsByName,
448
- g29 as getFormComponentsDictionary,
449
+ g30 as getFormComponentsDictionary,
449
450
  g15 as getFormatConcatenated,
450
451
  g12 as getFormatDate,
451
452
  g14 as getFormatPoints,
452
453
  g16 as getFormatPrice,
453
454
  g18 as getFormattersComponentsDictionary,
454
455
  a16 as getHeightSizeStyles,
455
- g34 as getIconColor,
456
+ g35 as getIconColor,
456
457
  g8 as getIsIfInDynamicFilter,
457
458
  g22 as getLoadingErrorComponentsDictionary,
458
459
  g24 as getMFLoaderComponentsDictionary,
@@ -461,21 +462,22 @@ export {
461
462
  g28 as getModalDictionary,
462
463
  g26 as getNoItemPrivilegesComponentsDictionary,
463
464
  g25 as getNoItemSelectedComponentsDictionary,
464
- g38 as getNullGuard,
465
+ g39 as getNullGuard,
465
466
  g27 as getObjectLogsComponentsDictionary,
466
467
  g11 as getPagerComponentsDictionary,
467
- g32 as getPaletteColor,
468
+ g33 as getPaletteColor,
468
469
  g21 as getPeriodComponetsDictionary,
469
470
  g20 as getRHFAutocompleteAsyncComponentsDictionary,
470
471
  g19 as getRHFAutocompleteComponentsDictionary,
471
472
  g9 as getRawFiltersForNetwork,
472
473
  g10 as getRawSortsForNetwork,
473
- g35 as getSizeStyles,
474
- g39 as getStepsAndValidationSchema,
475
- g33 as getTypographyStyles,
474
+ g36 as getSizeStyles,
475
+ g29 as getStepperComponentsDictionary,
476
+ g40 as getStepsAndValidationSchema,
477
+ g34 as getTypographyStyles,
476
478
  g13 as getUncertaintyFormat,
477
- g37 as getValidDate,
478
- g30 as getformAddEditDictionary,
479
+ g38 as getValidDate,
480
+ g31 as getformAddEditDictionary,
479
481
  i as isEqualLayout,
480
482
  k as isEqualLayouts,
481
483
  i2 as isValidDate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.3.12-JT270825.beta.2",
3
+ "version": "9.3.12-JT290825.beta.1",
4
4
  "license": "UNLICENSED",
5
5
  "description": "M4L Components",
6
6
  "lint-staged": {
@@ -5,5 +5,5 @@ interface StepperDecoratorProps extends Omit<StepperProps, 'steps'> {
5
5
  /**
6
6
  * Decorator para Storybook
7
7
  */
8
- export declare function StepperDecorator({ withVisibilityConditions, }: StepperDecoratorProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function StepperDecorator({ withVisibilityConditions, orientation, visibleTitle, indicatorType, }: StepperDecoratorProps): import("react/jsx-runtime").JSX.Element;
9
9
  export {};