@solostylist/ui-kit 1.0.139 → 1.0.141
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.
|
@@ -41,6 +41,10 @@ export interface SGalleryProps {
|
|
|
41
41
|
mediaItems: MediaItemType[];
|
|
42
42
|
/** Layout variant to use (default: 'masonry') */
|
|
43
43
|
variant?: GalleryLayoutVariant;
|
|
44
|
+
/** Loading state - shows skeleton placeholders matching the variant layout */
|
|
45
|
+
loading?: boolean;
|
|
46
|
+
/** Number of skeleton items to show when loading (default: 6) */
|
|
47
|
+
skeletonCount?: number;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
50
|
* SGallery - A sophisticated media gallery with drag-and-drop, modal viewing, and animations.
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Box as
|
|
4
|
-
import { AnimatePresence as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
const e =
|
|
9
|
-
return
|
|
10
|
-
const
|
|
1
|
+
import { j as t } from "../jsx-runtime-OVHDjVDe.js";
|
|
2
|
+
import { useState as y, useId as R, useEffect as b, useRef as D } from "react";
|
|
3
|
+
import { Box as a, Paper as w, Skeleton as E, Typography as j } from "@mui/material";
|
|
4
|
+
import { AnimatePresence as M, motion as I } from "framer-motion";
|
|
5
|
+
import V from "../s-image-modal/s-image-modal.js";
|
|
6
|
+
import P from "../s-lazy-image/s-lazy-image.js";
|
|
7
|
+
const A = ({ item: i, sx: o, onClick: s }) => {
|
|
8
|
+
const e = D(null), [n, l] = y(!1), [u, f] = y(!0);
|
|
9
|
+
return b(() => {
|
|
10
|
+
const c = {
|
|
11
11
|
root: null,
|
|
12
12
|
rootMargin: "50px",
|
|
13
13
|
// Start loading 50px before entering viewport
|
|
14
14
|
threshold: 0.1
|
|
15
15
|
// Trigger when 10% of video is visible
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
return e.current &&
|
|
20
|
-
e.current &&
|
|
16
|
+
}, g = new IntersectionObserver((d) => {
|
|
17
|
+
d.forEach((r) => l(r.isIntersecting));
|
|
18
|
+
}, c);
|
|
19
|
+
return e.current && g.observe(e.current), () => {
|
|
20
|
+
e.current && g.unobserve(e.current);
|
|
21
21
|
};
|
|
22
|
-
}, []),
|
|
23
|
-
let
|
|
24
|
-
return
|
|
25
|
-
if (!(!e.current || !
|
|
22
|
+
}, []), b(() => {
|
|
23
|
+
let c = !0;
|
|
24
|
+
return n ? (async () => {
|
|
25
|
+
if (!(!e.current || !n || !c))
|
|
26
26
|
try {
|
|
27
|
-
e.current.readyState >= 3 ? (
|
|
28
|
-
e.current && (e.current.oncanplay = () =>
|
|
29
|
-
}),
|
|
30
|
-
} catch (
|
|
31
|
-
console.warn("Video playback failed:",
|
|
27
|
+
e.current.readyState >= 3 ? (f(!1), await e.current.play()) : (f(!0), await new Promise((d) => {
|
|
28
|
+
e.current && (e.current.oncanplay = () => d());
|
|
29
|
+
}), c && (f(!1), await e.current.play()));
|
|
30
|
+
} catch (d) {
|
|
31
|
+
console.warn("Video playback failed:", d);
|
|
32
32
|
}
|
|
33
33
|
})() : e.current && e.current.pause(), () => {
|
|
34
|
-
|
|
34
|
+
c = !1, e.current && (e.current.pause(), e.current.removeAttribute("src"), e.current.load());
|
|
35
35
|
};
|
|
36
|
-
}, [
|
|
37
|
-
|
|
36
|
+
}, [n]), i.type === "video" ? /* @__PURE__ */ t.jsxs(
|
|
37
|
+
a,
|
|
38
38
|
{
|
|
39
39
|
sx: {
|
|
40
40
|
position: "relative",
|
|
@@ -44,12 +44,12 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
44
44
|
...o
|
|
45
45
|
},
|
|
46
46
|
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
|
|
47
|
+
/* @__PURE__ */ t.jsx(
|
|
48
|
+
a,
|
|
49
49
|
{
|
|
50
50
|
component: "video",
|
|
51
51
|
ref: e,
|
|
52
|
-
onClick:
|
|
52
|
+
onClick: s,
|
|
53
53
|
playsInline: !0,
|
|
54
54
|
muted: !0,
|
|
55
55
|
loop: !0,
|
|
@@ -58,17 +58,17 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
58
58
|
width: "100%",
|
|
59
59
|
height: "100%",
|
|
60
60
|
objectFit: "cover",
|
|
61
|
-
opacity:
|
|
61
|
+
opacity: u ? 0.8 : 1,
|
|
62
62
|
transition: "opacity 0.2s",
|
|
63
63
|
transform: "translateZ(0)",
|
|
64
64
|
willChange: "transform",
|
|
65
65
|
display: "block"
|
|
66
66
|
},
|
|
67
|
-
children: /* @__PURE__ */
|
|
67
|
+
children: /* @__PURE__ */ t.jsx("source", { src: i.url, type: "video/mp4" })
|
|
68
68
|
}
|
|
69
69
|
),
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
u && /* @__PURE__ */ t.jsx(
|
|
71
|
+
a,
|
|
72
72
|
{
|
|
73
73
|
sx: {
|
|
74
74
|
position: "absolute",
|
|
@@ -78,8 +78,8 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
78
78
|
justifyContent: "center",
|
|
79
79
|
bgcolor: "action.disabled"
|
|
80
80
|
},
|
|
81
|
-
children: /* @__PURE__ */
|
|
82
|
-
|
|
81
|
+
children: /* @__PURE__ */ t.jsx(
|
|
82
|
+
a,
|
|
83
83
|
{
|
|
84
84
|
sx: {
|
|
85
85
|
width: 24,
|
|
@@ -99,56 +99,62 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
99
99
|
)
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
|
-
) : /* @__PURE__ */
|
|
103
|
-
|
|
102
|
+
) : /* @__PURE__ */ t.jsx(a, { onClick: s, sx: { width: "100%", height: "100%", ...o }, children: /* @__PURE__ */ t.jsx(
|
|
103
|
+
P,
|
|
104
104
|
{
|
|
105
|
-
src:
|
|
106
|
-
alt:
|
|
105
|
+
src: i.url,
|
|
106
|
+
alt: i.title || "",
|
|
107
107
|
width: "100%",
|
|
108
108
|
height: "100%",
|
|
109
109
|
style: {
|
|
110
110
|
objectFit: o != null && o.objectFit ? o.objectFit : "cover",
|
|
111
|
-
cursor:
|
|
111
|
+
cursor: s ? "pointer" : "default",
|
|
112
112
|
display: "block",
|
|
113
113
|
width: "100%",
|
|
114
114
|
height: "100%"
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
) });
|
|
118
|
-
},
|
|
119
|
-
let
|
|
118
|
+
}, C = (i, o) => {
|
|
119
|
+
let s = 1, e = 2;
|
|
120
120
|
switch (o) {
|
|
121
121
|
case "grid":
|
|
122
|
-
|
|
122
|
+
s = 1, e = 2;
|
|
123
123
|
break;
|
|
124
124
|
case "masonry":
|
|
125
|
-
|
|
125
|
+
s = 1, e = i % 3 === 0 ? 3 : i % 2 === 0 ? 2 : 4;
|
|
126
126
|
break;
|
|
127
127
|
case "spotlight":
|
|
128
|
-
|
|
128
|
+
i === 0 ? (s = 2, e = 4) : (s = 1, e = 2);
|
|
129
129
|
break;
|
|
130
130
|
case "featured":
|
|
131
|
-
|
|
131
|
+
i === 0 ? (s = 2, e = 6) : (s = 1, e = 2);
|
|
132
|
+
break;
|
|
133
|
+
case "custom":
|
|
134
|
+
s = 1, e = 2;
|
|
132
135
|
break;
|
|
133
136
|
}
|
|
134
|
-
return {
|
|
135
|
-
}
|
|
136
|
-
const
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
return { colSpan: s, rowSpan: e };
|
|
138
|
+
}, S = (i, o) => o === "custom" ? i : i.map((s, e) => {
|
|
139
|
+
const { colSpan: n, rowSpan: l } = C(e, o);
|
|
140
|
+
return { ...s, colSpan: n, rowSpan: l };
|
|
141
|
+
}), W = ({ mediaItems: i, variant: o = "masonry", loading: s = !1, skeletonCount: e = 6 }) => {
|
|
142
|
+
const [n, l] = y(null), [u, f] = y(() => S(i, o)), [c, g] = y(!1), d = R();
|
|
143
|
+
return b(() => {
|
|
144
|
+
f(S(i, o));
|
|
145
|
+
}, [i, o]), /* @__PURE__ */ t.jsxs(a, { sx: { width: "100%", position: "relative", zIndex: 1 }, children: [
|
|
146
|
+
/* @__PURE__ */ t.jsx(
|
|
147
|
+
V,
|
|
142
148
|
{
|
|
143
|
-
selectedItem:
|
|
144
|
-
isOpen: !!
|
|
145
|
-
onClose: () =>
|
|
146
|
-
onItemChange:
|
|
147
|
-
mediaItems:
|
|
149
|
+
selectedItem: n,
|
|
150
|
+
isOpen: !!n,
|
|
151
|
+
onClose: () => l(null),
|
|
152
|
+
onItemChange: l,
|
|
153
|
+
mediaItems: u
|
|
148
154
|
}
|
|
149
155
|
),
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
|
|
156
|
+
/* @__PURE__ */ t.jsx(M, { mode: "wait", children: !n && /* @__PURE__ */ t.jsx(
|
|
157
|
+
I.div,
|
|
152
158
|
{
|
|
153
159
|
initial: "hidden",
|
|
154
160
|
animate: "visible",
|
|
@@ -161,8 +167,8 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
161
167
|
// Stagger child animations
|
|
162
168
|
}
|
|
163
169
|
},
|
|
164
|
-
children: /* @__PURE__ */
|
|
165
|
-
|
|
170
|
+
children: /* @__PURE__ */ t.jsx(
|
|
171
|
+
a,
|
|
166
172
|
{
|
|
167
173
|
sx: {
|
|
168
174
|
display: "grid",
|
|
@@ -176,11 +182,38 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
176
182
|
position: "relative"
|
|
177
183
|
// Ensure proper stacking context
|
|
178
184
|
},
|
|
179
|
-
children:
|
|
180
|
-
m
|
|
185
|
+
children: s ? Array.from({ length: e }).map((r, p) => {
|
|
186
|
+
const { colSpan: h, rowSpan: m } = C(p, o);
|
|
187
|
+
return /* @__PURE__ */ t.jsx(
|
|
188
|
+
w,
|
|
189
|
+
{
|
|
190
|
+
sx: {
|
|
191
|
+
position: "relative",
|
|
192
|
+
overflow: "hidden",
|
|
193
|
+
borderRadius: 2,
|
|
194
|
+
gridRow: `span ${m}`,
|
|
195
|
+
gridColumn: `span ${h}`
|
|
196
|
+
},
|
|
197
|
+
children: /* @__PURE__ */ t.jsx(
|
|
198
|
+
E,
|
|
199
|
+
{
|
|
200
|
+
variant: "rectangular",
|
|
201
|
+
animation: "wave",
|
|
202
|
+
sx: {
|
|
203
|
+
width: "100%",
|
|
204
|
+
height: "100%",
|
|
205
|
+
transform: "none"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
},
|
|
210
|
+
p
|
|
211
|
+
);
|
|
212
|
+
}) : u.map((r, p) => /* @__PURE__ */ t.jsx(
|
|
213
|
+
I.div,
|
|
181
214
|
{
|
|
182
|
-
layoutId: `media-${
|
|
183
|
-
onClick: () => !
|
|
215
|
+
layoutId: `media-${r.id}-${d}`,
|
|
216
|
+
onClick: () => !c && l(r),
|
|
184
217
|
variants: {
|
|
185
218
|
hidden: { y: 50, scale: 0.9, opacity: 0 },
|
|
186
219
|
visible: {
|
|
@@ -191,7 +224,7 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
191
224
|
type: "spring",
|
|
192
225
|
stiffness: 350,
|
|
193
226
|
damping: 25,
|
|
194
|
-
delay:
|
|
227
|
+
delay: p * 0.05
|
|
195
228
|
}
|
|
196
229
|
}
|
|
197
230
|
},
|
|
@@ -199,22 +232,22 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
199
232
|
drag: !0,
|
|
200
233
|
dragConstraints: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
201
234
|
dragElastic: 1,
|
|
202
|
-
onDragStart: () =>
|
|
203
|
-
onDragEnd: (
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
if (Math.abs(
|
|
207
|
-
const
|
|
208
|
-
|
|
235
|
+
onDragStart: () => g(!0),
|
|
236
|
+
onDragEnd: (h, m) => {
|
|
237
|
+
g(!1);
|
|
238
|
+
const x = m.offset.x + m.offset.y;
|
|
239
|
+
if (Math.abs(x) > 50) {
|
|
240
|
+
const v = [...u], k = v[p], $ = x > 0 ? Math.min(p + 1, u.length - 1) : Math.max(p - 1, 0);
|
|
241
|
+
v.splice(p, 1), v.splice($, 0, k), f(v);
|
|
209
242
|
}
|
|
210
243
|
},
|
|
211
244
|
style: {
|
|
212
245
|
position: "relative",
|
|
213
|
-
gridRow:
|
|
214
|
-
gridColumn:
|
|
246
|
+
gridRow: r.rowSpan ? `span ${r.rowSpan}` : "span 2",
|
|
247
|
+
gridColumn: r.colSpan ? `span ${r.colSpan}` : "span 1"
|
|
215
248
|
},
|
|
216
|
-
children: /* @__PURE__ */
|
|
217
|
-
|
|
249
|
+
children: /* @__PURE__ */ t.jsxs(
|
|
250
|
+
w,
|
|
218
251
|
{
|
|
219
252
|
sx: {
|
|
220
253
|
position: "relative",
|
|
@@ -229,16 +262,16 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
229
262
|
}
|
|
230
263
|
},
|
|
231
264
|
children: [
|
|
232
|
-
/* @__PURE__ */
|
|
233
|
-
|
|
265
|
+
/* @__PURE__ */ t.jsx(
|
|
266
|
+
A,
|
|
234
267
|
{
|
|
235
|
-
item:
|
|
268
|
+
item: r,
|
|
236
269
|
sx: { position: "absolute", inset: 0, width: "100%", height: "100%" },
|
|
237
|
-
onClick: () => !
|
|
270
|
+
onClick: () => !c && l(r)
|
|
238
271
|
}
|
|
239
272
|
),
|
|
240
|
-
(
|
|
241
|
-
|
|
273
|
+
(r.title || r.desc) && /* @__PURE__ */ t.jsxs(
|
|
274
|
+
a,
|
|
242
275
|
{
|
|
243
276
|
className: "hover-overlay",
|
|
244
277
|
sx: {
|
|
@@ -254,18 +287,18 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
254
287
|
transition: "opacity 0.2s ease-in-out"
|
|
255
288
|
},
|
|
256
289
|
children: [
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
|
|
290
|
+
/* @__PURE__ */ t.jsx(
|
|
291
|
+
a,
|
|
259
292
|
{
|
|
260
293
|
sx: {
|
|
261
294
|
position: "absolute",
|
|
262
295
|
inset: 0,
|
|
263
|
-
background: (
|
|
296
|
+
background: (h) => `linear-gradient(to top, ${(h.vars || h).palette.grey[900]}CC, ${(h.vars || h).palette.grey[900]}66, transparent)`
|
|
264
297
|
}
|
|
265
298
|
}
|
|
266
299
|
),
|
|
267
|
-
|
|
268
|
-
|
|
300
|
+
r.title && /* @__PURE__ */ t.jsx(
|
|
301
|
+
j,
|
|
269
302
|
{
|
|
270
303
|
variant: "subtitle2",
|
|
271
304
|
sx: {
|
|
@@ -276,23 +309,23 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
276
309
|
overflow: "hidden",
|
|
277
310
|
textOverflow: "ellipsis"
|
|
278
311
|
},
|
|
279
|
-
children:
|
|
312
|
+
children: r.title
|
|
280
313
|
}
|
|
281
314
|
),
|
|
282
|
-
|
|
283
|
-
|
|
315
|
+
r.desc && /* @__PURE__ */ t.jsx(
|
|
316
|
+
j,
|
|
284
317
|
{
|
|
285
318
|
variant: "caption",
|
|
286
319
|
sx: {
|
|
287
320
|
position: "relative",
|
|
288
321
|
color: "text.secondary",
|
|
289
|
-
mt:
|
|
322
|
+
mt: r.title ? 0.5 : 0,
|
|
290
323
|
display: "-webkit-box",
|
|
291
324
|
WebkitLineClamp: 2,
|
|
292
325
|
WebkitBoxOrient: "vertical",
|
|
293
326
|
overflow: "hidden"
|
|
294
327
|
},
|
|
295
|
-
children:
|
|
328
|
+
children: r.desc
|
|
296
329
|
}
|
|
297
330
|
)
|
|
298
331
|
]
|
|
@@ -302,7 +335,7 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
302
335
|
}
|
|
303
336
|
)
|
|
304
337
|
},
|
|
305
|
-
`${
|
|
338
|
+
`${r.id}-${d}`
|
|
306
339
|
))
|
|
307
340
|
}
|
|
308
341
|
)
|
|
@@ -311,6 +344,6 @@ const E = ({ item: n, sx: o, onClick: l }) => {
|
|
|
311
344
|
] });
|
|
312
345
|
};
|
|
313
346
|
export {
|
|
314
|
-
|
|
315
|
-
|
|
347
|
+
A as MediaItem,
|
|
348
|
+
W as default
|
|
316
349
|
};
|