@soyfri/shared-library 2.0.0-beta.2 → 2.0.0-beta.4
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/.dockerignore +8 -0
- package/.github/workflows/publish.yml +107 -0
- package/.prettierrc +3 -0
- package/.storybook/main.ts +19 -0
- package/.storybook/preview.ts +14 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/Dockerfile +37 -0
- package/build.js +102 -0
- package/chromatic.config.json +5 -0
- package/cleanDirectories.js +40 -0
- package/dist/README.md +243 -0
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Table/Table.js +1 -1
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -1
- package/dist/mui.d.ts +1 -0
- package/dist/package.json +197 -0
- package/package.json +4 -32
- package/rollup.config.cjs +87 -0
- package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
- package/src/components/ActionMenu/ActionMenu.tsx +174 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +272 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +123 -0
- package/src/components/AppBar/AppBarBrand.tsx +120 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
- package/src/components/AppBar/index.ts +25 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +477 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +748 -0
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +361 -0
- package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
- package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
- package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
- package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
- package/src/components/Autocomplete/index.ts +12 -0
- package/src/components/Avatar/Avatar.definitions.ts +162 -0
- package/src/components/Avatar/Avatar.stories.tsx +258 -0
- package/src/components/Avatar/Avatar.tsx +206 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.definition.ts +97 -0
- package/src/components/Button/Button.stories.tsx +285 -0
- package/src/components/Button/Button.tsx +67 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.definition.ts +5 -0
- package/src/components/Card/Card.stories.tsx +221 -0
- package/src/components/Card/Card.sx.ts +104 -0
- package/src/components/Card/Card.tsx +200 -0
- package/src/components/Card/index.ts +9 -0
- package/src/components/Chip/Chip.definitions.ts +167 -0
- package/src/components/Chip/Chip.stories.tsx +265 -0
- package/src/components/Chip/Chip.tsx +61 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Column/Column.tsx +29 -0
- package/src/components/Column/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.definitions.ts +228 -0
- package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +309 -0
- package/src/components/DatePicker/DatePicker.sx.ts +33 -0
- package/src/components/DatePicker/DatePicker.tsx +189 -0
- package/src/components/DatePicker/DatePicker.types.ts +10 -0
- package/src/components/DatePicker/index.ts +9 -0
- package/src/components/DateRangePicker/DateRangePicker.definitions.ts +191 -0
- package/src/components/DateRangePicker/DateRangePicker.stories.tsx +252 -0
- package/src/components/DateRangePicker/DateRangePicker.tsx +56 -0
- package/src/components/DateRangePicker/index.ts +1 -0
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +256 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +418 -0
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +225 -0
- package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
- package/src/components/DateTimePicker/index.ts +9 -0
- package/src/components/Drawer/Drawer.stories.tsx +270 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +214 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +110 -0
- package/src/components/Drawer/index.ts +10 -0
- package/src/components/Flyout/Flyout.stories.tsx +282 -0
- package/src/components/Flyout/Flyout.tsx +122 -0
- package/src/components/Flyout/index.ts +1 -0
- package/src/components/Gallery/Gallery.definition.tsx +37 -0
- package/src/components/Gallery/Gallery.stories.tsx +82 -0
- package/src/components/Gallery/Gallery.tsx +118 -0
- package/src/components/Gallery/GalleryLightbox.tsx +170 -0
- package/src/components/Gallery/GalleryMain.tsx +84 -0
- package/src/components/Gallery/GalleryThumbnails.tsx +106 -0
- package/src/components/Gallery/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +121 -0
- package/src/components/Icon/Icon.tsx +175 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.definitions.ts +324 -0
- package/src/components/Input/Input.helpers.ts +49 -0
- package/src/components/Input/Input.stories.tsx +499 -0
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +141 -0
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/index.ts +9 -0
- package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +267 -0
- package/src/components/InputGroup/InputGroup.tsx +179 -0
- package/src/components/InputGroup/index.ts +1 -0
- package/src/components/MenuButton/MenuButton.stories.tsx +197 -0
- package/src/components/MenuButton/MenuButton.tsx +100 -0
- package/src/components/MenuButton/index.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +721 -0
- package/src/components/Modal/Modal.tsx +355 -0
- package/src/components/Modal/ModalBody.tsx +16 -0
- package/src/components/Modal/ModalFooter.tsx +71 -0
- package/src/components/Modal/ModalHeader.tsx +18 -0
- package/src/components/Modal/index.ts +6 -0
- package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
- package/src/components/PageLoader/PageLoader.tsx +96 -0
- package/src/components/PageLoader/index.ts +2 -0
- package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
- package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
- package/src/components/ScrollTopButton/index.ts +8 -0
- package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
- package/src/components/Select/Select.definitions.ts +602 -0
- package/src/components/Select/Select.helpers.ts +71 -0
- package/src/components/Select/Select.stories.tsx +687 -0
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +429 -0
- package/src/components/Select/Select.types.ts +15 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
- package/src/components/Select/_parts/SelectValue.tsx +96 -0
- package/src/components/Select/index.ts +14 -0
- package/src/components/Stat/Stat.stories.tsx +85 -0
- package/src/components/Stat/Stat.tsx +117 -0
- package/src/components/Stat/index.ts +2 -0
- package/src/components/StatusMessage/StatusMessage.stories.tsx +130 -0
- package/src/components/StatusMessage/StatusMessage.tsx +162 -0
- package/src/components/StatusMessage/index.ts +2 -0
- package/src/components/Stepper/Step.tsx +21 -0
- package/src/components/Stepper/Stepper.definition.ts +75 -0
- package/src/components/Stepper/Stepper.stories.tsx +122 -0
- package/src/components/Stepper/Stepper.tsx +75 -0
- package/src/components/Stepper/index.ts +2 -0
- package/src/components/Table/EmptyTable.png +0 -0
- package/src/components/Table/Table.definition.ts +580 -0
- package/src/components/Table/Table.stories.tsx +853 -0
- package/src/components/Table/Table.tsx +495 -0
- package/src/components/Table/data.ts +134 -0
- package/src/components/Table/exportsUtils.ts +195 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/Table/types.ts +34 -0
- package/src/components/Tabs/Tab.definition.ts +53 -0
- package/src/components/Tabs/Tab.tsx +19 -0
- package/src/components/Tabs/Tabs.stories.tsx +118 -0
- package/src/components/Tabs/Tabs.tsx +99 -0
- package/src/components/Tabs/_tabUtils.tsx +4 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Timeline/Timeline.definition.ts +43 -0
- package/src/components/Timeline/Timeline.stories.tsx +108 -0
- package/src/components/Timeline/Timeline.tsx +49 -0
- package/src/components/Timeline/TimelineItem.tsx +31 -0
- package/src/components/Timeline/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +129 -0
- package/src/components/Tooltip/Tooltip.tsx +58 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/_shared/formField.sx.ts +118 -0
- package/src/components/_shared/resolvePreset.ts +35 -0
- package/src/hooks/ClipBoard/ClipBoard.stories.tsx +168 -0
- package/src/hooks/ClipBoard/ClipBoard.tsx +131 -0
- package/src/hooks/ClipBoard/ClipboardUnifiedDemo.tsx +111 -0
- package/src/hooks/ClipBoard/index.ts +1 -0
- package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
- package/src/hooks/Wizard/WizardContext.tsx +166 -0
- package/src/hooks/Wizard/index.ts +6 -0
- package/src/hooks/Wizard/useWizard.ts +13 -0
- package/src/index.ts +17 -0
- package/src/mui.ts +54 -0
- package/src/styles.css +3 -0
- package/src/theme/componentStyles.ts +47 -0
- package/src/theme/tokens.ts +43 -0
- package/tailwind.config.js +10 -0
- package/tsconfig.json +48 -0
- package/tsup.config.js +41 -0
- package/vite.config.js +132 -0
- package/vitest.config.ts +35 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
3
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
4
|
+
import { DateRangePicker as MuiDateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker';
|
|
5
|
+
import { TextField } from '@mui/material';
|
|
6
|
+
import { Dayjs } from 'dayjs';
|
|
7
|
+
|
|
8
|
+
// Define las props para el DateRangePicker
|
|
9
|
+
export interface DateRangePickerProps {
|
|
10
|
+
label?: string;
|
|
11
|
+
startDate: Dayjs | null;
|
|
12
|
+
endDate: Dayjs | null;
|
|
13
|
+
onDateRangeChange: (start: Dayjs | null, end: Dayjs | null) => void;
|
|
14
|
+
minDate?: Dayjs;
|
|
15
|
+
maxDate?: Dayjs;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
slotProps?: any; // Para pasar slotProps a MuiDateRangePicker
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const DateRangePicker: React.FC<DateRangePickerProps> = ({
|
|
22
|
+
label,
|
|
23
|
+
startDate,
|
|
24
|
+
endDate,
|
|
25
|
+
onDateRangeChange,
|
|
26
|
+
minDate,
|
|
27
|
+
maxDate,
|
|
28
|
+
disabled,
|
|
29
|
+
readOnly,
|
|
30
|
+
slotProps,
|
|
31
|
+
...rest
|
|
32
|
+
}) => {
|
|
33
|
+
const value: [Dayjs | null, Dayjs | null] = [startDate, endDate];
|
|
34
|
+
|
|
35
|
+
const handleChange = (newValue: [Dayjs | null, Dayjs | null]) => {
|
|
36
|
+
onDateRangeChange(newValue[0], newValue[1]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
41
|
+
<MuiDateRangePicker
|
|
42
|
+
localeText={{ start: 'Fecha de Inicio', end: 'Fecha de Fin' }}
|
|
43
|
+
value={value}
|
|
44
|
+
onChange={handleChange}
|
|
45
|
+
minDate={minDate}
|
|
46
|
+
maxDate={maxDate}
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
readOnly={readOnly}
|
|
49
|
+
slotProps={slotProps} // Pasa los slotProps directamente
|
|
50
|
+
{...rest}
|
|
51
|
+
/>
|
|
52
|
+
</LocalizationProvider>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default DateRangePicker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DateRangePicker } from './DateRangePicker';
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// DateTimePicker.definitions.ts
|
|
2
|
+
|
|
3
|
+
export const BasicDateTimePickerDefinition = `
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import { Box, Typography } from '@mui/material';
|
|
8
|
+
|
|
9
|
+
export const BasicDateTimePickerExample = () => {
|
|
10
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
11
|
+
return (
|
|
12
|
+
<Box sx={{ width: 300 }}>
|
|
13
|
+
<DateTimePicker
|
|
14
|
+
label="Seleccionar Fecha y Hora"
|
|
15
|
+
selectedDateTime={selectedDateTime}
|
|
16
|
+
onDateTimeChange={setSelectedDateTime}
|
|
17
|
+
/>
|
|
18
|
+
<Typography sx={{ mt: 2 }}>
|
|
19
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
20
|
+
</Typography>
|
|
21
|
+
</Box>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const DateTimePickerWithMinMaxDefinition = `
|
|
27
|
+
import React, { useState } from 'react';
|
|
28
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
29
|
+
import dayjs from 'dayjs';
|
|
30
|
+
import { Box, Typography } from '@mui/material';
|
|
31
|
+
|
|
32
|
+
export const DateTimePickerWithMinMaxExample = () => {
|
|
33
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs('2023-06-15T10:00'));
|
|
34
|
+
const minDateTime = dayjs('2023-06-01T09:00');
|
|
35
|
+
const maxDateTime = dayjs('2023-06-30T17:00');
|
|
36
|
+
return (
|
|
37
|
+
<Box sx={{ width: 300 }}>
|
|
38
|
+
<DateTimePicker
|
|
39
|
+
label="Fecha y Hora en Junio"
|
|
40
|
+
selectedDateTime={selectedDateTime}
|
|
41
|
+
onDateTimeChange={setSelectedDateTime}
|
|
42
|
+
minDateTime={minDateTime}
|
|
43
|
+
maxDateTime={maxDateTime}
|
|
44
|
+
/>
|
|
45
|
+
<Typography sx={{ mt: 2 }}>
|
|
46
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
47
|
+
</Typography>
|
|
48
|
+
<Typography variant="caption" color="text.secondary">
|
|
49
|
+
(Rango: \${minDateTime.format('YYYY-MM-DD HH:mm')} a \${maxDateTime.format('YYYY-MM-DD HH:mm')})
|
|
50
|
+
</Typography>
|
|
51
|
+
</Box>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
export const DateTimePickerDisabledDefinition = `
|
|
57
|
+
import React, { useState } => from 'react';
|
|
58
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
59
|
+
import dayjs from 'dayjs';
|
|
60
|
+
import { Box, Typography } from '@mui/material';
|
|
61
|
+
|
|
62
|
+
export const DateTimePickerDisabledExample = () => {
|
|
63
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
64
|
+
return (
|
|
65
|
+
<Box sx={{ width: 300 }}>
|
|
66
|
+
<DateTimePicker
|
|
67
|
+
label="Fecha y Hora (Deshabilitado)"
|
|
68
|
+
selectedDateTime={selectedDateTime}
|
|
69
|
+
onDateTimeChange={setSelectedDateTime}
|
|
70
|
+
disabled
|
|
71
|
+
/>
|
|
72
|
+
<Typography sx={{ mt: 2 }}>
|
|
73
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
74
|
+
</Typography>
|
|
75
|
+
</Box>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
export const DateTimePickerReadOnlyDefinition = `
|
|
81
|
+
import React, { useState } from 'react';
|
|
82
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
83
|
+
import dayjs from 'dayjs';
|
|
84
|
+
import { Box, Typography } from '@mui/material';
|
|
85
|
+
|
|
86
|
+
export const DateTimePickerReadOnlyExample = () => {
|
|
87
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs('2024-07-24T14:30'));
|
|
88
|
+
return (
|
|
89
|
+
<Box sx={{ width: 300 }}>
|
|
90
|
+
<DateTimePicker
|
|
91
|
+
label="Fecha y Hora (Solo Lectura)"
|
|
92
|
+
selectedDateTime={selectedDateTime}
|
|
93
|
+
onDateTimeChange={() => {}} // No permite cambios
|
|
94
|
+
readOnly
|
|
95
|
+
/>
|
|
96
|
+
<Typography sx={{ mt: 2 }}>
|
|
97
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
98
|
+
</Typography>
|
|
99
|
+
</Box>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
export const DateTimePickerWithInitialNullDefinition = `
|
|
105
|
+
import React, { useState } from 'react';
|
|
106
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
107
|
+
import dayjs from 'dayjs';
|
|
108
|
+
import { Box, Typography } from '@mui/material';
|
|
109
|
+
|
|
110
|
+
export const DateTimePickerWithInitialNullExample = () => {
|
|
111
|
+
const [selectedDateTime, setSelectedDateTime] = useState(null);
|
|
112
|
+
return (
|
|
113
|
+
<Box sx={{ width: 300 }}>
|
|
114
|
+
<DateTimePicker
|
|
115
|
+
label="Fecha y Hora (Sin Selección Inicial)"
|
|
116
|
+
selectedDateTime={selectedDateTime}
|
|
117
|
+
onDateTimeChange={setSelectedDateTime}
|
|
118
|
+
/>
|
|
119
|
+
<Typography sx={{ mt: 2 }}>
|
|
120
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
121
|
+
</Typography>
|
|
122
|
+
</Box>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
export const DateTimePickerSmallSizeDefinition = `
|
|
128
|
+
import React, { useState } from 'react';
|
|
129
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
130
|
+
import dayjs from 'dayjs';
|
|
131
|
+
import { Box, Typography } from '@mui/material';
|
|
132
|
+
|
|
133
|
+
export const DateTimePickerSmallSizeExample = () => {
|
|
134
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
135
|
+
return (
|
|
136
|
+
<Box sx={{ width: 250 }}>
|
|
137
|
+
<DateTimePicker
|
|
138
|
+
label="Fecha y Hora (Pequeño)"
|
|
139
|
+
selectedDateTime={selectedDateTime}
|
|
140
|
+
onDateTimeChange={setSelectedDateTime}
|
|
141
|
+
slotProps={{ textField: { size: 'small' } }}
|
|
142
|
+
/>
|
|
143
|
+
<Typography sx={{ mt: 2 }}>
|
|
144
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
145
|
+
</Typography>
|
|
146
|
+
</Box>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
export const DateTimePickerWithButtonsDefinition = `
|
|
152
|
+
import React, { useState } => from 'react';
|
|
153
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
154
|
+
import dayjs from 'dayjs';
|
|
155
|
+
import { Box, Typography } from '@mui/material';
|
|
156
|
+
|
|
157
|
+
export const DateTimePickerWithButtonsExample = () => {
|
|
158
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
159
|
+
return (
|
|
160
|
+
<Box sx={{ width: 300 }}>
|
|
161
|
+
<DateTimePicker
|
|
162
|
+
label="Fecha y Hora (Con Botones por Defecto)"
|
|
163
|
+
selectedDateTime={selectedDateTime}
|
|
164
|
+
onDateTimeChange={setSelectedDateTime}
|
|
165
|
+
slotProps={{
|
|
166
|
+
actionBar: {
|
|
167
|
+
actions: ['clear', 'cancel', 'accept'],
|
|
168
|
+
},
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
<Typography sx={{ mt: 2 }}>
|
|
172
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
173
|
+
</Typography>
|
|
174
|
+
</Box>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
export const DateTimePickerWithCustomButtonTextDefinition = `
|
|
180
|
+
import React, { useState } from 'react';
|
|
181
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
182
|
+
import dayjs from 'dayjs';
|
|
183
|
+
import { Box, Typography } from '@mui/material';
|
|
184
|
+
|
|
185
|
+
export const DateTimePickerWithCustomButtonTextExample = () => {
|
|
186
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
187
|
+
return (
|
|
188
|
+
<Box sx={{ width: 300 }}>
|
|
189
|
+
<DateTimePicker
|
|
190
|
+
label="Fecha y Hora (Botones Personalizados)"
|
|
191
|
+
selectedDateTime={selectedDateTime}
|
|
192
|
+
onDateTimeChange={setSelectedDateTime}
|
|
193
|
+
clearButtonText="Limpiar Todo"
|
|
194
|
+
cancelButtonText="Descartar"
|
|
195
|
+
acceptButtonText="Confirmar Selección"
|
|
196
|
+
slotProps={{
|
|
197
|
+
actionBar: {
|
|
198
|
+
actions: ['clear', 'cancel', 'accept'],
|
|
199
|
+
},
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
202
|
+
<Typography sx={{ mt: 2 }}>
|
|
203
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
204
|
+
</Typography>
|
|
205
|
+
</Box>
|
|
206
|
+
);
|
|
207
|
+
};
|
|
208
|
+
`;
|
|
209
|
+
|
|
210
|
+
export const DateTimePickerEmptyWithMaskDefinition = `
|
|
211
|
+
import React, { useState } from 'react';
|
|
212
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
213
|
+
import { Dayjs } from 'dayjs';
|
|
214
|
+
import { Box, Typography } from '@mui/material';
|
|
215
|
+
|
|
216
|
+
export const DateTimePickerEmptyWithMaskExample = () => {
|
|
217
|
+
const [selectedDateTime, setSelectedDateTime] = useState<Dayjs | null>(null);
|
|
218
|
+
return (
|
|
219
|
+
<Box sx={{ width: 300 }}>
|
|
220
|
+
<DateTimePicker
|
|
221
|
+
label="Fecha y Hora"
|
|
222
|
+
selectedDateTime={selectedDateTime}
|
|
223
|
+
onDateTimeChange={setSelectedDateTime}
|
|
224
|
+
inputFormat="DD/MM/YY HH:mm"
|
|
225
|
+
/>
|
|
226
|
+
<Typography sx={{ mt: 2 }} variant="caption" color="text.secondary">
|
|
227
|
+
Al estar vacío, el campo muestra la máscara del formato (DD/MM/AA HH:MM).
|
|
228
|
+
</Typography>
|
|
229
|
+
</Box>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
`;
|
|
233
|
+
|
|
234
|
+
export const DateTimePickerWithCustomInputFormatDefinition = `
|
|
235
|
+
import React, { useState } from 'react';
|
|
236
|
+
import { DateTimePicker } from './DateTimePicker'; // Ajusta la ruta si es necesario
|
|
237
|
+
import dayjs from 'dayjs';
|
|
238
|
+
import { Box, Typography } from '@mui/material';
|
|
239
|
+
|
|
240
|
+
export const DateTimePickerWithCustomInputFormatExample = () => {
|
|
241
|
+
const [selectedDateTime, setSelectedDateTime] = useState(dayjs());
|
|
242
|
+
return (
|
|
243
|
+
<Box sx={{ width: 300 }}>
|
|
244
|
+
<DateTimePicker
|
|
245
|
+
label="Fecha y Hora (Formato dd/MM/YYYY)"
|
|
246
|
+
selectedDateTime={selectedDateTime}
|
|
247
|
+
onDateTimeChange={setSelectedDateTime}
|
|
248
|
+
inputFormat="DD/MM/YYYY HH:mm" // Formato de fecha personalizado
|
|
249
|
+
/>
|
|
250
|
+
<Typography sx={{ mt: 2 }}>
|
|
251
|
+
Seleccionado: \${selectedDateTime ? selectedDateTime.format('YYYY-MM-DD HH:mm') : 'Ninguna'}
|
|
252
|
+
</Typography>
|
|
253
|
+
</Box>
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DateValidationError } from '@mui/x-date-pickers/models';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Traduce el error del DateTimePicker a un mensaje en español. Se usa
|
|
5
|
+
* internamente para poblar `helperText` cuando hay error de validación.
|
|
6
|
+
*/
|
|
7
|
+
export const getDateTimeValidationMessage = (
|
|
8
|
+
error: DateValidationError | null,
|
|
9
|
+
): string => {
|
|
10
|
+
switch (error) {
|
|
11
|
+
case 'minDate':
|
|
12
|
+
case 'maxDate':
|
|
13
|
+
case 'invalidDate':
|
|
14
|
+
return 'Formato de fecha/hora inválido';
|
|
15
|
+
case 'disableFuture':
|
|
16
|
+
return 'No se permiten fechas/horas futuras';
|
|
17
|
+
case 'disablePast':
|
|
18
|
+
return 'No se permiten fechas/horas pasadas';
|
|
19
|
+
default:
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Construye el `localeText` que MUI acepta para overridear los labels de los
|
|
26
|
+
* botones del popover (Cancel / OK / Clear).
|
|
27
|
+
*/
|
|
28
|
+
export const buildLocaleText = (
|
|
29
|
+
clearButtonText?: string,
|
|
30
|
+
cancelButtonText?: string,
|
|
31
|
+
acceptButtonText?: string,
|
|
32
|
+
): Record<string, string> => {
|
|
33
|
+
const text: Record<string, string> = {};
|
|
34
|
+
if (clearButtonText) text.clearButtonLabel = clearButtonText;
|
|
35
|
+
if (cancelButtonText) text.cancelButtonLabel = cancelButtonText;
|
|
36
|
+
if (acceptButtonText) text.okButtonLabel = acceptButtonText;
|
|
37
|
+
return text;
|
|
38
|
+
};
|