@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 r } from "../jsx-runtime-OVHDjVDe.js";
2
- import { useState as h, useId as C, useEffect as y, useRef as S } from "react";
3
- import { Box as c, Paper as k, Typography as x } from "@mui/material";
4
- import { AnimatePresence as $, motion as m } from "framer-motion";
5
- import R from "../s-image-modal/s-image-modal.js";
6
- import D from "../s-lazy-image/s-lazy-image.js";
7
- const E = ({ item: n, sx: o, onClick: l }) => {
8
- const e = S(null), [i, s] = h(!1), [f, u] = h(!0);
9
- return y(() => {
10
- const d = {
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
- }, t = new IntersectionObserver((a) => {
17
- a.forEach((p) => s(p.isIntersecting));
18
- }, d);
19
- return e.current && t.observe(e.current), () => {
20
- e.current && t.unobserve(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
- }, []), y(() => {
23
- let d = !0;
24
- return i ? (async () => {
25
- if (!(!e.current || !i || !d))
22
+ }, []), b(() => {
23
+ let c = !0;
24
+ return n ? (async () => {
25
+ if (!(!e.current || !n || !c))
26
26
  try {
27
- e.current.readyState >= 3 ? (u(!1), await e.current.play()) : (u(!0), await new Promise((a) => {
28
- e.current && (e.current.oncanplay = () => a());
29
- }), d && (u(!1), await e.current.play()));
30
- } catch (a) {
31
- console.warn("Video playback failed:", a);
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
- d = !1, e.current && (e.current.pause(), e.current.removeAttribute("src"), e.current.load());
34
+ c = !1, e.current && (e.current.pause(), e.current.removeAttribute("src"), e.current.load());
35
35
  };
36
- }, [i]), n.type === "video" ? /* @__PURE__ */ r.jsxs(
37
- c,
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__ */ r.jsx(
48
- c,
47
+ /* @__PURE__ */ t.jsx(
48
+ a,
49
49
  {
50
50
  component: "video",
51
51
  ref: e,
52
- onClick: l,
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: f ? 0.8 : 1,
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__ */ r.jsx("source", { src: n.url, type: "video/mp4" })
67
+ children: /* @__PURE__ */ t.jsx("source", { src: i.url, type: "video/mp4" })
68
68
  }
69
69
  ),
70
- f && /* @__PURE__ */ r.jsx(
71
- c,
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__ */ r.jsx(
82
- c,
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__ */ r.jsx(c, { onClick: l, sx: { width: "100%", height: "100%", ...o }, children: /* @__PURE__ */ r.jsx(
103
- D,
102
+ ) : /* @__PURE__ */ t.jsx(a, { onClick: s, sx: { width: "100%", height: "100%", ...o }, children: /* @__PURE__ */ t.jsx(
103
+ P,
104
104
  {
105
- src: n.url,
106
- alt: n.title || "",
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: l ? "pointer" : "default",
111
+ cursor: s ? "pointer" : "default",
112
112
  display: "block",
113
113
  width: "100%",
114
114
  height: "100%"
115
115
  }
116
116
  }
117
117
  ) });
118
- }, w = (n, o) => o === "custom" ? n : n.map((l, e) => {
119
- let i = 1, s = 2;
118
+ }, C = (i, o) => {
119
+ let s = 1, e = 2;
120
120
  switch (o) {
121
121
  case "grid":
122
- i = 1, s = 2;
122
+ s = 1, e = 2;
123
123
  break;
124
124
  case "masonry":
125
- i = 1, s = e % 3 === 0 ? 3 : e % 2 === 0 ? 2 : 4;
125
+ s = 1, e = i % 3 === 0 ? 3 : i % 2 === 0 ? 2 : 4;
126
126
  break;
127
127
  case "spotlight":
128
- e === 0 ? (i = 2, s = 4) : (i = 1, s = 2);
128
+ i === 0 ? (s = 2, e = 4) : (s = 1, e = 2);
129
129
  break;
130
130
  case "featured":
131
- e === 0 ? (i = 2, s = 6) : (i = 1, s = 2);
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 { ...l, colSpan: i, rowSpan: s };
135
- }), T = ({ mediaItems: n, variant: o = "masonry" }) => {
136
- const [l, e] = h(null), [i, s] = h(() => w(n, o)), [f, u] = h(!1), d = C();
137
- return y(() => {
138
- s(w(n, o));
139
- }, [n, o]), /* @__PURE__ */ r.jsxs(c, { sx: { width: "100%", position: "relative", zIndex: 1 }, children: [
140
- /* @__PURE__ */ r.jsx(
141
- R,
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: l,
144
- isOpen: !!l,
145
- onClose: () => e(null),
146
- onItemChange: e,
147
- mediaItems: i
149
+ selectedItem: n,
150
+ isOpen: !!n,
151
+ onClose: () => l(null),
152
+ onItemChange: l,
153
+ mediaItems: u
148
154
  }
149
155
  ),
150
- /* @__PURE__ */ r.jsx($, { mode: "wait", children: !l && /* @__PURE__ */ r.jsx(
151
- m.div,
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__ */ r.jsx(
165
- c,
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: i.map((t, a) => /* @__PURE__ */ r.jsx(
180
- m.div,
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-${t.id}-${d}`,
183
- onClick: () => !f && e(t),
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: a * 0.05
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: () => u(!0),
203
- onDragEnd: (p, b) => {
204
- u(!1);
205
- const v = b.offset.x + b.offset.y;
206
- if (Math.abs(v) > 50) {
207
- const g = [...i], j = g[a], I = v > 0 ? Math.min(a + 1, i.length - 1) : Math.max(a - 1, 0);
208
- g.splice(a, 1), g.splice(I, 0, j), s(g);
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: t.rowSpan ? `span ${t.rowSpan}` : "span 2",
214
- gridColumn: t.colSpan ? `span ${t.colSpan}` : "span 1"
246
+ gridRow: r.rowSpan ? `span ${r.rowSpan}` : "span 2",
247
+ gridColumn: r.colSpan ? `span ${r.colSpan}` : "span 1"
215
248
  },
216
- children: /* @__PURE__ */ r.jsxs(
217
- k,
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__ */ r.jsx(
233
- E,
265
+ /* @__PURE__ */ t.jsx(
266
+ A,
234
267
  {
235
- item: t,
268
+ item: r,
236
269
  sx: { position: "absolute", inset: 0, width: "100%", height: "100%" },
237
- onClick: () => !f && e(t)
270
+ onClick: () => !c && l(r)
238
271
  }
239
272
  ),
240
- (t.title || t.desc) && /* @__PURE__ */ r.jsxs(
241
- c,
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__ */ r.jsx(
258
- c,
290
+ /* @__PURE__ */ t.jsx(
291
+ a,
259
292
  {
260
293
  sx: {
261
294
  position: "absolute",
262
295
  inset: 0,
263
- background: (p) => `linear-gradient(to top, ${(p.vars || p).palette.grey[900]}CC, ${(p.vars || p).palette.grey[900]}66, transparent)`
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
- t.title && /* @__PURE__ */ r.jsx(
268
- x,
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: t.title
312
+ children: r.title
280
313
  }
281
314
  ),
282
- t.desc && /* @__PURE__ */ r.jsx(
283
- x,
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: t.title ? 0.5 : 0,
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: t.desc
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
- `${t.id}-${d}`
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
- E as MediaItem,
315
- T as default
347
+ A as MediaItem,
348
+ W as default
316
349
  };