@soyfri/shared-library 2.0.0-beta.0 → 2.0.0-beta.2

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 (181) hide show
  1. package/dist/components/Icon/Icon.js +1 -1
  2. package/dist/components/Table/Table.js +1 -1
  3. package/package.json +32 -4
  4. package/.dockerignore +0 -8
  5. package/.github/workflows/publish.yml +0 -107
  6. package/.prettierrc +0 -3
  7. package/.storybook/main.ts +0 -19
  8. package/.storybook/preview.ts +0 -14
  9. package/.storybook/vitest.setup.ts +0 -9
  10. package/Dockerfile +0 -37
  11. package/build.js +0 -102
  12. package/chromatic.config.json +0 -5
  13. package/cleanDirectories.js +0 -40
  14. package/rollup.config.cjs +0 -87
  15. package/src/components/ActionMenu/ActionMenu.stories.tsx +0 -230
  16. package/src/components/ActionMenu/ActionMenu.tsx +0 -174
  17. package/src/components/ActionMenu/index.ts +0 -2
  18. package/src/components/AppBar/AppBar.stories.tsx +0 -272
  19. package/src/components/AppBar/AppBar.sx.ts +0 -32
  20. package/src/components/AppBar/AppBar.tsx +0 -123
  21. package/src/components/AppBar/AppBarBrand.tsx +0 -120
  22. package/src/components/AppBar/AppBarContext.ts +0 -25
  23. package/src/components/AppBar/AppBarMenuToggle.tsx +0 -90
  24. package/src/components/AppBar/AppBarUserMenu.tsx +0 -217
  25. package/src/components/AppBar/index.ts +0 -25
  26. package/src/components/Autocomplete/Autocomplete.definitions.ts +0 -477
  27. package/src/components/Autocomplete/Autocomplete.helpers.ts +0 -60
  28. package/src/components/Autocomplete/Autocomplete.stories.tsx +0 -748
  29. package/src/components/Autocomplete/Autocomplete.sx.ts +0 -30
  30. package/src/components/Autocomplete/Autocomplete.tsx +0 -361
  31. package/src/components/Autocomplete/Autocomplete.types.ts +0 -13
  32. package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +0 -55
  33. package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +0 -17
  34. package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +0 -31
  35. package/src/components/Autocomplete/index.ts +0 -12
  36. package/src/components/Avatar/Avatar.definitions.ts +0 -162
  37. package/src/components/Avatar/Avatar.stories.tsx +0 -258
  38. package/src/components/Avatar/Avatar.tsx +0 -206
  39. package/src/components/Avatar/index.ts +0 -1
  40. package/src/components/Button/Button.definition.ts +0 -97
  41. package/src/components/Button/Button.stories.tsx +0 -285
  42. package/src/components/Button/Button.tsx +0 -67
  43. package/src/components/Button/index.ts +0 -1
  44. package/src/components/Card/Card.definition.ts +0 -5
  45. package/src/components/Card/Card.stories.tsx +0 -221
  46. package/src/components/Card/Card.sx.ts +0 -104
  47. package/src/components/Card/Card.tsx +0 -200
  48. package/src/components/Card/index.ts +0 -9
  49. package/src/components/Chip/Chip.definitions.ts +0 -167
  50. package/src/components/Chip/Chip.stories.tsx +0 -265
  51. package/src/components/Chip/Chip.tsx +0 -61
  52. package/src/components/Chip/index.ts +0 -1
  53. package/src/components/Column/Column.tsx +0 -29
  54. package/src/components/Column/index.ts +0 -1
  55. package/src/components/DatePicker/DatePicker.definitions.ts +0 -228
  56. package/src/components/DatePicker/DatePicker.helpers.ts +0 -24
  57. package/src/components/DatePicker/DatePicker.stories.tsx +0 -309
  58. package/src/components/DatePicker/DatePicker.sx.ts +0 -33
  59. package/src/components/DatePicker/DatePicker.tsx +0 -189
  60. package/src/components/DatePicker/DatePicker.types.ts +0 -10
  61. package/src/components/DatePicker/index.ts +0 -9
  62. package/src/components/DateRangePicker/DateRangePicker.definitions.ts +0 -191
  63. package/src/components/DateRangePicker/DateRangePicker.stories.tsx +0 -252
  64. package/src/components/DateRangePicker/DateRangePicker.tsx +0 -56
  65. package/src/components/DateRangePicker/index.ts +0 -1
  66. package/src/components/DateTimePicker/DateTimePicker.definitions.ts +0 -256
  67. package/src/components/DateTimePicker/DateTimePicker.helpers.ts +0 -38
  68. package/src/components/DateTimePicker/DateTimePicker.stories.tsx +0 -418
  69. package/src/components/DateTimePicker/DateTimePicker.sx.ts +0 -30
  70. package/src/components/DateTimePicker/DateTimePicker.tsx +0 -225
  71. package/src/components/DateTimePicker/DateTimePicker.types.ts +0 -10
  72. package/src/components/DateTimePicker/index.ts +0 -9
  73. package/src/components/Drawer/Drawer.stories.tsx +0 -270
  74. package/src/components/Drawer/Drawer.sx.ts +0 -106
  75. package/src/components/Drawer/Drawer.tsx +0 -214
  76. package/src/components/Drawer/DrawerContext.ts +0 -26
  77. package/src/components/Drawer/DrawerItem.tsx +0 -110
  78. package/src/components/Drawer/index.ts +0 -10
  79. package/src/components/Flyout/Flyout.stories.tsx +0 -282
  80. package/src/components/Flyout/Flyout.tsx +0 -122
  81. package/src/components/Flyout/index.ts +0 -1
  82. package/src/components/Gallery/Gallery.definition.tsx +0 -37
  83. package/src/components/Gallery/Gallery.stories.tsx +0 -82
  84. package/src/components/Gallery/Gallery.tsx +0 -118
  85. package/src/components/Gallery/GalleryLightbox.tsx +0 -170
  86. package/src/components/Gallery/GalleryMain.tsx +0 -84
  87. package/src/components/Gallery/GalleryThumbnails.tsx +0 -106
  88. package/src/components/Gallery/index.ts +0 -1
  89. package/src/components/Icon/Icon.stories.tsx +0 -121
  90. package/src/components/Icon/Icon.tsx +0 -175
  91. package/src/components/Icon/index.ts +0 -2
  92. package/src/components/Input/Input.definitions.ts +0 -324
  93. package/src/components/Input/Input.helpers.ts +0 -49
  94. package/src/components/Input/Input.stories.tsx +0 -499
  95. package/src/components/Input/Input.sx.ts +0 -42
  96. package/src/components/Input/Input.tsx +0 -141
  97. package/src/components/Input/Input.types.ts +0 -10
  98. package/src/components/Input/index.ts +0 -9
  99. package/src/components/InputGroup/InputGroup.definitions.ts +0 -158
  100. package/src/components/InputGroup/InputGroup.stories.tsx +0 -267
  101. package/src/components/InputGroup/InputGroup.tsx +0 -179
  102. package/src/components/InputGroup/index.ts +0 -1
  103. package/src/components/MenuButton/MenuButton.stories.tsx +0 -197
  104. package/src/components/MenuButton/MenuButton.tsx +0 -100
  105. package/src/components/MenuButton/index.ts +0 -1
  106. package/src/components/Modal/Modal.stories.tsx +0 -721
  107. package/src/components/Modal/Modal.tsx +0 -355
  108. package/src/components/Modal/ModalBody.tsx +0 -16
  109. package/src/components/Modal/ModalFooter.tsx +0 -71
  110. package/src/components/Modal/ModalHeader.tsx +0 -18
  111. package/src/components/Modal/index.ts +0 -6
  112. package/src/components/PageLoader/PageLoader.stories.tsx +0 -217
  113. package/src/components/PageLoader/PageLoader.tsx +0 -96
  114. package/src/components/PageLoader/index.ts +0 -2
  115. package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +0 -158
  116. package/src/components/ScrollTopButton/ScrollTopButton.tsx +0 -135
  117. package/src/components/ScrollTopButton/index.ts +0 -8
  118. package/src/components/ScrollTopButton/scrollToTop.ts +0 -37
  119. package/src/components/Select/Select.definitions.ts +0 -602
  120. package/src/components/Select/Select.helpers.ts +0 -71
  121. package/src/components/Select/Select.stories.tsx +0 -687
  122. package/src/components/Select/Select.sx.ts +0 -14
  123. package/src/components/Select/Select.tsx +0 -429
  124. package/src/components/Select/Select.types.ts +0 -15
  125. package/src/components/Select/_parts/SelectMenuItem.tsx +0 -40
  126. package/src/components/Select/_parts/SelectSearchHeader.tsx +0 -51
  127. package/src/components/Select/_parts/SelectValue.tsx +0 -96
  128. package/src/components/Select/index.ts +0 -14
  129. package/src/components/Stat/Stat.stories.tsx +0 -85
  130. package/src/components/Stat/Stat.tsx +0 -117
  131. package/src/components/Stat/index.ts +0 -2
  132. package/src/components/StatusMessage/StatusMessage.stories.tsx +0 -130
  133. package/src/components/StatusMessage/StatusMessage.tsx +0 -162
  134. package/src/components/StatusMessage/index.ts +0 -2
  135. package/src/components/Stepper/Step.tsx +0 -21
  136. package/src/components/Stepper/Stepper.definition.ts +0 -75
  137. package/src/components/Stepper/Stepper.stories.tsx +0 -122
  138. package/src/components/Stepper/Stepper.tsx +0 -75
  139. package/src/components/Stepper/index.ts +0 -2
  140. package/src/components/Table/EmptyTable.png +0 -0
  141. package/src/components/Table/Table.definition.ts +0 -580
  142. package/src/components/Table/Table.stories.tsx +0 -853
  143. package/src/components/Table/Table.tsx +0 -495
  144. package/src/components/Table/data.ts +0 -134
  145. package/src/components/Table/exportsUtils.ts +0 -195
  146. package/src/components/Table/index.ts +0 -3
  147. package/src/components/Table/types.ts +0 -34
  148. package/src/components/Tabs/Tab.definition.ts +0 -53
  149. package/src/components/Tabs/Tab.tsx +0 -19
  150. package/src/components/Tabs/Tabs.stories.tsx +0 -118
  151. package/src/components/Tabs/Tabs.tsx +0 -99
  152. package/src/components/Tabs/_tabUtils.tsx +0 -4
  153. package/src/components/Tabs/index.ts +0 -2
  154. package/src/components/Timeline/Timeline.definition.ts +0 -43
  155. package/src/components/Timeline/Timeline.stories.tsx +0 -108
  156. package/src/components/Timeline/Timeline.tsx +0 -49
  157. package/src/components/Timeline/TimelineItem.tsx +0 -31
  158. package/src/components/Timeline/index.ts +0 -2
  159. package/src/components/Tooltip/Tooltip.stories.tsx +0 -129
  160. package/src/components/Tooltip/Tooltip.tsx +0 -58
  161. package/src/components/Tooltip/index.ts +0 -1
  162. package/src/components/_shared/formField.sx.ts +0 -118
  163. package/src/components/_shared/resolvePreset.ts +0 -35
  164. package/src/hooks/ClipBoard/ClipBoard.stories.tsx +0 -168
  165. package/src/hooks/ClipBoard/ClipBoard.tsx +0 -131
  166. package/src/hooks/ClipBoard/ClipboardUnifiedDemo.tsx +0 -111
  167. package/src/hooks/ClipBoard/index.ts +0 -1
  168. package/src/hooks/Wizard/Wizard.stories.tsx +0 -301
  169. package/src/hooks/Wizard/WizardContext.tsx +0 -166
  170. package/src/hooks/Wizard/index.ts +0 -6
  171. package/src/hooks/Wizard/useWizard.ts +0 -13
  172. package/src/index.ts +0 -17
  173. package/src/mui.ts +0 -44
  174. package/src/styles.css +0 -3
  175. package/src/theme/componentStyles.ts +0 -47
  176. package/src/theme/tokens.ts +0 -43
  177. package/tailwind.config.js +0 -10
  178. package/tsconfig.json +0 -48
  179. package/tsup.config.js +0 -41
  180. package/vite.config.js +0 -132
  181. package/vitest.config.ts +0 -35
