vane-waterfall 2.0.1 → 2.0.2

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.
Files changed (65) hide show
  1. package/README.md +4 -4
  2. package/dist/chunks/WaterfallCore-EdAZuWAY.js +695 -0
  3. package/dist/chunks/{doc-kTbJE7rY.js → doc-BCmEnh39.js} +31 -29
  4. package/dist/chunks/doc-BQQoKNto.js +126 -0
  5. package/dist/chunks/{doc-j4W9SUrY.js → doc-BSnWbrkH.js} +39 -27
  6. package/dist/chunks/{doc-BCGQ8Cp5.js → doc-BXaJl1By.js} +54 -41
  7. package/dist/chunks/{doc-CraXjOaA.js → doc-BindRMfO.js} +30 -26
  8. package/dist/chunks/{doc-78xF08vt.js → doc-BmoijI6q.js} +35 -35
  9. package/dist/chunks/{doc-BtzhgTYj.js → doc-CN4edvn_.js} +27 -27
  10. package/dist/chunks/{doc-NhL4Ux8q.js → doc-CkU5GtLw.js} +65 -54
  11. package/dist/chunks/doc-DAieSXLy.js +86 -0
  12. package/dist/chunks/{doc-BP0DmB7-.js → doc-D_ozEn0Q.js} +27 -27
  13. package/dist/chunks/{doc-f4Uijujv.js → doc-KN6Bvmty.js} +54 -32
  14. package/dist/chunks/{doc-B6kLfMPv.js → doc-a0MK2S3n.js} +61 -40
  15. package/dist/chunks/{index-COaun3nf.js → index-B8o6R4RZ.js} +2 -2
  16. package/dist/chunks/{index-DXAtA2f6.js → index-BFyYpEY_.js} +2 -2
  17. package/dist/chunks/{index-wLI6UXkY.js → index-CF0tYRop.js} +1 -1
  18. package/dist/chunks/{index-gjoCq0yC.js → index-CJR0Buju.js} +4 -4
  19. package/dist/chunks/{index-DsRLmBW-.js → index-DHTB3QEP.js} +3 -3
  20. package/dist/chunks/withPlugins-DG3YpSgL.js +655 -0
  21. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +19 -0
  22. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -1
  23. package/dist/components/WaterfallPlugin/layout.d.ts +7 -0
  24. package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -1
  25. package/dist/components/WaterfallPlugin/plugins/types.d.ts +3 -0
  26. package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -1
  27. package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -1
  28. package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -1
  29. package/dist/custom-plugins/A11yPlugin/index.js +1 -1
  30. package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -1
  31. package/dist/custom-plugins/BookmarkPlugin/index.js +1 -1
  32. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +2 -0
  33. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -1
  34. package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +1 -1
  35. package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -1
  36. package/dist/custom-plugins/GapPlugin/index.js +1 -1
  37. package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -1
  38. package/dist/custom-plugins/GroupingPlugin/index.js +1 -1
  39. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +2 -0
  40. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -1
  41. package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +1 -1
  42. package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -1
  43. package/dist/custom-plugins/InfiniteScrollPlugin/index.js +1 -1
  44. package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -1
  45. package/dist/custom-plugins/PaginationPlugin/index.js +1 -1
  46. package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -1
  47. package/dist/custom-plugins/RecyclePlugin/index.js +1 -1
  48. package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -1
  49. package/dist/custom-plugins/StatePersistencePlugin/index.js +1 -1
  50. package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -1
  51. package/dist/custom-plugins/StickyHeaderPlugin/index.js +1 -1
  52. package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -1
  53. package/dist/custom-plugins/URLSyncPlugin/index.js +1 -1
  54. package/dist/custom-plugins/index.js +5 -5
  55. package/dist/entries/core.js +1 -1
  56. package/dist/entries/plugins.js +6 -6
  57. package/dist/index.js +2 -2
  58. package/dist/presets/dashboard/index.js +2 -2
  59. package/dist/presets/photo-feed/index.js +2 -2
  60. package/dist/presets/product-feed/index.js +1 -1
  61. package/package.json +31 -23
  62. package/dist/chunks/WaterfallCore-BSXw7bl_.js +0 -581
  63. package/dist/chunks/doc-B-7dugGv.js +0 -79
  64. package/dist/chunks/doc-DJjxOYzW.js +0 -111
  65. package/dist/chunks/withPlugins-DLoKg4AP.js +0 -559
