@m4l/components 9.4.20 → 9.4.22-BE20260204-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/AccountPopover/slots/AccountPopoverSlots.d.ts +3 -3
- package/components/ActionsGroup/slots/ActionsGroupSlots.d.ts +1 -1
- package/components/CheckableList/slots/styled.d.ts +4 -4
- package/components/Chip/slots/ChipSlots.d.ts +1 -1
- 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/EditLabel/slots/EditLabelSlots.d.ts +1 -1
- package/components/HelperError/slots/HelperErrorSlots.d.ts +1 -1
- package/components/ImageText/slots/ImageTextSlots.d.ts +2 -2
- package/components/Label/slots/LabelSlots.d.ts +2 -2
- package/components/LoadingError/slots/LoadingErrorSlots.d.ts +1 -1
- package/components/MFIsolationApp/slots/MFIsolationAppSlots.d.ts +2 -2
- package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +2 -0
- package/components/ObjectLogs/slots/ObjectLogsSlots.d.ts +1 -1
- package/components/Pager/slots/PagerSlots.d.ts +3 -3
- package/components/PaperForm/slots/PaperFormSlots.d.ts +1 -1
- package/components/PropertyValue/PropertyValue.js +23 -12
- package/components/PropertyValue/PropertyValue.styles.js +135 -15
- package/components/PropertyValue/slots/PropertyValueEnum.d.ts +4 -1
- package/components/PropertyValue/slots/PropertyValueEnum.js +3 -0
- package/components/PropertyValue/slots/PropertyValueSlots.d.ts +9 -0
- package/components/PropertyValue/slots/PropertyValueSlots.js +17 -1
- package/components/PropertyValue/types.d.ts +117 -5
- package/components/SettingsLayout/slots/SettingsLayoutSlots.d.ts +1 -1
- package/components/Stepper/slots/StepperSlot.d.ts +4 -4
- package/components/TabsNavigator/slots/TabsNavigatorSlots.d.ts +2 -2
- package/components/ToastContainer/slots/toastContainerSlots.d.ts +2 -2
- package/components/WindowBase/slots/WindowBaseSlots.d.ts +2 -2
- package/components/areas/components/AreasAdmin/slots/AreasAdminSlots.d.ts +1 -1
- package/components/datagrids/helpers/index.d.ts +1 -0
- package/components/datagrids/helpers/shared/getDefaultAction/getDefaultAction.d.ts +8 -0
- package/components/datagrids/helpers/shared/getDefaultAction/getDefaultAction.js +12 -0
- package/components/datagrids/helpers/shared/getDefaultAction/getDefaultAction.test.d.ts +1 -0
- package/components/datagrids/helpers/shared/getDefaultAction/index.d.ts +1 -0
- package/components/datagrids/helpers/shared/getDefaultAction/index.js +1 -0
- package/components/datagrids/index.d.ts +1 -1
- package/components/datagrids/types.d.ts +17 -2
- package/components/datagrids/views/CardsView/subcomponents/CardRow/CardRow.js +21 -0
- package/components/datagrids/views/TableView/TableView.js +15 -1
- package/components/datagrids/views/TableView/hooks/useSortColumnsRows/useSortColumnsRows.js +2 -0
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.d.ts +1 -1
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterSlots.d.ts +1 -1
- package/components/formatters/DateFormatter/slots/DateFormatterSlots.d.ts +1 -1
- package/components/formatters/DistanceToNowFormatter/slots/DistanceToNowFormatterSlots.d.ts +1 -1
- package/components/formatters/ImageFormatter/slots/ImageFormatterSlots.d.ts +1 -1
- package/components/formatters/PeriodFormatter/slots/PeriodFormatterSlots.d.ts +1 -1
- package/components/formatters/PointsFormatter/slots/ointsFormatterSlots.d.ts +1 -1
- package/components/formatters/PriceFormatter/slots/PriceFormatterSlots.d.ts +1 -1
- package/components/formatters/UncertaintyFormatter/slots/UncertaintyFormatterSlots.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/reducer/RHFAutocompleteReducer.js +5 -0
- 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/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +5 -5
- package/components/hook-form/index.d.ts +1 -0
- package/components/index.d.ts +1 -0
- package/components/mui_extended/Accordion/slots/AccordionSlots.d.ts +1 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +2 -2
- package/components/mui_extended/Button/slots/ButtonSlots.d.ts +1 -1
- package/components/mui_extended/CheckBox/slots/CheckBoxSlots.d.ts +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemSlots.d.ts +1 -1
- package/components/mui_extended/NavLink/slots/NavLinkSlots.d.ts +1 -1
- package/components/mui_extended/Radio/slots/styled.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +3 -3
- package/components/mui_extended/Tab/Slots/TabSlots.d.ts +1 -1
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +3 -3
- package/components/mui_extended/Typography/slots/typographySlots.d.ts +1 -1
- package/hooks/useDynamicFilterAndSort/slots/DynamicFilterAndSortSlots.d.ts +3 -3
- package/index.js +40 -36
- package/not_recognized/index.js +100 -25
- package/package.json +1 -1
|
@@ -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
|
+
|