@soyfri/shared-library 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +8 -0
- package/.github/workflows/publish.yml +107 -0
- package/.prettierrc +3 -0
- package/.storybook/main.ts +19 -0
- package/.storybook/preview.ts +14 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/Dockerfile +37 -0
- package/build.js +102 -0
- package/chromatic.config.json +5 -0
- package/cleanDirectories.js +40 -0
- package/dist/README.md +243 -0
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Table/Table.js +1 -1
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -1
- package/dist/mui.d.ts +1 -0
- package/dist/package.json +197 -0
- package/package.json +4 -32
- package/rollup.config.cjs +87 -0
- package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
- package/src/components/ActionMenu/ActionMenu.tsx +174 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +272 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +123 -0
- package/src/components/AppBar/AppBarBrand.tsx +120 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
- package/src/components/AppBar/index.ts +25 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +477 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +748 -0
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +361 -0
- package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
- package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
- package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
- package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
- package/src/components/Autocomplete/index.ts +12 -0
- package/src/components/Avatar/Avatar.definitions.ts +162 -0
- package/src/components/Avatar/Avatar.stories.tsx +258 -0
- package/src/components/Avatar/Avatar.tsx +206 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.definition.ts +97 -0
- package/src/components/Button/Button.stories.tsx +285 -0
- package/src/components/Button/Button.tsx +67 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.definition.ts +5 -0
- package/src/components/Card/Card.stories.tsx +221 -0
- package/src/components/Card/Card.sx.ts +104 -0
- package/src/components/Card/Card.tsx +200 -0
- package/src/components/Card/index.ts +9 -0
- package/src/components/Chip/Chip.definitions.ts +167 -0
- package/src/components/Chip/Chip.stories.tsx +265 -0
- package/src/components/Chip/Chip.tsx +61 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Column/Column.tsx +29 -0
- package/src/components/Column/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.definitions.ts +228 -0
- package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +309 -0
- package/src/components/DatePicker/DatePicker.sx.ts +33 -0
- package/src/components/DatePicker/DatePicker.tsx +189 -0
- package/src/components/DatePicker/DatePicker.types.ts +10 -0
- package/src/components/DatePicker/index.ts +9 -0
- package/src/components/DateRangePicker/DateRangePicker.definitions.ts +191 -0
- package/src/components/DateRangePicker/DateRangePicker.stories.tsx +252 -0
- package/src/components/DateRangePicker/DateRangePicker.tsx +56 -0
- package/src/components/DateRangePicker/index.ts +1 -0
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +256 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +418 -0
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +225 -0
- package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
- package/src/components/DateTimePicker/index.ts +9 -0
- package/src/components/Drawer/Drawer.stories.tsx +270 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +214 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +110 -0
- package/src/components/Drawer/index.ts +10 -0
- package/src/components/Flyout/Flyout.stories.tsx +282 -0
- package/src/components/Flyout/Flyout.tsx +122 -0
- package/src/components/Flyout/index.ts +1 -0
- package/src/components/Gallery/Gallery.definition.tsx +37 -0
- package/src/components/Gallery/Gallery.stories.tsx +82 -0
- package/src/components/Gallery/Gallery.tsx +118 -0
- package/src/components/Gallery/GalleryLightbox.tsx +170 -0
- package/src/components/Gallery/GalleryMain.tsx +84 -0
- package/src/components/Gallery/GalleryThumbnails.tsx +106 -0
- package/src/components/Gallery/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +121 -0
- package/src/components/Icon/Icon.tsx +175 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.definitions.ts +324 -0
- package/src/components/Input/Input.helpers.ts +49 -0
- package/src/components/Input/Input.stories.tsx +499 -0
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +141 -0
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/index.ts +9 -0
- package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +267 -0
- package/src/components/InputGroup/InputGroup.tsx +179 -0
- package/src/components/InputGroup/index.ts +1 -0
- package/src/components/MenuButton/MenuButton.stories.tsx +197 -0
- package/src/components/MenuButton/MenuButton.tsx +100 -0
- package/src/components/MenuButton/index.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +721 -0
- package/src/components/Modal/Modal.tsx +355 -0
- package/src/components/Modal/ModalBody.tsx +16 -0
- package/src/components/Modal/ModalFooter.tsx +71 -0
- package/src/components/Modal/ModalHeader.tsx +18 -0
- package/src/components/Modal/index.ts +6 -0
- package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
- package/src/components/PageLoader/PageLoader.tsx +96 -0
- package/src/components/PageLoader/index.ts +2 -0
- package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
- package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
- package/src/components/ScrollTopButton/index.ts +8 -0
- package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
- package/src/components/Select/Select.definitions.ts +602 -0
- package/src/components/Select/Select.helpers.ts +71 -0
- package/src/components/Select/Select.stories.tsx +687 -0
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +429 -0
- package/src/components/Select/Select.types.ts +15 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
- package/src/components/Select/_parts/SelectValue.tsx +96 -0
- package/src/components/Select/index.ts +14 -0
- package/src/components/Stat/Stat.stories.tsx +85 -0
- package/src/components/Stat/Stat.tsx +117 -0
- package/src/components/Stat/index.ts +2 -0
- package/src/components/StatusMessage/StatusMessage.stories.tsx +130 -0
- package/src/components/StatusMessage/StatusMessage.tsx +162 -0
- package/src/components/StatusMessage/index.ts +2 -0
- package/src/components/Stepper/Step.tsx +21 -0
- package/src/components/Stepper/Stepper.definition.ts +75 -0
- package/src/components/Stepper/Stepper.stories.tsx +122 -0
- package/src/components/Stepper/Stepper.tsx +75 -0
- package/src/components/Stepper/index.ts +2 -0
- package/src/components/Table/EmptyTable.png +0 -0
- package/src/components/Table/Table.definition.ts +580 -0
- package/src/components/Table/Table.stories.tsx +853 -0
- package/src/components/Table/Table.tsx +495 -0
- package/src/components/Table/data.ts +134 -0
- package/src/components/Table/exportsUtils.ts +195 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/Table/types.ts +34 -0
- package/src/components/Tabs/Tab.definition.ts +53 -0
- package/src/components/Tabs/Tab.tsx +19 -0
- package/src/components/Tabs/Tabs.stories.tsx +118 -0
- package/src/components/Tabs/Tabs.tsx +99 -0
- package/src/components/Tabs/_tabUtils.tsx +4 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Timeline/Timeline.definition.ts +43 -0
- package/src/components/Timeline/Timeline.stories.tsx +108 -0
- package/src/components/Timeline/Timeline.tsx +49 -0
- package/src/components/Timeline/TimelineItem.tsx +31 -0
- package/src/components/Timeline/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +129 -0
- package/src/components/Tooltip/Tooltip.tsx +58 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/_shared/formField.sx.ts +118 -0
- package/src/components/_shared/resolvePreset.ts +35 -0
- package/src/hooks/ClipBoard/ClipBoard.stories.tsx +168 -0
- package/src/hooks/ClipBoard/ClipBoard.tsx +131 -0
- package/src/hooks/ClipBoard/ClipboardUnifiedDemo.tsx +111 -0
- package/src/hooks/ClipBoard/index.ts +1 -0
- package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
- package/src/hooks/Wizard/WizardContext.tsx +166 -0
- package/src/hooks/Wizard/index.ts +6 -0
- package/src/hooks/Wizard/useWizard.ts +13 -0
- package/src/index.ts +17 -0
- package/src/mui.ts +54 -0
- package/src/styles.css +3 -0
- package/src/theme/componentStyles.ts +47 -0
- package/src/theme/tokens.ts +43 -0
- package/tailwind.config.js +10 -0
- package/tsconfig.json +48 -0
- package/tsup.config.js +41 -0
- package/vite.config.js +132 -0
- package/vitest.config.ts +35 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { Stack, useMediaQuery } from "@mui/material";
|
|
3
|
+
import { GalleryThumbnails } from "./GalleryThumbnails";
|
|
4
|
+
import { GalleryMain } from "./GalleryMain";
|
|
5
|
+
import { GalleryLightbox } from "./GalleryLightbox";
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
8
|
+
items: Array<{
|
|
9
|
+
url: string;
|
|
10
|
+
type: "image" | "video" | string;
|
|
11
|
+
title: string;
|
|
12
|
+
thumbnail: string;
|
|
13
|
+
}>;
|
|
14
|
+
maxWidth?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export const Gallery:React.FC<Props> = ({ items, maxWidth='600px' }: Props) => {
|
|
19
|
+
const isMobile = useMediaQuery("(max-width:700px)");
|
|
20
|
+
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
21
|
+
const [openLightbox, setOpenLightbox] = useState(false);
|
|
22
|
+
const [zoom, setZoom] = useState(1);
|
|
23
|
+
const [rotation, setRotation] = useState(0);
|
|
24
|
+
const videoRef = useRef<HTMLVideoElement | null>(null);
|
|
25
|
+
|
|
26
|
+
const [thumbStartIdx, setThumbStartIdx] = useState(0);
|
|
27
|
+
const THUMB_VISIBLE_COUNT = isMobile ? 3 : 5;
|
|
28
|
+
|
|
29
|
+
// Flechas para miniaturas
|
|
30
|
+
const handleThumbUp = () => {
|
|
31
|
+
setThumbStartIdx((prev) => Math.max(0, prev - 1));
|
|
32
|
+
};
|
|
33
|
+
const handleThumbDown = () => {
|
|
34
|
+
setThumbStartIdx((prev) =>
|
|
35
|
+
Math.min(items.length - THUMB_VISIBLE_COUNT, prev + 1)
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Navegación entre imágenes
|
|
40
|
+
const handlePrev = () => {
|
|
41
|
+
setSelectedIdx((idx) => (idx === 0 ? items.length - 1 : idx - 1));
|
|
42
|
+
};
|
|
43
|
+
const handleNext = () => {
|
|
44
|
+
setSelectedIdx((idx) =>
|
|
45
|
+
idx === items.length - 1 ? 0 : idx + 1
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Acciones de teclado
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!openLightbox) return;
|
|
52
|
+
const handleKey = (e: KeyboardEvent) => {
|
|
53
|
+
switch (e.key) {
|
|
54
|
+
case "ArrowLeft":
|
|
55
|
+
handlePrev();
|
|
56
|
+
break;
|
|
57
|
+
case "ArrowRight":
|
|
58
|
+
handleNext();
|
|
59
|
+
break;
|
|
60
|
+
case "Escape":
|
|
61
|
+
setOpenLightbox(false);
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener("keydown", handleKey);
|
|
68
|
+
return () => window.removeEventListener("keydown", handleKey);
|
|
69
|
+
}, [openLightbox, items.length]);
|
|
70
|
+
|
|
71
|
+
// Reset zoom/rotación y autoplay video
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (
|
|
74
|
+
openLightbox &&
|
|
75
|
+
items[selectedIdx]?.type === "video" &&
|
|
76
|
+
videoRef.current
|
|
77
|
+
) {
|
|
78
|
+
videoRef.current.currentTime = 0;
|
|
79
|
+
videoRef.current.play();
|
|
80
|
+
}
|
|
81
|
+
setZoom(1);
|
|
82
|
+
setRotation(0);
|
|
83
|
+
}, [openLightbox, selectedIdx, items]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Stack direction={isMobile ? "column" : "row"} gap={3} sx={{ maxWidth: maxWidth, mx: "auto", minHeight: 300 }}>
|
|
87
|
+
<GalleryThumbnails
|
|
88
|
+
items={items}
|
|
89
|
+
selectedIdx={selectedIdx}
|
|
90
|
+
onSelect={setSelectedIdx}
|
|
91
|
+
thumbStartIdx={thumbStartIdx}
|
|
92
|
+
THUMB_VISIBLE_COUNT={THUMB_VISIBLE_COUNT}
|
|
93
|
+
handleThumbUp={handleThumbUp}
|
|
94
|
+
handleThumbDown={handleThumbDown}
|
|
95
|
+
isMobile={isMobile}
|
|
96
|
+
/>
|
|
97
|
+
<GalleryMain
|
|
98
|
+
item={items[selectedIdx]}
|
|
99
|
+
onOpenLightbox={() => setOpenLightbox(true)}
|
|
100
|
+
isMobile={isMobile}
|
|
101
|
+
/>
|
|
102
|
+
<GalleryLightbox
|
|
103
|
+
open={openLightbox}
|
|
104
|
+
onClose={() => setOpenLightbox(false)}
|
|
105
|
+
item={items[selectedIdx]}
|
|
106
|
+
handlePrev={handlePrev}
|
|
107
|
+
handleNext={handleNext}
|
|
108
|
+
zoom={zoom}
|
|
109
|
+
setZoom={setZoom}
|
|
110
|
+
rotation={rotation}
|
|
111
|
+
setRotation={setRotation}
|
|
112
|
+
videoRef={videoRef}
|
|
113
|
+
/>
|
|
114
|
+
</Stack>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default Gallery;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogActions,
|
|
6
|
+
Stack,
|
|
7
|
+
IconButton,
|
|
8
|
+
Box,
|
|
9
|
+
Typography,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
|
|
12
|
+
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
|
13
|
+
import ZoomInIcon from "@mui/icons-material/ZoomIn";
|
|
14
|
+
import ZoomOutIcon from "@mui/icons-material/ZoomOut";
|
|
15
|
+
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
|
16
|
+
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
|
17
|
+
import RestartAltIcon from "@mui/icons-material/RestartAlt";
|
|
18
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
19
|
+
import { Button } from "../Button";
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
open: boolean;
|
|
24
|
+
onClose: () => void;
|
|
25
|
+
item: {
|
|
26
|
+
url: string;
|
|
27
|
+
type: "image" | "video" | string;
|
|
28
|
+
title: string;
|
|
29
|
+
thumbnail: string;
|
|
30
|
+
};
|
|
31
|
+
handlePrev: () => void;
|
|
32
|
+
handleNext: () => void;
|
|
33
|
+
zoom: number;
|
|
34
|
+
setZoom: React.Dispatch<React.SetStateAction<number>>;
|
|
35
|
+
rotation: number;
|
|
36
|
+
setRotation: React.Dispatch<React.SetStateAction<number>>;
|
|
37
|
+
videoRef?: React.RefObject<HTMLVideoElement | null>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const GalleryLightbox = ({
|
|
41
|
+
open,
|
|
42
|
+
onClose,
|
|
43
|
+
item,
|
|
44
|
+
handlePrev,
|
|
45
|
+
handleNext,
|
|
46
|
+
zoom,
|
|
47
|
+
setZoom,
|
|
48
|
+
rotation,
|
|
49
|
+
setRotation,
|
|
50
|
+
videoRef,
|
|
51
|
+
}: Props) => (
|
|
52
|
+
<Dialog open={open} onClose={onClose} fullWidth maxWidth="lg">
|
|
53
|
+
<DialogContent
|
|
54
|
+
sx={{
|
|
55
|
+
minHeight: 431,
|
|
56
|
+
display: "flex",
|
|
57
|
+
flexDirection: "column",
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
gap: 2,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<Stack direction="row" justifyContent="space-between" alignItems="center" width="100%">
|
|
64
|
+
<IconButton onClick={handlePrev}>
|
|
65
|
+
<ArrowBackIosNewIcon />
|
|
66
|
+
</IconButton>
|
|
67
|
+
<Typography variant="subtitle1" fontWeight={600} sx={{ flex: 1, textAlign: "center" }}>
|
|
68
|
+
{item.title}
|
|
69
|
+
</Typography>
|
|
70
|
+
<IconButton onClick={handleNext}>
|
|
71
|
+
<ArrowForwardIosIcon />
|
|
72
|
+
</IconButton>
|
|
73
|
+
</Stack>
|
|
74
|
+
{item.type === "video" ? (
|
|
75
|
+
<Box
|
|
76
|
+
component="video"
|
|
77
|
+
key={item.url}
|
|
78
|
+
ref={videoRef}
|
|
79
|
+
src={item.url}
|
|
80
|
+
controls
|
|
81
|
+
autoPlay
|
|
82
|
+
sx={{
|
|
83
|
+
width: "100%",
|
|
84
|
+
maxWidth: "900px",
|
|
85
|
+
maxHeight: "70vh",
|
|
86
|
+
objectFit: "contain",
|
|
87
|
+
bgcolor: "#000",
|
|
88
|
+
borderRadius: 1,
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
) : (
|
|
92
|
+
<Box
|
|
93
|
+
component="img"
|
|
94
|
+
src={item.url}
|
|
95
|
+
alt={item.title}
|
|
96
|
+
sx={{
|
|
97
|
+
transform: `scale(${zoom}) rotate(${rotation}deg)`,
|
|
98
|
+
transition: "transform 0.2s ease",
|
|
99
|
+
width: "100%",
|
|
100
|
+
maxWidth: "900px",
|
|
101
|
+
maxHeight: "70vh",
|
|
102
|
+
objectFit: "contain",
|
|
103
|
+
borderRadius: 1,
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</DialogContent>
|
|
108
|
+
<DialogActions
|
|
109
|
+
sx={{
|
|
110
|
+
display: "flex",
|
|
111
|
+
justifyContent: item.type === 'image' ? "space-between" : "end",
|
|
112
|
+
flexWrap: "wrap",
|
|
113
|
+
gap: 1,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
|
|
117
|
+
{item.type === 'image' && <>
|
|
118
|
+
<Stack direction="row" spacing={1}>
|
|
119
|
+
<Button
|
|
120
|
+
variant="outlined"
|
|
121
|
+
startIcon={<ZoomInIcon />}
|
|
122
|
+
onClick={() => setZoom((z) => z + 0.25)}
|
|
123
|
+
>
|
|
124
|
+
Zoom +
|
|
125
|
+
</Button>
|
|
126
|
+
<Button
|
|
127
|
+
variant="outlined"
|
|
128
|
+
startIcon={<ZoomOutIcon />}
|
|
129
|
+
onClick={() => setZoom((z) => Math.max(0.25, z - 0.25))}
|
|
130
|
+
>
|
|
131
|
+
Zoom −
|
|
132
|
+
</Button>
|
|
133
|
+
</Stack>
|
|
134
|
+
<Stack direction="row" spacing={1}>
|
|
135
|
+
<Button
|
|
136
|
+
variant="outlined"
|
|
137
|
+
onClick={() => setRotation((r) => r - 90)}
|
|
138
|
+
>
|
|
139
|
+
<RotateLeftIcon />
|
|
140
|
+
</Button>
|
|
141
|
+
<Button
|
|
142
|
+
variant="outlined"
|
|
143
|
+
onClick={() => setRotation((r) => r + 90)}
|
|
144
|
+
>
|
|
145
|
+
<RotateRightIcon />
|
|
146
|
+
</Button>
|
|
147
|
+
</Stack>
|
|
148
|
+
<Button
|
|
149
|
+
variant="outlined"
|
|
150
|
+
startIcon={<RestartAltIcon />}
|
|
151
|
+
onClick={() => {
|
|
152
|
+
setZoom(1);
|
|
153
|
+
setRotation(0);
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
Reset
|
|
157
|
+
</Button>
|
|
158
|
+
|
|
159
|
+
</>
|
|
160
|
+
}
|
|
161
|
+
<Button
|
|
162
|
+
variant="contained"
|
|
163
|
+
startIcon={<CloseIcon />}
|
|
164
|
+
onClick={onClose}
|
|
165
|
+
>
|
|
166
|
+
Cerrar
|
|
167
|
+
</Button>
|
|
168
|
+
</DialogActions>
|
|
169
|
+
</Dialog >
|
|
170
|
+
);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, IconButton } from "@mui/material";
|
|
3
|
+
import FullscreenIcon from "@mui/icons-material/Fullscreen";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
item: {
|
|
7
|
+
url: string;
|
|
8
|
+
type: "image" | "video" | string;
|
|
9
|
+
title: string;
|
|
10
|
+
thumbnail: string;
|
|
11
|
+
};
|
|
12
|
+
onOpenLightbox: () => void;
|
|
13
|
+
isMobile: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const GalleryMain = ({ item, onOpenLightbox, isMobile }: Props) => (
|
|
17
|
+
<Box
|
|
18
|
+
sx={{
|
|
19
|
+
width: isMobile ? "80%" : '100%',
|
|
20
|
+
maxHeight: 431,
|
|
21
|
+
maxWidth: isMobile ? "80%" : '100%',
|
|
22
|
+
display: "flex",
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
position: "relative",
|
|
26
|
+
borderRadius: 1,
|
|
27
|
+
bgcolor: "#f8f9fa",
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
mx: "auto",
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Box
|
|
33
|
+
sx={{
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: "100%",
|
|
36
|
+
cursor: "pointer",
|
|
37
|
+
display: "flex",
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
}}
|
|
41
|
+
onClick={onOpenLightbox}
|
|
42
|
+
>
|
|
43
|
+
{item.type === "video" ? (
|
|
44
|
+
<Box
|
|
45
|
+
component="video"
|
|
46
|
+
controls
|
|
47
|
+
src={item.url}
|
|
48
|
+
sx={{
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "100%",
|
|
51
|
+
objectFit: "contain",
|
|
52
|
+
bgcolor: "#000",
|
|
53
|
+
borderRadius: 1,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
) : (
|
|
57
|
+
<Box
|
|
58
|
+
component="img"
|
|
59
|
+
src={item.url}
|
|
60
|
+
alt={item.title}
|
|
61
|
+
sx={{
|
|
62
|
+
width: "100%",
|
|
63
|
+
height: "100%",
|
|
64
|
+
objectFit: "contain",
|
|
65
|
+
borderRadius: 1,
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</Box>
|
|
70
|
+
<IconButton
|
|
71
|
+
onClick={onOpenLightbox}
|
|
72
|
+
sx={{
|
|
73
|
+
position: "absolute",
|
|
74
|
+
top: 16,
|
|
75
|
+
right: 16,
|
|
76
|
+
bgcolor: "#1976d2",
|
|
77
|
+
"&:hover": { bgcolor: "#1565c0" },
|
|
78
|
+
boxShadow: 2,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<FullscreenIcon sx={{ color: "#fff" }} />
|
|
82
|
+
</IconButton>
|
|
83
|
+
</Box>
|
|
84
|
+
);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, IconButton } from "@mui/material";
|
|
3
|
+
import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
|
|
4
|
+
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
5
|
+
import KeyboardArrowLeftIcon from "@mui/icons-material/KeyboardArrowLeft";
|
|
6
|
+
import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
items: Array<{
|
|
11
|
+
url: string;
|
|
12
|
+
type: string;
|
|
13
|
+
title: string;
|
|
14
|
+
thumbnail: string;
|
|
15
|
+
}>;
|
|
16
|
+
selectedIdx: number;
|
|
17
|
+
onSelect: (idx: number) => void;
|
|
18
|
+
thumbStartIdx: number;
|
|
19
|
+
THUMB_VISIBLE_COUNT: number;
|
|
20
|
+
handleThumbUp: () => void;
|
|
21
|
+
handleThumbDown: () => void;
|
|
22
|
+
isMobile: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const GalleryThumbnails = ({
|
|
26
|
+
items,
|
|
27
|
+
selectedIdx,
|
|
28
|
+
onSelect,
|
|
29
|
+
thumbStartIdx,
|
|
30
|
+
THUMB_VISIBLE_COUNT,
|
|
31
|
+
handleThumbUp,
|
|
32
|
+
handleThumbDown,
|
|
33
|
+
isMobile,
|
|
34
|
+
}: Props) => (
|
|
35
|
+
<Box
|
|
36
|
+
sx={{
|
|
37
|
+
display: "flex",
|
|
38
|
+
flexDirection: isMobile ? "row" : "column",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
minWidth: 70,
|
|
41
|
+
width: 70,
|
|
42
|
+
borderRadius: 1,
|
|
43
|
+
bgcolor: "#f8f9fa",
|
|
44
|
+
boxSizing: "border-box",
|
|
45
|
+
py: 1,
|
|
46
|
+
mb: isMobile ? 2 : 0,
|
|
47
|
+
px: isMobile ? 1 : 0,
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<IconButton
|
|
51
|
+
size="small"
|
|
52
|
+
onClick={handleThumbUp}
|
|
53
|
+
disabled={thumbStartIdx === 0}
|
|
54
|
+
sx={{ mb: isMobile ? 0 : 1, mr: isMobile ? 1 : 0 }}
|
|
55
|
+
>
|
|
56
|
+
{isMobile ? <KeyboardArrowLeftIcon /> : <KeyboardArrowUpIcon />}
|
|
57
|
+
</IconButton>
|
|
58
|
+
{items
|
|
59
|
+
.slice(thumbStartIdx, thumbStartIdx + THUMB_VISIBLE_COUNT)
|
|
60
|
+
.map((item, idx) => {
|
|
61
|
+
const realIdx = thumbStartIdx + idx;
|
|
62
|
+
return (
|
|
63
|
+
<Box
|
|
64
|
+
key={realIdx}
|
|
65
|
+
onClick={() => onSelect(realIdx)}
|
|
66
|
+
sx={{
|
|
67
|
+
cursor: "pointer",
|
|
68
|
+
width: 60,
|
|
69
|
+
height: 60,
|
|
70
|
+
borderRadius: 1,
|
|
71
|
+
border:
|
|
72
|
+
selectedIdx === realIdx
|
|
73
|
+
? "2px solid #1976d2"
|
|
74
|
+
: "2px solid #eee",
|
|
75
|
+
overflow: "hidden",
|
|
76
|
+
bgcolor: "#eee",
|
|
77
|
+
display: "flex",
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
justifyContent: "center",
|
|
80
|
+
flexShrink: 0,
|
|
81
|
+
m: isMobile ? "0 4px" : "4px 0",
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<Box
|
|
85
|
+
component="img"
|
|
86
|
+
src={item.thumbnail}
|
|
87
|
+
alt={item.title}
|
|
88
|
+
sx={{
|
|
89
|
+
width: "100%",
|
|
90
|
+
height: "100%",
|
|
91
|
+
objectFit: "cover",
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</Box>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
<IconButton
|
|
98
|
+
size="small"
|
|
99
|
+
onClick={handleThumbDown}
|
|
100
|
+
disabled={thumbStartIdx + THUMB_VISIBLE_COUNT >= items.length}
|
|
101
|
+
sx={{ mt: isMobile ? 0 : 1, ml: isMobile ? 1 : 0 }}
|
|
102
|
+
>
|
|
103
|
+
{isMobile ? <KeyboardArrowRightIcon /> : <KeyboardArrowDownIcon />}
|
|
104
|
+
</IconButton>
|
|
105
|
+
</Box>
|
|
106
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Gallery } from './Gallery';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Icon } from './Icon';
|
|
3
|
+
import NotificationsIcon from '@mui/icons-material/Notifications';
|
|
4
|
+
import SettingsIcon from '@mui/icons-material/Settings';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Icon> = {
|
|
7
|
+
title: 'Components/Icon',
|
|
8
|
+
component: Icon,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component:
|
|
14
|
+
'Componente Icon con soporte para 3 fuentes: `children` (elemento MUI), `path` (string SVG inline, para los iconos custom de Metronic) y `url` (ruta a un archivo `.svg`).',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof Icon>;
|
|
23
|
+
|
|
24
|
+
// ── Modo legacy: children ──────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
children: <NotificationsIcon />,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Outlined: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
children: <SettingsIcon />,
|
|
35
|
+
outlined: true,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Spinning: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
children: <SettingsIcon />,
|
|
42
|
+
spin: true,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const WithBadge: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
children: <NotificationsIcon />,
|
|
49
|
+
badge: 3,
|
|
50
|
+
badgeColor: 'error',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const LargeWhiteIcon: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
children: <NotificationsIcon />,
|
|
57
|
+
size: 'xl',
|
|
58
|
+
white: true,
|
|
59
|
+
badge: 10,
|
|
60
|
+
badgeColor: 'primary',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ── Nuevas fuentes: path + url ────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
export const FromPathD: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
path: 'M12 2L2 22h20L12 2zm0 3.83L19.17 20H4.83L12 5.83zM11 16h2v2h-2v-2zm0-6h2v5h-2v-5z',
|
|
69
|
+
color: '#f59e0b',
|
|
70
|
+
size: 'lg',
|
|
71
|
+
},
|
|
72
|
+
parameters: {
|
|
73
|
+
docs: {
|
|
74
|
+
description: {
|
|
75
|
+
story:
|
|
76
|
+
'Renderiza un SVG a partir del atributo `d` de un `<path>`. Es la forma en que Metronic suele entregar iconos custom.',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const FromFullSvg: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
path: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2" stroke="white" stroke-width="2" fill="none"/></svg>',
|
|
85
|
+
color: '#2563eb',
|
|
86
|
+
size: 'lg',
|
|
87
|
+
},
|
|
88
|
+
parameters: {
|
|
89
|
+
docs: {
|
|
90
|
+
description: {
|
|
91
|
+
story:
|
|
92
|
+
'Si `path` contiene un `<svg>` completo (con `viewBox`, múltiples paths, etc), se inyecta tal cual.',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const FromUrl: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
url: 'https://upload.wikimedia.org/wikipedia/commons/4/4f/SVG_Logo.svg',
|
|
101
|
+
alt: 'SVG logo',
|
|
102
|
+
size: 'xl',
|
|
103
|
+
},
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
description: {
|
|
107
|
+
story:
|
|
108
|
+
'Renderiza un `<img>` apuntando a un archivo `.svg`. Útil para assets locales (p.ej. `/public/icons/foo.svg`).',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const PathWithBadge: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
path: 'M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z',
|
|
117
|
+
badge: '9+',
|
|
118
|
+
badgeColor: 'error',
|
|
119
|
+
size: 'md',
|
|
120
|
+
},
|
|
121
|
+
};
|