@soyfri/shared-library 2.0.0-beta.0 → 2.0.0-beta.10
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/dist/README.md +243 -0
- package/dist/components/Drawer/Drawer.cjs +14 -17
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts +8 -1
- package/dist/components/Drawer/Drawer.js +14 -17
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/Input/Input.definitions.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.cjs +202 -0
- package/dist/components/RadioGroup/RadioGroup.cjs.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +53 -0
- package/dist/components/RadioGroup/RadioGroup.definitions.d.ts +6 -0
- package/dist/components/RadioGroup/RadioGroup.js +202 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.sx.d.ts +20 -0
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +1 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RadioGroup.d.ts +6 -0
- package/dist/components/Stepper/Stepper.cjs +136 -23
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.js +137 -24
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/Switch/Switch.cjs +181 -0
- package/dist/components/Switch/Switch.cjs.map +1 -0
- package/dist/components/Switch/Switch.d.ts +43 -0
- package/dist/components/Switch/Switch.definitions.d.ts +7 -0
- package/dist/components/Switch/Switch.js +181 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/Switch.sx.d.ts +22 -0
- package/dist/components/Switch/Switch.types.d.ts +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch.d.ts +6 -0
- 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 +207 -0
- package/dist/theme/componentStyles.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Drawer/Drawer.stories.tsx +168 -0
- package/src/components/Drawer/Drawer.tsx +26 -18
- package/src/components/Input/Input.definitions.ts +24 -0
- package/src/components/Input/Input.stories.tsx +29 -0
- package/src/components/RadioGroup/RadioGroup.definitions.ts +177 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +231 -0
- package/src/components/RadioGroup/RadioGroup.sx.ts +75 -0
- package/src/components/RadioGroup/RadioGroup.tsx +196 -0
- package/src/components/RadioGroup/RadioGroup.types.ts +10 -0
- package/src/components/RadioGroup/index.ts +9 -0
- package/src/components/Stepper/Stepper.stories.tsx +72 -0
- package/src/components/Stepper/Stepper.tsx +139 -4
- package/src/components/Switch/Switch.definitions.ts +134 -0
- package/src/components/Switch/Switch.stories.tsx +213 -0
- package/src/components/Switch/Switch.sx.ts +81 -0
- package/src/components/Switch/Switch.tsx +172 -0
- package/src/components/Switch/Switch.types.ts +10 -0
- package/src/components/Switch/index.ts +9 -0
- package/src/mui.ts +10 -0
- package/src/theme/componentStyles.ts +3 -1
- package/storybook-static/addon-visual-tests-assets/visual-test-illustration.mp4 +0 -0
- package/storybook-static/assets/AccountCircle-BDZFsbTw.js +1 -0
- package/storybook-static/assets/ActionMenu-EynP8yU1.js +19 -0
- package/storybook-static/assets/ActionMenu.stories-DqSqRGix.js +185 -0
- package/storybook-static/assets/Alert-3zvTPc0p.js +1 -0
- package/storybook-static/assets/AppBar.stories-DcX3M5th.js +172 -0
- package/storybook-static/assets/Autocomplete.stories-CXJm8FOT.js +788 -0
- package/storybook-static/assets/Avatar-NbFfkZws.js +1 -0
- package/storybook-static/assets/Avatar.stories-CwOYCzqU.js +390 -0
- package/storybook-static/assets/Box-BnhEcfFm.js +1 -0
- package/storybook-static/assets/Button-D9h7OggD.js +1 -0
- package/storybook-static/assets/Button-DBpqmVB_.js +1 -0
- package/storybook-static/assets/Button.stories-F20dmnjq.js +320 -0
- package/storybook-static/assets/ButtonBase-qyaMEhe4.js +74 -0
- package/storybook-static/assets/Card.stories-B3NpAhO0.js +154 -0
- package/storybook-static/assets/CheckCircleOutline-CEj5mDsl.js +1 -0
- package/storybook-static/assets/Chip-C3vKPpzR.js +1 -0
- package/storybook-static/assets/Chip.stories-sxcfHVo9.js +333 -0
- package/storybook-static/assets/CircularProgress-DC7ZNWwl.js +28 -0
- package/storybook-static/assets/Clear-4kYcKvT3.js +1 -0
- package/storybook-static/assets/ClipBoard-DvLBdNHe.js +1 -0
- package/storybook-static/assets/ClipBoard.stories-BGUo47r6.js +108 -0
- package/storybook-static/assets/Close-CgHeRgmh.js +1 -0
- package/storybook-static/assets/Close-Cy8nELYU.js +1 -0
- package/storybook-static/assets/Color-AVL7NMMY-BJKvwERm.js +1 -0
- package/storybook-static/assets/ContentCopy-BfLTDb10.js +1 -0
- package/storybook-static/assets/DatePicker-Clkpr-Ku.js +1 -0
- package/storybook-static/assets/DatePicker.stories-EaUCMkh3.js +444 -0
- package/storybook-static/assets/DateRangePicker.stories-BMlkj-8K.js +390 -0
- package/storybook-static/assets/DateTimePicker.stories-B6gdzKq5.js +555 -0
- package/storybook-static/assets/DefaultPropsProvider-BGoQxtDa.js +16 -0
- package/storybook-static/assets/Delete-D2SMMmIA.js +1 -0
- package/storybook-static/assets/DialogContent-BeCDKgax.js +1 -0
- package/storybook-static/assets/Divider-BbCj9wT4.js +1 -0
- package/storybook-static/assets/DocsRenderer-PQXLIZUC-BebLK5Y_.js +1243 -0
- package/storybook-static/assets/Drawer-DcFwy73r.js +1 -0
- package/storybook-static/assets/Drawer.stories-C5AZkJBk.js +173 -0
- package/storybook-static/assets/EmptyTable-B-RKtgVs.png +0 -0
- package/storybook-static/assets/ErrorOutline-D9gM7ART.js +1 -0
- package/storybook-static/assets/Fade-Ll96CvH8.js +1 -0
- package/storybook-static/assets/Flyout.stories-Cf7z6MNw.js +163 -0
- package/storybook-static/assets/Gallery.stories-DdpWVTF6.js +127 -0
- package/storybook-static/assets/Grow-8y4FglGK.js +1 -0
- package/storybook-static/assets/Home-BRvJEp2L.js +1 -0
- package/storybook-static/assets/Icon.stories-D0mUiW_t.js +78 -0
- package/storybook-static/assets/IconButton-9OYSTH58.js +1 -0
- package/storybook-static/assets/Input-CjX0t4h-.js +1 -0
- package/storybook-static/assets/Input.stories-BRxekliy.js +650 -0
- package/storybook-static/assets/InputGroup.stories-DH6gUfmn.js +306 -0
- package/storybook-static/assets/KeyboardArrowRight-WO_attK2.js +1 -0
- package/storybook-static/assets/KeyboardArrowUp-DsyVef-i.js +1 -0
- package/storybook-static/assets/ListItem-D3O0103N.js +1 -0
- package/storybook-static/assets/ListItemIcon-hca6xN79.js +1 -0
- package/storybook-static/assets/ListItemText-BFLAwLdl.js +1 -0
- package/storybook-static/assets/Logout-gj-P3AfU.js +1 -0
- package/storybook-static/assets/Menu-ClzfjLc3.js +1 -0
- package/storybook-static/assets/MenuButton.stories-B-W_QVDt.js +162 -0
- package/storybook-static/assets/MenuItem-iU6tAqJI.js +1 -0
- package/storybook-static/assets/Modal-3okp9H2i.js +1 -0
- package/storybook-static/assets/Modal.stories-DIWzm4qR.js +468 -0
- package/storybook-static/assets/MoreVert-BoIVG4gh.js +1 -0
- package/storybook-static/assets/Notifications-DY_A-Sho.js +1 -0
- package/storybook-static/assets/PageLoader.stories-DmtO1mlm.js +158 -0
- package/storybook-static/assets/Paper-SwQBhqI7.js +1 -0
- package/storybook-static/assets/Person-CkQl-mpq.js +1 -0
- package/storybook-static/assets/PickersModalDialog-Tjnr_cu5.js +10 -0
- package/storybook-static/assets/PickersToolbarButton-Tt185-si.js +1 -0
- package/storybook-static/assets/Popper-CnCTYXxy.js +1 -0
- package/storybook-static/assets/Portal-Cj8XF9Lf.js +1 -0
- package/storybook-static/assets/ScrollTopButton.stories-BflQCwNP.js +90 -0
- package/storybook-static/assets/Select-CjcuMAY0.js +4 -0
- package/storybook-static/assets/Select-DJh2biEb.js +3 -0
- package/storybook-static/assets/Select.stories-DU1Gb3I2.js +1103 -0
- package/storybook-static/assets/Settings-BLKc1CnO.js +1 -0
- package/storybook-static/assets/Snackbar-BtVeKTw6.js +1 -0
- package/storybook-static/assets/Stack-D01OUIXi.js +1 -0
- package/storybook-static/assets/Stat.stories-Bn9-iuPT.js +60 -0
- package/storybook-static/assets/StatusMessage.stories-hnfX8FeU.js +73 -0
- package/storybook-static/assets/Stepper-BtKB5ykn.js +2 -0
- package/storybook-static/assets/Stepper.stories-CTEZbgPc.js +165 -0
- package/storybook-static/assets/Table.stories-CTn2Ktmn.js +1260 -0
- package/storybook-static/assets/TableContainer-CzLNaEU-.js +1 -0
- package/storybook-static/assets/TableRow-CS88-1HF.js +2 -0
- package/storybook-static/assets/Tabs-DLpDOu_n.js +1 -0
- package/storybook-static/assets/Tabs.stories-BFVuFy_5.js +159 -0
- package/storybook-static/assets/TextField-22T-xHBm.js +1 -0
- package/storybook-static/assets/Timeline.stories-DJU_U2Hv.js +97 -0
- package/storybook-static/assets/Tooltip-DbnHUxNj.js +1 -0
- package/storybook-static/assets/Tooltip.stories-B7tA3dnV.js +66 -0
- package/storybook-static/assets/Typography-BgntX2Ep.js +1 -0
- package/storybook-static/assets/Wizard.stories-CVrJLK_D.js +23 -0
- package/storybook-static/assets/createSimplePaletteValueFilter-bm0fmN_7.js +1 -0
- package/storybook-static/assets/createSvgIcon-D_Gca4vA.js +1 -0
- package/storybook-static/assets/debounce-Be36O1Ab.js +1 -0
- package/storybook-static/assets/emotion-react.browser.esm--g-C9cX9.js +8 -0
- package/storybook-static/assets/extendSxProp-CEpa30hT.js +1 -0
- package/storybook-static/assets/formField.sx-DMCmZIAa.js +1 -0
- package/storybook-static/assets/getReactElementRef-BQ3ANZdy.js +1 -0
- package/storybook-static/assets/iframe-BAJnc_4n.js +1079 -0
- package/storybook-static/assets/index-B1tlhOpe.js +240 -0
- package/storybook-static/assets/index-BF3FAXTk.js +9 -0
- package/storybook-static/assets/index-CIeucmOB.js +2 -0
- package/storybook-static/assets/index-CY7j4a7o.js +1 -0
- package/storybook-static/assets/index-CxkKctw5.js +1 -0
- package/storybook-static/assets/isFocusVisible-B8k4qzLc.js +1 -0
- package/storybook-static/assets/isMuiElement-CTZSFcY5.js +1 -0
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/listItemTextClasses-CC_rwJam.js +1 -0
- package/storybook-static/assets/mergeSlotProps-B0UBKBMe.js +1 -0
- package/storybook-static/assets/ownerDocument-DW-IO8s5.js +1 -0
- package/storybook-static/assets/ownerWindow-HkKU3E4x.js +1 -0
- package/storybook-static/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/storybook-static/assets/react-18-BUJ64QCV.js +25 -0
- package/storybook-static/assets/resolvePreset-CN2aOJJr.js +1 -0
- package/storybook-static/assets/useControlled-DsVh1a5j.js +1 -0
- package/storybook-static/assets/useForkRef-0ANIrxcF.js +1 -0
- package/storybook-static/assets/useId-b4fZxjOL.js +1 -0
- package/storybook-static/assets/useMobilePicker-DK-c8xbD.js +1 -0
- package/storybook-static/assets/usePreviousProps-WR0rG4aR.js +1 -0
- package/storybook-static/assets/useSlot-b6pXgp5_.js +1 -0
- package/storybook-static/assets/useSlotProps-C0uMfuBt.js +1 -0
- package/storybook-static/assets/useTheme-BmOJK7ra.js +1 -0
- package/storybook-static/assets/useThemeProps-DYtxXiUU.js +1 -0
- package/storybook-static/assets/useThemeProps-U4yXiZ_5.js +1 -0
- package/storybook-static/assets/useTimeout-DNjRaOWc.js +1 -0
- package/storybook-static/assets/visuallyHidden-Dan1xhjv.js +1 -0
- package/storybook-static/favicon-wrapper.svg +46 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +686 -0
- package/storybook-static/index.html +160 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-2/manager-bundle.js +356 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-2/manager-bundle.js.LEGAL.txt +40 -0
- package/storybook-static/sb-addons/docs-4/manager-bundle.js +151 -0
- package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +127 -0
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
- package/storybook-static/sb-addons/vitest-3/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon-wrapper.svg +46 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +797 -0
- package/storybook-static/sb-manager/globals-runtime.js +69679 -0
- package/storybook-static/sb-manager/globals.js +34 -0
- package/storybook-static/sb-manager/runtime.js +13195 -0
- package/storybook-static/vite-inject-mocker-entry.js +18 -0
|
@@ -10,6 +10,7 @@ import NotificationsIcon from '@mui/icons-material/Notifications';
|
|
|
10
10
|
|
|
11
11
|
import { Drawer } from './Drawer';
|
|
12
12
|
import { DrawerItem } from './DrawerItem';
|
|
13
|
+
import { useDrawerContext } from './DrawerContext';
|
|
13
14
|
|
|
14
15
|
const meta: Meta<typeof Drawer> = {
|
|
15
16
|
title: 'Components/Drawer',
|
|
@@ -55,6 +56,34 @@ const SampleLogo = () => (
|
|
|
55
56
|
</Typography>
|
|
56
57
|
);
|
|
57
58
|
|
|
59
|
+
// Logo "inteligente" que usa el context para adaptarse: texto completo cuando
|
|
60
|
+
// está expandido, inicial cuando está colapsado. Es el patrón esperado para el
|
|
61
|
+
// nuevo prop `logo` del Drawer.
|
|
62
|
+
const BrandLogo = () => {
|
|
63
|
+
const { collapsed } = useDrawerContext();
|
|
64
|
+
return collapsed ? (
|
|
65
|
+
<Box
|
|
66
|
+
sx={{
|
|
67
|
+
width: 32,
|
|
68
|
+
height: 32,
|
|
69
|
+
borderRadius: 1,
|
|
70
|
+
bgcolor: 'primary.main',
|
|
71
|
+
color: '#fff',
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
fontWeight: 700,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
s
|
|
79
|
+
</Box>
|
|
80
|
+
) : (
|
|
81
|
+
<Typography variant="h6" sx={{ fontWeight: 700, color: 'primary.main' }}>
|
|
82
|
+
soyfri
|
|
83
|
+
</Typography>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
58
87
|
const SampleFooter = ({ collapsed }: { collapsed: boolean }) => (
|
|
59
88
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
|
60
89
|
<Avatar sx={{ width: 36, height: 36 }}>AP</Avatar>
|
|
@@ -236,6 +265,145 @@ export const TemporaryDrawer: Story = {
|
|
|
236
265
|
},
|
|
237
266
|
};
|
|
238
267
|
|
|
268
|
+
// ── Nuevo prop `logo` (beta 6) ──────────────────────────────────────────
|
|
269
|
+
|
|
270
|
+
export const WithLogoExpanded: Story = {
|
|
271
|
+
args: {
|
|
272
|
+
variant: 'permanent',
|
|
273
|
+
collapsed: false,
|
|
274
|
+
expandedWidth: 260,
|
|
275
|
+
collapsedWidth: 72,
|
|
276
|
+
logo: <BrandLogo />,
|
|
277
|
+
},
|
|
278
|
+
render: (args) => (
|
|
279
|
+
<Box sx={{ display: 'flex', height: '100vh' }}>
|
|
280
|
+
<Drawer
|
|
281
|
+
{...args}
|
|
282
|
+
onToggleCollapse={() => {
|
|
283
|
+
/* noop para que aparezca el chevron */
|
|
284
|
+
}}
|
|
285
|
+
>
|
|
286
|
+
<DrawerItem icon={<HomeIcon />} label="Inicio" active />
|
|
287
|
+
<DrawerItem icon={<PersonIcon />} label="Perfil" />
|
|
288
|
+
<DrawerItem icon={<ReceiptIcon />} label="Facturación" />
|
|
289
|
+
<DrawerItem icon={<SettingsIcon />} label="Configuración" />
|
|
290
|
+
</Drawer>
|
|
291
|
+
<Box sx={{ flex: 1, p: 3 }}>
|
|
292
|
+
<Typography variant="h5">Prop `logo` expandido</Typography>
|
|
293
|
+
<Typography color="text.secondary">
|
|
294
|
+
Logo a la izquierda, chevron a la derecha en la misma fila.
|
|
295
|
+
</Typography>
|
|
296
|
+
</Box>
|
|
297
|
+
</Box>
|
|
298
|
+
),
|
|
299
|
+
parameters: {
|
|
300
|
+
docs: {
|
|
301
|
+
description: {
|
|
302
|
+
story:
|
|
303
|
+
'Nuevo prop `logo`: brand + toggle alineados horizontalmente cuando el drawer está expandido. El consumer solo pasa el nodo del logo y el Drawer se encarga del layout.',
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export const WithLogoCollapsed: Story = {
|
|
310
|
+
...WithLogoExpanded,
|
|
311
|
+
args: {
|
|
312
|
+
...WithLogoExpanded.args,
|
|
313
|
+
collapsed: true,
|
|
314
|
+
},
|
|
315
|
+
parameters: {
|
|
316
|
+
docs: {
|
|
317
|
+
description: {
|
|
318
|
+
story:
|
|
319
|
+
'Mismo drawer colapsado: el `logo` sigue visible (a diferencia del viejo `header` que se ocultaba). Layout vertical: logo-mini arriba centrado, chevron debajo centrado. El `BrandLogo` usa `useDrawerContext()` para mostrar la versión mini.',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export const WithLogoToggleable: Story = {
|
|
326
|
+
render: () => {
|
|
327
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
328
|
+
return (
|
|
329
|
+
<Box sx={{ display: 'flex', height: '100vh' }}>
|
|
330
|
+
<Drawer
|
|
331
|
+
variant="permanent"
|
|
332
|
+
collapsed={collapsed}
|
|
333
|
+
onToggleCollapse={() => setCollapsed((v) => !v)}
|
|
334
|
+
logo={<BrandLogo />}
|
|
335
|
+
footer={<SampleFooter collapsed={collapsed} />}
|
|
336
|
+
>
|
|
337
|
+
<DrawerItem icon={<HomeIcon />} label="Inicio" active />
|
|
338
|
+
<DrawerItem icon={<PersonIcon />} label="Perfil" />
|
|
339
|
+
<DrawerItem icon={<ReceiptIcon />} label="Facturación" />
|
|
340
|
+
<DrawerItem icon={<SettingsIcon />} label="Configuración" />
|
|
341
|
+
<DrawerItem icon={<LogoutIcon />} label="Cerrar sesión" danger />
|
|
342
|
+
</Drawer>
|
|
343
|
+
<Box sx={{ flex: 1, p: 3 }}>
|
|
344
|
+
<Typography variant="h5">
|
|
345
|
+
Drawer con `logo`: {collapsed ? 'colapsado' : 'expandido'}
|
|
346
|
+
</Typography>
|
|
347
|
+
<Typography color="text.secondary">
|
|
348
|
+
Alterná con el chevron: logo y toggle quedan alineados en ambos
|
|
349
|
+
estados (fila horizontal expandido, stack vertical colapsado).
|
|
350
|
+
</Typography>
|
|
351
|
+
</Box>
|
|
352
|
+
</Box>
|
|
353
|
+
);
|
|
354
|
+
},
|
|
355
|
+
parameters: {
|
|
356
|
+
docs: {
|
|
357
|
+
description: {
|
|
358
|
+
story:
|
|
359
|
+
'Caso interactivo: mismo patrón que `ToggleableDrawer` pero usando el nuevo prop `logo` en lugar de `header`. Comparar contra `ToggleableDrawer` para ver la diferencia de alineación al colapsar.',
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export const WithLogoAndHeader: Story = {
|
|
366
|
+
args: {
|
|
367
|
+
variant: 'permanent',
|
|
368
|
+
collapsed: false,
|
|
369
|
+
logo: <BrandLogo />,
|
|
370
|
+
header: (
|
|
371
|
+
<Typography variant="caption" color="text.secondary">
|
|
372
|
+
Workspace: Afiliaciones · v2.1
|
|
373
|
+
</Typography>
|
|
374
|
+
),
|
|
375
|
+
},
|
|
376
|
+
render: (args) => (
|
|
377
|
+
<Box sx={{ display: 'flex', height: '100vh' }}>
|
|
378
|
+
<Drawer
|
|
379
|
+
{...args}
|
|
380
|
+
onToggleCollapse={() => {
|
|
381
|
+
/* noop */
|
|
382
|
+
}}
|
|
383
|
+
>
|
|
384
|
+
<DrawerItem icon={<HomeIcon />} label="Inicio" active />
|
|
385
|
+
<DrawerItem icon={<PersonIcon />} label="Perfil" />
|
|
386
|
+
<DrawerItem icon={<SettingsIcon />} label="Configuración" />
|
|
387
|
+
</Drawer>
|
|
388
|
+
<Box sx={{ flex: 1, p: 3 }}>
|
|
389
|
+
<Typography variant="h5">`logo` + `header` combinados</Typography>
|
|
390
|
+
<Typography color="text.secondary">
|
|
391
|
+
El `logo` vive junto al toggle. El `header` queda debajo como fila
|
|
392
|
+
secundaria y se oculta al colapsar.
|
|
393
|
+
</Typography>
|
|
394
|
+
</Box>
|
|
395
|
+
</Box>
|
|
396
|
+
),
|
|
397
|
+
parameters: {
|
|
398
|
+
docs: {
|
|
399
|
+
description: {
|
|
400
|
+
story:
|
|
401
|
+
'Ambos props conviven: `logo` es la sección de brand siempre visible (junto al toggle), `header` sigue siendo una fila secundaria que se oculta al colapsar.',
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
|
|
239
407
|
export const RightAnchored: Story = {
|
|
240
408
|
args: {
|
|
241
409
|
variant: 'permanent',
|
|
@@ -52,6 +52,13 @@ export interface DrawerProps {
|
|
|
52
52
|
showCollapseButton?: boolean;
|
|
53
53
|
/** Contenido del header (por encima de los items). Típicamente logo/brand. */
|
|
54
54
|
header?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Logo/brand que se muestra junto al botón de toggle.
|
|
57
|
+
* - Expandido: logo a la izquierda, toggle a la derecha en la misma fila.
|
|
58
|
+
* - Colapsado: logo arriba centrado, toggle debajo centrado (stack vertical).
|
|
59
|
+
* Siempre visible (a diferencia de `header`, que se oculta al colapsar).
|
|
60
|
+
*/
|
|
61
|
+
logo?: ReactNode;
|
|
55
62
|
/** Contenido del footer (por debajo de los items). Típicamente user profile. */
|
|
56
63
|
footer?: ReactNode;
|
|
57
64
|
/**
|
|
@@ -78,6 +85,7 @@ export function Drawer({
|
|
|
78
85
|
collapsedWidth = 72,
|
|
79
86
|
showCollapseButton,
|
|
80
87
|
header,
|
|
88
|
+
logo,
|
|
81
89
|
footer,
|
|
82
90
|
preset,
|
|
83
91
|
sx,
|
|
@@ -129,22 +137,28 @@ export function Drawer({
|
|
|
129
137
|
sx: paperSx,
|
|
130
138
|
}}
|
|
131
139
|
>
|
|
132
|
-
{
|
|
140
|
+
{(logo || shouldShowToggle) && (
|
|
133
141
|
<Box
|
|
134
142
|
sx={{
|
|
135
143
|
display: 'flex',
|
|
144
|
+
flexDirection: contextValue.collapsed ? 'column' : 'row',
|
|
136
145
|
alignItems: 'center',
|
|
137
146
|
justifyContent: contextValue.collapsed
|
|
138
147
|
? 'center'
|
|
139
|
-
:
|
|
148
|
+
: logo
|
|
149
|
+
? 'space-between'
|
|
150
|
+
: 'flex-end',
|
|
151
|
+
gap: contextValue.collapsed ? 0.5 : 0,
|
|
140
152
|
px: contextValue.collapsed ? 1 : 2,
|
|
141
|
-
py: 1
|
|
153
|
+
py: 1,
|
|
142
154
|
minHeight: 64,
|
|
143
155
|
flexShrink: 0,
|
|
144
156
|
}}
|
|
145
157
|
>
|
|
146
|
-
{
|
|
147
|
-
<Box sx={{ flex:
|
|
158
|
+
{logo && (
|
|
159
|
+
<Box sx={{ display: 'flex', alignItems: 'center', minWidth: 0 }}>
|
|
160
|
+
{logo}
|
|
161
|
+
</Box>
|
|
148
162
|
)}
|
|
149
163
|
{shouldShowToggle && (
|
|
150
164
|
<IconButton
|
|
@@ -158,24 +172,18 @@ export function Drawer({
|
|
|
158
172
|
</Box>
|
|
159
173
|
)}
|
|
160
174
|
|
|
161
|
-
{
|
|
175
|
+
{header && !contextValue.collapsed && (
|
|
162
176
|
<Box
|
|
163
177
|
sx={{
|
|
164
178
|
display: 'flex',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
px: 2,
|
|
181
|
+
py: 1.5,
|
|
182
|
+
minHeight: 56,
|
|
183
|
+
flexShrink: 0,
|
|
170
184
|
}}
|
|
171
185
|
>
|
|
172
|
-
<
|
|
173
|
-
size="small"
|
|
174
|
-
onClick={onToggleCollapse}
|
|
175
|
-
aria-label={collapsed ? 'Expandir menú' : 'Colapsar menú'}
|
|
176
|
-
>
|
|
177
|
-
{collapsed ? <ChevronRightIcon /> : <ChevronLeftIcon />}
|
|
178
|
-
</IconButton>
|
|
186
|
+
<Box sx={{ flex: 1, minWidth: 0 }}>{header}</Box>
|
|
179
187
|
</Box>
|
|
180
188
|
)}
|
|
181
189
|
|
|
@@ -322,3 +322,27 @@ export const CustomStylingExample = () => {
|
|
|
322
322
|
);
|
|
323
323
|
};
|
|
324
324
|
`;
|
|
325
|
+
|
|
326
|
+
export const MultilineInputDefinition = `
|
|
327
|
+
import React, { useState } from 'react';
|
|
328
|
+
import { Input } from './Input';
|
|
329
|
+
import { Box, Typography } from '@mui/material';
|
|
330
|
+
|
|
331
|
+
export const MultilineInputExample = () => {
|
|
332
|
+
const [value, setValue] = useState('Escribe un comentario en varias líneas...');
|
|
333
|
+
return (
|
|
334
|
+
<Box sx={{ width: 400 }}>
|
|
335
|
+
<Input
|
|
336
|
+
label="Comentario"
|
|
337
|
+
value={value}
|
|
338
|
+
onChange={(v) => setValue(v.toString())}
|
|
339
|
+
multiline
|
|
340
|
+
minRows={3}
|
|
341
|
+
maxRows={6}
|
|
342
|
+
fullWidth
|
|
343
|
+
/>
|
|
344
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
345
|
+
</Box>
|
|
346
|
+
);
|
|
347
|
+
};
|
|
348
|
+
`;
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
LabelPositionFloatingDefinition,
|
|
25
25
|
CustomBorderRadiusDefinition,
|
|
26
26
|
CustomStylingDefinition,
|
|
27
|
+
MultilineInputDefinition,
|
|
27
28
|
} from './Input.definitions';
|
|
28
29
|
|
|
29
30
|
// =============================================================================
|
|
@@ -456,6 +457,34 @@ export const CustomBorderRadius: Story = {
|
|
|
456
457
|
}
|
|
457
458
|
};
|
|
458
459
|
|
|
460
|
+
export const MultilineInput: Story = {
|
|
461
|
+
render: () => {
|
|
462
|
+
const [value, setValue] = useState('Escribe un comentario en varias líneas...');
|
|
463
|
+
return (
|
|
464
|
+
<Box sx={{ width: 400 }}>
|
|
465
|
+
<Input
|
|
466
|
+
label="Comentario"
|
|
467
|
+
value={value}
|
|
468
|
+
onChange={(v) => setValue(v.toString())}
|
|
469
|
+
multiline
|
|
470
|
+
minRows={3}
|
|
471
|
+
maxRows={6}
|
|
472
|
+
fullWidth
|
|
473
|
+
/>
|
|
474
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
475
|
+
</Box>
|
|
476
|
+
);
|
|
477
|
+
},
|
|
478
|
+
parameters: {
|
|
479
|
+
docs: {
|
|
480
|
+
description: {
|
|
481
|
+
story: "Un campo de entrada multilínea (`multiline`) usando `minRows` y `maxRows` para auto-expandirse dentro de un rango. Útil para comentarios, descripciones o textos largos."
|
|
482
|
+
},
|
|
483
|
+
source: { code: MultilineInputDefinition.trim() }
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
459
488
|
export const CustomStyling: Story = {
|
|
460
489
|
render: () => {
|
|
461
490
|
const [bg, setBg] = useState('Fondo gris claro');
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// RadioGroup.definitions.ts — código fuente para la pestaña Docs de Storybook.
|
|
2
|
+
|
|
3
|
+
export const BasicRadioGroupDefinition = `
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { RadioGroup } from './RadioGroup';
|
|
6
|
+
import { Box, Typography } from '@mui/material';
|
|
7
|
+
|
|
8
|
+
const options = [
|
|
9
|
+
{ value: 'a', label: 'Opción A' },
|
|
10
|
+
{ value: 'b', label: 'Opción B' },
|
|
11
|
+
{ value: 'c', label: 'Opción C' },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export const BasicRadioGroupExample = () => {
|
|
15
|
+
const [value, setValue] = useState('a');
|
|
16
|
+
return (
|
|
17
|
+
<Box sx={{ width: 360 }}>
|
|
18
|
+
<RadioGroup
|
|
19
|
+
label="Selecciona una opción"
|
|
20
|
+
options={options}
|
|
21
|
+
value={value}
|
|
22
|
+
onChange={setValue}
|
|
23
|
+
/>
|
|
24
|
+
<Typography sx={{ mt: 2 }}>Valor actual: {value}</Typography>
|
|
25
|
+
</Box>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const ColumnRadioGroupDefinition = `
|
|
31
|
+
import React, { useState } from 'react';
|
|
32
|
+
import { RadioGroup } from './RadioGroup';
|
|
33
|
+
import { Box } from '@mui/material';
|
|
34
|
+
|
|
35
|
+
const options = [
|
|
36
|
+
{ value: 'sm', label: 'Pequeño' },
|
|
37
|
+
{ value: 'md', label: 'Mediano' },
|
|
38
|
+
{ value: 'lg', label: 'Grande' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export const ColumnRadioGroupExample = () => {
|
|
42
|
+
const [value, setValue] = useState('md');
|
|
43
|
+
return (
|
|
44
|
+
<Box sx={{ width: 360 }}>
|
|
45
|
+
<RadioGroup
|
|
46
|
+
label="Tamaño"
|
|
47
|
+
options={options}
|
|
48
|
+
value={value}
|
|
49
|
+
onChange={setValue}
|
|
50
|
+
row={false}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const RadioGroupWithErrorDefinition = `
|
|
58
|
+
import React, { useState } from 'react';
|
|
59
|
+
import { RadioGroup } from './RadioGroup';
|
|
60
|
+
import { Box } from '@mui/material';
|
|
61
|
+
|
|
62
|
+
const options = [
|
|
63
|
+
{ value: 'yes', label: 'Sí' },
|
|
64
|
+
{ value: 'no', label: 'No' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export const RadioGroupWithErrorExample = () => {
|
|
68
|
+
const [value, setValue] = useState('');
|
|
69
|
+
const hasError = !value;
|
|
70
|
+
return (
|
|
71
|
+
<Box sx={{ width: 360 }}>
|
|
72
|
+
<RadioGroup
|
|
73
|
+
label="¿Aceptas los términos?"
|
|
74
|
+
options={options}
|
|
75
|
+
value={value}
|
|
76
|
+
onChange={setValue}
|
|
77
|
+
error={hasError}
|
|
78
|
+
helperText={hasError ? 'Este campo es obligatorio' : ''}
|
|
79
|
+
/>
|
|
80
|
+
</Box>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
export const DisabledRadioGroupDefinition = `
|
|
86
|
+
import React, { useState } from 'react';
|
|
87
|
+
import { RadioGroup } from './RadioGroup';
|
|
88
|
+
import { Box } from '@mui/material';
|
|
89
|
+
|
|
90
|
+
const options = [
|
|
91
|
+
{ value: 'a', label: 'Opción A' },
|
|
92
|
+
{ value: 'b', label: 'Opción B', disabled: true },
|
|
93
|
+
{ value: 'c', label: 'Opción C' },
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
export const DisabledRadioGroupExample = () => {
|
|
97
|
+
const [value, setValue] = useState('a');
|
|
98
|
+
return (
|
|
99
|
+
<Box sx={{ width: 360 }}>
|
|
100
|
+
{/* Bloqueo total */}
|
|
101
|
+
<RadioGroup
|
|
102
|
+
label="Grupo deshabilitado"
|
|
103
|
+
options={options}
|
|
104
|
+
value={value}
|
|
105
|
+
onChange={setValue}
|
|
106
|
+
disabled
|
|
107
|
+
/>
|
|
108
|
+
{/* Bloqueo por opción */}
|
|
109
|
+
<RadioGroup
|
|
110
|
+
label="Opción B deshabilitada"
|
|
111
|
+
options={options}
|
|
112
|
+
value={value}
|
|
113
|
+
onChange={setValue}
|
|
114
|
+
sx={{ mt: 3 }}
|
|
115
|
+
/>
|
|
116
|
+
</Box>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
export const UnborderedRadioGroupDefinition = `
|
|
122
|
+
import React, { useState } from 'react';
|
|
123
|
+
import { RadioGroup } from './RadioGroup';
|
|
124
|
+
import { Box } from '@mui/material';
|
|
125
|
+
|
|
126
|
+
const options = [
|
|
127
|
+
{ value: 'a', label: 'Opción A' },
|
|
128
|
+
{ value: 'b', label: 'Opción B' },
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
export const UnborderedRadioGroupExample = () => {
|
|
132
|
+
const [value, setValue] = useState('a');
|
|
133
|
+
return (
|
|
134
|
+
<Box sx={{ width: 360 }}>
|
|
135
|
+
<RadioGroup
|
|
136
|
+
options={options}
|
|
137
|
+
value={value}
|
|
138
|
+
onChange={setValue}
|
|
139
|
+
bordered={false}
|
|
140
|
+
/>
|
|
141
|
+
</Box>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
`;
|
|
145
|
+
|
|
146
|
+
export const RHFRadioGroupDefinition = `
|
|
147
|
+
import React from 'react';
|
|
148
|
+
import { useForm } from 'react-hook-form';
|
|
149
|
+
import { RadioGroup } from './RadioGroup';
|
|
150
|
+
import { Box, Button, Typography } from '@mui/material';
|
|
151
|
+
|
|
152
|
+
const options = [
|
|
153
|
+
{ value: 'paypal', label: 'PayPal' },
|
|
154
|
+
{ value: 'card', label: 'Tarjeta' },
|
|
155
|
+
{ value: 'transfer', label: 'Transferencia' },
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
export const RHFRadioGroupExample = () => {
|
|
159
|
+
const { control, handleSubmit, watch } = useForm({
|
|
160
|
+
defaultValues: { paymentMethod: 'card' },
|
|
161
|
+
});
|
|
162
|
+
const value = watch('paymentMethod');
|
|
163
|
+
return (
|
|
164
|
+
<Box sx={{ width: 360 }} component="form" onSubmit={handleSubmit(console.log)}>
|
|
165
|
+
<RadioGroup
|
|
166
|
+
label="Método de pago"
|
|
167
|
+
options={options}
|
|
168
|
+
name="paymentMethod"
|
|
169
|
+
control={control}
|
|
170
|
+
validation={{ required: 'Selecciona un método' }}
|
|
171
|
+
/>
|
|
172
|
+
<Typography sx={{ mt: 2 }}>Valor en el form: {value}</Typography>
|
|
173
|
+
<Button type="submit" sx={{ mt: 1 }}>Enviar</Button>
|
|
174
|
+
</Box>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
`;
|