@@ -1,230 +0,0 @@
1
- import React from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
- import { fn } from '@storybook/test';
4
- import {
5
- Box,
6
- Button,
7
- Table,
8
- TableBody,
9
- TableCell,
10
- TableHead,
11
- TableRow,
12
- Paper,
13
- Chip,
14
- } from '@mui/material';
15
- import EditIcon from '@mui/icons-material/Edit';
16
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
17
- import DeleteIcon from '@mui/icons-material/Delete';
18
- import VisibilityIcon from '@mui/icons-material/Visibility';
19
- import DownloadIcon from '@mui/icons-material/Download';
20
- import ShareIcon from '@mui/icons-material/Share';
21
- import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
22
-
23
- import { ActionMenu } from './ActionMenu';
24
-
25
- const meta: Meta<typeof ActionMenu> = {
26
- title: 'Components/ActionMenu',
27
- component: ActionMenu,
28
- tags: ['autodocs'],
29
- parameters: {
30
- docs: {
31
- description: {
32
- component:
33
- 'Menú de acciones compacto pensado para celdas de tabla, cabeceras y cualquier lugar donde hagan falta acciones secundarias detrás de un trigger. Reemplaza los patrones `<Dropdown>` de react-bootstrap.',
34
- },
35
- },
36
- },
37
- };
38
-
39
- export default meta;
40
- type Story = StoryObj<typeof ActionMenu>;
41
-
42
- // ── Stories ──────────────────────────────────────────────────────────────
43
-
44
- export const Default: Story = {
45
- args: {
46
- items: [
47
- { label: 'Editar', icon: <EditIcon fontSize="small" />, onClick: fn() },
48
- { label: 'Duplicar', icon: <ContentCopyIcon fontSize="small" />, onClick: fn() },
49
- { label: 'Ver detalle', icon: <VisibilityIcon fontSize="small" />, onClick: fn() },
50
- ],
51
- },
52
- parameters: {
53
- docs: {
54
- description: {
55
- story:
56
- 'Menú básico con trigger de 3 puntos (icono por defecto). Cada item tiene label + icono + onClick.',
57
- },
58
- },
59
- },
60
- };
61
-
62
- export const WithDangerItem: Story = {
63
- args: {
64
- items: [
65
- { label: 'Editar', icon: <EditIcon fontSize="small" />, onClick: fn() },
66
- { label: 'Duplicar', icon: <ContentCopyIcon fontSize="small" />, onClick: fn() },
67
- {
68
- label: 'Eliminar',
69
- icon: <DeleteIcon fontSize="small" />,
70
- onClick: fn(),
71
- danger: true,
72
- dividerBefore: true,
73
- },
74
- ],
75
- },
76
- parameters: {
77
- docs: {
78
- description: {
79
- story:
80
- 'Item final marcado como `danger` (pintado en rojo) con `dividerBefore: true` para separarlo visualmente del resto. Patrón típico para acciones destructivas.',
81
- },
82
- },
83
- },
84
- };
85
-
86
- export const WithDisabledItems: Story = {
87
- args: {
88
- items: [
89
- { label: 'Editar', icon: <EditIcon fontSize="small" />, onClick: fn() },
90
- {
91
- label: 'Exportar',
92
- icon: <DownloadIcon fontSize="small" />,
93
- onClick: fn(),
94
- disabled: true,
95
- },
96
- {
97
- label: 'Compartir',
98
- icon: <ShareIcon fontSize="small" />,
99
- onClick: fn(),
100
- disabled: true,
101
- },
102
- ],
103
- },
104
- parameters: {
105
- docs: {
106
- description: {
107
- story:
108
- 'Items deshabilitados condicionalmente — útil cuando una acción no aplica al estado actual del row (ej. exportar un recurso que aún no se procesó).',
109
- },
110
- },
111
- },
112
- };
113
-
114
- export const CustomTrigger: Story = {
115
- args: {
116
- items: [
117
- { label: 'Editar', icon: <EditIcon fontSize="small" />, onClick: fn() },
118
- { label: 'Duplicar', icon: <ContentCopyIcon fontSize="small" />, onClick: fn() },
119
- { label: 'Eliminar', icon: <DeleteIcon fontSize="small" />, onClick: fn(), danger: true },
120
- ],
121
- trigger: (
122
- <Button variant="outlined" startIcon={<MoreHorizIcon />}>
123
- Más
124
- </Button>
125
- ),
126
- },
127
- parameters: {
128
- docs: {
129
- description: {
130
- story:
131
- 'El trigger por defecto es un IconButton de 3 puntos, pero podés pasar cualquier nodo (botón, chip, icono custom). El `onClick` del menú se inyecta automáticamente al trigger clonado.',
132
- },
133
- },
134
- },
135
- };
136
-
137
- export const InsideTableCell: Story = {
138
- render: () => {
139
- const rows = [
140
- { id: 1, name: 'Comercio A', status: 'Activo' },
141
- { id: 2, name: 'Comercio B', status: 'Pendiente' },
142
- { id: 3, name: 'Comercio C', status: 'Suspendido' },
143
- ];
144
-
145
- return (
146
- <Paper sx={{ maxWidth: 720 }}>
147
- <Table size="small">
148
- <TableHead>
149
- <TableRow>
150
- <TableCell>ID</TableCell>
151
- <TableCell>Comercio</TableCell>
152
- <TableCell>Estado</TableCell>
153
- <TableCell align="right">Acciones</TableCell>
154
- </TableRow>
155
- </TableHead>
156
- <TableBody>
157
- {rows.map((row) => (
158
- <TableRow key={row.id} hover>
159
- <TableCell>{row.id}</TableCell>
160
- <TableCell>{row.name}</TableCell>
161
- <TableCell>
162
- <Chip
163
- label={row.status}
164
- size="small"
165
- color={
166
- row.status === 'Activo'
167
- ? 'success'
168
- : row.status === 'Pendiente'
169
- ? 'warning'
170
- : 'error'
171
- }
172
- />
173
- </TableCell>
174
- <TableCell align="right">
175
- <ActionMenu
176
- items={[
177
- {
178
- label: 'Ver detalle',
179
- icon: <VisibilityIcon fontSize="small" />,
180
- onClick: fn(() => console.log('Ver', row.id)),
181
- },
182
- {
183
- label: 'Editar',
184
- icon: <EditIcon fontSize="small" />,
185
- onClick: fn(() => console.log('Editar', row.id)),
186
- },
187
- {
188
- label: 'Eliminar',
189
- icon: <DeleteIcon fontSize="small" />,
190
- onClick: fn(() => console.log('Eliminar', row.id)),
191
- danger: true,
192
- dividerBefore: true,
193
- },
194
- ]}
195
- />
196
- </TableCell>
197
- </TableRow>
198
- ))}
199
- </TableBody>
200
- </Table>
201
- </Paper>
202
- );
203
- },
204
- parameters: {
205
- docs: {
206
- description: {
207
- story:
208
- 'Caso de uso principal: un `ActionMenu` por cada fila de una tabla. Reemplaza exactamente el patrón `DropDownActions` + `react-bootstrap Dropdown` usado hoy en Afiliaciones.',
209
- },
210
- },
211
- },
212
- };
213
-
214
- export const DisabledTrigger: Story = {
215
- args: {
216
- disabled: true,
217
- items: [
218
- { label: 'Editar', icon: <EditIcon fontSize="small" />, onClick: fn() },
219
- { label: 'Eliminar', icon: <DeleteIcon fontSize="small" />, onClick: fn(), danger: true },
220
- ],
221
- },
222
- parameters: {
223
- docs: {
224
- description: {
225
- story:
226
- 'Cuando el row o la acción no tiene permisos, se puede deshabilitar el trigger entero pasando `disabled`.',
227
- },
228
- },
229
- },
230
- };
@@ -1,174 +0,0 @@
1
- import React, { useState, type ReactNode, type MouseEvent } from 'react';
2
- import {
3
- IconButton,
4
- Menu,
5
- MenuItem,
6
- ListItemIcon,
7
- ListItemText,
8
- Divider,
9
- Tooltip,
10
- } from '@mui/material';
11
- import MoreVertIcon from '@mui/icons-material/MoreVert';
12
- import type { SxProps, Theme } from '@mui/material/styles';
13
-
14
- export interface ActionMenuItem {
15
- /** Key única para React. Si no se provee, se usa el label. */
16
- key?: string;
17
- /** Texto del item. */
18
- label: ReactNode;
19
- /** Icono opcional a la izquierda. */
20
- icon?: ReactNode;
21
- /** Handler de click. Recibe el evento del MenuItem. */
22
- onClick?: (event: MouseEvent<HTMLLIElement>) => void;
23
- /** Deshabilita el item. */
24
- disabled?: boolean;
25
- /** Marca el item como destructivo (pinta color error). */
26
- danger?: boolean;
27
- /** Inserta un `<Divider />` ANTES de este item. */
28
- dividerBefore?: boolean;
29
- }
30
-
31
- export interface ActionMenuProps {
32
- /** Lista de items del menú. */
33
- items: ActionMenuItem[];
34
- /**
35
- * Elemento trigger. Si no se provee, se renderiza un IconButton con icono
36
- * de tres puntos (MoreVertIcon) — el patrón típico de celda de tabla.
37
- */
38
- trigger?: ReactNode;
39
- /** Texto de tooltip sobre el trigger default. Default: "Acciones". */
40
- triggerTooltip?: string;
41
- /** Anchor origin del menu. Default: { vertical: 'bottom', horizontal: 'right' }. */
42
- anchorOrigin?: {
43
- vertical: 'top' | 'center' | 'bottom';
44
- horizontal: 'left' | 'center' | 'right';
45
- };
46
- /** Transform origin del menu. Default: { vertical: 'top', horizontal: 'right' }. */
47
- transformOrigin?: {
48
- vertical: 'top' | 'center' | 'bottom';
49
- horizontal: 'left' | 'center' | 'right';
50
- };
51
- /** sx del Menu (Paper interno). */
52
- menuSx?: SxProps<Theme>;
53
- /** Deshabilita el trigger entero. */
54
- disabled?: boolean;
55
- className?: string;
56
- }
57
-
58
- /**
59
- * Menú de acciones compacto, pensado para celdas de tabla y cabeceras.
60
- * Reemplaza los patrones `<Dropdown>` de react-bootstrap.
61
- *
62
- * ```tsx
63
- * <ActionMenu
64
- * items={[
65
- * { label: 'Editar', icon: <EditIcon />, onClick: handleEdit },
66
- * { label: 'Duplicar', icon: <CopyIcon />, onClick: handleDup },
67
- * { label: 'Eliminar', icon: <TrashIcon />, onClick: handleDel, danger: true, dividerBefore: true },
68
- * ]}
69
- * />
70
- * ```
71
- */
72
- export function ActionMenu({
73
- items,
74
- trigger,
75
- triggerTooltip = 'Acciones',
76
- anchorOrigin = { vertical: 'bottom', horizontal: 'right' },
77
- transformOrigin = { vertical: 'top', horizontal: 'right' },
78
- menuSx,
79
- disabled = false,
80
- className,
81
- }: ActionMenuProps) {
82
- const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
83
- const open = Boolean(anchorEl);
84
-
85
- const handleOpen = (event: MouseEvent<HTMLElement>) => {
86
- if (disabled) return;
87
- event.stopPropagation();
88
- setAnchorEl(event.currentTarget);
89
- };
90
-
91
- const handleClose = () => setAnchorEl(null);
92
-
93
- const handleItemClick = (
94
- event: MouseEvent<HTMLLIElement>,
95
- item: ActionMenuItem,
96
- ) => {
97
- event.stopPropagation();
98
- item.onClick?.(event);
99
- handleClose();
100
- };
101
-
102
- const triggerElement = trigger ? (
103
- React.isValidElement(trigger) ? (
104
- React.cloneElement(trigger as React.ReactElement<any>, {
105
- onClick: handleOpen,
106
- disabled,
107
- })
108
- ) : (
109
- <span onClick={handleOpen}>{trigger}</span>
110
- )
111
- ) : (
112
- <Tooltip title={triggerTooltip} arrow>
113
- <span>
114
- <IconButton
115
- size="small"
116
- onClick={handleOpen}
117
- disabled={disabled}
118
- aria-label={triggerTooltip}
119
- >
120
- <MoreVertIcon fontSize="small" />
121
- </IconButton>
122
- </span>
123
- </Tooltip>
124
- );
125
-
126
- return (
127
- <span className={className}>
128
- {triggerElement}
129
- <Menu
130
- anchorEl={anchorEl}
131
- open={open}
132
- onClose={handleClose}
133
- anchorOrigin={anchorOrigin}
134
- transformOrigin={transformOrigin}
135
- slotProps={{ paper: { sx: { minWidth: 180, ...(menuSx as any) } } }}
136
- >
137
- {items.map((item, idx) => {
138
- const key = item.key ?? `${String(item.label)}-${idx}`;
139
- const node = (
140
- <MenuItem
141
- key={key}
142
- disabled={item.disabled}
143
- onClick={(event) => handleItemClick(event, item)}
144
- sx={(theme) => ({
145
- color: item.danger ? theme.palette.error.main : 'inherit',
146
- '& .MuiListItemIcon-root': {
147
- color: item.danger
148
- ? theme.palette.error.main
149
- : 'inherit',
150
- minWidth: 32,
151
- },
152
- })}
153
- >
154
- {item.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
155
- <ListItemText primary={item.label} />
156
- </MenuItem>
157
- );
158
-
159
- if (item.dividerBefore && idx > 0) {
160
- return (
161
- <React.Fragment key={`${key}-frag`}>
162
- <Divider />
163
- {node}
164
- </React.Fragment>
165
- );
166
- }
167
- return node;
168
- })}
169
- </Menu>
170
- </span>
171
- );
172
- }
173
-
174
- export default ActionMenu;
@@ -1,2 +0,0 @@
1
- export { ActionMenu, default } from './ActionMenu';
2
- export type { ActionMenuProps, ActionMenuItem } from './ActionMenu';
@@ -1,272 +0,0 @@
1
- import React, { useState } from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
- import { Box, Typography, Button, IconButton, Tooltip } from '@mui/material';
4
- import NotificationsIcon from '@mui/icons-material/Notifications';
5
- import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
6
- import PersonIcon from '@mui/icons-material/Person';
7
- import SettingsIcon from '@mui/icons-material/Settings';
8
- import LogoutIcon from '@mui/icons-material/Logout';
9
- import DashboardIcon from '@mui/icons-material/Dashboard';
10
-
11
- import { AppBar } from './AppBar';
12
- import { AppBarBrand } from './AppBarBrand';
13
- import { AppBarMenuToggle } from './AppBarMenuToggle';
14
- import { AppBarUserMenu } from './AppBarUserMenu';
15
-
16
- const meta: Meta<typeof AppBar> = {
17
- title: 'Components/AppBar',
18
- component: AppBar,
19
- tags: ['autodocs'],
20
- parameters: {
21
- layout: 'fullscreen',
22
- docs: {
23
- description: {
24
- component:
25
- 'AppBar (header superior) pensado como shell compositivo. El consumer arma su contenido con los sub-componentes `AppBarBrand`, `AppBarMenuToggle` y `AppBarUserMenu`, además de cualquier acción custom. Reemplaza el header de Metronic.',
26
- },
27
- },
28
- },
29
- argTypes: {
30
- position: {
31
- control: 'select',
32
- options: ['fixed', 'sticky', 'static', 'absolute', 'relative'],
33
- },
34
- color: {
35
- control: 'select',
36
- options: ['default', 'primary', 'secondary', 'transparent', 'inherit'],
37
- },
38
- elevation: { control: { type: 'number', min: 0, max: 24, step: 1 } },
39
- height: { control: { type: 'number', min: 48, max: 96, step: 4 } },
40
- },
41
- };
42
-
43
- export default meta;
44
- type Story = StoryObj<typeof AppBar>;
45
-
46
- // ── Helpers ──────────────────────────────────────────────────────────────
47
-
48
- const SampleLogo = () => (
49
- <Box
50
- sx={{
51
- width: 32,
52
- height: 32,
53
- borderRadius: 1,
54
- display: 'flex',
55
- alignItems: 'center',
56
- justifyContent: 'center',
57
- backgroundColor: 'primary.main',
58
- color: 'primary.contrastText',
59
- fontWeight: 700,
60
- fontSize: 14,
61
- }}
62
- >
63
- F
64
- </Box>
65
- );
66
-
67
- const SampleBody = () => (
68
- <Box sx={{ p: 3 }}>
69
- <Typography variant="h5" gutterBottom>
70
- Contenido de la página
71
- </Typography>
72
- <Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
73
- Este bloque sólo demuestra el layout bajo el AppBar.
74
- </Typography>
75
- {Array.from({ length: 20 }).map((_, idx) => (
76
- <Typography key={idx} variant="body2" sx={{ mb: 1 }}>
77
- Línea {idx + 1} — contenido de ejemplo para scroll sticky.
78
- </Typography>
79
- ))}
80
- </Box>
81
- );
82
-
83
- const userMenuItems = [
84
- {
85
- label: 'Mi perfil',
86
- icon: <PersonIcon fontSize="small" />,
87
- onClick: () => console.log('profile'),
88
- },
89
- {
90
- label: 'Configuración',
91
- icon: <SettingsIcon fontSize="small" />,
92
- onClick: () => console.log('settings'),
93
- },
94
- {
95
- label: 'Cerrar sesión',
96
- icon: <LogoutIcon fontSize="small" />,
97
- onClick: () => console.log('logout'),
98
- danger: true,
99
- dividerBefore: true,
100
- },
101
- ];
102
-
103
- // ── Stories ──────────────────────────────────────────────────────────────
104
-
105
- export const BasicHeader: Story = {
106
- args: {
107
- position: 'sticky',
108
- color: 'default',
109
- elevation: 1,
110
- height: 64,
111
- },
112
- render: (args) => (
113
- <>
114
- <AppBar {...args}>
115
- <AppBarBrand
116
- logo={<SampleLogo />}
117
- title="Afiliaciones"
118
- subtitle="Panel administrativo"
119
- />
120
- </AppBar>
121
- <SampleBody />
122
- </>
123
- ),
124
- };
125
-
126
- export const WithMenuToggle: Story = {
127
- render: (args) => {
128
- const [open, setOpen] = useState(false);
129
- return (
130
- <>
131
- <AppBar
132
- {...args}
133
- onMenuToggle={() => setOpen((value) => !value)}
134
- menuOpen={open}
135
- >
136
- <AppBarMenuToggle />
137
- <AppBarBrand logo={<SampleLogo />} title="Afiliaciones" />
138
- </AppBar>
139
- <Box sx={{ p: 3 }}>
140
- <Typography variant="body2">
141
- Drawer {open ? 'abierto' : 'cerrado'} — el icono cambia según el
142
- estado. Click en el botón hamburguesa para alternar.
143
- </Typography>
144
- </Box>
145
- </>
146
- );
147
- },
148
- };
149
-
150
- export const WithUserMenu: Story = {
151
- render: (args) => (
152
- <>
153
- <AppBar {...args}>
154
- <AppBarBrand logo={<SampleLogo />} title="Afiliaciones" />
155
- <Box sx={{ flex: 1 }} />
156
- <AppBarUserMenu
157
- user={{
158
- name: 'Andrea Pineda',
159
- email: 'andrea@soyfri.com',
160
- }}
161
- items={userMenuItems}
162
- />
163
- </AppBar>
164
- <SampleBody />
165
- </>
166
- ),
167
- };
168
-
169
- export const CompleteDashboardHeader: Story = {
170
- render: (args) => {
171
- const [open, setOpen] = useState(true);
172
- return (
173
- <>
174
- <AppBar
175
- {...args}
176
- onMenuToggle={() => setOpen((value) => !value)}
177
- menuOpen={open}
178
- >
179
- <AppBarMenuToggle />
180
- <AppBarBrand
181
- logo={<SampleLogo />}
182
- title="Afiliaciones"
183
- subtitle="Panel administrativo"
184
- onClick={() => console.log('go home')}
185
- />
186
- <Box sx={{ flex: 1 }} />
187
- <Tooltip title="Notificaciones" arrow>
188
- <IconButton color="inherit">
189
- <NotificationsIcon />
190
- </IconButton>
191
- </Tooltip>
192
- <Tooltip title="Ayuda" arrow>
193
- <IconButton color="inherit">
194
- <HelpOutlineIcon />
195
- </IconButton>
196
- </Tooltip>
197
- <AppBarUserMenu
198
- user={{
199
- name: 'Andrea Pineda',
200
- email: 'andrea@soyfri.com',
201
- }}
202
- items={userMenuItems}
203
- />
204
- </AppBar>
205
- <SampleBody />
206
- </>
207
- );
208
- },
209
- };
210
-
211
- export const TransparentVariant: Story = {
212
- args: {
213
- color: 'transparent',
214
- elevation: 0,
215
- },
216
- render: (args) => (
217
- <Box
218
- sx={{
219
- minHeight: '100vh',
220
- background:
221
- 'linear-gradient(135deg, #f0f4ff 0%, #e6f7ff 50%, #fff5f5 100%)',
222
- }}
223
- >
224
- <AppBar {...args}>
225
- <AppBarBrand logo={<SampleLogo />} title="Afiliaciones" />
226
- <Box sx={{ flex: 1 }} />
227
- <Button variant="contained" color="primary" size="small">
228
- Iniciar sesión
229
- </Button>
230
- </AppBar>
231
- <Box sx={{ p: 3 }}>
232
- <Typography variant="h5">Landing page transparente</Typography>
233
- <Typography variant="body2" color="text.secondary">
234
- Sin sombra, con borde sutil — útil para headers sobre hero sections.
235
- </Typography>
236
- </Box>
237
- </Box>
238
- ),
239
- };
240
-
241
- export const PrimaryColorWithMenu: Story = {
242
- args: {
243
- color: 'primary',
244
- },
245
- render: (args) => {
246
- const [open, setOpen] = useState(false);
247
- return (
248
- <>
249
- <AppBar
250
- {...args}
251
- onMenuToggle={() => setOpen((value) => !value)}
252
- menuOpen={open}
253
- >
254
- <AppBarMenuToggle />
255
- <DashboardIcon sx={{ mr: 1 }} />
256
- <Typography variant="h6" sx={{ fontWeight: 700 }}>
257
- Dashboard
258
- </Typography>
259
- <Box sx={{ flex: 1 }} />
260
- <AppBarUserMenu
261
- user={{
262
- name: 'Andrea Pineda',
263
- email: 'andrea@soyfri.com',
264
- }}
265
- items={userMenuItems}
266
- />
267
- </AppBar>
268
- <SampleBody />
269
- </>
270
- );
271
- },
272
- };