@wyxos/vibe 1.6.3 → 1.6.5
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/README.md +188 -139
- package/lib/demo.webp +0 -0
- package/lib/index.js +518 -423
- package/lib/vibe.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +124 -23
- package/src/Masonry.vue +17 -7
- package/src/components/MasonryItem.vue +132 -0
- package/src/style.css +30 -0
package/lib/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { nextTick as
|
|
2
|
-
let
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
1
|
+
import { nextTick as Q, defineComponent as Le, ref as L, onMounted as He, watch as Ne, createElementBlock as q, openBlock as V, renderSlot as $e, createElementVNode as O, createCommentVNode as oe, withModifiers as ze, toDisplayString as de, computed as se, onUnmounted as Re, normalizeClass as we, normalizeStyle as Ce, createVNode as Me, TransitionGroup as _e, withCtx as qe, Fragment as Ve, renderList as Ge, mergeProps as Te, unref as Ue } from "vue";
|
|
2
|
+
let ue = null;
|
|
3
|
+
function Xe() {
|
|
4
|
+
if (ue != null) return ue;
|
|
5
5
|
const e = document.createElement("div");
|
|
6
6
|
e.style.visibility = "hidden", e.style.overflow = "scroll", e.style.msOverflowStyle = "scrollbar", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e);
|
|
7
7
|
const o = document.createElement("div");
|
|
8
8
|
o.style.width = "100%", e.appendChild(o);
|
|
9
|
-
const
|
|
10
|
-
return document.body.removeChild(e),
|
|
9
|
+
const l = e.offsetWidth - o.offsetWidth;
|
|
10
|
+
return document.body.removeChild(e), ue = l, l;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Ye(e, o, l, s = {}) {
|
|
13
13
|
const {
|
|
14
|
-
gutterX:
|
|
15
|
-
gutterY:
|
|
16
|
-
header:
|
|
17
|
-
footer:
|
|
18
|
-
paddingLeft:
|
|
14
|
+
gutterX: h = 0,
|
|
15
|
+
gutterY: v = 0,
|
|
16
|
+
header: a = 0,
|
|
17
|
+
footer: n = 0,
|
|
18
|
+
paddingLeft: d = 0,
|
|
19
19
|
paddingRight: u = 0,
|
|
20
20
|
sizes: c = {
|
|
21
21
|
base: 1,
|
|
@@ -25,191 +25,191 @@ function Ge(e, o, i, s = {}) {
|
|
|
25
25
|
xl: 5,
|
|
26
26
|
"2xl": 6
|
|
27
27
|
},
|
|
28
|
-
placement:
|
|
28
|
+
placement: b = "masonry"
|
|
29
29
|
} = s;
|
|
30
|
-
let
|
|
30
|
+
let m = 0, x = 0;
|
|
31
31
|
try {
|
|
32
32
|
if (o && o.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
|
|
33
33
|
const w = window.getComputedStyle(o);
|
|
34
|
-
|
|
34
|
+
m = parseFloat(w.paddingLeft) || 0, x = parseFloat(w.paddingRight) || 0;
|
|
35
35
|
}
|
|
36
36
|
} catch {
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
return Math.round(S *
|
|
38
|
+
const F = (d || 0) + m, _ = (u || 0) + x, H = o.offsetWidth - o.clientWidth, M = H > 0 ? H + 2 : Xe() + 2, P = o.offsetWidth - M - F - _, U = h * (l - 1), S = Math.floor((P - U) / l), T = e.map((w) => {
|
|
39
|
+
const N = w.width, I = w.height;
|
|
40
|
+
return Math.round(S * I / N) + n + a;
|
|
41
41
|
});
|
|
42
|
-
if (
|
|
43
|
-
const w =
|
|
42
|
+
if (b === "sequential-balanced") {
|
|
43
|
+
const w = T.length;
|
|
44
44
|
if (w === 0) return [];
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
for (let
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
else if (
|
|
45
|
+
const N = (p, k, B) => p + (k > 0 ? v : 0) + B;
|
|
46
|
+
let I = Math.max(...T), D = T.reduce((p, k) => p + k, 0) + v * Math.max(0, w - 1);
|
|
47
|
+
const Z = (p) => {
|
|
48
|
+
let k = 1, B = 0, z = 0;
|
|
49
|
+
for (let $ = 0; $ < w; $++) {
|
|
50
|
+
const G = T[$], R = N(B, z, G);
|
|
51
|
+
if (R <= p)
|
|
52
|
+
B = R, z++;
|
|
53
|
+
else if (k++, B = G, z = 1, G > p || k > l) return !1;
|
|
54
54
|
}
|
|
55
|
-
return
|
|
55
|
+
return k <= l;
|
|
56
56
|
};
|
|
57
|
-
for (;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
const
|
|
62
|
-
let
|
|
63
|
-
for (let
|
|
64
|
-
const
|
|
65
|
-
!(
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
for (let
|
|
70
|
-
const
|
|
71
|
-
for (let
|
|
72
|
-
const
|
|
73
|
-
...e[
|
|
57
|
+
for (; I < D; ) {
|
|
58
|
+
const p = Math.floor((I + D) / 2);
|
|
59
|
+
Z(p) ? D = p : I = p + 1;
|
|
60
|
+
}
|
|
61
|
+
const ee = D, X = new Array(l).fill(0);
|
|
62
|
+
let te = l - 1, Y = 0, J = 0;
|
|
63
|
+
for (let p = w - 1; p >= 0; p--) {
|
|
64
|
+
const k = T[p], B = p < te;
|
|
65
|
+
!(N(Y, J, k) <= ee) || B ? (X[te] = p + 1, te--, Y = k, J = 1) : (Y = N(Y, J, k), J++);
|
|
66
|
+
}
|
|
67
|
+
X[0] = 0;
|
|
68
|
+
const j = [], ae = new Array(l).fill(0);
|
|
69
|
+
for (let p = 0; p < l; p++) {
|
|
70
|
+
const k = X[p], B = p + 1 < l ? X[p + 1] : w, z = p * (S + h);
|
|
71
|
+
for (let $ = k; $ < B; $++) {
|
|
72
|
+
const R = {
|
|
73
|
+
...e[$],
|
|
74
74
|
columnWidth: S,
|
|
75
75
|
imageHeight: 0,
|
|
76
76
|
columnHeight: 0,
|
|
77
77
|
left: 0,
|
|
78
78
|
top: 0
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
R.imageHeight = T[$] - (n + a), R.columnHeight = T[$], R.left = z, R.top = ae[p], ae[p] += R.columnHeight + ($ + 1 < B ? v : 0), j.push(R);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return
|
|
83
|
+
return j;
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const y = new Array(l).fill(0), W = [];
|
|
86
86
|
for (let w = 0; w < e.length; w++) {
|
|
87
|
-
const
|
|
88
|
-
...
|
|
87
|
+
const N = e[w], I = {
|
|
88
|
+
...N,
|
|
89
89
|
columnWidth: 0,
|
|
90
90
|
imageHeight: 0,
|
|
91
91
|
columnHeight: 0,
|
|
92
92
|
left: 0,
|
|
93
93
|
top: 0
|
|
94
|
-
},
|
|
95
|
-
|
|
94
|
+
}, D = y.indexOf(Math.min(...y)), Z = N.width, ee = N.height;
|
|
95
|
+
I.columnWidth = S, I.left = D * (S + h), I.imageHeight = Math.round(S * ee / Z), I.columnHeight = I.imageHeight + n + a, I.top = y[D], y[D] += I.columnHeight + v, W.push(I);
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return W;
|
|
98
98
|
}
|
|
99
|
-
var
|
|
100
|
-
function
|
|
101
|
-
var o =
|
|
99
|
+
var Je = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Ae = Je || Ke || Function("return this")(), ie = Ae.Symbol, We = Object.prototype, Qe = We.hasOwnProperty, Ze = We.toString, re = ie ? ie.toStringTag : void 0;
|
|
100
|
+
function et(e) {
|
|
101
|
+
var o = Qe.call(e, re), l = e[re];
|
|
102
102
|
try {
|
|
103
|
-
e[
|
|
103
|
+
e[re] = void 0;
|
|
104
104
|
var s = !0;
|
|
105
105
|
} catch {
|
|
106
106
|
}
|
|
107
|
-
var
|
|
108
|
-
return s && (o ? e[
|
|
107
|
+
var h = Ze.call(e);
|
|
108
|
+
return s && (o ? e[re] = l : delete e[re]), h;
|
|
109
109
|
}
|
|
110
|
-
var
|
|
111
|
-
function
|
|
112
|
-
return
|
|
110
|
+
var tt = Object.prototype, at = tt.toString;
|
|
111
|
+
function nt(e) {
|
|
112
|
+
return at.call(e);
|
|
113
113
|
}
|
|
114
|
-
var
|
|
115
|
-
function
|
|
116
|
-
return e == null ? e === void 0 ?
|
|
114
|
+
var rt = "[object Null]", ot = "[object Undefined]", Ie = ie ? ie.toStringTag : void 0;
|
|
115
|
+
function lt(e) {
|
|
116
|
+
return e == null ? e === void 0 ? ot : rt : Ie && Ie in Object(e) ? et(e) : nt(e);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function st(e) {
|
|
119
119
|
return e != null && typeof e == "object";
|
|
120
120
|
}
|
|
121
|
-
var
|
|
122
|
-
function
|
|
123
|
-
return typeof e == "symbol" ||
|
|
121
|
+
var it = "[object Symbol]";
|
|
122
|
+
function ut(e) {
|
|
123
|
+
return typeof e == "symbol" || st(e) && lt(e) == it;
|
|
124
124
|
}
|
|
125
|
-
var
|
|
126
|
-
function
|
|
127
|
-
for (var o = e.length; o-- &&
|
|
125
|
+
var ct = /\s/;
|
|
126
|
+
function ft(e) {
|
|
127
|
+
for (var o = e.length; o-- && ct.test(e.charAt(o)); )
|
|
128
128
|
;
|
|
129
129
|
return o;
|
|
130
130
|
}
|
|
131
|
-
var
|
|
132
|
-
function
|
|
133
|
-
return e && e.slice(0,
|
|
131
|
+
var dt = /^\s+/;
|
|
132
|
+
function gt(e) {
|
|
133
|
+
return e && e.slice(0, ft(e) + 1).replace(dt, "");
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function ge(e) {
|
|
136
136
|
var o = typeof e;
|
|
137
137
|
return e != null && (o == "object" || o == "function");
|
|
138
138
|
}
|
|
139
|
-
var
|
|
140
|
-
function
|
|
139
|
+
var Pe = NaN, mt = /^[-+]0x[0-9a-f]+$/i, vt = /^0b[01]+$/i, pt = /^0o[0-7]+$/i, ht = parseInt;
|
|
140
|
+
function Se(e) {
|
|
141
141
|
if (typeof e == "number")
|
|
142
142
|
return e;
|
|
143
|
-
if (
|
|
144
|
-
return
|
|
145
|
-
if (
|
|
143
|
+
if (ut(e))
|
|
144
|
+
return Pe;
|
|
145
|
+
if (ge(e)) {
|
|
146
146
|
var o = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
147
|
-
e =
|
|
147
|
+
e = ge(o) ? o + "" : o;
|
|
148
148
|
}
|
|
149
149
|
if (typeof e != "string")
|
|
150
150
|
return e === 0 ? e : +e;
|
|
151
|
-
e =
|
|
152
|
-
var
|
|
153
|
-
return
|
|
151
|
+
e = gt(e);
|
|
152
|
+
var l = vt.test(e);
|
|
153
|
+
return l || pt.test(e) ? ht(e.slice(2), l ? 2 : 8) : mt.test(e) ? Pe : +e;
|
|
154
154
|
}
|
|
155
|
-
var
|
|
156
|
-
return
|
|
157
|
-
},
|
|
158
|
-
function
|
|
159
|
-
var s,
|
|
155
|
+
var ce = function() {
|
|
156
|
+
return Ae.Date.now();
|
|
157
|
+
}, yt = "Expected a function", bt = Math.max, xt = Math.min;
|
|
158
|
+
function ke(e, o, l) {
|
|
159
|
+
var s, h, v, a, n, d, u = 0, c = !1, b = !1, m = !0;
|
|
160
160
|
if (typeof e != "function")
|
|
161
|
-
throw new TypeError(
|
|
162
|
-
o =
|
|
163
|
-
function
|
|
164
|
-
var
|
|
165
|
-
return s =
|
|
161
|
+
throw new TypeError(yt);
|
|
162
|
+
o = Se(o) || 0, ge(l) && (c = !!l.leading, b = "maxWait" in l, v = b ? bt(Se(l.maxWait) || 0, o) : v, m = "trailing" in l ? !!l.trailing : m);
|
|
163
|
+
function x(y) {
|
|
164
|
+
var W = s, w = h;
|
|
165
|
+
return s = h = void 0, u = y, a = e.apply(w, W), a;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return u =
|
|
167
|
+
function F(y) {
|
|
168
|
+
return u = y, n = setTimeout(M, o), c ? x(y) : a;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
var
|
|
172
|
-
return
|
|
170
|
+
function _(y) {
|
|
171
|
+
var W = y - d, w = y - u, N = o - W;
|
|
172
|
+
return b ? xt(N, v - w) : N;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
var
|
|
176
|
-
return
|
|
174
|
+
function H(y) {
|
|
175
|
+
var W = y - d, w = y - u;
|
|
176
|
+
return d === void 0 || W >= o || W < 0 || b && w >= v;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
var
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
182
|
-
|
|
178
|
+
function M() {
|
|
179
|
+
var y = ce();
|
|
180
|
+
if (H(y))
|
|
181
|
+
return P(y);
|
|
182
|
+
n = setTimeout(M, _(y));
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
return
|
|
184
|
+
function P(y) {
|
|
185
|
+
return n = void 0, m && s ? x(y) : (s = h = void 0, a);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
187
|
+
function U() {
|
|
188
|
+
n !== void 0 && clearTimeout(n), u = 0, s = d = h = n = void 0;
|
|
189
189
|
}
|
|
190
190
|
function S() {
|
|
191
|
-
return
|
|
191
|
+
return n === void 0 ? a : P(ce());
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
var
|
|
195
|
-
if (s = arguments,
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
198
|
-
if (
|
|
199
|
-
return clearTimeout(
|
|
200
|
-
}
|
|
201
|
-
return
|
|
193
|
+
function T() {
|
|
194
|
+
var y = ce(), W = H(y);
|
|
195
|
+
if (s = arguments, h = this, d = y, W) {
|
|
196
|
+
if (n === void 0)
|
|
197
|
+
return F(d);
|
|
198
|
+
if (b)
|
|
199
|
+
return clearTimeout(n), n = setTimeout(M, o), x(d);
|
|
200
|
+
}
|
|
201
|
+
return n === void 0 && (n = setTimeout(M, o)), a;
|
|
202
202
|
}
|
|
203
|
-
return
|
|
203
|
+
return T.cancel = U, T.flush = S, T;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
const o = window.innerWidth,
|
|
207
|
-
return o >= 1536 &&
|
|
205
|
+
function fe(e) {
|
|
206
|
+
const o = window.innerWidth, l = e.sizes;
|
|
207
|
+
return o >= 1536 && l["2xl"] ? l["2xl"] : o >= 1280 && l.xl ? l.xl : o >= 1024 && l.lg ? l.lg : o >= 768 && l.md ? l.md : o >= 640 && l.sm ? l.sm : l.base;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
return e.reduce((
|
|
209
|
+
function wt(e) {
|
|
210
|
+
return e.reduce((l, s) => Math.max(l, s.top + s.columnHeight), 0) + 500;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function Mt(e) {
|
|
213
213
|
return {
|
|
214
214
|
transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
|
|
215
215
|
top: "0px",
|
|
@@ -218,102 +218,196 @@ function bt(e) {
|
|
|
218
218
|
height: `${e.columnHeight}px`
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Tt(e, o = 0) {
|
|
222
222
|
return {
|
|
223
|
-
style:
|
|
223
|
+
style: Mt(e),
|
|
224
224
|
"data-top": e.top,
|
|
225
225
|
"data-left": e.left,
|
|
226
226
|
"data-id": `${e.page}-${e.id}`,
|
|
227
227
|
"data-index": o
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function me(e, o) {
|
|
231
231
|
if (!e.length || o <= 0)
|
|
232
232
|
return new Array(Math.max(1, o)).fill(0);
|
|
233
|
-
const s = Array.from(new Set(e.map((
|
|
234
|
-
for (let
|
|
235
|
-
const
|
|
236
|
-
for (const
|
|
237
|
-
const
|
|
238
|
-
|
|
233
|
+
const s = Array.from(new Set(e.map((a) => a.left))).sort((a, n) => a - n).slice(0, o), h = /* @__PURE__ */ new Map();
|
|
234
|
+
for (let a = 0; a < s.length; a++) h.set(s[a], a);
|
|
235
|
+
const v = new Array(s.length).fill(0);
|
|
236
|
+
for (const a of e) {
|
|
237
|
+
const n = h.get(a.left);
|
|
238
|
+
n != null && (v[n] = Math.max(v[n], a.top + a.columnHeight));
|
|
239
239
|
}
|
|
240
|
-
for (;
|
|
241
|
-
return
|
|
240
|
+
for (; v.length < o; ) v.push(0);
|
|
241
|
+
return v;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
function
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
243
|
+
function It(e, o) {
|
|
244
|
+
function l(a, n) {
|
|
245
|
+
const d = parseInt(a.dataset.left || "0", 10), u = parseInt(a.dataset.top || "0", 10), c = parseInt(a.dataset.index || "0", 10), b = Math.min(c * 20, 160), m = a.style.getPropertyValue("--masonry-opacity-delay");
|
|
246
|
+
a.style.setProperty("--masonry-opacity-delay", `${b}ms`), requestAnimationFrame(() => {
|
|
247
|
+
a.style.opacity = "1", a.style.transform = `translate3d(${d}px, ${u}px, 0) scale(1)`;
|
|
248
|
+
const x = () => {
|
|
249
|
+
m ? a.style.setProperty("--masonry-opacity-delay", m) : a.style.removeProperty("--masonry-opacity-delay"), a.removeEventListener("transitionend", x), n();
|
|
250
250
|
};
|
|
251
|
-
|
|
251
|
+
a.addEventListener("transitionend", x);
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
-
function s(
|
|
255
|
-
const
|
|
256
|
-
|
|
254
|
+
function s(a) {
|
|
255
|
+
const n = parseInt(a.dataset.left || "0", 10), d = parseInt(a.dataset.top || "0", 10);
|
|
256
|
+
a.style.opacity = "0", a.style.transform = `translate3d(${n}px, ${d + 10}px, 0) scale(0.985)`;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
function h(a) {
|
|
259
|
+
const n = parseInt(a.dataset.left || "0", 10), d = parseInt(a.dataset.top || "0", 10);
|
|
260
|
+
a.style.transition = "none", a.style.opacity = "1", a.style.transform = `translate3d(${n}px, ${d}px, 0) scale(1)`, a.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
|
|
261
|
+
a.style.transition = "";
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
const
|
|
266
|
-
let
|
|
267
|
-
if (!Number.isFinite(
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
(!
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
},
|
|
264
|
+
function v(a, n) {
|
|
265
|
+
const d = parseInt(a.dataset.left || "0", 10), u = parseInt(a.dataset.top || "0", 10), c = typeof (o == null ? void 0 : o.leaveDurationMs) == "number" ? o.leaveDurationMs : NaN;
|
|
266
|
+
let b = Number.isFinite(c) && c > 0 ? c : NaN;
|
|
267
|
+
if (!Number.isFinite(b)) {
|
|
268
|
+
const M = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", P = parseFloat(M);
|
|
269
|
+
b = Number.isFinite(P) && P > 0 ? P : 200;
|
|
270
|
+
}
|
|
271
|
+
const m = a.style.transitionDuration, x = () => {
|
|
272
|
+
a.removeEventListener("transitionend", F), clearTimeout(_), a.style.transitionDuration = m || "";
|
|
273
|
+
}, F = (H) => {
|
|
274
|
+
(!H || H.target === a) && (x(), n());
|
|
275
|
+
}, _ = setTimeout(() => {
|
|
276
|
+
x(), n();
|
|
277
|
+
}, b + 100);
|
|
278
278
|
requestAnimationFrame(() => {
|
|
279
|
-
|
|
279
|
+
a.style.transitionDuration = `${b}ms`, a.style.opacity = "0", a.style.transform = `translate3d(${d}px, ${u + 10}px, 0) scale(0.985)`, a.addEventListener("transitionend", F);
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
return {
|
|
283
|
-
onEnter:
|
|
283
|
+
onEnter: l,
|
|
284
284
|
onBeforeEnter: s,
|
|
285
|
-
onBeforeLeave:
|
|
286
|
-
onLeave:
|
|
285
|
+
onBeforeLeave: h,
|
|
286
|
+
onLeave: v
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function Pt({
|
|
290
290
|
container: e,
|
|
291
291
|
masonry: o,
|
|
292
|
-
columns:
|
|
292
|
+
columns: l,
|
|
293
293
|
containerHeight: s,
|
|
294
|
-
isLoading:
|
|
295
|
-
pageSize:
|
|
296
|
-
refreshLayout:
|
|
297
|
-
setItemsRaw:
|
|
298
|
-
loadNext:
|
|
294
|
+
isLoading: h,
|
|
295
|
+
pageSize: v,
|
|
296
|
+
refreshLayout: a,
|
|
297
|
+
setItemsRaw: n,
|
|
298
|
+
loadNext: d,
|
|
299
299
|
loadThresholdPx: u
|
|
300
300
|
}) {
|
|
301
301
|
let c = 0;
|
|
302
|
-
async function
|
|
302
|
+
async function b(m) {
|
|
303
303
|
if (!e.value) return;
|
|
304
|
-
const
|
|
304
|
+
const x = m ?? me(o.value, l.value), F = x.length ? Math.max(...x) : 0, _ = e.value.scrollTop + e.value.clientHeight, H = e.value.scrollTop > c + 1;
|
|
305
305
|
c = e.value.scrollTop;
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
await
|
|
306
|
+
const M = typeof u == "number" ? u : 200, P = M >= 0 ? Math.max(0, F - M) : Math.max(0, F + M);
|
|
307
|
+
if (_ >= P && H && !h.value) {
|
|
308
|
+
await d(), await Q();
|
|
309
309
|
return;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
return {
|
|
313
|
-
handleScroll:
|
|
313
|
+
handleScroll: b
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
|
-
const
|
|
316
|
+
const St = { class: "relative w-full h-full group" }, kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, Et = {
|
|
317
|
+
key: 0,
|
|
318
|
+
class: "absolute inset-0 flex items-center justify-center bg-slate-100"
|
|
319
|
+
}, Lt = {
|
|
320
|
+
key: 1,
|
|
321
|
+
class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-50 text-slate-400 text-sm p-4 text-center"
|
|
322
|
+
}, Ht = ["src"], Nt = { 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" }, $t = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, ve = /* @__PURE__ */ Le({
|
|
323
|
+
__name: "MasonryItem",
|
|
324
|
+
props: {
|
|
325
|
+
item: {},
|
|
326
|
+
remove: { type: Function }
|
|
327
|
+
},
|
|
328
|
+
setup(e) {
|
|
329
|
+
const o = e, l = L(!1), s = L(!1), h = L(null);
|
|
330
|
+
function v(a) {
|
|
331
|
+
return new Promise((n, d) => {
|
|
332
|
+
if (!a) {
|
|
333
|
+
d(new Error("No image source provided"));
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const u = new Image(), c = Date.now(), b = 300;
|
|
337
|
+
u.onload = () => {
|
|
338
|
+
const m = Date.now() - c, x = Math.max(0, b - m);
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
l.value = !0, s.value = !1, n();
|
|
341
|
+
}, x);
|
|
342
|
+
}, u.onerror = () => {
|
|
343
|
+
s.value = !0, l.value = !1, d(new Error("Failed to load image"));
|
|
344
|
+
}, u.src = a;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return He(async () => {
|
|
348
|
+
var n, d;
|
|
349
|
+
console.log("[MasonryItem] Component mounted", (n = o.item) == null ? void 0 : n.id);
|
|
350
|
+
const a = (d = o.item) == null ? void 0 : d.src;
|
|
351
|
+
if (a) {
|
|
352
|
+
h.value = a, l.value = !1, s.value = !1;
|
|
353
|
+
try {
|
|
354
|
+
await v(a);
|
|
355
|
+
} catch {
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}), Ne(
|
|
359
|
+
() => {
|
|
360
|
+
var a;
|
|
361
|
+
return (a = o.item) == null ? void 0 : a.src;
|
|
362
|
+
},
|
|
363
|
+
async (a) => {
|
|
364
|
+
if (a && a !== h.value) {
|
|
365
|
+
l.value = !1, s.value = !1, h.value = a;
|
|
366
|
+
try {
|
|
367
|
+
await v(a);
|
|
368
|
+
} catch {
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
), (a, n) => (V(), q("div", St, [
|
|
373
|
+
$e(a.$slots, "default", {
|
|
374
|
+
item: a.item,
|
|
375
|
+
remove: a.remove,
|
|
376
|
+
imageLoaded: l.value,
|
|
377
|
+
imageError: s.value
|
|
378
|
+
}, () => [
|
|
379
|
+
O("div", kt, [
|
|
380
|
+
!l.value && !s.value ? (V(), q("div", Et, n[1] || (n[1] = [
|
|
381
|
+
O("div", { class: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" }, null, -1)
|
|
382
|
+
]))) : oe("", !0),
|
|
383
|
+
s.value ? (V(), q("div", Lt, n[2] || (n[2] = [
|
|
384
|
+
O("i", { class: "fas fa-image text-2xl mb-2 opacity-50" }, null, -1),
|
|
385
|
+
O("span", null, "Failed to load image", -1)
|
|
386
|
+
]))) : oe("", !0),
|
|
387
|
+
l.value && h.value ? (V(), q("img", {
|
|
388
|
+
key: 2,
|
|
389
|
+
src: h.value,
|
|
390
|
+
class: "w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",
|
|
391
|
+
loading: "lazy",
|
|
392
|
+
decoding: "async"
|
|
393
|
+
}, null, 8, Ht)) : oe("", !0),
|
|
394
|
+
n[4] || (n[4] = O("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" }, null, -1)),
|
|
395
|
+
a.remove ? (V(), q("button", {
|
|
396
|
+
key: 3,
|
|
397
|
+
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",
|
|
398
|
+
onClick: n[0] || (n[0] = ze((d) => a.remove(a.item), ["stop"])),
|
|
399
|
+
"aria-label": "Remove item"
|
|
400
|
+
}, n[3] || (n[3] = [
|
|
401
|
+
O("i", { class: "fas fa-times text-sm" }, null, -1)
|
|
402
|
+
]))) : oe("", !0),
|
|
403
|
+
O("div", Nt, [
|
|
404
|
+
O("p", $t, "Item #" + de(String(a.item.id).split("-")[0]), 1)
|
|
405
|
+
])
|
|
406
|
+
])
|
|
407
|
+
])
|
|
408
|
+
]));
|
|
409
|
+
}
|
|
410
|
+
}), At = /* @__PURE__ */ Le({
|
|
317
411
|
__name: "Masonry",
|
|
318
412
|
props: {
|
|
319
413
|
getNextPage: {
|
|
@@ -413,8 +507,8 @@ const Mt = ["src"], Pt = ["onClick"], It = /* @__PURE__ */ $e({
|
|
|
413
507
|
"retry:stop",
|
|
414
508
|
"remove-all:complete"
|
|
415
509
|
],
|
|
416
|
-
setup(e, { expose: o, emit:
|
|
417
|
-
const s = e,
|
|
510
|
+
setup(e, { expose: o, emit: l }) {
|
|
511
|
+
const s = e, h = {
|
|
418
512
|
sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
|
|
419
513
|
gutterX: 10,
|
|
420
514
|
gutterY: 10,
|
|
@@ -423,41 +517,41 @@ const Mt = ["src"], Pt = ["onClick"], It = /* @__PURE__ */ $e({
|
|
|
423
517
|
paddingLeft: 0,
|
|
424
518
|
paddingRight: 0,
|
|
425
519
|
placement: "masonry"
|
|
426
|
-
},
|
|
520
|
+
}, v = se(() => {
|
|
427
521
|
var t;
|
|
428
522
|
return {
|
|
429
|
-
...
|
|
523
|
+
...h,
|
|
430
524
|
...s.layout,
|
|
431
525
|
sizes: {
|
|
432
|
-
...
|
|
526
|
+
...h.sizes,
|
|
433
527
|
...((t = s.layout) == null ? void 0 : t.sizes) || {}
|
|
434
528
|
}
|
|
435
529
|
};
|
|
436
|
-
}),
|
|
530
|
+
}), a = l, n = se({
|
|
437
531
|
get: () => s.items,
|
|
438
|
-
set: (t) =>
|
|
439
|
-
}),
|
|
440
|
-
function
|
|
532
|
+
set: (t) => a("update:items", t)
|
|
533
|
+
}), d = L(7), u = L(null), c = L([]), b = L(null), m = L(!1), x = L(0), F = L(/* @__PURE__ */ new Set());
|
|
534
|
+
function _(t) {
|
|
441
535
|
return typeof t == "number" && Number.isFinite(t) && t > 0;
|
|
442
536
|
}
|
|
443
|
-
function
|
|
537
|
+
function H(t, r) {
|
|
444
538
|
try {
|
|
445
539
|
if (!Array.isArray(t) || t.length === 0) return;
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
540
|
+
const i = t.filter((g) => !_(g == null ? void 0 : g.width) || !_(g == null ? void 0 : g.height));
|
|
541
|
+
if (i.length === 0) return;
|
|
448
542
|
const f = [];
|
|
449
|
-
for (const
|
|
450
|
-
const A = (
|
|
451
|
-
|
|
543
|
+
for (const g of i) {
|
|
544
|
+
const A = (g == null ? void 0 : g.id) ?? `idx:${t.indexOf(g)}`;
|
|
545
|
+
F.value.has(A) || (F.value.add(A), f.push(A));
|
|
452
546
|
}
|
|
453
547
|
if (f.length > 0) {
|
|
454
|
-
const
|
|
548
|
+
const g = f.slice(0, 10);
|
|
455
549
|
console.warn(
|
|
456
550
|
"[Masonry] Items missing width/height detected:",
|
|
457
551
|
{
|
|
458
|
-
context:
|
|
552
|
+
context: r,
|
|
459
553
|
count: f.length,
|
|
460
|
-
sampleIds:
|
|
554
|
+
sampleIds: g,
|
|
461
555
|
hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
|
|
462
556
|
}
|
|
463
557
|
);
|
|
@@ -465,363 +559,364 @@ const Mt = ["src"], Pt = ["onClick"], It = /* @__PURE__ */ $e({
|
|
|
465
559
|
} catch {
|
|
466
560
|
}
|
|
467
561
|
}
|
|
468
|
-
const
|
|
562
|
+
const M = L(0), P = L(0), U = s.virtualBufferPx, S = L(!1), T = L({
|
|
469
563
|
distanceToTrigger: 0,
|
|
470
564
|
isNearTrigger: !1
|
|
471
|
-
}),
|
|
565
|
+
}), y = (t) => {
|
|
472
566
|
if (!u.value) return;
|
|
473
|
-
const { scrollTop:
|
|
474
|
-
|
|
475
|
-
distanceToTrigger: Math.round(
|
|
476
|
-
isNearTrigger:
|
|
567
|
+
const { scrollTop: r, clientHeight: i } = u.value, f = r + i, g = t ?? me(n.value, d.value), A = g.length ? Math.max(...g) : 0, C = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, K = C >= 0 ? Math.max(0, A - C) : Math.max(0, A + C), xe = Math.max(0, K - f), je = xe <= 100;
|
|
568
|
+
T.value = {
|
|
569
|
+
distanceToTrigger: Math.round(xe),
|
|
570
|
+
isNearTrigger: je
|
|
477
571
|
};
|
|
478
|
-
}, { onEnter:
|
|
479
|
-
function
|
|
572
|
+
}, { onEnter: W, onBeforeEnter: w, onBeforeLeave: N, onLeave: I } = It(n, { leaveDurationMs: s.leaveDurationMs });
|
|
573
|
+
function D(t, r) {
|
|
480
574
|
if (S.value) {
|
|
481
|
-
const
|
|
482
|
-
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${
|
|
483
|
-
t.style.transition = "",
|
|
575
|
+
const i = parseInt(t.dataset.left || "0", 10), f = parseInt(t.dataset.top || "0", 10);
|
|
576
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${i}px, ${f}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
|
|
577
|
+
t.style.transition = "", r();
|
|
484
578
|
});
|
|
485
579
|
} else
|
|
486
|
-
|
|
580
|
+
W(t, r);
|
|
487
581
|
}
|
|
488
|
-
function
|
|
582
|
+
function Z(t) {
|
|
489
583
|
if (S.value) {
|
|
490
|
-
const
|
|
491
|
-
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${
|
|
584
|
+
const r = parseInt(t.dataset.left || "0", 10), i = parseInt(t.dataset.top || "0", 10);
|
|
585
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${r}px, ${i}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
|
|
492
586
|
} else
|
|
493
587
|
w(t);
|
|
494
588
|
}
|
|
495
|
-
function
|
|
496
|
-
S.value ||
|
|
589
|
+
function ee(t) {
|
|
590
|
+
S.value || N(t);
|
|
497
591
|
}
|
|
498
|
-
function
|
|
499
|
-
S.value ?
|
|
592
|
+
function X(t, r) {
|
|
593
|
+
S.value ? r() : I(t, r);
|
|
500
594
|
}
|
|
501
|
-
const
|
|
502
|
-
const t =
|
|
503
|
-
return !
|
|
504
|
-
const
|
|
505
|
-
return f.top + f.columnHeight >= t &&
|
|
595
|
+
const te = se(() => {
|
|
596
|
+
const t = M.value - U, r = M.value + P.value + U, i = n.value;
|
|
597
|
+
return !i || i.length === 0 ? [] : i.filter((f) => {
|
|
598
|
+
const g = f.top;
|
|
599
|
+
return f.top + f.columnHeight >= t && g <= r;
|
|
506
600
|
});
|
|
507
|
-
}), { handleScroll:
|
|
601
|
+
}), { handleScroll: Y } = Pt({
|
|
508
602
|
container: u,
|
|
509
|
-
masonry:
|
|
510
|
-
columns:
|
|
511
|
-
containerHeight:
|
|
512
|
-
isLoading:
|
|
603
|
+
masonry: n,
|
|
604
|
+
columns: d,
|
|
605
|
+
containerHeight: x,
|
|
606
|
+
isLoading: m,
|
|
513
607
|
pageSize: s.pageSize,
|
|
514
|
-
refreshLayout:
|
|
608
|
+
refreshLayout: j,
|
|
515
609
|
setItemsRaw: (t) => {
|
|
516
|
-
|
|
610
|
+
n.value = t;
|
|
517
611
|
},
|
|
518
|
-
loadNext:
|
|
612
|
+
loadNext: z,
|
|
519
613
|
loadThresholdPx: s.loadThresholdPx
|
|
520
614
|
});
|
|
521
615
|
o({
|
|
522
|
-
isLoading:
|
|
523
|
-
refreshLayout:
|
|
524
|
-
containerHeight:
|
|
525
|
-
remove:
|
|
526
|
-
removeMany:
|
|
527
|
-
removeAll:
|
|
528
|
-
loadNext:
|
|
529
|
-
loadPage:
|
|
530
|
-
refreshCurrentPage:
|
|
531
|
-
reset:
|
|
532
|
-
init:
|
|
616
|
+
isLoading: m,
|
|
617
|
+
refreshLayout: j,
|
|
618
|
+
containerHeight: x,
|
|
619
|
+
remove: G,
|
|
620
|
+
removeMany: R,
|
|
621
|
+
removeAll: Be,
|
|
622
|
+
loadNext: z,
|
|
623
|
+
loadPage: B,
|
|
624
|
+
refreshCurrentPage: $,
|
|
625
|
+
reset: Oe,
|
|
626
|
+
init: De,
|
|
533
627
|
paginationHistory: c,
|
|
534
|
-
cancelLoad:
|
|
535
|
-
scrollToTop:
|
|
536
|
-
totalItems:
|
|
628
|
+
cancelLoad: he,
|
|
629
|
+
scrollToTop: pe,
|
|
630
|
+
totalItems: se(() => n.value.length)
|
|
537
631
|
});
|
|
538
|
-
function
|
|
539
|
-
const
|
|
540
|
-
let
|
|
632
|
+
function J(t) {
|
|
633
|
+
const r = wt(t);
|
|
634
|
+
let i = 0;
|
|
541
635
|
if (u.value) {
|
|
542
|
-
const { scrollTop: f, clientHeight:
|
|
543
|
-
|
|
636
|
+
const { scrollTop: f, clientHeight: g } = u.value;
|
|
637
|
+
i = f + g + 100;
|
|
544
638
|
}
|
|
545
|
-
|
|
639
|
+
x.value = Math.max(r, i);
|
|
546
640
|
}
|
|
547
|
-
function
|
|
641
|
+
function j(t) {
|
|
548
642
|
if (!u.value) return;
|
|
549
|
-
|
|
550
|
-
const
|
|
643
|
+
H(t, "refreshLayout");
|
|
644
|
+
const r = t.map((f, g) => ({
|
|
551
645
|
...f,
|
|
552
|
-
originalIndex: f.originalIndex ??
|
|
553
|
-
})),
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
function
|
|
557
|
-
return new Promise((
|
|
558
|
-
const f = Math.max(0, t | 0),
|
|
559
|
-
|
|
646
|
+
originalIndex: f.originalIndex ?? g
|
|
647
|
+
})), i = Ye(r, u.value, d.value, v.value);
|
|
648
|
+
J(i), n.value = i;
|
|
649
|
+
}
|
|
650
|
+
function ae(t, r) {
|
|
651
|
+
return new Promise((i) => {
|
|
652
|
+
const f = Math.max(0, t | 0), g = Date.now();
|
|
653
|
+
r(f, f);
|
|
560
654
|
const A = setInterval(() => {
|
|
561
|
-
if (
|
|
562
|
-
clearInterval(A),
|
|
655
|
+
if (E.value) {
|
|
656
|
+
clearInterval(A), i();
|
|
563
657
|
return;
|
|
564
658
|
}
|
|
565
|
-
const
|
|
566
|
-
|
|
659
|
+
const C = Date.now() - g, K = Math.max(0, f - C);
|
|
660
|
+
r(K, f), K <= 0 && (clearInterval(A), i());
|
|
567
661
|
}, 100);
|
|
568
662
|
});
|
|
569
663
|
}
|
|
570
|
-
async function
|
|
664
|
+
async function p(t) {
|
|
571
665
|
try {
|
|
572
|
-
const
|
|
573
|
-
return
|
|
574
|
-
} catch (
|
|
575
|
-
throw console.error("Error in getContent:",
|
|
666
|
+
const r = await k(() => s.getNextPage(t));
|
|
667
|
+
return j([...n.value, ...r.items]), r;
|
|
668
|
+
} catch (r) {
|
|
669
|
+
throw console.error("Error in getContent:", r), r;
|
|
576
670
|
}
|
|
577
671
|
}
|
|
578
|
-
async function
|
|
579
|
-
let
|
|
580
|
-
const
|
|
672
|
+
async function k(t) {
|
|
673
|
+
let r = 0;
|
|
674
|
+
const i = s.retryMaxAttempts;
|
|
581
675
|
let f = s.retryInitialDelayMs;
|
|
582
676
|
for (; ; )
|
|
583
677
|
try {
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
} catch (
|
|
587
|
-
if (
|
|
588
|
-
throw
|
|
589
|
-
|
|
590
|
-
|
|
678
|
+
const g = await t();
|
|
679
|
+
return r > 0 && a("retry:stop", { attempt: r, success: !0 }), g;
|
|
680
|
+
} catch (g) {
|
|
681
|
+
if (r++, r > i)
|
|
682
|
+
throw a("retry:stop", { attempt: r - 1, success: !1 }), g;
|
|
683
|
+
a("retry:start", { attempt: r, max: i, totalMs: f }), await ae(f, (A, C) => {
|
|
684
|
+
a("retry:tick", { attempt: r, remainingMs: A, totalMs: C });
|
|
591
685
|
}), f += s.retryBackoffStepMs;
|
|
592
686
|
}
|
|
593
687
|
}
|
|
594
|
-
async function
|
|
595
|
-
if (!
|
|
596
|
-
|
|
688
|
+
async function B(t) {
|
|
689
|
+
if (!m.value) {
|
|
690
|
+
E.value = !1, m.value = !0;
|
|
597
691
|
try {
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
const
|
|
601
|
-
return
|
|
602
|
-
} catch (
|
|
603
|
-
throw console.error("Error loading page:",
|
|
692
|
+
const r = n.value.length;
|
|
693
|
+
if (E.value) return;
|
|
694
|
+
const i = await p(t);
|
|
695
|
+
return E.value ? void 0 : (b.value = t, c.value.push(i.nextPage), await ne(r), i);
|
|
696
|
+
} catch (r) {
|
|
697
|
+
throw console.error("Error loading page:", r), r;
|
|
604
698
|
} finally {
|
|
605
|
-
|
|
699
|
+
m.value = !1;
|
|
606
700
|
}
|
|
607
701
|
}
|
|
608
702
|
}
|
|
609
|
-
async function
|
|
610
|
-
if (!
|
|
611
|
-
|
|
703
|
+
async function z() {
|
|
704
|
+
if (!m.value) {
|
|
705
|
+
E.value = !1, m.value = !0;
|
|
612
706
|
try {
|
|
613
|
-
const t =
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
-
return
|
|
707
|
+
const t = n.value.length;
|
|
708
|
+
if (E.value) return;
|
|
709
|
+
const r = c.value[c.value.length - 1], i = await p(r);
|
|
710
|
+
return E.value ? void 0 : (b.value = r, c.value.push(i.nextPage), await ne(t), i);
|
|
617
711
|
} catch (t) {
|
|
618
712
|
throw console.error("Error loading next page:", t), t;
|
|
619
713
|
} finally {
|
|
620
|
-
|
|
714
|
+
m.value = !1;
|
|
621
715
|
}
|
|
622
716
|
}
|
|
623
717
|
}
|
|
624
|
-
async function
|
|
625
|
-
if (console.log("[Masonry] refreshCurrentPage called, isLoading:",
|
|
626
|
-
|
|
718
|
+
async function $() {
|
|
719
|
+
if (console.log("[Masonry] refreshCurrentPage called, isLoading:", m.value, "currentPage:", b.value), !m.value) {
|
|
720
|
+
E.value = !1, m.value = !0;
|
|
627
721
|
try {
|
|
628
|
-
const t =
|
|
722
|
+
const t = b.value;
|
|
629
723
|
if (console.log("[Masonry] pageToRefresh:", t), t == null) {
|
|
630
|
-
console.warn("[Masonry] No current page to refresh - currentPage:",
|
|
724
|
+
console.warn("[Masonry] No current page to refresh - currentPage:", b.value, "paginationHistory:", c.value);
|
|
631
725
|
return;
|
|
632
726
|
}
|
|
633
|
-
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
|
|
637
|
-
const
|
|
638
|
-
return await
|
|
727
|
+
n.value = [], x.value = 0, c.value = [t], await Q();
|
|
728
|
+
const r = await p(t);
|
|
729
|
+
if (E.value) return;
|
|
730
|
+
b.value = t, c.value.push(r.nextPage);
|
|
731
|
+
const i = n.value.length;
|
|
732
|
+
return await ne(i), r;
|
|
639
733
|
} catch (t) {
|
|
640
734
|
throw console.error("[Masonry] Error refreshing current page:", t), t;
|
|
641
735
|
} finally {
|
|
642
|
-
|
|
736
|
+
m.value = !1;
|
|
643
737
|
}
|
|
644
738
|
}
|
|
645
739
|
}
|
|
646
|
-
async function
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
740
|
+
async function G(t) {
|
|
741
|
+
const r = n.value.filter((i) => i.id !== t.id);
|
|
742
|
+
if (n.value = r, await Q(), console.log("[Masonry] remove - next.length:", r.length, "paginationHistory.length:", c.value.length), r.length === 0 && c.value.length > 0) {
|
|
649
743
|
if (s.autoRefreshOnEmpty)
|
|
650
|
-
console.log("[Masonry] All items removed, calling refreshCurrentPage"), await
|
|
744
|
+
console.log("[Masonry] All items removed, calling refreshCurrentPage"), await $();
|
|
651
745
|
else {
|
|
652
746
|
console.log("[Masonry] All items removed, calling loadNext and forcing backfill");
|
|
653
747
|
try {
|
|
654
|
-
await
|
|
748
|
+
await z(), await ne(0, !0);
|
|
655
749
|
} catch {
|
|
656
750
|
}
|
|
657
751
|
}
|
|
658
752
|
return;
|
|
659
753
|
}
|
|
660
|
-
await new Promise((
|
|
661
|
-
|
|
754
|
+
await new Promise((i) => requestAnimationFrame(() => i())), requestAnimationFrame(() => {
|
|
755
|
+
j(r);
|
|
662
756
|
});
|
|
663
757
|
}
|
|
664
|
-
async function
|
|
758
|
+
async function R(t) {
|
|
665
759
|
if (!t || t.length === 0) return;
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
760
|
+
const r = new Set(t.map((f) => f.id)), i = n.value.filter((f) => !r.has(f.id));
|
|
761
|
+
if (n.value = i, await Q(), i.length === 0 && c.value.length > 0) {
|
|
668
762
|
if (s.autoRefreshOnEmpty)
|
|
669
|
-
await
|
|
763
|
+
await $();
|
|
670
764
|
else
|
|
671
765
|
try {
|
|
672
|
-
await
|
|
766
|
+
await z(), await ne(0, !0);
|
|
673
767
|
} catch {
|
|
674
768
|
}
|
|
675
769
|
return;
|
|
676
770
|
}
|
|
677
771
|
await new Promise((f) => requestAnimationFrame(() => f())), requestAnimationFrame(() => {
|
|
678
|
-
|
|
772
|
+
j(i);
|
|
679
773
|
});
|
|
680
774
|
}
|
|
681
|
-
function
|
|
775
|
+
function pe(t) {
|
|
682
776
|
u.value && u.value.scrollTo({
|
|
683
777
|
top: 0,
|
|
684
778
|
behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
|
|
685
779
|
...t
|
|
686
780
|
});
|
|
687
781
|
}
|
|
688
|
-
async function
|
|
689
|
-
|
|
782
|
+
async function Be() {
|
|
783
|
+
pe({ behavior: "smooth" }), n.value = [], x.value = 0, await Q(), a("remove-all:complete");
|
|
690
784
|
}
|
|
691
|
-
function
|
|
692
|
-
|
|
785
|
+
function Fe() {
|
|
786
|
+
d.value = fe(v.value), j(n.value), u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight);
|
|
693
787
|
}
|
|
694
|
-
let
|
|
695
|
-
const
|
|
696
|
-
async function
|
|
697
|
-
if (!
|
|
698
|
-
const
|
|
699
|
-
if (!(!s.pageSize || s.pageSize <= 0 || c.value[c.value.length - 1] == null) && !(
|
|
700
|
-
|
|
788
|
+
let le = !1;
|
|
789
|
+
const E = L(!1);
|
|
790
|
+
async function ne(t, r = !1) {
|
|
791
|
+
if (!r && !s.backfillEnabled || le || E.value) return;
|
|
792
|
+
const i = (t || 0) + (s.pageSize || 0);
|
|
793
|
+
if (!(!s.pageSize || s.pageSize <= 0 || c.value[c.value.length - 1] == null) && !(n.value.length >= i)) {
|
|
794
|
+
le = !0;
|
|
701
795
|
try {
|
|
702
|
-
let
|
|
703
|
-
for (
|
|
704
|
-
|
|
705
|
-
fetched:
|
|
706
|
-
target:
|
|
707
|
-
calls:
|
|
708
|
-
remainingMs:
|
|
709
|
-
totalMs:
|
|
796
|
+
let g = 0;
|
|
797
|
+
for (a("backfill:start", { target: i, fetched: n.value.length, calls: g }); n.value.length < i && g < s.backfillMaxCalls && c.value[c.value.length - 1] != null && !E.value && (await ae(s.backfillDelayMs, (C, K) => {
|
|
798
|
+
a("backfill:tick", {
|
|
799
|
+
fetched: n.value.length,
|
|
800
|
+
target: i,
|
|
801
|
+
calls: g,
|
|
802
|
+
remainingMs: C,
|
|
803
|
+
totalMs: K
|
|
710
804
|
});
|
|
711
|
-
}), !
|
|
805
|
+
}), !E.value); ) {
|
|
712
806
|
const A = c.value[c.value.length - 1];
|
|
713
807
|
try {
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
c.value.push(
|
|
808
|
+
m.value = !0;
|
|
809
|
+
const C = await p(A);
|
|
810
|
+
if (E.value) break;
|
|
811
|
+
c.value.push(C.nextPage);
|
|
718
812
|
} finally {
|
|
719
|
-
|
|
813
|
+
m.value = !1;
|
|
720
814
|
}
|
|
721
|
-
|
|
815
|
+
g++;
|
|
722
816
|
}
|
|
723
|
-
|
|
817
|
+
a("backfill:stop", { fetched: n.value.length, calls: g });
|
|
724
818
|
} finally {
|
|
725
|
-
|
|
819
|
+
le = !1;
|
|
726
820
|
}
|
|
727
821
|
}
|
|
728
822
|
}
|
|
729
|
-
function
|
|
730
|
-
|
|
823
|
+
function he() {
|
|
824
|
+
E.value = !0, m.value = !1, le = !1;
|
|
731
825
|
}
|
|
732
|
-
function
|
|
733
|
-
|
|
826
|
+
function Oe() {
|
|
827
|
+
he(), E.value = !1, u.value && u.value.scrollTo({
|
|
734
828
|
top: 0,
|
|
735
829
|
behavior: "smooth"
|
|
736
|
-
}),
|
|
830
|
+
}), n.value = [], x.value = 0, b.value = s.loadAtPage, c.value = [s.loadAtPage], T.value = {
|
|
737
831
|
distanceToTrigger: 0,
|
|
738
832
|
isNearTrigger: !1
|
|
739
833
|
};
|
|
740
834
|
}
|
|
741
|
-
const
|
|
742
|
-
u.value && (
|
|
743
|
-
const t =
|
|
744
|
-
|
|
745
|
-
}, 200),
|
|
746
|
-
function
|
|
747
|
-
|
|
835
|
+
const ye = ke(async () => {
|
|
836
|
+
u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight), S.value = !0, await Q(), await new Promise((r) => requestAnimationFrame(() => r())), S.value = !1;
|
|
837
|
+
const t = me(n.value, d.value);
|
|
838
|
+
Y(t), y(t);
|
|
839
|
+
}, 200), be = ke(Fe, 200);
|
|
840
|
+
function De(t, r, i) {
|
|
841
|
+
b.value = r, c.value = [r], c.value.push(i), H(t, "init"), j([...n.value, ...t]), y();
|
|
748
842
|
}
|
|
749
|
-
return
|
|
843
|
+
return Ne(
|
|
844
|
+
v,
|
|
845
|
+
() => {
|
|
846
|
+
u.value && (d.value = fe(v.value), j(n.value));
|
|
847
|
+
},
|
|
848
|
+
{ deep: !0 }
|
|
849
|
+
), He(async () => {
|
|
750
850
|
var t;
|
|
751
851
|
try {
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
c.value = [
|
|
755
|
-
} catch (
|
|
756
|
-
console.error("Error during component initialization:",
|
|
852
|
+
d.value = fe(v.value), u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight);
|
|
853
|
+
const r = s.loadAtPage;
|
|
854
|
+
c.value = [r], s.skipInitialLoad || await B(c.value[0]), y();
|
|
855
|
+
} catch (r) {
|
|
856
|
+
console.error("Error during component initialization:", r), m.value = !1;
|
|
757
857
|
}
|
|
758
|
-
(t = u.value) == null || t.addEventListener("scroll",
|
|
759
|
-
}),
|
|
858
|
+
(t = u.value) == null || t.addEventListener("scroll", ye, { passive: !0 }), window.addEventListener("resize", be);
|
|
859
|
+
}), Re(() => {
|
|
760
860
|
var t;
|
|
761
|
-
(t = u.value) == null || t.removeEventListener("scroll",
|
|
762
|
-
}), (t,
|
|
763
|
-
class:
|
|
861
|
+
(t = u.value) == null || t.removeEventListener("scroll", ye), window.removeEventListener("resize", be);
|
|
862
|
+
}), (t, r) => (V(), q("div", {
|
|
863
|
+
class: we(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
|
|
764
864
|
ref_key: "container",
|
|
765
865
|
ref: u
|
|
766
866
|
}, [
|
|
767
|
-
|
|
867
|
+
O("div", {
|
|
768
868
|
class: "relative",
|
|
769
|
-
style:
|
|
869
|
+
style: Ce({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
|
|
770
870
|
}, [
|
|
771
|
-
|
|
871
|
+
Me(_e, {
|
|
772
872
|
name: "masonry",
|
|
773
873
|
css: !1,
|
|
774
|
-
onEnter:
|
|
775
|
-
onBeforeEnter:
|
|
776
|
-
onLeave:
|
|
777
|
-
onBeforeLeave:
|
|
874
|
+
onEnter: D,
|
|
875
|
+
onBeforeEnter: Z,
|
|
876
|
+
onLeave: X,
|
|
877
|
+
onBeforeLeave: ee
|
|
778
878
|
}, {
|
|
779
|
-
default:
|
|
780
|
-
(
|
|
781
|
-
key: `${
|
|
879
|
+
default: qe(() => [
|
|
880
|
+
(V(!0), q(Ve, null, Ge(te.value, (i, f) => (V(), q("div", Te({
|
|
881
|
+
key: `${i.page}-${i.id}`,
|
|
782
882
|
class: "absolute masonry-item",
|
|
783
883
|
ref_for: !0
|
|
784
|
-
},
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}, null, 8,
|
|
792
|
-
V("button", {
|
|
793
|
-
class: "absolute bottom-0 right-0 bg-red-500 text-white p-2 rounded cursor-pointer",
|
|
794
|
-
onClick: (d) => _(l)
|
|
795
|
-
}, a[0] || (a[0] = [
|
|
796
|
-
V("i", { class: "fas fa-trash" }, null, -1)
|
|
797
|
-
]), 8, Pt)
|
|
884
|
+
}, Ue(Tt)(i, f), {
|
|
885
|
+
style: { paddingTop: `${v.value.header}px`, paddingBottom: `${v.value.footer}px` }
|
|
886
|
+
}), [
|
|
887
|
+
$e(t.$slots, "item", Te({ ref_for: !0 }, { item: i, remove: G }), () => [
|
|
888
|
+
Me(ve, {
|
|
889
|
+
item: i,
|
|
890
|
+
remove: G
|
|
891
|
+
}, null, 8, ["item"])
|
|
798
892
|
], !0)
|
|
799
893
|
], 16))), 128))
|
|
800
894
|
]),
|
|
801
895
|
_: 3
|
|
802
896
|
}),
|
|
803
|
-
|
|
897
|
+
x.value > 0 ? (V(), q("div", {
|
|
804
898
|
key: 0,
|
|
805
|
-
class:
|
|
899
|
+
class: we(["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": !T.value.isNearTrigger, "opacity-100": T.value.isNearTrigger }])
|
|
806
900
|
}, [
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
], 2)) :
|
|
901
|
+
O("span", null, de(n.value.length) + " items", 1),
|
|
902
|
+
r[0] || (r[0] = O("span", { class: "mx-2" }, "|", -1)),
|
|
903
|
+
O("span", null, de(T.value.distanceToTrigger) + "px to load", 1)
|
|
904
|
+
], 2)) : oe("", !0)
|
|
811
905
|
], 4)
|
|
812
906
|
], 2));
|
|
813
907
|
}
|
|
814
|
-
}),
|
|
815
|
-
const
|
|
816
|
-
for (const [s,
|
|
817
|
-
|
|
818
|
-
return
|
|
819
|
-
},
|
|
908
|
+
}), Wt = (e, o) => {
|
|
909
|
+
const l = e.__vccOpts || e;
|
|
910
|
+
for (const [s, h] of o)
|
|
911
|
+
l[s] = h;
|
|
912
|
+
return l;
|
|
913
|
+
}, Ee = /* @__PURE__ */ Wt(At, [["__scopeId", "data-v-08b0e6d9"]]), Ft = {
|
|
820
914
|
install(e) {
|
|
821
|
-
e.component("WyxosMasonry",
|
|
915
|
+
e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem", ve), e.component("WMasonryItem", ve);
|
|
822
916
|
}
|
|
823
917
|
};
|
|
824
918
|
export {
|
|
825
|
-
|
|
826
|
-
|
|
919
|
+
Ee as Masonry,
|
|
920
|
+
ve as MasonryItem,
|
|
921
|
+
Ft as default
|
|
827
922
|
};
|