@wyxos/vibe 1.6.9 → 1.6.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/lib/index.js +133 -136
- package/package.json +1 -1
- package/src/components/MasonryItem.vue +2 -7
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nextTick as J, defineComponent as Le, ref as k, computed as te, onMounted as Se, onUnmounted as Ne, watch as He, createElementBlock as B, openBlock as D, renderSlot as $e, createElementVNode as
|
|
1
|
+
import { nextTick as J, defineComponent as Le, ref as k, computed as te, onMounted as Se, onUnmounted as Ne, watch as He, createElementBlock as B, openBlock as D, renderSlot as $e, createElementVNode as S, createCommentVNode as X, normalizeClass as Y, toDisplayString as ue, withModifiers as ze, normalizeStyle as Re, createVNode as Te, TransitionGroup as _e, withCtx as Ce, Fragment as qe, renderList as Ve, mergeProps as Ge, unref as Ue } from "vue";
|
|
2
2
|
let fe = null;
|
|
3
3
|
function Xe() {
|
|
4
4
|
if (fe != null) return fe;
|
|
@@ -35,28 +35,28 @@ function Ye(e, r, l, s = {}) {
|
|
|
35
35
|
}
|
|
36
36
|
} catch {
|
|
37
37
|
}
|
|
38
|
-
const N = (h || 0) + m, z = (c || 0) + d, $ = r.offsetWidth - r.clientWidth,
|
|
39
|
-
const H = P.width,
|
|
40
|
-
return Math.round(M *
|
|
38
|
+
const N = (h || 0) + m, z = (c || 0) + d, $ = r.offsetWidth - r.clientWidth, E = $ > 0 ? $ + 2 : Xe() + 2, i = r.offsetWidth - E - N - z, g = w * (l - 1), M = Math.floor((i - g) / l), I = e.map((P) => {
|
|
39
|
+
const H = P.width, L = P.height;
|
|
40
|
+
return Math.round(M * L / H) + n + a;
|
|
41
41
|
});
|
|
42
42
|
if (T === "sequential-balanced") {
|
|
43
43
|
const P = I.length;
|
|
44
44
|
if (P === 0) return [];
|
|
45
45
|
const H = (x, F, R) => x + (F > 0 ? v : 0) + R;
|
|
46
|
-
let
|
|
46
|
+
let L = Math.max(...I), _ = I.reduce((x, F) => x + F, 0) + v * Math.max(0, P - 1);
|
|
47
47
|
const ae = (x) => {
|
|
48
48
|
let F = 1, R = 0, q = 0;
|
|
49
|
-
for (let
|
|
50
|
-
const U = I[
|
|
49
|
+
for (let O = 0; O < P; O++) {
|
|
50
|
+
const U = I[O], V = H(R, q, U);
|
|
51
51
|
if (V <= x)
|
|
52
52
|
R = V, q++;
|
|
53
53
|
else if (F++, R = U, q = 1, U > x || F > l) return !1;
|
|
54
54
|
}
|
|
55
55
|
return F <= l;
|
|
56
56
|
};
|
|
57
|
-
for (;
|
|
58
|
-
const x = Math.floor((
|
|
59
|
-
ae(x) ? _ = x :
|
|
57
|
+
for (; L < _; ) {
|
|
58
|
+
const x = Math.floor((L + _) / 2);
|
|
59
|
+
ae(x) ? _ = x : L = x + 1;
|
|
60
60
|
}
|
|
61
61
|
const ne = _, K = new Array(l).fill(0);
|
|
62
62
|
let oe = l - 1, Q = 0, Z = 0;
|
|
@@ -68,23 +68,23 @@ function Ye(e, r, l, s = {}) {
|
|
|
68
68
|
const C = [], re = new Array(l).fill(0);
|
|
69
69
|
for (let x = 0; x < l; x++) {
|
|
70
70
|
const F = K[x], R = x + 1 < l ? K[x + 1] : P, q = x * (M + w);
|
|
71
|
-
for (let
|
|
71
|
+
for (let O = F; O < R; O++) {
|
|
72
72
|
const V = {
|
|
73
|
-
...e[
|
|
73
|
+
...e[O],
|
|
74
74
|
columnWidth: M,
|
|
75
75
|
imageHeight: 0,
|
|
76
76
|
columnHeight: 0,
|
|
77
77
|
left: 0,
|
|
78
78
|
top: 0
|
|
79
79
|
};
|
|
80
|
-
V.imageHeight = I[
|
|
80
|
+
V.imageHeight = I[O] - (n + a), V.columnHeight = I[O], V.left = q, V.top = re[x], re[x] += V.columnHeight + (O + 1 < R ? v : 0), C.push(V);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
return C;
|
|
84
84
|
}
|
|
85
85
|
const b = new Array(l).fill(0), A = [];
|
|
86
86
|
for (let P = 0; P < e.length; P++) {
|
|
87
|
-
const H = e[P],
|
|
87
|
+
const H = e[P], L = {
|
|
88
88
|
...H,
|
|
89
89
|
columnWidth: 0,
|
|
90
90
|
imageHeight: 0,
|
|
@@ -92,7 +92,7 @@ function Ye(e, r, l, s = {}) {
|
|
|
92
92
|
left: 0,
|
|
93
93
|
top: 0
|
|
94
94
|
}, _ = b.indexOf(Math.min(...b)), ae = H.width, ne = H.height;
|
|
95
|
-
|
|
95
|
+
L.columnWidth = M, L.left = _ * (M + w), L.imageHeight = Math.round(M * ne / ae), L.columnHeight = L.imageHeight + n + a, L.top = b[_], b[_] += L.columnHeight + v, A.push(L);
|
|
96
96
|
}
|
|
97
97
|
return A;
|
|
98
98
|
}
|
|
@@ -136,7 +136,7 @@ function me(e) {
|
|
|
136
136
|
var r = typeof e;
|
|
137
137
|
return e != null && (r == "object" || r == "function");
|
|
138
138
|
}
|
|
139
|
-
var Ie = NaN, mt = /^[-+]0x[0-9a-f]+$/i,
|
|
139
|
+
var Ie = NaN, mt = /^[-+]0x[0-9a-f]+$/i, gt = /^0b[01]+$/i, pt = /^0o[0-7]+$/i, yt = parseInt;
|
|
140
140
|
function Pe(e) {
|
|
141
141
|
if (typeof e == "number")
|
|
142
142
|
return e;
|
|
@@ -149,8 +149,8 @@ function Pe(e) {
|
|
|
149
149
|
if (typeof e != "string")
|
|
150
150
|
return e === 0 ? e : +e;
|
|
151
151
|
e = vt(e);
|
|
152
|
-
var l =
|
|
153
|
-
return l ||
|
|
152
|
+
var l = gt.test(e);
|
|
153
|
+
return l || pt.test(e) ? yt(e.slice(2), l ? 2 : 8) : mt.test(e) ? Ie : +e;
|
|
154
154
|
}
|
|
155
155
|
var de = function() {
|
|
156
156
|
return Ae.Date.now();
|
|
@@ -165,7 +165,7 @@ function ke(e, r, l) {
|
|
|
165
165
|
return s = w = void 0, c = b, a = e.apply(P, A), a;
|
|
166
166
|
}
|
|
167
167
|
function N(b) {
|
|
168
|
-
return c = b, n = setTimeout(
|
|
168
|
+
return c = b, n = setTimeout(E, r), f ? d(b) : a;
|
|
169
169
|
}
|
|
170
170
|
function z(b) {
|
|
171
171
|
var A = b - h, P = b - c, H = r - A;
|
|
@@ -175,16 +175,16 @@ function ke(e, r, l) {
|
|
|
175
175
|
var A = b - h, P = b - c;
|
|
176
176
|
return h === void 0 || A >= r || A < 0 || T && P >= v;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function E() {
|
|
179
179
|
var b = de();
|
|
180
180
|
if ($(b))
|
|
181
181
|
return i(b);
|
|
182
|
-
n = setTimeout(
|
|
182
|
+
n = setTimeout(E, z(b));
|
|
183
183
|
}
|
|
184
184
|
function i(b) {
|
|
185
185
|
return n = void 0, m && s ? d(b) : (s = w = void 0, a);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function g() {
|
|
188
188
|
n !== void 0 && clearTimeout(n), c = 0, s = h = w = n = void 0;
|
|
189
189
|
}
|
|
190
190
|
function M() {
|
|
@@ -196,11 +196,11 @@ function ke(e, r, l) {
|
|
|
196
196
|
if (n === void 0)
|
|
197
197
|
return N(h);
|
|
198
198
|
if (T)
|
|
199
|
-
return clearTimeout(n), n = setTimeout(
|
|
199
|
+
return clearTimeout(n), n = setTimeout(E, r), d(h);
|
|
200
200
|
}
|
|
201
|
-
return n === void 0 && (n = setTimeout(
|
|
201
|
+
return n === void 0 && (n = setTimeout(E, r)), a;
|
|
202
202
|
}
|
|
203
|
-
return I.cancel =
|
|
203
|
+
return I.cancel = g, I.flush = M, I;
|
|
204
204
|
}
|
|
205
205
|
function ve(e) {
|
|
206
206
|
const r = window.innerWidth, l = e.sizes;
|
|
@@ -227,7 +227,7 @@ function Mt(e, r = 0) {
|
|
|
227
227
|
"data-index": r
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function ge(e, r) {
|
|
231
231
|
if (!e.length || r <= 0)
|
|
232
232
|
return new Array(Math.max(1, r)).fill(0);
|
|
233
233
|
const s = Array.from(new Set(e.map((a) => a.left))).sort((a, n) => a - n).slice(0, r), w = /* @__PURE__ */ new Map();
|
|
@@ -265,7 +265,7 @@ function It(e, r) {
|
|
|
265
265
|
const h = parseInt(a.dataset.left || "0", 10), c = parseInt(a.dataset.top || "0", 10), f = typeof (r == null ? void 0 : r.leaveDurationMs) == "number" ? r.leaveDurationMs : NaN;
|
|
266
266
|
let T = Number.isFinite(f) && f > 0 ? f : NaN;
|
|
267
267
|
if (!Number.isFinite(T)) {
|
|
268
|
-
const
|
|
268
|
+
const E = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", i = parseFloat(E);
|
|
269
269
|
T = Number.isFinite(i) && i > 0 ? i : 200;
|
|
270
270
|
}
|
|
271
271
|
const m = a.style.transitionDuration, d = () => {
|
|
@@ -301,9 +301,9 @@ function Pt({
|
|
|
301
301
|
let f = 0;
|
|
302
302
|
async function T(m) {
|
|
303
303
|
if (!e.value) return;
|
|
304
|
-
const d = m ??
|
|
304
|
+
const d = m ?? ge(r.value, l.value), N = d.length ? Math.max(...d) : 0, z = e.value.scrollTop + e.value.clientHeight, $ = e.value.scrollTop > f + 1;
|
|
305
305
|
f = e.value.scrollTop;
|
|
306
|
-
const
|
|
306
|
+
const E = typeof c == "number" ? c : 200, i = E >= 0 ? Math.max(0, N - E) : Math.max(0, N + E);
|
|
307
307
|
if (z >= i && $ && !w.value) {
|
|
308
308
|
await h(), await J();
|
|
309
309
|
return;
|
|
@@ -319,13 +319,13 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
319
319
|
}, Lt = {
|
|
320
320
|
key: 1,
|
|
321
321
|
class: "relative w-full h-full"
|
|
322
|
-
}, St = ["src"], Nt = ["src"], Ht = { class: "
|
|
322
|
+
}, St = ["src"], Nt = ["src"], Ht = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, $t = {
|
|
323
323
|
key: 3,
|
|
324
324
|
class: "absolute bottom-2 left-1/2 transform -translate-x-1/2 flex items-center justify-center"
|
|
325
|
-
},
|
|
325
|
+
}, At = {
|
|
326
326
|
key: 4,
|
|
327
327
|
class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-50 text-slate-400 text-sm p-4 text-center"
|
|
328
|
-
},
|
|
328
|
+
}, Ft = ["title"], Wt = { class: "absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 delay-75 pointer-events-none" }, Ot = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, pe = /* @__PURE__ */ Le({
|
|
329
329
|
__name: "MasonryItem",
|
|
330
330
|
props: {
|
|
331
331
|
item: {},
|
|
@@ -344,7 +344,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
344
344
|
return r.notFound ?? ((i = r.item) == null ? void 0 : i.notFound) ?? !1;
|
|
345
345
|
});
|
|
346
346
|
function z(i) {
|
|
347
|
-
return new Promise((
|
|
347
|
+
return new Promise((g, M) => {
|
|
348
348
|
if (!i) {
|
|
349
349
|
M(new Error("No image source provided"));
|
|
350
350
|
return;
|
|
@@ -353,7 +353,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
353
353
|
I.onload = () => {
|
|
354
354
|
const P = Date.now() - b, H = Math.max(0, A - P);
|
|
355
355
|
setTimeout(async () => {
|
|
356
|
-
l.value = !0, s.value = !1, c.value = !1, await J(), await new Promise((
|
|
356
|
+
l.value = !0, s.value = !1, c.value = !1, await J(), await new Promise((L) => setTimeout(L, 100)), f.value = !0, g();
|
|
357
357
|
}, H);
|
|
358
358
|
}, I.onerror = () => {
|
|
359
359
|
s.value = !0, l.value = !1, c.value = !1, M(new Error("Failed to load image"));
|
|
@@ -361,7 +361,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
function $(i) {
|
|
364
|
-
return new Promise((
|
|
364
|
+
return new Promise((g, M) => {
|
|
365
365
|
if (!i) {
|
|
366
366
|
M(new Error("No video source provided"));
|
|
367
367
|
return;
|
|
@@ -370,18 +370,18 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
370
370
|
I.preload = "metadata", I.muted = !0, I.onloadedmetadata = () => {
|
|
371
371
|
const P = Date.now() - b, H = Math.max(0, A - P);
|
|
372
372
|
setTimeout(async () => {
|
|
373
|
-
v.value = !0, a.value = !1, c.value = !1, await J(), await new Promise((
|
|
373
|
+
v.value = !0, a.value = !1, c.value = !1, await J(), await new Promise((L) => setTimeout(L, 100)), f.value = !0, g();
|
|
374
374
|
}, H);
|
|
375
375
|
}, I.onerror = () => {
|
|
376
376
|
a.value = !0, v.value = !1, c.value = !1, M(new Error("Failed to load video"));
|
|
377
377
|
}, I.src = i;
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
381
|
-
var
|
|
380
|
+
async function E() {
|
|
381
|
+
var g;
|
|
382
382
|
if (!h.value || c.value || N.value || d.value === "video" && v.value || d.value === "image" && l.value)
|
|
383
383
|
return;
|
|
384
|
-
const i = (
|
|
384
|
+
const i = (g = r.item) == null ? void 0 : g.src;
|
|
385
385
|
if (i)
|
|
386
386
|
if (c.value = !0, f.value = !1, d.value === "video") {
|
|
387
387
|
n.value = i, v.value = !1, a.value = !1;
|
|
@@ -400,8 +400,8 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
400
400
|
return Se(() => {
|
|
401
401
|
T.value && (m = new IntersectionObserver(
|
|
402
402
|
(i) => {
|
|
403
|
-
i.forEach((
|
|
404
|
-
|
|
403
|
+
i.forEach((g) => {
|
|
404
|
+
g.isIntersecting && g.intersectionRatio >= 1 ? h.value || (h.value = !0, E()) : g.isIntersecting;
|
|
405
405
|
});
|
|
406
406
|
},
|
|
407
407
|
{
|
|
@@ -435,7 +435,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
), (i,
|
|
438
|
+
), (i, g) => (D(), B("div", {
|
|
439
439
|
ref_key: "containerRef",
|
|
440
440
|
ref: T,
|
|
441
441
|
class: "relative w-full h-full group"
|
|
@@ -451,11 +451,11 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
451
451
|
isLoading: c.value,
|
|
452
452
|
mediaType: d.value
|
|
453
453
|
}, () => [
|
|
454
|
-
|
|
455
|
-
N.value ? (D(), B("div", Et,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
454
|
+
S("div", kt, [
|
|
455
|
+
N.value ? (D(), B("div", Et, g[4] || (g[4] = [
|
|
456
|
+
S("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
|
|
457
|
+
S("span", { class: "font-medium" }, "Not Found", -1),
|
|
458
|
+
S("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
|
|
459
459
|
]))) : (D(), B("div", Lt, [
|
|
460
460
|
d.value === "image" && w.value ? (D(), B("img", {
|
|
461
461
|
key: 0,
|
|
@@ -480,9 +480,9 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
480
480
|
muted: "",
|
|
481
481
|
loop: "",
|
|
482
482
|
playsinline: "",
|
|
483
|
-
onMouseenter:
|
|
484
|
-
onMouseleave:
|
|
485
|
-
onError:
|
|
483
|
+
onMouseenter: g[0] || (g[0] = (M) => M.target.play()),
|
|
484
|
+
onMouseleave: g[1] || (g[1] = (M) => M.target.pause()),
|
|
485
|
+
onError: g[2] || (g[2] = (M) => a.value = !0)
|
|
486
486
|
}, null, 42, Nt)) : X("", !0),
|
|
487
487
|
!l.value && !v.value && !s.value && !a.value ? (D(), B("div", {
|
|
488
488
|
key: 2,
|
|
@@ -491,25 +491,22 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
491
491
|
f.value ? "opacity-0 pointer-events-none" : "opacity-100"
|
|
492
492
|
])
|
|
493
493
|
}, [
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}, null, 2)
|
|
499
|
-
]),
|
|
500
|
-
E("span", At, ie(d.value), 1)
|
|
494
|
+
S("div", Ht, [
|
|
495
|
+
S("i", {
|
|
496
|
+
class: Y(d.value === "video" ? "fas fa-video text-xl text-slate-400" : "fas fa-image text-xl text-slate-400")
|
|
497
|
+
}, null, 2)
|
|
501
498
|
])
|
|
502
499
|
], 2)) : X("", !0),
|
|
503
|
-
c.value ? (D(), B("div",
|
|
504
|
-
|
|
505
|
-
|
|
500
|
+
c.value ? (D(), B("div", $t, g[5] || (g[5] = [
|
|
501
|
+
S("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
|
|
502
|
+
S("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
|
|
506
503
|
], -1)
|
|
507
504
|
]))) : X("", !0),
|
|
508
|
-
d.value === "image" && s.value || d.value === "video" && a.value ? (D(), B("div",
|
|
509
|
-
|
|
505
|
+
d.value === "image" && s.value || d.value === "video" && a.value ? (D(), B("div", At, [
|
|
506
|
+
S("i", {
|
|
510
507
|
class: Y(d.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
|
|
511
508
|
}, null, 2),
|
|
512
|
-
|
|
509
|
+
S("span", null, "Failed to load " + ue(d.value), 1)
|
|
513
510
|
])) : X("", !0)
|
|
514
511
|
])),
|
|
515
512
|
!N.value && (l.value || v.value || c.value) ? (D(), B("div", {
|
|
@@ -517,27 +514,27 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
517
514
|
class: "absolute top-2 left-2 w-7 h-7 flex items-center justify-center bg-black/60 backdrop-blur-sm text-white rounded-full shadow-sm opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none",
|
|
518
515
|
title: d.value === "video" ? "Video" : "Image"
|
|
519
516
|
}, [
|
|
520
|
-
|
|
517
|
+
S("i", {
|
|
521
518
|
class: Y(d.value === "video" ? "fas fa-video text-xs" : "fas fa-image text-xs")
|
|
522
519
|
}, null, 2)
|
|
523
|
-
], 8,
|
|
524
|
-
|
|
520
|
+
], 8, Ft)) : X("", !0),
|
|
521
|
+
g[7] || (g[7] = S("div", { class: "absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none" }, null, -1)),
|
|
525
522
|
i.remove ? (D(), B("button", {
|
|
526
523
|
key: 3,
|
|
527
524
|
class: "absolute top-2 right-2 w-8 h-8 flex items-center justify-center bg-white/90 backdrop-blur-sm text-slate-700 rounded-full shadow-sm opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 hover:bg-red-500 hover:text-white cursor-pointer z-10",
|
|
528
|
-
onClick:
|
|
525
|
+
onClick: g[3] || (g[3] = ze((M) => i.remove(i.item), ["stop"])),
|
|
529
526
|
"aria-label": "Remove item"
|
|
530
|
-
},
|
|
531
|
-
|
|
527
|
+
}, g[6] || (g[6] = [
|
|
528
|
+
S("i", { class: "fas fa-times text-sm" }, null, -1)
|
|
532
529
|
]))) : X("", !0),
|
|
533
|
-
|
|
534
|
-
|
|
530
|
+
S("div", Wt, [
|
|
531
|
+
S("p", Ot, "Item #" + ue(String(i.item.id).split("-")[0]), 1)
|
|
535
532
|
])
|
|
536
533
|
])
|
|
537
534
|
])
|
|
538
535
|
], 512));
|
|
539
536
|
}
|
|
540
|
-
}),
|
|
537
|
+
}), jt = /* @__PURE__ */ Le({
|
|
541
538
|
__name: "Masonry",
|
|
542
539
|
props: {
|
|
543
540
|
getNextPage: {
|
|
@@ -669,18 +666,18 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
669
666
|
if (!Array.isArray(t) || t.length === 0) return;
|
|
670
667
|
const u = t.filter((y) => !z(y == null ? void 0 : y.width) || !z(y == null ? void 0 : y.height));
|
|
671
668
|
if (u.length === 0) return;
|
|
672
|
-
const
|
|
669
|
+
const p = [];
|
|
673
670
|
for (const y of u) {
|
|
674
|
-
const
|
|
675
|
-
N.value.has(
|
|
671
|
+
const j = (y == null ? void 0 : y.id) ?? `idx:${t.indexOf(y)}`;
|
|
672
|
+
N.value.has(j) || (N.value.add(j), p.push(j));
|
|
676
673
|
}
|
|
677
|
-
if (
|
|
678
|
-
const y =
|
|
674
|
+
if (p.length > 0) {
|
|
675
|
+
const y = p.slice(0, 10);
|
|
679
676
|
console.warn(
|
|
680
677
|
"[Masonry] Items missing width/height detected:",
|
|
681
678
|
{
|
|
682
679
|
context: o,
|
|
683
|
-
count:
|
|
680
|
+
count: p.length,
|
|
684
681
|
sampleIds: y,
|
|
685
682
|
hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
|
|
686
683
|
}
|
|
@@ -689,21 +686,21 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
689
686
|
} catch {
|
|
690
687
|
}
|
|
691
688
|
}
|
|
692
|
-
const
|
|
689
|
+
const E = k(0), i = k(0), g = s.virtualBufferPx, M = k(!1), I = k({
|
|
693
690
|
distanceToTrigger: 0,
|
|
694
691
|
isNearTrigger: !1
|
|
695
692
|
}), b = (t) => {
|
|
696
693
|
if (!c.value) return;
|
|
697
|
-
const { scrollTop: o, clientHeight: u } = c.value,
|
|
694
|
+
const { scrollTop: o, clientHeight: u } = c.value, p = o + u, y = t ?? ge(n.value, h.value), j = y.length ? Math.max(...y) : 0, G = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, ee = G >= 0 ? Math.max(0, j - G) : Math.max(0, j + G), we = Math.max(0, ee - p), De = we <= 100;
|
|
698
695
|
I.value = {
|
|
699
696
|
distanceToTrigger: Math.round(we),
|
|
700
697
|
isNearTrigger: De
|
|
701
698
|
};
|
|
702
|
-
}, { onEnter: A, onBeforeEnter: P, onBeforeLeave: H, onLeave:
|
|
699
|
+
}, { onEnter: A, onBeforeEnter: P, onBeforeLeave: H, onLeave: L } = It(n, { leaveDurationMs: s.leaveDurationMs });
|
|
703
700
|
function _(t, o) {
|
|
704
701
|
if (M.value) {
|
|
705
|
-
const u = parseInt(t.dataset.left || "0", 10),
|
|
706
|
-
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${u}px, ${
|
|
702
|
+
const u = parseInt(t.dataset.left || "0", 10), p = parseInt(t.dataset.top || "0", 10);
|
|
703
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${u}px, ${p}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
|
|
707
704
|
t.style.transition = "", o();
|
|
708
705
|
});
|
|
709
706
|
} else
|
|
@@ -720,13 +717,13 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
720
717
|
M.value || H(t);
|
|
721
718
|
}
|
|
722
719
|
function K(t, o) {
|
|
723
|
-
M.value ? o() :
|
|
720
|
+
M.value ? o() : L(t, o);
|
|
724
721
|
}
|
|
725
722
|
const oe = te(() => {
|
|
726
|
-
const t =
|
|
727
|
-
return !u || u.length === 0 ? [] : u.filter((
|
|
728
|
-
const y =
|
|
729
|
-
return
|
|
723
|
+
const t = E.value - g, o = E.value + i.value + g, u = n.value;
|
|
724
|
+
return !u || u.length === 0 ? [] : u.filter((p) => {
|
|
725
|
+
const y = p.top;
|
|
726
|
+
return p.top + p.columnHeight >= t && y <= o;
|
|
730
727
|
});
|
|
731
728
|
}), { handleScroll: Q } = Pt({
|
|
732
729
|
container: c,
|
|
@@ -751,8 +748,8 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
751
748
|
removeAll: We,
|
|
752
749
|
loadNext: q,
|
|
753
750
|
loadPage: R,
|
|
754
|
-
refreshCurrentPage:
|
|
755
|
-
reset:
|
|
751
|
+
refreshCurrentPage: O,
|
|
752
|
+
reset: je,
|
|
756
753
|
init: Be,
|
|
757
754
|
paginationHistory: f,
|
|
758
755
|
cancelLoad: he,
|
|
@@ -763,31 +760,31 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
763
760
|
const o = wt(t);
|
|
764
761
|
let u = 0;
|
|
765
762
|
if (c.value) {
|
|
766
|
-
const { scrollTop:
|
|
767
|
-
u =
|
|
763
|
+
const { scrollTop: p, clientHeight: y } = c.value;
|
|
764
|
+
u = p + y + 100;
|
|
768
765
|
}
|
|
769
766
|
d.value = Math.max(o, u);
|
|
770
767
|
}
|
|
771
768
|
function C(t) {
|
|
772
769
|
if (!c.value) return;
|
|
773
770
|
$(t, "refreshLayout");
|
|
774
|
-
const o = t.map((
|
|
775
|
-
...
|
|
776
|
-
originalIndex:
|
|
771
|
+
const o = t.map((p, y) => ({
|
|
772
|
+
...p,
|
|
773
|
+
originalIndex: p.originalIndex ?? y
|
|
777
774
|
})), u = Ye(o, c.value, h.value, v.value);
|
|
778
775
|
Z(u), n.value = u;
|
|
779
776
|
}
|
|
780
777
|
function re(t, o) {
|
|
781
778
|
return new Promise((u) => {
|
|
782
|
-
const
|
|
783
|
-
o(
|
|
784
|
-
const
|
|
779
|
+
const p = Math.max(0, t | 0), y = Date.now();
|
|
780
|
+
o(p, p);
|
|
781
|
+
const j = setInterval(() => {
|
|
785
782
|
if (W.value) {
|
|
786
|
-
clearInterval(
|
|
783
|
+
clearInterval(j), u();
|
|
787
784
|
return;
|
|
788
785
|
}
|
|
789
|
-
const G = Date.now() - y, ee = Math.max(0,
|
|
790
|
-
o(ee,
|
|
786
|
+
const G = Date.now() - y, ee = Math.max(0, p - G);
|
|
787
|
+
o(ee, p), ee <= 0 && (clearInterval(j), u());
|
|
791
788
|
}, 100);
|
|
792
789
|
});
|
|
793
790
|
}
|
|
@@ -802,7 +799,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
802
799
|
async function F(t) {
|
|
803
800
|
let o = 0;
|
|
804
801
|
const u = s.retryMaxAttempts;
|
|
805
|
-
let
|
|
802
|
+
let p = s.retryInitialDelayMs;
|
|
806
803
|
for (; ; )
|
|
807
804
|
try {
|
|
808
805
|
const y = await t();
|
|
@@ -810,9 +807,9 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
810
807
|
} catch (y) {
|
|
811
808
|
if (o++, o > u)
|
|
812
809
|
throw a("retry:stop", { attempt: o - 1, success: !1 }), y;
|
|
813
|
-
a("retry:start", { attempt: o, max: u, totalMs:
|
|
814
|
-
a("retry:tick", { attempt: o, remainingMs:
|
|
815
|
-
}),
|
|
810
|
+
a("retry:start", { attempt: o, max: u, totalMs: p }), await re(p, (j, G) => {
|
|
811
|
+
a("retry:tick", { attempt: o, remainingMs: j, totalMs: G });
|
|
812
|
+
}), p += s.retryBackoffStepMs;
|
|
816
813
|
}
|
|
817
814
|
}
|
|
818
815
|
async function R(t) {
|
|
@@ -845,7 +842,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
845
842
|
}
|
|
846
843
|
}
|
|
847
844
|
}
|
|
848
|
-
async function
|
|
845
|
+
async function O() {
|
|
849
846
|
if (console.log("[Masonry] refreshCurrentPage called, isLoading:", m.value, "currentPage:", T.value), !m.value) {
|
|
850
847
|
W.value = !1, m.value = !0;
|
|
851
848
|
try {
|
|
@@ -871,7 +868,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
871
868
|
const o = n.value.filter((u) => u.id !== t.id);
|
|
872
869
|
if (n.value = o, await J(), console.log("[Masonry] remove - next.length:", o.length, "paginationHistory.length:", f.value.length), o.length === 0 && f.value.length > 0) {
|
|
873
870
|
if (s.autoRefreshOnEmpty)
|
|
874
|
-
console.log("[Masonry] All items removed, calling refreshCurrentPage"), await
|
|
871
|
+
console.log("[Masonry] All items removed, calling refreshCurrentPage"), await O();
|
|
875
872
|
else {
|
|
876
873
|
console.log("[Masonry] All items removed, calling loadNext and forcing backfill");
|
|
877
874
|
try {
|
|
@@ -887,10 +884,10 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
887
884
|
}
|
|
888
885
|
async function V(t) {
|
|
889
886
|
if (!t || t.length === 0) return;
|
|
890
|
-
const o = new Set(t.map((
|
|
887
|
+
const o = new Set(t.map((p) => p.id)), u = n.value.filter((p) => !o.has(p.id));
|
|
891
888
|
if (n.value = u, await J(), u.length === 0 && f.value.length > 0) {
|
|
892
889
|
if (s.autoRefreshOnEmpty)
|
|
893
|
-
await
|
|
890
|
+
await O();
|
|
894
891
|
else
|
|
895
892
|
try {
|
|
896
893
|
await q(), await le(0, !0);
|
|
@@ -898,7 +895,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
898
895
|
}
|
|
899
896
|
return;
|
|
900
897
|
}
|
|
901
|
-
await new Promise((
|
|
898
|
+
await new Promise((p) => requestAnimationFrame(() => p())), requestAnimationFrame(() => {
|
|
902
899
|
C(u);
|
|
903
900
|
});
|
|
904
901
|
}
|
|
@@ -912,16 +909,16 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
912
909
|
async function We() {
|
|
913
910
|
ye({ behavior: "smooth" }), n.value = [], d.value = 0, await J(), a("remove-all:complete");
|
|
914
911
|
}
|
|
915
|
-
function
|
|
916
|
-
h.value = ve(v.value), C(n.value), c.value && (
|
|
912
|
+
function Oe() {
|
|
913
|
+
h.value = ve(v.value), C(n.value), c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight);
|
|
917
914
|
}
|
|
918
|
-
let
|
|
915
|
+
let ie = !1;
|
|
919
916
|
const W = k(!1);
|
|
920
917
|
async function le(t, o = !1) {
|
|
921
|
-
if (!o && !s.backfillEnabled ||
|
|
918
|
+
if (!o && !s.backfillEnabled || ie || W.value) return;
|
|
922
919
|
const u = (t || 0) + (s.pageSize || 0);
|
|
923
920
|
if (!(!s.pageSize || s.pageSize <= 0 || f.value[f.value.length - 1] == null) && !(n.value.length >= u)) {
|
|
924
|
-
|
|
921
|
+
ie = !0;
|
|
925
922
|
try {
|
|
926
923
|
let y = 0;
|
|
927
924
|
for (a("backfill:start", { target: u, fetched: n.value.length, calls: y }); n.value.length < u && y < s.backfillMaxCalls && f.value[f.value.length - 1] != null && !W.value && (await re(s.backfillDelayMs, (G, ee) => {
|
|
@@ -933,10 +930,10 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
933
930
|
totalMs: ee
|
|
934
931
|
});
|
|
935
932
|
}), !W.value); ) {
|
|
936
|
-
const
|
|
933
|
+
const j = f.value[f.value.length - 1];
|
|
937
934
|
try {
|
|
938
935
|
m.value = !0;
|
|
939
|
-
const G = await x(
|
|
936
|
+
const G = await x(j);
|
|
940
937
|
if (W.value) break;
|
|
941
938
|
f.value.push(G.nextPage);
|
|
942
939
|
} finally {
|
|
@@ -946,14 +943,14 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
946
943
|
}
|
|
947
944
|
a("backfill:stop", { fetched: n.value.length, calls: y });
|
|
948
945
|
} finally {
|
|
949
|
-
|
|
946
|
+
ie = !1;
|
|
950
947
|
}
|
|
951
948
|
}
|
|
952
949
|
}
|
|
953
950
|
function he() {
|
|
954
|
-
W.value = !0, m.value = !1,
|
|
951
|
+
W.value = !0, m.value = !1, ie = !1;
|
|
955
952
|
}
|
|
956
|
-
function
|
|
953
|
+
function je() {
|
|
957
954
|
he(), W.value = !1, c.value && c.value.scrollTo({
|
|
958
955
|
top: 0,
|
|
959
956
|
behavior: "smooth"
|
|
@@ -963,10 +960,10 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
963
960
|
};
|
|
964
961
|
}
|
|
965
962
|
const be = ke(async () => {
|
|
966
|
-
c.value && (
|
|
967
|
-
const t =
|
|
963
|
+
c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight), M.value = !0, await J(), await new Promise((o) => requestAnimationFrame(() => o())), M.value = !1;
|
|
964
|
+
const t = ge(n.value, h.value);
|
|
968
965
|
Q(t), b(t);
|
|
969
|
-
}, 200), xe = ke(
|
|
966
|
+
}, 200), xe = ke(Oe, 200);
|
|
970
967
|
function Be(t, o, u) {
|
|
971
968
|
T.value = o, f.value = [o], f.value.push(u), $(t, "init"), C([...n.value, ...t]), b();
|
|
972
969
|
}
|
|
@@ -979,7 +976,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
979
976
|
), Se(async () => {
|
|
980
977
|
var t;
|
|
981
978
|
try {
|
|
982
|
-
h.value = ve(v.value), c.value && (
|
|
979
|
+
h.value = ve(v.value), c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight);
|
|
983
980
|
const o = s.loadAtPage;
|
|
984
981
|
f.value = [o], s.skipInitialLoad || await R(f.value[0]), b();
|
|
985
982
|
} catch (o) {
|
|
@@ -994,7 +991,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
994
991
|
ref_key: "container",
|
|
995
992
|
ref: c
|
|
996
993
|
}, [
|
|
997
|
-
|
|
994
|
+
S("div", {
|
|
998
995
|
class: "relative",
|
|
999
996
|
style: Re({ height: `${d.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
|
|
1000
997
|
}, [
|
|
@@ -1007,18 +1004,18 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
1007
1004
|
onBeforeLeave: ne
|
|
1008
1005
|
}, {
|
|
1009
1006
|
default: Ce(() => [
|
|
1010
|
-
(D(!0), B(qe, null, Ve(oe.value, (u,
|
|
1007
|
+
(D(!0), B(qe, null, Ve(oe.value, (u, p) => (D(), B("div", Ge({
|
|
1011
1008
|
key: `${u.page}-${u.id}`,
|
|
1012
1009
|
class: "absolute masonry-item",
|
|
1013
1010
|
ref_for: !0
|
|
1014
|
-
}, Ue(Mt)(u,
|
|
1011
|
+
}, Ue(Mt)(u, p), {
|
|
1015
1012
|
style: { paddingTop: `${v.value.header}px`, paddingBottom: `${v.value.footer}px` }
|
|
1016
1013
|
}), [
|
|
1017
1014
|
$e(t.$slots, "default", {
|
|
1018
1015
|
item: u,
|
|
1019
1016
|
remove: U
|
|
1020
1017
|
}, () => [
|
|
1021
|
-
Te(
|
|
1018
|
+
Te(pe, {
|
|
1022
1019
|
item: u,
|
|
1023
1020
|
remove: U
|
|
1024
1021
|
}, null, 8, ["item"])
|
|
@@ -1031,25 +1028,25 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
|
|
|
1031
1028
|
key: 0,
|
|
1032
1029
|
class: Y(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !I.value.isNearTrigger, "opacity-100": I.value.isNearTrigger }])
|
|
1033
1030
|
}, [
|
|
1034
|
-
|
|
1035
|
-
o[0] || (o[0] =
|
|
1036
|
-
|
|
1031
|
+
S("span", null, ue(n.value.length) + " items", 1),
|
|
1032
|
+
o[0] || (o[0] = S("span", { class: "mx-2" }, "|", -1)),
|
|
1033
|
+
S("span", null, ue(I.value.distanceToTrigger) + "px to load", 1)
|
|
1037
1034
|
], 2)) : X("", !0)
|
|
1038
1035
|
], 4)
|
|
1039
1036
|
], 2));
|
|
1040
1037
|
}
|
|
1041
|
-
}),
|
|
1038
|
+
}), Bt = (e, r) => {
|
|
1042
1039
|
const l = e.__vccOpts || e;
|
|
1043
1040
|
for (const [s, w] of r)
|
|
1044
1041
|
l[s] = w;
|
|
1045
1042
|
return l;
|
|
1046
|
-
}, Ee = /* @__PURE__ */
|
|
1043
|
+
}, Ee = /* @__PURE__ */ Bt(jt, [["__scopeId", "data-v-110c3294"]]), zt = {
|
|
1047
1044
|
install(e) {
|
|
1048
|
-
e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem",
|
|
1045
|
+
e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem", pe), e.component("WMasonryItem", pe);
|
|
1049
1046
|
}
|
|
1050
1047
|
};
|
|
1051
1048
|
export {
|
|
1052
1049
|
Ee as Masonry,
|
|
1053
|
-
|
|
1054
|
-
|
|
1050
|
+
pe as MasonryItem,
|
|
1051
|
+
zt as default
|
|
1055
1052
|
};
|
package/package.json
CHANGED
|
@@ -289,13 +289,8 @@ watch(
|
|
|
289
289
|
]"
|
|
290
290
|
>
|
|
291
291
|
<!-- Media type indicator - shown BEFORE preloading starts -->
|
|
292
|
-
<div
|
|
293
|
-
class="
|
|
294
|
-
>
|
|
295
|
-
<div class="w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm">
|
|
296
|
-
<i :class="mediaType === 'video' ? 'fas fa-video text-xl' : 'fas fa-image text-xl'"></i>
|
|
297
|
-
</div>
|
|
298
|
-
<span class="text-xs font-medium uppercase">{{ mediaType }}</span>
|
|
292
|
+
<div class="w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm">
|
|
293
|
+
<i :class="mediaType === 'video' ? 'fas fa-video text-xl text-slate-400' : 'fas fa-image text-xl text-slate-400'"></i>
|
|
299
294
|
</div>
|
|
300
295
|
</div>
|
|
301
296
|
|