oraculo-ui 0.1.9 → 0.1.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.
@@ -1,175 +0,0 @@
1
- import {
2
- ChevronLeftRounded_default,
3
- ChevronRightRounded_default,
4
- OraculoGameSlide_default
5
- } from "./chunk-AIT7B2J3.mjs";
6
- import {
7
- OraculoSectionTitle
8
- } from "./chunk-5GTDKE3I.mjs";
9
- import {
10
- OraculoCarousel_default
11
- } from "./chunk-VHW77D2M.mjs";
12
- import {
13
- OraculoButton
14
- } from "./chunk-IJQLK4NO.mjs";
15
-
16
- // src/organisms/OraculoSeccionVirtuales/OraculoSeccionVirtuales.tsx
17
- import { useRef, useState } from "react";
18
- import Stack from "@mui/material/Stack";
19
- import Box from "@mui/material/Box";
20
- import { jsx, jsxs } from "react/jsx-runtime";
21
- var buildVirtualSlides = (games, mosaicFirst = true, gridSize = 4) => {
22
- const baseItems = games.map((g, idx) => {
23
- var _a, _b;
24
- return {
25
- id: (_a = g.orden) != null ? _a : idx,
26
- imageUrl: (_b = g.logo) != null ? _b : ""
27
- };
28
- });
29
- if (!baseItems.length) return [];
30
- const slides = [];
31
- let start = 0;
32
- if (mosaicFirst) {
33
- const take = Math.min(baseItems.length, 5);
34
- slides.push({
35
- id: "mosaic-0",
36
- kind: "mosaic",
37
- items: baseItems.slice(0, take)
38
- });
39
- start = take;
40
- }
41
- while (start < baseItems.length) {
42
- const end = Math.min(start + gridSize, baseItems.length);
43
- slides.push({
44
- id: `grid-${start}`,
45
- kind: "grid",
46
- items: baseItems.slice(start, end)
47
- });
48
- start = end;
49
- }
50
- return slides;
51
- };
52
- var OraculoSeccionVirtuales = ({
53
- items,
54
- title = "Virtuales",
55
- iconUrl = "/assets/img/home/Virtuales/virtuales.svg",
56
- onItemClick,
57
- onViewMore,
58
- mosaicFirst = true,
59
- gridSize = 4
60
- }) => {
61
- const carouselRef = useRef(null);
62
- const [navState, setNavState] = useState({ isStart: true, isEnd: false });
63
- const slides = buildVirtualSlides(items, mosaicFirst, gridSize);
64
- const handlePrev = () => {
65
- var _a;
66
- (_a = carouselRef.current) == null ? void 0 : _a.prev();
67
- };
68
- const handleNext = () => {
69
- var _a;
70
- (_a = carouselRef.current) == null ? void 0 : _a.next();
71
- };
72
- const handleViewMore = () => {
73
- onViewMore == null ? void 0 : onViewMore();
74
- };
75
- return /* @__PURE__ */ jsx("section", { children: /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 2, useFlexGap: true, children: [
76
- /* @__PURE__ */ jsxs(
77
- Box,
78
- {
79
- sx: {
80
- display: "grid",
81
- gridTemplateColumns: "1fr auto auto",
82
- alignItems: "center",
83
- columnGap: 1.5,
84
- rowGap: 1
85
- },
86
- children: [
87
- /* @__PURE__ */ jsx(
88
- OraculoSectionTitle,
89
- {
90
- title,
91
- iconUrl,
92
- size: "md"
93
- }
94
- ),
95
- /* @__PURE__ */ jsxs(
96
- Box,
97
- {
98
- sx: {
99
- display: "flex",
100
- gap: 1,
101
- justifyContent: "flex-end"
102
- },
103
- children: [
104
- /* @__PURE__ */ jsx(
105
- OraculoButton,
106
- {
107
- ariaLabel: "Anterior",
108
- variant: "secondary",
109
- iconOnly: true,
110
- leftIcon: /* @__PURE__ */ jsx(ChevronLeftRounded_default, {}),
111
- onClick: handlePrev,
112
- disabled: navState.isStart
113
- }
114
- ),
115
- /* @__PURE__ */ jsx(
116
- OraculoButton,
117
- {
118
- ariaLabel: "Siguiente",
119
- variant: "secondary",
120
- iconOnly: true,
121
- rightIcon: /* @__PURE__ */ jsx(ChevronRightRounded_default, {}),
122
- onClick: handleNext,
123
- disabled: navState.isEnd
124
- }
125
- )
126
- ]
127
- }
128
- ),
129
- /* @__PURE__ */ jsx(Box, { sx: { justifySelf: "end" }, children: /* @__PURE__ */ jsx(OraculoButton, { variant: "secondary", onClick: handleViewMore, children: "Ver m\xE1s" }) })
130
- ]
131
- }
132
- ),
133
- /* @__PURE__ */ jsx(
134
- OraculoCarousel_default,
135
- {
136
- ref: carouselRef,
137
- items: slides,
138
- perPage: 1,
139
- gap: "0",
140
- options: {
141
- autoWidth: true,
142
- gap: "12px",
143
- trimSpace: false,
144
- pagination: false,
145
- arrows: false,
146
- drag: true,
147
- focus: "start",
148
- perMove: 1
149
- },
150
- renderItem: (slide) => /* @__PURE__ */ jsx("div", { style: { alignSelf: "start" }, children: /* @__PURE__ */ jsx(
151
- OraculoGameSlide_default,
152
- {
153
- items: slide.items,
154
- layout: slide.kind === "mosaic" ? "mosaic" : "grid",
155
- onClick: (itm) => {
156
- const game = items.find(
157
- (g, idx) => {
158
- var _a;
159
- return ((_a = g.orden) != null ? _a : idx) === itm.id;
160
- }
161
- );
162
- if (game) onItemClick == null ? void 0 : onItemClick(game);
163
- }
164
- }
165
- ) }),
166
- onMove: ({ isStart, isEnd }) => setNavState({ isStart, isEnd })
167
- }
168
- )
169
- ] }) });
170
- };
171
- var OraculoSeccionVirtuales_default = OraculoSeccionVirtuales;
172
-
173
- export {
174
- OraculoSeccionVirtuales_default
175
- };