vane-waterfall 2.0.1 → 2.0.3
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 +4 -4
- package/dist/chunks/WaterfallCore-EdAZuWAY.js +695 -0
- package/dist/chunks/doc-BAhVW3g8.js +150 -0
- package/dist/chunks/doc-BU0CKW63.js +156 -0
- package/dist/chunks/doc-BrEd0oZB.js +100 -0
- package/dist/chunks/{doc-bTHwfIVb.js → doc-Bud0hbaz.js} +39 -25
- package/dist/chunks/{doc-DukOmDCo.js → doc-C-B3zK2o.js} +52 -23
- package/dist/chunks/{doc-DElLNjIc.js → doc-C206ZwYC.js} +33 -24
- package/dist/chunks/doc-C2L8kkeI.js +112 -0
- package/dist/chunks/doc-CE1DGMBV.js +166 -0
- package/dist/chunks/{doc-BXSy2aPP.js → doc-CHbQXLwY.js} +33 -19
- package/dist/chunks/{doc-BfWnfTst.js → doc-CInpKZNU.js} +38 -24
- package/dist/chunks/{doc-gTAsLjVx.js → doc-CYxwSuG6.js} +30 -16
- package/dist/chunks/{doc-DzvTrZ13.js → doc-CaJ02INP.js} +25 -16
- package/dist/chunks/{doc-BXElhF2h.js → doc-CiCso5Ti.js} +44 -30
- package/dist/chunks/doc-CkuMr8Ca.js +118 -0
- package/dist/chunks/{doc-3Fpag2G8.js → doc-D7m1OFCW.js} +38 -24
- package/dist/chunks/doc-DEN2WTDh.js +153 -0
- package/dist/chunks/{doc-C5xrHNoC.js → doc-DhICh9S2.js} +37 -23
- package/dist/chunks/doc-DlJICsyN.js +100 -0
- package/dist/chunks/{doc-BtzhgTYj.js → doc-DtxS1-P0.js} +35 -26
- package/dist/chunks/{doc-BIzjYAZW.js → doc-DudYCn_-.js} +25 -16
- package/dist/chunks/doc-HoyAFR_m.js +101 -0
- package/dist/chunks/doc-RlBMCMNs.js +170 -0
- package/dist/chunks/doc-RwKQqySd.js +102 -0
- package/dist/chunks/{doc-CTUoMe7o.js → doc-eYhNJy97.js} +31 -22
- package/dist/chunks/{doc-CcPFavOs.js → doc-i6FY1We1.js} +27 -13
- package/dist/chunks/doc-skPl6ZMP.js +101 -0
- package/dist/chunks/index-8gEIzUxi.js +15 -0
- package/dist/chunks/index-B96I5CKE.js +21 -0
- package/dist/chunks/index-Bjmhy8jW.js +11 -0
- package/dist/chunks/index-Cuq0ofv-.js +13 -0
- package/dist/chunks/{index-BAWlVYr3.js → index-Cz4YEqRF.js} +1 -1
- package/dist/chunks/{index-wLI6UXkY.js → index-FBJVUYmH.js} +1 -1
- package/dist/chunks/withPlugins-BOeDFhof.js +743 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +19 -0
- package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/layout.d.ts +7 -0
- package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/plugins/types.d.ts +3 -0
- package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -1
- package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -1
- package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +64 -40
- package/dist/custom-plugins/A11yPlugin/index.js +1 -1
- package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/AlignmentPlugin/index.js +1 -1
- package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +53 -44
- package/dist/custom-plugins/AutoColumnPlugin/index.js +1 -1
- package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +44 -35
- package/dist/custom-plugins/BookmarkPlugin/index.js +1 -1
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +2 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +29 -0
- package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +1 -1
- package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +37 -28
- package/dist/custom-plugins/DebounceLayoutPlugin/index.js +1 -1
- package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +14 -0
- package/dist/custom-plugins/DragReorderPlugin/index.js +1 -1
- package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +53 -39
- package/dist/custom-plugins/FilterPlugin/index.js +1 -1
- package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/FixedHeightPlugin/index.js +1 -1
- package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/GapPlugin/doc.json.d.ts +61 -37
- package/dist/custom-plugins/GapPlugin/index.js +1 -1
- package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +61 -32
- package/dist/custom-plugins/GroupingPlugin/index.js +1 -1
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +2 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +24 -0
- package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +1 -1
- package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +55 -36
- package/dist/custom-plugins/InfiniteScrollPlugin/index.js +1 -1
- package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +56 -42
- package/dist/custom-plugins/PaginationPlugin/index.js +1 -1
- package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +49 -35
- package/dist/custom-plugins/PinItemPlugin/index.js +1 -1
- package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +57 -28
- package/dist/custom-plugins/RecyclePlugin/index.js +1 -1
- package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +29 -0
- package/dist/custom-plugins/ReducedMotionPlugin/index.js +1 -1
- package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +40 -31
- package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +1 -1
- package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +42 -28
- package/dist/custom-plugins/ScrollAnchorPlugin/index.js +1 -1
- package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +53 -39
- package/dist/custom-plugins/SearchPlugin/index.js +1 -1
- package/dist/custom-plugins/SortPlugin/doc.json.d.ts +52 -38
- package/dist/custom-plugins/SortPlugin/index.js +1 -1
- package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +71 -37
- package/dist/custom-plugins/StatePersistencePlugin/index.js +1 -1
- package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +43 -34
- package/dist/custom-plugins/StickyHeaderPlugin/index.js +1 -1
- package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +43 -34
- package/dist/custom-plugins/ThrottlePlugin/index.js +1 -1
- package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +49 -35
- package/dist/custom-plugins/TransitionPlugin/index.js +1 -1
- package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -1
- package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +57 -33
- package/dist/custom-plugins/URLSyncPlugin/index.js +1 -1
- package/dist/custom-plugins/index.js +6 -6
- package/dist/entries/core.js +1 -1
- package/dist/entries/plugins.js +7 -7
- package/dist/index.js +2 -2
- package/dist/presets/dashboard/index.js +2 -2
- package/dist/presets/photo-feed/index.js +3 -3
- package/dist/presets/product-feed/index.js +2 -2
- package/package.json +16 -8
- package/dist/chunks/WaterfallCore-BSXw7bl_.js +0 -581
- package/dist/chunks/doc-78xF08vt.js +0 -82
- package/dist/chunks/doc-B-7dugGv.js +0 -79
- package/dist/chunks/doc-B6kLfMPv.js +0 -121
- package/dist/chunks/doc-BCGQ8Cp5.js +0 -114
- package/dist/chunks/doc-BP0DmB7-.js +0 -91
- package/dist/chunks/doc-CBHjiDG7.js +0 -88
- package/dist/chunks/doc-CraXjOaA.js +0 -68
- package/dist/chunks/doc-DJjxOYzW.js +0 -111
- package/dist/chunks/doc-NhL4Ux8q.js +0 -125
- package/dist/chunks/doc-f4Uijujv.js +0 -102
- package/dist/chunks/doc-j4W9SUrY.js +0 -76
- package/dist/chunks/doc-kTbJE7rY.js +0 -92
- package/dist/chunks/index-COaun3nf.js +0 -15
- package/dist/chunks/index-DXAtA2f6.js +0 -11
- package/dist/chunks/index-DsRLmBW-.js +0 -13
- package/dist/chunks/index-gjoCq0yC.js +0 -21
- package/dist/chunks/withPlugins-DLoKg4AP.js +0 -559
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
import { jsxs as Kt, jsx as $t } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Xt, useRef as c, useMemo as lt, useState as ut, useCallback as j, useEffect as vt, useImperativeHandle as Zt } from "react";
|
|
3
|
-
function Ot(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 te(r, i) {
|
|
12
|
-
return typeof r == "number" && Number.isFinite(r) && r > 0 ? r : i && i > 0 ? i : 0;
|
|
13
|
-
}
|
|
14
|
-
function ee(r) {
|
|
15
|
-
const {
|
|
16
|
-
heights: i,
|
|
17
|
-
columnGap: f,
|
|
18
|
-
rowGap: o,
|
|
19
|
-
alignmentMode: p = "shortest",
|
|
20
|
-
estimateHeight: C,
|
|
21
|
-
hooks: s
|
|
22
|
-
} = r, u = Ot(r.padding), b = r.containerWidth, g = s?.calculateColumns?.(r.columns), m = Math.max(
|
|
23
|
-
1,
|
|
24
|
-
Math.round(
|
|
25
|
-
typeof g == "number" && Number.isFinite(g) ? g : r.columns
|
|
26
|
-
)
|
|
27
|
-
), I = (b - u.left - u.right - f * (m - 1)) / m, E = s?.calculateColumnWidth?.(
|
|
28
|
-
I,
|
|
29
|
-
m,
|
|
30
|
-
b
|
|
31
|
-
), S = typeof E == "number" && Number.isFinite(E) ? E : I, H = Array(m).fill(u.top), N = Array(m).fill(0), Q = /* @__PURE__ */ new Map();
|
|
32
|
-
let F = 0;
|
|
33
|
-
if (i.length === 0)
|
|
34
|
-
return {
|
|
35
|
-
columns: m,
|
|
36
|
-
columnWidth: S,
|
|
37
|
-
padding: u,
|
|
38
|
-
columnHeights: H,
|
|
39
|
-
totalHeight: u.top + u.bottom,
|
|
40
|
-
positions: Q,
|
|
41
|
-
estimatedCount: 0
|
|
42
|
-
};
|
|
43
|
-
for (let L = 0; L < i.length; L++) {
|
|
44
|
-
const J = i[L], V = te(J, C);
|
|
45
|
-
if (V === 0) continue;
|
|
46
|
-
typeof J == "number" && J > 0 || (F += 1);
|
|
47
|
-
let k = 0;
|
|
48
|
-
if (p === "sequential")
|
|
49
|
-
k = L % m;
|
|
50
|
-
else if (p === "balanced") {
|
|
51
|
-
let T = N[0];
|
|
52
|
-
for (let R = 1; R < m; R++)
|
|
53
|
-
N[R] < T && (T = N[R], k = R);
|
|
54
|
-
} else {
|
|
55
|
-
let T = H[0];
|
|
56
|
-
for (let R = 1; R < H.length; R++)
|
|
57
|
-
H[R] < T && (T = H[R], k = R);
|
|
58
|
-
}
|
|
59
|
-
let z = {
|
|
60
|
-
x: u.left + k * (S + f),
|
|
61
|
-
y: H[k],
|
|
62
|
-
width: S,
|
|
63
|
-
height: V,
|
|
64
|
-
column: k,
|
|
65
|
-
row: Math.floor(L / m)
|
|
66
|
-
};
|
|
67
|
-
const P = s?.calculateItemPosition?.(L, V, z);
|
|
68
|
-
if (P) {
|
|
69
|
-
const T = { ...z, ...P };
|
|
70
|
-
P.column !== void 0 && P.x === void 0 && (T.x = u.left + Math.min(Math.max(0, T.column), m - 1) * (S + f)), z = T;
|
|
71
|
-
}
|
|
72
|
-
Q.set(L, z);
|
|
73
|
-
const K = Math.min(
|
|
74
|
-
Math.max(0, z.column),
|
|
75
|
-
H.length - 1
|
|
76
|
-
);
|
|
77
|
-
H[K] = z.y + z.height + o, N[K] += 1;
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
columns: m,
|
|
81
|
-
columnWidth: S,
|
|
82
|
-
padding: u,
|
|
83
|
-
columnHeights: H,
|
|
84
|
-
totalHeight: Math.max(...H) + u.bottom,
|
|
85
|
-
positions: Q,
|
|
86
|
-
estimatedCount: F
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function ne(r, i, f = "start", o = 0) {
|
|
90
|
-
let p = r.y + o;
|
|
91
|
-
return f === "center" ? p -= i / 2 - r.height / 2 : f === "end" && (p -= i - r.height), Math.max(0, p);
|
|
92
|
-
}
|
|
93
|
-
const re = 8;
|
|
94
|
-
function oe(r, i, f = 0.5) {
|
|
95
|
-
const o = [];
|
|
96
|
-
for (const s of r)
|
|
97
|
-
Number.isFinite(s) && s > 0 && o.push(s);
|
|
98
|
-
if (o.length < re) return i;
|
|
99
|
-
o.sort((s, u) => s - u);
|
|
100
|
-
const p = Math.min(1, Math.max(0, f)), C = Math.min(o.length - 1, Math.round(p * (o.length - 1)));
|
|
101
|
-
return Math.max(1, Math.ceil(o[C]));
|
|
102
|
-
}
|
|
103
|
-
function ie(r, i, f, o, p = 1) {
|
|
104
|
-
if (i <= 0) return { start: 0, end: -1, hiddenCount: 0 };
|
|
105
|
-
if (r.size === 0) {
|
|
106
|
-
const v = Math.max(1, Math.ceil(o / 240) + 2);
|
|
107
|
-
return { start: 0, end: Math.min(i - 1, v - 1), hiddenCount: 0 };
|
|
108
|
-
}
|
|
109
|
-
const C = Math.max(0, o * p), s = f - C, u = f + Math.max(o, 1) + C;
|
|
110
|
-
let b = Number.POSITIVE_INFINITY, g = -1;
|
|
111
|
-
if (r.forEach((v, I) => {
|
|
112
|
-
const E = v.y;
|
|
113
|
-
v.y + v.height > s && E < u && (I < b && (b = I), I > g && (g = I));
|
|
114
|
-
}), g < 0) {
|
|
115
|
-
let v = 0, I = Number.POSITIVE_INFINITY;
|
|
116
|
-
r.forEach((S, H) => {
|
|
117
|
-
const N = Math.abs(S.y - f);
|
|
118
|
-
N < I && (I = N, v = H);
|
|
119
|
-
});
|
|
120
|
-
const E = Math.max(1, Math.ceil(o / 240) + 2);
|
|
121
|
-
b = Math.max(0, v - E), g = Math.min(i - 1, v + E);
|
|
122
|
-
}
|
|
123
|
-
b = Math.max(0, b), g = Math.min(i - 1, g), g < b && (g = b);
|
|
124
|
-
const m = g - b + 1;
|
|
125
|
-
return { start: b, end: g, hiddenCount: Math.max(0, i - m) };
|
|
126
|
-
}
|
|
127
|
-
function ce(r) {
|
|
128
|
-
return r ? r === !0 ? {
|
|
129
|
-
overscan: 1,
|
|
130
|
-
estimateHeight: 240,
|
|
131
|
-
dynamicHeights: !0,
|
|
132
|
-
adaptiveEstimate: !0,
|
|
133
|
-
estimateQuantile: 0.5
|
|
134
|
-
} : {
|
|
135
|
-
overscan: r.overscan ?? 1,
|
|
136
|
-
estimateHeight: r.estimateHeight ?? 240,
|
|
137
|
-
dynamicHeights: r.dynamicHeights ?? !0,
|
|
138
|
-
adaptiveEstimate: r.adaptiveEstimate ?? !0,
|
|
139
|
-
estimateQuantile: r.estimateQuantile ?? 0.5
|
|
140
|
-
} : null;
|
|
141
|
-
}
|
|
142
|
-
function kt(r, i, f, o) {
|
|
143
|
-
const p = i.y, C = i.y + i.height, s = f + o, u = Math.max(
|
|
144
|
-
0,
|
|
145
|
-
Math.min(s, C) - Math.max(f, p)
|
|
146
|
-
);
|
|
147
|
-
return {
|
|
148
|
-
index: r,
|
|
149
|
-
isVisible: u > 0,
|
|
150
|
-
visibleRatio: i.height > 0 ? Math.min(1, u / i.height) : 0,
|
|
151
|
-
isAboveViewport: C <= f,
|
|
152
|
-
isBelowViewport: p >= s
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const ue = Xt(
|
|
156
|
-
function(i, f) {
|
|
157
|
-
const {
|
|
158
|
-
items: o = [],
|
|
159
|
-
renderItem: p,
|
|
160
|
-
keyExtractor: C = (t, e) => e,
|
|
161
|
-
columns: s = 3,
|
|
162
|
-
gap: u = 16,
|
|
163
|
-
rowGap: b,
|
|
164
|
-
columnGap: g,
|
|
165
|
-
alignmentMode: m = "shortest",
|
|
166
|
-
padding: v = 0,
|
|
167
|
-
containerStyle: I,
|
|
168
|
-
containerClassName: E,
|
|
169
|
-
itemStyle: S,
|
|
170
|
-
itemClassName: H,
|
|
171
|
-
useTransform: N = !0,
|
|
172
|
-
throttleDelay: Q = 16,
|
|
173
|
-
debounceDelay: F = 150,
|
|
174
|
-
reachBottomOffset: L = 100,
|
|
175
|
-
virtualize: J,
|
|
176
|
-
layoutHooks: V,
|
|
177
|
-
onMount: k,
|
|
178
|
-
onUnmount: z,
|
|
179
|
-
onBeforeLayout: P,
|
|
180
|
-
onLayout: K,
|
|
181
|
-
onLayoutComplete: T,
|
|
182
|
-
onItemMount: R,
|
|
183
|
-
onItemUnmount: At,
|
|
184
|
-
onItemEnterViewport: ht,
|
|
185
|
-
onItemLeaveViewport: ft,
|
|
186
|
-
onScroll: Rt,
|
|
187
|
-
onResize: It,
|
|
188
|
-
onReachBottom: mt,
|
|
189
|
-
onItemClick: Bt,
|
|
190
|
-
children: Ft,
|
|
191
|
-
containerRefExternal: Pt,
|
|
192
|
-
itemRefsExternal: Gt,
|
|
193
|
-
debug: gt = !1
|
|
194
|
-
} = i, _t = c(null), y = Pt ?? _t, xt = c(/* @__PURE__ */ new Map()), O = Gt ?? xt, $ = c(/* @__PURE__ */ new Map()), q = c(/* @__PURE__ */ new Map()), rt = c(null), X = c(), Z = c(), D = c(null), Tt = c(0), tt = c(!1), dt = c(0), pt = c(!1), Wt = c(""), Ct = c(void 0), ot = c(async () => {
|
|
195
|
-
}), et = c(!1), nt = c(!1), yt = c(/* @__PURE__ */ new Set()), bt = c(o);
|
|
196
|
-
bt.current = o;
|
|
197
|
-
const A = c(/* @__PURE__ */ new Map()), it = b ?? u, U = g ?? u, G = lt(() => Ot(v), [v]), Et = JSON.stringify(J ?? null), a = lt(
|
|
198
|
-
() => ce(JSON.parse(Et) ?? void 0),
|
|
199
|
-
[Et]
|
|
200
|
-
), [_, Qt] = ut(() => ({
|
|
201
|
-
columns: s,
|
|
202
|
-
columnWidth: 0,
|
|
203
|
-
gap: U,
|
|
204
|
-
columnHeights: Array(s).fill(0),
|
|
205
|
-
totalHeight: 0,
|
|
206
|
-
containerWidth: 0,
|
|
207
|
-
containerHeight: 0
|
|
208
|
-
})), [ct, qt] = ut(
|
|
209
|
-
() => /* @__PURE__ */ new Map()
|
|
210
|
-
), [B, St] = ut({
|
|
211
|
-
scrollTop: 0,
|
|
212
|
-
scrollLeft: 0,
|
|
213
|
-
scrollHeight: 0,
|
|
214
|
-
scrollWidth: 0,
|
|
215
|
-
clientHeight: 0,
|
|
216
|
-
clientWidth: 0,
|
|
217
|
-
isScrolling: !1,
|
|
218
|
-
direction: null
|
|
219
|
-
}), [, Dt] = ut({});
|
|
220
|
-
A.current = ct;
|
|
221
|
-
const Ht = c(_), Y = j(async () => {
|
|
222
|
-
const t = y.current;
|
|
223
|
-
if (!t) return;
|
|
224
|
-
const e = `${s}|${U}|${it}|${G.top},${G.right},${G.bottom},${G.left}|${m}|${a?.estimateHeight ?? ""}|${a?.adaptiveEstimate ?? ""}|${a?.estimateQuantile ?? ""}`;
|
|
225
|
-
if (tt.current) {
|
|
226
|
-
(e !== Wt.current || V !== Ct.current) && (pt.current = !0);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (tt.current = !0, Wt.current = e, Ct.current = V, nt.current = !1, await P?.() === !1) {
|
|
230
|
-
tt.current = !1;
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
gt && console.time("[WaterfallCore] layout"), K?.();
|
|
234
|
-
const l = t.clientWidth, W = bt.current.map((M, at) => {
|
|
235
|
-
const Mt = O.current.get(at)?.offsetHeight ?? 0;
|
|
236
|
-
return Mt > 0 ? ($.current.set(at, Mt), Mt) : $.current.get(at) ?? 0;
|
|
237
|
-
});
|
|
238
|
-
let h;
|
|
239
|
-
if (a)
|
|
240
|
-
if (a.adaptiveEstimate === !1)
|
|
241
|
-
h = a.estimateHeight;
|
|
242
|
-
else {
|
|
243
|
-
const M = oe(
|
|
244
|
-
$.current.values(),
|
|
245
|
-
a.estimateHeight ?? 240,
|
|
246
|
-
a.estimateQuantile
|
|
247
|
-
);
|
|
248
|
-
Math.abs(M - dt.current) > 8 && (dt.current = M), h = dt.current || M;
|
|
249
|
-
}
|
|
250
|
-
const d = ee({
|
|
251
|
-
heights: W,
|
|
252
|
-
columns: s,
|
|
253
|
-
containerWidth: l,
|
|
254
|
-
columnGap: U,
|
|
255
|
-
rowGap: it,
|
|
256
|
-
padding: G,
|
|
257
|
-
alignmentMode: m,
|
|
258
|
-
estimateHeight: h,
|
|
259
|
-
hooks: V
|
|
260
|
-
}), w = {
|
|
261
|
-
columns: d.columns,
|
|
262
|
-
columnWidth: d.columnWidth,
|
|
263
|
-
gap: U,
|
|
264
|
-
columnHeights: d.columnHeights,
|
|
265
|
-
totalHeight: d.totalHeight,
|
|
266
|
-
containerWidth: l,
|
|
267
|
-
containerHeight: t.clientHeight
|
|
268
|
-
};
|
|
269
|
-
Ht.current = w, A.current = d.positions, Qt(w), qt(d.positions), et.current = !0, gt && (console.timeEnd("[WaterfallCore] layout"), d.estimatedCount > 0 && console.debug(
|
|
270
|
-
`[WaterfallCore] ${d.estimatedCount} 项按估值占位(estimateHeight=${h})`
|
|
271
|
-
)), T?.(), tt.current = !1, pt.current && (pt.current = !1, ot.current());
|
|
272
|
-
}, [
|
|
273
|
-
s,
|
|
274
|
-
U,
|
|
275
|
-
it,
|
|
276
|
-
G,
|
|
277
|
-
m,
|
|
278
|
-
a?.estimateHeight,
|
|
279
|
-
V,
|
|
280
|
-
P,
|
|
281
|
-
K,
|
|
282
|
-
T,
|
|
283
|
-
gt,
|
|
284
|
-
y,
|
|
285
|
-
O
|
|
286
|
-
]);
|
|
287
|
-
ot.current = Y;
|
|
288
|
-
const st = j(() => {
|
|
289
|
-
Z.current && window.clearTimeout(Z.current), Z.current = window.setTimeout(() => {
|
|
290
|
-
ot.current();
|
|
291
|
-
}, F);
|
|
292
|
-
}, [F]), Lt = j(() => {
|
|
293
|
-
D.current == null && (D.current = requestAnimationFrame(() => {
|
|
294
|
-
D.current = null, ot.current();
|
|
295
|
-
}));
|
|
296
|
-
}, []), Nt = j((t) => {
|
|
297
|
-
const e = y.current;
|
|
298
|
-
e && St((n) => {
|
|
299
|
-
const l = e.scrollTop, W = e.scrollLeft, h = l > n.scrollTop ? "down" : l < n.scrollTop ? "up" : W > n.scrollLeft ? "right" : W < n.scrollLeft ? "left" : n.direction;
|
|
300
|
-
return {
|
|
301
|
-
scrollTop: l,
|
|
302
|
-
scrollLeft: W,
|
|
303
|
-
scrollHeight: e.scrollHeight,
|
|
304
|
-
scrollWidth: e.scrollWidth,
|
|
305
|
-
clientHeight: e.clientHeight,
|
|
306
|
-
clientWidth: e.clientWidth,
|
|
307
|
-
isScrolling: t,
|
|
308
|
-
direction: h
|
|
309
|
-
};
|
|
310
|
-
});
|
|
311
|
-
}, [y]), Ut = j(() => {
|
|
312
|
-
const t = y.current;
|
|
313
|
-
if (!t) return;
|
|
314
|
-
const e = Date.now();
|
|
315
|
-
Nt(!0);
|
|
316
|
-
const n = t.scrollTop, { clientHeight: l, scrollHeight: W } = t;
|
|
317
|
-
if (Rt?.(n, t.scrollLeft), e - Tt.current >= Q) {
|
|
318
|
-
if (Tt.current = e, mt) {
|
|
319
|
-
const h = W - (n + l);
|
|
320
|
-
h < L && mt(h);
|
|
321
|
-
}
|
|
322
|
-
if (ht || ft) {
|
|
323
|
-
const h = A.current, d = /* @__PURE__ */ new Set();
|
|
324
|
-
h.forEach((w, M) => {
|
|
325
|
-
Math.max(
|
|
326
|
-
0,
|
|
327
|
-
Math.min(n + l, w.y + w.height) - Math.max(n, w.y)
|
|
328
|
-
) > 0 && (d.add(M), yt.current.has(M) || ht?.(
|
|
329
|
-
M,
|
|
330
|
-
kt(M, w, n, l)
|
|
331
|
-
));
|
|
332
|
-
}), yt.current.forEach((w) => {
|
|
333
|
-
if (d.has(w)) return;
|
|
334
|
-
const M = h.get(w);
|
|
335
|
-
M && ft?.(
|
|
336
|
-
w,
|
|
337
|
-
kt(w, M, n, l)
|
|
338
|
-
);
|
|
339
|
-
}), yt.current = d;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
X.current && window.clearTimeout(X.current), X.current = window.setTimeout(() => {
|
|
343
|
-
St((h) => ({ ...h, isScrolling: !1 }));
|
|
344
|
-
}, F);
|
|
345
|
-
}, [
|
|
346
|
-
Nt,
|
|
347
|
-
Rt,
|
|
348
|
-
mt,
|
|
349
|
-
ht,
|
|
350
|
-
ft,
|
|
351
|
-
Q,
|
|
352
|
-
F,
|
|
353
|
-
L
|
|
354
|
-
]), Yt = j(() => {
|
|
355
|
-
const t = y.current;
|
|
356
|
-
t && (It?.(t.clientWidth, t.clientHeight), st());
|
|
357
|
-
}, [It, st, y]);
|
|
358
|
-
vt(() => {
|
|
359
|
-
k?.(), et.current || Y();
|
|
360
|
-
const t = y.current;
|
|
361
|
-
return t && typeof ResizeObserver < "u" && (rt.current = new ResizeObserver(Yt), rt.current.observe(t)), () => {
|
|
362
|
-
z?.(), rt.current?.disconnect(), rt.current = null, q.current.forEach((e) => {
|
|
363
|
-
try {
|
|
364
|
-
e.disconnect();
|
|
365
|
-
} catch {
|
|
366
|
-
}
|
|
367
|
-
}), q.current.clear(), X.current && window.clearTimeout(X.current), Z.current && window.clearTimeout(Z.current), D.current != null && (cancelAnimationFrame(D.current), D.current = null);
|
|
368
|
-
};
|
|
369
|
-
}, []);
|
|
370
|
-
const wt = c(/* @__PURE__ */ new Map());
|
|
371
|
-
vt(() => {
|
|
372
|
-
et.current = !1, nt.current = !1, wt.current.clear(), st();
|
|
373
|
-
}, [o, st]), vt(() => {
|
|
374
|
-
et.current = !1, nt.current = !1, Y();
|
|
375
|
-
}, [
|
|
376
|
-
s,
|
|
377
|
-
U,
|
|
378
|
-
it,
|
|
379
|
-
G,
|
|
380
|
-
m,
|
|
381
|
-
a?.estimateHeight,
|
|
382
|
-
a?.adaptiveEstimate,
|
|
383
|
-
a?.estimateQuantile,
|
|
384
|
-
V
|
|
385
|
-
]);
|
|
386
|
-
const Vt = c(
|
|
387
|
-
() => {
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
Vt.current = (t, e) => {
|
|
391
|
-
if (e) {
|
|
392
|
-
O.current.set(t, e);
|
|
393
|
-
const n = e.offsetHeight;
|
|
394
|
-
if (n > 0 && $.current.set(t, n), (a ? a.dynamicHeights !== !1 : !0) && !q.current.has(t) && typeof ResizeObserver < "u") {
|
|
395
|
-
const W = new ResizeObserver(() => {
|
|
396
|
-
const h = e.offsetHeight;
|
|
397
|
-
if (h <= 0) return;
|
|
398
|
-
$.current.set(t, h);
|
|
399
|
-
const d = A.current.get(t), w = d ? Math.abs(d.height - h) > 0.5 : !1, M = wt.current.get(t) === h;
|
|
400
|
-
d ? w && !M && (wt.current.set(t, h), Lt()) : Lt();
|
|
401
|
-
});
|
|
402
|
-
try {
|
|
403
|
-
W.observe(e), q.current.set(t, W);
|
|
404
|
-
} catch {
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
R?.(t, e), et.current && !A.current.has(t) && !tt.current && !nt.current && (nt.current = !0, requestAnimationFrame(() => void Y()));
|
|
408
|
-
} else {
|
|
409
|
-
O.current.delete(t);
|
|
410
|
-
const n = q.current.get(t);
|
|
411
|
-
if (n) {
|
|
412
|
-
try {
|
|
413
|
-
n.disconnect();
|
|
414
|
-
} catch {
|
|
415
|
-
}
|
|
416
|
-
q.current.delete(t);
|
|
417
|
-
}
|
|
418
|
-
At?.(t);
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
const zt = c(
|
|
422
|
-
/* @__PURE__ */ new Map()
|
|
423
|
-
), jt = (t) => {
|
|
424
|
-
let e = zt.current.get(t);
|
|
425
|
-
return e || (e = (n) => Vt.current(t, n), zt.current.set(t, e)), e;
|
|
426
|
-
}, x = lt(
|
|
427
|
-
() => a ? ie(
|
|
428
|
-
ct,
|
|
429
|
-
o.length,
|
|
430
|
-
B.scrollTop,
|
|
431
|
-
B.clientHeight || _.containerHeight || 600,
|
|
432
|
-
a.overscan
|
|
433
|
-
) : { start: 0, end: Math.max(0, o.length - 1), hiddenCount: 0 },
|
|
434
|
-
[
|
|
435
|
-
a,
|
|
436
|
-
ct,
|
|
437
|
-
o.length,
|
|
438
|
-
B.scrollTop,
|
|
439
|
-
B.clientHeight,
|
|
440
|
-
_.containerHeight
|
|
441
|
-
]
|
|
442
|
-
);
|
|
443
|
-
Zt(
|
|
444
|
-
f,
|
|
445
|
-
() => ({
|
|
446
|
-
relayout: () => {
|
|
447
|
-
$.current.clear(), bt.current.forEach((t, e) => {
|
|
448
|
-
const n = O.current.get(e);
|
|
449
|
-
n && $.current.set(e, n.offsetHeight);
|
|
450
|
-
}), Y();
|
|
451
|
-
},
|
|
452
|
-
scrollToItem: (t, e = {}) => {
|
|
453
|
-
const n = y.current, l = A.current.get(t);
|
|
454
|
-
!n || !l || n.scrollTo({
|
|
455
|
-
top: ne(
|
|
456
|
-
l,
|
|
457
|
-
n.clientHeight,
|
|
458
|
-
e.block ?? "start",
|
|
459
|
-
e.offset ?? 0
|
|
460
|
-
),
|
|
461
|
-
behavior: e.behavior ?? "auto"
|
|
462
|
-
});
|
|
463
|
-
},
|
|
464
|
-
scrollToTop: (t = {}) => {
|
|
465
|
-
y.current?.scrollTo({
|
|
466
|
-
top: t.offset ?? 0,
|
|
467
|
-
behavior: t.behavior ?? "auto"
|
|
468
|
-
});
|
|
469
|
-
},
|
|
470
|
-
scrollToBottom: (t = {}) => {
|
|
471
|
-
const e = y.current;
|
|
472
|
-
e && e.scrollTo({
|
|
473
|
-
top: e.scrollHeight - e.clientHeight + (t.offset ?? 0),
|
|
474
|
-
behavior: t.behavior ?? "auto"
|
|
475
|
-
});
|
|
476
|
-
},
|
|
477
|
-
getItemPosition: (t) => A.current.get(t) ?? null,
|
|
478
|
-
getAllItemPositions: () => A.current,
|
|
479
|
-
getColumnHeights: () => Ht.current.columnHeights,
|
|
480
|
-
getLayoutInfo: () => Ht.current,
|
|
481
|
-
getViewportInfo: () => {
|
|
482
|
-
const t = y.current;
|
|
483
|
-
return t ? {
|
|
484
|
-
scrollTop: t.scrollTop,
|
|
485
|
-
scrollLeft: t.scrollLeft,
|
|
486
|
-
scrollHeight: t.scrollHeight,
|
|
487
|
-
scrollWidth: t.scrollWidth,
|
|
488
|
-
clientHeight: t.clientHeight,
|
|
489
|
-
clientWidth: t.clientWidth,
|
|
490
|
-
isScrolling: B.isScrolling,
|
|
491
|
-
direction: B.direction
|
|
492
|
-
} : B;
|
|
493
|
-
},
|
|
494
|
-
getVisibleRange: () => ({ start: x.start, end: x.end }),
|
|
495
|
-
forceUpdate: () => Dt({}),
|
|
496
|
-
getContainer: () => y.current,
|
|
497
|
-
getItemElement: (t) => O.current.get(t) ?? null,
|
|
498
|
-
measureItem: async (t) => {
|
|
499
|
-
const e = O.current.get(t);
|
|
500
|
-
if (e) {
|
|
501
|
-
const l = { width: e.offsetWidth, height: e.offsetHeight };
|
|
502
|
-
return l.height > 0 && $.current.set(t, l.height), l;
|
|
503
|
-
}
|
|
504
|
-
const n = $.current.get(t);
|
|
505
|
-
return n ? { width: _.columnWidth, height: n } : { width: _.columnWidth, height: a?.estimateHeight ?? 0 };
|
|
506
|
-
}
|
|
507
|
-
}),
|
|
508
|
-
[Y, _, B, x, y, O, a?.estimateHeight]
|
|
509
|
-
);
|
|
510
|
-
const Jt = lt(() => {
|
|
511
|
-
if (!a) return o.map((e, n) => n);
|
|
512
|
-
const t = [];
|
|
513
|
-
for (let e = x.start; e <= x.end; e++) t.push(e);
|
|
514
|
-
return t;
|
|
515
|
-
}, [a, o, x.start, x.end]);
|
|
516
|
-
return /* @__PURE__ */ Kt(
|
|
517
|
-
"div",
|
|
518
|
-
{
|
|
519
|
-
ref: y,
|
|
520
|
-
style: {
|
|
521
|
-
position: "relative",
|
|
522
|
-
overflowX: "hidden",
|
|
523
|
-
overflowY: "auto",
|
|
524
|
-
...I
|
|
525
|
-
},
|
|
526
|
-
className: E,
|
|
527
|
-
onScroll: Ut,
|
|
528
|
-
"data-vane-waterfall": "",
|
|
529
|
-
children: [
|
|
530
|
-
Ft,
|
|
531
|
-
/* @__PURE__ */ $t(
|
|
532
|
-
"div",
|
|
533
|
-
{
|
|
534
|
-
style: {
|
|
535
|
-
position: "relative",
|
|
536
|
-
width: "100%",
|
|
537
|
-
height: _.totalHeight,
|
|
538
|
-
minWidth: 0
|
|
539
|
-
},
|
|
540
|
-
children: Jt.map((t) => {
|
|
541
|
-
const e = o[t];
|
|
542
|
-
if (e === void 0) return null;
|
|
543
|
-
const n = ct.get(t), l = n ? N ? {
|
|
544
|
-
position: "absolute",
|
|
545
|
-
transform: `translate(${n.x}px, ${n.y}px)`,
|
|
546
|
-
width: n.width,
|
|
547
|
-
boxSizing: "border-box"
|
|
548
|
-
} : {
|
|
549
|
-
position: "absolute",
|
|
550
|
-
left: n.x,
|
|
551
|
-
top: n.y,
|
|
552
|
-
width: n.width,
|
|
553
|
-
boxSizing: "border-box"
|
|
554
|
-
} : { position: "absolute", opacity: 0, pointerEvents: "none" };
|
|
555
|
-
return /* @__PURE__ */ $t(
|
|
556
|
-
"div",
|
|
557
|
-
{
|
|
558
|
-
ref: jt(t),
|
|
559
|
-
style: { ...l, ...S },
|
|
560
|
-
className: H,
|
|
561
|
-
onClick: (W) => Bt?.(t, e, W),
|
|
562
|
-
"data-index": t,
|
|
563
|
-
"data-column": n?.column,
|
|
564
|
-
children: p(e, t)
|
|
565
|
-
},
|
|
566
|
-
C(e, t)
|
|
567
|
-
);
|
|
568
|
-
})
|
|
569
|
-
}
|
|
570
|
-
)
|
|
571
|
-
]
|
|
572
|
-
}
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
);
|
|
576
|
-
export {
|
|
577
|
-
ue as W,
|
|
578
|
-
ne as a,
|
|
579
|
-
ie as b,
|
|
580
|
-
ee as c
|
|
581
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
function g(n = {}) {
|
|
2
|
-
const t = Math.max(1, n.threshold ?? 300);
|
|
3
|
-
let e = !1;
|
|
4
|
-
return {
|
|
5
|
-
name: "InfiniteScrollPlugin",
|
|
6
|
-
priority: 35,
|
|
7
|
-
enabled: !0,
|
|
8
|
-
hooks: {
|
|
9
|
-
transformProps: (o) => ({
|
|
10
|
-
...o,
|
|
11
|
-
reachBottomOffset: t
|
|
12
|
-
}),
|
|
13
|
-
onReachBottom: async (o, a) => {
|
|
14
|
-
if (e || o.hasMore === !1 || a > t) return;
|
|
15
|
-
const s = n.onLoadMore ?? o.props.onLoadMore;
|
|
16
|
-
if (typeof s == "function") {
|
|
17
|
-
e = !0;
|
|
18
|
-
try {
|
|
19
|
-
await Promise.resolve(s());
|
|
20
|
-
} finally {
|
|
21
|
-
e = !1;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
onUnmount: () => {
|
|
26
|
-
e = !1;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const r = "InfiniteScrollPlugin", i = "监听 Core 的 onReachBottom,在距底部 `threshold` 像素内触发 onLoadMore。自带并发锁:上一次还没结束不会重复触发。", l = "2.0.0", c = [
|
|
32
|
-
"data",
|
|
33
|
-
"加载更多"
|
|
34
|
-
], f = [
|
|
35
|
-
{
|
|
36
|
-
name: "threshold",
|
|
37
|
-
type: "number",
|
|
38
|
-
default: "300",
|
|
39
|
-
description: "触发距离 px"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "onLoadMore",
|
|
43
|
-
type: "() => void | Promise<void>",
|
|
44
|
-
default: "props.onLoadMore",
|
|
45
|
-
description: "加载回调"
|
|
46
|
-
}
|
|
47
|
-
], d = `// 滚动到距底部阈值内触发加载更多,带并发锁防重复请求。
|
|
48
|
-
const Waterfall = withPlugins(WaterfallCore, [
|
|
49
|
-
createInfiniteScrollPlugin({
|
|
50
|
-
threshold: 300,
|
|
51
|
-
}),
|
|
52
|
-
]);
|
|
53
|
-
|
|
54
|
-
<Waterfall items={items} renderItem={(item) => <Card data={item} />} />;`, u = [
|
|
55
|
-
"PaginationPlugin"
|
|
56
|
-
], m = [
|
|
57
|
-
"距底 300px 预加载,滚到底时数据已就位",
|
|
58
|
-
"并发锁:加载中不重复触发",
|
|
59
|
-
"context.hasMore 为 false 时自动停"
|
|
60
|
-
], p = [
|
|
61
|
-
"信息流无限滚动",
|
|
62
|
-
"画廊继续加载",
|
|
63
|
-
"搜索结果瀑布流"
|
|
64
|
-
], h = [
|
|
65
|
-
"阈值不要小于一屏(约 600px),否则用户滚到底会看到空白等待。",
|
|
66
|
-
"翻页类场景请用 PaginationPlugin,两者不要同装。"
|
|
67
|
-
], P = {
|
|
68
|
-
name: r,
|
|
69
|
-
description: i,
|
|
70
|
-
since: l,
|
|
71
|
-
tags: c,
|
|
72
|
-
config: f,
|
|
73
|
-
example: d,
|
|
74
|
-
conflicts: u,
|
|
75
|
-
features: m,
|
|
76
|
-
useCases: p,
|
|
77
|
-
notes: h
|
|
78
|
-
};
|
|
79
|
-
export {
|
|
80
|
-
g as c,
|
|
81
|
-
P as d
|
|
82
|
-
};
|