@wyxos/vibe 1.6.3 → 1.6.4
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 +525 -431
- 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 Ee, ref as L, onMounted as Le, watch as He, createElementBlock as q, openBlock as V, renderSlot as Ne, createElementVNode as O, createCommentVNode as oe, withModifiers as je, toDisplayString as de, computed as ie, onUnmounted as ze, normalizeClass as xe, normalizeStyle as Re, createVNode as we, TransitionGroup as Ce, withCtx as _e, Fragment as qe, renderList as Ve, mergeProps as Te, unref as Ge } from "vue";
|
|
2
|
+
let ue = null;
|
|
3
|
+
function Ue() {
|
|
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 Xe(e, o, l, i = {}) {
|
|
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:
|
|
29
|
-
} =
|
|
30
|
-
let
|
|
28
|
+
placement: b = "masonry"
|
|
29
|
+
} = i;
|
|
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, T = H > 0 ? H + 2 : Ue() + 2, P = o.offsetWidth - T - F - _, U = h * (l - 1), S = Math.floor((P - U) / l), M = e.map((w) => {
|
|
39
|
+
const N = w.width, I = w.height;
|
|
40
|
+
return Math.round(S * I / N) + n + a;
|
|
41
41
|
});
|
|
42
|
-
if (
|
|
42
|
+
if (b === "sequential-balanced") {
|
|
43
43
|
const w = M.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(...M), D = M.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 = M[$], 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 = M[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 = M[$] - (n + a), R.columnHeight = M[$], 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 Ye = typeof global == "object" && global && global.Object === Object && global, Je = typeof self == "object" && self && self.Object === Object && self, $e = Ye || Je || Function("return this")(), se = $e.Symbol, Ae = Object.prototype, Ke = Ae.hasOwnProperty, Qe = Ae.toString, re = se ? se.toStringTag : void 0;
|
|
100
|
+
function Ze(e) {
|
|
101
|
+
var o = Ke.call(e, re), l = e[re];
|
|
102
102
|
try {
|
|
103
|
-
e[
|
|
104
|
-
var
|
|
103
|
+
e[re] = void 0;
|
|
104
|
+
var i = !0;
|
|
105
105
|
} catch {
|
|
106
106
|
}
|
|
107
|
-
var
|
|
108
|
-
return
|
|
107
|
+
var h = Qe.call(e);
|
|
108
|
+
return i && (o ? e[re] = l : delete e[re]), h;
|
|
109
109
|
}
|
|
110
|
-
var
|
|
111
|
-
function et(e) {
|
|
112
|
-
return Ze.call(e);
|
|
113
|
-
}
|
|
114
|
-
var tt = "[object Null]", nt = "[object Undefined]", xe = ie ? ie.toStringTag : void 0;
|
|
110
|
+
var et = Object.prototype, tt = et.toString;
|
|
115
111
|
function at(e) {
|
|
116
|
-
return
|
|
112
|
+
return tt.call(e);
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
var nt = "[object Null]", rt = "[object Undefined]", Me = se ? se.toStringTag : void 0;
|
|
115
|
+
function ot(e) {
|
|
116
|
+
return e == null ? e === void 0 ? rt : nt : Me && Me in Object(e) ? Ze(e) : at(e);
|
|
120
117
|
}
|
|
121
|
-
var ot = "[object Symbol]";
|
|
122
118
|
function lt(e) {
|
|
123
|
-
return
|
|
119
|
+
return e != null && typeof e == "object";
|
|
124
120
|
}
|
|
125
|
-
var it =
|
|
121
|
+
var it = "[object Symbol]";
|
|
126
122
|
function st(e) {
|
|
127
|
-
|
|
123
|
+
return typeof e == "symbol" || lt(e) && ot(e) == it;
|
|
124
|
+
}
|
|
125
|
+
var ut = /\s/;
|
|
126
|
+
function ct(e) {
|
|
127
|
+
for (var o = e.length; o-- && ut.test(e.charAt(o)); )
|
|
128
128
|
;
|
|
129
129
|
return o;
|
|
130
130
|
}
|
|
131
|
-
var
|
|
132
|
-
function
|
|
133
|
-
return e && e.slice(0,
|
|
131
|
+
var ft = /^\s+/;
|
|
132
|
+
function dt(e) {
|
|
133
|
+
return e && e.slice(0, ct(e) + 1).replace(ft, "");
|
|
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 Ie = NaN, gt = /^[-+]0x[0-9a-f]+$/i, mt = /^0b[01]+$/i, vt = /^0o[0-7]+$/i, pt = parseInt;
|
|
140
|
+
function Pe(e) {
|
|
141
141
|
if (typeof e == "number")
|
|
142
142
|
return e;
|
|
143
|
-
if (
|
|
144
|
-
return
|
|
145
|
-
if (
|
|
143
|
+
if (st(e))
|
|
144
|
+
return Ie;
|
|
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 = dt(e);
|
|
152
|
+
var l = mt.test(e);
|
|
153
|
+
return l || vt.test(e) ? pt(e.slice(2), l ? 2 : 8) : gt.test(e) ? Ie : +e;
|
|
154
154
|
}
|
|
155
|
-
var
|
|
156
|
-
return
|
|
157
|
-
},
|
|
158
|
-
function
|
|
159
|
-
var
|
|
155
|
+
var ce = function() {
|
|
156
|
+
return $e.Date.now();
|
|
157
|
+
}, ht = "Expected a function", yt = Math.max, bt = Math.min;
|
|
158
|
+
function Se(e, o, l) {
|
|
159
|
+
var i, 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
|
|
161
|
+
throw new TypeError(ht);
|
|
162
|
+
o = Pe(o) || 0, ge(l) && (c = !!l.leading, b = "maxWait" in l, v = b ? yt(Pe(l.maxWait) || 0, o) : v, m = "trailing" in l ? !!l.trailing : m);
|
|
163
|
+
function x(y) {
|
|
164
|
+
var W = i, w = h;
|
|
165
|
+
return i = 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(T, 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 ? bt(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
178
|
function T() {
|
|
179
|
-
var
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
182
|
-
|
|
179
|
+
var y = ce();
|
|
180
|
+
if (H(y))
|
|
181
|
+
return P(y);
|
|
182
|
+
n = setTimeout(T, _(y));
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
return
|
|
184
|
+
function P(y) {
|
|
185
|
+
return n = void 0, m && i ? x(y) : (i = h = void 0, a);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
187
|
+
function U() {
|
|
188
|
+
n !== void 0 && clearTimeout(n), u = 0, i = d = h = n = void 0;
|
|
189
189
|
}
|
|
190
190
|
function S() {
|
|
191
|
-
return
|
|
191
|
+
return n === void 0 ? a : P(ce());
|
|
192
192
|
}
|
|
193
193
|
function M() {
|
|
194
|
-
var
|
|
195
|
-
if (
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
198
|
-
if (
|
|
199
|
-
return clearTimeout(
|
|
200
|
-
}
|
|
201
|
-
return
|
|
194
|
+
var y = ce(), W = H(y);
|
|
195
|
+
if (i = arguments, h = this, d = y, W) {
|
|
196
|
+
if (n === void 0)
|
|
197
|
+
return F(d);
|
|
198
|
+
if (b)
|
|
199
|
+
return clearTimeout(n), n = setTimeout(T, o), x(d);
|
|
200
|
+
}
|
|
201
|
+
return n === void 0 && (n = setTimeout(T, o)), a;
|
|
202
202
|
}
|
|
203
|
-
return M.cancel =
|
|
203
|
+
return M.cancel = U, M.flush = S, M;
|
|
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 xt(e) {
|
|
210
|
+
return e.reduce((l, i) => Math.max(l, i.top + i.columnHeight), 0) + 500;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function wt(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: wt(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
|
|
234
|
-
for (let
|
|
235
|
-
const
|
|
236
|
-
for (const
|
|
237
|
-
const
|
|
238
|
-
|
|
233
|
+
const i = 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 < i.length; a++) h.set(i[a], a);
|
|
235
|
+
const v = new Array(i.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 Mt(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
|
|
255
|
-
const
|
|
256
|
-
|
|
254
|
+
function i(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 T = getComputedStyle(
|
|
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 T = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", P = parseFloat(T);
|
|
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:
|
|
284
|
-
onBeforeEnter:
|
|
285
|
-
onBeforeLeave:
|
|
286
|
-
onLeave:
|
|
283
|
+
onEnter: l,
|
|
284
|
+
onBeforeEnter: i,
|
|
285
|
+
onBeforeLeave: h,
|
|
286
|
+
onLeave: v
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function It({
|
|
290
290
|
container: e,
|
|
291
291
|
masonry: o,
|
|
292
|
-
columns:
|
|
293
|
-
containerHeight:
|
|
294
|
-
isLoading:
|
|
295
|
-
pageSize:
|
|
296
|
-
refreshLayout:
|
|
297
|
-
setItemsRaw:
|
|
298
|
-
loadNext:
|
|
292
|
+
columns: l,
|
|
293
|
+
containerHeight: i,
|
|
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 T = typeof u == "number" ? u : 200,
|
|
307
|
-
if (
|
|
308
|
-
await
|
|
306
|
+
const T = typeof u == "number" ? u : 200, P = T >= 0 ? Math.max(0, F - T) : Math.max(0, F + T);
|
|
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 Pt = { class: "relative w-full h-full group" }, St = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, kt = {
|
|
317
|
+
key: 0,
|
|
318
|
+
class: "absolute inset-0 flex items-center justify-center bg-slate-100"
|
|
319
|
+
}, Et = {
|
|
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
|
+
}, Lt = ["src"], Ht = { 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" }, Nt = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, $t = /* @__PURE__ */ Ee({
|
|
323
|
+
__name: "MasonryItem",
|
|
324
|
+
props: {
|
|
325
|
+
item: {},
|
|
326
|
+
remove: { type: Function }
|
|
327
|
+
},
|
|
328
|
+
setup(e) {
|
|
329
|
+
const o = e, l = L(!1), i = 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, i.value = !1, n();
|
|
341
|
+
}, x);
|
|
342
|
+
}, u.onerror = () => {
|
|
343
|
+
i.value = !0, l.value = !1, d(new Error("Failed to load image"));
|
|
344
|
+
}, u.src = a;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return Le(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, i.value = !1;
|
|
353
|
+
try {
|
|
354
|
+
await v(a);
|
|
355
|
+
} catch {
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}), He(
|
|
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, i.value = !1, h.value = a;
|
|
366
|
+
try {
|
|
367
|
+
await v(a);
|
|
368
|
+
} catch {
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
), (a, n) => (V(), q("div", Pt, [
|
|
373
|
+
Ne(a.$slots, "default", {
|
|
374
|
+
item: a.item,
|
|
375
|
+
remove: a.remove,
|
|
376
|
+
imageLoaded: l.value,
|
|
377
|
+
imageError: i.value
|
|
378
|
+
}, () => [
|
|
379
|
+
O("div", St, [
|
|
380
|
+
!l.value && !i.value ? (V(), q("div", kt, 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
|
+
i.value ? (V(), q("div", Et, 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, Lt)) : 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] = je((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", Ht, [
|
|
404
|
+
O("p", Nt, "Item #" + de(String(a.item.id).split("-")[0]), 1)
|
|
405
|
+
])
|
|
406
|
+
])
|
|
407
|
+
])
|
|
408
|
+
]));
|
|
409
|
+
}
|
|
410
|
+
}), At = /* @__PURE__ */ Ee({
|
|
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
|
|
510
|
+
setup(e, { expose: o, emit: l }) {
|
|
511
|
+
const i = 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 = ie(() => {
|
|
427
521
|
var t;
|
|
428
522
|
return {
|
|
429
|
-
...
|
|
430
|
-
...
|
|
523
|
+
...h,
|
|
524
|
+
...i.layout,
|
|
431
525
|
sizes: {
|
|
432
|
-
...
|
|
433
|
-
...((t =
|
|
526
|
+
...h.sizes,
|
|
527
|
+
...((t = i.layout) == null ? void 0 : t.sizes) || {}
|
|
434
528
|
}
|
|
435
529
|
};
|
|
436
|
-
}),
|
|
437
|
-
get: () =>
|
|
438
|
-
set: (t) =>
|
|
439
|
-
}),
|
|
440
|
-
function
|
|
530
|
+
}), a = l, n = ie({
|
|
531
|
+
get: () => i.items,
|
|
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 s = t.filter((g) => !_(g == null ? void 0 : g.width) || !_(g == null ? void 0 : g.height));
|
|
541
|
+
if (s.length === 0) return;
|
|
448
542
|
const f = [];
|
|
449
|
-
for (const
|
|
450
|
-
const A = (
|
|
451
|
-
|
|
543
|
+
for (const g of s) {
|
|
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,363 @@ const Mt = ["src"], Pt = ["onClick"], It = /* @__PURE__ */ $e({
|
|
|
465
559
|
} catch {
|
|
466
560
|
}
|
|
467
561
|
}
|
|
468
|
-
const T =
|
|
562
|
+
const T = L(0), P = L(0), U = i.virtualBufferPx, S = L(!1), M = L({
|
|
469
563
|
distanceToTrigger: 0,
|
|
470
564
|
isNearTrigger: !1
|
|
471
|
-
}),
|
|
565
|
+
}), y = (t) => {
|
|
472
566
|
if (!u.value) return;
|
|
473
|
-
const { scrollTop:
|
|
567
|
+
const { scrollTop: r, clientHeight: s } = u.value, f = r + s, g = t ?? me(n.value, d.value), A = g.length ? Math.max(...g) : 0, C = typeof i.loadThresholdPx == "number" ? i.loadThresholdPx : 200, K = C >= 0 ? Math.max(0, A - C) : Math.max(0, A + C), be = Math.max(0, K - f), De = be <= 100;
|
|
474
568
|
M.value = {
|
|
475
|
-
distanceToTrigger: Math.round(
|
|
476
|
-
isNearTrigger:
|
|
569
|
+
distanceToTrigger: Math.round(be),
|
|
570
|
+
isNearTrigger: De
|
|
477
571
|
};
|
|
478
|
-
}, { onEnter:
|
|
479
|
-
function
|
|
572
|
+
}, { onEnter: W, onBeforeEnter: w, onBeforeLeave: N, onLeave: I } = Mt(n, { leaveDurationMs: i.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 s = 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(${s}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), s = parseInt(t.dataset.top || "0", 10);
|
|
585
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${r}px, ${s}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 = T.value -
|
|
503
|
-
return !
|
|
504
|
-
const
|
|
505
|
-
return f.top + f.columnHeight >= t &&
|
|
595
|
+
const te = ie(() => {
|
|
596
|
+
const t = T.value - U, r = T.value + P.value + U, s = n.value;
|
|
597
|
+
return !s || s.length === 0 ? [] : s.filter((f) => {
|
|
598
|
+
const g = f.top;
|
|
599
|
+
return f.top + f.columnHeight >= t && g <= r;
|
|
506
600
|
});
|
|
507
|
-
}), { handleScroll:
|
|
601
|
+
}), { handleScroll: Y } = It({
|
|
508
602
|
container: u,
|
|
509
|
-
masonry:
|
|
510
|
-
columns:
|
|
511
|
-
containerHeight:
|
|
512
|
-
isLoading:
|
|
513
|
-
pageSize:
|
|
514
|
-
refreshLayout:
|
|
603
|
+
masonry: n,
|
|
604
|
+
columns: d,
|
|
605
|
+
containerHeight: x,
|
|
606
|
+
isLoading: m,
|
|
607
|
+
pageSize: i.pageSize,
|
|
608
|
+
refreshLayout: j,
|
|
515
609
|
setItemsRaw: (t) => {
|
|
516
|
-
|
|
610
|
+
n.value = t;
|
|
517
611
|
},
|
|
518
|
-
loadNext:
|
|
519
|
-
loadThresholdPx:
|
|
612
|
+
loadNext: z,
|
|
613
|
+
loadThresholdPx: i.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: We,
|
|
622
|
+
loadNext: z,
|
|
623
|
+
loadPage: B,
|
|
624
|
+
refreshCurrentPage: $,
|
|
625
|
+
reset: Fe,
|
|
626
|
+
init: Oe,
|
|
533
627
|
paginationHistory: c,
|
|
534
|
-
cancelLoad:
|
|
535
|
-
scrollToTop:
|
|
536
|
-
totalItems:
|
|
628
|
+
cancelLoad: pe,
|
|
629
|
+
scrollToTop: ve,
|
|
630
|
+
totalItems: ie(() => n.value.length)
|
|
537
631
|
});
|
|
538
|
-
function
|
|
539
|
-
const
|
|
540
|
-
let
|
|
632
|
+
function J(t) {
|
|
633
|
+
const r = xt(t);
|
|
634
|
+
let s = 0;
|
|
541
635
|
if (u.value) {
|
|
542
|
-
const { scrollTop: f, clientHeight:
|
|
543
|
-
|
|
636
|
+
const { scrollTop: f, clientHeight: g } = u.value;
|
|
637
|
+
s = f + g + 100;
|
|
544
638
|
}
|
|
545
|
-
|
|
639
|
+
x.value = Math.max(r, s);
|
|
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
|
+
})), s = Xe(r, u.value, d.value, v.value);
|
|
648
|
+
J(s), n.value = s;
|
|
649
|
+
}
|
|
650
|
+
function ae(t, r) {
|
|
651
|
+
return new Promise((s) => {
|
|
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), s();
|
|
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), s());
|
|
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(() => i.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
|
|
581
|
-
let f =
|
|
672
|
+
async function k(t) {
|
|
673
|
+
let r = 0;
|
|
674
|
+
const s = i.retryMaxAttempts;
|
|
675
|
+
let f = i.retryInitialDelayMs;
|
|
582
676
|
for (; ; )
|
|
583
677
|
try {
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
} catch (
|
|
587
|
-
if (
|
|
588
|
-
throw
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}), f +=
|
|
678
|
+
const g = await t();
|
|
679
|
+
return r > 0 && a("retry:stop", { attempt: r, success: !0 }), g;
|
|
680
|
+
} catch (g) {
|
|
681
|
+
if (r++, r > s)
|
|
682
|
+
throw a("retry:stop", { attempt: r - 1, success: !1 }), g;
|
|
683
|
+
a("retry:start", { attempt: r, max: s, totalMs: f }), await ae(f, (A, C) => {
|
|
684
|
+
a("retry:tick", { attempt: r, remainingMs: A, totalMs: C });
|
|
685
|
+
}), f += i.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 s = await p(t);
|
|
695
|
+
return E.value ? void 0 : (b.value = t, c.value.push(s.nextPage), await ne(r), s);
|
|
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], s = await p(r);
|
|
710
|
+
return E.value ? void 0 : (b.value = r, c.value.push(s.nextPage), await ne(t), s);
|
|
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 s = n.value.length;
|
|
732
|
+
return await ne(s), 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 (
|
|
649
|
-
if (
|
|
650
|
-
console.log("[Masonry] All items removed, calling refreshCurrentPage"), await
|
|
740
|
+
async function G(t) {
|
|
741
|
+
const r = n.value.filter((s) => s.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) {
|
|
743
|
+
if (i.autoRefreshOnEmpty)
|
|
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((s) => requestAnimationFrame(() => s())), 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 (
|
|
668
|
-
if (
|
|
669
|
-
await
|
|
760
|
+
const r = new Set(t.map((f) => f.id)), s = n.value.filter((f) => !r.has(f.id));
|
|
761
|
+
if (n.value = s, await Q(), s.length === 0 && c.value.length > 0) {
|
|
762
|
+
if (i.autoRefreshOnEmpty)
|
|
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(s);
|
|
679
773
|
});
|
|
680
774
|
}
|
|
681
|
-
function
|
|
775
|
+
function ve(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 We() {
|
|
783
|
+
ve({ behavior: "smooth" }), n.value = [], x.value = 0, await Q(), a("remove-all:complete");
|
|
690
784
|
}
|
|
691
|
-
function
|
|
692
|
-
|
|
785
|
+
function Be() {
|
|
786
|
+
d.value = fe(v.value), j(n.value), u.value && (T.value = u.value.scrollTop, P.value = u.value.clientHeight);
|
|
693
787
|
}
|
|
694
|
-
let
|
|
695
|
-
const
|
|
696
|
-
async function
|
|
697
|
-
if (!
|
|
698
|
-
const
|
|
699
|
-
if (!(!
|
|
700
|
-
|
|
788
|
+
let le = !1;
|
|
789
|
+
const E = L(!1);
|
|
790
|
+
async function ne(t, r = !1) {
|
|
791
|
+
if (!r && !i.backfillEnabled || le || E.value) return;
|
|
792
|
+
const s = (t || 0) + (i.pageSize || 0);
|
|
793
|
+
if (!(!i.pageSize || i.pageSize <= 0 || c.value[c.value.length - 1] == null) && !(n.value.length >= s)) {
|
|
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: s, fetched: n.value.length, calls: g }); n.value.length < s && g < i.backfillMaxCalls && c.value[c.value.length - 1] != null && !E.value && (await ae(i.backfillDelayMs, (C, K) => {
|
|
798
|
+
a("backfill:tick", {
|
|
799
|
+
fetched: n.value.length,
|
|
800
|
+
target: s,
|
|
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 pe() {
|
|
824
|
+
E.value = !0, m.value = !1, le = !1;
|
|
731
825
|
}
|
|
732
|
-
function
|
|
733
|
-
|
|
826
|
+
function Fe() {
|
|
827
|
+
pe(), 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 = i.loadAtPage, c.value = [i.loadAtPage], M.value = {
|
|
737
831
|
distanceToTrigger: 0,
|
|
738
832
|
isNearTrigger: !1
|
|
739
833
|
};
|
|
740
834
|
}
|
|
741
|
-
const he =
|
|
742
|
-
u.value && (T.value = u.value.scrollTop,
|
|
743
|
-
const t =
|
|
744
|
-
|
|
745
|
-
}, 200),
|
|
746
|
-
function
|
|
747
|
-
|
|
835
|
+
const he = Se(async () => {
|
|
836
|
+
u.value && (T.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), ye = Se(Be, 200);
|
|
840
|
+
function Oe(t, r, s) {
|
|
841
|
+
b.value = r, c.value = [r], c.value.push(s), H(t, "init"), j([...n.value, ...t]), y();
|
|
748
842
|
}
|
|
749
|
-
return
|
|
843
|
+
return He(
|
|
844
|
+
v,
|
|
845
|
+
() => {
|
|
846
|
+
u.value && (d.value = fe(v.value), j(n.value));
|
|
847
|
+
},
|
|
848
|
+
{ deep: !0 }
|
|
849
|
+
), Le(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 && (T.value = u.value.scrollTop, P.value = u.value.clientHeight);
|
|
853
|
+
const r = i.loadAtPage;
|
|
854
|
+
c.value = [r], i.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", he, { passive: !0 }), window.addEventListener("resize",
|
|
759
|
-
}),
|
|
858
|
+
(t = u.value) == null || t.addEventListener("scroll", he, { passive: !0 }), window.addEventListener("resize", ye);
|
|
859
|
+
}), ze(() => {
|
|
760
860
|
var t;
|
|
761
|
-
(t = u.value) == null || t.removeEventListener("scroll", he), window.removeEventListener("resize",
|
|
762
|
-
}), (t,
|
|
763
|
-
class:
|
|
861
|
+
(t = u.value) == null || t.removeEventListener("scroll", he), window.removeEventListener("resize", ye);
|
|
862
|
+
}), (t, r) => (V(), q("div", {
|
|
863
|
+
class: xe(["overflow-auto w-full flex-1 masonry-container", { "force-motion": i.forceMotion }]),
|
|
764
864
|
ref_key: "container",
|
|
765
865
|
ref: u
|
|
766
866
|
}, [
|
|
767
|
-
|
|
867
|
+
O("div", {
|
|
768
868
|
class: "relative",
|
|
769
|
-
style:
|
|
869
|
+
style: Re({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
|
|
770
870
|
}, [
|
|
771
|
-
|
|
871
|
+
we(Ce, {
|
|
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: _e(() => [
|
|
880
|
+
(V(!0), q(qe, null, Ve(te.value, (s, f) => (V(), q("div", Te({
|
|
881
|
+
key: `${s.page}-${s.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
|
+
}, Ge(Tt)(s, f), {
|
|
885
|
+
style: { paddingTop: `${v.value.header}px`, paddingBottom: `${v.value.footer}px` }
|
|
886
|
+
}), [
|
|
887
|
+
Ne(t.$slots, "item", Te({ ref_for: !0 }, { item: s, remove: G }), () => [
|
|
888
|
+
we($t, {
|
|
889
|
+
item: s,
|
|
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: xe(["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": !M.value.isNearTrigger, "opacity-100": M.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(M.value.distanceToTrigger) + "px to load", 1)
|
|
904
|
+
], 2)) : oe("", !0)
|
|
811
905
|
], 4)
|
|
812
906
|
], 2));
|
|
813
907
|
}
|
|
814
|
-
}),
|
|
815
|
-
const
|
|
816
|
-
for (const [
|
|
817
|
-
i
|
|
818
|
-
return
|
|
819
|
-
},
|
|
908
|
+
}), Wt = (e, o) => {
|
|
909
|
+
const l = e.__vccOpts || e;
|
|
910
|
+
for (const [i, h] of o)
|
|
911
|
+
l[i] = h;
|
|
912
|
+
return l;
|
|
913
|
+
}, ke = /* @__PURE__ */ Wt(At, [["__scopeId", "data-v-08b0e6d9"]]), Ft = {
|
|
820
914
|
install(e) {
|
|
821
|
-
e.component("WyxosMasonry",
|
|
915
|
+
e.component("WyxosMasonry", ke), e.component("WMasonry", ke);
|
|
822
916
|
}
|
|
823
917
|
};
|
|
824
918
|
export {
|
|
825
|
-
|
|
826
|
-
|
|
919
|
+
ke as Masonry,
|
|
920
|
+
Ft as default
|
|
827
921
|
};
|