@m4l/components 9.1.88 → 9.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/types.d.ts +9 -1
- package/components/Chip/Chip.js +3 -1
- package/components/Chip/ChipStyles.js +19 -14
- package/components/Chip/types.d.ts +8 -3
- package/components/hook-form/RHFDateTime/RHFDateTime.d.ts +4 -0
- package/components/hook-form/RHFDateTime/RHFDateTime.js +39 -86
- package/components/hook-form/RHFDateTime/RHFDateTime.styles.d.ts +2 -0
- package/components/hook-form/RHFDateTime/RHFDateTime.styles.js +17 -0
- package/components/hook-form/RHFDateTime/constants.d.ts +1 -0
- package/components/hook-form/RHFDateTime/constants.js +4 -0
- package/components/hook-form/RHFDateTime/slots/RHFDateTimeEnum.d.ts +3 -0
- package/components/hook-form/RHFDateTime/slots/RHFDateTimeEnum.js +7 -0
- package/components/hook-form/RHFDateTime/slots/RHFDateTimeSlots.d.ts +1 -0
- package/components/hook-form/RHFDateTime/slots/RHFDateTimeSlots.js +9 -0
- package/components/hook-form/RHFDateTime/tests/RHFDateTime.test.d.ts +1 -0
- package/components/hook-form/RHFDateTime/types.d.ts +13 -12
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +1 -5
- package/components/mui_extended/DateTimePicker/DateTimePicker.d.ts +33 -0
- package/components/mui_extended/DateTimePicker/DateTimePicker.js +154 -0
- package/components/mui_extended/DateTimePicker/DateTimePicker.styles.d.ts +2 -0
- package/components/mui_extended/DateTimePicker/DateTimePicker.styles.js +752 -0
- package/components/mui_extended/DateTimePicker/constants.d.ts +1 -0
- package/components/mui_extended/DateTimePicker/constants.js +4 -0
- package/components/mui_extended/DateTimePicker/icons.d.ts +4 -0
- package/components/mui_extended/DateTimePicker/icons.js +10 -0
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerEnum.d.ts +10 -0
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerEnum.js +14 -0
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.d.ts +26 -0
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.js +49 -0
- package/components/mui_extended/DateTimePicker/tests/DateTimePicker.test.d.ts +1 -0
- package/components/mui_extended/DateTimePicker/types.d.ts +51 -0
- package/package.json +1 -1
- package/components/hook-form/RHFDateTime/classes/constants.d.ts +0 -1
- package/components/hook-form/RHFDateTime/classes/constants.js +0 -4
- package/components/hook-form/RHFDateTime/classes/index.d.ts +0 -11
- package/components/hook-form/RHFDateTime/classes/index.js +0 -45
- package/components/hook-form/RHFDateTime/classes/types.d.ts +0 -16
- package/components/hook-form/RHFDateTime/styles.js +0 -7
- package/components/hook-form/RHFDateTime/subcomponents/Skeleton/index.d.ts +0 -5
- package/components/hook-form/RHFDateTime/subcomponents/Skeleton/index.js +0 -15
- package/components/hook-form/RHFDateTime/subcomponents/Skeleton/types.d.ts +0 -5
- package/components/hook-form/RHFDateTime/test/constants.d.ts +0 -1
- package/components/hook-form/RHFDateTime/test/constants.js +0 -4
- package/components/hook-form/RHFDateTime/test/utils.d.ts +0 -2
- package/components/hook-form/RHFDateTime/test/utils.js +0 -7
package/@types/types.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ import { LinearProgressIndeterminateOwnerState, LinearProgressIndeterminateType
|
|
|
143
143
|
import { MenuDividerOwnerState, MenuDividerSlotsType } from '../components/mui_extended/MenuDivider/types';
|
|
144
144
|
import { RHFSelectSlotsType, RHFSelectOwnerState } from '../components/hook-form/RHFSelect/types';
|
|
145
145
|
import { RHFCheckBoxOwnerState, RHFCheckBoxSlotsType } from '../components/hook-form/RHFCheckbox/types';
|
|
146
|
+
import { DateTimePickerOwnerState, DateTimePickerSlotsType } from '../components/mui_extended/DateTimePicker/types';
|
|
146
147
|
import { DividerOwnerState, DividerSlotsType } from '../components/mui_extended/Divider/types';
|
|
147
148
|
|
|
148
149
|
declare module '@mui/material/styles' {
|
|
@@ -203,6 +204,7 @@ declare module '@mui/material/styles' {
|
|
|
203
204
|
M4LLinearProgressIndeterminate: LinearProgressIndeterminateType;
|
|
204
205
|
M4LMenuDivider: MenuDividerSlotsType;
|
|
205
206
|
M4LRHFSelect: RHFSelectSlotsType;
|
|
207
|
+
M4LDateTimePicker: DateTimePickerSlotsType;
|
|
206
208
|
M4LDivider: DividerSlotsType;
|
|
207
209
|
}
|
|
208
210
|
|
|
@@ -263,8 +265,8 @@ declare module '@mui/material/styles' {
|
|
|
263
265
|
M4LLinearProgressIndeterminate: Partial<LinearProgressIndeterminateOwnerState>;
|
|
264
266
|
M4LMenuDivider: Partial<MenuDividerOwnerState>;
|
|
265
267
|
M4LRHFSelect: Partial<RHFSelectOwnerState>;
|
|
268
|
+
M4LDateTimePicker: Partial<DateTimePickerOwnerState>;
|
|
266
269
|
M4LDivider: Partial<DividerOwnerState>;
|
|
267
|
-
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
interface Components {
|
|
@@ -544,6 +546,12 @@ declare module '@mui/material/styles' {
|
|
|
544
546
|
styleOverrides?: ComponentsOverrides<Theme>['M4LRHFSelect'];
|
|
545
547
|
variants?: ComponentsVariants['M4LRHFSelect'];
|
|
546
548
|
};
|
|
549
|
+
|
|
550
|
+
M4LDateTimePicker?: {
|
|
551
|
+
defaultProps?: ComponentsPropsList['M4LDateTimePicker'];
|
|
552
|
+
styleOverrides?: ComponentsOverrides<Theme>['M4LDateTimePicker'];
|
|
553
|
+
variants?: ComponentsVariants['M4LDateTimePicker'];
|
|
554
|
+
};
|
|
547
555
|
M4LDivider?: {
|
|
548
556
|
defaultProps?: ComponentsPropsList['M4LDivider'];
|
|
549
557
|
styleOverrides?: ComponentsOverrides<Theme>['M4LDivider'];
|
package/components/Chip/Chip.js
CHANGED
|
@@ -11,6 +11,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
11
11
|
label,
|
|
12
12
|
startIcon,
|
|
13
13
|
color = "default",
|
|
14
|
+
externalColor,
|
|
14
15
|
size = "small",
|
|
15
16
|
variant = "contained",
|
|
16
17
|
skeletonWidth = "100%",
|
|
@@ -29,7 +30,8 @@ const Chip = forwardRef((props, ref) => {
|
|
|
29
30
|
chipSize: adjustedSize,
|
|
30
31
|
variant,
|
|
31
32
|
color,
|
|
32
|
-
opacity
|
|
33
|
+
opacity,
|
|
34
|
+
externalColor
|
|
33
35
|
};
|
|
34
36
|
if (isSkeleton) {
|
|
35
37
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { g as getHeightSizeStyles } from "../../utils/getHeightSizeStyles.js";
|
|
1
2
|
const chipStyles = {
|
|
2
3
|
/**
|
|
3
4
|
* Styles for the root element of the chip.
|
|
@@ -7,25 +8,30 @@ const chipStyles = {
|
|
|
7
8
|
* @updatedUser Andrés Quintero - automatic
|
|
8
9
|
*/
|
|
9
10
|
root: ({ theme, ownerState }) => {
|
|
10
|
-
const keyColor = ownerState.color
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const bgColor = ownerState.
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const color = ownerState.variant === "contained" && !ownerState.opacity ? theme.vars.palette.chips[keyColorConditionalOpacity].contrastText : theme.vars.palette.chips[keyColorConditionalOpacity].semanticText;
|
|
11
|
+
const keyColor = ownerState.variant === "contained" ? ownerState.color + "Contained" : ownerState.color + "Outlined";
|
|
12
|
+
const finalPalette = ownerState.externalColor ? ownerState.externalColor : theme.vars.palette.chips[keyColor ?? "default"];
|
|
13
|
+
const color = ownerState.opacity ? finalPalette.color : finalPalette.colorTone;
|
|
14
|
+
const bgColor = ownerState.opacity ? finalPalette.backgroundColor : finalPalette.backgroundColorTone;
|
|
15
|
+
const bgHover = ownerState.opacity ? finalPalette.backgroundHover : finalPalette.backgroundHoverTone;
|
|
16
|
+
const bgActive = ownerState.opacity ? finalPalette.backgroundActive : finalPalette.backgroundActiveTone;
|
|
17
17
|
return {
|
|
18
18
|
display: "flex",
|
|
19
19
|
alignItems: "center",
|
|
20
20
|
padding: theme.vars.size.baseSpacings.sp1,
|
|
21
|
+
paddingRight: 0,
|
|
21
22
|
borderRadius: theme.vars.size.borderRadius["r0-5"],
|
|
22
23
|
width: "max-content",
|
|
23
24
|
cursor: "pointer",
|
|
24
25
|
color,
|
|
25
|
-
backgroundColor: bgColor,
|
|
26
|
+
backgroundColor: !(ownerState.variant === "outlined") ? bgColor : "transparent",
|
|
26
27
|
"& .M4LIcon-icon": {
|
|
27
28
|
backgroundColor: `${color} !important`
|
|
28
29
|
},
|
|
30
|
+
...getHeightSizeStyles(
|
|
31
|
+
theme.generalSettings.isMobile,
|
|
32
|
+
ownerState.chipSize || "medium",
|
|
33
|
+
"base"
|
|
34
|
+
),
|
|
29
35
|
"&:hover": {
|
|
30
36
|
backgroundColor: bgHover
|
|
31
37
|
},
|
|
@@ -37,15 +43,14 @@ const chipStyles = {
|
|
|
37
43
|
},
|
|
38
44
|
...ownerState.variant === "outlined" && {
|
|
39
45
|
border: `${theme.vars.size.borderStroke.container}`,
|
|
40
|
-
borderColor:
|
|
46
|
+
borderColor: bgColor
|
|
41
47
|
},
|
|
42
48
|
"&:focus-visible": {
|
|
43
49
|
boxShadow: "none",
|
|
44
|
-
outline: theme.vars.size.borderStroke.container
|
|
45
|
-
outlineColor: theme.vars.palette.border.main,
|
|
46
|
-
outlineOffset: theme.vars.size.baseSpacings["sp0-5"],
|
|
50
|
+
outline: `${theme.vars.size.borderStroke.container} ${theme.vars.palette.border.main}`,
|
|
47
51
|
backgroundColor: bgActive
|
|
48
|
-
}
|
|
52
|
+
},
|
|
53
|
+
variants: []
|
|
49
54
|
};
|
|
50
55
|
},
|
|
51
56
|
/**
|
|
@@ -58,7 +63,7 @@ const chipStyles = {
|
|
|
58
63
|
textChip: ({ theme }) => ({
|
|
59
64
|
whiteSpace: "nowrap",
|
|
60
65
|
paddingLeft: theme.vars.size.baseSpacings.sp1,
|
|
61
|
-
paddingRight: theme.vars.size.baseSpacings.
|
|
66
|
+
paddingRight: theme.vars.size.baseSpacings.sp2
|
|
62
67
|
}),
|
|
63
68
|
/**
|
|
64
69
|
* Styles for the chip icon element.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentPalletColor, Sizes } from '@m4l/styles';
|
|
1
|
+
import { ChipColor, ComponentPalletColor, Sizes } from '@m4l/styles';
|
|
2
2
|
import { Theme } from '@mui/material';
|
|
3
3
|
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
4
4
|
import { EventHandler, ReactNode } from 'react';
|
|
@@ -39,7 +39,11 @@ export interface ChipProps {
|
|
|
39
39
|
* Defines the color of the `Chip`.
|
|
40
40
|
* @createdAt 2025-01-08 10:36:39 - automatic
|
|
41
41
|
*/
|
|
42
|
-
color?: Exclude<ComponentPalletColor, 'primary'
|
|
42
|
+
color?: Exclude<ComponentPalletColor, 'primary'> | 'florest' | 'disabled';
|
|
43
|
+
/**
|
|
44
|
+
* Alternative color for the `Chip`.
|
|
45
|
+
*/
|
|
46
|
+
externalColor?: ChipColor;
|
|
43
47
|
/**
|
|
44
48
|
* Define el with of skeleton mode
|
|
45
49
|
* @createdAt 2025-01-08 10:36:39 - automatic
|
|
@@ -75,9 +79,10 @@ export interface ChipProps {
|
|
|
75
79
|
/**
|
|
76
80
|
* Owner state of the `Chip` used to define internal style and behavior properties.
|
|
77
81
|
*/
|
|
78
|
-
export interface ChipOwnerState extends Pick<ChipProps, 'variant' | '
|
|
82
|
+
export interface ChipOwnerState extends Pick<ChipProps, 'variant' | 'externalColor'> {
|
|
79
83
|
opacity?: boolean;
|
|
80
84
|
chipSize: ChipProps['size'];
|
|
85
|
+
color: Exclude<ComponentPalletColor, 'primary'> | 'florest' | 'disabled';
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
83
88
|
* Defines the types of Slots available for the `Chip`.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { RHFDateTimeProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
|
+
* @author DanielEscobar - automatic
|
|
5
|
+
* @createdAt 2025-01-27 14:53:37 - automatic
|
|
6
|
+
* @updatedAt 2025-01-28 12:16:07 - automatic
|
|
7
|
+
* @updatedUser DanielEscobar - automatic
|
|
4
8
|
*/
|
|
5
9
|
export declare function RHFDateTime(props: RHFDateTimeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,79 +1,44 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
-
import { DateTimePicker } from "@mui/x-date-pickers";
|
|
4
|
-
import { useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
5
|
-
import { S as SkeletonRHFDateTime } from "./subcomponents/Skeleton/index.js";
|
|
6
|
-
import { useFormatter, useResponsiveDesktop } from "@m4l/graphics";
|
|
7
|
-
import { useState, useEffect } from "react";
|
|
8
|
-
import { u as useUtilityClasses } from "./classes/index.js";
|
|
9
2
|
import clsx from "clsx";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
5
|
+
import { useFormatter } from "@m4l/graphics";
|
|
6
|
+
import { g as getComponentClasses } from "../../../utils/getComponentSlotRoot.js";
|
|
7
|
+
import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
8
|
+
import { D as DateTimePicker } from "../../mui_extended/DateTimePicker/DateTimePicker.js";
|
|
9
|
+
import { R as RHFDateTimeRootStyled } from "./slots/RHFDateTimeSlots.js";
|
|
10
|
+
import { R as RHF_DATE_TIME_KEY_COMPONENT } from "./constants.js";
|
|
11
|
+
import { R as RHFDateTimeSlots } from "./slots/RHFDateTimeEnum.js";
|
|
12
|
+
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
14
13
|
import { L as Label } from "../../Label/Label.js";
|
|
15
14
|
import { H as HelperError } from "../../HelperError/HelperError.js";
|
|
16
|
-
import { I as Icon } from "../../Icon/Icon.js";
|
|
17
15
|
function RHFDateTime(props) {
|
|
18
16
|
const {
|
|
19
17
|
name: nameRHF,
|
|
20
18
|
disabled,
|
|
21
|
-
size = "
|
|
19
|
+
size = "medium",
|
|
22
20
|
variant,
|
|
23
|
-
skeletonWidth = "50%",
|
|
24
|
-
skeletonHeight = 14,
|
|
25
|
-
className,
|
|
26
21
|
label,
|
|
27
22
|
helperMessage,
|
|
28
23
|
mandatory,
|
|
29
|
-
mandatoryMessage
|
|
24
|
+
mandatoryMessage,
|
|
25
|
+
className,
|
|
26
|
+
dataTestId
|
|
30
27
|
} = props;
|
|
31
|
-
const {
|
|
32
|
-
const
|
|
33
|
-
return /* @__PURE__ */ jsx(
|
|
34
|
-
Icon,
|
|
35
|
-
{
|
|
36
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/rhfdate/ended_at.svg`
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
const [currentVariant, setCurrentVariant] = useState(void 0);
|
|
41
|
-
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
42
|
-
const {
|
|
43
|
-
control,
|
|
44
|
-
formState: { errors }
|
|
45
|
-
} = useFormContext();
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (errors[nameRHF]) {
|
|
48
|
-
setCurrentVariant("error");
|
|
49
|
-
} else if (variant) {
|
|
50
|
-
setCurrentVariant(variant);
|
|
51
|
-
} else {
|
|
52
|
-
setCurrentVariant(void 0);
|
|
53
|
-
}
|
|
54
|
-
}, [errors[nameRHF], variant, control]);
|
|
55
|
-
const isSkeleton = useModuleSkeleton();
|
|
28
|
+
const { control } = useFormContext();
|
|
29
|
+
const htmlForId = useId();
|
|
56
30
|
const {
|
|
57
31
|
dateFormatter: { datetimeFormat }
|
|
58
32
|
} = useFormatter();
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
63
|
-
disabled,
|
|
64
|
-
size: isDesktop ? size : "medium",
|
|
65
|
-
variant: currentVariant
|
|
66
|
-
};
|
|
67
|
-
const classes = useUtilityClasses(ownerState);
|
|
33
|
+
const { currentSize } = useComponentSize(size);
|
|
34
|
+
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
35
|
+
const classes = getComponentClasses(RHF_DATE_TIME_KEY_COMPONENT, RHFDateTimeSlots);
|
|
68
36
|
return /* @__PURE__ */ jsx(
|
|
69
|
-
|
|
37
|
+
RHFDateTimeRootStyled,
|
|
70
38
|
{
|
|
71
|
-
className: clsx(classes.root
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onKeyUp: handlerOnKeyUp,
|
|
75
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameRHFDateTimeDataTestId("root") } : {},
|
|
76
|
-
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
39
|
+
className: clsx(className, classes.root),
|
|
40
|
+
...getPropDataTestId(RHF_DATE_TIME_KEY_COMPONENT, RHFDateTimeSlots.root, dataTestId),
|
|
41
|
+
children: /* @__PURE__ */ jsx(
|
|
77
42
|
Controller,
|
|
78
43
|
{
|
|
79
44
|
name: nameRHF,
|
|
@@ -83,7 +48,9 @@ function RHFDateTime(props) {
|
|
|
83
48
|
label && /* @__PURE__ */ jsx(
|
|
84
49
|
Label,
|
|
85
50
|
{
|
|
86
|
-
|
|
51
|
+
disabled,
|
|
52
|
+
htmlFor: htmlForId,
|
|
53
|
+
size: adjustedSize,
|
|
87
54
|
label,
|
|
88
55
|
mandatory,
|
|
89
56
|
mandatoryMessage,
|
|
@@ -93,41 +60,27 @@ function RHFDateTime(props) {
|
|
|
93
60
|
/* @__PURE__ */ jsx(
|
|
94
61
|
DateTimePicker,
|
|
95
62
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
},
|
|
63
|
+
variant,
|
|
64
|
+
size: adjustedSize,
|
|
65
|
+
disabled,
|
|
101
66
|
inputRef: ref,
|
|
102
|
-
ampm: true,
|
|
103
|
-
value,
|
|
104
|
-
onChange: (newValue) => {
|
|
105
|
-
onChange(newValue);
|
|
106
|
-
},
|
|
107
|
-
slots: {
|
|
108
|
-
openPickerIcon: resourceIcon
|
|
109
|
-
},
|
|
110
67
|
slotProps: {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
onBlur: handlerOnBlur
|
|
68
|
+
field: {
|
|
69
|
+
format: datetimeFormat
|
|
114
70
|
},
|
|
115
|
-
|
|
116
|
-
|
|
71
|
+
textField: {
|
|
72
|
+
id: htmlForId
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
value,
|
|
76
|
+
onChange,
|
|
77
|
+
error: !!error?.message
|
|
117
78
|
}
|
|
118
79
|
),
|
|
119
|
-
error?.message && /* @__PURE__ */ jsx(HelperError, { message: error?.message + "" })
|
|
80
|
+
error?.message && /* @__PURE__ */ jsx(HelperError, { size: adjustedSize, htmlFor: htmlForId, message: error?.message + "" })
|
|
120
81
|
] });
|
|
121
82
|
}
|
|
122
83
|
}
|
|
123
|
-
) : /* @__PURE__ */ jsx(
|
|
124
|
-
SkeletonRHFDateTime,
|
|
125
|
-
{
|
|
126
|
-
skeletonWidth,
|
|
127
|
-
skeletonHeight,
|
|
128
|
-
className: classes,
|
|
129
|
-
label
|
|
130
|
-
}
|
|
131
84
|
)
|
|
132
85
|
}
|
|
133
86
|
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const rhfDateTimeStyles = {
|
|
2
|
+
/**
|
|
3
|
+
* estilos root
|
|
4
|
+
* @author DanielEscobar - automatic
|
|
5
|
+
* @createdAt 2025-01-27 11:56:49 - automatic
|
|
6
|
+
* @updatedAt 2025-01-27 11:56:50 - automatic
|
|
7
|
+
* @updatedUser DanielEscobar - automatic
|
|
8
|
+
*/
|
|
9
|
+
root: ({ theme }) => ({
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
gap: theme.vars.size.baseSpacings["sp0-5"]
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
rhfDateTimeStyles as r
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RHF_DATE_TIME_KEY_COMPONENT = "M4LRHFDateTime";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RHFDateTimeRootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown>, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { styled } from "@mui/material";
|
|
2
|
+
import { R as RHF_DATE_TIME_KEY_COMPONENT } from "../constants.js";
|
|
3
|
+
import { r as rhfDateTimeStyles } from "../RHFDateTime.styles.js";
|
|
4
|
+
const RHFDateTimeRootStyled = styled("div", {
|
|
5
|
+
name: RHF_DATE_TIME_KEY_COMPONENT
|
|
6
|
+
})(rhfDateTimeStyles.root);
|
|
7
|
+
export {
|
|
8
|
+
RHFDateTimeRootStyled as R
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import { Sizes } from '@m4l/styles';
|
|
2
|
+
import { TextFieldVariants } from '../../../components/mui_extended/TextField/types';
|
|
1
3
|
import { LabelProps } from '../../Label/types';
|
|
4
|
+
import { M4LOverridesStyleRules } from '../../../../src/@types/augmentations';
|
|
5
|
+
import { Theme } from '@mui/material';
|
|
6
|
+
import { RHFDateTimeSlots } from './slots/RHFDateTimeEnum';
|
|
7
|
+
import { RHF_DATE_TIME_KEY_COMPONENT } from './constants';
|
|
2
8
|
export interface RHFDateTimeProps extends Omit<LabelProps, 'label'> {
|
|
3
|
-
skeletonWidth?: string | number;
|
|
4
|
-
skeletonHeight?: string | number;
|
|
5
9
|
name: string;
|
|
6
|
-
variant?:
|
|
7
|
-
size?:
|
|
10
|
+
variant?: TextFieldVariants;
|
|
11
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
8
12
|
disabled?: boolean;
|
|
9
13
|
className?: string;
|
|
10
14
|
label?: string;
|
|
11
15
|
helperMessage?: string;
|
|
16
|
+
/**
|
|
17
|
+
* dataTestId
|
|
18
|
+
*/
|
|
19
|
+
dataTestId?: string;
|
|
12
20
|
}
|
|
13
|
-
type
|
|
14
|
-
export type RHFDateTimeVariants = 'info' | 'success' | 'warning' | undefined;
|
|
15
|
-
export interface OwnerState extends Pick<RHFDateTimeProps, 'size' | 'disabled'> {
|
|
16
|
-
isFocus: boolean;
|
|
17
|
-
isTabSelected: boolean;
|
|
18
|
-
variant?: RHFDateTimeVariants | 'error';
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
21
|
+
export type RHFDateTimeStyles = M4LOverridesStyleRules<keyof typeof RHFDateTimeSlots, typeof RHF_DATE_TIME_KEY_COMPONENT, Theme>;
|
|
@@ -58,11 +58,7 @@ const autocompleteSyles = {
|
|
|
58
58
|
* @updatedAt 2025-01-08 10:36:41 - automatic
|
|
59
59
|
* @updatedUser Andrés Quintero - automatic
|
|
60
60
|
*/
|
|
61
|
-
chip:
|
|
62
|
-
"& .M4LIconClass-root": {
|
|
63
|
-
backgroundColor: theme.vars.palette.chips.default.semanticText
|
|
64
|
-
}
|
|
65
|
-
}),
|
|
61
|
+
chip: {},
|
|
66
62
|
/**
|
|
67
63
|
* Styles for the text field component.
|
|
68
64
|
* @author SebastianM - automatic
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DateTimePickerProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* DataTimePicker es un refactor del componente de material UI.
|
|
4
|
+
* @author DanielEscobar - automatic
|
|
5
|
+
* @createdAt 2025-01-27 14:53:37 - automatic
|
|
6
|
+
* @updatedAt 2025-01-28 13:53:42 - automatic
|
|
7
|
+
* @updatedUser DanielEscobar - automatic
|
|
8
|
+
*
|
|
9
|
+
* ```tsx *
|
|
10
|
+
* const ExampleComponent = () => {
|
|
11
|
+
* const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
|
|
12
|
+
*
|
|
13
|
+
* const handleDateChange = (date: Date | null) => {
|
|
14
|
+
* setSelectedDate(date);
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <DateTimePicker
|
|
19
|
+
* size="medium"
|
|
20
|
+
* error={false}
|
|
21
|
+
* disabled={false}
|
|
22
|
+
* variant="outlined"
|
|
23
|
+
* ampm={true}
|
|
24
|
+
* value={selectedDate}
|
|
25
|
+
* onChange={handleDateChange}
|
|
26
|
+
* />
|
|
27
|
+
* );
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* export default ExampleComponent;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const DateTimePicker: (props: DateTimePickerProps<Date>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { useMemo, useCallback } from "react";
|
|
4
|
+
import { useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
5
|
+
import { useIsMobile } from "@m4l/graphics";
|
|
6
|
+
import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
7
|
+
import { g as getComponentClasses } from "../../../utils/getComponentSlotRoot.js";
|
|
8
|
+
import { P as PopperStyled, a as PickersCalendarHeaderStyled, I as IconButtonStyled, b as PickersDayStyled, c as PaperStyled, S as SkeletonStyled, M as MobileDateTimePickerRootStyled, D as DesktopDateTimePickerRootStyled } from "./slots/DateTimePickerSlots.js";
|
|
9
|
+
import { d as date, c as chevron_right, a as chevron_left, b as chevron_down } from "./icons.js";
|
|
10
|
+
import { D as DateTimePickerEnum } from "./slots/DateTimePickerEnum.js";
|
|
11
|
+
import { D as DATE_TIME_PICKER_KEY_COMPONENT } from "./constants.js";
|
|
12
|
+
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
13
|
+
import { I as IconButton } from "../IconButton/IconButton.js";
|
|
14
|
+
const DateTimePicker = (props) => {
|
|
15
|
+
const {
|
|
16
|
+
size = "medium",
|
|
17
|
+
error = false,
|
|
18
|
+
disabled = false,
|
|
19
|
+
className,
|
|
20
|
+
dataTestId,
|
|
21
|
+
variant,
|
|
22
|
+
ampm = true,
|
|
23
|
+
value,
|
|
24
|
+
onChange,
|
|
25
|
+
...others
|
|
26
|
+
} = props;
|
|
27
|
+
const isMobile = useIsMobile();
|
|
28
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
29
|
+
const { currentSize } = useComponentSize(size);
|
|
30
|
+
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
31
|
+
const ownerState = useMemo(() => ({
|
|
32
|
+
size: adjustedSize,
|
|
33
|
+
error,
|
|
34
|
+
variant,
|
|
35
|
+
disabled
|
|
36
|
+
}), [adjustedSize, disabled, error, variant]);
|
|
37
|
+
const openPickerButton = useCallback((args) => {
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
IconButton,
|
|
40
|
+
{
|
|
41
|
+
...args,
|
|
42
|
+
icon: `${host_static_assets}/${environment_assets}/${date}`,
|
|
43
|
+
size: adjustedSize,
|
|
44
|
+
disabled
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}, [adjustedSize, disabled, environment_assets, host_static_assets]);
|
|
48
|
+
const popper = useCallback((args) => {
|
|
49
|
+
return /* @__PURE__ */ jsx(PopperStyled, { ...args, ownerState, ...getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.popper, dataTestId) });
|
|
50
|
+
}, [ownerState]);
|
|
51
|
+
const calendarHeader = useCallback((args) => {
|
|
52
|
+
return /* @__PURE__ */ jsx(PickersCalendarHeaderStyled, { ...args, ownerState, ...getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.pickersCalendarHeader, dataTestId) });
|
|
53
|
+
}, [ownerState]);
|
|
54
|
+
const nextIconButton = useCallback((args) => {
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
IconButtonStyled,
|
|
57
|
+
{
|
|
58
|
+
...args,
|
|
59
|
+
ownerState,
|
|
60
|
+
size: adjustedSize,
|
|
61
|
+
disabled,
|
|
62
|
+
icon: `${host_static_assets}/${environment_assets}/${chevron_right}`
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}, [adjustedSize, disabled, environment_assets, host_static_assets, ownerState]);
|
|
66
|
+
const previousIconButton = useCallback((args) => {
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
IconButtonStyled,
|
|
69
|
+
{
|
|
70
|
+
...args,
|
|
71
|
+
ownerState,
|
|
72
|
+
size: adjustedSize,
|
|
73
|
+
disabled,
|
|
74
|
+
icon: `${host_static_assets}/${environment_assets}/${chevron_left}`
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}, [adjustedSize, disabled, environment_assets, host_static_assets, ownerState]);
|
|
78
|
+
const switchViewButton = useCallback((args) => {
|
|
79
|
+
return /* @__PURE__ */ jsx(
|
|
80
|
+
IconButtonStyled,
|
|
81
|
+
{
|
|
82
|
+
...args,
|
|
83
|
+
ownerState,
|
|
84
|
+
size: adjustedSize,
|
|
85
|
+
disabled,
|
|
86
|
+
icon: `${host_static_assets}/${environment_assets}/${chevron_down}`
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}, [adjustedSize, disabled, environment_assets, host_static_assets, ownerState]);
|
|
90
|
+
const day = useCallback((args) => {
|
|
91
|
+
return /* @__PURE__ */ jsx(PickersDayStyled, { ...args, disableRipple: true, ownerState, ...getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.pickersDay, dataTestId) });
|
|
92
|
+
}, [ownerState]);
|
|
93
|
+
const mobilePaper = useCallback((args) => {
|
|
94
|
+
return /* @__PURE__ */ jsx(PaperStyled, { ...args, ownerState, ...getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.paper, dataTestId) });
|
|
95
|
+
}, [ownerState]);
|
|
96
|
+
const classes = getComponentClasses(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum);
|
|
97
|
+
const isSkeleton = useModuleSkeleton();
|
|
98
|
+
if (isSkeleton) {
|
|
99
|
+
return /* @__PURE__ */ jsx(SkeletonStyled, { ownerState, ...getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.skeleton, dataTestId) });
|
|
100
|
+
}
|
|
101
|
+
return isMobile ? /* @__PURE__ */ jsx(
|
|
102
|
+
MobileDateTimePickerRootStyled,
|
|
103
|
+
{
|
|
104
|
+
ownerState,
|
|
105
|
+
ampm,
|
|
106
|
+
disabled,
|
|
107
|
+
value,
|
|
108
|
+
onChange,
|
|
109
|
+
slots: {
|
|
110
|
+
calendarHeader,
|
|
111
|
+
nextIconButton,
|
|
112
|
+
previousIconButton,
|
|
113
|
+
switchViewButton,
|
|
114
|
+
day,
|
|
115
|
+
mobilePaper
|
|
116
|
+
},
|
|
117
|
+
slotProps: {
|
|
118
|
+
textField: {
|
|
119
|
+
className: clsx(className, classes.rootMobile),
|
|
120
|
+
"data-testid": getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.rootMobile, dataTestId)["data-testid"]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
...others
|
|
124
|
+
}
|
|
125
|
+
) : /* @__PURE__ */ jsx(
|
|
126
|
+
DesktopDateTimePickerRootStyled,
|
|
127
|
+
{
|
|
128
|
+
ownerState,
|
|
129
|
+
ampm,
|
|
130
|
+
disabled,
|
|
131
|
+
value,
|
|
132
|
+
onChange,
|
|
133
|
+
slots: {
|
|
134
|
+
openPickerButton,
|
|
135
|
+
popper,
|
|
136
|
+
calendarHeader,
|
|
137
|
+
nextIconButton,
|
|
138
|
+
previousIconButton,
|
|
139
|
+
switchViewButton,
|
|
140
|
+
day
|
|
141
|
+
},
|
|
142
|
+
slotProps: {
|
|
143
|
+
textField: {
|
|
144
|
+
className: clsx(className, classes.rootDesktop),
|
|
145
|
+
"data-testid": getPropDataTestId(DATE_TIME_PICKER_KEY_COMPONENT, DateTimePickerEnum.rootDesktop, dataTestId)["data-testid"]
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
...others
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
export {
|
|
153
|
+
DateTimePicker as D
|
|
154
|
+
};
|