@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,197 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { MenuButton, MenuOption } from './MenuButton';
3
+ import AccountCircleIcon from '@mui/icons-material/AccountCircle';
4
+ import SettingsIcon from '@mui/icons-material/Settings';
5
+ import LogoutIcon from '@mui/icons-material/Logout';
6
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
7
+ import PersonIcon from '@mui/icons-material/Person';
8
+ import VpnKeyIcon from '@mui/icons-material/VpnKey';
9
+ import NotificationsIcon from '@mui/icons-material/Notifications';
10
+ import WarningIcon from '@mui/icons-material/Warning'; // Asegúrate de importar este ícono si lo usas
11
+ import { fn } from '@storybook/test';
12
+
13
+ const meta: Meta<typeof MenuButton> = {
14
+ title: 'Components/MenuButton',
15
+ component: MenuButton,
16
+ tags: ['autodocs'],
17
+ argTypes: {
18
+ buttonText: {
19
+ control: 'text',
20
+ description: 'Texto a mostrar en el botón.',
21
+ },
22
+ buttonIcon: {
23
+ control: false,
24
+ description: 'Ícono a mostrar en el botón.',
25
+ },
26
+ options: {
27
+ control: 'object',
28
+ description: 'Arreglo de opciones del menú, cada una con `label`, `action` y opcionalmente `icon`.',
29
+ },
30
+ variant: {
31
+ control: 'select',
32
+ options: ['text', 'outlined', 'contained'],
33
+ description: 'Variante de estilo del botón de Material-UI.',
34
+ },
35
+ },
36
+ parameters: {
37
+ docs: {
38
+ description: {
39
+ component: 'Un botón que despliega un menú de opciones. El ancho del menú se ajusta automáticamente al ancho del botón. Cada ítem del menú puede incluir un ícono.',
40
+ },
41
+ },
42
+ },
43
+ };
44
+
45
+ export default meta;
46
+ type Story = StoryObj<typeof MenuButton>;
47
+
48
+ // --- Historias ---
49
+
50
+ // Historia por defecto: Botón con texto y menú básico con íconos en los ítems
51
+ export const Default: Story = {
52
+ args: {
53
+ buttonText: 'Opciones de Usuario',
54
+ options: [
55
+ { label: 'Ver Perfil', action: fn(), icon: <PersonIcon /> },
56
+ { label: 'Cambiar Contraseña', action: fn()},
57
+ { label: 'Cerrar Sesión', action: fn(), icon: <LogoutIcon /> },
58
+ ],
59
+ variant: 'contained',
60
+ },
61
+ parameters: {
62
+ docs: {
63
+ description: {
64
+ story: 'Muestra un botón con texto y un menú con ítems que incluyen íconos.',
65
+ },
66
+ },
67
+ },
68
+ };
69
+
70
+ // Historia: Botón con solo un ícono, menú con íconos
71
+ export const IconButton: Story = {
72
+ args: {
73
+ buttonIcon: <AccountCircleIcon />,
74
+ options: [
75
+ { label: 'Mi Perfil', action: fn(), icon: <PersonIcon /> },
76
+ { label: 'Ajustes de Cuenta', action: fn(), icon: <SettingsIcon /> },
77
+ ],
78
+ variant: 'text',
79
+ },
80
+ parameters: {
81
+ docs: {
82
+ description: {
83
+ story: 'Muestra un botón que solo contiene un ícono, con un menú de opciones también con íconos.',
84
+ },
85
+ },
86
+ },
87
+ };
88
+
89
+ // Historia: Botón con texto e ícono, menú con íconos
90
+ export const TextAndIconButton: Story = {
91
+ args: {
92
+ buttonText: 'Configuración',
93
+ buttonIcon: <SettingsIcon />,
94
+ options: [
95
+ { label: 'General', action: fn(), icon: <SettingsIcon /> },
96
+ { label: 'Privacidad', action: fn(), icon: <VpnKeyIcon /> },
97
+ { label: 'Notificaciones', action: fn(), icon: <NotificationsIcon /> },
98
+ ],
99
+ variant: 'outlined',
100
+ },
101
+ parameters: {
102
+ docs: {
103
+ description: {
104
+ story: 'Muestra un botón con texto e ícono, y un menú con ítems que también tienen íconos.',
105
+ },
106
+ },
107
+ },
108
+ };
109
+
110
+ // Historia: Botón con un menú largo (para probar el scroll y el ancho dinámico)
111
+ export const LongMenu: Story = {
112
+ args: {
113
+ buttonText: 'Más Opciones de Gestión de Datos',
114
+ buttonIcon: <MoreVertIcon />,
115
+ options: Array.from({ length: 15 }, (_, i) => ({
116
+ label: `Opción de Datos ${i + 1}`,
117
+ action: fn(),
118
+ icon: i % 3 === 0 ? <PersonIcon /> : i % 3 === 1 ? <SettingsIcon /> : <LogoutIcon />,
119
+ })),
120
+ variant: 'contained',
121
+ },
122
+ parameters: {
123
+ docs: {
124
+ description: {
125
+ story: 'Demuestra un menú con muchas opciones para probar el scroll y cómo el ancho del menú se ajusta al botón, incluso si el texto del ítem es más corto.',
126
+ },
127
+ },
128
+ },
129
+ };
130
+
131
+ // Historia: Botón con acciones de ejemplo (usando alert para demostrar)
132
+ export const WithAlertActions: Story = {
133
+ args: {
134
+ buttonText: 'Acciones con Alerta',
135
+ options: [
136
+ { label: 'Mostrar Alerta Crítica', action: () => alert('¡Alerta Crítica!'), icon: <WarningIcon /> },
137
+ { label: 'Mostrar Alerta Informativa', action: () => alert('¡Alerta Informativa!'), icon: <NotificationsIcon /> },
138
+ ],
139
+ variant: 'contained',
140
+ },
141
+ parameters: {
142
+ docs: {
143
+ description: {
144
+ story: 'Muestra un botón con ítems de menú que ejecutan funciones de alerta al ser clickeados.',
145
+ },
146
+ },
147
+ },
148
+ };
149
+
150
+ // Historia: Diferentes variantes de botón (con íconos en el menú)
151
+ export const Variants: Story = {
152
+ render: () => (
153
+ <div style={{ display: 'flex', gap: '20px' }}>
154
+ <MenuButton
155
+ buttonText="Contained"
156
+ options={[{ label: 'Item Contenido', action: fn(), icon: <PersonIcon /> }]}
157
+ variant="contained"
158
+ />
159
+ <MenuButton
160
+ buttonText="Outlined"
161
+ options={[{ label: 'Item Delineado', action: fn(), icon: <SettingsIcon /> }]}
162
+ variant="outlined"
163
+ />
164
+ <MenuButton
165
+ buttonText="Text"
166
+ options={[{ label: 'Item de Texto', action: fn(), icon: <LogoutIcon /> }]}
167
+ variant="text"
168
+ />
169
+ </div>
170
+ ),
171
+ parameters: {
172
+ docs: {
173
+ description: {
174
+ story: 'Muestra el componente con diferentes variantes de botón de Material-UI.',
175
+ },
176
+ },
177
+ },
178
+ };
179
+
180
+ // Historia: Botón con texto largo para probar el ajuste de ancho
181
+ export const WideButton: Story = {
182
+ args: {
183
+ buttonText: 'Este es un botón con un texto muy largo para probar el ancho del menú',
184
+ options: [
185
+ { label: 'Opción corta', action: fn(), icon: <PersonIcon /> },
186
+ { label: 'Opción con texto más largo para el ítem', action: fn(), icon: <SettingsIcon /> },
187
+ ],
188
+ variant: 'contained',
189
+ },
190
+ parameters: {
191
+ docs: {
192
+ description: {
193
+ story: 'Demuestra cómo el menú ajusta su ancho para coincidir con un botón que tiene un texto considerablemente largo.',
194
+ },
195
+ },
196
+ },
197
+ };
@@ -0,0 +1,100 @@
1
+ import React, { useState, MouseEvent, ReactNode, useId, useRef } from 'react'; // 👈 Importa useRef
2
+ import { Button, Menu, MenuItem, ListItemIcon, Typography } from '@mui/material';
3
+ import { ButtonProps } from '@mui/material/Button';
4
+
5
+ // Define la interfaz para cada opción del menú
6
+ export interface MenuOption {
7
+ label: string;
8
+ action: () => void;
9
+ icon?: ReactNode;
10
+ }
11
+
12
+ // Define las props para el componente reutilizable
13
+ interface MenuButtonProps {
14
+ buttonText?: string;
15
+ buttonIcon?: ReactNode;
16
+ options: MenuOption[];
17
+ variant?: ButtonProps['variant'];
18
+ }
19
+
20
+ export const MenuButton: React.FC<MenuButtonProps> = ({
21
+ buttonText,
22
+ buttonIcon,
23
+ options,
24
+ variant = 'contained',
25
+ }) => {
26
+ const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
27
+ const [menuWidth, setMenuWidth] = useState<number>(0);
28
+ const open = Boolean(anchorEl);
29
+
30
+ const buttonRef = useRef<HTMLButtonElement>(null);
31
+
32
+ const uniqueId = useId();
33
+ const buttonId = `menu-button-${uniqueId}`;
34
+ const menuId = `menu-content-${uniqueId}`;
35
+
36
+ const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
37
+ setAnchorEl(event.currentTarget);
38
+ if (buttonRef.current) {
39
+ setMenuWidth(buttonRef.current.offsetWidth);
40
+ }
41
+ };
42
+
43
+ const handleClose = () => {
44
+ setAnchorEl(null);
45
+ };
46
+
47
+ const handleMenuItemClick = (action: () => void) => {
48
+ handleClose();
49
+ action();
50
+ };
51
+
52
+ return (
53
+ <>
54
+ <Button
55
+ ref={buttonRef}
56
+ variant={variant}
57
+ id={buttonId}
58
+ aria-controls={open ? menuId : undefined}
59
+ aria-haspopup="true"
60
+ aria-expanded={open ? 'true' : undefined}
61
+ onClick={handleClick}
62
+ startIcon={buttonIcon}
63
+ >
64
+ {buttonText}
65
+ </Button>
66
+ <Menu
67
+ id={menuId}
68
+ anchorEl={anchorEl}
69
+ open={open}
70
+ onClose={handleClose}
71
+ MenuListProps={{
72
+ 'aria-labelledby': buttonId,
73
+ }}
74
+ PaperProps={{
75
+ style: {
76
+ minWidth: menuWidth,
77
+ },
78
+ }}
79
+ >
80
+ {options.map((option, index) => (
81
+ <MenuItem
82
+ key={index}
83
+ onClick={() => handleMenuItemClick(option.action)}
84
+ >
85
+ {option.icon && (
86
+ <ListItemIcon>
87
+ {option.icon}
88
+ </ListItemIcon>
89
+ )}
90
+ <Typography variant="inherit" noWrap>
91
+ {option.label}
92
+ </Typography>
93
+ </MenuItem>
94
+ ))}
95
+ </Menu>
96
+ </>
97
+ );
98
+ };
99
+
100
+ export default MenuButton;
@@ -0,0 +1 @@
1
+ export { default as MenuButton } from './MenuButton'