@m4l/components 9.4.22 → 9.4.24
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/components/DaysOfMonthPicker/DaysOfMonthPicker.d.ts +6 -0
- package/components/DaysOfMonthPicker/DaysOfMonthPicker.js +66 -0
- package/components/DaysOfMonthPicker/DaysOfMonthPicker.styles.d.ts +2 -0
- package/components/DaysOfMonthPicker/DaysOfMonthPicker.styles.js +111 -0
- package/components/DaysOfMonthPicker/DaysOfMonthPicker.test.d.ts +1 -0
- package/components/DaysOfMonthPicker/constants.d.ts +12 -0
- package/components/DaysOfMonthPicker/constants.js +11 -0
- package/components/DaysOfMonthPicker/constants.test.d.ts +1 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/index.d.ts +2 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/index.js +1 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/types.d.ts +27 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/types.js +1 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/useDaysOfMonthPicker.d.ts +8 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/useDaysOfMonthPicker.js +121 -0
- package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/useDaysOfMonthPicker.test.d.ts +1 -0
- package/components/DaysOfMonthPicker/index.d.ts +2 -0
- package/components/DaysOfMonthPicker/index.js +1 -0
- package/components/DaysOfMonthPicker/slots/DaysOfMonthPickerEnum.d.ts +6 -0
- package/components/DaysOfMonthPicker/slots/DaysOfMonthPickerEnum.js +10 -0
- package/components/DaysOfMonthPicker/slots/DaysOfMonthPickerSlots.d.ts +4 -0
- package/components/DaysOfMonthPicker/slots/DaysOfMonthPickerSlots.js +28 -0
- package/components/DaysOfMonthPicker/slots/index.d.ts +2 -0
- package/components/DaysOfMonthPicker/types.d.ts +82 -0
- package/components/DaysOfMonthPicker/types.js +1 -0
- package/components/Stepper/helpers/delay/index.d.ts +7 -0
- package/components/Stepper/helpers/delay/index.js +4 -0
- package/components/Stepper/helpers/focusFirstErrorField/index.d.ts +10 -0
- package/components/Stepper/helpers/focusFirstErrorField/index.js +24 -0
- package/components/Stepper/helpers/index.d.ts +2 -0
- package/components/Stepper/helpers/isElementInViewport/index.d.ts +6 -0
- package/components/Stepper/helpers/isElementInViewport/index.js +14 -0
- package/components/Stepper/hooks/useStepperActions/index.js +6 -2
- package/components/Stepper/subcomponents/StepArea/hooks/useStepArea.js +5 -2
- package/components/hook-form/RHFDaysOfMonthPicker/RHFDaysOfMonthPicker.d.ts +29 -0
- package/components/hook-form/RHFDaysOfMonthPicker/RHFDaysOfMonthPicker.js +6 -0
- package/components/hook-form/RHFDaysOfMonthPicker/index.d.ts +1 -0
- package/components/hook-form/RHFDaysOfMonthPicker/index.js +1 -0
- package/components/hook-form/index.d.ts +1 -0
- package/components/index.d.ts +1 -0
- package/index.js +40 -36
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DaysOfMonthPickerProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente DaysOfMonthPicker que permite seleccionar uno o varios días del mes (1-31).
|
|
4
|
+
* Utiliza una estrategia de slots con overrides CSS de Button para cada día.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DaysOfMonthPicker: import('react').ForwardRefExoticComponent<DaysOfMonthPickerProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { T as TEST_PROP_ID } from "../../test/constants_no_mock.js";
|
|
5
|
+
import { D as DaysOfMonthPickerRootStyled, a as DaysOfMonthPickerDaysStyled, S as SkeletonDayStyled } from "./slots/DaysOfMonthPickerSlots.js";
|
|
6
|
+
import { D as DAYS_OF_MONTH_PICKER_CLASSES } from "./constants.js";
|
|
7
|
+
import { u as useDaysOfMonthPicker } from "./hooks/useDaysOfMonthPicker/useDaysOfMonthPicker.js";
|
|
8
|
+
const DaysOfMonthPicker = forwardRef((props, ref) => {
|
|
9
|
+
const { className, dataTestId, disabled } = props;
|
|
10
|
+
const { days, ownerState, currentSize, isSkeleton, renderDay } = useDaysOfMonthPicker(props);
|
|
11
|
+
if (isSkeleton) {
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
DaysOfMonthPickerRootStyled,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
className: clsx(className, DAYS_OF_MONTH_PICKER_CLASSES.root),
|
|
17
|
+
ownerState,
|
|
18
|
+
role: "group",
|
|
19
|
+
"aria-label": "Selector de días del mes",
|
|
20
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: dataTestId } : {},
|
|
21
|
+
children: /* @__PURE__ */ jsx(
|
|
22
|
+
DaysOfMonthPickerDaysStyled,
|
|
23
|
+
{
|
|
24
|
+
className: DAYS_OF_MONTH_PICKER_CLASSES.days,
|
|
25
|
+
role: "grid",
|
|
26
|
+
"aria-label": "Días del mes",
|
|
27
|
+
children: days.map((day) => /* @__PURE__ */ jsx(
|
|
28
|
+
SkeletonDayStyled,
|
|
29
|
+
{
|
|
30
|
+
variant: "rounded",
|
|
31
|
+
className: DAYS_OF_MONTH_PICKER_CLASSES.skeletonDay,
|
|
32
|
+
ownerState: { size: currentSize }
|
|
33
|
+
},
|
|
34
|
+
day
|
|
35
|
+
))
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
DaysOfMonthPickerRootStyled,
|
|
43
|
+
{
|
|
44
|
+
ref,
|
|
45
|
+
className: clsx(className, DAYS_OF_MONTH_PICKER_CLASSES.root),
|
|
46
|
+
ownerState,
|
|
47
|
+
role: "group",
|
|
48
|
+
"aria-label": "Selector de días del mes",
|
|
49
|
+
"aria-disabled": disabled || void 0,
|
|
50
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: dataTestId } : {},
|
|
51
|
+
children: /* @__PURE__ */ jsx(
|
|
52
|
+
DaysOfMonthPickerDaysStyled,
|
|
53
|
+
{
|
|
54
|
+
className: DAYS_OF_MONTH_PICKER_CLASSES.days,
|
|
55
|
+
role: "grid",
|
|
56
|
+
"aria-label": "Días del mes",
|
|
57
|
+
children: days.map(renderDay)
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
DaysOfMonthPicker.displayName = "DaysOfMonthPicker";
|
|
64
|
+
export {
|
|
65
|
+
DaysOfMonthPicker as D
|
|
66
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { g as getTypographyStyles } from "../../utils/getTypographyStyles.js";
|
|
2
|
+
import { g as getSizeStyles } from "../../utils/getSizeStyles/getSizeStyles.js";
|
|
3
|
+
const daysOfMonthPickerStyles = {
|
|
4
|
+
/**
|
|
5
|
+
* Estilos para el elemento raíz del componente.
|
|
6
|
+
*/
|
|
7
|
+
root: ({ theme }) => ({
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "column",
|
|
10
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
11
|
+
width: "fit-content"
|
|
12
|
+
}),
|
|
13
|
+
/**
|
|
14
|
+
* Estilos para el contenedor de días.
|
|
15
|
+
*/
|
|
16
|
+
days: ({ theme }) => ({
|
|
17
|
+
display: "grid",
|
|
18
|
+
gridTemplateColumns: "repeat(7, 1fr)",
|
|
19
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
20
|
+
width: "100%"
|
|
21
|
+
}),
|
|
22
|
+
/**
|
|
23
|
+
* Estilos para cada día individual (slot con overrides de Button).
|
|
24
|
+
*/
|
|
25
|
+
day: ({ theme, ownerState }) => {
|
|
26
|
+
const dayOwnerState = ownerState;
|
|
27
|
+
const isSelected = dayOwnerState?.selected;
|
|
28
|
+
const isDisabled = dayOwnerState?.disabled;
|
|
29
|
+
const isReadOnly = dayOwnerState?.readOnly;
|
|
30
|
+
const backgroundColor = isSelected ? theme.vars.palette.primary.enabledOpacity : "transparent";
|
|
31
|
+
let textColor = theme.vars.palette.default.semanticText;
|
|
32
|
+
if (isSelected) {
|
|
33
|
+
textColor = theme.vars.palette.primary.enabled;
|
|
34
|
+
}
|
|
35
|
+
if (isDisabled) {
|
|
36
|
+
textColor = theme.vars.palette.text.disabled;
|
|
37
|
+
}
|
|
38
|
+
const borderRadius = theme.vars.size.borderRadius.r2;
|
|
39
|
+
const shouldHaveInteractiveStates = !isDisabled && !isReadOnly;
|
|
40
|
+
return {
|
|
41
|
+
"&&&": {
|
|
42
|
+
...getSizeStyles(theme, dayOwnerState?.size || "medium", "action", (size) => ({
|
|
43
|
+
minWidth: size,
|
|
44
|
+
width: size,
|
|
45
|
+
height: size,
|
|
46
|
+
minHeight: size
|
|
47
|
+
})),
|
|
48
|
+
...getTypographyStyles(theme.generalSettings.isMobile, dayOwnerState?.size || "medium", "body"),
|
|
49
|
+
padding: 0,
|
|
50
|
+
borderRadius,
|
|
51
|
+
display: "flex",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
border: "none",
|
|
55
|
+
// Usar !important cuando está selected para sobrescribir el backgroundColor: 'unset' del Button base (variante text)
|
|
56
|
+
backgroundColor: isSelected ? `${theme.vars.palette.primary.enabledOpacity}!important` : backgroundColor,
|
|
57
|
+
// Usar !important cuando está selected para sobrescribir el color del texto del Button base (especialmente cuando está disabled)
|
|
58
|
+
color: `${textColor}!important`,
|
|
59
|
+
cursor: !shouldHaveInteractiveStates ? "default" : "pointer",
|
|
60
|
+
transition: "background-color 0.2s ease, color 0.2s ease",
|
|
61
|
+
pointerEvents: !shouldHaveInteractiveStates ? "none" : "auto",
|
|
62
|
+
// Estado hover: mantener el backgroundColor actual si está disabled o readOnly
|
|
63
|
+
"&:hover": {
|
|
64
|
+
backgroundColor: shouldHaveInteractiveStates ? isSelected ? `${theme.vars.palette.primary.enabledOpacity}!important` : theme.vars.palette.default.hoverOpacity : `${backgroundColor}!important`
|
|
65
|
+
// Mantener el estado base si no hay estados interactivos
|
|
66
|
+
},
|
|
67
|
+
// Estado active: mantener el backgroundColor actual si está disabled o readOnly
|
|
68
|
+
"&:active": {
|
|
69
|
+
backgroundColor: shouldHaveInteractiveStates ? isSelected ? `${theme.vars.palette.primary.activeOpacity}!important` : theme.vars.palette.default.activeOpacity : `${backgroundColor}!important`
|
|
70
|
+
// Mantener el estado base si no hay estados interactivos
|
|
71
|
+
},
|
|
72
|
+
// Estado focus visible (solo si no está deshabilitado ni en readOnly)
|
|
73
|
+
...shouldHaveInteractiveStates && {
|
|
74
|
+
"&:focus-visible": {
|
|
75
|
+
outline: `${theme.vars.size.borderStroke.container} solid ${theme.vars.palette.primary.focusVisible}`,
|
|
76
|
+
outlineOffset: "2px"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
// Override del texto del botón
|
|
80
|
+
"& .M4LButton-textButton": {
|
|
81
|
+
// Usar !important cuando está selected para sobrescribir el color del Button base (especialmente cuando está disabled)
|
|
82
|
+
color: `${textColor}!important`,
|
|
83
|
+
padding: 0,
|
|
84
|
+
fontSize: theme.typography.bodyDens.fontSize,
|
|
85
|
+
fontWeight: isSelected ? 600 : 400,
|
|
86
|
+
minWidth: "auto",
|
|
87
|
+
width: "auto",
|
|
88
|
+
cursor: "inherit"
|
|
89
|
+
// Heredar el cursor del contenedor
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Estilos para cada día individual en modo skeleton.
|
|
96
|
+
*/
|
|
97
|
+
skeletonDay: ({ theme, ownerState }) => {
|
|
98
|
+
const dayOwnerState = ownerState;
|
|
99
|
+
return {
|
|
100
|
+
...getSizeStyles(theme, dayOwnerState?.size || "medium", "action", (size) => ({
|
|
101
|
+
minWidth: size,
|
|
102
|
+
width: size,
|
|
103
|
+
height: size,
|
|
104
|
+
minHeight: size
|
|
105
|
+
}))
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export {
|
|
110
|
+
daysOfMonthPickerStyles as d
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clave de identificación del componente DaysOfMonthPicker dentro del sistema.
|
|
3
|
+
*
|
|
4
|
+
* Esta constante se utiliza como identificador único para asociar y personalizar estilos y configuraciones
|
|
5
|
+
* relacionadas con el componente `DaysOfMonthPicker` dentro del sistema de temas y estilos.
|
|
6
|
+
* @default 'M4LDaysOfMonthPicker'
|
|
7
|
+
*/
|
|
8
|
+
export declare const DAYS_OF_MONTH_PICKER_KEY_COMPONENT = "M4LDaysOfMonthPicker";
|
|
9
|
+
/**
|
|
10
|
+
* Inventario de clases CSS para el componente DaysOfMonthPicker
|
|
11
|
+
*/
|
|
12
|
+
export declare const DAYS_OF_MONTH_PICKER_CLASSES: Record<"root" | "days" | "day" | "skeletonDay", string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { g as getComponentClasses } from "../../utils/getComponentSlotRoot.js";
|
|
2
|
+
import { D as DaysOfMonthPickerSlots } from "./slots/DaysOfMonthPickerEnum.js";
|
|
3
|
+
const DAYS_OF_MONTH_PICKER_KEY_COMPONENT = "M4LDaysOfMonthPicker";
|
|
4
|
+
const DAYS_OF_MONTH_PICKER_CLASSES = getComponentClasses(
|
|
5
|
+
DAYS_OF_MONTH_PICKER_KEY_COMPONENT,
|
|
6
|
+
DaysOfMonthPickerSlots
|
|
7
|
+
);
|
|
8
|
+
export {
|
|
9
|
+
DAYS_OF_MONTH_PICKER_CLASSES as D,
|
|
10
|
+
DAYS_OF_MONTH_PICKER_KEY_COMPONENT as a
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DaysOfMonthPickerOwnerState } from '../../types';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Valores retornados por el hook useDaysOfMonthPicker
|
|
5
|
+
*/
|
|
6
|
+
export interface UseDaysOfMonthPickerReturn {
|
|
7
|
+
/**
|
|
8
|
+
* Array de días del mes (1-31, siempre en orden consecutivo)
|
|
9
|
+
*/
|
|
10
|
+
days: number[];
|
|
11
|
+
/**
|
|
12
|
+
* Owner state del componente principal
|
|
13
|
+
*/
|
|
14
|
+
ownerState: DaysOfMonthPickerOwnerState;
|
|
15
|
+
/**
|
|
16
|
+
* Tamaño actual del componente
|
|
17
|
+
*/
|
|
18
|
+
currentSize: 'small' | 'medium';
|
|
19
|
+
/**
|
|
20
|
+
* Indica si el componente está en modo skeleton
|
|
21
|
+
*/
|
|
22
|
+
isSkeleton: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Función para renderizar un día individual
|
|
25
|
+
*/
|
|
26
|
+
renderDay: (day: number) => ReactNode;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DaysOfMonthPickerProps } from '../../types';
|
|
2
|
+
import { UseDaysOfMonthPickerReturn } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Hook personalizado que maneja toda la lógica del componente DaysOfMonthPicker
|
|
5
|
+
* @param props - Propiedades del componente DaysOfMonthPicker
|
|
6
|
+
* @returns Objeto con los valores y funciones necesarias para el render
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDaysOfMonthPicker: (props: DaysOfMonthPickerProps) => UseDaysOfMonthPickerReturn;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
3
|
+
import { useMemo, useCallback } from "react";
|
|
4
|
+
import { D as DAYS_OF_MONTH_PICKER_CLASSES } from "../../constants.js";
|
|
5
|
+
import { b as DayButtonStyled } from "../../slots/DaysOfMonthPickerSlots.js";
|
|
6
|
+
import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
|
|
7
|
+
const useDaysOfMonthPicker = (props) => {
|
|
8
|
+
const {
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
multiple = false,
|
|
12
|
+
disabledDays = [],
|
|
13
|
+
disabled = false,
|
|
14
|
+
readOnly = false,
|
|
15
|
+
size
|
|
16
|
+
} = props;
|
|
17
|
+
const isSkeleton = useModuleSkeleton();
|
|
18
|
+
const { currentSize } = useComponentSize(size);
|
|
19
|
+
const ownerState = useMemo(
|
|
20
|
+
() => ({
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly
|
|
23
|
+
}),
|
|
24
|
+
[disabled, readOnly]
|
|
25
|
+
);
|
|
26
|
+
const days = useMemo(() => {
|
|
27
|
+
const daysArray = [];
|
|
28
|
+
for (let day = 1; day <= 31; day++) {
|
|
29
|
+
daysArray.push(day);
|
|
30
|
+
}
|
|
31
|
+
return daysArray;
|
|
32
|
+
}, []);
|
|
33
|
+
const isDaySelected = useCallback(
|
|
34
|
+
(day) => {
|
|
35
|
+
if (value === void 0) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (multiple) {
|
|
39
|
+
return Array.isArray(value) && value.includes(day);
|
|
40
|
+
}
|
|
41
|
+
return value === day;
|
|
42
|
+
},
|
|
43
|
+
[value, multiple]
|
|
44
|
+
);
|
|
45
|
+
const isDayDisabled = useCallback(
|
|
46
|
+
(day) => {
|
|
47
|
+
return disabled || disabledDays.includes(day);
|
|
48
|
+
},
|
|
49
|
+
[disabled, disabledDays]
|
|
50
|
+
);
|
|
51
|
+
const handleDayClick = useCallback(
|
|
52
|
+
(day) => {
|
|
53
|
+
if (isDayDisabled(day) || readOnly || isSkeleton) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (multiple) {
|
|
57
|
+
const currentValue = Array.isArray(value) ? value : [];
|
|
58
|
+
const isSelected = currentValue.includes(day);
|
|
59
|
+
if (isSelected) {
|
|
60
|
+
const newValue = currentValue.filter((d) => d !== day);
|
|
61
|
+
onChange?.(newValue);
|
|
62
|
+
} else {
|
|
63
|
+
const newValue = [...currentValue, day];
|
|
64
|
+
onChange?.(newValue);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
const newValue = value === day ? void 0 : day;
|
|
68
|
+
onChange?.(newValue);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[multiple, value, onChange, isDayDisabled, readOnly, isSkeleton]
|
|
72
|
+
);
|
|
73
|
+
const renderDay = useCallback(
|
|
74
|
+
(day) => {
|
|
75
|
+
const selected = isDaySelected(day);
|
|
76
|
+
const dayDisabled = isDayDisabled(day);
|
|
77
|
+
const dayOwnerState = {
|
|
78
|
+
selected,
|
|
79
|
+
disabled: dayDisabled,
|
|
80
|
+
readOnly,
|
|
81
|
+
size: currentSize
|
|
82
|
+
};
|
|
83
|
+
const dayLabel = day.toString().padStart(2, "0");
|
|
84
|
+
const ariaLabel = selected ? `Día ${day} seleccionado` : `Día ${day} no seleccionado`;
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
DayButtonStyled,
|
|
87
|
+
{
|
|
88
|
+
label: dayLabel,
|
|
89
|
+
variant: "text",
|
|
90
|
+
disabled: dayDisabled,
|
|
91
|
+
onClick: () => handleDayClick(day),
|
|
92
|
+
ownerState: dayOwnerState,
|
|
93
|
+
"aria-label": ariaLabel,
|
|
94
|
+
"aria-pressed": selected,
|
|
95
|
+
"aria-disabled": dayDisabled || readOnly,
|
|
96
|
+
role: "button",
|
|
97
|
+
tabIndex: dayDisabled || readOnly ? -1 : 0,
|
|
98
|
+
className: DAYS_OF_MONTH_PICKER_CLASSES.day
|
|
99
|
+
},
|
|
100
|
+
day
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
[
|
|
104
|
+
isDaySelected,
|
|
105
|
+
isDayDisabled,
|
|
106
|
+
readOnly,
|
|
107
|
+
handleDayClick,
|
|
108
|
+
currentSize
|
|
109
|
+
]
|
|
110
|
+
);
|
|
111
|
+
return {
|
|
112
|
+
days,
|
|
113
|
+
ownerState,
|
|
114
|
+
currentSize,
|
|
115
|
+
isSkeleton,
|
|
116
|
+
renderDay
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
useDaysOfMonthPicker as u
|
|
121
|
+
};
|
package/components/DaysOfMonthPicker/hooks/useDaysOfMonthPicker/useDaysOfMonthPicker.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var DaysOfMonthPickerSlots = /* @__PURE__ */ ((DaysOfMonthPickerSlots2) => {
|
|
2
|
+
DaysOfMonthPickerSlots2["root"] = "root";
|
|
3
|
+
DaysOfMonthPickerSlots2["days"] = "days";
|
|
4
|
+
DaysOfMonthPickerSlots2["day"] = "day";
|
|
5
|
+
DaysOfMonthPickerSlots2["skeletonDay"] = "skeletonDay";
|
|
6
|
+
return DaysOfMonthPickerSlots2;
|
|
7
|
+
})(DaysOfMonthPickerSlots || {});
|
|
8
|
+
export {
|
|
9
|
+
DaysOfMonthPickerSlots as D
|
|
10
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const DaysOfMonthPickerRootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
2
|
+
export declare const DaysOfMonthPickerDaysStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
3
|
+
export declare const DayButtonStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('../../mui_extended/Button').ButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>, "value" | "size" | "children" | "title" | "component" | "name" | "id" | "type" | "disabled" | "action" | "variant" | "color" | "content" | "translate" | "className" | "style" | "classes" | "sx" | "form" | "label" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "href" | "skeletonWidth" | "startIcon" | "endIcon" | keyof import('react').RefAttributes<HTMLButtonElement> | "fullWidth" | "disableElevation"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
4
|
+
export declare const SkeletonDayStyled: import('@emotion/styled').StyledComponent<Pick<import('../../mui_extended/Skeleton/types').SkeletonProps, keyof import('../../mui_extended/Skeleton/types').SkeletonProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Record<string, unknown>, {}, {}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { d as daysOfMonthPickerStyles } from "../DaysOfMonthPicker.styles.js";
|
|
3
|
+
import { a as DAYS_OF_MONTH_PICKER_KEY_COMPONENT } from "../constants.js";
|
|
4
|
+
import { D as DaysOfMonthPickerSlots } from "./DaysOfMonthPickerEnum.js";
|
|
5
|
+
import { S as Skeleton } from "../../mui_extended/Skeleton/Skeleton.js";
|
|
6
|
+
import { B as Button } from "../../mui_extended/Button/Button.js";
|
|
7
|
+
const DaysOfMonthPickerRootStyled = styled("div", {
|
|
8
|
+
name: DAYS_OF_MONTH_PICKER_KEY_COMPONENT,
|
|
9
|
+
slot: DaysOfMonthPickerSlots.root
|
|
10
|
+
})(daysOfMonthPickerStyles?.root);
|
|
11
|
+
const DaysOfMonthPickerDaysStyled = styled("div", {
|
|
12
|
+
name: DAYS_OF_MONTH_PICKER_KEY_COMPONENT,
|
|
13
|
+
slot: DaysOfMonthPickerSlots.days
|
|
14
|
+
})(daysOfMonthPickerStyles?.days);
|
|
15
|
+
const DayButtonStyled = styled(Button, {
|
|
16
|
+
name: DAYS_OF_MONTH_PICKER_KEY_COMPONENT,
|
|
17
|
+
slot: DaysOfMonthPickerSlots.day
|
|
18
|
+
})(daysOfMonthPickerStyles?.day);
|
|
19
|
+
const SkeletonDayStyled = styled(Skeleton, {
|
|
20
|
+
name: DAYS_OF_MONTH_PICKER_KEY_COMPONENT,
|
|
21
|
+
slot: DaysOfMonthPickerSlots.skeletonDay
|
|
22
|
+
})(daysOfMonthPickerStyles?.skeletonDay);
|
|
23
|
+
export {
|
|
24
|
+
DaysOfMonthPickerRootStyled as D,
|
|
25
|
+
SkeletonDayStyled as S,
|
|
26
|
+
DaysOfMonthPickerDaysStyled as a,
|
|
27
|
+
DayButtonStyled as b
|
|
28
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Theme } from '@mui/material/styles';
|
|
2
|
+
import { M4LOverridesStyleRules } from '../../@types/augmentations';
|
|
3
|
+
import { DAYS_OF_MONTH_PICKER_KEY_COMPONENT } from './constants';
|
|
4
|
+
import { DaysOfMonthPickerSlots } from './slots/DaysOfMonthPickerEnum';
|
|
5
|
+
import { Sizes } from '@m4l/styles';
|
|
6
|
+
/**
|
|
7
|
+
* Propiedades del componente `DaysOfMonthPicker`.
|
|
8
|
+
*/
|
|
9
|
+
export interface DaysOfMonthPickerProps {
|
|
10
|
+
/**
|
|
11
|
+
* Valor seleccionado. Puede ser un número (día único) o un array de números (múltiples días).
|
|
12
|
+
*/
|
|
13
|
+
value?: number | number[];
|
|
14
|
+
/**
|
|
15
|
+
* Callback que se ejecuta cuando cambia la selección.
|
|
16
|
+
*/
|
|
17
|
+
onChange?: (value: number | number[]) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Si es true, permite seleccionar múltiples días. Si es false, solo permite seleccionar un día modo single.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
multiple?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Array de días que están deshabilitados y no se pueden seleccionar.
|
|
25
|
+
*/
|
|
26
|
+
disabledDays?: number[];
|
|
27
|
+
/**
|
|
28
|
+
* Si es true, el componente está completamente deshabilitado.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Si es true, el componente está en modo solo lectura.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Class name para el componente.
|
|
39
|
+
*/
|
|
40
|
+
className?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tamaño del componente.
|
|
43
|
+
*/
|
|
44
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
45
|
+
/**
|
|
46
|
+
* Test id para el componente.
|
|
47
|
+
*/
|
|
48
|
+
dataTestId?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Owner state del componente `DaysOfMonthPicker` usado para definir propiedades internas de estilo y comportamiento.
|
|
52
|
+
*/
|
|
53
|
+
export interface DaysOfMonthPickerOwnerState {
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
readOnly?: boolean;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Owner state para cada día individual.
|
|
60
|
+
*/
|
|
61
|
+
export interface DayOwnerState {
|
|
62
|
+
selected: boolean;
|
|
63
|
+
disabled: boolean;
|
|
64
|
+
readOnly: boolean;
|
|
65
|
+
size: Extract<Sizes, 'small' | 'medium'>;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Owner state para cada header de día individual.
|
|
70
|
+
*/
|
|
71
|
+
export interface DayHeaderOwnerState {
|
|
72
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Define los tipos de Slots disponibles para el componente `DaysOfMonthPicker`.
|
|
77
|
+
*/
|
|
78
|
+
export type DaysOfMonthPickerSlotsType = keyof typeof DaysOfMonthPickerSlots;
|
|
79
|
+
/**
|
|
80
|
+
* Estilos aplicables al componente `DaysOfMonthPicker` usando temas y slots personalizados.
|
|
81
|
+
*/
|
|
82
|
+
export type DaysOfMonthPickerStyles = M4LOverridesStyleRules<DaysOfMonthPickerSlotsType, typeof DAYS_OF_MONTH_PICKER_KEY_COMPONENT, Theme>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Espera un tiempo determinado antes de continuar.
|
|
3
|
+
* Útil para esperar actualizaciones de estado de React o coordinar animaciones.
|
|
4
|
+
* @param ms - Tiempo en milisegundos a esperar
|
|
5
|
+
* @returns Promise que se resuelve después del tiempo especificado
|
|
6
|
+
*/
|
|
7
|
+
export declare const delay: (ms: number) => Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FieldValues, UseFormSetFocus, UseFormGetFieldState } from 'react-hook-form';
|
|
2
|
+
/**
|
|
3
|
+
* Enfoca el primer campo con error y hace scroll suave hacia él.
|
|
4
|
+
* Usa setFocus de react-hook-form que internamente tiene los refs registrados
|
|
5
|
+
* por los componentes Controller.
|
|
6
|
+
* @param fieldsToValidate - Array de nombres de campos a verificar (en orden de prioridad)
|
|
7
|
+
* @param getFieldState - Función getFieldState de useFormContext() para obtener estado actualizado
|
|
8
|
+
* @param setFocus - Función setFocus de useFormContext()
|
|
9
|
+
*/
|
|
10
|
+
export declare function focusFirstErrorField(fieldsToValidate: string[], getFieldState: UseFormGetFieldState<FieldValues>, setFocus: UseFormSetFocus<FieldValues>): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { d as delay } from "../delay/index.js";
|
|
2
|
+
import { i as isElementInViewport } from "../isElementInViewport/index.js";
|
|
3
|
+
const DELAY_FOR_ERROR_STATE_UPDATE = 0;
|
|
4
|
+
const DELAY_FOR_SCROLL_AFTER_FOCUS = 50;
|
|
5
|
+
async function focusFirstErrorField(fieldsToValidate, getFieldState, setFocus) {
|
|
6
|
+
await delay(DELAY_FOR_ERROR_STATE_UPDATE);
|
|
7
|
+
for (const fieldName of fieldsToValidate) {
|
|
8
|
+
const fieldState = getFieldState(fieldName);
|
|
9
|
+
if (fieldState.error) {
|
|
10
|
+
setFocus(fieldName, { shouldSelect: true });
|
|
11
|
+
await delay(DELAY_FOR_SCROLL_AFTER_FOCUS);
|
|
12
|
+
if (!isElementInViewport(document.activeElement)) {
|
|
13
|
+
document.activeElement?.scrollIntoView({
|
|
14
|
+
behavior: "smooth",
|
|
15
|
+
block: "center"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
focusFirstErrorField as f
|
|
24
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { evaluateVisibilityStepCondition } from './evaluateVisibilityStepCondition';
|
|
2
2
|
export { findNextVisibleValidStep } from './findNextVisibleValidStep';
|
|
3
3
|
export { findPrevVisibleValidStep } from './findPrevVisibleValidStep';
|
|
4
|
+
export { focusFirstErrorField } from './focusFirstErrorField';
|
|
5
|
+
export { isElementInViewport } from './isElementInViewport';
|
|
4
6
|
export { isLastVisibleValidStep } from './isLastVisibleValidStep';
|
|
5
7
|
export { parseWatchedValues } from './parseWatchedValues';
|
|
6
8
|
export { getInitialFieldValues } from './getInitialFieldValues';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function isElementInViewport(element) {
|
|
2
|
+
if (!element) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const rect = element.getBoundingClientRect();
|
|
6
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
7
|
+
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
8
|
+
const isInsideVertically = rect.top >= 0 && rect.bottom <= windowHeight;
|
|
9
|
+
const isInsideHorizontally = rect.left >= 0 && rect.right <= windowWidth;
|
|
10
|
+
return isInsideVertically && isInsideHorizontally;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
isElementInViewport as i
|
|
14
|
+
};
|
|
@@ -3,8 +3,9 @@ import { u as useStepper } from "../useStepper/index.js";
|
|
|
3
3
|
import { useFormContext } from "react-hook-form";
|
|
4
4
|
import { shallow } from "zustand/shallow";
|
|
5
5
|
import { u as useDynamicValidation } from "../useDynamicValidation/index.js";
|
|
6
|
+
import { f as focusFirstErrorField } from "../../helpers/focusFirstErrorField/index.js";
|
|
6
7
|
function useStepperActions() {
|
|
7
|
-
const { trigger, clearErrors, getValues, reset } = useFormContext();
|
|
8
|
+
const { trigger, clearErrors, getValues, reset, setFocus, getFieldState } = useFormContext();
|
|
8
9
|
const { activateFieldsValidation, clearAllValidation } = useDynamicValidation();
|
|
9
10
|
const {
|
|
10
11
|
nextStep,
|
|
@@ -46,6 +47,7 @@ function useStepperActions() {
|
|
|
46
47
|
const result = await trigger(fieldsToValidate);
|
|
47
48
|
if (!result) {
|
|
48
49
|
activateFieldsValidation(fieldsToValidate);
|
|
50
|
+
focusFirstErrorField(fieldsToValidate, getFieldState, setFocus);
|
|
49
51
|
}
|
|
50
52
|
return result;
|
|
51
53
|
};
|
|
@@ -77,7 +79,9 @@ function useStepperActions() {
|
|
|
77
79
|
trigger,
|
|
78
80
|
getValues,
|
|
79
81
|
activateFieldsValidation,
|
|
80
|
-
clearAllValidation
|
|
82
|
+
clearAllValidation,
|
|
83
|
+
setFocus,
|
|
84
|
+
getFieldState
|
|
81
85
|
]);
|
|
82
86
|
const cancelAction = useCallback(() => {
|
|
83
87
|
reset();
|
|
@@ -2,10 +2,11 @@ import { useCallback, useMemo } from "react";
|
|
|
2
2
|
import { useFormContext } from "react-hook-form";
|
|
3
3
|
import { u as useStepper } from "../../../hooks/useStepper/index.js";
|
|
4
4
|
import { u as useDynamicValidation } from "../../../hooks/useDynamicValidation/index.js";
|
|
5
|
+
import { f as focusFirstErrorField } from "../../../helpers/focusFirstErrorField/index.js";
|
|
5
6
|
import { d as deepShallow } from "../../../../../utils/deepShallow.js";
|
|
6
7
|
function useStepArea(props) {
|
|
7
8
|
const { visibleSteps } = props;
|
|
8
|
-
const { trigger, clearErrors } = useFormContext();
|
|
9
|
+
const { trigger, clearErrors, setFocus, getFieldState } = useFormContext();
|
|
9
10
|
const {
|
|
10
11
|
activateFieldsValidation,
|
|
11
12
|
startExternalValidation,
|
|
@@ -59,6 +60,7 @@ function useStepArea(props) {
|
|
|
59
60
|
setCurrentStep(stepOriginalIndex);
|
|
60
61
|
setStepValidationStatus(stepOriginalIndex, false);
|
|
61
62
|
activateFieldsValidation(step.validationFields || []);
|
|
63
|
+
focusFirstErrorField(step.validationFields || [], getFieldState, setFocus);
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
64
66
|
setStepValidationStatus(stepOriginalIndex, true);
|
|
@@ -74,6 +76,7 @@ function useStepArea(props) {
|
|
|
74
76
|
if (!isCurrentValid) {
|
|
75
77
|
setStepValidationStatus(currentStepOriginalIndex, false);
|
|
76
78
|
activateFieldsValidation(currentStepData.validationFields || []);
|
|
79
|
+
focusFirstErrorField(currentStepData.validationFields || [], getFieldState, setFocus);
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
setStepValidationStatus(currentStepOriginalIndex, true);
|
|
@@ -97,7 +100,7 @@ function useStepArea(props) {
|
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
|
-
}, [visibleSteps, steps, setCurrentStep, currentStep, startExternalValidation, trigger, endExternalValidation, setStepValidationStatus, activateFieldsValidation, stepValidationStatus, clearErrors]);
|
|
103
|
+
}, [visibleSteps, steps, setCurrentStep, currentStep, startExternalValidation, trigger, endExternalValidation, setStepValidationStatus, activateFieldsValidation, stepValidationStatus, clearErrors, getFieldState, setFocus]);
|
|
101
104
|
return useMemo(() => ({
|
|
102
105
|
visibleTitle,
|
|
103
106
|
orientation,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Componente RHFDaysOfMonthPicker que integra DaysOfMonthPicker con react-hook-form.
|
|
3
|
+
*
|
|
4
|
+
* Este componente permite seleccionar días del mes (1-31) en un formulario controlado
|
|
5
|
+
* por react-hook-form, proporcionando validación automática y manejo de estados.
|
|
6
|
+
*
|
|
7
|
+
* ### Características:
|
|
8
|
+
* - **Integración con RHF**: Se integra automáticamente con react-hook-form mediante el HOC withRHFController
|
|
9
|
+
* - **Validación**: Soporta validación mediante esquemas de validación (Yup, Zod, etc.)
|
|
10
|
+
* - **Estados del formulario**: Se deshabilita automáticamente durante el envío del formulario
|
|
11
|
+
* - **Label y errores**: El HOC maneja automáticamente el Label y los mensajes de error
|
|
12
|
+
* - **Modo single/multiple**: Permite seleccionar un día único o múltiples días
|
|
13
|
+
* - **Atajos**: Soporta atajos de selección rápida cuando está en modo multiple
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const schema = Yup.object({
|
|
17
|
+
* days: Yup.array().min(1, 'Debe seleccionar al menos un día').required('Campo requerido'),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* <RHFDaysOfMonthPicker
|
|
21
|
+
* name="days"
|
|
22
|
+
* label="Días del mes"
|
|
23
|
+
* mandatory
|
|
24
|
+
* multiple
|
|
25
|
+
* disabledDays={[1, 15]} // Deshabilita día 1 y 15
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const RHFDaysOfMonthPicker: import('react').ForwardRefExoticComponent<Omit<import('../../DaysOfMonthPicker').DaysOfMonthPickerProps & import('react').RefAttributes<HTMLDivElement> & import('../../../hocs').BaseRHFProps<import('react-hook-form').FieldValues>, "ref"> & import('react').RefAttributes<any>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { w as withRHFController } from "../../../hocs/withRHFController/index.js";
|
|
2
|
+
import { D as DaysOfMonthPicker } from "../../DaysOfMonthPicker/DaysOfMonthPicker.js";
|
|
3
|
+
const RHFDaysOfMonthPicker = withRHFController(DaysOfMonthPicker);
|
|
4
|
+
export {
|
|
5
|
+
RHFDaysOfMonthPicker as R
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RHFDaysOfMonthPicker } from './RHFDaysOfMonthPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -9,6 +9,7 @@ export { RHFDateTime } from './RHFDateTime';
|
|
|
9
9
|
export { RHFDateTimePicker } from './RHFDateTimePicker';
|
|
10
10
|
export { RHFDatePicker } from './RHFDatePicker';
|
|
11
11
|
export * from './RHFDaysOfWeekPicker';
|
|
12
|
+
export * from './RHFDaysOfMonthPicker';
|
|
12
13
|
export { RHFMultiCheckbox } from './RHFMultiCheckbox';
|
|
13
14
|
export { RHFSelect } from './RHFSelect';
|
|
14
15
|
export { RHFHelperError } from './RHFHelperError';
|
package/components/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './CommonActions/dictionary';
|
|
|
16
16
|
export * from './datagrids';
|
|
17
17
|
export * from './DaysOfWeekPicker';
|
|
18
18
|
export * from './DragResizeWindowRND';
|
|
19
|
+
export * from './DaysOfMonthPicker';
|
|
19
20
|
export * from './DynamicFilter';
|
|
20
21
|
export * from './DynamicSort';
|
|
21
22
|
export * from './extended';
|
package/index.js
CHANGED
|
@@ -86,14 +86,15 @@ import { g as g8 } from "./components/DaysOfWeekPicker/dictionary.js";
|
|
|
86
86
|
import { D as D4 } from "./components/DragResizeWindowRND/DragResizeWindowRND.js";
|
|
87
87
|
import { d as d2 } from "./components/DragResizeWindowRND/classes/index.js";
|
|
88
88
|
import { W } from "./components/DragResizeWindowRND/constants.js";
|
|
89
|
+
import { D as D5 } from "./components/DaysOfMonthPicker/DaysOfMonthPicker.js";
|
|
89
90
|
import { g as g9 } from "./components/DynamicFilter/dictionary.js";
|
|
90
91
|
import { a as a5, g as g10 } from "./components/DynamicFilter/helpers/frontEndHelpers.js";
|
|
91
92
|
import { g as g11 } from "./components/DynamicFilter/helpers/getRawFiltersForNetwork.js";
|
|
92
|
-
import { D as
|
|
93
|
+
import { D as D6 } from "./components/DynamicFilter/DynamicFilter.js";
|
|
93
94
|
import { a as a6 } from "./components/DynamicSort/dictionary.js";
|
|
94
95
|
import { S as S2 } from "./components/DynamicSort/helpers/frontEndHelpers.js";
|
|
95
96
|
import { g as g12 } from "./components/DynamicSort/helpers/getRawSortsForNetwork.js";
|
|
96
|
-
import { D as
|
|
97
|
+
import { D as D7 } from "./components/DynamicSort/DynamicSort.js";
|
|
97
98
|
import { R } from "./components/extended/React-Resizable/Resizable/Resizable.js";
|
|
98
99
|
import { R as R2 } from "./components/extended/React-Resizable/ResizableBox/ResizableBox.js";
|
|
99
100
|
import { S as S3 } from "./components/extended/React-resizable-panels/SplitLayout.js";
|
|
@@ -137,11 +138,11 @@ import { a as a8, T as T15 } from "./components/mui_extended/ToggleIconButton/co
|
|
|
137
138
|
import { T as T16 } from "./components/mui_extended/ToggleIconButton/slots/ToggleIconButtonEnum.js";
|
|
138
139
|
import { T as T17 } from "./components/mui_extended/ToggleIconButton/slots/ToggleIconButtonSlots.js";
|
|
139
140
|
import { N as N2 } from "./components/mui_extended/NavLink/NavLink.js";
|
|
140
|
-
import { D as
|
|
141
|
-
import { D as
|
|
142
|
-
import { D as
|
|
141
|
+
import { D as D8 } from "./components/mui_extended/Dialog/Dialog.js";
|
|
142
|
+
import { D as D9 } from "./components/mui_extended/Divider/Divider.js";
|
|
143
|
+
import { D as D10 } from "./components/mui_extended/DatePicker/DatePicker.js";
|
|
143
144
|
import { B as B6 } from "./components/formatters/BooleanFormatter/BooleanFormatter.js";
|
|
144
|
-
import { D as
|
|
145
|
+
import { D as D11, g as g14 } from "./components/formatters/DateFormatter/DateFormatter.js";
|
|
145
146
|
import { U, g as g15 } from "./components/formatters/UncertaintyFormatter/UncertaintyFormatter.js";
|
|
146
147
|
import { P as P3, g as g16 } from "./components/formatters/PointsFormatter/PointsFormatter.js";
|
|
147
148
|
import { C as C33, g as g17 } from "./components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
@@ -152,7 +153,7 @@ import { C as C34 } from "./components/formatters/ColorFormatter/ColorFormatter.
|
|
|
152
153
|
import { I as I4 } from "./components/formatters/ImageFormatter/ImageFormatter.js";
|
|
153
154
|
import { C as C35 } from "./components/formatters/ChipStatusFormatter/ChipStatusFormatter.js";
|
|
154
155
|
import { g as g19 } from "./components/formatters/DistanceToNowFormatter/dictionary.js";
|
|
155
|
-
import { D as
|
|
156
|
+
import { D as D12 } from "./components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js";
|
|
156
157
|
import { u as u17 } from "./components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.js";
|
|
157
158
|
import { g as g20 } from "./components/formatters/dictionary.js";
|
|
158
159
|
import { F as F2 } from "./components/FormContainer/FormContainer.js";
|
|
@@ -179,20 +180,21 @@ import { R as R16 } from "./components/hook-form/RHFColorPicker/RFHColorPicker.j
|
|
|
179
180
|
import { R as R17 } from "./components/hook-form/RHFCheckbox/RHFCheckbox.js";
|
|
180
181
|
import { R as R18 } from "./components/hook-form/RHFCheckableList/RHFCheckableList.js";
|
|
181
182
|
import { R as R19 } from "./components/hook-form/RHFDaysOfWeekPicker/RHFDaysOfWeekPicker.js";
|
|
182
|
-
import { R as R20 } from "./components/hook-form/
|
|
183
|
-
import { R as R21 } from "./components/hook-form/
|
|
183
|
+
import { R as R20 } from "./components/hook-form/RHFDaysOfMonthPicker/RHFDaysOfMonthPicker.js";
|
|
184
|
+
import { R as R21 } from "./components/hook-form/RHFTextField/RHFTextField.js";
|
|
185
|
+
import { R as R22 } from "./components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.js";
|
|
184
186
|
import { g as g23 } from "./components/hook-form/RHFPeriod/subcomponents/Period/dictionary.js";
|
|
185
187
|
import { r } from "./components/hook-form/RHFPeriod/RHFPeriod.styles.js";
|
|
186
|
-
import { R as
|
|
187
|
-
import { R as
|
|
188
|
-
import { R as
|
|
189
|
-
import { N as N3, P as P6, R as
|
|
190
|
-
import { R as
|
|
191
|
-
import { R as
|
|
188
|
+
import { R as R23 } from "./components/hook-form/RHFPeriod/RHFPeriod.js";
|
|
189
|
+
import { R as R24 } from "./components/hook-form/RHFPeriod/constants.js";
|
|
190
|
+
import { R as R25 } from "./components/hook-form/RHFPeriod/slots/RHFPeriodEnum.js";
|
|
191
|
+
import { N as N3, P as P6, R as R26, S as S7 } from "./components/hook-form/RHFPeriod/slots/RHFPeriodSlots.js";
|
|
192
|
+
import { R as R27 } from "./components/hook-form/RHFNumberInput/RHFNumberInput.js";
|
|
193
|
+
import { R as R28 } from "./components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js";
|
|
192
194
|
import { V as V2, b as b4, a as a9 } from "./components/hook-form/RHFormProvider/types.js";
|
|
193
|
-
import { F as F3, R as
|
|
195
|
+
import { F as F3, R as R29, u as u18 } from "./components/hook-form/RHFormProvider/RHFormProvider.js";
|
|
194
196
|
import { d as d4, a as a10, b as b5, c as c3 } from "./components/hook-form/RHFormProvider/schema.js";
|
|
195
|
-
import { R as
|
|
197
|
+
import { R as R30 } from "./components/hook-form/RHFActionsGroup/RHFActionsGroup.js";
|
|
196
198
|
import { I as I5 } from "./components/Icon/Icon.js";
|
|
197
199
|
import { I as I6 } from "./components/Image/Image.js";
|
|
198
200
|
import { L as L6 } from "./components/Label/Label.js";
|
|
@@ -232,7 +234,7 @@ import { u as u20 } from "./components/WindowBase/hooks/useWindowToolsMF/index.j
|
|
|
232
234
|
import { u as u21, a as a14 } from "./components/WindowBase/hooks/useDynamicMFParameters/index.js";
|
|
233
235
|
import { M as M7, W as W3, a as a15 } from "./components/WindowBase/contexts/WindowToolsMFContext/WindowToolsMFContext.js";
|
|
234
236
|
import { c as c4 } from "./components/WindowBase/contexts/DynamicMFParmsContext/store.js";
|
|
235
|
-
import { D as
|
|
237
|
+
import { D as D13, a as a16, M as M8 } from "./components/WindowBase/contexts/DynamicMFParmsContext/DynamicMFParmsContext.js";
|
|
236
238
|
import { W as W4 } from "./components/WindowConfirm/WindowConfirm.js";
|
|
237
239
|
import { a as a17, g as g30 } from "./components/ModalDialog/dictionary.js";
|
|
238
240
|
import { M as M9 } from "./components/ModalDialog/ModalDialog.js";
|
|
@@ -354,17 +356,18 @@ export {
|
|
|
354
356
|
e as DATAGRID_SEMANTIC_WIDTHS,
|
|
355
357
|
D as DICTIONARY,
|
|
356
358
|
D2 as DataGrid,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
+
D11 as DateFormatter,
|
|
360
|
+
D10 as DatePicker,
|
|
361
|
+
D5 as DaysOfMonthPicker,
|
|
359
362
|
D3 as DaysOfWeekPicker,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
D8 as Dialog,
|
|
364
|
+
D12 as DistanceToNowFormatter,
|
|
365
|
+
D9 as Divider,
|
|
363
366
|
D4 as DragResizeWindowRND,
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
D6 as DynamicFilter,
|
|
368
|
+
D13 as DynamicMFParmsContext,
|
|
366
369
|
a16 as DynamicMFParmsProvider,
|
|
367
|
-
|
|
370
|
+
D7 as DynamicSort,
|
|
368
371
|
F as FixedSizeList,
|
|
369
372
|
F2 as FormContainer,
|
|
370
373
|
F3 as FormProviderCustom,
|
|
@@ -423,7 +426,7 @@ export {
|
|
|
423
426
|
P11 as PrintingSystem,
|
|
424
427
|
P as PropagateLoaderSpinner,
|
|
425
428
|
P12 as PropertyValue,
|
|
426
|
-
|
|
429
|
+
R30 as RHFActionsGroup,
|
|
427
430
|
R6 as RHFAutocomplete,
|
|
428
431
|
R7 as RHFAutocompleteAsync,
|
|
429
432
|
R18 as RHFCheckableList,
|
|
@@ -432,21 +435,22 @@ export {
|
|
|
432
435
|
R10 as RHFDatePicker,
|
|
433
436
|
R8 as RHFDateTime,
|
|
434
437
|
R9 as RHFDateTimePicker,
|
|
438
|
+
R20 as RHFDaysOfMonthPicker,
|
|
435
439
|
R19 as RHFDaysOfWeekPicker,
|
|
436
440
|
R13 as RHFHelperError,
|
|
437
441
|
R11 as RHFMultiCheckbox,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
R27 as RHFNumberInput,
|
|
443
|
+
R23 as RHFPeriod,
|
|
444
|
+
R26 as RHFPeriodRootStyled,
|
|
445
|
+
R25 as RHFPeriodSlots,
|
|
442
446
|
R14 as RHFRadioGroup,
|
|
443
447
|
R12 as RHFSelect,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
448
|
+
R21 as RHFTextField,
|
|
449
|
+
R22 as RHFTextFieldPassword,
|
|
450
|
+
R28 as RHFUploadImage,
|
|
447
451
|
R15 as RHFUploadSingleFile,
|
|
448
|
-
|
|
449
|
-
|
|
452
|
+
R24 as RHF_PERIOD_KEY_COMPONENT,
|
|
453
|
+
R29 as RHFormProvider,
|
|
450
454
|
R4 as Radio,
|
|
451
455
|
R3 as ReactJsonViewer,
|
|
452
456
|
R as Resizable,
|