@@ -0,0 +1,695 @@
1
+ import { jsxs as de, jsx as Lt } from "react/jsx-runtime";
2
+ import ye, { forwardRef as pe, useRef as l, useMemo as bt, useCallback as L, useState as Ht, useLayoutEffect as be, useEffect as Ct, useImperativeHandle as He } from "react";
3
+ function we(r = 0) {
4
+ return typeof r == "number" ? { top: r, right: r, bottom: r, left: r } : {
5
+ top: r.top ?? 0,
6
+ right: r.right ?? 0,
7
+ bottom: r.bottom ?? 0,
8
+ left: r.left ?? 0
9
+ };
10
+ }
11
+ function Re(r, a, u) {
12
+ return typeof r == "number" && Number.isFinite(r) && r > 0 ? r : a && a > 0 ? a : u && u > 0 ? u : 0;
13
+ }
14
+ function Me(r) {
15
+ const {
16
+ heights: a,
17
+ columnGap: u,
18
+ rowGap: o,
19
+ alignmentMode: b = "shortest",
20
+ estimateHeight: R,
21
+ minItemHeight: g,
22
+ hooks: M
23
+ } = r, f = we(r.padding), H = r.containerWidth, T = M?.calculateColumns?.(r.columns), c = Math.max(
24
+ 1,
25
+ Math.round(
26
+ typeof T == "number" && Number.isFinite(T) ? T : r.columns
27
+ )
28
+ ), $ = (H - f.left - f.right - u * (c - 1)) / c, F = M?.calculateColumnWidth?.(
29
+ $,
30
+ c,
31
+ H
32
+ ), z = typeof F == "number" && Number.isFinite(F) ? F : $, I = Array(c).fill(f.top), G = Array(c).fill(0), x = /* @__PURE__ */ new Map();
33
+ let nt = 0;
34
+ if (a.length === 0)
35
+ return {
36
+ columns: c,
37
+ columnWidth: z,
38
+ padding: f,
39
+ columnHeights: I,
40
+ totalHeight: f.top + f.bottom,
41
+ positions: x,
42
+ estimatedCount: 0
43
+ };
44
+ for (let V = 0; V < a.length; V++) {
45
+ const D = a[V], rt = Re(D, R, g);
46
+ if (rt === 0) continue;
47
+ typeof D == "number" && D > 0 || (nt += 1);
48
+ let S = 0;
49
+ if (b === "sequential")
50
+ S = V % c;
51
+ else if (b === "balanced") {
52
+ let W = G[0];
53
+ for (let v = 1; v < c; v++)
54
+ G[v] < W && (W = G[v], S = v);
55
+ } else {
56
+ let W = I[0];
57
+ for (let v = 1; v < I.length; v++)
58
+ I[v] < W && (W = I[v], S = v);
59
+ }
60
+ let A = {
61
+ x: f.left + S * (z + u),
62
+ y: I[S],
63
+ width: z,
64
+ height: rt,
65
+ column: S,
66
+ row: Math.floor(V / c)
67
+ };
68
+ const U = M?.calculateItemPosition?.(V, rt, A);
69
+ if (U) {
70
+ const W = { ...A, ...U };
71
+ U.column !== void 0 && U.x === void 0 && (W.x = f.left + Math.min(Math.max(0, W.column), c - 1) * (z + u)), A = W;
72
+ }
73
+ x.set(V, A);
74
+ const ot = Math.min(
75
+ Math.max(0, A.column),
76
+ I.length - 1
77
+ );
78
+ I[ot] = A.y + A.height + o, G[ot] += 1;
79
+ }
80
+ return {
81
+ columns: c,
82
+ columnWidth: z,
83
+ padding: f,
84
+ columnHeights: I,
85
+ totalHeight: Math.max(...I) + f.bottom,
86
+ positions: x,
87
+ estimatedCount: nt
88
+ };
89
+ }
90
+ function Ie(r, a, u = "start", o = 0) {
91
+ let b = r.y + o;
92
+ return u === "center" ? b -= a / 2 - r.height / 2 : u === "end" && (b -= a - r.height), Math.max(0, b);
93
+ }
94
+ const ve = 8;
95
+ function Te(r, a, u = 0.5) {
96
+ const o = [];
97
+ for (const g of r)
98
+ Number.isFinite(g) && g > 0 && o.push(g);
99
+ if (o.length < ve) return a;
100
+ o.sort((g, M) => g - M);
101
+ const b = Math.min(1, Math.max(0, u)), R = Math.min(o.length - 1, Math.round(b * (o.length - 1)));
102
+ return Math.max(1, Math.ceil(o[R]));
103
+ }
104
+ function Se(r, a, u, o, b = 1) {
105
+ if (a <= 0) return { start: 0, end: -1, hiddenCount: 0 };
106
+ if (r.size === 0) {
107
+ const c = Math.max(1, Math.ceil(o / 240) + 2);
108
+ return { start: 0, end: Math.min(a - 1, c - 1), hiddenCount: 0 };
109
+ }
110
+ const R = Math.max(0, o * b), g = u - R, M = u + Math.max(o, 1) + R;
111
+ let f = Number.POSITIVE_INFINITY, H = -1;
112
+ if (r.forEach((c, N) => {
113
+ const $ = c.y;
114
+ c.y + c.height > g && $ < M && (N < f && (f = N), N > H && (H = N));
115
+ }), H < 0) {
116
+ let c = 0, N = Number.POSITIVE_INFINITY;
117
+ r.forEach((F, z) => {
118
+ const I = Math.abs(F.y - u);
119
+ I < N && (N = I, c = z);
120
+ });
121
+ const $ = Math.max(1, Math.ceil(o / 240) + 2);
122
+ f = Math.max(0, c - $), H = Math.min(a - 1, c + $);
123
+ }
124
+ f = Math.max(0, f), H = Math.min(a - 1, H), H < f && (H = f);
125
+ const T = H - f + 1;
126
+ return { start: f, end: H, hiddenCount: Math.max(0, a - T) };
127
+ }
128
+ function We(r) {
129
+ return r ? r === !0 ? {
130
+ overscan: 1,
131
+ estimateHeight: 240,
132
+ dynamicHeights: !0,
133
+ adaptiveEstimate: !0,
134
+ estimateQuantile: 0.5
135
+ } : {
136
+ overscan: r.overscan ?? 1,
137
+ estimateHeight: r.estimateHeight ?? 240,
138
+ dynamicHeights: r.dynamicHeights ?? !0,
139
+ adaptiveEstimate: r.adaptiveEstimate ?? !0,
140
+ estimateQuantile: r.estimateQuantile ?? 0.5
141
+ } : null;
142
+ }
143
+ function Zt(r, a, u, o) {
144
+ const b = a.y, R = a.y + a.height, g = u + o, M = Math.max(
145
+ 0,
146
+ Math.min(g, R) - Math.max(u, b)
147
+ );
148
+ return {
149
+ index: r,
150
+ isVisible: M > 0,
151
+ visibleRatio: a.height > 0 ? Math.min(1, M / a.height) : 0,
152
+ isAboveViewport: R <= u,
153
+ isBelowViewport: b >= g
154
+ };
155
+ }
156
+ const Ee = ye.memo(function({
157
+ index: a,
158
+ item: u,
159
+ position: o,
160
+ useTransform: b,
161
+ itemStyle: R,
162
+ itemClassName: g,
163
+ renderItem: M,
164
+ onClick: f,
165
+ itemRef: H
166
+ }) {
167
+ const T = o ? b ? {
168
+ position: "absolute",
169
+ transform: `translate(${o.x}px, ${o.y}px)`,
170
+ width: o.width,
171
+ boxSizing: "border-box"
172
+ } : {
173
+ position: "absolute",
174
+ left: o.x,
175
+ top: o.y,
176
+ width: o.width,
177
+ boxSizing: "border-box"
178
+ } : { position: "absolute", opacity: 0, pointerEvents: "none" };
179
+ return /* @__PURE__ */ Lt(
180
+ "div",
181
+ {
182
+ ref: H,
183
+ style: { ...T, ...R },
184
+ className: g,
185
+ onClick: f ? (c) => f(a, u, c) : void 0,
186
+ "data-index": a,
187
+ "data-column": o?.column,
188
+ children: M(u, a)
189
+ }
190
+ );
191
+ }), Ve = pe(
192
+ function(a, u) {
193
+ const {
194
+ items: o = [],
195
+ renderItem: b,
196
+ keyExtractor: R = (t, e) => e,
197
+ columns: g = 3,
198
+ gap: M = 16,
199
+ rowGap: f,
200
+ columnGap: H,
201
+ alignmentMode: T = "shortest",
202
+ padding: c = 0,
203
+ containerStyle: N,
204
+ containerClassName: $,
205
+ itemStyle: F,
206
+ itemClassName: z,
207
+ useTransform: I = !0,
208
+ throttleDelay: G = 16,
209
+ debounceDelay: x = 150,
210
+ reachBottomOffset: nt = 100,
211
+ minItemHeight: V = 48,
212
+ scrollAnchor: D = !0,
213
+ virtualize: rt,
214
+ layoutHooks: S,
215
+ onMount: A,
216
+ onUnmount: U,
217
+ onBeforeLayout: ot,
218
+ onLayout: W,
219
+ onLayoutComplete: v,
220
+ onItemMount: te,
221
+ onItemUnmount: ee,
222
+ onItemEnterViewport: wt,
223
+ onItemLeaveViewport: Rt,
224
+ onScroll: Nt,
225
+ onResize: Vt,
226
+ onReachBottom: $t,
227
+ onItemClick: ne,
228
+ children: re,
229
+ containerRefExternal: oe,
230
+ itemRefsExternal: ce,
231
+ debug: Mt = !1
232
+ } = a, ie = l(null), y = oe ?? ie, se = l(/* @__PURE__ */ new Map()), O = ce ?? se, C = l(/* @__PURE__ */ new Map()), j = l(/* @__PURE__ */ new Map()), ut = l(null), ct = l(), it = l(), J = l(null), K = l(null), zt = l(0), ft = l(!1), st = l(0), It = l(!1), At = l(""), kt = l(void 0), ht = l(async () => {
233
+ }), lt = l(!1), at = l(!1), mt = l(/* @__PURE__ */ new Set()), X = l(o);
234
+ X.current = o;
235
+ const k = l(/* @__PURE__ */ new Map()), Bt = l(null), vt = l(0), Ft = l(R);
236
+ Ft.current = R;
237
+ const xt = l($t);
238
+ xt.current = $t;
239
+ const gt = f ?? M, Z = H ?? M, Ot = typeof c == "number" ? c : c?.top ?? 0, Pt = typeof c == "number" ? c : c?.right ?? 0, _t = typeof c == "number" ? c : c?.bottom ?? 0, Gt = typeof c == "number" ? c : c?.left ?? 0, q = bt(
240
+ () => ({ top: Ot, right: Pt, bottom: _t, left: Gt }),
241
+ [Ot, Pt, _t, Gt]
242
+ ), E = L((t) => {
243
+ const e = X.current[t];
244
+ if (e === void 0) return `#${t}`;
245
+ try {
246
+ return String(Ft.current(e, t));
247
+ } catch {
248
+ return `#${t}`;
249
+ }
250
+ }, []), qt = L(() => {
251
+ const t = X.current;
252
+ let e = String(t.length);
253
+ for (let n = 0; n < t.length; n++) e += `|${E(n)}`;
254
+ return e;
255
+ }, [E]), Qt = JSON.stringify(rt ?? null), d = bt(
256
+ () => We(JSON.parse(Qt) ?? void 0),
257
+ [Qt]
258
+ ), [Q, le] = Ht(() => ({
259
+ columns: g,
260
+ columnWidth: 0,
261
+ gap: Z,
262
+ columnHeights: Array(g).fill(0),
263
+ totalHeight: 0,
264
+ containerWidth: 0,
265
+ containerHeight: 0
266
+ })), [dt, ae] = Ht(
267
+ () => /* @__PURE__ */ new Map()
268
+ ), [P, Yt] = Ht({
269
+ scrollTop: 0,
270
+ scrollLeft: 0,
271
+ scrollHeight: 0,
272
+ scrollWidth: 0,
273
+ clientHeight: 0,
274
+ clientWidth: 0,
275
+ isScrolling: !1,
276
+ direction: null
277
+ }), [, ue] = Ht({});
278
+ k.current = dt;
279
+ const Tt = l(Q), Dt = L(
280
+ (t) => {
281
+ const e = k.current;
282
+ if (e.size === 0) return null;
283
+ const n = t.scrollTop;
284
+ if (n <= 0) return null;
285
+ let i = -1, h = Number.POSITIVE_INFINITY, w = -1, s = Number.NEGATIVE_INFINITY;
286
+ e.forEach((p, B) => {
287
+ p.y >= n && p.y < h && (h = p.y, i = B), p.y <= n && p.y + p.height > n && p.y > s && (s = p.y, w = B);
288
+ });
289
+ const m = i >= 0 ? i : w, _ = e.get(m);
290
+ return _ ? { index: m, offset: _.y - n } : null;
291
+ },
292
+ []
293
+ ), Ut = l(""), tt = l(null), yt = L(() => {
294
+ const t = xt.current;
295
+ if (!t) return;
296
+ const e = y.current;
297
+ if (!e) return;
298
+ const { scrollTop: n, scrollHeight: i, clientHeight: h } = e, w = i - (n + h);
299
+ if (w >= nt) return;
300
+ const s = `${n}|${i}|${h}`;
301
+ s !== Ut.current && (Ut.current = s, t(w));
302
+ }, [y, nt]), jt = L(() => {
303
+ tt.current == null && (tt.current = window.setTimeout(() => {
304
+ tt.current = null, yt();
305
+ }, 0));
306
+ }, [yt]), et = L(async () => {
307
+ const t = y.current;
308
+ if (!t) return;
309
+ const e = `${g}|${Z}|${gt}|${q.top},${q.right},${q.bottom},${q.left}|${T}|${d?.estimateHeight ?? ""}|${d?.adaptiveEstimate ?? ""}|${d?.estimateQuantile ?? ""}`;
310
+ if (ft.current) {
311
+ (e !== At.current || S !== kt.current) && (It.current = !0);
312
+ return;
313
+ }
314
+ ft.current = !0, At.current = e, kt.current = S, at.current = !1;
315
+ const n = Dt(t);
316
+ try {
317
+ if (await ot?.() === !1) return;
318
+ Mt && console.time("[WaterfallCore] layout"), W?.();
319
+ const h = t.clientWidth, w = X.current.map((p, B) => {
320
+ const Et = O.current.get(B)?.offsetHeight ?? 0;
321
+ return Et > 0 ? (C.current.set(E(B), Et), Et) : C.current.get(E(B)) ?? 0;
322
+ });
323
+ let s;
324
+ if (d)
325
+ if (d.adaptiveEstimate === !1)
326
+ s = d.estimateHeight;
327
+ else {
328
+ const p = Te(
329
+ C.current.values(),
330
+ d.estimateHeight ?? 240,
331
+ d.estimateQuantile
332
+ );
333
+ Math.abs(p - st.current) > 8 && (st.current = p), s = st.current || p;
334
+ }
335
+ const m = Me({
336
+ heights: w,
337
+ columns: g,
338
+ containerWidth: h,
339
+ columnGap: Z,
340
+ rowGap: gt,
341
+ padding: q,
342
+ alignmentMode: T,
343
+ estimateHeight: s,
344
+ minItemHeight: V,
345
+ hooks: S
346
+ }), _ = {
347
+ columns: m.columns,
348
+ columnWidth: m.columnWidth,
349
+ gap: Z,
350
+ columnHeights: m.columnHeights,
351
+ totalHeight: m.totalHeight,
352
+ containerWidth: h,
353
+ containerHeight: t.clientHeight
354
+ };
355
+ if (Tt.current = _, k.current = m.positions, le(_), ae(m.positions), lt.current = !0, Mt && (console.timeEnd("[WaterfallCore] layout"), m.estimatedCount > 0 && console.debug(
356
+ `[WaterfallCore] ${m.estimatedCount} 项按估值占位(estimateHeight=${s})`
357
+ )), v?.(), n && D) {
358
+ const p = m.positions.get(n.index);
359
+ if (p) {
360
+ const B = p.y - n.offset - t.scrollTop;
361
+ Math.abs(B) >= 1 && (vt.current += B);
362
+ }
363
+ }
364
+ jt();
365
+ } catch (i) {
366
+ console.warn("[vane-waterfall] 布局过程出错,本次布局已跳过", i);
367
+ } finally {
368
+ ft.current = !1, It.current && (It.current = !1, ht.current());
369
+ }
370
+ }, [
371
+ g,
372
+ Z,
373
+ gt,
374
+ q,
375
+ T,
376
+ d?.estimateHeight,
377
+ S,
378
+ ot,
379
+ W,
380
+ v,
381
+ Mt,
382
+ V,
383
+ D,
384
+ y,
385
+ O,
386
+ E,
387
+ Dt,
388
+ jt
389
+ ]);
390
+ be(() => {
391
+ const t = vt.current;
392
+ if (!t) return;
393
+ vt.current = 0;
394
+ const e = y.current;
395
+ e && (e.scrollTop += t);
396
+ }), ht.current = et;
397
+ const pt = L(() => {
398
+ it.current && window.clearTimeout(it.current), it.current = window.setTimeout(() => {
399
+ ht.current();
400
+ }, x);
401
+ }, [x]), Jt = L(() => {
402
+ J.current == null && (J.current = requestAnimationFrame(() => {
403
+ J.current = null, ht.current();
404
+ }));
405
+ }, []), Kt = L((t) => {
406
+ K.current == null && (K.current = requestAnimationFrame(() => {
407
+ K.current = null;
408
+ const e = y.current;
409
+ e && Yt((n) => {
410
+ const i = e.scrollTop, h = e.scrollLeft, w = i > n.scrollTop ? "down" : i < n.scrollTop ? "up" : h > n.scrollLeft ? "right" : h < n.scrollLeft ? "left" : n.direction, s = {
411
+ scrollTop: i,
412
+ scrollLeft: h,
413
+ scrollHeight: e.scrollHeight,
414
+ scrollWidth: e.scrollWidth,
415
+ clientHeight: e.clientHeight,
416
+ clientWidth: e.clientWidth,
417
+ isScrolling: t,
418
+ direction: w
419
+ };
420
+ return n.scrollTop === s.scrollTop && n.scrollLeft === s.scrollLeft && n.scrollHeight === s.scrollHeight && n.clientHeight === s.clientHeight && n.isScrolling === s.isScrolling ? n : s;
421
+ });
422
+ }));
423
+ }, [y]), fe = L(() => {
424
+ const t = y.current;
425
+ if (!t) return;
426
+ const e = Date.now();
427
+ Kt(!0);
428
+ const n = t.scrollTop, i = t.clientHeight;
429
+ if (Nt?.(n, t.scrollLeft), e - zt.current >= G && (zt.current = e, yt(), wt || Rt)) {
430
+ const h = k.current, w = /* @__PURE__ */ new Set();
431
+ h.forEach((s, m) => {
432
+ Math.max(
433
+ 0,
434
+ Math.min(n + i, s.y + s.height) - Math.max(n, s.y)
435
+ ) > 0 && (w.add(m), mt.current.has(m) || wt?.(
436
+ m,
437
+ Zt(m, s, n, i)
438
+ ));
439
+ }), mt.current.forEach((s) => {
440
+ if (w.has(s)) return;
441
+ const m = h.get(s);
442
+ m && Rt?.(
443
+ s,
444
+ Zt(s, m, n, i)
445
+ );
446
+ }), mt.current = w;
447
+ }
448
+ ct.current && window.clearTimeout(ct.current), ct.current = window.setTimeout(() => {
449
+ Yt((h) => ({ ...h, isScrolling: !1 }));
450
+ }, x);
451
+ }, [
452
+ Kt,
453
+ Nt,
454
+ wt,
455
+ Rt,
456
+ G,
457
+ x,
458
+ yt
459
+ ]), he = L(() => {
460
+ const t = y.current;
461
+ t && (Vt?.(t.clientWidth, t.clientHeight), pt());
462
+ }, [Vt, pt, y]);
463
+ Ct(() => {
464
+ A?.(), lt.current || et();
465
+ const t = y.current;
466
+ return t && typeof ResizeObserver < "u" && (ut.current = new ResizeObserver(he), ut.current.observe(t)), () => {
467
+ U?.(), ut.current?.disconnect(), ut.current = null, j.current.forEach((e) => {
468
+ try {
469
+ e.disconnect();
470
+ } catch {
471
+ }
472
+ }), j.current.clear(), ct.current && window.clearTimeout(ct.current), it.current && window.clearTimeout(it.current), tt.current != null && (window.clearTimeout(tt.current), tt.current = null), K.current != null && (cancelAnimationFrame(K.current), K.current = null), J.current != null && (cancelAnimationFrame(J.current), J.current = null);
473
+ };
474
+ }, []);
475
+ const St = l(/* @__PURE__ */ new Map());
476
+ Ct(() => {
477
+ const t = qt();
478
+ if (t === Bt.current) return;
479
+ Bt.current = t, lt.current = !1, at.current = !1, St.current.clear();
480
+ const e = /* @__PURE__ */ new Set();
481
+ for (let i = 0; i < X.current.length; i++) e.add(E(i));
482
+ let n = 0;
483
+ C.current.forEach((i, h) => {
484
+ e.has(h) ? n += 1 : C.current.delete(h);
485
+ }), n === 0 && (st.current = 0), pt();
486
+ }, [o, pt, qt, E]), Ct(() => {
487
+ lt.current = !1, at.current = !1, et();
488
+ }, [
489
+ g,
490
+ Z,
491
+ gt,
492
+ q,
493
+ T,
494
+ d?.estimateHeight,
495
+ d?.adaptiveEstimate,
496
+ d?.estimateQuantile,
497
+ S
498
+ ]);
499
+ const Xt = l(
500
+ () => {
501
+ }
502
+ );
503
+ Xt.current = (t, e) => {
504
+ if (e) {
505
+ O.current.set(t, e);
506
+ const n = E(t), i = e.offsetHeight;
507
+ if (i > 0 && C.current.set(n, i), (d ? d.dynamicHeights !== !1 : !0) && !j.current.has(t) && typeof ResizeObserver < "u") {
508
+ const w = new ResizeObserver(() => {
509
+ const s = e.offsetHeight;
510
+ if (s <= 0) return;
511
+ C.current.set(E(t), s);
512
+ const m = k.current.get(t), _ = m ? Math.abs(m.height - s) > 0.5 : !1, p = St.current.get(t) === s;
513
+ m ? _ && !p && (St.current.set(t, s), Jt()) : Jt();
514
+ });
515
+ try {
516
+ w.observe(e), j.current.set(t, w);
517
+ } catch {
518
+ }
519
+ }
520
+ te?.(t, e), lt.current && !k.current.has(t) && !ft.current && !at.current && (at.current = !0, requestAnimationFrame(() => void et()));
521
+ } else {
522
+ O.current.delete(t), Wt.current.delete(t);
523
+ const n = j.current.get(t);
524
+ if (n) {
525
+ try {
526
+ n.disconnect();
527
+ } catch {
528
+ }
529
+ j.current.delete(t);
530
+ }
531
+ ee?.(t);
532
+ }
533
+ };
534
+ const Wt = l(
535
+ /* @__PURE__ */ new Map()
536
+ ), me = (t) => {
537
+ let e = Wt.current.get(t);
538
+ return e || (e = (n) => Xt.current(t, n), Wt.current.set(t, e)), e;
539
+ }, Y = bt(
540
+ () => d ? Se(
541
+ dt,
542
+ o.length,
543
+ P.scrollTop,
544
+ P.clientHeight || Q.containerHeight || 600,
545
+ d.overscan
546
+ ) : { start: 0, end: Math.max(0, o.length - 1), hiddenCount: 0 },
547
+ [
548
+ d,
549
+ dt,
550
+ o.length,
551
+ P.scrollTop,
552
+ P.clientHeight,
553
+ Q.containerHeight
554
+ ]
555
+ );
556
+ He(
557
+ u,
558
+ () => ({
559
+ relayout: () => {
560
+ C.current.clear(), st.current = 0, X.current.forEach((t, e) => {
561
+ const n = O.current.get(e);
562
+ if (!n) return;
563
+ const i = n.offsetHeight;
564
+ i > 0 && C.current.set(E(e), i);
565
+ }), et();
566
+ },
567
+ scrollToItem: (t, e = {}) => {
568
+ const n = y.current, i = k.current.get(t);
569
+ !n || !i || n.scrollTo({
570
+ top: Ie(
571
+ i,
572
+ n.clientHeight,
573
+ e.block ?? "start",
574
+ e.offset ?? 0
575
+ ),
576
+ behavior: e.behavior ?? "auto"
577
+ });
578
+ },
579
+ scrollToTop: (t = {}) => {
580
+ y.current?.scrollTo({
581
+ top: t.offset ?? 0,
582
+ behavior: t.behavior ?? "auto"
583
+ });
584
+ },
585
+ scrollToBottom: (t = {}) => {
586
+ const e = y.current;
587
+ e && e.scrollTo({
588
+ top: e.scrollHeight - e.clientHeight + (t.offset ?? 0),
589
+ behavior: t.behavior ?? "auto"
590
+ });
591
+ },
592
+ getItemPosition: (t) => k.current.get(t) ?? null,
593
+ getAllItemPositions: () => k.current,
594
+ getColumnHeights: () => Tt.current.columnHeights,
595
+ getLayoutInfo: () => Tt.current,
596
+ getViewportInfo: () => {
597
+ const t = y.current;
598
+ return t ? {
599
+ scrollTop: t.scrollTop,
600
+ scrollLeft: t.scrollLeft,
601
+ scrollHeight: t.scrollHeight,
602
+ scrollWidth: t.scrollWidth,
603
+ clientHeight: t.clientHeight,
604
+ clientWidth: t.clientWidth,
605
+ isScrolling: P.isScrolling,
606
+ direction: P.direction
607
+ } : P;
608
+ },
609
+ getVisibleRange: () => ({ start: Y.start, end: Y.end }),
610
+ getVisibleItems: () => new Set(mt.current),
611
+ forceUpdate: () => ue({}),
612
+ getContainer: () => y.current,
613
+ getItemElement: (t) => O.current.get(t) ?? null,
614
+ measureItem: async (t) => {
615
+ const e = O.current.get(t), n = E(t);
616
+ if (e) {
617
+ const h = { width: e.offsetWidth, height: e.offsetHeight };
618
+ return h.height > 0 && C.current.set(n, h.height), h;
619
+ }
620
+ const i = C.current.get(n);
621
+ return i ? { width: Q.columnWidth, height: i } : { width: Q.columnWidth, height: d?.estimateHeight ?? 0 };
622
+ }
623
+ }),
624
+ [
625
+ et,
626
+ Q,
627
+ P,
628
+ Y,
629
+ y,
630
+ O,
631
+ d?.estimateHeight,
632
+ E
633
+ ]
634
+ );
635
+ const ge = bt(() => {
636
+ if (!d) return o.map((e, n) => n);
637
+ const t = [];
638
+ for (let e = Y.start; e <= Y.end; e++) t.push(e);
639
+ return t;
640
+ }, [d, o, Y.start, Y.end]);
641
+ return /* @__PURE__ */ de(
642
+ "div",
643
+ {
644
+ ref: y,
645
+ style: {
646
+ position: "relative",
647
+ overflowX: "hidden",
648
+ overflowY: "auto",
649
+ ...N
650
+ },
651
+ className: $,
652
+ onScroll: fe,
653
+ "data-vane-waterfall": "",
654
+ children: [
655
+ re,
656
+ /* @__PURE__ */ Lt(
657
+ "div",
658
+ {
659
+ style: {
660
+ position: "relative",
661
+ width: "100%",
662
+ height: Q.totalHeight,
663
+ minWidth: 0
664
+ },
665
+ children: ge.map((t) => {
666
+ const e = o[t];
667
+ return e === void 0 ? null : /* @__PURE__ */ Lt(
668
+ Ee,
669
+ {
670
+ index: t,
671
+ item: e,
672
+ position: dt.get(t),
673
+ useTransform: I,
674
+ itemStyle: F,
675
+ itemClassName: z,
676
+ renderItem: b,
677
+ onClick: ne,
678
+ itemRef: me(t)
679
+ },
680
+ R(e, t)
681
+ );
682
+ })
683
+ }
684
+ )
685
+ ]
686
+ }
687
+ );
688
+ }
689
+ );
690
+ export {
691
+ Ve as W,
692
+ Ie as a,
693
+ Se as b,
694
+ Me as c
695
+ };