@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.
Files changed (187) hide show
  1. package/.dockerignore +8 -0
  2. package/.github/workflows/publish.yml +107 -0
  3. package/.prettierrc +3 -0
  4. package/.storybook/main.ts +19 -0
  5. package/.storybook/preview.ts +14 -0
  6. package/.storybook/vitest.setup.ts +9 -0
  7. package/Dockerfile +37 -0
  8. package/build.js +102 -0
  9. package/chromatic.config.json +5 -0
  10. package/cleanDirectories.js +40 -0
  11. package/dist/README.md +243 -0
  12. package/dist/components/Icon/Icon.js +1 -1
  13. package/dist/components/Table/Table.js +1 -1
  14. package/dist/index.cjs +24 -0
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +7 -1
  17. package/dist/mui.d.ts +1 -0
  18. package/dist/package.json +197 -0
  19. package/package.json +4 -32
  20. package/rollup.config.cjs +87 -0
  21. package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
  22. package/src/components/ActionMenu/ActionMenu.tsx +174 -0
  23. package/src/components/ActionMenu/index.ts +2 -0
  24. package/src/components/AppBar/AppBar.stories.tsx +272 -0
  25. package/src/components/AppBar/AppBar.sx.ts +32 -0
  26. package/src/components/AppBar/AppBar.tsx +123 -0
  27. package/src/components/AppBar/AppBarBrand.tsx +120 -0
  28. package/src/components/AppBar/AppBarContext.ts +25 -0
  29. package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
  30. package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
  31. package/src/components/AppBar/index.ts +25 -0
  32. package/src/components/Autocomplete/Autocomplete.definitions.ts +477 -0
  33. package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
  34. package/src/components/Autocomplete/Autocomplete.stories.tsx +748 -0
  35. package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
  36. package/src/components/Autocomplete/Autocomplete.tsx +361 -0
  37. package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
  38. package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
  39. package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
  40. package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
  41. package/src/components/Autocomplete/index.ts +12 -0
  42. package/src/components/Avatar/Avatar.definitions.ts +162 -0
  43. package/src/components/Avatar/Avatar.stories.tsx +258 -0
  44. package/src/components/Avatar/Avatar.tsx +206 -0
  45. package/src/components/Avatar/index.ts +1 -0
  46. package/src/components/Button/Button.definition.ts +97 -0
  47. package/src/components/Button/Button.stories.tsx +285 -0
  48. package/src/components/Button/Button.tsx +67 -0
  49. package/src/components/Button/index.ts +1 -0
  50. package/src/components/Card/Card.definition.ts +5 -0
  51. package/src/components/Card/Card.stories.tsx +221 -0
  52. package/src/components/Card/Card.sx.ts +104 -0
  53. package/src/components/Card/Card.tsx +200 -0
  54. package/src/components/Card/index.ts +9 -0
  55. package/src/components/Chip/Chip.definitions.ts +167 -0
  56. package/src/components/Chip/Chip.stories.tsx +265 -0
  57. package/src/components/Chip/Chip.tsx +61 -0
  58. package/src/components/Chip/index.ts +1 -0
  59. package/src/components/Column/Column.tsx +29 -0
  60. package/src/components/Column/index.ts +1 -0
  61. package/src/components/DatePicker/DatePicker.definitions.ts +228 -0
  62. package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
  63. package/src/components/DatePicker/DatePicker.stories.tsx +309 -0
  64. package/src/components/DatePicker/DatePicker.sx.ts +33 -0
  65. package/src/components/DatePicker/DatePicker.tsx +189 -0
  66. package/src/components/DatePicker/DatePicker.types.ts +10 -0
  67. package/src/components/DatePicker/index.ts +9 -0
  68. package/src/components/DateRangePicker/DateRangePicker.definitions.ts +191 -0
  69. package/src/components/DateRangePicker/DateRangePicker.stories.tsx +252 -0
  70. package/src/components/DateRangePicker/DateRangePicker.tsx +56 -0
  71. package/src/components/DateRangePicker/index.ts +1 -0
  72. package/src/components/DateTimePicker/DateTimePicker.definitions.ts +256 -0
  73. package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
  74. package/src/components/DateTimePicker/DateTimePicker.stories.tsx +418 -0
  75. package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
  76. package/src/components/DateTimePicker/DateTimePicker.tsx +225 -0
  77. package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
  78. package/src/components/DateTimePicker/index.ts +9 -0
  79. package/src/components/Drawer/Drawer.stories.tsx +270 -0
  80. package/src/components/Drawer/Drawer.sx.ts +106 -0
  81. package/src/components/Drawer/Drawer.tsx +214 -0
  82. package/src/components/Drawer/DrawerContext.ts +26 -0
  83. package/src/components/Drawer/DrawerItem.tsx +110 -0
  84. package/src/components/Drawer/index.ts +10 -0
  85. package/src/components/Flyout/Flyout.stories.tsx +282 -0
  86. package/src/components/Flyout/Flyout.tsx +122 -0
  87. package/src/components/Flyout/index.ts +1 -0
  88. package/src/components/Gallery/Gallery.definition.tsx +37 -0
  89. package/src/components/Gallery/Gallery.stories.tsx +82 -0
  90. package/src/components/Gallery/Gallery.tsx +118 -0
  91. package/src/components/Gallery/GalleryLightbox.tsx +170 -0
  92. package/src/components/Gallery/GalleryMain.tsx +84 -0
  93. package/src/components/Gallery/GalleryThumbnails.tsx +106 -0
  94. package/src/components/Gallery/index.ts +1 -0
  95. package/src/components/Icon/Icon.stories.tsx +121 -0
  96. package/src/components/Icon/Icon.tsx +175 -0
  97. package/src/components/Icon/index.ts +2 -0
  98. package/src/components/Input/Input.definitions.ts +324 -0
  99. package/src/components/Input/Input.helpers.ts +49 -0
  100. package/src/components/Input/Input.stories.tsx +499 -0
  101. package/src/components/Input/Input.sx.ts +42 -0
  102. package/src/components/Input/Input.tsx +141 -0
  103. package/src/components/Input/Input.types.ts +10 -0
  104. package/src/components/Input/index.ts +9 -0
  105. package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
  106. package/src/components/InputGroup/InputGroup.stories.tsx +267 -0
  107. package/src/components/InputGroup/InputGroup.tsx +179 -0
  108. package/src/components/InputGroup/index.ts +1 -0
  109. package/src/components/MenuButton/MenuButton.stories.tsx +197 -0
  110. package/src/components/MenuButton/MenuButton.tsx +100 -0
  111. package/src/components/MenuButton/index.ts +1 -0
  112. package/src/components/Modal/Modal.stories.tsx +721 -0
  113. package/src/components/Modal/Modal.tsx +355 -0
  114. package/src/components/Modal/ModalBody.tsx +16 -0
  115. package/src/components/Modal/ModalFooter.tsx +71 -0
  116. package/src/components/Modal/ModalHeader.tsx +18 -0
  117. package/src/components/Modal/index.ts +6 -0
  118. package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
  119. package/src/components/PageLoader/PageLoader.tsx +96 -0
  120. package/src/components/PageLoader/index.ts +2 -0
  121. package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
  122. package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
  123. package/src/components/ScrollTopButton/index.ts +8 -0
  124. package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
  125. package/src/components/Select/Select.definitions.ts +602 -0
  126. package/src/components/Select/Select.helpers.ts +71 -0
  127. package/src/components/Select/Select.stories.tsx +687 -0
  128. package/src/components/Select/Select.sx.ts +14 -0
  129. package/src/components/Select/Select.tsx +429 -0
  130. package/src/components/Select/Select.types.ts +15 -0
  131. package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
  132. package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
  133. package/src/components/Select/_parts/SelectValue.tsx +96 -0
  134. package/src/components/Select/index.ts +14 -0
  135. package/src/components/Stat/Stat.stories.tsx +85 -0
  136. package/src/components/Stat/Stat.tsx +117 -0
  137. package/src/components/Stat/index.ts +2 -0
  138. package/src/components/StatusMessage/StatusMessage.stories.tsx +130 -0
  139. package/src/components/StatusMessage/StatusMessage.tsx +162 -0
  140. package/src/components/StatusMessage/index.ts +2 -0
  141. package/src/components/Stepper/Step.tsx +21 -0
  142. package/src/components/Stepper/Stepper.definition.ts +75 -0
  143. package/src/components/Stepper/Stepper.stories.tsx +122 -0
  144. package/src/components/Stepper/Stepper.tsx +75 -0
  145. package/src/components/Stepper/index.ts +2 -0
  146. package/src/components/Table/EmptyTable.png +0 -0
  147. package/src/components/Table/Table.definition.ts +580 -0
  148. package/src/components/Table/Table.stories.tsx +853 -0
  149. package/src/components/Table/Table.tsx +495 -0
  150. package/src/components/Table/data.ts +134 -0
  151. package/src/components/Table/exportsUtils.ts +195 -0
  152. package/src/components/Table/index.ts +3 -0
  153. package/src/components/Table/types.ts +34 -0
  154. package/src/components/Tabs/Tab.definition.ts +53 -0
  155. package/src/components/Tabs/Tab.tsx +19 -0
  156. package/src/components/Tabs/Tabs.stories.tsx +118 -0
  157. package/src/components/Tabs/Tabs.tsx +99 -0
  158. package/src/components/Tabs/_tabUtils.tsx +4 -0
  159. package/src/components/Tabs/index.ts +2 -0
  160. package/src/components/Timeline/Timeline.definition.ts +43 -0
  161. package/src/components/Timeline/Timeline.stories.tsx +108 -0
  162. package/src/components/Timeline/Timeline.tsx +49 -0
  163. package/src/components/Timeline/TimelineItem.tsx +31 -0
  164. package/src/components/Timeline/index.ts +2 -0
  165. package/src/components/Tooltip/Tooltip.stories.tsx +129 -0
  166. package/src/components/Tooltip/Tooltip.tsx +58 -0
  167. package/src/components/Tooltip/index.ts +1 -0
  168. package/src/components/_shared/formField.sx.ts +118 -0
  169. package/src/components/_shared/resolvePreset.ts +35 -0
  170. package/src/hooks/ClipBoard/ClipBoard.stories.tsx +168 -0
  171. package/src/hooks/ClipBoard/ClipBoard.tsx +131 -0
  172. package/src/hooks/ClipBoard/ClipboardUnifiedDemo.tsx +111 -0
  173. package/src/hooks/ClipBoard/index.ts +1 -0
  174. package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
  175. package/src/hooks/Wizard/WizardContext.tsx +166 -0
  176. package/src/hooks/Wizard/index.ts +6 -0
  177. package/src/hooks/Wizard/useWizard.ts +13 -0
  178. package/src/index.ts +17 -0
  179. package/src/mui.ts +54 -0
  180. package/src/styles.css +3 -0
  181. package/src/theme/componentStyles.ts +47 -0
  182. package/src/theme/tokens.ts +43 -0
  183. package/tailwind.config.js +10 -0
  184. package/tsconfig.json +48 -0
  185. package/tsup.config.js +41 -0
  186. package/vite.config.js +132 -0
  187. 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
+ };